Skip to content

Commit

Permalink
Added IFACE_BAR_MODE configuration option from HRP
Browse files Browse the repository at this point in the history
  • Loading branch information
JanSimek committed May 21, 2022
1 parent 98c6acb commit 4f69eec
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/combat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5266,7 +5266,7 @@ int calledShotSelectHitLocation(Object* critter, int* hitLocation, int hitMode)
int calledShotWindowX = (screenGetWidth() - CALLED_SHOT_WINDOW_WIDTH) / 2;
// Center vertically for HRP, otherwise maintain original location (20).
int calledShotWindowY = screenGetHeight() != 480
? (screenGetHeight() - 100 - 1 - CALLED_SHOT_WINDOW_HEIGHT) / 2
? (screenGetHeight() - INTERFACE_BAR_HEIGHT - 1 - CALLED_SHOT_WINDOW_HEIGHT) / 2
: CALLED_SHOT_WINDOW_Y;
gCalledShotWindow = windowCreate(calledShotWindowX,
calledShotWindowY,
Expand Down
13 changes: 13 additions & 0 deletions src/core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "color.h"
#include "dinput.h"
#include "draw.h"
#include "interface.h"
#include "memory.h"
#include "mmx.h"
#include "text_font.h"
Expand Down Expand Up @@ -2047,6 +2048,8 @@ int _GNW95_init_mode_ex(int width, int height, int bpp)
if (configGetBool(&resolutionConfig, "MAIN", "WINDOWED", &windowed)) {
fullscreen = !windowed;
}

configGetBool(&resolutionConfig, "IFACE", "IFACE_BAR_MODE", &gInterfaceBarMode);
}
configFree(&resolutionConfig);
}
Expand Down Expand Up @@ -4617,6 +4620,16 @@ int screenGetHeight()
return rectGetHeight(&_scr_size);
}

int screenGetVisibleHeight()
{
int windowBottomMargin = 0;

if (!gInterfaceBarMode) {
windowBottomMargin = INTERFACE_BAR_HEIGHT;
}
return screenGetHeight() - windowBottomMargin;
}

void mouseGetPositionInWindow(int win, int* x, int* y)
{
mouseGetPosition(x, y);
Expand Down
1 change: 1 addition & 0 deletions src/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ bool _vcr_load_record(STRUCT_51E2F0* ptr, File* stream);

int screenGetWidth();
int screenGetHeight();
int screenGetVisibleHeight();
void mouseGetPositionInWindow(int win, int* x, int* y);
bool mouseHitTestInWindow(int win, int left, int top, int right, int bottom);

Expand Down
3 changes: 2 additions & 1 deletion src/elevator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "draw.h"
#include "game_mouse.h"
#include "game_sound.h"
#include "interface.h"
#include "map.h"
#include "pipboy.h"
#include "scripts.h"
Expand Down Expand Up @@ -535,7 +536,7 @@ int elevatorWindowInit(int elevator)
}

int elevatorWindowX = (screenGetWidth() - gElevatorBackgroundFrmWidth) / 2;
int elevatorWindowY = (screenGetHeight() - 100 - 1 - gElevatorBackgroundFrmHeight) / 2;
int elevatorWindowY = (screenGetHeight() - INTERFACE_BAR_HEIGHT - 1 - gElevatorBackgroundFrmHeight) / 2;
gElevatorWindow = windowCreate(
elevatorWindowX,
elevatorWindowY,
Expand Down
3 changes: 2 additions & 1 deletion src/game_mouse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,8 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState)
}
}

if (!_mouse_click_in(0, 0, _scr_size.right - _scr_size.left, _scr_size.bottom - _scr_size.top - 100)) {
// TODO: allow clicking to the left and right of the INTERFACE_BAR if gInterfaceBarMode is enabled
if (!_mouse_click_in(0, 0, _scr_size.right - _scr_size.left, _scr_size.bottom - _scr_size.top - INTERFACE_BAR_HEIGHT)) {
return;
}

Expand Down
11 changes: 4 additions & 7 deletions src/interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@

#include <stdio.h>

#define INDICATOR_BOX_WIDTH 130
#define INDICATOR_BOX_HEIGHT 21

#define INTERFACE_BAR_WIDTH 640
#define INTERFACE_BAR_HEIGHT 100

// The width of connectors in the indicator box.
//
// There are male connectors on the left, and female connectors on the right.
Expand Down Expand Up @@ -337,6 +331,9 @@ unsigned char* gInventoryButtonDownFrmData;
// 0x59D40C
unsigned char gInterfaceActionPointsBarBackground[90 * 5];

// Should the game window stretch all the way to the bottom or sit at the top of the interface bar (default)
bool gInterfaceBarMode = false;

// intface_init
// 0x45D880
int interfaceInit()
Expand All @@ -352,7 +349,7 @@ int interfaceInit()
gInterfaceBarInitialized = 1;

int interfaceBarWindowX = (screenGetWidth() - INTERFACE_BAR_WIDTH) / 2;
int interfaceBarWindowY = screenGetHeight() - INTERFACE_BAR_HEIGHT - 1;
int interfaceBarWindowY = screenGetHeight() - INTERFACE_BAR_HEIGHT;

gInterfaceBarWindow = windowCreate(interfaceBarWindowX, interfaceBarWindowY, INTERFACE_BAR_WIDTH, INTERFACE_BAR_HEIGHT, _colorTable[0], WINDOW_HIDDEN);
if (gInterfaceBarWindow == -1) {
Expand Down
7 changes: 7 additions & 0 deletions src/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ typedef enum InterfaceNumbersColor {
INTERFACE_NUMBERS_COLOR_RED = 240,
} InterfaceNumbersColor;

#define INDICATOR_BOX_WIDTH 130
#define INDICATOR_BOX_HEIGHT 21

#define INTERFACE_BAR_WIDTH 640
#define INTERFACE_BAR_HEIGHT 100

// The maximum number of indicator boxes the indicator bar can display.
//
// For unknown reason this number is 6, even though there are only 5 different
Expand Down Expand Up @@ -171,6 +177,7 @@ extern unsigned char* gOptionsButtonDownFrmData;
extern unsigned char* gSkilldexButtonUpFrmData;
extern unsigned char* gInventoryButtonDownFrmData;
extern unsigned char gInterfaceActionPointsBarBackground[450];
extern bool gInterfaceBarMode;

int interfaceInit();
void interfaceReset();
Expand Down
12 changes: 6 additions & 6 deletions src/map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ int isoInit()
_square[elevation] = &(_square_data[elevation]);
}

gIsoWindow = windowCreate(0, 0, _scr_size.right - _scr_size.left + 1, _scr_size.bottom - _scr_size.top - 99, 256, 10);
gIsoWindow = windowCreate(0, 0, screenGetWidth(), screenGetVisibleHeight(), 256, 10);
if (gIsoWindow == -1) {
debugPrint("win_add failed in iso_init\n");
return -1;
Expand All @@ -167,14 +167,14 @@ int isoInit()

debugPrint(">art_init\t\t");

if (tileInit(_square, SQUARE_GRID_WIDTH, SQUARE_GRID_HEIGHT, HEX_GRID_WIDTH, HEX_GRID_HEIGHT, gIsoWindowBuffer, _scr_size.right - _scr_size.left + 1, _scr_size.bottom - _scr_size.top - 99, _scr_size.right - _scr_size.left + 1, isoWindowRefreshRect) != 0) {
if (tileInit(_square, SQUARE_GRID_WIDTH, SQUARE_GRID_HEIGHT, HEX_GRID_WIDTH, HEX_GRID_HEIGHT, gIsoWindowBuffer, screenGetWidth(), screenGetVisibleHeight(), screenGetWidth(), isoWindowRefreshRect) != 0) {
debugPrint("tile_init failed in iso_init\n");
return -1;
}

debugPrint(">tile_init\t\t");

if (objectsInit(gIsoWindowBuffer, _scr_size.right - _scr_size.left + 1, _scr_size.bottom - _scr_size.top - 99, _scr_size.right - _scr_size.left + 1) != 0) {
if (objectsInit(gIsoWindowBuffer, screenGetWidth(), screenGetVisibleHeight(), screenGetWidth()) != 0) {
debugPrint("obj_init failed in iso_init\n");
return -1;
}
Expand Down Expand Up @@ -577,9 +577,9 @@ int mapScroll(int dx, int dy)
Rect r2;
rectCopy(&r2, &r1);

int width = _scr_size.right - _scr_size.left + 1;
int width = screenGetWidth();
int pitch = width;
int height = _scr_size.bottom - _scr_size.top - 99;
int height = screenGetVisibleHeight();

if (screenDx != 0) {
width -= 32;
Expand All @@ -601,7 +601,7 @@ int mapScroll(int dx, int dy)
if (screenDy < 0) {
r1.bottom = r1.top - screenDy;
src = gIsoWindowBuffer + pitch * (height - 1);
dest = gIsoWindowBuffer + pitch * (_scr_size.bottom - _scr_size.top - 100);
dest = gIsoWindowBuffer + pitch * (screenGetVisibleHeight() - 1);
if (screenDx < 0) {
dest -= screenDx;
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/skilldex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "game.h"
#include "game_mouse.h"
#include "game_sound.h"
#include "interface.h"
#include "map.h"
#include "memory.h"
#include "object.h"
Expand Down Expand Up @@ -187,7 +188,7 @@ int skilldexWindowInit()

// Maintain original position relative to centered interface bar.
int skilldexWindowX = (screenGetWidth() - 640) / 2 + 640 - gSkilldexFrmSizes[SKILLDEX_FRM_BACKGROUND].width - SKILLDEX_WINDOW_RIGHT_MARGIN;
int skilldexWindowY = screenGetHeight() - 100 - 1 - gSkilldexFrmSizes[SKILLDEX_FRM_BACKGROUND].height - SKILLDEX_WINDOW_BOTTOM_MARGIN;
int skilldexWindowY = screenGetHeight() - INTERFACE_BAR_HEIGHT - 1 - gSkilldexFrmSizes[SKILLDEX_FRM_BACKGROUND].height - SKILLDEX_WINDOW_BOTTOM_MARGIN;
gSkilldexWindow = windowCreate(skilldexWindowX,
skilldexWindowY,
gSkilldexFrmSizes[SKILLDEX_FRM_BACKGROUND].width,
Expand Down

0 comments on commit 4f69eec

Please sign in to comment.