Advertisement
gamesmame

Untitled

Apr 26th, 2023
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. ///////////////////////////////////////////////////
  2. //
  3. // Attract-Mode Frontend - Control Menu plugin
  4. //
  5. ///////////////////////////////////////////////////
  6. //
  7. // Define use configurable settings
  8. //
  9.  
  10. const OPT_HELP="The text to show in the menu for this item";
  11. 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.";
  12.  
  13. class UserConfig </ help="Calls a Attract Mode Control Menu for Arcade Setups with limited buttons " /> {
  14. </ label="Control", help="The control to press to display the Attract Mode Control Menu", is_input=true, order=1 />
  15. button="U";
  16. }
  17.  
  18. local config=fe.get_config();
  19. local my_dir = fe.script_dir;
  20. local items = [];
  21.  
  22. const MAX_OUTPUT_LINES = 40;
  23.  
  24. fe.load_module( "submenu" );
  25.  
  26. class AnyCommandOutput extends SubMenu
  27. {
  28. m_t = "";
  29.  
  30. constructor()
  31. {
  32. base.constructor();
  33. m_t = fe.add_text( "", 0, 0, fe.layout.width, fe.layout.height );
  34. m_t.charsize=fe.layout.height / MAX_OUTPUT_LINES;
  35. m_t.align=Align.Left;
  36. m_t.word_wrap=true;
  37. m_t.bg_alpha=180;
  38. m_t.visible = false;
  39. }
  40.  
  41. function on_show() { m_t.visible = true; }
  42. function on_hide() { m_t.visible = false; }
  43. function on_scroll_up() { m_t.first_line_hint--; }
  44. function on_scroll_down() { m_t.first_line_hint++; }
  45.  
  46. function show_output( msg )
  47. {
  48. m_t.msg = msg;
  49. m_t.first_line_hint=0;
  50.  
  51. show( true );
  52. }
  53. };
  54. fe.plugin[ "Attract Mode Control Menu" ] <- AnyCommandOutput();
  55.  
  56. //
  57. // Load the menu with the necessary commands
  58. //
  59.  
  60.  
  61. items.append("Choose Emulator");
  62. items.append("Configure System");
  63. items.append("Display Filters");
  64. items.append("Add/Remove Favorites");
  65. items.append("Power Off");
  66.  
  67. //
  68. // Add a cancel/back option
  69. //
  70. items.append( "Back" );
  71.  
  72. //
  73. // Create a tick function that tests if the configured button is pressed and runs
  74. // the corresponding script or command if it is.
  75. //
  76. fe.add_ticks_callback( "control_menu_plugin_tick" );
  77.  
  78. function control_menu_plugin_tick( ttime )
  79. {
  80. if ( fe.get_input_state( config["button"] ) )
  81. {
  82.  
  83. local res = fe.overlay.list_dialog( items, "Options Menu", items.len() / 2 );
  84. if ( res < 0)
  85. return;
  86.  
  87. if (res ==2) {
  88. fe.signal("filters_menu");
  89.  
  90. } else if (res ==3) {
  91. fe.signal("add_favourite");
  92.  
  93. } else if (res ==0) {
  94. fe.signal("displays_menu");
  95. } else if (res ==1) {
  96. fe.signal("configure");
  97. } else if (res ==4) {
  98. fe.signal("exit_no_menu");
  99. }
  100. }
  101. }
  102.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement