diff --git a/gameenv/data/sys/cvardefs.cvars b/gameenv/data/sys/cvardefs.cvars new file mode 100644 index 0000000..cce33e4 --- /dev/null +++ b/gameenv/data/sys/cvardefs.cvars @@ -0,0 +1,3 @@ +vid_3d_renderer true +vid_3d_grid false +vid_2d_background false \ No newline at end of file diff --git a/gmtk2025/data/cfg/startup.cfg b/gmtk2025/data/cfg/startup.cfg index ed4d1db..5ab20ca 100644 --- a/gmtk2025/data/cfg/startup.cfg +++ b/gmtk2025/data/cfg/startup.cfg @@ -2,4 +2,6 @@ echo "GMTK 2025" echo "Made with MPFW" echo "" show_cursor +disable_game +ui_show ui_create_window "data/menus/mainmenu.wnd" \ No newline at end of file diff --git a/gmtk2025/data/sys/cvardefs.cvars b/gmtk2025/data/sys/cvardefs.cvars new file mode 100644 index 0000000..cce33e4 --- /dev/null +++ b/gmtk2025/data/sys/cvardefs.cvars @@ -0,0 +1,3 @@ +vid_3d_renderer true +vid_3d_grid false +vid_2d_background false \ No newline at end of file diff --git a/gmtk2025/imgui.ini b/gmtk2025/imgui.ini new file mode 100644 index 0000000..fe28880 --- /dev/null +++ b/gmtk2025/imgui.ini @@ -0,0 +1,8 @@ +[Window][Debug##Default] +Pos=60,60 +Size=400,400 + +[Window][GMTK 2025] +Pos=57,64 +Size=262,178 + diff --git a/mpfw/MPFW_CVars.cpp b/mpfw/MPFW_CVars.cpp deleted file mode 100644 index b663ae6..0000000 --- a/mpfw/MPFW_CVars.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "MPFW_CVars.h" - - -#include - - -std::variant MPFW::CVar::get() { - try { - int retval = std::stoi(value); - return retval; - } - catch(...){ - return value; - } -} - diff --git a/mpfw/MPFW_CVars.h b/mpfw/MPFW_CVars.h deleted file mode 100644 index 34f861b..0000000 --- a/mpfw/MPFW_CVars.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include -#include -#include - -namespace MPFW { - class CVar { - public: - std::string value; - std::variant get(); - }; - - - using CVarMap = std::map; - -} - diff --git a/mpfw/MPFW_Console.cpp b/mpfw/MPFW_Console.cpp index 5e45d6b..547a488 100644 --- a/mpfw/MPFW_Console.cpp +++ b/mpfw/MPFW_Console.cpp @@ -1,9 +1,12 @@ + +#include #include "MPFW_Console.h" #include #include #include + MPFW_ConsoleCommand(echo) { for (int i = 0; i < cmd.size(); i++) { *logStr += std::format("{} ", cmd[i]); @@ -31,9 +34,15 @@ MPFW_ConsoleCommand(ui_create_window) { } } +MPFW_ConsoleCommand(ui_show) { + ctx->ui->rendererIsActive = true; +} +MPFW_ConsoleCommand(ui_hide) { + ctx->ui->rendererIsActive = false; +} + MPFW_ConsoleCommand(ui_delete_window) { if (cmd.size() != 1) { - } } @@ -79,18 +88,46 @@ MPFW_ConsoleCommand(map_mpfw) { *logStr += "Mode MPFW has no \"map\" command because it has no available map format.\n\nUse one of these modes instead:\n - 'mode 1' : QUAKE\n\n"; } - +MPFW_ConsoleCommand(disable_game) { + ctx->gameDisabled = true; +} +MPFW_ConsoleCommand(enable_game) { + ctx->gameDisabled = false; +} MPFW_ConsoleCommand(set) { - + if (cmd.size() == 2) { + ctx->cvars[cmd[0]] = cmd[1]; + } } +MPFW_ConsoleCommand(show_cursor) { + ctx->ui->showCursorOnLaunch = true; + EnableCursor(); +} +MPFW_ConsoleCommand(hide_cursor) { + ctx->ui->showCursorOnLaunch = false; + DisableCursor(); +} MPFW::Console::CommandHandler::CommandHandler(CommandHandlerResources* c) { chr = c; + + chr->cvars.clear(); + + std::ifstream cvarFile("data/sys/cvardefs.cvars"); + std::string cvarLine; + while (std::getline(cvarFile, cvarLine)) { + std::vector line = parseCommand(cvarLine); + chr->cvars[line[0]] = line[1]; + } + + + + #pragma region @@ -99,6 +136,12 @@ MPFW::Console::CommandHandler::CommandHandler(CommandHandlerResources* c) // elemental commands work. less important commands will be // defined with a definition instantiator or some random shit + CommandID mpfwSet = { MPFW, "set" }; + CommandID quakeSet = { QUAKE, "set" }; + functionMap[mpfwSet] = set; + functionMap[quakeSet] = set; + + CommandID mpfwEcho = { MPFW, "echo" }; CommandID quakeEcho = { QUAKE, "echo" }; functionMap[mpfwEcho] = echo; @@ -125,6 +168,25 @@ MPFW::Console::CommandHandler::CommandHandler(CommandHandlerResources* c) CommandID uiCreateWindow = { MPFW, "ui_create_window" }; functionMap[uiCreateWindow] = ui_create_window; + CommandID uiShow = { MPFW, "ui_show" }; + functionMap[uiShow] = ui_show; + CommandID uiHide = { MPFW, "ui_hide" }; + functionMap[uiHide] = ui_hide; + + + CommandID mpfwShowCursor = { MPFW, "show_cursor" }; + functionMap[mpfwShowCursor] = show_cursor; + + CommandID mpfwHideCursor = { MPFW, "hide_cursor" }; + functionMap[mpfwHideCursor] = hide_cursor; + + + CommandID mpfwEnableGame = { MPFW, "enable_game" }; + functionMap[mpfwEnableGame] = enable_game; + + CommandID mpfwDisableGame = { MPFW, "disable_game" }; + functionMap[mpfwDisableGame] = disable_game; + #pragma endregion System Commands diff --git a/mpfw/MPFW_Console.h b/mpfw/MPFW_Console.h index 9e5c085..f52dbdd 100644 --- a/mpfw/MPFW_Console.h +++ b/mpfw/MPFW_Console.h @@ -20,6 +20,8 @@ namespace MPFW { Quake::Maps::MapFile* mapQuake; OperationMode mode = MPFW; UI::UIRenderer* ui; + std::map cvars; + bool gameDisabled = false; }; @@ -63,7 +65,7 @@ namespace MPFW{ CommandHandlerResources* chr; std::unordered_map,CommandHandlerResources*, std::string*)>> functionMap; public: - + [[deprecated("Never initialize an empty command handler")]] CommandHandler() { throw; } diff --git a/mpfw/MPFW_UI.h b/mpfw/MPFW_UI.h index f8e2064..adfc348 100644 --- a/mpfw/MPFW_UI.h +++ b/mpfw/MPFW_UI.h @@ -40,7 +40,7 @@ namespace MPFW { class UIRenderer { bool cursorState = false; // false = off, true = on public: - + bool showCursorOnLaunch = false; UIRenderer(); bool rendererIsActive = false; MPFW::Console::CommandHandler* cmh; diff --git a/mpfw/main.cpp b/mpfw/main.cpp index f622da8..00ad747 100644 --- a/mpfw/main.cpp +++ b/mpfw/main.cpp @@ -135,47 +135,7 @@ int main() { #endif MPFW::Quake::Maps::MapFile map; - // std::thread t(__DebugCounter_Quake, &map); - - // t.detach(); - - std::vector colors; - - for (int i = 0; i < 3000000; i++) { - colors.push_back({ (unsigned char)GetRandomValue(0, 255), (unsigned char)GetRandomValue(0, 255), (unsigned char)GetRandomValue(0, 255), 255 }); - } - - std::print("MAP DATA:\n---------\n\n"); - std::print("Version: {}\n", map.data.header.version); - std::print("\n---\nDIRENTS\n-------\n"); - std::print("Entities: {}\n", map.data.header.entities); - std::print("Planes: {}\n", map.data.header.planes); - std::print("Wall Textures (miptex): {}\n", map.data.header.miptex); - std::print("Map Vertices: {}\n", map.data.header.vertices); - std::print("Leaves Visibility Lists: {}\n", map.data.header.visilist); - std::print("BSP Nodes: {}\n", map.data.header.nodes); - std::print("Texture Info for Faces: {}\n", map.data.header.texinfo); - std::print("Faces of each surface: {}\n", map.data.header.faces); - std::print("Wall Lightmaps: {}\n", map.data.header.lightmaps); - std::print("Clip Nodes: {}\n", map.data.header.clipnodes); - std::print("BSP Leaves: {}\n", map.data.header.leaves); - std::print("List of Faces: {}\n", map.data.header.lface); - std::print("Edges of Faces: {}\n", map.data.header.edges); - std::print("List of Edges: {}\n", map.data.header.ledges); - std::print("Models: {}\n", map.data.header.models); - - std::print("---\n\n"); - - std::print("Vertex count: {} (on {} in header)\n", map.data.vertices.size(), map.data.header.vertices.size / sizeof(Vector3)); - std::print("Edge count: {} (on {} in header)\n", map.data.edges.size(), map.data.header.edges.size / 4); - - std::print("Model count: {} (on {} in header)\n", map.data.models.size(), map.data.header.models.size / sizeof(MPFW::Quake::Maps::qModel)); - for (int i = 0; i < map.data.models.size(); i++) { - if (map.data.models[i].node_id3 != 0) { - std::print("node 3 on {} isn't 0 ({})\n", i, map.data.models[i].node_id3); - } - } - + map.pal = new MPFW::Quake::Maps::Palette("data/palette.lmp"); SetConfigFlags(FLAG_WINDOW_RESIZABLE); @@ -221,7 +181,7 @@ int main() { while (!WindowShouldClose()) { - if (framebuffer < 5) { + if (framebuffer < 5 && !uiRenderer.showCursorOnLaunch) { DisableCursor(); framebuffer++; @@ -230,7 +190,7 @@ int main() { if (IsKeyPressed(KEY_APOSTROPHE)) { consoleOn = !consoleOn; } - if(!consoleOn){ + if(!consoleOn && IsCursorHidden()){ Look(); Vector3 wishVel = { 0,0,0 }; wishSpeed = 320; @@ -271,9 +231,11 @@ int main() { velocity *= {GetFrameTime(), 1, GetFrameTime()}; + camera.position += velocity; + camera.target = camera.position + rotation; } - if (IsKeyPressed(KEY_ESCAPE)) { + if (IsKeyPressed(KEY_ESCAPE) && !chr.gameDisabled) { if (IsCursorHidden()) { EnableCursor(); uiRenderer.rendererIsActive = true; @@ -284,47 +246,47 @@ int main() { } } - camera.position += velocity; - camera.target = camera.position + rotation; BeginDrawing(); ClearBackground(BLACK); - DrawRectangleGradientV(0, 0, GetScreenWidth(), GetScreenHeight(), WHITE, LIGHTGRAY); + if (chr.cvars["vid_2d_background"] == "true") DrawRectangleGradientV(0, 0, GetScreenWidth(), GetScreenHeight(), WHITE, LIGHTGRAY); - BeginMode3D(camera); - DrawGrid(10000, 10); - - for (int i = 0; i < map.data.renderFaces.size(); i++) { - rlColor4ub(255, 255, 255, 255); - rlSetTexture(map.data.renderFaces[i].glTextureId); + if (chr.cvars["vid_3d_renderer"] == "true") { + BeginMode3D(camera); + if(chr.cvars["vid_3d_grid"] == "true") DrawGrid(10000, 10); + + for (int i = 0; i < map.data.renderFaces.size(); i++) { + rlColor4ub(255, 255, 255, 255); + rlSetTexture(map.data.renderFaces[i].glTextureId); - for (int j = 1; j < map.data.renderFaces[i].vertices.size(); j++) { - rlBegin(RL_QUADS); // for texturing reasons because rlgl - Vector3 a = map.data.renderFaces[i].vertices[0], - b = map.data.renderFaces[i].vertices[j], - c = map.data.renderFaces[i].vertices[j - 1]; + for (int j = 1; j < map.data.renderFaces[i].vertices.size(); j++) { + rlBegin(RL_QUADS); // for texturing reasons because rlgl + Vector3 a = map.data.renderFaces[i].vertices[0], + b = map.data.renderFaces[i].vertices[j], + c = map.data.renderFaces[i].vertices[j - 1]; - Vector2 at = map.data.renderFaces[i].texCoords[0], - bt = map.data.renderFaces[i].texCoords[j], - ct = map.data.renderFaces[i].texCoords[j - 1]; + Vector2 at = map.data.renderFaces[i].texCoords[0], + bt = map.data.renderFaces[i].texCoords[j], + ct = map.data.renderFaces[i].texCoords[j - 1]; - rlTexCoord2f(at.x, at.y); - rlVertex3f(a.x, a.y, a.z); - rlTexCoord2f(bt.x, bt.y); - rlVertex3f(b.x, b.y, b.z); - rlTexCoord2f(ct.x, ct.y); - rlVertex3f(c.x, c.y, c.z); - rlVertex3f(c.x, c.y, c.z); + rlTexCoord2f(at.x, at.y); + rlVertex3f(a.x, a.y, a.z); + rlTexCoord2f(bt.x, bt.y); + rlVertex3f(b.x, b.y, b.z); + rlTexCoord2f(ct.x, ct.y); + rlVertex3f(c.x, c.y, c.z); + rlVertex3f(c.x, c.y, c.z); + + + rlEnd(); + } - rlEnd(); } - - + EndMode3D(); } - EndMode3D(); DrawFPS(0, 0); if (consoleOn) { diff --git a/mpfw/mpfw.vcxproj b/mpfw/mpfw.vcxproj index 0fa15bd..94b4147 100644 --- a/mpfw/mpfw.vcxproj +++ b/mpfw/mpfw.vcxproj @@ -146,7 +146,6 @@ - @@ -155,7 +154,6 @@ - diff --git a/mpfw/mpfw.vcxproj.filters b/mpfw/mpfw.vcxproj.filters index 75a1879..327449a 100644 --- a/mpfw/mpfw.vcxproj.filters +++ b/mpfw/mpfw.vcxproj.filters @@ -33,9 +33,6 @@ Source Files - - Source Files - ext. @@ -80,9 +77,6 @@ Header Files - - Header Files - Header Files diff --git a/mpfw/mpfw.vcxproj.user b/mpfw/mpfw.vcxproj.user index 6acfa8d..d011c1f 100644 --- a/mpfw/mpfw.vcxproj.user +++ b/mpfw/mpfw.vcxproj.user @@ -1,11 +1,11 @@  - $(SolutionDir)/gmtk2025 + $(SolutionDir)/gameenv WindowsLocalDebugger - $(SolutionDir)/gmtk2025 + $(SolutionDir)/gameenv WindowsLocalDebugger \ No newline at end of file