mirror of
https://github.com/mwpenny/portal64-still-alive.git
synced 2024-10-19 22:27:36 -04:00
Add version text to landing menus
If the current commit has a tag, the tag name is used as the version. Otherwise, the short hash of the current commit is used.
This commit is contained in:
parent
da028cd405
commit
429dc0bd91
15
Makefile
15
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
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#define STRIDE_OPTION_2 16
|
||||
#define PACKED_MENU_THRESHOLD 4
|
||||
|
||||
#define LANDING_MENU_VERSION_END_Y 20
|
||||
|
||||
Gfx portal_logo_gfx[] = {
|
||||
gsSPTextureRectangle(
|
||||
PORTAL_LOGO_X << 2,
|
||||
|
@ -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]);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ struct LandingMenuOption {
|
|||
struct LandingMenu {
|
||||
struct LandingMenuOption* options;
|
||||
struct PrerenderedText** optionText;
|
||||
struct PrerenderedText* versionText;
|
||||
short selectedItem;
|
||||
short optionCount;
|
||||
short darkenBackground;
|
||||
|
|
Loading…
Reference in a new issue