Files
Paradise/code/game/machinery/status_display.dm
T
elly1989@rocketmail.com 6e274cd395 New lighting, it's essentially just the old DAL system with a queue.
Comments for lighting:
	Like sd_DAL (what we used to use), it changes the shading overlays of areas by splitting each type of area into sub-areas
	by using the var/tag variable and moving turfs into the contents list of the correct sub-area.

	Unlike sd_DAL however it uses a queueing system. Everytime we  call a change to opacity or luminosity
	(through SetOpacity() or SetLuminosity()) we are  simply updating variables and scheduling certain lights/turfs for an
	update. Actual updates are handled periodically by the lighting_controller. This carries additional overheads, however it
	means that each thing is changed only once per lighting_controller.processing_interval ticks. Allowing for greater control
	over how much priority we'd like lighting updates to have. It also makes it possible for us to simply delay updates by
	setting lighting_controller.processing = 0 at say, the start of a large explosion, waiting for it to finish, and then
	turning it back on with lighting_controller.processing = 1.

	Unlike our old system there is a hardcoded maximum luminosity. This is to discourage coders using large luminosity values
	for dynamic lighting, as the cost of lighting grows rapidly at large luminosity levels (especially when changing opacity
	at runtime)

	Also, in order for the queueing system to work, each light remembers the effect it casts on each turf. This is going to
	have larger memory requirements than our previous system but hopefully it's worth the hassle for the greater control we
	gain. Besides, there are far far worse uses of needless lists in the game, it'd be worth pruning some of them to offset
	costs.

	Known Issues/TODO:
		admin-spawned turfs will have broken lumcounts. Not willing to fix it at this moment
		mob luminosity will be lower than expected when one of multiple light sources is dropped after exceeding the maximum luminosity
		Shuttles still do not have support for dynamic lighting (I hope to fix this at some point)
		No directional lighting support. Fairly easy to add this and the code is ready.
		When opening airlocks etc, lighting does not always update to account for the change in opacity.

Explosions now cause lighting to cease processing temporarily.

Moved controller datums to the code/controllers directory. I plan on standardising them.
"Master","Ticker","Lighting","Air","Jobs","Sun","Radio","Supply Shuttle","Emergency Shuttle","Configuration","pAI" controller datums can be accessed via the debug controller verb (used to be the debug master controller verb)
Supply shuttle now uses a controller datum. Shuttles tend to arrive up to 30 seconds late, this is not a bug.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4537 316c924e-a436-60f5-8080-3fe189b3f50e
2012-08-25 16:06:57 +00:00

320 lines
6.8 KiB
Plaintext

// Status display
// (formerly Countdown timer display)
// Use to show shuttle ETA/ETD times
// Alert status
// And arbitrary messages set by comms computer
/obj/machinery/status_display
icon = 'icons/obj/status_display.dmi'
icon_state = "frame"
name = "status display"
anchored = 1
density = 0
use_power = 1
idle_power_usage = 10
var/mode = 1 // 0 = Blank
// 1 = Shuttle timer
// 2 = Arbitrary message(s)
// 3 = alert picture
// 4 = Supply shuttle timer
var/picture_state // icon_state of alert picture
var/message1 = "" // message line 1
var/message2 = "" // message line 2
var/index1 // display index for scrolling messages or 0 if non-scrolling
var/index2
var/lastdisplayline1 = "" // the cached last displays
var/lastdisplayline2 = ""
var/frequency = 1435 // radio frequency
var/supply_display = 0 // true if a supply shuttle display
var/repeat_update = 0 // true if we are going to update again this ptick
var/friendc = 0 // track if Friend Computer mode
// new display
// register for radio system
New()
..()
spawn(5) // must wait for map loading to finish
if(radio_controller)
radio_controller.add_object(src, frequency)
// timed process
process()
if(stat & NOPOWER)
overlays = null
return
update()
// set what is displayed
proc/update()
if(friendc && mode!=4) //Makes all status displays except supply shuttle timer display the eye -- Urist
set_picture("ai_friend")
return
if(mode==0)
overlays = null
return
if(mode==3) // alert picture, no change
return
if(mode==1) // shuttle timer
if(emergency_shuttle.online)
var/displayloc
if(emergency_shuttle.location == 1)
displayloc = "ETD "
else
displayloc = "ETA "
var/displaytime = get_shuttle_timer()
if(lentext(displaytime) > 5)
displaytime = "**~**"
update_display(displayloc, displaytime)
return
else
overlays = null
return
if(mode==4) // supply shuttle timer
var/disp1
var/disp2
if(supply_shuttle.moving)
disp1 = "SPPLY"
disp2 = get_supply_shuttle_timer()
if(lentext(disp1) > 5)
disp1 = "**~**"
else
if(supply_shuttle.at_station)
disp1 = "SPPLY"
disp2 = "STATN"
else
disp1 = "SPPLY"
disp2 = "AWAY"
update_display(disp1, disp2)
if(mode==2)
var/line1
var/line2
if(!index1)
line1 = message1
else
line1 = copytext(message1+message1, index1, index1+5)
if(index1++ > (lentext(message1)))
index1 = 1
if(!index2)
line2 = message2
else
line2 = copytext(message2+message2, index2, index2+5)
if(index2++ > (lentext(message2)))
index2 = 1
update_display(line1, line2)
// the following allows 2 updates per process, giving faster scrolling
if((index1 || index2) && repeat_update) // if either line is scrolling
// and we haven't forced an update yet
spawn(5)
repeat_update = 0
update() // set to update again in 5 ticks
repeat_update = 1
proc/set_message(var/m1, var/m2)
if(m1)
index1 = (lentext(m1) > 5)
message1 = uppertext(m1)
else
message1 = ""
index1 = 0
if(m2)
index2 = (lentext(m2) > 5)
message2 = uppertext(m2)
else
message2 = null
index2 = 0
repeat_update = 1
proc/set_picture(var/state)
picture_state = state
overlays = null
overlays += image('icons/obj/status_display.dmi', icon_state=picture_state)
proc/update_display(var/line1, var/line2)
if(line1 == lastdisplayline1 && line2 == lastdisplayline2)
return // no change, no need to update
lastdisplayline1 = line1
lastdisplayline2 = 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 shuttle timer as text
proc/get_shuttle_timer()
var/timeleft = emergency_shuttle.timeleft()
if(timeleft)
return "[add_zero(num2text((timeleft / 60) % 60),2)]~[add_zero(num2text(timeleft % 60), 2)]"
// note ~ translates into a blinking :
return ""
proc/get_supply_shuttle_timer()
if(supply_shuttle.moving)
var/timeleft = round((supply_shuttle.eta_timeofday - world.timeofday) / 10,1)
return "[add_zero(num2text((timeleft / 60) % 60),2)]~[add_zero(num2text(timeleft % 60), 2)]"
// note ~ translates into a blinking :
return ""
// return an icon of a time text string (tn)
// valid characters are 0-9 and :
// px, py are pixel offsets
proc/texticon(var/tn, var/px = 0, var/py = 0)
var/image/I = image('icons/obj/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('icons/obj/status_display.dmi', icon_state=char)
ID.pixel_x = -(d-1)*5 + px
ID.pixel_y = py
I.overlays += ID
return I
receive_signal(datum/signal/signal)
switch(signal.data["command"])
if("blank")
mode = 0
if("shuttle")
mode = 1
if("message")
mode = 2
set_message(signal.data["msg1"], signal.data["msg2"])
if("alert")
mode = 3
set_picture(signal.data["picture_state"])
if("supply")
if(supply_display)
mode = 4
/obj/machinery/ai_status_display
icon = 'icons/obj/status_display.dmi'
icon_state = "frame"
name = "AI display"
anchored = 1
density = 0
var/mode = 0 // 0 = Blank
// 1 = AI emoticon
// 2 = Blue screen of death
var/picture_state // icon_state of ai picture
var/emotion = "Neutral"
process()
if(stat & NOPOWER)
overlays = null
return
update()
proc/update()
if(mode==0) //Blank
overlays = null
return
if(mode==1) // AI emoticon
switch(emotion)
if("Very Happy")
set_picture("ai_veryhappy")
if("Happy")
set_picture("ai_happy")
if("Neutral")
set_picture("ai_neutral")
if("Unsure")
set_picture("ai_unsure")
if("Confused")
set_picture("ai_confused")
if("Sad")
set_picture("ai_sad")
if("BSOD")
set_picture("ai_bsod")
if("Blank")
set_picture("ai_off")
if("Problems?")
set_picture("ai_trollface")
if("Awesome")
set_picture("ai_awesome")
if("Dorfy")
set_picture("ai_urist")
if("Facepalm")
set_picture("ai_facepalm")
if("Friend Computer")
set_picture("ai_friend")
return
if(mode==2) // BSOD
set_picture("ai_bsod")
return
proc/set_picture(var/state)
picture_state = state
overlays = null
overlays += image('icons/obj/status_display.dmi', icon_state=picture_state)