add dodge button
This commit is contained in:
parent
2cacbfe27f
commit
b1c4739138
|
@ -195,6 +195,7 @@ public:
|
||||||
ChampSelectSession getChampSelectSession();
|
ChampSelectSession getChampSelectSession();
|
||||||
bool setChampSelectAction(int32_t actionid, int32_t champid, bool completed);
|
bool setChampSelectAction(int32_t actionid, int32_t champid, bool completed);
|
||||||
PlayerInfo getSelf();
|
PlayerInfo getSelf();
|
||||||
|
void dodge();
|
||||||
|
|
||||||
std::vector<int32_t> getBannableChampIDs();
|
std::vector<int32_t> getBannableChampIDs();
|
||||||
std::vector<int32_t> getPickableChampIDs();
|
std::vector<int32_t> getPickableChampIDs();
|
||||||
|
|
|
@ -45,6 +45,8 @@ protected:
|
||||||
std::vector<RuneAspekt> runeaspekts;
|
std::vector<RuneAspekt> runeaspekts;
|
||||||
std::vector<RuneStyle> runestyles;
|
std::vector<RuneStyle> runestyles;
|
||||||
|
|
||||||
|
ClientAPI::GameflowPhase lastPhase;
|
||||||
|
bool dodgeNow = false;
|
||||||
bool nextApplyRunes = false;
|
bool nextApplyRunes = false;
|
||||||
bool smiteWarnEnabled = true;
|
bool smiteWarnEnabled = true;
|
||||||
bool autoWriteTextEnabled = false;
|
bool autoWriteTextEnabled = false;
|
||||||
|
@ -86,9 +88,13 @@ public:
|
||||||
const std::vector<RuneStyle>& getRuneStyles();
|
const std::vector<RuneStyle>& getRuneStyles();
|
||||||
void setAutoWriteText(bool enabled, const QString& text = {});
|
void setAutoWriteText(bool enabled, const QString& text = {});
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void dodge();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void statusChanged(LolAutoAccept::Status); // new status: 0 = off, 1 = on, 2 = failed
|
void statusChanged(LolAutoAccept::Status); // new status: 0 = off, 1 = on, 2 = failed
|
||||||
void positionChanged(Position);
|
void positionChanged(Position);
|
||||||
|
void dodgePossible(bool); // true = the dodge button is available
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void stopJoinThread();
|
void stopJoinThread();
|
||||||
|
|
|
@ -12,6 +12,7 @@ QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class MainWindow; }
|
namespace Ui { class MainWindow; }
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
class QMessageBox;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
|
||||||
class LoadingWindow;
|
class LoadingWindow;
|
||||||
|
@ -61,6 +62,7 @@ private:
|
||||||
Config conf;
|
Config conf;
|
||||||
LolAutoAccept lolaa;
|
LolAutoAccept lolaa;
|
||||||
LoadingWindow* lwin;
|
LoadingWindow* lwin;
|
||||||
|
QMessageBox* dodgeQuestion;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -108,6 +108,11 @@ ClientAPI::PlayerInfo ClientAPI::getSelf() {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClientAPI::dodge() {
|
||||||
|
QJsonDocument doc = request("lol-login/v1/session/invoke?destination=lcdsServiceProxy&method=call&args=[\"\",\"teambuilder-draft\",\"quitV2\", \"\"]", Method::POST, "");
|
||||||
|
qDebug() << "dodge result:" << doc;
|
||||||
|
}
|
||||||
|
|
||||||
static std::vector<int32_t> fromArrayToVector(const QJsonArray& arr) {
|
static std::vector<int32_t> fromArrayToVector(const QJsonArray& arr) {
|
||||||
std::vector<int32_t> out;
|
std::vector<int32_t> out;
|
||||||
out.reserve(arr.size());
|
out.reserve(arr.size());
|
||||||
|
|
|
@ -116,6 +116,10 @@ void LolAutoAccept::setAutoWriteText(bool enabled, const QString& text) {
|
||||||
autoWriteText = text;
|
autoWriteText = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LolAutoAccept::dodge() {
|
||||||
|
dodgeNow = true;
|
||||||
|
}
|
||||||
|
|
||||||
void LolAutoAccept::stopJoinThread() {
|
void LolAutoAccept::stopJoinThread() {
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
|
@ -161,6 +165,16 @@ void LolAutoAccept::innerRun() {
|
||||||
} else if(phase == ClientAPI::GameflowPhase::CHAMPSELECT) {
|
} else if(phase == ClientAPI::GameflowPhase::CHAMPSELECT) {
|
||||||
champSelect();
|
champSelect();
|
||||||
extrasleep = 0; // no extra sleep
|
extrasleep = 0; // no extra sleep
|
||||||
|
|
||||||
|
// first time champselect phase -> enable dodge button
|
||||||
|
if(lastPhase != phase) {
|
||||||
|
dodgeNow = false;
|
||||||
|
emit this->dodgePossible(true);
|
||||||
|
} else if (dodgeNow) {
|
||||||
|
// this makes sure that the event comes after the phase was entered and is not lingering from before
|
||||||
|
dodgeNow = false;
|
||||||
|
clientapi->dodge();
|
||||||
|
}
|
||||||
} else if(phase == ClientAPI::GameflowPhase::INPROGRESS) {
|
} else if(phase == ClientAPI::GameflowPhase::INPROGRESS) {
|
||||||
extrasleep = 30000; // 30s bonus sleep
|
extrasleep = 30000; // 30s bonus sleep
|
||||||
resetAllOffsets();
|
resetAllOffsets();
|
||||||
|
@ -178,6 +192,13 @@ void LolAutoAccept::innerRun() {
|
||||||
resetAllOffsets();
|
resetAllOffsets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// change phase to non champselect phase -> disable dodge button
|
||||||
|
if(phase != ClientAPI::GameflowPhase::CHAMPSELECT && lastPhase != phase) {
|
||||||
|
emit this->dodgePossible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
lastPhase = phase;
|
||||||
|
|
||||||
auto end = std::chrono::high_resolution_clock::now();
|
auto end = std::chrono::high_resolution_clock::now();
|
||||||
std::chrono::duration<double> dur = (end-start);
|
std::chrono::duration<double> dur = (end-start);
|
||||||
//if(dur.count() > 1e-5)
|
//if(dur.count() > 1e-5)
|
||||||
|
@ -214,6 +235,7 @@ void LolAutoAccept::resetAllOffsets() {
|
||||||
currentPositionSet = false;
|
currentPositionSet = false;
|
||||||
chatid.clear();
|
chatid.clear();
|
||||||
autoWriteTextDone = false;
|
autoWriteTextDone = false;
|
||||||
|
dodgeNow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LolAutoAccept::applyConfigToStage(Stage& stage, const Config::StageConfig& stageconf) {
|
void LolAutoAccept::applyConfigToStage(Stage& stage, const Config::StageConfig& stageconf) {
|
||||||
|
|
|
@ -3,13 +3,15 @@
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <Log.h>
|
#include <Log.h>
|
||||||
|
|
||||||
#include "loadingwindow.h"
|
#include "loadingwindow.h"
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), loading(true), ui(new Ui::MainWindow), saveTimer(new QTimer(this)), dd(QLocale().name()),
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), loading(true), ui(new Ui::MainWindow), saveTimer(new QTimer(this)), dd(QLocale().name()),
|
||||||
lolaa(conf.getConfig(), dd), lwin(new LoadingWindow(nullptr)) {
|
lolaa(conf.getConfig(), dd), lwin(new LoadingWindow(nullptr)),
|
||||||
|
dodgeQuestion(new QMessageBox(QMessageBox::Icon::Warning, MainWindow::tr("Dodge?"), MainWindow::tr("Are you sure you want to dodge?"), QMessageBox::Cancel | QMessageBox::Yes, this)) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
QObject::connect(&dd, &DataDragon::fetchingChamp, lwin, &LoadingWindow::setChampion);
|
QObject::connect(&dd, &DataDragon::fetchingChamp, lwin, &LoadingWindow::setChampion);
|
||||||
|
@ -19,6 +21,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), loading(true), ui
|
||||||
QObject::connect(lwin, &LoadingWindow::closed, qApp, &QCoreApplication::quit, Qt::ConnectionType::QueuedConnection);
|
QObject::connect(lwin, &LoadingWindow::closed, qApp, &QCoreApplication::quit, Qt::ConnectionType::QueuedConnection);
|
||||||
dd.startThread();
|
dd.startThread();
|
||||||
|
|
||||||
|
QObject::connect(&lolaa, &LolAutoAccept::dodgePossible, ui->dodgeBtn, &QAbstractButton::setEnabled);
|
||||||
|
QObject::connect(ui->dodgeBtn, &QAbstractButton::pressed, dodgeQuestion, &QMessageBox::show);
|
||||||
|
QObject::connect(dodgeQuestion, &QMessageBox::accepted, &lolaa, &LolAutoAccept::dodge);
|
||||||
QObject::connect(&lolaa, &LolAutoAccept::statusChanged, this, &MainWindow::lolaaStatusChanged);
|
QObject::connect(&lolaa, &LolAutoAccept::statusChanged, this, &MainWindow::lolaaStatusChanged);
|
||||||
QObject::connect(&lolaa, &LolAutoAccept::positionChanged, this, &MainWindow::onPosChange);
|
QObject::connect(&lolaa, &LolAutoAccept::positionChanged, this, &MainWindow::onPosChange);
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,9 @@ QByteArray RestClient::requestRaw(const QString& url, Method m, const QString& d
|
||||||
case Method::POST:
|
case Method::POST:
|
||||||
curl_easy_setopt(curl, CURLOPT_POST, 1L);
|
curl_easy_setopt(curl, CURLOPT_POST, 1L);
|
||||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, dataArr.data());
|
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, dataArr.data());
|
||||||
headerlist = curl_slist_append(headerlist, "Content-Type: application/json");
|
if(!dataArr.isEmpty()) {
|
||||||
|
headerlist = curl_slist_append(headerlist, "Content-Type: application/json");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Method::PUT:
|
case Method::PUT:
|
||||||
case Method::PATCH:
|
case Method::PATCH:
|
||||||
|
|
|
@ -19,6 +19,16 @@
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="textInteractionFlags">
|
||||||
|
<set>Qt::NoTextInteraction</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
<widget class="QProgressBar" name="progressBar">
|
<widget class="QProgressBar" name="progressBar">
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
@ -29,17 +39,36 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QPushButton" name="icon">
|
||||||
<property name="alignment">
|
<property name="focusPolicy">
|
||||||
<set>Qt::AlignCenter</set>
|
<enum>Qt::NoFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="textInteractionFlags">
|
<property name="contextMenuPolicy">
|
||||||
<set>Qt::NoTextInteraction</set>
|
<enum>Qt::NoContextMenu</enum>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../resources/res.qrc">
|
||||||
|
<normaloff>:/lolautoaccept.svg</normaloff>:/lolautoaccept.svg</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>64</width>
|
||||||
|
<height>64</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="flat">
|
||||||
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>icon</tabstop>
|
||||||
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../resources/res.qrc"/>
|
<include location="../resources/res.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
158
ui/mainwindow.ui
158
ui/mainwindow.ui
|
@ -62,13 +62,16 @@
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>9</number>
|
<number>9</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="5" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QCheckBox" name="enableAutoWrite">
|
<widget class="QCheckBox" name="enableSmiteWarning">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Write a Text as soon as you are in a champ select lobby.</string>
|
<string>Spam "smite" in the chat when there is not exactly 1 player with smite equiped in champ select</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Auto Write</string>
|
<string>Enable Smite Warning</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -94,73 +97,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QCheckBox" name="mainswitch">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>This controls the connection to the LoL client. As long as this is off, no interactions with the LoL client take place.</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Mainswitch</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
|
||||||
<widget class="QCheckBox" name="enableSmiteWarning">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Spam "smite" in the chat when there is not exactly 1 player with smite equiped in champ select</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Enable Smite Warning</string>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0" rowspan="2">
|
|
||||||
<widget class="QCheckBox" name="enableAll">
|
|
||||||
<property name="text">
|
|
||||||
<string>Enable LoL-Auto-Accept</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="0" colspan="2">
|
|
||||||
<widget class="QTextEdit" name="autoWriteText">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>80</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="baseSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Sunken</enum>
|
|
||||||
</property>
|
|
||||||
<property name="lineWrapMode">
|
|
||||||
<enum>QTextEdit::NoWrap</enum>
|
|
||||||
</property>
|
|
||||||
<property name="acceptRichText">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="textInteractionFlags">
|
|
||||||
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
|
||||||
</property>
|
|
||||||
<property name="placeholderText">
|
|
||||||
<string>autowriteText</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="7" column="0" colspan="2">
|
<item row="7" column="0" colspan="2">
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="tabPosition">
|
<property name="tabPosition">
|
||||||
|
@ -170,7 +106,7 @@
|
||||||
<enum>QTabWidget::Rounded</enum>
|
<enum>QTabWidget::Rounded</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>4</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="elideMode">
|
<property name="elideMode">
|
||||||
<enum>Qt::ElideNone</enum>
|
<enum>Qt::ElideNone</enum>
|
||||||
|
@ -254,6 +190,84 @@
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QCheckBox" name="enableAutoWrite">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Write a Text as soon as you are in a champ select lobby.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Auto Write</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0" colspan="2">
|
||||||
|
<widget class="QTextEdit" name="autoWriteText">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>80</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="baseSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Sunken</enum>
|
||||||
|
</property>
|
||||||
|
<property name="lineWrapMode">
|
||||||
|
<enum>QTextEdit::NoWrap</enum>
|
||||||
|
</property>
|
||||||
|
<property name="acceptRichText">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="textInteractionFlags">
|
||||||
|
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>autowriteText</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QCheckBox" name="mainswitch">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>This controls the connection to the LoL client. As long as this is off, no interactions with the LoL client take place.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Mainswitch</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" rowspan="2">
|
||||||
|
<widget class="QCheckBox" name="enableAll">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable LoL-Auto-Accept</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="0" colspan="2">
|
||||||
|
<widget class="QPushButton" name="dodgeBtn">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Dodge without closing the client.
|
||||||
|
You will still be punished.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Dodge</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="RuneManager" name="runesPage">
|
<widget class="RuneManager" name="runesPage">
|
||||||
|
|
Loading…
Reference in New Issue