mirror of
https://github.com/raylib-cs/raylib-cs
synced 2025-10-13 04:51:53 -04:00
Explicit core types and autonomous types. (#304)
* All the "var" variables were changed to explicit types on the raylib class * "MakeDirectory" overload, and string version of "GetApplicationDirectory" and "GetWorkingDirectory" methods * Added "Dimensions" property to "Texture2D" * New overloads for the "LoadFileData" and "SaveFileData" methods * 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" * Added new extension "byte.Lerp" * Added new extension "Log" for "TraceLogLevel" * Constructors on Color no longer just truncate the float value, but also round it (+ 0.5f) * New static method on Color, "Color.Lerp" * Added static method "FromHSV" to Color * Added new getter method "GetHSV" on Color * Added index security on the FilePathList indexer * Added Rectangle extension * Added "MoveTowards" extensions to RaylibExtensions * Added "TranslateLocal" and "TranslateGlobal" to Transform * Removed unnecessary "partial" declarations * Updating calls and docs * Moved the "AudioCallback" delegate into the "AudioMixed.cs" File * Properties and structs marked as read-only on the "Model.cs" file * Updated the "README.md" to mentions Raylib-cs targets net6.0 and net8.0 (and also explicitly added that the "STAThread" attribute comes from the "System" namespace) * Added a few sizing utils to "Rectangle" * Added "GetScreenCenter" to "Raylib.Utils"
This commit is contained in:
@@ -29,7 +29,7 @@ internal readonly struct Native
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
struct VaListLinuxX64
|
||||
internal struct VaListLinuxX64
|
||||
{
|
||||
uint _gpOffset;
|
||||
uint _fpOffset;
|
||||
@@ -42,10 +42,10 @@ struct VaListLinuxX64
|
||||
/// </summary>
|
||||
public static unsafe class Logging
|
||||
{
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
|
||||
[UnmanagedCallersOnly(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
|
||||
public static unsafe void LogConsole(int msgType, sbyte* text, sbyte* args)
|
||||
{
|
||||
var message = GetLogMessage(new IntPtr(text), new IntPtr(args));
|
||||
string message = GetLogMessage(new IntPtr(text), new IntPtr(args));
|
||||
Console.WriteLine(message);
|
||||
}
|
||||
|
||||
@@ -62,13 +62,13 @@ public static unsafe class Logging
|
||||
return LinuxX64LogCallback(format, args);
|
||||
}
|
||||
|
||||
var byteLength = VsnPrintf(IntPtr.Zero, UIntPtr.Zero, format, args) + 1;
|
||||
int byteLength = VsnPrintf(IntPtr.Zero, UIntPtr.Zero, format, args) + 1;
|
||||
if (byteLength <= 1)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var buffer = Marshal.AllocHGlobal(byteLength);
|
||||
IntPtr buffer = Marshal.AllocHGlobal(byteLength);
|
||||
VsPrintf(buffer, format, args);
|
||||
|
||||
string result = Marshal.PtrToStringUTF8(buffer);
|
||||
@@ -77,12 +77,12 @@ public static unsafe class Logging
|
||||
return result;
|
||||
}
|
||||
|
||||
static string AppleLogCallback(IntPtr format, IntPtr args)
|
||||
private static string AppleLogCallback(IntPtr format, IntPtr args)
|
||||
{
|
||||
IntPtr buffer = IntPtr.Zero;
|
||||
try
|
||||
{
|
||||
var count = Native.VasPrintfApple(ref buffer, format, args);
|
||||
int count = Native.VasPrintfApple(ref buffer, format, args);
|
||||
if (count == -1)
|
||||
{
|
||||
return string.Empty;
|
||||
@@ -95,10 +95,10 @@ public static unsafe class Logging
|
||||
}
|
||||
}
|
||||
|
||||
static string LinuxX64LogCallback(IntPtr format, IntPtr args)
|
||||
private static string LinuxX64LogCallback(IntPtr format, IntPtr args)
|
||||
{
|
||||
// The args pointer cannot be reused between two calls. We need to make a copy of the underlying structure.
|
||||
var listStructure = Marshal.PtrToStructure<VaListLinuxX64>(args);
|
||||
VaListLinuxX64 listStructure = Marshal.PtrToStructure<VaListLinuxX64>(args);
|
||||
IntPtr listPointer = IntPtr.Zero;
|
||||
int byteLength = 0;
|
||||
string result = "";
|
||||
@@ -125,9 +125,9 @@ public static unsafe class Logging
|
||||
}
|
||||
|
||||
// https://github.com/dotnet/runtime/issues/51052
|
||||
static int VsnPrintf(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args)
|
||||
private static int VsnPrintf(IntPtr buffer, UIntPtr size, IntPtr format, IntPtr args)
|
||||
{
|
||||
var os = Environment.OSVersion;
|
||||
OperatingSystem os = Environment.OSVersion;
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
return Native.VsnPrintfWindows(buffer, size, format, args);
|
||||
@@ -144,7 +144,7 @@ public static unsafe class Logging
|
||||
}
|
||||
|
||||
// https://github.com/dotnet/runtime/issues/51052
|
||||
static int VsPrintf(IntPtr buffer, IntPtr format, IntPtr args)
|
||||
private static int VsPrintf(IntPtr buffer, IntPtr format, IntPtr args)
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
|
Reference in New Issue
Block a user