Currently I am trying to have Client.North and South, if an Option datum is created, scroll through the parameters of the list eg: client
North()
if(mob.Options)
mob.Select("up")
else
..()
and then Select figures the rest out:
mob
proc
Select(direction)
if(direction == "up")
if(selected == Options.options[1])
selected = Options.options[Options.options.len]
option_number = Options.options.len
return //can't scroll up anymore, so go to bottom
selected = Options.options[--option_number]
Hmm, now there's a few issues, like what if I want to have client.East() move the selected object to the eastern most selection? I can't really scroll through the list of the contents properly then...
So how can I effectively go about creating a flexible menu on HUD that I can scroll through the contents with arrow keys?
THE FOLLOWING IS MY ATTEMPT, and isn't necessary to read through - but hopefully it will give you an idea of what I'm trying to do:
Options Datum:
mob
var
Options
Options
obj/option/selected
option_number = 1
obj/highlight
f_choice = null
Options
var
mob/chooser
list
options = new
New(mob/selector, list/l)
chooser = selector
selector.Options = src
for(var/a in l)
//list("startgame:7,5" , "endgame:7,4")
var
indexc = 1
tname
sloc
namecount = 0
for()
namecount ++
if(copytext("[a]",indexc++,indexc) == ":")
break
tname = copytext("[a]",1,namecount)
sloc = copytext("[a]",namecount+1)
var/obj/option/b = new
b.title = tname
b.screen_loc = sloc
selector.client.screen += b
options += b
selector.selected = options[1] //give a default select. top of the list.
selector.HighLight()
proc
Choice()
var/obj/option/final_choice = chooser.selected
chooser.selected = null
chooser.Options = null
if(chooser.highlight)
chooser.client.screen -= chooser.highlight
del chooser.highlight
chooser.f_choice = final_choice
del src
How I want to work with the options through the variable:
mob
proc
Option(list/string)
new/Options(src, string)
while(!f_choice)
sleep(1)
var/obj/option/schoice = f_choice
f_choice = null
return schoice.title
mob
verb
TEST_OPTIONS()
var/option = Option(list("START:1,5","END:1,4","CANCEL:1,3"))
if(option == "START")
world << "you selected start"
if(option == "END")
world << "you selected end"
if(option == "CANCEL")
world << "cancelled."
Any help appreciated, thanks.
1 2 3
4 5 x
6 x x
7 8 9
Say the numbers are the options and the x's are blank spaces.
You may also use associative lists.
This way, you can easily track the options through their index. i.e. choice = matrix["[row],[column]"]
You can then scroll through the list through client/Move().