diff options
| author | Sarah Duck <git@sarahduck.ca> | 2025-06-16 22:10:06 -0700 |
|---|---|---|
| committer | Sarah Duck <git@sarahduck.ca> | 2025-06-16 22:10:06 -0700 |
| commit | 48deeeabfd86cfc5b993936760e1332308a47ab2 (patch) | |
| tree | a2dd297bb356cad7792fe0f75de52f47685ee03f /Main.cs | |
| parent | c5b8b31dc7f29fd5512ac482cdffa2d274e6e01b (diff) | |
Optimizations, and Transparent Window!
Diffstat (limited to 'Main.cs')
| -rw-r--r-- | Main.cs | 30 |
1 files changed, 23 insertions, 7 deletions
@@ -16,15 +16,24 @@ static class OnekoOnline public static Vector2 Resolution => new(WindowX, WindowY); public static readonly bool SpectatorMode = Config.GetValue("SpectatorMode", false); + public static readonly bool HostServer = Config.GetValue("HostServer", false); + public static readonly bool TransparentWindow = Config.GetValue("TransparentWindow", false); public static Font DefaultFont; - const ConfigFlags raylibConfFlags = ConfigFlags.VSyncHint; + public static string AppTitle { + get => _appTitle; + set { + Raylib.SetWindowTitle(value); + _appTitle = value; + } + } + static string _appTitle = "Oneko Online"; public static void Main() { - Raylib.SetConfigFlags(raylibConfFlags); - Raylib.InitWindow(WindowX*WindowScale, WindowY*WindowScale, "OnekoOnline"); + if (TransparentWindow) Raylib.SetConfigFlags(ConfigFlags.TransparentWindow); + Raylib.InitWindow(WindowX*WindowScale, WindowY*WindowScale, AppTitle); Raylib.SetTargetFPS(30); Raylib.HideCursor(); @@ -36,13 +45,16 @@ static class OnekoOnline int port = Config.GetValue("ServerPort", 42069); string serverPassword = Config.GetValue("ServerPassword", ""); - if (Config.GetValue("HostServer", false)) { + if (HostServer) { Server = new(port, Config.GetValue("ServerMaxUsers", 32)); Client = new("127.0.0.1", port, serverPassword); } else { string Address = Config.GetValue("ServerIP", "pond.sarahduck.ca"); - if (string.IsNullOrEmpty(Address)) Console.WriteLine("Server IP empty or invalid, you're offline."); + if (string.IsNullOrEmpty(Address)) { + Console.WriteLine("Server IP empty or invalid, you're offline."); + AppTitle = "Oneko Offline"; + } else Client = new(Address, port, serverPassword); } Net.Client.UserConnected += OnekoNet.SpawnNetNeko; @@ -50,6 +62,9 @@ static class OnekoOnline DefaultFont = Raylib.LoadFont("misc/MPlusBitmap.fnt"); + Color BackgroundColor = Color.Gray; + if (TransparentWindow) BackgroundColor = BackgroundColor with {A = 0}; + while (!Raylib.WindowShouldClose()) { //Poll networking @@ -58,15 +73,16 @@ static class OnekoOnline Raylib.BeginTextureMode(RenderTexture); - Raylib.ClearBackground(Color.Gray); + Raylib.ClearBackground(BackgroundColor); Raylib.DrawTextEx(DefaultFont, "こんにちは", new(17,18), 11, 0, Color.White); - Raylib.DrawText("Oneko Online", 10, 9, 8, Color.White); + Raylib.DrawText(AppTitle, 10, 9, 8, Color.White); Drawable.DrawAll(); Raylib.EndTextureMode(); Raylib.BeginDrawing(); + if (TransparentWindow) Raylib.ClearBackground(Color.Blank); //Dunno why, but it renders upside down, so I flip it here Raylib.DrawTexturePro(RenderTexture.Texture, new Rectangle(0f,0f,WindowX,-WindowY), new Rectangle(0,0,WindowX*WindowScale,WindowY*WindowScale), Vector2.Zero,0f,Color.White); Raylib.EndDrawing(); |
