Changeset 301c90a in opengl-game for vulkan-game.cpp
- Timestamp:
- Mar 13, 2021, 10:37:06 PM (3 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- d255d52
- Parents:
- 187b0f5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.cpp
r187b0f5 r301c90a 8 8 9 9 #include "IMGUI/imgui_impl_sdl.h" 10 #include "IMGUI/imgui_internal.h" // For CalcItemSize 10 11 11 12 #include "logger.hpp" 12 13 13 14 #include "utils.hpp" 15 16 #include "gui/imgui/button-imgui.hpp" 14 17 15 18 using namespace std; … … 854 857 } 855 858 859 // This was left ovedr from the previous SDL UI implementation. 860 // Might need something like this again when I start processing screen-specific UI events not related 861 // to the IMGUI ui, such as arrow keys for movement and other buttons for shotting or something 856 862 // currentScreen->handleEvent(e); 857 863 } … … 911 917 ImGui::NewFrame(); 912 918 913 (this->*currentRenderScreenFn)( );919 (this->*currentRenderScreenFn)(gui->getWindowWidth(), gui->getWindowHeight()); 914 920 915 921 ImGui::Render(); … … 2187 2193 } 2188 2194 2189 void VulkanGame::renderMainScreen() { 2190 unsigned int windowWidth = 640; 2191 unsigned int windowHeight = 480; 2192 2195 void VulkanGame::renderMainScreen(int width, int height) { 2193 2196 { 2194 2197 int padding = 4; 2195 ImGui::SetNextWindowPos( ImVec2(-padding, -padding), ImGuiCond_Once);2196 ImGui::SetNextWindowSize( ImVec2(windowWidth + 2 * padding, windowHeight + 2 * padding), ImGuiCond_Always);2198 ImGui::SetNextWindowPos(vec2(-padding, -padding), ImGuiCond_Once); 2199 ImGui::SetNextWindowSize(vec2(width + 2 * padding, height + 2 * padding), ImGuiCond_Always); 2197 2200 ImGui::Begin("WndMain", nullptr, 2198 2201 ImGuiWindowFlags_NoTitleBar | … … 2200 2203 ImGuiWindowFlags_NoMove); 2201 2204 2202 ImGui::InvisibleButton("", ImVec2(10, 80));2203 ImGui::InvisibleButton("", ImVec2(285, 18)); 2204 ImGui:: SameLine();2205 if ( ImGui::Button("New Game")) {2205 ButtonImGui btn("New Game"); 2206 2207 ImGui::InvisibleButton("", vec2(10, height / 6)); 2208 if (btn.draw((width - btn.getWidth()) / 2)) { 2206 2209 goToScreen(&VulkanGame::renderGameScreen); 2207 2210 } 2208 2211 2209 ImGui::InvisibleButton("", ImVec2(10, 15));2210 ImGui::InvisibleButton("", ImVec2(300, 18)); 2211 ImGui:: SameLine();2212 if ( ImGui::Button("Quit")) {2212 ButtonImGui btn2("Quit"); 2213 2214 ImGui::InvisibleButton("", vec2(10, 15)); 2215 if (btn2.draw((width - btn2.getWidth()) / 2)) { 2213 2216 quitGame(); 2214 2217 } … … 2218 2221 } 2219 2222 2220 void VulkanGame::renderGameScreen( ) {2223 void VulkanGame::renderGameScreen(int width, int height) { 2221 2224 { 2222 ImGui::SetNextWindowSize( ImVec2(130, 65), ImGuiCond_Once);2223 ImGui::SetNextWindowPos( ImVec2(10, 50), ImGuiCond_Once);2225 ImGui::SetNextWindowSize(vec2(130, 65), ImGuiCond_Once); 2226 ImGui::SetNextWindowPos(vec2(10, 50), ImGuiCond_Once); 2224 2227 ImGui::Begin("WndStats", nullptr, 2225 2228 ImGuiWindowFlags_NoTitleBar | … … 2234 2237 2235 2238 { 2236 ImGui::SetNextWindowSize( ImVec2(250, 35), ImGuiCond_Once);2237 ImGui::SetNextWindowPos( ImVec2(380, 10), ImGuiCond_Once);2239 ImGui::SetNextWindowSize(vec2(250, 35), ImGuiCond_Once); 2240 ImGui::SetNextWindowPos(vec2(width - 260, 10), ImGuiCond_Always); 2238 2241 ImGui::Begin("WndMenubar", nullptr, 2239 2242 ImGuiWindowFlags_NoTitleBar | 2240 2243 ImGuiWindowFlags_NoResize | 2241 2244 ImGuiWindowFlags_NoMove); 2242 ImGui::InvisibleButton("", ImVec2(155, 18));2245 ImGui::InvisibleButton("", vec2(155, 18)); 2243 2246 ImGui::SameLine(); 2244 2247 if (ImGui::Button("Main Menu")) { … … 2249 2252 2250 2253 { 2251 ImGui::SetNextWindowSize( ImVec2(200, 200), ImGuiCond_Once);2252 ImGui::SetNextWindowPos( ImVec2(430, 60), ImGuiCond_Once);2254 ImGui::SetNextWindowSize(vec2(200, 200), ImGuiCond_Once); 2255 ImGui::SetNextWindowPos(vec2(width - 210, 60), ImGuiCond_Always); 2253 2256 ImGui::Begin("WndDebug", nullptr, 2254 2257 ImGuiWindowFlags_NoTitleBar | … … 2267 2270 } 2268 2271 2272 // TODO: Probably turn this into a UI widget class 2269 2273 void VulkanGame::renderGuiValueList(vector<UIValue>& values) { 2270 2274 float maxWidth = 0.0f; … … 2304 2308 } 2305 2309 2306 void VulkanGame::goToScreen(void (VulkanGame::* renderScreenFn)( )) {2310 void VulkanGame::goToScreen(void (VulkanGame::* renderScreenFn)(int width, int height)) { 2307 2311 currentRenderScreenFn = renderScreenFn; 2308 2312
Note:
See TracChangeset
for help on using the changeset viewer.