internal GlobalUIState(ImGuiSDL2CSWindow viewport) { ViewPort = viewport; PulsarGuiWindow._state = this; var windowPtr = viewport.Handle; SDL.SDL_SetHint(SDL.SDL_HINT_RENDER_DRIVER, "opengl"); //var surfacePtr = SDL.SDL_GetWindowSurface(windowPtr); rendererPtr = SDL.SDL_CreateRenderer(windowPtr, -1, SDL.SDL_RendererFlags.SDL_RENDERER_ACCELERATED); for (int i = 0; i < (int)UserOrbitSettings.OrbitBodyType.NumberOf; i++) { UserOrbitSettingsMtx.Add(new List <UserOrbitSettings>()); DrawNameZoomLvl.Add(100f); for (int j = 0; j < (int)UserOrbitSettings.OrbitTrajectoryType.NumberOf; j++) { UserOrbitSettingsMtx[i].Add(new UserOrbitSettings()); } } Camera = new Camera(viewport); MainMenuItems.GetInstance().IsActive = true; string rf = "Resources"; LoadImg("Logo", Path.Combine(rf, "PulsarLogo.bmp")); LoadImg("PlayImg", Path.Combine(rf, "Play.bmp")); LoadImg("PauseImg", Path.Combine(rf, "Pause.bmp")); LoadImg("OneStepImg", Path.Combine(rf, "OneStep.bmp")); LoadImg("UpImg", Path.Combine(rf, "UpArrow.bmp")); LoadImg("DnImg", Path.Combine(rf, "DnArrow.bmp")); LoadImg("RepeatImg", Path.Combine(rf, "RepeatIco.bmp")); LoadImg("CancelImg", Path.Combine(rf, "CancelIco.bmp")); /* * int gltxtrID; * GL.GenTextures(1, out gltxtrID); * GL.BindTexture(GL.Enum.GL_TEXTURE_2D, gltxtrID); * GL.PixelStorei(GL.Enum.GL_UNPACK_ROW_LENGTH, 0); * GL.TexImage2D(GL.Enum.GL_TEXTURE_2D, 0, (int)GL.Enum.GL_RGBA, 16, 16, 0, GL.Enum.GL_RGBA, GL.Enum.GL_UNSIGNED_BYTE, playImgPtr); * * GLImageDictionary["PlayImg"] = gltxtrID; * GL.Enable(GL.Enum.GL_TEXTURE_2D); */ }
internal override void Display() { if (IsActive) { if (ImGui.Begin("New Game Setup", ref IsActive, _flags)) { ImGui.InputText("Game Name", _nameInputBuffer, 16); ImGui.InputText("SM Pass", _smPassInputbuffer, 16); ImGui.InputText("Faction Name", _factionInputBuffer, 16); ImGui.InputText("Password", _passInputBuffer, 16); ImGui.InputInt("Max Systems", ref _maxSystems); ImGui.InputInt("Master Seed:", ref _masterSeed); if (ImGui.RadioButton("Host Network Game", ref _gameTypeButtonGrp, 1)) { _selectedGameType = gameType.Nethost; } if (ImGui.RadioButton("Start Standalone Game", ref _gameTypeButtonGrp, 0)) { _selectedGameType = gameType.Standalone; } if (_selectedGameType == gameType.Nethost) { ImGui.InputText("Network Port", _netPortInputBuffer, 8); } if (ImGui.Button("Create New Game!") || _uiState.debugnewgame) { _uiState.debugnewgame = false; CreateNewGame(); } ImGui.End(); } else { MainMenuItems.GetInstance().SetActive(); } } }
internal override void Display() { if (IsActive) { if (ImGui.Begin("New Game Setup", ref IsActive, _flags)) { ImGui.InputText("Game Name", _nameInputBuffer, (uint)_nameInputBuffer.Length); ImGui.InputText("Faction Name", _factionNameInputBuffer, 16); ImGui.InputText("Password", _passInputBuffer, 16); ImGui.InputInt("Max Systems", ref _maxSystems); ImGui.InputInt("Master Seed:", ref _masterSeed); if (ImGui.RadioButton("Host Network Game", ref _gameTypeButtonGrp, 1)) { _selectedGameType = gameType.Nethost; } if (ImGui.RadioButton("Start Standalone Game", ref _gameTypeButtonGrp, 0)) { _selectedGameType = gameType.Standalone; } if (_selectedGameType == gameType.Nethost) { ImGui.InputText("Network Port", _netPortInputBuffer, 8); } if (ImGui.Button("Create New Game!")) { CreateNewGame(System.Text.Encoding.UTF8.GetString(_nameInputBuffer)); } } else { MainMenuItems.GetInstance().IsActive = true; } ImGui.End(); } }
private bool MyEventHandler(SDL2Window window, SDL.SDL_Event e) { int mouseX; int mouseY; SDL.SDL_GetMouseState(out mouseX, out mouseY); if (!ImGuiSDL2CSHelper.HandleEvent(e, ref g_MouseWheel, g_MousePressed)) { return(false); } if (e.type == SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN && e.button.button == 1 & !ImGui.GetIO().WantCaptureMouse) { _state.Camera.IsGrabbingMap = true; _state.Camera.MouseFrameIncrementX = e.motion.x; _state.Camera.MouseFrameIncrementY = e.motion.y; mouseDownX = mouseX; mouseDownY = mouseY; } if (e.type == SDL.SDL_EventType.SDL_MOUSEBUTTONUP && e.button.button == 1) { _state.Camera.IsGrabbingMap = false; if (mouseDownX == mouseX && mouseDownY == mouseY) //click on map. { _state.MapClicked(_state.Camera.WorldCoordinate(mouseX, mouseY), MouseButtons.Primary); //sdl and imgu use different numbers for buttons. } } if (e.type == SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN && e.button.button == 3 & !ImGui.GetIO().WantCaptureMouse) { mouseDownAltX = mouseX; mouseDownAltY = mouseY; } if (e.type == SDL.SDL_EventType.SDL_MOUSEBUTTONUP && e.button.button == 3) { _state.Camera.IsGrabbingMap = false; if (mouseDownAltX == mouseX && mouseDownAltY == mouseY) //click on map. { _state.MapClicked(_state.Camera.WorldCoordinate(mouseX, mouseY), MouseButtons.Alt); //sdl and imgu use different numbers for buttons. } } if (_state.Camera.IsGrabbingMap) { int deltaX = _state.Camera.MouseFrameIncrementX - e.motion.x; int deltaY = _state.Camera.MouseFrameIncrementY - e.motion.y; _state.Camera.WorldOffset(deltaX, deltaY); _state.Camera.MouseFrameIncrementX = e.motion.x; _state.Camera.MouseFrameIncrementY = e.motion.y; } if (e.type == SDL.SDL_EventType.SDL_KEYUP) { if (e.key.keysym.sym == SDL.SDL_Keycode.SDLK_ESCAPE) { MainMenuItems mainMenu = MainMenuItems.GetInstance(); mainMenu.IsActive = true; } } if (e.type == SDL.SDL_EventType.SDL_MOUSEWHEEL) { if (e.wheel.y > 0) { _state.Camera.ZoomIn(mouseX, mouseY); } else if (e.wheel.y < 0) { _state.Camera.ZoomOut(mouseX, mouseY); } } return(true); }
internal GlobalUIState(ImGuiSDL2CSWindow viewport) { ViewPort = viewport; PulsarGuiWindow._uiState = this; var windowPtr = viewport.Handle; SDL.SDL_SetHint(SDL.SDL_HINT_RENDER_DRIVER, "opengl"); //var surfacePtr = SDL.SDL_GetWindowSurface(windowPtr); rendererPtr = SDL.SDL_CreateRenderer(windowPtr, -1, SDL.SDL_RendererFlags.SDL_RENDERER_ACCELERATED); for (int i = 0; i < (int)UserOrbitSettings.OrbitBodyType.NumberOf; i++) { UserOrbitSettingsMtx.Add(new List <UserOrbitSettings>()); DrawNameZoomLvl.Add(100f); for (int j = 0; j < (int)UserOrbitSettings.OrbitTrajectoryType.NumberOf; j++) { UserOrbitSettingsMtx[i].Add(new UserOrbitSettings()); } } Camera = new Camera(viewport); MainMenuItems.GetInstance().SetActive(); string rf = "Resources"; LoadImg("Logo", Path.Combine(rf, "PulsarLogo.bmp")); LoadImg("PlayImg", Path.Combine(rf, "Play.bmp")); LoadImg("PauseImg", Path.Combine(rf, "Pause.bmp")); LoadImg("OneStepImg", Path.Combine(rf, "OneStep.bmp")); LoadImg("UpImg", Path.Combine(rf, "UpArrow.bmp")); LoadImg("DnImg", Path.Combine(rf, "DnArrow.bmp")); LoadImg("RepeatImg", Path.Combine(rf, "RepeatIco.bmp")); LoadImg("CancelImg", Path.Combine(rf, "CancelIco.bmp")); LoadImg("DesComp", Path.Combine(rf, "DesignComponentIco.bmp")); LoadImg("DesShip", Path.Combine(rf, "DesignShipIco.bmp")); LoadImg("DesOrd", Path.Combine(rf, "DesignOrdnanceIco.bmp")); LoadImg("GalMap", Path.Combine(rf, "GalaxyMapIco.bmp")); LoadImg("Research", Path.Combine(rf, "ResearchIco.bmp")); LoadImg("Power", Path.Combine(rf, "PowerIco.bmp")); LoadImg("Ruler", Path.Combine(rf, "RulerIco.bmp")); LoadImg("Cargo", Path.Combine(rf, "CargoIco.bmp")); LoadImg("Firecon", Path.Combine(rf, "FireconIco.bmp")); LoadImg("Industry", Path.Combine(rf, "IndustryIco.bmp")); LoadImg("Pin", Path.Combine(rf, "PinIco.bmp")); LoadImg("Rename", Path.Combine(rf, "RenameIco.bmp")); LoadImg("Select", Path.Combine(rf, "SelectIco.bmp")); LoadImg("Tree", Path.Combine(rf, "TreeIco.bmp")); //DEBUG Code: (can be deleted); DamageTools.LoadFromBitMap(Path.Combine(rf, "ImgTest.bmp")); /* * int gltxtrID; * GL.GenTextures(1, out gltxtrID); * GL.BindTexture(GL.Enum.GL_TEXTURE_2D, gltxtrID); * GL.PixelStorei(GL.Enum.GL_UNPACK_ROW_LENGTH, 0); * GL.TexImage2D(GL.Enum.GL_TEXTURE_2D, 0, (int)GL.Enum.GL_RGBA, 16, 16, 0, GL.Enum.GL_RGBA, GL.Enum.GL_UNSIGNED_BYTE, playImgPtr); * * GLImageDictionary["PlayImg"] = gltxtrID; * GL.Enable(GL.Enum.GL_TEXTURE_2D); */ }