Compare commits
9 Commits
0.6.2
...
alpha-0-3-
Author | SHA1 | Date | |
---|---|---|---|
122b07639e | |||
ce6170c475 | |||
0786c6f999 | |||
5144d5c00c | |||
1bf4ac775f | |||
4f1b5ee53c | |||
da498451c2 | |||
37422eb337 | |||
1f36fa9599 |
49
.github/workflows/Docs.yml
vendored
49
.github/workflows/Docs.yml
vendored
@ -1,49 +0,0 @@
|
|||||||
name: 📄
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ "**" ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ "*" ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
# This workflow contains a single job called "build"
|
|
||||||
build:
|
|
||||||
# The type of runner that the job will run on
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
|
||||||
steps:
|
|
||||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Extract branch name
|
|
||||||
shell: bash
|
|
||||||
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
|
|
||||||
id: branch
|
|
||||||
- name: Display branch name
|
|
||||||
shell: bash
|
|
||||||
run: echo ${{ steps.branch.outputs.branch }}
|
|
||||||
# Runs a single command using the runners shell
|
|
||||||
- name: Run a one-line script
|
|
||||||
run: |
|
|
||||||
sudo apt-get install doxygen cmake -y
|
|
||||||
doxygen
|
|
||||||
echo done
|
|
||||||
ls -r
|
|
||||||
cd ..
|
|
||||||
git clone https://github.com/NPI-D7/NPI-D7.github.io.git
|
|
||||||
mkdir -p NPI-D7.github.io/${{ steps.branch.outputs.branch }}
|
|
||||||
#rm -r NPI-D7.github.io/${{ steps.branch.outputs.branch }}/*
|
|
||||||
mv -v RenderD7/doc NPI-D7.github.io/${{ steps.branch.outputs.branch }}/
|
|
||||||
#rm -r doc
|
|
||||||
cd NPI-D7.github.io
|
|
||||||
git config --global user.email "tobid7@outlook.de"
|
|
||||||
git config --global user.name "Tobi-D7"
|
|
||||||
echo tobid7
|
|
||||||
git stage *
|
|
||||||
echo staged
|
|
||||||
git commit -m "Documentation1"
|
|
||||||
git tag doc
|
|
||||||
echo commited
|
|
||||||
git push origin main
|
|
||||||
echo pushed
|
|
50
.github/workflows/Update extlibs.yml
vendored
50
.github/workflows/Update extlibs.yml
vendored
@ -1,50 +0,0 @@
|
|||||||
name: Extlibs
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ '!*' ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ '!*' ]
|
|
||||||
|
|
||||||
# Allows you to run this workflow manually from the Actions tab
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
|
||||||
jobs:
|
|
||||||
# This workflow contains a single job called "build"
|
|
||||||
build:
|
|
||||||
# The type of runner that the job will run on
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
|
||||||
steps:
|
|
||||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: update
|
|
||||||
run: |
|
|
||||||
#gl
|
|
||||||
cd ..
|
|
||||||
git clone https://github.com/lua/lua.git
|
|
||||||
cd RenderD7
|
|
||||||
mkdir -p extlibs/
|
|
||||||
mkdir -p extlibs/lua/
|
|
||||||
cp -r ../lua/*.c extlibs/lua/
|
|
||||||
cp -r ../lua/*.h extlibs/lua/
|
|
||||||
cp -r ../lua/*.md extlibs/lua/
|
|
||||||
#RenderD7
|
|
||||||
cd ..
|
|
||||||
git clone https://github.com/NPI-D7/RenderD7.git
|
|
||||||
cd lp-next-ctr
|
|
||||||
mkdir -p extlibs/
|
|
||||||
rm -r extlibs/RenderD7
|
|
||||||
mkdir -p extlibs/RenderD7/
|
|
||||||
cp -r ../RenderD7/*.c* extlibs/RenderD7/
|
|
||||||
cp -r ../RenderD7/*.h* extlibs/RenderD7/
|
|
||||||
cp -r ../RenderD7/*.md extlibs/RenderD7/
|
|
||||||
#config
|
|
||||||
git config --global user.email "tobid7@outlook.de"
|
|
||||||
git config --global user.name "Tobi-D7"
|
|
||||||
#commit
|
|
||||||
git stage *
|
|
||||||
git commit -m "update extlibs"
|
|
||||||
git push origin main
|
|
@ -32,14 +32,14 @@ DOXYFILE_ENCODING = UTF-8
|
|||||||
# title of most generated pages and in a few other places.
|
# title of most generated pages and in a few other places.
|
||||||
# The default value is: My Project.
|
# The default value is: My Project.
|
||||||
|
|
||||||
PROJECT_NAME = Renderd7-nightly
|
PROJECT_NAME = Renderd7-0.3.0
|
||||||
|
|
||||||
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
|
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
|
||||||
# could be handy for archiving the generated documentation or if some version
|
# could be handy for archiving the generated documentation or if some version
|
||||||
# control system is used.
|
# control system is used.
|
||||||
|
|
||||||
|
|
||||||
PROJECT_NUMBER = "v0.7.0"
|
PROJECT_NUMBER = "v0.3.0"
|
||||||
|
|
||||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||||
# for a project that appears at the top of each page and should give viewer a
|
# for a project that appears at the top of each page and should give viewer a
|
||||||
@ -52,7 +52,7 @@ PROJECT_BRIEF "3ds graphics helper"
|
|||||||
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
|
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
|
||||||
# the logo to the output directory.
|
# the logo to the output directory.
|
||||||
|
|
||||||
PROJECT_LOGO =
|
PROJECT_LOGO = Docs/logo.svg
|
||||||
|
|
||||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
|
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
|
||||||
# into which the generated documentation will be written. If a relative path is
|
# into which the generated documentation will be written. If a relative path is
|
||||||
@ -855,7 +855,7 @@ WARN_LOGFILE =
|
|||||||
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
|
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
|
||||||
# Note: If this tag is empty the current directory is searched.
|
# Note: If this tag is empty the current directory is searched.
|
||||||
|
|
||||||
INPUT = .
|
INPUT = include doc/md
|
||||||
|
|
||||||
# This tag can be used to specify the character encoding of the source files
|
# This tag can be used to specify the character encoding of the source files
|
||||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||||
@ -884,7 +884,7 @@ INPUT_ENCODING = UTF-8
|
|||||||
# *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, *.vhdl,
|
# *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, *.vhdl,
|
||||||
# *.ucf, *.qsf and *.ice.
|
# *.ucf, *.qsf and *.ice.
|
||||||
|
|
||||||
FILE_PATTERNS = *.hpp *.h *.cpp
|
FILE_PATTERNS = *.hpp *.md
|
||||||
|
|
||||||
# The RECURSIVE tag can be used to specify whether or not subdirectories should
|
# The RECURSIVE tag can be used to specify whether or not subdirectories should
|
||||||
# be searched for input files as well.
|
# be searched for input files as well.
|
||||||
@ -1192,7 +1192,7 @@ HTML_STYLESHEET =
|
|||||||
# list). For an example see the documentation.
|
# list). For an example see the documentation.
|
||||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||||
|
|
||||||
HTML_EXTRA_STYLESHEET = doxygen.css
|
HTML_EXTRA_STYLESHEET = doc/custom.css
|
||||||
|
|
||||||
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
|
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
|
||||||
# other source files which should be copied to the HTML output directory. Note
|
# other source files which should be copied to the HTML output directory. Note
|
13
Docs/custom.css
Normal file
13
Docs/custom.css
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#projectlogo img{
|
||||||
|
max-height: 70px;
|
||||||
|
}
|
||||||
|
img[src="logotype.svg"]{
|
||||||
|
width:10cm;
|
||||||
|
}
|
||||||
|
div.contents{
|
||||||
|
max-width: 85%;
|
||||||
|
margin-left: 2%;
|
||||||
|
}
|
||||||
|
.textblock h1{
|
||||||
|
border-bottom: 1px solid #666;
|
||||||
|
}
|
@ -1,2 +1,5 @@
|
|||||||
# RenderD7 (https://npi-d7.github.io/RenderD7/main/doc/html/index.html)
|
# RenderD7 030
|
||||||
Simple and Easey to use UI and Graphics helper.
|
Simple and Easey to use UI and Graphics helper.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
1450
doxygen.css
1450
doxygen.css
File diff suppressed because it is too large
Load Diff
320
external/fs.c
vendored
320
external/fs.c
vendored
@ -1,320 +0,0 @@
|
|||||||
#include "external/fs.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
void Utils_U8_To_U16(u16 *buf, const u8 *input, size_t bufsize) {
|
|
||||||
ssize_t units = utf8_to_utf16(buf, input, bufsize);
|
|
||||||
|
|
||||||
if (units < 0)
|
|
||||||
units = 0;
|
|
||||||
|
|
||||||
buf[units] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
FS_Archive archive, sdmc_archive, nand_archive;
|
|
||||||
|
|
||||||
Result FS_OpenArchive(FS_Archive *archive, FS_ArchiveID archiveID) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_OpenArchive(archive, archiveID, fsMakePath(PATH_EMPTY, ""))))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_CloseArchive(FS_Archive archive) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_CloseArchive(archive)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_OpenDir(Handle *handle, FS_Archive archive, const char *path) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_OpenDirectory(handle, archive, fsMakePath(PATH_UTF16, path_u16))))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_OpenFile(Handle *handle, FS_Archive archive, const char *path, u32 flags, u32 attributes) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_OpenFile(handle, archive, fsMakePath(PATH_UTF16, path_u16), flags, attributes)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_MakeDir(FS_Archive archive, const char *path) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_CreateDirectory(archive, fsMakePath(PATH_UTF16, path_u16), 0)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_CreateFile(FS_Archive archive, const char *path, u64 size) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_CreateFile(archive, fsMakePath(PATH_UTF16, path_u16), 0, size)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_RecursiveMakeDir(FS_Archive archive, const char *path) {
|
|
||||||
Result ret = 0;
|
|
||||||
char buf[256];
|
|
||||||
char *p = NULL;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%s", path);
|
|
||||||
len = strlen(buf);
|
|
||||||
|
|
||||||
if (buf[len - 1] == '/')
|
|
||||||
buf[len - 1] = 0;
|
|
||||||
|
|
||||||
for (p = buf + 1; *p; p++) {
|
|
||||||
if (*p == '/') {
|
|
||||||
*p = 0;
|
|
||||||
|
|
||||||
if (!FS_DirExists(archive, buf))
|
|
||||||
ret = FS_MakeDir(archive, buf);
|
|
||||||
|
|
||||||
*p = '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FS_DirExists(archive, buf))
|
|
||||||
ret = FS_MakeDir(archive, buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FS_FileExists(FS_Archive archive, const char *path) {
|
|
||||||
Handle handle;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(FSUSER_OpenFile(&handle, archive, fsMakePath(PATH_UTF16, path_u16), FS_OPEN_READ, 0)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (R_FAILED(FSFILE_Close(handle)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FS_DirExists(FS_Archive archive, const char *path) {
|
|
||||||
Handle handle;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(FSUSER_OpenDirectory(&handle, archive, fsMakePath(PATH_UTF16, path_u16))))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (R_FAILED(FSDIR_Close(handle)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_GetFileSize(FS_Archive archive, const char *path, u64 *size) {
|
|
||||||
Result ret = 0;
|
|
||||||
Handle handle;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_OpenFile(&handle, archive, fsMakePath(PATH_UTF16, path_u16), FS_OPEN_READ, 0)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSFILE_GetSize(handle, size))) {
|
|
||||||
FSFILE_Close(handle);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSFILE_Close(handle)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 FS_GetFreeStorage(FS_SystemMediaType media_type) {
|
|
||||||
FS_ArchiveResource resource = {0};
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(FSUSER_GetArchiveResource(&resource, media_type)))
|
|
||||||
return (((u64)resource.freeClusters * (u64)resource.clusterSize));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 FS_GetTotalStorage(FS_SystemMediaType media_type) {
|
|
||||||
FS_ArchiveResource resource = {0};
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(FSUSER_GetArchiveResource(&resource, media_type)))
|
|
||||||
return (((u64)resource.totalClusters * (u64)resource.clusterSize));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 FS_GetUsedStorage(FS_SystemMediaType media_type) {
|
|
||||||
return (FS_GetTotalStorage(media_type) - FS_GetUsedStorage(media_type));
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_RemoveFile(FS_Archive archive, const char *path) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_DeleteFile(archive, fsMakePath(PATH_UTF16, path_u16))))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_RemoveDir(FS_Archive archive, const char *path) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_DeleteDirectory(archive, fsMakePath(PATH_UTF16, path_u16))))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_RemoveDirRecursive(FS_Archive archive, const char *path) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_DeleteDirectoryRecursively(archive, fsMakePath(PATH_UTF16, path_u16))))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_RenameFile(FS_Archive archive, const char *old_filename, const char *new_filename) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
u16 old_filename_u16[strlen(old_filename) + 1];
|
|
||||||
Utils_U8_To_U16(old_filename_u16, (const u8 *)old_filename, strlen(old_filename) + 1);
|
|
||||||
|
|
||||||
u16 new_filename_u16[strlen(new_filename) + 1];
|
|
||||||
Utils_U8_To_U16(new_filename_u16, (const u8 *)new_filename, strlen(new_filename) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_RenameFile(archive, fsMakePath(PATH_UTF16, old_filename_u16), archive, fsMakePath(PATH_UTF16, new_filename_u16))))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_RenameDir(FS_Archive archive, const char *old_dirname, const char *new_dirname) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
u16 old_dirname_u16[strlen(old_dirname) + 1];
|
|
||||||
Utils_U8_To_U16(old_dirname_u16, (const u8 *)old_dirname, strlen(old_dirname) + 1);
|
|
||||||
|
|
||||||
u16 new_dirname_u16[strlen(new_dirname) + 1];
|
|
||||||
Utils_U8_To_U16(new_dirname_u16, (const u8 *)new_dirname, strlen(new_dirname) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_RenameDirectory(archive, fsMakePath(PATH_UTF16, old_dirname_u16), archive, fsMakePath(PATH_UTF16, new_dirname_u16))))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_Read(FS_Archive archive, const char *path, u64 size, void *buf) {
|
|
||||||
Result ret = 0;
|
|
||||||
Handle handle;
|
|
||||||
|
|
||||||
u32 bytes_read = 0;
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FS_OpenFile(&handle, archive, path, FS_OPEN_READ, 0)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSFILE_Read(handle, &bytes_read, 0, buf, size))) {
|
|
||||||
FSFILE_Close(handle);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSFILE_Close(handle)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_Write(FS_Archive archive, const char *path, const void *buf, u32 size) {
|
|
||||||
Result ret = 0;
|
|
||||||
Handle handle;
|
|
||||||
u32 bytes_written = 0;
|
|
||||||
|
|
||||||
if (FS_FileExists(archive, path))
|
|
||||||
FS_RemoveFile(archive, path);
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_CreateFile(archive, fsMakePath(PATH_UTF16, path_u16), 0, size)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_OpenFile(&handle, archive, fsMakePath(PATH_UTF16, path_u16), FS_OPEN_WRITE, 0)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSFILE_Write(handle, &bytes_written, 0, buf, size, FS_WRITE_FLUSH))) {
|
|
||||||
FSFILE_Close(handle);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSFILE_Close(handle)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *FS_GetFileTimestamp(const char *path) {
|
|
||||||
static char timeStr[60];
|
|
||||||
u64 mtime = 0;
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(archive_getmtime(path, &mtime))) {
|
|
||||||
time_t mt = mtime;
|
|
||||||
struct tm *timeStruct = gmtime(&mt);
|
|
||||||
|
|
||||||
int hours = timeStruct->tm_hour;
|
|
||||||
int minutes = timeStruct->tm_min;
|
|
||||||
|
|
||||||
int day = timeStruct->tm_mday;
|
|
||||||
int month = timeStruct->tm_mon + 1; // January being 0
|
|
||||||
int year = timeStruct->tm_year + 1900;
|
|
||||||
|
|
||||||
snprintf(timeStr, 60, "%d/%d/%d %2i:%02i", year, month, day, hours, minutes);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return timeStr;
|
|
||||||
}
|
|
30
external/fs.h
vendored
30
external/fs.h
vendored
@ -1,30 +0,0 @@
|
|||||||
#ifndef _3D_SHELL_FS_H
|
|
||||||
#define _3D_SHELL_FS_H
|
|
||||||
|
|
||||||
#include <3ds.h>
|
|
||||||
|
|
||||||
extern FS_Archive archive, sdmc_archive, nand_archive;
|
|
||||||
|
|
||||||
Result FS_OpenArchive(FS_Archive *archive, FS_ArchiveID id);
|
|
||||||
Result FS_CloseArchive(FS_Archive archive);
|
|
||||||
Result FS_OpenDir(Handle *handle, FS_Archive archive, const char *path);
|
|
||||||
Result FS_OpenFile(Handle *handle, FS_Archive archive, const char *path, u32 flags, u32 attributes);
|
|
||||||
Result FS_MakeDir(FS_Archive archive, const char *path);
|
|
||||||
Result FS_CreateFile(FS_Archive archive, const char *path, u64 size);
|
|
||||||
Result FS_RecursiveMakeDir(FS_Archive archive, const char *path);
|
|
||||||
bool FS_FileExists(FS_Archive archive, const char *path);
|
|
||||||
bool FS_DirExists(FS_Archive archive, const char *path);
|
|
||||||
Result FS_GetFileSize(FS_Archive archive, const char *path, u64 *size);
|
|
||||||
u64 FS_GetFreeStorage(FS_SystemMediaType media_type);
|
|
||||||
u64 FS_GetTotalStorage(FS_SystemMediaType media_type);
|
|
||||||
u64 FS_GetUsedStorage(FS_SystemMediaType media_type);
|
|
||||||
Result FS_RemoveFile(FS_Archive archive, const char *path);
|
|
||||||
Result FS_RemoveDir(FS_Archive archive, const char *path);
|
|
||||||
Result FS_RemoveDirRecursive(FS_Archive archive, const char *path);
|
|
||||||
Result FS_RenameFile(FS_Archive archive, const char *old_filename, const char *new_filename);
|
|
||||||
Result FS_RenameDir(FS_Archive archive, const char *old_dirname, const char *new_dirname);
|
|
||||||
Result FS_Read(FS_Archive archive, const char *path, u64 size, void *buf);
|
|
||||||
Result FS_Write(FS_Archive archive, const char *path, const void *buf, u32 size);
|
|
||||||
char *FS_GetFileTimestamp(const char *path);
|
|
||||||
|
|
||||||
#endif
|
|
25447
external/json.hpp
vendored
25447
external/json.hpp
vendored
File diff suppressed because it is too large
Load Diff
6464
external/lodepng.cpp
vendored
6464
external/lodepng.cpp
vendored
File diff suppressed because it is too large
Load Diff
1977
external/lodepng.h
vendored
1977
external/lodepng.h
vendored
File diff suppressed because it is too large
Load Diff
@ -1 +0,0 @@
|
|||||||
External Librarys
|
|
@ -1,20 +0,0 @@
|
|||||||
#include "Clock.hpp"
|
|
||||||
|
|
||||||
namespace rnd7 {
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time Clock::getElapsedTime() const {
|
|
||||||
return getCurrentTime() - m_startTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time Clock::restart() {
|
|
||||||
Time now = getCurrentTime();
|
|
||||||
Time elapsed = now - m_startTime;
|
|
||||||
m_startTime = now;
|
|
||||||
|
|
||||||
return elapsed;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
#include <Time.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
namespace rnd7 {
|
|
||||||
class Clock {
|
|
||||||
public:
|
|
||||||
Clock() {};
|
|
||||||
|
|
||||||
virtual ~Clock() {};
|
|
||||||
|
|
||||||
|
|
||||||
virtual Time getCurrentTime() const { return Time{}; };
|
|
||||||
|
|
||||||
Time getElapsedTime() const;
|
|
||||||
|
|
||||||
Time restart();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
Time m_startTime; ///< Time of last reset, in microseconds
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
@ -1,200 +0,0 @@
|
|||||||
#include "Time.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
namespace rnd7 {
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
const Time Time::Zero_;
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time::Time() :
|
|
||||||
m_microseconds(0) {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
float Time::asSeconds() const {
|
|
||||||
return m_microseconds / 1000000.f;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
int Time::asMilliseconds() const {
|
|
||||||
return static_cast<int>(m_microseconds / 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
long Time::asMicroseconds() const {
|
|
||||||
return m_microseconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time::Time(long microseconds) :
|
|
||||||
m_microseconds(microseconds) {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time seconds(float amount) {
|
|
||||||
return Time(static_cast<long>(amount * 1000000));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time milliseconds(int amount) {
|
|
||||||
return Time(static_cast<long>(amount) * 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time microseconds(long amount) {
|
|
||||||
return Time(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
bool operator==(Time left, Time right) {
|
|
||||||
return left.asMicroseconds() == right.asMicroseconds();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
bool operator!=(Time left, Time right) {
|
|
||||||
return left.asMicroseconds() != right.asMicroseconds();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
bool operator<(Time left, Time right) {
|
|
||||||
return left.asMicroseconds() < right.asMicroseconds();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
bool operator>(Time left, Time right) {
|
|
||||||
return left.asMicroseconds() > right.asMicroseconds();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
bool operator<=(Time left, Time right) {
|
|
||||||
return left.asMicroseconds() <= right.asMicroseconds();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
bool operator>=(Time left, Time right) {
|
|
||||||
return left.asMicroseconds() >= right.asMicroseconds();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time operator-(Time right) {
|
|
||||||
return microseconds(-right.asMicroseconds());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time operator+(Time left, Time right) {
|
|
||||||
return microseconds(left.asMicroseconds() + right.asMicroseconds());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time &operator+=(Time &left, Time right) {
|
|
||||||
return left = left + right;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time operator-(Time left, Time right) {
|
|
||||||
return microseconds(left.asMicroseconds() - right.asMicroseconds());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time &operator-=(Time &left, Time right) {
|
|
||||||
return left = left - right;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time operator*(Time left, float right) {
|
|
||||||
return seconds(left.asSeconds() * right);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time operator*(Time left, long right) {
|
|
||||||
return microseconds(left.asMicroseconds() * right);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time operator*(float left, Time right) {
|
|
||||||
return right * left;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time operator*(long left, Time right) {
|
|
||||||
return right * left;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time &operator*=(Time &left, float right) {
|
|
||||||
return left = left * right;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time &operator*=(Time &left, long right) {
|
|
||||||
return left = left * right;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time operator/(Time left, float right) {
|
|
||||||
return seconds(left.asSeconds() / right);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time operator/(Time left, long right) {
|
|
||||||
return microseconds(left.asMicroseconds() / right);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time &operator/=(Time &left, float right) {
|
|
||||||
return left = left / right;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time &operator/=(Time &left, long right) {
|
|
||||||
return left = left / right;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
float operator/(Time left, Time right) {
|
|
||||||
return left.asSeconds() / right.asSeconds();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time operator%(Time left, Time right) {
|
|
||||||
return microseconds(left.asMicroseconds() % right.asMicroseconds());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
Time &operator%=(Time &left, Time right) {
|
|
||||||
return left = left % right;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,82 +0,0 @@
|
|||||||
namespace rnd7 {
|
|
||||||
class Time {
|
|
||||||
public:
|
|
||||||
|
|
||||||
Time();
|
|
||||||
|
|
||||||
float asSeconds() const;
|
|
||||||
|
|
||||||
int asMilliseconds() const;
|
|
||||||
|
|
||||||
long asMicroseconds() const;
|
|
||||||
|
|
||||||
static const Time Zero_;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
friend Time seconds(float);
|
|
||||||
|
|
||||||
friend Time milliseconds(int);
|
|
||||||
|
|
||||||
friend Time microseconds(long);
|
|
||||||
|
|
||||||
explicit Time(long microseconds);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
long m_microseconds; ///< Time value stored as microseconds
|
|
||||||
};
|
|
||||||
|
|
||||||
Time seconds(float amount);
|
|
||||||
|
|
||||||
Time milliseconds(int amount);
|
|
||||||
|
|
||||||
Time microseconds(long amount);
|
|
||||||
|
|
||||||
bool operator==(Time left, Time right);
|
|
||||||
|
|
||||||
bool operator!=(Time left, Time right);
|
|
||||||
|
|
||||||
bool operator<(Time left, Time right);
|
|
||||||
|
|
||||||
bool operator>(Time left, Time right);
|
|
||||||
bool operator<=(Time left, Time right);
|
|
||||||
|
|
||||||
bool operator>=(Time left, Time right);
|
|
||||||
|
|
||||||
Time operator-(Time right);
|
|
||||||
Time operator+(Time left, Time right);
|
|
||||||
|
|
||||||
Time &operator+=(Time &left, Time right);
|
|
||||||
|
|
||||||
Time operator-(Time left, Time right);
|
|
||||||
|
|
||||||
Time &operator-=(Time &left, Time right);
|
|
||||||
|
|
||||||
Time operator*(Time left, float right);
|
|
||||||
|
|
||||||
Time operator*(Time left, long right);
|
|
||||||
|
|
||||||
Time operator*(float left, Time right);
|
|
||||||
|
|
||||||
Time operator*(long left, Time right);
|
|
||||||
|
|
||||||
Time &operator*=(Time &left, float right);
|
|
||||||
|
|
||||||
Time &operator*=(Time &left, long right);
|
|
||||||
|
|
||||||
Time operator/(Time left, float right);
|
|
||||||
|
|
||||||
Time operator/(Time left, long right);
|
|
||||||
|
|
||||||
Time &operator/=(Time &left, float right);
|
|
||||||
|
|
||||||
Time &operator/=(Time &left, long right);
|
|
||||||
|
|
||||||
float operator/(Time left, Time right);
|
|
||||||
|
|
||||||
Time operator%(Time left, Time right);
|
|
||||||
|
|
||||||
Time &operator%=(Time &left, Time right);
|
|
||||||
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <3ds.h>
|
|
||||||
#include <citro2d.h>
|
|
||||||
#include <citro3d.h>
|
|
||||||
#include <memory>
|
|
||||||
#include <stack>
|
|
||||||
#include <string>
|
|
||||||
#include <functional>
|
|
||||||
#include <vector>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <cstring>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include <codecvt>
|
|
||||||
#include <map>
|
|
||||||
#include "lang.hpp"
|
|
||||||
#include "parameter.hpp"
|
|
||||||
#include "thread.hpp"
|
|
||||||
#include "ini.hpp"
|
|
||||||
#include "stringtool.hpp"
|
|
||||||
|
|
||||||
enum EngineType
|
|
||||||
{
|
|
||||||
_2D,
|
|
||||||
_3D
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace Npi
|
|
||||||
class Game {
|
|
||||||
public:
|
|
||||||
Game(EngineType, std::string name);
|
|
||||||
~Game(){}
|
|
||||||
private:
|
|
||||||
std::string g_name;
|
|
||||||
EngineType g_etype;
|
|
||||||
};
|
|
||||||
}
|
|
679
internal/ini.hpp
679
internal/ini.hpp
@ -1,679 +0,0 @@
|
|||||||
#ifndef INI_INI_H_
|
|
||||||
#define INI_INI_H_
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <sstream>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <utility>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <vector>
|
|
||||||
#include <memory>
|
|
||||||
#include <fstream>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <cctype>
|
|
||||||
|
|
||||||
namespace INI
|
|
||||||
{
|
|
||||||
namespace INIStringUtil
|
|
||||||
{
|
|
||||||
const char* const whitespaceDelimiters = " \t\n\r\f\v";
|
|
||||||
inline void trim(std::string& str)
|
|
||||||
{
|
|
||||||
str.erase(str.find_last_not_of(whitespaceDelimiters) + 1);
|
|
||||||
str.erase(0, str.find_first_not_of(whitespaceDelimiters));
|
|
||||||
}
|
|
||||||
#ifndef INI_CASE_SENSITIVE
|
|
||||||
inline void toLower(std::string& str)
|
|
||||||
{
|
|
||||||
std::transform(str.begin(), str.end(), str.begin(), [](const char c) {
|
|
||||||
return static_cast<const char>(std::tolower(c));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
inline void replace(std::string& str, std::string const& a, std::string const& b)
|
|
||||||
{
|
|
||||||
if (!a.empty())
|
|
||||||
{
|
|
||||||
std::size_t pos = 0;
|
|
||||||
while ((pos = str.find(a, pos)) != std::string::npos)
|
|
||||||
{
|
|
||||||
str.replace(pos, a.size(), b);
|
|
||||||
pos += b.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef _WIN32
|
|
||||||
const char* const endl = "\r\n";
|
|
||||||
#else
|
|
||||||
const char* const endl = "\n";
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
class INIMap
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
using T_DataIndexMap = std::unordered_map<std::string, std::size_t>;
|
|
||||||
using T_DataItem = std::pair<std::string, T>;
|
|
||||||
using T_DataContainer = std::vector<T_DataItem>;
|
|
||||||
using T_MultiArgs = typename std::vector<std::pair<std::string, T>>;
|
|
||||||
|
|
||||||
T_DataIndexMap dataIndexMap;
|
|
||||||
T_DataContainer data;
|
|
||||||
|
|
||||||
inline std::size_t setEmpty(std::string& key)
|
|
||||||
{
|
|
||||||
std::size_t index = data.size();
|
|
||||||
dataIndexMap[key] = index;
|
|
||||||
data.emplace_back(key, T());
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
using const_iterator = typename T_DataContainer::const_iterator;
|
|
||||||
|
|
||||||
INIMap() { }
|
|
||||||
|
|
||||||
INIMap(INIMap const& other)
|
|
||||||
{
|
|
||||||
std::size_t data_size = other.data.size();
|
|
||||||
for (std::size_t i = 0; i < data_size; ++i)
|
|
||||||
{
|
|
||||||
auto const& key = other.data[i].first;
|
|
||||||
auto const& obj = other.data[i].second;
|
|
||||||
data.emplace_back(key, obj);
|
|
||||||
}
|
|
||||||
dataIndexMap = T_DataIndexMap(other.dataIndexMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
T& operator[](std::string key)
|
|
||||||
{
|
|
||||||
INIStringUtil::trim(key);
|
|
||||||
#ifndef INI_CASE_SENSITIVE
|
|
||||||
INIStringUtil::toLower(key);
|
|
||||||
#endif
|
|
||||||
auto it = dataIndexMap.find(key);
|
|
||||||
bool hasIt = (it != dataIndexMap.end());
|
|
||||||
std::size_t index = (hasIt) ? it->second : setEmpty(key);
|
|
||||||
return data[index].second;
|
|
||||||
}
|
|
||||||
T get(std::string key) const
|
|
||||||
{
|
|
||||||
INIStringUtil::trim(key);
|
|
||||||
#ifndef INI_CASE_SENSITIVE
|
|
||||||
INIStringUtil::toLower(key);
|
|
||||||
#endif
|
|
||||||
auto it = dataIndexMap.find(key);
|
|
||||||
if (it == dataIndexMap.end())
|
|
||||||
{
|
|
||||||
return T();
|
|
||||||
}
|
|
||||||
return T(data[it->second].second);
|
|
||||||
}
|
|
||||||
bool has(std::string key) const
|
|
||||||
{
|
|
||||||
INIStringUtil::trim(key);
|
|
||||||
#ifndef INI_CASE_SENSITIVE
|
|
||||||
INIStringUtil::toLower(key);
|
|
||||||
#endif
|
|
||||||
return (dataIndexMap.count(key) == 1);
|
|
||||||
}
|
|
||||||
void set(std::string key, T obj)
|
|
||||||
{
|
|
||||||
INIStringUtil::trim(key);
|
|
||||||
#ifndef INI_CASE_SENSITIVE
|
|
||||||
INIStringUtil::toLower(key);
|
|
||||||
#endif
|
|
||||||
auto it = dataIndexMap.find(key);
|
|
||||||
if (it != dataIndexMap.end())
|
|
||||||
{
|
|
||||||
data[it->second].second = obj;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dataIndexMap[key] = data.size();
|
|
||||||
data.emplace_back(key, obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void set(T_MultiArgs const& multiArgs)
|
|
||||||
{
|
|
||||||
for (auto const& it : multiArgs)
|
|
||||||
{
|
|
||||||
auto const& key = it.first;
|
|
||||||
auto const& obj = it.second;
|
|
||||||
set(key, obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool remove(std::string key)
|
|
||||||
{
|
|
||||||
INIStringUtil::trim(key);
|
|
||||||
#ifndef INI_CASE_SENSITIVE
|
|
||||||
INIStringUtil::toLower(key);
|
|
||||||
#endif
|
|
||||||
auto it = dataIndexMap.find(key);
|
|
||||||
if (it != dataIndexMap.end())
|
|
||||||
{
|
|
||||||
std::size_t index = it->second;
|
|
||||||
data.erase(data.begin() + index);
|
|
||||||
dataIndexMap.erase(it);
|
|
||||||
for (auto& it2 : dataIndexMap)
|
|
||||||
{
|
|
||||||
auto& vi = it2.second;
|
|
||||||
if (vi > index)
|
|
||||||
{
|
|
||||||
vi--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
void clear()
|
|
||||||
{
|
|
||||||
data.clear();
|
|
||||||
dataIndexMap.clear();
|
|
||||||
}
|
|
||||||
std::size_t size() const
|
|
||||||
{
|
|
||||||
return data.size();
|
|
||||||
}
|
|
||||||
const_iterator begin() const { return data.begin(); }
|
|
||||||
const_iterator end() const { return data.end(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
using INIStructure = INIMap<INIMap<std::string>>;
|
|
||||||
|
|
||||||
namespace INIParser
|
|
||||||
{
|
|
||||||
using T_ParseValues = std::pair<std::string, std::string>;
|
|
||||||
|
|
||||||
enum class PDataType : char
|
|
||||||
{
|
|
||||||
PDATA_NONE,
|
|
||||||
PDATA_COMMENT,
|
|
||||||
PDATA_SECTION,
|
|
||||||
PDATA_KEYVALUE,
|
|
||||||
PDATA_UNKNOWN
|
|
||||||
};
|
|
||||||
|
|
||||||
inline PDataType parseLine(std::string line, T_ParseValues& parseData)
|
|
||||||
{
|
|
||||||
parseData.first.clear();
|
|
||||||
parseData.second.clear();
|
|
||||||
INIStringUtil::trim(line);
|
|
||||||
if (line.empty())
|
|
||||||
{
|
|
||||||
return PDataType::PDATA_NONE;
|
|
||||||
}
|
|
||||||
char firstCharacter = line[0];
|
|
||||||
if (firstCharacter == ';')
|
|
||||||
{
|
|
||||||
return PDataType::PDATA_COMMENT;
|
|
||||||
}
|
|
||||||
if (firstCharacter == '[')
|
|
||||||
{
|
|
||||||
auto commentAt = line.find_first_of(';');
|
|
||||||
if (commentAt != std::string::npos)
|
|
||||||
{
|
|
||||||
line = line.substr(0, commentAt);
|
|
||||||
}
|
|
||||||
auto closingBracketAt = line.find_last_of(']');
|
|
||||||
if (closingBracketAt != std::string::npos)
|
|
||||||
{
|
|
||||||
auto section = line.substr(1, closingBracketAt - 1);
|
|
||||||
INIStringUtil::trim(section);
|
|
||||||
parseData.first = section;
|
|
||||||
return PDataType::PDATA_SECTION;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
auto lineNorm = line;
|
|
||||||
INIStringUtil::replace(lineNorm, "\\=", " ");
|
|
||||||
auto equalsAt = lineNorm.find_first_of('=');
|
|
||||||
if (equalsAt != std::string::npos)
|
|
||||||
{
|
|
||||||
auto key = line.substr(0, equalsAt);
|
|
||||||
INIStringUtil::trim(key);
|
|
||||||
INIStringUtil::replace(key, "\\=", "=");
|
|
||||||
auto value = line.substr(equalsAt + 1);
|
|
||||||
INIStringUtil::trim(value);
|
|
||||||
parseData.first = key;
|
|
||||||
parseData.second = value;
|
|
||||||
return PDataType::PDATA_KEYVALUE;
|
|
||||||
}
|
|
||||||
return PDataType::PDATA_UNKNOWN;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class INIReader
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using T_LineData = std::vector<std::string>;
|
|
||||||
using T_LineDataPtr = std::shared_ptr<T_LineData>;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::ifstream fileReadStream;
|
|
||||||
T_LineDataPtr lineData;
|
|
||||||
|
|
||||||
T_LineData readFile()
|
|
||||||
{
|
|
||||||
std::string fileContents;
|
|
||||||
fileReadStream.seekg(0, std::ios::end);
|
|
||||||
fileContents.resize(fileReadStream.tellg());
|
|
||||||
fileReadStream.seekg(0, std::ios::beg);
|
|
||||||
std::size_t fileSize = fileContents.size();
|
|
||||||
fileReadStream.read(&fileContents[0], fileSize);
|
|
||||||
fileReadStream.close();
|
|
||||||
T_LineData output;
|
|
||||||
if (fileSize == 0)
|
|
||||||
{
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
std::string buffer;
|
|
||||||
buffer.reserve(50);
|
|
||||||
for (std::size_t i = 0; i < fileSize; ++i)
|
|
||||||
{
|
|
||||||
char& c = fileContents[i];
|
|
||||||
if (c == '\n')
|
|
||||||
{
|
|
||||||
output.emplace_back(buffer);
|
|
||||||
buffer.clear();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (c != '\0' && c != '\r')
|
|
||||||
{
|
|
||||||
buffer += c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
output.emplace_back(buffer);
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
INIReader(std::string const& filename, bool keepLineData = false)
|
|
||||||
{
|
|
||||||
fileReadStream.open(filename, std::ios::in | std::ios::binary);
|
|
||||||
if (keepLineData)
|
|
||||||
{
|
|
||||||
lineData = std::make_shared<T_LineData>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
~INIReader() { }
|
|
||||||
|
|
||||||
bool operator>>(INIStructure& data)
|
|
||||||
{
|
|
||||||
if (!fileReadStream.is_open())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
T_LineData fileLines = readFile();
|
|
||||||
std::string section;
|
|
||||||
bool inSection = false;
|
|
||||||
INIParser::T_ParseValues parseData;
|
|
||||||
for (auto const& line : fileLines)
|
|
||||||
{
|
|
||||||
auto parseResult = INIParser::parseLine(line, parseData);
|
|
||||||
if (parseResult == INIParser::PDataType::PDATA_SECTION)
|
|
||||||
{
|
|
||||||
inSection = true;
|
|
||||||
data[section = parseData.first];
|
|
||||||
}
|
|
||||||
else if (inSection && parseResult == INIParser::PDataType::PDATA_KEYVALUE)
|
|
||||||
{
|
|
||||||
auto const& key = parseData.first;
|
|
||||||
auto const& value = parseData.second;
|
|
||||||
data[section][key] = value;
|
|
||||||
}
|
|
||||||
if (lineData && parseResult != INIParser::PDataType::PDATA_UNKNOWN)
|
|
||||||
{
|
|
||||||
if (parseResult == INIParser::PDataType::PDATA_KEYVALUE && !inSection)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
lineData->emplace_back(line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
T_LineDataPtr getLines()
|
|
||||||
{
|
|
||||||
return lineData;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class INIGenerator
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::ofstream fileWriteStream;
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool prettyPrint = false;
|
|
||||||
|
|
||||||
INIGenerator(std::string const& filename)
|
|
||||||
{
|
|
||||||
fileWriteStream.open(filename, std::ios::out | std::ios::binary);
|
|
||||||
}
|
|
||||||
~INIGenerator() { }
|
|
||||||
|
|
||||||
bool operator<<(INIStructure const& data)
|
|
||||||
{
|
|
||||||
if (!fileWriteStream.is_open())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!data.size())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
auto it = data.begin();
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
auto const& section = it->first;
|
|
||||||
auto const& collection = it->second;
|
|
||||||
fileWriteStream
|
|
||||||
<< "["
|
|
||||||
<< section
|
|
||||||
<< "]";
|
|
||||||
if (collection.size())
|
|
||||||
{
|
|
||||||
fileWriteStream << INIStringUtil::endl;
|
|
||||||
auto it2 = collection.begin();
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
auto key = it2->first;
|
|
||||||
INIStringUtil::replace(key, "=", "\\=");
|
|
||||||
auto value = it2->second;
|
|
||||||
INIStringUtil::trim(value);
|
|
||||||
fileWriteStream
|
|
||||||
<< key
|
|
||||||
<< ((prettyPrint) ? " = " : "=")
|
|
||||||
<< value;
|
|
||||||
if (++it2 == collection.end())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
fileWriteStream << INIStringUtil::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (++it == data.end())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
fileWriteStream << INIStringUtil::endl;
|
|
||||||
if (prettyPrint)
|
|
||||||
{
|
|
||||||
fileWriteStream << INIStringUtil::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class INIWriter
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
using T_LineData = std::vector<std::string>;
|
|
||||||
using T_LineDataPtr = std::shared_ptr<T_LineData>;
|
|
||||||
|
|
||||||
std::string filename;
|
|
||||||
|
|
||||||
T_LineData getLazyOutput(T_LineDataPtr const& lineData, INIStructure& data, INIStructure& original)
|
|
||||||
{
|
|
||||||
T_LineData output;
|
|
||||||
INIParser::T_ParseValues parseData;
|
|
||||||
std::string sectionCurrent;
|
|
||||||
bool parsingSection = false;
|
|
||||||
bool continueToNextSection = false;
|
|
||||||
bool discardNextEmpty = false;
|
|
||||||
bool writeNewKeys = false;
|
|
||||||
std::size_t lastKeyLine = 0;
|
|
||||||
for (auto line = lineData->begin(); line != lineData->end(); ++line)
|
|
||||||
{
|
|
||||||
if (!writeNewKeys)
|
|
||||||
{
|
|
||||||
auto parseResult = INIParser::parseLine(*line, parseData);
|
|
||||||
if (parseResult == INIParser::PDataType::PDATA_SECTION)
|
|
||||||
{
|
|
||||||
if (parsingSection)
|
|
||||||
{
|
|
||||||
writeNewKeys = true;
|
|
||||||
parsingSection = false;
|
|
||||||
--line;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
sectionCurrent = parseData.first;
|
|
||||||
if (data.has(sectionCurrent))
|
|
||||||
{
|
|
||||||
parsingSection = true;
|
|
||||||
continueToNextSection = false;
|
|
||||||
discardNextEmpty = false;
|
|
||||||
output.emplace_back(*line);
|
|
||||||
lastKeyLine = output.size();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
continueToNextSection = true;
|
|
||||||
discardNextEmpty = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (parseResult == INIParser::PDataType::PDATA_KEYVALUE)
|
|
||||||
{
|
|
||||||
if (continueToNextSection)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (data.has(sectionCurrent))
|
|
||||||
{
|
|
||||||
auto& collection = data[sectionCurrent];
|
|
||||||
auto const& key = parseData.first;
|
|
||||||
auto const& value = parseData.second;
|
|
||||||
if (collection.has(key))
|
|
||||||
{
|
|
||||||
auto outputValue = collection[key];
|
|
||||||
if (value == outputValue)
|
|
||||||
{
|
|
||||||
output.emplace_back(*line);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
INIStringUtil::trim(outputValue);
|
|
||||||
auto lineNorm = *line;
|
|
||||||
INIStringUtil::replace(lineNorm, "\\=", " ");
|
|
||||||
auto equalsAt = lineNorm.find_first_of('=');
|
|
||||||
auto valueAt = lineNorm.find_first_not_of(
|
|
||||||
INIStringUtil::whitespaceDelimiters,
|
|
||||||
equalsAt + 1
|
|
||||||
);
|
|
||||||
std::string outputLine = line->substr(0, valueAt);
|
|
||||||
if (prettyPrint && equalsAt + 1 == valueAt)
|
|
||||||
{
|
|
||||||
outputLine += " ";
|
|
||||||
}
|
|
||||||
outputLine += outputValue;
|
|
||||||
output.emplace_back(outputLine);
|
|
||||||
}
|
|
||||||
lastKeyLine = output.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (discardNextEmpty && line->empty())
|
|
||||||
{
|
|
||||||
discardNextEmpty = false;
|
|
||||||
}
|
|
||||||
else if (parseResult != INIParser::PDataType::PDATA_UNKNOWN)
|
|
||||||
{
|
|
||||||
output.emplace_back(*line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (writeNewKeys || std::next(line) == lineData->end())
|
|
||||||
{
|
|
||||||
T_LineData linesToAdd;
|
|
||||||
if (data.has(sectionCurrent) && original.has(sectionCurrent))
|
|
||||||
{
|
|
||||||
auto const& collection = data[sectionCurrent];
|
|
||||||
auto const& collectionOriginal = original[sectionCurrent];
|
|
||||||
for (auto const& it : collection)
|
|
||||||
{
|
|
||||||
auto key = it.first;
|
|
||||||
if (collectionOriginal.has(key))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
auto value = it.second;
|
|
||||||
INIStringUtil::replace(key, "=", "\\=");
|
|
||||||
INIStringUtil::trim(value);
|
|
||||||
linesToAdd.emplace_back(
|
|
||||||
key + ((prettyPrint) ? " = " : "=") + value
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!linesToAdd.empty())
|
|
||||||
{
|
|
||||||
output.insert(
|
|
||||||
output.begin() + lastKeyLine,
|
|
||||||
linesToAdd.begin(),
|
|
||||||
linesToAdd.end()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (writeNewKeys)
|
|
||||||
{
|
|
||||||
writeNewKeys = false;
|
|
||||||
--line;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto const& it : data)
|
|
||||||
{
|
|
||||||
auto const& section = it.first;
|
|
||||||
if (original.has(section))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (prettyPrint && output.size() > 0 && !output.back().empty())
|
|
||||||
{
|
|
||||||
output.emplace_back();
|
|
||||||
}
|
|
||||||
output.emplace_back("[" + section + "]");
|
|
||||||
auto const& collection = it.second;
|
|
||||||
for (auto const& it2 : collection)
|
|
||||||
{
|
|
||||||
auto key = it2.first;
|
|
||||||
auto value = it2.second;
|
|
||||||
INIStringUtil::replace(key, "=", "\\=");
|
|
||||||
INIStringUtil::trim(value);
|
|
||||||
output.emplace_back(
|
|
||||||
key + ((prettyPrint) ? " = " : "=") + value
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool prettyPrint = false;
|
|
||||||
|
|
||||||
INIWriter(std::string const& filename)
|
|
||||||
: filename(filename)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
~INIWriter() { }
|
|
||||||
|
|
||||||
bool operator<<(INIStructure& data)
|
|
||||||
{
|
|
||||||
struct stat buf;
|
|
||||||
bool fileExists = (stat(filename.c_str(), &buf) == 0);
|
|
||||||
if (!fileExists)
|
|
||||||
{
|
|
||||||
INIGenerator generator(filename);
|
|
||||||
generator.prettyPrint = prettyPrint;
|
|
||||||
return generator << data;
|
|
||||||
}
|
|
||||||
INIStructure originalData;
|
|
||||||
T_LineDataPtr lineData;
|
|
||||||
bool readSuccess = false;
|
|
||||||
{
|
|
||||||
INIReader reader(filename, true);
|
|
||||||
if ((readSuccess = reader >> originalData))
|
|
||||||
{
|
|
||||||
lineData = reader.getLines();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!readSuccess)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
T_LineData output = getLazyOutput(lineData, data, originalData);
|
|
||||||
std::ofstream fileWriteStream(filename, std::ios::out | std::ios::binary);
|
|
||||||
if (fileWriteStream.is_open())
|
|
||||||
{
|
|
||||||
if (output.size())
|
|
||||||
{
|
|
||||||
auto line = output.begin();
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
fileWriteStream << *line;
|
|
||||||
if (++line == output.end())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
fileWriteStream << INIStringUtil::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class INIFile
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
std::string filename;
|
|
||||||
|
|
||||||
public:
|
|
||||||
INIFile(std::string const& filename)
|
|
||||||
: filename(filename)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
~INIFile() { }
|
|
||||||
|
|
||||||
bool read(INIStructure& data) const
|
|
||||||
{
|
|
||||||
if (data.size())
|
|
||||||
{
|
|
||||||
data.clear();
|
|
||||||
}
|
|
||||||
if (filename.empty())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
INIReader reader(filename);
|
|
||||||
return reader >> data;
|
|
||||||
}
|
|
||||||
bool generate(INIStructure const& data, bool pretty = false) const
|
|
||||||
{
|
|
||||||
if (filename.empty())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
INIGenerator generator(filename);
|
|
||||||
generator.prettyPrint = pretty;
|
|
||||||
return generator << data;
|
|
||||||
}
|
|
||||||
bool write(INIStructure& data, bool pretty = false) const
|
|
||||||
{
|
|
||||||
if (filename.empty())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
INIWriter writer(filename);
|
|
||||||
writer.prettyPrint = pretty;
|
|
||||||
return writer << data;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,98 +0,0 @@
|
|||||||
#include "lang.hpp"
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <3ds.h>
|
|
||||||
static nlohmann::json appJson;
|
|
||||||
|
|
||||||
std::string RenderD7::Lang::getSys()
|
|
||||||
{
|
|
||||||
|
|
||||||
u8 language = 1;
|
|
||||||
CFGU_GetSystemLanguage(&language);
|
|
||||||
|
|
||||||
switch(language) {
|
|
||||||
case 0:
|
|
||||||
return "jp"; // Japanese
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
return "en"; // English
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
return "fr"; // French
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
return "de"; // German
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
return "it"; // Italian
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
return "es"; // Spanish
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
return "zh-CN"; // Chinese (Simplified)
|
|
||||||
break;
|
|
||||||
|
|
||||||
// case 7:
|
|
||||||
// return "ko"; // Korean
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case 8:
|
|
||||||
// return "nl"; // Dutch
|
|
||||||
// break;
|
|
||||||
|
|
||||||
case 9:
|
|
||||||
return "pt"; // Portuguese
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 10:
|
|
||||||
return "ru"; // Russian
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 11:
|
|
||||||
return "zh-TW"; // Chinese (Traditional)
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return "en"; // Fall back to English if missing
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
std::string RenderD7::Lang::get(const std::string &key) {
|
|
||||||
if (!appJson.contains(key)) return key;
|
|
||||||
|
|
||||||
return appJson.at(key).get_ref<const std::string&>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::Lang::load(const std::string &lang) {
|
|
||||||
FILE *values;
|
|
||||||
|
|
||||||
if (access(("romfs:/lang/" + lang + "/app.json").c_str(), F_OK) == 0) {
|
|
||||||
values = fopen(("romfs:/lang/" + lang + "/app.json").c_str(), "rt");
|
|
||||||
if (values) {
|
|
||||||
appJson = nlohmann::json::parse(values, nullptr, false);
|
|
||||||
fclose(values);
|
|
||||||
}
|
|
||||||
if (appJson.is_discarded())
|
|
||||||
appJson = { };
|
|
||||||
return;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
values = fopen("romfs:/lang/en/app.json", "rt");
|
|
||||||
if (values) {
|
|
||||||
appJson = nlohmann::json::parse(values, nullptr, false);
|
|
||||||
fclose(values);
|
|
||||||
}
|
|
||||||
if (appJson.is_discarded())
|
|
||||||
appJson = { };
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <string>
|
|
||||||
#include "json.hpp"
|
|
||||||
|
|
||||||
/// RenderD7::Lang
|
|
||||||
namespace RenderD7::Lang
|
|
||||||
{
|
|
||||||
/// Get the 3ds System Language
|
|
||||||
std::string getSys();
|
|
||||||
/// Get a translated string
|
|
||||||
/// key: The Key so the code can find your string
|
|
||||||
std::string get(const std::string &key);
|
|
||||||
/// Load the lang file from dir structure en/app.json for sample
|
|
||||||
/// lang: the folder name en, fr, de ... . I prefer geSys()
|
|
||||||
void load(const std::string &lang);
|
|
||||||
} /// RenderD7::Lang
|
|
@ -1,112 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <tuple>
|
|
||||||
|
|
||||||
namespace RenderD7{
|
|
||||||
class Parameter
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
using id = size_t;
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct type { static void id() { } };
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
static id type_id() { return reinterpret_cast<id>(&type<T>::id); }
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
using decay = typename std::decay<T>::type;
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
using none = typename std::enable_if<!std::is_same<Parameter, T>::value>::type;
|
|
||||||
|
|
||||||
struct base
|
|
||||||
{
|
|
||||||
virtual ~base() { }
|
|
||||||
virtual bool is(id) const = 0;
|
|
||||||
virtual base *copy() const = 0;
|
|
||||||
} *p = nullptr;
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct data : base, std::tuple<T>
|
|
||||||
{
|
|
||||||
using std::tuple<T>::tuple;
|
|
||||||
|
|
||||||
T &get() & { return std::get<0>(*this); }
|
|
||||||
T const &get() const& { return std::get<0>(*this); }
|
|
||||||
|
|
||||||
bool is(id i) const override { return i == type_id<T>(); }
|
|
||||||
base *copy() const override { return new data{get()}; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T &stat() { return static_cast<data<T>&>(*p).get(); }
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T const &stat() const { return static_cast<data<T> const&>(*p).get(); }
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T &dyn() { return dynamic_cast<data<T>&>(*p).get(); }
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T const &dyn() const { return dynamic_cast<data<T> const&>(*p).get(); }
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Default constructor
|
|
||||||
*/
|
|
||||||
Parameter() { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Destructs the Parameter
|
|
||||||
*/
|
|
||||||
~Parameter() { delete p; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Copy constructor
|
|
||||||
* @param s The Parameter to copy
|
|
||||||
*/
|
|
||||||
Parameter(Parameter &&s) : p{s.p} { s.p = nullptr; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Const copy constructor
|
|
||||||
* @param s The Parameter to copy
|
|
||||||
*/
|
|
||||||
Parameter(Parameter const &s) : p{s.p->copy()} { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initializes the Parameter with the given value
|
|
||||||
* @param x The value to initialize the Parameter with
|
|
||||||
*/
|
|
||||||
template<typename T, typename U = decay<T>, typename = none<U>>
|
|
||||||
Parameter(T &&x) : p{new data<U>{std::forward<T>(x)}} { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Overloads the assignment operator
|
|
||||||
* @param s The value to set the Parameter to
|
|
||||||
*/
|
|
||||||
Parameter &operator=(Parameter s) { swap(*this, s); return *this; }
|
|
||||||
|
|
||||||
friend void swap(Parameter &s, Parameter &r) { std::swap(s.p, r.p); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Clears the Parameter
|
|
||||||
*/
|
|
||||||
void clear() { delete p; p = nullptr; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Checks whether the Parameter is the given type
|
|
||||||
* @tparam T The type to check
|
|
||||||
* @return Whether the Parameter has the given type or not
|
|
||||||
*/
|
|
||||||
template<typename T>
|
|
||||||
bool is() const { return p ? p->is(type_id<T>()) : false; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the value of the Parameter
|
|
||||||
* @tparam T The type of the Parameter
|
|
||||||
* @return The value of the Parameter
|
|
||||||
* @warning If the type of the Parameter doesn't match the type of it's stored value, it will result in undefined behaviour.
|
|
||||||
*/
|
|
||||||
template<typename T> T &get() & { return stat<T>(); }
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
template<class T>
|
|
||||||
T GetFileName(T const & path, T const & delims = "/\\")
|
|
||||||
{
|
|
||||||
return path.substr(path.find_last_of(delims) + 1);
|
|
||||||
}
|
|
||||||
template<class T>
|
|
||||||
T remove_ext(T const & filename)
|
|
||||||
{
|
|
||||||
typename T::size_type const p(filename.find_last_of('.'));
|
|
||||||
return p > 0 && p != T::npos ? filename.substr(0, p) : filename;
|
|
||||||
}
|
|
@ -1,81 +0,0 @@
|
|||||||
#include "thread.hpp"
|
|
||||||
namespace RenderD7 {
|
|
||||||
void Threads::Exit()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
Thread::Thread() :
|
|
||||||
m_started(false),
|
|
||||||
m_running(false) { /* do nothing */ }
|
|
||||||
|
|
||||||
Thread::Thread(std::function<void(RenderD7::Parameter)> t_function, RenderD7::Parameter t_parameter, bool t_autostart, bool t_detached, unsigned long long int t_stackSize) :
|
|
||||||
m_started(false),
|
|
||||||
m_running(false) {
|
|
||||||
initialize(t_function, t_parameter, t_autostart, t_detached, t_stackSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
Thread::~Thread() {
|
|
||||||
join();
|
|
||||||
|
|
||||||
if (m_started) threadFree(m_thread);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Thread::initialize(std::function<void(RenderD7::Parameter)> t_function, RenderD7::Parameter t_parameter, bool t_autostart, bool t_detached, unsigned long long int t_stackSize) {
|
|
||||||
m_stackSize = t_stackSize;
|
|
||||||
m_data.m_parameter = t_parameter;
|
|
||||||
m_data.m_function = t_function;
|
|
||||||
m_data.m_running = &m_running;
|
|
||||||
|
|
||||||
if (t_autostart) {
|
|
||||||
start(t_detached);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Thread::setStackSize(unsigned long long int t_stackSize) {
|
|
||||||
m_stackSize = t_stackSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Thread::start(bool t_detached) {
|
|
||||||
if (!m_running) {
|
|
||||||
m_started = true;
|
|
||||||
m_running = true;
|
|
||||||
s32 prio;
|
|
||||||
svcGetThreadPriority(&prio, CUR_THREAD_HANDLE);
|
|
||||||
m_thread = threadCreate(threadFunction, &m_data, m_stackSize, prio + 1, -2, t_detached);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Thread::kill() {
|
|
||||||
threadDetach(m_thread);
|
|
||||||
m_running = false;
|
|
||||||
m_started = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Thread::join(long long unsigned int t_timeout) {
|
|
||||||
if (m_running) {
|
|
||||||
threadJoin(m_thread, t_timeout);
|
|
||||||
threadFree(m_thread);
|
|
||||||
m_running = false;
|
|
||||||
m_started = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Thread::isRunning() {
|
|
||||||
return m_running;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Thread::sleep() {
|
|
||||||
svcSleepThread(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Thread::sleep(int t_milliseconds) {
|
|
||||||
svcSleepThread(1000000 * t_milliseconds);
|
|
||||||
}
|
|
||||||
|
|
||||||
// private methods
|
|
||||||
void Thread::threadFunction(void* arg) {
|
|
||||||
RenderD7::Thread::ThreadData data = *static_cast<RenderD7::Thread::ThreadData*>(arg);
|
|
||||||
data.m_function(data.m_parameter);
|
|
||||||
*data.m_running = false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,119 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <3ds.h>
|
|
||||||
#include <atomic>
|
|
||||||
#include <functional>
|
|
||||||
#include <string>
|
|
||||||
#include "parameter.hpp"
|
|
||||||
|
|
||||||
using CTRU_Thread = Thread;
|
|
||||||
|
|
||||||
#define THREAD_STACK_SIZE 0x1000
|
|
||||||
|
|
||||||
namespace RenderD7 {
|
|
||||||
namespace Threads
|
|
||||||
{
|
|
||||||
inline bool threadrunning = false;
|
|
||||||
|
|
||||||
struct Thread
|
|
||||||
{
|
|
||||||
Handle handle;
|
|
||||||
void (*ep)(void);
|
|
||||||
bool finished;
|
|
||||||
void* stacktop;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool Create();
|
|
||||||
bool Join();
|
|
||||||
void Exit();
|
|
||||||
}
|
|
||||||
class Thread {
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief Default constructor
|
|
||||||
* @note This should only be called when calling m3d::Thread::initialize() before calling m3d::Thread::start()
|
|
||||||
*/
|
|
||||||
Thread();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Constructs the thread
|
|
||||||
* @param t_function The thread function
|
|
||||||
* @param t_parameter The parameter to pass to the function
|
|
||||||
* @param t_autostart Whether the thread should start instantly
|
|
||||||
* @param t_detached Whether the thread starts detached or not
|
|
||||||
* @param t_stackSize The stacksize allocated for the thread in bytes (rounded to multiples of 8 bytes)
|
|
||||||
* @note t_function needs to be of type `void` and take one (and only one) parameter of type m3d::Parameter
|
|
||||||
* @warning If the thread priority is lower than the priority of the calling thread, the thread will never get executed. Use m3d::Thread::getCurrentPriority() to get the priority of the current thread
|
|
||||||
*/
|
|
||||||
Thread(std::function<void(RenderD7::Parameter)> t_function, RenderD7::Parameter t_parameter = nullptr, bool t_autostart = false, bool t_detached = false, unsigned long long int t_stackSize = 4 * 1024);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Destructs the thread
|
|
||||||
*/
|
|
||||||
virtual ~Thread();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initializes the thread
|
|
||||||
* @param t_function The thread function
|
|
||||||
* @param t_parameter The parameter to pass to the function
|
|
||||||
* @param t_autostart Whether the thread should start instantly
|
|
||||||
* @param t_detached Whether the thread starts detached or not
|
|
||||||
* @param t_stackSize The stacksize allocated for the thread in bytes (rounded to multiples of 8 bytes)
|
|
||||||
* @note t_function needs to be of type `void` and take one (and only one) parameter of type m3d::Parameter
|
|
||||||
* @warning If the thread priority is lower than the priority of the calling thread, the thread will never get executed. Use m3d::Thread::getCurrentPriority() to get the priority of the current thread
|
|
||||||
*/
|
|
||||||
void initialize(std::function<void(RenderD7::Parameter)> t_function, RenderD7::Parameter t_parameter = nullptr, bool t_autostart = false, bool t_detached = false, unsigned long long int t_stackSize = 4 * 1024);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Sets the size of the stack that gets allocated for the next thread that get's started
|
|
||||||
* @param t_stackSize The allocated space in bytes (rounded to multiples of 8 bytes)
|
|
||||||
*/
|
|
||||||
void setStackSize(unsigned long long int t_stackSize);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Starts the thread. To restart it, call Thread::join() before
|
|
||||||
* @param t_detached Whether the thread should start detached or not
|
|
||||||
*/
|
|
||||||
void start(bool t_detached = false);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Detaches the thread
|
|
||||||
*/
|
|
||||||
void kill();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Waits for the thread to finish
|
|
||||||
* @param t_timeout The timeout in nanoseconds. Leave it for no timeout
|
|
||||||
*/
|
|
||||||
void join(long long unsigned int t_timeout = U64_MAX);
|
|
||||||
|
|
||||||
bool isRunning();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Puts the thread to sleep
|
|
||||||
*
|
|
||||||
* This is needed if you have multiple threads running at the same time. It doesn't affect the execution-time of the thread, it just makes it possible for the other threads to get their chance to shine.
|
|
||||||
*/
|
|
||||||
static void sleep();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Sleeps for the given time
|
|
||||||
* @param t_milliseconds The time to sleep in milliseconds
|
|
||||||
*/
|
|
||||||
static void sleep(int t_milliseconds);
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct ThreadData {
|
|
||||||
RenderD7::Parameter m_parameter;
|
|
||||||
std::function<void(RenderD7::Parameter)> m_function;
|
|
||||||
std::atomic<bool>* m_running;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void threadFunction(void* t_arg);
|
|
||||||
/* data */
|
|
||||||
int m_priority, m_stackSize;
|
|
||||||
bool m_started;
|
|
||||||
std::atomic<bool> m_running;
|
|
||||||
RenderD7::Thread::ThreadData m_data;
|
|
||||||
CTRU_Thread m_thread;
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
#include "Clock.hpp"
|
|
||||||
|
|
||||||
namespace rnd7{
|
|
||||||
enum class TweenType : int {Position = 1, Color, Alpha};
|
|
||||||
|
|
||||||
enum class TweenLoop : int {None = 1, Loop = 2,};
|
|
||||||
|
|
||||||
enum class TweenDirection : int {Current, Forward, Backward};
|
|
||||||
|
|
||||||
enum class TweenState : int {Playing = 1, Stopped};
|
|
||||||
class Tween
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Tween(float from, float to, float duration, TweenLoop loop, TweenState state);
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
9
log.cpp
9
log.cpp
@ -30,15 +30,14 @@ Log::Log()
|
|||||||
|
|
||||||
void Log::Init(const char *filename)
|
void Log::Init(const char *filename)
|
||||||
{
|
{
|
||||||
std::string name = "logs/Log_" + Log::logDate() + filename + ".txt";
|
this->filename = filename;
|
||||||
this->filename = name.c_str();
|
if ((access(filename, F_OK) == 0))
|
||||||
if ((access(name.c_str(), F_OK) == 0))
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FILE* logfile = fopen((name.c_str()), "w");
|
FILE* logfile = fopen((filename), "w");
|
||||||
fclose(logfile);
|
fclose(logfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,4 +56,4 @@ void Log::Write(std::string debug_text)
|
|||||||
Log::~Log()
|
Log::~Log()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
15
log.hpp
15
log.hpp
@ -1,30 +1,19 @@
|
|||||||
#pragma once
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
/** Log Class */
|
|
||||||
class Log
|
class Log
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Construct */
|
|
||||||
Log();
|
Log();
|
||||||
/** Deconstruct */
|
|
||||||
~Log();
|
~Log();
|
||||||
/// Init the log file
|
|
||||||
/// \param filename name for the file
|
|
||||||
void Init(const char *filename);
|
void Init(const char *filename);
|
||||||
/// Write Text to logfile
|
|
||||||
/// \param debug_text your text
|
|
||||||
void Write(std::string debug_text);
|
void Write(std::string debug_text);
|
||||||
/// Get the date
|
|
||||||
std::string logDate(void);
|
std::string logDate(void);
|
||||||
/// Format to logstyle
|
|
||||||
/// \param fmt_str the formatted style
|
|
||||||
std::string format(const std::string& fmt_str, ...);
|
std::string format(const std::string& fmt_str, ...);
|
||||||
private:
|
private:
|
||||||
/// param filename the name of the logfile
|
|
||||||
std::string filename;
|
std::string filename;
|
||||||
};
|
};
|
518
renderd7.cpp
518
renderd7.cpp
@ -4,24 +4,11 @@
|
|||||||
|
|
||||||
#define RGBA8(r, g, b, a) ((((r) & 0xFF) << 0) | (((g) & 0xFF) << 8) | (((b) & 0xFF) << 16) | (((a) & 0xFF) << 24))
|
#define RGBA8(r, g, b, a) ((((r) & 0xFF) << 0) | (((g) & 0xFF) << 8) | (((b) & 0xFF) << 16) | (((a) & 0xFF) << 24))
|
||||||
#define D7_NOTHING C2D_Color32(0, 0, 0, 0)
|
#define D7_NOTHING C2D_Color32(0, 0, 0, 0)
|
||||||
#define CFGVER "0"
|
|
||||||
Log renderd7log;
|
Log renderd7log;
|
||||||
float animtime;
|
float animtime;
|
||||||
bool isndspinit = false;
|
bool isndspinit = false;
|
||||||
bool running = true;
|
bool running = true;
|
||||||
std::stack<std::unique_ptr<RenderD7::Scene>> RenderD7::Scene::scenes;
|
std::stack<std::unique_ptr<RenderD7::Scene>> RenderD7::Scene::scenes;
|
||||||
//std::vector<RenderD7::Ovl> overlays;
|
|
||||||
bool usedbgmsg = false;
|
|
||||||
std::string dspststus = "Not Initialisized!";
|
|
||||||
|
|
||||||
int cobj___;
|
|
||||||
int maxobj__;
|
|
||||||
|
|
||||||
//INI::INIFile cfgfile;
|
|
||||||
std::unique_ptr<INI::INIFile> cfgfile = nullptr;
|
|
||||||
INI::INIStructure cfgstruct;
|
|
||||||
|
|
||||||
std::string D_app_name;
|
|
||||||
|
|
||||||
u32 d7_hDown;
|
u32 d7_hDown;
|
||||||
u32 d7_hHeld;
|
u32 d7_hHeld;
|
||||||
@ -38,16 +25,6 @@ static u64 last_time = 0;
|
|||||||
float d11framerate = 0;
|
float d11framerate = 0;
|
||||||
//-----------------
|
//-----------------
|
||||||
|
|
||||||
//Metrik-------------------------------------
|
|
||||||
u32 mt_color;
|
|
||||||
u32 mt_txtcolor;
|
|
||||||
|
|
||||||
int mt_screen;
|
|
||||||
//int mt_width = mt_screen ? 320 : 400;
|
|
||||||
float mt_txtSize;
|
|
||||||
bool metrikd = false;
|
|
||||||
double mt_fpsgraph[320];
|
|
||||||
//-------------------------------------------
|
|
||||||
bool currentScreen = false;
|
bool currentScreen = false;
|
||||||
|
|
||||||
C3D_RenderTarget* Top;
|
C3D_RenderTarget* Top;
|
||||||
@ -62,7 +39,7 @@ RenderD7::SpriteSheetAnimation::SpriteSheetAnimation()
|
|||||||
}
|
}
|
||||||
RenderD7::SpriteSheetAnimation::~SpriteSheetAnimation()
|
RenderD7::SpriteSheetAnimation::~SpriteSheetAnimation()
|
||||||
{
|
{
|
||||||
//
|
|
||||||
}
|
}
|
||||||
bool RenderD7::DrawImageFromSheet(RenderD7::Sheet* sheet, size_t index, float x, float y, float scaleX, float scaleY)
|
bool RenderD7::DrawImageFromSheet(RenderD7::Sheet* sheet, size_t index, float x, float y, float scaleX, float scaleY)
|
||||||
{
|
{
|
||||||
@ -83,11 +60,9 @@ void RenderD7::Init::NdspFirm(bool useit)
|
|||||||
{
|
{
|
||||||
ndspInit();
|
ndspInit();
|
||||||
isndspinit = true;
|
isndspinit = true;
|
||||||
dspststus = "Initialisized success!";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dspststus = "Not found: dspfirm.cdc";
|
|
||||||
renderd7log.Write("RenderD7: SoundEngine Error! ndspfirm not found!");
|
renderd7log.Write("RenderD7: SoundEngine Error! ndspfirm not found!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,7 +74,7 @@ void RenderD7::Exit::NdspFirm()
|
|||||||
ndspExit();
|
ndspExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void RenderD7::Msg::Display(std::string titletxt, std::string subtext, C3D_RenderTarget *target)
|
void RenderD7::Msg::Display(std::string titletxt, std::string txt, C3D_RenderTarget *target)
|
||||||
{
|
{
|
||||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||||
C2D_TargetClear(Top, DSEVENBLACK);
|
C2D_TargetClear(Top, DSEVENBLACK);
|
||||||
@ -112,37 +87,17 @@ void RenderD7::Msg::Display(std::string titletxt, std::string subtext, C3D_Rende
|
|||||||
RenderD7::OnScreen(target);
|
RenderD7::OnScreen(target);
|
||||||
RenderD7::DrawRect(0, 0, 400, 26, RenderD7::Color::Hex("#333333", 200));
|
RenderD7::DrawRect(0, 0, 400, 26, RenderD7::Color::Hex("#333333", 200));
|
||||||
RenderD7::DrawText(5, 2, 0.7f, DSEVENWHITE, titletxt);
|
RenderD7::DrawText(5, 2, 0.7f, DSEVENWHITE, titletxt);
|
||||||
RenderD7::DrawText(5, 30, 0.6f, DSEVENWHITE, subtext);
|
RenderD7::DrawText(5, 30, 0.6f, DSEVENWHITE, txt);
|
||||||
|
|
||||||
C3D_FrameEnd(0);
|
C3D_FrameEnd(0);
|
||||||
}
|
}
|
||||||
void RenderD7::Msg::DisplayWithProgress(std::string titletext, std::string subtext, float current, float total, u32 prgbarcolor)
|
|
||||||
{
|
|
||||||
RenderD7::ClearTextBufs();
|
|
||||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
|
||||||
C2D_TargetClear(Top, DSEVENBLACK);
|
|
||||||
C2D_TargetClear(Bottom, DSEVENBLACK);
|
|
||||||
char str[256];
|
|
||||||
snprintf(str, sizeof(str), "(%.2f%%)", ((float)current/(float)total) * 100.0f);
|
|
||||||
RenderD7::OnScreen(Top);
|
|
||||||
RenderD7::DrawRect(0, 0, 400, 240, RenderD7::Color::Hex("#111111"));
|
|
||||||
RenderD7::DrawRect(0, 0, 400, 26, RenderD7::Color::Hex("#333333", 200));
|
|
||||||
RenderD7::DrawText(5, 2, 0.7f, DSEVENWHITE, titletext);
|
|
||||||
RenderD7::DrawText(5, 30, 0.6f, DSEVENWHITE, subtext);
|
|
||||||
RenderD7::DrawRect(30, 120, 342, 30, RenderD7::Color::Hex("#333333"));
|
|
||||||
RenderD7::DrawRect(31, 121, (int)(((float)current / (float)total) * 338.0f), 28, prgbarcolor);
|
|
||||||
RenderD7::DrawTextCentered(5, 124, 0.7f, RenderD7::Color::Hex("#111111"), str, 390);
|
|
||||||
RenderD7::OnScreen(Bottom);
|
|
||||||
RenderD7::DrawRect(0, 0, 320, 240, RenderD7::Color::Hex("#111111"));
|
|
||||||
|
|
||||||
C3D_FrameEnd(0);
|
|
||||||
}
|
|
||||||
void RenderD7::SetupLog()
|
void RenderD7::SetupLog()
|
||||||
{
|
{
|
||||||
renderd7log.Init("sdmc:/RenderD7.log");
|
renderd7log.Init("sdmc:/Flappy-Bird-RenderD7.log");
|
||||||
}
|
}
|
||||||
void RenderD7::SpriteSheetAnimation::Setup(RenderD7::Sheet *sheet, size_t imagecount, size_t startimage, float frame_begin, float frame_finish)
|
void RenderD7::SpriteSheetAnimation::Setup(RenderD7::Sheet *sheet, size_t imagecount, size_t startimage, float frame_begin, float frame_finish)
|
||||||
{
|
{
|
||||||
|
|
||||||
D_totaltime = frame_begin;
|
D_totaltime = frame_begin;
|
||||||
renderd7log.Write("frame_begin success");
|
renderd7log.Write("frame_begin success");
|
||||||
this->images = imagecount;
|
this->images = imagecount;
|
||||||
@ -167,43 +122,22 @@ void RenderD7::SpriteSheetAnimation::Play(float timespeed)
|
|||||||
}
|
}
|
||||||
RenderD7::SpriteSheetAnimation::FromSheet(sheet, imgs);
|
RenderD7::SpriteSheetAnimation::FromSheet(sheet, imgs);
|
||||||
//RenderD7::SpriteSheetAnimation::Draw();
|
//RenderD7::SpriteSheetAnimation::Draw();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderD7::Error::DisplayError(std::string toptext, std::string errortext, int timesec)
|
void RenderD7::Error::DisplayError(std::string toptext, std::string errortext)
|
||||||
{
|
{
|
||||||
RenderD7::ClearTextBufs();
|
RenderD7::ClearTextBufs();
|
||||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||||
C2D_TargetClear(Top, DSEVENBLACK);
|
C2D_TargetClear(Top, DSEVENBLACK);
|
||||||
C2D_TargetClear(Bottom, DSEVENBLACK);
|
C2D_TargetClear(Bottom, DSEVENBLACK);
|
||||||
RenderD7::OnScreen(Top);
|
|
||||||
RenderD7::DrawText(0, 0, 0.7f, DSEVENWHITE, toptext);
|
|
||||||
RenderD7::DrawText(0, 30, 0.6f, DSEVENWHITE, errortext);
|
|
||||||
C3D_FrameEnd(0);
|
|
||||||
int time = 60*timesec;
|
|
||||||
for (int i = 0; i < 60*timesec; i++) {
|
|
||||||
RenderD7::DrawRect(0, 236, (int)(((float)i / (float)60*timesec) * 400.0f), 4, RenderD7::Color::Hex("#00ff00"));
|
|
||||||
gspWaitForVBlank();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void RenderD7::Error::DisplayFatalError(std::string toptext, std::string errortext)
|
|
||||||
{
|
|
||||||
bool error___ = true;
|
|
||||||
RenderD7::ClearTextBufs();
|
|
||||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
|
||||||
C2D_TargetClear(Top, DSEVENBLACK);
|
|
||||||
C2D_TargetClear(Bottom, DSEVENBLACK);
|
|
||||||
RenderD7::OnScreen(Top);
|
|
||||||
RenderD7::DrawTextCentered(0, 0, 0.7f, DSEVENWHITE, toptext, 400);
|
RenderD7::DrawTextCentered(0, 0, 0.7f, DSEVENWHITE, toptext, 400);
|
||||||
RenderD7::DrawTextCentered(0, 100, 0.6f, DSEVENWHITE, errortext, 400);
|
RenderD7::DrawTextCentered(0, 100, 0.6f, DSEVENWHITE, errortext, 400);
|
||||||
RenderD7::DrawTextCentered(0, 200, 0.6f, DSEVENWHITE, "Press Start to Exit!", 400);
|
|
||||||
C3D_FrameEnd(0);
|
C3D_FrameEnd(0);
|
||||||
while (error___)
|
for (int i = 0; i < 60*20; i++) {
|
||||||
{
|
gspWaitForVBlank();
|
||||||
if(d7_hDown & KEY_START)
|
}
|
||||||
{
|
|
||||||
RenderD7::ExitApp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
u32 RenderD7::Color::Hex(const std::string color, u8 a)
|
u32 RenderD7::Color::Hex(const std::string color, u8 a)
|
||||||
{
|
{
|
||||||
@ -241,28 +175,6 @@ void RenderD7::OnScreen(C3D_RenderTarget *target)
|
|||||||
C2D_SceneBegin(target);
|
C2D_SceneBegin(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
void frameloop()
|
|
||||||
{
|
|
||||||
frames++;
|
|
||||||
u64 delta_time = osGetTime() - last_time;
|
|
||||||
if (delta_time >= 1000) {
|
|
||||||
current_fps = frames/(delta_time/1000.0f)+1;
|
|
||||||
frames = 0;
|
|
||||||
last_time = osGetTime();
|
|
||||||
}
|
|
||||||
d11framerate = current_fps;
|
|
||||||
mt_fpsgraph[320] = current_fps;
|
|
||||||
}
|
|
||||||
float getframerate()
|
|
||||||
{
|
|
||||||
return d11framerate;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string RenderD7::GetFramerate()
|
|
||||||
{
|
|
||||||
return (std::to_string((int)d11framerate).substr(0, 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RenderD7::MainLoop()
|
bool RenderD7::MainLoop()
|
||||||
{
|
{
|
||||||
if (!aptMainLoop()) return false;
|
if (!aptMainLoop()) return false;
|
||||||
@ -274,25 +186,20 @@ bool RenderD7::MainLoop()
|
|||||||
|
|
||||||
RenderD7::ClearTextBufs();
|
RenderD7::ClearTextBufs();
|
||||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||||
|
|
||||||
C2D_TargetClear(Top, C2D_Color32(0, 0, 0, 0));
|
C2D_TargetClear(Top, C2D_Color32(0, 0, 0, 0));
|
||||||
C2D_TargetClear(Bottom, C2D_Color32(0, 0, 0, 0));
|
C2D_TargetClear(Bottom, C2D_Color32(0, 0, 0, 0));
|
||||||
frameloop();
|
|
||||||
RenderD7::Scene::doDraw();
|
|
||||||
RenderD7::Scene::doLogic(d7_hDown, d7_hHeld, d7_hUp, d7_touch);
|
|
||||||
|
|
||||||
//if (metrikd)RenderD7::DrawMetrikOvl();
|
|
||||||
return running;
|
return running;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RenderD7::Sheet::Sheet()
|
RenderD7::Sheet::Sheet()
|
||||||
{
|
{
|
||||||
//
|
|
||||||
}
|
}
|
||||||
RenderD7::Sheet::~Sheet()
|
RenderD7::Sheet::~Sheet()
|
||||||
{
|
{
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result RenderD7::Sheet::Load(const char *path)
|
Result RenderD7::Sheet::Load(const char *path)
|
||||||
@ -308,11 +215,11 @@ void RenderD7::Sheet::Free()
|
|||||||
|
|
||||||
RenderD7::Sprite::Sprite()
|
RenderD7::Sprite::Sprite()
|
||||||
{
|
{
|
||||||
//
|
|
||||||
}
|
}
|
||||||
RenderD7::Sprite::~Sprite()
|
RenderD7::Sprite::~Sprite()
|
||||||
{
|
{
|
||||||
//
|
|
||||||
}
|
}
|
||||||
void RenderD7::Sprite::FromSheet(RenderD7::Sheet *sheet, size_t index)
|
void RenderD7::Sprite::FromSheet(RenderD7::Sheet *sheet, size_t index)
|
||||||
{
|
{
|
||||||
@ -355,31 +262,33 @@ float RenderD7::Sprite::getPosY()
|
|||||||
return this->sprite.params.pos.y;
|
return this->sprite.params.pos.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderD7::Sprite::FromImage(RenderD7::Image *img)
|
|
||||||
{
|
|
||||||
C2D_SpriteFromImage(&this->sprite, img->img);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::Sprite::SetScale(float x, float y)
|
|
||||||
{
|
|
||||||
C2D_SpriteScale(&this->sprite, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::ClearTextBufs(void)
|
void RenderD7::ClearTextBufs(void)
|
||||||
{
|
{
|
||||||
C2D_TextBufClear(TextBuf);
|
C2D_TextBufClear(TextBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void frameloop()
|
||||||
|
{
|
||||||
|
frames++;
|
||||||
|
u64 delta_time = osGetTime() - last_time;
|
||||||
|
if (delta_time >= 1000) {
|
||||||
|
current_fps = frames/(delta_time/1000.0f)+1;
|
||||||
|
frames = 0;
|
||||||
|
last_time = osGetTime();
|
||||||
|
}
|
||||||
|
d11framerate = current_fps;
|
||||||
|
}
|
||||||
|
float getframerate()
|
||||||
|
{
|
||||||
|
frameloop();
|
||||||
|
return d11framerate;
|
||||||
|
}
|
||||||
|
|
||||||
bool RenderD7::DrawRect(float x, float y, float w, float h, u32 color)
|
bool RenderD7::DrawRect(float x, float y, float w, float h, u32 color)
|
||||||
{
|
{
|
||||||
return C2D_DrawRectSolid(x, y, 0.5f, w, h, color);
|
return C2D_DrawRectSolid(x, y, 0.5f, w, h, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderD7::DrawPx(float x, float y, u32 color)
|
|
||||||
{
|
|
||||||
return C2D_DrawRectSolid(x, y, 0.5f, 1, 1, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::DrawTextCentered(float x, float y, float size, u32 color, std::string Text, int maxWidth, int maxHeight, C2D_Font fnt) {
|
void RenderD7::DrawTextCentered(float x, float y, float size, u32 color, std::string Text, int maxWidth, int maxHeight, C2D_Font fnt) {
|
||||||
float lineHeight, widthScale;
|
float lineHeight, widthScale;
|
||||||
|
|
||||||
@ -399,6 +308,7 @@ void RenderD7::DrawTextCentered(float x, float y, float size, u32 color, std::st
|
|||||||
} else {
|
} else {
|
||||||
widthScale = RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n')));
|
widthScale = RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n')));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Do the widthScale 2.
|
// Do the widthScale 2.
|
||||||
if (fnt != nullptr) {
|
if (fnt != nullptr) {
|
||||||
@ -406,7 +316,9 @@ void RenderD7::DrawTextCentered(float x, float y, float size, u32 color, std::st
|
|||||||
} else {
|
} else {
|
||||||
widthScale = std::min((float)maxWidth, RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n'))));
|
widthScale = std::min((float)maxWidth, RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n'))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fnt != nullptr) {
|
if (fnt != nullptr) {
|
||||||
RenderD7::DrawText((currentScreen ? 200 : 160)+x-(widthScale/2), y+(lineHeight*line), size, color, Text.substr(0, Text.find('\n')), maxWidth, maxHeight, fnt);
|
RenderD7::DrawText((currentScreen ? 200 : 160)+x-(widthScale/2), y+(lineHeight*line), size, color, Text.substr(0, Text.find('\n')), maxWidth, maxHeight, fnt);
|
||||||
} else {
|
} else {
|
||||||
@ -424,6 +336,7 @@ void RenderD7::DrawTextCentered(float x, float y, float size, u32 color, std::st
|
|||||||
} else {
|
} else {
|
||||||
widthScale = RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n')));
|
widthScale = RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n')));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// And again.
|
// And again.
|
||||||
if (fnt != nullptr) {
|
if (fnt != nullptr) {
|
||||||
@ -431,6 +344,7 @@ void RenderD7::DrawTextCentered(float x, float y, float size, u32 color, std::st
|
|||||||
} else {
|
} else {
|
||||||
widthScale = std::min((float)maxWidth, RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n'))));
|
widthScale = std::min((float)maxWidth, RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n'))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (fnt != nullptr) {
|
if (fnt != nullptr) {
|
||||||
RenderD7::DrawText((currentScreen ? 200 : 160)+x-(widthScale/2), y+(lineHeight*line), size, color, Text.substr(0, Text.find('\n')), maxWidth, maxHeight, fnt);
|
RenderD7::DrawText((currentScreen ? 200 : 160)+x-(widthScale/2), y+(lineHeight*line), size, color, Text.substr(0, Text.find('\n')), maxWidth, maxHeight, fnt);
|
||||||
@ -455,6 +369,7 @@ void RenderD7::DrawText(float x, float y, float size, u32 color, std::string Tex
|
|||||||
if (maxHeight == 0) {
|
if (maxHeight == 0) {
|
||||||
heightScale = size;
|
heightScale = size;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (fnt != nullptr) {
|
if (fnt != nullptr) {
|
||||||
heightScale = std::min(size, size*(maxHeight/RenderD7::GetTextHeight(size, Text, fnt)));
|
heightScale = std::min(size, size*(maxHeight/RenderD7::GetTextHeight(size, Text, fnt)));
|
||||||
} else {
|
} else {
|
||||||
@ -472,10 +387,7 @@ void RenderD7::DrawText(float x, float y, float size, u32 color, std::string Tex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void RenderD7::DrawTextLeft(float x, float y, float size, u32 color, std::string Text, int maxWidth, int maxHeight, C2D_Font fnt)
|
|
||||||
{
|
|
||||||
RenderD7::DrawText(x - RenderD7::GetTextWidth(size, Text, fnt), y, size, color, Text, maxWidth, maxHeight, fnt);
|
|
||||||
}
|
|
||||||
// Get String or Text Width.
|
// Get String or Text Width.
|
||||||
float RenderD7::GetTextWidth(float size, std::string Text, C2D_Font fnt) {
|
float RenderD7::GetTextWidth(float size, std::string Text, C2D_Font fnt) {
|
||||||
float width = 0;
|
float width = 0;
|
||||||
@ -528,88 +440,38 @@ bool RenderD7::DrawCircle(float x, float y, float radius, u32 color)
|
|||||||
return C2D_DrawCircleSolid(x, y, 0.5f, radius, color);
|
return C2D_DrawCircleSolid(x, y, 0.5f, radius, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetrikThread(RenderD7::Parameter param) {
|
Result RenderD7::Init::Main()
|
||||||
while (true) {
|
|
||||||
RenderD7::DrawMetrikOvl();
|
|
||||||
RenderD7::Thread::sleep(1000 * 1); // wait; also, this is needed to allow for concurrency (refer to the documentation for m3d::Thread::sleep())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Result RenderD7::Init::Main(std::string app_name)
|
|
||||||
{
|
{
|
||||||
gfxInitDefault();
|
gfxInitDefault();
|
||||||
aptInit();
|
aptInit();
|
||||||
romfsInit();
|
romfsInit();
|
||||||
cfguInit();
|
cfguInit();
|
||||||
if (cobj___){maxobj__ = cobj___;}
|
osSetSpeedupEnable(true);
|
||||||
if (!cobj___){maxobj__ = C2D_DEFAULT_MAX_OBJECTS;}
|
|
||||||
D_app_name = app_name;
|
|
||||||
std::string cfgpath = "sdmc:/RenderD7/Apps/";
|
|
||||||
cfgpath += D_app_name;
|
|
||||||
mkdir("sdmc:/RenderD7/", 0777);
|
|
||||||
mkdir("sdmc:/RenderD7/Apps", 0777);
|
|
||||||
mkdir(cfgpath.c_str(), 0777);
|
|
||||||
bool renew = false;
|
|
||||||
if (FS::FileExist(cfgpath + "/config.ini"))
|
|
||||||
{
|
|
||||||
cfgfile = std::make_unique<INI::INIFile>(cfgpath + "/config.ini");
|
|
||||||
cfgfile->read(cfgstruct);
|
|
||||||
std::string version = cfgstruct["info"]["version"];
|
|
||||||
if (version != CFGVER) renew = true;
|
|
||||||
}
|
|
||||||
if (!FS::FileExist(cfgpath + "/config.ini") || renew)
|
|
||||||
{
|
|
||||||
cfgfile = std::make_unique<INI::INIFile>(cfgpath+ "/config.ini");
|
|
||||||
cfgfile->read(cfgstruct);
|
|
||||||
cfgstruct["info"]["version"] = CFGVER;
|
|
||||||
cfgstruct["info"]["renderd7ver"] = RENDERD7VSTRING;
|
|
||||||
cfgstruct["settings"]["doscreentimeout"] = "0";
|
|
||||||
cfgstruct["settings"]["forcetimeoutLB"] = "1";
|
|
||||||
cfgstruct["settings"]["forceFrameRate"] = "60";
|
|
||||||
cfgstruct["settings"]["super-reselution"] = "0";
|
|
||||||
cfgstruct["metrik-settings"]["enableoverlay"] = "0";
|
|
||||||
cfgstruct["metrik-settings"]["Screen"] = "0";
|
|
||||||
cfgstruct["metrik-settings"]["txtColor"] = "#ffffff";
|
|
||||||
cfgstruct["metrik-settings"]["txtColorA"] = "255";
|
|
||||||
cfgstruct["metrik-settings"]["ColorA"] = "255";
|
|
||||||
cfgstruct["metrik-settings"]["Color"] = "#000000";
|
|
||||||
cfgstruct["metrik-settings"]["txtSize"] = "0.7f";
|
|
||||||
cfgfile->write(cfgstruct);
|
|
||||||
}
|
|
||||||
cfgfile = std::make_unique<INI::INIFile>(cfgpath+ "/config.ini");
|
|
||||||
cfgfile->read(cfgstruct);
|
|
||||||
std::string Fps = cfgstruct["settings"]["forceFrameRate"];
|
|
||||||
C3D_FrameRate(RenderD7::Convert::StringtoFloat(Fps));
|
|
||||||
metrikd = RenderD7::Convert::FloatToBool(RenderD7::Convert::StringtoFloat(cfgstruct["metrik-settings"]["enableoverlay"]));
|
|
||||||
mt_txtcolor = RenderD7::Color::Hex(cfgstruct["metrik-settings"]["txtColor"], (u8)RenderD7::Convert::StringtoFloat(cfgstruct["metrik-settings"]["txtColorA"]));
|
|
||||||
mt_color = RenderD7::Color::Hex(cfgstruct["metrik-settings"]["Color"], (u8)RenderD7::Convert::StringtoFloat(cfgstruct["metrik-settings"]["ColorA"]));
|
|
||||||
mt_txtSize = RenderD7::Convert::StringtoFloat(cfgstruct["metrik-settings"]["txtSize"]);
|
|
||||||
mt_screen = RenderD7::Convert::StringtoInt(cfgstruct["metrik-settings"]["Screen"]);
|
|
||||||
|
|
||||||
osSetSpeedupEnable(true);
|
|
||||||
|
|
||||||
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
|
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
|
||||||
C2D_Init(size_t(maxobj__));
|
C2D_Init(C2D_DEFAULT_MAX_OBJECTS);
|
||||||
C2D_Prepare();
|
C2D_Prepare();
|
||||||
Top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
|
Top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
|
||||||
TopRight = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT);
|
TopRight = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT);
|
||||||
Bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);
|
Bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);
|
||||||
TextBuf = C2D_TextBufNew(4096);
|
TextBuf = C2D_TextBufNew(4096);
|
||||||
Font = C2D_FontLoadSystem(CFG_REGION_USA);
|
Font = C2D_FontLoadSystem(CFG_REGION_USA);
|
||||||
//RenderD7::Msg::Display("RenderD7", "RenderD7 init success!\nWaiting for MainLoop!", Top);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
void RenderD7::Exit::Main()
|
void RenderD7::Exit::Main()
|
||||||
{
|
{
|
||||||
cfgfile->write(cfgstruct);
|
|
||||||
if (RenderD7::Threads::threadrunning) RenderD7::Threads::Exit();
|
|
||||||
C2D_TextBufDelete(TextBuf);
|
C2D_TextBufDelete(TextBuf);
|
||||||
C2D_Fini();
|
C2D_Fini();
|
||||||
C3D_Fini();
|
C3D_Fini();
|
||||||
aptExit();
|
aptExit();
|
||||||
gfxExit();
|
|
||||||
romfsExit();
|
romfsExit();
|
||||||
cfguExit();
|
cfguExit();
|
||||||
romfsExit();
|
}
|
||||||
|
|
||||||
|
std::string RenderD7::GetFramerate()
|
||||||
|
{
|
||||||
|
frameloop();
|
||||||
|
return (std::to_string(d11framerate).substr(0, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderD7::DrawTObjects(std::vector<RenderD7::TObject> tobjects, u32 color, u32 txtcolor, int selection, u32 selbgcolor, u32 selcolor)
|
void RenderD7::DrawTObjects(std::vector<RenderD7::TObject> tobjects, u32 color, u32 txtcolor, int selection, u32 selbgcolor, u32 selcolor)
|
||||||
@ -628,26 +490,9 @@ void RenderD7::DrawTObjects(std::vector<RenderD7::TObject> tobjects, u32 color,
|
|||||||
RenderD7::DrawRect(tobjects[i].x, tobjects[i].y - 1, tobjects[i].w, tobjects[i].h, color);
|
RenderD7::DrawRect(tobjects[i].x, tobjects[i].y - 1, tobjects[i].w, tobjects[i].h, color);
|
||||||
RenderD7::DrawText(tobjects[i].x + (tobjects[i].w/2) - RenderD7::GetTextHeight(tobjects[i].txtsize , tobjects[i].text) + tobjects[i].correctx, tobjects[i].y + (tobjects[i].h/2) - RenderD7::GetTextHeight(tobjects[i].txtsize, tobjects[i].text) + tobjects[i].correcty, tobjects[i].txtsize, txtcolor, tobjects[i].text);
|
RenderD7::DrawText(tobjects[i].x + (tobjects[i].w/2) - RenderD7::GetTextHeight(tobjects[i].txtsize , tobjects[i].text) + tobjects[i].correctx, tobjects[i].y + (tobjects[i].h/2) - RenderD7::GetTextHeight(tobjects[i].txtsize, tobjects[i].text) + tobjects[i].correcty, tobjects[i].txtsize, txtcolor, tobjects[i].text);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderD7::DrawTLBtns(std::vector<RenderD7::TLBtn> btns, u32 color, int selection, u32 selbgcolor, u32 selcolor)
|
|
||||||
{
|
|
||||||
for(int i = 0; i < (int)btns.size(); i++)
|
|
||||||
{
|
|
||||||
if (selection == i)
|
|
||||||
{
|
|
||||||
RenderD7::DrawRect(btns[i].x - 2, btns[i].y - 2, btns[i].w + 4, btns[i].h + 4, selbgcolor);
|
|
||||||
RenderD7::DrawRect(btns[i].x, btns[i].y, btns[i].w, btns[i].h, color);
|
|
||||||
RenderD7::DrawRect(btns[i].x, btns[i].y, btns[i].w, btns[i].h, selcolor);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RenderD7::DrawRect(btns[i].x, btns[i].y - 1, btns[i].w, btns[i].h, color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::ExitApp()
|
void RenderD7::ExitApp()
|
||||||
{
|
{
|
||||||
running = false;
|
running = false;
|
||||||
@ -659,14 +504,6 @@ bool RenderD7::touchTObj(touchPosition touch, RenderD7::TObject button)
|
|||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RenderD7::GetRandomInt(int b, int e)
|
|
||||||
{
|
|
||||||
std::default_random_engine generator;
|
|
||||||
std::uniform_int_distribution<int> distribution(b, e);
|
|
||||||
int r = distribution(generator);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::DrawSTObject(std::vector<RenderD7::TObject> tobject, int tobjectindex, u32 color, u32 txtcolor)
|
void RenderD7::DrawSTObject(std::vector<RenderD7::TObject> tobject, int tobjectindex, u32 color, u32 txtcolor)
|
||||||
{
|
{
|
||||||
RenderD7::DrawRect(tobject[tobjectindex].x, tobject[tobjectindex].y, tobject[tobjectindex].w, tobject[tobjectindex].h, color);
|
RenderD7::DrawRect(tobject[tobjectindex].x, tobject[tobjectindex].y, tobject[tobjectindex].w, tobject[tobjectindex].h, color);
|
||||||
@ -720,259 +557,10 @@ void RenderD7::GetDirContentsExt(std::vector<RenderD7::DirContent> &dircontent,
|
|||||||
|
|
||||||
closedir(pdir);
|
closedir(pdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
sort(dircontent.begin(), dircontent.end(), dirEntryPredicate);
|
sort(dircontent.begin(), dircontent.end(), dirEntryPredicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderD7::GetDirContents(std::vector<RenderD7::DirContent> &dircontent) {
|
void RenderD7::GetDirContents(std::vector<RenderD7::DirContent> &dircontent) {
|
||||||
RenderD7::GetDirContentsExt(dircontent, {});
|
RenderD7::GetDirContentsExt(dircontent, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderD7::Image::LoadPng(const std::string path)
|
|
||||||
{
|
|
||||||
if (usedbgmsg)
|
|
||||||
{
|
|
||||||
RenderD7::Msg::Display("RenderD7", "Loading Png:" + path, Top);
|
|
||||||
}
|
|
||||||
std::vector<u8> ImageBuffer;
|
|
||||||
unsigned width, height;
|
|
||||||
if (loadet)
|
|
||||||
{
|
|
||||||
C3D_TexDelete(this->img.tex);
|
|
||||||
}
|
|
||||||
lodepng::decode(ImageBuffer, width, height, path);
|
|
||||||
|
|
||||||
this->img.tex = new C3D_Tex;
|
|
||||||
this->img.subtex = new Tex3DS_SubTexture({(u16)width, (u16)height, 0.0f, 1.0f, width / 1024.0f, 1.0f - (height / 1024.0f)});
|
|
||||||
|
|
||||||
C3D_TexInit(this->img.tex, 1024, 1024, GPU_RGBA8);
|
|
||||||
C3D_TexSetFilter(this->img.tex, GPU_LINEAR, GPU_LINEAR);
|
|
||||||
this->img.tex->border = 0xFFFFFFFF;
|
|
||||||
C3D_TexSetWrap(this->img.tex, GPU_CLAMP_TO_BORDER, GPU_CLAMP_TO_BORDER);
|
|
||||||
|
|
||||||
for (u32 x = 0; x < width && x < 1024; x++) {
|
|
||||||
for (u32 y = 0; y < height && y < 1024; y++) {
|
|
||||||
const u32 dstPos = ((((y >> 3) * (1024 >> 3) + (x >> 3)) << 6) +
|
|
||||||
((x & 1) | ((y & 1) << 1) | ((x & 2) << 1) | ((y & 2) << 2) |
|
|
||||||
((x & 4) << 2) | ((y & 4) << 3))) * 4;
|
|
||||||
|
|
||||||
const u32 srcPos = (y * width + x) * 4;
|
|
||||||
((uint8_t *)this->img.tex->data)[dstPos + 0] = ImageBuffer.data()[srcPos + 3];
|
|
||||||
((uint8_t *)this->img.tex->data)[dstPos + 1] = ImageBuffer.data()[srcPos + 2];
|
|
||||||
((uint8_t *)this->img.tex->data)[dstPos + 2] = ImageBuffer.data()[srcPos + 1];
|
|
||||||
((uint8_t *)this->img.tex->data)[dstPos + 3] = ImageBuffer.data()[srcPos + 0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
loadet = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::Image::LoadPFromBuffer(const std::vector<u8> &buffer)
|
|
||||||
{
|
|
||||||
std::vector<u8> ImageBuffer;
|
|
||||||
if (loadet)
|
|
||||||
{
|
|
||||||
C3D_TexDelete(this->img.tex);
|
|
||||||
}
|
|
||||||
unsigned width, height;
|
|
||||||
lodepng::decode(ImageBuffer, width, height, buffer);
|
|
||||||
|
|
||||||
img.tex = new C3D_Tex;
|
|
||||||
img.subtex = new Tex3DS_SubTexture({(u16)width, (u16)height, 0.0f, 1.0f, width / 512.0f, 1.0f - (height / 512.0f)});
|
|
||||||
|
|
||||||
C3D_TexInit(img.tex, 512, 512, GPU_RGBA8);
|
|
||||||
C3D_TexSetFilter(img.tex, GPU_LINEAR, GPU_LINEAR);
|
|
||||||
img.tex->border = 0xFFFFFFFF;
|
|
||||||
C3D_TexSetWrap(img.tex, GPU_CLAMP_TO_BORDER, GPU_CLAMP_TO_BORDER);
|
|
||||||
|
|
||||||
for (u32 x = 0; x < width && x < 512; x++) {
|
|
||||||
for (u32 y = 0; y < height && y < 512; y++) {
|
|
||||||
const u32 dstPos = ((((y >> 3) * (512 >> 3) + (x >> 3)) << 6) +
|
|
||||||
((x & 1) | ((y & 1) << 1) | ((x & 2) << 1) | ((y & 2) << 2) |
|
|
||||||
((x & 4) << 2) | ((y & 4) << 3))) * 4;
|
|
||||||
|
|
||||||
const u32 srcPos = (y * width + x) * 4;
|
|
||||||
((uint8_t *)img.tex->data)[dstPos + 0] = ImageBuffer.data()[srcPos + 3];
|
|
||||||
((uint8_t *)img.tex->data)[dstPos + 1] = ImageBuffer.data()[srcPos + 2];
|
|
||||||
((uint8_t *)img.tex->data)[dstPos + 2] = ImageBuffer.data()[srcPos + 1];
|
|
||||||
((uint8_t *)img.tex->data)[dstPos + 3] = ImageBuffer.data()[srcPos + 0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RenderD7::DrawImage(C2D_Image img, float x, float y, float scaleX, float scaleY)
|
|
||||||
{
|
|
||||||
return C2D_DrawImageAt(img, x, y, 0.5f, nullptr, scaleX, scaleY);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RenderD7::Image::Draw(float x, float y, float scaleX, float scaleY)
|
|
||||||
{
|
|
||||||
return C2D_DrawImageAt(this->img, x, y, 0.5f, nullptr, scaleX, scaleY);
|
|
||||||
}
|
|
||||||
bool RenderD7::FS::FileExist(const std::string& path)
|
|
||||||
{
|
|
||||||
FILE *test = fopen(path.c_str(), "r");
|
|
||||||
if(test != NULL)
|
|
||||||
{
|
|
||||||
fclose(test);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RenderD7::IsNdspInit()
|
|
||||||
{
|
|
||||||
if (isndspinit)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::DrawList1(RenderD7::ScrollList1 &l, float txtsize, C3D_RenderTarget *t)
|
|
||||||
{
|
|
||||||
RenderD7::OnScreen(t);
|
|
||||||
RenderD7::DrawRect(0, 0, 400, 240, RenderD7::Color::Hex("#dddddd"));
|
|
||||||
RenderD7::DrawText(0, 0, 0.8f, RenderD7::Color::Hex("#ffffff"), l.Text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::DrawMetrikOvl()
|
|
||||||
{
|
|
||||||
switch (mt_screen)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
RenderD7::OnScreen(Top);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
RenderD7::OnScreen(Bottom);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
RenderD7::OnScreen(Bottom);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
RenderD7::DrawText(0, 0, mt_txtSize, mt_txtcolor, "FPS: " + RenderD7::GetFramerate());
|
|
||||||
RenderD7::DrawText(0, 50, mt_txtSize, mt_txtcolor, "CPU: " + std::to_string(C3D_GetProcessingTime()*6.0f) + "%/" + std::to_string(C3D_GetProcessingTime()));
|
|
||||||
RenderD7::DrawText(0, 70, mt_txtSize, mt_txtcolor, "GPU: " + std::to_string(C3D_GetDrawingTime()*6.0f) + "%/" + std::to_string(C3D_GetDrawingTime()));
|
|
||||||
RenderD7::DrawText(0, 90, mt_txtSize, mt_txtcolor, "CMD: " + std::to_string(C3D_GetCmdBufUsage()*100.0f) + "%/" + std::to_string(C3D_GetCmdBufUsage()));
|
|
||||||
for (int z = 0; z < 320; z++)
|
|
||||||
{
|
|
||||||
C2D_DrawLine(z, 239 - mt_fpsgraph[z], mt_txtcolor, z + 1, 239 - mt_fpsgraph[z + 1], mt_txtcolor, 1, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RenderD7::DrawNFRect(float p1x, float p1y, float w, float h, u32 color, float scale)
|
|
||||||
{
|
|
||||||
C2D_DrawLine(p1x, p1y, color,w, p1y, color, scale, 1);
|
|
||||||
C2D_DrawLine(w, p1y, color,w, h, color, scale, 1);
|
|
||||||
C2D_DrawLine(w, h, color,p1x, h, color, scale, 1);
|
|
||||||
C2D_DrawLine(p1x, h, color,p1x, p1y, color, scale, 1);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::FrameEnd()
|
|
||||||
{
|
|
||||||
if (metrikd)RenderD7::DrawMetrikOvl();
|
|
||||||
/*for (int i = 0; i < (int)overlays.size(); i++)
|
|
||||||
{
|
|
||||||
overlays[i].Draw();
|
|
||||||
}*/
|
|
||||||
if (d7_hHeld & KEY_L && d7_hHeld & KEY_R && d7_hDown & KEY_Y)
|
|
||||||
{
|
|
||||||
RenderD7::LoadSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
C3D_FrameEnd(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
RenderD7::RSettings::RSettings()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
RenderD7::RSettings::~RSettings()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::RSettings::Draw(void) const
|
|
||||||
{
|
|
||||||
std::string metkkkkk = "Metrik: " + metrikd ? "true" : "false";
|
|
||||||
RenderD7::OnScreen(Top);
|
|
||||||
RenderD7::DrawRect(0, 0, 400, 20, RenderD7::Color::Hex("#111111"));
|
|
||||||
RenderD7::DrawRect(0, 20, 400, 220, RenderD7::Color::Hex("#eeeeee"));
|
|
||||||
RenderD7::DrawText(0, 0, 0.7f, DSEVENWHITE, "RenderD7->Settings");
|
|
||||||
RenderD7::DrawText(0, 22, 0.7f, DSEVENBLACK, metkkkkk);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::RSettings::Logic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (d7_hDown & KEY_B)
|
|
||||||
{
|
|
||||||
RenderD7::Scene::Back();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::LoadSettings(){
|
|
||||||
RenderD7::Scene::Load(std::make_unique<RenderD7::RSettings>());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*void RenderD7::AddOvl(RenderD7::Ovl overlay)
|
|
||||||
{
|
|
||||||
overlays.push_back(overlay);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*RenderD7::Console::Console()
|
|
||||||
{
|
|
||||||
this->x = 0;
|
|
||||||
this->y = 0;
|
|
||||||
this->w = 320;
|
|
||||||
this->h = 240;
|
|
||||||
this->color = {0, 0, 0, 255};
|
|
||||||
}
|
|
||||||
RenderD7::Console::Console(int x, int y, int w, int h, u8 a)
|
|
||||||
{
|
|
||||||
this->x = x;
|
|
||||||
this->y = y;
|
|
||||||
this->w = w;
|
|
||||||
this->h = h;
|
|
||||||
this->color = {0, 0, 0, a};
|
|
||||||
|
|
||||||
}
|
|
||||||
RenderD7::Console::Console(int x, int y, int w, int h, RenderD7::Color::rgba col)
|
|
||||||
{
|
|
||||||
this->x = x;
|
|
||||||
this->y = y;
|
|
||||||
this->w = w;
|
|
||||||
this->h = h;
|
|
||||||
this->color = col;
|
|
||||||
}
|
|
||||||
RenderD7::Console::Console(int x, int y, int w, int h, std::string name, RenderD7::Color::rgba col, RenderD7::Color::rgba barcol, RenderD7::Color::rgba outlinecol)
|
|
||||||
{
|
|
||||||
this->x = x;
|
|
||||||
this->y = y;
|
|
||||||
this->w = w;
|
|
||||||
this->h = h;
|
|
||||||
this->color = col;
|
|
||||||
this->outlinecol = outlinecol;
|
|
||||||
this->barcolor = barcol;
|
|
||||||
this->m_name = name;
|
|
||||||
}
|
|
||||||
RenderD7::Console::~Console()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
void RenderD7::Console::On(C3D_RenderTarget *t_cscreen)
|
|
||||||
{
|
|
||||||
this->cscreen = t_cscreen;
|
|
||||||
}
|
|
||||||
bool RenderD7::Console::Update()
|
|
||||||
{
|
|
||||||
bool dr_sc = true;
|
|
||||||
return dr_sc;
|
|
||||||
}
|
|
||||||
*/
|
|
208
renderd7.hpp
208
renderd7.hpp
@ -1,4 +1,3 @@
|
|||||||
#pragma once
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
#include <citro2d.h>
|
#include <citro2d.h>
|
||||||
#include <citro3d.h>
|
#include <citro3d.h>
|
||||||
@ -6,28 +5,13 @@
|
|||||||
#include <stack>
|
#include <stack>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <random>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include "external/lodepng.h"
|
|
||||||
#include "external/fs.h"
|
|
||||||
#include <codecvt>
|
|
||||||
#include "lang.hpp"
|
|
||||||
#include "parameter.hpp"
|
|
||||||
#include "thread.hpp"
|
|
||||||
#include "ini.hpp"
|
|
||||||
#include "stringtool.hpp"
|
|
||||||
#include "Clock.hpp"
|
|
||||||
|
|
||||||
#define RENDERD7VSTRING "0.6.2"
|
|
||||||
#define CHANGELOG "0.6.2: \n0.6.10: rewrite Threadsystem, Improve framerate\n0.6.02: Fix Code in lang.hpp\nadd Draw Text Left Function.\nadd changelog\n0.6.01: add Threading system."
|
|
||||||
#define DEFAULT_CENTER 0.5f
|
#define DEFAULT_CENTER 0.5f
|
||||||
|
|
||||||
extern C3D_RenderTarget* Top;
|
extern C3D_RenderTarget* Top;
|
||||||
@ -39,76 +23,28 @@ extern u32 d7_hHeld;
|
|||||||
extern u32 d7_hUp;
|
extern u32 d7_hUp;
|
||||||
extern touchPosition d7_touch;
|
extern touchPosition d7_touch;
|
||||||
|
|
||||||
extern std::string dspststus;
|
|
||||||
|
|
||||||
/// RenderD7
|
|
||||||
namespace RenderD7
|
namespace RenderD7
|
||||||
{
|
{
|
||||||
enum kbd{
|
|
||||||
SWKBD,
|
|
||||||
BKBD
|
|
||||||
};
|
|
||||||
enum kbd_type
|
|
||||||
{
|
|
||||||
NUMPAD,
|
|
||||||
STANDARD
|
|
||||||
};
|
|
||||||
/// Set current RenderScreen
|
|
||||||
/// \param target The RenderTarget Top, Bottom
|
|
||||||
void OnScreen(C3D_RenderTarget *target);
|
void OnScreen(C3D_RenderTarget *target);
|
||||||
/** The Spritesheet Class */
|
|
||||||
class Sheet
|
class Sheet
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Construct sheet
|
|
||||||
Sheet();
|
Sheet();
|
||||||
// Deconstruct sheet
|
|
||||||
~Sheet();
|
~Sheet();
|
||||||
/// Load a Sritesheet
|
|
||||||
/// path: Path to the Spritesheet (.t3x)
|
|
||||||
Result Load(const char *path);
|
Result Load(const char *path);
|
||||||
/// Unload the Spritesheet
|
|
||||||
void Free();
|
void Free();
|
||||||
// The Spritesheet
|
|
||||||
C2D_SpriteSheet spritesheet;
|
C2D_SpriteSheet spritesheet;
|
||||||
|
|
||||||
};
|
};
|
||||||
/// Image Class
|
|
||||||
class Image
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Load Image from Png
|
|
||||||
/// path: path to png file
|
|
||||||
void LoadPng(const std::string path);
|
|
||||||
/// Load the Image from buffer
|
|
||||||
/// buffer: the frame buffer
|
|
||||||
void LoadPFromBuffer(const std::vector<u8> &buffer);
|
|
||||||
/// Draw the Image directly
|
|
||||||
/// \param x The x position
|
|
||||||
/// \param y the y position
|
|
||||||
/// \param scaleX x scale from 0.0 to 1.0
|
|
||||||
/// \param scaleY y scale from 0.0 to 1.0
|
|
||||||
bool Draw(float x, float y, float scaleX = 1.0f, float scaleY = 1.0f);
|
|
||||||
/// \brief Get The Image
|
|
||||||
/// \return C2D_Image
|
|
||||||
C2D_Image Get(){return this->img;}
|
|
||||||
/// \img this is the C2D_Image
|
|
||||||
C2D_Image img;
|
|
||||||
/// \loadet whether the image is loadet or not
|
|
||||||
bool loadet = false;
|
|
||||||
};
|
|
||||||
/// Sprite Class
|
|
||||||
class Sprite
|
class Sprite
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// \brief Construct Sprite
|
|
||||||
Sprite();
|
Sprite();
|
||||||
~Sprite();
|
~Sprite();
|
||||||
void FromSheet(RenderD7::Sheet *sheet, size_t index);
|
void FromSheet(RenderD7::Sheet *sheet, size_t index);
|
||||||
void FromImage(RenderD7::Image *img);
|
|
||||||
bool Draw();
|
bool Draw();
|
||||||
void SetCenter(float x, float y);
|
void SetCenter(float x, float y);
|
||||||
void SetPos(float x, float y);
|
void SetPos(float x, float y);
|
||||||
void SetScale(float x, float y);
|
|
||||||
void SetRotation(float rotation);
|
void SetRotation(float rotation);
|
||||||
void Rotate(float speed);
|
void Rotate(float speed);
|
||||||
float getWidth();
|
float getWidth();
|
||||||
@ -119,66 +55,31 @@ namespace RenderD7
|
|||||||
C2D_ImageTint tint;
|
C2D_ImageTint tint;
|
||||||
C2D_Sprite sprite;
|
C2D_Sprite sprite;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Scene {
|
class Scene {
|
||||||
public:
|
public:
|
||||||
static std::stack<std::unique_ptr<Scene>> scenes;
|
static std::stack<std::unique_ptr<Scene>> scenes;
|
||||||
virtual ~Scene() {}
|
virtual ~Scene() {}
|
||||||
virtual void Logic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch) = 0;
|
virtual void Logic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch) = 0;
|
||||||
virtual void Draw() const = 0;
|
virtual void Draw() const = 0;
|
||||||
//virtual void Ovl() const = 0;
|
|
||||||
static void Load(std::unique_ptr<Scene> scene);
|
static void Load(std::unique_ptr<Scene> scene);
|
||||||
static void Back();
|
static void Back();
|
||||||
static void doDraw();
|
static void doDraw();
|
||||||
static void doLogic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch);
|
static void doLogic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch);
|
||||||
//static void HandleOvl();
|
|
||||||
};
|
|
||||||
|
|
||||||
class RSettings : public RenderD7::Scene
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
/* data */
|
|
||||||
public:
|
|
||||||
RSettings();
|
|
||||||
void Draw(void) const override;
|
|
||||||
~RSettings();
|
|
||||||
void Logic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void LoadSettings();
|
|
||||||
|
|
||||||
/*class Ovl {
|
|
||||||
public:
|
|
||||||
virtual ~Ovl(){}
|
|
||||||
virtual void Draw() const = 0;
|
|
||||||
};
|
|
||||||
void AddOvl(RenderD7::Ovl overlay);*/
|
|
||||||
namespace Color
|
namespace Color
|
||||||
{
|
{
|
||||||
struct rgba
|
|
||||||
{
|
|
||||||
u8 r, g, b, a;
|
|
||||||
};
|
|
||||||
class RGBA{
|
|
||||||
public:
|
|
||||||
RGBA(u8 r, u8 g, u8 b, u8 a) : m_r(r),m_g(g),m_b(b),m_a(a){}
|
|
||||||
u32 toRGBA() const {return (m_r << 24) | (m_g << 16) | (m_b << 8) | m_a;}
|
|
||||||
|
|
||||||
u8 m_r, m_g ,m_b, m_a;
|
|
||||||
};
|
|
||||||
u32 Hex(const std::string color, u8 a = 255);
|
u32 Hex(const std::string color, u8 a = 255);
|
||||||
}
|
}
|
||||||
int GetRandomInt(int b, int e);
|
|
||||||
void DrawMetrikOvl();
|
|
||||||
bool DrawImageFromSheet(RenderD7::Sheet* sheet, size_t index, float x, float y, float scaleX = 1.0, float scaleY = 1.0);
|
bool DrawImageFromSheet(RenderD7::Sheet* sheet, size_t index, float x, float y, float scaleX = 1.0, float scaleY = 1.0);
|
||||||
namespace Error
|
namespace Error
|
||||||
{
|
{
|
||||||
void DisplayError(std::string toptext, std::string errortext, int timesec);
|
void DisplayError(std::string toptext, std::string errortext);
|
||||||
void DisplayFatalError(std::string toptext, std::string errortext);
|
void DisplayFatalError(std::string toptext, std::string errortext);
|
||||||
}
|
}
|
||||||
namespace Init
|
namespace Init
|
||||||
{
|
{
|
||||||
Result Main(std::string app_name = "RD7Game");
|
Result Main();
|
||||||
void NdspFirm(bool useit = false);
|
void NdspFirm(bool useit = false);
|
||||||
}
|
}
|
||||||
namespace Exit
|
namespace Exit
|
||||||
@ -188,21 +89,10 @@ namespace RenderD7
|
|||||||
}
|
}
|
||||||
namespace Msg
|
namespace Msg
|
||||||
{
|
{
|
||||||
void Display(std::string titletxt, std::string subtext, C3D_RenderTarget *target);
|
void Display(std::string titletxt, std::string, C3D_RenderTarget *target);
|
||||||
void DisplayWithProgress(std::string titletext, std::string subtext, float current, float total, u32 prgbarcolor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Convert
|
|
||||||
{
|
|
||||||
inline float StringtoFloat(std::string inp){return std::atof(inp.c_str());}
|
|
||||||
inline int StringtoInt(std::string inp){return std::atoi(inp.c_str());}
|
|
||||||
inline bool FloatToBool(float inp){if(inp == 1)return true; else return false;}
|
|
||||||
}
|
|
||||||
namespace FS
|
|
||||||
{
|
|
||||||
bool FileExist(const std::string& path);
|
|
||||||
}
|
|
||||||
bool IsNdspInit();
|
|
||||||
void SetupLog(void);
|
void SetupLog(void);
|
||||||
std::string GetFramerate();
|
std::string GetFramerate();
|
||||||
bool MainLoop();
|
bool MainLoop();
|
||||||
@ -211,22 +101,19 @@ namespace RenderD7
|
|||||||
void ClearTextBufs(void);
|
void ClearTextBufs(void);
|
||||||
|
|
||||||
bool DrawRect(float x, float y, float w, float h, u32 color);
|
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 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 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);
|
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);
|
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);
|
float GetTextHeight(float size, std::string Text, C2D_Font fnt = nullptr);
|
||||||
Result loadFont(C2D_Font &fnt, const char * Path = "");
|
Result loadFont(C2D_Font &fnt, const char * Path = "");
|
||||||
Result unloadFont(C2D_Font &fnt);
|
Result unloadFont(C2D_Font &fnt);
|
||||||
bool DrawCircle(float x, float y, float radius, u32 color);
|
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();
|
|
||||||
|
|
||||||
class SpriteSheetAnimation : public RenderD7::Sprite
|
class SpriteSheetAnimation : public RenderD7::Sprite
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SpriteSheetAnimation();
|
SpriteSheetAnimation();
|
||||||
~SpriteSheetAnimation();
|
~SpriteSheetAnimation();
|
||||||
@ -238,87 +125,34 @@ namespace RenderD7
|
|||||||
float D_totaltime;
|
float D_totaltime;
|
||||||
RenderD7::Sheet *sheet;
|
RenderD7::Sheet *sheet;
|
||||||
float time;
|
float time;
|
||||||
|
|
||||||
};
|
};
|
||||||
struct TObject
|
struct TObject
|
||||||
{
|
{
|
||||||
int x; //Position X
|
int x;
|
||||||
int y; //Position Y
|
int y;
|
||||||
int w; //Button Width
|
int w;
|
||||||
int h; //Button Height
|
int h;
|
||||||
std::string text = ""; //Text
|
std::string text = "";
|
||||||
float correctx = 0; //Correct X Position
|
float correctx = 0;
|
||||||
float correcty = 0; //Correct Y Position
|
float correcty = 0;
|
||||||
float txtsize = 0.7f; //Set Text Size
|
float txtsize = 0.7f;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TLBtn
|
|
||||||
{
|
|
||||||
int x; //Position X
|
|
||||||
int y; //Position Y
|
|
||||||
int w; //Button Width
|
|
||||||
int h; //Button Height
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ScrollList1
|
|
||||||
{
|
|
||||||
std::string Text = "";
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ScrollList2
|
|
||||||
{
|
|
||||||
float x;
|
|
||||||
float y;
|
|
||||||
float w;
|
|
||||||
float h;
|
|
||||||
std::string Text = "";
|
|
||||||
};
|
|
||||||
/*enum ListType
|
|
||||||
{
|
|
||||||
ONE,
|
|
||||||
TWO
|
|
||||||
};*/
|
|
||||||
void DrawList1(RenderD7::ScrollList1 &l, float txtsize, C3D_RenderTarget *t);
|
|
||||||
void DrawTObjects(std::vector<RenderD7::TObject> tobjects, u32 color, u32 txtcolor, int selection = -1, u32 selbgcolor = RenderD7::Color::Hex("#2D98AF"), u32 selcolor = RenderD7::Color::Hex("#000000"));
|
void DrawTObjects(std::vector<RenderD7::TObject> tobjects, u32 color, u32 txtcolor, int selection = -1, u32 selbgcolor = RenderD7::Color::Hex("#2D98AF"), u32 selcolor = RenderD7::Color::Hex("#000000"));
|
||||||
void DrawSTObject(std::vector<RenderD7::TObject> tobject, int tobjectindex, u32 color, u32 txtcolor);
|
void DrawSTObject(std::vector<RenderD7::TObject> tobject, int tobjectindex, u32 color, u32 txtcolor);
|
||||||
bool touchTObj(touchPosition touch, RenderD7::TObject button);
|
bool touchTObj(touchPosition touch, RenderD7::TObject button);
|
||||||
void DrawTLBtns(std::vector<RenderD7::TLBtn> btns, u32 color, int selection = -1, u32 selbgcolor = RenderD7::Color::Hex("#2D98AF"), u32 selcolor = RenderD7::Color::Hex("#000000"));
|
|
||||||
struct DirContent
|
struct DirContent
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string path;
|
std::string path;
|
||||||
bool isDir;
|
bool isDir;
|
||||||
};
|
};
|
||||||
struct Checkbox
|
|
||||||
{
|
|
||||||
float x, y, s;
|
|
||||||
bool is_chexked = false;
|
|
||||||
u32 outcol, incol, chcol;
|
|
||||||
};
|
|
||||||
void DrawCheckbox(Checkbox box);
|
|
||||||
/*class Console
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Console();
|
|
||||||
Console(int x, int y, int w, int h, int a = 255);
|
|
||||||
Console(int x, int y, int w, int h, RenderD7::Color::rgba col);
|
|
||||||
Console(int x, int y, int w, int h, std::string name, RenderD7::Color::rgba col = {255, 255, 255, 255}, RenderD7::Color::rgba barcol = {0, 0, 0, 255}, RenderD7::Color::rgba outlinecol = {222, 222, 222, 255});
|
|
||||||
void On(C3D_RenderTarget *t_cscreen);
|
|
||||||
bool Update();
|
|
||||||
~Console();
|
|
||||||
private:
|
|
||||||
std::vector<std::string> m_lines;
|
|
||||||
int x, y, w, h;
|
|
||||||
std::string m_name = "";
|
|
||||||
C3D_RenderTarget *cscreen;
|
|
||||||
bool m_nconsole = false;
|
|
||||||
bool m_mconsole = false;
|
|
||||||
RenderD7::Color::rgba color = {255, 255, 255, 255};
|
|
||||||
RenderD7::Color::rgba outlinecol = {222, 222, 222, 255};
|
|
||||||
RenderD7::Color::rgba barcolor = {0, 0, 0, 255};
|
|
||||||
};*/
|
|
||||||
|
|
||||||
bool NameIsEndingWith(const std::string &name, const std::vector<std::string> &extensions);
|
bool NameIsEndingWith(const std::string &name, const std::vector<std::string> &extensions);
|
||||||
void GetDirContentsExt(std::vector<RenderD7::DirContent> &dircontent, const std::vector<std::string> &extensions);
|
void GetDirContentsExt(std::vector<RenderD7::DirContent> &dircontent, const std::vector<std::string> &extensions);
|
||||||
void GetDirContents(std::vector<RenderD7::DirContent> &dircontent);
|
void GetDirContents(std::vector<RenderD7::DirContent> &dircontent);
|
||||||
|
|
||||||
} /// RenderD7
|
|
||||||
|
}
|
15
sound.cpp
15
sound.cpp
@ -5,7 +5,6 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
extern bool isndspinit;
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
// Reference: http://yannesposito.com/Scratch/en/blog/2010-10-14-Fun-with-wav/
|
// Reference: http://yannesposito.com/Scratch/en/blog/2010-10-14-Fun-with-wav/
|
||||||
@ -26,7 +25,6 @@ typedef struct _WavHeader {
|
|||||||
static_assert(sizeof(WavHeader) == 44, "WavHeader size is not 44 bytes.");
|
static_assert(sizeof(WavHeader) == 44, "WavHeader size is not 44 bytes.");
|
||||||
|
|
||||||
sound::sound(const string& path, int channel, bool toloop) {
|
sound::sound(const string& path, int channel, bool toloop) {
|
||||||
if (isndspinit){
|
|
||||||
ndspSetOutputMode(NDSP_OUTPUT_STEREO);
|
ndspSetOutputMode(NDSP_OUTPUT_STEREO);
|
||||||
ndspSetOutputCount(2); // Num of buffers
|
ndspSetOutputCount(2); // Num of buffers
|
||||||
|
|
||||||
@ -100,11 +98,10 @@ sound::sound(const string& path, int channel, bool toloop) {
|
|||||||
waveBuf.nsamples = dataSize / (wavHeader.bits_per_sample >> 3);
|
waveBuf.nsamples = dataSize / (wavHeader.bits_per_sample >> 3);
|
||||||
waveBuf.looping = toloop;
|
waveBuf.looping = toloop;
|
||||||
waveBuf.status = NDSP_WBUF_FREE;
|
waveBuf.status = NDSP_WBUF_FREE;
|
||||||
chnl = channel;}
|
chnl = channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
sound::~sound() {
|
sound::~sound() {
|
||||||
if (isndspinit){
|
|
||||||
waveBuf.data_vaddr = 0;
|
waveBuf.data_vaddr = 0;
|
||||||
waveBuf.nsamples = 0;
|
waveBuf.nsamples = 0;
|
||||||
waveBuf.looping = false;
|
waveBuf.looping = false;
|
||||||
@ -113,18 +110,16 @@ sound::~sound() {
|
|||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
linearFree(data);
|
linearFree(data);
|
||||||
}}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sound::play() {
|
void sound::play() {
|
||||||
if (isndspinit){
|
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
DSP_FlushDataCache(data, dataSize);
|
DSP_FlushDataCache(data, dataSize);
|
||||||
ndspChnWaveBufAdd(chnl, &waveBuf);}
|
ndspChnWaveBufAdd(chnl, &waveBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sound::stop() {
|
void sound::stop() {
|
||||||
if (isndspinit){
|
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
ndspChnWaveBufClear(chnl);}
|
ndspChnWaveBufClear(chnl);
|
||||||
}
|
}
|
12
sound.hpp
12
sound.hpp
@ -1,21 +1,14 @@
|
|||||||
#pragma once
|
#ifndef _UNIVERSAL_UPDATER_SOUND_H
|
||||||
|
#define _UNIVERSAL_UPDATER_SOUND_H
|
||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
/** Sound Class */
|
|
||||||
class sound {
|
class sound {
|
||||||
public:
|
public:
|
||||||
/// \brief Construct new Soundeffect
|
|
||||||
/// \param path Path to the .wav file
|
|
||||||
/// \param channel the channel 1-23
|
|
||||||
/// \param toloop true:loop the sound, false: don't loop
|
|
||||||
sound(const std::string& path, int channel = 1, bool toloop = false);
|
sound(const std::string& path, int channel = 1, bool toloop = false);
|
||||||
/** deconstruct the sound */
|
|
||||||
~sound();
|
~sound();
|
||||||
/** play the sound */
|
|
||||||
void play();
|
void play();
|
||||||
/** stop the sound */
|
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -25,3 +18,4 @@ private:
|
|||||||
int chnl;
|
int chnl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -1,11 +0,0 @@
|
|||||||
//rd7cc
|
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
std::ofstream result ("result.hpp");
|
|
||||||
|
|
||||||
result << "//Result" << std::endl;
|
|
||||||
|
|
||||||
result.close();
|
|
||||||
}
|
|
Reference in New Issue
Block a user