⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simpledialogscript.luac.lua

📁 htc manila 2 sourcecode
💻 LUA
字号:
-- Decompiled using luadec 0.6 by sztupy (http://winmo.sztupy.hu)
-- Command line was: -l ;;;0,4;0,12,26;0,19;;;;0,0,6,27,49,53,56,88;;;0,0,1,5,16;;;0,0,4,8,12,16,20,26,60,86,105;0,12;0,0,16,26,32;;0,0,22,28;;0,11,89;;;; 581be449_manila.luac 

trace("Loaded SimpleModalDialog Script\n")
require("theme")
ItemSizeWidth = 480
ItemSizeHeight = 80
Modal_CurrentStackIndex = 0
Modal_SelectedStack = {}
Modal_PressedItem = nil
Modal_IgnoreInputEvent = true
ConnectEvents = function()
   _application.DialogManager.OnDialogIn:connect(AnimateIn)
   _application.DialogManager.OnDialogOut:connect(AnimateOut)
end

DisconnectEvents = function()
   _application.DialogManager.OnDialogIn:disconnect(AnimateIn)
   _application.DialogManager.OnDialogOut:disconnect(AnimateOut)
end

HandleModalListItemSelected = function(l_3_0)
   local l_3_1 = l_3_0.Namespace:FindName("Arrow")
   if l_3_1._visible then
      Modal_CurrentStackIndex = Modal_CurrentStackIndex + 1
      Modal_SelectedStack[Modal_CurrentStackIndex] = l_3_0.Tag.Data
      AnimateOut(nil, Rebind)
   elseif _config_os == "windowsmobile" then
      trace("DialogItemPressed: " .. l_3_0.Tag.Data.Name .. "\n")
      _dialog.Result.UserValue = l_3_0.Tag.Data.Name
      _dialog:Exit(DialogExitType_OK)
   else
      trace("DialogItemPressed: " .. l_3_0.Tag.Data .. "\n")
      AnimateOut()
   end
end

OnModalMouseDown = function(l_4_0)
   if Modal_IgnoreInputEvent == true then
      return 
   end
   trace("OnModalMouseDown\n")
   local l_4_1 = ModalListView:GetIndexAtMousePoint(l_4_0._xmouse, l_4_0._ymouse)
   if l_4_1 ~= -1 then
      trace("hit item: " .. tostring(l_4_1) .. "\n")     
      local l_4_2 = ModalGenerator:GetItem(l_4_1)     
      if l_4_2.Tag.Enable then
        UpdateFocusUI(l_4_2, true)
        l_4_2:Focus()
      end
   end
end

OnModalMouseUp = function(l_5_0)
   if Modal_IgnoreInputEvent == true then
      return 
   end
   trace("OnModalMouseUp\n")
   if Modal_PressedItem ~= nil then
     UpdateFocusUI(Modal_PressedItem, false)
   end
   local l_5_1 = ModalListView:GetIndexAtMousePoint(l_5_0._xmouse, l_5_0._ymouse)
   if l_5_1 ~= -1 then
     if l_5_1 == ModalGenerator.SelectedIndex then
       Modal_IgnoreInputEvent = true
       local item = ModalGenerator:GetItem(l_5_1)
       if item.Tag.Enable then
         HandleModalListItemSelected(item)
         return
       end
     end     
   end
   CancelDialog()
end

OnModalKeyUp = function(l_6_0, l_6_1, l_6_2)
   if Modal_IgnoreInputEvent == true then
      return 
   end
   if l_6_1.Code == KeyCode_Back then
      if Modal_CurrentStackIndex > 0 then
         BackDialog()
      else
         CancelDialog()
      end
      l_6_2.value = true      
   end
end

OnModalListItemKeyDown = function(l_7_0, l_7_1, l_7_2)
   if Modal_IgnoreInputEvent == true then
      return 
   end
   if l_7_0.Tag.Enable and (l_7_1.Code == KeyCode_Return or l_7_1.Code == KeyCode_Space) then
      HandleModalListItemSelected(l_7_0)
      UpdateFocusUI(l_7_0, true)
      l_7_2.value = true
   end
end

OnModalListItemKeyUp = function(l_8_0, l_8_1, l_8_2)
   if Modal_IgnoreInputEvent == true then
      return 
   end
   if l_8_0.Tag.Enable then
     UpdateFocusUI(l_8_0, false)
   end
end

UpdateFocusUI = function(l_9_0, l_9_1)
   local l_9_2 = ModalListView:GetGenerator():GetIndexForItem(l_9_0)
   trace("ListIndex - " .. tostring(l_9_2))
   trace("Selected Index - " .. tostring(ModalListView:GetGenerator().SelectedIndex))
   local l_9_3 = ModalListView:GetGenerator().SelectedIndex
   l_9_3 = l_9_2 == l_9_3
   trace("Selected - " .. tostring(l_9_3))
   trace("Pressed - " .. tostring(l_9_1))
   local l_9_4 = l_9_0.Namespace:FindName("TopSelected")
   local l_9_5 = l_9_0.Namespace:FindName("TopPressed")
   if l_9_3 ~= nil then
      local l_9_6 = 0
      if l_9_3 then
         l_9_6 = 100
      end
      l_9_4.Opacity:Interpolate(l_9_6, 2, 0, Interpolate_Linear)
      l_9_4 = l_9_0.Namespace:FindName("Selected")
      l_9_4.Opacity:Interpolate(l_9_6, 2, 0, Interpolate_Linear)
   end
   if l_9_1 ~= nil then
      local l_9_6 = 0
      if l_9_1 then
         l_9_6 = 100
         if Modal_PressedItem ~= nil then
            local l_9_7 = Modal_PressedItem
            UpdateFocusUI(Modal_PressedItem, false, nil)
         end
         Modal_PressedItem = l_9_0
      else
         if Modal_PressedItem ~= nil then
            if Modal_PressedItem.Tag.Index == l_9_0.Tag.Index then
               Modal_PressedItem = nil
            end
         end
      end
      local tp = l_9_0.Namespace:FindName("TopPressed")
      tp.Opacity:Interpolate(l_9_6, 2, 0, Interpolate_Linear)
      tp = l_9_0.Namespace:FindName("Pressed")
      tp.Opacity:Interpolate(l_9_6, 2, 0, Interpolate_Linear)
   end
   local l_9_6 = l_9_0.Namespace:FindName("Text")
   if l_9_3 == true or l_9_1 == true then
      l_9_6.Color = GetMenuSelectedColor()
   else
      l_9_6.Color = GetMenuUnselectedColor()
   end
end

Rebind = function()
   if _config_os == "windowsmobile" then
      BuildModalDialog(Modal_SelectedStack[Modal_CurrentStackIndex]:GetChildren())
      if Modal_CurrentStackIndex == 0 then
         _application:SetLeftSoftkey(Softkey("", nil))
      else
         _application:SetLeftSoftkey(Softkey(Locale:GetString("IDS_BACK"), BackDialog))
      end
   else
      BuildModalDialog(Test_Menu[Modal_SelectedStack[Modal_CurrentStackIndex]])
   end
   AnimateIn(nil, function()
   end)
   Modal_IgnoreInputEvent = false
end

GetIdealListviewY = function(l_11_0)
   local l_11_1 = l_11_0:GetLayout().ItemSize.y * l_11_0:GetGenerator().Collection:GetCount()
   if l_11_1 > 684 then
      l_11_1 = 684
   end
   return l_11_1
end

IsDialogItemEnable = function(l_12_0, l_12_1)
   local l_12_2 = true
   local l_12_3 = l_12_1.Namespace:FindName("Text")
   if l_12_0.Name == "Quote" then
      local l_12_4 = tonumber(_dialog.URL.Parameters:GetParameter("Count"))
      if l_12_4 ~= nil and l_12_4 >= 21 then
        l_12_2 = false
        trace("[Menu] Disable option -- " .. l_12_0.Name)
      end      
      if l_12_2 then
         l_12_3.Color = Color(0, 0, 0, 255)
      else
         l_12_3.Color = Color(155, 155, 155, 255)
      end
   end
   return l_12_2
end

HandleItemSelected = function(l_13_0)
   if Modal_IgnoreInputEvent == true then
      return 
   end
   UpdateFocusUI(l_13_0, nil)
end

HandleItemDeselected = function(l_14_0)
   if Modal_IgnoreInputEvent == true then
      return 
   end
   UpdateFocusUI(l_14_0, false)
end

HandleModalListItemCreation = function(l_15_0, l_15_1)
   local l_15_2 = l_15_1.Namespace:FindName("Text")
   local l_15_3 = l_15_1.Namespace:FindName("TopItem")
   local l_15_4 = l_15_1.Namespace:FindName("MiddleItem")
   local l_15_5 = l_15_1.Namespace:FindName("Arrow")
   local l_15_6 = l_15_1.Namespace:FindName("Contents")
   local l_15_7 = ModalListView:GetGenerator():GetIndexForItem(l_15_1)
   if l_15_7 == 0 then
      l_15_3._visible = true
      l_15_4._visible = false
   end
   if _config_os == "windowsmobile" then
      l_15_2.String = l_15_0.Title
      l_15_5._visible = l_15_0.HasChildren
   else
      l_15_2.String = l_15_0
      l_15_5._visible = l_15_7 == 4
   end
   l_15_2.Tag = {}
   l_15_2.Tag.Data = l_15_0
   l_15_2.onKeyDown:connect(OnModalListItemKeyDown)
   l_15_2.onKeyUp:connect(OnModalListItemKeyUp)
   local l_15_8 = IsDialogItemEnable(l_15_0, l_15_1)
   l_15_1.Tag = {}
   l_15_1.Tag.Data = l_15_0
   l_15_1.Tag.Index = l_15_7
   l_15_1.Tag.Enable = l_15_8
   l_15_1.OnSelected:connect(HandleItemSelected)
   l_15_1.OnDeselected:connect(HandleItemDeselected)
   if ModalListView.Tag.InitialAnimation then
     local l_15_9 = l_15_7 * 2 + 1
     if l_15_9 >= 7 then
       l_15_9 = 7
     end
     l_15_6.Opacity:Interpolate(0, 100, 10, l_15_9, Interpolate_Linear, nil)
     local l_15_10 = (GetIdealListviewY(ModalListView) - 52) / ModalListView:GetLayout().ItemSize.y
     if l_15_10 <= l_15_7 then
        ModalListView.Tag.InitialAnimation = false
     end
   end   
end

HandleModalListItemDestruction = function(l_16_0)
   l_16_0.OnSelected:disconnect(HandleItemSelected)
   l_16_0.OnDeselected:disconnect(HandleItemDeselected)
   local l_16_1 = l_16_0.Namespace:FindName("Text")
   l_16_1.onKeyDown:disconnect(OnModalListItemKeyDown)
   l_16_1.onKeyUp:disconnect(OnModalListItemKeyUp)
end

dialogRequest = nil
AnimateIn = function(l_17_0, l_17_1)
   if l_17_0 ~= nil then
      if dialogRequest ~= nil then
         return 
      end
      dialogRequest = l_17_0
   end
   trace("Animating in\n")
   if l_17_1 == nil then
      l_17_1 = AnimateInDone
   end
   local l_17_2 = GetIdealListviewY(ModalListView)
   local l_17_3 = (GetIdealListviewY(ModalListView) - 52) / ModalListView:GetLayout().ItemSize.y
   local l_17_4 = 2 + 4 * (l_17_3 / 8)
   if l_17_4 >= 7 then
      l_17_4 = 7
   end
   DialogGroup.Position:Interpolate(Vector3(0, 0, 0), Vector3(0, l_17_2, 0), l_17_4, 0, Interpolate_EaseInOutQuad, l_17_1)
end

AnimateInDone = function()
   _application.DialogManager:DialogInComplete(dialogRequest)
end

AnimateOut = function(l_19_0, l_19_1)
   trace("Animating out\n")
   if l_19_0 ~= nil and dialogRequest ~= l_19_0 then
      return 
   end
   if l_19_1 == nil then
      l_19_1 = AnimateOutDone
   end
   local l_19_2 = (GetIdealListviewY(ModalListView) - 52) / ModalListView:GetLayout().ItemSize.y
   local l_19_3 = 2 + 4 * (l_19_2 / 8)
   if l_19_3 >= 7 then
      l_19_3 = 7
   end
   DialogGroup.Position:Interpolate(Vector3(0, DialogGroup.Position.y, 0), Vector3(0, 0, 0), l_19_3, 0, Interpolate_EaseInOutQuad, l_19_1)
end

AnimateOutDone = function()
   trace("AnimateOutDone\n")
   if _config_os == "windowsmobile" then
      DisconnectEvents()
      _application.DialogManager:DialogOutComplete(dialogRequest)
   end
   dialogRequest = nil
end

BuildModalDialog = function(l_21_0)
   ModalListView.Tag = {}
   ModalListView.Tag.InitialAnimation = true
   ModalItemListLayout = TileLayout()
   local l_21_1 = Vector3F()
   l_21_1.x = ItemSizeWidth
   l_21_1.y = ItemSizeHeight
   ModalListView.Viewport.x = ItemSizeWidth
   ModalItemListLayout.ItemSize = l_21_1
   ModalListView:SetLayout(ModalItemListLayout)
   if _config_os == "windowsmobile" then
      ModalGenerator = LibraryGeneratorDialogItem(l_21_0, ModalListView:GetMovie(), ModalListView.ComponentLibraryName, ModalListView.ComponentLibraryID)
   else
      ModalGenerator = LibraryGeneratorstring(l_21_0, ModalListView:GetMovie(), ModalListView.ComponentLibraryName, ModalListView.ComponentLibraryID)
   end
   ModalGenerator.RecycleItems = true
   ModalGenerator.ItemCreated:connect(HandleModalListItemCreation)
   ModalGenerator.ItemDestroyed:connect(HandleModalListItemDestruction)
   ModalListView:SetGenerator(ModalGenerator)
   ModalListView:ForceLayout()
   ModalListView:Focus()
   Modal_PressedItem = nil
   Modal_IgnoreInputEvent = false
   local l_21_2 = ModalListView:GetLayout().ItemSize.y * ModalListView:GetGenerator().Collection:GetCount()
   trace("[Menu] ModalListView.Viewport.y = " .. l_21_2)
   ModalListView.Viewport.y = l_21_2
end

CancelDialog = function()
   _dialog:Exit(DialogExitType_Cancel)
end

BackDialog = function()
   trace("[BackDialog]")
   Modal_CurrentStackIndex = Modal_CurrentStackIndex - 1
   AnimateOut(nil, Rebind)
end

if _config_os == "windowsmobile" then
   _application:SetRightSoftkey(Softkey(Locale:GetString("IDS_CLOSE"), CancelDialog))
   _application:SetLeftSoftkey(Softkey("", nil))
   Collection = _application.DialogManager:GetDialogTree(_dialog:GetDialog()):GetChildren()
   Modal_SelectedStack[Modal_CurrentStackIndex] = _application.DialogManager:GetDialogTree(_dialog:GetDialog())
   if _application.Store:GetStringValue(Lifetime_Permanent, "EnableLandscape") == "true" then
      trace("[SimpleDialogScript] : EnableLandscape")
      require("SimpleDialog\\SimpleDialog_Landscape")
      _SimpleDialog_ScreenRotation = SimpleDialogRotation(SoundsSettingsItemListView, Camera_2D, Camera_3D, Mask)
   end
   BuildModalDialog(Collection)
   ConnectEvents()
else
   FakeCollection = VectorNotifystring()
   for i = 0, 7 do
      FakeCollection:push_back("Item " .. tostring(i))
   end
   FakeCollectionSub = VectorNotifystring()
   for i = 0, 4 do
      FakeCollectionSub:push_back("SubItem " .. tostring(i))
   end
   FakeCollectionSubSub = VectorNotifystring()
   for i = 0, 3 do
      FakeCollectionSubSub:push_back("SubSubItem " .. tostring(i))
   end
   Test_Menu = {}
   Test_Menu["Item 4"] = FakeCollectionSub
   Test_Menu["SubItem 4"] = FakeCollectionSubSub
   BuildModalDialog(FakeCollection)
   AnimateIn(nil, function()
   end)
end
ModalListView.onMouseUp:connect(OnModalMouseUp)
ModalListView.onMouseDown:connect(OnModalMouseDown)
ModalListView.onKeyUp:connect(OnModalKeyUp)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -