From aa35c4cef3eca452e5236c8e0226db54c6410a55 Mon Sep 17 00:00:00 2001 From: davipatury Date: Mon, 20 Feb 2017 09:13:37 -0300 Subject: [PATCH] No copypasta' --- .../computers/item/computer.dm | 58 ------------------- .../computers/item/computer_ui.dm | 58 +++++++++++++++++++ .../file_system/programs/ntdownloader.dm | 2 +- nano/layouts/layout_default.tmpl | 36 ++++++++++++ nano/templates/computer_main.tmpl | 35 ----------- nano/templates/file_manager.tmpl | 35 ----------- nano/templates/laptop_configuration.tmpl | 37 +----------- nano/templates/ntnet_chat.tmpl | 35 ----------- nano/templates/ntnet_dos.tmpl | 41 +------------ nano/templates/ntnet_downloader.tmpl | 35 ----------- nano/templates/ntnet_transfer.tmpl | 35 ----------- 11 files changed, 99 insertions(+), 308 deletions(-) diff --git a/code/modules/modular_computers/computers/item/computer.dm b/code/modules/modular_computers/computers/item/computer.dm index 3410cc0d06c..2505024ff4a 100644 --- a/code/modules/modular_computers/computers/item/computer.dm +++ b/code/modules/modular_computers/computers/item/computer.dm @@ -272,64 +272,6 @@ handle_power() // Handles all computer power interaction //check_update_ui_need() -// Function used by NanoUI's to obtain data for header. All relevant entries begin with "PC_" -/obj/item/device/modular_computer/proc/get_header_data() - var/list/data = list() - - var/obj/item/weapon/computer_hardware/battery/battery_module = all_components[MC_CELL] - var/obj/item/weapon/computer_hardware/recharger/recharger = all_components[MC_CHARGE] - - if(battery_module && battery_module.battery) - switch(battery_module.battery.percent()) - if(80 to 200) // 100 should be maximal but just in case.. - data["PC_batteryicon"] = "batt_100.gif" - if(60 to 80) - data["PC_batteryicon"] = "batt_80.gif" - if(40 to 60) - data["PC_batteryicon"] = "batt_60.gif" - if(20 to 40) - data["PC_batteryicon"] = "batt_40.gif" - if(5 to 20) - data["PC_batteryicon"] = "batt_20.gif" - else - data["PC_batteryicon"] = "batt_5.gif" - data["PC_batterypercent"] = "[round(battery_module.battery.percent())] %" - data["PC_showbatteryicon"] = 1 - else - data["PC_batteryicon"] = "batt_5.gif" - data["PC_batterypercent"] = "N/C" - data["PC_showbatteryicon"] = battery_module ? 1 : 0 - - if(recharger && recharger.enabled && recharger.check_functionality() && recharger.use_power(0)) - data["PC_apclinkicon"] = "charging.gif" - - switch(get_ntnet_status()) - if(0) - data["PC_ntneticon"] = "sig_none.gif" - if(1) - data["PC_ntneticon"] = "sig_low.gif" - if(2) - data["PC_ntneticon"] = "sig_high.gif" - if(3) - data["PC_ntneticon"] = "sig_lan.gif" - - if(idle_threads.len) - var/list/program_headers = list() - for(var/I in idle_threads) - var/datum/computer_file/program/P = I - if(!P.ui_header) - continue - program_headers.Add(list(list( - "icon" = P.ui_header - ))) - - data["PC_programheaders"] = program_headers - - data["PC_stationtime"] = worldtime2text() - data["PC_hasheader"] = 1 - data["PC_showexitprogram"] = active_program ? 1 : 0 // Hides "Exit Program" button on mainscreen - return data - // Relays kill program request to currently active program. Use this to quit current program. /obj/item/device/modular_computer/proc/kill_program(forced = FALSE) if(active_program) diff --git a/code/modules/modular_computers/computers/item/computer_ui.dm b/code/modules/modular_computers/computers/item/computer_ui.dm index 4fb9615b061..7df664a1bb4 100644 --- a/code/modules/modular_computers/computers/item/computer_ui.dm +++ b/code/modules/modular_computers/computers/item/computer_ui.dm @@ -51,6 +51,64 @@ return data +// Function used by NanoUI's to obtain data for header. All relevant entries begin with "PC_" +/obj/item/device/modular_computer/proc/get_header_data() + var/list/data = list() + + var/obj/item/weapon/computer_hardware/battery/battery_module = all_components[MC_CELL] + var/obj/item/weapon/computer_hardware/recharger/recharger = all_components[MC_CHARGE] + + if(battery_module && battery_module.battery) + switch(battery_module.battery.percent()) + if(80 to 200) // 100 should be maximal but just in case.. + data["PC_batteryicon"] = "batt_100.gif" + if(60 to 80) + data["PC_batteryicon"] = "batt_80.gif" + if(40 to 60) + data["PC_batteryicon"] = "batt_60.gif" + if(20 to 40) + data["PC_batteryicon"] = "batt_40.gif" + if(5 to 20) + data["PC_batteryicon"] = "batt_20.gif" + else + data["PC_batteryicon"] = "batt_5.gif" + data["PC_batterypercent"] = "[round(battery_module.battery.percent())] %" + data["PC_showbatteryicon"] = 1 + else + data["PC_batteryicon"] = "batt_5.gif" + data["PC_batterypercent"] = "N/C" + data["PC_showbatteryicon"] = battery_module ? 1 : 0 + + if(recharger && recharger.enabled && recharger.check_functionality() && recharger.use_power(0)) + data["PC_apclinkicon"] = "charging.gif" + + switch(get_ntnet_status()) + if(0) + data["PC_ntneticon"] = "sig_none.gif" + if(1) + data["PC_ntneticon"] = "sig_low.gif" + if(2) + data["PC_ntneticon"] = "sig_high.gif" + if(3) + data["PC_ntneticon"] = "sig_lan.gif" + + if(idle_threads.len) + var/list/program_headers = list() + for(var/I in idle_threads) + var/datum/computer_file/program/P = I + if(!P.ui_header) + continue + program_headers.Add(list(list( + "icon" = P.ui_header + ))) + + data["PC_programheaders"] = program_headers + + data["PC_stationtime"] = worldtime2text() + data["PC_hasheader"] = 1 + data["PC_showexitprogram"] = active_program ? 1 : 0 // Hides "Exit Program" button on mainscreen + return data + // Handles user's GUI input /obj/item/device/modular_computer/Topic(href, list/href_list) diff --git a/code/modules/modular_computers/file_system/programs/ntdownloader.dm b/code/modules/modular_computers/file_system/programs/ntdownloader.dm index 2a35dd7b8d8..ca4ea4eace0 100644 --- a/code/modules/modular_computers/file_system/programs/ntdownloader.dm +++ b/code/modules/modular_computers/file_system/programs/ntdownloader.dm @@ -128,7 +128,7 @@ data["downloaddesc"] = downloaded_file.filedesc data["downloadsize"] = downloaded_file.size data["downloadspeed"] = download_netspeed - data["downloadcompletion"] = round(download_completion, 0.1) + data["downloadcompletion"] = round(min(download_completion, downloaded_file.size), 0.1) else // No download running, pick file. var/obj/item/weapon/computer_hardware/hard_drive/hard_drive = my_computer.all_components[MC_HDD] data["disk_size"] = hard_drive.max_capacity diff --git a/nano/layouts/layout_default.tmpl b/nano/layouts/layout_default.tmpl index 1c270ee4c18..c0832fb6803 100644 --- a/nano/layouts/layout_default.tmpl +++ b/nano/layouts/layout_default.tmpl @@ -31,6 +31,42 @@ +{{if data.PC_hasheader}} +
+
+ + {{if data.PC_batteryicon && data.PC_showbatteryicon}} +
+ {{/if}} + {{if data.PC_batterypercent && data.PC_showbatteryicon}} + {{:data.PC_batterypercent}} + {{/if}} + {{if data.PC_ntneticon}} + + {{/if}} + {{if data.PC_apclinkicon}} + + {{/if}} + {{if data.PC_stationtime}} + {{:data.PC_stationtime}} + {{/if}} + {{for data.PC_programheaders}} + + {{/for}} +
+
+
+
+ +
{{:helper.link('Shutdown', null, {'action' : 'PC_shutdown'})}} + {{if data.PC_showexitprogram}} + {{:helper.link('EXIT PROGRAM', null, {'action' : 'PC_exit'})}} + {{:helper.link('Minimize Program', null, {'action' : 'PC_minimize'})}} + {{/if}} +
+
+
+{{/if}}
Initiating...
diff --git a/nano/templates/computer_main.tmpl b/nano/templates/computer_main.tmpl index 6dfaa26ff66..c11be44be5c 100644 --- a/nano/templates/computer_main.tmpl +++ b/nano/templates/computer_main.tmpl @@ -1,38 +1,3 @@ -
-
- - {{if data.PC_batteryicon && data.PC_showbatteryicon}} -
- {{/if}} - {{if data.PC_batterypercent && data.PC_showbatteryicon}} - {{:data.PC_batterypercent}} - {{/if}} - {{if data.PC_ntneticon}} - - {{/if}} - {{if data.PC_apclinkicon}} - - {{/if}} - {{if data.PC_stationtime}} - {{:data.PC_stationtime}} - {{/if}} - {{for data.PC_programheaders}} - - {{/for}} -
-
-
-
- -
{{:helper.link('Shutdown', null, {'action' : 'PC_shutdown'})}} - {{if data.PC_showexitprogram}} - {{:helper.link('EXIT PROGRAM', null, {'action' : 'PC_exit'})}} - {{:helper.link('Minimize Program', null, {'action' : 'PC_minimize'})}} - {{/if}} -
-
-
- No program loaded. Please select program from list below.
diff --git a/nano/templates/file_manager.tmpl b/nano/templates/file_manager.tmpl index 271bc8822b7..7cf1dd8a676 100644 --- a/nano/templates/file_manager.tmpl +++ b/nano/templates/file_manager.tmpl @@ -1,38 +1,3 @@ -
-
-
- {{if data.PC_batteryicon && data.PC_showbatteryicon}} -
- {{/if}} - {{if data.PC_batterypercent && data.PC_showbatteryicon}} - {{:data.PC_batterypercent}} - {{/if}} - {{if data.PC_ntneticon}} - - {{/if}} - {{if data.PC_apclinkicon}} - - {{/if}} - {{if data.PC_stationtime}} - {{:data.PC_stationtime}} - {{/if}} - {{for data.PC_programheaders}} - - {{/for}} -
-
-
-
- -
{{:helper.link('Shutdown', null, {'action' : 'PC_shutdown'})}} - {{if data.PC_showexitprogram}} - {{:helper.link('EXIT PROGRAM', null, {'action' : 'PC_exit'})}} - {{:helper.link('Minimize Program', null, {'action' : 'PC_minimize'})}} - {{/if}} -
-
-
- {{if data.error}}

An error has occurred and this program can not continue.

Additional information: {{:data.error}}
diff --git a/nano/templates/laptop_configuration.tmpl b/nano/templates/laptop_configuration.tmpl index 41ab8f74e02..07c499d7158 100644 --- a/nano/templates/laptop_configuration.tmpl +++ b/nano/templates/laptop_configuration.tmpl @@ -1,38 +1,3 @@ -
-
- - {{if data.PC_batteryicon && data.PC_showbatteryicon}} -
- {{/if}} - {{if data.PC_batterypercent && data.PC_showbatteryicon}} - {{:data.PC_batterypercent}} - {{/if}} - {{if data.PC_ntneticon}} - - {{/if}} - {{if data.PC_apclinkicon}} - - {{/if}} - {{if data.PC_stationtime}} - {{:data.PC_stationtime}} - {{/if}} - {{for data.PC_programheaders}} - - {{/for}} -
-
-
-
- -
{{:helper.link('Shutdown', null, {'action' : 'PC_shutdown'})}} - {{if data.PC_showexitprogram}} - {{:helper.link('EXIT PROGRAM', null, {'action' : 'PC_exit'})}} - {{:helper.link('Minimize Program', null, {'action' : 'PC_minimize'})}} - {{/if}} -
-
-
- Welcome to computer configuration utility. Please consult your system administrator if you have any questions about your device.

Power Supply

@@ -69,7 +34,7 @@

File System

Used Capacity
- {{:helper.displayBar(data.disk_used, 0, data.disk_size, (data.disk_used > data.disk_size/2) ? 'bad' : (data.disk_used > data.disk_size/4) ? 'average' : 'good')}} + {{:helper.displayBar(data.disk_used, 0, data.disk_size, (data.disk_used > data.disk_size*0.75) ? 'bad' : (data.disk_used > data.disk_size/2) ? 'average' : 'good')}}
{{:helper.smoothRound(data.disk_used, 1)}}/{{:data.disk_size}}GQ
diff --git a/nano/templates/ntnet_chat.tmpl b/nano/templates/ntnet_chat.tmpl index 02287508ab8..c3f2573f8e2 100644 --- a/nano/templates/ntnet_chat.tmpl +++ b/nano/templates/ntnet_chat.tmpl @@ -1,38 +1,3 @@ -
-
- - {{if data.PC_batteryicon && data.PC_showbatteryicon}} -
- {{/if}} - {{if data.PC_batterypercent && data.PC_showbatteryicon}} - {{:data.PC_batterypercent}} - {{/if}} - {{if data.PC_ntneticon}} - - {{/if}} - {{if data.PC_apclinkicon}} - - {{/if}} - {{if data.PC_stationtime}} - {{:data.PC_stationtime}} - {{/if}} - {{for data.PC_programheaders}} - - {{/for}} -
-
-
-
- -
{{:helper.link('Shutdown', null, {'action' : 'PC_shutdown'})}} - {{if data.PC_showexitprogram}} - {{:helper.link('EXIT PROGRAM', null, {'action' : 'PC_exit'})}} - {{:helper.link('Minimize Program', null, {'action' : 'PC_minimize'})}} - {{/if}} -
-
-
- {{if data.adminmode}}

ADMINISTRATIVE MODE

{{/if}} diff --git a/nano/templates/ntnet_dos.tmpl b/nano/templates/ntnet_dos.tmpl index 7243901cbd8..93faa096bfe 100644 --- a/nano/templates/ntnet_dos.tmpl +++ b/nano/templates/ntnet_dos.tmpl @@ -1,38 +1,4 @@ -
-
- - {{if data.PC_batteryicon && data.PC_showbatteryicon}} -
- {{/if}} - {{if data.PC_batterypercent && data.PC_showbatteryicon}} - {{:data.PC_batterypercent}} - {{/if}} - {{if data.PC_ntneticon}} - - {{/if}} - {{if data.PC_apclinkicon}} - - {{/if}} - {{if data.PC_stationtime}} - {{:data.PC_stationtime}} - {{/if}} - {{for data.PC_programheaders}} - - {{/for}} -
-
-
-
- -
{{:helper.link('Shutdown', null, {'action' : 'PC_shutdown'})}} - {{if data.PC_showexitprogram}} - {{:helper.link('EXIT PROGRAM', null, {'action' : 'PC_exit'})}} - {{:helper.link('Minimize Program', null, {'action' : 'PC_minimize'})}} - {{/if}} -
-
-
- +{{:helper.syndicateMode()}} {{if data.error}} ##SYSTEM ERROR: {{:data.error}}{{:helper.link('RESET', null, {'action' : 'PRG_reset'})}} {{else data.target}} @@ -47,14 +13,13 @@
Targeted device ID:
{{if data.focus}}{{:data.focus}}{{else}}None{{/if}}
-
- {{:helper.link('EXECUTE', null, {'action' : 'PRG_execute'})}}
+ {{:helper.link('EXECUTE', null, { 'PRG_execute' : 1 })}}
Detected devices on network:
{{for data.relays}} -
{{:helper.link(value.id, null, {'action' : 'PRG_target_relay', 'targid' : value.id})}} +
{{:helper.link(value.id, null, {'action' : 'PRG_target_relay', 'targid' : value.id})}} {{/for}}
{{/if}} \ No newline at end of file diff --git a/nano/templates/ntnet_downloader.tmpl b/nano/templates/ntnet_downloader.tmpl index 5a60e7d0556..3582a48bf7c 100644 --- a/nano/templates/ntnet_downloader.tmpl +++ b/nano/templates/ntnet_downloader.tmpl @@ -1,38 +1,3 @@ -
-
- - {{if data.PC_batteryicon && data.PC_showbatteryicon}} -
- {{/if}} - {{if data.PC_batterypercent && data.PC_showbatteryicon}} - {{:data.PC_batterypercent}} - {{/if}} - {{if data.PC_ntneticon}} - - {{/if}} - {{if data.PC_apclinkicon}} - - {{/if}} - {{if data.PC_stationtime}} - {{:data.PC_stationtime}} - {{/if}} - {{for data.PC_programheaders}} - - {{/for}} -
-
-
-
- -
{{:helper.link('Shutdown', null, {'action' : 'PC_shutdown'})}} - {{if data.PC_showexitprogram}} - {{:helper.link('EXIT PROGRAM', null, {'action' : 'PC_exit'})}} - {{:helper.link('Minimize Program', null, {'action' : 'PC_minimize'})}} - {{/if}} -
-
-
- Welcome to software download utility. Please select which software you wish to download.
{{if data.error}}

Download Error

diff --git a/nano/templates/ntnet_transfer.tmpl b/nano/templates/ntnet_transfer.tmpl index 9495df39bf1..660838b94dc 100644 --- a/nano/templates/ntnet_transfer.tmpl +++ b/nano/templates/ntnet_transfer.tmpl @@ -1,38 +1,3 @@ -
-
- - {{if data.PC_batteryicon && data.PC_showbatteryicon}} -
- {{/if}} - {{if data.PC_batterypercent && data.PC_showbatteryicon}} - {{:data.PC_batterypercent}} - {{/if}} - {{if data.PC_ntneticon}} - - {{/if}} - {{if data.PC_apclinkicon}} - - {{/if}} - {{if data.PC_stationtime}} - {{:data.PC_stationtime}} - {{/if}} - {{for data.PC_programheaders}} - - {{/for}} -
-
-
-
- -
{{:helper.link('Shutdown', null, {'action' : 'PC_shutdown'})}} - {{if data.PC_showexitprogram}} - {{:helper.link('EXIT PROGRAM', null, {'action' : 'PC_exit'})}} - {{:helper.link('Minimize Program', null, {'action' : 'PC_minimize'})}} - {{/if}} -
-
-
- {{if data.error}}

An error has occurred during operation...