new config working

This commit is contained in:
mrbesen 2022-07-04 17:50:18 +02:00
parent 0276f83f3f
commit 68c7ce92d9
Signed by untrusted user: MrBesen
GPG Key ID: 596B2350DCD67504
5 changed files with 20 additions and 3 deletions

View File

@ -12,7 +12,7 @@ public:
operator QJsonObject() const;
std::vector<std::string> champs;
bool enabled;
bool enabled = false;
};
struct PositionConfig {

View File

@ -3,6 +3,7 @@
#include <QWidget>
#include "config.h"
#include "datadragon.h"
namespace Ui {
@ -37,6 +38,8 @@ public:
void setDataDragon(DataDragon* dd);
void addChamp(const std::string& champname, uint32_t id, QPixmap icon);
void loadConfig(Config::StageConfig& c);
private slots:
void toggledinternal(int state);
void addChamp();

View File

@ -78,13 +78,13 @@ static std::vector<uint32_t> toChampionIDList(const std::vector<StageSettings::S
}
void MainWindow::tabtoggled(Position p, LolAutoAccept::State s, bool state) {
Log::info << "PrePick checkbox toggled " << state << " position: " << p << " state: " << (int) s;
Log::info << "checkbox toggled " << state << " position: " << p << " state: " << (int) s;
lolaa.setEnabled(state, s);
}
void MainWindow::tabchanged(Position p, LolAutoAccept::State s) {
Log::info << "prepick edited position: " << p << " state: " << (int) s;
Log::info << "edited position: " << p << " state: " << (int) s;
SettingsTab* tab = (SettingsTab*) ui->tabWidget->widget((int) p -1);
auto champs = tab->getChamps(s);

View File

@ -2,6 +2,7 @@
#include "ui_settingstab.h"
#include <algorithm>
#include <Log.h>
static std::vector<std::string> toChampionNameList(const std::vector<StageSettings::SelectedChamp>& scs) {
std::vector<std::string> out;
@ -26,6 +27,10 @@ void SettingsTab::setup(Config::PositionConfig& conf, DataDragon* dd) {
ui->banstage->setDataDragon(dd);
ui->pickstage->setDataDragon(dd);
// load config
ui->banstage->loadConfig(conf.ban);
ui->pickstage->loadConfig(conf.pick);
}
std::vector<StageSettings::SelectedChamp> SettingsTab::getChamps(LolAutoAccept::State s) const {
@ -51,21 +56,25 @@ Position SettingsTab::getPosition() const {
}
void SettingsTab::banToggled(bool b) {
Log::trace << __PRETTY_FUNCTION__ << " position: " << position;
conf->ban.enabled = b;
emit toggled(position, LolAutoAccept::State::BAN, b);
}
void SettingsTab::banChampsChanged() {
Log::trace << __PRETTY_FUNCTION__ << " position: " << position;
conf->ban.champs = toChampionNameList(ui->banstage->getChampions());
emit changed(position, LolAutoAccept::State::BAN);
}
void SettingsTab::pickToggled(bool b) {
Log::trace << __PRETTY_FUNCTION__ << " position: " << position;
conf->pick.enabled = b;
emit toggled(position, LolAutoAccept::State::PICK, b);
}
void SettingsTab::pickChampsChanged() {
Log::trace << __PRETTY_FUNCTION__ << " position: " << position;
conf->pick.champs = toChampionNameList(ui->pickstage->getChampions());
emit changed(position, LolAutoAccept::State::BAN);
}

View File

@ -67,6 +67,11 @@ void StageSettings::addChamp(const std::string& champname, uint32_t id, QPixmap
champr->setChamp(champname, id, icon);
}
void StageSettings::loadConfig(Config::StageConfig& c) {
setChampions(c.champs);
setState(c.enabled);
}
void StageSettings::toggledinternal(int state) {
emit toggled(state == Qt::CheckState::Checked);
updateEnabled();