# Rewrite Stage 1.5

- Added Overlays (Performance / Keyboaed)
- Keyboard has Gamepad Movement WIP (kinda)
- Work on UI7 Started
- Added Input Manager
- Added Message Boxes (Animated)
- Added Signle Header Tween func for animated stuff (Keyboard Messages, etc)
- Add FastHash (Maybe useful later)
- Using const & for vec in lithium
- Add ability to copy a command by a Ref
- Make Lists in Commands OpenAccess for Modification (StaticObject)
- Add Static Object (System to PreRender Suff that never changes) but can still be recolored or moved
- Add Layer and Font change functions
- Make Renderer Tools (RotateCorner, CreateRect, CreateLine, InBox, OptiCommandList) static (OpenAccess)
- Add ReIndexing to PushCommand
- Add Ability to Init vec3 and vec4 with vec2 and add .xy and .zw to vec4
- Fully Animated Keyboard that currently has problem of Top Down GamePad movement
- Add Func to Get GamePad Icon Codepoints for TextRenderer
- Made deltatime a float
- Using filesystem::path().wstring for convertation (works)
- Add a New InBox to Renderer that only checks if a point is inside a boundingbox
- Disable Font loading on Renderer Init due to 3ds Freezes when using SystemFont
- Make SystemFont lineheight 10% larger than it is to be nearly the same size as the ttf fonts
- Fix Some SpaceOffsets between TTF and SystemFont Rendering
- Cleanup the Update Rendermode Func
- Use LayerRenderSystem by default now as it now runs faster even with ttf fonts
This commit is contained in:
2025-01-19 20:16:43 +01:00
parent d815bb5674
commit b4a4b6a426
35 changed files with 1919 additions and 131 deletions

View File

@ -0,0 +1,105 @@
#pragma once
#include <pd/controls/hid.hpp>
#include <pd/maths/tween.hpp>
#include <pd/overlays/overlay.hpp>
namespace PD {
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
class Keyboard : public Overlay {
public:
enum KeyOperation {
AppendSelf = 0,
Shift = 1,
Backspace = 2,
Enter = 3,
OpCancel = 4,
OpConfirm = 5,
Tab = 6,
Caps = 7,
Space = 8,
Op1 = 9,
Op2 = 10,
};
enum Type {
Default,
Numpad,
Password,
};
enum State {
None,
Cancel,
Confirm,
};
using Flags = u32;
enum Flags_ {
Flags_None = 0,
Flags_BlendTop = 1 << 0,
Flags_BlendBottom = 1 << 1,
Flags_LockControls = 1 << 2,
Flags_Default = Flags_BlendBottom | Flags_BlendTop | Flags_LockControls,
};
Keyboard(std::string& text, State& state, const std::string& hint = "",
Type type = Default, Flags flags = Flags_Default) {
too++;
if (too > 1) {
Kill();
return;
}
this->text = &text;
this->copy = text;
this->state = &state;
this->hint = hint;
this->type = type;
this->flags = flags;
this->raw_sel = -1;
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);
}
~Keyboard() { too--; }
void Update(float delta, LI::Renderer::Ref ren, Hid::Ref inp) override;
void Rem() {
rem = true;
flymgr.From(vec2(0, 115)).To(vec2(0, 240)).In(0.2f).As(flymgr.EaseOutQuad);
}
private:
void LoadTheKeys(LI::Renderer::Ref ren);
void Movement(Hid::Ref inp);
void MoveSelector();
void DoOperation(KeyOperation op, const std::string& kname);
void RecolorBy(KeyOperation op, u32 color, int cm);
void InputOpBind(Hid::Key k, KeyOperation op, Hid::Ref inp, int cm);
std::string* text;
std::string copy;
std::string hint;
State* state;
Type type;
Flags flags;
int mode = 0; // def, caps, shift
// Stands for The Only One
static int too;
Tween<vec2> selector;
Tween<vec2> sel_szs;
vec2 cselszs;
int raw_sel;
// Performance Optimisation
LI::StaticObject::Ref keys[3];
bool keys_loadet = false;
// Some Animation
bool rem = false;
/// Probably a float would've done the job as well ;)
Tween<vec2> flymgr;
Tween<vec2> chflymgr;
bool show_help = true;
};
} // namespace PD

View File

@ -0,0 +1,45 @@
#pragma once
#include <pd/graphics/lithium.hpp>
#include <pd/maths/color.hpp>
#include <pd/maths/tween.hpp>
namespace PD {
class MessageMgr : public PD::SmartCtor<MessageMgr> {
public:
class Container : public PD::SmartCtor<Container> {
public:
Container(const std::string& title, const std::string& msg);
~Container() {}
void Render(PD::LI::Renderer::Ref ren);
void Update(int slot, float delta);
void FlyIn();
void ToBeMoved(int slot);
void ToBeRemoved();
bool ShouldBeRemoved() const { return (tbr && pos.IsFinished()) || kill; }
private:
PD::Color col_bg; // Background Color
PD::Color col_text; // Text Color
float lifetime = 0.f; // LifeTime
PD::Tween<vec2> pos; // Position effect
std::string title; // Title
std::string msg; // Message
vec2 size; // Size of the Background
bool tbr = false; // To be Removed ?
bool kill = false; // Instant Kill
int s = 0; // Slot
};
MessageMgr(PD::LI::Renderer::Ref r) { ren = r; }
~MessageMgr() {}
void Push(const std::string& title, const std::string& text);
void Update(float delta);
private:
std::vector<Container::Ref> msgs;
PD::LI::Renderer::Ref ren;
};
} // namespace PD

View File

@ -0,0 +1,23 @@
#pragma once
#include <pd/common/common.hpp>
#include <pd/controls/hid.hpp>
#include <pd/graphics/lithium.hpp>
namespace PD {
class Overlay : public SmartCtor<Overlay> {
public:
Overlay() {}
virtual ~Overlay() {}
virtual void Update(float delta, LI::Renderer::Ref ren, Hid::Ref inp) = 0;
bool IsKilled() const { return kill; }
protected:
void Kill() { kill = true; }
private:
bool kill = false;
};
} // namespace PD

View File

@ -0,0 +1,24 @@
#pragma once
#include <pd/controls/hid.hpp>
#include <pd/graphics/lithium.hpp>
#include <pd/overlays/overlay.hpp>
namespace PD {
class OverlayMgr : public SmartCtor<OverlayMgr> {
public:
OverlayMgr(LI::Renderer::Ref ren, Hid::Ref inp) {
this->ren = ren;
this->inp = inp;
}
~OverlayMgr() { overlays.clear(); }
void Push(Overlay::Ref overlay);
void Update(float delta);
private:
std::vector<Overlay::Ref> overlays;
LI::Renderer::Ref ren;
Hid::Ref inp;
};
} // namespace PD

View File

@ -0,0 +1,31 @@
#pragma once
#include <pd/overlays/overlay.hpp>
#include <pd/controls/hid.hpp>
namespace PD {
class Performance : public Overlay {
public:
Performance(bool& skill, bool& screen) {
too++;
if (too > 1) {
Kill();
return;
}
this->skill = &skill;
*this->skill = false; // Make sure its false
this->screen = &screen;
}
~Performance() { too--; }
void Update(float delta, LI::Renderer::Ref ren, Hid::Ref inp) override;
private:
void Line(vec2& pos, const std::string& text, LI::Renderer::Ref ren);
// Trace String Average
std::string TSA(const std::string& id);
// Described in Keyboard
static int too;
bool *skill, *screen;
};
} // namespace PD

View File

@ -0,0 +1,38 @@
#pragma once
#include <pd/maths/tween.hpp>
#include <pd/overlays/overlay.hpp>
#include <pd/controls/hid.hpp>
namespace PD {
class SettingsMenu : public Overlay {
public:
SettingsMenu() {
too++;
if (too > 1) {
Kill();
return;
}
flymgr.From(vec2(0, 240)).To(vec2(0, 115)).In(0.3f).As(flymgr.EaseInQuad);
}
~SettingsMenu() { too--; }
void Update(float delta, LI::Renderer::Ref ren, Hid::Ref inp) override;
void Rem() {
rem = true;
flymgr.From(vec2(0, 115)).To(vec2(0, 240)).In(0.2f).As(flymgr.EaseOutQuad);
}
private:
/// Section is used to determinate what
/// should be displayed on the top screen
int section = 0;
// Stands for The Only One
static int too;
// Some Animation
bool rem = false;
Tween<vec2> flymgr;
};
} // namespace PD