calendarpickerscript.luac.lua
来自「htc manila 2 sourcecode」· LUA 代码 · 共 651 行 · 第 1/2 页
LUA
651 行
PreCalendar._visible = false
calendar:PreviousNMonth(2)
GetNextList(PreCalendar, CalendarControl.PreMonthX)
calendar:NextNMonth(1)
CalendarControl:SetInitSelection()
YearText.String = calendar:GetCurrentYearName(4)
MonthText.String = calendar:GetCurrentMonthName(3)
CalendarControl:ResetBound()
CalendarControl:SetSelection()
ConnectCalendarEvent()
end
CheckChangeDay = function(l_33_0, l_33_1, l_33_2, l_33_3)
local l_33_4 = 0
local l_33_5 = nil
local l_33_6 = false
local l_33_7 = 0
if l_33_0.Year == l_33_1 and l_33_0.Month == l_33_2 then
l_33_4 = calendar:GetWeek(l_33_0.Year, l_33_0.Month, l_33_0.Day) - 1
l_33_5 = l_33_3.Tag[(l_33_4) * 7 + l_33_0.DayOfWeek]
l_33_6 = appointment:IsAppointmentOnDay(l_33_0.Year, l_33_0.Month, l_33_0.Day)
SetTextureToDay(l_33_5, true, true, l_33_6)
end
if l_33_1 == CalendarControl.Year and l_33_2 == CalendarControl.Month then
l_33_4 = calendar:GetWeek(CalendarControl.Year, CalendarControl.Month, CalendarControl.Day) - 1
l_33_7 = calendar:GetDayOfWeek(CalendarControl.Year, CalendarControl.Month, CalendarControl.Day)
l_33_5 = l_33_3.Tag[(l_33_4) * 7 + l_33_7]
l_33_6 = appointment:IsAppointmentOnDay(CalendarControl.Year, CalendarControl.Month, CalendarControl.Day)
SetTextureToDay(l_33_5, false, true, l_33_6)
end
end
onDayChange = function()
local l_34_0 = calendar:GetToday()
trace("day=" .. l_34_0.Day .. "CalendarControl.Day=" .. CalendarControl.Day)
if l_34_0.Day ~= CalendarControl.Day then
local l_34_1, l_34_2 = CalendarControl:GetNextMonth(calendar:GetCurrentYear(),calendar:GetCurrentMonth())
local l_34_3, l_34_4 = CalendarControl:GetPreMonth(calendar:GetCurrentYear(),calendar:GetCurrentMonth())
CheckChangeDay(l_34_0, calendar:GetCurrentYear(), calendar:GetCurrentMonth(), ActiveCalendar)
CheckChangeDay(l_34_0, l_34_3, l_34_4, PreCalendar)
CheckChangeDay(l_34_0, l_34_1, l_34_2, NextCalendar)
CalendarControl:SetToday(l_34_0)
end
end
IsToday = function(l_35_0, l_35_1, l_35_2)
local l_35_3 = calendar:GetToday()
if l_35_3.Year == l_35_0 and l_35_3.Month == l_35_1 and l_35_3.Day == l_35_2 then
return true
end
return false
end
SetTextureToDay = function(l_36_0, l_36_1, l_36_2, l_36_3)
if l_36_3 then
l_36_0:SetTextureRef("green_rectangle")
elseif l_36_2 then
if l_36_1 then
l_36_0:SetTextureRef("gray_rectangle")
else
l_36_0:SetTextureRef("white_rectangle")
end
else
l_36_0:SetTextureRef("gray_rectangle")
end
end
initMonthDayText = function()
local x = GLESText()
x.Color = Color(0, 0, 0, 255)
x.FontPath = "\\Windows\\HTC\\Assets\\Fonts\\Helvetica Neue LT Pro 1\\neue helvetica 55 roman.ttf"
x.FontSize = 15
x.Position.x = 2
x.Position.y = 0
x.Position.z = 0
x.Size.width = CalendarControl.textArea
x.Size.height = CalendarControl.textArea
return x
end
initCurrentMonth = function()
local x = GLESText()
x.Color = Color(0, 0, 0, 255)
x.FontPath = "\\Windows\\HTC\\Assets\\Fonts\\Helvetica Neue LT Pro 1\\neue helvetica 55 roman.ttf"
x.FontSize = 27
x.Position.x = 123
x.Position.y = -43.5
x.Position.z = 0
x.Size.width = 300
x.Size.height = 39
x.VerticalAlignment = Alignment_VerticalCenter
x.HorizontalAlignment = Alignment_Left
return x
end
initCurrentYear = function(l_39_0, l_39_1, l_39_2, l_39_3)
local x = GLESText()
x.Color = Color(0, 0, 0, 255)
x.FontPath = "\\Windows\\HTC\\Assets\\Fonts\\Helvetica Neue LT Pro 1\\neue helvetica 55 roman.ttf"
x.FontSize = 27
x.Position.x = l_39_0
x.Position.y = l_39_1
x.Position.z = l_39_2
x.Size.width = 120
x.Size.height = 39
x.VerticalAlignment = Alignment_VerticalCenter
x.HorizontalAlignment = l_39_3
return x
end
initMonthLabel = function(l_40_0, l_40_1, l_40_2)
local x = GLESText()
x.Color = Color(0, 0, 0, 255)
x.FontPath = "\\Windows\\HTC\\Assets\\Fonts\\Helvetica Neue LT Pro 1\\neue helvetica 55 roman.ttf"
x.FontSize = 22
x.Position.x = l_40_0
x.Position.y = l_40_1
x.Position.z = l_40_2
x.Size.width = CalendarControl.Width
x.Size.height = CalendarControl.Height
x.VerticalAlignment = Alignment_VerticalCenter
x.HorizontalAlignment = Alignment_HorizontalCenter
return x
end
initMonthItem = function(l_41_0, l_41_1, l_41_2)
local x = GLESSprite2D()
x.TextureCoords.x = 0
x.TextureCoords.y = 0
x.TextureCoords.width = 0.98460388183594
x.TextureCoords.height = 0.78118896484375
x.Size.width = CalendarControl.Width
x.Size.height = CalendarControl.Height
x.Position.x = l_41_0
x.Position.y = l_41_1
x.Position.z = l_41_2
return x
end
destoryCalendar = function(l_42_0)
local l_42_1 = l_42_0.Tag
if l_42_1 ~= nil then
local l_42_2 = l_42_1.group.Nodes
local l_42_3 = 41
for i = 0, 6 do
l_42_0:Detach(l_42_1.label[i])
l_42_1.label[i] = nil
end
for i = 0, l_42_3 do
l_42_1.group:Detach(l_42_1[i])
l_42_1[i]:Detach(l_42_1.text[i])
l_42_1[i] = nil
l_42_1.text[i] = nil
end
l_42_0:Detach(l_42_1.month)
l_42_0:Detach(l_42_1.year)
l_42_0:Detach(l_42_1.group)
l_42_1.label = nil
l_42_1.text = nil
l_42_1.group = nil
l_42_1.month = nil
l_42_1.year = nil
l_42_1 = nil
l_42_0.Tag = nil
end
end
CreateCalendar = function(l_43_0)
trace("create calendar start")
local l_43_1 = 6
local l_43_2 = {}
l_43_0.Tag = l_43_2
l_43_2.group = Group()
l_43_0:Attach(l_43_2.group)
l_43_2.month = initCurrentMonth()
l_43_2.year = initCurrentYear(313, -43.5, 0, Alignment_Left)
l_43_0:Attach(l_43_2.month)
l_43_0:Attach(l_43_2.year)
l_43_2.count = l_43_1 * 7
local l_43_3 = l_43_1 - 1
local l_43_4 = CalendarControl.weekNamePosX
local l_43_5 = CalendarControl.weekNamePosY
local l_43_6 = 0
l_43_2.label = {}
for i = 0, 6 do
l_43_2.label[i] = initMonthLabel(l_43_4, l_43_5, l_43_6)
l_43_0:Attach(l_43_2.label[i])
l_43_2.label[i].String = Locale:GetString("IDS_WEEK_" .. i)
l_43_4 = l_43_4 + CalendarControl.Width
end
local l_43_7 = 0
local l_43_8 = calendar:GetCurrentMonth()
l_43_2.text = {}
l_43_5 = 0
for i1 = 0, l_43_3 do
l_43_4 = 0
for i2 = 0, 6 do
l_43_7 = i1 * 7 + i2
l_43_2[l_43_7] = initMonthItem(l_43_4, l_43_5, l_43_6)
l_43_2.text[l_43_7] = initMonthDayText()
l_43_2.group:Attach(l_43_2[l_43_7])
l_43_2[l_43_7]:Attach(l_43_2.text[l_43_7])
l_43_4 = l_43_4 + CalendarControl.Width
end
l_43_5 = l_43_5 - CalendarControl.Height
end
trace("create calendar end")
end
GetNextList = function(l_44_0, l_44_1)
trace("GetNextList.." .. l_44_1)
l_44_0.Position.x = l_44_1
local l_44_2 = calendar:GetWeeksInMonth(calendar:GetCurrentYear(), calendar:GetCurrentMonth())
local l_44_3 = l_44_0.Tag
trace("CurrentYear=" .. calendar:GetCurrentYear() .. " CurrentMonth=" .. calendar:GetCurrentMonth() .. " weekNum=" .. l_44_2)
l_44_3.group.Position.y = CalendarControl:GetPosY(l_44_2)
l_44_3.group.Position.x = 23
l_44_3.month.String = calendar:GetCurrentMonthName()
l_44_3.year.String = calendar:GetCurrentYearName()
local l_44_4 = l_44_3.count
l_44_3.count = l_44_2 * 7
trace("old count=" .. l_44_4 .. "new count=" .. l_44_3.count)
local l_44_5 = 0
local l_44_6 = 0
local l_44_7 = 0
local l_44_8 = 0
local l_44_9 = calendar:GetCurrentMonth()
trace("current month=" .. l_44_9)
l_44_6 = 0
while l_44_3.count < l_44_4 do
l_44_4 = l_44_4 - 1
l_44_3[l_44_4]._visible = false
end
while l_44_4 < l_44_3.count do
l_44_3[l_44_4]._visible = true
l_44_4 = l_44_4 + 1
end
trace("init day")
for i1 = 0, l_44_2 - 1 do
for i2 = 0, 6 do
l_44_8 = i1 * 7 + i2
l_44_3.text[l_44_8].String = ResetDayAppointment(l_44_3[l_44_8], i1, i2, l_44_9)
end
end
trace("getNextList= end")
end
ResetDayAppointment = function(l_45_0, l_45_1, l_45_2, l_45_3)
local l_45_4 = ""
local l_45_5 = calendar:GetPosDay(l_45_1, l_45_2)
local l_45_6 = calendar:GetPosYear(l_45_1, l_45_2)
local l_45_7 = calendar:GetPosMonth(l_45_1, l_45_2)
local l_45_8 = l_45_3 == l_45_7
local l_45_9 = CalendarControl:IsSelected(l_45_6, l_45_7, l_45_5)
SetTextureToDay(l_45_0, IsToday(l_45_6, l_45_7, l_45_5), l_45_8)
if l_45_8 then
l_45_4 = l_45_4 .. tostring(l_45_5)
end
return l_45_4
end
DisconnectCalendarEvent = function()
CalendarHitArea.onPress:disconnect(HandleCalendarMousePress)
CalendarHitArea.onReleaseOutside:disconnect(HandleCalendarReleaseOutside)
MonthSubIcon.onPress:disconnect(HandleOnMonthSubPress)
MonthAddIcon.onPress:disconnect(HandleOnMonthAddPress)
YearSubIcon.onPress:disconnect(HandleYearSubPress)
YearAddIcon.onPress:disconnect(HandleYearAddPress)
Group3D.onKeyDown:disconnect(HandleCalendarKeyDown)
end
ConnectCalendarEvent = function()
CalendarHitArea.onPress:connect(HandleCalendarMousePress)
CalendarHitArea.onReleaseOutside:connect(HandleCalendarReleaseOutside)
MonthSubIcon.onPress:connect(HandleOnMonthSubPress)
MonthAddIcon.onPress:connect(HandleOnMonthAddPress)
YearSubIcon.onPress:connect(HandleYearSubPress)
YearAddIcon.onPress:connect(HandleYearAddPress)
Group3D.onKeyDown:connect(HandleCalendarKeyDown)
end
LSKfunction = function()
FrmClockView.PageEdit:SetNewDate(CalendarControl.selectedYear, CalendarControl.selectedMonth, CalendarControl.selectedDay)
FrmClockView:Switch(FrmClockView.PageEdit)
end
DatePicker = class(WorldClock.Clock.PageBase)
DatePicker.__init = function(l_49_0)
setOffScreen()
l_49_0.Node = DatePickerNode
l_49_0.ComponentName = "DatePickerComponent"
end
DatePicker.ShowPage = function(l_50_0)
if not l_50_0.Initialized then
l_50_0:Initialize()
end
l_50_0.Node._visible = true
ActiveCalendar = Calendar_1
NextCalendar = Calendar_2
PreCalendar = Calendar_3
_application:SetRightSoftkey(Softkey("", nil))
_application:SetLeftSoftkey(Softkey(Locale:GetString("IDS_SELECTDATE"), LSKfunction))
Group3D:Focus()
trace("_application.Navigation.Title=" .. _application.Navigation.Title)
_application.Navigation.Title = "Select a date"
initialCalendar()
if _application.Store:GetStringValue(Lifetime_Permanent, "EnableLandscape") == "true" then
trace(" EnableLandscape")
require("Calendar\\Calendar_Picker_Landscape")
CalendarPicker_RotationControl = CalendarPicker_ScreenRotation(Camera2D, Camera3D, CalendarGroup, ControlGroup, YearControl, MonthControl)
end
ConnectCalendarEvent()
end
DatePicker.HidePage = function(l_51_0)
l_51_0.Node._visible = false
destoryCalendar(ActiveCalendar)
destoryCalendar(NextCalendar)
destoryCalendar(PreCalendar)
DisconnectCalendarEvent()
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?