AGS 4.0 - Alpha 24 for public test

Started by Crimson Wizard, Thu 01/06/2023 14:00:59

Previous topic - Next topic

Baguettator

Oh, sorting strings seems more complicated than I thought...!

I have another feature request in mind, I don't know if it would be difficult to add, but perhaps it could lead to nice improvement for visuals : could it be possible to make a GUI's edges displayed with some graphic style ?

For example, the edges of a GUI could be "fade-out", that means : it gradually draw the GUI from solid (no transparency) to nothing (real edge of the GUI). Making superposed GUI more beautiful in some cases. The width of the "fade-out" could be a parameter too in the editor, and even accessible in script (could be used for "Tween" functions for example !).

It could be also something like "geometry" : edges could be just a line, or something like waves.

The corners of the GUI could be 90°, or like a circle.

Well, that sort of things !

Of course, it's just a suggestion. Perhaps I'm wrong because it could be done via coding into AGS, but I think it could be very convenient to have it built-in, allowing better graphic design in AGS games !

Crimson Wizard

#461
Quote from: Baguettator on Yesterday at 16:41:12I have another feature request in mind, I don't know if it would be difficult to add, but perhaps it could lead to nice improvement for visuals : could it be possible to make a GUI's edges displayed with some graphic style ?

Displaying GUI borders as sprites, similar to how it's done for TextWindow GUI, may be done. But there are myriads of possible styles and effects that may be wanted, so trying to accommodate all possible ones will lead to overdesign, and still never fully achieved. I'd prefer to keep things simple. We may provide an ability to set 8 edge graphics on GUI, and then let user customize these graphics as they prefer.

Baguettator

I didn't think about giving sprites for the edges. Just something like a "blend mode" (I'm not sure if it's the right word in english). Like an effect. A Fade-Out or a Geometry shape. Not another sprite like a TextWindow GUI.

Crimson Wizard

#463
Quote from: Baguettator on Yesterday at 16:56:16I didn't think about giving sprites for the edges. Just something like a "blend mode" (I'm not sure if it's the right word in english). Like an effect. A Fade-Out or a Geometry shape. Not another sprite like a TextWindow GUI.

There are many possible effects and geometric shapes that users may wish. We won't be able to cover them all. That's why I proposed edge sprites instead. If there were ones, then users may give these sprites any shapes and effects they want.

If you want an effect on the GUI background (whole GUI), then that may be achieved with shaders now (and previously could be achieved with dynamic sprites).

If it's still not that, then please post an example, as a screenshot or a video.

Crimson Wizard

Quote from: Crimson Wizard on Mon 18/08/2025 21:39:48I've been thinking that maybe we can add a compatibility fix, and let engine override BlendMode under following conditions:

- DrawingColor is COLOR_TRANSPARENT
- BlendMode is Normal.
- A geometry shape function is called (DrawLine, DrawPixel, DrawRectangle, etc)

In such case the engine will use BlendMode Copy just for the current operation (without changing properties).


I tried this today, but stopped after realizing that this will lead to illogical behavior.

Imagine there's a slider that changes "alpha" component of the drawing color. Each time a slider moves, the drawing color is updated, and something is redrawn with a new color.
While you move the slider back and forth, the rectangle is drawn with more or less transparency over a surface.
But if you move the slider to zero, then suddenly the rectangle is cut from the surface instead.

So, I decided that I cannot do such fix.

Baguettator

Quote from: Crimson Wizard on Yesterday at 16:59:41
Quote from: Baguettator on Yesterday at 16:56:16I didn't think about giving sprites for the edges. Just something like a "blend mode" (I'm not sure if it's the right word in english). Like an effect. A Fade-Out or a Geometry shape. Not another sprite like a TextWindow GUI.

There are many possible effects and geometric shapes that users may wish. We won't be able to cover them all. That's why I proposed edge sprites instead. If there were ones, then users may give these sprites any shapes and effects they want.

If you want an effect on the GUI background (whole GUI), then that may be achieved with shaders now (and previously could be achieved with dynamic sprites).

If it's still not that, then please post an example, as a screenshot or a video.

For my personal use and for now, I only thought about edges fading out to transparent. But not only for the background of the GUI, I thought for the whole GUI (background + his own GUIControls) fading out to transparent on the edges.

As an example, think about the StarWars Introduction (with the yellow text on the space screen). The text goes away and disappear. If it was done by AGS (how grateful it could be :) ), it could be :

- Room Background is the space image
- create a GUI a bit smaller than the room's size, with transparent background
- set the upper edge to fade-out with a 20 pixels width (20 pixels for example)
- set the other edges to standard (no effect)
- create a button with the text as a sprite, make the button's Y coordinate scrolling up (tween motion !)
- as the button approaches the upper edge, it is drawn using the fade-out effect as set before : so everything in the GUI (the GUI's background and his own controls) is drawn using the fade-out effect in the zone with coordinates range Y = 0 to Y = 20

Hope I'm clear enough, and excuse me if it's not the case :)

Another idea comes this morning : could it be possible to have a built in function allowing to call an object/GUIControl/whatever's OnClick function ? For example :

Code: ags
ButtonA_OnClick(GUIControl *control, MouseButton button)
{
  Display("Yo, I'm Mister A !");
}

ButtonB_OnClick(GUIControl * control, MouseButton button)
{
  DIsplay("Wow, impressing !");
}

function on_key_press(eKeyCode keycode, int mod)
{
  if (keycode==eKeyA) ButtonA.CallScript(eMouseLeft); // Calls "ButtonA_OnClick"
  else if (keycode==eKeyB) ButtonB.CallScript(eMouseLeft); // Calls "ButtonB_OnClick"
}

I know we can use Processclick functions, but it could be a bit annoying in some cases (and it would be  much longer to code).

Crimson Wizard

#466
Quote from: Baguettator on Today at 07:05:26For my personal use and for now, I only thought about edges fading out to transparent. But not only for the background of the GUI, I thought for the whole GUI (background + his own GUIControls) fading out to transparent on the edges.

I understand what you mean by "fade-out" now. So, yes, the Shader attached to GUI is definitely one of the possible solutions for this, and it's relative easy to write one. Such shader would apply the alpha value to the pixel depending on the relative distance from the surface edge.
It also does not have to be GUI, similar thing may be achieved for any type of object, only may need slightly different approach.

There must be a way to code this for Software renderer too, if software renderer support is desired for your game. I don't know yet, I must think about this.


Quote from: Baguettator on Today at 07:05:26Another idea comes this morning : could it be possible to have a built in function allowing to call an object/GUIControl/whatever's OnClick function ? For example :

There's Button.Click.

But commonly this is solved by having the action code in a separate function, and then calling that function from both control's event and "key press" event.

Snarky

Quote from: Crimson Wizard on Today at 07:50:58
Quote from: Baguettator on Today at 07:05:26Another idea comes this morning : could it be possible to have a built in function allowing to call an object/GUIControl/whatever's OnClick function ? For example :

There's Button.Click.

But commonly this is solved by having the action code in a separate function, and then calling that function from both control's event and "key press" event.

But also, there is nothing stopping you from simply calling the event handler like any other function:

Code: ags
ButtonA_OnClick(GUIControl *control, MouseButton button)
{
  Display("Yo, I'm Mister A !");
}

ButtonB_OnClick(GUIControl * control, MouseButton button)
{
  Display("Wow, impressing !");
}

function on_key_press(eKeyCode keycode, int mod)
{
  if (keycode==eKeyA) ButtonA_OnClick(ButtonA, eMouseLeft); // Calls "ButtonA_OnClick"
  else if (keycode==eKeyB) ButtonB_OnClick(ButtonB, eMouseLeft); // Calls "ButtonB_OnClick"
}

Baguettator

Quote from: Snarky on Today at 08:23:17
Quote from: Crimson Wizard on Today at 07:50:58
Quote from: Baguettator on Today at 07:05:26Another idea comes this morning : could it be possible to have a built in function allowing to call an object/GUIControl/whatever's OnClick function ? For example :

There's Button.Click.

But commonly this is solved by having the action code in a separate function, and then calling that function from both control's event and "key press" event.

But also, there is nothing stopping you from simply calling the event handler like any other function:

Code: ags
ButtonA_OnClick(GUIControl *control, MouseButton button)
{
  Display("Yo, I'm Mister A !");
}

ButtonB_OnClick(GUIControl * control, MouseButton button)
{
  Display("Wow, impressing !");
}

function on_key_press(eKeyCode keycode, int mod)
{
  if (keycode==eKeyA) ButtonA_OnClick(ButtonA, eMouseLeft); // Calls "ButtonA_OnClick"
  else if (keycode==eKeyB) ButtonB_OnClick(ButtonB, eMouseLeft); // Calls "ButtonB_OnClick"
}

Yes, understood, I know that. My problem is that I want to use it for ListBox (for example), and ListBox doesn't have the .Click function. What I want to do is :

- a ListBox pointer gives the focus on a listbox
- if I use the arrow down or arrow up keys, it moves the List Selected Index (up or down).
- as this ListBox has a OnClick function (making things appearing on screen according to the selected index), I want to make as if I clicked on the new selected index. So the arrow keys act as a click on the upper/lower index.
- because it's a pointer (it's not a prticular listbox, it can be any of them), I can't call the specific function without coding it manually with many if/else instances

I thought that a .Click function for other things than buttons could be interesting. I know too that I can do it in other way (1 onclick function for all listboxes of the game, calling specific onclick functions according to the listbox clicked, as Crimson said), but I presume if there is a .Click function for Buttons, it's because it could be needed ? So why not for other controls ?

Baguettator

Quote from: Crimson Wizard on Today at 07:50:58
Quote from: Baguettator on Today at 07:05:26For my personal use and for now, I only thought about edges fading out to transparent. But not only for the background of the GUI, I thought for the whole GUI (background + his own GUIControls) fading out to transparent on the edges.

I understand what you mean by "fade-out" now. So, yes, the Shader attached to GUI is definitely one of the possible solutions for this, and it's relative easy to write one. Such shader would apply the alpha value to the pixel depending on the relative distance from the surface edge.
It also does not have to be GUI, similar thing may be achieved for any type of object, only may need slightly different approach.

There must be a way to code this for Software renderer too, if software renderer support is desired for your game. I don't know yet, I must think about this.


Quote from: Baguettator on Today at 07:05:26Another idea comes this morning : could it be possible to have a built in function allowing to call an object/GUIControl/whatever's OnClick function ? For example :

There's Button.Click.

But commonly this is solved by having the action code in a separate function, and then calling that function from both control's event and "key press" event.

Sorry, didn't know about shader in AGS ! How can I learn about how to use it in AGS ? It's not in the online manual, and in the local manual (within ags editor), it's not explaining anything.

By reading your message, I understand that it will be in any case something to code manually, no need to make something built-in ?

Crimson Wizard

#470
Quote from: Baguettator on Today at 09:04:53My problem is that I want to use it for ListBox (for example), and ListBox doesn't have the .Click function. What I want to do is :

- a ListBox pointer gives the focus on a listbox
- if I use the arrow down or arrow up keys, it moves the List Selected Index (up or down).
- as this ListBox has a OnClick function (making things appearing on screen according to the selected index), I want to make as if I clicked on the new selected index. So the arrow keys act as a click on the upper/lower index.
- because it's a pointer (it's not a prticular listbox, it can be any of them), I can't call the specific function without coding it manually with many if/else instances

In this case it should not be Click function, because it's not the "click" list box event, but "OnSelectionChanged".
The problem is not that there is no such function to be called directly, but because in AGS GUI controls are working inconsistently. In a normal ui framework a listbox control would trigger a event whenever its selection is changed by command too. In other words, when you set SelectionIndex, the listbox should call its "SelectionChanged" function.
That is what should be done here, not a click simulation.

Crimson Wizard

#471
Quote from: Baguettator on Today at 09:09:25Sorry, didn't know about shader in AGS ! How can I learn about how to use it in AGS ? It's not in the online manual, and in the local manual (within ags editor), it's not explaining anything.

By reading your message, I understand that it will be in any case something to code manually, no need to make something built-in ?

We do not have a fully prepared manual for the AGS 4 yet.

The Shaders feature is discussed in this forum thread, with examples and demo game attached:
https://www.adventuregamestudio.co.uk/forums/engine-development/experiment-ags-4-custom-shaders-support/

I also was experimenting with BlendModes. There's a "CopyAlpha" blend mode that can apply a transparency mask onto things below it. I was thinking that maybe if there's a button with a transparency mask, then it could act like a "fade-out" edge effect. Unfortunately, it did not work well in this case, because it affects both controls and gui background, meaning that gui background may become less transparent at some points. If this problem can be solved somehow, then the "Star Wars" text effect will be achievable with blend modes too (and will work in Software renderer).

EDIT: theoretically that would be solved if either:
- the mask would affect controls but not gui itself, or
- there's another blend mode that only decreases resulting alpha, but never increases it (above what gui/controls have).

In the past I tried to implement Min and Max blend modes, but something was not working well with guis, so I cancelled that work. I think that something like "MinAlpha" would work in this case.

Crimson Wizard

#472
Updated to Alpha 24
(Please use download links in the first post)

This update contains all the additions and fixes from 3.6.2 Patch 3 and 3.6.3 Beta 1 (except ones related to backwards compatibility).

The own changes are quite small this time and are mostly bug fixes.

Common:
- Fixed an ancient mistake where Character's and Object's sprites would be drawn 1 pixel higher than their Y position demands. This affects both how the sprites are positioned in game at runtime and in the Room Editor.

Editor:
- The "Upgrade Game Wizard" dialog will be now shown if the loaded game must go through noteable modifications when upgrading to the current version.
- Fixed setting Color property in the editor to 0 makes a black color instead of transparent.
- Fixed non-latin unicode characters in room and room object/hotspot etc properties getting lost when closing and reloading a room.

Scripting:
- Support modulus-assignment operator (%=).

Script API:
- Expanded RepeatStyle with more animation flow styles: eOnceAndReset, eOnceAndBack and eRepeatAlternate. These styles are currently supported in Animate(), MovePath() and WalkPath() commands, and MotionPath struct.

Engine:
- Fixed buttons with non-clipped text wider than the button itself had a wrong interaction rectangle.
- Fixed reading saves with walking characters made after 4.0.0.16.
- Fixed reading saves with overlays made after 4.0.0.18.



Regarding the 1 pixel vertical bug:
When you are upgrading your old project, the Editor will launch a "Upgrade Game Wizard", where it will suggest you to move each room object in each room by 1 pixel in order to compensate for this fix. This may help to keep the visual positioning of object sprite relative to the room background.
This fixup is optional and may be skipped. Of course, you may later fix your objects positions yourself as you see fit.

Regarding the new RepeatStyles:
- eOnceAndReset: plays once in the starting direction, then resets to the first frame (or last frame - if played backwards).
- eOnceAndBack: plays once in the starting direction, then another once in reverse.
- eRepeatAlternate: plays repeatedly, changing direction each time the last (or first - when in reverse) frame was reached.

SMF spam blocked by CleanTalk