on multiple champs pick first

This commit is contained in:
mrbesen 2022-04-23 16:45:23 +02:00
parent b66e6740d8
commit a63143c3df
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
2 changed files with 8 additions and 3 deletions

View File

@ -201,7 +201,7 @@ const DataDragon::ChampData& DataDragon::getBestMatchingChamp(const std::string&
}
if(count) *count = bestmatchingcount;
if(bestmatchingcount == 1 && bestmatchingoffset >= 0)
if(bestmatchingoffset >= 0)
return champs.at(bestmatchingoffset);
return EMPTYCHAMP;

View File

@ -48,18 +48,23 @@ void StageSettings::resizeEvent([[maybe_unused]] QResizeEvent* event) {
}
void StageSettings::championChangedinternal(const QString& str) {
emit championChanged(str);
QString emitting = str;
if(dd) {
int count = 0;
const DataDragon::ChampData& cd = dd->getBestMatchingChamp(str.toStdString(), &count);
if(cd.key != currentdisplayedChampKey) {
img = (cd.id.empty()) ? cv::Mat() : dd->getImage(cd.id);
img = (cd.key < 0) ? cv::Mat() : dd->getImage(cd.id);
currentdisplayedChampKey = cd.key;
if(cd.key >= 0) {
emitting = QString::fromStdString(cd.name);
}
}
ui->champcount->setText(tr("Champions matched: %1").arg(QString::fromStdString(std::to_string(count))));
rescaleImage();
}
emit championChanged(emitting);
}
void StageSettings::toggledinternal(int state) {