TAB map content centred again; key bindings no longer pass on Ctrl/Alt
- megamap: the zoomed view (0x6cc950) is shared by the large map and the TAB overview map; its centre is now set per call from the drawing window's offset (hud::DrawOffsetX) instead of fixed to the render width - input: drop the Ctrl/Alt pass-through; GetKeyState reports Alt as held after Alt+Tab, which switched all bindings back to the game's handling Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
037fc73158
commit
e914bd1590
4 files changed
+50
-14
No files matched your search
+37
-7
@@ -10,11 +10,13 @@
|
||||
// the zoom buttons at the bottom stay centred. The window is drawn and clicked
|
||||
// unshifted (mods/hud.cpp, Anchor::Screen). See docs/hud.md.
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "game/addresses.h"
|
||||
#include "mods/hud.h"
|
||||
#include "mods/megamap.h"
|
||||
#include "mods/widescreen.h"
|
||||
#include "re/hook.h"
|
||||
@@ -37,12 +39,16 @@ constexpr uint32_t kScrollLimit = 0x006c9edd;
|
||||
// The view centre 200h: the zoom-in frame (0x6ca53f) and the image centred
|
||||
// on it (0x6ca637, 0x6ca645).
|
||||
constexpr uint32_t kCentreImmediates[] = {0x006ca53f, 0x006ca637, 0x006ca645};
|
||||
// fsub/fld/fadd [512.0]: centring the scroll on the hero (opening the map
|
||||
// 0x6c7bfe, 0x6cb27a), the zoomed view (0x6ccb7f) and its quest markers
|
||||
// (0x6cf782).
|
||||
constexpr uint32_t kCentreFloatUses[] = {0x006c7bfe, 0x006cb27a, 0x006ccb7f, 0x006cf782};
|
||||
// fld [768.0] as an x: markers in the zoomed view at 768 - d (0x6ce156), the
|
||||
// centre plus 256.
|
||||
// fsub [512.0]: centring the scroll on the hero (opening the map 0x6c7bfe,
|
||||
// 0x6cb27a).
|
||||
constexpr uint32_t kCentreFloatUses[] = {0x006c7bfe, 0x006cb27a};
|
||||
// The zoomed view (0x6cc950, cdecl) is drawn by the large map and by the TAB
|
||||
// overview map (cUI_OverviewMap 0x6c69d0, a centred window: shifted by the
|
||||
// HUD layer). Its centre: fld [512.0] (0x6ccb7f), quest markers fadd [512.0]
|
||||
// (0x6cf782), other markers fld [768.0] as an x, 768 - d = centre + 256
|
||||
// (0x6ce156). It is set on every call from the window's draw offset.
|
||||
constexpr uint32_t kZoomView = 0x006cc950;
|
||||
constexpr uint32_t kZoomCentreUses[] = {0x006ccb7f, 0x006cf782};
|
||||
constexpr uint32_t kZoomMarkerX = 0x006ce156;
|
||||
constexpr float kZoomMarkerFromCentre = 256.0f;
|
||||
// The dark band around the view (10 vertices, mov [esp+..], imm32): its right
|
||||
@@ -52,6 +58,7 @@ constexpr uint32_t kBandRightInner[] = {0x006ca7bc, 0x006ca84c};
|
||||
constexpr int kBandWidth = 70;
|
||||
|
||||
float g_halfWidth = 512.0f;
|
||||
float g_zoomCentre = 512.0f;
|
||||
float g_zoomMarkerX = 768.0f;
|
||||
|
||||
uint32_t FloatBits(float value) {
|
||||
@@ -172,7 +179,9 @@ void PatchLayout(int width) {
|
||||
for (uint32_t instruction : kCentreFloatUses) {
|
||||
failed += !re::RedirectOperand(instruction, game::addr::kScreenHalfWidthF, &g_halfWidth);
|
||||
}
|
||||
g_zoomMarkerX = g_halfWidth + kZoomMarkerFromCentre;
|
||||
for (uint32_t instruction : kZoomCentreUses) {
|
||||
failed += !re::RedirectOperand(instruction, game::addr::kScreenHalfWidthF, &g_zoomCentre);
|
||||
}
|
||||
failed += !re::RedirectOperand(kZoomMarkerX, game::addr::kScreenHeightF, &g_zoomMarkerX);
|
||||
failed += re::PatchAll(kBandRightOuter, FloatBits(1024.0f), FloatBits(static_cast<float>(width)));
|
||||
failed += re::PatchAll(kBandRightInner, FloatBits(1024.0f - kBandWidth),
|
||||
@@ -180,10 +189,31 @@ void PatchLayout(int width) {
|
||||
re::Log("megamap: view width %d%s", width, failed ? " (some patches FAILED)" : "");
|
||||
}
|
||||
|
||||
// Before each zoomed view: its centre in the coordinates of the window that
|
||||
// draws it (the large map is unshifted: width / 2; a centred window, which
|
||||
// the HUD layer shifts: 512).
|
||||
void __cdecl SetZoomCentre() {
|
||||
const int width = std::max(mods::widescreen::RenderWidth(), kLayoutWidth);
|
||||
g_zoomCentre = width / 2.0f - static_cast<float>(mods::hud::DrawOffsetX());
|
||||
g_zoomMarkerX = g_zoomCentre + kZoomMarkerFromCentre;
|
||||
}
|
||||
|
||||
} // namespace mods::megamap
|
||||
|
||||
namespace game {
|
||||
|
||||
// The zoomed view (0x6cc950, cdecl): sets its centre, then runs it unchanged.
|
||||
void ZoomView();
|
||||
RE_HOOK(mods::megamap::kZoomView, ZoomView);
|
||||
__declspec(naked) void ZoomView() {
|
||||
__asm {
|
||||
pushad
|
||||
call mods::megamap::SetZoomCentre
|
||||
popad
|
||||
jmp dword ptr [ZoomView_original]
|
||||
}
|
||||
}
|
||||
|
||||
// cUI_Megamap::Show (vf24 0x6c7930, the argument: show / hide).
|
||||
void __fastcall UiMegamap_Show(void* self, void* edx, int show);
|
||||
RE_HOOK(0x006c7930, UiMegamap_Show);
|
||||
|
||||
Reference in new issue
Block a user