Skip to content

Latest commit

 

History

History
144 lines (108 loc) · 3.87 KB

File metadata and controls

144 lines (108 loc) · 3.87 KB

RaylibFishGfx

Raylib graphics and input backend for FishUI. Provides a complete, production-ready implementation using Raylib-cs.

.NET 9.0 License

Features

  • Complete IFishUIGfx Implementation - All 27+ methods implemented with native Raylib calls
  • RaylibInput - Full keyboard, mouse, and text input handling
  • Optimized - Native 9-patch, circles, texture filtering, and scissor clipping
  • Game Loop Integration - UseBeginDrawing option for existing game loops

Installation

dotnet add package FishUI
dotnet add package RaylibFishGfx

Quick Start

using FishUI;
using FishUI.Controls;
using RaylibFishGfx;
using Raylib_cs;

// Create Raylib backend
var gfx = new RaylibFishGfx(1280, 720, "My App");
var input = new RaylibInput();
var events = new MyEventHandler(); // Implement IFishUIEvents

// Initialize FishUI
var settings = new FishUISettings();
var fishUI = new FishUI.FishUI(settings, gfx, input, events);
fishUI.Init();

// Load theme
settings.LoadTheme("data/themes/gwen_default.yaml", applyImmediately: true);

// Add controls
var window = new Window
{
    Position = new Vector2(100, 100),
    Size = new Vector2(400, 300),
    Title = "Hello FishUI!"
};
fishUI.AddControl(window);

var button = new Button
{
    Position = new Vector2(20, 50),
    Size = new Vector2(120, 30),
    Text = "Click Me!"
};
button.OnButtonPressed += (btn, mbtn, pos) => Console.WriteLine("Clicked!");
window.AddChild(button);

// Main loop
while (!Raylib.WindowShouldClose())
{
    float dt = Raylib.GetFrameTime();
    fishUI.Tick(dt, (float)Raylib.GetTime());
}

Raylib.CloseWindow();

Integrating with Existing Game Loops

If you already have a Raylib game loop with BeginDrawing/EndDrawing:

var gfx = new RaylibFishGfx(1280, 720, "My Game");
gfx.UseBeginDrawing = false; // Don't call BeginDrawing/EndDrawing

while (!Raylib.WindowShouldClose())
{
    Raylib.BeginDrawing();
    Raylib.ClearBackground(Color.SkyBlue);
    
    // Draw your game here...
    DrawGame();
    
    // Draw UI on top
    fishUI.Tick(Raylib.GetFrameTime(), (float)Raylib.GetTime());
    
    Raylib.EndDrawing();
}

Classes

RaylibFishGfx

Complete graphics backend implementing SimpleFishUIGfx:

public class RaylibFishGfx : SimpleFishUIGfx
{
    // Constructor
    public RaylibFishGfx(int width, int height, string title);
    
    // Set to false when integrating with existing game loop
    public bool UseBeginDrawing { get; set; } = true;
}

RaylibInput

Input backend implementing IFishUIInput:

public class RaylibInput : IFishUIInput
{
    public FishInputState GetInputState();
}

Implemented Features

Feature Implementation
Window management Init(), GetWindowWidth(), GetWindowHeight(), FocusWindow()
Image loading Full image, cropped regions, sub-images
Font loading TTF fonts with size, spacing, color, monospace detection
Primitives Lines, rectangles, circles (filled & outline)
Images DrawTexture, DrawTexturePro, NPatch/9-slice
Text MeasureText, DrawText with color/scale
Clipping BeginScissorMode, EndScissorMode, push/pop stack
Filtering Point (pixelated) or Trilinear (smooth)

Links

License

MIT License - see LICENSE for details.