Backported HEROWIN, DIALOGVIEW, COUNTERWIN game mode flags from 4.x

Updated UI hotkeys example mod.
This commit is contained in:
NovaRain
2019-09-13 08:09:07 +08:00
parent 9693c0d439
commit a6a8e2e42f
8 changed files with 92 additions and 20 deletions
Binary file not shown.
@@ -32,6 +32,7 @@ procedure start begin
if (event) then begin
mode := get_game_mode;
if (mode bwand COUNTERWIN) then return; // new mode from sfall 4.2/3.8.20
if (keyDX == DIK_I and (mode bwand INVENTORY)) then begin
tap_key(DIK_ESCAPE);
end else if (keyDX == DIK_S and (mode bwand SKILLDEX)) then begin
@@ -43,7 +44,7 @@ procedure start begin
tap_key(DIK_CAPITAL);
tap_key(DIK_A);
tap_key(DIK_CAPITAL);
end else if (mode bwand BARTER) then begin
end else if (mode == (BARTER + DIALOG)) then begin
tap_key(DIK_M);
end
end
+3
View File
@@ -17,6 +17,9 @@
#define INTFACEUSE (0x8000)
#define INTFACELOOT (0x10000)
#define BARTER (0x20000)
#define HEROWIN (0x40000)
#define DIALOGVIEW (0x80000)
#define COUNTERWIN (0x100000) // counter window for moving multiple items or setting a timer
//Valid arguments to register_hook
#define HOOK_TOHIT (0)
+3
View File
@@ -367,6 +367,8 @@ const DWORD gdialog_barter_pressed_ = 0x44A52C;
const DWORD gdialogActive_ = 0x444D2C;
const DWORD gdialogDisplayMsg_ = 0x445448;
const DWORD gdProcess_ = 0x4465C0;
const DWORD gdReviewExit_ = 0x445C18;
const DWORD gdReviewInit_ = 0x445938;
const DWORD GetSlotList_ = 0x47E5D0;
const DWORD get_input_ = 0x4C8B78;
const DWORD get_time_ = 0x4C9370;
@@ -644,6 +646,7 @@ const DWORD strParseStrFromList_ = 0x4AFE08;
const DWORD switch_hand_ = 0x4714E0;
const DWORD talk_to_critter_reacts_ = 0x447CA0;
const DWORD talk_to_translucent_trans_buf_to_buf_ = 0x44AC68;
const DWORD text_curr_ = 0x4D58D4;
const DWORD text_font_ = 0x4D58DC;
const DWORD text_object_create_ = 0x4B036C;
const DWORD tile_coord_ = 0x4B1674;
+3
View File
@@ -591,6 +591,8 @@ extern const DWORD gdialog_barter_pressed_;
extern const DWORD gdialogActive_;
extern const DWORD gdialogDisplayMsg_;
extern const DWORD gdProcess_;
extern const DWORD gdReviewExit_;
extern const DWORD gdReviewInit_;
extern const DWORD GetSlotList_;
extern const DWORD get_input_;
extern const DWORD get_time_;
@@ -877,6 +879,7 @@ extern const DWORD strParseStrFromList_;
extern const DWORD switch_hand_;
extern const DWORD talk_to_critter_reacts_;
extern const DWORD talk_to_translucent_trans_buf_to_buf_;
extern const DWORD text_curr_;
extern const DWORD text_font_;
extern const DWORD text_object_create_;
extern const DWORD tile_coord_; // eax - tilenum, edx (int*) - x, ebx (int*) - y
+5
View File
@@ -22,6 +22,7 @@
#include "Define.h"
#include "FalloutEngine.h"
#include "HeroAppearance.h"
#include "LoadGameHook.h"
#include "Message.h"
#include "PartyControl.h"
#include "ScriptExtender.h"
@@ -1403,6 +1404,8 @@ void _stdcall HeroSelectWindow(int raceStyleFlag) {
if (!isStyle) styleVal = 0;
LoadHeroDat(raceVal, styleVal, true);
SetLoopFlag(HEROWIN);
while (true) { // main loop
NewTick = GetTickCount(); // timer for redraw
if (OldTick > NewTick) OldTick = NewTick;
@@ -1486,6 +1489,8 @@ void _stdcall HeroSelectWindow(int raceStyleFlag) {
}
}
ClearLoopFlag(HEROWIN);
LoadHeroDat(currentRaceVal, currentStyleVal, true);
SetAppearanceGlobals(currentRaceVal, currentStyleVal);
+45
View File
@@ -74,6 +74,14 @@ DWORD GetLoopFlags() {
return InLoop;
}
void SetLoopFlag(LoopFlag flag) {
InLoop |= flag;
}
void ClearLoopFlag(LoopFlag flag) {
InLoop &= ~flag;
}
static void _stdcall ResetState(DWORD onLoad) {
if (!onLoad) FileSystemReset();
ClearGlobalScripts();
@@ -522,6 +530,39 @@ static void __declspec(naked) AutomapHook() {
}
}
static void __declspec(naked) DialogReviewInitHook() {
__asm {
call gdReviewInit_;
test eax, eax;
jnz error;
or InLoop, DIALOGVIEW;
xor eax, eax;
error:
retn;
}
}
static void __declspec(naked) DialogReviewExitHook() {
__asm {
and InLoop, (-1 ^ DIALOGVIEW);
jmp gdReviewExit_;
}
}
static void __declspec(naked) setup_move_timer_win_Hook() {
__asm {
or InLoop, COUNTERWIN;
jmp text_curr_;
}
}
static void __declspec(naked) exit_move_timer_win_Hook() {
__asm {
and InLoop, (-1 ^ COUNTERWIN);
jmp win_delete_;
}
}
void LoadGameHookInit() {
SaveInCombatFix = GetPrivateProfileInt("Misc", "SaveInCombatFix", 1, ini);
if (SaveInCombatFix > 2) SaveInCombatFix = 0;
@@ -596,4 +637,8 @@ void LoadGameHookInit() {
HookCall(0x4466C7, BarterInventoryHook);
HookCall(0x44396D, AutomapHook);
HookCall(0x479519, AutomapHook);
HookCall(0x445CA7, DialogReviewInitHook);
HookCall(0x445D30, DialogReviewExitHook);
HookCall(0x476AC6, setup_move_timer_win_Hook); // before init win
HookCall(0x477067, exit_move_timer_win_Hook);
}
+31 -19
View File
@@ -27,24 +27,36 @@ DWORD InWorldMap();
DWORD InCombat();
DWORD InDialog();
#define WORLDMAP (1<<0) // 0x1
#define LOCALMAP (1<<1) // 0x2 No point hooking this: would always be 1 at any point at which scripts are running
#define DIALOG (1<<2) // 0x4
#define ESCMENU (1<<3) // 0x8
#define SAVEGAME (1<<4) // 0x10
#define LOADGAME (1<<5) // 0x20
#define COMBAT (1<<6) // 0x40
#define OPTIONS (1<<7) // 0x80
#define HELP (1<<8) // 0x100
#define CHARSCREEN (1<<9) // 0x200
#define PIPBOY (1<<10) // 0x400
#define PCOMBAT (1<<11) // 0x800
#define INVENTORY (1<<12) // 0x1000
#define AUTOMAP (1<<13) // 0x2000
#define SKILLDEX (1<<14) // 0x4000
#define INTFACEUSE (1<<15) // 0x8000
#define INTFACELOOT (1<<16) // 0x10000
#define BARTER (1<<17) // 0x20000
#define RESERVED (1<<31)
enum LoopFlag : unsigned long {
WORLDMAP = 1 << 0, // 0x1
LOCALMAP = 1 << 1, // 0x2 No point hooking this: would always be 1 at any point at which scripts are running
DIALOG = 1 << 2, // 0x4
ESCMENU = 1 << 3, // 0x8
SAVEGAME = 1 << 4, // 0x10
LOADGAME = 1 << 5, // 0x20
COMBAT = 1 << 6, // 0x40
OPTIONS = 1 << 7, // 0x80
HELP = 1 << 8, // 0x100
CHARSCREEN = 1 << 9, // 0x200
PIPBOY = 1 << 10, // 0x400
PCOMBAT = 1 << 11, // 0x800
INVENTORY = 1 << 12, // 0x1000
AUTOMAP = 1 << 13, // 0x2000
SKILLDEX = 1 << 14, // 0x4000
INTFACEUSE = 1 << 15, // 0x8000
INTFACELOOT = 1 << 16, // 0x10000
BARTER = 1 << 17, // 0x20000
HEROWIN = 1 << 18, // 0x40000 Hero Appearance mod
DIALOGVIEW = 1 << 19, // 0x80000
COUNTERWIN = 1 << 20, // 0x100000 Counter window for moving multiple items or setting a timer
// RESERVED = 1 << 31
};
DWORD GetLoopFlags();
// set the given flag
void SetLoopFlag(LoopFlag flag);
// unset the given flag
void ClearLoopFlag(LoopFlag flag);