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

Cursors #252

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft

Cursors #252

wants to merge 9 commits into from

Conversation

Nemrav
Copy link
Contributor

@Nemrav Nemrav commented Aug 20, 2024

Draft, loads cursors, animated and not animated, handles switching between cursors.
Currently contains code just for testing/demoing: right click the mouse to cycle through loaded cursors. The watch is set as an i-beam cursor so that you can try hovering over a text field (ex. in the new-game menu) to observe how the Cursor Manager handles auto-switching between animated cursors.

Loading of the cursors and generating new resolutions handled by the c++ side CursorSingleton. Managing what frame to display, and when to switch cursors handled by gdscript side CursorManager. This architecture is because we want a c++ dataloader, but we also need to listen to the scene tree to know when its safe to call a hardware cursor change.

Possible improvements:

  • Doesn't support the full image spec (unhandled things like 16bit colour images that vic2 doesn't use)
  • Might want to change how I handle collecting both .cur and .CUR files in the loading function (perhaps a new, "ignore-case" parameter for .lookup_files_in_dir_recursive?
  • CursorManager creates a new compat_Cursor inner class whenever we switch cursors, which re-fetches the cursor stored in CursorSingleton. We can store a list of all compat_cursors to avoid this.

@Nemrav Nemrav added the enhancement New feature or request label Aug 20, 2024
Copy link
Contributor

@Hop311 Hop311 left a comment

Choose a reason for hiding this comment

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

Some random comments from looking through the code (not form proper testing yet)

Comment on lines 46 to 47
std::optional<godot::TypedArray<float>> displayRates;
std::optional<godot::TypedArray<int>> sequence;
Copy link
Contributor

Choose a reason for hiding this comment

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

Godot has special Packed***Array types that are faster and more space-efficient than regular arrays full of the same value type:

  • PackedByteArray - array of uint8_ts
  • PackedColorArray - array of Colors (so basically Vector4s)
  • PackedFloat32Array - array of floats
  • PackedFloat64Array - array of doubles
  • PackedInt32Array - array of int32_ts
  • PackedInt64Array - array of int64_t
  • PackedStringArray - array of godot::Strings
  • PackedVector2Array - array of Vector2s (2 floats)
  • PackedVector3Array - array of Vector3s (3 floats)
  • PackedVector4Array - array of Vector4s (4 floats)

So here it would be best to use godot::PackedFloat32Array and godot::PackedInt32Array. Unfortunately there isn't a PackedVector2iArray we could use for resolutions, so that will have to stay as a regular array (unless you're able to switch to using float-based Vector2s? Tbh probably not worth it anyway).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the change to PackedFloat and Ints. You probably could use Vector2s instead of Vector2is, so I'll leave this unresolved in case you really do want that.


using namespace godot;
using namespace OpenVic;
using namespace OpenVic::NodeTools;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed in this file?

Copy link
Contributor Author

@Nemrav Nemrav Sep 15, 2024

Choose a reason for hiding this comment

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

We do use godot for various datatypes. Namespace OpenVic is used for GameSingleton access only to my knowledge.
Removed NodeTools because it is completely unused.
Tell me if you want the using namespace Openvic; removed, and to just use the double colon where appropriate instead.

game/src/Game/GameStart.gd Outdated Show resolved Hide resolved
game/src/Game/GameStart.gd Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants