Author Topic: PopUp.nut displaying image behind background  (Read 1285 times)

allactiondan1

  • Newbie
  • *
  • Posts: 9
    • View Profile
PopUp.nut displaying image behind background
« on: March 04, 2023, 08:36:39 PM »
I want to have it that when I press a button it will display a help menu. I found an old thread here about doing just that using PopUp.nut. I did as the post said and it does display my image, but it's behind the background layer and every other layer instead of being right on top of everything. I can't seem to figure out how to change the Z order of the plugin image. I don't know if it matters but I'm using attract mode plus. Any help would be appreciated.

Here is the original thread http://forum.attractmode.org/index.php?topic=456.0

This is the script I used for popup.nut.
Code: [Select]
class UserConfig </ help="This plugin will show a popup image when the specified key is pressed." /> {
</ label="Image", help="The full path to the image that will be displayed", order=1 />
image="";
</ label="Key", help="The key that will display the image", is_input="yes", order=2 />
key="";
</ label="Hold Key", help="If enabled, you must hold the key down", options="Yes,No", order=3 />
hold="No";
};

class PopUpImage
{
        _image = null;
_key = null;
_hold = false;
_showing = false;
_key_delay = 250;
_last_check = 0;

        constructor()
        {
local config = fe.get_config();
_image = fe.add_image( config["image"], 0, 0, fe.layout.width, fe.layout.height );
_image.visible=false;
_image.preserve_aspect_ratio = true;
_key = config["key"];
_hold = config["hold"];
fe.add_ticks_callback( this, "on_tick" );
        }

function on_tick( ttime )
{
local is_down = fe.get_input_state( _key );
if ( _hold == "Yes" )
{
_image.visible = is_down;
_showing = is_down;
} else
{
if ( is_down )
{
if ( ttime - _last_check > _key_delay )
{
_last_check = ttime;
_image.visible = !_showing;
_showing = !_showing;
}
}
}
}
}

fe.plugin[ "PopUpImage" ] <- PopUpImage();

tankman37

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: PopUp.nut displaying image behind background
« Reply #1 on: December 22, 2023, 01:29:42 AM »
This may be a bit late for you, but i had the same question the other day, and same issue with PopUp.nut. Found this code on the Discord server. image will appear when you press and hold a key, in this case up or down. i use it for next page arrows. Hopefully someone one day will see this post and have a use. Just a note, the pop up.nut works on AM, but in AM+ the image appears behind everything ( some Z order thing i dont understand)


local image_up = fe.add_image ("arrow_up.png", 490,1125,100,100);
local image_down = fe.add_image ("arrow_down.png", 490,1605,100,100);
image_up.visible = false;
image_down.visible = false;
fe.add_ticks_callback( "tick_up" );
fe.add_ticks_callback( "tick_down" );
function tick_up( ttime )
{
    if (fe.get_input_state("Up")==true)
            {
                image_up.visible = true;
            
            }
   else if (fe.get_input_state("Up")== false)
            {
                image_up.visible = false;
            
            }
            return true;
   return false;
}

function tick_down ( ttime )
{
    if (fe.get_input_state("Down")==true)
            {
                image_down.visible = true;
            }
   else if (fe.get_input_state("Up")== false)
            {
                image_down.visible = false;
            }
            return true;
   return false;
}

jedione

  • Hero Member
  • *****
  • Posts: 1135
  • punktoe
    • View Profile
Re: PopUp.nut displaying image behind background
« Reply #2 on: January 02, 2024, 07:33:17 PM »
this will set custom1 to use as a pop up for the pic..

Code: [Select]
              local image_hud = fe.add_image ("images/hud.png", 250, 200, 1395, 683);

image_hud.visible = false;
function on_transition (ttime){


(fe.get_input_state ("custom1") ) ? image_hud.visible = true : image_hud.visible = false;
}

fe.add_ticks_callback ("on_transition");
help a friend....