new ui stuff wip
This commit is contained in:
parent
1cc36ae0ee
commit
0276f83f3f
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "clientaccess.h"
|
||||
#include "restclient.h"
|
||||
#include "position.h"
|
||||
|
||||
class ClientAPI : public RestClient {
|
||||
public:
|
||||
|
@ -41,16 +42,6 @@ public:
|
|||
};
|
||||
static ChampSelectPhase toChampSelectPhase(const std::string& str);
|
||||
|
||||
enum class Position : uint32_t {
|
||||
INVALID = 0,
|
||||
TOP,
|
||||
MIDDLE,
|
||||
BOTTOM,
|
||||
JUNGLE,
|
||||
UTILITY
|
||||
};
|
||||
static Position toPosition(const std::string& str);
|
||||
|
||||
enum class ChampSelectActionType : uint32_t {
|
||||
INVALID = 0,
|
||||
BAN,
|
||||
|
@ -165,5 +156,4 @@ private:
|
|||
std::ostream& operator<<(std::ostream&, const ClientAPI::ReadyCheckState&);
|
||||
std::ostream& operator<<(std::ostream&, const ClientAPI::GameflowPhase&);
|
||||
std::ostream& operator<<(std::ostream&, const ClientAPI::ChampSelectPhase&);
|
||||
std::ostream& operator<<(std::ostream&, const ClientAPI::Position&);
|
||||
std::ostream& operator<<(std::ostream&, const ClientAPI::ChampSelectActionType&);
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "position.h"
|
||||
|
||||
class Config {
|
||||
public:
|
||||
struct StageConfig {
|
||||
|
@ -13,14 +15,26 @@ public:
|
|||
bool enabled;
|
||||
};
|
||||
|
||||
struct PositionConfig {
|
||||
PositionConfig();
|
||||
PositionConfig(const QJsonObject&);
|
||||
operator QJsonObject() const;
|
||||
|
||||
Position position; // top, bot, sup,...
|
||||
|
||||
StageConfig ban;
|
||||
StageConfig pick;
|
||||
};
|
||||
|
||||
struct RootConfig {
|
||||
RootConfig();
|
||||
RootConfig(const QJsonObject&);
|
||||
operator QJsonObject() const;
|
||||
|
||||
StageConfig prepick;
|
||||
StageConfig ban;
|
||||
StageConfig pick;
|
||||
PositionConfig& getPositionConfig(Position position);
|
||||
|
||||
std::vector<PositionConfig> positionConfigs;
|
||||
|
||||
bool enabledAutoAccept;
|
||||
};
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <thread>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#include "clientapi.h"
|
||||
|
||||
|
@ -16,6 +17,7 @@ protected:
|
|||
uint32_t currentOffset = 0;
|
||||
};
|
||||
|
||||
std::mutex stagesMutex; // protects stagesvector
|
||||
std::vector<Stage*> stages;
|
||||
|
||||
bool shouldrun = false;
|
||||
|
@ -28,10 +30,8 @@ protected:
|
|||
public:
|
||||
enum class State {
|
||||
LOBBY = 0,
|
||||
PREPICK = 1,
|
||||
BAN = 2,
|
||||
PICK = 3,
|
||||
GAME = 4
|
||||
BAN = 1,
|
||||
PICK = 2,
|
||||
};
|
||||
|
||||
LolAutoAccept();
|
||||
|
|
|
@ -26,12 +26,9 @@ protected:
|
|||
private slots:
|
||||
void toggleMainswitch(bool);
|
||||
void aatoggled(bool);
|
||||
void pptoggled(bool);
|
||||
void ppedited();
|
||||
void bantoggled(bool);
|
||||
void banedited();
|
||||
void picktoggled(bool);
|
||||
void pickedited();
|
||||
|
||||
void tabtoggled(Position, LolAutoAccept::State, bool);
|
||||
void tabchanged(Position, LolAutoAccept::State);
|
||||
|
||||
private:
|
||||
// returns empty string on no match
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
|
||||
enum class Position : uint32_t {
|
||||
INVALID = 0,
|
||||
TOP,
|
||||
JUNGLE,
|
||||
MIDDLE,
|
||||
BOTTOM,
|
||||
UTILITY
|
||||
};
|
||||
Position toPosition(const std::string& str);
|
||||
std::string toString(Position p);
|
||||
|
||||
std::ostream& operator<<(std::ostream&, const Position&);
|
||||
|
||||
Q_DECLARE_METATYPE(Position);
|
|
@ -0,0 +1,53 @@
|
|||
#ifndef SETTINGSTAB_H
|
||||
#define SETTINGSTAB_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "config.h"
|
||||
#include "datadragon.h"
|
||||
#include "lolautoaccept.h"
|
||||
#include "stagesettings.h"
|
||||
|
||||
namespace Ui {
|
||||
class SettingsTab;
|
||||
}
|
||||
|
||||
class SettingsTab : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(Position position MEMBER position READ getPosition)
|
||||
|
||||
public:
|
||||
explicit SettingsTab(QWidget *parent = nullptr);
|
||||
~SettingsTab();
|
||||
|
||||
void setup(Config::PositionConfig& conf, DataDragon* dd = nullptr);
|
||||
|
||||
std::vector<StageSettings::SelectedChamp> getChamps(LolAutoAccept::State s) const;
|
||||
bool getState(LolAutoAccept::State s) const;
|
||||
void setChamps(LolAutoAccept::State s, const std::vector<std::string>&);
|
||||
void setState(LolAutoAccept::State s, bool b);
|
||||
|
||||
Position getPosition() const;
|
||||
|
||||
private slots:
|
||||
void banToggled(bool);
|
||||
void banChampsChanged();
|
||||
void pickToggled(bool);
|
||||
void pickChampsChanged();
|
||||
|
||||
signals:
|
||||
void changed(Position p, LolAutoAccept::State s);
|
||||
void toggled(Position p, LolAutoAccept::State s, bool newstate);
|
||||
|
||||
private:
|
||||
StageSettings* getStage(LolAutoAccept::State s) const;
|
||||
|
||||
Ui::SettingsTab *ui;
|
||||
|
||||
Config::PositionConfig* conf;
|
||||
DataDragon* dd = nullptr;
|
||||
Position position;
|
||||
};
|
||||
|
||||
#endif // SETTINGSTAB_H
|
|
@ -39,6 +39,7 @@ SOURCES += \
|
|||
src/mainwindow.cpp \
|
||||
src/memoryimagecache.cpp \
|
||||
src/restclient.cpp \
|
||||
src/settingstab.cpp \
|
||||
src/stagesettings.cpp \
|
||||
thirdparty/Log/Log.cpp
|
||||
|
||||
|
@ -59,6 +60,7 @@ HEADERS += \
|
|||
include/mainwindow.h \
|
||||
include/memoryimagecache.h \
|
||||
include/restclient.h \
|
||||
include/settingstab.h \
|
||||
include/stagesettings.h \
|
||||
thirdparty/Log/Log.h
|
||||
|
||||
|
@ -71,6 +73,7 @@ OBJECTS_DIR = build/
|
|||
FORMS += \
|
||||
ui/championsearch.ui \
|
||||
ui/mainwindow.ui \
|
||||
ui/settingstab.ui \
|
||||
ui/stagesettings.ui
|
||||
|
||||
INCLUDEPATH += $$PWD/include/ \
|
||||
|
|
|
@ -16,7 +16,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", "middle", "bottom", "jungle", "utility");
|
||||
ARR(Position, "Invalid", "top", "jungle", "middle", "bottom", "utility");
|
||||
ARR(ChampSelectActionType, "Invalid", "ban", "pick", "ten_bans_reveal");
|
||||
|
||||
template<typename T>
|
||||
|
@ -60,8 +60,12 @@ ClientAPI::ChampSelectPhase ClientAPI::toChampSelectPhase(const std::string& str
|
|||
return MAPENUM(str, ChampSelectPhase, INVALID);
|
||||
}
|
||||
|
||||
ClientAPI::Position ClientAPI::toPosition(const std::string& str) {
|
||||
return MAPENUM(str, Position, INVALID);
|
||||
Position toPosition(const std::string& str) {
|
||||
return mapEnum(str, PositionNames, PositionNamesCount, Position::INVALID);
|
||||
}
|
||||
|
||||
std::string toString(Position p) {
|
||||
return PositionNames[(int) p];
|
||||
}
|
||||
|
||||
ClientAPI::ChampSelectActionType ClientAPI::toChampSelectActionType(const std::string& str) {
|
||||
|
@ -177,5 +181,9 @@ ClientAPI::ChampSelectSession::operator bool() {
|
|||
PRINTENUM(ReadyCheckState)
|
||||
PRINTENUM(GameflowPhase)
|
||||
PRINTENUM(ChampSelectPhase)
|
||||
PRINTENUM(Position)
|
||||
PRINTENUM(ChampSelectActionType)
|
||||
|
||||
std::ostream& operator<<(std::ostream& str, const Position & state) { \
|
||||
assert(((int) state) < PositionNamesCount); \
|
||||
return str << PositionNames[(int) state] << " (" << (int) state << ')'; \
|
||||
}
|
||||
|
|
|
@ -45,26 +45,71 @@ Config::StageConfig::operator QJsonObject() const {
|
|||
return out;
|
||||
}
|
||||
|
||||
Config::PositionConfig::PositionConfig() {}
|
||||
Config::PositionConfig::PositionConfig(const QJsonObject& j) {
|
||||
ban = getValue<Config::StageConfig>(j, "ban");
|
||||
pick = getValue<Config::StageConfig>(j, "pick");
|
||||
position = toPosition(getValue<std::string>(j, "position"));
|
||||
if((int) position < 0 || position > Position::UTILITY) {
|
||||
Log::warn << "invalid config value \"position\"";
|
||||
position = Position::MIDDLE;
|
||||
}
|
||||
}
|
||||
Config::PositionConfig::operator QJsonObject() const {
|
||||
QJsonObject out;
|
||||
|
||||
out["ban"] = (QJsonObject) ban;
|
||||
out["pick"] = (QJsonObject) pick;
|
||||
out["position"] = QString::fromStdString(toString(position));
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
Config::RootConfig::RootConfig() {}
|
||||
|
||||
Config::RootConfig::RootConfig(const QJsonObject& j) {
|
||||
prepick = getValue<Config::StageConfig>(j, "prepick");
|
||||
ban = getValue<Config::StageConfig>(j, "ban");
|
||||
pick = getValue<Config::StageConfig>(j, "pick");
|
||||
enabledAutoAccept = getValue(j, "enabledAutoAccept", false);
|
||||
auto jposref = j["positions"];
|
||||
if(jposref.isArray()) {
|
||||
QJsonArray jpos = jposref.toArray();
|
||||
|
||||
positionConfigs.reserve(jpos.size());
|
||||
for(QJsonValue val : jpos) {
|
||||
if(val.isObject()) {
|
||||
positionConfigs.emplace_back(val.toObject()); // implicit cast to PositionConfig
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enabledAutoAccept = getValue(j, "enabledAutoAccept", true);
|
||||
}
|
||||
|
||||
Config::RootConfig::operator QJsonObject() const {
|
||||
QJsonObject out;
|
||||
|
||||
out.insert("prepick", (QJsonObject) prepick);
|
||||
out.insert("ban", (QJsonObject) ban);
|
||||
out.insert("pick", (QJsonObject) pick);
|
||||
QJsonArray positionarr;
|
||||
for(const PositionConfig& pos : positionConfigs) {
|
||||
positionarr.push_back((QJsonObject) pos);
|
||||
}
|
||||
|
||||
out["positions"] = positionarr;
|
||||
out.insert("enabledAutoAccept", enabledAutoAccept);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
Config::PositionConfig& Config::RootConfig::getPositionConfig(Position position) {
|
||||
for(uint32_t i = 0; i < positionConfigs.size(); ++i) {
|
||||
if(positionConfigs.at(i).position == position) {
|
||||
return positionConfigs.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
// add a new config
|
||||
positionConfigs.emplace_back();
|
||||
positionConfigs.back().position = position;
|
||||
return positionConfigs.back();
|
||||
}
|
||||
|
||||
Config::Config() {
|
||||
configFolderPath = getHome() + ".config/lolautoaccept/";
|
||||
configFilePath = configFolderPath + "config.json";
|
||||
|
|
|
@ -8,9 +8,9 @@ LolAutoAccept::Stage::Stage() {}
|
|||
LolAutoAccept::Stage::~Stage() {}
|
||||
|
||||
LolAutoAccept::LolAutoAccept() {
|
||||
stages.reserve(4);
|
||||
std::lock_guard lock(stagesMutex);
|
||||
stages.reserve(3);
|
||||
stages.push_back(new Stage()); // accept
|
||||
stages.push_back(new Stage()); // prepick
|
||||
stages.push_back(new Stage()); // ban
|
||||
stages.push_back(new Stage()); // pick
|
||||
}
|
||||
|
@ -18,28 +18,32 @@ LolAutoAccept::LolAutoAccept() {
|
|||
LolAutoAccept::~LolAutoAccept() {
|
||||
stopJoinThread();
|
||||
|
||||
std::lock_guard lock(stagesMutex);
|
||||
for(auto s : stages) {
|
||||
delete s;
|
||||
}
|
||||
}
|
||||
|
||||
void LolAutoAccept::setChamps(const std::vector<uint32_t>& champs, State s) {
|
||||
if(s == State::LOBBY || s >= State::GAME) {
|
||||
if(s == State::LOBBY || s >= State::PICK) {
|
||||
Log::warn << "setChamps() called on invalid State";
|
||||
return;
|
||||
}
|
||||
|
||||
stages.at((int) s)->champids = champs;
|
||||
stages.at((int) s)->currentOffset = 0;
|
||||
{
|
||||
std::lock_guard lock(stagesMutex);
|
||||
stages.at((int) s)->champids = champs;
|
||||
stages.at((int) s)->currentOffset = 0;
|
||||
}
|
||||
Log::info << "set champs on state: " << (int) s << " count: " << champs.size();
|
||||
}
|
||||
|
||||
void LolAutoAccept::setEnabled(bool b, State s) {
|
||||
if(s >= State::GAME) {
|
||||
if(s >= State::PICK) {
|
||||
Log::warn << "setEnabled() called on invalid State";
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard lock(stagesMutex);
|
||||
stages.at((int) s)->enabled = b;
|
||||
}
|
||||
|
||||
|
@ -83,6 +87,7 @@ void LolAutoAccept::innerRun() {
|
|||
shouldrun = true;
|
||||
|
||||
while(shouldrun) {
|
||||
uint32_t extrasleep = 800;
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
|
||||
auto phase = clientapi->getGameflowPhase();
|
||||
|
@ -100,8 +105,20 @@ void LolAutoAccept::innerRun() {
|
|||
}
|
||||
}
|
||||
resetAllOffsets();
|
||||
extrasleep = 0; // no extra sleep
|
||||
} else if(phase == ClientAPI::GameflowPhase::CHAMPSELECT) {
|
||||
champSelect();
|
||||
extrasleep = 0; // no extra sleep
|
||||
} else if(phase == ClientAPI::GameflowPhase::INPROGRESS) {
|
||||
extrasleep = 30000; // 30s bonus sleep
|
||||
} else if(phase == ClientAPI::GameflowPhase::ENDOFGAME) {
|
||||
extrasleep = 2000; // 2 s bonus sleep
|
||||
} else if(phase == ClientAPI::GameflowPhase::PREENDOFGAME) {
|
||||
extrasleep = 4000; // 4 s bonus sleep
|
||||
} else if(phase == ClientAPI::GameflowPhase::WAITINGFORSTATS) {
|
||||
extrasleep = 4000; // 4 s bonus sleep
|
||||
} else if(phase == ClientAPI::GameflowPhase::NONE) {
|
||||
extrasleep = 30000; // 30 s bonus sleep - no lobby
|
||||
}
|
||||
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
|
@ -109,7 +126,7 @@ void LolAutoAccept::innerRun() {
|
|||
//if(dur.count() > 1e-5)
|
||||
Log::note << "iteration took: " << (dur.count() * 1000) << " ms";
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1200));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(400 + extrasleep));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,7 +193,7 @@ LolAutoAccept::ownactions_t LolAutoAccept::getOwnActions(int32_t cellid, const s
|
|||
}
|
||||
|
||||
void LolAutoAccept::prepickPhase(const ownactions_t& ownactions) {
|
||||
phase(ownactions, ClientAPI::ChampSelectActionType::PICK, State::PREPICK, false);
|
||||
phase(ownactions, ClientAPI::ChampSelectActionType::PICK, State::PICK, false);
|
||||
}
|
||||
|
||||
void LolAutoAccept::banPhase(const ownactions_t& ownactions, const ClientAPI::ChampSelectSession& session) {
|
||||
|
@ -229,7 +246,7 @@ void LolAutoAccept::champSelect() {
|
|||
}
|
||||
}
|
||||
|
||||
ClientAPI::Position pos = me ? me->position : ClientAPI::Position::INVALID;
|
||||
Position pos = me ? me->position : Position::INVALID;
|
||||
|
||||
Log::debug << "cellid: " << cellid << " position: " << pos << " counter: " << session.counter << " timer: timeleftip: " << session.timer.adjustedTimeLeftInPhase << " totaltimephase: " << session.timer.totalTimeInPhase;
|
||||
|
||||
|
@ -239,6 +256,8 @@ void LolAutoAccept::champSelect() {
|
|||
|
||||
// try to prepick champ
|
||||
Log::info << "champselectphase: " << session.timer.phase;
|
||||
|
||||
std::lock_guard lock(stagesMutex);
|
||||
if(session.timer.phase == ClientAPI::ChampSelectPhase::PLANNING) {
|
||||
prepickPhase(ownactions);
|
||||
} else if(session.timer.phase == ClientAPI::ChampSelectPhase::BAN_PICK) {
|
||||
|
|
|
@ -3,26 +3,23 @@
|
|||
|
||||
#include <Log.h>
|
||||
|
||||
static void applySetting(const Config::StageConfig& sc, StageSettings* ss) {
|
||||
ss->setState(sc.enabled);
|
||||
ss->setChampions(sc.champs);
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(LolAutoAccept& lolaa, QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), lolaa(lolaa), dd(QLocale().name().toStdString()) {
|
||||
ui->setupUi(this);
|
||||
|
||||
conf.load();
|
||||
|
||||
ui->prepickstage->setDataDragon(&dd);
|
||||
ui->banstage->setDataDragon(&dd);
|
||||
ui->pickstage->setDataDragon(&dd);
|
||||
// for all tabs - set their config and datadragon
|
||||
Config::RootConfig& rc = conf.getConfig();
|
||||
for(int32_t tabnr = 0; tabnr < ui->tabWidget->count(); ++tabnr) {
|
||||
SettingsTab* tab = (SettingsTab*) ui->tabWidget->widget(tabnr);
|
||||
tab->setup(rc.getPositionConfig(tab->getPosition()), &dd);
|
||||
|
||||
QObject::connect(tab, SIGNAL( changed(Position, LolAutoAccept::State) ), this, SLOT( tabchanged(Position, LolAutoAccept::State) ));
|
||||
QObject::connect(tab, SIGNAL( toggled(Position, LolAutoAccept::State, bool) ), this, SLOT( tabtoggled(Position, LolAutoAccept::State, bool) ));
|
||||
}
|
||||
|
||||
const Config::RootConfig& rc = conf.getConfig();
|
||||
ui->enableAll->setChecked(rc.enabledAutoAccept);
|
||||
lolaa.setEnabled(rc.enabledAutoAccept, LolAutoAccept::State::LOBBY);
|
||||
applySetting(rc.prepick, ui->prepickstage);
|
||||
applySetting(rc.ban, ui->banstage);
|
||||
applySetting(rc.pick, ui->pickstage);
|
||||
|
||||
resizeEvent(nullptr);
|
||||
}
|
||||
|
@ -70,16 +67,6 @@ void MainWindow::aatoggled(bool state) {
|
|||
conf.getConfig().enabledAutoAccept = state;
|
||||
}
|
||||
|
||||
static std::vector<std::string> toChampionNameList(const std::vector<StageSettings::SelectedChamp>& scs) {
|
||||
std::vector<std::string> out;
|
||||
|
||||
for(const StageSettings::SelectedChamp& sc : scs) {
|
||||
out.push_back(sc.name);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
static std::vector<uint32_t> toChampionIDList(const std::vector<StageSettings::SelectedChamp>& scs) {
|
||||
std::vector<uint32_t> out;
|
||||
|
||||
|
@ -90,41 +77,16 @@ static std::vector<uint32_t> toChampionIDList(const std::vector<StageSettings::S
|
|||
return out;
|
||||
}
|
||||
|
||||
void MainWindow::pptoggled(bool state) {
|
||||
Log::info << "enablePrePick checkbox toggled " << state;
|
||||
lolaa.setEnabled(state, LolAutoAccept::State::PREPICK);
|
||||
conf.getConfig().prepick.enabled = state;
|
||||
void MainWindow::tabtoggled(Position p, LolAutoAccept::State s, bool state) {
|
||||
Log::info << "PrePick checkbox toggled " << state << " position: " << p << " state: " << (int) s;
|
||||
|
||||
lolaa.setEnabled(state, s);
|
||||
}
|
||||
|
||||
void MainWindow::ppedited() {
|
||||
Log::info << "prepick edited";
|
||||
auto champs = ui->prepickstage->getChampions();
|
||||
lolaa.setChamps(toChampionIDList(champs), LolAutoAccept::State::PREPICK);
|
||||
conf.getConfig().prepick.champs = toChampionNameList(champs);
|
||||
}
|
||||
void MainWindow::tabchanged(Position p, LolAutoAccept::State s) {
|
||||
Log::info << "prepick edited position: " << p << " state: " << (int) s;
|
||||
|
||||
void MainWindow::bantoggled(bool state) {
|
||||
Log::info << "enableBan checkbox toggled " << state;
|
||||
lolaa.setEnabled(state, LolAutoAccept::State::BAN);
|
||||
conf.getConfig().ban.enabled = state;
|
||||
}
|
||||
|
||||
void MainWindow::banedited() {
|
||||
Log::info << "ban edited";
|
||||
auto champs = ui->banstage->getChampions();
|
||||
lolaa.setChamps(toChampionIDList(champs), LolAutoAccept::State::BAN);
|
||||
conf.getConfig().ban.champs = toChampionNameList(champs);
|
||||
}
|
||||
|
||||
void MainWindow::picktoggled(bool state) {
|
||||
Log::info << "enablePick checkbox toggled " << state;
|
||||
lolaa.setEnabled(state, LolAutoAccept::State::PICK);
|
||||
conf.getConfig().pick.enabled = state;
|
||||
}
|
||||
|
||||
void MainWindow::pickedited() {
|
||||
Log::info << "pick edited";
|
||||
auto champs = ui->pickstage->getChampions();
|
||||
lolaa.setChamps(toChampionIDList(champs), LolAutoAccept::State::PICK);
|
||||
conf.getConfig().pick.champs = toChampionNameList(champs);
|
||||
SettingsTab* tab = (SettingsTab*) ui->tabWidget->widget((int) p -1);
|
||||
auto champs = tab->getChamps(s);
|
||||
lolaa.setChamps(toChampionIDList(champs), s);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
#include "settingstab.h"
|
||||
#include "ui_settingstab.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
static std::vector<std::string> toChampionNameList(const std::vector<StageSettings::SelectedChamp>& scs) {
|
||||
std::vector<std::string> out;
|
||||
out.reserve(scs.size());
|
||||
|
||||
std::transform(scs.begin(), scs.end(), std::insert_iterator(out, out.begin()), [](const StageSettings::SelectedChamp& sc) { return sc.name; });
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
SettingsTab::SettingsTab(QWidget *parent) : QWidget(parent), ui(new Ui::SettingsTab) {
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
SettingsTab::~SettingsTab() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SettingsTab::setup(Config::PositionConfig& conf, DataDragon* dd) {
|
||||
this->conf = &conf;
|
||||
this->dd = dd;
|
||||
|
||||
ui->banstage->setDataDragon(dd);
|
||||
ui->pickstage->setDataDragon(dd);
|
||||
}
|
||||
|
||||
std::vector<StageSettings::SelectedChamp> SettingsTab::getChamps(LolAutoAccept::State s) const {
|
||||
return getStage(s)->getChampions();
|
||||
}
|
||||
|
||||
bool SettingsTab::getState(LolAutoAccept::State s) const {
|
||||
auto stage = getStage(s);
|
||||
return stage->getState();
|
||||
}
|
||||
|
||||
void SettingsTab::setChamps(LolAutoAccept::State s, const std::vector<std::string>& c) {
|
||||
getStage(s)->setChampions(c);
|
||||
}
|
||||
|
||||
void SettingsTab::setState(LolAutoAccept::State s, bool b) {
|
||||
auto stage = getStage(s);
|
||||
return stage->setState(b);
|
||||
}
|
||||
|
||||
Position SettingsTab::getPosition() const {
|
||||
return position;
|
||||
}
|
||||
|
||||
void SettingsTab::banToggled(bool b) {
|
||||
conf->ban.enabled = b;
|
||||
emit toggled(position, LolAutoAccept::State::BAN, b);
|
||||
}
|
||||
|
||||
void SettingsTab::banChampsChanged() {
|
||||
conf->ban.champs = toChampionNameList(ui->banstage->getChampions());
|
||||
emit changed(position, LolAutoAccept::State::BAN);
|
||||
}
|
||||
|
||||
void SettingsTab::pickToggled(bool b) {
|
||||
conf->pick.enabled = b;
|
||||
emit toggled(position, LolAutoAccept::State::PICK, b);
|
||||
}
|
||||
|
||||
void SettingsTab::pickChampsChanged() {
|
||||
conf->pick.champs = toChampionNameList(ui->pickstage->getChampions());
|
||||
emit changed(position, LolAutoAccept::State::BAN);
|
||||
}
|
||||
|
||||
StageSettings* SettingsTab::getStage(LolAutoAccept::State s) const {
|
||||
switch(s) {
|
||||
case LolAutoAccept::State::BAN: return ui->banstage;
|
||||
case LolAutoAccept::State::PICK: return ui->pickstage;
|
||||
default: break;
|
||||
}
|
||||
assert(false); // "invalid" stage (Lobby or Game)
|
||||
return nullptr;
|
||||
}
|
|
@ -89,6 +89,38 @@
|
|||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>championList</sender>
|
||||
<signal>doubleClicked(QModelIndex)</signal>
|
||||
<receiver>ChampionSearch</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>182</x>
|
||||
<y>169</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>396</x>
|
||||
<y>188</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>championList</sender>
|
||||
<signal>itemActivated(QListWidgetItem*)</signal>
|
||||
<receiver>ChampionSearch</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>324</x>
|
||||
<y>106</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>396</x>
|
||||
<y>116</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>searchChanged(QString)</slot>
|
||||
|
|
222
ui/mainwindow.ui
222
ui/mainwindow.ui
|
@ -54,72 +54,65 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="StageSettings" name="prepickstage" native="true">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="tabPosition">
|
||||
<enum>QTabWidget::North</enum>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<property name="tabShape">
|
||||
<enum>QTabWidget::Rounded</enum>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="name" stdset="0">
|
||||
<string>Pre Pick</string>
|
||||
<property name="elideMode">
|
||||
<enum>Qt::ElideNone</enum>
|
||||
</property>
|
||||
<property name="state" stdset="0">
|
||||
<property name="usesScrollButtons">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="StageSettings" name="banstage" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="name" stdset="0">
|
||||
<string>Ban</string>
|
||||
</property>
|
||||
<property name="state" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="StageSettings" name="pickstage" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="name" stdset="0">
|
||||
<string>Pick</string>
|
||||
</property>
|
||||
<property name="state" stdset="0">
|
||||
<property name="tabsClosable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="SettingsTab" name="tab_top">
|
||||
<property name="position" stdset="0">
|
||||
<UInt>1</UInt>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Top</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="SettingsTab" name="tab_jgl">
|
||||
<property name="position" stdset="0">
|
||||
<UInt>2</UInt>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Jungle</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="SettingsTab" name="tab_mid">
|
||||
<property name="position" stdset="0">
|
||||
<UInt>3</UInt>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Middle</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="SettingsTab" name="tab_bot">
|
||||
<property name="position" stdset="0">
|
||||
<UInt>4</UInt>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Bottom</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="SettingsTab" name="tab_sup">
|
||||
<property name="position" stdset="0">
|
||||
<UInt>5</UInt>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Support</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -139,13 +132,10 @@
|
|||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>StageSettings</class>
|
||||
<class>SettingsTab</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>stagesettings.h</header>
|
||||
<slots>
|
||||
<signal>toggled(bool)</signal>
|
||||
<signal>championsChanged()</signal>
|
||||
</slots>
|
||||
<header>settingstab.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
|
@ -170,38 +160,6 @@
|
|||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>prepickstage</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>pptoggled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>253</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>296</x>
|
||||
<y>309</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>banstage</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>bantoggled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>227</x>
|
||||
<y>413</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>265</x>
|
||||
<y>390</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>mainswitch</sender>
|
||||
<signal>clicked(bool)</signal>
|
||||
|
@ -218,79 +176,11 @@
|
|||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pickstage</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>picktoggled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>201</x>
|
||||
<y>489</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>265</x>
|
||||
<y>476</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pickstage</sender>
|
||||
<signal>championsChanged()</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>pickedited()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>172</x>
|
||||
<y>498</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>122</x>
|
||||
<y>473</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>banstage</sender>
|
||||
<signal>championsChanged()</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>banedited()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>149</x>
|
||||
<y>418</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>111</x>
|
||||
<y>379</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>prepickstage</sender>
|
||||
<signal>championsChanged()</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>ppedited()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>185</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>122</x>
|
||||
<y>308</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>aatoggled(bool)</slot>
|
||||
<slot>pptoggled(bool)</slot>
|
||||
<slot>ppedited()</slot>
|
||||
<slot>bantoggled(bool)</slot>
|
||||
<slot>picktoggled(bool)</slot>
|
||||
<slot>banedited()</slot>
|
||||
<slot>pickedited()</slot>
|
||||
<slot>tabtoggled(Position, LolAutoAccept::State, bool)</slot>
|
||||
<slot>tabchanged(Position, LolAutoAccept::State)</slot>
|
||||
<slot>toggleMainswitch(bool)</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SettingsTab</class>
|
||||
<widget class="QWidget" name="SettingsTab">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="StageSettings" name="banstage" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="name" stdset="0">
|
||||
<string>Ban</string>
|
||||
</property>
|
||||
<property name="state" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="StageSettings" name="pickstage" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="name" stdset="0">
|
||||
<string>Pick</string>
|
||||
</property>
|
||||
<property name="state" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>StageSettings</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>stagesettings.h</header>
|
||||
<slots>
|
||||
<signal>toggled(bool)</signal>
|
||||
<signal>championsChanged()</signal>
|
||||
</slots>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>banstage</sender>
|
||||
<signal>championsChanged()</signal>
|
||||
<receiver>SettingsTab</receiver>
|
||||
<slot>banChampsChanged()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>179</x>
|
||||
<y>78</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>398</x>
|
||||
<y>86</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>banstage</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>SettingsTab</receiver>
|
||||
<slot>banToggled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>329</x>
|
||||
<y>124</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>397</x>
|
||||
<y>123</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pickstage</sender>
|
||||
<signal>championsChanged()</signal>
|
||||
<receiver>SettingsTab</receiver>
|
||||
<slot>pickChampsChanged()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>284</x>
|
||||
<y>220</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>400</x>
|
||||
<y>200</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pickstage</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>SettingsTab</receiver>
|
||||
<slot>pickToggled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>344</x>
|
||||
<y>257</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>400</x>
|
||||
<y>257</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>banToggled(bool)</slot>
|
||||
<slot>banChampsChanged()</slot>
|
||||
<slot>pickToggled(bool)</slot>
|
||||
<slot>pickChampsChanged()</slot>
|
||||
</slots>
|
||||
</ui>
|
Loading…
Reference in New Issue