question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Add a string method for `OpenURL` and `SetGamepadMappings`

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 2 months ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
9ParsonsBcommented, Jul 30, 2023

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

0reactions
MrScautHDcommented, Aug 4, 2023
Read more comments on GitHub >

github_iconTop Results From Across the Web

[core] Add function to update gamepad mappings #1506
I was thinking naming it SetGamepadMappings or UpdateGamepadMappings . Code Example. RLAPI int SetGamepadMappings(const char *mappings); ...
Read more >
raylib.h - raysan5
A simple and easy-to-use library to enjoy videogames programming - raylib/src/raylib.h at master · raysan5/raylib.
Read more >
raylib - cheatsheet
raylib is a simple and easy-to-use library to enjoy videogames programming. Don't miss latest functions added to raylib... check raylib cheatsheet.
Read more >
2 Generated Raylib Bindings
Encode text as codepoints array into UTF-8 text string (WARNING: memory must be freed!) procedure. ( ...
Read more >
rl
Package raylib - Go bindings for raylib, a simple and easy-to-use library to learn videogames programming.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found