181 lines
No EOL
6.5 KiB
C#
181 lines
No EOL
6.5 KiB
C#
using System;
|
|
using System.Numerics;
|
|
|
|
namespace Raylib_cs;
|
|
|
|
public sealed class Window : IDisposable
|
|
{
|
|
public event OnInit Init;
|
|
public event OnUpdate Update;
|
|
public event OnDraw Draw;
|
|
public event OnClose Close;
|
|
|
|
private int _width;
|
|
private int _height;
|
|
private string _title;
|
|
|
|
public Window(int width, int height, string title) {
|
|
this._width = width;
|
|
this._height = height;
|
|
this._title = title;
|
|
}
|
|
|
|
public void Run() {
|
|
Raylib.InitWindow(_width, _height, _title);
|
|
Init?.Invoke();
|
|
|
|
while (!ShouldClose()) {
|
|
Update?.Invoke();
|
|
|
|
Raylib.BeginDrawing();
|
|
Raylib.ClearBackground(Color.SKYBLUE);
|
|
Draw?.Invoke();
|
|
Raylib.EndDrawing();
|
|
}
|
|
|
|
Close?.Invoke();
|
|
Raylib.CloseWindow();
|
|
}
|
|
|
|
/// <inheritdoc cref="Raylib.WindowShouldClose"/>
|
|
public bool ShouldClose() => Raylib.WindowShouldClose();
|
|
|
|
/// <inheritdoc cref="Raylib.TakeScreenshot(string)"/>
|
|
public void TakeScreenshot(string path) => Raylib.TakeScreenshot(path);
|
|
|
|
|
|
/// <inheritdoc cref="Raylib.IsWindowReady"/>
|
|
public bool IsReady() => Raylib.IsWindowReady();
|
|
|
|
/// <inheritdoc cref="Raylib.IsWindowFullscreen"/>
|
|
public bool IsFullscreen() => Raylib.IsWindowFullscreen();
|
|
|
|
/// <inheritdoc cref="Raylib.IsWindowHidden"/>
|
|
public bool IsHidden() => Raylib.IsWindowHidden();
|
|
|
|
/// <inheritdoc cref="Raylib.IsWindowMinimized"/>
|
|
public bool IsMinimized() => Raylib.IsWindowMinimized();
|
|
|
|
/// <inheritdoc cref="Raylib.IsWindowMaximized"/>
|
|
public bool IsMaximized() => Raylib.IsWindowMaximized();
|
|
|
|
/// <inheritdoc cref="Raylib.IsWindowFocused"/>
|
|
public bool IsFocused() => Raylib.IsWindowFocused();
|
|
|
|
/// <inheritdoc cref="Raylib.IsWindowResized"/>
|
|
public bool IsResized() => Raylib.IsWindowResized();
|
|
|
|
/// <inheritdoc cref="Raylib.IsWindowState"/>
|
|
public bool IsState(ConfigFlags state) => Raylib.IsWindowState(state);
|
|
|
|
|
|
/// <inheritdoc cref="Raylib.SetWindowState"/>
|
|
public bool SetState(ConfigFlags state) => Raylib.SetWindowState(state);
|
|
|
|
/// <inheritdoc cref="Raylib.ClearWindowState"/>
|
|
public void ClearState(ConfigFlags state) => Raylib.ClearWindowState(state);
|
|
|
|
/// <inheritdoc cref="Raylib.ToggleFullscreen"/>
|
|
public void ToggleFullscreen() => Raylib.ToggleFullscreen();
|
|
|
|
/// <inheritdoc cref="Raylib.MaximizeWindow"/>
|
|
public void Maximize() => Raylib.MaximizeWindow();
|
|
|
|
/// <inheritdoc cref="Raylib.MinimizeWindow"/>
|
|
public void Minimize() => Raylib.MinimizeWindow();
|
|
|
|
/// <inheritdoc cref="Raylib.RestoreWindow"/>
|
|
public void Restore() => Raylib.RestoreWindow();
|
|
|
|
/// <inheritdoc cref="Raylib.SetWindowIcon"/>
|
|
public void SetIcon(Image image) => Raylib.SetWindowIcon(image);
|
|
|
|
/// <inheritdoc cref="Raylib.SetWindowIcons"/>
|
|
public unsafe void SetIcons(Image* images, int count) => Raylib.SetWindowIcons(images, count);
|
|
|
|
/// <inheritdoc cref="Raylib.SetWindowTitle(string)"/>
|
|
public void SetTitle(string title) => Raylib.SetWindowTitle(title);
|
|
|
|
/// <inheritdoc cref="Raylib.SetClipboardText(string)"/>
|
|
public void SetClipboardText(string path) => Raylib.SetClipboardText(path);
|
|
|
|
/// <inheritdoc cref="Raylib.SetWindowPosition"/>
|
|
public void SetPosition(int x, int y) => Raylib.SetWindowPosition(x, y);
|
|
|
|
/// <inheritdoc cref="Raylib.SetWindowMonitor"/>
|
|
public void SetMonitor(int monitor) => Raylib.SetWindowMonitor(monitor);
|
|
|
|
/// <inheritdoc cref="Raylib.SetWindowMinSize"/>
|
|
public void SetMinSize(int width, int height) => Raylib.SetWindowMinSize(width, height);
|
|
|
|
/// <inheritdoc cref="Raylib.SetWindowSize"/>
|
|
public void SetSize(int width, int height) => Raylib.SetWindowSize(width, height);
|
|
|
|
/// <inheritdoc cref="Raylib.SetWindowOpacity"/>
|
|
public void SetOpacity(float opacity) => Raylib.SetWindowOpacity(opacity);
|
|
|
|
/// <inheritdoc cref="Raylib.EnableEventWaiting"/>
|
|
public void EnableEventWaiting() => Raylib.EnableEventWaiting();
|
|
|
|
/// <inheritdoc cref="Raylib.DisableEventWaiting"/>
|
|
public void DisableEventWaiting() => Raylib.DisableEventWaiting();
|
|
|
|
|
|
/// <inheritdoc cref="Raylib.GetScreenWidth"/>
|
|
public int GetScreenWidth() => Raylib.GetScreenWidth();
|
|
|
|
/// <inheritdoc cref="Raylib.GetScreenHeight"/>
|
|
public int GetScreenHeight() => Raylib.GetScreenHeight();
|
|
|
|
/// <inheritdoc cref="Raylib.GetRenderWidth"/>
|
|
public int GetRenderWidth() => Raylib.GetRenderWidth();
|
|
|
|
/// <inheritdoc cref="Raylib.GetRenderHeight"/>
|
|
public int GetRenderHeight() => Raylib.GetRenderHeight();
|
|
|
|
/// <inheritdoc cref="Raylib.GetMonitorCount"/>
|
|
public int GetMonitorCount() => Raylib.GetMonitorCount();
|
|
|
|
/// <inheritdoc cref="Raylib.GetCurrentMonitor"/>
|
|
public int GetCurrentMonitor() => Raylib.GetCurrentMonitor();
|
|
|
|
/// <inheritdoc cref="Raylib.GetMonitorPosition"/>
|
|
public Vector2 GetMonitorPosition(int monitor) => Raylib.GetMonitorPosition(monitor);
|
|
|
|
/// <inheritdoc cref="Raylib.GetMonitorWidth"/>
|
|
public int GetMonitorWidth(int monitor) => Raylib.GetMonitorWidth(monitor);
|
|
|
|
/// <inheritdoc cref="Raylib.GetMonitorHeight"/>
|
|
public int GetMonitorHeight(int monitor) => Raylib.GetMonitorHeight(monitor);
|
|
|
|
/// <inheritdoc cref="Raylib.GetMonitorPhysicalWidth"/>
|
|
public int GetMonitorPhysicalWidth(int monitor) => Raylib.GetMonitorPhysicalWidth(monitor);
|
|
|
|
/// <inheritdoc cref="Raylib.GetMonitorPhysicalHeight"/>
|
|
public int GetMonitorPhysicalHeight(int monitor) => Raylib.GetMonitorPhysicalHeight(monitor);
|
|
|
|
/// <inheritdoc cref="Raylib.GetMonitorRefreshRate"/>
|
|
public int GetMonitorRefreshRate(int monitor) => Raylib.GetMonitorRefreshRate(monitor);
|
|
|
|
/// <inheritdoc cref="Raylib.GetWindowPosition"/>
|
|
public Vector2 GetPosition() => Raylib.GetWindowPosition();
|
|
|
|
/// <inheritdoc cref="Raylib.GetWindowScaleDPI"/>
|
|
public Vector2 GetScaleDpi() => Raylib.GetWindowScaleDPI();
|
|
|
|
/// <inheritdoc cref="Raylib.GetMonitorName_"/>
|
|
public string GetMonitorName(int monitor) => Raylib.GetMonitorName_(monitor);
|
|
|
|
/// <inheritdoc cref="Raylib.GetClipboardText_"/>
|
|
public string GetClipboardText() => Raylib.GetClipboardText_();
|
|
|
|
public delegate void OnInit();
|
|
|
|
public delegate void OnUpdate();
|
|
|
|
public delegate void OnDraw();
|
|
|
|
public delegate void OnClose();
|
|
|
|
public void Dispose() { }
|
|
} |