Author Topic: Pop up window for Infos  (Read 5732 times)

Neosys

  • Full Member
  • ***
  • Posts: 50
    • View Profile
Pop up window for Infos
« on: March 23, 2017, 12:52:56 PM »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Pop up window for Infos
« Reply #1 on: March 23, 2017, 01:27:39 PM »
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

  • Full Member
  • ***
  • Posts: 50
    • View Profile
Re: Pop up window for Infos
« Reply #2 on: March 23, 2017, 01:41:24 PM »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Pop up window for Infos
« Reply #3 on: March 23, 2017, 02:22:50 PM »
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

  • Full Member
  • ***
  • Posts: 98
    • View Profile
Re: Pop up window for Infos
« Reply #4 on: February 03, 2024, 04:46:28 AM »
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  :-\
« Last Edit: February 03, 2024, 04:49:28 AM by gamesmame »