diff options
| author | V10lator <v10lator@myway.de> | 2025-07-13 21:26:50 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-13 13:26:50 -0600 |
| commit | 4c6e68aa8ad900000e5103dcb8c8144ecd4ac163 (patch) | |
| tree | 846691aa85622f954acb8df2bac4b97d9267ebf5 | |
| parent | 77a9408817886fe3da042afbe1e4ac2a5c4d3923 (diff) | |
Add version and debug state (#437)
* cmake: Correctly set PROJECT_VERSION
This needs CI to adjust
Signed-off-by: Thomas Rohloff <v10lator@myway.de>
* Log version
Signed-off-by: Thomas Rohloff <v10lator@myway.de>
* Show version and debug state
Signed-off-by: Thomas Rohloff <v10lator@myway.de>
* Log debug mode toggling
Signed-off-by: Thomas Rohloff <v10lator@myway.de>
* Finish version string
Signed-off-by: Thomas Rohloff <v10lator@myway.de>
* Update CMakeLists.txt
* Update CMakeLists.txt
* Try to fix execute_process() from within CI
Signed-off-by: Thomas Rohloff <v10lator@myway.de>
* CI: Checkout with tags
Signed-off-by: Thomas Rohloff <v10lator@myway.de>
* Fix PR CIs, too
Signed-off-by: Thomas Rohloff <v10lator@myway.de>
* Add config button for version
Signed-off-by: Thomas Rohloff <v10lator@myway.de>
---------
Signed-off-by: Thomas Rohloff <v10lator@myway.de>
Co-authored-by: MegaMech <MegaMech@users.noreply.github.com>
| -rw-r--r-- | .github/workflows/linux-compile.yml | 2 | ||||
| -rw-r--r-- | .github/workflows/macos-compile.yml | 2 | ||||
| -rw-r--r-- | .github/workflows/main.yml | 13 | ||||
| -rw-r--r-- | .github/workflows/windows-compile.yml | 4 | ||||
| -rw-r--r-- | CMakeLists.txt | 22 | ||||
| -rw-r--r-- | src/menu_items.c | 22 | ||||
| -rw-r--r-- | src/port/Engine.cpp | 3 | ||||
| -rw-r--r-- | src/port/ui/PortMenu.cpp | 7 |
8 files changed, 69 insertions, 6 deletions
diff --git a/.github/workflows/linux-compile.yml b/.github/workflows/linux-compile.yml index 458f500d6..fb5019d94 100644 --- a/.github/workflows/linux-compile.yml +++ b/.github/workflows/linux-compile.yml @@ -10,6 +10,8 @@ jobs: steps: - uses: actions/checkout@v4 with: + fetch-depth: 0 + fetch-tags: true submodules: recursive - name: Update machine run: sudo apt update diff --git a/.github/workflows/macos-compile.yml b/.github/workflows/macos-compile.yml index 0e4391b9d..870579d6a 100644 --- a/.github/workflows/macos-compile.yml +++ b/.github/workflows/macos-compile.yml @@ -10,6 +10,8 @@ jobs: steps: - uses: actions/checkout@v4 with: + fetch-depth: 0 + fetch-tags: true submodules: recursive - name: Install dependencies run: brew install ninja cmake diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 79be5c107..4e3462345 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -50,6 +50,8 @@ jobs: steps: - uses: actions/checkout@v4 with: + fetch-depth: 0 + fetch-tags: true submodules: recursive - name: Build run: | @@ -80,6 +82,8 @@ jobs: steps: - uses: actions/checkout@v4 with: + fetch-depth: 0 + fetch-tags: true submodules: recursive - name: Install dependencies run: brew install ninja cmake @@ -116,6 +120,8 @@ jobs: steps: - uses: actions/checkout@v4 with: + fetch-depth: 0 + fetch-tags: true submodules: recursive - name: Update machine run: sudo apt update @@ -205,6 +211,8 @@ jobs: steps: - uses: actions/checkout@v4 with: + fetch-depth: 0 + fetch-tags: true submodules: recursive - name: Update machine run: sudo apt update @@ -306,8 +314,9 @@ jobs: steps: - uses: actions/checkout@v4 with: - submodules: recursive fetch-depth: 0 + fetch-tags: true + submodules: recursive - name: Docker caching uses: ScribeMD/docker-cache@0.5.0 id: cache @@ -330,6 +339,8 @@ jobs: steps: - uses: actions/checkout@v4 with: + fetch-depth: 0 + fetch-tags: true submodules: recursive - name: Install dependencies run: | diff --git a/.github/workflows/windows-compile.yml b/.github/workflows/windows-compile.yml index 56ce1d294..bbaee328b 100644 --- a/.github/workflows/windows-compile.yml +++ b/.github/workflows/windows-compile.yml @@ -10,6 +10,8 @@ jobs: steps: - uses: actions/checkout@v4 with: + fetch-depth: 0 + fetch-tags: true submodules: recursive - name: Build run: | @@ -20,4 +22,4 @@ jobs: with: name: spaghetti-windows path: ./build/x64/Debug - retention-days: 1
\ No newline at end of file + retention-days: 1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 2da9881fb..2c62337c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,22 @@ set(NATO_PHONETIC_ALPHABET "Xray" "Yankee" "Zulu" ) +execute_process( + COMMAND git describe --tags + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE PROJECT_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE +) +string(REPLACE "-" ";" PROJECT_VERSION_LIST "${PROJECT_VERSION}") +list(GET PROJECT_VERSION_LIST 0 PROJECT_VERSION_PATCH) +string(REPLACE "." ";" PROJECT_VERSION_LIST "${PROJECT_VERSION_PATCH}") +list(LENGTH PROJECT_VERSION_LIST PROJECT_VERSION_LIST_LENGTH) +if (${PROJECT_VERSION_LIST_LENGTH} LESS 3) + set(PROJECT_VERSION_PATCH 0) +else() + list(GET PROJECT_VERSION_LIST 2 PROJECT_VERSION_PATCH) +endif() + # Get the patch version number from the project version math(EXPR PATCH_INDEX "${PROJECT_VERSION_PATCH}") @@ -35,9 +51,6 @@ set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use") set(CMAKE_C_STANDARD 11 CACHE STRING "The C standard to use") set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Spaghettify) set(PROJECT_TEAM "MegaMech") -set(PROJECT_VERSION_MAJOR 1) -set(PROJECT_VERSION_MINOR 0) -set(PROJECT_VERSION_PATCH 0) #add_compile_options(-fsanitize=address) #add_link_options(-fsanitize=address) @@ -125,6 +138,7 @@ add_compile_definitions( NON_MATCHING=1 NON_EQUIVALENT=1 AVOID_UB=1 + SPAGHETTI_VERSION="${PROJECT_VERSION}" ) # Find necessary libraries @@ -453,7 +467,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "NintendoSwitch") nx_generate_nacp(${PROJECT_NAME}.nacp NAME "${PROJECT_NAME}" AUTHOR "${PROJECT_TEAM}" - VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}" + VERSION "${PROJECT_VERSION}" ) nx_create_nro(${PROJECT_NAME} diff --git a/src/menu_items.c b/src/menu_items.c index a1213c9d0..78b7476bf 100644 --- a/src/menu_items.c +++ b/src/menu_items.c @@ -6366,6 +6366,24 @@ void add_menu_item(s32 type, s32 column, s32 row, s8 priority) { GLOBAL_ASM("asm/non_matchings/menu_items/add_menu_item.s") #endif +static void draw_debug(void) { + if (CVarGetInteger("gEnableDebugMode", 0) != 0) { + set_text_color(TEXT_RED); + print_text1_right(0x138, 0xEA, "DEBUG", 0, 0.5f, 0.5f); + } +} + +static void draw_version(void) { + s32 column = 0x138; + + if (CVarGetInteger("gEnableDebugMode", 0) != 0) { + column -= (s32) ((f32) (get_string_width("DEBUG") + 5 )) * 0.5f; + } + + set_text_color(TEXT_GREEN); + print_text1_right(column, 0xEA, SPAGHETTI_VERSION, 0, 0.5f, 0.5f); +} + #ifdef NON_MATCHING // https://decomp.me/scratch/MatRp // Biggest diff left is in the case 0x12 though 0x19 handling. Not really sure what's going on there @@ -6508,6 +6526,10 @@ void render_menus(MenuItem* arg0) { case MENU_ITEM_UI_GAME_SELECT: gDisplayListHead = render_menu_textures(gDisplayListHead, seg2_game_select_texture, arg0->column, arg0->row); + if (CVarGetInteger("gShowSpaghettiVersion", true)) { + draw_version(); + draw_debug(); + } break; case MENU_ITEM_UI_1P_GAME: case MENU_ITEM_UI_2P_GAME: diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index c93131bc8..93c67487c 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -199,6 +199,9 @@ GameEngine::GameEngine() { Ship::Context::GetInstance()->GetLogger()->set_pattern("[%H:%M:%S.%e] [%s:%#] [%l] %v"); #endif + SPDLOG_INFO("Spaghetti Kart " SPAGHETTI_VERSION); + SPDLOG_INFO(CVarGetInteger("gEnableDebugMode", 0) == 0 ? "Debug Mode deactivated" : "Debug Mode activated"); + wnd->SetRendererUCode(ucode_f3dex); this->context->InitGfxDebugger(); diff --git a/src/port/ui/PortMenu.cpp b/src/port/ui/PortMenu.cpp index e6a1c9ac6..740c60531 100644 --- a/src/port/ui/PortMenu.cpp +++ b/src/port/ui/PortMenu.cpp @@ -379,6 +379,10 @@ void PortMenu::AddEnhancements() { AddWidget(path, "Harder CPU", WIDGET_CVAR_CHECKBOX).CVar("gHarderCPU"); + AddWidget(path, "Show Spaghetti version", WIDGET_CVAR_CHECKBOX) + .CVar("gShowSpaghettiVersion") + .Options(CheckboxOptions().Tooltip("Show the Spaghetti Kart version on the Mario Kart menu").DefaultValue(true)); + path = { "Enhancements", "Cheats", SECTION_COLUMN_1 }; AddSidebarEntry("Enhancements", "Cheats", 3); AddWidget(path, "Moon Jump", WIDGET_CVAR_CHECKBOX).CVar("gEnableMoonJump"); @@ -438,6 +442,9 @@ void PortMenu::AddDevTools() { .Options(CheckboxOptions().Tooltip("Changes the menu display from overlay to windowed.")); AddWidget(path, "Debug Mode", WIDGET_CVAR_CHECKBOX) .CVar("gEnableDebugMode") + .Callback([](WidgetInfo& info) { + SPDLOG_INFO(CVarGetInteger("gEnableDebugMode", 0) == 0 ? "Debug Mode deactivated" : "Debug Mode activated"); + }) .Options(CheckboxOptions().Tooltip("Enables Debug Mode.")); AddWidget(path, "Modify Interpolation Target FPS", WIDGET_CVAR_CHECKBOX) .CVar("gModifyInterpolationTargetFPS") |
