Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions Common/Cpp/ColoredText.cpp
Original file line number Diff line number Diff line change
@@ -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 "<font color=#" + str + ">" + text + "</font>";
}
std::string make_text_url(const std::string& url, const std::string& text){
#if 0
switch (CURRENT_THEME){
case 0:
return "<a href=\"" + url + "\">" + text + "</a>";
case 1:
return "<a href=\"" + url + "\" style=\"color: #0080ff\">" + text + "</a>";
}
throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "Invalid theme #.");
#endif
return "<a href=\"" + url + "\" style=\"color: #0080ff\">" + text + "</a>";
}






}
23 changes: 23 additions & 0 deletions Common/Cpp/ColoredText.h
Original file line number Diff line number Diff line change
@@ -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 <string>

namespace PokemonAutomation{

inline size_t CURRENT_THEME = 0;

@Mysticial Mysticial Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is not ideal, but the themes aren't visible here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I agree. Is there a better way?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. Unless we move the theme definitions here.


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

Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <QCryptographicHash>
#include <QDesktopServices>
#include <QUrl>
#include "Common/Cpp/ColoredText.h"
#include "Common/Cpp/Containers/Pimpl.tpp"
#include "Common/Cpp/LifetimeSanitizer.h"
#include "Common/Cpp/Json/JsonValue.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@
#include <QFile>
#include <QTextStream>
#include <QApplication>
#include "Common/Cpp/ColoredText.h"
#include "Common/Cpp/Exceptions.h"
#include "CommonFramework/Windows/DpiScaler.h"
#include "ThemeSelectorOption.h"

namespace PokemonAutomation{


size_t current_theme = 0;


void set_theme(size_t index){
if (index == current_theme){
if (index == CURRENT_THEME){
return;
}
QString stylesheet;
Expand All @@ -42,7 +41,7 @@ void set_theme(size_t index){
QApplication* app = static_cast<QApplication*>(QApplication::instance());
app->setStyleSheet(stylesheet);

current_theme = index;
CURRENT_THEME = index;
}


Expand Down Expand Up @@ -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 "<font color=#" + str + ">" + text + "</font>";
}
std::string make_text_url(const std::string& url, const std::string& text){
#if 0
switch (current_theme){
case 0:
return "<a href=\"" + url + "\">" + text + "</a>";
case 1:
return "<a href=\"" + url + "\" style=\"color: #0080ff\">" + text + "</a>";
}
throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "Invalid theme #.");
#endif
return "<a href=\"" + url + "\" style=\"color: #0080ff\">" + text + "</a>";
}








Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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);



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <QLabel>
#include <QPushButton>
#include "CommonFramework/Globals.h"
#include "CommonFramework/Options/Environment/ThemeSelectorOption.h"
#include "Common/Cpp/ColoredText.h"
#include "PanelElements.h"

namespace PokemonAutomation{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion SerialPrograms/Source/Controllers/ControllerConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
*/

#include "CommonFramework/Options/Environment/ThemeSelectorOption.h"
#include "Common/Cpp/ColoredText.h"
#include "ControllerConnection.h"

//#include <iostream>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <QHBoxLayout>
#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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <QHBoxLayout>
#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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <sstream>
#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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions SerialPrograms/cmake/SourceFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading