diff --git a/Assets/Lua/UI/UIBattle/UIBattleDeployView.lua b/Assets/Lua/UI/UIBattle/UIBattleDeployView.lua index 775387faa..97d496d07 100644 --- a/Assets/Lua/UI/UIBattle/UIBattleDeployView.lua +++ b/Assets/Lua/UI/UIBattle/UIBattleDeployView.lua @@ -14,9 +14,8 @@ local LabelToggleType = { INT = 4, DEX = 5, LUK = 6, - HEX = 7, - Current = 8, - More = 9 + Current = 7, + More = 8 } local HeadToggleType = { Head1 = 1, @@ -57,7 +56,8 @@ function UIBattleDeployView:Init() self:SetSelectedToggleInfo({ id = HeadToggleType.Head1, isSelected_Bool = true, - tabSelectedIdx_Int = 1 + tabSelectedIdx_Int = TabToggleType.Property, + other = {labelSelectedIdx = LabelToggleType.Current} }) self.tabToggleList = { [1] = self.propertyToggle, @@ -73,6 +73,16 @@ function UIBattleDeployView:Init() [4] = self.tab4, [5] = self.tab5 } + self.propertyLabelList = { + [1] = self.maxStrLabelToggle, + [2] = self.maxAgiLabelToggle, + [3] = self.maxVitLabelToggle, + [4] = self.maxIntLabelToggle, + [5] = self.maxDexLabelToggle, + [6] = self.maxLukLabelToggle, + [7] = self.currentLabelToggle, + [8] = self.moreLabelToggle + } self.attr_plane.cUIPolygon:InitVertexsCount(6) @@ -113,9 +123,18 @@ function UIBattleDeployView:OnHide() end function UIBattleDeployView:OnShow(data) - LogError("UIBattleDeployView:OnShow") self.controller:SetData(data) - + local heroId = data + local currSelectedInfo = self:GetCurrSelectedInfo() + if currSelectedInfo.id == TabToggleType.Property then + self:SetSelectedToggleInfo({ + id = currSelectedInfo.id, + isSelected_Bool = true, + tabSelectedIdx_Int = TabToggleType.Property, + other = {labelSelectedIdx = LabelToggleType.Current} + }) + end + self:Refresh() end @@ -133,10 +152,12 @@ end function UIBattleDeployView:OnValueChanged_HeadToggleGroup(toggle, toggleType, isOn) --LogError("TAG: "..toggle.name..", HeadToggleGroup "..toggleType..", isOn "..tostring(isOn)) if isOn == false then return end + local currSelectedInfo = self:GetCurrSelectedInfo() self:SetSelectedToggleInfo({ - id = toggleType, + id = currSelectedInfo.id, isSelected_Bool = true, - tabSelectedIdx_Int = 1 + tabSelectedIdx_Int = toggleType, + other = {labelSelectedIdx = LabelToggleType.Current} }) self:Refresh() end @@ -148,17 +169,18 @@ function UIBattleDeployView:OnValueChanged_TabToggleGroup(toggle, toggleType, is self:SetSelectedToggleInfo({ id = currSelectedInfo.id, isSelected_Bool = true, - tabSelectedIdx_Int = toggleType + tabSelectedIdx_Int = toggleType, + other = {labelSelectedIdx = LabelToggleType.Current} }) self:Refresh() end function UIBattleDeployView:OnValueChanged_LabelToggleGroup(toggle, toggleType, isOn) - --LogError("TAG: "..toggle.name..", LabelToggleGroup "..toggleType..", isOn "..tostring(isOn)) if isOn == false then return end + --LogError("TAG: "..toggle.name..", LabelToggleGroup "..toggleType..", isOn "..tostring(isOn)) local curr_ActorData = self:GetCurrSelected_ActorData() local heroId = CommonUtil.ToNumber(curr_ActorData.ID) - + if toggleType == LabelToggleType.STR then local maxAttr = CommonUtil.ToNumber(self.controller:CalcMaxAttr(heroId, Enum.HeroAttrType.STR)) local oneAttrAddDic = {} @@ -168,7 +190,14 @@ function UIBattleDeployView:OnValueChanged_LabelToggleGroup(toggle, toggleType, end end oneAttrAddDic[Enum.HeroAttrType.STR] = maxAttr - self:RefreshPropertyTab(heroId, oneAttrAddDic) + local currSelectedInfo = self:GetCurrSelectedInfo() + self:SetSelectedToggleInfo({ + id = currSelectedInfo.id, + isSelected_Bool = currSelectedInfo.isSelected_Bool, + tabSelectedIdx_Int = currSelectedInfo.tabSelectedIdx_Int, + other = {labelSelectedIdx = toggleType} + }) + self:RefreshPropertyTab(heroId, oneAttrAddDic, self:GetCurrSelectedInfo()) elseif toggleType == LabelToggleType.AGI then local maxAttr = CommonUtil.ToNumber(self.controller:CalcMaxAttr(heroId, Enum.HeroAttrType.AGI)) @@ -179,7 +208,14 @@ function UIBattleDeployView:OnValueChanged_LabelToggleGroup(toggle, toggleType, end end oneAttrAddDic[Enum.HeroAttrType.AGI] = maxAttr - self:RefreshPropertyTab(heroId, oneAttrAddDic) + local currSelectedInfo = self:GetCurrSelectedInfo() + self:SetSelectedToggleInfo({ + id = currSelectedInfo.id, + isSelected_Bool = currSelectedInfo.isSelected_Bool, + tabSelectedIdx_Int = currSelectedInfo.tabSelectedIdx_Int, + other = {labelSelectedIdx = toggleType} + }) + self:RefreshPropertyTab(heroId, oneAttrAddDic, self:GetCurrSelectedInfo()) elseif toggleType == LabelToggleType.VIT then local maxAttr = CommonUtil.ToNumber(self.controller:CalcMaxAttr(heroId, Enum.HeroAttrType.VIT)) @@ -190,7 +226,14 @@ function UIBattleDeployView:OnValueChanged_LabelToggleGroup(toggle, toggleType, end end oneAttrAddDic[Enum.HeroAttrType.VIT] = maxAttr - self:RefreshPropertyTab(heroId, oneAttrAddDic) + local currSelectedInfo = self:GetCurrSelectedInfo() + self:SetSelectedToggleInfo({ + id = currSelectedInfo.id, + isSelected_Bool = currSelectedInfo.isSelected_Bool, + tabSelectedIdx_Int = currSelectedInfo.tabSelectedIdx_Int, + other = {labelSelectedIdx = toggleType} + }) + self:RefreshPropertyTab(heroId, oneAttrAddDic, self:GetCurrSelectedInfo()) elseif toggleType == LabelToggleType.INT then local maxAttr = CommonUtil.ToNumber(self.controller:CalcMaxAttr(heroId, Enum.HeroAttrType.INT)) @@ -201,7 +244,14 @@ function UIBattleDeployView:OnValueChanged_LabelToggleGroup(toggle, toggleType, end end oneAttrAddDic[Enum.HeroAttrType.INT] = maxAttr - self:RefreshPropertyTab(heroId, oneAttrAddDic) + local currSelectedInfo = self:GetCurrSelectedInfo() + self:SetSelectedToggleInfo({ + id = currSelectedInfo.id, + isSelected_Bool = currSelectedInfo.isSelected_Bool, + tabSelectedIdx_Int = currSelectedInfo.tabSelectedIdx_Int, + other = {labelSelectedIdx = toggleType} + }) + self:RefreshPropertyTab(heroId, oneAttrAddDic, self:GetCurrSelectedInfo()) elseif toggleType == LabelToggleType.DEX then local maxAttr = CommonUtil.ToNumber(self.controller:CalcMaxAttr(heroId, Enum.HeroAttrType.DEX)) @@ -212,7 +262,14 @@ function UIBattleDeployView:OnValueChanged_LabelToggleGroup(toggle, toggleType, end end oneAttrAddDic[Enum.HeroAttrType.DEX] = maxAttr - self:RefreshPropertyTab(heroId, oneAttrAddDic) + local currSelectedInfo = self:GetCurrSelectedInfo() + self:SetSelectedToggleInfo({ + id = currSelectedInfo.id, + isSelected_Bool = currSelectedInfo.isSelected_Bool, + tabSelectedIdx_Int = currSelectedInfo.tabSelectedIdx_Int, + other = {labelSelectedIdx = toggleType} + }) + self:RefreshPropertyTab(heroId, oneAttrAddDic, self:GetCurrSelectedInfo()) elseif toggleType == LabelToggleType.LUK then local maxAttr = CommonUtil.ToNumber(self.controller:CalcMaxAttr(heroId, Enum.HeroAttrType.LUK)) @@ -223,7 +280,14 @@ function UIBattleDeployView:OnValueChanged_LabelToggleGroup(toggle, toggleType, end end oneAttrAddDic[Enum.HeroAttrType.LUK] = maxAttr - self:RefreshPropertyTab(heroId, oneAttrAddDic) + local currSelectedInfo = self:GetCurrSelectedInfo() + self:SetSelectedToggleInfo({ + id = currSelectedInfo.id, + isSelected_Bool = currSelectedInfo.isSelected_Bool, + tabSelectedIdx_Int = currSelectedInfo.tabSelectedIdx_Int, + other = {labelSelectedIdx = toggleType} + }) + self:RefreshPropertyTab(heroId, oneAttrAddDic, self:GetCurrSelectedInfo()) elseif toggleType == LabelToggleType.Current then local heroData = self.controller:GetHeroLogicData(heroId) @@ -233,9 +297,19 @@ function UIBattleDeployView:OnValueChanged_LabelToggleGroup(toggle, toggleType, oneAttrAddDic[i] = CommonUtil.ToNumber(heroData.attrs[i]) end end - self:RefreshPropertyTab(heroId, oneAttrAddDic) + local currSelectedInfo = self:GetCurrSelectedInfo() + self:SetSelectedToggleInfo({ + id = currSelectedInfo.id, + isSelected_Bool = currSelectedInfo.isSelected_Bool, + tabSelectedIdx_Int = currSelectedInfo.tabSelectedIdx_Int, + other = {labelSelectedIdx = toggleType} + }) + self:RefreshPropertyTab(heroId, oneAttrAddDic, self:GetCurrSelectedInfo()) elseif toggleType == LabelToggleType.More then + if ManagerContainer.LuaUIMgr:HasOpenPage(Enum.UIPageName.UIRoleNaturePoint) == false then + ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIRoleNaturePoint, heroId, self.uiData.id) + end end end @@ -249,10 +323,10 @@ function UIBattleDeployView:GetCurrSelectedInfo() end function UIBattleDeployView:SetSelectedToggleInfo(toggleInfo) self.data_SelectedToggleInfo = { - [1] = {id = HeadToggleType.Head1, isSelected_Bool = false, tabSelectedIdx_Int = 1}, - [2] = {id = HeadToggleType.Head2, isSelected_Bool = false, tabSelectedIdx_Int = 1}, - [3] = {id = HeadToggleType.Head3, isSelected_Bool = false, tabSelectedIdx_Int = 1}, - [4] = {id = HeadToggleType.Head4, isSelected_Bool = false, tabSelectedIdx_Int = 1}, + [1] = {id = HeadToggleType.Head1, isSelected_Bool = false, tabSelectedIdx_Int = 1, other = {}}, + [2] = {id = HeadToggleType.Head2, isSelected_Bool = false, tabSelectedIdx_Int = 1, other = {}}, + [3] = {id = HeadToggleType.Head3, isSelected_Bool = false, tabSelectedIdx_Int = 1, other = {}}, + [4] = {id = HeadToggleType.Head4, isSelected_Bool = false, tabSelectedIdx_Int = 1, other = {}}, } self.data_SelectedToggleInfo[toggleInfo.id] = toggleInfo end @@ -295,7 +369,9 @@ currSelectedInfo: {id = HeadToggleType.Head1, isSelected_Bool = true, tabSelect function UIBattleDeployView:RefreshHeroPad(data_ActorData, currSelectedInfo) for i = 1, #self.tabToggleList do local tabToggle = self.tabToggleList[i] - tabToggle.toggle.isOn = (i==currSelectedInfo.tabSelectedIdx_Int) + if i == currSelectedInfo.tabSelectedIdx_Int then + tabToggle.toggle.isOn = true + end end local heroId = CommonUtil.ToNumber(data_ActorData.ID) @@ -324,7 +400,7 @@ function UIBattleDeployView:RefreshHeroPad(data_ActorData, currSelectedInfo) oneAttrAddDic[i] = CommonUtil.ToNumber(heroData.attrs[i]) end end - self:RefreshPropertyTab(heroId, oneAttrAddDic) + self:RefreshPropertyTab(heroId, oneAttrAddDic, currSelectedInfo) elseif currSelectedInfo.tabSelectedIdx_Int == TabToggleType.Skill1 then elseif currSelectedInfo.tabSelectedIdx_Int == TabToggleType.Skill2 then @@ -333,7 +409,13 @@ function UIBattleDeployView:RefreshHeroPad(data_ActorData, currSelectedInfo) end end -function UIBattleDeployView:RefreshPropertyTab(heroId, oneAttrAddDic) +function UIBattleDeployView:RefreshPropertyTab(heroId, oneAttrAddDic, currSelectedInfo) + local labelSelectedIdx = currSelectedInfo.other.labelSelectedIdx + for k, v in pairs(self.propertyLabelList) do + if k == labelSelectedIdx then + v.toggle.isOn = (k == labelSelectedIdx) + end + end local heroData = self.controller:GetHeroLogicData(heroId) if oneAttrAddDic == nil or CommonUtil.GetTableCount(oneAttrAddDic) == 0 then oneAttrAddDic = {} @@ -360,31 +442,32 @@ function UIBattleDeployView:RefreshPropertyTab(heroId, oneAttrAddDic) end self.attr_plane.cUIPolygon:RefreshPolygonVertexs() - local baseAttrs = self.controller:GetLastBaseAttrs(heroId) - local dic = ManagerContainer.LuaActorDataMgr:GetRoleIncreaseSecondAttrVal(heroId, - oneAttrAddDic[Enum.HeroAttrType.STR] + GetBaseAttrsByType(baseAttrs, Enum.HeroAttrType.STR), - oneAttrAddDic[Enum.HeroAttrType.AGI] + GetBaseAttrsByType(baseAttrs, Enum.HeroAttrType.AGI), - oneAttrAddDic[Enum.HeroAttrType.INT] + GetBaseAttrsByType(baseAttrs, Enum.HeroAttrType.INT), - oneAttrAddDic[Enum.HeroAttrType.VIT] + GetBaseAttrsByType(baseAttrs, Enum.HeroAttrType.VIT), - oneAttrAddDic[Enum.HeroAttrType.DEX] + GetBaseAttrsByType(baseAttrs, Enum.HeroAttrType.DEX), - oneAttrAddDic[Enum.HeroAttrType.LUK] + GetBaseAttrsByType(baseAttrs, Enum.HeroAttrType.LUK) - ) - local twoAttrAddDic = {} - local iter = dic:GetEnumerator() - while iter:MoveNext() do - --LogError("Add "..tostring(iter.Current.Value)) - local newAttrs = heroData.attrs - -- LogError(Inspect(newAttrs)) - --服务器整数增量 = 取下整(当前本地增量 + 服务器当前 )- 取下整(服务器当前) - if newAttrs[iter.Current.Key] ~= nil then - local SfServerAdd = SDataUtil.Add(newAttrs[iter.Current.Key] , iter.Current.Value) - local ServerAdd = SDataUtil.InvConvertDouble(SfServerAdd) - local CurServer = SDataUtil.InvConvertDouble(newAttrs[iter.Current.Key] ) - twoAttrAddDic[iter.Current.Key] = math.floor(ServerAdd) - math.floor(CurServer) - else - twoAttrAddDic[iter.Current.Key] = math.floor(iter.Current.Value) - end + if labelSelectedIdx ~= LabelToggleType.Current then + local baseAttrs = self.controller:GetLastBaseAttrs(heroId) + local dic = ManagerContainer.LuaActorDataMgr:GetRoleIncreaseSecondAttrVal(heroId, + oneAttrAddDic[Enum.HeroAttrType.STR] + GetBaseAttrsByType(baseAttrs, Enum.HeroAttrType.STR), + oneAttrAddDic[Enum.HeroAttrType.AGI] + GetBaseAttrsByType(baseAttrs, Enum.HeroAttrType.AGI), + oneAttrAddDic[Enum.HeroAttrType.INT] + GetBaseAttrsByType(baseAttrs, Enum.HeroAttrType.INT), + oneAttrAddDic[Enum.HeroAttrType.VIT] + GetBaseAttrsByType(baseAttrs, Enum.HeroAttrType.VIT), + oneAttrAddDic[Enum.HeroAttrType.DEX] + GetBaseAttrsByType(baseAttrs, Enum.HeroAttrType.DEX), + oneAttrAddDic[Enum.HeroAttrType.LUK] + GetBaseAttrsByType(baseAttrs, Enum.HeroAttrType.LUK) + ) + local iter = dic:GetEnumerator() + while iter:MoveNext() do + local newAttrs = heroData.attrs + LogError("Add "..tostring(iter.Current.Value)) + -- LogError(Inspect(newAttrs)) + --服务器整数增量 = 取下整(当前本地增量 + 服务器当前 )- 取下整(服务器当前) + if newAttrs[iter.Current.Key] ~= nil then + local SfServerAdd = SDataUtil.Add(newAttrs[iter.Current.Key] , iter.Current.Value) + local ServerAdd = SDataUtil.InvConvertDouble(SfServerAdd) + local CurServer = SDataUtil.InvConvertDouble(newAttrs[iter.Current.Key] ) + twoAttrAddDic[iter.Current.Key] = math.floor(ServerAdd) - math.floor(CurServer) + else + twoAttrAddDic[iter.Current.Key] = math.floor(iter.Current.Value) + end + end end self.baseList = {}