Adventure Game Studio | Forums

AGS Support => Modules & Plugins => Topic started by: abstauber on 29 Apr 2017, 15:41

Title: TEMPLATE: Tumbleweed Verbs 1.2 Last update: 4th April 2019
Post by: abstauber on 29 Apr 2017, 15:41
This is the long overdue overhaul of the classic 9 Verbs template:
Tumbleweed Verbs!

Here are a few highlights:

Thimbleweed(tm) mode
x1 x2 x4 x8


A new save&load system
x1 x2 x4 x8


...while offering the classic SCUMM experience
x1 x2 x4 x8


And it still speaks your local language... sort of ;)
x1 x2 x4 x8


A more complete feature list:


Code
https://github.com/dkrey/ags_tumbleweed

Download
(all files compiled with AGS 3.4.3 Patch1)

Here is the template:
http://shatten.sonores.de/wp-content/uploads/2019/04/Tumbleweed_1.2.zip

The documentation is included with the template and also available as a .chm file here:
http://shatten.sonores.de/wp-content/uploads/2017/05/tumbeweed_doc.zip
Title: Re: Tumbleweed Verbs (Beta!)
Post by: Mehrdad on 29 Apr 2017, 16:27
Great!!!. It's really useful . Nice job!!
Title: Re: Tumbleweed Verbs (Beta!)
Post by: selmiak on 30 Apr 2017, 11:51
nice! Can you integrate this into the normal LA template?
Title: Re: Tumbleweed Verbs (Beta!)
Post by: CaptainD on 30 Apr 2017, 12:40
This looks great!  Thanks for all the hard work that's going into it.
Title: Re: Tumbleweed Verbs (Beta!)
Post by: Calin Leafshade on 30 Apr 2017, 19:20
Forgive my ignorance but what is the "Thimbleweed mode"?

It looks the same to me.
Title: Re: Tumbleweed Verbs (Beta!)
Post by: Snarky on 30 Apr 2017, 19:39
It just means the verb and hotspot name follow the mouse cursor instead of showing up in a dedicated "action bar"
Title: Re: Tumbleweed Verbs (Beta!)
Post by: abstauber on 30 Apr 2017, 21:14
@Calin & Snarky:
It is a tad more than just a label following the mouse cursor, although it is true that it isn't actually visible on the screenshot.
The "action label" also show the default action for the location and switches to the chosen action upon mouse click.
It stays that way until:
- you cancel the action
- the action is executed and done
- you move the mouse away from the location

The SCUMM mode always displays the chosen action until you click something or the action is done. It is a bit hard to explain - just try it and you will see ;)

@Selmiak: Do you have a particular feature in mind?
As long as the "normal" template is being used, I will maintain it. But the purpose of this template is to replace the older one.
I might integrate the running stuff in the 9Verbs MI-Style template at some point. Done

@CaptainD & Mehrdad: Thanks :)
Title: Re: Tumbleweed Verbs (Beta!)
Post by: LostTrainDude on 30 Apr 2017, 22:00
Rounds of applause abstauber! This looks great!
Title: Re: Tumbleweed Verbs (Beta!)
Post by: Danvzare on 01 May 2017, 15:57
Awesome, who knew Thimbleweed Park would have spurred abstauber to update this old template so much. :-D
Title: Re: Tumbleweed Verbs (Beta!)
Post by: abstauber on 03 May 2017, 10:49
A question for you native speakers:

How should the label for the GUI style be called? (It is a slider where you switch between classic SCUMM mode and the 'modern' thimbleweed mode.

Currently it is slider called GUI style with the options classic and modern
In German I called the slider 'Bedienung' which can be translated to Mode of operation.

But how could it be called in English? 'GUI style' sounds a bit too technical.
Title: Re: Tumbleweed Verbs (Beta!)
Post by: CaptainD on 03 May 2017, 11:28
Hmm... I think "Layout" or possibly just "Style" would be reasonable words to use.  I'd probably favour "Layout" myself.
Title: Re: Tumbleweed Verbs (Beta!)
Post by: abstauber on 04 May 2017, 10:25
Alright, thanks! I'll stick with layout then.

Btw. I've uploaded a new beta. For better testing the second room is now scrolling.
Thanks to arj0n, we have a new translation: dutch.
Also thanks to Bicilotti, Monsieur Ouxx and Cireja for helping me with the existing translation.
Title: Re: Tumbleweed Verbs (Beta!) Last update: 4th May 2017
Post by: abstauber on 09 May 2017, 13:33
Here's a new beta and I finally managed to create a repository for this template.

Changes:
The "cog" button is now on the same GUI as the action label.
Slight changes to what happens if you "talk to" nothing.
Code cleanup and small bugfixes

Did actually anyone already give this a go?

Title: Re: Tumbleweed Verbs (Beta!) Last update: 10th May 2017
Post by: abstauber on 10 May 2017, 13:08
Lo and behold, I received a bug report :-D
Beta4 is up. The running mode now waits for certain distance between player character and cursor. Also the running isn't blocking anymore.

edit: We have reached Beta5. You can now "run" on hotspots with an exit extention to change rooms.
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: abstauber on 17 May 2017, 20:30
I finally managed to update the documentation and I also added a new chapter about the changes and differences to the 9verbs MI-style template.
I guess waiting for further bug reports at this point might be a bit useless, so I call this a release candidate :P
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: daniel on 26 May 2017, 10:18
this looks awesome abstauber!

noob question:
how do i go about updating my game from the 9-verb template? i can't seem to figure out how i can import this template into my existing game:D
i already have custom UI graphics, colors, fonts etc. in place. i suppose this is going to be a bit of a pain? :-\

p.s. i noticed in both your templates, when you look at something you can click the mouse to skip a line of text. however in lucasarts games when you look at stuff you can still move while the text keeps displaying. i feel this really helps the "flow" of the gameplay. would it be possible to achieve this in AGS as well?
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: abstauber on 29 May 2017, 09:21
Quote
how do i go about updating my game from the 9-verb template?
Currently both templates share the same features, except the save/load handling. You can export the save/load GUIs from the template and import them to your game. Also you need to export the optiongui module.
Actually migrating your game completely from one template to another might indeed be quite a pain ;) I'd rather say: create a new game from Tumbleweed template and import your rooms into it. Afterwards apply your other changes, fonts colors and graphics.

Quote
however in lucasarts games when you look at stuff you can still move while the text keeps displaying
Unfortunately displaying speech is usually blocking in AGS. You could use BackgroundSpeech, but that way you would loose the talking animations with "lucas style speech".
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: daniel on 31 May 2017, 13:45
thanks abstauber,

i guess i'll just continue with the "old" template for now and maybe migrate at a later point...
actually the one thing that i like most from the new template is that the action/info is displayed over the cursor instead of an action bar.
is this possible in the 9-verb template somehow?
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: abstauber on 01 Jun 2017, 12:38
Sure, that is actually not a big deal. First you need to resize the gAction GUI to your game's screen resolution (eg 320x200)
Now you need to copy over this adjusted  AdjustActionBarPosition function to your template and make sure it is called in repeatedly_execute_always

Code: Adventure Game Studio
  1. void AdjustActionBarPosition()
  2. {
  3.   int actionLabelWidth = GetTextWidth(ActionLine.Text, eFontTextOut) + 4;
  4.   int actionLabelHalf = actionLabelWidth / 2;
  5.   int xpos = mouse.x - actionLabelHalf ;
  6.   int ypos = mouse.y - Game.SpriteHeight[mouse.GetModeGraphic(mouse.Mode)] - 4;
  7.  
  8.   if (xpos + actionLabelWidth >= System.ScreenWidth) xpos = System.ScreenWidth - actionLabelWidth;
  9.   else if (xpos < 0) xpos = 0;
  10.  
  11.   if (ypos < 0 ) ypos = 0;
  12.  
  13.   ActionLine.X = xpos;
  14.   ActionLine.Y = ypos;
  15.   ActionLine.Width = actionLabelWidth;
  16. }
  17.  
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: Jigen Daisuke on 15 Dec 2017, 11:56
Hi Abstauber!

Is it possible to use your save/load GUI (with screenshot/date/hour mode) on other templates?
I'd like to use it in a game I'm currently developing!
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: abstauber on 15 Dec 2017, 12:37
Hi,
as long as you know your ways around AGS, it should not be too hard. The whole GUI stuff is already pretty much modulized.
You need to export the optiongui module from the template, as well as the GUIs: gSave, gSaveConfirm, gLoad (and optionally gOptions).

In gOptions you might want to remove the Layout slider and the code behind it, since this is the only(?) template specific thing in this module.
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: Jigen Daisuke on 15 Dec 2017, 13:56
Hi,
as long as you know your ways around AGS, it should not be too hard. The whole GUI stuff is already pretty much modulized.
You need to export the optiongui module from the template, as well as the GUIs: gSave, gSaveConfirm, gLoad (and optionally gOptions).

In gOptions you might want to remove the Layout slider and the code behind it, since this is the only(?) template specific thing in this module.

Thank you very much!:-D
I'm at my first game and I'm currently Learning Scripting but I'm confident to be able to do it (nod)
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: Jigen Daisuke on 05 Jan 2018, 16:16
Hi Abstauber!

I tried to import the module but my AGS version is slightly older than the one you used for the module... so the importing failed
do you know if is it possible to use it in another way?
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: zurik on 19 Apr 2018, 07:09
Sure, that is actually not a big deal. First you need to resize the gAction GUI to your game's screen resolution (eg 320x200)
Now you need to copy over this adjusted  AdjustActionBarPosition function to your template and make sure it is called in repeatedly_execute_always

Code: Adventure Game Studio
  1. void AdjustActionBarPosition()
  2. {
  3.   int actionLabelWidth = GetTextWidth(ActionLine.Text, eFontTextOut) + 4;
  4.   int actionLabelHalf = actionLabelWidth / 2;
  5.   int xpos = mouse.x - actionLabelHalf ;
  6.   int ypos = mouse.y - Game.SpriteHeight[mouse.GetModeGraphic(mouse.Mode)] - 4;
  7.  
  8.   if (xpos + actionLabelWidth >= System.ScreenWidth) xpos = System.ScreenWidth - actionLabelWidth;
  9.   else if (xpos < 0) xpos = 0;
  10.  
  11.   if (ypos < 0 ) ypos = 0;
  12.  
  13.   ActionLine.X = xpos;
  14.   ActionLine.Y = ypos;
  15.   ActionLine.Width = actionLabelWidth;
  16. }
  17.  


This is perfect! Thank you. But is it possible to hide the actionline when starting an action, in an easy way?
"Talk to character" for example is still on the screen (highlighted) when the dialog goes on. And sometimes those texts even overlap each other.

Thank you!
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: Monsieur OUXX on 19 Apr 2018, 10:03
helping me with the existing translation.

Watch out you made a copy&paste mistake in the French screenshot : It's not "ourvrir", it's supposed to be "ouvrir".

Question : apart from the new copy&save, are there any other improvements? We've just finished integrating the 9verb into the "custom save with screenshots" and bam, just at the same time you release it packaged. So I'm thinking if it's worth integrating again.
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: abstauber on 19 Apr 2018, 20:53
@zurik I'll have a look tomorrow

@Monsieur Ouxx
Hehe, thanks for the hint. I'll update the graphics in the future. How comes that you stumble upon this template almost exactly a year after it's release? (laugh)
Quote
We've just finished integrating the 9verb into the "custom save with screenshots" and bam, just at the same time you release it packaged.
Did I release something recently?

The main additions are double click running and the new save gui. And of course the whole code reorganizing and refactoring stuff, but technically these aren't features ;)
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: abstauber on 20 Apr 2018, 12:41
@zurik
I think the trick was to set the action label to an empty string after an action was executed or the GUI gets disabled. The GUI gets disabled once a dialog starts, so we use this effect.

This is from the tumbleweed script, so there's a bit work left to adapt it to the 9verb GUI variable and function names.

Code: Adventure Game Studio
  1. function repeatedly_execute_always() {
  2.  
  3.  
  4.   if (!IsGamePaused() && !Verbs.IsGuiDisabled()) {
  5.  
  6.     // Update Actionbar
  7.     if (classicGui == false) {
  8.       Verbs.CheckDefaultAction();
  9.  
  10.       // Update Actionbar after command is executed
  11.       if (location_clicked != null && location_clicked.Length > 0) {
  12.         if (location_clicked.IndexOf(">") > 0) temp_location = location_clicked.Truncate(location_clicked.IndexOf(">"));
  13.         else temp_location = location_clicked;
  14.       }
  15.       else temp_location = "";
  16.  
  17.       if (IsInterfaceEnabled() || temp_location != location || location == "") {
  18.         Verbs.UpdateActionBar();
  19.         location_clicked = "";
  20.       }
  21.       Verbs.AdjustActionBarPosition();
  22.     }
  23.     // Doubleclick Timer
  24.     if (dc_timer_run == true)
  25.     {
  26.       if (disableDoubleclick) {
  27.         dc_timer_run = false;
  28.       }
  29.       else {
  30.         dc_timer_click++;
  31.         if (dc_timer_click >= dc_speed){
  32.           dc_timer_click = 0;
  33.           dc_timer_run = false;
  34.         }
  35.       }
  36.     }
  37.   }
  38. }
  39.  
  40.  
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: Monsieur OUXX on 20 Apr 2018, 16:19
The main additions are double click running and the new save gui. And of course the whole code reorganizing and refactoring stuff, but technically these aren't features ;)

So basically it does exactly what our template does. Even the running. I'm gutted. Proof I should visit the forums more often ;)
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: Loslem on 24 Apr 2018, 05:59
Hi Abstauber!

First of all, love the new Verbs, great design.

I'm having some trouble with the doors. I set up the doors as I learned and the Anyclick works. Problem is this: in my new game I will have more than one playable characters, the user can switch anytime he wants. So, what I want to get working is this: If a Character on one side of a door opens the doors(but steps not trough it), then it should also be open in the next room, even if an other characzer approaches it from the other side, right?
I put the Getdoorstate in room_load on both sides, trying to always update the door state. Ot works for going trough the door, but it doesn't change the corrsponding object. Hence:
You will step trough an open bit displayed closed, door.
Well this is how I set doors up:

Code: Adventure Game Studio
  1. Room_First_Load {  
  2. //Set up a doors with ID 20 and set it to unlocked but closed
  3.  
  4. Doors.Initobject (20, oDoor.ID);
  5.  Doors.Setdoorstate (20, 0);
  6. }
  7.  
  8. Room_Load{
  9.  //check if door is closed or open
  10. Doors.Getdoorstate (20);
  11. }
  12.  
  13.  
Code: Adventure Game Studio
  1. Room_First_Load {  
  2. //Set up a doors with ID 20 and set it to open
  3.  
  4. Doors.Initobject (20, oDoor.ID);
  5.  Doors.Setdoorstate (20, 1);
  6. }
  7.  
  8.  
  9. Room_Load{
  10.  //check if door is closed or open
  11. Doors.Getdoorstate (20);
  12. }
  13.  
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: abstauber on 24 Apr 2018, 08:09
Hi and thanks for the kind words.

Without testing it I'd say you need to init the door object every time the room loads.
GetDoorState just return the state of the door, but doesn't apply it. InitObject does both: it get the state and modifies the object if needed.

Code: Adventure Game Studio
  1. Room_First_Load {  
  2. //Set up a doors with ID 20 and set it to open
  3.  Doors.Setdoorstate (20, 1);
  4. }
  5.  
  6.  
  7. Room_Load{
  8.  //check if door is closed or open
  9. Doors.InitObject (20, oDoor.ID);
  10. }
  11.  
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: Loslem on 24 Apr 2018, 10:14
EDIT: Doors work now! I'am so happy!

Thanks! I'll try this evening and let you know :)
Oh, I also had another bug regarding the safe-system. I have to recreate it in the evening because I'm at work now, but I would describe it like this:
If I open the Menu via the GUI Button I can safe and load without problem. But If I open the Menu via F5 and safe I get an error. As I said I have to recreate it, but I recall it pointed to the part of the script where you added a comment saying "workaround for taking a screenshot without the menu-gui".

I tried with both compiled game and the testeun with AGS open.


EDIT: The Error Reads "Error running function 'repeatedly_excecute'": Error: Null String referenced

and it refers to the line 402 of the optiongui.asc

Code: Adventure Game Studio
  1. if (save_scheduled) {
  2.     SaveGameSlot(saveSlotId, saveSlotString);
  3.     saveSlotId = 0;
  4.     saveSlotString = "";      
  5.     save_scheduled = false;
  6.   }
  7.  
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: abstauber on 24 Apr 2018, 18:07
A good thing, that I called this a release candidate ;)

Here's your bugfix.

In globalscript.asc at line 25 edit your code like this:
Code: Adventure Game Studio
  1.   if (keycode == eKeyF5) {
  2.     //gOptions.Visible=true; // F5 - OPTIONS
  3.     Verbs.UpdateActionBar();
  4.     OptionGui.ShowOptions();
  5.   }
  6.  
That fixed the issue for me.
Title: Re: TEMPLATE: Tumbleweed Verbs (RC1) Last update: 17th May 2017
Post by: Loslem on 12 Jun 2018, 21:59
Hi it's me again, back to bother you! :D

Say: It's super convienient to set Door Hotspots with the extension >o, so that right click right opens them. Problem: if you click right again you always get the door string for the open door.
Is there a way to implement that the door is closed again with a right click?

EDIT: Sorry I found it on site 14 of your Verbs Manual. Good write!
Title: Re: TEMPLATE: Tumbleweed Verbs 1.0 Last update: 13th June 2018
Post by: abstauber on 13 Jun 2018, 10:43
Great that you've sorted it out.

And since we're at it, I've added the fixes to Github and updated the template.
So after over a year in RC state, I now proudly call it 1.0 :-D
Title: Re: TEMPLATE: Tumbleweed Verbs 1.0 Last update: 13th June 2018
Post by: imsomnia212 on 21 Jul 2018, 21:33
First of all I really love the template.
Well, I have a question: Is possible to show the save screenshot with anti-alising when your game is nearest-neighbor? I wan't to show it like the way Thimbleweed do, but in the template with a nearest-neighbor game, it pixelate and lose information in the screenshot.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.0 Last update: 13th June 2018
Post by: Crimson Wizard on 21 Jul 2018, 21:45
Well, I have a question: Is possible to show the save screenshot with anti-alising when your game is nearest-neighbor? I wan't to show it like the way Thimbleweed do, but in the template with a nearest-neighbor game, it pixelate and lose information in the screenshot.

This would require applying different graphic filter at runtime, which AGS currently cannot do, I am afraid. (Well, technically it could, but there is no script command or option to make it do so).
Title: Re: TEMPLATE: Tumbleweed Verbs 1.0 Last update: 13th June 2018
Post by: Monsieur OUXX on 23 Jul 2018, 11:24
imsomnia212 : What you can do is apply the anti-aliasing AFTER taking the screenshot.
I'm not detailing, but :
1) locate the place in the module where the screenshot is taken
2) Open the file from disk or start fiddling with the dynamic sprite directly (I haven't checked which of those two scenarios applies here)
2) Resize the sprite using the DynamicSprite and DrawingSurface scaling abilities -- apply the antialiasing at that time.
3) Save the sprite as a file where it should normally have been saved in the first place
Title: Re: TEMPLATE: Tumbleweed Verbs 1.0 Last update: 13th June 2018
Post by: Snarky on 23 Jul 2018, 11:55
2) Resize the sprite using the DynamicSprite and DrawingSurface scaling abilities -- apply the antialiasing at that time.

I don't understand how this step is supposed to work. Neither DrawingSurface.DrawImage()/DrawSurface() nor DynamicSprite.Resize() allow you to specify antialiasing – I'm not sure whether it's always off or whether it depends on the "Smooth scaled sprites" setting in winsetup, but it's not something you can control through AGS script (the best you can do is game.disable_antialiasing, but there's no game.force_antialiasing).

It might be possible to write a function to do bilinear sprite scaling by reading and drawing individual pixels, but that would be SLOOOW.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.0 Last update: 13th June 2018
Post by: Crimson Wizard on 23 Jul 2018, 12:33
2) Resize the sprite using the DynamicSprite and DrawingSurface scaling abilities -- apply the antialiasing at that time.

I don't understand how this step is supposed to work. Neither DrawingSurface.DrawImage()/DrawSurface() nor DynamicSprite.Resize() allow you to specify antialiasing – I'm not sure whether it's always off or whether it depends on the "Smooth scaled sprites" setting in winsetup, but it's not something you can control through AGS script (the best you can do is game.disable_antialiasing, but there's no game.force_antialiasing).

I was too confused by this advice. At first I thought there is a mode for SetGameOption I forgot about, but then I checked engine code, and this is not the case with anti-aliased sprites. But that option is not even applied to DrawingSurface operations, only when drawing characters and objects in the room.
(Which may be an oversight really. Also, that should be technically possible to add an option to switch sprite anti-aliasing at runtime, if really necessary)
Title: Re: TEMPLATE: Tumbleweed Verbs 1.0 Last update: 13th June 2018
Post by: Snarky on 23 Jul 2018, 13:14
But that option is not even applied to DrawingSurface operations, only when drawing characters and objects in the room.
(Which may be an oversight really. Also, that should be technically possible to add an option to switch sprite anti-aliasing at runtime, if really necessary)

It feels like a design decision made back in 2000 or thereabouts that doesn't make much sense any more.

How I would want it to work, ideally:

-Antialiasing (or more properly interpolation) for scaling characters is a game setting that can be controlled in script
-There's a game-wide default value, but it can also be overridden for individual characters
-Possible values for this setting would be Nearest Neighbor, Bilinear, Bicubic and User-Configured (which would then be controlled by winsetup; the default for backwards compatibility), with option to extend later
-For relevant DrawingSurface/DynamicSprite operation (scaling and rotation), there would be an optional interpolation argument with the same possible values, defaulting to Nearest Neighbor
-While we're at it, also add a subpixel Translate operation to shift a sprite by a fraction of a pixel (using any of the interpolation settings – though Nearest Neighbor wouldn't really do much).
Title: Re: TEMPLATE: Tumbleweed Verbs 1.0 Last update: 13th June 2018
Post by: Ray on 23 Jul 2018, 23:39
Thank you very much for this template!
I'm just starting with AGS, so such a good example will definitely be a help :)
Title: Re: TEMPLATE: Tumbleweed Verbs 1.0 Last update: 13th June 2018
Post by: imsomnia212 on 24 Jul 2018, 08:29
This would require applying different graphic filter at runtime, which AGS currently cannot do, I am afraid. (Well, technically it could, but there is no script command or option to make it do so).

That's sad but maybe in a near future that's Will be possible.
I have another problem, when I set up a bg for the dialog gui (is a image with alpha channel) it show a pink bg and not the transparent img like do when use the ags gui system, see:

Using the ags gui system for the main gui (verbs, inventory items, etc):
(http://i.imgur.com/dTaqQFH.jpg)

Using the dialog script provide by Tumbleweed module:

(http://i.imgur.com/9XHp7OL.jpg)

I set up the script like the note said:

Code: Adventure Game Studio
  1. // Background
  2. // set bg img_transparency to -1 if you&#39;re using 32-bit graphics and
  3. // want to preserve the alpha channel
  4. this.bg_img                = 276;
  5. this.bg_img_scaling        = 0;
  6. this.bg_img_transparency   = -1;
  7. this.bg_color              = 0;
  8.  
Title: Re: TEMPLATE: Tumbleweed Verbs 1.0 Last update: 13th June 2018
Post by: Monsieur OUXX on 25 Jul 2018, 08:29
I'm so confused right now. Wasn't there a new parameter added recently to DynamicSprite.Draw or .Resize or whatever where you could choose the scaling algorithm? Or am I mixing it up with the new parameter for transparency copy (legacy, additive...)? My bad then.

But anyways, even if imsomnia212 has to write the antialised method himself (which shouldn't be too hard because it doesn't have to be real-time, it can be super slow, just copy some bilinear code from wikipedia), it's only an extra step to the method I described to achieve his goal of antialised saved games screenshots.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.0 Last update: 13th June 2018
Post by: Snarky on 25 Jul 2018, 08:57
Scripting a bilinear interpolation filter is complicated by AGS's crappy color handling (not allowing you to get or set the full 32-bit color value). To get the correct result without degrading the screenshot to 16-bit, you would have to grab the individual pixels as sprites and draw them on top of each other at various transparencies.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.0 Last update: 13th June 2018
Post by: abstauber on 27 Jul 2018, 11:36
@imsomnia212 I can replicate this, but I'm clueless why it isn't working anymore. Drawing images with an alpha channel used to work on dialog GUIs - at least in 2017. I'm trying to find out in which version of AGS, this feature broke again. It never broke, see below ;)

Title: Re: TEMPLATE: Tumbleweed Verbs 1.0 Last update: 13th June 2018
Post by: Crimson Wizard on 27 Jul 2018, 11:44
@imsomnia212 I can replicate this, but I'm clueless why it isn't working anymore. Drawing images with an alpha channel used to work on dialog GUIs - at least in 2017. I'm trying to find out in which version of AGS, this feature broke again.

What version of AGS are you using? Does it replicate in this template right away, or you need to do something extra to see it?
Title: Re: TEMPLATE: Tumbleweed Verbs 1.0 Last update: 13th June 2018
Post by: abstauber on 27 Jul 2018, 11:49
Sorry for accusing AGS: I messed up :X.
I forgot to set info.HasAlphaChannel = true;

@imsomnia212
In line 382 (function dialog_options_get_dimensions) add this

Code: Adventure Game Studio
  1.   if ((CDG.bg_img_transparency > 0 || CDG.bg_img_transparency == -1) && CDG.bg_img!=0 ) {
  2.     info.HasAlphaChannel = true;
  3.   }
  4.  
Title: Re: TEMPLATE: Tumbleweed Verbs 1.0 Last update: 13th June 2018
Post by: Monsieur OUXX on 30 Jul 2018, 19:00
When you double-click on the hologram character, the player does not "fast walk". Is that intended? I haven't tested but I guess the same thing would happen when you double-click on objects or hotspots?
Title: Re: TEMPLATE: Tumbleweed Verbs 1.0 Last update: 13th June 2018
Post by: abstauber on 31 Jul 2018, 08:06
For some reason I thought that this would be the way to do it. But apparently you can doubleclick-walk to everything in Thimbleweed Park.
So yeah, it seems to be an intentional bug which I'll fix right away :)

In the meantime you can comment out the 'if condition' in line 2075 and it's bracket in 2085. In line 2095 remove this piece from the if condition: 
"&& location_type == eLocationNothing"

I'll test it some more and see if this fix breaks anything.
--edit: of course it broke something :P Gotta fix the door handling now.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: abstauber on 03 Aug 2018, 15:11
Here's the new version - sorry for refactoring so much code after the 1.0 release.
All template settings are now grouped in a separate module and you can change them from anywhere in your code. I've also removed the old doubleclick code and integrated CW's module instead.

Btw. thanks to CW and Snarky for telling me about attributs and how they work :D Also thanks to Monsieur Ouxx who brought the issue up.

This version also contains two bugfixes:
1) Alpha transparency for the dialog GUI is now a thing
2) Running works on everything, not just plain areas.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Monsieur OUXX on 03 Aug 2018, 17:05
hurray!
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: imsomnia212 on 05 Aug 2018, 04:40
Hey thanks for the fix!
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Monsieur OUXX on 05 Aug 2018, 18:18
Tiny issue : the "tiny" font points to the same file as other fonts : xpaider2.ttf. And that file does not seem to be the right one. I tried importing it at small sizes (5 or 6pt) but it's not right. Can you help me?
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: abstauber on 05 Aug 2018, 20:12
Oh, that's easy to explain: the "tiny" font is a .wfn font. But if I recall correctly, you have to start with a ttf font first and then replace it with the wfn font in the file system.
You can find the wfn font in the assets folder in Github, or here on the forums: it is Tom Thumb.
http://www.adventuregamestudio.co.uk/forums/index.php?topic=48798

@Imsomnia212: Cheers! I'm looking forward to see some of your games in the future. Your abandoned mags game already looked very promising.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Monsieur OUXX on 06 Aug 2018, 11:38
You can find the wfn font in the assets folder in Github, or here on the forums: it is Tom Thumb.
http://www.adventuregamestudio.co.uk/forums/index.php?topic=48798

Cool. That's also the one I've been using in other places.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Monsieur OUXX on 08 Aug 2018, 13:46
fyi : I've done a pull request.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: imsomnia212 on 09 Aug 2018, 01:34
@Imsomnia212: Cheers! I'm looking forward to see some of your games in the future. Your abandoned mags game already looked very promising.

Soon I will show in the forum something that I'm working on too hard
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Babar on 02 Sep 2018, 15:16
I get a "Not Found" page when I try to download the template.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Crimson Wizard on 02 Sep 2018, 15:34
I get a "Not Found" page when I try to download the template.

I think you may still download the source project from github:
https://github.com/dkrey/ags_tumbleweed
if you click on green "Clone or download" button and choose Download ZIP.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Babar on 02 Sep 2018, 17:51
I think you may still download the source project from github:
https://github.com/dkrey/ags_tumbleweed
if you click on green "Clone or download" button and choose Download ZIP.
Yes, that is what I did, I just figured I'd try to get the template as an agt file.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: abstauber on 05 Sep 2018, 11:00
@Babar: Sorry about the broken link, I've just fixed it.

@Monsieur OUXX: Your changes seem to make a lot of sense, but unfortunately your pull request does not compile (yet)
Quote
GlobalScript.asc(54): Error (line 54): '.AdjustLanguage' is not a public member of 'Verbs'. Are you sure you spelt it correctly (remember, capital letters are important)?
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Monsieur OUXX on 11 Sep 2018, 14:25
your pull request does not compile (yet)

Weird. I made sure I never committed without compiling and testing first.
How do pull requests work? Do you see the state of the code at the time I did the pull request, or do you see the current state of the cloned respository and the branch it contains?
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: abstauber on 10 Oct 2018, 09:32
I downloaded your last commit from Aug 18th (dedfd488392cf46dad0af3dbe2ddde97eb44c1d f) and tried it to compile it with AGS. Since then I still didn't find the time review all the changes and probably find a fix for the remaining bugs.

That also raises the question: do I need merge this borked pull request and fix the bugs in the master branch or do I have to work in your repo to make it happen?
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Crimson Wizard on 10 Oct 2018, 11:08
That also raises the question: do I need merge this borked pull request and fix the bugs in the master branch or do I have to work in your repo to make it happen?

Sorry for barging in the discussion; technically both ways are viable, usually this is rather an organizational question.
Also, a while ago Github has allowed such feature as letting the owner of target repository to add commits directly to pull request branch, if the PR creator has ticked this option. Personally I cannot tell if it's the case not having necessary permissions there.

BTW this reminds me, Monsieur OUXX, have you noticed my comment to your pull request?
https://github.com/dkrey/ags_tumbleweed/pull/1#issuecomment-411395083
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: abstauber on 10 Oct 2018, 14:07
Quote
Sorry for barging in the discussion
I was actually hoping you would do that :D
Thanks for the clarification, I guess I just need to wait until Mathieu replies. Maybe in the meantime I find time to do a full code review, since this pull request is quite a biggie.
In any case the #error command will find its way into the template (nod)
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Monsieur OUXX on 12 Oct 2018, 17:32
Sorry guys I had a crazy month (I think the other people in my game project have probably hired bounty hunters to get me by now). I'll check out my code and the state of the pull, as well as CW's comment asap.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: abstauber on 06 Nov 2018, 16:06
Quote
I'll check out my code and the state of the pull, as well as CW's comment asap.
(wtf)

Hehe, no worries. I was able to find some time fixing your bugs and to merge your changes. Thanks for the tedious work of refactoring all this stuff (nod)

Anyone dares to test this right from the repo as well?
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: abstauber on 07 Nov 2018, 20:48
Here's the new beta, compiled as a template for your convenience :)
I've been testing it for a bit now, but I couldn't find anything odd yet. But since so much has changed code wise, it would be great if anyone else could have a look.

Changes (mostly by Monsieur Ouxx)
- cleaned up the global script (moved the remaining GUI actions to the options menu module)
- Localisation of the GUI elements is handled a bit different internally
- It's possible to change the GUIs being used by the template
- Some more refactoring, the template throws errors if a module is missing.

Here it is:
http://shatten.sonores.de/wp-content/uploads/2018/11/tumbleweed_12_beta.zip (http://shatten.sonores.de/wp-content/uploads/2018/11/tumbleweed_12_beta.zip)
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Monsieur OUXX on 03 Jan 2019, 00:02
So I'm not forgetting that I need to review the pull request, but in the meantime I'm having a weird issue. thanks to Khris it's been narrowed down to AGS apparently not being very good at having a sprite with alpha AND a transparency > 0 used as a GUI background.

I'm trying to set the custom dialogs GUI background to a black background with a slight transparency. Everything below failed :

- I tried with a fully black image (no alpha) and eDialogGui_bg_img_transparency set to 20, the background does not appear at all.
- I tried with a sprite imported from a PNG containing an all-black image with alpha (the black is 20% transparent) and  and eDialogGui_bg_img_transparency set to 0, now it's the font outline that goes cuckoo.
- I tried with the same semi-transparent PNG sprite and eDialogGui_bg_img_transparency set to -1. Now it's the transparency rendering that's all over the place (some pixels become fully transparent while some others are fully opaque).

What is the proper way?
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Snarky on 03 Jan 2019, 08:57
There is no proper way. There's a bug in AGS: rendering is broken for GUIs with alpha-transparent backgrounds and content (including text) with alpha-transparency.

The workaround is to use two GUIs; one for the background and one on top (with the background set to COLOR_TRANSPARENT) for the content.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: abstauber on 03 Jan 2019, 09:38
Maybe I don't get it, but if it's about a GUI background with different alpha levels... that works and it's already implemented in the template.
Code: Adventure Game Studio
  1.   // Background
  2.   // set bg_img_transparency to -1 if you're using 32-bit graphics and
  3.   // want to preserve the alpha channel  
  4.   CustomDialogGui.DialogGuiOptions[eDialogGui_bg_img]                = 122;
  5.   CustomDialogGui.DialogGuiOptions[eDialogGui_bg_img_scaling]        = 0;
  6.   CustomDialogGui.DialogGuiOptions[eDialogGui_bg_img_transparency]   = -1;
  7.   CustomDialogGui.DialogGuiOptions[eDialogGui_bg_color]              = 0;
  8.  

When you work with an alpha transparent PNG, you actually don't want AGS to interfere with it, you do it all in the image file.

Quote
- I tried with a sprite imported from a PNG containing an all-black image with alpha (the black is 20% transparent) and  and eDialogGui_bg_img_transparency set to 0, now it's the font outline that goes cuckoo
Just set eDialogGui_bg_img_transparency to -1 and you should be fine.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Crimson Wizard on 03 Jan 2019, 10:01
There is no proper way. There's a bug in AGS: rendering is broken for GUIs with alpha-transparent backgrounds and content (including text) with alpha-transparency.

This was supposed to be fixed long ago! If it's still not working please do bug report, otherwise I won't know about it.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: abstauber on 03 Jan 2019, 10:24
There is no proper way. There's a bug in AGS: rendering is broken for GUIs with alpha-transparent backgrounds and content (including text) with alpha-transparency.

This was supposed to be fixed long ago! If it's still not working please do bug report, otherwise I won't know about it.

Here's proof that it works  8-) The frame is 100% opaque, the background is semi transparent, the scroll arrows render correctly as does the font outline.
x1 x2 x4 x8

Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Monsieur OUXX on 03 Jan 2019, 12:07

  CustomDialogGui.DialogGuiOptions[eDialogGui_bg_img_transparency]   = -1;

OK. I don't know what I'm doing wrong. When importing the PNG, should I say "yes" to "use alpha?" and should I select "leave transparency as-is"?
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: abstauber on 03 Jan 2019, 12:13

  CustomDialogGui.DialogGuiOptions[eDialogGui_bg_img_transparency]   = -1;

OK. I don't know what I'm doing wrong. When importing the PNG, should I say "yes" to "use alpha?" and should I select "leave transparency as-is"?

Yep.
Also make sure to check the option "GUI alpha rendering style" in the general settings. It has to be set to Proper Alpha Blending".

Here's the source image from the template, if you import this one, you can be sure that it works.

x1 x2 x4 x8

https://raw.githubusercontent.com/dkrey/ags_tumbleweed/master/assets/gui/dialog_background.png (https://raw.githubusercontent.com/dkrey/ags_tumbleweed/master/assets/gui/dialog_background.png)
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: tzachs on 04 Jan 2019, 13:54
Maybe you're using an older version of AGS (from before the fix)?
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Monsieur OUXX on 04 Jan 2019, 14:23
PROBLEM SOLVED.

From the start I was focusing on "GUI alpha rendering style", but it was actually "Sprite alpha rendering style" that caused the issue.
I'm not sure if it was because of the background sprite I was using OR if it was because of the font I'm using, that contains semi-transparent pixels, causing the outline to go crazy when the blending failed (unfortunately it went so crazy that I failed to visually identify it as only the outline)

Anyways now that everything is set to "proper alpha blending", everything seems to work as expected.

Thanks!!!
This is the thing that took me the most time on the short game I'm making :D *sigh of relief*
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Monsieur OUXX on 30 Jan 2019, 13:26
I have a new problem, which is the font issue that I've mentionned previously. It's not caused by the module itself however I don't understand what differs between my own game files and the demo game.

Abstauber, unfortunately the best way to show you my issue is to share the game files but I don't want to do it publicly, so I'm sending them to you in a Private Message.

For everyone, here is my issue's description:

CONTEXT
- I have a game based on the Tumbleweed module.
- It contains the "gAction" GUI, which itself contains "lblAction" -- same as Tumbleweed demo game
- lblAction uses the "eFontTumbleTextOut" font.  -- same as Tumbleweed demo game
- "TumbleTextOut" was imported from assets/xpaider2.ttf  -- same as Tumbleweed demo game
- TumbleTextOut was imported as 9pts and has outline "automatic" -- same as Tumbleweed demo game
- the game is set to "proper alpha blending" for both GUI and fonts -- same as Tumbleweed demo game

ISSUE
- In the demo game, when i open gAction, the label appears with the font without its outline (the outline is rendered only in-game)
- In my own game, when I open gAction, the label appears with a crappy 1-pixel outline the same color as the font. It's like the font is white with a white outline.

Screenshot:
(https://www.dropbox.com/s/z30m617kea93b1q/issue.png?raw=1)

I've tried tried overwriting xpaider2.ttf over itself, by re-importing it into the Tumbleweed demo game (without changing anything else), to see if it would do the same as in my game. That is, to see if the import action was broken in my current AGS version (3.4.1.13) but the label is still rendered properly in the Editor in the demo game.
I've tried re-importing /xpaider2.ttf over itself into my own game, but the issue is still there : it has this unwanted white outline.

Note that the font appears as expected in the Editor's "font" panel. It's only messed up in the label in gAction.

I'm 100% sure it's caused by transparency and some font pixels not being 100% transparent, hence being rendered as 100% opaque. But I just can't understand why it doesn't do the same in my game and in the demo game.

==========

unrelated : how do you manage to have all the GUIs appear with the proper Z order in your demo game, without defining any custom z-order? I had to do it in my own game.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: abstauber on 30 Jan 2019, 14:47
Hmm... it seems like you somehow triggered an editor bug. The font is rendered correctly in the game itself and it is also rendered correctly if you chose a button instead of a label.

It is just the label, that doesn't like the Xpaider font. Changing other labels to the mentioned font (your debug GUI for example) worked perfectly fine. But creating a new GUI with a new label resulted in a messy font again.

Like you described, I wasn't able to replicate this outside of your game project.

I'd say you also show your sources to Tzachs and Crimson Wizard, maybe they have a clue about what going on.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Monsieur OUXX on 30 Jan 2019, 16:35
I wasn't able to replicate this outside of your game project.

Thanks a lot for such a quick answer. I'll send the link to CW and Tzachs.

============

EDIT: so the issue was that "Anti-alias TTF fonts" was set to "true" in the general settings. Now everything works perfectly.

============

EDIT 2 :

Here is a module that generates all the action buttons automatically, with an outline, shadow, inner gradient, and is meant to fit nicely with Tumbleweed. It also manages the horizontal stretching of some buttons in the languages that allow it (mostly, English)
It's meant to save the hassle of having to redraw and reimport a billion action buttons in every language. In our case we didn't like the blue theme but it would have taken an eternity to change it to red.

It's called "AutoButtons" (CODE BELOW)

Spoiler: ShowHide



Module header :
Code: Adventure Game Studio
  1. /*
  2.  
  3. //All values below defined in Tumbleweed module
  4. enum Action {
  5.   eGA_LookAt = 0, //Starting at zero helps avoiding human mistakes when iterating on the enum
  6.   eGA_TalkTo,
  7.   eGA_GiveTo,
  8.   eGA_PickUp,
  9.   eGA_Use,
  10.   eGA_Open,
  11.   eGA_Close,
  12.   eGA_Push,
  13.   eGA_Pull,
  14.   eGA_UseInv,
  15.   eGA_Default,
  16.   eGA_WalkTo
  17. };
  18.  
  19. enum eLanguage {
  20.   eLangEN = 0, //Starting at zero helps avoiding human mistakes when iterating on the enum
  21.   eLangDE,
  22.   eLangES,
  23.   eLangIT,
  24.   eLangFR,
  25.   eLangPT,
  26.   eLangNL
  27. };
  28.  
  29. */
  30.  
  31. enum AutoButtonStates {
  32.     eAutoButton_off = 0,
  33.     eAutoButton_on = 1,
  34.     eAutoButton_hover = 2
  35. };
  36.  
  37.  
  38. #define THEMESIZE 20 //this must be bigger than the number of values in AutoButtonsThemeSettings
  39.  
  40. enum AutoButtonsThemeSettings {
  41.   eAutoBSetting_color_off,  
  42.   eAutoBSetting_color_off_gradienttop,  
  43.   eAutoBSetting_color_off_gradientbottom,  
  44.   eAutoBSetting_color_on,  
  45.   eAutoBSetting_color_on_gradienttop,  
  46.   eAutoBSetting_color_on_gradientbottom,  
  47.   eAutoBSetting_color_hover,  
  48.   eAutoBSetting_color_hover_gradienttop,  
  49.   eAutoBSetting_color_hover_gradientbottom,  
  50.   eAutoBSetting_color_outline,  
  51.   eAutoBSetting_color_shadow
  52. };
  53.  
  54. enum AutoButtonThemes {
  55.     eAutoButtonTheme_Red = 0,
  56.     eAutoButtonTheme_Blue = 1
  57.    
  58. };
  59.  
  60. struct AutoButtons
  61. {
  62.     import static int[] GetTheme(AutoButtonThemes theme); //Get the settings values from any of the built-in themes
  63.     import static void SetTheme(AutoButtonThemes theme,  int themeSettings[]); //Overwrite an existing theme from your game, without requiring to temper with the module's script (if needed)
  64.     import static int GenerateAll(int themeSettings[]);
  65.     import static DynamicSprite* GetSprite(eLanguage lan,  Action action,  AutoButtonStates state);
  66.     import static int GetSpriteID(eLanguage lan,  Action action,  AutoButtonStates state);
  67.    
  68.    
  69. };
  70.  




Module body :
Code: Adventure Game Studio
  1. #define NBACTIONS 12
  2. #define NBLANGUAGES 7
  3. #define MAXAUTOBUTTONS 84 //12*7
  4.  
  5. #define BUTT_WIDTH 56
  6. #define BUTT_HEIGHT 12
  7.  
  8. #define MAXTEXTWIDTH 200 //Some bullshit width to be passed to GetTextHeight. Should be bigger than the biggest possible width
  9.  
  10. int defaultTheme;
  11. GUI* guiMain; //The gui that has the action buttons
  12.  
  13. struct AutoButtonData {
  14.     DynamicSprite* s[3]; //one for each state
  15.     eLanguage lan;
  16.     Action action;
  17.     String text;
  18.     int widenFactor; //how much the text should be stretched horizontally (not all the same depending on the language and the action)
  19.     int width; //what should be the width of the buttons (they don't have the same width depending on the language and the action)
  20. };
  21. AutoButtonData buttons[MAXAUTOBUTTONS];
  22.  
  23. #define MAXTHEMES 3
  24.  
  25. struct Constants {
  26.     int width;
  27.     int height;    
  28. };
  29. Constants constants;
  30.  
  31. struct Theme {
  32.     //all values below initialized in game_start or if you call SetTheme
  33.     int settings[THEMESIZE];
  34.    
  35.     //You can add any field you want. For example String themeName;
  36.    
  37. };
  38. Theme themes[MAXTHEMES];
  39. //int nbThemes;
  40.  
  41.  
  42. //Unfortunately the Verbs module does not provide the bare actions, only with their prepositions and complement, like "Look at %s"
  43. String TranslateAction(Action a, eLanguage lan) {
  44.     switch(lan) {
  45.         case eLangEN:
  46.             switch(a) {
  47.                 case eGA_WalkTo: return "Go to";
  48.                 case eGA_LookAt: return "Look At";
  49.                 case eGA_TalkTo: return "Talk To";
  50.                 case eGA_GiveTo: return "Give";
  51.                 case eGA_PickUp: return "Pick Up";
  52.                 case eGA_Use: return "Use";
  53.                 case eGA_Open: return "Open";
  54.                 case eGA_Close: return "Close";
  55.                 case eGA_Push: return "Push";
  56.                 case eGA_Pull: return "Pull";
  57.                 default :
  58.                     return "ERROR";
  59.                     break;
  60.             }
  61.             break;
  62.         case eLangDE :
  63.             switch(a) {
  64.                 case eGA_WalkTo: return "Gehe zu";
  65.                 case eGA_LookAt: return "Schau";
  66.                 case eGA_TalkTo: return "Rede";
  67.                 case eGA_GiveTo: return "Gebe";
  68.                 case eGA_PickUp: return "Nehme";
  69.                 case eGA_Use: return "Nutze";
  70.                 case eGA_Open: return "Öffne";
  71.                 case eGA_Close: return "Schließe";
  72.                 case eGA_Push: return "Drücke";
  73.                 case eGA_Pull: return "Ziehe";
  74.                 default :
  75.                     return "ERROR";
  76.                     break;
  77.             }
  78.             break;
  79.         case eLangES :
  80.             switch(a) {
  81.                 case eGA_WalkTo: return "Ir a";
  82.                 case eGA_LookAt: return "Mirar";
  83.                 case eGA_TalkTo: return "Hablar";
  84.                 case eGA_GiveTo: return "Dar";
  85.                 case eGA_PickUp: return "Coger";
  86.                 case eGA_Use: return "Usar";
  87.                 case eGA_Open: return "Abrir";
  88.                 case eGA_Close: return "Cerrar";
  89.                 case eGA_Push: return "Empujar";
  90.                 case eGA_Pull: return "Tirar";
  91.                 default :
  92.                     return "ERROR";
  93.                     break;
  94.             }
  95.             break;
  96.         case eLangFR :
  97.             switch(a) {
  98.                 case eGA_WalkTo: return "Aller";
  99.                 case eGA_LookAt: return "Regarder";
  100.                 case eGA_TalkTo: return "Parler";
  101.                 case eGA_GiveTo: return "Donner";
  102.                 case eGA_PickUp: return "Prendre";
  103.                 case eGA_Use: return "Utiliser";
  104.                 case eGA_Open: return "Ouvrir";
  105.                 case eGA_Close: return "Fermer";
  106.                 case eGA_Push: return "Pousser";
  107.                 case eGA_Pull: return "Tirer";
  108.                 default :
  109.                     return "ERROR";
  110.                     break;
  111.             }
  112.             break;
  113.         case eLangIT :
  114.             switch(a) {
  115.                
  116.                 case eGA_WalkTo: return "Vai a";
  117.                 case eGA_LookAt: return "Esamina";
  118.                 case eGA_TalkTo: return "Parla";
  119.                 case eGA_GiveTo: return "Dai";
  120.                 case eGA_PickUp: return "Raccogli";
  121.                 case eGA_Use: return "Usa";
  122.                 case eGA_Open: return "Apri";
  123.                 case eGA_Close: return "Ferma";
  124.                 case eGA_Push: return "Premi";
  125.                 case eGA_Pull: return "Tira";
  126.                 default :
  127.                     return "ERROR";
  128.                     break;
  129.             }
  130.             break;
  131.         case eLangPT :
  132.             switch(a) {  
  133.                
  134.                 case eGA_WalkTo: return "Ir para";
  135.                 case eGA_LookAt: return "Olhar";
  136.                 case eGA_TalkTo: return "Falar";
  137.                 case eGA_GiveTo: return "Dar";
  138.                 case eGA_PickUp: return "Apanhar";
  139.                 case eGA_Use: return "Usar";
  140.                 case eGA_Open: return "Abrir";
  141.                 case eGA_Close: return "Fechar";
  142.                 case eGA_Push: return "Empurrar";
  143.                 case eGA_Pull: return "Puxar";
  144.                 default :
  145.                     return "ERROR";
  146.                     break;
  147.             }
  148.             break;
  149.         case eLangNL :
  150.             switch(a) {
  151.    
  152.                 case eGA_WalkTo: return "Ga naar";
  153.                 case eGA_LookAt: return "Bekijk";
  154.                 case eGA_TalkTo: return "Praat";
  155.                 case eGA_GiveTo: return "Geef";
  156.                 case eGA_PickUp: return "Pak";
  157.                 case eGA_Use: return "Gebruik";
  158.                 case eGA_Open: return "Open";
  159.                 case eGA_Close: return "Sluit";
  160.                 case eGA_Push: return "Duw";
  161.                 case eGA_Pull: return "Trek";
  162.                 default :
  163.                     return "ERROR";
  164.                     break;
  165.             }
  166.             break;    
  167.         default :
  168.                 return "ERROR2";
  169.                 break;
  170.     }
  171. }
  172.  
  173. DynamicSprite* DrawString_Widened(int font, String text, int color,  int widenFactor )
  174. {
  175.     int kerning = 0;
  176.     int wordSpacing = 2; //arbitrary number of pixels for the 'space' character, to make the text more compact
  177.     int maxWidth = GetTextWidth(text, font)*3;
  178.     int height = GetTextHeight(text,  font,  MAXTEXTWIDTH);
  179.    
  180.     //The width is a bit hard to calculate so we'll start by drawing onto a temporary surface
  181.     DynamicSprite* temp_s = DynamicSprite.Create(maxWidth,  height, true);
  182.     DrawingSurface* temp_ds = temp_s.GetDrawingSurface();
  183.     temp_ds.Clear();
  184.     int offset = 0;
  185.     temp_ds.DrawingColor = color;
  186.     //we draw each letter one by one
  187.     for (int i=0; i<text.Length; i++) {
  188.         if (text.Chars[i] == ' ') {
  189.            offset+=wordSpacing;
  190.            
  191.         } else {
  192.             String c = String.Format("%c", text.Chars[i]);
  193.             int letterWidth = GetTextWidth(c, font);
  194.             //the easiest way to widen a letter is to draw it several times
  195.             for (int j=0; j < widenFactor; j++) {
  196.                 temp_ds.DrawString(offset+j, 0, font, c);
  197.             }
  198.             offset+=(letterWidth+widenFactor);
  199.            
  200.             //if it's not the last letter we add a white space after the letter
  201.             if (i<text.Length-1)
  202.                 offset+=kerning;
  203.         }
  204.     }
  205.    
  206.     //now that we know the width we copy the temp sprite to a final sprite    
  207.     DynamicSprite* s = DynamicSprite.Create(offset,  height, true);
  208.     DrawingSurface* ds = s.GetDrawingSurface();
  209.     ds.DrawSurface(temp_ds);
  210.    
  211.     temp_ds.Release();
  212.    
  213.     return s;
  214.    
  215. }
  216.  
  217. //Draws 'graphic' 9 times onto ds, in an "outlined" manner (i.e. with offsets of -1 to +1)
  218. void DrawOutline(DrawingSurface*ds,  int x,  int y,  int graphic)
  219. {
  220.    ds.DrawImage(x-1, y-1, graphic);
  221.    ds.DrawImage(x-0, y-1, graphic);
  222.    ds.DrawImage(x+1, y-1, graphic);
  223.    ds.DrawImage(x-1, y-0, graphic);
  224.    ds.DrawImage(x-0, y-0, graphic);
  225.    ds.DrawImage(x+1, y-0, graphic);
  226.    ds.DrawImage(x-1, y+1, graphic);
  227.    ds.DrawImage(x-0, y+1, graphic);
  228.    ds.DrawImage(x+1, y+1, graphic);
  229. }
  230.  
  231. //See more at https://www.adventuregamestudio.co.uk/forums/index.php?topic=42449.0
  232. int[] GetRGBFromColor(int color)
  233. {
  234.     int rgb[] = new int[3];
  235.     bool highBit = true; //or false, you decide
  236.  
  237.     if (color > 65535) color -= 65536;
  238.     rgb[0] = ((color >> 11) & 31) << 3;
  239.     rgb[1] = ((color >> 6) & 31) << 3;
  240.     rgb[2] = (color & 31) << 3;
  241.     if (highBit)
  242.     {
  243.         rgb[0] = rgb[0] | 7;
  244.         rgb[1] = rgb[1] | 3;
  245.         rgb[2] = rgb[2] | 7;
  246.     }
  247.  
  248.     return rgb;
  249. }
  250.  
  251. //from top to bottom, every color of 'ds' that has color 'color' will be replaced by a gradient
  252. void noloopcheck ApplyGradient(DrawingSurface* ds, int color, int color_gradient_top, int color_gradient_bottom)
  253. {
  254.     int rgb_top[] = GetRGBFromColor(color_gradient_top);
  255.     int rgb_bottom[] = GetRGBFromColor(color_gradient_bottom);
  256.     float height_f = IntToFloat(ds.Height);
  257.    
  258.     float r_top = IntToFloat(rgb_top[0]); float r_bottom = IntToFloat(rgb_bottom[0]); float step_r = (r_bottom-r_top)/height_f;
  259.     float g_top = IntToFloat(rgb_top[1]); float g_bottom = IntToFloat(rgb_bottom[1]); float step_g = (g_bottom-g_top)/height_f;
  260.     float b_top = IntToFloat(rgb_top[2]); float b_bottom = IntToFloat(rgb_bottom[2]); float step_b = (b_bottom-b_top)/height_f;
  261.    
  262.     float r = r_top; float g = g_top; float b = b_top; //start values
  263.     for (int j=0; j< ds.Height; j++) {
  264.         ds.DrawingColor = Game.GetColorFromRGB(FloatToInt(r), FloatToInt(g),  FloatToInt(b));
  265.        
  266.         for (int i=0; i<ds.Width; i++) {
  267.             if (ds.GetPixel(i, j)==color)
  268.                 ds.DrawPixel(i, j);
  269.         }
  270.        
  271.         r+=step_r; g+=step_g; b+=step_b;
  272.     }
  273. }
  274.  
  275. DynamicSprite* GenerateButton(String text,  int width,  AutoButtonStates state,  int widenFactor,  int themeSettings[])
  276. {
  277.    
  278.    int font = eFontTumbleText;
  279.    
  280.    //int COLOR_BLACK = Game.GetColorFromRGB(5, 5, 5);
  281.    int COLOR_RED = Game.GetColorFromRGB(255, 0, 0);
  282.    int color = COLOR_RED; //we give it a default value for satefy
  283.    int color_gradient_top = COLOR_RED; //we give it a default value for satefy
  284.    int color_gradient_bottom = COLOR_RED; //we give it a default value for satefy
  285.    switch(state) {
  286.        case eAutoButton_off :
  287.         color = themeSettings[eAutoBSetting_color_off];
  288.         color_gradient_top = themeSettings[eAutoBSetting_color_off_gradienttop];
  289.         color_gradient_bottom = themeSettings[eAutoBSetting_color_off_gradientbottom];
  290.         break;
  291.        case eAutoButton_on :
  292.         color = themeSettings[eAutoBSetting_color_on];
  293.         color_gradient_top = themeSettings[eAutoBSetting_color_on_gradienttop];
  294.         color_gradient_bottom = themeSettings[eAutoBSetting_color_on_gradientbottom];
  295.         break;
  296.        case eAutoButton_hover :
  297.         color = themeSettings[eAutoBSetting_color_hover];
  298.         color_gradient_top = themeSettings[eAutoBSetting_color_hover_gradienttop];
  299.         color_gradient_bottom = themeSettings[eAutoBSetting_color_hover_gradientbottom];
  300.         break;
  301.        
  302.        default:
  303.         AbortGame("Unknown state");
  304.    }
  305.    //int width = constants.width;
  306.    int height = constants.height;
  307.    DynamicSprite* text_s = null;
  308.    
  309.    DynamicSprite* s = DynamicSprite.Create(width, height, true);  
  310.    DrawingSurface* ds = s.GetDrawingSurface();
  311.    //ds.DrawingColor = COLOR_TRANSPARENT;
  312.    ds.Clear();
  313.    
  314.    //int textWidth = GetTextWidth(text, font); //we actually need the widened width
  315.    int textHeight = GetTextHeight(text, font, MAXTEXTWIDTH);
  316.    
  317.    //(optional) colored rectangular background
  318.    //ds.DrawingColor = Game.GetColorFromRGB(100, 100, 100);
  319.    //ds.DrawRectangle(0, 0, width, height);
  320.    
  321.    //shadow
  322.    text_s = DrawString_Widened(font, text, themeSettings[eAutoBSetting_color_shadow], widenFactor );
  323.    int textWidth = text_s.Width;
  324.    int offset_x = (width - textWidth)/2; if (offset_x < 0) offset_x = 0;
  325.    int offset_y = (height - textHeight)/2;  if (offset_y < 0) offset_y = 0;
  326.    DrawOutline(ds, offset_x+widenFactor, offset_y, text_s.Graphic);
  327.    
  328.    //outline (the cheapest way to do an outline is to draw the text 9 times with and offset of -1 or +1 all around
  329.    text_s = DrawString_Widened(font, text, themeSettings[eAutoBSetting_color_outline], widenFactor );
  330.     DrawOutline(ds, offset_x, offset_y, text_s.Graphic);
  331.    //widened text. It returns a temporary sprite that we immediately copy onto our drawing surface
  332.    text_s = DrawString_Widened(font, text, color, widenFactor );
  333.    ds.DrawImage(offset_x,  offset_y, text_s.Graphic);
  334.    
  335.    //gradient
  336.    ApplyGradient(ds, color,  color_gradient_top,  color_gradient_bottom);
  337.    
  338.    //finish up
  339.    text_s.Delete();
  340.    ds.Release();
  341.    
  342.    return s;
  343. }
  344.  
  345. //this is purely built-in
  346. //how much the text should be stretched horizontally (not all the same depending on the language and the action)
  347. int GetWidenFactor(eLanguage lan,  Action a)
  348. {
  349.     switch(lan) {
  350.         case eLangDE :
  351.                     if (a==eGA_Close) //In German, "SchlieBe"'s font is narrower then the other buttons fonts
  352.                         return 1;
  353.                     else
  354.                         return 2;
  355.                     break;
  356.         case eLangEN : return 2; break;
  357.         case eLangES : return 1; break;
  358.         case eLangFR : return 1; break;
  359.         case eLangIT : return 1; break;
  360.         case eLangNL : return 1; break;
  361.         case eLangPT : return 1; break;
  362.  
  363.         default : AbortGame("Unknown language");
  364.     }
  365. }
  366.  
  367.  
  368. //Utility : Returns the button bound to a given action. Unfortunately this function is not provided by Verbs
  369. Button*  GetActionButton(Action a)
  370. {
  371.     //we scan every control
  372.     for (int i=0; i<guiMain.ControlCount; i++) {
  373.       GUIControl* c = guiMain.Controls[i];
  374.       Button* b = c.AsButton;
  375.       if (b!=null) {
  376.           if (Verbs.GetButtonAction(b) == a)
  377.             return b;
  378.       }
  379.     }
  380.    
  381.     //AbortGame("Couldn't find the button bound to action '%d'", a);
  382.     return null; //Not all actions have a button. E.g. "walk to"
  383.    
  384.     //If it was implemented in Verbs we would just use this :
  385.     //return Verbs.GetActionButton(a);
  386. }
  387.  
  388.  
  389. int GetButtonWidth(Action a) {
  390.     /*
  391.     //Somehow the automated code below doesn't work. buttons return goofy values, like b.Width == 200. I have no idea why.
  392.     Button* b = GetActionButton(a);
  393.     if (b!= null) {
  394.         //Display("Action %d return button.ID=%d, which has width %d x height %d. It belongs to GUI %d. Name is '%s'", a,  b.ID,  b.Width, b.Height,  b.OwningGUI.ID,  b.Text);
  395.         return b.Width;
  396.     } else {
  397.         return constants.width; //this action doesn't seem to have a button. We roll back to the default buttons width
  398.     }
  399.     */
  400.    
  401.     //Manual version. TODO : find why code above does not work.
  402.     switch(a) {
  403.         case eGA_LookAt :  return 56; //larger buttons in the central column
  404.         case eGA_TalkTo :  return 56; //larger buttons in the central column
  405.         case eGA_PickUp :  return 56;  //larger buttons in the central column
  406.         default: return 50; //narrower buttons in th eleft and right column
  407.     }
  408. }
  409.  
  410. static int AutoButtons::GenerateAll(int themeSettings[])
  411. {
  412.     int NBSPRITES = NBACTIONS*NBLANGUAGES;
  413.    
  414.     //safety
  415.     if (NBSPRITES > MAXAUTOBUTTONS)
  416.         AbortGame("Did something change?");
  417.    
  418.     //Some languages have shorter words so we can make the text wider up to a factor of 3
  419.     int widenFactor = 1;
  420.    
  421.     for (int i=0; i < NBLANGUAGES; i++) {
  422.        
  423.        
  424.         for (int a = 0; a<NBACTIONS; a++) {
  425.              widenFactor = GetWidenFactor(i,  a);
  426.             int width = GetButtonWidth(a);
  427.            
  428.             buttons[i*NBACTIONS+a].widenFactor = widenFactor;
  429.             buttons[i*NBACTIONS+a].width = width;
  430.            
  431.             String text = TranslateAction(a, i);
  432.            
  433.             buttons[i*NBACTIONS+a].lan = i;
  434.             buttons[i*NBACTIONS+a].action = a;
  435.             buttons[i*NBACTIONS+a].s[eAutoButton_off] = GenerateButton(text, width, eAutoButton_off, widenFactor, themeSettings);
  436.             buttons[i*NBACTIONS+a].s[eAutoButton_on] = GenerateButton(text, width,  eAutoButton_on, widenFactor, themeSettings);
  437.             buttons[i*NBACTIONS+a].s[eAutoButton_hover] = GenerateButton(text, width, eAutoButton_hover, widenFactor, themeSettings);
  438.             buttons[i*NBACTIONS+a].text = text;
  439.            
  440.         }
  441.     }
  442.    
  443. }
  444.  
  445.  
  446. static DynamicSprite* AutoButtons::GetSprite(eLanguage lan,  Action action,  AutoButtonStates state)
  447. {
  448.     return buttons[lan*NBACTIONS+action].s[state];
  449. }
  450.  
  451. static int AutoButtons::GetSpriteID(eLanguage lan,  Action action,  AutoButtonStates state)
  452. {
  453.     return buttons[lan*NBACTIONS+action].s[state].Graphic;
  454. }
  455.  
  456. float min(float a,  float b) { if (a < b) return a; return b; }
  457. float max(float a,  float b) { if (a > b) return a; return b; }
  458. float bound(float a,  float roof,  float floor) { return min(roof, max(a, floor)); }
  459.  
  460. //this function returns a darker or brighter version of color 'color'.
  461. // 'factor' between 0.0 and 2.0.
  462. // - If factor is 0.0, the function returns black (because the color has been darkened to the max).
  463. // - If it's 1.0, the color doesn't change
  464. // - If factor is 2.0, the function probably returns white, or at least 'color" is now twice brighter
  465. int ChangeBrightness(int color,  float factor)
  466. {
  467.     int rgb[] = GetRGBFromColor(color);
  468.     float r = IntToFloat(rgb[0]); float g = IntToFloat(rgb[1]); float b = IntToFloat(rgb[2]);
  469.     rgb = null;
  470.     r = bound(r*factor, 255.0,  0.0); g = bound(g*factor, 255.0,  0.0); b = bound(b*factor, 255.0,  0.0);
  471.     return Game.GetColorFromRGB(FloatToInt(r), FloatToInt(g),FloatToInt(b));
  472. }
  473.  
  474. int[] GetTheme_BuiltIn(AutoButtonThemes theme)
  475. {
  476.  
  477.     //useful values
  478.     int COLOR_RED = Game.GetColorFromRGB(255, 99, 99);
  479.     int COLOR_BROWN = Game.GetColorFromRGB(50, 0, 0);
  480.     int COLOR_YELLOW = Game.GetColorFromRGB(255, 249, 72);
  481.     int COLOR_GRAYISHRED = Game.GetColorFromRGB(116, 63, 63);
  482.     int COLOR_DARKGRAYISHRED = Game.GetColorFromRGB(52, 32, 32);
  483.     int COLOR_BLACK = Game.GetColorFromRGB(5, 5, 5);
  484.    
  485.     int themeSettings[] = new int[THEMESIZE];
  486.    
  487.     switch (theme) {
  488.         case eAutoButtonTheme_Red :
  489.  
  490.    
  491.             themeSettings[eAutoBSetting_color_off] = COLOR_RED;
  492.             themeSettings[eAutoBSetting_color_on] = COLOR_YELLOW;
  493.             themeSettings[eAutoBSetting_color_hover] = COLOR_BROWN;
  494.             themeSettings[eAutoBSetting_color_outline] = COLOR_GRAYISHRED;
  495.             themeSettings[eAutoBSetting_color_shadow] = COLOR_BLACK;
  496.            
  497.             /*
  498.             //MANUAL
  499.             themeSettings[eAutoBSetting_color_off_gradienttop] =            Game.GetColorFromRGB(255, 175, 175);
  500.             themeSettings[eAutoBSetting_color_off_gradientbottom] =         Game.GetColorFromRGB(200, 0, 0);
  501.             themeSettings[eAutoBSetting_color_on_gradienttop] =             Game.GetColorFromRGB(255, 249, 125);
  502.             themeSettings[eAutoBSetting_color_on_gradientbottom] =          Game.GetColorFromRGB(200, 200, 25);
  503.             themeSettings[eAutoBSetting_color_hover_gradienttop] =          Game.GetColorFromRGB(100, 50, 50);
  504.             themeSettings[eAutoBSetting_color_hover_gradientbottom] =       Game.GetColorFromRGB(25, 0, 0);
  505.             */
  506.             //AUTOMATED
  507.             themeSettings[eAutoBSetting_color_off_gradienttop] =            ChangeBrightness(themeSettings[eAutoBSetting_color_off],  1.5);
  508.             themeSettings[eAutoBSetting_color_off_gradientbottom] =         ChangeBrightness(themeSettings[eAutoBSetting_color_off],  0.5);
  509.             themeSettings[eAutoBSetting_color_on_gradienttop] =             ChangeBrightness(themeSettings[eAutoBSetting_color_on],  1.5);
  510.             themeSettings[eAutoBSetting_color_on_gradientbottom] =          ChangeBrightness(themeSettings[eAutoBSetting_color_on],  0.5);
  511.             themeSettings[eAutoBSetting_color_hover_gradienttop] =          ChangeBrightness(themeSettings[eAutoBSetting_color_hover],  1.5);
  512.             themeSettings[eAutoBSetting_color_hover_gradientbottom] =       ChangeBrightness(themeSettings[eAutoBSetting_color_hover],  0.5);
  513.            
  514.  
  515.             break;
  516.            
  517.         case eAutoButtonTheme_Blue :
  518.             AbortGame("NOT IMPLEMENTED (suit yourself)");
  519.            
  520.             break;
  521.     }
  522.    
  523.     return themeSettings;
  524. }
  525.  
  526. static int[] AutoButtons::GetTheme(AutoButtonThemes theme)
  527. {
  528.     int themeSettings[] = new int[THEMESIZE];
  529.    
  530.     if (theme < 0 || theme >= MAXTHEMES)
  531.         AbortGame("Not a valid theme number : %d", theme);
  532.    
  533.     for (int i=0; i< THEMESIZE; i++) {
  534.         themeSettings[i] = themes[theme].settings[i];
  535.     }
  536.    
  537.     return themeSettings;
  538. }
  539.  
  540.  //Overwrite an existing theme from your game, without requiring to temper with the module's script (if needed)
  541. static void AutoButtons::SetTheme(AutoButtonThemes theme,  int themeSettings[])
  542. {
  543.     if (theme < 0 || theme >= MAXTHEMES)
  544.         AbortGame("Not a valid theme number : %d", theme);
  545.    
  546.     for (int i=0; i< THEMESIZE; i++) {
  547.         themes[theme].settings[i] = themeSettings[i];
  548.     }
  549. }
  550.  
  551.  
  552.  
  553. void game_start()
  554. {
  555.     //depends on your game
  556.     guiMain = gMain; //this is a dirty hack. we should rely only on "Verbs" methods but it doesn't offer GetActionButton.
  557.    
  558.     //nbThemes = 0;
  559.     defaultTheme = eAutoButtonTheme_Red;
  560.    
  561.     //Init buttons constant width. This is normally ignored and replaced with buttons[].width because not all buttons have the same width
  562.     constants.height = BUTT_HEIGHT;
  563.     constants.width = BUTT_WIDTH;
  564.  
  565.     //Init built-in themes
  566.     int themeSettings[] = GetTheme_BuiltIn(eAutoButtonTheme_Red);
  567.     AutoButtons.SetTheme(eAutoButtonTheme_Red,  themeSettings);
  568.     //themeSettings[] = GetTheme_BuiltIn(eAutoButtonTheme_Blue);
  569.     //AutoButtons.SetTheme(eAutoButtonTheme_Blue,  themeSettings);
  570.    
  571.     //final init
  572.     themeSettings = AutoButtons.GetTheme(defaultTheme);
  573.     AutoButtons.GenerateAll(themeSettings);
  574. }
  575.  



Here is how to make it work with Tumbleweed :
(locate the code below in your Tumbleweed initialization code)
Code: Adventure Game Studio
  1.       // English - eLangEN  
  2.       /*
  3.         //WITHOUT AUTOBUTTONS : Set button graphics manually
  4.         odd_id=1407; even_id = odd_id+1;
  5.         Verbs.LocalizeActionButton(eLangEN,eGA_Open,    GetOddId(), GetEvenId(), 'q');
  6.         Verbs.LocalizeActionButton(eLangEN,eGA_Close,   GetOddId(), GetEvenId(), 'a');
  7.         Verbs.LocalizeActionButton(eLangEN,eGA_GiveTo,  GetOddId(), GetEvenId(), 'z');
  8.         Verbs.LocalizeActionButton(eLangEN,eGA_Push,    GetOddId(), GetEvenId(), 'e');
  9.         Verbs.LocalizeActionButton(eLangEN,eGA_Pull,    GetOddId(), GetEvenId(), 'd');
  10.         Verbs.LocalizeActionButton(eLangEN,eGA_Use,     GetOddId(), GetEvenId(), 'c');
  11.         Verbs.LocalizeActionButton(eLangEN,eGA_PickUp,  GetOddId(), GetEvenId(), 'w');
  12.         Verbs.LocalizeActionButton(eLangEN,eGA_LookAt,  GetOddId(), GetEvenId(), 's');
  13.         Verbs.LocalizeActionButton(eLangEN,eGA_TalkTo,  GetOddId(), GetEvenId(), 'x');
  14.       */
  15.         //WITH AUTOBUTTONS : Get the sprites IDs from the module; it generated thems for you.
  16.         eLanguage lan = eLangEN; int graphic_off; int graphic_on; Action a;
  17.         a = eGA_Open;
  18.         graphic_off = AutoButtons.GetSpriteID(lan, a, eAutoButton_off);
  19.         graphic_on = AutoButtons.GetSpriteID(lan, a, eAutoButton_on);
  20.         Verbs.LocalizeActionButton(lan, a,    graphic_off, graphic_on, 'q');
  21.        
  22.         a = eGA_Close;
  23.         graphic_off = AutoButtons.GetSpriteID(lan, a, eAutoButton_off);
  24.         graphic_on = AutoButtons.GetSpriteID(lan, a, eAutoButton_on);
  25.         Verbs.LocalizeActionButton(lan, a,    graphic_off, graphic_on, 'a');
  26.        
  27.         a = eGA_GiveTo;
  28.         graphic_off = AutoButtons.GetSpriteID(lan, a, eAutoButton_off);
  29.         graphic_on = AutoButtons.GetSpriteID(lan, a, eAutoButton_on);
  30.         Verbs.LocalizeActionButton(lan, a,    graphic_off, graphic_on, 'z');
  31.        
  32.         a = eGA_Push;
  33.         graphic_off = AutoButtons.GetSpriteID(lan, a, eAutoButton_off);
  34.         graphic_on = AutoButtons.GetSpriteID(lan, a, eAutoButton_on);
  35.         Verbs.LocalizeActionButton(lan, a,    graphic_off, graphic_on, 'e');
  36.        
  37.         a = eGA_Pull;
  38.         graphic_off = AutoButtons.GetSpriteID(lan, a, eAutoButton_off);
  39.         graphic_on = AutoButtons.GetSpriteID(lan, a, eAutoButton_on);
  40.         Verbs.LocalizeActionButton(lan, a,    graphic_off, graphic_on, 'd');
  41.        
  42.         a = eGA_Use;
  43.         graphic_off = AutoButtons.GetSpriteID(lan, a, eAutoButton_off);
  44.         graphic_on = AutoButtons.GetSpriteID(lan, a, eAutoButton_on);
  45.         Verbs.LocalizeActionButton(lan, a,    graphic_off, graphic_on, 'c');
  46.        
  47.         a = eGA_PickUp;
  48.         graphic_off = AutoButtons.GetSpriteID(lan, a, eAutoButton_off);
  49.         graphic_on = AutoButtons.GetSpriteID(lan, a, eAutoButton_on);
  50.         Verbs.LocalizeActionButton(lan, a,    graphic_off, graphic_on, 'w');
  51.        
  52.         a = eGA_LookAt;
  53.         graphic_off = AutoButtons.GetSpriteID(lan, a, eAutoButton_off);
  54.         graphic_on = AutoButtons.GetSpriteID(lan, a, eAutoButton_on);
  55.         Verbs.LocalizeActionButton(lan, a,    graphic_off, graphic_on, 's');
  56.        
  57.         a = eGA_TalkTo;
  58.         graphic_off = AutoButtons.GetSpriteID(lan, a, eAutoButton_off);
  59.         graphic_on = AutoButtons.GetSpriteID(lan, a, eAutoButton_on);
  60.         Verbs.LocalizeActionButton(lan, a,    graphic_off, graphic_on, 'x');
  61.        
  62.  
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Flugeldufel on 06 Feb 2019, 14:28
First of all: Thank you, abstauber for this nice template! Gefällt mir! ;)

I'm currently working on my first game and I changed some GUIs and sprites to match my taste. Among others I replaced the verbs with the ones shown in the screenshot.
Now I'm not sure, if (when I release this game sometime) I might get problems because it looks too similar to the original Thimbleweed-verbs. (although I drew them totally new for that low resolution, 320x180)

Should I change it? What do you all think?  ???

(https://imgur.com/7f8UljA.jpg)

Here's a comparison of both:

mine:

(https://imgur.com/me9izXm.jpg)


Thimbleweed Park:

(https://imgur.com/jyRKumW.jpg)
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: abstauber on 11 Feb 2019, 08:33
Wow, those graphics look really nice!

Well the button font is quite close to the one of Thimbleweed Park - I'd say if you go commercial, you might want to go for a more independet route.

But if it's freeware I don't see any issues at all - the font (also the color) fits your game perfectly (as far as I can tell from your background)
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: Flugeldufel on 11 Feb 2019, 10:00
Thank you very much for your feedback! And you confirmed what I already thought.
I don't know, if it's going to be freeware or commercial - it will depend on how complex the game will finally be, full length or not... We'll see. It's still at an early stage.
So I think I'll keep the sprites for now and maybe make some new ones later.

By the way, I would give the actual sprites to anyone who's interested in using them. Just let me know...
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: croquetasesina on 28 Mar 2019, 12:29
Is it possible to save more than nine games?
Title: Re: TEMPLATE: Tumbleweed Verbs 1.1 Last update: 3rd August 2018
Post by: abstauber on 04 Apr 2019, 09:10
Yes, out of the box, you are stuck with nine games. But you can of course extend the save/load gui to your liking: you just need to add more save/load buttons and tell the optiongui script about it.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.2 Last update: 4th April 2019
Post by: abstauber on 04 Apr 2019, 09:31
Maybe it's time to finally declare 1.2 to be stable.  (nod)

This is mainly a refactoring release, no new functions have been added so far. But internally the template has changed a lot.

- cleaned up the global script (moved the remaining GUI actions to the options menu module)
- Localisation of the GUI elements is handled a bit different internally
- It's possible to change the GUIs being used by the template
- Some more refactoring, the template throws errors if a module is missing.
- Bugfix: Option GUI wasn't translated if English is not set as default language

Title: Re: TEMPLATE: Tumbleweed Verbs 1.2 Last update: 4th April 2019
Post by: Crimson Wizard on 30 Apr 2019, 09:57
Hello, I'd like to report a bug.

Preferably performed in larger rooms for convenience:
* Have room 1 and room2;
* In room 2 script cutscene where player's character is walking non-blocking in After Fade-in event
Code: Adventure Game Studio
  1. player.Walk(x,y,eNoBlock);
  2. while (player.Moving) Wait(1);
  3.  
* Run the game, and when in room 1 start running with double-click;
* Immediately press Ctrl+X and change to room 2.

The player character will continue running during cutscene in another room.

Thinking about it, maybe it's enough to just run a cutscene in the same room. Guess the mistake is that character keeps running even when another Walk is called by a script command, even though it may not be required.
Title: Re: TEMPLATE: Tumbleweed Verbs 1.2 Last update: 4th April 2019
Post by: abstauber on 30 Apr 2019, 11:01
Hi and thanks for the bugreport.

I think, that this is because I check the running in repexec and not repexec always. An easy thing to mitigate this for room changes would be to stop running, everytime you change a room. Also by using CTRL-X you're cheating a bit, as I'm checking for 'regular' room changes at line VerbGui.asc:2519 ;)

Running is also cancelled by every new mouseclick, so for this to happen you need to trigger a cutscene while the player is running without any other interaction or event. And the game designer would not stop the player from moving. The question is: how to detect such a cutscene.
I could use Game.InSkippableCutscene, but this would leave out unskipable cutscenes. Maybe a solution would be simply to add a StopRunning command which you would call in a cutscene

I'd love to get some more input on this.

Anyway to stop running also via CTRL-X room changes, this should do the trick
VerbGui.asc:2181
Code: Adventure Game Studio
  1. function on_event(EventType event, int data)
  2. {
  3.   if (event == eEventEnterRoomBeforeFadein) {
  4.     Verbs.CheckDefaultAction();
  5.     Verbs.UpdateActionBar();
  6.    
  7.     verbsData.player_is_running = false;
  8.     player.StopMoving();
  9.     player.SetWalkSpeed(verbsData.player_walk_x_speed,  verbsData.player_walk_y_speed);
  10.     player.AnimationSpeed = verbsData.player_ani_speed;
  11.   }
  12.  
  13.   else if (event==eEventRestoreGame) {
  14.     //Verbs.AdjustLanguage();
  15.     Verbs.InitGuiLanguage();
  16.   }
  17. }
  18.