Tags

, , ,

Some day ago i put myself to work on the gui.

What i started to think was “how does the user interact in a roguelike” ? the first things that came in my mind were “menus“.

The next step was to define “what is a menu?” and the answer was quite simple:

a menu is something that contains a list of selectable items.

from there i reached the conclusion that i could handle the interface with 2 different types of menu:

  • a hover menu
  • a character-selection menu

The first one allows one of the selectable items to be visibly different from the others, allowing the user to recognize which option he’s selecting . The difference might be in the background/foreground colors, a simple character before the label, or anything else.

The second one allows the gui to show a list of items and for each one ,a letter to press to do something.

A hover menu

Here on the left there is a simple hover menu.

The selected item is shown by a simple “>” character befor the element.

 

 

A character selection menu is quite the same thing,but instead of showing only the labels of the choices, it shows also what key to press to select the single choice.

And here comes the next step: there must be a keyboard handler that can recognize what’s happening. (this is a next post topic)

What’s nice about how i handled the menus is that if i put them close to the bottom side of the console , the scrolling is handled correctly, so the whole menu scrolls to show  the user the choices that don’t fit in the screen.

The syntax is quite simple, with a single line i can handle the menu printing

engine.writeScrollable(“consolename”,menuobject,x,y)

and with another couple i can handle the keyboard input:

handler = kh.HoverMenuKeyboardHandler(menu)
engine.setKeyboardHandler(handler)

3 lines and that’s all.

 

Advertisements