diff --git a/Makefile b/Makefile index fb8e669..704c4f6 100644 --- a/Makefile +++ b/Makefile @@ -19,8 +19,11 @@ $(SKELATOOL64): @$(MAKE) -C skelatool64 +# Use tag name if a tag exists, otherwise use commit hash +GAME_VERSION := $(shell git describe --tags --exact-match HEAD 2>/dev/null || git rev-parse --short HEAD) + OPTIMIZER := -Os -LCDEFS := -DDEBUG -g -Werror -Wall +LCDEFS := -DDEBUG -DGAME_VERSION=\"$(GAME_VERSION)\" -g -Werror -Wall N64LIB := -lultra_rom ifeq ($(PORTAL64_WITH_DEBUGGER),1) @@ -134,6 +137,14 @@ spanish_audio: vpk/portal_sound_vo_spanish_dir.vpk vpk/portal_sound_vo_spanish_0 buildgame: $(BASE_TARGET_NAME).z64 +# Allow targets to depend on the GAME_VERSION variable via a file. +# Update the file only when it differs from the variable (triggers rebuild). +.PHONY: gameversion +build/version.txt: gameversion +ifneq ($(shell cat build/version.txt 2>/dev/null), $(GAME_VERSION)) + echo -n $(GAME_VERSION) > build/version.txt +endif + include $(COMMONRULES) .s.o: @@ -363,7 +374,7 @@ build/src/menu/controls.o: build/assets/materials/ui.h build/src/audio/clips.h b build/src/menu/game_menu.o: build/src/audio/clips.h build/assets/materials/ui.h build/assets/materials/images.h build/assets/test_chambers/test_chamber_00/test_chamber_00.h build/src/menu/gameplay_options.o: build/assets/materials/ui.h build/src/audio/clips.h build/src/menu/joystick_options.o: build/assets/materials/ui.h build/src/audio/clips.h -build/src/menu/landing_menu.o: build/assets/materials/ui.h build/src/audio/clips.h +build/src/menu/landing_menu.o: build/assets/materials/ui.h build/src/audio/clips.h build/version.txt build/src/menu/load_game.o: build/assets/materials/ui.h build/src/audio/clips.h build/src/audio/subtitles.h build/src/menu/main_menu.o: build/src/audio/clips.h build/assets/materials/ui.h build/assets/materials/images.h build/assets/test_chambers/test_chamber_00/test_chamber_00.h build/src/menu/new_game_menu.o: build/src/audio/clips.h build/assets/materials/ui.h build/assets/materials/images.h build/src/audio/subtitles.h build/assets/test_chambers/test_chamber_00/test_chamber_00.h diff --git a/src/menu/landing_menu.c b/src/menu/landing_menu.c index d703e7e..d3c39eb 100644 --- a/src/menu/landing_menu.c +++ b/src/menu/landing_menu.c @@ -11,19 +11,21 @@ #include "cheat_codes.h" #include "./translations.h" -#define PORTAL_LOGO_X 30 -#define PORTAL_LOGO_Y 74 +#define PORTAL_LOGO_X 30 +#define PORTAL_LOGO_Y 74 -#define PORTAL_LOGO_WIDTH 128 -#define PORTAL_LOGO_P_WIDTH 15 -#define PORTAL_LOGO_O_WIDTH 30 -#define PORTAL_LOGO_HEIGHT 47 +#define PORTAL_LOGO_WIDTH 128 +#define PORTAL_LOGO_P_WIDTH 15 +#define PORTAL_LOGO_O_WIDTH 30 +#define PORTAL_LOGO_HEIGHT 47 -#define LANDING_MENU_TEXT_START_X 30 -#define LANDING_MENU_TEXT_START_Y 132 -#define STRIDE_OPTION_1 12 -#define STRIDE_OPTION_2 16 -#define PACKED_MENU_THRESHOLD 4 +#define LANDING_MENU_TEXT_START_X 30 +#define LANDING_MENU_TEXT_START_Y 132 +#define STRIDE_OPTION_1 12 +#define STRIDE_OPTION_2 16 +#define PACKED_MENU_THRESHOLD 4 + +#define LANDING_MENU_VERSION_END_Y 20 Gfx portal_logo_gfx[] = { gsSPTextureRectangle( @@ -72,11 +74,19 @@ void landingMenuInitText(struct LandingMenu* landingMenu) { SCREEN_WD); y += stride; } + + landingMenu->versionText = menuBuildPrerenderedText(&gDejaVuSansFont, GAME_VERSION, 0, 0, SCREEN_WD); + prerenderedTextRelocate( + landingMenu->versionText, + SCREEN_WD - LANDING_MENU_TEXT_START_X - landingMenu->versionText->width, + SCREEN_HT - LANDING_MENU_VERSION_END_Y - landingMenu->versionText->height + ); } void landingMenuInit(struct LandingMenu* landingMenu, struct LandingMenuOption* options, int optionCount, int darkenBackground) { landingMenu->optionText = malloc(sizeof(struct PrerenderedText*) * optionCount); landingMenu->options = options; + landingMenu->versionText = NULL; landingMenu->selectedItem = 0; landingMenu->optionCount = optionCount; landingMenu->darkenBackground = darkenBackground; @@ -87,6 +97,8 @@ void landingMenuRebuildText(struct LandingMenu* landingMenu) { for (int i = 0; i < landingMenu->optionCount; ++i) { prerenderedTextFree(landingMenu->optionText[i]); } + prerenderedTextFree(landingMenu->versionText); + landingMenuInitText(landingMenu); } @@ -169,6 +181,8 @@ void landingMenuRender(struct LandingMenu* landingMenu, struct RenderState* rend for (int i = 0; i < landingMenu->optionCount; ++i) { prerenderedBatchAdd(batch, landingMenu->optionText[i], &gColorWhite); } + prerenderedBatchAdd(batch, landingMenu->versionText, &gHalfTransparentWhite); + renderState->dl = prerenderedBatchFinish(batch, gDejaVuSansImages, renderState->dl); gSPDisplayList(renderState->dl++, ui_material_revert_list[DEJAVU_SANS_0_INDEX]); } diff --git a/src/menu/landing_menu.h b/src/menu/landing_menu.h index 392e799..10b8658 100644 --- a/src/menu/landing_menu.h +++ b/src/menu/landing_menu.h @@ -13,6 +13,7 @@ struct LandingMenuOption { struct LandingMenu { struct LandingMenuOption* options; struct PrerenderedText** optionText; + struct PrerenderedText* versionText; short selectedItem; short optionCount; short darkenBackground;