Compare commits
9 Commits
main
...
alpha-0-3-
Author | SHA1 | Date | |
---|---|---|---|
122b07639e | |||
ce6170c475 | |||
0786c6f999 | |||
5144d5c00c | |||
1bf4ac775f | |||
4f1b5ee53c | |||
da498451c2 | |||
37422eb337 | |||
![]() |
1f36fa9599 |
259
.clang-format
259
.clang-format
@ -1,259 +0,0 @@
|
||||
---
|
||||
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
|
||||
...
|
||||
|
11
.gitignore
vendored
11
.gitignore
vendored
@ -1,11 +0,0 @@
|
||||
*.bz2
|
||||
*.DS_Store*
|
||||
.cache/
|
||||
compile_commands.json
|
||||
|
||||
# DOCS
|
||||
docs/*
|
||||
!docs/javascripts
|
||||
!docs/overrides
|
||||
!docs/stylesheets
|
||||
site/*
|
18
.vscode/c_cpp_properties.json
vendored
18
.vscode/c_cpp_properties.json
vendored
@ -1,18 +0,0 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "3DS | Windows",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**",
|
||||
"C:/devkitpro/libctru/include/**",
|
||||
"C:/devkitpro/devkitARM/include/**",
|
||||
"C:/devkitpro/devkitARM/arm-none-eabi/include/**",
|
||||
"C:/devkitpro/portlibs/3ds/include/**",
|
||||
"/opt/devkitpro/libctru/include/**",
|
||||
"/opt/devkitpro/portlibs/**"
|
||||
|
||||
]
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
121
.vscode/launch.json
vendored
121
.vscode/launch.json
vendored
@ -1,121 +0,0 @@
|
||||
{
|
||||
"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",
|
||||
/// LINUX
|
||||
//"miDebuggerPath": "/opt/devkitPro/devkitARM/bin/arm-none-eabi-gdb",
|
||||
/// WINDOWS
|
||||
"miDebuggerPath": "C:/devkitPro/devkitARM/bin/arm-none-eabi-gdb.exe",
|
||||
"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",
|
||||
/// LINUX
|
||||
//"miDebuggerPath": "/opt/devkitPro/devkitARM/bin/arm-none-eabi-gdb",
|
||||
/// WINDOWS
|
||||
"miDebuggerPath": "C:/devkitPro/devkitARM/bin/arm-none-eabi-gdb.exe",
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
118
.vscode/settings.json
vendored
118
.vscode/settings.json
vendored
@ -1,118 +0,0 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"array": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory": "cpp",
|
||||
"numeric": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"fstream": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"new": "cpp",
|
||||
"optional": "cpp",
|
||||
"ostream": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"string": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"utility": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bit": "cpp",
|
||||
"bitset": "cpp",
|
||||
"chrono": "cpp",
|
||||
"codecvt": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"deque": "cpp",
|
||||
"forward_list": "cpp",
|
||||
"map": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"ratio": "cpp",
|
||||
"regex": "cpp",
|
||||
"shared_mutex": "cpp",
|
||||
"valarray": "cpp",
|
||||
"random": "cpp",
|
||||
"cuchar": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
"numbers": "cpp",
|
||||
"filesystem": "cpp",
|
||||
"xstring": "cpp",
|
||||
"charconv": "cpp",
|
||||
"format": "cpp",
|
||||
"ios": "cpp",
|
||||
"list": "cpp",
|
||||
"locale": "cpp",
|
||||
"mutex": "cpp",
|
||||
"stack": "cpp",
|
||||
"stop_token": "cpp",
|
||||
"thread": "cpp",
|
||||
"xfacet": "cpp",
|
||||
"xhash": "cpp",
|
||||
"xiosbase": "cpp",
|
||||
"xlocale": "cpp",
|
||||
"xlocbuf": "cpp",
|
||||
"xlocinfo": "cpp",
|
||||
"xlocmes": "cpp",
|
||||
"xlocmon": "cpp",
|
||||
"xlocnum": "cpp",
|
||||
"xloctime": "cpp",
|
||||
"xmemory": "cpp",
|
||||
"xstddef": "cpp",
|
||||
"xtr1common": "cpp",
|
||||
"xtree": "cpp",
|
||||
"xutility": "cpp",
|
||||
"queue": "cpp",
|
||||
"semaphore": "cpp",
|
||||
"hash_map": "cpp",
|
||||
"set": "cpp",
|
||||
"unordered_set": "cpp",
|
||||
"source_location": "cpp",
|
||||
"future": "cpp",
|
||||
"cfenv": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"typeindex": "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"
|
||||
}
|
||||
}
|
37
.vscode/tasks.json
vendored
37
.vscode/tasks.json
vendored
@ -1,37 +0,0 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Build",
|
||||
"command": "make",
|
||||
"type": "shell",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/rd7tf/"
|
||||
},
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "new",
|
||||
"focus": true
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Format",
|
||||
"command": "python ${workspaceFolder}/clang-format.py",
|
||||
"type": "shell",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/"
|
||||
},
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "new",
|
||||
"focus": true
|
||||
},
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
112
CHANGELOG.md
112
CHANGELOG.md
@ -1,112 +0,0 @@
|
||||
# RenderD7 Changelog
|
||||
## 0.9.5
|
||||
- Remove Npi Intro and NVID Api
|
||||
- Replace Toasts System with Message
|
||||
- Added GetTime
|
||||
- Move from Draw to Render2 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
|
||||
- Rewrite of RenderD7::Image
|
||||
- Internal Debugger/Database (IDB)
|
||||
- Removed BitmapPrinter
|
||||
- Added nimg and swr(render2nimg | SoftwareRender)
|
||||
- Removed Old Error/Message Handler
|
||||
- GetTextSize (extra buffer) + New TextShorter
|
||||
- Require specific FLAG for 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
|
||||
- Added Font class
|
||||
- Add LinearAllocator (for std)
|
||||
- Fix Crash in FilsSystem
|
||||
- Implement basic Theme System
|
||||
- Remove 0.9.4 Security
|
||||
- Tasks now based on std functional/thread
|
||||
- Add Network Support (Download Files, APi Requests)
|
||||
- Remove RD7TF
|
||||
- Add Cia Installer
|
||||
- Move from Init bool values to flags
|
||||
## 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
|
2566
Docs/Doxyfile
Normal file
2566
Docs/Doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
13
Docs/custom.css
Normal file
13
Docs/custom.css
Normal file
@ -0,0 +1,13 @@
|
||||
#projectlogo img{
|
||||
max-height: 70px;
|
||||
}
|
||||
img[src="logotype.svg"]{
|
||||
width:10cm;
|
||||
}
|
||||
div.contents{
|
||||
max-width: 85%;
|
||||
margin-left: 2%;
|
||||
}
|
||||
.textblock h1{
|
||||
border-bottom: 1px solid #666;
|
||||
}
|
695
LICENSE
695
LICENSE
@ -1,21 +1,674 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 tobid7
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
|
66
README.md
66
README.md
@ -1,61 +1,5 @@
|
||||
# <img alt="LOGO" src="https://dev.npid7.de/tobid7/RenderD7/raw/branch/main/logo.png" height="90">
|
||||
# RenderD7 as Submodule (0.9.5+)
|
||||
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 := -lcurl -lmbedtls -lmbedx509 -lmbedcrypto -lz -lm -lcitro2dd -lcitro3d -lctru
|
||||
```
|
||||
Now you need to add it to your sources and includes
|
||||
```
|
||||
SOURCES := source $(RENDERD7_SRC)
|
||||
INCLUDES := source $(RENDERD7_INC)
|
||||
```
|
||||
|
||||
Example from rd7tf
|
||||
### Installation (0.8.0-0.9.4) (OUTDATED)
|
||||
Download a Package From Releses Page
|
||||
`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
|
||||
`bzip2 -cd renderd7.tar.bz2 | tar -xf - -C path_to_your_libs`
|
||||
Finally put `-lrenderd7` to the First Place and add the path_to_your_libs
|
||||
```
|
||||
LIBS := -lrenderd7 -lcurl -lstdc++ -lm -lcitro2d -lcitro3d -lctru
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(PORTLIBS) $(CTRULIB) ../path_to_your_libs
|
||||
```
|
||||
Make sure that `-lrenderd7` is before `-lcitro2d`, `-lcitro3d`, `-lctru`.
|
||||
Here an example tree
|
||||
```
|
||||
Example-App
|
||||
├── gfx
|
||||
├── libs
|
||||
│ ├── include
|
||||
│ │ ├── rd7.hpp
|
||||
│ │ └── renderd7
|
||||
│ └── lib
|
||||
│ ├── librenderd7.a
|
||||
│ └── librenderd7d.a
|
||||
├── Makefile
|
||||
├── romfs
|
||||
│ └── gfx
|
||||
└── src
|
||||
└── main.cpp
|
||||
```
|
||||
# Credits
|
||||
- NPI-D7
|
||||
- Tobi-D7 Main Dev
|
||||
|
||||
Some Icons are From
|
||||
https://icons8.de/
|
||||
See Subfolder Readmes
|
||||
# RenderD7 030
|
||||
Simple and Easey to use UI and Graphics helper.
|
||||
|
||||
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
--atlas -f rgba -z auto
|
||||
|
||||
renderd7_logo/renderd7_logo.png
|
Binary file not shown.
Before Width: | Height: | Size: 17 KiB |
@ -1,27 +0,0 @@
|
||||
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('include')
|
||||
fmt_dir('include/renderd7')
|
||||
|
||||
# Format LE and TF as well
|
||||
fmt_dir('rd7tf/source')
|
||||
#fmt_dir('rd7le/source')
|
||||
print('Done')
|
@ -1,18 +0,0 @@
|
||||
<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>
|
||||
|
@ -1,18 +0,0 @@
|
||||
<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>
|
||||
|
@ -1,49 +0,0 @@
|
||||
: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);
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
title: RenderD7
|
||||
description:
|
||||
files:
|
||||
- "include/*.hpp"
|
||||
- "include/renderd7/*.hpp"
|
||||
- "include/renderd7/music/*.hpp"
|
||||
- "include/*.h"
|
||||
- "include/renderd7/*.h"
|
||||
- "include/renderd7/music/*.h"
|
@ -1,63 +0,0 @@
|
||||
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("// THIS FILE WAS GENERATED BY generate_assets.py!!!\n\n")
|
||||
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("// THIS FILE WAS GENERATED BY generate_assets.py!!!\n\n")
|
||||
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,19 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <renderd7/Allocator.hpp>
|
||||
#include <renderd7/Error.hpp>
|
||||
#include <renderd7/FileSystem.hpp>
|
||||
#include <renderd7/Hid.hpp>
|
||||
#include <renderd7/Image.hpp>
|
||||
#include <renderd7/Installer.hpp>
|
||||
#include <renderd7/Message.hpp>
|
||||
#include <renderd7/Net.hpp>
|
||||
#include <renderd7/Overlays.hpp>
|
||||
#include <renderd7/Sound.hpp>
|
||||
#include <renderd7/Timer.hpp>
|
||||
#include <renderd7/UI7.hpp>
|
||||
#include <renderd7/global_db.hpp>
|
||||
#include <renderd7/renderd7.hpp>
|
||||
#include <renderd7/swr.hpp>
|
||||
|
||||
namespace RD7 = RenderD7;
|
@ -1,40 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
#include <memory>
|
||||
#include <renderd7/Error.hpp>
|
||||
|
||||
// Write own LinearAllocator for learning
|
||||
|
||||
namespace RenderD7 {
|
||||
template <typename T>
|
||||
class LinearAllocator : public std::allocator<T> {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
|
||||
template <typename T1>
|
||||
struct rebind {
|
||||
typedef LinearAllocator<T1> other;
|
||||
};
|
||||
|
||||
pointer allocate(size_type n, const void* hint = nullptr) {
|
||||
if (n > this->max_size()) {
|
||||
RenderD7::Error(
|
||||
"Linear Allocator: \nBad Alloc -> size is larger than free space!");
|
||||
return nullptr;
|
||||
}
|
||||
return (pointer)linearAlloc(n * sizeof(T));
|
||||
}
|
||||
|
||||
void deallocate(pointer p, size_type) { linearFree((void*)p); }
|
||||
|
||||
size_type max_size() { return linearSpaceFree(); }
|
||||
|
||||
LinearAllocator() throw() {}
|
||||
LinearAllocator(const LinearAllocator<T>& a) throw() : std::allocator<T>(a) {}
|
||||
~LinearAllocator() throw() {}
|
||||
};
|
||||
} // namespace RenderD7
|
@ -1,204 +0,0 @@
|
||||
#pragma once
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#define UNPACK_RGBA(col) \
|
||||
(unsigned char)(col >> 24), (col >> 16), (col >> 8), (col)
|
||||
#define UNPACK_BGRA(col) \
|
||||
(unsigned char)(col >> 8), (col >> 16), (col >> 24), (col)
|
||||
|
||||
inline unsigned int RGBA8(unsigned char r, unsigned char g, unsigned char b,
|
||||
unsigned char a = 255) {
|
||||
return (r | g << 8 | b << 16 | a << 24);
|
||||
}
|
||||
|
||||
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, ///< Selector Color
|
||||
RD7Color_SelectorFade, ///< Selector FadingTo Color
|
||||
RD7Color_List0, ///< List Color1
|
||||
RD7Color_List1, ///< List Color2
|
||||
RD7Color_MessageBackground, ///< Message Background
|
||||
RD7Color_Button, ///< Button Color
|
||||
RD7Color_ButtonHovered, ///< Button Color if Hovered
|
||||
RD7Color_ButtonDisabled, ///< Button Color if disabled
|
||||
RD7Color_ButtonActive, ///< Button Colkor if Clicked
|
||||
RD7Color_Checkmark, ///< Checkbox Checkmark Color
|
||||
RD7Color_FrameBg, ///< Frame Background Color
|
||||
RD7Color_FrameBgHovered, ///< Frame Background Color if hovered
|
||||
RD7Color_Progressbar, ///< Progressbar Color
|
||||
/// NON COLOR ///
|
||||
RD7Color_Len, ///< Used to define the lengh of this list
|
||||
};
|
||||
|
||||
namespace RenderD7 {
|
||||
class Theme {
|
||||
public:
|
||||
Theme() = default;
|
||||
~Theme() = default;
|
||||
|
||||
void Load(const std::string &path);
|
||||
void Default();
|
||||
void Save(const std::string &path);
|
||||
|
||||
unsigned int Get(RD7Color clr);
|
||||
void Set(RD7Color clr, unsigned int v);
|
||||
void Swap(RD7Color a, RD7Color b);
|
||||
bool Undo();
|
||||
void UndoAll();
|
||||
void TextBy(RD7Color bg);
|
||||
RD7Color AutoText(RD7Color bg);
|
||||
void ClearHistory() { changes.clear(); }
|
||||
|
||||
std::vector<unsigned int> &GetTableRef() { return clr_tab; }
|
||||
// For Smart Pointer
|
||||
RD7_SMART_CTOR(Theme);
|
||||
|
||||
// Loader method
|
||||
void CopyOther(Theme::Ref theme);
|
||||
|
||||
private:
|
||||
struct change {
|
||||
change(RD7Color a, unsigned int f, unsigned int t)
|
||||
: clr(a), from(f), to(t) {}
|
||||
change(RD7Color a, RD7Color b, unsigned int f, unsigned int t)
|
||||
: clr(a), clr2(b), from(f), to(t) {}
|
||||
RD7Color clr;
|
||||
RD7Color clr2 = 0; // Used if Swap
|
||||
unsigned int from;
|
||||
unsigned int to;
|
||||
};
|
||||
// Use a vector for faster access
|
||||
std::vector<unsigned int> clr_tab;
|
||||
std::vector<change> changes;
|
||||
};
|
||||
|
||||
Theme::Ref ThemeActive();
|
||||
/// @brief Change Theme Adress
|
||||
/// @param theme your adress
|
||||
void ThemeSet(Theme::Ref theme);
|
||||
namespace Color {
|
||||
/// @brief RGBA Class
|
||||
class RGBA {
|
||||
public:
|
||||
/// @brief Construct
|
||||
/// @param r
|
||||
/// @param g
|
||||
/// @param b
|
||||
/// @param a
|
||||
RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 255)
|
||||
: 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) {
|
||||
if (!RenderD7::ThemeActive()) return;
|
||||
unsigned int col = RenderD7::ThemeActive()->Get(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
|
||||
/// @return color
|
||||
unsigned int toRGBA() const { return RGBA8(m_r, m_g, m_b, 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);
|
||||
}
|
||||
|
||||
unsigned char m_r = 0, m_g = 0, m_b = 0, m_a = 0;
|
||||
};
|
||||
std::string RGBA2Hex(unsigned int c32);
|
||||
/// @brief Convert RGB to Hex
|
||||
/// @param r
|
||||
/// @param g
|
||||
/// @param b
|
||||
/// @return Hex-String
|
||||
std::string RGB2Hex(int r, int g, int b);
|
||||
/// @brief Hex to U32
|
||||
/// @param color
|
||||
/// @param a
|
||||
/// @return Color32
|
||||
unsigned int Hex(const std::string &color, unsigned char a = 255);
|
||||
} // namespace Color
|
||||
} // namespace RenderD7
|
@ -1,18 +0,0 @@
|
||||
#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,24 +0,0 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace RenderD7 {
|
||||
namespace FileSystem {
|
||||
/// @brief A Directory Entry
|
||||
struct Entry {
|
||||
/// @brief Patf of The Entry
|
||||
std::string path;
|
||||
/// @brief Name of The Entry
|
||||
std::string name;
|
||||
/// @brief Directory or File
|
||||
bool dir = false;
|
||||
};
|
||||
/// @brief Gets All Entrys of A Directory into a Vector
|
||||
/// @param path The Path of the Directory
|
||||
/// @return The Vector of found Entrys
|
||||
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 RenderD7
|
@ -1,36 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <citro2d.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <renderd7/Error.hpp>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
|
||||
namespace RenderD7 {
|
||||
class Font {
|
||||
public:
|
||||
Font() = default;
|
||||
Font(const std::string& path) { Load(path); };
|
||||
~Font() { Unload(); }
|
||||
RD7_SMART_CTOR(Font)
|
||||
|
||||
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
|
@ -1,76 +0,0 @@
|
||||
#pragma once
|
||||
// Base includes
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
// 3ds does not support std::chrono
|
||||
#include <3ds.h>
|
||||
|
||||
/// @brief 3ds System Ticks per milli second
|
||||
#define TICKS_PER_MSEC 268111.856
|
||||
|
||||
#define f2s(x_) #x_
|
||||
#define scomb(x1, x2) std::string(x1 + x2)
|
||||
|
||||
namespace RenderD7 {
|
||||
namespace Ftrace {
|
||||
/// @brief Result of FTrace
|
||||
struct FTRes {
|
||||
std::string group; ///< Group of the Trace
|
||||
std::string func_name; ///< Function Name
|
||||
|
||||
uint64_t time_start; ///< when started
|
||||
uint64_t time_end; ///< when stopped
|
||||
float time_of; ///< stop - start (how long)
|
||||
float time_ofm; ///< max time off
|
||||
bool is_ovl; ///< is displayed in overlay?
|
||||
};
|
||||
|
||||
/// @brief Map of Traces
|
||||
extern std::map<std::string, RenderD7::Ftrace::FTRes> rd7_traces;
|
||||
|
||||
/// @brief Set a Start TracePoint
|
||||
/// @param group Set a Group Name
|
||||
/// @param func_name Set a Function Name
|
||||
inline void Beg(const std::string& group, const std::string& func_name) {
|
||||
std::string trace_id = scomb(group, func_name);
|
||||
auto& trace = rd7_traces[trace_id];
|
||||
trace.group = group;
|
||||
trace.func_name = func_name;
|
||||
trace.time_start = svcGetSystemTick();
|
||||
}
|
||||
/// @brief Set an End TracePoint
|
||||
/// @param group Set a Group Name
|
||||
/// @param func_name Set a Function Name
|
||||
inline void End(const std::string& group, const std::string& func_name) {
|
||||
std::string trace_id = scomb(group, func_name);
|
||||
auto& trace = rd7_traces[trace_id];
|
||||
trace.time_end = svcGetSystemTick();
|
||||
if (trace.time_of > trace.time_ofm) trace.time_ofm = trace.time_of;
|
||||
trace.time_of =
|
||||
static_cast<float>(trace.time_end - trace.time_start) / TICKS_PER_MSEC;
|
||||
}
|
||||
/// @brief Trace a function execution
|
||||
/// @param group Set a Group Name
|
||||
/// @param name Set a Function Name
|
||||
inline void Func(const std::string& group, const std::string& name,
|
||||
std::function<void()> fun) {
|
||||
if (!fun) return;
|
||||
Beg(group, name);
|
||||
fun();
|
||||
End(group, name);
|
||||
}
|
||||
|
||||
/// @brief This Starts an Ftrace and
|
||||
/// end ist when going out of scope
|
||||
struct ScopedTrace {
|
||||
ScopedTrace(std::string g, std::string n) : group(g), name(n) {
|
||||
Ftrace::Beg(g, n);
|
||||
}
|
||||
~ScopedTrace() { Ftrace::End(group, name); }
|
||||
std::string group;
|
||||
std::string name;
|
||||
};
|
||||
} // namespace Ftrace
|
||||
} // namespace RenderD7
|
@ -1,26 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace RenderD7 {
|
||||
namespace Hardware {
|
||||
/// @brief Initialisize required Services
|
||||
void Initialisize();
|
||||
/// @brief Check if Headphones are Plugged in
|
||||
/// @return true if headphones plugged in
|
||||
bool IsHeadphones();
|
||||
/// @brief Check if the 3ds Is Charging
|
||||
/// @return true if System gets Charged
|
||||
bool IsCharging();
|
||||
/// @brief Check the Battery Percentage
|
||||
/// @return Persentage as int
|
||||
int GetBatteryPercentage();
|
||||
/// @brief Get current State of 3d Slider
|
||||
/// @return current 3dslider poition
|
||||
float Get3dSliderLevel();
|
||||
/// @brief Get Current state of Sound Slider
|
||||
/// @return current SoundSlider state
|
||||
float GetSoundSliderLevel();
|
||||
/// @brief Get Current Wifi Level
|
||||
/// @return current wifi level
|
||||
int GetWifiLevel();
|
||||
} // namespace Hardware
|
||||
} // namespace RenderD7
|
@ -1,42 +0,0 @@
|
||||
// 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();
|
||||
R7Vec2 GetTouchDownPosition();
|
||||
void Update();
|
||||
// Lock/Unlock Input api for example for Keyboard
|
||||
void Lock();
|
||||
void Unlock();
|
||||
void Clear();
|
||||
} // namespace Hid
|
||||
} // namespace RenderD7
|
@ -1,33 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <3ds.h>
|
||||
#include <citro2d.h>
|
||||
|
||||
#include <renderd7/R7Vec.hpp>
|
||||
#include <renderd7/nimg.hpp>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace RenderD7 {
|
||||
class Image {
|
||||
public:
|
||||
Image() = default;
|
||||
Image(C2D_Image img) { this->img = img; }
|
||||
Image(const std::string& path) { this->Load(path); }
|
||||
~Image() = default;
|
||||
RD7_SMART_CTOR(Image)
|
||||
void Load(const std::string& path);
|
||||
void From_NIMG(const nimg& image);
|
||||
void Delete();
|
||||
|
||||
C2D_Image Get();
|
||||
C2D_Image& GetRef();
|
||||
void Set(const C2D_Image& i);
|
||||
R7Vec2 GetSize();
|
||||
bool Loadet();
|
||||
|
||||
private:
|
||||
bool ext = false;
|
||||
C2D_Image img;
|
||||
};
|
||||
} // namespace RenderD7
|
@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace RenderD7 {
|
||||
struct InstallerInfo {
|
||||
unsigned long long total;
|
||||
unsigned long long current;
|
||||
unsigned int mem_size = 0x80000;
|
||||
bool active = false;
|
||||
};
|
||||
Result InstallCia(const std::string& path, bool self);
|
||||
void InstallSetBuffersSize(unsigned int bytes);
|
||||
InstallerInfo InstallGetInfo();
|
||||
} // namespace RenderD7
|
@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
#include <fstream>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace RenderD7 {
|
||||
|
||||
/// @brief Logger base Class
|
||||
class LoggerBase {
|
||||
public:
|
||||
/// @brief Constructor
|
||||
LoggerBase() = default;
|
||||
/// @brief Deconstructor
|
||||
~LoggerBase();
|
||||
RD7_SMART_CTOR(LoggerBase)
|
||||
/// @brief Init the Logger
|
||||
/// @param filename name[_date_time.txt]
|
||||
void Init(const std::string& name, bool fileless = false);
|
||||
/// @brief Write a String
|
||||
/// @param debug_text string
|
||||
/// @param lvl Logger LVL 0 = ERR, 1 =WARNING, >=2= Default
|
||||
void Write(const std::string& debug_text, int lvl = 2);
|
||||
void SetLvl(int lvl) { writelvl = lvl; }
|
||||
const std::vector<std::string>& Lines();
|
||||
|
||||
private:
|
||||
/// \param filename the name of the logfile
|
||||
std::string filename;
|
||||
std::string log_path;
|
||||
std::ofstream _log;
|
||||
int writelvl = 1; // Only log errors/Warnings
|
||||
std::vector<std::string> lines;
|
||||
};
|
||||
} // namespace RenderD7
|
@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace RenderD7 {
|
||||
namespace Memory {
|
||||
/// @brief Metriks struct For the Internal Tracker
|
||||
struct memory_metrics {
|
||||
uint32_t t_TotalAllocated = 0; ///< Total Allocated Memory
|
||||
uint32_t t_TotalFreed = 0; ///< Total Deleted Memory
|
||||
/// @brief Gets the Currently Allocated Memory
|
||||
uint32_t t_CurrentlyAllocated() { return t_TotalAllocated - t_TotalFreed; }
|
||||
};
|
||||
/// @brief Get Total Allocated Memory
|
||||
/// @return Total Allocated Memory
|
||||
size_t GetTotalAllocated();
|
||||
/// @brief Get Total Deleted Memory
|
||||
/// @return Total Deleted Memory
|
||||
size_t GetTotalFreed();
|
||||
/// @brief Get Current Allocated Memory
|
||||
/// @return Current Allocated Memory
|
||||
size_t GetCurrent();
|
||||
} // namespace Memory
|
||||
} // namespace RenderD7
|
@ -1,27 +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);
|
||||
inline void PushMessage(const std::string& head, const std::string& msg) {
|
||||
PushMessage(Message(head, msg));
|
||||
}
|
||||
// Config
|
||||
void SetMessageIdleStartFrame(int frame);
|
||||
void SetMessageTotalAnimationFrames(int total_frames);
|
||||
void SetMessageFadeOutStartFrame(int frame);
|
||||
} // namespace RenderD7
|
@ -1,42 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <renderd7/external/json.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace RenderD7 {
|
||||
namespace Net {
|
||||
// Define List of Errors
|
||||
enum Error_ {
|
||||
Error_None, // Function Executed Successfully
|
||||
Error_Memory, // Memory Allocation Error
|
||||
Error_Write, // Unable to Write File
|
||||
Error_StatusCode, // Error with Status Code
|
||||
Error_Git, // Git Error
|
||||
Error_CtrStatus, // 3ds Result Code
|
||||
Error_Curl, // Curl Error
|
||||
Error_Busy, // Another Download Taskl is already running
|
||||
Error_Invalid, // Invalid Json struct
|
||||
Error_NoWifi, // Console not connected to wifi
|
||||
};
|
||||
// Set an typedefine for Error code
|
||||
using Error = unsigned long long;
|
||||
// Extract Error_ from Error code
|
||||
inline Error_ ErrorCode(Error err) {
|
||||
return static_cast<Error_>(static_cast<unsigned int>(err & 0xffffffff));
|
||||
}
|
||||
// Extract Http Status code, Curl Error Code or Ctr Result Code
|
||||
inline int StatusCode(Error err) {
|
||||
Error_ c = ErrorCode(err);
|
||||
if (c != Error_StatusCode && c != Error_CtrStatus && c != Error_Curl)
|
||||
return 0;
|
||||
return static_cast<unsigned int>(err >> 32);
|
||||
}
|
||||
Error Download(const std::string& url, std::string& data);
|
||||
Error Download2File(const std::string& url, const std::string& path);
|
||||
Error GitDownloadRelease(const std::string& url, const std::string& asset_name,
|
||||
const std::string& path, bool prerelease = false);
|
||||
Error JsonApiRequest(const std::string& api_url, nlohmann::json& res);
|
||||
unsigned long long GetProgressCurrent();
|
||||
unsigned long long GetProgressTotal();
|
||||
} // namespace Net
|
||||
} // namespace RenderD7
|
@ -1,85 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <renderd7/Ovl.hpp>
|
||||
#include <string>
|
||||
|
||||
typedef int RD7Keyboard;
|
||||
|
||||
enum RD7Keyboard_ {
|
||||
RD7Keyboard_Default,
|
||||
RD7Keyboard_Numpad,
|
||||
RD7Keyboard_Password,
|
||||
};
|
||||
|
||||
enum RD7KeyboardState {
|
||||
RD7KeyboardState_None = 0,
|
||||
RD7KeyboardState_Cancel = 1,
|
||||
RD7KeyboardState_Confirm = 2,
|
||||
};
|
||||
|
||||
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;
|
||||
mutable std::string mt_mem;
|
||||
|
||||
// Importand Adresses
|
||||
bool* i_is_enabled;
|
||||
bool* i_screen;
|
||||
uint32_t* i_mt_color;
|
||||
uint32_t* i_txt_color;
|
||||
float* i_txt_size;
|
||||
};
|
||||
|
||||
class Ovl_Keyboard : public RenderD7::Ovl {
|
||||
public:
|
||||
/// @brief Constructor
|
||||
/// Keyboard Type not Supported for now
|
||||
Ovl_Keyboard(std::string& ref, RD7KeyboardState& state,
|
||||
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;
|
||||
RD7KeyboardState* state;
|
||||
RD7Keyboard type;
|
||||
int mode = 0;
|
||||
int ft3 = 0;
|
||||
};
|
||||
} // namespace RenderD7
|
@ -1,28 +0,0 @@
|
||||
#pragma once
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
namespace RenderD7 {
|
||||
/// @brief The Overlay Class (Used for Toasts for example)
|
||||
class Ovl {
|
||||
public:
|
||||
/// @brief Deconstructor
|
||||
virtual ~Ovl() {}
|
||||
/// @brief Function Called to Draw this
|
||||
virtual void Draw() const = 0;
|
||||
/// @brief Logic of the Overlay
|
||||
virtual void Logic() = 0;
|
||||
/// @brief Should the overlay be killed
|
||||
/// @return Killed or Not
|
||||
inline bool IsKilled() { return this->iskilled; }
|
||||
/// @brief Kill The Overlay
|
||||
inline void Kill() { iskilled = true; }
|
||||
|
||||
private:
|
||||
/// @param iskilled For IsKilled();
|
||||
bool iskilled = false;
|
||||
};
|
||||
/// @brief Add an Overlay to the Screen
|
||||
/// @param scene Overlay to push to Screen
|
||||
void AddOvl(std::unique_ptr<RenderD7::Ovl> scene);
|
||||
} // namespace RenderD7
|
@ -1,104 +0,0 @@
|
||||
#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;
|
||||
};
|
||||
|
||||
struct R7Vec4 {
|
||||
// Init Funcs
|
||||
R7Vec4() : x(0), y(0), z(0), w(0) {}
|
||||
R7Vec4(float i0, float i1, float i2, float i3) : x(i0), y(i1), z(i2), w(i3) {}
|
||||
R7Vec4(const R7Vec4 &i) {
|
||||
x = i.x;
|
||||
y = i.y;
|
||||
z = i.z;
|
||||
w = i.w;
|
||||
}
|
||||
|
||||
R7Vec4(const R7Vec2 &i0, const R7Vec2 &i1) {
|
||||
x = i0.x;
|
||||
y = i0.y;
|
||||
z = i1.x;
|
||||
w = i1.y;
|
||||
}
|
||||
|
||||
// Operators
|
||||
// Add
|
||||
R7Vec4 &operator+=(const R7Vec4 &i) {
|
||||
x += i.x;
|
||||
y += i.y;
|
||||
z += i.z;
|
||||
w += i.w;
|
||||
return *this;
|
||||
}
|
||||
|
||||
R7Vec4 operator+(const R7Vec4 &i) const {
|
||||
return R7Vec4(x + i.x, y + i.y, z + i.z, w + i.w);
|
||||
}
|
||||
|
||||
// Sub
|
||||
R7Vec4 &operator-=(const R7Vec4 &i) {
|
||||
x -= i.x;
|
||||
y -= i.y;
|
||||
z -= i.z;
|
||||
w -= i.w;
|
||||
return *this;
|
||||
}
|
||||
|
||||
R7Vec4 operator-(const R7Vec4 &i) const {
|
||||
return R7Vec4(x - i.x, y - i.y, z - i.z, w - i.w);
|
||||
}
|
||||
|
||||
// Compare
|
||||
bool operator==(const R7Vec4 &in) const {
|
||||
return x == in.x && y == in.y && z == in.z && w == in.w;
|
||||
}
|
||||
|
||||
bool operator!=(const R7Vec4 &in) const {
|
||||
// use the first comparefuncs result
|
||||
// and swap it lol
|
||||
return !(*this == in);
|
||||
}
|
||||
// Internal Values
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float w;
|
||||
};
|
@ -1,97 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <renderd7/Color.hpp>
|
||||
#include <renderd7/Font.hpp>
|
||||
#include <renderd7/Image.hpp>
|
||||
#include <renderd7/R7Vec.hpp>
|
||||
#include <renderd7/Sprite.hpp>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
|
||||
#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),
|
||||
};
|
||||
|
||||
enum R2Screen {
|
||||
R2Screen_Bottom,
|
||||
R2Screen_Top,
|
||||
// TopRight,
|
||||
};
|
||||
|
||||
namespace RenderD7 {
|
||||
class R2 {
|
||||
public:
|
||||
struct R2Cmd {
|
||||
R7Vec2 pos; //< Position
|
||||
R7Vec2 pszs; //< Position or (TextBox) Size
|
||||
R7Vec2 ap; //< Additional Pos
|
||||
unsigned int clr; //< Color
|
||||
bool Screen; //< TopScreen
|
||||
Image::Ref img; //< Image Reference
|
||||
Sprite::Ref spr; //< Sprite Reference
|
||||
// 0 = skip, 1 = rect, 2 = tri, 3 = text,
|
||||
// 4 = image, 5 = sprite, 6 = Line
|
||||
int type; //< Command Type
|
||||
bool lined = false; //< Draw Lined Rect/Tri
|
||||
// Text Specific
|
||||
RD7TextFlags flags; // Text Flags
|
||||
std::string text; // Text
|
||||
RD7_SMART_CTOR(R2Cmd)
|
||||
};
|
||||
R2() = default;
|
||||
~R2() = default;
|
||||
|
||||
static void Init();
|
||||
|
||||
// Settings
|
||||
static void SetFont(Font::Ref fnt);
|
||||
static Font::Ref GetFont();
|
||||
static void DefaultFont();
|
||||
static void DrawNextLined();
|
||||
static void OnScreen(R2Screen screen);
|
||||
static R2Screen GetCurrentScreen();
|
||||
static void SetTextSize(float szs);
|
||||
static void DefaultTextSize();
|
||||
static float GetTextSize();
|
||||
static R7Vec2 GetCurrentScreenSize();
|
||||
// Processing
|
||||
static void Process();
|
||||
static R7Vec2 GetTextDimensions(const std::string& text);
|
||||
static std::string WrapText(const std ::string& in, int maxlen);
|
||||
static std::string ShortText(const std::string& in, int maxlen);
|
||||
// Draw Functions
|
||||
static void AddRect(R7Vec2 pos, R7Vec2 size, RD7Color clr);
|
||||
static void AddRect(R7Vec2 pos, R7Vec2 size, unsigned int clr);
|
||||
static void AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, RD7Color clr);
|
||||
static void AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2,
|
||||
unsigned int clr);
|
||||
static void AddText(R7Vec2 pos, const std::string& text, RD7Color clr,
|
||||
RD7TextFlags flags = 0, R7Vec2 tmb = R7Vec2());
|
||||
static void AddText(R7Vec2 pos, const std::string& text, unsigned int clr,
|
||||
RD7TextFlags flags = 0, R7Vec2 tmb = R7Vec2());
|
||||
static void AddImage(R7Vec2 pos, Image::Ref img);
|
||||
static void AddSprite(Sprite::Ref spr);
|
||||
static void AddLine(R7Vec2 pos_a, R7Vec2 pos_b, RD7Color clr, int t = 1);
|
||||
static void AddLine(R7Vec2 pos_a, R7Vec2 pos_b, unsigned int clr, int t = 1);
|
||||
|
||||
private:
|
||||
static const float default_text_size;
|
||||
static float text_size;
|
||||
static Font::Ref font;
|
||||
static std::map<std::string, float> ts;
|
||||
static std::map<std::string, int> mln;
|
||||
static bool next_lined;
|
||||
static std::vector<R2Cmd::Ref> commands;
|
||||
static R2Screen current_screen;
|
||||
};
|
||||
} // namespace RenderD7
|
@ -1,54 +0,0 @@
|
||||
#pragma once
|
||||
#include <3ds.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace RenderD7 {
|
||||
/// @brief Decoder for 3ds Result Codes
|
||||
class ResultDecoder {
|
||||
public:
|
||||
/// @brief Constructor
|
||||
ResultDecoder() {}
|
||||
/// @brief Deconstructor
|
||||
~ResultDecoder() {}
|
||||
/// @brief Load a Result into Decoder
|
||||
/// @param rescode Result Code
|
||||
void Load(Result rescode);
|
||||
/// @brief Load A Hex Converted Code into Decoder
|
||||
/// @param rescode Result-Hex Code
|
||||
void Load(std::string rescode);
|
||||
/// @brief Get Hex Code
|
||||
/// @return Hex-Code
|
||||
std::string GetCode();
|
||||
/// @brief Get Level Name
|
||||
/// @return Level Name
|
||||
std::string GetLevel();
|
||||
/// @brief Get Level Value
|
||||
/// @return Level Value
|
||||
int GetLevelInt();
|
||||
/// @brief Get The Mosule Name
|
||||
/// @return Module Name
|
||||
std::string GetModule();
|
||||
/// @brief Get The Module Value
|
||||
/// @return Module Value
|
||||
int GetModuleInt();
|
||||
/// @brief Get The Description
|
||||
/// @return Description
|
||||
std::string GetDescription();
|
||||
/// @brief Get The Description Valur
|
||||
/// @return Description Value
|
||||
int GetDescriptionInt();
|
||||
/// @brief Get the Summary
|
||||
/// @return Summary
|
||||
std::string GetSummary();
|
||||
/// @brief Get the Summary Value
|
||||
/// @return Summary Value
|
||||
int GetSummaryInt();
|
||||
/// @brief Write a Result log file to sd
|
||||
void WriteLog(void);
|
||||
|
||||
private:
|
||||
/// @param m_rescode Result code
|
||||
Result m_rescode;
|
||||
};
|
||||
} // namespace RenderD7
|
@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
#include <3ds.h> // Result
|
||||
#include <citro2d.h>
|
||||
#include <citro3d.h>
|
||||
|
||||
#include <renderd7/Image.hpp>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace RenderD7 {
|
||||
/// @brief SpriteSheet Class
|
||||
class Sheet {
|
||||
public:
|
||||
/// @brief Constructor
|
||||
Sheet() = default;
|
||||
Sheet(const std::string& path) { this->Load(path); }
|
||||
/// @brief Deconstructor
|
||||
~Sheet() {
|
||||
if (spritesheet) Free();
|
||||
}
|
||||
RD7_SMART_CTOR(Sheet);
|
||||
/// @brief Load A Spritesheet File
|
||||
/// @param path Path to the t3x
|
||||
/// @return Result Code
|
||||
Result Load(const std::string& path);
|
||||
/// @brief Unload the Sheet
|
||||
void Free();
|
||||
C2D_Image GetImage(int idx);
|
||||
C2D_SpriteSheet Get() { return this->spritesheet; }
|
||||
|
||||
private:
|
||||
/// \param spritesheet The Sheet
|
||||
C2D_SpriteSheet spritesheet;
|
||||
};
|
||||
} // namespace RenderD7
|
@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace RenderD7 {
|
||||
/** Sound Class */
|
||||
class Sound {
|
||||
public:
|
||||
/// \brief Construct new Soundeffect
|
||||
/// \param path Path to the .wav file
|
||||
/// \param channel the channel 1-23
|
||||
/// \param toloop true:loop the sound, false: don't loop
|
||||
Sound(const std::string &path, int channel = 1, bool toloop = false);
|
||||
/// @brief Deconstructor
|
||||
~Sound();
|
||||
RD7_SMART_CTOR(Sound)
|
||||
/// @brief Play the sound
|
||||
void Play();
|
||||
/// @brief Stop the sound
|
||||
void Stop();
|
||||
|
||||
private:
|
||||
/// \param dataSize Size of the filedata
|
||||
u32 dataSize;
|
||||
/// \param waveBuf For ndsp
|
||||
ndspWaveBuf waveBuf;
|
||||
/// \param data Memmory data of the sound
|
||||
uint8_t *data = NULL;
|
||||
/// \param chnl Channel of the sound
|
||||
int chnl;
|
||||
};
|
||||
} // namespace RenderD7
|
@ -1,71 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <citro2d.h>
|
||||
#include <citro3d.h>
|
||||
|
||||
#include <renderd7/Image.hpp>
|
||||
#include <renderd7/Sheet.hpp>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
|
||||
namespace RenderD7 {
|
||||
/// @brief Sprite Class
|
||||
class Sprite {
|
||||
public:
|
||||
/// \brief Construct Sprite
|
||||
Sprite() = default;
|
||||
/// \brief Deconstruct Sprite
|
||||
~Sprite() = default;
|
||||
RD7_SMART_CTOR(Sprite)
|
||||
/// \brief Load a Sprite From SpriteSheet
|
||||
/// \param sheet the Sheet to load from.(RenderD7::Sheet)
|
||||
/// \param index the number of the Sprite in the Sheet
|
||||
void FromSheet(RenderD7::Sheet::Ref sheet, size_t index);
|
||||
/// \brief Load a Sprite From SpriteSheet
|
||||
/// \param img the Image to load from.(RenderD7::Image)
|
||||
void FromImage(RenderD7::Image::Ref img);
|
||||
/// @brief Draw the Sprite
|
||||
/// @return success ?
|
||||
bool Draw();
|
||||
/// @brief Set the Center Position
|
||||
/// @param x X Pos
|
||||
/// @param y Y Pos
|
||||
void SetCenter(float x, float y);
|
||||
/// @brief Set the Sprite's Position
|
||||
/// @param x X Pos
|
||||
/// @param y Y Pos
|
||||
void SetPos(float x, float y);
|
||||
/// @brief Set The Sprite's Scale
|
||||
/// @param x Scale on X-Axis
|
||||
/// @param y Scale on Y-Axis
|
||||
void SetScale(float x, float y);
|
||||
/// @brief Set the Sprite's Rotation
|
||||
/// @param rotation ratation
|
||||
void SetRotation(float rotation);
|
||||
/// @brief Rotate the Sprite
|
||||
/// @param speed Speed to Rotate
|
||||
void Rotate(float speed);
|
||||
/// @brief Get Tje Sprite's Width
|
||||
/// @return Width
|
||||
float GetWidth();
|
||||
/// @brief Get the Sprite's Height
|
||||
/// @return Height
|
||||
float GetHeight();
|
||||
/// @brief Get The Sprite's X Position
|
||||
/// @return X Position
|
||||
float GetPosX();
|
||||
/// @brief Get the Sprite's Y Position
|
||||
/// @return Y Position
|
||||
float GetPosY();
|
||||
R7Vec2 GetSize();
|
||||
R7Vec2 GetPos();
|
||||
void SetPos(R7Vec2 pos);
|
||||
void SetScale(R7Vec2 scale);
|
||||
void SetRotCenter(R7Vec2 percentage);
|
||||
|
||||
private:
|
||||
/// @param tint ImageTint (unused)
|
||||
C2D_ImageTint tint;
|
||||
/// @param sprite The Sprite
|
||||
C2D_Sprite sprite;
|
||||
};
|
||||
} // namespace RenderD7
|
@ -1,43 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <citro2d.h>
|
||||
#include <citro3d.h>
|
||||
|
||||
#include <renderd7/Sheet.hpp>
|
||||
#include <renderd7/Sprite.hpp>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
|
||||
namespace RenderD7 {
|
||||
/// @brief SpriteSheetAnimation Class
|
||||
class SpriteSheetAnimation : public RenderD7::Sprite {
|
||||
public:
|
||||
/// @brief Constructor
|
||||
SpriteSheetAnimation() = default;
|
||||
/// @brief Deconstructor
|
||||
~SpriteSheetAnimation() = default;
|
||||
RD7_SMART_CTOR(SpriteSheetAnimation);
|
||||
/// @brief Setup an Animation
|
||||
/// @param sheet Input Spritesheet
|
||||
/// @param imagecount Count of Images
|
||||
/// @param startimage Where to Start the Loop
|
||||
/// @param frame_begin Current Time (Should be 0)
|
||||
/// @param frame_finish Time Length
|
||||
void Setup(RenderD7::Sheet::Ref sheet, size_t imagecount, size_t startimage,
|
||||
float frame_begin, float frame_finish);
|
||||
/// @brief Play the Animation
|
||||
/// @param timespeed Speed of the animation
|
||||
void Play(float timespeed);
|
||||
|
||||
private:
|
||||
/// @param images Count of Images
|
||||
size_t images;
|
||||
/// @param imgs Another Count of images ???
|
||||
size_t imgs = 0;
|
||||
/// @param D_totaltime Current Time
|
||||
float D_totaltime;
|
||||
/// @param sheet The Sheet of Images
|
||||
RenderD7::Sheet::Ref sheet;
|
||||
/// @param time Total Time from frame_finish
|
||||
float time;
|
||||
};
|
||||
} // namespace RenderD7
|
@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
#include <functional>
|
||||
|
||||
namespace RenderD7 {
|
||||
namespace Tasks {
|
||||
/// @brief Push A Task
|
||||
/// @param fun Function of Your Task
|
||||
/// @return index
|
||||
int Create(std::function<void()> fun);
|
||||
/// @brief Destroy all Tasks
|
||||
void DestroyAll();
|
||||
} // namespace Tasks
|
||||
} // namespace RenderD7
|
@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <renderd7/renderd7.hpp>
|
||||
|
||||
namespace RenderD7 {
|
||||
class ThemeEditor : public RenderD7::Scene {
|
||||
public:
|
||||
ThemeEditor();
|
||||
~ThemeEditor();
|
||||
|
||||
void Draw(void) const override;
|
||||
void Logic() override;
|
||||
|
||||
private:
|
||||
Theme::Ref edit_theme;
|
||||
// Placeholder to save active one to
|
||||
Theme::Ref temp_theme;
|
||||
|
||||
// temp vars for samples
|
||||
mutable bool cm;
|
||||
mutable std::string inpt;
|
||||
mutable int menu = 0;
|
||||
|
||||
// Keyboard
|
||||
mutable RD7KeyboardState kbd_state;
|
||||
mutable std::string kbd_text;
|
||||
mutable std::vector<std::string> theme_list;
|
||||
};
|
||||
} // namespace RenderD7
|
@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
namespace RenderD7 {
|
||||
/// @brief Format a String
|
||||
/// @param fmt_str Format To
|
||||
/// @param ... Additional Args
|
||||
/// @return Formatted String
|
||||
std::string FormatString(std::string fmt_str, ...);
|
||||
/// @brief Get Current Time as String
|
||||
/// @return Time-String
|
||||
std::string GetTimeStr(void);
|
||||
} // namespace RenderD7
|
@ -1,26 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
|
||||
namespace RenderD7 {
|
||||
class Timer {
|
||||
public:
|
||||
Timer(bool autostart = true);
|
||||
~Timer() {}
|
||||
RD7_SMART_CTOR(Timer)
|
||||
void Reset();
|
||||
void Tick();
|
||||
void Pause();
|
||||
void Resume();
|
||||
float Get();
|
||||
float GetLive();
|
||||
bool Running();
|
||||
|
||||
private:
|
||||
uint64_t last = 0;
|
||||
uint64_t current = 0;
|
||||
bool is_running = false;
|
||||
};
|
||||
} // namespace RenderD7
|
@ -1,105 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <renderd7/Image.hpp>
|
||||
#include <renderd7/R7Vec.hpp>
|
||||
#include <renderd7/Render2.hpp>
|
||||
#include <renderd7/smart_ctor.hpp>
|
||||
|
||||
// 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),
|
||||
UI7MenuFlags_Scrolling = MAKEFLAG(2),
|
||||
};
|
||||
|
||||
class DrawCmd;
|
||||
class UI7DrawList {
|
||||
public:
|
||||
UI7DrawList() = default;
|
||||
~UI7DrawList() = default;
|
||||
|
||||
void AddRectangle(R7Vec2 pos, R7Vec2 szs, RD7Color clr);
|
||||
void AddRectangle(R7Vec2 pos, R7Vec2 szs, unsigned int clr);
|
||||
void AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, RD7Color clr);
|
||||
void AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int clr);
|
||||
void AddText(R7Vec2 pos, const std::string &text, RD7Color clr,
|
||||
RD7TextFlags flags = 0, R7Vec2 box = R7Vec2());
|
||||
void AddText(R7Vec2 pos, const std::string &text, unsigned int clr,
|
||||
RD7TextFlags flags = 0, R7Vec2 box = R7Vec2());
|
||||
void AddImage(R7Vec2 pos, RenderD7::Image::Ref img);
|
||||
void AddCall(std::shared_ptr<DrawCmd> cmd);
|
||||
|
||||
void Process(bool auto_clear = true);
|
||||
void Clear();
|
||||
|
||||
RD7_SMART_CTOR(UI7DrawList)
|
||||
|
||||
private:
|
||||
void AddDebugCall(std::shared_ptr<DrawCmd> cmd);
|
||||
std::vector<std::shared_ptr<DrawCmd>> list;
|
||||
};
|
||||
|
||||
namespace UI7 {
|
||||
// Key functions
|
||||
void Init();
|
||||
void Deinit();
|
||||
void Update();
|
||||
float GetTime();
|
||||
float GetDeltaTime();
|
||||
bool &IsDebugging();
|
||||
// Internal Function
|
||||
// Should not be used
|
||||
void Debug();
|
||||
bool &DebugMenu();
|
||||
|
||||
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::Ref 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, const R7Vec2 &entry_size,
|
||||
void (*display_func)(void *, R7Vec2), void **data_array,
|
||||
size_t num_entrys);
|
||||
void ColorSelector(const std::string &label, unsigned int &color);
|
||||
bool BeginTree(const std::string &text);
|
||||
void EndTree();
|
||||
R7Vec2 GetCursorPos();
|
||||
void SetCursorPos(R7Vec2 cp);
|
||||
void RestoreCursor();
|
||||
void SameLine();
|
||||
// Internal API (For Creating Custom Objects)
|
||||
bool InBox(R7Vec2 inpos, R7Vec2 boxpos, R7Vec2 boxsize);
|
||||
void MoveCursor(R7Vec2 size);
|
||||
bool HandleScrolling(R7Vec2 &pos, R7Vec2 size);
|
||||
bool InMenu();
|
||||
namespace Menu {
|
||||
// All of them return the Main BG DrawList if Menu is null
|
||||
UI7DrawList::Ref GetBackgroundList();
|
||||
UI7DrawList::Ref GetList();
|
||||
UI7DrawList::Ref GetForegroundList();
|
||||
// Other Menu Specific Functions
|
||||
float GetScrollingOffset();
|
||||
void SetScrollingOffset(float off);
|
||||
bool IsScrolling();
|
||||
} // namespace Menu
|
||||
// DrawLists
|
||||
UI7DrawList::Ref GetForegroundList();
|
||||
UI7DrawList::Ref GetBackgroundList();
|
||||
} // namespace UI7
|
25447
include/renderd7/external/json.hpp
vendored
25447
include/renderd7/external/json.hpp
vendored
File diff suppressed because it is too large
Load Diff
8681
include/renderd7/external/stb_image.h
vendored
8681
include/renderd7/external/stb_image.h
vendored
File diff suppressed because it is too large
Load Diff
2054
include/renderd7/external/stb_image_write.h
vendored
2054
include/renderd7/external/stb_image_write.h
vendored
File diff suppressed because it is too large
Load Diff
5636
include/renderd7/external/stb_truetype.h
vendored
5636
include/renderd7/external/stb_truetype.h
vendored
File diff suppressed because it is too large
Load Diff
@ -1,38 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <renderd7/external/json.hpp>
|
||||
#include <renderd7/renderd7.hpp>
|
||||
|
||||
namespace RenderD7 {
|
||||
namespace IDB {
|
||||
void Start();
|
||||
void Stop();
|
||||
void Restart();
|
||||
} // namespace IDB
|
||||
} // namespace RenderD7
|
||||
|
||||
using RD7Flags = int;
|
||||
enum RD7Flags_ {
|
||||
RD7Flags_None = 0,
|
||||
RD7Flags_MemTrack = 1 << 0,
|
||||
RD7Flags_SceneSystem = 1 << 1,
|
||||
RD7Flags_ShowSplash = 1 << 2,
|
||||
RD7Flags_Default = RD7Flags_SceneSystem,
|
||||
};
|
||||
|
||||
// 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;
|
||||
|
||||
// Modern Global Api
|
||||
extern int rd7_max_objects;
|
||||
extern C3D_RenderTarget *rd7_top;
|
||||
extern C3D_RenderTarget *rd7_top_right;
|
||||
extern C3D_RenderTarget *rd7_bottom;
|
||||
extern RD7Flags rd7_flags;
|
||||
|
||||
// Draw2
|
||||
extern float rd7_draw2_tsm;
|
@ -1,70 +0,0 @@
|
||||
#pragma once
|
||||
#include <renderd7/Net.hpp>
|
||||
#include <renderd7/external/json.hpp>
|
||||
#include <renderd7/global_db.hpp>
|
||||
#include <renderd7/renderd7.hpp>
|
||||
|
||||
#define CFGVER "1"
|
||||
#define THEMEVER "0"
|
||||
|
||||
#ifndef V_RD7BTIME
|
||||
#define V_RD7BTIME "SUBMODULE"
|
||||
#endif
|
||||
#ifndef V_RD7CSTRING
|
||||
#define V_RD7CSTRING "SUBMODULE"
|
||||
#endif
|
||||
|
||||
// Base
|
||||
extern bool rd7i_do_splash;
|
||||
extern bool rd7i_enable_scene_system;
|
||||
extern bool rd7i_debugging;
|
||||
extern bool rd7i_enable_memtrack;
|
||||
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 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;
|
||||
extern void* rd7i_soc_buf;
|
||||
extern bool rd7i_is_am_init;
|
||||
extern RenderD7::Theme::Ref rd7i_active_theme;
|
||||
extern bool rd7i_lggrf;
|
||||
|
||||
// Use function for protection
|
||||
RenderD7::LoggerBase::Ref _rd7i_logger();
|
||||
RenderD7::Net::Error rd7i_soc_init();
|
||||
void rd7i_soc_deinit();
|
@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
// clang-format off
|
||||
#include <string>
|
||||
#include <renderd7/external/json.hpp>
|
||||
// clang-format on
|
||||
|
||||
namespace RenderD7 {
|
||||
namespace Lang {
|
||||
/// @brief Get 3ds System lang! [en] by default
|
||||
/// @return Sytemlang as string
|
||||
std::string GetSys();
|
||||
/// @brief Get The Translation String
|
||||
/// @param key Key of Translation
|
||||
/// @return The Translated String
|
||||
std::string Get(const std::string &key);
|
||||
/// @brief Load A Language json
|
||||
/// @param lang The Language Key [en], [de], etc, or getSys()
|
||||
void Load(const std::string &lang);
|
||||
// New funcs
|
||||
std::string GetName();
|
||||
std::string GetAuthor();
|
||||
std::string GetShortcut();
|
||||
} // namespace Lang
|
||||
} // namespace RenderD7
|
@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#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
|
@ -1,134 +0,0 @@
|
||||
#pragma once
|
||||
#include <tuple>
|
||||
|
||||
namespace RenderD7 {
|
||||
class Parameter {
|
||||
private:
|
||||
using id = size_t;
|
||||
|
||||
template <typename T>
|
||||
struct type {
|
||||
static void id() {}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
static id type_id() {
|
||||
return reinterpret_cast<id>(&type<T>::id);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
using decay = typename std::decay<T>::type;
|
||||
|
||||
template <typename T>
|
||||
using none =
|
||||
typename std::enable_if<!std::is_same<Parameter, T>::value>::type;
|
||||
|
||||
struct base {
|
||||
virtual ~base() {}
|
||||
virtual bool is(id) const = 0;
|
||||
virtual base *copy() const = 0;
|
||||
} *p = nullptr;
|
||||
|
||||
template <typename T>
|
||||
struct data : base, std::tuple<T> {
|
||||
using std::tuple<T>::tuple;
|
||||
|
||||
T &get() & { return std::get<0>(*this); }
|
||||
T const &get() const & { return std::get<0>(*this); }
|
||||
|
||||
bool is(id i) const override { return i == type_id<T>(); }
|
||||
base *copy() const override { return new data{get()}; }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
T &stat() {
|
||||
return static_cast<data<T> &>(*p).get();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T const &stat() const {
|
||||
return static_cast<data<T> const &>(*p).get();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T &dyn() {
|
||||
return dynamic_cast<data<T> &>(*p).get();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T const &dyn() const {
|
||||
return dynamic_cast<data<T> const &>(*p).get();
|
||||
}
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Default constructor
|
||||
*/
|
||||
Parameter() {}
|
||||
|
||||
/**
|
||||
* @brief Destructs the Parameter
|
||||
*/
|
||||
~Parameter() { delete p; }
|
||||
|
||||
/**
|
||||
* @brief Copy constructor
|
||||
* @param s The Parameter to copy
|
||||
*/
|
||||
Parameter(Parameter &&s) : p{s.p} { s.p = nullptr; }
|
||||
|
||||
/**
|
||||
* @brief Const copy constructor
|
||||
* @param s The Parameter to copy
|
||||
*/
|
||||
Parameter(Parameter const &s) : p{s.p->copy()} {}
|
||||
|
||||
/**
|
||||
* @brief Initializes the Parameter with the given value
|
||||
* @param x The value to initialize the Parameter with
|
||||
*/
|
||||
template <typename T, typename U = decay<T>, typename = none<U>>
|
||||
Parameter(T &&x) : p{new data<U>{std::forward<T>(x)}} {}
|
||||
|
||||
/**
|
||||
* @brief Overloads the assignment operator
|
||||
* @param s The value to set the Parameter to
|
||||
*/
|
||||
Parameter &operator=(Parameter s) {
|
||||
swap(*this, s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend void swap(Parameter &s, Parameter &r) { std::swap(s.p, r.p); }
|
||||
|
||||
/**
|
||||
* @brief Clears the Parameter
|
||||
*/
|
||||
void clear() {
|
||||
delete p;
|
||||
p = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks whether the Parameter is the given type
|
||||
* @tparam T The type to check
|
||||
* @return Whether the Parameter has the given type or not
|
||||
*/
|
||||
template <typename T>
|
||||
bool is() const {
|
||||
return p ? p->is(type_id<T>()) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the value of the Parameter
|
||||
* @tparam T The type of the Parameter
|
||||
* @return The value of the Parameter
|
||||
* @warning If the type of the Parameter doesn't match the type of it's stored
|
||||
* value, it will result in undefined behaviour.
|
||||
*/
|
||||
template <typename T>
|
||||
T &get() & {
|
||||
return stat<T>();
|
||||
}
|
||||
};
|
||||
} // namespace RenderD7
|
@ -1,196 +0,0 @@
|
||||
#pragma once
|
||||
/// c++ Includes
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
/// c includes
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
/// 3ds Includes
|
||||
#include <3ds.h>
|
||||
#include <citro2d.h>
|
||||
#include <citro3d.h>
|
||||
/// RenderD7 Includes
|
||||
#include <renderd7/Color.hpp>
|
||||
#include <renderd7/FunctionTrace.hpp>
|
||||
#include <renderd7/Hardware.hpp>
|
||||
#include <renderd7/Logger.hpp>
|
||||
#include <renderd7/Memory.hpp>
|
||||
#include <renderd7/Overlays.hpp>
|
||||
#include <renderd7/Ovl.hpp>
|
||||
#include <renderd7/Render2.hpp>
|
||||
#include <renderd7/ResultDecoder.hpp>
|
||||
#include <renderd7/Sheet.hpp>
|
||||
#include <renderd7/Sprite.hpp>
|
||||
#include <renderd7/SpriteAnimation.hpp>
|
||||
#include <renderd7/Tasks.hpp>
|
||||
#include <renderd7/Time.hpp>
|
||||
#include <renderd7/lang.hpp>
|
||||
#include <renderd7/parameter.hpp>
|
||||
#include <renderd7/stringtool.hpp>
|
||||
#include <renderd7/thread.hpp>
|
||||
|
||||
#define RENDERD7VSTRING "0.9.5"
|
||||
|
||||
#define DEFAULT_CENTER 0.5f
|
||||
|
||||
/// @param rd7_max_objects Config Param for C2D Mac objects
|
||||
extern int rd7_max_objects;
|
||||
|
||||
namespace RenderD7 {
|
||||
// Reference to the New Renderer
|
||||
R2Base::Ref R2();
|
||||
// Reference to Global Logger
|
||||
LoggerBase::Ref Logger();
|
||||
/// @brief Get Deltatime
|
||||
/// @return Deltatime
|
||||
float GetDeltaTime();
|
||||
|
||||
/// @brief Scene Class
|
||||
class Scene {
|
||||
public:
|
||||
/// @brief Stack of the Scenes
|
||||
static std::stack<std::unique_ptr<Scene>> scenes;
|
||||
/// @brief Deconstructor
|
||||
virtual ~Scene() {}
|
||||
virtual void Logic() = 0;
|
||||
/// @brief Draw Func to Override
|
||||
virtual void Draw() const = 0;
|
||||
/// @brief Push a Scene to Stack
|
||||
/// @param scene Scene to Push
|
||||
/// @param fade FadeEffect (Not Correctly Implementet yet)
|
||||
static void Load(std::unique_ptr<Scene> scene, bool fade = false);
|
||||
/// @brief Go Back a Scene
|
||||
static void Back();
|
||||
/// @brief do the Draw (Called in RenderD7::MainLoop())
|
||||
static void doDraw();
|
||||
static void doLogic();
|
||||
};
|
||||
|
||||
/// @brief Integrated Setting Menu of RenderD7
|
||||
class RSettings : public RenderD7::Scene {
|
||||
private:
|
||||
/// @brief State (Define for Menus)
|
||||
enum RState {
|
||||
RSETTINGS, // Main Settings Menu
|
||||
RIDB, // Internal Debugger
|
||||
ROVERLAYS, // Overlay Settings
|
||||
RFTRACE, // FTRace Menu
|
||||
RUI7, // UI7 Menu
|
||||
RLOGS, // Logs
|
||||
};
|
||||
|
||||
/// @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)
|
||||
RenderD7::RSettings::RState m_state = RenderD7::RSettings::RState::RSETTINGS;
|
||||
|
||||
/// @brief Position in FTrace Menu
|
||||
int ftrace_index = 0;
|
||||
|
||||
/// @param mtovlstate State of Metricks Overlay
|
||||
std::string mtovlstate = "false";
|
||||
/// @param mtscreenstate Screen the Overlay is Set to
|
||||
std::string mtscreenstate = "Top";
|
||||
std::string kbd_test;
|
||||
RD7KeyboardState kbd_state;
|
||||
bool statemtold = false;
|
||||
bool stateftold = false;
|
||||
float tmp_txt;
|
||||
|
||||
public:
|
||||
/// @brief Constructor
|
||||
RSettings();
|
||||
/// @brief Override for Draw
|
||||
/// @param
|
||||
void Draw(void) const override;
|
||||
/// @brief Deconstructor
|
||||
~RSettings();
|
||||
void Logic() override;
|
||||
};
|
||||
|
||||
/// @brief Show Up the RenderD7-Settings Menu
|
||||
void LoadSettings();
|
||||
/// @brief Show Up The Theme Editor
|
||||
void LoadThemeEditor();
|
||||
/// @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
|
||||
/// @param b From
|
||||
/// @param e To
|
||||
/// @return Random Int
|
||||
int GetRandomInt(int b, int e);
|
||||
/// @brief Fade In
|
||||
/// @param duration Duration in Frames
|
||||
void FadeIn();
|
||||
/// @brief Fade Out
|
||||
/// @param duration Duration in Frames
|
||||
void FadeOut();
|
||||
/// @brief Display Fade Effects
|
||||
void FadeDisplay();
|
||||
|
||||
namespace Init {
|
||||
/// @brief Init Default RenderD7
|
||||
/// @param app_name Name of Your App
|
||||
/// @return ResCode
|
||||
Result Main(std::string app_name = "RD7Game");
|
||||
/// @brief Init Minimal RenderD7 (For better Hax2.x support)
|
||||
/// @param app_name Name of Your App
|
||||
/// @return ResCode
|
||||
Result Minimal(std::string app_name = "RD7Game");
|
||||
/// @brief Reload the Graphics Engine
|
||||
/// @return ResCode
|
||||
Result Reload();
|
||||
/// @brief Init Graphics Only (NOT SUPPORTET use Reload)
|
||||
void Graphics();
|
||||
/// @brief Init Ndsp for Sounds
|
||||
void NdspFirm();
|
||||
} // namespace Init
|
||||
|
||||
namespace FS {
|
||||
/// @brief Check if File exists
|
||||
/// @param path Path to the File
|
||||
/// @return exists or not
|
||||
bool FileExist(const std::string &path);
|
||||
} // namespace FS
|
||||
|
||||
/// @brief Check if Ndsp is Init
|
||||
/// @return is or not
|
||||
bool IsNdspInit();
|
||||
/// @brief Get Current Framerate as String
|
||||
/// @return Framerate String
|
||||
std::string GetFramerate();
|
||||
/// @brief MainLoop of RenderD7s
|
||||
/// @return Is Still Running or not
|
||||
bool MainLoop();
|
||||
/// @brief Exit App (brak the MainLoop)
|
||||
void ExitApp();
|
||||
|
||||
/// @brief Clear the Citro2D TextBuffers
|
||||
/// @param
|
||||
void ClearTextBufs(void);
|
||||
|
||||
/// @brief Draw Overlays And end the Frame. DO NEVER USE C3D_FRAMEEND cause it
|
||||
/// breaks Overlay crash Security
|
||||
void FrameEnd();
|
||||
|
||||
/// @brief Returns App Working Directory path
|
||||
/// @return AppDir Path
|
||||
std::string GetAppDirectory();
|
||||
/// @brief returns path to the Data Directory
|
||||
/// @return data dir path
|
||||
std::string GetDataDirectory();
|
||||
} // namespace RenderD7
|
@ -1,8 +0,0 @@
|
||||
// THIS FILE WAS GENERATED BY generate_assets.py!!!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
extern unsigned char renderd7_logo[];
|
||||
extern size_t renderd7_logo_size;
|
@ -1,10 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#define RD7_SMART_CTOR(type) \
|
||||
using Ref = std::shared_ptr<type>; \
|
||||
template <typename... args> \
|
||||
static Ref New(args&&... cargs) { \
|
||||
return std::make_shared<type>(std::forward<args>(cargs)...); \
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
#pragma once
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace RenderD7 {
|
||||
/// @brief Check if A String ends with
|
||||
/// @param name Input String
|
||||
/// @param extensions Extensions to Check for
|
||||
/// @return Ends with or not
|
||||
inline bool NameIsEndingWith(const std::string &name,
|
||||
const std::vector<std::string> &extensions) {
|
||||
if (name.substr(0, 2) == "._") return false;
|
||||
|
||||
if (name.size() == 0) return false;
|
||||
|
||||
if (extensions.size() == 0) return true;
|
||||
|
||||
for (int i = 0; i < (int)extensions.size(); i++) {
|
||||
const std::string ext = extensions.at(i);
|
||||
if (strcasecmp(name.c_str() + name.size() - ext.size(), ext.c_str()) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/// @brief Format Milliseconds to clean string (Stolen from one of my Mc
|
||||
/// Plugins)
|
||||
/// @param t_time Time in ms
|
||||
/// @return String
|
||||
inline std::string MsTimeFmt(float t_time, bool dems = false) {
|
||||
std::ostringstream oss;
|
||||
|
||||
if (t_time < 0.001f) {
|
||||
oss << std::fixed << std::setprecision(2) << t_time * 1000.0f << "ns";
|
||||
} else if (t_time < 1.0f) {
|
||||
oss << std::fixed << std::setprecision(2) << t_time << "ms";
|
||||
} else if (t_time < 60000.0f) {
|
||||
int seconds = static_cast<int>(t_time / 1000.0f);
|
||||
float milliseconds = t_time - (seconds * 1000.0f);
|
||||
|
||||
if (seconds > 0) {
|
||||
oss << seconds << "s ";
|
||||
}
|
||||
if (!dems)
|
||||
oss << std::fixed << std::setprecision(2) << milliseconds << "ms";
|
||||
} else {
|
||||
int minutes = static_cast<int>(t_time / 60000.0f);
|
||||
int seconds = static_cast<int>((t_time - (minutes * 60000.0f)) / 1000.0f);
|
||||
float milliseconds = t_time - (minutes * 60000.0f) - (seconds * 1000.0f);
|
||||
|
||||
oss << minutes << "m ";
|
||||
if (seconds > 0 || milliseconds > 0.0f) {
|
||||
oss << seconds << "s ";
|
||||
}
|
||||
if (milliseconds > 0.0f && !dems) {
|
||||
oss << std::fixed << std::setprecision(2) << milliseconds << "ms";
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
template <class T>
|
||||
T GetFileName(T const &path, T const &delims = "/\\") {
|
||||
return path.substr(path.find_last_of(delims) + 1);
|
||||
}
|
||||
template <class T>
|
||||
T remove_ext(T const &filename) {
|
||||
typename T::size_type const p(filename.find_last_of('.'));
|
||||
return p > 0 && p != T::npos ? filename.substr(0, p) : filename;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string Int_To_Hex(T i) {
|
||||
std::stringstream stream;
|
||||
stream << "0x" << std::setfill('0') << std::setw(sizeof(T) * 2) << std::hex
|
||||
<< i;
|
||||
return stream.str();
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <renderd7/nimg.hpp>
|
||||
|
||||
namespace RenderD7 {
|
||||
class swr {
|
||||
public:
|
||||
swr(int w, int h);
|
||||
swr();
|
||||
~swr();
|
||||
nimg& get_image() { 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 draw_line(int x1, int y1, int x2, int y2, unsigned int color, int t = 1);
|
||||
void flip(bool h, bool v);
|
||||
|
||||
private:
|
||||
nimg image;
|
||||
};
|
||||
} // namespace RenderD7
|
@ -1,122 +0,0 @@
|
||||
#pragma once
|
||||
#include <3ds.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <renderd7/parameter.hpp>
|
||||
|
||||
using CTRU_Thread = Thread;
|
||||
|
||||
#define THREAD_STACK_SIZE 0x1000
|
||||
|
||||
namespace RenderD7 {
|
||||
class Thread {
|
||||
public:
|
||||
/**
|
||||
* @brief Default constructor
|
||||
* @note This should only be called when calling m3d::Thread::initialize()
|
||||
* before calling m3d::Thread::start()
|
||||
*/
|
||||
Thread();
|
||||
|
||||
/**
|
||||
* @brief Constructs the thread
|
||||
* @param t_function The thread function
|
||||
* @param t_parameter The parameter to pass to the function
|
||||
* @param t_autostart Whether the thread should start instantly
|
||||
* @param t_detached Whether the thread starts detached or not
|
||||
* @param t_stackSize The stacksize allocated for the thread in bytes (rounded
|
||||
* to multiples of 8 bytes)
|
||||
* @note t_function needs to be of type `void` and take one (and only one)
|
||||
* parameter of type m3d::Parameter
|
||||
* @warning If the thread priority is lower than the priority of the calling
|
||||
* thread, the thread will never get executed. Use
|
||||
* m3d::Thread::getCurrentPriority() to get the priority of the current thread
|
||||
*/
|
||||
Thread(std::function<void(RenderD7::Parameter)> t_function,
|
||||
RenderD7::Parameter t_parameter = nullptr, bool t_autostart = false,
|
||||
bool t_detached = false,
|
||||
unsigned long long int t_stackSize = 4 * 1024);
|
||||
|
||||
/**
|
||||
* @brief Destructs the thread
|
||||
*/
|
||||
virtual ~Thread();
|
||||
|
||||
/**
|
||||
* @brief Initializes the thread
|
||||
* @param t_function The thread function
|
||||
* @param t_parameter The parameter to pass to the function
|
||||
* @param t_autostart Whether the thread should start instantly
|
||||
* @param t_detached Whether the thread starts detached or not
|
||||
* @param t_stackSize The stacksize allocated for the thread in bytes (rounded
|
||||
* to multiples of 8 bytes)
|
||||
* @note t_function needs to be of type `void` and take one (and only one)
|
||||
* parameter of type m3d::Parameter
|
||||
* @warning If the thread priority is lower than the priority of the calling
|
||||
* thread, the thread will never get executed. Use
|
||||
* m3d::Thread::getCurrentPriority() to get the priority of the current thread
|
||||
*/
|
||||
void initialize(std::function<void(RenderD7::Parameter)> t_function,
|
||||
RenderD7::Parameter t_parameter = nullptr,
|
||||
bool t_autostart = false, bool t_detached = false,
|
||||
unsigned long long int t_stackSize = 4 * 1024);
|
||||
|
||||
/**
|
||||
* @brief Sets the size of the stack that gets allocated for the next thread
|
||||
* that get's started
|
||||
* @param t_stackSize The allocated space in bytes (rounded to multiples of 8
|
||||
* bytes)
|
||||
*/
|
||||
void setStackSize(unsigned long long int t_stackSize);
|
||||
|
||||
/**
|
||||
* @brief Starts the thread. To restart it, call Thread::join() before
|
||||
* @param t_detached Whether the thread should start detached or not
|
||||
*/
|
||||
void start(bool t_detached = false);
|
||||
|
||||
/**
|
||||
* @brief Detaches the thread
|
||||
*/
|
||||
void kill();
|
||||
|
||||
/**
|
||||
* @brief Waits for the thread to finish
|
||||
* @param t_timeout The timeout in nanoseconds. Leave it for no timeout
|
||||
*/
|
||||
void join(long long unsigned int t_timeout = U64_MAX);
|
||||
|
||||
bool isRunning();
|
||||
|
||||
/**
|
||||
* @brief Puts the thread to sleep
|
||||
*
|
||||
* This is needed if you have multiple threads running at the same time. It
|
||||
* doesn't affect the execution-time of the thread, it just makes it possible
|
||||
* for the other threads to get their chance to shine.
|
||||
*/
|
||||
static void sleep();
|
||||
|
||||
/**
|
||||
* @brief Sleeps for the given time
|
||||
* @param t_milliseconds The time to sleep in milliseconds
|
||||
*/
|
||||
static void sleep(int t_milliseconds);
|
||||
|
||||
private:
|
||||
struct ThreadData {
|
||||
RenderD7::Parameter m_parameter;
|
||||
std::function<void(RenderD7::Parameter)> m_function;
|
||||
std::atomic<bool> *m_running;
|
||||
};
|
||||
|
||||
static void threadFunction(void *t_arg);
|
||||
/* data */
|
||||
int m_priority, m_stackSize;
|
||||
bool m_started;
|
||||
std::atomic<bool> m_running;
|
||||
RenderD7::Thread::ThreadData m_data;
|
||||
CTRU_Thread m_thread;
|
||||
};
|
||||
} // namespace RenderD7
|
59
log.cpp
Normal file
59
log.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
#include "log.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
std::string Log::format(const std::string& fmt_str, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char* fp = NULL;
|
||||
va_start(ap, fmt_str);
|
||||
vasprintf(&fp, fmt_str.c_str(), ap);
|
||||
va_end(ap);
|
||||
std::unique_ptr<char, decltype(free)*> formatted(fp, free);
|
||||
return std::string(formatted.get());
|
||||
}
|
||||
|
||||
std::string Log::logDate(void)
|
||||
{
|
||||
time_t unixTime;
|
||||
struct tm timeStruct;
|
||||
time(&unixTime);
|
||||
localtime_r(&unixTime, &timeStruct);
|
||||
return format("%04i-%02i-%02i %02i:%02i:%02i", timeStruct.tm_year + 1900, timeStruct.tm_mon + 1, timeStruct.tm_mday,
|
||||
timeStruct.tm_hour, timeStruct.tm_min, timeStruct.tm_sec);
|
||||
}
|
||||
|
||||
Log::Log()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Log::Init(const char *filename)
|
||||
{
|
||||
this->filename = filename;
|
||||
if ((access(filename, F_OK) == 0))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
FILE* logfile = fopen((filename), "w");
|
||||
fclose(logfile);
|
||||
}
|
||||
}
|
||||
|
||||
void Log::Write(std::string debug_text)
|
||||
{
|
||||
std::ofstream logFile;
|
||||
logFile.open((this->filename), std::ofstream::app);
|
||||
std::string writeDebug = "[";
|
||||
writeDebug += logDate();
|
||||
writeDebug += "] ";
|
||||
writeDebug += debug_text.c_str();
|
||||
logFile << writeDebug << std::endl;
|
||||
logFile.close();
|
||||
}
|
||||
Log::~Log()
|
||||
{
|
||||
|
||||
}
|
19
log.hpp
Normal file
19
log.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <stdarg.h>
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
class Log
|
||||
{
|
||||
public:
|
||||
Log();
|
||||
~Log();
|
||||
void Init(const char *filename);
|
||||
void Write(std::string debug_text);
|
||||
std::string logDate(void);
|
||||
std::string format(const std::string& fmt_str, ...);
|
||||
private:
|
||||
std::string filename;
|
||||
};
|
44
mkdocs.yaml
44
mkdocs.yaml
@ -1,44 +0,0 @@
|
||||
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
|
||||
|
566
renderd7.cpp
Normal file
566
renderd7.cpp
Normal file
@ -0,0 +1,566 @@
|
||||
#include "renderd7.hpp"
|
||||
#include "log.hpp"
|
||||
#include <regex>
|
||||
|
||||
#define RGBA8(r, g, b, a) ((((r) & 0xFF) << 0) | (((g) & 0xFF) << 8) | (((b) & 0xFF) << 16) | (((a) & 0xFF) << 24))
|
||||
#define D7_NOTHING C2D_Color32(0, 0, 0, 0)
|
||||
Log renderd7log;
|
||||
float animtime;
|
||||
bool isndspinit = false;
|
||||
bool running = true;
|
||||
std::stack<std::unique_ptr<RenderD7::Scene>> RenderD7::Scene::scenes;
|
||||
|
||||
u32 d7_hDown;
|
||||
u32 d7_hHeld;
|
||||
u32 d7_hUp;
|
||||
touchPosition d7_touch;
|
||||
|
||||
C2D_TextBuf TextBuf;
|
||||
C2D_Font Font;
|
||||
|
||||
// Fps Calc
|
||||
static float current_fps = 0.0f;
|
||||
static unsigned int frames = 0;
|
||||
static u64 last_time = 0;
|
||||
float d11framerate = 0;
|
||||
//-----------------
|
||||
|
||||
bool currentScreen = false;
|
||||
|
||||
C3D_RenderTarget* Top;
|
||||
C3D_RenderTarget* TopRight;
|
||||
C3D_RenderTarget* Bottom;
|
||||
|
||||
#define DSEVENBLACK C2D_Color32(0, 0 ,0, 255)
|
||||
#define DSEVENWHITE C2D_Color32(255, 255, 255, 255)
|
||||
RenderD7::SpriteSheetAnimation::SpriteSheetAnimation()
|
||||
{
|
||||
renderd7log.Write("SpriteSheetAnimation createt!");
|
||||
}
|
||||
RenderD7::SpriteSheetAnimation::~SpriteSheetAnimation()
|
||||
{
|
||||
|
||||
}
|
||||
bool RenderD7::DrawImageFromSheet(RenderD7::Sheet* sheet, size_t index, float x, float y, float scaleX, float scaleY)
|
||||
{
|
||||
if (sheet->spritesheet != nullptr)
|
||||
{
|
||||
if (C2D_SpriteSheetCount(sheet->spritesheet) >= index)
|
||||
{
|
||||
return C2D_DrawImageAt(C2D_SpriteSheetGetImage(sheet->spritesheet, index), x, y, 0.5f, nullptr, scaleX, scaleY);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void RenderD7::Init::NdspFirm(bool useit)
|
||||
{
|
||||
if (useit)
|
||||
{
|
||||
if ( access( "sdmc:/3ds/dspfirm.cdc", F_OK ) != -1 )
|
||||
{
|
||||
ndspInit();
|
||||
isndspinit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
renderd7log.Write("RenderD7: SoundEngine Error! ndspfirm not found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
void RenderD7::Exit::NdspFirm()
|
||||
{
|
||||
if (isndspinit)
|
||||
{
|
||||
ndspExit();
|
||||
}
|
||||
}
|
||||
void RenderD7::Msg::Display(std::string titletxt, std::string txt, C3D_RenderTarget *target)
|
||||
{
|
||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||
C2D_TargetClear(Top, DSEVENBLACK);
|
||||
C2D_TargetClear(Bottom, DSEVENBLACK);
|
||||
RenderD7::ClearTextBufs();
|
||||
RenderD7::OnScreen(Top);
|
||||
RenderD7::DrawRect(0, 0, 400, 240, RenderD7::Color::Hex("#111111"));
|
||||
RenderD7::OnScreen(Bottom);
|
||||
RenderD7::DrawRect(0, 0, 320, 240, RenderD7::Color::Hex("#111111"));
|
||||
RenderD7::OnScreen(target);
|
||||
RenderD7::DrawRect(0, 0, 400, 26, RenderD7::Color::Hex("#333333", 200));
|
||||
RenderD7::DrawText(5, 2, 0.7f, DSEVENWHITE, titletxt);
|
||||
RenderD7::DrawText(5, 30, 0.6f, DSEVENWHITE, txt);
|
||||
|
||||
C3D_FrameEnd(0);
|
||||
}
|
||||
void RenderD7::SetupLog()
|
||||
{
|
||||
renderd7log.Init("sdmc:/Flappy-Bird-RenderD7.log");
|
||||
}
|
||||
void RenderD7::SpriteSheetAnimation::Setup(RenderD7::Sheet *sheet, size_t imagecount, size_t startimage, float frame_begin, float frame_finish)
|
||||
{
|
||||
|
||||
D_totaltime = frame_begin;
|
||||
renderd7log.Write("frame_begin success");
|
||||
this->images = imagecount;
|
||||
renderd7log.Write("imagecount success");
|
||||
this->sheet = sheet;
|
||||
renderd7log.Write("sheet success");
|
||||
this->time = frame_finish;
|
||||
renderd7log.Write("frame_finish success");
|
||||
RenderD7::SpriteSheetAnimation::FromSheet(this->sheet, startimage);
|
||||
}
|
||||
void RenderD7::SpriteSheetAnimation::Play(float timespeed)
|
||||
{
|
||||
D_totaltime += timespeed;
|
||||
if (D_totaltime >= time)
|
||||
{
|
||||
D_totaltime -= time;
|
||||
imgs++;
|
||||
if (imgs == images)
|
||||
{
|
||||
imgs = 0;
|
||||
}
|
||||
}
|
||||
RenderD7::SpriteSheetAnimation::FromSheet(sheet, imgs);
|
||||
//RenderD7::SpriteSheetAnimation::Draw();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void RenderD7::Error::DisplayError(std::string toptext, std::string errortext)
|
||||
{
|
||||
RenderD7::ClearTextBufs();
|
||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||
C2D_TargetClear(Top, DSEVENBLACK);
|
||||
C2D_TargetClear(Bottom, DSEVENBLACK);
|
||||
RenderD7::DrawTextCentered(0, 0, 0.7f, DSEVENWHITE, toptext, 400);
|
||||
RenderD7::DrawTextCentered(0, 100, 0.6f, DSEVENWHITE, errortext, 400);
|
||||
C3D_FrameEnd(0);
|
||||
for (int i = 0; i < 60*20; i++) {
|
||||
gspWaitForVBlank();
|
||||
}
|
||||
}
|
||||
u32 RenderD7::Color::Hex(const std::string color, u8 a)
|
||||
{
|
||||
if (color.length() < 7 || std::regex_search(color.substr(1), std::regex("[^0-9A-Fa-f]"))) { // invalid color.
|
||||
return D7_NOTHING;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
void RenderD7::Scene::doDraw() {
|
||||
if(!RenderD7::Scene::scenes.empty())
|
||||
RenderD7::Scene::scenes.top()->Draw();
|
||||
}
|
||||
|
||||
void RenderD7::Scene::doLogic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch) {
|
||||
if(!RenderD7::Scene::scenes.empty())
|
||||
RenderD7::Scene::scenes.top()->Logic(hDown, hHeld, hUp, touch);
|
||||
}
|
||||
|
||||
void RenderD7::Scene::Load(std::unique_ptr<Scene> scene)
|
||||
{
|
||||
Scene::scenes.push(std::move(scene));
|
||||
}
|
||||
|
||||
void RenderD7::Scene::Back() {
|
||||
if(RenderD7::Scene::scenes.size() > 0)
|
||||
RenderD7::Scene::scenes.pop();
|
||||
}
|
||||
|
||||
void RenderD7::OnScreen(C3D_RenderTarget *target)
|
||||
{
|
||||
C2D_SceneBegin(target);
|
||||
}
|
||||
|
||||
bool RenderD7::MainLoop()
|
||||
{
|
||||
if (!aptMainLoop()) return false;
|
||||
hidScanInput();
|
||||
d7_hDown = hidKeysDown();
|
||||
d7_hUp = hidKeysUp();
|
||||
d7_hHeld = hidKeysHeld();
|
||||
hidTouchRead(&d7_touch);
|
||||
|
||||
RenderD7::ClearTextBufs();
|
||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||
C2D_TargetClear(Top, C2D_Color32(0, 0, 0, 0));
|
||||
C2D_TargetClear(Bottom, C2D_Color32(0, 0, 0, 0));
|
||||
|
||||
return running;
|
||||
}
|
||||
|
||||
|
||||
RenderD7::Sheet::Sheet()
|
||||
{
|
||||
|
||||
}
|
||||
RenderD7::Sheet::~Sheet()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Result RenderD7::Sheet::Load(const char *path)
|
||||
{
|
||||
this->spritesheet = C2D_SpriteSheetLoad(path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RenderD7::Sheet::Free()
|
||||
{
|
||||
C2D_SpriteSheetFree(this->spritesheet);
|
||||
}
|
||||
|
||||
RenderD7::Sprite::Sprite()
|
||||
{
|
||||
|
||||
}
|
||||
RenderD7::Sprite::~Sprite()
|
||||
{
|
||||
|
||||
}
|
||||
void RenderD7::Sprite::FromSheet(RenderD7::Sheet *sheet, size_t index)
|
||||
{
|
||||
C2D_SpriteFromSheet(&this->sprite, sheet->spritesheet, index);
|
||||
}
|
||||
bool RenderD7::Sprite::Draw()
|
||||
{
|
||||
return C2D_DrawSprite(&this->sprite);
|
||||
}
|
||||
void RenderD7::Sprite::SetCenter(float x, float y)
|
||||
{
|
||||
C2D_SpriteSetCenter(&this->sprite, x, y);
|
||||
}
|
||||
void RenderD7::Sprite::SetPos(float x, float y)
|
||||
{
|
||||
C2D_SpriteSetPos(&this->sprite, x, y);
|
||||
}
|
||||
void RenderD7::Sprite::SetRotation(float rotation)
|
||||
{
|
||||
C2D_SpriteSetRotation(&this->sprite, rotation);
|
||||
}
|
||||
void RenderD7::Sprite::Rotate(float speed)
|
||||
{
|
||||
C2D_SpriteRotateDegrees(&this->sprite, speed);
|
||||
}
|
||||
float RenderD7::Sprite::getHeigh()
|
||||
{
|
||||
return this->sprite.params.pos.h;
|
||||
}
|
||||
float RenderD7::Sprite::getWidth()
|
||||
{
|
||||
return this->sprite.params.pos.w;
|
||||
}
|
||||
float RenderD7::Sprite::getPosX()
|
||||
{
|
||||
return this->sprite.params.pos.x;
|
||||
}
|
||||
float RenderD7::Sprite::getPosY()
|
||||
{
|
||||
return this->sprite.params.pos.y;
|
||||
}
|
||||
|
||||
void RenderD7::ClearTextBufs(void)
|
||||
{
|
||||
C2D_TextBufClear(TextBuf);
|
||||
}
|
||||
|
||||
void frameloop()
|
||||
{
|
||||
frames++;
|
||||
u64 delta_time = osGetTime() - last_time;
|
||||
if (delta_time >= 1000) {
|
||||
current_fps = frames/(delta_time/1000.0f)+1;
|
||||
frames = 0;
|
||||
last_time = osGetTime();
|
||||
}
|
||||
d11framerate = current_fps;
|
||||
}
|
||||
float getframerate()
|
||||
{
|
||||
frameloop();
|
||||
return d11framerate;
|
||||
}
|
||||
|
||||
bool RenderD7::DrawRect(float x, float y, float w, float h, u32 color)
|
||||
{
|
||||
return C2D_DrawRectSolid(x, y, 0.5f, w, h, color);
|
||||
}
|
||||
|
||||
void RenderD7::DrawTextCentered(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::GetTextHeight(size, " ", fnt);
|
||||
} else {
|
||||
lineHeight = RenderD7::GetTextHeight(size, " ");
|
||||
}
|
||||
|
||||
int line = 0;
|
||||
while(Text.find('\n') != Text.npos) {
|
||||
if (maxWidth == 0) {
|
||||
// Do the widthScale.
|
||||
if (fnt != nullptr) {
|
||||
widthScale = RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n')), fnt);
|
||||
} else {
|
||||
widthScale = RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n')));
|
||||
}
|
||||
|
||||
} else {
|
||||
// Do the widthScale 2.
|
||||
if (fnt != nullptr) {
|
||||
widthScale = std::min((float)maxWidth, RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n')), fnt));
|
||||
} else {
|
||||
widthScale = std::min((float)maxWidth, RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n'))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (fnt != nullptr) {
|
||||
RenderD7::DrawText((currentScreen ? 200 : 160)+x-(widthScale/2), y+(lineHeight*line), size, color, Text.substr(0, Text.find('\n')), maxWidth, maxHeight, fnt);
|
||||
} else {
|
||||
RenderD7::DrawText((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::GetTextWidth(size, Text.substr(0, Text.find('\n')), fnt);
|
||||
} else {
|
||||
widthScale = RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n')));
|
||||
}
|
||||
|
||||
} else {
|
||||
// And again.
|
||||
if (fnt != nullptr) {
|
||||
widthScale = std::min((float)maxWidth, RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n')), fnt));
|
||||
} else {
|
||||
widthScale = std::min((float)maxWidth, RenderD7::GetTextWidth(size, Text.substr(0, Text.find('\n'))));
|
||||
}
|
||||
|
||||
}
|
||||
if (fnt != nullptr) {
|
||||
RenderD7::DrawText((currentScreen ? 200 : 160)+x-(widthScale/2), y+(lineHeight*line), size, color, Text.substr(0, Text.find('\n')), maxWidth, maxHeight, fnt);
|
||||
} else {
|
||||
RenderD7::DrawText((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::DrawText(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::GetTextHeight(size, Text, fnt)));
|
||||
} else {
|
||||
heightScale = std::min(size, size*(maxHeight/RenderD7::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::GetTextWidth(size, Text, fnt))), heightScale, color);
|
||||
} else {
|
||||
C2D_DrawText(&c2d_text, C2D_WithColor, x, y, 0.5f, std::min(size, size*(maxWidth/RenderD7::GetTextWidth(size, Text))), heightScale, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get String or Text Width.
|
||||
float RenderD7::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::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::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::loadFont(C2D_Font &fnt, const char* Path) {
|
||||
fnt = C2D_FontLoad(Path); // Only load if found.
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Unload a Font.
|
||||
Result RenderD7::unloadFont(C2D_Font &fnt) {
|
||||
if (fnt != nullptr) {
|
||||
C2D_FontFree(fnt); // Make sure to only unload if not nullptr.
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool RenderD7::DrawCircle(float x, float y, float radius, u32 color)
|
||||
{
|
||||
return C2D_DrawCircleSolid(x, y, 0.5f, radius, color);
|
||||
}
|
||||
|
||||
Result RenderD7::Init::Main()
|
||||
{
|
||||
gfxInitDefault();
|
||||
aptInit();
|
||||
romfsInit();
|
||||
cfguInit();
|
||||
osSetSpeedupEnable(true);
|
||||
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
|
||||
C2D_Init(C2D_DEFAULT_MAX_OBJECTS);
|
||||
C2D_Prepare();
|
||||
Top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
|
||||
TopRight = C2D_CreateScreenTarget(GFX_TOP, GFX_RIGHT);
|
||||
Bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);
|
||||
TextBuf = C2D_TextBufNew(4096);
|
||||
Font = C2D_FontLoadSystem(CFG_REGION_USA);
|
||||
return 0;
|
||||
|
||||
}
|
||||
void RenderD7::Exit::Main()
|
||||
{
|
||||
C2D_TextBufDelete(TextBuf);
|
||||
C2D_Fini();
|
||||
C3D_Fini();
|
||||
aptExit();
|
||||
romfsExit();
|
||||
cfguExit();
|
||||
}
|
||||
|
||||
std::string RenderD7::GetFramerate()
|
||||
{
|
||||
frameloop();
|
||||
return (std::to_string(d11framerate).substr(0, 2));
|
||||
}
|
||||
|
||||
void RenderD7::DrawTObjects(std::vector<RenderD7::TObject> tobjects, u32 color, u32 txtcolor, int selection, u32 selbgcolor, u32 selcolor)
|
||||
{
|
||||
for(int i = 0; i < (int)tobjects.size(); i++)
|
||||
{
|
||||
if (selection == i)
|
||||
{
|
||||
RenderD7::DrawRect(tobjects[i].x - 2, tobjects[i].y - 2, tobjects[i].w + 4, tobjects[i].h + 4, selbgcolor);
|
||||
RenderD7::DrawRect(tobjects[i].x, tobjects[i].y, tobjects[i].w, tobjects[i].h, color);
|
||||
RenderD7::DrawRect(tobjects[i].x, tobjects[i].y, tobjects[i].w, tobjects[i].h, selcolor);
|
||||
RenderD7::DrawText(tobjects[i].x + (tobjects[i].w/2) - RenderD7::GetTextHeight(tobjects[i].txtsize , tobjects[i].text) + tobjects[i].correctx, tobjects[i].y + (tobjects[i].h/2) - RenderD7::GetTextHeight(tobjects[i].txtsize, tobjects[i].text) + tobjects[i].correcty, tobjects[i].txtsize, txtcolor, tobjects[i].text);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderD7::DrawRect(tobjects[i].x, tobjects[i].y - 1, tobjects[i].w, tobjects[i].h, color);
|
||||
RenderD7::DrawText(tobjects[i].x + (tobjects[i].w/2) - RenderD7::GetTextHeight(tobjects[i].txtsize , tobjects[i].text) + tobjects[i].correctx, tobjects[i].y + (tobjects[i].h/2) - RenderD7::GetTextHeight(tobjects[i].txtsize, tobjects[i].text) + tobjects[i].correcty, tobjects[i].txtsize, txtcolor, tobjects[i].text);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
void RenderD7::ExitApp()
|
||||
{
|
||||
running = false;
|
||||
}
|
||||
|
||||
bool RenderD7::touchTObj(touchPosition touch, RenderD7::TObject button)
|
||||
{
|
||||
if (touch.px >= button.x && touch.px <= (button.x + button.w) && touch.py >= button.y && touch.py <= (button.y + button.h)) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
void RenderD7::DrawSTObject(std::vector<RenderD7::TObject> tobject, int tobjectindex, u32 color, u32 txtcolor)
|
||||
{
|
||||
RenderD7::DrawRect(tobject[tobjectindex].x, tobject[tobjectindex].y, tobject[tobjectindex].w, tobject[tobjectindex].h, color);
|
||||
RenderD7::DrawText(tobject[tobjectindex].x + (tobject[tobjectindex].w/2) - RenderD7::GetTextHeight(tobject[tobjectindex].txtsize , tobject[tobjectindex].text) + tobject[tobjectindex].correctx, tobject[tobjectindex].y + (tobject[tobjectindex].h/2) - RenderD7::GetTextHeight(tobject[tobjectindex].txtsize, tobject[tobjectindex].text) + tobject[tobjectindex].correcty, tobject[tobjectindex].txtsize, txtcolor, tobject[tobjectindex].text);
|
||||
}
|
||||
|
||||
bool RenderD7::NameIsEndingWith(const std::string &name, const std::vector<std::string> &extensions) {
|
||||
if (name.substr(0, 2) == "._") return false;
|
||||
|
||||
if (name.size() == 0) return false;
|
||||
|
||||
if (extensions.size() == 0) return true;
|
||||
|
||||
for(int i = 0; i < (int)extensions.size(); i++) {
|
||||
const std::string ext = extensions.at(i);
|
||||
if (strcasecmp(name.c_str() + name.size() - ext.size(), ext.c_str()) == 0) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool dirEntryPredicate(const RenderD7::DirContent &lhs, const RenderD7::DirContent &rhs) {
|
||||
if (!lhs.isDir && rhs.isDir) return false;
|
||||
if (lhs.isDir && !rhs.isDir) return true;
|
||||
|
||||
return strcasecmp(lhs.name.c_str(), rhs.name.c_str()) < 0;
|
||||
}
|
||||
|
||||
void RenderD7::GetDirContentsExt(std::vector<RenderD7::DirContent> &dircontent, const std::vector<std::string> &extensions) {
|
||||
struct stat st;
|
||||
|
||||
dircontent.clear();
|
||||
|
||||
DIR *pdir = opendir(".");
|
||||
|
||||
if (pdir != nullptr) {
|
||||
while(true) {
|
||||
RenderD7::DirContent dirEntry;
|
||||
|
||||
struct dirent *pent = readdir(pdir);
|
||||
if (pent == NULL) break;
|
||||
|
||||
stat(pent->d_name, &st);
|
||||
dirEntry.name = pent->d_name;
|
||||
dirEntry.isDir = (st.st_mode & S_IFDIR) ? true : false;
|
||||
|
||||
if (dirEntry.name.compare(".") != 0 && (dirEntry.isDir || RenderD7::NameIsEndingWith(dirEntry.name, extensions))) {
|
||||
dircontent.push_back(dirEntry);
|
||||
}
|
||||
}
|
||||
|
||||
closedir(pdir);
|
||||
}
|
||||
|
||||
sort(dircontent.begin(), dircontent.end(), dirEntryPredicate);
|
||||
}
|
||||
|
||||
void RenderD7::GetDirContents(std::vector<RenderD7::DirContent> &dircontent) {
|
||||
RenderD7::GetDirContentsExt(dircontent, {});
|
||||
}
|
158
renderd7.hpp
Normal file
158
renderd7.hpp
Normal file
@ -0,0 +1,158 @@
|
||||
#include <3ds.h>
|
||||
#include <citro2d.h>
|
||||
#include <citro3d.h>
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <cstring>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define DEFAULT_CENTER 0.5f
|
||||
|
||||
extern C3D_RenderTarget* Top;
|
||||
extern C3D_RenderTarget* TopRight;
|
||||
extern C3D_RenderTarget* Bottom;
|
||||
|
||||
extern u32 d7_hDown;
|
||||
extern u32 d7_hHeld;
|
||||
extern u32 d7_hUp;
|
||||
extern touchPosition d7_touch;
|
||||
|
||||
namespace RenderD7
|
||||
{
|
||||
void OnScreen(C3D_RenderTarget *target);
|
||||
class Sheet
|
||||
{
|
||||
public:
|
||||
Sheet();
|
||||
~Sheet();
|
||||
Result Load(const char *path);
|
||||
void Free();
|
||||
C2D_SpriteSheet spritesheet;
|
||||
|
||||
};
|
||||
class Sprite
|
||||
{
|
||||
public:
|
||||
Sprite();
|
||||
~Sprite();
|
||||
void FromSheet(RenderD7::Sheet *sheet, size_t index);
|
||||
bool Draw();
|
||||
void SetCenter(float x, float y);
|
||||
void SetPos(float x, float y);
|
||||
void SetRotation(float rotation);
|
||||
void Rotate(float speed);
|
||||
float getWidth();
|
||||
float getHeigh();
|
||||
float getPosX();
|
||||
float getPosY();
|
||||
private:
|
||||
C2D_ImageTint tint;
|
||||
C2D_Sprite sprite;
|
||||
};
|
||||
class Scene {
|
||||
public:
|
||||
static std::stack<std::unique_ptr<Scene>> scenes;
|
||||
virtual ~Scene() {}
|
||||
virtual void Logic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch) = 0;
|
||||
virtual void Draw() const = 0;
|
||||
static void Load(std::unique_ptr<Scene> scene);
|
||||
static void Back();
|
||||
static void doDraw();
|
||||
static void doLogic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch);
|
||||
|
||||
};
|
||||
namespace Color
|
||||
{
|
||||
u32 Hex(const std::string color, u8 a = 255);
|
||||
}
|
||||
bool DrawImageFromSheet(RenderD7::Sheet* sheet, size_t index, float x, float y, float scaleX = 1.0, float scaleY = 1.0);
|
||||
namespace Error
|
||||
{
|
||||
void DisplayError(std::string toptext, std::string errortext);
|
||||
void DisplayFatalError(std::string toptext, std::string errortext);
|
||||
}
|
||||
namespace Init
|
||||
{
|
||||
Result Main();
|
||||
void NdspFirm(bool useit = false);
|
||||
}
|
||||
namespace Exit
|
||||
{
|
||||
void Main();
|
||||
void NdspFirm();
|
||||
}
|
||||
namespace Msg
|
||||
{
|
||||
void Display(std::string titletxt, std::string, C3D_RenderTarget *target);
|
||||
}
|
||||
|
||||
|
||||
void SetupLog(void);
|
||||
std::string GetFramerate();
|
||||
bool MainLoop();
|
||||
void ExitApp();
|
||||
|
||||
void ClearTextBufs(void);
|
||||
|
||||
bool DrawRect(float x, float y, float w, float h, u32 color);
|
||||
void DrawTextCentered(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr);
|
||||
void DrawText(float x, float y, float size, u32 color, std::string Text, int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr);
|
||||
float GetTextWidth(float size, std::string Text, C2D_Font fnt = nullptr);
|
||||
void GetTextSize(float size, float *width, float *height, std::string Text, C2D_Font fnt = nullptr);
|
||||
float GetTextHeight(float size, std::string Text, C2D_Font fnt = nullptr);
|
||||
Result loadFont(C2D_Font &fnt, const char * Path = "");
|
||||
Result unloadFont(C2D_Font &fnt);
|
||||
bool DrawCircle(float x, float y, float radius, u32 color);
|
||||
|
||||
|
||||
class SpriteSheetAnimation : public RenderD7::Sprite
|
||||
{
|
||||
|
||||
public:
|
||||
SpriteSheetAnimation();
|
||||
~SpriteSheetAnimation();
|
||||
void Setup(RenderD7::Sheet *sheet, size_t imagecount, size_t startimage, float frame_begin, float frame_finish);
|
||||
void Play(float timespeed);
|
||||
private:
|
||||
size_t images;
|
||||
size_t imgs = 0;
|
||||
float D_totaltime;
|
||||
RenderD7::Sheet *sheet;
|
||||
float time;
|
||||
|
||||
};
|
||||
struct TObject
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
std::string text = "";
|
||||
float correctx = 0;
|
||||
float correcty = 0;
|
||||
float txtsize = 0.7f;
|
||||
|
||||
};
|
||||
void DrawTObjects(std::vector<RenderD7::TObject> tobjects, u32 color, u32 txtcolor, int selection = -1, u32 selbgcolor = RenderD7::Color::Hex("#2D98AF"), u32 selcolor = RenderD7::Color::Hex("#000000"));
|
||||
void DrawSTObject(std::vector<RenderD7::TObject> tobject, int tobjectindex, u32 color, u32 txtcolor);
|
||||
bool touchTObj(touchPosition touch, RenderD7::TObject button);
|
||||
|
||||
struct DirContent
|
||||
{
|
||||
std::string name;
|
||||
std::string path;
|
||||
bool isDir;
|
||||
};
|
||||
|
||||
bool NameIsEndingWith(const std::string &name, const std::vector<std::string> &extensions);
|
||||
void GetDirContentsExt(std::vector<RenderD7::DirContent> &dircontent, const std::vector<std::string> &extensions);
|
||||
void GetDirContents(std::vector<RenderD7::DirContent> &dircontent);
|
||||
|
||||
|
||||
}
|
125
sound.cpp
Normal file
125
sound.cpp
Normal file
@ -0,0 +1,125 @@
|
||||
#include "sound.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
using std::string;
|
||||
|
||||
// Reference: http://yannesposito.com/Scratch/en/blog/2010-10-14-Fun-with-wav/
|
||||
typedef struct _WavHeader {
|
||||
char magic[4]; // "RIFF"
|
||||
u32 totallength; // Total file length, minus 8.
|
||||
char wavefmt[8]; // Should be "WAVEfmt "
|
||||
u32 format; // 16 for PCM format
|
||||
u16 pcm; // 1 for PCM format
|
||||
u16 channels; // Channels
|
||||
u32 frequency; // Sampling frequency
|
||||
u32 bytes_per_second;
|
||||
u16 bytes_by_capture;
|
||||
u16 bits_per_sample;
|
||||
char data[4]; // "data"
|
||||
u32 bytes_in_data;
|
||||
} WavHeader;
|
||||
static_assert(sizeof(WavHeader) == 44, "WavHeader size is not 44 bytes.");
|
||||
|
||||
sound::sound(const string& path, int channel, bool toloop) {
|
||||
ndspSetOutputMode(NDSP_OUTPUT_STEREO);
|
||||
ndspSetOutputCount(2); // Num of buffers
|
||||
|
||||
// Reading wav file
|
||||
FILE* fp = fopen(path.c_str(), "rb");
|
||||
|
||||
if (!fp) {
|
||||
printf("Could not open the WAV file: %s\n", path.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
WavHeader wavHeader;
|
||||
size_t read = fread(&wavHeader, 1, sizeof(wavHeader), fp);
|
||||
if (read != sizeof(wavHeader)) {
|
||||
// Short read.
|
||||
printf("WAV file header is too short: %s\n", path.c_str());
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify the header.
|
||||
static const char RIFF_magic[4] = {'R','I','F','F'};
|
||||
if (memcmp(wavHeader.magic, RIFF_magic, sizeof(wavHeader.magic)) != 0) {
|
||||
// Incorrect magic number.
|
||||
printf("Wrong file format.\n");
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wavHeader.totallength == 0 ||
|
||||
(wavHeader.channels != 1 && wavHeader.channels != 2) ||
|
||||
(wavHeader.bits_per_sample != 8 && wavHeader.bits_per_sample != 16)) {
|
||||
// Unsupported WAV file.
|
||||
printf("Corrupted wav file.\n");
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the file size.
|
||||
fseek(fp, 0, SEEK_END);
|
||||
dataSize = ftell(fp) - sizeof(wavHeader);
|
||||
|
||||
// Allocating and reading samples
|
||||
data = static_cast<u8*>(linearAlloc(dataSize));
|
||||
fseek(fp, 44, SEEK_SET);
|
||||
fread(data, 1, dataSize, fp);
|
||||
fclose(fp);
|
||||
dataSize /= 2; // FIXME: 16-bit or stereo?
|
||||
|
||||
// Find the right format
|
||||
u16 ndspFormat;
|
||||
if (wavHeader.bits_per_sample == 8) {
|
||||
ndspFormat = (wavHeader.channels == 1) ?
|
||||
NDSP_FORMAT_MONO_PCM8 :
|
||||
NDSP_FORMAT_STEREO_PCM8;
|
||||
} else {
|
||||
ndspFormat = (wavHeader.channels == 1) ?
|
||||
NDSP_FORMAT_MONO_PCM16 :
|
||||
NDSP_FORMAT_STEREO_PCM16;
|
||||
}
|
||||
|
||||
ndspChnReset(channel);
|
||||
ndspChnSetInterp(channel, NDSP_INTERP_NONE);
|
||||
ndspChnSetRate(channel, float(wavHeader.frequency));
|
||||
ndspChnSetFormat(channel, ndspFormat);
|
||||
|
||||
// Create and play a wav buffer
|
||||
memset(&waveBuf, 0, sizeof(waveBuf));
|
||||
|
||||
waveBuf.data_vaddr = reinterpret_cast<u32*>(data);
|
||||
waveBuf.nsamples = dataSize / (wavHeader.bits_per_sample >> 3);
|
||||
waveBuf.looping = toloop;
|
||||
waveBuf.status = NDSP_WBUF_FREE;
|
||||
chnl = channel;
|
||||
}
|
||||
|
||||
sound::~sound() {
|
||||
waveBuf.data_vaddr = 0;
|
||||
waveBuf.nsamples = 0;
|
||||
waveBuf.looping = false;
|
||||
waveBuf.status = 0;
|
||||
ndspChnWaveBufClear(chnl);
|
||||
|
||||
if (data) {
|
||||
linearFree(data);
|
||||
}
|
||||
}
|
||||
|
||||
void sound::play() {
|
||||
if (!data) return;
|
||||
DSP_FlushDataCache(data, dataSize);
|
||||
ndspChnWaveBufAdd(chnl, &waveBuf);
|
||||
}
|
||||
|
||||
void sound::stop() {
|
||||
if (!data) return;
|
||||
ndspChnWaveBufClear(chnl);
|
||||
}
|
21
sound.hpp
Normal file
21
sound.hpp
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef _UNIVERSAL_UPDATER_SOUND_H
|
||||
#define _UNIVERSAL_UPDATER_SOUND_H
|
||||
|
||||
#include <3ds.h>
|
||||
#include <string>
|
||||
|
||||
class sound {
|
||||
public:
|
||||
sound(const std::string& path, int channel = 1, bool toloop = false);
|
||||
~sound();
|
||||
void play();
|
||||
void stop();
|
||||
|
||||
private:
|
||||
u32 dataSize;
|
||||
ndspWaveBuf waveBuf;
|
||||
u8* data = NULL;
|
||||
int chnl;
|
||||
};
|
||||
|
||||
#endif
|
229
source/Color.cpp
229
source/Color.cpp
@ -1,229 +0,0 @@
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <renderd7/Color.hpp>
|
||||
#include <renderd7/Message.hpp>
|
||||
#include <renderd7/external/json.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
|
||||
void rd7i_swap32(unsigned int& c) {
|
||||
c = ((c & 0xFF) << 24) | ((c & 0xFF00) << 8) | ((c & 0xFF0000) >> 8) |
|
||||
((c & 0xFF000000) >> 24);
|
||||
}
|
||||
|
||||
std::string RenderD7::Color::RGBA2Hex(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 = {
|
||||
{'0', 0}, {'1', 1}, {'2', 2}, {'3', 3}, {'4', 4}, {'5', 5},
|
||||
{'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}};
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// Default Theme
|
||||
const std::map<RD7Color, unsigned int> rd7i_default_theme = {
|
||||
{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)},
|
||||
};
|
||||
|
||||
void RenderD7::Theme::Load(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;
|
||||
}
|
||||
this->clr_tab.clear();
|
||||
this->clr_tab.resize(RD7Color_Len);
|
||||
this->clr_tab[RD7Color_Text] = rd7i_special_color_hex(js["RD7Color_Text"].get<std::string>());
|
||||
this->clr_tab[RD7Color_Text2] = rd7i_special_color_hex(js["RD7Color_Text2"].get<std::string>());
|
||||
this->clr_tab[RD7Color_TextDisabled] = rd7i_special_color_hex(js["RD7Color_TextDisabled"].get<std::string>());
|
||||
this->clr_tab[RD7Color_Background] = rd7i_special_color_hex(js["RD7Color_Background"].get<std::string>());
|
||||
this->clr_tab[RD7Color_Header] = rd7i_special_color_hex(js["RD7Color_Header"].get<std::string>());
|
||||
this->clr_tab[RD7Color_Selector] = rd7i_special_color_hex(js["RD7Color_Selector"].get<std::string>());
|
||||
this->clr_tab[RD7Color_SelectorFade] = rd7i_special_color_hex(js["RD7Color_SelectorFade"].get<std::string>());
|
||||
this->clr_tab[RD7Color_List0] = rd7i_special_color_hex(js["RD7Color_List0"].get<std::string>());
|
||||
this->clr_tab[RD7Color_List1] = rd7i_special_color_hex(js["RD7Color_List1"].get<std::string>());
|
||||
this->clr_tab[RD7Color_MessageBackground] = rd7i_special_color_hex(js["RD7Color_MessageBackground"].get<std::string>());
|
||||
this->clr_tab[RD7Color_Button] = rd7i_special_color_hex(js["RD7Color_Button"].get<std::string>());
|
||||
this->clr_tab[RD7Color_ButtonHovered] = rd7i_special_color_hex(js["RD7Color_ButtonHovered"].get<std::string>());
|
||||
this->clr_tab[RD7Color_ButtonDisabled] = rd7i_special_color_hex(js["RD7Color_ButtonDisabled"].get<std::string>());
|
||||
this->clr_tab[RD7Color_ButtonActive] = rd7i_special_color_hex(js["RD7Color_ButtonActive"].get<std::string>());
|
||||
this->clr_tab[RD7Color_Checkmark] = rd7i_special_color_hex(js["RD7Color_Checkmark"].get<std::string>());
|
||||
this->clr_tab[RD7Color_FrameBg] = rd7i_special_color_hex(js["RD7Color_FrameBg"].get<std::string>());
|
||||
this->clr_tab[RD7Color_FrameBgHovered] = rd7i_special_color_hex(js["RD7Color_FrameBgHovered"].get<std::string>());
|
||||
this->clr_tab[RD7Color_Progressbar] = rd7i_special_color_hex(js["RD7Color_Progressbar"].get<std::string>());
|
||||
// clang-format on
|
||||
file.close();
|
||||
}
|
||||
|
||||
void RenderD7::Theme::Default() {
|
||||
this->clr_tab.clear();
|
||||
this->clr_tab.resize(RD7Color_Len);
|
||||
for (auto& it : rd7i_default_theme) {
|
||||
this->clr_tab[it.first] = it.second;
|
||||
}
|
||||
}
|
||||
|
||||
void RenderD7::Theme::CopyOther(Theme::Ref theme) {
|
||||
this->clr_tab.clear();
|
||||
this->clr_tab.resize(RD7Color_Len);
|
||||
for (int i = 0; i < (int)RD7Color_Len; i++) {
|
||||
this->clr_tab[i] = theme->Get(i);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int RenderD7::Theme::Get(RD7Color clr) {
|
||||
if (clr < 0 || clr >= RD7Color_Len) return 0;
|
||||
return this->clr_tab[clr];
|
||||
}
|
||||
|
||||
void RenderD7::Theme::Set(RD7Color clr, unsigned int v) {
|
||||
if (clr < 0 || clr >= RD7Color_Len) return;
|
||||
this->changes.push_back(change(clr, this->clr_tab[clr], v));
|
||||
this->clr_tab[clr] = v;
|
||||
}
|
||||
void RenderD7::Theme::Swap(RD7Color a, RD7Color b) {
|
||||
if (a < 0 || a >= RD7Color_Len || b < 0 || b >= RD7Color_Len) return;
|
||||
auto c = this->clr_tab[a];
|
||||
this->clr_tab[a] = this->clr_tab[b];
|
||||
this->clr_tab[b] = c;
|
||||
this->changes.push_back(change(a, b, c, this->clr_tab[a]));
|
||||
}
|
||||
|
||||
void RenderD7::Theme::TextBy(RD7Color bg) {
|
||||
if (!Color::RGBA(bg).is_light()) Swap(RD7Color_Text, RD7Color_Text2);
|
||||
}
|
||||
|
||||
RD7Color RenderD7::Theme::AutoText(RD7Color bg) {
|
||||
return Color::RGBA(bg).is_light() ? RD7Color_Text : RD7Color_Text2;
|
||||
}
|
||||
|
||||
bool RenderD7::Theme::Undo() {
|
||||
if (!this->changes.size()) return false;
|
||||
auto ch = this->changes[this->changes.size() - 1];
|
||||
this->changes.pop_back();
|
||||
if (ch.clr2) {
|
||||
this->clr_tab[ch.clr2] = ch.to;
|
||||
this->clr_tab[ch.clr] = ch.from;
|
||||
} else {
|
||||
this->clr_tab[ch.clr] = ch.from;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderD7::Theme::UndoAll() {
|
||||
while (Undo()) {
|
||||
// Just Run Undo Until all is undone
|
||||
}
|
||||
}
|
||||
|
||||
void RenderD7::Theme::Save(const std::string& path) {
|
||||
if (std::filesystem::path(path).filename().string() == "renderd7.theme") {
|
||||
if (!rd7i_amdt) {
|
||||
RenderD7::PushMessage("Theme", "Default Theme cannot\nbe overwritten!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
std::ofstream file(path);
|
||||
if (!file.is_open()) {
|
||||
RenderD7::PushMessage("Theme", "Unable to\ncreate file!");
|
||||
return;
|
||||
}
|
||||
nlohmann::json js;
|
||||
// clang-format off
|
||||
js["version"] = THEMEVER;
|
||||
js["RD7Color_Text"] = RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_Text]);
|
||||
js["RD7Color_Text2"] = RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_Text2]);
|
||||
js["RD7Color_TextDisabled"] =
|
||||
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_TextDisabled]); js["RD7Color_Background"] =
|
||||
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_Background]); js["RD7Color_Header"] =
|
||||
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_Header]); js["RD7Color_Selector"] =
|
||||
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_Selector]); js["RD7Color_SelectorFade"] =
|
||||
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_SelectorFade]); js["RD7Color_List0"] =
|
||||
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_List0]); js["RD7Color_List1"] =
|
||||
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_List1]); js["RD7Color_MessageBackground"] =
|
||||
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_MessageBackground]); js["RD7Color_Button"] =
|
||||
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_Button]); js["RD7Color_ButtonHovered"] =
|
||||
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_ButtonHovered]);
|
||||
js["RD7Color_ButtonDisabled"] =
|
||||
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_ButtonDisabled]);
|
||||
js["RD7Color_ButtonActive"] =
|
||||
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_ButtonActive]); js["RD7Color_Checkmark"] =
|
||||
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_Checkmark]); js["RD7Color_FrameBg"] =
|
||||
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_FrameBg]); js["RD7Color_FrameBgHovered"] =
|
||||
RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_FrameBgHovered]); js["RD7Color_Progressbar"]
|
||||
= RenderD7::Color::RGBA2Hex(this->clr_tab[RD7Color_Progressbar]);
|
||||
// clang-format on
|
||||
file << js.dump(4);
|
||||
file.close();
|
||||
}
|
||||
|
||||
RenderD7::Theme::Ref RenderD7::ThemeActive() { return rd7i_active_theme; }
|
||||
|
||||
void RenderD7::ThemeSet(RenderD7::Theme::Ref theme) {
|
||||
rd7i_active_theme = theme;
|
||||
}
|
||||
|
||||
unsigned int RenderD7::Color::Hex(const std::string& color, uint8_t a) {
|
||||
if (color.length() < 7 ||
|
||||
std::find_if(color.begin() + 1, color.end(),
|
||||
[](char c) { return !std::isxdigit(c); }) != color.end()) {
|
||||
return RenderD7::Color::Hex("#000000", 0);
|
||||
}
|
||||
|
||||
int r = HEX_TO_DEC.at(color[1]) * 16 + HEX_TO_DEC.at(color[2]);
|
||||
int g = HEX_TO_DEC.at(color[3]) * 16 + HEX_TO_DEC.at(color[4]);
|
||||
int b = HEX_TO_DEC.at(color[5]) * 16 + HEX_TO_DEC.at(color[6]);
|
||||
|
||||
return RGBA8(r, g, b, a);
|
||||
}
|
||||
|
||||
std::string RenderD7::Color::RGB2Hex(int r, int g, int b) {
|
||||
std::stringstream ss;
|
||||
ss << "#";
|
||||
ss << std::hex << (r << 16 | g << 8 | b);
|
||||
return ss.str();
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
#include <3ds.h>
|
||||
|
||||
#include <renderd7/Error.hpp>
|
||||
#include <renderd7/UI7.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
#include <renderd7/renderd7.hpp>
|
||||
|
||||
void rd7i_save_report(const std::string& msg) {
|
||||
auto ts = RenderD7::GetTimeStr();
|
||||
std::ofstream f("sdmc:/RenderD7/Reports/report_" + ts + ".txt");
|
||||
f << "RenderD7 Error [" << rd7i_app_name << ", " << ts << "]" << std::endl;
|
||||
f << "Error Message: " << std::endl;
|
||||
f << msg << std::endl;
|
||||
f << "SysInfo: " << std::endl;
|
||||
f << "- Citra -> " << (rd7i_is_citra ? "true" : "false") << std::endl;
|
||||
f.close();
|
||||
}
|
||||
|
||||
namespace RenderD7 {
|
||||
void Error(const std::string& msg) {
|
||||
rd7i_save_report(msg);
|
||||
if (rd7i_graphics_on) {
|
||||
while (aptMainLoop()) {
|
||||
hidScanInput();
|
||||
if (hidKeysDown() & KEY_START) break;
|
||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||
RenderD7::ClearTextBufs();
|
||||
C2D_TargetClear(rd7_top, 0x00000000);
|
||||
C2D_TargetClear(rd7_bottom, 0x00000000);
|
||||
RenderD7::R2()->OnScreen(R2Screen_Top);
|
||||
if (UI7::BeginMenu("RenderD7 - Error Manager", R7Vec2(),
|
||||
UI7MenuFlags_TitleMid)) {
|
||||
UI7::Label(msg, RD7TextFlags_Wrap);
|
||||
UI7::Label("Press Start to Exit!");
|
||||
UI7::EndMenu();
|
||||
}
|
||||
RenderD7::R2()->OnScreen(R2Screen_Bottom);
|
||||
UI7::Update();
|
||||
RenderD7::R2()->Process();
|
||||
C3D_FrameEnd(0);
|
||||
}
|
||||
exit(0);
|
||||
} else {
|
||||
gfxInitDefault();
|
||||
consoleInit(GFX_TOP, NULL);
|
||||
printf("RENDERD7 - ERROR MANAGER\n\n%s\n", msg.c_str());
|
||||
printf("Report Saved in\nsdmc:/RenderD7/Reports\n");
|
||||
printf("Press Start to Exit\n");
|
||||
while (aptMainLoop()) {
|
||||
hidScanInput();
|
||||
if (hidKeysDown() & KEY_START) break;
|
||||
gfxSwapBuffers();
|
||||
}
|
||||
gfxExit();
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
} // namespace RenderD7
|
@ -1,70 +0,0 @@
|
||||
#include <3ds.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <renderd7/FileSystem.hpp>
|
||||
// Debugging
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
#include <renderd7/stringtool.hpp>
|
||||
|
||||
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::string RenderD7::FileSystem::GetParentPath(std::string path,
|
||||
std::string mount_point) {
|
||||
std::string tcl = path;
|
||||
if (path.substr(path.length() - 1, 1) != "/") {
|
||||
tcl += "/";
|
||||
}
|
||||
std::string 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;
|
||||
for (const auto &entry :
|
||||
std::filesystem::directory_iterator(std::filesystem::path(path))) {
|
||||
res.push_back({entry.path().string(), GetFileName(entry.path().string()),
|
||||
entry.is_directory()});
|
||||
}
|
||||
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;
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
#include <renderd7/FunctionTrace.hpp>
|
||||
|
||||
std::map<std::string, RenderD7::Ftrace::FTRes> RenderD7::Ftrace::rd7_traces;
|
@ -1,47 +0,0 @@
|
||||
#include <renderd7/Hardware.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
|
||||
// Os Specific includes
|
||||
#include <3ds.h>
|
||||
|
||||
void RenderD7::Hardware::Initialisize() {
|
||||
mcuHwcInit();
|
||||
atexit(mcuHwcExit);
|
||||
ptmuInit();
|
||||
atexit(ptmuExit);
|
||||
}
|
||||
|
||||
bool RenderD7::Hardware::IsHeadphones() {
|
||||
if (rd7i_is_ndsp) {
|
||||
bool inserted;
|
||||
DSP_GetHeadphoneStatus(&inserted);
|
||||
return inserted;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RenderD7::Hardware::IsCharging() {
|
||||
uint8_t var;
|
||||
PTMU_GetBatteryChargeState(&var);
|
||||
// Some Security Stuff
|
||||
if (var < 0x00 && var > 0x01) {
|
||||
return false;
|
||||
}
|
||||
return (var == 0x01 ? true : false);
|
||||
}
|
||||
|
||||
int RenderD7::Hardware::GetBatteryPercentage() {
|
||||
uint8_t percentLevel = 0;
|
||||
MCUHWC_GetBatteryLevel(&percentLevel);
|
||||
return percentLevel;
|
||||
}
|
||||
|
||||
float RenderD7::Hardware::Get3dSliderLevel() { return osGet3DSliderState(); }
|
||||
|
||||
float RenderD7::Hardware::GetSoundSliderLevel() {
|
||||
uint8_t percentLevel;
|
||||
MCUHWC_GetSoundSliderLevel(&percentLevel);
|
||||
return (float)percentLevel / 100;
|
||||
}
|
||||
|
||||
int RenderD7::Hardware::GetWifiLevel() { return osGetWifiStrength(); }
|
120
source/Hid.cpp
120
source/Hid.cpp
@ -1,120 +0,0 @@
|
||||
#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();
|
||||
dtp = 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; }
|
||||
R7Vec2 getTouchDownPos() { return dtp; }
|
||||
|
||||
void update() {
|
||||
last_touch_pos = touch_pos[0];
|
||||
if (isEvent("touch", Hid::Down)) {
|
||||
dtp = touch_pos[0];
|
||||
}
|
||||
if (isEvent("touch", Hid::Up)) {
|
||||
dtp = R7Vec2();
|
||||
}
|
||||
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;
|
||||
R7Vec2 dtp;
|
||||
|
||||
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(); }
|
||||
R7Vec2 GetTouchDownPosition() { return hid_handler.getTouchDownPos(); }
|
||||
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
|
181
source/Image.cpp
181
source/Image.cpp
@ -1,181 +0,0 @@
|
||||
#include <renderd7/external/stb_image.h>
|
||||
|
||||
#include <renderd7/Image.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
#include <vector>
|
||||
|
||||
static u32 __rd7i_gp2o__(u32 v) {
|
||||
v--;
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
v |= v >> 4;
|
||||
v |= v >> 8;
|
||||
v |= v >> 16;
|
||||
v++;
|
||||
return (v >= 64 ? v : 64);
|
||||
}
|
||||
|
||||
static void __rd7i_r24r32(std::vector<uint8_t> &out,
|
||||
const std::vector<uint8_t> &in, const int &w,
|
||||
const int &h) {
|
||||
// Converts RGB24 to RGBA32
|
||||
for (int y = 0; y < h; y++) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
int src = (y * w + x) * 3;
|
||||
int dst = (y * w + x) * 4;
|
||||
out[dst + 0] = in[src + 0];
|
||||
out[dst + 1] = in[src + 1];
|
||||
out[dst + 2] = in[src + 2];
|
||||
out[dst + 3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void __rd7i_maketex__(C3D_Tex *tex, Tex3DS_SubTexture *sub,
|
||||
std::vector<unsigned char> &buf, int w, int h) {
|
||||
if (!tex || !sub) {
|
||||
_rd7i_logger()->Write("Invalid Inpit (objects have no adress!)");
|
||||
return;
|
||||
}
|
||||
// RGBA -> Abgr
|
||||
for (int y = 0; y < h; y++) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
int pos = (x + y * w) * 4;
|
||||
auto r = buf[pos + 0];
|
||||
auto g = buf[pos + 1];
|
||||
auto b = buf[pos + 2];
|
||||
auto a = buf[pos + 3];
|
||||
buf[pos + 0] = a;
|
||||
buf[pos + 1] = b;
|
||||
buf[pos + 2] = g;
|
||||
buf[pos + 3] = r;
|
||||
}
|
||||
}
|
||||
|
||||
// Pow2
|
||||
int wp2 = __rd7i_gp2o__((unsigned int)w);
|
||||
int hp2 = __rd7i_gp2o__((unsigned int)h);
|
||||
|
||||
sub->width = (u16)w;
|
||||
sub->height = (u16)h;
|
||||
sub->left = 0.0f;
|
||||
sub->top = 1.0f;
|
||||
sub->right = ((float)w / (float)wp2);
|
||||
sub->bottom = 1.0 - ((float)h / (float)hp2);
|
||||
|
||||
// Texture Setup
|
||||
C3D_TexInit(tex, (u16)wp2, (u16)hp2, GPU_RGBA8);
|
||||
C3D_TexSetFilter(tex, GPU_NEAREST, GPU_NEAREST);
|
||||
|
||||
memset(tex->data, 0, tex->size);
|
||||
|
||||
for (int x = 0; x < w; x++) {
|
||||
for (int y = 0; y < h; y++) {
|
||||
int dst_pos = ((((y >> 3) * (wp2 >> 3) + (x >> 3)) << 6) +
|
||||
((x & 1) | ((y & 1) << 1) | ((x & 2) << 1) |
|
||||
((y & 2) << 2) | ((x & 4) << 2) | ((y & 4) << 3))) *
|
||||
4;
|
||||
int src_pos = (y * w + x) * 4;
|
||||
|
||||
memcpy(&((unsigned char *)tex->data)[dst_pos], &buf[src_pos], 4);
|
||||
}
|
||||
}
|
||||
|
||||
C3D_TexFlush(tex);
|
||||
tex->border = 0x00000000;
|
||||
C3D_TexSetWrap(tex, GPU_CLAMP_TO_BORDER, GPU_CLAMP_TO_BORDER);
|
||||
}
|
||||
|
||||
namespace RenderD7 {
|
||||
|
||||
void Image::Load(const std::string &path) {
|
||||
// Make sure to cleanup
|
||||
Delete();
|
||||
ext = false;
|
||||
// Setup Func and Load Data
|
||||
int w, h, c = 0;
|
||||
unsigned char *image = stbi_load(path.c_str(), &w, &h, &c, 4);
|
||||
if (image == nullptr) {
|
||||
//_rd7i_logger()->Write("Failed to Load Image: " + path);
|
||||
return;
|
||||
}
|
||||
// Size/Fmt Check
|
||||
if (w > 1024 || h > 1024) {
|
||||
// Reason: Image to Large
|
||||
//_rd7i_logger()->Write("Image too Large!");
|
||||
stbi_image_free(image);
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> wimg;
|
||||
if (c == 3) {
|
||||
//_rd7i_logger()->Write("Convert Image to RGBA");
|
||||
stbi_image_free(image);
|
||||
image = stbi_load(path.c_str(), &w, &h, &c, 3);
|
||||
wimg.resize(w * h * 4);
|
||||
__rd7i_r24r32(wimg, std::vector<unsigned char>(image, image + (w * h * 3)),
|
||||
w, h);
|
||||
} else {
|
||||
wimg.assign(&image[0], &image[(w * h * 4) - 1]);
|
||||
stbi_image_free(image);
|
||||
}
|
||||
// Create C2D_Image
|
||||
C3D_Tex *tex = new C3D_Tex;
|
||||
Tex3DS_SubTexture *subtex = new Tex3DS_SubTexture;
|
||||
__rd7i_maketex__(tex, subtex, wimg, w, h);
|
||||
_rd7i_logger()->Write(RenderD7::FormatString("Created Texture (%d, %d)",
|
||||
tex->width, tex->height));
|
||||
img = {tex, subtex};
|
||||
}
|
||||
|
||||
void Image::From_NIMG(const nimg &image) {
|
||||
// Make sure to cleanup
|
||||
Delete();
|
||||
ext = false;
|
||||
if (image.width > 1024 || image.height > 1024) return;
|
||||
C3D_Tex *tex = new C3D_Tex;
|
||||
Tex3DS_SubTexture *subtex = new Tex3DS_SubTexture;
|
||||
std::vector<unsigned char> mdpb = image.pixel_buffer;
|
||||
__rd7i_maketex__(tex, subtex, mdpb, image.width, image.height);
|
||||
img = {tex, subtex};
|
||||
}
|
||||
|
||||
C2D_Image Image::Get() {
|
||||
if (!Loadet()) {
|
||||
_rd7i_logger()->Write("Image not Loadet!");
|
||||
}
|
||||
return img;
|
||||
}
|
||||
C2D_Image &Image::GetRef() {
|
||||
if (!Loadet()) {
|
||||
_rd7i_logger()->Write("Image not Loadet!");
|
||||
}
|
||||
return img;
|
||||
}
|
||||
|
||||
void Image::Set(const C2D_Image &i) {
|
||||
Delete();
|
||||
ext = true;
|
||||
img = i;
|
||||
}
|
||||
|
||||
R7Vec2 Image::GetSize() {
|
||||
if (!img.subtex) return R7Vec2(0, 0);
|
||||
return R7Vec2(img.subtex->width, img.subtex->height);
|
||||
}
|
||||
|
||||
void Image::Delete() {
|
||||
if (ext) return;
|
||||
if (img.subtex != nullptr) {
|
||||
delete img.subtex;
|
||||
img.subtex = nullptr;
|
||||
}
|
||||
if (img.tex != nullptr) {
|
||||
C3D_TexDelete(img.tex);
|
||||
delete img.tex;
|
||||
img.tex = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool Image::Loadet() { return (img.subtex != nullptr && img.tex != nullptr); }
|
||||
} // namespace RenderD7
|
@ -1,149 +0,0 @@
|
||||
#include <3ds.h>
|
||||
|
||||
#include <renderd7/Installer.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
|
||||
namespace RenderD7 {
|
||||
Result DeletePrevious(u64 id, FS_MediaType mt) {
|
||||
if (!rd7i_is_am_init) return -1;
|
||||
u32 num_titles = 0;
|
||||
Result ret = AM_GetTitleCount(mt, &num_titles);
|
||||
if (R_FAILED(ret)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
u32 read_titles = 0;
|
||||
auto ids = new u64[num_titles];
|
||||
ret = AM_GetTitleList(&read_titles, mt, num_titles, ids);
|
||||
|
||||
if (R_FAILED(ret)) {
|
||||
delete[] ids;
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < read_titles; i++) {
|
||||
if (ids[i] == id) {
|
||||
ret = AM_DeleteAppTitle(mt, id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] ids;
|
||||
if (R_FAILED(ret)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
FS_MediaType GetTitleDest(u64 id) {
|
||||
u16 platform = (u16)((id >> 48) & 0xFFFF);
|
||||
u16 category = (u16)((id >> 32) & 0xFFFF);
|
||||
u8 variation = (u8)(id & 0xFF);
|
||||
|
||||
/* DSiWare 3DS DSiWare, System, DLP
|
||||
* Application System Title */
|
||||
return platform == 0x0003 || (platform == 0x0004 &&
|
||||
((category & 0x8011) != 0 ||
|
||||
(category == 0x0000 && variation == 0x02)))
|
||||
? MEDIATYPE_NAND
|
||||
: MEDIATYPE_SD;
|
||||
}
|
||||
|
||||
InstallerInfo rd7i_installer_info;
|
||||
|
||||
InstallerInfo InstallGetInfo() { return rd7i_installer_info; }
|
||||
|
||||
void InstallSetBuffersSize(unsigned int bytes) {
|
||||
if (rd7i_installer_info.active) return;
|
||||
if (bytes == 0) return;
|
||||
if (bytes >= 0x200000) bytes = 0x200000;
|
||||
rd7i_installer_info.mem_size = bytes;
|
||||
}
|
||||
|
||||
Result InstallCia(const std::string& path, bool self) {
|
||||
if (!rd7i_is_am_init) return -1;
|
||||
if (rd7i_installer_info.active) return -1;
|
||||
u32 bytes_read = 0;
|
||||
u32 bytes_written = 0;
|
||||
rd7i_installer_info.current = 0;
|
||||
// Set 1 to avoid div0 error
|
||||
rd7i_installer_info.total = 1;
|
||||
u64 size = 0;
|
||||
Handle cia, file;
|
||||
AM_TitleEntry info;
|
||||
Result ret = 0;
|
||||
FS_MediaType media = MEDIATYPE_SD;
|
||||
|
||||
std::string pth;
|
||||
if (path[0] == '/') {
|
||||
pth = path;
|
||||
} else if (path.substr(0, 5) == "sdmc:") {
|
||||
pth = path.substr(5);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = FSUSER_OpenFileDirectly(&file, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, ""),
|
||||
fsMakePath(PATH_ASCII, pth.c_str()),
|
||||
FS_OPEN_READ, 0);
|
||||
|
||||
if (R_FAILED(ret)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = AM_GetCiaFileInfo(media, &info, file);
|
||||
|
||||
if (R_FAILED(ret)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
media = GetTitleDest(info.titleID);
|
||||
|
||||
if (!self) {
|
||||
ret = DeletePrevious(info.titleID, media);
|
||||
if (R_FAILED(ret)) return ret;
|
||||
}
|
||||
|
||||
ret = FSFILE_GetSize(file, &size);
|
||||
|
||||
if (R_FAILED(ret)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = AM_StartCiaInstall(media, &cia);
|
||||
|
||||
if (R_FAILED(ret)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> buf(rd7i_installer_info.mem_size);
|
||||
rd7i_installer_info.total = size;
|
||||
|
||||
do {
|
||||
FSFILE_Read(file, &bytes_read, rd7i_installer_info.current, &buf[0],
|
||||
buf.size());
|
||||
FSFILE_Write(cia, &bytes_written, rd7i_installer_info.current, &buf[0],
|
||||
buf.size(), FS_WRITE_FLUSH);
|
||||
rd7i_installer_info.current += bytes_read;
|
||||
} while (rd7i_installer_info.current < rd7i_installer_info.total);
|
||||
|
||||
ret = AM_FinishCiaInstall(cia);
|
||||
|
||||
if (R_FAILED(ret)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = FSFILE_Close(file);
|
||||
|
||||
if (R_FAILED(ret)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (self) {
|
||||
aptSetChainloaderToSelf();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
} // namespace RenderD7
|
@ -1,44 +0,0 @@
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <renderd7/Logger.hpp>
|
||||
#include <renderd7/Time.hpp>
|
||||
#include <renderd7/renderd7.hpp>
|
||||
|
||||
namespace RenderD7 {
|
||||
LoggerBase::~LoggerBase() {
|
||||
if (_log.is_open()) _log.close();
|
||||
}
|
||||
void LoggerBase::Init(const std::string& name, bool fileless) {
|
||||
if (!fileless) {
|
||||
std::string path_base = RenderD7::GetAppDirectory() + "/logs/";
|
||||
if (!std::filesystem::is_directory(path_base)) {
|
||||
std::filesystem::create_directories(path_base);
|
||||
}
|
||||
auto ts = RenderD7::GetTimeStr();
|
||||
std::string fn = name + ts + ".txt";
|
||||
this->filename = name;
|
||||
this->log_path = path_base + name;
|
||||
if (std::filesystem::exists(this->log_path)) {
|
||||
// Do nothing
|
||||
} else {
|
||||
_log.open(this->log_path, std::ios::out);
|
||||
}
|
||||
}
|
||||
this->Write("RenderD7 Log\n\n");
|
||||
}
|
||||
|
||||
void LoggerBase::Write(const std::string& debug_text, int lvl) {
|
||||
std::string msg = "[" + RenderD7::GetTimeStr() + "]: " + debug_text;
|
||||
if (this->_log.is_open() && lvl <= writelvl) {
|
||||
this->_log << msg << std::endl;
|
||||
}
|
||||
/*while (msg.find_first_of('\n') != 0) {
|
||||
lines.push_back(msg.substr(0, msg.find_first_of('\n')));
|
||||
msg = msg.substr(msg.find_first_of('\n'));
|
||||
}*/
|
||||
lines.push_back(msg);
|
||||
}
|
||||
|
||||
const std::vector<std::string>& LoggerBase::Lines() { return this->lines; }
|
||||
} // namespace RenderD7
|
@ -1,56 +0,0 @@
|
||||
#include <cstdlib>
|
||||
#include <map>
|
||||
#include <renderd7/Memory.hpp>
|
||||
|
||||
static RenderD7::Memory::memory_metrics metrics;
|
||||
|
||||
bool rd7i_enable_memtrack;
|
||||
|
||||
void *operator new(size_t size) {
|
||||
void *ptr = malloc(size);
|
||||
if (rd7i_enable_memtrack) metrics.t_TotalAllocated += size;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void operator delete(void *memory, size_t size) {
|
||||
if (rd7i_enable_memtrack) metrics.t_TotalFreed += size;
|
||||
free(memory);
|
||||
}
|
||||
|
||||
int allocations = 0;
|
||||
int total_size = 0;
|
||||
std::map<void *, size_t> sizes;
|
||||
|
||||
void *operator new[](size_t size) {
|
||||
void *ptr = malloc(size);
|
||||
if (rd7i_enable_memtrack) {
|
||||
allocations++;
|
||||
total_size += size;
|
||||
sizes[ptr] = size;
|
||||
metrics.t_TotalAllocated += size;
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void operator delete[](void *ptr) {
|
||||
if (rd7i_enable_memtrack) {
|
||||
allocations--;
|
||||
total_size -= sizes[ptr];
|
||||
metrics.t_TotalFreed += sizes[ptr];
|
||||
sizes.erase(ptr);
|
||||
}
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
namespace RenderD7 {
|
||||
|
||||
namespace Memory {
|
||||
|
||||
size_t GetTotalAllocated() { return metrics.t_TotalAllocated; }
|
||||
|
||||
size_t GetTotalFreed() { return metrics.t_TotalFreed; }
|
||||
|
||||
size_t GetCurrent() { return metrics.t_CurrentlyAllocated(); }
|
||||
} // namespace Memory
|
||||
} // namespace RenderD7
|
@ -1,95 +0,0 @@
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <renderd7/Color.hpp>
|
||||
#include <renderd7/Message.hpp>
|
||||
#include <renderd7/renderd7.hpp>
|
||||
#include <vector>
|
||||
|
||||
extern bool rd7i_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() {
|
||||
float tmp_txt = R2::GetTextSize();
|
||||
R2::DefaultTextSize();
|
||||
// Draw in ovl mode
|
||||
R2::OnScreen(R2Screen_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
|
||||
auto bgc = RenderD7::Color::RGBA(RD7Color_MessageBackground)
|
||||
.changeA(new_alpha)
|
||||
.toRGBA();
|
||||
auto tc =
|
||||
RenderD7::Color::RGBA(RD7Color_Text2).changeA(new_alpha).toRGBA();
|
||||
R2::AddRect(pos, R7Vec2(150, 50), bgc);
|
||||
R2::AddText(pos + R7Vec2(5, 1), msg_lst[i]->title, tc);
|
||||
R2::AddText(pos + R7Vec2(5, 17), msg_lst[i]->message, tc);
|
||||
if (rd7i_debugging)
|
||||
R2::AddText(pos + R7Vec2(155, 1),
|
||||
std::to_string(msg_lst[i]->animationframe), tc);
|
||||
// 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());
|
||||
R2::SetTextSize(tmp_txt);
|
||||
}
|
||||
|
||||
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
|
245
source/Net.cpp
245
source/Net.cpp
@ -1,245 +0,0 @@
|
||||
// TODO: Make Download2File faster on large files
|
||||
|
||||
#include <3ds.h>
|
||||
#include <curl/curl.h>
|
||||
#include <malloc.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <regex>
|
||||
#include <renderd7/Net.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
|
||||
static RenderD7::Net::Error rd7i_check_wifi() {
|
||||
// if (rd7i_is_citra) return 0;
|
||||
int s = osGetWifiStrength();
|
||||
return (s == 0 ? RenderD7::Net::Error_NoWifi : 0);
|
||||
}
|
||||
|
||||
static size_t rd7i_handle_data(char* ptr, size_t size, size_t nmemb,
|
||||
void* userdata) {
|
||||
size_t ms = size * nmemb;
|
||||
((std::string*)userdata)->append(ptr, ms);
|
||||
return ms;
|
||||
}
|
||||
|
||||
static size_t rd7i_handle_file(char* ptr, size_t size, size_t nmemb,
|
||||
void* out) {
|
||||
size_t ms = size * nmemb;
|
||||
((std::ofstream*)out)->write(reinterpret_cast<const char*>(ptr), ms);
|
||||
return ms;
|
||||
}
|
||||
|
||||
struct rd7i_net_dl {
|
||||
unsigned long long current = 0;
|
||||
unsigned long long total = 1;
|
||||
void Reset() {
|
||||
current = 0;
|
||||
total = 1;
|
||||
}
|
||||
};
|
||||
|
||||
static rd7i_net_dl rd7i_net_dl_spec;
|
||||
|
||||
static int rd7i_handle_curl_progress(CURL* hnd, curl_off_t dltotal,
|
||||
curl_off_t dlnow, curl_off_t ultotal,
|
||||
curl_off_t ulnow) {
|
||||
rd7i_net_dl_spec.total = dltotal;
|
||||
rd7i_net_dl_spec.current = dlnow;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rd7i_setup_curl_context(CURL* hnd, const std::string& url,
|
||||
void* userptr, bool mem) {
|
||||
std::string user_agent =
|
||||
rd7i_app_name + "/RenderD7 (Version: " + std::string(RENDERD7VSTRING) +
|
||||
")";
|
||||
|
||||
if (!mem) {
|
||||
curl_easy_setopt(hnd, CURLOPT_FAILONERROR, 1L);
|
||||
curl_easy_setopt(hnd, CURLOPT_ACCEPT_ENCODING, "gzip");
|
||||
curl_easy_setopt(hnd, CURLOPT_XFERINFOFUNCTION, rd7i_handle_curl_progress);
|
||||
}
|
||||
|
||||
curl_easy_setopt(hnd, CURLOPT_URL, url.c_str());
|
||||
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 0L);
|
||||
curl_easy_setopt(hnd, CURLOPT_USERAGENT, user_agent.c_str());
|
||||
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, userptr);
|
||||
curl_easy_setopt(hnd, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
|
||||
curl_easy_setopt(hnd, CURLOPT_HTTP_VERSION, (long)CURL_HTTP_VERSION_2TLS);
|
||||
curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION,
|
||||
mem ? rd7i_handle_data : rd7i_handle_file);
|
||||
curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
|
||||
curl_easy_setopt(hnd, CURLOPT_STDERR, stdout);
|
||||
}
|
||||
|
||||
static bool rd7i_curl_is_busy = false;
|
||||
static bool rd7i_apir_is_busy = false;
|
||||
|
||||
namespace RenderD7 {
|
||||
namespace Net {
|
||||
Error Download(const std::string& url, std::string& data) {
|
||||
if (rd7i_curl_is_busy) return Error_Busy;
|
||||
Error ret = rd7i_check_wifi();
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
rd7i_curl_is_busy = true;
|
||||
rd7i_net_dl_spec.Reset();
|
||||
|
||||
auto hnd = curl_easy_init();
|
||||
rd7i_setup_curl_context(hnd, url, &data, true);
|
||||
|
||||
CURLcode curl_res = curl_easy_perform(hnd);
|
||||
curl_easy_cleanup(hnd);
|
||||
|
||||
if (curl_res != CURLE_OK) {
|
||||
data.clear();
|
||||
rd7i_curl_is_busy = false;
|
||||
return ((static_cast<Error>(curl_res) << 32) |
|
||||
static_cast<Error>(Error_Curl));
|
||||
}
|
||||
|
||||
rd7i_curl_is_busy = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Error Download2File(const std::string& url, const std::string& path) {
|
||||
if (rd7i_curl_is_busy) return Error_Busy;
|
||||
Error ret = rd7i_check_wifi();
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
rd7i_curl_is_busy = true;
|
||||
rd7i_net_dl_spec.Reset();
|
||||
// std::filesystem::create_directories(
|
||||
// std::filesystem::path(path).remove_filename());
|
||||
std::ofstream file(path, std::ios::binary);
|
||||
|
||||
if (!file.is_open()) {
|
||||
rd7i_curl_is_busy = false;
|
||||
return Error_Write;
|
||||
}
|
||||
|
||||
auto hnd = curl_easy_init();
|
||||
rd7i_setup_curl_context(hnd, url, &file, false);
|
||||
|
||||
CURLcode curl_res = curl_easy_perform(hnd);
|
||||
curl_easy_cleanup(hnd);
|
||||
|
||||
file.close();
|
||||
if (curl_res != CURLE_OK) {
|
||||
if (RenderD7::FS::FileExist(path)) {
|
||||
std::filesystem::remove(path);
|
||||
}
|
||||
rd7i_curl_is_busy = false;
|
||||
return ((static_cast<Error>(curl_res) << 32) |
|
||||
static_cast<Error>(Error_Curl));
|
||||
}
|
||||
|
||||
rd7i_curl_is_busy = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Error GitDownloadRelease(const std::string& url, const std::string& asset_name,
|
||||
const std::string& path, bool prerelease) {
|
||||
if (rd7i_apir_is_busy) return Error_Busy;
|
||||
Error ret = rd7i_check_wifi();
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
rd7i_apir_is_busy = true;
|
||||
std::regex parse("github\\.com\\/(.+)\\/(.+)");
|
||||
std::smatch res;
|
||||
std::regex_search(url, res, parse);
|
||||
|
||||
std::string user = res[1].str();
|
||||
std::string repo = res[2].str();
|
||||
|
||||
std::stringstream req;
|
||||
req << "https://api.github.com/repos/" << user << "/" << repo
|
||||
<< (prerelease ? "/releases" : "/releases/latest");
|
||||
|
||||
std::string buf;
|
||||
ret = Download(req.str(), buf);
|
||||
if (ret) {
|
||||
rd7i_apir_is_busy = false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int pret = 0;
|
||||
std::string freq;
|
||||
if (nlohmann::json::accept(buf)) {
|
||||
nlohmann::json api = nlohmann::json::parse(buf);
|
||||
if (!api.size()) pret = -1;
|
||||
if (pret != -1) {
|
||||
if (prerelease) api = api[0];
|
||||
if (api["assets"].is_array()) {
|
||||
for (const auto& asset : api["assets"]) {
|
||||
if (asset.is_object() && asset["name"].is_string() &&
|
||||
asset["browser_download_url"].is_string()) {
|
||||
if (std::regex_match(std::string(asset["name"]),
|
||||
std::regex(asset_name))) {
|
||||
freq = asset["browser_download_url"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pret = -1;
|
||||
}
|
||||
|
||||
if (pret != 0 || freq.empty()) {
|
||||
rd7i_apir_is_busy = false;
|
||||
return Error_Git;
|
||||
}
|
||||
|
||||
ret = Download2File(freq, path);
|
||||
rd7i_apir_is_busy = false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
Error JsonApiRequest(const std::string& api_url, nlohmann::json& res) {
|
||||
if (rd7i_apir_is_busy) return Error_Busy;
|
||||
Error ret = rd7i_check_wifi();
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
rd7i_apir_is_busy = true;
|
||||
|
||||
std::string buf;
|
||||
ret = Download(api_url, buf);
|
||||
if (ret) {
|
||||
rd7i_apir_is_busy = false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (nlohmann::json::accept(buf)) {
|
||||
res = nlohmann::json::parse(buf);
|
||||
if (!res.size()) {
|
||||
rd7i_apir_is_busy = false;
|
||||
return Error_Invalid;
|
||||
}
|
||||
} else {
|
||||
rd7i_apir_is_busy = false;
|
||||
return Error_Invalid;
|
||||
}
|
||||
|
||||
rd7i_apir_is_busy = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long long GetProgressCurrent() { return rd7i_net_dl_spec.current; }
|
||||
unsigned long long GetProgressTotal() {
|
||||
// As curl sets total to 0 we need
|
||||
// to return a 1 as devide by zeroi will crash
|
||||
if (rd7i_net_dl_spec.total <= 0) return 1;
|
||||
return rd7i_net_dl_spec.total;
|
||||
}
|
||||
} // namespace Net
|
||||
} // namespace RenderD7
|
@ -1,497 +0,0 @@
|
||||
#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_num{
|
||||
// 1st row
|
||||
{"7", R7Vec2(5, 135), R7Vec2(36, 24), 0},
|
||||
{"8", R7Vec2(43, 135), R7Vec2(36, 24), 0},
|
||||
{"9", R7Vec2(81, 135), R7Vec2(36, 24), 0},
|
||||
// 2nd row
|
||||
{"4", R7Vec2(5, 161), R7Vec2(36, 24), 0},
|
||||
{"5", R7Vec2(43, 161), R7Vec2(36, 24), 0},
|
||||
{"6", R7Vec2(81, 161), R7Vec2(36, 24), 0},
|
||||
// 3rd row
|
||||
{"1", R7Vec2(5, 187), R7Vec2(36, 24), 0},
|
||||
{"2", R7Vec2(43, 187), R7Vec2(36, 24), 0},
|
||||
{"3", R7Vec2(81, 187), R7Vec2(36, 24), 0},
|
||||
|
||||
// 4th row
|
||||
{"0", R7Vec2(5, 213), R7Vec2(74, 24), 0},
|
||||
{".", R7Vec2(81, 213), R7Vec2(36, 24), 0},
|
||||
// additional actions
|
||||
{"<---", R7Vec2(119, 135), R7Vec2(74, 24), 2},
|
||||
//{"", R7Vec2(119, 161), R7Vec2(74, 24), 0},
|
||||
{"Confirm", R7Vec2(119, 187), R7Vec2(74, 24), 5},
|
||||
{"Cancel", R7Vec2(119, 213), R7Vec2(74, 24), 4},
|
||||
};
|
||||
|
||||
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},
|
||||
{"<---", 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},
|
||||
{"<---", 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},
|
||||
{"<---", 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 {
|
||||
float tmp_txt = R2::GetTextSize();
|
||||
R2::DefaultTextSize();
|
||||
R2::OnScreen(R2Screen_Top);
|
||||
RenderD7::Color::RGBA bg(RD7Color_Background);
|
||||
bg.changeA(150);
|
||||
R2::AddRect(R7Vec2(0, 0), R7Vec2(400, 20), bg.toRGBA());
|
||||
|
||||
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++) {
|
||||
R2::AddText(R7Vec2(5, 30 + i * 15), dt[i].func_name, RD7Color_Text);
|
||||
R2::AddText(R7Vec2(295, 30 + i * 15), RenderD7::MsTimeFmt(dt[i].time_of),
|
||||
RD7Color_Text);
|
||||
}
|
||||
R2::SetTextSize(tmp_txt);
|
||||
}
|
||||
|
||||
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 {
|
||||
float tmp_txt = R2::GetTextSize();
|
||||
R2::DefaultTextSize();
|
||||
R2::OnScreen(i_screen[0] ? R2Screen_Bottom : R2Screen_Top);
|
||||
std::string info =
|
||||
"RenderD7 " + std::string(RENDERD7VSTRING) + " Debug Overlay";
|
||||
float dim_y = R2::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";
|
||||
if (rd7i_enable_memtrack)
|
||||
mt_mem = "Mem: " + RenderD7::FormatBytes(RenderD7::Memory::GetCurrent()) +
|
||||
" | " +
|
||||
RenderD7::FormatBytes(RenderD7::Memory::GetTotalAllocated()) +
|
||||
" | " + RenderD7::FormatBytes(RenderD7::Memory::GetTotalFreed());
|
||||
R2::AddRect(R7Vec2(0, 0), R2::GetTextDimensions(mt_fps),
|
||||
(unsigned int)i_mt_color[0]);
|
||||
R2::AddRect(R7Vec2(0, 50), R2::GetTextDimensions(mt_cpu),
|
||||
(unsigned int)i_mt_color[0]);
|
||||
R2::AddRect(R7Vec2(0, 50 + dim_y * 1), R2::GetTextDimensions(mt_gpu),
|
||||
(unsigned int)i_mt_color[0]);
|
||||
R2::AddRect(R7Vec2(0, 50 + dim_y * 2), R2::GetTextDimensions(mt_cmd),
|
||||
(unsigned int)i_mt_color[0]);
|
||||
R2::AddRect(R7Vec2(0, 50 + dim_y * 3), R2::GetTextDimensions(mt_lfr),
|
||||
(unsigned int)i_mt_color[0]);
|
||||
R2::AddRect(R7Vec2(0, 50 + dim_y * 4), R2::GetTextDimensions(mt_tbs),
|
||||
(unsigned int)i_mt_color[0]);
|
||||
if (rd7i_enable_memtrack)
|
||||
R2::AddRect(R7Vec2(0, 50 + dim_y * 5), R2::GetTextDimensions(mt_mem),
|
||||
(unsigned int)i_mt_color[0]);
|
||||
R2::AddRect(R7Vec2(0, infoy), R2::GetTextDimensions(info),
|
||||
(unsigned int)i_mt_color[0]);
|
||||
R2::AddText(R7Vec2(0, 0), mt_fps, (unsigned int)i_txt_color[0]);
|
||||
R2::AddText(R7Vec2(0, 50), mt_cpu, (unsigned int)i_txt_color[0]);
|
||||
R2::AddText(R7Vec2(0, 50 + dim_y * 1), mt_gpu,
|
||||
(unsigned int)i_txt_color[0]);
|
||||
R2::AddText(R7Vec2(0, 50 + dim_y * 2), mt_cmd,
|
||||
(unsigned int)i_txt_color[0]);
|
||||
R2::AddText(R7Vec2(0, 50 + dim_y * 3), mt_lfr,
|
||||
(unsigned int)i_txt_color[0]);
|
||||
R2::AddText(R7Vec2(0, 50 + dim_y * 4), mt_tbs,
|
||||
(unsigned int)i_txt_color[0]);
|
||||
if (rd7i_enable_memtrack)
|
||||
R2::AddText(R7Vec2(0, 50 + dim_y * 5), mt_mem,
|
||||
(unsigned int)i_txt_color[0]);
|
||||
R2::AddText(R7Vec2(0, infoy), info, (unsigned int)i_txt_color[0]);
|
||||
|
||||
// Force Bottom (Debug Touchpos)
|
||||
R2::OnScreen(R2Screen_Bottom);
|
||||
if (Hid::IsEvent("touch", Hid::Held)) {
|
||||
R2::AddLine(R7Vec2(Hid::GetTouchPosition().x, 0),
|
||||
R7Vec2(Hid::GetTouchPosition().x, 240),
|
||||
RenderD7::Color::Hex("#ff0000"));
|
||||
R2::AddLine(R7Vec2(0, Hid::GetTouchPosition().y),
|
||||
R7Vec2(320, Hid::GetTouchPosition().y),
|
||||
RenderD7::Color::Hex("#ff0000"));
|
||||
}
|
||||
R2::SetTextSize(tmp_txt);
|
||||
}
|
||||
|
||||
void Ovl_Metrik::Logic() {
|
||||
if (!i_is_enabled[0]) this->Kill();
|
||||
}
|
||||
|
||||
Ovl_Keyboard::Ovl_Keyboard(std::string& ref, RD7KeyboardState& state,
|
||||
const std::string& hint, RD7Keyboard type) {
|
||||
// Blocks All Input outside of Keyboard
|
||||
// Doesnt work for Hidkeys down etc
|
||||
RenderD7::Hid::Lock();
|
||||
typed_text = &ref;
|
||||
this->state = &state;
|
||||
this->type = type;
|
||||
*this->state = RD7KeyboardState_None;
|
||||
str_bak = ref;
|
||||
ft3 = 0;
|
||||
}
|
||||
|
||||
Ovl_Keyboard::~Ovl_Keyboard() {
|
||||
// And Unlock when closing Keyboard lol
|
||||
RenderD7::Hid::Unlock();
|
||||
}
|
||||
|
||||
void Ovl_Keyboard::Draw(void) const {
|
||||
float tmp_txt = R2::GetTextSize();
|
||||
R2::DefaultTextSize();
|
||||
if (ft3 > 5) RenderD7::Hid::Unlock();
|
||||
auto key_table =
|
||||
(type == RD7Keyboard_Numpad) ? keyboard_layout_num : keyboard_layout;
|
||||
if (mode == 1)
|
||||
key_table = keyboard_layout_caps;
|
||||
else if (mode == 2)
|
||||
key_table = keyboard_layout_shift;
|
||||
R2::OnScreen(R2Screen_Top);
|
||||
R2::AddRect(R7Vec2(0, 0), R7Vec2(400, 240),
|
||||
RenderD7::Color::RGBA(RD7Color_FrameBg).changeA(150).toRGBA());
|
||||
R2::OnScreen(R2Screen_Bottom);
|
||||
R2::AddRect(R7Vec2(0, 0), R7Vec2(320, 112),
|
||||
RenderD7::Color::RGBA(RD7Color_FrameBg).changeA(150).toRGBA());
|
||||
R2::AddRect(R7Vec2(0, 112), R7Vec2(320, 128), RD7Color_FrameBg);
|
||||
R2::AddRect(R7Vec2(0, 112), R7Vec2(320, 20), RD7Color_Header);
|
||||
R2::AddText(R7Vec2(5, 114), "> " + *typed_text,
|
||||
RenderD7::ThemeActive()->AutoText(RD7Color_Header));
|
||||
for (auto const& it : key_table) {
|
||||
R7Vec2 szs = it.size;
|
||||
R7Vec2 pos = it.pos;
|
||||
R7Vec2 txtdim = R2::GetTextDimensions(it.disp);
|
||||
RD7Color btn = RD7Color_Button;
|
||||
if (RenderD7::Hid::IsEvent("cancel", RenderD7::Hid::Up)) {
|
||||
RenderD7::Hid::Clear();
|
||||
shared_data[0x05] = 1;
|
||||
}
|
||||
if (RenderD7::Hid::IsEvent("touch", RenderD7::Hid::Up) &&
|
||||
UI7_InBox(RenderD7::Hid::GetLastTouchPosition(), pos, szs)) {
|
||||
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;
|
||||
pos -= R7Vec2(1, 1);
|
||||
szs += R7Vec2(2, 2);
|
||||
}
|
||||
R7Vec2 txtpos = R7Vec2(pos.x + szs.x * 0.5 - txtdim.x * 0.5,
|
||||
pos.y + szs.y * 0.5 - txtdim.y * 0.5);
|
||||
R2::AddRect(pos, szs, btn);
|
||||
R2::AddText(txtpos, it.disp, RenderD7::ThemeActive()->AutoText(btn));
|
||||
}
|
||||
if (ft3 > 5) RenderD7::Hid::Lock();
|
||||
R2::SetTextSize(tmp_txt);
|
||||
}
|
||||
|
||||
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;
|
||||
*state = RD7KeyboardState_Cancel;
|
||||
this->Kill();
|
||||
} else if (it.first == 0x06) {
|
||||
*state = RD7KeyboardState_Confirm;
|
||||
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,378 +0,0 @@
|
||||
#include <citro2d.h>
|
||||
|
||||
#include <renderd7/Render2.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
|
||||
namespace RenderD7 {
|
||||
const float R2::default_text_size = 0.5f;
|
||||
float R2::text_size = 0.5;
|
||||
Font::Ref R2::font;
|
||||
std::map<std::string, float> R2::ts;
|
||||
std::map<std::string, int> R2::mln;
|
||||
bool R2::next_lined = false;
|
||||
std::vector<R2::R2Cmd::Ref> R2::commands;
|
||||
R2Screen R2::current_screen = R2Screen_Bottom;
|
||||
|
||||
void R2::Init() { R2::font = Font::New(); }
|
||||
|
||||
void R2::SetFont(Font::Ref fnt) {
|
||||
if (!fnt) return;
|
||||
R2::font = fnt;
|
||||
}
|
||||
|
||||
Font::Ref R2::GetFont() { return R2::font; }
|
||||
|
||||
void R2::DefaultFont() { R2::font->Unload(); }
|
||||
|
||||
void R2::DrawNextLined() { R2::next_lined = true; }
|
||||
|
||||
void R2::OnScreen(R2Screen screen) {
|
||||
if (screen < 0 || screen > R2Screen_Top) return;
|
||||
R2::current_screen = screen;
|
||||
}
|
||||
|
||||
void R2::SetTextSize(float szs) { text_size = szs; }
|
||||
|
||||
void R2::DefaultTextSize() { text_size = R2::default_text_size; }
|
||||
|
||||
float R2::GetTextSize() { return text_size; }
|
||||
|
||||
R2Screen R2::GetCurrentScreen() { return current_screen; }
|
||||
|
||||
R7Vec2 R2::GetTextDimensions(const std::string& text) {
|
||||
C2D_TextBufClear(rd7i_d2_dimbuf);
|
||||
float w = 0, h = 0;
|
||||
C2D_Text c2dtext;
|
||||
C2D_TextFontParse(&c2dtext, font->Ptr(), rd7i_d2_dimbuf, text.c_str());
|
||||
C2D_TextGetDimensions(&c2dtext, R2::text_size, R2::text_size, &w, &h);
|
||||
return R7Vec2(w, h);
|
||||
}
|
||||
|
||||
std::string R2::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 = R2::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;
|
||||
}
|
||||
|
||||
std::string R2::ShortText(const std::string& in, int maxlen) {
|
||||
auto textdim = R2::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 -= R2::GetTextDimensions(ft).x - R2::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 (R2::GetTextDimensions(out + "(...)" + ft).x > (float)maxlen) {
|
||||
out += "(...)";
|
||||
out += ft;
|
||||
return out;
|
||||
}
|
||||
}
|
||||
return out; // Impossible to reach
|
||||
}
|
||||
|
||||
R7Vec2 R2::GetCurrentScreenSize() {
|
||||
return R7Vec2(R2::current_screen == R2Screen_Bottom ? 320 : 400, 240);
|
||||
}
|
||||
|
||||
// Main Processing of Draw Calls
|
||||
void R2::Process() {
|
||||
for (auto& it : R2::commands) {
|
||||
if (it->type <= 0 || it->type > 6) {
|
||||
// Skip
|
||||
continue;
|
||||
}
|
||||
C2D_SceneBegin(it->Screen ? rd7_top : rd7_bottom);
|
||||
if (it->type == 1) {
|
||||
// Rect
|
||||
if (it->lined) {
|
||||
C2D_DrawLine(it->pos.x, it->pos.y, it->clr, it->pos.x + it->pszs.x,
|
||||
it->pos.y, it->clr, 1.f, 0.5f);
|
||||
C2D_DrawLine(it->pos.x, it->pos.y, it->clr, it->pos.x,
|
||||
it->pos.y + it->pszs.y, it->clr, 1.f, 0.5f);
|
||||
C2D_DrawLine(it->pos.x + it->pszs.x, it->pos.y, it->clr,
|
||||
it->pos.x + it->pszs.x, it->pos.y + it->pszs.y, it->clr,
|
||||
1.f, 0.5f);
|
||||
C2D_DrawLine(it->pos.x, it->pos.y + it->pszs.y, it->clr,
|
||||
it->pos.x + it->pszs.x, it->pos.y + it->pszs.y, it->clr,
|
||||
1.f, 0.5f);
|
||||
} else {
|
||||
C2D_DrawRectSolid(it->pos.x, it->pos.y, 0.5, it->pszs.x, it->pszs.y,
|
||||
it->clr);
|
||||
}
|
||||
} else if (it->type == 2) {
|
||||
// Triangle
|
||||
if (it->lined) {
|
||||
C2D_DrawLine(it->pos.x, it->pos.y, it->clr, it->pszs.x, it->pszs.y,
|
||||
it->clr, 1, 0.5f);
|
||||
C2D_DrawLine(it->pos.x, it->pos.y, it->clr, it->ap.x, it->ap.y, it->clr,
|
||||
1, 0.5f);
|
||||
C2D_DrawLine(it->pszs.x, it->pszs.y, it->clr, it->ap.x, it->ap.y,
|
||||
it->clr, 1, 0.5f);
|
||||
} else {
|
||||
C2D_DrawTriangle(it->pos.x, it->pos.y, it->clr, it->pszs.x, it->pszs.y,
|
||||
it->clr, it->ap.x, it->ap.y, it->clr, 0.5);
|
||||
}
|
||||
} else if (it->type == 3) {
|
||||
// Text
|
||||
// little patch for a freeze
|
||||
if (it->text.length() < 1) continue;
|
||||
if (it->pszs.x == 0.0f) {
|
||||
it->pszs.x = it->Screen == R2Screen_Top ? 400 : 320;
|
||||
}
|
||||
if (it->pszs.y == 0.0f) {
|
||||
it->pszs.y = 240;
|
||||
}
|
||||
std::string edit_text = it->text;
|
||||
if (edit_text.substr(it->text.length() - 1) != "\n")
|
||||
edit_text.append("\n"); // Add \n to end if not exist
|
||||
int line = 0;
|
||||
|
||||
if (it->flags & RD7TextFlags_Wrap) {
|
||||
edit_text = WrapText(it->text, it->pszs.x - it->pos.x);
|
||||
}
|
||||
|
||||
while (edit_text.find('\n') != edit_text.npos) {
|
||||
std::string current_line = edit_text.substr(0, edit_text.find('\n'));
|
||||
if (it->flags & RD7TextFlags_Short)
|
||||
current_line = R2::ShortText(current_line, it->pszs.x - it->pos.x);
|
||||
R7Vec2 newpos = it->pos;
|
||||
// Check Flags
|
||||
R7Vec2 dim = R2::GetTextDimensions(current_line);
|
||||
if (it->flags & RD7TextFlags_AlignRight) newpos.x = newpos.x - dim.x;
|
||||
if (it->flags & RD7TextFlags_AlignMid) // Offset by inpos
|
||||
newpos.x = (it->pszs.x * 0.5) - (dim.x * 0.5) + it->pos.x;
|
||||
if (it->flags & RD7TextFlags_Scroll) { // Scroll Text
|
||||
// Look into Old Draw2 Code
|
||||
// TODO: Create Code for this
|
||||
}
|
||||
if (rd7i_debugging) {
|
||||
R2::DrawNextLined();
|
||||
R2::AddRect(newpos, dim, 0xff0000ff);
|
||||
}
|
||||
C2D_Text c2dtext;
|
||||
C2D_TextFontParse(&c2dtext, font->Ptr(), rd7i_text_buffer,
|
||||
current_line.c_str());
|
||||
C2D_TextOptimize(&c2dtext);
|
||||
|
||||
if (it->flags & RD7TextFlags_Shaddow) // performance Killer xd
|
||||
C2D_DrawText(&c2dtext, C2D_WithColor, newpos.x + 1 + (dim.y * line),
|
||||
newpos.y + 1, 0.5, R2::text_size, R2::text_size,
|
||||
RenderD7::ThemeActive()->Get(RD7Color_TextDisabled));
|
||||
|
||||
C2D_DrawText(&c2dtext, C2D_WithColor, newpos.x,
|
||||
newpos.y + (dim.y * line), 0.5, R2::text_size,
|
||||
R2::text_size, it->clr);
|
||||
edit_text = edit_text.substr(edit_text.find('\n') + 1);
|
||||
line++;
|
||||
}
|
||||
} else if (it->type == 4) {
|
||||
if (it->img->Loadet()) {
|
||||
C2D_DrawImageAt(it->img->Get(), it->pos.x, it->pos.y, 0.5f);
|
||||
}
|
||||
} else if (it->type == 5) {
|
||||
// TODO: Move the Draw Func into this API
|
||||
it->spr->Draw();
|
||||
} else if (it->type == 6) {
|
||||
C2D_DrawLine(it->pos.x, it->pos.y, it->clr, it->pszs.x, it->pszs.y,
|
||||
it->clr, it->ap.x, 0.5f);
|
||||
}
|
||||
}
|
||||
R2::commands.clear();
|
||||
}
|
||||
|
||||
void R2::AddRect(R7Vec2 pos, R7Vec2 size, RD7Color clr) {
|
||||
auto cmd = R2Cmd::New();
|
||||
cmd->pos = pos;
|
||||
cmd->pszs = size;
|
||||
cmd->clr = RenderD7::ThemeActive()->Get(clr);
|
||||
cmd->type = 1; // Rect
|
||||
// Just assign current screen as bottom is 0 (false)
|
||||
// and Top and TopRight are !0 (true)
|
||||
cmd->Screen = current_screen;
|
||||
if (R2::next_lined) {
|
||||
cmd->lined = true;
|
||||
R2::next_lined = false;
|
||||
}
|
||||
R2::commands.push_back(cmd);
|
||||
}
|
||||
|
||||
void R2::AddRect(R7Vec2 pos, R7Vec2 size, unsigned int clr) {
|
||||
auto cmd = R2Cmd::New();
|
||||
cmd->pos = pos;
|
||||
cmd->pszs = size;
|
||||
cmd->clr = clr;
|
||||
cmd->type = 1; // Rect
|
||||
// Just assign current screen as bottom is 0 (false)
|
||||
// and Top and TopRight are !0 (true)
|
||||
cmd->Screen = current_screen;
|
||||
if (R2::next_lined) {
|
||||
cmd->lined = true;
|
||||
R2::next_lined = false;
|
||||
}
|
||||
R2::commands.push_back(cmd);
|
||||
}
|
||||
|
||||
void R2::AddLine(R7Vec2 pos_a, R7Vec2 pos_b, RD7Color clr, int t) {
|
||||
auto cmd = R2Cmd::New();
|
||||
cmd->pos = pos_a;
|
||||
cmd->pszs = pos_b;
|
||||
cmd->ap.x = t;
|
||||
cmd->clr = RenderD7::ThemeActive()->Get(clr);
|
||||
cmd->type = 6; // Line
|
||||
// Just assign current screen as bottom is 0 (false)
|
||||
// and Top and TopRight are !0 (true)
|
||||
cmd->Screen = current_screen;
|
||||
if (R2::next_lined) {
|
||||
cmd->lined = true;
|
||||
R2::next_lined = false;
|
||||
}
|
||||
R2::commands.push_back(cmd);
|
||||
}
|
||||
|
||||
void R2::AddLine(R7Vec2 pos_a, R7Vec2 pos_b, unsigned int clr, int t) {
|
||||
auto cmd = R2Cmd::New();
|
||||
cmd->pos = pos_a;
|
||||
cmd->pszs = pos_b;
|
||||
cmd->ap.x = t;
|
||||
cmd->clr = clr;
|
||||
cmd->type = 6; // Line
|
||||
// Just assign current screen as bottom is 0 (false)
|
||||
// and Top and TopRight are !0 (true)
|
||||
cmd->Screen = current_screen;
|
||||
if (R2::next_lined) {
|
||||
cmd->lined = true;
|
||||
R2::next_lined = false;
|
||||
}
|
||||
R2::commands.push_back(cmd);
|
||||
}
|
||||
|
||||
void R2::AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, RD7Color clr) {
|
||||
auto cmd = R2Cmd::New();
|
||||
cmd->pos = pos0;
|
||||
cmd->pszs = pos1;
|
||||
cmd->ap = pos2;
|
||||
cmd->clr = RenderD7::ThemeActive()->Get(clr);
|
||||
cmd->type = 2; // Triangle
|
||||
// Just assign current screen as bottom is 0 (false)
|
||||
// and Top and TopRight are !0 (true)
|
||||
cmd->Screen = current_screen;
|
||||
if (R2::next_lined) {
|
||||
cmd->lined = true;
|
||||
R2::next_lined = false;
|
||||
}
|
||||
R2::commands.push_back(cmd);
|
||||
}
|
||||
|
||||
void R2::AddTriangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int clr) {
|
||||
auto cmd = R2Cmd::New();
|
||||
cmd->pos = pos0;
|
||||
cmd->pszs = pos1;
|
||||
cmd->ap = pos2;
|
||||
cmd->clr = clr;
|
||||
cmd->type = 2; // Triangle
|
||||
// Just assign current screen as bottom is 0 (false)
|
||||
// and Top and TopRight are !0 (true)
|
||||
cmd->Screen = current_screen;
|
||||
if (R2::next_lined) {
|
||||
cmd->lined = true;
|
||||
R2::next_lined = false;
|
||||
}
|
||||
R2::commands.push_back(cmd);
|
||||
}
|
||||
|
||||
void R2::AddText(R7Vec2 pos, const std::string& text, RD7Color clr,
|
||||
RD7TextFlags flags, R7Vec2 tmb) {
|
||||
auto cmd = R2Cmd::New();
|
||||
cmd->pos = pos;
|
||||
cmd->pszs = tmb;
|
||||
cmd->clr = RenderD7::ThemeActive()->Get(clr);
|
||||
cmd->flags = flags;
|
||||
cmd->text = text;
|
||||
cmd->type = 3; // Text
|
||||
// Just assign current screen as bottom is 0 (false)
|
||||
// and Top and TopRight are !0 (true)
|
||||
cmd->Screen = current_screen;
|
||||
if (R2::next_lined) {
|
||||
cmd->lined = true;
|
||||
R2::next_lined = false;
|
||||
}
|
||||
R2::commands.push_back(cmd);
|
||||
}
|
||||
|
||||
void R2::AddText(R7Vec2 pos, const std::string& text, unsigned int clr,
|
||||
RD7TextFlags flags, R7Vec2 tmb) {
|
||||
auto cmd = R2Cmd::New();
|
||||
cmd->pos = pos;
|
||||
cmd->pszs = tmb;
|
||||
cmd->clr = clr;
|
||||
cmd->flags = flags;
|
||||
cmd->text = text;
|
||||
cmd->type = 3; // Text
|
||||
// Just assign current screen as bottom is 0 (false)
|
||||
// and Top and TopRight are !0 (true)
|
||||
cmd->Screen = current_screen;
|
||||
if (R2::next_lined) {
|
||||
cmd->lined = true;
|
||||
R2::next_lined = false;
|
||||
}
|
||||
R2::commands.push_back(cmd);
|
||||
}
|
||||
|
||||
void R2::AddImage(R7Vec2 pos, Image::Ref img) {
|
||||
auto cmd = R2Cmd::New();
|
||||
cmd->pos = pos;
|
||||
cmd->img = img;
|
||||
cmd->type = 4; // Image
|
||||
// Just assign current screen as bottom is 0 (false)
|
||||
// and Top and TopRight are !0 (true)
|
||||
cmd->Screen = current_screen;
|
||||
if (R2::next_lined) {
|
||||
cmd->lined = true;
|
||||
R2::next_lined = false;
|
||||
}
|
||||
R2::commands.push_back(cmd);
|
||||
}
|
||||
|
||||
void R2::AddSprite(Sprite::Ref spr) {
|
||||
auto cmd = R2Cmd::New();
|
||||
cmd->spr = spr;
|
||||
cmd->type = 5; // Sprite
|
||||
// Just assign current screen as bottom is 0 (false)
|
||||
// and Top and TopRight are !0 (true)
|
||||
cmd->Screen = current_screen;
|
||||
if (R2::next_lined) {
|
||||
cmd->lined = true;
|
||||
R2::next_lined = false;
|
||||
}
|
||||
R2::commands.push_back(cmd);
|
||||
}
|
||||
|
||||
} // namespace RenderD7
|
@ -1,460 +0,0 @@
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <renderd7/ResultDecoder.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
#include <sstream>
|
||||
|
||||
static std::map<int, std::string> modules = {
|
||||
{0, "common"},
|
||||
{1, "kernel"},
|
||||
{2, "util"},
|
||||
{3, "file server"},
|
||||
{4, "loader server"},
|
||||
{5, "tcb"},
|
||||
{6, "os"},
|
||||
{7, "dbg"},
|
||||
{8, "dmnt"},
|
||||
{9, "pdn"},
|
||||
{10, "gsp"},
|
||||
{11, "i2c"},
|
||||
{12, "gpio"},
|
||||
{13, "dd"},
|
||||
{14, "codec"},
|
||||
{15, "spi"},
|
||||
{16, "pxi"},
|
||||
{17, "fs"},
|
||||
{18, "di"},
|
||||
{19, "hid"},
|
||||
{20, "cam"},
|
||||
{21, "pi"},
|
||||
{22, "pm"},
|
||||
{23, "pm_low"},
|
||||
{24, "fsi"},
|
||||
{25, "srv"},
|
||||
{26, "ndm"},
|
||||
{27, "nwm"},
|
||||
{28, "soc"},
|
||||
{29, "ldr"},
|
||||
{30, "acc"},
|
||||
{31, "romfs"},
|
||||
{32, "am"},
|
||||
{33, "hio"},
|
||||
{34, "updater"},
|
||||
{35, "mic"},
|
||||
{36, "fnd"},
|
||||
{37, "mp"},
|
||||
{38, "mpwl"},
|
||||
{39, "ac"},
|
||||
{40, "http"},
|
||||
{41, "dsp"},
|
||||
{42, "snd"},
|
||||
{43, "dlp"},
|
||||
{44, "hio_low"},
|
||||
{45, "csnd"},
|
||||
{46, "ssl"},
|
||||
{47, "am_low"},
|
||||
{48, "nex"},
|
||||
{49, "friends"},
|
||||
{50, "rdt"},
|
||||
{51, "applet"},
|
||||
{52, "nim"},
|
||||
{53, "ptm"},
|
||||
{54, "midi"},
|
||||
{55, "mc"},
|
||||
{56, "swc"},
|
||||
{57, "fatfs"},
|
||||
{58, "ngc"},
|
||||
{59, "card"},
|
||||
{60, "cardnor"},
|
||||
{61, "sdmc"},
|
||||
{62, "boss"},
|
||||
{63, "dbm"},
|
||||
{64, "config"},
|
||||
{65, "ps"},
|
||||
{66, "cec"},
|
||||
{67, "ir"},
|
||||
{68, "uds"},
|
||||
{69, "pl"},
|
||||
{70, "cup"},
|
||||
{71, "gyroscope"},
|
||||
{72, "mcu"},
|
||||
{73, "ns"},
|
||||
{74, "news"},
|
||||
{75, "ro"},
|
||||
{76, "gd"},
|
||||
{77, "card spi"},
|
||||
{78, "ec"},
|
||||
{79, "web browser"},
|
||||
{80, "test"},
|
||||
{81, "enc"},
|
||||
{82, "pia"},
|
||||
{83, "act"},
|
||||
{84, "vctl"},
|
||||
{85, "olv"},
|
||||
{86, "neia"},
|
||||
{87, "npns"},
|
||||
{90, "avd"},
|
||||
{91, "l2b"},
|
||||
{92, "mvd"},
|
||||
{93, "nfc"},
|
||||
{94, "uart"},
|
||||
{95, "spm"},
|
||||
{96, "qtm"},
|
||||
{97, "nfp"},
|
||||
{254, "application"},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> levels = {
|
||||
{0, "Success"}, {1, "Info"}, {25, "Status"},
|
||||
{26, "Temporary"}, {27, "Permanent"}, {28, "Usage"},
|
||||
{29, "Reinitialize"}, {30, "Reset"}, {31, "Fatal"},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> summaries = {
|
||||
{0, "Success"},
|
||||
{1, "Nothing happened"},
|
||||
{2, "Would block"},
|
||||
{3, "Out of resource"},
|
||||
{4, "Not found"},
|
||||
{5, "Invalid state"},
|
||||
{6, "Not supported"},
|
||||
{7, "Invalid argument"},
|
||||
{8, "Wrong argument"},
|
||||
{9, "Canceled"},
|
||||
{10, "Status changed"},
|
||||
{11, "Internal"},
|
||||
{63, "Invalid result value"},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> desccommon = {
|
||||
{0, "Success"},
|
||||
{1000, "Invalid selection"},
|
||||
{1001, "Too large"},
|
||||
{1002, "Not authorized"},
|
||||
{1003, "Already done"},
|
||||
{1004, "Invalid size"},
|
||||
{1005, "Invalid enum value"},
|
||||
{1006, "Invalid combination"},
|
||||
{1007, "No data"},
|
||||
{1008, "Busy"},
|
||||
{1009, "Misaligned address"},
|
||||
{1010, "Misaligned size"},
|
||||
{1011, "Out of memory"},
|
||||
{1012, "Not implemented"},
|
||||
{1013, "Invalid address"},
|
||||
{1014, "Invalid pointer"},
|
||||
{1015, "Invalid handle"},
|
||||
{1016, "Not initialized"},
|
||||
{1017, "Already initialized"},
|
||||
{1018, "Not found"},
|
||||
{1019, "Cancel requested"},
|
||||
{1020, "Already exists"},
|
||||
{1021, "Out of range"},
|
||||
{1022, "Timeout"},
|
||||
{1023, "Invalid result value"},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> desckernel = {
|
||||
{2, "Invalid memory permissions."},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> descos = {
|
||||
{10, "Not enough memory."},
|
||||
{26, "Session closed by remote."},
|
||||
{47, "Invalid command header."},
|
||||
};
|
||||
|
||||
// Need to Fix The Range based Values
|
||||
static std::map<int, std::string> descfs = {
|
||||
{101, "Archive not mounted or mount-point not found."},
|
||||
{120, "Title or object not found."},
|
||||
{141, "Gamecard not inserted."},
|
||||
{230, "Invalid open flags or permissions."},
|
||||
{391, "NCCH hash check failed."},
|
||||
{302, "RSA or AES-MAC verification failed."},
|
||||
{395, "RomFS or Savedata hash check failed."},
|
||||
{630, "Command not allowed, or missing permissions."},
|
||||
{702, "Invalid path."},
|
||||
{761, "Incorrect ExeFS read size."},
|
||||
{100, "[Media] not found."},
|
||||
{180, "Exists already."},
|
||||
{200, "Not enough space."},
|
||||
{220, "Invalidated archive."},
|
||||
{230, "Unacceptable or write protected."},
|
||||
{340, "0x01"},
|
||||
{360, "Bad format."},
|
||||
{390, "Verification failure."},
|
||||
{400, "0x01"},
|
||||
{600, "Out of resources."},
|
||||
{630, "Access denied."},
|
||||
{661, "0x01"},
|
||||
{700, "Invalid argument."},
|
||||
{730, "Not initialized."},
|
||||
{750, "Already initialized."},
|
||||
{760, "Not supported."},
|
||||
{780, "0x01"},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> descsrv = {
|
||||
{5,
|
||||
"Invalid string length (service name length is zero or longer than 8 "
|
||||
"chars)."},
|
||||
{6,
|
||||
"Access to service denied (requested a service the application does "
|
||||
"not have access to)."},
|
||||
{7,
|
||||
"String size does not match contents (service name contains unexpected "
|
||||
"null byte)."},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> descnwm = {
|
||||
{2,
|
||||
"This error usually indicates the wifi chipset in the console is dying "
|
||||
"or dead."},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> descam = {
|
||||
{4, "Invalid ticket version."},
|
||||
{32, "Empty CIA."},
|
||||
{37, "Invalid NCCH."},
|
||||
{39, "Invalid title version."},
|
||||
{43, "Database doesn\"t exist, or it failed to open."},
|
||||
{44, "Trying to uninstall system-app."},
|
||||
{106,
|
||||
"Invalid signature/CIA. Usually happens when developer UNITINFO is "
|
||||
"enabled in Luma3DS."},
|
||||
{393, "Invalid database."},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> deschttp = {
|
||||
{105, "Request timed out."},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> descnim = {
|
||||
{1,
|
||||
"Invalid string IPC paramater (non null terminated at its indicated "
|
||||
"length)."},
|
||||
{12,
|
||||
"Invalid country code returned by CFG module reading config save "
|
||||
"0xB0000."},
|
||||
{13,
|
||||
"Zero string length console serial number or '000000000000000' "
|
||||
"returned by CFG's SecureInfoGetSerialNo."},
|
||||
{18,
|
||||
"General data reading error of NIM's .dat files from its system save, "
|
||||
"bad data or bad data lengths."},
|
||||
{22,
|
||||
"General invalid data or length of data returned from nintendo "
|
||||
"servers. (Only applicable for some operations)"},
|
||||
{25,
|
||||
"IntegrityVerificationSeed is waiting on servers to be synced into "
|
||||
"console. Can't processed with online services without sync being "
|
||||
"completed first over IPC request."},
|
||||
{26,
|
||||
"Unavailable/unaccessable IntegrityVerificationSeed on Nintendo "
|
||||
"servers. May happen if NIM is told to import "
|
||||
"IntegrityVerificationSeed from servers at any time other than after "
|
||||
"the successful System Transfer reboot."},
|
||||
{27,
|
||||
"Invalid country language code returned by CFG module reading config "
|
||||
"save 0xA0002."},
|
||||
{37,
|
||||
"Service is in Standby Mode. (eShop ban? General service is down? "
|
||||
"This caused by a server response flag on account information. "
|
||||
"Account is not referring to NNID.)"},
|
||||
{39, "HTTP Status non 200. (Only applicable for some operations)"},
|
||||
{40, "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)"},
|
||||
{58,
|
||||
"Invalid NPNS token returned by CFG module reading config save 0xF0006."},
|
||||
{67, "HTTP Status 404 while trying to download a game's seed."},
|
||||
{68, "HTTP Status 503 while trying to download a game's seed."},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> descmvd = {
|
||||
{271, "Invalid configuration."},
|
||||
};
|
||||
|
||||
static std::map<int, std::string> descqtm = {
|
||||
{8, "Camera is already in use or busy."},
|
||||
};
|
||||
|
||||
// Need to Fix The Range based Values
|
||||
static std::map<int, std::string> descapplication = {
|
||||
{0,
|
||||
"The application raised an error. Please consult the application's "
|
||||
"source code or ask the author for assistance with it."},
|
||||
{1024, "0x01"},
|
||||
};
|
||||
|
||||
namespace RenderD7 {
|
||||
void ResultDecoder::Load(Result rescode) { this->m_rescode = rescode; }
|
||||
void ResultDecoder::Load(std::string rescode) {
|
||||
std::stringstream ss;
|
||||
ss << rescode;
|
||||
ss >> std::hex >> this->m_rescode;
|
||||
}
|
||||
std::string RenderD7::ResultDecoder::GetCode() {
|
||||
std::stringstream ss;
|
||||
ss << std::hex << m_rescode;
|
||||
std::string reshex(ss.str());
|
||||
return reshex;
|
||||
}
|
||||
std::string ResultDecoder::GetLevel() {
|
||||
std::string res = levels.at(this->GetLevelInt()) + " (" +
|
||||
std::to_string(this->GetLevelInt()) + ")";
|
||||
return res;
|
||||
}
|
||||
int ResultDecoder::GetLevelInt() { return R_LEVEL(m_rescode); }
|
||||
std::string ResultDecoder::GetModule() {
|
||||
std::string res = modules.at(this->GetModuleInt()) + " (" +
|
||||
std::to_string(this->GetModuleInt()) + ")";
|
||||
return res;
|
||||
}
|
||||
int ResultDecoder::GetModuleInt() { return R_MODULE(m_rescode); }
|
||||
std::string ResultDecoder::GetDescription() {
|
||||
std::string res = "Desc Not Implemented!";
|
||||
switch (this->GetModuleInt()) {
|
||||
case 0:
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
break;
|
||||
case 1:
|
||||
if ((desckernel.find(this->GetDescriptionInt()) == desckernel.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = desckernel.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if ((descos.find(this->GetDescriptionInt()) == descos.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = descos.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 17:
|
||||
if ((descfs.find(this->GetDescriptionInt()) == descfs.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = descfs.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 25:
|
||||
if ((descsrv.find(this->GetDescriptionInt()) == descsrv.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = descsrv.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 27:
|
||||
if ((descnwm.find(this->GetDescriptionInt()) == descnwm.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = descnwm.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
if ((descam.find(this->GetDescriptionInt()) == descam.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = descam.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 40:
|
||||
if ((deschttp.find(this->GetDescriptionInt()) == deschttp.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = deschttp.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 52:
|
||||
if ((descnim.find(this->GetDescriptionInt()) == descnim.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = descnim.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 92:
|
||||
if ((descmvd.find(this->GetDescriptionInt()) == descmvd.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = descmvd.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 96:
|
||||
if ((descqtm.find(this->GetDescriptionInt()) == descqtm.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = descqtm.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
case 254:
|
||||
if ((descapplication.find(this->GetDescriptionInt()) ==
|
||||
descapplication.end())) {
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
} else {
|
||||
res = descapplication.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
res = desccommon.at(this->GetDescriptionInt()) + " (" +
|
||||
std::to_string(this->GetDescriptionInt()) + ")";
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
int ResultDecoder::GetDescriptionInt() { return R_DESCRIPTION(m_rescode); }
|
||||
std::string ResultDecoder::GetSummary() {
|
||||
std::string res = summaries.at(this->GetSummaryInt()) + " (" +
|
||||
std::to_string(this->GetSummaryInt()) + ")";
|
||||
return res;
|
||||
}
|
||||
|
||||
void RenderD7::ResultDecoder::WriteLog() {
|
||||
std::string out_path = "sdmc:/RenderD7/Apps/" + rd7i_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); }
|
||||
} // namespace RenderD7
|
@ -1,22 +0,0 @@
|
||||
#include <renderd7/Sheet.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
|
||||
Result RenderD7::Sheet::Load(const std::string& path) {
|
||||
if (this->spritesheet) Free();
|
||||
this->spritesheet = C2D_SpriteSheetLoad(path.c_str());
|
||||
if (!this->spritesheet) {
|
||||
_rd7i_logger()->Write("Failed to Load Spritesheet from: " + path, 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RenderD7::Sheet::Free() {
|
||||
if (!this->spritesheet) return;
|
||||
C2D_SpriteSheetFree(this->spritesheet);
|
||||
this->spritesheet = nullptr;
|
||||
}
|
||||
|
||||
C2D_Image RenderD7::Sheet::GetImage(int idx) {
|
||||
if (!this->spritesheet) return {nullptr, nullptr};
|
||||
return C2D_SpriteSheetGetImage(this->spritesheet, idx);
|
||||
}
|
133
source/Sound.cpp
133
source/Sound.cpp
@ -1,133 +0,0 @@
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <renderd7/Sound.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
#include <string>
|
||||
|
||||
using std::string;
|
||||
|
||||
// Reference: http://yannesposito.com/Scratch/en/blog/2010-10-14-Fun-with-wav/
|
||||
typedef struct _WavHeader {
|
||||
char magic[4]; // "RIFF"
|
||||
u32 totallength; // Total file length, minus 8.
|
||||
char wavefmt[8]; // Should be "WAVEfmt "
|
||||
u32 format; // 16 for PCM format
|
||||
u16 pcm; // 1 for PCM format
|
||||
u16 channels; // Channels
|
||||
u32 frequency; // Sampling frequency
|
||||
u32 bytes_per_second;
|
||||
u16 bytes_by_capture;
|
||||
u16 bits_per_sample;
|
||||
char data[4]; // "data"
|
||||
u32 bytes_in_data;
|
||||
} WavHeader;
|
||||
static_assert(sizeof(WavHeader) == 44, "WavHeader size is not 44 bytes.");
|
||||
|
||||
using namespace RenderD7;
|
||||
Sound::Sound(const string &path, int channel, bool toloop) {
|
||||
if (rd7i_is_ndsp) {
|
||||
ndspSetOutputMode(NDSP_OUTPUT_STEREO);
|
||||
ndspSetOutputCount(2); // Num of buffers
|
||||
|
||||
// Reading wav file
|
||||
std::fstream fp(path, std::ios::in | std::ios::binary);
|
||||
|
||||
if (!fp.is_open()) {
|
||||
_rd7i_logger()->Write("Could not open WAV: " + path, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
WavHeader wavHeader;
|
||||
fp.read(reinterpret_cast<char *>(&wavHeader), sizeof(WavHeader));
|
||||
size_t read = fp.tellg();
|
||||
if (read != sizeof(wavHeader)) {
|
||||
// Short read.
|
||||
_rd7i_logger()->Write("WAV Header is too short", 0);
|
||||
fp.close();
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify the header.
|
||||
static const char RIFF_magic[4] = {'R', 'I', 'F', 'F'};
|
||||
if (memcmp(wavHeader.magic, RIFF_magic, sizeof(wavHeader.magic)) != 0) {
|
||||
// Incorrect magic number.
|
||||
_rd7i_logger()->Write("Wrong Fileformat", 0);
|
||||
fp.close();
|
||||
return;
|
||||
}
|
||||
|
||||
if (wavHeader.totallength == 0 ||
|
||||
(wavHeader.channels != 1 && wavHeader.channels != 2) ||
|
||||
(wavHeader.bits_per_sample != 8 && wavHeader.bits_per_sample != 16)) {
|
||||
// Unsupported WAV file.
|
||||
_rd7i_logger()->Write("File is invalid", 0);
|
||||
fp.close();
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the file size.
|
||||
fp.seekg(0, std::ios::end);
|
||||
dataSize = fp.tellg();
|
||||
dataSize -= sizeof(WavHeader);
|
||||
|
||||
// Allocating and reading samples
|
||||
data = static_cast<u8 *>(linearAlloc(dataSize));
|
||||
fp.seekg(44, std::ios::beg);
|
||||
fp.read(reinterpret_cast<char *>(data), dataSize);
|
||||
fp.close();
|
||||
dataSize /= 2; // FIXME: 16-bit or stereo?
|
||||
|
||||
// Find the right format
|
||||
u16 ndspFormat;
|
||||
if (wavHeader.bits_per_sample == 8) {
|
||||
ndspFormat = (wavHeader.channels == 1) ? NDSP_FORMAT_MONO_PCM8
|
||||
: NDSP_FORMAT_STEREO_PCM8;
|
||||
} else {
|
||||
ndspFormat = (wavHeader.channels == 1) ? NDSP_FORMAT_MONO_PCM16
|
||||
: NDSP_FORMAT_STEREO_PCM16;
|
||||
}
|
||||
|
||||
ndspChnReset(channel);
|
||||
ndspChnSetInterp(channel, NDSP_INTERP_NONE);
|
||||
ndspChnSetRate(channel, float(wavHeader.frequency));
|
||||
ndspChnSetFormat(channel, ndspFormat);
|
||||
|
||||
// Create and play a wav buffer
|
||||
memset(&waveBuf, 0, sizeof(waveBuf));
|
||||
|
||||
waveBuf.data_vaddr = reinterpret_cast<u32 *>(data);
|
||||
waveBuf.nsamples = dataSize / (wavHeader.bits_per_sample >> 3);
|
||||
waveBuf.looping = toloop;
|
||||
waveBuf.status = NDSP_WBUF_FREE;
|
||||
chnl = channel;
|
||||
}
|
||||
}
|
||||
|
||||
Sound::~Sound() {
|
||||
if (rd7i_is_ndsp) {
|
||||
waveBuf.data_vaddr = 0;
|
||||
waveBuf.nsamples = 0;
|
||||
waveBuf.looping = false;
|
||||
waveBuf.status = 0;
|
||||
ndspChnWaveBufClear(chnl);
|
||||
|
||||
if (data) {
|
||||
linearFree(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Sound::Play() {
|
||||
if (rd7i_is_ndsp) {
|
||||
if (!data) return;
|
||||
DSP_FlushDataCache(data, dataSize);
|
||||
ndspChnWaveBufAdd(chnl, &waveBuf);
|
||||
}
|
||||
}
|
||||
|
||||
void Sound::Stop() {
|
||||
if (rd7i_is_ndsp) {
|
||||
if (!data) return;
|
||||
ndspChnWaveBufClear(chnl);
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
#include <renderd7/Sprite.hpp>
|
||||
|
||||
void RenderD7::Sprite::FromSheet(RenderD7::Sheet::Ref sheet, size_t index) {
|
||||
C2D_SpriteFromSheet(&this->sprite, sheet->Get(), index);
|
||||
}
|
||||
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) {
|
||||
C2D_SpriteSetCenter(&this->sprite, x, y);
|
||||
}
|
||||
void RenderD7::Sprite::SetPos(float x, float y) {
|
||||
C2D_SpriteSetPos(&this->sprite, x, y);
|
||||
}
|
||||
void RenderD7::Sprite::SetRotation(float rotation) {
|
||||
C2D_SpriteSetRotation(&this->sprite, rotation);
|
||||
}
|
||||
void RenderD7::Sprite::Rotate(float speed) {
|
||||
C2D_SpriteRotateDegrees(&this->sprite, speed);
|
||||
}
|
||||
float RenderD7::Sprite::GetHeight() { return GetSize().x; }
|
||||
float RenderD7::Sprite::GetWidth() { return GetSize().y; }
|
||||
float RenderD7::Sprite::GetPosX() { return GetPos().x; }
|
||||
float RenderD7::Sprite::GetPosY() { return GetPos().y; }
|
||||
|
||||
R7Vec2 RenderD7::Sprite::GetPos() {
|
||||
return R7Vec2(this->sprite.params.pos.x, this->sprite.params.pos.y);
|
||||
}
|
||||
|
||||
R7Vec2 RenderD7::Sprite::GetSize() {
|
||||
return R7Vec2(this->sprite.params.pos.w, this->sprite.params.pos.h);
|
||||
}
|
||||
|
||||
void RenderD7::Sprite::SetPos(R7Vec2 pos) {
|
||||
C2D_SpriteSetPos(&this->sprite, pos.x, pos.y);
|
||||
}
|
||||
|
||||
void RenderD7::Sprite::SetScale(R7Vec2 scale) {
|
||||
C2D_SpriteScale(&this->sprite, scale.x, scale.y);
|
||||
}
|
||||
void RenderD7::Sprite::SetRotCenter(R7Vec2 percentage) {
|
||||
C2D_SpriteSetCenter(&this->sprite, percentage.x, percentage.y);
|
||||
}
|
||||
|
||||
void RenderD7::Sprite::FromImage(RenderD7::Image::Ref img) {
|
||||
C2D_SpriteFromImage(&this->sprite, img->Get());
|
||||
}
|
||||
|
||||
void RenderD7::Sprite::SetScale(float x, float y) {
|
||||
C2D_SpriteScale(&this->sprite, x, y);
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
#include <renderd7/SpriteAnimation.hpp>
|
||||
|
||||
void RenderD7::SpriteSheetAnimation::Setup(RenderD7::Sheet::Ref sheet,
|
||||
size_t imagecount, size_t startimage,
|
||||
float frame_begin,
|
||||
float frame_finish) {
|
||||
D_totaltime = frame_begin;
|
||||
|
||||
this->images = imagecount;
|
||||
|
||||
this->sheet = sheet;
|
||||
|
||||
this->time = frame_finish;
|
||||
|
||||
RenderD7::SpriteSheetAnimation::FromSheet(this->sheet, startimage);
|
||||
}
|
||||
void RenderD7::SpriteSheetAnimation::Play(float timespeed) {
|
||||
D_totaltime += timespeed;
|
||||
if (D_totaltime >= time) {
|
||||
D_totaltime -= time;
|
||||
imgs++;
|
||||
if (imgs == images) {
|
||||
imgs = 0;
|
||||
}
|
||||
}
|
||||
RenderD7::SpriteSheetAnimation::FromSheet(sheet, imgs);
|
||||
// RenderD7::SpriteSheetAnimation::Draw();
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
#include <memory>
|
||||
#include <renderd7/Tasks.hpp>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
static std::vector<std::shared_ptr<std::thread>> threads;
|
||||
|
||||
int RenderD7::Tasks::Create(std::function<void()> fun) {
|
||||
auto thrd = std::make_shared<std::thread>(fun);
|
||||
threads.push_back(thrd);
|
||||
return threads.size();
|
||||
}
|
||||
|
||||
void RenderD7::Tasks::DestroyAll() {
|
||||
for (auto& it : threads) {
|
||||
if (it && it->joinable()) {
|
||||
it->join();
|
||||
}
|
||||
}
|
||||
// Delete Pointers
|
||||
threads.clear();
|
||||
}
|
@ -1,138 +0,0 @@
|
||||
#include <filesystem>
|
||||
#include <renderd7/Hid.hpp>
|
||||
#include <renderd7/Message.hpp>
|
||||
#include <renderd7/ThemeEditor.hpp>
|
||||
#include <renderd7/UI7.hpp>
|
||||
|
||||
std::map<RD7Color, std::string> color_names = {
|
||||
{RD7Color_Background, "Background"},
|
||||
{RD7Color_Button, "Button"},
|
||||
{RD7Color_ButtonActive, "ButtonActive"},
|
||||
{RD7Color_ButtonDisabled, "ButtonDisabled"},
|
||||
{RD7Color_ButtonHovered, "ButtonHovered"},
|
||||
{RD7Color_Checkmark, "Checkmark"},
|
||||
{RD7Color_FrameBg, "FrameBg"},
|
||||
{RD7Color_FrameBgHovered, "FrameBgHovered"},
|
||||
{RD7Color_Header, "Header"},
|
||||
{RD7Color_List0, "List0"},
|
||||
{RD7Color_List1, "List1"},
|
||||
{RD7Color_MessageBackground, "Message Background"},
|
||||
{RD7Color_Progressbar, "Progressbar"},
|
||||
{RD7Color_Selector, "Selector"},
|
||||
{RD7Color_SelectorFade, "SelectorFade"},
|
||||
{RD7Color_Text2, "Text Light"},
|
||||
{RD7Color_Text, "Text Dark"},
|
||||
{RD7Color_TextDisabled, "Text Disabled"},
|
||||
};
|
||||
|
||||
RenderD7::ThemeEditor::ThemeEditor() {
|
||||
// Backup active Theme and create New one to edit
|
||||
temp_theme = RenderD7::ThemeActive();
|
||||
edit_theme = RenderD7::Theme::New();
|
||||
edit_theme->CopyOther(temp_theme);
|
||||
RenderD7::ThemeSet(edit_theme);
|
||||
}
|
||||
|
||||
RenderD7::ThemeEditor::~ThemeEditor() {
|
||||
// Set Back to Acrive Theme
|
||||
RenderD7::ThemeSet(temp_theme);
|
||||
}
|
||||
|
||||
void RenderD7::ThemeEditor::Draw() const {
|
||||
RenderD7::R2()->OnScreen(R2Screen_Top);
|
||||
if (UI7::BeginMenu("RenderD7 -> Theme Editor")) {
|
||||
UI7::Label("Sample Text");
|
||||
UI7::Checkbox("Checkbox", cm);
|
||||
UI7::InputText("Input Text", inpt, "Input Text");
|
||||
UI7::Button("Button");
|
||||
UI7::Progressbar(0.5f);
|
||||
UI7::ColorSelector("Color Selector",
|
||||
edit_theme->GetTableRef()[RD7Color_Progressbar]);
|
||||
UI7::EndMenu();
|
||||
}
|
||||
RenderD7::R2()->OnScreen(R2Screen_Bottom);
|
||||
if (UI7::BeginMenu("Theme", R7Vec2(), UI7MenuFlags_Scrolling)) {
|
||||
if (menu == 0) {
|
||||
if (UI7::Button("Create New")) {
|
||||
menu = 1;
|
||||
edit_theme->Default();
|
||||
} else if (UI7::Button("Edit Current")) {
|
||||
menu = 1;
|
||||
} else if (UI7::Button("Select Theme")) {
|
||||
menu = 2;
|
||||
theme_list.clear();
|
||||
for (const auto& it : std::filesystem::directory_iterator(
|
||||
RenderD7::GetAppDirectory() + "/themes")) {
|
||||
theme_list.push_back(it.path().filename().string());
|
||||
}
|
||||
}
|
||||
} else if (menu == 1) {
|
||||
if (UI7::Button("Go back")) {
|
||||
edit_theme->CopyOther(temp_theme);
|
||||
menu = 0;
|
||||
} else if (UI7::Button("Save")) {
|
||||
RenderD7::AddOvl(std::make_unique<Ovl_Keyboard>(kbd_text, kbd_state,
|
||||
"<name>.theme"));
|
||||
}
|
||||
for (auto& it : color_names) {
|
||||
UI7::ColorSelector(it.second, edit_theme->GetTableRef()[it.first]);
|
||||
}
|
||||
} else if (menu == 2) {
|
||||
if (UI7::Button("Go back")) {
|
||||
menu = 0;
|
||||
}
|
||||
for (auto& it : theme_list) {
|
||||
if (UI7::Button(it)) {
|
||||
edit_theme->Load(RenderD7::GetAppDirectory() + "/themes/" + it);
|
||||
menu = 1;
|
||||
}
|
||||
UI7::SameLine();
|
||||
if (UI7::Button("Make Current")) {
|
||||
edit_theme->Load(RenderD7::GetAppDirectory() + "/themes/" + it);
|
||||
temp_theme->CopyOther(edit_theme);
|
||||
menu = 0;
|
||||
}
|
||||
UI7::SameLine();
|
||||
if (UI7::Button("Delete")) {
|
||||
if (std::string(it) != "renderd7.theme") {
|
||||
std::filesystem::remove(RenderD7::GetAppDirectory() + "/themes/" +
|
||||
it);
|
||||
theme_list.clear();
|
||||
for (const auto& it : std::filesystem::directory_iterator(
|
||||
RenderD7::GetAppDirectory() + "/themes")) {
|
||||
theme_list.push_back(it.path().filename().string());
|
||||
}
|
||||
} else {
|
||||
RenderD7::PushMessage("ThemeEditor",
|
||||
"Cannot Delete\nrenderd7.theme!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
UI7::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderD7::ThemeEditor::Logic() {
|
||||
if (kbd_state) {
|
||||
if (kbd_state == RD7KeyboardState_Confirm) {
|
||||
auto path =
|
||||
RenderD7::GetAppDirectory() + "/themes/" + kbd_text + ".theme";
|
||||
kbd_text = "";
|
||||
if (std::filesystem::exists(path)) {
|
||||
// Prompt Override
|
||||
return;
|
||||
}
|
||||
edit_theme->Save(path);
|
||||
}
|
||||
kbd_state = RD7KeyboardState_None;
|
||||
}
|
||||
if (Hid::IsEvent("cancel", Hid::Down)) {
|
||||
if (menu == 0) {
|
||||
RenderD7::Scene::Back();
|
||||
} else {
|
||||
if (menu == 1) edit_theme->CopyOther(temp_theme);
|
||||
menu = 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <memory>
|
||||
#include <renderd7/Time.hpp>
|
||||
#include <string>
|
||||
|
||||
std::string RenderD7::FormatString(std::string fmt_str, ...) {
|
||||
va_list ap;
|
||||
char *fp = NULL;
|
||||
va_start(ap, fmt_str);
|
||||
vasprintf(&fp, fmt_str.c_str(), ap);
|
||||
va_end(ap);
|
||||
std::unique_ptr<char, decltype(free) *> formatted(fp, free);
|
||||
return std::string(formatted.get());
|
||||
}
|
||||
|
||||
std::string RenderD7::GetTimeStr(void) {
|
||||
time_t unixTime;
|
||||
struct tm timeStruct;
|
||||
time(&unixTime);
|
||||
localtime_r(&unixTime, &timeStruct);
|
||||
return FormatString("%04i-%02i-%02i_%02i-%02i-%02i",
|
||||
timeStruct.tm_year + 1900, timeStruct.tm_mon + 1,
|
||||
timeStruct.tm_mday, timeStruct.tm_hour, timeStruct.tm_min,
|
||||
timeStruct.tm_sec);
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
#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::GetLive() { return (float)((svcGetSystemTick() - last) / TPMS); }
|
||||
} // namespace RenderD7
|
1254
source/UI7.cpp
1254
source/UI7.cpp
File diff suppressed because it is too large
Load Diff
@ -1,291 +0,0 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <malloc.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <renderd7/Error.hpp>
|
||||
#include <renderd7/FileSystem.hpp>
|
||||
#include <renderd7/external/json.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
#include <renderd7/renderd7.hpp>
|
||||
|
||||
/// Base ///
|
||||
RD7Flags rd7_flags = RD7Flags_Default;
|
||||
static RenderD7::Thread rd7i_idb_server; // Protected
|
||||
std::string rd7i_app_name;
|
||||
std::string rd7i_config_path;
|
||||
nlohmann::json rd7i_config;
|
||||
u8 rd7i_console_model = 0;
|
||||
u8 rd7i_system_region = CFG_REGION_USA;
|
||||
bool rd7i_is_citra = false;
|
||||
bool rd7i_settings = false;
|
||||
R7Vec2 rd7i_hid_touch_pos;
|
||||
C2D_TextBuf rd7i_text_buffer;
|
||||
C2D_Font rd7i_base_font;
|
||||
C2D_TextBuf rd7i_d2_dimbuf;
|
||||
bool rd7i_is_ndsp = false;
|
||||
bool rd7i_running = false;
|
||||
std::stack<std::unique_ptr<RenderD7::Scene>> RenderD7::Scene::scenes;
|
||||
std::unique_ptr<RenderD7::Scene> rd7i_fade_scene;
|
||||
std::vector<std::unique_ptr<RenderD7::Ovl>> rd7i_overlays;
|
||||
unsigned int rd7i_frames = 0;
|
||||
u64 rd7i_last_time = 0;
|
||||
float rd7i_framerate = 0.0f;
|
||||
u32 rd7i_mt_color = 0xaa000000;
|
||||
u32 rd7i_mt_txtcolor = 0xbbffffff;
|
||||
bool rd7i_mt_screen;
|
||||
float rd7i_mt_txtSize;
|
||||
bool rd7i_metrikd = false;
|
||||
bool rd7i_ftraced = false;
|
||||
u64 rd7i_delta_time;
|
||||
u64 rd7i_last_tm;
|
||||
float rd7i_dtm;
|
||||
float rd7i_time;
|
||||
bool rd7i_fadeout = false, rd7i_fadein = false, rd7i_fadeout2 = false,
|
||||
rd7i_fadein2 = false;
|
||||
int rd7i_fadealpha = 0;
|
||||
int rd7i_fadecolor = 0;
|
||||
bool rd7i_wait_fade = false;
|
||||
bool rd7i_fade_exit = false;
|
||||
bool rd7i_fade_scene_wait = false;
|
||||
bool rd7i_idb_running = false;
|
||||
bool rd7i_graphics_on = false;
|
||||
float rd7_draw2_tsm = 1.2f;
|
||||
bool rd7i_amdt = false;
|
||||
void *rd7i_soc_buf = nullptr;
|
||||
bool rd7i_is_am_init = false;
|
||||
RenderD7::Theme::Ref rd7i_active_theme;
|
||||
RenderD7::LoggerBase::Ref rd7i_logger;
|
||||
bool rd7i_lggrf = false;
|
||||
|
||||
RenderD7::LoggerBase::Ref _rd7i_logger() {
|
||||
if (!rd7i_logger) {
|
||||
RenderD7::Error(
|
||||
"You're trying to use a RenderD7 Func without Init RenderD7!");
|
||||
}
|
||||
return rd7i_logger;
|
||||
}
|
||||
|
||||
/// Global ///
|
||||
// Outdated HidApi (HidV2Patched)
|
||||
u32 d7_hDown;
|
||||
u32 d7_hHeld;
|
||||
u32 d7_hUp;
|
||||
u32 d7_hRepeat; // Inofficial lol
|
||||
touchPosition d7_touch;
|
||||
|
||||
// Modern Global Api
|
||||
int rd7_max_objects = C2D_DEFAULT_MAX_OBJECTS;
|
||||
bool rd7i_do_splash = false;
|
||||
bool rd7i_enable_scene_system = true;
|
||||
bool rd7i_debugging = false;
|
||||
C3D_RenderTarget *rd7_top;
|
||||
C3D_RenderTarget *rd7_top_right;
|
||||
C3D_RenderTarget *rd7_bottom;
|
||||
|
||||
RenderD7::Net::Error rd7i_soc_init() {
|
||||
if (rd7i_soc_buf != nullptr) {
|
||||
return 0;
|
||||
}
|
||||
rd7i_soc_buf = memalign(0x1000, 0x100000);
|
||||
if (!rd7i_soc_buf) {
|
||||
return RenderD7::Net::Error_Memory;
|
||||
}
|
||||
Result ret = socInit((u32 *)rd7i_soc_buf, 0x100000);
|
||||
if (R_FAILED(ret)) {
|
||||
free(rd7i_soc_buf);
|
||||
return ((static_cast<RenderD7::Net::Error>(ret) << 32) |
|
||||
static_cast<RenderD7::Net::Error>(RenderD7::Net::Error_CtrStatus));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rd7i_soc_deinit() {
|
||||
if (rd7i_soc_buf) {
|
||||
socExit();
|
||||
free(rd7i_soc_buf);
|
||||
}
|
||||
rd7i_soc_buf = nullptr;
|
||||
}
|
||||
|
||||
class Logger {
|
||||
public:
|
||||
Logger() = default;
|
||||
virtual ~Logger() = default;
|
||||
|
||||
static void log(const std::string &prefix, const std::string &message) {
|
||||
std::cout << "[" << prefix << "]: " << message << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
#define rd7_err(x) Logger::log("ERROR", x)
|
||||
#define rd7_wrn(x) Logger::log("WARNING", x)
|
||||
|
||||
class tcp_server {
|
||||
public:
|
||||
tcp_server(const std::string &ip, int port) {
|
||||
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sockfd < 0) {
|
||||
rd7_err("Unable to create socket!");
|
||||
return;
|
||||
}
|
||||
server.sin_family = AF_INET;
|
||||
server.sin_port = port;
|
||||
server.sin_addr.s_addr = inet_addr(ip.c_str());
|
||||
|
||||
e = bind(sockfd, (struct sockaddr *)&server, sizeof(server));
|
||||
if (e == -1) {
|
||||
rd7_err("Unable to bind!");
|
||||
return;
|
||||
}
|
||||
e = listen(sockfd, 10);
|
||||
if (e == 0) {
|
||||
printf("[+]Listening...\n");
|
||||
} else {
|
||||
rd7_err("Error in Binding");
|
||||
return;
|
||||
}
|
||||
addr_size = sizeof(new_addr);
|
||||
new_sock = accept(sockfd, (struct sockaddr *)&new_addr, &addr_size);
|
||||
std::cout << "Connected" << std::endl;
|
||||
}
|
||||
~tcp_server() {
|
||||
// Nothing here
|
||||
}
|
||||
|
||||
bool reconnect() {
|
||||
close(new_sock);
|
||||
new_sock = accept(sockfd, (struct sockaddr *)&new_addr, &addr_size);
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t snd(void *ptr, size_t size) { return send(new_sock, ptr, size, 0); }
|
||||
|
||||
size_t rec(void *ptr, size_t size) { return recv(new_sock, ptr, size, 0); }
|
||||
|
||||
private:
|
||||
int e, sockfd, new_sock;
|
||||
struct sockaddr_in server, new_addr;
|
||||
socklen_t addr_size;
|
||||
};
|
||||
|
||||
#define stupid(x) &x, sizeof(x)
|
||||
#define rd7i_reacttion(x) \
|
||||
{ \
|
||||
int code = x; \
|
||||
server.snd(stupid(code)); \
|
||||
}
|
||||
|
||||
struct pak32 {
|
||||
pak32() {}
|
||||
pak32(const std::string &n0, float n1, unsigned char n2, unsigned char n3,
|
||||
bool n4, bool n5, bool n6, float n7, float n8, float n9, float n10,
|
||||
unsigned int n11, unsigned int n12, unsigned int n13,
|
||||
unsigned int n14) {
|
||||
magic = 0x44772277;
|
||||
for (int i = 0; i < 64; i++) app_name[i] = (char)0;
|
||||
int l = n0.length();
|
||||
if (l > 64) l = 64;
|
||||
for (int i = 0; i < l; i++) app_name[i] = n0[i];
|
||||
framerate = n1;
|
||||
console_model = n2;
|
||||
system_region = n3;
|
||||
is_citra = n4;
|
||||
ndsp_support = n5;
|
||||
in_settings = n6;
|
||||
deltatime = n7;
|
||||
rtime = n8;
|
||||
cpu = n9;
|
||||
gpu = n10;
|
||||
mem_alloc = n11;
|
||||
mem_dalloc = n12;
|
||||
mem_ialloc = n13;
|
||||
tbs = n14;
|
||||
}
|
||||
uint32_t magic;
|
||||
char app_name[64];
|
||||
float framerate;
|
||||
unsigned char console_model;
|
||||
unsigned char system_region;
|
||||
bool is_citra;
|
||||
bool ndsp_support;
|
||||
bool in_settings;
|
||||
float deltatime;
|
||||
float rtime;
|
||||
float cpu;
|
||||
float gpu;
|
||||
unsigned int mem_alloc;
|
||||
unsigned int mem_dalloc;
|
||||
unsigned int mem_ialloc;
|
||||
unsigned int tbs;
|
||||
};
|
||||
|
||||
static bool rd7i_idb_fp = false;
|
||||
|
||||
void KillIdbServer() {
|
||||
rd7i_idb_fp = true;
|
||||
rd7i_idb_server.join(100);
|
||||
}
|
||||
|
||||
void ServerThread(RenderD7::Parameter param) {
|
||||
if (rd7i_soc_buf == nullptr) return;
|
||||
rd7i_idb_running = true;
|
||||
rd7i_idb_fp = false;
|
||||
atexit(KillIdbServer);
|
||||
tcp_server server("0.0.0.0", 4727);
|
||||
int cmd = 0;
|
||||
while (!rd7i_idb_fp) {
|
||||
size_t r = server.rec(&cmd, sizeof(int));
|
||||
if (r == 0) {
|
||||
server.reconnect();
|
||||
}
|
||||
if (cmd == 1) {
|
||||
rd7i_reacttion(1);
|
||||
auto pak = pak32(
|
||||
rd7i_app_name, rd7i_framerate, rd7i_console_model, rd7i_system_region,
|
||||
rd7i_is_citra, rd7i_is_ndsp, rd7i_settings, rd7i_dtm, rd7i_time,
|
||||
C3D_GetProcessingTime(), C3D_GetDrawingTime(),
|
||||
RenderD7::Memory::GetTotalAllocated(),
|
||||
RenderD7::Memory::GetTotalFreed(), RenderD7::Memory::GetCurrent(),
|
||||
C2D_TextBufGetNumGlyphs(rd7i_text_buffer));
|
||||
server.snd(stupid(pak));
|
||||
} else if (cmd == 2) {
|
||||
rd7i_reacttion(2);
|
||||
std::vector<RenderD7::FileSystem::Entry> el =
|
||||
RenderD7::FileSystem::GetDirContent("sdmc:/");
|
||||
size_t buf = el.size() * sizeof(RenderD7::FileSystem::Entry);
|
||||
server.snd(stupid(buf));
|
||||
server.snd(el.data(), buf);
|
||||
|
||||
} else if (cmd == 3) {
|
||||
rd7i_reacttion(3);
|
||||
RenderD7::ExitApp();
|
||||
rd7i_idb_fp = true;
|
||||
} else {
|
||||
rd7i_reacttion(1234);
|
||||
}
|
||||
}
|
||||
rd7i_idb_running = false;
|
||||
}
|
||||
|
||||
namespace RenderD7 {
|
||||
namespace IDB {
|
||||
void Start() {
|
||||
if (rd7i_idb_running) return;
|
||||
rd7i_idb_server.initialize(ServerThread);
|
||||
rd7i_idb_server.start(true);
|
||||
}
|
||||
void Stop() {
|
||||
if (!rd7i_idb_running) return;
|
||||
rd7i_idb_fp = true;
|
||||
KillIdbServer();
|
||||
}
|
||||
void Restart() {
|
||||
Stop();
|
||||
Start();
|
||||
}
|
||||
} // namespace IDB
|
||||
} // namespace RenderD7
|
118
source/lang.cpp
118
source/lang.cpp
@ -1,118 +0,0 @@
|
||||
#include <3ds.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <renderd7/lang.hpp>
|
||||
|
||||
static nlohmann::json appJson;
|
||||
|
||||
std::string RenderD7::Lang::GetSys() {
|
||||
u8 language = 1;
|
||||
CFGU_GetSystemLanguage(&language);
|
||||
|
||||
switch (language) {
|
||||
case 0:
|
||||
return "jp"; // Japanese
|
||||
break;
|
||||
|
||||
case 1:
|
||||
return "en"; // English
|
||||
break;
|
||||
|
||||
case 2:
|
||||
return "fr"; // French
|
||||
break;
|
||||
|
||||
case 3:
|
||||
return "de"; // German
|
||||
break;
|
||||
|
||||
case 4:
|
||||
return "it"; // Italian
|
||||
break;
|
||||
|
||||
case 5:
|
||||
return "es"; // Spanish
|
||||
break;
|
||||
|
||||
case 6:
|
||||
return "zh-CN"; // Chinese (Simplified)
|
||||
break;
|
||||
|
||||
case 7:
|
||||
return "ko"; // Korean
|
||||
break;
|
||||
|
||||
case 8:
|
||||
return "nl"; // Dutch
|
||||
break;
|
||||
|
||||
case 9:
|
||||
return "pt"; // Portuguese
|
||||
break;
|
||||
|
||||
case 10:
|
||||
return "ru"; // Russian
|
||||
break;
|
||||
|
||||
case 11:
|
||||
return "zh-TW"; // Chinese (Traditional)
|
||||
break;
|
||||
|
||||
default:
|
||||
return "en"; // Fall back to English if missing
|
||||
break;
|
||||
}
|
||||
}
|
||||
std::string RenderD7::Lang::Get(const std::string &key) {
|
||||
if (!appJson.contains("keys")) return "ERR-01";
|
||||
nlohmann::json js = appJson["keys"];
|
||||
if (!js.contains(key)) return key;
|
||||
return js.at(key).get<std::string>();
|
||||
}
|
||||
|
||||
void RenderD7::Lang::Load(const std::string &lang) {
|
||||
std::fstream values;
|
||||
if (std::filesystem::exists("romfs:/lang/" + lang + "/app.json")) {
|
||||
values.open("romfs:/lang/" + lang + "/app.json", std::ios::in);
|
||||
if (values.is_open()) {
|
||||
appJson = nlohmann::json::parse(values);
|
||||
}
|
||||
values.close();
|
||||
if (appJson.is_discarded()) {
|
||||
appJson = {};
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
values.open("romfs:/lang/en/app.json", std::ios::in);
|
||||
if (values.is_open()) {
|
||||
appJson = nlohmann::json::parse(values);
|
||||
}
|
||||
values.close();
|
||||
if (appJson.is_discarded()) {
|
||||
appJson = {};
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::string RenderD7::Lang::GetName() {
|
||||
if (!appJson.contains("info")) return "";
|
||||
nlohmann::json js = appJson["info"];
|
||||
if (!js.contains("name")) return "Unknown";
|
||||
return js.at("name").get<std::string>();
|
||||
}
|
||||
|
||||
std::string RenderD7::Lang::GetAuthor() {
|
||||
if (!appJson.contains("info")) return "";
|
||||
nlohmann::json js = appJson["info"];
|
||||
if (!js.contains("author")) return "Unknown";
|
||||
return js.at("author").get<std::string>();
|
||||
}
|
||||
|
||||
std::string RenderD7::Lang::GetShortcut() {
|
||||
if (!appJson.contains("info")) return "";
|
||||
nlohmann::json js = appJson["info"];
|
||||
if (!js.contains("shortcut")) return "Unknown";
|
||||
return js.at("shortcut").get<std::string>();
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
;
|
||||
LI7 Shader;
|
||||
Constants.constf myconst(0.0, 1.0, 0.00392156862745, 0.0)
|
||||
.alias ones myconst.yyyy;
|
||||
Vector full of ones
|
||||
|
||||
;
|
||||
Uniforms.fvec projection[4]
|
||||
|
||||
;
|
||||
Outputs.out out_position position.out out_color color.out out_uv texcoord0
|
||||
|
||||
;
|
||||
Inputs.alias in_xyz v0.alias in_uvc
|
||||
v1.alias in_col v2
|
||||
|
||||
.entry vmain.proc vmain mov r0.xyz,
|
||||
in_xyz.xyz mov r0.w,
|
||||
ones
|
||||
|
||||
dp4 out_position.x,
|
||||
projection[0], r0 dp4 out_position.y, projection[1], r0 dp4 out_position.z,
|
||||
projection[2], r0 dp4 out_position.w, projection[3],
|
||||
r0
|
||||
|
||||
mov out_uv,
|
||||
in_uvc.xy
|
||||
|
||||
mul r1,
|
||||
myconst.zzzz, in_col mov out_color, r1 end.end
|
117
source/nimg.cpp
117
source/nimg.cpp
@ -1,117 +0,0 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <renderd7/nimg.hpp>
|
||||
|
||||
// Use an Npi simplifier cause I am lazy
|
||||
#define reca_cc(x) reinterpret_cast<const char*>(x)
|
||||
#define reca_c(x) reinterpret_cast<char*>(x)
|
||||
#define pak32(q, w, e, r) \
|
||||
((((q) & 0xff) << 0) | (((w) & 0xff) << 8) | (((e) & 0xff) << 16) | \
|
||||
(((r) & 0xff) << 24))
|
||||
|
||||
// Stupid RLE Algorithm
|
||||
void npi_compress(std::vector<unsigned char>& ret,
|
||||
const std::vector<unsigned char>& in) {
|
||||
unsigned char counter = 1;
|
||||
unsigned char tmp = in[0];
|
||||
for (size_t i = 1; i < in.size(); ++i) {
|
||||
if (tmp == in[i]) {
|
||||
counter++;
|
||||
} else {
|
||||
ret.push_back(counter);
|
||||
ret.push_back(tmp);
|
||||
counter = 1;
|
||||
tmp = in[i];
|
||||
}
|
||||
if (counter == 255) {
|
||||
ret.push_back(counter);
|
||||
ret.push_back(tmp);
|
||||
counter = 0;
|
||||
}
|
||||
}
|
||||
if (counter > 0) {
|
||||
ret.push_back(counter);
|
||||
ret.push_back(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
void npi_decompress(std::vector<unsigned char>& ret,
|
||||
const std::vector<unsigned char>& in) {
|
||||
// Size is sus
|
||||
if ((in.size() % 2) != 0) return;
|
||||
for (size_t i = 0; i < in.size(); i += 2) {
|
||||
int count = in[i];
|
||||
int value = in[i + 1];
|
||||
for (int c = 0; c < count; c++) {
|
||||
ret.push_back(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace RenderD7 {
|
||||
nimg NIMG_Load(std::string path) {
|
||||
nimg res;
|
||||
std::ifstream fin(path, std::ios::in | std::ios::binary);
|
||||
// Check magic
|
||||
fin.read(reca_c(&res.magic), sizeof(uint32_t));
|
||||
if (res.magic != NPI_NIMG_) {
|
||||
std::cout << path << " is invalid!" << std::endl;
|
||||
return res;
|
||||
}
|
||||
// Read Information
|
||||
fin.read(reca_c(&res.width), sizeof(int));
|
||||
fin.read(reca_c(&res.height), sizeof(int));
|
||||
fin.read(reca_c(&res.format), sizeof(int));
|
||||
fin.read(reca_c(&res.compression), sizeof(int));
|
||||
// Read Pixeldata
|
||||
if (res.compression == 1) {
|
||||
std::vector<unsigned char> tb;
|
||||
int pb_size = 0;
|
||||
fin.read(reca_c(&pb_size), sizeof(int));
|
||||
tb.resize(pb_size);
|
||||
fin.read(reca_c(tb.data()), pb_size);
|
||||
npi_decompress(res.pixel_buffer, tb);
|
||||
} else {
|
||||
int pb_size = 0;
|
||||
fin.read(reca_c(&pb_size), sizeof(int));
|
||||
res.pixel_buffer.resize(pb_size);
|
||||
fin.read(reca_c(res.pixel_buffer.data()), pb_size);
|
||||
}
|
||||
|
||||
// Close stream
|
||||
fin.close();
|
||||
// Return the loadet imaeg
|
||||
return res;
|
||||
}
|
||||
|
||||
nimg NIMG_LoadFromMem(unsigned char* buffer, size_t bf_size) { return nimg(); }
|
||||
|
||||
void NIMG_Save(nimg image, std::string path) {
|
||||
std::ofstream fout(path);
|
||||
// Write Magic
|
||||
fout.write(reca_cc(&image.magic), sizeof(uint32_t));
|
||||
// Write Information
|
||||
fout.write(reca_cc(&image.width), sizeof(int));
|
||||
fout.write(reca_cc(&image.height), sizeof(int));
|
||||
fout.write(reca_cc(&image.format), sizeof(int));
|
||||
fout.write(reca_cc(&image.compression), sizeof(int));
|
||||
std::vector<unsigned char> test;
|
||||
// Write pixels
|
||||
if (image.compression == 1) {
|
||||
std::vector<unsigned char> tb;
|
||||
npi_compress(tb, image.pixel_buffer);
|
||||
int buf_szs = tb.size();
|
||||
fout.write(reca_cc(&buf_szs), sizeof(int)); // buf_size
|
||||
fout.write(reca_cc(tb.data()),
|
||||
tb.size()); // buffer
|
||||
} else {
|
||||
int buf_szs = image.pixel_buffer.size();
|
||||
fout.write(reca_cc(&buf_szs), sizeof(int)); // buf_size
|
||||
fout.write(reca_cc(image.pixel_buffer.data()),
|
||||
image.pixel_buffer.size()); // buffer
|
||||
}
|
||||
|
||||
// Close stream
|
||||
fout.close();
|
||||
}
|
||||
} // namespace RenderD7
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user