diff --git a/sfall/HRP/Init.cpp b/sfall/HRP/Init.cpp index 483d6500..8b370687 100644 --- a/sfall/HRP/Init.cpp +++ b/sfall/HRP/Init.cpp @@ -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_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::ALTERNATE_AMMO_METRE = sf::IniReader::GetInt("IFACE", "ALTERNATE_AMMO_METRE", 0, f2ResIni); diff --git a/sfall/HRP/MainMenu.cpp b/sfall/HRP/MainMenu.cpp index 65566071..46463543 100644 --- a/sfall/HRP/MainMenu.cpp +++ b/sfall/HRP/MainMenu.cpp @@ -95,9 +95,8 @@ static void __cdecl main_menu_create_hook_buf_to_buf(BYTE* src, long sw, long sh // 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 static long __fastcall main_menu_create_hook_add_win(long h, long y, long color, long flags) { - long x = 0; - long w = 640; - long sw = w, sh = h; + long x = 0, w = 640; + long sw = w, sh = h; // h = 480 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) { sw = mainBackgroundFrm->frames->width; sh = mainBackgroundFrm->frames->height; + w = sw; + h = sh; } } - if (MainMenuScreen::MAIN_MENU_SIZE != 2) { - if (mainBackgroundFrm || MainMenuScreen::MAIN_MENU_SIZE == 1) { - w = Setting::ScreenWidth(); - h = Setting::ScreenHeight(); + if (MainMenuScreen::MAIN_MENU_SIZE == 1 || sw > Setting::ScreenWidth() || sh > Setting::ScreenHeight()) { + // out size + w = Setting::ScreenWidth(); + 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 (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; - } + if (w > Setting::ScreenWidth()) w = Setting::ScreenWidth(); + if (h > Setting::ScreenHeight()) h = Setting::ScreenHeight(); } else if (MainMenuScreen::MAIN_MENU_SIZE == 2) { h = Setting::ScreenHeight(); w = Setting::ScreenWidth(); - mainmenuWidth = w; } else { // centering x = (Setting::ScreenWidth() - w) / 2; y = (Setting::ScreenHeight() - h) / 2; } + mainmenuWidth = w; // set scaling factor scaleWidth = (w / 640.0f); diff --git a/sfall/Modules/Console.cpp b/sfall/Modules/Console.cpp index bd613f5c..06ea724d 100644 --- a/sfall/Modules/Console.cpp +++ b/sfall/Modules/Console.cpp @@ -21,6 +21,8 @@ #include "..\main.h" #include "..\Modules\LoadGameHook.h" +#include "..\HRP\Init.h" + #include "Console.h" namespace sfall @@ -63,7 +65,7 @@ void Console::init() { if (!path.empty()) { consoleFile.open(path); if (consoleFile.is_open()) { - MakeJump(0x43186C, display_print_hack); + if (!HRP::Setting::IsEnabled()) MakeJump(0x43186C, display_print_hack); LoadGameHook::OnGameReset() += []() { printCount = 0; diff --git a/sfall/Modules/Credits.cpp b/sfall/Modules/Credits.cpp index 0f97f41a..ee31efde 100644 --- a/sfall/Modules/Credits.cpp +++ b/sfall/Modules/Credits.cpp @@ -34,7 +34,7 @@ static const char* ExtraLines[] = { "#SFALL " VERSION_STRING, "", "sfall is free software, licensed under the GPL", - "Copyright 2008-2020 The sfall team", + LEGAL_COPYRIGHT, "", "@Author", "Timeslip", @@ -62,7 +62,7 @@ static const char* ExtraLines[] = { "Mr.Stalin", "Ghosthack", "", - "@Additional thanks to", + "@Additional thanks", "Nirran", "killap", "MIB88", diff --git a/sfall/WinProc.cpp b/sfall/WinProc.cpp index 5015f949..d07fdf3f 100644 --- a/sfall/WinProc.cpp +++ b/sfall/WinProc.cpp @@ -48,29 +48,24 @@ static int __stdcall WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara switch (msg) { //case WM_CREATE: // break; - case WM_DESTROY: __asm xor eax, eax; __asm call fo::funcoffs::exit_; return 1; - case WM_MOVE: client.x = LOWORD(lParam); client.y = HIWORD(lParam); break; - case WM_WINDOWPOSCHANGED: win.x = ((WINDOWPOS*)lParam)->x; win.y = ((WINDOWPOS*)lParam)->y; break; - case WM_ERASEBKGND: if (bkgndErased || !window) return 1; bkgndErased = true; break; - 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.bottom -= 1; __asm { @@ -79,35 +74,30 @@ static int __stdcall WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara } } break; - case WM_ACTIVATE: if (!cCursorShow && wParam == WA_INACTIVE) { cCursorShow = true; ShowCursor(1); } break; - case WM_SETCURSOR: { - short type = LOWORD(lParam); + WORD type = LOWORD(lParam); /*if (type == HTCAPTION || type == HTBORDER || type == HTMINBUTTON || type == HTCLOSE || type == HTMAXBUTTON) { if (!cCursorShow) { cCursorShow = true; 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) { cCursorShow = false; ShowCursor(0); } } return 1; - //break; } case WM_SYSCOMMAND: if ((wParam & 0xFFF0) == SC_SCREENSAVE || (wParam & 0xFFF0) == SC_MONITORPOWER) return 0; break; - case WM_ACTIVATEAPP: fo::var::setInt(FO_VAR_GNW95_isActive) = wParam; 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; call fo::funcoffs::win_refresh_all_; } - } else{ - // ClipCursor(0); + } else { + //ClipCursor(0); __asm xor eax, eax; __asm call fo::funcoffs::GNW95_hook_input_; } return 0; - case WM_CLOSE: __asm { call fo::funcoffs::main_menu_is_shown_; @@ -277,7 +266,7 @@ void WinProc::LoadPosition() { win.x = windowData >> 16; win.y = windowData & 0xFFFF; } 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() { - // Replace the engine WindowProc_ with sfall one + // Replace the engine WindowProc_ with sfall implementation MakeJump(0x4DE9FC, WindowProc); // WindowProc_ HookCall(0x481B2A, main_menu_loop_hook); diff --git a/sfall/main.cpp b/sfall/main.cpp index 1b51d010..1854ad49 100644 --- a/sfall/main.cpp +++ b/sfall/main.cpp @@ -219,6 +219,8 @@ static HMODULE SfallInit() { WinProc::init(); } + versionCHI = (*(DWORD*)0x4CAF23 == 0x225559); // check if the exe is modified for Chinese support + if (IniReader::GetIntDefaultConfig("Debugging", "SkipCompatModeCheck", 0) == 0) { int is64bit; typedef int (__stdcall *chk64bitproc)(HANDLE, int*); @@ -266,8 +268,6 @@ defaultIni: } std::srand(GetTickCount()); - versionCHI = (*(DWORD*)0x4CAF23 == 0x225559); // check if the exe is modified for Chinese support - IniReader::init(); if (IniReader::GetConfigString("Misc", "ConfigFile", "", falloutConfigName, 65)) {