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

chore: clean up linter warnings

This commit is contained in:
tiger tiger tiger 2026-07-29 19:58:47 +02:00
commit dfc34997bc
No known key found for this signature in database
217 changed files with 1863 additions and 1077 deletions

View file

@ -13,11 +13,7 @@
*
********************************************************************************************/
using System.Numerics;
using System.Linq;
using System.Globalization;
using System.Collections.Generic;
using static Raylib_cs.Raylib;
namespace Examples.Text;

View file

@ -17,9 +17,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Text;
public partial class FontFilters : IExample

View file

@ -22,9 +22,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Text;
public partial class FontLoading : IExample

View file

@ -13,11 +13,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using System.Runtime.InteropServices;
using static Raylib_cs.Raylib;
namespace Examples.Text;
public partial class FontSdf : IExample

View file

@ -23,9 +23,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Text;
public partial class FontSpritefont : IExample

View file

@ -13,8 +13,6 @@
*
********************************************************************************************/
using static Raylib_cs.Raylib;
namespace Examples.Text;
public partial class FormatText : IExample

View file

@ -15,11 +15,7 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using System.Text;
using Raylib_cs;
using static Raylib_cs.Raylib;
namespace Examples.Text;
@ -170,7 +166,10 @@ public partial class InlineStyling : IExample
colHexText.Append(ch);
colHexCount++;
}
else break; // Only affects while loop
else
{
break; // Only affects while loop
}
}
// Convert hex color text into actual Color
@ -192,11 +191,20 @@ public partial class InlineStyling : IExample
int index = GetGlyphIndex(font, codepoint);
float increaseX = 0.0f;
if (font.Glyphs[index].AdvanceX == 0) increaseX = (font.Recs[index].Width * scaleFactor + spacing);
else increaseX += (font.Glyphs[index].AdvanceX * scaleFactor + spacing);
if (font.Glyphs[index].AdvanceX == 0)
{
increaseX = (font.Recs[index].Width * scaleFactor + spacing);
}
else
{
increaseX += (font.Glyphs[index].AdvanceX * scaleFactor + spacing);
}
// Draw background rectangle color (if required)
if (colBack.A > 0) DrawRectangleRec(new Rectangle(position.X + textOffsetX, position.Y + textOffsetY - backRecPadding, increaseX, fontSize + 2 * backRecPadding), colBack);
if (colBack.A > 0)
{
DrawRectangleRec(new Rectangle(position.X + textOffsetX, position.Y + textOffsetY - backRecPadding, increaseX, fontSize + 2 * backRecPadding), colBack);
}
if ((codepoint != ' ') && (codepoint != '\t'))
{
@ -217,7 +225,10 @@ public partial class InlineStyling : IExample
{
Vector2 textSize = new(0, 0);
if ((font.Texture.Id == 0) || (text == null) || (text.Length == 0)) return textSize; // Security check
if ((font.Texture.Id == 0) || (text == null) || (text.Length == 0))
{
return textSize; // Security check
}
using var textNative = new Utf8Buffer(text);
sbyte* t = textNative.AsPointer();
@ -257,7 +268,10 @@ public partial class InlineStyling : IExample
{
colHexCount++;
}
else break; // Only affects while loop
else
{
break; // Only affects while loop
}
}
i += (colHexCount + 1); // Skip color value retrieved and ']'
@ -268,8 +282,14 @@ public partial class InlineStyling : IExample
{
index = GetGlyphIndex(font, codepoint);
if (font.Glyphs[index].AdvanceX > 0) textWidth += font.Glyphs[index].AdvanceX;
else textWidth += (font.Recs[index].Width + font.Glyphs[index].OffsetX);
if (font.Glyphs[index].AdvanceX > 0)
{
textWidth += font.Glyphs[index].AdvanceX;
}
else
{
textWidth += (font.Recs[index].Width + font.Glyphs[index].OffsetX);
}
validCodepointCounter++;
i += codepointByteCount;

View file

@ -13,8 +13,6 @@
*
********************************************************************************************/
using static Raylib_cs.Raylib;
namespace Examples.Text;
public partial class InputBox : IExample

View file

@ -16,9 +16,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Text;
public partial class RaylibFonts : IExample

View file

@ -15,9 +15,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Text;
public partial class RectangleBounds : IExample

View file

@ -15,12 +15,7 @@
*
********************************************************************************************/
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Text;
using Raylib_cs;
using static Raylib_cs.Raylib;
namespace Examples.Text;
@ -135,12 +130,35 @@ public partial class StringsManagement : IExample
}
// Reset using TextTo* functions
if (IsKeyPressed(KeyboardKey.One)) PrepareFirstTextParticle("raylib => fun videogames programming!");
if (IsKeyPressed(KeyboardKey.Two)) PrepareFirstTextParticle(TextToUpper("raylib => fun videogames programming!"));
if (IsKeyPressed(KeyboardKey.Three)) PrepareFirstTextParticle(TextToLower("raylib => fun videogames programming!"));
if (IsKeyPressed(KeyboardKey.Four)) PrepareFirstTextParticle(TextToPascal("raylib_fun_videogames_programming"));
if (IsKeyPressed(KeyboardKey.Five)) PrepareFirstTextParticle(TextToSnake("RaylibFunVideogamesProgramming"));
if (IsKeyPressed(KeyboardKey.Six)) PrepareFirstTextParticle(TextToCamel("raylib_fun_videogames_programming"));
if (IsKeyPressed(KeyboardKey.One))
{
PrepareFirstTextParticle("raylib => fun videogames programming!");
}
if (IsKeyPressed(KeyboardKey.Two))
{
PrepareFirstTextParticle(TextToUpper("raylib => fun videogames programming!"));
}
if (IsKeyPressed(KeyboardKey.Three))
{
PrepareFirstTextParticle(TextToLower("raylib => fun videogames programming!"));
}
if (IsKeyPressed(KeyboardKey.Four))
{
PrepareFirstTextParticle(TextToPascal("raylib_fun_videogames_programming"));
}
if (IsKeyPressed(KeyboardKey.Five))
{
PrepareFirstTextParticle(TextToSnake("RaylibFunVideogamesProgramming"));
}
if (IsKeyPressed(KeyboardKey.Six))
{
PrepareFirstTextParticle(TextToCamel("raylib_fun_videogames_programming"));
}
// Slice by char pressed only when we have one text particle
int charPressed = GetCharPressed();

View file

@ -28,11 +28,7 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using System.Text;
using Raylib_cs;
using static Raylib_cs.Raylib;
namespace Examples.Text;
@ -182,8 +178,16 @@ public partial class Text3D : IExample
}
// Handle Events
if (IsKeyPressed(KeyboardKey.F1)) showLetterBoundry = !showLetterBoundry;
if (IsKeyPressed(KeyboardKey.F2)) showTextBoundry = !showTextBoundry;
if (IsKeyPressed(KeyboardKey.F1))
{
showLetterBoundry = !showLetterBoundry;
}
if (IsKeyPressed(KeyboardKey.F2))
{
showTextBoundry = !showTextBoundry;
}
if (IsKeyPressed(KeyboardKey.F3))
{
// Handle camera change
@ -226,18 +230,50 @@ public partial class Text3D : IExample
}
// Handle text layers changes
if (IsKeyPressed(KeyboardKey.Home)) { if (layers > 1) --layers; }
else if (IsKeyPressed(KeyboardKey.End)) { if (layers < TextMaxLayers) ++layers; }
if (IsKeyPressed(KeyboardKey.Home)) { if (layers > 1)
{
--layers;
}
}
else if (IsKeyPressed(KeyboardKey.End)) { if (layers < TextMaxLayers)
{
++layers;
}
}
// Handle text changes
if (IsKeyPressed(KeyboardKey.Left)) fontSize -= 0.5f;
else if (IsKeyPressed(KeyboardKey.Right)) fontSize += 0.5f;
else if (IsKeyPressed(KeyboardKey.Up)) fontSpacing -= 0.1f;
else if (IsKeyPressed(KeyboardKey.Down)) fontSpacing += 0.1f;
else if (IsKeyPressed(KeyboardKey.PageUp)) lineSpacing -= 0.1f;
else if (IsKeyPressed(KeyboardKey.PageDown)) lineSpacing += 0.1f;
else if (IsKeyDown(KeyboardKey.Insert)) layerDistance -= 0.001f;
else if (IsKeyDown(KeyboardKey.Delete)) layerDistance += 0.001f;
if (IsKeyPressed(KeyboardKey.Left))
{
fontSize -= 0.5f;
}
else if (IsKeyPressed(KeyboardKey.Right))
{
fontSize += 0.5f;
}
else if (IsKeyPressed(KeyboardKey.Up))
{
fontSpacing -= 0.1f;
}
else if (IsKeyPressed(KeyboardKey.Down))
{
fontSpacing += 0.1f;
}
else if (IsKeyPressed(KeyboardKey.PageUp))
{
lineSpacing -= 0.1f;
}
else if (IsKeyPressed(KeyboardKey.PageDown))
{
lineSpacing += 0.1f;
}
else if (IsKeyDown(KeyboardKey.Insert))
{
layerDistance -= 0.001f;
}
else if (IsKeyDown(KeyboardKey.Delete))
{
layerDistance += 0.001f;
}
else if (IsKeyPressed(KeyboardKey.Tab))
{
multicolor = !multicolor; // Enable /disable multicolor mode
@ -258,17 +294,26 @@ public partial class Text3D : IExample
if (IsKeyPressed(KeyboardKey.Backspace))
{
// Remove last char
if (text.Length > 0) text = text.Substring(0, text.Length - 1);
if (text.Length > 0)
{
text = text.Substring(0, text.Length - 1);
}
}
else if (IsKeyPressed(KeyboardKey.Enter))
{
// handle newline
if (text.Length < 63) text += '\n';
if (text.Length < 63)
{
text += '\n';
}
}
else
{
// append only printable chars
if ((ch != 0) && (text.Length < 63)) text += char.ConvertFromUtf32(ch);
if ((ch != 0) && (text.Length < 63))
{
text += char.ConvertFromUtf32(ch);
}
}
// Measure 3D text so we can center it
@ -302,12 +347,20 @@ public partial class Text3D : IExample
for (int i = 0; i < layers; i++)
{
Color clr = light;
if (multicolor) clr = multi[i];
if (multicolor)
{
clr = multi[i];
}
DrawTextWave3D(font, text, new Vector3(-tbox.X / 2.0f, layerDistance * i, -4.5f), fontSize, fontSpacing, lineSpacing, true, wcfg, time, clr);
}
// Draw the text boundry if set
if (showTextBoundry) DrawCubeWiresV(new Vector3(0.0f, 0.0f, -4.5f + tbox.Z / 2), tbox, dark);
if (showTextBoundry)
{
DrawCubeWiresV(new Vector3(0.0f, 0.0f, -4.5f + tbox.Z / 2), tbox, dark);
}
Rlgl.PopMatrix();
// Don't draw the letter boundries for the 3D text below
@ -490,7 +543,10 @@ public partial class Text3D : IExample
float tw = (srcRec.X + srcRec.Width) / font.Texture.Width;
float th = (srcRec.Y + srcRec.Height) / font.Texture.Height;
if (showLetterBoundry) DrawCubeWiresV(new Vector3(position.X + width / 2, position.Y, position.Z + height / 2), new Vector3(width, LetterBoundrySize, height), LetterBoundryColor);
if (showLetterBoundry)
{
DrawCubeWiresV(new Vector3(position.X + width / 2, position.Y, position.Z + height / 2), new Vector3(width, LetterBoundrySize, height), LetterBoundryColor);
}
Rlgl.CheckRenderBatchLimit(4 + 4 * (backface ? 1 : 0));
Rlgl.SetTexture(font.Texture.Id);
@ -545,7 +601,10 @@ public partial class Text3D : IExample
// NOTE: Normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f)
// but we need to draw all of the bad bytes using the '?' symbol moving one byte
if (codepoint == 0x3f) codepointByteCount = 1;
if (codepoint == 0x3f)
{
codepointByteCount = 1;
}
if (codepoint == '\n')
{
@ -561,8 +620,14 @@ public partial class Text3D : IExample
DrawTextCodepoint3D(font, codepoint, new Vector3(position.X + textOffsetX, position.Y, position.Z + textOffsetY), fontSize, backface, tint);
}
if (font.Glyphs[index].AdvanceX == 0) textOffsetX += font.Recs[index].Width * scale + fontSpacing;
else textOffsetX += font.Glyphs[index].AdvanceX * scale + fontSpacing;
if (font.Glyphs[index].AdvanceX == 0)
{
textOffsetX += font.Recs[index].Width * scale + fontSpacing;
}
else
{
textOffsetX += font.Glyphs[index].AdvanceX * scale + fontSpacing;
}
}
i += codepointByteCount; // Move text bytes counter to next codepoint
@ -593,7 +658,10 @@ public partial class Text3D : IExample
// NOTE: Normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f)
// but we need to draw all of the bad bytes using the '?' symbol moving one byte
if (codepoint == 0x3f) codepointByteCount = 1;
if (codepoint == 0x3f)
{
codepointByteCount = 1;
}
if (codepoint == '\n')
{
@ -626,8 +694,14 @@ public partial class Text3D : IExample
DrawTextCodepoint3D(font, codepoint, new Vector3(pos.X + textOffsetX, pos.Y, pos.Z + textOffsetY), fontSize, backface, tint);
}
if (font.Glyphs[index].AdvanceX == 0) textOffsetX += font.Recs[index].Width * scale + fontSpacing;
else textOffsetX += font.Glyphs[index].AdvanceX * scale + fontSpacing;
if (font.Glyphs[index].AdvanceX == 0)
{
textOffsetX += font.Recs[index].Width * scale + fontSpacing;
}
else
{
textOffsetX += font.Glyphs[index].AdvanceX * scale + fontSpacing;
}
}
i += codepointByteCount; // Move text bytes counter to next codepoint
@ -660,7 +734,11 @@ public partial class Text3D : IExample
// NOTE: normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f)
// but we need to draw all of the bad bytes using the '?' symbol so to not skip any we set next = 1
if (letter == 0x3f) next = 1;
if (letter == 0x3f)
{
next = 1;
}
i += next - 1;
if (letter != '\n')
@ -672,22 +750,38 @@ public partial class Text3D : IExample
else
{
lenCounter++;
if (font.Glyphs[index].AdvanceX != 0) textWidth += font.Glyphs[index].AdvanceX * scale;
else textWidth += (font.Recs[index].Width + font.Glyphs[index].OffsetX) * scale;
if (font.Glyphs[index].AdvanceX != 0)
{
textWidth += font.Glyphs[index].AdvanceX * scale;
}
else
{
textWidth += (font.Recs[index].Width + font.Glyphs[index].OffsetX) * scale;
}
}
}
else
{
if (tempTextWidth < textWidth) tempTextWidth = textWidth;
if (tempTextWidth < textWidth)
{
tempTextWidth = textWidth;
}
lenCounter = 0;
textWidth = 0.0f;
textHeight += fontSize + lineSpacing;
}
if (tempLen < lenCounter) tempLen = lenCounter;
if (tempLen < lenCounter)
{
tempLen = lenCounter;
}
}
if (tempTextWidth < textWidth) tempTextWidth = textWidth;
if (tempTextWidth < textWidth)
{
tempTextWidth = textWidth;
}
Vector3 vec = new(0, 0, 0);
vec.X = tempTextWidth + ((tempLen - 1) * fontSpacing); // Adds chars spacing to measure

View file

@ -15,10 +15,6 @@
*
********************************************************************************************/
using System.Numerics;
using Raylib_cs;
using static Raylib_cs.Raylib;
namespace Examples.Text;
public partial class UnicodeRanges : IExample
@ -115,11 +111,26 @@ public partial class UnicodeRanges : IExample
SetTextureFilter(font.Texture, TextureFilter.Bilinear); // Set font atlas scale filter
}
if (IsKeyPressed(KeyboardKey.Zero)) unicodeRange = 0;
else if (IsKeyPressed(KeyboardKey.One)) unicodeRange = 1;
else if (IsKeyPressed(KeyboardKey.Two)) unicodeRange = 2;
else if (IsKeyPressed(KeyboardKey.Three)) unicodeRange = 3;
else if (IsKeyPressed(KeyboardKey.Four)) unicodeRange = 4;
if (IsKeyPressed(KeyboardKey.Zero))
{
unicodeRange = 0;
}
else if (IsKeyPressed(KeyboardKey.One))
{
unicodeRange = 1;
}
else if (IsKeyPressed(KeyboardKey.Two))
{
unicodeRange = 2;
}
else if (IsKeyPressed(KeyboardKey.Three))
{
unicodeRange = 3;
}
else if (IsKeyPressed(KeyboardKey.Four))
{
unicodeRange = 4;
}
//else if (IsKeyPressed(KeyboardKey.Five)) unicodeRange = 5;
//----------------------------------------------------------------------------------
@ -185,11 +196,16 @@ public partial class UnicodeRanges : IExample
int[] updatedCodepoints = new int[updatedCodepointCount];
// Get current codepoint list
for (int i = 0; i < currentRangeSize; i++) updatedCodepoints[i] = font.Glyphs[i].Value;
for (int i = 0; i < currentRangeSize; i++)
{
updatedCodepoints[i] = font.Glyphs[i].Value;
}
// Add new codepoints to list (provided range)
for (int i = currentRangeSize; i < updatedCodepointCount; i++)
{
updatedCodepoints[i] = start + (i - currentRangeSize);
}
UnloadFont(font);
font = LoadFontEx(fontPath, 32, updatedCodepoints, updatedCodepointCount);

View file

@ -15,8 +15,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
using static Raylib_cs.Raymath; // Required for: Lerp()
namespace Examples.Text;
@ -81,29 +79,47 @@ public partial class WordsAlignment : IExample
//----------------------------------------------------------------------------------
if (IsKeyPressed(KeyboardKey.Left))
{
if (hAlign > 0) hAlign = hAlign - 1;
if (hAlign > 0)
{
hAlign = hAlign - 1;
}
}
if (IsKeyPressed(KeyboardKey.Right))
{
hAlign = hAlign + 1;
if (hAlign > 2) hAlign = 2;
if (hAlign > 2)
{
hAlign = 2;
}
}
if (IsKeyPressed(KeyboardKey.Up))
{
if (vAlign > 0) vAlign = vAlign - 1;
if (vAlign > 0)
{
vAlign = vAlign - 1;
}
}
if (IsKeyPressed(KeyboardKey.Down))
{
vAlign = vAlign + 1;
if (vAlign > 2) vAlign = 2;
if (vAlign > 2)
{
vAlign = 2;
}
}
// One word per second
if (wordCount > 0) wordIndex = (int)GetTime() % wordCount;
else wordIndex = 0;
if (wordCount > 0)
{
wordIndex = (int)GetTime() % wordCount;
}
else
{
wordIndex = 0;
}
//----------------------------------------------------------------------------------
// Draw

View file

@ -13,8 +13,6 @@
*
********************************************************************************************/
using static Raylib_cs.Raylib;
namespace Examples.Text;
public partial class WritingAnim : IExample