# 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:
parent
cbdb15e0de
commit
f9a1d8aefb
181
CMakeLists.txt
181
CMakeLists.txt
@ -1,5 +1,29 @@
|
|||||||
cmake_minimum_required(VERSION 3.18)
|
cmake_minimum_required(VERSION 3.18)
|
||||||
|
|
||||||
|
### Helper Function to Build Librarys without have always
|
||||||
|
### These includes and definition defines
|
||||||
|
function(add_pd_lib TARGET_NAME)
|
||||||
|
set(opts "")
|
||||||
|
set(one_val_args "")
|
||||||
|
set(multi_val_args SRC_FILES DEPENDS)
|
||||||
|
cmake_parse_arguments(ARG "${opts}" "${one_val_args}" "${multi_val_args}" ${ARGN})
|
||||||
|
|
||||||
|
add_library(${TARGET_NAME} STATIC ${ARG_SRC_FILES})
|
||||||
|
target_include_directories(${TARGET_NAME} PUBLIC
|
||||||
|
include
|
||||||
|
${DEVKITPRO}/portlibs/3ds/include)
|
||||||
|
target_compile_definitions(${TARGET_NAME} PUBLIC
|
||||||
|
-D_GNU_SOURCE=1
|
||||||
|
-DPALLADIUM_VERSION="${PROJECT_VERSION}"
|
||||||
|
-DPALLADIUM_GIT_COMMIT="${GIT_SHORT_HASH}"
|
||||||
|
-DBUILD_CTR=1)
|
||||||
|
### For the libs that depend on another
|
||||||
|
if(ARG_DEPENDS)
|
||||||
|
target_link_libraries(${TARGET_NAME} PUBLIC ${ARG_DEPENDS})
|
||||||
|
endif()
|
||||||
|
install(TARGETS ${TARGET_NAME})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
# Setup Toolchain if not specified
|
# Setup Toolchain if not specified
|
||||||
# Could propably avoided by using arm-none-eabi-cmake
|
# Could propably avoided by using arm-none-eabi-cmake
|
||||||
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||||
@ -18,7 +42,9 @@ execute_process(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Set Project
|
# Set Project
|
||||||
project(palladium LANGUAGES C CXX VERSION 0.1.9)
|
project(palladium LANGUAGES C CXX VERSION 0.2.1)
|
||||||
|
|
||||||
|
option(PD_BUILD_TESTS "Sets if TestApp and TestBench get build" OFF)
|
||||||
|
|
||||||
# Enable Compile Command Export
|
# Enable Compile Command Export
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
@ -31,67 +57,103 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
|||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-psabi -O2")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-psabi -O2")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions")
|
||||||
|
|
||||||
set(SRC_FILES
|
set(CORE_SRC
|
||||||
# Core (common)
|
source/core/common.cpp
|
||||||
source/common/app.cpp
|
source/core/io.cpp
|
||||||
source/common/common.cpp
|
source/core/strings.cpp
|
||||||
source/common/strings.cpp
|
source/core/sys.cpp
|
||||||
source/common/timetrace.cpp
|
source/core/timetrace.cpp)
|
||||||
source/common/sys.cpp
|
|
||||||
source/common/lang.cpp
|
add_pd_lib(pd-core SRC_FILES ${CORE_SRC})
|
||||||
source/common/error.cpp
|
|
||||||
source/common/io.cpp
|
set(MATHS_SRC
|
||||||
# Controls
|
source/maths/bit_util.cpp
|
||||||
source/controls/hid.cpp
|
source/maths/color.cpp
|
||||||
# Maths
|
source/maths/img_blur.cpp
|
||||||
source/maths/color.cpp
|
source/maths/img_convert.cpp)
|
||||||
source/maths/bit_util.cpp
|
add_pd_lib(pd-maths SRC_FILES ${MATHS_SRC} DEPENDS pd-core)
|
||||||
source/maths/img_convert.cpp
|
|
||||||
source/maths/img_blur.cpp
|
set(EXTERNAL_SRC
|
||||||
# Graphics
|
source/external/stb.cpp)
|
||||||
source/graphics/texture.cpp
|
add_pd_lib(pd-external SRC_FILES ${EXTERNAL_SRC})
|
||||||
source/graphics/spritesheet.cpp
|
|
||||||
source/graphics/li7_shader.cpp
|
set(DRVS_SRC
|
||||||
source/graphics/lithium.cpp
|
source/drivers/hid.cpp)
|
||||||
# Overlays
|
|
||||||
source/overlays/message_mgr.cpp
|
add_pd_lib(pd-drivers SRC_FILES ${DRVS_SRC} DEPENDS pd-maths)
|
||||||
source/overlays/overlay_mgr.cpp
|
|
||||||
source/overlays/keyboard.cpp
|
set(L3DS_SRC
|
||||||
source/overlays/performance.cpp
|
source/lib3ds/gamepad_icons.cpp
|
||||||
source/overlays/settings.cpp
|
source/lib3ds/result_decoder.cpp
|
||||||
# Tools
|
source/lib3ds/drv_hid.cpp)
|
||||||
source/tools/gamepad_icons.cpp
|
|
||||||
# UI7
|
add_pd_lib(pd-lib3ds SRC_FILES ${L3DS_SRC} DEPENDS pd-drivers)
|
||||||
source/ui7/drawlist.cpp
|
|
||||||
source/ui7/menu.cpp
|
set(LI_SRC
|
||||||
source/ui7/theme.cpp
|
source/lithium/li7_shader.cpp
|
||||||
source/ui7/ui7.cpp
|
source/lithium/spritesheet.cpp
|
||||||
source/ui7/container/container.cpp
|
source/lithium/texture.cpp
|
||||||
source/ui7/container/button.cpp
|
source/lithium/font.cpp
|
||||||
source/ui7/container/checkbox.cpp
|
source/lithium/objects.cpp
|
||||||
source/ui7/container/image.cpp
|
source/lithium/renderer.cpp)
|
||||||
source/ui7/container/label.cpp
|
|
||||||
# External
|
add_pd_lib(pd-lithium SRC_FILES ${LI_SRC} DEPENDS pd-maths pd-external citro3d)
|
||||||
source/external/stb.cpp
|
|
||||||
|
set(OVL_SRC
|
||||||
|
source/overlays/keyboard.cpp
|
||||||
|
source/overlays/message_mgr.cpp
|
||||||
|
source/overlays/overlay_mgr.cpp
|
||||||
|
source/overlays/performance.cpp
|
||||||
|
source/overlays/settings.cpp)
|
||||||
|
|
||||||
|
add_pd_lib(pd-overlays SRC_FILES ${OVL_SRC} DEPENDS pd-lithium)
|
||||||
|
|
||||||
|
set(APP_SRC
|
||||||
|
source/app/app.cpp
|
||||||
|
source/app/lang.cpp
|
||||||
|
source/app/error.cpp)
|
||||||
|
|
||||||
|
add_pd_lib(pd-app SRC_FILES ${APP_SRC} DEPENDS pd-overlays pd-drivers pd-lib3ds)
|
||||||
|
|
||||||
|
set(UI7_SRC
|
||||||
|
source/ui7/drawlist.cpp
|
||||||
|
source/ui7/menu.cpp
|
||||||
|
source/ui7/theme.cpp
|
||||||
|
source/ui7/ui7.cpp
|
||||||
|
source/ui7/container/container.cpp
|
||||||
|
source/ui7/container/button.cpp
|
||||||
|
source/ui7/container/checkbox.cpp
|
||||||
|
source/ui7/container/image.cpp
|
||||||
|
source/ui7/container/label.cpp)
|
||||||
|
|
||||||
|
add_pd_lib(pd-ui7 SRC_FILES ${UI7_SRC} DEPENDS pd-drivers pd-lithium)
|
||||||
|
|
||||||
|
add_library(palladium INTERFACE)
|
||||||
|
target_link_libraries(palladium INTERFACE
|
||||||
|
pd-core
|
||||||
|
pd-maths
|
||||||
|
pd-external
|
||||||
|
pd-drivers
|
||||||
|
pd-lib3ds
|
||||||
|
pd-lithium
|
||||||
|
pd-overlays
|
||||||
|
pd-app
|
||||||
|
pd-ui7
|
||||||
)
|
)
|
||||||
|
|
||||||
set(TARGET_NAME palladium)
|
add_dependencies(palladium
|
||||||
|
pd-core
|
||||||
# Set Executable and its sources
|
pd-maths
|
||||||
add_library(${TARGET_NAME} STATIC ${SRC_FILES})
|
pd-external
|
||||||
|
pd-drivers
|
||||||
# Set dependencies, include dirs and definitions
|
pd-lib3ds
|
||||||
target_include_directories(${TARGET_NAME} PUBLIC
|
pd-lithium
|
||||||
include
|
pd-overlays
|
||||||
${DEVKITPRO}/portlibs/3ds/include
|
pd-app
|
||||||
)
|
pd-ui7
|
||||||
target_compile_definitions(${TARGET_NAME} PUBLIC
|
|
||||||
-D_GNU_SOURCE=1
|
|
||||||
-DPALLADIUM_VERSION="${PROJECT_VERSION}"
|
|
||||||
-DPALLADIUM_GIT_COMMIT="${GIT_SHORT_HASH}"
|
|
||||||
-DBUILD_CTR=1
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(PD_BUILD_TESTS)
|
||||||
add_executable(test test/app/main.cpp)
|
add_executable(test test/app/main.cpp)
|
||||||
target_include_directories(test PUBLIC include test/app)
|
target_include_directories(test PUBLIC include test/app)
|
||||||
target_link_directories(test PUBLIC ${CMAKE_BINARY_DIR})
|
target_link_directories(test PUBLIC ${CMAKE_BINARY_DIR})
|
||||||
@ -121,5 +183,6 @@ ctr_create_3dsx(
|
|||||||
SMDH "${CMAKE_BINARY_DIR}/test.smdh"
|
SMDH "${CMAKE_BINARY_DIR}/test.smdh"
|
||||||
ROMFS "${CMAKE_SOURCE_DIR}/test/romfs"
|
ROMFS "${CMAKE_SOURCE_DIR}/test/romfs"
|
||||||
)
|
)
|
||||||
install(TARGETS ${TARGET_NAME})
|
endif()
|
||||||
|
|
||||||
install(DIRECTORY include DESTINATION ".")
|
install(DIRECTORY include DESTINATION ".")
|
@ -24,22 +24,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Common
|
// Core
|
||||||
#include <pd/common/app.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/common/lang.hpp>
|
#include <pd/core/io.hpp>
|
||||||
#include <pd/common/strings.hpp>
|
#include <pd/core/strings.hpp>
|
||||||
#include <pd/common/sys.hpp>
|
#include <pd/core/sys.hpp>
|
||||||
#include <pd/common/timetrace.hpp>
|
#include <pd/core/timetrace.hpp>
|
||||||
// Graphics
|
// Graphics
|
||||||
#include <pd/graphics/lithium.hpp>
|
#include <pd/lithium/renderer.hpp>
|
||||||
#include <pd/graphics/spritesheet.hpp>
|
#include <pd/lithium/spritesheet.hpp>
|
||||||
#include <pd/graphics/texture.hpp>
|
|
||||||
// Maths
|
// Maths
|
||||||
#include <pd/maths/bit_util.hpp>
|
#include <pd/maths/bit_util.hpp>
|
||||||
#include <pd/maths/color.hpp>
|
#include <pd/maths/color.hpp>
|
||||||
#include <pd/maths/img_blur.hpp>
|
#include <pd/maths/img_blur.hpp>
|
||||||
#include <pd/maths/img_convert.hpp>
|
#include <pd/maths/img_convert.hpp>
|
||||||
#include <pd/maths/vec.hpp>
|
#include <pd/maths/vec.hpp>
|
||||||
|
// Drivers
|
||||||
|
#include <pd/drivers/hid.hpp>
|
||||||
// Overlays
|
// Overlays
|
||||||
#include <pd/overlays/keyboard.hpp>
|
#include <pd/overlays/keyboard.hpp>
|
||||||
#include <pd/overlays/message_mgr.hpp>
|
#include <pd/overlays/message_mgr.hpp>
|
||||||
@ -49,6 +50,12 @@ SOFTWARE.
|
|||||||
// UI7
|
// UI7
|
||||||
#include <pd/ui7/ui7.hpp>
|
#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
|
/// Setup these as non Namespaced access by default
|
||||||
#ifndef PD_MATH_NAMESPACED
|
#ifndef PD_MATH_NAMESPACED
|
||||||
using vec2 = PD::vec2;
|
using vec2 = PD::vec2;
|
||||||
|
@ -23,10 +23,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/common/timetrace.hpp>
|
#include <pd/core/timetrace.hpp>
|
||||||
#include <pd/controls/hid.hpp>
|
#include <pd/lib3ds/drv_hid.hpp>
|
||||||
#include <pd/graphics/lithium.hpp>
|
#include <pd/lithium/renderer.hpp>
|
||||||
#include <pd/overlays/message_mgr.hpp>
|
#include <pd/overlays/message_mgr.hpp>
|
||||||
#include <pd/overlays/overlay_mgr.hpp>
|
#include <pd/overlays/overlay_mgr.hpp>
|
||||||
|
|
||||||
@ -52,16 +52,20 @@ class App {
|
|||||||
AppInitFlags_New3dsMode = 1 << 2,
|
AppInitFlags_New3dsMode = 1 << 2,
|
||||||
AppInitFlags_InitGraphicsNoC3D = 1 << 3,
|
AppInitFlags_InitGraphicsNoC3D = 1 << 3,
|
||||||
AppInitFlags_InitLithium = 1 << 4,
|
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_Default = AppInitFlags_MountRomfs | AppInitFlags_InitGraphics |
|
||||||
AppInitFlags_New3dsMode | AppInitFlags_InitLithium,
|
AppInitFlags_New3dsMode | AppInitFlags_InitLithium,
|
||||||
};
|
};
|
||||||
App() {
|
App(const std::string& name = "App") {
|
||||||
if (too) {
|
if (too) {
|
||||||
Error("Only one App can be created at the same time!");
|
Error("Only one App can be created at the same time!");
|
||||||
}
|
}
|
||||||
|
this->name = name;
|
||||||
too++;
|
too++;
|
||||||
}
|
}
|
||||||
~App() = default;
|
~App() { too--; }
|
||||||
|
|
||||||
/// @brief Templete function where the user can Init his stuff
|
/// @brief Templete function where the user can Init his stuff
|
||||||
virtual void Init() {}
|
virtual void Init() {}
|
||||||
@ -110,6 +114,8 @@ class App {
|
|||||||
float app_time;
|
float app_time;
|
||||||
float fps;
|
float fps;
|
||||||
|
|
||||||
|
std::string name;
|
||||||
|
|
||||||
/// The Only One
|
/// The Only One
|
||||||
static int too;
|
static int too;
|
||||||
};
|
};
|
@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
void Error(const std::string& error);
|
void Error(const std::string& error);
|
@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
/// @brief Lang System
|
/// @brief Lang System
|
@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/common/sys.hpp>
|
#include <pd/core/sys.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
class Timer {
|
class Timer {
|
@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace IO {
|
namespace IO {
|
@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
class Markdown {
|
class Markdown {
|
@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace Strings {
|
namespace Strings {
|
@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/common/timetrace.hpp>
|
#include <pd/core/timetrace.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace Sys {
|
namespace Sys {
|
@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
class TimeStats : public SmartCtor<TimeStats> {
|
class TimeStats : public SmartCtor<TimeStats> {
|
@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/maths/vec.hpp>
|
#include <pd/maths/vec.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
@ -64,7 +64,7 @@ class Hid : public SmartCtor<Hid> {
|
|||||||
Event_Held,
|
Event_Held,
|
||||||
Event_Up,
|
Event_Up,
|
||||||
};
|
};
|
||||||
Hid();
|
Hid() {}
|
||||||
~Hid() {}
|
~Hid() {}
|
||||||
|
|
||||||
vec2 TouchPos() const { return touch[0]; }
|
vec2 TouchPos() const { return touch[0]; }
|
||||||
@ -105,14 +105,14 @@ class Hid : public SmartCtor<Hid> {
|
|||||||
|
|
||||||
/// @brief Get the New Keystates etc
|
/// @brief Get the New Keystates etc
|
||||||
/// @note WOW not using the deltatime
|
/// @note WOW not using the deltatime
|
||||||
void Update();
|
virtual void Update() {}
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
|
std::unordered_map<u32, u32> binds;
|
||||||
void SwappyTable();
|
void SwappyTable();
|
||||||
/// Using 2 Touch positions for current and last frame
|
/// Using 2 Touch positions for current and last frame
|
||||||
vec2 touch[2];
|
vec2 touch[2];
|
||||||
bool locked = false;
|
bool locked = false;
|
||||||
std::unordered_map<Event, u32> key_events[2];
|
std::unordered_map<Event, u32> key_events[2];
|
||||||
std::unordered_map<u32, u32> binds;
|
|
||||||
};
|
};
|
||||||
} // namespace PD
|
} // namespace PD
|
36
include/pd/lib3ds/drv_hid.hpp
Normal file
36
include/pd/lib3ds/drv_hid.hpp
Normal 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
|
@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/controls/hid.hpp>
|
#include <pd/drivers/hid.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace GamePadIcons {
|
namespace GamePadIcons {
|
@ -26,8 +26,8 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/common/error.hpp>
|
#include <pd/app/error.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
template <typename T>
|
template <typename T>
|
@ -25,13 +25,12 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/tools/markdown.hpp>
|
#include <pd/core/markdown.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
class ResultDecoder {
|
class ResultDecoder {
|
||||||
public:
|
public:
|
||||||
ResultDecoder(Result res);
|
ResultDecoder(Result res);
|
||||||
|
|
||||||
};
|
};
|
||||||
} // namespace PD
|
} // namespace PD
|
105
include/pd/lithium/command.hpp
Normal file
105
include/pd/lithium/command.hpp
Normal 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
|
60
include/pd/lithium/flags.hpp
Normal file
60
include/pd/lithium/flags.hpp
Normal 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
|
95
include/pd/lithium/font.hpp
Normal file
95
include/pd/lithium/font.hpp
Normal 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
|
166
include/pd/lithium/objects.hpp
Normal file
166
include/pd/lithium/objects.hpp
Normal 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
|
@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/maths/vec.hpp>
|
#include <pd/maths/vec.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
@ -24,332 +24,24 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/common/memory.hpp>
|
#include <pd/lib3ds/memory.hpp>
|
||||||
#include <pd/graphics/rect.hpp>
|
#include <pd/lithium/command.hpp>
|
||||||
#include <pd/graphics/screen.hpp>
|
#include <pd/lithium/flags.hpp>
|
||||||
#include <pd/graphics/texture.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/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 PD {
|
||||||
namespace LI {
|
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> {
|
class Renderer : public SmartCtor<Renderer> {
|
||||||
public:
|
public:
|
||||||
Renderer(RenderFlags flags = RenderFlags_Default);
|
Renderer(LIRenderFlags flags = LIRenderFlags_Default);
|
||||||
~Renderer();
|
~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 PrepareRender();
|
||||||
void Render(Screen::Ref s);
|
void Render(Screen::Ref s);
|
||||||
void FinalizeRender();
|
void FinalizeRender();
|
||||||
@ -377,7 +69,7 @@ class Renderer : public SmartCtor<Renderer> {
|
|||||||
float TextScale() const { return text_size; }
|
float TextScale() const { return text_size; }
|
||||||
void Layer(int v) { current_layer = v; }
|
void Layer(int v) { current_layer = v; }
|
||||||
int Layer() const { return current_layer; }
|
int Layer() const { return current_layer; }
|
||||||
RenderFlags& GetFlags() { return flags; }
|
LIRenderFlags& GetFlags() { return flags; }
|
||||||
void Font(Font::Ref v) {
|
void Font(Font::Ref v) {
|
||||||
font = v;
|
font = v;
|
||||||
font_update = true;
|
font_update = true;
|
||||||
@ -494,7 +186,7 @@ class Renderer : public SmartCtor<Renderer> {
|
|||||||
Screen::Ref screens[2];
|
Screen::Ref screens[2];
|
||||||
|
|
||||||
/// Context Related ///
|
/// Context Related ///
|
||||||
RenderFlags flags = RenderFlags_Default;
|
LIRenderFlags flags = LIRenderFlags_Default;
|
||||||
vec2 area_size;
|
vec2 area_size;
|
||||||
int current_layer = 0;
|
int current_layer = 0;
|
||||||
Texture::Ref current_tex = nullptr;
|
Texture::Ref current_tex = nullptr;
|
@ -26,7 +26,7 @@ SOFTWARE.
|
|||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
#include <citro3d.h>
|
#include <citro3d.h>
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/maths/vec.hpp>
|
#include <pd/maths/vec.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
@ -26,9 +26,8 @@ SOFTWARE.
|
|||||||
#include <citro3d.h>
|
#include <citro3d.h>
|
||||||
#include <tex3ds.h>
|
#include <tex3ds.h>
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/graphics/lithium.hpp>
|
#include <pd/lithium/texture.hpp>
|
||||||
#include <pd/graphics/texture.hpp>
|
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
class SpriteSheet : public SmartCtor<SpriteSheet> {
|
class SpriteSheet : public SmartCtor<SpriteSheet> {
|
@ -26,8 +26,8 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include <citro3d.h>
|
#include <citro3d.h>
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/graphics/rect.hpp>
|
#include <pd/lithium/rect.hpp>
|
||||||
#include <pd/maths/vec.hpp>
|
#include <pd/maths/vec.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
62
include/pd/lithium/vertex.hpp
Normal file
62
include/pd/lithium/vertex.hpp
Normal 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
|
@ -24,7 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace BitUtil {
|
namespace BitUtil {
|
||||||
|
@ -24,7 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
/// @brief Color class (Supports hex, rgb(a)8, u32 input)
|
/// @brief Color class (Supports hex, rgb(a)8, u32 input)
|
||||||
|
@ -24,7 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/maths/vec.hpp>
|
#include <pd/maths/vec.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
|
@ -24,7 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/maths/img.hpp>
|
#include <pd/maths/img.hpp>
|
||||||
#include <pd/maths/vec.hpp>
|
#include <pd/maths/vec.hpp>
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace ImgConvert {
|
namespace ImgConvert {
|
||||||
|
@ -29,7 +29,7 @@ SOFTWARE.
|
|||||||
* and easy to use like in glsl or glm
|
* and easy to use like in glsl or glm
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
struct vec2 {
|
struct vec2 {
|
||||||
|
@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/controls/hid.hpp>
|
#include <pd/drivers/hid.hpp>
|
||||||
#include <pd/maths/tween.hpp>
|
#include <pd/maths/tween.hpp>
|
||||||
#include <pd/overlays/overlay.hpp>
|
#include <pd/overlays/overlay.hpp>
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/graphics/lithium.hpp>
|
#include <pd/lithium/renderer.hpp>
|
||||||
#include <pd/maths/color.hpp>
|
#include <pd/maths/color.hpp>
|
||||||
#include <pd/maths/tween.hpp>
|
#include <pd/maths/tween.hpp>
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/controls/hid.hpp>
|
#include <pd/drivers/hid.hpp>
|
||||||
#include <pd/graphics/lithium.hpp>
|
#include <pd/lithium/renderer.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
class Overlay : public SmartCtor<Overlay> {
|
class Overlay : public SmartCtor<Overlay> {
|
||||||
|
@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/controls/hid.hpp>
|
#include <pd/drivers/hid.hpp>
|
||||||
#include <pd/graphics/lithium.hpp>
|
#include <pd/lithium/renderer.hpp>
|
||||||
#include <pd/overlays/overlay.hpp>
|
#include <pd/overlays/overlay.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
|
@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <pd/drivers/hid.hpp>
|
||||||
#include <pd/overlays/overlay.hpp>
|
#include <pd/overlays/overlay.hpp>
|
||||||
#include <pd/controls/hid.hpp>
|
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
class Performance : public Overlay {
|
class Performance : public Overlay {
|
||||||
|
@ -23,8 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/app.hpp>
|
#include <pd/drivers/hid.hpp>
|
||||||
#include <pd/controls/hid.hpp>
|
|
||||||
#include <pd/maths/tween.hpp>
|
#include <pd/maths/tween.hpp>
|
||||||
#include <pd/overlays/overlay.hpp>
|
#include <pd/overlays/overlay.hpp>
|
||||||
#include <pd/ui7/ui7.hpp>
|
#include <pd/ui7/ui7.hpp>
|
||||||
@ -32,14 +31,12 @@ SOFTWARE.
|
|||||||
namespace PD {
|
namespace PD {
|
||||||
class SettingsMenu : public Overlay {
|
class SettingsMenu : public Overlay {
|
||||||
public:
|
public:
|
||||||
SettingsMenu(PD::App* app) {
|
SettingsMenu() {
|
||||||
too++;
|
too++;
|
||||||
if (too > 1) {
|
if (too > 1) {
|
||||||
Kill();
|
Kill();
|
||||||
return;
|
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);
|
flymgr.From(vec2(0, 240)).To(vec2(0, 115)).In(0.3f).As(flymgr.EaseInQuad);
|
||||||
}
|
}
|
||||||
~SettingsMenu() { too--; }
|
~SettingsMenu() { too--; }
|
||||||
@ -48,12 +45,10 @@ class SettingsMenu : public Overlay {
|
|||||||
|
|
||||||
void Rem() {
|
void Rem() {
|
||||||
rem = true;
|
rem = true;
|
||||||
app_ref->FeatureEnable(App::AppFLags_UserLoop);
|
|
||||||
flymgr.From(vec2(0, 115)).To(vec2(0, 240)).In(0.2f).As(flymgr.EaseOutQuad);
|
flymgr.From(vec2(0, 115)).To(vec2(0, 240)).In(0.2f).As(flymgr.EaseOutQuad);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PD::App* app_ref = nullptr;
|
|
||||||
/// Section is used to determinate what
|
/// Section is used to determinate what
|
||||||
/// should be displayed on the top screen
|
/// should be displayed on the top screen
|
||||||
int section = 0;
|
int section = 0;
|
||||||
|
@ -23,9 +23,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/common/strings.hpp>
|
#include <pd/core/strings.hpp>
|
||||||
#include <pd/controls/hid.hpp>
|
#include <pd/drivers/hid.hpp>
|
||||||
#include <pd/maths/vec.hpp>
|
#include <pd/maths/vec.hpp>
|
||||||
#include <pd/ui7/drawlist.hpp>
|
#include <pd/ui7/drawlist.hpp>
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/graphics/lithium.hpp>
|
#include <pd/lithium/renderer.hpp>
|
||||||
#include <pd/ui7/theme.hpp>
|
#include <pd/ui7/theme.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
@ -61,7 +61,7 @@ class DrawList : public SmartCtor<DrawList> {
|
|||||||
int layer;
|
int layer;
|
||||||
int base;
|
int base;
|
||||||
LI::Renderer::Ref ren;
|
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;
|
std::vector<std::pair<bool, LI::Command::Ref>> commands;
|
||||||
};
|
};
|
||||||
} // namespace UI7
|
} // namespace UI7
|
||||||
|
@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/common/strings.hpp>
|
#include <pd/core/strings.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace UI7 {
|
namespace UI7 {
|
||||||
|
@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/controls/hid.hpp>
|
#include <pd/drivers/hid.hpp>
|
||||||
#include <pd/maths/tween.hpp>
|
#include <pd/maths/tween.hpp>
|
||||||
#include <pd/ui7/containers.hpp>
|
#include <pd/ui7/containers.hpp>
|
||||||
#include <pd/ui7/drawlist.hpp>
|
#include <pd/ui7/drawlist.hpp>
|
||||||
|
@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
|
|
||||||
using UI7Color = PD::u32;
|
using UI7Color = PD::u32;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
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/drawlist.hpp>
|
||||||
#include <pd/ui7/flags.hpp>
|
#include <pd/ui7/flags.hpp>
|
||||||
#include <pd/ui7/id.hpp>
|
#include <pd/ui7/id.hpp>
|
||||||
|
@ -24,8 +24,8 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
|
||||||
#include <pd/common/app.hpp>
|
#include <pd/app/app.hpp>
|
||||||
#include <pd/common/sys.hpp>
|
#include <pd/core/sys.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
int App::too;
|
int App::too;
|
||||||
@ -87,7 +87,10 @@ void App::PreInit() {
|
|||||||
if (InitFlags & AppInitFlags_MountRomfs) {
|
if (InitFlags & AppInitFlags_MountRomfs) {
|
||||||
romfsInit();
|
romfsInit();
|
||||||
}
|
}
|
||||||
input_mgr = Hid::New();
|
if (InitFlags & AppInitFlags_UnnamedOption1) {
|
||||||
|
std::filesystem::create_directories("sdmc:/palladium/apps/" + name);
|
||||||
|
}
|
||||||
|
input_mgr = PD::New<CtrHid>();
|
||||||
if (InitFlags & AppInitFlags_InitLithium) {
|
if (InitFlags & AppInitFlags_InitLithium) {
|
||||||
Assert(!(InitFlags & AppInitFlags_InitGraphicsNoC3D),
|
Assert(!(InitFlags & AppInitFlags_InitGraphicsNoC3D),
|
||||||
"InitGraphicsNoC3D is not compatible with InitLithium!");
|
"InitGraphicsNoC3D is not compatible with InitLithium!");
|
@ -23,7 +23,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
|
||||||
#include <pd/common/error.hpp>
|
#include <pd/app/error.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
void Error(const std::string& msg) {
|
void Error(const std::string& msg) {
|
@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/lang.hpp>
|
#include <pd/app/lang.hpp>
|
||||||
#include <pd/external/json.hpp>
|
#include <pd/external/json.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
@ -22,8 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/common.hpp>
|
#include <pd/core/common.hpp>
|
||||||
#include <pd/common/strings.hpp>
|
#include <pd/core/strings.hpp>
|
||||||
|
|
||||||
#ifndef PALLADIUM_VERSION
|
#ifndef PALLADIUM_VERSION
|
||||||
#define PALLADIUM_VERSION "unknown"
|
#define PALLADIUM_VERSION "unknown"
|
@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/io.hpp>
|
#include <pd/core/io.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace IO {
|
namespace IO {
|
@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/strings.hpp>
|
#include <pd/core/strings.hpp>
|
||||||
|
|
||||||
namespace PD::Strings {
|
namespace PD::Strings {
|
||||||
bool StringEndsWith(const std::string& str,
|
bool StringEndsWith(const std::string& str,
|
@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/sys.hpp>
|
#include <pd/core/sys.hpp>
|
||||||
|
|
||||||
namespace PD::Sys {
|
namespace PD::Sys {
|
||||||
TraceMap pd_sys_tm;
|
TraceMap pd_sys_tm;
|
@ -21,8 +21,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/sys.hpp>
|
#include <pd/core/sys.hpp>
|
||||||
#include <pd/common/timetrace.hpp>
|
#include <pd/core/timetrace.hpp>
|
||||||
|
|
||||||
namespace PD::TT {
|
namespace PD::TT {
|
||||||
void Beg(const std::string& id) {
|
void Beg(const std::string& id) {
|
44
source/drivers/hid.cpp
Normal file
44
source/drivers/hid.cpp
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
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>
|
||||||
|
|
||||||
|
/// Reform of the RenderD7 095 Hid Api
|
||||||
|
/// Using Custom Keybindings for future
|
||||||
|
/// Porting of the library
|
||||||
|
|
||||||
|
namespace PD {
|
||||||
|
bool Hid::IsEvent(Event e, Key keys) { return key_events[0][e] & keys; }
|
||||||
|
|
||||||
|
void Hid::SwappyTable() {
|
||||||
|
auto tkd = key_events[1][Event_Down];
|
||||||
|
auto tkh = key_events[1][Event_Held];
|
||||||
|
auto tku = key_events[1][Event_Up];
|
||||||
|
key_events[1][Event_Down] = key_events[0][Event_Down];
|
||||||
|
key_events[1][Event_Held] = key_events[0][Event_Held];
|
||||||
|
key_events[1][Event_Up] = key_events[0][Event_Up];
|
||||||
|
key_events[0][Event_Down] = tkd;
|
||||||
|
key_events[0][Event_Held] = tkh;
|
||||||
|
key_events[0][Event_Up] = tku;
|
||||||
|
}
|
||||||
|
} // namespace PD
|
@ -23,14 +23,14 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
|
||||||
#include <pd/controls/hid.hpp>
|
#include <pd/lib3ds/drv_hid.hpp>
|
||||||
|
|
||||||
/// Reform of the RenderD7 095 Hid Api
|
/// Reform of the RenderD7 095 Hid Api
|
||||||
/// Using Custom Keybindings for future
|
/// Using Custom Keybindings for future
|
||||||
/// Porting of the library
|
/// Porting of the library
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
Hid::Hid() {
|
CtrHid::CtrHid() {
|
||||||
binds[KEY_A] = A;
|
binds[KEY_A] = A;
|
||||||
binds[KEY_B] = B;
|
binds[KEY_B] = B;
|
||||||
binds[KEY_X] = X;
|
binds[KEY_X] = X;
|
||||||
@ -55,7 +55,7 @@ Hid::Hid() {
|
|||||||
binds[KEY_ZR] = ZR;
|
binds[KEY_ZR] = ZR;
|
||||||
binds[KEY_TOUCH] = Touch;
|
binds[KEY_TOUCH] = Touch;
|
||||||
}
|
}
|
||||||
void Hid::Update() {
|
void CtrHid::Update() {
|
||||||
hidScanInput();
|
hidScanInput();
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
key_events[i][Event_Down] = 0;
|
key_events[i][Event_Down] = 0;
|
||||||
@ -84,18 +84,4 @@ void Hid::Update() {
|
|||||||
touch[1] = touch[0]; // Cycle touch pos
|
touch[1] = touch[0]; // Cycle touch pos
|
||||||
touch[0] = vec2(t.px, t.py);
|
touch[0] = vec2(t.px, t.py);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Hid::IsEvent(Event e, Key keys) { return key_events[0][e] & keys; }
|
|
||||||
|
|
||||||
void Hid::SwappyTable() {
|
|
||||||
auto tkd = key_events[1][Event_Down];
|
|
||||||
auto tkh = key_events[1][Event_Held];
|
|
||||||
auto tku = key_events[1][Event_Up];
|
|
||||||
key_events[1][Event_Down] = key_events[0][Event_Down];
|
|
||||||
key_events[1][Event_Held] = key_events[0][Event_Held];
|
|
||||||
key_events[1][Event_Up] = key_events[0][Event_Up];
|
|
||||||
key_events[0][Event_Down] = tkd;
|
|
||||||
key_events[0][Event_Held] = tkh;
|
|
||||||
key_events[0][Event_Up] = tku;
|
|
||||||
}
|
|
||||||
} // namespace PD
|
} // namespace PD
|
@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/tools/gamepad_icons.hpp>
|
#include <pd/lib3ds/gamepad_icons.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace GamePadIcons {
|
namespace GamePadIcons {
|
@ -22,7 +22,7 @@ SOFTWARE.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef PD_EXTENDED_DEBUG
|
#ifdef PD_EXTENDED_DEBUG
|
||||||
#include <pd/tools/result_decoder.hpp>
|
#include <pd/lib3ds/result_decoder.hpp>
|
||||||
|
|
||||||
static const std::map<int, std::string> modules = {
|
static const std::map<int, std::string> modules = {
|
||||||
{0, "common"},
|
{0, "common"},
|
222
source/lithium/font.cpp
Normal file
222
source/lithium/font.cpp
Normal file
@ -0,0 +1,222 @@
|
|||||||
|
/*
|
||||||
|
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 <3ds.h>
|
||||||
|
#include <pd/external/stb_truetype.h>
|
||||||
|
|
||||||
|
#include <pd/core/io.hpp>
|
||||||
|
#include <pd/core/strings.hpp>
|
||||||
|
#include <pd/core/sys.hpp>
|
||||||
|
#include <pd/lithium/font.hpp>
|
||||||
|
|
||||||
|
namespace PD {
|
||||||
|
namespace LI {
|
||||||
|
void Font::LoadTTF(const std::string& path, int height) {
|
||||||
|
sysfont = false;
|
||||||
|
TT::Scope st("LI_LoadTTF_" + path);
|
||||||
|
pixel_height = height;
|
||||||
|
int quad = height * 16;
|
||||||
|
stbtt_fontinfo inf;
|
||||||
|
std::ifstream loader(path, std::ios::binary);
|
||||||
|
if (!loader.is_open()) return;
|
||||||
|
loader.seekg(0, std::ios::end);
|
||||||
|
size_t len = loader.tellg();
|
||||||
|
loader.seekg(0, std::ios::beg);
|
||||||
|
unsigned char* buffer = new unsigned char[len];
|
||||||
|
loader.read(reinterpret_cast<char*>(buffer), len);
|
||||||
|
loader.close();
|
||||||
|
stbtt_InitFont(&inf, buffer, 0);
|
||||||
|
std::vector<unsigned char> font_tex(quad * quad);
|
||||||
|
float scale = stbtt_ScaleForPixelHeight(&inf, pixel_height);
|
||||||
|
|
||||||
|
int ascent, descent, lineGap;
|
||||||
|
stbtt_GetFontVMetrics(&inf, &ascent, &descent, &lineGap);
|
||||||
|
int baseline = static_cast<int>(ascent * scale);
|
||||||
|
|
||||||
|
std::map<u32, int> buf_cache;
|
||||||
|
|
||||||
|
auto tex = Texture::New();
|
||||||
|
vec2 off;
|
||||||
|
for (u32 ii = 0x0000; ii < 0xFFFF; ii++) {
|
||||||
|
int i = stbtt_FindGlyphIndex(&inf, ii);
|
||||||
|
if (i == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (stbtt_IsGlyphEmpty(&inf, i)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Codepoint c;
|
||||||
|
int w = 0, h = 0, xo = 0, yo = 0;
|
||||||
|
unsigned char* bitmap =
|
||||||
|
stbtt_GetCodepointBitmap(&inf, scale, scale, i, &w, &h, &xo, &yo);
|
||||||
|
int x0, y0, x1, y1;
|
||||||
|
stbtt_GetCodepointBitmapBox(&inf, i, scale, scale, &x0, &y0, &x1, &y1);
|
||||||
|
|
||||||
|
u32 hashed_map = IO::HashMemory(std::vector<u8>(bitmap, bitmap + (w * h)));
|
||||||
|
if (buf_cache.find(hashed_map) != buf_cache.end()) {
|
||||||
|
c = GetCodepoint(buf_cache[hashed_map]);
|
||||||
|
c.cp(i);
|
||||||
|
cpmap[i] = c;
|
||||||
|
free(bitmap);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
buf_cache[hashed_map] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (off[0] + w > quad) {
|
||||||
|
off[1] += pixel_height;
|
||||||
|
off[0] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 uvs;
|
||||||
|
uvs[0] = static_cast<float>(off.x() / (float)quad);
|
||||||
|
uvs[1] = static_cast<float>(1.f - (off.y() / (float)quad));
|
||||||
|
uvs[2] = static_cast<float>((float)(off.x() + w) / (float)quad);
|
||||||
|
uvs[3] = static_cast<float>(1.f - (float)(off.y() + h) / (float)quad);
|
||||||
|
c.uv(uvs);
|
||||||
|
|
||||||
|
c.tex(tex);
|
||||||
|
c.size(vec2(w, h));
|
||||||
|
c.off(baseline + yo);
|
||||||
|
|
||||||
|
for (int y = 0; y < h; ++y) {
|
||||||
|
for (int x = 0; x < w; ++x) {
|
||||||
|
int map_pos = ((off[1] + y) * quad + (off[0] + x));
|
||||||
|
font_tex[map_pos] = bitmap[x + y * w];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(bitmap);
|
||||||
|
cpmap[i] = c;
|
||||||
|
|
||||||
|
// Small Patch to avoid some possible artifacts
|
||||||
|
off[0] += w + 1;
|
||||||
|
if (off[0] + w > quad) {
|
||||||
|
off[1] += pixel_height;
|
||||||
|
if (off[1] + pixel_height > quad) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
off[0] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tex->LoadPixels(font_tex, quad, quad, Texture::A8, Texture::LINEAR);
|
||||||
|
textures.push_back(tex);
|
||||||
|
}
|
||||||
|
|
||||||
|
Font::Codepoint& Font::GetCodepoint(u32 cp) {
|
||||||
|
auto res = cpmap.find(cp);
|
||||||
|
if (res == cpmap.end()) {
|
||||||
|
static Codepoint invalid;
|
||||||
|
return invalid.invalid(true);
|
||||||
|
}
|
||||||
|
return res->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Font::LoadSystemFont() {
|
||||||
|
TT::Scope st("LI_SystemFont");
|
||||||
|
sysfont = true;
|
||||||
|
fontEnsureMapped();
|
||||||
|
const auto fnt = fontGetSystemFont();
|
||||||
|
const auto fnt_info = fontGetInfo(fnt);
|
||||||
|
const auto glyph_info = fontGetGlyphInfo(fnt);
|
||||||
|
this->textures.resize(glyph_info->nSheets + 1);
|
||||||
|
/// Modify the Pixel Height by 1.1f to fit the
|
||||||
|
/// Size og ttf font Rendering
|
||||||
|
pixel_height = glyph_info->cellHeight * 1.1f;
|
||||||
|
for (size_t i = 0; i < glyph_info->nSheets; i++) {
|
||||||
|
auto stex = Texture::New();
|
||||||
|
auto tx = new C3D_Tex;
|
||||||
|
tx->data = fontGetGlyphSheetTex(fnt, i);
|
||||||
|
tx->fmt = (GPU_TEXCOLOR)glyph_info->sheetFmt;
|
||||||
|
tx->size = glyph_info->sheetSize;
|
||||||
|
tx->width = glyph_info->sheetWidth;
|
||||||
|
tx->height = glyph_info->sheetHeight;
|
||||||
|
tx->param = GPU_TEXTURE_MAG_FILTER(GPU_LINEAR) |
|
||||||
|
GPU_TEXTURE_MIN_FILTER(GPU_LINEAR) |
|
||||||
|
GPU_TEXTURE_WRAP_S(GPU_REPEAT) | GPU_TEXTURE_WRAP_T(GPU_REPEAT);
|
||||||
|
tx->border = 0xffffffff;
|
||||||
|
tx->lodParam = 0;
|
||||||
|
stex->LoadExternal(tx, vec2(tx->width, tx->height), vec4(0, 1, 1, 0));
|
||||||
|
stex->AutoUnLoad(false);
|
||||||
|
textures[i] = stex;
|
||||||
|
}
|
||||||
|
std::vector<unsigned int> charSet;
|
||||||
|
for (auto cmap = fnt_info->cmap; cmap; cmap = cmap->next) {
|
||||||
|
if (cmap->mappingMethod == CMAP_TYPE_DIRECT) {
|
||||||
|
if (cmap->codeEnd >= cmap->codeBegin) {
|
||||||
|
charSet.reserve(charSet.size() + cmap->codeEnd - cmap->codeBegin + 1);
|
||||||
|
for (auto i = cmap->codeBegin; i <= cmap->codeEnd; ++i) {
|
||||||
|
if (cmap->indexOffset + (i - cmap->codeBegin) == 0xFFFF) break;
|
||||||
|
charSet.emplace_back(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (cmap->mappingMethod == CMAP_TYPE_TABLE) {
|
||||||
|
if (cmap->codeEnd >= cmap->codeBegin) {
|
||||||
|
charSet.reserve(charSet.size() + cmap->codeEnd - cmap->codeBegin + 1);
|
||||||
|
for (auto i = cmap->codeBegin; i <= cmap->codeEnd; ++i) {
|
||||||
|
if (cmap->indexTable[i - cmap->codeBegin] == 0xFFFF) continue;
|
||||||
|
charSet.emplace_back(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (cmap->mappingMethod == CMAP_TYPE_SCAN) {
|
||||||
|
charSet.reserve(charSet.size() + cmap->nScanEntries);
|
||||||
|
for (unsigned i = 0; i < cmap->nScanEntries; ++i) {
|
||||||
|
if (cmap->scanEntries[i].code >= cmap->codeBegin &&
|
||||||
|
cmap->scanEntries[i].code <= cmap->codeEnd) {
|
||||||
|
if (cmap->scanEntries[i].glyphIndex != 0xFFFF) {
|
||||||
|
charSet.emplace_back(cmap->scanEntries[i].code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(charSet.begin(), charSet.end());
|
||||||
|
charSet.erase(std::unique(charSet.begin(), charSet.end()));
|
||||||
|
|
||||||
|
for (auto cp : charSet) {
|
||||||
|
int gidx = fontGlyphIndexFromCodePoint(fnt, cp);
|
||||||
|
if (gidx >= 0xFFFF) continue;
|
||||||
|
Codepoint codepoint;
|
||||||
|
fontGlyphPos_s dat;
|
||||||
|
fontCalcGlyphPos(&dat, fnt, gidx, GLYPH_POS_CALC_VTXCOORD, 1.f, 1.f);
|
||||||
|
|
||||||
|
codepoint.cp(cp);
|
||||||
|
codepoint.uv(vec4(dat.texcoord.left, dat.texcoord.top, dat.texcoord.right,
|
||||||
|
dat.texcoord.bottom));
|
||||||
|
|
||||||
|
if (dat.sheetIndex < (int)textures.size()) {
|
||||||
|
codepoint.tex(textures[dat.sheetIndex]);
|
||||||
|
} else {
|
||||||
|
codepoint.invalid(true);
|
||||||
|
}
|
||||||
|
codepoint.size(vec2(dat.vtxcoord.right, dat.vtxcoord.bottom));
|
||||||
|
codepoint.off(0);
|
||||||
|
cpmap[cp] = codepoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace LI
|
||||||
|
} // namespace PD
|
@ -24,7 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/graphics/li7_shader.hpp>
|
#include <pd/lithium/li7_shader.hpp>
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
unsigned char li7_shader[] = {
|
unsigned char li7_shader[] = {
|
60
source/lithium/objects.cpp
Normal file
60
source/lithium/objects.cpp
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
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/external/stb_truetype.h>
|
||||||
|
|
||||||
|
#include <pd/core/io.hpp>
|
||||||
|
#include <pd/core/strings.hpp>
|
||||||
|
#include <pd/core/sys.hpp>
|
||||||
|
#include <pd/lithium/font.hpp>
|
||||||
|
#include <pd/lithium/renderer.hpp>
|
||||||
|
|
||||||
|
namespace PD {
|
||||||
|
namespace LI {
|
||||||
|
void StaticText::Setup(Renderer* ren, const vec2& pos, u32 clr,
|
||||||
|
const std::string& text, LITextFlags flags,
|
||||||
|
const vec2& box) {
|
||||||
|
this->tdim = ren->GetTextDimensions(text);
|
||||||
|
this->pos = pos;
|
||||||
|
this->ren = ren;
|
||||||
|
this->text = StaticObject::New();
|
||||||
|
/// Ensure that it also renders Out of Screen i guess
|
||||||
|
ren->TextCommand(this->text->List(), pos, clr, text,
|
||||||
|
flags | LITextFlags_RenderOOS, box);
|
||||||
|
Renderer::OptiCommandList(this->text->List());
|
||||||
|
}
|
||||||
|
|
||||||
|
void StaticText::Draw() {
|
||||||
|
used = true;
|
||||||
|
for (auto& it : text->List()) {
|
||||||
|
ren->PushCommand(it);
|
||||||
|
}
|
||||||
|
text->ReCopy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StaticText::SetColor(u32 col) { text->ReColor(col); }
|
||||||
|
void StaticText::SetPos(const vec2& pos) { text->MoveIt(pos - this->pos); }
|
||||||
|
|
||||||
|
void StaticText::SetLayer(int layer) { text->ReLayer(layer); }
|
||||||
|
} // namespace LI
|
||||||
|
} // namespace PD
|
596
source/lithium/renderer.cpp
Normal file
596
source/lithium/renderer.cpp
Normal file
@ -0,0 +1,596 @@
|
|||||||
|
/*
|
||||||
|
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 <3ds.h>
|
||||||
|
#include <pd/external/stb_truetype.h>
|
||||||
|
|
||||||
|
#include <pd/core/io.hpp>
|
||||||
|
#include <pd/core/strings.hpp>
|
||||||
|
#include <pd/core/sys.hpp>
|
||||||
|
#include <pd/lithium/font.hpp>
|
||||||
|
#include <pd/lithium/li7_shader.hpp>
|
||||||
|
#include <pd/lithium/renderer.hpp>
|
||||||
|
|
||||||
|
namespace PD {
|
||||||
|
namespace LI {
|
||||||
|
Renderer::Renderer(LIRenderFlags flags) {
|
||||||
|
vertex_buf.resize(4 * 4096, Vertex());
|
||||||
|
index_buf.resize(6 * 4096, 0);
|
||||||
|
|
||||||
|
/// Use 3ds u32 here
|
||||||
|
dvlb = DVLB_ParseFile((uint32_t*)li7_shader, li7_shader_size);
|
||||||
|
shaderProgramInit(&shader);
|
||||||
|
shaderProgramSetVsh(&shader, &dvlb->DVLE[0]);
|
||||||
|
uLoc_projection =
|
||||||
|
shaderInstanceGetUniformLocation(shader.vertexShader, "projection");
|
||||||
|
|
||||||
|
AttrInfo_Init(&attr);
|
||||||
|
AttrInfo_AddLoader(&attr, 0, GPU_FLOAT, 2);
|
||||||
|
AttrInfo_AddLoader(&attr, 1, GPU_FLOAT, 2);
|
||||||
|
AttrInfo_AddLoader(&attr, 2, GPU_UNSIGNED_BYTE, 4);
|
||||||
|
|
||||||
|
// Precalculate Projection (Never changes)
|
||||||
|
Mtx_OrthoTilt(&top_proj, 0.f, 400.f, 240.f, 0.f, 1.f, -1.f, false);
|
||||||
|
Mtx_OrthoTilt(&bot_proj, 0.f, 320.f, 240.f, 0.f, 1.f, -1.f, false);
|
||||||
|
|
||||||
|
std::vector<u8> pixels(16 * 16 * 4, 255);
|
||||||
|
white = Texture::New(pixels, 16, 16);
|
||||||
|
UseTex(white);
|
||||||
|
|
||||||
|
// Not Loading as Systemfont is freezing
|
||||||
|
// font = Font::New();
|
||||||
|
// font->LoadSystemFont();
|
||||||
|
}
|
||||||
|
Renderer::~Renderer() {
|
||||||
|
shaderProgramFree(&shader);
|
||||||
|
DVLB_Free(dvlb);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Renderer::InBox(const vec2& pos, const vec2& szs, const vec4& rect) {
|
||||||
|
return (pos[0] + szs[0] >= rect[0] && pos[1] + szs[1] >= rect[1] &&
|
||||||
|
pos[0] <= rect[2] && pos[1] <= rect[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Renderer::InBox(const vec2& pos, const vec4& rect) {
|
||||||
|
return (pos.x() > rect.x() && pos.x() < rect.x() + rect.z() &&
|
||||||
|
pos.y() > rect.y() && pos.y() < rect.y() + rect.w());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Renderer::InBox(const vec2& alpha, const vec2& bravo, const vec2& charlie,
|
||||||
|
const vec4& rect) {
|
||||||
|
return ((alpha[0] < rect[2] && bravo[0] < rect[2] && charlie[0] < rect[2]) ||
|
||||||
|
(alpha[1] < rect[3] && bravo[1] < rect[3] && charlie[1] < rect[3]) ||
|
||||||
|
(alpha[0] > 0 && bravo[0] > 0 && charlie[0] > 0) ||
|
||||||
|
(alpha[1] > 0 && bravo[1] > 0 && charlie[1] > 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::RotateCorner(vec2& v, float s, float c) {
|
||||||
|
float x = v[0] * c - v[1] * s;
|
||||||
|
float y = v[1] * c + v[0] * s;
|
||||||
|
v = vec2(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
Rect Renderer::CreateRect(const vec2& pos, const vec2& size, float angle) {
|
||||||
|
vec2 c = size * 0.5f; // Center
|
||||||
|
vec2 corner[4] = {
|
||||||
|
vec2(-c[0], -c[1]),
|
||||||
|
vec2(-c[0] + size[0], -c[1]),
|
||||||
|
vec2(-c[0], -c[1] + size[1]),
|
||||||
|
vec2(-c[0] + size[0], -c[1] + size[1]),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Only rotate if required
|
||||||
|
if (angle != 0.f) {
|
||||||
|
float s = std::sin(angle);
|
||||||
|
float co = std::cos(angle);
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
RotateCorner(corner[i], s, co);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return Result
|
||||||
|
return Rect(corner[0] + pos + c, corner[1] + pos + c, corner[2] + pos + c,
|
||||||
|
corner[3] + pos + c);
|
||||||
|
}
|
||||||
|
|
||||||
|
Rect Renderer::CreateLine(const vec2& a, const vec2& b, int t) {
|
||||||
|
// Usin g th evec maths api makes the code as short as it is
|
||||||
|
vec2 dir = a - b;
|
||||||
|
float len = dir.len();
|
||||||
|
vec2 unit_dir = dir / len;
|
||||||
|
vec2 perpendicular(-unit_dir.y(), unit_dir.x());
|
||||||
|
vec2 off = perpendicular * ((float)t * 0.5f);
|
||||||
|
|
||||||
|
return Rect(a + off, b + off, a - off, b - off);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::OptiCommandList(std::vector<Command::Ref>& list) {
|
||||||
|
std::sort(list.begin(), list.end(), [](Command::Ref a, Command::Ref b) {
|
||||||
|
if (a->Layer() == b->Layer()) {
|
||||||
|
if (a->Tex() == b->Tex()) {
|
||||||
|
return a->Index() < b->Index();
|
||||||
|
}
|
||||||
|
return a->Tex() < b->Tex(); // else
|
||||||
|
}
|
||||||
|
return a->Layer() < b->Layer(); // else
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::SetupCommand(Command::Ref cmd) {
|
||||||
|
cmd->Index(cmd_idx++).Layer(current_layer).Tex(current_tex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::QuadCommand(Command::Ref cmd, const Rect& quad, const Rect& uv,
|
||||||
|
u32 col) {
|
||||||
|
cmd->PushIndex(0).PushIndex(1).PushIndex(2);
|
||||||
|
cmd->PushIndex(0).PushIndex(2).PushIndex(3);
|
||||||
|
cmd->PushVertex(Vertex(quad.BotRight(), uv.BotRight(), col));
|
||||||
|
cmd->PushVertex(Vertex(quad.TopRight(), uv.TopRight(), col));
|
||||||
|
cmd->PushVertex(Vertex(quad.TopLeft(), uv.TopLeft(), col));
|
||||||
|
cmd->PushVertex(Vertex(quad.BotLeft(), uv.BotLeft(), col));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::TriangleCommand(Command::Ref cmd, const vec2& a, const vec2& b,
|
||||||
|
const vec2& c, u32 col) {
|
||||||
|
cmd->Index(cmd_idx++).Layer(current_layer).Tex(current_tex);
|
||||||
|
cmd->PushIndex(2).PushIndex(1).PushIndex(0);
|
||||||
|
cmd->PushVertex(Vertex(a, vec2(0.f, 1.f), col));
|
||||||
|
cmd->PushVertex(Vertex(b, vec2(1.f, 1.f), col));
|
||||||
|
cmd->PushVertex(Vertex(c, vec2(1.f, 0.f), col));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::TextCommand(std::vector<Command::Ref>& cmds, const vec2& pos,
|
||||||
|
u32 color, const std::string& text,
|
||||||
|
LITextFlags flags, const vec2& box) {
|
||||||
|
if (!font) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vec2 off;
|
||||||
|
float cfs = (default_font_h * text_size) / (float)font->PixelHeight();
|
||||||
|
float lh = (float)font->PixelHeight() * cfs;
|
||||||
|
vec2 td;
|
||||||
|
vec2 rpos = pos;
|
||||||
|
vec2 rbox = box;
|
||||||
|
if (flags & (LITextFlags_AlignMid | LITextFlags_AlignRight)) {
|
||||||
|
td = GetTextDimensions(text);
|
||||||
|
if (rbox[0] == 0.f) {
|
||||||
|
rbox[0] = area_size.x();
|
||||||
|
}
|
||||||
|
if (rbox[1] == 0.f) {
|
||||||
|
rbox[1] = area_size.y();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flags & LITextFlags_AlignMid) {
|
||||||
|
rpos = rbox * 0.5 - td * 0.5 + pos;
|
||||||
|
}
|
||||||
|
if (flags & LITextFlags_AlignRight) {
|
||||||
|
rpos[0] = rpos[0] - td[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> lines;
|
||||||
|
std::istringstream iss(text);
|
||||||
|
std::string tmp;
|
||||||
|
while (std::getline(iss, tmp)) {
|
||||||
|
lines.push_back(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& it : lines) {
|
||||||
|
if (flags & LITextFlags_Short) {
|
||||||
|
vec2 tmp_dim;
|
||||||
|
it = ShortText(it, box.x() - pos.x(), tmp_dim);
|
||||||
|
}
|
||||||
|
/// Well support OOS Rendering here as well
|
||||||
|
/// Fixes UI7 Scroll back up bug
|
||||||
|
if (rpos[1] + off[1] + lh < 0 && !(flags & LITextFlags_RenderOOS)) {
|
||||||
|
off[1] += lh;
|
||||||
|
continue;
|
||||||
|
} else if (rpos[1] + off[1] > GetViewport().w() &&
|
||||||
|
!(flags & LITextFlags_RenderOOS)) {
|
||||||
|
// Break cause next lines would be out of screen
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
auto wline = Strings::MakeWstring(it);
|
||||||
|
auto cmd = Command::New();
|
||||||
|
current_tex = font->GetCodepoint(wline[0]).tex();
|
||||||
|
SetupCommand(cmd);
|
||||||
|
cmd->Rendermode(RenderMode_Font);
|
||||||
|
for (auto& jt : wline) {
|
||||||
|
auto cp = font->GetCodepoint(jt);
|
||||||
|
if (cp.invalid() && jt != '\n' && jt != '\t') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (current_tex != cp.tex()) {
|
||||||
|
cmds.push_back(cmd);
|
||||||
|
cmd = Command::New();
|
||||||
|
current_tex = cp.tex();
|
||||||
|
SetupCommand(cmd);
|
||||||
|
cmd->Rendermode(RenderMode_Font);
|
||||||
|
}
|
||||||
|
if (jt == '\t') {
|
||||||
|
off[0] += 16 * cfs;
|
||||||
|
} else {
|
||||||
|
if (jt != ' ') {
|
||||||
|
int lr = current_layer;
|
||||||
|
if (flags & LITextFlags_Shaddow) {
|
||||||
|
// Draw
|
||||||
|
Rect rec = CreateRect(
|
||||||
|
rpos + vec2(off[0] + 1, off[1] + (cp.off() * cfs)) + 1,
|
||||||
|
cp.size() * cfs, 0.f);
|
||||||
|
QuadCommand(cmd, rec, cp.uv(), 0xff111111);
|
||||||
|
current_layer++;
|
||||||
|
}
|
||||||
|
// Draw
|
||||||
|
Rect rec = CreateRect(rpos + off + vec2(0, (cp.off() * cfs)),
|
||||||
|
cp.size() * cfs, 0.f);
|
||||||
|
QuadCommand(cmd, rec, cp.uv(), color);
|
||||||
|
current_layer = lr;
|
||||||
|
} else {
|
||||||
|
if (!font->SystemFont()) {
|
||||||
|
off[0] += 2 * cfs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
off[0] += cp.size().x() * cfs + 2 * cfs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cmds.push_back(cmd);
|
||||||
|
off[1] += lh;
|
||||||
|
off[0] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 Renderer::GetViewport() { return vec4(vec2(), screen->GetSize()); }
|
||||||
|
|
||||||
|
std::string Renderer::ShortText(const std::string& text, int maxlen,
|
||||||
|
vec2& newsize) {
|
||||||
|
vec2 cdim;
|
||||||
|
if (flags & LIRenderFlags_TMS) {
|
||||||
|
auto e = tms.find(text);
|
||||||
|
if (e != tms.end()) {
|
||||||
|
e->second.TimeCreated(Sys::GetTime());
|
||||||
|
if (e->second.Optional()) {
|
||||||
|
return e->second.Text();
|
||||||
|
}
|
||||||
|
cdim = e->second.Size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cdim = this->GetTextDimensions(text);
|
||||||
|
if (cdim[0] < (float)maxlen) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
std::string ext;
|
||||||
|
/// Forgot why i called this var ending cause
|
||||||
|
/// Its more a placeholder for removed content
|
||||||
|
std::string ending = "...";
|
||||||
|
std::string cpy = text;
|
||||||
|
std::string res;
|
||||||
|
size_t extension = text.find_last_of('.');
|
||||||
|
if (extension != text.npos) {
|
||||||
|
ext = text.substr(extension);
|
||||||
|
cpy = text.substr(0, extension);
|
||||||
|
maxlen -= GetTextDimensions(ext).x();
|
||||||
|
}
|
||||||
|
maxlen -= GetTextDimensions(ending).x();
|
||||||
|
for (auto& it : cpy) {
|
||||||
|
if (GetTextDimensions(res).x() > (float)maxlen) {
|
||||||
|
res += ending;
|
||||||
|
res += ext;
|
||||||
|
newsize = GetTextDimensions(res);
|
||||||
|
if (flags & LIRenderFlags_TMS) {
|
||||||
|
auto& tmp = tms[text];
|
||||||
|
tmp.Text(res);
|
||||||
|
tmp.Size(newsize);
|
||||||
|
tmp.TimeCreated(Sys::GetTime());
|
||||||
|
tmp.Optional(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
res += it;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Renderer::WrapText(const std::string& text, int maxlen,
|
||||||
|
vec2& newsize) {}
|
||||||
|
|
||||||
|
vec2 Renderer::GetTextDimensions(const std::string& text) {
|
||||||
|
if (!font) {
|
||||||
|
// No font no size (oder so)
|
||||||
|
return vec2();
|
||||||
|
}
|
||||||
|
// Handle TextMapSystem
|
||||||
|
if (flags & LIRenderFlags_TMS) {
|
||||||
|
auto ref = tms.find(text);
|
||||||
|
if (ref != tms.end()) {
|
||||||
|
ref->second.TimeCreated(Sys::GetTime());
|
||||||
|
return ref->second.Size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Use wstring for exemple for german äöü
|
||||||
|
auto wtext = Strings::MakeWstring(text);
|
||||||
|
// Create a temp position and offset as [0, 0]
|
||||||
|
vec2 res;
|
||||||
|
float x = 0;
|
||||||
|
// Curent Font Scale
|
||||||
|
float cfs = (default_font_h * text_size) / (float)font->PixelHeight();
|
||||||
|
float lh = (float)font->PixelHeight() * cfs;
|
||||||
|
size_t index = 0;
|
||||||
|
for (auto& it : wtext) {
|
||||||
|
if (it == '\0') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
auto cp = font->GetCodepoint(it);
|
||||||
|
if (cp.invalid() && it != '\n' && it != '\t' && it != ' ') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
switch (it) {
|
||||||
|
case '\n':
|
||||||
|
res[1] += lh;
|
||||||
|
res[0] = std::max(res[0], x);
|
||||||
|
x = 0.f;
|
||||||
|
break;
|
||||||
|
case '\t':
|
||||||
|
x += 16 * cfs;
|
||||||
|
break;
|
||||||
|
case ' ':
|
||||||
|
if (!font->SystemFont()) {
|
||||||
|
x += 2 * cfs;
|
||||||
|
}
|
||||||
|
// Fall trough here to get the same result as in
|
||||||
|
// TextCommand if/else Section
|
||||||
|
default:
|
||||||
|
x += cp.size().x() * cfs;
|
||||||
|
if (index != wtext.size()) {
|
||||||
|
x += 2 * cfs;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res[0] = std::max(res[0], x);
|
||||||
|
res[1] += lh;
|
||||||
|
if (flags & LIRenderFlags_TMS) {
|
||||||
|
tms[text] = TextBox(res, Sys::GetTime());
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::UpdateRenderMode(const RenderMode& mode) {
|
||||||
|
C3D_TexEnv* env = C3D_GetTexEnv(0);
|
||||||
|
switch (mode) {
|
||||||
|
case RenderMode_Font:
|
||||||
|
/// Sets Only Alpha Using the Color and Replase RGB with vertex color
|
||||||
|
C3D_TexEnvInit(env);
|
||||||
|
C3D_TexEnvSrc(env, C3D_RGB, GPU_PRIMARY_COLOR);
|
||||||
|
C3D_TexEnvFunc(env, C3D_RGB, GPU_REPLACE);
|
||||||
|
C3D_TexEnvSrc(env, C3D_Alpha, GPU_TEXTURE0);
|
||||||
|
C3D_TexEnvFunc(env, C3D_Alpha, GPU_MODULATE);
|
||||||
|
break;
|
||||||
|
// Fall trough instead of defining twice
|
||||||
|
case RenderMode_RGBA:
|
||||||
|
default:
|
||||||
|
/// Use Texture for RGBA and vertexcolor for visibility
|
||||||
|
C3D_TexEnvInit(env);
|
||||||
|
C3D_TexEnvSrc(env, C3D_Both, GPU_TEXTURE0);
|
||||||
|
C3D_TexEnvFunc(env, C3D_Both, GPU_MODULATE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::PrepareRender() {
|
||||||
|
if (font_update) {
|
||||||
|
tms.clear();
|
||||||
|
font_update = false;
|
||||||
|
}
|
||||||
|
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||||
|
TT::Beg("LI_RenderAll");
|
||||||
|
vertex_idx = 0;
|
||||||
|
index_idx = 0;
|
||||||
|
vertices = 0;
|
||||||
|
indices = 0;
|
||||||
|
commands = 0;
|
||||||
|
drawcalls = 0;
|
||||||
|
C3D_BindProgram(&shader);
|
||||||
|
C3D_SetAttrInfo(&attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::FinalizeRender() {
|
||||||
|
C3D_FrameEnd(0);
|
||||||
|
TT::End("LI_RenderAll");
|
||||||
|
current_layer = 0;
|
||||||
|
cmd_idx = 0;
|
||||||
|
rot = 0.f;
|
||||||
|
UseTex();
|
||||||
|
if (flags & LIRenderFlags_TMS) {
|
||||||
|
std::vector<std::string> rem;
|
||||||
|
for (auto& it : tms) {
|
||||||
|
if (Sys::GetTime() - it.second.TimeCreated() > 5) rem.push_back(it.first);
|
||||||
|
}
|
||||||
|
for (auto it : rem) tms.erase(it);
|
||||||
|
} else {
|
||||||
|
tms.clear();
|
||||||
|
}
|
||||||
|
if (flags & LIRenderFlags_AST) {
|
||||||
|
std::vector<u32> rem;
|
||||||
|
for (auto it : ast) {
|
||||||
|
if (!it.second->Used()) {
|
||||||
|
rem.push_back(it.first);
|
||||||
|
}
|
||||||
|
it.second->SetUnused();
|
||||||
|
}
|
||||||
|
for (auto& it : rem) {
|
||||||
|
ast.erase(it);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ast.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::Render(Screen::Ref s) {
|
||||||
|
Assert(s.get(), "Expected Screen Address but got nullptr!");
|
||||||
|
s->Clear();
|
||||||
|
s->Use();
|
||||||
|
bool bot = s->ScreenType() == Screen::Bottom;
|
||||||
|
C3D_FVUnifMtx4x4(GPU_VERTEX_SHADER, uLoc_projection,
|
||||||
|
(bot ? &bot_proj : &top_proj));
|
||||||
|
C3D_DepthTest(false, GPU_GREATER, GPU_WRITE_ALL);
|
||||||
|
UpdateRenderMode(RenderMode_RGBA);
|
||||||
|
int total_vertices = 0;
|
||||||
|
int total_indices = 0;
|
||||||
|
auto& cmds = draw_list[Screen32(s)];
|
||||||
|
commands += cmds.size();
|
||||||
|
size_t index = 0;
|
||||||
|
if (flags & LIRenderFlags_LRS) {
|
||||||
|
OptiCommandList(cmds);
|
||||||
|
}
|
||||||
|
while (index < cmds.size()) {
|
||||||
|
C3D_Tex* tex = cmds[index]->Tex()->GetTex();
|
||||||
|
auto mode = cmds[index]->Rendermode();
|
||||||
|
UpdateRenderMode(mode);
|
||||||
|
u32 start_vtx = vertex_idx;
|
||||||
|
u32 start_idx = index_idx;
|
||||||
|
while (index < cmds.size() && cmds[index]->Tex()->GetTex() == tex &&
|
||||||
|
cmds[index]->Rendermode() == mode) {
|
||||||
|
auto c = cmds[index];
|
||||||
|
// Indices
|
||||||
|
for (size_t i = 0; i < c->IndexList().size(); i++) {
|
||||||
|
index_buf[index_idx++] = vertex_idx + c->IndexList().at(i);
|
||||||
|
}
|
||||||
|
// Vertices
|
||||||
|
for (size_t i = 0; i < c->VertexList().size(); i++) {
|
||||||
|
vertex_buf[vertex_idx++] = c->VertexList().at(i);
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
C3D_TexBind(0, tex);
|
||||||
|
|
||||||
|
auto bufInfo = C3D_GetBufInfo();
|
||||||
|
BufInfo_Init(bufInfo);
|
||||||
|
BufInfo_Add(bufInfo, vertex_buf.data(), sizeof(Vertex), 3, 0x210);
|
||||||
|
|
||||||
|
C3D_DrawElements(GPU_TRIANGLES, index_idx - start_idx, C3D_UNSIGNED_SHORT,
|
||||||
|
index_buf.data() + start_idx);
|
||||||
|
|
||||||
|
drawcalls++;
|
||||||
|
total_vertices += vertex_idx - start_vtx;
|
||||||
|
total_indices += index_idx - start_idx;
|
||||||
|
}
|
||||||
|
cmds.clear();
|
||||||
|
C3D_DepthTest(true, GPU_GREATER, GPU_WRITE_ALL);
|
||||||
|
vertices += total_vertices;
|
||||||
|
indices += total_indices;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::DrawRect(const vec2& pos, const vec2& size, u32 color,
|
||||||
|
const Rect& uv) {
|
||||||
|
if (!InBox(pos, size, GetViewport())) {
|
||||||
|
// Instand abort as it is out of screen
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Rect rec = CreateRect(pos, size, rot);
|
||||||
|
auto cmd = Command::New();
|
||||||
|
SetupCommand(cmd);
|
||||||
|
QuadCommand(cmd, rec, uv, color);
|
||||||
|
draw_list[Screen32(screen)].push_back(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::DrawRectSolid(const vec2& pos, const vec2& size, u32 color) {
|
||||||
|
UseTex();
|
||||||
|
DrawRect(pos, size, color, vec4(0.f, 1.f, 1.f, 0.f));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::DrawTriangle(const vec2& a, const vec2& b, const vec2& c,
|
||||||
|
u32 color) {
|
||||||
|
if (!InBox(a, b, c, GetViewport())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UseTex();
|
||||||
|
auto cmd = Command::New();
|
||||||
|
SetupCommand(cmd);
|
||||||
|
TriangleCommand(cmd, a, b, c, color);
|
||||||
|
draw_list[Screen32(screen)].push_back(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::DrawCircle(const vec2& center_pos, float r, u32 color,
|
||||||
|
int segments) {
|
||||||
|
if (segments < 3) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto cmd = Command::New();
|
||||||
|
cmd->Index(cmd_idx++).Layer(current_layer).Tex(current_tex);
|
||||||
|
for (int i = 1; i < segments - 1; i++) {
|
||||||
|
cmd->PushIndex(0);
|
||||||
|
cmd->PushIndex(i + 1).PushIndex(i);
|
||||||
|
}
|
||||||
|
float as = 2.f * M_PI / segments;
|
||||||
|
for (int i = 0; i < segments; i++) {
|
||||||
|
float a = i * as;
|
||||||
|
float x = center_pos.x() + r * std::cos(a);
|
||||||
|
float y = center_pos.y() + r * std::sin(a);
|
||||||
|
cmd->PushVertex(Vertex(
|
||||||
|
vec2(x, y), vec2((std::cos(a) + 1.f) / 2.f, (std::sin(a) + 1.f) / 2.f),
|
||||||
|
color));
|
||||||
|
}
|
||||||
|
draw_list[Screen32(screen)].push_back(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::DrawLine(const vec2& a, const vec2& b, u32 color, int t) {
|
||||||
|
UseTex();
|
||||||
|
Rect line = CreateLine(a, b, t);
|
||||||
|
|
||||||
|
auto cmd = Command::New();
|
||||||
|
SetupCommand(cmd);
|
||||||
|
QuadCommand(cmd, line, vec4(0.f, 1.f, 1.f, 0.f), color);
|
||||||
|
draw_list[Screen32(screen)].push_back(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::DrawImage(const vec2& pos, Texture::Ref tex, const vec2& scale) {
|
||||||
|
UseTex(tex);
|
||||||
|
DrawRect(pos, tex->GetSize() * scale, 0xffffffff, tex->GetUV());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::DrawText(const vec2& pos, u32 color, const std::string& text,
|
||||||
|
u32 flags, const vec2& ap) {
|
||||||
|
if (!font) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this->flags & LIRenderFlags_AST) {
|
||||||
|
u32 id = Strings::FastHash(text);
|
||||||
|
auto e = ast.find(id);
|
||||||
|
if (e == ast.end()) {
|
||||||
|
ast[id] = StaticText::New();
|
||||||
|
e = ast.find(id);
|
||||||
|
}
|
||||||
|
if (!e->second->IsSetup() || e->second->Font() != font) {
|
||||||
|
e->second->Setup(this, pos, color, text, flags, ap);
|
||||||
|
e->second->Font(font);
|
||||||
|
}
|
||||||
|
e->second->SetPos(pos);
|
||||||
|
e->second->SetColor(color);
|
||||||
|
e->second->Draw();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TextCommand(draw_list[Screen32(screen)], pos, color, text, flags, ap);
|
||||||
|
}
|
||||||
|
} // namespace LI
|
||||||
|
} // namespace PD
|
@ -21,8 +21,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/io.hpp>
|
#include <pd/core/io.hpp>
|
||||||
#include <pd/graphics/spritesheet.hpp>
|
#include <pd/app/error.hpp>
|
||||||
|
#include <pd/lithium/spritesheet.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
SpriteSheet::~SpriteSheet() { textures.clear(); }
|
SpriteSheet::~SpriteSheet() { textures.clear(); }
|
@ -26,10 +26,10 @@ SOFTWARE.
|
|||||||
#include <pd/external/stb_image.h>
|
#include <pd/external/stb_image.h>
|
||||||
#include <tex3ds.h>
|
#include <tex3ds.h>
|
||||||
|
|
||||||
#include <pd/common/error.hpp>
|
#include <pd/app/error.hpp>
|
||||||
#include <pd/common/io.hpp>
|
#include <pd/core/io.hpp>
|
||||||
#include <pd/common/timetrace.hpp>
|
#include <pd/core/timetrace.hpp>
|
||||||
#include <pd/graphics/texture.hpp>
|
#include <pd/lithium/texture.hpp>
|
||||||
#include <pd/maths/bit_util.hpp>
|
#include <pd/maths/bit_util.hpp>
|
||||||
#include <pd/maths/img_convert.hpp>
|
#include <pd/maths/img_convert.hpp>
|
||||||
|
|
@ -24,7 +24,7 @@ SOFTWARE.
|
|||||||
#include <pd/external/json.hpp>
|
#include <pd/external/json.hpp>
|
||||||
#include <pd/maths/color.hpp>
|
#include <pd/maths/color.hpp>
|
||||||
#include <pd/overlays/keyboard.hpp>
|
#include <pd/overlays/keyboard.hpp>
|
||||||
#include <pd/tools/gamepad_icons.hpp>
|
#include <pd/lib3ds/gamepad_icons.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
struct Key {
|
struct Key {
|
||||||
|
@ -21,8 +21,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/strings.hpp>
|
#include <pd/core/strings.hpp>
|
||||||
#include <pd/common/sys.hpp>
|
#include <pd/core/sys.hpp>
|
||||||
#include <pd/overlays/performance.hpp>
|
#include <pd/overlays/performance.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
|
@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/sys.hpp>
|
#include <pd/core/sys.hpp>
|
||||||
#include <pd/ui7/container/container.hpp>
|
#include <pd/ui7/container/container.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
|
@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/strings.hpp>
|
#include <pd/core/strings.hpp>
|
||||||
#include <pd/ui7/drawlist.hpp>
|
#include <pd/ui7/drawlist.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
@ -62,7 +62,7 @@ void DrawList::AddText(vec2 pos, const std::string& text, const UI7Color& clr,
|
|||||||
u32 id = Strings::FastHash(text);
|
u32 id = Strings::FastHash(text);
|
||||||
auto e = static_text.find(id);
|
auto e = static_text.find(id);
|
||||||
if (e == static_text.end()) {
|
if (e == static_text.end()) {
|
||||||
static_text[id] = LI::Renderer::StaticText::New();
|
static_text[id] = LI::StaticText::New();
|
||||||
e = static_text.find(id);
|
e = static_text.find(id);
|
||||||
}
|
}
|
||||||
if (!e->second->IsSetup() || e->second->Font() != ren->Font()) {
|
if (!e->second->IsSetup() || e->second->Font() != ren->Font()) {
|
||||||
|
@ -21,8 +21,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/sys.hpp>
|
#include <pd/core/sys.hpp>
|
||||||
#include <pd/common/timetrace.hpp>
|
#include <pd/core/timetrace.hpp>
|
||||||
#include <pd/ui7/menu.hpp>
|
#include <pd/ui7/menu.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
|
@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/common/timetrace.hpp>
|
#include <pd/core/timetrace.hpp>
|
||||||
#include <pd/ui7/ui7.hpp>
|
#include <pd/ui7/ui7.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
|
@ -84,7 +84,7 @@ class Test : public PD::App {
|
|||||||
m->SameLine();
|
m->SameLine();
|
||||||
if (m->Button("Palladium")) {
|
if (m->Button("Palladium")) {
|
||||||
this->FeatureDisable(AppFLags_UserLoop);
|
this->FeatureDisable(AppFLags_UserLoop);
|
||||||
Overlays()->Push(PD::New<PD::SettingsMenu>(this));
|
Overlays()->Push(PD::New<PD::SettingsMenu>());
|
||||||
}
|
}
|
||||||
m->SeparatorText("SeparatorText");
|
m->SeparatorText("SeparatorText");
|
||||||
m->Checkbox("Test", cbtest);
|
m->Checkbox("Test", cbtest);
|
||||||
|
@ -86,9 +86,9 @@ for object in shaders:
|
|||||||
name = Path(Path(object).stem).stem
|
name = Path(Path(object).stem).stem
|
||||||
bp = os.path.dirname(object)
|
bp = os.path.dirname(object)
|
||||||
build_shader(object)
|
build_shader(object)
|
||||||
file2array(bp + '/' + name + '.shbin', 'pd/graphics/')
|
file2array(bp + '/' + name + '.shbin', 'pd/lithium/')
|
||||||
install_code(name + '.cpp', 'source/graphics/')
|
install_code(name + '.cpp', 'source/lithium/')
|
||||||
install_code(name + '.hpp', 'include/pd/graphics/')
|
install_code(name + '.hpp', 'include/pd/lithium/')
|
||||||
|
|
||||||
cleanup()
|
cleanup()
|
||||||
print("Done")
|
print("Done")
|
Loading…
Reference in New Issue
Block a user