Using the typical alphabet is easy, we just type what we want to see in game exactly as we want to see it..
but how do we use the UI characters?
I'm building a menu system where some items in the menu will open another window and others won't. some might toggle the item on the list, or disable it, etc.
I'd like to use the < and > like characters from the UI section of the font. are these available for use in text entry? perhaps there is a character code i'd need to use?
Part of my current experiment includes some fancier-than-expected menus. for example, menus with items that:
open a sub-menu (i'd like to place a downward arrow next to this)
toggle a feature on/off (i'd like to place the double arrow next to that and update the text once clicked)
i haven't experimented with tiles for this yet, but it feels wonky to consider drawing a tile on to of the native menu implementation. i doubt it would work?
If there might be an escape code to drop these UI widget characters into a normal text string, that would work best for me.
Those UI tiles are kind of off in their own tile pool so they can’t be embedded in text. One option is to export the font from Font mode and import the png that produces as regular tiles in Room mode. Then you can embed them in a string as you would other tiles.
Maybe this might save you some work though: menu calls can be nested. Background menus already maintain their cursor position and change its icon to represent its background position in the menu stack.
wait - i had no idea i could embed a tile in a string? do I just put the tilename in {'s like another variable?
huge facepalm here! i thought i tried this and found it wouldn't work!! DOH!
ok, this might save me a LOT of time. thanks!
is there any way to change the contents of the menu at runtime though? my current menu structure includes something like this:
on drawMenu do
frm = frame
setup="setup_mnu_{frm}"
draw="draw_mnu_{frm}"
call "{setup}"
call "{draw}"
end
on setup_mnu_0 do
opt_0_halt="Halt" // player selects to halt their robot's running code
if g_mode_auto==1 then
opt_0_mode="Mode:Auto"
else
opt_0_mode="Mode:Manual" // player selects to toggle between manual and automatic
end
...
end
on draw_mnu_0 do
menu at x,y,len,items then
option "{opt_0_halt}" then
mnu_pending = 1 // re-enter menu level 0
g_prog_running = 0
end
option "{opt_0_mode}" then
mnu_pending = 1
if g_mode_auto==1 then
// we were in auto mode, switch to manual and cancel any running program
g_prog_running = 0
g_mode_auto = 0
else
g_mode_auto = 1
end
...
end
if mnu_pending==1 then, on the next frame, player.draw will call MENU.drawMenu before clearing the mnu_pending flag.
With the above I can make it look like a menu stays open no matter how many things you click on; and i can modify the text within the menu. so toggling between auto and manual mode looks like it happens while the menu is still open...
for the relatively simple behavior above this might not be a big deal, but i plan to include menus in which a user can define a script of sorts, like this:
Prog 0 menu
NOP
NOP
NOP
NOP
NOP
NOP
NOP
Then, as the user scrolls through that list they can click any "no operation" NOP entry to open a submenu. from the submenu they will see a list of all the "instructions" they have access to. Picking one of those instructions will replace the original NOP. So after some interaction the above might look like:
Prog 0 menu
Select tool: Camera // user now has a camera in robot's arm
Use tool // use the camera to scan the block in front of you
Investigate: Forward // determine the type of block ahead; maybe a wall?
Compare: Wall // compare investigate result to "wall"; set a flag for result
Decide: Prog 1 // if flag is set, run another program
Execute: Prog 2 // if we didn't jump away, run prog 2
NOP // we never reach here because we jump away above
Embedding a tile in a string is documented under say but will be moving to a separate "String formatting” section in the next push. It looks like this:
say "You got an {embed:apple}Apple!"
As for changing menu options that are already on screen, I’m pretty sure that’s not possible. You can control which options display by nesting them inside if blocks inside the menu block, eg.
menu at x,y then
option "Fight" then
// make with the hitting
end
if spell_count>0 then
option "Magic" then
menu at x2,y then
if spell_fire==1 then
option "Fire" then
// make with the burning
end
end
if spell_ice==1 then
option "Ice" then
// make with the freezing
end
end
end
end
end
option "Run" then
// make with the fleeing
end
end
But those conditions are evaluated each time the menu is opened, not continuously while the menu is on screen.
Edit: Here’s that link to the new String formatting section of the docs.