Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - abstauber

#401
Sweden - especially Gothenburg sounds indeed very tempting. Unfortunately my vacation ends on 31th July.
Let's see if I can move it for a week. But yes: I'm very interested and we've got a direct ferry connection to Gothenburg :)
#402
Terrific news - thanks for your hard work.
Btw: Is the official Bugtracker now located at Youtrack or is it still this forum's module?
#403
I'm sad to say that this weekend is also completely blocked for me.
*But I keep my fingers crossed that the ceremony gets postponed once more* :-*

Otherwise have fun and many thanks to Mods for making it happen this year (nod)
#404
1) Good
2) Yes
3) hmm...
:P



Code: ags

  int btn = BtnHelper.create(50, 50);
  Btns[btn].setRoundness(25);
  Btns[btn].setColors(1);
  Btns[btn].setText("Oux",15, eFontFont3);
  Btns[btn].setForegroundGradient(59163, 65535, eBtnBlend_easeOut, 70, 100);  


Yup, this is all possible :) For some reason, odd "roundness" values look better than even values.
About the bevel effect: the script creates an outer and an inner quarter circle for the transparency mask. Then a rectangular bevel is being drawn and the mask is applied afterwards. If I'd create smaller circles (and multiple masks) small pixel holes would appear in the corners. I think the only "perfect" solution would be to work with bezier curves. But a bevel of 1px (which is rendered as 2px) still looks acceptable for completely round buttons and might be enough in low res. You can of course apply any sorts of background images and therefore pre-render the bevel.

#405
Oops, seems to be another bug:

Code: ags

//line 110 in GlobalScript.asc 
//old
  if (!IsGamePaused()) {

//new 
 if (!IsGamePaused() && !is_gui_disabled())
#406
Cheers :)
I hope it makes people's life a bit easier.
#407
In the meantime I've added rounded button support 8-)
#408
I was more thinking of the illusion of rounded buttons ;)

As a hardcore workaround you could also use dummy characters instead of real gui buttons. But that's out of scope for this module of course.
#409
True, without the bevel feature, rounded buttons would have been already added.
Let's see if this module attracts users at all. If so I might consider adding at least rounded buttons.
#410
Hmm.. it really seems like listboxes do not allow to change colors during runtime - only fonts. Has this been overlooked for such a long time? Maybe it's best to open a separate thread for this.
#411
Have you ever been tired of drawing all your GUI buttons in a paint program? Is it even more boring to create versions for highlighted and clicked buttons in all the different languages? If your answer is 'yes', continue reading :)

Abstract:
This module generates rectangular buttons, which you can assign to anything: GUI buttons, objects, inventory or dynamic sprites - you name it.

Dependencies:
AGS 3.x
Alpha support in AGS has been fixed recently, so you might want to use AGS 3.3 if you need proper alpha channel support.

Download:
http://shatten.sonores.de/wp-content/uploads/2016/04/BtnHelper_1.1.1.zip

Demo:

Now with rounded buttons

Usage:
To turn this

into this:


all you need is this bit of code:
Code: ags

  import cBtns Btns[MAX_BTNS];
  // Button1: normal. Define the basic values
  int btn1 = BtnHelper.createFromGuiButton(ActionButton1, true);
  Btns[btn1].setColors(2, 48599, 16937);
  Btns[btn1].setBorder(3);
  Btns[btn1].setBevel(3);
  Btns[btn1].setBackgroundImg(3, 0, false);
  Btns[btn1].setBackgroundGradient(28030, 19445, eBtnBlend_easeIn, 50, 70);  
  Btns[btn1].setForegroundImg(1, 0, eBtnAlignVertical_center, eBtnAlignHorizontal_right);
  Btns[btn1].setText("Ags",59228, eFontFont3);
  Btns[btn1].setTextShadow(16937);
  Btns[btn1].render();
  
  // Button2: highlight. Set an outline and change font color
  int btn2 = BtnHelper.createFromGuiButton(ActionButton2, true);
  Btns[btn2].copyAttributes(btn1);
  Btns[btn2].setOutline(59228);
  Btns[btn2].setText("Ags",65490, eFontFont3);
  Btns[btn2].render();
  
  // Button3: clicked. Inverse bevel and adjust border
  int btn3 = BtnHelper.createFromGuiButton(ActionButton2, true);
  Btns[btn3].copyAttributes(btn2);
  Btns[btn3].setBorder(4);
  Btns[btn3].setColors(2,16937, 48599);
  Btns[btn3].render();

  // Assign the graphics to the GUI buttons
  ActionButton1.NormalGraphic = Btns[btn1].getGraphic();
  ActionButton2.NormalGraphic = Btns[btn2].getGraphic();  
  ActionButton3.NormalGraphic = Btns[btn3].getGraphic();  





Documentation:
First you need to import the button struct called Btns in your script
Code: ags
import cBtns Btns[MAX_BTNS];


Now here's a simple rounded blue Button with white text.
Code: ags

  //The Gui Button we want to use is called Button1
  int btn = BtnHelper.createFromGuiButton(ActionButton, true);
  // Set some attributes
  Btns[btn].setRoundness(10);
  Btns[btn].setColors(1);
  Btns[btn].setText("Hello",15, eFontFont3);
  // Create the image
  Btns[btn].render();
  
  // After the image has been rendered, we need to assign the new graphic to the button.
  Button1.NormalGraphic = Btns[btn].getGraphic();    



To create a button, you need to call BtnHelper struct - think of it as a factory which creates button dummies :) After that, you call the button struct directly with the generated id.
Code: ags

// First we call the helper
int id = BtnHelper.create(30,20);
// Now use the struct
Btns[id].setColors(15);
Btns[id].render();

This results in a white 30x20px rectangle. But you can't see it yet. First you need to assign it to some AGS element, e.g. a GUI button.
Code: ags
  
Button1.NormalGraphic = Btns[id].getGraphic();    

There you go. The button will now show as a white rectangle.

These are all public helper functions.
Code: ags

  // creates a button from scratch and returns the id to address it in the button struct
  int id  = BtnHelper.create(int width,  int height,  bool preserveAlpha );
  // same as above, but takes the sizes and (optional) image from the GUI Button.
  int id2 = BtnHelper.createFromGuiButton(Button *guiButton, bool preserveAlpha );

  // Deletes a button. Make sure it's image isn't in use anymore
  BtnHelper.reset(id);  

  // Deletes all buttons. Make sure the images aren't in use anymore
  BtnHelper.resetAll();


These are the public functions to change the button's look.
Code: ags

copyAttributes(int src_btn_id);
setColors(int baseCol,  int highCol,  int shadowCol);
setBorder(int amount);
setBevel(int amount);
setBackgroundGradient(int startColor,  int endColor, eBtnBlend blendMode, int startTransparency, int endTransparency);
setForegroundGradient(int startColor,  int endColor, eBtnBlend blendMode, int startTransparency, int endTransparency);
setText(String text, int color, int font, eBtnAlignVertical vAlign, eBtnAlignHorizontal hAlign); 
setTextShadow(int color);
setTextGradient(int startColor,  int endColor, eBtnBlend blendMode, int startTransparency, int endTransparency);
setBackgroundImg(int spriteSlot, int transparency, bool scaling);
setForegroundImg(int spriteSlot, int transparency, eBtnAlignVertical vAlign, eBtnAlignHorizontal hAlign );
setRoundness(int amount);
setOutline(int color);
getGraphic();
render();

The private functions start with an underscore, you shouldn't need to call them directly.


Revision History:
1.0   initial release
1.1   rounded button support
1.1.1 added the function "getGraphic()", minor touch ups
#412
Here you go:
http://www.adventuregamestudio.co.uk/forums/index.php?topic=53409
It's only been tested with AGS 3.4.0.6 so far, since I know that the alpha channel rendering is solid in this version.
That's also why I trusted "CopyTransparencyMask" when applying the gradient on the font - it simply works :)

As for Challenge #0: Are you sure you don't want to rely on a c++/lua plugin? Scanning the source and target image with GetPixel will take ages. Also I'm not sure if GetPixel respects the alpha channel correctly.

PS:
Once I can think of a few nice sample buttons, I'll open a thread in the module section.
Done :)
#413

Surprisingly I did find some time :D

Now this all needs to be commented.. oh and btw. do I still unlock the achievement, if I make this public or does it have to be exclusive?
#414
Challenge #1 partially accepted


I made a button generator - unfortunately my weekend is blocked, so I might continue on Monday.
#415
Just to add my two cents: having Avast installed is worse than having an actual virus.
And I never had any problems with AGS under Win7, Win8.x and 10 before I installed Avast and it all continued to be fine after I got rid of it.

Avast simply blocks the AGS executable and even remembers that. So once you run winsetup, you're screwed because afterwards the game is blocked forever.
#416
QuoteMaybe i have an older version?
That could be it. In the recent versions of this template, this function is called from the GlobalScript at line 41 inside game_start().
In any case, here is the function :)

Code: ags

//guiscript.ash
import function InitGuiLanguage();


Code: ags

//guiscript.asc
function InitGuiLanguage() {
  AdjustLanguage();
  int i;
  GUIControl*gc;
  Button*b;
  
  while (i < A_COUNT_) {
    gc = gMaingui.Controls[action_button[i]];
    b =  gc.AsButton;
    b.NormalGraphic=action_button_normal[i];
    i++;
  }
}


PS.
Quoteit gives me unresolved import initguilanguage.
remember, ags script it is case sensitive: InitGuiLanguage  ;)
#417
Congratz!
And thanks a million for doing this in AGS! I hope sales are skyrocketing :D
#418
Hey, thanks for the feedback. I never thought that there are still some CGA palette fans out there, my family was mostly put off by the color choice :P
I have plans to add a jump'n run stage (in the vain of Commander Keen) for the next holiday season, let's see if I manage find some spare time.
#419
Good to hear, I ditch the test case then :)
As for the other problem: instead of calling AdjustLanguage() inside room_load, try
Code: ags
InitGuiLanguage()
This calls also AdjustLanguage but also assigns all button images immediately.
#420
Quotethe gui change always after fade in even in room load (using adjust language command)
Could you please provide some more details on the first problem - I somehow can't make sense of that statement.

Quotewhen we change gui we change also character but the inventory items of the previous character stay visible during fade in and then change
Both characters are in different rooms I suppose? I'll create a test case and see if I can replicate this. In the meantime, have you tried to force an update via invMain.CharacterToUse = cCthulhu; ?
SMF spam blocked by CleanTalk