Wrote the asset pack creator; Encryption no longer needs to be specified in readFile
This commit is contained in:
parent
29b3f8627e
commit
995cd5e80a
BIN
DevScreenshots/2. Textured Quad with Transformations.png
Normal file
BIN
DevScreenshots/2. Textured Quad with Transformations.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
@ -108,6 +108,9 @@
|
|||||||
<AdditionalLibraryDirectories>$(ProjectDir)dep\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(ProjectDir)dep\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>nf.res;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>nf.res;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Command>cd "$(SolutionDir)NFPackCreator\bin\AssetBuild" && "$(SolutionDir)NFPackCreator\bin\Win32$(Configuration)\NFPackCreator.exe" && del "$(OutDir)assets\" /Q /S && copy "$(SolutionDir)NFPackCreator\bin\AssetBuild\*.nfpack" "$(OutDir)assets\"</Command>
|
||||||
|
</PostBuildEvent>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
@ -131,6 +134,9 @@
|
|||||||
<AdditionalLibraryDirectories>$(ProjectDir)dep\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(ProjectDir)dep\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>nf.res;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>nf.res;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Command>cd "$(SolutionDir)NFPackCreator\bin\AssetBuild" && "$(SolutionDir)NFPackCreator\bin\Win32$(Configuration)\NFPackCreator.exe" && del "$(OutDir)assets\" /Q /S && copy "$(SolutionDir)NFPackCreator\bin\AssetBuild\*.nfpack" "$(OutDir)assets\"</Command>
|
||||||
|
</PostBuildEvent>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
@ -150,6 +156,9 @@
|
|||||||
<AdditionalLibraryDirectories>$(ProjectDir)dep\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(ProjectDir)dep\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>nf.res;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>nf.res;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Command>cd "$(SolutionDir)NFPackCreator\bin\AssetBuild" && "$(SolutionDir)NFPackCreator\bin\Win32$(Configuration)\NFPackCreator.exe" && del "$(OutDir)assets\" /Q /S && copy "$(SolutionDir)NFPackCreator\bin\AssetBuild\*.nfpack" "$(OutDir)assets\"</Command>
|
||||||
|
</PostBuildEvent>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
@ -173,6 +182,9 @@
|
|||||||
<AdditionalLibraryDirectories>$(ProjectDir)dep\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(ProjectDir)dep\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>nf.res;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>nf.res;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
|
<PostBuildEvent>
|
||||||
|
<Command>cd "$(SolutionDir)NFPackCreator\bin\AssetBuild" && "$(SolutionDir)NFPackCreator\bin\Win32$(Configuration)\NFPackCreator.exe" && del "$(OutDir)assets\" /Q /S && copy "$(SolutionDir)NFPackCreator\bin\AssetBuild\*.nfpack" "$(OutDir)assets\"</Command>
|
||||||
|
</PostBuildEvent>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\NothinFancy\NothinFancy.vcxproj">
|
<ProjectReference Include="..\NothinFancy\NothinFancy.vcxproj">
|
||||||
|
100
NFPackCreator/NFPackCreator.rc
Normal file
100
NFPackCreator/NFPackCreator.rc
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
// Microsoft Visual C++ generated resource script.
|
||||||
|
//
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 2 resource.
|
||||||
|
//
|
||||||
|
#include "winres.h"
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// English (United States) resources
|
||||||
|
|
||||||
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||||
|
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||||
|
#pragma code_page(1252)
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TEXTINCLUDE
|
||||||
|
//
|
||||||
|
|
||||||
|
1 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"resource.h\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
2 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"#include ""winres.h""\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
3 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Version
|
||||||
|
//
|
||||||
|
|
||||||
|
VS_VERSION_INFO VERSIONINFO
|
||||||
|
FILEVERSION 1,0,0,1
|
||||||
|
PRODUCTVERSION 1,0,0,1
|
||||||
|
FILEFLAGSMASK 0x3fL
|
||||||
|
#ifdef _DEBUG
|
||||||
|
FILEFLAGS 0x1L
|
||||||
|
#else
|
||||||
|
FILEFLAGS 0x0L
|
||||||
|
#endif
|
||||||
|
FILEOS 0x40004L
|
||||||
|
FILETYPE 0x1L
|
||||||
|
FILESUBTYPE 0x0L
|
||||||
|
BEGIN
|
||||||
|
BLOCK "StringFileInfo"
|
||||||
|
BEGIN
|
||||||
|
BLOCK "040904b0"
|
||||||
|
BEGIN
|
||||||
|
VALUE "CompanyName", "Grayson Riffe"
|
||||||
|
VALUE "FileDescription", "Nothin' Fancy Asset Pack Creator"
|
||||||
|
VALUE "FileVersion", "1.0"
|
||||||
|
VALUE "InternalName", "NFPackCreator.exe"
|
||||||
|
VALUE "LegalCopyright", "Copyright (C) 2021 Grayson Riffe"
|
||||||
|
VALUE "OriginalFilename", "NFPackCreator.exe"
|
||||||
|
VALUE "ProductName", "Nothin' Fancy Asset Pack Creator"
|
||||||
|
VALUE "ProductVersion", "1.0"
|
||||||
|
END
|
||||||
|
END
|
||||||
|
BLOCK "VarFileInfo"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Translation", 0x409, 1200
|
||||||
|
END
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // English (United States) resources
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 3 resource.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#endif // not APSTUDIO_INVOKED
|
||||||
|
|
98
NFPackCreator/NFPackCreator.vcxproj
Normal file
98
NFPackCreator/NFPackCreator.vcxproj
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{771b4aee-e2c6-4745-ac40-1ef57149612e}</ProjectGuid>
|
||||||
|
<RootNamespace>NFPackCreator</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<OutDir>$(ProjectDir)bin\$(Platform)$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(ProjectDir)int\$(Platform)$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<OutDir>$(ProjectDir)bin\$(Platform)$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(ProjectDir)int\$(Platform)$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="src\main.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="resource.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="NFPackCreator.rc" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
32
NFPackCreator/NFPackCreator.vcxproj.filters
Normal file
32
NFPackCreator/NFPackCreator.vcxproj.filters
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="src\main.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="resource.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="NFPackCreator.rc">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</ResourceCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
16
NFPackCreator/NFPackCreator.vcxproj.user
Normal file
16
NFPackCreator/NFPackCreator.vcxproj.user
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ShowAllFiles>true</ShowAllFiles>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
|
||||||
|
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||||
|
<LocalDebuggerCommandArguments>-h</LocalDebuggerCommandArguments>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
|
||||||
|
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||||
|
<LocalDebuggerCommandArguments>-h</LocalDebuggerCommandArguments>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
14
NFPackCreator/resource.h
Normal file
14
NFPackCreator/resource.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Visual C++ generated include file.
|
||||||
|
// Used by NFPackCreator.rc
|
||||||
|
|
||||||
|
// Next default values for new objects
|
||||||
|
//
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||||
|
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||||
|
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||||
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
|
#endif
|
||||||
|
#endif
|
120
NFPackCreator/src/main.cpp
Normal file
120
NFPackCreator/src/main.cpp
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <set>
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
void Log(const std::string& in) {
|
||||||
|
std::cout << "[NFPackCreator] Info: " << in << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
void Log(const char* in) {
|
||||||
|
std::cout << "[NFPackCreator] Info: " << in << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
__declspec(noreturn) void Error(const std::string& in) {
|
||||||
|
HANDLE cmd = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
SetConsoleTextAttribute(cmd, FOREGROUND_RED);
|
||||||
|
std::cout << "[NFPackCreator] Error: " + in + "\n";
|
||||||
|
SetConsoleTextAttribute(cmd, 7);
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||||
|
std::exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Success(const std::string& in) {
|
||||||
|
HANDLE cmd = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
SetConsoleTextAttribute(cmd, FOREGROUND_GREEN);
|
||||||
|
std::cout << "[NFPackCreator] Success: " + in + "\n";
|
||||||
|
SetConsoleTextAttribute(cmd, 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string readFile(const std::string& filename) {
|
||||||
|
std::ifstream in;
|
||||||
|
in.open(filename);
|
||||||
|
if (!in)
|
||||||
|
Error("File \"" + (std::string)filename + (std::string)"\" could not be read!");
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << in.rdbuf();
|
||||||
|
std::string read(ss.str());
|
||||||
|
if (read.size() > 4 && read.substr(0, 4) == "NFEF") {
|
||||||
|
read = read.substr(4);
|
||||||
|
for (unsigned int i = 0; i < read.size(); i++)
|
||||||
|
read[i] = read[i] - 100;
|
||||||
|
}
|
||||||
|
return read;
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeFile(const std::string& filename, const std::string& in, bool encrypted) {
|
||||||
|
std::ofstream out;
|
||||||
|
out.open(filename);
|
||||||
|
if (!out)
|
||||||
|
Error("File \"" + (std::string)filename + (std::string)"\" could not be written!");
|
||||||
|
std::string write(in);
|
||||||
|
if (encrypted) {
|
||||||
|
for (unsigned int i = 0; i < write.size(); i++)
|
||||||
|
write[i] = write[i] + 100;
|
||||||
|
write.insert(0, "NFEF");
|
||||||
|
}
|
||||||
|
out << write;
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
Log("Starting up");
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
if ((std::string)argv[1] == "-h") {
|
||||||
|
Log("Nothin' Fancy Asset Pack Creator\nThis tool creates .nfpack files for the NF engine to load at runtime.\nA pack gets created for each directory in the working directory if there are only compatible files inside.\nSubdirectories are not ignored.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::set<std::string> extensions;
|
||||||
|
extensions.insert({ "obj", "png" });
|
||||||
|
|
||||||
|
unsigned int dirCount = 0;
|
||||||
|
const std::filesystem::path workingDir = std::filesystem::current_path();
|
||||||
|
for (const auto& currDir : std::filesystem::directory_iterator(std::filesystem::current_path())) {
|
||||||
|
if (!currDir.is_directory())
|
||||||
|
continue;
|
||||||
|
std::string filename = currDir.path().filename().string().append(".nfpack");
|
||||||
|
Log("Creating pack \"" + filename + (std::string)"\"");
|
||||||
|
std::ifstream in;
|
||||||
|
std::stringstream out;
|
||||||
|
unsigned int fileCount = 0;
|
||||||
|
for (const auto& curr : std::filesystem::recursive_directory_iterator(currDir)) {
|
||||||
|
if (curr.is_directory())
|
||||||
|
continue;
|
||||||
|
std::filesystem::path relative = std::filesystem::relative(curr, currDir);
|
||||||
|
if (extensions.find(relative.extension().string().substr(1)) == extensions.end())
|
||||||
|
Error("File \"" + relative.string() + (std::string)"\" is not of supported type!");
|
||||||
|
Log("Current file: " + relative.string());
|
||||||
|
|
||||||
|
in.open(curr.path(), std::ios::binary);
|
||||||
|
if (!in)
|
||||||
|
Error("Couldn't open \"" + relative.string() + (std::string)"\"!");
|
||||||
|
if (out.rdbuf()->in_avail() != 0)
|
||||||
|
out << "\n";
|
||||||
|
out << "#NFASSET " + curr.path().filename().string();
|
||||||
|
out << "\n";
|
||||||
|
out << in.rdbuf();
|
||||||
|
in.close();
|
||||||
|
fileCount++;
|
||||||
|
}
|
||||||
|
if (fileCount == 0) {
|
||||||
|
Log("No files found inside of \"" + currDir.path().filename().string() + (std::string)"\". No pack written.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
writeFile(filename, out.str(), true);
|
||||||
|
Success("Wrote \"" + filename + (std::string)"\" containing " + std::to_string(fileCount) + (std::string)" files.");
|
||||||
|
dirCount++;
|
||||||
|
}
|
||||||
|
if (dirCount > 0)
|
||||||
|
Log("Wrote " + std::to_string(dirCount) + (std::string)" asset pack(s).");
|
||||||
|
Log("Done");
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||||
|
return 0;
|
||||||
|
}
|
@ -23,7 +23,7 @@ namespace nf {
|
|||||||
|
|
||||||
void AssetPack::load(const char* packName) {
|
void AssetPack::load(const char* packName) {
|
||||||
std::string path = "assets/" + (std::string)packName + ".nfpack";
|
std::string path = "assets/" + (std::string)packName + ".nfpack";
|
||||||
std::string contents = readFile(path.c_str(), true);
|
std::string contents = readFile(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetPack::~AssetPack() {
|
AssetPack::~AssetPack() {
|
||||||
|
@ -35,7 +35,7 @@ namespace nf {
|
|||||||
SetConsoleTextAttribute(cmd, FOREGROUND_RED);
|
SetConsoleTextAttribute(cmd, FOREGROUND_RED);
|
||||||
std::printf("[%.4f] Error (%s, %i): %s\n", time.count(), filename, line, in);
|
std::printf("[%.4f] Error (%s, %i): %s\n", time.count(), filename, line, in);
|
||||||
SetConsoleTextAttribute(cmd, 7);
|
SetConsoleTextAttribute(cmd, 7);
|
||||||
CloseHandle(cmd);
|
FindClose(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Debug::ErrorImp(const std::string& in, const char* filename, int line) {
|
void Debug::ErrorImp(const std::string& in, const char* filename, int line) {
|
||||||
@ -45,7 +45,7 @@ namespace nf {
|
|||||||
std::printf("[%.4f] Error (%s, %i): ", time.count(), filename, line);
|
std::printf("[%.4f] Error (%s, %i): ", time.count(), filename, line);
|
||||||
std::cout << in << "\n";
|
std::cout << in << "\n";
|
||||||
SetConsoleTextAttribute(cmd, 7);
|
SetConsoleTextAttribute(cmd, 7);
|
||||||
CloseHandle(cmd);
|
FindClose(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::chrono::duration<float> Debug::getCurrentTime() {
|
std::chrono::duration<float> Debug::getCurrentTime() {
|
||||||
@ -82,11 +82,10 @@ namespace nf {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool writeFile(const char* filename, const std::string& in, bool encrypted) {
|
void writeFile(const std::string& filename, const std::string& in, bool encrypted) {
|
||||||
std::string file(filename);
|
if (filename.find('/') != std::string::npos || filename.find('\\') != std::string::npos) {
|
||||||
if (file.find('/') != std::string::npos || file.find('\\') != std::string::npos) {
|
int pos = filename.find_last_of("/\\");
|
||||||
int pos = file.find_last_of("/\\");
|
std::string temp = filename.substr(0, pos);
|
||||||
std::string temp = file.substr(0, pos);
|
|
||||||
std::wstring folders(temp.begin(), temp.end());
|
std::wstring folders(temp.begin(), temp.end());
|
||||||
WCHAR exe[MAX_PATH];
|
WCHAR exe[MAX_PATH];
|
||||||
GetModuleFileName(GetModuleHandle(NULL), exe, MAX_PATH);
|
GetModuleFileName(GetModuleHandle(NULL), exe, MAX_PATH);
|
||||||
@ -104,21 +103,23 @@ namespace nf {
|
|||||||
if (encrypted) {
|
if (encrypted) {
|
||||||
for (unsigned int i = 0; i < write.size(); i++)
|
for (unsigned int i = 0; i < write.size(); i++)
|
||||||
write[i] = write[i] + 100;
|
write[i] = write[i] + 100;
|
||||||
|
write.insert(0, "NFEF");
|
||||||
}
|
}
|
||||||
out << write;
|
out << write;
|
||||||
out.close();
|
out.close();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string readFile(const char* filename, bool encrypted) {
|
std::string readFile(const std::string& filename) {
|
||||||
std::ifstream in;
|
std::ifstream in;
|
||||||
in.open(filename);
|
in.open(filename, std::ios::binary);
|
||||||
|
//TODO: Test this change
|
||||||
if (!in)
|
if (!in)
|
||||||
Error("File \"" + (std::string)filename + (std::string)"\" could not be read!");
|
Error("File \"" + (std::string)filename + (std::string)"\" could not be read!");
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << in.rdbuf();
|
ss << in.rdbuf();
|
||||||
std::string read(ss.str());
|
std::string read(ss.str());
|
||||||
if (encrypted) {
|
if (read.size() > 4 && read.substr(0, 4) == "NFEF" ){
|
||||||
|
read = read.substr(4);
|
||||||
for (unsigned int i = 0; i < read.size(); i++)
|
for (unsigned int i = 0; i < read.size(); i++)
|
||||||
read[i] = read[i] - 100;
|
read[i] = read[i] - 100;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ std::exit(-1);}
|
|||||||
|
|
||||||
const wchar_t* toWide(const char* in);
|
const wchar_t* toWide(const char* in);
|
||||||
const wchar_t* toWide(const std::string& in);
|
const wchar_t* toWide(const std::string& in);
|
||||||
bool writeFile(const char* filename, const std::string& in, bool encrypted = false);
|
void writeFile(const std::string& filename, const std::string& in, bool encrypted = false);
|
||||||
std::string readFile(const char* filename, bool encrypted = false);
|
std::string readFile(const std::string& filename);
|
||||||
|
|
||||||
}
|
}
|
11
STEMSln.sln
11
STEMSln.sln
@ -6,6 +6,11 @@ MinimumVisualStudioVersion = 10.0.40219.1
|
|||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NothinFancy", "NothinFancy\NothinFancy.vcxproj", "{1B9C5361-E301-41BF-97E7-56D65F11E2BB}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NothinFancy", "NothinFancy\NothinFancy.vcxproj", "{1B9C5361-E301-41BF-97E7-56D65F11E2BB}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Game", "Game\Game.vcxproj", "{B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Game", "Game\Game.vcxproj", "{B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{771B4AEE-E2C6-4745-AC40-1EF57149612E} = {771B4AEE-E2C6-4745-AC40-1EF57149612E}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NFPackCreator", "NFPackCreator\NFPackCreator.vcxproj", "{771B4AEE-E2C6-4745-AC40-1EF57149612E}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -27,6 +32,12 @@ Global
|
|||||||
{B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Release|x64.ActiveCfg = Release|x64
|
{B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Release|x64.ActiveCfg = Release|x64
|
||||||
{B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Release|x86.ActiveCfg = Release|Win32
|
{B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Release|x86.ActiveCfg = Release|Win32
|
||||||
{B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Release|x86.Build.0 = Release|Win32
|
{B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{771B4AEE-E2C6-4745-AC40-1EF57149612E}.Debug|x64.ActiveCfg = Debug|Win32
|
||||||
|
{771B4AEE-E2C6-4745-AC40-1EF57149612E}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{771B4AEE-E2C6-4745-AC40-1EF57149612E}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{771B4AEE-E2C6-4745-AC40-1EF57149612E}.Release|x64.ActiveCfg = Release|Win32
|
||||||
|
{771B4AEE-E2C6-4745-AC40-1EF57149612E}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{771B4AEE-E2C6-4745-AC40-1EF57149612E}.Release|x86.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
Reference in New Issue
Block a user