Compare commits

...

40 Commits

Author SHA1 Message Date
mrbesen 01e9a42482
add loading screen; make RestClient a QObject 2023-08-27 16:51:19 +02:00
mrbesen e7a10f2921
remove debug logging 2023-06-19 21:22:44 +02:00
mrbesen 7d5f61dba8
implement subgroups in rune editor 2023-06-19 20:58:55 +02:00
mrbesen df78570e51
select Rune Style 2023-06-13 23:02:38 +02:00
mrbesen a9fa26346f
rune editor with runeaspektbuttongroups 2023-06-13 22:40:55 +02:00
mrbesen 201f3665b3
fix restclient corrupting requests 2023-06-12 20:19:37 +02:00
mrbesen 61c64def43
remove runepage from lolaa; corrupted QString fix; cellid changed fix 2023-06-11 21:06:32 +02:00
mrbesen adcf715694
runepage icons fuzzy matching 2023-06-11 20:36:56 +02:00
mrbesen b919a64ae6
move to QString 2023-05-31 22:22:23 +02:00
mrbesen 42ff827caf
update translations 2023-05-21 12:42:22 +02:00
mrbesen 4535495b09
new icons 2023-05-21 12:42:08 +02:00
mrbesen e9f99b2323
move delete to bottom 2023-05-21 11:57:21 +02:00
mrbesen bc63e4be72
windows compat 2023-05-04 20:13:07 +02:00
mrbesen 96d57e8b8a
no rich text 2023-05-02 21:40:53 +02:00
mrbesen 17b244ec81
import and export runes 2023-05-02 21:31:17 +02:00
mrbesen 5aff7f431a
fix autowriteTextbox 2023-05-01 22:36:25 +02:00
mrbesen 14ec8a711b
add runeeditor 2023-05-01 22:36:11 +02:00
mrbesen ee7a11b0ef
champion images in runepages 2023-05-01 01:23:08 +02:00
mrbesen 67175bc446
update link 2023-05-01 00:22:02 +02:00
mrbesen d375c590f8
auto sync runes 2023-04-30 22:10:21 +02:00
mrbesen 41de5a8652
fix id alignment problem when deleting aa runes 2023-04-30 16:26:46 +02:00
mrbesen 67d5614be3
restoring runepages 2023-04-30 16:20:13 +02:00
mrbesen 4aa35ff4e1
storing runepages 2023-04-23 23:54:09 +02:00
mrbesen ef36280894
rune manager preperations 2023-04-23 19:13:49 +02:00
mrbesen 6ffdf23085
make LolAutoAccept a QObject 2023-02-26 13:50:57 +01:00
mrbesen 5f3ff9e292
fix endsWith bug 2023-02-26 12:37:30 +01:00
mrbesen e67c18f2ce
update version and changelog 2023-02-05 13:53:26 +01:00
mrbesen 0aca8969f9
change behavior of autowrite: only write re-write on rising edge 2023-02-05 13:47:09 +01:00
mrbesen aa982d3798
automatically embed translations with qmake and cleanup of pro file 2023-02-05 13:46:26 +01:00
mrbesen dd125d3183
adjust stagesettings ui; fix Enable Pick / Ban Button 2023-01-22 23:46:03 +01:00
mrbesen 152873d860
auto save configuration 2022-12-16 23:09:24 +01:00
mrbesen 5fc50a524c
add tab icons 2022-12-16 22:44:10 +01:00
mrbesen 3f1c264818
use new logger version with qt support 2022-10-26 22:01:03 +02:00
mrbesen 49bdc60071
changelog 2022-10-11 20:22:49 +02:00
mrbesen bc6f80c187
update language 2022-10-10 21:40:36 +02:00
mrbesen ec4566f76a
copyright label as single label 2022-10-10 21:38:35 +02:00
mrbesen 7cd1795155
add version, copyright info, link to release page, update translation 2022-10-08 18:38:01 +02:00
mrbesen 53d642f507
fix the not working checkboxes 2022-10-02 23:46:11 +02:00
mrbesen dd01c70230
fixed default page 2022-09-21 16:50:06 +02:00
mrbesen af63c975c7
autowrite implemented 2022-09-21 13:47:08 +02:00
81 changed files with 3823 additions and 868 deletions

2
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "thirdparty/Log"]
path = thirdparty/Log
url = https://git.okaestne.de/okaestne/Log.git
url = https://git.mrbesen.de/MrBesen/Log.git

21
debian/changelog vendored
View File

@ -1,4 +1,23 @@
lolautoaccept (0.0.5) UNRELEASED; urgency=medium
lolautoaccept (0.0.7) unstable; urgency=medium
* add tab icons
* embed translations with qt
* adjust stagesettings ui
* add autosave for configurations
* change to log-version with qt-support
-- MrBesen <> Sun, 05 Feb 2023 13:48:39 +0100
lolautoaccept (0.0.6) unstable; urgency=medium
[ MrBesen Tue, 11 Oct 2022 20:17:00 +0200 ]
* fix the default tab
* fix the `enable pick` and `enable ban` buttons
* add autowrite - automatically send a text message in the champselect lobby
-- MrBesen <> Tue, 11 Oct 2022 20:17:54 +0200
lolautoaccept (0.0.5) unstable; urgency=medium
* Initial release.

View File

@ -8,6 +8,8 @@
#include "position.h"
class BlitzAPI : public RestClient {
Q_OBJECT
public:
BlitzAPI();

View File

@ -8,12 +8,12 @@ class ChampCache {
public:
ChampCache();
std::string getVersion();
QString getVersion();
QJsonDocument getChamps();
void saveChamps(QJsonDocument doc, const std::string& version);
void saveChamps(QJsonDocument doc, const QString& version);
private:
std::string basefolder;
QString basefolder;
uint64_t maxage = 86400; // is in seconds
};

View File

@ -1,25 +1,25 @@
#pragma once
#include <istream>
#include <string>
#include <memory>
#include <vector>
#include <QString>
class ClientAccess {
ClientAccess();
public:
ClientAccess(const std::string& token, uint16_t port);
ClientAccess(const QString& token, uint16_t port);
static std::shared_ptr<ClientAccess> find();
public:
std::string getBasicAuth() const;
QString getBasicAuth() const;
uint16_t getPort() const;
std::string getURL() const;
QString getURL() const;
private:
std::string authcode;
QString authcode;
uint16_t port = 0;
};

View File

@ -1,13 +1,17 @@
#pragma once
#include "clientaccess.h"
#include "restclient.h"
#include "datadragonimagecache.h"
#include "memoryimagecache.h"
#include "position.h"
#include "restclient.h"
#include "runeaspekt.h"
#include "runepage.h"
#include "runestyle.h"
class ClientAPI : public RestClient {
Q_OBJECT
public:
enum class ReadyCheckState : uint32_t {
INVALID = 0,
@ -35,7 +39,7 @@ public:
ENDOFGAME,
TERMINATEDINERROR,
};
static GameflowPhase toGameflowPhase(const std::string&);
static GameflowPhase toGameflowPhase(const QString&);
enum class ChampSelectPhase : uint32_t {
INVALID = 0,
@ -44,7 +48,7 @@ public:
BAN_PICK,
FINALIZATION
};
static ChampSelectPhase toChampSelectPhase(const std::string& str);
static ChampSelectPhase toChampSelectPhase(const QString& str);
enum class ChampSelectActionType : uint32_t {
INVALID = 0,
@ -52,7 +56,7 @@ public:
PICK,
TEN_BANS_REVEAL,
};
static ChampSelectActionType toChampSelectActionType(const std::string& str);
static ChampSelectActionType toChampSelectActionType(const QString& str);
struct TimerInfo {
int64_t adjustedTimeLeftInPhase = 0;
@ -69,12 +73,12 @@ public:
struct PlayerInfo {
int64_t summonerid = 0; // to test validity -> test if this is not null
std::string gameName;
std::string name;
std::string statusMessage;
QString gameName;
QString name;
QString statusMessage;
// lol specific
std::string puuid;
QString puuid;
uint32_t level = 0;
};
@ -97,7 +101,7 @@ public:
int32_t championID = 0;
int32_t championPickIntentID = 0;
int64_t summonerID = 0;
int64_t spell1Id = 0; // 4 = flash, 6 = ghost, 7 = heal, 11 = smite, 12 = teleport, 14 = ignite
int64_t spell1Id = 0; // 4 = flash, 6 = ghost, 7 = heal, 11 = smite, 12 = teleport, 13 = klarheitz, 14 = ignite, 32 = snowball
int64_t spell2Id = 0;
ChampSelectCell();
@ -137,7 +141,7 @@ public:
struct RunePage {
uint64_t id = 0;
uint64_t lastmodified = 0;
std::string name;
QString name;
bool isDeleteable = true;
bool isEditable = true;
bool isActive = false; // what is the difference between active and current????
@ -151,30 +155,30 @@ public:
};
struct Message {
std::string body;
std::string fromId;
std::string fromPid;
QString body;
QString fromId;
QString fromPid;
int64_t fromSummonerId;
std::string id;
QString id;
bool isHistorical;
std::string timestamp;
std::string type; // known types: chat (1:1), customGame, championSelect, groupchat
QString timestamp;
QString type; // known types: chat (1:1), customGame, championSelect, groupchat
Message();
explicit Message(const QJsonObject& json);
};
struct Conversation {
std::string gameName;
std::string gameTag;
std::string id;
QString gameName;
QString gameTag;
QString id;
bool isMuted;
std::shared_ptr<Message> lastMessage;
std::string name;
std::string password;
std::string pid;
std::string targetRegion;
std::string type;
QString name;
QString password;
QString pid;
QString targetRegion;
QString type;
int64_t unreadMessageCount;
Conversation();
@ -199,24 +203,37 @@ public:
// chats
std::vector<Conversation> getAllConversations();
Message sendMessage(const std::string& chatid, const std::string& messagebody);
Message sendMessage(const QString& chatid, const QString& messagebody);
// rune stuff
RunePage getCurrentRunePage();
std::vector<RunePage> getAllRunePages();
bool selectRunePage(uint64_t id);
bool editRunePage(const RunePage& page);
bool createRunePage(const RunePage& page);
bool deleteRunePage(uint64_t id);
std::vector<RuneAspekt> getAllRuneAspekts();
std::vector<RuneStyle> getAllRuneStyles();
const std::string& getRuneStyleByID(uint32_t id);
const QString& getRuneStyleByID(uint32_t id);
QPixmap getImageResource(QString path);
private:
ClientAccess access;
MemoryImageCache memImageCache;
DataDragonImageCache imageCache;
};
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::ChampSelectActionType&);
#define DEFINEOPERATOR(CLASS) \
std::ostream& operator<<(std::ostream&, const ClientAPI::CLASS&); \
QDebug operator<<(QDebug, const ClientAPI::CLASS&);
DEFINEOPERATOR(ReadyCheckState);
DEFINEOPERATOR(GameflowPhase);
DEFINEOPERATOR(ChampSelectPhase);
DEFINEOPERATOR(ChampSelectActionType);
#undef DEFINEOPERATOR

33
include/clipboardpopup.h Normal file
View File

@ -0,0 +1,33 @@
#pragma once
#include <QDialog>
namespace Ui {
class ClipboardPopup;
}
class ClipboardPopup : public QDialog {
Q_OBJECT
public:
enum class Direction {
Paste,
Copy
};
explicit ClipboardPopup(Direction dir, QWidget* parent = nullptr);
~ClipboardPopup();
void setText(QString text);
QString getText() const;
private slots:
void textPasted();
void copyButton();
private:
Ui::ClipboardPopup *ui;
Direction direction;
int lastKnownTextSize = 0;
};

View File

@ -4,6 +4,7 @@
#include <QJsonObject>
#include "position.h"
#include "runepage.h"
class Config {
public:
@ -12,7 +13,7 @@ public:
StageConfig(const QJsonObject&);
operator QJsonObject() const;
std::vector<std::string> champs;
std::vector<QString> champs;
bool enabled = false;
};
@ -27,6 +28,25 @@ public:
StageConfig pick;
};
struct RunePageConfig {
RunePageConfig();
RunePageConfig(QString name, const RunePage& rp);
RunePageConfig(const QJsonObject&);
operator QJsonObject() const;
QString name;
RunePage runepage;
};
struct GeneralRunePageConfig {
GeneralRunePageConfig();
GeneralRunePageConfig(const QJsonObject&);
operator QJsonObject() const;
bool autoSync;
std::vector<std::shared_ptr<RunePageConfig>> runePages;
};
struct RootConfig {
RootConfig();
RootConfig(const QJsonObject&);
@ -35,9 +55,12 @@ public:
std::shared_ptr<Config::PositionConfig> getPositionConfig(Position position);
std::vector<std::shared_ptr<PositionConfig>> positionConfigs;
GeneralRunePageConfig runepagesConfig;
bool enabledAutoAccept;
bool enabledSmiteWarn;
bool enabledAutoWrite;
QString autoWriteText;
};
Config();
@ -48,7 +71,7 @@ public:
RootConfig& getConfig();
private:
std::string configFolderPath;
std::string configFilePath;
QString configFolderPath;
QString configFilePath;
RootConfig root;
};

View File

@ -4,8 +4,7 @@
#include <functional>
#include <mutex>
#include <set>
#include <string>
#include <thread>
#include <QString>
#include <vector>
#include <QPixmap>
@ -15,11 +14,15 @@
#include "memoryimagecache.h"
#include "restclient.h"
class QThread;
class DataDragon : public RestClient {
Q_OBJECT
public:
using notifyImgfunc_t = std::function<void(QPixmap)>;
DataDragon(const std::string& locale);
DataDragon(const QString& locale);
~DataDragon();
DataDragon(const DataDragon&) = delete;
DataDragon& operator=(const DataDragon&) = delete;
@ -29,11 +32,11 @@ public:
ChampData();
ChampData(const QJsonObject& source);
std::string name;
std::string id;
QString name;
QString id;
int key = 0;
std::string partype;
std::string title;
QString partype;
QString title;
};
enum class ImageType {
@ -43,42 +46,54 @@ public:
};
// might block until version is available
const std::string& getVersion();
const QString& getVersion();
// might block until champ data is available
const std::vector<ChampData>& getChamps();
// might block until image is downloaded
QPixmap getImage(const std::string& champid, ImageType imgtype = ImageType::SQUARE, bool writeMemcache = true);
void getImageAsnyc(const std::string& champid, notifyImgfunc_t func, ImageType imgtype = ImageType::SQUARE);
QPixmap getImage(const QString& champid, ImageType imgtype = ImageType::SQUARE, bool writeMemcache = true);
void getImageAsnyc(const QString& champid, notifyImgfunc_t func, ImageType imgtype = ImageType::SQUARE);
// 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& getBestMatchingChamp(const QString& name, int* count = nullptr);
std::vector<const ChampData*> getMatchingChamp(const QString& 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<QString>& champnames);
void startThread();
static const ChampData EMPTYCHAMP;
protected:
std::string getImageUrl(const std::string& champid, ImageType type);
std::string getCDNString() const;
void prefetchChampImage(const std::string& champid, ImageType imgtype = ImageType::SQUARE);
public slots:
void stop();
signals:
// loading progress in 0.0 - 1.0
void loading(float);
// which champion is currently prefretched
void fetchingChamp(QString);
protected:
QString getImageUrl(const QString& champid, ImageType type);
QString getCDNString() const;
void prefetchChampImage(const QString& champid, ImageType imgtype = ImageType::SQUARE);
void getVersionInternal();
void getChampsInternal();
void startThread();
void stopThread();
void stopAndJoinThread();
void threadLoop();
std::string locale;
std::string version;
QString locale;
QString version;
std::vector<ChampData> champs;
std::mutex cachedatamutex;
std::condition_variable cachedatacv;
std::set<std::string> notDownloadedImages; // the champions of which the square image is not downloaded yet. Is used to download them on idle
std::set<QString> notDownloadedImages; // the champions of which the square image is not downloaded yet. Is used to download them on idle
private:
struct Task {
std::string champid;
QString champid;
notifyImgfunc_t func;
ImageType type;
};
@ -90,9 +105,9 @@ private:
std::list<Task> tasks;
std::mutex tasksmutex;
std::condition_variable tasksnotemptycv;
std::thread bgthread;
QThread* bgthread;
bool shouldrun = true;
};
std::ostream& operator<<(std::ostream& str, const DataDragon::ChampData& cd);
std::ostream& operator<<(std::ostream& str, const DataDragon::ChampData& cd);

View File

@ -1,20 +1,20 @@
#pragma once
#include <string>
#include <QString>
#include <QByteArray>
#include <QPixmap>
class DataDragonImageCache {
public:
DataDragonImageCache(const std::string& folderextra, const std::string& imageext = ".jpg");
DataDragonImageCache(const QString& folderextra, const QString& imageext = ".jpg");
~DataDragonImageCache();
bool hasImage(const std::string& name);
QPixmap getImage(const std::string& name);
void addImageRaw(const QByteArray& arr, const std::string& name);
bool hasImage(const QString& name);
QPixmap getImage(const QString& name);
void addImageRaw(const QByteArray& arr, const QString& name);
private:
std::string getFilepath(const std::string& name) const;
QString getFilepath(const QString& name) const;
std::string cacheDir;
std::string imageext; // file extention including dot
QString cacheDir;
QString imageext; // file extention including dot
};

View File

@ -3,12 +3,13 @@
// stuff required for file handling
#include <string>
#include <QString>
// create a directory and its parents
bool mkdirs(const std::string& path);
bool mkdirs(const QString& path);
// get $HOME or a useful default value
std::string getHome();
QString getHome();
// folder for caching example: $HOME/.cache/lolautoaccept/
std::string getCache();
QString getCache();

View File

@ -22,7 +22,7 @@ template<>
uint64_t convert(const QJsonValue& val);
template<>
std::string convert(const QJsonValue& val);
QString convert(const QJsonValue& val);
template<>
bool convert(const QJsonValue& val);

36
include/loadingwindow.h Normal file
View File

@ -0,0 +1,36 @@
#ifndef LOADINGWINDOW_H
#define LOADINGWINDOW_H
#include <QWidget>
class QCloseEvent;
namespace Ui {
class LoadingWindow;
}
class LoadingWindow : public QWidget {
Q_OBJECT
public:
explicit LoadingWindow( QWidget* parent = nullptr );
~LoadingWindow();
public slots:
void setChampion(QString championName);
void setText(QString text);
// should be 0.0 to 1.0
void setProgress(float val);
signals:
void closed();
protected:
virtual void closeEvent(QCloseEvent*) override;
private:
Ui::LoadingWindow* ui;
};
#endif // LOADINGWINDOW_H

View File

@ -4,6 +4,8 @@
#include <memory>
#include <mutex>
#include <QObject>
#include "blitzapi.h"
#include "clientapi.h"
#include "config.h"
@ -11,11 +13,9 @@
#include "runepage.h"
#include "runestyle.h"
class LolAutoAccept {
public:
using onposchange_func = std::function<void(Position)>;
using onruneschange_func = std::function<void(const RunePage&)>;
using onfailed_func = std::function<void()>;
class LolAutoAccept : public QObject {
Q_OBJECT
protected:
struct Stage {
Stage();
@ -31,12 +31,10 @@ protected:
Position currentPosition = Position::INVALID;
bool currentPositionSet = false;
uint32_t lastPickedChamp = 0;
int32_t lastCellId = -1; // last cellid -> if changed -> reset
Config::RootConfig& config;
DataDragon& dd;
onposchange_func onPoschange;
onruneschange_func onRuneschange;
onfailed_func onFailed;
bool shouldrun = false;
std::thread lolaathread;
@ -49,8 +47,11 @@ protected:
bool nextApplyRunes = false;
bool smiteWarnEnabled = true;
bool autoWriteTextEnabled = false;
bool autoWriteTextDone = false;
QString autoWriteText;
std::string chatid; // the chatid of the chat from the champselect
QString chatid; // the chatid of the chat from the champselect
std::chrono::time_point<std::chrono::system_clock> lastMessageSent;
public:
@ -60,8 +61,15 @@ public:
PICK = 2,
};
LolAutoAccept(Config::RootConfig& config, DataDragon& dd, onfailed_func = {}, onposchange_func = {}, onruneschange_func = {});
~LolAutoAccept();
enum class Status {
Off,
Running,
Failed
};
Q_ENUM(Status)
LolAutoAccept(Config::RootConfig& config, DataDragon& dd, QObject* parent = nullptr);
virtual ~LolAutoAccept();
void setChamps(const std::vector<uint32_t>& champs, State s);
void setEnabled(bool b, State s);
@ -70,19 +78,23 @@ public:
bool init(); // returns true on success
void run();
void stop();
Status getStatus();
void reload(); // reload the config, when something was changed
const std::vector<RuneAspekt>& getRuneAspekts();
const std::vector<RuneStyle>& getRuneStyles();
void applyRunes();
void setOnRuneChangeFunc(onruneschange_func on);
void setAutoWriteText(bool enabled, const QString& text = {});
signals:
void statusChanged(LolAutoAccept::Status); // new status: 0 = off, 1 = on, 2 = failed
void positionChanged(Position);
private:
void stopJoinThread();
void innerRun();
void resetPickOffsets();
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);
@ -102,6 +114,7 @@ private:
static int32_t getMatchingRunePage(const RunePage& rp, const std::vector<ClientAPI::RunePage>& allpages);
void champSelect();
void smiteWarning(const std::vector<ClientAPI::ChampSelectCell>& cells);
const std::string& getChatid();
void applyRunes_internal(uint32_t champid, Position pos);
const QString& getChatid();
};
Q_DECLARE_METATYPE(LolAutoAccept::Status)

View File

@ -12,6 +12,11 @@ QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class QTimer;
class LoadingWindow;
class MainWindow : public QMainWindow {
Q_OBJECT
@ -21,9 +26,16 @@ public:
protected:
virtual void closeEvent(QCloseEvent* event) override;
virtual void resizeEvent(QResizeEvent *event) override;
signals:
void requestTabChange(int tabindex);
public slots:
void resetSaveTimer();
private slots:
void loadingStatus(float);
void toggleMainswitch(bool);
void aatoggled(bool);
void smitewarntoggled(bool);
@ -31,21 +43,24 @@ private slots:
void tabtoggled(Position, LolAutoAccept::State, bool);
void tabchanged(Position, LolAutoAccept::State);
void applyRunes();
void autoWriteChanged();
signals:
void requestTabChange(int tabindex);
void saveConfig();
void initDone();
private:
// returns empty string on no match
void onPosChange(Position newpos); // to trigger the signal from a QObject
void onFail(); // get triggerd, when the autoacceptor fails (lost connection)
void lolaaStatusChanged(LolAutoAccept::Status); // get triggerd, when the autoacceptor fails (lost connection)
private:
bool loading;
Ui::MainWindow *ui;
QTimer* saveTimer;
std::thread lolaathread;
DataDragon dd;
Config conf;
LolAutoAccept lolaa;
LoadingWindow* lwin;
};
#endif // MAINWINDOW_H

View File

@ -1,27 +1,27 @@
#pragma once
#include <functional>
#include <string>
#include <QString>
#include <QPixmap>
class MemoryImageCache {
public:
MemoryImageCache(size_t maxsize = 25);
void addImage(QPixmap, const std::string& title, int type);
QPixmap getImage(const std::string& title, int type);
void addImage(QPixmap, const QString& title, int type);
QPixmap getImage(const QString& title, int type);
private:
void cleanUp();
struct CachedImage {
time_t lastaccessed = 0;
QPixmap imageref;
std::string title;
QString title;
int type;
bool operator<(const CachedImage& other) const;
};
static std::function<bool(const CachedImage&)> getImageMatcher(const std::string& title, int type);
static std::function<bool(const CachedImage&)> getImageMatcher(const QString& title, int type);
std::list<CachedImage> cache;
size_t maxsize;

View File

@ -1,8 +1,8 @@
#pragma once
#include <QDebug>
#include <QVariant>
enum class Position : uint32_t {
INVALID = 0,
TOP,
@ -11,10 +11,11 @@ enum class Position : uint32_t {
BOTTOM,
UTILITY
};
Position toPosition(const std::string& str);
std::string toString(Position p);
std::string toShortString(Position p);
Position toPosition(const QString& str);
QString toString(Position p);
QString toShortString(Position p);
std::ostream& operator<<(std::ostream&, const Position&);
QDebug operator<<(QDebug , const Position&);
Q_DECLARE_METATYPE(Position);

View File

@ -1,12 +1,21 @@
#pragma once
#include <string>
#include <QJsonDocument>
#include <curl/curl.h>
class RestClient {
#include <QObject>
#include <QJsonDocument>
#include <QString>
#ifdef Q_OS_WIN
#undef DELETE
#endif
class RestClient : public QObject {
Q_OBJECT
public:
RestClient(const std::string& base);
RestClient(const QString& base);
RestClient(const RestClient&) = delete;
virtual ~RestClient();
@ -15,7 +24,7 @@ public:
POST,
PUT,
PATCH,
// DELETE
DELETE
};
struct WebException {
@ -25,19 +34,21 @@ public:
};
protected:
QByteArray requestRaw(const std::string& url, Method m = Method::GET, const std::string& data = {});
QJsonDocument request(const std::string& url, Method m = Method::GET, const std::string& data = {});
QByteArray requestRaw(const QString& url, Method m = Method::GET, const QString& data = {});
QJsonDocument request(const QString& url, Method m = Method::GET, const QString& data = {});
void enableDebugging(bool enabled = true);
std::string escape(const std::string& in) const;
QString escape(const QString& in) const;
std::string baseurl;
QString baseurl;
CURL* curl = nullptr; // the curl (does curling)
std::string basicauth; // basic auth code (user:pw) or empty string to disable
QString basicauth; // basic auth code (user:pw) or empty string to disable
#ifdef WIN32
bool disableCertCheck = true;
#else
bool disableCertCheck = false;
#endif
};
const char* toString(RestClient::Method);

View File

@ -7,11 +7,11 @@ class QJsonObject;
struct RuneAspekt {
uint32_t id = 0;
std::string name;
std::string shortDesc;
std::string longDesc;
std::string tooltip;
std::string iconPath;
QString name;
QString shortDesc;
QString longDesc;
QString tooltip;
QString iconPath;
RuneAspekt();
explicit RuneAspekt(const QJsonObject& json);

View File

@ -0,0 +1,42 @@
#pragma once
#include <QPushButton>
#include <vector>
namespace Ui {
class RuneAspektButton;
}
class RuneAspektButtonGroup;
class RuneAspektButton : public QPushButton {
Q_OBJECT
public:
explicit RuneAspektButton(QWidget* parent = nullptr);
~RuneAspektButton();
void setAspektId(uint32_t id);
void setButtonGroup(RuneAspektButtonGroup* group);
bool isSelected() const;
signals:
void aspektToggled(int aspekt);
public slots:
void buttonPressed();
void dataChanged(); // triggers a refresh
void checkSelection(uint32_t aspekt); // only used for rune styles
private slots:
void setShowSelection(bool selected); // show/hide the red border
public:
uint32_t aspektId = 0;
private:
Ui::RuneAspektButton* ui;
RuneAspektButtonGroup* group = nullptr;
};

View File

@ -0,0 +1,39 @@
#pragma once
#include <cstdint>
#include <QObject>
#include <QVector>
class RuneAspektButton;
class RuneAspektButtonGroup : public QObject {
Q_OBJECT
public:
RuneAspektButtonGroup(QObject* parent, uint32_t size);
virtual ~RuneAspektButtonGroup();
void addButton(RuneAspektButton* button);
void setSelectedRunes(const QVector<int>& newRunes);
constexpr const QVector<int>& getSelectedRunes() const { return selectedRune; }
constexpr uint32_t getSize() const { return size; }
void setSubgroups(const QVector<QVector<int>>& newSubgroups);
static const int INVALID_ASPEKT_ID;
signals:
void changed(); // signal that the group was changed -> all buttons should refresh
private slots:
void buttonPressed(int aspektId);
private:
// try to fetch a aspektId, that is in selectedRune and in the same subgroup as aspektId
// return 0 when no suitable candidate is found
int getOtherSubgroupMemeber(int aspketId);
QVector<int> selectedRune;
QVector<QVector<int>> subgroups; // might be empty
uint32_t size = 0;
};

View File

@ -29,8 +29,8 @@ signals:
private:
void updateText();
std::string getRuneText(uint32_t id);
std::string getRuneStyleByID(uint32_t id);
QString getRuneText(uint32_t id);
QString getRuneStyleByID(uint32_t id);
Ui::RuneDisplay *ui;

65
include/runeeditor.h Normal file
View File

@ -0,0 +1,65 @@
#pragma once
#include <vector>
#include <QDialog>
#include <QVector>
#include "runeaspekt.h"
#include "runepage.h"
#include "runestyle.h"
namespace Ui {
class RuneEditor;
}
class ClientAPI;
class RuneAspektButton;
class RuneAspektButtonGroup;
class QGridLayout;
class RuneEditor : public QDialog {
Q_OBJECT
public:
explicit RuneEditor(QWidget* parent = nullptr);
~RuneEditor();
void setClient(ClientAPI& client);
void setRunepage(const ::RunePage& rp);
void selectStyle(uint32_t id);
void selectSubStyle(uint32_t id);
void clearLayout(QLayout* layout);
void setName(QString text);
QString getName() const;
const RunePage& getRunepage();
signals:
void selectionChanged();
void selectPrimary(int aspektId);
void selectSecondary(int aspektId);
private:
const RuneStyle* getRuneStyle(uint32_t id) const;
RuneAspektButton* createStyleButton(const RuneStyle& rs, bool selected);
RuneAspektButton* createAspektButton(uint32_t perk);
RuneAspektButton* createButtonFromResource(QString resource);
void fillRuneStyle(QGridLayout* target, const RuneStyle& rs);
QString fixString(QString text);
Ui::RuneEditor* ui;
ClientAPI* client = nullptr;
::RunePage runepage;
std::vector<RuneAspekt> aspekts;
std::vector<RuneStyle> styles;
// 0 = keystone, 1-3 = main runes, 4 = sub runes (2), 5-7 = stats
QVector<RuneAspektButtonGroup*> groups;
};

53
include/runemanager.h Normal file
View File

@ -0,0 +1,53 @@
#pragma once
#include <memory>
#include <QWidget>
#include "config.h"
#include "runeaspekt.h"
#include "runestyle.h"
namespace Ui {
class RuneManager;
}
class ClientAPI;
class DataDragon;
class QListWidgetItem;
class QTimer;
class RuneManager : public QWidget {
Q_OBJECT
public:
explicit RuneManager(QWidget* parent = nullptr);
~RuneManager();
void setConfig(Config& config);
void setDataDragon(DataDragon& dd);
private slots:
void loadRunes();
void setRunesEnabled(bool enabled);
void saveRunePageClient(int id, QString name, const RunePage& rp);
void saveRunePageAA(int id, QString name, const RunePage& rp);
void deleteRunepageClient(int id);
void deleteRunepageAA(int id);
void autoSyncToggled();
private:
void syncRunes();
void reloadAARunes();
Ui::RuneManager* ui;
std::shared_ptr<ClientAPI> client;
Config* config = nullptr;
QTimer* initialLoadTimer = nullptr;
std::vector<RuneAspekt> runeInfo;
std::vector<RuneStyle> runeStyles;
};

View File

@ -4,6 +4,8 @@
#include <ostream>
#include <vector>
#include <QDebug>
#include <QJsonObject>
// represents a runepage
struct RunePage {
public:
@ -11,9 +13,14 @@ public:
uint32_t secondaryStyle = 0;
std::vector<uint32_t> selectedAspects; // all selected aspekts (should be exactly 9)
RunePage();
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)
operator QJsonObject() const;
RunePage(const QJsonObject& obj);
};
std::ostream& operator<<(std::ostream&, const RunePage&);
QDebug operator<<(QDebug, const RunePage&);

73
include/runepagelist.h Normal file
View File

@ -0,0 +1,73 @@
#pragma once
#include <vector>
#include <QListWidget>
#include "clientapi.h"
#include "config.h"
#include "datadragon.h"
#include "runeaspekt.h"
#include "runestyle.h"
namespace Ui {
class RunePageList;
}
class DropEvent;
class ClientAPI;
class RunePageList : public QListWidget {
Q_OBJECT
public:
static const uint32_t RoleId = Qt::UserRole;
static const uint32_t RolePointer = Qt::UserRole + 1;
explicit RunePageList(QWidget* parent = nullptr);
~RunePageList();
constexpr void setIsClient(bool b) { isClient = b; }
constexpr void setClient(ClientAPI& client) { this->client = &client; }
constexpr void setOther(QListWidget* other) { this->other = other; }
constexpr void setDataDragon(DataDragon& dd) { this->dd = &dd; }
void loadRunePages(const std::vector<ClientAPI::RunePage>& pages);
void loadRunePages(const std::vector<std::shared_ptr<Config::RunePageConfig>>& pages);
void setRuneInfos(const std::vector<RuneAspekt>& runeInfo, const std::vector<RuneStyle>& runeStyles);
signals:
void runepageChanged(int id, QString name, const RunePage& rp);
void runepageDeleted(int id);
protected:
virtual void dropEvent(QDropEvent* event) override;
private slots:
void itemChangedCallback(QListWidgetItem* item);
void openContextMenu(const QPoint&);
void deleteCurrentItem();
void editCurrentItem();
void duplicateCurrentItem();
void exportCurrentItem();
void importItem();
private:
void clearItems();
void addRunepageItem(QString name, int id, const ::RunePage& rp, bool isCurrent = false);
const DataDragon::ChampData& findChamp(const QString& name);
QString getRuneDescription(const ::RunePage& runepage);
QString getRuneText(uint32_t id);
QString getRuneStyleByID(uint32_t id);
const std::vector<RuneAspekt>* runeInfo = nullptr;
const std::vector<RuneStyle>* runeStyles = nullptr;
Ui::RunePageList* ui;
QListWidget* other = nullptr;
DataDragon* dd = nullptr;
ClientAPI* client = nullptr;
bool isClient;
};

View File

@ -2,15 +2,30 @@
#include <cstdint>
#include <string>
#include <vector>
// fwd.
class QJsonObject;
struct RuneStyleSlot {
std::vector<int> perks;
QString type;
RuneStyleSlot();
RuneStyleSlot(const QJsonObject& json);
};
struct RuneStyle {
uint32_t id;
std::string name;
std::string iconPath;
std::string tooltip;
QString name;
QString iconPath;
QString tooltip;
std::vector<int> allowedSubStyles;
QString idName;
std::vector<RuneStyleSlot> runeSlots;
RuneStyle();
explicit RuneStyle(const QJsonObject& json);

View File

@ -25,7 +25,7 @@ public:
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 setChamps(LolAutoAccept::State s, const std::vector<QString>&);
void setState(LolAutoAccept::State s, bool b);
Position getPosition() const;

View File

@ -27,13 +27,13 @@ public:
void setState(bool);
struct SelectedChamp {
SelectedChamp(std::string name, uint32_t id);
std::string name;
SelectedChamp(QString name, uint32_t id);
QString name;
uint32_t id;
};
std::vector<SelectedChamp> getChampions() const;
void setChampions(const std::vector<std::string>& champs);
void setChampions(const std::vector<QString>& champs);
void setDataDragon(DataDragon* dd);
void addChamp(const DataDragon::ChampData& cd, QPixmap icon);
@ -52,7 +52,7 @@ signals:
private:
// delete all items
void resolveAndAddChamp(const std::string& name, bool emitchange = false);
void resolveAndAddChamp(const QString& name, bool emitchange = false);
void clear();
void updateEnabled();

View File

@ -7,6 +7,11 @@ CONFIG += c++17
# debugging
CONFIG += debug
MOC_DIR = build/generated/
UI_DIR = build/ui/
RCC_DIR = build/rcc/
OBJECTS_DIR = build/objects/
unix:LIBS += -lcurl -pthread -lrt
# The following define makes your compiler emit warnings if you use
@ -14,12 +19,15 @@ unix:LIBS += -lcurl -pthread -lrt
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
DEFINES += LOG_ENABLEQT=1
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
DEFINES += LOLAA_VERSION=\\\"0.0.7\\\"
# parameters: var, prepend, append
defineReplace(prependAll) {
for(a,$$1):result += $$2$${a}$$3
@ -35,18 +43,25 @@ SOURCES += \
src/clientaccess.cpp \
src/clientapi_json.cpp \
src/clientapi.cpp \
src/clipboardpopup.cpp \
src/config.cpp \
src/datadragon.cpp \
src/datadragonimagecache.cpp \
src/files.cpp \
src/json.cpp \
src/loadingwindow.cpp \
src/lolautoaccept.cpp \
src/main.cpp \
src/mainwindow.cpp \
src/memoryimagecache.cpp \
src/restclient.cpp \
src/runeaspektbutton.cpp \
src/runeaspektbuttongroup.cpp \
src/runedisplay.cpp \
src/runeeditor.cpp \
src/runemanager.cpp \
src/runepage.cpp \
src/runepagelist.cpp \
src/settingstab.cpp \
src/stagesettings.cpp \
thirdparty/Log/Log.cpp
@ -63,51 +78,53 @@ HEADERS += \
include/champrow.h \
include/clientaccess.h \
include/clientapi.h \
include/clipboardpopup.h \
include/config.h \
include/datadragon.h \
include/datadragonimagecache.h \
include/defer.h \
include/files.h \
include/json.h \
include/loadingwindow.h \
include/lolautoaccept.h \
include/mainwindow.h \
include/memoryimagecache.h \
include/restclient.h \
include/runeaspektbutton.h \
include/runeaspektbuttongroup.h \
include/runedisplay.h \
include/runeeditor.h \
include/runemanager.h \
include/runepage.h \
include/runepagelist.h \
include/settingstab.h \
include/stagesettings.h \
thirdparty/Log/Log.h
MOC_DIR = build/generated/
UI_DIR = ui/
OBJECTS_DIR = build/
FORMS += \
ui/championsearch.ui \
ui/clipboardpopup.ui \
ui/loadingwindow.ui \
ui/mainwindow.ui \
ui/runeaspektbutton.ui \
ui/runedisplay.ui \
ui/runeeditor.ui \
ui/runemanager.ui \
ui/runepagelist.ui \
ui/settingstab.ui \
ui/stagesettings.ui
INCLUDEPATH += $$PWD/include/ \
$$PWD/thirdparty/Log/
#TRANSLATIONS += \
# ts/de_DE.ts \
# ts/en.ts
# translations
LANGUAGES = de_DE en
CONFIG += lrelease embed_translations
TRANSLATIONS = $$prependAll(LANGUAGES, $$PWD/resources/ts/, .ts)
TRANSLATIONSQM = $$prependAll(LANGUAGES, $$PWD/resources/ts/, .qm)
makelang.commands = lrelease $$_PRO_FILE_
updatelang.commands = lupdate $$_PRO_FILE_
QMAKE_EXTRA_TARGETS += makelang updatelang
PRE_TARGETDEPS += makelang
QMAKE_CLEAN += $$TRANSLATIONSQM
QMAKE_EXTRA_TARGETS += updatelang
# build AppImage
unix {
@ -119,7 +136,6 @@ unix {
appimg.depends = linuxdeploy-x86_64.AppImage $${TARGET} resources/lolautoaccept.png
appimg.commands = rm -rf AppDir ; \
mkdir -p AppDir/ts ; \
cp ./resources/ts/*.qm ./AppDir/ts ; \
./linuxdeploy-x86_64.AppImage --appdir=AppDir -e lolautoaccept -i resources/lolautoaccept.png -d resources/lolautoaccept.desktop --output appimage
QMAKE_EXTRA_TARGETS += appimg linuxdeploy-x86_64.AppImage resources/lolautoaccept.png

5
resources/icons/bot.svg Normal file
View File

@ -0,0 +1,5 @@
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<path d="M27.333 27.333H5.196l4.406-4.786h12.945V9.602l4.786-4.406v22.137z"></path>
<path fill-opacity=".4"
d="M4 4h20.94l-5.041 4.188H8.187v11.628l-4.188 4.526V4zm14.359 14.359h-5.983v-5.983h5.983v5.983z"></path>
</svg>

After

Width:  |  Height:  |  Size: 308 B

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="1024"
height="1024"
viewBox="0 0 270.93333 270.93334"
version="1.1"
id="svg8"
sodipodi:docname="delete.svg"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.7"
inkscape:cx="451.15206"
inkscape:cy="659.53498"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:pagecheckerboard="true"
borderlayer="true"
inkscape:window-width="2528"
inkscape:window-height="1381"
inkscape:window-x="1952"
inkscape:window-y="28"
inkscape:window-maximized="1"
showguides="false" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-26.06665)">
<rect
style="opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#fffffb;stroke-width:16.93333244;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="rect1013"
width="142.55424"
height="161.20285"
x="64.189545"
y="100.63498" />
<rect
style="opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#fffffb;stroke-width:16.93333435;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="rect1015"
width="179.60214"
height="20.944307"
x="45.665596"
y="79.216049"
ry="6.992558"
rx="0" />
<rect
style="opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#fffffb;stroke-width:16.93333244;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="rect1017"
width="30.616072"
height="17.764881"
x="120.15863"
y="61.228806"
ry="6.9925671" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="1024"
height="1024"
viewBox="0 0 270.93333 270.93334"
version="1.1"
id="svg8"
sodipodi:docname="duplicate.svg"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.49497475"
inkscape:cx="-137.33323"
inkscape:cy="973.74201"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:pagecheckerboard="true"
borderlayer="true"
inkscape:window-width="2528"
inkscape:window-height="1381"
inkscape:window-x="1952"
inkscape:window-y="28"
inkscape:window-maximized="1"
showguides="false" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-26.06665)">
<rect
style="opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:16.93333435;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="rect865-3"
width="127.58046"
height="172.03047"
x="112.739"
y="98.764053"
inkscape:label="new" />
<path
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:64;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m 130.59961,81.945312 c -17.66933,0.0061 -31.99042,14.330669 -31.992188,31.999998 v 650.19727 c 0.0018,17.66933 14.322858,31.99392 31.992188,32 H 362.0957 v -64 H 162.60156 V 145.94727 h 418.19727 v 64.8125 h 64.00195 v -96.81446 c -0.002,-17.672379 -14.32762,-31.99823 -32,-31.999998 z"
transform="matrix(0.26458333,0,0,0.26458333,0,26.06665)"
id="rect1910"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccccccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.8 KiB

66
resources/icons/edit.svg Normal file
View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="1024"
height="1024"
viewBox="0 0 270.93333 270.93334"
version="1.1"
id="svg8"
sodipodi:docname="edit.svg"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.49497475"
inkscape:cx="267.73794"
inkscape:cy="973.74201"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:pagecheckerboard="true"
borderlayer="true"
inkscape:window-width="2528"
inkscape:window-height="1381"
inkscape:window-x="1952"
inkscape:window-y="28"
inkscape:window-maximized="1"
showguides="false" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-26.06665)">
<path
style="opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="M 191.78519,59.101843 46.234389,204.65213 92.347853,250.76559 237.89814,105.21479 Z M 42.32145,212.71572 l -9.286255,51.24907 51.250619,-9.28677 z"
id="rect838"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="1024"
height="1024"
viewBox="0 0 270.93333 270.93334"
version="1.1"
id="svg8"
sodipodi:docname="export.svg"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.49497475"
inkscape:cx="89.911358"
inkscape:cy="1128.7865"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:pagecheckerboard="true"
borderlayer="true"
inkscape:window-width="2528"
inkscape:window-height="1381"
inkscape:window-x="1952"
inkscape:window-y="28"
inkscape:window-maximized="1"
showguides="false" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-26.06665)">
<path
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:36.93648148;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m 43.435547,231.03711 c -10.201227,-3.4e-4 -18.471041,8.26947 -18.470703,18.4707 v 731.05664 c -3.44e-4,10.20123 8.269472,18.47105 18.470703,18.47071 H 774.49219 c 10.20123,3.4e-4 18.47104,-8.26948 18.4707,-18.47071 V 249.50781 c 3.4e-4,-10.20123 -8.26947,-18.47104 -18.4707,-18.4707 h -52.1543 c -3.3615,2.96416 -6.64075,6.0031 -9.81641,9.13867 -8.67079,8.56135 -16.71538,17.79803 -24.0996,27.79297 h 67.60937 V 962.0957 H 61.904297 V 267.96875 H 613.25586 c 6.92944,-13.03955 14.61015,-25.35573 23.02734,-36.93164 z"
transform="matrix(0.26458333,0,0,0.26458333,0,26.06665)"
id="rect909"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:8.46666718;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 159.95132,132.72143 C 165.7499,90.045345 191.29939,68.478702 229.47904,60.410947"
id="path911"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#fffffb;stroke-width:8.46666718;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 221.23258,38.481818 42.41883,18.747657 -41.87698,27.147964"
id="path913"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccc"
inkscape:label="ArrowTop" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="1024"
height="1024"
viewBox="0 0 270.93333 270.93334"
version="1.1"
id="svg8"
sodipodi:docname="import.svg"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.49497475"
inkscape:cx="-490.64446"
inkscape:cy="895.44453"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:pagecheckerboard="true"
borderlayer="true"
inkscape:window-width="2528"
inkscape:window-height="1381"
inkscape:window-x="1952"
inkscape:window-y="28"
inkscape:window-maximized="1"
showguides="false" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-26.06665)">
<path
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:36.93648148;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m 43.435547,231.03711 a 18.470088,18.470088 0 0 0 -18.470703,18.4707 v 731.05664 a 18.470088,18.470088 0 0 0 18.470703,18.47071 H 774.49219 a 18.470088,18.470088 0 0 0 18.4707,-18.47071 V 249.50781 a 18.470088,18.470088 0 0 0 -18.4707,-18.4707 h -18.48047 c -14.21343,10.60781 -27.51005,22.92882 -39.94922,36.93164 h 39.96875 V 962.0957 H 61.904297 V 267.96875 H 635.49805 c 8.74524,-13.01432 18.04176,-25.34765 27.92187,-36.93164 z"
transform="matrix(0.26458333,0,0,0.26458333,0,26.06665)"
id="rect909"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:8.46666718;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 253.90605,66.613651 C 211.10887,61.789428 183.94424,81.282492 166.77618,116.32578"
id="path911"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#fffffb;stroke-width:8.46666718;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 147.53278,102.9623 7.79389,45.71747 36.57285,-33.95761"
id="path913"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccc"
inkscape:label="ArrowTop" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.3 KiB

5
resources/icons/jgl.svg Normal file
View File

@ -0,0 +1,5 @@
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<path
d="m16.21 29.333-7.875-7.955A18.22 18.22 0 0 0 4 10.09c6.93 2.606 8.04 7.818 8.04 7.818 1.245-6.091-3.39-15.242-3.39-15.242 13.305 16.652 7.56 26.667 7.56 26.667zM16.57 13a37.966 37.966 0 0 1 6.765-10.333 49.874 49.874 0 0 0-4.365 15.5s-1.02-3.591-2.4-5.167zM28 9.879c-9.315 5.576-8.325 15.515-8.325 15.515l4.185-4.258C23.71 13.03 28 9.878 28 9.878z">
</path>
</svg>

After

Width:  |  Height:  |  Size: 460 B

6
resources/icons/mid.svg Normal file
View File

@ -0,0 +1,6 @@
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<path d="M5.333 26.667v-4.364l16.97-16.97h4.364v4.364l-16.97 16.97H5.333z"></path>
<path fill-opacity=".4"
d="m19.394 5.333-3.879 3.879H9.212v6.303l-3.879 3.879V5.333h14.061zm-6.788 21.334 3.879-3.879h6.303v-6.303l3.879-3.879v14.061H12.606z">
</path>
</svg>

After

Width:  |  Height:  |  Size: 346 B

5
resources/icons/sup.svg Normal file
View File

@ -0,0 +1,5 @@
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<path
d="M19.03 4h-6.061l-1.061 1.417 4.091 5.037 4.091-5.037L19.029 4zm-7.878 4.88H2.667c1.167 1.144 2.514 2.221 3.939 2.991.572.185 1.068.313 1.667.315h2.273l-2.424 2.991 3.939 1.889 1.515-5.667-2.424-2.519zm9.696 0h8.485c-1.168 1.143-2.515 2.222-3.939 2.991-.572.185-1.068.313-1.667.315h-2.273l2.424 2.991-3.939 1.889-1.515-5.667 2.424-2.519zm-1.666 15.268-2.424-12.593a.863.863 0 0 1-.758.63.87.87 0 0 1-.758-.63l-2.424 12.593L16 26.667l3.182-2.519z">
</path>
</svg>

After

Width:  |  Height:  |  Size: 558 B

6
resources/icons/top.svg Normal file
View File

@ -0,0 +1,6 @@
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<path d="M4 4h22.137l-4.406 4.786H8.786v12.945L4 26.137V4z"></path>
<path fill-opacity=".4"
d="M27.333 27.333H6.393l5.041-4.188h11.712V10.918l4.188-4.526v20.94zM12.974 12.974h5.983v5.983h-5.983v-5.983z">
</path>
</svg>

After

Width:  |  Height:  |  Size: 307 B

View File

@ -1,8 +1,16 @@
<RCC>
<qresource prefix="/">
<file>ts/de_DE.qm</file>
<file>ts/de_DE.ts</file>
<file>lolautoaccept.png</file>
<file>lolautoaccept.svg</file>
<file>icons/top.svg</file>
<file>icons/sup.svg</file>
<file>icons/mid.svg</file>
<file>icons/jgl.svg</file>
<file>icons/bot.svg</file>
<file>icons/delete.svg</file>
<file>icons/duplicate.svg</file>
<file>icons/edit.svg</file>
<file>icons/export.svg</file>
<file>icons/import.svg</file>
</qresource>
</RCC>

View File

@ -14,6 +14,24 @@
<translation>Champion:</translation>
</message>
</context>
<context>
<name>ClipboardPopup</name>
<message>
<location filename="../../ui/clipboardpopup.ui" line="14"/>
<source>Clipboard Text</source>
<translation>Zwischenablage</translation>
</message>
<message>
<location filename="../../ui/clipboardpopup.ui" line="30"/>
<source>Copy To Clipboard</source>
<translation>In Zwischenablage kopieren</translation>
</message>
<message>
<location filename="../../src/clipboardpopup.cpp" line="11"/>
<source>Paste here</source>
<translation>Hier einfügen</translation>
</message>
</context>
<context>
<name>MainWindow</name>
<message>
@ -22,89 +40,116 @@
<translation>LoL-Auto-Accept</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="45"/>
<location filename="../../ui/mainwindow.ui" line="99"/>
<source>Mainswitch</source>
<translation>Hauptschalter</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="52"/>
<location filename="../../ui/mainwindow.ui" line="119"/>
<source>Enable LoL-Auto-Accept</source>
<translation>Spiel automatisch annehmen</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="59"/>
<location filename="../../ui/mainwindow.ui" line="106"/>
<source>Spam &quot;smite&quot; in the chat when there is not exactly 1 player with smite equiped in champ select</source>
<translation>Wenn nicht genau 1 Spieler Smite ausgewählt hat, wird &quot;smite&quot; in den Chat gespammt</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="62"/>
<location filename="../../ui/mainwindow.ui" line="40"/>
<source>Auto Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="64"/>
<source>Write a Text as soon as you are in a champ select lobby.</source>
<translation>Einen Text schreiben, sobald du in der Champion Auswahl bist.</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="67"/>
<source>Auto Write</source>
<translation>Automatisch Schreiben</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="96"/>
<source>This controls the connection to the LoL client. As long as this is off, no interactions with the LoL client take place.</source>
<translation>Dies kontrolliert die Verbindung zum LoL Client. Solange dies aus ist, wird nicht mit dem LoL Client interagiert.</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="109"/>
<source>Enable Smite Warning</source>
<translation>Smite Warnung</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="91"/>
<source>Developed by MrBesen</source>
<translation type="vanished">Entwickelt von MrBesen</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="156"/>
<source>autowriteText</source>
<translation>Zu schreibender Text</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="182"/>
<source>This Tab is used, when you are in a gamemode with no fixed roles</source>
<translation>Dieser Tab wird verwendet, wenn der Gamemode keine festen Rollen hat</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="97"/>
<location filename="../../ui/mainwindow.ui" line="188"/>
<source>Default</source>
<translation>Default</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="105"/>
<location filename="../../ui/mainwindow.ui" line="200"/>
<source>Top</source>
<translation>Top</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="113"/>
<location filename="../../ui/mainwindow.ui" line="212"/>
<source>Jungle</source>
<translation>Jungle</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="121"/>
<location filename="../../ui/mainwindow.ui" line="224"/>
<source>Middle</source>
<translation></translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="129"/>
<location filename="../../ui/mainwindow.ui" line="236"/>
<source>Bottom</source>
<translation></translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="137"/>
<location filename="../../ui/mainwindow.ui" line="248"/>
<source>Support</source>
<translation></translation>
<translation>Support</translation>
</message>
<message>
<source>Pick</source>
<translation type="vanished">Pick</translation>
<location filename="../../ui/mainwindow.ui" line="257"/>
<source>Runes</source>
<translation>Runen</translation>
</message>
<message>
<source>Champion:</source>
<translation type="vanished">Champion:</translation>
<location filename="../../ui/mainwindow.ui" line="77"/>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Developed by MrBesen&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://lolautoacceptor.mrbesen.de/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;Webseite&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Version: %1&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Entwickelt von MrBesen&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://lolautoacceptor.mrbesen.de/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;Webseite&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Version: %1&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
<source>Ban</source>
<translation type="vanished">Bannen</translation>
</message>
<message>
<location filename="../../src/mainwindow.cpp" line="56"/>
<location filename="../../src/mainwindow.cpp" line="86"/>
<source>League of Legends Client not found!</source>
<translation>League of Legends Client nicht gefunden!</translation>
</message>
<message>
<location filename="../../src/mainwindow.cpp" line="66"/>
<location filename="../../src/mainwindow.cpp" line="184"/>
<source>Auto-Acceptor started!</source>
<translation></translation>
</message>
<message>
<location filename="../../src/mainwindow.cpp" line="70"/>
<location filename="../../src/mainwindow.cpp" line="181"/>
<source>Auto-Acceptor stoped!</source>
<translation>Auto Acceptor gestoppt!</translation>
</message>
<message>
<location filename="../../src/mainwindow.cpp" line="118"/>
<location filename="../../src/mainwindow.cpp" line="187"/>
<source>Auto-Acceptor failed!</source>
<translation>Auto-Acceptor fehlgeschlagen!</translation>
</message>
@ -141,6 +186,75 @@ ID: %4</translation>
<translation>Runen Anwenden</translation>
</message>
</context>
<context>
<name>RuneEditor</name>
<message>
<location filename="../../ui/runeeditor.ui" line="14"/>
<source>Runepage Editor</source>
<translation>Runenseiten Editor</translation>
</message>
</context>
<context>
<name>RuneManager</name>
<message>
<location filename="../../ui/runemanager.ui" line="17"/>
<source>Runes in the Client</source>
<translation>Runen im Client</translation>
</message>
<message>
<location filename="../../ui/runemanager.ui" line="24"/>
<source>Runes in the Autoacceptor</source>
<translation>Runen im Autoacceptor</translation>
</message>
<message>
<location filename="../../ui/runemanager.ui" line="51"/>
<source>Reload</source>
<translation>Neuladen</translation>
</message>
<message>
<location filename="../../ui/runemanager.ui" line="62"/>
<source>Runes from the client get copied to the autoacceptor automatically.</source>
<translation>Runen vom Client werden automatisch in den Autoacceptor kopiert.</translation>
</message>
<message>
<location filename="../../ui/runemanager.ui" line="65"/>
<source>Auto Copy Runes</source>
<translation>Auto Runen kopieren</translation>
</message>
</context>
<context>
<name>RunePageList</name>
<message>
<location filename="../../src/runepagelist.cpp" line="80"/>
<source>Edit (Beta)</source>
<translation>Bearbeiten (Beta)</translation>
</message>
<message>
<location filename="../../src/runepagelist.cpp" line="81"/>
<source>Duplicate</source>
<translation>Dublizieren</translation>
</message>
<message>
<location filename="../../src/runepagelist.cpp" line="82"/>
<source>Export</source>
<translation>Exportieren</translation>
</message>
<message>
<location filename="../../src/runepagelist.cpp" line="83"/>
<source>Import</source>
<translation>Importerien</translation>
</message>
<message>
<location filename="../../src/runepagelist.cpp" line="84"/>
<source>Delete</source>
<translation>Löschen</translation>
</message>
<message>
<location filename="../../src/runepagelist.cpp" line="235"/>
<source>with</source>
<translation>mit</translation>
</message>
</context>
<context>
<name>SettingsTab</name>
<message>
@ -161,7 +275,7 @@ ID: %4</translation>
<translation type="vanished">Champion:</translation>
</message>
<message>
<location filename="../../src/stagesettings.cpp" line="25"/>
<location filename="../../src/stagesettings.cpp" line="29"/>
<source>Enable %1</source>
<translation>Aktiviere %1</translation>
</message>
@ -180,12 +294,12 @@ Titel: %3
ID: %4</translation>
</message>
<message>
<location filename="../../ui/stagesettings.ui" line="74"/>
<location filename="../../ui/stagesettings.ui" line="77"/>
<source>Add Champion</source>
<translation>Champion hinzufügen</translation>
</message>
<message>
<location filename="../../ui/stagesettings.ui" line="87"/>
<location filename="../../ui/stagesettings.ui" line="90"/>
<source>Remove Champion</source>
<translation>Champion entfernen</translation>
</message>

View File

@ -14,6 +14,24 @@
<translation>Champion:</translation>
</message>
</context>
<context>
<name>ClipboardPopup</name>
<message>
<location filename="../../ui/clipboardpopup.ui" line="14"/>
<source>Clipboard Text</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../ui/clipboardpopup.ui" line="30"/>
<source>Copy To Clipboard</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/clipboardpopup.cpp" line="11"/>
<source>Paste here</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MainWindow</name>
<message>
@ -22,89 +40,116 @@
<translation>LoL-Auto-Accept</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="45"/>
<location filename="../../ui/mainwindow.ui" line="99"/>
<source>Mainswitch</source>
<translation>Mainswitch</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="52"/>
<location filename="../../ui/mainwindow.ui" line="119"/>
<source>Enable LoL-Auto-Accept</source>
<translation>Automatically accept game</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="59"/>
<location filename="../../ui/mainwindow.ui" line="106"/>
<source>Spam &quot;smite&quot; in the chat when there is not exactly 1 player with smite equiped in champ select</source>
<translation>Spam &quot;smite&quot; in the chat when there is not exactly 1 player with smite equiped in champ select</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="62"/>
<location filename="../../ui/mainwindow.ui" line="40"/>
<source>Auto Accept</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="64"/>
<source>Write a Text as soon as you are in a champ select lobby.</source>
<translation>Write a Text as soon as you are in the champ select lobby.</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="67"/>
<source>Auto Write</source>
<translation>Auto write</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="96"/>
<source>This controls the connection to the LoL client. As long as this is off, no interactions with the LoL client take place.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="109"/>
<source>Enable Smite Warning</source>
<translation>Enable Smite Warning</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="91"/>
<source>Developed by MrBesen</source>
<translation type="vanished">Developed by MrBesen</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="156"/>
<source>autowriteText</source>
<translation>Text to autowrite</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="182"/>
<source>This Tab is used, when you are in a gamemode with no fixed roles</source>
<translation>This Tab is used, when you are in a gamemode with no fixed roles</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="97"/>
<location filename="../../ui/mainwindow.ui" line="188"/>
<source>Default</source>
<translation>Default</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="105"/>
<location filename="../../ui/mainwindow.ui" line="200"/>
<source>Top</source>
<translation>Top</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="113"/>
<location filename="../../ui/mainwindow.ui" line="212"/>
<source>Jungle</source>
<translation>Jungle</translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="121"/>
<location filename="../../ui/mainwindow.ui" line="224"/>
<source>Middle</source>
<translation></translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="129"/>
<location filename="../../ui/mainwindow.ui" line="236"/>
<source>Bottom</source>
<translation></translation>
</message>
<message>
<location filename="../../ui/mainwindow.ui" line="137"/>
<location filename="../../ui/mainwindow.ui" line="248"/>
<source>Support</source>
<translation></translation>
<translation>Support</translation>
</message>
<message>
<source>Pick</source>
<translation type="vanished">Pick</translation>
<location filename="../../ui/mainwindow.ui" line="257"/>
<source>Runes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Champion:</source>
<translation type="vanished">Champion:</translation>
<location filename="../../ui/mainwindow.ui" line="77"/>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Developed by MrBesen&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://lolautoacceptor.mrbesen.de/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;Webseite&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Version: %1&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Developed by MrBesen&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://lolautoacceptor.mrbesen.de/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;Webseite&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Version: %1&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
<source>Ban</source>
<translation type="vanished">Ban</translation>
</message>
<message>
<location filename="../../src/mainwindow.cpp" line="56"/>
<location filename="../../src/mainwindow.cpp" line="86"/>
<source>League of Legends Client not found!</source>
<translation>League of Legends Client not found!</translation>
</message>
<message>
<location filename="../../src/mainwindow.cpp" line="66"/>
<location filename="../../src/mainwindow.cpp" line="184"/>
<source>Auto-Acceptor started!</source>
<translation>Auto-Acceptor started!</translation>
</message>
<message>
<location filename="../../src/mainwindow.cpp" line="70"/>
<location filename="../../src/mainwindow.cpp" line="181"/>
<source>Auto-Acceptor stoped!</source>
<translation>Auto-Acceptor stopped!</translation>
</message>
<message>
<location filename="../../src/mainwindow.cpp" line="118"/>
<location filename="../../src/mainwindow.cpp" line="187"/>
<source>Auto-Acceptor failed!</source>
<translation>Auto-Acceptor failed!</translation>
</message>
@ -141,6 +186,75 @@ ID: %4</translation>
<translation>Apply Runes</translation>
</message>
</context>
<context>
<name>RuneEditor</name>
<message>
<location filename="../../ui/runeeditor.ui" line="14"/>
<source>Runepage Editor</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RuneManager</name>
<message>
<location filename="../../ui/runemanager.ui" line="17"/>
<source>Runes in the Client</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../ui/runemanager.ui" line="24"/>
<source>Runes in the Autoacceptor</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../ui/runemanager.ui" line="51"/>
<source>Reload</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../ui/runemanager.ui" line="62"/>
<source>Runes from the client get copied to the autoacceptor automatically.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../ui/runemanager.ui" line="65"/>
<source>Auto Copy Runes</source>
<translation>Auto copy Runes</translation>
</message>
</context>
<context>
<name>RunePageList</name>
<message>
<location filename="../../src/runepagelist.cpp" line="80"/>
<source>Edit (Beta)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/runepagelist.cpp" line="81"/>
<source>Duplicate</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/runepagelist.cpp" line="82"/>
<source>Export</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/runepagelist.cpp" line="83"/>
<source>Import</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/runepagelist.cpp" line="84"/>
<source>Delete</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/runepagelist.cpp" line="235"/>
<source>with</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsTab</name>
<message>
@ -161,7 +275,7 @@ ID: %4</translation>
<translation type="vanished">Champion:</translation>
</message>
<message>
<location filename="../../src/stagesettings.cpp" line="25"/>
<location filename="../../src/stagesettings.cpp" line="29"/>
<source>Enable %1</source>
<translation>Enable %1</translation>
</message>
@ -180,12 +294,12 @@ Title: %3
ID: %4</translation>
</message>
<message>
<location filename="../../ui/stagesettings.ui" line="74"/>
<location filename="../../ui/stagesettings.ui" line="77"/>
<source>Add Champion</source>
<translation>Add Champion</translation>
</message>
<message>
<location filename="../../ui/stagesettings.ui" line="87"/>
<location filename="../../ui/stagesettings.ui" line="90"/>
<source>Remove Champion</source>
<translation>Remove Champion</translation>
</message>

View File

@ -12,7 +12,7 @@
// query=query ChampionBuilds($championId:Int!,$queue:Queue!,$role:Role,$opponentChampionId:Int,$key:ChampionBuildKey){championBuildStats(championId:$championId,queue:$queue,role:$role,opponentChampionId:$opponentChampionId,key:$key){championId opponentChampionId queue role builds{completedItems{games index averageIndex itemId wins}games mythicId mythicAverageIndex primaryRune runes{games index runeId wins treeId}skillOrders{games skillOrder wins}startingItems{games startingItemIds wins}summonerSpells{games summonerSpellIds wins}wins}}}
// &variables={"championId":25,"role":"SUPPORT","queue":"RANKED_SOLO_5X5","opponentChampionId":null,"key":"PUBLIC"}
static const std::string POSITIONNAMES[] = {"INVALID", "TOP", "JUNGLE", "MIDDLE", "BOTTOM", "SUPPORT"};
static const QString POSITIONNAMES[] = {"INVALID", "TOP", "JUNGLE", "MIDDLE", "BOTTOM", "SUPPORT"};
BlitzAPI::BlitzAPI() : RestClient("https://league-champion-aggregate.iesdev.com/graphql?") {}
@ -58,7 +58,7 @@ BlitzAPI::ChampionInfo::ChampionInfo(const QJsonObject& json) {
auto runeid = rune["runeId"];
if(runeid.isDouble()) {
runes.at(index+1) = runeid.toDouble();
Log::debug << "found rune: index: " << index << " +1 set to: " << runes.at(index+1);
qDebug() << "found rune: index: " << index << " +1 set to: " << runes.at(index+1);
if(index == 0) {
runepage.primaryStyle = rune["treeId"].toInt();
@ -80,7 +80,7 @@ BlitzAPI::ChampionInfo BlitzAPI::getChampionInfo(uint32_t championID, Position p
vars["championId"] = (int) championID;
if(p != Position::INVALID) {
vars["role"] = QString::fromStdString(POSITIONNAMES[(int) p]);
vars["role"] = POSITIONNAMES[(int) p];
}
vars["queue"] = "RANKED_SOLO_5X5";
@ -91,10 +91,10 @@ BlitzAPI::ChampionInfo BlitzAPI::getChampionInfo(uint32_t championID, Position p
vars["key"] = "PUBLIC"; // ? what does this do?
QJsonDocument jvars(vars);
const std::string variables = jvars.toJson(QJsonDocument::Compact).toStdString();
const std::string query = "query ChampionBuilds($championId:Int!,$queue:Queue!,$role:Role,$opponentChampionId:Int,$key:ChampionBuildKey){championBuildStats(championId:$championId,queue:$queue,role:$role,opponentChampionId:$opponentChampionId,key:$key){championId opponentChampionId queue role builds{completedItems{games index averageIndex itemId wins}games mythicId mythicAverageIndex primaryRune runes{games index runeId wins treeId}skillOrders{games skillOrder wins}startingItems{games startingItemIds wins}summonerSpells{games summonerSpellIds wins}wins}}}";
const std::string requeststr = "query=" + escape(query) + "&variables=" + escape(variables);
Log::debug << "GetChampionInfo requestVariables: " << variables << " requeststr: " << requeststr;
const QString variables = jvars.toJson(QJsonDocument::Compact);
const QString query = "query ChampionBuilds($championId:Int!,$queue:Queue!,$role:Role,$opponentChampionId:Int,$key:ChampionBuildKey){championBuildStats(championId:$championId,queue:$queue,role:$role,opponentChampionId:$opponentChampionId,key:$key){championId opponentChampionId queue role builds{completedItems{games index averageIndex itemId wins}games mythicId mythicAverageIndex primaryRune runes{games index runeId wins treeId}skillOrders{games skillOrder wins}startingItems{games startingItemIds wins}summonerSpells{games summonerSpellIds wins}wins}}}";
const QString requeststr = "query=" + escape(query) + "&variables=" + escape(variables);
qDebug() << "GetChampionInfo requestVariables: " << variables << " requeststr: " << requeststr;
QJsonDocument doc;
try {
@ -105,11 +105,11 @@ BlitzAPI::ChampionInfo BlitzAPI::getChampionInfo(uint32_t championID, Position p
if(!doc.isObject()) {
// error
Log::error << "could not get ChampionInfo. Returned Response: " << doc.toJson().toStdString();
qCritical() << "could not get ChampionInfo. Returned Response: " << doc.toJson();
return {};
}
Log::debug << "championinfo Response: " << doc.toJson().trimmed().toStdString();
qDebug() << "championinfo Response: " << doc.toJson().trimmed();
QJsonObject obj = doc.object();
QJsonValueRef dataref = obj["data"];

View File

@ -18,17 +18,17 @@ static qint64 ageOfFile(QFile& f) {
return info.lastModified().secsTo(QDateTime::currentDateTime());
}
std::string ChampCache::getVersion() {
QFile versionfile(QString::fromStdString(basefolder + "version"));
QString ChampCache::getVersion() {
QFile versionfile(basefolder + "version");
if(ageOfFile(versionfile) < (qint64) maxage) {
versionfile.open(QFile::ReadOnly);
return versionfile.readAll().toStdString();
return versionfile.readAll();
}
return {}; // empty string
}
QJsonDocument ChampCache::getChamps() {
QFile champsfile(QString::fromStdString(basefolder + "champs.json"));
QFile champsfile(basefolder + "champs.json");
if(ageOfFile(champsfile) < (qint64) maxage) {
champsfile.open(QFile::ReadOnly);
@ -39,16 +39,16 @@ QJsonDocument ChampCache::getChamps() {
return {}; // empty document
}
void ChampCache::saveChamps(QJsonDocument doc, const std::string& version) {
void ChampCache::saveChamps(QJsonDocument doc, const QString& version) {
QByteArray arr = doc.toJson();
QFile champsfile(QString::fromStdString(basefolder + "champs.json"));
QFile champsfile(basefolder + "champs.json");
champsfile.open(QFile::WriteOnly | QFile::Truncate);
champsfile.write(arr);
QFile versionfile(QString::fromStdString(basefolder + "version"));
QFile versionfile(basefolder + "version");
versionfile.open(QFile::WriteOnly | QFile::Truncate);
versionfile.write(version.c_str());
versionfile.write(version.toLocal8Bit());
versionfile.close();
Log::info << "saved Champs and version Cache";
qInfo() << "saved Champs and version Cache";
}

View File

@ -20,10 +20,10 @@ ChampRow* ChampionSearch::getSearchResult() {
}
void ChampionSearch::searchChanged(QString str) {
Log::info << "champion search: " << str.toStdString();
qInfo() << "champion search: " << str;
const std::vector<const DataDragon::ChampData*> champs = dd->getMatchingChamp(str.toStdString());
Log::info << "found " << champs.size() << " champs";
const std::vector<const DataDragon::ChampData*> champs = dd->getMatchingChamp(str);
qInfo() << "found " << champs.size() << " champs";
clear();

View File

@ -7,14 +7,12 @@ ChampRow::~ChampRow() {
}
void ChampRow::setChamp(const DataDragon::ChampData& cd, QPixmap icon) {
setText(QString::fromStdString(cd.name));
setText(cd.name);
champid = cd.key;
this->icon = icon;
setIcon(QIcon(icon));
#define QS(A) arg(QString::fromStdString(A))
setToolTip(QWidget::tr("Champion: %1\nType: %2\nTitle: %3\nID: %4").QS(cd.name).QS(cd.partype).QS(cd.title).arg(cd.key));
#undef QS
setToolTip(QWidget::tr("Champion: %1\nType: %2\nTitle: %3\nID: %4").arg(cd.name).arg(cd.partype).arg(cd.title).arg(cd.key));
}
QString ChampRow::getChamp() const {

View File

@ -2,39 +2,39 @@
#include <fstream>
#include <iomanip>
#include <Log.h>
#include <QDebug>
#include <QStringList>
ClientAccess::ClientAccess() {}
ClientAccess::ClientAccess(const std::string& token, uint16_t port) : authcode(token), port(port) {}
ClientAccess::ClientAccess(const QString& token, uint16_t port) : authcode(token), port(port) {}
std::shared_ptr<ClientAccess> createFromLockfile(std::istream& lockfile) {
std::vector<std::string> parts;
std::string content;
while(std::getline(lockfile, content, ':')) {
parts.push_back(content);
}
std::getline(lockfile, content);
QStringList parts = QString::fromStdString(content).split(':');
if(parts.size() != 5) {
Log::error << "lockfile contained " << parts.size() << " parts, expected 5";
qCritical() << "lockfile contained " << parts.size() << " parts, expected 5";
return {};
}
const std::string portstr = parts.at(2);
const std::string token = parts.at(3);
const QString portstr = parts.at(2);
const QString token = parts.at(3);
// try to parse port
try {
uint16_t port = std::stoi(portstr);
return std::shared_ptr<ClientAccess>(new ClientAccess(token, port));
} catch(std::exception& e) {
Log::error << "could not parse port: " << std::quoted(portstr);
bool success = false;
uint16_t port = portstr.toUInt(&success);
if(!success) {
qCritical() << "could not parse port: " << portstr;
return nullptr;
}
return nullptr;
return std::shared_ptr<ClientAccess>(new ClientAccess(token, port));
}
std::string ClientAccess::getBasicAuth() const {
QString ClientAccess::getBasicAuth() const {
return "riot:" + authcode;
}
@ -42,6 +42,6 @@ uint16_t ClientAccess::getPort() const {
return port;
}
std::string ClientAccess::getURL() const {
return "https://127.0.0.1:" + std::to_string(port) + "/";
QString ClientAccess::getURL() const {
return "https://127.0.0.1:" + QString::number(port) + "/";
}

View File

@ -19,27 +19,29 @@
#include "defer.h"
static const std::string CLIENTNAME = "LeagueClientUx.exe"; // returns the name and value of a argument or empty string if it could not be parsed
static const QString CLIENTNAME = "LeagueClientUx.exe"; // returns the name and value of a argument or empty string if it could not be parsed
static std::shared_ptr<ClientAccess> findUsingLockfile(const std::vector<std::string>& cmdline, pid_t pid);
static bool endsWith(const std::string& all, const std::string& end) {
return all.rfind(end) == all.size() - end.size();
}
static std::shared_ptr<ClientAccess> findUsingLockfile(const std::vector<QString>& cmdline, pid_t pid);
// reads a procfile into a vector (strings are \0 seperated)
static std::vector<std::string> readProcFile(const std::string& path) {
std::ifstream in(path);
std::vector<std::string> out;
static std::vector<QString> readProcFile(const QString& path) {
std::ifstream in(path.toStdString());
std::vector<QString> out;
std::string line;
while(std::getline(in, line, '\0')) {
if(!line.empty()) {
out.push_back(line);
out.push_back(QString::fromStdString(line));
}
}
return out;
}
// test server
#if 0
std::shared_ptr<ClientAccess> ClientAccess::find() {
return std::make_shared<ClientAccess>("password", 4443);
}
#else
std::shared_ptr<ClientAccess> ClientAccess::find() {
DIR* procdir = opendir("/proc");
@ -51,27 +53,27 @@ std::shared_ptr<ClientAccess> ClientAccess::find() {
while ((entry = readdir(procdir)) != NULL) {
if (entry->d_type != DT_DIR) continue;
std::string name(entry->d_name);
QString name(entry->d_name);
pid_t pid = -1;
try {
pid = std::stoi(name);
} catch(std::exception& e) {
bool success = false;
pid = name.toULong(&success);
if(!success) {
// could not parse -> not a pid
continue;
}
// get info on the exe
std::string cmdfile = "/proc/" + std::to_string(pid) + "/cmdline";
std::vector<std::string> args = readProcFile(cmdfile);
QString cmdfile = "/proc/" + QString::number(pid) + "/cmdline";
std::vector<QString> args = readProcFile(cmdfile);
// Log::debug << "process: " << pid << " has " << args.size() << " args";
// qDebug() << "process: " << pid << " has " << args.size() << " args";
if(args.empty()) continue;
std::string& exename = args.at(0);
if(endsWith(exename, CLIENTNAME)) {
Log::info << CLIENTNAME << " found";
QString& exename = args.at(0);
if(exename.endsWith(CLIENTNAME)) {
qInfo() << CLIENTNAME << " found: " << exename;
std::shared_ptr<ClientAccess> out;
@ -85,33 +87,34 @@ std::shared_ptr<ClientAccess> ClientAccess::find() {
return nullptr;
}
#endif
std::shared_ptr<ClientAccess> findUsingLockfile(const std::vector<std::string>& cmdline, pid_t pid) {
std::shared_ptr<ClientAccess> findUsingLockfile(const std::vector<QString>& cmdline, pid_t pid) {
// get WINEPREFIX env
std::vector<std::string> envs = readProcFile("/proc/" + std::to_string(pid) + "/environ");
std::vector<QString> envs = readProcFile("/proc/" + QString::number(pid) + "/environ");
const static std::string WINEPREFIX = "WINEPREFIX=";
const static QString WINEPREFIX = "WINEPREFIX=";
// find WINEPREFIX
auto found = std::find_if(envs.begin(), envs.end(), [](const std::string& s) {
return s.find(WINEPREFIX) == 0;
auto found = std::find_if(envs.begin(), envs.end(), [](const QString& s) {
return s.startsWith(WINEPREFIX);
});
// WINEPREFIX env not present
if(found == envs.end()) {
Log::debug << "WINEPREFIX environment variable not set";
qDebug() << "WINEPREFIX environment variable not set";
return {};
}
const std::string wineprefix = found->substr(WINEPREFIX.size());
const std::string binarypath = cmdline.at(0);
std::string gamefolder = binarypath.substr(2, binarypath.rfind('/')-1); // remove the "C:" and the name of the binary
const QString wineprefix = found->remove(0, WINEPREFIX.size());
const QString binarypath = cmdline.at(0);
QString gamefolder = binarypath.mid(2, binarypath.lastIndexOf('/')-1); // remove the "C:" and the name of the binary
// TODO: gamefoldre could contain '\' so replacing every occurance with '/' would be a good idea
const std::string lockfilepath = wineprefix + "/drive_c/" + gamefolder + "/lockfile";
const QString lockfilepath = wineprefix + "/drive_c/" + gamefolder + "/lockfile";
Log::debug << "lockfilepath: " << std::quoted(lockfilepath);
qDebug() << "lockfilepath: " << lockfilepath;
// read lockfile
std::ifstream lockfile(lockfilepath);
std::ifstream lockfile(lockfilepath.toStdString());
return createFromLockfile(lockfile);
}

View File

@ -16,10 +16,10 @@
#include "defer.h"
static const std::string CLIENTNAME = "LeagueClientUx.exe";
static const QString CLIENTNAME = "LeagueClientUx.exe";
static std::string narrow(WCHAR* str, size_t len) {
std::string out;
static QString narrow(WCHAR* str, size_t len) {
QString out;
out.reserve(len);
for(uint32_t i = 0; i < len && str[i]; ++i) {
out.append(1, (char) str[i]);
@ -27,11 +27,11 @@ static std::string narrow(WCHAR* str, size_t len) {
return out;
}
static std::string getProcessPath(DWORD dwPID) {
static QString getProcessPath(DWORD dwPID) {
// Take a snapshot of all modules in the specified process.
HANDLE hModuleSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, dwPID );
if(hModuleSnap == INVALID_HANDLE_VALUE) {
Log::error << "CreateToolhelp32Snapshot (of modules) failed";
qCritical() << "CreateToolhelp32Snapshot (of modules) failed";
return {}; // empty string
}
@ -44,7 +44,7 @@ static std::string getProcessPath(DWORD dwPID) {
// Retrieve information about the first module,
// and exit if unsuccessful
if( !Module32First( hModuleSnap, &me32 ) ) {
Log::error << "Module32First";
qCritical() << "Module32First";
return {};
}
@ -52,15 +52,15 @@ static std::string getProcessPath(DWORD dwPID) {
}
static std::shared_ptr<ClientAccess> findUsingLockfile(PROCESSENTRY32& proc) {
const std::string exepath = getProcessPath(proc.th32ProcessID);
const QString exepath = getProcessPath(proc.th32ProcessID);
Log::note << "exepath: " << exepath;
// lockfile path
const std::string lockfilepath = exepath.substr(0, exepath.rfind('\\')+1) + "lockfile"; // possible out of bounds
Log::debug << "Lockfile: " << lockfilepath;
const QString lockfilepath = exepath.substr(0, exepath.rfind('\\')+1) + "lockfile"; // possible out of bounds
qDebug() << "Lockfile: " << lockfilepath;
std::ifstream lockfile(lockfilepath);
if(!lockfile) {
Log::error << "lockfile could not be opend";
qCritical() << "lockfile could not be opend";
return nullptr;
}
return createFromLockfile(lockfile);
@ -72,7 +72,7 @@ std::shared_ptr<ClientAccess> ClientAccess::find() {
// Take a snapshot of all processes in the system.
HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hProcessSnap == INVALID_HANDLE_VALUE) {
Log::error << "CreateToolhelp32Snapshot (of processes) failed";
qCritical() << "CreateToolhelp32Snapshot (of processes) failed";
return nullptr;
}
@ -85,18 +85,18 @@ std::shared_ptr<ClientAccess> ClientAccess::find() {
// Retrieve information about the first process,
// and exit if unsuccessful
if (!Process32First(hProcessSnap, &pe32)) {
Log::error << "Process32First failed"; // show cause of failure
qCritical() << "Process32First failed"; // show cause of failure
return nullptr;
}
// Now walk the snapshot of processes, and
// display information about each process in turn
do {
std::string exename = narrow((WCHAR*) pe32.szExeFile, sizeof(pe32.szExeFile));
QString exename = narrow((WCHAR*) pe32.szExeFile, sizeof(pe32.szExeFile));
// Log::note << "found process: " << exename;
if(exename == CLIENTNAME) {
Log::info << CLIENTNAME << " found";
qInfo() << CLIENTNAME << " found";
std::shared_ptr<ClientAccess> out;

View File

@ -9,7 +9,7 @@
#include "json.h"
ClientAPI::ClientAPI(const ClientAccess& ca) : RestClient(ca.getURL()), access(ca) {
ClientAPI::ClientAPI(const ClientAccess& ca) : RestClient(ca.getURL()), access(ca), memImageCache(40), imageCache("runes", "") {
basicauth = ca.getBasicAuth();
disableCertCheck = true;
// enableDebugging();
@ -30,9 +30,9 @@ ClientAPI::GameflowPhase ClientAPI::getGameflowPhase() {
// it is just a json-string no object
QByteArray data = requestRaw("lol-gameflow/v1/gameflow-phase");
std::string datastr = data.toStdString();
QString datastr = QString::fromLocal8Bit(data);
if (data.size() > 2) {
datastr = datastr.substr(1, datastr.size() -2);
datastr = datastr.mid(1, datastr.size() -2);
return toGameflowPhase(datastr);
}
@ -63,25 +63,25 @@ bool ClientAPI::setChampSelectAction(int32_t actionid, int32_t champid, bool com
requestj["completed"] = completed;
requestj["id"] = actionid;
QJsonDocument requestdoc(requestj);
const std::string requeststr = requestdoc.toJson(QJsonDocument::JsonFormat::Compact).toStdString();
Log::debug << "requeststr: " << requeststr;
QJsonDocument doc = request("lol-champ-select/v1/session/actions/" + std::to_string(actionid), Method::PATCH, requeststr);
const QString requeststr = QString::fromLocal8Bit(requestdoc.toJson(QJsonDocument::JsonFormat::Compact));
qDebug().noquote() << "requeststr: " << requeststr;
QJsonDocument doc = request("lol-champ-select/v1/session/actions/" + QString::number(actionid), Method::PATCH, requeststr);
std::string error;
QString error;
if(doc.isObject()) {
QJsonObject obj = doc.object();
auto errref = obj["errorCode"];
auto msgref = obj["message"];
if(errref.isString()) {
error = errref.toString().toStdString() + " ";
error = errref.toString() + " ";
}
if(msgref.isString()) {
error += msgref.toString().toStdString();
error += msgref.toString();
}
}
Log::note << "patching action: " << actionid << " error: " << error;
return error.empty();
qDebug() << "patching action: " << actionid << " error: " << error;
return error.isEmpty();
}
ClientAPI::PlayerInfo ClientAPI::getSelf() {
@ -91,15 +91,15 @@ ClientAPI::PlayerInfo ClientAPI::getSelf() {
QJsonObject obj = doc.object();
PlayerInfo info;
info.gameName = getValue<std::string>(obj, "gameName");
info.name = getValue<std::string>(obj, "name");
info.statusMessage = getValue<std::string>(obj, "statusMessage", "");
info.gameName = getValue<QString>(obj, "gameName");
info.name = getValue<QString>(obj, "name");
info.statusMessage = getValue<QString>(obj, "statusMessage", "");
info.summonerid = getValue<uint64_t>(obj, "summonerId");
auto lolref = obj["lol"];
if(lolref.isObject()) {
QJsonObject lol = lolref.toObject();
info.puuid = getValue<std::string>(lol, "puuid");
info.puuid = getValue<QString>(lol, "puuid");
info.level = getValue<int32_t>(lol, "level");
}
@ -165,32 +165,32 @@ std::vector<ClientAPI::Conversation> ClientAPI::getAllConversations() {
return out;
}
ClientAPI::Message ClientAPI::sendMessage(const std::string& chatid, const std::string& messagebody) {
ClientAPI::Message ClientAPI::sendMessage(const QString& chatid, const QString& messagebody) {
QJsonObject requestj;
requestj["body"] = QString::fromStdString(messagebody);
requestj["body"] = messagebody;
QJsonDocument requestdoc(requestj);
const std::string requeststr = requestdoc.toJson(QJsonDocument::JsonFormat::Compact).toStdString();
Log::debug << "requeststr: " << requeststr;
const QString requeststr = QString::fromLocal8Bit(requestdoc.toJson(QJsonDocument::JsonFormat::Compact));
qDebug().noquote() << "requeststr: " << requeststr;
QJsonDocument doc = request("lol-chat/v1/conversations/" + chatid + "/messages", Method::POST, requeststr);
std::string error;
QString error;
if(doc.isObject()) {
QJsonObject obj = doc.object();
auto errref = obj["errorCode"];
auto msgref = obj["message"];
if(errref.isString()) {
error = errref.toString().toStdString() + " ";
error = errref.toString() + " ";
}
if(msgref.isString()) {
error += msgref.toString().toStdString();
error += msgref.toString();
}
if(error.empty()) {
if(error.isEmpty()) {
return (Message) obj;
}
}
Log::note << "send message error: " << error;
qDebug() << "send message error: " << error;
return {};
}
@ -220,12 +220,12 @@ std::vector<ClientAPI::RunePage> ClientAPI::getAllRunePages() {
}
bool ClientAPI::selectRunePage(uint64_t id) {
QJsonDocument doc = request("lol-perks/v1/currentpage", Method::PUT, std::to_string(id));
QJsonDocument doc = request("lol-perks/v1/currentpage", Method::PUT, QString::number(id));
if(doc.isEmpty()) return true; // ok
// error
Log::warn << "error selecting runepage: " << id << " " << doc.toJson().toStdString();
qWarning() << "error selecting runepage: " << id << " " << doc.toJson();
return false;
}
@ -233,7 +233,7 @@ bool ClientAPI::selectRunePage(uint64_t id) {
bool ClientAPI::editRunePage(const RunePage& page) {
QJsonObject pagereq;
pagereq["name"] = QString::fromStdString(page.name);
pagereq["name"] = page.name;
pagereq["primaryStyleId"] = (int) page.runepage.primaryStyle;
pagereq["subStyleId"] = (int) page.runepage.secondaryStyle;
@ -245,14 +245,52 @@ bool ClientAPI::editRunePage(const RunePage& page) {
pagereq["selectedPerkIds"] = selected;
QJsonDocument reqdoc(pagereq);
const std::string requestdocstr = reqdoc.toJson(QJsonDocument::JsonFormat::Compact).toStdString();
Log::info << "requeststr: " << requestdocstr;
QJsonDocument doc = request("lol-perks/v1/pages/" + std::to_string(page.id), Method::PUT, requestdocstr);
const QString requestdocstr = QString::fromLocal8Bit(reqdoc.toJson(QJsonDocument::JsonFormat::Compact));
qInfo().noquote() << "requeststr: " << requestdocstr;
QJsonDocument doc = request("lol-perks/v1/pages/" + QString::number(page.id), Method::PUT, requestdocstr);
if(doc.isEmpty()) return true; // ok
// error
Log::warn << "error editing runepage: " << page.id << " " << doc.toJson().toStdString();
qWarning() << "error editing runepage: " << page.id << " " << doc.toJson();
return false;
}
bool ClientAPI::createRunePage(const RunePage& page) {
QJsonObject pagereq;
pagereq["name"] = page.name;
pagereq["primaryStyleId"] = (int) page.runepage.primaryStyle;
pagereq["subStyleId"] = (int) page.runepage.secondaryStyle;
QJsonArray selected;
for(uint32_t sel : page.runepage.selectedAspects) {
selected.push_back((int) sel);
}
pagereq["selectedPerkIds"] = selected;
QJsonDocument reqdoc(pagereq);
const QString requestdocstr = reqdoc.toJson(QJsonDocument::JsonFormat::Compact);
qInfo() << "requeststr: " << requestdocstr;
QJsonDocument doc = request("lol-perks/v1/pages/", Method::POST, requestdocstr);
if(doc.isEmpty()) return true; // ok
// error
qWarning() << "error creating runepage: " << page.name << " " << doc.toJson();
return false;
}
bool ClientAPI::deleteRunePage(uint64_t id) {
QJsonDocument doc = request("lol-perks/v1/pages/" + QString::number(id), Method::DELETE);
if(doc.isEmpty()) return true; // ok
// error
qWarning() << "error deleteing runepage: " << id << " " << doc.toJson();
return false;
}
@ -261,7 +299,7 @@ std::vector<RuneAspekt> ClientAPI::getAllRuneAspekts() {
QJsonDocument doc = request("lol-perks/v1/perks");
if(!doc.isArray()) {
Log::warn << __PRETTY_FUNCTION__ << " doc is not array";
qWarning() << __PRETTY_FUNCTION__ << " doc is not array";
return {};
}
@ -280,7 +318,7 @@ std::vector<RuneStyle> ClientAPI::getAllRuneStyles() {
QJsonDocument doc = request("lol-perks/v1/styles");
if(!doc.isArray()) {
Log::warn << __PRETTY_FUNCTION__ << " doc is not array";
qWarning() << __PRETTY_FUNCTION__ << " doc is not array";
return {};
}
@ -294,3 +332,38 @@ std::vector<RuneStyle> ClientAPI::getAllRuneStyles() {
}
return out;
}
QPixmap ClientAPI::getImageResource(QString path) {
if(path.isEmpty()) return {};
QString simplePath;
{
QString simplePathQ = path;
simplePath = simplePathQ.replace('/', '_');
}
// query mem cache
QPixmap img = memImageCache.getImage(path, 0);
if(!img.isNull()) return img;
// query HDD cache
img = imageCache.getImage(simplePath);
if(!img.isNull()) {
// update mem cache
memImageCache.addImage(img, path, 0);
return img;
}
qInfo() << "requesting: " << path;
QByteArray arr = requestRaw(path);
QPixmap out;
out.loadFromData(arr);
// store HDD cache
imageCache.addImageRaw(arr, simplePath);
// store memchache
memImageCache.addImage(out, path, 0);
return out;
}

View File

@ -1,6 +1,5 @@
#include "clientapi.h"
#include <iomanip>
#include <QJsonArray>
#include <QJsonObject>
@ -10,7 +9,7 @@
// calculate the size of a constant sized array
#define ARRSIZE(ARRNAME) (sizeof(ARRNAME) / sizeof(ARRNAME[0]))
#define ARR(NAME, ...) static const std::string NAME ## Names[] = {__VA_ARGS__}; \
#define ARR(NAME, ...) static const QString NAME ## Names[] = {__VA_ARGS__}; \
static const uint32_t NAME ## NamesCount = ARRSIZE(NAME ## Names);
ARR(ReadyCheckState, "Invalid", "None", "InProgress", "Accepted", "Declined");
@ -21,8 +20,8 @@ ARR(ShortPosition, "", "Top", "Jgl", "Mid", "Bot", "Sup");
ARR(ChampSelectActionType, "Invalid", "ban", "pick", "ten_bans_reveal");
template<typename T>
static T mapEnum(const std::string& input, const std::string* names, uint32_t count, T defaul) {
if(input.empty()) return defaul;
static T mapEnum(const QString& input, const QString* names, uint32_t count, T defaul) {
if(input.isEmpty()) return defaul;
for (uint32_t i = 0; i < count; ++i) {
if (names[i] == input) {
@ -30,7 +29,7 @@ static T mapEnum(const std::string& input, const std::string* names, uint32_t co
}
}
Log::warn << "no mapping of enum-string: " << std::quoted(input) << " using default: " << defaul << " type: " << typeid(T).name();
qWarning() << "no mapping of enum-string: " << input << " using default: " << defaul << " type: " << typeid(T).name();
return defaul;
}
@ -50,8 +49,8 @@ static std::vector<T> readVector(QJsonArray arr) {
}
ClientAPI::ReadyCheckState ClientAPI::toReadyCheckState(const QJsonObject& obj) {
std::string searchState = getValue<std::string>(obj, "state", "Invalid");
std::string playerresponse = getValue<std::string>(obj, "playerResponse", "None");
QString searchState = getValue<QString>(obj, "state", "Invalid");
QString playerresponse = getValue<QString>(obj, "playerResponse", "None");
ClientAPI::ReadyCheckState response = MAPENUM(playerresponse, ReadyCheckState, NONE);
@ -65,27 +64,27 @@ ClientAPI::ReadyCheckState ClientAPI::toReadyCheckState(const QJsonObject& obj)
return response;
}
ClientAPI::GameflowPhase ClientAPI::toGameflowPhase(const std::string& str) {
ClientAPI::GameflowPhase ClientAPI::toGameflowPhase(const QString& str) {
return MAPENUM(str, GameflowPhase, NONE);
}
ClientAPI::ChampSelectPhase ClientAPI::toChampSelectPhase(const std::string& str) {
ClientAPI::ChampSelectPhase ClientAPI::toChampSelectPhase(const QString& str) {
return MAPENUM(str, ChampSelectPhase, INVALID);
}
Position toPosition(const std::string& str) {
Position toPosition(const QString& str) {
return mapEnum(str, PositionNames, PositionNamesCount, Position::INVALID);
}
std::string toString(Position p) {
QString toString(Position p) {
return PositionNames[(int) p];
}
std::string toShortString(Position p) {
QString toShortString(Position p) {
return ShortPositionNames[(int) p];
}
ClientAPI::ChampSelectActionType ClientAPI::toChampSelectActionType(const std::string& str) {
ClientAPI::ChampSelectActionType ClientAPI::toChampSelectActionType(const QString& str) {
return MAPENUM(str, ChampSelectActionType, INVALID);
}
@ -95,7 +94,7 @@ ClientAPI::TimerInfo::TimerInfo(const QJsonObject& obj) {
internalNowInEpochMs = getValue<int64_t>(obj, "internalNowInEpochMs", 0);
isefinite = getValue<bool>(obj, "isefinite", 0);
phase = MAPENUM(getValue<std::string>(obj, "phase", "Invalid"), ChampSelectPhase, INVALID);
phase = MAPENUM(getValue<QString>(obj, "phase", "Invalid"), ChampSelectPhase, INVALID);
totalTimeInPhase = getValue<int64_t>(obj, "totalTimeInPhase", 0);
}
@ -108,13 +107,13 @@ ClientAPI::ChampSelectAction::ChampSelectAction(const QJsonObject& json) {
id = getValue<int32_t>(json, "id");
isAllyAction = getValue<bool>(json, "isAllyAction");
isInProgress = getValue<bool>(json, "isInProgress");
const std::string typestr = getValue<std::string>(json, "type", "Invalid");
const QString typestr = getValue<QString>(json, "type", "Invalid");
type = toChampSelectActionType(typestr);
}
ClientAPI::ChampSelectCell::ChampSelectCell() {}
ClientAPI::ChampSelectCell::ChampSelectCell(const QJsonObject& json) {
position = toPosition(getValue<std::string>(json, "assignedPosition"));
position = toPosition(getValue<QString>(json, "assignedPosition"));
cellID = getValue<int32_t>(json, "cellId");
championID = getValue<int32_t>(json, "championId");
championPickIntentID = getValue<int32_t>(json, "championPickIntent");
@ -195,7 +194,7 @@ ClientAPI::RunePage::RunePage(const QJsonObject& json) {
lastmodified = getValue<int64_t>(json, "lastModified", 0);
runepage.primaryStyle = getValue<int32_t>(json, "primaryStyleId", 0);
runepage.secondaryStyle = getValue<int32_t>(json, "subStyleId", 0);
name = getValue<std::string>(json, "name");
name = getValue<QString>(json, "name");
isDeleteable = getValue<bool>(json, "isDeletable", false);
isEditable = getValue<bool>(json, "isEditable", false);
isActive = getValue<bool>(json, "isActive", false);
@ -209,48 +208,69 @@ ClientAPI::RunePage::RunePage(const QJsonObject& json) {
}
}
RuneStyleSlot::RuneStyleSlot() {}
RuneStyleSlot::RuneStyleSlot(const QJsonObject& json) {
type = getValue<QString>(json, "type");
auto perksj = json["perks"];
if(perksj.isArray()) {
perks = readVector<int>(perksj.toArray());
}
}
RuneStyle::RuneStyle() {}
RuneStyle::RuneStyle(const QJsonObject& json) {
id = getValue<int32_t>(json, "id", 0);
name = getValue<std::string>(json, "name");
iconPath = getValue<std::string>(json, "iconPath");
tooltip = getValue<std::string>(json, "tooltip");
name = getValue<QString>(json, "name");
iconPath = getValue<QString>(json, "iconPath");
tooltip = getValue<QString>(json, "tooltip");
idName = getValue<QString>(json, "idName");
auto subStylesRef = json["allowedSubStyles"];
if(subStylesRef.isArray()) {
allowedSubStyles = readVector<int>(subStylesRef.toArray());
}
auto runeSlotsRef = json["slots"];
if(runeSlotsRef.isArray()) {
runeSlots = readVector<RuneStyleSlot>(runeSlotsRef.toArray());
}
}
RuneAspekt::RuneAspekt() {}
RuneAspekt::RuneAspekt(const QJsonObject& json) {
id = getValue<int32_t>(json, "id", 0);
name = getValue<std::string>(json, "name");
shortDesc = getValue<std::string>(json, "shortDesc");
longDesc = getValue<std::string>(json, "longDesc");
tooltip = getValue<std::string>(json, "tooltip");
iconPath = getValue<std::string>(json, "iconPath");
name = getValue<QString>(json, "name");
shortDesc = getValue<QString>(json, "shortDesc");
longDesc = getValue<QString>(json, "longDesc");
tooltip = getValue<QString>(json, "tooltip");
iconPath = getValue<QString>(json, "iconPath");
}
ClientAPI::Message::Message() {}
ClientAPI::Message::Message(const QJsonObject& json) {
body = getValue<std::string>(json, "body");
fromId = getValue<std::string>(json, "fromId");
fromPid = getValue<std::string>(json, "fromPid");
body = getValue<QString>(json, "body");
fromId = getValue<QString>(json, "fromId");
fromPid = getValue<QString>(json, "fromPid");
fromSummonerId = getValue<int64_t>(json, "fromSummonerId");
id = getValue<std::string>(json, "id");
id = getValue<QString>(json, "id");
isHistorical = getValue<bool>(json, "isHistorical", true);
timestamp = getValue<std::string>(json, "timestamp");
type = getValue<std::string>(json, "type");
timestamp = getValue<QString>(json, "timestamp");
type = getValue<QString>(json, "type");
}
ClientAPI::Conversation::Conversation() {}
ClientAPI::Conversation::Conversation(const QJsonObject& json) : lastMessage(nullptr) {
gameName = getValue<std::string>(json, "gameName");
gameTag = getValue<std::string>(json, "gameTag");
id = getValue<std::string>(json, "id");
gameName = getValue<QString>(json, "gameName");
gameTag = getValue<QString>(json, "gameTag");
id = getValue<QString>(json, "id");
isMuted = getValue<bool>(json, "isMuted");
name = getValue<std::string>(json, "name");
password = getValue<std::string>(json, "password");
pid = getValue<std::string>(json, "pid");
targetRegion = getValue<std::string>(json, "targetRegion");
type = getValue<std::string>(json, "type");
name = getValue<QString>(json, "name");
password = getValue<QString>(json, "password");
pid = getValue<QString>(json, "pid");
targetRegion = getValue<QString>(json, "targetRegion");
type = getValue<QString>(json, "type");
unreadMessageCount = getValue<int64_t>(json, "unreadMessageCount");
auto msgref = json["lastMessage"];
@ -262,6 +282,11 @@ ClientAPI::Conversation::Conversation(const QJsonObject& json) : lastMessage(nul
#define PRINTENUM(ENUMNAME) \
std::ostream& operator<<(std::ostream& str, const ClientAPI:: ENUMNAME & state) { \
assert(((uint32_t) state) < ENUMNAME ## NamesCount); \
return str << ENUMNAME ## Names[(uint32_t) state].toStdString() << " (" << (uint32_t) state << ')'; \
} \
\
QDebug operator<<(QDebug str, const ClientAPI:: ENUMNAME & state) { \
assert(((uint32_t) state) < ENUMNAME ## NamesCount); \
return str << ENUMNAME ## Names[(uint32_t) state] << " (" << (uint32_t) state << ')'; \
}
@ -274,6 +299,11 @@ PRINTENUM(ChampSelectActionType)
// not using macro because its not in ClientAPI
std::ostream& operator<<(std::ostream& str, const Position & state) {
assert(((uint32_t) state) < PositionNamesCount);
return str << PositionNames[(uint32_t) state].toStdString() << " (" << (uint32_t) state << ')';
}
QDebug operator<<(QDebug str, const Position & state) {
assert(((uint32_t) state) < PositionNamesCount);
return str << PositionNames[(uint32_t) state] << " (" << (uint32_t) state << ')';
}

57
src/clipboardpopup.cpp Normal file
View File

@ -0,0 +1,57 @@
#include "clipboardpopup.h"
#include "ui_clipboardpopup.h"
#include <QClipboard>
ClipboardPopup::ClipboardPopup(Direction dir, QWidget* parent) : QDialog(parent), ui(new Ui::ClipboardPopup), direction(dir) {
ui->setupUi(this);
if(direction == Direction::Paste) {
this->ui->copyButton->hide();
this->ui->text->setPlaceholderText(ClipboardPopup::tr("Paste here"));
this->ui->buttonBox->setStandardButtons(QDialogButtonBox::Cancel);
QObject::connect(this->ui->text, &QTextEdit::textChanged, this, &ClipboardPopup::textPasted);
} else {
// copy
this->ui->text->setReadOnly(true);
}
QObject::connect(this->ui->copyButton, &QPushButton::pressed, this, &ClipboardPopup::copyButton);
}
ClipboardPopup::~ClipboardPopup() {
delete this->ui;
}
void ClipboardPopup::textPasted() {
int newTextSize = this->getText().size();
if(newTextSize - 1 > lastKnownTextSize && newTextSize > 1) {
// asume that something was pasted
accept();
return;
}
if(newTextSize > 0) {
this->ui->buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
}
lastKnownTextSize = newTextSize;
}
void ClipboardPopup::setText(QString text) {
this->ui->text->setText(text);
this->ui->text->selectAll();
}
QString ClipboardPopup::getText() const {
return this->ui->text->toPlainText();
}
void ClipboardPopup::copyButton() {
QClipboard* clip = qApp->clipboard();
clip->setText(this->ui->text->toPlainText());
// close this dialog
accept();
}

View File

@ -19,7 +19,7 @@ Config::StageConfig::StageConfig() : enabled(false) {}
Config::StageConfig::StageConfig(const QJsonObject& j) {
if(j["champ"].isString()) {
champs.push_back(getValue<std::string>(j, "champ", ""));
champs.push_back(getValue<QString>(j, "champ"));
}
if(j["champs"].isArray()) {
QJsonArray jchamps = j["champs"].toArray();
@ -27,7 +27,7 @@ Config::StageConfig::StageConfig(const QJsonObject& j) {
if(jchamp.isString()) {
QString jchampstr = jchamp.toString();
if(!jchampstr.isEmpty()) {
champs.push_back(jchampstr.toStdString());
champs.push_back(jchampstr);
}
}
}
@ -39,9 +39,9 @@ Config::StageConfig::operator QJsonObject() const {
QJsonObject out;
QJsonArray jchamps;
for(const std::string& champ : champs) {
if(!champ.empty()) {
jchamps.push_back(QString::fromStdString(champ));
for(const QString& champ : champs) {
if(!champ.isEmpty()) {
jchamps.push_back(champ);
}
}
@ -55,9 +55,9 @@ 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"));
position = toPosition(getValue<QString>(j, "position"));
if((int) position < 0 || position > Position::UTILITY) {
Log::warn << "invalid config value \"position\"";
qWarning() << "invalid config value \"position\"";
position = Position::MIDDLE;
}
}
@ -66,14 +66,71 @@ Config::PositionConfig::operator QJsonObject() const {
out["ban"] = (QJsonObject) ban;
out["pick"] = (QJsonObject) pick;
out["position"] = QString::fromStdString(toString(position));
out["position"] = toString(position);
return out;
}
Config::RunePageConfig::RunePageConfig() {}
Config::RunePageConfig::RunePageConfig(const QJsonObject& j) {
name = getValue<QString>(j, "name");
runepage = getValue<::RunePage>(j, "runepage");
}
Config::RunePageConfig::operator QJsonObject() const {
QJsonObject out;
out["name"] = name;
out["runepage"] = static_cast<QJsonObject>(runepage);
return out;
}
Config::RootConfig::RootConfig() {}
Config::RunePageConfig::RunePageConfig(QString name, const RunePage& rp) : name(name), runepage(rp) {}
Config::GeneralRunePageConfig::GeneralRunePageConfig() {}
Config::GeneralRunePageConfig::GeneralRunePageConfig(const QJsonObject& j) {
auto runepagesRef = j["pages"];
if(runepagesRef.isArray()) {
QJsonArray jpages = runepagesRef.toArray();
runePages.reserve(jpages.size());
for(QJsonValue val : jpages) {
if(val.isObject()) {
runePages.push_back(std::make_shared<RunePageConfig>(val.toObject()));
}
}
}
autoSync = getValue(j, "autosync", true);
}
Config::GeneralRunePageConfig::operator QJsonObject() const {
QJsonObject out;
QJsonArray runepagesArr;
for(std::shared_ptr<RunePageConfig> rp : runePages) {
runepagesArr.push_back((QJsonObject) *rp);
}
out.insert("pages", runepagesArr);
out.insert("autosync", autoSync);
return out;
}
Config::RootConfig::RootConfig(const QJsonObject& j) {
if(j.contains("version")) {
int version = j["version"].toInt();
if(version > 1) {
// error
qCritical() << "config version is not known: " << version << " using the config might corrupt it.";
// TODO: make backup of config or something
}
// add migrations here if required
}
auto jposref = j["positions"];
if(jposref.isArray()) {
QJsonArray jpos = jposref.toArray();
@ -86,8 +143,12 @@ Config::RootConfig::RootConfig(const QJsonObject& j) {
}
}
runepagesConfig = getValue<GeneralRunePageConfig>(j, "runepages");
enabledAutoAccept = getValue(j, "enabledAutoAccept", true);
enabledSmiteWarn = getValue(j, "enabledSmiteWarn", true);
enabledAutoWrite = getValue(j, "enabledAutoWrite", false);
autoWriteText = getValue<QString>(j, "autoWriteText");
}
Config::RootConfig::operator QJsonObject() const {
@ -99,8 +160,12 @@ Config::RootConfig::operator QJsonObject() const {
}
out["positions"] = positionarr;
out["runepages"] = (QJsonObject) runepagesConfig;
out.insert("enabledAutoAccept", enabledAutoAccept);
out.insert("enabledSmiteWarn", enabledSmiteWarn);
out.insert("enabledAutoWrite", enabledAutoWrite);
out.insert("autoWriteText", autoWriteText);
out.insert("version", 1);
return out;
}
@ -129,42 +194,43 @@ Config::Config() {
Config::~Config() {}
bool Config::load() {
QFile conffile(QString::fromStdString(configFilePath));
QFile conffile(configFilePath);
if(!conffile.open(QIODevice::ReadOnly)) {
Log::error << "could not open configfile: " << configFilePath;
qCritical() << "could not open configfile: " << configFilePath;
return false;
}
QJsonParseError err;
QJsonDocument doc = QJsonDocument::fromJson(conffile.readAll(), &err);
if(err.error != QJsonParseError::NoError) {
Log::error << "config parse error: " << err.errorString().toStdString() << " position: " << err.offset;
qCritical() << "config parse error: " << err.errorString() << " position: " << err.offset;
return false;
}
if(doc.isObject()) {
// implicit cast
root = doc.object();
Log::info << "config loaded";
qInfo() << "config loaded";
return true;
}
Log::error << "config is not a json object!";
qCritical() << "config is not a json object!";
return false;
}
void Config::save() {
Log::note << "Config::save()";
mkdirs(configFolderPath);
QFile conffile(QString::fromStdString(configFilePath));
QFile conffile(configFilePath);
if(!conffile.open(QIODevice::WriteOnly)) {
Log::error << "could not open configfile: " << configFilePath;
qCritical() << "could not open configfile: " << configFilePath;
return;
}
QJsonDocument doc;
doc.setObject(root);
conffile.write(doc.toJson());
Log::info << "config saved";
qInfo() << "config saved";
}
Config::RootConfig& Config::getConfig() {

View File

@ -6,18 +6,20 @@
#include <curl/easy.h>
#include <Log.h>
#include <QEventLoop>
#include <QJsonArray>
#include <QJsonObject>
#include <QThread>
#include <algorithm> // std::max, champ matching
#include "json.h"
static const std::string BASEURL = "https://ddragon.leagueoflegends.com/";
static const QString BASEURL = "https://ddragon.leagueoflegends.com/";
const DataDragon::ChampData DataDragon::EMPTYCHAMP;
DataDragon::DataDragon(const std::string& locale) : RestClient(BASEURL), locale(locale), cache({{"square", ".png"}, {"loading", "_0.jpg"}, {"splash", "_0.jpg"}}) {
startThread();
DataDragon::DataDragon(const QString& locale) : RestClient(BASEURL), locale(locale), cache({{"square", ".png"}, {"loading", "_0.jpg"}, {"splash", "_0.jpg"}}) {
this->setObjectName("DataDragon");
}
DataDragon::~DataDragon() {
@ -27,16 +29,16 @@ DataDragon::~DataDragon() {
DataDragon::ChampData::ChampData() : key(-1) {}
DataDragon::ChampData::ChampData(const QJsonObject& source) {
name = getValue<std::string>(source, "name", "");
id = getValue<std::string>(source, "id", "");
name = getValue<QString>(source, "name", "");
id = getValue<QString>(source, "id", "");
key = getValue<int>(source, "key", -1);
partype = getValue<std::string>(source, "partype", "");
title = getValue<std::string>(source, "title", "");
partype = getValue<QString>(source, "partype", "");
title = getValue<QString>(source, "title", "");
}
const std::string& DataDragon::getVersion() {
const QString& DataDragon::getVersion() {
std::unique_lock lock(cachedatamutex);
while(version.empty() && shouldrun) {
while(version.isEmpty() && shouldrun) {
cachedatacv.wait(lock);
}
return version;
@ -50,8 +52,8 @@ const std::vector<DataDragon::ChampData>& DataDragon::getChamps() {
return champs;
}
QPixmap DataDragon::getImage(const std::string& champid, ImageType imgtype, bool writeMemcache) {
if(champid.empty()) return {};
QPixmap DataDragon::getImage(const QString& champid, ImageType imgtype, bool writeMemcache) {
if(champid.isEmpty()) return {};
// query mem cache
QPixmap img = memcache.getImage(champid, (int) imgtype);
@ -65,8 +67,8 @@ QPixmap DataDragon::getImage(const std::string& champid, ImageType imgtype, bool
return img;
}
const std::string url = getImageUrl(champid, imgtype);
if(url.empty()) return {};
const QString url = getImageUrl(champid, imgtype);
if(url.isEmpty()) return {};
QByteArray arr;
@ -74,14 +76,14 @@ QPixmap DataDragon::getImage(const std::string& champid, ImageType imgtype, bool
arr = requestRaw(url);
} catch(RestClient::WebException& e) {}
if(arr.isEmpty()) {
Log::error << "image could not be loaded";
qCritical() << "image could not be loaded";
return {};
}
// propably an error
if(arr.size() < 1000) {
Log::info << "small icon url: " << url;
Log::info << "content: " << std::string(arr.data(), arr.size());
qInfo() << "small icon url: " << url;
qInfo() << "content: " << QString::fromLocal8Bit(arr);
return {};
}
@ -102,7 +104,7 @@ QPixmap DataDragon::getImage(const std::string& champid, ImageType imgtype, bool
return decodedImage;
}
void DataDragon::getImageAsnyc(const std::string& champid, notifyImgfunc_t func, ImageType imgtype) {
void DataDragon::getImageAsnyc(const QString& champid, notifyImgfunc_t func, ImageType imgtype) {
if(!func) return;
{
@ -112,44 +114,40 @@ void DataDragon::getImageAsnyc(const std::string& champid, notifyImgfunc_t func,
tasksnotemptycv.notify_one();
}
static std::string toLower(const std::string& in) {
return QString::fromStdString(in).toLower().toStdString();
}
static size_t startinglength(const std::string& original, const std::string& prefix) {
size_t i = 0;
static int startinglength(const QString& original, const QString& prefix) {
int i = 0;
for(; i < original.size() && i < prefix.size(); ++i) {
if(original.substr(0, i+1) != prefix.substr(0, i+1)) {
if(original.left(i+1) != prefix.left(i+1)) {
return i;
}
}
return i;
}
static size_t matchChamp(const DataDragon::ChampData& champ, const std::string& lower) {
std::string lowerid = toLower(champ.id);
std::string lowername = toLower(champ.name);
static size_t matchChamp(const DataDragon::ChampData& champ, const QString& lower) {
QString lowerid = champ.id.toLower();
QString lowername = champ.name.toLower();
if(lowerid == lower || lowername == lower) {
return lower.size();
}
size_t lengtha = startinglength(lowerid, lower);
size_t lengthb = startinglength(lowername, lower);
int lengtha = startinglength(lowerid, lower);
int lengthb = startinglength(lowername, lower);
return std::max(lengtha, lengthb);
return qMax(lengtha, lengthb);
}
const DataDragon::ChampData& DataDragon::getBestMatchingChamp(const std::string& name, int* count) {
const DataDragon::ChampData& DataDragon::getBestMatchingChamp(const QString& name, int* count) {
getChamps();
// for now: just check for a perfect hit
std::string lower = toLower(name);
QString lower = name.toLower();
int bestmatchingoffset = -1;
size_t bestmatchinglength = 0;
int bestmatchinglength = 0;
uint32_t bestmatchingcount = 0;
for(size_t offset = 0; offset < champs.size(); ++offset) {
const ChampData& it = champs.at(offset);
size_t match = matchChamp(it, lower);
int match = matchChamp(it, lower);
if(match > bestmatchinglength) {
bestmatchinglength = match;
bestmatchingcount = 1;
@ -171,12 +169,12 @@ const DataDragon::ChampData& DataDragon::getBestMatchingChamp(const std::string&
return EMPTYCHAMP;
}
std::vector<const DataDragon::ChampData*> DataDragon::getMatchingChamp(const std::string& name, uint32_t limit) {
std::vector<const DataDragon::ChampData*> DataDragon::getMatchingChamp(const QString& name, uint32_t limit) {
if(limit == 0) return {};
if(name.empty()) return {};
if(name.isEmpty()) return {};
getChamps();
std::string lower = toLower(name);
QString lower = name.toLower();
std::vector<size_t> matches;
matches.resize(champs.size());
@ -212,11 +210,11 @@ const DataDragon::ChampData* DataDragon::getChampByID(uint32_t id) {
return &*it;
}
std::vector<uint32_t> DataDragon::resolveChampIDs(const std::vector<std::string>& champnames) {
std::vector<uint32_t> DataDragon::resolveChampIDs(const std::vector<QString>& champnames) {
std::vector<uint32_t> out;
out.reserve(champnames.size());
std::transform(champnames.begin(), champnames.end(), std::insert_iterator(out, out.begin()), [this](const std::string& champname) {
std::transform(champnames.begin(), champnames.end(), std::insert_iterator(out, out.begin()), [this](const QString& champname) {
auto cd = getBestMatchingChamp(champname);
return cd.key; // might be 0 (invalid)
});
@ -224,10 +222,27 @@ std::vector<uint32_t> DataDragon::resolveChampIDs(const std::vector<std::string>
return out;
}
std::string DataDragon::getImageUrl(const std::string& champid, ImageType type) {
void DataDragon::startThread() {
shouldrun = true;
bgthread = QThread::create(&DataDragon::threadLoop, this);
bgthread->setObjectName("DataDragonThread");
bgthread->start();
this->moveToThread(bgthread);
}
void DataDragon::stop() {
qDebug() << "stop DataDragon";
shouldrun = false;
std::unique_lock lock(tasksmutex);
tasks.clear();
notDownloadedImages.clear(); // this is a possible race condition!
}
QString DataDragon::getImageUrl(const QString& champid, ImageType type) {
switch(type) {
case ImageType::SQUARE: {
if(getVersion().empty()) {
if(getVersion().isEmpty()) {
return {};
}
@ -244,13 +259,13 @@ std::string DataDragon::getImageUrl(const std::string& champid, ImageType type)
return {};
}
std::string DataDragon::getCDNString() const {
QString DataDragon::getCDNString() const {
return "cdn/" + version + "/";
}
void DataDragon::prefetchChampImage(const std::string& champid, ImageType imgtype) {
void DataDragon::prefetchChampImage(const QString& champid, ImageType imgtype) {
if(!cache[(int) imgtype].hasImage(champid)) {
Log::debug << "prefetch " << champid << " type: " << (int) imgtype;
qDebug() << "prefetch " << champid << " type: " << (int) imgtype;
getImage(champid, imgtype, false);
}
}
@ -258,31 +273,31 @@ void DataDragon::prefetchChampImage(const std::string& champid, ImageType imgtyp
void DataDragon::getVersionInternal() {
std::unique_lock lock(cachedatamutex);
if(!version.empty()) return;
if(!version.isEmpty()) return;
version = champCache.getVersion();
if(!version.empty()) return;
if(!version.isEmpty()) return;
try {
QJsonDocument jversions = request("api/versions.json");
if(jversions.isArray()) {
QJsonArray jverarr = jversions.array();
if(!jverarr.empty()) {
version = jverarr.at(0).toString().toStdString();
Log::info << "got League version: " << version;
version = jverarr.at(0).toString();
qInfo() << "got League version: " << version;
lock.unlock();
cachedatacv.notify_all();
return;
}
}
Log::error << "error parsing version object";
qCritical() << "error parsing version object";
} catch(RestClient::WebException& e) {}
}
void DataDragon::getChampsInternal() {
std::unique_lock lock(cachedatamutex);
if(!champs.empty() && version.empty()) {
if(!champs.empty() && version.isEmpty()) {
return;
}
@ -316,16 +331,11 @@ void DataDragon::getChampsInternal() {
}
}
}
Log::info << "loaded " << champs.size() << " champs from cache: " << cacheSuccessfull;
qInfo() << "loaded " << champs.size() << " champs from cache: " << cacheSuccessfull;
lock.unlock();
cachedatacv.notify_all();
}
void DataDragon::startThread() {
shouldrun = true;
bgthread = std::thread(&DataDragon::threadLoop, this);
}
void DataDragon::stopThread() {
shouldrun = false;
tasksnotemptycv.notify_all();
@ -334,11 +344,12 @@ void DataDragon::stopThread() {
void DataDragon::stopAndJoinThread() {
stopThread();
if(bgthread.joinable())
bgthread.join();
bgthread->wait();
}
void DataDragon::threadLoop() {
QEventLoop loop;
// init version and champ list
getVersionInternal();
getChampsInternal();
@ -354,15 +365,18 @@ void DataDragon::threadLoop() {
} else {
Log::note << "DataDragon background thread is idleing - prefetching champion images TODO: " << notDownloadedImages.size();
while(!notDownloadedImages.empty() && tasks.empty()) {
while(shouldrun && !notDownloadedImages.empty() && tasks.empty()) {
lock.unlock();
auto it = notDownloadedImages.begin();
std::string champid = *it;
QString champid = *it;
notDownloadedImages.erase(it);
prefetchChampImage(champid, ImageType::SQUARE);
emit this->loading(1.0 - (notDownloadedImages.size() / (float) champs.size()));
emit this->fetchingChamp(champid);
lock.lock();
}
@ -372,24 +386,29 @@ void DataDragon::threadLoop() {
if(!once) {
once = true;
Log::note << "all champs are prefetched now";
emit this->loading( 1.0 );
}
tasksnotemptycv.wait(lock);
}
}
}
if(tasks.empty()) continue;
t = tasks.front();
tasks.pop_front();
}
loop.processEvents();
QPixmap img = getImage(t.champid, t.type);
t.func(img);
}
}
qDebug() << "DataDragon Thread terminated";
}
std::ostream& operator<<(std::ostream& str, const DataDragon::ChampData& cd) {
return str << "[n: " << cd.name << " " << " k: " << cd.key << " id: " << cd.id << "]";
return str << "[n: " << cd.name.toStdString() << " " << " k: " << cd.key << " id: " << cd.id.toStdString() << "]";
}

View File

@ -7,7 +7,7 @@
#include "files.h"
DataDragonImageCache::DataDragonImageCache(const std::string& folderextra, const std::string& imageext) : imageext(imageext) {
DataDragonImageCache::DataDragonImageCache(const QString& folderextra, const QString& imageext) : imageext(imageext) {
// init cache dir
cacheDir = getCache() + folderextra + "/";
@ -15,21 +15,21 @@ DataDragonImageCache::DataDragonImageCache(const std::string& folderextra, const
}
DataDragonImageCache::~DataDragonImageCache() {}
bool DataDragonImageCache::hasImage(const std::string& name) {
QFile file(QString::fromStdString(getFilepath(name)));
bool DataDragonImageCache::hasImage(const QString& name) {
QFile file(getFilepath(name));
return file.size() > 1024; // a image with less than 1KiB? assume it would be readable (r-Permissions)
}
QPixmap DataDragonImageCache::getImage(const std::string& name) {
return QPixmap(QString::fromStdString(getFilepath(name)));
QPixmap DataDragonImageCache::getImage(const QString& name) {
return QPixmap(getFilepath(name));
}
void DataDragonImageCache::addImageRaw(const QByteArray& arr, const std::string& name) {
QFile file(QString::fromStdString(getFilepath(name)));
void DataDragonImageCache::addImageRaw(const QByteArray& arr, const QString& name) {
QFile file(getFilepath(name));
file.open(QIODevice::WriteOnly);
file.write(arr);
}
std::string DataDragonImageCache::getFilepath(const std::string& name) const {
QString DataDragonImageCache::getFilepath(const QString& name) const {
return cacheDir + name + imageext;
}

View File

@ -2,6 +2,8 @@
#include <sys/stat.h>
#include <QDir>
#include <Log.h>
#ifdef WIN32
@ -11,45 +13,31 @@
#endif
#ifdef WIN32
#include <QDir>
bool mkdirs(const std::string& path) {
return QDir::root().mkpath(QString::fromStdString(path));
}
std::string getHome() {
QString getHome() {
const char* homevar = getenv("appdata");
if(homevar == nullptr) {
Log::warn << "%appdata% is not set! Defaulting to ./";
qWarning() << "%appdata% is not set! Defaulting to ./";
return "./";
}
return std::string(homevar) + "/";
return QString(homevar) + "/";
}
#else
bool mkdirs(const std::string& path) {
size_t offset = 0;
while(offset < path.size()) {
offset = path.find('/', offset+1);
int res = mkdir(path.substr(0, offset).c_str(), S_IRWXU | S_IRWXG); // 770
if(res == -1 && errno != EEXIST) {
// mkdirs failed
return false;
}
}
return true;
}
std::string getHome() {
QString getHome() {
const char* homevar = getenv("HOME");
if(homevar == nullptr) {
Log::warn << "$HOME is not set! Defaulting to ./";
qWarning() << "$HOME is not set! Defaulting to ./";
return "./";
}
return std::string(homevar) + "/";
return QString(homevar) + "/";
}
#endif
std::string getCache() {
bool mkdirs(const QString& path) {
return QDir::root().mkpath(path);
}
QString getCache() {
return getHome() + CACHEPATH;
}

27
src/loadingwindow.cpp Normal file
View File

@ -0,0 +1,27 @@
#include "loadingwindow.h"
#include "ui_loadingwindow.h"
LoadingWindow::LoadingWindow(QWidget* parent) : QWidget(parent), ui(new Ui::LoadingWindow) {
ui->setupUi(this);
}
LoadingWindow::~LoadingWindow() {
delete ui;
}
void LoadingWindow::setChampion(QString championName) {
this->setText(LoadingWindow::tr("Loading Champion: %0").arg(championName));
}
void LoadingWindow::setText(QString text) {
ui->label->setText(text);
}
void LoadingWindow::setProgress(float val) {
ui->progressBar->setValue(val * 100);
}
void LoadingWindow::closeEvent(QCloseEvent* event) {
QWidget::closeEvent(event);
emit this->closed();
}

View File

@ -4,10 +4,14 @@
#include <thread>
#include <Log.h>
#include <QDebug>
LolAutoAccept::Stage::Stage() {}
LolAutoAccept::Stage::~Stage() {}
LolAutoAccept::LolAutoAccept(Config::RootConfig& config, DataDragon& dd, onfailed_func fail, onposchange_func onposch, onruneschange_func onrunch) : config(config), dd(dd), onPoschange(onposch), onRuneschange(onrunch), onFailed(fail) {
LolAutoAccept::LolAutoAccept(Config::RootConfig& config, DataDragon& dd, QObject* parent) : QObject(parent), config(config), dd(dd) {
qRegisterMetaType<LolAutoAccept::Status>();
std::lock_guard lock(stagesMutex);
stages.resize(3); // accept, ban, pick
}
@ -18,22 +22,22 @@ LolAutoAccept::~LolAutoAccept() {
void LolAutoAccept::setChamps(const std::vector<uint32_t>& champs, State s) {
if(s == State::LOBBY || s >= State::PICK) {
Log::warn << "setChamps() called on invalid State";
qWarning() << "setChamps() called on invalid State";
return;
}
Log::debug << "LolAutoAccept::setChamps";
qDebug() << "LolAutoAccept::setChamps";
{
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();
qInfo() << "set champs on state: " << (int) s << " count: " << champs.size();
}
void LolAutoAccept::setEnabled(bool b, State s) {
if(s >= State::PICK) {
Log::warn << "setEnabled() called on invalid State";
if(s > State::PICK) {
qWarning() << "setEnabled() called on invalid State";
return;
}
@ -52,7 +56,7 @@ bool LolAutoAccept::init() {
if(ca) {
clientapi = std::make_shared<ClientAPI>(*ca.get());
auto selfinfo = clientapi->getSelf();
Log::info << "selfinfo: gameName: " << selfinfo.gameName << " name: " << selfinfo.name << " summonerid: " << selfinfo.summonerid << " statusMessage: " << selfinfo.statusMessage << " puuid: " << selfinfo.puuid << " level: " << selfinfo.level;
qInfo() << "selfinfo: gameName: " << selfinfo.gameName << " name: " << selfinfo.name << " summonerid: " << selfinfo.summonerid << " statusMessage: " << selfinfo.statusMessage << " puuid: " << selfinfo.puuid << " level: " << selfinfo.level;
}
return (bool) clientapi;
@ -71,6 +75,10 @@ void LolAutoAccept::stop() {
shouldrun = false;
}
LolAutoAccept::Status LolAutoAccept::getStatus() {
return shouldrun ? Status::Running : Status::Off;
}
void LolAutoAccept::reload() {
Log::note << "reload LolAutoAccept";
if(currentPositionSet)
@ -81,7 +89,7 @@ const std::vector<RuneAspekt>& LolAutoAccept::getRuneAspekts() {
if(runeaspekts.empty()) {
if(clientapi) {
runeaspekts = clientapi->getAllRuneAspekts();
Log::info << "Loaded " << runeaspekts.size() << " rune aspekts";
qInfo() << "Loaded " << runeaspekts.size() << " rune aspekts";
}
}
@ -92,19 +100,20 @@ const std::vector<RuneStyle>& LolAutoAccept::getRuneStyles() {
if(runestyles.empty()) {
if(clientapi) {
runestyles = clientapi->getAllRuneStyles();
Log::info << "Loaded " << runestyles.size() << " rune styles";
qInfo() << "Loaded " << runestyles.size() << " rune styles";
}
}
return runestyles;
}
void LolAutoAccept::applyRunes() {
nextApplyRunes = true;
}
void LolAutoAccept::setOnRuneChangeFunc(onruneschange_func on) {
onRuneschange = on;
void LolAutoAccept::setAutoWriteText(bool enabled, const QString& text) {
if ( enabled && !autoWriteTextEnabled ) {
// only re-write on rising edge
autoWriteTextDone = false;
}
autoWriteTextEnabled = enabled;
autoWriteText = text;
}
void LolAutoAccept::stopJoinThread() {
@ -119,32 +128,31 @@ void LolAutoAccept::stopJoinThread() {
void LolAutoAccept::innerRun() {
shouldrun = true;
auto convs = clientapi->getAllConversations();
Log::info << "got " << convs.size() << " conversations";
try {
auto convs = clientapi->getAllConversations();
qInfo() << "got " << convs.size() << " conversations";
emit statusChanged(Status::Running);
while(shouldrun) {
uint32_t extrasleep = 800;
auto start = std::chrono::high_resolution_clock::now();
auto phase = clientapi->getGameflowPhase();
Log::info << "current Gameflowphase: " << phase;
qInfo() << "current Gameflowphase: " << phase;
// do processing
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();
Log::info << "readychack state: " << state;
qInfo() << "readychack state: " << state;
if(state == ClientAPI::ReadyCheckState::INPROGRESS) {
Log::info << "auto accepting";
qInfo() << "auto accepting";
clientapi->acceptMatch();
}
}
@ -156,23 +164,18 @@ void LolAutoAccept::innerRun() {
} 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();
@ -182,8 +185,9 @@ void LolAutoAccept::innerRun() {
std::this_thread::sleep_for(std::chrono::milliseconds(400 + extrasleep));
}
emit statusChanged(Status::Off);
} catch(RestClient::WebException& e) {
Log::error << "WebException catched: " << e.curlresponse;
qCritical() << "WebException catched: " << e.curlresponse;
if(e.curlresponse == CURLE_COULDNT_CONNECT) {
// free clientapi
clientapi.reset();
@ -191,34 +195,30 @@ void LolAutoAccept::innerRun() {
// disable this thread
shouldrun = false;
// notify the ui
if(onFailed) {
onFailed();
}
}
// notify the ui
emit statusChanged(Status::Failed);
}
}
void LolAutoAccept::resetAllOffsets() {
void LolAutoAccept::resetPickOffsets() {
for(Stage& stage : stages) {
stage.currentOffset = 0;
}
currentPosition = Position::INVALID;
currentPositionSet = false;
lastPickedChamp = 0;
chatid.clear();
}
void LolAutoAccept::resetRunes() {
if(onRuneschange) {
onRuneschange({});
}
nextApplyRunes = false;
void LolAutoAccept::resetAllOffsets() {
resetPickOffsets();
currentPosition = Position::INVALID;
currentPositionSet = false;
chatid.clear();
autoWriteTextDone = false;
}
void LolAutoAccept::applyConfigToStage(Stage& stage, const Config::StageConfig& stageconf) {
stage.champids = dd.resolveChampIDs(stageconf.champs);
stage.enabled = stage.enabled;
stage.enabled = stageconf.enabled;
stage.currentOffset = 0;
}
@ -246,8 +246,8 @@ uint32_t LolAutoAccept::getChampOfState(State s) {
uint32_t size = stage.champids.size();
if(stage.currentOffset >= size) {
// no champ to try left
Log::warn << "no champ left at stage: " << (int) s;
Log::warn << "stage size: " << stage.champids.size();
qWarning() << "no champ left at stage: " << (int) s;
qWarning() << "stage size: " << stage.champids.size();
return 0;
}
@ -264,8 +264,8 @@ void LolAutoAccept::nextChampOfState(State s) {
if(stage.currentOffset >= size) {
// no champ to try left
Log::warn << "no champ left at stage: " << (int) s;
Log::warn << "stage size: " << stage.champids.size();
qWarning() << "no champ left at stage: " << (int) s;
qWarning() << "stage size: " << stage.champids.size();
stage.currentOffset = 0;
return;
@ -275,7 +275,7 @@ void LolAutoAccept::nextChampOfState(State s) {
bool LolAutoAccept::isChampIntentofTeammate(uint32_t champid, const ClientAPI::ChampSelectSession& session) {
for(const ClientAPI::ChampSelectCell& player : session.myTeam) {
if(player.championID == (int32_t) champid || player.championPickIntentID == (int32_t) champid) {
Log::info << "player " << player.cellID << " @ " << player.position << " wants to play " << champid;
qInfo() << "player " << player.cellID << " @ " << toString(player.position) << " wants to play " << champid;
return true;
}
}
@ -295,7 +295,7 @@ LolAutoAccept::ownactions_t LolAutoAccept::getOwnActions(int32_t cellid, const s
ownactions_t out;
for(const auto& it : actions) {
if(it.actorCellID == cellid) {
Log::debug << "ownaction: id: " << it.id << " champid: " << it.championID << " completed: " << it.completed << " type: " << it.type;
qDebug() << "ownaction: id: " << it.id << " champid: " << it.championID << " completed: " << it.completed << " type: " << it.type;
if(!it.completed) { // completed cant be interacted anyways, so just ignore them.
out.push_back(it);
}
@ -319,9 +319,14 @@ void LolAutoAccept::pickPhase(const ownactions_t& ownactions) {
}
void LolAutoAccept::phase(const ownactions_t& ownactions, ClientAPI::ChampSelectActionType type, State s, bool complete, std::function<bool(uint32_t)> filter) {
if ( !( stages.at((int) s).enabled ) ) {
qDebug() << (int) s << " stage is disabled. skipping";
return;
}
for(auto it : ownactions) {
if(it.type == type) {
Log::info << type << " action anvailable: " << it.id << " champid: " << it.championID;
qInfo() << type << " action anvailable: " << it.id << " champid: " << it.championID;
uint32_t champid = getChampOfState(s);
if(filter) {
@ -333,9 +338,9 @@ void LolAutoAccept::phase(const ownactions_t& ownactions, ClientAPI::ChampSelect
}
}
if(it.championID != (int32_t) champid || !it.completed) {
if((it.championID != (int32_t) champid || !it.completed) && champid != 0) {
// try to prepick a champion
Log::info << "try to pick champ: " << champid;
qInfo() << "try to pick champ: " << champid;
if(!clientapi->setChampSelectAction(it.id, champid, complete)) {
nextChampOfState(s);
@ -347,15 +352,15 @@ void LolAutoAccept::phase(const ownactions_t& ownactions, ClientAPI::ChampSelect
}
int32_t LolAutoAccept::getBestRunePage(const std::vector<ClientAPI::RunePage>& pages) {
Log::debug << "searching RunePages: " << pages.size();
qDebug() << "searching RunePages: " << pages.size();
for(uint32_t i = 0; i < pages.size(); ++i) {
Log::debug << i << ": " << pages[i].id << " " << pages[i].name << " " << pages[i].isCurrent;
qDebug() << i << ": " << pages[i].id << " " << pages[i].name << " " << pages[i].isCurrent;
}
// search for a rune page with a name that starts with "AA: "
for(uint32_t i = 0; i < pages.size(); ++i) {
const ClientAPI::RunePage& rp = pages.at(i);
if(rp.name.size() >= 4 && rp.name.substr(0, 4) == "AA: ") {
if(rp.name.size() >= 4 && rp.name.left(4) == "AA: ") {
return i;
}
}
@ -378,7 +383,12 @@ int32_t LolAutoAccept::getMatchingRunePage(const RunePage& rp, const std::vector
void LolAutoAccept::champSelect() {
auto session = clientapi->getChampSelectSession();
int32_t cellid = session.localPlayerCellId;
const int32_t cellid = session.localPlayerCellId;
if(cellid != lastCellId && lastCellId != -1) {
resetPickOffsets();
}
lastCellId = cellid;
// find own cellid info
const ClientAPI::ChampSelectCell* me = nullptr;
@ -395,34 +405,25 @@ void LolAutoAccept::champSelect() {
// check if runes need adjustment
if(pickedChamp != lastPickedChamp) {
Log::info << "picked champ changed from: " << lastPickedChamp << " to: " << pickedChamp;
qInfo() << "picked champ changed from: " << lastPickedChamp << " to: " << pickedChamp;
lastPickedChamp = pickedChamp;
// update runes
if(onRuneschange) {
auto champinfo = blitzapi.getChampionInfo(pickedChamp, pos); // TODO: add detection for enemy champ
Log::info << "champinfo aquired: " << champinfo.runepage;
onRuneschange(champinfo.runepage);
}
}
// reload config based on position if changed
if(pos != currentPosition) {
if(pos != currentPosition || !currentPositionSet) {
Log::note << "LolAutoAccept reloading config for position: " << pos << " because it was: " << currentPosition;
loadPosition(pos);
if(onPoschange) {
onPoschange(pos);
}
emit positionChanged(pos);
}
Log::debug << "cellid: " << cellid << " position: " << pos << " counter: " << session.counter << " timer: timeleftip: " << session.timer.adjustedTimeLeftInPhase << " totaltimephase: " << session.timer.totalTimeInPhase;
qDebug() << "cellid: " << cellid << " position: " << toString(pos) << " counter: " << session.counter << " timer: timeleftip: " << session.timer.adjustedTimeLeftInPhase << " totaltimephase: " << session.timer.totalTimeInPhase;
// find actions for own cell
auto ownactions = getOwnActions(cellid, session.actions);
Log::debug << "ownactions: " << ownactions.size();
qDebug() << "ownactions: " << ownactions.size();
// try to prepick champ
Log::info << "champselectphase: " << session.timer.phase;
qInfo() << "champselectphase: " << session.timer.phase;
std::lock_guard lock(stagesMutex);
if(session.timer.phase == ClientAPI::ChampSelectPhase::PLANNING) {
@ -439,15 +440,20 @@ void LolAutoAccept::champSelect() {
}
}
if(nextApplyRunes) {
applyRunes_internal(pickedChamp, pos);
// check for autowriteText
if(autoWriteTextEnabled && !autoWriteTextDone && !autoWriteText.isEmpty()) {
const QString& chatid = getChatid();
if(!chatid.isEmpty()) {
clientapi->sendMessage(chatid, autoWriteText);
autoWriteTextDone = true;
}
}
}
void LolAutoAccept::smiteWarning(const std::vector<ClientAPI::ChampSelectCell>& cells) {
uint32_t smiteCount = 0;
for(const ClientAPI::ChampSelectCell& member : cells) {
Log::info << "position: " << member.position << " spells: " << member.spell1Id << " " << member.spell2Id;
qInfo() << "position: " << toString(member.position) << " spells: " << member.spell1Id << " " << member.spell2Id;
smiteCount += (member.spell1Id == 11 || member.spell2Id == 11);
}
@ -458,24 +464,24 @@ void LolAutoAccept::smiteWarning(const std::vector<ClientAPI::ChampSelectCell>&
return;
}
Log::info << "smite warning: " << smiteCount;
const std::string& chatid = getChatid();
if(!chatid.empty()) {
qInfo() << "smite warning: " << smiteCount;
const QString& chatid = getChatid();
if(!chatid.isEmpty()) {
clientapi->sendMessage(chatid, "smite");
lastMessageSent = currenttime;
}
}
}
const std::string& LolAutoAccept::getChatid() {
if(chatid.empty()) {
const QString& LolAutoAccept::getChatid() {
if(chatid.isEmpty()) {
std::vector<ClientAPI::Conversation> convs = clientapi->getAllConversations();
Log::info << "got " << convs.size() << " conversations";
qInfo() << "got " << convs.size() << " conversations";
for(const ClientAPI::Conversation& conv : convs) {
Log::info << " id: " << conv.id << " type: " << conv.type << " name: " << conv.name << " gameName: " << conv.gameName;
if(conv.type == "championSelect" && conv.name.empty()) {
Log::info << "groupchat found";
qInfo() << " id: " << conv.id << " type: " << conv.type << " name: " << conv.name << " gameName: " << conv.gameName;
if(conv.type == "championSelect" && conv.name.isEmpty()) {
qInfo() << "groupchat found";
chatid = conv.id;
return chatid;
}
@ -483,56 +489,3 @@ const std::string& LolAutoAccept::getChatid() {
}
return chatid; //might be empty string
}
void LolAutoAccept::applyRunes_internal(uint32_t champid, Position pos) {
nextApplyRunes = false;
Log::note << "apply runes";
// get recommended runes and stuff
auto champinfo = blitzapi.getChampionInfo(champid, pos);
Log::info << "fetched champion info runes: " << champinfo.runepage;
// choose page
auto pages = clientapi->getAllRunePages();
// check for page that allready contains the settings
int32_t choosepage = getMatchingRunePage(champinfo.runepage, pages);
if(choosepage != -1) {
ClientAPI::RunePage& page = pages.at(choosepage);
Log::info << "matching runepage found, selecting: " << page.id << " " << page.name;
if(clientapi->selectRunePage(page.id)) {
return;
}
Log::warn << "selecting runepage failed";
}
// find page to replace
int32_t pageoffset = getBestRunePage(pages);
if(pageoffset < 0) {
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: " + champname + " " + toShortString(pos); // TODO: make role "Utility" resolve to "Support"?
newpage.runepage = champinfo.runepage;
clientapi->editRunePage(newpage);
//select runepage
if(!rp.isCurrent) {
Log::info << "page is not selected, selecting now (id: " << newpage.id << ')';
clientapi->selectRunePage(newpage.id);
}
Log::info << "runepage done";
}

View File

@ -8,11 +8,12 @@
#include <QTranslator>
#include <Log.h>
#include <QDebug>
#include "arg.h"
#include "mainwindow.h"
#include "clientaccess.h"
#include "clientapi.h"
#include "mainwindow.h"
int main(int argc, char** argv) {
Log::init();
@ -25,24 +26,21 @@ int main(int argc, char** argv) {
if(args.debugLog) {
Log::setConsoleLogLevel(Log::Level::trace);
Log::addLogfile("log.txt", Log::Level::trace);
Log::debug << "debug Log enabled";
qDebug() << "debug Log enabled";
}
Log::info << "Hello, World!";
Log::note << "Using Locale: " << QLocale().name().toStdString();
qInfo() << "Hello, World!";
qInfo() << "Using Locale: " << QLocale().name();
QApplication app(argc, argv);
QTranslator translator;
if(translator.load(QLocale().name(), ":/ts")) {
if(translator.load(QLocale().name(), ":/i18n")) {
app.installTranslator(&translator);
} else {
Log::warn << "translation not found";
qWarning() << "translation not found";
}
MainWindow win;
QIcon icon(":/lolautoaccept.png");
win.setWindowIcon(icon);
win.show();
int ret = app.exec();
Log::stop();

View File

@ -1,25 +1,35 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QApplication>
#include <QTimer>
#include <Log.h>
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), dd(QLocale().name().toStdString()),
lolaa(conf.getConfig(), dd, std::bind(&MainWindow::onFail, this), std::bind(&MainWindow::onPosChange, this, std::placeholders::_1)) {
#include "loadingwindow.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), loading(true), ui(new Ui::MainWindow), saveTimer(new QTimer(this)), dd(QLocale().name()),
lolaa(conf.getConfig(), dd), lwin(new LoadingWindow(nullptr)) {
ui->setupUi(this);
lolaa.setOnRuneChangeFunc(std::bind(&RuneDisplay::setRunes, ui->runedisplay, std::placeholders::_1));
QObject::connect(&dd, &DataDragon::fetchingChamp, lwin, &LoadingWindow::setChampion);
QObject::connect(&dd, &DataDragon::loading, lwin, &LoadingWindow::setProgress);
QObject::connect(&dd, &DataDragon::loading, this, &MainWindow::loadingStatus);
QObject::connect(lwin, &LoadingWindow::closed, &dd, &DataDragon::stop);
QObject::connect(lwin, &LoadingWindow::closed, qApp, &QCoreApplication::quit, Qt::ConnectionType::QueuedConnection);
dd.startThread();
QObject::connect(&lolaa, &LolAutoAccept::statusChanged, this, &MainWindow::lolaaStatusChanged);
QObject::connect(&lolaa, &LolAutoAccept::positionChanged, this, &MainWindow::onPosChange);
saveTimer->setInterval(std::chrono::minutes(1));
saveTimer->setSingleShot(true);
QObject::connect(saveTimer, &QTimer::timeout, this, &MainWindow::saveConfig);
ui->copyrightlabel->setText(ui->copyrightlabel->text().arg(LOLAA_VERSION));
conf.load();
// 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) ));
}
ui->enableAll->setChecked(rc.enabledAutoAccept);
lolaa.setEnabled(rc.enabledAutoAccept, LolAutoAccept::State::LOBBY);
@ -27,84 +37,148 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
ui->enableSmiteWarning->setChecked(rc.enabledSmiteWarn);
lolaa.setSmiteWarn(rc.enabledSmiteWarn);
ui->enableAutoWrite->setChecked(rc.enabledAutoWrite);
ui->autoWriteText->setText(rc.autoWriteText);
lolaa.setAutoWriteText(rc.enabledAutoWrite, rc.autoWriteText);
resizeEvent(nullptr);
lwin->show();
}
MainWindow::~MainWindow() {
lolaa.stop();
conf.save();
delete ui;
delete this->ui;
}
void MainWindow::closeEvent([[maybe_unused]] QCloseEvent* event) {
lolaa.stop();
conf.save();
}
void MainWindow::resizeEvent([[maybe_unused]] QResizeEvent *event) {
ui->verticalLayoutWidget->setMinimumSize(ui->centralwidget->size());
ui->verticalLayoutWidget->setMaximumSize(ui->centralwidget->size());
ui->verticalLayoutWidget->setMinimumSize(ui->centralwidget->size());
void MainWindow::resetSaveTimer() {
saveTimer->start();
qDebug() << "resetTimer";
}
void MainWindow::loadingStatus(float f) {
if(f >= 1.0 && lwin) {
// loading complete
// 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, &SettingsTab::changed, this, &MainWindow::tabchanged);
QObject::connect(tab, &SettingsTab::toggled, this, &MainWindow::tabtoggled);
}
// load runepage images
ui->runesPage->setDataDragon(dd);
ui->runesPage->setConfig(conf);
// switch from loading window to main window
lwin->hide();
this->show();
lwin->deleteLater();
lwin = nullptr;
// a timer to delay the loading flag a short time until all other signals are processed
QTimer::singleShot(std::chrono::milliseconds(1), this, &MainWindow::initDone);
}
}
void MainWindow::toggleMainswitch(bool state) {
Log::info << "mainswitch toggled: " << state;
qDebug() << "mainswitch toggled: " << state;
if(state) {
ui->mainswitch->setCheckState(Qt::CheckState::PartiallyChecked);
ui->mainswitch->setEnabled(false);
// make sure the changes to the mainswitch are rendered, before going into the blocking call
QCoreApplication::processEvents();
// TODO: make this non blocking
if(!lolaa.init()) {
Log::error << "League Client not found!";
qCritical() << "League Client not found!";
ui->statusbar->showMessage(tr("League of Legends Client not found!"));
ui->mainswitch->setCheckState(Qt::CheckState::Unchecked);
ui->mainswitch->setEnabled(true);
return;
}
ui->runedisplay->setRuneMeta(lolaa.getRuneAspekts());
ui->runedisplay->setStyles(lolaa.getRuneStyles());
lolaa.run();
ui->statusbar->showMessage(tr("Auto-Acceptor started!"));
} else {
lolaa.stop();
ui->statusbar->showMessage(tr("Auto-Acceptor stoped!"));
ui->mainswitch->setCheckState(Qt::CheckState::PartiallyChecked);
ui->mainswitch->setEnabled(false);
}
}
void MainWindow::aatoggled(bool state) {
Log::info << "enableAll checkbox toggled " << state;
if( loading ) return;
qDebug() << "enableAll checkbox toggled " << state;
lolaa.setEnabled(state, LolAutoAccept::State::LOBBY);
conf.getConfig().enabledAutoAccept = state;
resetSaveTimer();
}
void MainWindow::smitewarntoggled(bool state) {
Log::info << "smitewarn checkbox toggled " << state;
if( loading ) return;
qDebug() << "smitewarn checkbox toggled " << state;
lolaa.setSmiteWarn(state);
conf.getConfig().enabledSmiteWarn = state;
resetSaveTimer();
}
void MainWindow::tabtoggled(Position p, LolAutoAccept::State s, bool state) {
Log::info << "checkbox toggled " << state << " position: " << p << " state: " << (int) s;
if( loading ) return;
if(s == LolAutoAccept::State::LOBBY) {
lolaa.setEnabled(state, s);
}
qDebug() << "checkbox toggled " << state << " position: " << p << " state: " << (int) s;
lolaa.setEnabled(state, s);
lolaa.reload();
resetSaveTimer();
}
void MainWindow::tabchanged(Position p, LolAutoAccept::State s) {
Log::info << "edited position: " << p << " state: " << (int) s;
if( loading ) return;
qDebug() << "edited position: " << p << " state: " << (int) s;
lolaa.reload();
resetSaveTimer();
}
void MainWindow::applyRunes() {
Log::info << "applyRunes pressed";
void MainWindow::autoWriteChanged() {
if( loading ) return;
lolaa.applyRunes();
bool enabled = ui->enableAutoWrite->isChecked();
const QString text = ui->autoWriteText->toPlainText();
lolaa.setAutoWriteText(enabled, text);
conf.getConfig().enabledAutoWrite = enabled;
conf.getConfig().autoWriteText = text;
resetSaveTimer();
}
void MainWindow::saveConfig() {
conf.save();
}
void MainWindow::initDone() {
loading = false;
qDebug() << "loading done";
}
void MainWindow::onPosChange(Position newpos) {
@ -113,8 +187,21 @@ void MainWindow::onPosChange(Position newpos) {
emit requestTabChange((int) newpos);
}
void MainWindow::onFail() {
ui->mainswitch->setChecked(false);
ui->statusbar->showMessage(tr("Auto-Acceptor failed!"));
}
void MainWindow::lolaaStatusChanged(LolAutoAccept::Status status) {
qDebug() << "new status: " << (int) status;
switch(status) {
case LolAutoAccept::Status::Off:
this->ui->statusbar->showMessage(tr("Auto-Acceptor stoped!"));
break;
case LolAutoAccept::Status::Running:
this->ui->statusbar->showMessage(tr("Auto-Acceptor started!"));
break;
case LolAutoAccept::Status::Failed:
this->ui->statusbar->showMessage(tr("Auto-Acceptor failed!"));
break;
}
this->ui->mainswitch->setEnabled(true);
this->ui->mainswitch->setChecked(status == LolAutoAccept::Status::Running);
}

View File

@ -5,7 +5,7 @@
MemoryImageCache::MemoryImageCache(size_t maxsize) : maxsize(maxsize) {}
void MemoryImageCache::addImage(QPixmap img, const std::string& title, int type) {
void MemoryImageCache::addImage(QPixmap img, const QString& title, int type) {
auto it = std::find_if(cache.begin(), cache.end(), getImageMatcher(title, type));
if(it == cache.end()) {
// insert new
@ -19,7 +19,7 @@ void MemoryImageCache::addImage(QPixmap img, const std::string& title, int type)
it->imageref = img;
}
QPixmap MemoryImageCache::getImage(const std::string& title, int type) {
QPixmap MemoryImageCache::getImage(const QString& title, int type) {
auto it = std::find_if(cache.begin(), cache.end(), getImageMatcher(title, type));
if(it == cache.end()) {
return {};
@ -40,7 +40,7 @@ bool MemoryImageCache::CachedImage::operator<(const MemoryImageCache::CachedImag
return lastaccessed < other.lastaccessed;
}
std::function<bool(const MemoryImageCache::CachedImage&)> MemoryImageCache::getImageMatcher(const std::string& title, int type) {
std::function<bool(const MemoryImageCache::CachedImage&)> MemoryImageCache::getImageMatcher(const QString& title, int type) {
return [title, type](const MemoryImageCache::CachedImage& img) -> bool {
return img.type == type && img.title == title;
};

View File

@ -63,7 +63,7 @@ static int my_trace(CURL* handle, curl_infotype type, char* data, size_t size, v
return 0;
}
RestClient::RestClient(const std::string& base) : baseurl(base) {
RestClient::RestClient(const QString& base) : baseurl(base) {
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, arrayWriteCallback);
@ -77,13 +77,15 @@ RestClient::~RestClient() {
RestClient::WebException::WebException(CURLcode c) : curlresponse(c) {
}
QByteArray RestClient::requestRaw(const std::string& url, Method m, const std::string& data) {
QByteArray RestClient::requestRaw(const QString& url, Method m, const QString& data) {
if (!curl) return {};
std::string requrl = baseurl + url;
curl_easy_setopt(curl, CURLOPT_URL, requrl.c_str());
QString requrl = baseurl + url;
const QByteArray reqArr = requrl.toLocal8Bit();
curl_easy_setopt(curl, CURLOPT_URL, reqArr.data());
curl_easy_setopt(curl, CURLOPT_USERPWD, basicauth.c_str());
const QByteArray basicArr = basicauth.toLocal8Bit();
curl_easy_setopt(curl, CURLOPT_USERPWD, basicArr.data());
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
if (disableCertCheck) {
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
@ -99,6 +101,7 @@ QByteArray RestClient::requestRaw(const std::string& url, Method m, const std::s
struct curl_slist* headerlist = NULL;
headerlist = curl_slist_append(headerlist, "Accept: application/json");
const QByteArray dataArr = data.toLocal8Bit();
switch (m) {
default:
@ -106,21 +109,16 @@ QByteArray RestClient::requestRaw(const std::string& url, Method m, const std::s
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L); break;
case Method::POST:
curl_easy_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data.c_str());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, dataArr.data());
headerlist = curl_slist_append(headerlist, "Content-Type: application/json");
break;
case Method::PUT:
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT"); // to use the POSTFIELDS (do not use CURLOPT_PUT, it does not support POSTFIELDS)
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data.c_str());
headerlist = curl_slist_append(headerlist, "Content-Type: application/json");
break;
case Method::PATCH:
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PATCH");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data.c_str());
case Method::DELETE:
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, toString(m)); // to use the POSTFIELDS (do not use CURLOPT_PUT, it does not support POSTFIELDS)
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, dataArr.data());
headerlist = curl_slist_append(headerlist, "Content-Type: application/json");
break;
//case Method::DELETE:
// curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE"); break;
}
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
@ -138,9 +136,9 @@ QByteArray RestClient::requestRaw(const std::string& url, Method m, const std::s
if (res == CURLE_HTTP_RETURNED_ERROR) {
long responsecode = -1;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &responsecode);
Log::warn << "API request failed: " << baseurl << " " << url << " -> " << responsecode;
qWarning() << "API request failed: " << baseurl << " " << url << " -> " << responsecode;
} else {
Log::warn << "API request failed: " << baseurl << " " << url << " " << curl_easy_strerror(res);
qWarning() << "API request failed: " << baseurl << " " << url << " " << curl_easy_strerror(res);
if(res == CURLE_COULDNT_CONNECT) {
throw WebException(res);
}
@ -150,14 +148,14 @@ QByteArray RestClient::requestRaw(const std::string& url, Method m, const std::s
return ba;
}
QJsonDocument RestClient::request(const std::string& url, Method m, const std::string& data) {
QJsonDocument RestClient::request(const QString& url, Method m, const QString& data) {
QByteArray arr = requestRaw(url, m, data);
if (arr.isEmpty()) return {};
QJsonParseError err;
QJsonDocument parsed = QJsonDocument::fromJson(arr, &err);
if (parsed.isNull() || err.error != QJsonParseError::NoError) {
Log::error << "API Json parse error " << err.errorString().toStdString() << " offset: " << err.offset;
qCritical() << "API Json parse error " << err.errorString() << " offset: " << err.offset;
return {};
}
@ -175,9 +173,15 @@ void RestClient::enableDebugging(bool enabled) {
}
}
std::string RestClient::escape(const std::string& in) const {
char* e = curl_easy_escape(curl, in.c_str(), in.length());
std::string esc(e);
QString RestClient::escape(const QString& in) const {
char* e = curl_easy_escape(curl, in.toLocal8Bit().data(), in.length());
QString esc(e);
curl_free(e);
return esc;
}
const char* toString(RestClient::Method m) {
static const char* MethodNames[] = {"GET", "POST", "PUT", "PATCH", "DELETE"};
return MethodNames[(int) m];
}

55
src/runeaspektbutton.cpp Normal file
View File

@ -0,0 +1,55 @@
#include "runeaspektbutton.h"
#include "ui_runeaspektbutton.h"
#include <QDebug>
#include "runeaspektbuttongroup.h"
RuneAspektButton::RuneAspektButton(QWidget* parent) : QPushButton(parent), ui(new Ui::RuneAspektButton) {
ui->setupUi(this);
QObject::connect(this, &QPushButton::pressed, this, &RuneAspektButton::buttonPressed);
}
RuneAspektButton::~RuneAspektButton() {
delete this->ui;
}
void RuneAspektButton::setAspektId(uint32_t id) {
aspektId = id;
dataChanged();
}
void RuneAspektButton::setButtonGroup(RuneAspektButtonGroup* group) {
this->group = group;
}
bool RuneAspektButton::isSelected() const {
return group && group->getSelectedRunes().contains(aspektId);
}
void RuneAspektButton::buttonPressed() {
emit aspektToggled(aspektId);
}
void RuneAspektButton::dataChanged() {
bool selection = isSelected();
qDebug() << text() << " datachanged - isSelected: " << selection;
setShowSelection(selection);
}
void RuneAspektButton::checkSelection(uint32_t aspekt) {
qDebug() << "checkSelection: " << text() << aspekt << aspektId;
setShowSelection(aspekt == this->aspektId);
}
void RuneAspektButton::setShowSelection(bool selected) {
if(selected) {
setStyleSheet("border: 1px solid red;");
} else {
setStyleSheet("");
}
}

View File

@ -0,0 +1,73 @@
#include "runeaspektbuttongroup.h"
#include "runeaspektbutton.h"
#include <QDebug>
const int RuneAspektButtonGroup::INVALID_ASPEKT_ID = 0;
RuneAspektButtonGroup::RuneAspektButtonGroup(QObject* parent, uint32_t size) : QObject(parent), selectedRune(), size(size) {
selectedRune.reserve(size*2);
}
RuneAspektButtonGroup::~RuneAspektButtonGroup() {}
void RuneAspektButtonGroup::addButton(RuneAspektButton* button) {
QObject::connect(this, &RuneAspektButtonGroup::changed, button, &RuneAspektButton::dataChanged);
QObject::connect(button, &RuneAspektButton::aspektToggled, this, &RuneAspektButtonGroup::buttonPressed);
button->setButtonGroup(this);
}
void RuneAspektButtonGroup::setSelectedRunes(const QVector<int>& newRunes) {
selectedRune = newRunes;
qDebug() << "selectedRunes changed to: " << selectedRune << " refesching buttons";
emit changed();
}
void RuneAspektButtonGroup::setSubgroups(const QVector<QVector<int>>& newSubgroups) {
subgroups = newSubgroups;
}
void RuneAspektButtonGroup::buttonPressed(int aspektId) {
if(selectedRune.contains(aspektId)) {
selectedRune.removeAll(aspektId);
} else {
// check subgroups first
int otherSubgroupMember = getOtherSubgroupMemeber(aspektId);
if(otherSubgroupMember != INVALID_ASPEKT_ID) {
// collision in subgroup -> remove other member
selectedRune.removeAll(otherSubgroupMember);
}
selectedRune.push_back(aspektId);
if((uint32_t) selectedRune.size() > size) {
selectedRune.removeFirst();
}
}
emit changed();
}
int RuneAspektButtonGroup::getOtherSubgroupMemeber(int aspektId) {
if(subgroups.empty()) {
return INVALID_ASPEKT_ID;
}
for(const QVector<int>& subgroup : subgroups) {
if(subgroup.contains(aspektId)) {
for(const int& subgroupMember : subgroup) {
if(aspektId != subgroupMember && selectedRune.contains(subgroupMember)) {
return subgroupMember;
}
}
break;
}
}
return INVALID_ASPEKT_ID;
}

View File

@ -1,9 +1,9 @@
#include "runedisplay.h"
#include "ui_runedisplay.h"
#include <sstream>
#include <QTextStream>
const static std::string EMPTY;
const static QString EMPTY;
RuneDisplay::RuneDisplay(QWidget *parent) : QWidget(parent), ui(new Ui::RuneDisplay) {
ui->setupUi(this);
@ -32,10 +32,11 @@ void RuneDisplay::applyRunesClicked() {
}
void RuneDisplay::updateText() {
std::ostringstream out;
QString outStr;
QTextStream out(&outStr);
if(! (bool) runepage) {
ui->runetext->setText(QString::fromStdString(""));
ui->runetext->setText("");
ui->applyRunesBtn->setEnabled(false);
return;
}
@ -45,24 +46,24 @@ void RuneDisplay::updateText() {
for(uint32_t rune : runepage.selectedAspects) {
out << getRuneText(rune) << '\n';
}
ui->runetext->setText(QString::fromStdString(out.str()));
ui->runetext->setText(outStr);
ui->applyRunesBtn->setEnabled(true);
}
std::string RuneDisplay::getRuneText(uint32_t id) {
QString RuneDisplay::getRuneText(uint32_t id) {
for(const RuneAspekt& ra : runeinfo) {
if(ra.id == id) {
return ra.name;
}
}
return "(" + std::to_string(id) + ")";
return "(" + QString::number(id) + ")";
}
std::string RuneDisplay::getRuneStyleByID(uint32_t id) {
QString RuneDisplay::getRuneStyleByID(uint32_t id) {
auto it = std::find_if(runestyles.begin(), runestyles.end(), [id](const RuneStyle& rs) { return rs.id == id; });
if(it == runestyles.end()) {
return '(' + std::to_string(id) + ')';
return '(' + QString::number(id) + ')';
}
return it->name;

279
src/runeeditor.cpp Normal file
View File

@ -0,0 +1,279 @@
#include "runeeditor.h"
#include "ui_runeeditor.h"
#include <QByteArray>
#include <QDebug>
#include <QGridLayout>
#include <QPixmap>
#include <QPushButton>
#include "clientapi.h"
#include "runeaspektbutton.h"
#include "runeaspektbuttongroup.h"
RuneEditor::RuneEditor(QWidget* parent) : QDialog(parent), ui(new Ui::RuneEditor), groups(8, nullptr) {
ui->setupUi(this);
QObject::connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &RuneEditor::accept);
QObject::connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &RuneEditor::reject);
}
RuneEditor::~RuneEditor() {
delete this->ui;
}
void RuneEditor::setClient(ClientAPI& client) {
this->client = &client;
if(!this->client) return;
try {
// build ui
aspekts = client.getAllRuneAspekts();
styles = client.getAllRuneStyles();
for(const RuneStyle& rs : styles) {
RuneAspektButton* runeStyleBtn = createStyleButton(rs, rs.id == runepage.primaryStyle);
if(!runeStyleBtn) continue;
QObject::connect(runeStyleBtn, &QPushButton::pressed, [this, id = rs.id](){
selectStyle(id);
});
QObject::connect(this, &RuneEditor::selectPrimary, runeStyleBtn, &RuneAspektButton::checkSelection);
ui->style->addWidget(runeStyleBtn);
}
} catch(RestClient::WebException& e) {
qCritical() << "webexception: " << e.curlresponse;
if(e.curlresponse == CURLE_COULDNT_CONNECT) {
this->client = nullptr;
}
}
}
void RuneEditor::setRunepage(const ::RunePage& rp) {
qInfo() << "runepage: " << rp.selectedAspects.size();
selectStyle(rp.primaryStyle);
selectSubStyle(rp.secondaryStyle);
runepage = rp;
uint32_t offset = 0;
for(RuneAspektButtonGroup* group : groups) {
if(!group) continue;
QVector<int> selected(group->getSize(), 0);
for(uint32_t i = 0; i < group->getSize(); ++i) {
selected.replace(i, rp.selectedAspects.at(offset));
offset++;
}
group->setSelectedRunes(selected);
}
emit selectionChanged();
}
void RuneEditor::selectStyle(uint32_t id) {
if(runepage.primaryStyle == id) return;
const RuneStyle* style = getRuneStyle(id);
if(style) {
runepage.primaryStyle = id;
runepage.secondaryStyle = 0;
runepage.selectedAspects.clear();
runepage.selectedAspects.resize(9, 0);
emit selectPrimary(id);
clearLayout(ui->substyle);
clearLayout(ui->stylePerks);
clearLayout(ui->substylePerks);
// populate substyles
for(int subStyleId : style->allowedSubStyles) {
const RuneStyle* substyle = getRuneStyle(subStyleId);
RuneAspektButton* subStyleBtn = createStyleButton(*substyle, false);
if(!subStyleBtn) continue;
QObject::connect(subStyleBtn, &QPushButton::pressed, [this, subStyleId](){
selectSubStyle(subStyleId);
});
QObject::connect(this, &RuneEditor::selectSecondary, subStyleBtn, &RuneAspektButton::checkSelection);
ui->substyle->addWidget(subStyleBtn);
}
// populate perks
fillRuneStyle(ui->stylePerks, *style);
}
}
void RuneEditor::selectSubStyle(uint32_t id) {
if(runepage.secondaryStyle == id) return;
const RuneStyle* substyle = getRuneStyle(id);
if(substyle) {
runepage.secondaryStyle = id;
emit selectSecondary(id);
clearLayout(ui->substylePerks);
delete groups.at(4);
QVector<QVector<int>> subgroups;
subgroups.reserve(substyle->runeSlots.size());
// populate perks
RuneAspektButtonGroup* group = new RuneAspektButtonGroup(this, 2);
for(size_t idx = 0; idx < substyle->runeSlots.size(); ++idx) {
const RuneStyleSlot& rss = substyle->runeSlots.at(idx);
QVector<int> subgroup;
subgroup.reserve(rss.perks.size());
if(rss.type != "kMixedRegularSplashable") continue;
for(int perkNr = 0; perkNr < (int) rss.perks.size(); ++perkNr) {
uint32_t perk = rss.perks.at(perkNr);
subgroup.append((int) perk);
RuneAspektButton* aspektBtn = createAspektButton(perk);
if(!aspektBtn) continue;
group->addButton(aspektBtn);
ui->substylePerks->addWidget(aspektBtn, idx, perkNr);
}
subgroups.append(subgroup);
}
group->setSubgroups(subgroups);
groups.replace(4, group);
}
}
void RuneEditor::clearLayout(QLayout* layout) {
while(layout->count()) {
QLayoutItem* item = layout->takeAt(0);
delete item->widget();
delete item;
}
}
void RuneEditor::setName(QString text) {
ui->runepageName->setText(text);
}
QString RuneEditor::getName() const {
return ui->runepageName->text();
}
const RunePage& RuneEditor::getRunepage() {
runepage.selectedAspects.clear();
runepage.selectedAspects.resize(9, 0);
for(const RuneAspektButtonGroup* group : groups) {
if(!group) continue;
const QVector<int>& selected = group->getSelectedRunes();
for(uint32_t i = 0; i < group->getSize(); ++i) {
runepage.selectedAspects.push_back(selected.at(i));
}
}
return runepage;
}
const RuneStyle* RuneEditor::getRuneStyle(uint32_t id) const {
auto it = std::find_if(styles.cbegin(), styles.cend(), [id](const RuneStyle& rs) {
return rs.id == id;
});
return it == styles.cend() ? nullptr : &*it;
}
RuneAspektButton* RuneEditor::createStyleButton(const RuneStyle& rs, bool selected) {
RuneAspektButton* styleBtn = createButtonFromResource(rs.iconPath);
if(!styleBtn) return nullptr;
styleBtn->setText(rs.name);
styleBtn->setToolTip(rs.tooltip);
styleBtn->setAspektId(rs.id);
if(selected) {
styleBtn->setStyleSheet("border: 1px solid red;");
}
return styleBtn;
}
RuneAspektButton* RuneEditor::createAspektButton(uint32_t perk) {
auto itFound = std::find_if(aspekts.cbegin(), aspekts.cend(), [perk](const RuneAspekt& ra) {
return ra.id == perk;
});
if(itFound == aspekts.cend()) {
return nullptr;
}
RuneAspektButton* aspektBtn = createButtonFromResource(itFound->iconPath);
aspektBtn->setText(itFound->name);
aspektBtn->setToolTip(itFound->tooltip);
aspektBtn->setAspektId(itFound->id);
return aspektBtn;
}
RuneAspektButton* RuneEditor::createButtonFromResource(QString resource) {
if(!client) {
return nullptr;
}
QPixmap icon;
try {
icon = client->getImageResource(resource.remove(0, 1));
} catch(RestClient::WebException& e) {
qCritical() << "webexception: " << e.curlresponse;
if(e.curlresponse == CURLE_COULDNT_CONNECT) {
client = nullptr;
}
}
RuneAspektButton* rab = new RuneAspektButton(this);
rab->setIcon(icon);
return rab;
}
void RuneEditor::fillRuneStyle(QGridLayout* target, const RuneStyle& rs) {
for(size_t idx = 0; idx < rs.runeSlots.size(); ++idx) {
const RuneStyleSlot& rss = rs.runeSlots.at(idx);
RuneAspektButtonGroup* group = new RuneAspektButtonGroup(this, 1);
for(int perkNr = 0; perkNr < (int) rss.perks.size(); ++perkNr) {
uint32_t perk = rss.perks.at(perkNr);
RuneAspektButton* aspektBtn = createAspektButton(perk);
if(!aspektBtn) continue;
group->addButton(aspektBtn);
target->addWidget(aspektBtn, idx, perkNr);
}
groups.replace(idx + (idx > 3), group);
}
}
QString RuneEditor::fixString(QString text) {
return text.replace("&nbsp;", "").replace("</?.*?>", "");
}

252
src/runemanager.cpp Normal file
View File

@ -0,0 +1,252 @@
#include "runemanager.h"
#include "ui_runemanager.h"
#include <QDebug>
#include <QListWidgetItem>
#include <QTimer>
#include "clientapi.h"
RuneManager::RuneManager(QWidget* parent) : QWidget(parent), ui(new Ui::RuneManager) {
ui->setupUi(this);
ui->listClientRunes->setIsClient(true);
ui->listaaRunes->setIsClient(false);
ui->listClientRunes->setOther(ui->listaaRunes);
ui->listaaRunes->setOther(ui->listClientRunes);
QObject::connect(ui->listaaRunes, &RunePageList::runepageChanged, this, &RuneManager::saveRunePageAA);
QObject::connect(ui->listClientRunes, &RunePageList::runepageChanged, this, &RuneManager::saveRunePageClient);
QObject::connect(ui->listaaRunes, &RunePageList::runepageDeleted, this, &RuneManager::deleteRunepageAA);
QObject::connect(ui->listClientRunes, &RunePageList::runepageDeleted, this, &RuneManager::deleteRunepageClient);
QObject::connect(ui->chkAutoCopy, &QCheckBox::clicked, this, &RuneManager::autoSyncToggled);
initialLoadTimer = new QTimer(this);
QObject::connect(initialLoadTimer, &QTimer::timeout, this, &RuneManager::loadRunes);
initialLoadTimer->setInterval(std::chrono::milliseconds(1));
initialLoadTimer->setSingleShot(true);
initialLoadTimer->start();
}
RuneManager::~RuneManager() {
delete this->ui;
}
void RuneManager::setConfig(Config& config) {
this->config = &config;
Config::GeneralRunePageConfig& rpc = config.getConfig().runepagesConfig;
ui->listaaRunes->loadRunePages(rpc.runePages);
ui->chkAutoCopy->setChecked(rpc.autoSync);
if(rpc.autoSync) {
syncRunes();
}
}
void RuneManager::setDataDragon(DataDragon& dd) {
ui->listaaRunes->setDataDragon(dd);
ui->listClientRunes->setDataDragon(dd);
}
void RuneManager::loadRunes() {
if(initialLoadTimer) {
initialLoadTimer->deleteLater();
initialLoadTimer = nullptr;
}
this->ui->btnRetry->setEnabled(false);
QCoreApplication::processEvents();
if(!client) {
auto ca = ClientAccess::find();
if(ca) {
client = std::make_shared<ClientAPI>(*ca.get());
}
}
if(client) {
try {
// load meta data
runeInfo = client->getAllRuneAspekts();
QCoreApplication::processEvents();
runeStyles = client->getAllRuneStyles();
QCoreApplication::processEvents();
ui->listClientRunes->setClient(*client);
ui->listaaRunes->setClient(*client);
this->ui->listClientRunes->setRuneInfos(runeInfo, runeStyles);
this->ui->listaaRunes->setRuneInfos(runeInfo, runeStyles);
// load runepages
const std::vector<ClientAPI::RunePage> runePages = client->getAllRunePages();
ui->listClientRunes->loadRunePages(runePages);
// reload runepages - so they ids can get their names
reloadAARunes();
// check if autosync is enabled
if(config && config->getConfig().runepagesConfig.autoSync) {
syncRunes();
}
} catch(RestClient::WebException& e) {
qCritical() << "webexception: " << e.curlresponse;
if(e.curlresponse == CURLE_COULDNT_CONNECT) {
client.reset();
}
}
}
setRunesEnabled(!!client); // cast to bool
this->ui->btnRetry->setEnabled(true);
}
void RuneManager::setRunesEnabled(bool enabled) {
this->ui->lblClientRunes->setEnabled(enabled);
this->ui->listClientRunes->setEnabled(enabled);
}
void RuneManager::saveRunePageClient(int id, QString name, const RunePage& rp) {
if(client) {
ClientAPI::RunePage newPage;
newPage.name = name;
newPage.runepage = rp;
newPage.id = id;
try {
if(id == -1) {
// create new page
if(!client->createRunePage(newPage)) {
// TODO: some error occured
}
} else {
// edit existing page
if(!client->editRunePage(newPage)) {
// TODO: some error occured
}
}
} catch(RestClient::WebException& e) {
qCritical() << "webexception: " << e.curlresponse;
if(e.curlresponse == CURLE_COULDNT_CONNECT) {
client.reset();
setRunesEnabled(false);
}
}
}
}
void RuneManager::saveRunePageAA(int id, QString name, const RunePage& rp) {
if(!config) return;
Config::RootConfig& rc = config->getConfig();
auto& pages = rc.runepagesConfig.runePages;
if(id == -1) {
// int newId = pages.size();
pages.push_back(std::make_shared<Config::RunePageConfig>(name, rp));
} else {
if((int) pages.size() > id && id >= 0) {
pages.at(id)->runepage = rp;
pages.at(id)->name = name;
} else {
// unkown id
qWarning() << "unknown runepage id:" << id;
}
}
config->save();
// reload runes
ui->listaaRunes->loadRunePages(pages);
}
void RuneManager::deleteRunepageClient(int id) {
if(client) {
try {
if(!client->deleteRunePage(id)) {
// TODO: some error occured
}
} catch(RestClient::WebException& e) {
qCritical() << "webexception: " << e.curlresponse;
if(e.curlresponse == CURLE_COULDNT_CONNECT) {
client.reset();
setRunesEnabled(false);
}
}
}
}
void RuneManager::deleteRunepageAA(int id) {
if(!config) return;
Config::RootConfig& rc = config->getConfig();
auto& pages = rc.runepagesConfig.runePages;
if((int) pages.size() > id && id >= 0) {
pages.erase(pages.begin() + id);
config->save();
ui->listaaRunes->loadRunePages(pages);
} else {
// unkown id
qWarning() << "unknown runepage id:" << id;
}
}
void RuneManager::autoSyncToggled() {
bool autoSync = (ui->chkAutoCopy->isChecked());
if(config) {
config->getConfig().runepagesConfig.autoSync = autoSync;
config->save();
}
if(autoSync) {
syncRunes();
}
}
void RuneManager::syncRunes() {
qInfo() << "syncing" << ui->listClientRunes->count() << "runes";
std::vector<std::shared_ptr<Config::RunePageConfig>>& configs = config->getConfig().runepagesConfig.runePages;
bool changed = false;
for(int i = 0; i < ui->listClientRunes->count(); ++i) {
const QListWidgetItem* item = ui->listClientRunes->item(i);
QString name = item->text();
const RunePage* rp = (RunePage*) item->data(RunePageList::RolePointer).toULongLong();
auto itFound = std::find_if(configs.cbegin(), configs.cend(), [name, rp](const std::shared_ptr<Config::RunePageConfig>& rpc){
return rpc->name == name && *rp == rpc->runepage;
});
if(itFound == configs.cend()) {
// no duplicate found -> add it
configs.push_back(std::make_shared<Config::RunePageConfig>(name, *rp));
changed = true;
}
}
if(changed) {
config->save();
ui->listaaRunes->loadRunePages(configs);
}
}
void RuneManager::reloadAARunes() {
if(!config) return;
const auto& pages = config->getConfig().runepagesConfig.runePages;
// reload runes
ui->listaaRunes->loadRunePages(pages);
}

View File

@ -1,7 +1,13 @@
#include "runepage.h"
#include <QJsonArray>
#include <algorithm>
#include "json.h"
RunePage::RunePage() {}
bool RunePage::operator==(const RunePage& rp) const {
if(primaryStyle == rp.primaryStyle && secondaryStyle == rp.secondaryStyle && selectedAspects.size() == rp.selectedAspects.size()) {
return std::is_permutation(selectedAspects.begin(), selectedAspects.end(), rp.selectedAspects.begin());
@ -13,6 +19,41 @@ RunePage::operator bool() const {
return primaryStyle != 0 && secondaryStyle != 0 && selectedAspects.size() == 9;
}
RunePage::operator QJsonObject() const {
QJsonObject obj;
obj.insert("primary", (int) primaryStyle);
obj.insert("secondary", (int) secondaryStyle);
QJsonArray aspects;
for(uint32_t aspect : selectedAspects) {
aspects.push_back((int) aspect);
}
obj.insert("aspects", aspects);
return obj;
}
RunePage::RunePage(const QJsonObject& obj) :
primaryStyle(getValue(obj, "primary", 0)),
secondaryStyle(getValue(obj, "secondary", 0))
{
if(obj.contains("aspects") && obj["aspects"].isArray() && obj["aspects"].toArray().size() == 9) {
selectedAspects.clear();
selectedAspects.reserve(9);
QJsonArray arr = obj["aspects"].toArray();
for(QJsonValueRef aspect : arr) {
if(aspect.isDouble()) {
selectedAspects.push_back(aspect.toDouble());
}
}
}
}
std::ostream& operator<<(std::ostream& str, const RunePage& rp) {
return str << "Primary: " << rp.primaryStyle << " Secondary: " << rp.secondaryStyle << " aspects: " << rp.selectedAspects.size();
}
QDebug operator<<(QDebug str, const RunePage& rp) {
return str << "Primary: " << rp.primaryStyle << " Secondary: " << rp.secondaryStyle << " aspects: " << rp.selectedAspects.size();
}

304
src/runepagelist.cpp Normal file
View File

@ -0,0 +1,304 @@
#include "runepagelist.h"
#include "ui_runepagelist.h"
#include <QDebug>
#include <QDropEvent>
#include <QMenu>
#include <QMimeData>
#include <QTextStream>
#include "clipboardpopup.h"
#include "runeeditor.h"
RunePageList::RunePageList(QWidget* parent) : QListWidget(parent), ui(new Ui::RunePageList) {
ui->setupUi(this);
QObject::connect(this, &QListWidget::itemChanged, this, &RunePageList::itemChangedCallback);
QObject::connect(this, &QListWidget::customContextMenuRequested, this, &RunePageList::openContextMenu);
}
RunePageList::~RunePageList() {
delete this->ui;
}
void RunePageList::loadRunePages(const std::vector<ClientAPI::RunePage>& pages) {
clearItems();
for(const ClientAPI::RunePage& rp : pages) {
addRunepageItem(rp.name, rp.id, rp.runepage, rp.isCurrent);
}
}
void RunePageList::loadRunePages(const std::vector<std::shared_ptr<Config::RunePageConfig>>& pages) {
clearItems();
for(size_t i = 0; i < pages.size(); ++i) {
std::shared_ptr<Config::RunePageConfig> rp = pages.at(i);
addRunepageItem(rp->name, i, rp->runepage);
}
}
void RunePageList::setRuneInfos(const std::vector<RuneAspekt>& runeInfo, const std::vector<RuneStyle>& runeStyles) {
this->runeInfo = &runeInfo;
this->runeStyles = &runeStyles;
}
void RunePageList::dropEvent(QDropEvent* event) {
if(event->source() == nullptr || event->source() != other) {
event->ignore();
return;
}
auto selected = other->selectedItems();
if(selected.size() != 1) {
event->ignore();
return;
}
QListWidgetItem* item = selected.at(0);
// compare rune pages for duplicates?
// QListWidget::dropEvent(event);
// save change
QString name = item->text();
const RunePage* oldPage = (RunePage*) item->data(RolePointer).toULongLong();
emit runepageChanged(-1, name, *oldPage);
}
void RunePageList::itemChangedCallback(QListWidgetItem* item) {
int pageId = item->data(RunePageList::RoleId).toUInt();
QString newName = item->text();
const ::RunePage* page = (::RunePage*) item->data(RunePageList::RolePointer).toULongLong();
emit runepageChanged(pageId, newName, *page);
}
void RunePageList::openContextMenu(const QPoint& pos) {
QPoint globalPos = mapToGlobal(pos);
QMenu menu;
menu.addAction(QIcon(":/icons/edit.svg"), RunePageList::tr("Edit (Beta)"), this, &RunePageList::editCurrentItem);
menu.addAction(QIcon(":/icons/duplicate.svg"), RunePageList::tr("Duplicate"), this, &RunePageList::duplicateCurrentItem);
menu.addAction(QIcon(":/icons/export.svg"), RunePageList::tr("Export"), this, &RunePageList::exportCurrentItem);
menu.addAction(QIcon(":/icons/import.svg"), RunePageList::tr("Import"), this, &RunePageList::importItem);
menu.addAction(QIcon(":/icons/delete.svg"), RunePageList::tr("Delete"), this, &RunePageList::deleteCurrentItem);
menu.exec(globalPos);
}
void RunePageList::deleteCurrentItem() {
QListWidgetItem* item = currentItem();
if (item) {
uint32_t id = item->data(RoleId).toUInt();
RunePage* page = (RunePage*) item->data(RolePointer).toULongLong();
removeItemWidget(item);
delete item;
delete page;
emit runepageDeleted(id);
}
}
void RunePageList::editCurrentItem() {
QListWidgetItem* item = currentItem();
if(!item) return;
RunePage* rp = (RunePage*) item->data(RolePointer).toULongLong();
const uint32_t id = item->data(RoleId).toUInt();
RuneEditor re;
re.setName(item->text());
re.setClient(*client);
re.setRunepage(*rp);
int result = re.exec();
// check result - save
if(result == QDialog::Accepted) {
// update config
emit runepageChanged(id, re.getName(), re.getRunepage());
}
}
void RunePageList::duplicateCurrentItem() {
QListWidgetItem* item = currentItem();
if(!item) return;
const RunePage* rp = (RunePage*) item->data(RolePointer).toULongLong();
QString name = item->text();
static const QRegularExpression regex(".*(\\d)+$");
QRegularExpressionMatchIterator regexIt = regex.globalMatch(name);
int num = 0;
if(regexIt.hasNext()) {
QRegularExpressionMatch match = regexIt.next();
QStringRef ref = match.capturedRef(1);
name.chop(ref.size());
num = ref.toInt();
}
name += QString::number(num+1);
emit runepageChanged(-1, name, *rp);
}
void RunePageList::exportCurrentItem() {
QListWidgetItem* item = currentItem();
if(!item) return;
const RunePage* rp = (RunePage*) item->data(RolePointer).toULongLong();
Config::RunePageConfig rpc;
rpc.name = item->text();
rpc.runepage = *rp;
QJsonDocument rpcDoc(rpc); // cast to QJsonObject
QByteArray jsonBytes = rpcDoc.toJson(QJsonDocument::Compact).toBase64();
QString runePageString = QString::fromLocal8Bit(jsonBytes);
ClipboardPopup popup(ClipboardPopup::Direction::Copy);
popup.setText(runePageString);
popup.exec();
}
void RunePageList::importItem() {
ClipboardPopup popup(ClipboardPopup::Direction::Paste);
if(popup.exec() != QDialog::Accepted) {
return;
}
QString text = popup.getText();
QByteArray jsonBytes = QByteArray::fromBase64(text.toLocal8Bit());
QJsonDocument rpcDoc = QJsonDocument::fromJson(jsonBytes);
if(rpcDoc.isObject()) {
QJsonObject rpcJson = rpcDoc.object();
Config::RunePageConfig rpc = rpcJson; // implicit cast
if(rpc.name.isEmpty() || !rpc.runepage) {
// invalid
return;
}
emit runepageChanged(-1, rpc.name, rpc.runepage);
}
}
void RunePageList::clearItems() {
while(count()) {
QListWidgetItem* item = takeItem(0);
delete (RunePage*) item->data(RolePointer).toULongLong();
delete item;
}
clear();
}
void RunePageList::addRunepageItem(QString name, int id, const ::RunePage& rp, bool isCurrent) {
QListWidgetItem* item = new QListWidgetItem(name);
item->setData(RoleId, (uint) id);
item->setData(RolePointer, (qulonglong) new ::RunePage(rp));
const DataDragon::ChampData& champData = findChamp(name);
if(champData.key != -1) {
QPixmap iamge = dd->getImage(champData.id);
item->setIcon(iamge);
}
QString tooltipStr;
if(id != -1) {
tooltipStr = QString("id: %0\n").arg(id);
}
tooltipStr += getRuneDescription(rp);
item->setToolTip(tooltipStr);
item->setFlags(item->flags() | Qt::ItemIsEditable);
if(isCurrent) {
item->setSelected(true);
}
addItem(item);
}
const DataDragon::ChampData& RunePageList::findChamp(const QString& name) {
if(!dd) {
return DataDragon::EMPTYCHAMP;
}
// try direct
int count = 0;
const DataDragon::ChampData& directChampData = dd->getBestMatchingChamp(name, &count);
if(directChampData.key != -1) {
return directChampData;
}
// not specific
if(count > 1) {
return DataDragon::EMPTYCHAMP;
}
// try for substrings
static const QRegularExpression splittingRegex("\\W+");
QStringList list = name.split(splittingRegex, QString::SplitBehavior::SkipEmptyParts);
QSet<int> matchedIds;
const DataDragon::ChampData* lastMatched = nullptr;
for(const QString& entry : list) {
count = 0;
const DataDragon::ChampData& splitChampData = dd->getBestMatchingChamp(entry, &count);
if(count == 1) {
matchedIds.insert(splitChampData.key);
lastMatched = &splitChampData;
} else if(count > 1) {
// not specific
return DataDragon::EMPTYCHAMP;
}
}
if(lastMatched && matchedIds.size() == 1) {
return *lastMatched;
}
// not specific or not found
return DataDragon::EMPTYCHAMP;
}
QString RunePageList::getRuneDescription(const ::RunePage& runepage) {
QString outStr;
outStr.reserve(100);
QTextStream out(&outStr);
if(! (bool) runepage) {
return {};
}
out << getRuneStyleByID(runepage.primaryStyle) << ' ' << RunePageList::tr("with") << ' ' << getRuneStyleByID(runepage.secondaryStyle);
for(uint32_t rune : runepage.selectedAspects) {
out << '\n' << getRuneText(rune);
}
return outStr;
}
QString RunePageList::getRuneText(uint32_t id) {
if(runeInfo != nullptr) {
for(const RuneAspekt& ra : *runeInfo) {
if(ra.id == id) {
return ra.name;
}
}
}
return QString("(%0)").arg(id);
}
QString RunePageList::getRuneStyleByID(uint32_t id) {
if(runeStyles != nullptr) {
auto it = std::find_if(runeStyles->begin(), runeStyles->end(), [id](const RuneStyle& rs) { return rs.id == id; });
if(it != runeStyles->end()) {
return it->name;
}
}
return QString("(%0)").arg(id);
}

View File

@ -4,8 +4,8 @@
#include <algorithm>
#include <Log.h>
static std::vector<std::string> toChampionNameList(const std::vector<StageSettings::SelectedChamp>& scs) {
std::vector<std::string> out;
static std::vector<QString> toChampionNameList(const std::vector<StageSettings::SelectedChamp>& scs) {
std::vector<QString> out;
out.reserve(scs.size());
std::transform(scs.begin(), scs.end(), std::insert_iterator(out, out.begin()), [](const StageSettings::SelectedChamp& sc) { return sc.name; });
@ -42,7 +42,7 @@ bool SettingsTab::getState(LolAutoAccept::State s) const {
return stage->getState();
}
void SettingsTab::setChamps(LolAutoAccept::State s, const std::vector<std::string>& c) {
void SettingsTab::setChamps(LolAutoAccept::State s, const std::vector<QString>& c) {
getStage(s)->setChampions(c);
}

View File

@ -39,23 +39,23 @@ void StageSettings::setState(bool b) {
updateEnabled();
}
StageSettings::SelectedChamp::SelectedChamp(std::string name, uint32_t id) : name(name), id(id) {}
StageSettings::SelectedChamp::SelectedChamp(QString name, uint32_t id) : name(name), id(id) {}
std::vector<StageSettings::SelectedChamp> StageSettings::getChampions() const {
std::vector<SelectedChamp> out;
out.reserve(ui->championList->count());
for(int32_t i = 0; i < ui->championList->count(); ++i) {
ChampRow* cr = (ChampRow*) ui->championList->item(i);
out.emplace_back(cr->getChamp().toStdString(), cr->getChampID());
out.emplace_back(cr->getChamp(), cr->getChampID());
}
return out;
}
void StageSettings::setChampions(const std::vector<std::string>& champs) {
void StageSettings::setChampions(const std::vector<QString>& champs) {
clear();
// add new champs
for(const std::string& champ : champs) {
for(const QString& champ : champs) {
resolveAndAddChamp(champ, champ == champs.back());
}
}
@ -87,7 +87,7 @@ void StageSettings::addChamp() {
// popup with champion search
ChampionSearch cs(dd, this);
int res = cs.exec();
Log::info << "championsearch result: " << res;
qInfo() << "championsearch result: " << res;
if(res == QDialog::Accepted) {
auto cr = cs.getSearchResult();
if(cr) {
@ -110,7 +110,7 @@ void StageSettings::moved() {
emit championsChanged();
}
void StageSettings::resolveAndAddChamp(const std::string& name, bool emitchange) {
void StageSettings::resolveAndAddChamp(const QString& name, bool emitchange) {
if(dd) {
int count = 0;
auto cd = dd->getBestMatchingChamp(name, &count);
@ -122,7 +122,7 @@ void StageSettings::resolveAndAddChamp(const std::string& name, bool emitchange)
}
});
} else {
Log::error << __PRETTY_FUNCTION__ << " Datadragon not set!";
qCritical() << __PRETTY_FUNCTION__ << " Datadragon not set!";
}
}

2
thirdparty/Log vendored

@ -1 +1 @@
Subproject commit e1475e798e2429d171b8f58fc3c96c81db25639c
Subproject commit 9a43d50969ecc34d9a3bc8944bc2182e55f7a712

78
ui/clipboardpopup.ui Normal file
View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ClipboardPopup</class>
<widget class="QDialog" name="ClipboardPopup">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Clipboard Text</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="copyButton">
<property name="text">
<string>Copy To Clipboard</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QTextEdit" name="text">
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ClipboardPopup</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ClipboardPopup</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

47
ui/loadingwindow.ui Normal file
View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LoadingWindow</class>
<widget class="QWidget" name="LoadingWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>739</width>
<height>176</height>
</rect>
</property>
<property name="windowTitle">
<string>LoL-Auto-Accept</string>
</property>
<property name="windowIcon">
<iconset resource="../resources/res.qrc">
<normaloff>:/lolautoaccept.svg</normaloff>:/lolautoaccept.svg</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::NoTextInteraction</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../resources/res.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>452</width>
<height>645</height>
<width>579</width>
<height>788</height>
</rect>
</property>
<property name="sizePolicy">
@ -19,139 +19,259 @@
<property name="windowTitle">
<string>LoL-Auto-Accept</string>
</property>
<property name="windowIcon">
<iconset resource="../resources/res.qrc">
<normaloff>:/lolautoaccept.svg</normaloff>:/lolautoaccept.svg</iconset>
</property>
<widget class="QWidget" name="centralwidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>465</width>
<height>581</height>
</rect>
<layout class="QGridLayout" name="centralGridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QCheckBox" name="mainswitch">
<property name="text">
<string>Mainswitch</string>
</property>
<item row="1" column="0">
<widget class="QTabWidget" name="centralTabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="autoacceptPage">
<attribute name="title">
<string>Auto Accept</string>
</attribute>
<layout class="QGridLayout" name="gridLayout" columnstretch="2,0">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<property name="spacing">
<number>9</number>
</property>
<item row="5" column="0">
<widget class="QCheckBox" name="enableAutoWrite">
<property name="toolTip">
<string>Write a Text as soon as you are in a champ select lobby.</string>
</property>
<property name="text">
<string>Auto Write</string>
</property>
</widget>
</item>
<item row="0" column="1" rowspan="6">
<widget class="QLabel" name="copyrightlabel">
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Developed by MrBesen&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://lolautoacceptor.mrbesen.de/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;Webseite&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Version: %1&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="mainswitch">
<property name="toolTip">
<string>This controls the connection to the LoL client. As long as this is off, no interactions with the LoL client take place.</string>
</property>
<property name="text">
<string>Mainswitch</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="enableSmiteWarning">
<property name="toolTip">
<string>Spam &quot;smite&quot; in the chat when there is not exactly 1 player with smite equiped in champ select</string>
</property>
<property name="text">
<string>Enable Smite Warning</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" rowspan="2">
<widget class="QCheckBox" name="enableAll">
<property name="text">
<string>Enable LoL-Auto-Accept</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QTextEdit" name="autoWriteText">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>80</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="lineWrapMode">
<enum>QTextEdit::NoWrap</enum>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
<property name="placeholderText">
<string>autowriteText</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QTabWidget" name="tabWidget">
<property name="tabPosition">
<enum>QTabWidget::North</enum>
</property>
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>4</number>
</property>
<property name="elideMode">
<enum>Qt::ElideNone</enum>
</property>
<property name="usesScrollButtons">
<bool>false</bool>
</property>
<property name="tabsClosable">
<bool>false</bool>
</property>
<widget class="SettingsTab" name="tab_default">
<property name="toolTip">
<string>This Tab is used, when you are in a gamemode with no fixed roles</string>
</property>
<property name="position" stdset="0">
<UInt>0</UInt>
</property>
<attribute name="title">
<string>Default</string>
</attribute>
</widget>
<widget class="SettingsTab" name="tab_top">
<property name="position" stdset="0">
<UInt>1</UInt>
</property>
<attribute name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/icons/top.svg</normaloff>:/icons/top.svg</iconset>
</attribute>
<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="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/icons/jgl.svg</normaloff>:/icons/jgl.svg</iconset>
</attribute>
<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="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/icons/mid.svg</normaloff>:/icons/mid.svg</iconset>
</attribute>
<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="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/icons/bot.svg</normaloff>:/icons/bot.svg</iconset>
</attribute>
<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="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/icons/sup.svg</normaloff>:/icons/sup.svg</iconset>
</attribute>
<attribute name="title">
<string>Support</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="enableAll">
<property name="text">
<string>Enable LoL-Auto-Accept</string>
</property>
<widget class="RuneManager" name="runesPage">
<attribute name="title">
<string>Runes</string>
</attribute>
</widget>
</item>
<item>
<widget class="QCheckBox" name="enableSmiteWarning">
<property name="toolTip">
<string>Spam &quot;smite&quot; in the chat when there is not exactly 1 player with smite equiped in champ select</string>
</property>
<property name="text">
<string>Enable Smite Warning</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="tabPosition">
<enum>QTabWidget::North</enum>
</property>
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="elideMode">
<enum>Qt::ElideNone</enum>
</property>
<property name="usesScrollButtons">
<bool>false</bool>
</property>
<property name="tabsClosable">
<bool>false</bool>
</property>
<widget class="SettingsTab" name="tab_default">
<property name="toolTip">
<string>This Tab is used, when you are in a gamemode with no fixed roles</string>
</property>
<property name="position" stdset="0">
<UInt>0</UInt>
</property>
<attribute name="title">
<string>Default</string>
</attribute>
</widget>
<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>
<item>
<widget class="RuneDisplay" name="runedisplay" native="true"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>452</width>
<height>21</height>
<width>579</width>
<height>24</height>
</rect>
</property>
</widget>
@ -165,20 +285,24 @@
<container>1</container>
</customwidget>
<customwidget>
<class>RuneDisplay</class>
<class>RuneManager</class>
<extends>QWidget</extends>
<header>runedisplay.h</header>
<header>runemanager.h</header>
<container>1</container>
<slots>
<signal>applyRunes()</signal>
</slots>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>centralTabWidget</tabstop>
<tabstop>mainswitch</tabstop>
<tabstop>enableAll</tabstop>
<tabstop>enableSmiteWarning</tabstop>
<tabstop>enableAutoWrite</tabstop>
<tabstop>autoWriteText</tabstop>
<tabstop>tabWidget</tabstop>
</tabstops>
<resources/>
<resources>
<include location="../resources/res.qrc"/>
</resources>
<connections>
<connection>
<sender>enableAll</sender>
@ -187,8 +311,8 @@
<slot>aatoggled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>19</x>
<y>61</y>
<x>36</x>
<y>128</y>
</hint>
<hint type="destinationlabel">
<x>393</x>
@ -203,8 +327,8 @@
<slot>toggleMainswitch(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>88</x>
<y>38</y>
<x>99</x>
<y>94</y>
</hint>
<hint type="destinationlabel">
<x>1</x>
@ -223,24 +347,8 @@
<y>86</y>
</hint>
<hint type="destinationlabel">
<x>407</x>
<y>145</y>
</hint>
</hints>
</connection>
<connection>
<sender>runedisplay</sender>
<signal>applyRunes()</signal>
<receiver>MainWindow</receiver>
<slot>applyRunes()</slot>
<hints>
<hint type="sourcelabel">
<x>270</x>
<y>599</y>
</hint>
<hint type="destinationlabel">
<x>458</x>
<y>576</y>
<x>408</x>
<y>380</y>
</hint>
</hints>
</connection>
@ -251,8 +359,8 @@
<slot>smitewarntoggled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>190</x>
<y>77</y>
<x>202</x>
<y>162</y>
</hint>
<hint type="destinationlabel">
<x>201</x>
@ -260,6 +368,54 @@
</hint>
</hints>
</connection>
<connection>
<sender>enableAutoWrite</sender>
<signal>clicked(bool)</signal>
<receiver>MainWindow</receiver>
<slot>autoWriteChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>199</x>
<y>196</y>
</hint>
<hint type="destinationlabel">
<x>441</x>
<y>147</y>
</hint>
</hints>
</connection>
<connection>
<sender>autoWriteText</sender>
<signal>textChanged()</signal>
<receiver>MainWindow</receiver>
<slot>autoWriteChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>326</x>
<y>285</y>
</hint>
<hint type="destinationlabel">
<x>347</x>
<y>146</y>
</hint>
</hints>
</connection>
<connection>
<sender>enableAutoWrite</sender>
<signal>toggled(bool)</signal>
<receiver>autoWriteText</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>105</x>
<y>196</y>
</hint>
<hint type="destinationlabel">
<x>97</x>
<y>285</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<signal>requestTabChange(int)</signal>
@ -269,5 +425,6 @@
<slot>toggleMainswitch(bool)</slot>
<slot>applyRunes()</slot>
<slot>smitewarntoggled(bool)</slot>
<slot>autoWriteChanged()</slot>
</slots>
</ui>

18
ui/runeaspektbutton.ui Normal file
View File

@ -0,0 +1,18 @@
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>RuneAspektButton</class>
<widget class="QPushButton" name="RuneAspektButton">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
</widget>
<pixmapfunction/>
<connections/>
</ui>

79
ui/runeeditor.ui Normal file
View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RuneEditor</class>
<widget class="QWidget" name="RuneEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>576</width>
<height>455</height>
</rect>
</property>
<property name="windowTitle">
<string>Runepage Editor</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QLineEdit" name="runepageName"/>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="substyle"/>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="style"/>
</item>
<item row="3" column="1" rowspan="3">
<layout class="QGridLayout" name="substylePerks"/>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="8" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
</property>
</widget>
</item>
<item row="2" column="0" rowspan="7">
<layout class="QGridLayout" name="stylePerks">
<property name="rightMargin">
<number>10</number>
</property>
</layout>
</item>
<item row="6" column="1" rowspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>120</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

100
ui/runemanager.ui Normal file
View File

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RuneManager</class>
<widget class="QWidget" name="RuneManager">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>498</width>
<height>654</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QLabel" name="lblClientRunes">
<property name="text">
<string>Runes in the Client</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="lblaaRunes">
<property name="text">
<string>Runes in the Autoacceptor</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="RunePageList" name="listClientRunes">
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragDrop</enum>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="RunePageList" name="listaaRunes">
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragDrop</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="btnRetry">
<property name="text">
<string>Reload</string>
</property>
<property name="icon">
<iconset theme="reload">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="chkAutoCopy">
<property name="toolTip">
<string>Runes from the client get copied to the autoacceptor automatically.</string>
</property>
<property name="text">
<string>Auto Copy Runes</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>RunePageList</class>
<extends>QListWidget</extends>
<header>runepagelist.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>btnRetry</sender>
<signal>clicked()</signal>
<receiver>RuneManager</receiver>
<slot>loadRunes()</slot>
<hints>
<hint type="sourcelabel">
<x>223</x>
<y>28</y>
</hint>
<hint type="destinationlabel">
<x>544</x>
<y>55</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>loadRunes()</slot>
</slots>
</ui>

19
ui/runepagelist.ui Normal file
View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RunePageList</class>
<widget class="QListWidget" name="RunePageList">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>412</width>
<height>180</height>
<height>277</height>
</rect>
</property>
<property name="sizePolicy">
@ -46,7 +46,7 @@
<property name="title">
<string notr="true"/>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QGridLayout" name="gridLayout_2" columnstretch="4,3">
<property name="sizeConstraint">
<enum>QLayout::SetMinAndMaxSize</enum>
</property>
@ -59,6 +59,9 @@
</item>
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetMinAndMaxSize</enum>
</property>