AGS 4.0 - Alpha 17 for public test

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

Previous topic - Next topic

Crimson Wizard

AGS 4 - Alpha 16
Full release number: 4.0.0.13

ACHTUNG!

This is a ALPHA version of AGS 4.
This is a WIP version, and must go through extensive testing.
Use at your own risk. Please back up any games before opening them in this version of AGS.
New settings in this version WILL make your project files unusable in previous versions after saving with this version.


For Engine/Editor developers
Spoiler


Last updated: 29th December 2024



This release is brought to you by:

- Alan v.Drake
- Crimson Wizard
- eri0o (joystick & gamepad support, other improvements)
- fernewelten (new script compiler)
- ChamberOfFear, aka persn (open room format, Editor improvements)
- Matteo Piovanelli (improvements)
- KeyserSoSay0 (improvements, fixes)



What is AGS 4

AGS 4.0 is an upcoming version which is currently in experimental stage. The primary idea of this version is a complete removal of the deprecated functionality: game settings and script functions. AGS 4 will no longer be able to run older 2.* or 3.* games. It will only guarantee the import of the latest 3.* game projects (such as 3.6.0). This means that if you want to update your existing game to AGS 4, then you'll have to first import and save it in 3.6.0. If your game is using any of the deprecated settings or script commands - you'll have to replace these, as 4.0 will no longer have necessary "backwards compatibility" switches in General Settings.

It is still in works, and there is a number of large changes planned.
But what are the ready major new features of AGS 4?

Open Room format

The new room format made by @ChamberOfFear now stores rooms as a collection of directories with room data split into multiple files. The room properties are stored in XML, which make it possible to read and even edit by hand outside of the editor. Room backgrounds and region masks are stored as separate PNG images.

This improves the safety of working with rooms, allows to change things externally, and simplify teamwork to some degree.

New script compiler with new syntax features

The new compiler was written by @fernewelten, and it grants a whole bunch of syntax improvements to the AGS script, such as nested structs, multi-dimensional arrays, dynamic arrays have `Length` pseudo-property, and so on.

The full cheat-sheet of the new features may be found here:
https://github.com/adventuregamestudio/ags/wiki/New-compiler%27s-end-user-cheat-sheet
If anyone is curious, here's the more "technical" version, explaining things in depth:
https://github.com/adventuregamestudio/ags/wiki/Features-of-the-new-Script-Compiler

Managed pointers inside managed structs

These are also allowed now (this is not related directly to the script compiler, but also to how engine handles dynamically created objects). This feature finally opens full potential of structs referencing each other with pointers, and allow you to create virtually any kind of data storage in script.

To give an example:
Code: ags
managed struct Item; // pre-declaration

managed struct Person {
    Item* items[];
};

managed struct Item {
    Person* owner;
};

Here's a LinkedList module I wrote for a test:
https://www.dropbox.com/s/sxur2bsccsvaqmr/ags399-LinkedList.zip?dl=0

Watch Variables panel

This panel lets you see values of the script variables while you run the game from the Editor.
An example of how it looks like is on this screenshot:
https://i.imgur.com/D1L69LH.png

Advanced object features

The game objects have two new features worth mentioning up front: Blend Mode and Rotation.
* BlendMode property lets you change the way object is drawn, selecting one of the 10 classic modes (Add, Subtract, Dodge, etc). This gives you ability to make more visual effects in your game.
* Rotation property (called GraphicRotation in some) lets you to rotate the object by a number of degrees. Most standard things have this, and even Cameras, so you may, for example, rotate the whole room view, and characters in it individually. Rotation is hardware accelerated (in Direct3D/OpenGL mode) and does not slow things down, unlike rotating dynamic sprites. Engine correctly detects clicks on rotated objects, so for example, rotated GUI will be fully functional.
* GUIs may be scaled using ScaleX and ScaleY properties (and SetScale function).

What else is PLANNED for AGS 4?

Here's the milestone proposal:
https://github.com/adventuregamestudio/ags/issues/1298

It's not clear at the moment whether all of these features will be a part of the first 4.0 release, but at least some of these will hopefully be.

How safe is this WIP version currently?

It is relatively stable, and there are few people who were already using it to make games for a while: Alan Drake is one of them, and I suspect that fernewelten was also using it sometimes for his games because of his new compiler (but I may be mistaken).
The biggest problem with this is that this version will be updated further, so some things may not be final. Project format may also change in the next updates. We'll try to keep things upgradeable (so that the previous projects made in this WIP version won't just break).
And it surely it will benefit from more testers.



The full changelog follows:

Contains all improvements and fixes from AGS 3.6.1 and 3.6.2 (including patches), except ones made for backwards compatibility.

Common:
 - Support true 32-bit colors in GUI, text messages and drawing commands in script. Color number properties now correspond to the encoded 32-bit RGB (R8G8B8 format).
 - Fonts are split into Font Files and Fonts, where multiple Fonts may use same Font File, or not have any Font File assigned at all (for instance, if they are meant to act as placeholders and get replaced by fonts from plugin).
 - Most of the deprecated functionality (game settings and script API) is cut out from both Editor and Engine, and is no longer supported. The Editor guarantees to import the projects saved by AGS 3.6.0 and later. The Engine may run games compiled in 3.6.0, but only so long as they don't use any deprecated settings or script commands.
 - Removed support for 16-bit games. Any older 16-bit project will be converted to 32-bit on import by the Editor.
 - Completely removed Global Messages and Room Messages.
 - Removed built-in support for Game Score, including related game settings and GiveScore script command. Users are advised to script their own score counter if they need one.
 - Removed support for '[' as a linebreak character in text.

Editor:
 - Open room project format: rooms are now saved as subfolders in "Rooms" folder, where each component has its own separate file (room data, backgrounds, masks and scripts).
 - Support room backgrounds and masks as PNGs.
 - "Fonts" node in the Project Explorer now contains separate "Font Files" and "Fonts" sublists.
 - Actual font files on disk are now stored in "Fonts" subfolder in the project when imported, and keep their original names (no longer renamed to "agsfntN.*").
 - Translation sources are now saved in PO format.
 - In General Settings added "Script Compiler" option that lets to choose between old and new script compilers for your game (see "Scripting" section below for the new compiler's details).
 - Added Custom Properties for: Audio Clips, Dialogs, GUI, GUI Controls, Regions, Walkable Areas.
 - Added Enabled and Visible properties to Characters, Enabled property to Room Objects.
 - Added BlendMode property to Characters, GUI and Room Objects.
 - Added Flip property to View Frame, replacing a boolean Flipped property. The new property supports all 3 flip variants: horizontal, vertical and both at once.
 - Added FaceDirectionRatio property to General Settings, Room and Walkable Areas.
 - Added readonly Length property to AudioClips, for the reference.
 - Added "Source FontFile" property to Fonts, this property lets assign a Font File to the Font.
 - Implemented "Watch Variables" panel which lets to watch values of the selected script variables while running the game. This feature is working only if game is built in Debug mode. The panel has an option to automatically enlist local variables (relative to current position in script).
 - Added "Add to Watch Panel" command to Script Editor's context menu.
 - Support dragging a text from the script window into the "Watch Variables" panel.
 - Added "Word Wrap" command to Edit menu for scripts.
 - General panel look enhancements.
 - Support built-in Base Color Themes that have the custom themes applied over them.
 - Game template selection now displays template's description right in the dialog.
 - F2 is now a hotkey for editing labels in the Project Tree. "Game statistics" are now displayed by Ctrl + F2.
 - Support importing and keeping sprites as explicitly 8-bit images without converting to the game's default color depth. This lets to have chosen sprites used as 8-bit masks in a 16/32-bit game.
 - When importing room backgrounds of a different size Editor will now let user decide whether to reset, keep or rescale room masks.
 - Fixed faulty double-click on project items in case user dragged the cursor away.
 - Fixed certain errors like "not terminated string" in Dialog Scripts did not report correct Dialog and line, making it difficult to find the cause of mistake.

Compiler:
 - The new extended script compiler is available. Almost all of the new Scripting features are only supported when using the new script compiler.
 - Optimization to the bytecode generation: same scripts may now work faster at runtime.

Scripting:
 - Managed structs may have constructors. Constructor is a member function which name is identical to the struct's name, and type is "void". Constructor will be called automatically when the managed object is created with "new" command.
 - Support for having regular structs inside any structs (regular or managed); there's no nesting limit.
 - Support having managed pointers inside managed structs.
 - When declaring a pointer to managed struct you may now omit "*" sign.
 - When writing struct's function's code you may now omit "this" keyword when addressing current struct's member (variable, attribute or function).
 - Similarly you may omit struct's name when addressing a static member from within a struct's member function.
 - Extender attributes; similar to extender functions, but these define a pair of get_ and set_ functions.
 - Multi-dimensional regular arrays. They may have any positive number of dimensions.
 - Multi-dimensional dynamic arrays, also known as "jagged arrays". These are arrays of arrays, where each parent array's element has to be created separately, but may be of any independent length.
 - Regular arrays of dynamic arrays: that is a regular array where each element is a pointer to a dynamic array of the same type.
 - Dynamic arrays of regular structs.
 - Dynamic arrays now have Length pseudo-attribute used to retrieve their length.
 - Global variables may now be declared right after struct's or enum's declaration, between the closing bracket and closing semi-colon.
 - Functions now may call any other function from within same script, regardless of their order of declaration.
 - When calling a function you may specify parameter names like "name1: value, name2: value", and when doing so - pass arguments in any order.
 - Compiler can now evaluate integer or float expressions at compile time whenever result is actually constant and can be calculated at compile time.
 - "const" keyword now may be used to define compile-time "int" and "float" constants.
 - "readonly" keyword now may be used to declare non-modifiable variables (local or global) and function parameters.
 - Added "fallthrough" keyword, which is used to hint that switch's case does not require a break statement. This is only to clarify coder's intent and prevent compiler's warnings.
 - Support pre-increment and pre-decrement operators (++x, --x).
 - Support bitwise negation operator (~x).
 - Support addressing members of the function return values in one expression. This lets chain multiple commands including function calls, e.g. GetObject().MyVariable...and so on.
 - Two sequenced string literals ("text" "text") are now automatically concatenated.
 - Dialog Scripts dropped support for a number of obsolete commands: "run-script", "new-room", "set-speech-view", "set-globalint", "play-sound", "add-inv", "lose-inv". All of those have contemporary equivalents.

Script API:
 - Most of the deprecated API is now removed completely, except those that have no equivalent.
 - Added SCRIPT_EXT_AGS4 macro which tells whether extended script syntax is supported by the compiler. This may be used to know whether the script is being compiled by the old or new compiler.
 - Added SCRIPT_EXT_NESTEDPOINTERS macro which tells whether nested managed structs are supported by the compiler.
 - Added Joystick struct, meant to work with joystics and gamepads in script.
 - Added VideoPlayer struct, which provides means of playing non-blocking videos rendered onto a sprite that may be displayed on any game object.
 - Added WalkableArea and Walkbehind structs which let work with these region types in OO-style.
 - Added Pathfinder struct, which lets to search walkable paths in certain two-dimensional "space", and returns them as an array of Points.
 - Added MaskPathfinder struct, which lets to initialize a Pathfinder using a 8-bit sprite serving as a navigation mask.
 - Added Custom Properties interface to types: AudioClip, Dialog, GUI, GUIControl, Region, WalkableArea. This includes functions: GetProperty(), GetTextProperty(), SetProperty() and SetTextProperty().
 - Added BlendMode enum.
 - Added Character.Enabled and Visible properties, added Object.Enabled property, Character.on is deprecated.
 - Added Character.BlendMode, GUI.BlendMode, Object.BlendMode, Overlay.BlendMode.
 - Added Character.UseRegionTint and Object.UseRegionTint, deprecated Character.IgnoreLighting.
 - Added Camera.Rotation, Character.GraphicRotation, GUI.Rotation, Object.GraphicRotation, Overlay.Rotation.
 - Added Game.FaceDirectionRatio, Room.FaceDirectionRatio, WalkableArea.FaceDirectionRatio and Character.FaceDirectionRatio.
 - Added Character.MovePath() and WalkPath(), which makes character to move along an arbitrary list of coordinates, and Character.GetPath() that returns current character's walking path.
 - Added Object.MovePath() and Object.GetPath() functions, that work similar to Character's.
 - Added ColorFormat enum, and optional "color_format" parameter to DynamicSprite's functions: Create(), CreateFromBackground(), CreateFromDrawingSurface(), CreateFromExistingSprite() and CreateFromFile().
 - Added DrawingSurface.BlendImage() and DrawingSurface.BlendSurface() functions.
 - Added DrawingSurface.ColorDepth readonly property.
 - Added Game.RoomCount, RoomNumbers[] and RoomNames[] properties.
 - Added Game.SpriteColorDepth[] readonly indexed property.
 - Added GUI.ScaleX and ScaleY properties, GUI.SetScale() function.
 - Added GUI.GUIToScreenPoint() and GUI.ScreenToGUIPoint() functions.
 - Added Overlay.Flip property that lets to set one of the 3 standard flip styles.
 - Added Overlay.Tint(), SetLightLevel() and RemoveTint() functions, Overlay.HasTint, HasLightLevel, LightLevel, TintBlue, TintGreen, TintRed, TintSaturation, TintLuminance properties, matching Character and Object tinting functionality.
 - Added Room.Number and Name properties.
 - Added Room.PathFinder property that returns a Pathfinder object, searching paths over this room's walkable areas.
 - Added StringSplitOptions enum, String.Join(), String.Split() and String.Trim() functions.
 - Expanded String.IndexOf() with new parameters: "StringCompareStyle", "index" and "count".
 - ViewFrame.Flipped property now returns eFlipDirection instead of bool.
 - Added "walkarea[]" and "walkbehind[]" global arrays.
 - Global generated game objects (Characters, GUIs, etc), and global arrays of these objects (character[], object[], gui[], etc) are now declared as object *pointers* and arrays of pointers respectively. From the user's perspective this is a mere formality, as working with these variables and arrays will be syntactically same, but this makes it easier for the engine to handle them and objects internally.
 - Removed "hasAlphaChannel" param from DynamicSprite.Create() and CreateFromExistingSprite().
 - Removed HasAlphaChannel property from DialogOptionsRenderingInfo.
 - Removed "transparent" param from Overlay.CreateGraphical() and CreateRoomGraphical().
 - Removed Object.MergeIntoBackground() function as redundant, and complicating Object's logic.

Engine:
 - Support joystick and gamepad input.
 - Engine now supports up to 1024 simultaneously loaded scripts (was 128).
 - Implemented more accurate Character movement. The movement direction is now more precise and diagonal movement speed no longer may exceed MovementSpeed setting.
 - Ensure that Character.Speaking returns true even if character has no speech view.
 - Camera will not follow a disabled player character.
 - Animated buttons now display flipped frames correctly.
 - AudioChannel.Position and PositionMs no longer return a very large value while skipping cutscene.
 - Allow to run the game even if it has no fonts (log a warning).
 - Allow to continue running the game if any font failed to load on startup. Such font will simply not get drawn, unless replaced by a plugin, for example.
 - Overlay.X and Y properties of textual screen overlays, such as blocking speech, now treat assigned values correctly as screen coordinates and return values set by user consistently. They also return the assigned values without any offsets for textual overlays created using a TextWindow (having extra borders and padding).
 - All the area-related GetAtScreenXY functions (for Hotspot, Region, Walkbehind and WalkableArea) now return a null pointer if no room viewport is found under given coordinates.
 - GetTextHeight() no longer reduces "width" parameter by -1. This was an ancient mistake in the engine kept for many years for backwards compatibility.
 - Both blocking and non-blocking videos are buffered and played on a separate thread.
 - Added FLAC support for music, speech and sound effects.
 - Added "--print-rtti" command line option which prints script RTTI table to the log.
   (RTTI stands for "runtime type information", and is used for handling of certain advanced script features, such as nested managed structs.)

Crimson Wizard

#1
KNOWN ISSUES

[FIXED]1. Some room backgrounds may become fully transparent after the project import. Their RGB colors persist, but alpha channel becomes 0 in every pixel.
The workaround currently is either to reimport background from the original source, or to open a bg png in the Rooms dir and fill alpha channel with opaqueness (if you graphic editor allows that).



2. There are couple of functions which now have less arguments compared to the previous versions of AGS.

These functions are:
- DynamicSprite.Create and DynamicSprite.CreateFromExisting, they no longer have "has alpha" argument, as in 32-bit games all sprites are considered to have usable alpha channel now. (This is actually under question, and may change again to e.g. have an argument that defines a pixel format)
- Overlay.CreateGraphical does not have "transparent" arg, as it was useless all the way.

This is an unusual case (commonly arguments are added). This may cause script errors if you import a project or a module.

The solution for a quick fix, when you don't want to manually fix all these function calls in your game, is to create a script module on the top of the scripts list, and place helper extenders there which wrap actual function calls, like this:

Code: ags
DynamicSprite* Create(static DynamicSprite, int width, int height, bool unused)
{
    return DynamicSprite.Create(width, height);
}

static DynamicSprite* DynamicSprite.CreateFromExistingSprite(int slot, bool unused)
{
    return DynamicSprite.CreateFromExistingSprite(slot);
}

Overlay* CreateGraphical(static Overlay, int x, int y, int slot, bool unused, bool clone)
{
    return Overlay.CreateGraphical(x, y, slot, clone);
}

Overlay* CreateRoomGraphical(static Overlay, int x, int y, int slot, bool unused, bool clone)
{
    return Overlay.CreateRoomGraphical(x, y, slot, clone);
}

Eon_Star

Hi,

I tested this version. When in room editing window the background PNG was not visible (Gray Background). In the game window however it was ok. Thanks for your efforts.

eri0o


Crimson Wizard

Quote from: Eon_Star on Fri 02/06/2023 22:12:38I tested this version. When in room editing window the background PNG was not visible (Gray Background). In the game window however it was ok. Thanks for your efforts.

Hello, this is a known issue that I'm currently looking at. The background does not actually become grey, it becomes fully transparent with alpha channel = 0. It's visible in the game because the engine forces room bgs to be rendered opaque.

The workaround currently is either to reimport background from the original source, or to open a bg png in the Rooms dir and fill alpha channel with opaqueness (if you graphic editor allows that).

Eon_Star

Thank you Crimson Wizard. I think this version will be great. :-D


Eon_Star

I did dowload the fixed version. Keep up the good work and stay healthy. ;-D

Crimson Wizard

Updated to Alpha 2
(Please use download links in the first post)

Contains updates and fixes from 3.6.1 Beta 3.

Other changes:

Editor:
- Fixed room backgrounds with color depths < 32-bit (like 24-bit rgb) could display fully transparent in the Editor after project upgrade.
- (possibly) Fixed incorrect "script was modified externally" message occuring when it was not actually modified externally.

Compiler:
- Fixed `++` and `--` operators could be used wrongly as a binary op (like `a ++ b`), and compiler did not detect any error.

Engine:
- Fixed character/object scaling not working at all, because of a typo in code.

Crimson Wizard

Updated to Alpha 3
(Please use download links in the first post)

Contains updates and fixes from 3.6.1 Beta 6.

Other changes:

Common:
- Removed support for '[' as a linebreak character in text.
  Please use a standard '\n' from now on.

Editor:
- Support loading PNGs with transparent chunks as Room Masks.

Engine:
- Fixed flipped button frames displayed without transparent parts.




You might have noticed that there was not much of new additions to AGS 4 updates besides than merging 3.6.1 updates in. There are currently couple of major changes in works:
- Translation migration from classic AGS TRS format to a more widespread PO format, which should make working with translations safer, and make adding further translation features easier.
- Joystick/Gamepad script API.

I believe these two will be introduced in the next AGS 4 Alpha update.

Baguettator

Just a big congrats to all of you who are still working on this incredible free  and rich program !! I will test AGS 4.0 as soon as I can !

I have a question that could be (or not) a suggestion for AGS development : is it possible to create during runtime new buttons or GUICOntrols or things like that ? I mean : the game could manage new buttons that have not been created in the editor, but created during playing the game ?

My idea is that I'm making a "map editor" for something, so I have to place tokens (tiles, events, starting zones, objectives, characters etc...) to create a map. I can't imagine doing this another way than using GUIControls (or characters, or room objects) to represent tokens, to easily be able to manage clicks on them to delete, rotate, move etc...

The problem is that it will necessary limit the possibilities, the number of tokens "available" because I can't have infinite GUIControls. I have to create 100 GUIControls, and I can't add more than 100 tokens for a map (for example).

So, the idea would be to be able to create new Buttons in runtime. Each time I create a token, it creates a Button that could be a copy of another one (for the scripts functions attached to them for example), and then act on them (change the graphic, the orientation etc...).

Is it a limitation of AGS Engine ? Or a limitation of engines in general ? Or something like that could be possible ?

Probably my question is stupid, as I'm not an expert like you. But perhaps... :)

Also, I hope my post is at the right place, as I thought it was a "development consideration", but sorry if it's not the case, I can delete it if necessary.

Anyway, congrats for AGS workers that make it possible to have such a program !

Crimson Wizard

#11
Quote from: Baguettator on Sun 06/08/2023 08:42:21Is it a limitation of AGS Engine ? Or a limitation of engines in general ? Or something like that could be possible ?

This is the current limitation of the AGS engine. But frankly this is more of a design issue rather than a technical one. In other words, it's not too hard to create a button at runtime, it may be complicated to logically bind this with how the engine treats the objects created in the editor.
This is further complicated by AGS not supporting linking functions to events in script, which means that even if you create a button in script, you won't be able to receive click events from it.

Supporting doing this is theoretically in TODO (for a long time).

Quote from: Baguettator on Sun 06/08/2023 08:42:21My idea is that I'm making a "map editor" for something, so I have to place tokens (tiles, events, starting zones, objectives, characters etc...) to create a map. I can't imagine doing this another way than using GUIControls

For the purpose of having unknown number of objects on screen there are 3 existing options:
1. DrawingSurface. This is a traditional method. You may drawing anything, but you will have to store all the object properties in your custom structs, including their positions.
2. Overlays. They are not limited anymore since 3.6.0. The benefit of these for the map editor is probably that you don't have to script redrawing a map when moving/deleting these, and they may use fast scaling & rotation (may be not exactly important for the map editor).
3. Using a pool of objects. Will limit number of simultaneous objects on screen, so probably not the best solution for the map editor.

With the first two options you have to detect clicks yourself. How this is done depends on your use of them. If this is a "tiled" map editor that might be rather simple, since you can calculate which tile the player clicked on and proceed from that. Overall this is a big technical topic, which I won't like to cover in this forum thread.

Snarky

#12
@Baguettator, you may want to check out the ImGi module, which allows you to create GUI Controls in script (though they're not "real" Controls, but a reimplementation using Overlays). Though since what you're trying to do isn't actually to create a GUI, you may be better off just implementing what you're trying to do yourself, as CW explains.

eri0o

Hey, my ImGi module started as using Overlays but it quickly changed to be based to Drawing Surface with it's own hashed-dirty-rects system due to the limitations of Overlays at the time - like, there was no sorting of overlays at the time.

There is still one limitation that makes it rather tricky to rewrite it as hardware accelerated that is there is no clipping in an Overlay, and this makes something like scrolling a bit hard to do - like, I would need to make things hardware accelerated and selectively degenerate things as software drawn when they were clipped, which is a bit hard. If there was some hardware accelerated clipping, than it could be done easier. Alternatively, some sort of Camera system in the GUI space would also work - although much harder to manage from a scripting perspective, "clippable " overlays would be far easier.

Baguettator

Thanks for answers ! I didn't expect that it was a limitation of AGS engine, but something not too hard to update. So good news ! Even if it will take time to be achieved, I think the best thing is to wait and sometimes push the idea to ags developers :D

Thanks for the solutions and for erioo's module, it's what I thought about (I've never worked with overlays, but sounds great !). For now I'll stay with Guicontrols, as I have already implemented many things with it and it's easier to script. When Ags will be ready... I'll change :)

So, good news ! I hope to test AGS 4.0 soon !

Baguettator

EDIT : Crimson Wizard, you told that it's not complicated to create a button at runtime ? The biggest problem to link it to functions in script ? But does that mean that we could have AGS able to create buttons at runtime, and then we could interact with buttons using the "mouse_onclick" function, something like :

Code: ags
function onmouse_click ()
{
  GUIControl *g=GUIControl.GetAtScreen(mouse.x, mouse.y);
  if (g.Graphic==12)
  {
    //I know which token it is, so I do that
  }
}

It could be as simple as it, waiting for a long time if one day it could be possible to do more complex thing, attaching functions dynamically to controls by script. But if that simple case could be possible... could be great, isn't it ? :)

Crimson Wizard

#16
Quote from: Baguettator on Sun 06/08/2023 22:26:38EDIT : Crimson Wizard, you told that it's not complicated to create a button at runtime ? The biggest problem to link it to functions in script ?

That is not the first problem. There's a number of things that have to be decided and changed in the engine to make supporting this convenient. I would have to go into more detail to explain, but I do not want to do this in this forum thread.

But, besides, if the button is not bound to events, then what's the point of creating it? It's easier to create an overlay.
Overlays are simpliest graphical objects in AGS, they are fast, flexible, may exist both on GUI and Room layer, and already support more graphic effects than buttons (e.g. scaling in 3.6.0 and rotation and blend in ags 4). This actually makes them superior to buttons, at least at the moment, if you excuse the lack of an automatic reaction to clicking.

You may do almost same thing in on_mouse_click with overlays as you do with buttons, except you need to write your own GetAtScreen for them.

Baguettator

Yeah, but scripting an overlay to detect mouse clicks would be harder, isn't it ? I thought having a button is easier to detect that it's a button and I click on that, even if it doesn't have any function linked to it.

Crimson Wizard

#18
Quote from: Baguettator on Sun 06/08/2023 22:54:52Yeah, but scripting an overlay to detect mouse clicks would be harder, isn't it ?

Supposedly, but that's a typical problem, and has its solutions for a script.

EDIT:
It's also possible to add GetAtScreenXY for overlays too, I did not add that at a time because I wanted to keep its API simple, but guess it was a wrong idea.
The problem this is coupled with is that currently GetAtScreenXY works simply by iterating over all objects of the type and testing the coordinates. This will become slow with the large number of objects created, so some kind of an optimized algorithm would be prefered, like space partitioning. But same goes to anything else that would support dynamic creation.

vga256

I am beginning AGS4 testing on a game that requires the new features offered by the new data structures. Please let me know if there are specific features or functions the team would like to see tested as I work.

Although I know this is not the proper place for this - I am also among those who needs support for runtime-generated/dynamic GUIs. Scripting workarounds to emulate this (e.g. spawning dozens of empty GUI elements and then showing/hiding them at runtime) is currently extremely painful as a developer.

For the time being, GetAtScreenXY for Overlays alone would be hugely useful for projects like mine.

Crimson Wizard

#20
Yes of course, having dynamically created objects would be an important and useful functionality.
But there is a number of problems and design questions that have to be resolved first. Especially if we don't want to push another set of ugly hacks into the engine. I need to gather up the information about everything that has to be solved, and write a ticket about this.

At the moment the dynamic creation of objects is not even in the first ags4 milestone draft:
https://github.com/adventuregamestudio/ags/issues/1298

There's always something else that has to be worked on. Always more and more tasks, problems and requests stacking up, and for some reasons their numbers are not diminishing, but rising in time. From all the tasks that I've been scheduling for a period of time, I accomplish around 50%, or less, and am constantly changing plans due to urgent requests. It's going like this for years.

This project has always been lacking a proper project manager who would work on setting up priority tasks and keep team focus on them.
As well as more help, at least to deal with minor tasks.

eri0o

About dynamically created objects we need to first have either delegates (#1409) or pointer downcast (#2018), so we can pass a function/action object from script to a function/attribute that "links" the necessary interactions. Since any of these will probably be exclusive to the new compiler and ags4 is meant to have both the old and the new compiler for a while, we can't do it there until the old compiler is let go - assuming the new dynamic creation will be the only way. So I don't see this making into ags4 without big changes (possibly breaking).

About AGS dev, I honestly think a lot of the problem is lack of people, for development. See this example from scummvm, there is like 5 people doing tests and trying different code ideas to solve a problem (our old FreeType dependency due to breaking changes in font metrics). A PM would be nice, but they would have trouble scoping with the limited resources - one more senior ags dev would be ideal, as I think only CW is senior among the contributors. Unfortunately I don't know how to get more devs or make the project more approachable.

vga256

Quote from: eri0o on Wed 16/08/2023 14:27:31About dynamically created objects we need to first have either delegates (#1409) or pointer downcast (#2018), so we can pass a function/action object from script to a function/attribute that "links" the necessary interactions. Since any of these will probably be exclusive to the new compiler and ags4 is meant to have both the old and the new compiler for a while, we can't do it there until the old compiler is let go - assuming the new dynamic creation will be the only way. So I don't see this making into ags4 without big changes (possibly breaking).

Thanks for pointing out these challenges. As I'm not familiar with the compiler architecture, it helps to know this isn't a simple fix. From my perspective as a game developer, I can write "I wish AGS had..." type requests all day  :wink:

abstauber

Just a small observation while I've been tinkering around with this: AGS 3.6.1b7 is quite a bit faster.

My testgame draws almost everything directly on a room surface and is quite heavy on the scripting side. In AGS 3.6.1b7 I get around 517 FPS, whereas in AGS4a3 it's 'just' around 310 FPS. But apart from this and the 16-bit graphics issue, it appears to be pretty stable indeed.

Crimson Wizard

#24
Quote from: abstauber on Fri 25/08/2023 08:53:06My testgame draws almost everything directly on a room surface and is quite heavy on the scripting side. In AGS 3.6.1b7 I get around 517 FPS, whereas in AGS4a3 it's 'just' around 310 FPS.

This is a serious difference, and is quite unexpected. Could you send us your test game for analysis?

Also, were you using old or new script compiler? We still support both, and old one is chosen in General Settings by default when you import old game, because the new one has stricter syntax rules. But new compiler is known to produce more efficient compiled script.

It's General Settings -> Compiler -> Use extended script compiler

abstauber

The extended compiler is not too happy with all my legacy stuff going on, especially the tween module seems to need an update.
Anyhow the game starts and the difference is now a bit lower.

AGS361


AGS4

Crimson Wizard

#26
Quote from: abstauber on Fri 25/08/2023 09:59:48The extended compiler is not too happy with all my legacy stuff going on, especially the tween module seems to need an update.

I do recommend upgrading eventually, the new compiler provides much more useful syntax features, and possibly old one will be dropped at some point.

EDIT: Hm, actually, I notice that it compiles fine the project that you sent me. It prints warnings, some of them may be ignored (ones regarding default values), but others point to actual logical mistakes.

abstauber

Thanks a lot for looking into this. Updating the code of my "game" for AGS4 is actually a great idea - and it's a good opportunity to get familiar with it once again.

Crimson Wizard

#28
Updated to Alpha 4
(Please use download links in the first post)

This is AGS 4.0 Early Alpha 4.

Contains updates and fixes from 3.6.1 Beta 7 and 8.

Other changes:

Editor:
- Translation sources are now saved in PO format.
- Fixed room data xml was saved without linebreaks and indentation.
- Fixed all room images (backgrounds, masks) were rewritten on disk each time a room is saved, even if they are not modified.

Compiler:
- Fixed forward-declared but unresolved function not reported correctly.
- Fixed accessing dynamic arrays with a numeric literal index was not tested for "out of bounds" mistake.
- Fixed multidimensional array index delimiters (",") were confused with function parameter delimiters in call to a function.

Script API:
- Added Joystick struct, meant to work with joystics and gamepads in script.

Engine:
- Support joystick and gamepad input.
- Fixed DynamicSprite.CreateFromSaveGame producing invisible screenshot sprites.
- Fixed an attempt to read screenshot from a save with no screenshot could cause engine to crash.
- Fixed 16-bit sprites in 32-bit games turning completely transparent.



WARNINGS:

1. SpeechCenter plugin will stop working with this AGS 4 update. It won't crash, but won't see translated strings. This is because Translation storage had changed in the Editor. The plugin will have to be updated to work with AGS 4.

2. AGSJoy plugin will not compile with AGS 4, because its Joystick struct will conflict with the AGS own Joystick struct. The solution is to either disable newest script API level (by lowering to v3.6.1, but that will also disable anything else), or adjust the code to work with the new Joystick API. The API is relatively simple, so upgrading should not be a huge problem. The plugin is no longer needed after that.

nightmarer

#29
Hello, I tried to open my project with this version and I got the following error.

https://imgur.com/vJpzMms
https://imgur.com/rJtGzU3

Error: El intervalo solicitado se extiende más allá del final de la matriz.
(This means: the interval requested is extended beyond the end of the array).
Version: AGS 3.99.107.0

System.ArgumentOutOfRangeException: El intervalo solicitado se extiende más allá del final de la matriz.
   en System.Runtime.InteropServices.Marshal.CopyToNative(Object source, Int32 startIndex, IntPtr destination, Int32 length)
   en AGS.Editor.BitmapExtensions.SetRawData(Bitmap bmp, Byte[] rawData, PixelFormat pixelFormat)
   en AGS.Editor.ObjectsEditorFilter.Paint(Graphics graphics, RoomEditorState state)
   en AGS.Editor.RoomSettingsEditor.bufferedPanel1_Paint(Object sender, PaintEventArgs e)
   en System.Windows.Forms.Control.OnPaint(PaintEventArgs e)
   en System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
   en System.Windows.Forms.Control.WmPaint(Message& m)
   en System.Windows.Forms.Control.WndProc(Message& m)
   en System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   en System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   en System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   en System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Crimson Wizard

Quote from: nightmarer on Sat 02/09/2023 16:57:02Hello, I tried to open my project with this version and I got the following error.

Please tell, does this happen all the time, in any room, or in particular room?

Crimson Wizard

Updated to Alpha 6
(Please use download links in the first post)

This is a small update, mostly to catch up with 3.6.1. Not many changes specific to AGS 4.

Contains updates and fixes from 3.6.1 Beta 9 to 12 (except ones related to backwards compatibility).

Other changes:

Common:
- Completely removed Global Messages and Room Messages.
- Removed built-in support for Game Score, including related game settings and GiveScore script command. Users are advised to script their own score counter if they need one.

Editor:
- Fixed "section" dropdown list in the script editor was getting broken by custom Color Themes.

Compiler:
- Accept constructor-like syntax (`T *o = new T();`), but skip the parentheses and do nothing, as AGS script does not really support constructors at this point. The purpose of this is to make it easier for users who have C++ or C# habits.
- Fixed "autoptr" struct's modifier required "builtin", should require only "managed".

Engine:
- Implemented more accurate Character movement. The movement direction is now more precise and diagonal movement speed no longer may exceed MovementSpeed setting.

Crimson Wizard

#32
@vga256,

Quote from: vga256 on Tue 15/08/2023 23:39:26For the time being, GetAtScreenXY for Overlays alone would be hugely useful for projects like mine.

I've been thinking about potential issues for a while, and came to a realization that this would not be useful at all, at least not in the current circumstances.

Suppose the engine will find an Overlay under cursor and give it to you, how do you tell which overlay that is?
You see, other objects have IDs, they have ScriptName property, some have custom properties, or interactions which you may run.
But Overlays do not have IDs, or anything at all to report their meaning (at least not in a direct sense), or connection with anything. What would you do with this random Overlay?

The way I see this, searching for an overlay under cursor is almost pointless, as it's nothing but a sprite on a screen. That would have more sense to search in custom script data instead, which in turn "owns" Overlay as its visual representation. Then we'd probably need an opposite kind of test: not Overlay.GetAtScreenXY() that finds some overlay under the coordinates, but Overlay.HitTest() that tells whether a particular overlay is under coordinates. But then, it may be easier and faster to test for a bounding rectangle right in script, unless your overlay is shape-transformed (rotated etc) or you need a pixel perfect test.

I suppose this requires a good forethought to investigate the use case and potential usability issues.

Besides this, ther's a number of problems regarding performance and object validation when doing GetAtScreenXY(). I'll put them under the spoiler:

Spoiler
1. Performance
The engine does not have any "magic" to spot overlays under the cursor, so it has to do some kind of a search. The most primitive method is to iterate all existing overlays and test each one's bounding box. That could work as a simple formal solution.
But given Overlays are not limited anymore, the game may have many thousands of them, and then this search will become slow. So this will not work as a general solution.

This problem may be countered by introducing object groups, where each group is limited by certain portion of the screen, and maybe even by z-order range (so x,y,z position). This would mean that the engine should be ready to move overlay between these groups whenever overlay changes its position or size.
Note: if this system is created, then this has to be done regardless of whether game script has a call to Overlay.GetAtScreenXY() ever or not at all.
Then, @eri0o has a concern that any changes to overlays update will make overlays "less fast", and he's being using them in many thousands in his games, and put an effort to make this work as fast as possible. I don't know and cannot tell beforehand how impactful such "grouping" system could be to the existing performance. But it's definite that such system has to be well designed and performance tested first.
On another hand, popular engines seem to separate objects that support hit detection and those which do not. This lets reduce number of objects that may be searched for. This may be done through type hierarchy, or components. For instance, iirc, Unity 3D requires an object to have a "collider" component in order to be detected by a hit test. Possibly only those "colliders" are involved in a object search mechanics. Is this also a way to go with Overlays in AGS, by making a distinct interactable type derived from them? i cannot tell, and this problem is also complicated by AGS being generally "clunky" when it comes to type hierarchy in script (lack of proper pointer casting, and so forth).

2. Validation
Then there's something else: engine does not know how do you use Overlays, and what for. But you do.
This means that you may have better idea on how to separate wanted and unwanted overlays for your search.
Look at this example: you are using Overlays to generate dynamic GUI controls, so you store them in arrays and describe their relations using pointers. If you are doing a click test - then first you may find out which parent GUI is under cursor, and then search in its children. This may be faster than searching all existing overlays.
If you are using overlays to create a tilemap, then you may narrow search down to a certain visible portion, or group of tiles close to coordinates, if these tiles would store pointers to overlays on top of them, for instance.
Not only your own search may be more optimal than engine's but also it may be more valid. As engine will search for any overlays at all, including standard ones like character speech, while you may want to limit the search to overlays that serve particular purpose in your game.

[close]

Exkodius

#33
Hi! I'm a long time lurker to these here forums and thought that i had to finally register to give a little heads up about a bug i found in trying out the early aplha 6 version.

In my project i work with 8-bit 256 colors. Sadly it seems that this version of the editor really does not like that, as it refuses to import my room backgrounds as anything other that 32-bit.

The new room subfolder structure is new to me so i might have missed something important. I did try to manually convert the image in the subfolder back into 256 colors and change the value of <ColorDepth>32</ColorDepth> to <ColorDepth>8</ColorDepth> in data.xml to no avail. I do get it to compile and run, but the colors are a garbled mess.

Any advice would be appriciated and a big thanks for still going strong after all these years!

Crimson Wizard

#34
Quote from: Exkodius on Mon 06/11/2023 01:52:24Hi! I'm a long time lurker to these here forums and thought that i had to finally register to give a little heads up about a bug i found in trying out the early aplha 6 version.

In my project i work with 8-bit 256 colors. Sadly it seems that this version of the editor really does not like that, as it refuses to import my room backgrounds as anything other that 32-bit.

Hello.
I guess nobody tested the new version with 8-bit games yet. I'll try this and open a bug ticket.

EDIT:
https://github.com/adventuregamestudio/ags/issues/2218

Crimson Wizard

#35
Updated to Alpha 7
(Please use download links in the first post)

Contains updates and fixes from 3.6.1 Beta 13 to 15 (except ones related to backwards compatibility).

Other changes:

Editor:
- Fixed occasional crash when scrolling the room in the editor.
- Fixed room not getting recompiled with a new content if a background or a mask was modified externally.

Scripting:
- Multi-dimensional dynamic arrays, also known as "jagged arrays". These are arrays of arrays, where each parent array's element has to be created separately, but may be of any independent length.
- Regular arrays of dynamic arrays: that is a regular array where each element is a pointer to a dynamic array of the same type.
- Dynamic arrays of regular structs.



This update contains a wonderful addition to scripting by @fernewelten : multidimensional dynamic arrays. Also known as "jagged arrays", because each sub-element may have its own length.

In these each element of all dimensions except last one is a pointer to another dynamic array, and elements of last dimension are values of the array's type. All sub-arrays must be created individually, but also may have a independent length.

First you must create the "parent" array, then you may create sub-arrays for each of its elements. Each nesting level the sub-array has one dimension less. When you create actual arrays, only the first dimension must have a fixed size, and following dimensions still have undefined size.

About like this:
Code: ags
// declare a 3-dimensional array
int dyn_arr[][][];
// create 3-dimensional array of size 10
dyn_arr = new int[10][][];
// for the 5th element of the first dimension,
// create a 2-dimensional array of size 20
dyn_arr[5] = new int[20][];
// for the 6th element of the first dimension,
// create a 2-dimensional array of size 25
dyn_arr[6] = new int[25][];
// for the 15th element of the 5th element,
// create a 1-dimensional array of size 40
dyn_arr[5][15] = new int[40];
// finally we may access the actual integer values
dyn_arr[5][15][35] = 100;


Regular arrays of dynamic arrays are also supported, and also may be of any number of dimensions. For instance, you could have this "mixed" array:
Code: ags
int overcomplicated_array[10][20][][];

Here first upper dimensions are fixed in script memory, and the two last ones are dynamic.

Code: ags
overcomplicated_array[5][15] = new int[100][];
overcomplicated_array[5][15][50] = new int[200];

Rulaman

#36
After a short Test with the AGS4 alpha 7 version I found some problems.

The conversion (from AGS 3.6.12 beta 13) was ok, but the crm files did not get deleted. (I expected this)

And I could not display any rooms objects

QuoteError: Der angeforderte Bereich geht über das Arrayende hinaus. <- Index out of bound
Version: AGS 4.00.00.02

System.ArgumentOutOfRangeException: Der angeforderte Bereich geht über das Arrayende hinaus.
 bei System.Runtime.InteropServices.Marshal.CopyToNative(Object source, Int32 startIndex, IntPtr destination, Int32 length)
 bei AGS.Editor.BitmapExtensions.SetRawData(Bitmap bmp, Byte[] rawData, PixelFormat pixelFormat)
 bei AGS.Editor.BitmapExtensions.SetRawData(Bitmap bmp, Byte[] rawData)
 bei AGS.Editor.ObjectsEditorFilter.Paint(Graphics graphics, RoomEditorState state)
 bei AGS.Editor.RoomSettingsEditor.bufferedPanel1_Paint(Object sender, PaintEventArgs e)
 bei System.Windows.Forms.Control.OnPaint(PaintEventArgs e)
 bei System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
 bei System.Windows.Forms.Control.WmPaint(Message& m)
 bei System.Windows.Forms.Control.WndProc(Message& m)
 bei System.Windows.Forms.ScrollableControl.WndProc(Message& m)
 bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
 bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
 bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


I debugged the error to the following function

Quotepublic static void SetRawData(this Bitmap bmp, byte[] rawData, PixelFormat pixelFormat)
{
    BitmapData data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, pixelFormat);
    int pixelCount = Math.Abs(data.Stride) * data.Height;
    Marshal.Copy(rawData, 0, data.Scan0, pixelCount);
    bmp.UnlockBits(data);
}

The bitmap size is 14x20
the pixelCount 1120
and the rawdata length is 560

I think there is some problem with the conversion.

When I get back in the callstack, i get the sprite info which is Format16bppRgb565
but this will be put over a Format32bppArgb image.

Quoteusing (Bitmap sprite = Factory.NativeProxy.GetBitmapForSprite(obj.Image))
using (Bitmap sprite32bppAlpha = new Bitmap(sprite.Width, sprite.Height, PixelFormat.Format32bppArgb))
{
    sprite32bppAlpha.SetRawData(sprite.GetRawData());
    graphics.DrawImage(sprite32bppAlpha, xpos, ypos, spriteSize.Width, spriteSize.Height);
}


Code: ags
The code tags looks very ugly.

Rulaman
Zak: Komm mit mir Sushi.
Zak: Come with me Sushi.

Crimson Wizard

#37
Quote from: Rulaman on Tue 02/01/2024 19:57:57The conversion (from AGS 3.6.12 beta 13) was ok, but the crm files did not get deleted. (I expected this)

The crm files are still used in a compiled game, but they are strictly output files now. They are updated when you do Build game and put inside game data. On another hand, when the game is run from editor in "Test run" mode, the game files are not packed and engine reads these files directly from disk. This makes game test launch faster. They are never deleted for the same reason: to make things faster if you re-run test game repeatedly.
This may be a good idea to move these into some "intermediate output" folder though, so to not confuse people.

Quote from: Rulaman on Tue 02/01/2024 19:57:57And I could not display any rooms objects

<...>

I think there is some problem with the conversion.

When I get back in the callstack, i get the sprite info which is Format16bppRgb565
but this will be put over a Format32bppArgb image.

Quoteusing (Bitmap sprite = Factory.NativeProxy.GetBitmapForSprite(obj.Image))
using (Bitmap sprite32bppAlpha = new Bitmap(sprite.Width, sprite.Height, PixelFormat.Format32bppArgb))
{
    sprite32bppAlpha.SetRawData(sprite.GetRawData());
    graphics.DrawImage(sprite32bppAlpha, xpos, ypos, spriteSize.Width, spriteSize.Height);
}

So your object sprite is 16-bit but it tries to interpret its pixel data as 32-bit? I will test this myself too and open a bug ticket.


Quote from: Rulaman on Tue 02/01/2024 19:57:57
Code: ags
The code tags looks very ugly.

If you have problems with these please mention this in "Site & Forum Reports", the forum and website is not something that AGS developers are responsible for:
https://www.adventuregamestudio.co.uk/forums/site-forum-reports/

Kastchey

Not sure if this is intended, but DialogOptionsRenderingInfo seems to have lost .HasAlphaChannel property in 4.0.

AGS 3.6:


AGS 4.0:

Crimson Wizard

#39
Quote from: Kastchey on Mon 29/01/2024 20:28:32Not sure if this is intended, but DialogOptionsRenderingInfo seems to have lost .HasAlphaChannel property in 4.0.

Yes, it's been cut out, as well as from DynamicSprite and DrawingSurface.
In AGS 4.0 we decided that all 32-bit sprites and surfaces assume valid alpha-channel, because having this property complicated the engine behavior.

This is mentioned in the changelog in the first post.
Quote- Removed "hasAlphaChannel" param from DynamicSprite.Create() and CreateFromExistingSprite().
- Removed HasAlphaChannel property from DialogOptionsRenderingInfo.


EDIT:
I must clarify, the normal transparent color also works, both when importing a sprite, or when drawing with COLOR_TRANSPARENT in script, because it has alpha 0. In the future we plan to support full RGBA color definition in color properties and script drawing.

Kastchey

Ah I see, sorry I missed that in the changelog then. I was looking at the help files within the editor which still list the property as included.

Crimson Wizard

Quote from: Kastchey on Tue 30/01/2024 11:32:22Ah I see, sorry I missed that in the changelog then. I was looking at the help files within the editor which still list the property as included.

Unfortunately, we do not have a proper manual for 4.0 yet. No one have bothered to write articles about new features yet, and also our manual source currently has a problem that it's somewhat inconvenient to have version branches. Hopefully this will be resolved.

Kastchey


Crimson Wizard

#43
Updated to Alpha 8
(Please use download links in the first post)

Contains updates and fixes from 3.6.1 Beta 16 to RC5 (except ones related to backwards compatibility).

Other changes:

Editor:
- Added Enabled and Visible properties to Characters, Enabled property to Room Objects.
- Added FaceDirectionRatio property to General Settings, Room and Walkable Areas.

Script API:
- Added WalkableArea and Walkbehind structs which let work with these region types in OO-style.
- Added Character.Enabled and Visible properties, added Object.Enabled property, Character.on is deprecated.
- Added Game.FaceDirectionRatio, Room.FaceDirectionRatio, WalkableArea.FaceDirectionRatio and Character.FaceDirectionRatio.
- Added File.Rename().
- ListBox.FillSaveGameList(), RestoreGameDialog() and SaveGameDialog() now let define a range of save slots for display.
- Added MoveSaveSlot() which renames a savegame.
- Added "walkarea[]" and "walkbehind[]" global arrays.
- Global arrays of game objects (Characters, GUIs, etc) are now declared as arrays of object *pointers*. From the user's perspective this is a mere formality, as working with these arrays will be syntactically same, but this makes it easier for the engine to handle these arrays and objects internally.
- Removed Object.MergeIntoBackground() function as redundant, and complicating Object's logic.

Engine:
- AudioChannel.Position and PositionMs no longer return a very large value while skipping cutscene.
- DeleteSaveSlot() no longer causes highest save to be renamed to fill a gap in saves.







The new WalkableArea and Walkbehind structs are declared as:
Code: ags
builtin managed struct WalkableArea {
  /// Gets the walkable area at the specified position on the screen.
  import static WalkableArea* GetAtScreenXY(int x, int y);
  /// Returns the walkable area at the specified position within this room.
  import static WalkableArea* GetAtRoomXY(int x, int y);
  /// Gets the drawing surface for the 8-bit walkable mask
  import static DrawingSurface* GetDrawingSurface();
  /// Changes this walkable area's scaling level.
  import void SetScaling(int min, int max);
  /// Gets the ID number for this area.
  import readonly attribute int ID;
  /// Gets/sets whether this walkable area is enabled.
  import attribute bool Enabled;
  /// Gets this walkable area's minimal scaling level.
  import readonly attribute int ScalingMin;
  /// Gets this walkable area's maximal scaling level.
  import readonly attribute int ScalingMax;
  /// Gets/sets the optional y/x ratio of character's facing directions, determining directional loop selection for each Character while on this area.
  import static attribute float FaceDirectionRatio;
};

builtin managed struct Walkbehind {
  /// Gets the walk-behind at the specified position on the screen.
  import static Walkbehind* GetAtScreenXY(int x, int y);
  /// Returns the walk-behind at the specified position within this room.
  import static Walkbehind* GetAtRoomXY(int x, int y);
  /// Gets the drawing surface for the 8-bit walk-behind mask
  import static DrawingSurface* GetDrawingSurface();
  /// Gets the ID number for this walk-behind.
  import readonly attribute int ID;
  /// Gets/sets this walk-behind's baseline.
  import attribute int Baseline;
};

They are accessible from new global arrays:
Code: ags
WalkableArea *walkarea[AGS_MAX_WALKABLE_AREAS];
Walkbehind *walkbehind[AGS_MAX_WALKBEHINDS];

For example:
Code: ags
walkarea[0].Enabled = false;
walkbehind[4].Baseline = 200;

eri0o

Hey, on GitHub the release name has a typo, it should be "v4.0.0.3 (AGS 4.0 Early Alpha 8)". :)

Crimson Wizard

Updated to Alpha 9
(Please use download links in the first post)

Contains updates and fixes from 3.6.1 Beta RC6 (except ones related to backwards compatibility).

Other changes:

Editor:
- Fixed 8-bit images imported and converted for a 32-bit game to not get their colors clamped to a low-precision palette.
- Fixed 8-bit rooms not being usable in the new Editor version (regression in AGS 4).
NOTE: 8-bit backgrounds are still not working fully correct in this version, new imported bgs do not have their palette remapped.

Script API:
- Added VideoPlayer struct, which provides means of playing non-blocking videos rendered onto a sprite that may be displayed on any game object.

Engine:
- Camera will not follow a disabled player character.
- Fixed error occuring when trying to make a screenshot while running Direct3D renderer (regression in AGS 4).
- Fixed sprites leaving traces on background while running Software renderer (regression in AGS 4).







The new VideoPlayer struct is declared as:
Code: ags
builtin managed struct VideoPlayer {
  import static VideoPlayer* Open(const string filename, bool autoPlay=true, RepeatStyle=eOnce);
  /// Starts or resumes the playback.
  import void Play();
  /// Pauses the playback.
  import void Pause();
  /// Advances video by 1 frame, may be called when the video is paused.
  import void NextFrame();
  /// Changes playback to continue from the specified frame; returns new position or -1 on error.
  import int  SeekFrame(int frame);
  /// Changes playback to continue from the specified position in milliseconds; returns new position or -1 on error.
  import int  SeekMs(int position);
  /// Stops the video completely.
  import void Stop();

  /// Gets current frame index.
  import readonly attribute int Frame;
  /// Gets total number of frames in this video.
  import readonly attribute int FrameCount;
  /// Gets this video's framerate (number of frames per second).
  import readonly attribute float FrameRate;
  /// Gets the number of sprite this video renders to.
  import readonly attribute int Graphic;
  /// The length of the currently playing video, in milliseconds.
  import readonly attribute int LengthMs;
  /// Gets/sets whether the video should loop.
  import attribute bool Looping;
  /// The current playback position, in milliseconds.
  import readonly attribute int PositionMs;
  /// The speed of playing (1.0 is default).
  import attribute float Speed;
  /// Gets the current playback state (playing, paused, etc).
  import readonly attribute PlaybackState State;
  /// The volume of this video's sound, from 0 to 100.
  import attribute int Volume;
};


The idea is that you create a VideoPlayer object, and then use its Graphic property to assign the video frame to something, like room object, or Overlay.
NOTE: scaling video is done by scaling an object: for example, you may play a 320x180 video in a 1920x1080 game by assigning to an Overlay and changing Overlay's Width and Height - that's the simplest and fastest (performance-wise) method for stretching video in game so far.

After that you may control the video playback any way you like: start it, stop it, pause and resume, change speed and audio volume.
WARNING: proper Seek is currently not implemented, but Seek(0) works, rewinding the video back to beginning.

Video's FPS is completely disconnected from the game's FPS. Videos are played as a background "process", and their state and displayed frame is synchronized with the game once per game's update. If video's FPS is lower than the game, that would simply mean that the game may display same frame during 2 or more updates. If video's FPS is higher than the game, that would result in frame skipping, because some frames will be replaced faster than the game can display them.

On another hand, you may choose to open VideoPlayer in a non-automatic mode, by passing "autoPlay = false". Then you may use NextFrame() function to advance a frame manually, according to your own rules. There's an important nuance: video's audio track is not played with NextFrame(), but only when the video is played automatically.

Multiple simultaneous video playbacks are supported, but keep in mind that decoding and preparing a frame on screen takes time, so more videos you play in parallel, the more performance hit will be.
In general, following are the factors that slow things down:
- Number of simultaneous video playbacks;
- Video's resolution (but scaling video frame using game object is fast!);
- Video's FPS: the higher FPS the more often the frame has to be decoded and updated, increasing amount of work.


Example:
Code: ags
VideoPlayer *MyVideo;
Overlay *VideoOver;

function ButtonPlay_OnClick(GUIControl *control, MouseButton button)
{
    MyVideo = VideoPlayer.Open("video.ogv", true, eRepeat);
    if (MyVideo)
    {
        VideoOver = Overlay.CreateRoomGraphical(0, 0, MyVideo.Graphic);
        VideoOver.Width = 320;
        VideoOver.Height = 200;
    }
}

function ButtonPauseResume_OnClick(GUIControl *control, MouseButton button)
{
    if (MyVideo)
    {
        if (MyVideo.State == ePlaybackOn)
            MyVideo.Pause();
        else
            MyVideo.Play();
    }
}

function ButtonStop_OnClick(GUIControl *control, MouseButton button)
{
    if (MyVideo)
    {
        MyVideo = null;
        VideoOver = null;
    }
}

function ButtonSlower_OnClick(GUIControl *control, MouseButton button)
{
    if (MyVideo)
    {
        MyVideo.Speed = 0.5;
    }
}

function ButtonNormal_OnClick(GUIControl *control, MouseButton button)
{
    if (MyVideo)
    {
        MyVideo.Speed = 1.0;
    }
}

function ButtonFaster_OnClick(GUIControl *control, MouseButton button)
{
    if (MyVideo)
    {
        MyVideo.Speed = 2.0;
    }
}

function ButtonFrame_OnClick(GUIControl *control, MouseButton button)
{
    if (MyVideo)
    {
        MyVideo.NextFrame();
    }
}

Crimson Wizard

I reposted the recent update again (see a post above), but the problem with room backgrounds in 8-bit games was not fully fixed, and will take more time to investigate and fix.

Importing existing 8-bit games in ags4 now works properly (judging by few tests), but adding new backgrounds does not work correctly yet (they look wrong at runtime).

lapsking

#47
I think I found an issue, unfortunately. It happens on all AGS 3.6. Haven't tried it on 4.0 yet.

I'm making a high resolution game 1920x1080. Khris wrote me a specific code for a new exit hotspot function: Here

It has been working well in all of the rooms. But the last room I'm working on has a glitch. The code is the same and everything. So it took me good few hours to realize glitch happens after interacting with more objects visible=true, visible=false. Is it possible the code is not working because my game is high resolution and because of more objects appearing and disappearing this issue happens? I don't know what else it can be cause otherwise the code is doing fine. That's the only thing that comes to my mind. Some memory or I don't what issue to make code work properly? Maybe I had to post this on AGS 3.6 forums though!

Edit: Sometimes if I leave the room and come back after a reload the issue is resolved. Can it be some kind of a memory overload that doesn't  let the code function properly, since the code also has something to do with storing previous function in memory and reloading it.

Crimson Wizard

Quote from: lapsking on Mon 18/03/2024 05:40:18It has been working well in all of the rooms. But the last room I'm working on has a glitch. The code is the same and everything. So it took me good few hours to realize glitch happens after interacting with more objects visible=true, visible=false. Is it possible the code is not working because my game is high resolution and because of more objects appearing and disappearing this issue happens? I don't know what else it can be cause otherwise the code is doing fine. That's the only thing that comes to my mind. Some memory or I don't what issue to make code work properly? Maybe I had to post this on AGS 3.6 forums though!

Yes, bug reports (and suspicions) are better posted in the forum thread dedicated to the version that you are using.

We'd need to see a exact code that you think is not working, the description of the room (what is present there), and what exactly happens wrong. I won't be able to answer your questions without this information.

lapsking

Sorry, Crimson.  If it does worth having a look, shall I remove this post from here and write it with more details where it was supposed to be?

Crimson Wizard

Quote from: lapsking on Mon 18/03/2024 06:17:23Sorry, Crimson.  If it does worth having a look, shall I remove this post from here and write it with more details where it was supposed to be?

There's no need to remove anything, but surely post the description of this problem with more details.

Baguettator

Hi !

I'm sorry if I missed something, but are the jagged arrays available for custom structs too ? (I mean for structs I created myself).

Crimson Wizard

#52
Quote from: Baguettator on Fri 22/03/2024 05:38:18I'm sorry if I missed something, but are the jagged arrays available for custom structs too ? (I mean for structs I created myself).

There's no such thing as "custom struct" really, any struct acts the same.
The difference in behavior are only added by struct's modifiers, these are: "managed" and "builtin".

Jagged arrays only work with "managed" structs.
EDIT: I made a mistake, apparently they work with non-managed structs too. But I would need to test this to be certain.
EDIT2: Alright, I tested, and they work with anything: simple types (like "int"), normal structs and managed structs.

Baguettator

Good news thanks Crimson !

I tried to upgrade my game with 4.0, but when I run it, it crashes and says for all my rooms "if you have deleted roomX.asc, use the Exclude From Game option". What is it intended ?

Crimson Wizard

Quote from: Baguettator on Sat 23/03/2024 09:53:58I tried to upgrade my game with 4.0, but when I run it, it crashes and says for all my rooms "if you have deleted roomX.asc, use the Exclude From Game option". What is it intended ?

No, of course that's not intended. The "if you have deleted roomX.asc" is shown when the room script file is missing.
On a side note, that message is silly and should be changed.

Did you have any errors or messages during upgrade?
Is there a new "Rooms" subfolder in your project files, and what does it have inside?

Baguettator

I can't look at the project now, but during the upgrade, when I loaded my game into the editor 4.0, I saw a message saying "updating rooms in open format", and it seemed to work well !

Will look at the project asap.

Alan v.Drake

Depending on when it crashed, either the scripts didn't get copied over to the new room format folders, or the Editor is retrying to upgrade the old rooms to the new format and can't find the scripts because they were moved to the new folders.

- Alan

Baguettator

The game doesn't launch, so it crashes just after I click the "run" button.

Crimson Wizard

#58
Were you able to check the "Rooms" folder in your project?

Baguettator

Now, yes ! I hav a "Room" folder with all of my 17 rooms folders, and inside of each one there are "background", "walkable area", "hotspot", "regions", "walkbehind" and "data" files.

The scripts seem to be .crm files, but they are at the root of the game's folder (with othr scripts)

Crimson Wizard

Quote from: Baguettator on Sun 24/03/2024 21:27:40The scripts seem to be .crm files, but they are at the root of the game's folder (with othr scripts)

No, .crm files are compiled rooms. Room scripts must be called roomN.asc and located inside "Rooms".
From your post it seems like they are not there.

Do you have a previous version of the game backed up? Does it have roomN.asc files? If so, could you try upgrading once more from backup copy, and see if room scripts appear properly in ags4 version?

eri0o

In the Rooms directory, if I remember correctly, there is a directory with a number for each room and in each directory a XML for the room description, a script Room1.asc (or whatever is the room number)  a few PNG files for the masks and background.

The crm files in the project root are just the "built" binary rooms, and in ags4 you don't need to version them anymore because it should be possible to recover them from the source files in Rooms directory.

Edit: CW was faster. :)

Baguettator

Ahah, thanks a lot for your answers (and congrats to CW the man who answers faster than his shadow !)

I don't see any .asc file in the room folder, but there were .asc files for each of my rooms in the 3.6 version of my game. I could try to re-upgrade my game from a backup version, but it's exactly what I did before, so it should be the same result...

Perhaps I could try to copy/paste manually the .asc files from my back up directly into rooms folder in the upgraded version ?

I will try to reupgrade too and tell you if it worked (it's an other pc where I can't go often, but perhaps in the evening today)

Crimson Wizard

Quote from: Baguettator on Mon 25/03/2024 04:25:06Perhaps I could try to copy/paste manually the .asc files from my back up directly into rooms folder in the upgraded version ?

Yes, you could do that too.

Baguettator

Copy/paste the .asc files from the back up seems to work. but upgrading deletes the asc files... Could it be fixed ?

Crimson Wizard

Quote from: Baguettator on Mon 25/03/2024 08:42:08Copy/paste the .asc files from the back up seems to work. but upgrading deletes the asc files... Could it be fixed ?

I never experienced such problem when testing upgrading a project.
Which exact version of AGS 4 are you using? (this may be seen in Help->About)
Does this happen to any project you upgrade or only to a particular one?

room.asc is the only file that is moved to Rooms. *.crm files are not moved, and the rest is created anew. In theory this might mean that file copying or moving is not working for some reason. It may be worth investigating if this process is safe, in terms of checking wether copy operation is successful before removing old files.

Do you have any antivirus, or programs like Windows Defender active on your computer? If so, would it improve the situation if you disable them, or tell them to ignore your project folder before upgrading?

Alan v.Drake

#66
When I asked when it crashed, I meant the Editor, because it's possible something went wrong during upgrade and the upgraded project was never saved (you have to save manually in any case). If the project is recognized as "not upgraded" the Editor will retry again to upgrade from the CRM files, but this time there wont be the scripts, and this is how these problems arise.

We should probably force a save after an upgrade, or ask for confirmation before proceeding.

- Alan

Crimson Wizard

Quote from: Alan v.Drake on Mon 25/03/2024 11:00:06If the project is recognized as "not upgraded" the Editor will retry again to upgrade from the CRM files, but this time there wont be the scripts, and this is how these problems arise.

We should probably force a save after an upgrade, or ask for confirmation before proceeding.

I wrote a ticket about this problem in the past:
https://github.com/adventuregamestudio/ags/issues/1596

Not sure if it's the same case though, as this problem occurs only if you close the Editor without saving nor building (or running) the game after upgrade.

Baguettator

That's exactly what I did : I openned my game with AGS4.0, it converted the rooms, but I didn't save the project with AGS 4.0 the first time. So the .asc files were deleted at the second launch of AGS4.0 as Alan v.Drake just said. Sorry, it was my fault  :-[

I will try to upgrade fully my game soon, and will tell you if I encounter any bug !

Thanks a lot for helping !

Baguettator

Hey again, sorry for asking again, but will AGS 4.0 be able to manage PNG files in Dynamic Sprites ? It would be so great especially for transparent backgrounds...

Crimson Wizard

#70
Quote from: Baguettator on Thu 28/03/2024 11:58:47Hey again, sorry for asking again, but will AGS 4.0 be able to manage PNG files in Dynamic Sprites ? It would be so great especially for transparent backgrounds...

If you are referring to DynamicSprite.CreateFromFile, then I suppose it's possible to extend the supported formats, if we add a proper image-loading library to the engine (this was discussed some time ago).

But which "transparent backgrounds" are you speaking of, and why do you need dynamic sprites for these?

Baguettator

Well, using PNG files will be always easier, this way you don't need to save a BMP file in a "magic pink" background to "emulate" a transparent background. It would be a quality-of-life improvement I presume ?

EDIT : also, I'm always working with PNG files, never with BMP files. But perhaps I'm a lonely bad guy :)

Anyway, the proposal milestone of AGS 4 looks great ! Have you got any release date for a fully achieved version ?

Crimson Wizard

Quote from: Baguettator on Sun 21/04/2024 14:04:36Well, using PNG files will be always easier, this way you don't need to save a BMP file in a "magic pink" background to "emulate" a transparent background. It would be a quality-of-life improvement I presume ?

EDIT : also, I'm always working with PNG files, never with BMP files. But perhaps I'm a lonely bad guy :)

Everyone seems to be working with PNGs today, and AGS allows to import PNGs into your game.
It's just that creating dynamic sprites from image files is not a very common thing, so extending image format support for this function was never addressed.

Baguettator

Well at least for me, creating Dynamic Sprites using PNG files could be very useful :)

Crimson Wizard

It's been a while since AGS 4 alpha had an update, in the meantime there have been a 3.6.1 release with 2 patches.

I've been thinking to release a AGS 4 update right now, but there's one issue after recent changes that has to be fixed before giving this version to public use. Hopefully this may be done on this week.

Baguettator

And what's about PNG files able to be used in DynamicSprite.CreateFromExistingFile ? Will it be available for AGS 3.6.X ? Or only AGS 4 ? Or none of them ?

Congrats for all the work on AGS program :)

Crimson Wizard

Quote from: Baguettator on Thu 02/05/2024 07:28:15And what's about PNG files able to be used in DynamicSprite.CreateFromExistingFile ? Will it be available for AGS 3.6.X ? Or only AGS 4 ? Or none of them ?

I cannot tell at this moment. I was not addressing this task yet.


Crimson Wizard

#78
Updated to Alpha 10
(Please use download links in the first post)

This update does not contain any major additions, was made primarily to sync fixes with the latest 3.6.1 release.
Contains updates and fixes from 3.6.1 up to Patch 2 (except ones related to backwards compatibility).

Other changes:

Editor:
- More panes in the Editor are DPI-aware (rescale well with the system font scaling).
- Editor tabs now display icons indicating their contents (may be disabled in Editor Preferences).
- Room panel tabs now display room names.
- Support reordering folders in Project Explorer with drag & drop.
- Support importing plain script files: ash, asc or both, - besides script modules (*.scm).
- Added "Controls transparency" slider to GUI edit pane.
- Fixed few problems occuring when importing old rooms into the new editor.
- Fixed some of the new files could be left after old room upgrade in case of a failure.
- Fixed import, palette remap and compilation of 8-bit room backgrounds in 8-bit games.
- Fixed double warning message when trying to close the Editor while a game test is running.

Script API:
- Added Character.MoveStraight() complementing WalkStraight().
- Added String.Join(), String.Split() and String.Trim() functions.
- Added System.GetEngineInteger() and System.GetEngineString() for returning diagnostic information about engine's runtime state. Possible arguments are defined by EngineValueID enum.

Engine:
- Overlay.X and Y properties of textual screen overlays, such as blocking speech, now treat assigned values correctly as screen coordinates and return values set by user consistently. They also return the assigned values without any offsets for textual overlays created using a TextWindow (having extra borders and padding).
- Added "--no-plugins" command-line argument that denies loading any plugins; also added respective config option.
- Fixed taking screenshots not working properly (regression in AGS 4.0).



The two new functions System.GetEngineInteger(EngineValueID value, int index = 0) and System.GetEngineString(EngineValueID value, int index = 0) may now be used to get some values that describe engine's state, rather than game's state.
Here's the list of currently supported parameters:

Code: ags
// Engine value constant name pattern:
// ENGINE_VALUE_<I,II,S,SI>_NAME, where
//   I - integer, II - indexed integer, S - string, SI - indexed string.

  ENGINE_VALUE_UNDEFINED = 0,              // formality...
  ENGINE_VALUE_SI_VALUENAME,             // get engine value's own name, by its index
  ENGINE_VALUE_S_ENGINE_NAME,          //
  ENGINE_VALUE_S_ENGINE_VERSION,    // N.N.N.N (with an optional custom tag)
  ENGINE_VALUE_S_ENGINE_VERSION_FULL,    // full, with bitness, endianess and any tag list
  ENGINE_VALUE_S_DISPLAY_MODE_STR, // string contains display mode information ( width x height x color depth, etc)
  ENGINE_VALUE_S_GFXRENDERER,
  ENGINE_VALUE_S_GFXFILTER,
  ENGINE_VALUE_I_SPRCACHE_MAXNORMAL,  // user-defined sprite cache size limit
  ENGINE_VALUE_I_SPRCACHE_NORMAL,        // current sprite cache size
  ENGINE_VALUE_I_SPRCACHE_LOCKED,       // size of "locked" sprites (prevented from disposal)
  ENGINE_VALUE_I_SPRCACHE_EXTERNAL,   // size of "external" sprites not automatically disposed (basically - DynamicSprites)
  ENGINE_VALUE_I_TEXCACHE_MAXNORMAL,  // user-defined texture cache size limit
  ENGINE_VALUE_I_TEXCACHE_NORMAL,    // current texture cache size
  ENGINE_VALUE_I_FPS_MAX,     // max allowed FPS (set as GameSpeed, or with --fps command line arg)
  ENGINE_VALUE_I_FPS,    // actual average FPS
  ENGINE_VALUE_LAST                      // in case user wants to iterate them

Example of use:

Code: ags
function repeatedly_execute_always()
{
    int current = System.GetEngineInteger(ENGINE_VALUE_I_SPRCACHE_NORMAL);
    int max = System.GetEngineInteger(ENGINE_VALUE_I_SPRCACHE_MAXNORMAL);
    lblSpriteCacheLoad.Text = String.Format("Sprites: %d / %d KB (%d%%)",
           current, max, current * 100 / max);
}

eri0o

I think the tabs icons depends on it being enabled in the Editor preferences and I think it defaults on not being enabled - not sure on this last part.

Crimson Wizard

Quote from: eri0o on Mon 06/05/2024 19:15:27I think the tabs icons depends on it being enabled in the Editor preferences and I think it defaults on not being enabled - not sure on this last part.

I did not know that, this is bad, it should be on by default. Otherwise nobody will know it's there.

Crimson Wizard

Ah, I rushed this release, and forgot to review all post-3.6.1 changes, like System.GetEngineString. They are also merged into AGS 4 now.
I must gather these and add to the changelog too.

eri0o

The support for moving folders in the project explorer by click and drag and adding a script and header pair too should be there. I think the name of the room itself too being readable in the editor tab - instead of only Room1.


Baguettator

Hi here !

I don't know if it has been already asked for a request, but is it doable in AGS to add the possibility to rotate/rescale dynamically (when game is launched) GUIs and/or GUIControls ? It would be so great... :)

But I don't know if it is too many work  or if it is doable for now...

Crimson Wizard

#85
Quote from: Baguettator on Fri 10/05/2024 20:53:34I don't know if it has been already asked for a request, but is it doable in AGS to add the possibility to rotate/rescale dynamically (when game is launched) GUIs and/or GUIControls ? It would be so great... :)

In AGS 4 it is possible to rotate GUI and almost anything else (Objects, Characters, Camera...) using Rotation or GraphicRotation property (varies depending on type of object).
There's no command to scale gui, but it's not too difficult to add. In the current state of AGS 4 it's mostly a matter of inventing a good way to set this parameter.

I might try adding this in the next update.

eri0o

I had made a issue for GUI Scaling here: https://github.com/adventuregamestudio/ags/issues/1656

I think it may be nice to have different width height for scaling - just thinking about when someone sets a different game resolution, instead of doing whatever is done today with the GUIs if the person clicks yes, it would just scale it - which feels less "destructive".

Crimson Wizard

#87
Hm, I did not remember there's a suggestion ticket.

We have reserved transformation fields for "scalex", "scaley" in save format for almost all types of objects now, and iirc the discussed API was to have properties ScaleX, ScaleY; and something convenient to set uniform scaling, like a SetScale(x,y) function, where "y" arg is optional, and if not passed, then it is set equal to "x".

Both scaling and rotation are done using fast texture transformation (with renderers that support that), and will likewise be affected by the "Render sprites at screen resolution" setting.

Baguettator

Good news !!! Thanks a lot, I'm waiting this feature :)

Crimson Wizard

Made a draft PR: https://github.com/adventuregamestudio/ags/pull/2426
Test build may be downloaded here and played with:
https://cirrus-ci.com/task/5935527583547392

Added GUI.ScaleX, GUI.ScaleY and GUI.SetScale(x,y).

The transformation mechanism is already in place, so this was a matter of inventing commands and "wiring" script to internal parameters.

Allows both positive and negative scaling; negative scaling leads to a mirrored image.
Scaling "0" is forbidden, passing "0" to any scale value will reset it to 1.0. If this seems inconvenient, I may allow it, but some fixes will have to be made around the code... Of course scale 0 means that object is not drawn.

When scaled, GUI's image shifts relative to its origin, which is top-left corner. If you want to scale "centered", you must adjust X,Y position along in script. This is perfectly consistent with other types of objects, each type has its own "origin".


Baguettator

Nice, I will have a look at it !

How coordinates work while scaling ? If a button is at coordinates (10, 50) in its GUI which has width=200 and height =200, and you scale the GUI at (100, 100), what will be the new coordinates of that button ? Screen-related ? GUI-related ?

Crimson Wizard

#91
Quote from: Baguettator on Sat 11/05/2024 19:52:31How coordinates work while scaling ? If a button is at coordinates (10, 50) in its GUI which has width=200 and height =200, and you scale the GUI at (100, 100), what will be the new coordinates of that button ? Screen-related ? GUI-related ?

Control's coordinate properties (Button.X,Y) are unchanged, and related to non-transformed GUI.

Real position on screen changes along with GUI scaling and rotation.
Because GUI's origin is at 0,0, the real controls positions may be calculated by multiplying every control's coordinate by the scale value.
(Rotation is more complicated)

EDIT: we have Screen.RoomToScreenPoint/ScreenToRoomPoint functions because Cameras may be scaled and rotated.
I suppose we might need something similar for GUIs, in case user wants to find out real control's location in script.

EDIT2: I found a curious bug, apparently InventoryWindow does not respect transformation when being interacted with.
It is drawn correctly, but detected item positions are wrong.

Crimson Wizard

#92
An updated variant:
PR: https://github.com/adventuregamestudio/ags/pull/2426
Download:
https://cirrus-ci.com/task/6618591464783872
https://cirrus-ci.com/task/5727916917522432

Adds properties and functions:
* GUI.ScaleX,
* GUI.ScaleY,
* GUI.SetScale(x,y),
* GUI.GUIToScreenPoint(int guix, int guiy, bool clipToGUI),
* GUI.ScreenToGUIPoint(int screenx, int screeny, bool clipToGUI)

Fixed InventoryWindow interaction in case of scaled/rotated GUI.

UPDATE 2: fixed to allow scaling value 0, which is useful in case of tweening between positive and negative scale.

Baguettator

Hi there !

In AGS 3.6.1.24, it seems that \n symbols are not properly drawn with the DrawString function. It displays a square with a cross inside, and it doesn't do a linebreak.

Is it intended ?

(I put it here in case it's a bug, it could be also for AGS 4.0)

eri0o

I think only DrawStringWrapped support line breaks.

Baguettator

OK, so it's probably intended. Understood :)

Another question : it's said that AGS 4.0 will rework the translation system. Could somebody explain how it will work then ? How we can manage translations for both creators and translators ? In and out of the editor ? A program to help translators ? (better HUD that only a .txt file with 1 line for native language and 1 line for translation)

Alan v.Drake

Quote from: Baguettator on Sun 26/05/2024 13:24:58Another question : it's said that AGS 4.0 will rework the translation system. Could somebody explain how it will work then ? How we can manage translations for both creators and translators ? In and out of the editor ? A program to help translators ? (better HUD that only a .txt file with 1 line for native language and 1 line for translation)

I already implemented the PO format which is an industry standard (you can manage it from Poedit and other major translation platforms).
What's missing is adding the secondary metadata features like source line references/context/comments, then possibly implementing native .mo compiled translations.


- Alan

Crimson Wizard

Updated to Alpha 11
(Please use download links in the first post)

This update comes with several important new features (see below).

Contains updates and fixes from 3.6.1 Patch 3 (except ones related to backwards compatibility).

Other changes:

Editor:
- Added "Watch Variables" panel which lets to watch values of the selected script variables while running the game. This feature is working only if game is built in Debug mode.
- Support importing 1-bit (monochrome) and 4-bit images as sprites, room backgrounds and masks (converted to 8-bit).
- Ensure that Editor exports room backgrounds in their actual color depth.
- Improved scrolling of drop-down lists in the Room's navigation bar: made scroll buttons larger, and support mouse wheel.
- Fixed breakpoints not working in room scripts.

Script API:
- Added Pathfinder struct, which lets to search walkable paths in certain two-dimensional "space", and returns them as an array of Points.
- Added Room.PathFinder property that returns a Pathfinder object, searching paths over this room's walkable areas.
- Added Character.MovePath() and WalkPath(), which makes character to move along an arbitrary list of coordinates, and Character.GetPath() that returns current character's walking path.
- Added Object.MovePath() and Object.GetPath() functions, that work similar to Character's.
- Added GUI.ScaleX and ScaleY properties, GUI.SetScale() function.
- Added GUI.GUIToScreenPoint() and GUI.ScreenToGUIPoint() functions.
- Added Speech.SpeakingCharacter that returns currently speaking character (for blocking speech).

Engine:
- Ensure that Character.Speaking returns true even if character has no speech view.
- DynamicSprite.CreateFromFile() may now load 1-bit and 4-bit bitmaps, converting to 8-bit.
- Fixed VideoPlayer's looping mode not working.

Engine Plugin API:
- Added IAGSEngine.Log(), which lets plugins to print using engine's log system.



"Watch Variables" panel is a long waited method for reading the values of the script variables when running the game from Editor. It may be toggled in the Windows menu. Users may add variable names to it, and whenever game hits a breakpoint these variable values will be retrieved and updated.
NOTE: this only works if the game is compiled in Debug mode.

An example of how it looks like on this screenshot:
https://i.imgur.com/D1L69LH.png



Pathfinding API lets you to find paths using internal AGS pathfinder, and use them for your purposes.
OTOH it also lets you pass your own custom path to Character or Room Object, and make them move along one.
Paths are represented as a dynamic array of Points.

Under spoiler is a script example, which draws found path on screen overlay:
Spoiler
Code: ags
DynamicSprite *pathspr;
DynamicSprite *mask_copy;
Overlay *pathover;
Point* last_path[];

function on_mouse_click(MouseButton button)
{
	if (pathover == null)
	{
		pathspr = DynamicSprite.Create(Room.Width, Room.Height);
		pathover = Overlay.CreateRoomGraphical(0, 0, pathspr.Graphic);
	}
	
	if (mask_copy == null)
	{
		mask_copy = DynamicSprite.Create(Room.Width, Room.Height);
	}
	
	DrawingSurface *mask_copy_ds = mask_copy.GetDrawingSurface();
	DrawingSurface *mask = WalkableArea.GetDrawingSurface();
	mask_copy_ds.Clear(30);
	mask_copy_ds.DrawSurface(mask, 0, 0, 0, mask_copy_ds.Width, mask_copy_ds.Height);
	mask.Release();
	mask_copy_ds.Release();
  
	Point *goal = Screen.ScreenToRoomPoint(mouse.x, mouse.y);
	Pathfinder *finder = Room.PathFinder;
    
	player.Solid = false;
	Point *path[] = finder.FindPath(player.x, player.y, goal.x, goal.y);
	Point *trace = finder.Trace(player.x, player.y, goal.x, goal.y);
	player.Solid = true;
	
	DrawingSurface *ds = pathspr.GetDrawingSurface();
	ds.Clear(COLOR_TRANSPARENT);
	ds.DrawImage(0, 0, mask_copy.Graphic, 50);
	
	if (path != null)
	{
		for (int i = 0; i < path.Length; i++)
		{
			if (i > 0)
			{
				ds.DrawingColor = 1;
				ds.DrawLine(path[i - 1].x, path[i - 1].y, path[i].x, path[i].y);
			}
			ds.DrawingColor = 4;
			ds.DrawRectangle(path[i].x - 1, path[i].y - 1, path[i].x + 1, path[i].y + 1);
		}
	}
	
	if (trace != null)
	{
		ds.DrawingColor = 12;
		ds.DrawLine(player.x, player.y, trace.x, trace.y);
	}
	
	ds.Release();
	
	last_path = path;
}
[close]


The new MovePath and WalkPath functions have additional eRepeatStyle and eDirection parameters, which let you create a repeating walking paths for characters or objects.
Here's a trivial example of a character patrolling between 2 points:

Code: ags
Point* path[] = new Point[3];
path[0] = new Point; path[0].x = 100; path[0].y = 100;
path[1] = new Point; path[1].x = 200; path[1].y = 100;
path[2] = path[0]; // make it circular

cGuard.WalkPath(path, eNoBlock, eRepeat);

Crimson Wizard

I had to fix one bad error in the latest update, and reuploaded the version. Please download again (same links).

Crimson Wizard

In regards to the "Watch Variables", make sure that you do full game rebuild before using it, currently there are possible errors if some scripts were not recompiled in the new version.

Crimson Wizard

#100
Updated to Alpha 12
(Please use download links in the first post)

Contains updates and fixes from 3.6.1 Patch 4 (except ones related to backwards compatibility).

Other changes:

Editor:
- Improved scrolling of drop-down lists in the Room's navigation bar: made scroll buttons larger, and support mouse wheel.
- Do not delete previously built game exe from Compiled/Windows folder when testing a game from the editor.
- Added "Open Recent" submenu in the File menu.
- Sync script editor's commands in Edit menu with the context menu.
- Added "Toggle Line Comment" command to Edit menu for scripts.
- Added "Word Wrap" command to Edit menu for scripts.
- Support to import and keep sprites as explicitly 8-bit images without converting to the game's default color depth. This lets to have chosen sprites used as 8-bit masks in a 16/32-bit game.
- Added TurnWhenFacing property to Characters.
- Fixed Character.Enabled and Visible properties not written correctly when the game is built.
- Fixed an unhandled exception occuring when rebuilding rooms if any script's header is missing.

Script API:
- Added MaskPathfinder struct, which lets to initialize a Pathfinder using a 8-bit sprite serving as a navigation mask.
- Added Character.TurnWhenFacing property.
- Added ColorFormat enum, and optional "color_format" parameter to DynamicSprite's functions: Create(), CreateFromBackground(), CreateFromDrawingSurface(), CreateFromExistingSprite() and CreateFromFile().
- Added readonly DrawingSurface.ColorDepth property.
- Added readonly Game.SpriteColorDepth[] indexed property.
- Added StringSplitOptions enum, and "options" parameter to String.Split().
- Expanded `on_mouse_click` callback, now supports two more parameters: click x,y coordinates.
- Global generated game objects (Characters, GUIs, etc) are now declared as object *pointers* in script (this complements recent similar change done to arrays of game objects).
- All the area-related GetAtScreenXY functions (for Hotspot, Region, Walkbehind and WalkableArea) now return a null pointer if no room viewport is found under given coordinates.

Engine:
- GetTextHeight() no longer reduces "width" parameter by -1. This was an ancient mistake in the engine kept for many years for backwards compatibility.
- Fixed a crash occuring when debugger requested a variable's value, but script contains no "table of contents".
- Fixed Character.MovePath and WalkPath not reacting to the "path" parameter being a null pointer, and proceeding with mistakes.
- Fixed a crash in SaveScreenShot (repeating regression in AGS 4).
- Fixed WalkableArea.GetAtScreenXY and GetAtRoomXY returning "garbage" values instead of a valid WalkableArea pointer.

Snarky

Quote from: Crimson Wizard on Mon 22/07/2024 23:49:00- GetTextHeight() no longer reduces "width" parameter by -1. This was an ancient mistake in the engine kept for many years for backwards compatibility.

Do you mean GetTextWidth()?

Crimson Wizard

#102
Quote from: Snarky on Tue 23/07/2024 00:01:22Do you mean GetTextWidth()?

No, GetTextHeight had a mistake that used "width - 1" instead of "width" when splitting text up into multiple lines.
GetTextWidth worked properly.

eri0o

Uhm, there are a few other small additions in ags4 that aren't listed because they were added with intention of being in the at some point upcoming 3.6.2 but they are also in ags4 simply because ags4 gets all improvements.  8-) 

Crimson Wizard

#104
Quote from: eri0o on Tue 23/07/2024 02:20:36Uhm, there are a few other small additions in ags4 that aren't listed because they were added with intention of being in the at some point upcoming 3.6.2 but they are also in ags4 simply because ags4 gets all improvements.  8-) 

My intent was to list these too, it looks like I forgot to add them to the update's list this time. But they are added to the full list in the first post.

EDIT: added changes from 3.6.2 dev branch.

Mehrdad

#105
Just for information. I have now tested the Android port from AGS4 and got the output. Everything works great ;-D

Thanks @eri0o   @Crimson Wizard


Edit :  If you add MAC and iOS ports to the editor I can test them.
My official site: http://www.pershaland.com/

Crimson Wizard

#106
Quote from: Mehrdad on Wed 24/07/2024 18:53:01Edit :  If you add MAC and iOS ports to the editor I can test them.

Building for iOS and Mac is not integrated in the Editor, and likely won't be for a while. But engine ports are available, just like in AGS 3.

Mehrdad

Quote from: Crimson Wizard on Mon 29/07/2024 14:18:37Building for iOS and Mac is not integrated in the Editor, and likely won't be for a while. But engine ports are available, just like in AGS 3.

I'm not a good programmer and I can't get output other than the editor. So I am waiting for you to add these two ports to AGS4.
My official site: http://www.pershaland.com/

lapsking

Hi,

 I don't know what exactly I'm talking about, but I was wondering if it's possible to have some commands to force the script into Block or NoBlock modes. I've seen others asking on the forums too, before. But you always have to work it around (which is not always easy or even possible). They also mentioned a NoBlock module which I couldn't find so I'm not sure how it works and someone mentioned it's outdated anyway. Does it make sense to integrate this into engine instead of having it as a module?

 The reason I'm asking this is because khris wrote a module which I'm using but then it stops running when the game is blocked, and you have to wait till it's unblocked which takes time. I've seen others have been asking about it too, so I gather it doesn't exist on AGS 3.6.1.

Alan v.Drake

Quote from: lapsking on Thu 01/08/2024 10:35:24Hi,

 I don't know what exactly I'm talking about, but I was wondering if it's possible to have some commands to force the script into Block or NoBlock modes. [...]

Check this page on the manual: https://adventuregamestudio.github.io/ags-manual/RepExec.html

You can use the "_always" variants for things that should always be executed.


- Alan

lapsking

@Alan v.Drake

Thanks for the fast reply. I've tried that. The problem is the code is:

Code: ags
event == eEventEnterRoomBeforeFadein

It says: undefined symbol event under repeatedly_execute_always()

So the script starts the module when the player enters the room but it keeps running as long as the player is in the room and changes the music. But if the music wants to change in the middle of a block which is a long one, stops running and doesn't change the music till it's unblocked.

Maybe I should ask in the forum how to work it around. But I thought if this happens for few others too, might be a good idea to mention it.

Alan v.Drake

That is a question for "Beginners' Technical Questions".
Here you should report and discuss issues about the engine/editor. Also try to search manual and forum for examples.


- Alan


lapsking

@Alan v.Drake

It was just a general stupid suggestion. Wasn't looking for an specific solution for my game. Another thing is the possibility to add more hotspots, for example a library with 100 books. I've already worked it around by adding books as objects one by one, but it wasn't easy. Anyway thanks, better go back to my business.

Crimson Wizard

Quote from: lapsking on Thu 01/08/2024 11:26:17Another thing is the possibility to add more hotspots, for example a library with 100 books. I've already worked it around by adding books as objects one by one, but it wasn't easy.

Hotspots amount may in theory be increased up to 255 (that's the maximum that the room masks allow).

But having 100 separate hotspots for individual books on the shelves is almost similarly suboptimal as having 100 objects for that.
It may be easier to have a single hotspot for a shelf and script a mathematical formula that gives you a book's index based on a coordinate.

lapsking

@Crimson Wizard
[/quote]
It may be easier to have a single hotspot for a shelf and script a mathematical formula that gives you a book's index based on a coordinate.
[/quote]

Thanks for your reply Crimson. The problem is I'm terrible at mathematics, unlike you guys. I'm more of a visual person and I prefer to draw hotspots by hand. That's the main reason I was attracted to AGS engine in first place, because of it's friendly interface.

By the way, I realized where I should put _always in the script! My problem is solved thanks to Alan, though that was not my intention.

Best

Crimson Wizard

Quote from: lapsking on Thu 01/08/2024 12:47:48Thanks for your reply Crimson. The problem is I'm terrible at mathematics, unlike you guys. I'm more of a visual person and I prefer to draw hotspots by hand. That's the main reason I was attracted to AGS engine in first place, because of it's friendly interface.

Well, this may be done with a "visual" method too, if you create a custom mask from a sprite. This allows to have as many "things" as there are unique colors.

But this is a topic for technical help forums.

eri0o

Just a minor trick I use for hotspot as objects , I create a few squares and rectangles in more or less standard sizes, as rectangles that I draw in black with the opacity at 1% in the drawing program, so they are practically invisible in AGS or I draw them in any color and then script them to have 99 in transparency, and then position the objects where I want in the room Editor. This allows the full rectangle to be picked even in pixel perfect mode.

I do this because when there is an object in the background that should be clickable to avoid readjusting hotspots manually later. I noticed through trial and error that on touch screen, specially in an average smartphone, a game with 320x180 resolution, needs at minimum 20x20 square or something like a 22x18 or 18x22 to be able to be reasonably clicked with the finger - for direct touch but also it allows a less precise mouse usage on indirect mode too that feels more comfortable. Using this trick of object as hotspot I can easily mass adjust the size of "background object hotspots" in my games.

lapsking

@eri0o
Quote from: eri0o on Thu 01/08/2024 13:38:14Just a minor trick I use for hotspot as objects , I create a few squares and rectangles in more or less standard sizes, as rectangles that I draw in black with the opacity at 1% in the drawing program, so they are practically invisible in AGS or I draw them in any color and then script them to have 99 in transparency, and then position the objects where I want in the room Editor. This allows the full rectangle to be picked even in pixel perfect mode.

I do this because when there is an object in the background that should be clickable to avoid readjusting hotspots manually later. I noticed through trial and error that on touch screen, specially in an average smartphone, a game with 320x180 resolution, needs at minimum 20x20 square or something like a 22x18 or 18x22 to be able to be reasonably clicked with the finger - for direct touch but also it allows a less precise mouse usage on indirect mode too that feels more comfortable. Using this trick of object as hotspot I can easily mass adjust the size of "background object hotspots" in my games.

I think I might be trashing the engine forum, so feel free to delete all these posts. But just wanted to say the books were part of the background and they were not in square or rectangular shapes, but books in different sizes in perspective some parts covered by other books. So they had random shapes. So what I had to do was to make a PNG of each of these random shapes one by one and add them as objects and put each exactly on the same spot on background. If I could directly draw the shapes on the background in engine it would be much easier. But maybe there are better ways to do this, which I need to learn.

boycalledjames

Hi, I've upgraded from 4.00.00.06 to the latest 4.00.00.07 build. However when I attempt to open the AGSEditor.exe I am greeted with the following error message:

Quote---------------------------
Error
---------------------------
An unexpected error occurred trying to start up the AGS Editor. Please consult the details below and post the error to the AGS Technical Forum.

System.ArgumentNullException: Value cannot be null.

Parameter name: path1

  at System.IO.Path.Combine(String path1, String path2)

  at AGS.Editor.Components.FileCommandsComponent.GetRecentGamesSubcommands()

  at AGS.Editor.Components.FileCommandsComponent.GetOpenRecentMenuCommand()

  at AGS.Editor.Components.FileCommandsComponent..ctor(GUIController guiController, AGSEditor agsEditor)

  at AGS.Editor.ApplicationController.CreateComponents()

  at AGS.Editor.ApplicationController..ctor()

  at AGS.Editor.Program.startupTimer_Tick(Object sender, EventArgs e)

  at System.Windows.Forms.Timer.OnTick(EventArgs e)

  at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)

  at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
---------------------------
OK 
---------------------------

I have tried both the installer and the .zip file just to be sure, but both return the same results. Any help would be greatly appreciated! Many thanks

eri0o

#119
Hi @boycalledjames !

Can I ask you to send me through private message the file in your following location:

Code: ags
C:\Users\YOURUSERNAME\AppData\Local\AGS\AGSEditor.exe_StrongName_mqpdv5kqypl2dezfmjnjxse4zvfvse2h\4.0.0.7

I don't remember right now if the random characters after the AGSEditor.exe are the same for everyone... But I would like to look into your user.config file because it will help me pick up the exact issue.

Now for it having the error, the problem is I messed up my code and didn't account for this possibility.

The cause is (I think!) that in this file, which is a xml, there is a recent game that is listed with an empty path.

Code: xml
...
<setting name="RecentGames" serializeAs="Xml">
    <value>
        <ArrayOfRecentGame xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <RecentGame>
                <Name>TestSpriteDepth</Name>
                <Path></Path>  
                <!-- this path above should not be empty! -->
            </RecentGame>
            <RecentGame>
                <Name>TestPathFinder</Name>
                <Path>C:\Users\USERNAME\Documents\AGSProjects\TestPathFinder</Path>
            </RecentGame>
            <RecentGame>
                <Name>Ags4VideoHD</Name>
                <Path>C:\Users\USERNAME\Documents\AGSProjects\Ags4VideoHD</Path>
            </RecentGame>
        </ArrayOfRecentGame>
    </value>
</setting>
...


boycalledjames

Thanks @eri0o ! That was it! ;)

So just for the sake of clarity/reporting; my user.config file had a game listed without a path as suspected. The specific text within the config file that was causing the error read;

Code: ags
<RecentGame>
<Name>Game1</Name>
</RecentGame>

Whereas all other projects had the "<Path></Path>", this one did not. Once I removed the above text from the config, the AGSEditor.exe worked as expected.

Many thanks!

eri0o

Well, nothing like real usage to find bugs, thanks @boycalledjames , turns out I didn't test for the case where (for whatever reason) the Path tag disappears. I put a PR for a fix for it that should be in future versions. I am curious how it happened in the first place so I will still play a bit with project upgrade here to see if I can figure it out.

Anyway, happy you managed to find and fix in the file as a workaround. :)

Crimson Wizard

#122
Updated to Alpha 13
(Please use download links in the first post)

This is suddenly an update with multiple new functionalities. Some of those are going to be exclusive to AGS 4, while few may be a part of the next minor 3.6.* update later.

Contains fixes from 3.6.1 Patches 5 and 6 (except ones related to backwards compatibility).

Other changes:

Common:
- Support true 32-bit colors in GUI, text messages and drawing commands in script. Color number properties now correspond to the encoded 32-bit RGB (R8G8B8 format). Older projects will have all Color properties upgraded by the Editor (but not colors in script!).
- Removed support for 16-bit games. Any older 16-bit project will be converted to 32-bit on import by the Editor.
SPECIAL NOTE: 8-bit games are still supported.

Editor:
- Editor will now remember certain window states: "Sprite selector" window and splitter position, splitter position in "Sprite manager".
- Copy, paste and delete commands now apply to all the selected GUI controls in GUI editor.
- Support editing group properties for selected GUI controls.
- When importing room backgrounds of a different size Editor will now let user decide whether to reset, keep or rescale room masks.
- Ensure that Editor exports room backgrounds in their actual color depth.
- Removed obsolete "Copy walkable area mask to regions" command from the Room editor.
- Merged all "***Color" and "***ColorNumber" paired properties into a single "***Color" property. This property is internally saved as a number, but is viewed and edited as RGB combination for 32-bit games, and as a palette index for 8-bit games.
- Added Custom Properties for: Audio Clips, Dialogs, GUI, GUI Controls, Regions, Walkable Areas.
- Textual GUI controls can now select "Null Font" as their font: this will prevent any text to be drawn even if one is assigned, and make it have zero size (when it matters).
- Added "/maketemplate" command-line option that tells Editor to run, make template out of the said game, and quit.
- Fixed "Flood Fill" operation on mask in the room editor for masks of sizes which are not multiples of 4.
- Fixed "Recent games" menu could throw a error if a saved Editor's config contained empty paths for any reason.
- Fixed "Make template" operation was not adding Rooms subfolder to a template.

Compiler:
- Compiler no longer requires explicit pointer declaration for imported global variables of managed types. Now they are always assumed to be pointers by default, and non-pointer imports of builtin managed types are not permitted, unless a backwards compatibility option is set.
- Fixed compiler could cause memory corruption while compiling certain expressions.
- Fixed parsing of bracketed expressions inside ternary operation ( ? : ).
- Fixed a error message reported in case of undefined symbol, now it correctly states that the symbol is undefined, instead of making a vague statement of "unexpected expression".

Script API:
- All ***Color properties and function arguments now require a 32-bit RGB number. Where Game.GetColorFromRGB() is used to create a color number, there the script should continue to work as before, but if a literal number was used in script, these must be updated by hand or wrong colors will be displayed at runtime.
- Added eNullFont constant that lets assign or pass a "null font" to any property or function parameter which expects a font's ID. This "null font" will simply make any text not drawn and have no actual measurements (size, spacing, etc).
- Added global events: eEventDialogStart, eEventDialogStop, eEventDialogRun, eEventDialogOptionsOpen, eEventDialogOptionsClose (these are handled in "on_event").
- Added Custom Properties interface to types: AudioClip, Dialog, GUI, GUIControl, Region, WalkableArea. This includes functions: GetProperty(), GetTextProperty(), SetProperty() and SetTextProperty().
- Added static Dialog.CurrentDialog property and non-static ExecutedOption and AreOptionsDisplayed properties.
- Added RenderLayer enum, and optional "layers" parameter to DynamicSprite.CreateFromScreenShot(), that tells which of the game's render layers to capture when making a screenshot.
- Added Overlay.SetPosition() and SetSize() functions for convenience.
- Added Overlay.Tint(), SetLightLevel() and RemoveTint() functions, Overlay.HasTint, HasLightLevel, LightLevel, TintBlue, TintGreen, TintRed, TintSaturation, TintLuminance properties, matching Character and Object tinting functionality.
- Expanded String.IndexOf() with new parameters: "StringCompareStyle", "index" and "count".
- Added optional "sprite" parameter to SaveGameSlot(), that lets to pass a number of an arbitrary sprite to write into this save instead of a standard "screenshot".
- Added new game-wide option OPT_SAVEGAMESCREENSHOTLAYER that lets to define which of the game's render layers will be captured when making a standard screenshot for the save game.

Engine:
- Do not alter or clamp palette for 8-bit sprites loaded into a 16/32-bit game at runtime.
- Assigning InventoryItem.Graphic will no longer reassign CursorGraphic too even if they were identical previously.
- Added new accessibility config settings in "access" section: "speechskip" and "textskip". These let player to override game's skipping style for character speech and text messages respectively.
- Fix transformed (scaled or rotated) overlays could look wrong in Software renderer.

WinSetup:
- Redesigned winsetup into a tabbed dialog.
- Added "Accessibility" settings for skipping speech and text messages.

ThreeOhFour

May I quietly add my enthusiastic praise for adding support for different blending modes in game. One of my most wanted features, I am delighted that 4.0 will support this.

Pax Animo

Heya,

Copying and pasting of labels on a GUI seems to be not working correctly, not sure what else this extends too but will update if any other problems.
Misunderstood

Crimson Wizard

Quote from: Pax Animo on Tue 24/09/2024 18:29:01Copying and pasting of labels on a GUI seems to be not working correctly, not sure what else this extends too but will update if any other problems.

Yes, copy/pasting gui controls appears broken in ags4 (it works in all other versions).

Crimson Wizard


Pax Animo

Heya, adding a new text line via *[* in strings no longer seems to work.
Misunderstood

Crimson Wizard

Quote from: Pax Animo on Sat 28/09/2024 18:44:30Heya, adding a new text line via *[* in strings no longer seems to work.

We no longer support "[" for newlines, now you should be using standard escaped sequence "\n" for this.

Crimson Wizard

#129
Updated to Alpha 14
(Please use download links in the first post)

Contains all the new features from 3.6.2 Betas 1 and 2.

Other changes:

Common:
- Fonts are split into Font Files and Fonts, where multiple Fonts may use same Font File, or not have any Font File assigned at all (for instance, if they are meant to act as placeholders and get replaced by fonts from plugin).

Editor:
- "Fonts" node in the Project Explorer now contains separate "Font Files" and "Fonts" sublists.
- Actual font files on disk are now stored in "Fonts" subfolder in the project when imported, and keep their original names (no longer renamed to "agsfntN.*").
- In General Settings replaced "Use Extended Compiler" option with "Script Compiler" option that acts as a dropdown list, with compiler names to choose from.
- Added "Source FontFile" property to Fonts, this property lets assign a Font File to the Font.
- Fixed GUI controls failing to copy/paste via Clipboard (regression in previous Alpha versions).

Engine:
- Allow to run the game even if it has no fonts (log a warning).
- Allow to continue running the game if any font failed to load on startup. Such font will simply not get drawn, unless replaced by a plugin, for example.



Fonts...

Inside the project Fonts are now split into Fonts and Font Files. They may be added and deleted separately from each other.
Font Files retain their actual names when imported, they are no longer renamed into "agsfntN" (unless you rename these files yourself, or upgrade older project where they've been called like that).




When you open a Font's properties, you may select one of the imported Font Files as this font's "Source FontFile". Multiple Fonts may select same FontFile as their source, and at the same time use different properties (size, outline, linespacing and so forth).



For extra convenience, Fonts that use same FontFile are referenced under the FontFile as well:





EDIT: I just realized that these screenshots were made before we added new icons for FontFiles... so things look a bit better in the Editor now.

ThreeOhFour

Great stuff!

Reading through some of the changes to recent versions of the editor, I notice a lot of room editing shortcuts have been added that makes it work much like image editors. Things like space + click & drag to pan, ctrl + mousewheel to zoom in and out based on cursor position. I love this! Another shortcut I use all the time in image editing programs is alt + click to colour select with the eyedropper tool. Seeing as alt + click doesn't seem to be used for anything else in here, might I add that as a feature request? It would make picking between hotspots, regions and such very quick and familiar to people used to Photoshop, Aseprite, Clip Studio Paint, etc.

Crimson Wizard

#131
There's unfortunately an annoying bug found in the latest Alpha 14 release, following an addition of "Script Module" selection for events in AGS 4.

Room scripts are stored in a different place in AGS 4, but the script module setting was not adjusted for AGS 4 situation in this feature, so ScriptModule for rooms points to a non existing file.

As a result, when you hit "..." button wanting to add a new event function, the function's name is filled into the property field, but the script is not opened and new function is not added there.

The workaround is to add such function in script by hand.

I'm currently investigating this to make a fix, and will have to release a new update soon.

EDIT: here's a temporary build with just this fix:
https://cirrus-ci.com/task/5366978280423424



Quote from: ThreeOhFour on Wed 23/10/2024 16:48:47nother shortcut I use all the time in image editing programs is alt + click to colour select with the eyedropper tool. Seeing as alt + click doesn't seem to be used for anything else in here, might I add that as a feature request? It would make picking between hotspots, regions and such very quick and familiar to people used to Photoshop, Aseprite, Clip Studio Paint, etc.

So, - make "Alt + LMB" to trigger a area selection when in corresponding mode. I suppose this may be done.

ThreeOhFour

Quote from: Crimson Wizard on Fri 01/11/2024 12:34:19So, - make "Alt + LMB" to trigger a area selection when in corresponding mode. I suppose this may be done.

Yep, if you hold down Alt while in most image editing programs the cursor will change to the eyedropper tool while the Alt key is held down, then change back to your previously selected drawing tool when you release it. This is fairly universal - from memory GIMP uses Ctrl by default instead, but everything else I know uses Alt.

Crimson Wizard

#133
Quote from: ThreeOhFour on Sat 02/11/2024 05:32:26Yep, if you hold down Alt while in most image editing programs the cursor will change to the eyedropper tool while the Alt key is held down, then change back to your previously selected drawing tool when you release it. This is fairly universal - from memory GIMP uses Ctrl by default instead, but everything else I know uses Alt.

So, I did this, but there's a silly issue I met. Whenever Alt key is released, the focus goes to the menu, as that's a standard thing in windows.
I can prevent this by marking the key event as "handled" if it's done in "Area editing" mode, but I was not sure if that would be expected, as that would on contrary prevent user from calling a menu using Alt while in certain room editing modes.

How do applications deal with this usually?

EDIT: don't know why, but appears it goes to system menu, and not to the main menu. Maybe that has to be coded separately.
Also AGS seems to have a separate glitch on its own, because as soon as you open a system menu after pressing Alt, it's moved down, causing graphical artifacts on the window panel...
EDIT2: apparently something got broken in that regard too. In 3.2.1 pressing Alt would focus the main menu, but starting with the first open source version 3.3.0 it focuses the system menu and causes the above glitch. Perhaps this got broken when AGS interface was redone with docking panels.


EDIT3: Maybe I should change this feature to using Ctrl instead. Ctrl is usually associated with selection (ctrl + click can mean "add to selection" in editors).

ThreeOhFour

I think Ctrl+click would work well too, yes! I will use this in image editors to select a layer (as opposed to a colour) which probably makes just as much sense, thematically.

Snarky

Just out of curiosity, what if anything is holding AGS 4 back from becoming the official AGS release (or at least the next RC)?

eri0o

#136
Note: what I mention below is my own opinion

At minimum we need to document everything we made. I would say the biggest thing in my mind is documentation. And updating the templates.

Perhaps there are small details since because no one tested.

Spoiler
Other than this there are small known issues that I think it's mostly about people being ok with current state of things. I think the blend modes may not work on the web due to limitations of WebGL because they would need to somehow be reimplemented using shaders (I conceptually don't know how, like how I would sample what is there to calculate the blending, it seems I need for each 2d pixel all pixels "vertically" of the things on top and bottom), I don't remember if rotation had all the click handling done but this was a thing at some point. If we ever do touch there are some issues that needs to be redone on the backend of GUIs but perhaps this can be changed without affecting things. There is also the Joystick/Gamepad stuff for skipping things, the preconfigured skippings of AGS, how one would set a button - currently you need to manually use Skip for joysticks if you want a custom config. We need to add Length to the autocomplete of arrays - this is now an issue in 3.6.2. But maybe these don't matter for a release, they sound like things that can be postponed, it all depends from people testing and giving their feedback.
[close]

Overall my feeling is more about the process of things, ags3 is magically backwards compatible to everything before, both in project and binary (the engine runtime). In ags4 the idea is to drop this, or at least drop this for things in the land before time. This impacts things, for me documentation is the hard one since so far we simply always added stuff and now suddenly I need to delete stuff, what does it means, would it be maintaining two documentation repositories for some time and forward?

Crimson Wizard

#137
Quote from: Snarky on Tue 19/11/2024 15:06:34Just out of curiosity, what if anything is holding AGS 4 back from becoming the official AGS release (or at least the next RC)?

1. My lack of confidence in planning.

2. Documentation must be updated, and before that we need to have a proper support for 2 branches of the manual (3.* and 4.* at least).

3. At least couple of planned new features, like Touch input API (joystick/gamepad api is already implemented, and touch api is the only api remaining to let users script their own controls on all types of platforms).

4. Each new major feature has to be reviewed for completeness, tested, and finished if it's not complete, like the "blend modes" that eri0o mentioned.



In regards to testing: I am fairly certain that at least several people have been using AGS 4 for a while now to make games. But I know that mostly because of the occasional conversations on Discord. If it were possible to bring more people to just experiment with the new version, or chosen features at least (if not making actual games with it), and give feedback, that might speed things up too.

WiseFrog

Are you planning to add the possibility to update games without losing saved files in this version of ags?

Crimson Wizard

#139
Quote from: WiseFrog on Tue 19/11/2024 23:06:13Are you planning to add the possibility to update games without losing saved files in this version of ags?

I'm adding this in 3.6.2 first, because I wanted to have this in a backwards compatible version as well. (Of course AGS 4 will receive it too)
The basic functionality is already done*, and currently I am working on a additional "save prescanning" feature that lets to test a save without actually loading it.

This is thoroughly explained in this thread, and links to test builds are available in posts:
https://www.adventuregamestudio.co.uk/forums/engine-development/load-older-game-saves-into-updated-game-attempt-2/

* - when I say "done", i refer to the minimal functionality. It may be expanded further (although there's a limit of what may be achieved with the existing save format). This feature still awaits its users to provide potential use cases and feedback.

ThreeOhFour

Out of curiosity, what features are you looking for feedback on? I'm using AGS 4 daily now, and am using some of the new features - but definitely not all of them. Overlay rotation and the add blend mode work perfectly. I haven't spent much time trying to rotate anything else, nor using the other blend modes, but can spend some time with them and give feedback if it's desired?

Crimson Wizard

#141
Quote from: ThreeOhFour on Tue 19/11/2024 23:39:03Out of curiosity, what features are you looking for feedback on?

Any from the list, really. Even if only just the fact that they are being used, work as expected, and if are useful or not.
It's not clear at this point which were tried by other people than the devs themselves, since there had been little mention of this.

Then, there are those that are rather straightforward, and those that are complex. The latter may be of more interest.

1. New scripting features available with the new compiler; more importantly those that require using pointers: managed structs within managed structs, connecting custom managed objects together, and such. These involve both script compiler and the engine managing "garbage collection".
2. "Watch variables" panel.
3. From new scripting commands, it would be nice to see someone trying VideoPlayer, but I understand that's rather niche thing to have in games. That will mostly be useful if someone makes one of those "FMV style" games.
4. New Joystick/gamepad interface in script. It should replace a use of joystick plugin. But this is interesting for people who make gamepad controls in their games.
5. Translations, because they are now saved in a PO format. Although the usage should still be pretty straightforward, but I am curious if they cause any kind of trouble.

Earlier I would have also mention "Room editing" because of the new rooms storage format, but you can't miss it when you edit the game, so, I suppose. this was tested more than other things.

eri0o

Another feature that would be nice to get more experimentation is the PathFinder and MaskPathFinder API along with the path movement stuff - you can pass an array of Points to things to create a path that they should move along, at least for objects and characters. I think at the time only I and CW played with it.

Snarky

Quote from: Crimson Wizard on Tue 19/11/2024 18:10:322. Documentation must be updated, and before that we need to have a proper support for 2 branches of the manual (3.* and 4.* at least).

I assume "proper support for 2 branches," means that it's not just a matter of forking the manual's Github repo, then.

Crimson Wizard

Quote from: Snarky on Wed 20/11/2024 14:09:29I assume "proper support for 2 branches," means that it's not just a matter of forking the manual's Github repo, then.

I don't know, maybe having 2 repositories is also a way, if branches don't work.

With 2 repos the wiki pages may be still being used to edit the manual (github does not support editing multiple branches through the "wiki" front).

This approach will become inconvenient if we want to have separate branch per maintained version, including minor versions. But it also may be a temporary "dirty" solution until something better comes up.

Crimson Wizard

#145
Updated to Alpha 15
(Please use download links in the first post)

Contains all the new features from 3.6.2 Betas 3.

Own changes:

Editor:
 - The "Watch Variables" panel has an option to automatically enlist local variables (relative to current position in script) when testing the game.
 - Added "Add to Watch Panel" command to Script Editor's context menu.
 - Support dragging a text from the script window into the "Watch Variables" panel.
 - Fixed mistakes occuring when overwriting existing room files by a imported room.

Scripting:
 - Managed structs may have constructors. Constructor is a member function which name is identical to the struct's name, and type is "void". Constructor will be called automatically when the managed object is created with "new" command.
 - Dialog Scripts dropped support for a number of obsolete commands: "run-script", "new-room", "set-speech-view", "set-globalint", "play-sound", "add-inv", "lose-inv". All of those have contemporary equivalents.



Using constructors is more or less how you do it in C++/C#, except it has to be declared having a type "void", as opposed to no type at all (this is kept so for simplicity of compiler's work, idk if it's critical, but maybe we could look into letting to declare it completely typeless later).

Example:
Code: ags
// header
managed struct MyStruct
{
     import void MyStruct(int data); // this is constructor
     import readonly attribute int Data;

     writeprotected int _data;
};

// script
void MyStruct::MyStruct(int data)
{
     _data = data;
}

int get_Data(this MyStruct*)
{
     return _data;
}

// elsewhere in another script
function game_start()
{
     MyStruct *s = new MyStruct(10); // this actually calls constructor
     Display("%d", s.Data); // should display 10
}


ThreeOhFour

I've been taking a look at the alternate blending modes added to AGS 4.0 and some of them seem to handle alpha channels in a way different than I expect from these modes. Normal, additive and subtractive blending modes act exactly as I expect them to, but the rest seem to have trouble processing the alpha channel correctly, with alpha seeming to be processed without any gradation, and even blending where the image is completely transparent. Here's an example:

Normal blending mode

Mutliply blending mode

I'm using build 4.00.00.09, and I've put up a copy of the sprite used in this test here.

eri0o

#148
I noticed it went unmentioned in last release notes here on the forums but there's an additional fix for the watch pane that could make the engine unresponsive if one "step into" too fast -  this made it hard to use the watch pane, but the latest 4.0.0.11 also fixed this, so now debugging is much smoother.

About the blending modes, the way they are currently implemented relies on DirectX and OpenGL own implementations, and I guess it may require some of those premultiply alpha settings.

They would be less driver dependent if we used shaders, but there is a detail here that the current use of shaders in the engine, for tint (color and lighting) and transparency, only depends on the data in the texture of the sprite itself. With blending modes the shader has to depend on the information "below", but currently, in the gfx drivers the previous drawn sprites aren't "rasterized" (or "flattened"), so it's not clear how one would get the information of the pixels below, I guess once it has to draw a sprite that has a blending effect it would need to "flatten" so that we can pass each pixel info to the shader drawing this sprite. Beyond investigating implementation there would be a need to check performance impacts, if any.

Crimson Wizard

#149
To put it simply, not all of the blend modes were implemented correctly in all graphic renderers, and this has to be looked into before the final AGS 4 release.

BTW, there's a ticket that I wrote, about "reimplementing blend modes as shaders", but I wrote it just to have a formal reminder. It is quite possible that this cannot be done with shaders alone, since, as eri0o mentioned, for blending you have to combine pixels from current texture and pixels from already drawn textures below, and shaders cannot do that on their own afaik.

ThreeOhFour

Thanks for the information! I did some tests with the different drivers and see that there's a difference there. Good to know, thank you.

yarooze

The new features of AGS4 are great! Nested objects, multi dimensional arrays, watch variables window, shiny new editor windows.. I don't know, how we lived without them.  :smiley:

Unfortunately, after I wrote some functions, the editor starts crashing from time to time without any warnings.

I click F5 or "run" button.
AGS popup "Please wait while your scripts are compiled..." appears.
Then the editor crashes and Windows popup "AGS Editor for Windows does't work anymore" appears.

This one:



The game can be compiled then, if I edit any script (adding some spaces or new lines is enough), save it and compile it again. So it seems, that I can reproduce this error and compile it correctly with the same code.  :confused:

I have some nested Object in my code (even some recursions), but it crushes on compile - not in the run time.

So my questions:
1. Is there any possibility to write some logs to find the problem?
2. Do anybody have such problem with the crushing editor?


I'm using Win10.
Code: ags
AGS Editor .NET 32-bit (Build 4.00.00.11) ** BETA VERSION **
v4.0.0, November 2024
My Blog

Snarky

I seem to recall that people have experienced similar problems (not just with AGS4) caused by their antivirus, which for some unknown reason hates AGS. You could try disabling it temporarily and see if you can build.

eri0o

Just add an exception to your own game folder to Windows Defender and it should work I think. Maybe an exception to AGS Editor too, but I don't think that is needed.

I know the JetBrains IDEs I use for c++, python and Android all require to have the work directories added to Windows Defender otherwise I get some weird behavior.

yarooze

Windows Defender is actually deactivated. Trend Micro is active but has nothing in log.
My Blog

Crimson Wizard

Quote from: yarooze on Wed 18/12/2024 14:13:58So my questions:
1. Is there any possibility to write some logs to find the problem?
2. Do anybody have such problem with the crushing editor?

There's no logging in the editor, other than compiler's errors.

You could PM us your project for a test, if this is a bug in the editor then we'll be able to see what is happening.

Crimson Wizard

#156
@yarooze I checked your project, and it has a mistake in script that is known to cause all kinds of weird issues.

This is when you have "import" keyword used in function's body, like:
Code: ags
import void HemisphereElement::HemisphereElement(int id,  Hemisphere *hemisphere)
{

}

We have this crash already fixed and the fix will be included in the next update (coming soon).
Instead compiler will report a syntax error.
But you have to fix the script anyway.

yarooze

Quote from: Crimson Wizard on Wed 18/12/2024 18:24:04This is when you have "import" keyword used in function's body, like:

Oh.. looks like "silly me".

You mean: "Import belongs to the header. Export belongs to the code. Copypasta is evil."?
My Blog

Crimson Wizard

#158
Updated to Alpha 16
(Please use download links in the first post)

Contains all the new features and fixes from 3.6.2 Beta 4 (excepts ones related to backwards compatibility).


Own changes:

Editor:
- Added Flip property to View Frame, replacing a boolean Flipped property. The new property supports all 3 flip variants: horizontal, vertical and both at once.
- Fixed certain errors like "not terminated string" in Dialog Scripts did not report correct Dialog and line, making it difficult to find the cause of mistake.

Compiler:
- Fixed function bodies mistakenly declared with "import" keyword could cause program memory corruption during compilation.

Scripting:
- When calling a function you may specify parameter names like "name1: value, name2: value", and when doing so - pass arguments in any order.

Script API:
- Added Overlay.Flip property that lets to set one of the 3 standard flip styles.
- ViewFrame.Flipped property now returns eFlipDirection instead of bool.

Engine:
- Engine now supports up to 1024 simultaneously loaded scripts (was 128).
- Fixed Type.GetByName() not working (regression since one of the previous v4.0 Alphas).
- Fixed Software renderer not handling all the Overlay transformations correctly (like rotation).



In regards to naming parameters in the function call.

When calling a function, you can pass parameters having their names explicitly specified. This may be advantageous for the clarity of code. But in the end this is a user's choice of code style.

For example:
Code: ags
import int Func(int param, float fparam, String str_param);

void CallAnother()
{
    int result = Func(param: 10, fparam: 5.7, str_param: "text");
}

There are following rules:

* A function call must have either all passed parameters named, or none named. These two syntax styles cannot be mixed in the same function call.
* If you pass parameters named, they may go in any order.
* But, in any case, non-optional parameters (ones without default value) must be passed in the function call regardless of the syntax style used.
* If you are calling a variadic function (such as String.Format), and pass fixed parameters named, then you won't be able to pass variable parameters at all (because they don't have names!).

yarooze

I've got some strange behavior with the new AGS4 build a couple of time.

As I wrote the function (actually I did some copy pasta and change some parameters), I've got an error message:

Code: ags
Error: Der Index war außerhalb des Arraybereichs.
Version: AGS 4.00.00.12

System.IndexOutOfRangeException: Der Index war außerhalb des Arraybereichs.
  bei AGS.Editor.AutoComplete.GetFunctionParametersAsVariableList(ScriptFunction func, List`1 variables)
  bei AGS.Editor.AutoComplete.GetLocalVariableDeclarations(ScriptFunction func, List`1 localStructs, String scriptToParse, Int32 relativeCharacterIndex)
  bei AGS.Editor.ScintillaWrapper.CheckFunctionForLocalVariables(Int32 currentPos, ScriptFunction func, String scriptExtract, Boolean searchWholeFunction)
  bei AGS.Editor.ScintillaWrapper.GetListOfLocalVariablesForCurrentPosition(Boolean searchWholeFunction, Int32 currentPos)
  bei AGS.Editor.ScintillaWrapper.FindLocalVariableWithName(Int32 startAtPos, String nameToFind)
  bei AGS.Editor.ScintillaWrapper.GetFinalPartOfExpression(Int32 currentPos, ScriptStruct& memberOfStruct, Boolean functionsOnly)
  bei AGS.Editor.ScintillaWrapper.CheckForAndShowEnumAutocomplete(Int32 checkAtPos)
  bei AGS.Editor.ScintillaWrapper.ShowAutoCompleteIfAppropriate(Int32 minimumLength)
  bei AGS.Editor.ScintillaWrapper.OnUpdateUI(Object sender, EventArgs e)
  bei ScintillaNET.Scintilla.OnUpdateUI(UpdateUIEventArgs e)
  bei ScintillaNET.Scintilla.WmReflectNotify(Message& m)
  bei ScintillaNET.Scintilla.WndProc(Message& m)
  bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
  bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
  bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


"Der Index war außerhalb des Arraybereichs." means "The index is out of the array boundaries"

The Editor did not crash. Simple displayed me this message a couple of time. I was able to work further.

I'm not really sure how to reproduce it. I added parameters into the existing constructor (it had no parameter and was imported into the struct in the ash file). So I wrote something like this in the asc file:

Code: ags
void SkyViewElement::SkyViewElement(SkyView *skyView, int is = 0) 

ash was like this:

Code: ags
import void SkyViewElement();

Message as screenshot:






My Blog

Crimson Wizard

This temp build should have the problem with autocomplete crashing fixed:
https://cirrus-ci.com/task/6320305364271104

yarooze

Sorry, but it's me again.

It seems for me, that the function Character.AddWaypoint doesn't work as described: https://adventuregamestudio.github.io/ags-manual/Character.html#characteraddwaypoint


If I put it into the default game, the character walks endless on the 50,145 point and sometimes the game crashes then:
Code: ags
function room_AfterFadeIn()
{
  cEgo.Walk(50, 145);
  cEgo.AddWaypoint(100, 145);
}

If I remove AddWaypoint line, then cEgo stops on the 50,145.

Am I doing something wrong?
My Blog

Crimson Wizard

Quote from: yarooze on Thu 26/12/2024 22:30:35and sometimes the game crashes then

Please tell is there any error message when it crashes?

yarooze

#163
Quote from: Crimson Wizard on Thu 26/12/2024 22:50:52
Quote from: yarooze on Thu 26/12/2024 22:30:35and sometimes the game crashes then

Please tell is there any error message when it crashes?


Looks like this:
https://get.hidrive.com/i/JNHiHwr8

then sometimes this message:

Code: ags
---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occurred in ACWIN.EXE at EIP = 0x779928CF; program pointer is +9908, engine version 4.0.0.11, gtags (0,9)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and contact the game author for support or post these details on the AGS Technical Forum.



Most versions of Windows allow you to press Ctrl+C now to copy this entire message to the clipboard for easy reporting.

An error file CrashInfo.dmp has been created. You may be asked to upload this file when reporting this problem on the AGS Forums. (code 0)
---------------------------
OK   
---------------------------

My Blog

Crimson Wizard

@yarooze there was a bug in AddWaypoint, here's a temp build with a fix:
https://cirrus-ci.com/task/5025614987526144

yarooze

Quote from: Crimson Wizard on Fri 27/12/2024 01:54:47@yarooze there was a bug in AddWaypoint, here's a temp build with a fix:
https://cirrus-ci.com/task/5025614987526144
It works. Thank you.

PlaySound("Your sound card works perfectly!");
My Blog

Crimson Wizard

Updated to Alpha 17
(Please use download links in the first post)

Contains all the new features and fixes from 3.6.2 Beta 5 (excepts ones related to backwards compatibility).


Own changes:

Editor:
- Fixed incorrect default values of GUI color properties (BackgroundColor, etc). This is a regression in 4.0 Alphas since we support full 32-bit color range values.
- Fixed default value of ListBox's SelectedBackgroundColor is being treated as "transparent", for the same reason.

Scripting:
- May omit struct's name when addressing a static member from within a struct's member function.

Script API:
- Added Game.RoomCount, RoomNumbers[] and RoomNames[] properties.
- Added Room.Number and Name properties.

Engine:
- Fixed program exception when Character.AddWaypoint() is called in script.


Baguettator

Hi,

I'm trying to test AGS 4.0 with my project developped on AGS 3.6.1.

I'm adjusting some of the deprecated functions now.

In AGS 4.0, is there a way to play MP3 files (or audio files) placed in the game's directory ? Before, I used to use the PlayMP3 function (with an old-style scripting enabled in general settings if I remember well).

Also, it doesn't seem Tween module is compatible with AGS 4.0 ?

And last question : is it normal that each time I want to launch my game, all the rooms are recompiled ? (even if I didn't change any Header script files)

Crimson Wizard

#168
Quote from: Baguettator on Thu 02/01/2025 12:43:28In AGS 4.0, is there a way to play MP3 files (or audio files) placed in the game's directory ? Before, I used to use the PlayMP3 function (with an old-style scripting enabled in general settings if I remember well).

No. We have discussed a possible replacement, but it was not done yet.

Quote from: Baguettator on Thu 02/01/2025 12:43:28Also, it doesn't seem Tween module is compatible with AGS 4.0 ?

It may require fixing some syntax mistakes.

Quote from: Baguettator on Thu 02/01/2025 12:43:28And last question : is it normal that each time I want to launch my game, all the rooms are recompiled ? (even if I didn't change any Header script files)

No, it's not normal.
But this is a known problem if you have just upgraded your project, then all rooms will be recompiled after fixing any mistake in script.
If that's the case, one way to fix this is to open Game.agf.user in a notepad and change value of "<RequiresRebuild>True</RequiresRebuild>" to "False".

Baguettator

Thanks Crimson !

I encounter a problem with the upgrade of AGS 4.0 : my game places tokens like in a tabletop game, it's gui's buttons with a dynamicsprite.CreateFromFile as visual. Sometimes it has to be rotated.

In AGS 4.0, all the sprites look "grey", like with black lines on them. And the larger sprites (supposed to be tiles, larger than tokens) are not displayed at all (only full black squares, I tested with a script that displays a text if I click on these buttons, and the text is well displayed. So the button is here, it has correct width/height, but it's full black instead of its intended picture).

https://drive.google.com/file/d/1IOlLnlPJ1-rahRnH7AoCIa-tobb5RlSe/view?usp=sharing

In AGS 3.6, everything was working perfectly...

Any idea ?

The only thing I changed by upgrading to AGS 4.0, is to remove the bool parameter in DynamicSprite.Create and DynamicSprite.CreateFromExistingFile, and these are not used for that tokens and tiles because I use sprites that are not imported in my game's editor. These images are in the Game's directory, and they are BMP files (or sometimes PNG, but on my examples they are BMP).

The buttons with the image displayed correctly in my example are buttons that have their sprite already imported in my editor's game. So they have no problem.

Baguettator

Also, another problem (or difference between AGS 3.6 and 4.0, if intended or not ?) I noticed :

In my code, I had this line :

Code: ags
String tmp_name="tmp";
File* tmp = File.Open(tmp_name, eFileWrite);

It was supposed to open (create) a file that didn't exist before, write in it, then copy its content into another file, then delete it (I think it's a bit weird to do that way, it's from a module I didn't make, but anyway...).

In AGS 3.6, no problem.

In AGS 4.0, tmp was always a null pointer.

Perhaps the File.Open command wasn't containing any tag for the path of the file ? it was just the name of the file, and I don't know if by default, if no path is indicated, AGS pointed to its game's directory.

The thing is, now in AGS 4, it's a crash, it wasn't before. I don't know if it's intended ?

Crimson Wizard

#171
Quote from: Baguettator on Thu 02/01/2025 19:30:03Perhaps the File.Open command wasn't containing any tag for the path of the file ? it was just the name of the file, and I don't know if by default, if no path is indicated, AGS pointed to its game's directory.

The thing is, now in AGS 4, it's a crash, it wasn't before. I don't know if it's intended ?

You should always insert a location token into the path. When you do not, AGS assumes "game's directory", which is forbidden for writing files.

In AGS 3 there was a backwards compatible mode, where in such case it would remap the path to "$APPDATADIR$" instead.

Initially it was supposed to work only for older games, but someone persuaded me to change it and make it work for new games too, which is a mistake in my opinion. Anyway, it seems people might be using this in 3.* versions without realizing what is going on.

AGS 4 is strict about this.

Baguettator

OK, thanks for the explanation ! It's not a problem for me, I corrected the script :)

Any idea about the sprite problem I wrote before ?

Crimson Wizard

Quote from: Baguettator on Thu 02/01/2025 15:00:41I encounter a problem with the upgrade of AGS 4.0 : my game places tokens like in a tabletop game, it's gui's buttons with a dynamicsprite.CreateFromFile as visual. Sometimes it has to be rotated.

In AGS 4.0, all the sprites look "grey", like with black lines on them. And the larger sprites (supposed to be tiles, larger than tokens) are not displayed at all (only full black squares, I tested with a script that displays a text if I click on these buttons, and the text is well displayed. So the button is here, it has correct width/height, but it's full black instead of its intended picture).

https://drive.google.com/file/d/1IOlLnlPJ1-rahRnH7AoCIa-tobb5RlSe/view?usp=sharing

Please upload an example of image, and post an example of a script command that loads this sprite into the game, so that I could test this.

Baguettator

#174
OK, here a folder with all the tokens I use. You find the tiles in the "Dalles" repertory, and the other tokens in every other directory.

https://drive.google.com/file/d/1uJiEOUisX77uaZZcMvKmSYU2k5uif5U9/view?usp=sharing

My script is very simple.

Code: ags
struct Token
{
DynamicSprite *ds;
};

Token token[50];

function CreateTokens(int id, String path, int angle)
{
  token[id].ds=DynamicSprite.CreateFromFile(path);
  if (angle>0) token[id].ds.Rotate(angle);
  gTabletop.controls[id].NormalGraphic=token[id].ds.Graphic;
  gTabletop.controls[id].Visible=true;

  // etc...
}

EDIT : it seems very strange, some sprites are displayed strangely (as I have shown in my previous screenshot), but some sprites don't appear at all, like if they were totally transparent...

Baguettator

#175
I found something annoying with the last update of AGS 4, it's that when you test the game with the editor, and the game crashes, the call stacks and the little message telling you what happenned are not displayed, you have to go to "window=>call stack" to see them, and you click "okay, close the game", the game doesn't close and the editor is stuck in debugging mod. (you can modify it, but you need Ctrl+Alt+Suppr to close it for real)

EDIT : seems to not concern every crash reason.

EDIT 2 : new problem I encounter in AGS 4. If I attach a function On_Click on a button called "Objectif", the function is by default called Objectif_OnClick. If I rename it, let say Fouille, then in the editor I click in the "..." button of on_click function in the right panel of the gui's window (with the Objectif button selected, so in this box there is the name of its onclick function, so in my case it's written Fouille), the editor creates a new function called Fouille. Previously in AGS 3.6, he knew that there was a function called Fouille, and he didn't create a new one, he jumped to the right function directly.

Crimson Wizard

Quote from: Baguettator on Fri 03/01/2025 15:17:43EDIT 2 : new problem I encounter in AGS 4. If I attach a function On_Click on a button called "Objectif", the function is by default called Objectif_OnClick. If I rename it, let say Fouille, then in the editor I click in the "..." button of on_click function in the right panel of the gui's window (with the Objectif button selected, so in this box there is the name of its onclick function, so in my case it's written Fouille), the editor creates a new function called Fouille. Previously in AGS 3.6, he knew that there was a function called Fouille, and he didn't create a new one, he jumped to the right function directly.

This may be the case with AGS 3.6.2 too (will need to test this), because this is where some additions to event creation and linking were done first.

Baguettator

Alright, thanks !

Have you looked into the sprite rendering issue ? (no pressure, just to know if you indentified at the problem)

Crimson Wizard

Quote from: Baguettator on Fri 03/01/2025 20:10:46Have you looked into the sprite rendering issue ? (no pressure, just to know if you indentified at the problem)

I did reproduce the problem, but did not have time to investigate this yet.

Baguettator

Nice, happy to know it's also for the others :D

Hope you'll be able to fix it !

I'm testing AGS 4.0 as deeply as I can with my game. I'll report if I encounter anything else !

Thanks a lot for developing the tool :)

Baguettator

#180
Crimson, sorry for double post, but here is what I can observe about the sprite problem :

it seems sprites rendering is "decreasing in quality". Because my scripts gives DynamicSprites to many buttons, I can see one of them in pretty good quality, and then, others are like less and less in quality. Until they become invisible. I can see as if the sprites were "cut" with a knife, making transparent lines on them. And they got more and more "cuts".

i'm not sure if it's important for you, but it seems the process is worser and worser, or better and better. I don't know... Hope it will help you !

EDIT : I just saw that the DynamicSprite.CreateFromFile function has a second optional parameter : colorformat. Should it be the issue ? In my game, I don't use this parameter (all of my DynamicSprite.CreateFromFile have only 1 parameter).

Baguettator

Also, not a great problem, but I noticed that if selectedBackgroundColor=0; 0; 0 for a ListBox, it makes it transparent. Before, in AGS 3.6, it was black (as intended).

(sorry for multiposts, I don't know if you are notified if I make "quick edits" in my old posts, so I create a new one, but tell me if I'm doing wrong please !)

Crimson Wizard

#182
Quote from: Baguettator on Sun 05/01/2025 09:31:57Also, not a great problem, but I noticed that if selectedBackgroundColor=0; 0; 0 for a ListBox, it makes it transparent. Before, in AGS 3.6, it was black (as intended).

This is a known problem, but I must clarify: color 0 is treated as transparent by SelectedBackgroundColor property.
The reason why "black" color worked before was that it was written in palette index other than 0 (16 to be precise), but it's not possible to do now in AGS 4, where colors in 32-bit games must be written as 32-bit RGBs.

There's no other way around this than to select slightly non-black color at the moment.

I do not know what the actual fix should be, as there's no way to select "transparent color" in these properties. Either we have to implement that somehow, or maybe there could be a separate property that sais "show or not show the selection".

Personally, I'd prefer selectable transparent color, as "selection" awhole may involve multiple things, not just the bg color, while user may want to have front color for selected items, for instance, but not bg color.

EDIT: Perhaps having 0 color be black in 32-bit would work as a quick fix. Because it's more likely that users want a bg color for selection. And if they want transparent color, they may assign the background GUI color. The only case when that won't work is if the GUI has a non-trivial background graphic...

Snarky

Quote from: Crimson Wizard on Sun 05/01/2025 10:14:43I do not know what the actual fix should be, as there's no way to select "transparent color" in these properties. Either we have to implement that somehow

Would there possibly be a need for three versions of the color picker?

- 24-bit (RGB) for colors that must be fully opaque
- 24-bit/transparent for colors that can be opaque or not drawn at all
- 32-bit (RGBA) for colors that can have alpha-transparency

Crimson Wizard

#184
Quote from: Snarky on Sun 05/01/2025 10:22:11Would there possibly be a need for three versions of the color picker?

- 24-bit (RGB) for colors that must be fully opaque
- 24-bit/transparent for colors that can be opaque or not drawn at all
- 32-bit (RGBA) for colors that can have alpha-transparency

I am currently not certain if it is necessary to have all 3 variants and not just the fullest one.
But besides (or rather - before) the editor GUI there's a problem of
a) saving this value in game data. Right now all the colors in AGS 4 are interpreted uniformly as R8G8B8, the uniformity keeps things simple.
b) having this value in respective script properties.

Because even if you take just the single transparent color as an addition, it's not im clear how to incorporate it in the existing system without treating alpha bits as alpha. I.e. classic 255,0,255 color may be opaque too.

I had a ticket open (https://github.com/adventuregamestudio/ags/issues/2525), but it received a mixed reaction from other devs. I suggest that we need to come to a conclusion on it.

EDIT: I think (and noted in the last comment to that ticket), that I put several separate things in it by mistake. Maybe these things should be disconnected and dealt with separately.

eri0o

I mentioned in the ticket, what if we do that Color managed struct, all these properties are now this type, and things that need color properties would instantiate these managed structs and hold a reference internally. Then we can either make these readonly (so people must use the properties) or handle the pointer assignment as way that only copies the values (but not the pointer, or people could pass the same pointer to multiple properties and get confused when changing one property change another).

Then we could do obj.Color.RGB = 0xRRGGBB or obj.Color.ARGB = 0xAARRGGBB (or obj.Color.RGBA = 0xRRGGBBAA, and however we handle it, we hide it internally (including any mask color necessary).

Crimson Wizard

#186
Above looks alright on its own (in api sense), but naturally my concern is that this will break all the people scripts... If that's fine, we could try that approach.


EDIT:
Also, I am mentioning this since you have brought the script function speed before, this will make setting colors somewhat slower, because that would require 2 function calls:
- get_Color - that returns a pointer to Color struct
- set_RGB - that sets value as rgb.

eri0o

Two things often appear when I use the VS Profiler in the AGS Engine when I am trying to do something visual (like the recent Particles script module)

  • Engine Script API calls
  • BitmapToVideoMemory methods

Other than this for some reason loops in AGS Script feel slower than they should, but these don't appear when profiling.

The Color having to be fast is an issue only in one place, which is the DrawingSurface.DrawingColor property, which is critical for doing fun effects!

I guess we could try the plain int approach and see how that works.

Whatever is done has to be throughly tested in the hard case that is a game with a linear interpolation, to see if the border of sprites are affected since the ticket with all the changes written impacts how sprite importing would happen.

Crimson Wizard

#188
Quote from: eri0o on Sun 05/01/2025 13:40:17Whatever is done has to be throughly tested in the hard case that is a game with a linear interpolation, to see if the border of sprites are affected since the ticket with all the changes written impacts how sprite importing would happen.

I don't understand, how does that ticket impacts sprite importing?
I re-read it, and I do not see anything mentioning sprite import...
EDIT: i found something in comments, is it about sprite->texture conversion?

In any case, I am not suggesting to implement that ticket as-is. It may be split apart and done in steps, discussing and testing every step separately.

Crimson Wizard

Quote from: Baguettator on Fri 03/01/2025 15:17:43EDIT 2 : new problem I encounter in AGS 4. If I attach a function On_Click on a button called "Objectif", the function is by default called Objectif_OnClick. If I rename it, let say Fouille, then in the editor I click in the "..." button of on_click function in the right panel of the gui's window (with the Objectif button selected, so in this box there is the name of its onclick function, so in my case it's written Fouille), the editor creates a new function called Fouille. Previously in AGS 3.6, he knew that there was a function called Fouille, and he didn't create a new one, he jumped to the right function directly.

@Baguettator  could you please post step-by-step instruction on how to reproduce this problem? At first I thought I got it, but trying now it works fine, so maybe I am not doing what you were doing.

Baguettator

Yeah, in my last working time, I didn't encounter the bug. Will notice you if I encounter again, because perhaps it was the previous AGS 4.0 version (was alpha 13 before).

The main problem for me is the dynamicsprite not rendering correctly. Hope you will fix it as soon as possible ! ;)

Crimson Wizard

#191
Quote from: Baguettator on Sun 05/01/2025 17:41:09The main problem for me is the dynamicsprite not rendering correctly. Hope you will fix it as soon as possible ! ;)

I found what was wrong with some sprites not visible after loading, but I don't know how to reproduce the other problem where sprites have lines on them.

Does this happen with particular sprites (which ones?), or after you do something to them?

EDIT:
here's the temp build which has sprite loading fixed:
https://cirrus-ci.com/task/6201304671846400

eri0o

@Baguettator can you make a small game and project that has the same lines issue and share the project here?

Also, does the issue happens with all three graphics drivers (D3D, OGL, and Software)?

Baguettator

Thanks Crimson ! Is it safe to test my game with your fixed version ?

Will have a look and tell you what I'll see :)

Crimson Wizard

#194
Quote from: eri0o on Sun 05/01/2025 12:13:10I mentioned in the ticket, what if we do that Color managed struct, all these properties are now this type, and things that need color properties would instantiate these managed structs and hold a reference internally. Then we can either make these readonly (so people must use the properties) or handle the pointer assignment as way that only copies the values (but not the pointer, or people could pass the same pointer to multiple properties and get confused when changing one property change another).

Then we could do obj.Color.RGB = 0xRRGGBB or obj.Color.ARGB = 0xAARRGGBB (or obj.Color.RGBA = 0xRRGGBBAA, and however we handle it, we hide it internally (including any mask color necessary).


I've been thinking this over for several hours, and while I like the syntax, I am much concerned about the implementation particularly in AGS, and thus became reluctant to do something like that. If this was a new engine, or a different script language, then maybe it would be easier or better justified...

There are multiple issues here: the color storage in dynamic memory that has to be serialized, how game objects will be accessing these, will the Color instance duplicate color values from object's own data or read/write directly to them?
There will be a use of Color in object properties, but also in user script, then likely it has to contain all data within itself.
Then, AGS engine's code currently has a number of problems in its organization, which may make it inconvenient to bind a game class to a separate managed object. An example is GUI classes that do not have any proper "runtime" class equivalent yet which would allow to handle access to managed data. We'd need to reorganize them first prior to doing something like that.

Then, if we replace properties, then should not we also replace function arguments? There is "color" arg in some functions, like Overlay.CreateTextual. Game.GetColorFromRGB would need to return Color struct.

An idea of having separate DrawingSurface.DrawingColor as integer just for the sake of maintaining performance, while having a practical purpose, looks bad for consistency of API.

If script API uses Color struct, then users should be able to store colors in the same struct too, to keep things smooth.
But then another big inconsistency is going to be color assignment: as you say, when stored in objects they should not be shared, so assigning a Color reference to object's property will act as a copy. But if users use Color struct in their scripts, these will not copy when assigned but share a reference? Which will lead to mass confusion. So this might require designing a specific syntax approach. I'd even say: an ability to pass and assign PODs (plain structs) could come handy.

Overall this means that implementing such approach would require good amount of effort, while breaking user scripts and requiring them to change some habits.

Repeating myself, if this were a new engine then this could be justified. But what do we gain with such overhaul in the existing one? It's the ability to set "transparent color", or provide "alpha" value to color properties, where latter is not normally required alot.
Looking at the cost / benefit relation here makes me quite doubtful.

Maybe this idea could be planned to be looked into again after a bigger refactor of the game classes in the engine, as a part of the big script api overhaul, where other complex things, such as various transformation and graphical properties, would receive same change.

eri0o

We could use the plain int approach, this could work nice with the hex assignment. 0xaarrggbb or 0xrrggbbaa or just 0xrrggbb depending how the colors are thought through.

Baguettator

@Crimson Wizard Hi, I have tested with your fixed version : everything is ok !

I think the problem was "per GUI" : the first images you generate within the same GUI will have problems (invisible), and less and less problems for the followings. That's why the images became more and more visible, and only 1 or 2 of them were fully displayed.

Each time it was 3-4 GUIControls within a GUI, every control was invisible. In my Tabletop GUI, I had 40-50 controls who received DynamicSprite.CreateFromFile as graphics. The first who received the sprites were invisible, and then, the last were without problems, and at the middle, a "crescendo" of visibility :)

Crimson Wizard

Quote from: Baguettator on Mon 06/01/2025 10:06:23I think the problem was "per GUI" : the first images you generate within the same GUI will have problems (invisible), and less and less problems for the followings. That's why the images became more and more visible, and only 1 or 2 of them were fully displayed.

The problem I fixed was loaded sprites being invisible. But I cannot explain other things.

Crimson Wizard

#198
Quote from: eri0o on Mon 06/01/2025 09:54:32We could use the plain int approach, this could work nice with the hex assignment. 0xaarrggbb or 0xrrggbbaa or just 0xrrggbb depending how the colors are thought through.

I've been thinking about 2 approaches in regards to plain int values.

1. Have all colors treated uniformly as ARGB in all properties and arguments.

That will be most consistent, and simple to implement, but will make 0xFF... prefix mandatory for opaque colors when you define the color by hand, which may be seen as annoying by some, and be prone to user mistakes.
Two more notes here:
- Value 0 will be the easy way to set "transparent color".
- Alpha has to be in highest bits, because 0xRRGGBB may be cast (assigned) to 0xAARRGGBB, but cannot be cast to 0xRRGGBBAA (will require value conversion).
- Majority of users can just use Game.GetColorFromRGB / Game.GetColorFromRGBA functions to form colors; where old one will always return opaque color (alpha 0xFF).

--------

2. Have separate properties for RGB and ARGB.

After some hesitation, I wanted to propose this as an alternative to having a Color.RGB/ARGB syntax.
The reasoning here is that in majority of cases users will likely want opaque colors, and specify alpha in relatively very small number of situations.

The idea is to have a "argb" property pair for each xColor property. For example:
- GUI.BackgroundColor
- GUI.BackgroundColorA
- Button.TextColor
- Button.TextColorA
- DrawingSurface.DrawingColor
- DrawingSurface.DrawingColorA
etc

where Object.Color would interpret positive integer values as RGB, and let's say "-1", or any invalid value would mean "transparent color".
And Object.ColorA would interpret any value as ARGB.

The downside here is obvious duplication of each Color property (but I think there are not too many of those).
There is also a room for mistake, where one would try to assign full argb to rgb property.

The upsides are:
- This allows to restrict certain things to no alpha support, and make alpha support more explicit.
- Users are not required to remember to put alpha 0xFF when they define opaque colors.

There's a remaining question of colors as function parameters though.

eri0o

#199
I see you using the word "Opaque" a lot, and so more making a note here to remind me when making docs, alpha is actually a measure (or a value?) of Opacity. Throughout AGS Script API we use Transparency, which is the inverse. A 100 value of Transparency is a 0 value of alpha.

Also with alpha in the color a lot of things that used to be blit can't be blit if the alpha is not 255.

Crimson Wizard

Quote from: eri0o on Mon 06/01/2025 11:13:23I see you using the word "Opaque" a lot, and so more making a note here to remind me when making docs, alpha is actually a measure (or a value?) of Opacity. Throughout AGS Script API we use Transparency, which is the inverse. A 100 value of Transparency is a 0 value of alpha.

BTW there's a ticket that proposes to change Transparency to 0-255 alpha too:
https://github.com/adventuregamestudio/ags/issues/2549

Quote from: eri0o on Mon 06/01/2025 11:13:23Also with alpha in the color a lot of things that used to be blit can't be blit if the alpha is not 255.

This is a matter of providing a separate blitting function that supports alpha blending.
OTOH we may state that we do not support it everywhere for starters.

Baguettator

1) I have seen that AGS 4.0 is not displaying "perfectly" sprites : it seems sometimes (or always ? hard to say), there is a line (1 pixel width) that is not drawn. Also for ListBoxes' or TextBoxes' perimeter, not all the lines appear.

2) when you update the translation file, how it works ? If I have already a translation file, and then I delete some lines in my scripts : will the deleted lines be kept in the update ? I remember in 3.6, only the new lines were added (like a File.Append), but I had to delete manually in the .trs file the lines that weren't anymore in my game

3) request for quality of life : would it be possible to add an extra option for the search/replace process ? It would be great if we could choose to search in the full script OR only in the "texts" (the ones who appear in dark red color, between ""). For example, since AGS 4.0, I have to replace many [ symbols, and it would be great to have the replace process to only look at texts zones and not the full script (because you'll have to be careful to not replace the brackets of arrays, and it would be so long, so many "next" clicks...)

Here are my last thoughts ! :)

Crimson Wizard

#202
Quote from: Baguettator on Tue 07/01/2025 11:05:591) I have seen that AGS 4.0 is not displaying "perfectly" sprites : it seems sometimes (or always ? hard to say), there is a line (1 pixel width) that is not drawn. Also for ListBoxes' or TextBoxes' perimeter, not all the lines appear.

Does this happen always, or in a particular case? Can you give a precise example, like, which object, what are this object's properties (size, position, graphic settings)? Does this happen with any graphic driver or specific one?


Quote from: Baguettator on Tue 07/01/2025 11:05:592) when you update the translation file, how it works ? If I have already a translation file, and then I delete some lines in my scripts : will the deleted lines be kept in the update ? I remember in 3.6, only the new lines were added (like a File.Append), but I had to delete manually in the .trs file the lines that weren't anymore in my game

As far as I know, nothing has changed in this regard compared to 3.6.

eri0o

A note on translation files, I believe it now uses the PO format.

ThreeOhFour

Quote from: eri0o on Mon 06/01/2025 11:13:23Throughout AGS Script API we use Transparency, which is the inverse.

This gave me trouble for years when learn AGS because drawing programs use 'Opacity' for this (and usually handle it as a percentage, as AGS does, rather than the 8 bit alpha value) and I always had to convert things backwards. I'm not proposing that this be changed, just mentioning that it always stood out as a quirk in AGS's nomenclature.

I do think it would be great to be able to access the full range of the A value for a colour, though I can't say I've ever run up against it as an issue. But I imagine now that I'm getting back into making effects inside AGS that I would quite rapidly find uses for being able to read and store RGBA colour values.

Baguettator

Quote from: Crimson Wizard on Tue 07/01/2025 12:50:51Does this happen always, or in a particular case? Can you give a precise example, like, which object, what are this object's properties (size, position, graphic settings)? Does this happen with any graphic driver or specific one?

Perhaps, just try with the sprites I sent to you, especially those which are located in "dalles" folder. In my game, they are placed one next to the other, without any gap between (side by side). In AGS 4.0, I can see white lines between some sides of them (my background is white). As I also specified, list boxes and text boxes are concerned too. I'll tell you if I see anything else !

About the translation file, I know PO format, I don't know what does it change for me. Just it would be cool if the "update translation file" command would really update it (store the already translated lines, delete everything in the file, and then add all the lines from the scripts, comparing to the stored translated lines and if they match, putting the translated line in the updated file). I have made a "game" to especially do that, but it would be more convenient to have this built-in. (hope my explications are right, I'm not sure of my english language right now !)

And what about my 3° request ? :)

Crimson Wizard

#206
Quote from: Baguettator on Thu 09/01/2025 07:57:31Perhaps, just try with the sprites I sent to you, especially those which are located in "dalles" folder. In my game, they are placed one next to the other, without any gap between (side by side). In AGS 4.0, I can see white lines between some sides of them (my background is white).

Placed how? Were you using objects, or raw drawing them on a surface?
Were these sprites imported, or loaded using DynamicSprite.CreateFromFile?
Can you tell exact name(s) of sprite(s), in case it matters?

Quote from: Baguettator on Thu 09/01/2025 07:57:31As I also specified, list boxes and text boxes are concerned too.

I put a random text box and list box on gui, and they look fine. Does this happen with ANY listbox and textbox for you, or particular ones?
Is this problem seen in the editor or only at runtime?
Does this occur with the particular graphics driver, or any of them?

Snarky

Quote from: Baguettator on Thu 09/01/2025 07:57:31Perhaps, just try with the sprites I sent to you, especially those which are located in "dalles" folder. In my game, they are placed one next to the other, without any gap between (side by side). In AGS 4.0, I can see white lines between some sides of them (my background is white). As I also specified, list boxes and text boxes are concerned too. I'll tell you if I see anything else !

Can't you post a screenshot, at least? It's almost impossible to guess what the problem might be based on the information you've provided.

One possibility is that it has to do with scaling. Are the sprites scaled in-game? Is the game scaled on the screen?

Baguettator

Yes I will give more information when I will able to test.

But, question : my savegames are 250Mo each... It seems VERY large, doesn't it ? Which things take so many place in a save file ? Variables ?

Can it be improved to have savegames lighter ?

Crimson Wizard

#209
Quote from: Baguettator on Fri 10/01/2025 21:53:46But, question : my savegames are 250Mo each... It seems VERY large, doesn't it ? Which things take so many place in a save file ? Variables ?

Can it be improved to have savegames lighter ?

For instance, dynamic sprites are all written in saves by default.
You may avoid that using a new feature (introduced in 3.6.2 and latest 4.0), which allows to exclude dynamic sprites from saves. This is explained here:
https://adventuregamestudio.github.io/ags-manual/UpgradeTo362.html#restricting-the-data-read-or-written-in-a-save

This comes with an obvious problem: you must recreate all the necessary dynamic sprites for the current scene on "eEventRestoreGame" event.

Apart from that, I think you have mentioned that your game is not a standard point and click adventure game, but some kind of a base building strategy game?
In which case I would rather recommend designing your own save system instead. That could be much more convenient than using AGS save states, as you will fully control what is saved and loaded, what is kept intact when restoring a save, and what gets overwritten.

Baguettator

Thanks for explanations !

I had a crash for an array out of size, and the runtime executable (the program which runs the game while in the editor) didn't close normally. Perhaps this kind of error causes that issue ?

eri0o

It would be nice to get bug reports that are minimal, complete and verifiable.

QuoteMinimal – Use as little code as possible that still produces the same problem
Complete – Provide all parts needed to reproduce the problem
Verifiable – Test the code you're about to provide to make sure it reproduces the problem

I think without something that can be run and reproduces any issue it is very hard to grasp anything of what you are reporting. I refrained from writing this because it is useful to get some reporting of bugs but it's hard to act without having anything, ideally, make a small new AGS game that reproduces the issue and attach it somewhere that can be downloaded and link here.

Think in this way, someone writes a bad review in Steam about your game and then just say "bugs", but doesn't clarify any details, it would be nice to get everything needed to reproduce and fix such issues so others get to enjoy the game.

Baguettator

Sorry, I wrote it quickly because I already reported here this issue (when the runtime executable doesn't close normally), but really this message is so far now... Apologizes...

The thing is I had something like that :

Code: ags
for (int i=0 ; i<7 ; i++)
{
  btn[i].Visible=true;
}

The btn array's size was [6], so the game crashed (out of array size). And this crash reproduced the "runtime executable doesn't close normally" issue.

Baguettator

OK, so here's the problem with "transparent lines" appearing around sprites. I don't know if it's for any sprites, but at least for the tiles in my example (big squares), it's easy to see.

https://drive.google.com/file/d/149PE4pu_DI8YVueWZiyg_5tY4NOXpgAW/view?usp=sharing

I can imagine it's something about rotating sprites. This problem appears with both Draw functions (drawing a DynamicSprite into a surface) and attributing a dynamicsprite to an object (button in my case). If that dynamicsprite is NOT rotated, no problem, no "transparent lines" on edges. If it IS rotated, then the problem happens.

In my screen shots, tiles are the squares  behind every other tokens. There are 3x3 squares, so 9 in total. The rotation of each tile can be seen with the number written on the corner of the tile : the direction of the number indicates the rotation (0, 90, 180 or 270°). Each time a tile is 90 or 270° rotated, it shows the bug.

eri0o

That is zombicide.

But can you hit new in AGS and create a small game that reproduces this specific rotation issue, and share the game project here?

Crimson Wizard

#215
Quote from: Baguettator on Sat 11/01/2025 09:50:36The btn array's size was [6], so the game crashed (out of array size). And this crash reproduced the "runtime executable doesn't close normally" issue.

I noticed a similar problem, and apparently it does not matter which error is this.
When a "An error has occured" window appears in the editor, it does not stay and disappears automatically a moment later, game shuts down on its own too (at least in my case), without waiting for you to press the button.

This happens only in AGS 4. (not in any other recently updated versions like 3.6.2)

---

EDIT:  after subsequent tests, this seem random. Sometimes it happens and sometimes is not. It looks like something closes the error popup.
I also do not see the game being stuck in debug mode, although I had an idea why that could happen sometimes (and already pushed a fix earlier).

EDIT2: not sure, but this may be related to another particular application being opened at the same time.

Crimson Wizard

#216
Quote from: Baguettator on Sat 11/01/2025 11:36:11In my screen shots, tiles are the squares  behind every other tokens. There are 3x3 squares, so 9 in total. The rotation of each tile can be seen with the number written on the corner of the tile : the direction of the number indicates the rotation (0, 90, 180 or 270°). Each time a tile is 90 or 270° rotated, it shows the bug.

Do you rotate same sprite multiple times, or do you recreate it from original each time and then rotate to the final angle?

There's a known issue that if you keep rotating same sprite again and again, then it looses quality over time.
Although, in theory, rotation by the multiples of 90 degrees should not lead to this, so idk if it's related in this case.


EDIT: I tested rotating this big tile from the sprite archive that you have uploaded earlier, and I do reproduce this problem.
It becomes worse if I keep rotating same sprite, bit also happens if I recreate it before giving it a bigger rotation.

Baguettator

I rotate them 1 time after creating them.

Crimson Wizard

#218
I confirm that there's definitely something off with the dynamic sprite rotation in AGS 4.

I made a game in 3.6.0 where I draw 4 tiles on room background, each next rotated by 90 further.

In 3.6.0 version there are no gaps between them, but when replicating same game in 4.0 there are gaps.

Here are both game projects for comparison:
https://www.dropbox.com/scl/fi/fbr8o10b805h3hwvbo6rf/test-360-dynamictilerotate.zip?rlkey=zl3lmkrvfl6zbwo54ua7r9ugq&st=rvkvia0e&dl=0
https://www.dropbox.com/scl/fi/rdmwbkmrk93ud4pyvf78h/ags4-dynamictilerotate.zip?rlkey=2exi0wau9yaw8hcwtb4lc5of8&st=9dssf1cc&dl=0

My first guess is that the dynamic sprites get unexpectedly distorted when rotated.

eri0o

#219
allegro in both ags3 and ags4 are identical except in how they work with the palette for images with palette (8-bit). The rotation code (rotate.c) in both is identical.

In ags4, in Common/gfx/allegrobitmap.h there was a comment added that is like this
Code: ags
    // Draws rotated bitmap, using angle given in degrees.
    // Warning: does not resize destination bitmap; if it's not large enough
    // then the resulting image may end up cropped.

Found the workaround, just pass the width and height properly when rotating. Using your test game @Crimson Wizard

Code: ags
function room_Load()
{
  DynamicSprite *tile = DynamicSprite.CreateFromExistingSprite(1);
  int wid = tile.Width;
  int hit = tile.Height;
  
  DrawingSurface *ds = Room.GetDrawingSurfaceForBackground();
  ds.Clear(Game.GetColorFromRGB(255, 0, 0));
  ds.DrawImage(100, 100, tile.Graphic);
  tile.Rotate(90, 250, 250);
  ds.DrawImage(100 + wid, 100, tile.Graphic);
  tile.Rotate(90, 250, 250);
  ds.DrawImage(100 + wid * 2, 100, tile.Graphic);
  tile.Rotate(90, 250, 250);
  ds.DrawImage(100 + wid * 3, 100, tile.Graphic);
  ds.Release();
}

Works fine in ags4.

Crimson Wizard

#220

eri0o

For the dynamic sprite rotation in ags4, there is a build in the CI here with a fix: https://cirrus-ci.com/task/5179283984875520

Baguettator

Also, I have another request but I know I several times suggested it by the past : because you told about RGBA colours and things about that, is it possible to add PNG management by the editor ? It could be so great to have the possibility to add png files with their alpha channel instead of "magic pink backgrounds" for BMP files.

I don't know how much it is complicated/not planned/not wanted :)

eri0o

Editor supports importing a png file with alpha, just select the leave as is for alpha when importing.

Did the editor in the link fix the issue with rotating dynamic sprites for you?

Crimson Wizard

Quote from: Baguettator on Mon 13/01/2025 12:05:08Also, I have another request but I know I several times suggested it by the past : because you told about RGBA colours and things about that, is it possible to add PNG management by the editor ? It could be so great to have the possibility to add png files with their alpha channel instead of "magic pink backgrounds" for BMP files.

This is already supported in the editor for many years. Do you maybe mean loading a PNG with DynamicSprite?

What we said about RGBA colors is not related to this.

Baguettator

Yes sorry, I meant : using PNG files for DynamicSprites :)

@eri0o : I didn't try yet, will have a look !

Baguettator

Hi all,

@eri0o : the fix for the rotation with dynamicsprites worked for me, thank you !

I noticed a problem with the GUIControl.GetByName function : I didn't change anything in my game, just ported it to AGS 4.0 (last build, the fix erioo sent me), and I have a null pointer instead of something working like before.

For example, I have a button called "Button1" in my game (it's the script name of the button). Here's my code in game_start function :

Code: ags
int u=1;
  GUIControl *g=GUIControl.GetByName(String.Format("Button%d", u));
  u=g.ID; // error is here, g appears to be a null pointer, whereas it exists in my GUI !
  Display("%d", u);

Crimson Wizard

Quote from: Baguettator on Sat 18/01/2025 19:26:51I noticed a problem with the GUIControl.GetByName function : I didn't change anything in my game, just ported it to AGS 4.0 (last build, the fix erioo sent me), and I have a null pointer instead of something working like before.

GetByName got broken again, you will need to use the most recent unreleased build to make it work:
https://cirrus-ci.com/task/6345700029497344

Baguettator

Does it include the rotation fix for dynamicsprite too ?

Crimson Wizard

#229
Quote from: Baguettator on Sun 19/01/2025 09:00:28Does it include the rotation fix for dynamicsprite too ?

This is the latest build which includes everything.

But I forgot that the above includes update of a color format, so may not be entirely safe. It's still in testing.
After upgrading, users will have to fix all of their color constants if they have these in scripts,
that is - assignments like "GUI.BackgroundColor = 123456;". These should be replaced with AARRBBGG format like, which is easier to write in hex (like "0xFF123456").
If you don't have such things in script, then it's safer, but still I recommend making a game backup.

If you don't want to do this right away, there's a temporary workaround for GetByName:
Code: ags
GUIControl *MyGetByName(GUI* parentGUI, String name)
{
    for (int i = 0; i < parentGUI.ControlCount; i++)
    {
        if (parentGUI.Controls[i].ScriptName == name)
            return parentGUI.Controls[i];
    }
    return null;
}