mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Fixed some problems with the main menu in sfall HRP
Minor edits to other code.
This commit is contained in:
@@ -78,6 +78,10 @@ char* GetMsg(fo::MessageList* msgList, int msgNum, int msgType) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fo::Window* GetWindow(long winID) {
|
||||||
|
return fo::var::window[fo::var::window_index[winID]];
|
||||||
|
}
|
||||||
|
|
||||||
fo::Queue* QueueFind(fo::GameObject* object, long type) {
|
fo::Queue* QueueFind(fo::GameObject* object, long type) {
|
||||||
if (fo::var::queue) {
|
if (fo::var::queue) {
|
||||||
fo::Queue* queue = fo::var::queue;
|
fo::Queue* queue = fo::var::queue;
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ fo::MessageNode* GetMsgNode(fo::MessageList* msgList, int msgNum);
|
|||||||
|
|
||||||
char* GetMsg(fo::MessageList* msgList, int msgNum, int msgType);
|
char* GetMsg(fo::MessageList* msgList, int msgNum, int msgType);
|
||||||
|
|
||||||
|
fo::Window* GetWindow(long winID);
|
||||||
|
|
||||||
fo::Queue* QueueFind(fo::GameObject* object, long type);
|
fo::Queue* QueueFind(fo::GameObject* object, long type);
|
||||||
|
|
||||||
// returns weapon animation code
|
// returns weapon animation code
|
||||||
|
|||||||
@@ -61,6 +61,7 @@
|
|||||||
#define FO_VAR_curr_font_num 0x51E3B0
|
#define FO_VAR_curr_font_num 0x51E3B0
|
||||||
#define FO_VAR_curr_pc_stat 0x6681AC
|
#define FO_VAR_curr_pc_stat 0x6681AC
|
||||||
#define FO_VAR_curr_stack 0x59E96C
|
#define FO_VAR_curr_stack 0x59E96C
|
||||||
|
#define FO_VAR_current_palette 0x6639D0
|
||||||
#define FO_VAR_currentProgram 0x59E78C
|
#define FO_VAR_currentProgram 0x59E78C
|
||||||
#define FO_VAR_currentWindow 0x51DCB8
|
#define FO_VAR_currentWindow 0x51DCB8
|
||||||
#define FO_VAR_cursor_line 0x664514
|
#define FO_VAR_cursor_line 0x664514
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ VAR_(btncnt, DWORD)
|
|||||||
VARD(cap, fo::AIcap) // dynamic array
|
VARD(cap, fo::AIcap) // dynamic array
|
||||||
VAR_(carCurrentArea, DWORD)
|
VAR_(carCurrentArea, DWORD)
|
||||||
VAR_(carGasAmount, long) // from 0 to 80000
|
VAR_(carGasAmount, long) // from 0 to 80000
|
||||||
VARA(cmap, fo::PALETTE, 256)
|
VARA(cmap, fo::PALETTE, 256) // palette without gamma
|
||||||
VAR_(colorTable, DWORD)
|
VAR_(colorTable, DWORD)
|
||||||
VAR_(combat_end_due_to_load, DWORD)
|
VAR_(combat_end_due_to_load, DWORD)
|
||||||
VAR_(combat_free_move, DWORD)
|
VAR_(combat_free_move, DWORD)
|
||||||
@@ -41,6 +41,7 @@ VAR_(curr_anim_counter, DWORD)
|
|||||||
VAR_(curr_font_num, DWORD)
|
VAR_(curr_font_num, DWORD)
|
||||||
VARA(curr_pc_stat, long, fo::PCSTAT_max_pc_stat)
|
VARA(curr_pc_stat, long, fo::PCSTAT_max_pc_stat)
|
||||||
VAR_(curr_stack, DWORD)
|
VAR_(curr_stack, DWORD)
|
||||||
|
VARA(current_palette, fo::PALETTE, 256) // current palette without gamma
|
||||||
VAR_(currentProgram, fo::Program*)
|
VAR_(currentProgram, fo::Program*)
|
||||||
VAR_(cursor_line, DWORD)
|
VAR_(cursor_line, DWORD)
|
||||||
VAR_(DarkGreenColor, BYTE)
|
VAR_(DarkGreenColor, BYTE)
|
||||||
|
|||||||
+11
-10
@@ -51,18 +51,19 @@ static void __cdecl main_death_scene_hook_buf_to_buf(fo::FrmData* frm, long w, l
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
yPosition = h;
|
yPosition = h;
|
||||||
Image::Scale(frm->frame.data, width, height, dst, w, h, Setting::ScreenWidth());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
yPosition = height;
|
|
||||||
|
|
||||||
long y = (h - height) / 2;
|
Image::Scale(frm->frame.data, width, height, dst, w, h, Setting::ScreenWidth());
|
||||||
long x = (w - width) / 2;
|
} else {
|
||||||
if (x || y) {
|
yPosition = height;
|
||||||
yPosition += y;
|
|
||||||
dst += x + (y * Setting::ScreenWidth());
|
long y = (h - height) / 2;
|
||||||
|
long x = (w - width) / 2;
|
||||||
|
if (x || y) {
|
||||||
|
yPosition += y;
|
||||||
|
dst += x + (y * Setting::ScreenWidth());
|
||||||
|
}
|
||||||
|
fo::func::buf_to_buf(frm->frame.data, width, height, width, dst, Setting::ScreenWidth());
|
||||||
}
|
}
|
||||||
fo::func::buf_to_buf(frm->frame.data, width, height, width, dst, Setting::ScreenWidth());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Darkens a rectangle area for printing text
|
// Darkens a rectangle area for printing text
|
||||||
|
|||||||
@@ -43,15 +43,15 @@ static void __cdecl game_help_hook_buf_to_buf(fo::FrmData* frm, long w, long h,
|
|||||||
Image::GetAspectSize(width, height, &x, &y, w, h);
|
Image::GetAspectSize(width, height, &x, &y, w, h);
|
||||||
if (x || y) dst += x + (y * Setting::ScreenWidth());
|
if (x || y) dst += x + (y * Setting::ScreenWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
Image::Scale(frm->frame.data, width, height, dst, w, h, Setting::ScreenWidth());
|
Image::Scale(frm->frame.data, width, height, dst, w, h, Setting::ScreenWidth());
|
||||||
return;
|
} else {
|
||||||
|
long y = (h - height) / 2;
|
||||||
|
long x = (w - width) / 2;
|
||||||
|
if (x || y) dst += x + (y * Setting::ScreenWidth());
|
||||||
|
|
||||||
|
fo::func::buf_to_buf(frm->frame.data, width, height, width, dst, Setting::ScreenWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
long y = (h - height) / 2;
|
|
||||||
long x = (w - width) / 2;
|
|
||||||
if (x || y) dst += x + (y * Setting::ScreenWidth());
|
|
||||||
|
|
||||||
fo::func::buf_to_buf(frm->frame.data, width, height, width, dst, Setting::ScreenWidth());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpScreen::init() {
|
void HelpScreen::init() {
|
||||||
|
|||||||
+7
-7
@@ -163,8 +163,8 @@ struct BMPHEADER {
|
|||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
/* BMP 24-bit
|
// BMP 24-bit
|
||||||
bool MakeBMP(const char* file, BYTE* dataRGB32, long width, long height, long pitch) {
|
bool Image::MakeBMP(const char* file, BYTE* dataRGB32, long width, long height, long pitch) {
|
||||||
long bmpExtraSize = width * 3 % 4;
|
long bmpExtraSize = width * 3 % 4;
|
||||||
if (bmpExtraSize != 0) bmpExtraSize = 4 - bmpExtraSize;
|
if (bmpExtraSize != 0) bmpExtraSize = 4 - bmpExtraSize;
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ bool MakeBMP(const char* file, BYTE* dataRGB32, long width, long height, long pi
|
|||||||
BMPHEADER bmpHeader;
|
BMPHEADER bmpHeader;
|
||||||
std::memset(&bmpHeader, 0, sizeof(BMPHEADER));
|
std::memset(&bmpHeader, 0, sizeof(BMPHEADER));
|
||||||
|
|
||||||
bmpHeader.bFile.bfType = 'BM';
|
bmpHeader.bFile.bfType = 'MB';
|
||||||
bmpHeader.bFile.bfSize = sizeImage + sizeof(BMPHEADER);
|
bmpHeader.bFile.bfSize = sizeImage + sizeof(BMPHEADER);
|
||||||
bmpHeader.bFile.bfOffBits = sizeof(BMPHEADER);
|
bmpHeader.bFile.bfOffBits = sizeof(BMPHEADER);
|
||||||
bmpHeader.bInfo.biSize = sizeof(BITMAPINFOHEADER);
|
bmpHeader.bInfo.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
@@ -189,9 +189,9 @@ bool MakeBMP(const char* file, BYTE* dataRGB32, long width, long height, long pi
|
|||||||
BYTE* dData = bmpImageData;
|
BYTE* dData = bmpImageData;
|
||||||
|
|
||||||
// 32-bit to 24-bit
|
// 32-bit to 24-bit
|
||||||
for (size_t h = 0; h < height; h++) {
|
for (long h = 0; h < height; h++) {
|
||||||
BYTE* sData = dataRGB32;
|
BYTE* sData = dataRGB32;
|
||||||
for (size_t w = 0; w < width; w++) {
|
for (long w = 0; w < width; w++) {
|
||||||
*dData++ = *sData++;
|
*dData++ = *sData++;
|
||||||
*dData++ = *sData++;
|
*dData++ = *sData++;
|
||||||
*dData++ = *sData++;
|
*dData++ = *sData++;
|
||||||
@@ -201,7 +201,7 @@ bool MakeBMP(const char* file, BYTE* dataRGB32, long width, long height, long pi
|
|||||||
dData += bmpExtraSize;
|
dData += bmpExtraSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE hFile = CreateFileA(file, GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
|
HANDLE hFile = CreateFileA(file, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
|
||||||
bool result = (hFile != INVALID_HANDLE_VALUE);
|
bool result = (hFile != INVALID_HANDLE_VALUE);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -213,6 +213,6 @@ bool MakeBMP(const char* file, BYTE* dataRGB32, long width, long height, long pi
|
|||||||
delete[] bmpImageData;
|
delete[] bmpImageData;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ public:
|
|||||||
|
|
||||||
static void Scale(BYTE* src, long sWight, long sHeight, BYTE* dst, long dWight, long dHeight, long dPitch = 0, long sPitch = 0);
|
static void Scale(BYTE* src, long sWight, long sHeight, BYTE* dst, long dWight, long dHeight, long dPitch = 0, long sPitch = 0);
|
||||||
static void ScaleText(BYTE* dst, const char* text, long txtWidth, long dstWidth, long colorFlags, float scaleFactor);
|
static void ScaleText(BYTE* dst, const char* text, long txtWidth, long dstWidth, long colorFlags, float scaleFactor);
|
||||||
|
|
||||||
|
static bool MakeBMP(const char* file, BYTE* dataRGB32, long width, long height, long pitch);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-6
@@ -90,11 +90,12 @@ bool Setting::ExternalEnabled() {
|
|||||||
static std::string GetBackupFileName(const char* runFileName, bool wait) {
|
static std::string GetBackupFileName(const char* runFileName, bool wait) {
|
||||||
std::string bakExeName(runFileName);
|
std::string bakExeName(runFileName);
|
||||||
size_t n = bakExeName.rfind('.');
|
size_t n = bakExeName.rfind('.');
|
||||||
if (n != std::string::npos) {
|
if (n == std::string::npos) return std::string(); // empty
|
||||||
bakExeName.replace(n, 4, ".hrp");
|
|
||||||
char c = 10;
|
bakExeName.replace(n, 4, ".hrp");
|
||||||
while (std::remove(bakExeName.c_str()) != 0 && wait && --c) Sleep(1000); // delete .hrp (if it exists)
|
char c = 10;
|
||||||
}
|
while (std::remove(bakExeName.c_str()) != 0 && wait && --c) Sleep(1000); // delete .hrp (if it exists)
|
||||||
|
|
||||||
return bakExeName;
|
return bakExeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +122,7 @@ static bool DisableExtHRP(const char* runFileName, std::string &cmdline) {
|
|||||||
std::fclose(ft);
|
std::fclose(ft);
|
||||||
cmdline.append(" -restart");
|
cmdline.append(" -restart");
|
||||||
|
|
||||||
MessageBoxA(0, "High Resolution Patch has been successfully deactivated.", "sfall", MB_TASKMODAL | MB_ICONINFORMATION);
|
//MessageBoxA(0, "High Resolution Patch has been successfully deactivated.", "sfall", MB_TASKMODAL | MB_ICONINFORMATION);
|
||||||
|
|
||||||
ShellExecuteA(0, 0, runFileName, cmdline.c_str(), 0, SW_SHOWDEFAULT); // restart game
|
ShellExecuteA(0, 0, runFileName, cmdline.c_str(), 0, SW_SHOWDEFAULT); // restart game
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+17
-12
@@ -43,7 +43,7 @@ static long offsetX = 0, offsetY = 0;
|
|||||||
|
|
||||||
// draw image to main menu window
|
// draw image to main menu window
|
||||||
static void __cdecl main_menu_create_hook_buf_to_buf(BYTE* src, long sw, long sh, long srcW, BYTE* dst, long dstW) {
|
static void __cdecl main_menu_create_hook_buf_to_buf(BYTE* src, long sw, long sh, long srcW, BYTE* dst, long dstW) {
|
||||||
fo::Window* win = fo::var::window[fo::var::main_window]; // the window size is always equal to the scaled image
|
fo::Window* win = fo::util::GetWindow(fo::var::main_window); // the window size is always equal to the scaled image
|
||||||
long h = win->height;
|
long h = win->height;
|
||||||
long w = win->width;
|
long w = win->width;
|
||||||
dstW = w;
|
dstW = w;
|
||||||
@@ -113,18 +113,17 @@ static long __fastcall main_menu_create_hook_add_win(long h, long y, long color,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MainMenuScreen::MAIN_MENU_SIZE == 1 || sw > Setting::ScreenWidth() || sh > Setting::ScreenHeight()) {
|
if (MainMenuScreen::MAIN_MENU_SIZE || sw > Setting::ScreenWidth() || sh > Setting::ScreenHeight()) {
|
||||||
// out size
|
// out size
|
||||||
w = Setting::ScreenWidth();
|
w = Setting::ScreenWidth();
|
||||||
h = Setting::ScreenHeight();
|
h = Setting::ScreenHeight();
|
||||||
|
|
||||||
Image::GetAspectSize(sw, sh, &x, &y, w, h);
|
if (MainMenuScreen::MAIN_MENU_SIZE <= 1) {
|
||||||
|
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();
|
||||||
} else if (MainMenuScreen::MAIN_MENU_SIZE == 2) {
|
}
|
||||||
h = Setting::ScreenHeight();
|
|
||||||
w = Setting::ScreenWidth();
|
|
||||||
} else {
|
} else {
|
||||||
// centering
|
// centering
|
||||||
x = (Setting::ScreenWidth() - w) / 2;
|
x = (Setting::ScreenWidth() - w) / 2;
|
||||||
@@ -140,8 +139,14 @@ static long __fastcall main_menu_create_hook_add_win(long h, long y, long color,
|
|||||||
if (MainMenuScreen::USE_HIRES_IMAGES == false || (MainMenuScreen::USE_HIRES_IMAGES && MainMenuScreen::SCALE_BUTTONS_AND_TEXT_MENU)) {
|
if (MainMenuScreen::USE_HIRES_IMAGES == false || (MainMenuScreen::USE_HIRES_IMAGES && MainMenuScreen::SCALE_BUTTONS_AND_TEXT_MENU)) {
|
||||||
scaleFactor = scaleHeight;
|
scaleFactor = scaleHeight;
|
||||||
} else {
|
} else {
|
||||||
if (w != 640) offsetX = (long)(6.0f * (Setting::ScreenWidth() * 0.0015625));
|
if (w != 640) {
|
||||||
if (h != 480) offsetY = (long)(4.0f * (Setting::ScreenHeight() * 0.0020833334f));
|
float diff = (Setting::ScreenWidth() / 640.0f);
|
||||||
|
offsetX = (long)((8.0f * (diff * diff)));
|
||||||
|
}
|
||||||
|
if (h != 480) {
|
||||||
|
float diff = (Setting::ScreenHeight() / 480.0f);
|
||||||
|
offsetY = (long)((6.0f * (diff * diff)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::MainMenu::mTextOffset = offsetX;
|
sf::MainMenu::mTextOffset = offsetX;
|
||||||
@@ -158,7 +163,7 @@ static long __fastcall main_menu_create_hook_add_win(long h, long y, long color,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static long __fastcall GetHeightOffset(long &y) {
|
static long __fastcall GetHeightOffset(long &y) {
|
||||||
long h = fo::var::window[fo::var::main_window]->height;
|
long h = fo::util::GetWindow(fo::var::main_window)->height;
|
||||||
y = ((y - 460) - 20) + h;
|
y = ((y - 460) - 20) + h;
|
||||||
if (y > h) {
|
if (y > h) {
|
||||||
y = h - 10;
|
y = h - 10;
|
||||||
@@ -237,7 +242,7 @@ static long __fastcall ButtonPosition(long &width, long xPos, BYTE* &upImageData
|
|||||||
xPos = (long)(xPos * scaleFactor);
|
xPos = (long)(xPos * scaleFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
long h = fo::var::window[fo::var::main_window]->height;
|
long h = fo::util::GetWindow(fo::var::main_window)->height;
|
||||||
|
|
||||||
/*** Button position ***/
|
/*** Button position ***/
|
||||||
xPos += (long)(sf::MainMenu::mXOffset * scaleWidth) + offsetX;
|
xPos += (long)(sf::MainMenu::mXOffset * scaleWidth) + offsetX;
|
||||||
|
|||||||
@@ -30,7 +30,13 @@ static void __fastcall SetMovieSize() {
|
|||||||
|
|
||||||
long subtitleHeight = (fo::var::getInt(FO_VAR_subtitles) && fo::var::getInt(FO_VAR_subtitleList)) ? fo::var::getInt(FO_VAR_subtitleH) + 4 : 0;
|
long subtitleHeight = (fo::var::getInt(FO_VAR_subtitles) && fo::var::getInt(FO_VAR_subtitleList)) ? fo::var::getInt(FO_VAR_subtitleH) + 4 : 0;
|
||||||
|
|
||||||
if (MoviesScreen::MOVIE_SIZE == 1 || bW > sWidth || bH > sHeight) {
|
if (MoviesScreen::MOVIE_SIZE == 2) {
|
||||||
|
movieToSize.top = 0;
|
||||||
|
movieToSize.bottom = Setting::ScreenHeight() - subtitleHeight;
|
||||||
|
|
||||||
|
movieToSize.left = 0;
|
||||||
|
movieToSize.right = Setting::ScreenWidth();
|
||||||
|
} else if (MoviesScreen::MOVIE_SIZE == 1 || bW > sWidth || bH > sHeight) {
|
||||||
long aspectW = sWidth;
|
long aspectW = sWidth;
|
||||||
long aspectH = sHeight;
|
long aspectH = sHeight;
|
||||||
long x = 0;
|
long x = 0;
|
||||||
@@ -41,12 +47,6 @@ static void __fastcall SetMovieSize() {
|
|||||||
movieToSize.top = y;
|
movieToSize.top = y;
|
||||||
movieToSize.right = x + aspectW;
|
movieToSize.right = x + aspectW;
|
||||||
movieToSize.bottom = y + aspectH;
|
movieToSize.bottom = y + aspectH;
|
||||||
} else if (MoviesScreen::MOVIE_SIZE == 2) {
|
|
||||||
movieToSize.top = 0;
|
|
||||||
movieToSize.bottom = Setting::ScreenHeight() - subtitleHeight;
|
|
||||||
|
|
||||||
movieToSize.left = 0;
|
|
||||||
movieToSize.right = Setting::ScreenWidth();
|
|
||||||
} else {
|
} else {
|
||||||
// set to center
|
// set to center
|
||||||
movieToSize.top = (Setting::ScreenHeight() - bH) / 2;
|
movieToSize.top = (Setting::ScreenHeight() - bH) / 2;
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ static void __cdecl endgame_display_image_hook_buf_to_buf(BYTE* src, long w, lon
|
|||||||
if (x || y) dst += x + (y * Setting::ScreenWidth());
|
if (x || y) dst += x + (y * Setting::ScreenWidth());
|
||||||
}
|
}
|
||||||
bottomPos = h;
|
bottomPos = h;
|
||||||
|
|
||||||
Image::Scale(src, width, height, dst, w, h, Setting::ScreenWidth());
|
Image::Scale(src, width, height, dst, w, h, Setting::ScreenWidth());
|
||||||
} else {
|
} else {
|
||||||
bottomPos = height;
|
bottomPos = height;
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ static void __declspec(naked) MainMenuHookTextYOffset() {
|
|||||||
static void __fastcall main_menu_create_hook_print_text(long xPos, const char* text, long yPos, long color) {
|
static void __fastcall main_menu_create_hook_print_text(long xPos, const char* text, long yPos, long color) {
|
||||||
long winId = fo::var::main_window;
|
long winId = fo::var::main_window;
|
||||||
if (!HRP::Setting::ExternalEnabled() && HRP::Setting::IsEnabled()) {
|
if (!HRP::Setting::ExternalEnabled() && HRP::Setting::IsEnabled()) {
|
||||||
fo::Window* win = fo::var::window[winId];
|
fo::Window* win = fo::util::GetWindow(winId);
|
||||||
yPos = ((yPos - 460) - 20) + win->height;
|
yPos = ((yPos - 460) - 20) + win->height;
|
||||||
xPos = ((xPos - 615) - 25) + win->width;
|
xPos = ((xPos - 615) - 25) + win->width;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user