lolautoaccept/include/lolautoaccept.h
2022-04-24 21:04:36 +02:00

87 lines
1.8 KiB
C++

#pragma once
#include "scaleableinputs.h"
#include "screen.h"
#include "matcher.h"
#include <xinputsimulator.h>
#include <thread>
class LolAutoAccept {
protected:
struct Stage {
Stage(const std::string& matchertmpl);
virtual ~Stage();
Matcher matcher;
std::string champ; // not every stage has a champ
bool enabled = false;
virtual void action(LolAutoAccept& lolaa) = 0;
virtual bool process(LolAutoAccept& lolaa, cv::Mat& img);
};
struct CooldownStage : public Stage {
CooldownStage(const std::string& matchertmpl);
time_t lastused = 0;
uint32_t cooldown = 30; // how long until this stage can be used again (seconds)
virtual bool process(LolAutoAccept& lolaa, cv::Mat& img) override;
};
struct AcceptStage : public Stage {
AcceptStage();
virtual void action(LolAutoAccept& lolaa) override;
};
struct PrePickStage : public CooldownStage {
PrePickStage();
virtual void action(LolAutoAccept& lolaa) override;
};
struct BanStage : public CooldownStage {
BanStage();
virtual void action(LolAutoAccept& lolaa) override;
};
struct PickStage : public CooldownStage {
PickStage();
virtual void action(LolAutoAccept& lolaa) override;
};
ScreenShot* screen = nullptr;
std::vector<Stage*> stages;
XInputSimulator& sim;
ScaleableInputs inputs;
bool shouldrun = false;
std::thread lolaathread;
void performClick(uint32_t nr, bool movemouseaway = true);
void enterSearch(const std::string& text);
void pickFirst(const std::string& search);
public:
enum class State {
LOBBY = 0,
PREPICK = 1,
BAN = 2,
PICK = 3,
GAME = 4
};
LolAutoAccept();
~LolAutoAccept();
void setChamp(const std::string& champ, State s);
void setEnabled(bool b, State s);
bool init(); // returns true on success
void run();
void stop();
private:
void stopJoinThread();
void innerRun();
};