vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | CalendarEditor_cMaxItems = 15; |
2 | |||
3 | gCalendarEditor_SelectedDate = -1; |
||
4 | gCalendarEditor_CompiledSchedule = nil; |
||
5 | |||
6 | function CalendarEditor_ShowCompiledSchedule(pDate, pCompiledSchedule) |
||
7 | -- Make sure the event editor and viewer is closed |
||
8 | |||
9 | CalendarEventEditor_DoneEditing(); |
||
10 | CalendarEventViewer_DoneViewing(); |
||
11 | |||
12 | -- |
||
13 | |||
14 | gCalendarEditor_SelectedDate = pDate; |
||
15 | gCalendarEditor_CompiledSchedule = pCompiledSchedule; |
||
16 | |||
17 | -- Set the date being displayed |
||
18 | |||
19 | CalendarEditorFrameSubTitle:SetText(Calendar_GetLongDateString(pDate)); |
||
20 | |||
21 | CalendarEditor_BuildCompiledScheduleList(pCompiledSchedule); |
||
22 | |||
23 | Calendar_SetButtonEnable(CalendarEditorNewEventButton, gCalendarEditor_SelectedDate >= gGroupCalendar_MinimumEventDate); |
||
24 | |||
25 | ShowUIPanel(CalendarEditorFrame); |
||
26 | end |
||
27 | |||
28 | function CalendarEditor_BuildCompiledScheduleList(pCompiledSchedule) |
||
29 | local vItemIndex = 1; |
||
30 | local vTotalNumItems = 0; |
||
31 | |||
32 | if pCompiledSchedule ~= nil then |
||
33 | -- Populate the schedule items |
||
34 | |||
35 | vTotalNumItems = table.getn(pCompiledSchedule); |
||
36 | |||
37 | for vEventIndex, vCompiledEvent in pCompiledSchedule do |
||
38 | local vEventItemName = "CalendarEditorEvent"..vItemIndex; |
||
39 | |||
40 | local vEventItemFrame = getglobal(vEventItemName); |
||
41 | local vEventItemTime = getglobal(vEventItemName.."Time"); |
||
42 | local vEventItemTitle = getglobal(vEventItemName.."Title"); |
||
43 | local vEventItemOwner = getglobal(vEventItemName.."Owner"); |
||
44 | local vEventItemCircled = getglobal(vEventItemName.."Circled"); |
||
45 | |||
46 | if vCompiledEvent.mEvent.mType == "Birth" then |
||
47 | vEventItemTime:SetText(GroupCalendar_cBirthdayEventName); |
||
48 | else |
||
49 | local vTime; |
||
50 | |||
51 | if gGroupCalendar_Settings.ShowEventsInLocalTime then |
||
52 | vTime = Calendar_GetLocalTimeFromServerTime(vCompiledEvent.mEvent.mTime); |
||
53 | else |
||
54 | vTime = vCompiledEvent.mEvent.mTime; |
||
55 | end |
||
56 | |||
57 | vEventItemTime:SetText(Calendar_GetShortTimeString(vTime)); |
||
58 | end |
||
59 | |||
60 | vEventItemTitle:SetText(EventDatabase_GetEventDisplayName(vCompiledEvent.mEvent)); |
||
61 | vEventItemOwner:SetText(vCompiledEvent.mOwner); |
||
62 | |||
63 | if EventDatabase_PlayerIsAttendingEvent(vCompiledEvent.mOwner, vCompiledEvent.mEvent) then |
||
64 | vEventItemCircled:Show(); |
||
65 | else |
||
66 | vEventItemCircled:Hide(); |
||
67 | end |
||
68 | |||
69 | vEventItemFrame:Show(); |
||
70 | |||
71 | vItemIndex = vItemIndex + 1; |
||
72 | |||
73 | if vItemIndex > CalendarEditor_cMaxItems then |
||
74 | break; |
||
75 | end |
||
76 | end |
||
77 | end |
||
78 | |||
79 | FauxScrollFrame_Update( |
||
80 | CalendarEditorScrollFrame, |
||
81 | vTotalNumItems, |
||
82 | CalendarEditor_cMaxItems, |
||
83 | 22, |
||
84 | nil, nil, nil, |
||
85 | nil, |
||
86 | 220, 254); |
||
87 | |||
88 | for vIndex = vItemIndex, CalendarEditor_cMaxItems do |
||
89 | local vEventItemFrame = getglobal("CalendarEditorEvent"..vIndex); |
||
90 | |||
91 | vEventItemFrame:Hide(); |
||
92 | end |
||
93 | end |
||
94 | |||
95 | function CalendarEditor_ScheduleChanged(pDate, pSchedule) |
||
96 | if pDate == gCalendarEditor_SelectedDate then |
||
97 | local vCompiledSchedule = EventDatabase_GetCompiledSchedule(pDate); |
||
98 | |||
99 | gCalendarEditor_CompiledSchedule = vCompiledSchedule; |
||
100 | |||
101 | CalendarEditor_BuildCompiledScheduleList(vCompiledSchedule); |
||
102 | end |
||
103 | end |
||
104 | |||
105 | function CalendarEditor_MajorDatabaseChange() |
||
106 | if not gCalendarEditor_SelectedDate == -1 then |
||
107 | return; |
||
108 | end |
||
109 | |||
110 | local vCompiledSchedule = EventDatabase_GetCompiledSchedule(gCalendarEditor_SelectedDate); |
||
111 | |||
112 | gCalendarEditor_CompiledSchedule = vCompiledSchedule; |
||
113 | |||
114 | CalendarEditor_BuildCompiledScheduleList(vCompiledSchedule); |
||
115 | end |
||
116 | |||
117 | function CalendarEditor_IsOpen() |
||
118 | return gCalendarEditor_SelectedDate ~= -1 |
||
119 | and not gCalendarEventEditor_Active |
||
120 | and not gCalendarEventViewer_Active; |
||
121 | end |
||
122 | |||
123 | function CalendarEditor_Close() |
||
124 | HideUIPanel(CalendarEditorFrame); |
||
125 | end |
||
126 | |||
127 | function CalendarEditor_OnShow() |
||
128 | PlaySound("igCharacterInfoOpen"); |
||
129 | end |
||
130 | |||
131 | function CalendarEditor_OnHide() |
||
132 | PlaySound("igCharacterInfoClose"); |
||
133 | gCalendarEditor_SelectedDate = -1; |
||
134 | GroupCalendar_EditorClosed(); |
||
135 | end |
||
136 | |||
137 | function CalendarEditor_NewEvent() |
||
138 | local vDatabase = EventDatabase_GetDatabase(gGroupCalendar_PlayerName, true); |
||
139 | local vEvent = EventDatabase_NewEvent(vDatabase, gCalendarEditor_SelectedDate); |
||
140 | |||
141 | CalendarEventEditor_EditEvent(vDatabase, vEvent, true); |
||
142 | end |
||
143 | |||
144 | function CalendarEditor_EditIndexedEvent(pIndex) |
||
145 | local vCompiledEvent = gCalendarEditor_CompiledSchedule[pIndex]; |
||
146 | local vDatabase = EventDatabase_GetDatabase(vCompiledEvent.mOwner); |
||
147 | |||
148 | if vDatabase then |
||
149 | if vDatabase.IsPlayerOwned |
||
150 | and not EventDatabase_IsResetEventType(vCompiledEvent.mEvent.mType) then |
||
151 | CalendarEventEditor_EditEvent(vDatabase, vCompiledEvent.mEvent, false); |
||
152 | else |
||
153 | CalendarEventViewer_ViewEvent(vDatabase, vCompiledEvent.mEvent); |
||
154 | end |
||
155 | end |
||
156 | end |