-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFViewDetail.lua
More file actions
211 lines (180 loc) · 6.72 KB
/
Copy pathFViewDetail.lua
File metadata and controls
211 lines (180 loc) · 6.72 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
--[[
玩家详情
]]
local UIBase = require_ex("ui.base.UIBase")
local M = class("FViewDetail", UIBase)
local ListCol = 4
function M:ctor(data)
self.effRipple = true
self.effDark = true
UIBase.ctor(self)
self:init(data)
end
function M:init(data)
self._BindWidget = {
["panel_touch"] = {handle = handler(self, self.onClose)},
["panel_center/btn_confirm"] = {key = "btn_confirm", handle = handler(self, self.onConfirm)},
["panel_center/txt_emoji"] = {key = "txt_emoji"},
["panel_center/txt_magic"] = {key = "txt_magic"},
["panel_center/txt_magic/txt_magic_cost"] = {key = "txt_magic_cost"},
["panel_center/txt_name"] = {key = "txt_name"},
["panel_center/panel_head/img_head"] = {key = "img_head"},
["panel_center/txt_VIP"] = {key = "txt_vip"},
["panel_center/txt_ID"] = {key = "txt_id"},
["panel_center/txt_cannon"] = {key = "txt_cannon"},
["panel_center/panel_fee"] = {key = "panel_fee"},
["panel_center/panel_fee/txt_fee"] = {key = "txt_fee"},
["panel_center/lv_list"] = {key = "lv_list"},
["point_marquee"] = {},
["temp_list"] = {},
}
self._pid = 0
self:initViews(data)
end
function M:initViews(data)
local uiNode = createCsbNode("subgame/catchFish/personage.csb")
self:addChild(uiNode, 1)
self._rootNode = uiNode
bindWidgetList(uiNode, self._BindWidget, self._widgets)
local tag = self._widgets.temp_list:getTag()
if tag < 10 then
ListCol = tag
end
if Assist.isEmpty(data) then
self:initMyInfo()
else
self:initOtherInfo(data)
end
end
function M:initMyInfo()
self._widgets.txt_emoji:setVisible(true)
self._widgets.txt_magic:setVisible(false)
local v = {
uid = Game:doPluginAPI("get", "playerUid"),
nick = Game:doPluginAPI("get", "playerName"),
facelook = Game:doPluginAPI("get", "playerIcon"),
lottery = Game:doPluginAPI("get", "playerLottery"),
vip = Game:doPluginAPI("get", "playerVIP"),
cannon = Game.fishDB:getPlayerCannonLv(),
}
local cannonLv = v.cannon or 1
local cannon = BYCannonLevelConfig.cannon_multiple(cannonLv) or cannonLv
Game:doPluginAPI("set", "headIcon", self._widgets.img_head, v.facelook, true)
self._widgets.txt_id:setString("ID:"..v.uid)
self._widgets.txt_name:setString(v.nick)
Assist.checkTTF(self._widgets.txt_name)
self._widgets.txt_cannon:setString(Config.localize("detail_cannon")..cannon)
if Game:funcIsOpen("vip") then
self._widgets.txt_vip:setString("VIP"..checknumber(v.vip))
else
self._widgets.txt_vip:setVisible(false)
end
if Game:funcIsOpen("exchange") then
self._widgets.txt_fee:setString(string.format("%.2f%s", v.lottery/100, Config.localize("recharge_yuan")))
else
self._widgets.panel_fee:setVisible(false)
end
local emojis = BYEmojiConfig.getIds()
table.sort(emojis)
local idx, clone, item, cfg = 1
for i, eid in ipairs(emojis) do
cfg = BYEmojiConfig[eid]
if not clone or idx > ListCol then
clone = self._widgets.temp_list:clone()
clone:setVisible(true)
self._widgets.lv_list:pushBackCustomItem(clone)
idx = 1
end
item = clone:getChildByName("img_icon_"..idx)
fitIconSize(item, cfg.icon)
item:setTag(i)
item:setVisible(true)
bindClickFunc(item, handler(self, self.onEmoji))
idx = idx + 1
end
self._widgets.lv_list:jumpToTop()
end
function M:initOtherInfo(v)
self._widgets.txt_emoji:setVisible(false)
self._widgets.txt_magic:setVisible(true)
if self._widgets.txt_magic_cost then
self._widgets.txt_magic_cost:setString(Game.fishDB:getMagicCost())
end
local cannon = BYCannonLevelConfig.cannon_multiple(v.cannon_lv or 1)
Game:doPluginAPI("set", "headIcon", self._widgets.img_head, v.facelook)
self._pid = v.player_id
self._widgets.txt_id:setString("ID:"..v.player_id)
self._widgets.txt_name:setString(v.name)
Assist.checkTTF(self._widgets.txt_name)
self._widgets.txt_cannon:setString(Config.localize("detail_cannon")..cannon)
if Game:funcIsOpen("vip") then
self._widgets.txt_vip:setString("VIP"..checknumber(v.vip))
else
self._widgets.txt_vip:setVisible(false)
end
if Game:funcIsOpen("exchange") and v.lottery then
self._widgets.txt_fee:setString(string.format("%.2f%s", v.lottery/100, Config.localize("recharge_yuan")))
else
self._widgets.panel_fee:setVisible(false)
end
local emojis = MagicEmojiConfig.getIds()
table.sort(emojis)
local idx, clone, item, cfg = 1
for i, eid in ipairs(emojis) do
cfg = MagicEmojiConfig[eid]
if not clone or idx > ListCol then
clone = self._widgets.temp_list:clone()
clone:setVisible(true)
self._widgets.lv_list:pushBackCustomItem(clone)
idx = 1
end
item = clone:getChildByName("img_icon_"..idx)
fitIconSize(item, cfg.icon)
item:setTag(i)
item:setVisible(true)
bindClickFunc(item, handler(self, self.onMagicEmoji))
idx = idx + 1
end
self._widgets.lv_list:jumpToTop()
if not Game:doPluginAPI("get", "friend", self._pid) and Game:funcIsOpen("friend") then
self._canAddFriend = true
self._widgets.btn_confirm:setTitleString(Config.localize("add_friend"))
end
end
----------------------------------
-- 交互及回调
function M:onEmoji(sender)
local eid = sender:getTag()
Game:doPluginAPI("send", "chat", eid, Game:doPluginAPI("get", "playerUid"))
self:onClose()
end
function M:onMagicEmoji(sender)
if Game:doPluginAPI("get", "playerCoin") < Game.fishDB:getMagicCost() then
Game:tipMsg(Config.localize("magic_goldless"))
else
local mid = sender:getTag()
Game:doPluginAPI("send", "chat", {magic=mid}, self._pid)
self:onClose()
end
end
function M:onConfirm()
if self._canAddFriend then
Game:doPluginAPI("add", "friend", self._pid, function()
self._canAddFriend = false
self._widgets.btn_confirm:setTitleString(Config.localize("que_ding"))
end)
else
self:onClose()
end
end
function M:getOtherPlayerUid()
return self._pid or 0
end
function M:onEnter()
UIBase.onEnter(self)
if self._widgets.point_marquee then
local pos = cc.p(self._widgets.point_marquee:getPosition())
Game:doPluginAPI("move", "marquee", pos)
end
end
return M