This commit is contained in:
mrbesen 2022-07-10 15:19:25 +02:00
parent 4716e48cbf
commit 1cb3134c8e
Signed by untrusted user: MrBesen
GPG Key ID: 596B2350DCD67504
12 changed files with 118 additions and 20 deletions

View File

@ -52,6 +52,7 @@ public:
// might block until champ data is available
const ChampData& getBestMatchingChamp(const std::string& name, int* count = nullptr);
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);

View File

@ -70,6 +70,7 @@ private:
void stopJoinThread();
void innerRun();
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 loadPosition(Position pos);

View File

@ -13,6 +13,7 @@ enum class Position : uint32_t {
};
Position toPosition(const std::string& str);
std::string toString(Position p);
std::string toShortString(Position p);
std::ostream& operator<<(std::ostream&, const Position&);

View File

@ -18,6 +18,13 @@ public:
void setRuneMeta(const std::vector<RuneAspekt>& runeinfo);
void setRunes(const RunePage& rp);
private slots:
void applyRunesClicked();
signals:
void applyRunes();
private:
void updateText();
std::string getRuneText(uint32_t id);

View File

@ -12,6 +12,8 @@ public:
std::vector<uint32_t> selectedAspects; // all selected aspekts (should be exactly 9)
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&);

View File

@ -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(ChampSelectPhase, "Invalid", "PLANNING", "BAN_PICK", "FINALIZATION");
ARR(Position, "Invalid", "top", "jungle", "middle", "bottom", "utility");
ARR(ShortPosition, "", "Top", "Jgl", "Mid", "Bot", "Sup");
ARR(ChampSelectActionType, "Invalid", "ban", "pick", "ten_bans_reveal");
template<typename T>
@ -80,6 +81,10 @@ std::string toString(Position p) {
return PositionNames[(int) p];
}
std::string toShortString(Position p) {
return ShortPositionNames[(int) p];
}
ClientAPI::ChampSelectActionType ClientAPI::toChampSelectActionType(const std::string& str) {
return MAPENUM(str, ChampSelectActionType, INVALID);
}

View File

@ -197,6 +197,17 @@ std::vector<const DataDragon::ChampData*> DataDragon::getMatchingChamp(const std
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> out;
out.reserve(champnames.size());

View File

@ -111,8 +111,13 @@ void LolAutoAccept::innerRun() {
Log::info << "current Gameflowphase: " << phase;
// do processing
if(phase == ClientAPI::GameflowPhase::MATCHMAKING) {
if(phase == ClientAPI::GameflowPhase::LOBBY) {
resetAllOffsets();
resetRunes();
} else if(phase == ClientAPI::GameflowPhase::MATCHMAKING) {
extrasleep = 200;
resetAllOffsets();
resetRunes();
} else if(phase == ClientAPI::GameflowPhase::READYCHECK) {
if(stages.at(0).enabled) { // auto accept enabled
auto state = clientapi->getReadyCheckState();
@ -130,14 +135,24 @@ void LolAutoAccept::innerRun() {
extrasleep = 0; // no extra sleep
} else if(phase == ClientAPI::GameflowPhase::INPROGRESS) {
extrasleep = 30000; // 30s bonus sleep
resetAllOffsets();
resetRunes();
} else if(phase == ClientAPI::GameflowPhase::ENDOFGAME) {
extrasleep = 2000; // 2 s bonus sleep
resetAllOffsets();
resetRunes();
} else if(phase == ClientAPI::GameflowPhase::PREENDOFGAME) {
extrasleep = 4000; // 4 s bonus sleep
resetAllOffsets();
resetRunes();
} else if(phase == ClientAPI::GameflowPhase::WAITINGFORSTATS) {
extrasleep = 4000; // 4 s bonus sleep
resetAllOffsets();
resetRunes();
} else if(phase == ClientAPI::GameflowPhase::NONE) {
extrasleep = 10000; // 10 s bonus sleep - no lobby
resetAllOffsets();
resetRunes();
}
auto end = std::chrono::high_resolution_clock::now();
@ -156,6 +171,13 @@ void LolAutoAccept::resetAllOffsets() {
currentPosition = Position::INVALID;
}
void LolAutoAccept::resetRunes() {
if(onRuneschange) {
onRuneschange({});
}
nextApplyRunes = false;
}
void LolAutoAccept::applyConfigToStage(Stage& stage, const Config::StageConfig& stageconf) {
stage.champids = dd.resolveChampIDs(stageconf.champs);
stage.enabled = stage.enabled;
@ -412,12 +434,18 @@ void LolAutoAccept::applyRunes_internal(uint32_t champid, Position pos) {
Log::warn << "no rune page found!";
return;
}
// replace the page
ClientAPI::RunePage& rp = pages.at(pageoffset);
Log::info << "replace runepage id: " << rp.id << " old-name: " << rp.name;
// resolve champion name for the runepage name
ClientAPI::RunePage newpage;
auto champ = dd.getChampByID(champid);
const std::string champname = champ ? champ->name : std::to_string(champid);
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;
clientapi->editRunePage(newpage);

View File

@ -21,15 +21,26 @@ void RuneDisplay::setRunes(const RunePage& rp) {
updateText();
}
void RuneDisplay::applyRunesClicked() {
emit applyRunes();
}
void RuneDisplay::updateText() {
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';
for(uint32_t rune : runepage.selectedAspects) {
out << getRuneText(rune) << '\n';
}
ui->runetext->setText(QString::fromStdString(out.str()));
ui->applyRunesBtn->setEnabled(true);
}
std::string RuneDisplay::getRuneText(uint32_t id) {

View File

@ -9,6 +9,10 @@ bool RunePage::operator==(const RunePage& rp) const {
return false;
}
RunePage::operator bool() const {
return primaryStyle != 0 && secondaryStyle != 0 && selectedAspects.size() == 9;
}
std::ostream& operator<<(std::ostream& str, const RunePage& rp) {
return str << "Primary: " << rp.primaryStyle << " Secondary: " << rp.secondaryStyle << " aspects: " << rp.selectedAspects.size();
}

View File

@ -115,16 +115,6 @@
</widget>
</widget>
</item>
<item>
<widget class="QPushButton" name="applyRunesBtn">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select a Runepage and modify it to this runes.&lt;br/&gt;The page used is the first that:&lt;/p&gt;&lt;ol style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;matches this Runes&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;has a name starting with &amp;quot;AA:&amp;quot;&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;is currently selected&lt;/li&gt;&lt;/ol&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Apply Runes</string>
</property>
</widget>
</item>
<item>
<widget class="RuneDisplay" name="runedisplay" native="true"/>
</item>
@ -155,6 +145,9 @@
<extends>QWidget</extends>
<header>runedisplay.h</header>
<container>1</container>
<slots>
<signal>applyRunes()</signal>
</slots>
</customwidget>
</customwidgets>
<tabstops>
@ -212,18 +205,18 @@
</hints>
</connection>
<connection>
<sender>applyRunesBtn</sender>
<signal>clicked()</signal>
<sender>runedisplay</sender>
<signal>applyRunes()</signal>
<receiver>MainWindow</receiver>
<slot>applyRunes()</slot>
<hints>
<hint type="sourcelabel">
<x>349</x>
<y>571</y>
<x>270</x>
<y>599</y>
</hint>
<hint type="destinationlabel">
<x>476</x>
<y>577</y>
<x>458</x>
<y>576</y>
</hint>
</hints>
</connection>

View File

@ -14,15 +14,49 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="applyRunesBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select a Runepage and modify it to this runes.&lt;br/&gt;The page used is the first that:&lt;/p&gt;&lt;ol style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;matches this Runes&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;has a name starting with &amp;quot;AA:&amp;quot;&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;is currently selected&lt;/li&gt;&lt;/ol&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Apply Runes</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="runetext">
<property name="text">
<string>Runes: </string>
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<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>