新增Item绘制接口HOOK
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
|
||||
class Rindro_Item {
|
||||
//C指针
|
||||
C_Object = null;
|
||||
//绘制信息结构体
|
||||
DrawInfo = null;
|
||||
|
||||
constructor() {
|
||||
|
||||
@@ -24,6 +26,15 @@ class Rindro_Item {
|
||||
function SetIndex(Index) {
|
||||
NativePointer(C_Object).add(0x1C).writeInt(Index);
|
||||
}
|
||||
//获取名字
|
||||
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);
|
||||
@@ -64,4 +75,172 @@ class Rindro_Item {
|
||||
function SetEnchanting(Enchanting) {
|
||||
MemoryTool.EncodeMemoryData(C_Object + 0x1084, Enchanting);
|
||||
}
|
||||
}
|
||||
//读取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;
|
||||
//信息
|
||||
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();
|
||||
local UpgradeStr = UpgradeLevel > 0 ? (UpgradeLevel + " ") : "";
|
||||
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 {
|
||||
AddDividing(26, 15);
|
||||
//第二道分割线下面
|
||||
if (GuidanceInformationFlag > 4) {
|
||||
//有自定义的代理内容则添加
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
//增加内容
|
||||
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");
|
||||
Reference in New Issue
Block a user