mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Added inventory code
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
* sfall
|
||||
* Copyright (C) 2008-2016 The sfall team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
* sfall
|
||||
* Copyright (C) 2008-2016 The sfall team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -109,6 +109,14 @@ struct AnimationSad {
|
||||
|
||||
static_assert(sizeof(AnimationSad) == 3240, "Incorrect AnimationSad definition.");
|
||||
|
||||
struct InventScrData {
|
||||
long artIndex;
|
||||
long width;
|
||||
long height;
|
||||
long x;
|
||||
long y;
|
||||
};
|
||||
|
||||
struct SquareRect {
|
||||
long y;
|
||||
long x;
|
||||
|
||||
@@ -144,6 +144,8 @@
|
||||
#define FO_VAR_i_lhand 0x59E958
|
||||
#define FO_VAR_i_rhand 0x59E968
|
||||
#define FO_VAR_i_wid 0x59E964
|
||||
#define FO_VAR_i_wid_max_x 0x59E974
|
||||
#define FO_VAR_i_wid_max_y 0x59E970
|
||||
#define FO_VAR_i_worn 0x59E954
|
||||
#define FO_VAR_idle_func 0x51E234
|
||||
#define FO_VAR_In_WorldMap 0x672E1C
|
||||
@@ -156,6 +158,7 @@
|
||||
#define FO_VAR_inven_scroll_dn_bid 0x5190E8
|
||||
#define FO_VAR_inven_scroll_up_bid 0x5190E4
|
||||
#define FO_VAR_inventry_message_file 0x59E814
|
||||
#define FO_VAR_iscr_data 0x519068
|
||||
#define FO_VAR_itemButtonItems 0x5970F8
|
||||
#define FO_VAR_itemCurrentItem 0x518F78
|
||||
#define FO_VAR_kb_lock_flags 0x51E2EA
|
||||
|
||||
@@ -102,6 +102,7 @@ VAR_(inven_pid, DWORD)
|
||||
VAR_(inven_scroll_dn_bid, DWORD)
|
||||
VAR_(inven_scroll_up_bid, DWORD)
|
||||
VAR_(inventry_message_file, fo::MessageList)
|
||||
VARA(iscr_data, fo::InventScrData, 6)
|
||||
VARA(itemButtonItems, fo::ItemButtonItem, 2) // 0 - left, 1 - right
|
||||
VAR_(itemCurrentItem, long) // 0 - left, 1 - right
|
||||
VAR_(kb_lock_flags, DWORD)
|
||||
|
||||
@@ -44,6 +44,13 @@ static long __fastcall CreateWinDialog(long height, long yPos, long xPos, long c
|
||||
xPosition = xPos;
|
||||
yPosition = yPos;
|
||||
|
||||
// item move window
|
||||
fo::var::iscr_data[4].x = xPos + 185;
|
||||
fo::var::iscr_data[4].y = yPos + 115;
|
||||
// about window
|
||||
fo::var::iscr_data[3].x = xPos + 80;
|
||||
fo::var::iscr_data[3].y = yPos + 290;
|
||||
|
||||
return fo::func::win_add(xPos, yPos, width, height, color, flags);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "MainMenu.h"
|
||||
#include "InterfaceBar.h"
|
||||
#include "Dialog.h"
|
||||
#include "Inventory.h"
|
||||
|
||||
#include "Init.h"
|
||||
|
||||
@@ -146,6 +147,7 @@ void HRP::init() {
|
||||
ViewMap::init();
|
||||
IFaceBar::init();
|
||||
Dialog::init();
|
||||
Inventory::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* sfall
|
||||
* Copyright (C) 2008-2021 The sfall team
|
||||
*
|
||||
*/
|
||||
|
||||
#include "..\main.h"
|
||||
#include "..\FalloutEngine\Fallout2.h"
|
||||
|
||||
#include "Init.h"
|
||||
|
||||
#include "Inventory.h"
|
||||
|
||||
namespace sfall
|
||||
{
|
||||
|
||||
static bool setPosition[3];
|
||||
static long xPosition;
|
||||
static long yPosition;
|
||||
|
||||
static long __fastcall CreateWin(long height, long yPos, long xPos, long width, long mode, long color, long flags) {
|
||||
if (!setPosition[mode]) {
|
||||
setPosition[mode] = true;
|
||||
long x = (HRP::ScreenWidth() - width) / 2;
|
||||
long y = (fo::var::getInt(FO_VAR_buf_length_2) - height) / 2;
|
||||
fo::var::iscr_data[mode].x = x;
|
||||
fo::var::iscr_data[mode].y = y;
|
||||
}
|
||||
// item move window
|
||||
fo::var::iscr_data[4].x = fo::var::iscr_data[mode].x + 60;
|
||||
fo::var::iscr_data[4].y = fo::var::iscr_data[mode].y + 80;
|
||||
|
||||
xPos -= 80;
|
||||
xPos += fo::var::iscr_data[mode].x;
|
||||
yPos += fo::var::iscr_data[mode].y;
|
||||
xPosition = xPos - 80;
|
||||
yPosition = yPos;
|
||||
|
||||
fo::var::setInt(FO_VAR_i_wid_max_x) = xPos + width;
|
||||
fo::var::setInt(FO_VAR_i_wid_max_y) = yPos + height;
|
||||
|
||||
return fo::func::win_add(xPos, yPos, width, height, color, flags);
|
||||
}
|
||||
|
||||
static void __declspec(naked) setup_inventory_hook_win_add() {
|
||||
__asm {
|
||||
pop ebp; // ret addr
|
||||
push edi; // mode
|
||||
push ebx; // width
|
||||
push eax; // xPos
|
||||
push ebp;
|
||||
jmp CreateWin;
|
||||
}
|
||||
}
|
||||
|
||||
static void __declspec(naked) inventory_hook_mouse_click_in() {
|
||||
__asm {
|
||||
add eax, xPosition; // left
|
||||
add ebx, xPosition; // right
|
||||
add edx, yPosition; // top
|
||||
add ecx, yPosition; // bottom
|
||||
jmp fo::funcoffs::mouse_click_in_;
|
||||
}
|
||||
}
|
||||
|
||||
void Inventory::init() {
|
||||
// set timer window position to center screen
|
||||
fo::var::iscr_data[5].x = (HRP::ScreenWidth() - fo::var::iscr_data[5].width) / 2;
|
||||
fo::var::iscr_data[5].y = (HRP::ScreenHeight() - fo::var::iscr_data[5].height) / 2;
|
||||
|
||||
HookCall(0x46ED0E, setup_inventory_hook_win_add);
|
||||
HookCalls(inventory_hook_mouse_click_in, {
|
||||
0x471145, 0x471270, 0x471301, 0x47138B, // inven_pickup_
|
||||
0x474959, 0x474A23 // move_inventory_
|
||||
});
|
||||
|
||||
// setup_inventory_
|
||||
SafeMemSet(0x46ED23, CodeType::Nop, 6);
|
||||
SafeMemSet(0x46ED31, CodeType::Nop, 6);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* sfall
|
||||
* Copyright (C) 2008-2021 The sfall team
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace sfall
|
||||
{
|
||||
|
||||
class Inventory {
|
||||
public:
|
||||
static void init();
|
||||
};
|
||||
|
||||
}
|
||||
@@ -313,6 +313,7 @@
|
||||
<ClInclude Include="HRP\Image.h" />
|
||||
<ClInclude Include="HRP\Init.h" />
|
||||
<ClInclude Include="HRP\InterfaceBar.h" />
|
||||
<ClInclude Include="HRP\Inventory.h" />
|
||||
<ClInclude Include="HRP\MainMenu.h" />
|
||||
<ClInclude Include="HRP\SplashScreen.h" />
|
||||
<ClInclude Include="HRP\ViewMap\EdgeBorder.h" />
|
||||
@@ -440,6 +441,7 @@
|
||||
<ClCompile Include="HRP\Image.cpp" />
|
||||
<ClCompile Include="HRP\Init.cpp" />
|
||||
<ClCompile Include="HRP\InterfaceBar.cpp" />
|
||||
<ClCompile Include="HRP\Inventory.cpp" />
|
||||
<ClCompile Include="HRP\MainMenu.cpp" />
|
||||
<ClCompile Include="HRP\SplashScreen.cpp" />
|
||||
<ClCompile Include="HRP\ViewMap\EdgeBorder.cpp" />
|
||||
|
||||
@@ -404,6 +404,9 @@
|
||||
<ClInclude Include="HRP\Dialog.h">
|
||||
<Filter>HRP</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HRP\Inventory.h">
|
||||
<Filter>HRP</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
@@ -743,6 +746,9 @@
|
||||
<ClCompile Include="HRP\Dialog.cpp">
|
||||
<Filter>HRP</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HRP\Inventory.cpp">
|
||||
<Filter>HRP</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="version.rc" />
|
||||
|
||||
Reference in New Issue
Block a user