citypicker.luac.lua

来自「htc manila 2 sourcecode」· LUA 代码 · 共 164 行

LUA
164
字号
-- Decompiled using luadec 0.7 by sztupy (http://winmo.sztupy.hu)
-- Command line was: -l ;2,15,27;;0,12,16,42;;;;;;;0,33;;;;; 41b39431_manila.luac 

require("transitions")
require("scrollphysics")
require("LetterPicker")
require("weather_svc")
require("worldclock_svc")
g_BackUrl = _request.URL.Parameters:GetParameter("BackUrl")
InitialListView = function()
   local l_1_0 = TileLayout()
   l_1_0.SelectionNode = CountryPickerSelector
   l_1_0:SetItemSize(480, 80, 0)
   CountryPickerList:SetLayout(l_1_0)
   local l_1_1 = InputBox.WindowText
   local l_1_2 = LibraryGeneratorCity(weather:GetCountryList(), CountryPickerList:GetMovie(), CountryPickerList.ComponentLibraryName, CountryPickerList.ComponentLibraryID)
   l_1_2.ItemCreated:connect(HandleItemCreated)
   CountryPickerList:SetGenerator(l_1_2)
   CountryPickerList:Focus()
   CountryPickerListScrollPhysics = ScrollPhysics(CountryPickerList, CountryPickerList, HandleCountryListSelection)
   CountryPickerListScrollPhysics:ConnectMouseEvents()
end

HandleItemCreated = function(l_2_0, l_2_1)
   l_2_1.Namespace:FindName("CityPickerCityName").String = l_2_0.country
end

HandleCountryListSelection = function(l_3_0)
   _application.Navigation.Title = "[[IDS_SELECTCITY]]"
   if l_3_0 < 0 then
      return 
   end
   local l_3_1 = CountryPickerList:GetGenerator():GetData(l_3_0)
   currentCountry = l_3_1.country
   local l_3_2 = TileLayout()
   l_3_2:SetItemSize(480, 80, 0)
   l_3_2.SelectionNode = CityPickerSelector
   CityPickerList:SetLayout(l_3_2)
   local l_3_3 = LibraryGeneratorCity(weather:SearchCitiesInCountry("", l_3_1.country, 5000), CityPickerList:GetMovie(), CityPickerList.ComponentLibraryName, CityPickerList.ComponentLibraryID)
   l_3_3.ItemCreated:connect(HandleCityListItemCreation)
   CityPickerList:SetGenerator(l_3_3)
   CityPickerList:Focus()
   CityPickerListScrollPhysics = ScrollPhysics(CityPickerList, CityPickerList, HandleCityListSelection)
   CityPickerListScrollPhysics:ConnectMouseEvents()
   _application:SetLeftSoftkey(Softkey("", nil))
   _application:SetRightSoftkey(Softkey("Back", resetcountry))
   InputBox.WindowText = ""
   CountryPickerList._visible = false
   CountryPickerListScrollPhysics:DisconnectMouseEvents()
   CityPickerList._visible = true
   InputBoxDefaultText._visible = true
   InputBox:SetShowWindowFlag(false)
end

HandleCityListSelection = function(l_4_0)
   if l_4_0 < 0 then
      return 
   end
   SelectedCity = CityPickerList:GetGenerator():GetData(l_4_0)
   _application.Store:SetIntValue(Lifetime_Application, "WorldClock_IsFormCityPicker", 1001)
   _application.Navigation:Navigate(URL(g_BackUrl .. "?CityName=" .. SelectedCity.cityName .. "&AccuWeatherCode=" .. SelectedCity.accuweatherCode .. "&TimeZone=" .. tostring(SelectedCity.timezone)), false)
end

HandleCityListItemCreation = function(l_5_0, l_5_1)
   l_5_1.Namespace:FindName("CityPickerCityName").String = l_5_0.cityName
end

resetcountry = function()
   InputBox.WindowText = ""
   CountryPickerList._visible = true
   CityPickerList._visible = false
   _application.Navigation.Title = "[[IDS_SELECTCOUNTRY]]"
   CountryPickerListScrollPhysics:ConnectMouseEvents()
   CityPickerListScrollPhysics:DisconnectMouseEvents()
   _application:SetLeftSoftkey(Softkey("", nil))
   _application:SetRightSoftkey(Softkey("Cancel", function()
      _application.Navigation:NavigateBack()
   end))
   InputBoxDefaultText._visible = true
   InputBox:SetShowWindowFlag(false)
end

OnNavigateOut = function(l_7_0)
   _request.NavigateOutTo:disconnect(OnNavigateOut)
   _request.NavigateInFrom:disconnect(OnNavigateIn)
   Text_bg.onPress:disconnect(InputBoxOnPress)
   InputBox.onFocusOut:disconnect(FocusOutInputBox)
   InputBox.OnTextChanged:disconnect(InputBoxChanged)
   InputBox:SetShowWindowFlag(false)
   Transition(l_7_0, "Out")
end

OnNavigateIn = function(l_8_0)
   Transition(l_8_0, "In")
end

RightSoftKeyOnClick = function()
   _application.Navigation:Navigate(URL(g_BackUrl), false)
end

LetterSelected = function(l_10_0)
   if CountryPickerList._visible then
      local l_10_1 = weather:GetCountryLetterIndex(l_10_0)
      CountryPickerList:GetLayout():JumpToIndex(l_10_1, ListAlignment_Top, ListAlignmentOptions_Snap)
      CountryPickerList:JumpToIndex(l_10_1)
      CountryPickerList:GetGenerator().SelectedIndex = l_10_1
   else
      if CityPickerList._visible then
         local l_10_1 = weather:GetCityLetterIndex(l_10_0)
         CityPickerList:GetLayout():JumpToIndex(l_10_1, ListAlignment_Top, ListAlignmentOptions_Snap)
         CityPickerList:JumpToIndex(l_10_1)
         CityPickerList:GetGenerator().SelectedIndex = l_10_1
      end
   end
end

FocusOutInputBox = function()
   if InputBox.WindowText == "" then
      InputBoxDefaultText._visible = true
      LetterGroup._visible = true
   end
end

InputBoxOnPress = function()
   InputBox:SetShowWindowFlag(true)
   InputBoxDefaultText._visible = false
   LetterGroup._visible = false
end

InputBoxChanged = function()
   if CountryPickerList._visible then
      CountryPickerList:GetLayout():JumpToIndex(0, ListAlignment_Top, ListAlignmentOptions_Snap)
      CountryPickerList:JumpToIndex(0)
      CountryPickerList:GetGenerator().SelectedIndex = 0
      CountryPickerList:GetGenerator().Collection = weather:SearchCountries(InputBox.WindowText)
   else
      CityPickerList:GetLayout():JumpToIndex(0, ListAlignment_Top, ListAlignmentOptions_Snap)
      CityPickerList:JumpToIndex(0)
      CityPickerList:GetGenerator().SelectedIndex = 0
      CityPickerList:GetGenerator().Collection = weather:SearchCitiesInCountry(InputBox.WindowText, currentCountry, 5000)
   end
end

main = function()
   objs3D = {}
   objs3D[1] = Camera2D
   setOffScreen()
   _application:SetLeftSoftkey(Softkey("", nil))
   _application:SetRightSoftkey(Softkey("Cancel", RightSoftKeyOnClick))
   _application.Navigation.Title = "[[IDS_SELECTCOUNTRY]]"
   _application.Store:SetIntValue(Lifetime_Permanent, "Weather_DisableRandomAccess", 0)
   weather = AccuWeather(_application:GetScopedLog("weather"), _application.Store)
   _request.NavigateOutTo:connect(OnNavigateOut)
   _request.NavigateInFrom:connect(OnNavigateIn)
   Text_bg.onPress:connect(InputBoxOnPress)
   InputBox.OnTextChanged:connect(InputBoxChanged)
   InputBox.onFocusOut:connect(FocusOutInputBox)
   InitialListView()
   LetterPicker(LetterPickerListView, ScrubBar, LetterSelected, CharacterDialogGroup, LetterPickerDialogChar)
end

main()

⌨️ 快捷键说明

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