Skip to content

Commit

Permalink
convenience changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pifopi committed Dec 22, 2024
1 parent c0685e6 commit 5f66392
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/cpp-ci-serial-programs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
- uses: actions/checkout@v4
with:
path: Arduino-Source
- uses: actions/checkout@v4
with:
repository: 'PokemonAutomation/Arduino-Source-Internal'
path: Arduino-Source-Internal
token: ${{ secrets.PA_TOKEN }}
- uses: actions/checkout@v4
with:
repository: 'PokemonAutomation/Packages'
Expand Down
6 changes: 6 additions & 0 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x050F00)
link_directories(${CMAKE_CURRENT_LIST_DIR})

file(GLOB MAIN_SOURCES
../../Arduino-Source-Internal/Repository/Internal/SerialPrograms/PokemonSV_TeraCardFinder.cpp
../../Arduino-Source-Internal/Repository/Internal/SerialPrograms/PokemonSV_TeraCardFinder.h
../../Arduino-Source-Internal/Repository/Internal/SerialPrograms/PokemonSV_TeraCardJoiner.cpp
../../Arduino-Source-Internal/Repository/Internal/SerialPrograms/PokemonSV_TeraCardJoiner.h
../../Arduino-Source-Internal/Repository/Internal/SerialPrograms/PokemonSV_TextRaidJoiner.cpp
../../Arduino-Source-Internal/Repository/Internal/SerialPrograms/PokemonSV_TextRaidJoiner.h
../3rdParty/QtWavFile/WavFile.cpp
../3rdParty/QtWavFile/WavFile.h
../3rdParty/TesseractPA/TesseractPA.cpp
Expand Down
6 changes: 6 additions & 0 deletions SerialPrograms/SerialPrograms.pro
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ macx{


SOURCES += \
../../Arduino-Source-Internal/Repository/Internal/SerialPrograms/PokemonSV_TeraCardFinder.cpp \
../../Arduino-Source-Internal/Repository/Internal/SerialPrograms/PokemonSV_TeraCardJoiner.cpp \
../../Arduino-Source-Internal/Repository/Internal/SerialPrograms/PokemonSV_VideoFastCodeEntry.cpp \
../3rdParty/QtWavFile/WavFile.cpp \
../3rdParty/TesseractPA/TesseractPA.cpp \
../ClientSource/Connection/BotBase.cpp \
Expand Down Expand Up @@ -1031,6 +1034,9 @@ SOURCES += \
Source/ZeldaTotK/ZeldaTotK_Settings.h

HEADERS += \
../../Arduino-Source-Internal/Repository/Internal/SerialPrograms/PokemonSV_TeraCardFinder.h \
../../Arduino-Source-Internal/Repository/Internal/SerialPrograms/PokemonSV_TeraCardJoiner.h \
../../Arduino-Source-Internal/Repository/Internal/SerialPrograms/PokemonSV_VideoFastCodeEntry.h \
../3rdParty/QtWavFile/WavFile.h \
../3rdParty/TesseractPA/TesseractPA.h \
../3rdParty/dpp/appcommand.h \
Expand Down
16 changes: 0 additions & 16 deletions SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,6 @@ void PreloadSettings::load(const JsonValue& json){
return;
}

// Naughty mode.
obj->read_boolean(NAUGHTY_MODE, "NAUGHTY_MODE");

// Developer mode stuff.
const std::string* dev_token = obj->get_string("DEVELOPER_TOKEN");
if (dev_token){
QCryptographicHash hash(QCryptographicHash::Algorithm::Sha256);
#if QT_VERSION < 0x060700
hash.addData(dev_token->c_str(), (int)dev_token->size());
#else
QByteArrayView dataView(dev_token->data(), dev_token->size());
hash.addData(dataView);
#endif
DEVELOPER_MODE = TOKENS.find(hash.result().toHex().toStdString()) != TOKENS.end();
}

const JsonObject* debug_obj = obj->get_object("DEBUG");
if (debug_obj){
debug_obj->read_boolean(DEBUG.COLOR_CHECK, "COLOR_CHECK");
Expand Down
4 changes: 2 additions & 2 deletions SerialPrograms/Source/CommonFramework/GlobalSettingsPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ class PreloadSettings{

void load(const JsonValue& json);

bool NAUGHTY_MODE = false;
bool DEVELOPER_MODE = false;
bool NAUGHTY_MODE = true;
bool DEVELOPER_MODE = true;

DebugSettings DEBUG;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ EventNotificationOption::~EventNotificationOption(){}
EventNotificationOption::EventNotificationOption(
std::string label,
bool enabled, bool ping,
std::chrono::seconds rate_limit
[[maybe_unused]] std::chrono::seconds rate_limit
)
: StaticTableRow(label)
, m_data(CONSTRUCT_TOKEN, std::move(label), enabled, ping, rate_limit)
, m_data(CONSTRUCT_TOKEN, std::move(label), enabled, ping, std::chrono::seconds(0))
, m_test_button(*this)
{
add_option(m_data->m_enabled, "Enabled");
Expand All @@ -196,10 +196,10 @@ EventNotificationOption::EventNotificationOption(
std::string label,
bool enabled, bool ping,
std::vector<std::string> tags,
std::chrono::seconds rate_limit
[[maybe_unused]] std::chrono::seconds rate_limit
)
: StaticTableRow(label)
, m_data(CONSTRUCT_TOKEN, std::move(label), enabled, ping, std::move(tags), rate_limit)
, m_data(CONSTRUCT_TOKEN, std::move(label), enabled, ping, std::move(tags), std::chrono::seconds(0))
, m_test_button(*this)
{
add_option(m_data->m_enabled, "Enabled");
Expand All @@ -217,10 +217,10 @@ EventNotificationOption::EventNotificationOption(
bool enabled, bool ping,
ImageAttachmentMode screenshot,
std::vector<std::string> tags,
std::chrono::seconds rate_limit
[[maybe_unused]] std::chrono::seconds rate_limit
)
: StaticTableRow(label)
, m_data(CONSTRUCT_TOKEN, std::move(label), enabled, ping, screenshot, std::move(tags), rate_limit)
, m_data(CONSTRUCT_TOKEN, std::move(label), enabled, ping, screenshot, std::move(tags), std::chrono::seconds(0))
, m_test_button(*this)
{
add_option(m_data->m_enabled, "Enabled");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ LanguageOCRCell::LanguageOCRCell(
std::forward_as_tuple(language),
std::forward_as_tuple(index)
);
if (language == Language::French){
m_default = index;
m_current = index;
}
index++;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class LanguageOCRCell : public ConfigOption{

std::vector<std::pair<Language, bool>> m_case_list;
std::map<Language, size_t> m_case_map;
const size_t m_default;
size_t m_default;

std::atomic<size_t> m_current;
};
Expand Down
51 changes: 47 additions & 4 deletions SerialPrograms/Source/Integrations/DiscordIntegrationSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ DiscordIntegrationSettingsOption::~DiscordIntegrationSettingsOption(){
DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption()
: GroupOption(
"Discord Integration Settings",
LockMode::LOCK_WHILE_RUNNING,
GroupOption::EnableMode::DEFAULT_DISABLED
LockMode::LOCK_WHILE_RUNNING
)
// , m_integration_enabled(integration_enabled)
, run_on_start(
"<b>Run Discord Integration on Launch:</b><br>Automatically connect to Discord as soon as the program is launched.",
LockMode::LOCK_WHILE_RUNNING,
false
true
)
, library0(
"<b>Discord Integration Library:</b><br>Restart the program for this to take effect.",
Expand All @@ -61,7 +60,7 @@ DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption()
true,
"<b>Discord Token:</b><br>Enter your Discord bot's token. Keep it safe and don't share it with anyone.",
LockMode::LOCK_WHILE_RUNNING,
"", "0123456789abcdefghijklmnopqrstuvwxyzABCDEGFHIJKLMNOPQRSTUVWXYZ"
std::getenv("DISCORD_BOT_TOKEN"), "0123456789abcdefghijklmnopqrstuvwxyzABCDEGFHIJKLMNOPQRSTUVWXYZ"
)
, command_prefix(
false,
Expand Down Expand Up @@ -119,6 +118,50 @@ DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption()

DiscordIntegrationSettingsOption::value_changed(this);

{
std::unique_ptr<EditableTableRow> channel = channels.make_row();
DiscordIntegrationChannel* channel_casted = static_cast<DiscordIntegrationChannel*>(channel.get());
channel_casted->label.set("Alone#pokemonautomation");
channel_casted->channel_id.set("907578334119071775");
channels.insert_row(channels.current_rows(), std::move(channel));
}
{
std::unique_ptr<EditableTableRow> channel = channels.make_row();
DiscordIntegrationChannel* channel_casted = static_cast<DiscordIntegrationChannel*>(channel.get());
channel_casted->label.set("PA#shiny-bot-logs");
channel_casted->tags_text.set("Showcase");
channel_casted->allow_commands = false;
channel_casted->channel_id.set("898882421129375835");
channels.insert_row(channels.current_rows(), std::move(channel));
}
{
std::unique_ptr<EditableTableRow> channel = channels.make_row();
DiscordIntegrationChannel* channel_casted = static_cast<DiscordIntegrationChannel*>(channel.get());
channel_casted->label.set("PA#live-hosting");
channel_casted->tags_text.set("LiveHost");
channel_casted->allow_commands = false;
channel_casted->channel_id.set("885388078066307102");
channels.insert_row(channels.current_rows(), std::move(channel));
}
{
std::unique_ptr<EditableTableRow> channel = channels.make_row();
DiscordIntegrationChannel* channel_casted = static_cast<DiscordIntegrationChannel*>(channel.get());
channel_casted->label.set("SHA#live-hosting");
channel_casted->tags_text.set("LiveHost");
channel_casted->allow_commands = false;
channel_casted->channel_id.set("885388760370520114");
channels.insert_row(channels.current_rows(), std::move(channel));
}
{
std::unique_ptr<EditableTableRow> channel = channels.make_row();
DiscordIntegrationChannel* channel_casted = static_cast<DiscordIntegrationChannel*>(channel.get());
channel_casted->label.set("PA#tera-join-reports");
channel_casted->tags_text.set("Telemetry");
channel_casted->allow_commands = false;
channel_casted->channel_id.set("1052784581809545327");
channels.insert_row(channels.current_rows(), std::move(channel));
}

this->add_listener(*this);
library0.add_listener(*this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ DiscordMessageSettingsOption::DiscordMessageSettingsOption()
false,
"<b>Discord User ID:</b><br>Set this to your discord user ID to receive pings. Your ID is a number.",
LockMode::LOCK_WHILE_RUNNING,
"",
"282197676982927375",
"123456789012345678"
)
, message(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ FastCodeEntrySettingsOption::FastCodeEntrySettingsOption(LockMode lock_while_pro
{KeyboardLayout::AZERTY, "azerty", "AZERTY"},
},
LockMode::LOCK_WHILE_RUNNING,
KeyboardLayout::QWERTY
KeyboardLayout::AZERTY
)
, SKIP_PLUS(
"<b>Skip the Plus:</b><br>Don't press + to finalize the code. Useful for testing.",
Expand Down
5 changes: 5 additions & 0 deletions SerialPrograms/Source/PokemonSV/PokemonSV_Panels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
#include "../../Internal/SerialPrograms/NintendoSwitch_TestPrograms.h"
#endif

#include "../../../Arduino-Source-Internal/Repository/Internal/SerialPrograms/PokemonSV_TeraCardJoiner.h"
#include "../../../Arduino-Source-Internal/Repository/Internal/SerialPrograms/PokemonSV_TextRaidJoiner.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonSV{
Expand Down Expand Up @@ -125,6 +128,8 @@ std::vector<PanelEntry> PanelListFactory::make_panels() const{
ret.emplace_back("---- Fast Code Entry ----");
ret.emplace_back(make_multi_switch_program<FastCodeEntry_Descriptor, FastCodeEntry>());
ret.emplace_back(make_multi_switch_program<ClipboardFastCodeEntry_Descriptor, ClipboardFastCodeEntry>());
ret.emplace_back(make_multi_switch_program<TeraCardJoiner_Descriptor, TeraCardJoiner>());
ret.emplace_back(make_multi_switch_program<TextRaidJoiner_Descriptor, TextRaidJoiner>());
ret.emplace_back(make_multi_switch_program<VideoFastCodeEntry_Descriptor, VideoFastCodeEntry>());

ret.emplace_back("---- Stats Hunting ----");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ FlyingTrialFarmer::FlyingTrialFarmer()
"<b>Inverted controls while flying:</b><br>"
"Check this option if you have inverted controls on during flying.",
LockMode::UNLOCK_WHILE_RUNNING,
false
true
)
, NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(3600))
, NOTIFICATIONS({
Expand Down
9 changes: 9 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pushd %~dp0
cd SerialPrograms
mkdir bin
cd bin
cmake .. -DCMAKE_PREFIX_PATH=C:\Qt\6.8.1\msvc2022_64\
cmake --build . --config RelWithDebInfo --parallel 10
robocopy ..\..\..\Packages\SerialPrograms\Resources\ Resources\ /s
robocopy ..\..\..\CommandLineTests\ . /s
popd

0 comments on commit 5f66392

Please sign in to comment.