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] Add a string method for OpenURL and SetGamepadMappings #178

Closed
3 tasks done
MrScautHD opened this issue Jul 29, 2023 · 5 comments
Closed
3 tasks done

[Feature] Add a string method for OpenURL and SetGamepadMappings #178

MrScautHD opened this issue Jul 29, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@MrScautHD
Copy link
Contributor

MrScautHD commented Jul 29, 2023

Before submitting a new issue, please verify and check:

  • The issue is specific to Raylib-cs and not raylib
  • I checked there is no similar issue already reported
  • My code has no errors or misuse of Raylib-cs

Issue description

Hello, i saw by the methods OpenURL and SetGamepadMappings that there is just a method that takes sbyte* i would suggest to do a second method with a string value.

And i found another thing, you could use instead of try/finally:

You use:

    public static unsafe int MeasureText(string text, int fontSize)
    {
      UTF8Buffer utF8Buffer = text.ToUTF8Buffer();
      try
      {
        return Raylib.MeasureText(utF8Buffer.AsPointer(), fontSize);
      }
      finally
      {
        utF8Buffer.Dispose();
      }
    }

What i suggest:

    public static unsafe int MeasureText(string text, int fontSize)
    {
        using (UTF8Buffer buffer = text.ToUTF8Buffer())
        {
            return Raylib.MeasureText(buffer.AsPointer(), fontSize);
        }
    }

What i suggest (smallest):

    public static unsafe int MeasureText(string text, int fontSize) {
        using UTF8Buffer buffer = text.ToUTF8Buffer();
        return Raylib.MeasureText(buffer.AsPointer(), fontSize);
    }

That would Dispose it to and it would smaller.

@MrScautHD
Copy link
Contributor Author

Let me know if you like my idea so i doing a PR.

@9ParsonsB
Copy link
Collaborator

We are more then happy to accept pull requests, though we already use your suggested method:

https://github.com/ChrisDill/Raylib-cs/blob/master/Raylib-cs/types/Raylib.Utils.cs#L886

@MrScautHD
Copy link
Contributor Author

We are more then happy to accept pull requests, though we already use your suggested method:

https://github.com/ChrisDill/Raylib-cs/blob/master/Raylib-cs/types/Raylib.Utils.cs#L886

ohhh, if i download it on nuget it doing it like that.... lol

@MrScautHD
Copy link
Contributor Author

I wanna create laiter a pull for the string value

@MrScautHD
Copy link
Contributor Author

Merged: #180

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

No branches or pull requests

3 participants