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

[FEATURE] Enums in Hscript #3801

Closed
wants to merge 4 commits into from
Closed

Conversation

lemz1
Copy link
Contributor

@lemz1 lemz1 commented Oct 28, 2024

DESCRIPTION

This pr aims to make it possible to import enums.
The macro creates "wrappers" around the actual enum.

EXPLANATION

For example funkin.ui.NavControls:
We create a class polymod.enums.funkin.ui.NavControls.
This class has all fields of funkin.ui.NavControls, and treats them as regular variables and functions, which call the respective fields from the actual funkin.ui.NavControls enum.
We then create an alias for funkin.ui.NavControls and make it point to polymod.enums.funkin.ui.NavControls.

EXAMPLES

import funkin.play.song.Song;
import funkin.ui.NavControls;

class ExampleSong extends Song
{
	function new()
	{
		super('exampleSong');
		
		trace(NavControls.Columns(5)); // Columns(5)
		trace(NavControls.Rows(5)); // Rows(5)
		trace(NavControls.Both); // Both

		trace(NavControls.Rows(5) == NavControls.Rows(3)); // false
		trace(NavControls.Rows(5) == NavControls.Rows(5)); // true
	}
}

TODO

  • Make all enums accessible
  • Make switch statements work

@lemz1 lemz1 marked this pull request as draft October 28, 2024 20:27
@github-actions github-actions bot added haxe Issue/PR modifies game code large A large pull request with more than 100 changes labels Oct 28, 2024
@lemz1 lemz1 closed this Oct 28, 2024
@lemz1 lemz1 deleted the polymod-enums branch October 28, 2024 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
haxe Issue/PR modifies game code large A large pull request with more than 100 changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants