Choose method - Graphics bug?

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Choose method - Graphics bug?

Post by meadwarrior »

Hello!

While working on the GUI, I noticed a strange thing about the choose method container:

Image

There's a black bar where the mouse point at.
I can offset the actionbutton's x value to change that, but I don't know how to re-position the weapon markers and the 'weapon in use' mosaic. I guess it's something in the render.lua, but I'm not proficient enough with scripting to understand anything that's going on in that... :?

Thanks!
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Choose method - Graphics bug?

Post by Gambit37 »

First, nice work on your UI! :)

Are there differences between your graphics and the templates found in DSB? If you keep your graphics exactly the same size as those in the DSB graphics download, there shouldn't be any layering/position problems.

The issues only start if you change the size of your graphics. At that point, you need to start getting your hands dirty in the render.lua code to update the sizes/offsets -- so that DSB will draw things in your intended layout.
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: Choose method - Graphics bug?

Post by meadwarrior »

Thanks, Gambit!

I took the exact same size for the all graphics (except the top_hands, but those work fine).
The border is there even in the base version with the original graphics, the GUI elements are just positioned in a way that hides it (cramped to the sides of the screen, so to speak, which I don't like very much).

Where could I find the offsets in the render.lua? I searched around for x or y values, but haven't found much...

Thanks!
User avatar
Gambit37
Should eat more pies
Posts: 13715
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Choose method - Graphics bug?

Post by Gambit37 »

I wrote a longer reply, then realised the result is simpler than I first thought:

I think you have probably moved the whole thing over to the left a bit. The function to draw the action boxes starts by clearing the whole thing to black, which is where your black bar is coming from as the whole module is now "on top" of the dungeon view.

Try changing the {0,0,0} on line 109 of render.lua to {255,0,255}. I think that should fix it. The number in the {} is a RGB colour, and each of the values can range from 0 to 255. The values {255,0,255} make a bright pink colour (powerpink) which in DSB is rendered as transparent.

Although this is a quick fix, it would still be better to modify the function so that everything is rendered further to the right. It's probably not good practice to have these modules being drawn over the dungeon viewport.

ORIGINAL ANSWER, which you can ignore unless you're going to modify the button positions:

Have a look at function sys_render_attack_options(bmp, frozen) in render.lua. This loops through the number of champions and draws an action button for each one.

Line 112 renders out the attack button at a calculated x/y point. The y value is always 18, but the x value is 10 + 44 * i. These values are:

* 10 pixels from the left edge of the module
* the width of the action button image (40) and 4 pixels "padding" to create the small gap before the next button is drawn
* multiplied by the current loop value. The current loop is controlled by variable i and goes from 0 to 3 (line 109 in this function).

So the first time through the loop, the value of i is 0. This means the x coordinate for the first button is 10+ (44 * 0 = 0) -- therefore, the first button is drawn 10 pixels from the left edge of the module (remember, the x pos of the "methods" module is defined in gui_info.lua). The second time through the loop, we get a value of 10 + (44 * 1) = 54, so that's the x position of the second button. And so on.

The position of the weapon icon on the button uses a similar formula and is on line 135.

Lines 138-140 create the pattern grid to "ghost out" the panel if relevant, and the following line creates the invisible clickzone for the size of the action button.
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: Choose method - Graphics bug?

Post by meadwarrior »

That worked! Thank you!
It's good to have at least a small grasp of what happens inside the render.lua. Thanks for the detailed explanation!
I used the 'easier' solution for now but I'll try the more complicated one when I'm a bit more comfortable with everything.
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Choose method - Graphics bug?

Post by Sophia »

The positions and sizes of the gui elements are specified in base/gui_info.lua, but I assume you've already found that since you've been moving stuff around. :mrgreen:
User avatar
meadwarrior
Journeyman
Posts: 91
Joined: Sat Dec 01, 2018 1:02 am

Re: Choose method - Graphics bug?

Post by meadwarrior »

:mrgreen: Nice and tidy!

Image

By the way, thank you for commenting everything in the code, Sophia. Makes it a lot easier for beginners!
Post Reply