Skip to content

Commit

Permalink
PlayStation styled inventory text box implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Arsunt committed Sep 25, 2018
1 parent 8d10d45 commit 8a2b210
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 1 deletion.
12 changes: 12 additions & 0 deletions game/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include "specific/output.h"
#include "global/vars.h"

#ifdef FEATURE_HUD_IMPROVED
extern DWORD InvTextBoxMode;
#endif // FEATURE_HUD_IMPROVED

static const BYTE T_TextSpacing[0x6E] = {
// A B C D E F G H
14, 11, 11, 11, 11, 11, 11, 13,
Expand Down Expand Up @@ -487,7 +491,15 @@ void __cdecl T_DrawThisText(TEXT_STR_INFO *textInfo) {

// Draw outline
if( CHK_ANY(textInfo->flags, TIF_Outline) ) {
#ifdef FEATURE_HUD_IMPROVED
if( InvTextBoxMode ) {
S_DrawScreenBox(boxX, boxY, boxZ, boxW, boxH, textInfo->outlColour, textInfo->outlGour, textInfo->outlFlags);
} else {
T_DrawTextBox(boxX, boxY, z, boxW, boxH);
}
#else // !FEATURE_HUD_IMPROVED
T_DrawTextBox(boxX, boxY, z, boxW, boxH);
#endif // FEATURE_HUD_IMPROVED
}
}
}
Expand Down
91 changes: 90 additions & 1 deletion specific/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
#include "specific/utils.h"
#include "global/vars.h"

#ifdef FEATURE_HUD_IMPROVED
#include "3dsystem/3dinsert.h"

DWORD InvTextBoxMode = 0;
#endif // FEATURE_HUD_IMPROVED

static void FadeWait() {
// Null function
}
Expand All @@ -42,6 +48,59 @@ void __cdecl S_DrawScreenLine(int x, int y, int z, int xLen, int yLen, BYTE colo
}

void __cdecl S_DrawScreenBox(int sx, int sy, int z, int width, int height, BYTE colorIdx, GOURAUD_OUTLINE *gour, UINT16 flags) {
int adder;
#ifdef FEATURE_HUD_IMPROVED
adder = GetRenderScale(2);
#else // !FEATURE_HUD_IMPROVED
// NOTE: in the original code there was no adder at all for this function
adder = 2;
#endif // FEATURE_HUD_IMPROVED
width += adder;
height += adder;

#ifdef FEATURE_HUD_IMPROVED
if( InvTextBoxMode && gour != NULL ) {
int x[3], y[3], lw;
int sz = PhdNearZ + z * 8;

lw = GetRenderScale(1);
x[0] = sx;
y[0] = sy;
x[2] = sx + width;
y[2] = sy + height;
x[1] = (x[0] + x[2]) / 2;
y[1] = (y[0] + y[2]) / 2;

InsertGourQuad(x[0]-lw, y[0]-lw, x[1], y[0], sz,
gour->clr[0], gour->clr[1],
gour->clr[1], gour->clr[0]);
InsertGourQuad(x[1], y[0]-lw, x[2], y[0], sz,
gour->clr[1], gour->clr[2],
gour->clr[2], gour->clr[1]);

InsertGourQuad(x[2], y[0]-lw, x[2]+lw, y[1], sz,
gour->clr[2], gour->clr[2],
gour->clr[3], gour->clr[3]);
InsertGourQuad(x[2], y[1], x[2]+lw, y[2], sz,
gour->clr[3], gour->clr[3],
gour->clr[4], gour->clr[4]);

InsertGourQuad(x[1], y[2], x[2]+lw, y[2]+lw, sz,
gour->clr[5], gour->clr[4],
gour->clr[4], gour->clr[5]);
InsertGourQuad(x[0], y[2], x[1], y[2]+lw, sz,
gour->clr[6], gour->clr[5],
gour->clr[5], gour->clr[6]);

InsertGourQuad(x[0]-lw, y[1], x[0], y[2]+lw, sz,
gour->clr[7], gour->clr[7],
gour->clr[6], gour->clr[6]);
InsertGourQuad(x[0]-lw, y[0], x[0], y[1], sz,
gour->clr[8], gour->clr[8],
gour->clr[7], gour->clr[7]);
return;
}
#endif // FEATURE_HUD_IMPROVED
const BYTE colorIdx1 = 15;
const BYTE colorIdx2 = 31;
int sx1 = sx + width;
Expand All @@ -67,14 +126,44 @@ void __cdecl S_DrawScreenBox(int sx, int sy, int z, int width, int height, BYTE

void __cdecl S_DrawScreenFBox(int sx, int sy, int z, int width, int height, BYTE colorIdx, GOURAUD_FILL *gour, UINT16 flags) {
int adder;
int sz = PhdNearZ + z * 8;
#ifdef FEATURE_HUD_IMPROVED
adder = GetRenderScale(2);
#else // !FEATURE_HUD_IMPROVED
// NOTE: in the original code the adder was 1, but 1 is insufficient,
// because there was visible gap between FBox and bottom/right Frame
adder = 2;
#endif // FEATURE_HUD_IMPROVED
ins_trans_quad(sx, sy, width + adder, height + adder, PhdNearZ + z * 8);
width += adder;
height += adder;

#ifdef FEATURE_HUD_IMPROVED
if( InvTextBoxMode && gour != NULL ) {
int x[3], y[3];

x[0] = sx;
y[0] = sy;
x[2] = sx + width;
y[2] = sy + height;
x[1] = (x[0] + x[2]) / 2;
y[1] = (y[0] + y[2]) / 2;

InsertGourQuad(x[0], y[0], x[1], y[1], sz,
gour->clr[0][0], gour->clr[0][1],
gour->clr[0][2], gour->clr[0][3]);
InsertGourQuad(x[1], y[0], x[2], y[1], sz,
gour->clr[1][0], gour->clr[1][1],
gour->clr[1][2], gour->clr[1][3]);
InsertGourQuad(x[1], y[1], x[2], y[2], sz,
gour->clr[2][0], gour->clr[2][1],
gour->clr[2][2], gour->clr[2][3]);
InsertGourQuad(x[0], y[1], x[1], y[2], sz,
gour->clr[3][0], gour->clr[3][1],
gour->clr[3][2], gour->clr[3][3]);
return;
}
#endif // FEATURE_HUD_IMPROVED
ins_trans_quad(sx, sy, width, height, sz);
}

void __cdecl S_FinishInventory() {
Expand Down
1 change: 1 addition & 0 deletions specific/registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#define REG_INVBGND_MODE "InvBackgroundMode"
#define REG_PICTURE_STRETCH "PictureStretchLimit"
#define REG_SHADOW_MODE "ShadowMode"
#define REG_INVTEXTBOX_MODE "InvTextBoxMode"
#define REG_HEALTHBAR_MODE "HealthBarMode"
#define REG_SCREENSHOT_FORMAT "ScreenshotFormat"

Expand Down
2 changes: 2 additions & 0 deletions specific/smain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "global/vars.h"

#ifdef FEATURE_HUD_IMPROVED
extern DWORD InvTextBoxMode;
extern DWORD HealthBarMode;
extern bool PsxBarPosEnabled;
extern double GameGUI_Scale;
Expand Down Expand Up @@ -439,6 +440,7 @@ void __cdecl S_LoadSettings() {
GetRegistryBinaryValue(REG_GAME_LAYOUT, (LPBYTE)Layout[CTRL_Custom].key, sizeof(UINT16)*14, NULL);

#ifdef FEATURE_HUD_IMPROVED
GetRegistryDwordValue(REG_INVTEXTBOX_MODE, &InvTextBoxMode, 0);
GetRegistryDwordValue(REG_HEALTHBAR_MODE, &HealthBarMode, 0);
GetRegistryBoolValue(REG_PSXBARPOS_ENABLE, &PsxBarPosEnabled, false);
GetRegistryFloatValue(REG_GAME_GUI_SCALE, &GameGUI_Scale, 1.0);
Expand Down

0 comments on commit 8a2b210

Please sign in to comment.