Add IFACE_BAR_MODE configuration option from HRP (#5)

See #3
This commit is contained in:
Jan Šimek 2022-05-21 11:30:25 -07:00 committed by GitHub
parent 6725edcf5f
commit 86d8a92ce0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 38 additions and 17 deletions

View File

@ -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,

View File

@ -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"
@ -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);
}
@ -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);

View File

@ -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);

View File

@ -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"
@ -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,

View File

@ -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;
}

View File

@ -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.
@ -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()
@ -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) {

View File

@ -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
@ -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();

View File

@ -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;
@ -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;
}
@ -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;
@ -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 {

View File

@ -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"
@ -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,