Author Topic: Basic questions for my layout  (Read 1988 times)

Elaphe666

  • Jr. Member
  • **
  • Posts: 15
    • View Profile
Basic questions for my layout
« on: October 05, 2024, 09:23:12 AM »
Hello. I'm new to Attract Mode and I have several questions. I have already made a very simple and minimalistic layout for a resolution of 640x480 and I would like to improve some aspects.

First: is there any way to have a key for menu select and another key for launching games? I see that the "select" option under controls works for both.

Second: I have made a vertical version of my layout (I will rotate my 4:3 CRT monitor). Is there any way I can toggle between the horizontal and the vertical layout with a button/key? My current solution is to use Autohotkey to map a button to perform a series of actions such as copying different versions of attract.cfg in a toggle and restart the frontend.

Third: I am using the popup script to show an imagen with some help information. How can I center it on screen for both my horizontal and vertical layouts? This is the code I have:

Code: [Select]

class PopUpImage
{
        _my_image=null;

        constructor()
        {
                _my_image = fe.add_image( "help.png", 0, 0 );
                _my_image.visible=false;
                fe.add_signal_handler( this, "on_signal" )
        }

        function on_signal( signal )
        {
                if ( signal == "custom1" )
                {
                        _my_image.visible=!_my_image.visible;
                        return true;
                }
                return false;
        }
}

local blah = PopUpImage();

Logged

« Last Edit: October 05, 2024, 01:20:59 PM by Elaphe666 »

zestful

  • Full Member
  • ***
  • Posts: 35
    • View Profile
Re: Basic questions for my layout
« Reply #1 on: October 07, 2024, 08:24:50 AM »
                _my_image = fe.add_image( "help.png", 0, 0 );

The 0,0 is your X and Y cords, change those to position it where you want

If you're rotating the layout you could look at a switch statement tied to one of the custom buttons attract mode offers and change all your items positions inside of that.   You can use the same approach for menuselect vs launching games

Code: [Select]
    //Signal Handlers
    fe.add_signal_handler("interationControls");


    //--Define what interactions should do on the layout
    function interationControls(sig)
    {
        switch (sig)
        {
            case "custom1": //button x for example (set in menu of attract mode the key to use)
                logo.x = 500 // just an example
                return true;

           
        }
    }

Elaphe666

  • Jr. Member
  • **
  • Posts: 15
    • View Profile
Re: Basic questions for my layout
« Reply #2 on: October 07, 2024, 09:44:47 AM »
                _my_image = fe.add_image( "help.png", 0, 0 );

The 0,0 is your X and Y cords, change those to position it where you want


I know, but I have to write the code for the popup and it wil be valid for centering the image in one of my layouts. I am using the same button in both cases. It can't be centered in both because one is horizontal and the other one is vertical. I wonder if there is an option in the pop up code to tell the program to use certain x and y values for the horizontal layout and others for the vertical layout.

zestful

  • Full Member
  • ***
  • Posts: 35
    • View Profile
Re: Basic questions for my layout
« Reply #3 on: October 07, 2024, 10:17:05 AM »
You can bind the change of layout to a custom button as in the example I provided. 

Bind custom1 to button X, custom2 to button Y, then have all your attribute positioned for horizontal layout on one button press, and verticle on the other.

Elaphe666

  • Jr. Member
  • **
  • Posts: 15
    • View Profile
Re: Basic questions for my layout
« Reply #4 on: October 08, 2024, 12:41:54 AM »
My question about changing layouts with one button was much simpler. Now I've found out that I just need to define both layouts in attract.cfg and then configure a key for "next_display".


Code: [Select]

display display
layout               horizontal
romlist              MAME
in_cycle             yes
in_menu              yes
global_filter       
rule                 Rotation equals 0|180

display display
layout               vertical
romlist              MAME
in_cycle             yes
in_menu              yes
global_filter       
rule                 Rotation equals 90|270