Attract-Mode Support > Scripting

Pop up window for Infos

(1/1)

Neosys:
Hello!

How can I create a pop up window for infos (game info etc.).

I want to press a button and then open an info window.

How can I do that?

Thank you

keilmillerjr:
Create your surface and store all objects on it. Change visibility to be hidden. Add a signal handler for a custom button and toggle visibility for your surface.

Neosys:
Excuse me. But I do not know exactly how I should do that.

Can you please explain exactly what I have to do.

Thank you.

keilmillerjr:
Your excused. Im on a damn phone right now so I'm not going to do it all for you. I figured I'd just point you in the right direction. If your unfamiliar with attract mode and squirrel, look over the layouts markdown file. Specifically focus on parts I mentioned. If you attempt what I said and still have issues, post your code and I can look at it. Otherwise, you have to wait until I'm home from work and sitting in front of the computer with a few minutes of free time.

https://github.com/mickelson/attract/blob/master/Layouts.md#constants

gamesmame:
I liked this ideia!!! "I created" this with some infos:

// Step 1: Create a surface to store information objects
local infoSurface = fe.add_surface(fe.layout.width, fe.layout.height);
infoSurface.visible = false;

// Step 2: Add game information objects to the surface
local infoText = fe.add_text("", 50, 50, infoSurface.width - 100, infoSurface.height - 100);
infoText.set_rgb(255, 255, 255);
infoText.set_font("your_font", your_font_size);

local closeButton = fe.add_text("Close", infoSurface.width - 100, infoSurface.height - 50, 100, 50);
closeButton.set_rgb(255, 0, 0);
closeButton.set_font("your_font", your_font_size);
closeButton.preserve_aspect_ratio = true;

// Step 3: Add signal handler for the custom button
local showInfoButton = fe.add_text("Show Info", 100, 100, 100, 50);
showInfoButton.set_rgb(0, 255, 0);
showInfoButton.set_font("your_font", your_font_size);

showInfoButton.add_signal("on_trigger", "toggleInfoVisibility");

// Toggle visibility function
function toggleInfoVisibility()
{
    infoSurface.visible = !infoSurface.visible;
}

// Use this function to update the information displayed on the infoText
function updateInfoText()
{
    infoText.msg = "Game Title: " + fe.game_info(Info.Title) + "\n" +
                   "Year: " + fe.game_info(Info.Year) + "\n" +
                   "Genre: " + fe.game_info(Info.Genre);
}

// Add a signal handler to update the information when a game is selected
fe.add_signal("on_game_selected", "updateInfoText");

BUT i dont know how this work exacly... some part code or almost code dont work or something its wrong  :-\

Navigation

[0] Message Index

Go to full version