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 championPickIntentID = 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;
|
||||
|
||||
ChampSelectCell();
|
||||
|
|
|
@ -38,6 +38,8 @@ public:
|
|||
|
||||
bool enabledAutoAccept;
|
||||
bool enabledSmiteWarn;
|
||||
bool enabledAutoWrite;
|
||||
std::string autoWriteText;
|
||||
};
|
||||
|
||||
Config();
|
||||
|
|
|
@ -49,6 +49,9 @@ protected:
|
|||
|
||||
bool nextApplyRunes = false;
|
||||
bool smiteWarnEnabled = true;
|
||||
bool autoWriteTextEnabled = false;
|
||||
bool autoWriteTextDone = false;
|
||||
std::string autoWriteText;
|
||||
|
||||
std::string chatid; // the chatid of the chat from the champselect
|
||||
std::chrono::time_point<std::chrono::system_clock> lastMessageSent;
|
||||
|
@ -77,6 +80,7 @@ public:
|
|||
const std::vector<RuneStyle>& getRuneStyles();
|
||||
void applyRunes();
|
||||
void setOnRuneChangeFunc(onruneschange_func on);
|
||||
void setAutoWriteText(bool enabled, const std::string& text = {});
|
||||
|
||||
private:
|
||||
void stopJoinThread();
|
||||
|
|
|
@ -32,6 +32,7 @@ private slots:
|
|||
void tabchanged(Position, LolAutoAccept::State);
|
||||
|
||||
void applyRunes();
|
||||
void autoWriteChanged();
|
||||
|
||||
signals:
|
||||
void requestTabChange(int tabindex);
|
||||
|
|
|
@ -88,6 +88,8 @@ Config::RootConfig::RootConfig(const QJsonObject& j) {
|
|||
|
||||
enabledAutoAccept = getValue(j, "enabledAutoAccept", true);
|
||||
enabledSmiteWarn = getValue(j, "enabledSmiteWarn", true);
|
||||
enabledAutoWrite = getValue(j, "enabledAutoWrite", false);
|
||||
autoWriteText = getValue<std::string>(j, "autoWriteText");
|
||||
}
|
||||
|
||||
Config::RootConfig::operator QJsonObject() const {
|
||||
|
@ -101,6 +103,8 @@ Config::RootConfig::operator QJsonObject() const {
|
|||
out["positions"] = positionarr;
|
||||
out.insert("enabledAutoAccept", enabledAutoAccept);
|
||||
out.insert("enabledSmiteWarn", enabledSmiteWarn);
|
||||
out.insert("enabledAutoWrite", enabledAutoWrite);
|
||||
out.insert("autoWriteText", QString::fromStdString(autoWriteText));
|
||||
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -107,6 +107,12 @@ void LolAutoAccept::setOnRuneChangeFunc(onruneschange_func on) {
|
|||
onRuneschange = on;
|
||||
}
|
||||
|
||||
void LolAutoAccept::setAutoWriteText(bool enabled, const std::string& text) {
|
||||
autoWriteTextEnabled = enabled;
|
||||
autoWriteTextDone = false;
|
||||
autoWriteText = text;
|
||||
}
|
||||
|
||||
void LolAutoAccept::stopJoinThread() {
|
||||
stop();
|
||||
|
||||
|
@ -119,10 +125,10 @@ void LolAutoAccept::stopJoinThread() {
|
|||
void LolAutoAccept::innerRun() {
|
||||
shouldrun = true;
|
||||
|
||||
auto convs = clientapi->getAllConversations();
|
||||
Log::info << "got " << convs.size() << " conversations";
|
||||
|
||||
try {
|
||||
auto convs = clientapi->getAllConversations();
|
||||
Log::info << "got " << convs.size() << " conversations";
|
||||
|
||||
while(shouldrun) {
|
||||
uint32_t extrasleep = 800;
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
|
@ -207,6 +213,7 @@ void LolAutoAccept::resetAllOffsets() {
|
|||
currentPositionSet = false;
|
||||
lastPickedChamp = 0;
|
||||
chatid.clear();
|
||||
autoWriteTextDone = false;
|
||||
}
|
||||
|
||||
void LolAutoAccept::resetRunes() {
|
||||
|
@ -442,6 +449,15 @@ void LolAutoAccept::champSelect() {
|
|||
if(nextApplyRunes) {
|
||||
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) {
|
||||
|
|
|
@ -27,6 +27,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||
ui->enableSmiteWarning->setChecked(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);
|
||||
}
|
||||
|
||||
|
@ -107,6 +111,14 @@ void MainWindow::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) {
|
||||
assert(newpos <= Position::UTILITY);
|
||||
|
||||
|
|
114
ui/mainwindow.ui
114
ui/mainwindow.ui
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>452</width>
|
||||
<height>645</height>
|
||||
<width>465</width>
|
||||
<height>635</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -66,6 +66,53 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="tabPosition">
|
||||
|
@ -150,8 +197,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>452</width>
|
||||
<height>21</height>
|
||||
<width>465</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
@ -223,8 +270,8 @@
|
|||
<y>86</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>407</x>
|
||||
<y>145</y>
|
||||
<x>408</x>
|
||||
<y>380</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
@ -239,7 +286,7 @@
|
|||
<y>599</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>458</x>
|
||||
<x>452</x>
|
||||
<y>576</y>
|
||||
</hint>
|
||||
</hints>
|
||||
|
@ -251,8 +298,8 @@
|
|||
<slot>smitewarntoggled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>190</x>
|
||||
<y>77</y>
|
||||
<x>191</x>
|
||||
<y>111</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>201</x>
|
||||
|
@ -260,6 +307,54 @@
|
|||
</hint>
|
||||
</hints>
|
||||
</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>
|
||||
<slots>
|
||||
<signal>requestTabChange(int)</signal>
|
||||
|
@ -269,5 +364,6 @@
|
|||
<slot>toggleMainswitch(bool)</slot>
|
||||
<slot>applyRunes()</slot>
|
||||
<slot>smitewarntoggled(bool)</slot>
|
||||
<slot>autoWriteChanged()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
|
|
Loading…
Reference in New Issue