Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - gamesmame

Pages: [1] 2 3 ... 7
1
Scripting / I'm trying to do in Attract-Mode (Help Needed!) Please
« on: April 16, 2025, 05:24:19 PM »
## 🧵 What I'm trying to do in Attract-Mode (Help Needed!)

Hello everyone, I need some help with a layout I'm creating in Attract-Mode.

I'm trying to load custom artwork positions (x, y, width, height) from a per-game `.txt` file and apply them dynamically when the layout is loaded.

---
### ✅ What I have so far

Each game has a corresponding text file like this, stored in:
```
M:/Media/Nintendo Entertainment System/LayoutsData/
```

Example file: `Abadox - The Deadly Inner War (USA).txt`
```
snap_x=100
snap_y=120
snap_w=900
snap_h=680
art3_x=0
art3_y=0
art3_w=1920
art3_h=1080
```

---
### 🧠 My layout.nut logic

I'm using this Squirrel code in `layout.nut`:

```nut
fe.layout.width = 1920;
fe.layout.height = 1080;

function read_config(path)
{
    local config = {};
    try {
        local f = file(path, "r");
        if (typeof f.read_line != "function") {
            print("Invalid file: " + path + "\n");
            return config;
        }

        while (!f.eos())
        {
            local line = f.read_line().strip();
            if (line == "" || line.find("=") == null) continue;
            local parts = line.split("=");
            if (parts.len() >= 2)
            {
                local key = parts[0].strip();
                local value = parts[1].tointeger();
                config[key] <- value;
            }
        }
        f.close();
    } catch(e) {
        print("Error reading config: " + path + "\n");
    }
    return config;
}

local game_name = fe.game_info(Info.Name);
local config_path = "M:/Media/Nintendo Entertainment System/LayoutsData/" + game_name + ".txt";
local cfg = read_config(config_path);

// Default values if not found
local snap_x = cfg.rawin("snap_x") ? cfg["snap_x"] : 100;
local snap_y = cfg.rawin("snap_y") ? cfg["snap_y"] : 100;
local snap_w = cfg.rawin("snap_w") ? cfg["snap_w"] : 640;
local snap_h = cfg.rawin("snap_h") ? cfg["snap_h"] : 480;

local art3_x = cfg.rawin("art3_x") ? cfg["art3_x"] : 0;
local art3_y = cfg.rawin("art3_y") ? cfg["art3_y"] : 0;
local art3_w = cfg.rawin("art3_w") ? cfg["art3_w"] : fe.layout.width;
local art3_h = cfg.rawin("art3_h") ? cfg["art3_h"] : fe.layout.height;

local bg = fe.add_artwork("background", 0, 0, fe.layout.width, fe.layout.height);
bg.preserve_aspect_ratio = false;

local snap = fe.add_artwork("snap", snap_x, snap_y, snap_w, snap_h);
snap.preserve_aspect_ratio = true;

local art3 = fe.add_artwork("artwork3", art3_x, art3_y, art3_w, art3_h);
art3.preserve_aspect_ratio = true;
```

---
### ❌ Issue I'm facing

The layout loads the background and artworks, **but it seems to ignore the values from the config files.** No error appears, but the coordinates from the `.txt` file aren’t being applied.

If I hardcode the values, it works. If I try to apply them dynamically via `.x`, `.y`, `.width`, `.height` after `add_artwork`, then nothing shows.

---
### 🔍 What I tried that **didn’t work**:

```nut
local snap = fe.add_artwork("snap", 0, 0, 640, 480);
if ("snap_x" in cfg) snap.x = cfg["snap_x"];
if ("snap_y" in cfg) snap.y = cfg["snap_y"];
if ("snap_w" in cfg) snap.width = cfg["snap_w"];
if ("snap_h" in cfg) snap.height = cfg["snap_h"];
```

Same thing for `art3`. Nothing is rendered.

---
### 💬 What I'm looking for

I just want to read position values from `.txt` files per game and dynamically apply them to `add_artwork` objects. If someone has done something similar or sees what's wrong, I’d really appreciate any help or working example.

Thanks a lot!

2
Emulators / Re: Various emulator settings
« on: December 28, 2024, 07:02:48 AM »
@Yaron  @PaCiFiKbAllA  @Oomek @jedione @hermine.potter your ARE the MASTERS of programing please http://forum.attractmode.org/index.php?topic=4598.0 Please help him, the Super Pause Menu its very amazing!!!

3
General / Re: Chadmando's super pause menu
« on: December 28, 2024, 06:59:20 AM »
@Yaron  @PaCiFiKbAllA  @Oomek @jedione @hermine.potter your ARE the MASTERS of programing please http://forum.attractmode.org/index.php?topic=4598.0 Please help him, the Super Pause Menu its very amazing!!!!!!  :D ;D ;D ;D ;D

4
Have a way to make/create one "HYPERPAUSE" like RocketLauncher for attractmode? i dont like to use RL because some times give a bug with RL when exits game in some times. I like to use one "ATTRACTPAUSE" if have a possibility.

5
Scripting / Re: Pop up window for Infos
« 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  :-\

6
Emulators / Help with MAME CD+floppy i dont find in anywere... please...
« on: August 20, 2023, 04:09:28 AM »
i use this: mame fmtmarty -cdrom 38man -skip_gameinfo

LOAD GAME OK, but in game the game needs the disk/floppy inserted (boot disk/floppy) and i dont know how i put this in code for LOAD CD and the boot disk togetter

7
Thanks friend, i see this too but i belive, have way to make it... auto play the tape... but i dont know how... maybe @hermine.potter know some thing about this..

8
With this .bat:

mame fmnew7 -skip_gameinfo -autoboot_command "load\n" -autoboot_delay 4 backgamm -uimodekey F2

I open the game XXXX after that I click on F2 and it (MAME) autoloads(PLAY) the cassette(tape) then just hold the insert for a few seconds and it accelerates the tape(PLAY) until the end and after that the game was loaded then I need to type RUN and press ENTER on the keyboard.. only then the game opens and is ready to be played!!!  ;D

Manually after opening the .bat, I need to MANUALLY click on F2 and then click and HOLD the Insert key and after finishing the reading type RUN and press enter MANUALLY...

Question is... how do I automate this in .bat? Because I get it in .bat I will transfer the modifying code to use in attractmode. or can you automate these commands directly in attractmode  :-\?

9
for example, read cbr and pdf with no choose, but automatic.. :P

10
How i make the sumatra read all formats with no need change options!!! have this way?!!! have this way?

plugin.nut

Code: [Select]
///////////////////////////////////////////////////
//
// Attract-Mode Frontend - SumatraPDF  WIP plugin (By Machiminax)
//
// For use with the SumatraPDF Reader
//
///////////////////////////////////////////////////

//
// The UserConfig class identifies plugin settings that can be configured
// from Attract-Mode's configuration menu
//
class UserConfig </ help="Read your Manuals with SumatraPDF" /> {

    </ label="Command", help="SumatraPDF launcher", order=1 />
    command="SumatraPDF.bat";
    </ label="Extension", help="File extension to use", options=".pdf, .chm, .djvu, .djv, .epub, .fb2, .fb2.zip, .mobi, .prc, .oxps, .xps, .cb7, .cbr, .cbt, .cbz", order = 2 />
    extension=".pdf";
    </ label="Path", help="Path to manuals - can include [Name], [Emulator], [Year], [Manufacturer], [System], [DisplayName]", order = 3 />
    path="Game Manuals/[Emulator]";
    </ label="View Key", help="Key to use to view", options="custom1,custom2,custom3,custom4,custom5,custom6", order = 4 />
    key="custom1";
    </ label="Missing Image", help="Path to 'missing' image - can include [Name], [Emulator], [Year], [Manufacturer], [System], [DisplayName]", order = 5 />
    missing="png/Manual_not_found.png";
}

local config=fe.get_config(); // get user config settings corresponding to the UserConfig class above

//
// Copy the configured values from uconfig so we can use them
// whenever the transition callback function gets called
//

class PDFManualReader
{
    VERSION=1.1;
    game_name=null;

    constructor()
    {
        fe.add_signal_handler( this, "on_signal" )
    }


    function on_signal( signal )
    {
            if ( signal == config["key"] )
            {
                local path = get_magic_token_path(config["path"]);
                local game_name = fe.game_info(Info.Name);
                local filename = "\"" + path + game_name + config["extension"] + "\"";
                local missing_path = get_magic_token_path(config["missing"]);
                local missing = "\"" + missing_path.slice(0, missing_path.len() - 1) + "\"";
                local exe = FeConfigDirectory  + "/plugins/SumatraPDF/" + config["command"];
                print("Launching SumatraPDF:\n");
                print(" " + exe + " " + filename + " " + missing + "\n");
                fe.plugin_command_bg( exe, filename + " " + missing );
                return true;
            }
            return false;
    }
   
    //replace specified magic tokens in path
    function get_magic_token_path(path) {
        local tokens = {
            "Name": fe.game_info(Info.Name),
            "Emulator": fe.game_info(Info.Emulator),
            "Year": fe.game_info(Info.Year),
            "Manufacturer": fe.game_info(Info.Manufacturer),
            "Category": fe.game_info(Info.Category),
            "System": fe.game_info(Info.System),
            "DisplayName": fe.list.name
        }
        foreach( key, val in tokens)
            path = replace(path, "[" + key + "]", val);
           
        //replace slashes with backslashes
        path = replace(path, "\\", "/");
        //ensure trailing slash
        local trailing = path.slice(path.len() - 1, path.len());
        if ( trailing != "/") path += "/";
        return path;
    }
   
    //replace all instances of 'find' in 'str' with 'repl'
    function replace(str, find, repl) {
        local start = str.find(find);
        if ( start != null ) {
            local end = start + find.len();
            local before = str.slice(0, start);
            local after = str.slice(end, str.len());
            str = before + repl + after;
            str = replace(str, find, repl);
        }
        return str;
    }
}

PDFManualReader();

11
Jedione how plugin you use? i use one here sumatra and works good but after load PDF i put right or left for read the manual the attractmode in background go to sides change games in list, i need after load the plugin block/disable the controles in background/attractmode so and after closes the plugin/sumattra back controles to attractmode!!! you understand?

12
General / Help this code works? i try but not sucess!!
« on: March 27, 2023, 01:20:44 PM »
I tried to create a simple and elegant layout to experiment with. This layout displays a background image and a list of available games on the main screen. When selecting a game, a menu should appear with the options "Play", "Manual" and "Video".

But do I think something is missing, or is the code completely wrong?

Code: [Select]
// Configurações
local bg = fe.add_artwork("backdrop", fe.add_image(bg_image)) // nome da imagem de fundo
local font_name = "Roboto Regular" // nome da fonte
local font_size = 20 // tamanho da fonte
local title_offset_y = 80 // distância do título em relação ao topo
local item_height = 40 // altura de cada item da lista
local item_spacing = 10 // espaçamento entre os itens da lista
local menu_options = [    ["Jogar", "emulator", "[name]"],
    ["Manual", "exec", "[rompath]/manual.pdf"],
    ["Vídeo", "exec", "[rompath]/video.mp4"]
]

// Imagem de fundo
local bg = fe.add_artwork("backdrop", bg_image)
bg.preserve_aspect_ratio = true
bg.trigger = Transition.EndNavigation
bg.post_trigger = Transition.ToNewVideo

// Título
local title = fe.add_text("[Title]", 0, title_offset_y, fe.layout.width, font_size*2, font_name, font_size*2, 0xffffffff, Effect.Fade)
title.word_wrap = true
title.align = Align.Center
title.trigger = Transition.EndNavigation
title.post_trigger = Transition.ToNewVideo

// Lista de jogos
local list = fe.add_list("romlist", 0, title_offset_y + title.height + item_spacing, fe.layout.width, fe.layout.height - (title_offset_y + title.height + item_spacing), font_name, font_size, 0xffffffff, Effect.Fade)
list.spacing = item_spacing
list.trigger = Transition.EndNavigation
list.post_trigger = Transition.ToNewVideo

// Ações
list.on_change = function( selected_item ) {
    title.set_text( selected_item.parent.get_name( selected_item ) )
}

list.on_select = function( selected_item ) {
    local sel = fe.do_menu(menu_options, "Menu")
    if (sel == -1) fe.exit()
    fe.do_action(sel)
}

13
Themes / Re: new attractmode arcade_downloader theme, "preview"
« on: March 06, 2023, 01:57:52 PM »
Cool  ;D

14
Themes / Re: My New Jukebox Theme
« on: May 25, 2022, 02:47:49 PM »
Cool man!!! great!!

15
Scripting / Dobout with Sumatra
« on: April 21, 2022, 01:22:45 PM »
I Have many manuals in PDF and CBR!!! example: abadox.PDF and batletoads.CBR I have in same folder 100pdf and 100 cbr mixed one game in pdf other in cbr!!
Have a way i use(plugin look) 2 extension sametime? For example: .PDF and .CBR? How i make this works?

How i change this in code?

Other dobout... how i make the "sumatra/code/plugin,etc.." delete the sumatrapdfcache when i exit from game manual? sumatra creates one cache and this with the time pass its a BIG GB's trash space lost!!

Pages: [1] 2 3 ... 7