Adds battery status icon to NTOS

- Laptops now have status icon which shows status of their internal battery.
- Adds support for "status bar" - allows more status icons in future (such as, network connection? time? whatever), status bar icons should be 16x16px
This commit is contained in:
Atlantiscze
2014-07-20 15:15:29 +02:00
parent 69ab22896b
commit c127fee6b4
9 changed files with 38 additions and 0 deletions

View File

@@ -165,6 +165,8 @@
<body><div style='width:640px;height:480px; border:2px solid black;padding:8px;background-position:center;background-image:url(\ref['nano/images/uiBackground.png'])'>"} <body><div style='width:640px;height:480px; border:2px solid black;padding:8px;background-position:center;background-image:url(\ref['nano/images/uiBackground.png'])'>"}
dat += generate_status_bar()
var/list/files = list_files() var/list/files = list_files()
if(current) if(current)
dat +=window(current.name,buttonbar(),filegrid(files)) dat +=window(current.name,buttonbar(),filegrid(files))
@@ -176,6 +178,32 @@
usr << browse(dat, "window=\ref[computer];size=670x510") usr << browse(dat, "window=\ref[computer];size=670x510")
onclose(usr, "\ref[computer]") onclose(usr, "\ref[computer]")
// STATUS BAR
// Small 16x16 icons representing status of components, etc.
// Currently only used by battery icon
// TODO: Add more icons!
/datum/file/program/ntos/proc/generate_status_bar()
var/dat = ""
// Battery level icon
switch(computer.check_battery_status())
if(-1)
dat += "<img src=\ref['icons/ntos/battery_icons/batt_none.gif']>"
if(0 to 5)
dat += "<img src=\ref['icons/ntos/battery_icons/batt_5.gif']>"
if(6 to 20)
dat += "<img src=\ref['icons/ntos/battery_icons/batt_20.gif']>"
if(21 to 40)
dat += "<img src=\ref['icons/ntos/battery_icons/batt_40.gif']>"
if(41 to 60)
dat += "<img src=\ref['icons/ntos/battery_icons/batt_60.gif']>"
if(61 to 80)
dat += "<img src=\ref['icons/ntos/battery_icons/batt_80.gif']>"
if(81 to 100)
dat += "<img src=\ref['icons/ntos/battery_icons/batt_100.gif']>"
dat += "<br>"
return dat
/datum/file/program/ntos/Topic(href, list/href_list) /datum/file/program/ntos/Topic(href, list/href_list)
if(!interactable() || ..(href,href_list)) if(!interactable() || ..(href,href_list))
return return

View File

@@ -449,6 +449,16 @@
overlays += kb overlays += kb
name = initial(name) + " (orange screen of death)" name = initial(name) + " (orange screen of death)"
//Returns percentage of battery charge remaining. Returns -1 if no battery is installed.
proc/check_battery_status()
if (battery)
var/obj/item/weapon/cell/B = battery
return round(B.charge / (B.maxcharge / 100))
else
return -1
/obj/machinery/computer3/wall_comp /obj/machinery/computer3/wall_comp
name = "terminal" name = "terminal"
icon = 'icons/obj/computer3.dmi' icon = 'icons/obj/computer3.dmi'

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B