When I get home, I will send you the code and how I did this. A little hint, think outside of the box (eh layout
)
-- So chrisvg I am home now. A little background first, my cab has 4 admin buttons to ease frontend use for guests. They are MENU, SELECT, QUIT/BACK, PAUSE.
In Attractmode, I set MENU to open the Menu plugin. The menu you see in my video/screenshot is showing those options. I wanted to make sure, all options someone would use can be set using only those admin buttons.
The menu code used in my layout is here - it works for all menus that are not called using the tab key e.g.: displays hot key or the plugin menu hotkey.
////////////////////////////////////////
//
//Configure Custom Menu
//
///////////////////////////////////////
// Overall Surface
local overlaySurface = fe.add_surface(1280,1024);
overlaySurface.visible = false;
// translucent background
local overlayBackground = overlaySurface.add_image("images/overlaymenu/black.png",0,0,1280,1024);
overlayBackground.alpha = 225;
// create extra surface for the menu
local overlayMenuSur = overlaySurface.add_surface(322,328);
overlayMenuSur.set_pos(480,359);
overlayMenuSur.add_image("images/overlaymenu/menuframe.png",0,40,321,256); // Add the menu frame
local overlay_lb = overlayMenuSur.add_listbox(1,40,320,256); //Add the listbox
overlay_lb.rows = 6; // the listbox will have 6 slots
overlay_lb.charsize = 22;
overlay_lb.set_rgb( 128, 128, 128 );
overlay_lb.sel_style = Style.Bold;
overlay_lb.set_sel_rgb( 255, 255, 255 );
overlay_lb.set_selbg_rgb( 255, 165, 0 );
local overlayMenuTitle = overlayMenuSur.add_text("[DisplayName]",0,0,322,35); //Add the menu title
overlayMenuTitle.charsize=30;
overlayMenuTitle.style = Style.Bold;
overlayMenuTitle.set_rgb(255,165,0);
//clone the menu surface for the bartop picture
overlaySurface.add_image("images/overlaymenu/black.png",330,480,100,240);
local overlayClone = overlaySurface.add_clone(overlayMenuSur);
overlayClone.set_pos(354,559,102,90);
overlayClone.skew_x=12;
overlayClone.pinch_y=8;
overlayClone.alpha=250;
local overlayBartop = overlaySurface.add_image("images/overlaymenu/menuBartop.png"); //add the bartop picutre
overlayBartop.set_pos(300,480);
// Show the up time
local ut = overlaySurface.add_text( "ELASPED TIME: ", 460, 655, 280, 24 );
ut.set_rgb( 128, 128, 128 );
ut.align = Align.Right;
ut.charsize=15;
local ut = overlaySurface.add_text( "", 725, 655, 280, 25 );
ut.set_rgb( 255, 165, 0 );
ut.align = Align.Left;
ut.charsize=15;
// Function to update the time
function update_uptime( ttime )
{
local mil = fe.layout.time;
local seconds = ((mil / 1000) % 60) ;
local minutes = ((mil / (1000*60)) % 60);
local hours = ((mil / (1000*60*60)) % 24);
//ut.msg= hours+":"+minutes+":"+seconds;
ut.msg = format("%02d", hours ) + ":" + format("%02d", minutes) + ":" + format("%02d", seconds )
}
fe.add_ticks_callback( this, "update_uptime" );
// tell Attractmode we are using a custom overlay menu
fe.overlay.set_custom_controls( overlayMenuTitle, overlay_lb );
Attached you will find my altered menu plugin script with my menu options. The file goes in your plugin folder, the code is here for reference.
///////////////////////////////////////////////////
//
// Attract-Mode Frontend - Control Menu plugin
//
///////////////////////////////////////////////////
//
// Define use configurable settings
//
const OPT_HELP="The text to show in the menu for this item";
const CMD_HELP="The command to run when this item is selected. Use @<script_name.nut> to run a squirrel script that is located in the Utility Menu's plugin directory.";
class UserConfig </ help="Calls a Attract Mode Control Menu for Arcade Setups with limited buttons " /> {
</ label="Control", help="The control to press to display the Attract Mode Control Menu", is_input=true, order=1 />
button="U";
}
local config=fe.get_config();
local my_dir = fe.script_dir;
local items = [];
const MAX_OUTPUT_LINES = 40;
fe.load_module( "submenu" );
class AnyCommandOutput extends SubMenu
{
m_t = "";
constructor()
{
base.constructor();
m_t = fe.add_text( "", 0, 0, fe.layout.width, fe.layout.height );
m_t.charsize=fe.layout.height / MAX_OUTPUT_LINES;
m_t.align=Align.Left;
m_t.word_wrap=true;
m_t.bg_alpha=180;
m_t.visible = false;
}
function on_show() { m_t.visible = true; }
function on_hide() { m_t.visible = false; }
function on_scroll_up() { m_t.first_line_hint--; }
function on_scroll_down() { m_t.first_line_hint++; }
function show_output( msg )
{
m_t.msg = msg;
m_t.first_line_hint=0;
show( true );
}
};
fe.plugin[ "Attract Mode Control Menu" ] <- AnyCommandOutput();
//
// Load the menu with the necessary commands
//
items.append("Choose Emulator");
items.append("Configure System");
items.append("Display Filters");
items.append("Add/Remove Favorites");
items.append("Power Off");
//
// Add a cancel/back option
//
items.append( "Back" );
//
// Create a tick function that tests if the configured button is pressed and runs
// the corresponding script or command if it is.
//
fe.add_ticks_callback( "control_menu_plugin_tick" );
function control_menu_plugin_tick( ttime )
{
if ( fe.get_input_state( config["button"] ) )
{
local res = fe.overlay.list_dialog( items, "Options Menu", items.len() / 2 );
if ( res < 0)
return;
if (res ==2) {
fe.signal("filters_menu");
} else if (res ==3) {
fe.signal("add_favourite");
} else if (res ==0) {
fe.signal("displays_menu");
} else if (res ==1) {
fe.signal("configure");
} else if (res ==4) {
fe.signal("exit_no_menu");
}
}
}
Hmmmm, now that I think of it, I could have put this in my layout as well. But hey, I like to keep things seperate. The plugin will still work when I get tired of my own layout and change it one day.