Fix ExpandBarter and DIALOG_SCRN_BACKGROUND conflict (closes #544)

This commit is contained in:
phobos2077
2024-06-01 20:27:57 +02:00
parent 002dfa61cb
commit 6b8613a91f
3 changed files with 23 additions and 6 deletions
+15 -6
View File
@@ -30,19 +30,22 @@ bool Dialog::DIALOG_SCRN_BACKGROUND = false;
static long xPosition;
static long yPosition;
static long dialogExpandedHeight = 0;
static long __fastcall CreateWinDialog(long height, long yPos, long xPos, long color, long flags) {
long fitRectW = fo::var::getInt(FO_VAR_buf_width_2);
long fitRectH = fo::var::getInt(FO_VAR_buf_length_2);
if (Dialog::DIALOG_SCRN_BACKGROUND) {
fo::func::win_hide(fo::var::getInt(FO_VAR_display_win));
IFaceBar::Hide();
yPos += 50;
fitRectH += fo::func::GNW_find(fo::var::interfaceWindow)->height;
}
long mapWinW = fo::var::getInt(FO_VAR_buf_width_2) / 2;
long mapWinH = fo::var::getInt(FO_VAR_buf_length_2) / 2;
xPos += mapWinW - (width / 2); // xPos:0
yPos += mapWinH - (height / 2); // yPos:0 = 480 - art_frame_length
long expandedHeight = dialogExpandedHeight > 0 ? dialogExpandedHeight : height;
xPos += (fitRectW - width) / 2; // xPos:0
yPos += (fitRectH - expandedHeight) / 2; // yPos:0 = 480 - art_frame_length
if (yPos < 0) yPos = 0;
yPosition = yPos;
@@ -274,4 +277,10 @@ void Dialog::init() {
}
}
void Dialog::SetDialogExpandedHeight(long height) {
assert(height >= 0);
dialogExpandedHeight = height;
}
}
+2
View File
@@ -15,6 +15,8 @@ public:
static bool DIALOG_SCRN_ART_FIX;
static bool DIALOG_SCRN_BACKGROUND;
static void SetDialogExpandedHeight(long height);
};
}
+6
View File
@@ -27,6 +27,7 @@
#include "LoadGameHook.h"
#include "Worldmap.h"
#include "..\HRP\Dialog.h"
#include "..\HRP\InterfaceBar.h"
#include "..\HRP\viewmap\EdgeClipping.h"
@@ -1291,7 +1292,12 @@ static void ExpandedBarterPatch() {
if (HRP::Setting::VersionIsValid) {
// HRP overrides window creation code setup_inventory, so need to write correct max Y value into HRP itself.
SafeWrite32(HRP::Setting::GetAddress(0x1001220C), 470 + extraBarterHeight);
// Vertical offset in DialogWinSetup() when main screen is disabled (DIALOG_SCRN_BACKGROUND = 1).
SafeWrite32(HRP::Setting::GetAddress(0x1001228F), dialogWindowHeight / 2);
// Window height for passing to AdjustWinPosToGame function that calculates x & y.
SafeWrite32(HRP::Setting::GetAddress(0x100122C3), dialogWindowHeight);
} else {
HRP::Dialog::SetDialogExpandedHeight(dialogWindowHeight);
SafeWrite32(0x46EDD4, 470 + extraBarterHeight); // Trade window max Y = Y pos + height = 290 + 180 = 470
}
SafeWriteBatch<DWORD>(dialogWindowHeight, { // Game dialog BG window height (for Y calculation only)