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.


Topics - Arcade-TV

Pages: [1]
1
Scripting / Fixing "next/prev_letter" hanging on certain titles.
« on: January 01, 2023, 04:36:53 PM »
This is my fix for AM hanging on letters when the "Title" has a different case as the previous entry, has special or numeric chars in it or other reasons as the famous "vs." or ", The" hanging.
Pre-sorting your romlists by "Title" (2nd entry in the csv file) helps.
I hope I correctly copied this from my layout file. Pls let me know otherwise.


Layout:

Code: [Select]
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Fixing next_letter / prev_letter /////////////////////////////////////////////////////////////////////////////////////

::current_signal <- "";

function setCurrentLetterIndex() {
    ::print("setCurrentLetterIndex()\n");
    ::print("list idx:"+fe.list.index+", currentLetterIndex:"+::currentLetterIndex+"\n");
    for(local i=0; i < ::letterIndexes.len(); i++) {
        if(::letterIndexes[i] >= fe.list.index) {
            ::currentLetterIndex = i-1;
            return;
        }
    }
    ::currentLetterIndex = (::letterIndexes.len()-1);
}

function buildLettersArray() {
    ::print("CurrentList: "+fe.list.index+" of "+fe.list.size+"\n");
    ::currentLetterIndex <- 0;
    local list_size = fe.list.size;
    local g;
    ::letterIndexes <- [];
    local l_prevLetter = "";
    for(g = 0; g < list_size; g++) {
        local l_gameTitle = fe.game_info( Info.Title, g-fe.list.index );
        local l_gameLetter = l_gameTitle.slice(0, 1);
        l_gameLetter = l_gameLetter.tolower();
        // declare any other char than a-z as numeric:
        if(l_gameLetter != "a" && l_gameLetter != "b" && l_gameLetter != "c" && l_gameLetter != "d" && l_gameLetter != "e" && l_gameLetter != "f" && l_gameLetter != "g" && l_gameLetter != "h" && l_gameLetter != "i" && l_gameLetter != "j" && l_gameLetter != "k" && l_gameLetter != "l" && l_gameLetter != "m" && l_gameLetter != "n" && l_gameLetter != "o" && l_gameLetter != "p" && l_gameLetter != "q" && l_gameLetter != "r" && l_gameLetter != "s" && l_gameLetter != "t" && l_gameLetter != "u" && l_gameLetter != "v" && l_gameLetter != "w" && l_gameLetter != "x" && l_gameLetter != "y" && l_gameLetter != "z") {
            l_gameLetter = "0";
        }
        // fill letterIndexes array:
        if(l_prevLetter != l_gameLetter) {
            ::letterIndexes.push(g-1);
            l_prevLetter = l_gameLetter;
            ::print(l_gameLetter+": "+g+"\n");
        }
    }
    setCurrentLetterIndex();
}
buildLettersArray();

::print("::currentLetterIndex: "+::currentLetterIndex+"\n");

function prevLetter() {
    if(::currentLetterIndex == 0) {
        ::currentLetterIndex = ::letterIndexes.len()-1;
    }else{
        ::currentLetterIndex--;
    }
    jumpToLetter("prev");
}

function nextLetter() {
    if(::currentLetterIndex >= ::letterIndexes.len()-1) {
        ::currentLetterIndex = 0;
    }else{
        ::currentLetterIndex++;
    }
    jumpToLetter("next");
}

function jumpToLetter(dir) {
    switch(dir) {
        case "next":
            fe.list.index = ::letterIndexes[::currentLetterIndex]+1;
            break;

        case "prev":
            fe.list.index = ::letterIndexes[::currentLetterIndex+1];
            break;
    }
}

Transition Callback:

Code: [Select]
function transition_callback(ttype, var, ttime)
{
    switch ( ttype )
    {
        case Transition.ToNewList:
            buildLettersArray();
            break;

        case Transition.EndNavigation:
            switch (::current_signal) {

                case "prev_letter":
                    setCurrentLetterIndex();
                    break;

                case "next_letter":
                    setCurrentLetterIndex();
                    break;

                case "prev_game":
                    setCurrentLetterIndex();
                    break;

                case "next_game":
                    setCurrentLetterIndex();
                    break;
            }
            break;
    }

    return false;
}

fe.add_transition_callback("transition_callback" );



onSignal:

Code: [Select]
function on_signal(str) {
   
if (str != "") {
::current_signal <- str;
    }

    case "prev_letter":
        prevLetter();
        return true;
        break;

    case "next_letter":
        nextLetter();
        return true;
        break;

    return false;
}

fe.add_signal_handler(this, "on_signal");


2
General / Voice-over for layouts
« on: February 02, 2019, 06:43:42 PM »
I'd like to share this set of voices I made while experimenting with Attract Mode layouts...

https://www.dropbox.com/sh/f3zb52qsuqmbuhp/AAAUgWOYdzGg7X6tHgWJvEFta?dl=0


Maybe someone finds this useful.

3
Scripting / Diving into squirrel-scripting: some questions
« on: January 30, 2019, 01:26:04 AM »
Hey guys,
I'd like to thank you for all the efford that went into attract mode. Having the freedom of doing so much with it is just awesome.

I'm creating a layout for a 240p-setup to be outputted to a crt and ran into some questions I'd like to sort out.

First issue is with the default font and missing font-size parameter for it:
The font-size is calculated by the layout's size. Mine is 320x240 so the font in my "Configure"-menu is appx. 8px in height, which is okay as long as I use a pixel-font that was created with 8px height in mind. The help-messages on the bottom of the menu are rendered smaller, appx 5px in height in my layout, so again, if I use a font like "CG pixel 4x5" those texts display just fine but the menu-items don't display properly because the 5px font is stretched to a height of 8px.
I would love to see some more parameters to target this issue maybe sometime in the future development of attract mode.

Next is a scripting question about creating a condition for "DisplayName". This does exist as a Magic Token so it can be used in "add_text" but when I want to create a condition I fail to do something like this:

Code: [Select]
if([DisplayName] == "Displays Menu"){
    // code for the layout where I can select the different displays/systems
}else{
    // code for layouts that relate to a display/emulator/gamelist
}

I use snaps with a low alpha value in the background and titles as a small preview image in my layout. When a display has a lot of entries in its gamelist I see performance issues while navigating through the list of games, so I'd like to remove all media while browsing and add it back to the layout after a delay-timer counted to a given value. I've seen concepts like this in other threads but I have to ask:
How can remove an image or artwork and use a function to add it to the layout.
Something like this, called on transition-callbacks doesn't seem to work:
Code: [Select]
function showImage(){
    fe.add_image(...);
}

I sure have some more questions, but for a start this is enough ;-)


Thanks, any help with this is very much appreciated!

Pages: [1]