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

📄 manila.luac.lua

📁 htc manila 2 sourcecode
💻 LUA
📖 第 1 页 / 共 3 页
字号:
OnSelectorMouseMove = function()
   if selectorIsDragging == true then
      if ModalOverlay._visible == false then
         SetSelectorX(selector._xmouse - selectorDragOffset)
      end
   end
end

layoutInitialized = false
initializeLayout = function()
  trace("***********************initializeLayout\n")
  if layoutInitialized == false then
    layoutInitialized = true
    previewRoot.Opacity.value = 0
    currentPreviewIndex = -1
    selectMinX = -selectBodyOffset
    selectMaxX = screenWidth - (selectorWidth - selectBodyOffset)
    local traytotal = (tabOffset + trayIconsCount * tabSpacing) - (selectorWidth - selectBodyOffset)
    trace("++++++++++++++++++++selectMinX = " .. selectMinX)
    trace("++++++++++++++++++++selectMaxX = " .. selectMaxX)
    trace("++++++++++++++++++++trayTotal = " .. traytotal)
    trace("++++++++++++++++++++tabOffset = " .. tabOffset)
    trace("++++++++++++++++++++trayIconsCount = " .. trayIconsCount)
    trace("++++++++++++++++++++tabSpacing = " .. tabSpacing)
    trace("++++++++++++++++++++tabOffset = ".. tabOffset)
    if traytotal < selectMaxX then
        selectMaxX = traytotal
    end
    selectTotalX = selectMaxX - selectMinX
    for i_1,i_2 in pairs(trayIcons) do
        i_2.Position.x = tabOffset + tabSpacing * i_1
    end
    for i_1,i_2 in pairs(notificationIcons) do
        i_2.Position.x = tabOffset + tabSpacing * i_1
    end
    trace(" showTabs, selectorIconOffset = " .. tostring(selectorIconOffset) .. "\n")
    for i_1,i_2 in pairs(selectorIcons) do
        i_2.Position.x = selectorIconOffset
        i_2.Opacity.value = 0
    end
    if usingPreviews then
        for i_1,i_2 in pairs(previewIcons) do
          i_2.Opacity.value = 0
        end
    end
    selectedIconSpacing = selectTotalX / (trayIconsCount - 1)
    selectedPositions = {}
    for i = 0, trayIconsCount - 1 do
        selectedPositions[i] = selectMinX + i * selectedIconSpacing
    end
  end   
end

rebuildNavigation = function(l_23_0)
   trace("***********************rebuildNavigation\n")
   trace("begin rebuildNavigation\n")
   layoutInitialized = false
   if usingPreviews then
      previewRoot.Opacity.value = 0
   end
   if trayIconsCount > 0 then
      trace("     rebuildNavigation detaching old pages\n")
      for i = 0, trayIconsCount - 1 do
         oldPages[i]:Detach("icon_normal", iconTrayRoot)
         oldPages[i]:Detach("icon_selected", iconSelectorRoot)
         if usingPreviews then
            oldPages[i]:Detach("icon_preview", iconPreviewRoot)
         end
         if oldPages[i]:ComponentExists("icon_notification") == true then
            oldPages[i]:Detach("icon_notification", notificationTrayRoot)
         end
      end
   end
   if _application.Navigation == nil or _application.Navigation.CurrentRequest == nil then
     tabsShown = false
     trace("Navigation or CurrentRequest is nil\n")
     return
   end
   oldPageGroup = _application.Navigation.CurrentRequest.PageGroup
   oldPages = {}
   local pages = _application.Navigation.CurrentRequest.PageGroup.Pages
   currentNumberOfTabs = pages:GetCount()
   selectorIcons = {}
   selectorIconsCount = 0
   trayIcons = {}
   trayIconsCount = 0
   notificationIcons = {}
   URLS = {}
   previewIcons = {}
   previewTitles = {}
   trace("     rebuildNavigation currentNumberOfTabs = " .. tostring(currentNumberOfTabs) .. "\n")
   local l_23_2 = _application.Navigation.CurrentRequest.Page.Path:ToString(URLParts_All)
   local l_23_3 = -1
   if currentNumberOfTabs > 1 then
      hideTabs()
      while pages:Next() == true do
         pages:GetValue().OnVisibilityChanged:connect(OnPageVisibilityChanged)
         if pages:GetValue().Visibility == true then
            oldPages[trayIconsCount] = pages:GetValue()
            URLS[trayIconsCount] = pages:GetValue().Path
            if URLS[trayIconsCount]:ToString(URLParts_All) == l_23_2 then
              l_23_3 = trayIconsCount
            end
            local itr = pages:GetValue():Attach("icon_normal", iconTrayRoot)
            itr:stop()
            local iconbutton = itr:GetComponentClip().Namespace:FindName("iconButton")
            if iconbutton == nil then
               trace("no iconButton instance for page " .. pages:GetValue().Path:ToString(URLParts_All) .. "\n")
            else
               iconbutton.onPress:connect(OnTrayIconPress)
               iconbutton.onRelease:connect(OnTrayIconRelease)
               iconbutton.onReleaseOutside:connect(OnTrayIconReleaseOutside)
               iconbutton.Tag = trayIconsCount
            end
            trayIcons[trayIconsCount] = itr            
            local iconselector = pages:GetValue():Attach("icon_selected", iconSelectorRoot)
            iconselector:stop()
            selectorIcons[selectorIconsCount] = iconselector
            if pages:GetValue():ComponentExists("icon_notification") == true then
               local notificationtrayroot = pages:GetValue():Attach("icon_notification", notificationTrayRoot)
               notificationtrayroot:stop()
               notificationIcons[trayIconsCount] = notificationtrayroot
               local notificationcomp = notificationtrayroot:GetComponentClip().Namespace:FindName("notificationComponent")
               if notificationcomp ~= nil then
                  local urb = notificationcomp:GetComponentClip().Namespace:FindName("UnreadButtonImage")
                  if urb ~= nil then
                    urb.onRelease:connect(OnTrayIconRelease)
                    urb.Tag = trayIconsCount
                  end
               end
            end
            if usingPreviews then
               local ipr = pages:GetValue():Attach("icon_preview", iconPreviewRoot)
               ipr:stop()
               local title = pages:GetValue().Title
               previewIcons[trayIconsCount] = ipr
               previewTitles[trayIconsCount] = title
            end
            trayIconsCount = trayIconsCount + 1
            selectorIconsCount = selectorIconsCount + 1
            trace("     attached " .. tostring(trayIconsCount) .. "\n")
         end            
      end
      if l_23_3 == -1 then
         trace("ERROR: could not selectedurl " .. l_23_2 .. "\n")
      end
      currentNumberOfTabs = trayIconsCount
      initializeLayout()
      _application.Navigation.TabVisibility = true
      selector._visible = true
      TabJumpTo(l_23_3)
      tabBGChange(l_23_0)
    else
      _application.Navigation.TabVisibility = false
      selector._visible = false
    end
end

OnNavigate = function(l_24_0)
   trace("***********************OnNavigate\n")
   trace(" OnNavigate \n")
   local l_24_1 = false
   if l_24_0 == NavigateDirection_None and 
                oldPageGroup ~= nil and
        oldPageGroup.Path:ToString(URLParts_All) ~= _application.Navigation.CurrentRequest.PageGroup.Path:ToString(URLParts_All) then
        l_24_1 = true
   end
   if l_24_0 == NavigateDirection_Arbitrary or l_24_0 == NavigateDirection_Front or l_24_0 == NavigateDirection_Back or oldPageGroup == nil or l_24_1 == true then
      trace(" rebuilding navigation \n")
      local l_24_2 = _application.Navigation.CurrentRequest.PageGroup.Level      
      trace("\n LEVEL: " .. l_24_2 .. " \n")
      BGChange(l_24_2)
      rebuildNavigation(l_24_2)
    else
      if l_24_0 == NavigateDirection_Left or
         l_24_0 == NavigateDirection_Right or
         l_24_0 == NavigateDirection_None then
         local pages = _application.Navigation.CurrentRequest.PageGroup.Pages
         local l_24_3 = _application.Navigation.CurrentRequest.Page.Path:ToString(URLParts_All)         
         local l_24_4 = -1
         local l_24_5 = 0         
         if trayIconsCount > 0 then
            for i = 0, trayIconsCount - 1 do
               if oldPages[i].Path:ToString(URLParts_All) == l_24_3 then
                  l_24_4 = i
               end
            end
         end
         trace("********** selectedIndex: " .. tostring(l_24_4))
         if l_24_4 > -1 then
            TabJumpTo(l_24_4)
         else
            trace("error: could not find selected index\n")
         end
      end
   end
end

OnTitleChanged = function()
   trace("***********************OnTitleChanged\n")
   trace("OnTitleChanged\n")
   TitleText.String = _application.Navigation.Title
   local l_25_0 = _application.Navigation.CurrentRequest.PageGroup.Path:ToString()
   if l_25_0 == "Manila://PeopleDetail" or l_25_0 == "Manila://PeopleDetail_SIM" then
      TitleTextLowLayer.String = ""
   else
      TitleTextLowLayer.String = _application.Navigation.Title
   end
end

OnTabVisibilityChanged = function()
   trace("***********************OnTabVisibilityChanged\n")
   trace("OnTabVisibilityChanged\n")
   if _tptabTimer then
      _tptabTimer:Stop()
   end
   if _application.Navigation.TabVisibility == true then
      if _application.Orientation == ScreenOrientation_Landscape then
         hideTabs()
         Landscape_up_btn_group._visible = true
         local sth = nil
         if _application.Navigation.CurrentRequest.PageGroup.Level == 0 then
           sth = "FirstLayer_up_tab"
         else
           sth = "SecondLayer_up_tab"
         end
         Landscape_up_btn:SetTextureRef(sth)
      else
         showTabs()
         Landscape_up_btn_group._visible = false
      end
   else
      hideTabs()
      Landscape_up_btn_group._visible = false
   end
end

OnTabTrayOpacityChanged = function()
   trace("***********************OnTabTrayOpacityChanged\n")
   trace("OnTabOpacityChanged\n")
   setTabTrayOpacity(_application.Navigation.TabTrayOpacity)
   setHomeTitleOpacity(_application.Navigation.TabTrayOpacity)
end

OnForceShowTitleBar = function()
   local l_28_0 = Titlebar
   l_28_0 = l_28_0.Opacity
   l_28_0.value = 100
end

OnTitlebarVisibilityChanged = function()
   trace("***********************OnTitlebarVisibilityChanged\n")
   trace("OnTitlebarVisibillityChanged\n")
   if _application.Navigation.TitlebarVisibility == false then
      Titlebar.Opacity.value = 0
   end
   if _application.Navigation.TitlebarVisibility == true then
      if _application.Orientation == ScreenOrientation_Landscape then
         if _application.Navigation.CurrentRequest.PageGroup.Level == 0 then
            Titlebar.Opacity.value = 0
         else
            Titlebar.Opacity.value = 100
         end
      else
         Titlebar.Opacity.value = 100
      end
   end
end

OnPageVisibilityChanged = function(l_30_0)
   trace("***********************OnPageVisibilityChanged\n")
   local urlparts = _application.Navigation.CurrentRequest.Page.Path:ToString(URLParts_All)
   local purl = l_30_0.Path:ToString(URLParts_All)
   if l_30_0.Visibility == false and urlparts == purl then
         local l3 = nil
         local l4 = _application.Navigation.CurrentRequest.PageGroup.Pages         
         while l4:Next() == true and l3 == nil do 
            if l4:GetValue().Visibility == true and
               l4:GetValue().Path:ToString(URLParts_All) ~= purl then
             l3 = l4:GetValue().Path
            end
         end 
         if l3 == nil then
            _application.Navigation:NavigateHome()
         else
            Navigate(l3, false)
         end
      end
      RefreshTabControl()
end

OnOrientationChanged = function()
   SystemTitlebarHeight = 52
   local l0 = nil
   trace("++++++++++[Manila.lua] : OnOrientationChanged")
   if _application.Orientation == ScreenOrientation_Portrait then
      trace("++++++++++[Manila.lua] : ScreenOrientation_Portrait")
      screenWidth = 480
      screenHeight = 800
      local l_31_1 = screenHeight - 2 * SystemTitlebarHeight
      Background_Cam.Viewport.value = RectF(0, 0, screenWidth, l_31_1 + 2)
      Background_Cam.ViewLeft.value = 0
      Background_Cam.ViewRight.value = screenWidth
      Background_Cam.ViewTop.value = l_31_1 + 2
      Background_Cam.ViewButtom.value = 0
      Content_Cam.Viewport.value = RectF(0, 0, screenWidth, l_31_1)
      Content_Cam.ViewLeft.value = 0
      Content_Cam.ViewRight.value = screenWidth
      Content_Cam.ViewTop.value = l_31_1
      Content_Cam.ViewButtom.value = 0
      previewRoot.Position.y = 528
      TabBackgroundGraphicLevel0.TextureCoords:set(0, 0.39840698242188, 240, 1)
      TabBackgroundGraphicLevel0.Size.width = 480
      TabBackgroundGraphicLevel1.TextureCoords:set(0, 0.39840698242188, 240, 1)
      TabBackgroundGraphicLevel1.Size.width = 480
      BackGroundLevel0:SetTextureRef("BG_level0")
      BackGroundLevel0.Position.x = 0
      BackGroundLevel0.Position.y = 698
      BackGroundLevel0.TextureCoords:set(0, 0, 0.9375, 1)
      BackGroundLevel0.Size.width = 480
      BackGroundLevel0.Size.height = 512
      BackGroundLevel0.Opacity.value = 65
      BackGroundLevel0_bottom:SetTextureRef("BG_level0_bottom")
      BackGroundLevel0_bottom.Position.x = 0
      BackGroundLevel0_bottom.Position.y = 186
      BackGroundLevel0_bottom.TextureCoords:set(0, 0.0078125, 0.9375, 0.7265625)
      BackGroundLevel0_bottom.Size.width = 480
      BackGroundLevel0_bottom.Size.height = 186
      BackGroundLevel0_bottom.Opacity.value = 65
      BackGroundLevel1:SetTextureRef("BG_level1")
      BackGroundLevel1.Position.x = 0
      BackGroundLevel1.Position.y = 698
      BackGroundLevel1.TextureCoords:set(0, 0, 0.9375, 1)
      BackGroundLevel1.Size.width = 480
      BackGroundLevel1.Size.height = 512
      BackGroundLevel1_bottom:SetTextureRef("BG_level1_bottom")
      BackGroundLevel1_bottom.Position.x = 0
      BackGroundLevel1_bottom.Position.y = 186
      BackGroundLevel1_bottom.TextureCoords:set(0, 0.0078125, 0.9375, 0.7265625)
      BackGroundLevel1_bottom.Size.width = 480
      BackGroundLevel1_bottom.Size.height = 186
      ModalBackground.Size.width = screenWidth
      ModalBackground.Size.height = l_31_1 + 1
      ModalBackground.Position.y = l_31_1 + 1
      ModalBackground.TextureCoords:set(0, 0, screenWidth / 2, (l_31_1 + 1) / 2)
      iconPreviewRoot.Position.x = 166
      iconPreviewRoot.Position.y = -95
      PreviewTitleText.Position.x = 0
      PreviewTitleText.Position.y = -280
      PreviewBackground.Size.width = screenWidth
      PreviewBackground.Size.height = 625

⌨️ 快捷键说明

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