Rindro-Sqr/Base/_Tool/Item_Class.nut

249 lines
7.6 KiB
Plaintext
Raw Normal View History

class Rindro_Item {
2026-01-20 02:55:20 +08:00
//C指针
C_Object = null;
2026-01-20 02:55:20 +08:00
//绘制信息结构体
DrawInfo = null;
constructor() {
}
function LoadById(Index) {
local itemBuffer = Memory.alloc(0xD0);
L_Sq_CallFunc(0x65DE50, "pointer", FFI_FASTCALL, ["pointer", "int"], itemBuffer.C_Object, 0); //Fastcall 补位
C_Object = L_Sq_CallFunc(0x972220, "int", FFI_MS_CDECL, ["int", "pointer", "int"], Index, itemBuffer.C_Object, 1); //ID 后面的1未知
}
function LoadByAddress(Address) {
C_Object = Address;
}
//获取ID
function GetIndex() {
return NativePointer(C_Object).add(0x1C).readInt();
}
//设置ID
function SetIndex(Index) {
NativePointer(C_Object).add(0x1C).writeInt(Index);
}
2026-01-20 02:55:20 +08:00
//获取名字
function GetName() {
local NamePointer = NativePointer(C_Object).add(0x20).readInt();
return NativePointer(L_sq_I2P(NamePointer)).readUnicodeString();
}
//获取品级
function GetRarity() {
return NativePointer(C_Object).add(0xF4).readInt();
}
//获取强化值
function GetUpgrade() {
return MemoryTool.DecodeMemoryData(C_Object + 0x1054);
}
//设置强化值
function SetUpgrade(Upgrade) {
MemoryTool.EncodeMemoryData(C_Object + 0x1054, Upgrade);
}
//获取增幅属性
function GetAmplification() {
return MemoryTool.DecodeMemoryData(C_Object + 0x10A8);
}
//设置增幅属性
function SetAmplification(Amplification) {
MemoryTool.EncodeMemoryData(C_Object + 0x10A8, Amplification);
}
//获取锻造等级
function GetForging() {
return MemoryTool.DecodeMemoryData(C_Object + 0x10E8);
}
//设置锻造等级
function SetForging(Forging) {
MemoryTool.EncodeMemoryData(C_Object + 0x10E8, Forging);
}
//获取锻造属性
function GetForgingAttribute() {
return MemoryTool.DecodeMemoryData(C_Object + 0xE1C);
}
//设置锻造属性
function SetForgingAttribute(ForgingAttribute) {
MemoryTool.EncodeMemoryData(C_Object + 0xE1C, ForgingAttribute);
}
//获取附魔卡片ID
function GetEnchanting() {
return MemoryTool.DecodeMemoryData(C_Object + 0x1084);
}
//设置附魔卡片ID
function SetEnchanting(Enchanting) {
MemoryTool.EncodeMemoryData(C_Object + 0x1084, Enchanting);
}
2026-01-20 02:55:20 +08:00
//读取Uuid
function GetUuid() {
return NativePointer(C_Object).add(0x206).readInt();
}
//是否为装备
function IsEquip() {
return NativePointer(C_Object).add(0x4).readInt() == 2;
}
//是否为消耗品
function IsStack() {
return NativePointer(C_Object).add(0x4).readInt() == 1;
}
function ConstructDrawingInformation(...) {
if (!DrawInfo) {
DrawInfo = Rindro_Item_DrawInfo(this);
if (vargc > 0) {
DrawInfo.AddGuidanceInformation(vargv[0]);
}
DrawInfo.Init();
}
}
function Show(X, Y) {
//背景框
Rindro_BaseToolClass.DrawNineBox(X, Y, 214, DrawInfo.Height + 30, "interface2/common/mypopup/popup.img", 0);
// local C_Object = Rindro_Image_GlobalMap["popup"].GetPng(134);
// print(C_Object);
// L_Sq_CallFunc(0x11DF050, "void", FFI_FASTCALL, ["pointer", "int", "int", "int", "int", "int"], C_Object, 0, 10, 10, 10, 10);
foreach(info in DrawInfo.InfoList) {
//文字
if (info.Type == 0) {
L_sq_DrawCode(info.Content, X + info.X, Y + info.Y, info.Color, 0, 1);
} else if (info.Type == 1) {
Rindro_Image_GlobalMap["popup"].DrawPng(270, X + info.X, Y + info.Y);
} else if (info.Type == 2) {
info.Func(X + info.X, Y + info.Y, this);
}
}
}
}
class Rindro_Item_DrawInfo {
//Item对象
Item = null;
//指导信息 (原装备生成的信息)
GuidanceInformation = null;
//指导信息标志位
GuidanceInformationFlag = 0;
2026-02-02 13:30:37 +08:00
//分割线计数
GuidanceDivCount = 0;
2026-01-20 02:55:20 +08:00
//信息
InfoList = null;
Height = 0;
Padding = 8;
constructor(gItem) {
Item = gItem;
InfoList = [];
}
//添加指导信息
function AddGuidanceInformation(info) {
GuidanceInformation = info;
}
function Init() {
//读取强化等级
local UpgradeLevel = Item.GetUpgrade();
//读取名字
local Name = Item.GetName();
2026-02-02 13:30:37 +08:00
local UpgradeStr = UpgradeLevel > 0 ? ("+" + UpgradeLevel + " ") : "";
2026-01-20 02:55:20 +08:00
local NameStr = Name.len() > 0 ? (Name + " ") : "未定名";
AddContent((UpgradeStr + Name), Padding, Padding, Rindro_BaseToolClass.GetRarityColor(Item.GetRarity()));
if (isGm()) {
//读取编号
local Index = Item.GetIndex();
//读取uuid
local Uuid = Item.GetUuid();
local IndexStr = Index > 0 ? ("编号: [" + Index + "] ") : "";
local UuidStr = Uuid > 10000 ? ("uid: [" + Uuid + "] ") : "";
AddContent((IndexStr + UuidStr), Padding, 15, 0xffffffff);
}
for (local i = 1; i< GuidanceInformation.len(); i++) {
local info = GuidanceInformation[i];
if (info.Str && info.Str.len() > 0) {
local RealStr = format(info.Str);
if (info.Flag != GuidanceInformationFlag) {
AddContent(RealStr, Padding, 15, info.Color);
}
//说明要绘制在右侧这个左侧信息已经绘制过了
else {
local StrLength = LenheartTextClass.GetStringLength(RealStr);
AddContent(RealStr, 215 - StrLength - Padding, 0, info.Color);
}
} else {
2026-02-02 13:30:37 +08:00
GuidanceDivCount++;
2026-01-20 02:55:20 +08:00
AddDividing(26, 15);
//第二道分割线下面
2026-02-02 13:30:37 +08:00
if (GuidanceDivCount > 1) {
2026-01-20 02:55:20 +08:00
//有自定义的代理内容则添加
if (getroottable()["NewItemInfoWindow_Obj"].CustomDrawDelegate.len() > 0) {
//真正达成条件需要代理的Item
local RealCustomDrawDelegate = [];
//先遍历一遍检查条件是否成立
foreach(Name, Info in getroottable()["NewItemInfoWindow_Obj"].CustomDrawDelegate) {
if (Info.CheckFunc(Item) == true) RealCustomDrawDelegate.append(Info);
}
//需要代理的项
if (RealCustomDrawDelegate.len() > 0) {
foreach(Info in RealCustomDrawDelegate) {
AddDelegate(Info.Height, Info.Func);
}
AddDividing(26, 15);
}
}
}
}
GuidanceInformationFlag = info.Flag;
}
}
2026-02-02 13:30:37 +08:00
2026-01-20 02:55:20 +08:00
//增加内容
function AddContent(Content, X, Y, Color) {
InfoList.append({
Type = 0,
Content = Content,
X = X,
Y = Y + Height,
Color = Color
});
Height += Y;
}
//增加分割线
function AddDividing(X, Y) {
InfoList.append({
Type = 1,
X = X,
Y = Y + Height + 3,
});
Height += 8;
}
//增加自定义代理
function AddDelegate(Y, Func) {
InfoList.append({
Type = 2,
X = 0,
Y = Height,
Func = Func
});
Height += Y;
}
}
getroottable().rawdelete("NewItemInfoWindow_Obj");