From 94020e5a0401983790384785ab55953c380d7763 Mon Sep 17 00:00:00 2001 From: MrBesen Date: Fri, 26 Aug 2022 13:47:21 +0200 Subject: [PATCH] add smitewarn checkbox to ui --- include/config.h | 1 + include/lolautoaccept.h | 2 ++ include/mainwindow.h | 1 + src/config.cpp | 2 ++ src/lolautoaccept.cpp | 8 +++++++- src/mainwindow.cpp | 10 ++++++++++ ui/mainwindow.ui | 40 +++++++++++++++++++++++++++++++++++----- 7 files changed, 58 insertions(+), 6 deletions(-) diff --git a/include/config.h b/include/config.h index 3103d2e..afcd7db 100644 --- a/include/config.h +++ b/include/config.h @@ -37,6 +37,7 @@ public: std::vector> positionConfigs; bool enabledAutoAccept; + bool enabledSmiteWarn; }; Config(); diff --git a/include/lolautoaccept.h b/include/lolautoaccept.h index 0bc3bb1..06820ad 100644 --- a/include/lolautoaccept.h +++ b/include/lolautoaccept.h @@ -48,6 +48,7 @@ protected: std::vector runestyles; bool nextApplyRunes = false; + bool smiteWarnEnabled = true; std::string chatid; // the chatid of the chat from the champselect std::chrono::time_point lastMessageSent; @@ -64,6 +65,7 @@ public: void setChamps(const std::vector& champs, State s); void setEnabled(bool b, State s); + void setSmiteWarn(bool b); bool init(); // returns true on success void run(); diff --git a/include/mainwindow.h b/include/mainwindow.h index 1852cb3..f5bea9b 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -26,6 +26,7 @@ protected: private slots: void toggleMainswitch(bool); void aatoggled(bool); + void smitewarntoggled(bool); void tabtoggled(Position, LolAutoAccept::State, bool); void tabchanged(Position, LolAutoAccept::State); diff --git a/src/config.cpp b/src/config.cpp index 3a81a6e..4b12fb4 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -87,6 +87,7 @@ Config::RootConfig::RootConfig(const QJsonObject& j) { } enabledAutoAccept = getValue(j, "enabledAutoAccept", true); + enabledSmiteWarn = getValue(j, "enabledSmiteWarn", true); } Config::RootConfig::operator QJsonObject() const { @@ -99,6 +100,7 @@ Config::RootConfig::operator QJsonObject() const { out["positions"] = positionarr; out.insert("enabledAutoAccept", enabledAutoAccept); + out.insert("enabledSmiteWarn", enabledSmiteWarn); return out; } diff --git a/src/lolautoaccept.cpp b/src/lolautoaccept.cpp index 4e47f72..c557a90 100644 --- a/src/lolautoaccept.cpp +++ b/src/lolautoaccept.cpp @@ -41,6 +41,10 @@ void LolAutoAccept::setEnabled(bool b, State s) { stages.at((int) s).enabled = b; } +void LolAutoAccept::setSmiteWarn(bool b) { + smiteWarnEnabled = b; +} + bool LolAutoAccept::init() { if(clientapi) return true; @@ -430,7 +434,9 @@ void LolAutoAccept::champSelect() { // trade? // check for smite - smiteWarning(session.myTeam); + if(smiteWarnEnabled) { + smiteWarning(session.myTeam); + } } if(nextApplyRunes) { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0d7d2e2..eece646 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -24,6 +24,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi ui->enableAll->setChecked(rc.enabledAutoAccept); lolaa.setEnabled(rc.enabledAutoAccept, LolAutoAccept::State::LOBBY); + ui->enableSmiteWarning->setChecked(rc.enabledSmiteWarn); + lolaa.setSmiteWarn(rc.enabledSmiteWarn); + resizeEvent(nullptr); } @@ -75,6 +78,13 @@ void MainWindow::aatoggled(bool state) { conf.getConfig().enabledAutoAccept = state; } +void MainWindow::smitewarntoggled(bool state) { + Log::info << "smitewarn checkbox toggled " << state; + + lolaa.setSmiteWarn(state); + conf.getConfig().enabledSmiteWarn = state; +} + void MainWindow::tabtoggled(Position p, LolAutoAccept::State s, bool state) { Log::info << "checkbox toggled " << state << " position: " << p << " state: " << (int) s; diff --git a/ui/mainwindow.ui b/ui/mainwindow.ui index 549a9b3..4faaa7e 100644 --- a/ui/mainwindow.ui +++ b/ui/mainwindow.ui @@ -53,6 +53,19 @@ + + + + Spam "smite" in the chat when there is not exactly 1 player with smite equiped in champ select + + + Enable Smite Warning + + + true + + + @@ -138,7 +151,7 @@ 0 0 452 - 24 + 21 @@ -174,8 +187,8 @@ aatoggled(bool) - 18 - 80 + 19 + 61 393 @@ -190,8 +203,8 @@ toggleMainswitch(bool) - 87 - 49 + 88 + 38 1 @@ -231,6 +244,22 @@ + + enableSmiteWarning + clicked(bool) + MainWindow + smitewarntoggled(bool) + + + 190 + 77 + + + 201 + 88 + + + requestTabChange(int) @@ -239,5 +268,6 @@ tabchanged(Position, LolAutoAccept::State) toggleMainswitch(bool) applyRunes() + smitewarntoggled(bool)