AGS 3.6.0 - Beta 15

Started by Crimson Wizard, Sun 20/03/2022 20:23:39

Previous topic - Next topic

Baguettator

I would like to "merge" the functions for 3 controls : the custom slider and the customs arrows I made for scrolling a list box. As there are many listboxes in my game, I would like to minimize the number of functions in global script. Merging would allow to do that in one single function, instead of 3 : 1 arrow for Scrolling up, 1 arrow for scrolling down, 1 slider for scrolling up or down. For me it's just an optimization for the script (less functions, less lines etc...).

I can't do that because the "onchange" functions need only 1 parameter, and the "onclick" functions need 2 parameters. So I can't apply a 2 parameters function for a slider (the game crashes and says "1 parameter intended").

Crimson Wizard

#201
Quote from: Baguettator on Tue 28/06/2022 19:06:20
I would like to "merge" the functions for 3 controls : the custom slider and the customs arrows I made for scrolling a list box. As there are many listboxes in my game, I would like to minimize the number of functions in global script. Merging would allow to do that in one single function, instead of 3 : 1 arrow for Scrolling up, 1 arrow for scrolling down, 1 slider for scrolling up or down. For me it's just an optimization for the script (less functions, less lines etc...).

Hm, no, it would be incorrect to change the event function only for that purpose. The solution here is to modify the editor and engine and allow to put event handlers in different scripts, not only global script.
Alternatively, there's a plan to let connecting functions to events in script: this way one would be able to create complex gui setups dynamically.

I guess at this moment you may still merge all arrow buttons in one event handler, and all list sliders in another event handler.

Baguettator

Well it could be useful to allow the difference between left-click and right-click in a slider, couldn't it ?

I have also 1 request, but I know that it's not really your plans to make new improvements :

Could it be possible to add new informations in the Slider struct ? Like the left corner's position (x, y, in the screen, or from the slider itself) of the handle. Also maybe a Y Offset ? And allow negative offsets ?

In my game, the sliders are custom, I use a rectangle for the slider background and a square for the handle. The problem is when value=0 (or value=max), half of the handle isout of the slider. So I need to use a transparent image for the slider, use a button for the real background of the slider, calculate how much the handle is out from the slider, resize the slider so that at value=0 (or value=max) the handle fit perfectly to the borders of the real background (the button's sprite)... And then place the arrows (buttons too) just on top and below the real background of the slider. This way I manage to create a true custom slider that fit perfectly. But it's a lot of work, it could be easier. Like if we can define that the handle's borders can't be out of the slider. Or give it offsets ? Also, being able to know the x,y coordinates of the handle could be useful to generate automatically the custom sliders' sprites at game_start, especially if they use the same images, but not at the same sizes.

Maybe I don't know how to make a good custom slider :) Well, I know it could be out of this thread because it looks like a technical question, but it's mainly a request - until someone tells me that there is an other already existing solution (sorry eri0o for always saying me that I'm out of this thread :( ).

I also encountered problems with the last 3.6 version: I'm playing MP3 audioclips, using the old audio functions (PlayClip or something like that), and at one moment, I heard like a distorsion sound for about 5 seconds, then the music played, but 1 tone lower...!!!

Crimson Wizard

#203
Quote from: Baguettator on Thu 30/06/2022 17:33:11
Maybe I don't know how to make a good custom slider :) Well, I know it could be out of this thread because it looks like a technical question, but it's mainly a request - until someone tells me that there is an other already existing solution (sorry eri0o for always saying me that I'm out of this thread :( ).

At this point my advice is to script your own slider. For example, you could use buttons for slider elements, or raw drawing (DrawingSurface, DynamicSprite). That way you may design literally anything, and script any behavior. People were using raw drawing to create custom controls for years, there were modules made with custom text boxes, scrolling chats, and so on. But yes, this is a topic for Technical Questions section.

Quote from: Baguettator on Thu 30/06/2022 17:33:11
I also encountered problems with the last 3.6 version: I'm playing MP3 audioclips, using the old audio functions (PlayClip or something like that), and at one moment, I heard like a distorsion sound for about 5 seconds, then the music played, but 1 tone lower...!!!

As usual, we would need to know details. What precisely version of AGS, what clip, what was the script command, and so on. We won't be able to do anything without knowing detailed information.

Baguettator

OK, I will gather informations and tell you what happenned exactly :)

About sliders, OK I understand, my question was if it was possible to get more options for the handle offsets, maybe it's not planned for now.

Few bugs, probably :

- If my handle is 50*50 pixels, when the slider value is minimal, the handle is perfectly 25 pixels out from the slider background. If the slider value is maximal, the handle is only at 21 pixels out from the slider background. There is always a 4 pixels "offset" when the value is maximal. Strange ?

- the LisBox.RowCount value seems bugged.When I launch my game, I add items in my listbox (for example 7 items). The gui where my listbox is is not visible yet. If I display the rowcount value, it's 0 ! then I make the gui visible, and display again the value : 5 ! ( the right value !) is it a bug that the listboxes' row count value are not set up propely until they appear at screen ?

Crimson Wizard

#205
Quote from: Baguettator on Fri 01/07/2022 15:41:41
- the LisBox.RowCount value seems bugged.When I launch my game, I add items in my listbox (for example 7 items). The gui where my listbox is is not visible yet. If I display the rowcount value, it's 0 ! then I make the gui visible, and display again the value : 5 ! ( the right value !) is it a bug that the listboxes' row count value are not set up propely until they appear at screen ?

This appeared to be an old bug (reproduced as early as AGS 3.2.1), but will be fixed now.

Quote from: Baguettator on Fri 01/07/2022 15:41:41
About sliders, OK I understand, my question was if it was possible to get more options for the handle offsets, maybe it's not planned for now.

No, nothing else is planned for 3.6.0. Right now there's a HandleOffset property for sliders which creates a horizontal offset, it may be both positive and negative.
Changing anything there would require a good design plan on how control should behave. Frankly, I doubt this will be done in AGS 3.* versions, maybe within experimental "AGS 4" branch.

Quote from: Baguettator on Fri 01/07/2022 15:41:41
- If my handle is 50*50 pixels, when the slider value is minimal, the handle is perfectly 25 pixels out from the slider background. If the slider value is maximal, the handle is only at 21 pixels out from the slider background. There is always a 4 pixels "offset" when the value is maximal. Strange ?

Please tell what is the width of the slider itself?

Overall this is probably because of how handle position is calculated. From my memory, the slider's width is divided by value range, and that's how handle positions are set up.
For instance, if you have values 0-10, this means 11 positions. If your slider is 110 pixels wide, that would mean a position each 10 pixels, distributed along all the slider's width. If slider is 100 pixels wide, that would mean 9 pixels for position and so on. On top of that AGS may add some extra tweaks to create offsets/margins for a handle. This may result in slightly different offsets; the larger the graphics the larger this difference may be (in absolute pixel value).

Baguettator

Quote from: Crimson Wizard on Fri 01/07/2022 19:52:27
Please tell what is the width of the slider itself?

Overall this is probably because of how handle position is calculated. From my memory, the slider's width is divided by value range, and that's how handle positions are set up.
For instance, if you have values 0-10, this means 11 positions. If your slider is 110 pixels wide, that would mean a position each 10 pixels, distributed along all the slider's width. If slider is 100 pixels wide, that would mean 9 pixels for position and so on. On top of that AGS may add some extra tweaks to create offsets/margins for a handle. This may result in slightly different offsets; the larger the graphics the larger this difference may be (in absolute pixel value).

The slider has the same width as the handle. My slider is vertical : so the max value is up. Min value is down. The strange thing is that the handle seems to be always with 4 pixels offset when it's max value. Could you reproduce the same problem with your own tests ? My handle is a square, the same width as the slider background.

Crimson Wizard

#207
Quote from: Baguettator on Fri 01/07/2022 21:59:07
The slider has the same width as the handle. My slider is vertical

Well, then, please tell what it's height. I need to know the slider's size, most importantly the size along which the handle is moving to reproduce this and investigate. Also Min and Max values, just in case.
Since you mentioned slider is vertical, this 4px offset, is it vertical or horizontal?

Baguettator

Quote from: Crimson Wizard on Fri 01/07/2022 19:52:27
This appeared to be an old bug (reproduced as early as AGS 3.2.1), but will be fixed now.

Will it be in the next update ?

About the slider :

Arrow buttons, Handle : 50*50
Slider width:50
Slider Max value : 7
I tried these situations :

-slider height=200
-slider height=273
- slider height=259

I always place the arrow buttons so that at max and min values, the handle is placed just next to the buttons corners.

In each case, there were 4 pixels between the arrow button (up) and the handle when it's in the max value position.

It seems to be a bug ?

Crimson Wizard

#209
Quote from: Baguettator on Sat 02/07/2022 21:23:14
About the slider :

Arrow buttons, Handle : 50*50
Slider width:50
Slider Max value : 7
I tried these situations :

-slider height=200
-slider height=273
- slider height=259

I always place the arrow buttons so that at max and min values, the handle is placed just next to the buttons corners.

In each case, there were 4 pixels between the arrow button (up) and the handle when it's in the max value position.

That's just how AGS calculates the slider positions, it has strange math, it has been like that since ancient times.

There's a "handle range" value that tells in which range the handle can move. This range is calculated as "width - 4" for horizontal and "height - 4" for vertical sliders.
When calculating current position of the vertical slider the formula is "current_pos = (int)(((float)(MaxValue - Value) * (float)handle_range) / (float)(MaxValue - MinValue))".
In addition the handle position is always shifted 2 or 4 pixels to the right or down from the slider's left or top edge (depending on orientation). It's 2 extra pixels for low-resolution games and 4 pixels for high resolution games (640x400 and above).
The handle's graphic is then centered around this position.

For example, if vertical slider has height 200, min value of 0 and max of 7, then:
- handle range = 200 - 4 = 196

- the position at minimal value will be = ((7 - 0) * 196) / (7 - 0) = 196
but there's also +4 pixel offset for a high res game (I'll just assume your is high res, because you have large sliders), so it's = 200.
The sprite handle is then centered around slider's Y 200.

- the position at maximal value will be =((7 - 7) * 196) / (7 - 0) = 0
but there's also +4 pixel offset, so it's = 4.
The sprite handle is then centered around slider's Y 4. This is where the 4 pixels come from in your case.


Baguettator

Wow that's strange !!

Is it planned to change it ? Or there is a reason for that kind of "maths" to exist ? (I believe yes, because why to do difficult when you can do easy).

About my audio problems I told before, could you have a look if the PlayMp3File function works normally ? My code uses this function, I don't do anything excepting playing MP3 files normally, and I encounter "randomly" the bug while the files are played 1 tone under the original.

Also, the Audio.Play function works like before ? Because in the 3.5 versions, I didn't write parameters (I did myaudio.Play()), and it played once normally. Now the same audio files are playing several times, and I didn't change the code ! As you worked on audio before (as I saw in this thread), maybe things have changed a bit ?

Crimson Wizard

Quote from: Baguettator on Sun 03/07/2022 18:50:28
Is it planned to change it ? Or there is a reason for that kind of "maths" to exist ? (I believe yes, because why to do difficult when you can do easy).

I have no idea why it was made like that, it could be a random attempt to make it look in certain way.
No, there were no plans to change how gui look like, at least not in 3.6.0, because changing this now may break looks for someone else who already adjusted to this behavior; also rushing things may cause us missing something. Maybe this will be changed in the future versions, but this has to be well thought through, how the sliders should look, work, and which parameters to use. It's probably not the only thing that could've been adjusted too.

Quote from: Baguettator on Sun 03/07/2022 18:50:28
About my audio problems I told before, could you have a look if the PlayMp3File function works normally ? My code uses this function, I don't do anything excepting playing MP3 files normally, and I encounter "randomly" the bug while the files are played 1 tone under the original.

I cannot tell what does 1 tone down means... Could you give an example of mp3 file, or record how it sounds in some media player and inside a game for comparison?

Quote from: Baguettator on Sun 03/07/2022 18:50:28
Also, the Audio.Play function works like before ? Because in the 3.5 versions, I didn't write parameters (I did myaudio.Play()), and it played once normally. Now the same audio files are playing several times, and I didn't change the code ! As you worked on audio before (as I saw in this thread), maybe things have changed a bit ?

Nothing was supposed to change in script commands. But according to AudioClip.Play, if you dont pass any parameters, then the default values for this clip/audio type will be used. Please check what your clip properties and audio type properties say in the editor.

Baguettator

OK, no problem for sliders, my code deals really well with that :)

1 tone down is about the "pitch" of the music. I could send you my project so that you can test and see.

Also I encountered again the strange sound, like a train slowing quickly... Strange...

Any update of AGS 3.6 with the fix for ListBox.RowCount bug ?

Crimson Wizard

Quote from: Baguettator on Mon 04/07/2022 17:24:37
1 tone down is about the "pitch" of the music. I could send you my project so that you can test and see.

Yes, please.

Quote from: Baguettator on Mon 04/07/2022 17:24:37
Any update of AGS 3.6 with the fix for ListBox.RowCount bug ?

It has been fixed, if you like you may download the latest build here:
https://cirrus-ci.com/task/5111025316921344

Baguettator

Hi,

Also I thought about a thing : would it be possible to make the slider's handle clickable even "out" from the slider's height ?

If my handle's image is 50*50 pixels, at min value or at max value, the slider is 25 pixels out from the slider (+/- 4 pixels, according to the strange maths in AGS  ;) ). The problem is that if I click on the handle, but the click is on the 25 pixels "out" from the slider, the handle doesn't react. Even if you click on it, and even if you have chosen the pixel-perfect collision.

Of course, if the handle is within the slider (not at min/max value), it works perfectly by clicking everywhere on it.

Crimson Wizard

#215
Quote from: Baguettator on Fri 08/07/2022 06:30:52
Also I thought about a thing : would it be possible to make the slider's handle clickable even "out" from the slider's height ?

This was the intended behavior, but got broken few months ago, will be fixed in the next update.

Quote from: Baguettator on Fri 08/07/2022 06:30:52Even if you click on it, and even if you have chosen the pixel-perfect collision.

Please note that pixel-perfect click detection does not work on guis at the moment.

Crimson Wizard

Updated to Beta 10
(use download links in the first post)

Editor:
- Editor no longer errors and fails when opening a game project with some script files missing.
- Fixed editor displaying unhandled exception if the script which user is trying to open was missing. Instead it will now open a blank script.
- Fixed a recently imported sprite could be displayed incorrectly scaled up in the room editor for high-resolution games, if the "Allow relative asset resolutions" was enabled in General Settings, and the sprite 0 had "Resolution" property set to "Low".
- Fixed script autocomplete for function calls was mistreating commas in strings and inline comments as if they were separating actual parameters.
- Fixed script autocomplete was not displaying members of extended structs if the parent struct was declared in another header.
- Fixed script autocomplete was not working for enum names.
- Fixed structs and enums were not highlighted if declared inside a script's body.
- Fixed crash in TextWindow GUI preview.

Engine:
- Fixed AGS_EngineInitGfx plugin callback was not called during OpenGL renderer initialization.
- Fixed ListBox.RowCount reporting 0 if called before the control was displayed once.
- Fixed ListBox was trying to draw double border (in hi-res games) outside of the control's clipping rectangle.
- Fixed Slider's handle not reacting to mouse clicks when partially outside the slider's box.

Baguettator

Hi !

I found minor bugs in the last version :

- the functions for specific controls (functions like that : function my function (this Button*)) don't appear in the list of the editor (at the top of the script). It was not a problem in previous versions

- the labels seem to cut the letters at their top border, even if the option in General Settings is false ("GUIControl cut their content").

- is there any reason for the DrawString function is not as good as the way texts are displayed in labels ? With my font (GorriSans), texts in labels are perfectly displayed, and when I use the DrawString function, the letters are "bold" and not as precise.

Crimson Wizard

#218
Quote from: Baguettator on Sun 10/07/2022 22:39:10
- the functions for specific controls (functions like that : function my function (this Button*)) don't appear in the list of the editor (at the top of the script). It was not a problem in previous versions

What are these functions, where and how are they declared?

Quote from: Baguettator on Sun 10/07/2022 22:39:10
- the labels seem to cut the letters at their top border, even if the option in General Settings is false ("GUIControl cut their content").

Please, give some details... what is the font, which parameters do you use, what is the label's parameters?

Quote from: Baguettator on Sun 10/07/2022 22:39:10
- is there any reason for the DrawString function is not as good as the way texts are displayed in labels ? With my font (GorriSans), texts in labels are perfectly displayed, and when I use the DrawString function, the letters are "bold" and not as precise.

Depends on what do you draw upon. If the font is anti-aliased, and you draw on a surface without alpha channel, then the anti-aliasing will be lost.

Baguettator

Quote from: Crimson Wizard on Sun 10/07/2022 23:03:07
Quote from: Baguettator on Sun 10/07/2022 22:39:10
- the functions for specific controls (functions like that : function my function (this Button*)) don't appear in the list of the editor (at the top of the script). It was not a problem in previous versions

What are these functions, where and how are they declared?

For example, I have these two functions declared in the script .asc :

Code: ags
function Prise_Objectif(int typesalle, Button *bouton)
function PionFouille(this Button*)


In the list of the script (the one who gathers ALL the functions of the script, at the top of the editor), normally, I should able to see :

PriseObjectif
Button::PionFouille

But the second one doesn't appear. And all the functions linked to a struct that is not created in the script (all the "standard" ones, like Button, GuiControl, ListBox etc...) don't appear in the list.

Quote from: Crimson Wizard on Sun 10/07/2022 23:03:07
Quote from: Baguettator on Sun 10/07/2022 22:39:10
- the labels seem to cut the letters at their top border, even if the option in General Settings is false ("GUIControl cut their content").

Please, give some details... what is the font, which parameters do you use, what is the label's parameters?

Sorry, the font is Gorri Sans, the label parameters are standard, the thing is that probably I need to add a vertical offset to the font so the top of the letters won't be cut by the label top edge. But if I didn't choose the "cut content for Guicontrol" option in General Settings, that's not intended to be cut ?

Quote from: Crimson Wizard on Sun 10/07/2022 23:03:07
Quote from: Baguettator on Sun 10/07/2022 22:39:10
- is there any reason for the DrawString function is not as good as the way texts are displayed in labels ? With my font (GorriSans), texts in labels are perfectly displayed, and when I use the DrawString function, the letters are "bold" and not as precise.

Depends on what do you draw upon. If the font is anti-aliased, and you draw on a surface without alpha channel, then the anti-aliasing will be lost.

Perfect, I didn't know about it ! thanks !

SMF spam blocked by CleanTalk