Skip to content

Commit

Permalink
Merge pull request #4746 from out-of-phaze/codequality/ontopic
Browse files Browse the repository at this point in the history
Convert many Topic overrides to use OnTopic instead
  • Loading branch information
MistakeNot4892 authored Feb 1, 2025
2 parents 7d09291 + 9ce3e7b commit 602924b
Show file tree
Hide file tree
Showing 73 changed files with 1,512 additions and 1,515 deletions.
3 changes: 2 additions & 1 deletion code/datums/communication/dsay.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
mute_setting = MUTE_DEADCHAT
show_preference_setting = /datum/client_preference/show_dsay

// Changes the default speech_method kwarg.
/decl/communication_channel/dsay/communicate(communicator, message, speech_method = /decl/dsay_communication/say)
..()
return ..()

/decl/communication_channel/dsay/can_communicate(var/client/communicator, var/message, var/speech_method_type)
var/decl/dsay_communication/speech_method = GET_DECL(speech_method_type)
Expand Down
2 changes: 1 addition & 1 deletion code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@
Used for atoms performing audible actions
- `message`: The string to show to anyone who can hear this atom
- `dead_message?`: The string deaf mobs will see
- `deaf_message?`: The string deaf mobs will see
- `hearing_distance?`: The number of tiles away the message can be heard. Defaults to world.view
- `check_ghosts?`: TRUE if ghosts should hear the message if their preferences allow
- `radio_message?`: The string to send over radios
Expand Down
10 changes: 10 additions & 0 deletions code/game/machinery/_machines_base/machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ Class Procs:
/obj/machinery/CouldNotUseTopic(var/mob/user)
user.unset_machine()

// This must not be converted to use OnTopic.
// mechanics_text and power_text can be done at a distance (via examination)
// while the TOPIC_REFRESH handling must come after OnTopic has resolved in the parent call of Topic.
/obj/machinery/Topic(href, href_list, datum/topic_state/state)
if(href_list["mechanics_text"] && construct_state) // This is an OOC examine thing handled via Topic; specifically bypass all checks, but do nothing other than message to chat.
var/list/info = get_tool_manipulation_info()
Expand All @@ -254,6 +257,13 @@ Class Procs:
. = ..()
if(. == TOPIC_REFRESH)
updateUsrDialog() // Update legacy UIs to the extent possible.
SSnano.update_uis(src) // And our modern NanoUI ones, too.
update_icon() // A lot of machines like to do icon updates on refresh, so we'll handle it for them here.
else if(. == TOPIC_CLOSE)
usr.unset_machine()
var/datum/nanoui/open_ui = SSnano.get_open_ui(usr, src, "main")
if(open_ui)
open_ui.close()

/obj/machinery/proc/get_tool_manipulation_info()
return construct_state?.mechanics_info()
Expand Down
31 changes: 14 additions & 17 deletions code/game/machinery/atmo_control.dm
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@

data["automation"] = automation

/obj/machinery/computer/air_control/Process()
..()

/obj/machinery/computer/air_control/receive_signal(datum/signal/signal)
if(!signal || signal.encryption)
return
Expand Down Expand Up @@ -148,56 +145,56 @@
if(href_list["in_refresh_status"])
input_info = null
refreshing_input = TRUE
signal.data = list ("tag" = input_tag, "status" = 1)
signal.data = list("tag" = input_tag, "status" = 1)
. = 1

if(href_list["in_toggle_injector"])
input_info = null
refreshing_input = TRUE
signal.data = list ("tag" = input_tag, "power_toggle" = 1)
signal.data = list("tag" = input_tag, "power_toggle" = 1)
. = 1

if(href_list["in_set_flowrate"])
input_info = null
refreshing_input = TRUE
input_flow_setting = input("What would you like to set the rate limit to?", "Set Volume", input_flow_setting) as num|null
input_flow_setting = input(user, "What would you like to set the rate limit to?", "Set Volume", input_flow_setting) as num|null
input_flow_setting = clamp(input_flow_setting, 0, ATMOS_DEFAULT_VOLUME_PUMP+500)
signal.data = list ("tag" = input_tag, "set_volume_rate" = input_flow_setting)
signal.data = list("tag" = input_tag, "set_volume_rate" = input_flow_setting)
. = 1

if(href_list["in_set_max"])
input_info = null
refreshing_input = TRUE
input_flow_setting = ATMOS_DEFAULT_VOLUME_PUMP+500
signal.data = list ("tag" = input_tag, "set_volume_rate" = input_flow_setting)
signal.data = list("tag" = input_tag, "set_volume_rate" = input_flow_setting)
. = 1

if(href_list["out_refresh_status"])
output_info = null
refreshing_output = TRUE
signal.data = list ("tag" = output_tag, "status" = 1)
signal.data = list("tag" = output_tag, "status" = 1)
. = 1

if(href_list["out_toggle_power"])
output_info = null
refreshing_output = TRUE
signal.data = list ("tag" = output_tag, "power_toggle" = 1, "status" = 1)
signal.data = list("tag" = output_tag, "power_toggle" = 1, "status" = 1)
. = 1

if(href_list["out_set_pressure"])
output_info = null
refreshing_output = TRUE
pressure_setting = input("How much pressure would you like to output?", "Set Pressure", pressure_setting) as num|null
pressure_setting = input(user, "How much pressure would you like to output?", "Set Pressure", pressure_setting) as num|null
pressure_setting = clamp(pressure_setting, 0, MAX_PUMP_PRESSURE)
signal.data = list ("tag" = output_tag, "set_internal_pressure" = "[pressure_setting]", "status" = 1)
signal.data = list("tag" = output_tag, "set_internal_pressure" = "[pressure_setting]", "status" = 1)
. = 1

if(href_list["s_out_set_pressure"])
output_info = null
refreshing_output = TRUE
pressure_setting = input("How much pressure would you like to maintain inside the core?", "Set Core Pressure", pressure_setting) as num|null
pressure_setting = input(user, "How much pressure would you like to maintain inside the core?", "Set Core Pressure", pressure_setting) as num|null
pressure_setting = clamp(pressure_setting, 0, MAX_PUMP_PRESSURE)
signal.data = list ("tag" = output_tag, "set_external_pressure" = pressure_setting, "checks" = 1, "status" = 1)
signal.data = list("tag" = output_tag, "set_external_pressure" = pressure_setting, "checks" = 1, "status" = 1)
. = 1

if(href_list["s_set_default"])
Expand All @@ -210,11 +207,11 @@
output_info = null
refreshing_output = TRUE
pressure_setting = MAX_PUMP_PRESSURE
signal.data = list ("tag" = output_tag, "set_internal_pressure" = pressure_setting, "status" = 1)
signal.data = list("tag" = output_tag, "set_internal_pressure" = pressure_setting, "status" = 1)
. = 1

if(href_list["set_frequency"])
var/F = input("What frequency would you like to set this to? (Decimal is added automatically)", "Adjust Frequency", frequency) as num|null
var/F = input(user, "What frequency would you like to set this to? (Decimal is added automatically)", "Adjust Frequency", frequency) as num|null
if(F)
frequency = F
set_frequency(F)
Expand Down Expand Up @@ -291,7 +288,7 @@
else
..(signal)

/obj/machinery/computer/air_control/fuel_injection/Topic(href, href_list)
/obj/machinery/computer/air_control/fuel_injection/OnTopic(mob/user, href_list, datum/topic_state/state)
if((. = ..()))
return

Expand Down
14 changes: 7 additions & 7 deletions code/game/machinery/computer/area_atmos.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,25 @@
show_browser(user, "[dat]", "window=miningshuttle;size=400x400")
status = ""

/obj/machinery/computer/area_atmos/Topic(href, href_list)
if(..())
/obj/machinery/computer/area_atmos/OnTopic(mob/user, href_list)
if((. = ..()))
return
usr.set_machine(src)


if(href_list["scan"])
scanscrubbers()
return TOPIC_REFRESH
else if(href_list["toggle"])
var/obj/machinery/portable_atmospherics/powered/scrubber/huge/scrubber = locate(href_list["scrub"])

if(!validscrubber(scrubber))
spawn(20)
spawn(2 SECONDS)
status = "ERROR: Couldn't connect to scrubber! (timeout)"
connectedscrubbers -= scrubber
src.updateUsrDialog()
return
updateUsrDialog()
return TOPIC_REFRESH

scrubber.update_use_power(text2num(href_list["toggle"]) ? POWER_USE_ACTIVE : POWER_USE_IDLE)
return TOPIC_REFRESH

/obj/machinery/computer/area_atmos/proc/validscrubber(var/obj/machinery/portable_atmospherics/powered/scrubber/huge/scrubber)
if(!isobj(scrubber) || get_dist(scrubber.loc, src.loc) > src.range || scrubber.loc.z != src.loc.z)
Expand Down
Loading

0 comments on commit 602924b

Please sign in to comment.