Watch
2
0
Fork
You've already forked raylib-cs
0

Ordering readings

Added "SaveFileData" overload to "Raylib.Utils"
Moved "SaveFileText" from "RaylibExtensions" to "Raylib.Utils"
Moved "LoadFileText" from "RaylibExtensions" to "Raylib.Utils"
Raymath's const "NativeLibName" is now referencing to "Raylib.NativeLibName"
Color constructors are more readable
Added "Dimensions" property to "Image"
Changed all the "var" for explicit types on the "Logging" class
Changed "Int64" for "long" on CBool, and using constructor on the operators instead setting the value manually
Added indexer to "FilePathLists"
Changed all "var" for explicit types on "Utf8Buffer"
New "GetRandomSequence" method overloads in "Raylib.Utils" acepting "int" and "float"
This commit is contained in:
Matorio 2025-07-15 17:17:41 -05:00
commit 9811c0d129
11 changed files with 140 additions and 60 deletions

View file

@ -1,4 +1,3 @@
using System;
using System.Runtime.InteropServices;
namespace Raylib_cs;
@ -13,8 +12,8 @@ public readonly struct CBool
* which can be later implicitely cast onto any type during usage.
*
* It is wise to note that C booleans are any numeric value, but allocating an
* Int64 for every CBool instance is.. well, wildly memory-inefficient. Yes, the
* process is basically treated as a 0-cost instantiation, but it's better to rely
* Int64 (long) for every CBool instance is.. well, wildly memory-inefficient. Yes,
* the process is basically treated as a 0-cost instantiation, but it's better to rely
* on explicit motivation than to blindly trust the runtime judgement on its memory
* management.
*
@ -30,7 +29,7 @@ public readonly struct CBool
{
this.Value = (sbyte)(value ? 1 : 0);
}
public CBool(Int64 value)
public CBool(long value)
{
this.Value = (sbyte)(value != 0 ? 1 : 0);
}
@ -45,20 +44,20 @@ public readonly struct CBool
// Allows for CBools to be implicitely assigned to a native boolean variable.
public static implicit operator bool(CBool x)
{
return x.Value != 0 ? true : false;
return x.Value != 0;
}
// Native -> CBool
// Allows native booleans to be implicitely constructed into CBools while passing parameters.
public static implicit operator CBool(bool x)
{
return new CBool { Value = (sbyte)(x ? 1 : 0) };
return new CBool(x);
}
// Same goes for integer numeric values (any value, so an Int64 is used).
public static implicit operator CBool(Int64 x)
public static implicit operator CBool(long x)
{
return new CBool { Value = (sbyte)(x != 0 ? 1 : 0) };
return new CBool(x);
}
/* Arithmetic overloads

View file

@ -22,4 +22,12 @@ public unsafe struct FilePathList
/// Filepaths entries
/// </summary>
public byte** Paths;
public string this[uint i]
{
get
{
return Marshal.PtrToStringUTF8((System.IntPtr)Paths[i]);
}
}
}

View file

@ -41,10 +41,10 @@ public static class Utf8StringUtils
return null;
}
var length = Encoding.UTF8.GetByteCount(text);
int length = Encoding.UTF8.GetByteCount(text);
var byteArray = new byte[length + 1];
var wrote = Encoding.UTF8.GetBytes(text, 0, text.Length, byteArray, 0);
byte[] byteArray = new byte[length + 1];
int wrote = Encoding.UTF8.GetBytes(text, 0, text.Length, byteArray, 0);
byteArray[wrote] = 0;
return byteArray;