Author Topic: Creating an MVS module - having odd issue with index offset?  (Read 3755 times)

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Creating an MVS module - having odd issue with index offset?
« on: April 02, 2017, 12:08:54 PM »
I am finally getting around to creating an mvs module. Usage will be to have artwork like a neo geo multislot, and navigate all slots. When user is on the last slot, or first slot, and continues in that direction, all slots will shift over.

Example: Numbers are list entry. O is a selected game.

1 2 3 4
O x x x

->

1 2 3 4
x O x x

->

1 2 3 4
x x O x

->

1 2 3 4
x x x O

->

2 3 4 5
x x x O

<-

2 3 4 5
x x O x

The issue I am having thus far is that when I send mvs.slot_artwork[0].file_name in the log it yields nothing, yet all other slots yield a correct file name. It doesn’t make any sense to me. Can anyone spot the issue?

Here’s my code so far.

Code: [Select]
class MVS {
artwork_label = "";
num_slots = 0;
opacity = 0;
artwork_parent = null;
slot_artwork = [];
selected_slot = 0;

constructor(a="marquee", n=4, o=25, ap=::fe) {
artwork_label = a;
num_slots = n;
opacity = o;
artwork_parent = ap;

for (local i=0; i<num_slots; i++) {
slot_artwork.push(artwork_parent.add_artwork(artwork_label, -1, -1, 1, 1));
}

set_slots();
}

function set_slots() {
for (local i=0; i<num_slots; i++) {
slot_artwork[i].index_offset = -(selected_slot - i);
}
}
}


Code: [Select]
// --------------------
// Load Modules
// --------------------
if (fe.load_module("Debug")) log <- Log();
fe.load_module("shader");
fe.load_module("helpers");
fe.load_module("fade");
fe.load_module("mvs");


// --------------------
// Layout User Options
// --------------------
class UserConfig {
}
local config = fe.get_config();

// --------------------
// Layout Constants
// --------------------
local flw = fe.layout.width;
local flh = fe.layout.height;

// --------------------
// Colors
// --------------------
local colors = {
black = { r = 0, g = 0, b = 0 },
white = { r = 255, g = 255, b = 255 },
grey = { r = 120, g = 120, b = 120 },
}

// --------------------
// Settings
// --------------------
local settings = {
snap = {
x = 0,
y = 0,
width = flw,
height = flh,
},
}

// --------------------
// Magic Functions
// --------------------

// --------------------
// Layout
// --------------------
local snap = FadeArt("snap", -1, -1, 1, 1);
setProperties(snap, settings.snap);

local mvs = MVS();
try { log.send(mvs.slot_artwork[0].file_name + " " + mvs.slot_artwork[0].index_offset); } catch(e) {}
try { log.send(mvs.slot_artwork[1].file_name + " " + mvs.slot_artwork[1].index_offset); } catch(e) {}
try { log.send(mvs.slot_artwork[2].file_name + " " + mvs.slot_artwork[2].index_offset); } catch(e) {}
try { log.send(mvs.slot_artwork[3].file_name + " " + mvs.slot_artwork[3].index_offset); } catch(e) {}

// --------------------
// Enable Shaders
// --------------------


Code: [Select]
Keils-iMac:MacOS keiljr$ /Applications/Attract.app/Contents/MacOS/attract
Starting Attract-Mode v2.2.0-3 (OSX)
Config: /Users/keiljr/.attract/attract.cfg

*** Initializing display: 'Neo Geo'
 - Loaded master romlist 'mame' in 1 ms (147 entries kept, 10 discarded)
 - Constructed 10 filters in 0 ms (1470 comparisons)
Fontconfig error: Cannot load default config file
 - Debug message:  0
 - Debug message: /Applications/mame0182b_macOS/marquees/roboarmy.png 1
 - Debug message: /Applications/mame0182b_macOS/marquees/svc.png 2
 - Debug message: /Applications/mame0182b_macOS/marquees/samsho.png 3
 - Loaded layout: /Users/keiljr/.attract/layouts/mvscomplete/ (layout.nut)

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Creating an MVS module - having odd issue with index offset?
« Reply #1 on: April 02, 2017, 12:45:57 PM »
https://github.com/mickelson/attract/blob/master/Layouts.md#Image
Quote
#### `fe.Image` ####

index_offset - Get/set offset from current selection for the artwork/ dynamic image to display. For example, set to -1 for the image corresponding to the previous list entry, or 1 for the next list entry, etc. Default value is 0.

When I set index_offset to 0, there is no file_name.

bjose2345

  • Sr. Member
  • ****
  • Posts: 107
    • View Profile
Re: Creating an MVS module - having odd issue with index offset?
« Reply #2 on: April 02, 2017, 02:48:56 PM »
Could you post some image or video to see exactly the error, I do not understand the problem very well  :-[

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Creating an MVS module - having odd issue with index offset?
« Reply #3 on: April 02, 2017, 05:56:35 PM »
Could you post some image or video to see exactly the error, I do not understand the problem very well  :-[

Images show correctly, but look at the debug message. File name will not return for mvs.slot_artwork[0].

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Creating an MVS module - having odd issue with index offset?
« Reply #4 on: April 02, 2017, 07:12:17 PM »
Here’s a video of it working. Keep in mind that the module is not finished. I still don’t understand why I cant return the file name for slot 0. Oh well.

https://vimeo.com/keilmiller/mvscompletepreview

bjose2345

  • Sr. Member
  • ****
  • Posts: 107
    • View Profile
Re: Creating an MVS module - having odd issue with index offset?
« Reply #5 on: April 02, 2017, 11:55:23 PM »
its kinda hard but maybe the problem could be this line:

slot_artwork.index_offset = [here]-[/here] (selected_slot - i);

that negative is correct there?
« Last Edit: April 02, 2017, 11:59:12 PM by bjose2345 »