Keybind system redone, display keybinds and mana costs on HUD.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
#include "olcPixelGameEngine.h"
|
||||
#include <set>
|
||||
|
||||
//Future-proof game controller support.
|
||||
enum InputType{
|
||||
KEY,
|
||||
MOUSE,
|
||||
CONTROLLER
|
||||
};
|
||||
|
||||
//A generic class that represents any type of input.
|
||||
class Input{
|
||||
friend class InputGroup;
|
||||
InputType type;
|
||||
int key; //This will be interpreted differently depending on input type.
|
||||
public:
|
||||
Input(InputType type,int key);
|
||||
bool Pressed();
|
||||
bool Held();
|
||||
bool Released();
|
||||
std::string GetDisplayName();
|
||||
bool operator<(const Input&rhs)const{
|
||||
return type<rhs.type||(type==rhs.type&&key<rhs.key);
|
||||
}
|
||||
};
|
||||
|
||||
class InputGroup{
|
||||
std::set<Input>keys;
|
||||
public:
|
||||
InputGroup();
|
||||
void AddKeybind(Input bind);
|
||||
void RemoveKeybind(Input bind);
|
||||
bool Pressed();
|
||||
bool Held();
|
||||
bool Released();
|
||||
std::string GetDisplayName();
|
||||
};
|
||||
|
||||
class GenericKey{
|
||||
public:
|
||||
static std::map<std::pair<InputType,int>,std::string>keyLiteral; //The displayed text for a given key for a given input type.
|
||||
};
|
||||
Reference in New Issue
Block a user