diff --git a/CMakeLists.txt b/CMakeLists.txt index b2c5ed9..f8b8b89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,11 +25,10 @@ add_executable(Harbour Harbour/src/main.cpp Harbour/src/App.cpp Harbour/src/GameCard.cpp - Harbour/src/utils/FileManager.cpp - Harbour/include/MenuScreen.h + Harbour/src/utils/FileManager.cpp Harbour/src/MenuScreen.cpp - Harbour/include/utils/LoadImage.h Harbour/src/utils/LoadImage.cpp + Harbour/src/utils/ColorManager.cpp ) target_include_directories(Harbour PRIVATE diff --git a/Harbour/include/App.h b/Harbour/include/App.h index 160729c..068b865 100644 --- a/Harbour/include/App.h +++ b/Harbour/include/App.h @@ -11,6 +11,7 @@ #include "GameCard.h" #include "utils/FileManager.h" +#include "utils/ColorManager.h" #include "MenuScreen.h" namespace Harbour { @@ -38,7 +39,10 @@ namespace Harbour { private: HarbourUtils::FileManager m_fileManager = {}; + HarbourUtils::ColorManager m_colorManager = {}; + void constructLibraryFromJSON(std::vector& output, std::string lib); + }; } diff --git a/Harbour/include/GameCard.h b/Harbour/include/GameCard.h index 05e6864..0de47a0 100644 --- a/Harbour/include/GameCard.h +++ b/Harbour/include/GameCard.h @@ -1,6 +1,5 @@ #pragma once -#include "utils/LoadImage.h" #include namespace Harbour { @@ -26,7 +25,7 @@ namespace Harbour { std::string m_version; const char* m_thumbnailFilePath = nullptr; - GLuint m_texture = 0; + unsigned int m_texture = 0; //GLuint equivalent }; } \ No newline at end of file diff --git a/Harbour/include/MenuScreen.h b/Harbour/include/MenuScreen.h index 1350903..2a03a12 100644 --- a/Harbour/include/MenuScreen.h +++ b/Harbour/include/MenuScreen.h @@ -1,12 +1,11 @@ #pragma once -#include "imgui.h" #include #include "GameCard.h" - +#include "utils/ColorManager.h" namespace HarbourGUI { - enum screenID { + const enum screenID { MyLibrary, AllGames, Settings, @@ -15,6 +14,65 @@ namespace HarbourGUI { void MyLibraryScreen(std::vector& myLibrary); void downloadsScreen(std::vector& downloads); - void settingsScreen(); + void settingsScreen(HarbourUtils::ColorManager& colorManager); void helpScreen(); -} \ No newline at end of file +} + +/* +Nice, you found it! `0.1, 0.1, 0.15, 1.0` is a nice dark bluish-gray — easy on the eyes and doesn’t clash with ImGui’s default colors. + +Here are some suggestions for alternative color schemes and the general “feel” they give: + +--- + +### **1. Green-themed** + +* `0.05, 0.1, 0.05, 1.0` ? very dark forest green, calm and natural +* Works well with beige/tan or light green accent buttons +* Gives a “terminal + nature” vibe + +--- + +### **2. Red-themed** + +* `0.15, 0.05, 0.05, 1.0` ? dark maroon / burgundy +* Good for alert-heavy UI or if you want a warm, energetic feel +* Red can be tiring if the UI is used a lot, so best for accents + +--- + +### **3. Gray-themed / Neutral** + +* `0.1, 0.1, 0.1, 1.0` ? almost black, very neutral +* `0.15, 0.15, 0.15, 1.0` ? slightly lighter, good for soft contrast +* Easy on eyes, very professional, works well with any highlight color (green/red/blue/yellow) + +--- + +### **4. Blue / Nautical** + +* `0.05, 0.05, 0.2, 1.0` ? navy, classic dark blue +* Fits your “nautical” theme perfectly +* Works with white, teal, or gold highlights + +--- + +### **5. Teal / Sci-Fi** + +* `0.05, 0.15, 0.15, 1.0` ? dark teal +* Gives a techy, slightly futuristic look +* Accent with cyan or orange + +--- + +**Tips for choosing a scheme:** + +* Keep background darker than your text for readability. +* Use 1–2 accent colors for highlights/buttons to avoid visual clutter. +* If you plan to make this customizable, consider saving the RGBA in a JSON settings file so users can pick a color in the UI. + +--- + +If you want, I can mock up a **few ready-to-use RGBA palettes** for Harbour/SoH that would look good with ImGui’s default widgets — could save you time experimenting. Do you want me to do that? + +*/ diff --git a/Harbour/include/utils/ColorManager.h b/Harbour/include/utils/ColorManager.h new file mode 100644 index 0000000..c6cf560 --- /dev/null +++ b/Harbour/include/utils/ColorManager.h @@ -0,0 +1,42 @@ +#pragma once + +struct ImVec4; + +namespace HarbourUtils { + const enum Colors { + BlueGray, //Default + DarkBlue, //0.0, 0.0, 0.25, 1.0 + LightBlue, //0.43 0.52 0.89 + Green, //0.05, 0.2, 0.05 + Teal, //0.05, 0.25, 0.25 + DarkRed, //0.2, 0.05, 0.05 + LightRed, //0.85, 0.25, 0.25 + DarkGray, //0.15, 0.15, 0.15 + }; + + class ColorManager { + public: + ColorManager(); + + public: + //Getters/setters + ImVec4 getBackground() const; + int getThemeColor() const; + void drawBackground() const; + void setThemeColor(int colorTheme); + + private: + void setBackgroundColor(); + void setAccentColor(); + void setHoverColor(); + void setMenuBarColor(); + + Colors m_currentColorTheme = {}; //Doesn't do much yet, add load by file + + ImVec4 m_backgroundColor = {}; //Set by setBackgroundColor() and m_currentColorTheme + ImVec4 m_menuBarColor = {}; //The menu bar background, only changes on certain themes + ImVec4 m_accentColor = {}; //Dropdowns, other UI + ImVec4 m_hoverColor = {}; //Buttons when hovered + + }; +} diff --git a/Harbour/include/utils/FileManager.h b/Harbour/include/utils/FileManager.h index 35a18ce..ead16cd 100644 --- a/Harbour/include/utils/FileManager.h +++ b/Harbour/include/utils/FileManager.h @@ -1,9 +1,7 @@ #pragma once -#include -#include + #include #include -#include namespace HarbourUtils { class FileManager { diff --git a/Harbour/include/utils/LoadImage.h b/Harbour/include/utils/LoadImage.h index bd143fb..b5b5070 100644 --- a/Harbour/include/utils/LoadImage.h +++ b/Harbour/include/utils/LoadImage.h @@ -3,7 +3,6 @@ #pragma once #include -#include "imgui.h" #define _CRT_SECURE_NO_WARNINGS #include "stb/stb_image.h" diff --git a/Harbour/src/App.cpp b/Harbour/src/App.cpp index 09acf4e..b234755 100644 --- a/Harbour/src/App.cpp +++ b/Harbour/src/App.cpp @@ -11,150 +11,155 @@ Harbour::App::App() { this->init(); - this->constructLibraryFromJSON(m_library, "library/myGames.json"); - this->constructLibraryFromJSON(m_allGames, "library/allGames.json"); - - m_fileManager.checkLatestVersions(); + this->constructLibraryFromJSON(m_library, "library/myGames.json"); + this->constructLibraryFromJSON(m_allGames, "library/allGames.json"); + + m_fileManager.checkLatestVersions(); } Harbour::App::~App() { - this->shutdown(); + this->shutdown(); } void Harbour::App::init() { - SDL_Init(SDL_INIT_VIDEO); - m_window = SDL_CreateWindow("Harbour of Harkinian", - SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - 1280, 720, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); + SDL_Init(SDL_INIT_VIDEO); + m_window = SDL_CreateWindow("Harbour of Harkinian", + SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, + 1280, 720, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); - SDL_GLContext gl_context = SDL_GL_CreateContext(m_window); - gladLoadGLLoader((GLADloadproc)SDL_GL_GetProcAddress); + SDL_GLContext gl_context = SDL_GL_CreateContext(m_window); + gladLoadGLLoader((GLADloadproc)SDL_GL_GetProcAddress); - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); + IMGUI_CHECKVERSION(); + ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); - io.Fonts->AddFontFromFileTTF("./assets/Fonts/montserrat/Montserrat-Regular.otf", 16.0f); + int read = ImGuiCol_MenuBarBg; - ImGui_ImplSDL2_InitForOpenGL(m_window, gl_context); - ImGui_ImplOpenGL3_Init("#version 150"); + std::cout << ImGui::GetStyle().Colors[read].x << std::endl; + std::cout << ImGui::GetStyle().Colors[read].y << std::endl; + std::cout << ImGui::GetStyle().Colors[read].z << std::endl; + std::cout << ImGui::GetStyle().Colors[read].w << std::endl; + + ImGuiIO& io = ImGui::GetIO(); + io.Fonts->AddFontFromFileTTF("./assets/Fonts/montserrat/Montserrat-Regular.otf", 16.0f); + + ImGui_ImplSDL2_InitForOpenGL(m_window, gl_context); + ImGui_ImplOpenGL3_Init("#version 150"); } void Harbour::App::shutdown() { - ImGui_ImplOpenGL3_Shutdown(); - ImGui_ImplSDL2_Shutdown(); - ImGui::DestroyContext(); - SDL_DestroyWindow(m_window); - SDL_Quit(); + ImGui_ImplOpenGL3_Shutdown(); + ImGui_ImplSDL2_Shutdown(); + ImGui::DestroyContext(); + SDL_DestroyWindow(m_window); + SDL_Quit(); } void Harbour::App::run() { - SDL_Event event; - while (m_isRunning) { - while (SDL_PollEvent(&event)) { - ImGui_ImplSDL2_ProcessEvent(&event); - if (event.type == SDL_QUIT) m_isRunning = false; - } - - ImGui_ImplOpenGL3_NewFrame(); - ImGui_ImplSDL2_NewFrame(); - ImGui::NewFrame(); - - ImGui::SetNextWindowPos(ImVec2(0, 0)); - ImGui::SetNextWindowSize(ImGui::GetIO().DisplaySize); - - ImGui::Begin("MainOverlay", nullptr, - ImGuiWindowFlags_NoDecoration | - ImGuiWindowFlags_NoBackground | - ImGuiWindowFlags_NoMove | - ImGuiWindowFlags_MenuBar - ); - //for directly into the window - - if (ImGui::BeginMenuBar()) { - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.0f, 0.0f, 0.0f, 0.0f)); - HarbourGUI::screenID next = {}; - if (ImGui::Button("My Library")) { - next = HarbourGUI::MyLibrary; - this->switchScreens(next); - } - if (ImGui::Button("All Games")) { - next = HarbourGUI::AllGames; - this->switchScreens(next); - } - if (ImGui::Button("Settings")) { - next = HarbourGUI::Settings; - this->switchScreens(next); - } - if (ImGui::Button("Help Center")) { - next = HarbourGUI::HelpCenter; - this->switchScreens(next); - } - ImGui::PopStyleColor(); - - ImGui::EndMenuBar(); - } - - this->drawCurrentScreen(); - - ImGui::End(); - - - ImGui::Render(); - glViewport(0, 0, 1280, 720); - glClearColor(0.1f, 0.1f, 0.15f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); - SDL_GL_SwapWindow(m_window); - } + SDL_Event event; + while (m_isRunning) { + while (SDL_PollEvent(&event)) { + ImGui_ImplSDL2_ProcessEvent(&event); + if (event.type == SDL_QUIT) m_isRunning = false; + } + + ImGui_ImplOpenGL3_NewFrame(); + ImGui_ImplSDL2_NewFrame(); + ImGui::NewFrame(); + + ImGui::SetNextWindowPos(ImVec2(0, 0)); + ImGui::SetNextWindowSize(ImGui::GetIO().DisplaySize); + + ImGui::Begin("MainOverlay", nullptr, + ImGuiWindowFlags_NoDecoration | + ImGuiWindowFlags_NoBackground | + ImGuiWindowFlags_NoMove | + ImGuiWindowFlags_MenuBar + ); + //for directly into the window + + if (ImGui::BeginMenuBar()) { + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.0f, 0.0f, 0.0f, 0.0f)); + HarbourGUI::screenID next = {}; + if (ImGui::Button("My Library")) { + next = HarbourGUI::MyLibrary; + this->switchScreens(next); + } + if (ImGui::Button("All Games")) { + next = HarbourGUI::AllGames; + this->switchScreens(next); + } + if (ImGui::Button("Settings")) { + next = HarbourGUI::Settings; + this->switchScreens(next); + } + if (ImGui::Button("Help Center")) { + next = HarbourGUI::HelpCenter; + this->switchScreens(next); + } + ImGui::PopStyleColor(); + + ImGui::EndMenuBar(); + } + + this->drawCurrentScreen(); + + ImGui::End(); + + + ImGui::Render(); + m_colorManager.drawBackground(); + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + SDL_GL_SwapWindow(m_window); + } } void Harbour::App::switchScreens(HarbourGUI::screenID& id) { - m_screenID = id; + m_screenID = id; } void Harbour::App::drawCurrentScreen() { - switch (m_screenID) { - case HarbourGUI::MyLibrary: - { - HarbourGUI::MyLibraryScreen(m_library); - break; - } - case HarbourGUI::AllGames: - { - HarbourGUI::downloadsScreen(m_allGames); - break; - } - case HarbourGUI::Settings: - { - HarbourGUI::settingsScreen(); - break; - } - case HarbourGUI::HelpCenter: - { - HarbourGUI::helpScreen(); - break; - } - default: - HarbourGUI::MyLibraryScreen(m_library); - } + switch (m_screenID) { + case HarbourGUI::MyLibrary: + { + HarbourGUI::MyLibraryScreen(m_library); + break; + } + case HarbourGUI::AllGames: + { + HarbourGUI::downloadsScreen(m_allGames); + break; + } + case HarbourGUI::Settings: + { + HarbourGUI::settingsScreen(m_colorManager); + break; + } + case HarbourGUI::HelpCenter: + { + HarbourGUI::helpScreen(); + break; + } + default: + HarbourGUI::MyLibraryScreen(m_library); + } } void Harbour::App::constructLibraryFromJSON(std::vector& output, std::string lib) { - auto res = m_fileManager.readJSON(lib); + auto res = m_fileManager.readJSON(lib); - if (res.size() == 0) return; + if (res.size() == 0) return; - for (size_t i = 0; i < res.size(); i++) { - std::cout << res[i].at("name") << std::endl << res[i].at("version") << std::endl; - output.emplace_back(res[i].at("name"), res[i].at("version")); - } + for (size_t i = 0; i < res.size(); i++) { + std::cout << res[i].at("name") << std::endl << res[i].at("version") << std::endl; + output.emplace_back(res[i].at("name"), res[i].at("version")); + } } diff --git a/Harbour/src/GameCard.cpp b/Harbour/src/GameCard.cpp index 6574b4c..49de529 100644 --- a/Harbour/src/GameCard.cpp +++ b/Harbour/src/GameCard.cpp @@ -1,6 +1,9 @@ #include "GameCard.h" -#include +#include "utils/LoadImage.h" + +#include +#include Harbour::GameCard::GameCard() { diff --git a/Harbour/src/MenuScreen.cpp b/Harbour/src/MenuScreen.cpp index c479069..9c7c065 100644 --- a/Harbour/src/MenuScreen.cpp +++ b/Harbour/src/MenuScreen.cpp @@ -1,6 +1,9 @@ +#include #include "MenuScreen.h" #include "GameCard.h" +#include + //MyLibraryScreen helped by AI in deciding the parameters after //ThatCodingFrog thought of the idea of how to pass data void HarbourGUI::MyLibraryScreen(std::vector& myLibrary) @@ -36,12 +39,29 @@ void HarbourGUI::downloadsScreen(std::vector& downloads) //Read data from allGames.json, then run loop based on results to draw thumbnails w/ download buttons } -void HarbourGUI::settingsScreen() +void HarbourGUI::settingsScreen(HarbourUtils::ColorManager& colorManager) { ImGui::PushFont(NULL, 24.0f); ImGui::Text("Settings"); ImGui::PopFont(); + const char* schemes[] = { + "Blue Gray", "Dark Blue", "Light Blue", + "Green", "Teal", "Dark Red", "Light Red", "Dark Gray" + //Currently needs to follow order of Colors enum or it will break + }; + + int current = colorManager.getThemeColor(); + + //ImGui::PushStyleColor(ImGuiCol_PopupBg, ImVec4(0.8f, 0.0f, 0.0f, 1.0f)); + + if ( ImGui::Combo("Background Color", ¤t, schemes, IM_ARRAYSIZE(schemes)) ) { + std::cout << current; + colorManager.setThemeColor(current); + } + + //ImGui::PopStyleColor(); + ImGui::Text("Coming soon..."); } diff --git a/Harbour/src/utils/ColorManager.cpp b/Harbour/src/utils/ColorManager.cpp new file mode 100644 index 0000000..5a13a03 --- /dev/null +++ b/Harbour/src/utils/ColorManager.cpp @@ -0,0 +1,173 @@ +#include +#include + +#include "utils/ColorManager.h" + +HarbourUtils::ColorManager::ColorManager() +{ + //Load theme from user settings and change accordingly + m_currentColorTheme = BlueGray; + this->setBackgroundColor(); +} + +ImVec4 HarbourUtils::ColorManager::getBackground() const +{ + return m_backgroundColor; +} + +int HarbourUtils::ColorManager::getThemeColor() const +{ + return m_currentColorTheme; +} + +void HarbourUtils::ColorManager::drawBackground() const +{ + glViewport(0, 0, 1280, 720); + glClearColor( + m_backgroundColor.x, + m_backgroundColor.y, + m_backgroundColor.z, + m_backgroundColor.w + ); + glClear(GL_COLOR_BUFFER_BIT); + +} + +void HarbourUtils::ColorManager::setThemeColor(int colorTheme) +{ + m_currentColorTheme = (Colors)colorTheme; + this->setBackgroundColor(); + this->setMenuBarColor(); + this->setAccentColor(); + this->setHoverColor(); +} + +void HarbourUtils::ColorManager::setBackgroundColor() +{ + switch (m_currentColorTheme) { + case BlueGray: + m_backgroundColor = ImVec4(0.1f, 0.1f, 0.15f, 1.0f); + break; + case DarkBlue: + m_backgroundColor = ImVec4(0.0f, 0.0f, 0.25f, 1.0f); + break; + case LightBlue: + m_backgroundColor = ImVec4(0.43f, 0.52f, 0.89f, 1.0f); + break; + case Green: + m_backgroundColor = ImVec4(0.05f, 0.2f, 0.05f, 1.0f); + break; + case Teal: + m_backgroundColor = ImVec4(0.05f, 0.25f, 0.25f, 1.0f); + break; + case DarkRed: + m_backgroundColor = ImVec4(0.2f, 0.05f, 0.05f, 1.0f); + break; + case LightRed: + m_backgroundColor = ImVec4(0.85f, 0.25f, 0.25f, 1.0f); + break; + case DarkGray: + m_backgroundColor = ImVec4(0.15f, 0.15f, 0.15f, 1.0f); + break; + default: + m_backgroundColor = ImVec4(0.1f, 0.1f, 0.15f, 1.0f); + } +} + +void HarbourUtils::ColorManager::setAccentColor() +{ + //Build off of StyleColorsDark() in imgui_draw.cpp + float alpha = 0.94f; + + switch (m_currentColorTheme) { + case BlueGray: + m_accentColor = ImVec4(0.1f, 0.1f, 0.15f, alpha); + break; + case DarkBlue: + m_accentColor = ImVec4(0.0f, 0.0f, 0.25f, alpha); + break; + case LightBlue: + m_accentColor = ImVec4(0.43f, 0.52f, 0.89f, alpha); + break; + case Green: + m_accentColor = ImVec4(0.05f, 0.2f, 0.05f, alpha); + break; + case Teal: + m_accentColor = ImVec4(0.05f, 0.25f, 0.25f, alpha); + break; + case DarkRed: + m_accentColor = ImVec4(0.2f, 0.05f, 0.05f, alpha); + break; + case LightRed: + m_accentColor = ImVec4(0.55f, 0.15f, 0.15f, alpha); + break; + case DarkGray: + m_accentColor = ImVec4(0.15f, 0.15f, 0.15f, alpha); + break; + default: + m_accentColor = ImVec4(0.1f, 0.1f, 0.15f, alpha); + } + + ImGui::GetStyle().Colors[ImGuiCol_PopupBg] = m_accentColor; + ImGui::GetStyle().Colors[ImGuiCol_FrameBg] = m_accentColor; + +} + +void HarbourUtils::ColorManager::setHoverColor() +{ + switch (m_currentColorTheme) { + case BlueGray: + m_hoverColor = ImVec4(0.1f, 0.1f, 0.15f, 1.0f); + break; + case DarkBlue: + m_hoverColor = ImVec4(0.0f, 0.0f, 0.25f, 1.0f); + break; + case LightBlue: + m_hoverColor = ImVec4(0.43f, 0.52f, 0.89f, 1.0f); + break; + case Green: + m_hoverColor = ImVec4(0.05f, 0.2f, 0.05f, 1.0f); + break; + case Teal: + m_hoverColor = ImVec4(0.05f, 0.25f, 0.25f, 1.0f); + break; + case DarkRed: + m_hoverColor = ImVec4(0.2f, 0.05f, 0.05f, 1.0f); + break; + case LightRed: + m_menuBarColor = ImVec4(0.55f, 0.15f, 0.15f, 1.0f); + break; + case DarkGray: + m_hoverColor = ImVec4(0.15f, 0.15f, 0.15f, 1.0f); + break; + default: + m_hoverColor = ImVec4(0.1f, 0.1f, 0.15f, 1.0f); + } +} + +void HarbourUtils::ColorManager::setMenuBarColor() +{ + switch (m_currentColorTheme) + { + /*case HarbourUtils::BlueGray: + break; + case HarbourUtils::DarkBlue: + break; + case HarbourUtils::LightBlue: + break; + case HarbourUtils::Green: + break; + case HarbourUtils::Teal: + break; + case HarbourUtils::DarkRed: + break; + case HarbourUtils::DarkGray: + break;*/ + case LightRed: + m_menuBarColor = ImVec4(0.55f, 0.15f, 0.15f, 1.0f); + break; + default: + m_menuBarColor = ImVec4(0.14f, 0.14f, 0.14f, 1.0f); + } + ImGui::GetStyle().Colors[ImGuiCol_MenuBarBg] = m_menuBarColor; +} diff --git a/Harbour/src/utils/FileManager.cpp b/Harbour/src/utils/FileManager.cpp index d6b554d..568ca4e 100644 --- a/Harbour/src/utils/FileManager.cpp +++ b/Harbour/src/utils/FileManager.cpp @@ -1,7 +1,12 @@ #include "utils/FileManager.h" #include +#include +#include + #include +#include + void HarbourUtils::FileManager::createNewDirectory(std::string dir) { @@ -44,49 +49,49 @@ nlohmann::json HarbourUtils::FileManager::readJSON(std::string file) //WriteCallback generated by AI, based on https://gist.github.com/whoshuu/2dc858b8730079602044 //If anyone knows better cURL usage or documentation (especially for C++), it would be appreciated greatly static size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* s) { - size_t totalSize = size * nmemb; - s->append((char*)contents, totalSize); - return totalSize; + size_t totalSize = size * nmemb; + s->append((char*)contents, totalSize); + return totalSize; } std::string HarbourUtils::FileManager::makeCURLRequest(const char* url) { - CURL* curl = curl_easy_init(); - std::string response; + CURL* curl = curl_easy_init(); + std::string response; - if (curl) { - // Set URL - curl_easy_setopt(curl, CURLOPT_URL, url); + if (curl) { + // Set URL + curl_easy_setopt(curl, CURLOPT_URL, url); - // Set User-Agent (required by GitHub API) - curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-example/1.0"); + // Set User-Agent (required by GitHub API) + curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-example/1.0"); - // Set callback to capture response - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response); + // Set callback to capture response + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response); - // Perform request - CURLcode res = curl_easy_perform(curl); + // Perform request + CURLcode res = curl_easy_perform(curl); - if (res == CURLE_OK) { - //std::cout << "Response: " << response << std::endl; - } - else { - std::cerr << "Request failed: " << curl_easy_strerror(res) << std::endl; - } + if (res == CURLE_OK) { + //std::cout << "Response: " << response << std::endl; + } + else { + std::cerr << "Request failed: " << curl_easy_strerror(res) << std::endl; + } - curl_easy_cleanup(curl); - } + curl_easy_cleanup(curl); + } - return response; + return response; } void HarbourUtils::FileManager::checkLatestVersions() { - //Get/check install links for versions based on version + //Get/check install links for versions based on version #if defined(_WIN32) - auto latest = this->checkShipVersion(); - auto installed = this->readJSON("library/myGames.json"); + auto latest = this->checkShipVersion(); + auto installed = this->readJSON("library/myGames.json"); #elif defined(__linux__) @@ -97,18 +102,18 @@ void HarbourUtils::FileManager::checkLatestVersions() nlohmann::json HarbourUtils::FileManager::checkShipVersion() { - nlohmann::json ship = nlohmann::json::parse( makeCURLRequest("https://api.github.com/repos/HarbourMasters/Shipwright/releases/latest") ); - //std::cout << ship << std::endl; - return ship; + nlohmann::json ship = nlohmann::json::parse( makeCURLRequest("https://api.github.com/repos/HarbourMasters/Shipwright/releases/latest") ); + //std::cout << ship << std::endl; + return ship; } nlohmann::json HarbourUtils::FileManager::check2ShipVersion() { - this->makeCURLRequest("https://api.github.com/repos/HarbourMasters/2Ship2Harkinian/releases/latest"); - return nlohmann::json(); + this->makeCURLRequest("https://api.github.com/repos/HarbourMasters/2Ship2Harkinian/releases/latest"); + return nlohmann::json(); } nlohmann::json HarbourUtils::FileManager::checkStarShipVersion() { - return nlohmann::json(); + return nlohmann::json(); } diff --git a/Harbour/src/utils/LoadImage.cpp b/Harbour/src/utils/LoadImage.cpp index cffd6a4..be2cbf1 100644 --- a/Harbour/src/utils/LoadImage.cpp +++ b/Harbour/src/utils/LoadImage.cpp @@ -1,5 +1,6 @@ #define STB_IMAGE_IMPLEMENTATION +#include #include "utils/LoadImage.h" // Simple helper function to load an image into a OpenGL texture with common settings