diff --git a/Common/Cpp/ColoredText.cpp b/Common/Cpp/ColoredText.cpp new file mode 100644 index 0000000000..2662e074ed --- /dev/null +++ b/Common/Cpp/ColoredText.cpp @@ -0,0 +1,53 @@ +/* Colored Text + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "ColoredText.h" + +namespace PokemonAutomation{ + + +#if 1 +Color theme_friendly_darkblue(){ + if (CURRENT_THEME == 1){ + return Color(0xff0080ff); + } + return COLOR_DARK_BLUE; +} +#endif +std::string html_color_text(const std::string& text, Color color){ + if (color == Color()){ + return text; + } + const char HEX[] = "0123456789abcdef"; + uint32_t rgb = (uint32_t)color; + std::string str; + str += HEX[(rgb >> 20) & 15]; + str += HEX[(rgb >> 16) & 15]; + str += HEX[(rgb >> 12) & 15]; + str += HEX[(rgb >> 8) & 15]; + str += HEX[(rgb >> 4) & 15]; + str += HEX[(rgb >> 0) & 15]; + return "" + text + ""; +} +std::string make_text_url(const std::string& url, const std::string& text){ +#if 0 + switch (CURRENT_THEME){ + case 0: + return "" + text + ""; + case 1: + return "" + text + ""; + } + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "Invalid theme #."); +#endif + return "" + text + ""; +} + + + + + + +} diff --git a/Common/Cpp/ColoredText.h b/Common/Cpp/ColoredText.h new file mode 100644 index 0000000000..ef4c15e798 --- /dev/null +++ b/Common/Cpp/ColoredText.h @@ -0,0 +1,23 @@ +/* Colored Text + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_ColoredText_H +#define PokemonAutomation_ColoredText_H + +#include "Common/Cpp/Color.h" +#include + +namespace PokemonAutomation{ + +inline size_t CURRENT_THEME = 0; + +Color theme_friendly_darkblue(); +std::string html_color_text(const std::string& text, Color color); +std::string make_text_url(const std::string& url, const std::string& text); + +} +#endif + diff --git a/SerialPrograms/Source/CommonFramework/ErrorReports/ErrorReports.cpp b/SerialPrograms/Source/CommonFramework/ErrorReports/ErrorReports.cpp index fd72429725..a4f9aa5653 100644 --- a/SerialPrograms/Source/CommonFramework/ErrorReports/ErrorReports.cpp +++ b/SerialPrograms/Source/CommonFramework/ErrorReports/ErrorReports.cpp @@ -18,7 +18,7 @@ #include "CommonFramework/GlobalSettingsPanel.h" #include "CommonFramework/Logging/Logger.h" #include "CommonFramework/Notifications/ProgramNotifications.h" -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "Common/Cpp/ColoredText.h" #include "CommonFramework/Recording/StreamHistorySession.h" #include "CommonFramework/Tools/GlobalThreadPools.h" #include "ProgramDumper.h" diff --git a/SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.cpp b/SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.cpp index 006a96c3e2..c06d30c0fc 100644 --- a/SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.cpp +++ b/SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.cpp @@ -10,6 +10,7 @@ #include #include #include +#include "Common/Cpp/ColoredText.h" #include "Common/Cpp/Containers/Pimpl.tpp" #include "Common/Cpp/LifetimeSanitizer.h" #include "Common/Cpp/Json/JsonValue.h" diff --git a/SerialPrograms/Source/CommonFramework/Options/Environment/ThemeSelectorOption.cpp b/SerialPrograms/Source/CommonFramework/Options/Environment/ThemeSelectorOption.cpp index dc6879182f..5223ad69c2 100644 --- a/SerialPrograms/Source/CommonFramework/Options/Environment/ThemeSelectorOption.cpp +++ b/SerialPrograms/Source/CommonFramework/Options/Environment/ThemeSelectorOption.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "Common/Cpp/ColoredText.h" #include "Common/Cpp/Exceptions.h" #include "CommonFramework/Windows/DpiScaler.h" #include "ThemeSelectorOption.h" @@ -14,11 +15,9 @@ namespace PokemonAutomation{ -size_t current_theme = 0; - void set_theme(size_t index){ - if (index == current_theme){ + if (index == CURRENT_THEME){ return; } QString stylesheet; @@ -42,7 +41,7 @@ void set_theme(size_t index){ QApplication* app = static_cast(QApplication::instance()); app->setStyleSheet(stylesheet); - current_theme = index; + CURRENT_THEME = index; } @@ -72,46 +71,6 @@ void ThemeSelectorOption::load_json(const JsonValue& json){ -#if 1 -Color theme_friendly_darkblue(){ - if (current_theme == 1){ - return Color(0xff0080ff); - } - return COLOR_DARK_BLUE; -} -#endif -std::string html_color_text(const std::string& text, Color color){ - if (color == Color()){ - return text; - } - const char HEX[] = "0123456789abcdef"; - uint32_t rgb = (uint32_t)color; - std::string str; - str += HEX[(rgb >> 20) & 15]; - str += HEX[(rgb >> 16) & 15]; - str += HEX[(rgb >> 12) & 15]; - str += HEX[(rgb >> 8) & 15]; - str += HEX[(rgb >> 4) & 15]; - str += HEX[(rgb >> 0) & 15]; - return "" + text + ""; -} -std::string make_text_url(const std::string& url, const std::string& text){ -#if 0 - switch (current_theme){ - case 0: - return "" + text + ""; - case 1: - return "" + text + ""; - } - throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "Invalid theme #."); -#endif - return "" + text + ""; -} - - - - - diff --git a/SerialPrograms/Source/CommonFramework/Options/Environment/ThemeSelectorOption.h b/SerialPrograms/Source/CommonFramework/Options/Environment/ThemeSelectorOption.h index 78709ebf80..14e6398773 100644 --- a/SerialPrograms/Source/CommonFramework/Options/Environment/ThemeSelectorOption.h +++ b/SerialPrograms/Source/CommonFramework/Options/Environment/ThemeSelectorOption.h @@ -7,7 +7,6 @@ #ifndef PokemonAutomation_ThemeSelectorOption_H #define PokemonAutomation_ThemeSelectorOption_H -#include "Common/Cpp/Color.h" #include "Common/Cpp/Options/EnumDropdownOption.h" namespace PokemonAutomation{ @@ -22,9 +21,6 @@ class ThemeSelectorOption : public IntegerEnumDropdownOption{ }; -Color theme_friendly_darkblue(); -std::string html_color_text(const std::string& text, Color color); -std::string make_text_url(const std::string& url, const std::string& text); diff --git a/SerialPrograms/Source/CommonFramework/Panels/UI/PanelElements.cpp b/SerialPrograms/Source/CommonFramework/Panels/UI/PanelElements.cpp index 7d63a67034..64b16dbf45 100644 --- a/SerialPrograms/Source/CommonFramework/Panels/UI/PanelElements.cpp +++ b/SerialPrograms/Source/CommonFramework/Panels/UI/PanelElements.cpp @@ -9,7 +9,7 @@ #include #include #include "CommonFramework/Globals.h" -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "Common/Cpp/ColoredText.h" #include "PanelElements.h" namespace PokemonAutomation{ diff --git a/SerialPrograms/Source/CommonFramework/Startup/NewVersionCheck.cpp b/SerialPrograms/Source/CommonFramework/Startup/NewVersionCheck.cpp index ec326bb632..bd4db94e50 100644 --- a/SerialPrograms/Source/CommonFramework/Startup/NewVersionCheck.cpp +++ b/SerialPrograms/Source/CommonFramework/Startup/NewVersionCheck.cpp @@ -10,7 +10,7 @@ #include "Common/Cpp/Json/JsonObject.h" #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonFramework/Options/CheckForUpdatesOption.h" -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "Common/Cpp/ColoredText.h" #include "CommonFramework/Tools/FileDownloader.h" #include "CommonFramework/Globals.h" #include "CommonFramework/GlobalSettingsPanel.h" diff --git a/SerialPrograms/Source/CommonFramework/Windows/MainWindow.cpp b/SerialPrograms/Source/CommonFramework/Windows/MainWindow.cpp index 515c432905..e3a8163b1b 100644 --- a/SerialPrograms/Source/CommonFramework/Windows/MainWindow.cpp +++ b/SerialPrograms/Source/CommonFramework/Windows/MainWindow.cpp @@ -22,7 +22,7 @@ #include "CommonFramework/Logging/LoggerWindow.h" #include "CommonFramework/Startup/NewVersionCheck.h" #include "CommonFramework/Options/ResolutionOption.h" -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "Common/Cpp/ColoredText.h" #include "CommonFramework/Windows/DpiScaler.h" #include "PanelLists.h" #include "WindowTracker.h" diff --git a/SerialPrograms/Source/Controllers/ControllerConnection.cpp b/SerialPrograms/Source/Controllers/ControllerConnection.cpp index 6d479d5be7..d875dc0702 100644 --- a/SerialPrograms/Source/Controllers/ControllerConnection.cpp +++ b/SerialPrograms/Source/Controllers/ControllerConnection.cpp @@ -4,7 +4,7 @@ * */ -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "Common/Cpp/ColoredText.h" #include "ControllerConnection.h" //#include diff --git a/SerialPrograms/Source/Controllers/PABotBase2/PABotBase2_DeviceHandle.cpp b/SerialPrograms/Source/Controllers/PABotBase2/PABotBase2_DeviceHandle.cpp index c19e9bd246..1d65c3db88 100644 --- a/SerialPrograms/Source/Controllers/PABotBase2/PABotBase2_DeviceHandle.cpp +++ b/SerialPrograms/Source/Controllers/PABotBase2/PABotBase2_DeviceHandle.cpp @@ -9,7 +9,7 @@ #include "Common/Cpp/PrettyPrint.h" #include "Common/PABotBase2/PABotBase2CC_MessageDumper.h" #include "CommonFramework/Globals.h" -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "Common/Cpp/ColoredText.h" #include "CommonFramework/GlobalSettingsPanel.h" #include "Controllers/ControllerTypeStrings.h" #include "Controllers/SerialPABotBase/SerialPABotBase.h" diff --git a/SerialPrograms/Source/Controllers/PABotBase2/SerialPABotBase2_Connection.cpp b/SerialPrograms/Source/Controllers/PABotBase2/SerialPABotBase2_Connection.cpp index 4fc1625238..29d6ecbe22 100644 --- a/SerialPrograms/Source/Controllers/PABotBase2/SerialPABotBase2_Connection.cpp +++ b/SerialPrograms/Source/Controllers/PABotBase2/SerialPABotBase2_Connection.cpp @@ -12,7 +12,7 @@ #include "Common/PABotBase2/PABotBase2_MessageProtocol.h" #include "CommonFramework/Globals.h" #include "CommonFramework/GlobalSettingsPanel.h" -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "Common/Cpp/ColoredText.h" #include "CommonFramework/Tools/GlobalThreadPools.h" #include "Controllers/SerialPortPollerQt.h" #include "Controllers/SerialPABotBase/SerialPABotBase.h" diff --git a/SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Connection.cpp b/SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Connection.cpp index 749b690e0f..2510baf65c 100644 --- a/SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Connection.cpp +++ b/SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_Connection.cpp @@ -13,7 +13,7 @@ #include "Common/Cpp/SerialConnection/SerialConnection.h" #include "CommonFramework/Globals.h" #include "CommonFramework/GlobalSettingsPanel.h" -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "Common/Cpp/ColoredText.h" #include "CommonFramework/Tools/GlobalThreadPools.h" #include "Controllers/ControllerTypeStrings.h" #include "Controllers/SerialPABotBase/Messages/SerialPABotBase_MessageWrappers_BaseProtocol_Errors.h" diff --git a/SerialPrograms/Source/Controllers/StandardHid/StandardHid_Keyboard_PABotBase2.cpp b/SerialPrograms/Source/Controllers/StandardHid/StandardHid_Keyboard_PABotBase2.cpp index 6424c4df94..c57517b609 100644 --- a/SerialPrograms/Source/Controllers/StandardHid/StandardHid_Keyboard_PABotBase2.cpp +++ b/SerialPrograms/Source/Controllers/StandardHid/StandardHid_Keyboard_PABotBase2.cpp @@ -6,7 +6,7 @@ #include "Common/SerialPABotBase/SerialPABotBase_Protocol_IDs.h" #include "Common/PABotBase2/Controllers/PABotBase2_Controller_HID_Keyboard.h" -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "Common/Cpp/ColoredText.h" #include "StandardHid_Keyboard_PABotBase2.h" namespace PokemonAutomation{ diff --git a/SerialPrograms/Source/ML/UI/ML_ImageAnnotationCommandRow.cpp b/SerialPrograms/Source/ML/UI/ML_ImageAnnotationCommandRow.cpp index 5728f67742..abd2383467 100644 --- a/SerialPrograms/Source/ML/UI/ML_ImageAnnotationCommandRow.cpp +++ b/SerialPrograms/Source/ML/UI/ML_ImageAnnotationCommandRow.cpp @@ -7,7 +7,7 @@ #include #include "Common/Qt/Options/ConfigWidget.h" #include "CommonFramework/GlobalSettingsPanel.h" -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "Common/Cpp/ColoredText.h" #include "CommonFramework/Recording/StreamHistoryOption.h" #include "ML_ImageAnnotationCommandRow.h" diff --git a/SerialPrograms/Source/NintendoSwitch/Controllers/PABotBase2/NintendoSwitch_PABotBase2_OemController.cpp b/SerialPrograms/Source/NintendoSwitch/Controllers/PABotBase2/NintendoSwitch_PABotBase2_OemController.cpp index c36c547394..7f1e99c781 100644 --- a/SerialPrograms/Source/NintendoSwitch/Controllers/PABotBase2/NintendoSwitch_PABotBase2_OemController.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Controllers/PABotBase2/NintendoSwitch_PABotBase2_OemController.cpp @@ -5,7 +5,7 @@ */ #include "Common/PABotBase2/Controllers/PABotBase2_Controller_NS1_OemController.h" -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "Common/Cpp/ColoredText.h" #include "Controllers/SerialPABotBase/SerialPABotBase.h" #include "NintendoSwitch/NintendoSwitch_Settings.h" #include "NintendoSwitch_PABotBase2_OemController.h" diff --git a/SerialPrograms/Source/NintendoSwitch/Controllers/PABotBase2/NintendoSwitch_PABotBase2_WiredController.cpp b/SerialPrograms/Source/NintendoSwitch/Controllers/PABotBase2/NintendoSwitch_PABotBase2_WiredController.cpp index 60ee5e9ca1..81a7c202cc 100644 --- a/SerialPrograms/Source/NintendoSwitch/Controllers/PABotBase2/NintendoSwitch_PABotBase2_WiredController.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Controllers/PABotBase2/NintendoSwitch_PABotBase2_WiredController.cpp @@ -6,7 +6,7 @@ #include "Common/SerialPABotBase/SerialPABotBase_Protocol_IDs.h" #include "Common/PABotBase2/Controllers/PABotBase2_Controller_NS_WiredController.h" -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "Common/Cpp/ColoredText.h" #include "Controllers/JoystickTools.h" #include "NintendoSwitch_PABotBase2_WiredController.h" diff --git a/SerialPrograms/Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_WiredController.cpp b/SerialPrograms/Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_WiredController.cpp index 067803c19e..344d80bc26 100644 --- a/SerialPrograms/Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_WiredController.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_WiredController.cpp @@ -5,7 +5,7 @@ */ #include "Common/Cpp/Exceptions.h" -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "Common/Cpp/ColoredText.h" #include "Controllers/JoystickTools.h" #include "Controllers/SerialPABotBase/SerialPABotBase.h" #include "Controllers/SerialPABotBase/Messages/SerialPABotBase_MessageWrappers_BaseProtocol_ControllerMode.h" diff --git a/SerialPrograms/Source/NintendoSwitch/Controllers/SysbotBase/SysbotBase_Connection.cpp b/SerialPrograms/Source/NintendoSwitch/Controllers/SysbotBase/SysbotBase_Connection.cpp index c61dcda3cb..a1aa65bad7 100644 --- a/SerialPrograms/Source/NintendoSwitch/Controllers/SysbotBase/SysbotBase_Connection.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Controllers/SysbotBase/SysbotBase_Connection.cpp @@ -8,7 +8,7 @@ #include "Common/Cpp/Time.h" //#include "CommonFramework/Logging/Logger.h" #include "CommonFramework/GlobalSettingsPanel.h" -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "Common/Cpp/ColoredText.h" #include "CommonFramework/Tools/GlobalThreadPools.h" #include "NintendoSwitch/NintendoSwitch_Settings.h" #include "SysbotBase_Connection.h" diff --git a/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_CommandRow.cpp b/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_CommandRow.cpp index 821ab5480c..c9c616f2ef 100644 --- a/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_CommandRow.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Framework/UI/NintendoSwitch_CommandRow.cpp @@ -7,7 +7,7 @@ #include #include "Common/Qt/Options/ConfigWidget.h" #include "CommonFramework/GlobalSettingsPanel.h" -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "Common/Cpp/ColoredText.h" #include "CommonFramework/Panels/ConsoleSettingsStretch.h" #include "CommonFramework/Recording/StreamHistoryOption.h" #include "ControllerInput/ControllerInput.h" diff --git a/SerialPrograms/Source/PokemonLA/Options/PokemonLA_ShinyDetectedAction.cpp b/SerialPrograms/Source/PokemonLA/Options/PokemonLA_ShinyDetectedAction.cpp index 16132c4ba8..d6c46df50e 100644 --- a/SerialPrograms/Source/PokemonLA/Options/PokemonLA_ShinyDetectedAction.cpp +++ b/SerialPrograms/Source/PokemonLA/Options/PokemonLA_ShinyDetectedAction.cpp @@ -6,7 +6,7 @@ #include #include "CommonFramework/Exceptions/ProgramFinishedException.h" -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "Common/Cpp/ColoredText.h" #include "CommonFramework/Notifications/ProgramNotifications.h" #include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonFramework/Tools/ProgramEnvironment.h" diff --git a/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp b/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp index d5ff041211..85d9907f50 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggAutonomous.cpp @@ -10,7 +10,7 @@ #include "CommonFramework/Exceptions/FatalProgramException.h" #include "CommonFramework/Exceptions/OperationFailedException.h" //#include "CommonFramework/Exceptions/UnexpectedBattleException.h" -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "Common/Cpp/ColoredText.h" #include "CommonFramework/Notifications/ProgramNotifications.h" #include "CommonFramework/ProgramStats/StatsTracking.h" #include "CommonFramework/VideoPipeline/VideoFeed.h" diff --git a/SerialPrograms/Source/PokemonSwSh/Programs/DateSpamFarmers/PokemonSwSh_DateSpam-BerryFarmer2.cpp b/SerialPrograms/Source/PokemonSwSh/Programs/DateSpamFarmers/PokemonSwSh_DateSpam-BerryFarmer2.cpp index af1538f529..956cef6707 100644 --- a/SerialPrograms/Source/PokemonSwSh/Programs/DateSpamFarmers/PokemonSwSh_DateSpam-BerryFarmer2.cpp +++ b/SerialPrograms/Source/PokemonSwSh/Programs/DateSpamFarmers/PokemonSwSh_DateSpam-BerryFarmer2.cpp @@ -8,7 +8,7 @@ #include "Common/Cpp/Time.h" #include "CommonFramework/Exceptions/ProgramFinishedException.h" #include "CommonFramework/Notifications/ProgramNotifications.h" -#include "CommonFramework/Options/Environment/ThemeSelectorOption.h" +#include "Common/Cpp/ColoredText.h" #include "CommonFramework/VideoPipeline/VideoFeed.h" #include "CommonTools/Async/InferenceRoutines.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index ec6ad35870..84ad8bbcb3 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -26,6 +26,8 @@ file(GLOB LIBRARY_SOURCES ../Common/Cpp/CancellableScope.h ../Common/Cpp/Color.cpp ../Common/Cpp/Color.h + ../Common/Cpp/ColoredText.cpp + ../Common/Cpp/ColoredText.h ../Common/Cpp/Concurrency/AsyncTask.h ../Common/Cpp/Concurrency/Backends/AsyncTask_Default.h ../Common/Cpp/Concurrency/Backends/Thread_Qt.tpp