-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtargetinfo.lua
More file actions
155 lines (129 loc) · 4.8 KB
/
targetinfo.lua
File metadata and controls
155 lines (129 loc) · 4.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
function TARGET_INFO_SECURITY_RISK()
if _G["TARGETINFO_ON_MSG_OLD"] == nil then
_G["TARGETINFO_ON_MSG_OLD"] = _G["TARGETINFO_ON_MSG"];
_G["TARGETINFO_ON_MSG"] = TARGETINFO_ON_MSG_HOOKED;
else
_G["TARGETINFO_ON_MSG"] = TARGETINFO_ON_MSG_HOOKED;
end
if _G["TGTINFO_TARGET_SET_OLD"] == nil then
_G["TGTINFO_TARGET_SET_OLD"] = _G["TGTINFO_TARGET_SET"];
_G["TGTINFO_TARGET_SET"] = TGTINFO_TARGET_SET_HOOKED;
else
_G["TGTINFO_TARGET_SET"] = TGTINFO_TARGET_SET_HOOKED;
end
end
function TGTINFO_TARGET_SET_HOOKED(frame, msg, argStr, argNum)
if argStr == "None" then
return;
end
local stat = info.GetStat(session.GetTargetHandle());
if stat == nil then
return;
end
local targetinfo = info.GetTargetInfo( session.GetTargetHandle() );
if nil == targetinfo then
return
end
-- local ifp = info.GetIFP(session.GetTargetHandle());
-- local mifp = info.GetMIFP(session.GetTargetHandle());
-- ui.SysMsg(ifp .. " " .. mifp);
-- local wiki = session.GetWikiByName(session.GetTargetHandle());
-- dumpTable(session);
local numhp = frame:CreateOrGetControl("richtext", "numhp", -17, 0, 176, 115);
tolua.cast(numhp, "ui::CRichText");
numhp:ShowWindow(1);
numhp:SetGravity(ui.CENTER_HORZ, ui.TOP);
numhp:SetTextAlign("center", "center");
numhp:SetText(stat.HP .. "/" .. stat.maxHP);
numhp:SetFontName("white_16_ol");
frame:Resize(480, frame:GetHeight())
frame:SetGravity(ui.CENTER_HORZ, ui.TOP);
TARGET_INFO_OFFSET_X = 710
frame:SetMargin(0,196,0,0);
local nametext = GET_CHILD(frame, "name", "ui::CRichText");
nametext:SetGravity(ui.CENTER_HORZ, ui.TOP);
nametext:SetMargin(0, 80, 0, 0)
if targetinfo.attribute ~= nil then
local attribute = frame:CreateOrGetControl("picture", "attribute", 0, 0, 100, 40);
tolua.cast(attribute, "ui::CPicture");
attribute:ShowWindow(1);
attribute:SetGravity(ui.LEFT, ui.TOP);
attribute:SetImage('Attri_' .. targetinfo.attribute);
attribute:SetMargin(350, 9, 0, 0);
attribute:SetTextAlign("right", "center");
attribute:SetText(targetinfo.attribute);
attribute:SetFontName("white_16_ol");
end
if targetinfo.armorType ~= nil then
local armorType = frame:CreateOrGetControl("picture", "armorType", 0, 0, 100, 40);
tolua.cast(armorType, "ui::CPicture");
armorType:ShowWindow(1);
armorType:SetGravity(ui.LEFT, ui.TOP);
armorType:SetImage('Armor_' .. targetinfo.armorType);
armorType:SetMargin(350, 40, 0, 0);
armorType:SetTextAlign("right", "center");
armorType:SetText(targetinfo.armorType);
armorType:SetFontName("white_16_ol");
end
if targetinfo.raceType ~= nil then
local raceType = frame:CreateOrGetControl("picture", "raceType", 0, 0, 100, 40);
tolua.cast(raceType, "ui::CPicture");
raceType:ShowWindow(1);
raceType:SetGravity(ui.LEFT, ui.TOP);
raceType:SetMargin(350, 71, 0, 0);
raceType:SetImage('Tribe_' .. targetinfo.raceType);
-- dumpTable(raceType);
raceType:SetTextAlign("right", "center");
raceType:SetText(targetinfo.raceType);
raceType:SetFontName("white_16_ol");
-- local raceTypeText = frame:CreateOrGetControl("richtext", "raceTypeText", 40, 0, 176, 50);
-- tolua.cast(raceTypeText, "ui::CRichText");
-- raceTypeText:ShowWindow(1);
-- raceTypeText:SetGravity(ui.CENTER_HORZ, ui.TOP);
-- raceTypeText:SetTextAlign("center", "center");
-- raceTypeText:SetText("");
-- raceTypeText:SetFontName("white_16_ol");
end
if targetinfo.size ~= nil then
local targetSizeText = frame:CreateOrGetControl("richtext", "targetSizeText", 0, 0, 60, 50);
tolua.cast(targetSizeText, "ui::CRichText");
targetSizeText:ShowWindow(1);
targetSizeText:SetGravity(ui.CENTER_HORZ, ui.TOP);
targetSizeText:SetMargin(90, 65, 0 , 0);
targetSizeText:SetTextAlign("center", "center");
targetSizeText:SetText('{@st43}'.. targetinfo.size .. '{@st53} ');
end
local oldf = _G["TGTINFO_TARGET_SET_OLD"];
return oldf(frame, msg, str, exp, tableinfo)
end
function TARGETINFO_ON_MSG_HOOKED(frame, msg, argStr, argNum)
if frame == nil then
return
end
if msg == 'TARGET_UPDATE' then
local stat = info.GetStat(session.GetTargetHandle());
if stat == nil then
return;
end
local targetinfo = info.GetTargetInfo( session.GetTargetHandle() );
local numhp = frame:CreateOrGetControl("richtext", "numhp", -17, 0, 176, 115);
tolua.cast(numhp, "ui::CRichText");
numhp:ShowWindow(1);
numhp:SetGravity(ui.CENTER_HORZ, ui.TOP);
numhp:SetTextAlign("center", "center");
numhp:SetText(stat.HP .. "/" .. stat.maxHP);
numhp:SetFontName("white_16_ol");
end
local oldf = _G["TARGETINFO_ON_MSG_OLD"];
return oldf(frame, msg, str, exp, tableinfo)
end
function dumpTable(table)
file = io.open("test-script3.txt", "w")
local status, err = pcall(function () file:write(DataDumper(getmetatable(table))); end);
if err ~= nil then
ui.SysMsg(err);
file:write(err);
end
file:close()
end
TARGET_INFO_SECURITY_RISK()