Deconstructing the interface mechanics

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
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Deconstructing the interface mechanics

Post by Gambit37 »

I've been looking at the code for the interface elements such as the runes, weapon attack icons, attack option menus and portrait/hands areas.
While I don't yet fully understand it all, I think I can see more or less how to radically change the interface and even the game mechanics by modifying these functions.

Some questions:
  • Is it possible to change the runes panel to have all 24 runes displayed at once, with the corresponding 24 click zones? And therefore for the runes to be clicked in any order? (I can't quite work out the loops in the runes code, one loop is for 8 turns which doesn't seem to correspond with anything in the interface?)
  • Most of the elements seem to clear their bitmap area to black first. If I remove that, can I put fully transparent images in here, or do things always need to clear to a solid bitmap/colour?
  • Is it possible to create arbitrary new controls anywhere on the interface using new custom clickzones?
  • Are there exposed functions for changing the way the hands/portraits/stamina bars are handled? There is space available in the interface to enlarge these...
  • Are there exposed functions that I can use for rendering one bitmap over a semi-transparent second bitmap? (like how you do the colouring of the new guy icons overlay for the party order).
  • Is there an exposed function for scaling bitmaps?
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Deconstructing the interface mechanics

Post by Sophia »

Gambit37 wrote:Is it possible to change the runes panel to have all 24 runes displayed at once, with the corresponding 24 click zones? And therefore for the runes to be clicked in any order? (I can't quite work out the loops in the runes code, one loop is for 8 turns which doesn't seem to correspond with anything in the interface?)
Yes, although this will require substantial alterations to the code that processes a cast spell, too, of course.
The loop that goes from 1 to 8 is to draw the current spell. Normal DM doesn't support spells that are 8 runes long, but DSB is flexible, remember? :D
Gambit37 wrote:Most of the elements seem to clear their bitmap area to black first. If I remove that, can I put fully transparent images in here, or do things always need to clear to a solid bitmap/colour?
Power pink will work, alpha won't.
Gambit37 wrote:Is it possible to create arbitrary new controls anywhere on the interface using new custom clickzones?
I'll say yes, at least until you try some crazy thing that doesn't work and prove me wrong. :mrgreen:
Gambit37 wrote:Are there exposed functions for changing the way the hands/portraits/stamina bars are handled? There is space available in the interface to enlarge these...
No. What do you want to do?
Gambit37 wrote:Are there exposed functions that I can use for rendering one bitmap over a semi-transparent second bitmap? (like how you do the colouring of the new guy icons overlay for the party order).
I'm not sure what you're asking, really. If you just want to draw an image with an alpha channel over another one, you can do that already, but that's probably not what you mean.
Gambit37 wrote:Is there an exposed function for scaling bitmaps?
No, but I'll add one.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Deconstructing the interface mechanics

Post by Gambit37 »

Sophia wrote:Yes, although this will require substantial alterations to the code that processes a cast spell, too, of course.
The loop that goes from 1 to 8 is to draw the current spell. Normal DM doesn't support spells that are 8 runes long, but DSB is flexible, remember? :D
Boy, do I remember. I keep finding lots of cool little things in the base code that inspire me to try out new things... :)
Sophia wrote:
Gambit37 wrote:Is it possible to create arbitrary new controls anywhere on the interface using new custom clickzones?
I'll say yes, at least until you try some crazy thing that doesn't work and prove me wrong. :mrgreen:
OK, cool. Though I'm not sure how to go about it. So far, I've just been modifying existing code, and it just *works*. I'm not sure how to create an entirely new function to do a new button, and where I should put it in the code?
Sophia wrote:
Gambit37 wrote:Are there exposed functions for changing the way the hands/portraits/stamina bars are handled? There is space available in the interface to enlarge these...
No. What do you want to do?
Not a lot, just thought it would be nice to make larger portraits and enlarge the stat bars a bit...
Sophia wrote:
Gambit37 wrote:Are there exposed functions that I can use for rendering one bitmap over a semi-transparent second bitmap? (like how you do the colouring of the new guy icons overlay for the party order).
I'm not sure what you're asking, really. If you just want to draw an image with an alpha channel over another one, you can do that already, but that's probably not what you mean.
Perhaps it's the same thing, I'm not sure: Your new guyicons have two images, a base image and an overlay image. In between those, you're rendering the party colours over the base image. How would I do something like that?
Sophia wrote:
Gambit37 wrote:Is there an exposed function for scaling bitmaps?
No, but I'll add one.
Cool, thanks :-)
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Deconstructing the interface mechanics

Post by Sophia »

Gambit37 wrote:Though I'm not sure how to go about it. So far, I've just been modifying existing code, and it just *works*. I'm not sure how to create an entirely new function to do a new button, and where I should put it in the code?
There's the "RTC-like" way, and there's the more "correct for DSB" way. Both methods involve the use of dsb_msgzone(bitmap, target_id, zone_number, x, y, w, h, msgtype)

The "RTC-like way" is to create a function_caller somewhere out of the way in the dungeon, and assign whatever code you want to execute to its activate, deactivate, or whatever functions. Make a note of its id number. Then, in your code, call dsb_msgzone with the right target id and message type. For example, to create a 64x64 button at (100, 100) that sends an activate message to inst 850 (which would be your function_caller), do this:

Code: Select all

dsb_msgzone(bmp, 850, 0, 100, 100, 64, 64, M_ACTIVATE)
As an aside, it doesn't have to be a function_caller, but most of the other DSB mechanics don't really do anything worth putting in an interface button.

The more correct (but more code-writing-intensive) way is to use a target of SYSTEM, and define your own new system message. Everything from 1 to 65535 is open to custom dungeon designers. Then, write sys_system_message, which by default does nothing, to handle your message. I've skimped a bit on this explanation because I think I know what approach you'll opt for. ;)
Gambit37 wrote:Your new guyicons have two images, a base image and an overlay image. In between those, you're rendering the party colours over the base image. How would I do something like that?
Oh, that is different. You'd basically have to go through the image pixel by pixel and tint it. You actually can do that, but it's more complicated than just drawing stuff over other stuff. dsb_get_pixel(bitmap, x, y) and dsb_put_pixel(bitmap, x, y, { R,G,B }) will help you. Each one supports an optional alpha parameter, too.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Deconstructing the interface mechanics

Post by Gambit37 »

Cool, thanks for the info, I think I can work with that.
Sophia wrote:I've skimped a bit on this explanation because I think I know what approach you'll opt for. ;)
You'd probably be right ;-)
Sophia wrote:You'd basically have to go through the image pixel by pixel and tint it. You actually can do that, but it's more complicated than just drawing stuff over other stuff. dsb_get_pixel(bitmap, x, y) and dsb_put_pixel(bitmap, x, y, { R,G,B }) will help you. Each one supports an optional alpha parameter, too.
Aha, right, very cool. Again, I think I can work this one out, thanks :-)

On another note, do you have any plans to expose the functions for all the interface elements? I have a great new interface which I think streamlines things a lot better, but I'd need to be able to override everything, including the hands / stat bars / portraits / damage readouts / positions of messages such as 'Game Frozen' (alignment goes off weird when you use a custom font). Would it be straightforward to expose the functions to do all that, or is it a lot of work?
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Deconstructing the interface mechanics

Post by Sophia »

Gambit37 wrote:On another note, do you have any plans to expose the functions for all the interface elements? I have a great new interface which I think streamlines things a lot better, but I'd need to be able to override everything, including the hands / stat bars / portraits / damage readouts / positions of messages such as 'Game Frozen' (alignment goes off weird when you use a custom font). Would it be straightforward to expose the functions to do all that, or is it a lot of work?
It is both straightforward and a lot of work, if that makes sense. :mrgreen:

That said, if you'd like to describe/send me images of your new interface, in a private message if you'd prefer, I might be able to make something work for you. I doubt if you truly want to override everything, so I could add customization for the stuff you wanted to change without producing a huge, atrocious mess.
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Deconstructing the interface mechanics

Post by Gambit37 »

It's significantly different. More like Black Crypt:
Image
Not finished yet, but it's a bit like this, minus the arrows (see my poll elsewhere) and with the magic area taking up the right hand space, plus the text console goes there too, but much smaller than in DM.
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Deconstructing the interface mechanics

Post by Sophia »

So from that, a concrete list of things you want to change and currently can't would seem to be:
:arrow: Change the layout and positioning of the "boxes" of the four party members
:arrow: Move the "hands" relative to the rest of the layout
:arrow: Allow stats to be displayed numerically instead of as bars, and move its relative positioning as well
:arrow: Allow the ability to display portraits all the time

Was there anything I missed?
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Deconstructing the interface mechanics

Post by Gambit37 »

Actually, not quite, it's actually a bit simpler than Black Crypt, that was just to give an impression of the layout. I'll finish up the design and give you a preview, so you can see exactly what I've been working on :-) (Note, I've done something possibly very complicated with the party direction/position icons....!)
Post Reply