# Stage 2.1

- Split palladium into diffrent libraries
- Fix a Logical bug in App class
- Add New Flag to Init App Data Directory
- Add Cmake Option for build tests
- Bump Version in cmake file
- Make Hid a Driver
- Start moving 3ds specific stuff into pd-lib3ds
- Split Lithium into more files
This commit is contained in:
2025-02-22 00:23:48 +01:00
parent cbdb15e0de
commit f9a1d8aefb
73 changed files with 1705 additions and 508 deletions

View File

@ -24,22 +24,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// Common
#include <pd/common/app.hpp>
#include <pd/common/lang.hpp>
#include <pd/common/strings.hpp>
#include <pd/common/sys.hpp>
#include <pd/common/timetrace.hpp>
// Core
#include <pd/core/common.hpp>
#include <pd/core/io.hpp>
#include <pd/core/strings.hpp>
#include <pd/core/sys.hpp>
#include <pd/core/timetrace.hpp>
// Graphics
#include <pd/graphics/lithium.hpp>
#include <pd/graphics/spritesheet.hpp>
#include <pd/graphics/texture.hpp>
#include <pd/lithium/renderer.hpp>
#include <pd/lithium/spritesheet.hpp>
// Maths
#include <pd/maths/bit_util.hpp>
#include <pd/maths/color.hpp>
#include <pd/maths/img_blur.hpp>
#include <pd/maths/img_convert.hpp>
#include <pd/maths/vec.hpp>
// Drivers
#include <pd/drivers/hid.hpp>
// Overlays
#include <pd/overlays/keyboard.hpp>
#include <pd/overlays/message_mgr.hpp>
@ -49,6 +50,12 @@ SOFTWARE.
// UI7
#include <pd/ui7/ui7.hpp>
// App
#include <pd/app/app.hpp>
#include <pd/app/error.hpp>
#include <pd/app/lang.hpp>
#include <pd/app/timer.hpp>
/// Setup these as non Namespaced access by default
#ifndef PD_MATH_NAMESPACED
using vec2 = PD::vec2;

View File

@ -23,10 +23,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/common/timetrace.hpp>
#include <pd/controls/hid.hpp>
#include <pd/graphics/lithium.hpp>
#include <pd/core/common.hpp>
#include <pd/core/timetrace.hpp>
#include <pd/lib3ds/drv_hid.hpp>
#include <pd/lithium/renderer.hpp>
#include <pd/overlays/message_mgr.hpp>
#include <pd/overlays/overlay_mgr.hpp>
@ -52,16 +52,20 @@ class App {
AppInitFlags_New3dsMode = 1 << 2,
AppInitFlags_InitGraphicsNoC3D = 1 << 3,
AppInitFlags_InitLithium = 1 << 4,
/// I dont have a name for this one yet
/// It Inits Internal Directory structure
AppInitFlags_UnnamedOption1 = 1 << 5,
AppInitFlags_Default = AppInitFlags_MountRomfs | AppInitFlags_InitGraphics |
AppInitFlags_New3dsMode | AppInitFlags_InitLithium,
};
App() {
App(const std::string& name = "App") {
if (too) {
Error("Only one App can be created at the same time!");
}
this->name = name;
too++;
}
~App() = default;
~App() { too--; }
/// @brief Templete function where the user can Init his stuff
virtual void Init() {}
@ -110,6 +114,8 @@ class App {
float app_time;
float fps;
std::string name;
/// The Only One
static int too;
};

View File

@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/core/common.hpp>
namespace PD {
void Error(const std::string& error);

View File

@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/core/common.hpp>
namespace PD {
/// @brief Lang System

View File

@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/common/sys.hpp>
#include <pd/core/common.hpp>
#include <pd/core/sys.hpp>
namespace PD {
class Timer {

View File

@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/core/common.hpp>
namespace PD {
namespace IO {

View File

@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/core/common.hpp>
namespace PD {
class Markdown {

View File

@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/core/common.hpp>
namespace PD {
namespace Strings {

View File

@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/common/timetrace.hpp>
#include <pd/core/common.hpp>
#include <pd/core/timetrace.hpp>
namespace PD {
namespace Sys {

View File

@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/core/common.hpp>
namespace PD {
class TimeStats : public SmartCtor<TimeStats> {

View File

@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/core/common.hpp>
#include <pd/maths/vec.hpp>
namespace PD {
@ -64,7 +64,7 @@ class Hid : public SmartCtor<Hid> {
Event_Held,
Event_Up,
};
Hid();
Hid() {}
~Hid() {}
vec2 TouchPos() const { return touch[0]; }
@ -105,14 +105,14 @@ class Hid : public SmartCtor<Hid> {
/// @brief Get the New Keystates etc
/// @note WOW not using the deltatime
void Update();
virtual void Update() {}
private:
protected:
std::unordered_map<u32, u32> binds;
void SwappyTable();
/// Using 2 Touch positions for current and last frame
vec2 touch[2];
bool locked = false;
std::unordered_map<Event, u32> key_events[2];
std::unordered_map<u32, u32> binds;
};
} // namespace PD

View File

@ -0,0 +1,36 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 René Amthor (tobid7)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/drivers/hid.hpp>
namespace PD {
class CtrHid : public Hid {
public:
CtrHid();
~CtrHid() {}
void Update() override;
};
} // namespace PD

View File

@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/controls/hid.hpp>
#include <pd/core/common.hpp>
#include <pd/drivers/hid.hpp>
namespace PD {
namespace GamePadIcons {

View File

@ -26,8 +26,8 @@ SOFTWARE.
#include <3ds.h>
#include <pd/common/common.hpp>
#include <pd/common/error.hpp>
#include <pd/core/common.hpp>
#include <pd/app/error.hpp>
namespace PD {
template <typename T>

View File

@ -25,13 +25,12 @@ SOFTWARE.
#include <3ds.h>
#include <pd/common/common.hpp>
#include <pd/tools/markdown.hpp>
#include <pd/core/common.hpp>
#include <pd/core/markdown.hpp>
namespace PD {
class ResultDecoder {
public:
ResultDecoder(Result res);
public:
ResultDecoder(Result res);
};
} // namespace PD

View File

@ -0,0 +1,105 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/core/common.hpp>
#include <pd/lithium/flags.hpp>
#include <pd/lithium/texture.hpp>
#include <pd/lithium/vertex.hpp>
#include <pd/maths/vec.hpp>
namespace PD {
namespace LI {
/// @brief Reform the Drawcommand by generating the Vertexbuffer into it
class Command : public SmartCtor<Command> {
public:
Command() {}
~Command() {}
Command(Command::Ref v) {
this->index = v->index;
this->index_buf = v->index_buf;
this->layer = v->layer;
this->mode = v->mode;
this->tex = v->tex;
this->vertex_buf = v->vertex_buf;
}
Command& Layer(int v) {
layer = v;
return *this;
}
int Layer() const { return layer; }
Command& Index(int v) {
index = v;
return *this;
}
int Index() const { return index; }
Command& Tex(Texture::Ref v) {
tex = v;
return *this;
}
Texture::Ref Tex() const { return tex; }
Command& PushVertex(const Vertex& v) {
vertex_buf.push_back(v);
return *this;
}
const std::vector<u16>& IndexList() const { return index_buf; }
const std::vector<Vertex>& VertexList() const { return vertex_buf; }
/// ADVANCED ///
std::vector<u16>& IndexList() { return index_buf; }
std::vector<Vertex>& VertexList() { return vertex_buf; }
Command& PushIndex(u16 v) {
index_buf.push_back(vertex_buf.size() + v);
return *this;
}
Command& Rendermode(const RenderMode& v) {
mode = v;
return *this;
}
RenderMode Rendermode() const { return mode; }
private:
/// Using Default std::vector here
std::vector<Vertex> vertex_buf;
std::vector<u16> index_buf;
int layer;
Texture::Ref tex;
int index;
RenderMode mode = RenderMode_RGBA;
};
} // namespace LI
} // namespace PD

View File

@ -0,0 +1,60 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/core/common.hpp>
using LITextFlags = PD::u32;
enum LITextFlags_ {
LITextFlags_None = 0,
LITextFlags_AlignRight = 1 << 0,
LITextFlags_AlignMid = 1 << 1,
LITextFlags_Shaddow = 1 << 2, // Draws the text twice
LITextFlags_Wrap = 1 << 3, // May be runs better with TMS
LITextFlags_Short = 1 << 4, // May be runs better with TMS
LITextFlags_Scroll = 1 << 5, // Not implemented
LITextFlags_RenderOOS = 1 << 6 // Render Out of Screen
};
using LIRenderFlags = PD::u32;
enum LIRenderFlags_ {
LIRenderFlags_None = 0,
LIRenderFlags_TMS = 1 << 0, ///< Text Map System
LIRenderFlags_LRS = 1 << 1, ///< Layer Render System
LIRenderFlags_AST = 1 << 2, ///< Auto Static Text
LIRenderFlags_Default =
LIRenderFlags_TMS | LIRenderFlags_LRS | LIRenderFlags_AST,
};
namespace PD {
namespace LI {
/// @brief Required to Set the TexENV
enum RenderMode {
RenderMode_RGBA,
RenderMode_Font,
};
} // namespace LI
} // namespace PD

View File

@ -0,0 +1,95 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/core/common.hpp>
#include <pd/lithium/rect.hpp>
#include <pd/lithium/texture.hpp>
#include <pd/maths/vec.hpp>
namespace PD {
namespace LI {
class Font : public SmartCtor<Font> {
public:
class Codepoint {
public:
Codepoint() {}
~Codepoint() {}
u32 cp() const { return m_cp; }
Codepoint& cp(u32 v) {
m_cp = v;
return *this;
}
vec4 uv() const { return m_uv; }
Codepoint& uv(const vec4& v) {
m_uv = v;
return *this;
}
Texture::Ref tex() const { return m_tex; }
Codepoint& tex(Texture::Ref v) {
m_tex = v;
return *this;
}
vec2 size() const { return m_size; }
Codepoint& size(const vec2& v) {
m_size = v;
return *this;
}
float off() const { return m_off; }
Codepoint& off(float v) {
m_off = v;
return *this;
}
bool invalid() const { return m_invalid; }
Codepoint& invalid(bool v) {
m_invalid = v;
return *this;
}
private:
u32 m_cp = 0;
vec4 m_uv;
Texture::Ref m_tex = nullptr;
vec2 m_size;
float m_off = 0;
bool m_invalid = false;
};
Font() {}
~Font() {}
void LoadTTF(const std::string& path, int px_height = 32);
void LoadSystemFont();
int PixelHeight() const { return pixel_height; }
Codepoint& GetCodepoint(u32 c);
bool SystemFont() const { return sysfont; }
private:
bool sysfont;
int pixel_height;
std::vector<Texture::Ref> textures;
std::map<u32, Codepoint> cpmap;
};
} // namespace LI
} // namespace PD

View File

@ -0,0 +1,166 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/core/common.hpp>
#include <pd/lithium/command.hpp>
#include <pd/lithium/flags.hpp>
#include <pd/lithium/font.hpp>
#include <pd/lithium/texture.hpp>
#include <pd/lithium/vertex.hpp>
#include <pd/maths/vec.hpp>
namespace PD {
namespace LI {
class Renderer;
class StaticObject : public SmartCtor<StaticObject> {
public:
StaticObject() {}
~StaticObject() {}
void PushCommand(Command::Ref v) { cmds.push_back(v); }
void ReCopy() {
cpy.clear();
for (auto it : cmds) {
cpy.push_back(Command::New(it));
}
}
void ReColorQuad(int idx, u32 col) {
if (idx > (int)cpy.size()) {
return;
}
for (auto& it : cpy[idx]->VertexList()) {
it.Color(col);
}
}
void MoveIt(vec2 off) {
for (auto& it : cpy) {
for (auto& jt : it->VertexList()) {
jt.pos += off;
}
}
}
void ReColor(u32 col) {
for (auto& it : cpy) {
for (auto& jt : it->VertexList()) {
jt.Color(col);
}
}
}
void ReLayer(int base_layer) {
for (auto& it : cpy) {
it->Layer(it->Layer() + base_layer);
}
}
void ReIndex(int start) {
for (int i = 0; i < (int)cpy.size(); i++) {
cpy[i]->Index(start + i);
}
}
std::vector<Command::Ref>& List() {
if (cpy.size() != 0) {
return cpy;
}
return cmds;
}
private:
std::vector<Command::Ref> cpy;
std::vector<Command::Ref> cmds;
};
class TextBox {
public:
TextBox() {}
TextBox(const vec2& s, float time) {
size = s;
time_created = time;
optional = false;
}
~TextBox() {}
void TimeCreated(float v) { time_created = v; }
void Size(const vec2& v) { size = v; }
void Optional(bool v) { optional = v; }
void Text(const std::string& v) { text = v; }
vec2 Size() const { return size; }
float TimeCreated() const { return time_created; }
bool Optional() const { return optional; }
std::string Text() const { return text; }
private:
vec2 size;
float time_created;
bool optional;
std::string text; // TextWrap
};
class StaticText : public SmartCtor<StaticText> {
public:
StaticText() {}
StaticText(Renderer* ren, const vec2& pos, u32 clr, const std::string& text,
LITextFlags flags = 0, const vec2& box = 0) {
Setup(ren, pos, clr, text, flags, box);
}
~StaticText() {}
void Setup(Renderer* ren, const vec2& pos, u32 clr, const std::string& text,
LITextFlags flags = 0, const vec2& box = 0);
vec2 GetDim() const { return tdim; }
vec2 GetPos() const { return pos; }
void SetColor(u32 col);
void SetPos(const vec2& pos);
void SetLayer(int l);
void SetUnused() { used = false; }
bool Used() const { return used; }
bool IsSetup() { return text != nullptr; }
void Draw();
void Font(Font::Ref fnt) { font = fnt; }
Font::Ref Font() { return font; }
private:
Font::Ref font;
bool used;
Renderer* ren;
vec2 tdim;
vec2 pos;
StaticObject::Ref text;
};
} // namespace LI
} // namespace PD

View File

@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/core/common.hpp>
#include <pd/maths/vec.hpp>
namespace PD {

View File

@ -24,332 +24,24 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/common/memory.hpp>
#include <pd/graphics/rect.hpp>
#include <pd/graphics/screen.hpp>
#include <pd/graphics/texture.hpp>
#include <pd/core/common.hpp>
#include <pd/lib3ds/memory.hpp>
#include <pd/lithium/command.hpp>
#include <pd/lithium/flags.hpp>
#include <pd/lithium/font.hpp>
#include <pd/lithium/objects.hpp>
#include <pd/lithium/screen.hpp>
#include <pd/lithium/texture.hpp>
#include <pd/lithium/vertex.hpp>
#include <pd/maths/vec.hpp>
#include <pd/tools/markdown.hpp>
using LITextFlags = u32;
enum LITextFlags_ {
LITextFlags_None = 0,
LITextFlags_AlignRight = 1 << 0,
LITextFlags_AlignMid = 1 << 1,
LITextFlags_Shaddow = 1 << 2, // Draws the text twice
LITextFlags_Wrap = 1 << 3, // May be runs better with TMS
LITextFlags_Short = 1 << 4, // May be runs better with TMS
LITextFlags_Scroll = 1 << 5, // Not implemented
LITextFlags_RenderOOS = 1 << 6 // Render Out of Screen
};
namespace PD {
namespace LI {
class Font : public SmartCtor<Font> {
public:
class Codepoint {
public:
Codepoint() {}
~Codepoint() {}
u32 cp() const { return m_cp; }
Codepoint& cp(u32 v) {
m_cp = v;
return *this;
}
vec4 uv() const { return m_uv; }
Codepoint& uv(const vec4& v) {
m_uv = v;
return *this;
}
Texture::Ref tex() const { return m_tex; }
Codepoint& tex(Texture::Ref v) {
m_tex = v;
return *this;
}
vec2 size() const { return m_size; }
Codepoint& size(const vec2& v) {
m_size = v;
return *this;
}
float off() const { return m_off; }
Codepoint& off(float v) {
m_off = v;
return *this;
}
bool invalid() const { return m_invalid; }
Codepoint& invalid(bool v) {
m_invalid = v;
return *this;
}
private:
u32 m_cp = 0;
vec4 m_uv;
Texture::Ref m_tex = nullptr;
vec2 m_size;
float m_off = 0;
bool m_invalid = false;
};
Font() {}
~Font() {}
void LoadTTF(const std::string& path, int px_height = 32);
void LoadSystemFont();
int PixelHeight() const { return pixel_height; }
Codepoint& GetCodepoint(u32 c);
bool SystemFont() const { return sysfont; }
private:
bool sysfont;
int pixel_height;
std::vector<Texture::Ref> textures;
std::map<u32, Codepoint> cpmap;
};
class Vertex {
public:
Vertex() {}
Vertex(const vec2& p, const vec2& u, u32 c) {
pos[0] = p[0];
pos[1] = p[1];
uv = u;
color = c;
}
~Vertex() {}
Vertex& Pos(const vec2& v) {
pos = v;
return *this;
}
Vertex& Uv(const vec2& v) {
uv = v;
return *this;
}
Vertex& Color(u32 v) {
color = v;
return *this;
}
// private:
vec2 pos;
vec2 uv;
u32 color;
};
/// @brief Required to Set the TexENV
enum RenderMode {
RenderMode_RGBA,
RenderMode_Font,
};
/// @brief Reform the Drawcommand by generating the Vertexbuffer into it
class Command : public SmartCtor<Command> {
public:
Command() {}
~Command() {}
Command(Command::Ref v) {
this->index = v->index;
this->index_buf = v->index_buf;
this->layer = v->layer;
this->mode = v->mode;
this->tex = v->tex;
this->vertex_buf = v->vertex_buf;
}
Command& Layer(int v) {
layer = v;
return *this;
}
int Layer() const { return layer; }
Command& Index(int v) {
index = v;
return *this;
}
int Index() const { return index; }
Command& Tex(Texture::Ref v) {
tex = v;
return *this;
}
Texture::Ref Tex() const { return tex; }
Command& PushVertex(const Vertex& v) {
vertex_buf.push_back(v);
return *this;
}
const std::vector<u16>& IndexList() const { return index_buf; }
const std::vector<Vertex>& VertexList() const { return vertex_buf; }
/// ADVANCED ///
std::vector<u16>& IndexList() { return index_buf; }
std::vector<Vertex>& VertexList() { return vertex_buf; }
Command& PushIndex(u16 v) {
index_buf.push_back(vertex_buf.size() + v);
return *this;
}
Command& Rendermode(const RenderMode& v) {
mode = v;
return *this;
}
RenderMode Rendermode() const { return mode; }
private:
/// Using Default std::vector here
std::vector<Vertex> vertex_buf;
std::vector<u16> index_buf;
int layer;
Texture::Ref tex;
int index;
RenderMode mode = RenderMode_RGBA;
};
class TextBox {
public:
TextBox() {}
TextBox(const vec2& s, float time) {
size = s;
time_created = time;
optional = false;
}
~TextBox() {}
void TimeCreated(float v) { time_created = v; }
void Size(const vec2& v) { size = v; }
void Optional(bool v) { optional = v; }
void Text(const std::string& v) { text = v; }
vec2 Size() const { return size; }
float TimeCreated() const { return time_created; }
bool Optional() const { return optional; }
std::string Text() const { return text; }
private:
vec2 size;
float time_created;
bool optional;
std::string text; // TextWrap
};
class StaticObject : public SmartCtor<StaticObject> {
public:
StaticObject() {}
~StaticObject() {}
void PushCommand(Command::Ref v) { cmds.push_back(v); }
void ReCopy() {
cpy.clear();
for (auto it : cmds) {
cpy.push_back(Command::New(it));
}
}
void ReColorQuad(int idx, u32 col) {
if (idx > (int)cpy.size()) {
return;
}
for (auto& it : cpy[idx]->VertexList()) {
it.Color(col);
}
}
void MoveIt(vec2 off) {
for (auto& it : cpy) {
for (auto& jt : it->VertexList()) {
jt.pos += off;
}
}
}
void ReColor(u32 col) {
for (auto& it : cpy) {
for (auto& jt : it->VertexList()) {
jt.Color(col);
}
}
}
void ReLayer(int base_layer) {
for (auto& it : cpy) {
it->Layer(it->Layer() + base_layer);
}
}
void ReIndex(int start) {
for (int i = 0; i < (int)cpy.size(); i++) {
cpy[i]->Index(start + i);
}
}
std::vector<Command::Ref>& List() {
if (cpy.size() != 0) {
return cpy;
}
return cmds;
}
private:
std::vector<Command::Ref> cpy;
std::vector<Command::Ref> cmds;
};
using RenderFlags = u32;
enum RenderFlags_ {
RenderFlags_None = 0,
RenderFlags_TMS = 1 << 0, ///< Text Map System
RenderFlags_LRS = 1 << 1, ///< Layer Render System
RenderFlags_AST = 1 << 2, ///< Auto Static Text
RenderFlags_Default = RenderFlags_TMS | RenderFlags_LRS | RenderFlags_AST,
};
class Renderer : public SmartCtor<Renderer> {
public:
Renderer(RenderFlags flags = RenderFlags_Default);
Renderer(LIRenderFlags flags = LIRenderFlags_Default);
~Renderer();
class StaticText : public SmartCtor<StaticText> {
public:
StaticText() {}
StaticText(Renderer* ren, const vec2& pos, u32 clr, const std::string& text,
LITextFlags flags = 0, const vec2& box = 0) {
Setup(ren, pos, clr, text, flags, box);
}
~StaticText() {}
void Setup(Renderer* ren, const vec2& pos, u32 clr, const std::string& text,
LITextFlags flags = 0, const vec2& box = 0);
vec2 GetDim() const { return tdim; }
vec2 GetPos() const { return pos; }
void SetColor(u32 col);
void SetPos(const vec2& pos);
void SetLayer(int l);
void SetUnused() { used = false; }
bool Used() const { return used; }
bool IsSetup() { return text != nullptr; }
void Draw();
void Font(Font::Ref fnt) { font = fnt; }
Font::Ref Font() { return font; }
private:
Font::Ref font;
bool used;
Renderer* ren;
vec2 tdim;
vec2 pos;
StaticObject::Ref text;
};
void PrepareRender();
void Render(Screen::Ref s);
void FinalizeRender();
@ -377,7 +69,7 @@ class Renderer : public SmartCtor<Renderer> {
float TextScale() const { return text_size; }
void Layer(int v) { current_layer = v; }
int Layer() const { return current_layer; }
RenderFlags& GetFlags() { return flags; }
LIRenderFlags& GetFlags() { return flags; }
void Font(Font::Ref v) {
font = v;
font_update = true;
@ -494,7 +186,7 @@ class Renderer : public SmartCtor<Renderer> {
Screen::Ref screens[2];
/// Context Related ///
RenderFlags flags = RenderFlags_Default;
LIRenderFlags flags = LIRenderFlags_Default;
vec2 area_size;
int current_layer = 0;
Texture::Ref current_tex = nullptr;

View File

@ -26,7 +26,7 @@ SOFTWARE.
#include <3ds.h>
#include <citro3d.h>
#include <pd/common/common.hpp>
#include <pd/core/common.hpp>
#include <pd/maths/vec.hpp>
namespace PD {

View File

@ -26,9 +26,8 @@ SOFTWARE.
#include <citro3d.h>
#include <tex3ds.h>
#include <pd/common/common.hpp>
#include <pd/graphics/lithium.hpp>
#include <pd/graphics/texture.hpp>
#include <pd/core/common.hpp>
#include <pd/lithium/texture.hpp>
namespace PD {
class SpriteSheet : public SmartCtor<SpriteSheet> {

View File

@ -26,8 +26,8 @@ SOFTWARE.
#include <citro3d.h>
#include <pd/common/common.hpp>
#include <pd/graphics/rect.hpp>
#include <pd/core/common.hpp>
#include <pd/lithium/rect.hpp>
#include <pd/maths/vec.hpp>
namespace PD {

View File

@ -0,0 +1,62 @@
#pragma once
/*
MIT License
Copyright (c) 2024 - 2025 tobid7
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/core/common.hpp>
#include <pd/maths/vec.hpp>
namespace PD {
namespace LI {
class Vertex {
public:
Vertex() {}
Vertex(const vec2& p, const vec2& u, u32 c) {
pos[0] = p[0];
pos[1] = p[1];
uv = u;
color = c;
}
~Vertex() {}
Vertex& Pos(const vec2& v) {
pos = v;
return *this;
}
Vertex& Uv(const vec2& v) {
uv = v;
return *this;
}
Vertex& Color(u32 v) {
color = v;
return *this;
}
// private:
vec2 pos;
vec2 uv;
u32 color;
};
} // namespace LI
} // namespace PD

View File

@ -24,7 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/core/common.hpp>
namespace PD {
namespace BitUtil {

View File

@ -24,7 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/core/common.hpp>
namespace PD {
/// @brief Color class (Supports hex, rgb(a)8, u32 input)

View File

@ -24,7 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/core/common.hpp>
#include <pd/maths/vec.hpp>
namespace PD {

View File

@ -24,7 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/core/common.hpp>
#include <pd/maths/img.hpp>
#include <pd/maths/vec.hpp>

View File

@ -24,7 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/core/common.hpp>
namespace PD {
namespace ImgConvert {

View File

@ -29,7 +29,7 @@ SOFTWARE.
* and easy to use like in glsl or glm
*/
#include <pd/common/common.hpp>
#include <pd/core/common.hpp>
namespace PD {
struct vec2 {

View File

@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/controls/hid.hpp>
#include <pd/drivers/hid.hpp>
#include <pd/maths/tween.hpp>
#include <pd/overlays/overlay.hpp>

View File

@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/graphics/lithium.hpp>
#include <pd/lithium/renderer.hpp>
#include <pd/maths/color.hpp>
#include <pd/maths/tween.hpp>

View File

@ -23,9 +23,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/controls/hid.hpp>
#include <pd/graphics/lithium.hpp>
#include <pd/core/common.hpp>
#include <pd/drivers/hid.hpp>
#include <pd/lithium/renderer.hpp>
namespace PD {
class Overlay : public SmartCtor<Overlay> {

View File

@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/controls/hid.hpp>
#include <pd/graphics/lithium.hpp>
#include <pd/drivers/hid.hpp>
#include <pd/lithium/renderer.hpp>
#include <pd/overlays/overlay.hpp>
namespace PD {

View File

@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/drivers/hid.hpp>
#include <pd/overlays/overlay.hpp>
#include <pd/controls/hid.hpp>
namespace PD {
class Performance : public Overlay {

View File

@ -23,8 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/app.hpp>
#include <pd/controls/hid.hpp>
#include <pd/drivers/hid.hpp>
#include <pd/maths/tween.hpp>
#include <pd/overlays/overlay.hpp>
#include <pd/ui7/ui7.hpp>
@ -32,14 +31,12 @@ SOFTWARE.
namespace PD {
class SettingsMenu : public Overlay {
public:
SettingsMenu(PD::App* app) {
SettingsMenu() {
too++;
if (too > 1) {
Kill();
return;
}
app_ref = app;
app->FeatureDisable(PD::App::AppFLags_UserLoop);
flymgr.From(vec2(0, 240)).To(vec2(0, 115)).In(0.3f).As(flymgr.EaseInQuad);
}
~SettingsMenu() { too--; }
@ -48,12 +45,10 @@ class SettingsMenu : public Overlay {
void Rem() {
rem = true;
app_ref->FeatureEnable(App::AppFLags_UserLoop);
flymgr.From(vec2(0, 115)).To(vec2(0, 240)).In(0.2f).As(flymgr.EaseOutQuad);
}
private:
PD::App* app_ref = nullptr;
/// Section is used to determinate what
/// should be displayed on the top screen
int section = 0;

View File

@ -23,9 +23,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/common/strings.hpp>
#include <pd/controls/hid.hpp>
#include <pd/core/common.hpp>
#include <pd/core/strings.hpp>
#include <pd/drivers/hid.hpp>
#include <pd/maths/vec.hpp>
#include <pd/ui7/drawlist.hpp>

View File

@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/graphics/lithium.hpp>
#include <pd/core/common.hpp>
#include <pd/lithium/renderer.hpp>
#include <pd/ui7/theme.hpp>
namespace PD {
@ -61,7 +61,7 @@ class DrawList : public SmartCtor<DrawList> {
int layer;
int base;
LI::Renderer::Ref ren;
std::unordered_map<u32, LI::Renderer::StaticText::Ref> static_text;
std::unordered_map<u32, LI::StaticText::Ref> static_text;
std::vector<std::pair<bool, LI::Command::Ref>> commands;
};
} // namespace UI7

View File

@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/common/strings.hpp>
#include <pd/core/common.hpp>
#include <pd/core/strings.hpp>
namespace PD {
namespace UI7 {

View File

@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/controls/hid.hpp>
#include <pd/drivers/hid.hpp>
#include <pd/maths/tween.hpp>
#include <pd/ui7/containers.hpp>
#include <pd/ui7/drawlist.hpp>

View File

@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/common/common.hpp>
#include <pd/core/common.hpp>
using UI7Color = PD::u32;

View File

@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include <pd/controls/hid.hpp> //// WOW A NON UI/ Header
#include <pd/drivers/hid.hpp> //// WOW A NON UI/ Header
#include <pd/ui7/drawlist.hpp>
#include <pd/ui7/flags.hpp>
#include <pd/ui7/id.hpp>