ID:262704
 
I can't get the arrow in my game menu to work. Can anyone tell me how to go about this? I'd rather not post my code here, but can anyone tell me how to do it correctly? And if anyone doesn't understand this, I'm talking about an arrow like in the FF series, when you open up the menu, you got the arrow next to the category you want to go into, etc.

im not sure if you can do that in byond code or not thats what statpanels are for
In response to National Guardsmen
You can but sorry I'm not so sure how you can do it.
You need to tell us how you are currently trying to do arrows. Otherwise, we don't know how you could do it, since we can't adapt a concept to your current one. Either post your programming, or tell us your concept on how you currently do the game menus.

A way to do it is to create a datum which controls the arrow, and keeps track of the item selections, and what they do.

~~> Dragon Lord
In response to Mecha Destroyer JD
Okay, I'm following Rakwon's example in his "Raekwon Random Combat" demo.
In response to Game Sage
Game Sage wrote:
Okay, I'm following Rakwon's example in his "Raekwon Random Combat" demo.

My god, don't use that demo. It has terrible programming practices, and will only end up being a pain in the ass to create new screen objects. Sure it might work, but when you start to learn what it does, you will realise there are way better ways to do it, and the way which that specific demo shows it is terrible.

As I said before, one good way to display input boxes on the screen which can be used over again in different situations is by creating a datum specific to it. The inputbox datum could hold a list of what boxes would be drawn on the screen. The datum would have the drawing functions, and would draw as many tiles to how many elements to the list it is told to do.

Here is a small basic empty example you could build off of:
proc
tmax(list/L) // returns the longest charactered text string in a list
.=""
for(var/i in L)
if(length(i) > length(.))
. = i

client
var/inputbox/ib
Move(l, d)
if(ib && ib.selecting)
ib.MoveArrow(d)
return 0
return ..()

obj/screenobj
New(l, client/C, sc) // sc = screen_loc
C.screen += src
screen_loc = sc
..()
arrow
icon = 'arrow.dmi'

inputbox
var
client/owner
list/selections = list()
offset = 1 // x where the inputbox starts
obj/screenobj/arrow
selecting = 0
currSelection // current selection element the arrow is pointing to

New(client/C, list/selec)
owner = C
selections = selec
arrow = new (null, owner, "[offset],15")
// assuming 15 is the height of the screen
DrawScreen()
var w = 1
for(var/i in selections)
DrawText(i, w)
w++

proc
DrawScreen()
// draws the background "black" colours
// height and width is dependent on the longest length in the selection list (width), and how long the list will be (height).
var width = length(tmax(selections))
var height = selections.len
// do the drawing of the background.


DrawText(i, j) // j is the number in which i is put in
// draws the text "i" in (offset + 1, j) coordinates on the screen
// a nice drawing utility for this type of situation would be DMIFonts, by Lummox JR


ClientInput()
selecting = 1

MoveArrow(d) // d can be any direction, but this specific example will only apply to north and south
var/ldirec = d == 1 ? -1 : 1
// direction in the list to go to
// north = -1, south = 1
var/possibleItem
if((currSelection + ldirec) > selections.len)
currSelection = 1
else if((currSelection + ldirec) < 1)
currSelection = selections.len
else
currSelection = currSelection + ldirec
// loop to the start of the list if the end of the
// list is attained to, and vice versa
currSelection = selections[currSelection]
DrawArrow()

DrawArrow()
arrow.screen_loc = "[offset], [selections.Find(currSelection)]"


And to create the input box, we do something like this..

mob/verb
test_on_screen_input()
var/list/L = list("Test Selection","A test")
var/inputbox/B = new (src.client, L)
// when ready, call B.ClientInput to allow input to the inputbox via client/Move
B.ClientInput()


This snippet just serves as an example on how you can expand an input box on the screen to your use. This will hopefully point you to the right direction. If you are unfamiliar with datums, then you need to learn them!

~~> Dragon Lord