AGS 3.6.0 WIP (Alpha 21) - SDL2-based engine + Unicode support

Started by Crimson Wizard, Thu 25/03/2021 02:28:54

Previous topic - Next topic

Crimson Wizard

AGS 3.6.0 - Alpha - for Public Test

ACHTUNG!
This is a ALPHA version of AGS 3.6.0.
It's not considered stable yet 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 may make your project files unusable in previous versions after saving with this version.


Last update: 14th March 2022


Preword

This release presents a SDL2-based engine. For about 2 decades AGS engine was based on Allegro 4 graphic library, which was discontinued somewhere in the early 2010-ies (only received few patches since). There was an intent to move either to Allegro 5 or SDL (1 or 2) since, but for various reasons this task was continiously postponed. Finally we have a good progress there enough to make a build for public test.
(NOTE: Allegro 5 is very different in everything, therefore it was not trivial to just go from Allegro 4 to 5. In fact it appeared to be easier to change from Allegro 4 to SDL2).

NOTE: contains all the changes from AGS 3.5.1 (Patch 9).


Credits

- SDL2 port mostly done by Nick Sonneveld;
- Improved Android port, and Web/Emscripten port made by eri0o;
- me basically gathered Nick Sonneveld's works together, tidied and fixed where necessary.
+ added more stuff (see below) and some new script commands
+ some stuff added by Alan v. Drake.
+ fernewelten (fixes)
+ panreyes (fixes)


Downloads and instructions

* Full AGS 3.6.0 as installer
* Full AGS 3.6.0 as a .zip archive
* Android game player, aka launcher (APK signed with Debug key), suitable for running any compatible AGS game.


Notable changes related to new backend and ports

Full list of changes now available here (will be posted for the final release on forums too):
https://github.com/adventuregamestudio/ags/blob/v.3.6.0.20/Changes.txt

* Freely resizable window (in desktop windowed mode, obviously).
* Software renderer uses SDL2 as a final output, meaning the actual drawing on screen may be done by anything that your system supports from DirectX to OpenGL. This presumably ensures that it works on any version of Windows.
* Fully rewritten audio playback, now uses OpenAL interface and modern SDL-based sound library.
* On Android supports both "software" and "hardware" types of renderers (they are both OpenGL but use different approaches drawing sprites and effects).
* Removed AVI/MPEG video support (may be temporary...). The main reason is that in the old engine they were implemented using Windows-only DirectX interface and Allegro 4 was already providing access to these. SDL2 does not, and it may be an extra hassle to recreate them. So this is under question now.
* For similar reasons removed support for DirectX-related functions in plugin API. I'm afraid this will break some older plugins that require DirectDraw and similar things. Direct3D plugin maybe will continue working as it wants Direct3D renderer, and that is still present.


Other Notable engine/editor changes

Editor now requires .NET Framework 4.6 (was 4.5). NOTE: the compiled games DO NOT require .NET to run.

Full Unicode support. Editor and engine can work in Unicode mode, allowing practically any human language. ASCII/ANSI mode is still supported for backward compatibility. See "Text format" option in General Settings. Additionally, translations (TRS) have individual setting. More information on translations is here: https://www.adventuregamestudio.co.uk/forums/index.php?topic=59240.0

Improved key input handling, with the purpose for easing unicode input support. This is controlled by the "Use old keyboard handling" option in General Settings: setting it to "false" will use new handling mode with extended features. See "Script API" section below for more information.

New rewritten Android game player (aka "launcher"). Suitable for building for Google Play and similar stores, can read game assets from the android-specific packages (apk, aab).

Introducing Web/Emscripten port capable of running games in browsers.

Build Android and Web/Emscripten games from the Editor.

Editor supports multiple compressions for sprites, which may be selected in General Settings. Currently available: RLE (old default) and LZW.
Also, there's an option to optimize sprite storage format to reduce disk space whenever possible. This option is separate from compression but may be used alongside for the further effect. It's enabled by default in this version.

Editor supports packing multiple speech voxes, using files in the "Speech" subfolders (e.g. "Speech\french" subfolder will produce "sp_french.vox").
Engine can switch to a different speech vox by a script command (see below).

Editor supports packing custom files into the game (General Settings -> Compiler -> Package custom data folder(s)). These may be read in script using File.Open with "$DATA$" path token.

Engine supports "borderless full-screen window" mode in addition to the real (exclusive) fullscreen.

Engine supports scripts using functions and variables (imported) from any other scripts, regardless of the script module order in the project. These still have to be declared as "import" above their use though.

There's "GUI controls clip their contents" option in the General Settings (enabled by default). This clips texts to the control's rectangle.

Configuration for TTF fonts that let display both common TTFs and ones made specifically for AGS in the past as they were meant to be.
Fixed display of certain TTF fonts which previously had their heights calculated wrongly. This could lead to texts being cut of at the bottom due to the graphical surface being not large enough.

Custom font outline thickness and style, works for automatic outlines only. In the font properties you may set how thick outline is in pixels, and choose between "Square" and "Round" style.

Removed a limit of Overlays created at the same time (was 30).

Now has 16 max Audio Channels (was 8).

Select script editor's font in the editor's Preferences.

Zoom controls on almost all panels (sprite manager, cursor, inventory item, and so on).

Debug displays, such as showing room mask and character walk paths, are now implemented as non-blocking translucent overlays, allowing you to keep playing the game while they are on. (See "Debug" script command).


New Script API

- Expanded on_key_press callback, now supports two parameters: key code and key modifier flags: on_key_press(eKeyCode key, int mod); where "mod" argument contains key modifiers (ctrl, alt, shift, etc).
- In the new key handling mode on_key_press is called for each actual key press; e.g. combinations like Ctrl+Z will result in two on_key_press calls, one with eKeyCtrlLeft and second with eKeyZ.
- Implemented new on_text_input(int ch) callback which is called when the engine receives a printable character. This callback is essential for handling unicode chars in script.
- Similarily, expanded dialog_options_key_press with the third mod argument, and implemented dialog_options_text_input callback for receiving unicode chars during the custom dialog options state.
- Added eKey constants for Shift, Control and Alt keys.
- Added eKeyMod enum for key modifiers constants.
- String.AppendChar, ReplaceChar and Chars[] property are now working with the unicode characters.
- String.Format("%c") specifier will now be able to print unicode characters.
- Added Game.ChangeSpeechVox() and Game.SpeechVoxFilename, which work in a similar fashion to Game.ChangeTranslation and Game.TranslationFilename respectively.
- DrawingSurface.DrawImage() and DrawSurface() now accept optional source rect coordinates, so you can draw a chosen part of the sprite directly;
Code: ags
DrawingSurface.DrawImage(int x, int y, int spriteSlot, optional int transparency, optional int width, optional int height,
		optional int cut_x, optional int cut_y, optional int cut_width, optional int cut_height);

- Functions for getting drawing surfaces for room areas and regions, letting you paint them at runtime:
   static Hotspot.GetDrawingSurface(), static Region.GetDrawingSurface(), GetDrawingSurfaceForWalkableArea(), GetDrawingSurfaceForWalkbehind();
- Room.Exists(): tests if the room of certain number is available;
- Every function accepting file path now supports "$DATA$" location token, which lets you read game resources. This was added mainly for reading custom packed files, but will work with any game resource fwiw. Opening files like this will only work in read mode, writing will fail. Examples:
Code: ags
File *f = File.Open("$DATA$/MyDir/myfile.txt", eFileRead);

Code: ags
ListBox.FillDirList("$DATA$/MyDir/*.*");

- WaitMouse(): complements other Wait* functions.
- SkipWait(): skips current Wait (will normally only work from repeatedly_execute_always callback).
- All the Wait* functions now accept "0" as "no timeout", in which case waiting may only be interrupted using either corresponding input or SkipWait.
- All the Wait* functions now return a code telling how they were interrupted:
Quote* positive value means a key code;
* negative value means a -(mouse code);
* 0 means timeout or interrupt with a script command.
- AudioChannel.Pause(), Resume() functions and AudioChannel.IsPaused read-only property.
- AudioClip.PlayOnChannel() lets you play a clip explicitly on a certain channel, disregarding any audio type rules. Works with channels 1-15 now (channel 0 is kept reserved for a speech voice-over).
- Characters now may be scaled freely, not limited to 5 - 200% (new range is 1 - 32767 for technical reasons).
- Added Character.IdleAnimationDelay to let control idle view's animation speed.
- Hotspot.Name and Object.Name may now be set in script.
- Object.SetView() now resets loop and frame to 0 by default. Previously default was -1 which made object retain loop & frame, which was often unexpected, and could cause game errors.
- Object.ManualScaling and Scaling properties, now letting to scale an object by command similar to Character (previously objects were only scaled by the walkable area).
- Added new delay parameter to Mouse.ChangeModeView() to let control cursor's animation speed.
- Game.BlockingWaitSkipped: returns the last reason of the last blocking action interruption: this is same as Wait* function return value, but also works for skipped blocking speech, and so on.
- readonly Overlay.Width and Overlay.Height: let you know the overlay's size;
- Overlay.Transparency lets you change overlay's translucency without recreating its image.
- Overlay.ZOrder lets you to define overlay's drawing order on screen. Overlays are now sorted among GUIs.
- Speech.TextOverlay and Speech.PortraitOverlay: give access to the text and portrait overlays of a current blocking speech. In practice these are only available in repeatedly_execute_always callback. Among other things, these properties allow to detect appearance, removal, and change of the blocking speech; also calling Speech.TextOverlay.Remove() will work as a speech interrupt.
- System.Log(): prints into the engine log.
- Debug(2, 0) command that displayed walkable areas is superceded by Debug(2, n), where "n" is a mask type: 0 - none, 1 - hotspots, 2 - walkbehinds, 3 - walkable areas, 4 - regions. This command also works as a toggle switch, calling it with the same mask index will turn it off.
- Debug(5, n) command that displayed character's walk paths now also works as a toggle switch.


Known problems

...?


Other potential issue

* On Windows we currently build engine dynamically linking to SDL2.dll. This means one have to be put along with the game exe. Because this may be a hassle, I suppose we may later change this to static linking just like Allegro 4 was linked to the engine before.
* On Linux, if you are using our prebuilt binaries you should be fine, if not then you have to install SDL2 runtime libs on your linux system.
* Noticed there may be problems playing MIDI, again need to test more and fix.
* Anything we don't know yet about ....







In regards to building Web version of the game. This only works when you have "Web build component" installed along with the Editor. The new "Web" Build target should become available. If you check it, and rebuild the project, the Editor will deploy necessary files into Compiled/Web folder in your project.

Note that you cannot run index.html directly, it likely won't work. You need to create a web server with these files on it. There is a multitude of ways you can do that. For example I've been testing this using a simple Google Chrome app called Web Server for Chrome. You may find your own way.

For any questions regarding the Web port please refer to and post in dedicated forum thread:
https://www.adventuregamestudio.co.uk/forums/index.php?topic=59164.0

Joseph DiPerla

Nice. I will give this ago within the next couple of days. Thank you all!
Joseph DiPerla--- http://www.adventurestockpile.com
Play my Star Wars MMORPG: http://sw-bfs.com
See my Fiverr page for translation and other services: https://www.fiverr.com/josephdiperla
Google Plus Adventure Community: https://plus.google.com/communities/116504865864458899575

Crimson Wizard

Updated to Alpha 2, this is just to include latest fixes and changes from AGS 3.5.1, to keep them in sync.

New download links in the first post.

nightmarer


Crimson Wizard

Quote from: nightmarer on Sun 11/04/2021 20:49:19
I have received this error while running a room.
https://imgur.com/byuwNv7
[imgzoom]https://imgur.com/byuwNv7[/imgzoom]

Does this room open well in the editor? If so, can other engine (like 3.5.1) run same game?

nightmarer

Hello, I'm not having this error in the 3.5.1 version.
This error happens while being in that room during a half minute. It is truth that this room has a lot of things going on, animations and other events, but it works fine in the 3.5.1.

Crimson Wizard

Updated to Alpha 3, this is just to include latest fixes and changes from AGS 3.5.1. New download links in the first post.


Quote from: nightmarer on Sun 11/04/2021 22:16:08
Hello, I'm not having this error in the 3.5.1 version.
This error happens while being in that room during a half minute. It is truth that this room has a lot of things going on, animations and other events, but it works fine in the 3.5.1.

Sorry, I did not have a chance to reply. I don't think I will be able to do much without game itself. Can I get a copy to test?

nightmarer

Hello.

The thing is that it happens randomly. Yesterday I got the same error in another part of the game.
But I tried to replicate and it doesn't happen.
https://imgur.com/a/oyD4syF

Crimson Wizard

Quote from: nightmarer on Tue 20/04/2021 08:40:02
The thing is that it happens randomly. Yesterday I got the same error in another part of the game.
But I tried to replicate and it doesn't happen.
https://imgur.com/a/oyD4syF

I won't be able to solve anything having only this error message, because there may be various reasons why program runs out of memory.
I would like to test and compare the game in 3.5.1 and 3.6.0 to observe how much memory they use, and and maybe find out what causes this difference.

Potajito

Hi!
So far, so good, but the game crashes when I alt-tab when running in Full Screen mode. (Compiled exe). No problems so far Windowed.
This is the error:
https://imgur.com/zOZodXH
Let me know if you think this is worth investigating/need any more info.
Thanks for everything!

Crimson Wizard

#10
Heads up regarding the memory issue: there's definitely a memory leak in this version, and it seems to be related to audio (found out by disabling certain functions in the engine code).

EDIT: well, apparently the loaded audio never gets deleted from memory in the new code.

The easiest way to observe this is:
Code: ags

function room_RepExec()
{
	atest.Play();
}


game crashes in several seconds.

or more manual:
Code: ags

function on_key_press(eKeyCode key)
{
	atest.Play();
}

Crimson Wizard

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

Updated to include all changes from v.3.5.1.5.

Fixed major memory leak in the audio subsystem.

eri0o

@Potajito, do you still have the crash when alt+tabbing?

Potajito

Quote from: eri0o on Wed 12/05/2021 15:48:22
@Potajito, do you still have the crash when alt+tabbing?
Yes as of 3.6.0.3! That is, using Direct9. Open GL is all fine (was also with previous alpha). Are we not supposed to used Directx?
Thanks!

Crimson Wizard

#14
Potajito, we found out that this is because AGS 3.6.0 does not properly support suspending the game when it's alt+tabbed, so it always keeps running and redrawing in background. And Direct3D seem to not like that in fullscreen: similar error happens if you run any previous version in fullscreen and have "SetMultitaskingMode(1)" in script.

So, the fix is then first to restore proper handling of disabled multitasking (which is the default) and then figure out conditions under which game should not be redrawn even if multitasking is on.

Potajito

Quote from: Crimson Wizard on Sun 23/05/2021 04:20:28
Potajito, we found out that this is because AGS 3.6.0 does not properly support suspending the game when it's alt+tabbed, so it always keeps running and redrawing in background. And Direct3D seem to not like that in fullscreen: similar error happens if you run any previous version in fullscreen and have "SetMultitaskingMode(1)" in script.

So, the fix is then first to restore proper handling of disabled multitasking (which is the default) and then figure out conditions under which game should not be redrawn even if multitasking is on.
Nice! Thanks for looking into it. I'm more than happy using just OpenGl, but you never know what people would prefer.

Another one on the latest Alpha 4:


When creating a new project, either new or from a template.

Crimson Wizard

Where do you create your game, is the location writeable and you have permissions there? Were you able to create a game in the same place with the previous versions (3.5.0, 3.5.1)?

Potajito

Quote from: Crimson Wizard on Mon 24/05/2021 10:39:32
Where do you create your game, is the location writeable and you have permissions there? Were you able to create a game in the same place with the previous versions (3.5.0, 3.5.1)?
Yep, it is writable! in fact what I did was create a project in 3.5 (same folder, same name) and then just open it with 3.6.

Crimson Wizard

#18
Yes, there's something wrong with it, I'll investigate.


EDIT:
Sorry for this, there was a stupid mistake made in template extraction.

The fixed version will be available here, under "Artifacts", as soon as build server finishes working:
https://cirrus-ci.com/task/6038530150367232

Crimson Wizard

Seeing as some people already use this engine when building their games, I'd like to ask for an opinion of Windows users about SDL2.dll.

All the previous versions depended on "Allegro 4" library, but that library was merged with the engine exe, so you only had that game.exe or acwin.exe to handle and copy around.

This new version currently links SDL2 library dynamically, so you have to additionally have SDL2.dll.

Is this a big deal for people? I think we may reconfigure the engine to use "static linking" with SDL2. This is bit less flexible (e.g. one won't be able to swap it by hand if it needs an update), but I don't remember if there are other disadvantages.

SMF spam blocked by CleanTalk