From 0d8577194b287feec41e8877ecd732da3560b209 Mon Sep 17 00:00:00 2001 From: Thelie Date: Thu, 25 Aug 2022 16:12:07 +0200 Subject: [PATCH] Corrected formatting by running `format-files.sh` script. --- src/MainMenu.cxx | 68 ++++++++++++++++++------------ src/engine/Layout.hxx | 2 +- src/engine/UIManager.cxx | 38 +++++++---------- src/engine/UIManager.hxx | 25 +++++------ src/engine/WindowManager.cxx | 7 ++- src/engine/basics/Camera.cxx | 3 +- src/engine/basics/GameStates.hxx | 3 +- src/engine/basics/tileData.hxx | 20 +++++---- src/game/ui/BuildMenu.hxx | 32 ++++++++------ src/game/ui/GameTimeMenu.cxx | 18 +++++--- src/game/ui/LoadMenu.cxx | 27 ++++++++---- src/game/ui/LoadMenu.hxx | 3 +- src/game/ui/PauseMenu.cxx | 11 +++-- src/game/ui/SettingsMenu.cxx | 45 +++++++++++--------- src/scripting/ImGuiAngelscript.cxx | 3 +- src/services/AudioMixer.cxx | 8 ++-- 16 files changed, 178 insertions(+), 135 deletions(-) diff --git a/src/MainMenu.cxx b/src/MainMenu.cxx index e2b4e22f67..9b45fd8d1c 100644 --- a/src/MainMenu.cxx +++ b/src/MainMenu.cxx @@ -60,7 +60,8 @@ bool mainMenu() int logoTexW, logoTexH; SDL_QueryTexture(logoTex, nullptr, nullptr, &logoTexW, &logoTexH); - auto beginFrame = [] { + auto beginFrame = [] + { SDL_RenderClear(WindowManager::instance().getRenderer()); WindowManager::instance().newImGuiFrame(); @@ -70,10 +71,13 @@ bool mainMenu() ui::SetNextWindowSize(ui::GetIO().DisplaySize); bool open = true; - ui::Begin("MainWnd", &open, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse); + ui::Begin("MainWnd", &open, + ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | + ImGuiWindowFlags_NoScrollWithMouse); }; - auto renderFrame = [] { + auto renderFrame = [] + { ui::End(); WindowManager::instance().renderScreen(); @@ -86,7 +90,7 @@ bool mainMenu() { beginFrame(); - // break the loop if an event occurs + // break the loop if an event occurs const bool has_event = SDL_PollEvent(&event) != 0; if (has_event && event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_KEYDOWN) opacity = 254; @@ -107,10 +111,12 @@ bool mainMenu() { beginFrame(); - while (SDL_PollEvent(&event) != 0) { // while there is a pending event + while (SDL_PollEvent(&event) != 0) + { // while there is a pending event ImGui_ImplSDL2_ProcessEvent(&event); - if (event.type == SDL_QUIT) { + if (event.type == SDL_QUIT) + { startGame = false; mainMenuLoop = false; } @@ -119,23 +125,24 @@ bool mainMenu() if (showLoadDialog) { loadMenu.draw(); - switch (loadMenu.result()) { - case LoadMenu::e_close: - showLoadDialog = false; - break; - - case LoadMenu::e_load_file: - #ifdef USE_AUDIO - playAudioMajorSelection(); - #endif // USE_AUDIO - SignalMediator::instance().signalLoadGame.emit(loadMenu.filename()); - mainMenuLoop = false; - break; - default: - break; + switch (loadMenu.result()) + { + case LoadMenu::e_close: + showLoadDialog = false; + break; + + case LoadMenu::e_load_file: +#ifdef USE_AUDIO + playAudioMajorSelection(); +#endif // USE_AUDIO + SignalMediator::instance().signalLoadGame.emit(loadMenu.filename()); + mainMenuLoop = false; + break; + default: + break; } } - else + else { ui::PushFont(buttonFont); ui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); @@ -147,23 +154,26 @@ bool mainMenu() constexpr int buttonInterval = 20; ImVec2 buttonPos(screenWidth / 2 - buttonSize.x / 2, screenHeight / 2 - buttonSize.y); ui::SetCursorPos(buttonPos); - if (ui::ButtonCt("New Game", buttonSize)) { - #ifdef USE_AUDIO + if (ui::ButtonCt("New Game", buttonSize)) + { +#ifdef USE_AUDIO playAudioMajorSelection(); - #endif // USE_AUDIO +#endif // USE_AUDIO mainMenuLoop = false; SignalMediator::instance().signalNewGame.emit(true); } buttonPos.y += buttonSize.y + buttonInterval; ui::SetCursorPos(buttonPos); - if (ui::ButtonCt("Load Game", buttonSize)) { + if (ui::ButtonCt("Load Game", buttonSize)) + { showLoadDialog = true; } buttonPos.y += buttonSize.y + buttonInterval; ui::SetCursorPos(buttonPos); - if (ui::ButtonCt("Quit Game", buttonSize)) { + if (ui::ButtonCt("Quit Game", buttonSize)) + { startGame = false; mainMenuLoop = false; } @@ -171,13 +181,15 @@ bool mainMenu() constexpr int xOffset = 5, btnSize = 32; ImVec2 leftBottom(xOffset, screenHeight - btnSize - xOffset * 2); ui::SetCursorPos(leftBottom); - if (ui::ImageButton(discordTex, ImVec2(btnSize, btnSize))) { + if (ui::ImageButton(discordTex, ImVec2(btnSize, btnSize))) + { OSystem::openDir("https://discord.gg/MG3tgYV6ce"); } leftBottom.x += xOffset * 2 + btnSize; // xOffset * 2 because, need interval between buttons ui::SetCursorPos(leftBottom); - if (ui::ImageButton(githubTex, ImVec2(btnSize, btnSize))) { + if (ui::ImageButton(githubTex, ImVec2(btnSize, btnSize))) + { OSystem::openDir("https://github.com/CytopiaTeam/Cytopia/issues/new"); } diff --git a/src/engine/Layout.hxx b/src/engine/Layout.hxx index 690a7571dd..5b503a507a 100644 --- a/src/engine/Layout.hxx +++ b/src/engine/Layout.hxx @@ -15,7 +15,7 @@ struct LayoutData int groupHeight = 0; ///< height of all elements in group int groupWidth = 0; ///< Width of all elements in group uint32_t fontSize = 20; ///< default font size of all elements in group - struct ImFont *font = nullptr; ///< font pointer for elements + struct ImFont *font = nullptr; ///< font pointer for elements }; #endif diff --git a/src/engine/UIManager.cxx b/src/engine/UIManager.cxx index 025faf02f2..0555586219 100644 --- a/src/engine/UIManager.cxx +++ b/src/engine/UIManager.cxx @@ -66,7 +66,8 @@ ImFont *UIManager::loadFont(const std::string &fontPath, uint32_t size) return newFont; } -void UIManager::initializeImGuiFonts() { +void UIManager::initializeImGuiFonts() +{ std::string fontPath = fs::getBasePath() + Settings::instance().fontFileName.get(); // fix for macos, need to use abs path const auto names = {"MainMenuButtons", "PauseMenuButtons", "LoadDialogButtons", "BuildMenuButtons"}; @@ -74,13 +75,14 @@ void UIManager::initializeImGuiFonts() { { if (const auto it = m_layouts.find(name); it != m_layouts.end()) { - auto &layout = it->second; - layout.font = loadFont(fontPath, layout.fontSize); + auto &layout = it->second; + layout.font = loadFont(fontPath, layout.fontSize); } } } -void UIManager::loadSettings(json& uiLayout) { +void UIManager::loadSettings(json &uiLayout) +{ std::string jsonFileContent = fs::readFileAsString(Settings::instance().uiLayoutJSONFile.get()); uiLayout = json::parse(jsonFileContent, nullptr, false); @@ -89,7 +91,7 @@ void UIManager::loadSettings(json& uiLayout) { throw ConfigurationError(TRACE_INFO "Error parsing JSON File " + Settings::instance().uiLayoutJSONFile.get()); } -void UIManager::parseLayouts(const json& uiLayout) +void UIManager::parseLayouts(const json &uiLayout) { // parse Layout for (const auto &it : uiLayout["LayoutGroups"].items()) @@ -137,9 +139,7 @@ void UIManager::parseLayouts(const json& uiLayout) } } -void UIManager::setFPSCounterText(const std::string &fps) { - m_fpsCounter = fps; -} +void UIManager::setFPSCounterText(const std::string &fps) { m_fpsCounter = fps; } void UIManager::closeOpenMenus() { @@ -179,10 +179,7 @@ void UIManager::addPersistentMenu(GameMenu::Ptr menu) } } -bool UIManager::isMouseHovered() const -{ - return ImGui::IsAnyItemHovered(); -} +bool UIManager::isMouseHovered() const { return ImGui::IsAnyItemHovered(); } void UIManager::drawUI() { @@ -199,7 +196,8 @@ void UIManager::drawUI() m->draw(); } - if (!m_tooltip.empty()) { + if (!m_tooltip.empty()) + { ImVec2 pos = ui::GetMousePos(); ui::SetCursorScreenPos(pos); ui::Text(m_tooltip.c_str()); @@ -211,7 +209,9 @@ void UIManager::drawUI() ui::SetNextWindowSize(ImVec2(140, 20)); bool open = true; - ui::Begin("##fpswindow", &open, ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse); + ui::Begin("##fpswindow", &open, + ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoScrollbar | + ImGuiWindowFlags_NoScrollWithMouse); ui::Text(m_fpsCounter.c_str()); ui::SameLine(); ui::Checkbox("debug", &m_showDebugMenu); @@ -219,12 +219,6 @@ void UIManager::drawUI() } } -void UIManager::setTooltip(const std::string &tooltipText) -{ - m_tooltip = tooltipText; -} +void UIManager::setTooltip(const std::string &tooltipText) { m_tooltip = tooltipText; } -void UIManager::clearTooltip() -{ - m_tooltip.clear(); -} \ No newline at end of file +void UIManager::clearTooltip() { m_tooltip.clear(); } \ No newline at end of file diff --git a/src/engine/UIManager.hxx b/src/engine/UIManager.hxx index b718b9a19a..c089e77454 100644 --- a/src/engine/UIManager.hxx +++ b/src/engine/UIManager.hxx @@ -12,9 +12,13 @@ struct GameMenu { using Ptr = std::shared_ptr; virtual ~GameMenu() = default; - virtual void draw() const { /* default implementation do nothing */ } + virtual void draw() const + { /* default implementation do nothing */ + } virtual bool isMouseHovered() const { return false; } - virtual void closeSubmenus() { /* default implementation do nothing */ } + virtual void closeSubmenus() + { /* default implementation do nothing */ + } }; struct BuildMenu; @@ -47,7 +51,7 @@ public: struct ImFont *loadFont(const std::string &name, uint32_t size); void initializeImGuiFonts(); - void loadSettings(json& uiLayout); + void loadSettings(json &uiLayout); void parseLayouts(const json &uiLayout); /** @@ -75,7 +79,7 @@ public: std::unordered_map &getLayouts() { return m_layouts; } void setTooltip(const std::string &tooltipText); - + /** * @brief Hides and resets the active tooltip. * @see Tooltip#reset @@ -89,8 +93,7 @@ public: void openMenu(GameMenu::Ptr menuOption); - template - void openMenu() { openMenu(std::make_shared()); } + template void openMenu() { openMenu(std::make_shared()); } void closeMenu(); inline bool isAnyMenuOpen() const { return !m_menuStack.empty(); } @@ -99,8 +102,8 @@ public: bool isMouseHovered() const; - template - inline GameMenu::Ptr findMenu() const { + template inline GameMenu::Ptr findMenu() const + { for (const auto &m : m_menuStack) { if (dynamic_cast(m.get())) @@ -119,15 +122,13 @@ public: return nullptr; } - - template - void addPersistentMenu() { addPersistentMenu(std::make_shared()); } + + template void addPersistentMenu() { addPersistentMenu(std::make_shared()); } BUILDMENU_LAYOUT buildMenuLayout() const { return m_buildMenuLayout; } void setBuildMenuLayout(BUILDMENU_LAYOUT l) { m_buildMenuLayout = l; } private: - UIManager() = default; ~UIManager() = default; diff --git a/src/engine/WindowManager.cxx b/src/engine/WindowManager.cxx index 4cac1a827c..6f9d6efcc6 100644 --- a/src/engine/WindowManager.cxx +++ b/src/engine/WindowManager.cxx @@ -36,8 +36,7 @@ WindowManager::WindowManager() if (!m_window) throw UIError(TRACE_INFO "Failed to create window: " + string{SDL_GetError()}); - rendererFlags = SDL_RENDERER_ACCELERATED - | (Settings::instance().vSync ? SDL_RENDERER_PRESENTVSYNC : 0); + rendererFlags = SDL_RENDERER_ACCELERATED | (Settings::instance().vSync ? SDL_RENDERER_PRESENTVSYNC : 0); #if defined(TESTING_ENABLED) && defined(__linux) // Set the index to 2 for running tests @@ -179,7 +178,7 @@ void WindowManager::initializeImguiRenderer() ImGui_ImplSDLRenderer_Init(m_renderer); } -void WindowManager::destroyImGuiRenderer() +void WindowManager::destroyImGuiRenderer() { ImGui_ImplSDLRenderer_Shutdown(); ImGui_ImplSDL2_Shutdown(); @@ -226,7 +225,7 @@ void WindowManager::newImGuiFrame() { ImGui_ImplSDLRenderer_NewFrame(); ImGui_ImplSDL2_NewFrame(); - ImGui::NewFrame(); + ImGui::NewFrame(); } void WindowManager::renderScreen() diff --git a/src/engine/basics/Camera.cxx b/src/engine/basics/Camera.cxx index f791094890..aecc2f2db2 100644 --- a/src/engine/basics/Camera.cxx +++ b/src/engine/basics/Camera.cxx @@ -88,7 +88,8 @@ void Camera::moveCamera(int xOffset, int yOffset) m_CameraOffset.y -= yOffset; MapFunctions::instance().refreshVisibleMap(); // update center coordinates - m_CenterIsoCoordinates = convertScreenToIsoCoordinates({Settings::instance().screenWidth / 2, Settings::instance().screenHeight / 2}); + m_CenterIsoCoordinates = + convertScreenToIsoCoordinates({Settings::instance().screenWidth / 2, Settings::instance().screenHeight / 2}); } const SDL_Point &Camera::cameraOffset() const noexcept { return m_CameraOffset; } diff --git a/src/engine/basics/GameStates.hxx b/src/engine/basics/GameStates.hxx index d524e3f749..8927b9ce36 100644 --- a/src/engine/basics/GameStates.hxx +++ b/src/engine/basics/GameStates.hxx @@ -13,7 +13,8 @@ struct GameStatesData { bool drawUI = true; ///< Draw UI. This is a temporary variable until the new UI has been implemented. bool rectangularRoads = false; ///< place rectangular road tiles instead of diagonal tiles - LayerEditMode layerEditMode = LayerEditMode::TERRAIN; ///< Specifies the Layer Editmode. Editing Terrain or Blueprint (water pipes, subway,..) + LayerEditMode layerEditMode = + LayerEditMode::TERRAIN; ///< Specifies the Layer Editmode. Editing Terrain or Blueprint (water pipes, subway,..) PlacementMode placementMode = PlacementMode::LINE; ///< Specifies the placement mode when holding down the mouse DemolishMode demolishMode = DemolishMode::DEFAULT; }; diff --git a/src/engine/basics/tileData.hxx b/src/engine/basics/tileData.hxx index 43ef28cbcd..29d3e6778b 100644 --- a/src/engine/basics/tileData.hxx +++ b/src/engine/basics/tileData.hxx @@ -134,13 +134,16 @@ template <> struct hash /// Holds all releavted information to this specific tile struct TileData { - std::string id; ///< The ID of this item. Must be unique and can be referenced in the code. - std::string author; ///< The author of this item - std::string category; ///< The category this item resides in. Categories are used for the building menu in-game and for sorting the items in the editors tree view - std::string subCategory; ///< subcategories are used for the building menu in-game and for sorting the items in the editors tree view - uint8_t buildingsize; ///< the size that the building occupies in tiles. - std::vector biomes; ///< Restrict this building to spawn only in the given biomes. Must correspond to a biome defined in resources/data/TerrainGen.json - std::vector tags; ///< Tags to filter buildings in the gui + std::string id; ///< The ID of this item. Must be unique and can be referenced in the code. + std::string author; ///< The author of this item + std::string + category; ///< The category this item resides in. Categories are used for the building menu in-game and for sorting the items in the editors tree view + std::string + subCategory; ///< subcategories are used for the building menu in-game and for sorting the items in the editors tree view + uint8_t buildingsize; ///< the size that the building occupies in tiles. + std::vector + biomes; ///< Restrict this building to spawn only in the given biomes. Must correspond to a biome defined in resources/data/TerrainGen.json + std::vector tags; ///< Tags to filter buildings in the gui TileSetData tiles; ///< Tile Spritesheet information TileType tileType = TileType::DEFAULT; ///< @todo: String for now, should be an enum @@ -153,7 +156,8 @@ struct TileData int power = 0; ///< power production / consumption if negative int water = 0; ///< water production / consumption if negative - std::vector groundDecoration; ///< tileID of the item that should be drawn on ground below sprite instead of terrain(grass, concrete, ...). Must be a tileID with tileType GroundDecoration + std::vector + groundDecoration; ///< tileID of the item that should be drawn on ground below sprite instead of terrain(grass, concrete, ...). Must be a tileID with tileType GroundDecoration bool placeOnGround = true; ///< whether or not this building is placeable on ground bool placeOnWater = false; ///< whether or not this building is placeable on water bool isOverPlacable; ///< Determines if other tiles can be placed over this one tile. diff --git a/src/game/ui/BuildMenu.hxx b/src/game/ui/BuildMenu.hxx index d0e59fd8b3..4c4909883b 100644 --- a/src/game/ui/BuildMenu.hxx +++ b/src/game/ui/BuildMenu.hxx @@ -6,28 +6,29 @@ struct TileData; -struct BuildMenuButton { +struct BuildMenuButton +{ using Ptr = std::shared_ptr; using Items = std::vector; - bool m_open = false; // draw subbuttons - bool m_background = false; // draw background + bool m_open = false; // draw subbuttons + bool m_background = false; // draw background - std::string m_texstr; // texture name - std::string m_id; // unique id - std::string m_action; // additional action - std::string m_tiletype; // which tiletype place on map + std::string m_texstr; // texture name + std::string m_id; // unique id + std::string m_action; // additional action + std::string m_tiletype; // which tiletype place on map - SDL_Texture *m_tex; // sdl texture + SDL_Texture *m_tex; // sdl texture ImVec2 m_uv0 = ImVec2{0, 0}; - ImVec2 m_uv1 = ImVec2{1, 1}; // texture sub coords - ImSpan2i m_texSize; // texutre size + ImVec2 m_uv1 = ImVec2{1, 1}; // texture sub coords + ImSpan2i m_texSize; // texutre size BuildMenuButton *m_parent = nullptr; // parent button, need for recursive logic - ImVec4 m_destRect; // texture additional offsets - ImVec2 m_btnSize; // button frame rect + ImVec4 m_destRect; // texture additional offsets + ImVec2 m_btnSize; // button frame rect - Items m_buttons; // sub items + Items m_buttons; // sub items // ctor simple button with sub items BuildMenuButton(const std::string &tx, const std::string &category); @@ -36,7 +37,10 @@ struct BuildMenuButton { BuildMenuButton(const std::string &tx, const std::string &category, const TileData &tile); // add new subbutton - Ptr addCategoryButton(const std::string &tx, const std::string &id, const TileData &tile) { return addButtonImpl(tx, id, tile); } + Ptr addCategoryButton(const std::string &tx, const std::string &id, const TileData &tile) + { + return addButtonImpl(tx, id, tile); + } // add button which change tile type Ptr addTileButton(const std::string &tx, const std::string &id, const TileData &tile) { return addButtonImpl(tx, id, tile); } diff --git a/src/game/ui/GameTimeMenu.cxx b/src/game/ui/GameTimeMenu.cxx index f6831db5cd..6ffff0b64a 100644 --- a/src/game/ui/GameTimeMenu.cxx +++ b/src/game/ui/GameTimeMenu.cxx @@ -12,7 +12,8 @@ namespace ui = ImGui; -void GameTimeMenu::draw() const { +void GameTimeMenu::draw() const +{ ImVec2 screenSize = ui::GetIO().DisplaySize; auto &uiManager = UIManager::instance(); @@ -24,8 +25,11 @@ void GameTimeMenu::draw() const { ImVec2 pos(screenSize.x - windowSize.x, 0); const ImRect bb(ImVec2{0, 0}, ImVec2{0, 0} + windowSize); - struct { uint8_t clr, frame, frameShade, bottomFrame, bottomFrameShade; } bg; - bg = { 128, 150, 200, 106, 84 }; + struct + { + uint8_t clr, frame, frameShade, bottomFrame, bottomFrameShade; + } bg; + bg = {128, 150, 200, 106, 84}; const ImVec2 timeFramePos = bb.Min + ImVec2(spacing, spacing); @@ -38,9 +42,11 @@ void GameTimeMenu::draw() const { ui::SetNextWindowSize(windowSize); bool open = true; - ui::Begin("##gametimemenu", &open, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoDecoration); + ui::Begin("##gametimemenu", &open, + ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | + ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoDecoration); - ImGuiWindow* window = ImGui::GetCurrentWindow(); + ImGuiWindow *window = ImGui::GetCurrentWindow(); /*window->DrawList->PathLineTo(window->Pos); window->DrawList->PathLineTo(window->Pos + ImVec2(64, 0)); @@ -72,7 +78,7 @@ void GameTimeMenu::draw() const { ui::SetCursorPos(timeFramePos); const float speedFactor = GameClock::instance().getGameClockSpeed(); - auto is_interval = [&] (float val) { return fabs(speedFactor - val) < 0.1f ? ImGuiButtonFlags_ForcePressed : 0; }; + auto is_interval = [&](float val) { return fabs(speedFactor - val) < 0.1f ? ImGuiButtonFlags_ForcePressed : 0; }; if (ui::ButtonCtEx("||", buttonSize, is_interval(0.f))) { GameClock::instance().setGameClockSpeed(0.0f); diff --git a/src/game/ui/LoadMenu.cxx b/src/game/ui/LoadMenu.cxx index 4be4af6212..9e5d6a5a29 100644 --- a/src/game/ui/LoadMenu.cxx +++ b/src/game/ui/LoadMenu.cxx @@ -17,11 +17,13 @@ namespace fs = std::filesystem; namespace ui = ImGui; -LoadMenu::LoadMenu() { +LoadMenu::LoadMenu() +{ // still do nothing } -void LoadMenu::draw() const { +void LoadMenu::draw() const +{ m_result = e_none; m_filename.clear(); @@ -31,7 +33,7 @@ void LoadMenu::draw() const { auto &uiManager = UIManager::instance(); const auto &layout = uiManager.getLayouts()["LoadDialogButtons"]; - ui::SetNextWindowPos(ImVec2((screenSize.x - windowSize.x)/2, (screenSize.y - windowSize.y)/2)); + ui::SetNextWindowPos(ImVec2((screenSize.x - windowSize.x) / 2, (screenSize.y - windowSize.y) / 2)); ui::SetNextWindowSize(windowSize); constexpr float btnSide = 40; @@ -45,9 +47,11 @@ void LoadMenu::draw() const { ui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, buttonOffset.y)); bool open = true; - ui::BeginCt("LoadDialog", &open, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse); + ui::BeginCt("LoadDialog", &open, + ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | + ImGuiWindowFlags_NoScrollWithMouse); - // empty header + // empty header ui::PushItemWidth(widgetSize.x); // header label @@ -63,14 +67,17 @@ void LoadMenu::draw() const { if (!fs::is_regular_file(entry) || entry.path().extension() != ".cts") continue; - ui::Dummy({btnSide / 2.f, 0.f}); ui::SameLine(); + ui::Dummy({btnSide / 2.f, 0.f}); + ui::SameLine(); if (ui::ButtonCt(entry.path().filename().string().c_str(), buttonSize)) { m_filename = entry.path().filename().string(); m_result = e_load_file; } - ui::SameLine(); ui::Dummy({btnSide / 2.f, 0.f}); ui::SameLine(); + ui::SameLine(); + ui::Dummy({btnSide / 2.f, 0.f}); + ui::SameLine(); if (ui::ButtonCt("X", {btnSide, btnSide})) { m_filename = entry.path().filename().string(); @@ -84,7 +91,8 @@ void LoadMenu::draw() const { ImVec2 btnSize(windowSize.x / 4, btnSide); ui::SetCursorPosY(windowSize.y - btnSize.y * 2); - ui::Dummy({(windowSize.x - btnSize.x) / 2.f, 0.f}); ui::SameLine(); + ui::Dummy({(windowSize.x - btnSize.x) / 2.f, 0.f}); + ui::SameLine(); if (ui::ButtonCt("OK", btnSize)) { m_result = e_close; @@ -96,6 +104,7 @@ void LoadMenu::draw() const { ui::End(); } -LoadMenu::~LoadMenu() { +LoadMenu::~LoadMenu() +{ // still do nothing } \ No newline at end of file diff --git a/src/game/ui/LoadMenu.hxx b/src/game/ui/LoadMenu.hxx index 53aa7bdb06..6ac62245b4 100644 --- a/src/game/ui/LoadMenu.hxx +++ b/src/game/ui/LoadMenu.hxx @@ -6,7 +6,8 @@ class LoadMenu : public GameMenu { public: - enum Result { + enum Result + { e_none, e_close, e_load_file, diff --git a/src/game/ui/PauseMenu.cxx b/src/game/ui/PauseMenu.cxx index a5137b1730..c37045da5f 100644 --- a/src/game/ui/PauseMenu.cxx +++ b/src/game/ui/PauseMenu.cxx @@ -10,18 +10,19 @@ namespace ui = ImGui; -void PauseMenu::draw() const { +void PauseMenu::draw() const +{ ImVec2 windowSize(300, 400); ImVec2 screenSize = ui::GetIO().DisplaySize; // dont remove yet, need for tuning //bool show = true; - //ui::ShowDemoWindow(&show); + //ui::ShowDemoWindow(&show); auto &uiManager = UIManager::instance(); const auto &layout = uiManager.getLayouts()["PauseMenuButtons"]; - ui::SetNextWindowPos(ImVec2((screenSize.x - windowSize.x)/2, (screenSize.y - windowSize.y)/2)); + ui::SetNextWindowPos(ImVec2((screenSize.x - windowSize.x) / 2, (screenSize.y - windowSize.y) / 2)); ui::SetNextWindowSize(windowSize); const ImVec2 buttonSize(200, 40); @@ -34,7 +35,9 @@ void PauseMenu::draw() const { ui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, buttonOffset.y)); bool open = true; - ui::BeginCt("PauseMenu", &open, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse); + ui::BeginCt("PauseMenu", &open, + ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | + ImGuiWindowFlags_NoScrollWithMouse); ui::Dummy({0.f, (windowSize.y - (buttonSize.y + buttonOffset.y) * 5) / 2}); if (ui::ButtonCt("Settings", buttonSize)) diff --git a/src/game/ui/SettingsMenu.cxx b/src/game/ui/SettingsMenu.cxx index 090f68485f..6fb1841d3e 100644 --- a/src/game/ui/SettingsMenu.cxx +++ b/src/game/ui/SettingsMenu.cxx @@ -14,22 +14,22 @@ namespace ui = ImGui; -SettingsMenu::SettingsMenu() { -} +SettingsMenu::SettingsMenu() {} -void SettingsMenu::draw() const { +void SettingsMenu::draw() const +{ ImVec2 windowSize(600, 600); ImVec2 screenSize = ui::GetIO().DisplaySize; // dont remove yet, need for tuning //bool show = true; - //ui::ShowDemoWindow(&show); + //ui::ShowDemoWindow(&show); auto &uiManager = UIManager::instance(); auto &settings = Settings::instance(); const auto &layout = uiManager.getLayouts()["PauseMenuButtons"]; - ui::SetNextWindowPos(ImVec2((screenSize.x - windowSize.x)/2, (screenSize.y - windowSize.y)/2)); + ui::SetNextWindowPos(ImVec2((screenSize.x - windowSize.x) / 2, (screenSize.y - windowSize.y) / 2)); ui::SetNextWindowSize(windowSize); const ImVec2 buttonSize(200, 40); @@ -43,9 +43,11 @@ void SettingsMenu::draw() const { ui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, buttonOffset.y)); bool open = true; - ui::BeginCt("PauseMenu", &open, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse); + ui::BeginCt("PauseMenu", &open, + ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | + ImGuiWindowFlags_NoScrollWithMouse); - // empty header + // empty header ui::Dummy({0.f, buttonSize.y}); ui::PushItemWidth(widgetSize.x); @@ -58,13 +60,15 @@ void SettingsMenu::draw() const { // vsync label + checkbox { - ui::LabelText("##vsynclbl", "Enable VSync"); ui::SameLine(); + ui::LabelText("##vsynclbl", "Enable VSync"); + ui::SameLine(); ui::CheckboxCt("##vsync", &settings.vSync); } // sceen mode label + combobox { - ui::LabelText("##fullscreenmodelbl", "Screen Mode"); ui::SameLine(); + ui::LabelText("##fullscreenmodelbl", "Screen Mode"); + ui::SameLine(); std::vector modes = {"WINDOWED", "BORDERLESS", "FULLSCREEN"}; if (ui::BeginComboCt("##fullcreenmmode", modes[settings.fullScreenMode].c_str())) { @@ -85,7 +89,8 @@ void SettingsMenu::draw() const { // screen resolution label + combobox { - ui::LabelText("##screenreslbl", "Resolution"); ui::SameLine(); + ui::LabelText("##screenreslbl", "Resolution"); + ui::SameLine(); std::string currentResolution = std::to_string(settings.screenWidth) + " x " + std::to_string(settings.screenHeight); if (ui::BeginComboCt("##screenres", currentResolution.c_str())) { @@ -95,7 +100,8 @@ void SettingsMenu::draw() const { const bool is_selected = (settings.screenHeight == mode->h && settings.screenWidth == mode->w); if (ui::Selectable(resolution.c_str(), is_selected)) { - WindowManager::instance().setScreenResolution((int)(&mode - &WindowManager::instance().getSupportedScreenResolutions().front())); + WindowManager::instance().setScreenResolution( + (int)(&mode - &WindowManager::instance().getSupportedScreenResolutions().front())); MapFunctions::instance().refreshVisibleMap(); } if (is_selected) @@ -107,7 +113,8 @@ void SettingsMenu::draw() const { // menu layout label + combobox { - ui::LabelText("##menulayoutlbl", "Build Menu Pos"); ui::SameLine(); + ui::LabelText("##menulayoutlbl", "Build Menu Pos"); + ui::SameLine(); int buildMenuLayoutIdx = (int)uiManager.buildMenuLayout(); std::vector layouts = {"LEFT", "RIGHT", "TOP", "BOTTOM"}; if (ui::BeginComboCt("##menulayoutcombo", layouts[buildMenuLayoutIdx])) @@ -131,7 +138,8 @@ void SettingsMenu::draw() const { // music volume label + slider { - ui::LabelText("##musicvol", "Music Volume"); ui::SameLine(); + ui::LabelText("##musicvol", "Music Volume"); + ui::SameLine(); float saveVolume = settings.musicVolume; ui::SliderFloatCt(" ", &settings.musicVolume, 0, 1, "", ImGuiSliderFlags_NoText); @@ -143,7 +151,7 @@ void SettingsMenu::draw() const { } } -//sfx volume label + slider + //sfx volume label + slider ui::LabelText("##sfxvol", "Sound FX Volume"); ui::SameLine(); float saveSFXVolume = settings.soundEffectsVolume; @@ -161,7 +169,8 @@ void SettingsMenu::draw() const { ImVec2 btnSize(windowSize.x / 4, 40); ui::SetCursorPosY(windowSize.y - btnSize.y * 2); - ui::Dummy({btnSize.x / 2, 0.f}); ui::SameLine(); + ui::Dummy({btnSize.x / 2, 0.f}); + ui::SameLine(); if (ui::ButtonCt("OK", btnSize)) { uiManager.closeMenu(); @@ -177,9 +186,8 @@ void SettingsMenu::draw() const { if (ui::ButtonCt("Reset", btnSize)) { uiManager.closeMenu(); - Settings::instance().resetSettingsToDefaults(); + Settings::instance().resetSettingsToDefaults(); } - ui::PopFont(); ui::PopStyleVar(3); @@ -187,5 +195,4 @@ void SettingsMenu::draw() const { ui::End(); } -SettingsMenu::~SettingsMenu() { -} \ No newline at end of file +SettingsMenu::~SettingsMenu() {} \ No newline at end of file diff --git a/src/scripting/ImGuiAngelscript.cxx b/src/scripting/ImGuiAngelscript.cxx index 99f52abae3..5a2ebf1a13 100644 --- a/src/scripting/ImGuiAngelscript.cxx +++ b/src/scripting/ImGuiAngelscript.cxx @@ -25,7 +25,8 @@ void registerImVec2(asIScriptEngine *engine) { int r; - r = engine->RegisterObjectType("ImVec2", sizeof(ImVec2), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA | asOBJ_APP_CLASS_ALLFLOATS); + r = engine->RegisterObjectType("ImVec2", sizeof(ImVec2), + asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA | asOBJ_APP_CLASS_ALLFLOATS); assert(r >= 0); // Register the object properties diff --git a/src/services/AudioMixer.cxx b/src/services/AudioMixer.cxx index d55633eb24..77eadc86bd 100644 --- a/src/services/AudioMixer.cxx +++ b/src/services/AudioMixer.cxx @@ -296,7 +296,7 @@ static LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv; static LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf; static LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv; -void AudioMixer::playSoundtrackWithEffect(SoundtrackUPtr& track, int ALEffect) +void AudioMixer::playSoundtrackWithEffect(SoundtrackUPtr &track, int ALEffect) { if (!track) throw AudioError(TRACE_INFO "Received an invalid soundtrack"); @@ -304,7 +304,7 @@ void AudioMixer::playSoundtrackWithEffect(SoundtrackUPtr& track, int ALEffect) if (!track->source) throw AudioError{TRACE_INFO "Unable to play track because its source is uninitialized"}; - //set up effect + //set up effect #define LOAD_PROC(T, x) ((x) = (T)alGetProcAddress(#x)) LOAD_PROC(LPALGENEFFECTS, alGenEffects); LOAD_PROC(LPALDELETEEFFECTS, alDeleteEffects); @@ -336,9 +336,9 @@ void AudioMixer::playSoundtrackWithEffect(SoundtrackUPtr& track, int ALEffect) // Create the effect object alGenEffects(1, &effect); - + alEffecti(effect, AL_EFFECT_TYPE, ALEffect); - + // this is where we would put code to customize the properties of the effect // Check if an error occured, and clean up if so.