yunque9/lua_probject/base_project/Game/View/NewGroup/MngView/GroupGameSettingView.lua

823 lines
32 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

-- 牌友圈玩法设置
local GroupNumberInputView = import(".GroupNumberInputView")
local GroupRoomColorView = import(".GroupRoomColorView")
local GameListView = require "Game/View/Lobby/GameListView"
local GroupGameSettingView = {}
local M = GroupGameSettingView
function GroupGameSettingView.new(blur_view, gid, pid, room_config, hpdata, callback)
setmetatable(M, { __index = BaseWindow })
local self = setmetatable({}, { __index = M })
self.class = "GroupGameSettingView"
self._animation = false
self._full = true
self._full_offset = false
self.selectedIndex = index
self._close_destroy = true
self._put_map = false
self._new_hide = false
self._queue = false
self.group_id = gid
self.play = DataManager.groups:get(gid):getPlay(pid)
self.table_color = self.play and self.play.deskId or 0
if room_config then
self.room_config = json.decode(room_config)
end
self.lastHpdata = hpdata
self.rewards_data = {}
self.callback = callback
self._full = true
self:init("ui://NewGroup/View_GroupGameSetting")
return self
end
function M:init(url)
BaseWindow.init(self, url)
self.hpData = {}
self:FillGameData()
self._view:GetChild("btn_next").onClick:Set(function()
if self._view:GetChild("tex_name").text == "" then
ViewUtil.ErrorTip(nil, "输入玩法名才能进入下一步")
return
end
local game_data = self.gl_view:GetModeData().data.game_data
if not game_data then
ViewUtil.ErrorTip(nil, "请先下载游戏")
return
end
self.rewards_data = {}
self:FillFagData()
self._view:GetController("page").selectedIndex = 1
end)
self._view:GetChild("btn_color").onClick:Set(function()
local grcv = GroupRoomColorView.new(self._root_view, self.table_color, function(index)
self.table_color = index
end)
grcv:Show()
end)
end
-- 显示游戏列表
function M:FillGameData()
local index = 1
-- 显示所有游戏
local games = DataManager.SelfUser.games
local lst_game = self._view:GetChild("lst_game")
-- local n65 = lst_game:GetChild("n65")
printlog("jefe all games")
pt(games)
-- n65.visible = false
for i = 1, #games do
local game = games[i]
if (self.room_config and self.room_config.game_id == game.game_id) or i == 1 then
index = i
end
end
self.gl_view = GameListView.new(lst_game, index, self.room_config)
local btn_close = lst_game:GetChild("btn_close")
btn_close.onClick:Set(function()
self:Destroy()
end)
-- 玩法名
if self.play then
local tex_name = self._view:GetChild("tex_name")
tex_name.text = self.play.name
end
end
local tuoguanTimeList = { 10, 30, 60, 120, 180, 240, 300 }
-- 显示玩法体力值配置
function M:FillFagData()
local mod = self.gl_view:GetModeData()
local game_id = mod.data.game_data.game_id
local panel_play_set = self._view:GetChild("panel_play_set")
local ctr_show_nonnegative = panel_play_set:GetController("show_nonnegative") --玩法不可负分开关
local btn_nonnegative = panel_play_set:GetChild("btn_nonnegative") --不可负分开关
local btn_no_upper = panel_play_set:GetChild("btn_no_upper") --没有上限
local btn_tuoguan = panel_play_set:GetChild("btn_tuoguan") --托管开关
btn_tuoguan.selected = true
local btn_BanDismiss = panel_play_set:GetChild("btn_BanDismiss")
local cb_tuoguan_time = panel_play_set:GetChild("comb_offline") --托管时间
local cb_tuoguan_type = panel_play_set:GetChild("comb_result") --托管结算类型
local btn_hidden = panel_play_set:GetChild("btn_hidden") --防作弊开关
local btn_vip = panel_play_set:GetChild("btn_vip") --vip房间开关
--根据hpType显示
local game_data = mod.data.game_data
panel_play_set:GetController("game_type").selectedIndex = game_data and game_data.hpType or 0
--体力值开关
local ctr_switch = panel_play_set:GetController("hp_switch")
local group = DataManager.groups:get(self.group_id)
if group.type == 2 then
ctr_switch.selectedIndex = 1
panel_play_set:GetController("type").selectedIndex = 1
end
local hpData
if self.play then
-- 如果有玩法信息加载玩法的hpdata
if self.play.hpOnOff == 1 then
hpData = json.decode(self.play.hpData)
end
local config = json.decode(self.play.config)
ctr_switch.selectedIndex = self.play.hpOnOff
btn_BanDismiss.selected = (config.isBanDismiss and config.isBanDismiss ~= 0) and true or false
btn_tuoguan.selected = (config.tuoguan and config.tuoguan ~= 0) and true or false
if btn_tuoguan.selected then
cb_tuoguan_time.value = config.tuoguan_active_timeIndex or 1
cb_tuoguan_type.value = config.tuoguan_result_type
end
if btn_hidden then
btn_hidden.selected = (config.isHidden and config.isHidden ~= 0) and true or false
end
if btn_vip then
btn_vip.selected = (config.isvip and config.isvip ~= 0) and true or false
end
btn_nonnegative.selected = config.isNonnegative and config.isNonnegative == 1
btn_no_upper.selected = config.hp_no_limit and config.hp_no_limit == 1
end
local game = DataManager.SelfUser:getGameData(game_id)
ctr_show_nonnegative.selectedIndex = game.isNonnegative
if game.isNonnegative == 0 then
btn_nonnegative.selected = false
btn_no_upper.selected = false
else
btn_nonnegative.selected = true
end
local panel_fag = panel_play_set:GetChild("panel_fag")
-- 加入限制
local btn_join_limit = panel_play_set:GetChild("btn_join_limit")
local tex_join_limit = panel_play_set:GetChild("tex_join_limit")
tex_join_limit.text = hpData and d2ad(hpData.limitInRoom) or 0
btn_join_limit.onClick:Set(function()
self:__input_num(tex_join_limit, "limitInRoom")
end)
--机器人
local btn_robot_room = panel_fag:GetChild("robot_room")
local tex_robot_room = panel_fag:GetChild("tex_robot_room")
tex_robot_room.text = hpData and (hpData.robot_room and (hpData.robot_room) or 0) or 0
btn_robot_room.onClick:Set(function()
self:__input_num(tex_robot_room, "robot_room")
end)
--抢庄限制
-- local btn_bank_limit = panel_play_set:GetChild("btn_bank_limit")
--local tex_bank_limit = panel_play_set:GetChild("tex_bank_limit")
-- tex_bank_limit.text = hpData and hpData.limitloot and d2ad(hpData.limitloot) or 0
-- btn_bank_limit.onClick:Set(function()
-- self:__input_num(tex_bank_limit,"limitloot")
-- end)
-- 退出限制
local btn_exit_limit = panel_play_set:GetChild("btn_exit_limit")
local tex_exit_limit = panel_play_set:GetChild("tex_exit_limit")
tex_exit_limit.text = hpData and hpData.limitPlay and d2ad(hpData.limitPlay) or 1
btn_exit_limit.onClick:Set(function()
-- self:__input_num(tex_exit_limit, "limitPlay")
local gfiv = GroupNumberInputView.new(self._root_view, function(num)
if num == 0 then
ViewUtil.ErrorMsg(nil, -9, "不能输入0")
return
end
tex_exit_limit.text = num
end)
gfiv:Show()
end)
--体力值倍数
local tex_times = panel_play_set:GetChild("tex_times")
if game_id ~= 41 then
tex_times.text = hpData and d2ad(hpData.times) or 1
local btn_times_input = panel_play_set:GetChild("btn_times_input")
btn_times_input.onClick:Set(function()
self:__input_num(tex_times, "times", 3)
end)
else
tex_times.text = 1
end
local btn_sub = panel_play_set:GetChild("btn_sub")
btn_sub.onClick:Set(function()
local value = tonumber(tex_times.text)
if value > 1 then
value = value - 1
tex_times.text = tostring(value)
end
end)
local btn_add = panel_play_set:GetChild("btn_add")
btn_add.onClick:Set(function()
local value = tonumber(tex_times.text)
value = value + 1
tex_times.text = tostring(value)
end)
--显示创建空房间
local tex_times_room = panel_play_set:GetChild("tex_times_room")
if hpData and hpData.tex_times_room then
tex_times_room.text = hpData.tex_times_room / 1000
else
tex_times_room.text = 1
end
local btn_sub_room = panel_play_set:GetChild("btn_sub_room")
btn_sub_room.onClick:Set(function()
local value = tonumber(tex_times_room.text)
if value > 1 then
value = value - 1
tex_times_room.text = tostring(value)
end
end)
local btn_add_room = panel_play_set:GetChild("btn_add_room")
btn_add_room.onClick:Set(function()
local value = tonumber(tex_times_room.text)
value = value + 1
tex_times_room.text = tostring(value)
end)
-- 显示抽水列表
if hpData and hpData.rewards_list then
self.rewards_data = hpData.rewards_list
else
local tem = {}
-- tem.limitPump = hpData and hpData.limitPump or 0
-- tem.type = hpData and hpData.type or 1
tem.pumpProportion = hpData and hpData.pumpProportion or 0
tem.UpperLimit = hpData and hpData.UpperLimit or 0
table.insert(self.rewards_data, tem)
end
self._type = hpData and hpData.type or 1
self._limitPump = hpData and tonumber(hpData.limitPump) or 0
self:UpdateRewards()
-- 编辑类型0是全显示1是显示百分比2是显示人头制, 3是全民推广
local ctr_edit_type = panel_fag:GetController("edit_type")
local ctr_edit_value_type = panel_fag:GetController("edit_value_type")
if not self.play then
ctr_edit_type.selectedIndex = 0
ctr_edit_value_type.selectedIndex = 0
elseif hpData then
ctr_edit_type.selectedIndex = self.play.rewardType
ctr_edit_value_type.selectedIndex = self.play.rewardValueType or 1
end
local ctr_edit_type1 = panel_fag:GetController("edit_type1")
local ctr_edit_value_type1 = panel_fag:GetController("edit_value_type1")
if not self.play then
ctr_edit_type1.selectedIndex = 0
ctr_edit_value_type1.selectedIndex = 0
elseif hpData then
ctr_edit_type1.selectedIndex = self.play.xipai_rewardType
ctr_edit_value_type1.selectedIndex = self.play.xipai_rewardValueType or 1
end
local ctr_rewards1 = panel_fag:GetController("rewards1")
ctr_rewards1.selectedIndex = 2
local ctr_rewards_value1 = panel_fag:GetController("rewards_value1")
-- 奖励类型0百分比 1人头制 2全民推广
if self.play then
ctr_rewards1.selectedIndex = self.play.xipai_rewardType - 1
ctr_rewards_value1.selectedIndex = (self.play.xipai_rewardValueType or 1) - 1
end
local ctr_rewards2 = panel_fag:GetController("rewards2")
ctr_rewards2.selectedIndex = 2
local ctr_rewards_value2 = panel_fag:GetController("rewards_value2")
-- 奖励类型0百分比 1人头制 2全民推广
if self.play then
-- ctr_rewards1.selectedIndex = self.play.xipai_rewardType - 1
ctr_rewards_value2.selectedIndex = (self.play.anchou_rewardValueType or 1) - 1
end
local base_pump = 0
if hpData ~= nil and hpData.basePump ~= nil then
base_pump = d2ad(hpData.basePump)
end
local tex_base_pump = panel_fag:GetChild("tex_base_pump")
tex_base_pump.text = "" .. base_pump
local btn_base_pump = panel_fag:GetChild("btn_base_pump")
btn_base_pump.onClick:Set(function()
self:__input_num(tex_base_pump, "basePump", 3)
end)
-- panel_fag:GetController("alliance").selectedIndex = group.type == 2 and 1 or 0
panel_fag:GetController("alliance").selectedIndex = 0
local ctr_rewards = panel_fag:GetController("rewards")
local ctr_rewards_value = panel_fag:GetController("rewards_value")
-- 奖励类型0百分比 1人头制 2全民推广
if self.play then
ctr_rewards.selectedIndex = self.play.rewardType - 1
ctr_rewards_value.selectedIndex = (self.play.rewardValueType or 1) - 1
end
-- 点击确定按钮 更新玩法数据
local btn_ok = self._view:GetChild("btn_ok")
btn_ok.onClick:Set(function()
local _data = mod.data:SelectedConfigData()
_data.game_id = game_id
_data.isNonnegative = btn_nonnegative.selected and 1 or 0
_data.hp_no_limit = (btn_nonnegative.selected and btn_no_upper.selected) and 1 or 0
_data.tuoguan = btn_tuoguan.selected
_data.tuoguan_active_time = _data.tuoguan and tuoguanTimeList[(tonumber(cb_tuoguan_time.value))] or 0
_data.tuoguan_active_timeIndex = tonumber(cb_tuoguan_time.value)
_data.tuoguan_result_type = _data.tuoguan and tonumber(cb_tuoguan_type.value) or 0
if btn_BanDismiss.selected then
_data.isBanDismiss = 1
end
if btn_hidden then
_data.isHidden = btn_hidden.selected and 1 or 0
else
_data.isHidden = 0
end
if btn_vip then
_data.isvip = btn_vip.selected and 1 or 0
else
_data.isvip = 0
end
local hpType = mod.data.game_data.hpType
self.hpData.limitInRoom = ad2d(tonumber(panel_play_set:GetChild("tex_join_limit").text))
self.hpData.limitPlay = ad2d(tonumber(panel_play_set:GetChild("tex_exit_limit").text))
self.hpData.limitloot = 0 -- ad2d(tonumber(panel_play_set:GetChild("tex_bank_limit").text))
self.hpData.robot_room = (tonumber(panel_fag:GetChild("tex_robot_room").text))
self.hpData.type = self._type
self.hpData.limitPump = self._limitPump
local hpOnOff = ctr_switch.selectedIndex
if game_id == 41 then
if self.hpData.limitloot < ad2d(_data.up_bank) then
ViewUtil.ErrorMsg(self._root_view, -9, "抢庄限制必须大于等于" .. _data.up_bank)
return
end
end
if hpType > 1 and hpOnOff == 1 then
if self.hpData.limitInRoom < self.hpData.limitPlay then
ViewUtil.ErrorMsg(self._root_view, -9, "进入限制必须大于等于退出限制")
return
end
if self.hpData.limitPlay == 0 then
ViewUtil.ErrorMsg(self._root_view, -9, "退出房间限制不能为0")
return
end
end
local times = tonumber(tex_times.text)
self.hpData.times = ad2d(tonumber(times))
local tex_times_room = tonumber(tex_times_room.text)
self.hpData.tex_times_room = ad2d(tonumber(tex_times_room))
local base_pump = tonumber(tex_base_pump.text)
self.hpData.basePump = ad2d(tonumber(base_pump))
self.hpData.rewards_list = {}
local lst_rewards = panel_fag:GetChild("lst_rewards")
for i = 1, lst_rewards.numItems do
local r_item = lst_rewards:GetChildAt(i - 1)
local tem = {}
-- 大赢家
-- self.hpData.limitPump = tonumber(cb_type.value)
-- tem.limitPump = tonumber(r_item:GetChild("cb_type").value)
-- 抽水次数 固定抽水要发小数
local cb_method = r_item:GetChild("cb_method")
local proportion = string.gsub(
string.gsub(r_item:GetChild("cb_proportion" .. cb_method.value).title, "", ""), "", "")
if cb_method.value == "1" then proportion = ad2d(proportion) end
-- 抽水分数
-- self.hpData.pumpProportion = tonumber(proportion)
tem.pumpProportion = tonumber(proportion)
if tonumber(cb_method.value) == 1 then
local v = string.gsub(r_item:GetChild("cb_min").title, "", "")
-- self.hpData.UpperLimit = ad2d(tonumber(v))
tem.UpperLimit = ad2d(tonumber(v))
local vsend = string.gsub(r_item:GetChild("cb_min_send").title, "", "")
tem.UpperLimitReward = ad2d(tonumber(vsend))
else
local v = string.gsub(r_item:GetChild("cb_max").title, "", "")
-- self.hpData.UpperLimit = ad2d(tonumber(v))
tem.UpperLimit = ad2d(tonumber(v))
end
-- tem.type = cb_method.value
table.insert(self.hpData.rewards_list, tem)
end
self.hpData.rewards_type = ctr_rewards.selectedIndex + 1
self.hpData.rewardValueType = ctr_rewards_value.selectedIndex + 1
self.hpData.xipai_rewardType = ctr_rewards1.selectedIndex + 1
self.hpData.xipai_rewardValueType = ctr_rewards_value1.selectedIndex + 1
self.hpData.anchou_rewardType = ctr_rewards2.selectedIndex + 1
self.hpData.anchou_rewardValueType = ctr_rewards_value2.selectedIndex + 1
if self.hpData.rewardValueType == 1 then
self.hpData.rewards_val = 100
else
self.hpData.rewards_val = ad2d(10000)
end
if self.hpData.xipai_rewardValueType == 1 then
self.hpData.xipai_rewards_val = 100
else
self.hpData.xipai_rewards_val = ad2d(10000)
end
if self.hpData.anchou_rewardValueType == 1 then
self.hpData.anchou_rewards_val = 100
else
self.hpData.anchou_rewards_val = ad2d(10000)
end
local tex_name = self._view:GetChild("tex_name")
local name = tex_name.text
print("jefe:")
pt(self.hpData)
local fgCtr = ControllerManager.GetController(NewGroupController)
ViewUtil.ShowModalWait(self._root_view)
if not self.play then
-- 新增玩法
fgCtr:FG_AddPlay(self.group_id, game_id, _data, name, self.hpData, hpOnOff, group.type, self.table_color,
function(res)
if self._is_destroy then
return
end
ViewUtil.CloseModalWait()
--print("======新增玩法=============")
--pt(res)
if res.ReturnCode == 0 then
local play = {}
play.name = name
play.deskId = self.table_color
play.game_name = mod.data.game_data.name
play.gameId = game_id
play.hpOnOff = hpOnOff
play.hpData = json.encode(self.hpData)
play.id = res.Data.pid
play.xipai_rewards_val = self.hpData.xipairewards_val
play.anchou_rewards_val = self.hpData.anchou_rewards_val
play.reward = self.hpData.rewards_val
play.rewardType = self.hpData.rewards_type
play.rewardValueType = self.hpData.rewardValueType
play.xipai_rewardType = self.hpData.xipai_rewardType
play.anchou_rewardType = 3
play.xipai_rewardValueType = self.hpData.xipai_rewardValueType
play.anchou_rewardValueType = 1
_data.maxPlayers = res.Data.maxPlayers
play.config = json.encode(_data)
play.hp_times = self.hpData.times
play.maxPlayers = _data.maxPlayers
play.roomNum = self.hpData.tex_times_room / 1000
play.maxRound = res.Data.maxRound
ViewUtil.ShowBannerOnScreenCenter("添加玩法成功")
self.callback(play)
self:Destroy()
else
ViewUtil.ErrorTip(res.ReturnCode, "添加玩法失败!")
end
end)
else
-- 修改玩法
fgCtr:FG_UpdatePlay(self.group_id, game_id, _data, name, self.hpData, hpOnOff, self.play.id, group.type,
self.table_color, function(res)
if self._is_destroy then
return
end
ViewUtil.CloseModalWait()
--print("======修改玩法=============")
--pt(res)
if res.ReturnCode == 0 then
local play = {}
play.name = name
play.deskId = self.table_color
play.game_name = mod.data.game_data.name
play.gameId = game_id
play.id = self.play.id
play.hpOnOff = hpOnOff
play.hpData = json.encode(self.hpData)
play.xipai_rewards_val = self.hpData.xipairewards_val
play.anchou_rewards_val = self.hpData.anchou_rewards_val
play.reward = self.hpData.rewards_val
play.rewardType = self.hpData.rewards_type
play.rewardValueType = self.hpData.rewardValueType
play.xipai_rewardType = self.hpData.xipai_rewardType
play.anchou_rewardType = 3
play.xipai_rewardValueType = self.hpData.xipai_rewardValueType
play.anchou_rewardValueType = 1
_data.maxPlayers = res.Data.maxPlayers
play.config = json.encode(_data)
play.hp_times = self.hpData.times
play.maxPlayers = _data.maxPlayers
play.roomNum = self.hpData.tex_times_room / 1000
play.maxRound = res.Data.maxRound
self.callback(play)
self:Destroy()
else
ViewUtil.ErrorTip(res.ReturnCode, "修改玩法失败!")
end
end)
end
end)
end
function M:UpdateRewards()
local lst_rewards = self._view:GetChild("panel_play_set"):GetChild("panel_fag"):GetChild("lst_rewards")
lst_rewards:RemoveChildrenToPool()
for i = 1, #self.rewards_data do
local item = lst_rewards:AddItemFromPool()
self:OnRenderItem(i, item)
end
lst_rewards.height = 120 * #self.rewards_data
end
function M:OnRenderItem(index, obj)
local data = self.rewards_data[index]
-- 抽水方法,固定、浮动
local cb_method = obj:GetChild("cb_method")
cb_method.value = 1
-- cb_method.onChanged:Set(function()
-- local tem = membe_clone(self.rewards_data[1])
-- tem.pumpProportion = 0
-- self._type = tonumber(cb_method.value)
-- self.rewards_data = {}
-- self.rewards_data[1] = tem
-- self:UpdateRewards()
-- end)
--大赢家
local tem = obj:GetController("c1").selectedIndex
for i = 1, 2 do
local cb_type = obj:GetChild("cb_type" .. i)
if self._limitPump <= 4 - tem then
cb_type.value = tostring(self._limitPump)
else
self._limitPump = tonumber(cb_type.value)
end
cb_type.onChanged:Set(function()
local limitPump = cb_type.value
self._limitPump = tonumber(limitPump)
self:UpdateRewards()
end)
end
-- hptype控制器根据不同的hptype显示
local ctr_type = obj:GetController("type")
ctr_type.selectedIndex = self.gl_view:GetModeData().data.game_data.hpType
self._type = tonumber(cb_method.value)
--抽水次数
local val = data.pumpProportion
if cb_method.value ~= tostring(self._type) then
val = 0
elseif cb_method.value == "1" then
val = d2ad(val)
end
local cb_proportion1 = obj:GetChild("cb_proportion1")
local cb_proportion2 = obj:GetChild("cb_proportion2")
print(cb_method.value)
obj:GetChild("cb_proportion" .. cb_method.value).title = "" .. val .. ""
cb_proportion1.onChanged:Set(function()
data.pumpProportion = ad2d(string.gsub(string.gsub(cb_proportion1.title, "", ""), "", ""))
end)
cb_proportion2.onChanged:Set(function()
local v = string.gsub(string.gsub(cb_proportion2.title, "", ""), "", "")
data.pumpProportion = tonumber(v)
end)
--抽水上限
local cb_max = obj:GetChild("cb_max")
--抽水门槛
local cb_min = obj:GetChild("cb_min")
local cb_min_send = obj:GetChild("cb_min_send")
local UpperLimit = d2ad(data.UpperLimit)
local UpperLimitReward = d2ad(data.UpperLimitReward or 0)
if tonumber(cb_method.value) == 1 then
cb_min.title = UpperLimit .. "" or "0分"
cb_min_send.title = UpperLimitReward .. "" or "0分"
if UpperLimitReward == 0 then
obj:GetController("give_owner").selectedIndex = 0
else
obj:GetController("give_owner").selectedIndex = 1
end
else
cb_max.value = UpperLimit .. ""
self:SetIndex(cb_max, d2ad(data.UpperLimit))
end
obj:GetController("give_owner").onChanged:Add(function()
if obj:GetController("give_owner").selectedIndex == 0 then
data.UpperLimitReward = 0
self:UpdateRewards()
end
end)
if cb_max.selectedIndex == -1 then
cb_max.selectedIndex = 0
end
if cb_min.selectedIndex == -1 then
cb_min.selectedIndex = 0
end
if cb_min_send.selectedIndex == -1 then
cb_min_send.selectedIndex = 0
end
-- 显示备注
local str_min_tip, str_max_tip
if index == 1 then
local tem = ""
local next_data = self.rewards_data[index + 1]
if next_data then
tem = string.format("小于%s", d2ad(next_data.UpperLimit))
end
local tem1 = ""
if UpperLimitReward ~= 0 then
tem1 = string.format(",每个玩家赠送盟主%s分", UpperLimitReward)
end
str_min_tip = string.format("(低于%s分不抽水%s)", UpperLimit, tem1)
-- str_max_tip = string.format("(低于%s按此设置抽水)", UpperLimit)
elseif index == #self.rewards_data then
str_min_tip = string.format("(大于等于%s按此设置抽水)", UpperLimit)
-- str_max_tip = string.format("(大于等于%s,小于%s按此设置抽水)", last_upper, UpperLimit)
else
local next_upper = d2ad(self.rewards_data[index + 1].UpperLimit)
str_min_tip = string.format("(大于等于%s,小于%s按此设置抽水)", UpperLimit, next_upper)
-- str_max_tip = string.format("(大于等于%s,小于%s按此设置抽水)", last_upper, UpperLimit)
end
obj:GetChild("tex_min_tip").text = str_min_tip
-- obj:GetChild("tex_max_tip").text = str_max_tip
local input_limit = 1000
local btn_input = obj:GetChild("btn_input")
btn_input.onClick:Set(function()
local gfiv = GroupNumberInputView.new(self._root_view, function(num)
if num > input_limit then
ViewUtil.ErrorMsg(self._root_view, -9, "输入最大不能超过" .. input_limit)
return
end
cb_proportion1.title = "" .. num .. ""
data.pumpProportion = ad2d(num)
end, 3)
gfiv:Show()
end)
local input_limit2 = 1000
local min_v, max_v = 0, input_limit2 + 1
if index > 1 then
local last_data = self.rewards_data[index - 1]
min_v = d2ad(last_data.UpperLimit)
end
if index < #self.rewards_data then
local next_data = self.rewards_data[index + 1]
max_v = d2ad(next_data.UpperLimit)
end
local btn_input2 = obj:GetChild("btn_input2")
btn_input2.onClick:Set(function()
local gfiv = GroupNumberInputView.new(self._root_view, function(num)
if num > input_limit2 then
ViewUtil.ErrorMsg(nil, -9, "输入值不能超过" .. input_limit2)
return
elseif num >= max_v then
ViewUtil.ErrorMsg(nil, -9, "输入值必须小于" .. max_v)
return
elseif num <= min_v then
ViewUtil.ErrorMsg(nil, -9, "输入值必须大于" .. min_v)
return
end
-- cb_min.title = num .. "分"
data.UpperLimit = ad2d(num)
self:UpdateRewards()
end, 3)
gfiv:Show()
end)
local btn_input2_send = obj:GetChild("btn_input2_send")
btn_input2_send.onClick:Set(function()
local gfiv = GroupNumberInputView.new(self._root_view, function(num)
data.UpperLimitReward = ad2d(num)
self:UpdateRewards()
end, 3)
gfiv:Show()
end)
cb_min.onChanged:Set(function()
local tem = string.gsub(cb_min.title, "", "")
local tem = tonumber(tem)
if tem > input_limit2 then
ViewUtil.ErrorMsg(nil, -9, "输入值不能超过" .. input_limit2)
return
elseif tem >= max_v then
cb_min.title = d2ad(data.UpperLimit) .. ""
ViewUtil.ErrorMsg(nil, -9, "输入值必须小于" .. max_v)
return
elseif tem <= min_v then
cb_min.title = d2ad(data.UpperLimit) .. ""
ViewUtil.ErrorMsg(nil, -9, "输入值必须大于" .. min_v)
return
end
data.UpperLimit = ad2d(string.gsub(cb_min.title, "", ""))
self:UpdateRewards()
end)
cb_min_send.onChanged:Set(function()
local tem = string.gsub(cb_min_send.title, "", "")
local tem = tonumber(tem)
data.UpperLimitReward = ad2d(string.gsub(cb_min_send.title, "", ""))
self:UpdateRewards()
end)
cb_max.onChanged:Set(function()
local tem = string.gsub(cb_max.title, "", "")
local tem = tonumber(tem)
if tem > max_v then
self:SetIndex(cb_max, d2ad(data.UpperLimit))
ViewUtil.ErrorMsg(nil, -9, "输入值必须小于" .. max_v)
return
-- elseif tem <= min_v then
-- self:SetIndex(cb_max, d2ad(data.UpperLimit))
-- ViewUtil.ErrorMsg(nil,-9,"输入值必须大于" .. min_v)
-- return
end
data.UpperLimit = ad2d(tem)
self:UpdateRewards()
end)
obj:GetController("first").selectedIndex = self._type == 1 and #self.rewards_data ~= 1 and 1 or 0
obj:GetController("last").selectedIndex = self._type == 1 and index == #self.rewards_data and 1 or 0
local btn_add = obj:GetChild("btn_add")
btn_add.onClick:Set(function()
-- 如果UpperLimit达到最大值无法再增加
if (cb_method.value == "1" and data.UpperLimit >= ad2d(input_limit2)) or (cb_method.value == "2" and cb_max.selectedIndex == cb_max.values.Length - 1) then
ViewUtil.ErrorTip(nil, "已达到上限,无法再增加")
return
end
local ul = cb_method.value == "1" and data.UpperLimit + 10 or ad2d(cb_max.values[cb_max.selectedIndex + 1])
local tem = { type = data.type, pumpProportion = data.pumpProportion, UpperLimit = ul }
table.insert(self.rewards_data, tem)
self:UpdateRewards()
end)
local btn_remove = obj:GetChild("btn_remove")
btn_remove.onClick:Set(function()
local msg_tip = MsgWindow.new(self._root_view, "确定删除该项吗?", MsgWindow.MsgMode.OkAndCancel)
msg_tip.onOk:Add(function()
table.remove(self.rewards_data, index)
self:UpdateRewards()
end)
msg_tip:Show()
end)
end
function M:SetIndex(cb, value)
local str = tostring(value)
for i = 1, cb.values.Length do
if cb.values[i - 1] == str then
cb.selectedIndex = i - 1
return
end
end
cb.selectedIndex = 0
end
function M:__input_num(tex, filed, itype)
itype = itype or 0
local gfiv = GroupNumberInputView.new(self._root_view, function(num)
tex.text = num
if filed == "robot_room" then
--printlog("cccccccccccccccc ",num)
self.hpData[filed] = (num)
else
self.hpData[filed] = ad2d(num)
end
end, itype)
gfiv:Show()
end
function M:Destroy()
BaseWindow.Destroy(self)
self.gl_view:Destroy()
end
return M