git repos / saland

commit 23c455fb

Poul Sander · 2025-12-23 16:01
23c455fb470688bb45064a102d5b5afff5509722 patch · browse files
parent 0a4927fdc8c714cc4c504d74e64c846b48344002

Remove old HairSelect menu

Changed files

D src/ImGuiHairSelect.cpp before
D src/ImGuiHairSelect.hpp before
M src/saland.cpp before
diff --git a/src/ImGuiHairSelect.cpp b/src/ImGuiHairSelect.cpp deleted file mode 100644 index d0e7837..0000000 --- a/src/ImGuiHairSelect.cpp +++ /dev/null
@@ -1,125 +0,0 @@
-/*
-===========================================================================
- * Saland Adventures
-Copyright (C) 2014-2024 Poul Sander
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see http://www.gnu.org/licenses/
-
-Source information and contacts persons can be found at
-https://github.com/sago007/saland
-===========================================================================
- */
-
-#include "ImGuiHairSelect.hpp"
-#include "Libs/imgui/imgui.h"
-#include "common.h"
-#include "saland/globals.hpp"
-#include <SDL.h>
-
-ImGuiHairSelect::ImGuiHairSelect() {
- currentHair = globalData.player.hair;
-
- // Define available hair options
- hairOptions = {
- {"standard_hair", "Redhead"},
- {"hair_blonde", "Blonde"},
- {"hair_brunette", "Brunette"},
- {"hair_raven", "Black"},
- {"hair_blue", "Blue"},
- {"hair_1", "Short Blue"} // The old male_hair_single_blue variant
- };
-}
-
-bool ImGuiHairSelect::IsActive() {
- return active;
-}
-
-void ImGuiHairSelect::Draw(SDL_Renderer* target) {
- // Center the menu window
- ImGuiIO& io = ImGui::GetIO();
- ImVec2 window_size(400, 500);
- ImVec2 window_pos(
- (io.DisplaySize.x - window_size.x) * 0.5f,
- (io.DisplaySize.y - window_size.y) * 0.5f
- );
-
- ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always);
- ImGui::SetNextWindowSize(window_size, ImGuiCond_Always);
-
- if (!ImGui::Begin("Hair Select", &active,
- ImGuiWindowFlags_NoResize |
- ImGuiWindowFlags_NoMove |
- ImGuiWindowFlags_NoCollapse)) {
- ImGui::End();
- return;
- }
-
- // Center buttons horizontally
- float button_width = 300.0f;
- float button_height = 50.0f;
- float window_width = ImGui::GetWindowSize().x;
- float button_x = (window_width - button_width) * 0.5f;
-
- // Add some top spacing
- ImGui::Dummy(ImVec2(0.0f, 30.0f));
-
- // Display hair options as buttons
- for (const auto& option : hairOptions) {
- ImGui::SetCursorPosX(button_x);
-
- // Highlight current selection
- if (option.id == currentHair) {
- ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.3f, 0.6f, 0.3f, 1.0f));
- ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.4f, 0.7f, 0.4f, 1.0f));
- ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.2f, 0.5f, 0.2f, 1.0f));
- }
-
- if (ImGui::Button(option.displayName.c_str(), ImVec2(button_width, button_height))) {
- pendingHair = option.id;
- }
-
- if (option.id == currentHair) {
- ImGui::PopStyleColor(3);
- }
-
- ImGui::Dummy(ImVec2(0.0f, 5.0f));
- }
-
- ImGui::End();
-}
-
-void ImGuiHairSelect::ProcessInput(const SDL_Event& event, bool& processed) {
- // Handle Escape key to close menu
- if (event.type == SDL_KEYDOWN) {
- if (event.key.keysym.sym == SDLK_ESCAPE) {
- active = false;
- processed = true;
- }
- }
-}
-
-void ImGuiHairSelect::SelectHair(const std::string& hairName) {
- globalData.player.hair = hairName;
- currentHair = hairName;
- // Save player data
- PlayerSave();
- active = false;
-}
-
-void ImGuiHairSelect::Update() {
- if (!pendingHair.empty()) {
- SelectHair(pendingHair);
- pendingHair.clear();
- }
-}
diff --git a/src/ImGuiHairSelect.hpp b/src/ImGuiHairSelect.hpp deleted file mode 100644 index d8bbfb3..0000000 --- a/src/ImGuiHairSelect.hpp +++ /dev/null
@@ -1,61 +0,0 @@
-/*
-===========================================================================
- * Saland Adventures
-Copyright (C) 2014-2024 Poul Sander
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see http://www.gnu.org/licenses/
-
-Source information and contacts persons can be found at
-https://github.com/sago007/saland
-===========================================================================
- */
-
-#ifndef IMGUI_HAIR_SELECT_HPP
-#define IMGUI_HAIR_SELECT_HPP
-
-#include "sago/GameStateInterface.hpp"
-#include <string>
-#include <vector>
-
-struct SDL_Renderer;
-union SDL_Event;
-
-class ImGuiHairSelect : public sago::GameStateInterface {
-public:
- ImGuiHairSelect();
- virtual bool IsActive() override;
- virtual void Draw(SDL_Renderer* target) override;
- virtual void ProcessInput(const SDL_Event& event, bool& processed) override;
- virtual void Update() override;
-
- ImGuiHairSelect(const ImGuiHairSelect&) = delete;
- ImGuiHairSelect& operator=(const ImGuiHairSelect&) = delete;
- virtual ~ImGuiHairSelect() = default;
-
-private:
- void SelectHair(const std::string& hairName);
-
- bool active = true;
- std::string pendingHair;
- std::string currentHair;
-
- struct HairOption {
- std::string id;
- std::string displayName;
- };
-
- std::vector<HairOption> hairOptions;
-};
-
-#endif // IMGUI_HAIR_SELECT_HPP
diff --git a/src/saland.cpp b/src/saland.cpp index 42d9339..c6f4b75 100644 --- a/src/saland.cpp +++ b/src/saland.cpp
@@ -53,7 +53,6 @@ https://github.com/salandgame/saland
#include "ImGuiMainMenu.hpp"
#include "ImGuiWorldSelect.hpp"
#include "ImGuiPlayerSelect.hpp"
-#include "ImGuiHairSelect.hpp"
#include "ImGuiOptions.hpp"
#include "common.h"
@@ -326,11 +325,6 @@ void runPlayerSelect() {
RunGameState(m);
}
-void runHairSelect() {
- ImGuiHairSelect m;
- RunGameState(m);
-}
-
void ResetFullscreen() {
sago::SagoDataHolder& dataHolder = *globalData.dataHolder;