From b3c097be224c9714f2c74c5693a45636786aa6d7 Mon Sep 17 00:00:00 2001 From: shweet Date: Sun, 1 Mar 2026 01:09:02 -0500 Subject: [PATCH] vscode tasks, build settings, etc. --- .gitignore | 4 +- .vscode/launch.json | 83 +++++++++----- .vscode/tasks.json | 199 +++++++++++++++++++++++++++------- CMakeLists.txt | 16 ++- CMakePresets.json | 24 ++-- CMakeSettings.json | 30 ++--- README.md | 7 +- cmake/copy_resources.cmake | 17 +++ src/loader.cpp | 2 + src/loader.hpp | 2 - src/resource/xml/settings.hpp | 4 +- src/state.cpp | 6 +- src/state/main.cpp | 28 +++-- src/state/main/menu.cpp | 4 +- src/state/main/menu.hpp | 1 - src/state/main/world.cpp | 1 - web/index.html | 43 ++++++++ 17 files changed, 350 insertions(+), 121 deletions(-) create mode 100644 cmake/copy_resources.cmake create mode 100644 web/index.html diff --git a/.gitignore b/.gitignore index 83991c8..b327771 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ build/ build-web/ resources/ -release/ \ No newline at end of file +release/ +out/ +external/ \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 57435b0..6ea77e7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,28 +1,61 @@ { - "version": "0.2.0", - "configurations": [ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug (CMake Debug preset)", + "type": "cppdbg", + "request": "launch", + "preLaunchTask": "cmake: build debug", + "program": "${workspaceFolder}/out/build/linux-debug/bin/Debug/snivy", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}/out/build/linux-debug", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "miDebuggerPath": "/usr/bin/gdb", + "setupCommands": [ { - "name": "Debug", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceFolder}/build/snivy", - "args": [], - "stopAtEntry": false, - "cwd": "${workspaceFolder}/build", - "environment": [], - "externalConsole": false, - "MIMode": "gdb", - "miDebuggerPath": "/usr/bin/gdb", - "setupCommands": [ - { - "description": "Enable pretty-printing for gdb", - "text": "-enable-pretty-printing" - }, - { - "description": "Set disassembly flavor to Intel", - "text": "-gdb-set disassembly-flavor intel" - } - ] + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing" }, - ] -} \ No newline at end of file + { + "description": "Set disassembly flavor to Intel", + "text": "-gdb-set disassembly-flavor intel" + } + ], + "windows": { + "type": "cppvsdbg", + "program": "${workspaceFolder}/out/build/x64-Debug/bin/Debug/snivy.exe", + "cwd": "${workspaceFolder}/out/build/x64-Debug" + } + }, + { + "name": "Run (CMake Release preset)", + "type": "cppdbg", + "request": "launch", + "noDebug": true, + "preLaunchTask": "cmake: build release", + "program": "${workspaceFolder}/out/build/linux-release/bin/Release/snivy", + "args": [], + "cwd": "${workspaceFolder}/out/build/linux-release", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "miDebuggerPath": "/usr/bin/gdb", + "windows": { + "type": "cppvsdbg", + "program": "${workspaceFolder}/out/build/x64-Release/bin/Release/snivy.exe", + "cwd": "${workspaceFolder}/out/build/x64-Release" + } + }, + { + "name": "Web (Emscripten + Chromium)", + "type": "node-terminal", + "request": "launch", + "preLaunchTask": "web: run", + "command": "echo \"Web task complete. If Chromium did not open, run task: web: open chromium\"", + "cwd": "${workspaceFolder}" + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index aa7e245..b756d93 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,44 +1,159 @@ { - "version": "2.0.0", - "tasks": [ - { - "label": "build", - "type": "shell", - "command": "cmake --build build", - "group": { - "kind": "build", - "isDefault": true - }, - "problemMatcher": [ - "$gcc" - ] - }, - { - "label": "start-wasm-devserver", - "type": "shell", - "command": "${workspaceFolder}/scripts/start_wasm_dev.sh", - "presentation": { - "reveal": "silent", - "panel": "dedicated" - }, - "problemMatcher": [] - }, - { - "label": "stop-wasm-devserver", - "type": "shell", - "command": "${workspaceFolder}/scripts/stop_wasm_dev.sh", - "problemMatcher": [] - }, - { - "type": "cmake", - "label": "CMake: build", - "command": "build", - "targets": [ - "[N/A - Select Kit]" - ], - "group": "build", - "problemMatcher": [], - "detail": "CMake template build task" - } - ] + "version": "2.0.0", + "tasks": [ + { + "label": "cmake: configure debug", + "type": "shell", + "linux": { + "command": "cmake --preset linux-debug" + }, + "windows": { + "command": "cmake --preset x64-Debug" + }, + "problemMatcher": [] + }, + { + "label": "cmake: build debug", + "type": "shell", + "linux": { + "command": "cmake --build --preset linux-debug" + }, + "windows": { + "command": "cmake --build --preset x64-Debug" + }, + "dependsOn": "cmake: configure debug", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [ + "$gcc" + ] + }, + { + "label": "cmake: configure release", + "type": "shell", + "linux": { + "command": "cmake --preset linux-release" + }, + "windows": { + "command": "cmake --preset x64-Release" + }, + "problemMatcher": [] + }, + { + "label": "cmake: build release", + "type": "shell", + "linux": { + "command": "cmake --build --preset linux-release" + }, + "windows": { + "command": "cmake --build --preset x64-Release" + }, + "dependsOn": "cmake: configure release", + "problemMatcher": [ + "$gcc" + ] + }, + { + "label": "linux: run debug", + "type": "shell", + "linux": { + "command": "${workspaceFolder}/out/build/linux-debug/bin/Debug/snivy" + }, + "windows": { + "command": "echo \"linux: run debug is Linux-only\" && exit 1" + }, + "dependsOn": "cmake: build debug", + "problemMatcher": [] + }, + { + "label": "linux: run release", + "type": "shell", + "linux": { + "command": "${workspaceFolder}/out/build/linux-release/bin/Release/snivy" + }, + "windows": { + "command": "echo \"linux: run release is Linux-only\" && exit 1" + }, + "dependsOn": "cmake: build release", + "problemMatcher": [] + }, + { + "label": "web: configure", + "type": "shell", + "linux": { + "command": "sh -lc 'if ! command -v emcmake >/dev/null 2>&1; then if [ -n \"$EMSDK\" ] && [ -f \"$EMSDK/emsdk_env.sh\" ]; then . \"$EMSDK/emsdk_env.sh\" >/dev/null 2>&1; elif [ -f \"$HOME/emsdk/emsdk_env.sh\" ]; then . \"$HOME/emsdk/emsdk_env.sh\" >/dev/null 2>&1; elif [ -f \"../emsdk/emsdk_env.sh\" ]; then . \"../emsdk/emsdk_env.sh\" >/dev/null 2>&1; else echo \"Emscripten not found. Install emsdk or set EMSDK env var.\"; exit 1; fi; fi; emcmake cmake -S . -B out/build/web -DCMAKE_BUILD_TYPE=Release'" + }, + "windows": { + "command": "echo \"web tasks are configured for Linux (emsdk + python + chromium).\" && exit 1" + }, + "problemMatcher": [] + }, + { + "label": "web: build", + "type": "shell", + "linux": { + "command": "sh -lc 'if ! command -v emcmake >/dev/null 2>&1; then if [ -n \"$EMSDK\" ] && [ -f \"$EMSDK/emsdk_env.sh\" ]; then . \"$EMSDK/emsdk_env.sh\" >/dev/null 2>&1; elif [ -f \"$HOME/emsdk/emsdk_env.sh\" ]; then . \"$HOME/emsdk/emsdk_env.sh\" >/dev/null 2>&1; elif [ -f \"../emsdk/emsdk_env.sh\" ]; then . \"../emsdk/emsdk_env.sh\" >/dev/null 2>&1; else echo \"Emscripten not found. Install emsdk or set EMSDK env var.\"; exit 1; fi; fi; cmake --build out/build/web -j$(nproc)'" + }, + "windows": { + "command": "echo \"web tasks are configured for Linux (emsdk + python + chromium).\" && exit 1" + }, + "dependsOn": "web: configure", + "problemMatcher": [] + }, + { + "label": "web: serve", + "type": "shell", + "linux": { + "command": "sh -lc 'PID_FILE=/tmp/snivy-web-http.pid; LOG_FILE=/tmp/snivy-web-http.log; WEB_ROOT=out/build/web; URL=http://127.0.0.1:8000/bin/Release/index.html; [ -f \"$WEB_ROOT/bin/Release/index.html\" ] || { echo \"Web output not found at $WEB_ROOT/bin/Release/index.html (run web: build)\"; exit 1; }; if [ -f \"$PID_FILE\" ] && kill -0 \"$(cat \"$PID_FILE\")\" 2>/dev/null; then kill \"$(cat \"$PID_FILE\")\" >/dev/null 2>&1 || true; rm -f \"$PID_FILE\"; fi; nohup python3 -m http.server 8000 --bind 127.0.0.1 --directory \"$WEB_ROOT\" >\"$LOG_FILE\" 2>&1 & echo $! >\"$PID_FILE\"; echo \"Started web server on http://127.0.0.1:8000 (root: $WEB_ROOT)\"; READY=0; for _ in $(seq 1 40); do if command -v curl >/dev/null 2>&1; then curl -fsS \"$URL\" >/dev/null 2>&1 && READY=1 && break; elif command -v wget >/dev/null 2>&1; then wget -qO- \"$URL\" >/dev/null 2>&1 && READY=1 && break; fi; sleep 0.1; done; [ \"$READY\" = \"1\" ] || { echo \"Web server did not become ready. See /tmp/snivy-web-http.log\"; exit 1; }'" + }, + "windows": { + "command": "echo \"web tasks are configured for Linux (emsdk + python + chromium).\" && exit 1" + }, + "problemMatcher": [] + }, + { + "label": "web: stop server", + "type": "shell", + "linux": { + "command": "sh -lc 'PID_FILE=/tmp/snivy-web-http.pid; if [ -f \"$PID_FILE\" ] && kill -0 \"$(cat \"$PID_FILE\")\" 2>/dev/null; then kill \"$(cat \"$PID_FILE\")\" && rm -f \"$PID_FILE\" && echo \"Stopped web server\"; else rm -f \"$PID_FILE\" && echo \"Web server not running\"; fi'" + }, + "windows": { + "command": "echo \"web tasks are configured for Linux (emsdk + python + chromium).\" && exit 1" + }, + "problemMatcher": [] + }, + { + "label": "web: open chromium", + "type": "shell", + "linux": { + "command": "sh -lc 'URL=http://127.0.0.1:8000/bin/Release/index.html; (xdg-open \"$URL\" >/dev/null 2>&1 || chromium --new-tab \"$URL\" >/dev/null 2>&1 || chromium-browser --new-tab \"$URL\" >/dev/null 2>&1 || google-chrome --new-tab \"$URL\" >/dev/null 2>&1 || google-chrome-stable --new-tab \"$URL\" >/dev/null 2>&1 || python3 -m webbrowser \"$URL\" >/dev/null 2>&1) & sleep 0.15; echo \"Requested browser open: $URL\"'" + }, + "windows": { + "command": "start http://127.0.0.1:8000/index.html" + }, + "problemMatcher": [] + }, + { + "label": "web: prepare", + "dependsOrder": "sequence", + "dependsOn": [ + "web: build", + "web: serve" + ], + "problemMatcher": [] + }, + { + "label": "web: run", + "type": "shell", + "linux": { + "command": "sh -lc 'set -e; if ! command -v emcmake >/dev/null 2>&1; then if [ -n \"$EMSDK\" ] && [ -f \"$EMSDK/emsdk_env.sh\" ]; then . \"$EMSDK/emsdk_env.sh\" >/dev/null 2>&1; elif [ -f \"$HOME/emsdk/emsdk_env.sh\" ]; then . \"$HOME/emsdk/emsdk_env.sh\" >/dev/null 2>&1; elif [ -f \"../emsdk/emsdk_env.sh\" ]; then . \"../emsdk/emsdk_env.sh\" >/dev/null 2>&1; else echo \"Emscripten not found. Install emsdk or set EMSDK env var.\"; exit 1; fi; fi; emcmake cmake -S . -B out/build/web -DCMAKE_BUILD_TYPE=Release; cmake --build out/build/web -j$(nproc); PID_FILE=/tmp/snivy-web-http.pid; LOG_FILE=/tmp/snivy-web-http.log; WEB_ROOT=out/build/web; URL=http://127.0.0.1:8000/bin/Release/index.html; [ -f \"$WEB_ROOT/bin/Release/index.html\" ] || { echo \"Web output not found at $WEB_ROOT/bin/Release/index.html\"; exit 1; }; if [ -f \"$PID_FILE\" ] && kill -0 \"$(cat \"$PID_FILE\")\" 2>/dev/null; then kill \"$(cat \"$PID_FILE\")\" >/dev/null 2>&1 || true; rm -f \"$PID_FILE\"; fi; nohup python3 -m http.server 8000 --bind 127.0.0.1 --directory \"$WEB_ROOT\" >\"$LOG_FILE\" 2>&1 & echo $! >\"$PID_FILE\"; echo \"Started web server on http://127.0.0.1:8000 (root: $WEB_ROOT)\"; READY=0; for _ in $(seq 1 40); do if command -v curl >/dev/null 2>&1; then curl -fsS \"$URL\" >/dev/null 2>&1 && READY=1 && break; elif command -v wget >/dev/null 2>&1; then wget -qO- \"$URL\" >/dev/null 2>&1 && READY=1 && break; fi; sleep 0.1; done; [ \"$READY\" = \"1\" ] || { echo \"Web server did not become ready. See /tmp/snivy-web-http.log\"; exit 1; }; (xdg-open \"$URL\" >/dev/null 2>&1 || chromium --new-tab \"$URL\" >/dev/null 2>&1 || chromium-browser --new-tab \"$URL\" >/dev/null 2>&1 || google-chrome --new-tab \"$URL\" >/dev/null 2>&1 || google-chrome-stable --new-tab \"$URL\" >/dev/null 2>&1 || python3 -m webbrowser \"$URL\" >/dev/null 2>&1 || { echo \"Could not launch browser automatically. Open: $URL\"; exit 0; }) & sleep 0.15; echo \"Requested browser open: $URL\"'" + }, + "windows": { + "command": "echo \"web tasks are configured for Linux (emsdk + python + chromium).\" && exit 1" + }, + "problemMatcher": [] + } + ] } diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a0cddd..56a5d21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,6 +127,11 @@ add_executable(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/include/glad/glad.cpp ) +target_compile_definitions(${PROJECT_NAME} PRIVATE + "$<$:DEBUG=1>" + "$<$>:DEBUG=0>" +) + set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/bin/Debug" @@ -186,13 +191,15 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten") endif() set(PROJECT_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources") -set(PROJECT_RESOURCES_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/resources") +set(PROJECT_RESOURCES_BINARY_DIR "$/resources") if(EXISTS "${PROJECT_RESOURCES_DIR}") file(GLOB_RECURSE PROJECT_RESOURCE_FILES CONFIGURE_DEPENDS "${PROJECT_RESOURCES_DIR}/*") add_custom_target(copy_resources ALL - COMMAND ${CMAKE_COMMAND} -E remove_directory "${PROJECT_RESOURCES_BINARY_DIR}" - COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_RESOURCES_DIR}" "${PROJECT_RESOURCES_BINARY_DIR}" + COMMAND ${CMAKE_COMMAND} + -DSRC_DIR="${PROJECT_RESOURCES_DIR}" + -DDST_DIR="${PROJECT_RESOURCES_BINARY_DIR}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/copy_resources.cmake" DEPENDS ${PROJECT_RESOURCE_FILES} COMMENT "Copying resources directory") add_dependencies(${PROJECT_NAME} copy_resources) @@ -207,6 +214,7 @@ if(HAS_PROJECT_RESOURCES) endif() if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") + set(EMSCRIPTEN_SHELL_FILE "${CMAKE_CURRENT_SOURCE_DIR}/web/index.html") target_link_options(${PROJECT_NAME} PRIVATE "-sMIN_WEBGL_VERSION=2" "-sMAX_WEBGL_VERSION=2" @@ -217,6 +225,8 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") "-sFORCE_FILESYSTEM=1" "-sASYNCIFY" "-lidbfs.js" + "--shell-file" + "${EMSCRIPTEN_SHELL_FILE}" ) if(HAS_PROJECT_RESOURCES) target_link_options(${PROJECT_NAME} PRIVATE diff --git a/CMakePresets.json b/CMakePresets.json index 099f24f..8a5ede6 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -39,14 +39,14 @@ } }, { - "name": "x64-Debug", - "displayName": "x64 Debug", + "name": "win32-debug", + "displayName": "Win32 Debug", "description": "Visual Studio 2022 x64 Debug", "generator": "Visual Studio 17 2022", "architecture": "x64", - "binaryDir": "${sourceDir}/out/build/x64-Debug", + "binaryDir": "${sourceDir}/out/build/win32-debug", "cacheVariables": { - "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/x64-Debug" + "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/win32-debug" }, "condition": { "type": "equals", @@ -55,14 +55,14 @@ } }, { - "name": "x64-Release", - "displayName": "x64 Release", + "name": "win32-release", + "displayName": "Win32 Release", "description": "Visual Studio 2022 x64 Release", "generator": "Visual Studio 17 2022", "architecture": "x64", - "binaryDir": "${sourceDir}/out/build/x64-Release", + "binaryDir": "${sourceDir}/out/build/win32-release", "cacheVariables": { - "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/x64-Release" + "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/win32-release" }, "condition": { "type": "equals", @@ -81,13 +81,13 @@ "configurePreset": "linux-release" }, { - "name": "x64-Debug", - "configurePreset": "x64-Debug", + "name": "win32-debug", + "configurePreset": "win32-debug", "configuration": "Debug" }, { - "name": "x64-Release", - "configurePreset": "x64-Release", + "name": "win32-release", + "configurePreset": "win32-release", "configuration": "Release" } ] diff --git a/CMakeSettings.json b/CMakeSettings.json index dcfcab7..a6cec76 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -1,28 +1,28 @@ { "configurations": [ - { - "name": "x64-Debug", - "generator": "Ninja", - "configurationType": "Debug", - "inheritEnvironments": [ - "msvc_x64_x64" - ], + { + "name": "win32-debug", + "generator": "Ninja", + "configurationType": "Debug", + "inheritEnvironments": [ + "msvc_x64_x64" + ], "buildRoot": "${projectDir}\\out\\build\\${name}", "cmakeCommandArgs": "", "buildCommandArgs": "", "ctestCommandArgs": "" }, - { - "name": "x64-Release", - "generator": "Ninja", - "configurationType": "Release", - "inheritEnvironments": [ - "msvc_x64_x64" - ], + { + "name": "win32-release", + "generator": "Ninja", + "configurationType": "Release", + "inheritEnvironments": [ + "msvc_x64_x64" + ], "buildRoot": "${projectDir}\\out\\build\\${name}", "cmakeCommandArgs": "", "buildCommandArgs": "", "ctestCommandArgs": "" } ] -} \ No newline at end of file +} diff --git a/README.md b/README.md index cca72c4..30b9af2 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This Is A Video Game Where You Feed The Snivy. -[Get Resources Here](https://shweetz.net/files/games/feed-snivy/resources.7z) +[Resources](https://shweetz.net/files/games/feed-snivy/resources.7z) ## Build @@ -16,10 +16,11 @@ After cloning and enter the repository's directory, make sure to initialize the Visual Studio is recommended for build. ### Linux - ``` mkdir build cd build cmake .. make -``` \ No newline at end of file +``` + +If using VSCode, several tasks are available to quickly run and build. \ No newline at end of file diff --git a/cmake/copy_resources.cmake b/cmake/copy_resources.cmake new file mode 100644 index 0000000..500e3b7 --- /dev/null +++ b/cmake/copy_resources.cmake @@ -0,0 +1,17 @@ +if(NOT DEFINED SRC_DIR OR NOT DEFINED DST_DIR) + message(FATAL_ERROR "SRC_DIR and DST_DIR must be defined") +endif() + +file(REMOVE_RECURSE "${DST_DIR}") +file(MAKE_DIRECTORY "${DST_DIR}") + +# Copy all resources except characters/ contents. +file(COPY "${SRC_DIR}/" DESTINATION "${DST_DIR}" + PATTERN "characters/*" EXCLUDE) + +# Copy only .zip archives from resources/characters. +file(MAKE_DIRECTORY "${DST_DIR}/characters") +file(GLOB CHARACTER_ZIPS "${SRC_DIR}/characters/*.zip") +if(CHARACTER_ZIPS) + file(COPY ${CHARACTER_ZIPS} DESTINATION "${DST_DIR}/characters") +endif() diff --git a/src/loader.cpp b/src/loader.cpp index 163ca5b..f226847 100644 --- a/src/loader.cpp +++ b/src/loader.cpp @@ -45,6 +45,7 @@ namespace game Loader::Loader(int argc, const char** argv) { + #ifdef __EMSCRIPTEN__ util::web_filesystem::init_and_wait(); #endif @@ -83,6 +84,7 @@ namespace game SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); #ifdef __EMSCRIPTEN__ + static constexpr glm::vec2 SIZE = {1600, 900}; window = SDL_CreateWindow("Snivy", SIZE.x, SIZE.y, SDL_WINDOW_OPENGL); #else diff --git a/src/loader.hpp b/src/loader.hpp index 912733d..e9eb869 100644 --- a/src/loader.hpp +++ b/src/loader.hpp @@ -9,8 +9,6 @@ namespace game class Loader { public: - static constexpr glm::vec2 SIZE = {1280, 720}; - SDL_Window* window{}; SDL_GLContext context{}; bool isError{}; diff --git a/src/resource/xml/settings.hpp b/src/resource/xml/settings.hpp index a064180..aa473a5 100644 --- a/src/resource/xml/settings.hpp +++ b/src/resource/xml/settings.hpp @@ -20,10 +20,10 @@ namespace game::resource::xml }; util::measurement::System measurementSystem{util::measurement::METRIC}; - int volume{VOLUME_MAX}; + int volume{50}; glm::vec3 color{0.120f, 0.515f, 0.115f}; - glm::ivec2 windowSize{1280, 720}; + glm::ivec2 windowSize{1600, 900}; glm::vec2 windowPosition{}; bool isValid{}; diff --git a/src/state.cpp b/src/state.cpp index c6b4dfc..b68c5d4 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -41,7 +41,9 @@ namespace game void State::update() { +#ifndef __EMSCRIPTEN__ SDL_GetWindowSize(window, &resources.settings.windowSize.x, &resources.settings.windowSize.y); +#endif SDL_Event event; @@ -92,8 +94,10 @@ namespace game void State::render() { - ivec2 windowSize{}; + auto windowSize = resources.settings.windowSize; +#ifndef __EMSCRIPTEN__ SDL_GetWindowSize(window, &windowSize.x, &windowSize.y); +#endif canvas.bind(); canvas.size_set(windowSize); diff --git a/src/state/main.cpp b/src/state/main.cpp index 7740a37..390031c 100644 --- a/src/state/main.cpp +++ b/src/state/main.cpp @@ -18,6 +18,8 @@ namespace game::state { World::Focus Main::focus_get() { + if (!isWindows) return World::CENTER; + return menu.isOpen && tools.isOpen ? World::MENU_TOOLS : menu.isOpen ? World::MENU : tools.isOpen ? World::TOOLS @@ -84,26 +86,28 @@ namespace game::state text.entry = nullptr; text.isEnabled = false; - if (auto font = character.data.menuSchema.font.get()) ImGui::GetIO().FontDefault = font; - - if (game == NEW_GAME && dialogue.start.is_valid()) - { - character.queue_play({.animation = dialogue.start.animation, .isInterruptible = false}); - character.tick(); - isWindows = false; - isStart = true; - } - isPostgame = saveData.isPostgame; if (isPostgame) menu.isCheats = true; else - menu.isCheats = true; //false; + menu.isCheats = false; + if (game == NEW_GAME) isWindows = false; + + if (auto font = character.data.menuSchema.font.get()) ImGui::GetIO().FontDefault = font; + + character.play_default_animation(); + character.tick(); worldCanvas.size_set(imgui::to_vec2(ImGui::GetMainViewport()->Size)); - world.set(character, worldCanvas, focus_get()); + + if (game == NEW_GAME && dialogue.start.is_valid()) + { + character.queue_play({.animation = dialogue.start.animation, .isInterruptible = false}); + character.tick(); + isStart = true; + } } void Main::exit(Resources& resources) diff --git a/src/state/main/menu.cpp b/src/state/main/menu.cpp index 267c671..d8041b9 100644 --- a/src/state/main/menu.cpp +++ b/src/state/main/menu.cpp @@ -91,11 +91,13 @@ namespace game::state::main ImGui::EndTabItem(); } - if (isDebug && WIDGET_FX(ImGui::BeginTabItem("Debug"))) +#if defined(DEBUG) && DEBUG + if (WIDGET_FX(ImGui::BeginTabItem("Debug"))) { debug.update(character, cursor, itemManager, canvas); ImGui::EndTabItem(); } +#endif } ImGui::EndTabBar(); } diff --git a/src/state/main/menu.hpp b/src/state/main/menu.hpp index 376f790..8cba07a 100644 --- a/src/state/main/menu.hpp +++ b/src/state/main/menu.hpp @@ -28,7 +28,6 @@ namespace game::state::main state::Configuration configuration; bool isCheats{true}; - bool isDebug{true}; bool isOpen{true}; bool isChat{true}; util::imgui::WindowSlide slide{}; diff --git a/src/state/main/world.cpp b/src/state/main/world.cpp index 69620cb..4ee0158 100644 --- a/src/state/main/world.cpp +++ b/src/state/main/world.cpp @@ -13,7 +13,6 @@ namespace game::state::main void World::set(entity::Character& character, Canvas& canvas, Focus focus) { character.stage = character.stage_get(); - character.queue_idle_animation(); character_focus(character, canvas, focus); } diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..7f16d22 --- /dev/null +++ b/web/index.html @@ -0,0 +1,43 @@ + + + + + + snivy + + + + + + {{{ SCRIPT }}} + +