require("game.bag.AllAdditionView")
|
|
require("game.bag.EquipItem")
|
|
require("game.newMainRole.NewMainRoleView")
|
|
require("game.newMainRole.NewMainRoleModel")
|
|
require("game.newMainRole.roleAttribute.RoleAttributeModel")
|
|
require("game.newMainRole.roleAttribute.RoleAttributeView")
|
|
-- require("game.newMainRole.roleAttribute.RoleAttrInstructionView")
|
|
-- require("game.newMainRole.roleAttribute.RoleAttrItem")
|
|
-- require("game.newMainRole.roleAttribute.RoleAttrDesItem")
|
|
require("game.newMainRole.roleAttribute.RolePropertyItem")
|
|
require("game.newMainRole.roleAttribute.RolePropTips")
|
|
require("game.newMainRole.WorldLevelView")
|
|
require("game.newMainRole.SelectSysRoleHeadView")
|
|
require("game.newMainRole.RoleHeadShowItem")
|
|
-- require("game.newMainRole.RoleHeadTips")
|
|
require("game.newMainRole.roleAttribute.RolePropertyTop")
|
|
require("game.newMainRole.AttrDetailView") -- 属性详细介绍界面
|
|
require("game.newMainRole.NewMainRoleHatredView") -- 善恶值界面
|
|
|
|
NewMainRoleController = NewMainRoleController or BaseClass(BaseController)
|
|
|
|
function NewMainRoleController:__init()
|
|
NewMainRoleController.Instance = self
|
|
self.model = NewMainRoleModel:getInstance()
|
|
self.mainVo = RoleManager.Instance.mainRoleInfo
|
|
self.test_pattern = false
|
|
self:RegisterAllProtocals()
|
|
self:AddAllEvents()
|
|
end
|
|
|
|
function NewMainRoleController:RegisterAllProtocals()
|
|
self:RegisterProtocal(13013, "handler13013") --请求玩家figure
|
|
self:RegisterProtocal(13014, "handler13014")
|
|
|
|
self:RegisterProtocal(13085, "handler13085") --头像广播
|
|
self:RegisterProtocal(13045, "Handler13045") --转职
|
|
self:RegisterProtocal(13046, "Handler13046") --转职时间
|
|
|
|
-- self:RegisterProtocal(13082, "handler13082")--检测是否可上传头像
|
|
-- self:RegisterProtocal(13083, "handler13083")--上传头像
|
|
-- self:RegisterProtocal(13086, "handler13086")--上传头像
|
|
self:RegisterProtocal(13087, "handler13087") -- 登录相关时间查询协议
|
|
|
|
self:RegisterProtocal(13088, "handler13088") -- 查询角色头像信息
|
|
self:RegisterProtocal(13089, "handler13089") -- 激活头像
|
|
self:RegisterProtocal(13090, "handler13090") -- 更换头像
|
|
end
|
|
|
|
function NewMainRoleController:AddAllEvents()
|
|
local function onGameStart()
|
|
-- 请求登录时间信息
|
|
self:SendFmtToGame(13087)
|
|
-- 请求头像信息
|
|
self:SendFmtToGame(13088)
|
|
-- self.model:CheckErrorRoleHead()
|
|
end
|
|
GlobalEventSystem:Bind(EventName.GAME_START, onGameStart)
|
|
|
|
-- 头像是否可上传
|
|
-- local onCheckRoleHeadForbidState = function()
|
|
-- self:SendFmtToGame(13082)
|
|
-- end
|
|
-- GlobalEventSystem:Bind(EventName.CHECK_ROLE_HEAD_FORBID, onCheckRoleHeadForbidState)
|
|
-- 头像上传
|
|
-- local onRoleHeadUploadSucceed = function()
|
|
-- self:SendFmtToGame(13083)
|
|
-- end
|
|
-- GlobalEventSystem:Bind(EventName.ROLEHEAD_UPLOAD_SUCCEED, onRoleHeadUploadSucceed)
|
|
|
|
-- 本地头像上传
|
|
-- local onChangeLocalHead = function(id)
|
|
-- self:SendFmtToGame(13086, "h", id)
|
|
-- end
|
|
-- GlobalEventSystem:Bind(EventName.ROLEHEAD_LOCAL_UPLOAD, onChangeLocalHead)
|
|
|
|
local function OPEN_PROP_TIP(id, val, x, y)
|
|
do return end
|
|
if not self.RolePropTips then
|
|
self.RolePropTips = RolePropTips.New()
|
|
end
|
|
self.RolePropTips:Open(id, val, x, y)
|
|
end
|
|
RoleAttributeModel:getInstance():Bind(RoleAttributeModel.OPEN_PROP_VIEW, OPEN_PROP_TIP)
|
|
--绑定打开称号界面的方法
|
|
local function onOpenMainRoleView(index,sub_index,value)
|
|
if self.mainRoleView == nil then
|
|
self.mainRoleView = NewMainRoleView.New()
|
|
end
|
|
if not self.mainRoleView:HasOpen() then
|
|
self.mainRoleView:Open(index,sub_index,value)
|
|
else
|
|
self.mainRoleView:ReOpen(index,sub_index,value)
|
|
end
|
|
end
|
|
GlobalEventSystem:Bind(EventName.OPEN_NEW_MAIN_ROLE_VIEW, onOpenMainRoleView)
|
|
local function close_mianrole_view()
|
|
if self.mainRoleView and self.mainRoleView:HasOpen() then
|
|
self.mainRoleView:Close()
|
|
end
|
|
end
|
|
GlobalEventSystem:Bind(EventName.CLOSE_NEW_MAIN_ROLE_VIEW, close_mianrole_view)
|
|
|
|
local function onOpenAllAdditionView(type)
|
|
if self.AllAdditionView == nil then
|
|
self.AllAdditionView = AllAdditionView.New()
|
|
end
|
|
self.AllAdditionView:Open(type)
|
|
end
|
|
self.model:Bind(NewMainRoleModel.OPEN_ALL_ADDITION_VIEW, onOpenAllAdditionView)
|
|
|
|
local function open_attr_detail_view(type)
|
|
if not self.attr_detail_view then
|
|
self.attr_detail_view = AttrDetailView.New()
|
|
end
|
|
self.attr_detail_view:Open(type)
|
|
end
|
|
RoleAttributeModel:getInstance():Bind(RoleAttributeModel.OPEN_ATTR_DETAIL_VIEW, open_attr_detail_view)
|
|
|
|
local function open_hatred_view(force_close)
|
|
if force_close then
|
|
if self.hatred_view == nil then return end
|
|
if self.hatred_view:HasOpen() then self.hatred_view:Close() end
|
|
return
|
|
end
|
|
|
|
if not self.hatred_view then
|
|
self.hatred_view = NewMainRoleHatredView.New()
|
|
end
|
|
self.hatred_view:Open()
|
|
end
|
|
self.model:Bind(NewMainRoleModel.OPEN_HATRED_VIEW, open_hatred_view)
|
|
|
|
local function sent_turn_career_protocal(...)
|
|
local args = {...}
|
|
if args[1] == 13045 then
|
|
self:SendFmtToGame(args[1], "cc", args[2], args[3])
|
|
elseif args[1] == 13046 then
|
|
self:SendFmtToGame(args[1])
|
|
end
|
|
end
|
|
self.model:Bind(NewMainRoleModel.SEND_TURN_CAREER_PROTOCAL, sent_turn_career_protocal)
|
|
|
|
local function onRequestOtherInfo(unique_server_id, role_id, module_id)
|
|
if unique_server_id and role_id and module_id then
|
|
self:SendFmtToGame(13013, "hlh", unique_server_id, role_id, module_id)
|
|
end
|
|
end
|
|
self.model:Bind(NewMainRoleModel.REQUEST_OTHER_PLAYER_INFO, onRequestOtherInfo)
|
|
|
|
local function onRequestWorldLevel()
|
|
self:SendFmtToGame(13011)
|
|
end
|
|
self.model:Bind(NewMainRoleModel.RequestWorldLevel, onRequestWorldLevel)
|
|
|
|
local function onOpenWorldLevelView()
|
|
if self.worldLevelView == nil then
|
|
self.worldLevelView = WorldLevelView.New()
|
|
end
|
|
if not self.worldLevelView:HasOpen() then
|
|
self.worldLevelView:Open()
|
|
end
|
|
end
|
|
GlobalEventSystem:Bind(EventName.OPEN_WORLD_LEVEL_VIEW, onOpenWorldLevelView)
|
|
|
|
local function onCloseWorldLevelView()
|
|
if self.worldLevelView then
|
|
self.worldLevelView:Close()
|
|
self.worldLevelView = nil
|
|
end
|
|
end
|
|
GlobalEventSystem:Bind(EventName.CLOSE_WORLD_LEVEL_VIEW, onCloseWorldLevelView)
|
|
|
|
local function onGameStart()
|
|
-- if self.test_pattern then
|
|
-- if not self.game_start_set then
|
|
-- local data = CookieWrapper.Instance:GetCookie(CookieLevelType.Account, CookieKey.TEST_DETECT_PLAYER_ATTR)
|
|
-- if not data then
|
|
-- data = {}
|
|
-- end
|
|
-- local vo = {
|
|
-- start_time = os.date("%c", os.time()),
|
|
-- role_id = self.mainVo.role_id,
|
|
-- role_name = self.mainVo.name,
|
|
-- read_time = os.date("%c", os.time()),
|
|
-- role_lv = self.mainVo.level,
|
|
-- attr_list = self:SetRoleAttrList(),
|
|
-- }
|
|
-- table.insert(data, vo)
|
|
-- CookieWrapper.Instance:SaveCookie(CookieLevelType.Account, CookieTimeType.TYPE_ALWAYS, CookieKey.TEST_DETECT_PLAYER_ATTR, data)
|
|
-- self.game_start_set = true
|
|
-- end
|
|
-- end
|
|
end
|
|
GlobalEventSystem:Bind(SceneManager.START, onGameStart)
|
|
|
|
local function update_red_dot_by_tab_id_func( tab_id )--主要的更新红点方法
|
|
if not tab_id then
|
|
self.model:IsNeedRedAll()
|
|
else
|
|
self.model:IsNeedRed(tab_id)
|
|
end
|
|
local red_dot = self.model:GetAllRedDot()
|
|
local bool = false
|
|
for i,v in pairs(red_dot) do
|
|
if v then
|
|
bool = true
|
|
break
|
|
end
|
|
end
|
|
GlobalEventSystem:Fire(EventName.SHOW_FUNCTION_RED_POINT, 130, bool)
|
|
end
|
|
self.model:Bind(NewMainRoleModel.UPDATE_RED_DOT,update_red_dot_by_tab_id_func)
|
|
|
|
-- 查询玩家已激活的头像信息
|
|
local function onRequestRoleHeadInfo()
|
|
self:SendFmtToGame(13088)
|
|
end
|
|
GlobalEventSystem:Bind(EventName.REQ_ROLE_HEAD_INFO, onRequestRoleHeadInfo)
|
|
-- 请求激活目标头像
|
|
local function onActivateRoleHead(photo_id)
|
|
if not photo_id then return end
|
|
self:SendFmtToGame(13089, "i", photo_id)
|
|
end
|
|
GlobalEventSystem:Bind(EventName.REQ_ACTIVATE_ROLEHEAD, onActivateRoleHead)
|
|
-- 请求切换玩家头像
|
|
local function onChangeRoleHead(photo_id)
|
|
if not photo_id then return end
|
|
self:SendFmtToGame(13090, "i", photo_id)
|
|
end
|
|
GlobalEventSystem:Bind(EventName.REQ_CHANGE_ROLEHEAD, onChangeRoleHead)
|
|
-- local function onChangeAttr()
|
|
-- if self.test_pattern then
|
|
-- if self.game_start_set then
|
|
-- local data = CookieWrapper.Instance:GetCookie(CookieLevelType.Account, CookieKey.TEST_DETECT_PLAYER_ATTR)
|
|
-- if not data then
|
|
-- data = {}
|
|
-- end
|
|
-- local vo = {
|
|
-- start_time = 0,
|
|
-- role_id = self.mainVo.role_id,
|
|
-- role_name = self.mainVo.name,
|
|
-- read_time = os.date("%c", os.time()),
|
|
-- role_lv = self.mainVo.level,
|
|
-- attr_list = self:SetRoleAttrList(),
|
|
-- }
|
|
-- table.insert(data, vo)
|
|
-- CookieWrapper.Instance:SaveCookie(CookieLevelType.Account, CookieTimeType.TYPE_ALWAYS, CookieKey.TEST_DETECT_PLAYER_ATTR, data)
|
|
-- end
|
|
-- end
|
|
-- end
|
|
-- for k, v in pairs(Config.ConfigItemAttr.TestAttr) do -- 以下是数值策划测试所用
|
|
-- self.mainVo:BindOne(v.attr_str, onChangeAttr)
|
|
-- end
|
|
|
|
end
|
|
|
|
-- function NewMainRoleController:SetRoleAttrList()
|
|
-- local list = {}
|
|
-- for k, v in pairs(Config.ConfigItemAttr.TestAttr) do
|
|
-- if v then
|
|
-- local vo = {name = Config.ConfigItemAttr.Normal[v.id].name, attr_val = self.mainVo[v.attr_str]}
|
|
-- table.insert(list, vo)
|
|
-- end
|
|
-- end
|
|
-- return list
|
|
-- end
|
|
|
|
function NewMainRoleController:handler13013()
|
|
local vo = {}
|
|
vo.server_id = UserMsgAdapter.ReadFmt("h")
|
|
vo.role_id = UserMsgAdapter.ReadFmt("l")
|
|
vo.module_id = UserMsgAdapter.ReadFmt("h")
|
|
vo.fighting = UserMsgAdapter.ReadFmt("i")
|
|
FigureProtoVo.ReadFmt(vo)
|
|
vo.server_name = UserMsgAdapter.ReadFmt("s")
|
|
self.model:SetRoleFigure(vo)
|
|
self.model:Fire(NewMainRoleModel.REQUEST_OTHER_PLAYER_INFO, vo, vo.module_id)
|
|
end
|
|
|
|
function NewMainRoleController:handler13014()
|
|
self.model.other_guild_chief_vo = {}
|
|
self.model.other_guild_chief_vo.server_id = UserMsgAdapter.ReadFmt("h")
|
|
self.model.other_guild_chief_vo.guild_id = UserMsgAdapter.ReadFmt("l")
|
|
self.model.other_guild_chief_vo.module_id = UserMsgAdapter.ReadFmt("h")
|
|
self.model.other_guild_chief_vo.role_id = UserMsgAdapter.ReadFmt("l")
|
|
-- self.model.other_guild_chief_vo.fighting = UserMsgAdapter.ReadFmt("i")
|
|
FigureProtoVo.ReadFmt(self.model.other_guild_chief_vo)
|
|
-- self.model.other_guild_chief_vo.server_name = UserMsgAdapter.ReadFmt("s")
|
|
self.model:Fire(NewMainRoleModel.REQUEST_OTHER_PLAYER_INFO, self.model.other_guild_chief_vo, self.model.other_guild_chief_vo.module_id)
|
|
end
|
|
|
|
function NewMainRoleController:handler13085()
|
|
local role_id, img_str, img_ver = self:ReadFmt("lsi")
|
|
|
|
local role_vo = SceneManager.Instance:GetRoleVo(role_id)
|
|
if role_vo then
|
|
role_vo:ChangeVar("picture_ver", img_ver)
|
|
role_vo:ChangeVar("picture", img_str)
|
|
end
|
|
|
|
GlobalEventSystem:Fire(EventName.MAINROLEHEAD_DATA_CHANGE, self.mainVo.role_id)
|
|
end
|
|
|
|
function NewMainRoleController:Handler13045()
|
|
local error, str, career, sex = self:ReadFmt("iscc")
|
|
if error == 1 then
|
|
self.model:Fire(NewMainRoleModel.SEND_TURN_CAREER_PROTOCAL, 13046)
|
|
ReincarnationController.Instance:OpenSuccessView(sex, nil, career)
|
|
--self.model:Fire(MainRoleModel.TURN_CAREER_SUCCESS, career, sex)
|
|
else
|
|
ErrorCodeShow(error, str)
|
|
end
|
|
end
|
|
|
|
function NewMainRoleController:Handler13046()
|
|
local time = self:ReadFmt("i")
|
|
self.model:Fire(MainRoleModel.GET_TURN_CAREER_TIME, time)
|
|
end
|
|
|
|
function NewMainRoleController:handler13082()
|
|
local result = self:ReadFmt("c")
|
|
if result == 1 then
|
|
self:pickPhoto()
|
|
elseif result == 2 then
|
|
Message.show("你已被管理员禁止设置头像")
|
|
else
|
|
Message.show("未知原因,请与管理员联系")
|
|
end
|
|
end
|
|
|
|
function NewMainRoleController:handler13083()
|
|
local result, img_ver, img_str = self:ReadFmt("cis")
|
|
if result == 1 then
|
|
Message.show("保存头像成功!")
|
|
RoleManager.Instance.mainRoleInfo:ChangeVar("picture_ver", img_ver)
|
|
RoleManager.Instance.mainRoleInfo:ChangeVar("picture", img_str)
|
|
RoleManager.Instance.mainRoleInfo:ChangeVar("profile_photo_id", "")
|
|
GlobalEventSystem:Fire(EventName.MAINROLEHEAD_DATA_CHANGE, RoleManager.Instance.mainRoleInfo.role_id)
|
|
elseif result == 2 then
|
|
Message.show("你已被管理员禁止设置头像")
|
|
else
|
|
Message.show("保存头像失败!")
|
|
end
|
|
end
|
|
|
|
function NewMainRoleController:handler13086()
|
|
local result, icon_id = self:ReadFmt("ch")
|
|
if result == 1 then
|
|
Message.show("更头像成功!")
|
|
RoleManager.Instance.mainRoleInfo.picture = ""--:ChangeVar("picture", "")
|
|
RoleManager.Instance.mainRoleInfo.profile_photo_id = icon_id--:ChangeVar("local_picture_id", icon_id)
|
|
GlobalEventSystem:Fire(EventName.MAINROLEHEAD_DATA_CHANGE)
|
|
-- GlobalEventSystem:Fire(EventName.MAINROLEHEAD_LOCAL_DATA_CHANGE, RoleManager.Instance.mainRoleInfo.role_id)
|
|
elseif result == 2 then
|
|
Message.show("你已被管理员禁止设置头像")
|
|
else
|
|
ErrorCodeShow(result)
|
|
end
|
|
end
|
|
|
|
function NewMainRoleController:handler13087( )
|
|
-- 请求时服务器时间/上一次登录时间/本次登录时间/上次退出游戏时间
|
|
local req_time, last_login_time, cur_login_time, last_quit_time = self:ReadFmt("iiii")
|
|
self.model:SetRoleLoginTimeData(req_time, last_login_time, cur_login_time, last_quit_time)
|
|
GlobalEventSystem:Fire(EventName.UPDATE_ROLE_LOGIN_TIME_DATA)
|
|
end
|
|
|
|
function NewMainRoleController:handler13088( )
|
|
--开始构造数据,不要问为什么要这么做,为了要和112装扮模块的协议数据一致
|
|
local vo = {}
|
|
local len0 = self:ReadFmt("h") or 0
|
|
vo.dress_type = ChatDressSubType.ROLE_HEAD
|
|
vo.use_dress_id = RoleManager.Instance.mainRoleInfo.profile_photo_id
|
|
vo.enable_list = {}
|
|
for i = 1, len0 do
|
|
vo.enable_list[i] = {
|
|
dress_id = self:ReadFmt("i") or 0
|
|
}
|
|
end
|
|
ChatDressModel:getInstance():UpdateDressData(vo)
|
|
-- self.model:RefreshRoleHeadRed()
|
|
WardrobeModel:GetInstance():Fire(WardrobeConst.UPDATE_RED_DOT, WardrobeConst.TabId.DRESS)
|
|
self.model:Fire(NewMainRoleModel.REFRESH_ROLE_HEAD_ACTIVATE)
|
|
end
|
|
|
|
function NewMainRoleController:handler13089( )
|
|
local result, photo_id = self:ReadFmt("ii")
|
|
if result == 1 then
|
|
Message.show("激活成功")
|
|
-- 更新缓存
|
|
local data = {
|
|
dressup_list = {
|
|
[1] = {
|
|
dress_type = ChatDressSubType.ROLE_HEAD,
|
|
dress_id = photo_id,
|
|
}
|
|
}
|
|
}
|
|
ChatDressModel:getInstance():UpdataUsingDress(data)
|
|
|
|
local data = {
|
|
dress_id = photo_id,
|
|
dress_type = ChatDressSubType.ROLE_HEAD
|
|
}
|
|
ChatDressModel:getInstance():UpdataEnableList(data)
|
|
-- 先自动替换头像
|
|
RoleManager.Instance.mainRoleInfo:ChangeVar("profile_photo_id", photo_id)
|
|
GlobalEventSystem:Fire(EventName.MAINROLEHEAD_DATA_CHANGE)
|
|
WardrobeModel:GetInstance():Fire(WardrobeConst.UPDATE_RED_DOT, WardrobeConst.TabId.DRESS)
|
|
else
|
|
ErrorCodeShow(result)
|
|
end
|
|
end
|
|
|
|
function NewMainRoleController:handler13090( )
|
|
local result, photo_id = self:ReadFmt("ii")
|
|
if result == 1 then
|
|
if RoleManager.Instance.mainRoleInfo.profile_photo_id ~= 0 then -- 过滤掉非法头像切换的飘字
|
|
Message.show("替换头像成功")
|
|
local data = {
|
|
dressup_list = {
|
|
[1] = {
|
|
dress_type = ChatDressSubType.ROLE_HEAD,
|
|
dress_id = photo_id,
|
|
}
|
|
}
|
|
}
|
|
ChatDressModel:getInstance():UpdataUsingDress(data)
|
|
end
|
|
RoleManager.Instance.mainRoleInfo:ChangeVar("profile_photo_id", photo_id)
|
|
GlobalEventSystem:Fire(EventName.MAINROLEHEAD_DATA_CHANGE)
|
|
else
|
|
ErrorCodeShow(result)
|
|
end
|
|
end
|
|
|
|
function NewMainRoleController:pickPhoto()
|
|
local operate_str = "pickPhoto"
|
|
local role_info = RoleManager.Instance.mainRoleInfo
|
|
local new_version = role_info.picture_ver + 1
|
|
local file_path, file_name = UtilGetRolePicPath(role_info.role_id, nil, new_version)
|
|
SDKUtil.CallSDKFunc("PhonePhoto", operate_str, {imagePath = file_path, imageName = file_name, imageWidth = 200, imageHeight = 200})
|
|
|
|
local no_support_text = PlatformMgr:getInstance():NoSupportPhotoMsg()
|
|
if no_support_text then
|
|
local show_func = function()
|
|
Message.show(no_support_text)
|
|
end
|
|
setTimeout(show_func, 1)
|
|
end
|
|
end
|