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
|
||||
;v3.8.6
|
||||
;v3.8.7
|
||||
|
||||
[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
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "Define.h"
|
||||
#include "FalloutEngine.h"
|
||||
#include "HookScripts.h"
|
||||
#include "input.h"
|
||||
#include "Inventory.h"
|
||||
#include "LoadGameHook.h"
|
||||
|
||||
@@ -633,6 +634,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:[_i_wid]
|
||||
call 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 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:[_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:[_i_wid]
|
||||
call 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 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 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 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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InventoryInit() {
|
||||
mode=GetPrivateProfileInt("Misc", "CritterInvSizeLimitMode", 0, ini);
|
||||
@@ -701,6 +822,13 @@ void InventoryInit() {
|
||||
|
||||
// Move items to player's main inventory instead of the opened bag/backpack when confirming a trade
|
||||
SafeWrite32(0x475CF2, _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);
|
||||
*((DWORD*)_max) = 100;
|
||||
};
|
||||
}
|
||||
void InventoryReset() {
|
||||
invenapcost=GetPrivateProfileInt("Misc", "InventoryApCost", 4, ini);
|
||||
|
||||
+119
-26
@@ -23,15 +23,17 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#include "FalloutEngine.h"
|
||||
#include "graphics.h"
|
||||
#include "ScriptExtender.h"
|
||||
#include "HookScripts.h"
|
||||
#include "input.h"
|
||||
#include "DebugEditor.h"
|
||||
#include "Logging.h"
|
||||
|
||||
typedef HRESULT (_stdcall *DInputCreateProc)(HINSTANCE a,DWORD b,IDirectInputA** c,IUnknown* d);
|
||||
|
||||
static bool UseScrollWheel;
|
||||
bool UseScrollWheel = true;
|
||||
static DWORD WheelMod;
|
||||
|
||||
static bool ReverseMouse;
|
||||
@@ -57,8 +59,13 @@ static DWORD ForcingGraphicsRefresh=0;
|
||||
|
||||
static DWORD DebugEditorKey = 0;
|
||||
|
||||
void _stdcall ForceGraphicsRefresh(DWORD d) { ForcingGraphicsRefresh=(d==0)?0:1; }
|
||||
void GetMouse(int* x, int* y) { *x=mouseX; *y=mouseY; mouseX=0; mouseY=0; }
|
||||
void _stdcall ForceGraphicsRefresh(DWORD d) {
|
||||
ForcingGraphicsRefresh = (d == 0) ? 0 : 1;
|
||||
}
|
||||
|
||||
void GetMouse(int* x, int* y) {
|
||||
*x = mouseX; *y = mouseY; mouseX = 0; mouseY = 0;
|
||||
}
|
||||
|
||||
static BYTE LMouse = 0;
|
||||
static BYTE RMouse = 0;
|
||||
@@ -76,6 +83,7 @@ void SetMDown(bool down, bool right) {
|
||||
if (right) RMouse = down ? 0x80 : 0;
|
||||
else LMouse = down ? 0x80 : 0;
|
||||
}
|
||||
|
||||
void SetMPos(int x, int y) {
|
||||
MPMouseX = x;
|
||||
MPMouseY = y;
|
||||
@@ -126,24 +134,51 @@ public:
|
||||
formatLock = false;
|
||||
oldFormat.dwDataSize = 0;
|
||||
}
|
||||
|
||||
/*** IUnknown methods ***/
|
||||
HRESULT _stdcall QueryInterface (REFIID riid, LPVOID * ppvObj) { return RealDevice->QueryInterface(riid,ppvObj); }
|
||||
ULONG _stdcall AddRef(void) { return ++Refs; }
|
||||
HRESULT _stdcall QueryInterface(REFIID riid, LPVOID * ppvObj) {
|
||||
return RealDevice->QueryInterface(riid, ppvObj);
|
||||
}
|
||||
|
||||
ULONG _stdcall AddRef(void) {
|
||||
return ++Refs;
|
||||
}
|
||||
|
||||
ULONG _stdcall Release(void) {
|
||||
if (--Refs == 0) {
|
||||
RealDevice->Release();
|
||||
delete this;
|
||||
return 0;
|
||||
} else { return Refs; }
|
||||
} else {
|
||||
return Refs;
|
||||
}
|
||||
}
|
||||
|
||||
/*** IDirectInputDevice8A methods ***/
|
||||
HRESULT _stdcall GetCapabilities(LPDIDEVCAPS a) { return RealDevice->GetCapabilities(a); }
|
||||
HRESULT _stdcall EnumObjects(LPDIENUMDEVICEOBJECTSCALLBACKA a,LPVOID b,DWORD c) { return RealDevice->EnumObjects(a,b,c); }
|
||||
HRESULT _stdcall GetProperty(REFGUID a,DIPROPHEADER* b) { return RealDevice->GetProperty(a,b); }
|
||||
HRESULT _stdcall SetProperty(REFGUID a,const DIPROPHEADER* b) { return RealDevice->SetProperty(a,b); }
|
||||
HRESULT _stdcall Acquire(void) { return RealDevice->Acquire(); }
|
||||
HRESULT _stdcall Unacquire(void) { return RealDevice->Unacquire(); }
|
||||
HRESULT _stdcall GetCapabilities(LPDIDEVCAPS a) {
|
||||
return RealDevice->GetCapabilities(a);
|
||||
}
|
||||
|
||||
HRESULT _stdcall EnumObjects(LPDIENUMDEVICEOBJECTSCALLBACKA a, LPVOID b, DWORD c) {
|
||||
return RealDevice->EnumObjects(a, b, c);
|
||||
}
|
||||
|
||||
HRESULT _stdcall GetProperty(REFGUID a, DIPROPHEADER* b) {
|
||||
return RealDevice->GetProperty(a, b);
|
||||
}
|
||||
|
||||
HRESULT _stdcall SetProperty(REFGUID a, const DIPROPHEADER* b) {
|
||||
return RealDevice->SetProperty(a, b);
|
||||
}
|
||||
|
||||
HRESULT _stdcall Acquire(void) {
|
||||
return RealDevice->Acquire();
|
||||
}
|
||||
|
||||
HRESULT _stdcall Unacquire(void) {
|
||||
return RealDevice->Unacquire();
|
||||
}
|
||||
|
||||
//Only called for the mouse
|
||||
HRESULT _stdcall GetDeviceState(DWORD a, LPVOID b) {
|
||||
if (ForcingGraphicsRefresh) RefreshGraphics();
|
||||
@@ -173,15 +208,27 @@ public:
|
||||
if (UseScrollWheel) {
|
||||
int count = 1;
|
||||
if (MouseState.lZ > 0) {
|
||||
if (*(DWORD*)_gmouse_current_cursor == 2 || *(DWORD*)_gmouse_current_cursor == 3) {
|
||||
__asm {
|
||||
call 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 (*(DWORD*)_gmouse_current_cursor == 2 || *(DWORD*)_gmouse_current_cursor == 3) {
|
||||
__asm {
|
||||
call 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]) {
|
||||
if (!MiddleMouseDown) {
|
||||
TapKey(MiddleMouseKey);
|
||||
@@ -201,6 +248,7 @@ public:
|
||||
memcpy(b, &MouseState, sizeof(DIMOUSESTATE));
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Only called for the keyboard
|
||||
HRESULT _stdcall GetDeviceData(DWORD a, DIDEVICEOBJECTDATA* b, DWORD* c, DWORD d) {
|
||||
if (DeviceType != kDeviceType_KEYBOARD) {
|
||||
@@ -228,40 +276,73 @@ public:
|
||||
*c = 1;
|
||||
return DI_OK;
|
||||
}
|
||||
|
||||
HRESULT _stdcall SetDataFormat(const DIDATAFORMAT* a) {
|
||||
if (formatLock&&oldFormat.dwSize) return RealDevice->SetDataFormat(&oldFormat);
|
||||
memcpy(&oldFormat, a, sizeof(DIDATAFORMAT));
|
||||
return RealDevice->SetDataFormat(a);
|
||||
}
|
||||
HRESULT _stdcall SetEventNotification(HANDLE a) { return RealDevice->SetEventNotification(a); }
|
||||
|
||||
HRESULT _stdcall SetEventNotification(HANDLE a) {
|
||||
return RealDevice->SetEventNotification(a);
|
||||
}
|
||||
|
||||
HRESULT _stdcall SetCooperativeLevel(HWND a, DWORD b) {
|
||||
if (DeviceType == kDeviceType_KEYBOARD&&BackgroundKeyboard) b = DISCL_BACKGROUND | DISCL_NONEXCLUSIVE;
|
||||
if (DeviceType == kDeviceType_MOUSE&&BackgroundMouse) b = DISCL_BACKGROUND | DISCL_NONEXCLUSIVE;
|
||||
return RealDevice->SetCooperativeLevel(a, b);
|
||||
}
|
||||
HRESULT _stdcall GetObjectInfo(LPDIDEVICEOBJECTINSTANCEA a,DWORD b,DWORD c) { return RealDevice->GetObjectInfo(a,b,c); }
|
||||
HRESULT _stdcall GetDeviceInfo(LPDIDEVICEINSTANCEA a) { return RealDevice->GetDeviceInfo(a); }
|
||||
HRESULT _stdcall RunControlPanel(HWND a,DWORD b) { return RealDevice->RunControlPanel(a,b); }
|
||||
HRESULT _stdcall Initialize(HINSTANCE a,DWORD b,REFGUID c) { return RealDevice->Initialize(a,b,c); }
|
||||
void LockDataFormat(bool lock) {formatLock = lock; }
|
||||
|
||||
HRESULT _stdcall GetObjectInfo(LPDIDEVICEOBJECTINSTANCEA a, DWORD b, DWORD c) {
|
||||
return RealDevice->GetObjectInfo(a, b, c);
|
||||
}
|
||||
|
||||
HRESULT _stdcall GetDeviceInfo(LPDIDEVICEINSTANCEA a) {
|
||||
return RealDevice->GetDeviceInfo(a);
|
||||
}
|
||||
|
||||
HRESULT _stdcall RunControlPanel(HWND a, DWORD b) {
|
||||
return RealDevice->RunControlPanel(a, b);
|
||||
}
|
||||
|
||||
HRESULT _stdcall Initialize(HINSTANCE a, DWORD b, REFGUID c) {
|
||||
return RealDevice->Initialize(a, b, c);
|
||||
}
|
||||
|
||||
void LockDataFormat(bool lock) {
|
||||
formatLock = lock;
|
||||
}
|
||||
};
|
||||
|
||||
class FakeDirectInput : public IDirectInputA {
|
||||
private:
|
||||
IDirectInputA* RealInput;
|
||||
ULONG Refs;
|
||||
public:
|
||||
/*** Constructor ***/
|
||||
FakeDirectInput(IDirectInput* Real) { RealInput=Real; Refs=1; }
|
||||
FakeDirectInput(IDirectInput* Real) {
|
||||
RealInput = Real; Refs = 1;
|
||||
}
|
||||
|
||||
/*** IUnknown methods ***/
|
||||
HRESULT _stdcall QueryInterface (REFIID riid, LPVOID* ppvObj) { return RealInput->QueryInterface(riid,ppvObj); }
|
||||
ULONG _stdcall AddRef(void) { return ++Refs; }
|
||||
HRESULT _stdcall QueryInterface(REFIID riid, LPVOID* ppvObj) {
|
||||
return RealInput->QueryInterface(riid, ppvObj);
|
||||
}
|
||||
|
||||
ULONG _stdcall AddRef(void) {
|
||||
return ++Refs;
|
||||
}
|
||||
|
||||
ULONG _stdcall Release(void) {
|
||||
if (--Refs == 0) {
|
||||
RealInput->Release();
|
||||
delete this;
|
||||
return 0;
|
||||
} else { return Refs; }
|
||||
} else {
|
||||
return Refs;
|
||||
}
|
||||
}
|
||||
|
||||
/*** IDirectInput8A methods ***/
|
||||
HRESULT _stdcall CreateDevice(REFGUID r, IDirectInputDeviceA** device, IUnknown* unused) {
|
||||
GUID GUID_SysMouse = { 0x6F1D2B60, 0xD5A0, 0x11CF, { 0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00} };
|
||||
@@ -289,10 +370,22 @@ public:
|
||||
return DI_OK;
|
||||
}
|
||||
}
|
||||
HRESULT _stdcall EnumDevices(DWORD a,LPDIENUMDEVICESCALLBACKA b,void* c,DWORD d) { return RealInput->EnumDevices(a,b,c,d); }
|
||||
HRESULT _stdcall GetDeviceStatus(REFGUID r) { return RealInput->GetDeviceStatus(r); }
|
||||
HRESULT _stdcall RunControlPanel(HWND a,DWORD b) { return RealInput->RunControlPanel(a,b); }
|
||||
HRESULT _stdcall Initialize(HINSTANCE a,DWORD b) { return RealInput->Initialize(a,b); }
|
||||
|
||||
HRESULT _stdcall EnumDevices(DWORD a, LPDIENUMDEVICESCALLBACKA b, void* c, DWORD d) {
|
||||
return RealInput->EnumDevices(a, b, c, d);
|
||||
}
|
||||
|
||||
HRESULT _stdcall GetDeviceStatus(REFGUID r) {
|
||||
return RealInput->GetDeviceStatus(r);
|
||||
}
|
||||
|
||||
HRESULT _stdcall RunControlPanel(HWND a, DWORD b) {
|
||||
return RealInput->RunControlPanel(a, b);
|
||||
}
|
||||
|
||||
HRESULT _stdcall Initialize(HINSTANCE a, DWORD b) {
|
||||
return RealInput->Initialize(a, b);
|
||||
}
|
||||
};
|
||||
|
||||
HRESULT _stdcall FakeDirectInputCreate(HINSTANCE a, DWORD b, IDirectInputA** c, IUnknown* d) {
|
||||
|
||||
+8
-1
@@ -18,6 +18,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
extern bool UseScrollWheel;
|
||||
|
||||
void SetMPMode(bool active);
|
||||
void SetMDown(bool down, bool right);
|
||||
void SetMPos(int x, int y);
|
||||
@@ -122,7 +124,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) */
|
||||
@@ -169,4 +171,9 @@ 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);
|
||||
|
||||
+3
-3
@@ -22,12 +22,12 @@
|
||||
|
||||
#define VERSION_MAJOR 3
|
||||
#define VERSION_MINOR 8
|
||||
#define VERSION_BUILD 6
|
||||
#define VERSION_BUILD 7
|
||||
#define VERSION_REV 0
|
||||
#ifdef WIN2K
|
||||
#define VERSION_STRING "3.8.6 win2k"
|
||||
#define VERSION_STRING "3.8.7 win2k"
|
||||
#else
|
||||
#define VERSION_STRING "3.8.6"
|
||||
#define VERSION_STRING "3.8.7"
|
||||
#endif
|
||||
|
||||
#define CHECK_VAL (4)
|
||||
|
||||
Reference in New Issue
Block a user