Skip to content

Commit

Permalink
UI: Smaller tooltips #312
Browse files Browse the repository at this point in the history
  • Loading branch information
mgerhardy committed Nov 2, 2024
1 parent d0afd1d commit 235fff4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions code/qcommon/q_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ typedef enum {
#define PROP_GAP_WIDTH 2
#define PROP_SPACE_WIDTH 8
#define PROP_HEIGHT 27
#define PROP_TINY_SIZE_SCALE 0.6
#define PROP_SMALL_SIZE_SCALE 0.75

#define BLINK_DIVISOR 200
Expand All @@ -333,6 +334,7 @@ typedef enum {
#define UI_CENTER 0x00000001
#define UI_RIGHT 0x00000002
#define UI_FORMATMASK 0x00000007
#define UI_TINYFONT 0x00000008
#define UI_SMALLFONT 0x00000010
#define UI_BIGFONT 0x00000020 // default
#define UI_GIANTFONT 0x00000040
Expand Down
11 changes: 10 additions & 1 deletion code/ui/ui_atoms.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ float UI_ProportionalSizeScale(int style) {
if (style & UI_SMALLFONT) {
return PROP_SMALL_SIZE_SCALE;
}
if (style & UI_TINYFONT) {
return PROP_SMALL_SIZE_SCALE;
}

return 1.0f;
}
Expand Down Expand Up @@ -484,6 +487,9 @@ static int CharWidthForStringStyle(int style) {
else if (style & UI_GIANTFONT)
return GIANTCHAR_WIDTH;

else if (style & UI_TINYFONT)
return TINYCHAR_WIDTH;

return BIGCHAR_WIDTH;
}

Expand All @@ -494,6 +500,9 @@ static int CharHeightForStringStyle(int style) {
else if (style & UI_GIANTFONT)
return GIANTCHAR_HEIGHT;

else if (style & UI_TINYFONT)
return TINYCHAR_HEIGHT;

return BIGCHAR_HEIGHT;
}

Expand Down Expand Up @@ -991,7 +1000,7 @@ void UI_MouseEvent(int dx, int dy) {
trap_S_StartLocalSound(sfx, CHAN_LOCAL_SOUND);
} else {
trap_S_StartLocalSound(menuMoveSound, CHAN_LOCAL_SOUND);
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion code/ui/ui_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "../client/keycodes.h"
#include "../game/bg_public.h"

// For only widescreen menu SCREEN_* must be seprate values for UI, CGame, and Client.
// For only widescreen menu SCREEN_* must be separate values for UI, CGame, and Client.
#undef SCREEN_WIDTH
#undef SCREEN_HEIGHT
#define SCREEN_WIDTH 864
Expand Down
6 changes: 3 additions & 3 deletions code/ui/ui_qmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1431,10 +1431,10 @@ static void Menu_AdjustCursor(menuframework_s *m, int dir) {
}

static void UI_DrawToolTip(const menucommon_s *focusItem) {
static const int textStyleFlags = UI_SMALLFONT;
static const int textStyleFlags = UI_TINYFONT;
static const int maxTextWidth = 250;
static const int boxMargin = 5;
static const int lineHeight = 20;
static const int lineHeight = TINYCHAR_HEIGHT;
static const int outerMargin = 10;
int numLines;
int boxWidth, boxHeight;
Expand Down Expand Up @@ -1476,7 +1476,7 @@ static void UI_DrawToolTip(const menucommon_s *focusItem) {
textY = boxY + boxMargin;

UI_FillRect(boxX, boxY, boxWidth, boxHeight, color_orange);
UI_DrawString_AutoWrapped(textX, textY, maxTextWidth, 20, focusItem->toolTip, textStyleFlags, menu_text_color,
UI_DrawString_AutoWrapped(textX, textY, maxTextWidth, lineHeight, focusItem->toolTip, textStyleFlags, menu_text_color,
qfalse);
UI_DrawRect(boxX, boxY, boxWidth, boxHeight, colorYellow, 2);

Expand Down

0 comments on commit 235fff4

Please sign in to comment.