Made UI to update on idle program header icon update

Also made Atlantis happy
This commit is contained in:
Karolis2011
2016-01-26 21:16:55 +02:00
parent b185a3110a
commit 4550dfd644
@@ -12,6 +12,7 @@
var/last_power_usage = 0
var/last_battery_percent = 0 // Used for deciding if battery percentage has chandged
var/last_world_time = "00:00"
var/list/last_header_icons
var/computer_emagged = 0 // Whether the computer is emagged.
var/base_active_power_usage = 50 // Power usage when the computer is open (screen is active) and can be interacted with. Remember hardware can use power too.
@@ -210,11 +211,9 @@
P.ntnet_status = get_ntnet_status()
P.computer_emagged = computer_emagged
if(worldtime2text() != last_world_time)
last_world_time = worldtime2text()
update_uis()
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/modular_computer/proc/get_header_data()
@@ -388,11 +387,6 @@
if(battery_module)
battery_module.battery.use(power_usage * CELLRATE)
var/batery_percent = battery_module.battery.percent()
if(last_battery_percent != batery_percent) //Let's update UI on percent chandge
update_uis()
last_battery_percent = batery_percent
last_power_usage = power_usage
@@ -596,4 +590,30 @@
if(active_program.NM)
nanomanager.update_uis(active_program.NM)
else
nanomanager.update_uis(src)
nanomanager.update_uis(src)
/obj/item/modular_computer/proc/check_update_ui_need()
var/ui_updated_needed = 0
if(battery_module)
var/batery_percent = battery_module.battery.percent()
if(last_battery_percent != batery_percent) //Let's update UI on percent chandge
ui_updated_needed = 1
last_battery_percent = batery_percent
if(worldtime2text() != last_world_time)
last_world_time = worldtime2text()
ui_updated_needed = 1
if(idle_threads.len)
var/list/current_header_icons = list()
for(var/datum/computer_file/program/P in idle_threads)
if(!P.ui_header)
continue
current_header_icons[P.type] = P.ui_header
if (!(last_header_icons.len == current_header_icons.len && !length(last_header_icons^current_header_icons)))
last_header_icons = current_header_icons
ui_updated_needed = 1
if(ui_updated_needed)
update_uis