AGS 4.0 - Early Alpha 11 for public test

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

Previous topic - Next topic

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.

SMF spam blocked by CleanTalk