Backlog

by Ter13
Welcome to my brain's backwash
ID:2142088
 
interface
var
client/client
list/screen
showing = 0
initialized = 0
anchor_x
anchor_y
x
y
control_flags = INTERACT_NONE
proc
Show()
if(!showing)
if(!initialized)
Init()
initialized = 1
showing = 1
if(screen) client.screen += screen
return 1
return 0

Hide()
if(showing)
showing = 0
if(screen) client.screen -= screen
return 1
return 0

Init()

showsleep(duration)
var/etime = world.time+duration
while(showing&&world.time<etime)
sleep(TICK_LAG)
return showing

Focus(interface/ofocus)

Unfocus(interface/nfocus)

keyPress(bind,taps,time,delta)
return control_flags&INTERACT_KEYBOARD ? 1 : 0

keyRelease(bind,taps,time,delta)
return control_flags&INTERACT_KEYBOARD ? 1 : 0

Click(atom/object,location,control,params)
return control_flags&INTERACT_CLICK ? 1 : 0

DblClick(atom/object,location,control,params)
return control_flags&INTERACT_DBLCLICK ? 1 : 0

MouseDown(atom/object,location,control,params)
return control_flags&INTERACT_MOUSEHOLD ? 1 : 0

MouseUp(atom/object,location,control,params)
return control_flags&INTERACT_MOUSEHOLD ? 1 : 0

MouseEntered(atom/object,location,control,params)
return control_flags&INTERACT_MOUSEHOVER ? 1 : 0

MouseExited(atom/object,location,control,params)
return control_flags&INTERACT_MOUSEHOVER ? 1 : 0

MouseMove(atom/object,location,control,params)
return control_flags&INTERACT_MOUSEMOVE ? 1 : 0

MouseDrag(atom/object,atom/over_object,src_location,over_location,src_control,over_control,params)
return control_flags&INTERACT_MOUSEDRAG ? 1 : 0

MouseDrop(atom/object,atom/over_object,src_location,over_location,src_control,over_control,params)
return control_flags&INTERACT_MOUSEDROP ? 1 : 0

MouseWheel(atom/object,delta_x,delta_y,location,control,params)
return control_flags&INTERACT_MOUSEWHEEL ? 1 : 0

onClick(hudobj/object,location,control,params)
set waitfor = 0
. = showing

onDblClick(hudobj/object,location,control,params)
set waitfor = 0
. = showing

onMouseDown(hudobj/object,location,control,params)
set waitfor = 0
. = showing

onMouseUp(hudobj/object,location,control,params)
set waitfor = 0
. = showing

onMouseEntered(hudobj/object,location,control,params)
set waitfor = 0
. = showing

onMouseExited(hudobj/object,location,control,params)
set waitfor = 0
. = showing

onMouseMove(hudobj/object,location,control,params)
set waitfor = 0
. = showing

onMouseDrag(hudobj/object,atom/over_object,src_location,over_location,src_control,over_control,params)
set waitfor = 0
. = showing

onMouseDrop(hudobj/object,atom/over_object,src_location,over_location,src_control,over_control,params)
set waitfor = 0
. = showing

onMouseWheel(hudobj/object,delta_x,delta_y,location,control,params)
set waitfor = 0
. = showing

onButton(hudobj/object)
set waitfor = 0
. = showing

Destroy()
for(var/hudobj/h in screen)
h.container = null

New(client/owner,showing)
src.client = ismob(owner) ? owner:client : owner
if(showing==null&&src.showing) Show()
else if(showing) Show()

Del()
if(client&&showing&&screen)
client.screen -= screen
screen = null
client = null
..()

hudobj
parent_type = /obj
plane = HUD_PLANE
layer = 0
var/tmp
id
interface/container
mouse_flags = INTERACT_NONE
screen_x
screen_y

New(interface/owner,id=null,x=0,y=0)
if(owner) src.container = owner
if(id) src.id = id
screen_x = x
screen_y = y
if(!screen_loc)
screen_loc = "[owner.anchor_x]:[x+owner.x],[owner.anchor_y]:[y+owner.y]"

Click(location,control,params)
if(container&&container.showing&&mouse_flags&INTERACT_CLICK) return container.onClick(src,location,control,params)

DblClick(location,control,params)
if(container&&container.showing&&mouse_flags&INTERACT_DBLCLICK) return container.onDblClick(src,location,control,params)

MouseDown(location,control,params)
if(container&&container.showing&&mouse_flags&INTERACT_MOUSEHOLD) return container.onMouseDown(src,location,control,params)

MouseUp(location,control,params)
if(container&&container.showing&&mouse_flags&INTERACT_MOUSEHOLD) return container.onMouseUp(src,location,control,params)

MouseDrag(over_object,src_location,over_location,src_control,over_control,params)
if(container&&container.showing&&mouse_flags&INTERACT_MOUSEDRAG) return container.onMouseDrag(src,over_object,src_location,over_location,src_control,over_control,params)

MouseDrop(over_object,src_location,over_location,src_control,over_control,params)
if(container&&container.showing&&mouse_flags&INTERACT_MOUSEDROP) return container.onMouseDrop(src,over_object,src_location,over_location,src_control,over_control,params)

MouseEntered(location,control,params)
if(container&&container.showing&&mouse_flags&INTERACT_MOUSEHOVER) return container.onMouseEntered(src,location,control,params)

MouseExited(location,control,params)
if(container&&container.showing&&mouse_flags&INTERACT_MOUSEHOVER) return container.onMouseExited(src,location,control,params)

MouseMove(location,control,params)
if(container&&container.showing&&mouse_flags&INTERACT_MOUSEMOVE) return container.onMouseMove(src,location,control,params)

MouseWheel(delta_x,delta_y,location,control,params)
if(container&&container.showing&&mouse_flags&INTERACT_MOUSEWHEEL) return container.onMouseWheel(src,delta_x,delta_y,location,control,params)
Implementation example:

interface
sidemenu
anchor_x = 24
anchor_y = 1

control_flags = INTERACT_MOUSEHOLD

var
list/tabs

hudobj/sidemenubg/bg
interface/curtab

/hudobj/sidemenutab
mouse_flags = INTERACT_MOUSEHOLD
var
pos
tab1
name = "stats"
icon = 'Graphics/ui/tab1.dmi'
pos = 1
tab2
name = "items"
icon = 'Graphics/ui/tab2.dmi'
pos = 2
tab3
name = "skill"
icon = 'Graphics/ui/tab3.dmi'
pos = 3
tab4
name = "quest"
icon = 'Graphics/ui/tab4.dmi'
pos = 4

/hudobj/sidemenubg
icon = 'Graphics/ui/bg.dmi'

Init()
bg = new(src,"background",0,0)

var/hudobj/sidemenutab/t1 = new/hudobj/sidemenutab/tab1(src,"statstab",0,120)
var/hudobj/sidemenutab/t2 = new/hudobj/sidemenutab/tab2(src,"itemstab",0,120)
var/hudobj/sidemenutab/t3 = new/hudobj/sidemenutab/tab3(src,"skilltab",0,120)
var/hudobj/sidemenutab/t4 = new/hudobj/sidemenutab/tab4(src,"questtab",0,120)

tabs = list()
tabs[t1] = new/interface/statstab(client)
tabs[t2] = new/interface/itemstab(client)
tabs[t3] = new/interface/skilltab(client)
tabs[t4] = new/interface/questtab(client)

screen = list(bg,t4,t3,t2,t1)

onMouseDown(hudobj/object,location,control,params)
switch(object.id)
if("statstab","itemstab","skilltab","questtab")
var/is = "[object:pos]"
for(var/hudobj/h in tabs)
h.icon_state = is
bg.icon_state = object.name
var/interface/i = tabs[object]
if(curtab)
curtab.Hide()
curtab = i
i.Show()
. = ..()

statstab
anchor_x = 24
anchor_y = 1

var
list/pages
page = 0

/hudobj/stat
icon = 'Graphics/ui/stats.dmi'
maptext_height = 14

New(interface/owner,id=null,x=0,y=0,icon_state=null,width,maptext)
maptext_width = width
src.icon_state = icon_state
src.maptext = "<span class='right'>[maptext]</span>"
..()

Init()
var/list/l = list(new/hudobj/stat(src,"class",0,106,"fighter",56,"20 Fighter"),
new/hudobj/stat(src,"hp",0,92,"hp",28,9999),new/hudobj/stat(src,"mp",28,92,"mp",28,9999),
new/hudobj/stat(src,"str",0,78,"str",28,99),new/hudobj/stat(src,"int",28,78,"int",28,99),
new/hudobj/stat(src,"agi",0,64,"agi",28,99),new/hudobj/stat(src,"wis",28,64,"wis",28,99),
new/hudobj/stat(src,"vit",0,50,"vit",28,99),new/hudobj/stat(src,"luk",28,50,"luk",28,99),
new/hudobj/stat(src,"atk",0,36,"atk",28,999),new/hudobj/stat(src,"def",28,36,"def",28,999),
new/hudobj/stat(src,"crit",0,22,"crit",28,"100%"),new/hudobj/stat(src,"acc",28,22,"acc",28,"100%"),
new/hudobj/stat(src,"nexp",0,8,"nexp",56,"1000000"))
pages = list(l)
screen = l.Copy()

itemstab
anchor_x = 24
anchor_y = 1

var
list/equipslots
list/itemslots

/hudobj/itemslot
icon = 'Graphics/ui/slots.dmi'
var
slot

New(interface/owner,id=null,x=0,y=0,slot=0,icon_state=null)
src.slot = slot
src.icon_state = icon_state
..()

Init()
equipslots = list(new/hudobj/itemslot(src,"equip",0,106,"primary","primary"),new/hudobj/itemslot(src,"equip",14,106,"secondary","secondary"),new/hudobj/itemslot(src,"equip",28,106,"accessory1","accessory"),new/hudobj/itemslot(src,"equip",42,106,"accessory2","accessory"),
new/hudobj/itemslot(src,"equip",0,92,"head","head"),new/hudobj/itemslot(src,"equip",14,92,"body","body"),new/hudobj/itemslot(src,"equip",28,92,"back","back"),new/hudobj/itemslot(src,"equip",42,92,"feet","feet"),
new/hudobj/itemslot(src,"equip",0,14,"bag1","bag"),new/hudobj/itemslot(src,"equip",14,14,"bag2","bag"),new/hudobj/itemslot(src,"equip",28,14,"bag3","bag"),new/hudobj/itemslot(src,"equip",42,14,"bag4","bag"))

itemslots = list(new/hudobj/itemslot(src,"item",0,78,1,"empty"),new/hudobj/itemslot(src,"item",14,78,2,"empty"),new/hudobj/itemslot(src,"item",28,78,3,"empty"),new/hudobj/itemslot(src,"item",42,78,4,"empty"),
new/hudobj/itemslot(src,"item",0,64,5,"empty"),new/hudobj/itemslot(src,"item",14,64,6,"empty"),new/hudobj/itemslot(src,"item",28,64,7,"empty"),new/hudobj/itemslot(src,"item",42,64,8,"empty"),
new/hudobj/itemslot(src,"item",0,50,9,"empty"),new/hudobj/itemslot(src,"item",14,50,10,"empty"),new/hudobj/itemslot(src,"item",28,50,11,"empty"),new/hudobj/itemslot(src,"item",42,50,12,"empty"),
new/hudobj/itemslot(src,"item",0,36,13,"empty"),new/hudobj/itemslot(src,"item",14,36,14,"empty"),new/hudobj/itemslot(src,"item",28,36,15,"empty"),new/hudobj/itemslot(src,"item",42,36,16,"empty"))

screen = equipslots+itemslots

skilltab
anchor_x = 24
anchor_y = 1

questtab
anchor_x = 24
anchor_y = 1