Brig door timers now display the time remaining.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@37 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
musketstgstation@gmail.com
2010-08-31 16:07:12 +00:00
parent 1f799b5f9c
commit bcb90c5cd2

View File

@@ -1,10 +1,14 @@
// NOTE: Each brig door and door_control must be placed on top of an other on the map, use offset to
// put the control on a wall.
// ID variable on door and on door control links them together.
/obj/machinery/computer/door_control
name = "Door Control"
icon = 'stationobjs.dmi'
icon_state = "sec_computer"
req_access = list(access_brig)
// var/authenticated = 0.0 if anyone wants to make it so you need to log in in future go ahead.
var/id = 1.0
var/id = 1.0 // ID of door control and door it operates
/obj/machinery/computer/door_control/proc/alarm()
if(stat & (NOPOWER|BROKEN))
@@ -14,18 +18,21 @@
if(M.density)
spawn( 0 )
M.open()
else
spawn( 0 )
M.close()
// else
// spawn( 0 )
// M.close()
src.updateUsrDialog()
return
//Allows the AI to control doors, see human attack_hand function below
/obj/machinery/computer/door_control/attack_ai(var/mob/user as mob)
return src.attack_hand(user)
//Allows monkeys to control doors, see human attack_hand function below
/obj/machinery/computer/door_control/attack_paw(var/mob/user as mob)
return src.attack_hand(user)
// A security door_control computer for centralizing all brig door locks.
/obj/machinery/computer/door_control/attack_hand(var/mob/user as mob)
if(..())
return
@@ -51,6 +58,7 @@
onclose(user, "computer")
return
//Allows the door_control computer to open/close brig doors.
/obj/machinery/computer/door_control/Topic(href, href_list)
if(..())
return
@@ -79,37 +87,44 @@
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// new door timer code, mostly taken from status display.
/obj/machinery/door_timer
name = "Door Timer"
icon = 'stationobjs.dmi'
icon_state = "doortimer0"
desc = "A remote control switch for a door."
icon = 'status_display.dmi'
icon_state = "frame"
desc = "A remote control for a door."
req_access = list(access_brig)
anchored = 1.0
var/id = null
var/time = 30.0
var/timing = 0.0
anchored = 1.0 // can't pick it up
density = 0 // can walk through it.
var/id = null // id of door it controls.
var/time = 0.0 // defaults to 0 seconds timer
var/timing = 0.0 // boolean, true/1 timer is on, false/0 means it's not timing
var/picture_state // icon_state of alert picture
//Main door timer loop, if it's timing and time is >0 reduce time by 1.
// if it's less than 0, open door, reset timer
// update the door_timer window and the icon
/obj/machinery/door_timer/process()
..()
if (src.timing)
if (src.time > 0)
src.time = round(src.time) - 1
else
alarm()
alarm() // open doors
src.time = 0
src.timing = 0
src.updateDialog()
src.update_icon()
return
// has the door power sitatuation changed, if so update icon.
/obj/machinery/door_timer/power_change()
update_icon()
// alarm() checks if door_timer has power, if so it checks if the
// linked door is open/closed (by density) then opens it/closes it.
// It's also supposed to unlock the secure closets in the brig. TEST THIS
/obj/machinery/door_timer/proc/alarm()
if(stat & (NOPOWER|BROKEN))
return
@@ -118,9 +133,6 @@
if(M.density)
spawn( 0 )
M.open()
else
spawn( 0 )
M.close()
for(var/obj/secure_closet/brig/B in world)
if (B.id == src.id)
if(B.locked)
@@ -130,12 +142,18 @@
src.update_icon()
return
//Allows AIs to use door_timer, see human attack_hand function below
/obj/machinery/door_timer/attack_ai(var/mob/user as mob)
return src.attack_hand(user)
//Allows monkeys to use door_timer, see human attack_hand function below
/obj/machinery/door_timer/attack_paw(var/mob/user as mob)
return src.attack_hand(user)
//Allows humans to use door_timer
//Opens dialog window when someone clicks on door timer
// Allows altering timer and the timing boolean.
// Flasher activation limited to 150 seconds
/obj/machinery/door_timer/attack_hand(var/mob/user as mob)
if(..())
return
@@ -161,6 +179,13 @@
onclose(user, "computer")
return
//Function for using door_timer dialog input, checks if user has permission
// href_list to
// "time" turns on timer
// "tp" closes door
// "fc" activates flasher
// Also updates dialog window and timer icon
/obj/machinery/door_timer/Topic(href, href_list)
if(..())
return
@@ -175,6 +200,11 @@
var/tp = text2num(href_list["tp"])
src.time += tp
src.time = min(max(round(src.time), 0), 600)
for(var/obj/machinery/door/window/brigdoor/M in world)
if (M.id == src.id)
if(!M.density)
spawn( 0 )
M.close()
if (href_list["fc"])
if(src.allowed(usr))
for (var/obj/machinery/flasher/F in world)
@@ -185,19 +215,66 @@
src.update_icon()
return
//icon update function
// if NOPOWER, display blank
// if BROKEN, display blue screen of death icon AI uses
// if timing=true, run update display function
/obj/machinery/door_timer/proc/update_icon()
var/disp1
oview() << id
disp1 = "[add_zero(num2text((time / 60) % 60),2)]~[add_zero(num2text(time % 60), 2)]"
if(stat & (NOPOWER))
icon_state = "doortimer-p"
return
else if(stat & (BROKEN))
icon_state = "doortimer-b"
icon_state = "frame"
return
else
if(src.timing)
icon_state = "doortimer1"
else if(src.time > 0)
icon_state = "doortimer0"
if(stat & (BROKEN))
set_picture("ai_bsod")
return
else
spawn( 50 )
icon_state = "doortimer0"
icon_state = "doortimer2"
if(src.timing)
spawn( 5 )
update_display(id, disp1)
else
spawn( 5 )
update_display(id, null)
// Adds an icon in case the screen is broken/off, stolen from status_display.dm
/obj/machinery/door_timer/proc/set_picture(var/state)
picture_state = state
overlays = null
overlays += image('status_display.dmi', icon_state=picture_state)
//Checks to see if there's 1 line or 2, adds text-icons-numbers/letters over display
// Stolen from status_display
/obj/machinery/door_timer/proc/update_display(var/line1, var/line2)
if(line2 == null) // single line display
overlays = null
overlays += texticon(line1, 23, -13)
else // dual line display
overlays = null
overlays += texticon(line1, 23, -9)
overlays += texticon(line2, 23, -17)
// return an icon of a time text string (tn)
// valid characters are 0-9 and :
// px, py are pixel offsets
//Actual string input to icon display for loop, with 5 pixel x offsets for each letter.
//Stolen from status_display
/obj/machinery/door_timer/proc/texticon(var/tn, var/px = 0, var/py = 0)
var/image/I = image('status_display.dmi', "blank")
var/len = lentext(tn)
for(var/d = 1 to len)
var/char = copytext(tn, len-d+1, len-d+2)
if(char == " ")
continue
var/image/ID = image('status_display.dmi', icon_state=char)
ID.pixel_x = -(d-1)*5 + px
ID.pixel_y = py
I.overlays += ID
return I