#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "Levels/MainMenu.h" #include "Levels/TestLevel.h" int main() { ehs::Initialize("TechDemo", "Release", {1, 0, 0}); ehs::Log::EnableImmediateMode(true); ehs::File configFile("Config.json", ehs::Mode::READ_WRITE, ehs::Disposition::OPEN_PERSISTENT); if (!configFile.Size()) { ehs::JsonObj root; ehs::JsonObj server; server.AddVar({"identifier", ""}); server.AddVar({"address", ""}); server.AddVar({"port", 7840}); server.AddVar({"maxPlayers", 0}); root.AddVar({"server", server}); ehs::JsonObj client; client.AddVar({"username", ""}); client.AddVar({"connectAddress", ""}); client.AddVar({"connectPort", 7840}); root.AddVar({"client", client}); ehs::JsonObj server_client; server_client.AddVar({"timeout", 5}); server_client.AddVar({"resendRate", 0.5f}); root.AddVar({"server_client", server_client}); ehs::JsonObj engine; engine.AddVar({"threadCount", 0}); engine.AddVar({"timeLocked", true}); engine.AddVar({"maxTPS", 60}); root.AddVar({"engine", engine}); ehs::Json config(root); configFile.WriteStr_8(config.ToStr(false)); configFile.Release(); return 0; } ehs::Json config(configFile.ReadStr_8(configFile.Size()), 0); configFile.Release(); ehs::Vector args = ehs::Console::GetArgs_8(); if (args.Size() > 1 && ehs::Str_8::Cmp(args[1], "-server")) { ehs::Console::Attach(); ehs::Console::SetTitle_8("TechDemo"); EHS_LOG(ehs::LogType::INFO, 0, "Initializing server, standby."); lwe::GameLoop gl((ehs::UInt_8)*(ehs::JsonNum*)config.RetrieveValue("engine.threadCount"), 0); gl.EnableTimeLock(*(ehs::JsonBool*)config.RetrieveValue("engine.timeLocked")); gl.SetMaxTPS((ehs::UInt_32)*(ehs::JsonNum*)config.RetrieveValue("engine.maxTPS")); gl.AddLevel(new MainMenu("MainMenu")); gl.Initialize(); gl.Start(); gl.UnInitialize(); } else { ehs::Console::Attach(); lwe::RenderWindow::AddExtensions(); lwe::GpuInstance::Initialize(true); lwe::GpuDevice device = std::move(lwe::GpuDevice::GetBest()); lwe::GpuQueueFamily* family = device.GetQueueFamily(lwe::QueueType::GRAPHICS); lwe::GpuInterface inf(&device); lwe::RenderWindow::AddExtensions(&inf); lwe::GpuQueue primary(family, &inf, 1.0f); inf.Initialize(); lwe::RenderWindow win(&inf, &primary); win.Create_8(ehs::GetAppName_8(), {0, 0}, {1024, 768}); win.Show(); lwe::GameLoop gl(&win, (ehs::UInt_8)*(ehs::JsonNum*)config.RetrieveValue("engine.threadCount"), 0); gl.EnableTimeLock(*(ehs::JsonBool*)config.RetrieveValue("engine.timeLocked")); gl.SetMaxTPS((ehs::UInt_32)*(ehs::JsonNum*)config.RetrieveValue("engine.maxTPS")); gl.AddLevel(new TestLevel("Test")); gl.Initialize(); gl.Start(); gl.UnInitialize(); win.Close(); inf.Release(); lwe::GpuInstance::Release(); } ehs::Console::Free(); ehs::Uninitialize(); return 0; }