[HRP] Fixed the main menu still being stretched when MAIN_MENU_SIZE=0

[HRP] Fixed broken console messages when using ConsoleOutputPath (#424)
[HRP] Disabled IFACE_BAR_WIDTH for Chinese version.
Fixed the copyright line in the credits.
This commit is contained in:
NovaRain
2022-02-01 09:37:27 +08:00
parent 0807a4ea02
commit 0622a89978
6 changed files with 27 additions and 46 deletions
+1 -1
View File
@@ -264,7 +264,7 @@ void Setting::init(const char* exeFileName, std::string &cmdline) {
IFaceBar::IFACE_BAR_MODE = sf::IniReader::GetInt("IFACE", "IFACE_BAR_MODE", 0, f2ResIni); IFaceBar::IFACE_BAR_MODE = sf::IniReader::GetInt("IFACE", "IFACE_BAR_MODE", 0, f2ResIni);
IFaceBar::IFACE_BAR_SIDE_ART = sf::IniReader::GetInt("IFACE", "IFACE_BAR_SIDE_ART", 2, f2ResIni); IFaceBar::IFACE_BAR_SIDE_ART = sf::IniReader::GetInt("IFACE", "IFACE_BAR_SIDE_ART", 2, f2ResIni);
IFaceBar::IFACE_BAR_WIDTH = sf::IniReader::GetInt("IFACE", "IFACE_BAR_WIDTH", (SCR_WIDTH >= 800) ? 800 : 640, f2ResIni); IFaceBar::IFACE_BAR_WIDTH = sf::IniReader::GetInt("IFACE", "IFACE_BAR_WIDTH", (!sf::versionCHI && SCR_WIDTH >= 800) ? 800 : 640, f2ResIni);
IFaceBar::IFACE_BAR_SIDES_ORI = (sf::IniReader::GetInt("IFACE", "IFACE_BAR_SIDES_ORI", 0, f2ResIni) != 0); IFaceBar::IFACE_BAR_SIDES_ORI = (sf::IniReader::GetInt("IFACE", "IFACE_BAR_SIDES_ORI", 0, f2ResIni) != 0);
IFaceBar::ALTERNATE_AMMO_METRE = sf::IniReader::GetInt("IFACE", "ALTERNATE_AMMO_METRE", 0, f2ResIni); IFaceBar::ALTERNATE_AMMO_METRE = sf::IniReader::GetInt("IFACE", "ALTERNATE_AMMO_METRE", 0, f2ResIni);
+12 -22
View File
@@ -95,9 +95,8 @@ static void __cdecl main_menu_create_hook_buf_to_buf(BYTE* src, long sw, long sh
// create main menu window // create main menu window
// the window is created according to the size of the image, if the image exceeds the set game resolution, the window size is scaled // the window is created according to the size of the image, if the image exceeds the set game resolution, the window size is scaled
static long __fastcall main_menu_create_hook_add_win(long h, long y, long color, long flags) { static long __fastcall main_menu_create_hook_add_win(long h, long y, long color, long flags) {
long x = 0; long x = 0, w = 640;
long w = 640; long sw = w, sh = h; // h = 480
long sw = w, sh = h;
sf::Graphics::BackgroundClearColor(0); sf::Graphics::BackgroundClearColor(0);
@@ -109,38 +108,29 @@ static long __fastcall main_menu_create_hook_add_win(long h, long y, long color,
if (mainBackgroundFrm) { if (mainBackgroundFrm) {
sw = mainBackgroundFrm->frames->width; sw = mainBackgroundFrm->frames->width;
sh = mainBackgroundFrm->frames->height; sh = mainBackgroundFrm->frames->height;
w = sw;
h = sh;
} }
} }
if (MainMenuScreen::MAIN_MENU_SIZE != 2) { if (MainMenuScreen::MAIN_MENU_SIZE == 1 || sw > Setting::ScreenWidth() || sh > Setting::ScreenHeight()) {
if (mainBackgroundFrm || MainMenuScreen::MAIN_MENU_SIZE == 1) { // out size
w = Setting::ScreenWidth(); w = Setting::ScreenWidth();
h = Setting::ScreenHeight(); h = Setting::ScreenHeight();
x = Image::GetAspectSize(sw, sh, 0, 0, w, h); Image::GetAspectSize(sw, sh, &x, &y, w, h);
if (w > Setting::ScreenWidth()) w = Setting::ScreenWidth(); if (w > Setting::ScreenWidth()) w = Setting::ScreenWidth();
if (h > Setting::ScreenHeight()) h = Setting::ScreenHeight(); if (h > Setting::ScreenHeight()) h = Setting::ScreenHeight();
mainmenuWidth = w;
}
}
if (MainMenuScreen::MAIN_MENU_SIZE == 1) {
// extract x/y window position
if (x >= mainmenuWidth) {
y = x / mainmenuWidth;
x -= y * mainmenuWidth;
}
} else if (MainMenuScreen::MAIN_MENU_SIZE == 2) { } else if (MainMenuScreen::MAIN_MENU_SIZE == 2) {
h = Setting::ScreenHeight(); h = Setting::ScreenHeight();
w = Setting::ScreenWidth(); w = Setting::ScreenWidth();
mainmenuWidth = w;
} else { } else {
// centering // centering
x = (Setting::ScreenWidth() - w) / 2; x = (Setting::ScreenWidth() - w) / 2;
y = (Setting::ScreenHeight() - h) / 2; y = (Setting::ScreenHeight() - h) / 2;
} }
mainmenuWidth = w;
// set scaling factor // set scaling factor
scaleWidth = (w / 640.0f); scaleWidth = (w / 640.0f);
+3 -1
View File
@@ -21,6 +21,8 @@
#include "..\main.h" #include "..\main.h"
#include "..\Modules\LoadGameHook.h" #include "..\Modules\LoadGameHook.h"
#include "..\HRP\Init.h"
#include "Console.h" #include "Console.h"
namespace sfall namespace sfall
@@ -63,7 +65,7 @@ void Console::init() {
if (!path.empty()) { if (!path.empty()) {
consoleFile.open(path); consoleFile.open(path);
if (consoleFile.is_open()) { if (consoleFile.is_open()) {
MakeJump(0x43186C, display_print_hack); if (!HRP::Setting::IsEnabled()) MakeJump(0x43186C, display_print_hack);
LoadGameHook::OnGameReset() += []() { LoadGameHook::OnGameReset() += []() {
printCount = 0; printCount = 0;
+2 -2
View File
@@ -34,7 +34,7 @@ static const char* ExtraLines[] = {
"#SFALL " VERSION_STRING, "#SFALL " VERSION_STRING,
"", "",
"sfall is free software, licensed under the GPL", "sfall is free software, licensed under the GPL",
"Copyright 2008-2020 The sfall team", LEGAL_COPYRIGHT,
"", "",
"@Author", "@Author",
"Timeslip", "Timeslip",
@@ -62,7 +62,7 @@ static const char* ExtraLines[] = {
"Mr.Stalin", "Mr.Stalin",
"Ghosthack", "Ghosthack",
"", "",
"@Additional thanks to", "@Additional thanks",
"Nirran", "Nirran",
"killap", "killap",
"MIB88", "MIB88",
+7 -18
View File
@@ -48,29 +48,24 @@ static int __stdcall WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
switch (msg) { switch (msg) {
//case WM_CREATE: //case WM_CREATE:
// break; // break;
case WM_DESTROY: case WM_DESTROY:
__asm xor eax, eax; __asm xor eax, eax;
__asm call fo::funcoffs::exit_; __asm call fo::funcoffs::exit_;
return 1; return 1;
case WM_MOVE: case WM_MOVE:
client.x = LOWORD(lParam); client.x = LOWORD(lParam);
client.y = HIWORD(lParam); client.y = HIWORD(lParam);
break; break;
case WM_WINDOWPOSCHANGED: case WM_WINDOWPOSCHANGED:
win.x = ((WINDOWPOS*)lParam)->x; win.x = ((WINDOWPOS*)lParam)->x;
win.y = ((WINDOWPOS*)lParam)->y; win.y = ((WINDOWPOS*)lParam)->y;
break; break;
case WM_ERASEBKGND: case WM_ERASEBKGND:
if (bkgndErased || !window) return 1; if (bkgndErased || !window) return 1;
bkgndErased = true; bkgndErased = true;
break; break;
case WM_PAINT: case WM_PAINT:
if (window && GetUpdateRect(hWnd, &rect, 0) != 0) { // it's unclear under what conditions the redrawing is required if (window && GetUpdateRect(hWnd, &rect, 0) != 0) { // it's not clear under what conditions the redrawing is required
rect.right -= 1; rect.right -= 1;
rect.bottom -= 1; rect.bottom -= 1;
__asm { __asm {
@@ -79,35 +74,30 @@ static int __stdcall WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
} }
} }
break; break;
case WM_ACTIVATE: case WM_ACTIVATE:
if (!cCursorShow && wParam == WA_INACTIVE) { if (!cCursorShow && wParam == WA_INACTIVE) {
cCursorShow = true; cCursorShow = true;
ShowCursor(1); ShowCursor(1);
} }
break; break;
case WM_SETCURSOR: { case WM_SETCURSOR: {
short type = LOWORD(lParam); WORD type = LOWORD(lParam);
/*if (type == HTCAPTION || type == HTBORDER || type == HTMINBUTTON || type == HTCLOSE || type == HTMAXBUTTON) { /*if (type == HTCAPTION || type == HTBORDER || type == HTMINBUTTON || type == HTCLOSE || type == HTMAXBUTTON) {
if (!cCursorShow) { if (!cCursorShow) {
cCursorShow = true; cCursorShow = true;
ShowCursor(1); ShowCursor(1);
} }
} } else*/ if (type == HTCLIENT && fo::var::getInt(FO_VAR_GNW95_isActive)) {
else*/ if (type == HTCLIENT && fo::var::getInt(FO_VAR_GNW95_isActive)) {
if (cCursorShow) { if (cCursorShow) {
cCursorShow = false; cCursorShow = false;
ShowCursor(0); ShowCursor(0);
} }
} }
return 1; return 1;
//break;
} }
case WM_SYSCOMMAND: case WM_SYSCOMMAND:
if ((wParam & 0xFFF0) == SC_SCREENSAVE || (wParam & 0xFFF0) == SC_MONITORPOWER) return 0; if ((wParam & 0xFFF0) == SC_SCREENSAVE || (wParam & 0xFFF0) == SC_MONITORPOWER) return 0;
break; break;
case WM_ACTIVATEAPP: case WM_ACTIVATEAPP:
fo::var::setInt(FO_VAR_GNW95_isActive) = wParam; fo::var::setInt(FO_VAR_GNW95_isActive) = wParam;
if (wParam) { // active if (wParam) { // active
@@ -126,13 +116,12 @@ static int __stdcall WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
mov eax, FO_VAR_scr_size; mov eax, FO_VAR_scr_size;
call fo::funcoffs::win_refresh_all_; call fo::funcoffs::win_refresh_all_;
} }
} else{ } else {
// ClipCursor(0); //ClipCursor(0);
__asm xor eax, eax; __asm xor eax, eax;
__asm call fo::funcoffs::GNW95_hook_input_; __asm call fo::funcoffs::GNW95_hook_input_;
} }
return 0; return 0;
case WM_CLOSE: case WM_CLOSE:
__asm { __asm {
call fo::funcoffs::main_menu_is_shown_; call fo::funcoffs::main_menu_is_shown_;
@@ -277,7 +266,7 @@ void WinProc::LoadPosition() {
win.x = windowData >> 16; win.x = windowData >> 16;
win.y = windowData & 0xFFFF; win.y = windowData & 0xFFFF;
} else if (windowData == -1) { } else if (windowData == -1) {
WinProc::SetToCenter(win.width, win.height, &win.x, &win.y); SetToCenter(win.width, win.height, &win.x, &win.y);
} }
} }
@@ -294,7 +283,7 @@ const POINT* WinProc::GetClientPos() {
} }
void WinProc::init() { void WinProc::init() {
// Replace the engine WindowProc_ with sfall one // Replace the engine WindowProc_ with sfall implementation
MakeJump(0x4DE9FC, WindowProc); // WindowProc_ MakeJump(0x4DE9FC, WindowProc); // WindowProc_
HookCall(0x481B2A, main_menu_loop_hook); HookCall(0x481B2A, main_menu_loop_hook);
+2 -2
View File
@@ -219,6 +219,8 @@ static HMODULE SfallInit() {
WinProc::init(); WinProc::init();
} }
versionCHI = (*(DWORD*)0x4CAF23 == 0x225559); // check if the exe is modified for Chinese support
if (IniReader::GetIntDefaultConfig("Debugging", "SkipCompatModeCheck", 0) == 0) { if (IniReader::GetIntDefaultConfig("Debugging", "SkipCompatModeCheck", 0) == 0) {
int is64bit; int is64bit;
typedef int (__stdcall *chk64bitproc)(HANDLE, int*); typedef int (__stdcall *chk64bitproc)(HANDLE, int*);
@@ -266,8 +268,6 @@ defaultIni:
} }
std::srand(GetTickCount()); std::srand(GetTickCount());
versionCHI = (*(DWORD*)0x4CAF23 == 0x225559); // check if the exe is modified for Chinese support
IniReader::init(); IniReader::init();
if (IniReader::GetConfigString("Misc", "ConfigFile", "", falloutConfigName, 65)) { if (IniReader::GetConfigString("Misc", "ConfigFile", "", falloutConfigName, 65)) {