summaryrefslogtreecommitdiff
path: root/Main.cs
blob: 8b3e9bef45f24201d5623f5258693cae9bb6727c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System.Numerics;
using Raylib_cs;

namespace OnekoOnline;

static class OnekoOnline
{
    public static readonly ConfigFile Config = new("config.conf");

    const ConfigFlags raylibConfFlags = 
        //ConfigFlags.FLAG_WINDOW_UNDECORATED |
        //ConfigFlags.FLAG_WINDOW_TRANSPARENT |
        //ConfigFlags.FLAG_WINDOW_MOUSE_PASSTHROUGH |
        //ConfigFlags.FLAG_WINDOW_TOPMOST |
        //ConfigFlags.FLAG_WINDOW_RESIZABLE |
        ConfigFlags.FLAG_VSYNC_HINT;
    
    public static void Main()
    {
        Raylib.SetConfigFlags(raylibConfFlags);
        Raylib.InitWindow(640, 480, "OnekoOnline");
        Raylib.SetTargetFPS(30);
        //Raylib.MaximizeWindow();

        Oneko LocalOneko = new();

        RenderTexture2D RenderTexture = Raylib.LoadRenderTexture(320,240);

        int port = Config.GetValue("ServerPort", 42069);
        if (Config.GetValue("HostServer", false)) {
            Net.Server.Init(port);
            Net.Client.Init("127.0.0.1", port);
        } else {
            Net.Client.Init(Config.GetValue("ServerIP", "pond.sarahduck.ca"), port);
        }

        while (!Raylib.WindowShouldClose())
        {
            Raylib.BeginTextureMode(RenderTexture);

            Raylib.ClearBackground(Color.GRAY);
            Raylib.DrawText("Oneko Online",12, 12, 8, Color.WHITE);

            Drawable.DrawAll();

            Raylib.EndTextureMode();

            Raylib.BeginDrawing();
            Raylib.DrawTexturePro(RenderTexture.Texture, new Rectangle(0f,0f,320,-240), new Rectangle(0,0,640,480), Vector2.Zero,0f,Color.WHITE);
            Raylib.EndDrawing();
        }

        Drawable.DisposeAll();
        Raylib.CloseWindow();
        Config.SaveFile();
    }
}