-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathstack_ScriptTrackerPrefs_.livecodescript
More file actions
149 lines (123 loc) · 4.36 KB
/
stack_ScriptTrackerPrefs_.livecodescript
File metadata and controls
149 lines (123 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
Script "stack_ScriptTrackerPrefs_"
/*
# Name: stack "ScriptTrackerPrefs" of stack "ScriptTracker"
# ID: stack "ScriptTrackerPrefs" of stack "ScriptTracker"
*/
//>LOCALS
local sPrefsA, sStackName
on openCard
set the hilitedItemNames of widget 1 of group 1 of this card \
to the short name of this card
end openCard
on checkPref pPref, pValue, @xPrefsA, @xPrefsChanged
--if pValue is empty then exit checkPref
if pValue is not xPrefsA[pPref] then
put pValue into xPrefsA[pPref]
put true into xPrefsChanged
end if
end checkPref
on preOpenCard
if the short name of this card is among the items of "Stack,Exclusions" then
put field "StackName" of stack "ScriptTracker" into sStackName
if there is not a stack sStackName then
go card "Defaults"
exit preOpenCard
end if
put the customProperties[getPref("PropertySet")] of stack sStackName \
into sPrefsA
if sPrefsA is empty then
reinitializeStackPrefs
exit preOpenCard
end if
else
put getPrefsA() into sPrefsA
end if
displayPrefs
end preOpenCard
on closeCard
saveUpdatedPrefs
end closeCard
on displayPrefs
repeat for each item tPref in the uCheckBoxes of this card
set the hilite of button tPref of this card to (sPrefsA[tPref] is true)
end repeat
repeat for each item tPref in the uTextFields of this card
set the text of field tPref of this card to sPrefsA[tPref]
end repeat
repeat for each item tPref in the uOptionMenus of this card
set the label of button tPref of this card to sPrefsA[tPref]
end repeat
end displayPrefs
on saveUpdatedPrefs
local tPrefsChanged
repeat for each item tPref in the uCheckBoxes of this card
checkPref tPref, the hilite of button tPref of this card, \
sPrefsA, tPrefsChanged
end repeat
repeat for each item tPref in the uTextFields of this card
checkPref tPref, the text of field tPref of this card, \
sPrefsA, tPrefsChanged
end repeat
repeat for each item tPref in the uOptionMenus of this card
checkPref tPref, the label of button tPref of this card, \
sPrefsA, tPrefsChanged
end repeat
if tPrefsChanged then
if the short name of this card is among the items of "Stack,Exclusions" then
if there is a stack sStackName then
set the customProperties[getPref("PropertySet")] of \
stack sStackName to sPrefsA
restartAutoSync
else
beep
answer "Error: Stack" && quote & sStackName & quote && \
"is not open. Unable to edit preferences."
end if
else
setPrefsA sPrefsA
end if
end if
end saveUpdatedPrefs
on reinitializePrefs
local tPrefsA, tPrefsChanged
if the short name of this card is "Stack" then
reinitializeStackPrefs
exit reinitializePrefs
end if
put getDefaultPrefsA() into tPrefsA
repeat for each item tPref in the uCheckBoxes of this card
checkPref tPref, tPrefsA[tPref], sPrefsA, tPrefsChanged
end repeat
repeat for each item tPref in the uTextFields of this card
checkPref tPref, tPrefsA[tPref], sPrefsA, tPrefsChanged
end repeat
repeat for each item tPref in the uOptionMenus of this card
checkPref tPref, tPrefsA[tPref], sPrefsA, tPrefsChanged
end repeat
if tPrefsChanged then
setPrefsA sPrefsA
end if
displayPrefs
end reinitializePrefs
on reinitializeStackPrefs
local tExportPath, tPrefsA, tStackFileName
// get stack file name without extension
set the itemdel to "/"
put item -1 of (char 2 to -2 of word -1 of the long id of \
stack sStackName) into tStackFileName
set the itemdel to "."
delete item -1 of tStackFileName
put getPrefsA() into tPrefsA
put merge(tPrefsA["ExportPath"]) into tExportPath
put tExportPath into sPrefsA["ExportPath"]
put merge(tPrefsA["DiffPath"]) into sPrefsA["DiffPath"]
put merge(tPrefsA["ExtraPath"]) into sPrefsA["ExtraPath"]
put tPrefsA["CollisionPolicy"] into sPrefsA["CollisionPolicy"]
repeat for each item tType in "stack,group,card,widget,button,field,other"
put false into tPrefsA["exclude" & tType ]
end repeat
set the customProperties[getPref("PropertySet")] of stack sStackName \
to sPrefsA
displayPrefs
restartAutoSync
end reinitializeStackPrefs