Adds XGM panel (#20045)

* Refactor

* XGM Panel

* Icon
This commit is contained in:
Exxion
2018-10-10 08:23:20 -04:00
committed by jknpj
parent 01ed24d754
commit 01bc6a8651
4 changed files with 129 additions and 13 deletions

View File

@@ -22,10 +22,15 @@
for(var/p in subtypesof(/datum/gas))
var/datum/gas/gas = new p()
if(gas.id in gases)
if(!add(gas))
stack_trace("Duplicate gas id '[gas.id]' in from typepath '[p]'")
continue
/datum/xgm_data/proc/add(var/datum/gas/gas)
if(gases[gas.id])
return FALSE
return update(gas)
/datum/xgm_data/proc/update(var/datum/gas/gas)
gases[gas.id] = gas
name[gas.id] = gas.name
short_name[gas.id] = gas.short_name || gas.name
@@ -36,5 +41,62 @@
tile_overlay[gas.id] = image('icons/effects/tile_effects.dmi', gas.tile_overlay, FLY_LAYER)
if(gas.overlay_limit)
overlay_limit[gas.id] = gas.overlay_limit
return TRUE
return 1
/datum/xgm_data/proc/update_id(var/id)
if(gases[id])
return update(gases[id])
return FALSE
/datum/xgm_data/proc/update_all()
for(var/id in gases)
update_id(id)
/datum/xgm_data/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = NANOUI_FOCUS)
var/list/data = list()
var/list/data_gases = list()
for(var/g in gases)
var/list/L = list()
L["id"] = g
L["name"] = name[g]
data_gases[++data_gases.len] = L //We have to use this syntax because += will concatenate the lists instead.
data["gases"] = data_gases
//Everything below this point is taken directly from an example implementation, other than the args to create the new UI.
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
// The ui does not exist, so we'll create a new one.
ui = new(user, src, ui_key, "XGM_data.tmpl", "XGM Panel", 550, 410, ignore_distance = TRUE)
// When the UI is first opened this is the data it will use.
ui.set_initial_data(data)
// Open the new ui window.
ui.open()
// Auto update every Master Controller tick.
ui.set_auto_update(1)
/datum/xgm_data/Topic(href, href_list)
if(..())
return TRUE
if(!check_rights(R_VAREDIT)) //Can't do anything useful with this without +VAREDIT anyway
return FALSE
if(href_list["edit"])
usr.client.debug_variables(gases[href_list["edit"]])
return TRUE
if(href_list["update"])
update_id(href_list["update"])
return TRUE
if(href_list["create"])
var/id = input("Enter new gasid") as text|null
if(!isnull(id))
if(gases[id])
alert("That gasid is already used.", "Duplicate gasid")
else
var/datum/gas/G = new()
G.id = id
add(G)
return TRUE

View File

@@ -714,6 +714,8 @@ var/global/floorIsLava = 0
<hr />
<A href='?src=\ref[src];vsc=airflow'>Edit ZAS Settings</A><br>
<A href='?src=\ref[src];vsc=default'>Choose a default ZAS setting</A><br>
<A href='?src=\ref[src];xgm_panel=1'>XGM Panel</A><br>
<hr />
"}
if(wages_enabled)

View File

@@ -4110,6 +4110,9 @@
if(href_list["vsc"] == "default")
zas_settings.SetDefault(usr)
else if(href_list["xgm_panel"])
XGM.ui_interact(usr)
else if(href_list["toglang"])
if(check_rights(R_SPAWN))
var/mob/M = locate(href_list["toglang"])

View File

@@ -0,0 +1,49 @@
<div class="statusDisplay">
<div class="line">
After editing a gas, press its update button to apply the changes.
</div>
<br>
<div class="line">
<span class="bad">DO NOT</span> change the <span class="blue">id</span> var on any gas. It will fuck everything up.
</div>
<br>
<div class="line">
When you create a new gas, it will be initialized with default values for all vars except <span class="blue">id</span>. Edit and update it as usual to set the values you want.
</div>
<br>
<div class="line">
To add your new gas (or any other gas, for that matter) to a gas_mixture:
</div>
<div class="line">
<div class="statusLabel">
1.
</div>
<div class="statusValue">
VV the gas_mixture.
</div>
</div>
<div class="line">
<div class="statusLabel">
2.
</div>
<div class="statusValue">
Add a string equal to the gas's <span class="blue">id</span> to the gas_mixture's <span class="blue">gas</span> list, and associate it with the desired number of moles.
</div>
</div>
</div>
<div class="itemGroup">
{{for data.gases}}
<div class="item">
<div class="itemLabel">
{{>value.name}}
</div>
<div class="itemContent">
{{:helper.link('Edit', 'pencil', {'edit' : value.id})}}
{{:helper.link('Update', 'refresh', {'update' : value.id})}}
</div>
</div>
{{/for}}
<div class="item">
{{:helper.link('Create New', 'plus', {'create' : 1})}}
</div>
</div>