From aabe06f616f98484fe38e7690f99ebce4e4e4dbf Mon Sep 17 00:00:00 2001 From: ShadowLarkens Date: Thu, 20 Aug 2020 19:37:55 -0700 Subject: [PATCH] Enable TGUI --- code/modules/client/client defines.dm | 2 +- .../volume_sliders/01_volume.dm | 68 +++++++++---------- tgui/packages/tgui/interfaces/VolumePanel.js | 10 ++- tgui/packages/tgui/public/tgui.bundle.js | 12 ++-- 4 files changed, 49 insertions(+), 43 deletions(-) diff --git a/code/modules/client/client defines.dm b/code/modules/client/client defines.dm index 22d7dc3aa9..2c0d6ca7ac 100644 --- a/code/modules/client/client defines.dm +++ b/code/modules/client/client defines.dm @@ -24,7 +24,7 @@ var/time_died_as_mouse = null //when the client last died as a mouse var/datum/tooltip/tooltips = null var/datum/chatOutput/chatOutput - // var/datum/volume_panel/volume_panel = null // Initialized by /client/verb/volume_panel() + var/datum/volume_panel/volume_panel = null // Initialized by /client/verb/volume_panel() var/chatOutputLoadedAt var/adminhelped = 0 diff --git a/code/modules/client/preference_setup/volume_sliders/01_volume.dm b/code/modules/client/preference_setup/volume_sliders/01_volume.dm index 4458573ab2..5a65b99f40 100644 --- a/code/modules/client/preference_setup/volume_sliders/01_volume.dm +++ b/code/modules/client/preference_setup/volume_sliders/01_volume.dm @@ -62,46 +62,46 @@ // Neat little volume adjuster thing in case you don't wanna touch preferences by hand you lazy fuck // Currently unimplemented due to lack of TGUI v4 -// /datum/volume_panel -// /datum/volume_panel/tgui_state(mob/user) -// return GLOB.tgui_always_state +/datum/volume_panel +/datum/volume_panel/tgui_state(mob/user) + return GLOB.tgui_always_state -// /datum/volume_panel/tgui_interact(mob/user, datum/tgui/ui, datum/tgui/parent_ui) -// ui = SStgui.try_update_ui(user, src, ui) -// if(!ui) -// ui = new(user, src, "VolumePanel", "Volume Panel") -// ui.open() +/datum/volume_panel/tgui_interact(mob/user, datum/tgui/ui, datum/tgui/parent_ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "VolumePanel", "Volume Panel") + ui.open() -// /datum/volume_panel/tgui_data(mob/user) -// if(!user.client || !user.client.prefs) -// return list("error" = TRUE) +/datum/volume_panel/tgui_data(mob/user) + if(!user.client || !user.client.prefs) + return list("error" = TRUE) -// var/list/data = ..() -// data["volume_channels"] = user.client.prefs.volume_channels -// return data + var/list/data = ..() + data["volume_channels"] = user.client.prefs.volume_channels + return data -// /datum/volume_panel/tgui_act(action, params) -// if(..()) -// return TRUE +/datum/volume_panel/tgui_act(action, params) + if(..()) + return TRUE -// if(!usr?.client?.prefs) -// return TRUE + if(!usr?.client?.prefs) + return TRUE -// var/datum/preferences/P = usr.client.prefs -// switch(action) -// if("adjust_volume") -// var/channel = params["channel"] -// if(channel in P.volume_channels) -// P.volume_channels["[channel]"] = clamp(params["vol"], 0, 2) -// SScharacter_setup.queue_preferences_save(P) -// return TRUE + var/datum/preferences/P = usr.client.prefs + switch(action) + if("adjust_volume") + var/channel = params["channel"] + if(channel in P.volume_channels) + P.volume_channels["[channel]"] = clamp(params["vol"], 0, 2) + SScharacter_setup.queue_preferences_save(P) + return TRUE -// /client/verb/volume_panel() -// set name = "Volume Panel" -// set category = "Preferences" -// set desc = "Allows you to adjust volume levels on the fly." +/client/verb/volume_panel() + set name = "Volume Panel" + set category = "Preferences" + set desc = "Allows you to adjust volume levels on the fly." -// if(!volume_panel) -// volume_panel = new(src) + if(!volume_panel) + volume_panel = new(src) -// volume_panel.tgui_interact(mob) + volume_panel.tgui_interact(mob) diff --git a/tgui/packages/tgui/interfaces/VolumePanel.js b/tgui/packages/tgui/interfaces/VolumePanel.js index 33bc883fb0..fa964c06eb 100644 --- a/tgui/packages/tgui/interfaces/VolumePanel.js +++ b/tgui/packages/tgui/interfaces/VolumePanel.js @@ -23,11 +23,17 @@ export const VolumePanel = (props, context) => { minValue={0} maxValue={200} value={volume_channels[key] * 100} - onChange={(e, val) => act("adjust_volume", { channel: key, vol: (val / 100) })} /> + onChange={(e, val) => act("adjust_volume", { + channel: key, + vol: (val / 100), + })} />