Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Crimson Wizard

#721
Updated to Beta 4
(Please use download links in the first post)

Editor:
- Property Grid now displays Custom Properties right in the main properties list for each item that supports them.
- Support reordering folders in Sprite Manager with drag & drop.
- Script's Autocomplete will now work for dynamic array's Length property.
- Editor will now report any script functions that *look like* event functions, but not assigned to corresponding events, as warnings when compiling the game.
- Fixed dragging an item into the folder in Project Explorer could move it into a wrong folder if the folders have similar names only different in letter case.

Scripting:
- Support zero-length dynamic arrays. This may be useful if you need to have a dynamic array with no elements, but don't want to bother about checking a null pointer.

Script API:
- Added Character.Following property that returns another Character that this one follows after.
- Added System.DisplayFPS property that toggles FPS counter (a replacement to Debug(4, 1)).

Engine:
- Removed arbitrary limit of 2k bytes for the result of String.Format().
- Fixed calling Character.Animate() during idling state could cause incorrect error, reporting invalid animation loop. (This is regression in 3.6.1)
- Fixed GUI controls get shuffled when restoring saves made by pre-3.6.2 engines (regression since 3.6.2 Beta 3).
- Fixed Game.ScanSaveSlots() erroring on GUI in saves made by pre-3.6.2 engines.
#722
But if you don't use IsTimerExpired, you may as well just stop the timer yourself at 1.

Code: ags
function room_RepExec()
{
  int timeLeft = GetTimerPos(TIMER_ID);
  if (timeLeft == 0)
  {
    System.Log(eLogInfo, "Timer %d is not running", TIMER_ID);
  }
  else if (timeLeft == 1)
  {
    System.Log(eLogInfo, "Timer %d is about to expire!", TIMER_ID);
    SetTimer(TIMER_ID, 0); // stop the timer
  }
}

EDIT:
I think maybe this should be fixed... at least in ags4.
#723
@eri0o this is the problem with the current Timer implementation. It stays at 1 UNTIL user calls IsTimerExpired.
Add IsTimerExpired check somewhere in the script, and that should fix this infinite timer.

#724
The combined test build, if anyone like to try:
https://cirrus-ci.com/task/5407716887232512
WARNING: upgrades the game project to the new format, so don't use this on your real game project.
ViewFrames have a Flip property with 4 choices in the editor. The "Flip" command from menu ("F" key for shortcut) still flips only horizontally, I thought that would be convenient.
In script ViewFrame.Flipped was changed from boolean to eFlipDirection (since bool = 1 matches FlipHorizontal value).
Added Overlay.Flip property.
#725
Quote from: ThreeOhFour on Sat 14/12/2024 11:34:35The topic where you were discussing masks/stencils might be this one?

That was the person whose case caused my interest in stencils, but the discussion contains only the DynamicSprite solution. We talked on AGS Discord server afterwards, and I made a test build of the engine, with hardcoded stencil over some sprite. It was too ugly to make any PRs.

Technically the idea was that
- you need to enable stencil buffer (renderer must have something configured in them);
- user needs a way to tell "use this sprite as a stencil mask" and "use it with this object/sprite";
- renderer creates a stencil mask from one sprite and then later applies it when drawing another.
- stencil mask itself is just another texture. I think it should have low bitness (1 - 8 bit) to work correctly? don't remember this part by heart.
BTW this was not supported back then, but in latest ags4 you can demand to import/load certain image as a sprite while keeping it low-bit
(engine converts sprites to the game's depth by default).
- naturally, since we support Software renderer, the API should be suitable to also apply this mask in software mode.
#726
Quote from: eri0o on Sat 14/12/2024 01:27:45@Crimson Wizard when you were looking into cameras rotation I think, I remember you saying something about stencil, I don't remember what or exactly the details, but are those like something for a clipping mask?

Hmm, was not it GUI clipping?
I don't know if that's the only use for stencil, but at least one use is a clip mask of arbitrary shape.
The first time I checked stencils was when a user asked for a faster equivalent of CopyTransparencyMask, something that would carve a non-rectangular shape from an object.
#727
Quote from: eri0o on Sat 14/12/2024 00:27:53stamp a list of overlays in a buffer and then sample the alpha from this buffer and the colors from a second buffer to then write ove this second buffer which then you use it as texture to something (perhaps an overlay).

If we look in this article:
https://www.khronos.org/opengl/wiki/Blending
specifically the "Blend Equations" and "Blending Parameters" section,
we can see that there's a way to ask for certain color components from source and dest.

I.e. the quote:
QuoteWhen computing the output color, two equations are used: one for the RGB portion of the output color, and one for the alpha of the output color. This is useful if you want to do something like blend the source and dest colors but take the source alpha as the fragment output produced it.


The problem that I see with the case described above is that only character has to become a dark silhouette, but not the background image. Idk how realistic this effect is... but if the idea is to have different images behind the "screen" object to be affected differently, then this has to use a more complicated path rather than a single blend of screen object over everything that's behind...

I.e. something more like - be able to blend 2 objects together using one operation, and then blend the result to the rest of the room using another operation.

So... yes, if that is a wanted effect, then this has to be some kind of composite dynamic sprite.
#728
I have to admit that I was not reading the description of a use case thoroughly. Now when I see that you need to display a silhouette behind the screen, I am not completely certain that this Color property is the best suitable approach for that.

Maybe there's a way to achieve this with another blend mode too. Because the idea is that one sprite is layered over another, making the latter pixels change value.
#729
DynamicSprite.CopyTransparencyMask is relatively slow. The manual was first written around early-mid 2000-ies, alot changed since then, including computer power. Applying an effect to just few objects in low-res games should not lead to any noticable slowdown, and if this sprite is prepared once on room load, then there's no problem at all.

Both recoloring DynamicSprite and recoloring a sprite on render is technically possible. The latter would be very fast if done by a hardware accelerated gfx driver. I just recently experimented with this, it's couple of lines in the renderer code. The problem is mostly in how to organize this in script API and object data.
#730
I started working on Overlay.Flip, and ended up supporting full flip selection for the ViewFrame:
https://github.com/adventuregamestudio/ags/pull/2619
https://github.com/adventuregamestudio/ags/pull/2620

there are just a lot of things connected here, so when you begin changing one, you see that you can update others too.
#731
Quote from: Rik_Vargard on Thu 12/12/2024 20:40:13When you're in a creative mood, it is frustrating to stop working because you have to do that daily 30 minutes backup before going to bed and next morning to work.

If you use a a source versioning tool, that might take seconds to commit latest changes, and some seconds more to push these latest commits to a remote repository, as it only needs to copy the modified parts.
#732
Quote from: Rik_Vargard on Thu 12/12/2024 18:26:16My basic idea was that it would just be applied to the characters.

Because blurred backgrounds and overlays and objects etc can be done in an image or animation editor.

Both objects and overlays can change position in the room as well.
If this is feature is supported, that will not be proper to force users to make blurred versions of object graphics, there may be cases where same object graphic is used for multiple objects and even in multiple rooms.

Not to mention that it's easier to apply a dynamic effect than do it in art program. If any changes are necessary, they will be done by changing parameters in case of effect, but reapplying them to sprites may be less efficient.
#733
Quote from: Manu on Thu 12/12/2024 15:52:02I believe there is an in-game error message that does not go into the Translation file when you generate the translations:

"Unable to restore the saved game. File not found or could not be opened. Requested filename...."

This is a engine's own error hardcoded in the engine's program, that's why it's not found in translations. Translations are created by the Editor, and Editor does not know about what errors does engine display. (And engine does not attempt to translate these)

In order to support translating these, we'd have to at the very least introduce a list of "error types" and share it between Editor and Engine.
#734
In the end, my opinion on this is that the "Blur" is a way too uncommon effect to have a built-in property on Walkable Area.

IMO it should be implemented as a custom shader, which has a "distance" parameter, set from relative character position on a walkable area.

So:
1. Implement custom shader support.
2. Find a way to pass relative position from walkable area to custom shader as parameter.

#735
Please give more details, how do you have inventory window organized, is it on a popup bar, or inside a "window" that opens and closes? How do you open and close the gui which has inventory window on?
#736
Not only it should, but it already works.

Compiler already supports pointer upcast: you can pass subclass pointer to a function that expects base class pointer.
Therefore, an extension method is able to accept child pointer as well.

Code: ags
struct MyStruct
{
  int a;
};

struct MyChildStruct extends MyStruct
{
  int b;
};

function Extender(this MyStruct*)
{
}

function game_start()
{
  MyStruct x;
  x.Extender();
  MyChildStruct y;
  y.Extender();
}

Above compiles and runs fine with ags3 compiler.

So the problem is only with Autocomplete not working as it should again.
#737
So, I suppose, there are two issues related to this.

Having distinct Flip property may be useful for users convenience, because mirroring is the most common effect that they want. Internally it may be converted to a negative scaling with sprite position adjustment.

But then, there's also a question if we want to have regular Scaling also have a fixed offset. Because that's likely expected by users in majority of cases too.
#738
If "flip" is mirroring, then that may be achieved by setting negative scaling.

That should already work for GUI in AGS 4, but I don't remember by heart if that works for overlays.

EDIT: well, it's trivial to support negative width and height for overlays, but in current "Scaling" implementation in gfx drivers the negative scaling stretches textures to the opposite side of their origin. Meaning, the image shifts leftwards/topwards from "position".
GUI scaling has the same effect.
I recall having doubts about this, but since this is a new feature, I probably decided to leave this until there's user feedback.
https://github.com/adventuregamestudio/ags/pull/2426

The "flip" setting additionally fixes texture position to keep it where an unflipped texture would be.
Adding vertical flip to the graphic drivers is a non-issue.
But flip only potentially allows 3 scaling variants: (-1.0, 0), (0, -1.0) and (-1.0, -1.0).
#739
I have a vague memories of reporting this a while ago.

It works after you refresh a page.
#740
Yes, attributes (aka properties) are syntactic sugar over get/set functions.

Compared to a get/set pair they provide a single "attribute" name used for both get and set:
Code: ags
// functions
object.SetValue(new_value);
int value = object.GetValue();
// attribute
object.Value = new_value;
int value = object.Value;

Attributes combine variable syntax and abilities of a function.

Like variables, attributes may use assignment operators, including combined operators like += or ++:
Code: ags
object.Value++;
object.Value -= 10;

Like functions, attributes may have side effects (additional processing hidden behind them), they don't have to have a strict field associated with them. You may have a single attribute that changes multiple data on assignment, or multiple attributes that write or read same data in different ways.



You do not have to declare get_ and set_ functions in the struct. You may omit these, and then define them inside a script body as extender functions. That will save amount of code for the struct declaration.
This is also explained in the manual: https://adventuregamestudio.github.io/ags-manual/OOProgramming.html#access-with-extender-functions



Quote from: yarooze on Tue 10/12/2024 14:21:232. what is this "this" injection for?

The "this" in parameter list is used in extender function declaration only in order to tell which struct this function belongs to.
https://adventuregamestudio.github.io/ags-manual/ExtenderFunctions.html

If you write a function which was declared in a struct, then you use "Struct::Function" syntax, and you don't have to use "this" in parameter list, since compiler will already know that it belongs to "Struct".

In the example that you post, "void MyStruct" is already declared in the struct, so you use "MyStruct::MyStruct" syntax when writing its body.
But function "get_Data" is not declared in the struct, so you use extender syntax "get_Data(this MyStruct*)" in order to tell that this belongs to MyStruct.


In AGS 3 you must use "this." always in member functions. In AGS 4 the new compiler allows to omit "this."
However there's currently a problem in case member name matches global variable. IIRC in such case a global variable will take priority. So you better use "this.". We have a issue ticket opened for this reason:
https://github.com/adventuregamestudio/ags/issues/2067#issuecomment-1660533516
SMF spam blocked by CleanTalk