Add Some Tools and Assets to create cpp's for 0.9+

This commit is contained in:
tobid7 2023-03-13 21:19:07 +01:00
parent f6e3c50814
commit 780025bb74
47 changed files with 214 additions and 30355 deletions

View File

@ -1,4 +1,4 @@
# RenderD7 <img alt="LOGO" src="https://github.com/NPI-D7/RenderD7/blob/main/logo.png" height="30">
# RenderD7 <img alt="LOGO" src="https://github.com/NPI-D7/RenderD7/blob/main/logo.png" height="90">
RenderD7 is now LibRenderD7.
### Installation (Ubuntu)
first run this
@ -14,3 +14,11 @@ Make sure that `-lrenderd7` is before `-lcitro2d`, `-lcitro3d`, `-lctru`.
# RenderD7 (https://npi-d7.github.io/RenderD7/)
Simple and Easey to use UI and Graphics helper.
Create DOCS
# Credits
- NPI-D7
- Tobi-D7 Main Dev
Some Icons are From
https://icons8.de/
See Subfolder Readmes

34
assets/build_assets.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
echo "Create Directorys"
mkdir -p build
mkdir -p code
echo "Generating Spritesheets"
cd resources
for file in *.t3s
do
filename=$(basename "$file" .t3s).t3x
tex3ds -o "../build/$filename" -i "${file}"
done
echo "Converting Spritesheets into C++ Code"
cd ../code
for file in ../build/*.t3x
do
name="${file##*/}"
name="${name%.*}"
../../tools/bin/file2array "${file}" "${name}"
done
echo "Convert Npi-Intro to C++ Code"
../../tools/bin/file2array ../splash/npi_intro.nvid npi_intro
echo "Fix The Output of file2array"
for file in ./*.cpp
do
../../tools/bin/rd7f2afix "${file}" "renderd7"
done
echo "Finished!"

7
assets/clear_assets.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
echo "Deleting Directorys"
rm -rf build
rm -rf code
echo "Finished!"

View File

@ -0,0 +1,2 @@
# Source
https://icons8.de/

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 739 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

View File

@ -0,0 +1,11 @@
--atlas -f rgba -z auto
battery/battery_full.png
battery/battery_nearfull.png
battery/battery_half.png
battery/battery_low.png
battery/battery_verylow.png
battery/battery_warning.png
battery/battery_charging.png
battery/battery_empty.png
battery/battery_dead.png

View File

@ -0,0 +1,3 @@
--atlas -f rgba -z auto
renderd7_logo/renderd7_logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -0,0 +1,19 @@
--atlas -f rgba -z auto
ui_elements/high_volume.png
ui_elements/mid_volume.png
ui_elements/low_volume.png
ui_elements/speaker_v1.png
ui_elements/no_sound.png
ui_elements/speaker.png
ui_elements/wifi_connected.png
ui_elements/wifi_disconnected.png
ui_elements/wifi_off.png
ui_elements/good_connection.png
ui_elements/mid_connection.png
ui_elements/bad_connection.png
ui_elements/no_connection.png
ui_elements/headphones.png

View File

@ -0,0 +1,2 @@
# Source
https://icons8.de/

Binary file not shown.

After

Width:  |  Height:  |  Size: 392 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 964 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 681 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
assets/splash/npi_intro.mp4 Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1 +0,0 @@
External Librarys

View File

@ -0,0 +1,5 @@
#pragma once
#include <cstddef>
extern unsigned char battery_icons[];
extern size_t battery_icons_size;

View File

@ -0,0 +1,5 @@
#pragma once
#include <cstddef>
extern unsigned char ui_elements[];
extern size_t ui_elements_size;

BIN
logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 13 KiB

5
source/battery_icons.cpp Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -387,7 +387,8 @@ bool RenderD7::MainLoop() {
RenderD7::Scene::doDraw();
RenderD7::Scene::doLogic(d7_hDown, d7_hHeld, d7_hUp, d7_touch);
cnttttt++;
if (cnttttt > 2) {
//Disably Overlays For one Frame
if (cnttttt > 1) {
shouldbe_disabled = false;
cnttttt = 0;
}

File diff suppressed because one or more lines are too long

5
source/ui_elements.cpp Normal file

File diff suppressed because one or more lines are too long

9
tools/build_tools.sh Executable file
View File

@ -0,0 +1,9 @@
#Build Tools
echo "Generate Directorys"
mkdir -p bin
echo "Building file2array"
g++ -static -o bin/file2array file2array/file2array.cpp
echo "Building rd7f2afix"
g++ -static -o bin/rd7f2afix rd7f2afix/rd7f2afix.cpp
echo "Finished!"

4
tools/clear_tools.sh Executable file
View File

@ -0,0 +1,4 @@
#Delete Tools
echo "Delete Binary Directory"
rm -rf bin
echo "Finished!"

View File

@ -0,0 +1,43 @@
#include <fstream>
#include <iostream>
#include <vector>
int main(int argc, char *argv[]) {
if (argc < 3) {
std::cout << "Usage:\nfile2array <file> <dstfilename>\n";
return 0;
}
std::string file_path = argv[1];
std::ifstream file(file_path, std::ios::binary);
if (!file.is_open()) {
std::cerr << "[-] Could not open file" << std::endl;
return 1;
}
std::vector<unsigned char> buffer(std::istreambuf_iterator<char>(file), {});
const size_t array_size = buffer.size();
std::ofstream fout(std::string(argv[2]) + ".cpp");
fout << "#include <" << argv[2] << ".hpp>" << std::endl;
fout << "\nunsigned char " << argv[2] << "[] = {";
for (std::size_t i = 0; i < buffer.size(); ++i) {
if (i != 0) {
fout << ", ";
}
fout << "0x" << std::hex << static_cast<int>(buffer[i]);
}
fout << "};" << std::endl;
fout << "\nsize_t " << argv[2] << "_size = 0x" << std::hex << array_size
<< ";" << std::endl;
std::ofstream fhead(std::string(argv[2]) + ".hpp");
fhead << "#pragma once\n#include <cstddef>\n";
fhead << "\nextern unsigned char " << argv[2] << "[];";
fhead << "\nextern size_t " << argv[2] << "_size;";
file.close();
fout.close();
return 0;
}

View File

@ -0,0 +1,46 @@
#include <filesystem>
#include <fstream>
#include <iostream>
#include <regex>
#include <string>
int main(int argc, char *argv[]) {
if (argc != 3) {
std::cerr << "Usage: " << argv[0] << " input_file path\n";
return 1;
}
std::string input_filename =
std::filesystem::path(argv[1]).filename().string();
std::string input_path = argv[1];
std::string path = argv[2];
std::string header_filename =
input_filename.substr(0, input_filename.find_last_of(".")) + ".hpp";
std::string include_statement =
"#include <" + path + "/" + header_filename + ">";
std::ifstream input_file(input_path);
if (!input_file.is_open()) {
std::cerr << "Error: Failed to open input file\n";
return 1;
}
std::string input_contents((std::istreambuf_iterator<char>(input_file)),
std::istreambuf_iterator<char>());
input_file.close();
std::regex pattern("#include\\s+<.*\\.hpp>\\s*?");
input_contents =
std::regex_replace(input_contents, pattern, include_statement);
std::ofstream output_file(input_filename);
if (!output_file.is_open()) {
std::cerr << "Error: Failed to open output file for writing\n";
return 1;
}
output_file << input_contents;
output_file.close();
std::cout << "Done! Output written to " << input_filename << std::endl;
std::cout << "Include statement: " << include_statement << std::endl;
return 0;
}