forked from MrBesen/lolautoaccept
refactor
This commit is contained in:
parent
4716e48cbf
commit
1cb3134c8e
|
@ -52,6 +52,7 @@ public:
|
||||||
// might block until champ data is available
|
// might block until champ data is available
|
||||||
const ChampData& getBestMatchingChamp(const std::string& name, int* count = nullptr);
|
const ChampData& getBestMatchingChamp(const std::string& name, int* count = nullptr);
|
||||||
std::vector<const ChampData*> getMatchingChamp(const std::string& name, uint32_t limit = 25);
|
std::vector<const ChampData*> getMatchingChamp(const std::string& name, uint32_t limit = 25);
|
||||||
|
const ChampData* getChampByID(uint32_t id);
|
||||||
|
|
||||||
std::vector<uint32_t> resolveChampIDs(const std::vector<std::string>& champnames);
|
std::vector<uint32_t> resolveChampIDs(const std::vector<std::string>& champnames);
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@ private:
|
||||||
void stopJoinThread();
|
void stopJoinThread();
|
||||||
void innerRun();
|
void innerRun();
|
||||||
void resetAllOffsets();
|
void resetAllOffsets();
|
||||||
|
void resetRunes(); // when there is no option to push runes, make sure there is an update to trigger that, there are no runes showed
|
||||||
void applyConfigToStage(Stage& stage, const Config::StageConfig& stageconf);
|
void applyConfigToStage(Stage& stage, const Config::StageConfig& stageconf);
|
||||||
void loadPosition(Position pos);
|
void loadPosition(Position pos);
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ enum class Position : uint32_t {
|
||||||
};
|
};
|
||||||
Position toPosition(const std::string& str);
|
Position toPosition(const std::string& str);
|
||||||
std::string toString(Position p);
|
std::string toString(Position p);
|
||||||
|
std::string toShortString(Position p);
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream&, const Position&);
|
std::ostream& operator<<(std::ostream&, const Position&);
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,13 @@ public:
|
||||||
|
|
||||||
void setRuneMeta(const std::vector<RuneAspekt>& runeinfo);
|
void setRuneMeta(const std::vector<RuneAspekt>& runeinfo);
|
||||||
void setRunes(const RunePage& rp);
|
void setRunes(const RunePage& rp);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void applyRunesClicked();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void applyRunes();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateText();
|
void updateText();
|
||||||
std::string getRuneText(uint32_t id);
|
std::string getRuneText(uint32_t id);
|
||||||
|
|
|
@ -12,6 +12,8 @@ public:
|
||||||
std::vector<uint32_t> selectedAspects; // all selected aspekts (should be exactly 9)
|
std::vector<uint32_t> selectedAspects; // all selected aspekts (should be exactly 9)
|
||||||
|
|
||||||
bool operator==(const RunePage& rp) const;
|
bool operator==(const RunePage& rp) const;
|
||||||
|
|
||||||
|
operator bool() const; // check if this runepage is valid (this does not check semantic validity, only if the values are set as they supposed to be)
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream&, const RunePage&);
|
std::ostream& operator<<(std::ostream&, const RunePage&);
|
||||||
|
|
|
@ -17,6 +17,7 @@ ARR(ReadyCheckState, "Invalid", "None", "InProgress", "Accepted", "Declined");
|
||||||
ARR(GameflowPhase, "None", "Lobby", "Matchmaking", "CheckedIntoTournament", "ReadyCheck", "ChampSelect", "GameStart", "FailedToLaunch", "InProgress", "Reconnect", "WaitingForStats", "PreEndOfGame", "EndOfGame", "TerminatedInError");
|
ARR(GameflowPhase, "None", "Lobby", "Matchmaking", "CheckedIntoTournament", "ReadyCheck", "ChampSelect", "GameStart", "FailedToLaunch", "InProgress", "Reconnect", "WaitingForStats", "PreEndOfGame", "EndOfGame", "TerminatedInError");
|
||||||
ARR(ChampSelectPhase, "Invalid", "PLANNING", "BAN_PICK", "FINALIZATION");
|
ARR(ChampSelectPhase, "Invalid", "PLANNING", "BAN_PICK", "FINALIZATION");
|
||||||
ARR(Position, "Invalid", "top", "jungle", "middle", "bottom", "utility");
|
ARR(Position, "Invalid", "top", "jungle", "middle", "bottom", "utility");
|
||||||
|
ARR(ShortPosition, "", "Top", "Jgl", "Mid", "Bot", "Sup");
|
||||||
ARR(ChampSelectActionType, "Invalid", "ban", "pick", "ten_bans_reveal");
|
ARR(ChampSelectActionType, "Invalid", "ban", "pick", "ten_bans_reveal");
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -80,6 +81,10 @@ std::string toString(Position p) {
|
||||||
return PositionNames[(int) p];
|
return PositionNames[(int) p];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string toShortString(Position p) {
|
||||||
|
return ShortPositionNames[(int) p];
|
||||||
|
}
|
||||||
|
|
||||||
ClientAPI::ChampSelectActionType ClientAPI::toChampSelectActionType(const std::string& str) {
|
ClientAPI::ChampSelectActionType ClientAPI::toChampSelectActionType(const std::string& str) {
|
||||||
return MAPENUM(str, ChampSelectActionType, INVALID);
|
return MAPENUM(str, ChampSelectActionType, INVALID);
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,6 +197,17 @@ std::vector<const DataDragon::ChampData*> DataDragon::getMatchingChamp(const std
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DataDragon::ChampData* DataDragon::getChampByID(uint32_t id) {
|
||||||
|
getChamps();
|
||||||
|
|
||||||
|
auto it = std::find_if(champs.begin(), champs.end(), [id](const ChampData& cd) { return cd.key == id; });
|
||||||
|
|
||||||
|
// nothing found
|
||||||
|
if(it == champs.end()) return nullptr;
|
||||||
|
|
||||||
|
return &*it;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<uint32_t> DataDragon::resolveChampIDs(const std::vector<std::string>& champnames) {
|
std::vector<uint32_t> DataDragon::resolveChampIDs(const std::vector<std::string>& champnames) {
|
||||||
std::vector<uint32_t> out;
|
std::vector<uint32_t> out;
|
||||||
out.reserve(champnames.size());
|
out.reserve(champnames.size());
|
||||||
|
|
|
@ -111,8 +111,13 @@ void LolAutoAccept::innerRun() {
|
||||||
Log::info << "current Gameflowphase: " << phase;
|
Log::info << "current Gameflowphase: " << phase;
|
||||||
|
|
||||||
// do processing
|
// do processing
|
||||||
if(phase == ClientAPI::GameflowPhase::MATCHMAKING) {
|
if(phase == ClientAPI::GameflowPhase::LOBBY) {
|
||||||
|
resetAllOffsets();
|
||||||
|
resetRunes();
|
||||||
|
} else if(phase == ClientAPI::GameflowPhase::MATCHMAKING) {
|
||||||
extrasleep = 200;
|
extrasleep = 200;
|
||||||
|
resetAllOffsets();
|
||||||
|
resetRunes();
|
||||||
} else if(phase == ClientAPI::GameflowPhase::READYCHECK) {
|
} else if(phase == ClientAPI::GameflowPhase::READYCHECK) {
|
||||||
if(stages.at(0).enabled) { // auto accept enabled
|
if(stages.at(0).enabled) { // auto accept enabled
|
||||||
auto state = clientapi->getReadyCheckState();
|
auto state = clientapi->getReadyCheckState();
|
||||||
|
@ -130,14 +135,24 @@ void LolAutoAccept::innerRun() {
|
||||||
extrasleep = 0; // no extra sleep
|
extrasleep = 0; // no extra sleep
|
||||||
} else if(phase == ClientAPI::GameflowPhase::INPROGRESS) {
|
} else if(phase == ClientAPI::GameflowPhase::INPROGRESS) {
|
||||||
extrasleep = 30000; // 30s bonus sleep
|
extrasleep = 30000; // 30s bonus sleep
|
||||||
|
resetAllOffsets();
|
||||||
|
resetRunes();
|
||||||
} else if(phase == ClientAPI::GameflowPhase::ENDOFGAME) {
|
} else if(phase == ClientAPI::GameflowPhase::ENDOFGAME) {
|
||||||
extrasleep = 2000; // 2 s bonus sleep
|
extrasleep = 2000; // 2 s bonus sleep
|
||||||
|
resetAllOffsets();
|
||||||
|
resetRunes();
|
||||||
} else if(phase == ClientAPI::GameflowPhase::PREENDOFGAME) {
|
} else if(phase == ClientAPI::GameflowPhase::PREENDOFGAME) {
|
||||||
extrasleep = 4000; // 4 s bonus sleep
|
extrasleep = 4000; // 4 s bonus sleep
|
||||||
|
resetAllOffsets();
|
||||||
|
resetRunes();
|
||||||
} else if(phase == ClientAPI::GameflowPhase::WAITINGFORSTATS) {
|
} else if(phase == ClientAPI::GameflowPhase::WAITINGFORSTATS) {
|
||||||
extrasleep = 4000; // 4 s bonus sleep
|
extrasleep = 4000; // 4 s bonus sleep
|
||||||
|
resetAllOffsets();
|
||||||
|
resetRunes();
|
||||||
} else if(phase == ClientAPI::GameflowPhase::NONE) {
|
} else if(phase == ClientAPI::GameflowPhase::NONE) {
|
||||||
extrasleep = 10000; // 10 s bonus sleep - no lobby
|
extrasleep = 10000; // 10 s bonus sleep - no lobby
|
||||||
|
resetAllOffsets();
|
||||||
|
resetRunes();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto end = std::chrono::high_resolution_clock::now();
|
auto end = std::chrono::high_resolution_clock::now();
|
||||||
|
@ -156,6 +171,13 @@ void LolAutoAccept::resetAllOffsets() {
|
||||||
currentPosition = Position::INVALID;
|
currentPosition = Position::INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LolAutoAccept::resetRunes() {
|
||||||
|
if(onRuneschange) {
|
||||||
|
onRuneschange({});
|
||||||
|
}
|
||||||
|
nextApplyRunes = false;
|
||||||
|
}
|
||||||
|
|
||||||
void LolAutoAccept::applyConfigToStage(Stage& stage, const Config::StageConfig& stageconf) {
|
void LolAutoAccept::applyConfigToStage(Stage& stage, const Config::StageConfig& stageconf) {
|
||||||
stage.champids = dd.resolveChampIDs(stageconf.champs);
|
stage.champids = dd.resolveChampIDs(stageconf.champs);
|
||||||
stage.enabled = stage.enabled;
|
stage.enabled = stage.enabled;
|
||||||
|
@ -412,12 +434,18 @@ void LolAutoAccept::applyRunes_internal(uint32_t champid, Position pos) {
|
||||||
Log::warn << "no rune page found!";
|
Log::warn << "no rune page found!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// replace the page
|
||||||
ClientAPI::RunePage& rp = pages.at(pageoffset);
|
ClientAPI::RunePage& rp = pages.at(pageoffset);
|
||||||
Log::info << "replace runepage id: " << rp.id << " old-name: " << rp.name;
|
Log::info << "replace runepage id: " << rp.id << " old-name: " << rp.name;
|
||||||
|
|
||||||
|
// resolve champion name for the runepage name
|
||||||
ClientAPI::RunePage newpage;
|
ClientAPI::RunePage newpage;
|
||||||
|
auto champ = dd.getChampByID(champid);
|
||||||
|
const std::string champname = champ ? champ->name : std::to_string(champid);
|
||||||
|
|
||||||
newpage.id = rp.id;
|
newpage.id = rp.id;
|
||||||
newpage.name = "AA: " + std::to_string(champid) + " " + toString(pos); // TODO: resolve champname? add role?
|
newpage.name = "AA: " + champname + " " + toShortString(pos); // TODO: make role "Utility" resolve to "Support"?
|
||||||
newpage.runepage = champinfo.runepage;
|
newpage.runepage = champinfo.runepage;
|
||||||
clientapi->editRunePage(newpage);
|
clientapi->editRunePage(newpage);
|
||||||
|
|
||||||
|
|
|
@ -21,15 +21,26 @@ void RuneDisplay::setRunes(const RunePage& rp) {
|
||||||
updateText();
|
updateText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RuneDisplay::applyRunesClicked() {
|
||||||
|
emit applyRunes();
|
||||||
|
}
|
||||||
|
|
||||||
void RuneDisplay::updateText() {
|
void RuneDisplay::updateText() {
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
|
|
||||||
|
if(! (bool) runepage) {
|
||||||
|
ui->runetext->setText(QString::fromStdString(""));
|
||||||
|
ui->applyRunesBtn->setEnabled(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
out << "primary: " << getRuneText(runepage.primaryStyle) << " secondary: " << getRuneText(runepage.secondaryStyle) << '\n';
|
out << "primary: " << getRuneText(runepage.primaryStyle) << " secondary: " << getRuneText(runepage.secondaryStyle) << '\n';
|
||||||
|
|
||||||
for(uint32_t rune : runepage.selectedAspects) {
|
for(uint32_t rune : runepage.selectedAspects) {
|
||||||
out << getRuneText(rune) << '\n';
|
out << getRuneText(rune) << '\n';
|
||||||
}
|
}
|
||||||
ui->runetext->setText(QString::fromStdString(out.str()));
|
ui->runetext->setText(QString::fromStdString(out.str()));
|
||||||
|
ui->applyRunesBtn->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string RuneDisplay::getRuneText(uint32_t id) {
|
std::string RuneDisplay::getRuneText(uint32_t id) {
|
||||||
|
|
|
@ -9,6 +9,10 @@ bool RunePage::operator==(const RunePage& rp) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RunePage::operator bool() const {
|
||||||
|
return primaryStyle != 0 && secondaryStyle != 0 && selectedAspects.size() == 9;
|
||||||
|
}
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& str, const RunePage& rp) {
|
std::ostream& operator<<(std::ostream& str, const RunePage& rp) {
|
||||||
return str << "Primary: " << rp.primaryStyle << " Secondary: " << rp.secondaryStyle << " aspects: " << rp.selectedAspects.size();
|
return str << "Primary: " << rp.primaryStyle << " Secondary: " << rp.secondaryStyle << " aspects: " << rp.selectedAspects.size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,16 +115,6 @@
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="applyRunesBtn">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string><html><head/><body><p>Select a Runepage and modify it to this runes.<br/>The page used is the first that:</p><ol style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">matches this Runes</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">has a name starting with &quot;AA:&quot;</li><li style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">is currently selected</li></ol></body></html></string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Apply Runes</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="RuneDisplay" name="runedisplay" native="true"/>
|
<widget class="RuneDisplay" name="runedisplay" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
|
@ -155,6 +145,9 @@
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>runedisplay.h</header>
|
<header>runedisplay.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
|
<slots>
|
||||||
|
<signal>applyRunes()</signal>
|
||||||
|
</slots>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
|
@ -212,18 +205,18 @@
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>applyRunesBtn</sender>
|
<sender>runedisplay</sender>
|
||||||
<signal>clicked()</signal>
|
<signal>applyRunes()</signal>
|
||||||
<receiver>MainWindow</receiver>
|
<receiver>MainWindow</receiver>
|
||||||
<slot>applyRunes()</slot>
|
<slot>applyRunes()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>349</x>
|
<x>270</x>
|
||||||
<y>571</y>
|
<y>599</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>476</x>
|
<x>458</x>
|
||||||
<y>577</y>
|
<y>576</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
|
|
@ -14,15 +14,49 @@
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="applyRunesBtn">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>Select a Runepage and modify it to this runes.<br/>The page used is the first that:</p><ol style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">matches this Runes</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">has a name starting with &quot;AA:&quot;</li><li style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">is currently selected</li></ol></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Apply Runes</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="runetext">
|
<widget class="QLabel" name="runetext">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Runes: </string>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>applyRunesBtn</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>RuneDisplay</receiver>
|
||||||
|
<slot>applyRunesClicked()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>111</x>
|
||||||
|
<y>21</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>498</x>
|
||||||
|
<y>85</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
<slots>
|
||||||
|
<signal>applyRunes()</signal>
|
||||||
|
<slot>applyRunesClicked()</slot>
|
||||||
|
</slots>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
Loading…
Reference in New Issue