mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
feat(main_menu): add exit button and refactor layout with ColumnLayout
- Add `should_close_window()` method to force window close from UI. - Replace standalone button with ColumnLayout for proper centering. - Add "Exit" button that calls `should_close_window()`. - Update ESC key handling to only close window when game is not running. - Fix ColumnLayout to respect parent's anchor instead of hardcoded TOP_LEFT. - Remove unused parameter name in Image::update for consistency.
This commit is contained in:
@@ -73,8 +73,10 @@ bool Window::handle_key_event(const KeyEvent& e) {
|
||||
return true;
|
||||
}
|
||||
if (e.key == Key::ESCAPE && e.action == KeyAction::PRESS) {
|
||||
glfwSetWindowShouldClose(m_window, GLFW_TRUE);
|
||||
return true;
|
||||
if (!m_game_running) {
|
||||
glfwSetWindowShouldClose(m_window, GLFW_TRUE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (e.key == Key::LEFT_ALT && e.action == KeyAction::PRESS) {
|
||||
toggle_mouse_able();
|
||||
@@ -237,6 +239,9 @@ void Window::set_game_running(bool running) {
|
||||
m_mouse_enable = running;
|
||||
toggle_mouse_able();
|
||||
}
|
||||
|
||||
void Window::should_close_window() { glfwSetWindowShouldClose(m_window, true); }
|
||||
|
||||
void Window::imgui_init() {
|
||||
float dpi_scale_x, dpi_scale_y;
|
||||
glfwGetWindowContentScale(m_window, &dpi_scale_x, &dpi_scale_y);
|
||||
|
||||
Reference in New Issue
Block a user