# Changes 0.2.4-1
- Add GIT_BRANCH (for development and stable) - Write Documentation of - pd-core (exept of vec.hpp) - pd-app - pd-drivers - pd-lib3ds - pd-image - pd-image - pd-ui7
This commit is contained in:
@ -32,34 +32,56 @@ SOFTWARE.
|
||||
#include <pd/overlays/overlay_mgr.hpp>
|
||||
|
||||
namespace PD {
|
||||
/// @brief Template Class for User Application
|
||||
/**
|
||||
* Template Class for a User Application on the 3ds
|
||||
*/
|
||||
class App {
|
||||
public:
|
||||
/**
|
||||
* alias for AppFlags
|
||||
*/
|
||||
using AppFlags = u32;
|
||||
/**
|
||||
* App Flags
|
||||
*
|
||||
* - Probably only the default Setup should be used
|
||||
*/
|
||||
enum AppFlags_ {
|
||||
AppFlags_None = 0,
|
||||
AppFLags_UserLoop = 1 << 0,
|
||||
AppFlags_HandleOverlays = 1 << 1,
|
||||
AppFlags_HandleMessageMgr = 1 << 2,
|
||||
AppFlags_HandleRendering = 1 << 3,
|
||||
AppFlags_None = 0, ///< Do Nothing
|
||||
AppFLags_UserLoop = 1 << 0, ///< Handle User MainLoop
|
||||
AppFlags_HandleOverlays = 1 << 1, ///< Process Overlays
|
||||
AppFlags_HandleMessageMgr = 1 << 2, ///< Process Messages
|
||||
AppFlags_HandleRendering = 1 << 3, ///< Handle Rendering
|
||||
/// Default Flags
|
||||
AppFlags_Default = AppFlags_HandleMessageMgr | AppFlags_HandleOverlays |
|
||||
AppFlags_HandleRendering | AppFLags_UserLoop,
|
||||
};
|
||||
/**
|
||||
* alias for AppInitFlags
|
||||
*/
|
||||
using AppInitFlags = u32;
|
||||
/**
|
||||
* App Init Flags
|
||||
*/
|
||||
enum AppInitFlags_ {
|
||||
AppInitFlags_None = 0, /// Do nothing (probably a useles ability)
|
||||
AppInitFlags_MountRomfs = 1 << 0, /// Mount Romfs on PreInit
|
||||
AppInitFlags_InitGraphics = 1 << 1, /// Default Init Graphics for GPU use
|
||||
AppInitFlags_New3dsMode = 1 << 2, /// Enable New3DS Speedup
|
||||
AppInitFlags_InitGraphicsNoC3D = 1 << 3, /// Init GFX for Buf Modification
|
||||
AppInitFlags_InitLithium = 1 << 4, /// Init 2D Rendering Engine
|
||||
AppInitFlags_None = 0, ///< Do nothing (probably a useles ability)
|
||||
AppInitFlags_MountRomfs = 1 << 0, ///< Mount Romfs on PreInit
|
||||
AppInitFlags_InitGraphics = 1 << 1, ///< Default Init Graphics for GPU use
|
||||
AppInitFlags_New3dsMode = 1 << 2, ///< Enable New3DS Speedup
|
||||
AppInitFlags_InitGraphicsNoC3D = 1 << 3, ///< Init GFX for Buf Modification
|
||||
AppInitFlags_InitLithium = 1 << 4, ///< Init 2D Rendering Engine
|
||||
/// I dont have a name for this one yet
|
||||
/// It Inits Internal Directory structure
|
||||
AppInitFlags_UnnamedOption1 = 1 << 5,
|
||||
AppInitFlags_InitHwInfo = 1 << 6, /// Init HwInfo from lib3ds
|
||||
AppInitFlags_InitHwInfo = 1 << 6, ///< Init HwInfo from lib3ds
|
||||
/// Default App Init Flags
|
||||
AppInitFlags_Default = AppInitFlags_MountRomfs | AppInitFlags_InitGraphics |
|
||||
AppInitFlags_New3dsMode | AppInitFlags_InitLithium,
|
||||
};
|
||||
/**
|
||||
* App Constructor that can Optionally set a name for the App
|
||||
* @param name App Name Defaults to App
|
||||
*/
|
||||
App(const std::string& name = "App") {
|
||||
if (too) {
|
||||
Error("Only one App can be created at the same time!");
|
||||
@ -67,60 +89,143 @@ class App {
|
||||
this->name = name;
|
||||
too++;
|
||||
}
|
||||
/**
|
||||
* App Deconstructor
|
||||
*/
|
||||
~App() { too--; }
|
||||
|
||||
/// @brief Templete function where the user can Init his stuff
|
||||
/**
|
||||
* Templete function where the user can Init his stuff
|
||||
*/
|
||||
virtual void Init() {}
|
||||
/// @brief Templeta funciton to deinit stuff
|
||||
/// (most of that is done automatically)
|
||||
/**
|
||||
* Template function to deinit stuff (most is deinit automatically
|
||||
* but it is still possible that some things need to be ordered manually)
|
||||
*/
|
||||
virtual void Deinit() {}
|
||||
/// @brief App Mainloop
|
||||
/// @param delta Deltatime
|
||||
/// @param time App RunTime
|
||||
/// @return false to exit the app
|
||||
/**
|
||||
* Template User MainLoop
|
||||
* @param delta Delta time
|
||||
* @param time App Run time
|
||||
* @return false to exit the App
|
||||
*/
|
||||
virtual bool MainLoop(float delta, float time) { return false; }
|
||||
|
||||
/// @brief Function to run the App
|
||||
/// (int main() {
|
||||
/// UserApp app;
|
||||
/// app.Run();
|
||||
/// return 0;
|
||||
/// })
|
||||
/**
|
||||
* Function to actually run the app
|
||||
*
|
||||
* Example:
|
||||
* ```cpp
|
||||
* int main() {
|
||||
* UserApp app;
|
||||
* app.Run();
|
||||
* return 0;
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
void Run();
|
||||
/**
|
||||
* Get the Renderer Reference
|
||||
* @return Renderer Reference
|
||||
*/
|
||||
LI::Renderer::Ref Renderer() { return renderer; }
|
||||
/**
|
||||
* Get Message Manager Reference
|
||||
* @return Message Manager Reference
|
||||
*/
|
||||
MessageMgr::Ref Messages() { return msg_mgr; }
|
||||
/**
|
||||
* Get Overlay Manager Reference
|
||||
* @return Overlay Manager Reference
|
||||
*/
|
||||
OverlayMgr::Ref Overlays() { return overlay_mgr; }
|
||||
/**
|
||||
* Get Input Driver Reference
|
||||
* @return Input Driver Reference
|
||||
*/
|
||||
Hid::Ref Input() { return input_mgr; }
|
||||
/**
|
||||
* Get Framerate
|
||||
* @return frames per second
|
||||
*/
|
||||
float GetFps() const { return fps; }
|
||||
|
||||
/**
|
||||
* Enable Runtime Feature(s) (AppFlags)
|
||||
* @param flags Flag(s) to enable
|
||||
*/
|
||||
void FeatureEnable(AppFlags flags) { runtimeflags |= flags; }
|
||||
/**
|
||||
* Disable Runtime Feature(s) (AppFlags)
|
||||
* @param flags Flag(s) to disable
|
||||
*/
|
||||
void FeatureDisable(AppFlags flags) { runtimeflags &= ~flags; }
|
||||
/**
|
||||
* Get Reference Access to runtimeflags
|
||||
* @return reference to runtimeflags
|
||||
*/
|
||||
AppFlags& GetFeatureSet() { return runtimeflags; }
|
||||
|
||||
/**
|
||||
* Get App Datadirectory (if enabled in AppInitFlags)
|
||||
* @return App Data Directory
|
||||
*/
|
||||
std::string GetDataDirectory();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Top Screen Reference
|
||||
*/
|
||||
Screen::Ref Top;
|
||||
/**
|
||||
* Bottom Screen Reference
|
||||
*/
|
||||
Screen::Ref Bottom;
|
||||
/**
|
||||
* AppInitFlags
|
||||
*
|
||||
* - Can only be edited in your App class Constructor
|
||||
* - Editing them Later will not effect the Deinit Process
|
||||
* Example:
|
||||
* ```cpp
|
||||
* class YourApp : public PD::App {
|
||||
* public:
|
||||
* YourApp(): App("YourApp") {
|
||||
* AppInitFlags |= AppInitFlags_InitLithium;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
AppInitFlags InitFlags = AppInitFlags_Default;
|
||||
|
||||
private:
|
||||
/** Runtime Flags (can be edited) */
|
||||
AppFlags runtimeflags = AppFlags_Default;
|
||||
/// @brief Safe Copy to prevent from editing befor Deinit
|
||||
/** Safe Copy to prevent from editing befor Deinit */
|
||||
AppInitFlags SafeInitFlags = AppInitFlags_Default;
|
||||
/** PreInit Handler */
|
||||
void PreInit();
|
||||
/** Post Deinit Handler */
|
||||
void PostDeinit();
|
||||
/** Renderer Reference */
|
||||
LI::Renderer::Ref renderer;
|
||||
/** Message Manager */
|
||||
MessageMgr::Ref msg_mgr;
|
||||
/** Overlay Manager */
|
||||
OverlayMgr::Ref overlay_mgr;
|
||||
/** Input Driver */
|
||||
Hid::Ref input_mgr;
|
||||
/** Timer to track the App Runtime */
|
||||
Timer::Ref app_time;
|
||||
/** Last Time (for delta time and fps calculation) */
|
||||
u64 last_time;
|
||||
/** Framerate */
|
||||
float fps;
|
||||
|
||||
/** App Name */
|
||||
std::string name;
|
||||
|
||||
/// The Only One
|
||||
/** A static variable to make sure only one App instance can exist */
|
||||
static int too;
|
||||
};
|
||||
} // namespace PD
|
@ -26,6 +26,15 @@ SOFTWARE.
|
||||
#include <pd/core/common.hpp>
|
||||
|
||||
namespace PD {
|
||||
/**
|
||||
* Function to Throw an Error Screen
|
||||
* @param error Error Message to Display
|
||||
*/
|
||||
void Error(const std::string& error);
|
||||
/**
|
||||
* Custom Assert Function that Shows an Error Screen if it fails
|
||||
* @param v The bool var to check `(Throws error if it is false)`
|
||||
* @param msg The Message that Should be displayed if the Assert fails
|
||||
*/
|
||||
void Assert(bool v, const std::string& msg);
|
||||
} // namespace PD
|
@ -26,32 +26,73 @@ SOFTWARE.
|
||||
#include <pd/core/common.hpp>
|
||||
|
||||
namespace PD {
|
||||
/// @brief Lang System
|
||||
///< Translations are saved into json files
|
||||
///< Path should point to a directory the fils
|
||||
///< for example the files ar named [en.json, de.json, fr.json]
|
||||
/**
|
||||
* Language System
|
||||
*
|
||||
* - Translations are saved into json files
|
||||
* - path should point to a directory containing the json files
|
||||
* - example for filenames: `en.json`, `de.json`, `fr.json`
|
||||
*/
|
||||
class Lang : public SmartCtor<Lang> {
|
||||
public:
|
||||
Lang() = default;
|
||||
~Lang() = default;
|
||||
|
||||
/**
|
||||
* Function to set the path to search for Language files
|
||||
* @param path Path to search the files
|
||||
*/
|
||||
void SetBasePath(const std::string &path) { langs_path = path; }
|
||||
/**
|
||||
* Load a language file by the language key
|
||||
* @param lang_key Language key for example `de`
|
||||
*/
|
||||
void Load(const std::string &lang_key) {
|
||||
LoadFile(langs_path + "/" + lang_key + ".json");
|
||||
}
|
||||
/**
|
||||
* Directly load a Language file from a specific path
|
||||
* @param path Path to load the file from
|
||||
*/
|
||||
void LoadFile(const std::string &path);
|
||||
/**
|
||||
* Get a String by a `Keyword`
|
||||
* @param k Keyword to search for
|
||||
* @return Returns the string or if none found it returns the Keyword
|
||||
*/
|
||||
const std::string &Get(const std::string &k);
|
||||
/**
|
||||
* Get the Language Name
|
||||
* @return Returns the Language Name
|
||||
*/
|
||||
const std::string &GetName() { return lang_name; }
|
||||
/**
|
||||
* Get the Language ID / Key
|
||||
* @return Returns the Language ID
|
||||
*/
|
||||
const std::string &GetID() { return lang_id; }
|
||||
/**
|
||||
* Get the Language Author(s)
|
||||
* @return Returns the Author(s) of the Language file
|
||||
*/
|
||||
const std::string &GetAuthor() { return lang_author; }
|
||||
/**
|
||||
* Get the Language File Search Path
|
||||
* @return Returns Path where the Files are searched for
|
||||
*/
|
||||
const std::string &GetPath() { return langs_path; }
|
||||
|
||||
private:
|
||||
const int ver = 0;
|
||||
/** Language Files Root path */
|
||||
std::string langs_path = "romfs:/lang";
|
||||
/** Language Name */
|
||||
std::string lang_name;
|
||||
/** Language ID / Key */
|
||||
std::string lang_id;
|
||||
/** Language Author */
|
||||
std::string lang_author;
|
||||
/** KEY - STRING Table for faster Key access */
|
||||
std::map<std::string, std::string> ltable;
|
||||
};
|
||||
} // namespace PD
|
Reference in New Issue
Block a user