__
This commit is contained in:
25
include/renderd7/Draw.hpp
Normal file
25
include/renderd7/Draw.hpp
Normal file
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
#include <citro3d.h>
|
||||
#include <citro2d.h>
|
||||
#include <3ds.h>
|
||||
#include <string>
|
||||
|
||||
namespace RenderD7
|
||||
{
|
||||
namespace Draw
|
||||
{
|
||||
bool Rect(float x, float y, float w, float h, u32 color);
|
||||
bool NFRect(float p1x, float p1y, float w, float h, u32 color, float scale = 1);
|
||||
bool Px(float x, float y, u32 color);
|
||||
void TextCentered(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr);
|
||||
void Text(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr);
|
||||
void TextRight(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr);
|
||||
float GetTextWidth(float size, std::string Text, C2D_Font fnt = nullptr);
|
||||
void GetTextSize(float size, float *width, float *height, std::string Text, C2D_Font fnt = nullptr);
|
||||
float GetTextHeight(float size, std::string Text, C2D_Font fnt = nullptr);
|
||||
Result LoadFont(C2D_Font &fnt, const char * Path = "");
|
||||
Result UnloadFont(C2D_Font &fnt);
|
||||
bool Circle(float x, float y, float radius, u32 color);
|
||||
bool Image(C2D_Image img, float x, float y, float scaleX = 1.0f, float scaleY = 1.0f);
|
||||
}
|
||||
}
|
110
include/renderd7/FileSystem.hpp
Normal file
110
include/renderd7/FileSystem.hpp
Normal file
@ -0,0 +1,110 @@
|
||||
//FileSystem based on libphyfs based on https://github.com/TurtleP/3ds-examples/blob/fs/physfs/fs/physfs/include/filesystem.h
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <physfs.h>
|
||||
|
||||
namespace RenderD7
|
||||
{
|
||||
namespace FileSystem
|
||||
{
|
||||
static constexpr auto MAX_STAMP = 0x20000000000000LL;
|
||||
|
||||
enum FileMode
|
||||
{
|
||||
FileMode_Open,
|
||||
FileMode_Read,
|
||||
FileMode_Write,
|
||||
FileMode_Closed
|
||||
};
|
||||
|
||||
enum FileType
|
||||
{
|
||||
FileType_File,
|
||||
FileType_Directory,
|
||||
FileType_SymLink,
|
||||
FileType_Other
|
||||
};
|
||||
|
||||
struct File
|
||||
{
|
||||
PHYSFS_file* handle;
|
||||
FileMode mode;
|
||||
|
||||
File()
|
||||
{
|
||||
this->handle = nullptr;
|
||||
this->mode = FileMode_Closed;
|
||||
}
|
||||
|
||||
int64_t GetSize()
|
||||
{
|
||||
if (this->handle == nullptr)
|
||||
return 0;
|
||||
|
||||
return (int64_t)PHYSFS_fileLength(this->handle);
|
||||
}
|
||||
};
|
||||
|
||||
struct Info
|
||||
{
|
||||
int64_t size;
|
||||
int64_t mod_time;
|
||||
FileType type;
|
||||
};
|
||||
|
||||
int Init(const char* argv);
|
||||
|
||||
void Initialize();
|
||||
|
||||
/*
|
||||
** mounts a specific directory for physfs to search in
|
||||
** this is typically a main directory
|
||||
*/
|
||||
bool SetSource(const char* source);
|
||||
|
||||
/*
|
||||
** mounts a specific directory as a "save" directory
|
||||
** if appended, it will be added to the search path
|
||||
*/
|
||||
bool SetIdentity(const char* name, bool append);
|
||||
|
||||
static std::string savePath;
|
||||
|
||||
/* gets the last physfs error */
|
||||
const char* GetPhysfsError();
|
||||
|
||||
/* strips any duplicate slashes */
|
||||
std::string Normalize(const std::string& input);
|
||||
|
||||
/* gets the user directory from physfs */
|
||||
std::string GetUserDirectory();
|
||||
|
||||
/* gets the save directory */
|
||||
std::string GetSaveDirectory();
|
||||
|
||||
/* sets up the writing directory for physfs */
|
||||
bool SetupWriteDirectory();
|
||||
|
||||
/* gets a list of files in a directory */
|
||||
void GetDirectoryItems(const char* directory, std::vector<std::string>& items);
|
||||
|
||||
/* gets the size, mod_time, and type of a file */
|
||||
bool GetInfo(const char* filename, Info& info);
|
||||
|
||||
/* creates a new directory */
|
||||
bool CreateDirectory(const char* name);
|
||||
|
||||
bool CloseFile(File& file);
|
||||
|
||||
/* creates a new file */
|
||||
bool OpenFile(File& file, const char* name, FileMode mode);
|
||||
|
||||
/* writes to a file */
|
||||
bool WriteFile(File& file, const void* data, int64_t size);
|
||||
|
||||
/* reads a file's content */
|
||||
int64_t ReadFile(File& file, void* destination, int64_t size);
|
||||
}
|
||||
}
|
@ -40,6 +40,7 @@
|
||||
#include <renderd7/Color.hpp>
|
||||
#include <renderd7/Time.hpp>
|
||||
#include <renderd7/Screen.hpp>
|
||||
#include <renderd7/Draw.hpp>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@ -206,19 +207,7 @@ namespace RenderD7
|
||||
void ClearTextBufs(void);
|
||||
|
||||
std::string Kbd(int lenght, SwkbdType tp);
|
||||
bool DrawRect(float x, float y, float w, float h, u32 color);
|
||||
bool DrawNFRect(float p1x, float p1y, float w, float h, u32 color, float scale = 1);
|
||||
bool DrawPx(float x, float y, u32 color);
|
||||
void DrawTextCentered(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr);
|
||||
void DrawText(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr);
|
||||
void DrawTextLeft(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr);
|
||||
float GetTextWidth(float size, std::string Text, C2D_Font fnt = nullptr);
|
||||
void GetTextSize(float size, float *width, float *height, std::string Text, C2D_Font fnt = nullptr);
|
||||
float GetTextHeight(float size, std::string Text, C2D_Font fnt = nullptr);
|
||||
Result loadFont(C2D_Font &fnt, const char * Path = "");
|
||||
Result unloadFont(C2D_Font &fnt);
|
||||
bool DrawCircle(float x, float y, float radius, u32 color);
|
||||
bool DrawImage(C2D_Image img, float x, float y, float scaleX = 1.0f, float scaleY = 1.0f);
|
||||
|
||||
void FrameEnd();
|
||||
void ToggleRD7SR();
|
||||
bool IsRD7SR();
|
||||
|
Reference in New Issue
Block a user