Files
wowdecomp/Engine/Source/Frame/CSimpleScrollFrame_Scripts.cpp
T
SatyandClaude Opus 5.5 34770ee7ab Frame: port Engine/Frame (waves 1-4), 1667 of 1669 functions
Core (CSimpleFrame + Lua, CSimpleTop/CFrameStrata/CSimpleRender/
CRenderBatch, CSimpleRegion/CBackdropGenerator/CScriptRegion), animation,
text (FontString/Font/Fontable), texture and model, buttons, EditBox,
MessageFrame/MessageScrollFrame, MovieFrame/ColorSelect/StatusBar,
Slider/ScrollFrame/HTML/HyperlinkedFrame, all Lua method tables and
RegisterScriptMethods. Layouts, vtables and sizes rebuilt from the
12340 ctors, vtables and allocator initializers; CScriptObject vtable
slots 5/6 fixed; CSimpleFontedFrame is a real secondary base. Lua error
paths return after luaL_error as in 12340 (209 sites; 5 fall through).
Binary quirks kept and documented in docs/.

Supporting additions: Event key/char/ime/focus/size event headers,
Scrn/Scrn.h (ScrnLayerCreate), DivxDecoder import declarations,
C2Vector/CRect helpers, CM2Light dtor, OsInputEnableSecureMode, stpl.h
instance addresses, FrameXML LoadXML_AnimGroup/Create_SimpleMovieFrame.
Engine->WoW includes where 12340 calls directly: CSimpleModelFFX,
StringToMouseButton, GetDeclinedWord, EmblemTextureUpdate.

Also drops stale VERIFY stamps found invalid by the harness recheck.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-09-27 15:32:18 +02:00

215 lines
7.8 KiB
C++

#include <cstddef>
#include <cstdint>
#include "Engine/Source/Frame/CSimpleScrollFrame.h"
#include "Engine/Source/Base/Coordinate.h"
#include "Engine/Source/Frame/CScriptObject.h"
#include "Engine/Source/Frame/CSimpleFrame.h"
#include "Engine/Source/Frame/CSimpleTop.h"
#include "Engine/Source/FrameScript/FrameScript.h"
#include "Engine/Source/FrameScript/FrameScript_Object.h"
#include "Engine/Source/lua-5.1/src/lauxlib.h"
#include "Engine/Source/lua-5.1/src/lua.h"
// VERIFY: 37637b0d manual
// OFFSET: 0x00972210
static int32_t Script_SetScrollChild(lua_State* L) {
CSimpleScrollFrame* scrollFrame = static_cast<CSimpleScrollFrame*>(FrameScript_GetObjectThis(L, CSimpleScrollFrame::GetObjectType()));
if (lua_type(L, 2) == LUA_TNIL) {
scrollFrame->SetScrollChild(nullptr);
return 0;
}
CSimpleFrame* child = nullptr;
if (lua_isstring(L, 2)) {
child = static_cast<CSimpleFrame*>(CScriptObject::GetScriptObjectByName(lua_tolstring(L, 2, nullptr), CSimpleFrame::GetObjectType()));
} else if (lua_type(L, 2) == LUA_TTABLE) {
lua_rawgeti(L, 2, 0);
child = static_cast<CSimpleFrame*>(lua_touserdata(L, -1));
lua_settop(L, -2);
if (!child) {
const char* name = scrollFrame->GetName();
luaL_error(L, "%s:SetScrollChild(): Couldn't find 'this' in child object", name ? name : "<unnamed>");
return 0;
}
if (!child->IsA(CSimpleFrame::GetObjectType())) {
luaL_error(L, "%s:SetScrollChild(): Wrong child object type, expected frame", scrollFrame->GetDisplayName());
return 0;
}
}
if (!child) {
const char* name = scrollFrame->GetName();
luaL_error(L, "%s:SetScrollChild(): Couldn't find frame named '%s'", name ? name : "<unnamed>", lua_tolstring(L, 2, nullptr));
return 0;
}
if (!child->ProtectedFunctionsAllowed()) {
if (CSimpleTop::s_instance->m_actionBlockedCallback) {
CSimpleTop::s_instance->m_actionBlockedCallback(scrollFrame);
}
return 0;
}
for (CSimpleFrame* frame = scrollFrame; frame; frame = frame->m_parent) {
if (frame == child) {
const char* childName = child->GetName();
const char* name = scrollFrame->GetName();
luaL_error(L, "%s:SetScrollChild(): Would create a loop adding child %s", name ? name : "<unnamed>", childName ? childName : "<unnamed>");
return 0;
}
}
scrollFrame->SetScrollChild(child);
return 0;
}
// VERIFY: 75857c97 manual
// OFFSET: 0x00972410
static int32_t Script_GetScrollChild(lua_State* L) {
CSimpleScrollFrame* scrollFrame = static_cast<CSimpleScrollFrame*>(FrameScript_GetObjectThis(L, CSimpleScrollFrame::GetObjectType()));
CSimpleFrame* child = scrollFrame->m_scrollChild;
if (!child) {
lua_pushnil(L);
return 1;
}
if (!child->m_luaRegistered) {
child->RegisterScriptObject(nullptr);
}
lua_rawgeti(L, LUA_REGISTRYINDEX, child->m_luaObjectRef);
return 1;
}
// VERIFY: b554b7b2 auto
// OFFSET: 0x00972490
static int32_t Script_SetHorizontalScroll(lua_State* L) {
CSimpleScrollFrame* scrollFrame = static_cast<CSimpleScrollFrame*>(FrameScript_GetObjectThis(L, CSimpleScrollFrame::GetObjectType()));
if (!scrollFrame->ProtectedFunctionsAllowed()) {
if (CSimpleTop::s_instance->m_actionBlockedCallback) {
CSimpleTop::s_instance->m_actionBlockedCallback(scrollFrame);
}
return 0;
}
if (lua_isnumber(L, 2)) {
float offset = static_cast<float>(lua_tonumber(L, 2));
scrollFrame->SetHorizontalScroll(NDCToDDCWidth(offset / (CoordinateGetAspectCompensation() * 1024.0f)));
return 0;
}
const char* name = scrollFrame->GetName();
luaL_error(L, "Usage: %s:SetHorizontalScroll(offset)", name ? name : "<unnamed>");
return 0;
}
// VERIFY: 3469e010 auto
// OFFSET: 0x00972560
static int32_t Script_SetVerticalScroll(lua_State* L) {
CSimpleScrollFrame* scrollFrame = static_cast<CSimpleScrollFrame*>(FrameScript_GetObjectThis(L, CSimpleScrollFrame::GetObjectType()));
if (!scrollFrame->ProtectedFunctionsAllowed()) {
if (CSimpleTop::s_instance->m_actionBlockedCallback) {
CSimpleTop::s_instance->m_actionBlockedCallback(scrollFrame);
}
return 0;
}
if (lua_isnumber(L, 2)) {
float offset = static_cast<float>(lua_tonumber(L, 2));
scrollFrame->SetVerticalScroll(NDCToDDCWidth(offset / (CoordinateGetAspectCompensation() * 1024.0f)));
return 0;
}
const char* name = scrollFrame->GetName();
luaL_error(L, "Usage: %s:SetVerticalScroll(offset)", name ? name : "<unnamed>");
return 0;
}
// VERIFY: 30b3f47c manual
// OFFSET: 0x00972630
static int32_t Script_GetHorizontalScroll(lua_State* L) {
CSimpleScrollFrame* scrollFrame = static_cast<CSimpleScrollFrame*>(FrameScript_GetObjectThis(L, CSimpleScrollFrame::GetObjectType()));
lua_pushnumber(L, DDCToNDCWidth(CoordinateGetAspectCompensation() * 1024.0f * scrollFrame->m_scrollOffset.x));
return 1;
}
// VERIFY: e13915c9 manual
// OFFSET: 0x00972690
static int32_t Script_GetVerticalScroll(lua_State* L) {
CSimpleScrollFrame* scrollFrame = static_cast<CSimpleScrollFrame*>(FrameScript_GetObjectThis(L, CSimpleScrollFrame::GetObjectType()));
lua_pushnumber(L, DDCToNDCWidth(CoordinateGetAspectCompensation() * 1024.0f * scrollFrame->m_scrollOffset.y));
return 1;
}
// VERIFY: c56f5f68 manual
// OFFSET: 0x009726F0
static int32_t Script_GetHorizontalScrollRange(lua_State* L) {
CSimpleScrollFrame* scrollFrame = static_cast<CSimpleScrollFrame*>(FrameScript_GetObjectThis(L, CSimpleScrollFrame::GetObjectType()));
lua_pushnumber(L, DDCToNDCWidth(CoordinateGetAspectCompensation() * 1024.0f * scrollFrame->m_scrollRange.x));
return 1;
}
// VERIFY: 3492a4da manual
// OFFSET: 0x00972750
static int32_t Script_GetVerticalScrollRange(lua_State* L) {
CSimpleScrollFrame* scrollFrame = static_cast<CSimpleScrollFrame*>(FrameScript_GetObjectThis(L, CSimpleScrollFrame::GetObjectType()));
lua_pushnumber(L, DDCToNDCWidth(CoordinateGetAspectCompensation() * 1024.0f * scrollFrame->m_scrollRange.y));
return 1;
}
// VERIFY: 02c2e551 manual
// OFFSET: 0x009727B0
static int32_t Script_UpdateScrollChildRect(lua_State* L) {
CSimpleScrollFrame* scrollFrame = static_cast<CSimpleScrollFrame*>(FrameScript_GetObjectThis(L, CSimpleScrollFrame::GetObjectType()));
scrollFrame->m_scrollChildUpdate = 1;
return 0;
}
// STATIC: 0x00B2CE90
static FrameScript_Method s_ScriptMethods[] = {
{ "SetScrollChild", &Script_SetScrollChild },
{ "GetScrollChild", &Script_GetScrollChild },
{ "SetHorizontalScroll", &Script_SetHorizontalScroll },
{ "SetVerticalScroll", &Script_SetVerticalScroll },
{ "GetHorizontalScroll", &Script_GetHorizontalScroll },
{ "GetVerticalScroll", &Script_GetVerticalScroll },
{ "GetHorizontalScrollRange", &Script_GetHorizontalScrollRange },
{ "GetVerticalScrollRange", &Script_GetVerticalScrollRange },
{ "UpdateScrollChildRect", &Script_UpdateScrollChildRect },
};
// VERIFY: 144bac6f auto
// OFFSET: 0x009721C0
void CSimpleScrollFrame::RegisterScriptMethods(lua_State* L) {
CSimpleFrame::RegisterScriptMethods(L);
FrameScript_Object::FillScriptMethodTable(L, s_ScriptMethods, sizeof(s_ScriptMethods) / sizeof(s_ScriptMethods[0]));
}
// VERIFY: bef254f0 auto
// OFFSET: 0x009721E0
void CSimpleScrollFrame::DestroyScriptMetaTable() {
luaL_unref(FrameScript_GetContext(), LUA_REGISTRYINDEX, CSimpleScrollFrame::s_metatable);
CSimpleScrollFrame::s_metatable = LUA_NOREF;
}
// VERIFY: a912e40f auto
// OFFSET: 0x009727F0
void CSimpleScrollFrame::CreateScriptMetaTable() {
CSimpleScrollFrame::s_metatable = FrameScript_Object::CreateScriptMetaTable(FrameScript_GetContext(), &CSimpleScrollFrame::RegisterScriptMethods);
}