add dodge button
This commit is contained in:
parent
2cacbfe27f
commit
b1c4739138
|
@ -195,6 +195,7 @@ public:
|
|||
ChampSelectSession getChampSelectSession();
|
||||
bool setChampSelectAction(int32_t actionid, int32_t champid, bool completed);
|
||||
PlayerInfo getSelf();
|
||||
void dodge();
|
||||
|
||||
std::vector<int32_t> getBannableChampIDs();
|
||||
std::vector<int32_t> getPickableChampIDs();
|
||||
|
|
|
@ -45,6 +45,8 @@ protected:
|
|||
std::vector<RuneAspekt> runeaspekts;
|
||||
std::vector<RuneStyle> runestyles;
|
||||
|
||||
ClientAPI::GameflowPhase lastPhase;
|
||||
bool dodgeNow = false;
|
||||
bool nextApplyRunes = false;
|
||||
bool smiteWarnEnabled = true;
|
||||
bool autoWriteTextEnabled = false;
|
||||
|
@ -86,9 +88,13 @@ public:
|
|||
const std::vector<RuneStyle>& getRuneStyles();
|
||||
void setAutoWriteText(bool enabled, const QString& text = {});
|
||||
|
||||
public slots:
|
||||
void dodge();
|
||||
|
||||
signals:
|
||||
void statusChanged(LolAutoAccept::Status); // new status: 0 = off, 1 = on, 2 = failed
|
||||
void positionChanged(Position);
|
||||
void dodgePossible(bool); // true = the dodge button is available
|
||||
|
||||
private:
|
||||
void stopJoinThread();
|
||||
|
|
|
@ -12,6 +12,7 @@ QT_BEGIN_NAMESPACE
|
|||
namespace Ui { class MainWindow; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class QMessageBox;
|
||||
class QTimer;
|
||||
|
||||
class LoadingWindow;
|
||||
|
@ -61,6 +62,7 @@ private:
|
|||
Config conf;
|
||||
LolAutoAccept lolaa;
|
||||
LoadingWindow* lwin;
|
||||
QMessageBox* dodgeQuestion;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
@ -108,6 +108,11 @@ ClientAPI::PlayerInfo ClientAPI::getSelf() {
|
|||
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) {
|
||||
std::vector<int32_t> out;
|
||||
out.reserve(arr.size());
|
||||
|
|
|
@ -116,6 +116,10 @@ void LolAutoAccept::setAutoWriteText(bool enabled, const QString& text) {
|
|||
autoWriteText = text;
|
||||
}
|
||||
|
||||
void LolAutoAccept::dodge() {
|
||||
dodgeNow = true;
|
||||
}
|
||||
|
||||
void LolAutoAccept::stopJoinThread() {
|
||||
stop();
|
||||
|
||||
|
@ -161,6 +165,16 @@ void LolAutoAccept::innerRun() {
|
|||
} else if(phase == ClientAPI::GameflowPhase::CHAMPSELECT) {
|
||||
champSelect();
|
||||
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) {
|
||||
extrasleep = 30000; // 30s bonus sleep
|
||||
resetAllOffsets();
|
||||
|
@ -178,6 +192,13 @@ void LolAutoAccept::innerRun() {
|
|||
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();
|
||||
std::chrono::duration<double> dur = (end-start);
|
||||
//if(dur.count() > 1e-5)
|
||||
|
@ -214,6 +235,7 @@ void LolAutoAccept::resetAllOffsets() {
|
|||
currentPositionSet = false;
|
||||
chatid.clear();
|
||||
autoWriteTextDone = false;
|
||||
dodgeNow = false;
|
||||
}
|
||||
|
||||
void LolAutoAccept::applyConfigToStage(Stage& stage, const Config::StageConfig& stageconf) {
|
||||
|
|
|
@ -3,13 +3,15 @@
|
|||
|
||||
#include <QApplication>
|
||||
#include <QTimer>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <Log.h>
|
||||
|
||||
#include "loadingwindow.h"
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
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::positionChanged, this, &MainWindow::onPosChange);
|
||||
|
||||
|
|
|
@ -110,7 +110,9 @@ QByteArray RestClient::requestRaw(const QString& url, Method m, const QString& d
|
|||
case Method::POST:
|
||||
curl_easy_setopt(curl, CURLOPT_POST, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, dataArr.data());
|
||||
if(!dataArr.isEmpty()) {
|
||||
headerlist = curl_slist_append(headerlist, "Content-Type: application/json");
|
||||
}
|
||||
break;
|
||||
case Method::PUT:
|
||||
case Method::PATCH:
|
||||
|
|
|
@ -19,6 +19,16 @@
|
|||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<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">
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
|
@ -29,17 +39,36 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<widget class="QPushButton" name="icon">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::NoTextInteraction</set>
|
||||
<property name="contextMenuPolicy">
|
||||
<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>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>icon</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../resources/res.qrc"/>
|
||||
</resources>
|
||||
|
|
158
ui/mainwindow.ui
158
ui/mainwindow.ui
|
@ -62,13 +62,16 @@
|
|||
<property name="spacing">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="enableAutoWrite">
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="enableSmiteWarning">
|
||||
<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 name="text">
|
||||
<string>Auto Write</string>
|
||||
<string>Enable Smite Warning</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -94,73 +97,6 @@
|
|||
</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="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">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="tabPosition">
|
||||
|
@ -170,7 +106,7 @@
|
|||
<enum>QTabWidget::Rounded</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="elideMode">
|
||||
<enum>Qt::ElideNone</enum>
|
||||
|
@ -254,6 +190,84 @@
|
|||
</widget>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
<widget class="RuneManager" name="runesPage">
|
||||
|
|
Loading…
Reference in New Issue