0.9.5 preview1
This commit is contained in:
parent
a671631dde
commit
168614d579
259
.clang-format
Normal file
259
.clang-format
Normal file
@ -0,0 +1,259 @@
|
|||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
# BasedOnStyle: Google
|
||||||
|
AccessModifierOffset: -1
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignArrayOfStructures: None
|
||||||
|
AlignConsecutiveAssignments:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
PadOperators: true
|
||||||
|
AlignConsecutiveBitFields:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveDeclarations:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveMacros:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignEscapedNewlines: Left
|
||||||
|
AlignOperands: Align
|
||||||
|
AlignTrailingComments:
|
||||||
|
Kind: Always
|
||||||
|
OverEmptyLines: 0
|
||||||
|
AllowAllArgumentsOnNextLine: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortEnumsOnASingleLine: true
|
||||||
|
AllowShortFunctionsOnASingleLine: All
|
||||||
|
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortLoopsOnASingleLine: true
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: true
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
AttributeMacros:
|
||||||
|
- __capability
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BitFieldColonSpacing: Both
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: Never
|
||||||
|
AfterEnum: false
|
||||||
|
AfterExternBlock: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
BeforeLambdaBody: false
|
||||||
|
BeforeWhile: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
SplitEmptyNamespace: true
|
||||||
|
BreakAfterAttributes: Never
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakArrays: true
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeConceptDeclarations: Always
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeInlineASMColon: OnlyMultiline
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializers: BeforeColon
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 80
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: true
|
||||||
|
DisableFormat: false
|
||||||
|
EmptyLineAfterAccessModifier: Never
|
||||||
|
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
ForEachMacros:
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IfMacros:
|
||||||
|
- KJ_IF_MAYBE
|
||||||
|
IncludeBlocks: Regroup
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^<ext/.*\.h>'
|
||||||
|
Priority: 2
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: '^<.*\.h>'
|
||||||
|
Priority: 1
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: '^<.*'
|
||||||
|
Priority: 2
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 3
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
||||||
|
IncludeIsMainSourceRegex: ''
|
||||||
|
IndentAccessModifiers: false
|
||||||
|
IndentCaseBlocks: false
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentExternBlock: AfterExternBlock
|
||||||
|
IndentGotoLabels: true
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentRequiresClause: true
|
||||||
|
IndentWidth: 2
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
InsertBraces: false
|
||||||
|
InsertNewlineAtEOF: false
|
||||||
|
InsertTrailingCommas: None
|
||||||
|
IntegerLiteralSeparator:
|
||||||
|
Binary: 0
|
||||||
|
BinaryMinDigits: 0
|
||||||
|
Decimal: 0
|
||||||
|
DecimalMinDigits: 0
|
||||||
|
Hex: 0
|
||||||
|
HexMinDigits: 0
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
LambdaBodyIndentation: Signature
|
||||||
|
LineEnding: DeriveLF
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: None
|
||||||
|
ObjCBinPackProtocolList: Never
|
||||||
|
ObjCBlockIndentWidth: 2
|
||||||
|
ObjCBreakBeforeNestedBlockParam: true
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PackConstructorInitializers: NextLine
|
||||||
|
PenaltyBreakAssignment: 2
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 1
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakOpenParenthesis: 0
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyIndentedWhitespace: 0
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 200
|
||||||
|
PointerAlignment: Left
|
||||||
|
PPIndentWidth: -1
|
||||||
|
QualifierAlignment: Leave
|
||||||
|
RawStringFormats:
|
||||||
|
- Language: Cpp
|
||||||
|
Delimiters:
|
||||||
|
- cc
|
||||||
|
- CC
|
||||||
|
- cpp
|
||||||
|
- Cpp
|
||||||
|
- CPP
|
||||||
|
- 'c++'
|
||||||
|
- 'C++'
|
||||||
|
CanonicalDelimiter: ''
|
||||||
|
BasedOnStyle: google
|
||||||
|
- Language: TextProto
|
||||||
|
Delimiters:
|
||||||
|
- pb
|
||||||
|
- PB
|
||||||
|
- proto
|
||||||
|
- PROTO
|
||||||
|
EnclosingFunctions:
|
||||||
|
- EqualsProto
|
||||||
|
- EquivToProto
|
||||||
|
- PARSE_PARTIAL_TEXT_PROTO
|
||||||
|
- PARSE_TEST_PROTO
|
||||||
|
- PARSE_TEXT_PROTO
|
||||||
|
- ParseTextOrDie
|
||||||
|
- ParseTextProtoOrDie
|
||||||
|
- ParseTestProto
|
||||||
|
- ParsePartialTestProto
|
||||||
|
CanonicalDelimiter: pb
|
||||||
|
BasedOnStyle: google
|
||||||
|
ReferenceAlignment: Pointer
|
||||||
|
ReflowComments: true
|
||||||
|
RemoveBracesLLVM: false
|
||||||
|
RemoveSemicolon: false
|
||||||
|
RequiresClausePosition: OwnLine
|
||||||
|
RequiresExpressionIndentation: OuterScope
|
||||||
|
SeparateDefinitionBlocks: Leave
|
||||||
|
ShortNamespaceLines: 1
|
||||||
|
SortIncludes: CaseSensitive
|
||||||
|
SortJavaStaticImport: Before
|
||||||
|
SortUsingDeclarations: LexicographicNumeric
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceAroundPointerQualifiers: Default
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCaseColon: false
|
||||||
|
SpaceBeforeCpp11BracedList: false
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeParensOptions:
|
||||||
|
AfterControlStatements: true
|
||||||
|
AfterForeachMacros: true
|
||||||
|
AfterFunctionDefinitionName: false
|
||||||
|
AfterFunctionDeclarationName: false
|
||||||
|
AfterIfMacros: true
|
||||||
|
AfterOverloadedOperator: false
|
||||||
|
AfterRequiresInClause: false
|
||||||
|
AfterRequiresInExpression: false
|
||||||
|
BeforeNonEmptyParentheses: false
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceBeforeSquareBrackets: false
|
||||||
|
SpaceInEmptyBlock: false
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 2
|
||||||
|
SpacesInAngles: Never
|
||||||
|
SpacesInConditionalStatement: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInLineCommentPrefix:
|
||||||
|
Minimum: 1
|
||||||
|
Maximum: -1
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Auto
|
||||||
|
StatementAttributeLikeMacros:
|
||||||
|
- Q_EMIT
|
||||||
|
StatementMacros:
|
||||||
|
- Q_UNUSED
|
||||||
|
- QT_REQUIRE_VERSION
|
||||||
|
TabWidth: 8
|
||||||
|
UseTab: Never
|
||||||
|
WhitespaceSensitiveMacros:
|
||||||
|
- BOOST_PP_STRINGIZE
|
||||||
|
- CF_SWIFT_NAME
|
||||||
|
- NS_SWIFT_NAME
|
||||||
|
- PP_STRINGIZE
|
||||||
|
- STRINGIZE
|
||||||
|
...
|
||||||
|
|
50
.github/workflows/Docs.yml
vendored
50
.github/workflows/Docs.yml
vendored
@ -1,50 +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: |
|
|
||||||
git config --global user.email "tobid7@outlook.de"
|
|
||||||
git config --global user.name "Tobi-D7"
|
|
||||||
sudo apt-get install doxygen cmake -y
|
|
||||||
doxygen
|
|
||||||
echo done
|
|
||||||
ls -r
|
|
||||||
cd ..
|
|
||||||
git clone --depth 1 https://${{ secrets.TOKEN }}@github.com/NPI-D7/RenderD7.git RD7 -b gh-pages
|
|
||||||
|
|
||||||
mv -v RenderD7/doc/html/* RD7/
|
|
||||||
#rm -r doc
|
|
||||||
cd RD7
|
|
||||||
|
|
||||||
echo tobid7
|
|
||||||
git stage *
|
|
||||||
|
|
||||||
echo staged
|
|
||||||
git commit -m "Documentation1"
|
|
||||||
git tag doc
|
|
||||||
echo commited
|
|
||||||
git push origin gh-pages
|
|
||||||
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
|
|
14
.gitignore
vendored
14
.gitignore
vendored
@ -1,4 +1,12 @@
|
|||||||
release/
|
|
||||||
debug/
|
|
||||||
lib/
|
|
||||||
*.bz2
|
*.bz2
|
||||||
|
rd7le/
|
||||||
|
*.DS_Store*
|
||||||
|
rd7tf/build
|
||||||
|
rd7tf/rd7tf.*
|
||||||
|
|
||||||
|
# DOCS
|
||||||
|
docs/*
|
||||||
|
!docs/javascripts
|
||||||
|
!docs/overrides
|
||||||
|
!docs/stylesheets
|
||||||
|
site/*
|
115
.vscode/launch.json
vendored
Normal file
115
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "(gdb) Launch",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/rd7tf/rd7tf.elf",
|
||||||
|
"targetArchitecture": "arm",
|
||||||
|
"serverLaunchTimeout": 10000,
|
||||||
|
"stopAtEntry": true,
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": true,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "/opt/devkitPro/devkitARM/bin/arm-none-eabi-gdb",
|
||||||
|
"miDebuggerServerAddress": "192.168.2.220:4003",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing",
|
||||||
|
"text": "file ${workspaceFolder}/rd7tf/rd7tf.elf -enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "(gdb-emu) Launch",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/rd7tf/rd7tf.elf",
|
||||||
|
"targetArchitecture": "arm",
|
||||||
|
"serverLaunchTimeout": 10000,
|
||||||
|
"stopAtEntry": true,
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": true,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "/opt/devkitPro/devkitARM/bin/arm-none-eabi-gdb",
|
||||||
|
"miDebuggerServerAddress": "localhost:4003",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing",
|
||||||
|
"text": "file ${workspaceFolder}/rd7tf/rd7tf.elf -enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "(gdb-emu) lua",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/rd7le/rd7le.elf",
|
||||||
|
"targetArchitecture": "arm",
|
||||||
|
"serverLaunchTimeout": 10000,
|
||||||
|
"stopAtEntry": true,
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": true,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "C:\\devkitPro\\devkitARM\\bin\\arm-none-eabi-gdb.exe",
|
||||||
|
"miDebuggerServerAddress": "localhost:4003",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing",
|
||||||
|
"text": "file ${workspaceFolder}/rd7le/rd7le.elf -enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "(gdb) lua",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/rd7le/rd7le.elf",
|
||||||
|
"targetArchitecture": "arm",
|
||||||
|
"serverLaunchTimeout": 10000,
|
||||||
|
"stopAtEntry": true,
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": true,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "C:\\devkitPro\\devkitARM\\bin\\arm-none-eabi-gdb.exe",
|
||||||
|
"miDebuggerServerAddress": "192.168.2.220:4003",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing",
|
||||||
|
"text": "file ${workspaceFolder}/rd7le/rd7le.elf -enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "(gdb) testgame",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/testgame/testgame.elf",
|
||||||
|
"targetArchitecture": "arm",
|
||||||
|
"serverLaunchTimeout": 10000,
|
||||||
|
"stopAtEntry": true,
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": true,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "C:\\devkitPro\\devkitARM\\bin\\arm-none-eabi-gdb.exe",
|
||||||
|
"miDebuggerServerAddress": "localhost:4003",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing",
|
||||||
|
"text": "file ${workspaceFolder}/testgame/testgame.elf -enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
18
.vscode/settings.json
vendored
18
.vscode/settings.json
vendored
@ -97,6 +97,22 @@
|
|||||||
"cfenv": "cpp",
|
"cfenv": "cpp",
|
||||||
"cinttypes": "cpp",
|
"cinttypes": "cpp",
|
||||||
"typeindex": "cpp",
|
"typeindex": "cpp",
|
||||||
"variant": "cpp"
|
"variant": "cpp",
|
||||||
|
"ranges": "cpp",
|
||||||
|
"span": "cpp",
|
||||||
|
"coroutine": "cpp",
|
||||||
|
"__bit_reference": "cpp",
|
||||||
|
"__config": "cpp",
|
||||||
|
"__debug": "cpp",
|
||||||
|
"__errc": "cpp",
|
||||||
|
"__hash_table": "cpp",
|
||||||
|
"__locale": "cpp",
|
||||||
|
"__mutex_base": "cpp",
|
||||||
|
"__node_handle": "cpp",
|
||||||
|
"__split_buffer": "cpp",
|
||||||
|
"__threading_support": "cpp",
|
||||||
|
"__tree": "cpp",
|
||||||
|
"__verbose_abort": "cpp",
|
||||||
|
"complex": "cpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
104
CHANGELOG.md
Normal file
104
CHANGELOG.md
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
# RenderD7 Changelog
|
||||||
|
## 0.9.5
|
||||||
|
- Remove Npi Intro and NVID Api
|
||||||
|
- Replace Toasts System with Message
|
||||||
|
- Lots of Optimisations
|
||||||
|
- Added GetTime
|
||||||
|
- Implement Draw2 Api
|
||||||
|
- Implement RD7Color and R7Vec2
|
||||||
|
- Add new Features to Color::RGBA
|
||||||
|
- Cleanup Code
|
||||||
|
- Added RenderD7 Keyboard (Overlay)
|
||||||
|
- Added Ftrace Overlay
|
||||||
|
- Moved MetrikOVL into an Overlay
|
||||||
|
- Removed Old Font/Text Handlers
|
||||||
|
- Added UI7 (New UI Api)
|
||||||
|
- Remove Old UI Api
|
||||||
|
- Added Music Player (MP3, Vorbis)
|
||||||
|
- Rewrite of RenderD7::Image
|
||||||
|
- Internal Debugger/Database (IDB)
|
||||||
|
- Removed BitmapPrinter
|
||||||
|
- Added nimg and nimg_engine
|
||||||
|
- Removed Old Error/Message Handler
|
||||||
|
- GetTextSize (extra buffer) + New TextShorter
|
||||||
|
- Require specific FLAG for Music/MemTrack
|
||||||
|
- Replace all lodepng usage by stb_image
|
||||||
|
- Move Asset Generator into single python script
|
||||||
|
- Remove INI reader
|
||||||
|
- Python based clangformat script
|
||||||
|
- Move some Init code into functions to not use twice
|
||||||
|
## 0.9.4
|
||||||
|
- Implement new Security System To prevent from crashes
|
||||||
|
- Implement Functiontrace for better Timing Tests
|
||||||
|
- Implement MemAlloc Tracker (only size)
|
||||||
|
- Add some new Overlays (not functional yet)
|
||||||
|
- Complete Rewrite of Overlay System
|
||||||
|
- Fixed the FrameEnd Crash
|
||||||
|
- New System to get Hardware Info
|
||||||
|
- Removed RenderD7 Super Reselution (800px mode)
|
||||||
|
## 0.9.3
|
||||||
|
- Completly Documented Everything
|
||||||
|
- Fix typo in Sprite::getHeight
|
||||||
|
- Remove Deprecated/Useless Stuff
|
||||||
|
## 0.9.2
|
||||||
|
- Add Nvid Support(v0.0.1)
|
||||||
|
- Add Basic RenderD7 Splash
|
||||||
|
- Faster Graphics Init
|
||||||
|
- Fade Effects
|
||||||
|
- Fix Changelog Screen
|
||||||
|
## 0.9.1
|
||||||
|
- Fix Critical bug in Spritesheet animations
|
||||||
|
- Fix RenderD7::Color::Hex (Major performance tweak)
|
||||||
|
## 0.9.0
|
||||||
|
- Remove Stupid try of Console
|
||||||
|
- Add Services list
|
||||||
|
- Clean up Code
|
||||||
|
- Added Minimal Init for hax2.x
|
||||||
|
## 0.8.5
|
||||||
|
- Fix Deltatime
|
||||||
|
## 0.8.4
|
||||||
|
- A lot of Fixes
|
||||||
|
- New Features for BitmapPrinter
|
||||||
|
## 0.8.3
|
||||||
|
- Added Overlaycount to Info
|
||||||
|
- Addet ResultDecoder for errors
|
||||||
|
## 0.8.2
|
||||||
|
- Fix a lot of Stuff
|
||||||
|
- Use c++17 std::filesystem for RenderD7::Filesystem
|
||||||
|
## 0.8.1
|
||||||
|
- Add abillity to Get Stdout as string to render it to the screen.
|
||||||
|
## 0.8.0
|
||||||
|
- Implement BitmapPrinter
|
||||||
|
## 0.7.3
|
||||||
|
- Implement Over Render Overlay Framework
|
||||||
|
## 0.7.2
|
||||||
|
- Implement MT to csv file saving
|
||||||
|
- Add RGB2HEX
|
||||||
|
## 0.7.1
|
||||||
|
- Add the New Overlay Handler. Its Just in code and does nothing yet
|
||||||
|
## 0.7.0
|
||||||
|
- Made Big Progress In the MT Ovl but it still crashes On a 2nd C3D_FrameEnd \
|
||||||
|
- Implement 800px but doesn't work that good
|
||||||
|
## 0.6.2
|
||||||
|
- Fix Crash when exiting through Home Menu.
|
||||||
|
## 0.6.10
|
||||||
|
- Rewrite Threadsystem
|
||||||
|
- Improve framerate
|
||||||
|
## 0.6.02
|
||||||
|
- Fix Code in lang.hpp
|
||||||
|
- Add Draw Text Left Function (Right since 0.7.0)
|
||||||
|
- Add changelog
|
||||||
|
## 0.6.01
|
||||||
|
- Add Threading system
|
||||||
|
## 0.6.0
|
||||||
|
- Better Scene Management
|
||||||
|
## 0.5.0
|
||||||
|
- Fixed some Bugs!
|
||||||
|
## 0.4.0
|
||||||
|
- Trying to fix Filesystem and Bugs
|
||||||
|
## 0.3.0
|
||||||
|
- Recreate D7-Core into RenderD7
|
||||||
|
## 0.2.0
|
||||||
|
- Trying to create Animations of Images instead of Sheets
|
||||||
|
## 0.1.0
|
||||||
|
- Inital Release of D7-Core sprite animation plugin
|
201
Makefile
201
Makefile
@ -1,201 +0,0 @@
|
|||||||
#---------------------------------------------------------------------------------
|
|
||||||
.SUFFIXES:
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITARM)),)
|
|
||||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
|
||||||
endif
|
|
||||||
|
|
||||||
include $(DEVKITARM)/3ds_rules
|
|
||||||
|
|
||||||
export renderd7_MAJOR := 0
|
|
||||||
export renderd7_MINOR := 9
|
|
||||||
export renderd7_PATCH := 4
|
|
||||||
|
|
||||||
VERSION := $(renderd7_MAJOR).$(renderd7_MINOR).$(renderd7_PATCH)
|
|
||||||
|
|
||||||
# If on a tagged commit, use the tag instead of the commit
|
|
||||||
ifneq ($(shell echo $(shell git tag -l --points-at HEAD) | head -c 1),)
|
|
||||||
GIT_VER := $(shell git tag -l --points-at HEAD)
|
|
||||||
else
|
|
||||||
GIT_VER := $(shell git rev-parse --short HEAD)
|
|
||||||
endif
|
|
||||||
|
|
||||||
TIME_TIME := $(shell date --iso=seconds)
|
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# TARGET is the name of the output
|
|
||||||
# BUILD is the directory where object files & intermediate files will be placed
|
|
||||||
# SOURCES is a list of directories containing source code
|
|
||||||
# DATA is a list of directories containing data files
|
|
||||||
# INCLUDES is a list of directories containing header files
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
TARGET := renderd7
|
|
||||||
SOURCES := source external/source
|
|
||||||
DATA := data
|
|
||||||
INCLUDES := include
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# options for code generation
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
|
||||||
|
|
||||||
CFLAGS := -g -Wall -Werror -mword-relocations -save-temps\
|
|
||||||
-DV_STRING=\"$(GIT_VER)\" \
|
|
||||||
-DV_TIME=\"$(TIME_TIME)\" \
|
|
||||||
-ffunction-sections -fdata-sections \
|
|
||||||
$(ARCH) $(BUILD_CFLAGS)
|
|
||||||
|
|
||||||
CFLAGS += $(INCLUDE) -D__3DS__ -D_GNU_SOURCE=1
|
|
||||||
|
|
||||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++20
|
|
||||||
|
|
||||||
ASFLAGS := -g $(ARCH) $(DEFINES)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# list of directories containing libraries, this must be the top level containing
|
|
||||||
# include and lib
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
LIBDIRS := $(PORTLIBS) $(CTRULIB)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
|
||||||
# rules for different file extensions
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
|
||||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
|
||||||
|
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
|
||||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
|
||||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
|
||||||
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
|
|
||||||
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
|
|
||||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# use CXX for linking C++ projects, CC for standard C
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
ifeq ($(strip $(CPPFILES)),)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CC)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
export LD := $(CXX)
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
|
||||||
|
|
||||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \
|
|
||||||
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o)
|
|
||||||
|
|
||||||
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
|
|
||||||
|
|
||||||
export HFILES := $(PICAFILES:.v.pica=_shbin.h) $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
|
||||||
|
|
||||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
|
||||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
|
||||||
-I.
|
|
||||||
|
|
||||||
.PHONY: clean all doc
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
all: lib/librenderd7.a lib/librenderd7d.a
|
|
||||||
|
|
||||||
doc:
|
|
||||||
@doxygen Doxyfile
|
|
||||||
|
|
||||||
dist-bin: all
|
|
||||||
@tar --exclude=*~ -cjf $(TARGET).tar.bz2 include lib
|
|
||||||
|
|
||||||
dist-src:
|
|
||||||
@tar --exclude=*~ -cjf $(TARGET)-src.tar.bz2 include $(SOURCES) Makefile
|
|
||||||
|
|
||||||
dist: dist-src dist-bin
|
|
||||||
|
|
||||||
lib:
|
|
||||||
@[ -d $@ ] || mkdir -p $@
|
|
||||||
|
|
||||||
release:
|
|
||||||
@[ -d $@ ] || mkdir -p $@
|
|
||||||
|
|
||||||
debug:
|
|
||||||
@[ -d $@ ] || mkdir -p $@
|
|
||||||
|
|
||||||
|
|
||||||
lib/librenderd7.a : lib release $(SOURCES) $(INCLUDES)
|
|
||||||
@$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \
|
|
||||||
BUILD_CFLAGS="-DNDEBUG=1 -O2 -fomit-frame-pointer" \
|
|
||||||
DEPSDIR=$(CURDIR)/release \
|
|
||||||
--no-print-directory -C release \
|
|
||||||
-f $(CURDIR)/Makefile
|
|
||||||
|
|
||||||
lib/librenderd7d.a : lib debug $(SOURCES) $(INCLUDES)
|
|
||||||
@$(MAKE) BUILD=debug OUTPUT=$(CURDIR)/$@ \
|
|
||||||
BUILD_CFLAGS="-DDEBUG=1 -Og" \
|
|
||||||
DEPSDIR=$(CURDIR)/debug \
|
|
||||||
--no-print-directory -C debug \
|
|
||||||
-f $(CURDIR)/Makefile
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
clean:
|
|
||||||
@echo clean ...
|
|
||||||
@rm -fr release debug lib includes
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
|
||||||
|
|
||||||
DEPENDS := $(OFILES:.o=.d)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# main targets
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(OUTPUT) : $(OFILES)
|
|
||||||
|
|
||||||
$(OFILES_SOURCES) : $(HFILES)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# you need a rule like this for each extension you use as binary data
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
%.bin.o %_bin.h : %.bin
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(bin2o)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# rules for assembling GPU shaders
|
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
define shader-as
|
|
||||||
$(eval CURBIN := $*.shbin)
|
|
||||||
$(eval DEPSFILE := $(DEPSDIR)/$*.shbin.d)
|
|
||||||
echo "$(CURBIN).o: $< $1" > $(DEPSFILE)
|
|
||||||
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
|
|
||||||
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
|
|
||||||
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
|
|
||||||
picasso -o $(CURBIN) $1
|
|
||||||
bin2s $(CURBIN) | $(AS) -o $*.shbin.o
|
|
||||||
endef
|
|
||||||
|
|
||||||
%.shbin.o %_shbin.h : %.v.pica %.g.pica
|
|
||||||
@echo $(notdir $^)
|
|
||||||
@$(call shader-as,$^)
|
|
||||||
|
|
||||||
%.shbin.o %_shbin.h : %.v.pica
|
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(call shader-as,$<)
|
|
||||||
|
|
||||||
%.shbin.o %_shbin.h : %.shlist
|
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)$(file)))
|
|
||||||
|
|
||||||
-include $(DEPENDS)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
46
README.md
46
README.md
@ -1,6 +1,29 @@
|
|||||||
# <img alt="LOGO" src="https://github.com/NPI-D7/RenderD7/blob/main/logo.png" height="90">
|
# <img alt="LOGO" src="https://github.com/NPI-D7/RenderD7/raw/main/logo.png" height="90">
|
||||||
RenderD7 is now LibRenderD7.
|
# RenderD7 as Submodule (0.9.5+)
|
||||||
### Installation
|
To use RenderD7 just use this command: `git submodule add https://github.com/NPI-D7/RenderD7` and add `-b v0.9.5` for example for a specific version.
|
||||||
|
|
||||||
|
|
||||||
|
And in Your Project Makefile add this
|
||||||
|
```
|
||||||
|
# Make Sure to Change this paths if your Submodule
|
||||||
|
# is located somewhere else
|
||||||
|
RENDERD7_SRC := RenderD7/source RenderD7/external
|
||||||
|
RENDERD7_INC := RenderD7/include
|
||||||
|
# Libraries used for RenderD7
|
||||||
|
# if you already use -lm, -lctru etc place a # before -lm
|
||||||
|
RENDERD7_LIBS := -lmpg123 -lvorbisidec -logg -lcurl -lm -lcitro2dd -lcitro3d -lctru
|
||||||
|
RENDERD7_FLAGS := -DRENDERD7_MUSICDEC=1 -DRENDERD7_MEMTRACK=1
|
||||||
|
```
|
||||||
|
Now you need to add it to your sources and includes
|
||||||
|
```
|
||||||
|
SOURCES := source $(RENDERD7_SRC)
|
||||||
|
INCLUDES := source $(RENDERD7_INC)
|
||||||
|
```
|
||||||
|
Finally append `$(RENDERD7_FLAGS)` to your `CFLAGS`
|
||||||
|
|
||||||
|
Example from rd7tf
|
||||||
|
Keep in mind that -DRENDERD7_MUSICDEC=1 requires `-lmpg123 -lvorbisidec -logg`
|
||||||
|
### Installation (0.8.0-0.9.4) (OUTDATED)
|
||||||
Download a Package From Releses Page
|
Download a Package From Releses Page
|
||||||
`https://github.com/NPI-D7/RenderD7/releases/download/v0.9.4/renderd7.tar.bz2 -o renderd7.tar.bz2`
|
`https://github.com/NPI-D7/RenderD7/releases/download/v0.9.4/renderd7.tar.bz2 -o renderd7.tar.bz2`
|
||||||
Then Extract it to your Libraries Path
|
Then Extract it to your Libraries Path
|
||||||
@ -32,23 +55,6 @@ Example-App
|
|||||||
└── src
|
└── src
|
||||||
└── main.cpp
|
└── main.cpp
|
||||||
```
|
```
|
||||||
# Back to Old Usage aka Submodule (0.9.5+)
|
|
||||||
If you want to use RenderD7 as Submodule run
|
|
||||||
`git submodule add https://github.com/NPI-D7/RenderD7`
|
|
||||||
|
|
||||||
And to Use Add this to make file
|
|
||||||
```
|
|
||||||
# Make Sure to Change this paths if your Submodule
|
|
||||||
# is located somewhere else
|
|
||||||
RENDERD7_SRC := RenderD7/source RenderD7/external
|
|
||||||
RENDERD7_INC := RenderD7/include
|
|
||||||
```
|
|
||||||
Now you need to add it to your sources and includes
|
|
||||||
```
|
|
||||||
SOURCES := source $(RENDERD7_SRC)
|
|
||||||
INCLUDES := source $(RENDERD7_INC)
|
|
||||||
```
|
|
||||||
Example from rd7tf
|
|
||||||
# Credits
|
# Credits
|
||||||
- NPI-D7
|
- NPI-D7
|
||||||
- Tobi-D7 Main Dev
|
- Tobi-D7 Main Dev
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
echo "Create Directorys"
|
|
||||||
mkdir -p build
|
|
||||||
mkdir -p code
|
|
||||||
|
|
||||||
echo "Generating Spritesheets"
|
|
||||||
cd resources
|
|
||||||
|
|
||||||
for file in *.t3s
|
|
||||||
do
|
|
||||||
filename=$(basename "$file" .t3s).t3x
|
|
||||||
tex3ds -o "../build/$filename" -i "${file}"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Converting Spritesheets into C++ Code"
|
|
||||||
cd ../code
|
|
||||||
|
|
||||||
for file in ../build/*.t3x
|
|
||||||
do
|
|
||||||
name="${file##*/}"
|
|
||||||
name="${name%.*}"
|
|
||||||
../../tools/bin/file2array "${file}" "${name}"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Fix The Output of file2array"
|
|
||||||
for file in ./*.cpp
|
|
||||||
do
|
|
||||||
../../tools/bin/rd7f2afix "${file}" "renderd7"
|
|
||||||
done
|
|
||||||
echo "Finished!"
|
|
@ -1,7 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
echo "Deleting Directorys"
|
|
||||||
rm -rf build
|
|
||||||
rm -rf code
|
|
||||||
|
|
||||||
echo "Finished!"
|
|
Binary file not shown.
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 17 KiB |
@ -1,8 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
find . -type f \( -name '*.h' -o -name '*.hpp' -o -name '*.hh' -o -name '*.ino' -o -name '*.cpp' -o -name '*.c' -o -name '*.cxx' -o -name '*.inl' \) -and -not -path './build/*' -not -path './base/external/*' -not -path './DPP/*' | while read file; do
|
|
||||||
if [[ "$file" != *"json.hpp" ]]; then
|
|
||||||
echo "Formatting $file..."
|
|
||||||
clang-format -i --style=LLVM $file
|
|
||||||
fi
|
|
||||||
done
|
|
29
clang-format.py
Normal file
29
clang-format.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import subprocess
|
||||||
|
import glob
|
||||||
|
from pathlib import Path
|
||||||
|
# Format script
|
||||||
|
|
||||||
|
def fmt_file(path):
|
||||||
|
if Path(path).is_dir():
|
||||||
|
return # Skip
|
||||||
|
try:
|
||||||
|
subprocess.run(['clang-format', '-i', path, '--style=Google'], check=True)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print('Error for ' + Path(path).stem + ': ' + e)
|
||||||
|
|
||||||
|
def fmt_dir(path):
|
||||||
|
sources = glob.glob(path+'/*')
|
||||||
|
for file in sources:
|
||||||
|
fmt_file(file)
|
||||||
|
|
||||||
|
print('Formatting...')
|
||||||
|
fmt_dir('source')
|
||||||
|
fmt_dir('source/music')
|
||||||
|
fmt_dir('include')
|
||||||
|
fmt_dir('include/renderd7')
|
||||||
|
fmt_dir('include/renderd7/music')
|
||||||
|
|
||||||
|
# Format LE and TF as well
|
||||||
|
fmt_dir('rd7tf/source')
|
||||||
|
fmt_dir('rd7le/source')
|
||||||
|
print('Done')
|
18
docs/javascripts/mathjax.js
Normal file
18
docs/javascripts/mathjax.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<div class="md-copyright">
|
||||||
|
{% if config.copyright %}
|
||||||
|
<div class="md-copyright__highlight">
|
||||||
|
{{ config.copyright }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if not config.extra.generator == false %}
|
||||||
|
Made with
|
||||||
|
<a href="https://doxide.org" target="_blank" rel="noopener">
|
||||||
|
Doxide
|
||||||
|
</a>
|
||||||
|
and
|
||||||
|
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
|
||||||
|
Material for MkDocs
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
18
docs/overrides/partials/copyright.html
Normal file
18
docs/overrides/partials/copyright.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<div class="md-copyright">
|
||||||
|
{% if config.copyright %}
|
||||||
|
<div class="md-copyright__highlight">
|
||||||
|
{{ config.copyright }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if not config.extra.generator == false %}
|
||||||
|
Made with
|
||||||
|
<a href="https://doxide.org" target="_blank" rel="noopener">
|
||||||
|
Doxide
|
||||||
|
</a>
|
||||||
|
and
|
||||||
|
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
|
||||||
|
Material for MkDocs
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
49
docs/stylesheets/doxide.css
Normal file
49
docs/stylesheets/doxide.css
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
:root {
|
||||||
|
--md-admonition-icon--variable: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20.41 3c1.39 2.71 1.94 5.84 1.59 9-.2 3.16-1.3 6.29-3.17 9l-1.53-1c1.61-2.43 2.55-5.2 2.7-8 .34-2.8-.11-5.57-1.3-8l1.71-1M5.17 3 6.7 4C5.09 6.43 4.15 9.2 4 12c-.34 2.8.12 5.57 1.3 8l-1.69 1c-1.4-2.71-1.96-5.83-1.61-9 .2-3.16 1.3-6.29 3.17-9m6.91 7.68 2.32-3.23h2.53l-3.78 5 2.2 4.92h-2.26L11.71 14l-2.43 3.33H6.76l3.9-5.12-2.13-4.76h2.27l1.28 3.23Z"/></svg>');
|
||||||
|
--md-admonition-icon--function: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.6 5.29c-1.1-.1-2.07.71-2.17 1.82L13.18 10H16v2h-3l-.44 5.07a3.986 3.986 0 0 1-4.33 3.63 4.007 4.007 0 0 1-3.06-1.87l1.5-1.5c.24.74.9 1.31 1.73 1.38 1.1.1 2.07-.71 2.17-1.82L11 12H8v-2h3.17l.27-3.07c.19-2.2 2.13-3.83 4.33-3.63 1.31.11 2.41.84 3.06 1.87l-1.5 1.5c-.24-.74-.9-1.31-1.73-1.38Z"/></svg>');
|
||||||
|
--md-admonition-icon--concept: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3.75 3.5a.25.25 0 0 0-.25.25v2.062a.75.75 0 1 1-1.5 0V3.75C2 2.783 2.783 2 3.75 2h2.062a.75.75 0 1 1 0 1.5Zm13.688-.75a.75.75 0 0 1 .75-.75h2.062c.966 0 1.75.783 1.75 1.75v2.062a.75.75 0 1 1-1.5 0V3.75a.25.25 0 0 0-.25-.25h-2.062a.75.75 0 0 1-.75-.75ZM2.75 17.438a.75.75 0 0 1 .75.75v2.062c0 .138.112.25.25.25h2.062a.75.75 0 1 1 0 1.5H3.75A1.75 1.75 0 0 1 2 20.25v-2.062a.75.75 0 0 1 .75-.75Zm18.5 0a.75.75 0 0 1 .75.75v2.062A1.75 1.75 0 0 1 20.25 22h-2.062a.75.75 0 1 1 0-1.5h2.062a.25.25 0 0 0 .25-.25v-2.062a.75.75 0 0 1 .75-.75Zm-18.5-8.25a.75.75 0 0 1 .75.75v4.124a.75.75 0 1 1-1.5 0V9.938a.75.75 0 0 1 .75-.75ZM9.188 2.75a.75.75 0 0 1 .75-.75h4.124a.75.75 0 1 1 0 1.5H9.938a.75.75 0 0 1-.75-.75Zm0 18.5a.75.75 0 0 1 .75-.75h4.124a.75.75 0 1 1 0 1.5H9.938a.75.75 0 0 1-.75-.75ZM21.25 9.188a.75.75 0 0 1 .75.75v4.124a.75.75 0 1 1-1.5 0V9.938a.75.75 0 0 1 .75-.75ZM3.75 8.25a.75.75 0 0 1 .75-.75h2a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1-.75-.75Zm5.5 0A.75.75 0 0 1 10 7.5h2A.75.75 0 0 1 12 9h-2a.75.75 0 0 1-.75-.75Zm-1-4.5A.75.75 0 0 1 9 4.5v2a.75.75 0 0 1-1.5 0v-2a.75.75 0 0 1 .75-.75Zm0 5.5A.75.75 0 0 1 9 10v2a.75.75 0 0 1-1.5 0v-2a.75.75 0 0 1 .75-.75Zm0 4.75a.75.75 0 0 1 .75.75v4a.75.75 0 0 1-1.5 0v-4a.75.75 0 0 1 .75-.75ZM14 8.25a.75.75 0 0 1 .75-.75h4a.75.75 0 0 1 0 1.5h-4a.75.75 0 0 1-.75-.75Z"/></svg>');
|
||||||
|
--md-admonition-icon--macro: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m5.41 21 .71-4h-4l.35-2h4l1.06-6h-4l.35-2h4l.71-4h2l-.71 4h6l.71-4h2l-.71 4h4l-.35 2h-4l-1.06 6h4l-.35 2h-4l-.71 4h-2l.71-4h-6l-.71 4h-2M9.53 9l-1.06 6h6l1.06-6h-6Z"/></svg>');
|
||||||
|
}
|
||||||
|
|
||||||
|
.md-typeset .admonition.variable, .md-typeset details.variable,
|
||||||
|
.md-typeset .admonition.function, .md-typeset details.function,
|
||||||
|
.md-typeset .admonition.concept, .md-typeset details.concept,
|
||||||
|
.md-typeset .admonition.macro, .md-typeset details.macro {
|
||||||
|
border-color: var(--md-default-fg-color--lighter);
|
||||||
|
}
|
||||||
|
|
||||||
|
.md-typeset .variable > .admonition-title, .md-typeset .variable > summary,
|
||||||
|
.md-typeset .function > .admonition-title, .md-typeset .function > summary,
|
||||||
|
.md-typeset .concept > .admonition-title, .md-typeset .concept > summary,
|
||||||
|
.md-typeset .macro > .admonition-title, .md-typeset .macro > summary {
|
||||||
|
background-color: var(--md-default-bg-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.md-typeset .variable > .admonition-title::before,
|
||||||
|
.md-typeset .variable > summary::before {
|
||||||
|
background-color: var(--md-default-fg-color--light);
|
||||||
|
-webkit-mask-image: var(--md-admonition-icon--variable);
|
||||||
|
mask-image: var(--md-admonition-icon--variable);
|
||||||
|
}
|
||||||
|
|
||||||
|
.md-typeset .function > .admonition-title::before,
|
||||||
|
.md-typeset .function > summary::before {
|
||||||
|
background-color: var(--md-default-fg-color--light);
|
||||||
|
-webkit-mask-image: var(--md-admonition-icon--function);
|
||||||
|
mask-image: var(--md-admonition-icon--function);
|
||||||
|
}
|
||||||
|
|
||||||
|
.md-typeset .concept > .admonition-title::before,
|
||||||
|
.md-typeset .concept > summary::before {
|
||||||
|
background-color: var(--md-default-fg-color--light);
|
||||||
|
-webkit-mask-image: var(--md-admonition-icon--concept);
|
||||||
|
mask-image: var(--md-admonition-icon--concept);
|
||||||
|
}
|
||||||
|
|
||||||
|
.md-typeset .macro > .admonition-title::before,
|
||||||
|
.md-typeset .macro > summary::before {
|
||||||
|
background-color: var(--md-default-fg-color--light);
|
||||||
|
-webkit-mask-image: var(--md-admonition-icon--macro);
|
||||||
|
mask-image: var(--md-admonition-icon--macro);
|
||||||
|
}
|
||||||
|
|
638
docsn.css
638
docsn.css
@ -1,638 +0,0 @@
|
|||||||
/* This doxygen theme is free to use. If you like this, please Star https://github.com/kcwongjoe/doxygen_theme_flat_design */
|
|
||||||
|
|
||||||
/* Color Pattern. You can change this pattern to design your theme. */
|
|
||||||
|
|
||||||
:root {
|
|
||||||
/* Content */
|
|
||||||
--bgcolor: #ffffff;
|
|
||||||
--bgfont: #303030;
|
|
||||||
--bgfont2: #f3c60a;
|
|
||||||
--bgfont-hover: #f3c60a;
|
|
||||||
--bgfont-hover-text-decoration: none;
|
|
||||||
--bgborder: #7d7d7d;
|
|
||||||
--bgborder2: #f6f6f6;
|
|
||||||
/* Main Header */
|
|
||||||
--bg1color: #303030;
|
|
||||||
--bg1font: #ffffff;
|
|
||||||
--bg1font2: #f3c60a;
|
|
||||||
/* Second header */
|
|
||||||
--bg2color: #E2E2E2;
|
|
||||||
--bg2font: #7D7D7D;
|
|
||||||
--bg2-hover-bg: #ffffff;
|
|
||||||
--bg2-hover-font: #303030;
|
|
||||||
--bg2-hover-topborder: #f3c60a;
|
|
||||||
/* Third header */
|
|
||||||
--bg3color: #f6f6f6;
|
|
||||||
--bg3font: #303030;
|
|
||||||
--bg3font2: #7D7D7D;
|
|
||||||
/* Code */
|
|
||||||
--code-bg: #f6f6f6;
|
|
||||||
--code-comment: #7D7D7D;
|
|
||||||
--code-keyword: #d73a49;
|
|
||||||
--code-preprocessor: #d73a49;
|
|
||||||
--code-keywordtype: #d73a49;
|
|
||||||
--code-text: #303030;
|
|
||||||
--code-code: #6f42c1;
|
|
||||||
--code-line: #7D7D7D;
|
|
||||||
--code-line-bg: #D8D8D8;
|
|
||||||
/* Namespace List, Class List icon */
|
|
||||||
--icon-bg: #303030;
|
|
||||||
--icon-font: #f3c60a;
|
|
||||||
/* Class Index */
|
|
||||||
--qindex-menu-bg: #303030;
|
|
||||||
--qindex-menu-font: #ffffff;
|
|
||||||
--qindex-menu-font-hover: #f3c60a;
|
|
||||||
--qindex-icon-bg: #f3c60a;
|
|
||||||
--qindex-icon-font: #303030;
|
|
||||||
/* Member table */
|
|
||||||
--mem-title-bg: #303030;
|
|
||||||
--mem-title-font: #ffffff;
|
|
||||||
--mem-subtitle-bg: #f3c60a;
|
|
||||||
--mem-subtitle-font: #303030;
|
|
||||||
--mem-subtitle-font-hover: #303030;
|
|
||||||
--mem-content-bg: #ffffff;
|
|
||||||
--mem-content-font: #303030;
|
|
||||||
--mem-content-border: #f6f6f6;
|
|
||||||
/* Nav Tree */
|
|
||||||
--nav-tree-bg: #E2E2E2;
|
|
||||||
--nav-tree-bg-hover: #ffffff;
|
|
||||||
--nav-tree-font: #7D7D7D;
|
|
||||||
--nav-tree-font-hover: #303030;
|
|
||||||
--nav-tree-bg-selected: #f3c60a;
|
|
||||||
--nav-tree-font-selected: #303030;
|
|
||||||
}
|
|
||||||
|
|
||||||
body, table, div, p, dl {
|
|
||||||
color: var(--bgfont);
|
|
||||||
background-color: var(--bgcolor);
|
|
||||||
line-height: 150%;
|
|
||||||
font: 14px/22px, Roboto, Arial;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.contents {
|
|
||||||
margin: 20px 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.contents ul {
|
|
||||||
line-height: 200%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
/********** Project header *********/
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
#titlearea {
|
|
||||||
border-bottom: none;
|
|
||||||
padding-bottom: 20px;
|
|
||||||
padding-top: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#titlearea, #titlearea * {
|
|
||||||
color: var(--bg1font);
|
|
||||||
background-color: var(--bg1color);
|
|
||||||
}
|
|
||||||
|
|
||||||
#projectname {
|
|
||||||
padding: 0px 40px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#projectbrief {
|
|
||||||
padding: 0px 40px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#projectalign {
|
|
||||||
padding: 0px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
/************ Main Menu ************/
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
/* Margin */
|
|
||||||
|
|
||||||
#main-menu {
|
|
||||||
padding: 0px 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#main-menu a, #main-menu a:hover {
|
|
||||||
padding-top: 10px;
|
|
||||||
padding-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Menu button */
|
|
||||||
|
|
||||||
#main-menu li a {
|
|
||||||
background-image: none;
|
|
||||||
font-family: Arial;
|
|
||||||
text-transform: uppercase;
|
|
||||||
text-shadow: none;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
|
|
||||||
#main-menu, #main-menu>li>a {
|
|
||||||
background-image: none;
|
|
||||||
background-color: var(--bg2color);
|
|
||||||
color: var(--bg2font);
|
|
||||||
transition: 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* hover Effect */
|
|
||||||
|
|
||||||
#main-menu>li {
|
|
||||||
border-top: 5px solid var(--bg2color);
|
|
||||||
}
|
|
||||||
|
|
||||||
#main-menu>li:hover {
|
|
||||||
color: var(--bg2-hover-font);
|
|
||||||
background-color: var(--bg2-hover-bg);
|
|
||||||
border-top: 5px solid var(--bg2-hover-topborder);
|
|
||||||
}
|
|
||||||
|
|
||||||
#main-menu>li:hover, #main-menu>li>a:hover, #main-menu>li>a.highlighted {
|
|
||||||
color: var(--bg2-hover-font);
|
|
||||||
background-color: var(--bg2-hover-bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Search Bar */
|
|
||||||
|
|
||||||
#MSearchBox {
|
|
||||||
border-radius: 0;
|
|
||||||
box-shadow: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#MSearchBox>span {
|
|
||||||
margin: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#main-menu>li:last-child {
|
|
||||||
padding: 25px 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reset search hover color*/
|
|
||||||
|
|
||||||
#main-menu>li:last-child:hover {
|
|
||||||
color: var(--bg2font);
|
|
||||||
background-color: var(--bg2color);
|
|
||||||
border-top: 5px solid var(--bg2color);
|
|
||||||
}
|
|
||||||
|
|
||||||
#MSearchResultsWindow {
|
|
||||||
border: 1px solid var(--bg3font2);
|
|
||||||
background-color: var(--bg3color);
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
body.SRPage, body.SRPage * {
|
|
||||||
font-family: Arial;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Sub Menu */
|
|
||||||
|
|
||||||
#main-menu>li ul {
|
|
||||||
transition: max-height 0.2s ease-in-out;
|
|
||||||
padding: 0px;
|
|
||||||
border-radius: 0px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#main-menu>li ul:before, #main-menu>li ul:after {
|
|
||||||
border-width: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#main-menu>li>ul li a, #main-menu>li>ul li {
|
|
||||||
background-color: var(--bgcolor);
|
|
||||||
color: var(--bgfont);
|
|
||||||
background-image: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#main-menu>li>ul li a:hover, #main-menu>li>ul li:hover {
|
|
||||||
background-color: var(--bgfont2);
|
|
||||||
color: var(--bgfont);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
/************** Header *************/
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
div.headertitle {
|
|
||||||
padding: 5px 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.header, div.header * {
|
|
||||||
color: var(--bg3font);
|
|
||||||
background-color: var(--bg3color);
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.summary {
|
|
||||||
padding-right: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
/************** Link *************/
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
a, a:visited, a:active, .contents a:visited, body.SRPage a, body.SRPage a:visited, body.SRPage a:active {
|
|
||||||
color: var(--bgfont);
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover, .contents a:hover, body.SRPage a:hover {
|
|
||||||
color: var(--bgfont-hover);
|
|
||||||
text-decoration: var(--bgfont-hover-text-decoration);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
/************ Nav-path ************/
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
#nav-path, #nav-path ul {
|
|
||||||
background-image: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#nav-path ul {
|
|
||||||
padding: 5px 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#nav-path, #nav-path * {
|
|
||||||
color: var(--bg3font2);
|
|
||||||
background-color: var(--bg3color);
|
|
||||||
border: none;
|
|
||||||
font-family: Arial;
|
|
||||||
}
|
|
||||||
|
|
||||||
li.navelem {
|
|
||||||
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHhtbG5zOnN2Z2pzPSJodHRwOi8vc3ZnanMuY29tL3N2Z2pzIiB3aWR0aD0iNTEyIiBoZWlnaHQ9IjUxMiIgeD0iMCIgeT0iMCIgdmlld0JveD0iMCAwIDI5Mi4zNTkgMjkyLjM1OSIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNTEyIDUxMiIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSIgY2xhc3M9IiI+PGc+CjxnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+Cgk8cGF0aCBkPSJNMjIyLjk3OSwxMzMuMzMxTDk1LjA3Myw1LjQyNEM5MS40NTYsMS44MDcsODcuMTc4LDAsODIuMjI2LDBjLTQuOTUyLDAtOS4yMzMsMS44MDctMTIuODUsNS40MjQgICBjLTMuNjE3LDMuNjE3LTUuNDI0LDcuODk4LTUuNDI0LDEyLjg0N3YyNTUuODEzYzAsNC45NDgsMS44MDcsOS4yMzIsNS40MjQsMTIuODQ3YzMuNjIxLDMuNjE3LDcuOTAyLDUuNDI4LDEyLjg1LDUuNDI4ICAgYzQuOTQ5LDAsOS4yMy0xLjgxMSwxMi44NDctNS40MjhsMTI3LjkwNi0xMjcuOTA3YzMuNjE0LTMuNjEzLDUuNDI4LTcuODk3LDUuNDI4LTEyLjg0NyAgIEMyMjguNDA3LDE0MS4yMjksMjI2LjU5NCwxMzYuOTQ4LDIyMi45NzksMTMzLjMzMXoiIGZpbGw9IiM3ZDdkN2QiIGRhdGEtb3JpZ2luYWw9IiMwMDAwMDAiIHN0eWxlPSIiIGNsYXNzPSIiPjwvcGF0aD4KPC9nPgo8ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8L2c+CjxnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjwvZz4KPGcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPC9nPgo8ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8L2c+CjxnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjwvZz4KPGcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPC9nPgo8ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8L2c+CjxnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjwvZz4KPGcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPC9nPgo8ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8L2c+CjxnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjwvZz4KPGcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPC9nPgo8ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8L2c+CjxnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjwvZz4KPGcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPC9nPgo8L2c+PC9zdmc+);
|
|
||||||
background-size: 9px;
|
|
||||||
}
|
|
||||||
|
|
||||||
li.navelem a {
|
|
||||||
margin-right: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
/*************** mem ***************/
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
.memtitle {
|
|
||||||
padding: 15px;
|
|
||||||
margin-top: 30px;
|
|
||||||
border-top-left-radius: 0px;
|
|
||||||
border-top-right-radius: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.memtitle, .memtitle *, .memtitle a:visited {
|
|
||||||
border: none;
|
|
||||||
background-image: none;
|
|
||||||
color: var(--mem-title-font);
|
|
||||||
background-color: var(--mem-title-bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.memproto {
|
|
||||||
padding: 10px;
|
|
||||||
text-shadow: none;
|
|
||||||
padding: 20px;
|
|
||||||
border-top-right-radius: 0px;
|
|
||||||
-moz-border-radius-topright: 0px;
|
|
||||||
-webkit-border-top-right-radius: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.memproto, .memproto *, .memproto a:visited {
|
|
||||||
border: none;
|
|
||||||
background-image: none;
|
|
||||||
background-color: var(--mem-subtitle-bg);
|
|
||||||
color: var(--mem-subtitle-font);
|
|
||||||
font-size: inherit;
|
|
||||||
line-height: 100%
|
|
||||||
}
|
|
||||||
|
|
||||||
.memproto a:hover {
|
|
||||||
color: var(--mem-subtitle-font-hover);
|
|
||||||
}
|
|
||||||
|
|
||||||
.memdoc {
|
|
||||||
border-bottom: 1px solid var(--mem-content-border);
|
|
||||||
border-left: 1px solid var(--mem-content-border);
|
|
||||||
border-right: 1px solid var(--mem-content-border);
|
|
||||||
background-color: var(--mem-content-bg);
|
|
||||||
color: var(--mem-content-font);
|
|
||||||
border-bottom-left-radius: 0px;
|
|
||||||
border-bottom-right-radius: 0px;
|
|
||||||
-moz-border-radius-bottomleft: 0px;
|
|
||||||
-moz-border-radius-bottomright: 0px;
|
|
||||||
-webkit-border-bottom-left-radius: 0px;
|
|
||||||
-webkit-border-bottom-right-radius: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.memdoc p, .memdoc dt {
|
|
||||||
padding: 0px 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
/************* Contents ************/
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
a.anchor {
|
|
||||||
padding-top: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
/************* fragment ************/
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
h2.groupheader {
|
|
||||||
color: #303030;
|
|
||||||
font-size: 200%;
|
|
||||||
font-weight: bold;
|
|
||||||
border-bottom: none;
|
|
||||||
padding-top: 20px;
|
|
||||||
padding-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.fragment, pre.fragment {
|
|
||||||
border: none;
|
|
||||||
padding: 20px;
|
|
||||||
margin: none;
|
|
||||||
background-color: var(--code-bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
div.line {
|
|
||||||
background-color: var(--code-bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
span.comment {
|
|
||||||
color: var(--code-comment);
|
|
||||||
}
|
|
||||||
|
|
||||||
span.keyword {
|
|
||||||
color: var(--code-keyword);
|
|
||||||
}
|
|
||||||
|
|
||||||
span.preprocessor {
|
|
||||||
color: var(--code-preprocessor);
|
|
||||||
}
|
|
||||||
|
|
||||||
span.keywordtype {
|
|
||||||
color: var(--code-keywordtype);
|
|
||||||
}
|
|
||||||
|
|
||||||
span.mlabel {
|
|
||||||
background-color: var(--code-text);
|
|
||||||
color: var(--code-bg);
|
|
||||||
border-top: none;
|
|
||||||
border-left: none;
|
|
||||||
border-right: none;
|
|
||||||
border-bottom: none;
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.code {
|
|
||||||
color: var(--code-code);
|
|
||||||
}
|
|
||||||
|
|
||||||
span.lineno, span.lineno>* {
|
|
||||||
color: var(--code-line);
|
|
||||||
border-right: none;
|
|
||||||
background-color: var(--code-bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
span.lineno a {
|
|
||||||
background-color: var(--code-line-bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
span.lineno a:hover {
|
|
||||||
color: var(--bg3font);
|
|
||||||
background-color: var(--code-line-bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
/************* directory ***********/
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
.directory tr.even {
|
|
||||||
background-color: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.iconfclosed {
|
|
||||||
background-image: url(closed-folder.png);
|
|
||||||
margin-right: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.iconfopen {
|
|
||||||
background-image: url(opened-folder.png);
|
|
||||||
margin-right: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icondoc {
|
|
||||||
background-image: url(document.png);
|
|
||||||
margin-right: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.arrow {
|
|
||||||
color: #7d7d7d;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icona {
|
|
||||||
vertical-align: middle;
|
|
||||||
margin-right: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon {
|
|
||||||
background-color: var(--icon-bg);
|
|
||||||
color: var(--icon-font);
|
|
||||||
display: table-cell;
|
|
||||||
vertical-align: middle;
|
|
||||||
height: 20px;
|
|
||||||
width: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.ah {
|
|
||||||
background-color: var(--qindex-icon-bg);
|
|
||||||
color: var(--qindex-icon-font);
|
|
||||||
text-align: center;
|
|
||||||
background-image: none;
|
|
||||||
-webkit-box-shadow: none;
|
|
||||||
box-shadow: none;
|
|
||||||
-webkit-border-radius: 0px;
|
|
||||||
border-radius: 0px;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.qindex {
|
|
||||||
background-color: var(--qindex-menu-bg);
|
|
||||||
border: none;
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.qindex {
|
|
||||||
color: var(--qindex-menu-font);
|
|
||||||
font-weight: normal;
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover.qindex {
|
|
||||||
color: var(--qindex-menu-font-hover);
|
|
||||||
}
|
|
||||||
|
|
||||||
a:visited.qindex {
|
|
||||||
color: var(--qindex-menu-font);
|
|
||||||
}
|
|
||||||
|
|
||||||
table.classindex {
|
|
||||||
margin-top: 30px;
|
|
||||||
margin-bottom: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.classindex a.el {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
/************** footer *************/
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
div.directory {
|
|
||||||
border-top: 1px solid var(--bgborder);
|
|
||||||
border-bottom: none;
|
|
||||||
margin: 20px 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.directory a.el {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.directory>table {
|
|
||||||
margin: 20px 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr.footer {
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.contents>hr {
|
|
||||||
border-top: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
/*********** memberdecls ***********/
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
.memItemLeft, .memItemRight {
|
|
||||||
padding: 15px 30px;
|
|
||||||
background-color: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mdescRight {
|
|
||||||
padding: 0px 30px 10px 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.memberdecls * {
|
|
||||||
background-color: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.memSeparator {
|
|
||||||
border-bottom: 1px solid var(--bgborder2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.memTemplParams {
|
|
||||||
color: var(--bgfont);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
/*********** nav-tree ***********/
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
#nav-tree-contents {
|
|
||||||
background-color: var(--nav-tree-bg);
|
|
||||||
margin: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#side-nav, #nav-tree {
|
|
||||||
background-image: none;
|
|
||||||
background-color: var(--nav-tree-bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
#nav-tree .item {
|
|
||||||
background-color: var(--nav-tree-bg);
|
|
||||||
font-family: Arial;
|
|
||||||
text-transform: uppercase;
|
|
||||||
text-shadow: none;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 700;
|
|
||||||
padding: 10px;
|
|
||||||
color: var(--nav-tree-font);
|
|
||||||
}
|
|
||||||
|
|
||||||
#nav-tree .arrow {
|
|
||||||
color: var(--nav-tree-font);
|
|
||||||
}
|
|
||||||
|
|
||||||
#nav-tree .selected {
|
|
||||||
background-image: none;
|
|
||||||
background-color: var(--nav-tree-bg-selected);
|
|
||||||
}
|
|
||||||
|
|
||||||
#nav-tree .selected a {
|
|
||||||
color: var(--nav-tree-font-selected);
|
|
||||||
}
|
|
||||||
|
|
||||||
#nav-tree .item:hover {
|
|
||||||
background-color: var(--nav-tree-bg-hover);
|
|
||||||
color: var(--nav-tree-font-hover);
|
|
||||||
}
|
|
||||||
|
|
||||||
#nav-tree .item a:hover {
|
|
||||||
color: var(--nav-tree-font-hover);
|
|
||||||
}
|
|
||||||
|
|
||||||
#side-nav .ui-resizable-e {
|
|
||||||
background-image: none;
|
|
||||||
background-color: var(--nav-tree-bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
#nav-sync {
|
|
||||||
background-color: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
#nav-sync>img {
|
|
||||||
content: url(off_sync.png);
|
|
||||||
}
|
|
||||||
|
|
||||||
#nav-sync.sync>img {
|
|
||||||
content: url(on_sync.png);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
/*********** Plant UML ***********/
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
|
|
||||||
.plantumlgraph > img {
|
|
||||||
width: 80%;
|
|
||||||
}
|
|
9
doxide.yaml
Normal file
9
doxide.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
title: RenderD7
|
||||||
|
description:
|
||||||
|
files:
|
||||||
|
- "include/*.hpp"
|
||||||
|
- "include/renderd7/*.hpp"
|
||||||
|
- "include/renderd7/music/*.hpp"
|
||||||
|
- "include/*.h"
|
||||||
|
- "include/renderd7/*.h"
|
||||||
|
- "include/renderd7/music/*.h"
|
23
envsetup.sh
23
envsetup.sh
@ -1,23 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#Build Tools
|
|
||||||
echo "Build Tools..."
|
|
||||||
cd tools
|
|
||||||
./build_tools.sh
|
|
||||||
cd ..
|
|
||||||
#Setup asset-arrays
|
|
||||||
echo "Generate Asset-Arrays..."
|
|
||||||
cd assets
|
|
||||||
./build_assets.sh
|
|
||||||
echo "Update Files in RenderD7..."
|
|
||||||
cp -rf code/*.cpp ../source/
|
|
||||||
cp -rf code/*.hpp ../include/renderd7/
|
|
||||||
echo "Clean Assets..."
|
|
||||||
./clear_assets.sh
|
|
||||||
cd ..
|
|
||||||
#Clear Tools
|
|
||||||
echo "Clean Tools..."
|
|
||||||
cd tools
|
|
||||||
./clear_tools.sh
|
|
||||||
cd ..
|
|
||||||
#Finished
|
|
||||||
echo "Done!"
|
|
7737
external/source/lodepng.cpp
vendored
7737
external/source/lodepng.cpp
vendored
File diff suppressed because it is too large
Load Diff
61
generate_assets.py
Normal file
61
generate_assets.py
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
import os
|
||||||
|
import glob
|
||||||
|
import shutil
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# Simple Script to generate/update Assets
|
||||||
|
|
||||||
|
def file2array(path, custom_incluse_path):
|
||||||
|
print(path)
|
||||||
|
cip = len(custom_incluse_path)
|
||||||
|
sip = ''
|
||||||
|
if cip > 0:
|
||||||
|
sip = custom_incluse_path
|
||||||
|
name = Path(path).stem
|
||||||
|
filei = open(path, 'rb')
|
||||||
|
buf = filei.read()
|
||||||
|
filei.close()
|
||||||
|
fs = open(name + '.cpp', 'w')
|
||||||
|
fs.write('#include <'+ sip + name + '.hpp>\n\n')
|
||||||
|
fs.write('// clang-format off\n')
|
||||||
|
fs.write('unsigned char ' + name + '[] = {\n')
|
||||||
|
for byte in buf:
|
||||||
|
fs.write(hex(byte) + ', ')
|
||||||
|
fs.write('\n};\n')
|
||||||
|
fs.write('// clang-format on\n')
|
||||||
|
fs.write('size_t ' + name + '_size = ' + hex(len(buf)) + ';')
|
||||||
|
fs.close()
|
||||||
|
fh = open(name + '.hpp', 'w')
|
||||||
|
fh.write('#pragma once\n\n')
|
||||||
|
fh.write('#include <cstddef>\n\n')
|
||||||
|
fh.write('extern unsigned char ' + name + '[];\n')
|
||||||
|
fh.write('extern size_t ' + name + '_size;')
|
||||||
|
fh.close()
|
||||||
|
|
||||||
|
def tex3ds_build(path):
|
||||||
|
p = os.path.dirname(path)
|
||||||
|
n = Path(path).stem
|
||||||
|
os.system('tex3ds -o ' + p + '/' + n + '.t3x -i ' + path)
|
||||||
|
|
||||||
|
def cleanup():
|
||||||
|
t3x = glob.glob('assets/resources/*.t3x')
|
||||||
|
for f in t3x:
|
||||||
|
os.remove(f)
|
||||||
|
|
||||||
|
def install_code(what, where):
|
||||||
|
if Path(what).is_dir:
|
||||||
|
os.error('Must be a file!!!')
|
||||||
|
shutil.move(what, where + Path(what).name)
|
||||||
|
|
||||||
|
print("Generating...")
|
||||||
|
t3xtg = glob.glob('assets/resources/*.t3s')
|
||||||
|
for object in t3xtg:
|
||||||
|
name = Path(object).stem
|
||||||
|
bp = os.path.dirname(object)
|
||||||
|
tex3ds_build(object)
|
||||||
|
file2array(bp + '/' + name + '.t3x', 'renderd7/')
|
||||||
|
install_code(name + '.cpp', 'source/')
|
||||||
|
install_code(name + '.hpp', 'include/renderd7/')
|
||||||
|
|
||||||
|
cleanup()
|
||||||
|
print("Done")
|
@ -1,7 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <renderd7/DrawV2.hpp>
|
||||||
|
#include <renderd7/Error.hpp>
|
||||||
|
#include <renderd7/FileSystem.hpp>
|
||||||
|
#include <renderd7/Hid.hpp>
|
||||||
|
#include <renderd7/Image.hpp>
|
||||||
|
#include <renderd7/Message.hpp>
|
||||||
#include <renderd7/StealConsole.hpp>
|
#include <renderd7/StealConsole.hpp>
|
||||||
#include <renderd7/bmp.hpp>
|
#include <renderd7/Timer.hpp>
|
||||||
|
#include <renderd7/UI7.hpp>
|
||||||
|
#include <renderd7/global_db.hpp>
|
||||||
|
#include <renderd7/nimg_engine.hpp>
|
||||||
#include <renderd7/renderd7.hpp>
|
#include <renderd7/renderd7.hpp>
|
||||||
#include <renderd7/sound.hpp>
|
#include <renderd7/sound.hpp>
|
||||||
#include <renderd7/ToastsV2.hpp>
|
|
@ -1,219 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <renderd7/bmp.hpp>
|
|
||||||
#include <renderd7/bmpconverter.hpp>
|
|
||||||
|
|
||||||
#include <renderd7/Image.hpp>
|
|
||||||
|
|
||||||
#include <renderd7/Screen.hpp>
|
|
||||||
#include <renderd7/Time.hpp>
|
|
||||||
|
|
||||||
#include <renderd7/Fonts/NFontApi.hpp>
|
|
||||||
|
|
||||||
namespace RenderD7 {
|
|
||||||
/// @brief Encoder
|
|
||||||
enum Encoder {
|
|
||||||
BITMAP, ///< Encode Data to Bitmap
|
|
||||||
DIRECT, ///< Encode Direct to Framebuffer(No Decoder Required)
|
|
||||||
C3D ///< Encode Directly to C3D_Tex (Just an Idea)
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @brief Decoder
|
|
||||||
enum Decoder {
|
|
||||||
BITMAP2C3D, ///< Decode and Encode to C3D_Tex (Currently Fastest) (47,4ms)
|
|
||||||
BITMAP2PNG2C3D ///< Decode Bitmap end Convert to Png, then C3D (Very Slow)
|
|
||||||
///< (201,4ms)
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @brief BitmapPrinetr Class
|
|
||||||
class BitmapPrinter {
|
|
||||||
public:
|
|
||||||
/// @brief Constructor
|
|
||||||
/// @param w Widrth
|
|
||||||
/// @param h Height
|
|
||||||
BitmapPrinter(int w, int h);
|
|
||||||
/// @brief Deconstructor
|
|
||||||
~BitmapPrinter();
|
|
||||||
/// @brief Dexode Bitmap File
|
|
||||||
/// @param file path to File
|
|
||||||
/// @return success ?
|
|
||||||
bool DecodeFile(std::string file);
|
|
||||||
|
|
||||||
/// @brief Set the Decoder
|
|
||||||
/// @param deccc Decoder
|
|
||||||
void SetDecoder(Decoder deccc) { decc = deccc; }
|
|
||||||
/// @brief Draw a Pixel
|
|
||||||
/// @param x pos x
|
|
||||||
/// @param y pos y
|
|
||||||
/// @param b color blue
|
|
||||||
/// @param g color green
|
|
||||||
/// @param r color red
|
|
||||||
/// @param a color alpha
|
|
||||||
void DrawPixel(int x, int y, u8 b, u8 g, u8 r, u8 a);
|
|
||||||
/// @brief Draw Rectangle
|
|
||||||
/// @param x pos x
|
|
||||||
/// @param y pos y
|
|
||||||
/// @param w width
|
|
||||||
/// @param h height
|
|
||||||
/// @param line_w line width
|
|
||||||
/// @param b color blue
|
|
||||||
/// @param g color green
|
|
||||||
/// @param r color red
|
|
||||||
/// @param a colr alpha
|
|
||||||
void DrawRect(int x, int y, int w, int h, u8 line_w, u8 b, u8 g, u8 r, u8 a);
|
|
||||||
/// @brief Draw a Fillif Rectangle
|
|
||||||
/// @param x pos x
|
|
||||||
/// @param y pos y
|
|
||||||
/// @param w width
|
|
||||||
/// @param h height
|
|
||||||
/// @param b color blue
|
|
||||||
/// @param g color green
|
|
||||||
/// @param r color red
|
|
||||||
/// @param a color alpha
|
|
||||||
void DrawRectFilled(int x, int y, int w, int h, u8 b, u8 g, u8 r, u8 a);
|
|
||||||
/// @brief Draw Bitmap
|
|
||||||
/// @param x pos x
|
|
||||||
/// @param y pos y
|
|
||||||
/// @param map Bitmap to Print
|
|
||||||
void DrawBitmap(int x, int y, BMP map);
|
|
||||||
/// @brief Use Prebuild Bitmap
|
|
||||||
/// @param map bitmap
|
|
||||||
void UsePreMap(BMP map);
|
|
||||||
/// @brief Use Prebuild Printer Setup
|
|
||||||
/// @param printmap Printer
|
|
||||||
void UsePrePrintMap(BitmapPrinter printmap);
|
|
||||||
/// @brief Get Bitmap
|
|
||||||
/// @return Bitmap
|
|
||||||
BMP GetBitmap() { return bitmap; }
|
|
||||||
/// @brief Save to File
|
|
||||||
/// @param name Name/Path
|
|
||||||
void SaveBmp(std::string name);
|
|
||||||
/// @brief Save as Png
|
|
||||||
/// @param name Name/Path
|
|
||||||
void SavePng(std::string name);
|
|
||||||
|
|
||||||
/// @brief Setup Screen
|
|
||||||
/// @param target Screen
|
|
||||||
void CreateScreen(C3D_RenderTarget *target);
|
|
||||||
/// @brief Draw Directly to Screen With Framerate
|
|
||||||
/// @param framerate Framerate
|
|
||||||
/// @return
|
|
||||||
bool DrawScreenDirectF(int framerate);
|
|
||||||
/// @brief Draw Directly to Screen
|
|
||||||
/// @return
|
|
||||||
bool DrawScreenDirect();
|
|
||||||
/// @brief Render on Screen by Framerate
|
|
||||||
/// @param framerate Framerate
|
|
||||||
void DrawScreenF(int framerate);
|
|
||||||
/// @brief Draw to Screen
|
|
||||||
void DrawScreen();
|
|
||||||
/// @brief Update Image by Framerate
|
|
||||||
/// @param framerate Framerate
|
|
||||||
/// @return
|
|
||||||
bool UpdateScreenF(int framerate);
|
|
||||||
/// @brief Update Image
|
|
||||||
/// @return
|
|
||||||
bool UpdateScreen();
|
|
||||||
/// @brief Clear by Color
|
|
||||||
/// @param b color blue
|
|
||||||
/// @param g color green
|
|
||||||
/// @param r color red
|
|
||||||
/// @param a color alpha
|
|
||||||
void Clear(u8 b = 0, u8 g = 0, u8 r = 0, u8 a = 255);
|
|
||||||
/// @brief Clear Completly Blank
|
|
||||||
void ClearBlank();
|
|
||||||
/// @brief Get Rendered Image
|
|
||||||
/// @return Image
|
|
||||||
RenderD7::Image GetImage();
|
|
||||||
/// Test to Find out The Best Settings for BitmapPrinter
|
|
||||||
void Benchmark();
|
|
||||||
/// @brief Setup the Benchmark
|
|
||||||
/// \param framerate The Fps of the ScreenUpdates
|
|
||||||
void SetupBenchmark(int framerate);
|
|
||||||
/// @brief Check if Benchmark is Running
|
|
||||||
/// @return is running or not
|
|
||||||
bool IsBenchmarkRunning() { return this->benchmark; }
|
|
||||||
|
|
||||||
/// @brief Draw a Dubug Text
|
|
||||||
/// @param x pos x
|
|
||||||
/// @param y pos y
|
|
||||||
/// @param t_size Size of the Text
|
|
||||||
/// @param color Color of the Text
|
|
||||||
/// @param text String of the Text
|
|
||||||
void DrawDebugText(int x, int y, int t_size, u32 color, std::string text);
|
|
||||||
/// @brief Draw a Text width NFontApi (TTF)
|
|
||||||
/// @param x pos x
|
|
||||||
/// @param y pos y
|
|
||||||
/// @param t_size size of the Text
|
|
||||||
/// @param color Color of The Text
|
|
||||||
/// @param text String of The Text
|
|
||||||
/// @param font TTF Font
|
|
||||||
void DrawText(int x, int y, float t_size, u32 color, std::string text,
|
|
||||||
RenderD7::NFontApi font);
|
|
||||||
|
|
||||||
private:
|
|
||||||
// funcs
|
|
||||||
|
|
||||||
/// @brief Decode 2 RenderD7::Image
|
|
||||||
/// @param deccc Decoder
|
|
||||||
/// @return
|
|
||||||
bool Decode(Decoder deccc);
|
|
||||||
/// @brief Draw Char Func
|
|
||||||
/// @param posX pos x
|
|
||||||
/// @param posY pos y
|
|
||||||
/// @param t_size size
|
|
||||||
/// @param color color
|
|
||||||
/// @param character char
|
|
||||||
void DrawDebugChar(u32 posX, u32 posY, int t_size, u32 color, char character);
|
|
||||||
/// @brief NFont Draw Char
|
|
||||||
/// @param posX pos x
|
|
||||||
/// @param posY pos y
|
|
||||||
/// @param t_size size
|
|
||||||
/// @param color color
|
|
||||||
/// @param character char
|
|
||||||
/// @param font ttf
|
|
||||||
void DrawChar(int posX, int posY, float t_size, u32 color, char character,
|
|
||||||
RenderD7::NFontApi font);
|
|
||||||
// parameter
|
|
||||||
int frame = 0;
|
|
||||||
RenderD7::Image renderframe;
|
|
||||||
bool isscreen = false;
|
|
||||||
C3D_RenderTarget *targetr;
|
|
||||||
BMP bitmap = BMP(
|
|
||||||
20, 20,
|
|
||||||
true); // Need to Set e Predefined Bitmap. If not the System will Crash.
|
|
||||||
BMP blank = BMP(
|
|
||||||
20, 20,
|
|
||||||
true); // Need to Set e Predefined Bitmap. If not the System will Crash.
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Benchmark Stuff;
|
|
||||||
int testfpsd;
|
|
||||||
bool benchmark = false;
|
|
||||||
bool setupbenchmark;
|
|
||||||
float frametime = 0;
|
|
||||||
uint64_t lastTime = 0;
|
|
||||||
float dtt = 0.f;
|
|
||||||
float dtt2 = 0.f;
|
|
||||||
float dtt3 = 0.f;
|
|
||||||
float timer = 0;
|
|
||||||
float mhdtt = 0;
|
|
||||||
float mdtt2;
|
|
||||||
float mdtt3;
|
|
||||||
|
|
||||||
float fpsClock = 0.f;
|
|
||||||
int frameCounter = 0, fps = 0;
|
|
||||||
|
|
||||||
std::vector<float> hdttt;
|
|
||||||
std::vector<float> hdttt2;
|
|
||||||
std::vector<float> hdttt3;
|
|
||||||
std::vector<int> fpscountc;
|
|
||||||
int renderedframes = 0;
|
|
||||||
int testfps = 60;
|
|
||||||
Encoder encc = Encoder::BITMAP;
|
|
||||||
Decoder decc = Decoder::BITMAP2C3D;
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
};
|
|
||||||
} // namespace RenderD7
|
|
@ -1,36 +1,154 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#define UNPACK_RGBA(col) (uint8_t)(col >> 24), (col >> 16), (col >> 8), (col)
|
#define UNPACK_RGBA(col) (uint8_t)(col >> 24), (col >> 16), (col >> 8), (col)
|
||||||
#define UNPACK_BGRA(col) (uint8_t)(col >> 8), (col >> 16), (col >> 24), (col)
|
#define UNPACK_BGRA(col) (uint8_t)(col >> 8), (col >> 16), (col >> 24), (col)
|
||||||
|
|
||||||
namespace RenderD7 {
|
inline uint32_t RGBA8(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) {
|
||||||
namespace Color {
|
#define ISIMPLEPAK(x, y) (((x)&0xff) << y)
|
||||||
/// @brief RGBA Struct
|
return (ISIMPLEPAK(r, 0) | ISIMPLEPAK(g, 8) | ISIMPLEPAK(b, 16) |
|
||||||
struct rgba {
|
ISIMPLEPAK(a, 24));
|
||||||
/// @brief rgba Colors
|
}
|
||||||
uint8_t r, g, b, a;
|
|
||||||
|
typedef int RD7Color;
|
||||||
|
|
||||||
|
// MultiColor (Less FunctionNameLen)
|
||||||
|
|
||||||
|
struct Color2 {
|
||||||
|
unsigned int color0;
|
||||||
|
unsigned int color1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Color3 {
|
||||||
|
unsigned int color0;
|
||||||
|
unsigned int color1;
|
||||||
|
unsigned int color2;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Color4 {
|
||||||
|
unsigned int color0;
|
||||||
|
unsigned int color1;
|
||||||
|
unsigned int color2;
|
||||||
|
unsigned int color3;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum RD7Color_ {
|
||||||
|
RD7Color_Text, ///< This Color Should always be used for Light Backgrounds
|
||||||
|
RD7Color_TextDisabled, /// Text Disabled Color
|
||||||
|
RD7Color_Text2, ///< And This want for Texts on Dark Backgrounds
|
||||||
|
RD7Color_Background, ///< Your Bg Color
|
||||||
|
RD7Color_Header, ///< Header Color (if the header is dark text2 is used)
|
||||||
|
RD7Color_Selector,
|
||||||
|
RD7Color_SelectorFade,
|
||||||
|
RD7Color_List0,
|
||||||
|
RD7Color_List1,
|
||||||
|
RD7Color_MessageBackground,
|
||||||
|
RD7Color_Button,
|
||||||
|
RD7Color_ButtonHovered,
|
||||||
|
RD7Color_ButtonDisabled,
|
||||||
|
RD7Color_ButtonActive,
|
||||||
|
RD7Color_Checkmark,
|
||||||
|
RD7Color_FrameBg,
|
||||||
|
RD7Color_FrameBgHovered,
|
||||||
|
RD7Color_Progressbar,
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
unsigned int StyleColor(RD7Color color);
|
||||||
|
void RedirectColor(RD7Color to, RD7Color from);
|
||||||
|
void TextColorByBg(RD7Color background);
|
||||||
|
/// @brief Customices a color until undone
|
||||||
|
/// For example with RebderD7::Color::Hex
|
||||||
|
void CustomizeColor(RD7Color color, unsigned int custom);
|
||||||
|
/// @brief Completly changes a theme color
|
||||||
|
void ColorNew(RD7Color color, unsigned int new_color);
|
||||||
|
void UndoColorEdit(RD7Color color);
|
||||||
|
void UndoAllColorEdits();
|
||||||
|
void ThemeLoad(const std::string& path);
|
||||||
|
void ThemeSave(const std::string& path);
|
||||||
|
void ThemeDefault();
|
||||||
|
namespace Color {
|
||||||
/// @brief RGBA Class
|
/// @brief RGBA Class
|
||||||
class RGBA {
|
class RGBA {
|
||||||
public:
|
public:
|
||||||
/// @brief Construct
|
/// @brief Construct
|
||||||
/// @param r
|
/// @param r
|
||||||
/// @param g
|
/// @param g
|
||||||
/// @param b
|
/// @param b
|
||||||
/// @param a
|
/// @param a
|
||||||
RGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
RGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
|
||||||
: m_r(r), m_g(g), m_b(b), m_a(a) {}
|
: m_r(r), m_g(g), m_b(b), m_a(a) {}
|
||||||
|
/// @brief Construct
|
||||||
|
/// @param r
|
||||||
|
/// @param g
|
||||||
|
/// @param b
|
||||||
|
/// @param a
|
||||||
|
RGBA(float r, float g, float b, float a = 1.f)
|
||||||
|
: m_r(r * 255.f), m_g(g * 255.f), m_b(b * 255.f), m_a(a * 255.f) {}
|
||||||
|
RGBA(unsigned int in) {
|
||||||
|
#define ISIMPLEUNPAK(x, y) (((x) >> y) & 0xFF)
|
||||||
|
m_r = ISIMPLEUNPAK(in, 0);
|
||||||
|
m_g = ISIMPLEUNPAK(in, 8);
|
||||||
|
m_b = ISIMPLEUNPAK(in, 16);
|
||||||
|
m_a = ISIMPLEUNPAK(in, 24);
|
||||||
|
}
|
||||||
|
RGBA(RD7Color in) {
|
||||||
|
unsigned int col = RenderD7::StyleColor(in);
|
||||||
|
m_r = ISIMPLEUNPAK(col, 0);
|
||||||
|
m_g = ISIMPLEUNPAK(col, 8);
|
||||||
|
m_b = ISIMPLEUNPAK(col, 16);
|
||||||
|
m_a = ISIMPLEUNPAK(col, 24);
|
||||||
|
}
|
||||||
|
RGBA &changeR(unsigned char r) {
|
||||||
|
m_r = r;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
RGBA &changeG(unsigned char g) {
|
||||||
|
m_g = g;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
RGBA &changeB(unsigned char b) {
|
||||||
|
m_b = b;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
RGBA &changeA(unsigned char a) {
|
||||||
|
m_a = a;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBA &fade_to(const RGBA &color, float p) {
|
||||||
|
m_a =
|
||||||
|
m_a + static_cast<unsigned char>((color.m_a - m_a) * ((p + 1.0f) / 2));
|
||||||
|
m_b =
|
||||||
|
m_b + static_cast<unsigned char>((color.m_b - m_b) * ((p + 1.0f) / 2));
|
||||||
|
m_g =
|
||||||
|
m_g + static_cast<unsigned char>((color.m_g - m_g) * ((p + 1.0f) / 2));
|
||||||
|
m_r =
|
||||||
|
m_r + static_cast<unsigned char>((color.m_r - m_r) * ((p + 1.0f) / 2));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief Get as Uint32
|
/// @brief Get as Uint32
|
||||||
/// @return color
|
/// @return color
|
||||||
uint32_t toRGBA() const {
|
uint32_t toRGBA() const { return RGBA8(m_r, m_g, m_b, m_a); }
|
||||||
return (m_r << 24) | (m_g << 16) | (m_b << 8) | m_a;
|
|
||||||
|
// Just calculate the "lightness" f.e. to use Text or Text2
|
||||||
|
float luminance() const {
|
||||||
|
// For Reference https://en.wikipedia.org/wiki/HSL_and_HSV#Lightness
|
||||||
|
return (0.3 * (m_r / 255.f) + 0.59 * (m_g / 255.f) + 0.11 * (m_b / 255.f));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_light() {
|
||||||
|
// Gives us the light or dark to not
|
||||||
|
// always use the below "if" statement
|
||||||
|
return (luminance() >= 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t m_r, m_g, m_b, m_a;
|
uint8_t m_r, m_g, m_b, m_a;
|
||||||
|
@ -1,111 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <3ds.h>
|
|
||||||
#include <citro2d.h>
|
|
||||||
#include <citro3d.h>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace RenderD7 {
|
|
||||||
namespace Draw {
|
|
||||||
/// @brief Draw Rectangle
|
|
||||||
/// @param x Pos X
|
|
||||||
/// @param y Pos Y
|
|
||||||
/// @param w Width
|
|
||||||
/// @param h Height
|
|
||||||
/// @param color Color
|
|
||||||
/// @return success ?
|
|
||||||
bool Rect(float x, float y, float w, float h, u32 color);
|
|
||||||
/// @brief Draw a not filled Rectangle
|
|
||||||
/// @param p1x Pos X
|
|
||||||
/// @param p1y Pos Y
|
|
||||||
/// @param w Width
|
|
||||||
/// @param h Height
|
|
||||||
/// @param color Color
|
|
||||||
/// @param scale Scale
|
|
||||||
/// @return success ?
|
|
||||||
bool NFRect(float p1x, float p1y, float w, float h, u32 color, float scale = 1);
|
|
||||||
/// @brief Draw A Pixel
|
|
||||||
/// @param x Pos X
|
|
||||||
/// @param y Pos Y
|
|
||||||
/// @param color Color
|
|
||||||
/// @return success ?
|
|
||||||
bool Px(float x, float y, u32 color);
|
|
||||||
/// @brief Draw a Centered Text
|
|
||||||
/// @param x Pos X
|
|
||||||
/// @param y Pos Y
|
|
||||||
/// @param size Scale of the Text
|
|
||||||
/// @param color Color of The Text
|
|
||||||
/// @param Text Striing to Display
|
|
||||||
/// @param maxWidth Width to Calculate Centered Pos
|
|
||||||
/// @param maxHeight Height to Calculate Centered Pos
|
|
||||||
/// @param fnt Custom Font
|
|
||||||
void TextCentered(float x, float y, float size, u32 color, std::string Text,
|
|
||||||
int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr);
|
|
||||||
/// @brief Draw a Text
|
|
||||||
/// @param x Pos X
|
|
||||||
/// @param y Pos Y
|
|
||||||
/// @param size Scale of the Text
|
|
||||||
/// @param color Color of The Text
|
|
||||||
/// @param Text Striing to Display
|
|
||||||
/// @param maxWidth Width to Calculate Centered Pos
|
|
||||||
/// @param maxHeight Height to Calculate Centered Pos
|
|
||||||
/// @param fnt Custom Font
|
|
||||||
void Text(float x, float y, float size, u32 color, std::string Text,
|
|
||||||
int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr);
|
|
||||||
/// @brief Draw a Text Set to the Right
|
|
||||||
/// @param x Pos X
|
|
||||||
/// @param y Pos Y
|
|
||||||
/// @param size Scale of the Text
|
|
||||||
/// @param color Color of The Text
|
|
||||||
/// @param Text Striing to Display
|
|
||||||
/// @param maxWidth Width to Calculate Centered Pos
|
|
||||||
/// @param maxHeight Height to Calculate Centered Pos
|
|
||||||
/// @param fnt Custom Font
|
|
||||||
void TextRight(float x, float y, float size, u32 color, std::string Text,
|
|
||||||
int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr);
|
|
||||||
/// @brief Get Width of Text
|
|
||||||
/// @param size Size of the Text
|
|
||||||
/// @param Text String of The text
|
|
||||||
/// @param fnt Custom Font
|
|
||||||
/// @return The Size
|
|
||||||
float GetTextWidth(float size, std::string Text, C2D_Font fnt = nullptr);
|
|
||||||
/// @brief Get Text Size
|
|
||||||
/// @param size Size of The Text
|
|
||||||
/// @param width Width of the Text
|
|
||||||
/// @param height Height of The Text
|
|
||||||
/// @param Text String of Text
|
|
||||||
/// @param fnt Custom Font
|
|
||||||
void GetTextSize(float size, float *width, float *height, std::string Text,
|
|
||||||
C2D_Font fnt = nullptr);
|
|
||||||
/// @brief Get Height of the Text
|
|
||||||
/// @param size Size of the Text
|
|
||||||
/// @param Text String of the Text
|
|
||||||
/// @param fnt Custom Font
|
|
||||||
/// @return The Height
|
|
||||||
float GetTextHeight(float size, std::string Text, C2D_Font fnt = nullptr);
|
|
||||||
/// @brief Load A .bcfnt
|
|
||||||
/// @param fnt Output Font
|
|
||||||
/// @param Path path of The File
|
|
||||||
/// @return Result Code
|
|
||||||
Result LoadFont(C2D_Font &fnt, const char *Path = "");
|
|
||||||
/// @brief Unload a Font
|
|
||||||
/// @param fnt Font to Unload
|
|
||||||
/// @return Result Code
|
|
||||||
Result UnloadFont(C2D_Font &fnt);
|
|
||||||
/// @brief Draw a Circle
|
|
||||||
/// @param x Pos X
|
|
||||||
/// @param y Pos Y
|
|
||||||
/// @param radius Radius of the Circle
|
|
||||||
/// @param color Color of the circle
|
|
||||||
/// @return success ?
|
|
||||||
bool Circle(float x, float y, float radius, u32 color);
|
|
||||||
/// @brief Draw A Citro2D Image
|
|
||||||
/// @param img Image to Draw
|
|
||||||
/// @param x Pos X
|
|
||||||
/// @param y Pos Y
|
|
||||||
/// @param scaleX Scale of X-Axis
|
|
||||||
/// @param scaleY Scale of Y-Axis
|
|
||||||
/// @return success ?
|
|
||||||
bool Image(C2D_Image img, float x, float y, float scaleX = 1.0f,
|
|
||||||
float scaleY = 1.0f);
|
|
||||||
} // namespace Draw
|
|
||||||
} // namespace RenderD7
|
|
53
include/renderd7/DrawV2.hpp
Normal file
53
include/renderd7/DrawV2.hpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <citro2d.h>
|
||||||
|
|
||||||
|
#include <renderd7/Color.hpp>
|
||||||
|
#include <renderd7/Image.hpp>
|
||||||
|
#include <renderd7/R7Vec.hpp>
|
||||||
|
#include <renderd7/font.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#define MAKEFLAG(x) (1 << x)
|
||||||
|
|
||||||
|
typedef unsigned int RD7TextFlags;
|
||||||
|
|
||||||
|
enum RD7TextFlags_ {
|
||||||
|
RD7TextFlags_None = 0, //< Align is Left and Other things are disabled
|
||||||
|
RD7TextFlags_AlignRight = MAKEFLAG(0),
|
||||||
|
RD7TextFlags_AlignMid = MAKEFLAG(1),
|
||||||
|
RD7TextFlags_Shaddow = MAKEFLAG(2), // TextBuf Killer lol (doubled Text)
|
||||||
|
RD7TextFlags_Wrap = MAKEFLAG(3),
|
||||||
|
RD7TextFlags_Short = MAKEFLAG(4),
|
||||||
|
RD7TextFlags_Scroll = MAKEFLAG(5),
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
R7Vec2 GetTextDimensions(const std::string& text);
|
||||||
|
void CustomTextSize(float size);
|
||||||
|
void TextDefaultSize();
|
||||||
|
std::string TextShort(const std::string& in, int max_len);
|
||||||
|
// Overrite TextBox Size (by default Screenwidth x Text.h)
|
||||||
|
void TextMaxBox(R7Vec2 size);
|
||||||
|
void TextDefaultBox();
|
||||||
|
void TextFont(Font fnt);
|
||||||
|
void TextDefaultFont();
|
||||||
|
namespace Draw2 {
|
||||||
|
void Rect(R7Vec2 pos, R7Vec2 size, unsigned int color, int t = 1);
|
||||||
|
void RectFilled(R7Vec2 pos, R7Vec2 size, Color4 colors);
|
||||||
|
void RectFilledSolid(R7Vec2 pos, R7Vec2 size, unsigned int color);
|
||||||
|
// Wrapper of RectFilledSolid
|
||||||
|
inline void RFS(R7Vec2 pos, R7Vec2 size, unsigned int color) {
|
||||||
|
RectFilledSolid(pos, size, color);
|
||||||
|
}
|
||||||
|
void Line(R7Vec2 pos0, R7Vec2 pos1, unsigned int color, int t = 1);
|
||||||
|
void Triangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, Color3 colors);
|
||||||
|
void TriangleSolid(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int color);
|
||||||
|
// Beta and Very unstable
|
||||||
|
void TriangleLined(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int color,
|
||||||
|
int t = 1);
|
||||||
|
void Text(R7Vec2 pos, const std::string& text, RD7TextFlags flags = 0);
|
||||||
|
void Image(RenderD7::Image* img, const R7Vec2& pos = R7Vec2(0, 0),
|
||||||
|
const R7Vec2& scale = R7Vec2(1, 1));
|
||||||
|
} // namespace Draw2
|
||||||
|
} // namespace RenderD7
|
18
include/renderd7/Error.hpp
Normal file
18
include/renderd7/Error.hpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
void Error(const std::string& msg);
|
||||||
|
inline void InlineError(const std::string& msg) {
|
||||||
|
std::string location = __FILE__ + std::string(":") + std::to_string(__LINE__);
|
||||||
|
Error("Error: \n" + location + "\n" + msg);
|
||||||
|
}
|
||||||
|
inline void InlineAssert(bool v, const std::string& msg) {
|
||||||
|
if (v == false) {
|
||||||
|
std::string location =
|
||||||
|
__FILE__ + std::string(":") + std::to_string(__LINE__);
|
||||||
|
Error("Assert Failed:\n" + location + "\n" + msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace RenderD7
|
@ -1,5 +1,3 @@
|
|||||||
// FileSystem based on libphyfs based on
|
|
||||||
// https://github.com/TurtleP/3ds-examples/blob/fs/physfs/fs/physfs/include/filesystem.h
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -19,5 +17,8 @@ struct Entry {
|
|||||||
/// @param path The Path of the Directory
|
/// @param path The Path of the Directory
|
||||||
/// @return The Vector of found Entrys
|
/// @return The Vector of found Entrys
|
||||||
std::vector<RenderD7::FileSystem::Entry> GetDirContent(std::string path);
|
std::vector<RenderD7::FileSystem::Entry> GetDirContent(std::string path);
|
||||||
|
std::string GetParentPath(std::string path, std::string mount_point);
|
||||||
|
std::vector<Entry> GetDirContentsExt(
|
||||||
|
std::string &path, const std::vector<std::string> &extensions);
|
||||||
} // namespace FileSystem
|
} // namespace FileSystem
|
||||||
} // namespace RenderD7
|
} // namespace RenderD7
|
@ -1,142 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <bitset>
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <renderd7/external/stb_truetype.h>
|
|
||||||
|
|
||||||
#define MAXUNICODE 0x10FFFF
|
|
||||||
|
|
||||||
namespace RenderD7 {
|
|
||||||
inline int utf8_decode(const char *o) {
|
|
||||||
static const unsigned int limits[] = {0xFF, 0x7F, 0x7FF, 0xFFFF};
|
|
||||||
const unsigned char *s = (const unsigned char *)o;
|
|
||||||
unsigned int c = s[0];
|
|
||||||
unsigned int res = 0; /* final result */
|
|
||||||
if (c < 0x80) /* ascii? */
|
|
||||||
res = c;
|
|
||||||
else {
|
|
||||||
int count = 0; /* to count number of continuation bytes */
|
|
||||||
while (c & 0x40) { /* still have continuation bytes? */
|
|
||||||
int cc = s[++count]; /* read next byte */
|
|
||||||
if ((cc & 0xC0) != 0x80) /* not a continuation byte? */
|
|
||||||
return -1; /* invalid byte sequence */
|
|
||||||
res = (res << 6) | (cc & 0x3F); /* add lower 6 bits from cont. byte */
|
|
||||||
c <<= 1; /* to test next bit */
|
|
||||||
}
|
|
||||||
res |= ((c & 0x7F) << (count * 5)); /* add first byte */
|
|
||||||
if (count > 3 || res > MAXUNICODE || res <= limits[count])
|
|
||||||
return -1; /* invalid byte sequence */
|
|
||||||
s += count; /* skip continuation bytes read */
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::string IntToUtf8(int convertval) {
|
|
||||||
|
|
||||||
// We only care about plane 1 right now,
|
|
||||||
// but know that we have other options (0x10FFFF)
|
|
||||||
// Technically UTF-8 is "limited" to 4 bytes, so it's not
|
|
||||||
// Like it matters much anyways these days
|
|
||||||
|
|
||||||
if (convertval == 0)
|
|
||||||
return " ";
|
|
||||||
if ((convertval <= 0x7F) && (convertval > 0x00)) {
|
|
||||||
|
|
||||||
std::string out(".");
|
|
||||||
|
|
||||||
std::bitset<8> x(convertval);
|
|
||||||
|
|
||||||
unsigned long l = x.to_ulong();
|
|
||||||
unsigned char c = static_cast<unsigned char>(l);
|
|
||||||
out[0] = c;
|
|
||||||
|
|
||||||
return out;
|
|
||||||
|
|
||||||
} else if ((convertval >= 0x80) && (convertval <= 0x07FF)) {
|
|
||||||
|
|
||||||
std::string out("..");
|
|
||||||
|
|
||||||
int firstShift = (convertval >> 0x06) ^ 0xC0;
|
|
||||||
int secondShift = ((convertval ^ 0xFFC0) | 0x80) & ~0x40;
|
|
||||||
|
|
||||||
std::bitset<8> first(firstShift);
|
|
||||||
std::bitset<8> last(secondShift);
|
|
||||||
|
|
||||||
unsigned long l = first.to_ulong();
|
|
||||||
unsigned char c = static_cast<unsigned char>(l);
|
|
||||||
out[0] = c;
|
|
||||||
|
|
||||||
unsigned long ltwo = last.to_ulong();
|
|
||||||
unsigned char ctwo = static_cast<unsigned char>(ltwo);
|
|
||||||
out[1] = ctwo;
|
|
||||||
|
|
||||||
return out;
|
|
||||||
|
|
||||||
} else if ((convertval >= 0x0800) && (convertval <= 0xFFFF)) {
|
|
||||||
|
|
||||||
std::string out("...");
|
|
||||||
|
|
||||||
int firstShift = ((convertval ^ 0xFC0FFF) >> 0x0C) | 0xE0;
|
|
||||||
int secondShift = (((convertval ^ 0xFFF03F) >> 0x06) | 0x80) & ~0x40;
|
|
||||||
int thirdShift = ((convertval ^ 0xFFFC0) | 0x80) & ~0x40;
|
|
||||||
|
|
||||||
std::bitset<8> first(firstShift);
|
|
||||||
std::bitset<8> second(secondShift);
|
|
||||||
std::bitset<8> third(thirdShift);
|
|
||||||
|
|
||||||
unsigned long lone = first.to_ulong();
|
|
||||||
unsigned char cone = static_cast<unsigned char>(lone);
|
|
||||||
out[0] = cone;
|
|
||||||
|
|
||||||
unsigned long ltwo = second.to_ulong();
|
|
||||||
unsigned char ctwo = static_cast<unsigned char>(ltwo);
|
|
||||||
out[1] = ctwo;
|
|
||||||
|
|
||||||
unsigned long lthree = third.to_ulong();
|
|
||||||
unsigned char cthree = static_cast<unsigned char>(lthree);
|
|
||||||
out[2] = cthree;
|
|
||||||
|
|
||||||
return out;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return " ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#define I2U82I(val) RenderD7::utf8_decode(RenderD7::IntToUtf8(val).c_str())
|
|
||||||
|
|
||||||
class NFontApi {
|
|
||||||
public:
|
|
||||||
NFontApi();
|
|
||||||
~NFontApi();
|
|
||||||
void LoadTTF(std::string path);
|
|
||||||
unsigned char *GetGlyphBitmap(char glyph);
|
|
||||||
std::string GetStatus() { return status; }
|
|
||||||
float GetScale() { return scale; }
|
|
||||||
int GetGlyphWidth(char glyph);
|
|
||||||
int GetGlyphHeight(char glyph);
|
|
||||||
int GetLineHeight() { return l_h; }
|
|
||||||
int GetBaseHeight() { return height; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string status;
|
|
||||||
|
|
||||||
int height;
|
|
||||||
|
|
||||||
float scale;
|
|
||||||
int b_w;
|
|
||||||
int b_h;
|
|
||||||
int l_h;
|
|
||||||
|
|
||||||
int w;
|
|
||||||
int h;
|
|
||||||
|
|
||||||
int x0, y0, x1, y1;
|
|
||||||
int ascent, baseline, decent, linegap;
|
|
||||||
|
|
||||||
int linespace;
|
|
||||||
|
|
||||||
stbtt_fontinfo font;
|
|
||||||
};
|
|
||||||
} // namespace RenderD7
|
|
@ -24,6 +24,7 @@ struct FTRes {
|
|||||||
uint64_t time_start; ///< when started
|
uint64_t time_start; ///< when started
|
||||||
uint64_t time_end; ///< when stopped
|
uint64_t time_end; ///< when stopped
|
||||||
float time_of; ///< stop - start (how long)
|
float time_of; ///< stop - start (how long)
|
||||||
|
bool is_ovl; ///< is displayed in overlay?
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief Map of Traces
|
/// @brief Map of Traces
|
||||||
|
41
include/renderd7/Hid.hpp
Normal file
41
include/renderd7/Hid.hpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// WARNING
|
||||||
|
// THIS IS BETA STUFF
|
||||||
|
// ITS MAKE LIKE EXTERNAL BUT
|
||||||
|
// FOR RENDERD7 ITS INTEGRATED
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <renderd7/R7Vec.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
namespace Hid {
|
||||||
|
enum Actions {
|
||||||
|
Down = 0,
|
||||||
|
Held = 1,
|
||||||
|
Up = 2,
|
||||||
|
DownRepeat = 3,
|
||||||
|
};
|
||||||
|
// Register Functions
|
||||||
|
// Register Current state values
|
||||||
|
void RegKeyDown(uint32_t &key_down);
|
||||||
|
void RegKeyHeld(uint32_t &key_held);
|
||||||
|
void RegKeyUp(uint32_t &key_up);
|
||||||
|
void RegKeyRepeat(uint32_t &repeat);
|
||||||
|
void RegTouchCoords(R7Vec2 &touch_pos);
|
||||||
|
// Not Corectly Implemented Yet
|
||||||
|
void RegAnalog1Movement(R7Vec2 &movement);
|
||||||
|
void RegAnalog2Movement(R7Vec2 &movement);
|
||||||
|
// Register Keys
|
||||||
|
void RegKeyEvent(const std::string &event, uint32_t key);
|
||||||
|
// KeyEvents
|
||||||
|
bool IsEvent(const std::string &event, Actions action);
|
||||||
|
R7Vec2 GetTouchPosition();
|
||||||
|
R7Vec2 GetLastTouchPosition();
|
||||||
|
void Update();
|
||||||
|
// Lock/Unlock Input api for example for Keyboard
|
||||||
|
void Lock();
|
||||||
|
void Unlock();
|
||||||
|
void Clear();
|
||||||
|
} // namespace Hid
|
||||||
|
} // namespace RenderD7
|
@ -1,50 +1,29 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <3ds.h>
|
||||||
#include <citro2d.h>
|
#include <citro2d.h>
|
||||||
#include <citro3d.h>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <renderd7/Sheet.hpp>
|
#include <renderd7/R7Vec.hpp>
|
||||||
#include <renderd7/bmp.hpp>
|
#include <renderd7/nimg.hpp>
|
||||||
#include <renderd7/bmpconverter.hpp>
|
#include <string>
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <cstring>
|
|
||||||
#include <renderd7/Color.hpp>
|
|
||||||
#include <renderd7/external/lodepng.h>
|
|
||||||
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
/// Image Class
|
|
||||||
class Image {
|
class Image {
|
||||||
public:
|
public:
|
||||||
/// @brief Constructor
|
Image();
|
||||||
Image() {}
|
|
||||||
/// @brief Deconstructor
|
|
||||||
~Image();
|
~Image();
|
||||||
/// @brief Unload The Image
|
void load(const std::string& path);
|
||||||
void Unload();
|
void from_nimg(const nimg& image);
|
||||||
/// Load Image from Png
|
|
||||||
/// \param path path to png file
|
|
||||||
void LoadPng(const std::string path);
|
|
||||||
/// Load the Image from buffer
|
|
||||||
/// \param buffer the frame buffer
|
|
||||||
void LoadPFromBuffer(const std::vector<u8> &buffer);
|
|
||||||
void LoadFromBitmap(BMP bitmap);
|
|
||||||
void LoadJpg(std::string path);
|
|
||||||
void LoadPixels(int w, int h, int bpp, void *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; }
|
|
||||||
|
|
||||||
void FromSheet(RenderD7::Sheet sheet, size_t index);
|
C2D_Image get();
|
||||||
/// \param img this is the C2D_Image
|
C2D_Image& get_ref();
|
||||||
|
void set(const C2D_Image& i);
|
||||||
|
R7Vec2 get_size();
|
||||||
|
bool loaded();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void safe_del();
|
||||||
|
bool ld = false;
|
||||||
C2D_Image img;
|
C2D_Image img;
|
||||||
/// \param loadet whether the image is loadet or not
|
|
||||||
bool loadet = false;
|
|
||||||
};
|
};
|
||||||
} // namespace RenderD7
|
} // namespace RenderD7
|
24
include/renderd7/Message.hpp
Normal file
24
include/renderd7/Message.hpp
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
struct Message {
|
||||||
|
Message(std::string t, std::string m) {
|
||||||
|
title = t;
|
||||||
|
message = m;
|
||||||
|
animationframe = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string title;
|
||||||
|
std::string message;
|
||||||
|
int animationframe;
|
||||||
|
};
|
||||||
|
|
||||||
|
void ProcessMessages();
|
||||||
|
void PushMessage(const Message& msg);
|
||||||
|
// Config
|
||||||
|
void SetMessageIdleStartFrame(int frame);
|
||||||
|
void SetMessageTotalAnimationFrames(int total_frames);
|
||||||
|
void SetMessageFadeOutStartFrame(int frame);
|
||||||
|
} // namespace RenderD7
|
@ -1,16 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <renderd7/Ovl.hpp>
|
|
||||||
|
|
||||||
namespace RenderD7 {
|
|
||||||
class Ovl_Ftrace : public RenderD7::Ovl {
|
|
||||||
/// @brief Constructor
|
|
||||||
Ovl_Ftrace();
|
|
||||||
/// @brief Override for Draw
|
|
||||||
void Draw(void) const override;
|
|
||||||
/// @brief Override for Logic
|
|
||||||
void Logic() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
};
|
|
||||||
} // namespace RenderD7
|
|
76
include/renderd7/Overlays.hpp
Normal file
76
include/renderd7/Overlays.hpp
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <renderd7/Ovl.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
class Ovl_Ftrace : public RenderD7::Ovl {
|
||||||
|
public:
|
||||||
|
/// @brief Constructor
|
||||||
|
Ovl_Ftrace(bool* is_enabled);
|
||||||
|
/// @brief Override for Draw
|
||||||
|
void Draw(void) const override;
|
||||||
|
/// @brief Override for Logic
|
||||||
|
void Logic() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool* i_is_enabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Ovl_Metrik : public RenderD7::Ovl {
|
||||||
|
public:
|
||||||
|
/// @brief Constructor
|
||||||
|
Ovl_Metrik(bool* is_enabled, bool* screen, uint32_t* mt_color,
|
||||||
|
uint32_t* txt_color, float* txt_size);
|
||||||
|
/// @brief Override for Draw
|
||||||
|
void Draw(void) const override;
|
||||||
|
/// @brief Override for Logic
|
||||||
|
void Logic() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Mutable internal values
|
||||||
|
mutable std::string mt_fps;
|
||||||
|
mutable std::string mt_cpu;
|
||||||
|
mutable std::string mt_gpu;
|
||||||
|
mutable std::string mt_cmd;
|
||||||
|
mutable std::string mt_lfr;
|
||||||
|
mutable std::string mt_tbs;
|
||||||
|
|
||||||
|
// Importand Adresses
|
||||||
|
bool* i_is_enabled;
|
||||||
|
bool* i_screen;
|
||||||
|
uint32_t* i_mt_color;
|
||||||
|
uint32_t* i_txt_color;
|
||||||
|
float* i_txt_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef int RD7Keyboard;
|
||||||
|
|
||||||
|
enum RD7Keyboard_ {
|
||||||
|
RD7Keyboard_Default,
|
||||||
|
RD7Keyboard_Numpad,
|
||||||
|
RD7Keyboard_Password,
|
||||||
|
};
|
||||||
|
|
||||||
|
class Ovl_Keyboard : public RenderD7::Ovl {
|
||||||
|
public:
|
||||||
|
/// @brief Constructor
|
||||||
|
/// Keyboard Type not Supported for now
|
||||||
|
Ovl_Keyboard(std::string& ref, const std::string& hint = "",
|
||||||
|
RD7Keyboard type = 0);
|
||||||
|
/// @brief Deconstructor
|
||||||
|
~Ovl_Keyboard();
|
||||||
|
/// @brief Override for Draw
|
||||||
|
void Draw(void) const override;
|
||||||
|
/// @brief Override for Logic
|
||||||
|
void Logic() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
mutable std::map<unsigned char, char> shared_data;
|
||||||
|
// Pointer to useres String
|
||||||
|
std::string* typed_text = nullptr;
|
||||||
|
std::string str_bak;
|
||||||
|
int mode = 0;
|
||||||
|
int ft3 = 0;
|
||||||
|
};
|
||||||
|
} // namespace RenderD7
|
@ -4,7 +4,7 @@
|
|||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
/// @brief The Overlay Class (Used for Toasts for example)
|
/// @brief The Overlay Class (Used for Toasts for example)
|
||||||
class Ovl {
|
class Ovl {
|
||||||
public:
|
public:
|
||||||
/// @brief Deconstructor
|
/// @brief Deconstructor
|
||||||
virtual ~Ovl() {}
|
virtual ~Ovl() {}
|
||||||
/// @brief Function Called to Draw this
|
/// @brief Function Called to Draw this
|
||||||
@ -17,7 +17,7 @@ public:
|
|||||||
/// @brief Kill The Overlay
|
/// @brief Kill The Overlay
|
||||||
inline void Kill() { iskilled = true; }
|
inline void Kill() { iskilled = true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// @param iskilled For IsKilled();
|
/// @param iskilled For IsKilled();
|
||||||
bool iskilled = false;
|
bool iskilled = false;
|
||||||
};
|
};
|
||||||
|
42
include/renderd7/R7Vec.hpp
Normal file
42
include/renderd7/R7Vec.hpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
struct R7Vec2 {
|
||||||
|
// Init Funcs
|
||||||
|
R7Vec2() : x(0), y(0) {}
|
||||||
|
R7Vec2(float i0, float i1) : x(i0), y(i1) {}
|
||||||
|
R7Vec2(const R7Vec2 &i) {
|
||||||
|
x = i.x;
|
||||||
|
y = i.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Operators
|
||||||
|
// Add
|
||||||
|
R7Vec2 &operator+=(const R7Vec2 &i) {
|
||||||
|
x += i.x;
|
||||||
|
y += i.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
R7Vec2 operator+(const R7Vec2 &i) const { return R7Vec2(x + i.x, y + i.y); }
|
||||||
|
|
||||||
|
// Sub
|
||||||
|
R7Vec2 &operator-=(const R7Vec2 &i) {
|
||||||
|
x -= i.x;
|
||||||
|
y -= i.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
R7Vec2 operator-(const R7Vec2 &i) const { return R7Vec2(x - i.x, y - i.y); }
|
||||||
|
|
||||||
|
// Compare
|
||||||
|
bool operator==(const R7Vec2 &in) const { return x == in.x && y == in.y; }
|
||||||
|
|
||||||
|
bool operator!=(const R7Vec2 &in) const {
|
||||||
|
// use the first comparefuncs result
|
||||||
|
// and swap it lol
|
||||||
|
return !(*this == in);
|
||||||
|
}
|
||||||
|
// Internal Values
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
};
|
@ -1,11 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
/// @brief Decoder for 3ds Result Codes
|
/// @brief Decoder for 3ds Result Codes
|
||||||
class ResultDecoder {
|
class ResultDecoder {
|
||||||
public:
|
public:
|
||||||
/// @brief Constructor
|
/// @brief Constructor
|
||||||
ResultDecoder() {}
|
ResultDecoder() {}
|
||||||
/// @brief Deconstructor
|
/// @brief Deconstructor
|
||||||
@ -43,8 +44,10 @@ public:
|
|||||||
/// @brief Get the Summary Value
|
/// @brief Get the Summary Value
|
||||||
/// @return Summary Value
|
/// @return Summary Value
|
||||||
int GetSummaryInt();
|
int GetSummaryInt();
|
||||||
|
/// @brief Write a Result log file to sd
|
||||||
|
void WriteLog(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// @param m_rescode Result code
|
/// @param m_rescode Result code
|
||||||
Result m_rescode;
|
Result m_rescode;
|
||||||
};
|
};
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <3ds.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <3ds.h>
|
|
||||||
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
namespace Init {
|
namespace Init {
|
||||||
void Security();
|
void Security();
|
||||||
}
|
}
|
||||||
|
|
||||||
class Security {
|
class Security {
|
||||||
public:
|
public:
|
||||||
/// @brief Security Levels
|
/// @brief Security Levels
|
||||||
enum Level {
|
enum Level {
|
||||||
NONE, ///< Do Completly Nothing (excludes FrameEnd Security)
|
NONE, ///< Do Completly Nothing (excludes FrameEnd Security)
|
||||||
@ -24,10 +24,6 @@ public:
|
|||||||
|
|
||||||
Security();
|
Security();
|
||||||
~Security();
|
~Security();
|
||||||
/// @brief Report an Output (For SafeTraceInit)
|
|
||||||
/// @param addr Adress of Pointer
|
|
||||||
/// @param result_ptr Pointer to the result
|
|
||||||
void Report(uint32_t addr, void *result_ptr);
|
|
||||||
/// @brief Set the Security Level
|
/// @brief Set the Security Level
|
||||||
/// @param level Level to use
|
/// @param level Level to use
|
||||||
void SetLevel(Level level);
|
void SetLevel(Level level);
|
||||||
|
@ -1,19 +1,24 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <3ds.h> // Result
|
||||||
#include <citro2d.h>
|
#include <citro2d.h>
|
||||||
#include <citro3d.h>
|
#include <citro3d.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
/// @brief SpriteSheet Class
|
/// @brief SpriteSheet Class
|
||||||
class Sheet {
|
class Sheet {
|
||||||
public:
|
public:
|
||||||
/// @brief Constructor
|
/// @brief Constructor
|
||||||
Sheet();
|
Sheet() = default;
|
||||||
/// @brief Deconstructor
|
/// @brief Deconstructor
|
||||||
~Sheet();
|
~Sheet() {
|
||||||
|
if (spritesheet) Free();
|
||||||
|
}
|
||||||
/// @brief Load A Spritesheet File
|
/// @brief Load A Spritesheet File
|
||||||
/// @param path Path to the t3x
|
/// @param path Path to the t3x
|
||||||
/// @return Result Code
|
/// @return Result Code
|
||||||
Result Load(const char *path);
|
Result Load(const std::string& path);
|
||||||
/// @brief Unload the Sheet
|
/// @brief Unload the Sheet
|
||||||
void Free();
|
void Free();
|
||||||
/// \param spritesheet The Sheet
|
/// \param spritesheet The Sheet
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
/// @brief Sprite Class
|
/// @brief Sprite Class
|
||||||
class Sprite {
|
class Sprite {
|
||||||
public:
|
public:
|
||||||
/// \brief Construct Sprite
|
/// \brief Construct Sprite
|
||||||
Sprite();
|
Sprite() = default;
|
||||||
/// \brief Deconstruct Sprite
|
/// \brief Deconstruct Sprite
|
||||||
~Sprite();
|
~Sprite() = default;
|
||||||
/// \brief Load a Sprite From SpriteSheet
|
/// \brief Load a Sprite From SpriteSheet
|
||||||
/// \param sheet the Sheet to load from.(RenderD7::Sheet)
|
/// \param sheet the Sheet to load from.(RenderD7::Sheet)
|
||||||
/// \param index the number of the Sprite in the Sheet
|
/// \param index the number of the Sprite in the Sheet
|
||||||
@ -55,7 +55,7 @@ public:
|
|||||||
/// @return Y Position
|
/// @return Y Position
|
||||||
float getPosY();
|
float getPosY();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// @param tint ImageTint (unused)
|
/// @param tint ImageTint (unused)
|
||||||
C2D_ImageTint tint;
|
C2D_ImageTint tint;
|
||||||
/// @param sprite The Sprite
|
/// @param sprite The Sprite
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <renderd7/Sheet.hpp>
|
|
||||||
#include <renderd7/Sprite.hpp>
|
|
||||||
|
|
||||||
#include <citro2d.h>
|
#include <citro2d.h>
|
||||||
#include <citro3d.h>
|
#include <citro3d.h>
|
||||||
|
|
||||||
|
#include <renderd7/Sheet.hpp>
|
||||||
|
#include <renderd7/Sprite.hpp>
|
||||||
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
/// @brief SpriteSheetAnimation Class
|
/// @brief SpriteSheetAnimation Class
|
||||||
class SpriteSheetAnimation : public RenderD7::Sprite {
|
class SpriteSheetAnimation : public RenderD7::Sprite {
|
||||||
public:
|
public:
|
||||||
/// @brief Constructor
|
/// @brief Constructor
|
||||||
SpriteSheetAnimation();
|
SpriteSheetAnimation();
|
||||||
/// @brief Deconstructor
|
/// @brief Deconstructor
|
||||||
@ -26,7 +26,7 @@ public:
|
|||||||
/// @param timespeed Speed of the animation
|
/// @param timespeed Speed of the animation
|
||||||
void Play(float timespeed);
|
void Play(float timespeed);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// @param images Count of Images
|
/// @param images Count of Images
|
||||||
size_t images;
|
size_t images;
|
||||||
/// @param imgs Another Count of images ???
|
/// @param imgs Another Count of images ???
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
/// @brief StealConsole Class
|
/// @brief StealConsole Class
|
||||||
class StealConsole {
|
class StealConsole {
|
||||||
public:
|
public:
|
||||||
/// @brief Constructor
|
/// @brief Constructor
|
||||||
StealConsole();
|
StealConsole();
|
||||||
/// @brief Deconstructor
|
/// @brief Deconstructor
|
||||||
@ -14,7 +14,7 @@ public:
|
|||||||
/// @return Stdout as string
|
/// @return Stdout as string
|
||||||
std::string GetStdout();
|
std::string GetStdout();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// @param stolen_stdout Stolen Stdout
|
/// @param stolen_stdout Stolen Stdout
|
||||||
std::stringstream stolen_stdout;
|
std::stringstream stolen_stdout;
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
|
23
include/renderd7/Timer.hpp
Normal file
23
include/renderd7/Timer.hpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <3ds.h>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
class Timer {
|
||||||
|
public:
|
||||||
|
Timer(bool autostart = true);
|
||||||
|
~Timer() {}
|
||||||
|
void reset();
|
||||||
|
void tick();
|
||||||
|
void pause();
|
||||||
|
void resume();
|
||||||
|
float get();
|
||||||
|
float get_live();
|
||||||
|
bool running();
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint64_t last = 0;
|
||||||
|
uint64_t current = 0;
|
||||||
|
bool is_running = false;
|
||||||
|
};
|
||||||
|
} // namespace RenderD7
|
@ -1,24 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace RenderD7 {
|
|
||||||
struct Message {
|
|
||||||
Message(std::string t, std::string m) {
|
|
||||||
title = t;
|
|
||||||
message = m;
|
|
||||||
animationframe = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string title;
|
|
||||||
std::string message;
|
|
||||||
int animationframe;
|
|
||||||
};
|
|
||||||
|
|
||||||
void ProcessMessages();
|
|
||||||
void PushMessage(const Message& msg);
|
|
||||||
// Config
|
|
||||||
void SetIdleStartFrame(int frame);
|
|
||||||
void SetTotalAnimationFrames(int total_frames);
|
|
||||||
void SetFadeOutStartFrame(int frame);
|
|
||||||
}
|
|
54
include/renderd7/UI7.hpp
Normal file
54
include/renderd7/UI7.hpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <renderd7/DrawV2.hpp>
|
||||||
|
#include <renderd7/R7Vec.hpp>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
// UI7: The new RenderD7 UI Standart based on
|
||||||
|
// Draw2 (based on Citro2D)
|
||||||
|
|
||||||
|
#define UI7MAKEFLAG(x) (1 << x)
|
||||||
|
|
||||||
|
typedef int UI7MenuFlags;
|
||||||
|
|
||||||
|
enum UI7MenuFlags_ {
|
||||||
|
UI7MenuFlags_None = 0,
|
||||||
|
UI7MenuFlags_NoTitlebar = UI7MAKEFLAG(0),
|
||||||
|
UI7MenuFlags_TitleMid = UI7MAKEFLAG(1),
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace UI7 {
|
||||||
|
// Key functions
|
||||||
|
void Init();
|
||||||
|
void Deinit();
|
||||||
|
void Update();
|
||||||
|
float GetTime();
|
||||||
|
float GetDeltaTime();
|
||||||
|
|
||||||
|
bool Button(const std::string &label, R7Vec2 size = R7Vec2(0, 0));
|
||||||
|
void Checkbox(const std::string &label, bool &c);
|
||||||
|
void Label(const std::string &label, RD7TextFlags flags = 0);
|
||||||
|
void Progressbar(float value);
|
||||||
|
/// @brief Draw Image in Menu
|
||||||
|
/// @param img Pointer f.e to RenderD7::Image2
|
||||||
|
void Image(RenderD7::Image *img);
|
||||||
|
void BrowserList(const std::vector<std::string> &entrys, int &selection,
|
||||||
|
RD7TextFlags txtflags = 0, R7Vec2 size = R7Vec2(0, 0),
|
||||||
|
int max_entrys = 13);
|
||||||
|
void InputText(const std::string &label, std::string &text,
|
||||||
|
const std::string &hint = "");
|
||||||
|
bool BeginMenu(const std::string &title, R7Vec2 size = R7Vec2(0, 0),
|
||||||
|
UI7MenuFlags flags = 0);
|
||||||
|
void EndMenu();
|
||||||
|
void Grid(const std::string &name, const R7Vec2 &size,
|
||||||
|
R7Vec2 (*display_func)(void *, R7Vec2), void **data_array,
|
||||||
|
size_t num_entrys);
|
||||||
|
bool BeginTree(const std::string& text);
|
||||||
|
void EndTree();
|
||||||
|
R7Vec2 GetCursorPos();
|
||||||
|
void SetCursorPos(R7Vec2 cp);
|
||||||
|
void RestoreCursor();
|
||||||
|
void SameLine();
|
||||||
|
} // namespace UI7
|
@ -1,707 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <iterator>
|
|
||||||
#include <sstream>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
#pragma pack(push, 1)
|
|
||||||
|
|
||||||
struct BMPFileHeader {
|
|
||||||
uint16_t file_type{0x4D42}; // File type always BM which is 0x4D42 (stored as
|
|
||||||
// hex uint16_t in little endian)
|
|
||||||
uint32_t file_size{0}; // Size of the file (in bytes)
|
|
||||||
uint16_t reserved1{0}; // Reserved, always 0
|
|
||||||
uint16_t reserved2{0}; // Reserved, always 0
|
|
||||||
uint32_t offset_data{
|
|
||||||
0}; // Start position of pixel data (bytes from the beginning of the file)
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BMPInfoHeader {
|
|
||||||
uint32_t size{0}; // Size of this header (in bytes)
|
|
||||||
int32_t width{0}; // width of bitmap in pixels
|
|
||||||
int32_t height{
|
|
||||||
0}; // height of bitmap in pixels
|
|
||||||
// (if positive, bottom-up, with origin in lower left corner)
|
|
||||||
// (if negative, top-down, with origin in upper left corner)
|
|
||||||
uint16_t planes{1}; // No. of planes for the target device, this is always 1
|
|
||||||
uint16_t bit_count{0}; // No. of bits per pixel
|
|
||||||
uint32_t compression{0}; // 0 or 3 - uncompressed. THIS PROGRAM CONSIDERS ONLY
|
|
||||||
// UNCOMPRESSED BMP images
|
|
||||||
uint32_t size_image{0}; // 0 - for uncompressed images
|
|
||||||
int32_t x_pixels_per_meter{0};
|
|
||||||
int32_t y_pixels_per_meter{0};
|
|
||||||
uint32_t colors_used{0}; // No. color indexes in the color table. Use 0 for
|
|
||||||
// the max number of colors allowed by bit_count
|
|
||||||
uint32_t colors_important{0}; // No. of colors used for displaying the bitmap.
|
|
||||||
// If 0 all colors are required
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BMPColorHeader {
|
|
||||||
uint32_t red_mask{0x00ff0000}; // Bit mask for the red channel
|
|
||||||
uint32_t green_mask{0x0000ff00}; // Bit mask for the green channel
|
|
||||||
uint32_t blue_mask{0x000000ff}; // Bit mask for the blue channel
|
|
||||||
uint32_t alpha_mask{0xff000000}; // Bit mask for the alpha channel
|
|
||||||
uint32_t color_space_type{0x73524742}; // Default "sRGB" (0x73524742)
|
|
||||||
uint32_t unused[16]{0}; // Unused data for sRGB color space
|
|
||||||
};
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
class BMP {
|
|
||||||
public:
|
|
||||||
BMPFileHeader file_header;
|
|
||||||
BMPInfoHeader bmp_info_header;
|
|
||||||
BMPColorHeader bmp_color_header;
|
|
||||||
std::vector<uint8_t> data;
|
|
||||||
|
|
||||||
BMP(const char *fname) { read(fname); }
|
|
||||||
|
|
||||||
int read(const char *fname) {
|
|
||||||
std::ifstream inp{fname, std::ios_base::binary};
|
|
||||||
if (inp) {
|
|
||||||
inp.read((char *)&file_header, sizeof(file_header));
|
|
||||||
if (file_header.file_type != 0x4D42) {
|
|
||||||
|
|
||||||
return 50;
|
|
||||||
// throw std::runtime_error("Error! Unrecognized file format.");
|
|
||||||
}
|
|
||||||
inp.read((char *)&bmp_info_header, sizeof(bmp_info_header));
|
|
||||||
|
|
||||||
// The BMPColorHeader is used only for transparent images
|
|
||||||
if (bmp_info_header.bit_count == 32) {
|
|
||||||
// Check if the file has bit mask color information
|
|
||||||
if (bmp_info_header.size >=
|
|
||||||
(sizeof(BMPInfoHeader) + sizeof(BMPColorHeader))) {
|
|
||||||
inp.read((char *)&bmp_color_header, sizeof(bmp_color_header));
|
|
||||||
// Check if the pixel data is stored as BGRA and if the color space
|
|
||||||
// type is sRGB
|
|
||||||
check_color_header(bmp_color_header);
|
|
||||||
} else {
|
|
||||||
// std::cerr << "Error! The file \"" << fname << "\" does not seem to
|
|
||||||
// contain bit mask information\n"; return 51;//throw
|
|
||||||
// std::runtime_error("Error! Unrecognized file format.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Jump to the pixel data location
|
|
||||||
inp.seekg(file_header.offset_data, inp.beg);
|
|
||||||
|
|
||||||
// Adjust the header fields for output.
|
|
||||||
// Some editors will put extra info in the image file, we only save the
|
|
||||||
// headers and the data.
|
|
||||||
if (bmp_info_header.bit_count == 32) {
|
|
||||||
bmp_info_header.size = sizeof(BMPInfoHeader) + sizeof(BMPColorHeader);
|
|
||||||
file_header.offset_data = sizeof(BMPFileHeader) +
|
|
||||||
sizeof(BMPInfoHeader) +
|
|
||||||
sizeof(BMPColorHeader);
|
|
||||||
} else {
|
|
||||||
bmp_info_header.size = sizeof(BMPInfoHeader);
|
|
||||||
file_header.offset_data = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader);
|
|
||||||
}
|
|
||||||
file_header.file_size = file_header.offset_data;
|
|
||||||
|
|
||||||
if (bmp_info_header.height < 0) {
|
|
||||||
return 52; // throw std::runtime_error("The program can treat only BMP
|
|
||||||
// images with the origin in the bottom left corner!");
|
|
||||||
}
|
|
||||||
|
|
||||||
data.resize(bmp_info_header.width * bmp_info_header.height *
|
|
||||||
bmp_info_header.bit_count / 8);
|
|
||||||
|
|
||||||
// Here we check if we need to take into account row padding
|
|
||||||
if (bmp_info_header.width % 4 == 0) {
|
|
||||||
inp.read((char *)data.data(), data.size());
|
|
||||||
file_header.file_size += static_cast<uint32_t>(data.size());
|
|
||||||
} else {
|
|
||||||
row_stride = bmp_info_header.width * bmp_info_header.bit_count / 8;
|
|
||||||
uint32_t new_stride = make_stride_aligned(4);
|
|
||||||
std::vector<uint8_t> padding_row(new_stride - row_stride);
|
|
||||||
|
|
||||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
|
||||||
inp.read((char *)(data.data() + row_stride * y), row_stride);
|
|
||||||
inp.read((char *)padding_row.data(), padding_row.size());
|
|
||||||
}
|
|
||||||
file_header.file_size +=
|
|
||||||
static_cast<uint32_t>(data.size()) +
|
|
||||||
bmp_info_header.height * static_cast<uint32_t>(padding_row.size());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 53; // throw std::runtime_error("Unable to open the input image
|
|
||||||
// file "+std::string(fname));
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int read_mem(std::vector<unsigned char> buffer) {
|
|
||||||
std::stringstream inp;
|
|
||||||
std::copy(buffer.begin(), buffer.end(),
|
|
||||||
std::ostream_iterator<unsigned char>(inp, "\n"));
|
|
||||||
std::cout << buffer.size() << std::endl;
|
|
||||||
if (inp) {
|
|
||||||
inp.read((char *)&file_header, sizeof(file_header));
|
|
||||||
if (file_header.file_type != 0x4D42) {
|
|
||||||
|
|
||||||
return 50;
|
|
||||||
// throw std::runtime_error("Error! Unrecognized file format. Header " +
|
|
||||||
// std::to_string(file_header.file_type));
|
|
||||||
}
|
|
||||||
inp.read((char *)&bmp_info_header, sizeof(bmp_info_header));
|
|
||||||
|
|
||||||
// The BMPColorHeader is used only for transparent images
|
|
||||||
if (bmp_info_header.bit_count == 32) {
|
|
||||||
// Check if the file has bit mask color information
|
|
||||||
if (bmp_info_header.size >=
|
|
||||||
(sizeof(BMPInfoHeader) + sizeof(BMPColorHeader))) {
|
|
||||||
inp.read((char *)&bmp_color_header, sizeof(bmp_color_header));
|
|
||||||
// Check if the pixel data is stored as BGRA and if the color space
|
|
||||||
// type is sRGB
|
|
||||||
check_color_header(bmp_color_header);
|
|
||||||
} else {
|
|
||||||
// std::cerr << "Error! The file \"" << fname << "\" does not seem to
|
|
||||||
// contain bit mask information\n";
|
|
||||||
return 51;
|
|
||||||
// throw std::runtime_error("Error! Unrecognized file format. Size");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Jump to the pixel data location
|
|
||||||
inp.seekg(file_header.offset_data, inp.beg);
|
|
||||||
|
|
||||||
// Adjust the header fields for output.
|
|
||||||
// Some editors will put extra info in the image file, we only save the
|
|
||||||
// headers and the data.
|
|
||||||
if (bmp_info_header.bit_count == 32) {
|
|
||||||
bmp_info_header.size = sizeof(BMPInfoHeader) + sizeof(BMPColorHeader);
|
|
||||||
file_header.offset_data = sizeof(BMPFileHeader) +
|
|
||||||
sizeof(BMPInfoHeader) +
|
|
||||||
sizeof(BMPColorHeader);
|
|
||||||
} else {
|
|
||||||
bmp_info_header.size = sizeof(BMPInfoHeader);
|
|
||||||
file_header.offset_data = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader);
|
|
||||||
}
|
|
||||||
file_header.file_size = file_header.offset_data;
|
|
||||||
|
|
||||||
if (bmp_info_header.height < 0) {
|
|
||||||
return 52;
|
|
||||||
// throw std::runtime_error("The program can treat only BMP images with
|
|
||||||
// "
|
|
||||||
// "the origin in the bottom left corner!");
|
|
||||||
}
|
|
||||||
|
|
||||||
data.resize(bmp_info_header.width * bmp_info_header.height *
|
|
||||||
bmp_info_header.bit_count / 8);
|
|
||||||
|
|
||||||
// Here we check if we need to take into account row padding
|
|
||||||
if (bmp_info_header.width % 4 == 0) {
|
|
||||||
inp.read((char *)data.data(), data.size());
|
|
||||||
file_header.file_size += static_cast<uint32_t>(data.size());
|
|
||||||
} else {
|
|
||||||
row_stride = bmp_info_header.width * bmp_info_header.bit_count / 8;
|
|
||||||
uint32_t new_stride = make_stride_aligned(4);
|
|
||||||
std::vector<uint8_t> padding_row(new_stride - row_stride);
|
|
||||||
|
|
||||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
|
||||||
inp.read((char *)(data.data() + row_stride * y), row_stride);
|
|
||||||
inp.read((char *)padding_row.data(), padding_row.size());
|
|
||||||
}
|
|
||||||
file_header.file_size +=
|
|
||||||
static_cast<uint32_t>(data.size()) +
|
|
||||||
bmp_info_header.height * static_cast<uint32_t>(padding_row.size());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 53;
|
|
||||||
// throw std::runtime_error("Unable to open the input image buffer");
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
BMP(int32_t width, int32_t height, bool has_alpha = true) {
|
|
||||||
if (width <= 0 || height <= 0) {
|
|
||||||
width = 1;
|
|
||||||
height = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bmp_info_header.width = width;
|
|
||||||
bmp_info_header.height = height;
|
|
||||||
if (has_alpha) {
|
|
||||||
bmp_info_header.size = sizeof(BMPInfoHeader) + sizeof(BMPColorHeader);
|
|
||||||
file_header.offset_data = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader) +
|
|
||||||
sizeof(BMPColorHeader);
|
|
||||||
|
|
||||||
bmp_info_header.bit_count = 32;
|
|
||||||
bmp_info_header.compression = 3;
|
|
||||||
row_stride = width * 4;
|
|
||||||
data.resize(row_stride * height);
|
|
||||||
file_header.file_size = file_header.offset_data + data.size();
|
|
||||||
} else {
|
|
||||||
bmp_info_header.size = sizeof(BMPInfoHeader);
|
|
||||||
file_header.offset_data = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader);
|
|
||||||
|
|
||||||
bmp_info_header.bit_count = 24;
|
|
||||||
bmp_info_header.compression = 0;
|
|
||||||
row_stride = width * 3;
|
|
||||||
data.resize(row_stride * height);
|
|
||||||
|
|
||||||
uint32_t new_stride = make_stride_aligned(4);
|
|
||||||
file_header.file_size =
|
|
||||||
file_header.offset_data + static_cast<uint32_t>(data.size()) +
|
|
||||||
bmp_info_header.height * (new_stride - row_stride);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned write(const char *fname) {
|
|
||||||
std::ofstream of{fname, std::ios_base::binary};
|
|
||||||
if (of) {
|
|
||||||
if (bmp_info_header.bit_count == 32) {
|
|
||||||
write_headers_and_data(of);
|
|
||||||
} else if (bmp_info_header.bit_count == 24) {
|
|
||||||
if (bmp_info_header.width % 4 == 0) {
|
|
||||||
write_headers_and_data(of);
|
|
||||||
} else {
|
|
||||||
uint32_t new_stride = make_stride_aligned(4);
|
|
||||||
std::vector<uint8_t> padding_row(new_stride - row_stride);
|
|
||||||
|
|
||||||
write_headers(of);
|
|
||||||
|
|
||||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
|
||||||
of.write((const char *)(data.data() + row_stride * y), row_stride);
|
|
||||||
of.write((const char *)padding_row.data(), padding_row.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 54; // throw std::runtime_error("The program can treat only 24 or
|
|
||||||
// 32 bits per pixel BMP files");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 55; // throw std::runtime_error("Unable to open the output image
|
|
||||||
// file.");
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<unsigned char> DATA() {
|
|
||||||
std::stringstream ss;
|
|
||||||
if (ss) {
|
|
||||||
if (bmp_info_header.bit_count == 32) {
|
|
||||||
write_headers_and_datass(ss);
|
|
||||||
} else if (bmp_info_header.bit_count == 24) {
|
|
||||||
if (bmp_info_header.width % 4 == 0) {
|
|
||||||
write_headers_and_datass(ss);
|
|
||||||
} else {
|
|
||||||
uint32_t new_stride = make_stride_aligned(4);
|
|
||||||
std::vector<uint8_t> padding_row(new_stride - row_stride);
|
|
||||||
|
|
||||||
write_headersss(ss);
|
|
||||||
|
|
||||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
|
||||||
ss.write((const char *)(data.data() + row_stride * y), row_stride);
|
|
||||||
ss.write((const char *)padding_row.data(), padding_row.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
std::string test11 = ss.str();
|
|
||||||
std::vector<unsigned char> test12(test11.begin(), test11.end());
|
|
||||||
return test12;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned fill_region(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h,
|
|
||||||
uint8_t B, uint8_t G, uint8_t R, uint8_t A) {
|
|
||||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
/*if (x + w > (uint32_t)bmp_info_header.width || y + h >
|
|
||||||
(uint32_t)bmp_info_header.height) {
|
|
||||||
//
|
|
||||||
}*/
|
|
||||||
// else{
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = B;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = G;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = R;
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void fill_region_df(uint32_t x1, uint32_t y1, uint32_t w, uint32_t h,
|
|
||||||
uint8_t B, uint8_t G, uint8_t R, uint8_t A) {
|
|
||||||
|
|
||||||
int x0 = x1;
|
|
||||||
int y0 = this->bmp_info_header.height - y1 - h;
|
|
||||||
|
|
||||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
if ((x + w < (uint32_t)bmp_info_header.width) ||
|
|
||||||
this->bmp_info_header.height - y - h > 0) {
|
|
||||||
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = B;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = G;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = R;
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void manipulate_region(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h,
|
|
||||||
uint8_t A) {
|
|
||||||
int choice, choice2, intensity;
|
|
||||||
cout << "What color do you want to change? " << endl;
|
|
||||||
cout << "Enter 1 for Blue, 2 for Green, 3 for Red " << endl;
|
|
||||||
cin >> choice;
|
|
||||||
cout << "To what color do you want to change it too?" << endl;
|
|
||||||
cout << "Enter 1 for Blue, 2 for Green, 3 for Red " << endl;
|
|
||||||
cin >> choice2;
|
|
||||||
cout << "Enter the intensity of the color. (From 0 to 255) " << endl;
|
|
||||||
cin >> intensity;
|
|
||||||
if (x0 + w > (uint32_t)bmp_info_header.width ||
|
|
||||||
y0 + h > (uint32_t)bmp_info_header.height) {
|
|
||||||
return; // throw std::runtime_error("The region does not fit in the
|
|
||||||
// image!");
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
|
||||||
if (choice == 1 && choice2 == 1) {
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
cout << channels * (y * bmp_info_header.width + x) << endl;
|
|
||||||
// Make blue thing blue
|
|
||||||
if (data[channels * (y * bmp_info_header.width + x) + 0] > 80 &&
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] < 255) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = intensity;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = 0;
|
|
||||||
}
|
|
||||||
// data[channels * (y * bmp_info_header.width + x) + 0] = B;
|
|
||||||
// data[channels * (y * bmp_info_header.width + x) + 1] = G;
|
|
||||||
// data[channels * (y * bmp_info_header.width + x) + 2] = R;
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (choice == 1 && choice2 == 2) {
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
cout << channels * (y * bmp_info_header.width + x) << endl;
|
|
||||||
// Make blue thing green
|
|
||||||
if (data[channels * (y * bmp_info_header.width + x) + 0] > 80 &&
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] < 255) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = intensity;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = 0;
|
|
||||||
}
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (choice == 1 && choice2 == 3) {
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
cout << channels * (y * bmp_info_header.width + x) << endl;
|
|
||||||
// Make blue thing red
|
|
||||||
if (data[channels * (y * bmp_info_header.width + x) + 0] > 80 &&
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] < 255) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = intensity;
|
|
||||||
}
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (choice == 2 && choice2 == 1) {
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
cout << channels * (y * bmp_info_header.width + x) << endl;
|
|
||||||
// Make green thing blue
|
|
||||||
if (data[channels * (y * bmp_info_header.width + x) + 1] > 80 &&
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] < 255) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = intensity;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = 0;
|
|
||||||
}
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (choice == 2 && choice2 == 2) {
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
cout << channels * (y * bmp_info_header.width + x) << endl;
|
|
||||||
// Make green thing green
|
|
||||||
if (data[channels * (y * bmp_info_header.width + x) + 1] > 80 &&
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] < 255) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = intensity;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = 0;
|
|
||||||
}
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (choice == 2 && choice2 == 3) {
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
cout << channels * (y * bmp_info_header.width + x) << endl;
|
|
||||||
// Make green thing red
|
|
||||||
if (data[channels * (y * bmp_info_header.width + x) + 1] > 80 &&
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] < 255) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = intensity;
|
|
||||||
}
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (choice == 3 && choice2 == 1) {
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
cout << channels * (y * bmp_info_header.width + x) << endl;
|
|
||||||
// Make red thing blue
|
|
||||||
if (data[channels * (y * bmp_info_header.width + x) + 2] > 80 &&
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] < 255) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = intensity;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = 0;
|
|
||||||
}
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (choice == 3 && choice2 == 2) {
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
cout << channels * (y * bmp_info_header.width + x) << endl;
|
|
||||||
// Make red thing green
|
|
||||||
if (data[channels * (y * bmp_info_header.width + x) + 2] > 80 &&
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] < 255) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = intensity;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = 0;
|
|
||||||
}
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (choice == 3 && choice2 == 3) {
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
cout << channels * (y * bmp_info_header.width + x) << endl;
|
|
||||||
// Make red thing blue
|
|
||||||
if (data[channels * (y * bmp_info_header.width + x) + 2] > 80 &&
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] < 255) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = intensity;
|
|
||||||
}
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned set_pixel(uint32_t x0, uint32_t y0, uint8_t B, uint8_t G, uint8_t R,
|
|
||||||
uint8_t A) {
|
|
||||||
if (x0 >= (uint32_t)bmp_info_header.width ||
|
|
||||||
y0 >= (uint32_t)bmp_info_header.height || x0 < 0 || y0 < 0) {
|
|
||||||
return 59;
|
|
||||||
// std::string errr = "The point is outside the image boundaries! -> " +
|
|
||||||
// std::to_string(x0) + "," + std::to_string(y0); throw
|
|
||||||
// std::runtime_error(errr);
|
|
||||||
}
|
|
||||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
|
||||||
data[channels * (y0 * bmp_info_header.width + x0) + 0] = B;
|
|
||||||
data[channels * (y0 * bmp_info_header.width + x0) + 1] = G;
|
|
||||||
data[channels * (y0 * bmp_info_header.width + x0) + 2] = R;
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y0 * bmp_info_header.width + x0) + 3] = A;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_pixel_df(uint32_t x0, uint32_t y0, uint8_t B, uint8_t G, uint8_t R,
|
|
||||||
uint8_t A) {
|
|
||||||
uint32_t y1 = this->bmp_info_header.height - y0;
|
|
||||||
if (x0 >= (uint32_t)bmp_info_header.width ||
|
|
||||||
y1 <= (uint32_t)bmp_info_header.width || x0 < 0 || y0 > 0) {
|
|
||||||
return;
|
|
||||||
// throw std::runtime_error("The point is outside the image boundaries! ->
|
|
||||||
// " + std::to_string(x0) + "," + std::to_string(y1));
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
|
||||||
data[channels * (y0 * bmp_info_header.width + x0) + 0] = B;
|
|
||||||
data[channels * (y0 * bmp_info_header.width + x0) + 1] = G;
|
|
||||||
data[channels * (y0 * bmp_info_header.width + x0) + 2] = R;
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y0 * bmp_info_header.width + x0) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t get_pixel(uint32_t x0, uint32_t y0) {
|
|
||||||
if (x0 >= (uint32_t)bmp_info_header.width ||
|
|
||||||
y0 >= (uint32_t)bmp_info_header.height || x0 < 0 || y0 < 0) {
|
|
||||||
return 59; // throw std::runtime_error("The point is outside the image
|
|
||||||
// boundaries!");
|
|
||||||
}
|
|
||||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
|
||||||
uint32_t outcol = 0;
|
|
||||||
uint8_t red = 0;
|
|
||||||
uint8_t green = 0;
|
|
||||||
uint8_t blue = 0;
|
|
||||||
uint8_t alpha = 255;
|
|
||||||
blue = data[channels * (y0 * bmp_info_header.width + x0) + 0];
|
|
||||||
green = data[channels * (y0 * bmp_info_header.width + x0) + 1];
|
|
||||||
red = data[channels * (y0 * bmp_info_header.width + x0) + 2];
|
|
||||||
if (channels == 4) {
|
|
||||||
alpha = data[channels * (y0 * bmp_info_header.width + x0) + 3];
|
|
||||||
}
|
|
||||||
outcol = ((red << 24) | (green << 16) | (blue << 8) | alpha);
|
|
||||||
return outcol;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t get_pixel_df(uint32_t x0, uint32_t y0) {
|
|
||||||
uint32_t y1 = this->bmp_info_header.height - y0;
|
|
||||||
if (x0 >= (uint32_t)bmp_info_header.width ||
|
|
||||||
y1 <= (uint32_t)bmp_info_header.width || x0 < 0 || y0 > 0) {
|
|
||||||
return 0; // throw std::runtime_error("The point is outside the image
|
|
||||||
// boundaries!");
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
|
||||||
uint32_t outcol = 0;
|
|
||||||
uint8_t red = 0;
|
|
||||||
uint8_t green = 0;
|
|
||||||
uint8_t blue = 0;
|
|
||||||
uint8_t alpha = 255;
|
|
||||||
blue = data[channels * (y0 * bmp_info_header.width + x0) + 0];
|
|
||||||
green = data[channels * (y0 * bmp_info_header.width + x0) + 1];
|
|
||||||
red = data[channels * (y0 * bmp_info_header.width + x0) + 2];
|
|
||||||
if (channels == 4) {
|
|
||||||
alpha = data[channels * (y0 * bmp_info_header.width + x0) + 3];
|
|
||||||
}
|
|
||||||
outcol = ((red << 24) | (green << 16) | (blue << 8) | alpha);
|
|
||||||
return outcol;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned draw_rectangle(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h,
|
|
||||||
uint8_t B, uint8_t G, uint8_t R, uint8_t A,
|
|
||||||
uint8_t line_w) {
|
|
||||||
if (x0 + w > (uint32_t)bmp_info_header.width ||
|
|
||||||
y0 + h > (uint32_t)bmp_info_header.height) {
|
|
||||||
return 59; // throw std::runtime_error("The rectangle does not fit in the
|
|
||||||
// image!");
|
|
||||||
}
|
|
||||||
|
|
||||||
fill_region(x0, y0, w, line_w, B, G, R, A); // top line
|
|
||||||
fill_region(x0, (y0 + h - line_w), w, line_w, B, G, R, A); // bottom line
|
|
||||||
fill_region((x0 + w - line_w), (y0 + line_w), line_w, (h - (2 * line_w)), B,
|
|
||||||
G, R, A); // right line
|
|
||||||
fill_region(x0, (y0 + line_w), line_w, (h - (2 * line_w)), B, G, R,
|
|
||||||
A); // left line
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw_rectangle_df(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h,
|
|
||||||
uint8_t B, uint8_t G, uint8_t R, uint8_t A,
|
|
||||||
uint8_t line_w) {
|
|
||||||
if (x0 + w > (uint32_t)bmp_info_header.width ||
|
|
||||||
y0 + h > (uint32_t)bmp_info_header.height) {
|
|
||||||
return; // throw std::runtime_error("The rectangle does not fit in the
|
|
||||||
// image!");
|
|
||||||
}
|
|
||||||
|
|
||||||
fill_region_df(x0, y0, w, line_w, B, G, R, A); // top line
|
|
||||||
fill_region_df(x0, (y0 + h - line_w), w, line_w, B, G, R, A); // bottom line
|
|
||||||
fill_region_df((x0 + w - line_w), (y0 + line_w), line_w, (h - (2 * line_w)),
|
|
||||||
B, G, R, A); // right line
|
|
||||||
fill_region_df(x0, (y0 + line_w), line_w, (h - (2 * line_w)), B, G, R,
|
|
||||||
A); // left line
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
uint32_t row_stride{0};
|
|
||||||
|
|
||||||
void write_headers(std::ofstream &of) {
|
|
||||||
of.write((const char *)&file_header, sizeof(file_header));
|
|
||||||
of.write((const char *)&bmp_info_header, sizeof(bmp_info_header));
|
|
||||||
if (bmp_info_header.bit_count == 32) {
|
|
||||||
of.write((const char *)&bmp_color_header, sizeof(bmp_color_header));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void write_headers_and_data(std::ofstream &of) {
|
|
||||||
write_headers(of);
|
|
||||||
of.write((const char *)data.data(), data.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
void write_headersss(std::stringstream &of) {
|
|
||||||
of.write((const char *)&file_header, sizeof(file_header));
|
|
||||||
of.write((const char *)&bmp_info_header, sizeof(bmp_info_header));
|
|
||||||
if (bmp_info_header.bit_count == 32) {
|
|
||||||
of.write((const char *)&bmp_color_header, sizeof(bmp_color_header));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void write_headers_and_datass(std::stringstream &of) {
|
|
||||||
write_headersss(of);
|
|
||||||
of.write((const char *)data.data(), data.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add 1 to the row_stride until it is divisible with align_stride
|
|
||||||
uint32_t make_stride_aligned(uint32_t align_stride) {
|
|
||||||
uint32_t new_stride = row_stride;
|
|
||||||
while (new_stride % align_stride != 0) {
|
|
||||||
new_stride++;
|
|
||||||
}
|
|
||||||
return new_stride;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the pixel data is stored as BGRA and if the color space type is
|
|
||||||
// sRGB
|
|
||||||
void check_color_header(BMPColorHeader &bmp_color_header) {
|
|
||||||
BMPColorHeader expected_color_header;
|
|
||||||
if (expected_color_header.red_mask != bmp_color_header.red_mask ||
|
|
||||||
expected_color_header.blue_mask != bmp_color_header.blue_mask ||
|
|
||||||
expected_color_header.green_mask != bmp_color_header.green_mask ||
|
|
||||||
expected_color_header.alpha_mask != bmp_color_header.alpha_mask) {
|
|
||||||
return; // throw std::runtime_error("Unexpected color mask format! The
|
|
||||||
// program expects the pixel data to be in the BGRA format");
|
|
||||||
}
|
|
||||||
if (expected_color_header.color_space_type !=
|
|
||||||
bmp_color_header.color_space_type) {
|
|
||||||
return; // throw std::runtime_error("Unexpected color space type! The
|
|
||||||
// program expects sRGB values");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,21 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <renderd7/external/lodepng.h>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace BitmapConverter {
|
|
||||||
/// returns 0 if all went ok, non-0 if error
|
|
||||||
/// output image is always given in RGBA (with alpha channel), even if it's a
|
|
||||||
/// BMP without alpha channel
|
|
||||||
unsigned decodeBMP(std::vector<unsigned char> &image, unsigned &w, unsigned &h,
|
|
||||||
const std::vector<unsigned char> &bmp);
|
|
||||||
|
|
||||||
/// @brief Convert A File
|
|
||||||
/// @param filename
|
|
||||||
/// @return data
|
|
||||||
std::vector<unsigned char> ConvertFile(std::string filename);
|
|
||||||
/// @brief Convert data
|
|
||||||
/// @param data
|
|
||||||
/// @return data
|
|
||||||
std::vector<unsigned char> ConvertData(std::vector<unsigned char> data);
|
|
||||||
} // namespace BitmapConverter
|
|
@ -1,187 +0,0 @@
|
|||||||
/*
|
|
||||||
This file was autogenerated by raw2c.
|
|
||||||
Visit http://www.devkitpro.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
|
||||||
#ifndef _debugfont_h_
|
|
||||||
#define _debugfont_h_
|
|
||||||
//---------------------------------------------------------------------------------
|
|
||||||
static const unsigned char debugfont[] = {
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81,
|
|
||||||
0xbd, 0x99, 0x81, 0x7e, 0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e,
|
|
||||||
0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x10, 0x38, 0x7c, 0xfe,
|
|
||||||
0x7c, 0x38, 0x10, 0x00, 0x3c, 0x3c, 0x18, 0xff, 0xe7, 0x18, 0x3c, 0x00,
|
|
||||||
0x10, 0x38, 0x7c, 0xfe, 0xee, 0x10, 0x38, 0x00, 0x00, 0x00, 0x18, 0x3c,
|
|
||||||
0x3c, 0x18, 0x00, 0x00, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff,
|
|
||||||
0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0xff, 0xc3, 0x99, 0xbd,
|
|
||||||
0xbd, 0x99, 0xc3, 0xff, 0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0xcc, 0x78,
|
|
||||||
0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x08, 0x0c, 0x0a, 0x0a,
|
|
||||||
0x08, 0x78, 0xf0, 0x00, 0x18, 0x14, 0x1a, 0x16, 0x72, 0xe2, 0x0e, 0x1c,
|
|
||||||
0x10, 0x54, 0x38, 0xee, 0x38, 0x54, 0x10, 0x00, 0x80, 0xe0, 0xf8, 0xfe,
|
|
||||||
0xf8, 0xe0, 0x80, 0x00, 0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0x02, 0x00,
|
|
||||||
0x18, 0x3c, 0x5a, 0x18, 0x5a, 0x3c, 0x18, 0x00, 0x66, 0x66, 0x66, 0x66,
|
|
||||||
0x66, 0x00, 0x66, 0x00, 0x7f, 0xdb, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x00,
|
|
||||||
0x1c, 0x22, 0x38, 0x44, 0x44, 0x38, 0x88, 0x70, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x7e, 0x7e, 0x7e, 0x00, 0x18, 0x3c, 0x5a, 0x18, 0x5a, 0x3c, 0x18, 0x7e,
|
|
||||||
0x18, 0x3c, 0x5a, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18,
|
|
||||||
0x5a, 0x3c, 0x18, 0x00, 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00,
|
|
||||||
0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0,
|
|
||||||
0xc0, 0xfe, 0x00, 0x00, 0x00, 0x24, 0x42, 0xff, 0x42, 0x24, 0x00, 0x00,
|
|
||||||
0x00, 0x10, 0x38, 0x7c, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x7c,
|
|
||||||
0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x18, 0x3c, 0x3c, 0x18, 0x18, 0x00, 0x18, 0x00, 0x6c, 0x24, 0x24, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00,
|
|
||||||
0x10, 0x7c, 0xd0, 0x7c, 0x16, 0xfc, 0x10, 0x00, 0x00, 0x66, 0xac, 0xd8,
|
|
||||||
0x36, 0x6a, 0xcc, 0x00, 0x38, 0x4c, 0x38, 0x78, 0xce, 0xcc, 0x7a, 0x00,
|
|
||||||
0x30, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, 0x60,
|
|
||||||
0x60, 0x30, 0x18, 0x00, 0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00,
|
|
||||||
0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x30, 0x30, 0xfc,
|
|
||||||
0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x10, 0x20,
|
|
||||||
0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x30, 0x00, 0x02, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x00,
|
|
||||||
0x7c, 0xce, 0xde, 0xf6, 0xe6, 0xe6, 0x7c, 0x00, 0x18, 0x38, 0x78, 0x18,
|
|
||||||
0x18, 0x18, 0x7e, 0x00, 0x7c, 0xc6, 0x06, 0x1c, 0x70, 0xc6, 0xfe, 0x00,
|
|
||||||
0x7c, 0xc6, 0x06, 0x3c, 0x06, 0xc6, 0x7c, 0x00, 0x1c, 0x3c, 0x6c, 0xcc,
|
|
||||||
0xfe, 0x0c, 0x1e, 0x00, 0xfe, 0xc0, 0xfc, 0x06, 0x06, 0xc6, 0x7c, 0x00,
|
|
||||||
0x7c, 0xc6, 0xc0, 0xfc, 0xc6, 0xc6, 0x7c, 0x00, 0xfe, 0xc6, 0x0c, 0x18,
|
|
||||||
0x30, 0x30, 0x30, 0x00, 0x7c, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0x7c, 0x00,
|
|
||||||
0x7c, 0xc6, 0xc6, 0x7e, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x30, 0x00, 0x00,
|
|
||||||
0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x10, 0x20,
|
|
||||||
0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x7e, 0x00,
|
|
||||||
0x00, 0x7e, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x60, 0x00,
|
|
||||||
0x78, 0xcc, 0x0c, 0x18, 0x30, 0x00, 0x30, 0x00, 0x7c, 0x82, 0x9e, 0xa6,
|
|
||||||
0x9e, 0x80, 0x7c, 0x00, 0x7c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00,
|
|
||||||
0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0xfc, 0x00, 0x7c, 0xc6, 0xc0, 0xc0,
|
|
||||||
0xc0, 0xc6, 0x7c, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x66, 0x66, 0xfc, 0x00,
|
|
||||||
0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0xfe, 0x00, 0xfe, 0x62, 0x68, 0x78,
|
|
||||||
0x68, 0x60, 0xf0, 0x00, 0x7c, 0xc6, 0xc6, 0xc0, 0xce, 0xc6, 0x7e, 0x00,
|
|
||||||
0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x3c, 0x18, 0x18, 0x18,
|
|
||||||
0x18, 0x18, 0x3c, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0x00,
|
|
||||||
0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0xe6, 0x00, 0xf0, 0x60, 0x60, 0x60,
|
|
||||||
0x62, 0x66, 0xfe, 0x00, 0x82, 0xc6, 0xee, 0xfe, 0xd6, 0xc6, 0xc6, 0x00,
|
|
||||||
0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6,
|
|
||||||
0xc6, 0xc6, 0x7c, 0x00, 0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00,
|
|
||||||
0x7c, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x06, 0xfc, 0x66, 0x66, 0x7c,
|
|
||||||
0x66, 0x66, 0xe6, 0x00, 0x7c, 0xc6, 0xc0, 0x7c, 0x06, 0xc6, 0x7c, 0x00,
|
|
||||||
0x7e, 0x5a, 0x5a, 0x18, 0x18, 0x18, 0x3c, 0x00, 0xc6, 0xc6, 0xc6, 0xc6,
|
|
||||||
0xc6, 0xc6, 0x7c, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x10, 0x00,
|
|
||||||
0xc6, 0xc6, 0xd6, 0xfe, 0xee, 0xc6, 0x82, 0x00, 0xc6, 0x6c, 0x38, 0x38,
|
|
||||||
0x38, 0x6c, 0xc6, 0x00, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x3c, 0x00,
|
|
||||||
0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0xfe, 0x00, 0x78, 0x60, 0x60, 0x60,
|
|
||||||
0x60, 0x60, 0x78, 0x00, 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x02, 0x00,
|
|
||||||
0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00, 0x10, 0x38, 0x6c, 0xc6,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
|
|
||||||
0x30, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c,
|
|
||||||
0x7c, 0xcc, 0x76, 0x00, 0xe0, 0x60, 0x60, 0x7c, 0x66, 0x66, 0x7c, 0x00,
|
|
||||||
0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc6, 0x7c, 0x00, 0x1c, 0x0c, 0x0c, 0x7c,
|
|
||||||
0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00,
|
|
||||||
0x1c, 0x36, 0x30, 0x78, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, 0x76, 0xcc,
|
|
||||||
0xcc, 0x7c, 0x0c, 0x78, 0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0xe6, 0x00,
|
|
||||||
0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x0c, 0x00, 0x1c,
|
|
||||||
0x0c, 0x0c, 0xcc, 0x78, 0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0xe6, 0x00,
|
|
||||||
0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0xcc, 0xfe,
|
|
||||||
0xd6, 0xd6, 0xd6, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x00,
|
|
||||||
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0xdc, 0x66,
|
|
||||||
0x66, 0x7c, 0x60, 0xf0, 0x00, 0x00, 0x7c, 0xcc, 0xcc, 0x7c, 0x0c, 0x1e,
|
|
||||||
0x00, 0x00, 0xde, 0x76, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x7c, 0xc0,
|
|
||||||
0x7c, 0x06, 0x7c, 0x00, 0x10, 0x30, 0xfc, 0x30, 0x30, 0x34, 0x18, 0x00,
|
|
||||||
0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0xc6, 0xc6,
|
|
||||||
0x6c, 0x38, 0x10, 0x00, 0x00, 0x00, 0xc6, 0xd6, 0xd6, 0xfe, 0x6c, 0x00,
|
|
||||||
0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0xcc, 0xcc,
|
|
||||||
0xcc, 0x7c, 0x0c, 0xf8, 0x00, 0x00, 0xfc, 0x98, 0x30, 0x64, 0xfc, 0x00,
|
|
||||||
0x0e, 0x18, 0x18, 0x30, 0x18, 0x18, 0x0e, 0x00, 0x18, 0x18, 0x18, 0x00,
|
|
||||||
0x18, 0x18, 0x18, 0x00, 0xe0, 0x30, 0x30, 0x18, 0x30, 0x30, 0xe0, 0x00,
|
|
||||||
0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c,
|
|
||||||
0xc6, 0xc6, 0xfe, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc6, 0x7c, 0x18, 0x70,
|
|
||||||
0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x0e, 0x10, 0x7c, 0xc6,
|
|
||||||
0xfe, 0xc0, 0x7c, 0x00, 0x7c, 0x82, 0x38, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
|
|
||||||
0xcc, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, 0xe0, 0x10, 0x78, 0x0c,
|
|
||||||
0x7c, 0xcc, 0x76, 0x00, 0x30, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
|
|
||||||
0x00, 0x00, 0x7c, 0xc0, 0xc0, 0x7c, 0x18, 0x70, 0x7c, 0x82, 0x7c, 0xc6,
|
|
||||||
0xfe, 0xc0, 0x7c, 0x00, 0xc6, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00,
|
|
||||||
0xe0, 0x10, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00, 0x66, 0x00, 0x38, 0x18,
|
|
||||||
0x18, 0x18, 0x3c, 0x00, 0x7c, 0x82, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00,
|
|
||||||
0xe0, 0x10, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00, 0xc6, 0x00, 0x7c, 0xc6,
|
|
||||||
0xfe, 0xc6, 0xc6, 0x00, 0x38, 0x38, 0x7c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00,
|
|
||||||
0x0e, 0x10, 0xfe, 0x60, 0x78, 0x60, 0xfe, 0x00, 0x00, 0x00, 0x7c, 0x12,
|
|
||||||
0x7e, 0xd0, 0x7e, 0x00, 0x7e, 0xc8, 0xc8, 0xfe, 0xc8, 0xc8, 0xce, 0x00,
|
|
||||||
0x7c, 0x82, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0xc6, 0x00, 0x7c, 0xc6,
|
|
||||||
0xc6, 0xc6, 0x7c, 0x00, 0xe0, 0x10, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
|
|
||||||
0x7c, 0x82, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0xe0, 0x10, 0xcc, 0xcc,
|
|
||||||
0xcc, 0xcc, 0x76, 0x00, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8,
|
|
||||||
0xc6, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0xc6, 0x00, 0xc6, 0xc6,
|
|
||||||
0xc6, 0xc6, 0x7c, 0x00, 0x18, 0x7c, 0xd6, 0xd0, 0xd6, 0x7c, 0x18, 0x00,
|
|
||||||
0x38, 0x6c, 0x60, 0xf0, 0x60, 0xf2, 0xdc, 0x00, 0x66, 0x3c, 0x18, 0x7e,
|
|
||||||
0x18, 0x7e, 0x18, 0x00, 0xf8, 0xcc, 0xf8, 0xc4, 0xcc, 0xde, 0xcc, 0x06,
|
|
||||||
0x0e, 0x1b, 0x18, 0x3c, 0x18, 0x18, 0xd8, 0x70, 0x0e, 0x10, 0x78, 0x0c,
|
|
||||||
0x7c, 0xcc, 0x76, 0x00, 0x0e, 0x10, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00,
|
|
||||||
0x0e, 0x10, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x0e, 0x10, 0xcc, 0xcc,
|
|
||||||
0xcc, 0xcc, 0x76, 0x00, 0x66, 0x98, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x00,
|
|
||||||
0x66, 0x98, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0x00, 0x38, 0x0c, 0x3c, 0x34,
|
|
||||||
0x00, 0x7e, 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00,
|
|
||||||
0x30, 0x00, 0x30, 0x60, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0xfc,
|
|
||||||
0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x0c, 0x0c, 0x00, 0x00,
|
|
||||||
0xc0, 0xc8, 0xd0, 0xfe, 0x46, 0x8c, 0x1e, 0x00, 0xc0, 0xc8, 0xd0, 0xec,
|
|
||||||
0x5c, 0xbe, 0x0c, 0x00, 0x18, 0x00, 0x18, 0x18, 0x3c, 0x3c, 0x18, 0x00,
|
|
||||||
0x00, 0x36, 0x6c, 0xd8, 0x6c, 0x36, 0x00, 0x00, 0x00, 0xd8, 0x6c, 0x36,
|
|
||||||
0x6c, 0xd8, 0x00, 0x00, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88,
|
|
||||||
0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0xdb, 0x77, 0xdb, 0xee,
|
|
||||||
0xdb, 0x77, 0xdb, 0xee, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
|
||||||
0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18,
|
|
||||||
0xf8, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36, 0x00, 0x00, 0xf8, 0x18,
|
|
||||||
0xf8, 0x18, 0x18, 0x18, 0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36,
|
|
||||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0xfe, 0x06,
|
|
||||||
0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00,
|
|
||||||
0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00, 0x18, 0x18, 0xf8, 0x18,
|
|
||||||
0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18,
|
|
||||||
0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18,
|
|
||||||
0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18,
|
|
||||||
0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0xff, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18,
|
|
||||||
0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36,
|
|
||||||
0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00,
|
|
||||||
0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36,
|
|
||||||
0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x00, 0x00, 0xff, 0x00,
|
|
||||||
0xff, 0x00, 0x00, 0x00, 0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36,
|
|
||||||
0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36,
|
|
||||||
0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
|
||||||
0x3f, 0x00, 0x00, 0x00, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x3f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36,
|
|
||||||
0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
|
||||||
0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
|
|
||||||
0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0xcc, 0xc8, 0xdc, 0x76, 0x00,
|
|
||||||
0x78, 0xcc, 0xd8, 0xcc, 0xc6, 0xc6, 0xdc, 0x40, 0xfe, 0x62, 0x60, 0x60,
|
|
||||||
0x60, 0x60, 0xf0, 0x00, 0x00, 0x02, 0x7e, 0xec, 0x6c, 0x6c, 0x48, 0x00,
|
|
||||||
0xfe, 0x62, 0x30, 0x18, 0x30, 0x62, 0xfe, 0x00, 0x00, 0x00, 0x7e, 0xd0,
|
|
||||||
0xc8, 0xc8, 0x70, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xf8, 0x80,
|
|
||||||
0x00, 0x00, 0x7e, 0xd8, 0x18, 0x18, 0x10, 0x00, 0x38, 0x10, 0x7c, 0xd6,
|
|
||||||
0xd6, 0x7c, 0x10, 0x38, 0x7c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0x7c, 0x00,
|
|
||||||
0x7c, 0xc6, 0xc6, 0xc6, 0x6c, 0x28, 0xee, 0x00, 0x3c, 0x22, 0x18, 0x7c,
|
|
||||||
0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x66, 0x99, 0x99, 0x66, 0x00, 0x00,
|
|
||||||
0x00, 0x06, 0x7c, 0x9e, 0xf2, 0x7c, 0xc0, 0x00, 0x00, 0x00, 0x7c, 0xc0,
|
|
||||||
0xf8, 0xc0, 0x7c, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00,
|
|
||||||
0x00, 0xfe, 0x00, 0xfe, 0x00, 0xfe, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18,
|
|
||||||
0x18, 0x00, 0x7e, 0x00, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x00, 0x7c, 0x00,
|
|
||||||
0x18, 0x30, 0x60, 0x30, 0x18, 0x00, 0x7c, 0x00, 0x0e, 0x1b, 0x1b, 0x18,
|
|
||||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0x70,
|
|
||||||
0x00, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00,
|
|
||||||
0x76, 0xdc, 0x00, 0x00, 0x38, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x18, 0x00, 0x00, 0x00, 0x0f, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x3c, 0x00,
|
|
||||||
0xd8, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x30, 0xc0, 0xf0,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
||||||
|
|
||||||
};
|
|
||||||
const int debugfont_size = sizeof(debugfont);
|
|
||||||
//---------------------------------------------------------------------------------
|
|
||||||
#endif //_font_h_
|
|
||||||
//---------------------------------------------------------------------------------
|
|
2114
include/renderd7/external/lodepng.h
vendored
2114
include/renderd7/external/lodepng.h
vendored
File diff suppressed because it is too large
Load Diff
33
include/renderd7/font.hpp
Normal file
33
include/renderd7/font.hpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <citro2d.h>
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <renderd7/Error.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
class Font {
|
||||||
|
public:
|
||||||
|
Font() = default;
|
||||||
|
Font(const std::string& path) { load(path); };
|
||||||
|
~Font() { unload(); }
|
||||||
|
void load(const std::string& path) {
|
||||||
|
std::ifstream ft(path, std::ios::in | std::ios::binary);
|
||||||
|
bool io = ft.is_open();
|
||||||
|
ft.close();
|
||||||
|
RenderD7::InlineAssert(io, "File not Found!");
|
||||||
|
fnt = C2D_FontLoad(path.c_str());
|
||||||
|
RenderD7::InlineAssert(fnt, "Font could not be loaded!");
|
||||||
|
}
|
||||||
|
C2D_Font ptr() { return fnt; }
|
||||||
|
void unload() {
|
||||||
|
if (!fnt) return;
|
||||||
|
C2D_FontFree(fnt);
|
||||||
|
fnt = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
C2D_Font fnt = nullptr;
|
||||||
|
};
|
||||||
|
} // namespace RenderD7
|
28
include/renderd7/global_db.hpp
Normal file
28
include/renderd7/global_db.hpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <renderd7/external/json.hpp>
|
||||||
|
#include <renderd7/renderd7.hpp>
|
||||||
|
|
||||||
|
// Outdated HidApi (HidV2Patched)
|
||||||
|
extern u32 d7_hDown;
|
||||||
|
extern u32 d7_hHeld;
|
||||||
|
extern u32 d7_hUp;
|
||||||
|
extern u32 d7_hRepeat; // Inofficial lol
|
||||||
|
extern touchPosition d7_touch;
|
||||||
|
|
||||||
|
// Outdated Screens
|
||||||
|
extern C3D_RenderTarget *Top;
|
||||||
|
extern C3D_RenderTarget *TopRight;
|
||||||
|
extern C3D_RenderTarget *Bottom;
|
||||||
|
|
||||||
|
// Modern Global Api
|
||||||
|
extern int rd7_max_objects;
|
||||||
|
extern bool rd7_do_splash;
|
||||||
|
extern bool rd7_enable_scene_system;
|
||||||
|
extern bool rd7_debugging;
|
||||||
|
extern C3D_RenderTarget *rd7_top;
|
||||||
|
extern C3D_RenderTarget *rd7_top_right;
|
||||||
|
extern C3D_RenderTarget *rd7_bottom;
|
||||||
|
|
||||||
|
// Draw2
|
||||||
|
extern float rd7_draw2_tsm;
|
@ -1,545 +0,0 @@
|
|||||||
#ifndef INI_INI_H_
|
|
||||||
#define INI_INI_H_
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cctype>
|
|
||||||
#include <fstream>
|
|
||||||
#include <memory>
|
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
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
|
|
||||||
}; // namespace INIStringUtil
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}; // namespace INIParser
|
|
||||||
|
|
||||||
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 §ion = 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 §ion = 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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace INI
|
|
||||||
|
|
||||||
#endif
|
|
57
include/renderd7/internal_db.hpp
Normal file
57
include/renderd7/internal_db.hpp
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <renderd7/external/json.hpp>
|
||||||
|
#include <renderd7/global_db.hpp>
|
||||||
|
#include <renderd7/renderd7.hpp>
|
||||||
|
|
||||||
|
#define CFGVER "0"
|
||||||
|
#define THEMEVER "0"
|
||||||
|
|
||||||
|
#ifndef V_RD7BTIME
|
||||||
|
#define V_RD7BTIME "SUBMODULE"
|
||||||
|
#endif
|
||||||
|
#ifndef V_RD7CSTRING
|
||||||
|
#define V_RD7CSTRING "SUBMODULE"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Base
|
||||||
|
extern std::string rd7i_app_name;
|
||||||
|
extern std::string rd7i_config_path;
|
||||||
|
extern nlohmann::json rd7i_config;
|
||||||
|
extern u8 rd7i_console_model;
|
||||||
|
extern u8 rd7i_system_region;
|
||||||
|
extern bool rd7i_is_citra;
|
||||||
|
extern bool rd7i_settings;
|
||||||
|
extern R7Vec2 rd7i_hid_touch_pos;
|
||||||
|
extern C2D_TextBuf rd7i_text_buffer;
|
||||||
|
extern C2D_TextBuf rd7i_d2_dimbuf;
|
||||||
|
extern C2D_Font rd7i_base_font;
|
||||||
|
extern bool rd7i_is_ndsp;
|
||||||
|
extern bool rd7i_running;
|
||||||
|
extern std::unique_ptr<RenderD7::Scene> rd7i_fade_scene;
|
||||||
|
extern std::vector<std::unique_ptr<RenderD7::Ovl>> rd7i_overlays;
|
||||||
|
extern unsigned int rd7i_frames;
|
||||||
|
extern u64 rd7i_last_time;
|
||||||
|
extern float rd7i_framerate;
|
||||||
|
extern u32 rd7i_mt_color;
|
||||||
|
extern u32 rd7i_mt_txtcolor;
|
||||||
|
extern bool rd7i_mt_screen;
|
||||||
|
extern float rd7i_mt_txtSize;
|
||||||
|
extern bool rd7i_metrikd;
|
||||||
|
extern bool rd7i_ftraced;
|
||||||
|
extern bool rd7i_current_screen;
|
||||||
|
extern u64 rd7i_delta_time;
|
||||||
|
extern u64 rd7i_last_tm;
|
||||||
|
extern float rd7i_dtm;
|
||||||
|
extern float rd7i_time;
|
||||||
|
extern bool rd7i_fadeout;
|
||||||
|
extern bool rd7i_fadein;
|
||||||
|
extern bool rd7i_fadeout2;
|
||||||
|
extern bool rd7i_fadein2;
|
||||||
|
extern int rd7i_fadealpha;
|
||||||
|
extern int rd7i_fadecolor;
|
||||||
|
extern bool rd7i_wait_fade;
|
||||||
|
extern bool rd7i_fade_exit;
|
||||||
|
extern bool rd7i_fade_scene_wait;
|
||||||
|
extern bool rd7i_idb_running;
|
||||||
|
extern bool rd7i_graphics_on;
|
||||||
|
extern bool rd7i_amdt;
|
@ -1,13 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <fstream>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
/// @brief Log Class
|
/// @brief Log Class
|
||||||
class Log {
|
class Log {
|
||||||
public:
|
public:
|
||||||
/// @brief Constructor
|
/// @brief Constructor
|
||||||
Log();
|
Log();
|
||||||
/// @brief Deconstructor
|
/// @brief Deconstructor
|
||||||
@ -27,7 +28,7 @@ public:
|
|||||||
/// @return Formatted String
|
/// @return Formatted String
|
||||||
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
|
/// \param filename the name of the logfile
|
||||||
std::string filename;
|
std::string filename;
|
||||||
};
|
};
|
||||||
|
30
include/renderd7/nimg.hpp
Normal file
30
include/renderd7/nimg.hpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#define NPI_NIMG_ (uint32_t)0x4e494d47 // Magic: NIMG
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
struct nimg {
|
||||||
|
unsigned int magic; // Magic number defaults do NPI_NIMG_
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int format;
|
||||||
|
int compression;
|
||||||
|
std::vector<unsigned char> pixel_buffer;
|
||||||
|
|
||||||
|
nimg(int w = 0, int h = 0, int fmt = 0, int cmp = 0) {
|
||||||
|
magic = NPI_NIMG_;
|
||||||
|
width = w;
|
||||||
|
height = h;
|
||||||
|
format = fmt;
|
||||||
|
compression = cmp;
|
||||||
|
pixel_buffer.resize((w * h) * (format ? 3 : 4));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
nimg NIMG_Load(std::string path);
|
||||||
|
nimg NIMG_LoadFromMem(unsigned char* buffer, size_t bf_size);
|
||||||
|
void NIMG_Save(nimg image, std::string path);
|
||||||
|
} // namespace RenderD7
|
24
include/renderd7/nimg_engine.hpp
Normal file
24
include/renderd7/nimg_engine.hpp
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <renderd7/nimg.hpp>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
class NIMG_Engine {
|
||||||
|
public:
|
||||||
|
NIMG_Engine(int w, int h);
|
||||||
|
NIMG_Engine();
|
||||||
|
~NIMG_Engine();
|
||||||
|
nimg& GetImage() { return image; }
|
||||||
|
void load_file(const std::string& path);
|
||||||
|
void load_nimg(const std::string& path);
|
||||||
|
|
||||||
|
// Rendering
|
||||||
|
void draw_pixel(int x, int y, unsigned int color);
|
||||||
|
void draw_rect(int x, int y, int w, int h, unsigned int color, int t = 1);
|
||||||
|
void draw_rect_solid(int x, int y, int w, int h, unsigned int color);
|
||||||
|
void flip(bool h, bool v);
|
||||||
|
|
||||||
|
private:
|
||||||
|
nimg image;
|
||||||
|
};
|
||||||
|
} // namespace RenderD7
|
@ -3,18 +3,21 @@
|
|||||||
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
class Parameter {
|
class Parameter {
|
||||||
private:
|
private:
|
||||||
using id = size_t;
|
using id = size_t;
|
||||||
|
|
||||||
template <typename T> struct type {
|
template <typename T>
|
||||||
|
struct type {
|
||||||
static void id() {}
|
static void id() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T> static id type_id() {
|
template <typename T>
|
||||||
|
static id type_id() {
|
||||||
return reinterpret_cast<id>(&type<T>::id);
|
return reinterpret_cast<id>(&type<T>::id);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> using decay = typename std::decay<T>::type;
|
template <typename T>
|
||||||
|
using decay = typename std::decay<T>::type;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using none =
|
using none =
|
||||||
@ -26,7 +29,8 @@ private:
|
|||||||
virtual base *copy() const = 0;
|
virtual base *copy() const = 0;
|
||||||
} *p = nullptr;
|
} *p = nullptr;
|
||||||
|
|
||||||
template <typename T> struct data : base, std::tuple<T> {
|
template <typename T>
|
||||||
|
struct data : base, std::tuple<T> {
|
||||||
using std::tuple<T>::tuple;
|
using std::tuple<T>::tuple;
|
||||||
|
|
||||||
T &get() & { return std::get<0>(*this); }
|
T &get() & { return std::get<0>(*this); }
|
||||||
@ -36,19 +40,27 @@ private:
|
|||||||
base *copy() const override { return new data{get()}; }
|
base *copy() const override { return new data{get()}; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T> T &stat() { return static_cast<data<T> &>(*p).get(); }
|
template <typename T>
|
||||||
|
T &stat() {
|
||||||
|
return static_cast<data<T> &>(*p).get();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T> T const &stat() const {
|
template <typename T>
|
||||||
|
T const &stat() const {
|
||||||
return static_cast<data<T> const &>(*p).get();
|
return static_cast<data<T> const &>(*p).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> T &dyn() { return dynamic_cast<data<T> &>(*p).get(); }
|
template <typename T>
|
||||||
|
T &dyn() {
|
||||||
|
return dynamic_cast<data<T> &>(*p).get();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T> T const &dyn() const {
|
template <typename T>
|
||||||
|
T const &dyn() const {
|
||||||
return dynamic_cast<data<T> const &>(*p).get();
|
return dynamic_cast<data<T> const &>(*p).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Default constructor
|
* @brief Default constructor
|
||||||
*/
|
*/
|
||||||
@ -102,7 +114,8 @@ public:
|
|||||||
* @tparam T The type to check
|
* @tparam T The type to check
|
||||||
* @return Whether the Parameter has the given type or not
|
* @return Whether the Parameter has the given type or not
|
||||||
*/
|
*/
|
||||||
template <typename T> bool is() const {
|
template <typename T>
|
||||||
|
bool is() const {
|
||||||
return p ? p->is(type_id<T>()) : false;
|
return p ? p->is(type_id<T>()) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,6 +126,9 @@ public:
|
|||||||
* @warning If the type of the Parameter doesn't match the type of it's stored
|
* @warning If the type of the Parameter doesn't match the type of it's stored
|
||||||
* value, it will result in undefined behaviour.
|
* value, it will result in undefined behaviour.
|
||||||
*/
|
*/
|
||||||
template <typename T> T &get() & { return stat<T>(); }
|
template <typename T>
|
||||||
|
T &get() & {
|
||||||
|
return stat<T>();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} // namespace RenderD7
|
} // namespace RenderD7
|
||||||
|
@ -24,12 +24,9 @@
|
|||||||
#include <citro2d.h>
|
#include <citro2d.h>
|
||||||
#include <citro3d.h>
|
#include <citro3d.h>
|
||||||
/// RenderD7 Includes
|
/// RenderD7 Includes
|
||||||
#include <renderd7/BitmapPrinter.hpp>
|
|
||||||
#include <renderd7/Color.hpp>
|
#include <renderd7/Color.hpp>
|
||||||
#include <renderd7/Draw.hpp>
|
|
||||||
#include <renderd7/FunctionTrace.hpp>
|
#include <renderd7/FunctionTrace.hpp>
|
||||||
#include <renderd7/Hardware.hpp>
|
#include <renderd7/Hardware.hpp>
|
||||||
#include <renderd7/Image.hpp>
|
|
||||||
#include <renderd7/Memory.hpp>
|
#include <renderd7/Memory.hpp>
|
||||||
#include <renderd7/Ovl.hpp>
|
#include <renderd7/Ovl.hpp>
|
||||||
#include <renderd7/ResultDecoder.hpp>
|
#include <renderd7/ResultDecoder.hpp>
|
||||||
@ -40,110 +37,38 @@
|
|||||||
#include <renderd7/SpriteAnimation.hpp>
|
#include <renderd7/SpriteAnimation.hpp>
|
||||||
#include <renderd7/Tasks.hpp>
|
#include <renderd7/Tasks.hpp>
|
||||||
#include <renderd7/Time.hpp>
|
#include <renderd7/Time.hpp>
|
||||||
#include <renderd7/bmp.hpp>
|
|
||||||
#include <renderd7/bmpconverter.hpp>
|
|
||||||
#include <renderd7/external/lodepng.h>
|
|
||||||
#include <renderd7/ini.hpp>
|
|
||||||
#include <renderd7/lang.hpp>
|
#include <renderd7/lang.hpp>
|
||||||
#include <renderd7/parameter.hpp>
|
#include <renderd7/parameter.hpp>
|
||||||
#include <renderd7/stringtool.hpp>
|
#include <renderd7/stringtool.hpp>
|
||||||
#include <renderd7/thread.hpp>
|
#include <renderd7/thread.hpp>
|
||||||
|
|
||||||
#define RENDERD7VSTRING "0.9.5"
|
#define RENDERD7VSTRING "0.9.5"
|
||||||
#define CHANGELOG \
|
|
||||||
"0.9.5: Remove Npi Intro and NVID Api\nReplace Toasts System with " \
|
|
||||||
"ToastsV2\n aka MessageHandler\nLots of Optimisations\n" \
|
|
||||||
"0.9.4: Implement new Security System\n To prevent from crashes\nImplement " \
|
|
||||||
"Functiontrace for better\nTiming Tests\nImplement MemAlloc Tracker (only " \
|
|
||||||
"size)\nAdd some new Overlays (not functional yet)\nComplete Rewrite of " \
|
|
||||||
"Overlay System\nFixed the FrameEnd Crash\nNew System to get Hardware " \
|
|
||||||
"Info\nRemoved RD7SR\n0.9.3: Completly Documented Everything\nFix typo " \
|
|
||||||
"in " \
|
|
||||||
"Sprite::getHeight()\nRemove Deprecated/Useless Stuff\n0.9.2: Add " \
|
|
||||||
"NpiSplashVideo\nNvid Support(v0.0.1)\nAdd " \
|
|
||||||
"Basic RenderD7 " \
|
|
||||||
"Splash\nFaster Graphics Init\nFade Effects\nFix Screen for this " \
|
|
||||||
"Changelog\n0.9.1: Fix Critical bug in\nSpritesheet animations\nFix " \
|
|
||||||
"Color " \
|
|
||||||
"Conver(Hex)\n0.9.0: Remove Stupid try of Console\nAdd Services list and " \
|
|
||||||
"Clean up " \
|
|
||||||
"Code.\nAlso added Minimal Init for hax2.x\n0.8.5: Fix Deltatime \n0.8.4: " \
|
|
||||||
"A lot of Fixes and new\nFeatures for BitmapPrinter! \n0.8.3: Addet " \
|
|
||||||
"Overlaycount to Info\nand Addet ResultDecoder for errors.\n0.8.2: Fix a " \
|
|
||||||
"lot of Stuff and\nadd c++17 based filesystem class.\n0.8.1: Add abillity " \
|
|
||||||
"to Get Stdout as string\nto render it to the screen.\n0.8.0: Implement " \
|
|
||||||
"BitmapPrinter\n0.7.3: Implement Over\nRender Overlay Framework\n0.7.2: " \
|
|
||||||
"Implement MT to csv file\nsaving.(removed) Add RGB2HEX.\n0.7.1: Add the " \
|
|
||||||
"New Overlay Handler. Its\nJust in code and does nothing yet.\n0.7.0: Made " \
|
|
||||||
"Big Progress In the MT\nOvl but it still crashes On\na Scnd " \
|
|
||||||
"C3D_FrameEnd()." \
|
|
||||||
"\nImplement 800px but\ndoesn't work that good. \n0.6.2: Fix Crash when " \
|
|
||||||
"exiting\ntrouth Home Menu.\n0.6.10: rewrite Threadsystem,\nImprove " \
|
|
||||||
"framerate\n0.6.02: Fix Code in lang.hpp\nadd Draw Text Left " \
|
|
||||||
"Function\n(Right since 0.7.0).\nadd changelog\n0.6.01: add Threading " \
|
|
||||||
"system.\n0.6.0: Better " \
|
|
||||||
"Scene Management\n0.5.0: Fixed some Bugs!\n0.4.0: Trying to fix " \
|
|
||||||
"Filesystem and Bugs!\n0.3.0: Recreate D7-Core into RenderD7!\n0.2.0: " \
|
|
||||||
"Trying to create Animations of\nImages instead of Sheets!\n0.1.0: Initial " \
|
|
||||||
"Release of\nD7-Core sprite animation plugin!"
|
|
||||||
|
|
||||||
#define DEFAULT_CENTER 0.5f
|
#define DEFAULT_CENTER 0.5f
|
||||||
|
|
||||||
#define RD7_DEPRECATED // __attribute__ ((deprecated))
|
|
||||||
|
|
||||||
/// @param d7_hDown Current Key Down
|
|
||||||
extern u32 d7_hDown;
|
|
||||||
/// @param d7_hHeld Current Key Held
|
|
||||||
extern u32 d7_hHeld;
|
|
||||||
/// @param d7_hUp Current Key Up
|
|
||||||
extern u32 d7_hUp;
|
|
||||||
/// @param d7_touch Current Touch Position
|
|
||||||
extern touchPosition d7_touch;
|
|
||||||
|
|
||||||
/// @param dspststus Dsp Status String
|
|
||||||
extern std::string dspststus;
|
|
||||||
|
|
||||||
/// @param rd7_do_splash Config Value To Enable RenderD7 Splash
|
/// @param rd7_do_splash Config Value To Enable RenderD7 Splash
|
||||||
extern bool rd7_do_splash;
|
extern bool rd7_do_splash;
|
||||||
/// @param rd7_enable_memtrack Config Value to Track Mem Allocations
|
/// @param rd7_enable_memtrack Config Value to Track Mem Allocations
|
||||||
extern bool rd7_enable_memtrack;
|
extern bool rd7_enable_memtrack;
|
||||||
|
/// @param rd7_max_objects Config Param for C2D Mac objects
|
||||||
|
extern int rd7_max_objects;
|
||||||
|
/// @param rd7_enable_scene_system Enable/Disable Scene System (for example for
|
||||||
|
/// your own implementations)
|
||||||
|
extern bool rd7_enable_scene_system;
|
||||||
|
|
||||||
/// RenderD7
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
/// @brief Get Deltatime
|
/// @brief Get Deltatime
|
||||||
/// @return Deltatime
|
/// @return Deltatime
|
||||||
float GetDeltaTime();
|
float GetDeltaTime();
|
||||||
/// @brief Keyboard
|
|
||||||
enum kbd {
|
|
||||||
/// @brief libctru Keyboard
|
|
||||||
SWKBD,
|
|
||||||
/// @brief Unk (Not Usable)
|
|
||||||
BKBD
|
|
||||||
};
|
|
||||||
/// @brief Keyboar Type
|
|
||||||
enum kbd_type { NUMPAD, STANDARD };
|
|
||||||
/// @brief A Button
|
|
||||||
struct TObject {
|
|
||||||
int x; ///< Position X
|
|
||||||
int y; ///< Position Y
|
|
||||||
int w; ///< Button Width
|
|
||||||
int h; ///< Button Height
|
|
||||||
std::string text = ""; ///< Text
|
|
||||||
float txtsize = 0.7f; ///< Set Text Size
|
|
||||||
};
|
|
||||||
/// @brief Scene Class
|
/// @brief Scene Class
|
||||||
class Scene {
|
class Scene {
|
||||||
public:
|
public:
|
||||||
/// @brief Stack of the Scenes
|
/// @brief Stack of the Scenes
|
||||||
static std::stack<std::unique_ptr<Scene>> scenes;
|
static std::stack<std::unique_ptr<Scene>> scenes;
|
||||||
/// @brief Deconstructor
|
/// @brief Deconstructor
|
||||||
virtual ~Scene() {}
|
virtual ~Scene() {}
|
||||||
/// @brief Logic To Overide
|
virtual void Logic() = 0;
|
||||||
/// @param hDown Key Down
|
|
||||||
/// @param hHeld Key Held
|
|
||||||
/// @param hUp Key Up
|
|
||||||
/// @param touch Touch Position
|
|
||||||
virtual void Logic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch) = 0;
|
|
||||||
/// @brief Draw Func to Override
|
/// @brief Draw Func to Override
|
||||||
virtual void Draw() const = 0;
|
virtual void Draw() const = 0;
|
||||||
/// @brief Push a Scene to Stack
|
/// @brief Push a Scene to Stack
|
||||||
@ -154,43 +79,31 @@ public:
|
|||||||
static void Back();
|
static void Back();
|
||||||
/// @brief do the Draw (Called in RenderD7::MainLoop())
|
/// @brief do the Draw (Called in RenderD7::MainLoop())
|
||||||
static void doDraw();
|
static void doDraw();
|
||||||
/// @brief do the Logic (Called in RenderD7::MainLoop())
|
static void doLogic();
|
||||||
/// @param hDown Key Down
|
|
||||||
/// @param hHeld Key Held
|
|
||||||
/// @param hUp Key Up
|
|
||||||
/// @param touch Touch Positon
|
|
||||||
static void doLogic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief Integrated Setting Menu of RenderD7
|
/// @brief Integrated Setting Menu of RenderD7
|
||||||
class RSettings : public RenderD7::Scene {
|
class RSettings : public RenderD7::Scene {
|
||||||
private:
|
private:
|
||||||
/// @brief Calculate the Changelog Screen Stuff
|
|
||||||
/// @param lines vector of Lines
|
|
||||||
/// @param screen_index Current Screen
|
|
||||||
/// @param screens Count of Possible Screens
|
|
||||||
void calculate_screens(const std::vector<std::string> &lines,
|
|
||||||
int &screen_index, int &screens);
|
|
||||||
/// @brief State (Define for Menus)
|
/// @brief State (Define for Menus)
|
||||||
enum RState {
|
enum RState {
|
||||||
RSETTINGS,
|
RSETTINGS,
|
||||||
RINFO,
|
RINFO,
|
||||||
RSERVICES,
|
RSERVICES,
|
||||||
RCLOG,
|
|
||||||
RMCONFIG,
|
RMCONFIG,
|
||||||
RFTRACE,
|
RFTRACE,
|
||||||
RSECM,
|
RUI7,
|
||||||
RCREDITS
|
RCREDITS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @param shared_request Defines requests from Draw to Logic
|
||||||
|
/// As it is not planned to make Draw non const you'll need
|
||||||
|
/// A map of data or bool values that are mutable ake
|
||||||
|
/// editable by const functions
|
||||||
|
mutable std::map<unsigned int, unsigned int> shared_request;
|
||||||
/// @param m_state Current menu State (Default=MainMenu aka RSETTINGS)
|
/// @param m_state Current menu State (Default=MainMenu aka RSETTINGS)
|
||||||
RenderD7::RSettings::RState m_state = RenderD7::RSettings::RState::RSETTINGS;
|
RenderD7::RSettings::RState m_state = RenderD7::RSettings::RState::RSETTINGS;
|
||||||
|
|
||||||
/// @param screens Count of Changelog Screens
|
|
||||||
int screens = 0;
|
|
||||||
/// @param screen_index Current Changelog Screen
|
|
||||||
int screen_index = 0;
|
|
||||||
/// @param lines Vector of Changelog-Lines
|
|
||||||
std::vector<std::string> lines;
|
|
||||||
/// @brief Position in FTrace Menu
|
/// @brief Position in FTrace Menu
|
||||||
int ftrace_index = 0;
|
int ftrace_index = 0;
|
||||||
|
|
||||||
@ -198,15 +111,11 @@ private:
|
|||||||
std::string mtovlstate = "false";
|
std::string mtovlstate = "false";
|
||||||
/// @param mtscreenstate Screen the Overlay is Set to
|
/// @param mtscreenstate Screen the Overlay is Set to
|
||||||
std::string mtscreenstate = "Top";
|
std::string mtscreenstate = "Top";
|
||||||
|
std::string kbd_test;
|
||||||
|
bool statemtold = false;
|
||||||
|
bool stateftold = false;
|
||||||
|
|
||||||
/// @param buttons Vector of Buttons
|
public:
|
||||||
std::vector<RenderD7::TObject> buttons = {
|
|
||||||
{20, 35, 120, 35, "NotYET"}, {20, 85, 120, 35, "Changelog"},
|
|
||||||
{20, 135, 120, 35, "Metrik-Ovl"}, {20, 185, 120, 35, "Tasks"},
|
|
||||||
{180, 35, 120, 35, "FTrace"}, {180, 85, 120, 35, "Credits"},
|
|
||||||
{180, 135, 120, 35, "Info"}, {180, 185, 120, 35, "Security"}};
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// @brief Constructor
|
/// @brief Constructor
|
||||||
RSettings();
|
RSettings();
|
||||||
/// @brief Override for Draw
|
/// @brief Override for Draw
|
||||||
@ -214,30 +123,23 @@ public:
|
|||||||
void Draw(void) const override;
|
void Draw(void) const override;
|
||||||
/// @brief Deconstructor
|
/// @brief Deconstructor
|
||||||
~RSettings();
|
~RSettings();
|
||||||
/// @brief Override for Logic
|
void Logic() override;
|
||||||
/// @param hDown Key Down
|
|
||||||
/// @param hHeld Key Held
|
|
||||||
/// @param hUp Key Up
|
|
||||||
/// @param touch Touch Position
|
|
||||||
void Logic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief Show Up the RenderD7-Settings Menu
|
/// @brief Show Up the RenderD7-Settings Menu
|
||||||
void LoadSettings();
|
void LoadSettings();
|
||||||
|
/// @brief Get's The Programs Time running
|
||||||
|
/// @return Time Running
|
||||||
|
float GetTime();
|
||||||
|
/// @brief Get Framerate as Number
|
||||||
|
/// @return FPS
|
||||||
|
int GetFps();
|
||||||
|
|
||||||
/// @brief Get A Rendom Int
|
/// @brief Get A Rendom Int
|
||||||
/// @param b From
|
/// @param b From
|
||||||
/// @param e To
|
/// @param e To
|
||||||
/// @return Random Int
|
/// @return Random Int
|
||||||
int GetRandomInt(int b, int e);
|
int GetRandomInt(int b, int e);
|
||||||
/// @brief Short a String with (..,)
|
|
||||||
/// @param in Input string
|
|
||||||
/// @param size Size of Input Text
|
|
||||||
/// @param maxlen Max length of texr
|
|
||||||
/// @param font Custom Font for Correct Size Calculation
|
|
||||||
/// @return Shorted String
|
|
||||||
std::string ShortString(std::string in, float size, int maxlen,
|
|
||||||
C2D_Font font = nullptr);
|
|
||||||
/// @brief DrawMetrikOvl (YOUR OWN RISK)
|
/// @brief DrawMetrikOvl (YOUR OWN RISK)
|
||||||
void DrawMetrikOvl();
|
void DrawMetrikOvl();
|
||||||
/// @brief Draw Image from RenderD7 Sheet
|
/// @brief Draw Image from RenderD7 Sheet
|
||||||
@ -259,18 +161,6 @@ void FadeOut();
|
|||||||
/// @brief Display Fade Effects
|
/// @brief Display Fade Effects
|
||||||
void FadeDisplay();
|
void FadeDisplay();
|
||||||
|
|
||||||
namespace Error {
|
|
||||||
/// @brief DEPRECATED Display Error for n Seconds
|
|
||||||
/// @param toptext Head Text
|
|
||||||
/// @param errortext Error Text
|
|
||||||
/// @param timesec Time n to Display in Seconds
|
|
||||||
void DisplayError(std::string toptext, std::string errortext, int timesec = 3);
|
|
||||||
/// @brief Display A Fatal Error
|
|
||||||
/// @param toptext Head Text
|
|
||||||
/// @param errortext Error Text
|
|
||||||
void DisplayFatalError(std::string toptext, std::string errortext);
|
|
||||||
} // namespace Error
|
|
||||||
|
|
||||||
namespace Init {
|
namespace Init {
|
||||||
/// @brief Init Default RenderD7
|
/// @brief Init Default RenderD7
|
||||||
/// @param app_name Name of Your App
|
/// @param app_name Name of Your App
|
||||||
@ -289,38 +179,6 @@ void Graphics();
|
|||||||
void NdspFirm();
|
void NdspFirm();
|
||||||
} // namespace Init
|
} // namespace Init
|
||||||
|
|
||||||
namespace Msg {
|
|
||||||
/// @brief Display A Message
|
|
||||||
/// @param titletxt Header Text
|
|
||||||
/// @param subtext Message Text
|
|
||||||
/// @param target Screen
|
|
||||||
void Display(std::string titletxt, std::string subtext,
|
|
||||||
C3D_RenderTarget *target);
|
|
||||||
/// @brief Display A Message Wit Progress
|
|
||||||
/// @param titletext Header Text
|
|
||||||
/// @param subtext Message Text
|
|
||||||
/// @param current Current Progress
|
|
||||||
/// @param total Total Progress
|
|
||||||
/// @param prgbarcolor Color of Progressbar
|
|
||||||
void DisplayWithProgress(std::string titletext, std::string subtext,
|
|
||||||
float current, float total, u32 prgbarcolor);
|
|
||||||
} // namespace Msg
|
|
||||||
|
|
||||||
namespace Convert {
|
|
||||||
/// @brief Convert a String to Flaot
|
|
||||||
/// @param inp Input String
|
|
||||||
/// @return Float
|
|
||||||
inline float StringtoFloat(std::string inp) { return std::atof(inp.c_str()); }
|
|
||||||
/// @brief Convert String to Int
|
|
||||||
/// @param inp Input String
|
|
||||||
/// @return Int
|
|
||||||
inline int StringtoInt(std::string inp) { return std::atoi(inp.c_str()); }
|
|
||||||
/// @brief Convert a Float to Bool
|
|
||||||
/// @param inp Input Float
|
|
||||||
/// @return Bool
|
|
||||||
inline bool FloatToBool(float inp) { return (inp == 1 ? true : false); }
|
|
||||||
} // namespace Convert
|
|
||||||
|
|
||||||
namespace FS {
|
namespace FS {
|
||||||
/// @brief Check if File exists
|
/// @brief Check if File exists
|
||||||
/// @param path Path to the File
|
/// @param path Path to the File
|
||||||
@ -344,59 +202,11 @@ void ExitApp();
|
|||||||
/// @param
|
/// @param
|
||||||
void ClearTextBufs(void);
|
void ClearTextBufs(void);
|
||||||
|
|
||||||
/// @brief Open A Keyboard (SWKBD)
|
|
||||||
/// @param lenght Length of the string
|
|
||||||
/// @param tp Type of The Keyboard
|
|
||||||
/// @return the string if pressed Ok
|
|
||||||
std::string Kbd(int lenght, SwkbdType tp);
|
|
||||||
|
|
||||||
/// @brief Draw Overlays And end the Frame. DO NEVER USE C3D_FRAMEEND cause it
|
/// @brief Draw Overlays And end the Frame. DO NEVER USE C3D_FRAMEEND cause it
|
||||||
/// breaks Overlay crash Security
|
/// breaks Overlay crash Security
|
||||||
void FrameEnd();
|
void FrameEnd();
|
||||||
|
|
||||||
/// @brief Textless Button
|
/// @brief Returns App Working Directory path
|
||||||
struct TLBtn {
|
/// @return AppDir Path
|
||||||
int x; ///< Position X
|
std::string GetAppDirectory();
|
||||||
int y; ///< Position Y
|
|
||||||
int w; ///< Button Width
|
|
||||||
int h; ///< Button Height
|
|
||||||
};
|
|
||||||
/// @brief Draw Buttons
|
|
||||||
/// @param tobjects Vector of Buttons
|
|
||||||
/// @param color Color of the Buttons
|
|
||||||
/// @param txtcolor Color of The Text
|
|
||||||
/// @param selection Positon of Selection
|
|
||||||
/// @param selbgcolor Selection BackgroundColor
|
|
||||||
/// @param selcolor Selection Color
|
|
||||||
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"));
|
|
||||||
/// @brief Draw A Single Button
|
|
||||||
/// @param tobject Button
|
|
||||||
/// @param tobjectindex Button Index
|
|
||||||
/// @param color Color of the Button
|
|
||||||
/// @param txtcolor Color of The Text
|
|
||||||
void DrawSTObject(std::vector<RenderD7::TObject> tobject, int tobjectindex,
|
|
||||||
u32 color, u32 txtcolor);
|
|
||||||
/// @brief Touched A Button
|
|
||||||
/// @param touch Touch Position
|
|
||||||
/// @param button Button
|
|
||||||
/// @return is touched or not
|
|
||||||
bool touchTObj(touchPosition touch, RenderD7::TObject button);
|
|
||||||
/// @brief Touched A Textless Button
|
|
||||||
/// @param touch Touch Position
|
|
||||||
/// @param button Button
|
|
||||||
/// @return is touched or not
|
|
||||||
bool touchTLBtn(touchPosition touch, RenderD7::TLBtn button);
|
|
||||||
/// @brief Draw Textless Buttons
|
|
||||||
/// @param tobjects Vector of Buttons
|
|
||||||
/// @param color Color of the Buttons
|
|
||||||
/// @param selection Positon of Selection
|
|
||||||
/// @param selbgcolor Selection BackgroundColor
|
|
||||||
/// @param selcolor Selection Color
|
|
||||||
void DrawTLBtns(std::vector<RenderD7::TLBtn> btns, u32 color,
|
|
||||||
int selection = -1,
|
|
||||||
u32 selbgcolor = RenderD7::Color::Hex("#2D98AF"),
|
|
||||||
u32 selcolor = RenderD7::Color::Hex("#000000"));
|
|
||||||
} // namespace RenderD7
|
} // namespace RenderD7
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
extern unsigned char renderd7_logo[];
|
extern unsigned char renderd7_logo[];
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
/** Sound Class */
|
/** Sound Class */
|
||||||
class sound {
|
class sound {
|
||||||
public:
|
public:
|
||||||
/// \brief Construct new Soundeffect
|
/// \brief Construct new Soundeffect
|
||||||
/// \param path Path to the .wav file
|
/// \param path Path to the .wav file
|
||||||
/// \param channel the channel 1-23
|
/// \param channel the channel 1-23
|
||||||
@ -18,7 +19,7 @@ public:
|
|||||||
/// @brief Stop the sound
|
/// @brief Stop the sound
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// \param dataSize Size of the filedata
|
/// \param dataSize Size of the filedata
|
||||||
u32 dataSize;
|
u32 dataSize;
|
||||||
/// \param waveBuf For ndsp
|
/// \param waveBuf For ndsp
|
||||||
|
@ -11,14 +11,11 @@ namespace RenderD7 {
|
|||||||
/// @return Ends with or not
|
/// @return Ends with or not
|
||||||
inline bool NameIsEndingWith(const std::string &name,
|
inline bool NameIsEndingWith(const std::string &name,
|
||||||
const std::vector<std::string> &extensions) {
|
const std::vector<std::string> &extensions) {
|
||||||
if (name.substr(0, 2) == "._")
|
if (name.substr(0, 2) == "._") return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
if (name.size() == 0)
|
if (name.size() == 0) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
if (extensions.size() == 0)
|
if (extensions.size() == 0) return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
for (int i = 0; i < (int)extensions.size(); i++) {
|
for (int i = 0; i < (int)extensions.size(); i++) {
|
||||||
const std::string ext = extensions.at(i);
|
const std::string ext = extensions.at(i);
|
||||||
@ -32,7 +29,7 @@ inline bool NameIsEndingWith(const std::string &name,
|
|||||||
/// Plugins)
|
/// Plugins)
|
||||||
/// @param t_time Time in ms
|
/// @param t_time Time in ms
|
||||||
/// @return String
|
/// @return String
|
||||||
inline std::string MsTimeFmt(float t_time) {
|
inline std::string MsTimeFmt(float t_time, bool dems = false) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
|
|
||||||
if (t_time < 0.001f) {
|
if (t_time < 0.001f) {
|
||||||
@ -46,6 +43,7 @@ inline std::string MsTimeFmt(float t_time) {
|
|||||||
if (seconds > 0) {
|
if (seconds > 0) {
|
||||||
oss << seconds << "s ";
|
oss << seconds << "s ";
|
||||||
}
|
}
|
||||||
|
if (!dems)
|
||||||
oss << std::fixed << std::setprecision(2) << milliseconds << "ms";
|
oss << std::fixed << std::setprecision(2) << milliseconds << "ms";
|
||||||
} else {
|
} else {
|
||||||
int minutes = static_cast<int>(t_time / 60000.0f);
|
int minutes = static_cast<int>(t_time / 60000.0f);
|
||||||
@ -56,24 +54,48 @@ inline std::string MsTimeFmt(float t_time) {
|
|||||||
if (seconds > 0 || milliseconds > 0.0f) {
|
if (seconds > 0 || milliseconds > 0.0f) {
|
||||||
oss << seconds << "s ";
|
oss << seconds << "s ";
|
||||||
}
|
}
|
||||||
if (milliseconds > 0.0f) {
|
if (milliseconds > 0.0f && !dems) {
|
||||||
oss << std::fixed << std::setprecision(2) << milliseconds << "ms";
|
oss << std::fixed << std::setprecision(2) << milliseconds << "ms";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::string FormatBytes(int bytes) {
|
||||||
|
char out[32];
|
||||||
|
|
||||||
|
if (bytes == 1)
|
||||||
|
snprintf(out, sizeof(out), "%d Byte", bytes);
|
||||||
|
|
||||||
|
else if (bytes < 1024)
|
||||||
|
snprintf(out, sizeof(out), "%d Bytes", bytes);
|
||||||
|
|
||||||
|
else if (bytes < 1024 * 1024)
|
||||||
|
snprintf(out, sizeof(out), "%.1f KB", (float)bytes / 1024);
|
||||||
|
|
||||||
|
else if (bytes < 1024 * 1024 * 1024)
|
||||||
|
snprintf(out, sizeof(out), "%.1f MB", (float)bytes / 1024 / 1024);
|
||||||
|
|
||||||
|
else
|
||||||
|
snprintf(out, sizeof(out), "%.1f GB", (float)bytes / 1024 / 1024 / 1024);
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
} // namespace RenderD7
|
} // namespace RenderD7
|
||||||
|
|
||||||
template <class T> T GetFileName(T const &path, T const &delims = "/\\") {
|
template <class T>
|
||||||
|
T GetFileName(T const &path, T const &delims = "/\\") {
|
||||||
return path.substr(path.find_last_of(delims) + 1);
|
return path.substr(path.find_last_of(delims) + 1);
|
||||||
}
|
}
|
||||||
template <class T> T remove_ext(T const &filename) {
|
template <class T>
|
||||||
|
T remove_ext(T const &filename) {
|
||||||
typename T::size_type const p(filename.find_last_of('.'));
|
typename T::size_type const p(filename.find_last_of('.'));
|
||||||
return p > 0 && p != T::npos ? filename.substr(0, p) : filename;
|
return p > 0 && p != T::npos ? filename.substr(0, p) : filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> std::string Int_To_Hex(T i) {
|
template <typename T>
|
||||||
|
std::string Int_To_Hex(T i) {
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
stream << "0x" << std::setfill('0') << std::setw(sizeof(T) * 2) << std::hex
|
stream << "0x" << std::setfill('0') << std::setw(sizeof(T) * 2) << std::hex
|
||||||
<< i;
|
<< i;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <renderd7/parameter.hpp>
|
#include <renderd7/parameter.hpp>
|
||||||
@ -11,7 +12,7 @@ using CTRU_Thread = Thread;
|
|||||||
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
class Thread {
|
class Thread {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Default constructor
|
* @brief Default constructor
|
||||||
* @note This should only be called when calling m3d::Thread::initialize()
|
* @note This should only be called when calling m3d::Thread::initialize()
|
||||||
@ -104,7 +105,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
static void sleep(int t_milliseconds);
|
static void sleep(int t_milliseconds);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ThreadData {
|
struct ThreadData {
|
||||||
RenderD7::Parameter m_parameter;
|
RenderD7::Parameter m_parameter;
|
||||||
std::function<void(RenderD7::Parameter)> m_function;
|
std::function<void(RenderD7::Parameter)> m_function;
|
||||||
|
BIN
logo.png
BIN
logo.png
Binary file not shown.
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 17 KiB |
44
mkdocs.yaml
Normal file
44
mkdocs.yaml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
site_name: RenderD7 Docs
|
||||||
|
site_description:
|
||||||
|
theme:
|
||||||
|
name: material
|
||||||
|
custom_dir: docs/overrides
|
||||||
|
features:
|
||||||
|
- navigation.indexes
|
||||||
|
palette:
|
||||||
|
# Palette toggle for light mode
|
||||||
|
- scheme: default
|
||||||
|
primary: red
|
||||||
|
accent: red
|
||||||
|
toggle:
|
||||||
|
icon: material/brightness-7
|
||||||
|
name: Switch to dark mode
|
||||||
|
|
||||||
|
# Palette toggle for dark mode
|
||||||
|
- scheme: slate
|
||||||
|
primary: red
|
||||||
|
accent: red
|
||||||
|
toggle:
|
||||||
|
icon: material/brightness-4
|
||||||
|
name: Switch to light mode
|
||||||
|
|
||||||
|
markdown_extensions:
|
||||||
|
- def_list
|
||||||
|
- attr_list
|
||||||
|
- admonition
|
||||||
|
- pymdownx.details
|
||||||
|
- pymdownx.superfences
|
||||||
|
- pymdownx.arithmatex:
|
||||||
|
generic: true
|
||||||
|
- pymdownx.emoji:
|
||||||
|
emoji_index: !!python/name:materialx.emoji.twemoji
|
||||||
|
emoji_generator: !!python/name:materialx.emoji.to_svg
|
||||||
|
plugins:
|
||||||
|
- search
|
||||||
|
extra_css:
|
||||||
|
- stylesheets/doxide.css
|
||||||
|
extra_javascript:
|
||||||
|
- javascripts/mathjax.js
|
||||||
|
- https://polyfill.io/v3/polyfill.min.js?features=es6
|
||||||
|
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
|
||||||
|
|
@ -52,7 +52,7 @@ else
|
|||||||
GIT_VER := $(shell git rev-parse --short HEAD)
|
GIT_VER := $(shell git rev-parse --short HEAD)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
TIME_TIME := $(shell date --iso=seconds)
|
TIME_TIME := unk
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# Version number
|
# Version number
|
||||||
@ -72,6 +72,10 @@ VERSION_MICRO := 0
|
|||||||
# Repository!
|
# Repository!
|
||||||
RENDERD7_SRC := ../source ../external
|
RENDERD7_SRC := ../source ../external
|
||||||
RENDERD7_INC := ../include
|
RENDERD7_INC := ../include
|
||||||
|
# Libraries used for RenderD7
|
||||||
|
# if you already use -lm, -lctru etc place a # before -lm
|
||||||
|
RENDERD7_LIBS := -lcurl -lm -lcitro2dd -lcitro3d -lctru
|
||||||
|
RENDERD7_FLAGS := -DRENDERD7_MEMTRACK=1
|
||||||
TARGET := rd7tf
|
TARGET := rd7tf
|
||||||
BUILD := build
|
BUILD := build
|
||||||
SOURCES := source $(RENDERD7_SRC)
|
SOURCES := source $(RENDERD7_SRC)
|
||||||
@ -93,8 +97,8 @@ ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
|||||||
CFLAGS := -g -Wall -Wno-psabi -O2 -mword-relocations \
|
CFLAGS := -g -Wall -Wno-psabi -O2 -mword-relocations \
|
||||||
-DV_STRING=\"$(GIT_VER)\" \
|
-DV_STRING=\"$(GIT_VER)\" \
|
||||||
-DV_TIME=\"$(TIME_TIME)\" \
|
-DV_TIME=\"$(TIME_TIME)\" \
|
||||||
-fomit-frame-pointer -ffunction-sections \
|
-ffunction-sections \
|
||||||
$(ARCH)
|
$(ARCH) $(RENDERD7_FLAGS)
|
||||||
|
|
||||||
CFLAGS += $(INCLUDE) -D__3DS__ -D_GNU_SOURCE=1
|
CFLAGS += $(INCLUDE) -D__3DS__ -D_GNU_SOURCE=1
|
||||||
|
|
||||||
@ -103,7 +107,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++20
|
|||||||
ASFLAGS := -g $(ARCH)
|
ASFLAGS := -g $(ARCH)
|
||||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||||
|
|
||||||
LIBS := -lcurl -lstdc++ -lm -lz -lcitro2d -lcitro3d -lctru -ljpeg
|
LIBS := -lstdc++ $(RENDERD7_LIBS)
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
8
rd7tf/README.md
Normal file
8
rd7tf/README.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# TAGLIB
|
||||||
|
```
|
||||||
|
git clone --recursive https://github.com/taglib/taglib.git
|
||||||
|
cd taglib
|
||||||
|
cmake -B 3dsbuild . --toolchain /opt/devkitpro/cmake/3DS:cmake
|
||||||
|
cmake --build 3dsbuild
|
||||||
|
|
||||||
|
```
|
@ -1,9 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
#Clean old build
|
|
||||||
echo "Cleaning..."
|
|
||||||
make clean
|
|
||||||
rm -rf libs/*
|
|
||||||
cd ..
|
|
||||||
make clean
|
|
||||||
echo "Done!"
|
|
BIN
rd7tf/romfs/icons/icon.png
Normal file
BIN
rd7tf/romfs/icons/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 844 B |
BIN
rd7tf/romfs/roboto_bold.bcfnt
Normal file
BIN
rd7tf/romfs/roboto_bold.bcfnt
Normal file
Binary file not shown.
@ -1,24 +1,55 @@
|
|||||||
#include <rd7.hpp>
|
#include "scene.hpp"
|
||||||
|
|
||||||
|
void ColorThemeSample() {
|
||||||
|
RenderD7::ColorNew(RD7Color_Text, RenderD7::Color::Hex("#000000", 255));
|
||||||
|
RenderD7::ColorNew(RD7Color_TextDisabled,
|
||||||
|
RenderD7::Color::Hex("#212121", 200));
|
||||||
|
RenderD7::ColorNew(RD7Color_Text2, RenderD7::Color::Hex("#ffffff", 255));
|
||||||
|
RenderD7::ColorNew(RD7Color_Background, RenderD7::Color::Hex("#eeeeee", 170));
|
||||||
|
RenderD7::ColorNew(RD7Color_Header, RenderD7::Color::Hex("#222222", 190));
|
||||||
|
RenderD7::ColorNew(RD7Color_Selector, RenderD7::Color::Hex("#4444dd", 200));
|
||||||
|
RenderD7::ColorNew(RD7Color_SelectorFade,
|
||||||
|
RenderD7::Color::Hex("#7777dd", 200));
|
||||||
|
RenderD7::ColorNew(RD7Color_List0, RenderD7::Color::Hex("#555555", 130));
|
||||||
|
RenderD7::ColorNew(RD7Color_List1, RenderD7::Color::Hex("#777777", 130));
|
||||||
|
RenderD7::ColorNew(RD7Color_MessageBackground,
|
||||||
|
RenderD7::Color::Hex("#222222", 180));
|
||||||
|
RenderD7::ColorNew(RD7Color_Button, RenderD7::Color::Hex("#4444dd", 150));
|
||||||
|
RenderD7::ColorNew(RD7Color_ButtonHovered,
|
||||||
|
RenderD7::Color::Hex("#6666dd", 150));
|
||||||
|
RenderD7::ColorNew(RD7Color_ButtonDisabled,
|
||||||
|
RenderD7::Color::Hex("#2222dd", 150));
|
||||||
|
RenderD7::ColorNew(RD7Color_ButtonActive,
|
||||||
|
RenderD7::Color::Hex("#7777dd", 150));
|
||||||
|
RenderD7::ColorNew(RD7Color_Checkmark, RenderD7::Color::Hex("#4444dd", 130));
|
||||||
|
RenderD7::ColorNew(RD7Color_FrameBg, RenderD7::Color::Hex("#555555", 160));
|
||||||
|
RenderD7::ColorNew(RD7Color_FrameBgHovered,
|
||||||
|
RenderD7::Color::Hex("#777777", 160));
|
||||||
|
RenderD7::ColorNew(RD7Color_Progressbar,
|
||||||
|
RenderD7::Color::Hex("#4444dd", 200));
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void IdbServer();
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
rd7_enable_memtrack = true;
|
||||||
rd7_do_splash = true;
|
rd7_do_splash = true;
|
||||||
RenderD7::Ftrace::Beg("app", "app_init");
|
RenderD7::Ftrace::Beg("app", "app_init");
|
||||||
RenderD7::Init::Main("rd7tf");
|
RenderD7::Init::Main("rd7tf");
|
||||||
|
RenderD7::FadeIn();
|
||||||
|
// IdbServer();
|
||||||
|
ColorThemeSample();
|
||||||
RenderD7::Init::NdspFirm();
|
RenderD7::Init::NdspFirm();
|
||||||
RenderD7::Ftrace::Beg("app", f2s(RenderD7::LoadSettings));
|
RenderD7::Scene::Load(std::make_unique<Sample>());
|
||||||
RenderD7::LoadSettings();
|
|
||||||
RenderD7::Ftrace::End("app", f2s(RenderD7::LoadSettings));
|
|
||||||
sound snd("romfs:/thesound.wav", 0);
|
|
||||||
snd.play();
|
|
||||||
RenderD7::PushMessage(RenderD7::Message(std::string("RenderD7 ") + RENDERD7VSTRING, "Testing the ToastsV2"));
|
|
||||||
RenderD7::Ftrace::End("app", "app_init");
|
RenderD7::Ftrace::End("app", "app_init");
|
||||||
while (RenderD7::MainLoop()) {
|
while (RenderD7::MainLoop()) {
|
||||||
|
RenderD7::OnScreen(Top);
|
||||||
RenderD7::Ftrace::Beg("app", "app_mainloop");
|
RenderD7::Ftrace::Beg("app", "app_mainloop");
|
||||||
if (d7_hDown & KEY_START)
|
if (d7_hDown & KEY_START) {
|
||||||
|
RenderD7::FadeOut();
|
||||||
RenderD7::ExitApp();
|
RenderD7::ExitApp();
|
||||||
if(d7_hDown & KEY_A) {
|
|
||||||
RenderD7::PushMessage(RenderD7::Message(std::string("RenderD7 ") + RENDERD7VSTRING, "Testing the ToastsV2\nPressed A"));
|
|
||||||
}
|
}
|
||||||
|
RenderD7::OnScreen(Top);
|
||||||
RenderD7::FrameEnd();
|
RenderD7::FrameEnd();
|
||||||
RenderD7::Ftrace::End("app", "app_mainloop");
|
RenderD7::Ftrace::End("app", "app_mainloop");
|
||||||
}
|
}
|
||||||
|
131
rd7tf/source/scene.cpp
Normal file
131
rd7tf/source/scene.cpp
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
#include "scene.hpp"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
static float MakeOffset(float x) {
|
||||||
|
float y = cos(x) * 42;
|
||||||
|
return y - floor(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Wave(int index, R7Vec2 position, R7Vec2 size, float time,
|
||||||
|
bool dbg) {
|
||||||
|
float offset = MakeOffset(index) * 62;
|
||||||
|
float x_position =
|
||||||
|
position.x + size.x / 8 * ((index % 11) - 1) + cos(offset + time) * 10;
|
||||||
|
float y_position = position.y + size.y / 8 * (index / 11) + 40 +
|
||||||
|
sin(offset + time) * 10 + 30;
|
||||||
|
float color_effect = 1 - exp(-(index / 11) / 3.0f);
|
||||||
|
|
||||||
|
// As this is 3ds dont go out of the box
|
||||||
|
int shrink = 0;
|
||||||
|
if (y_position >= position.y + size.y - 90) {
|
||||||
|
shrink = y_position - (position.y + size.y - 90);
|
||||||
|
}
|
||||||
|
// Just to make sure...
|
||||||
|
y_position = std::min(y_position, position.y + size.y - (90 - shrink));
|
||||||
|
|
||||||
|
if (dbg)
|
||||||
|
RenderD7::Draw2::TriangleLined(
|
||||||
|
R7Vec2(x_position, y_position),
|
||||||
|
R7Vec2(x_position + 300, y_position + (90 - shrink)),
|
||||||
|
R7Vec2(x_position - 300, y_position + (90 - shrink)),
|
||||||
|
RenderD7::Color::RGBA(.94f - .17f * color_effect,
|
||||||
|
.61f - .25f * color_effect,
|
||||||
|
.36f + .38f * color_effect)
|
||||||
|
.toRGBA());
|
||||||
|
else
|
||||||
|
RenderD7::Draw2::TriangleSolid(
|
||||||
|
R7Vec2(x_position, y_position),
|
||||||
|
R7Vec2(x_position + 300, y_position + (90 - shrink)),
|
||||||
|
R7Vec2(x_position - 300, y_position + (90 - shrink)),
|
||||||
|
RenderD7::Color::RGBA(.94f - .17f * color_effect,
|
||||||
|
.61f - .25f * color_effect,
|
||||||
|
.36f + .38f * color_effect)
|
||||||
|
.toRGBA());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawWave(R7Vec2 position, R7Vec2 size, float time, bool dbg) {
|
||||||
|
RenderD7::Draw2::RectFilledSolid(position, size, 0xff64c9fd);
|
||||||
|
int i = 0;
|
||||||
|
for (; i < 44; i++) Wave(i, position, size, time, dbg);
|
||||||
|
}
|
||||||
|
|
||||||
|
R7Vec2 testv2 = R7Vec2(48, 48);
|
||||||
|
|
||||||
|
Sample::Sample() {
|
||||||
|
auto t = RenderD7::FileSystem::GetDirContent("sdmc:/music/");
|
||||||
|
for (const auto& it : t) {
|
||||||
|
names.push_back(it.name);
|
||||||
|
files.push_back(it.path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Sample::~Sample() {
|
||||||
|
// Here you can clear your data
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sample::Draw() const {
|
||||||
|
// Draw Things to Screen:
|
||||||
|
// Step 1 -> Select Screen
|
||||||
|
RenderD7::OnScreen(Top);
|
||||||
|
// Step 2 -> Draw Things
|
||||||
|
// The hbloader Triangle Wave
|
||||||
|
DrawWave(R7Vec2(0, 0), R7Vec2(400, 240), RenderD7::GetTime(),
|
||||||
|
debug_background);
|
||||||
|
// For Example A Rect with Draw2 and StyleColorApi
|
||||||
|
// And the RFS Wrapper for RectFilledSolid lol
|
||||||
|
/*RenderD7::Draw2::RFS(R7Vec2(0, 0), R7Vec2(400, 20),
|
||||||
|
RenderD7::StyleColor(RD7Color_Header));
|
||||||
|
// As the Top bar is Dark you need TextColor2
|
||||||
|
RenderD7::RedirectColor(RD7Color_Text, RD7Color_Text2);
|
||||||
|
RenderD7::Draw2::Text(R7Vec2(5, 2), "RenderD7 - Test Framework");
|
||||||
|
RenderD7::Draw2::Text(R7Vec2(395, 2), RENDERD7VSTRING,
|
||||||
|
RD7TextFlags_AlignRight);
|
||||||
|
RenderD7::UndoColorEdit(RD7Color_Text);*/
|
||||||
|
if (UI7::BeginMenu("RenderD7 Test Framework")) {
|
||||||
|
UI7::SetCursorPos(R7Vec2(395, 2));
|
||||||
|
UI7::Label(RenderD7::FormatBytes(RenderD7::Memory::GetCurrent()),
|
||||||
|
RD7TextFlags_AlignRight);
|
||||||
|
UI7::RestoreCursor();
|
||||||
|
if (state == State_Menu) {
|
||||||
|
UI7::Label("Test App");
|
||||||
|
}
|
||||||
|
UI7::EndMenu();
|
||||||
|
}
|
||||||
|
RenderD7::OnScreen(Bottom);
|
||||||
|
if (UI7::BeginMenu("Control Center")) {
|
||||||
|
if (state == State_Menu) {
|
||||||
|
if (UI7::Button("RenderD7 Settings"))
|
||||||
|
shared_requests[1U] = 1U; // Request a Toggle
|
||||||
|
UI7::SameLine();
|
||||||
|
if (UI7::Button("Test Message"))
|
||||||
|
shared_requests[2U] = 1U; // Request Test Msg
|
||||||
|
UI7::Checkbox("Debug BG", debug_background);
|
||||||
|
UI7::SameLine();
|
||||||
|
UI7::Checkbox("RD7-Debug", rd7_debugging);
|
||||||
|
UI7::InputText("Search", search__, "Tap Here");
|
||||||
|
}
|
||||||
|
UI7::EndMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sample::Logic() {
|
||||||
|
for (const auto& it : shared_requests) {
|
||||||
|
if (it.first == 1U) {
|
||||||
|
if (it.second) RenderD7::LoadSettings();
|
||||||
|
} else if (it.first == 2U) {
|
||||||
|
if (it.second)
|
||||||
|
RenderD7::PushMessage(RenderD7::Message(
|
||||||
|
"Test Message", "Button Bressed\nBest Msg Handler..."));
|
||||||
|
} else if (it.first == 3U) {
|
||||||
|
state = (State)it.second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d7_hDown & KEY_UP && sel > 0) sel--;
|
||||||
|
if (d7_hDown & KEY_DOWN && sel < ((int)files.size() - 1)) sel++;
|
||||||
|
|
||||||
|
// Make sure to clear after processing!!!;
|
||||||
|
shared_requests.clear();
|
||||||
|
if (d7_hDown & KEY_B) debug_background = !debug_background;
|
||||||
|
}
|
32
rd7tf/source/scene.hpp
Normal file
32
rd7tf/source/scene.hpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <rd7.hpp>
|
||||||
|
|
||||||
|
class Sample : public RenderD7::Scene {
|
||||||
|
public:
|
||||||
|
enum State {
|
||||||
|
State_Menu,
|
||||||
|
};
|
||||||
|
Sample();
|
||||||
|
~Sample();
|
||||||
|
|
||||||
|
void Draw() const override;
|
||||||
|
void Logic() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Just as the RD7 Settings Shows here as example
|
||||||
|
// by using a mutale map you're able to process
|
||||||
|
// requests from the const Draw function in the
|
||||||
|
// Logic Function! you could also create lots of
|
||||||
|
// mutable bool or make all Variables mutable but
|
||||||
|
// i think seperating draw and logic is better
|
||||||
|
// editable map request_id data/operation
|
||||||
|
mutable std::map<unsigned int, unsigned int> shared_requests;
|
||||||
|
// For Checkbox its best to use mutable
|
||||||
|
mutable bool debug_background = false;
|
||||||
|
mutable std::string search__ = "";
|
||||||
|
mutable std::vector<std::string> names;
|
||||||
|
mutable std::vector<std::string> files;
|
||||||
|
mutable int sel;
|
||||||
|
State state = State_Menu;
|
||||||
|
};
|
@ -1,22 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
#Clean old build
|
|
||||||
echo "Cleaning..."
|
|
||||||
rm -rf libs/*
|
|
||||||
#Format to LLVM
|
|
||||||
echo "Format to LLVM"
|
|
||||||
cd ..
|
|
||||||
./cformat.sh
|
|
||||||
#Compile RenderD7
|
|
||||||
echo "Compiling RenderD7"
|
|
||||||
make
|
|
||||||
#Copy new build
|
|
||||||
echo "Copy New Build"
|
|
||||||
cp -r include rd7tf/libs/
|
|
||||||
cp -r lib rd7tf/libs/
|
|
||||||
#Build Test Framework
|
|
||||||
echo "Building Test Framework"
|
|
||||||
cd rd7tf
|
|
||||||
make
|
|
||||||
|
|
||||||
echo "Done!"
|
|
@ -1,475 +0,0 @@
|
|||||||
#include <renderd7/BitmapPrinter.hpp>
|
|
||||||
#include <renderd7/ToastsV2.hpp>
|
|
||||||
#include <renderd7/stringtool.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
extern bool shouldbe_disabled;
|
|
||||||
extern std::string csvpc;
|
|
||||||
|
|
||||||
RenderD7::BitmapPrinter::BitmapPrinter(int w, int h) {
|
|
||||||
BMP newmap(w, h, true);
|
|
||||||
bitmap = newmap;
|
|
||||||
// renderframe.LoadPFromBuffer(BitmapConverter::ConvertData(bitmap.DATA()));
|
|
||||||
blank = newmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
RenderD7::BitmapPrinter::~BitmapPrinter() {
|
|
||||||
if (this->renderframe.loadet)
|
|
||||||
this->renderframe.Unload();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RenderD7::BitmapPrinter::DecodeFile(std::string file) {
|
|
||||||
unsigned error = bitmap.read(file.c_str());
|
|
||||||
|
|
||||||
if (error) {
|
|
||||||
RenderD7::PushMessage(RenderD7::Message(
|
|
||||||
"BitmapPrinter", "Error Code: " + std::to_string(error)));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::BitmapPrinter::DrawPixel(int x, int y, u8 b, u8 g, u8 r, u8 a) {
|
|
||||||
unsigned error =
|
|
||||||
bitmap.set_pixel(x, bitmap.bmp_info_header.height - y, b, g, r, a);
|
|
||||||
if (error) {
|
|
||||||
RenderD7::PushMessage(RenderD7::Message(
|
|
||||||
"BitmapPrinter->Pixel", "Error Code: " + std::to_string(error)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void RenderD7::BitmapPrinter::DrawRect(int x, int y, int w, int h, u8 line_w,
|
|
||||||
u8 b, u8 g, u8 r, u8 a) {
|
|
||||||
unsigned error = bitmap.draw_rectangle(
|
|
||||||
x, bitmap.bmp_info_header.height - y - h, w, h, b, g, r, a, line_w);
|
|
||||||
if (error) {
|
|
||||||
RenderD7::PushMessage(RenderD7::Message(
|
|
||||||
"BitmapPrinter->Rect", "Error Code: " + std::to_string(error)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::BitmapPrinter::DrawRectFilled(int x, int y, int w, int h, u8 b,
|
|
||||||
u8 g, u8 r, u8 a) {
|
|
||||||
unsigned error = bitmap.fill_region(x, bitmap.bmp_info_header.height - h - y,
|
|
||||||
w, h, b, g, r, a);
|
|
||||||
if (error) {
|
|
||||||
RenderD7::PushMessage(RenderD7::Message(
|
|
||||||
"BitmapPrinter->RectF", "Error Code: " + std::to_string(error)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::BitmapPrinter::SaveBmp(std::string name) {
|
|
||||||
if (!RenderD7::NameIsEndingWith(name, {"bmp"})) {
|
|
||||||
name += ".bmp";
|
|
||||||
}
|
|
||||||
bitmap.write(name.c_str());
|
|
||||||
}
|
|
||||||
void RenderD7::BitmapPrinter::SavePng(std::string name) {
|
|
||||||
if (!RenderD7::NameIsEndingWith(name, {"png"})) {
|
|
||||||
name += ".png";
|
|
||||||
}
|
|
||||||
std::vector<unsigned char> ImageBuffer;
|
|
||||||
ImageBuffer = BitmapConverter::ConvertData(bitmap.DATA());
|
|
||||||
lodepng::save_file(ImageBuffer, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::BitmapPrinter::CreateScreen(C3D_RenderTarget *target) {
|
|
||||||
isscreen = true;
|
|
||||||
targetr = target;
|
|
||||||
if (target == Top) {
|
|
||||||
bitmap = BMP(400, 240, true);
|
|
||||||
blank = BMP(400, 240, true);
|
|
||||||
}
|
|
||||||
if (target == TopRight) {
|
|
||||||
bitmap = BMP(400, 240, true);
|
|
||||||
blank = BMP(400, 240, true);
|
|
||||||
}
|
|
||||||
if (target == Bottom) {
|
|
||||||
bitmap = BMP(320, 240, true);
|
|
||||||
blank = BMP(320, 240, true);
|
|
||||||
}
|
|
||||||
renderframe.LoadPFromBuffer(BitmapConverter::ConvertData(bitmap.DATA()));
|
|
||||||
}
|
|
||||||
bool RenderD7::BitmapPrinter::DrawScreenDirectF(int framerate) {
|
|
||||||
bool updtt = false;
|
|
||||||
if (isscreen) {
|
|
||||||
if (frame == (60 / framerate)) {
|
|
||||||
RenderD7::OnScreen(targetr);
|
|
||||||
if (renderframe.loadet)
|
|
||||||
renderframe.Unload();
|
|
||||||
this->Decode(decc);
|
|
||||||
frame = 0;
|
|
||||||
updtt = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (renderframe.loadet)
|
|
||||||
renderframe.Draw(0, 0);
|
|
||||||
frame++;
|
|
||||||
}
|
|
||||||
return updtt;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RenderD7::BitmapPrinter::DrawScreenDirect() {
|
|
||||||
bool updtt = false;
|
|
||||||
if (isscreen) {
|
|
||||||
RenderD7::OnScreen(targetr);
|
|
||||||
if (renderframe.loadet)
|
|
||||||
renderframe.Unload();
|
|
||||||
this->Decode(decc);
|
|
||||||
updtt = true;
|
|
||||||
if (renderframe.loadet)
|
|
||||||
renderframe.Draw(0, 0);
|
|
||||||
}
|
|
||||||
return updtt;
|
|
||||||
}
|
|
||||||
|
|
||||||
RenderD7::Image RenderD7::BitmapPrinter::GetImage() {
|
|
||||||
RenderD7::Image img;
|
|
||||||
img.LoadFromBitmap(bitmap);
|
|
||||||
return img;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::BitmapPrinter::UsePreMap(BMP map) { bitmap = map; }
|
|
||||||
void RenderD7::BitmapPrinter::UsePrePrintMap(BitmapPrinter printmap) {
|
|
||||||
bitmap = printmap.GetBitmap();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::BitmapPrinter::Clear(u8 b, u8 g, u8 r, u8 a) {
|
|
||||||
bitmap.fill_region(0, 0, bitmap.bmp_info_header.width,
|
|
||||||
bitmap.bmp_info_header.height, b, g, r, a);
|
|
||||||
}
|
|
||||||
void RenderD7::BitmapPrinter::ClearBlank() { bitmap = blank; }
|
|
||||||
|
|
||||||
void RenderD7::BitmapPrinter::DrawScreenF(int framerate) {
|
|
||||||
if (isscreen) {
|
|
||||||
if (frame == (60 / framerate)) {
|
|
||||||
RenderD7::OnScreen(targetr);
|
|
||||||
frame = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (renderframe.loadet)
|
|
||||||
renderframe.Draw(0, 0);
|
|
||||||
frame++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void RenderD7::BitmapPrinter::DrawScreen() {
|
|
||||||
if (isscreen) {
|
|
||||||
RenderD7::OnScreen(targetr);
|
|
||||||
if (renderframe.loadet)
|
|
||||||
renderframe.Draw(0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool RenderD7::BitmapPrinter::UpdateScreenF(int framerate) {
|
|
||||||
bool updtt = false;
|
|
||||||
if (isscreen) {
|
|
||||||
if (frame == (60 / framerate)) {
|
|
||||||
if (renderframe.loadet)
|
|
||||||
renderframe.Unload();
|
|
||||||
// renderframe.LoadFromBitmap(bitmap);
|
|
||||||
this->Decode(decc);
|
|
||||||
frame = 0;
|
|
||||||
updtt = true;
|
|
||||||
}
|
|
||||||
frame++;
|
|
||||||
}
|
|
||||||
return updtt;
|
|
||||||
}
|
|
||||||
bool RenderD7::BitmapPrinter::UpdateScreen() {
|
|
||||||
bool updtt = false;
|
|
||||||
if (isscreen) {
|
|
||||||
if (renderframe.loadet)
|
|
||||||
renderframe.Unload();
|
|
||||||
this->Decode(decc);
|
|
||||||
updtt = true;
|
|
||||||
}
|
|
||||||
return updtt;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define TICKS_PER_MSEC 268111.856
|
|
||||||
|
|
||||||
void RenderD7::BitmapPrinter::Benchmark() {
|
|
||||||
if (setupbenchmark) {
|
|
||||||
frametime = 0;
|
|
||||||
renderedframes = 0;
|
|
||||||
timer = 0;
|
|
||||||
setupbenchmark = false;
|
|
||||||
lastTime = svcGetSystemTick();
|
|
||||||
}
|
|
||||||
if (benchmark) {
|
|
||||||
if (timer >= 60) {
|
|
||||||
std::string renderedf = std::to_string(renderedframes);
|
|
||||||
std::string avgdtt = std::to_string(mhdtt);
|
|
||||||
float alldtt = 0;
|
|
||||||
for (size_t i = 1; i < hdttt.size(); i++) {
|
|
||||||
alldtt += hdttt[i];
|
|
||||||
}
|
|
||||||
float alldtt2 = 0;
|
|
||||||
for (size_t i = 0; i < hdttt2.size(); i++) {
|
|
||||||
alldtt2 += hdttt2[i];
|
|
||||||
}
|
|
||||||
float alldtt3 = 0;
|
|
||||||
for (size_t i = 0; i < hdttt3.size(); i++) {
|
|
||||||
alldtt3 += hdttt3[i];
|
|
||||||
}
|
|
||||||
int allfps = 0;
|
|
||||||
for (size_t f = 1; f < fpscountc.size(); f++) {
|
|
||||||
allfps += fpscountc[f];
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string avgcpu = std::to_string((alldtt / (float)hdttt.size() - 1));
|
|
||||||
std::string avgcpu2 =
|
|
||||||
std::to_string(((alldtt2 / (float)hdttt2.size()) * 1000));
|
|
||||||
std::string avgcpu3 =
|
|
||||||
std::to_string(((alldtt3 / (float)hdttt3.size()) * 1000));
|
|
||||||
std::string avgfps = std::to_string((allfps / (int)fpscountc.size() - 1));
|
|
||||||
|
|
||||||
std::string resultt =
|
|
||||||
"TestMode: " + std::to_string(testfpsd) + "fps" +
|
|
||||||
"\nRendered Frames: " + renderedf + "\nMax Cpu Time: " + avgdtt +
|
|
||||||
"\nAvg Cpu Time: " + avgcpu + "\nAvg Fps: " + avgfps +
|
|
||||||
"\nAvg EncodeTime: " + avgcpu2 + "ms/f\nAvg DecodeTime: " + avgcpu3 +
|
|
||||||
"ms\n";
|
|
||||||
this->ClearBlank();
|
|
||||||
this->DrawRectFilled(0, 0, this->bitmap.bmp_info_header.width,
|
|
||||||
this->bitmap.bmp_info_header.height, 0, 0, 0, 255);
|
|
||||||
this->DrawDebugText(0, 0, 0, RenderD7::Color::Hex("#ffffff"), resultt);
|
|
||||||
std::string outname =
|
|
||||||
csvpc + "/benchmark_" + RenderD7::GetTimeStr() + ".png";
|
|
||||||
this->SavePng(outname);
|
|
||||||
RenderD7::PushMessage(
|
|
||||||
RenderD7::Message("Benchmark", "Saved to: \n" + outname));
|
|
||||||
benchmark = false;
|
|
||||||
}
|
|
||||||
uint64_t currentTime = svcGetSystemTick();
|
|
||||||
dtt = ((float)(currentTime / (float)TICKS_PER_MSEC) -
|
|
||||||
(float)(lastTime / (float)TICKS_PER_MSEC)) /
|
|
||||||
1000.f;
|
|
||||||
lastTime = currentTime;
|
|
||||||
lastTime = currentTime;
|
|
||||||
frameCounter++;
|
|
||||||
fpsClock += dtt;
|
|
||||||
if (fpsClock >= 1.f) {
|
|
||||||
fps = frameCounter;
|
|
||||||
frameCounter = 0;
|
|
||||||
fpsClock = 0.f;
|
|
||||||
}
|
|
||||||
uint64_t lastTime2 = svcGetSystemTick();
|
|
||||||
this->ClearBlank();
|
|
||||||
this->DrawRectFilled(0, 0, this->bitmap.bmp_info_header.width,
|
|
||||||
this->bitmap.bmp_info_header.width, 255, 255, 255,
|
|
||||||
255);
|
|
||||||
this->DrawRect(5, 5, this->bitmap.bmp_info_header.width - 10,
|
|
||||||
this->bitmap.bmp_info_header.height - 10, 5, 0, 0, 0, 0);
|
|
||||||
// this->DrawDebugText(20, 20, 0, RenderD7::Color::Hex("#ffffff"), "Fps: " +
|
|
||||||
// std::to_string(fps));
|
|
||||||
this->DrawDebugText(0, 0, 0.5f, RenderD7::Color::Hex("#ff0000"),
|
|
||||||
"Time: " + std::to_string(timer));
|
|
||||||
this->DrawDebugText(0, 10, 0.5f, RenderD7::Color::Hex("#ff0000"),
|
|
||||||
"Fps: " + std::to_string(fps));
|
|
||||||
this->DrawDebugText(0, 20, 0.5f, RenderD7::Color::Hex("#ff0000"),
|
|
||||||
"dt: " + std::to_string(dtt));
|
|
||||||
this->DrawDebugText(0, 30, 0.5f, RenderD7::Color::Hex("#ff0000"),
|
|
||||||
"MaxEncodeTime: " + std::to_string(mdtt2 * 1000) +
|
|
||||||
"ms/f");
|
|
||||||
this->DrawDebugText(0, 40, 0.5f, RenderD7::Color::Hex("#ff0000"),
|
|
||||||
"MaxDecodeTime: " + std::to_string(mdtt3 * 1000) +
|
|
||||||
"ms");
|
|
||||||
uint64_t currentTime2 = svcGetSystemTick();
|
|
||||||
dtt2 = ((float)(currentTime2 / (float)TICKS_PER_MSEC) -
|
|
||||||
(float)(lastTime2 / (float)TICKS_PER_MSEC)) /
|
|
||||||
1000.f;
|
|
||||||
hdttt2.push_back(dtt2);
|
|
||||||
lastTime2 = svcGetSystemTick();
|
|
||||||
bool updgg = this->UpdateScreenF(testfps);
|
|
||||||
currentTime2 = svcGetSystemTick();
|
|
||||||
dtt3 = ((float)(currentTime2 / (float)TICKS_PER_MSEC) -
|
|
||||||
(float)(lastTime2 / (float)TICKS_PER_MSEC)) /
|
|
||||||
1000.f;
|
|
||||||
if (updgg)
|
|
||||||
hdttt3.push_back(dtt3);
|
|
||||||
if (!shouldbe_disabled)
|
|
||||||
this->DrawScreen();
|
|
||||||
renderedframes++;
|
|
||||||
if (mdtt2 < dtt2) {
|
|
||||||
mdtt2 = dtt2;
|
|
||||||
}
|
|
||||||
if (mdtt3 < dtt3 && updgg) {
|
|
||||||
mdtt3 = dtt3;
|
|
||||||
}
|
|
||||||
timer += 1 * dtt;
|
|
||||||
float hdtt = C3D_GetProcessingTime();
|
|
||||||
hdttt.push_back(hdtt);
|
|
||||||
fpscountc.push_back(fps);
|
|
||||||
if (mhdtt < hdtt) {
|
|
||||||
mhdtt = C3D_GetProcessingTime();
|
|
||||||
}
|
|
||||||
/*if (!shouldbe_disabled)
|
|
||||||
{
|
|
||||||
RenderD7::OnScreen(Bottom);
|
|
||||||
RenderD7::DrawText(0, 0, 0.5f, RenderD7::Color::Hex("#ff0000"),
|
|
||||||
"Time: " + std::to_string(timer)); RenderD7::DrawText(0, 20, 0.5f,
|
|
||||||
RenderD7::Color::Hex("#ff0000"), "Fps: " + std::to_string(fps));
|
|
||||||
RenderD7::DrawText(0, 40, 0.5f, RenderD7::Color::Hex("#ff0000"),
|
|
||||||
"dt: " + std::to_string(dtt)); RenderD7::DrawText(0, 60, 0.5f,
|
|
||||||
RenderD7::Color::Hex("#ff0000"), "MaxRenderTime: " +
|
|
||||||
std::to_string(mdtt2*1000) + "ms/f"); RenderD7::DrawText(0, 80, 0.5f,
|
|
||||||
RenderD7::Color::Hex("#ff0000"), "MaxConvertTime: " +
|
|
||||||
std::to_string(mdtt3*1000) + "ms");
|
|
||||||
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::BitmapPrinter::SetupBenchmark(int framerate) {
|
|
||||||
benchmark = true;
|
|
||||||
setupbenchmark = true;
|
|
||||||
this->testfps = framerate;
|
|
||||||
this->testfpsd = framerate;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <renderd7/debugfont.h>
|
|
||||||
|
|
||||||
void RenderD7::BitmapPrinter::DrawDebugChar(u32 posX, u32 posY, int t_size,
|
|
||||||
u32 color, char character) {
|
|
||||||
bool isscale = (t_size > 1) ? true : false;
|
|
||||||
for (u32 y = 0; y < 8; y++) {
|
|
||||||
char charPos = debugfont[character * 8 + y];
|
|
||||||
|
|
||||||
for (u32 x = 0; x < 8; x++)
|
|
||||||
if (((charPos >> (7 - x)) & 1) == 1) {
|
|
||||||
if (!isscale)
|
|
||||||
DrawPixel((int)posX + x + 1, (int)posY + y + 1, UNPACK_BGRA(color));
|
|
||||||
if (isscale)
|
|
||||||
DrawRectFilled(((int)posX) + (x * t_size) + 1,
|
|
||||||
((int)posY) + (y * t_size) + 1, t_size, t_size,
|
|
||||||
UNPACK_BGRA(color));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::BitmapPrinter::DrawChar(int posX, int posY, float t_size,
|
|
||||||
u32 color, char character,
|
|
||||||
RenderD7::NFontApi font) {
|
|
||||||
for (int y = 0; y < font.GetGlyphHeight(character); y++) {
|
|
||||||
for (int x = 0; x < font.GetGlyphWidth(character); x++) {
|
|
||||||
DrawPixel(posX + x + 1, posY + y + 1, 255, 255, 255,
|
|
||||||
font.GetGlyphBitmap(
|
|
||||||
character)[((y * font.GetGlyphWidth(character) + x) * 1)]);
|
|
||||||
if (((font.GetGlyphBitmap(
|
|
||||||
character)[font.GetGlyphHeight(character) + y] >>
|
|
||||||
(font.GetGlyphWidth(character - 1) - x)) &
|
|
||||||
1) == 1) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// for(int y = 0; y < font.GetGlyphHeight(character) *
|
|
||||||
// font.GetGlyphWidth(character); y++)
|
|
||||||
//{
|
|
||||||
// DrawPixel(posX + x + 1, posY + y + 1, UNPACK_BGRA(color));
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define SPACING_Y 10
|
|
||||||
#define SPACING_X 8
|
|
||||||
|
|
||||||
void RenderD7::BitmapPrinter::DrawDebugText(int x, int y, int t_size, u32 color,
|
|
||||||
std::string text) {
|
|
||||||
if (t_size < 1) {
|
|
||||||
t_size = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (u32 i = 0, line_i = 0; i < strlen(text.c_str()); i++)
|
|
||||||
switch (text[i]) {
|
|
||||||
case '\n':
|
|
||||||
y += (SPACING_Y * t_size);
|
|
||||||
line_i = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '\t':
|
|
||||||
line_i += 2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
// Make sure we never get out of the screen
|
|
||||||
if (line_i >= (((u32)this->bitmap.bmp_info_header.width) - (u32)x) /
|
|
||||||
(SPACING_X * t_size)) {
|
|
||||||
y += (SPACING_Y * t_size);
|
|
||||||
line_i = 1; // Little offset so we know the same text continues
|
|
||||||
if (text[i] == ' ')
|
|
||||||
break; // Spaces at the start look weird
|
|
||||||
}
|
|
||||||
|
|
||||||
this->DrawDebugChar((u32)x + line_i * (SPACING_X * t_size), (u32)y,
|
|
||||||
t_size, color, text[i]);
|
|
||||||
|
|
||||||
line_i++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::BitmapPrinter::DrawText(int x, int y, float t_size, u32 color,
|
|
||||||
std::string text,
|
|
||||||
RenderD7::NFontApi font) {
|
|
||||||
if (t_size < 1) {
|
|
||||||
t_size = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (u32 i = 0, line_i = 0; i < strlen(text.c_str()); i++)
|
|
||||||
switch (text[i]) {
|
|
||||||
case '\n':
|
|
||||||
y += (font.GetLineHeight());
|
|
||||||
line_i = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case '\t':
|
|
||||||
line_i += 2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
// Make sure we never get out of the screen
|
|
||||||
if (line_i >= (((u32)this->bitmap.bmp_info_header.width) - (u32)x) /
|
|
||||||
(u32)(font.GetGlyphWidth(text[i]))) {
|
|
||||||
y += (SPACING_Y * t_size);
|
|
||||||
line_i = 1; // Little offset so we know the same text continues
|
|
||||||
if (text[i] == ' ')
|
|
||||||
break; // Spaces at the start look weird
|
|
||||||
}
|
|
||||||
|
|
||||||
this->DrawChar(x + line_i * (font.GetGlyphWidth(text[i])), y, t_size,
|
|
||||||
color, text[i], font);
|
|
||||||
|
|
||||||
line_i++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RenderD7::BitmapPrinter::Decode(Decoder deccc) {
|
|
||||||
bool res = false;
|
|
||||||
|
|
||||||
switch (deccc) {
|
|
||||||
case Decoder::BITMAP2PNG2C3D:
|
|
||||||
renderframe.LoadPFromBuffer(
|
|
||||||
BitmapConverter::ConvertData(this->bitmap.DATA()));
|
|
||||||
res = true;
|
|
||||||
break;
|
|
||||||
case Decoder::BITMAP2C3D:
|
|
||||||
renderframe.LoadFromBitmap(this->bitmap);
|
|
||||||
res = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
res = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::BitmapPrinter::DrawBitmap(int x, int y, BMP map) {
|
|
||||||
for (int i = 0; i < map.bmp_info_header.width; i++) {
|
|
||||||
for (int j = 0; j < map.bmp_info_header.height; j++) {
|
|
||||||
bitmap.set_pixel(
|
|
||||||
x + i, (bitmap.bmp_info_header.height - 1) - (y + j),
|
|
||||||
UNPACK_BGRA(map.get_pixel(i, (map.bmp_info_header.height - 1) - j)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
204
source/Color.cpp
204
source/Color.cpp
@ -1,30 +1,202 @@
|
|||||||
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <renderd7/Color.hpp>
|
#include <renderd7/Color.hpp>
|
||||||
|
#include <renderd7/external/json.hpp>
|
||||||
|
#include <renderd7/internal_db.hpp>
|
||||||
|
|
||||||
#define RGBA8(r, g, b, a) \
|
// This is btw the default theme setup
|
||||||
((((r)&0xFF) << 0) | (((g)&0xFF) << 8) | (((b)&0xFF) << 16) | \
|
// RenderD7 StyleColor Api
|
||||||
(((a)&0xFF) << 24))
|
// not const cause const = error lol
|
||||||
|
std::map<RD7Color, unsigned int> rd7i_color_map = {
|
||||||
|
{RD7Color_Text, RGBA8(0, 0, 0, 255)},
|
||||||
|
{RD7Color_Text2, RGBA8(255, 255, 255, 255)}, // For Background change or so
|
||||||
|
{RD7Color_TextDisabled, RGBA8(170, 170, 170, 255)},
|
||||||
|
{RD7Color_Background, RGBA8(238, 238, 238, 255)},
|
||||||
|
{RD7Color_Header, RGBA8(17, 17, 17, 255)},
|
||||||
|
{RD7Color_Selector, RGBA8(34, 34, 34, 255)},
|
||||||
|
{RD7Color_SelectorFade, RGBA8(90, 90, 90, 255)},
|
||||||
|
{RD7Color_List0, RGBA8(204, 204, 204, 255)}, // List0 = % 2
|
||||||
|
{RD7Color_List1, RGBA8(187, 187, 187, 255)},
|
||||||
|
{RD7Color_MessageBackground, RGBA8(51, 51, 51, 255)},
|
||||||
|
{RD7Color_Button, RGBA8(17, 17, 17, 255)},
|
||||||
|
{RD7Color_ButtonHovered, RGBA8(34, 34, 34, 255)},
|
||||||
|
{RD7Color_ButtonDisabled, RGBA8(8, 8, 8, 255)},
|
||||||
|
{RD7Color_ButtonActive, RGBA8(42, 42, 42, 255)},
|
||||||
|
{RD7Color_Checkmark, RGBA8(42, 42, 42, 255)},
|
||||||
|
{RD7Color_FrameBg, RGBA8(85, 85, 85, 255)},
|
||||||
|
{RD7Color_FrameBgHovered, RGBA8(119, 119, 119, 255)},
|
||||||
|
{RD7Color_Progressbar, RGBA8(0, 255, 0, 255)},
|
||||||
|
};
|
||||||
|
|
||||||
// uint32_t RenderD7::Color::Hex(const std::string &color, uint8_t a) {
|
std::map<RD7Color, unsigned int> rd7i_color_swap_map;
|
||||||
// if (color.length() < 7 ||
|
|
||||||
// std::regex_search(color.substr(1),
|
|
||||||
// std::regex("[^0-9A-Fa-f]"))) { // invalid color.
|
|
||||||
// return RenderD7::Color::Hex("#000000", 0);
|
|
||||||
// }
|
|
||||||
// int r = std::stoi(color.substr(1, 2), nullptr, 16);
|
|
||||||
// int g = std::stoi(color.substr(3, 2), nullptr, 16);
|
|
||||||
// int b = std::stoi(color.substr(5, 2), nullptr, 16);
|
|
||||||
// return RGBA8(r, g, b, a);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Lookup-Table für Hex-to-Dez-Konvertierung
|
unsigned int RenderD7::StyleColor(RD7Color color) {
|
||||||
|
if (rd7i_color_swap_map.find(color) != rd7i_color_swap_map.end())
|
||||||
|
return rd7i_color_swap_map[color];
|
||||||
|
else if (rd7i_color_map.find(color) != rd7i_color_map.end())
|
||||||
|
return rd7i_color_map[color];
|
||||||
|
return RGBA8(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderD7::ColorNew(RD7Color color, unsigned int new_color) {
|
||||||
|
// Dont edit before Init
|
||||||
|
if (!rd7i_running) return;
|
||||||
|
rd7i_color_map[color] = new_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderD7::RedirectColor(RD7Color to, RD7Color from) {
|
||||||
|
// As you see at the code Redirect doesnt redirect xd
|
||||||
|
// Just named cause it feels like redirecting
|
||||||
|
// Oh and if the color is edit you redirect to it is
|
||||||
|
// grabs that redirected lol
|
||||||
|
rd7i_color_swap_map[to] = StyleColor(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderD7::CustomizeColor(RD7Color color, unsigned int custom) {
|
||||||
|
rd7i_color_swap_map[color] = custom;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderD7::TextColorByBg(RD7Color background) {
|
||||||
|
UndoColorEdit(RD7Color_Text); // To be sure
|
||||||
|
rd7i_color_swap_map[RD7Color_Text] = StyleColor(
|
||||||
|
Color::RGBA(background).is_light() ? RD7Color_Text : RD7Color_Text2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderD7::UndoColorEdit(RD7Color color) {
|
||||||
|
if (rd7i_color_swap_map.find(color) == rd7i_color_swap_map.end()) return;
|
||||||
|
rd7i_color_swap_map.erase(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderD7::UndoAllColorEdits() { rd7i_color_swap_map.clear(); }
|
||||||
|
|
||||||
|
void rd7i_swap32(unsigned int& c) {
|
||||||
|
c = ((c & 0xFF) << 24) | ((c & 0xFF00) << 8) | ((c & 0xFF0000) >> 8) |
|
||||||
|
((c & 0xFF000000) >> 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string rd7i_mk2hex(unsigned int c32) {
|
||||||
|
rd7i_swap32(c32);
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "#";
|
||||||
|
ss << std::hex << std::setw(8) << std::setfill('0') << c32;
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Standart Color Converter
|
||||||
static const std::map<char, int> HEX_TO_DEC = {
|
static const std::map<char, int> HEX_TO_DEC = {
|
||||||
{'0', 0}, {'1', 1}, {'2', 2}, {'3', 3}, {'4', 4}, {'5', 5},
|
{'0', 0}, {'1', 1}, {'2', 2}, {'3', 3}, {'4', 4}, {'5', 5},
|
||||||
{'6', 6}, {'7', 7}, {'8', 8}, {'9', 9}, {'a', 10}, {'b', 11},
|
{'6', 6}, {'7', 7}, {'8', 8}, {'9', 9}, {'a', 10}, {'b', 11},
|
||||||
{'c', 12}, {'d', 13}, {'e', 14}, {'f', 15}, {'A', 10}, {'B', 11},
|
{'c', 12}, {'d', 13}, {'e', 14}, {'f', 15}, {'A', 10}, {'B', 11},
|
||||||
{'C', 12}, {'D', 13}, {'E', 14}, {'F', 15}};
|
{'C', 12}, {'D', 13}, {'E', 14}, {'F', 15}};
|
||||||
|
|
||||||
uint32_t RenderD7::Color::Hex(const std::string &color, uint8_t a) {
|
unsigned int rd7i_special_color_hex(const std::string& hex) {
|
||||||
|
if (hex.length() < 9 || std::find_if(hex.begin() + 1, hex.end(), [](char c) {
|
||||||
|
return !std::isxdigit(c);
|
||||||
|
}) != hex.end()) {
|
||||||
|
return rd7i_special_color_hex("#00000000");
|
||||||
|
}
|
||||||
|
|
||||||
|
int r = HEX_TO_DEC.at(hex[1]) * 16 + HEX_TO_DEC.at(hex[2]);
|
||||||
|
int g = HEX_TO_DEC.at(hex[3]) * 16 + HEX_TO_DEC.at(hex[4]);
|
||||||
|
int b = HEX_TO_DEC.at(hex[5]) * 16 + HEX_TO_DEC.at(hex[6]);
|
||||||
|
int a = HEX_TO_DEC.at(hex[7]) * 16 + HEX_TO_DEC.at(hex[8]);
|
||||||
|
|
||||||
|
return RGBA8(r, g, b, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderD7::ThemeLoad(const std::string& path) {
|
||||||
|
std::ifstream file(path);
|
||||||
|
if (!file.is_open()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
nlohmann::json js;
|
||||||
|
file >> js;
|
||||||
|
// clang-format off
|
||||||
|
if(THEMEVER != js["version"]) {
|
||||||
|
file.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
rd7i_color_map[RD7Color_Text] =rd7i_special_color_hex(js["RD7Color_Text"].get<std::string>());
|
||||||
|
rd7i_color_map[RD7Color_Text2] =rd7i_special_color_hex(js["RD7Color_Text2"].get<std::string>());
|
||||||
|
rd7i_color_map[RD7Color_TextDisabled] =rd7i_special_color_hex(js["RD7Color_TextDisabled"].get<std::string>());
|
||||||
|
rd7i_color_map[RD7Color_Background] =rd7i_special_color_hex(js["RD7Color_Background"].get<std::string>());
|
||||||
|
rd7i_color_map[RD7Color_Header] =rd7i_special_color_hex(js["RD7Color_Header"].get<std::string>());
|
||||||
|
rd7i_color_map[RD7Color_Selector] =rd7i_special_color_hex(js["RD7Color_Selector"].get<std::string>());
|
||||||
|
rd7i_color_map[RD7Color_SelectorFade] =rd7i_special_color_hex(js["RD7Color_SelectorFade"].get<std::string>());
|
||||||
|
rd7i_color_map[RD7Color_List0] =rd7i_special_color_hex(js["RD7Color_List0"].get<std::string>());
|
||||||
|
rd7i_color_map[RD7Color_List1] =rd7i_special_color_hex(js["RD7Color_List1"].get<std::string>());
|
||||||
|
rd7i_color_map[RD7Color_MessageBackground] = rd7i_special_color_hex(js["RD7Color_MessageBackground"].get<std::string>());
|
||||||
|
rd7i_color_map[RD7Color_Button] =rd7i_special_color_hex(js["RD7Color_Button"].get<std::string>());
|
||||||
|
rd7i_color_map[RD7Color_ButtonHovered] =rd7i_special_color_hex(js["RD7Color_ButtonHovered"].get<std::string>());
|
||||||
|
rd7i_color_map[RD7Color_ButtonDisabled] =rd7i_special_color_hex(js["RD7Color_ButtonDisabled"].get<std::string>());
|
||||||
|
rd7i_color_map[RD7Color_ButtonActive] =rd7i_special_color_hex(js["RD7Color_ButtonActive"].get<std::string>());
|
||||||
|
rd7i_color_map[RD7Color_Checkmark] =rd7i_special_color_hex(js["RD7Color_Checkmark"].get<std::string>());
|
||||||
|
rd7i_color_map[RD7Color_FrameBg] =rd7i_special_color_hex(js["RD7Color_FrameBg"].get<std::string>());
|
||||||
|
rd7i_color_map[RD7Color_FrameBgHovered] =rd7i_special_color_hex(js["RD7Color_FrameBgHovered"].get<std::string>());
|
||||||
|
rd7i_color_map[RD7Color_Progressbar] =rd7i_special_color_hex(js["RD7Color_Progressbar"].get<std::string>());
|
||||||
|
// clang-format on
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderD7::ThemeSave(const std::string& path) {
|
||||||
|
if (std::filesystem::path(path).filename().string() == "renderd7.theme") {
|
||||||
|
if (!rd7i_amdt) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::ofstream file(path);
|
||||||
|
if (!file.is_open()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
nlohmann::json js;
|
||||||
|
// clang-format off
|
||||||
|
js["version"] = THEMEVER;
|
||||||
|
js["RD7Color_Text"] = rd7i_mk2hex(rd7i_color_map[RD7Color_Text]);
|
||||||
|
js["RD7Color_Text2"] = rd7i_mk2hex(rd7i_color_map[RD7Color_Text2]);
|
||||||
|
js["RD7Color_TextDisabled"] = rd7i_mk2hex(rd7i_color_map[RD7Color_TextDisabled]);
|
||||||
|
js["RD7Color_Background"] = rd7i_mk2hex(rd7i_color_map[RD7Color_Background]);
|
||||||
|
js["RD7Color_Header"] = rd7i_mk2hex(rd7i_color_map[RD7Color_Header]);
|
||||||
|
js["RD7Color_Selector"] = rd7i_mk2hex(rd7i_color_map[RD7Color_Selector]);
|
||||||
|
js["RD7Color_SelectorFade"] = rd7i_mk2hex(rd7i_color_map[RD7Color_SelectorFade]);
|
||||||
|
js["RD7Color_List0"] = rd7i_mk2hex(rd7i_color_map[RD7Color_List0]);
|
||||||
|
js["RD7Color_List1"] = rd7i_mk2hex(rd7i_color_map[RD7Color_List1]);
|
||||||
|
js["RD7Color_MessageBackground"] = rd7i_mk2hex(rd7i_color_map[RD7Color_MessageBackground]);
|
||||||
|
js["RD7Color_Button"] = rd7i_mk2hex(rd7i_color_map[RD7Color_Button]);
|
||||||
|
js["RD7Color_ButtonHovered"] = rd7i_mk2hex(rd7i_color_map[RD7Color_ButtonHovered]);
|
||||||
|
js["RD7Color_ButtonDisabled"] = rd7i_mk2hex(rd7i_color_map[RD7Color_ButtonDisabled]);
|
||||||
|
js["RD7Color_ButtonActive"] = rd7i_mk2hex(rd7i_color_map[RD7Color_ButtonActive]);
|
||||||
|
js["RD7Color_Checkmark"] = rd7i_mk2hex(rd7i_color_map[RD7Color_Checkmark]);
|
||||||
|
js["RD7Color_FrameBg"] = rd7i_mk2hex(rd7i_color_map[RD7Color_FrameBg]);
|
||||||
|
js["RD7Color_FrameBgHovered"] = rd7i_mk2hex(rd7i_color_map[RD7Color_FrameBgHovered]);
|
||||||
|
js["RD7Color_Progressbar"] = rd7i_mk2hex(rd7i_color_map[RD7Color_Progressbar]);
|
||||||
|
// clang-format on
|
||||||
|
file << js.dump(4);
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderD7::ThemeDefault() {
|
||||||
|
rd7i_color_map[RD7Color_Text] = RGBA8(0, 0, 0, 255);
|
||||||
|
rd7i_color_map[RD7Color_Text2] = RGBA8(255, 255, 255, 255);
|
||||||
|
rd7i_color_map[RD7Color_TextDisabled] = RGBA8(170, 170, 170, 255);
|
||||||
|
rd7i_color_map[RD7Color_Background] = RGBA8(238, 238, 238, 255);
|
||||||
|
rd7i_color_map[RD7Color_Header] = RGBA8(17, 17, 17, 255);
|
||||||
|
rd7i_color_map[RD7Color_Selector] = RGBA8(34, 34, 34, 255);
|
||||||
|
rd7i_color_map[RD7Color_SelectorFade] = RGBA8(90, 90, 90, 255);
|
||||||
|
rd7i_color_map[RD7Color_List0] = RGBA8(204, 204, 204, 255);
|
||||||
|
rd7i_color_map[RD7Color_List1] = RGBA8(187, 187, 187, 255);
|
||||||
|
rd7i_color_map[RD7Color_MessageBackground] = RGBA8(51, 51, 51, 255);
|
||||||
|
rd7i_color_map[RD7Color_Button] = RGBA8(17, 17, 17, 255);
|
||||||
|
rd7i_color_map[RD7Color_ButtonHovered] = RGBA8(34, 34, 34, 255);
|
||||||
|
rd7i_color_map[RD7Color_ButtonDisabled] = RGBA8(8, 8, 8, 255);
|
||||||
|
rd7i_color_map[RD7Color_ButtonActive] = RGBA8(42, 42, 42, 255);
|
||||||
|
rd7i_color_map[RD7Color_Checkmark] = RGBA8(42, 42, 42, 255);
|
||||||
|
rd7i_color_map[RD7Color_FrameBg] = RGBA8(85, 85, 85, 255);
|
||||||
|
rd7i_color_map[RD7Color_FrameBgHovered] = RGBA8(119, 119, 119, 255);
|
||||||
|
rd7i_color_map[RD7Color_Progressbar] = RGBA8(0, 255, 0, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t RenderD7::Color::Hex(const std::string& color, uint8_t a) {
|
||||||
if (color.length() < 7 ||
|
if (color.length() < 7 ||
|
||||||
std::find_if(color.begin() + 1, color.end(),
|
std::find_if(color.begin() + 1, color.end(),
|
||||||
[](char c) { return !std::isxdigit(c); }) != color.end()) {
|
[](char c) { return !std::isxdigit(c); }) != color.end()) {
|
||||||
|
216
source/Draw.cpp
216
source/Draw.cpp
@ -1,216 +0,0 @@
|
|||||||
#include <renderd7/Draw.hpp>
|
|
||||||
|
|
||||||
extern C2D_TextBuf TextBuf;
|
|
||||||
extern C2D_Font Font;
|
|
||||||
extern bool currentScreen;
|
|
||||||
|
|
||||||
bool RenderD7::Draw::Rect(float x, float y, float w, float h, u32 color) {
|
|
||||||
return C2D_DrawRectSolid(x, y, 0.5f, w, h, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RenderD7::Draw::Px(float x, float y, u32 color) {
|
|
||||||
return C2D_DrawRectSolid(x, y, 0.5f, 1, 1, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::Draw::TextCentered(float x, float y, float size, u32 color,
|
|
||||||
std::string Text, int maxWidth, int maxHeight,
|
|
||||||
C2D_Font fnt) {
|
|
||||||
float lineHeight, widthScale;
|
|
||||||
|
|
||||||
// Check for the lineHeight.
|
|
||||||
if (fnt != nullptr) {
|
|
||||||
lineHeight = RenderD7::Draw::GetTextHeight(size, " ", fnt);
|
|
||||||
} else {
|
|
||||||
lineHeight = RenderD7::Draw::GetTextHeight(size, " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
int line = 0;
|
|
||||||
while (Text.find('\n') != Text.npos) {
|
|
||||||
if (maxWidth == 0) {
|
|
||||||
// Do the widthScale.
|
|
||||||
if (fnt != nullptr) {
|
|
||||||
widthScale = RenderD7::Draw::GetTextWidth(
|
|
||||||
size, Text.substr(0, Text.find('\n')), fnt);
|
|
||||||
} else {
|
|
||||||
widthScale =
|
|
||||||
RenderD7::Draw::GetTextWidth(size, Text.substr(0, Text.find('\n')));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Do the widthScale 2.
|
|
||||||
if (fnt != nullptr) {
|
|
||||||
widthScale = std::min((float)maxWidth,
|
|
||||||
RenderD7::Draw::GetTextWidth(
|
|
||||||
size, Text.substr(0, Text.find('\n')), fnt));
|
|
||||||
} else {
|
|
||||||
widthScale = std::min((float)maxWidth,
|
|
||||||
RenderD7::Draw::GetTextWidth(
|
|
||||||
size, Text.substr(0, Text.find('\n'))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fnt != nullptr) {
|
|
||||||
RenderD7::Draw::Text((currentScreen ? 200 : 160) + x - (widthScale / 2),
|
|
||||||
y + (lineHeight * line), size, color,
|
|
||||||
Text.substr(0, Text.find('\n')), maxWidth, maxHeight,
|
|
||||||
fnt);
|
|
||||||
} else {
|
|
||||||
RenderD7::Draw::Text((currentScreen ? 200 : 160) + x - (widthScale / 2),
|
|
||||||
y + (lineHeight * line), size, color,
|
|
||||||
Text.substr(0, Text.find('\n')), maxWidth,
|
|
||||||
maxHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
Text = Text.substr(Text.find('\n') + 1);
|
|
||||||
line++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxWidth == 0) {
|
|
||||||
// Do the next WidthScale.
|
|
||||||
if (fnt != nullptr) {
|
|
||||||
widthScale = RenderD7::Draw::GetTextWidth(
|
|
||||||
size, Text.substr(0, Text.find('\n')), fnt);
|
|
||||||
} else {
|
|
||||||
widthScale =
|
|
||||||
RenderD7::Draw::GetTextWidth(size, Text.substr(0, Text.find('\n')));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// And again.
|
|
||||||
if (fnt != nullptr) {
|
|
||||||
widthScale = std::min((float)maxWidth,
|
|
||||||
RenderD7::Draw::GetTextWidth(
|
|
||||||
size, Text.substr(0, Text.find('\n')), fnt));
|
|
||||||
} else {
|
|
||||||
widthScale = std::min(
|
|
||||||
(float)maxWidth,
|
|
||||||
RenderD7::Draw::GetTextWidth(size, Text.substr(0, Text.find('\n'))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fnt != nullptr) {
|
|
||||||
RenderD7::Draw::Text((currentScreen ? 200 : 160) + x - (widthScale / 2),
|
|
||||||
y + (lineHeight * line), size, color,
|
|
||||||
Text.substr(0, Text.find('\n')), maxWidth, maxHeight,
|
|
||||||
fnt);
|
|
||||||
} else {
|
|
||||||
RenderD7::Draw::Text((currentScreen ? 200 : 160) + x - (widthScale / 2),
|
|
||||||
y + (lineHeight * line), size, color,
|
|
||||||
Text.substr(0, Text.find('\n')), maxWidth, maxHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw String or Text.
|
|
||||||
void RenderD7::Draw::Text(float x, float y, float size, u32 color,
|
|
||||||
std::string Text, int maxWidth, int maxHeight,
|
|
||||||
C2D_Font fnt) {
|
|
||||||
C2D_Text c2d_text;
|
|
||||||
|
|
||||||
if (fnt != nullptr) {
|
|
||||||
C2D_TextFontParse(&c2d_text, fnt, TextBuf, Text.c_str());
|
|
||||||
} else {
|
|
||||||
C2D_TextFontParse(&c2d_text, Font, TextBuf, Text.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
C2D_TextOptimize(&c2d_text);
|
|
||||||
|
|
||||||
float heightScale;
|
|
||||||
if (maxHeight == 0) {
|
|
||||||
heightScale = size;
|
|
||||||
} else {
|
|
||||||
if (fnt != nullptr) {
|
|
||||||
heightScale = std::min(
|
|
||||||
size,
|
|
||||||
size * (maxHeight / RenderD7::Draw::GetTextHeight(size, Text, fnt)));
|
|
||||||
} else {
|
|
||||||
heightScale = std::min(
|
|
||||||
size, size * (maxHeight / RenderD7::Draw::GetTextHeight(size, Text)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxWidth == 0) {
|
|
||||||
C2D_DrawText(&c2d_text, C2D_WithColor, x, y, 0.5f, size, heightScale,
|
|
||||||
color);
|
|
||||||
} else {
|
|
||||||
if (fnt != nullptr) {
|
|
||||||
C2D_DrawText(
|
|
||||||
&c2d_text, C2D_WithColor, x, y, 0.5f,
|
|
||||||
std::min(size, size * (maxWidth / RenderD7::Draw::GetTextWidth(
|
|
||||||
size, Text, fnt))),
|
|
||||||
heightScale, color);
|
|
||||||
} else {
|
|
||||||
C2D_DrawText(
|
|
||||||
&c2d_text, C2D_WithColor, x, y, 0.5f,
|
|
||||||
std::min(size, size * (maxWidth /
|
|
||||||
RenderD7::Draw::GetTextWidth(size, Text))),
|
|
||||||
heightScale, color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void RenderD7::Draw::TextRight(float x, float y, float size, u32 color,
|
|
||||||
std::string Text, int maxWidth, int maxHeight,
|
|
||||||
C2D_Font fnt) {
|
|
||||||
RenderD7::Draw::Text(x - RenderD7::Draw::GetTextWidth(size, Text, fnt), y,
|
|
||||||
size, color, Text, maxWidth, maxHeight, fnt);
|
|
||||||
}
|
|
||||||
// Get String or Text Width.
|
|
||||||
float RenderD7::Draw::GetTextWidth(float size, std::string Text, C2D_Font fnt) {
|
|
||||||
float width = 0;
|
|
||||||
if (fnt != nullptr) {
|
|
||||||
GetTextSize(size, &width, NULL, Text, fnt);
|
|
||||||
} else {
|
|
||||||
GetTextSize(size, &width, NULL, Text);
|
|
||||||
}
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get String or Text Size.
|
|
||||||
void RenderD7::Draw::GetTextSize(float size, float *width, float *height,
|
|
||||||
std::string Text, C2D_Font fnt) {
|
|
||||||
C2D_Text c2d_text;
|
|
||||||
if (fnt != nullptr) {
|
|
||||||
C2D_TextFontParse(&c2d_text, fnt, TextBuf, Text.c_str());
|
|
||||||
} else {
|
|
||||||
C2D_TextFontParse(&c2d_text, Font, TextBuf, Text.c_str());
|
|
||||||
}
|
|
||||||
C2D_TextGetDimensions(&c2d_text, size, size, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get String or Text Height.
|
|
||||||
float RenderD7::Draw::GetTextHeight(float size, std::string Text,
|
|
||||||
C2D_Font fnt) {
|
|
||||||
float height = 0;
|
|
||||||
if (fnt != nullptr) {
|
|
||||||
GetTextSize(size, NULL, &height, Text.c_str(), fnt);
|
|
||||||
} else {
|
|
||||||
GetTextSize(size, NULL, &height, Text.c_str());
|
|
||||||
}
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result RenderD7::Draw::LoadFont(C2D_Font &fnt, const char *Path) {
|
|
||||||
fnt = C2D_FontLoad(Path); // Only load if found.
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unload a Font.
|
|
||||||
Result RenderD7::Draw::UnloadFont(C2D_Font &fnt) {
|
|
||||||
if (fnt != nullptr) {
|
|
||||||
C2D_FontFree(fnt); // Make sure to only unload if not nullptr.
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RenderD7::Draw::Circle(float x, float y, float radius, u32 color) {
|
|
||||||
return C2D_DrawCircleSolid(x, y, 0.5f, radius, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RenderD7::Draw::Image(C2D_Image img, float x, float y, float scaleX,
|
|
||||||
float scaleY) {
|
|
||||||
return C2D_DrawImageAt(img, x, y, 0.5f, nullptr, scaleX, scaleY);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RenderD7::Draw::NFRect(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;
|
|
||||||
}
|
|
239
source/DrawV2.cpp
Normal file
239
source/DrawV2.cpp
Normal file
@ -0,0 +1,239 @@
|
|||||||
|
#include <citro2d.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <renderd7/DrawV2.hpp>
|
||||||
|
#include <renderd7/global_db.hpp>
|
||||||
|
#include <renderd7/internal_db.hpp>
|
||||||
|
|
||||||
|
const float rd7i_d7_dts = 0.5f;
|
||||||
|
float rd7i_d2_txt_size = rd7i_d7_dts;
|
||||||
|
C2D_Font rd7i_d2_fnt = nullptr;
|
||||||
|
R7Vec2 rd7i_d7_mwh = R7Vec2(0, 0);
|
||||||
|
std::map<std::string, float> rd7i_d2_ts;
|
||||||
|
std::map<std::string, int> rd7i_d2_mln;
|
||||||
|
|
||||||
|
bool rd7i_txt_init = false;
|
||||||
|
|
||||||
|
std::string GetShortedText(const std::string &in, int maxlen) {
|
||||||
|
auto textdim = RenderD7::GetTextDimensions(in);
|
||||||
|
if (textdim.x < (float)maxlen) return in;
|
||||||
|
std::string ft = "";
|
||||||
|
std::string worker = in;
|
||||||
|
if (in.find_last_of('.') != in.npos) {
|
||||||
|
ft = in.substr(in.find_last_of('.'));
|
||||||
|
worker = in.substr(0, in.find_last_of('.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
maxlen -= RenderD7::GetTextDimensions(ft).x -
|
||||||
|
RenderD7::GetTextDimensions("(...)").x;
|
||||||
|
float len_mod = (float)maxlen / textdim.x;
|
||||||
|
int pos = (in.length() * len_mod) / rd7_draw2_tsm;
|
||||||
|
std::string out;
|
||||||
|
|
||||||
|
out = in.substr(0, pos);
|
||||||
|
|
||||||
|
for (size_t i = pos; i < worker.length(); i++) {
|
||||||
|
out += worker[i];
|
||||||
|
if (RenderD7::GetTextDimensions(out + "(...)" + ft).x > (float)maxlen) {
|
||||||
|
out += "(...)";
|
||||||
|
out += ft;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""; // Impossible to reach
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string WrapText(const std ::string &in, int maxlen) {
|
||||||
|
std::string out;
|
||||||
|
std::string line;
|
||||||
|
int line_x = 0;
|
||||||
|
std::istringstream istream(in);
|
||||||
|
std::string temp;
|
||||||
|
|
||||||
|
while (istream >> temp) {
|
||||||
|
R7Vec2 dim = RenderD7::GetTextDimensions(line + temp);
|
||||||
|
if (line_x + dim.x <= maxlen) {
|
||||||
|
line += temp + ' ';
|
||||||
|
line_x += dim.x;
|
||||||
|
} else {
|
||||||
|
out += line + '\n';
|
||||||
|
line = temp + ' ';
|
||||||
|
line_x = dim.x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out += line;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RD7I_FNT_VALID() {
|
||||||
|
if (rd7i_d2_fnt != nullptr && !rd7i_txt_init) {
|
||||||
|
rd7i_txt_init = true;
|
||||||
|
}
|
||||||
|
if (!rd7i_txt_init) {
|
||||||
|
if (rd7i_base_font != nullptr) {
|
||||||
|
rd7i_d2_fnt = rd7i_base_font;
|
||||||
|
rd7i_txt_init = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rd7i_d2_fnt != nullptr) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
rd7i_d2_fnt = rd7i_base_font;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Schould never be reached
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
R7Vec2 GetTextDimensions(const std::string &text) {
|
||||||
|
C2D_TextBufClear(rd7i_d2_dimbuf);
|
||||||
|
float w = 0, h = 0;
|
||||||
|
if (!RD7I_FNT_VALID()) return R7Vec2(w, h);
|
||||||
|
C2D_Text c2dtext;
|
||||||
|
C2D_TextFontParse(&c2dtext, rd7i_d2_fnt, rd7i_d2_dimbuf, text.c_str());
|
||||||
|
C2D_TextGetDimensions(&c2dtext, rd7i_d2_txt_size, rd7i_d2_txt_size, &w, &h);
|
||||||
|
return R7Vec2(w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomTextSize(float size) { rd7i_d2_txt_size = size; }
|
||||||
|
|
||||||
|
void TextDefaultSize() { rd7i_d2_txt_size = rd7i_d7_dts; }
|
||||||
|
|
||||||
|
void TextMaxBox(R7Vec2 size) { rd7i_d7_mwh = size; }
|
||||||
|
|
||||||
|
void TextDefaultBox() { rd7i_d7_mwh = R7Vec2(0, 0); }
|
||||||
|
|
||||||
|
void TextFont(Font fnt) { rd7i_d2_fnt = fnt.ptr(); }
|
||||||
|
|
||||||
|
void TextDefaultFont() { rd7i_d2_fnt = rd7i_base_font; }
|
||||||
|
|
||||||
|
std::string TextShort(const std::string &in, int max_len) {
|
||||||
|
return GetShortedText(in, max_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Draw2 {
|
||||||
|
void Rect(R7Vec2 pos, R7Vec2 size, unsigned int color, int t) {
|
||||||
|
// 4 DrawLine Calls Lol
|
||||||
|
C2D_DrawLine(pos.x, pos.y, color, pos.x + size.x, pos.y, color, t, 1.f);
|
||||||
|
C2D_DrawLine(pos.x, pos.y, color, pos.x, pos.y + size.y, color, t, 1.f);
|
||||||
|
C2D_DrawLine(pos.x + size.x, pos.y, color, pos.x + size.x, pos.y + size.y,
|
||||||
|
color, t, 1.f);
|
||||||
|
C2D_DrawLine(pos.x, pos.y + size.y, color, pos.x + size.x, pos.y + size.y,
|
||||||
|
color, t, 1.f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RectFilled(R7Vec2 pos, R7Vec2 size, Color4 colors) {
|
||||||
|
C2D_DrawRectangle(pos.x, pos.y, 0.5f, size.x, size.y, colors.color0,
|
||||||
|
colors.color1, colors.color2, colors.color3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RectFilledSolid(R7Vec2 pos, R7Vec2 size, unsigned int color) {
|
||||||
|
C2D_DrawRectSolid(pos.x, pos.y, 0.5f, size.x, size.y, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Line(R7Vec2 pos0, R7Vec2 pos1, unsigned int color, int t) {
|
||||||
|
C2D_DrawLine(pos0.x, pos0.y, color, pos1.x, pos1.y, color, t, 1.f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Triangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, Color3 colors) {
|
||||||
|
C2D_DrawTriangle(pos0.x, pos0.y, colors.color0, pos1.x, pos1.y, colors.color1,
|
||||||
|
pos2.x, pos2.y, colors.color2, 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TriangleSolid(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int color) {
|
||||||
|
C2D_DrawTriangle(pos0.x, pos0.y, color, pos1.x, pos1.y, color, pos2.x, pos2.y,
|
||||||
|
color, 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TriangleLined(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int color,
|
||||||
|
int t) {
|
||||||
|
// 3 Line Cqalls lol more efficient than Rect
|
||||||
|
C2D_DrawLine(pos0.x, pos0.y, color, pos1.x, pos1.y, color, t, 1.f);
|
||||||
|
C2D_DrawLine(pos0.x, pos0.y, color, pos2.x, pos2.y, color, t, 1.f);
|
||||||
|
C2D_DrawLine(pos1.x, pos1.y, color, pos2.x, pos2.y, color, t, 1.f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Text(R7Vec2 pos, const std::string &text, RD7TextFlags flags) {
|
||||||
|
// The Start of the C2D Text Hell
|
||||||
|
if (!RD7I_FNT_VALID()) return;
|
||||||
|
// little patch for a freeze
|
||||||
|
if (text.length() < 1) return;
|
||||||
|
// Variables
|
||||||
|
bool updated_mwh = false;
|
||||||
|
if (rd7i_d7_mwh.x == 0.0f) {
|
||||||
|
rd7i_d7_mwh.x = rd7i_current_screen ? 400 : 320;
|
||||||
|
updated_mwh = true;
|
||||||
|
}
|
||||||
|
if (rd7i_d7_mwh.y == 0.0f) {
|
||||||
|
rd7i_d7_mwh.y = 240;
|
||||||
|
updated_mwh = true;
|
||||||
|
}
|
||||||
|
std::string edit_text = text;
|
||||||
|
if (edit_text.substr(text.length() - 1) != "\n")
|
||||||
|
edit_text.append("\n"); // Add \n to end if not exist
|
||||||
|
int line = 0;
|
||||||
|
|
||||||
|
if (flags & RD7TextFlags_Wrap)
|
||||||
|
edit_text = WrapText(text, rd7i_d7_mwh.x - pos.x);
|
||||||
|
|
||||||
|
while (edit_text.find('\n') != edit_text.npos) {
|
||||||
|
std::string current_line = edit_text.substr(0, edit_text.find('\n'));
|
||||||
|
if (flags & RD7TextFlags_Short)
|
||||||
|
current_line = GetShortedText(current_line, rd7i_d7_mwh.x - pos.x);
|
||||||
|
R7Vec2 newpos = pos;
|
||||||
|
// Check Flags
|
||||||
|
R7Vec2 dim = GetTextDimensions(current_line);
|
||||||
|
if (flags & RD7TextFlags_AlignRight)
|
||||||
|
newpos.x = newpos.x - GetTextDimensions(current_line).x;
|
||||||
|
if (flags & RD7TextFlags_AlignMid) // Offset by inpos
|
||||||
|
newpos.x = (rd7i_d7_mwh.x * 0.5) - (dim.x * 0.5) + pos.x;
|
||||||
|
if (flags & RD7TextFlags_Scroll) { // Scroll Text
|
||||||
|
if (newpos.x + dim.x > rd7i_d7_mwh.x - newpos.x - 10) {
|
||||||
|
if (rd7i_d2_ts.find(current_line) == rd7i_d2_ts.end())
|
||||||
|
rd7i_d2_ts[current_line] = 0;
|
||||||
|
if (rd7i_d2_mln.find(current_line) == rd7i_d2_mln.end())
|
||||||
|
rd7i_d2_mln[current_line] =
|
||||||
|
GetShortedText(current_line, rd7i_d7_mwh.x - newpos.x).length();
|
||||||
|
rd7i_d2_ts[current_line] += rd7i_dtm * 6;
|
||||||
|
if ((int)rd7i_d2_ts[current_line] >= (int)current_line.length()) {
|
||||||
|
rd7i_d2_ts[current_line] = 0.0f;
|
||||||
|
}
|
||||||
|
std::string bcl = current_line;
|
||||||
|
current_line = current_line.substr((int)rd7i_d2_ts[current_line],
|
||||||
|
rd7i_d2_mln[current_line]);
|
||||||
|
if (newpos.x + GetTextDimensions(current_line).x <
|
||||||
|
rd7i_d7_mwh.x - newpos.x)
|
||||||
|
current_line +=
|
||||||
|
"|" + bcl.substr(0, rd7i_d2_ts[bcl] - (int)current_line.length());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rd7_debugging) {
|
||||||
|
RenderD7::Draw2::Rect(newpos, dim, RenderD7::Color::Hex("#ff0000"));
|
||||||
|
}
|
||||||
|
C2D_Text c2dtext;
|
||||||
|
C2D_TextFontParse(&c2dtext, rd7i_d2_fnt, rd7i_text_buffer,
|
||||||
|
current_line.c_str());
|
||||||
|
C2D_TextOptimize(&c2dtext);
|
||||||
|
|
||||||
|
if (flags & RD7TextFlags_Shaddow) // performance Killer xd
|
||||||
|
C2D_DrawText(&c2dtext, C2D_WithColor, newpos.x + 1 + (dim.y * line),
|
||||||
|
newpos.y + 1, 0.5, rd7i_d2_txt_size, rd7i_d2_txt_size,
|
||||||
|
RenderD7::StyleColor(RD7Color_TextDisabled));
|
||||||
|
|
||||||
|
C2D_DrawText(&c2dtext, C2D_WithColor, newpos.x, newpos.y + (dim.y * line),
|
||||||
|
0.5, rd7i_d2_txt_size, rd7i_d2_txt_size,
|
||||||
|
RenderD7::StyleColor(RD7Color_Text));
|
||||||
|
edit_text = edit_text.substr(edit_text.find('\n') + 1);
|
||||||
|
line++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updated_mwh) rd7i_d7_mwh = R7Vec2(0, 0);
|
||||||
|
}
|
||||||
|
void Image(RenderD7::Image *img, const R7Vec2 &pos, const R7Vec2 &scale) {
|
||||||
|
if (img->loaded())
|
||||||
|
C2D_DrawImageAt(img->get(), pos.x, pos.y, 0.5f, nullptr, scale.x, scale.y);
|
||||||
|
}
|
||||||
|
} // namespace Draw2
|
||||||
|
} // namespace RenderD7
|
44
source/Error.cpp
Normal file
44
source/Error.cpp
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#include <3ds.h>
|
||||||
|
|
||||||
|
#include <renderd7/Error.hpp>
|
||||||
|
#include <renderd7/UI7.hpp>
|
||||||
|
#include <renderd7/internal_db.hpp>
|
||||||
|
#include <renderd7/renderd7.hpp>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
void Error(const std::string& msg) {
|
||||||
|
if (rd7i_graphics_on) {
|
||||||
|
C3D_FrameEnd(0);
|
||||||
|
while (aptMainLoop()) {
|
||||||
|
hidScanInput();
|
||||||
|
if (hidKeysDown() & KEY_START) break;
|
||||||
|
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||||
|
RenderD7::ClearTextBufs();
|
||||||
|
C2D_TargetClear(Top, 0x00000000);
|
||||||
|
C2D_TargetClear(Bottom, 0x00000000);
|
||||||
|
RenderD7::OnScreen(Top);
|
||||||
|
if (UI7::BeginMenu("RenderD7 - Error Manager", R7Vec2(),
|
||||||
|
UI7MenuFlags_TitleMid)) {
|
||||||
|
UI7::Label(msg, RD7TextFlags_Wrap);
|
||||||
|
UI7::Label("Press Start to Exit!");
|
||||||
|
UI7::EndMenu();
|
||||||
|
}
|
||||||
|
RenderD7::OnScreen(Bottom);
|
||||||
|
C3D_FrameEnd(0);
|
||||||
|
}
|
||||||
|
exit(0);
|
||||||
|
} else {
|
||||||
|
gfxInitDefault();
|
||||||
|
consoleInit(GFX_TOP, NULL);
|
||||||
|
printf("RENDERD7 - ERROR MANAGER\n\n%s\n", msg.c_str());
|
||||||
|
printf("Press Start to Exit\n");
|
||||||
|
while (aptMainLoop()) {
|
||||||
|
hidScanInput();
|
||||||
|
if (hidKeysDown() & KEY_START) break;
|
||||||
|
gfxSwapBuffers();
|
||||||
|
}
|
||||||
|
gfxExit();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace RenderD7
|
@ -1,14 +1,48 @@
|
|||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <renderd7/FileSystem.hpp>
|
#include <renderd7/FileSystem.hpp>
|
||||||
// Debugging
|
// Debugging
|
||||||
|
#include <algorithm>
|
||||||
|
#include <filesystem>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <renderd7/stringtool.hpp>
|
#include <renderd7/stringtool.hpp>
|
||||||
|
|
||||||
#include <filesystem>
|
bool ___dir__predicate__(const RenderD7::FileSystem::Entry &lhs,
|
||||||
|
const RenderD7::FileSystem::Entry &rhs) {
|
||||||
|
if (!lhs.dir && rhs.dir) return false;
|
||||||
|
if (lhs.dir && !rhs.dir) return true;
|
||||||
|
std::string a = lhs.name;
|
||||||
|
std::string b = rhs.name;
|
||||||
|
std::transform(a.begin(), a.end(), a.begin(),
|
||||||
|
[](int i) { return std::tolower(i); });
|
||||||
|
std::transform(b.begin(), b.end(), b.begin(),
|
||||||
|
[](int i) { return std::tolower(i); });
|
||||||
|
return a.compare(b) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<RenderD7::FileSystem::Entry>
|
std::string RenderD7::FileSystem::GetParentPath(std::string path,
|
||||||
RenderD7::FileSystem::GetDirContent(std::string path) {
|
std::string mount_point) {
|
||||||
|
std::string tcl = path;
|
||||||
|
if (path.substr(path.length() - 1, 1) != "/") {
|
||||||
|
tcl += "/";
|
||||||
|
}
|
||||||
|
std::string res;
|
||||||
|
if (std::filesystem::exists(
|
||||||
|
std::filesystem::path(tcl).parent_path().parent_path()))
|
||||||
|
res = std::filesystem::path(tcl).parent_path().parent_path().string();
|
||||||
|
if (res.length() > mount_point.length()) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mount_point;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<RenderD7::FileSystem::Entry> RenderD7::FileSystem::GetDirContent(
|
||||||
|
std::string path) {
|
||||||
std::vector<RenderD7::FileSystem::Entry> res;
|
std::vector<RenderD7::FileSystem::Entry> res;
|
||||||
for (const auto &entry :
|
for (const auto &entry :
|
||||||
std::filesystem::directory_iterator(std::filesystem::path(path))) {
|
std::filesystem::directory_iterator(std::filesystem::path(path))) {
|
||||||
@ -17,3 +51,23 @@ RenderD7::FileSystem::GetDirContent(std::string path) {
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<RenderD7::FileSystem::Entry>
|
||||||
|
RenderD7::FileSystem::GetDirContentsExt(
|
||||||
|
std::string &path, const std::vector<std::string> &extensions) {
|
||||||
|
std::vector<RenderD7::FileSystem::Entry> res;
|
||||||
|
for (auto const &it :
|
||||||
|
std::filesystem::directory_iterator(std::filesystem::path(path))) {
|
||||||
|
RenderD7::FileSystem::Entry temp;
|
||||||
|
std::string fn = it.path().string();
|
||||||
|
temp.name = GetFileName(fn);
|
||||||
|
temp.path = it.path().string().c_str();
|
||||||
|
temp.dir = it.is_directory();
|
||||||
|
if (NameIsEndingWith(GetFileName(it.path().string()), extensions) ||
|
||||||
|
it.is_directory()) {
|
||||||
|
res.push_back(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::sort(res.begin(), res.end(), ___dir__predicate__);
|
||||||
|
return res;
|
||||||
|
}
|
110
source/Hid.cpp
Normal file
110
source/Hid.cpp
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
#include <map>
|
||||||
|
#include <renderd7/Hid.hpp>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
class HidApi {
|
||||||
|
public:
|
||||||
|
HidApi() {}
|
||||||
|
~HidApi() {}
|
||||||
|
|
||||||
|
void setKdown(uint32_t &in) { actions[Hid::Down] = ∈ }
|
||||||
|
void setKheld(uint32_t &in) { actions[Hid::Held] = ∈ }
|
||||||
|
void setKup(uint32_t &in) { actions[Hid::Up] = ∈ }
|
||||||
|
void setKrepeat(uint32_t &in) { actions[Hid::DownRepeat] = ∈ }
|
||||||
|
void setTouchCoords(R7Vec2 &touch_coords) { touch_pos = &touch_coords; }
|
||||||
|
void setJS1Movement(R7Vec2 &mvmt) { js1_mv = &mvmt; }
|
||||||
|
void setJS2Movement(R7Vec2 &mvmt) { js2_mv = &mvmt; }
|
||||||
|
void bindKey(const std::string &event, uint32_t key) {
|
||||||
|
key_bindings[event] = key; // Overrides if existing
|
||||||
|
}
|
||||||
|
void lock(bool lock) { locked = lock; }
|
||||||
|
|
||||||
|
void clear() {
|
||||||
|
// Clears Functionality for 1 Frame
|
||||||
|
last_touch_pos = R7Vec2();
|
||||||
|
touch_pos[0] = R7Vec2();
|
||||||
|
backups[Hid::Down] = 0;
|
||||||
|
backups[Hid::Held] = 0;
|
||||||
|
backups[Hid::Up] = 0;
|
||||||
|
backups[Hid::DownRepeat] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isEvent(const std::string &event, Hid::Actions action) {
|
||||||
|
if (locked) return false;
|
||||||
|
if (key_bindings.find(event) == key_bindings.end())
|
||||||
|
return false; // Unknown Event
|
||||||
|
if (backups.find(action) == backups.end())
|
||||||
|
return false; // What? NOT Alowed acrion
|
||||||
|
if (backups[action] & key_bindings[event])
|
||||||
|
return true; // Action contains key as flag
|
||||||
|
return false; // Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
R7Vec2 getTouchPos() { return touch_pos[0]; }
|
||||||
|
R7Vec2 getLastTouchPos() { return last_touch_pos; }
|
||||||
|
|
||||||
|
void update() {
|
||||||
|
last_touch_pos = touch_pos[0];
|
||||||
|
for (const auto &it : actions) {
|
||||||
|
backups[it.first] = it.second[0];
|
||||||
|
}
|
||||||
|
if (locked) {
|
||||||
|
actions[Hid::Down][0] = 0;
|
||||||
|
actions[Hid::Held][0] = 0;
|
||||||
|
actions[Hid::Up][0] = 0;
|
||||||
|
actions[Hid::DownRepeat][0] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::map<Hid::Actions, uint32_t *> actions;
|
||||||
|
std::map<Hid::Actions, uint32_t> backups;
|
||||||
|
R7Vec2 *touch_pos = nullptr;
|
||||||
|
R7Vec2 *js1_mv = nullptr;
|
||||||
|
R7Vec2 *js2_mv = nullptr;
|
||||||
|
|
||||||
|
R7Vec2 last_touch_pos;
|
||||||
|
|
||||||
|
std::map<std::string, uint32_t> key_bindings;
|
||||||
|
bool locked = false;
|
||||||
|
};
|
||||||
|
static HidApi hid_handler;
|
||||||
|
namespace Hid {
|
||||||
|
// Register Functions
|
||||||
|
// Register Current state values
|
||||||
|
void RegKeyDown(uint32_t &key_down) { hid_handler.setKdown(key_down); }
|
||||||
|
|
||||||
|
void RegKeyHeld(uint32_t &key_held) { hid_handler.setKheld(key_held); }
|
||||||
|
|
||||||
|
void RegKeyUp(uint32_t &key_up) { hid_handler.setKup(key_up); }
|
||||||
|
|
||||||
|
void RegKeyRepeat(uint32_t &repeat) { hid_handler.setKrepeat(repeat); }
|
||||||
|
|
||||||
|
void RegTouchCoords(R7Vec2 &touch_pos) {
|
||||||
|
hid_handler.setTouchCoords(touch_pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegAnalog1Movement(R7Vec2 &movement) {
|
||||||
|
hid_handler.setJS1Movement(movement);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegAnalog2Movement(R7Vec2 &movement) {
|
||||||
|
hid_handler.setJS2Movement(movement);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register Keys
|
||||||
|
void RegKeyEvent(const std::string &event, uint32_t key) {
|
||||||
|
hid_handler.bindKey(event, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsEvent(const std::string &event, Actions action) {
|
||||||
|
return hid_handler.isEvent(event, action);
|
||||||
|
}
|
||||||
|
R7Vec2 GetTouchPosition() { return hid_handler.getTouchPos(); }
|
||||||
|
R7Vec2 GetLastTouchPosition() { return hid_handler.getLastTouchPos(); }
|
||||||
|
void Update() { hid_handler.update(); }
|
||||||
|
void Lock() { hid_handler.lock(true); }
|
||||||
|
void Unlock() { hid_handler.lock(false); }
|
||||||
|
void Clear() { hid_handler.clear(); }
|
||||||
|
} // namespace Hid
|
||||||
|
} // namespace RenderD7
|
354
source/Image.cpp
354
source/Image.cpp
@ -1,23 +1,9 @@
|
|||||||
#include <renderd7/Image.hpp>
|
|
||||||
#include <renderd7/ToastsV2.hpp>
|
|
||||||
#include <renderd7/external/stb_image.h>
|
#include <renderd7/external/stb_image.h>
|
||||||
extern bool usedbgmsg;
|
|
||||||
|
|
||||||
void convert24to32(unsigned char *inputImage, int width, int height,
|
#include <renderd7/Image.hpp>
|
||||||
unsigned char *outputImage) {
|
#include <vector>
|
||||||
for (int y = 0; y < height; y++) {
|
|
||||||
for (int x = 0; x < width; x++) {
|
|
||||||
int i = (y * width + x) * 3; // index of current pixel in input image
|
|
||||||
int j = (y * width + x) * 4; // index of current pixel in output image
|
|
||||||
outputImage[j] = inputImage[i]; // copy red channel
|
|
||||||
outputImage[j + 1] = inputImage[i + 1]; // copy green channel
|
|
||||||
outputImage[j + 2] = inputImage[i + 2]; // copy blue channel
|
|
||||||
outputImage[j + 3] = 255; // set alpha channel to 255 (fully opaque)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static u32 GetNextPowerOf2(u32 v) {
|
static u32 __rd7i_gp2o__(u32 v) {
|
||||||
v--;
|
v--;
|
||||||
v |= v >> 1;
|
v |= v >> 1;
|
||||||
v |= v >> 2;
|
v |= v >> 2;
|
||||||
@ -28,70 +14,24 @@ static u32 GetNextPowerOf2(u32 v) {
|
|||||||
return (v >= 64 ? v : 64);
|
return (v >= 64 ? v : 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool C3DTexToC2DImage(C2D_Image *texture, u32 width, u32 height,
|
static void __rd7i_r24r32(std::vector<uint8_t> &out,
|
||||||
u8 *buf) {
|
const std::vector<uint8_t> &in, const int &w,
|
||||||
if (width >= 1024 || height >= 1024)
|
const int &h) {
|
||||||
return false;
|
// Converts RGB24 to RGBA32
|
||||||
|
for (int y = 0; y < h; y++) {
|
||||||
C3D_Tex *tex = new C3D_Tex[sizeof(C3D_Tex)];
|
for (int x = 0; x < w; x++) {
|
||||||
Tex3DS_SubTexture *subtex = new Tex3DS_SubTexture[sizeof(Tex3DS_SubTexture)];
|
int src = (y * w + x) * 3;
|
||||||
subtex->width = static_cast<u16>(width);
|
int dst = (y * w + x) * 4;
|
||||||
subtex->height = static_cast<u16>(height);
|
out[dst + 0] = in[src + 0];
|
||||||
// RGBA -> ABGR
|
out[dst + 1] = in[src + 1];
|
||||||
for (u32 row = 0; row < subtex->width; row++) {
|
out[dst + 2] = in[src + 2];
|
||||||
for (u32 col = 0; col < subtex->height; col++) {
|
out[dst + 3] = 255;
|
||||||
u32 z = (row + col * subtex->width) * 4;
|
|
||||||
|
|
||||||
u8 r = *(u8 *)(buf + z);
|
|
||||||
u8 g = *(u8 *)(buf + z + 1);
|
|
||||||
u8 b = *(u8 *)(buf + z + 2);
|
|
||||||
u8 a = *(u8 *)(buf + z + 3);
|
|
||||||
|
|
||||||
*(buf + z) = a;
|
|
||||||
*(buf + z + 1) = b;
|
|
||||||
*(buf + z + 2) = g;
|
|
||||||
*(buf + z + 3) = r;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 w_pow2 = GetNextPowerOf2(subtex->width);
|
|
||||||
u32 h_pow2 = GetNextPowerOf2(subtex->height);
|
|
||||||
subtex->left = 0.f;
|
|
||||||
subtex->top = 1.f;
|
|
||||||
subtex->right = (subtex->width / static_cast<float>(w_pow2));
|
|
||||||
subtex->bottom = (1.0 - (subtex->height / static_cast<float>(h_pow2)));
|
|
||||||
C3D_TexInit(tex, static_cast<u16>(w_pow2), static_cast<u16>(h_pow2),
|
|
||||||
GPU_RGBA8);
|
|
||||||
C3D_TexSetFilter(tex, GPU_NEAREST, GPU_NEAREST);
|
|
||||||
|
|
||||||
std::memset(tex->data, 0, tex->size);
|
|
||||||
|
|
||||||
for (u32 x = 0; x < subtex->width; x++) {
|
|
||||||
for (u32 y = 0; y < subtex->height; y++) {
|
|
||||||
u32 dst_pos = ((((y >> 3) * (w_pow2 >> 3) + (x >> 3)) << 6) +
|
|
||||||
((x & 1) | ((y & 1) << 1) | ((x & 2) << 1) |
|
|
||||||
((y & 2) << 2) | ((x & 4) << 2) | ((y & 4) << 3))) *
|
|
||||||
4;
|
|
||||||
u32 src_pos = (y * subtex->width + x) * 4;
|
|
||||||
std::memcpy(&(static_cast<u8 *>(tex->data))[dst_pos],
|
|
||||||
&(static_cast<u8 *>(buf))[src_pos], 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
C3D_TexFlush(tex);
|
|
||||||
tex->border = RenderD7::Color::Hex("#000000", 0);
|
|
||||||
C3D_TexSetWrap(tex, GPU_CLAMP_TO_BORDER, GPU_CLAMP_TO_BORDER);
|
|
||||||
if (tex && subtex) {
|
|
||||||
texture->tex = tex;
|
|
||||||
texture->subtex = subtex;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OLD_C3DTexToC2DImage(C3D_Tex *tex, Tex3DS_SubTexture *subtex,
|
static void __rd7i_c3dc2d__(C3D_Tex *tex, Tex3DS_SubTexture *subtex, u8 *buf,
|
||||||
u8 *buf, u32 size, u32 width, u32 height,
|
u32 size, u32 width, u32 height) {
|
||||||
GPU_TEXCOLOR format) {
|
|
||||||
// RGBA -> ABGR
|
// RGBA -> ABGR
|
||||||
for (u32 row = 0; row < width; row++) {
|
for (u32 row = 0; row < width; row++) {
|
||||||
for (u32 col = 0; col < height; col++) {
|
for (u32 col = 0; col < height; col++) {
|
||||||
@ -109,8 +49,8 @@ static void OLD_C3DTexToC2DImage(C3D_Tex *tex, Tex3DS_SubTexture *subtex,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 w_pow2 = GetNextPowerOf2(width);
|
u32 w_pow2 = __rd7i_gp2o__(width);
|
||||||
u32 h_pow2 = GetNextPowerOf2(height);
|
u32 h_pow2 = __rd7i_gp2o__(height);
|
||||||
|
|
||||||
subtex->width = (u16)width;
|
subtex->width = (u16)width;
|
||||||
subtex->height = (u16)height;
|
subtex->height = (u16)height;
|
||||||
@ -119,7 +59,7 @@ static void OLD_C3DTexToC2DImage(C3D_Tex *tex, Tex3DS_SubTexture *subtex,
|
|||||||
subtex->right = (width / (float)w_pow2);
|
subtex->right = (width / (float)w_pow2);
|
||||||
subtex->bottom = 1.0 - (height / (float)h_pow2);
|
subtex->bottom = 1.0 - (height / (float)h_pow2);
|
||||||
|
|
||||||
C3D_TexInit(tex, (u16)w_pow2, (u16)h_pow2, format);
|
C3D_TexInit(tex, (u16)w_pow2, (u16)h_pow2, GPU_RGBA8);
|
||||||
C3D_TexSetFilter(tex, GPU_NEAREST, GPU_NEAREST);
|
C3D_TexSetFilter(tex, GPU_NEAREST, GPU_NEAREST);
|
||||||
|
|
||||||
u32 pixel_size = (size / width / height);
|
u32 pixel_size = (size / width / height);
|
||||||
@ -142,197 +82,87 @@ static void OLD_C3DTexToC2DImage(C3D_Tex *tex, Tex3DS_SubTexture *subtex,
|
|||||||
|
|
||||||
tex->border = 0x00000000;
|
tex->border = 0x00000000;
|
||||||
C3D_TexSetWrap(tex, GPU_CLAMP_TO_BORDER, GPU_CLAMP_TO_BORDER);
|
C3D_TexSetWrap(tex, GPU_CLAMP_TO_BORDER, GPU_CLAMP_TO_BORDER);
|
||||||
linearFree(buf);
|
// linearFree(buf);
|
||||||
}
|
|
||||||
|
|
||||||
bool IMG_LoadImageFile(C2D_Image *texture, const char *path) {
|
|
||||||
stbi_uc *image = NULL;
|
|
||||||
int width = 0, height = 0;
|
|
||||||
int nc;
|
|
||||||
|
|
||||||
image = stbi_load(path, &width, &height, &nc, 4);
|
|
||||||
|
|
||||||
if (width > 1024 || height > 1024) {
|
|
||||||
stbi_image_free(image);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
C3D_Tex *tex = new C3D_Tex;
|
|
||||||
Tex3DS_SubTexture *subtex = new Tex3DS_SubTexture;
|
|
||||||
OLD_C3DTexToC2DImage(tex, subtex, image, (u32)(width * height * 4),
|
|
||||||
(u32)width, (u32)height, GPU_RGBA8);
|
|
||||||
texture->tex = tex;
|
|
||||||
texture->subtex = subtex;
|
|
||||||
stbi_image_free(image);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
loadet = false;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
RenderD7::Image::~Image() {
|
|
||||||
if (loadet)
|
|
||||||
C3D_TexDelete(img.tex);
|
|
||||||
loadet = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::Image::Unload() {
|
|
||||||
if (loadet)
|
|
||||||
C3D_TexDelete(img.tex);
|
|
||||||
loadet = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::Image::LoadPFromBuffer(const std::vector<u8> &buffer) {
|
|
||||||
std::vector<u8> ImageBuffer;
|
|
||||||
if (loadet) {
|
|
||||||
C3D_TexDelete(this->img.tex);
|
|
||||||
loadet = false;
|
|
||||||
}
|
|
||||||
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];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::Image::FromSheet(RenderD7::Sheet sheet, size_t index) {}
|
|
||||||
|
|
||||||
bool RenderD7::Image::Draw(float x, float y, float scaleX, float scaleY) {
|
|
||||||
if (loadet)
|
|
||||||
return C2D_DrawImageAt(this->img, x, y, 0.5f, nullptr, scaleX, scaleY);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderD7::Image::LoadFromBitmap(BMP bitmap) {
|
|
||||||
loadet = false;
|
|
||||||
unsigned error =
|
|
||||||
C3DTexToC2DImage(&this->img, bitmap.bmp_info_header.width,
|
|
||||||
bitmap.bmp_info_header.height, bitmap.data.data());
|
|
||||||
if (error == 0) {
|
|
||||||
this->loadet = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error) {
|
|
||||||
std::cout << "BMP decoding error " << error << std::endl;
|
|
||||||
RenderD7::PushMessage(
|
|
||||||
RenderD7::Message("Bmp - Error", "Code: " + std::to_string(error)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
void Image::LoadJpg(std::string path) {
|
Image::Image() {
|
||||||
if (usedbgmsg) {
|
img.tex = nullptr;
|
||||||
// RenderD7::Msg::Display("RenderD7", "Loading Png:" + path, Top);
|
img.subtex = nullptr;
|
||||||
}
|
|
||||||
if (loadet) {
|
|
||||||
C3D_TexDelete(this->img.tex);
|
|
||||||
loadet = false;
|
|
||||||
}
|
|
||||||
IMG_LoadImageFile(&this->img, path.c_str());
|
|
||||||
loadet = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image::LoadPixels(int w, int h, int bpp, void *buffer) {
|
Image::~Image() { safe_del(); }
|
||||||
if (loadet) {
|
|
||||||
C3D_TexDelete(this->img.tex);
|
void Image::load(const std::string &path) {
|
||||||
loadet = false;
|
// Make sure to cleanup
|
||||||
|
safe_del();
|
||||||
|
ld = false;
|
||||||
|
// Setup Func and Load Data
|
||||||
|
int w, h, c = 0;
|
||||||
|
uint8_t *image = stbi_load(path.c_str(), &w, &h, &c, 4);
|
||||||
|
if (image == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Size/Fmt Check
|
||||||
|
if (w > 1024 || h > 1024) {
|
||||||
|
// Reason: Image to Large
|
||||||
|
stbi_image_free(image);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
unsigned width, height;
|
|
||||||
width = w;
|
|
||||||
height = h;
|
|
||||||
uint8_t *ImageBuffer = new uint8_t[w * h * 4];
|
|
||||||
|
|
||||||
if (bpp == 3)
|
std::vector<uint8_t> wimg(w * h * 4);
|
||||||
convert24to32((uint8_t *)buffer, width, height, ImageBuffer);
|
if (c == 3) {
|
||||||
|
stbi_image_free(image);
|
||||||
img.tex = new C3D_Tex;
|
image = stbi_load(path.c_str(), &w, &h, &c, 3);
|
||||||
img.subtex =
|
__rd7i_r24r32(wimg, std::vector<uint8_t>(image, image + (w * h * 3)), w, h);
|
||||||
new Tex3DS_SubTexture({(u16)width, (u16)height, 0.0f, 1.0f,
|
} else {
|
||||||
width / 512.0f, 1.0f - (height / 512.0f)});
|
// Maybe find a better solution later
|
||||||
|
for (size_t i = 0; i < wimg.size(); i++) {
|
||||||
C3D_TexInit(img.tex, 512, 512, GPU_RGBA8);
|
wimg[i] = image[i];
|
||||||
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[srcPos + 3];
|
|
||||||
((uint8_t *)img.tex->data)[dstPos + 1] = ImageBuffer[srcPos + 2];
|
|
||||||
((uint8_t *)img.tex->data)[dstPos + 2] = ImageBuffer[srcPos + 1];
|
|
||||||
((uint8_t *)img.tex->data)[dstPos + 3] = ImageBuffer[srcPos + 0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete[] ImageBuffer;
|
stbi_image_free(image);
|
||||||
loadet = true;
|
// Create C2D_Image
|
||||||
|
C3D_Tex *tex = new C3D_Tex;
|
||||||
|
Tex3DS_SubTexture *subtex = new Tex3DS_SubTexture;
|
||||||
|
__rd7i_c3dc2d__(tex, subtex, wimg.data(), (u32)(w * h * 4), (u32)w, (u32)h);
|
||||||
|
img.tex = tex;
|
||||||
|
img.subtex = subtex;
|
||||||
|
ld = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Image::from_nimg(const nimg &image) {
|
||||||
|
// Make sure to cleanup
|
||||||
|
safe_del();
|
||||||
|
ld = false;
|
||||||
|
if (image.width > 1024 || image.height > 1024) return;
|
||||||
|
C3D_Tex *tex = new C3D_Tex;
|
||||||
|
Tex3DS_SubTexture *subtex = new Tex3DS_SubTexture;
|
||||||
|
__rd7i_c3dc2d__(tex, subtex, (u8 *)image.pixel_buffer.data(),
|
||||||
|
(u32)image.pixel_buffer.size(), (u32)image.width,
|
||||||
|
(u32)image.height);
|
||||||
|
img.tex = tex;
|
||||||
|
img.subtex = subtex;
|
||||||
|
ld = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
C2D_Image Image::get() { return img; }
|
||||||
|
C2D_Image &Image::get_ref() { return img; }
|
||||||
|
|
||||||
|
void Image::set(const C2D_Image &i) {
|
||||||
|
safe_del();
|
||||||
|
img = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
R7Vec2 Image::get_size() {
|
||||||
|
if (!img.subtex) return R7Vec2(0, 0);
|
||||||
|
return R7Vec2(img.subtex->width, img.subtex->height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Image::safe_del() {
|
||||||
|
if (img.subtex != nullptr) delete img.subtex;
|
||||||
|
if (img.tex != nullptr) delete img.tex;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Image::loaded() { return ld; }
|
||||||
} // namespace RenderD7
|
} // namespace RenderD7
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <cstdlib>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <renderd7/Memory.hpp>
|
#include <renderd7/Memory.hpp>
|
||||||
|
|
||||||
@ -5,16 +6,15 @@ static RenderD7::Memory::memory_metrics metrics;
|
|||||||
|
|
||||||
bool rd7_enable_memtrack;
|
bool rd7_enable_memtrack;
|
||||||
|
|
||||||
|
#ifdef RENDERD7_MEMTRACK
|
||||||
void *operator new(size_t size) {
|
void *operator new(size_t size) {
|
||||||
void *ptr = malloc(size);
|
void *ptr = malloc(size);
|
||||||
if (rd7_enable_memtrack)
|
if (rd7_enable_memtrack) metrics.t_TotalAllocated += size;
|
||||||
metrics.t_TotalAllocated += size;
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator delete(void *memory, size_t size) {
|
void operator delete(void *memory, size_t size) {
|
||||||
if (rd7_enable_memtrack)
|
if (rd7_enable_memtrack) metrics.t_TotalFreed += size;
|
||||||
metrics.t_TotalFreed += size;
|
|
||||||
free(memory);
|
free(memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,30 +23,24 @@ int total_size = 0;
|
|||||||
std::map<void *, size_t> sizes;
|
std::map<void *, size_t> sizes;
|
||||||
|
|
||||||
void *operator new[](size_t size) {
|
void *operator new[](size_t size) {
|
||||||
if (rd7_enable_memtrack)
|
if (rd7_enable_memtrack) allocations++;
|
||||||
allocations++;
|
if (rd7_enable_memtrack) total_size += size;
|
||||||
if (rd7_enable_memtrack)
|
|
||||||
total_size += size;
|
|
||||||
void *ptr = malloc(size);
|
void *ptr = malloc(size);
|
||||||
if (rd7_enable_memtrack)
|
if (rd7_enable_memtrack) sizes[ptr] = size;
|
||||||
sizes[ptr] = size;
|
if (rd7_enable_memtrack) metrics.t_TotalAllocated += size;
|
||||||
if (rd7_enable_memtrack)
|
|
||||||
metrics.t_TotalAllocated += size;
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator delete[](void *ptr) {
|
void operator delete[](void *ptr) {
|
||||||
if (rd7_enable_memtrack)
|
if (rd7_enable_memtrack) allocations--;
|
||||||
allocations--;
|
if (rd7_enable_memtrack) total_size -= sizes[ptr];
|
||||||
if (rd7_enable_memtrack)
|
if (rd7_enable_memtrack) metrics.t_TotalFreed += sizes[ptr];
|
||||||
total_size -= sizes[ptr];
|
if (rd7_enable_memtrack) sizes.erase(ptr);
|
||||||
if (rd7_enable_memtrack)
|
|
||||||
metrics.t_TotalFreed += sizes[ptr];
|
|
||||||
if (rd7_enable_memtrack)
|
|
||||||
sizes.erase(ptr);
|
|
||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
|
|
||||||
namespace Memory {
|
namespace Memory {
|
||||||
|
98
source/Message.cpp
Normal file
98
source/Message.cpp
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <memory>
|
||||||
|
#include <renderd7/Color.hpp>
|
||||||
|
#include <renderd7/DrawV2.hpp> // Update to Draw2
|
||||||
|
#include <renderd7/Message.hpp>
|
||||||
|
#include <renderd7/Screen.hpp>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
extern bool rd7_debugging;
|
||||||
|
|
||||||
|
static std::vector<std::shared_ptr<RenderD7::Message>> msg_lst;
|
||||||
|
static int fade_outs = 200; // Start of fadeout
|
||||||
|
static int idles = 60; // start of Idle
|
||||||
|
static int anim_len = 300; // Full Length of Animation
|
||||||
|
|
||||||
|
R7Vec2 MakePos(int frame, int entry) {
|
||||||
|
float fol = anim_len - fade_outs;
|
||||||
|
if (frame > fade_outs)
|
||||||
|
return R7Vec2(5, 240 - ((entry + 1) * 55) - 5 +
|
||||||
|
(float)((frame - fade_outs) / fol) * -20);
|
||||||
|
if (frame > idles) return R7Vec2(5, 240 - ((entry + 1) * 55) - 5);
|
||||||
|
return R7Vec2(-150 + ((float)(frame / (float)idles) * 155),
|
||||||
|
240 - ((entry + 1) * 55) - 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
float GetDeltaTime(); // Extern from renderd7.cpp
|
||||||
|
|
||||||
|
void ProcessMessages() {
|
||||||
|
// Draw in ovl mode
|
||||||
|
RenderD7::OnScreen(Top);
|
||||||
|
float fol = anim_len - fade_outs;
|
||||||
|
std::reverse(msg_lst.begin(), msg_lst.end());
|
||||||
|
for (size_t i = 0; i < msg_lst.size(); i++) {
|
||||||
|
R7Vec2 pos = MakePos(msg_lst[i]->animationframe, i);
|
||||||
|
if ((pos.y + 150) < 0) {
|
||||||
|
// Dont Render Out of Screen
|
||||||
|
// And as thay aren't relevant anymore
|
||||||
|
// Thay get deleted!
|
||||||
|
msg_lst.erase(msg_lst.begin() + i);
|
||||||
|
} else {
|
||||||
|
int new_alpha = 200;
|
||||||
|
if (msg_lst[i]->animationframe > fade_outs) {
|
||||||
|
new_alpha =
|
||||||
|
200 - (float(msg_lst[i]->animationframe - fade_outs) / fol) * 200;
|
||||||
|
}
|
||||||
|
// Wtf is this function lol
|
||||||
|
RenderD7::CustomizeColor(RD7Color_MessageBackground,
|
||||||
|
RenderD7::Color::RGBA(RD7Color_MessageBackground)
|
||||||
|
.changeA(new_alpha)
|
||||||
|
.toRGBA());
|
||||||
|
RenderD7::CustomizeColor(
|
||||||
|
RD7Color_Text,
|
||||||
|
RenderD7::Color::RGBA(RD7Color_Text2).changeA(new_alpha).toRGBA());
|
||||||
|
RenderD7::Draw2::RFS(pos, R7Vec2(150, 50),
|
||||||
|
RenderD7::StyleColor(RD7Color_MessageBackground));
|
||||||
|
RenderD7::Draw2::Text(pos + R7Vec2(5, 1), msg_lst[i]->title);
|
||||||
|
RenderD7::Draw2::Text(pos + R7Vec2(5, 17), msg_lst[i]->message);
|
||||||
|
if (rd7_debugging)
|
||||||
|
RenderD7::Draw2::Text(pos + R7Vec2(155, 1),
|
||||||
|
std::to_string(msg_lst[i]->animationframe));
|
||||||
|
RenderD7::UndoColorEdit(RD7Color_Text);
|
||||||
|
RenderD7::UndoColorEdit(RD7Color_MessageBackground);
|
||||||
|
// Why Frameadd? because Message uses int as frame and
|
||||||
|
// It seems that lower 0.5 will be rounded to 0
|
||||||
|
// Why not replace int with float ?
|
||||||
|
// cause of buggy positions (seen in Flappy Bird 3ds for example)
|
||||||
|
float frameadd = 60.f * RenderD7::GetDeltaTime();
|
||||||
|
// 60fps animation * delta to not slowdown
|
||||||
|
// Oh and fix for Startup lol
|
||||||
|
// Todo: Only do this on AppStart
|
||||||
|
if (msg_lst[i]->animationframe == 0) {
|
||||||
|
msg_lst[i]->animationframe += 1;
|
||||||
|
} else {
|
||||||
|
msg_lst[i]->animationframe += (frameadd < 1.f ? 1.f : frameadd);
|
||||||
|
}
|
||||||
|
if (msg_lst[i]->animationframe > anim_len) {
|
||||||
|
msg_lst.erase(msg_lst.begin() + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ReReverse ?? lol
|
||||||
|
// Cause otherwise the Toasts will swap
|
||||||
|
std::reverse(msg_lst.begin(), msg_lst.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
void PushMessage(const Message &msg) {
|
||||||
|
msg_lst.push_back(std::make_shared<RenderD7::Message>(msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetMessageIdleStartFrame(int frame) { idles = frame; }
|
||||||
|
|
||||||
|
void SetMessageTotalAnimationFrames(int total_frames) {
|
||||||
|
anim_len = total_frames;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetMessageFadeOutStartFrame(int frame) { fade_outs = frame; }
|
||||||
|
} // namespace RenderD7
|
@ -1,71 +0,0 @@
|
|||||||
#include <renderd7/Fonts/NFontApi.hpp>
|
|
||||||
#define STB_TRUETYPE_IMPLEMENTATION // force following include to generate
|
|
||||||
// implementation
|
|
||||||
#include <renderd7/external/stb_truetype.h>
|
|
||||||
|
|
||||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
|
||||||
#include <renderd7/external/stb_image_write.h>
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
RenderD7::NFontApi::NFontApi() {}
|
|
||||||
|
|
||||||
RenderD7::NFontApi::~NFontApi() {}
|
|
||||||
|
|
||||||
void RenderD7::NFontApi::LoadTTF(std::string path) {
|
|
||||||
/////READ FILE
|
|
||||||
unsigned char *buffer;
|
|
||||||
long size = 0;
|
|
||||||
std::fstream ttf__(path, std::ios::in | std::ios::binary);
|
|
||||||
if(!ttf__.is_open()) {
|
|
||||||
return; // Add Error Handler in future
|
|
||||||
}
|
|
||||||
ttf__.seekg(0, std::ios::end);
|
|
||||||
size = ttf__.tellg();
|
|
||||||
ttf__.seekg(0, std::ios::beg);
|
|
||||||
buffer = (unsigned char *)malloc(size);
|
|
||||||
ttf__.read(reinterpret_cast<char*>(buffer), size);
|
|
||||||
ttf__.close();
|
|
||||||
/////Setup Font
|
|
||||||
if (!stbtt_InitFont(&font, buffer, 0)) {
|
|
||||||
printf("failed\n");
|
|
||||||
status += "failed\n";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
status += "success!\n";
|
|
||||||
b_h = 128;
|
|
||||||
b_w = 512;
|
|
||||||
l_h = 24; /* line height */
|
|
||||||
scale = stbtt_ScaleForPixelHeight(&font, l_h);
|
|
||||||
|
|
||||||
stbtt_GetFontVMetrics(&font, &ascent, &decent, &linegap);
|
|
||||||
linespace = scale * (ascent - decent + linegap);
|
|
||||||
|
|
||||||
baseline = (int)(ascent * scale);
|
|
||||||
height = (int)((ascent - decent) * scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char *RenderD7::NFontApi::GetGlyphBitmap(char glyph) {
|
|
||||||
// stbtt_GetGlyphBitmapBox(&font, glyph, scale, scale, &x0, &y0, &x1, &y1);
|
|
||||||
stbtt_GetCodepointBitmapBox(&font, glyph, scale, scale, &x0, &y0, &x1, &y1);
|
|
||||||
w = x1 - x0;
|
|
||||||
h = y1 - y0;
|
|
||||||
|
|
||||||
unsigned char *bitmap;
|
|
||||||
bitmap = stbtt_GetCodepointBitmap(&font, scale, scale, glyph, &w, &h, 0, 0);
|
|
||||||
return bitmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
int RenderD7::NFontApi::GetGlyphHeight(char glyph) {
|
|
||||||
stbtt_GetCodepointBitmapBox(&font, glyph, scale, scale, &x0, &y0, &x1, &y1);
|
|
||||||
w = x1 - x0;
|
|
||||||
h = y1 - y0;
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
|
|
||||||
int RenderD7::NFontApi::GetGlyphWidth(char glyph) {
|
|
||||||
stbtt_GetCodepointBitmapBox(&font, glyph, scale, scale, &x0, &y0, &x1, &y1);
|
|
||||||
w = x1 - x0;
|
|
||||||
h = y1 - y0;
|
|
||||||
return w;
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
#include <renderd7/FunctionTrace.hpp>
|
|
||||||
#include <renderd7/Ovarlays.hpp>
|
|
||||||
#include <renderd7/renderd7.hpp>
|
|
||||||
|
|
||||||
namespace RenderD7 {
|
|
||||||
Ovl_Ftrace::Ovl_Ftrace() {}
|
|
||||||
|
|
||||||
void Ovl_Ftrace::Draw(void) const { RenderD7::OnScreen(Top); }
|
|
||||||
|
|
||||||
void Ovl_Ftrace::Logic() {}
|
|
||||||
} // namespace RenderD7
|
|
448
source/Overlays.cpp
Normal file
448
source/Overlays.cpp
Normal file
@ -0,0 +1,448 @@
|
|||||||
|
#include <renderd7/DrawV2.hpp>
|
||||||
|
#include <renderd7/FunctionTrace.hpp>
|
||||||
|
#include <renderd7/Hid.hpp>
|
||||||
|
#include <renderd7/Overlays.hpp>
|
||||||
|
#include <renderd7/internal_db.hpp>
|
||||||
|
#include <renderd7/renderd7.hpp>
|
||||||
|
|
||||||
|
///////////////////////////////
|
||||||
|
struct Key {
|
||||||
|
std::string disp;
|
||||||
|
R7Vec2 pos;
|
||||||
|
R7Vec2 size;
|
||||||
|
// 0 = default key
|
||||||
|
// 1 = Shift
|
||||||
|
// 2 = Backsp
|
||||||
|
// 3 = Enter
|
||||||
|
// 4 = Cancel
|
||||||
|
// 5 = Confirm
|
||||||
|
// 6 = Tab
|
||||||
|
// 7 = Caps
|
||||||
|
// 8 = Space
|
||||||
|
int action = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<Key> keyboard_layout = {
|
||||||
|
// 1st row
|
||||||
|
{"`", R7Vec2(5, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"1", R7Vec2(25, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"2", R7Vec2(45, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"3", R7Vec2(65, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"4", R7Vec2(85, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"5", R7Vec2(105, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"6", R7Vec2(125, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"7", R7Vec2(145, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"8", R7Vec2(165, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"9", R7Vec2(185, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"0", R7Vec2(205, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"-", R7Vec2(225, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"=", R7Vec2(245, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"Bksp", R7Vec2(265, 137), R7Vec2(50, 18), 2},
|
||||||
|
// 2nd row
|
||||||
|
{"Tab", R7Vec2(5, 157), R7Vec2(40, 18), 6},
|
||||||
|
{"q", R7Vec2(47, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"w", R7Vec2(67, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"e", R7Vec2(87, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"r", R7Vec2(107, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"t", R7Vec2(127, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"y", R7Vec2(147, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"u", R7Vec2(167, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"i", R7Vec2(187, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"o", R7Vec2(207, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"p", R7Vec2(227, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"[", R7Vec2(247, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"]", R7Vec2(267, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"\\", R7Vec2(287, 157), R7Vec2(28, 18), 0},
|
||||||
|
// 3rd row
|
||||||
|
{"Caps", R7Vec2(5, 177), R7Vec2(50, 18), 7},
|
||||||
|
{"a", R7Vec2(57, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"s", R7Vec2(77, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"d", R7Vec2(97, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"f", R7Vec2(117, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"g", R7Vec2(137, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"h", R7Vec2(157, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"j", R7Vec2(177, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"k", R7Vec2(197, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"l", R7Vec2(217, 177), R7Vec2(18, 18), 0},
|
||||||
|
{";", R7Vec2(237, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"'", R7Vec2(257, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"Enter", R7Vec2(277, 177), R7Vec2(38, 18), 3},
|
||||||
|
// 4th row
|
||||||
|
{"Shift", R7Vec2(5, 197), R7Vec2(60, 18), 1},
|
||||||
|
{"z", R7Vec2(67, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"x", R7Vec2(87, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"c", R7Vec2(107, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"v", R7Vec2(127, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"b", R7Vec2(147, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"n", R7Vec2(167, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"m", R7Vec2(187, 197), R7Vec2(18, 18), 0},
|
||||||
|
{",", R7Vec2(207, 197), R7Vec2(18, 18), 0},
|
||||||
|
{".", R7Vec2(227, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"/", R7Vec2(247, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"Shift", R7Vec2(267, 197), R7Vec2(48, 18), 1},
|
||||||
|
// 5th row
|
||||||
|
{"Cancel", R7Vec2(5, 217), R7Vec2(70, 18), 4},
|
||||||
|
{"(X)", R7Vec2(77, 217), R7Vec2(23, 18), 10},
|
||||||
|
{"Space", R7Vec2(102, 217), R7Vec2(108, 18), 8},
|
||||||
|
{"(!)", R7Vec2(212, 217), R7Vec2(23, 18), 10},
|
||||||
|
{"Confirm", R7Vec2(237, 217), R7Vec2(78, 18), 5},
|
||||||
|
/*{"←", R7Vec2(237, 217), R7Vec2(18, 18)},
|
||||||
|
{"→", R7Vec2(257, 217), R7Vec2(18, 18)},
|
||||||
|
{"↓", R7Vec2(277, 217), R7Vec2(18, 18)},
|
||||||
|
{"↑", R7Vec2(297, 217), R7Vec2(18, 18)},*/
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<Key> keyboard_layout_caps = {
|
||||||
|
// 1st row
|
||||||
|
{"`", R7Vec2(5, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"1", R7Vec2(25, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"2", R7Vec2(45, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"3", R7Vec2(65, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"4", R7Vec2(85, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"5", R7Vec2(105, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"6", R7Vec2(125, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"7", R7Vec2(145, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"8", R7Vec2(165, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"9", R7Vec2(185, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"0", R7Vec2(205, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"-", R7Vec2(225, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"=", R7Vec2(245, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"Bksp", R7Vec2(265, 137), R7Vec2(50, 18), 2},
|
||||||
|
// 2nd row
|
||||||
|
{"Tab", R7Vec2(5, 157), R7Vec2(40, 18), 6},
|
||||||
|
{"Q", R7Vec2(47, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"W", R7Vec2(67, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"E", R7Vec2(87, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"R", R7Vec2(107, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"T", R7Vec2(127, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"Y", R7Vec2(147, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"U", R7Vec2(167, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"I", R7Vec2(187, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"O", R7Vec2(207, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"P", R7Vec2(227, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"[", R7Vec2(247, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"]", R7Vec2(267, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"\\", R7Vec2(287, 157), R7Vec2(28, 18), 0},
|
||||||
|
// 3rd row
|
||||||
|
{"Caps", R7Vec2(5, 177), R7Vec2(50, 18), 7},
|
||||||
|
{"A", R7Vec2(57, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"S", R7Vec2(77, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"D", R7Vec2(97, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"F", R7Vec2(117, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"G", R7Vec2(137, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"H", R7Vec2(157, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"J", R7Vec2(177, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"K", R7Vec2(197, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"L", R7Vec2(217, 177), R7Vec2(18, 18), 0},
|
||||||
|
{";", R7Vec2(237, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"'", R7Vec2(257, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"Enter", R7Vec2(277, 177), R7Vec2(38, 18), 3},
|
||||||
|
// 4th row
|
||||||
|
{"Shift", R7Vec2(5, 197), R7Vec2(60, 18), 1},
|
||||||
|
{"Z", R7Vec2(67, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"X", R7Vec2(87, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"C", R7Vec2(107, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"V", R7Vec2(127, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"B", R7Vec2(147, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"N", R7Vec2(167, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"M", R7Vec2(187, 197), R7Vec2(18, 18), 0},
|
||||||
|
{",", R7Vec2(207, 197), R7Vec2(18, 18), 0},
|
||||||
|
{".", R7Vec2(227, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"/", R7Vec2(247, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"Shift", R7Vec2(267, 197), R7Vec2(48, 18), 1},
|
||||||
|
// 5th row
|
||||||
|
{"Cancel", R7Vec2(5, 217), R7Vec2(70, 18), 4},
|
||||||
|
{"(X)", R7Vec2(77, 217), R7Vec2(23, 18), 10},
|
||||||
|
{"Space", R7Vec2(102, 217), R7Vec2(108, 18), 8},
|
||||||
|
{"(!)", R7Vec2(212, 217), R7Vec2(23, 18), 10},
|
||||||
|
{"Confirm", R7Vec2(237, 217), R7Vec2(78, 18), 5},
|
||||||
|
/*{"←", R7Vec2(237, 217), R7Vec2(18, 18)},
|
||||||
|
{"→", R7Vec2(257, 217), R7Vec2(18, 18)},
|
||||||
|
{"↑", R7Vec2(277, 217), R7Vec2(18, 18)},
|
||||||
|
{"↓", R7Vec2(297, 217), R7Vec2(18, 18)},*/
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<Key> keyboard_layout_shift = {
|
||||||
|
// 1st row
|
||||||
|
{"~", R7Vec2(5, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"!", R7Vec2(25, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"@", R7Vec2(45, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"#", R7Vec2(65, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"$", R7Vec2(85, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"%", R7Vec2(105, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"^", R7Vec2(125, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"&", R7Vec2(145, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"*", R7Vec2(165, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"(", R7Vec2(185, 137), R7Vec2(18, 18), 0},
|
||||||
|
{")", R7Vec2(205, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"_", R7Vec2(225, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"+", R7Vec2(245, 137), R7Vec2(18, 18), 0},
|
||||||
|
{"Bksp", R7Vec2(265, 137), R7Vec2(50, 18), 2},
|
||||||
|
// 2nd row
|
||||||
|
{"Tab", R7Vec2(5, 157), R7Vec2(40, 18), 6},
|
||||||
|
{"Q", R7Vec2(47, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"W", R7Vec2(67, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"E", R7Vec2(87, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"R", R7Vec2(107, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"T", R7Vec2(127, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"Y", R7Vec2(147, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"U", R7Vec2(167, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"I", R7Vec2(187, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"O", R7Vec2(207, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"P", R7Vec2(227, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"{", R7Vec2(247, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"}", R7Vec2(267, 157), R7Vec2(18, 18), 0},
|
||||||
|
{"|", R7Vec2(287, 157), R7Vec2(28, 18), 0},
|
||||||
|
// 3rd row
|
||||||
|
{"Caps", R7Vec2(5, 177), R7Vec2(50, 18), 7},
|
||||||
|
{"A", R7Vec2(57, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"S", R7Vec2(77, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"D", R7Vec2(97, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"F", R7Vec2(117, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"G", R7Vec2(137, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"H", R7Vec2(157, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"J", R7Vec2(177, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"K", R7Vec2(197, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"L", R7Vec2(217, 177), R7Vec2(18, 18), 0},
|
||||||
|
{":", R7Vec2(237, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"\"", R7Vec2(257, 177), R7Vec2(18, 18), 0},
|
||||||
|
{"Enter", R7Vec2(277, 177), R7Vec2(38, 18), 3},
|
||||||
|
// 4th row
|
||||||
|
{"Shift", R7Vec2(5, 197), R7Vec2(60, 18), 1},
|
||||||
|
{"Z", R7Vec2(67, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"X", R7Vec2(87, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"C", R7Vec2(107, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"V", R7Vec2(127, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"B", R7Vec2(147, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"N", R7Vec2(167, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"M", R7Vec2(187, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"<", R7Vec2(207, 197), R7Vec2(18, 18), 0},
|
||||||
|
{">", R7Vec2(227, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"?", R7Vec2(247, 197), R7Vec2(18, 18), 0},
|
||||||
|
{"Shift", R7Vec2(267, 197), R7Vec2(48, 18), 1},
|
||||||
|
// 5th row
|
||||||
|
{"Cancel", R7Vec2(5, 217), R7Vec2(70, 18), 4},
|
||||||
|
{"(X)", R7Vec2(77, 217), R7Vec2(23, 18), 10},
|
||||||
|
{"Space", R7Vec2(102, 217), R7Vec2(108, 18), 8},
|
||||||
|
{"(!)", R7Vec2(212, 217), R7Vec2(23, 18), 10},
|
||||||
|
{"Confirm", R7Vec2(237, 217), R7Vec2(78, 18), 5},
|
||||||
|
/*{"←", R7Vec2(237, 217), R7Vec2(18, 18)},
|
||||||
|
{"→", R7Vec2(257, 217), R7Vec2(18, 18)},
|
||||||
|
{"↑", R7Vec2(277, 217), R7Vec2(18, 18)},
|
||||||
|
{"↓", R7Vec2(297, 217), R7Vec2(18, 18)},*/
|
||||||
|
};
|
||||||
|
|
||||||
|
// From UI7
|
||||||
|
bool UI7_InBox(R7Vec2 inpos, R7Vec2 boxpos, R7Vec2 boxsize) {
|
||||||
|
if ((inpos.x > boxpos.x) && (inpos.y > boxpos.y) &&
|
||||||
|
(inpos.x < boxpos.x + boxsize.x) && (inpos.y < boxpos.y + boxsize.y))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
Ovl_Ftrace::Ovl_Ftrace(bool* is_enabled) { i_is_enabled = is_enabled; }
|
||||||
|
|
||||||
|
void Ovl_Ftrace::Draw(void) const {
|
||||||
|
RenderD7::OnScreen(Top);
|
||||||
|
RenderD7::Draw2::RFS(R7Vec2(0, 0), R7Vec2(400, 20),
|
||||||
|
RenderD7::StyleColor(RD7Color_Background));
|
||||||
|
|
||||||
|
std::vector<RenderD7::Ftrace::FTRes> dt;
|
||||||
|
for (auto const& it : RenderD7::Ftrace::rd7_traces)
|
||||||
|
if (it.second.is_ovl && dt.size() < 10) dt.push_back(it.second);
|
||||||
|
for (size_t i = 0; i < (dt.size() < 10 ? dt.size() : 10); i++) {
|
||||||
|
RenderD7::Draw2::Text(R7Vec2(5, 30 + i * 15), dt[i].func_name);
|
||||||
|
RenderD7::Draw2::Text(R7Vec2(295, 30 + i * 15),
|
||||||
|
RenderD7::MsTimeFmt(dt[i].time_of));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ovl_Ftrace::Logic() {
|
||||||
|
if (!i_is_enabled[0]) this->Kill();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ovl_Metrik::Ovl_Metrik(bool* is_enabled, bool* screen, uint32_t* mt_color,
|
||||||
|
uint32_t* txt_color, float* txt_size) {
|
||||||
|
i_is_enabled = is_enabled;
|
||||||
|
i_screen = screen;
|
||||||
|
i_mt_color = mt_color;
|
||||||
|
i_txt_color = txt_color;
|
||||||
|
i_txt_size = txt_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ovl_Metrik::Draw(void) const {
|
||||||
|
if (i_screen[0]) {
|
||||||
|
RenderD7::OnScreen(Bottom);
|
||||||
|
} else {
|
||||||
|
RenderD7::OnScreen(Top);
|
||||||
|
}
|
||||||
|
std::string info =
|
||||||
|
"RenderD7 " + std::string(RENDERD7VSTRING) + " Debug Overlay";
|
||||||
|
float dim_y = RenderD7::GetTextDimensions(info).y;
|
||||||
|
float infoy = 240 - dim_y;
|
||||||
|
mt_fps = "FPS: " + RenderD7::GetFramerate();
|
||||||
|
if (rd7i_idb_running) mt_fps += " IDB -> ON";
|
||||||
|
mt_cpu = "CPU: " +
|
||||||
|
std::to_string(C3D_GetProcessingTime() * (RenderD7::GetFps() / 10))
|
||||||
|
.substr(0, 4) +
|
||||||
|
"%/" + std::to_string(C3D_GetProcessingTime()).substr(0, 4) + "ms";
|
||||||
|
mt_gpu = "GPU: " +
|
||||||
|
std::to_string(C3D_GetDrawingTime() * (RenderD7::GetFps() / 10))
|
||||||
|
.substr(0, 4) +
|
||||||
|
"%/" + std::to_string(C3D_GetDrawingTime()).substr(0, 4) + "ms";
|
||||||
|
mt_cmd =
|
||||||
|
"CMD: " + std::to_string(C3D_GetCmdBufUsage() * 100.0f).substr(0, 4) +
|
||||||
|
"%";
|
||||||
|
mt_lfr = "Linear: " + RenderD7::FormatBytes(linearSpaceFree());
|
||||||
|
mt_tbs =
|
||||||
|
"TextBuf: " + std::to_string(C2D_TextBufGetNumGlyphs(rd7i_text_buffer)) +
|
||||||
|
"/4096";
|
||||||
|
RenderD7::Draw2::RFS(R7Vec2(0, 0), RenderD7::GetTextDimensions(mt_fps),
|
||||||
|
i_mt_color[0]);
|
||||||
|
RenderD7::Draw2::RFS(R7Vec2(0, 50), RenderD7::GetTextDimensions(mt_cpu),
|
||||||
|
i_mt_color[0]);
|
||||||
|
RenderD7::Draw2::RFS(R7Vec2(0, 50 + dim_y * 1),
|
||||||
|
RenderD7::GetTextDimensions(mt_gpu), i_mt_color[0]);
|
||||||
|
RenderD7::Draw2::RFS(R7Vec2(0, 50 + dim_y * 2),
|
||||||
|
RenderD7::GetTextDimensions(mt_cmd), i_mt_color[0]);
|
||||||
|
RenderD7::Draw2::RFS(R7Vec2(0, 50 + dim_y * 3),
|
||||||
|
RenderD7::GetTextDimensions(mt_lfr), i_mt_color[0]);
|
||||||
|
RenderD7::Draw2::RFS(R7Vec2(0, 50 + dim_y * 4),
|
||||||
|
RenderD7::GetTextDimensions(mt_tbs), i_mt_color[0]);
|
||||||
|
RenderD7::Draw2::RFS(R7Vec2(0, infoy), RenderD7::GetTextDimensions(info),
|
||||||
|
i_mt_color[0]);
|
||||||
|
RenderD7::CustomizeColor(RD7Color_Text, i_txt_color[0]);
|
||||||
|
RenderD7::Draw2::Text(R7Vec2(0, 0), mt_fps);
|
||||||
|
RenderD7::Draw2::Text(R7Vec2(0, 50), mt_cpu);
|
||||||
|
RenderD7::Draw2::Text(R7Vec2(0, 50 + dim_y * 1), mt_gpu);
|
||||||
|
RenderD7::Draw2::Text(R7Vec2(0, 50 + dim_y * 2), mt_cmd);
|
||||||
|
RenderD7::Draw2::Text(R7Vec2(0, 50 + dim_y * 3), mt_lfr);
|
||||||
|
RenderD7::Draw2::Text(R7Vec2(0, 50 + dim_y * 4), mt_tbs);
|
||||||
|
RenderD7::Draw2::Text(R7Vec2(0, infoy), info);
|
||||||
|
RenderD7::UndoColorEdit(RD7Color_Text);
|
||||||
|
|
||||||
|
// Force Bottom (Debug Touchpos)
|
||||||
|
RenderD7::OnScreen(Bottom);
|
||||||
|
if (Hid::IsEvent("touch", Hid::Held)) {
|
||||||
|
RenderD7::Draw2::Line(R7Vec2(Hid::GetTouchPosition().x, 0),
|
||||||
|
R7Vec2(Hid::GetTouchPosition().x, 240),
|
||||||
|
RenderD7::Color::Hex("#ff0000"));
|
||||||
|
RenderD7::Draw2::Line(R7Vec2(0, Hid::GetTouchPosition().y),
|
||||||
|
R7Vec2(320, Hid::GetTouchPosition().y),
|
||||||
|
RenderD7::Color::Hex("#ff0000"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ovl_Metrik::Logic() {
|
||||||
|
if (!i_is_enabled[0]) this->Kill();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ovl_Keyboard::Ovl_Keyboard(std::string& ref, const std::string& hint,
|
||||||
|
RD7Keyboard type) {
|
||||||
|
// Blocks All Input outside of Keyboard
|
||||||
|
// Doesnt work for Hidkeys down etc
|
||||||
|
RenderD7::Hid::Lock();
|
||||||
|
typed_text = &ref;
|
||||||
|
str_bak = ref;
|
||||||
|
ft3 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ovl_Keyboard::~Ovl_Keyboard() {
|
||||||
|
// And Unlock when closing Keyboard lol
|
||||||
|
RenderD7::Hid::Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ovl_Keyboard::Draw(void) const {
|
||||||
|
if (ft3 > 5) RenderD7::Hid::Unlock();
|
||||||
|
auto key_table = keyboard_layout;
|
||||||
|
if (mode == 1)
|
||||||
|
key_table = keyboard_layout_caps;
|
||||||
|
else if (mode == 2)
|
||||||
|
key_table = keyboard_layout_shift;
|
||||||
|
RenderD7::OnScreen(Top);
|
||||||
|
RenderD7::Draw2::RFS(
|
||||||
|
R7Vec2(0, 0), R7Vec2(400, 240),
|
||||||
|
RenderD7::Color::RGBA(RD7Color_FrameBg).changeA(150).toRGBA());
|
||||||
|
RenderD7::OnScreen(Bottom);
|
||||||
|
RenderD7::Draw2::RFS(
|
||||||
|
R7Vec2(0, 0), R7Vec2(320, 112),
|
||||||
|
RenderD7::Color::RGBA(RD7Color_FrameBg).changeA(150).toRGBA());
|
||||||
|
RenderD7::Draw2::RFS(R7Vec2(0, 112), R7Vec2(320, 128),
|
||||||
|
RenderD7::StyleColor(RD7Color_FrameBg));
|
||||||
|
RenderD7::Draw2::RFS(R7Vec2(0, 112), R7Vec2(320, 20),
|
||||||
|
RenderD7::StyleColor(RD7Color_Header));
|
||||||
|
RenderD7::TextColorByBg(RD7Color_Header);
|
||||||
|
RenderD7::Draw2::Text(R7Vec2(5, 114), "> " + *typed_text);
|
||||||
|
RenderD7::UndoColorEdit(RD7Color_Text);
|
||||||
|
for (auto const& it : key_table) {
|
||||||
|
R7Vec2 txtdim = RenderD7::GetTextDimensions(it.disp);
|
||||||
|
R7Vec2 txtpos = R7Vec2(it.pos.x + it.size.x * 0.5 - txtdim.x * 0.5,
|
||||||
|
it.pos.y + it.size.y * 0.5 - txtdim.y * 0.5);
|
||||||
|
RD7Color btn = RD7Color_Button;
|
||||||
|
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up) &&
|
||||||
|
UI7_InBox(RenderD7::Hid::GetLastTouchPosition(), it.pos, it.size)) {
|
||||||
|
if (mode == 2) // Request Disable Shift
|
||||||
|
shared_data[0x02] = 1;
|
||||||
|
|
||||||
|
if (it.action == 0)
|
||||||
|
shared_data[0x01] = it.disp[0];
|
||||||
|
else if (it.action == 1)
|
||||||
|
shared_data[0x02] = 1;
|
||||||
|
else if (it.action == 2)
|
||||||
|
shared_data[0x03] = 1;
|
||||||
|
else if (it.action == 3)
|
||||||
|
shared_data[0x04] = 1;
|
||||||
|
else if (it.action == 4)
|
||||||
|
shared_data[0x05] = 1;
|
||||||
|
else if (it.action == 5)
|
||||||
|
shared_data[0x06] = 1;
|
||||||
|
else if (it.action == 6)
|
||||||
|
shared_data[0x07] = 1;
|
||||||
|
else if (it.action == 7)
|
||||||
|
shared_data[0x08] = 1;
|
||||||
|
else if (it.action == 8)
|
||||||
|
shared_data[0x09] = 1;
|
||||||
|
} else if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Held) &&
|
||||||
|
UI7_InBox(RenderD7::Hid::GetTouchPosition(), it.pos, it.size)) {
|
||||||
|
btn = RD7Color_ButtonHovered;
|
||||||
|
}
|
||||||
|
RenderD7::Draw2::RFS(it.pos, it.size, RenderD7::StyleColor(btn));
|
||||||
|
RenderD7::TextColorByBg(btn);
|
||||||
|
RenderD7::Draw2::Text(txtpos, it.disp);
|
||||||
|
RenderD7::UndoColorEdit(RD7Color_Text);
|
||||||
|
}
|
||||||
|
if (ft3 > 5) RenderD7::Hid::Lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ovl_Keyboard::Logic() {
|
||||||
|
ft3++;
|
||||||
|
for (const auto& it : shared_data) {
|
||||||
|
if (it.first == 0x01) {
|
||||||
|
typed_text->push_back(it.second);
|
||||||
|
} else if (it.first == 0x02) {
|
||||||
|
// Shift
|
||||||
|
mode = (mode == 2) ? 0 : 2;
|
||||||
|
} else if (it.first == 0x03) {
|
||||||
|
if (typed_text->length() >= 1)
|
||||||
|
typed_text->erase(typed_text->begin() + typed_text->length() - 1);
|
||||||
|
} else if (it.first == 0x04) {
|
||||||
|
// Enter
|
||||||
|
} else if (it.first == 0x05) {
|
||||||
|
*typed_text = str_bak;
|
||||||
|
this->Kill();
|
||||||
|
} else if (it.first == 0x06) {
|
||||||
|
this->Kill();
|
||||||
|
} else if (it.first == 0x07) {
|
||||||
|
// this->typed_text += '\t'; // Tab
|
||||||
|
} else if (it.first == 0x08) {
|
||||||
|
// Caps
|
||||||
|
mode = (mode == 1) ? 0 : 1;
|
||||||
|
} else if (it.first == 0x09) {
|
||||||
|
typed_text->append(" "); // Space
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shared_data.clear();
|
||||||
|
}
|
||||||
|
} // namespace RenderD7
|
@ -1,7 +1,11 @@
|
|||||||
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <renderd7/ResultDecoder.hpp>
|
#include <renderd7/ResultDecoder.hpp>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
extern std::string D_app_name;
|
||||||
|
|
||||||
static std::map<int, std::string> modules = {
|
static std::map<int, std::string> modules = {
|
||||||
{0, "common"},
|
{0, "common"},
|
||||||
{1, "kernel"},
|
{1, "kernel"},
|
||||||
@ -194,16 +198,20 @@ static std::map<int, std::string> descfs = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static std::map<int, std::string> descsrv = {
|
static std::map<int, std::string> descsrv = {
|
||||||
{5, "Invalid string length (service name length is zero or longer than 8 "
|
{5,
|
||||||
|
"Invalid string length (service name length is zero or longer than 8 "
|
||||||
"chars)."},
|
"chars)."},
|
||||||
{6, "Access to service denied (requested a service the application does "
|
{6,
|
||||||
|
"Access to service denied (requested a service the application does "
|
||||||
"not have access to)."},
|
"not have access to)."},
|
||||||
{7, "String size does not match contents (service name contains unexpected "
|
{7,
|
||||||
|
"String size does not match contents (service name contains unexpected "
|
||||||
"null byte)."},
|
"null byte)."},
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::map<int, std::string> descnwm = {
|
static std::map<int, std::string> descnwm = {
|
||||||
{2, "This error usually indicates the wifi chipset in the console is dying "
|
{2,
|
||||||
|
"This error usually indicates the wifi chipset in the console is dying "
|
||||||
"or dead."},
|
"or dead."},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -214,7 +222,8 @@ static std::map<int, std::string> descam = {
|
|||||||
{39, "Invalid title version."},
|
{39, "Invalid title version."},
|
||||||
{43, "Database doesn\"t exist, or it failed to open."},
|
{43, "Database doesn\"t exist, or it failed to open."},
|
||||||
{44, "Trying to uninstall system-app."},
|
{44, "Trying to uninstall system-app."},
|
||||||
{106, "Invalid signature/CIA. Usually happens when developer UNITINFO is "
|
{106,
|
||||||
|
"Invalid signature/CIA. Usually happens when developer UNITINFO is "
|
||||||
"enabled in Luma3DS."},
|
"enabled in Luma3DS."},
|
||||||
{393, "Invalid database."},
|
{393, "Invalid database."},
|
||||||
};
|
};
|
||||||
@ -224,31 +233,41 @@ static std::map<int, std::string> deschttp = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static std::map<int, std::string> descnim = {
|
static std::map<int, std::string> descnim = {
|
||||||
{1, "Invalid string IPC paramater (non null terminated at its indicated "
|
{1,
|
||||||
|
"Invalid string IPC paramater (non null terminated at its indicated "
|
||||||
"length)."},
|
"length)."},
|
||||||
{12, "Invalid country code returned by CFG module reading config save "
|
{12,
|
||||||
|
"Invalid country code returned by CFG module reading config save "
|
||||||
"0xB0000."},
|
"0xB0000."},
|
||||||
{13, "Zero string length console serial number or '000000000000000' "
|
{13,
|
||||||
|
"Zero string length console serial number or '000000000000000' "
|
||||||
"returned by CFG's SecureInfoGetSerialNo."},
|
"returned by CFG's SecureInfoGetSerialNo."},
|
||||||
{18, "General data reading error of NIM's .dat files from its system save, "
|
{18,
|
||||||
|
"General data reading error of NIM's .dat files from its system save, "
|
||||||
"bad data or bad data lengths."},
|
"bad data or bad data lengths."},
|
||||||
{22, "General invalid data or length of data returned from nintendo "
|
{22,
|
||||||
|
"General invalid data or length of data returned from nintendo "
|
||||||
"servers. (Only applicable for some operations)"},
|
"servers. (Only applicable for some operations)"},
|
||||||
{25, "IntegrityVerificationSeed is waiting on servers to be synced into "
|
{25,
|
||||||
|
"IntegrityVerificationSeed is waiting on servers to be synced into "
|
||||||
"console. Can't processed with online services without sync being "
|
"console. Can't processed with online services without sync being "
|
||||||
"completed first over IPC request."},
|
"completed first over IPC request."},
|
||||||
{26, "Unavailable/unaccessable IntegrityVerificationSeed on Nintendo "
|
{26,
|
||||||
|
"Unavailable/unaccessable IntegrityVerificationSeed on Nintendo "
|
||||||
"servers. May happen if NIM is told to import "
|
"servers. May happen if NIM is told to import "
|
||||||
"IntegrityVerificationSeed from servers at any time other than after "
|
"IntegrityVerificationSeed from servers at any time other than after "
|
||||||
"the successful System Transfer reboot."},
|
"the successful System Transfer reboot."},
|
||||||
{27, "Invalid country language code returned by CFG module reading config "
|
{27,
|
||||||
|
"Invalid country language code returned by CFG module reading config "
|
||||||
"save 0xA0002."},
|
"save 0xA0002."},
|
||||||
{37, "Service is in Standby Mode. (eShop ban? General service is down? "
|
{37,
|
||||||
|
"Service is in Standby Mode. (eShop ban? General service is down? "
|
||||||
"This caused by a server response flag on account information. "
|
"This caused by a server response flag on account information. "
|
||||||
"Account is not referring to NNID.)"},
|
"Account is not referring to NNID.)"},
|
||||||
{39, "HTTP Status non 200. (Only applicable for some operations)"},
|
{39, "HTTP Status non 200. (Only applicable for some operations)"},
|
||||||
{40, "General XML read/write error while processing Auto Delivery XMLs."},
|
{40, "General XML read/write error while processing Auto Delivery XMLs."},
|
||||||
{41, "General XML read/write error while processing Auto Delivery XMLs. "
|
{41,
|
||||||
|
"General XML read/write error while processing Auto Delivery XMLs. "
|
||||||
"(Stubbed virtual call was called)"},
|
"(Stubbed virtual call was called)"},
|
||||||
{58,
|
{58,
|
||||||
"Invalid NPNS token returned by CFG module reading config save 0xF0006."},
|
"Invalid NPNS token returned by CFG module reading config save 0xF0006."},
|
||||||
@ -266,7 +285,8 @@ static std::map<int, std::string> descqtm = {
|
|||||||
|
|
||||||
// Need to Fix The Range based Values
|
// Need to Fix The Range based Values
|
||||||
static std::map<int, std::string> descapplication = {
|
static std::map<int, std::string> descapplication = {
|
||||||
{0, "The application raised an error. Please consult the application's "
|
{0,
|
||||||
|
"The application raised an error. Please consult the application's "
|
||||||
"source code or ask the author for assistance with it."},
|
"source code or ask the author for assistance with it."},
|
||||||
{1024, "0x01"},
|
{1024, "0x01"},
|
||||||
};
|
};
|
||||||
@ -418,5 +438,24 @@ std::string ResultDecoder::GetSummary() {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderD7::ResultDecoder::WriteLog() {
|
||||||
|
std::string out_path = "sdmc:/RenderD7/Apps/" + D_app_name + "/resdec/";
|
||||||
|
std::filesystem::create_directories(out_path);
|
||||||
|
out_path += "/err_result_" + std::to_string(time(0)) + ".log";
|
||||||
|
std::ofstream out(out_path, std::ios::app);
|
||||||
|
out << "+-------------------\n";
|
||||||
|
out << "| Error: " << GetCode() << "\n";
|
||||||
|
out << "+-------------------\n";
|
||||||
|
out << "| Module: " << GetModule() << "\n";
|
||||||
|
out << "+-------------------\n";
|
||||||
|
out << "| Level: " << GetLevel() << "\n";
|
||||||
|
out << "+-------------------\n";
|
||||||
|
out << "| Summary: " << GetSummary() << "\n";
|
||||||
|
out << "+-------------------\n";
|
||||||
|
out << "| Description: " << GetDescription() << "\n";
|
||||||
|
out << "+-------------------\n";
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
|
||||||
int ResultDecoder::GetSummaryInt() { return R_SUMMARY(m_rescode); }
|
int ResultDecoder::GetSummaryInt() { return R_SUMMARY(m_rescode); }
|
||||||
} // namespace RenderD7
|
} // namespace RenderD7
|
@ -1,8 +1,7 @@
|
|||||||
#include <renderd7/Screen.hpp>
|
#include <renderd7/Screen.hpp>
|
||||||
|
#include <renderd7/internal_db.hpp>
|
||||||
extern bool currentScreen;
|
|
||||||
|
|
||||||
void RenderD7::OnScreen(C3D_RenderTarget *target) {
|
void RenderD7::OnScreen(C3D_RenderTarget *target) {
|
||||||
C2D_SceneBegin(target);
|
C2D_SceneBegin(target);
|
||||||
currentScreen = (target == Top || target == TopRight) ? 1 : 0;
|
rd7i_current_screen = (target == Top || target == TopRight) ? 1 : 0;
|
||||||
}
|
}
|
@ -1,33 +1,23 @@
|
|||||||
#include <renderd7/Security.hpp>
|
|
||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <renderd7/Security.hpp>
|
||||||
|
#include <renderd7/internal_db.hpp>
|
||||||
|
|
||||||
RenderD7::Security *rd7_security;
|
RenderD7::Security *rd7_security;
|
||||||
|
|
||||||
extern bool running;
|
|
||||||
bool *running_addr = NULL;
|
bool *running_addr = NULL;
|
||||||
|
RenderD7::Security::Level rd7i_slvl = RenderD7::Security::Level::NONE;
|
||||||
|
|
||||||
struct SecurityReport {
|
RenderD7::Security::Level RenderD7::Security::GetLevel() { return rd7i_slvl; }
|
||||||
uint32_t addr;
|
|
||||||
std::string initialisized_at;
|
|
||||||
bool success;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<SecurityReport> rd7_security_reports;
|
void RenderD7::Security::SetLevel(RenderD7::Security::Level level) {
|
||||||
|
rd7i_slvl = level;
|
||||||
RenderD7::Security::Level RenderD7::Security::GetLevel() {
|
|
||||||
return RenderD7::Security::Level::FULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderD7::Security::SetLevel(RenderD7::Security::Level level) {}
|
|
||||||
|
|
||||||
void RenderD7::Security::Report(uint32_t addr, void *result_ptr) {
|
|
||||||
// Create Report
|
|
||||||
}
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
Security::Security() { running_addr = &running; }
|
Security::Security() { running_addr = &rd7i_running; }
|
||||||
|
|
||||||
Security::~Security() { *running_addr = false; }
|
Security::~Security() { *running_addr = false; }
|
||||||
void Security::SafeExit(void (*exit_func)()) { atexit(exit_func); }
|
void Security::SafeExit(void (*exit_func)()) { atexit(exit_func); }
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
#include <renderd7/Sheet.hpp>
|
#include <renderd7/Sheet.hpp>
|
||||||
|
|
||||||
RenderD7::Sheet::Sheet() {
|
Result RenderD7::Sheet::Load(const std::string& path) {
|
||||||
//
|
this->spritesheet = C2D_SpriteSheetLoad(path.c_str());
|
||||||
}
|
|
||||||
RenderD7::Sheet::~Sheet() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
Result RenderD7::Sheet::Load(const char *path) {
|
|
||||||
this->spritesheet = C2D_SpriteSheetLoad(path);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderD7::Sheet::Free() { C2D_SpriteSheetFree(this->spritesheet); }
|
void RenderD7::Sheet::Free() {
|
||||||
|
C2D_SpriteSheetFree(this->spritesheet);
|
||||||
|
this->spritesheet = nullptr;
|
||||||
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
#include <renderd7/Sprite.hpp>
|
#include <renderd7/Sprite.hpp>
|
||||||
|
|
||||||
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) {
|
||||||
C2D_SpriteFromSheet(&this->sprite, sheet->spritesheet, index);
|
C2D_SpriteFromSheet(&this->sprite, sheet->spritesheet, index);
|
||||||
}
|
}
|
||||||
bool RenderD7::Sprite::Draw() { return C2D_DrawSprite(&this->sprite); }
|
bool RenderD7::Sprite::Draw() {
|
||||||
|
// Patch Depth before draw
|
||||||
|
sprite.params.depth = 0.5;
|
||||||
|
return C2D_DrawSprite(&this->sprite);
|
||||||
|
}
|
||||||
void RenderD7::Sprite::SetCenter(float x, float y) {
|
void RenderD7::Sprite::SetCenter(float x, float y) {
|
||||||
C2D_SpriteSetCenter(&this->sprite, x, y);
|
C2D_SpriteSetCenter(&this->sprite, x, y);
|
||||||
}
|
}
|
||||||
@ -28,7 +26,7 @@ float RenderD7::Sprite::getPosX() { return this->sprite.params.pos.x; }
|
|||||||
float RenderD7::Sprite::getPosY() { return this->sprite.params.pos.y; }
|
float RenderD7::Sprite::getPosY() { return this->sprite.params.pos.y; }
|
||||||
|
|
||||||
void RenderD7::Sprite::FromImage(RenderD7::Image *img) {
|
void RenderD7::Sprite::FromImage(RenderD7::Image *img) {
|
||||||
C2D_SpriteFromImage(&this->sprite, img->img);
|
C2D_SpriteFromImage(&this->sprite, img->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderD7::Sprite::SetScale(float x, float y) {
|
void RenderD7::Sprite::SetScale(float x, float y) {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include <renderd7/Tasks.hpp>
|
|
||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <renderd7/Tasks.hpp>
|
||||||
|
|
||||||
static std::vector<Thread> threads;
|
static std::vector<Thread> threads;
|
||||||
|
|
||||||
void RenderD7::Tasks::create(ThreadFunc entrypoint) {
|
void RenderD7::Tasks::create(ThreadFunc entrypoint) {
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
#include <fstream>
|
|
||||||
#include <memory>
|
|
||||||
#include <renderd7/Time.hpp>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <string>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <memory>
|
||||||
|
#include <renderd7/Time.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
std::string RenderD7::FormatString(std::string fmt_str, ...) {
|
std::string RenderD7::FormatString(std::string fmt_str, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *fp = NULL;
|
char *fp = NULL;
|
||||||
|
31
source/Timer.cpp
Normal file
31
source/Timer.cpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#include <renderd7/Timer.hpp>
|
||||||
|
|
||||||
|
// Ticks per MSEC
|
||||||
|
#define TPMS 268111.856
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
Timer::Timer(bool autostart) {
|
||||||
|
if (autostart) is_running = true;
|
||||||
|
last = svcGetSystemTick();
|
||||||
|
current = last;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Timer::reset() {
|
||||||
|
last = svcGetSystemTick();
|
||||||
|
current = last;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Timer::tick() {
|
||||||
|
if (is_running) current = svcGetSystemTick();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Timer::pause() { is_running = false; }
|
||||||
|
|
||||||
|
void Timer::resume() { is_running = true; }
|
||||||
|
|
||||||
|
bool Timer::running() { return is_running; }
|
||||||
|
|
||||||
|
float Timer::get() { return (float)((current - last) / TPMS); }
|
||||||
|
|
||||||
|
float Timer::get_live() { return (float)((svcGetSystemTick() - last) / TPMS); }
|
||||||
|
} // namespace RenderD7
|
@ -1,93 +0,0 @@
|
|||||||
#include <renderd7/Color.hpp>
|
|
||||||
#include <renderd7/Draw.hpp>
|
|
||||||
#include <renderd7/Screen.hpp>
|
|
||||||
#include <renderd7/ToastsV2.hpp>
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
extern bool rd7_debugging;
|
|
||||||
|
|
||||||
std::vector<std::shared_ptr<RenderD7::Message>> msg_lst;
|
|
||||||
int fade_outs = 200; // Start of fadeout
|
|
||||||
int idles = 60; // start of Idle
|
|
||||||
int anim_len = 300; // Full Length of Animation
|
|
||||||
|
|
||||||
std::pair<int, int> MakePos(int frame, int entry) {
|
|
||||||
float fol = anim_len - fade_outs;
|
|
||||||
if (frame > fade_outs)
|
|
||||||
return std::make_pair(5, 240 - ((entry + 1) * 55) - 5 +
|
|
||||||
(float)((frame - fade_outs) / fol) * -20);
|
|
||||||
if (frame > idles)
|
|
||||||
return std::make_pair(5, 240 - ((entry + 1) * 55) - 5);
|
|
||||||
return std::make_pair(-150 + ((float)(frame / (float)idles) * 155),
|
|
||||||
240 - ((entry + 1) * 55) - 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace RenderD7 {
|
|
||||||
float GetDeltaTime(); // Extern from renderd7.cpp
|
|
||||||
|
|
||||||
void ProcessMessages() {
|
|
||||||
// Draw in ovl mode
|
|
||||||
RenderD7::OnScreen(Top);
|
|
||||||
float fol = anim_len - fade_outs;
|
|
||||||
std::reverse(msg_lst.begin(), msg_lst.end());
|
|
||||||
for (size_t i = 0; i < msg_lst.size(); i++) {
|
|
||||||
std::pair<int, int> pos = MakePos(msg_lst[i]->animationframe, i);
|
|
||||||
if ((pos.second + 150) < 0) {
|
|
||||||
// Dont Render Out of Screen
|
|
||||||
// And as thay aren't relevant anymore
|
|
||||||
// Thay get deleted!
|
|
||||||
msg_lst.erase(msg_lst.begin() + i);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
int new_alpha = 200;
|
|
||||||
if (msg_lst[i]->animationframe > fade_outs) {
|
|
||||||
new_alpha =
|
|
||||||
200 - (float(msg_lst[i]->animationframe - fade_outs) / fol) * 200;
|
|
||||||
}
|
|
||||||
u32 txtcol = RenderD7::Color::Hex("#ffffff", new_alpha);
|
|
||||||
RenderD7::Draw::Rect(pos.first, pos.second, 150, 50,
|
|
||||||
RenderD7::Color::Hex("#333333", new_alpha));
|
|
||||||
RenderD7::Draw::Text(pos.first + 5, pos.second + 1, 0.4f, txtcol,
|
|
||||||
msg_lst[i]->title);
|
|
||||||
RenderD7::Draw::Text(pos.first + 5, pos.second + 17, 0.4f, txtcol,
|
|
||||||
msg_lst[i]->message);
|
|
||||||
if (rd7_debugging)
|
|
||||||
RenderD7::Draw::Text(pos.first + 160, pos.second + 1, 0.5f,
|
|
||||||
RenderD7::Color::Hex("#000000"),
|
|
||||||
std::to_string(msg_lst[i]->animationframe));
|
|
||||||
// Why Frameadd? because Message uses int as frame and
|
|
||||||
// It seems that lower 0.5 will be rounded to 0
|
|
||||||
// Why not replace int with float ?
|
|
||||||
// cause of buggy positions (seen in Flappy Bird 3ds for example)
|
|
||||||
float frameadd = 60.f * RenderD7::GetDeltaTime();
|
|
||||||
// 60fps animation * delta to not slowdown
|
|
||||||
// Oh and fix for Startup lol
|
|
||||||
// Todo: Only do this on AppStart
|
|
||||||
if (msg_lst[i]->animationframe == 0) {
|
|
||||||
msg_lst[i]->animationframe += 1;
|
|
||||||
} else {
|
|
||||||
msg_lst[i]->animationframe += (frameadd < 1.f ? 1.f : frameadd);
|
|
||||||
}
|
|
||||||
if (msg_lst[i]->animationframe > anim_len) {
|
|
||||||
msg_lst.erase(msg_lst.begin() + i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ReReverse ?? lol
|
|
||||||
// Cause otherwise the Toasts will swap
|
|
||||||
std::reverse(msg_lst.begin(), msg_lst.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
void PushMessage(const Message &msg) {
|
|
||||||
msg_lst.push_back(std::make_shared<RenderD7::Message>(msg));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetIdleStartFrame(int frame) { idles = frame; }
|
|
||||||
|
|
||||||
void SetTotalAnimationFrames(int total_frames) { anim_len = total_frames; }
|
|
||||||
|
|
||||||
void SetFadeOutStartFrame(int frame) { fade_outs = frame; }
|
|
||||||
} // namespace RenderD7
|
|
489
source/UI7.cpp
Normal file
489
source/UI7.cpp
Normal file
@ -0,0 +1,489 @@
|
|||||||
|
#include <ctime>
|
||||||
|
#include <renderd7/Color.hpp>
|
||||||
|
#include <renderd7/DrawV2.hpp>
|
||||||
|
#include <renderd7/Hid.hpp>
|
||||||
|
#include <renderd7/Overlays.hpp>
|
||||||
|
#include <renderd7/UI7.hpp>
|
||||||
|
#include <renderd7/internal_db.hpp>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
// As the 3ds doesn't support std::chrono
|
||||||
|
#ifdef __3DS__
|
||||||
|
/// @brief 3ds System Ticks per milli second
|
||||||
|
/// Already defined in FTrace ik but
|
||||||
|
/// I Want to make UI7 and Draw2 more
|
||||||
|
/// Independent of the main RenderD7 api
|
||||||
|
#define TICKS_PER_MSEC 268111.856
|
||||||
|
#include <3ds.h>
|
||||||
|
#define __get_time() svcGetSystemTick() / TICKS_PER_MSEC
|
||||||
|
#else
|
||||||
|
#include <chrono>
|
||||||
|
#define __get_time() \
|
||||||
|
std::chrono::duration_cast<std::chrono::milliseconds>( \
|
||||||
|
std::chrono::system_clock().now().time_since_epoch()) \
|
||||||
|
.count()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Basement structs enums etc
|
||||||
|
struct UI7ID {
|
||||||
|
UI7ID(const std::string &id) {
|
||||||
|
real_id = id;
|
||||||
|
title = id;
|
||||||
|
if (id.substr(0, 2) == "##") {
|
||||||
|
title = "";
|
||||||
|
has_title = false;
|
||||||
|
}
|
||||||
|
// Ensure the id is lowercase
|
||||||
|
std::transform(real_id.begin(), real_id.end(), real_id.begin(),
|
||||||
|
[](unsigned char c) { return std::tolower(c); });
|
||||||
|
lt = time(0);
|
||||||
|
}
|
||||||
|
UI7ID() {
|
||||||
|
title = "";
|
||||||
|
real_id = "";
|
||||||
|
has_title = false;
|
||||||
|
lt = time(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Title() {
|
||||||
|
lt = time(0);
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ID() {
|
||||||
|
lt = time(0);
|
||||||
|
return real_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const UI7ID &in) { return (real_id == in.real_id); }
|
||||||
|
|
||||||
|
bool operator!=(const UI7ID &in) { return !(*this == in); }
|
||||||
|
|
||||||
|
std::string title;
|
||||||
|
std::string real_id;
|
||||||
|
bool has_title;
|
||||||
|
int lt;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct UI7_Ctx {
|
||||||
|
UI7_Ctx() {
|
||||||
|
delta = 0.0f;
|
||||||
|
time = 0.0f;
|
||||||
|
is_activated = false;
|
||||||
|
_last = 0;
|
||||||
|
cursor = R7Vec2();
|
||||||
|
slc = R7Vec2();
|
||||||
|
cbackup = R7Vec2();
|
||||||
|
in_menu = false;
|
||||||
|
current_menu = UI7ID("");
|
||||||
|
}
|
||||||
|
float delta;
|
||||||
|
float time;
|
||||||
|
bool is_activated;
|
||||||
|
unsigned long long _last;
|
||||||
|
R7Vec2 cursor;
|
||||||
|
R7Vec2 cbackup;
|
||||||
|
R7Vec2 slc;
|
||||||
|
bool in_menu;
|
||||||
|
UI7ID current_menu;
|
||||||
|
std::map<std::string, R7Vec2> grid_mapping;
|
||||||
|
std::unordered_map<std::string, UI7ID *> ids;
|
||||||
|
};
|
||||||
|
|
||||||
|
UI7_Ctx *ui7_ctx;
|
||||||
|
|
||||||
|
bool UI7CtxValidate() {
|
||||||
|
if (ui7_ctx == nullptr) return false;
|
||||||
|
if (!ui7_ctx->is_activated) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UI7CtxInMenu() {
|
||||||
|
if (!UI7CtxValidate()) return false;
|
||||||
|
return ui7_ctx->in_menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UI7CtxBeginMenu(const std::string &lb) {
|
||||||
|
if (!UI7CtxValidate()) return false;
|
||||||
|
if (UI7CtxInMenu()) return false;
|
||||||
|
ui7_ctx->current_menu = UI7ID(lb);
|
||||||
|
ui7_ctx->in_menu = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UI7CtxEndMenu() {
|
||||||
|
if (!UI7CtxValidate()) return;
|
||||||
|
if (!UI7CtxInMenu()) return;
|
||||||
|
ui7_ctx->current_menu = UI7ID("");
|
||||||
|
ui7_ctx->in_menu = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UI7CtxCursorMove(R7Vec2 size) {
|
||||||
|
if (!UI7CtxValidate()) return;
|
||||||
|
if (!UI7CtxInMenu()) return;
|
||||||
|
ui7_ctx->slc = ui7_ctx->cursor + R7Vec2(5, 0);
|
||||||
|
ui7_ctx->cursor.x = 5;
|
||||||
|
ui7_ctx->cursor += R7Vec2(0, size.y + 5);
|
||||||
|
ui7_ctx->slc += R7Vec2(size.x, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
UI7ID *UI7CtxNewID(const std::string &i) {
|
||||||
|
std::string t = i;
|
||||||
|
std::transform(t.begin(), t.end(), t.begin(),
|
||||||
|
[](unsigned char c) { return std::tolower(c); });
|
||||||
|
if (ui7_ctx->ids.find(t) != ui7_ctx->ids.end()) {
|
||||||
|
return ui7_ctx->ids[t];
|
||||||
|
}
|
||||||
|
auto id = new UI7ID(i);
|
||||||
|
ui7_ctx->ids[id->real_id] = id;
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UI7CtxClearIDs() {
|
||||||
|
for (auto it = ui7_ctx->ids.begin(); it != ui7_ctx->ids.end();) {
|
||||||
|
if (it->second == nullptr) {
|
||||||
|
++it;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (time(0) - it->second->lt > 5) {
|
||||||
|
delete it->second;
|
||||||
|
it = ui7_ctx->ids.erase(it);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int rd7i_ui7_ids_active() {
|
||||||
|
if (!UI7CtxValidate()) return 0;
|
||||||
|
return ui7_ctx->ids.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace UI7 {
|
||||||
|
bool InBox(R7Vec2 inpos, R7Vec2 boxpos, R7Vec2 boxsize) {
|
||||||
|
if ((inpos.x > boxpos.x) && (inpos.y > boxpos.y) &&
|
||||||
|
(inpos.x < boxpos.x + boxsize.x) && (inpos.y < boxpos.y + boxsize.y))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Init() {
|
||||||
|
// If Context is valid it makes no sense to reinit lol
|
||||||
|
if (UI7CtxValidate()) return;
|
||||||
|
ui7_ctx = new UI7_Ctx;
|
||||||
|
ui7_ctx->delta = 0.0f;
|
||||||
|
ui7_ctx->time = 0.0f;
|
||||||
|
ui7_ctx->cursor = R7Vec2(0, 0);
|
||||||
|
ui7_ctx->is_activated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Deinit() {
|
||||||
|
// Dont deinit something not initialized
|
||||||
|
// Please dont count how often init... was
|
||||||
|
// written wront by me :(
|
||||||
|
if (!UI7CtxValidate()) return;
|
||||||
|
ui7_ctx->is_activated = false;
|
||||||
|
delete ui7_ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update() {
|
||||||
|
// Dont do anithing without ctx;
|
||||||
|
if (!UI7CtxValidate()) return;
|
||||||
|
unsigned long long current = __get_time();
|
||||||
|
ui7_ctx->delta = (float)((float)current - (float)ui7_ctx->_last) / 1000.f;
|
||||||
|
ui7_ctx->_last = current;
|
||||||
|
ui7_ctx->time += ui7_ctx->delta;
|
||||||
|
ui7_ctx->cursor = R7Vec2();
|
||||||
|
UI7CtxClearIDs();
|
||||||
|
}
|
||||||
|
|
||||||
|
float GetTime() {
|
||||||
|
if (!UI7CtxValidate()) return 0;
|
||||||
|
return ui7_ctx->time;
|
||||||
|
}
|
||||||
|
|
||||||
|
float GetDeltaTime() {
|
||||||
|
if (!UI7CtxValidate()) return 0;
|
||||||
|
return ui7_ctx->delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Button(const std::string &label, R7Vec2 size) {
|
||||||
|
bool ret = false;
|
||||||
|
if (!UI7CtxValidate()) return ret;
|
||||||
|
R7Vec2 textdim = RenderD7::GetTextDimensions(label);
|
||||||
|
if (size.x == 0) {
|
||||||
|
size.x = textdim.x + 8;
|
||||||
|
}
|
||||||
|
if (size.y == 0) {
|
||||||
|
size.y = textdim.y + 4;
|
||||||
|
}
|
||||||
|
RD7Color btn = RD7Color_Button;
|
||||||
|
R7Vec2 pos = GetCursorPos();
|
||||||
|
|
||||||
|
UI7CtxCursorMove(size);
|
||||||
|
|
||||||
|
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up) &&
|
||||||
|
InBox(RenderD7::Hid::GetLastTouchPosition(), pos, size)) {
|
||||||
|
btn = RD7Color_ButtonActive;
|
||||||
|
ret = true;
|
||||||
|
} else if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Held) &&
|
||||||
|
InBox(RenderD7::Hid::GetTouchPosition(), pos, size)) {
|
||||||
|
btn = RD7Color_ButtonHovered;
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderD7::Draw2::RFS(pos, size, RenderD7::StyleColor(btn));
|
||||||
|
pos = R7Vec2(pos.x + size.x * 0.5f - textdim.x * 0.5,
|
||||||
|
pos.y + size.y * 0.5f - textdim.y * 0.5);
|
||||||
|
RenderD7::TextColorByBg(btn);
|
||||||
|
RenderD7::Draw2::Text(pos, label);
|
||||||
|
RenderD7::UndoColorEdit(RD7Color_Text);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Checkbox(const std::string &label, bool &c) {
|
||||||
|
if (!UI7CtxValidate()) return;
|
||||||
|
R7Vec2 cbs = R7Vec2(18, 18);
|
||||||
|
R7Vec2 txtdim = RenderD7::GetTextDimensions(label);
|
||||||
|
R7Vec2 inp = cbs + R7Vec2(txtdim.x + 5, 0);
|
||||||
|
RD7Color bg = RD7Color_FrameBg;
|
||||||
|
|
||||||
|
R7Vec2 pos = GetCursorPos();
|
||||||
|
|
||||||
|
UI7CtxCursorMove(inp);
|
||||||
|
|
||||||
|
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up) &&
|
||||||
|
InBox(RenderD7::Hid::GetLastTouchPosition(), pos, inp)) {
|
||||||
|
bg = RD7Color_FrameBgHovered;
|
||||||
|
c = !c;
|
||||||
|
} else if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Held) &&
|
||||||
|
InBox(RenderD7::Hid::GetTouchPosition(), pos, inp)) {
|
||||||
|
bg = RD7Color_FrameBgHovered;
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderD7::Draw2::RFS(pos, cbs, RenderD7::StyleColor(bg));
|
||||||
|
if (c == true) {
|
||||||
|
RenderD7::Draw2::RFS(pos + R7Vec2(2, 2), cbs - R7Vec2(4, 4),
|
||||||
|
RenderD7::StyleColor(RD7Color_Checkmark));
|
||||||
|
}
|
||||||
|
RenderD7::Draw2::Text(pos + R7Vec2(cbs.x + 5, 1), label);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Label(const std::string &label, RD7TextFlags flags) {
|
||||||
|
if (!UI7CtxValidate()) return;
|
||||||
|
R7Vec2 textdim = RenderD7::GetTextDimensions(label);
|
||||||
|
R7Vec2 pos = GetCursorPos();
|
||||||
|
// Remove some y offset cause texts have some offset
|
||||||
|
UI7CtxCursorMove(textdim - R7Vec2(0, 4));
|
||||||
|
RenderD7::TextColorByBg(
|
||||||
|
(pos.y + textdim.y < 20 ? RD7Color_Header : RD7Color_Background));
|
||||||
|
RenderD7::Draw2::Text(pos, label, flags);
|
||||||
|
RenderD7::UndoColorEdit(RD7Color_Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Progressbar(float value) {
|
||||||
|
if (!UI7CtxValidate()) return;
|
||||||
|
R7Vec2 pos = GetCursorPos();
|
||||||
|
R7Vec2 size = R7Vec2((rd7i_current_screen ? 400 : 320) - (pos.x * 2), 20);
|
||||||
|
UI7CtxCursorMove(size);
|
||||||
|
|
||||||
|
RenderD7::Draw2::RFS(pos, size, RenderD7::StyleColor(RD7Color_FrameBg));
|
||||||
|
RenderD7::Draw2::RFS(pos + R7Vec2(2, 2), size - R7Vec2(4, 4),
|
||||||
|
RenderD7::StyleColor(RD7Color_FrameBgHovered));
|
||||||
|
if (!(value != value) && !(value < 0.0) && !(value > 1.0))
|
||||||
|
RenderD7::Draw2::RFS(pos + R7Vec2(2, 2),
|
||||||
|
R7Vec2((size.x - 4) * value, size.y - 4),
|
||||||
|
RenderD7::StyleColor(RD7Color_Progressbar));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Image(RenderD7::Image *img) {
|
||||||
|
if (!UI7CtxValidate()) return;
|
||||||
|
R7Vec2 pos = GetCursorPos();
|
||||||
|
UI7CtxCursorMove(R7Vec2(img->get_size().x, img->get_size().y));
|
||||||
|
|
||||||
|
RenderD7::Draw2::Image(img, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BrowserList(const std::vector<std::string> &entrys, int &selection,
|
||||||
|
RD7TextFlags txtflags, R7Vec2 size, int max_entrys) {
|
||||||
|
if (!UI7CtxValidate()) return;
|
||||||
|
if (selection < 0) return;
|
||||||
|
R7Vec2 pos = GetCursorPos();
|
||||||
|
if (pos.y + 15 * max_entrys > 230) max_entrys = (int)((230 - pos.y) / 15);
|
||||||
|
if (size.x == 0) size.x = (rd7i_current_screen ? 400 : 320) - (pos.x * 2);
|
||||||
|
if (size.y == 0) size.y = (max_entrys * 15);
|
||||||
|
UI7CtxCursorMove(size);
|
||||||
|
for (int i = 0; i < max_entrys; i++) {
|
||||||
|
RenderD7::Draw2::RFS(
|
||||||
|
pos + R7Vec2(0, 15 * i), R7Vec2(size.x, 15),
|
||||||
|
RenderD7::StyleColor((i % 2) == 0 ? RD7Color_List0 : RD7Color_List1));
|
||||||
|
}
|
||||||
|
for (size_t i = 0;
|
||||||
|
i < ((entrys.size() < (size_t)max_entrys) ? entrys.size()
|
||||||
|
: (size_t)max_entrys);
|
||||||
|
i++) {
|
||||||
|
int selindex = (selection < max_entrys ? selection : (max_entrys - 1));
|
||||||
|
int list_index =
|
||||||
|
(selection < max_entrys ? i : (i + selection - (max_entrys - 1)));
|
||||||
|
if (i == (size_t)selindex) {
|
||||||
|
RenderD7::Draw2::RectFilled(
|
||||||
|
pos + R7Vec2(0, 15 * i), R7Vec2(size.x, 15),
|
||||||
|
{RenderD7::StyleColor(RD7Color_Selector),
|
||||||
|
RenderD7::Color::RGBA(RD7Color_Selector)
|
||||||
|
.fade_to(RD7Color_SelectorFade, std::sin(RenderD7::GetTime()))
|
||||||
|
.toRGBA(),
|
||||||
|
RenderD7::StyleColor(RD7Color_Selector),
|
||||||
|
RenderD7::Color::RGBA(RD7Color_Selector)
|
||||||
|
.fade_to(RD7Color_SelectorFade, std::sin(RenderD7::GetTime()))
|
||||||
|
.toRGBA()});
|
||||||
|
RenderD7::TextColorByBg(RD7Color_Selector);
|
||||||
|
RenderD7::TextMaxBox(R7Vec2(size.x, 0));
|
||||||
|
RenderD7::Draw2::Text(pos + R7Vec2(5, 15 * i), entrys[list_index],
|
||||||
|
txtflags | RD7TextFlags_Short);
|
||||||
|
RenderD7::TextDefaultBox();
|
||||||
|
RenderD7::UndoColorEdit(RD7Color_Text);
|
||||||
|
} else {
|
||||||
|
RenderD7::Ftrace::Beg("app", "short_algo");
|
||||||
|
RenderD7::TextColorByBg(RD7Color_List0);
|
||||||
|
RenderD7::TextMaxBox(R7Vec2(size.x, 0));
|
||||||
|
RenderD7::Draw2::Text(pos + R7Vec2(5, 15 * i), entrys[list_index],
|
||||||
|
txtflags | RD7TextFlags_Short);
|
||||||
|
RenderD7::TextDefaultBox();
|
||||||
|
RenderD7::UndoColorEdit(RD7Color_Text);
|
||||||
|
RenderD7::Ftrace::End("app", "short_algo");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputText(const std::string &label, std::string &text,
|
||||||
|
const std::string &hint) {
|
||||||
|
if (!UI7CtxValidate()) return;
|
||||||
|
R7Vec2 cbs = R7Vec2(144, 18);
|
||||||
|
R7Vec2 txtdim = RenderD7::GetTextDimensions(label);
|
||||||
|
R7Vec2 inp = cbs + R7Vec2(txtdim.x + 5, 0);
|
||||||
|
RD7Color bg = RD7Color_FrameBg;
|
||||||
|
auto id = UI7CtxNewID(label);
|
||||||
|
|
||||||
|
R7Vec2 pos = GetCursorPos();
|
||||||
|
|
||||||
|
UI7CtxCursorMove(inp);
|
||||||
|
|
||||||
|
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up) &&
|
||||||
|
InBox(RenderD7::Hid::GetLastTouchPosition(), pos, inp)) {
|
||||||
|
bg = RD7Color_FrameBgHovered;
|
||||||
|
RenderD7::AddOvl(std::make_unique<RenderD7::Ovl_Keyboard>(text, hint));
|
||||||
|
} else if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Held) &&
|
||||||
|
InBox(RenderD7::Hid::GetTouchPosition(), pos, inp)) {
|
||||||
|
bg = RD7Color_FrameBgHovered;
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderD7::Draw2::RFS(pos, cbs, RenderD7::StyleColor(bg));
|
||||||
|
RenderD7::TextColorByBg(bg);
|
||||||
|
RenderD7::Draw2::Text(pos + R7Vec2(5, 1), (text != "" ? text : hint));
|
||||||
|
RenderD7::UndoColorEdit(RD7Color_Text);
|
||||||
|
RenderD7::Draw2::Text(pos + R7Vec2(cbs.x + 5, 1), id->Title());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BeginMenu(const std::string &title, R7Vec2 size, UI7MenuFlags flags) {
|
||||||
|
if (!UI7CtxValidate()) return false;
|
||||||
|
auto id = UI7CtxNewID(title);
|
||||||
|
bool titlebar = true;
|
||||||
|
if (size.x == 0) {
|
||||||
|
size.x = rd7i_current_screen ? 400 : 320;
|
||||||
|
}
|
||||||
|
if (size.y == 0) {
|
||||||
|
size.y = 240;
|
||||||
|
}
|
||||||
|
RD7TextFlags txtflags = 0;
|
||||||
|
if (flags & UI7MenuFlags_NoTitlebar) titlebar = false;
|
||||||
|
if (flags & UI7MenuFlags_TitleMid) txtflags = RD7TextFlags_AlignMid;
|
||||||
|
RenderD7::Draw2::RFS(R7Vec2(0, 0), size,
|
||||||
|
RenderD7::StyleColor(RD7Color_Background));
|
||||||
|
if (titlebar) {
|
||||||
|
RenderD7::Draw2::RFS(R7Vec2(0, 0), R7Vec2(size.x, 20),
|
||||||
|
RenderD7::StyleColor(RD7Color_Header));
|
||||||
|
RenderD7::TextColorByBg(RD7Color_Header);
|
||||||
|
RenderD7::Draw2::Text(R7Vec2(5, 2), id->title, txtflags);
|
||||||
|
RenderD7::UndoColorEdit(RD7Color_Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetCursorPos(R7Vec2(5, 25));
|
||||||
|
return UI7CtxBeginMenu(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndMenu() { UI7CtxEndMenu(); }
|
||||||
|
|
||||||
|
void Grid(const std::string &name, const R7Vec2 &size,
|
||||||
|
R7Vec2 (*display_func)(void *, R7Vec2), void **data_array,
|
||||||
|
size_t num_entrys) {
|
||||||
|
if (!UI7CtxValidate()) return;
|
||||||
|
if (num_entrys <= 0) return;
|
||||||
|
if (data_array == nullptr) return;
|
||||||
|
if (ui7_ctx->grid_mapping.find(UI7ID(name).real_id) ==
|
||||||
|
ui7_ctx->grid_mapping.end())
|
||||||
|
ui7_ctx->grid_mapping[UI7ID(name).real_id] =
|
||||||
|
R7Vec2(); // Register id not exist
|
||||||
|
R7Vec2 pos = GetCursorPos();
|
||||||
|
R7Vec2 cpos(pos);
|
||||||
|
|
||||||
|
// Debug Grid
|
||||||
|
RenderD7::Draw2::Rect(pos, size, RenderD7::Color::Hex("#ff0000"), 1);
|
||||||
|
|
||||||
|
// Y-Offset
|
||||||
|
int yoff = 0;
|
||||||
|
|
||||||
|
pos += ui7_ctx->grid_mapping[UI7ID(name).real_id];
|
||||||
|
for (size_t i = 0; i < num_entrys; i++) {
|
||||||
|
R7Vec2 szs = display_func(data_array[i], pos);
|
||||||
|
RenderD7::Draw2::Text(pos + R7Vec2(4, 4), std::to_string(i));
|
||||||
|
if (pos.x + (szs.x * 2) > (cpos.x + size.x) &&
|
||||||
|
pos.y + szs.y > cpos.y + size.y) {
|
||||||
|
if (ui7_ctx->grid_mapping[UI7ID(name).real_id].y == 0)
|
||||||
|
ui7_ctx->grid_mapping[UI7ID(name).real_id].y =
|
||||||
|
(cpos.y + size.y) / 2 - ((yoff + 1) * (szs.y + 4)) / 2;
|
||||||
|
break;
|
||||||
|
} else if (pos.x + (szs.x * 2) > (cpos.x + size.x)) {
|
||||||
|
if (ui7_ctx->grid_mapping[UI7ID(name).real_id].x == 0)
|
||||||
|
ui7_ctx->grid_mapping[UI7ID(name).real_id].x =
|
||||||
|
(cpos.x + size.x) / 2 - ((i + 1) * (szs.x + 4)) / 2;
|
||||||
|
pos = R7Vec2(5 + ui7_ctx->grid_mapping[UI7ID(name).real_id].x,
|
||||||
|
pos.y + szs.y + 4);
|
||||||
|
yoff++;
|
||||||
|
} else {
|
||||||
|
pos += R7Vec2(szs.x + 4, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UI7CtxCursorMove(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BeginTree(const std::string& text) {
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndTree() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
R7Vec2 GetCursorPos() {
|
||||||
|
if (!UI7CtxValidate()) return R7Vec2();
|
||||||
|
return ui7_ctx->cursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetCursorPos(R7Vec2 cp) {
|
||||||
|
if (!UI7CtxValidate()) return;
|
||||||
|
ui7_ctx->cbackup = ui7_ctx->cursor;
|
||||||
|
ui7_ctx->cursor = cp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RestoreCursor() {
|
||||||
|
if (!UI7CtxValidate()) return;
|
||||||
|
ui7_ctx->cursor = ui7_ctx->cbackup;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SameLine() {
|
||||||
|
if (!UI7CtxValidate()) return;
|
||||||
|
ui7_ctx->cursor = ui7_ctx->slc;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace UI7
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user