Skip to content

Commit

Permalink
Show version in title screen in non-release builds
Browse files Browse the repository at this point in the history
  • Loading branch information
parasti committed May 12, 2024
1 parent 4fec1db commit b11285e
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 17 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ ifeq ($(ENABLE_RADIANT_CONSOLE),1)
ALL_CPPFLAGS += -DENABLE_RADIANT_CONSOLE=1
endif

ifneq ($(BUILD),release)
ALL_CPPFLAGS += -DENABLE_VERSION=1
endif

# Enable libcurl by default, disable w/ ENABLE_FETCH=0.
ENABLE_FETCH := curl

Expand Down
8 changes: 8 additions & 0 deletions ball/st_title.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "config.h"
#include "cmd.h"
#include "demo_dir.h"
#include "version.h"

#include "game_common.h"
#include "game_server.h"
Expand Down Expand Up @@ -202,6 +203,13 @@ static int title_gui(void)
gui_layout(id, 0, 0);
}

#if ENABLE_VERSION
if ((id = gui_label(root_id, "Neverball " VERSION, GUI_TNY, gui_wht2, gui_wht2)))
{
gui_clr_rect(id);
gui_layout(id, -1, -1);
}
#endif

#if ENABLE_FETCH
if ((id = gui_vstack(root_id)))
Expand Down
39 changes: 26 additions & 13 deletions putt/st_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "course.h"
#include "config.h"
#include "video.h"
#include "version.h"

#include "st_all.h"
#include "st_conf.h"
Expand Down Expand Up @@ -212,34 +213,46 @@ static int title_action(int i)
static int title_enter(struct state *st, struct state *prev)
{
int id, jd, kd;
int root_id;

/* Build the title GUI. */

if ((id = gui_vstack(0)))
if ((root_id = gui_root()))
{
gui_label(id, "Neverputt", GUI_LRG, 0, 0);
gui_space(id);

if ((jd = gui_harray(id)))
if ((id = gui_vstack(root_id)))
{
gui_filler(jd);
gui_label(id, "Neverputt", GUI_LRG, 0, 0);
gui_space(id);

if ((kd = gui_varray(jd)))
if ((jd = gui_harray(id)))
{
gui_start(kd, gt_prefix("menu^Play"), GUI_MED, TITLE_PLAY, 1);
gui_state(kd, gt_prefix("menu^Options"), GUI_MED, TITLE_CONF, 0);
gui_state(kd, gt_prefix("menu^Exit"), GUI_MED, TITLE_EXIT, 0);
gui_filler(jd);

if ((kd = gui_varray(jd)))
{
gui_start(kd, gt_prefix("menu^Play"), GUI_MED, TITLE_PLAY, 1);
gui_state(kd, gt_prefix("menu^Options"), GUI_MED, TITLE_CONF, 0);
gui_state(kd, gt_prefix("menu^Exit"), GUI_MED, TITLE_EXIT, 0);
}

gui_filler(jd);
}
gui_layout(id, 0, 0);
}

gui_filler(jd);
#if ENABLE_VERSION
if ((id = gui_label(root_id, "Neverputt " VERSION, GUI_TNY, gui_wht2, gui_wht2)))
{
gui_clr_rect(id);
gui_layout(id, -1, -1);
}
gui_layout(id, 0, 0);
#endif
}

course_init();
course_rand();

return id;
return root_id;
}

static void title_leave(struct state *st, struct state *next, int id)
Expand Down
17 changes: 13 additions & 4 deletions share/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const GLubyte gui_blk[4] = { 0x00, 0x00, 0x00, 0xFF }; /* Black */
const GLubyte gui_gry[4] = { 0x55, 0x55, 0x55, 0xFF }; /* Gray */
const GLubyte gui_shd[4] = { 0x00, 0x00, 0x00, 0x80 }; /* Shadow */

const GLubyte gui_wht2[4] = { 0xFF, 0xFF, 0xFF, 0x60 }; /* Transparent white */

/*---------------------------------------------------------------------------*/

#define WIDGET_MAX 256
Expand Down Expand Up @@ -321,12 +323,19 @@ static void gui_geom_text(int id, int x, int y, int w, int h,
const GLfloat s1 = 1.0f - s0;
const GLfloat t1 = 1.0f - t0;

GLubyte color[4];

color[0] = gui_shd[0];
color[1] = gui_shd[1];
color[2] = gui_shd[2];
color[3] = c0[3] < 0xFF ? (GLubyte) (c0[3] * 0.5f) : gui_shd[3];

/* Generate vertex data for the colored text and its shadow. */

set_vert(v + 0, x + d, y + hh - d, s0, t0, gui_shd);
set_vert(v + 1, x + d, y - d, s0, t1, gui_shd);
set_vert(v + 2, x + ww + d, y + hh - d, s1, t0, gui_shd);
set_vert(v + 3, x + ww + d, y - d, s1, t1, gui_shd);
set_vert(v + 0, x + d, y + hh - d, s0, t0, color);
set_vert(v + 1, x + d, y - d, s0, t1, color);
set_vert(v + 2, x + ww + d, y + hh - d, s1, t0, color);
set_vert(v + 3, x + ww + d, y - d, s1, t1, color);

set_vert(v + 4, x, y + hh, s0, t0, c1);
set_vert(v + 5, x, y, s0, t1, c0);
Expand Down
2 changes: 2 additions & 0 deletions share/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ extern const GLubyte gui_grn[4];
extern const GLubyte gui_blk[4];
extern const GLubyte gui_gry[4];

extern const GLubyte gui_wht2[4];

enum trunc
{
TRUNC_NONE,
Expand Down

0 comments on commit b11285e

Please sign in to comment.