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

📄 digitalclock.luac.lua

📁 htc manila 2 sourcecode
💻 LUA
📖 第 1 页 / 共 2 页
字号:
   setmetatable(l_10_1, l_10_0)
   l_10_0.__index = l_10_0
   return l_10_1
end

DigitalClockHelperClass = class()
DigitalClockHelperClass.__init = function(l_11_0, l_11_1, l_11_2)
   l_11_0.DataBindingEnabled = l_11_2
   if l_11_2 then
      l_11_0.ClockTable = {LTabTop, LTabBottom, RTabTop, RTabBottom}
      for i_1,i_2 in ipairs(l_11_0.ClockTable) do
         i_2.onPress:connect(DigitalClockHelperClass.HandleTimePress, l_11_0)
         i_2.onMouseMove:connect(DigitalClockHelperClass.HandleTimeMouseMove, l_11_0)
         i_2.onRelease:connect(DigitalClockHelperClass.HandleTimeRelease, l_11_0)
         i_2.onReleaseOutside:connect(DigitalClockHelperClass.HandleTimeReleaseOutside, l_11_0)
      end
      l_11_1.CurrentTime.OnValueChanged:connect(DigitalClockHelperClass.HandleTimeChanged, l_11_0)
      l_11_1.TwentyFourHourTime.OnValueChanged:connect(DigitalClockHelperClass.HandleTimeChanged, l_11_0)
      l_11_1.TimeZone.OnValueChanged:connect(DigitalClockHelperClass.HandleTimeChanged, l_11_0)
   end
   l_11_0.HourFlip = nil
   l_11_0.MinuteFlip = nil
   local l3 = 1
   local l4 = 1
   if l_11_0.DataBindingEnabled then
      local l_11_5 = l_11_1.CurrentTime.Value
      if l_11_5.Hour - l3 < 0 then
         l_11_0.ShowingHour = 0
      else
         l_11_0.ShowingHour = l_11_5.Hour - l3
      end        
      if l_11_5.Minute - l4 < 0 then
         l_11_0.ShowingMinute = 0
      else
         l_11_0.ShowingMinute = l_11_5.Minute - l4
      end
   else
      l_11_0.ShowingHour = 6 - l3
      l_11_0.ShowingMinute = 15 - l4
   end
   l_11_0.FirstAnimationComplete = false
end

DigitalClockHelperClass.UpdateShowingTime = function(l_12_0)
   if l_12_0.HourFlip ~= nil then
      l_12_0.ShowingHour = l_12_0.HourFlip.ShowingTime
   end
   if l_12_0.MinuteFlip ~= nil then
      l_12_0.ShowingMinute = l_12_0.MinuteFlip.ShowingTime
   end
end

DigitalClockHelperClass.AnimationComplete = function(l_13_0)
   if not l_13_0.FirstAnimationComplete then
     local l_13_1 = true
     if l_13_0.HourFlip ~= nil and l_13_0.HourFlip.TimeDifference ~= 0 then
       l_13_1 = false
     end
     if l_13_0.MinuteFlip ~= nil and l_13_0.MinuteFlip.TimeDifference ~= 0 then
       l_13_1 = false
     end
     if l_13_1 then
        trace("First Animation Complete!\n")
        l_13_0.FirstAnimationComplete = true
     end
   end
   return l_13_0.FirstAnimationComplete
end

DigitalClockHelperClass.SetTime = function(l_14_0, l_14_1, l_14_2, l_14_3, l_14_4)
   if l_14_3 then
      trace("Setting time to " .. l_14_1 .. ":" .. l_14_2 .. "\n")
   elseif l_14_4 then
      trace("Setting time to " .. l_14_1 .. ":" .. l_14_2 .. " AM\n")
   else
      trace("Setting time to " .. l_14_1 .. ":" .. l_14_2 .. " PM\n")
   end
   local l_14_5 = 0
   local l_14_6 = 0
   local l_14_7 = false
   Date.String = machineStatus.CurrentTime.Value:GetDateString(Locale:GetString("IDS_DATEFORMAT"))
   if l_14_1 < l_14_0.ShowingHour or l_14_1 == l_14_0.ShowingHour and l_14_0.HourFlip ~= nil and l_14_0.HourFlip.TimeDifference > 0 then
      if l_14_3 then
         l_14_5 = 24 - l_14_0.ShowingHour + l_14_1
      elseif l_14_0.ShowingHour > 12 then
         l_14_5 = 24 - l_14_0.ShowingHour + l_14_1
      else
         l_14_5 = 12 - l_14_0.ShowingHour + l_14_1
      end
   else
      l_14_5 = l_14_1 - l_14_0.ShowingHour
   end
   if l_14_2 < l_14_0.ShowingMinute or l_14_2 == l_14_0.ShowingMinute and l_14_0.MinuteFlip ~= nil and l_14_0.MinuteFlip.TimeDifference > 0 then
      l_14_6 = 60 - l_14_0.ShowingMinute + l_14_2
   else
      l_14_6 = l_14_2 - l_14_0.ShowingMinute
   end
   if (l_14_0.FirstAnimationComplete and (l_14_5 > 1 or l_14_6 > 1)) or l_14_5 + (l_14_6) > 10 then
      trace("Setting time instantly\n")
      l_14_7 = true
   end
   if l_14_3 then
      AMPMFlip._visible = false
      AMPM._visible = false
   elseif l_14_4 then
      AMPMFlip._visible = true
      AMFlip._visible = true
      PMFlip._visible = false
   else
      AMPMFlip._visible = true
      PMFlip._visible = true
      AMFlip._visible = false
   end
   if l_14_5 > 0 then
      if l_14_0.HourFlip == nil then
         l_14_0.HourFlip = TabFlip:new()
         l_14_0.HourFlip.UpdateShowingTime = {Function = l_14_0.UpdateShowingTime, Param = l_14_0}
         l_14_0.HourFlip.AnimationComplete = {Function = l_14_0.AnimationComplete, Param = l_14_0}
         local tab1 = TabHalf:new()
         local tab2 = TabHalf:new()
         local tab3 = TabHalf:new()
         local tab4 = TabHalf:new()
         tab1.Tab = LTabTop
         tab1.HighDigit = LHighDigitTop
         tab1.LowDigit = LLowDigitTop
         tab2.Tab = LTabBottom
         tab2.HighDigit = LHighDigitBottom
         tab2.LowDigit = LLowDigitBottom
         tab3.Tab = LTabTopFlip
         tab3.HighDigit = LHighDigitTopFlip         
         tab3.LowDigit = LLowDigitTopFlip         
         tab4.Tab = LTabBottomFlip
         tab4.HighDigit = LHighDigitBottomFlip
         tab4.LowDigit = LLowDigitBottomFlip
         l_14_0.HourFlip.TopTab = tab1
         l_14_0.HourFlip.BottomTab = tab2
         l_14_0.HourFlip.TopTabFlip = tab3
         l_14_0.HourFlip.BottomTabFlip = tab4
         l_14_0.HourFlip.ShowingTime = l_14_0.ShowingHour
      end
      if l_14_3 then
         l_14_0.HourFlip.WrapAroundNumber = 23
         l_14_0.HourFlip.StartValue = 0
      else
         l_14_0.HourFlip.WrapAroundNumber = 12
         l_14_0.HourFlip.StartValue = 1
      end
      if l_14_7 == true then
         l_14_0.ShowingHour = l_14_1
         l_14_0.HourFlip:StopAnimationAndSetTime(l_14_1)
      else
         if l_14_0.HourFlip.TimeDifference == 0 then
            l_14_0.HourFlip.TimeDifference = l_14_5
            l_14_0.HourFlip:StartAnimation()
         else
            l_14_0.HourFlip.TimeDifference = l_14_5
         end
      end         
    else
       if AMFlip._visible ~= AMBottom._visible or PMFlip._visible ~= PMBottom._visible or AMPMFlip._visible ~= AMPM._visible then
          AMPM._visible = AMPMFlip._visible
          AMBottom._visible = AMFlip._visible
          PMBottom._visible = PMFlip._visible
       end
   end
   if l_14_6 > 0 then
      if l_14_0.MinuteFlip == nil then
         l_14_0.MinuteFlip = TabFlip:new()
         l_14_0.MinuteFlip.UseAltTiming = true
         l_14_0.MinuteFlip.UpdateShowingTime = {Function = l_14_0.UpdateShowingTime, Param = l_14_0}
         l_14_0.MinuteFlip.AnimationComplete = {Function = l_14_0.AnimationComplete, Param = l_14_0}
         local tab1 = TabHalf:new()
         local tab2 = TabHalf:new()
         local tab3 = TabHalf:new()
         local tab4 = TabHalf:new()
         tab1.Tab = RTabTop
         tab1.HighDigit = RHighDigitTop
         tab1.LowDigit = RLowDigitTop
         tab2.Tab = RTabBottom
         tab2.HighDigit = RHighDigitBottom
         tab2.LowDigit = RLowDigitBottom
         tab3.Tab = RTabTopFlip
         tab3.HighDigit = RHighDigitTopFlip         
         tab3.LowDigit = RLowDigitTopFlip         
         tab4.Tab = RTabBottomFlip
         tab4.HighDigit = RHighDigitBottomFlip
         tab4.LowDigit = RLowDigitBottomFlip         
         l_14_0.MinuteFlip.TopTab = tab1
         l_14_0.MinuteFlip.BottomTab = tab2
         l_14_0.MinuteFlip.TopTabFlip = tab3
         l_14_0.MinuteFlip.BottomTabFlip = tab4
         l_14_0.MinuteFlip.ShowingTime = l_14_0.ShowingMinute
         l_14_0.MinuteFlip.WrapAroundNumber = 59
         l_14_0.MinuteFlip.ShouldHideLeadingZeros = false
      end
      if l_14_7 == true then
         l_14_0.ShowingMinute = l_14_2
         l_14_0.MinuteFlip:StopAnimationAndSetTime(l_14_2)
      else
         if l_14_0.MinuteFlip.TimeDifference == 0 then
            l_14_0.MinuteFlip.TimeDifference = l_14_6
            l_14_0.MinuteFlip:StartAnimation()
         else
            l_14_0.MinuteFlip.TimeDifference = l_14_6
         end
      end
   end
end

DigitalClockHelperClass.HandleTimeChanged = function(l_15_0)
   if l_15_0.DataBindingEnabled then
      local l_15_1 = machineStatus.CurrentTime.Value     
      l_15_0:SetTime(l_15_1.Hour, l_15_1.Minute, l_15_1.IsTwentyFourHour, l_15_1.IsAM)
   else
      l_15_0:SetTime(12, 59, false, true)
   end
   if l_15_0.OnTimeChanged ~= nil then
      l_15_0.OnTimeChanged.Function()
   end
end

DigitalClockHelperClass.HandleTimePress = function(l_16_0, l_16_1, l_16_2)
   if l_16_0.OnTimePress ~= nil then
      l_16_0.OnTimePress.Function(l_16_1, l_16_2, l_16_0.OnTimePress.Param)
      trace("Handled value is: " .. (l_16_2.value and "true" or "false") .. "\n")
   end
end

DigitalClockHelperClass.HandleTimeMouseMove = function(l_17_0, l_17_1)
   if l_17_0.OnTimeMouseMove ~= nil then
      l_17_0.OnTimeMouseMove.Function(l_17_1, l_17_0.OnTimeMouseMove.Param)
   end
end

DigitalClockHelperClass.HandleTimePress = function(l_18_0, l_18_1, l_18_2)
   if l_18_0.OnTimePress ~= nil then
      trace("time press\n")
      l_18_0.OnTimePress.Function(l_18_1, l_18_2, l_18_0.OnTimePress.Param)
      trace("Handled value is: " .. (l_18_2.value and "true" or "false") .. "\n")
   end
end

DigitalClockHelperClass.HandleTimeRelease = function(l_19_0, l_19_1, l_19_2)
   if l_19_0.OnTimeRelease ~= nil then
      trace("time release\n")
      l_19_0.OnTimeRelease.Function(l_19_1, l_19_2, l_19_0.OnTimeRelease.Param)
      trace("Handled value is: " .. (l_19_2.value and "true" or "false") .. "\n")
   end
end

DigitalClockHelperClass.HandleTimeReleaseOutside = function(l_20_0, l_20_1, l_20_2)
   if l_20_0.OnTimeReleaseOutside ~= nil then
      trace("time release outside\n")
      l_20_0.OnTimeReleaseOutside.Function(l_20_1, l_20_2, l_20_0.OnTimeReleaseOutside.Param)
      trace("Handled value is: " .. (l_20_2.value and "true" or "false") .. "\n")
   end
end


⌨️ 快捷键说明

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