forked from MrBesen/lolautoaccept
autowrite implemented
This commit is contained in:
parent
7c96b8b188
commit
af63c975c7
|
@ -97,7 +97,7 @@ public:
|
||||||
int32_t championID = 0;
|
int32_t championID = 0;
|
||||||
int32_t championPickIntentID = 0;
|
int32_t championPickIntentID = 0;
|
||||||
int64_t summonerID = 0;
|
int64_t summonerID = 0;
|
||||||
int64_t spell1Id = 0; // 4 = flash, 6 = ghost, 7 = heal, 11 = smite, 12 = teleport, 14 = ignite
|
int64_t spell1Id = 0; // 4 = flash, 6 = ghost, 7 = heal, 11 = smite, 12 = teleport, 13 = klarheitz, 14 = ignite, 32 = snowball
|
||||||
int64_t spell2Id = 0;
|
int64_t spell2Id = 0;
|
||||||
|
|
||||||
ChampSelectCell();
|
ChampSelectCell();
|
||||||
|
|
|
@ -38,6 +38,8 @@ public:
|
||||||
|
|
||||||
bool enabledAutoAccept;
|
bool enabledAutoAccept;
|
||||||
bool enabledSmiteWarn;
|
bool enabledSmiteWarn;
|
||||||
|
bool enabledAutoWrite;
|
||||||
|
std::string autoWriteText;
|
||||||
};
|
};
|
||||||
|
|
||||||
Config();
|
Config();
|
||||||
|
|
|
@ -49,6 +49,9 @@ protected:
|
||||||
|
|
||||||
bool nextApplyRunes = false;
|
bool nextApplyRunes = false;
|
||||||
bool smiteWarnEnabled = true;
|
bool smiteWarnEnabled = true;
|
||||||
|
bool autoWriteTextEnabled = false;
|
||||||
|
bool autoWriteTextDone = false;
|
||||||
|
std::string autoWriteText;
|
||||||
|
|
||||||
std::string chatid; // the chatid of the chat from the champselect
|
std::string chatid; // the chatid of the chat from the champselect
|
||||||
std::chrono::time_point<std::chrono::system_clock> lastMessageSent;
|
std::chrono::time_point<std::chrono::system_clock> lastMessageSent;
|
||||||
|
@ -77,6 +80,7 @@ public:
|
||||||
const std::vector<RuneStyle>& getRuneStyles();
|
const std::vector<RuneStyle>& getRuneStyles();
|
||||||
void applyRunes();
|
void applyRunes();
|
||||||
void setOnRuneChangeFunc(onruneschange_func on);
|
void setOnRuneChangeFunc(onruneschange_func on);
|
||||||
|
void setAutoWriteText(bool enabled, const std::string& text = {});
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void stopJoinThread();
|
void stopJoinThread();
|
||||||
|
|
|
@ -32,6 +32,7 @@ private slots:
|
||||||
void tabchanged(Position, LolAutoAccept::State);
|
void tabchanged(Position, LolAutoAccept::State);
|
||||||
|
|
||||||
void applyRunes();
|
void applyRunes();
|
||||||
|
void autoWriteChanged();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void requestTabChange(int tabindex);
|
void requestTabChange(int tabindex);
|
||||||
|
|
|
@ -88,6 +88,8 @@ Config::RootConfig::RootConfig(const QJsonObject& j) {
|
||||||
|
|
||||||
enabledAutoAccept = getValue(j, "enabledAutoAccept", true);
|
enabledAutoAccept = getValue(j, "enabledAutoAccept", true);
|
||||||
enabledSmiteWarn = getValue(j, "enabledSmiteWarn", true);
|
enabledSmiteWarn = getValue(j, "enabledSmiteWarn", true);
|
||||||
|
enabledAutoWrite = getValue(j, "enabledAutoWrite", false);
|
||||||
|
autoWriteText = getValue<std::string>(j, "autoWriteText");
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::RootConfig::operator QJsonObject() const {
|
Config::RootConfig::operator QJsonObject() const {
|
||||||
|
@ -101,6 +103,8 @@ Config::RootConfig::operator QJsonObject() const {
|
||||||
out["positions"] = positionarr;
|
out["positions"] = positionarr;
|
||||||
out.insert("enabledAutoAccept", enabledAutoAccept);
|
out.insert("enabledAutoAccept", enabledAutoAccept);
|
||||||
out.insert("enabledSmiteWarn", enabledSmiteWarn);
|
out.insert("enabledSmiteWarn", enabledSmiteWarn);
|
||||||
|
out.insert("enabledAutoWrite", enabledAutoWrite);
|
||||||
|
out.insert("autoWriteText", QString::fromStdString(autoWriteText));
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,12 @@ void LolAutoAccept::setOnRuneChangeFunc(onruneschange_func on) {
|
||||||
onRuneschange = on;
|
onRuneschange = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LolAutoAccept::setAutoWriteText(bool enabled, const std::string& text) {
|
||||||
|
autoWriteTextEnabled = enabled;
|
||||||
|
autoWriteTextDone = false;
|
||||||
|
autoWriteText = text;
|
||||||
|
}
|
||||||
|
|
||||||
void LolAutoAccept::stopJoinThread() {
|
void LolAutoAccept::stopJoinThread() {
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
|
@ -119,10 +125,10 @@ void LolAutoAccept::stopJoinThread() {
|
||||||
void LolAutoAccept::innerRun() {
|
void LolAutoAccept::innerRun() {
|
||||||
shouldrun = true;
|
shouldrun = true;
|
||||||
|
|
||||||
auto convs = clientapi->getAllConversations();
|
|
||||||
Log::info << "got " << convs.size() << " conversations";
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
auto convs = clientapi->getAllConversations();
|
||||||
|
Log::info << "got " << convs.size() << " conversations";
|
||||||
|
|
||||||
while(shouldrun) {
|
while(shouldrun) {
|
||||||
uint32_t extrasleep = 800;
|
uint32_t extrasleep = 800;
|
||||||
auto start = std::chrono::high_resolution_clock::now();
|
auto start = std::chrono::high_resolution_clock::now();
|
||||||
|
@ -207,6 +213,7 @@ void LolAutoAccept::resetAllOffsets() {
|
||||||
currentPositionSet = false;
|
currentPositionSet = false;
|
||||||
lastPickedChamp = 0;
|
lastPickedChamp = 0;
|
||||||
chatid.clear();
|
chatid.clear();
|
||||||
|
autoWriteTextDone = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LolAutoAccept::resetRunes() {
|
void LolAutoAccept::resetRunes() {
|
||||||
|
@ -442,6 +449,15 @@ void LolAutoAccept::champSelect() {
|
||||||
if(nextApplyRunes) {
|
if(nextApplyRunes) {
|
||||||
applyRunes_internal(pickedChamp, pos);
|
applyRunes_internal(pickedChamp, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check for autowriteText
|
||||||
|
if(autoWriteTextEnabled && !autoWriteTextDone && !autoWriteText.empty()) {
|
||||||
|
const std::string& chatid = getChatid();
|
||||||
|
if(!chatid.empty()) {
|
||||||
|
clientapi->sendMessage(chatid, autoWriteText);
|
||||||
|
autoWriteTextDone = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LolAutoAccept::smiteWarning(const std::vector<ClientAPI::ChampSelectCell>& cells) {
|
void LolAutoAccept::smiteWarning(const std::vector<ClientAPI::ChampSelectCell>& cells) {
|
||||||
|
|
|
@ -27,6 +27,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||||
ui->enableSmiteWarning->setChecked(rc.enabledSmiteWarn);
|
ui->enableSmiteWarning->setChecked(rc.enabledSmiteWarn);
|
||||||
lolaa.setSmiteWarn(rc.enabledSmiteWarn);
|
lolaa.setSmiteWarn(rc.enabledSmiteWarn);
|
||||||
|
|
||||||
|
ui->enableAutoWrite->setChecked(rc.enabledAutoWrite);
|
||||||
|
ui->autoWriteText->setText(QString::fromStdString(rc.autoWriteText));
|
||||||
|
lolaa.setAutoWriteText(rc.enabledAutoWrite, rc.autoWriteText);
|
||||||
|
|
||||||
resizeEvent(nullptr);
|
resizeEvent(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,6 +111,14 @@ void MainWindow::applyRunes() {
|
||||||
lolaa.applyRunes();
|
lolaa.applyRunes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::autoWriteChanged() {
|
||||||
|
bool enabled = ui->enableAutoWrite->isChecked();
|
||||||
|
const std::string text = ui->autoWriteText->toPlainText().toStdString();
|
||||||
|
lolaa.setAutoWriteText(enabled, text);
|
||||||
|
conf.getConfig().enabledAutoWrite = enabled;
|
||||||
|
conf.getConfig().autoWriteText = text;
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::onPosChange(Position newpos) {
|
void MainWindow::onPosChange(Position newpos) {
|
||||||
assert(newpos <= Position::UTILITY);
|
assert(newpos <= Position::UTILITY);
|
||||||
|
|
||||||
|
|
114
ui/mainwindow.ui
114
ui/mainwindow.ui
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>452</width>
|
<width>465</width>
|
||||||
<height>645</height>
|
<height>635</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -66,6 +66,53 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="enableAutoWrite">
|
||||||
|
<property name="text">
|
||||||
|
<string>Auto Write</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<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="focusPolicy">
|
||||||
|
<enum>Qt::WheelFocus</enum>
|
||||||
|
</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::LinksAccessibleByMouse|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>autowriteText</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="tabPosition">
|
<property name="tabPosition">
|
||||||
|
@ -150,8 +197,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>452</width>
|
<width>465</width>
|
||||||
<height>21</height>
|
<height>24</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -223,8 +270,8 @@
|
||||||
<y>86</y>
|
<y>86</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>407</x>
|
<x>408</x>
|
||||||
<y>145</y>
|
<y>380</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -239,7 +286,7 @@
|
||||||
<y>599</y>
|
<y>599</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>458</x>
|
<x>452</x>
|
||||||
<y>576</y>
|
<y>576</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
|
@ -251,8 +298,8 @@
|
||||||
<slot>smitewarntoggled(bool)</slot>
|
<slot>smitewarntoggled(bool)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>190</x>
|
<x>191</x>
|
||||||
<y>77</y>
|
<y>111</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>201</x>
|
<x>201</x>
|
||||||
|
@ -260,6 +307,54 @@
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>enableAutoWrite</sender>
|
||||||
|
<signal>clicked(bool)</signal>
|
||||||
|
<receiver>MainWindow</receiver>
|
||||||
|
<slot>autoWriteChanged()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>182</x>
|
||||||
|
<y>130</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>441</x>
|
||||||
|
<y>147</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>autoWriteText</sender>
|
||||||
|
<signal>textChanged()</signal>
|
||||||
|
<receiver>MainWindow</receiver>
|
||||||
|
<slot>autoWriteChanged()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>315</x>
|
||||||
|
<y>169</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>347</x>
|
||||||
|
<y>146</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>enableAutoWrite</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>autoWriteText</receiver>
|
||||||
|
<slot>setEnabled(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>88</x>
|
||||||
|
<y>131</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>86</x>
|
||||||
|
<y>168</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<slots>
|
<slots>
|
||||||
<signal>requestTabChange(int)</signal>
|
<signal>requestTabChange(int)</signal>
|
||||||
|
@ -269,5 +364,6 @@
|
||||||
<slot>toggleMainswitch(bool)</slot>
|
<slot>toggleMainswitch(bool)</slot>
|
||||||
<slot>applyRunes()</slot>
|
<slot>applyRunes()</slot>
|
||||||
<slot>smitewarntoggled(bool)</slot>
|
<slot>smitewarntoggled(bool)</slot>
|
||||||
|
<slot>autoWriteChanged()</slot>
|
||||||
</slots>
|
</slots>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
Loading…
Reference in New Issue