WIP Backend System Redesign Step 1

- Created 1 Context for Backend Management and Sharing
- Made every class that used a static Backend require the Context or specific Backend
- Bring Back 3ds support
This commit is contained in:
2026-01-26 20:46:27 +01:00
parent 892f8ce0c4
commit e8072a064c
47 changed files with 350 additions and 242 deletions

View File

@@ -32,7 +32,9 @@ namespace PD {
namespace UI7 {
class InputHandler {
public:
InputHandler() { DragTime = Timer::New(false); }
InputHandler(PD::Context& ctx) : pCtx(ctx) {
DragTime = Timer::New(*pCtx.Os().get(), false);
}
~InputHandler() = default;
PD_SHARED(InputHandler);
@@ -55,10 +57,10 @@ class InputHandler {
}
}
// Get a Short define for touch pos
fvec2 p = Hid::MousePos();
fvec2 p = pCtx.Hid()->MousePos();
// Check if Drag starts in the area position
if ((Hid::IsDown(Hid::Key::Touch) ||
Hid::IsEvent(PD::Hid::Event::Event_Down, HidKb::Kb_MouseLeft)) &&
if ((pCtx.Hid()->IsDown(pCtx.Hid()->Key::Touch) ||
pCtx.Hid()->IsEvent(PD::HidDriver::Event_Down, HidKb::Kb_MouseLeft)) &&
Li::Renderer::InBox(p, area)) {
// Set ID and iniatial Positions
DraggedObject = id;
@@ -70,15 +72,16 @@ class InputHandler {
DragTime->Reset();
DragTime->Rseume();
return false; // To make sure the Object is "Dragged"
} else if ((Hid::IsHeld(Hid::Key::Touch) ||
Hid::IsEvent(PD::Hid::Event::Event_Held,
HidKb::Kb_MouseLeft)) &&
} else if ((pCtx.Hid()->IsHeld(pCtx.Hid()->Key::Touch) ||
pCtx.Hid()->IsEvent(PD::HidDriver::Event_Held,
HidKb::Kb_MouseLeft)) &&
IsObjectDragged()) {
// Update DragLast and DragPoisition
DragLastPosition = DragPosition;
DragPosition = p;
} else if ((Hid::IsUp(Hid::Key::Touch) ||
Hid::IsEvent(PD::Hid::Event::Event_Up, HidKb::Kb_MouseLeft)) &&
} else if ((pCtx.Hid()->IsUp(pCtx.Hid()->Key::Touch) ||
pCtx.Hid()->IsEvent(PD::HidDriver::Event_Up,
HidKb::Kb_MouseLeft)) &&
IsObjectDragged()) {
// Released... Everything gets reset
DraggedObject = 0;
@@ -88,9 +91,9 @@ class InputHandler {
DragDestination = fvec4(0);
// Set Drag released to true (only one frame)
// and Only if still in Box
DragReleased = Li::Renderer::InBox(Hid::MousePosLast(), area);
DragReleased = Li::Renderer::InBox(pCtx.Hid()->MousePosLast(), area);
DragReleasedAW = true; // Advanced
u64 d_rel = PD::OS::GetTime();
u64 d_rel = pCtx.Os()->GetTime();
if (d_rel - DragLastReleased < DoubleClickTime) {
DragDoubleRelease = true;
DragLastReleased = 0; // Set 0 to prevent double exec
@@ -129,6 +132,7 @@ class InputHandler {
bool DragReleased = false; ///< Drag Releaded in Box
bool DragReleasedAW = false; ///< Drag Released Anywhere
bool DragDoubleRelease = false; ///< Double Click
PD::Context& pCtx;
/** Check if an object is Dragged already */
bool IsObjectDragged() const { return DraggedObject != 0; }
};

View File

@@ -30,20 +30,21 @@ SOFTWARE.
#include <pd/ui7/viewport.hpp>
namespace PD {
class Context;
namespace UI7 {
class PD_API IO {
public:
IO() {
Time = Timer::New();
InputHandler = InputHandler::New();
IO(PD::Context& ctx) : pCtx(ctx) {
Time = Timer::New(*pCtx.Os().get());
InputHandler = InputHandler::New(pCtx);
Theme = UI7::Theme::New();
Back = Li::DrawList::New();
Front = Li::DrawList::New();
FDL = Li::DrawList::New();
Back = Li::DrawList::New(pCtx);
Front = Li::DrawList::New(pCtx);
FDL = Li::DrawList::New(pCtx);
DeltaStats = TimeStats::New(60);
/** Probably not the best solution i guess */
CurrentViewPort.z = PD::Gfx::pGfx->ViewPort.x;
CurrentViewPort.w = PD::Gfx::pGfx->ViewPort.y;
CurrentViewPort.z = pCtx.Gfx()->ViewPort.x;
CurrentViewPort.w = pCtx.Gfx()->ViewPort.y;
}
~IO() {}
@@ -90,6 +91,8 @@ class PD_API IO {
u32 NumIndices = 0; ///< Debug Indices Num
std::vector<u32> MenuOrder;
PD::Context& pCtx; // Palladium base context
// DrawListApi
void RegisterDrawList(const UI7::ID& id, Li::DrawList::Ref v) {
DrawListRegestry.push_back(std::make_pair(id, v));

View File

@@ -38,7 +38,7 @@ class PD_API Layout {
public:
Layout(const ID& id, IO::Ref io) : ID(id) {
this->IO = io;
DrawList = Li::DrawList::New();
DrawList = Li::DrawList::New(io->pCtx);
DrawList->SetFont(IO->Font);
DrawList->SetFontScale(io->FontScale);
Scrolling[0] = false;

View File

@@ -49,7 +49,7 @@ PD_API std::string GetVersion(bool show_build = false);
/** Base Context for UI7 */
class PD_API Context {
public:
Context() { pIO = IO::New(); }
Context(PD::Context& ctx) { pIO = IO::New(ctx); }
~Context() = default;
PD_SHARED(Context);