mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Enabled mouse scroll control in barter and loot screens when the cursor is hovering over other lists, also enabled scrolling through the display monitor (from Crafty) #120
Rearraged the code style in dinput.cpp. Updated version number.
This commit is contained in:
+2
-2
@@ -1,5 +1,5 @@
|
||||
;sfall configuration settings
|
||||
;v4.0.1
|
||||
;v4.0.2
|
||||
|
||||
[Main]
|
||||
;Change to 1 if you want to use command line args to tell sfall to use another ini file.
|
||||
@@ -72,7 +72,7 @@ Use32BitHeadGraphics=0
|
||||
|
||||
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
[Input]
|
||||
;Set to 1 to enable the mouse scroll wheel to scroll through your inventory
|
||||
;Set to 1 to enable the mouse scroll wheel to scroll through inventory, barter, and loot screens
|
||||
UseScrollWheel=1
|
||||
|
||||
;The mouse Z position is divided by this modifier to calculate the number of inventory
|
||||
|
||||
+31
-18
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "main.h"
|
||||
#include "Logging.h"
|
||||
#include "FalloutEngine\Fallout2.h"
|
||||
#include "Modules\Graphics.h"
|
||||
|
||||
#include "InputFuncs.h"
|
||||
@@ -30,7 +31,7 @@
|
||||
namespace sfall
|
||||
{
|
||||
|
||||
static bool useScrollWheel;
|
||||
bool useScrollWheel = true;
|
||||
static DWORD wheelMod;
|
||||
|
||||
static bool reverseMouse;
|
||||
@@ -131,21 +132,21 @@ void _stdcall TapKey(DWORD key) {
|
||||
|
||||
class FakeDirectInputDevice : public IDirectInputDeviceA {
|
||||
private:
|
||||
IDirectInputDeviceA* RealDevice;
|
||||
DWORD DeviceType;
|
||||
IDirectInputDeviceA* RealDevice;
|
||||
DWORD DeviceType;
|
||||
ULONG Refs;
|
||||
bool formatLock;
|
||||
DIDATAFORMAT oldFormat;
|
||||
|
||||
public:
|
||||
/*** Constructor and misc functions ***/
|
||||
FakeDirectInputDevice(IDirectInputDevice* device,DWORD type) {
|
||||
RealDevice=device;
|
||||
DeviceType=type;
|
||||
Refs=1;
|
||||
/*** Constructor and misc functions ***/
|
||||
FakeDirectInputDevice(IDirectInputDevice* device,DWORD type) {
|
||||
RealDevice = device;
|
||||
DeviceType = type;
|
||||
Refs = 1;
|
||||
formatLock = false;
|
||||
oldFormat.dwDataSize=0;
|
||||
}
|
||||
oldFormat.dwDataSize = 0;
|
||||
}
|
||||
|
||||
/*** IUnknown methods ***/
|
||||
HRESULT _stdcall QueryInterface(REFIID riid, LPVOID * ppvObj) {
|
||||
@@ -220,13 +221,25 @@ public:
|
||||
if (useScrollWheel) {
|
||||
int count = 1;
|
||||
if (MouseState.lZ > 0) {
|
||||
if (wheelMod) count = MouseState.lZ / wheelMod;
|
||||
if (count < 1) count = 1;
|
||||
while (count--) TapKey(DIK_UP);
|
||||
if (fo::var::gmouse_current_cursor == 2 || fo::var::gmouse_current_cursor == 3) {
|
||||
__asm {
|
||||
call fo::funcoffs::display_scroll_up_;
|
||||
}
|
||||
} else {
|
||||
if (wheelMod) count = MouseState.lZ / wheelMod;
|
||||
if (count < 1) count = 1;
|
||||
while (count--) TapKey(DIK_UP);
|
||||
}
|
||||
} else if (MouseState.lZ < 0) {
|
||||
if (wheelMod) count = (-MouseState.lZ) / wheelMod;
|
||||
if (count < 1) count = 1;
|
||||
while (count--) TapKey(DIK_DOWN);
|
||||
if (fo::var::gmouse_current_cursor == 2 || fo::var::gmouse_current_cursor == 3) {
|
||||
__asm {
|
||||
call fo::funcoffs::display_scroll_down_;
|
||||
}
|
||||
} else {
|
||||
if (wheelMod) count = (-MouseState.lZ) / wheelMod;
|
||||
if (count < 1) count = 1;
|
||||
while (count--) TapKey(DIK_DOWN);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (middleMouseKey&&MouseState.rgbButtons[2]) {
|
||||
@@ -323,7 +336,7 @@ public:
|
||||
RealInput = Real; Refs = 1;
|
||||
}
|
||||
|
||||
/*** IUnknown methods ***/
|
||||
/*** IUnknown methods ***/
|
||||
HRESULT _stdcall QueryInterface(REFIID riid, LPVOID* ppvObj) {
|
||||
return RealInput->QueryInterface(riid, ppvObj);
|
||||
}
|
||||
@@ -347,7 +360,7 @@ public:
|
||||
GUID GUID_SysMouse = { 0x6F1D2B60, 0xD5A0, 0x11CF, { 0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00} };
|
||||
GUID GUID_SysKeyboard = { 0x6F1D2B61, 0xD5A0, 0x11CF, { 0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00} };
|
||||
|
||||
if (r != GUID_SysKeyboard&&r != GUID_SysMouse) {
|
||||
if (r != GUID_SysKeyboard && r != GUID_SysMouse) {
|
||||
return RealInput->CreateDevice(r, device, unused);
|
||||
} else {
|
||||
DWORD d;
|
||||
|
||||
+8
-1
@@ -25,6 +25,8 @@
|
||||
namespace sfall
|
||||
{
|
||||
|
||||
extern bool useScrollWheel;
|
||||
|
||||
void SetMDown(bool down, bool right);
|
||||
void SetMPos(int x, int y);
|
||||
|
||||
@@ -135,7 +137,7 @@ void GetMouse(int* x, int* y);
|
||||
#define DIK_NOCONVERT 0x7B /* (Japanese keyboard) */
|
||||
#define DIK_YEN 0x7D /* (Japanese keyboard) */
|
||||
#define DIK_NUMPADEQUALS 0x8D /* = on numeric keypad (NEC PC98) */
|
||||
//#define DIK_CIRCUMFLEX 0x90 /* (Japanese keyboard) */
|
||||
#define DIK_PREVTRACK 0x90 /* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) */
|
||||
#define DIK_AT 0x91 /* (NEC PC98) */
|
||||
#define DIK_COLON 0x92 /* (NEC PC98) */
|
||||
#define DIK_UNDERLINE 0x93 /* (NEC PC98) */
|
||||
@@ -182,6 +184,11 @@ void GetMouse(int* x, int* y);
|
||||
#define DIK_DOWNARROW DIK_DOWN /* DownArrow on arrow keypad */
|
||||
#define DIK_PGDN DIK_NEXT /* PgDn on arrow keypad */
|
||||
|
||||
/*
|
||||
* Alternate names for keys originally not used on US keyboards.
|
||||
*/
|
||||
#define DIK_CIRCUMFLEX DIK_PREVTRACK /* Japanese keyboard */
|
||||
|
||||
void _stdcall ForceGraphicsRefresh(DWORD);
|
||||
|
||||
}
|
||||
|
||||
@@ -585,6 +585,126 @@ end:
|
||||
}
|
||||
}
|
||||
|
||||
static void __declspec(naked) loot_container_hack2() {
|
||||
__asm {
|
||||
cmp esi, 0x150 // source_down
|
||||
je scroll
|
||||
cmp esi, 0x148 // source_up
|
||||
jne end
|
||||
scroll:
|
||||
push edx
|
||||
push ecx
|
||||
push ebx
|
||||
mov eax, ds:[FO_VAR_i_wid]
|
||||
call fo::funcoffs::GNW_find_
|
||||
mov ebx, [eax+0x8+0x0] // ebx = _i_wid.rect.x
|
||||
mov ecx, [eax+0x8+0x4] // ecx = _i_wid.rect.y
|
||||
mov eax, 297
|
||||
add eax, ebx // x_start
|
||||
add ebx, 297+64 // x_end
|
||||
mov edx, 37
|
||||
add edx, ecx // y_start
|
||||
add ecx, 37+6*48 // y_end
|
||||
call fo::funcoffs::mouse_click_in_
|
||||
pop ebx
|
||||
pop ecx
|
||||
pop edx
|
||||
test eax, eax
|
||||
jz end
|
||||
cmp esi, 0x150 // source_down
|
||||
je targetDown
|
||||
mov esi, 0x18D // target_up
|
||||
jmp end
|
||||
targetDown:
|
||||
mov esi, 0x191 // target_down
|
||||
end:
|
||||
mov eax, ds:[FO_VAR_curr_stack]
|
||||
retn
|
||||
}
|
||||
}
|
||||
|
||||
static void __declspec(naked) barter_inventory_hack2() {
|
||||
__asm {
|
||||
push edx
|
||||
push ecx
|
||||
push ebx
|
||||
xchg esi, eax
|
||||
cmp esi, 0x150 // source_down
|
||||
je scroll
|
||||
cmp esi, 0x148 // source_up
|
||||
jne end
|
||||
scroll:
|
||||
mov eax, ds:[FO_VAR_i_wid]
|
||||
call fo::funcoffs::GNW_find_
|
||||
mov ebx, [eax+0x8+0x0] // ebx = _i_wid.rect.x
|
||||
mov ecx, [eax+0x8+0x4] // ecx = _i_wid.rect.y
|
||||
push ebx
|
||||
push ecx
|
||||
mov eax, 395
|
||||
add eax, ebx // x_start
|
||||
add ebx, 395+64 // x_end
|
||||
mov edx, 35
|
||||
add edx, ecx // y_start
|
||||
add ecx, 35+3*48 // y_end
|
||||
call fo::funcoffs::mouse_click_in_
|
||||
pop ecx
|
||||
pop ebx
|
||||
test eax, eax
|
||||
jz notTargetScroll
|
||||
cmp esi, 0x150 // source_down
|
||||
je targetDown
|
||||
mov esi, 0x18D // target_up
|
||||
jmp end
|
||||
targetDown:
|
||||
mov esi, 0x191 // target_down
|
||||
jmp end
|
||||
notTargetScroll:
|
||||
push ebx
|
||||
push ecx
|
||||
mov eax, 250
|
||||
add eax, ebx // x_start
|
||||
add ebx, 250+64 // x_end
|
||||
mov edx, 20
|
||||
add edx, ecx // y_start
|
||||
add ecx, 20+3*48 // y_end
|
||||
call fo::funcoffs::mouse_click_in_
|
||||
pop ecx
|
||||
pop ebx
|
||||
test eax, eax
|
||||
jz notTargetBarter
|
||||
cmp esi, 0x150 // source_down
|
||||
je barterTargetDown
|
||||
mov esi, 0x184 // target_barter_up
|
||||
jmp end
|
||||
barterTargetDown:
|
||||
mov esi, 0x176 // target_barter_down
|
||||
jmp end
|
||||
notTargetBarter:
|
||||
mov eax, 165
|
||||
add eax, ebx // x_start
|
||||
add ebx, 165+64 // x_end
|
||||
mov edx, 20
|
||||
add edx, ecx // y_start
|
||||
add ecx, 20+3*48 // y_end
|
||||
call fo::funcoffs::mouse_click_in_
|
||||
test eax, eax
|
||||
jz end
|
||||
cmp esi, 0x150 // source_down
|
||||
je barterSourceDown
|
||||
mov esi, 0x149 // source_barter_up
|
||||
jmp end
|
||||
barterSourceDown:
|
||||
mov esi, 0x151 // source_barter_down
|
||||
end:
|
||||
pop ebx
|
||||
pop ecx
|
||||
pop edx
|
||||
mov eax, esi
|
||||
cmp eax, 0x11
|
||||
retn
|
||||
}
|
||||
}
|
||||
|
||||
int __stdcall ItemCountFixStdcall(fo::GameObject* who, fo::GameObject* item) {
|
||||
int count = 0;
|
||||
for (int i = 0; i < who->invenSize; i++) {
|
||||
@@ -753,6 +873,13 @@ void Inventory::init() {
|
||||
// Move items to player's main inventory instead of the opened bag/backpack when confirming a trade
|
||||
SafeWrite32(0x475CF2, FO_VAR_stack);
|
||||
|
||||
// Enable mouse scroll control in barter and loot screens when the cursor is hovering over other lists
|
||||
if (useScrollWheel) {
|
||||
MakeCall(0x473E66, loot_container_hack2);
|
||||
MakeCall(0x4759F1, barter_inventory_hack2);
|
||||
fo::var::max = 100;
|
||||
};
|
||||
|
||||
// Fix item_count function returning incorrect value when there is a container-item inside
|
||||
MakeJump(0x47808C, ItemCountFix); // replacing item_count_ function
|
||||
}
|
||||
|
||||
+3
-3
@@ -24,13 +24,13 @@
|
||||
|
||||
#define VERSION_MAJOR 4
|
||||
#define VERSION_MINOR 0
|
||||
#define VERSION_BUILD 1
|
||||
#define VERSION_BUILD 2
|
||||
#define VERSION_REV 0
|
||||
|
||||
#ifdef WIN2K
|
||||
#define VERSION_STRING "4.0.1 win2k"
|
||||
#define VERSION_STRING "4.0.2 win2k"
|
||||
#else
|
||||
#define VERSION_STRING "4.0.1"
|
||||
#define VERSION_STRING "4.0.2"
|
||||
#endif
|
||||
|
||||
#define CHECK_VAL (4)
|
||||
|
||||
Reference in New Issue
Block a user