albumlistview.luac.lua

来自「htc manila 2 sourcecode」· LUA 代码 · 共 584 行 · 第 1/2 页

LUA
584
字号
   local l_13_9 = gDataModule:GetImageFilePath(l_13_0)
   local l_13_10 = 0
   local l_13_11 = 0
   if l_13_0 < 5 then
      l_13_10 = gDataModule:GetItemPropertyAsInt(0, l_13_0)
      l_13_11 = gDataModule:GetItemPropertyAsInt(1, l_13_0)
   else
      l_13_10 = gDataModule:GetActualWidth()
      l_13_11 = gDataModule:GetActualHeight()
   end
   if l_13_10 <= 0 or l_13_11 <= 0 then
      l_13_10 = LandscapeWidth
      l_13_11 = LandscapeHeight
   end
   if jItemLists[l_13_0].init == false then
      jItemLists[l_13_0].init = true
      local l_13_12 = 0
      if gbMobileDevice then
         l_13_12 = gDataModule:GetRandom(-2, 1)
      end
      if l_13_0 % 2 == 0 then
         jItemLists[l_13_0].rotation = 7 + l_13_12
         jItemLists[l_13_0].top_rotation_y = 90
      else
         jItemLists[l_13_0].rotation = -7 + l_13_12
         jItemLists[l_13_0].top_rotation_y = -90
      end
      if l_13_0 % 4 == 0 then
         jItemLists[l_13_0].bottom_rotation = Vector3F(-93, 10, 0)
      elseif l_13_0 % 4 == 1 then
         jItemLists[l_13_0].bottom_rotation = Vector3F(-93, 20, 0)
      elseif l_13_0 % 4 == 2 then
         jItemLists[l_13_0].bottom_rotation = Vector3F(-93, -10, 0)
      elseif l_13_0 % 4 == 3 then
         jItemLists[l_13_0].bottom_rotation = Vector3F(-93, -15, 0)
      else
         jItemLists[l_13_0].bottom_rotation = Vector3F(-93, 0, 0)
      end
   end
   if gFirstLaunch == true then
      l_13_1.Opacity.value = 0
   else
      l_13_1.Opacity.value = 100
      gFirstCount = gFirstCount + 1
      if gFirstCount > 4 then
        gFirstLaunch = true
      end
   end
   l_13_3:SetTexture(l_13_2)
   l_13_2:Clear()
   l_13_3.TextureCoords:set(0, 0, 1, 1)
   if l_13_8 == true then
      l_13_4._visible = true
      l_13_4.Opacity.value = 100
      l_13_5._visible = false
      l_13_6._visible = false
      jItemLists[l_13_0].landscape = true
      l_13_3.Size.width = LandscapeWidth - 2
      l_13_3.Size.height = LandscapeHeight
   else
      l_13_4._visible = false
      l_13_5._visible = true
      l_13_5.Opacity.value = 100
      l_13_6._visible = true
      l_13_6.Opacity.value = 100
      local l_13_12 = 2.9333190917969
      local l_13_13 = 1.6666564941406
      local l_13_14 = 1.3333282470703
      local l_13_15 = 0.75
      local l_13_16 = 0.60604858398438
      local l_13_17 = l_13_10 / l_13_11
      if l_13_12 <= l_13_17 then
         jItemLists[l_13_0].landscape = true
         l_13_3.Size.width = PanoramaWidth
         l_13_3.Size.height = PanoramaHeight
         l_13_3.Position.y = ParaOff
         l_13_5.Position.y = ParaOff
         l_13_6.Position.y = ParaOff
      elseif l_13_13 <= l_13_17 then
         jItemLists[l_13_0].landscape = true
         l_13_3.Size.width = WideLandscapeWidth
         l_13_3.Size.height = WideLandscapeHeight
         l_13_3.Position.y = WLOff
         l_13_5.Position.y = WLOff
         l_13_6.Position.y = WLOff
      elseif l_13_17 >= 1 then
         jItemLists[l_13_0].landscape = true
         l_13_3.Size.width = LandscapeWidth
         l_13_3.Size.height = LandscapeHeight
         l_13_3.Position.y = LOff
         l_13_5.Position.y = LOff
         l_13_6.Position.y = LOff
      elseif l_13_16 < l_13_17 then
         jItemLists[l_13_0].landscape = false
         l_13_3.Size.width = PortraitWidth
         l_13_3.Size.height = PortraitHeight
         l_13_3.Position.y = POff
         l_13_5.Position.y = POff
         l_13_6.Position.y = POff
      else
         jItemLists[l_13_0].landscape = false
         l_13_3.Size.width = PanoramaVWidth
         l_13_3.Size.height = PanoramaVHeight
         l_13_3.Position.y = VParaOff
         l_13_5.Position.y = VParaOff
         l_13_6.Position.y = VParaOff
      end
   end
   l_13_3.Center.x = l_13_3.Size.width / 2
   l_13_3.Center.y = -(l_13_3.Size.height / 2)
   l_13_5.Size.width = l_13_3.Size.width + 9
   l_13_5.Size.height = l_13_3.Size.height + 9
   l_13_5.Center.x = l_13_5.Size.width / 2
   l_13_5.Center.y = -(l_13_5.Size.height / 2)
   l_13_6.Size.width = l_13_5.Size.width * 1.0749969482422
   l_13_6.Size.height = l_13_5.Size.height * 1.0749969482422
   l_13_6.Center.x = l_13_6.Size.width / 2
   l_13_6.Center.y = -(l_13_6.Size.height / 2)
end

HandleAlbumDestroyed = function(l_14_0)
end

bFlyOutRotateFlag = false
bCenterRotateFlag = false
HandleKeyDown = function(l_15_0)
   trace("[PG] OnKeyDown. SI=" .. AlbumLV:GetGenerator().SelectedIndex .. " ")
   local l_15_1 = false
   local l_15_2 = false
   if l_15_0 == KeyCode_Up then
      trace("UP")
      if AlbumLV:GetGenerator().SelectedIndex > 0 then
         upArrowSprit.Opacity:Interpolate(100, 25, 3, 0, Interpolate_EaseOutQuad)
         upArrowSprit.Opacity:Interpolate(25, 100, 3, 3, Interpolate_EaseInQuad)
         AlbumLV:GetGenerator().SelectedIndex = AlbumLV:GetGenerator().SelectedIndex - 1
      end
      l_15_2 = true
      l_15_1 = true
   elseif l_15_0 == KeyCode_Down then
      trace("DOWN")
      local l_15_3 = AlbumLV:GetGenerator().SelectedIndex
      if l_15_3 < AlbumLV:GetGenerator():GetCount() - 1 and l_15_3 < gCountTotal - 1 then
         downArrowSprit.Opacity:Interpolate(100, 25, 3, 0, Interpolate_EaseOutQuad)
         downArrowSprit.Opacity:Interpolate(25, 100, 3, 3, Interpolate_EaseInQuad)
         AlbumLV:GetGenerator().SelectedIndex = l_15_3 + 1
      end
      l_15_2 = true
      l_15_1 = true
   else
      if l_15_0 == KeyCode_Return then
         trace("ACTION")
         ViewCurrentFileInAlbum()
         l_15_1 = true
      end
   end
   trace("\n")
   if l_15_2 == true then
      updateInfo(false)
   end
   collectgarbage("collect")
   collectgarbage("setpause", 20000)
   return l_15_1
end

onPhotoKeyDown = function(l_16_0, l_16_1, l_16_2)
   if gnViewType == 0 then
      if l_16_1.Code == KeyCode_Up or l_16_1.Code == KeyCode_SwipeDown then
         l_16_2.value = HandleKeyDown(KeyCode_Up)
      else
         if l_16_1.Code == KeyCode_Down or l_16_1.Code == KeyCode_SwipeUp then
            l_16_2.value = HandleKeyDown(KeyCode_Down)
         else
            l_16_2.value = HandleKeyDown(l_16_1.Code)
         end
      end
   end
end

PhotoHitTarget.onKeyDown:connect(onPhotoKeyDown)
PhotoHitTarget:Focus()
refreshControlPanel = function(l_17_0, l_17_1)
   upArrowSprit._visible = true
   downArrowSprit._visible = true
   if l_17_1 == 0 then
      upArrowSprit._visible = false
   end
   if l_17_0 - 1 <= l_17_1 then
      downArrowSprit._visible = false
   end
end

gnLastIndex = -1
updateInfo = function(l_18_0)
   if gExitingGizmo == true then
      trace("[AG] update disabled\n")
      return 
   end
   local l_18_1 = AlbumLV:GetGenerator().SelectedIndex
   local l_18_2 = 0
   if gbMobileDevice then
      gstrCurrentFilePath = gDataModule:GetImageFilePath(l_18_1)
      l_18_2 = gDataModule:GetImageCount()
      if l_18_2 > 0 then
         _application:SetLeftSoftkey(Softkey(Locale:GetString("IDS_ALBUM"), LSKFunction))
         if gDataModule:IsItemPlayable(l_18_1) == true then
            _application:SetRightSoftkey(Softkey(Locale:GetString("IDS_PLAY"), RSKFunction_play))
         else
            _application:SetRightSoftkey(Softkey(Locale:GetString("IDS_SLIDESHOW"), RSKFunction))
         end
      else
         _application:SetLeftSoftkey(Softkey(Locale:GetString("IDS_ALBUM"), LSKFunction))
         _application:SetRightSoftkey(Softkey("", nil))
      end
   else
      l_18_2 = 11
   end
   refreshControlPanel(l_18_2, l_18_1)
   if l_18_0 == false and l_18_1 == gnLastIndex then
      if l_18_1 == 0 then
         jItemLists[l_18_1].rotation = -jItemLists[l_18_1].rotation
      elseif l_18_1 == l_18_2 - 1 then
         jItemLists[l_18_1].rotation = -jItemLists[l_18_1].rotation
      end
   end
   gUpdateIndexStringForIndex(l_18_1 + 1)
   gnLastIndex = l_18_1
end

AlignVerticalScroll = function()
   trace("Aligning list view...")
   local l_19_0 = AlbumLV:GetGenerator().SelectedIndex
   if l_19_0 >= 0 then
      AlbumLV:GetLayout():JumpToIndex(l_19_0, ListAlignment_Top, ListAlignmentOptions_Snap)
      if Operator_HandlePhotoChange ~= nil then
         Operator_HandlePhotoChange(gstrCurrentFilePath)
      end
   end
end

HandleItemsAdded = function(l_20_0, l_20_1)
   AlignVerticalScroll()
end

HandleItemsRemoved = function(l_21_0, l_21_1)
   AlignVerticalScroll()
end

HandleItemsMoved = function(l_22_0, l_22_1, l_22_2)
   AlignVerticalScroll()
end

HandleItemsReplaced = function(l_23_0, l_23_1)
   AlignVerticalScroll()
end

HandleCollectionReset = function()
   AlignVerticalScroll()
end

HandleSelectedIndexChanged = function(l_25_0, l_25_1)
   AlignVerticalScroll()
end

if _application.Store:GetStringValue(Lifetime_Permanent, "EnableLandscape") == "true" then
   require("Album\\albumlandscape")
   gScreenRotation = Album_ScreenRotation(OnUIRotation)
else
   InitPortraitConstant()
end
ListLayout = AlbumLayout(PathLayout())
ListLayout.Base:SetItemSize(200, 150, 0)
AlbumLV:SetLayout(ListLayout.Base)
AlbumLV.AllowScrollToEnd = true
AlbumGenerator = LibraryGeneratorint(AlbumQuery, AlbumLV:GetMovie(), AlbumLV.ComponentLibraryName, AlbumLV.ComponentLibraryID)
AlbumGenerator.RecycleItems = true
AlbumGenerator.ForceImmediateCleanup = true
AlbumGenerator.ItemCreated:connect(HandleAlbumCreated)
AlbumGenerator.ItemDestroyed:connect(HandleAlbumDestroyed)
AlbumGenerator.ItemsAdded:connect(HandleItemsAdded)
AlbumGenerator.ItemsRemoved:connect(HandleItemsRemoved)
AlbumGenerator.ItemsMoved:connect(HandleItemsMoved)
AlbumGenerator.ItemsReplaced:connect(HandleItemsReplaced)
AlbumGenerator.CollectionReset:connect(HandleCollectionReset)
AlbumGenerator.SelectedIndexChanged:connect(HandleSelectedIndexChanged)
AlbumLV:SetGenerator(AlbumGenerator)
if AlbumGenerator:GetCount() > 0 then
   AlbumGenerator.SelectedIndex = 0
end
AlbumLV.onRelease:connect(AlbumLVOnRelease)
updateInfo(true)

⌨️ 快捷键说明

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