static void Main(string[] args) { Console.Title = "Nuklear SFML .NET"; Stopwatch SWatch = Stopwatch.StartNew(); VideoMode VMode = new VideoMode(1366, 768); RenderWindow RWind = new RenderWindow(VMode, Console.Title, Styles.Close); Color ClearColor = new Color(50, 50, 50); RWind.Closed += (S, E) => RWind.Close(); SFMLDevice Dev = new SFMLDevice(RWind); RWind.MouseButtonPressed += (S, E) => Dev.OnMouseButton((NuklearEvent.MouseButton)E.Button, E.X, E.Y, true); RWind.MouseButtonReleased += (S, E) => Dev.OnMouseButton((NuklearEvent.MouseButton)E.Button, E.X, E.Y, false); RWind.MouseMoved += (S, E) => Dev.OnMouseMove(E.X, E.Y); RWind.MouseWheelMoved += (S, E) => Dev.OnScroll(0, E.Delta); RWind.TextEntered += (S, E) => Dev.OnText(E.Unicode); RWind.KeyPressed += (S, E) => OnKey(Dev, E, true); RWind.KeyReleased += (S, E) => OnKey(Dev, E, false); NuklearAPI.Init(Dev); NuklearCalculator CalcA = new NuklearCalculator("Calc A", 50, 50); NuklearCalculator CalcB = new NuklearCalculator("Calc B", 300, 50); float Dt = 0.1f; while (RWind.IsOpen) { RWind.DispatchEvents(); RWind.Clear(ClearColor); NuklearAPI.SetDeltaTime(Dt); NuklearAPI.Frame(() => { if (CalcA.Open) { CalcA.Calculator(); } if (CalcB.Open) { CalcB.Calculator(); } TestWindow(400, 350); }); RWind.Display(); Dt = SWatch.ElapsedMilliseconds / 1000.0f; SWatch.Restart(); } Environment.Exit(0); }
public void Init(RenderWindow RWind, ShaderProgram GUIShader) { this.RWind = RWind; Docs = new List <FMLDocument>(); Dev = new FishGfxDevice(RWind.WindowSize, GUIShader); Dev.RegisterEvents(RWind); NuklearAPI.Init(Dev); }
public static void Init(NuklearDevice Dev) { NuklearAPI.Init(Dev); CalcA = new NuklearCalculator("Calc A", 50, 50); CalcB = new NuklearCalculator("Calc B", 300, 50); for (int i = 0; i < 30; i++) { ConsoleBuffer.AppendLine("LINE NUMBER " + i); } }
public void Init(RenderWindow RWind, ShaderProgram GUIShader) { this.RWind = RWind; Docs = new List <FMLDocument>(); Dev = new FishGfxDevice(RWind.WindowSize, GUIShader); Dev.RegisterEvents(RWind); NuklearAPI.Init(Dev); // TODO: Skinning ref nk_style style = ref NuklearAPI.Ctx->style;
static void LoadContent() { string GameDllPath = Path.Combine(CVar.GetString("game"), "Game.dll"); if (!File.Exists(GameDllPath)) { FatalError("File not found: {0}", GameDllPath); } Assembly GameAssembly = Reflect.LoadAssembly(GameDllPath); Importers.RegisterAll(GameAssembly); Type[] GameImplementations = Reflect.GetAllImplementationsOf(GameAssembly, typeof(LibTechGame)).ToArray(); if (GameImplementations.Length == 0) { FatalError("Could not find game implementation in {0}", GameDllPath); } if (GameImplementations.Length > 1) { FatalError("Found too many game implementations in {0}", GameDllPath); } Game = (LibTechGame)Activator.CreateInstance(GameImplementations[0]); Game.Load(); RenderDevice = new RenderDevice(ShaderProgram.GUI, Width, Height); NuklearAPI.Init(RenderDevice); NuklearAPI.SetClipboardCallback((Txt) => { if (string.IsNullOrEmpty(Txt)) { return; } Glfw.SetClipboardString(Window, Txt); }, () => { string Str = Glfw.GetClipboardString(Window); if (Str == null) { Str = ""; } return(Str); }); Glfw.SetCursorPosCallback(Window, (Wnd, X, Y) => { RenderDevice.OnMouseMove((int)X, (int)Y); }); Glfw.SetMouseButtonCallback(Window, (Wnd, Button, State, Mods) => { NuklearEvent.MouseButton NkButton; bool IsDown = State == Glfw.InputState.Press ? true : false; if (!(State == Glfw.InputState.Press || State == Glfw.InputState.Release)) { return; } if (Button == Glfw.MouseButton.ButtonLeft) { NkButton = NuklearEvent.MouseButton.Left; } else if (Button == Glfw.MouseButton.ButtonMiddle) { NkButton = NuklearEvent.MouseButton.Middle; } else if (Button == Glfw.MouseButton.ButtonRight) { NkButton = NuklearEvent.MouseButton.Right; } else { return; } RenderDevice.OnMouseButton(NkButton, (int)MousePos.X, (int)MousePos.Y, IsDown); }); Glfw.SetScrollCallback(Window, (Wnd, X, Y) => { RenderDevice.OnScroll((float)X, (float)Y); }); Glfw.SetCharCallback(Window, (Wnd, Chr) => { RenderDevice.OnText(((char)Chr).ToString()); }); Glfw.SetKeyCallback(Window, (Wnd, KCode, SCode, State, Mods) => { if (KCode == Glfw.KeyCode.F1 && State == Glfw.InputState.Press) { GConsole.Open = true; } NkKeys K = ConvertToNkKey(KCode, Mods); if (K != NkKeys.None) { RenderDevice.OnKey(K, State == Glfw.InputState.Press); if (State == Glfw.InputState.Repeat) { RenderDevice.OnKey(K, true); } } }); Glfw.SetDropCallback(Window, (Wnd, Cnt, Paths) => { DragDropPaths = Paths; }); }