From 0c0c46e23d9148c00c5de6ea194bc1d3b6250452 Mon Sep 17 00:00:00 2001 From: Grayson Riffe Date: Thu, 30 Jan 2025 12:39:59 -0600 Subject: [PATCH] Add entry point and debug texts --- NothinFancy/CMakeLists.txt | 6 ++++-- NothinFancy/src/Engine.cpp | 15 +++++++++++--- NothinFancy/src/include/nf.h | 24 ++++++++++++++++++++++- NothinFancy/src/include/nf/EngineConfig.h | 14 +++++++++++++ TestGame/src/TestGame.cpp | 9 ++++++--- 5 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 NothinFancy/src/include/nf/EngineConfig.h diff --git a/NothinFancy/CMakeLists.txt b/NothinFancy/CMakeLists.txt index f2eb9b1..1b1e8fe 100644 --- a/NothinFancy/CMakeLists.txt +++ b/NothinFancy/CMakeLists.txt @@ -1,12 +1,14 @@ # NF library CMakeLists.txt -add_library(NothinFancy STATIC "src/Engine.cpp" "src/include/nf.h" "src/pch.h" "src/util.h" "src/util/log.h" "src/util/log.cpp") +add_library(NothinFancy STATIC "src/Engine.cpp" "src/include/nf.h" "src/pch.h" "src/util.h" "src/util/log.h" "src/util/log.cpp" "src/include/nf/EngineConfig.h") # Use C++20 set_property(TARGET NothinFancy PROPERTY CXX_STANDARD 20) +# Additional include directories +target_include_directories(NothinFancy PUBLIC "src" "src/include") + # Use precompiled header target_precompile_headers(NothinFancy PUBLIC "src/pch.h") -target_include_directories(NothinFancy PUBLIC "src/") # Generate version.h find_package(Git) diff --git a/NothinFancy/src/Engine.cpp b/NothinFancy/src/Engine.cpp index bcf79e2..6cc79d2 100644 --- a/NothinFancy/src/Engine.cpp +++ b/NothinFancy/src/Engine.cpp @@ -1,13 +1,22 @@ // NF startup #include "pch.h" +#include "nf/EngineConfig.h" #include "version.h" #include "util.h" namespace nf { - void startEngine() { - NFLog(std::format("Nothin' Fancy {}", NFVERSION)); - NFError("Test error."); + void runEngine(EngineConfig config) { + std::string engineStr = std::format("Nothin' Fancy {}", NFVERSION); + std::string gameStr = std::format("{} {}", config.appName, config.appVersion); + NFLog(engineStr); + NFLog(std::format("Starting {}", gameStr)); + +#ifdef _DEBUG + SetThreadDescription(GetCurrentThread(), L"NF Main Thread"); + SetConsoleTitle(std::format("{} Debug Console - {}", engineStr, gameStr).c_str()); +#endif + std::cin.get(); } } diff --git a/NothinFancy/src/include/nf.h b/NothinFancy/src/include/nf.h index 1aa4a6a..3b92b55 100644 --- a/NothinFancy/src/include/nf.h +++ b/NothinFancy/src/include/nf.h @@ -1,6 +1,28 @@ // NF main public header #pragma once +#include "nf/EngineConfig.h" + namespace nf { - void startEngine(); + struct CommandLineArguments { + int argc; + char** argv; + }; + + EngineConfig configureEngine(CommandLineArguments cmdArgs); + + void runEngine(EngineConfig config); } + +// NF entry point +#ifdef NFENTRY + +int main(int argc, char* argv[]) { + nf::EngineConfig config = nf::configureEngine({ argc, argv }); + + nf::runEngine(config); + + return 0; +} + +#endif diff --git a/NothinFancy/src/include/nf/EngineConfig.h b/NothinFancy/src/include/nf/EngineConfig.h new file mode 100644 index 0000000..e8192ab --- /dev/null +++ b/NothinFancy/src/include/nf/EngineConfig.h @@ -0,0 +1,14 @@ +// EngineConfig struct public header +#pragma once + +namespace nf { + struct EngineConfig { + const char* appName; + const char* appVersion; + + EngineConfig() + : appName("Nothin' Fancy Game") + , appVersion("v0.1.0") + {} + }; +} diff --git a/TestGame/src/TestGame.cpp b/TestGame/src/TestGame.cpp index 3ac770d..f8dbec4 100644 --- a/TestGame/src/TestGame.cpp +++ b/TestGame/src/TestGame.cpp @@ -1,7 +1,10 @@ // TestGame main file +#define NFENTRY #include "nf.h" -int main(int argc, char* argv[]) { - nf::startEngine(); - return 0; +namespace nf { + EngineConfig configureEngine(CommandLineArguments cmdArgs) { + EngineConfig config; + return config; + } }