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 - Bgoulette

Pages: 1 [2]
16
Scripting / Help me wrap my head around the Conveyor module!
« on: November 18, 2015, 01:11:19 PM »
Hi all,

I've looked through the code for the conveyor module and the SimpleArtStrip class, but I still can't wrap my brain around how to actually use it in a layout. For my purposes, a simple extension of the SimpleArtStrip and SimpleArtStripSlot classes should meet my needs, but I have no idea how to actually make a conveyor -- even the default -- show up on the screen. I don't know what else I'm doing, either, but I figure if I started there, that'd be a good place...

I just want a horizontal strip of snaps to move either left or right depending on whether the user moves up or down in the game list. I want it to take one second between transitions and stop on the next entry in the list (up or down).

Can anyone break down how to use the conveyor for a toddler? :( Thanks!

17
Hi all,

I'm trying to get an image added to a surface to fill the surface but maintain aspect ratio. What I mean is I have the preserve_aspect_ratio flag set to true, but that keeps the asset "inside" the container, meaning you'll get letter- or pillar-boxing if the image isn't exactly the size of the container. What I want to do is treat the smallest dimension of the image to be loaded as the maximum size of the corresponding container dimension and scale the other dimension accordingly, meaning that in such cases, parts of the image would be "clipped."

An example: if I have a container (a surface we'll say) that's 100x100 and I have a snap that's 100x50 (for easy math!), I'd want AM to be able to see it as 200x100, thus ensuring that the container is filled even if it means I'm missing the "sides" of my image.

I tried an unholy combination of width, height, and subimg properties and positioning, and while it worked most of the time (or appeared to), on rare occasions, something would cause it to flip out. Here's what I have (that doesn't completely work):

Code: [Select]
function sizeSnap (str_sig)
{
/**/
// Determine snap width/height (subimg_) and scale accordingly:
// Take the smaller value and scale to SNAP_SIZE
local r=1.0; // ratio
local dims={w=snap.subimg_width, h=snap.subimg_height};

// If we haven't already, let's adjust the snap size:
if (dims.w > dims.h) {
// Wider
r=(dims.w+0.0)/dims.h;
snap.height=SNAP_SIZE;
snap.width=SNAP_SIZE*r.tofloat();
}
else if (dims.w < dims.h) {
// Taller
r=(dims.h+0.0/dims.w);
snap.width=SNAP_SIZE;
snap.height=SNAP_SIZE*r.tofloat();
}
else {
// Equal
snap.width=SNAP_SIZE;
snap.height=SNAP_SIZE;
}

// Position in frame:
snap.x=(SNAP_SIZE-snap.width)/2.0;
snap.y=(SNAP_SIZE-snap.height)/2.0;
/**/
}

(This assumes the constant SNAP_SIZE is defined and "snap" is an artwork image added earlier in the code.)

It's mostly there, just on occasion, moving up or down the list will cause a freak out that, typically, results in an image appearing as a bunch of vertical bars (even on images that are wider than tall). Not sure where that's happening...

Any thoughts? Or is there a simpler way to do this?! Thanks!

18
Scripting / What's the right way to access the entries in a list?
« on: August 20, 2015, 02:28:07 PM »
Hi all,

I'm trying to create a kind of "flip card" layout, but in order to do it, I need to know the right way to access all (or at least a specified subset) of the entries in the current filter, and I'm not sure how to go about determining that. Specifically, when I'm creating an array of "cards," each card has that game's snap on it, etc. I guess what I'm really asking is how do I get the next/previous, etc. snaps of the currently selected game? I've tried studying the SimpleArtStrip example, but I'm obviously missing something. I'll keep at it, but in case anyone had any other ideas... Thanks!

19
Scripting / Surfaces. How do they work?!
« on: August 18, 2015, 12:27:14 PM »
Hi all,

I have a bunch of junk I'm trying to cram into a surface, like this:

Code: [Select]
local surfSnap=fe.add_surface(280, 140);
surfSnap.set_pos(0, 60);

local snap_bg=surfSnap.add_image("snap_bg.png", 0, 0, 280, 140);
local snap_img=surfSnap.add_artwork("snap", 0, 0, 280, 140);

If I don't use surfaces, I can stack 'em up and they display as expected, but I'm trying to lay the groundwork for some motion, and surfaces appear to be the way to go. Am I missing something? I tried setting the surface object's alpha, visible, set_rgb, but nothing changed what I was seeing. I'd appreciate any insight! Thanks!

20
Scripting / Multiline? Expanded tokens? Oh my!
« on: August 15, 2015, 07:52:14 PM »
Hi all,

I'm poking around under the hood, probably in places I shouldn't, but here are my latest questions:

I have a text item that I want to span 3 lines. Once in a while, it'll work if I feed it a string like g_name+"\n"+g_cat+"\"+g_players ; other times, AM instantly crashes. Am I doing something wrong? Here's what I really want to happen:

When switching to the next game in the list, I want its ROM name, its category, and how many players it supports listed (hence the above variables). Here's the other thing: I'd also like to get the actual text for the category and the actual integer value for how many players, but I don't know how to do that. I tried using fe.game_info(Info.Category, index_offset) and fe.game_info(Info.Players, index_offset), but that only ever returns information related to the very first ROM displayed in the layout; moving up or down changes nothing. For the number of players, at least, I'd like to add a statement that "prettifies" the count, something like this:

Code: [Select]
local num_players, g_players;
g_players=(num_players==1 ? "1 player" : num_players.tostring()+" players");

So what I need to do is find some way to get the  currently displayed game's category and number of players (and name, and everything, but hey) in an object format, or find some means to expand the tokens and save the actual values into new variables.

Am I misunderstanding how fe.game_info() should work, or is there something else I need to implement to "kick it" to get updated ROM data when I switch to the previous/next game?

Oh, some notes: I have word_wrap enabled in the particular text field I'm using, and, as I said, sometimes it works, but -- and here's the head scratcher -- if the last game displayed didn't have anything in its category slot, AM would instantly die; if I disabled the newlines and category for a moment, moved up or down to a game with category information, then reenabled it, it would work! Weird!

As always, I'd appreciate any help or insight anyone can provide! Thanks!

21
Scripting / Gaussian blur filter shader: How?!
« on: August 15, 2015, 01:28:02 PM »
Hey all,

I'm trying to mess around with layouts, and I have the (very) basics down, I think, but I want to add a gaussian blur shader to part of it. Except I don't know how to write one and what I've been able to find on the internet looks... all right, it looks weird, but the way they have [Vertex_Shader] and [Pixel_Shader] sections makes squirrel angry, so straight up cutting and pasting is out. I'm happy to learn, but I'm such a neophyte that I'm not even sure where to really begin looking. Any advice or direction would be greatly appreciated! Thanks!

22
General / Yet another n00b filter question
« on: August 13, 2015, 09:56:45 PM »
Hey all,

I'm curious to learn if there's a way to filter based on, say, games released before or after a certain year. Basic greater than/less than comparators. But I'm not sure how (if?) they might be implemented in the filters. I have other filters working, but not sure what to do for this (assuming it's even possible)! If there is a way to do this, I'd also use it in games that can be either 1 or more (e.g., 1, 2, 3, 4) players, etc. Anyway, thanks!

Pages: 1 [2]