diff --git a/code/modules/mining/machine_processing.dm b/code/modules/mining/machine_processing.dm
index a436ab5dcd0..9e05c1caa1d 100644
--- a/code/modules/mining/machine_processing.dm
+++ b/code/modules/mining/machine_processing.dm
@@ -15,7 +15,7 @@
active_power_usage = 50
var/obj/machinery/mineral/processing_unit/machine
- var/show_all_ores = FALSE
+ var/show_all_ores = TRUE
var/points = 0
var/datum/weakref/scanned_id
@@ -83,7 +83,9 @@
if(id_turf && !id_turf.Adjacent(loc))
scanned_id = null
get_user_id(user)
- interact(user)
+ if(!setup_machine(user))
+ return
+ ui_interact(user)
/obj/machinery/mineral/processing_unit_console/proc/get_user_id(var/mob/user)
if(isDrone(user))
@@ -95,71 +97,55 @@
if(ID)
scanned_id = WEAKREF(ID)
-/obj/machinery/mineral/processing_unit_console/interact(mob/user)
- if(..())
- return
+/obj/machinery/mineral/processing_unit_console/ui_interact(mob/user, datum/tgui/ui)
+ ui = SStgui.try_update_ui(user, src, ui)
+ if(!ui)
+ ui = new(user, src, "MiningProcessor", "Ore Redemption Console", ui_x=500, ui_y=575)
+ ui.autoupdate = FALSE
+ ui.open()
- if(!setup_machine(user))
- return
-
- user.set_machine(src)
-
- var/dat = "
Ore processor console
"
-
- dat += "Current unclaimed points: [points]
"
-
- var/obj/item/card/id/ID = scanned_id.resolve()
+/obj/machinery/mineral/processing_unit_console/ui_data(mob/user)
+ var/list/data = list()
+ var/obj/item/card/id/ID = scanned_id?.resolve()
if(ID)
- dat += "You have [ID.mining_points] mining points collected. Eject ID.
"
- dat += "Claim points.
"
- dat += "Print yield declaration.
"
+ data["hasId"] = TRUE
+ data["miningPoints"] = ID.mining_points ? ID.mining_points : 0
else
- dat += "No ID inserted. Insert ID.
"
+ data["hasId"] = FALSE
- dat += "
"
+ data["enabled"] = machine.active
+ data["points"] = points
+ data["showAllOres"] = show_all_ores
+ var/list/ore_list = list()
for(var/ore in machine.ores_processing)
-
if(!machine.ores_stored[ore] && !show_all_ores)
continue
var/ore/O = ore_data[ore]
if(!O)
continue
- dat += "| [capitalize(O.display_name)] | [machine.ores_stored[ore]] | "
- if(machine.ores_processing[ore])
- switch(machine.ores_processing[ore])
- if(0)
- dat += "not processing"
- if(1)
- dat += "smelting"
- if(2)
- dat += "compressing"
- if(3)
- dat += "alloying"
- else
- dat += "not processing"
- dat += ". | \[change\] |
"
+ var/processing_type = ""
+ switch(machine.ores_processing[ore])
+ if(0)
+ processing_type = "Idle"
+ if(1)
+ processing_type = "Smelt"
+ if(2)
+ processing_type = "Compress"
+ if(3)
+ processing_type = "Alloy"
+ ore_list += list(list("name" = capitalize_first_letters(O.display_name), "processing" = processing_type, "stored" = machine.ores_stored[ore], "ore" = ore))
+ data["oreList"] = ore_list
+ return data
- dat += "
"
- dat += "Currently displaying [show_all_ores ? "all ore types" : "only available ore types"]. \[[show_all_ores ? "show less" : "show more"]\]"
- dat += "The ore processor is currently [(machine.active ? "processing" : "disabled")]."
-
- var/datum/browser/processor_win = new(user, "processor_console", capitalize_first_letters(name))
- processor_win.set_content(dat)
- processor_win.open()
-
-/obj/machinery/mineral/processing_unit_console/Topic(href, href_list)
+/obj/machinery/mineral/processing_unit_console/ui_act(action, params)
if(..())
return TRUE
- usr.set_machine(src)
- src.add_fingerprint(usr)
- if(href_list["choice"])
+ if(action == "choice")
var/obj/item/card/id/ID = scanned_id.resolve()
if(ID)
- if(href_list["choice"] == "eject")
- scanned_id = null
- if(href_list["choice"] == "claim")
+ if(params["choice"] == "claim")
if(access_mining_station in ID.access)
if(points >= 0)
ID.mining_points += points
@@ -170,21 +156,23 @@
to_chat(usr, SPAN_WARNING("[station_name()]'s mining division is currently indebted to NanoTrasen. Transaction incomplete until debt is cleared."))
else
to_chat(usr, SPAN_WARNING("Required access not found."))
- if(href_list["choice"] == "print_report")
+ if(params["choice"] == "print_report")
if(access_mining_station in ID.access)
print_report(usr)
else
to_chat(usr, SPAN_WARNING("Required access not found."))
-
- else if(href_list["choice"] == "insert")
+ else if(params["choice"] == "scan")
var/obj/item/card/id/I = usr.get_active_hand()
if(istype(I))
scanned_id = WEAKREF(I)
+ return TRUE
- if(href_list["toggle_smelting"])
- var/choice = input("What setting do you wish to use for processing [href_list["toggle_smelting"]]?") as null|anything in list("Smelting","Compressing","Alloying","Nothing")
+ if(action == "toggle_smelting")
+ var/ore_name = params["toggle_smelting"]
+
+ var/choice = input("What setting do you wish to use for processing [ore_name]?") as null|anything in list("Smelting", "Compressing", "Alloying", "Nothing")
if(!choice)
- return
+ return TRUE
switch(choice)
if("Nothing")
@@ -196,21 +184,20 @@
if("Alloying")
choice = 3
- machine.ores_processing[href_list["toggle_smelting"]] = choice
-
- if(href_list["toggle_power"])
+ machine.ores_processing[ore_name] = choice
+ return TRUE
+ if(action == "toggle_power")
machine.active = !machine.active
if(machine.active)
machine.icon_state = "furnace"
else
machine.icon_state = "furnace-off"
+ return TRUE
- if(href_list["toggle_ores"])
+ if(action == "toggle_ores")
show_all_ores = !show_all_ores
-
- src.updateUsrDialog()
- return
+ return TRUE
/obj/machinery/mineral/processing_unit_console/proc/print_report(var/mob/living/user)
var/obj/item/card/id/ID = scanned_id.resolve()
diff --git a/html/changelogs/geeves-tgui_mining_processor.yml b/html/changelogs/geeves-tgui_mining_processor.yml
new file mode 100644
index 00000000000..74cd739a340
--- /dev/null
+++ b/html/changelogs/geeves-tgui_mining_processor.yml
@@ -0,0 +1,6 @@
+author: Geeves
+
+delete-after: True
+
+changes:
+ - rscadd: "Converted the ore processor UI to TGUI."
diff --git a/tgui/packages/tgui/interfaces/MiningProcessor.tsx b/tgui/packages/tgui/interfaces/MiningProcessor.tsx
new file mode 100644
index 00000000000..0617c4fc654
--- /dev/null
+++ b/tgui/packages/tgui/interfaces/MiningProcessor.tsx
@@ -0,0 +1,122 @@
+import { useBackend } from '../backend';
+import { Button, Section, Box, Table } from '../components';
+import { Window } from '../layouts';
+
+export type OreListData = {
+ name: string;
+ processing: number;
+ stored: number;
+ ore: string;
+};
+
+export type MiningProcessorData = {
+ hasId: boolean;
+ enabled: boolean;
+ showAllOres: boolean;
+ miningPoints: number;
+ points: number;
+ oreList: OreListData[];
+};
+
+export const MiningProcessor = (props, context) => {
+ const { act, data } = useBackend(context);
+
+ return (
+
+
+
+ Current unclaimed points: {data.points}
+ {data.hasId ? (
+
+
+ You have {data.miningPoints} mining points collected.
+
+
+ ) : (
+
+ No ID detected.
+ act('choice', { choice: 'scan' })}
+ />
+
+ )}
+
+
+
+
+ Name
+ Stored
+ Setting
+
+ {data.oreList.map((ore) => (
+
+
+ {ore.name}
+
+ {ore.stored}
+
+
+ act('toggle_smelting', { toggle_smelting: ore.ore })
+ }
+ />
+
+
+ ))}
+
+
+
+
+
+
+
+ Currently displaying{' '}
+ {data.showAllOres
+ ? 'all ore types'
+ : 'only available ore types'}
+
+
+
+
+ act('toggle_ores')}
+ />
+
+
+
+
+
+
+ The ore processor is currently{' '}
+ {data.enabled ? 'processing' : 'disabled'}
+
+
+
+
+ act('toggle_power')}
+ />
+
+
+
+
+
+
+
+ );
+};