Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AGS 4: Script API: convert Walk-areas and Walkbehinds API to OO-style #2307

Merged

Conversation

ivan-mogilko
Copy link
Contributor

@ivan-mogilko ivan-mogilko commented Jan 21, 2024

Converting walkable areas and walk-behinds script api to OO-style, in compliance with existing Hotspot, Regions etc api.

This adds two managed structs, and array properties in the Room struct for getting these.

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/sets this walkable area's minimal scaling level.
  import readonly attribute int ScalingMin;
  /// Gets/sets this walkable area's maximal scaling level.
  import readonly attribute int ScalingMax;
};

builtin managed struct Walkbehind {
  /// Gets the walk-behind at the specified position on the screen.
  import static WalkableArea* GetAtScreenXY(int x, int y);
  /// Returns the walk-behind at the specified position within this room.
  import static WalkableArea* 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;
};

Added 2 global arrays of pointers to match existing ones, since they are still in use:

import readonly WalkableArea *walkarea[AGS_MAX_WALKABLE_AREAS];
import readonly Walkbehind *walkbehind[AGS_MAX_WALKBEHINDS];

But also added Room properties that return room's elements, as a suggestion for future use:

  /// Accesses the Hotspots in the current room.
  import static readonly attribute Hotspot *Hotspots[];
  /// Accesses the Objects in the current room.
  import static readonly attribute Object *Objects[];
  /// Accesses the Regions in the current room.
  import static readonly attribute Region *Regions[];
  /// Accesses the Walkable areas in the current room.
  import static readonly attribute WalkableArea *WalkableAreas[];
  /// Accesses the Walk-behinds in the current room.
  import static readonly attribute Walkbehind *Walkbehinds[];

@ivan-mogilko ivan-mogilko added ags 4 related to the ags4 development context: script api labels Jan 21, 2024
@ivan-mogilko ivan-mogilko added this to the 4.0.0 (preliminary) milestone Jan 21, 2024
@ericoporto
Copy link
Member

ericoporto commented Jan 21, 2024

Hey, the build failures are because the new files need to be added to Engine/CMakeLists.txt.

array properties in the Room struct for getting these

Not sure if I am missing this somewhere, but the Room struct in the Script API could also have an ObjectsCount property - perhaps the same to others, or not if they are a fixed number.

@ivan-mogilko
Copy link
Contributor Author

Not sure if I am missing this somewhere, but the Room struct in the Script API could also have an ObjectsCount property

There's is one already.

@ivan-mogilko
Copy link
Contributor Author

I added two global pointer arrays in addition to existing ones, since these are still in use:

import readonly WalkableArea *walkarea[AGS_MAX_WALKABLE_AREAS];
import readonly Walkbehind *walkbehind[AGS_MAX_WALKBEHINDS];

But also room properties for getting everything, as an alternative:

  /// Accesses the Hotspots in the current room.
  import static readonly attribute Hotspot *Hotspots[];
  /// Accesses the Objects in the current room.
  import static readonly attribute Object *Objects[];
  /// Accesses the Regions in the current room.
  import static readonly attribute Region *Regions[];
  /// Accesses the Walkable areas in the current room.
  import static readonly attribute WalkableArea *WalkableAreas[];
  /// Accesses the Walk-behinds in the current room.
  import static readonly attribute Walkbehind *Walkbehinds[];

@ivan-mogilko ivan-mogilko marked this pull request as ready for review January 21, 2024 23:44
@ivan-mogilko ivan-mogilko force-pushed the ags4--walkarea-ooapi branch 2 times, most recently from 042f4ab to f5844c6 Compare January 22, 2024 00:00
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gets/sets in the comment should just be Gets for ScalingMin and ScalingMax


// return the type name of the object
const char *CCWalkableArea::GetType() {
return "Walkarea";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be WalkableArea ?

#ifdef SCRIPT_API_v400
builtin managed struct Walkbehind {
/// Gets the walk-behind at the specified position on the screen.
import static WalkableArea* GetAtScreenXY(int x, int y); // $AUTOCOMPLETESTATICONLY$
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a Walkbehind pointer - and the next one too.

@ivan-mogilko ivan-mogilko merged commit 714ed3a into adventuregamestudio:ags4 Jan 28, 2024
20 checks passed
@ivan-mogilko ivan-mogilko deleted the ags4--walkarea-ooapi branch January 28, 2024 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ags 4 related to the ags4 development context: script api
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants