# Changes 0.2.4-2
- Document the rest of th elibs - remove sound.hpp header
This commit is contained in:
@ -23,50 +23,71 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/drivers/hid.hpp>
|
||||
#include <pd/core/tween.hpp>
|
||||
#include <pd/drivers/hid.hpp>
|
||||
#include <pd/overlays/overlay.hpp>
|
||||
|
||||
namespace PD {
|
||||
/**
|
||||
* Development Function to dump Keyboard Layout into a Json File
|
||||
* @param path Path to write into
|
||||
*/
|
||||
void DumpLayout(const std::string& path);
|
||||
/// Keyboard class
|
||||
/// @brief needs to be pushed with text and State reference as Overlay
|
||||
/// to communicate with it
|
||||
/// @note Hardcoded Rendering to get maximum Rendering Performance
|
||||
/**
|
||||
* Keyboard class
|
||||
*
|
||||
* - needs to be pushed with text and State reference as Overlay
|
||||
* to communicate with it
|
||||
* @note Hardcoded Rendering to get maximum Rendering Performance
|
||||
*/
|
||||
class Keyboard : public Overlay {
|
||||
public:
|
||||
/** Key Operations */
|
||||
enum KeyOperation {
|
||||
AppendSelf = 0,
|
||||
Shift = 1,
|
||||
Backspace = 2,
|
||||
Enter = 3,
|
||||
OpCancel = 4,
|
||||
OpConfirm = 5,
|
||||
Tab = 6,
|
||||
Caps = 7,
|
||||
Space = 8,
|
||||
Op1 = 9,
|
||||
Op2 = 10,
|
||||
AppendSelf = 0, ///< Append Keyname to res string
|
||||
Shift = 1, ///< Shift
|
||||
Backspace = 2, ///< Backspace
|
||||
Enter = 3, ///< Enter
|
||||
OpCancel = 4, ///< Cancel
|
||||
OpConfirm = 5, ///< Confirm
|
||||
Tab = 6, ///< Tab
|
||||
Caps = 7, ///< Caps
|
||||
Space = 8, ///< Space
|
||||
Op1 = 9, ///< Unnset Op 1
|
||||
Op2 = 10, ///< Unset Op 2
|
||||
};
|
||||
/** Keyboard Type */
|
||||
enum Type {
|
||||
Default,
|
||||
Numpad,
|
||||
Password,
|
||||
Default, ///< Default Keyboard
|
||||
Numpad, ///< Numpad
|
||||
Password, ///< Password Input
|
||||
};
|
||||
/** State */
|
||||
enum State {
|
||||
None,
|
||||
Cancel,
|
||||
Confirm,
|
||||
None, ///< Doing nothing
|
||||
Cancel, ///< Cancelled
|
||||
Confirm, ///< Confirmed
|
||||
};
|
||||
/** Alias for Keyboard Flags */
|
||||
using Flags = u32;
|
||||
/** Flags */
|
||||
enum Flags_ {
|
||||
Flags_None = 0,
|
||||
Flags_BlendTop = 1 << 0,
|
||||
Flags_BlendBottom = 1 << 1,
|
||||
Flags_LockControls = 1 << 2,
|
||||
Flags_Transparency = 1 << 3,
|
||||
Flags_None = 0, ///< Nothing
|
||||
Flags_BlendTop = 1 << 0, ///< Blend Top Screen
|
||||
Flags_BlendBottom = 1 << 1, ///< Blend Bottom
|
||||
Flags_LockControls = 1 << 2, ///< Lock Contols (Input Driver)
|
||||
Flags_Transparency = 1 << 3, ///< Transparant Keyboard Colors
|
||||
// Default Flags
|
||||
Flags_Default = Flags_BlendBottom | Flags_BlendTop | Flags_LockControls,
|
||||
};
|
||||
/**
|
||||
* Keyboard Constructor
|
||||
* @param text Result Text
|
||||
* @param state Result State
|
||||
* @param hint Hint to display if result is empty
|
||||
* @param type Keyboard type
|
||||
* @param flags Keyboard flags to use
|
||||
*/
|
||||
Keyboard(std::string& text, State& state, const std::string& hint = "",
|
||||
Type type = Default, Flags flags = Flags_Default) {
|
||||
too++;
|
||||
@ -84,46 +105,74 @@ class Keyboard : public Overlay {
|
||||
flymgr.From(vec2(0, 240)).To(vec2(0, 115)).In(0.3f).As(flymgr.EaseInQuad);
|
||||
chflymgr.From(vec2(-320, 0)).To(vec2(-320, 0)).In(0.1f).As(chflymgr.Linear);
|
||||
}
|
||||
/** Deconstructor */
|
||||
~Keyboard() { too--; }
|
||||
|
||||
/**
|
||||
* Rendering and Input Handler
|
||||
* @param delta Deltatime for Animations
|
||||
* @param ren Renderer Reference
|
||||
* @param inp Input Driver reference
|
||||
*/
|
||||
void Update(float delta, LI::Renderer::Ref ren, Hid::Ref inp) override;
|
||||
|
||||
/** Remove Keyboard */
|
||||
void Rem() {
|
||||
rem = true;
|
||||
flymgr.From(vec2(0, 115)).To(vec2(0, 240)).In(0.2f).As(flymgr.EaseOutQuad);
|
||||
}
|
||||
|
||||
private:
|
||||
/** Prerender Keys */
|
||||
void LoadTheKeys(LI::Renderer::Ref ren);
|
||||
/** Controller Movement */
|
||||
void Movement(Hid::Ref inp);
|
||||
/** Trigger Move from to Animation */
|
||||
void MoveSelector();
|
||||
/** Execute a Key operation */
|
||||
void DoOperation(KeyOperation op, const std::string& kname);
|
||||
/** Recolor all Keys with the same operation */
|
||||
void RecolorBy(KeyOperation op, u32 color, int cm);
|
||||
/** Bind an operation */
|
||||
void InputOpBind(Hid::Key k, KeyOperation op, Hid::Ref inp, int cm);
|
||||
// Result Text reference
|
||||
std::string* text;
|
||||
// Copy of the Text
|
||||
std::string copy;
|
||||
// Hint
|
||||
std::string hint;
|
||||
// Result State reference
|
||||
State* state;
|
||||
// Keyboard Type
|
||||
Type type;
|
||||
// Keyboard flags
|
||||
Flags flags;
|
||||
int mode = 0; // def, caps, shift
|
||||
// def, caps, shift
|
||||
int mode = 0;
|
||||
// Stands for The Only One
|
||||
static int too;
|
||||
|
||||
// Tween for selector Movement
|
||||
Tween<vec2> selector;
|
||||
// Tween for Selector Size
|
||||
Tween<vec2> sel_szs;
|
||||
// Current Cell size
|
||||
vec2 cselszs;
|
||||
// selector index
|
||||
int raw_sel;
|
||||
|
||||
// Performance Optimisation
|
||||
// Prerendered Keytables
|
||||
LI::StaticObject::Ref keys[3];
|
||||
// Value to check if table is loadet
|
||||
bool keys_loadet = false;
|
||||
|
||||
// Some Animation
|
||||
// Remove Animation
|
||||
bool rem = false;
|
||||
/// Probably a float would've done the job as well ;)
|
||||
Tween<vec2> flymgr;
|
||||
// Secode Flymanager
|
||||
Tween<vec2> chflymgr;
|
||||
// Show Help
|
||||
bool show_help = true;
|
||||
};
|
||||
} // namespace PD
|
@ -23,24 +23,45 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/lithium/renderer.hpp>
|
||||
#include <pd/core/color.hpp>
|
||||
#include <pd/core/tween.hpp>
|
||||
#include <pd/lithium/renderer.hpp>
|
||||
|
||||
namespace PD {
|
||||
/**
|
||||
* Message Manager
|
||||
*/
|
||||
class MessageMgr : public PD::SmartCtor<MessageMgr> {
|
||||
public:
|
||||
/**
|
||||
* Message Container
|
||||
*/
|
||||
class Container : public PD::SmartCtor<Container> {
|
||||
public:
|
||||
/**
|
||||
* Message Constructor
|
||||
* @param title Title
|
||||
* @param msg Message
|
||||
*/
|
||||
Container(const std::string& title, const std::string& msg);
|
||||
~Container() {}
|
||||
~Container() = default;
|
||||
|
||||
/** Render the Container */
|
||||
void Render(PD::LI::Renderer::Ref ren);
|
||||
/**
|
||||
* Update Animations by slot and delta
|
||||
* @param slot Slot
|
||||
* @param delta Deltatime
|
||||
*/
|
||||
void Update(int slot, float delta);
|
||||
/** Trigger Fly in Animation */
|
||||
void FlyIn();
|
||||
/** Trigger Change Position Animation */
|
||||
void ToBeMoved(int slot);
|
||||
/** Trigger Removed Animation */
|
||||
void ToBeRemoved();
|
||||
|
||||
/** Check if Message can be removed from list */
|
||||
bool ShouldBeRemoved() const { return (tbr && pos.IsFinished()) || kill; }
|
||||
|
||||
private:
|
||||
@ -55,14 +76,24 @@ class MessageMgr : public PD::SmartCtor<MessageMgr> {
|
||||
bool kill = false; // Instant Kill
|
||||
int s = 0; // Slot
|
||||
};
|
||||
/** Constructor to Link a Renderer reference */
|
||||
MessageMgr(PD::LI::Renderer::Ref r) { ren = r; }
|
||||
~MessageMgr() {}
|
||||
~MessageMgr() = default;
|
||||
|
||||
/**
|
||||
* Add a New Message
|
||||
* @param title Message Title
|
||||
* @param text Message Text
|
||||
*/
|
||||
void Push(const std::string& title, const std::string& text);
|
||||
/**
|
||||
* Update Messages
|
||||
* @param delta Deltatime
|
||||
*/
|
||||
void Update(float delta);
|
||||
|
||||
private:
|
||||
std::vector<Container::Ref> msgs;
|
||||
PD::LI::Renderer::Ref ren;
|
||||
std::vector<Container::Ref> msgs; // List of Messages
|
||||
PD::LI::Renderer::Ref ren; // Renderer Reference
|
||||
};
|
||||
} // namespace PD
|
@ -28,19 +28,30 @@ SOFTWARE.
|
||||
#include <pd/lithium/renderer.hpp>
|
||||
|
||||
namespace PD {
|
||||
/**
|
||||
* Overlay Template class
|
||||
*/
|
||||
class Overlay : public SmartCtor<Overlay> {
|
||||
public:
|
||||
Overlay() {}
|
||||
virtual ~Overlay() {}
|
||||
Overlay() = default;
|
||||
virtual ~Overlay() = default;
|
||||
|
||||
/**
|
||||
* Update Function for Overlay input and rendering
|
||||
* @param delta Deltatime
|
||||
* @param ren Renderer reference
|
||||
* @param inp Input Driver
|
||||
*/
|
||||
virtual void Update(float delta, LI::Renderer::Ref ren, Hid::Ref inp) = 0;
|
||||
|
||||
/** Check if killed to remove from Overlay Manager */
|
||||
bool IsKilled() const { return kill; }
|
||||
|
||||
protected:
|
||||
/** Internall Kill function to call from your Overlay */
|
||||
void Kill() { kill = true; }
|
||||
|
||||
private:
|
||||
bool kill = false;
|
||||
bool kill = false; ///< Should be killed or not
|
||||
};
|
||||
} // namespace PD
|
@ -28,20 +28,37 @@ SOFTWARE.
|
||||
#include <pd/overlays/overlay.hpp>
|
||||
|
||||
namespace PD {
|
||||
/**
|
||||
* Overlay Manager Class
|
||||
*/
|
||||
class OverlayMgr : public SmartCtor<OverlayMgr> {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
* @param ren Renderer
|
||||
* @param inp Input Driver reference
|
||||
*/
|
||||
OverlayMgr(LI::Renderer::Ref ren, Hid::Ref inp) {
|
||||
this->ren = ren;
|
||||
this->inp = inp;
|
||||
}
|
||||
/** Deconstructor */
|
||||
~OverlayMgr() { overlays.clear(); }
|
||||
|
||||
/**
|
||||
* Append a New Overlay
|
||||
* @param overlay Overlay reference to push
|
||||
*/
|
||||
void Push(Overlay::Ref overlay);
|
||||
/**
|
||||
* Update Overlays
|
||||
* @paran delta Deltatime
|
||||
*/
|
||||
void Update(float delta);
|
||||
|
||||
private:
|
||||
std::vector<Overlay::Ref> overlays;
|
||||
LI::Renderer::Ref ren;
|
||||
Hid::Ref inp;
|
||||
std::vector<Overlay::Ref> overlays; ///< Overlay List
|
||||
LI::Renderer::Ref ren; ///< Renderer reference
|
||||
Hid::Ref inp; ///< Input Driver reference
|
||||
};
|
||||
} // namespace PD
|
@ -27,8 +27,25 @@ SOFTWARE.
|
||||
#include <pd/overlays/overlay.hpp>
|
||||
|
||||
namespace PD {
|
||||
/**
|
||||
* Performance Overlay
|
||||
*
|
||||
* - Framerate / Frametime
|
||||
* - Renderer Avarage Time
|
||||
* - Overlays Avarage Time
|
||||
* - UserApp Average Time
|
||||
* - **V**ertices and **I**ndices
|
||||
* - **D**Draw Commands and Draw **C**alls
|
||||
* - Text Map System Texts
|
||||
* - Auto static Text Texts
|
||||
*/
|
||||
class Performance : public Overlay {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
* @param skill (if set to true the Overlay self kills)
|
||||
* @param screen Bottom or Top Screen
|
||||
*/
|
||||
Performance(bool& skill, bool& screen) {
|
||||
too++;
|
||||
if (too > 1) {
|
||||
@ -39,11 +56,24 @@ class Performance : public Overlay {
|
||||
*this->skill = false; // Make sure its false
|
||||
this->screen = &screen;
|
||||
}
|
||||
/** Deconstructor */
|
||||
~Performance() { too--; }
|
||||
|
||||
/**
|
||||
* Rendering Function
|
||||
* @param delta Deltatime
|
||||
* @param ren Renderer Reference
|
||||
* @param inp Input Driver Reference
|
||||
*/
|
||||
void Update(float delta, LI::Renderer::Ref ren, Hid::Ref inp) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Render an Info line
|
||||
* @param pos Position reference (gets updated for next line)
|
||||
* @param text Text to Show
|
||||
* @param ren Renderer Reference
|
||||
*/
|
||||
void Line(vec2& pos, const std::string& text, LI::Renderer::Ref ren);
|
||||
// Trace String Average
|
||||
std::string TSA(const std::string& id);
|
||||
|
@ -23,14 +23,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/drivers/hid.hpp>
|
||||
#include <pd/core/tween.hpp>
|
||||
#include <pd/drivers/hid.hpp>
|
||||
#include <pd/overlays/overlay.hpp>
|
||||
#include <pd/ui7/ui7.hpp>
|
||||
|
||||
namespace PD {
|
||||
/**
|
||||
* Settings Menu Overlay
|
||||
*/
|
||||
class SettingsMenu : public Overlay {
|
||||
public:
|
||||
/**
|
||||
* Constructor to setup Overlay
|
||||
*/
|
||||
SettingsMenu() {
|
||||
too++;
|
||||
if (too > 1) {
|
||||
@ -39,10 +45,15 @@ class SettingsMenu : public Overlay {
|
||||
}
|
||||
flymgr.From(vec2(0, 240)).To(vec2(0, 115)).In(0.3f).As(flymgr.EaseInQuad);
|
||||
}
|
||||
/** Deconstructor */
|
||||
~SettingsMenu() { too--; }
|
||||
|
||||
/** Rendering and Input Handler */
|
||||
void Update(float delta, LI::Renderer::Ref ren, Hid::Ref inp) override;
|
||||
|
||||
/**
|
||||
* Function to Trigger remove animation
|
||||
*/
|
||||
void Rem() {
|
||||
rem = true;
|
||||
flymgr.From(vec2(0, 115)).To(vec2(0, 240)).In(0.2f).As(flymgr.EaseOutQuad);
|
||||
|
Reference in New Issue
Block a user