· 4 years ago · Feb 07, 2021, 05:48 PM
1-- Easy Graphical User Interface for CraftOS
2-- with interactive designer
3-- v.1.2, for CraftOS 1.8
4
5--Please read until line 48 if you are new to EasyGUI!
6--If you need help the designer, run it on a computer and get help to almost everything if you hold F1 and click on the specific thing you have questions about.
7
8--multiple monitor support: this array stores the wrapped peripherals, monitor sizes and text scales
9monitors = {}
10terminalScreen = nil
11
12--GUI Elements Clickable
13--dynamic text boxes include rectangles by using an empty string and buttons (even checkboxes) by assigning an onClick Function
14dynamicTextBoxes = {}
15sliders = {}
16dropDownMenus = {}
17navigationMenus = {}
18colorPickers = {}
19
20--unclickable
21--progressBars can also be used as bar charts by assigning the bg color to one of its colors
22progressBars = {}
23coordinateSystems = {}
24pictures = {}
25
26elements = {}
27
28--For GUI Elements to be rendered, they need to be added to a screen. A screen can then be saved and rendered on any advanced device.
29screens = {}
30
31--PLEASE READ THIS ABOUT FILE SYSTEM
32--You might want to change the following value if you are not running EasyGUI in a root directory.
33--For example: if you put EasyGUI.lua in a folder called apis, change to: 'root = "/apis/"'
34root = "/"
35
36--1 = DEBUG, 2 = INFO, 3 = WARNING, 4 = ERROR, 5 = FATAL
37--PLEASE READ THIS ABOUT LOGGING!
38--WARNING level 1 results in extremely large files. Use only when debugging.
39--Level 2 can also be rather big. Leave it at 3 if everything works ok.
40--Keep in mind that the size of log file over time depends on the refresh rate used.
41--Note that by default one cc computer only has 1mb of storage, can be changed in computercraft.cfg.
42--If less than 1kb is available, log won't be written to anymore.
43writingLogLevel = 3
44
45--Designer/Editor colors.
46--If you don't like the default settings, change the colors here: default text color, default background color and an accent color.
47colorPalette = {colors.white,colors.black,colors.green}
48
49-------- Changelog
50
51--07/02/2020: Release 1.2 pastebin:
52--helping page for everything related to using the api in a program
53--tested: different text colors in dynTextBoxes using §a, also functional §n for paragraph: this feature has been implemented thoroughly into the designer
54-------
55
56--29/01/2020: Release 1.1 pastebin: ZZXJtQfA
57--implemented helping dialogue for many elements by holding f1 and clicking on it
58--implemented more hotkeys like Ctrl+Z for undo
59-------
60
61--16/01/2020: Release 1.0 pastebin: LxhGCu7F
62--fixed #1,#2 and #3
63--cleaned up adding a new screen while running designer on monitor
64--everything else appears very stable up to this point
65-------
66
67--25/12/2020: Release Beta v.0.1 pastebin: LGVzZLwK
68-- All features that were planned at this point have now been implemented.
69-- It took roughly half a year. An intensive testing phase is about to begin.
70-------
71
72-- Bugs
73--#1 designer not usable on turtle and pocket screen / fixed 16/01/2021
74--#2 wireless modems throw errors during monitor initialization sequence / fixed 16/01/2021
75--#3 when using only terminal and no monitors, will always try to find new monitors / fixed 16/01/2021
76-------
77
78--Future plans:
79--interactive helping page for everything related to using the api in a programm
80--feature that generates a generic EasyGUI implementation program
81-------
82
83----------------------------------
84--Technical stuff starting. Enjoy.
85refreshTimerID = nil
86refreshRate = nil
87
88IDlist = {}
89startTime = os.clock()
90logFile = nil
91lastLogString = nil
92
93refreshFunction = nil
94processClickEventFunc = nil
95processEventFunc = nil
96
97args = {...}
98
99--color arrays
100colorsArrayStrToNum = {}
101colorsArrayStrToNum["0"] = colors.white
102colorsArrayStrToNum["1"] = colors.orange
103colorsArrayStrToNum["2"] = colors.magenta
104colorsArrayStrToNum["3"] = colors.lightBlue
105colorsArrayStrToNum["4"] = colors.yellow
106colorsArrayStrToNum["5"] = colors.lime
107colorsArrayStrToNum["6"] = colors.pink
108colorsArrayStrToNum["7"] = colors.gray
109colorsArrayStrToNum["8"] = colors.lightGray
110colorsArrayStrToNum["9"] = colors.cyan
111colorsArrayStrToNum["a"] = colors.purple
112colorsArrayStrToNum["b"] = colors.blue
113colorsArrayStrToNum["c"] = colors.brown
114colorsArrayStrToNum["d"] = colors.green
115colorsArrayStrToNum["e"] = colors.red
116colorsArrayStrToNum["f"] = colors.black
117colorsArrayStrToNum["?"] = colorPalette[3]
118
119colorsArrayNumToNum = {colors.white,colors.orange,colors.magenta,colors.lightBlue,colors.yellow,colors.lime,colors.pink,colors.gray,colors.lightGray,colors.cyan,colors.purple,colors.blue,colors.brown,colors.green,colors.red,colors.black}
120
121colorsArrayNumToString = {}
122colorsArrayNumToString[colors.white] = "0"
123colorsArrayNumToString[colors.orange] = "1"
124colorsArrayNumToString[colors.magenta] = "2"
125colorsArrayNumToString[colors.lightBlue] = "3"
126colorsArrayNumToString[colors.yellow] = "4"
127colorsArrayNumToString[colors.lime] = "5"
128colorsArrayNumToString[colors.pink] = "6"
129colorsArrayNumToString[colors.gray] = "7"
130colorsArrayNumToString[colors.lightGray] = "8"
131colorsArrayNumToString[colors.cyan] = "9"
132colorsArrayNumToString[colors.purple] = "a"
133colorsArrayNumToString[colors.blue] = "b"
134colorsArrayNumToString[colors.brown] = "c"
135colorsArrayNumToString[colors.green] = "d"
136colorsArrayNumToString[colors.red] = "e"
137colorsArrayNumToString[colors.black] = "f"
138
139--designer stuff
140designerMonitor = nil
141designerScreen = nil
142designerX = nil
143designerY = nil
144lastSave = nil
145saveTimerID = nil
146selectedPart = ""
147F1Held = false
148CTRLHeld = false
149
150--hashes and help strings (md5)
151help = {}
152terminalID = "a8bcae0d70fdbf14c572156f8e31000a"
153
154initMonsSID = "cdac1a98818689af48db3b552851fc6f"
155initMonsSHeadingID = "890f2028b00a4579df6b48ad34d8a269"
156help[initMonsSHeadingID] = "EasyGUI needs to §?save §-your §?monitor configuration §-as pseudo-xml. This screen will guide you through the process."
157initMonsSLeftRectID = "ea24a45da7a8fbef8b236748907aa7fb"
158initMonsSTextID = "4900d0b145e8533b398b5e12dd7525e5"
159help[initMonsSTextID] = "You need to assign an §?ID §-to every §?monitor §-to tell them properly apart. IDs will be saved lower case and must not be longer than 31 characters."
160initMonsSPictureID = "694b8cec4ab3a26d01c68005ec8aa56c"
161initMonsSErrorID = "fb95b84d5b14a09ab93511fc6fb575f4"
162help[initMonsSErrorID] = "IDs need to be §?unique §-and must §?not §-be §?longer than 31 characters§-."
163
164changeMonSID = "c737dc7d97748d8b40963a95a0dc7861"
165help[changeMonSID] = "EasyGUI Designer/Editor can run on a §?computer terminal §-or on a §?monitor§-. On this screen you can choose to §?transfer §-the Designer. Note: you will have the best experience on a §?computer terminal §-because you can use your §?keyboard§-."
166changeMonSDDMenuID = "d73a60583fc13ea25db201571bca7301"
167help[changeMonSDDMenuID] = "Leave this at \"§?term§-\" if you want to run the designer on §?this computer screen§-. Otherwise, choose one of your §?monitors§-. Note: only §?computer screens §-are big enough to run EasyGUI Designer, §?turtle §-and §?pocket screens §-will §?not work§-."
168changeMonSApplyID = "c1eac4028ea88abba1e9fa2b5894a5ac"
169changeMonSScaleDDID = "0f76acbc91744387905e22aa7420e892"
170help[changeMonSScaleDDID] = "If running EasyGUI on a §?monitor§-, you may want to set the §?textScale §-higher. Standard §?0.5§- might result in very small letters on a big monitor."
171
172mainSID = "174e80d8ed22ac2287bf056b4e7c2c0a"
173mainSBorderID = "42adbd6df1cf676ed2cbf9040ff73d69"
174mainSButton1ID = "9d8692e9a7d29f1cea8ff0728b27ec15"
175help[mainSButton1ID] = "§?Elements §-are the essence of EasyGUI. On this menu you can §?add new elements §-and §?edit §-already existing ones. Right now, supports §?dynamicTextBoxes§-,§?sliders§-,§?dropDownMenus§-,§?navigationMenus§-,§?colorPickers§-,§?coordinateSystems§-,§?progressBars §-and §?pictures§-. All of them will be saved as pseudo-xml files."
176mainSButton2ID = "9ce00dc655e34d3e4ade16daa7267a12"
177help[mainSButton2ID] = "§?Elements §-alone can not be displayed, they need to be added to a §?screen §-which can then be displayed. On this menu you can §?add new screens §-and §?edit §-already existing ones. All of them will be saved as pseudo-xml files."
178mainSButton3ID = "a79fa19cb268b702bcbcaccbbb7ce8d3"
179mainSHeadingID = "0ede5fa492669473d6f765e957967296"
180
181screensSID = "c00d2f1c0bc784e4d9bd67f800a0e702"
182screensSHeadingID = "04f609cb0bf336e33b5ac887858f8a81"
183help[screensSHeadingID] = help[mainSButton1ID]
184screensSButton1ID = "aaa4cb31682f6968660ef882899b16b2"
185screensSButton2ID = "b10a959313edf31aa004faffcf905256"
186screensSButton3ID = "f2ca3bcbb6f6febcb3d73236ff285fb5"
187screensSDDMenuID = "a2f436771da5644c27a39d73b57fd29c"
188screensSMsgID = "b823cc4d92c1748967586c2878967248"
189
190elementsSID = "0ce4a8f25a81d19b9abf7cfcbd450a4d"
191elementsSHeadingID = "f34a17e23d41cffa1b9fbd6a33cd4f71"
192help[elementsSHeadingID] = help[mainSButton2ID]
193elementsSButton1ID = "c8a2c4a1a569bc97d659707bc42539fe"
194elementsSButton2ID = "650a9aef06bb8e99389773a9fd6ec2cd"
195elementsSDDMenu1ID = "bc9fc4bada884c28114d4bfb1783b8c7"
196elementsSDDMenu2ID = "030bbbca3d6cf0847f87feda6bf6a783"
197
198editorSID = "ba0832bc2dcb0adcf14b490ac6be2065"
199editorSElementID = nil
200editorSElementType = nil
201editorSElementX = nil
202editorSElementY = nil
203editorSRelocateButtonID = "ca5d5014d000faa233f4c58909e9ea21"
204help[editorSRelocateButtonID] = "Toggle on to §?relocate §-the §?current element §-to a place you click on the screen. Note: this has nothing to do with where the element will be rendered. It is purely for the sake of seeing things better."
205editorSLastSaveID = "70461177a186553350dbb333d5b2cde2"
206help[editorSLastSaveID] = "Shows when the element was §?last saved §-into the pseudo-xml file. Normally §?auto-saves §-every §?3 minutes§-. You can also save with §?Ctrl+S§-."
207editorSExitID = "99f1eb11c00f5c188844a7311c879bac"
208editorSUndoID = "0f7132a19e8760f425c2eef5b386cc61"
209editorSRedoID = "fe21a08c7dffa4717d24593f7fcd0a0e"
210editorSPropsID = "e46d61c144903147e4cb5f136a0fecb8"
211help[editorSPropsID] = "Toggle to §?show§-/§?hide §-the properties menu."
212editorSPropsMenuID = "cbf856355edab7b830d36dec09857e0d"
213help[editorSPropsMenuID] = "Shows every non-technical §?property §-of the §?element§-. Almost all of them §?can be changed §-in the editor."
214editorSDescID = "06431f84d6b74e6796e52341a882e9a5"
215editorSHideUIID = "ad4e5a2c6c8b4995893cec8cd4e2f219"
216help[editorSHideUIID] = "§?Hide §-all §?UI elements §-for a §?few seconds §-to see your §?element §-better."
217editorSPropColorPickID = "25c276460958a39672b08d75baf86b4d"
218editorSPropResetButtonID = "6c04474a36beb72d7659bb0be1a07753"
219help[editorSPropResetButtonID] = "By clicking, the property will be set §?nil §-if it is §?non-essential §-or to a §?default value §-if it is §?essential§-. See property description for further details."
220editorSPropDDMenuID = "0603d9ac23d75d560d24cf76b2321882"
221help[editorSPropDDMenuID] = "This property can only have §?specific values§-. Select them in this menu. First (empty) can only be selected by hitting the default button."
222editorSPropDisplayID = "43c8ab35bc70361a89080b0e6c8d0dcc"
223editorSPropConsoleInputButtonID = "48066d14f326e44bc285eacea5953c53"
224help[editorSPropConsoleInputButtonID] = "This property can be changed via §?console input§-. To do so, click this button."
225editorSPropConsoleMsgID = "253177a56e1e679a671650ff660ac628"
226editorSPropColorsArrayDDID = "f786c674209bc58c63be21a9973a36a7"
227help[editorSPropColorsArrayDDID] = "You can choose a §?different color §-for §?every index§-. This menu indicates the §?current index§-."
228editorSPropStringArrayDDID = "873ab20d4a621beb75c4a288aafc4d9b"
229help[editorSPropStringArrayDDID] = "To §?change §-or §?remove §-an entry, select it in this menu and hit the change button. Hit the last entry (\"§?+add§-\") to §?add §-another one."
230editorSPropNavMenuID = "1a8bf4cb11854ddc7070fa988b6bd061"
231help[editorSPropNavMenuID] = "You can §?change §-the §?menuArray structure §-by using this menu. §?Add §-new entries: \"§?+add§-\" §?Change §-or §?remove§-: §?select §-it and then \"§?<- edit§-\" Add §?another menu level§-: \"§?add sub§-\""
232editorSPropNavMenuHintID = "5e192f2543b2955606ea876e5a0f5061"
233help[editorSPropNavMenuHintID] = help[editorSPropNavMenuID]
234editorSPropCSTableIndexDDID = "c0db47af6a31df0c8b5d6d93528e8789"
235help[editorSPropCSTableIndexDDID] = "§?Multiple graphs §-can be saved. This indicates the §?index §-of the graph to be edited. You can §?add §-another one by hitting the last entry (\"§?+add§-\"). To §?remove §-an entire graph, hit the §?Remove §-button."
236editorSPropCSTableDDID = "285065eb94ad1d28cc4256b2ba90313e"
237help[editorSPropCSTableDDID] = "This lists all the §?coordinates §-of the §?selected graph§-. To §?change§-/§?remove §-a point, select it and hit the §?Change §-button. To §?add §-a new point, hit the last entry (\"§?+add§-\")"
238editorSPropCSChangeID = "69280395cc41074df3a851bd35dae7eb"
239help[editorSPropCSChangeID] = "Click to §?change §-or §?remove §-the selected coordinate/design property."
240editorSPropCSRemoveID = "947a332a5fd6e2f12cdee783584d7b2f"
241help[editorSPropCSRemoveID] = "Click to §?remove §-the selected graph."
242editorSPropCSDesignsIndexDDID = "6cc418ef452522709716091a3fee13b4"
243help[editorSPropCSDesignsIndexDDID] = "Every graph can have a §?different design§-. This indicates the §?index §-of the graph design to be edited."
244editorSPropCSDesignsDDID = "dcf4b18661fa3189e028cc5b9e3bb091"
245help[editorSPropCSDesignsDDID] = "Design consists of the §?character §-to be drawn at the point and the §?textcolor §-and §?backgroundcolor §-to be used. Select §?what to change §-in this menu."
246editorSPropCSDesignsDisplayID = "a911bd54fc2a722273349b86b7ba7e5b"
247editorSPropPicEditButtonID = "d4baa6b9a4165cd060adf01ac06413c1"
248
249pictureESID = "8c62478c73d841127d5cfee2ca0057f5"
250pictureESCurrentX = 1
251pictureESCurrentY = 1
252pictureESButtonBackID = "2b0706da3b5d426fa94dc2f8296b3163"
253pictureESCoordsDisplayID = "badf495b60b2dfbf16a6505fc5a6abea"
254help[pictureESCoordsDisplayID] = "§?Current selected coordinate §-on the picture."
255pictureESControlPicID = "8e30ae73df15a61c5031fbb303d0aacb"
256help[pictureESControlPicID] = "Click on the §?arrows §-to §?change §-selected §?coordinate§-. Click the §?middle circle §-to §?hide§-/§?show §-the §?selection indicator§-. Note: you can also use your §?arrow keys §-to change selected location."
257pictureESIndicatorID = "eedc3c41696a69f23da0afaa26966886"
258pictureESChangeID = "6fa7bc313ff09ed5ffe3a03eabd9f023"
259help[pictureESChangeID] = "Click to §?change §-the §?character §-at the §?selected location§-. Note: you can §?change characters §-without using this button simply by §?typing on your keyboard§-. You can also use §?paste §-(§?Ctrl+V§-)"
260pictureESColorPick1ID = "b35a1604be58560bed010a10814b9e96"
261help[pictureESColorPick1ID] = "Use to change §?textColor §-of current pixel."
262pictureESColorPick2ID = "f21f6272bc5b1fde77e1fae2b81a8cd2"
263help[pictureESColorPick2ID] = "Use to change §?backgroundColor §-of current pixel."
264pictureESUseDefault1ID = "544eede5770aab86e04abe55a69df30e"
265help[pictureESUseDefault1ID] = "Click to use §?default textcolor §-of current screen at selected location."
266pictureESUseDefault2ID = "6ecb339249a0d6fc15345a3a9678d801"
267help[pictureESUseDefault2ID] = "Click to use §?default backgroundcolor §-of current screen at selected location."
268pictureESTransparentID = "2273d20c36018b7d17dc3c2986581939"
269help[pictureESTransparentID] = "Click to make selected pixel §?entirely transparent §-so that other elements may be rendered behind it."
270
271newScreenSID = "4c87e69acef20548469e1739e668a0b2"
272newScreenSHeadingID = "d3b18e12b96639b9185abb60ba990ddb"
273help[newScreenSHeadingID] = "This screen guides you through the process of §?creating a new screen§-. §?Size §-and §?default colors §-need to be set."
274newScreenSTextID = "8413e43f729eccce6ae5ec696b90dbda"
275newScreenSDDM1ID = "5febc01add087220c728a65579e148f3"
276help[newScreenSDDM1ID] = "You can pick one of the §?first three options §-to use a screen size equivalent to the §?specific device screen§-. Choose the §?fourth option §-to adapt the screen size to one of your §?attached monitors§-. Choose the §?fifth §-to enter dimensions §?manually§-."
277newScreenSDDM2ID = "e5cc2beacfc426487c711c85deb2015d"
278help[newScreenSDDM2ID] = "Choose which §?monitor §-you want to adapt the screen §?size §-to."
279newScreenSDDM3ID = "1f2fae049f3e7a22afd512769a7b171d"
280help[newScreenSDDM3ID] = "You may want to set §?textScale §-higher on a §?bigger monitor §-to read things better. This will affect the §?screen size§-."
281newScreenSResultID = "bbdc5855b127608208219ecc1a275978"
282newScreenSColor1ID = "d43e48d259cd4baa3c209f590f912cbf"
283help[newScreenSColor1ID] = "Choose the §?default textcolor §-of the screen."
284newScreenSColor2ID = "0acbe4f69fa595fd123d03ad834cc50d"
285help[newScreenSColor2ID] = "Choose the §?default backgroundcolor §-of the screen."
286
287designerSID = nil
288designerSExitButtonID = "1d3b801e5d4f2c7226492cf2a66f9ebd"
289designerSHideUIID = "9818d56316ad57a0567c4076c26ae597"
290help[designerSHideUIID] = "§?Hide §-all §?UI elements §-for a §?few seconds §-to see your element better."
291designerSControlPicID = "71e90f74303d96e10277d15591add23e"
292help[designerSControlPicID] = "Click on the §?arrows §-to §?change §-the §?position §-of the §?selected element§-. You can also use your §?arrow keys§-, but may want to prefer relocating elements by §?dragging §-the §?indicator §-in the top left of the selected element."
293designerSSelectionID = "31cf20d5dd112d373b987ca97d7bec60"
294help[designerSSelectionID] = "Here you can see the §?position §-of the selected element, its §?ID §-and the selected §?part§-. Click to §?deselect§-."
295designerSAddID = "ebd3455e1d4cb26e3880b7ef5963ef55"
296help[designerSAddID] = "Click to §?show§-/§?hide §-a menu which shows all §?saved elements§-. §?Select §-one to §?add §-it to this screen."
297designerSRemoveID = "2a2abf50f7ca26032ee56471ead9ed46"
298help[designerSRemoveID] = "Click to §?remove §-selected §?element §-from the screen."
299designerSIndicatorID = "61a218bc9eadf687b5218d580c99d1c7"
300designerSLastSaveID = "5d7d14cce74cf0f0506a47557b2c49b7"
301help[designerSLastSaveID] = "Shows when the screen was §?last saved §-into the pseudo-xml file. Normally §?auto-saves §-every §?3 minutes§-. You can also §?save §-with §?Ctrl+S§-."
302designerSSelection = ""
303designerSmaxX = nil
304designerSmaxY = nil
305designerSBox1ID = "d0dca4a2df75fbc538d26bf55f838068"
306designerSBox2ID = "dd5bd01b51b9dae60c4908954a25da05"
307designerSUndoID = "b690378913463294bc11c499bf032798"
308designerSRedoID = "25d97fd89146fa2a0378577fea852434"
309designerRefresh = false
310designerSButtonHeld = false
311
312helpSID = "a4b4970624f9e7db4a4b9a1cad861aaf"
313helpSBorderID = "a91d2b3ffc44366c5801ccd3bb5b8c2f"
314helpSOKID = "a3a59d8266d8b1e220773f0977e22726"
315
316undoRedoTable = {}
317undoRedoIndex = 0
318
319--property tables
320--width, height, content, variables, textColor, textAlignmentHorizontal, textAlignmentVertical, BGColor, borderColor, onActiveFunction, onInactiveFunction, onClickMode, activeDuration, activeContent, activeTextColor, activeBGColor, activeBorderColor, borderThickness, active, timerID, visible, enabled
321dynamicTextBoxProperties = {}
322dynamicTextBoxProperties["content"] = {}
323dynamicTextBoxProperties["content"]["input"] = "string"
324dynamicTextBoxProperties["content"]["essential"] = true
325dynamicTextBoxProperties["content"]["desc"] = "§?content §-(§?string§-):§n the §?text §-inside the dynamicTextBox. It automatically splits the text into different lines if necessary. Color modifiers: §?§§- + §?0-f§- (colors) §?*§- for §?defaultTextColor§-, §?#§- for §?defaultBGColor§-, §?-§- for §?textColor§-. §?§§- + §?n§- will result in a new line."
326dynamicTextBoxProperties["content"]["default"] = "Your Text"
327
328dynamicTextBoxProperties["width"] = {}
329dynamicTextBoxProperties["width"]["input"] = "number"
330dynamicTextBoxProperties["width"]["essential"] = false
331dynamicTextBoxProperties["width"]["desc"] = "§?width §-(§?non-decimal number§- in §?pixels§-):§n how §?wide §-(§?x§-) the element should be. If unused (nil) the dynamicTextBox will take the space the text requires, but never run over the edge of the screen."
332
333dynamicTextBoxProperties["height"] = {}
334dynamicTextBoxProperties["height"]["input"] = "number"
335dynamicTextBoxProperties["height"]["essential"] = false
336dynamicTextBoxProperties["height"]["desc"] = "§?height §-(§?non-decimal number§- in §?pixels§-):§n how §?broad §-(§?y§-) the element should be. If unused (nil) the dynamicTextBox will take the space the text requires, but never run over the edge of the screen."
337
338dynamicTextBoxProperties["variables"] = {}
339dynamicTextBoxProperties["variables"]["input"] = "manual"
340dynamicTextBoxProperties["variables"]["essential"] = false
341dynamicTextBoxProperties["variables"]["desc"] = "§?variables §-(§?table§-):§n can be used thus: §?variables[\"name\"] = retrieveVarFunc§-, then put §?&name§- somewhere in content. Can only be set manually. (§?EasyGUI.changeProperty(ID,\"variables\",table)§-)"
342
343dynamicTextBoxProperties["textColor"] = {}
344dynamicTextBoxProperties["textColor"]["input"] = "color"
345dynamicTextBoxProperties["textColor"]["essential"] = false
346dynamicTextBoxProperties["textColor"]["desc"] = "§?textColor §-(§?color§-):§n §?color§- of the §?text§- inside the dynamicTextBox. If unused (nil) §?defaultTextColor§- of the screen will be used."
347
348dynamicTextBoxProperties["BGColor"] = {}
349dynamicTextBoxProperties["BGColor"]["input"] = "color"
350dynamicTextBoxProperties["BGColor"]["essential"] = false
351dynamicTextBoxProperties["BGColor"]["desc"] = "§?BGColor §-(§?color§-):§n §?color§- of §?background§- of the dynamicTextBox. If unused (nil) §?defaultBGColor§- of the screen will be used."
352
353dynamicTextBoxProperties["borderColor"] = {}
354dynamicTextBoxProperties["borderColor"]["input"] = "color"
355dynamicTextBoxProperties["borderColor"]["essential"] = false
356dynamicTextBoxProperties["borderColor"]["desc"] = "§?borderColor §-(§?color§-):§n §?color§- of the §?border§- of the dynamicTextBox. §?borderThickness§- needs to be greater than 0. If unused (nil) §?BGColor§- will be used."
357
358dynamicTextBoxProperties["activeContent"] = {}
359dynamicTextBoxProperties["activeContent"]["input"] = "string"
360dynamicTextBoxProperties["activeContent"]["essential"] = false
361dynamicTextBoxProperties["activeContent"]["desc"] = "§?activeContent §-(§?string§-):§n the §?text§- inside the dynamicTextBox if it's §?active§-. See description for §?content§-. If unused (nil) will be §?content§-."
362
363dynamicTextBoxProperties["activeTextColor"] = {}
364dynamicTextBoxProperties["activeTextColor"]["input"] = "color"
365dynamicTextBoxProperties["activeTextColor"]["essential"] = false
366dynamicTextBoxProperties["activeTextColor"]["desc"] = "§?activeTextColor §-(§?color§-):§n §?color§- of the §?text§- inside the dynamicTextBox if it's §?active§-. If unused (nil) §?textColor§- will be used."
367
368dynamicTextBoxProperties["activeBGColor"] = {}
369dynamicTextBoxProperties["activeBGColor"]["input"] = "color"
370dynamicTextBoxProperties["activeBGColor"]["essential"] = false
371dynamicTextBoxProperties["activeBGColor"]["desc"] = "§?activeBGColor §-(§?color§-):§n §?color§- of §?background§- of the dynamicTextBox if it's §?active§-. If unused (nil) §?BGColor§- will be used."
372
373dynamicTextBoxProperties["activeBorderColor"] = {}
374dynamicTextBoxProperties["activeBorderColor"]["input"] = "color"
375dynamicTextBoxProperties["activeBorderColor"]["essential"] = false
376dynamicTextBoxProperties["activeBorderColor"]["desc"] = "§?activeBorderColor §-(§?color§-):§n §?color§- of the §?border§- of the dynamicTextBox if it's §?active§-. §?borderThickness§- needs to be greater then 0. If unused (nil) §?borderColor§- will be used."
377
378dynamicTextBoxProperties["textAlignmentHorizontal"] = {}
379dynamicTextBoxProperties["textAlignmentHorizontal"]["input"] = "DDM:left:center:right"
380dynamicTextBoxProperties["textAlignmentHorizontal"]["essential"] = false
381dynamicTextBoxProperties["textAlignmentHorizontal"]["desc"] = "§?textAlignmentHorizontal §-(§?left§-,§?center§-,§?right§-):§n where the text inside the dynamicTextBox shall be placed §?horizontally§-. If unused (nil) defaults to §?center§-."
382
383dynamicTextBoxProperties["textAlignmentVertical"] = {}
384dynamicTextBoxProperties["textAlignmentVertical"]["input"] = "DDM:top:center:bottom"
385dynamicTextBoxProperties["textAlignmentVertical"]["essential"] = false
386dynamicTextBoxProperties["textAlignmentVertical"]["desc"] = "§?textAlignmentVertical §-(§?top§-,§?center§-,§?bottom§-):§n where the text inside the dynamicTextBox shall be placed §?vertically§-. If unused (nil) defaults to §?center§-."
387
388dynamicTextBoxProperties["borderThickness"] = {}
389dynamicTextBoxProperties["borderThickness"]["input"] = "number"
390dynamicTextBoxProperties["borderThickness"]["essential"] = false
391dynamicTextBoxProperties["borderThickness"]["desc"] = "§?borderThickness §-(§?non-decimal number§- in §?pixels§-):§n how §?thick§- the §?border§- of the dynamicTextBox shall be. If unused (nil) will be §?0§-. (no border)"
392
393dynamicTextBoxProperties["onClickMode"] = {}
394dynamicTextBoxProperties["onClickMode"]["input"] = "DDM:flash:toggle"
395dynamicTextBoxProperties["onClickMode"]["essential"] = false
396dynamicTextBoxProperties["onClickMode"]["desc"] = "§?onClickMode §-(§?flash§-,§?toggle§-):§n whether the dynamicTextBox if clicked shall stay active until the next click (§?toggle§-) or turn inactive again after a specific amount of time. (§?flash§-) Also set §?activeDuration§- if using the second option."
397
398dynamicTextBoxProperties["activeDuration"] = {}
399dynamicTextBoxProperties["activeDuration"]["input"] = "decimal"
400dynamicTextBoxProperties["activeDuration"]["essential"] = false
401dynamicTextBoxProperties["activeDuration"]["desc"] = "§?activeDuration §-(§?decimal number§- in §?seconds§-):§n if §?onClickMode§- is set to §?flash§-, this value determines how §?long§- the dynamicTextBox stays active after clicked. Can only be as accurate as §?1 in-game tick§- or §?0.05s§-. If unused (nil) will be §?0.05§-."
402
403dynamicTextBoxProperties["onActiveFunction"] = {}
404dynamicTextBoxProperties["onActiveFunction"]["input"] = "manual"
405dynamicTextBoxProperties["onActiveFunction"]["essential"] = false
406dynamicTextBoxProperties["onActiveFunction"]["desc"] = "§?onActiveFunction §-(§?function§-):§n to be §?called§- when the dynamicTextBox becomes §?active§- through a click. Can only be set manually. (§?EasyGUI.changeProperty(ID,\"onActiveFunction\",func)§-) Will be called with two §?arguments§-: §?ID of element§- (§?string§-), §?whether it's active§- (§?boolean§-)"
407
408dynamicTextBoxProperties["onInactiveFunction"] = {}
409dynamicTextBoxProperties["onInactiveFunction"]["input"] = "manual"
410dynamicTextBoxProperties["onInactiveFunction"]["essential"] = false
411dynamicTextBoxProperties["onInactiveFunction"]["desc"] = "§?onInactiveFunction §-(§?function§-):§n to be §?called§- when the dynamicTextBox becomes §?inactive§- through a click or when §?activeDuration§- has passed. Can only be set manually. (§?EasyGUI.changeProperty(ID,\"onInactiveFunction\",func)§-) Will be called with two §?arguments§-: §?ID of element§- (§?string§-), §?whether it's active§- (§?boolean§-)"
412
413--length, value, broadness, orientation, pixelsPerUnit, color, colorsArray, textPosition, textMargin, BGColor, borderColor, onChangeFunction, borderThickness, visible, enabled, mode, changeButtons
414sliderProperties = {}
415sliderProperties["length"] = {}
416sliderProperties["length"]["input"] = "number"
417sliderProperties["length"]["essential"] = true
418sliderProperties["length"]["desc"] = "§?length §-(§?number§-):§n the §?maximum value§- the slider shall take on. Not necessarily the length in pixels, for more info see §?pixelsPerUnit§-."
419sliderProperties["length"]["default"] = 5
420
421sliderProperties["value"] = {}
422sliderProperties["value"]["input"] = "number"
423sliderProperties["value"]["essential"] = true
424sliderProperties["value"]["desc"] = "§?value §-(§?number§-):§n the §?default value§- the slider shall take on."
425sliderProperties["value"]["default"] = 1
426
427sliderProperties["broadness"] = {}
428sliderProperties["broadness"]["input"] = "number"
429sliderProperties["broadness"]["essential"] = false
430sliderProperties["broadness"]["desc"] = "§?broadness §-(§?non-decimal number§- in §?pixels§-):§n how §?broad§- the slider shall be. Perpendicular to slider orientation. If unused (nil) will be §?1§-."
431
432sliderProperties["pixelsPerUnit"] = {}
433sliderProperties["pixelsPerUnit"]["input"] = "number"
434sliderProperties["pixelsPerUnit"]["essential"] = false
435sliderProperties["pixelsPerUnit"]["desc"] = "§?pixelsPerUnit §-(§?non-decimal number§- in §?pixels§-):§n how many §?pixels one unit§- of the slider shall take up. If unused (nil) will be §?1§-."
436
437sliderProperties["orientation"] = {}
438sliderProperties["orientation"]["input"] = "DDM:top-bottom:bottom-top:left-right:right-left"
439sliderProperties["orientation"]["essential"] = false
440sliderProperties["orientation"]["desc"] = "§?orientation §-(§?top-bottom§-,§?bottom-top§-,§?left-right§-,§?right-left§-):§n how the slider shall be §?oriented§-. '§?start-end§-'. If unused (nil) will be §?left-right§-."
441
442sliderProperties["color"] = {}
443sliderProperties["color"]["input"] = "color"
444sliderProperties["color"]["essential"] = false
445sliderProperties["color"]["desc"] = "§?color §-(§?color§-):§n the §?color§- the slider §?bar §-shall take on. If unused (nil) will be the §?defaultTextColor§- of the screen."
446
447sliderProperties["BGColor"] = {}
448sliderProperties["BGColor"]["input"] = "color"
449sliderProperties["BGColor"]["essential"] = false
450sliderProperties["BGColor"]["desc"] = "§?BGColor §-(§?color§-):§n the §?background§- of the slider. If unused (nil) will be the §?defaultBGColor§- of the screen."
451
452sliderProperties["borderColor"] = {}
453sliderProperties["borderColor"]["input"] = "color"
454sliderProperties["borderColor"]["essential"] = false
455sliderProperties["borderColor"]["desc"] = "§?borderColor §-(§?color§-):§n §?color§- of the §?border§- of the slider. §?borderThickness§- needs to be greater than §?0§-. If unused (nil) will be §?BGColor§-."
456
457sliderProperties["borderThickness"] = {}
458sliderProperties["borderThickness"]["input"] = "number"
459sliderProperties["borderThickness"]["essential"] = false
460sliderProperties["borderThickness"]["desc"] = "§?borderThickness §-(§?non-decimal number§- in §?pixels§-):§n how §?thick§- the §?border§- of the slider shall be. If unused (nil) will be §?0§-. (no border)"
461
462sliderProperties["colorsArray"] = {}
463sliderProperties["colorsArray"]["input"] = "colorsArray"
464sliderProperties["colorsArray"]["essential"] = false
465sliderProperties["colorsArray"]["desc"] = "§?colorsArray §-(§?numerically-indexed table§-):§n this can be used if you want a §?different bar color§- for §?different values§-. Example: red for high values and green for low values."
466
467sliderProperties["mode"] = {}
468sliderProperties["mode"]["input"] = "DDM:fill:value"
469sliderProperties["mode"]["essential"] = false
470sliderProperties["mode"]["desc"] = "§?mode§- (§?fill§-,§?value§-):§n whether the slider shall be filled up to the current value (§?fill§-) or only display the current value (§?value§-). If unused (nil) will be §?fill§-."
471
472sliderProperties["textPosition"] = {}
473sliderProperties["textPosition"]["input"] = "DDM:top:bottom:left:right"
474sliderProperties["textPosition"]["essential"] = false
475sliderProperties["textPosition"]["desc"] = "§?textPosition§- (§?top§-,§?bottom§-,§?left§-,§?right§-):§n if this value is set will display the §?current value§- at the chosen §?position§-."
476
477sliderProperties["textMargin"] = {}
478sliderProperties["textMargin"]["input"] = "number"
479sliderProperties["textMargin"]["essential"] = false
480sliderProperties["textMargin"]["desc"] = "§?textMargin §-(§?non-decimal number§- in §?pixels§-):§n determines how many §?pixels§- away from the slider the value will be §?placed§-. Requires §?textPosition§- to be set. If unused (nil) will be §?0§-."
481
482sliderProperties["changeButtons"] = {}
483sliderProperties["changeButtons"]["input"] = "string"
484sliderProperties["changeButtons"]["essential"] = false
485sliderProperties["changeButtons"]["desc"] = "§?changeButtons §-(§?2 characters§-):§n if set draws an §?increment button§- with the §?first character§- and a §?decrement button§- with the §?second character§-. Example: '§?+-§-'"
486
487sliderProperties["onChangeFunction"] = {}
488sliderProperties["onChangeFunction"]["input"] = "manual"
489sliderProperties["onChangeFunction"]["essential"] = false
490sliderProperties["onChangeFunction"]["desc"] = "§?onChangeFunction§- (§?function§-):§n §?to be called§- if the value of the slider changes through a click event. Can only be set manually. (§?EasyGUI.changeProperty(ID,\"onChangeFunction\",func)§-) Will be called with §?two arguments§-: §?ID of element§- (§?string§-), §?current value§- (§?number§-)"
491
492--entries,width,expandedMaxHeight, textColor, BGColor, borderColor, onChangeFunction, onExpandFunction, onCollapseFunction, highlightTextColor, highlightBGColor, borderThickness, expanded, visible, enabled,selectionID,scrollPositionIndex,highlightID,buttonsColor,buttonsBGColor
493dropDownMenuProperties = {}
494dropDownMenuProperties["entries"] = {}
495dropDownMenuProperties["entries"]["input"] = "stringArray"
496dropDownMenuProperties["entries"]["essential"] = true
497dropDownMenuProperties["entries"]["desc"] = "§?entries §-(§?numerically indexed table§-):§n all §?entries§- of the dropDownMenu."
498dropDownMenuProperties["entries"]["default"] = {"Entry 1","Entry 2","Entry 3"}
499
500dropDownMenuProperties["selectionID"] = {}
501dropDownMenuProperties["selectionID"]["input"] = "number"
502dropDownMenuProperties["selectionID"]["essential"] = true
503dropDownMenuProperties["selectionID"]["desc"] = "§?selectionID §-(§?non-decimal number§-):§n by §?default selected entry§- of dropDownMenu."
504dropDownMenuProperties["selectionID"]["default"] = 1
505
506dropDownMenuProperties["width"] = {}
507dropDownMenuProperties["width"]["input"] = "number"
508dropDownMenuProperties["width"]["essential"] = false
509dropDownMenuProperties["width"]["desc"] = "§?width §-(§?non-decimal number§- in §?pixels§-):§n how §?wide§- (§?x§-) the dropDownMenu shall be. Text will be shortened accordingly. If unused (nil) takes as much space as necessary but will not run over the edge of the screen."
510
511dropDownMenuProperties["expandedMaxHeight"] = {}
512dropDownMenuProperties["expandedMaxHeight"]["input"] = "number"
513dropDownMenuProperties["expandedMaxHeight"]["essential"] = false
514dropDownMenuProperties["expandedMaxHeight"]["desc"] = "§?expandedMaxHeight §-(§?non-decimal number§- in §?pixels§-):§n the §?maximum height§- of the dropDownMenu in its §?expanded§- state. Adds a scroll feature if necessary. If unused (nil) takes as much space as necessary but will not run over the edge of the screen."
515
516dropDownMenuProperties["textColor"] = {}
517dropDownMenuProperties["textColor"]["input"] = "color"
518dropDownMenuProperties["textColor"]["essential"] = false
519dropDownMenuProperties["textColor"]["desc"] = "§?textColor §-(§?color§-):§n §?color§- of the §?text§- of the §?entries§-. If unused (nil) §?defaultTextColor§- of the screen will be used."
520
521dropDownMenuProperties["BGColor"] = {}
522dropDownMenuProperties["BGColor"]["input"] = "color"
523dropDownMenuProperties["BGColor"]["essential"] = false
524dropDownMenuProperties["BGColor"]["desc"] = "§?BGColor §-(§?color§-):§n §?color§- of §?background§- of the dropDownMenu. If unused (nil) §?defaultBGColor§- of the screen will be used."
525
526dropDownMenuProperties["borderColor"] = {}
527dropDownMenuProperties["borderColor"]["input"] = "color"
528dropDownMenuProperties["borderColor"]["essential"] = false
529dropDownMenuProperties["borderColor"]["desc"] = "§?borderColor §-(§?color):§n §?color§- of the §?border§- of the dropDownMenu. §?borderThickness§- needs to be greater than §?0§-. If unused (nil) §?BGColor§- will be used."
530
531dropDownMenuProperties["highlightTextColor"] = {}
532dropDownMenuProperties["highlightTextColor"]["input"] = "color"
533dropDownMenuProperties["highlightTextColor"]["essential"] = false
534dropDownMenuProperties["highlightTextColor"]["desc"] = "§?highlightTextColor §-(§?color§-):§n §?color§- of the §?text§- of the §?highlighted entry§-. If unused (nil) §?textColor§- will be used."
535
536dropDownMenuProperties["highlightBGColor"] = {}
537dropDownMenuProperties["highlightBGColor"]["input"] = "color"
538dropDownMenuProperties["highlightBGColor"]["essential"] = false
539dropDownMenuProperties["highlightBGColor"]["desc"] = "§?highlightBGColor §-(§?color§-):§n §?color§- of §?background§- of the §?highlighted entry§-. If unused (nil) §?BGColor§- will be used."
540
541dropDownMenuProperties["buttonsColor"] = {}
542dropDownMenuProperties["buttonsColor"]["input"] = "color"
543dropDownMenuProperties["buttonsColor"]["essential"] = false
544dropDownMenuProperties["buttonsColor"]["desc"] = "§?buttonsColor §-(§?color§-):§n §?textColor§- of §?expand/collapse/scroll buttons§-. If unused (nil) §?textColor§- will be used."
545
546dropDownMenuProperties["buttonsBGColor"] = {}
547dropDownMenuProperties["buttonsBGColor"]["input"] = "color"
548dropDownMenuProperties["buttonsBGColor"]["essential"] = false
549dropDownMenuProperties["buttonsBGColor"]["desc"] = "§?buttonsBGColor §-(§?color§-):§n §?BGColor§- of §?expand/collapse/scroll buttons§-. If unused (nil) §?BGColor§- will be used."
550
551dropDownMenuProperties["borderThickness"] = {}
552dropDownMenuProperties["borderThickness"]["input"] = "number"
553dropDownMenuProperties["borderThickness"]["essential"] = false
554dropDownMenuProperties["borderThickness"]["desc"] = "§?borderThickness §-(§?non-decimal number§- in §?pixels§-):§n how §?thick§- the §?border§- of the dropDownMenu shall be. If unused (nil) will be §?0§-. (no border)"
555
556dropDownMenuProperties["onChangeFunction"] = {}
557dropDownMenuProperties["onChangeFunction"]["input"] = "manual"
558dropDownMenuProperties["onChangeFunction"]["essential"] = false
559dropDownMenuProperties["onChangeFunction"]["desc"] = "§?onChangeFunction §-(§?function§-):§n §?to be called§- if the §?selection§- of the dropDownMenu §?changes§- through a click event. Can only be set manually. (§?EasyGUI.changeProperty(ID,\"onChangeFunction\",func)§-) Will be called with §?two arguments§-: §?ID of element§- (§?string§-), §?current selection§- (§?number§-)"
560
561dropDownMenuProperties["onExpandFunction"] = {}
562dropDownMenuProperties["onExpandFunction"]["input"] = "manual"
563dropDownMenuProperties["onExpandFunction"]["essential"] = false
564dropDownMenuProperties["onExpandFunction"]["desc"] = "§?onExpandFunction §-(§?function§-):§n §?to be called§- if the dropDownMenu §?expands§- through a click event. Can only be set manually. (§?EasyGUI.changeProperty(ID,\"onExpandFunction\",func)§-) Will be called with §?two arguments§-: §?ID of element§- (§?string§-), §?whether it's expanded§- (§?boolean§-)"
565
566dropDownMenuProperties["onCollapseFunction"] = {}
567dropDownMenuProperties["onCollapseFunction"]["input"] = "manual"
568dropDownMenuProperties["onCollapseFunction"]["essential"] = false
569dropDownMenuProperties["onCollapseFunction"]["desc"] = "§?onCollapseFunction §-(§?function§-):§n §?to be called§- if the dropDownMenu §?collapses§- through a click event. Can only be set manually. (§?EasyGUI.changeProperty(ID,\"onCollapseFunction\",func)§-) Will be called with §?two arguments§-: §?ID of element§- (§?string§-), §?whether it's expanded§- (§?boolean§-)"
570
571--title,menuArray (text, submenu),titleTextColor,titleBGColor,titleTextColorExpanded,titleBGColorExpanded,textAlignmentHorizontal,textAlignmentVertical,entryWidth,entryHeight,entryTextColor,entryBGColor,borderColor,spaceBetweenEntries,borderThickness,highlightTextColor,highlightBGColor,expanded,highlightIDs,onChangeFunction,enabled,visible
572navigationMenuProperties = {}
573navigationMenuProperties["title"] = {}
574navigationMenuProperties["title"]["input"] = "string"
575navigationMenuProperties["title"]["essential"] = true
576navigationMenuProperties["title"]["desc"] = "§?title §-(§?string§-):§n the §?text§- of the §?title§- of the navigationMenu. Also displayed when the menu is collapsed."
577navigationMenuProperties["title"]["default"] = "Menu"
578
579navigationMenuProperties["menuArray"] = {}
580navigationMenuProperties["menuArray"]["input"] = "navMenuArray"
581navigationMenuProperties["menuArray"]["essential"] = true
582navigationMenuProperties["menuArray"]["desc"] = "§?menuArray §-(§?numerically indexed nested table§-):§n all §?entries §-of the navigationMenu with §?submenus§- if necessary. Structure: §?array[index]={[\"text\"]=\"text\",[\"submenu\"]=anotherMenuArray}§-"
583navigationMenuProperties["menuArray"]["default"] = {{["text"]="Entry 1"},{["text"]="Entry 2"},{["text"]="Entry 3"}}
584
585navigationMenuProperties["titleTextColor"] = {}
586navigationMenuProperties["titleTextColor"]["input"] = "color"
587navigationMenuProperties["titleTextColor"]["essential"] = false
588navigationMenuProperties["titleTextColor"]["desc"] = "§?titleTextColor §-(§?color§-):§n §?color§- of the §?title text§-. If unused (nil) §?defaultTextColor§- of the screen will be used."
589
590navigationMenuProperties["titleBGColor"] = {}
591navigationMenuProperties["titleBGColor"]["input"] = "color"
592navigationMenuProperties["titleBGColor"]["essential"] = false
593navigationMenuProperties["titleBGColor"]["desc"] = "§?titleBGColor §-(§?color§-):§n §?color§- of the §?background§- of §?title§-. If unused (nil) §?defaultBGColor§- of the screen will be used."
594
595navigationMenuProperties["titleTextColorExpanded"] = {}
596navigationMenuProperties["titleTextColorExpanded"]["input"] = "color"
597navigationMenuProperties["titleTextColorExpanded"]["essential"] = false
598navigationMenuProperties["titleTextColorExpanded"]["desc"] = "§?titleTextColor§- (§?color§-):§n §?color§- of the §?title text§- when menu is §?expanded§-. If unused (nil) §?titleTextColor§- will be used."
599
600navigationMenuProperties["titleBGColorExpanded"] = {}
601navigationMenuProperties["titleBGColorExpanded"]["input"] = "color"
602navigationMenuProperties["titleBGColorExpanded"]["essential"] = false
603navigationMenuProperties["titleBGColorExpanded"]["desc"] = "§?titleBGColor§- (§?color§-):§n §?color§- of the §?background§- of §?title§- when menu is §?expanded§-. If unused (nil) §?titleBGColor§- will be used."
604
605navigationMenuProperties["borderColor"] = {}
606navigationMenuProperties["borderColor"]["input"] = "color"
607navigationMenuProperties["borderColor"]["essential"] = false
608navigationMenuProperties["borderColor"]["desc"] = "§?borderColor §-(§?color§-):§n §?color§- of the §?border§- of the navigationMenu. §?borderThickness§- needs to be greater than §?0§-. If unused (nil) §?defaultBGColor§- of the screen will be used."
609
610navigationMenuProperties["entryTextColor"] = {}
611navigationMenuProperties["entryTextColor"]["input"] = "color"
612navigationMenuProperties["entryTextColor"]["essential"] = false
613navigationMenuProperties["entryTextColor"]["desc"] = "§?entryTextColor§- (§?color§-):§n §?color§- of the §?text§- of the §?entries§- of the expanded menu. If unused (nil) §?defaultTextColor§- of the screen will be used."
614
615navigationMenuProperties["entryBGColor"] = {}
616navigationMenuProperties["entryBGColor"]["input"] = "color"
617navigationMenuProperties["entryBGColor"]["essential"] = false
618navigationMenuProperties["entryBGColor"]["desc"] = "§?entryBGColor§- (§?color§-):§n §?color§- of the §?background§- of the §?entries§- of the expanded menu. If unused (nil) §?defaultBGColor§- of the screen will be used."
619
620navigationMenuProperties["highlightTextColor"] = {}
621navigationMenuProperties["highlightTextColor"]["input"] = "color"
622navigationMenuProperties["highlightTextColor"]["essential"] = false
623navigationMenuProperties["highlightTextColor"]["desc"] = "§?highlightTextColor§- (§?color§-):§n §?color§- of the §?text§- of a §?highlighted entry§- of the expanded menu. If unused (nil) §?entryTextColor§- will be used."
624
625navigationMenuProperties["highlightBGColor"] = {}
626navigationMenuProperties["highlightBGColor"]["input"] = "color"
627navigationMenuProperties["highlightBGColor"]["essential"] = false
628navigationMenuProperties["highlightBGColor"]["desc"] = "§?highlightBGColor§- (§?color§-):§n §?color§- of the §?background§- of a §?highlighted entry§- of the expanded menu. If unused (nil) §?entryBGColor§- will be used."
629
630navigationMenuProperties["entryWidth"] = {}
631navigationMenuProperties["entryWidth"]["input"] = "number"
632navigationMenuProperties["entryWidth"]["essential"] = false
633navigationMenuProperties["entryWidth"]["desc"] = "§?entryWidth §-(§?non-decimal number§- in §?pixels§-):§n how §?wide §-(§?x§-) every entry shall be including submenus. If unused (nil) will take as much space as needed."
634
635navigationMenuProperties["entryHeight"] = {}
636navigationMenuProperties["entryHeight"]["input"] = "number"
637navigationMenuProperties["entryHeight"]["essential"] = false
638navigationMenuProperties["entryHeight"]["desc"] = "§?entryHeight §-(§?non-decimal number§- in §?pixels§-):§n how §?broad§- (§?y§-) every entry shall be including submenus. If unused (nil) will be §?1§-."
639
640navigationMenuProperties["textAlignmentHorizontal"] = {}
641navigationMenuProperties["textAlignmentHorizontal"]["input"] = "DDM:left:center:right"
642navigationMenuProperties["textAlignmentHorizontal"]["essential"] = false
643navigationMenuProperties["textAlignmentHorizontal"]["desc"] = "§?textAlignmentHorizontal §-(§?left§-,§?center§-,§?right§-):§n where the text inside every entry including submenus shall be placed horizontally. If unused (nil) defaults to center."
644
645navigationMenuProperties["textAlignmentVertical"] = {}
646navigationMenuProperties["textAlignmentVertical"]["input"] = "DDM:top:center:bottom"
647navigationMenuProperties["textAlignmentVertical"]["essential"] = false
648navigationMenuProperties["textAlignmentVertical"]["desc"] = "§?textAlignmentVertical §-(§?top§-,§?center§-,§?bottom§-):§n where the text inside every entry including submenus shall be placed §?vertically§-. If unused (nil) defaults to §?center§-."
649
650navigationMenuProperties["borderThickness"] = {}
651navigationMenuProperties["borderThickness"]["input"] = "number"
652navigationMenuProperties["borderThickness"]["essential"] = false
653navigationMenuProperties["borderThickness"]["desc"] = "§?borderThickness §-(§?non-decimal number§- in §?pixels§-):§n how §?thick §-the §?border §-of the navigationMenu shall be. If unused (nil) will be §?0§-. (no border)"
654
655navigationMenuProperties["spaceBetweenEntries"] = {}
656navigationMenuProperties["spaceBetweenEntries"]["input"] = "number"
657navigationMenuProperties["spaceBetweenEntries"]["essential"] = false
658navigationMenuProperties["spaceBetweenEntries"]["desc"] = "§?spaceBetweenEntries §-(§?non-decimal number§- in §?pixels§-):§n §?broadness §-(§?y§-) of a §?line§- to be placed §?between entries §-for separation. If unused (nil) will be §?0§-. (no spaces)"
659
660navigationMenuProperties["onChangeFunction"] = {}
661navigationMenuProperties["onChangeFunction"]["input"] = "manual"
662navigationMenuProperties["onChangeFunction"]["essential"] = false
663navigationMenuProperties["onChangeFunction"]["desc"] = "§?onChangeFunction §-(§?function§-):§n §?to be called§- if the §?selection§- of the navigationMenu §?changes §-through a click event. Can only be set manually. (§?EasyGUI.changeProperty(ID,\"onChangeFunction\",func)§-) Will be called with §?two arguments§-: §?ID of element §-(§?string§-), §?selections§- of §?all submenus§- before menu closed. (§?number array§-)"
664
665--selection,borderColor,borderThickness,colorWidth,colorHeight,selectionCharacter,onChangeFunction,visible,enabled
666colorPickerProperties = {}
667colorPickerProperties["selection"] = {}
668colorPickerProperties["selection"]["input"] = "color"
669colorPickerProperties["selection"]["essential"] = false
670colorPickerProperties["selection"]["desc"] = "§?selection §-(§?color§-):§n by §?default §-selected §?color§-."
671
672colorPickerProperties["borderColor"] = {}
673colorPickerProperties["borderColor"]["input"] = "color"
674colorPickerProperties["borderColor"]["essential"] = false
675colorPickerProperties["borderColor"]["desc"] = "§?borderColor §-(§?color§-):§n §?color §-of the §?border §-of the colorPicker. §?borderThickness §-needs to be greater than §?0§-. If unused (nil) §?defaultBGColor §-of the screen will be used."
676
677colorPickerProperties["borderThickness"] = {}
678colorPickerProperties["borderThickness"]["input"] = "number"
679colorPickerProperties["borderThickness"]["essential"] = false
680colorPickerProperties["borderThickness"]["desc"] = "§?borderThickness §-(§?non-decimal number §-in §?pixels§-):§n how §?thick §-the §?border §-of the colorPicker shall be. If unused (nil) will be §?0§-. (no border)"
681
682colorPickerProperties["colorWidth"] = {}
683colorPickerProperties["colorWidth"]["input"] = "number"
684colorPickerProperties["colorWidth"]["essential"] = false
685colorPickerProperties["colorWidth"]["desc"] = "§?colorWidth §-(§?non-decimal number§- in §?pixels§-):§n how §?wide §-(§?x§-) every §?color §-shall be. If unused (nil) will be §?1§-."
686
687colorPickerProperties["colorHeight"] = {}
688colorPickerProperties["colorHeight"]["input"] = "number"
689colorPickerProperties["colorHeight"]["essential"] = false
690colorPickerProperties["colorHeight"]["desc"] = "§?colorHeight §-(§?non-decimal number§- in §?pixels§-):§n how §?broad §-(§?y§-) every §?color §-shall be. If unused (nil) will be §?1§-."
691
692colorPickerProperties["selectionCharacter"] = {}
693colorPickerProperties["selectionCharacter"]["input"] = "string"
694colorPickerProperties["selectionCharacter"]["essential"] = false
695colorPickerProperties["selectionCharacter"]["desc"] = "§?selectionCharacter §-(§?1 character§-):§n the §?character §-which shall indicate the currently §?selected color§-. If unused will be §?X§-."
696
697colorPickerProperties["onChangeFunction"] = {}
698colorPickerProperties["onChangeFunction"]["input"] = "manual"
699colorPickerProperties["onChangeFunction"]["essential"] = false
700colorPickerProperties["onChangeFunction"]["desc"] = "§?onChangeFunction §-(§?function§-):§n §?to be called §-if the §?selection §-of the colorPicker §?changes §-through a click event. Can only be set manually. (§?EasyGUI.changeProperty(ID,\"onChangeFunction\",func)§-) Will be called with §?two arguments§-: §?ID of element §-(§?string§-), §?selected color§-. (§?color§-)"
701
702--length, value, valueType, broadness, orientation, textPosition, textMargin, color, colorsArray, BGColor, borderColor, borderThickness, visible
703progressBarProperties = {}
704progressBarProperties["length"] = {}
705progressBarProperties["length"]["input"] = "number"
706progressBarProperties["length"]["essential"] = true
707progressBarProperties["length"]["desc"] = "§?length §-(§?non-decimal number§- in §?pixels§-):§n the §?length §-of the progressBar."
708progressBarProperties["length"]["default"] = 5
709
710progressBarProperties["value"] = {}
711progressBarProperties["value"]["input"] = "number"
712progressBarProperties["value"]["essential"] = false
713progressBarProperties["value"]["desc"] = "§?value §-(§?non-decimal number§-):§n the §?default value §-the progressBar shall take on, either in percent or absolute, see §?valueType§-. Defaults to §?0§-."
714
715progressBarProperties["valueType"] = {}
716progressBarProperties["valueType"]["input"] = "DDM:relative:absolute"
717progressBarProperties["valueType"]["essential"] = false
718progressBarProperties["valueType"]["desc"] = "§?valueType §-(§?relative§-,§?absolute§-):§n whether §?value §-shall be an §?absolute §-value or a §?relative percentage§-. Defaults to §?absolute§-."
719
720progressBarProperties["color"] = {}
721progressBarProperties["color"]["input"] = "color"
722progressBarProperties["color"]["essential"] = false
723progressBarProperties["color"]["desc"] = "§?color §-(§?color§-):§n the §?color §-the §?bar §-of the progressBar shall take on. If unused (nil) will be the §?defaultTextColor §-of the screen."
724
725progressBarProperties["BGColor"] = {}
726progressBarProperties["BGColor"]["input"] = "color"
727progressBarProperties["BGColor"]["essential"] = false
728progressBarProperties["BGColor"]["desc"] = "§?BGColor §-(§?color§-):§n the §?background §-of the progressBar. If unused (nil) will be the §?defaultBGColor §-of the screen."
729
730progressBarProperties["borderColor"] = {}
731progressBarProperties["borderColor"]["input"] = "color"
732progressBarProperties["borderColor"]["essential"] = false
733progressBarProperties["borderColor"]["desc"] = "§?borderColor §-(§?color§-):§n §?color §-of the §?border §-of the progressBar. §?borderThickness §-needs to be greater than §?0§-. If unused (nil) will be §?BGColor§-."
734
735progressBarProperties["borderThickness"] = {}
736progressBarProperties["borderThickness"]["input"] = "number"
737progressBarProperties["borderThickness"]["essential"] = false
738progressBarProperties["borderThickness"]["desc"] = "§?borderThickness §-(§?non-decimal number §-in §?pixels§-):§n how §?thick §-the §?border §-of the progressBar shall be. If unused (nil) will be §?0§-. (no border)"
739
740progressBarProperties["colorsArray"] = {}
741progressBarProperties["colorsArray"]["input"] = "colorsArray"
742progressBarProperties["colorsArray"]["essential"] = false
743progressBarProperties["colorsArray"]["desc"] = "§?colorsArray §-(§?numerically-indexed table§-):§n this can be used if you want a §?different bar color §-for §?different values§-. Example: red for high values and green for low values."
744
745progressBarProperties["broadness"] = {}
746progressBarProperties["broadness"]["input"] = "number"
747progressBarProperties["broadness"]["essential"] = false
748progressBarProperties["broadness"]["desc"] = "§?broadness §-(§?non-decimal number §-in §?pixels§-):§n how §?broad §-the progressBar shall be. Perpendicular to progressBar orientation. If unused (nil) will be §?1§-."
749
750progressBarProperties["orientation"] = {}
751progressBarProperties["orientation"]["input"] = "DDM:top-bottom:bottom-top:left-right:right-left"
752progressBarProperties["orientation"]["essential"] = false
753progressBarProperties["orientation"]["desc"] = "§?orientation §-(§?top-bottom§-,§?bottom-top§-,§?left-right§-,§?right-left§-):§n how the progressBar shall be §?oriented§-. '§?start-end§-'. If unused (nil) will be §?left-right§-."
754
755progressBarProperties["textPosition"] = {}
756progressBarProperties["textPosition"]["input"] = "DDM:top:bottom:left:right"
757progressBarProperties["textPosition"]["essential"] = false
758progressBarProperties["textPosition"]["desc"] = "§?textPosition §-(§?top§-,§?bottom§-,§?left§-,§?right§-):§n if this value is set will display the §?current value §-at the §?chosen position§-."
759
760progressBarProperties["textMargin"] = {}
761progressBarProperties["textMargin"]["input"] = "number"
762progressBarProperties["textMargin"]["essential"] = false
763progressBarProperties["textMargin"]["desc"] = "§?textMargin §-(§?non-decimal number §-in §?pixels§-):§n determines §?how many pixels away from §-the progressBar the §?value §-will be placed. Requires §?textPosition §-to be set. If unused (nil) will be §?0§-."
764
765--width,height,graphTables,graphDesigns(color,BGColor,character),unitsPerPixelX,unitsPerPixelY,axesColor,numbersColor,labelX,labelY,startX,startY,stepX,stepY
766coordinateSystemProperties = {}
767coordinateSystemProperties["width"] = {}
768coordinateSystemProperties["width"]["input"] = "number"
769coordinateSystemProperties["width"]["essential"] = true
770coordinateSystemProperties["width"]["desc"] = "§?width §-(§?non-decimal number §-in §?pixels§-):§n how §?long §-the §?x axis §-shall be."
771coordinateSystemProperties["width"]["default"] = 10
772
773coordinateSystemProperties["height"] = {}
774coordinateSystemProperties["height"]["input"] = "number"
775coordinateSystemProperties["height"]["essential"] = true
776coordinateSystemProperties["height"]["desc"] = "§?height §-(§?non-decimal number §-in §?pixels§-):§n how §?long §-the §?y axis §-shall be."
777coordinateSystemProperties["height"]["default"] = 10
778
779coordinateSystemProperties["graphTables"] = {}
780coordinateSystemProperties["graphTables"]["input"] = "CSTable"
781coordinateSystemProperties["graphTables"]["essential"] = false
782coordinateSystemProperties["graphTables"]["desc"] = "§?graphTables §-(§?numerically-indexed nested table§-):§n all §?graphs §-to be displayed. Structure: §?array[index]={[x]=y}§-"
783
784coordinateSystemProperties["graphDesigns"] = {}
785coordinateSystemProperties["graphDesigns"]["input"] = "CSDesignsTable"
786coordinateSystemProperties["graphDesigns"]["essential"] = false
787coordinateSystemProperties["graphDesigns"]["desc"] = "§?graphDesigns §-(§?numerically-indexed nested table§-):§n each graph can have a different §?display character§-, §?color §-and §?background color§-, stored in this table. Structure: §?array[index]={[\"character\"]=\"x\",[\"color\"]=color,[\"BGColor\"]=BGColor}§-"
788
789coordinateSystemProperties["numbersColor"] = {}
790coordinateSystemProperties["numbersColor"]["input"] = "color"
791coordinateSystemProperties["numbersColor"]["essential"] = false
792coordinateSystemProperties["numbersColor"]["desc"] = "§?numbersColor §-(§?color§-):§n §?color §-of the §?numbers §-next to the axes. If unused (nil) will be §?defaultTextColor §-of the screen."
793
794coordinateSystemProperties["axesColor"] = {}
795coordinateSystemProperties["axesColor"]["input"] = "color"
796coordinateSystemProperties["axesColor"]["essential"] = false
797coordinateSystemProperties["axesColor"]["desc"] = "§?axesColor §-(§?color§-):§n §?color §-of the §?axes§-. If unused (nil) will be §?defaultTextColor §-of the screen."
798
799coordinateSystemProperties["unitsPerPixelX"] = {}
800coordinateSystemProperties["unitsPerPixelX"]["input"] = "decimal"
801coordinateSystemProperties["unitsPerPixelX"]["essential"] = false
802coordinateSystemProperties["unitsPerPixelX"]["desc"] = "§?unitsPerPixelX §-(§?decimal number§-):§n how many §?units §-one §?pixel §-equals on the §?x axis§-. If unused (nil) will be §?1§-."
803
804coordinateSystemProperties["unitsPerPixelY"] = {}
805coordinateSystemProperties["unitsPerPixelY"]["input"] = "decimal"
806coordinateSystemProperties["unitsPerPixelY"]["essential"] = false
807coordinateSystemProperties["unitsPerPixelY"]["desc"] = "§?unitsPerPixelY §-(§?decimal number§-):§n how many §?units §-one §?pixel §-equals on the §?y axis§-. If unused (nil) will be §?1§-."
808
809coordinateSystemProperties["labelX"] = {}
810coordinateSystemProperties["labelX"]["input"] = "string"
811coordinateSystemProperties["labelX"]["essential"] = false
812coordinateSystemProperties["labelX"]["desc"] = "§?labelX §-(§?string§-):§n §?label §-of the §?x axis §-to be placed next to it. If unused (nil) will be §?X§-."
813
814coordinateSystemProperties["labelY"] = {}
815coordinateSystemProperties["labelY"]["input"] = "string"
816coordinateSystemProperties["labelY"]["essential"] = false
817coordinateSystemProperties["labelY"]["desc"] = "§?labelY §-(§?string§-):§n §?label §-of the §?y axis §-to be placed next to it. If unused (nil) will be §?Y§-."
818
819coordinateSystemProperties["startX"] = {}
820coordinateSystemProperties["startX"]["input"] = "decimal"
821coordinateSystemProperties["startX"]["essential"] = false
822coordinateSystemProperties["startX"]["desc"] = "§?startX §-(§?decimal number§-):§n what §?x coordinate §-shall be at the §?origin §-of the system. If unused (nil) will be §?0§-."
823
824coordinateSystemProperties["startY"] = {}
825coordinateSystemProperties["startY"]["input"] = "decimal"
826coordinateSystemProperties["startY"]["essential"] = false
827coordinateSystemProperties["startY"]["desc"] = "§?startY §-(§?decimal number§-):§n what §?y coordinate §-shall be at the §?origin §-of the system. If unused (nil) will be §?0§-."
828
829coordinateSystemProperties["stepX"] = {}
830coordinateSystemProperties["stepX"]["input"] = "number"
831coordinateSystemProperties["stepX"]["essential"] = false
832coordinateSystemProperties["stepX"]["desc"] = "§?stepX §-(§?non-decimal number §-in §?pixels§-):§n §?every how many pixels §-a §?number label §-shall be placed next to the §?x axis§-. If unused (nil) will be as small as possible while maintaining 1 pixel space."
833
834coordinateSystemProperties["stepY"] = {}
835coordinateSystemProperties["stepY"]["input"] = "number"
836coordinateSystemProperties["stepY"]["essential"] = false
837coordinateSystemProperties["stepY"]["desc"] = "§?stepY §-(§?non-decimal number §-in §?pixels§-):§n §?every how many pixels §-a §?number label §-shall be placed next to the §?y axis§-. If unused (nil) will be as small as possible while maintaining 1 pixel space."
838
839--linesArray
840pictureProperties = {}
841pictureProperties["linesArray"] = {}
842pictureProperties["linesArray"]["input"] = "picArray"
843pictureProperties["linesArray"]["essential"] = true
844pictureProperties["linesArray"]["desc"] = "§?linesArray §-(§?numerically indexed string table§-):§n this array defines the §?whole picture§-. §?One entry §-equals §?one line§-. Colors are defined with one character §?0-f§-. String structure: \"§?;§-\"=§?transparent pixel§-, \"§?color;§-\"=§?pixel without character§-, \"§?color:bgcolor:character;§-\"=§?pixel with character§-."
845pictureProperties["linesArray"]["default"] = {"#;#;#;#;#;#;#;#;#;#;","#;*:#:Y;*:#:o;*:#:u;*:#:r;#;*:#:P;*:#:i;*:#:c;#;","#;#;#;#;#;#;#;#;#;#;"}
846
847pictureProperties["width"] = {}
848pictureProperties["width"]["input"] = "number"
849pictureProperties["width"]["essential"] = true
850pictureProperties["width"]["desc"] = "§?width §-(§?non-decimal number §-in §?pixels§-):§n how §?wide §-the picture shall be. Even if more information is stored in linesArray, will not overrun this property."
851pictureProperties["width"]["default"] = 10
852
853pictureProperties["height"] = {}
854pictureProperties["height"]["input"] = "number"
855pictureProperties["height"]["essential"] = true
856pictureProperties["height"]["desc"] = "§?height §-(§?non-decimal number §-in §?pixels§-):§n how §?high §-the picture shall be. Even if more information is stored in linesArray, will not overrun this property."
857pictureProperties["height"]["default"] = 3
858
859--elementProperties
860elementProperties = {}
861elementProperties["dynTextBox"] = dynamicTextBoxProperties
862elementProperties["slider"] = sliderProperties
863elementProperties["dropDownMenu"] = dropDownMenuProperties
864elementProperties["navMenu"] = navigationMenuProperties
865elementProperties["colorPicker"] = colorPickerProperties
866elementProperties["progressBar"] = progressBarProperties
867elementProperties["coordsSystem"] = coordinateSystemProperties
868elementProperties["picture"] = pictureProperties
869
870elements = {}
871elements["dynTextBox"] = dynamicTextBoxes
872elements["slider"] = sliders
873elements["dropDownMenu"] = dropDownMenus
874elements["navMenu"] = navigationMenus
875elements["colorPicker"] = colorPickers
876elements["progressBar"] = progressBars
877elements["coordsSystem"] = coordinateSystems
878elements["picture"] = pictures
879
880addingFunctions = {}
881addingFunctions["dynTextBox"] = addDynamicTextBox
882addingFunctions["slider"] = addSlider
883addingFunctions["dropDownMenu"] = addDropDownMenu
884addingFunctions["navMenu"] = addNavigationMenu
885addingFunctions["colorPicker"] = addColorPicker
886addingFunctions["progressBar"] = addProgressBar
887addingFunctions["coordsSystem"] = addCoordinateSystem
888addingFunctions["picture"] = addPicture
889
890--function tables
891functions = {}
892
893functions["relX"] = {}
894functions["relX"]["desc"] = "This function can be used to convert a relative X position in % (argument 1) to an absolute coordinate (return value) on a specific screen. (argument 2)"
895functions["relX"]["arg1"] = "number percentage"
896functions["relX"]["arg2"] = "string screenID"
897functions["relX"]["return"] = "number coordinate"
898functions["relX"]["example"] = "If you want an element to take up the half of the screen (x-coordinate) and centered you would do something like this: changeProperty(\"yourElement\",\"width\",relX(50,\"yourScreen\")) changePos(\"yourElement\",\"yourScreen\",relX(25,\"yourScreen\"))"
899
900functions["relY"] = {}
901functions["relY"]["desc"] = "This function can be used to convert a relative Y position in % (argument 1) to an absolute coordinate (return value) on a specific screen. (argument 2)"
902functions["relY"]["arg1"] = "number percentage"
903functions["relY"]["arg2"] = "string screenID"
904functions["relY"]["return"] = "number coordinate"
905functions["relY"]["example"] = "If you want an element to take up the half of the screen (y-coordinate) and centered you would do something like this: changeProperty(\"yourElement\",\"width\",relY(50,\"yourScreen\")) changePos(\"yourElement\",\"yourScreen\",relY(25,\"yourScreen\"))"
906
907functions["loadScreen"] = {}
908functions["loadScreen"]["desc"] = "This function loads a screen from a pseudo-xml file located in /EasyGUI/screens."
909functions["loadScreen"]["arg1"] = "string screenID"
910functions["loadScreen"]["return"] = "boolean success"
911
912functions["saveScreen"] = {}
913functions["saveScreen"]["desc"] = "This function saves a screen present in memory to a pseudo-xml file in /EasyGUI/screens."
914functions["saveScreen"]["arg1"] = "string screenID"
915functions["saveScreen"]["return"] = "boolean success"
916
917functions["loadElement"] = {}
918functions["loadElement"]["desc"] = "This function loads an element of the given type (argument 2, string: \"dynTextBox\" or \"slider\" or \"dropDownMenu\" or \"navMenu\" or \"colorPicker\" or \"progressBar\" or \"coordsSystem\" or \"picture\") from a pseudo-xml file located in /EasyGUI/*type*."
919functions["loadElement"]["arg1"] = "string elementID"
920functions["loadElement"]["arg2"] = "string type"
921functions["loadElement"]["return"] = "boolean success"
922
923functions["saveElement"] = {}
924functions["saveElement"]["desc"] = "This function saves an element present in memory of the given type (argument 2, string: \"dynTextBox\" or \"slider\" or \"dropDownMenu\" or \"navMenu\" or \"colorPicker\" or \"progressBar\" or \"coordsSystem\" or \"picture\") into a pseudo-xml in /EasyGUI/*type*."
925functions["saveElement"]["arg1"] = "string elementID"
926functions["saveElement"]["arg2"] = "string type"
927functions["saveElement"]["return"] = "boolean success"
928
929functions["refresh"] = {}
930functions["refresh"]["desc"] = "This function refreshes all screens on all monitors/terminal in a very performance-friendly way. It only draws pixels again which actually changed. See also fullRefresh()."
931
932functions["fullRefresh"] = {}
933functions["fullRefresh"]["desc"] = "This function redraws all pixels on all screens on all monitors/terminal. This is very performance heavy and should be used very rarely (see refresh()). It has to be called however if you change which screen is to be rendered on a specific monitor/terminal."
934
935functions["run"] = {}
936functions["run"]["desc"] = "This function should be called last and starts the event cycle. Argument 1 specifies every how many seconds refresh() will be called. Can also be nil, in which case you will have to refresh manually if something changes. Will handle all click/touch events and pass events to previously specified functions. (See setProcessEventFunction) Loop can be interrupted with os.queueEvent(\"easygui_interrupt\")"
937functions["run"]["arg1"] = "number refreshRate"
938
939functions["addElementToScreen"] = {}
940functions["addElementToScreen"]["desc"] = "Self-explanatory. Note: one element cannot be added to one screen multiple times. However, one element can be added to multiple screens but this might have awkward results."
941functions["addElementToScreen"]["arg1"] = "string elementID"
942functions["addElementToScreen"]["arg2"] = "string screenID"
943functions["addElementToScreen"]["arg3"] = "number x"
944functions["addElementToScreen"]["arg4"] = "number y"
945functions["addElementToScreen"]["return"] = "boolean success"
946
947functions["removeElementFromScreen"] = {}
948functions["removeElementFromScreen"]["desc"] = "Self-explanatory."
949functions["removeElementFromScreen"]["arg1"] = "string elementID"
950functions["removeElementFromScreen"]["arg2"] = "string screenID"
951functions["removeElementFromScreen"]["return"] = "boolean success"
952
953functions["changePos"] = {}
954functions["changePos"]["desc"] = "Self-explanatory."
955functions["changePos"]["arg1"] = "string elementID"
956functions["changePos"]["arg2"] = "string screenID"
957functions["changePos"]["arg3"] = "number x"
958functions["changePos"]["arg4"] = "number y"
959functions["changePos"]["return"] = "boolean success"
960
961functions["getPos"] = {}
962functions["getPos"]["desc"] = "Self-explanatory."
963functions["getPos"]["arg1"] = "string elementID"
964functions["getPos"]["arg2"] = "string screenID"
965functions["getPos"]["return"] = "number x, number y"
966
967functions["setScreenToRenderOnMon"] = {}
968functions["setScreenToRenderOnMon"]["desc"] = "Pretty much self-explanatory. Argument 3 is required to determine with which textscale screen will be drawn. (normally 0.5) Arguments 4 and 5 are optional and can be used to offset the screen by a certain margin. (if screen size with given textscale is smaller than the whole monitor)"
969functions["setScreenToRenderOnMon"]["arg1"] = "string screenID"
970functions["setScreenToRenderOnMon"]["arg2"] = "string monitorID"
971functions["setScreenToRenderOnMon"]["arg3"] = "number textscale"
972functions["setScreenToRenderOnMon"]["arg4"] = "number offsetX"
973functions["setScreenToRenderOnMon"]["arg5"] = "number offsetY"
974functions["setScreenToRenderOnMon"]["return"] = "boolean success"
975
976functions["setScreenToRenderOnTerminal"] = {}
977functions["setScreenToRenderOnTerminal"]["desc"] = "Self-explanatory."
978functions["setScreenToRenderOnTerminal"]["arg1"] = "string screenID"
979functions["setScreenToRenderOnTerminal"]["return"] = "boolean success"
980
981functions["setRefreshFunction"] = {}
982functions["setRefreshFunction"]["desc"] = "After calling run(refreshRate), this function will be called every 'refreshRate' seconds. Note: the first time this will be called is after 'refreshRate' seconds have passed."
983functions["setRefreshFunction"]["arg1"] = "function refreshFunc"
984
985functions["setProcessEventFunction"] = {}
986functions["setProcessEventFunction"]["desc"] = "The specified function will be called every time an event is caught with all params os.pullEvent() delivers. See https://computercraft.info/wiki/Os.pullEvent."
987functions["setProcessEventFunction"]["arg1"] = "function processEventFunc"
988
989functions["setProcessClickEventFunction"] = {}
990functions["setProcessClickEventFunction"]["desc"] = "The specified function will be called when an EasyGUI element is clicked/dragged with following arguments: (elementType,elementID,elementPart)"
991functions["setProcessClickEventFunction"]["arg1"] = "function processClickEventFunc"
992
993functions["getType"] = {}
994functions["getType"]["desc"] = "Self-explanatory. Possible returns: \"dynTextBox\" or \"slider\" or \"dropDownMenu\" or \"navMenu\" or \"colorPicker\" or \"progressBar\" or \"coordsSystem\" or \"picture\" or \"screen\" or \"monitor\" or \"NOTFOUND\""
995functions["getType"]["arg1"] = "string ID"
996functions["getType"]["return"] = "string type"
997
998functions["getProperty"] = {}
999functions["getProperty"]["desc"] = "Self-explanatory."
1000functions["getProperty"]["arg1"] = "string elementID"
1001functions["getProperty"]["arg2"] = "string prop"
1002functions["getProperty"]["return"] = "var value"
1003
1004functions["changeProperty"] = {}
1005functions["changeProperty"]["desc"] = "Self-explanatory. Please be careful which property can cope with which values, as this function will not validate what you give it. Check the descriptions in the EasyGUI editor."
1006functions["changeProperty"]["arg1"] = "string elementID"
1007functions["changeProperty"]["arg2"] = "string prop"
1008functions["changeProperty"]["arg3"] = "var value"
1009functions["changeProperty"]["return"] = "boolean success"
1010
1011--string to boolean
1012function toBool(var)
1013 if type(var)=="string" then
1014 if var=="true" then
1015 return true
1016 else
1017 return false
1018 end
1019 end
1020end
1021
1022--this is used to avoid ID conflicts
1023function trackID(ID)
1024 ID = string.lower(ID)
1025 local found = false
1026 for i,current in ipairs(IDlist) do
1027 if current==ID then
1028 found = true
1029 break
1030 end
1031 end
1032 if found then
1033 writeToLog("Potential ID conflict: "..ID..". Ignore if designer.",3)
1034 else
1035 if ID~=nil then
1036 table.insert(IDlist,ID)
1037 writeToLog("ID "..ID.." added to list.",1)
1038 else
1039 writeToLog("ID can't be nil!",4)
1040 return false
1041 end
1042 end
1043 return not found
1044end
1045
1046function IDExists(ID)
1047 ID = string.lower(ID)
1048 for i,current in ipairs(IDlist) do
1049 if ID==current then
1050 return true
1051 end
1052 end
1053 return false
1054end
1055
1056--function to turn a percentage into an absolute coordinate
1057function relX(perc,screenID)
1058 if math.floor(((screens[screenID]["sizeX"])/100)*perc)>0 then
1059 return math.floor(((screens[screenID]["sizeX"])/100)*perc+0.5)
1060 else
1061 return 1
1062 end
1063end
1064
1065function relY(perc,screenID)
1066 if math.floor(((screens[screenID]["sizeY"])/100)*perc)>0 then
1067 return math.floor(((screens[screenID]["sizeY"])/100)*perc+0.5)
1068 else
1069 return 1
1070 end
1071end
1072
1073--writeToLog function with 5 different levels and time since program start
1074function writeToLog(text,level)
1075 local levels = {"DEBUG","INFO","WARNING","ERROR","FATAL"}
1076 if level == nil then
1077 level = 2
1078 end
1079 if level>=writingLogLevel then
1080 if fs.getFreeSpace(fs.combine(root,"EasyGUI/"))>1000 then
1081 local timeNumber = os.clock() - startTime
1082 local hours = 0
1083 local minutes = 0
1084 local seconds = 0
1085 local milliseconds = 0
1086 while timeNumber>=3600 do
1087 hours = hours + 1
1088 timeNumber = timeNumber - 3600
1089 end
1090 while timeNumber>=60 do
1091 minutes = minutes + 1
1092 timeNumber = timeNumber - 60
1093 end
1094 seconds = timeNumber
1095
1096 local hours = tostring(hours)
1097 local minutes = tostring(minutes)
1098 local seconds = tostring(seconds)
1099 if string.len(hours)==1 then
1100 hours = "0"..hours
1101 end
1102 if string.len(minutes)==1 then
1103 minutes = "0"..minutes
1104 end
1105 if lastLogString~="[EasyGUI]["..hours..":"..minutes..":"..seconds.."] "..levels[level]..": "..text then
1106 logFile.writeLine("[EasyGUI]["..hours..":"..minutes..":"..seconds.."] "..levels[level]..": "..text)
1107 logFile.flush()
1108 lastLogString = "[EasyGUI]["..hours..":"..minutes..":"..seconds.."] "..levels[level]..": "..text
1109 end
1110 end
1111 end
1112end
1113
1114--save and load functions from here:
1115--monitors,screens,dynamicTextBoxes,sliders,dropDownMenus,navigationMenus,colorPickers,progressBars,coordinateSystem,picture
1116
1117function saveMonitors()
1118 writeToLog("Saving monitors to monitors.xml...",2)
1119 if fs.exists(fs.combine(root,"EasyGUI/monitors.xml")) then
1120 fs.delete(fs.combine(root,"EasyGUI/monitors.xml"))
1121 end
1122 local stream = fs.open(fs.combine(root,"EasyGUI/monitors.xml"),"a")
1123 stream.writeLine("<monitors>")
1124
1125 for sMonitor,data in pairs(monitors) do
1126 writeToLog("Saving monitor "..sMonitor.." to monitors.xml...",1)
1127 stream.writeLine("\t<monitor>")
1128 stream.writeLine("\t\t<name>"..sMonitor.."</name>")
1129 writeToLog("Saving side "..data["side"]..".",1)
1130 stream.writeLine("\t\t<side>"..data["side"].."</side>")
1131 writeToLog("Saving networkID "..data["networkID"]..".",1)
1132 stream.writeLine("\t\t<networkID>"..data["networkID"].."</networkID>")
1133 stream.writeLine("\t</monitor>")
1134 writeToLog("Done saving monitor "..sMonitor.." to monitors.xml.",1)
1135 end
1136
1137 stream.writeLine("</monitors>")
1138 stream.close()
1139 writeToLog("Done saving monitors to monitors.xml.",2)
1140end
1141
1142function loadMonitors()
1143 writeToLog("Loading monitors from monitors.xml...",2)
1144 local stream = fs.open(fs.combine(root,"EasyGUI/monitors.xml"),"r")
1145
1146 local line = stream.readLine()
1147 local mon = nil
1148 while line~=nil do
1149 if string.match(line,"<monitor>") then
1150 if mon==nil then
1151 mon = {}
1152 writeToLog("Reading new monitor tag...",1)
1153 else
1154 writeToLog("Found monitor tag even though previous monitor tag was not closed. Did someone mess around with the xml?",4)
1155 mon = {}
1156 end
1157 end
1158 if string.match(line,"<name>") and string.match(line,"</name>") then
1159 a,start = string.find(line,"<name>")
1160 sEnd,b = string.find(line,"</name>")
1161 name = string.sub(line,start+1,sEnd-1)
1162 if mon~=nil then
1163 writeToLog("Reading monitor name: "..name,1)
1164 mon["name"] = name
1165 else
1166 writeToLog("Found name tag even though no monitor tag is opened. Did someone mess around with the xml?",4)
1167 end
1168 end
1169 if string.match(line,"<side>") and string.match(line,"</side>") then
1170 a,start = string.find(line,"<side>")
1171 sEnd,b = string.find(line,"</side>")
1172 side = string.sub(line,start+1,sEnd-1)
1173 if mon~=nil then
1174 writeToLog("Reading monitor side: "..side,1)
1175 mon["side"] = side
1176 else
1177 writeToLog("Found side tag even though no monitor tag is opened. Did someone mess around with the xml?",4)
1178 end
1179 end
1180 if string.match(line,"<networkID>") and string.match(line,"</networkID>") then
1181 a,start = string.find(line,"<networkID>")
1182 sEnd,b = string.find(line,"</networkID>")
1183 networkID = string.sub(line,start+1,sEnd-1)
1184 if mon~=nil then
1185 writeToLog("Reading monitor networkID: "..networkID,1)
1186 mon["networkID"] = networkID
1187 else
1188 writeToLog("Found networkID tag even though no monitor tag is opened. Did someone mess around with the xml?",4)
1189 end
1190 end
1191 if string.match(line,"</monitor>") then
1192 if mon~=nil then
1193 name = mon["name"]
1194 mon["name"] = nil
1195 if mon["side"]~=nil and mon["networkID"]~=nil then
1196 monitors[name] = mon
1197 trackID(name)
1198 if mon["networkID"]=="NONE" then
1199 monitors[name]["peripheral"] = peripheral.wrap(mon["side"])
1200 if monitors[name]["peripheral"]==nil then
1201 monitors[name]=nil
1202 writeToLog("A saved monitor is missing. Reinitializing search.",4)
1203 fs.delete(fs.combine(root,"EasyGUI/monitors.xml"))
1204 findMonitors()
1205 saveMonitors()
1206 break
1207 else
1208 writeToLog("Successfully read information for monitor "..name.." and added to the system.",1)
1209 end
1210 else
1211 monitors[name]["peripheral"] = peripheral.wrap(mon["networkID"])
1212 if monitors[name]["peripheral"]==nil then
1213 monitors[name]=nil
1214 writeToLog("A saved monitor is missing. Reinitializing search.",4)
1215 fs.delete(fs.combine(root,"EasyGUI/monitors.xml"))
1216 findMonitors()
1217 saveMonitors()
1218 break
1219 else
1220 writeToLog("Successfully read information for monitor "..name.." and added to the system.",1)
1221 end
1222 end
1223 else
1224 writeToLog("Information for monitor "..name.." is faulty. Did someone mess around with the xml?",4)
1225 end
1226 mon = nil
1227 else
1228 writeToLog("Found monitor closing tag even though it was not opened. Did someone mess around with the xml?",4)
1229 end
1230 end
1231
1232 line = stream.readLine()
1233 end
1234
1235 writeToLog("Done loading monitors from monitors.xml.",2)
1236 stream.close()
1237end
1238
1239function saveScreen(ID)
1240 local success = false
1241 if screens[ID]~=nil then
1242 writeToLog("Saving screen "..ID.."...",2)
1243 if fs.exists(fs.combine(root,"EasyGUI/screens/"..ID..".xml")) then
1244 fs.delete(fs.combine(root,"EasyGUI/screens/"..ID..".xml"))
1245 end
1246
1247 local handle = fs.open(fs.combine(root,"EasyGUI/screens/"..ID..".xml"),"a")
1248
1249 local data = screens[ID]
1250
1251 handle.writeLine("<screen>")
1252 saveProp(handle,"sizeX",data)
1253 saveProp(handle,"sizeY",data)
1254 saveProp(handle,"defaultTextColor",data)
1255 saveProp(handle,"defaultBGColor",data)
1256
1257 handle.writeLine("\t<elements>")
1258 for i,element in ipairs(data["elements"]) do
1259 if string.len(element["ID"])<32 then
1260 handle.writeLine("\t\t<element>")
1261 handle.writeLine("\t\t\t<type>"..element["type"].."</type>")
1262 handle.writeLine("\t\t\t<ID>"..element["ID"].."</ID>")
1263 handle.writeLine("\t\t\t<x>"..element["x"].."</x>")
1264 handle.writeLine("\t\t\t<y>"..element["y"].."</y>")
1265 saveElement(element["ID"],element["type"])
1266 handle.writeLine("\t\t</element>")
1267 end
1268 end
1269 handle.writeLine("\t</elements>")
1270
1271 handle.writeLine("</screen>")
1272 handle.close()
1273 writeToLog("Done saving screen "..ID..".",2)
1274 success = true
1275 else
1276 writeToLog("Could not save screen "..ID.." because it was not found.",3)
1277 end
1278 return success
1279end
1280
1281function loadScreen(ID)
1282 local success = false
1283 if fs.exists(fs.combine(root,"EasyGUI/screens/"..ID..".xml")) then
1284 local handle = fs.open(fs.combine(root,"EasyGUI/screens/"..ID..".xml"),"r")
1285 local temp = {}
1286 local line = handle.readLine()
1287 while line~=nil do
1288 readPropNumber(line,"sizeX",temp)
1289 readPropNumber(line,"sizeY",temp)
1290 readPropNumber(line,"defaultTextColor",temp)
1291 readPropNumber(line,"defaultBGColor",temp)
1292 if string.match(line,"<elements>") then
1293 local temp2 = {}
1294 line = handle.readLine()
1295 while not string.match(line,"</elements>") do
1296 if string.match(line,"<element>") then
1297 local temp3 = {}
1298 line = handle.readLine()
1299 while not string.match(line,"</element>") do
1300 if string.match(line,"<type>") and string.match(line,"</type>") then
1301 a,start = string.find(line,"<type>")
1302 sEnd,b = string.find(line,"</type>")
1303 type_ = string.sub(line,start+1,sEnd-1)
1304 temp3["type"] = type_
1305 end
1306 if string.match(line,"<ID>") and string.match(line,"</ID>") then
1307 a,start = string.find(line,"<ID>")
1308 sEnd,b = string.find(line,"</ID>")
1309 ID_ = string.sub(line,start+1,sEnd-1)
1310 temp3["ID"] = ID_
1311 end
1312 if string.match(line,"<x>") and string.match(line,"</x>") then
1313 a,start = string.find(line,"<x>")
1314 sEnd,b = string.find(line,"</x>")
1315 x_ = string.sub(line,start+1,sEnd-1)
1316 temp3["x"] = tonumber(x_)
1317 end
1318 if string.match(line,"<y>") and string.match(line,"</y>") then
1319 a,start = string.find(line,"<y>")
1320 sEnd,b = string.find(line,"</y>")
1321 y_ = string.sub(line,start+1,sEnd-1)
1322 temp3["y"] = tonumber(y_)
1323 end
1324
1325 line = handle.readLine()
1326 end
1327 loadElement(temp3["ID"],temp3["type"])
1328 table.insert(temp2,temp3)
1329 end
1330 line = handle.readLine()
1331 end
1332 temp["elements"] = temp2
1333 end
1334 line = handle.readLine()
1335 end
1336 if temp["sizeX"]~=nil and temp["sizeY"]~=nil and temp["defaultTextColor"]~=nil and temp["defaultBGColor"]~=nil and temp["elements"]~=nil then
1337 temp["pixelMatrix"] = {}
1338 screens[ID] = temp
1339 trackID(ID)
1340 writeToLog("Succesfully loaded screen "..ID..".",2)
1341 success = true
1342 else
1343 writeToLog("Information for screen "..ID.." is faulty. Did someone mess around with the xml?",4)
1344 end
1345 handle.close()
1346 else
1347 writeToLog("Could not load screen "..ID.." because the file was not found.",3)
1348 end
1349 return success
1350end
1351
1352function tryLoadAllScreens()
1353 if fs.exists(fs.combine(root,"/EasyGUI/screens/")) then
1354 for i,name in ipairs(fs.list(fs.combine(root,"/EasyGUI/screens/"))) do
1355 if string.sub(name,-4)==".xml" then
1356 if screens[string.sub(name,1,-5)]==nil then
1357 loadScreen(string.sub(name,1,-5))
1358 end
1359 end
1360 end
1361 end
1362end
1363
1364function tryLoadAllElements()
1365 for type_,data in pairs(elements) do
1366 if fs.exists(fs.combine(root,"/EasyGUI/"..type_.."/")) then
1367 for i,name in ipairs(fs.list(fs.combine(root,"/EasyGUI/"..type_.."/"))) do
1368 if string.sub(name,-4)==".xml" then
1369 if elements[type_][string.sub(name,1,-5)]==nil then
1370 loadElement(string.sub(name,1,-5),type_)
1371 end
1372 end
1373 end
1374 end
1375 end
1376end
1377
1378function saveProp(handle,prop,data)
1379 if data[prop]~=nil then
1380 handle.writeLine("\t<"..prop..">"..data[prop].."</"..prop..">")
1381 writeToLog("Saving "..prop.." "..data[prop]..".",1)
1382 end
1383end
1384
1385function readPropString(line,prop,temp)
1386 if string.match(line,"<"..prop..">") and string.match(line,"</"..prop..">") then
1387 local a,start = string.find(line,"<"..prop..">")
1388 local sEnd,b = string.find(line,"</"..prop..">")
1389 local value = string.sub(line,start+1,sEnd-1)
1390 temp[prop] = value
1391 writeToLog("Reading "..prop..": "..value,1)
1392 end
1393end
1394
1395function readPropNumber(line,prop,temp)
1396 if string.match(line,"<"..prop..">") and string.match(line,"</"..prop..">") then
1397 local a,start = string.find(line,"<"..prop..">")
1398 local sEnd,b = string.find(line,"</"..prop..">")
1399 local value = string.sub(line,start+1,sEnd-1)
1400 temp[prop] = tonumber(value)
1401 writeToLog("Reading "..prop..": "..value,1)
1402 end
1403end
1404
1405function saveArray(handle,prop,data)
1406 if data[prop]~=nil then
1407 handle.writeLine("\t<"..prop..">")
1408 writeToLog("Saving "..prop..".",1)
1409 for i,entry in ipairs(data[prop]) do
1410 handle.writeLine("\t\t<"..i..">"..entry.."</"..i..">")
1411 end
1412 handle.writeLine("\t</"..prop..">")
1413 end
1414end
1415
1416function readNumberArray(line,prop,temp,handle)
1417 if string.match(line,"<"..prop..">") then
1418 line = handle.readLine()
1419 local temp2 = {}
1420 while not (string.match(line,"</"..prop..">")) do
1421 if string.match(line,"<%d+>") and string.match(line,"</%d+>") then
1422 local a,start = string.find(line,"<%d+>")
1423 local sEnd,b = string.find(line,"</%d+>")
1424 local currentValue = tonumber(string.sub(line,start+1,sEnd-1))
1425 local index = tonumber(string.sub(line,a+1,start-1))
1426 temp2[index] = currentValue
1427 end
1428
1429 line = handle.readLine()
1430 end
1431 temp[prop] = temp2
1432 writeToLog("Reading "..prop..".",1)
1433 end
1434end
1435
1436function readStringArray(line,prop,temp,handle)
1437 if string.match(line,"<"..prop..">") then
1438 line = handle.readLine()
1439 local temp2 = {}
1440 while not (string.match(line,"</"..prop..">")) do
1441 if string.match(line,"<%d+>") and string.match(line,"</%d+>") then
1442 local a,start = string.find(line,"<%d+>")
1443 local sEnd,b = string.find(line,"</%d+>")
1444 local currentValue = (string.sub(line,start+1,sEnd-1))
1445 local index = tonumber(string.sub(line,a+1,start-1))
1446 temp2[index] = currentValue
1447 end
1448
1449 line = handle.readLine()
1450 end
1451 temp[prop] = temp2
1452 writeToLog("Reading "..prop..".",1)
1453 end
1454end
1455
1456--helper function for writing navMenu arrays (recursive)
1457function writeSubmenu(handle,array,level)
1458 local tabs = "\t\t"
1459 for i=1,level-1 do
1460 tabs = tabs.."\t\t"
1461 end
1462 for i,entry in ipairs(array) do
1463 handle.writeLine(tabs.."<"..i..">")
1464 handle.writeLine(tabs.."\t<text>"..entry["text"].."</text>")
1465 if entry["submenu"]~=nil then
1466 handle.writeLine(tabs.."\t<submenu>")
1467 writeSubmenu(handle,entry["submenu"],level+1)
1468 handle.writeLine(tabs.."\t</submenu>")
1469 end
1470 handle.writeLine(tabs.."</"..i..">")
1471 end
1472end
1473
1474function saveNavMenu(handle,prop,data)
1475 handle.writeLine("\t<"..prop..">")
1476 writeSubmenu(handle,data[prop],1)
1477 handle.writeLine("\t</"..prop..">")
1478end
1479
1480function readNavMenu(line,prop,temp,handle)
1481 if string.match(line,"<"..prop..">") then
1482 line = handle.readLine()
1483 local temp2 = {}
1484 local currentPos = {}
1485 local indexTagOpen = 0
1486 local submenuTagOpen = 0
1487 local currentIndex = nil
1488 while not string.match(line,"</"..prop..">") do
1489 if string.match(line,"<%d+>") then
1490 a,start = string.find(line,"<%d+>")
1491 sEnd,b = string.find(line,"</%d+>")
1492 index = tonumber(string.sub(line,a+1,start-1))
1493
1494 local currentArray = temp2
1495 for i=1,table.getn(currentPos) do
1496 currentArray = currentArray[currentPos[i]]
1497 end
1498
1499 currentIndex = index
1500 currentArray[currentIndex] = {}
1501 indexTagOpen = indexTagOpen + 1
1502 end
1503 if string.match(line,"</%d+>") then
1504 if indexTagOpen==0 then
1505 writeToLog("Invalid "..prop.." structure. Did someone mess around with the xml?",4)
1506 end
1507 currentIndex = nil
1508 indexTagOpen = indexTagOpen - 1
1509 end
1510 if string.match(line,"<text>") and string.match(line,"</text>") then
1511 a,start = string.find(line,"<text>")
1512 sEnd,b = string.find(line,"</text>")
1513 text = string.sub(line,start+1,sEnd-1)
1514 writeToLog("Reading text: "..text,1)
1515 if indexTagOpen==0 or currentIndex==nil then
1516 writeToLog("Invalid "..prop.." structure. Did someone mess around with the xml?",4)
1517 else
1518 local currentArray = temp2
1519 for i=1,table.getn(currentPos) do
1520 currentArray = currentArray[currentPos[i]]["submenu"]
1521 end
1522 currentArray[currentIndex] = {}
1523 currentArray[currentIndex]["text"] = text
1524 end
1525 end
1526 if string.match(line,"<submenu>") then
1527 if indexTagOpen==0 or currentIndex==nil then
1528 writeToLog("Invalid "..prop.." structure. Did someone mess around with the xml?",4)
1529 else
1530 local currentArray = temp2
1531 for i=1,table.getn(currentPos) do
1532 currentArray = currentArray[currentPos[i]]["submenu"]
1533 end
1534 table.insert(currentPos,currentIndex)
1535 currentArray[currentIndex]["submenu"] = {}
1536 end
1537 submenuTagOpen = submenuTagOpen + 1
1538 end
1539 if string.match(line,"</submenu>") then
1540 if submenuTagOpen == 0 then
1541 writeToLog("Invalid "..prop.." structure. Did someone mess around with the xml?",4)
1542 else
1543 currentPos[table.getn(currentPos)] = nil
1544 end
1545
1546 submenuTagOpen = submenuTagOpen - 1
1547 end
1548 line = handle.readLine()
1549 end
1550 if submenuTagOpen~=0 or indexTagOpen~=0 then
1551 writeToLog("Invalid "..prop.." structure. Did someone mess around with the xml?",4)
1552 else
1553 temp["menuArray"] = temp2
1554 end
1555 end
1556end
1557
1558function saveCSTable(handle,prop,data)
1559 if data[prop]~=nil then
1560 handle.writeLine("\t<"..prop..">")
1561 for i,currentTable in ipairs(data[prop]) do
1562 handle.writeLine("\t\t<"..i..">")
1563 for name,currentNumber in pairs(currentTable) do
1564 handle.writeLine("\t\t\t<"..name..">"..currentNumber.."</"..name..">")
1565 end
1566 handle.writeLine("\t\t</"..i..">")
1567 end
1568 handle.writeLine("\t</"..prop..">")
1569 end
1570end
1571
1572function saveCSDesignsTable(handle,prop,data)
1573 if data[prop]~=nil then
1574 handle.writeLine("\t<"..prop..">")
1575 for i,design in ipairs(data[prop]) do
1576 handle.writeLine("\t\t<"..i..">")
1577 if design["color"]~=nil then
1578 handle.writeLine("\t\t\t<color>"..design["color"].."</color>")
1579 end
1580 if design["BGColor"]~=nil then
1581 handle.writeLine("\t\t\t<BGColor>"..design["BGColor"].."</BGColor>")
1582 end
1583 if design["character"]~=nil then
1584 handle.writeLine("\t\t\t<character>"..design["character"].."</character>")
1585 end
1586 handle.writeLine("\t\t</"..i..">")
1587 end
1588 handle.writeLine("\t</"..prop..">")
1589 end
1590end
1591
1592function readCSTable(line,prop,temp,handle)
1593 if string.match(line,"<"..prop..">") then
1594 line = handle.readLine()
1595 local temp2 = {}
1596 local tableOpen = nil
1597 while not string.match(line,"</"..prop..">") do
1598 if string.match(line,"<[%d.-]+>") then
1599 a,start = string.find(line,"<[%d.-]+>")
1600 index = tonumber(string.sub(line,a+1,start-1))
1601 if tableOpen==nil then
1602 tableOpen = index
1603 temp2[tableOpen] = {}
1604 else
1605 if string.match(line,"</[%d.-]+>") then
1606 sEnd,b = string.find(line,"</[%d.-]+>")
1607 currentNumber = tonumber(string.sub(line,start+1,sEnd-1))
1608 temp2[tableOpen][index] = currentNumber
1609 end
1610 end
1611 else if string.match(line,"</[%d.-]+>") then
1612 tableOpen = nil
1613 end
1614 end
1615 line = handle.readLine()
1616 end
1617 temp[prop] = temp2
1618 end
1619end
1620
1621function readCSDesignsTable(line,prop,temp,handle)
1622 if string.match(line,"<"..prop..">") then
1623 line = handle.readLine()
1624 local temp2 = {}
1625 local tableOpen = nil
1626 while not string.match(line,"</"..prop..">") do
1627 if string.match(line,"<%d+>") then
1628 a,start = string.find(line,"<%d+>")
1629 index = tonumber(string.sub(line,a+1,start-1))
1630 if tableOpen==nil then
1631 tableOpen = index
1632 temp2[tableOpen] = {}
1633 else
1634 writeToLog("Invalid "..prop.." structure. Did someone mess around with the xml?",4)
1635 end
1636 end
1637 if string.match(line,"</%d+>") then
1638 tableOpen = nil
1639 end
1640 if string.match(line,"<color>") and string.match(line,"</color>") then
1641 a,start = string.find(line,"<color>")
1642 sEnd,b = string.find(line,"</color>")
1643 color = string.sub(line,start+1,sEnd-1)
1644 if tableOpen==nil then
1645 writeToLog("Invalid "..prop.." structure. Did someone mess around with the xml?",4)
1646 else
1647 temp2[tableOpen]["color"] = tonumber(color)
1648 end
1649 end
1650 if string.match(line,"<BGColor>") and string.match(line,"</BGColor>") then
1651 a,start = string.find(line,"<BGColor>")
1652 sEnd,b = string.find(line,"</BGColor>")
1653 BGColor = string.sub(line,start+1,sEnd-1)
1654 if tableOpen==nil then
1655 writeToLog("Invalid "..prop.." structure. Did someone mess around with the xml?",4)
1656 else
1657 temp2[tableOpen]["BGColor"] = tonumber(BGColor)
1658 end
1659 end
1660 if string.match(line,"<character>") and string.match(line,"</character>") then
1661 a,start = string.find(line,"<character>")
1662 sEnd,b = string.find(line,"</character>")
1663 character = string.sub(line,start+1,sEnd-1)
1664 if tableOpen==nil then
1665 writeToLog("Invalid "..prop.." structure. Did someone mess around with the xml?",4)
1666 else
1667 temp2[tableOpen]["character"] = character
1668 end
1669 end
1670 line = handle.readLine()
1671 end
1672 temp[prop] = temp2
1673 end
1674end
1675
1676function saveElement(ID,type_)
1677 local success = false
1678 if elements[type_][ID]~=nil then
1679 writeToLog("Saving "..type_.." "..ID.."...",2)
1680 if fs.exists(fs.combine(root,"EasyGUI/"..type_.."/"..ID..".xml")) then
1681 fs.delete(fs.combine(root,"EasyGUI/"..type_.."/"..ID..".xml"))
1682 end
1683
1684 local handle = fs.open(fs.combine(root,"EasyGUI/"..type_.."/"..ID..".xml"),"a")
1685
1686 local data = elements[type_][ID]
1687
1688 handle.writeLine("<"..type_..">")
1689
1690 for name,data2 in pairs(elementProperties[type_]) do
1691 if data2["input"]=="number" or data2["input"]=="string" or data2["input"]=="decimal" or data2["input"]=="color" or string.sub(data2["input"],1,3)=="DDM" then
1692 saveProp(handle,name,data)
1693 end
1694 if data2["input"]=="colorsArray" or data2["input"]=="stringArray" or data2["input"]=="picArray" then
1695 saveArray(handle,name,data)
1696 end
1697 if data2["input"]=="navMenuArray" then
1698 saveNavMenu(handle,name,data)
1699 end
1700 if data2["input"]=="CSTable" then
1701 saveCSTable(handle,name,data)
1702 end
1703 if data2["input"]=="CSDesignsTable" then
1704 saveCSDesignsTable(handle,name,data)
1705 end
1706 end
1707
1708 handle.writeLine("</"..type_..">")
1709 handle.close()
1710 writeToLog("Done saving "..type_.." "..ID..".",2)
1711 success = true
1712 else
1713 writeToLog("Could not save "..type_.." "..ID.." because it was not found.",3)
1714 end
1715 return success
1716end
1717
1718function loadElement(ID,type_)
1719 local success = false
1720 if fs.exists(fs.combine(root,"EasyGUI/"..type_.."/"..ID..".xml")) then
1721 local handle = fs.open(fs.combine(root,"EasyGUI/"..type_.."/"..ID..".xml"),"r")
1722 local temp = {}
1723 local line = handle.readLine()
1724 while line~=nil do
1725 for name,data2 in pairs(elementProperties[type_]) do
1726 if data2["input"]=="number" or data2["input"]=="decimal" or data2["input"]=="color" then
1727 readPropNumber(line,name,temp)
1728 end
1729 if data2["input"]=="string" or string.sub(data2["input"],1,3)=="DDM" then
1730 readPropString(line,name,temp)
1731 end
1732 if data2["input"]=="stringArray" or data2["input"]=="picArray" then
1733 readStringArray(line,name,temp,handle)
1734 end
1735 if data2["input"]=="colorsArray" then
1736 readNumberArray(line,name,temp,handle)
1737 end
1738 if data2["input"]=="navMenuArray" then
1739 readNavMenu(line,name,temp,handle)
1740 end
1741 if data2["input"]=="CSTable" then
1742 readCSTable(line,name,temp,handle)
1743 end
1744 if data2["input"]=="CSDesignsTable" then
1745 readCSDesignsTable(line,name,temp,handle)
1746 end
1747 end
1748
1749 line = handle.readLine()
1750 end
1751 local valid = true
1752 for name,data2 in pairs(elementProperties[type_]) do
1753 if data2["essential"] then
1754 if temp[name]==nil then
1755 valid = false
1756 break
1757 end
1758 end
1759 end
1760 if valid then
1761 temp["visible"] = true
1762 temp["enabled"] = true
1763 temp["expanded"] = false
1764 elements[type_][ID] = temp
1765 trackID(ID)
1766 writeToLog("Succesfully loaded "..type_.." "..ID..".",2)
1767 success = true
1768 else
1769 writeToLog("Information for "..type_.." "..ID.." is faulty. Did someone mess around with the xml?",4)
1770 end
1771 handle.close()
1772 else
1773 writeToLog("Could not load "..type_.." "..ID.." because the file was not found.",3)
1774 end
1775 return success
1776end
1777
1778--screens and pixel matrices from here
1779--this functions adds a screen
1780function addScreen(id,sizeX,sizeY,defaultTextColor,defaultBGColor)
1781 if not (type(sizeX)=="number" and type(sizeY)=="number") then
1782 writeToLog("Invalid size arguments for the new screen.",3)
1783 return false
1784 end
1785 if trackID(id) then
1786 screens[id] = {}
1787 screens[id]["sizeX"] = sizeX
1788 screens[id]["sizeY"] = sizeY
1789 screens[id]["defaultTextColor"] = defaultTextColor
1790 screens[id]["defaultBGColor"] = defaultBGColor
1791 screens[id]["elements"] = {}
1792 screens[id]["pixelMatrix"] = {}
1793 writeToLog("Added screen "..id..".",2)
1794 return true
1795 else
1796 writeToLog("Did not add screen because of ID conflict.",3)
1797 return false
1798 end
1799end
1800
1801--this is an essential function which adds pixels to screen matrices accordingly
1802function writeToPixelMatrix(screenID,s,x,y,textColor,BGColor,elementID,elementType,sPart)
1803 if string.len(s)==1 then
1804 if x<=screens[screenID]["sizeX"] and y<=screens[screenID]["sizeY"] and x>=1 and y>=1 then
1805 writeToLog("Drawing "..sPart.." of "..elementType.." "..elementID..".",1)
1806 screens[screenID]["pixelMatrix"][x..":"..y] = {}
1807 screens[screenID]["pixelMatrix"][x..":"..y]["character"] = s
1808 screens[screenID]["pixelMatrix"][x..":"..y]["textColor"] = textColor
1809 screens[screenID]["pixelMatrix"][x..":"..y]["BGColor"] = BGColor
1810 screens[screenID]["pixelMatrix"][x..":"..y]["elementID"] = elementID
1811 screens[screenID]["pixelMatrix"][x..":"..y]["elementType"] = elementType
1812 screens[screenID]["pixelMatrix"][x..":"..y]["part"] = sPart
1813 else
1814 writeToLog("Part "..sPart.." of "..elementType.." "..elementID.." tried to draw outside of screen "..screenID..".",3)
1815 end
1816 else
1817 for i=1,string.len(s) do
1818 writeToPixelMatrix(screenID,string.sub(s,i,i),x+i-1,y,textColor,BGColor,elementID,elementType,sPart)
1819 end
1820 end
1821end
1822
1823function fullRefresh()
1824 clearTerminal()
1825 clearMonitors()
1826 for name,data in pairs(screens) do
1827 screens[name]["pixelMatrix"] = {}
1828 end
1829 refresh()
1830end
1831
1832--this function adds an element to the screen
1833function addElementToScreen(elementID, screenID, x,y)
1834 if x==nil then
1835 x = 1
1836 end
1837 if y==nil then
1838 y = 1
1839 end
1840 if screens[screenID]~=nil then
1841 local elements = screens[screenID]["elements"]
1842 local element = {}
1843 local exists = false
1844
1845 for i,current in ipairs(elements) do
1846 if current["ID"]==elementID then
1847 exists = true
1848 end
1849 end
1850
1851 if not exists then
1852 if getType(elementID)~=nil then
1853 element["type"] = getType(elementID)
1854 element["ID"] = elementID
1855 element["x"] = x
1856 element["y"] = y
1857
1858 table.insert(elements, element)
1859 screens[screenID]["elements"] = elements
1860 writeToLog("Successfully added element "..elementID.." to screen "..screenID..".",2)
1861 return true
1862 else
1863 writeToLog("Could not add element to the screen. Element was not found or nil.",3)
1864 end
1865 else
1866 writeToLog("Did not add element to the screen because the element is already on that screen.",2)
1867 end
1868 else
1869 writeToLog("Could not add the element to the screen. Screen was not found or nil.",3)
1870 end
1871 return false
1872end
1873
1874function removeElementFromScreen(elementID,screenID)
1875 if screens[screenID]~=nil then
1876 for i,data in ipairs(screens[screenID]["elements"]) do
1877 if data["ID"]==elementID then
1878 table.remove(screens[screenID]["elements"],i)
1879 return true
1880 end
1881 end
1882 else
1883 writeToLog("Could not remove the element from the screen. Screen was not found or nil.",3)
1884 end
1885 return false
1886end
1887
1888function changePos(elementID,screenID,x,y)
1889 if x==nil then
1890 x = 1
1891 end
1892 if y==nil then
1893 y = 1
1894 end
1895 if screens[screenID]~=nil then
1896 local elements = screens[screenID]["elements"]
1897 local found = false
1898
1899 for name,data in pairs(screens[screenID]["elements"]) do
1900 if data["ID"]==elementID then
1901 found = true
1902 data["x"] = x
1903 data["y"] = y
1904 break
1905 end
1906 end
1907
1908 if found then
1909 writeToLog("Successfully changed pos of element "..elementID.." on screen "..screenID..".",2)
1910 return true
1911 else
1912 writeToLog("Could not change pos of element. Element was not found or nil.",3)
1913 end
1914 else
1915 writeToLog("Could not change pos of element. Screen was not found or nil.",3)
1916 end
1917 return false
1918end
1919
1920function getPos(elementID,screenID)
1921 if screens[screenID]~=nil then
1922 local elements = screens[screenID]["elements"]
1923
1924 for name,data in pairs(screens[screenID]["elements"]) do
1925 if data["ID"]==elementID then
1926 return data["x"],data["y"]
1927 end
1928 end
1929 end
1930end
1931
1932--this function updates the pixel matrix of a certain screen
1933function updatePixelMatrix(screenID,str)
1934 writeToLog("Updating pixel matrix of screen "..screenID..".",2)
1935 --write elements to pixel matrix
1936 for i,element in ipairs(screens[screenID]["elements"]) do
1937 if str==nil or (string.len(element["ID"])>31 and str=="ONLYHASH") or (string.len(element["ID"])<32 and str=="ONLYNONHASH") then
1938 if elements[element["type"]][element["ID"]]["visible"] then
1939 writeToLog("Writing "..element["type"].." "..element["ID"].." to pixel matrix.",1)
1940 success,msg = pcall(writeElementToPixelMatrix,screenID,element["ID"],element["x"],element["y"],element["type"])
1941 if success then
1942 writeToLog("Done writing "..element["type"].." "..element["ID"].." to pixel matrix.",1)
1943 else
1944 writeToLog("There was an error writing "..element["type"].." "..element["ID"].." to pixel matrix. Error message: "..msg,4)
1945 end
1946 end
1947 end
1948 end
1949 writeToLog("Done updating pixel matrix.",2)
1950end
1951
1952function writeElementToPixelMatrix(screenID,ID,x,y,type_)
1953 if type_=="dynTextBox" then
1954 writeDynamicTextBoxToPixelMatrix(screenID,ID,x,y)
1955 end
1956 if type_=="slider" then
1957 writeSliderToPixelMatrix(screenID,ID,x,y)
1958 end
1959 if type_=="dropDownMenu" then
1960 writeDropDownMenuToPixelMatrix(screenID,ID,x,y)
1961 end
1962 if type_=="navMenu" then
1963 writeNavigationMenuToPixelMatrix(screenID,ID,x,y)
1964 end
1965 if type_=="colorPicker" then
1966 writeColorPickerToPixelMatrix(screenID,ID,x,y)
1967 end
1968 if type_=="progressBar" then
1969 writeProgressBarToPixelMatrix(screenID,ID,x,y)
1970 end
1971 if type_=="coordsSystem" then
1972 writeCoordinateSystemToPixelMatrix(screenID,ID,x,y)
1973 end
1974 if type_=="picture" then
1975 writePictureToPixelMatrix(screenID,ID,x,y)
1976 end
1977end
1978
1979function setScreenToRenderOnMon(screenID,monID,textScale,offsetX,offsetY)
1980 if offsetX ==nil then
1981 offsetX = 0
1982 end
1983 if offsetY ==nil then
1984 offsetY = 0
1985 end
1986 if monitors[monID]~=nil then
1987 if screens[screenID]~=nil then
1988 clearMonitor(monID)
1989 screens[screenID]["pixelMatrix"] = {}
1990 monitors[monID]["screen"] = screenID
1991 monitors[monID]["offsetX"] = offsetX
1992 monitors[monID]["offsetY"] = offsetY
1993 monitors[monID]["textScale"] = textScale
1994 writeToLog("Set screen "..screenID.." to be rendered on monitor "..monID..".",2)
1995 return true
1996 else
1997 clearMonitor(monID)
1998 monitors[monID]["screen"] = nil
1999 monitors[monID]["offsetX"] = nil
2000 monitors[monID]["offsetY"] = nil
2001 monitors[monID]["textScale"] = nil
2002 writeToLog("Could not set screen to be rendered on monitor. Screen was not found or nil.",3)
2003 end
2004 else
2005 writeToLog("Could not set the screen to be rendered on monitor. Monitor was not found or nil.",3)
2006 end
2007 return false
2008end
2009
2010function setScreenToRenderOnTerminal(screenID)
2011 if screens[screenID]~=nil then
2012 clearTerminal()
2013 screens[screenID]["pixelMatrix"] = {}
2014 terminalScreen = screenID
2015 writeToLog("Set screen "..screenID.." to be rendered on terminal.")
2016 return true
2017 else
2018 terminalScreen = nil
2019 writeToLog("Could not set screen to be rendered on terminal. Screen was not found or nil.")
2020 end
2021 return false
2022end
2023
2024function setRefreshFunction(func)
2025 refreshFunction = func
2026 writeToLog("Changed refresh function.",2)
2027end
2028
2029function setProcessClickEventFunction(func)
2030 processClickEventFunc = func
2031 writeToLog("Changed processClickEvent function.",2)
2032end
2033
2034function setProcessEventFunction(func)
2035 processEventFunc = func
2036 writeToLog("Changed processEvent function.",2)
2037end
2038
2039function drawPixels(x,y,textColor,BGColor,str,monID)
2040 if monID~=nil then
2041 monitors[monID]["peripheral"].setBackgroundColor(BGColor)
2042 monitors[monID]["peripheral"].setTextColor(textColor)
2043 monitors[monID]["peripheral"].setCursorPos(x+monitors[monID]["offsetX"],y+monitors[monID]["offsetY"])
2044 monitors[monID]["peripheral"].write(str)
2045 else
2046 term.setBackgroundColor(BGColor)
2047 term.setTextColor(textColor)
2048 term.setCursorPos(x,y)
2049 term.write(str)
2050 end
2051end
2052
2053function drawOnMonitors(x,y,textColor,BGColor,str,monitorList)
2054 for i,monID in ipairs(monitorList) do
2055 if monID==terminalID then
2056 success,msg = pcall(drawPixels,x,y,textColor,BGColor,str)
2057 else
2058 success,msg = pcall(drawPixels,x,y,textColor,BGColor,str,monID)
2059 end
2060 if success then
2061 writeToLog("Drew "..str.." at "..x..":"..y..".",1)
2062 else
2063 writeToLog("There was an error drawing "..str.." at "..x..":"..y..". Error message: "..msg,4)
2064 end
2065 end
2066end
2067
2068function refresh()
2069 writeToLog("Refreshing all monitors...",2)
2070 local startTime = os.clock()
2071 for screenID,screenData in pairs(screens) do
2072 monitorList = {}
2073 for monID,data in pairs(monitors) do
2074 if screenID==data["screen"] then
2075 table.insert(monitorList,monID)
2076 end
2077 end
2078 if screenID==terminalScreen then
2079 table.insert(monitorList,terminalID)
2080 end
2081 if table.getn(monitorList)~=0 then
2082 --store previous pixels in this array
2083 local previousMatrix = {}
2084 for name,data in pairs(screens[screenID]["pixelMatrix"]) do
2085 previousMatrix[name] = data
2086 end
2087 screens[screenID]["pixelMatrix"] = {}
2088
2089 if designerRefresh then
2090 updatePixelMatrix(screenID,"ONLYNONHASH")
2091 screens[screenID]["sizeX"] = designerX
2092 screens[screenID]["sizeY"] = designerY
2093 updatePixelMatrix(screenID,"ONLYHASH")
2094 else
2095 updatePixelMatrix(screenID)
2096 end
2097
2098 writeToLog("Drawing pixels of screen "..screenID.." on monitors.",2)
2099 --render pixel matrix
2100 for y=1,screens[screenID]["sizeY"] do
2101 --this is a system which is performance optimized
2102 --instead of drawing each pixel separately, it collects all the pixels which use the same colors and writes it as a whole string
2103 local currStr = ""
2104 local currTextColor = nil
2105 local currBGColor = nil
2106 local currX = nil
2107 for x=1,screens[screenID]["sizeX"] do
2108 if screens[screenID]["pixelMatrix"][x..":"..y]~=nil then
2109 --only draw it if something changed about the pixel
2110 --performance
2111 local draw = true
2112 if previousMatrix[x..":"..y]~=nil then
2113 if previousMatrix[x..":"..y]["BGColor"]==screens[screenID]["pixelMatrix"][x..":"..y]["BGColor"] and previousMatrix[x..":"..y]["textColor"]==screens[screenID]["pixelMatrix"][x..":"..y]["textColor"] and previousMatrix[x..":"..y]["character"]==screens[screenID]["pixelMatrix"][x..":"..y]["character"] then
2114 draw = false
2115 end
2116 else
2117 if screens[screenID]["pixelMatrix"][x..":"..y]["BGColor"]==screens[screenID]["defaultBGColor"] and screens[screenID]["pixelMatrix"][x..":"..y]["character"]==" " then
2118 draw = false
2119 end
2120 end
2121 if draw then
2122 if currTextColor==screens[screenID]["pixelMatrix"][x..":"..y]["textColor"] and currBGColor==screens[screenID]["pixelMatrix"][x..":"..y]["BGColor"] then
2123 currStr = currStr ..screens[screenID]["pixelMatrix"][x..":"..y]["character"]
2124 else
2125 if currStr~="" and currStr~=nil then
2126 drawOnMonitors(currX,y,currTextColor,currBGColor,currStr,monitorList)
2127 end
2128 currStr = screens[screenID]["pixelMatrix"][x..":"..y]["character"]
2129 currTextColor = screens[screenID]["pixelMatrix"][x..":"..y]["textColor"]
2130 currBGColor = screens[screenID]["pixelMatrix"][x..":"..y]["BGColor"]
2131 currX = x
2132 end
2133 else
2134 if currStr~="" and currStr~=nil then
2135 drawOnMonitors(currX,y,currTextColor,currBGColor,currStr,monitorList)
2136 end
2137 currStr = ""
2138 currTextColor = nil
2139 currBGColor = nil
2140 currX = nil
2141 end
2142 previousMatrix[x..":"..y] = nil
2143 else
2144 if currStr~="" and currStr~=nil then
2145 drawOnMonitors(currX,y,currTextColor,currBGColor,currStr,monitorList)
2146 end
2147 currStr = ""
2148 currTextColor = nil
2149 currBGColor = nil
2150 currX = nil
2151 end
2152 end
2153 if currStr~="" and currStr~=nil then
2154 drawOnMonitors(currX,y,currTextColor,currBGColor,currStr,monitorList)
2155 end
2156 end
2157 writeToLog("Done drawing pixels of screen "..screenID.. " on monitors.",2)
2158
2159 --clean up using backup array. this procedure is necessary because clearing the monitor all the time (manually or with mon.clear()) creates too much lag with big screens
2160 --this is a clever way to increase performance
2161 writeToLog("Cleaning up monitors. (screen "..screenID..")",2)
2162 for y=1,screens[screenID]["sizeY"] do
2163 local str = ""
2164 local currX = nil
2165 for x=1,screens[screenID]["sizeX"] do
2166 if previousMatrix[x..":"..y]~=nil then
2167 if currX==nil then
2168 currX = x
2169 end
2170 str = str .." "
2171 else
2172 if str~="" then
2173 drawOnMonitors(currX,y,screens[screenID]["defaultTextColor"],screens[screenID]["defaultBGColor"],str,monitorList)
2174 end
2175 str = ""
2176 currX = nil
2177 end
2178 end
2179 if str~="" then
2180 drawOnMonitors(currX,y,screens[screenID]["defaultTextColor"],screens[screenID]["defaultBGColor"],str,monitorList)
2181 end
2182 end
2183 writeToLog("Done cleaning up monitors. (screen "..screenID..")",2)
2184
2185 if designerRefresh then
2186 screens[screenID]["sizeX"] = designerSmaxX
2187 screens[screenID]["sizeY"] = designerSmaxY
2188 end
2189 end
2190 end
2191 writeToLog("Done refreshing all monitors. Took "..(os.clock()-startTime).."seconds.",2)
2192end
2193
2194function clearMonitor(monID)
2195 local data = monitors[monID]
2196 if data["screen"]~=nil then
2197 local screenID = data["screen"]
2198 local offsetX = data["offsetX"]
2199 local offsetY = data["offsetY"]
2200 local textScale = data["textScale"]
2201 screens[screenID]["pixelMatrix"] = {}
2202 --check sizes
2203 monitors[monID]["peripheral"].setBackgroundColor(colors.black)
2204 monitors[monID]["peripheral"].clear()
2205 monX,monY = monitors[monID]["peripheral"].getSize()
2206 monitors[monID]["peripheral"].setTextScale(textScale)
2207 if (screens[screenID]["sizeX"] + offsetX)>monX or (screens[screenID]["sizeY"] + offsetY)>monY then
2208 writeToLog("Screen "..screenID.." cannot be displayed completely with given offset and textScale.",3)
2209 end
2210 monitors[monID]["peripheral"].setBackgroundColor(screens[screenID]["defaultBGColor"])
2211 --custom clear
2212 writeToLog("Clearing monitor "..monID.."...",1)
2213 local s = ""
2214 for i=1,screens[screenID]["sizeX"] do
2215 s = s.." "
2216 end
2217 for i=1,screens[screenID]["sizeY"] do
2218 monitors[monID]["peripheral"].setCursorPos(offsetX+1,offsetY+i)
2219 monitors[monID]["peripheral"].write(s)
2220 end
2221 writeToLog("Done clearing monitor "..monID..".",2)
2222 end
2223end
2224
2225function clearMonitors()
2226 for monID,data in pairs(monitors) do
2227 clearMonitor(monID)
2228 end
2229end
2230
2231function clearTerminal()
2232 if terminalScreen~=nil then
2233 local screenID = terminalScreen
2234 screens[screenID]["pixelMatrix"] = {}
2235 --check sizes
2236 sizeX,sizeY = term.getSize()
2237 if (screens[screenID]["sizeX"])>sizeX or (screens[screenID]["sizeY"])>sizeY then
2238 writeToLog("Screen "..screenID.." cannot be displayed completely on terminal.",3)
2239 end
2240 term.setBackgroundColor(colors.black)
2241 term.clear()
2242 term.setBackgroundColor(screens[screenID]["defaultBGColor"])
2243 --custom clear
2244 writeToLog("Clearing terminal.",1)
2245 local s = ""
2246 for i=1,screens[screenID]["sizeX"] do
2247 s = s.." "
2248 end
2249 for i=1,screens[screenID]["sizeY"] do
2250 term.setCursorPos(1,i)
2251 term.write(s)
2252 end
2253 writeToLog("Done clearing terminal.",2)
2254 end
2255end
2256
2257function run(nRefreshRate)
2258 writeToLog("Starting program, clearing all monitors...")
2259 clearMonitors()
2260 clearTerminal()
2261 writeToLog("Done clearing all monitors.")
2262
2263 refresh()
2264 if nRefreshRate~=nil then
2265 refreshRate = nRefreshRate
2266 refreshTimerID = os.startTimer(refreshRate)
2267 writeToLog("Starting refresh timer with refreshRate "..refreshRate.." seconds.",1)
2268 end
2269 local running = true
2270 while running do
2271 event,var1,var2,var3,var4,var5 = os.pullEventRaw()
2272 writeToLog("Caught "..event.." event.",2)
2273 if event=="timer" then
2274 processTimerEvent(var1)
2275 end
2276 if event=="monitor_resize" then
2277 fullRefresh()
2278 end
2279 if event=="mouse_click" then
2280 if var1==1 then
2281 processClickEvent(terminalID,var2,var3)
2282 end
2283 end
2284 if event=="monitor_touch" then
2285 processClickEvent(var1,var2,var3)
2286 end
2287 if event=="mouse_drag" then
2288 processDragEvent(var2,var3)
2289 end
2290 if event=="mouse_scroll" then
2291 processScrollEvent(var1,var2,var3)
2292 end
2293 if shell~=nil then
2294 if event=="key" then
2295 if var1==59 then
2296 F1Held = true
2297 end
2298 end
2299 if event=="key_up" then
2300 if var1==59 then
2301 F1Held = false
2302 end
2303 end
2304 if event=="key" then
2305 if var1==29 then
2306 CTRLHeld = true
2307 end
2308 end
2309 if event=="key_up" then
2310 if var1==29 then
2311 CTRLHeld = false
2312 end
2313 end
2314 end
2315 if event=="terminate" then
2316 writeToLog("User terminated. Exiting.",2)
2317 logFile.writeLine("")
2318 logFile.flush()
2319 for sMonitor,data in pairs(monitors) do
2320 data["peripheral"].setBackgroundColor(colors.black)
2321 data["peripheral"].clear()
2322 end
2323 term.setBackgroundColor(colors.black)
2324 term.setTextColor(colors.white)
2325 term.clear()
2326 term.setCursorPos(1,1)
2327 running = false
2328 end
2329 if event=="easygui_interrupt" then
2330 running = false
2331 end
2332 if processEventFunc~=nil then
2333 success,msg = pcall(processEventFunc,event,var1,var2,var3,var4,var5)
2334 if success then
2335 writeToLog("Successfully called processEventFunc.",2)
2336 else
2337 writeToLog("There was an error calling processEventFunc. Msg: "..msg)
2338 end
2339 end
2340 end
2341end
2342
2343function processScrollEvent(direction,x,y)
2344 if terminalScreen~=nil then
2345 local s = x..":"..y
2346 local screenID = terminalScreen
2347
2348 local data = screens[screenID]["pixelMatrix"][s]
2349 if data~=nil then
2350 local elementType = data["elementType"]
2351 local ID = data["elementID"]
2352 local part = data["part"]
2353
2354 if elementType=="dropDownMenu" and dropDownMenus[ID]["enabled"] and (part=="expandButton" or part=="BG" or part=="text") and not dropDownMenus[ID]["expanded"] then
2355 if direction==-1 then
2356 if dropDownMenus[ID]["selectionID"]~=1 then
2357 writeToLog("Changed selectionID of dropDownMenu "..ID.." because of scroll event.",2)
2358 dropDownMenus[ID]["selectionID"] = dropDownMenus[ID]["selectionID"]-1
2359 if dropDownMenus[ID]["onChangeFunction"]~=nil then
2360 success,msg = pcall(dropDownMenus[ID]["onChangeFunction"],ID,dropDownMenus[ID]["selectionID"])
2361 if success then
2362 writeToLog("Successfully called onChangeFunction of dropDownMenu "..ID..".",1)
2363 else
2364 writeToLog("There was an error calling onChangeFunction of dropDownMenu "..ID..". Error message: "..msg,4)
2365 end
2366 end
2367 refresh()
2368 end
2369 else
2370 if dropDownMenus[ID]["selectionID"]~=table.getn(dropDownMenus[ID]["entries"]) then
2371 writeToLog("Changed selectionID of dropDownMenu "..ID.." because of scroll event.",2)
2372 dropDownMenus[ID]["selectionID"] = dropDownMenus[ID]["selectionID"]+1
2373 if dropDownMenus[ID]["onChangeFunction"]~=nil then
2374 success,msg = pcall(dropDownMenus[ID]["onChangeFunction"],ID,dropDownMenus[ID]["selectionID"])
2375 if success then
2376 writeToLog("Successfully called onChangeFunction of dropDownMenu "..ID..".",1)
2377 else
2378 writeToLog("There was an error calling onChangeFunction of dropDownMenu "..ID..". Error message: "..msg,4)
2379 end
2380 end
2381 refresh()
2382 end
2383 end
2384 end
2385
2386 if elementType=="dropDownMenu" and dropDownMenus[ID]["enabled"] and dropDownMenus[ID]["expanded"] and (string.match(part,"entry") or string.match(part,"scroll")) then
2387 if dropDownMenus[ID]["scrollPositionIndex"]~=nil then
2388 if direction==-1 then
2389 if dropDownMenus[ID]["scrollPositionIndex"]~=1 then
2390 writeToLog("Scrolled up dropDownMenu "..ID.." because of scroll event.",2)
2391 dropDownMenus[ID]["scrollPositionIndex"] = dropDownMenus[ID]["scrollPositionIndex"]-1
2392 refresh()
2393 end
2394 else
2395 if dropDownMenus[ID]["scrollPositionIndex"]~=table.getn(dropDownMenus[ID]["entries"])-dropDownMenus[ID]["spaceY"]+1 then
2396 writeToLog("Scrolled down dropDownMenu "..ID.." because of scroll event.",2)
2397 dropDownMenus[ID]["scrollPositionIndex"] = dropDownMenus[ID]["scrollPositionIndex"]+1
2398 refresh()
2399 end
2400 end
2401 end
2402 end
2403
2404 if elementType=="slider" and sliders[ID]["enabled"] and string.match(part,"bar") then
2405 if direction==1 then
2406 if sliders[ID]["value"]~=sliders[ID]["length"] then
2407 sliders[ID]["value"] = sliders[ID]["value"] + 1
2408 writeToLog("Incremented value of slider "..ID.." because of scroll event.",2)
2409 if sliders[ID]["onChangeFunction"]~=nil then
2410 success,msg = pcall(sliders[ID]["onChangeFunction"],ID,sliders[ID]["value"])
2411 if success then
2412 writeToLog("Succesfully called onChangeFunction of slider "..ID..".",1)
2413 else
2414 writeToLog("There was an error calling the onChangeFunction of slider "..ID..". Error message: "..msg,4)
2415 end
2416 end
2417 refresh()
2418 end
2419 else
2420 if sliders[ID]["value"]~=1 then
2421 sliders[ID]["value"] = sliders[ID]["value"] - 1
2422 writeToLog("Decremented value of slider "..ID.." because of scroll event.",2)
2423 if sliders[ID]["onChangeFunction"]~=nil then
2424 success,msg = pcall(sliders[ID]["onChangeFunction"],ID,sliders[ID]["value"])
2425 if success then
2426 writeToLog("Succesfully called onChangeFunction of slider "..ID..".",1)
2427 else
2428 writeToLog("There was an error calling the onChangeFunction of slider "..ID..". Error message: "..msg,4)
2429 end
2430 end
2431 refresh()
2432 end
2433 end
2434 end
2435 end
2436 end
2437end
2438
2439function processDragEvent(x,y)
2440 if terminalScreen~=nil then
2441 local s = x..":"..y
2442 local screenID = terminalScreen
2443
2444 local data = screens[screenID]["pixelMatrix"][s]
2445 if data~=nil then
2446 local elementType = data["elementType"]
2447 local ID = data["elementID"]
2448 local part = data["part"]
2449
2450 if elementType=="slider" and sliders[ID]["enabled"] and string.match(part,"bar") then
2451 processClickEvent(terminalID,x,y)
2452 end
2453 end
2454 end
2455end
2456
2457function processTimerEvent(timerID)
2458 writeToLog("Processing timerEvent with ID "..timerID.."...",2)
2459 if timerID==refreshTimerID then
2460 if refreshFunction~=nil then
2461 success,msg = pcall(refreshFunction)
2462 if success then
2463 writeToLog("Successfully called refresh function.",1)
2464 else
2465 writeToLog("There was an error calling the refresh function. Error message: "..msg,4)
2466 end
2467 end
2468 refresh()
2469 writeToLog("Restarting refresh timer.",2)
2470 refreshTimerID = os.startTimer(refreshRate)
2471 end
2472
2473 for name,data in pairs(dynamicTextBoxes) do
2474 if data["timerID"]==timerID then
2475 writeToLog("Processing timer of dynamicTextBox "..name..".",1)
2476 dynamicTextBoxes[name]["active"] = false
2477 dynamicTextBoxes[name]["timerID"] = nil
2478 if dynamicTextBoxes[name]["onInactiveFunction"]~=nil then
2479 success,msg = pcall(dynamicTextBoxes[name]["onInactiveFunction"],name,dynamicTextBoxes[name]["active"])
2480 if success then
2481 writeToLog("Successfully called onInactiveFunction of dynamicTextBox "..name..".",1)
2482 else
2483 writeToLog("There was an error calling the onInactiveFunction of dynamicTextBox "..name..". Error message: "..msg,4)
2484 end
2485 end
2486 refresh()
2487 end
2488 end
2489
2490 writeToLog("Done processing timerEvent with ID "..timerID..".",2)
2491end
2492
2493function processClickEvent(monitorName,x,y)
2494 writeToLog("Processing click event.",2)
2495 local monID
2496 for name,data in pairs(monitors) do
2497 if monitorName==data["networkID"] then
2498 monID = name
2499 break
2500 end
2501 if monitorName==data["side"] and data["networkID"]=="NONE" then
2502 monID = name
2503 break
2504 end
2505 end
2506 if (monitorName==terminalID and terminalScreen~=nil) or (monitors[monID]~=nil and monitors[monID]["screen"]~=nil) then
2507 local s = nil
2508 local screenID = nil
2509 if monitorName==terminalID then
2510 s = x..":"..y
2511 screenID = terminalScreen
2512 else
2513 s = x-monitors[monID]["offsetX"]..":"..y-monitors[monID]["offsetY"]
2514 screenID = monitors[monID]["screen"]
2515 end
2516
2517 local data = screens[screenID]["pixelMatrix"][s]
2518 if data~=nil then
2519 local elementType = data["elementType"]
2520 local ID = data["elementID"]
2521 local part = data["part"]
2522
2523 if shell~=nil and F1Held then
2524 if help[ID]~=nil then
2525 changeProperty(helpSBorderID,"content",help[ID])
2526 setScreenToRenderOnTerminal(helpSID)
2527 fullRefresh()
2528 end
2529 else
2530 --button
2531 if elementType=="dynamicTextBox" and dynamicTextBoxes[ID]["enabled"] and dynamicTextBoxes[ID]["onClickMode"]=="toggle" then
2532 dynamicTextBoxes[ID]["active"] = not dynamicTextBoxes[ID]["active"]
2533 writeToLog("Changed status of dynamicTextBox "..ID.."because of click event.",2)
2534 if dynamicTextBoxes[ID]["active"] then
2535 if dynamicTextBoxes[ID]["onActiveFunction"]~=nil then
2536 success,msg = pcall(dynamicTextBoxes[ID]["onActiveFunction"],ID,dynamicTextBoxes[ID]["active"])
2537 if success then
2538 writeToLog("Successfully called onActiveFunction of dynamicTextBox "..ID..".",1)
2539 else
2540 writeToLog("There was an error calling the onActiveFunction of dynamicTextBox "..ID..". Error message: "..msg,4)
2541 end
2542 end
2543 end
2544 if not dynamicTextBoxes[ID]["active"] then
2545 if dynamicTextBoxes[ID]["onInactiveFunction"]~=nil then
2546 success,msg = pcall(dynamicTextBoxes[ID]["onInactiveFunction"],ID,dynamicTextBoxes[ID]["active"])
2547 if success then
2548 writeToLog("Successfully called onInactiveFunction of dynamicTextBox "..ID..".",1)
2549 else
2550 writeToLog("There was an error calling the onInactiveFunction of dynamicTextBox "..ID..". Error message: "..msg,4)
2551 end
2552 end
2553 end
2554 refresh()
2555 end
2556 if elementType=="dynamicTextBox" and dynamicTextBoxes[ID]["enabled"] and dynamicTextBoxes[ID]["onClickMode"]=="flash" and not dynamicTextBoxes[ID]["active"] then
2557 dynamicTextBoxes[ID]["active"] = true
2558 writeToLog("Changed status of dynamicTextBox "..ID.."because of click event.",2)
2559 if dynamicTextBoxes[ID]["onActiveFunction"]~=nil then
2560 success,msg = pcall(dynamicTextBoxes[ID]["onActiveFunction"],ID,dynamicTextBoxes[ID]["active"])
2561 if success then
2562 writeToLog("Successfully called onActiveFunction of dynamicTextBox "..ID..".",1)
2563 else
2564 writeToLog("There was an error calling the onActiveFunction of dynamicTextBox "..ID..". Error message: "..msg,4)
2565 end
2566 end
2567 refresh()
2568 if dynamicTextBoxes[ID]["activeDuration"]~=nil then
2569 writeToLog("Starting timer of dynamicTextBox "..ID..".",1)
2570 dynamicTextBoxes[ID]["timerID"] = os.startTimer(dynamicTextBoxes[ID]["activeDuration"])
2571 else
2572 writeToLog("Even though mode of dynamicTextBox "..ID.." is 'flash', activeDuration is not defined!",2)
2573 dynamicTextBoxes[ID]["timerID"] = os.startTimer(0)
2574 end
2575 end
2576
2577 --slider
2578 if elementType=="slider" and sliders[ID]["enabled"] then
2579 if part=="incrementButton" then
2580 if sliders[ID]["value"]~=sliders[ID]["length"] then
2581 sliders[ID]["value"] = sliders[ID]["value"] + 1
2582 writeToLog("Incremented value of slider "..ID.." because of click event.",2)
2583 if sliders[ID]["onChangeFunction"]~=nil then
2584 success,msg = pcall(sliders[ID]["onChangeFunction"],ID,sliders[ID]["value"])
2585 if success then
2586 writeToLog("Succesfully called onChangeFunction of slider "..ID..".",1)
2587 else
2588 writeToLog("There was an error calling the onChangeFunction of slider "..ID..". Error message: "..msg,4)
2589 end
2590 end
2591 refresh()
2592 end
2593 end
2594 if part=="decrementButton" then
2595 if sliders[ID]["value"]~=1 then
2596 sliders[ID]["value"] = sliders[ID]["value"] - 1
2597 writeToLog("Decremented value of slider "..ID.." because of click event.",2)
2598 if sliders[ID]["onChangeFunction"]~=nil then
2599 success,msg = pcall(sliders[ID]["onChangeFunction"],ID,sliders[ID]["value"])
2600 if success then
2601 writeToLog("Succesfully called onChangeFunction of slider "..ID..".",1)
2602 else
2603 writeToLog("There was an error calling the onChangeFunction of slider "..ID..". Error message: "..msg,4)
2604 end
2605 end
2606 refresh()
2607 end
2608 end
2609 if string.match(part,"bar") then
2610 local index = tonumber(string.sub(part,5))
2611 if index~=sliders[ID]["value"] then
2612 sliders[ID]["value"] = index
2613 writeToLog("Changed value of slider "..ID.." because of click event.",2)
2614 if sliders[ID]["onChangeFunction"]~=nil then
2615 success,msg = pcall(sliders[ID]["onChangeFunction"],ID,sliders[ID]["value"])
2616 if success then
2617 writeToLog("Succesfully called onChangeFunction of slider "..ID..".",1)
2618 else
2619 writeToLog("There was an error calling the onChangeFunction of slider "..ID..". Error message: "..msg,4)
2620 end
2621 end
2622 refresh()
2623 end
2624 end
2625 end
2626
2627 --dropdownmenus
2628 if elementType=="dropDownMenu" and dropDownMenus[ID]["enabled"] then
2629 if part=="collapseButton" then
2630 dropDownMenus[ID]["expanded"] = false
2631 dropDownMenus[ID]["scrollPositionIndex"] = nil
2632 dropDownMenus[ID]["highlightID"] = nil
2633 writeToLog("Collapsed dropDownMenu "..ID.." because of click event.",2)
2634 if dropDownMenus[ID]["onCollapseFunction"]~=nil then
2635 success,msg = pcall(dropDownMenus[ID]["onCollapseFunction"],ID,dropDownMenus[ID]["expanded"])
2636 if success then
2637 writeToLog("Successfully called onCollapseFunction of dropDownMenu "..ID..".",1)
2638 else
2639 writeToLog("There was an error calling the onCollapseFunction of dropDownMenu "..ID..". Error message: "..msg,4)
2640 end
2641 end
2642 refresh()
2643 end
2644 if (part=="expandButton" or part=="BG" or part=="text") and not dropDownMenus[ID]["expanded"] then
2645 dropDownMenus[ID]["expanded"] = true
2646 writeToLog("Expanded dropDownMenu "..ID.." because of click event.",2)
2647 if dropDownMenus[ID]["onExpandFunction"]~=nil then
2648 success,msg = pcall(dropDownMenus[ID]["onExpandFunction"],ID,dropDownMenus[ID]["expanded"])
2649 if success then
2650 writeToLog("Successfully called onExpandFunction of dropDownMenu "..ID..".",1)
2651 else
2652 writeToLog("There was an error calling the onExpandFunction of dropDownMenu "..ID..". Error message: "..msg,4)
2653 end
2654 end
2655 refresh()
2656 end
2657 if part=="scrollUpButton" then
2658 if dropDownMenus[ID]["scrollPositionIndex"]~=1 then
2659 writeToLog("Scrolled up dropDownMenu "..ID.." because of click event.",2)
2660 dropDownMenus[ID]["scrollPositionIndex"] = dropDownMenus[ID]["scrollPositionIndex"]-1
2661 refresh()
2662 end
2663 end
2664 if part=="scrollDownButton" then
2665 if dropDownMenus[ID]["scrollPositionIndex"]~=table.getn(dropDownMenus[ID]["entries"])-dropDownMenus[ID]["spaceY"]+1 then
2666 writeToLog("Scrolled down dropDownMenu "..ID.." because of click event.",2)
2667 dropDownMenus[ID]["scrollPositionIndex"] = dropDownMenus[ID]["scrollPositionIndex"]+1
2668 refresh()
2669 end
2670 end
2671 if string.match(part,"entry") then
2672 local index = tonumber(string.sub(part,7))
2673 if index==dropDownMenus[ID]["highlightID"] then
2674 dropDownMenus[ID]["selectionID"] = index
2675 dropDownMenus[ID]["highlightID"] = nil
2676 dropDownMenus[ID]["scrollPositionIndex"] = nil
2677 writeToLog("Changed selectionID of dropDownMenu "..ID.." because of click event.",2)
2678 dropDownMenus[ID]["expanded"] = false
2679 writeToLog("Collapsed dropDownMenu "..ID.." because of selection.",2)
2680 if dropDownMenus[ID]["onChangeFunction"]~=nil then
2681 success,msg = pcall(dropDownMenus[ID]["onChangeFunction"],ID,dropDownMenus[ID]["selectionID"])
2682 if success then
2683 writeToLog("Successfully called onChangeFunction of dropDownMenu "..ID..".",1)
2684 else
2685 writeToLog("There was an error calling onChangeFunction of dropDownMenu "..ID..". Error message: "..msg,4)
2686 end
2687 end
2688
2689 if dropDownMenus[ID]["onCollapseFunction"]~=nil then
2690 success,msg = pcall(dropDownMenus[ID]["onCollapseFunction"],ID,dropDownMenus[ID]["expanded"])
2691 if success then
2692 writeToLog("Successfully called onCollapseFunction of dropDownMenu "..ID..".",1)
2693 else
2694 writeToLog("There was an error calling the onCollapseFunction of dropDownMenu "..ID..". Error message: "..msg,4)
2695 end
2696 end
2697 refresh()
2698 else
2699 if dropDownMenus[ID]["highlightID"]~=index then
2700 dropDownMenus[ID]["highlightID"] = index
2701 writeToLog("Changed highlightID of dropDownMenu "..ID.." because of click event.",2)
2702 refresh()
2703 end
2704 end
2705 end
2706 end
2707
2708 --navMenus
2709 if elementType=="navigationMenu" and navigationMenus[ID]["enabled"] then
2710 if string.match(part,"title") then
2711 navigationMenus[ID]["expanded"] = not navigationMenus[ID]["expanded"]
2712 navigationMenus[ID]["highlightIDs"] = nil
2713 writeToLog("Expanded navMenu "..ID.." because of click event.",2)
2714 refresh()
2715 end
2716 if string.match(part,"entry") then
2717 local s = string.sub(part,7)
2718 local level = string.sub(s,1,string.find(s,":")-1)
2719 local entry = string.sub(s,string.find(s,":")+1)
2720 if tonumber(level)==1 then
2721 if navigationMenus[ID]["menuArray"][tonumber(entry)]["submenu"]~=nil then
2722 navigationMenus[ID]["highlightIDs"] = {tonumber(entry)}
2723 local i = 1
2724 while navigationMenus[ID]["highlightIDs"][tonumber(level)+i]~=nil do
2725 navigationMenus[ID]["highlightIDs"][tonumber(level)+i] = nil
2726 i = i + 1
2727 end
2728 writeToLog("Opened submenu on level 2 for navMenu "..ID..".",2)
2729 else
2730 navigationMenus[ID]["expanded"] = not navigationMenus[ID]["expanded"]
2731 writeToLog("Collapsed navMenu "..ID.." because of click event.",2)
2732 navigationMenus[ID]["highlightIDs"] = {tonumber(entry)}
2733 if navigationMenus[ID]["onChangeFunction"]~=nil then
2734 success,msg = pcall(navigationMenus[ID]["onChangeFunction"],ID,navigationMenus[ID]["highlightIDs"])
2735 if success then
2736 writeToLog("Successfully called onChangeFunction of navMenu "..ID..".",1)
2737 else
2738 writeToLog("There was an error calling onChangeFunction of navMenu "..ID..". Error message: "..msg,4)
2739 end
2740 end
2741 navigationMenus[ID]["highlightIDs"] = nil
2742 end
2743 else
2744 array = navigationMenus[ID]["menuArray"]
2745
2746 for i=1,tonumber(level)-1 do
2747 array = array[navigationMenus[ID]["highlightIDs"][i]]["submenu"]
2748 end
2749
2750 if array[tonumber(entry)]["submenu"]~=nil then
2751 navigationMenus[ID]["highlightIDs"][tonumber(level)] = tonumber(entry)
2752 local i = 1
2753 while navigationMenus[ID]["highlightIDs"][tonumber(level)+i]~=nil do
2754 navigationMenus[ID]["highlightIDs"][tonumber(level)+i] = nil
2755 i = i + 1
2756 end
2757 writeToLog("Opened submenu on level "..(tonumber(level)+1).." for navMenu "..ID..".",2)
2758 else
2759 navigationMenus[ID]["expanded"] = not navigationMenus[ID]["expanded"]
2760 writeToLog("Collapsed navMenu "..ID.." because of click event.",2)
2761 navigationMenus[ID]["highlightIDs"][tonumber(level)] = tonumber(entry)
2762 if navigationMenus[ID]["onChangeFunction"]~=nil then
2763 success,msg = pcall(navigationMenus[ID]["onChangeFunction"],ID,navigationMenus[ID]["highlightIDs"])
2764 if success then
2765 writeToLog("Successfully called onChangeFunction of navMenu "..ID..".",1)
2766 else
2767 writeToLog("There was an error calling onChangeFunction of navMenu "..ID..". Error message: "..msg,4)
2768 end
2769 end
2770 navigationMenus[ID]["highlightIDs"] = nil
2771 end
2772 end
2773 refresh()
2774 end
2775 end
2776
2777 --colorpicker
2778 if elementType=="colorPicker" and colorPickers[ID]["enabled"] then
2779 if part~="border" then
2780 if colorPickers[ID]["selection"]~=part then
2781 colorPickers[ID]["selection"] = part
2782 writeToLog("Changed selection of colorPicker "..ID.." because of clickEvent.",2)
2783 refresh()
2784 if colorPickers[ID]["onChangeFunction"]~=nil then
2785 success,msg = pcall(colorPickers[ID]["onChangeFunction"],ID,colorPickers[ID]["selection"])
2786 if success then
2787 writeToLog("Successfully called onChangeFunction of colorPicker "..ID..".",1)
2788 else
2789 writeToLog("There was an error calling onChangeFunction of colorPicker "..ID..". Error message: "..msg,4)
2790 end
2791 end
2792 end
2793 end
2794 end
2795
2796 if processClickEventFunc~=nil then
2797 success,msg = pcall(processClickEventFunc,elementType,ID,part)
2798 if success then
2799 writeToLog("Successfully called processClickEventFunction.",1)
2800 else
2801 writeToLog("There was an error calling the processClickEventFunction. Error message: "..msg,4)
2802 end
2803 end
2804 end
2805 end
2806 end
2807 writeToLog("Done processing click event.",2)
2808end
2809
2810--function to change any property from any element
2811function changeProperty(ID, propName, propValue)
2812 if elements[getType(ID)]~=nil then
2813 if elements[getType(ID)][ID]~=nil then
2814 elements[getType(ID)][ID][propName] = propValue
2815 writeToLog("Changed property of element "..ID..".",2)
2816 return true
2817 else
2818 writeToLog("Could not change property of element "..ID..". Element was not found. ",3)
2819 end
2820 end
2821 return false
2822end
2823
2824--function to get any property from any element
2825function getProperty(ID, propName)
2826 if elements[getType(ID)]~=nil then
2827 if elements[getType(ID)][ID]~=nil then
2828 return elements[getType(ID)][ID][propName]
2829 end
2830 end
2831end
2832
2833function getType(elementID)
2834 for name,data in pairs(dynamicTextBoxes) do
2835 if elementID==name then
2836 return "dynTextBox"
2837 end
2838 end
2839
2840 for name,data in pairs(sliders) do
2841 if elementID==name then
2842 return "slider"
2843 end
2844 end
2845
2846 for name,data in pairs(dropDownMenus) do
2847 if elementID==name then
2848 return "dropDownMenu"
2849 end
2850 end
2851
2852 for name,data in pairs(navigationMenus) do
2853 if elementID==name then
2854 return "navMenu"
2855 end
2856 end
2857
2858 for name,data in pairs(colorPickers) do
2859 if elementID==name then
2860 return "colorPicker"
2861 end
2862 end
2863
2864 for name,data in pairs(progressBars) do
2865 if elementID==name then
2866 return "progressBar"
2867 end
2868 end
2869
2870 for name,data in pairs(coordinateSystems) do
2871 if elementID==name then
2872 return "coordsSystem"
2873 end
2874 end
2875
2876 for name,data in pairs(pictures) do
2877 if elementID==name then
2878 return "picture"
2879 end
2880 end
2881
2882 for name,data in pairs(screens) do
2883 if elementID==name then
2884 return "screen"
2885 end
2886 end
2887
2888 for name,data in pairs(monitors) do
2889 if elementID==name then
2890 return "monitor"
2891 end
2892 end
2893 return "NOTFOUND"
2894end
2895
2896--DynamicTextBoxes from here
2897--DynamicTextBoxes all properties: width, height, content, variables, textColor, textAlignmentHorizontal, textAlignmentVertical, BGColor, borderColor, onActiveFunction, onInactiveFunction, onClickMode, activeDuration, activeContent, activeTextColor, activeBGColor, activeBorderColor, borderThickness, active, timerID, visible, enabled
2898function addDynamicTextBox(id, content)
2899 if trackID(id) then
2900 dynamicTextBoxes[id] = {}
2901 dynamicTextBoxes[id]["content"] = content
2902 dynamicTextBoxes[id]["visible"] = true
2903 dynamicTextBoxes[id]["enabled"] = true
2904 writeToLog("Added dynamicTextBox "..id..".",2)
2905 else
2906 writeToLog("Did not add dynamicTextBox because of ID conflict.",3)
2907 end
2908end
2909
2910--internal function used to draw a dynamic text box on a monitor
2911function writeDynamicTextBoxToPixelMatrix(screenID,dynamicTextBoxID,x,y)
2912 local data = dynamicTextBoxes[dynamicTextBoxID]
2913
2914 local content
2915 local textLines = {}
2916 local nTextLines
2917 local textColor
2918 local BGColor
2919 local borderColor
2920 local borderThickness
2921 local textAlignmentHorizontal
2922 local textAlignmentVertical
2923
2924 --standard value for horizontal alignment is center
2925 if data["textAlignmentHorizontal"]~=nil then
2926 textAlignmentHorizontal = data["textAlignmentHorizontal"]
2927 else
2928 textAlignmentHorizontal = "center"
2929 end
2930
2931 --standard value for vertical alignment is center
2932 if data["textAlignmentVertical"]~=nil then
2933 textAlignmentVertical = data["textAlignmentVertical"]
2934 else
2935 textAlignmentVertical = "center"
2936 end
2937
2938 --if no borderThickness is specified, assign the variable a zero value
2939 if data["borderThickness"]~=nil then
2940 borderThickness = data["borderThickness"]
2941 else
2942 borderThickness = 0
2943 end
2944
2945 --take care of all of the colors
2946 --if the button is active, colors might be different
2947 if data["active"] then
2948 if data["activeContent"]~=nil then
2949 content = data["activeContent"]
2950 else
2951 content = data["content"]
2952 end
2953 if data["activeTextColor"]~=nil then
2954 textColor = data["activeTextColor"]
2955 else
2956 textColor = data["textColor"]
2957 end
2958 if data["activeBGColor"]~=nil then
2959 BGColor = data["activeBGColor"]
2960 else
2961 BGColor = data["BGColor"]
2962 end
2963 if data["activeBorderColor"]~=nil then
2964 borderColor = data["activeBorderColor"]
2965 else
2966 borderColor = data["borderColor"]
2967 end
2968 else
2969 content = data["content"]
2970 textColor = data["textColor"]
2971 BGColor = data["BGColor"]
2972 borderColor = data["borderColor"]
2973 end
2974
2975 --if no colors are specified, use default colors of the corresponding screen
2976 if BGColor==nil then
2977 BGColor = screens[screenID]["defaultBGColor"]
2978 end
2979 if textColor==nil then
2980 textColor = screens[screenID]["defaultTextColor"]
2981 end
2982
2983 --if no bordercolor is specified, use the background color
2984 if borderColor==nil then
2985 borderColor = BGColor
2986 end
2987
2988 --replace variable placeholder with values
2989 if data["variables"]~=nil then
2990 for name, variableData in pairs(data["variables"]) do
2991 if data["variables"][name]~=nil then
2992 if type(data["variables"][name])=="function" then
2993 success,text = pcall(data["variables"][name],dynamicTextBoxID,name)
2994 if success then
2995 content = string.gsub(content,"$"..name,text)
2996 else
2997 writeToLog("There was an error retrieving variable "..name.." for dynamicTextBox "..dynamicTextBoxID..". Error message: "..text,4)
2998 end
2999 else if type(data["variables"][name])=="string" or type(data["variables"][name])=="number" then
3000 content = string.gsub(content,"$"..name,data["variables"][name])
3001 end end
3002 end
3003 end
3004 end
3005
3006
3007 local newLine = false
3008 local colorsTable = {}
3009 if data["ignoreMods"]==nil then
3010 while string.find(content,"%§[0123456789abcdefn#*-?]") do
3011 local a,b = string.find(content,"%§[0123456789abcdefn#*-?]")
3012 table.insert(colorsTable,{["color"] = string.sub(content,b,b),["start"]=a-1})
3013 if string.sub(content,b,b)=="n" then
3014 newLine = true
3015 end
3016 content = string.sub(content,1,a-1)..string.sub(content,b+1)
3017 end
3018 end
3019
3020 local maxX
3021 local maxY
3022
3023 if data["width"]~=nil then
3024 --if a width is specified the following variable is the maxX value
3025 maxX = x + data["width"] - 1
3026 --check if the content fits in one line with the specified width
3027 if string.len(content)<=(data["width"] - borderThickness*2) and (not newLine) then
3028 textLines[1] = content
3029 nTextLines = 1
3030 end
3031 --if it does not fit, text will be split down below
3032 else
3033 --check if it fits in one line, assuming maxX is the monitors sizeX
3034 if string.len(content)<=(screens[screenID]["sizeX"]-x+1-(borderThickness*2)) and (not newLine) then
3035 textLines[1] = content
3036 nTextLines = 1
3037 maxX = x + string.len(content) + borderThickness*2 - 1
3038 else
3039 --if it does not fit, text will be split down below
3040 maxX = screens[screenID]["sizeX"]
3041 end
3042 end
3043
3044 --variable used to determine the space for text on the dynamicTextBox
3045 local spaceX = maxX - x + 1 - borderThickness*2
3046
3047 --split text into lines
3048 if nTextLines~=1 then
3049 local words = {}
3050 --find spaces in the content string and use string.sub accordingly to create a list of words only
3051 local index = string.find(content," ")
3052 if index~=nil then
3053 local length = 0
3054 repeat
3055 --insert the word into the table
3056 length = length + string.len(string.sub(content,1,index-1))+1
3057 table.insert(words,string.sub(content,1,index-1))
3058 for i,data in ipairs(colorsTable) do
3059 if data["start"]==length-1 and data["color"]=="n" then
3060 table.insert(words,"§n")
3061 end
3062 end
3063 --remove the content that is already dealt with
3064 content = string.sub(content,index+1)
3065 index = string.find(content," ")
3066 until index==nil
3067 table.insert(words,content)
3068 else
3069 --in this case the content is one word alone
3070 table.insert(words,content)
3071 end
3072
3073 --create lines out of the words
3074 local sBuffer = ""
3075 for i,word in ipairs(words) do
3076 if word =="§n" then
3077 if sBuffer=="" then
3078 table.insert(textLines,"")
3079 else
3080 table.insert(textLines,sBuffer)
3081 sBuffer = ""
3082 local length = 0
3083 for i,data in ipairs(textLines) do
3084 length = length + string.len(data)
3085 end
3086 for name,data in pairs(colorsTable) do
3087 if data["start"]>length then
3088 data["start"] = data["start"] -1
3089 end
3090 end
3091 end
3092 else
3093 --the line is complete under three conditions: buffer not empty, current word added would be too long, current word is not longer than spaceX
3094 --it is also complete when it has the same length as spaceX or one less (space at the end) and the buffer is not empty
3095 --if the current word is longer than spaceX anyway, it can start in the current line and break subsequently
3096 if sBuffer~="" and ((string.len(sBuffer.." "..word)>spaceX and string.len(word)<=spaceX) or string.len(sBuffer)>=spaceX-1) then
3097 table.insert(textLines,sBuffer)
3098 --one space might get lost in this process, therefore correct the start for the modifiers
3099 local length = 0
3100 for i,data in ipairs(textLines) do
3101 length = length + string.len(data)
3102 end
3103 for name,data in pairs(colorsTable) do
3104 if data["start"]>length then
3105 data["start"] = data["start"] -1
3106 end
3107 end
3108 sBuffer = ""
3109 end
3110
3111 --split down too long words
3112 while string.len(word)>spaceX do
3113 if sBuffer == "" then
3114 --if the buffer is empty, simply insert the first 'spaceX' letters of the word
3115 table.insert(textLines,string.sub(word,1,spaceX))
3116 word = string.sub(word,spaceX+1)
3117 sBuffer = ""
3118 else
3119 --otherwise, add as many letters as still fit in the line (spaceX-lengthOfBuffer-space)
3120 table.insert(textLines,sBuffer.." "..string.sub(word,1,spaceX-string.len(sBuffer)-1))
3121 word = string.sub(word,spaceX-string.len(sBuffer)-1+1)
3122 sBuffer = ""
3123 end
3124 end
3125
3126 --add the word to the buffer accordingly
3127 if sBuffer=="" then
3128 sBuffer = word
3129 else
3130 sBuffer = sBuffer.." "..word
3131 end
3132 end
3133 end
3134
3135 --there can be one bit left at the end if it was a too long word
3136 if sBuffer~="" then
3137 table.insert(textLines,sBuffer)
3138 end
3139
3140 nTextLines = table.getn(textLines)
3141 end
3142
3143 if data["height"]~=nil then
3144 --if a height is specified, calculate maxY in the following variable
3145 maxY = y + data["height"] - 1
3146 --check if the lines fit with the given height
3147 if nTextLines>(data["height"] - borderThickness*2) then
3148 --in this case they don't, therefore use as many lines as there is space
3149 nTextLines = data["height"] - borderThickness*2
3150 end
3151 else
3152 --no height is specified therefore calculate maxY with as many lines as needed
3153 maxY = y + nTextLines + borderThickness*2 - 1
3154 --check if maxY is now bigger than the actual monitor's maxY
3155 if maxY>screens[screenID]["sizeY"] then
3156 --in this case it is bigger therefore maxY needs to be adjusted as well as the number of textLines
3157 maxY = screens[screenID]["sizeY"]
3158 nTextLines = maxY - y + 1 - borderThickness*2
3159 end
3160 end
3161
3162 --calculate the space for the text in y direction to be used later on
3163 local spaceY = maxY - y + 1 - borderThickness*2
3164
3165 --start drawing
3166 --border
3167 for currentOffset=0,borderThickness-1 do
3168 --this draws two horizontal lines
3169 for currentX=(x+currentOffset),(maxX-currentOffset) do
3170 writeToPixelMatrix(screenID," ",currentX,y+currentOffset,textColor,borderColor,dynamicTextBoxID,"dynamicTextBox","border")
3171 writeToPixelMatrix(screenID," ",currentX,maxY-currentOffset,textColor,borderColor,dynamicTextBoxID,"dynamicTextBox","border")
3172 end
3173
3174 --this draws two vertical lines to finish the border,offset by one because those spaces are already drawn
3175 for currentY=(y+currentOffset+1),(maxY-currentOffset-1) do
3176 writeToPixelMatrix(screenID," ",x+currentOffset,currentY,textColor,borderColor,dynamicTextBoxID,"dynamicTextBox","border")
3177 writeToPixelMatrix(screenID," ",maxX-currentOffset,currentY,textColor,borderColor,dynamicTextBoxID,"dynamicTextBox","border")
3178 end
3179 end
3180
3181 --draw the BGColor, offset by the borderThickness
3182 for currentX=(x+borderThickness),(maxX-borderThickness) do
3183 for currentY=(y+borderThickness),(maxY-borderThickness) do
3184 writeToPixelMatrix(screenID," ",currentX,currentY,textColor,BGColor,dynamicTextBoxID,"dynamicTextBox","BG")
3185 end
3186 end
3187
3188 --draw the text
3189 --calculate vertical offset
3190 local startOffsetY
3191 if textAlignmentVertical=="center" then
3192 --if vertical alignment is center, calculate the corresponding offset
3193 startOffsetY = math.floor((spaceY-nTextLines)/2)
3194 else
3195 if textAlignmentVertical=="top" then
3196 --no offset for top alignment
3197 startOffsetY = 0
3198 else
3199 if textAlignmentVertical=="bottom" then
3200 --calculate offsetY if alignment is bottom
3201 startOffsetY = spaceY - nTextLines
3202 end
3203 end
3204 end
3205
3206 local startOffsetX = {}
3207 --deal with horizontal alignment, calculate an offset for each line
3208 if textAlignmentHorizontal=="right" then
3209 for i,line in ipairs(textLines) do
3210 --calculate number for right alignment
3211 startOffsetX[i] = spaceX-string.len(line)
3212 end
3213 else
3214 if textAlignmentHorizontal=="center" then
3215 for i,line in ipairs(textLines) do
3216 --calculate number for center horizontal alignment
3217 startOffsetX[i] = math.floor((spaceX-string.len(line))/2)
3218 end
3219 else
3220 for i,line in ipairs(textLines) do
3221 --no offset needed for left alignment
3222 startOffsetX[i] = 0
3223 end
3224 end
3225 end
3226
3227 colorsArrayStrToNum["#"] = screens[screenID]["defaultBGColor"]
3228 colorsArrayStrToNum["*"] = screens[screenID]["defaultTextColor"]
3229 colorsArrayStrToNum["-"] = textColor
3230
3231 --write text, offset by borderThickness
3232 local currColor = textColor
3233 local length = 0
3234 for i=1,nTextLines do
3235 local modCount = 0
3236 length = length + string.len(textLines[i])
3237 local table_ = {}
3238 for j,data in ipairs(colorsTable) do
3239 if data["start"]>=length-string.len(textLines[i]) and data["start"]<=length and data["color"]~="n" then
3240 modCount = modCount + 1
3241 table.insert(table_,{["pos"]=data["start"]-(length-string.len(textLines[i])),["color"]=data["color"]})
3242 end
3243 end
3244 if modCount==0 then
3245 writeToPixelMatrix(screenID,textLines[i],x+borderThickness+startOffsetX[i],y+borderThickness+startOffsetY+i-1,currColor,BGColor,dynamicTextBoxID,"dynamicTextBox","text")
3246 else
3247 local length2 = 0
3248 writeToPixelMatrix(screenID,string.sub(textLines[i],1,table_[1]["pos"]),x+borderThickness+startOffsetX[i],y+borderThickness+startOffsetY+i-1,currColor,BGColor,dynamicTextBoxID,"dynamicTextBox","text")
3249 length2 = length2 + string.len(string.sub(textLines[i],1,table_[1]["pos"]))
3250 for j,data in ipairs(table_) do
3251 if table_[j+1]~=nil then
3252 currColor = colorsArrayStrToNum[table_[j]["color"]]
3253 writeToPixelMatrix(screenID,string.sub(textLines[i],table_[j]["pos"]+1,table_[j+1]["pos"]),x+borderThickness+startOffsetX[i]+length2,y+borderThickness+startOffsetY+i-1,currColor,BGColor,dynamicTextBoxID,"dynamicTextBox","text")
3254 length2 = length2 + string.len(string.sub(textLines[i],table_[j]["pos"]+1,table_[j+1]["pos"]))
3255 else
3256 currColor = colorsArrayStrToNum[table_[j]["color"]]
3257 writeToPixelMatrix(screenID,string.sub(textLines[i],table_[j]["pos"]+1),x+borderThickness+startOffsetX[i]+length2,y+borderThickness+startOffsetY+i-1,currColor,BGColor,dynamicTextBoxID,"dynamicTextBox","text")
3258 length2 = length2 + string.len(string.sub(textLines[i],table_[j]["pos"]+1))
3259 end
3260 end
3261 end
3262 end
3263end
3264
3265--Sliders from here
3266--Sliders all properties: length, value, broadness, orientation, pixelsPerUnit, color, colorsArray, textPosition, textMargin, BGColor, borderColor, onChangeFunction, borderThickness, visible, enabled, mode, changeButtons
3267function addSlider(id,length, value)
3268 if trackID(id) then
3269 sliders[id] = {}
3270 sliders[id]["length"] = length
3271 sliders[id]["value"] = value
3272 sliders[id]["visible"] = true
3273 sliders[id]["enabled"] = true
3274 writeToLog("Added slider "..id..".",2)
3275 else
3276 writeToLog("Did not add slider because of ID conflict.",3)
3277 end
3278end
3279
3280--function which draws a slider in the pixel matrix
3281function writeSliderToPixelMatrix(screenID,sliderID,x,y)
3282 local data = sliders[sliderID]
3283
3284 local length = data["length"]
3285 local value = math.floor(tonumber(data["value"]))
3286 local broadness
3287 local orientation
3288 local pixelsPerUnit
3289 local color
3290 local colorsArray
3291 local textPosition = data["textPosition"]
3292 local textMargin
3293 local BGColor
3294 local borderColor
3295 local borderThickness
3296 local mode
3297 local changeButtons
3298
3299 --take care of all variable defaults
3300 if data["broadness"]~=nil then
3301 broadness = data["broadness"]
3302 else
3303 broadness = 1
3304 end
3305
3306 if data["orientation"]~=nil then
3307 orientation = data["orientation"]
3308 else
3309 orientation = "left-right"
3310 end
3311
3312 if data["pixelsPerUnit"]~=nil then
3313 pixelsPerUnit = data["pixelsPerUnit"]
3314 else
3315 pixelsPerUnit = 1
3316 end
3317
3318 if data["color"]~=nil then
3319 color = data["color"]
3320 else
3321 color = screens[screenID]["defaultTextColor"]
3322 end
3323
3324 if data["colorsArray"]~=nil then
3325 if data["colorsArray"][value]~=nil then
3326 color = data["colorsArray"][value]
3327 end
3328 end
3329
3330 if data["textMargin"]~=nil then
3331 textMargin = data["textMargin"]
3332 else
3333 textMargin = 0
3334 end
3335
3336 if data["BGColor"]~=nil then
3337 BGColor = data["BGColor"]
3338 else
3339 BGColor = screens[screenID]["defaultBGColor"]
3340 end
3341
3342 if data["borderColor"]~=nil then
3343 borderColor = data["borderColor"]
3344 else
3345 borderColor = BGColor
3346 end
3347
3348 if data["borderThickness"]~=nil then
3349 borderThickness = data["borderThickness"]
3350 else
3351 borderThickness = 0
3352 end
3353
3354 if data["mode"]~=nil then
3355 mode = data["mode"]
3356 else
3357 mode = "fill"
3358 end
3359
3360 changeButtons = data["changeButtons"]
3361
3362 local maxX
3363 local maxY
3364
3365 --calculate maxX and maxY based on the orientation of slider
3366 if orientation=="left-right" or orientation=="right-left" then
3367 maxX = x + borderThickness*2 + length*pixelsPerUnit - 1
3368 maxY = y + borderThickness*2 + broadness - 1
3369 else
3370 maxX = x + borderThickness*2 + broadness - 1
3371 maxY = y + borderThickness*2 + length*pixelsPerUnit - 1
3372 end
3373
3374 --start drawing
3375 --border
3376 for currentOffset=0,borderThickness-1 do
3377 --this draws two horizontal lines
3378 for currentX=(x+currentOffset),(maxX-currentOffset) do
3379 writeToPixelMatrix(screenID," ",currentX,y+currentOffset,color,borderColor,sliderID,"slider","border")
3380 writeToPixelMatrix(screenID," ",currentX,maxY-currentOffset,color,borderColor,sliderID,"slider","border")
3381 end
3382
3383 --this draws two vertical lines to finish the border,offset by one because those spaces are already drawn
3384 for currentY=(y+currentOffset+1),(maxY-currentOffset-1) do
3385 writeToPixelMatrix(screenID," ",x+currentOffset,currentY,color,borderColor,sliderID,"slider","border")
3386 writeToPixelMatrix(screenID," ",maxX-currentOffset,currentY,color,borderColor,sliderID,"slider","border")
3387 end
3388 end
3389
3390 --draw bar case horizontal
3391 if orientation=="left-right" or orientation=="right-left" then
3392 --this makes things easier
3393 local s = ""
3394 for i=1,pixelsPerUnit do
3395 s = s.." "
3396 end
3397 --loop for x coordinate (length)
3398 for i=1,length do
3399 --change color according to slider value
3400 --check mode
3401 local currentColor
3402 if mode=="fill" then
3403 if i<=value then
3404 currentColor = color
3405 else
3406 currentColor = BGColor
3407 end
3408 end
3409 if mode=="value" then
3410 if i==value then
3411 currentColor = color
3412 else
3413 currentColor = BGColor
3414 end
3415 end
3416 --loop for y coordinate (broadness)
3417 for currentY=y+borderThickness,maxY-borderThickness do
3418 --take pixelsPerUnit into account for calculations
3419 if orientation=="left-right" then
3420 writeToPixelMatrix(screenID,s,x+borderThickness+(i-1)*pixelsPerUnit,currentY,currentColor,currentColor,sliderID,"slider","bar:"..i)
3421 end
3422 if orientation=="right-left" then
3423 writeToPixelMatrix(screenID,s,maxX-borderThickness-pixelsPerUnit+1-(i-1)*pixelsPerUnit,currentY,currentColor,currentColor,sliderID,"slider","bar:"..i)
3424 end
3425 end
3426 end
3427 else
3428 --this makes things easier
3429 local s = ""
3430 for i=1,broadness do
3431 s = s.." "
3432 end
3433 --draw bar case vertical
3434 --loop for y coordinate (length)
3435 for i=1,length do
3436 local currentColor
3437 if mode=="fill" then
3438 if i<=value then
3439 currentColor = color
3440 else
3441 currentColor = BGColor
3442 end
3443 end
3444 if mode=="value" then
3445 if i==value then
3446 currentColor = color
3447 else
3448 currentColor = BGColor
3449 end
3450 end
3451 --loop for x coordinate (broadness)
3452 for j=1,pixelsPerUnit do
3453 if orientation=="top-bottom" then
3454 writeToPixelMatrix(screenID,s,x+borderThickness,y+borderThickness+(i-1)*pixelsPerUnit+j-1,currentColor,currentColor,sliderID,"slider","bar:"..i)
3455 end
3456 if orientation=="bottom-top" then
3457 writeToPixelMatrix(screenID,s,x+borderThickness,maxY-borderThickness-pixelsPerUnit+1-(i-1)*pixelsPerUnit+j-1,currentColor,currentColor,sliderID,"slider","bar:"..i)
3458 end
3459 end
3460 end
3461 end
3462
3463 --this fixes rounding issue
3464 value = tostring(value)
3465 --draw text
3466 if textPosition~=nil then
3467 --calculations to center the text
3468 if textPosition=="right" then
3469 writeToPixelMatrix(screenID,value,maxX+1+textMargin,y+math.floor((maxY-y+1-1)/2),color,screens[screenID]["defaultBGColor"],sliderID,"slider","value")
3470 end
3471 if textPosition=="left" then
3472 writeToPixelMatrix(screenID,value,x-string.len(value)-textMargin,y+math.floor((maxY-y+1-1)/2),color,screens[screenID]["defaultBGColor"],sliderID,"slider","value")
3473 end
3474 if textPosition=="top" then
3475 writeToPixelMatrix(screenID,value,x+math.floor((maxX-x+1-string.len(value))/2),y-1-textMargin,color,screens[screenID]["defaultBGColor"],sliderID,"slider","value")
3476 end
3477 if textPosition=="bottom" then
3478 writeToPixelMatrix(screenID,value,x+math.floor((maxX-x+1-string.len(value))/2),maxY+1+textMargin,color,screens[screenID]["defaultBGColor"],sliderID,"slider","value")
3479 end
3480 end
3481
3482 --if defined, draws an increment and decrement button according to slider orientation
3483 if changeButtons~=nil then
3484 if orientation=="left-right" then
3485 writeToPixelMatrix(screenID,string.sub(changeButtons,1,1),maxX+1,y+math.floor((maxY-y+1-1)/2),color,screens[screenID]["defaultBGColor"],sliderID,"slider","incrementButton")
3486 writeToPixelMatrix(screenID,string.sub(changeButtons,2,2),x-1,y+math.floor((maxY-y+1-1)/2),color,screens[screenID]["defaultBGColor"],sliderID,"slider","decrementButton")
3487 end
3488 if orientation=="right-left" then
3489 writeToPixelMatrix(screenID,string.sub(changeButtons,2,2),maxX+1,y+math.floor((maxY-y+1-1)/2),color,screens[screenID]["defaultBGColor"],sliderID,"slider","decrementButton")
3490 writeToPixelMatrix(screenID,string.sub(changeButtons,1,1),x-1,y+math.floor((maxY-y+1-1)/2),color,screens[screenID]["defaultBGColor"],sliderID,"slider","incrementButton")
3491 end
3492 if orientation=="bottom-top" then
3493 writeToPixelMatrix(screenID,string.sub(changeButtons,1,1),x+math.floor((maxX-x+1-1)/2),y-1,color,screens[screenID]["defaultBGColor"],sliderID,"slider","incrementButton")
3494 writeToPixelMatrix(screenID,string.sub(changeButtons,2,2),x+math.floor((maxX-x+1-1)/2),maxY+1,color,screens[screenID]["defaultBGColor"],sliderID,"slider","decrementButton")
3495 end
3496 if orientation=="top-bottom" then
3497 writeToPixelMatrix(screenID,string.sub(changeButtons,2,2),x+math.floor((maxX-x+1-1)/2),y-1,color,screens[screenID]["defaultBGColor"],sliderID,"slider","decrementButton")
3498 writeToPixelMatrix(screenID,string.sub(changeButtons,1,1),x+math.floor((maxX-x+1-1)/2),maxY+1,color,screens[screenID]["defaultBGColor"],sliderID,"slider","incrementButton")
3499 end
3500 end
3501end
3502
3503--Dropdownmenus from here
3504--All properties: entries,width,expandedMaxHeight, textColor, BGColor, borderColor, onChangeFunction, onExpandFunction, onCollapseFunction, highlightTextColor, highlightBGColor, borderThickness, expanded, visible, enabled,selectionID,scrollPositionIndex,highlightID,buttonsColor,buttonsBGColor
3505function addDropDownMenu(id,entries,selectionID)
3506 if trackID(id) then
3507 dropDownMenus[id] = {}
3508 dropDownMenus[id]["entries"] = entries
3509 dropDownMenus[id]["selectionID"] = selectionID
3510 dropDownMenus[id]["visible"] = true
3511 dropDownMenus[id]["enabled"] = true
3512 dropDownMenus[id]["expanded"] = false
3513 writeToLog("Added dropDownMenu "..id..".",2)
3514 else
3515 writeToLog("Did not add dropDownMenu because of ID conflict.",3)
3516 end
3517end
3518
3519function writeDropDownMenuToPixelMatrix(screenID,dropDownMenuID,x,y)
3520 local data = dropDownMenus[dropDownMenuID]
3521
3522 local entries = data["entries"]
3523 local selectionID = data["selectionID"]
3524 local expanded = data["expanded"]
3525 local width
3526 local textColor
3527 local BGColor
3528 local borderColor
3529 local borderThickness
3530 local highlightTextColor
3531 local highlightBGColor
3532 local highlightID = data["highlightID"]
3533 local scrollPositionIndex = data["scrollPositionIndex"]
3534 local buttonsColor
3535 local buttonsBGColor
3536
3537 --take care of the colors and set other default values
3538 if data["textColor"]~=nil then
3539 textColor = data["textColor"]
3540 else
3541 textColor = screens[screenID]["defaultTextColor"]
3542 end
3543
3544 if data["BGColor"]~=nil then
3545 BGColor = data["BGColor"]
3546 else
3547 BGColor = screens[screenID]["defaultBGColor"]
3548 end
3549
3550 if data["borderColor"]~=nil then
3551 borderColor = data["borderColor"]
3552 else
3553 borderColor = BGColor
3554 end
3555
3556 if data["borderThickness"]~=nil then
3557 borderThickness = data["borderThickness"]
3558 else
3559 borderThickness = 0
3560 end
3561
3562 if data["highlightTextColor"]~=nil then
3563 highlightTextColor = data["highlightTextColor"]
3564 else
3565 highlightTextColor = textColor
3566 end
3567
3568 if data["highlightBGColor"]~=nil then
3569 highlightBGColor = data["highlightBGColor"]
3570 else
3571 highlightBGColor = BGColor
3572 end
3573
3574 if data["buttonsColor"]~=nil then
3575 buttonsColor = data["buttonsColor"]
3576 else
3577 buttonsColor = textColor
3578 end
3579
3580 if data["buttonsBGColor"]~=nil then
3581 buttonsBGColor = data["buttonsBGColor"]
3582 else
3583 buttonsBGColor = BGColor
3584 end
3585
3586 --calculate greatestTextLength to later define a width if its not specified
3587 local greatestTextLength = 0
3588 for name,entry in pairs(entries) do
3589 if string.len(entry)>greatestTextLength then
3590 greatestTextLength = string.len(entry)
3591 end
3592 end
3593
3594 --fill this array with entries and manipulate later
3595 local shortenedEntries = {}
3596 for i,entry in ipairs(entries) do
3597 shortenedEntries[i] = entry
3598 end
3599 local nEntries = table.getn(entries)
3600 if data["width"]~=nil then
3601 width = data["width"]
3602 --two pixel space: one for v and one for a space (or space + scrollbar)
3603 if greatestTextLength>width-borderThickness*2-2 then
3604 --shorten entries if necessary
3605 for i,entry in ipairs(entries) do
3606 shortenedEntries[i] = string.sub(entry,1,width-borderThickness*2-2)
3607 end
3608 end
3609 else
3610 if greatestTextLength>screens[screenID]["sizeX"]-x-borderThickness*2+1-2 then
3611 --shorten entries if necessary
3612 for i,entry in ipairs(entries) do
3613 shortenedEntries[i] = string.sub(entry,1,screens[screenID]["sizeX"]-x-borderThickness*2+1-2)
3614 end
3615 width = screens[screenID]["sizeX"]-x+1
3616 else
3617 --as wide as it needs
3618 width = borderThickness*2+greatestTextLength + 2
3619 end
3620 end
3621
3622 local maxX = x + width - 1
3623
3624 --draw collapsed menu
3625 if not expanded then
3626 local maxY = y + borderThickness*2
3627 --start drawing
3628 --border
3629 for currentOffset=0,borderThickness-1 do
3630 --this draws two horizontal lines
3631 for currentX=(x+currentOffset),(maxX-currentOffset) do
3632 writeToPixelMatrix(screenID," ",currentX,y+currentOffset,textColor,borderColor,dropDownMenuID,"dropDownMenu","border")
3633 writeToPixelMatrix(screenID," ",currentX,maxY-currentOffset,textColor,borderColor,dropDownMenuID,"dropDownMenu","border")
3634 end
3635
3636 --this draws two vertical lines to finish the border,offset by one because those spaces are already drawn
3637 for currentY=(y+currentOffset+1),(maxY-currentOffset-1) do
3638 writeToPixelMatrix(screenID," ",x+currentOffset,currentY,textColor,borderColor,dropDownMenuID,"dropDownMenu","border")
3639 writeToPixelMatrix(screenID," ",maxX-currentOffset,currentY,textColor,borderColor,dropDownMenuID,"dropDownMenu","border")
3640 end
3641 end
3642
3643 --draw the BGColor, offset by the borderThickness
3644 for currentX=(x+borderThickness),(maxX-borderThickness) do
3645 writeToPixelMatrix(screenID," ",currentX,y+borderThickness,textColor,BGColor,dropDownMenuID,"dropDownMenu","BG")
3646 end
3647
3648 --draw text
3649 writeToPixelMatrix(screenID,shortenedEntries[selectionID],x+borderThickness,y+borderThickness,textColor,BGColor,dropDownMenuID,"dropDownMenu","text")
3650
3651 --draw v (expandbutton)
3652 writeToPixelMatrix(screenID,"v",maxX-borderThickness,y+borderThickness,buttonsColor,buttonsBGColor,dropDownMenuID,"dropDownMenu","expandButton")
3653 else
3654 --determine if a scrollbar is necessary
3655 local scrollBar
3656 local maxY
3657 if highlightID ==nil then
3658 highlightID = selectionID
3659 end
3660 dropDownMenus[dropDownMenuID]["highlightID"] = highlightID
3661 if data["expandedMaxHeight"]~=nil then
3662 local expandedMaxHeight = data["expandedMaxHeight"]
3663 --check if all entries fit with the given height
3664 if borderThickness*2 + 1 + nEntries > expandedMaxHeight then
3665 maxY = y+expandedMaxHeight-1
3666 scrollBar = true
3667 else
3668 --as wide as it needs
3669 maxY = y + borderThickness*2 + 1 + nEntries -1
3670 scrollBar = false
3671 end
3672 else
3673 --with no specified height, check if the full list would be greater than screen size
3674 if y + borderThickness*2 +1 + nEntries - 1>screens[screenID]["sizeY"] then
3675 maxY = screens[screenID]["sizeY"]
3676 scrollBar = true
3677 else
3678 maxY = y + borderThickness*2 + 1 + nEntries - 1
3679 scrollBar = false
3680 end
3681 end
3682
3683 --draw the BGColor, offset by the borderThickness
3684 for currentX=(x+borderThickness),(maxX-borderThickness) do
3685 writeToPixelMatrix(screenID," ",currentX,y+borderThickness,textColor,BGColor,dropDownMenuID,"dropDownMenu","BG")
3686 end
3687
3688 --draw text
3689 writeToPixelMatrix(screenID,shortenedEntries[selectionID],x+borderThickness,y+borderThickness,textColor,BGColor,dropDownMenuID,"dropDownMenu","text")
3690
3691 --draw v
3692 writeToPixelMatrix(screenID,"v",maxX-borderThickness,y+borderThickness,buttonsColor,buttonsBGColor,dropDownMenuID,"dropDownMenu","collapseButton")
3693
3694 --draw list without scrollbar
3695 if not scrollBar then
3696 --entries need to be spaced in order to fill the whole line
3697 local spacedEntries = {}
3698 for i,entry in ipairs(shortenedEntries) do
3699 local s = ""
3700 for j=1,width-borderThickness*2-string.len(entry) do
3701 s = s.." "
3702 end
3703 spacedEntries[i] = entry..s
3704 end
3705 for i,entry in ipairs(spacedEntries) do
3706 --change color accordingly
3707 local currentTextColor
3708 local currentBGColor
3709 if i==highlightID then
3710 currentTextColor = highlightTextColor
3711 currentBGColor = highlightBGColor
3712 else
3713 currentTextColor = textColor
3714 currentBGColor = BGColor
3715 end
3716 writeToPixelMatrix(screenID,entry,x+borderThickness,y+borderThickness+i,currentTextColor,currentBGColor,dropDownMenuID,"dropDownMenu","entry:"..i)
3717 end
3718 else
3719 local spacedEntries = {}
3720 for i,entry in ipairs(shortenedEntries) do
3721 local s = ""
3722 --this time -1 because of scrollbar
3723 for j=1,width-borderThickness*2-string.len(entry)-1 do
3724 s = s.." "
3725 end
3726 spacedEntries[i] = entry..s
3727 end
3728 local spaceY = maxY-y+1-borderThickness*2-1
3729 dropDownMenus[dropDownMenuID]["spaceY"] = spaceY
3730 --set scrollposition if menu was just opened
3731 if scrollPositionIndex==nil then
3732 --make sure not to overrun
3733 if selectionID>nEntries-spaceY then
3734 scrollPositionIndex = nEntries-spaceY+1
3735 else
3736 scrollPositionIndex = selectionID
3737 end
3738
3739 --set for next time
3740 dropDownMenus[dropDownMenuID]["scrollPositionIndex"] = scrollPositionIndex
3741 end
3742
3743 for i=1,spaceY do
3744 local currentTextColor
3745 local currentBGColor
3746 if i+scrollPositionIndex-1==highlightID then
3747 currentTextColor = highlightTextColor
3748 currentBGColor = highlightBGColor
3749 else
3750 currentTextColor = textColor
3751 currentBGColor = BGColor
3752 end
3753
3754 --this is a workaround for a very special case where one dropDownMenu is displayed on different screens with different space
3755 if spacedEntries[i+scrollPositionIndex-1]==nil then
3756 maxY = y+borderThickness+i
3757 break
3758 else
3759 writeToPixelMatrix(screenID,spacedEntries[i+scrollPositionIndex-1],x+borderThickness,y+borderThickness+i,currentTextColor,currentBGColor,dropDownMenuID,"dropDownMenu","entry:"..i+scrollPositionIndex-1)
3760 end
3761 end
3762
3763 --draw scrollbar buttons and bg
3764 local scrollBarX = maxX-1
3765 for currentY=y+borderThickness+1,maxY-1 do
3766 if currentY==y+borderThickness+1 then
3767 writeToPixelMatrix(screenID,"^",scrollBarX,currentY,buttonsColor,buttonsBGColor,dropDownMenuID,"dropDownMenu","scrollUpButton")
3768 else if currentY==maxY-1 then
3769 writeToPixelMatrix(screenID,"v",scrollBarX,currentY,buttonsColor,buttonsBGColor,dropDownMenuID,"dropDownMenu","scrollDownButton")
3770 else
3771 writeToPixelMatrix(screenID," ",scrollBarX,currentY,buttonsColor,buttonsBGColor,dropDownMenuID,"dropDownMenu","scrollBarBG")
3772 end
3773 end
3774 end
3775 end
3776
3777 --draw border
3778 for currentOffset=0,borderThickness-1 do
3779 --this draws two horizontal lines
3780 for currentX=(x+currentOffset),(maxX-currentOffset) do
3781 writeToPixelMatrix(screenID," ",currentX,y+currentOffset,textColor,borderColor,dropDownMenuID,"dropDownMenu","border")
3782 writeToPixelMatrix(screenID," ",currentX,maxY-currentOffset,textColor,borderColor,dropDownMenuID,"dropDownMenu","border")
3783 end
3784
3785 --this draws two vertical lines to finish the border,offset by one because those spaces are already drawn
3786 for currentY=(y+currentOffset+1),(maxY-currentOffset-1) do
3787 writeToPixelMatrix(screenID," ",x+currentOffset,currentY,textColor,borderColor,dropDownMenuID,"dropDownMenu","border")
3788 writeToPixelMatrix(screenID," ",maxX-currentOffset,currentY,textColor,borderColor,dropDownMenuID,"dropDownMenu","border")
3789 end
3790 end
3791 end
3792end
3793
3794--navMenus from here
3795-- all props: title,menuArray (text, submenu),titleTextColor,titleBGColor,titleTextColorExpanded,titleBGColorExpanded,textAlignmentHorizontal,textAlignmentVertical,entryWidth,entryHeight,entryTextColor,entryBGColor,borderColor,spaceBetweenEntries,borderThickness,highlightTextColor,highlightBGColor,expanded,highlightIDs,onChangeFunction,enabled,visible
3796function addNavigationMenu(id,title,menuArray)
3797 if trackID(id) then
3798 navigationMenus[id] = {}
3799 navigationMenus[id]["title"] = title
3800 navigationMenus[id]["menuArray"] = menuArray
3801 navigationMenus[id]["visible"] = true
3802 navigationMenus[id]["enabled"] = true
3803 navigationMenus[id]["expanded"] = false
3804 navigationMenus[id]["highlightIDs"] = nil
3805 writeToLog("Added navMenu "..id..".",2)
3806 else
3807 writeToLog("Did not add navMenu because of ID conflict.",3)
3808 end
3809end
3810
3811function writeNavigationMenuToPixelMatrix(screenID,navigationMenuID,x,y)
3812 local data = navigationMenus[navigationMenuID]
3813
3814 local title = data["title"]
3815 local menuArray = data["menuArray"]
3816 local expanded = data["expanded"]
3817 local entryWidth = data["entryWidth"]
3818 local entryHeight
3819 local titleTextColor
3820 local titleBGColor
3821 local titleTextColorExpanded
3822 local titleBGColorExpanded
3823 local entryTextColor
3824 local entryBGColor
3825 local borderColor
3826 local borderThickness
3827 local spaceBetweenEntries
3828 local highlightIDs = data["highlightIDs"]
3829 local highlightTextColor
3830 local highlightBGColor
3831 local expanded = data["expanded"]
3832 local textAlignmentHorizontal
3833 local textAlignmentVertical
3834
3835 --take care of the colors and set other default values
3836 if data["entryTextColor"]~=nil then
3837 entryTextColor = data["entryTextColor"]
3838 else
3839 entryTextColor = screens[screenID]["defaultTextColor"]
3840 end
3841
3842 if data["entryBGColor"]~=nil then
3843 entryBGColor = data["entryBGColor"]
3844 else
3845 entryBGColor = screens[screenID]["defaultBGColor"]
3846 end
3847
3848 if data["titleTextColor"]~=nil then
3849 titleTextColor = data["titleTextColor"]
3850 else
3851 titleTextColor = screens[screenID]["defaultTextColor"]
3852 end
3853
3854 if data["titleBGColor"]~=nil then
3855 titleBGColor = data["titleBGColor"]
3856 else
3857 titleBGColor = screens[screenID]["defaultBGColor"]
3858 end
3859
3860 if data["titleTextColorExpanded"]~=nil then
3861 titleTextColorExpanded = data["titleTextColorExpanded"]
3862 else
3863 titleTextColorExpanded = titleTextColor
3864 end
3865
3866 if data["titleBGColorExpanded"]~=nil then
3867 titleBGColorExpanded = data["titleBGColorExpanded"]
3868 else
3869 titleBGColorExpanded = titleBGColor
3870 end
3871
3872 if data["borderColor"]~=nil then
3873 borderColor = data["borderColor"]
3874 else
3875 borderColor = screens[screenID]["defaultBGColor"]
3876 end
3877
3878 if data["borderThickness"]~=nil then
3879 borderThickness = data["borderThickness"]
3880 else
3881 borderThickness = 0
3882 end
3883
3884 if data["spaceBetweenEntries"]~=nil then
3885 spaceBetweenEntries = data["spaceBetweenEntries"]
3886 else
3887 spaceBetweenEntries = 0
3888 end
3889
3890 if data["highlightTextColor"]~=nil then
3891 highlightTextColor = data["highlightTextColor"]
3892 else
3893 highlightTextColor = entryTextColor
3894 end
3895
3896 if data["highlightBGColor"]~=nil then
3897 highlightBGColor = data["highlightBGColor"]
3898 else
3899 highlightBGColor = entryBGColor
3900 end
3901
3902 if data["entryHeight"]~=nil then
3903 entryHeight = data["entryHeight"]
3904 else
3905 entryHeight = 1
3906 end
3907
3908 --standard value for horizontal alignment is center
3909 if data["textAlignmentHorizontal"]~=nil then
3910 textAlignmentHorizontal = data["textAlignmentHorizontal"]
3911 else
3912 textAlignmentHorizontal = "center"
3913 end
3914
3915 --standard value for vertical alignment is center
3916 if data["textAlignmentVertical"]~=nil then
3917 textAlignmentVertical = data["textAlignmentVertical"]
3918 else
3919 textAlignmentVertical = "center"
3920 end
3921
3922 local greatestRootTextLength = string.len(title)
3923 local rootEntryCount = 0
3924 for name,entry in pairs(menuArray) do
3925 rootEntryCount = rootEntryCount + 1
3926 if string.len(entry["text"])>greatestRootTextLength then
3927 greatestRootTextLength = string.len(entry["text"])
3928 end
3929 end
3930
3931 --fill this array with entries and manipulate later
3932 local nRootEntries = 0
3933 local shortenedEntries = {}
3934 for i,entry in ipairs(menuArray) do
3935 nRootEntries = nRootEntries + 1
3936 shortenedEntries[i] = entry
3937 end
3938
3939 local rootMaxX
3940 if entryWidth~=nil then
3941 rootMaxX = x+borderThickness*2+entryWidth-1
3942 --shorten text
3943 if greatestRootTextLength>entryWidth then
3944 title = string.sub(title,1,entryWidth)
3945 for i,entry in ipairs(shortenedEntries) do
3946 shortenedEntries[i]["text"] = string.sub(entry["text"],1,entryWidth)
3947 end
3948 end
3949 else
3950 rootMaxX = x+borderThickness*2+greatestRootTextLength-1
3951 entryWidth = greatestRootTextLength
3952 end
3953
3954 local currentTextColor
3955 local currentBGColor
3956
3957 if expanded then
3958 currentTextColor = titleTextColorExpanded
3959 currentBGColor = titleBGColorExpanded
3960 else
3961 currentTextColor = titleTextColor
3962 currentBGColor = titleBGColor
3963 end
3964
3965 --titleBG
3966 for currentX=(x+borderThickness),(rootMaxX-borderThickness) do
3967 for currentY=(y+borderThickness),(y+borderThickness+entryHeight-1) do
3968 writeToPixelMatrix(screenID," ",currentX,currentY,currentTextColor,currentBGColor,navigationMenuID,"navigationMenu","titleBG")
3969 end
3970 end
3971
3972 local rootMaxY
3973 if not expanded then
3974 rootMaxY = y+borderThickness*2+entryHeight-1
3975 else
3976 rootMaxY = y+borderThickness*2+entryHeight+((entryHeight+spaceBetweenEntries)*rootEntryCount)-1
3977 end
3978
3979 --draw border
3980 for currentOffset=0,borderThickness-1 do
3981 --this draws two horizontal lines
3982 for currentX=(x+currentOffset),(rootMaxX-currentOffset) do
3983 writeToPixelMatrix(screenID," ",currentX,y+currentOffset,titleTextColor,borderColor,navigationMenuID,"navigationMenu","border")
3984 writeToPixelMatrix(screenID," ",currentX,rootMaxY-currentOffset,titleTextColor,borderColor,navigationMenuID,"navigationMenu","border")
3985 end
3986
3987 --this draws two vertical lines to finish the border,offset by one because those spaces are already drawn
3988 for currentY=(y+currentOffset+1),(rootMaxY-currentOffset-1) do
3989 writeToPixelMatrix(screenID," ",x+currentOffset,currentY,titleTextColor,borderColor,navigationMenuID,"navigationMenu","border")
3990 writeToPixelMatrix(screenID," ",rootMaxX-currentOffset,currentY,titleTextColor,borderColor,navigationMenuID,"navigationMenu","border")
3991 end
3992 end
3993
3994 --calculate vertical offset
3995 local startOffsetY
3996 if textAlignmentVertical=="center" then
3997 --if vertical alignment is center, calculate the corresponding offset
3998 startOffsetY = math.floor((entryHeight-1)/2)
3999 else
4000 if textAlignmentVertical=="top" then
4001 --no offset for top alignment
4002 startOffsetY = 0
4003 else
4004 if textAlignmentVertical=="bottom" then
4005 --calculate offsetY if alignment is bottom
4006 startOffsetY = entryHeight - 1
4007 end
4008 end
4009 end
4010
4011 local startOffsetX = 0
4012 --deal with horizontal alignment, calculate an offset
4013 if textAlignmentHorizontal=="right" then
4014 startOffsetX = entryWidth-string.len(title)
4015 else
4016 if textAlignmentHorizontal=="center" then
4017 --calculate number for center horizontal alignment
4018 startOffsetX = math.floor((entryWidth-string.len(title))/2)
4019 end
4020 end
4021
4022 --write title text
4023 writeToPixelMatrix(screenID,title,x+borderThickness+startOffsetX,y+borderThickness+startOffsetY,currentTextColor,currentBGColor,navigationMenuID,"navigationMenu","title")
4024
4025 local nextY
4026 if expanded then
4027 -- this makes things easier
4028 local s = ""
4029 for i=1,entryWidth do
4030 s = s.." "
4031 end
4032 --draw entries
4033 for i=1,nRootEntries do
4034 for j=0,spaceBetweenEntries-1 do
4035 writeToPixelMatrix(screenID,s,x+borderThickness,j+y+borderThickness+entryHeight+((i-1)*(spaceBetweenEntries+entryHeight)),titleTextColor,borderColor,navigationMenuID,"navigationMenu","spaceBorder")
4036 end
4037 local currentTextColor = entryTextColor
4038 local currentBGColor = entryBGColor
4039 if highlightIDs~=nil then
4040 if highlightIDs[1]==i then
4041 currentTextColor = highlightTextColor
4042 currentBGColor = highlightBGColor
4043 --for next submenu
4044 nextY = y+entryHeight+spaceBetweenEntries+((i-1)*(spaceBetweenEntries+entryHeight))
4045 end
4046 end
4047 for j=0,entryHeight-1 do
4048 writeToPixelMatrix(screenID,s,x+borderThickness,j+y+borderThickness+entryHeight+spaceBetweenEntries+((i-1)*(spaceBetweenEntries+entryHeight)),currentTextColor,currentBGColor,navigationMenuID,"navigationMenu","entry:1:"..i)
4049 end
4050 --calculate vertical offset
4051 local startOffsetY
4052 if textAlignmentVertical=="center" then
4053 --if vertical alignment is center, calculate the corresponding offset
4054 startOffsetY = math.floor((entryHeight-1)/2)
4055 else
4056 if textAlignmentVertical=="top" then
4057 --no offset for top alignment
4058 startOffsetY = 0
4059 else
4060 if textAlignmentVertical=="bottom" then
4061 --calculate offsetY if alignment is bottom
4062 startOffsetY = entryHeight - 1
4063 end
4064 end
4065 end
4066
4067 local startOffsetX = 0
4068 --deal with horizontal alignment, calculate an offset
4069 if textAlignmentHorizontal=="right" then
4070 startOffsetX = entryWidth-string.len(shortenedEntries[i]["text"])
4071 else
4072 if textAlignmentHorizontal=="center" then
4073 --calculate number for center horizontal alignment
4074 startOffsetX = math.floor((entryWidth-string.len(shortenedEntries[i]["text"]))/2)
4075 end
4076 end
4077
4078 --write title text
4079 writeToPixelMatrix(screenID,shortenedEntries[i]["text"],x+borderThickness+startOffsetX,y+borderThickness+entryHeight+spaceBetweenEntries+((i-1)*(spaceBetweenEntries+entryHeight))+startOffsetY,currentTextColor,currentBGColor,navigationMenuID,"navigationMenu","entry:1:"..i)
4080 end
4081
4082 --draw submenus
4083 if highlightIDs~=nil then
4084 --like this a lot of code is reused
4085 x = x + borderThickness + entryWidth
4086 y = nextY
4087 local subTable = menuArray[highlightIDs[1]]["submenu"]
4088 for k=1,table.getn(highlightIDs) do
4089 local greatestTextLength = 0
4090 local nEntries = 0
4091 for name,entry in pairs(subTable) do
4092 nEntries = nEntries + 1
4093 if string.len(entry["text"])>greatestTextLength then
4094 greatestTextLength = string.len(entry["text"])
4095 end
4096 end
4097
4098 --fill this array with entries and manipulate later
4099 local shortenedEntries = {}
4100 for i,entry in ipairs(subTable) do
4101 shortenedEntries[i] = entry
4102 end
4103
4104 entryWidth = data["entryWidth"]
4105 local maxX
4106 if entryWidth~=nil then
4107 maxX = x+borderThickness*2+entryWidth-1
4108 --shorten text
4109 if greatestTextLength>entryWidth then
4110 for i,entry in ipairs(shortenedEntries) do
4111 shortenedEntries[i]["text"] = string.sub(entry["text"],1,entryWidth)
4112 end
4113 end
4114 else
4115 maxX = x+borderThickness*2+greatestTextLength-1
4116 entryWidth = greatestTextLength
4117 end
4118
4119 -- this makes things easier
4120 local s = ""
4121 for i=1,entryWidth do
4122 s = s.." "
4123 end
4124
4125 local maxY = y + borderThickness*2 + (nEntries)*entryHeight + (nEntries-1)*spaceBetweenEntries - 1
4126
4127 --border
4128 for currentOffset=0,borderThickness-1 do
4129 --this draws two horizontal lines
4130 for currentX=(x+currentOffset),(maxX-currentOffset) do
4131 writeToPixelMatrix(screenID," ",currentX,y+currentOffset,titleTextColor,borderColor,navigationMenuID,"navigationMenu","border")
4132 writeToPixelMatrix(screenID," ",currentX,maxY-currentOffset,titleTextColor,borderColor,navigationMenuID,"navigationMenu","border")
4133 end
4134
4135 --this draws two vertical lines to finish the border,offset by one because those spaces are already drawn
4136 for currentY=(y+currentOffset+1),(maxY-currentOffset-1) do
4137 writeToPixelMatrix(screenID," ",x+currentOffset,currentY,titleTextColor,borderColor,navigationMenuID,"navigationMenu","border")
4138 writeToPixelMatrix(screenID," ",maxX-currentOffset,currentY,titleTextColor,borderColor,navigationMenuID,"navigationMenu","border")
4139 end
4140 end
4141
4142 for i=1,nEntries do
4143 if i~=nEntries then
4144 for j=0,spaceBetweenEntries-1 do
4145 writeToPixelMatrix(screenID,s,x+borderThickness,j+y+borderThickness+entryHeight+((i-1)*(spaceBetweenEntries+entryHeight)),titleTextColor,borderColor,navigationMenuID,"navigationMenu","spaceBorder")
4146 end
4147 end
4148
4149 local currentTextColor = entryTextColor
4150 local currentBGColor = entryBGColor
4151 if highlightIDs[k+1]==i then
4152 currentTextColor = highlightTextColor
4153 currentBGColor = highlightBGColor
4154 nextY = y+((i-1)*(spaceBetweenEntries+entryHeight))
4155 end
4156 for j=0,entryHeight-1 do
4157 writeToPixelMatrix(screenID,s,x+borderThickness,j+y+borderThickness+((i-1)*(spaceBetweenEntries+entryHeight)),currentTextColor,currentBGColor,navigationMenuID,"navigationMenu","entry:"..(k+1)..":"..i)
4158 end
4159 --calculate vertical offset
4160 local startOffsetY
4161 if textAlignmentVertical=="center" then
4162 --if vertical alignment is center, calculate the corresponding offset
4163 startOffsetY = math.floor((entryHeight-1)/2)
4164 else
4165 if textAlignmentVertical=="top" then
4166 --no offset for top alignment
4167 startOffsetY = 0
4168 else
4169 if textAlignmentVertical=="bottom" then
4170 --calculate offsetY if alignment is bottom
4171 startOffsetY = entryHeight - 1
4172 end
4173 end
4174 end
4175
4176 local startOffsetX = 0
4177 --deal with horizontal alignment, calculate an offset
4178 if textAlignmentHorizontal=="right" then
4179 startOffsetX = entryWidth-string.len(shortenedEntries[i]["text"])
4180 else
4181 if textAlignmentHorizontal=="center" then
4182 --calculate number for center horizontal alignment
4183 startOffsetX = math.floor((entryWidth-string.len(shortenedEntries[i]["text"]))/2)
4184 end
4185 end
4186
4187 --write title text
4188 writeToPixelMatrix(screenID,shortenedEntries[i]["text"],x+borderThickness+startOffsetX,y+borderThickness+((i-1)*(spaceBetweenEntries+entryHeight))+startOffsetY,currentTextColor,currentBGColor,navigationMenuID,"navigationMenu","entry:"..(k+1)..":"..i)
4189 end
4190
4191 if highlightIDs[k+1]~=nil then
4192 x = x + borderThickness + entryWidth
4193 y = nextY
4194 subTable = subTable[highlightIDs[k+1]]["submenu"]
4195 end
4196 end
4197 end
4198 end
4199end
4200
4201--colorPickers from here
4202--all props: selection,borderColor,borderThickness,colorWidth,colorHeight,selectionCharacter,onChangeFunction,visible,enabled
4203function addColorPicker(id,default)
4204 if trackID(id) then
4205 colorPickers[id] = {}
4206 colorPickers[id]["selection"] = default
4207 colorPickers[id]["visible"] = true
4208 colorPickers[id]["enabled"] = true
4209 writeToLog("Added colorPicker "..id..".",2)
4210 else
4211 writeToLog("Did not add colorPicker because of ID conflict.",3)
4212 end
4213end
4214
4215function writeColorPickerToPixelMatrix(screenID,colorPickerID,x,y)
4216 data = colorPickers[colorPickerID]
4217
4218 local selection = data["selection"]
4219 local colorWidth
4220 local colorHeight
4221 local borderColor
4222 local borderThickness
4223 local selectionCharacter
4224
4225 if data["colorWidth"]~=nil then
4226 colorWidth = data["colorWidth"]
4227 else
4228 colorWidth = 1
4229 end
4230
4231 if data["colorHeight"]~=nil then
4232 colorHeight = data["colorHeight"]
4233 else
4234 colorHeight = 1
4235 end
4236
4237 if data["borderColor"]~=nil then
4238 borderColor = data["borderColor"]
4239 else
4240 borderColor = screens[screenID]["defaultBGColor"]
4241 end
4242
4243 if data["borderThickness"]~=nil then
4244 borderThickness = data["borderThickness"]
4245 else
4246 borderThickness = 0
4247 end
4248
4249 if data["selectionCharacter"]~=nil then
4250 selectionCharacter = string.sub(data["selectionCharacter"],1,1)
4251 else
4252 selectionCharacter = "X"
4253 end
4254
4255 local maxX = x + borderThickness*2 + 4*colorWidth -1
4256 local maxY = y + borderThickness*2 + 4*colorHeight -1
4257
4258 --border
4259 for currentOffset=0,borderThickness-1 do
4260 --this draws two horizontal lines
4261 for currentX=(x+currentOffset),(maxX-currentOffset) do
4262 writeToPixelMatrix(screenID," ",currentX,y+currentOffset,borderColor,borderColor,colorPickerID,"colorPicker","border")
4263 writeToPixelMatrix(screenID," ",currentX,maxY-currentOffset,borderColor,borderColor,colorPickerID,"colorPicker","border")
4264 end
4265
4266 --this draws two vertical lines to finish the border,offset by one because those spaces are already drawn
4267 for currentY=(y+currentOffset+1),(maxY-currentOffset-1) do
4268 writeToPixelMatrix(screenID," ",x+currentOffset,currentY,borderColor,borderColor,colorPickerID,"colorPicker","border")
4269 writeToPixelMatrix(screenID," ",maxX-currentOffset,currentY,borderColor,borderColor,colorPickerID,"colorPicker","border")
4270 end
4271 end
4272
4273 for i=0,3 do
4274 for j=1,4 do
4275 local text = " "
4276 if selection==colorsArrayNumToNum[i*4+j] then
4277 text = selectionCharacter
4278 end
4279 local s = ""
4280 for h=1,colorWidth do
4281 s = s.. text
4282 end
4283
4284 for k=1,colorHeight do
4285 if selection==colors.black then
4286 writeToPixelMatrix(screenID,s,x+borderThickness+i*colorWidth,y+borderThickness+(j-1)*colorHeight+k-1,colors.white,colorsArrayNumToNum[i*4+j],colorPickerID,"colorPicker",colorsArrayNumToNum[i*4+j])
4287 else
4288 writeToPixelMatrix(screenID,s,x+borderThickness+i*colorWidth,y+borderThickness+(j-1)*colorHeight+k-1,colors.black,colorsArrayNumToNum[i*4+j],colorPickerID,"colorPicker",colorsArrayNumToNum[i*4+j])
4289 end
4290 end
4291 end
4292 end
4293end
4294
4295--Progressbars from here
4296-- all properties: length, value, valueType, broadness, orientation, textPosition, textMargin, color, colorsArray, BGColor, borderColor, borderThickness, visible
4297function addProgressBar(id,length)
4298 if trackID(id) then
4299 progressBars[id] = {}
4300 progressBars[id]["length"] = length
4301 progressBars[id]["visible"] = true
4302 writeToLog("Added progressBar "..id..".",2)
4303 else
4304 writeToLog("Did not add progressBar because of ID conflict.",3)
4305 end
4306end
4307
4308function writeProgressBarToPixelMatrix(screenID,progressBarID,x,y)
4309 data = progressBars[progressBarID]
4310
4311 local length = data["length"]
4312 local value = data["value"]
4313 local valueType
4314 local broadness
4315 local orientation
4316 local color
4317 local colorsArray
4318 local textPosition = data["textPosition"]
4319 local textMargin
4320 local BGColor
4321 local borderColor
4322 local borderThickness
4323
4324 --take care of all variable defaults
4325 if value==nil then
4326 value = 0
4327 end
4328
4329 if data["valueType"]~=nil then
4330 valueType = data["valueType"]
4331 else
4332 valueType = "absolute"
4333 end
4334
4335 local originalValue = value
4336 if valueType == "relative" then
4337 value = math.floor((length/100)*value)
4338 end
4339
4340 if data["broadness"]~=nil then
4341 broadness = data["broadness"]
4342 else
4343 broadness = 1
4344 end
4345
4346 if data["orientation"]~=nil then
4347 orientation = data["orientation"]
4348 else
4349 orientation = "left-right"
4350 end
4351
4352 if data["color"]~=nil then
4353 color = data["color"]
4354 else
4355 color = screens[screenID]["defaultTextColor"]
4356 end
4357
4358 if data["colorsArray"]~=nil then
4359 color = data["colorsArray"][value]
4360 end
4361
4362 if data["textMargin"]~=nil then
4363 textMargin = data["textMargin"]
4364 else
4365 textMargin = 0
4366 end
4367
4368 if data["BGColor"]~=nil then
4369 BGColor = data["BGColor"]
4370 else
4371 BGColor = screens[screenID]["defaultBGColor"]
4372 end
4373
4374 if data["borderColor"]~=nil then
4375 borderColor = data["borderColor"]
4376 else
4377 borderColor = color
4378 end
4379
4380 if data["borderThickness"]~=nil then
4381 borderThickness = data["borderThickness"]
4382 else
4383 borderThickness = 1
4384 end
4385
4386 local maxX
4387 local maxY
4388
4389 --calculate maxX and maxY based on the orientation of progressBar
4390 if orientation=="left-right" or orientation=="right-left" then
4391 maxX = x + borderThickness*2 + length - 1
4392 maxY = y + borderThickness*2 + broadness - 1
4393 else
4394 maxX = x + borderThickness*2 + broadness - 1
4395 maxY = y + borderThickness*2 + length - 1
4396 end
4397
4398 --start drawing
4399 --border
4400 for currentOffset=0,borderThickness-1 do
4401 --this draws two horizontal lines
4402 for currentX=(x+currentOffset),(maxX-currentOffset) do
4403 writeToPixelMatrix(screenID," ",currentX,y+currentOffset,color,borderColor,progressBarID,"progressBar","border")
4404 writeToPixelMatrix(screenID," ",currentX,maxY-currentOffset,color,borderColor,progressBarID,"progressBar","border")
4405 end
4406
4407 --this draws two vertical lines to finish the border,offset by one because those spaces are already drawn
4408 for currentY=(y+currentOffset+1),(maxY-currentOffset-1) do
4409 writeToPixelMatrix(screenID," ",x+currentOffset,currentY,color,borderColor,progressBarID,"progressBar","border")
4410 writeToPixelMatrix(screenID," ",maxX-currentOffset,currentY,color,borderColor,progressBarID,"progressBar","border")
4411 end
4412 end
4413
4414 --draw bar case horizontal
4415 if orientation=="left-right" or orientation=="right-left" then
4416 --this makes things easier
4417 local s = " "
4418
4419 --loop for x coordinate (length)
4420 for i=1,length do
4421 --change color according to slider value
4422 --check mode
4423 local currentColor
4424 if i<=value then
4425 currentColor = color
4426 else
4427 currentColor = BGColor
4428 end
4429 --loop for y coordinate (broadness)
4430 for currentY=y+borderThickness,maxY-borderThickness do
4431 --take pixelsPerUnit into account for calculations
4432 if orientation=="left-right" then
4433 writeToPixelMatrix(screenID,s,x+borderThickness+(i-1),currentY,currentColor,currentColor,progressBarID,"progressBar","bar:"..i)
4434 end
4435 if orientation=="right-left" then
4436 writeToPixelMatrix(screenID,s,maxX-borderThickness-(i-1),currentY,currentColor,currentColor,progressBarID,"progressBar","bar:"..i)
4437 end
4438 end
4439 end
4440 else
4441 --this makes things easier
4442 local s = ""
4443 for i=1,broadness do
4444 s = s.." "
4445 end
4446 --draw bar case vertical
4447 --loop for y coordinate (length)
4448 for i=1,length do
4449 local currentColor
4450 if i<=value then
4451 currentColor = color
4452 else
4453 currentColor = BGColor
4454 end
4455 if orientation=="top-bottom" then
4456 writeToPixelMatrix(screenID,s,x+borderThickness,y+borderThickness+(i-1),currentColor,currentColor,progressBarID,"progressBar","bar:"..i)
4457 end
4458 if orientation=="bottom-top" then
4459 writeToPixelMatrix(screenID,s,x+borderThickness,maxY-borderThickness-(i-1),currentColor,currentColor,progressBarID,"progressBar","bar:"..i)
4460 end
4461 end
4462 end
4463
4464 value = originalValue
4465 if valueType == "relative" then
4466 value = value .."%"
4467 end
4468 --draw text
4469 if textPosition~=nil then
4470 --calculations to center the text
4471 if textPosition=="right" then
4472 writeToPixelMatrix(screenID,value,maxX+1+textMargin,y+math.floor((maxY-y+1-1)/2),color,screens[screenID]["defaultBGColor"],progressBarID,"progressBar","value")
4473 end
4474 if textPosition=="left" then
4475 writeToPixelMatrix(screenID,value,x-string.len(value)-textMargin,y+math.floor((maxY-y+1-1)/2),color,screens[screenID]["defaultBGColor"],progressBarID,"progressBar","value")
4476 end
4477 if textPosition=="top" then
4478 writeToPixelMatrix(screenID,value,x+math.floor((maxX-x+1-string.len(value))/2),y-1-textMargin,color,screens[screenID]["defaultBGColor"],progressBarID,"progressBar","value")
4479 end
4480 if textPosition=="bottom" then
4481 writeToPixelMatrix(screenID,value,x+math.floor((maxX-x+1-string.len(value))/2),maxY+1+textMargin,color,screens[screenID]["defaultBGColor"],progressBarID,"progressBar","value")
4482 end
4483 end
4484end
4485
4486--coordinateSystems from here
4487-- all props: width,height,graphTables,graphDesigns(color,BGColor,character),unitsPerPixelX,unitsPerPixelY,axesColor,numbersColor,labelX,labelY,startX,startY,stepsX,stepsY
4488function addCoordinateSystem(id,width,height)
4489 if trackID(id) then
4490 coordinateSystems[id] = {}
4491 coordinateSystems[id]["width"] = width
4492 coordinateSystems[id]["height"] = height
4493 coordinateSystems[id]["visible"] = true
4494 writeToLog("Added coordinateSystem "..id..".",2)
4495 else
4496 writeToLog("Did not add coordinateSystem because of ID conflict.",3)
4497 end
4498end
4499
4500function writeCoordinateSystemToPixelMatrix(screenID,coordinateSystemID,x,y)
4501 data = coordinateSystems[coordinateSystemID]
4502
4503 local width = data["width"]
4504 local height = data["height"]
4505 local graphTables = data["graphTables"]
4506 local graphDesigns = data["graphDesigns"]
4507 local unitsPerPixelX
4508 local unitsPerPixelY
4509 local axesColor
4510 local numbersColor
4511 local labelX
4512 local labelY
4513 local startX
4514 local startY
4515 local numbersOffset
4516 local stepX = data["stepX"]
4517 local stepY
4518
4519 if data["stepY"]~=nil then
4520 stepY = data["stepY"]
4521 else
4522 stepY = 2
4523 end
4524
4525 if data["unitsPerPixelX"]~=nil then
4526 unitsPerPixelX = data["unitsPerPixelX"]
4527 else
4528 unitsPerPixelX = 1
4529 end
4530
4531 if data["unitsPerPixelY"]~=nil then
4532 unitsPerPixelY = data["unitsPerPixelY"]
4533 else
4534 unitsPerPixelY = 1
4535 end
4536
4537 if data["axesColor"]~=nil then
4538 axesColor = data["axesColor"]
4539 else
4540 axesColor = screens[screenID]["defaultTextColor"]
4541 end
4542
4543 if data["numbersColor"]~=nil then
4544 numbersColor = data["numbersColor"]
4545 else
4546 numbersColor = screens[screenID]["defaultTextColor"]
4547 end
4548
4549 if data["labelX"]~=nil then
4550 labelX = data["labelX"]
4551 else
4552 labelX = "X"
4553 end
4554
4555 if data["labelY"]~=nil then
4556 labelY = data["labelY"]
4557 else
4558 labelY = "Y"
4559 end
4560
4561 if data["startX"]~=nil then
4562 startX = data["startX"]
4563 else
4564 startX = 0
4565 end
4566
4567 if data["startY"]~=nil then
4568 startY = data["startY"]
4569 else
4570 startY = 0
4571 end
4572
4573 if data["numbersOffset"]~=nil then
4574 numbersOffset = data["numbersOffset"]
4575 else
4576 numbersOffset = 0
4577 end
4578
4579 --draw coordinateSystem
4580 --draw origin
4581 writeToPixelMatrix(screenID,"+",x,y,axesColor,screens[screenID]["defaultBGColor"],coordinateSystemID,"coordinateSystem","axisOrigin")
4582
4583 --draw start numbers around origin
4584 if startX == startY then
4585 writeToPixelMatrix(screenID,tostring(startX),x-string.len(startX)-numbersOffset,y+1+numbersOffset,numbersColor,screens[screenID]["defaultBGColor"],coordinateSystemID,"coordinateSystem","numberOriginXY")
4586 else
4587 writeToPixelMatrix(screenID,tostring(startX),x-math.floor(string.len(startX)/2),y+1+numbersOffset,numbersColor,screens[screenID]["defaultBGColor"],coordinateSystemID,"coordinateSystem","numberOriginX")
4588 writeToPixelMatrix(screenID,tostring(startY),x-string.len(startY)-numbersOffset,y,numbersColor,screens[screenID]["defaultBGColor"],coordinateSystemID,"coordinateSystem","numberOriginY")
4589 end
4590
4591 --draw axes
4592 for i=1,width-2 do
4593 writeToPixelMatrix(screenID,"-",x+i,y,axesColor,screens[screenID]["defaultBGColor"],coordinateSystemID,"coordinateSystem","axisX")
4594 end
4595 writeToPixelMatrix(screenID,">",x+width-1,y,axesColor,screens[screenID]["defaultBGColor"],coordinateSystemID,"coordinateSystem","axisXEnd")
4596
4597 for i=1,height-2 do
4598 writeToPixelMatrix(screenID,"|",x,y-i,axesColor,screens[screenID]["defaultBGColor"],coordinateSystemID,"coordinateSystem","axisY")
4599 end
4600 writeToPixelMatrix(screenID,"^",x,y-height+1,axesColor,screens[screenID]["defaultBGColor"],coordinateSystemID,"coordinateSystem","axisY")
4601
4602 --draw numbers
4603 if stepX==nil then
4604 local greatestTextLength = string.len(startX)
4605 if string.len(startX + (width-1)*unitsPerPixelX)>greatestTextLength then
4606 greatestTextLength = string.len(startX + (width-1)*unitsPerPixelX)
4607 end
4608 stepX = greatestTextLength + 1
4609 end
4610
4611 local currentX = x+stepX
4612 local currentValue = startX+(stepX*unitsPerPixelX)
4613 local maxX = x + width-1
4614 while currentX<maxX do
4615 writeToPixelMatrix(screenID,"+",currentX,y,axesColor,screens[screenID]["defaultBGColor"],coordinateSystemID,"coordinateSystem","axisX")
4616
4617 writeToPixelMatrix(screenID,tostring(currentValue),currentX-math.floor(string.len(currentValue)/2),y+1+numbersOffset,numbersColor,screens[screenID]["defaultBGColor"],coordinateSystemID,"coordinateSystem","numbersX")
4618
4619 currentX = currentX + stepX
4620 currentValue = currentValue + (stepX*unitsPerPixelX)
4621 end
4622
4623 local currentY = y-stepY
4624 local currentValue = startY+(stepY*unitsPerPixelY)
4625 local maxY = y - height+1
4626 while currentY>maxY do
4627 writeToPixelMatrix(screenID,"+",x,currentY,axesColor,screens[screenID]["defaultBGColor"],coordinateSystemID,"coordinateSystem","axisY")
4628
4629 writeToPixelMatrix(screenID,tostring(currentValue),x-numbersOffset-string.len(currentValue),currentY,numbersColor,screens[screenID]["defaultBGColor"],coordinateSystemID,"coordinateSystem","numbersY")
4630
4631 currentY = currentY - stepY
4632 currentValue = currentValue + (stepY*unitsPerPixelY)
4633 end
4634
4635 --draw labels
4636 writeToPixelMatrix(screenID,labelX,x+width-math.floor(string.len(labelX)/2)-1,y+1+numbersOffset,numbersColor,screens[screenID]["defaultBGColor"],coordinateSystemID,"coordinateSystem","labelX")
4637 writeToPixelMatrix(screenID,labelY,x-string.len(labelY)-numbersOffset,y-height+1,numbersColor,screens[screenID]["defaultBGColor"],coordinateSystemID,"coordinateSystem","labelY")
4638
4639 --draw graphs
4640 if graphTables~=nil then
4641 for i,graph in ipairs(graphTables) do
4642 local color = numbersColor
4643 local BGColor = screens[screenID]["defaultBGColor"]
4644 local character = "X"
4645 if graphDesigns~=nil then
4646 if graphDesigns[i]~=nil then
4647 if graphDesigns[i]["color"]~=nil then
4648 color = graphDesigns[i]["color"]
4649 end
4650 if graphDesigns[i]["BGColor"]~=nil then
4651 BGColor = graphDesigns[i]["BGColor"]
4652 end
4653 if graphDesigns[i]["character"]~=nil then
4654 character = graphDesigns[i]["character"]
4655 end
4656 end
4657 end
4658
4659 for currentX=x,maxX do
4660 if graph[((currentX-x)*unitsPerPixelX)+startX]~=nil then
4661 if y-math.floor((graph[((currentX-x)*unitsPerPixelX)+startX]-startY)/unitsPerPixelY+0.5)>=y-height+1 and y-math.floor((graph[((currentX-x)*unitsPerPixelX)+startX]-startY)/unitsPerPixelY+0.5)<=y then
4662 writeToPixelMatrix(screenID,character,currentX,y-math.floor((graph[((currentX-x)*unitsPerPixelX)+startX]-startY)/unitsPerPixelY+0.5),color,BGColor,coordinateSystemID,"coordinateSystem","graph:"..i)
4663 end
4664 end
4665 end
4666 end
4667 end
4668end
4669
4670--pictures from here
4671-- all props: linesArray
4672function addPicture(id,width,height,linesArray)
4673 if trackID(id) then
4674 pictures[id] = {}
4675 pictures[id]["width"] = width
4676 pictures[id]["height"] = height
4677 pictures[id]["linesArray"] = linesArray
4678 pictures[id]["visible"] = true
4679 writeToLog("Added picture "..id..".",2)
4680 else
4681 writeToLog("Did not add picture because of ID conflict.",3)
4682 end
4683end
4684
4685function writePictureToPixelMatrix(screenID,pictureID,x,y)
4686 data = pictures[pictureID]
4687 colorsArrayStrToNum["*"]=screens[screenID]["defaultTextColor"]
4688 colorsArrayStrToNum["#"]=screens[screenID]["defaultBGColor"]
4689
4690 local linesArray = data["linesArray"]
4691 local width = data["width"]
4692 local height = data["height"]
4693
4694 for i=1,height do
4695 local j = 1
4696 local line = linesArray[i]
4697 local correct = true
4698 if line~=nil then
4699 while string.find(line,";")~=nil do
4700 local currentLetter = string.sub(line,1,string.find(line,";")-1)
4701 line = string.sub(line,string.find(line,";")+1)
4702
4703 if string.len(currentLetter)==5 and string.sub(currentLetter,2,2)==":" and string.sub(currentLetter,4,4)==":" then
4704 local textColor = string.sub(currentLetter,1,1)
4705 local BGColor = string.sub(currentLetter,3,3)
4706 local character = string.sub(currentLetter,5,5)
4707
4708 writeToPixelMatrix(screenID,character,x+j-1,y+i-1,colorsArrayStrToNum[textColor],colorsArrayStrToNum[BGColor],pictureID,"picture",j..":"..i)
4709 end
4710
4711 if string.len(currentLetter)==1 then
4712 writeToPixelMatrix(screenID," ",x+j-1,y+i-1,colorsArrayStrToNum[currentLetter],colorsArrayStrToNum[currentLetter],pictureID,"picture",j..":"..i)
4713 end
4714
4715 if j == width then correct = false break end
4716 j = j + 1
4717 end
4718 else
4719 linesArray[i] = ""
4720 end
4721 --correct mistakes
4722 if correct then
4723 for k=1,width-j+1 do
4724 linesArray[i] = linesArray[i].."#;"
4725 end
4726 end
4727 end
4728end
4729
4730function addElement(ID,type_,arg1,arg2,arg3,arg4,arg5)
4731 local success,msg = pcall(addingFunctions["type_"],ID,arg1,arg2,arg3,arg4,arg5)
4732 return success
4733end
4734
4735--initalizing function searching for all monitors and adding them
4736function findMonitors()
4737 local nMonitorCount = 0
4738 monitors = {}
4739 writeToLog("Searching for monitors...",2)
4740 designerScreen = initMonsSID
4741 setScreenToRenderOnTerminal(initMonsSID)
4742 refresh()
4743 local sides = {"front","back","left","right","top","bottom"}
4744 --search for monitors and modems
4745 for i,side in ipairs(sides) do
4746 --check if there is a monitor
4747 if peripheral.isPresent(side) then
4748 if peripheral.getType(side)=="monitor" then
4749 --check if monitor is advanced
4750 if peripheral.call(side,"isColor") then
4751 -- initialize monitor
4752 monitor = peripheral.wrap(side)
4753 monitor.setBackgroundColor(colors.red)
4754 monitor.clear()
4755 changeProperty(initMonsSTextID,"content","Advanced monitor number "..(nMonitorCount+1).." was found on side "..side..". It has turned completely red for your identification. Please give this monitor a unique ID!")
4756
4757 writeToLog("Found monitor on side "..side..".",2)
4758 local sID
4759 local success = false
4760 repeat
4761 refresh()
4762 local x,y = term.getSize()
4763 term.setCursorPos(relX(20,initMonsSID)+2,y-1)
4764 term.setTextColor(colorPalette[1])
4765 term.write(">")
4766 sID = read()
4767 term.setCursorPos(relX(20,initMonsSID)+3,y-1)
4768 for i=1,string.len(sID) do
4769 term.write(" ")
4770 end
4771 if sID=="" then
4772 changeProperty(initMonsSErrorID,"content","Cannot be empty!")
4773 refresh()
4774 else
4775 if trackID(sID) then
4776 success = true
4777 else
4778 changeProperty(initMonsSErrorID,"content","ID already taken!")
4779 refresh()
4780 end
4781 end
4782 until success==true
4783 monitors[sID] = {}
4784 monitors[sID]["peripheral"] = monitor
4785 monitors[sID]["side"] = side
4786 monitors[sID]["networkID"] = "NONE"
4787 monitor.setBackgroundColor(colors.black)
4788 monitor.clear()
4789 nMonitorCount = nMonitorCount + 1
4790 writeToLog("Added monitor "..sID.." to the system.",2)
4791 changeProperty(initMonsSErrorID,"content","")
4792 end
4793 else
4794 --check monitors connected via modems
4795 if peripheral.getType(side)=="modem" then
4796 local modem = peripheral.wrap(side)
4797 if not modem.isWireless() then
4798 for i,sPeripheral in ipairs(modem.getNamesRemote()) do
4799 if string.match(sPeripheral,"monitor") then
4800 if modem.callRemote(sPeripheral,"isColor") then
4801 -- initialize monitor
4802 monitor = peripheral.wrap(sPeripheral)
4803 monitor.setBackgroundColor(colors.red)
4804 monitor.clear()
4805 changeProperty(initMonsSTextID,"content","Advanced monitor number "..(nMonitorCount+1).." was found via modem on side "..side..". It has turned red for your identification. Please give this monitor a unique ID!")
4806
4807 writeToLog("Found monitor on side "..side.." through modem.",2)
4808 local sID
4809 local success = false
4810 repeat
4811 refresh()
4812 local x,y = term.getSize()
4813 term.setCursorPos(relX(20,initMonsSID)+2,y-1)
4814 term.setTextColor(colorPalette[1])
4815 term.write(">")
4816 sID = read()
4817 term.setCursorPos(relX(20,initMonsSID)+3,y-1)
4818 for i=1,string.len(sID) do
4819 term.write(" ")
4820 end
4821 if sID=="" then
4822 changeProperty(initMonsSErrorID,"content","Cannot be empty!")
4823 refresh()
4824 else
4825 if trackID(sID) then
4826 success = true
4827 else
4828 changeProperty(initMonsSErrorID,"content","ID already taken!")
4829 refresh()
4830 end
4831 end
4832 until success==true
4833 monitors[sID] = {}
4834 monitors[sID]["peripheral"] = monitor
4835 monitors[sID]["side"] = side
4836 monitors[sID]["networkID"] = sPeripheral
4837 monitor.setBackgroundColor(colors.black)
4838 monitor.clear()
4839 nMonitorCount = nMonitorCount + 1
4840 writeToLog("Added monitor "..sID.." to the system.",2)
4841 changeProperty(initMonsSErrorID,"content","")
4842 end
4843 end
4844 end
4845 end
4846 end
4847 end
4848 end
4849 end
4850
4851 if nMonitorCount == 0 then
4852 writeToLog("Did not find any advanced monitors.",2)
4853 else
4854 writeToLog("Found "..nMonitorCount.." monitors.",2)
4855 end
4856end
4857
4858function setupStuff()
4859 local x,y = term.getSize()
4860 addScreen(initMonsSID,x,y,colorPalette[1],colorPalette[2])
4861 addDynamicTextBox(initMonsSLeftRectID,"")
4862 changeProperty(initMonsSLeftRectID,"width",relX(20,initMonsSID))
4863 changeProperty(initMonsSLeftRectID,"height",relY(100,initMonsSID))
4864 changeProperty(initMonsSLeftRectID,"BGColor",colorPalette[3])
4865 addElementToScreen(initMonsSLeftRectID,initMonsSID,1,1)
4866
4867 addDynamicTextBox(initMonsSHeadingID,"EasyGUI §?Monitor §-Initialization")
4868 changeProperty(initMonsSHeadingID,"width",relX(80,initMonsSID))
4869 changeProperty(initMonsSHeadingID,"borderThickness",1)
4870 addElementToScreen(initMonsSHeadingID,initMonsSID,relX(20,initMonsSID)+1,1)
4871
4872 addDynamicTextBox(initMonsSTextID,"Searching for §?monitors§-...")
4873 changeProperty(initMonsSTextID,"width",relX(80,initMonsSID))
4874 changeProperty(initMonsSTextID,"borderThickness",1)
4875 addElementToScreen(initMonsSTextID,initMonsSID,relX(20,initMonsSID)+1,relY(30,initMonsSID))
4876
4877 local picArray = {}
4878 for i=1,y do
4879 if (i%3)==1 then
4880 table.insert(picArray,"*;;;")
4881 end
4882 if (i%3)==2 then
4883 table.insert(picArray,";*;;")
4884 end
4885 if (i%3)==0 then
4886 table.insert(picArray,";;*;")
4887 end
4888 end
4889 addPicture(initMonsSPictureID,3,y,picArray)
4890 addElementToScreen(initMonsSPictureID,initMonsSID,relX(10,initMonsSID)-1,1)
4891
4892 addDynamicTextBox(initMonsSErrorID,"")
4893 changeProperty(initMonsSErrorID,"width",relX(80,initMonsSID))
4894 changeProperty(initMonsSErrorID,"textColor",colors.red)
4895 addElementToScreen(initMonsSErrorID,initMonsSID,relX(20,initMonsSID)+1,y)
4896
4897 addScreen(helpSID,x,y,colorPalette[1],colorPalette[3])
4898 addDynamicTextBox(helpSBorderID,"")
4899 changeProperty(helpSBorderID,"width",x-2)
4900 changeProperty(helpSBorderID,"height",y-2)
4901 changeProperty(helpSBorderID,"borderThickness",1)
4902 changeProperty(helpSBorderID,"textAlignmentHorizontal","left")
4903 changeProperty(helpSBorderID,"textAlignmentVertical","top")
4904 changeProperty(helpSBorderID,"BGColor",colorPalette[2])
4905 addElementToScreen(helpSBorderID,helpSID,2,2)
4906
4907 addDynamicTextBox(helpSOKID,"Okay")
4908 changeProperty(helpSOKID,"BGColor",colorPalette[1])
4909 changeProperty(helpSOKID,"textColor",colorPalette[2])
4910 changeProperty(helpSOKID,"onClickMode","flash")
4911 changeProperty(helpSOKID,"onActiveFunction",function()
4912 setScreenToRenderOnTerminal(designerScreen)
4913 fullRefresh()
4914 end)
4915 addElementToScreen(helpSOKID,helpSID,relX(50,initMonsSID),y-3)
4916end
4917
4918function setDesignerScreen(ID)
4919 designerScreen = ID
4920 if designerMonitor==terminalID then
4921 setScreenToRenderOnTerminal(ID)
4922 else
4923 setScreenToRenderOnMon(ID,designerMonitor,tonumber(getProperty(changeMonSScaleDDID,"entries")[getProperty(changeMonSScaleDDID,"selectionID")]),0,0)
4924 end
4925end
4926
4927function transferDesigner()
4928 local array = {"term"}
4929 for name,data in pairs(monitors) do
4930 table.insert(array,name)
4931 end
4932 if table.getn(array)~=1 then
4933 local x,y = term.getSize()
4934 addScreen(changeMonSID,x,y,colorPalette[1],colorPalette[2])
4935 setScreenToRenderOnTerminal(changeMonSID)
4936 designerScreen = changeMonSID
4937 addElementToScreen(initMonsSLeftRectID,changeMonSID,1,1)
4938 addElementToScreen(initMonsSPictureID,changeMonSID,relX(10,changeMonSID)-1,1)
4939 changeProperty(initMonsSHeadingID,"content","EasyGUI Designer §?transfer§-")
4940 addElementToScreen(initMonsSHeadingID,changeMonSID,relX(20,changeMonSID)+1,1)
4941 changeProperty(initMonsSTextID,"content","Would you like to §?transfer §-the designer on a §?monitor§-? You can also adjust §?textScale§-.")
4942 addElementToScreen(initMonsSTextID,changeMonSID,relX(20,changeMonSID)+1,relY(30,changeMonSID))
4943
4944 addDropDownMenu(changeMonSScaleDDID,{"0.5","1","1.5","2"},1)
4945 changeProperty(changeMonSScaleDDID,"borderThickness",1)
4946 changeProperty(changeMonSScaleDDID,"borderColor",colorPalette[3])
4947 changeProperty(changeMonSScaleDDID,"highlightTextColor",colorPalette[2])
4948 changeProperty(changeMonSScaleDDID,"highlightBGColor",colorPalette[1])
4949 changeProperty(changeMonSScaleDDID,"width",relX(40,changeMonSID)-2)
4950 addElementToScreen(changeMonSScaleDDID,changeMonSID,relX(20,changeMonSID)+2,relY(70,changeMonSID)+2)
4951
4952 addDropDownMenu(changeMonSDDMenuID,array,1)
4953 changeProperty(changeMonSDDMenuID,"borderThickness",1)
4954 changeProperty(changeMonSDDMenuID,"borderColor",colorPalette[3])
4955 changeProperty(changeMonSDDMenuID,"highlightTextColor",colorPalette[2])
4956 changeProperty(changeMonSDDMenuID,"highlightBGColor",colorPalette[1])
4957 changeProperty(changeMonSDDMenuID,"width",relX(40,changeMonSID)-2)
4958 addElementToScreen(changeMonSDDMenuID,changeMonSID,relX(20,changeMonSID)+2,relY(70,changeMonSID)-2)
4959
4960 addDynamicTextBox(changeMonSApplyID,"Apply")
4961 changeProperty(changeMonSApplyID,"width",relX(40,changeMonSID)-2)
4962 changeProperty(changeMonSApplyID,"textColor",colorPalette[3])
4963 changeProperty(changeMonSApplyID,"BGColor",colorPalette[1])
4964 changeProperty(changeMonSApplyID,"borderThickness",1)
4965 changeProperty(changeMonSApplyID,"onClickMode","flash")
4966 changeProperty(changeMonSApplyID,"onActiveFunction",function()
4967 os.queueEvent("easygui_interrupt") end)
4968 addElementToScreen(changeMonSApplyID,changeMonSID,relX(60,changeMonSID)+2,relY(70,changeMonSID))
4969
4970 run()
4971
4972 if getProperty(changeMonSDDMenuID,"selectionID")==1 then
4973 designerMonitor = terminalID
4974 else
4975 designerMonitor = array[getProperty(changeMonSDDMenuID,"selectionID")]
4976 end
4977 else
4978 designerMonitor = terminalID
4979 end
4980end
4981
4982function onLoadScreensS()
4983 tryLoadAllScreens()
4984 local array = {}
4985 for name,data in pairs(screens) do
4986 if string.len(name)<32 then
4987 table.insert(array,name)
4988 end
4989 end
4990 if table.getn(array)~=0 then
4991 changeProperty(screensSDDMenuID,"entries",array)
4992 else
4993 changeProperty(screensSButton2ID,"visible",false)
4994 changeProperty(screensSDDMenuID,"visible",false)
4995 end
4996end
4997
4998function onLoadElementsS()
4999 tryLoadAllElements()
5000 local array = {}
5001 for name,data in pairs(elements) do
5002 for name2,data2 in pairs(elements[name]) do
5003 if string.len(name2)<32 then
5004 table.insert(array,name2)
5005 end
5006 end
5007 end
5008 if table.getn(array)~=0 then
5009 changeProperty(elementsSDDMenu2ID,"entries",array)
5010 else
5011 changeProperty(elementsSButton2ID,"visible",false)
5012 changeProperty(elementsSDDMenu2ID,"visible",false)
5013 end
5014end
5015
5016function newElement(type_)
5017 local ID = nil
5018
5019 changeProperty(elementsSButton1ID,"visible",false)
5020 changeProperty(elementsSButton2ID,"visible",false)
5021 changeProperty(elementsSDDMenu1ID,"visible",false)
5022 changeProperty(elementsSDDMenu2ID,"visible",false)
5023 changeProperty(screensSButton3ID,"visible",false)
5024 changeProperty(screensSMsgID,"visible",true)
5025 refresh()
5026 term.setTextColor(colorPalette[1])
5027 term.setBackgroundColor(colorPalette[2])
5028 term.clear()
5029 term.setCursorPos(1,1)
5030 print("Please enter an unique ID for the new element:")
5031 repeat
5032 local input = read()
5033 if input~="" and input~=nil then
5034 if string.len(input)<32 then
5035 if not IDExists(input) then
5036 ID = input
5037 else
5038 print("ID already taken!")
5039 end
5040 else
5041 print("Must be less than 32 characters!")
5042 end
5043 else
5044 print("Cannot be an empty string.")
5045 end
5046 until ID~=nil
5047
5048 changeProperty(elementsSButton1ID,"visible",true)
5049 changeProperty(elementsSButton2ID,"visible",true)
5050 changeProperty(elementsSDDMenu1ID,"visible",true)
5051 changeProperty(elementsSDDMenu2ID,"visible",true)
5052 changeProperty(screensSButton3ID,"visible",true)
5053 changeProperty(screensSMsgID,"visible",false)
5054 fullRefresh()
5055
5056 elements[type_][ID] = {["enabled"]=true,["visible"]=true,["expanded"]=false}
5057
5058 for name,data in pairs(elementProperties[type_]) do
5059 if data["essential"] then
5060 changeProperty(ID,name,data["default"])
5061 end
5062 end
5063 return ID,type_
5064end
5065
5066function startEditor(ID,type_)
5067 editorSElementID = ID
5068 editorSElementType = type_
5069 saveElement(editorSElementID,editorSElementType)
5070 lastSave = os.clock()
5071 saveTimerID = os.startTimer(180)
5072 setProcessEventFunction(processEditorEvents)
5073 term.setTextColor(colorPalette[1])
5074 term.setBackgroundColor(colorPalette[2])
5075 term.clear()
5076 term.setCursorPos(1,1)
5077 term.write("EasyGUI Editor running on monitor.")
5078 addScreen(editorSID,designerX,designerY,colorPalette[1],colorPalette[2])
5079 addElementToScreen(editorSElementID,editorSID,relX(20,editorSID),relY(20,editorSID))
5080 editorSElementX = relX(20,editorSID)
5081 editorSElementY = relY(20,editorSID)
5082 undoRedoTable = {}
5083 undoRedoIndex = 0
5084
5085 addDynamicTextBox(editorSRelocateButtonID,"§?<§-Relocate§?>§-")
5086 changeProperty(editorSRelocateButtonID,"onClickMode","toggle")
5087 changeProperty(editorSRelocateButtonID,"activeTextColor",colorPalette[2])
5088 changeProperty(editorSRelocateButtonID,"activeBGColor",colorPalette[1])
5089 changeProperty(editorSRelocateButtonID,"onActiveFunction",relocateOn)
5090 changeProperty(editorSRelocateButtonID,"onInactiveFunction",relocateOff)
5091 addElementToScreen(editorSRelocateButtonID,editorSID,1,1)
5092
5093 addDynamicTextBox(editorSLastSaveID,"Last save: §?$time §-min ago.")
5094 changeProperty(editorSLastSaveID,"variables",{["time"]=function () return math.floor((os.clock()-lastSave)/60) end})
5095 addElementToScreen(editorSLastSaveID,editorSID,designerX-9,1)
5096
5097 addDynamicTextBox(editorSExitID,"§?<§-Save&Exit§?>§-")
5098 changeProperty(editorSExitID,"onClickMode","flash")
5099 changeProperty(editorSExitID,"onActiveFunction",function() saveElement(editorSElementID,editorSElementType)
5100 lastSave = os.clock()
5101 removeElementFromScreen(editorSElementID,editorSID)
5102 removeElementFromScreen(editorSDescID,editorSID)
5103 removeElementFromScreen(editorSExitID,editorSID)
5104 removeElementFromScreen(editorSHideUIID,editorSID)
5105 removeElementFromScreen(editorSLastSaveID,editorSID)
5106 removeElementFromScreen(editorSPropColorPickID,editorSID)
5107 removeElementFromScreen(editorSPropsID,editorSID)
5108 removeElementFromScreen(editorSPropsMenuID,editorSID)
5109 removeElementFromScreen(editorSRedoID,editorSID)
5110 removeElementFromScreen(editorSRelocateButtonID,editorSID)
5111 removeElementFromScreen(editorSUndoID,editorSID)
5112 removeElementFromScreen(editorSPropResetButtonID,editorSID)
5113 removeElementFromScreen(editorSPropDDMenuID,editorSID)
5114 removeElementFromScreen(editorSPropDisplayID,editorSID)
5115 removeElementFromScreen(editorSPropConsoleInputButtonID,editorSID)
5116 removeElementFromScreen(editorSPropConsoleMsgID,editorSID)
5117 removeElementFromScreen(editorSPropColorsArrayDDID,editorSID)
5118 removeElementFromScreen(editorSPropStringArrayDDID,editorSID)
5119 removeElementFromScreen(editorSPropNavMenuID,editorSID)
5120 removeElementFromScreen(editorSPropNavMenuHintID,editorSID)
5121 removeElementFromScreen(editorSPropCSTableIndexDDID,editorSID)
5122 removeElementFromScreen(editorSPropCSTableDDID,editorSID)
5123 removeElementFromScreen(editorSPropCSChangeID,editorSID)
5124 removeElementFromScreen(editorSPropCSRemoveID,editorSID)
5125 removeElementFromScreen(editorSPropCSDesignsDDID,editorSID)
5126 removeElementFromScreen(editorSPropCSDesignsDisplayID,editorSID)
5127 removeElementFromScreen(editorSPropCSDesignsIndexDDID,editorSID)
5128 removeElementFromScreen(editorSPropPicEditButtonID,editorSID)
5129 setProcessEventFunction(nil)
5130 editorSElementID = nil
5131 setDesignerScreen(elementsSID)
5132 refresh() end)
5133 addElementToScreen(editorSExitID,editorSID,designerX-10,designerY)
5134
5135 addDynamicTextBox(editorSPropsID,"§?<§-Properties§?>§-")
5136 changeProperty(editorSPropsID,"onClickMode","toggle")
5137 changeProperty(editorSPropsID,"activeTextColor",colorPalette[2])
5138 changeProperty(editorSPropsID,"activeBGColor",colorPalette[1])
5139 changeProperty(editorSPropsID,"onActiveFunction",function() changeProperty(editorSPropsMenuID,"visible",true)
5140 changeProperty(editorSDescID,"visible",true)
5141 changeProperty(editorSExitID,"visible",false)
5142 changeProperty(editorSRelocateButtonID,"visible",false)
5143 changeProperty(editorSHideUIID,"visible",false)
5144 refreshPropsMenu()
5145 pcall(getProperty(editorSPropsMenuID,"onChangeFunction")) end)
5146 changeProperty(editorSPropsID,"onInactiveFunction",function() changeProperty(editorSPropsMenuID,"visible",false)
5147 changeProperty(editorSDescID,"visible",false)
5148 changeProperty(editorSRelocateButtonID,"visible",true)
5149 changeProperty(editorSHideUIID,"visible",true)
5150 changeProperty(editorSExitID,"visible",true)
5151 changeProperty(editorSPropColorPickID,"visible",false)
5152 changeProperty(editorSPropResetButtonID,"visible",false)
5153 changeProperty(editorSPropDisplayID,"visible",false)
5154 changeProperty(editorSPropConsoleInputButtonID,"visible",false)
5155 changeProperty(editorSPropDDMenuID,"visible",false)
5156 changeProperty(editorSPropConsoleMsgID,"visible",false)
5157 changeProperty(editorSPropColorsArrayDDID,"visible",false)
5158 changeProperty(editorSPropStringArrayDDID,"visible",false)
5159 changeProperty(editorSPropNavMenuID,"visible",false)
5160 changeProperty(editorSPropNavMenuHintID,"visible",false)
5161 changeProperty(editorSPropCSTableIndexDDID,"visible",false)
5162 changeProperty(editorSPropCSTableDDID,"visible",false)
5163 changeProperty(editorSPropCSChangeID,"visible",false)
5164 changeProperty(editorSPropCSRemoveID,"visible",false)
5165 changeProperty(editorSPropCSDesignsDDID,"visible",false)
5166 changeProperty(editorSPropCSDesignsIndexDDID,"visible",false)
5167 changeProperty(editorSPropCSDesignsDisplayID,"visible",false)
5168 changeProperty(editorSPropPicEditButtonID,"visible",false) end)
5169 addElementToScreen(editorSPropsID,editorSID,1,designerY)
5170
5171 addDynamicTextBox(editorSUndoID,"§?<§-Undo§?>§-")
5172 changeProperty(editorSUndoID,"onClickMode","flash")
5173 changeProperty(editorSUndoID,"activeTextColor",colorPalette[2])
5174 changeProperty(editorSUndoID,"activeBGColor",colorPalette[1])
5175 changeProperty(editorSUndoID,"onActiveFunction",function()
5176 if undoRedoIndex~=0 then
5177 if type(undoRedoTable[undoRedoIndex]["undo"])=="function" then
5178 pcall(undoRedoTable[undoRedoIndex]["undo"],undoRedoTable[undoRedoIndex]["prop"],undoRedoTable[undoRedoIndex]["var1"],undoRedoTable[undoRedoIndex]["var2"],undoRedoTable[undoRedoIndex]["var3"],undoRedoTable[undoRedoIndex]["var4"],undoRedoTable[undoRedoIndex]["var5"])
5179 if getProperty(editorSPropsID,"active") then
5180 pcall(getProperty(editorSPropsMenuID,"onChangeFunction"))
5181 end
5182 onPixelSelecChange()
5183 refresh()
5184 else
5185 changeProperty(editorSElementID,undoRedoTable[undoRedoIndex]["prop"],undoRedoTable[undoRedoIndex]["undo"])
5186 if getProperty(editorSPropsID,"active") then
5187 pcall(getProperty(editorSPropsMenuID,"onChangeFunction"))
5188 end
5189 onPixelSelecChange()
5190 refresh()
5191 end
5192 undoRedoIndex = undoRedoIndex - 1
5193 end
5194 end)
5195 addElementToScreen(editorSUndoID,editorSID,relX(50,editorSID)-6,designerY)
5196
5197 addDynamicTextBox(editorSRedoID,"§?<§-Redo§?>§-")
5198 changeProperty(editorSRedoID,"onClickMode","flash")
5199 changeProperty(editorSRedoID,"activeTextColor",colorPalette[2])
5200 changeProperty(editorSRedoID,"activeBGColor",colorPalette[1])
5201 changeProperty(editorSRedoID,"onActiveFunction",function()
5202 if undoRedoIndex~=table.getn(undoRedoTable) then
5203 undoRedoIndex = undoRedoIndex + 1
5204 if type(undoRedoTable[undoRedoIndex]["redo"])=="function" then
5205 pcall(undoRedoTable[undoRedoIndex]["redo"],undoRedoTable[undoRedoIndex]["prop"],undoRedoTable[undoRedoIndex]["var1"],undoRedoTable[undoRedoIndex]["var2"],undoRedoTable[undoRedoIndex]["var3"],undoRedoTable[undoRedoIndex]["var4"],undoRedoTable[undoRedoIndex]["var5"])
5206 if getProperty(editorSPropsID,"active") then
5207 pcall(getProperty(editorSPropsMenuID,"onChangeFunction"))
5208 end
5209 onPixelSelecChange()
5210 refresh()
5211 else
5212 changeProperty(editorSElementID,undoRedoTable[undoRedoIndex]["prop"],undoRedoTable[undoRedoIndex]["redo"])
5213 if getProperty(editorSPropsID,"active") then
5214 pcall(getProperty(editorSPropsMenuID,"onChangeFunction"))
5215 end
5216 onPixelSelecChange()
5217 refresh()
5218 end
5219 end
5220 end)
5221 addElementToScreen(editorSRedoID,editorSID,relX(50,editorSID)+1,designerY)
5222
5223 addDynamicTextBox(editorSDescID,nil)
5224 changeProperty(editorSDescID,"visible",false)
5225 changeProperty(editorSDescID,"height",designerY - 5)
5226 changeProperty(editorSDescID,"textAlignmentHorizontal","left")
5227 changeProperty(editorSDescID,"textAlignmentVertical","top")
5228 addElementToScreen(editorSDescID,editorSID,relX(50,editorSID)+1,4)
5229
5230 addDynamicTextBox(editorSPropResetButtonID,"Set §*default §-or §*unused§-")
5231 changeProperty(editorSPropResetButtonID,"BGColor",colorPalette[3])
5232 changeProperty(editorSPropResetButtonID,"textColor",colorPalette[2])
5233 changeProperty(editorSPropResetButtonID,"borderColor",colorPalette[1])
5234 changeProperty(editorSPropResetButtonID,"borderThickness",1)
5235 changeProperty(editorSPropResetButtonID,"width",relX(50,editorSID)-1)
5236 changeProperty(editorSPropResetButtonID,"onClickMode","flash")
5237 changeProperty(editorSPropResetButtonID,"activeBGColor",colorPalette[2])
5238 changeProperty(editorSPropResetButtonID,"activeTextColor",colorPalette[3])
5239 changeProperty(editorSPropResetButtonID,"visible",false)
5240 changeProperty(editorSPropResetButtonID,"onActiveFunction",function()
5241 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["essential"] then
5242 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="number" or elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="decimal" or elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"] == "string" or elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"] == "color" or string.sub(elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"],1,3)=="DDM" then
5243 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])),elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["default"])
5244 else
5245 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"] == "stringArray" or elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"] == "colorsArray" or elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"] == "picArray" then
5246 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),copyOfSimpleArray(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))),elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["default"])
5247 else
5248 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"] == "CSTable" then
5249 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),copyOfCSTable(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))),elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["default"])
5250 else
5251 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"] == "CSDesignsTable" then
5252 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),copyOfCSDesignsTable(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))),elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["default"])
5253 else
5254 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"] == "navMenuArray" then
5255 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),copyOfNavMenu(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))),elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["default"])
5256 end
5257 end
5258 end
5259 end
5260 end
5261 changeProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["default"])
5262 changeProperty(editorSPropStringArrayDDID,"selectionID",1)
5263 changeProperty(editorSPropStringArrayDDID,"entries",{"Entry 1","Entry 2","Entry 3","+add"})
5264 else
5265 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="number" or elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="decimal" or elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"] == "string" or elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"] == "color" or string.sub(elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"],1,3)=="DDM" then
5266 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])),nil)
5267 else
5268 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"] == "stringArray" or elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"] == "colorsArray" or elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"] == "picArray" then
5269 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),copyOfSimpleArray(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))),nil)
5270 else
5271 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"] == "CSTable" then
5272 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),copyOfCSTable(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))),nil)
5273 else
5274 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"] == "CSDesignsTable" then
5275 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),copyOfCSDesignsTable(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))),nil)
5276 else
5277 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"] == "navMenuArray" then
5278 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),copyOfNavMenu(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))),nil)
5279 end
5280 end
5281 end
5282 end
5283 end
5284 changeProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),nil)
5285 changeProperty(editorSPropDDMenuID,"selectionID",1)
5286 changeProperty(editorSPropColorPickID,"selection",nil)
5287 changeProperty(editorSPropColorsArrayDDID,"entries",{"Use"})
5288 changeProperty(editorSPropCSTableIndexDDID,"entries",{"Use"})
5289 changeProperty(editorSPropCSDesignsIndexDDID,"entries",{"Use"})
5290 changeProperty(editorSPropCSDesignsDDID,"visible",false)
5291 changeProperty(editorSPropCSDesignsDisplayID,"visible",false)
5292 changeProperty(editorSPropCSTableDDID,"visible",false)
5293 changeProperty(editorSPropColorsArrayDDID,"selectionID",1)
5294 changeProperty(editorSPropCSTableIndexDDID,"selectionID",1)
5295 changeProperty(editorSPropCSDesignsIndexDDID,"selectionID",1)
5296 changeProperty(editorSPropColorsArrayDDID,"expanded",false)
5297 changeProperty(editorSPropColorsArrayDDID,"highlightID",nil)
5298 changeProperty(editorSPropCSChangeID,"visible",false)
5299 changeProperty(editorSPropCSRemoveID,"visible",false)
5300 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="colorsArray" or elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="CSDesignsTable" then
5301 changeProperty(editorSPropColorPickID,"visible",false)
5302 end
5303 end end)
5304 addElementToScreen(editorSPropResetButtonID,editorSID,1,designerY-4)
5305
5306 --input color
5307 addColorPicker(editorSPropColorPickID,nil)
5308 changeProperty(editorSPropColorPickID,"borderThickness",1)
5309 changeProperty(editorSPropColorPickID,"borderColor",colorPalette[3])
5310 changeProperty(editorSPropColorPickID,"visible",false)
5311 changeProperty(editorSPropColorPickID,"onChangeFunction", function(ID,selection)
5312 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="color" then
5313 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])),selection)
5314 changeProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),selection)
5315 end
5316 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="colorsArray" then
5317 --for colorsArray
5318 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),function(prop,var1,var2,var3) getProperty(editorSElementID,prop)[var3]=var1 end,function(prop,var1,var2,var3) getProperty(editorSElementID,prop)[var3]=var2 end,getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[getProperty(editorSPropColorsArrayDDID,"selectionID")],selection,getProperty(editorSPropColorsArrayDDID,"selectionID"))
5319 getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[getProperty(editorSPropColorsArrayDDID,"selectionID")] = selection
5320 end
5321 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="CSDesignsTable" then
5322 --for graphDesigns
5323 local string_ = ""
5324 if getProperty(editorSPropCSDesignsDDID,"selectionID")==1 then
5325 string_ = "color"
5326 else
5327 string_ = "BGColor"
5328 end
5329 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),function(prop,var1,var2,var3,var4) getProperty(editorSElementID,prop)[var3][var4] = var1 end,function(prop,var1,var2,var3,var4) getProperty(editorSElementID,prop)[var3][var4] = var2 end,getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[getProperty(editorSPropCSDesignsIndexDDID,"selectionID")][string_],selection,getProperty(editorSPropCSDesignsIndexDDID,"selectionID"),string_)
5330 getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[getProperty(editorSPropCSDesignsIndexDDID,"selectionID")][string_] = selection
5331 end
5332 refresh()
5333 end)
5334 addElementToScreen(editorSPropColorPickID,editorSID,1,7)
5335
5336 --input ddmenu
5337 addDropDownMenu(editorSPropDDMenuID,nil,1)
5338 changeProperty(editorSPropDDMenuID,"selectionID",1)
5339 changeProperty(editorSPropDDMenuID,"borderThickness",1)
5340 changeProperty(editorSPropDDMenuID,"borderColor",colorPalette[3])
5341 changeProperty(editorSPropDDMenuID,"highlightTextColor",colorPalette[2])
5342 changeProperty(editorSPropDDMenuID,"highlightBGColor",colorPalette[1])
5343 changeProperty(editorSPropDDMenuID,"visible",false)
5344 changeProperty(editorSPropDDMenuID,"width",relX(50,editorSID)-1)
5345 changeProperty(editorSPropDDMenuID,"expandedMaxHeight",designerY-8)
5346 changeProperty(editorSPropDDMenuID,"onChangeFunction",function(ID,selection)
5347 if getProperty(editorSPropDDMenuID,"selectionID")==1 then
5348 changeProperty(editorSPropDDMenuID,"selectionID",2)
5349 end
5350 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])),(getProperty(editorSPropDDMenuID,"entries")[getProperty(editorSPropDDMenuID,"selectionID")]))
5351 changeProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),(getProperty(editorSPropDDMenuID,"entries")[getProperty(editorSPropDDMenuID,"selectionID")]))
5352 end)
5353 addElementToScreen(editorSPropDDMenuID,editorSID,1,7)
5354
5355 --input console (string,number,decimal)
5356 addDynamicTextBox(editorSPropDisplayID,"Current value: $value")
5357 changeProperty(editorSPropDisplayID,"ignoreMods",true)
5358 changeProperty(editorSPropDisplayID,"width",relX(50,editorSID)-1)
5359 changeProperty(editorSPropDisplayID,"variables",{["value"]=function() return getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])) or "nil" end})
5360 changeProperty(editorSPropDisplayID,"textAlignmentHorizontal","center")
5361 changeProperty(editorSPropDisplayID,"visible",false)
5362 addElementToScreen(editorSPropDisplayID,editorSID,1,7)
5363
5364 addDynamicTextBox(editorSPropConsoleInputButtonID,"Change")
5365 changeProperty(editorSPropConsoleInputButtonID,"BGColor",colorPalette[3])
5366 changeProperty(editorSPropConsoleInputButtonID,"textColor",colorPalette[2])
5367 changeProperty(editorSPropConsoleInputButtonID,"borderColor",colorPalette[1])
5368 changeProperty(editorSPropConsoleInputButtonID,"borderThickness",1)
5369 changeProperty(editorSPropConsoleInputButtonID,"width",relX(50,editorSID)-1)
5370 changeProperty(editorSPropConsoleInputButtonID,"onClickMode","flash")
5371 changeProperty(editorSPropConsoleInputButtonID,"activeBGColor",colorPalette[2])
5372 changeProperty(editorSPropConsoleInputButtonID,"activeTextColor",colorPalette[3])
5373 changeProperty(editorSPropConsoleInputButtonID,"visible",false)
5374 changeProperty(editorSPropConsoleInputButtonID,"onActiveFunction",function()
5375 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]~="stringArray" then
5376 changeProperty(editorSPropsID,"visible",false)
5377 changeProperty(editorSPropsMenuID,"enabled",false)
5378 changeProperty(editorSUndoID,"visible",false)
5379 changeProperty(editorSRedoID,"visible",false)
5380 changeProperty(editorSPropConsoleInputButtonID,"visible",false)
5381 changeProperty(editorSPropResetButtonID,"visible",false)
5382 changeProperty(editorSPropConsoleMsgID,"visible",true)
5383 changeProperty(editorSPropCSTableIndexDDID,"enabled",false)
5384 changeProperty(editorSPropCSTableDDID,"enabled",false)
5385 refresh()
5386 term.setBackgroundColor(colorPalette[2])
5387 term.setTextColor(colorPalette[1])
5388 term.clear()
5389 term.setCursorPos(1,1)
5390 local valid = false
5391 repeat
5392 print("Please enter a new value for property '"..(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]).."' ("..elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]..")")
5393 input = read()
5394 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="string" then
5395 valid = true
5396 end
5397 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="number" then
5398 if tonumber(input)~=nil then
5399 input = math.floor(tonumber(input))
5400 valid = true
5401 else
5402 print("Must be a number!")
5403 end
5404 end
5405 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="decimal" then
5406 if tonumber(input)~=nil then
5407 input = (tonumber(input))
5408 valid = true
5409 else
5410 print("Must be a number!")
5411 end
5412 end
5413 until valid
5414 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])),input)
5415 changeProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),input)
5416
5417 changeProperty(editorSPropsID,"visible",true)
5418 changeProperty(editorSPropsMenuID,"enabled",true)
5419 changeProperty(editorSUndoID,"visible",true)
5420 changeProperty(editorSRedoID,"visible",true)
5421 changeProperty(editorSPropConsoleInputButtonID,"visible",true)
5422 changeProperty(editorSPropResetButtonID,"visible",true)
5423 changeProperty(editorSPropConsoleMsgID,"visible",false)
5424 changeProperty(editorSPropCSTableIndexDDID,"enabled",true)
5425 changeProperty(editorSPropCSTableDDID,"enabled",true)
5426 fullRefresh()
5427 else
5428 changeProperty(editorSPropsID,"visible",false)
5429 changeProperty(editorSPropsMenuID,"enabled",false)
5430 changeProperty(editorSUndoID,"visible",false)
5431 changeProperty(editorSRedoID,"visible",false)
5432 changeProperty(editorSPropConsoleInputButtonID,"visible",false)
5433 changeProperty(editorSPropResetButtonID,"visible",false)
5434 changeProperty(editorSPropConsoleMsgID,"visible",true)
5435 changeProperty(editorSPropCSTableIndexDDID,"enabled",false)
5436 changeProperty(editorSPropCSTableDDID,"enabled",false)
5437 refresh()
5438 term.setBackgroundColor(colorPalette[2])
5439 term.setTextColor(colorPalette[1])
5440 term.clear()
5441 term.setCursorPos(1,1)
5442 print("Please enter a new value for property '"..(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]).."' ("..elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]..") entry number "..getProperty(editorSPropStringArrayDDID,"selectionID")..". To remove this entry press enter.")
5443 input = read()
5444 if input~="" then
5445 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),function(prop,var1,var2,var3) getProperty(editorSElementID,prop)[var3]=var1 end, function(prop,var1,var2,var3) getProperty(editorSElementID,prop)[var3]=var2 end,getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries"))[getProperty(editorSPropsMenuID,"selectionID")])[getProperty(editorSPropStringArrayDDID,"selectionID")],input,getProperty(editorSPropStringArrayDDID,"selectionID"))
5446 getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[getProperty(editorSPropStringArrayDDID,"selectionID")] = input
5447 getProperty(editorSPropStringArrayDDID,"entries")[getProperty(editorSPropStringArrayDDID,"selectionID")] = input
5448 else
5449 local old = copyOfSimpleArray(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])))
5450 table.remove(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])),getProperty(editorSPropStringArrayDDID,"selectionID"))
5451 table.remove(getProperty(editorSPropStringArrayDDID,"entries"),getProperty(editorSPropStringArrayDDID,"selectionID"))
5452 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),old,copyOfSimpleArray(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))))
5453 end
5454 changeProperty(editorSPropsID,"visible",true)
5455 changeProperty(editorSPropsMenuID,"enabled",true)
5456 changeProperty(editorSUndoID,"visible",true)
5457 changeProperty(editorSRedoID,"visible",true)
5458 changeProperty(editorSPropConsoleInputButtonID,"visible",true)
5459 changeProperty(editorSPropResetButtonID,"visible",true)
5460 changeProperty(editorSPropConsoleMsgID,"visible",false)
5461 changeProperty(editorSPropCSTableIndexDDID,"enabled",true)
5462 changeProperty(editorSPropCSTableDDID,"enabled",true)
5463 fullRefresh()
5464 end
5465 end)
5466 addElementToScreen(editorSPropConsoleInputButtonID,editorSID,1,designerY-8)
5467
5468 addDynamicTextBox(editorSPropConsoleMsgID,"Please check term!")
5469 changeProperty(editorSPropConsoleMsgID,"borderThickness",1)
5470 changeProperty(editorSPropConsoleMsgID,"width",relX(50,editorSID)-1)
5471 changeProperty(editorSPropConsoleMsgID,"visible",false)
5472 addElementToScreen(editorSPropConsoleMsgID,editorSID,1,designerY-8)
5473
5474 --advanced types: colorsArray,stringArray,navMenuArray,CSTable,CSDesignsTable,picArray
5475
5476 --type colorsArray
5477 addDropDownMenu(editorSPropColorsArrayDDID,{"Use"},1)
5478 changeProperty(editorSPropColorsArrayDDID,"selectionID",1)
5479 changeProperty(editorSPropColorsArrayDDID,"expanded",false)
5480 changeProperty(editorSPropColorsArrayDDID,"highlightID",nil)
5481 changeProperty(editorSPropColorsArrayDDID,"borderThickness",1)
5482 changeProperty(editorSPropColorsArrayDDID,"borderColor",colorPalette[3])
5483 changeProperty(editorSPropColorsArrayDDID,"highlightTextColor",colorPalette[2])
5484 changeProperty(editorSPropColorsArrayDDID,"highlightBGColor",colorPalette[1])
5485 changeProperty(editorSPropColorsArrayDDID,"visible",false)
5486 changeProperty(editorSPropColorsArrayDDID,"expandedMaxHeight",designerY-8)
5487 changeProperty(editorSPropColorsArrayDDID,"onExpandFunction",function()
5488 if getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))==nil then
5489 local array = {}
5490 local entries = {}
5491 for i=1,getProperty(editorSElementID,"length") do
5492 array[i] = colors.white
5493 entries[i] = i
5494 end
5495 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),nil,copyOfSimpleArray(array))
5496 changeProperty(editorSPropColorsArrayDDID,"entries",entries)
5497 changeProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),array)
5498 end end)
5499 changeProperty(editorSPropColorsArrayDDID,"onChangeFunction",function(ID,selection)
5500 changeProperty(editorSPropColorPickID,"visible",true)
5501 changeProperty(editorSPropColorPickID,"selection",getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[getProperty(editorSPropColorsArrayDDID,"selectionID")])
5502 end)
5503 addElementToScreen(editorSPropColorsArrayDDID,editorSID,8,7)
5504
5505 --type stringArray
5506 addDropDownMenu(editorSPropStringArrayDDID,nil,1)
5507 changeProperty(editorSPropStringArrayDDID,"selectionID",1)
5508 changeProperty(editorSPropStringArrayDDID,"expanded",false)
5509 changeProperty(editorSPropStringArrayDDID,"highlightID",nil)
5510 changeProperty(editorSPropStringArrayDDID,"borderThickness",1)
5511 changeProperty(editorSPropStringArrayDDID,"borderColor",colorPalette[3])
5512 changeProperty(editorSPropStringArrayDDID,"highlightTextColor",colorPalette[2])
5513 changeProperty(editorSPropStringArrayDDID,"highlightBGColor",colorPalette[1])
5514 changeProperty(editorSPropStringArrayDDID,"visible",false)
5515 changeProperty(editorSPropStringArrayDDID,"expandedMaxHeight",designerY-8)
5516 changeProperty(editorSPropStringArrayDDID,"onChangeFunction",function(ID,selection)
5517 if selection==table.getn(getProperty(editorSPropStringArrayDDID,"entries")) then
5518 pcall(getProperty(editorSPropConsoleInputButtonID,"onActiveFunction"))
5519 table.insert(getProperty(editorSPropStringArrayDDID,"entries"),"+add")
5520 end
5521 end)
5522 addElementToScreen(editorSPropStringArrayDDID,editorSID,1,7)
5523
5524 --type navMenuArray
5525 addDynamicTextBox(editorSPropNavMenuHintID,"Click on any entry to §?change §-its text or §?add §-entries.")
5526 changeProperty(editorSPropNavMenuHintID,"width",relX(50,editorSID)-1)
5527 changeProperty(editorSPropNavMenuHintID,"visible",false)
5528 addElementToScreen(editorSPropNavMenuHintID,editorSID,1,designerY-8)
5529
5530 addNavigationMenu(editorSPropNavMenuID,"Entries",{})
5531 changeProperty(editorSPropNavMenuID,"expanded",false)
5532 changeProperty(editorSPropNavMenuID,"highlightIDs",nil)
5533 changeProperty(editorSPropNavMenuID,"borderColor",colorPalette[3])
5534 changeProperty(editorSPropNavMenuID,"textAlignmentHorizontal","left")
5535 changeProperty(editorSPropNavMenuID,"borderThickness",1)
5536 changeProperty(editorSPropNavMenuID,"visible",false)
5537 changeProperty(editorSPropNavMenuID,"onChangeFunction",function(ID,numbers)
5538 local temp = getProperty(editorSPropNavMenuID,"menuArray")
5539 local old = copyOfNavMenu(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])))
5540 for i=1,table.getn(numbers)-1 do
5541 temp = temp[numbers[i]]["submenu"]
5542 end
5543 if temp[numbers[table.getn(numbers)]]["text"] == "+add" then
5544 local offset = 0
5545 local temp2 = getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))
5546 for i=1,table.getn(numbers)-1 do
5547 temp2 = temp2[numbers[i]-offset]["submenu"]
5548 offset = 1
5549 end
5550 temp2[numbers[table.getn(numbers)]-offset] = {}
5551 temp2[numbers[table.getn(numbers)]-offset]["text"] = "New"
5552 pcall(getProperty(editorSPropsMenuID,"onChangeFunction"))
5553 end
5554 if temp[numbers[table.getn(numbers)]]["text"] == "+add sub" then
5555 local temp2 = getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))
5556 local offset = 0
5557 for i=1,table.getn(numbers)-2 do
5558 temp2 = temp2[numbers[i]-offset]["submenu"]
5559 offset = 1
5560 end
5561 temp2[numbers[table.getn(numbers)-1]-offset]["submenu"] = {}
5562 temp2[numbers[table.getn(numbers)-1]-offset]["submenu"][1] = {}
5563 temp2[numbers[table.getn(numbers)-1]-offset]["submenu"][1]["text"] = "New"
5564 pcall(getProperty(editorSPropsMenuID,"onChangeFunction"))
5565 end
5566 if temp[numbers[table.getn(numbers)]]["text"] == "<- edit" then
5567 local temp2 = getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))
5568 local highlightIDsString = "entry"
5569 local offset = 0
5570 for i=1,table.getn(numbers)-2 do
5571 temp2 = temp2[numbers[i]-offset]["submenu"]
5572 highlightIDsString = highlightIDsString .. "-"..numbers[i]-offset
5573 offset = 1
5574 end
5575 highlightIDsString = highlightIDsString .. "-"..(numbers[table.getn(numbers)-1]-offset)
5576
5577 local input = "Entry"
5578 changeProperty(editorSPropNavMenuID,"enabled",false)
5579 changeProperty(editorSPropNavMenuHintID,"visible",false)
5580 changeProperty(editorSPropsID,"visible",false)
5581 changeProperty(editorSPropsMenuID,"enabled",false)
5582 changeProperty(editorSUndoID,"visible",false)
5583 changeProperty(editorSRedoID,"visible",false)
5584 changeProperty(editorSPropResetButtonID,"visible",false)
5585 changeProperty(editorSPropConsoleMsgID,"visible",true)
5586 refresh()
5587
5588 term.setBackgroundColor(colorPalette[2])
5589 term.setTextColor(colorPalette[1])
5590 term.clear()
5591 term.setCursorPos(1,1)
5592 print("Please enter a new value for property '"..(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]).."' ("..elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]..", "..highlightIDsString.." ) To remove entry press enter.")
5593 input = read()
5594
5595 if input~="" then
5596 temp2[numbers[table.getn(numbers)-1]-offset]["text"] = input
5597 else
5598 if not (temp2==getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])) and numbers[1]==1) then
5599 temp2[numbers[table.getn(numbers)-1]-offset] = ""
5600 table.remove(temp2,numbers[table.getn(numbers)-1]-offset)
5601 end
5602
5603 local count = 0
5604 for name,data in pairs(temp2) do
5605 count = count + 1
5606 break
5607 end
5608
5609 if count==0 then
5610 local temp2 = getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))
5611 local offset = 0
5612 for i=1,table.getn(numbers)-3 do
5613 if i~=1 then
5614 temp2 = temp2[numbers[i]-1]["submenu"]
5615 else
5616 temp2 = temp2[numbers[i]]["submenu"]
5617 end
5618 offset = 1
5619 end
5620 temp2[numbers[table.getn(numbers)-2]-offset]["submenu"] = nil
5621 end
5622 end
5623
5624 changeProperty(editorSPropNavMenuID,"enabled",true)
5625 changeProperty(editorSPropNavMenuHintID,"visible",true)
5626 changeProperty(editorSPropsID,"visible",true)
5627 changeProperty(editorSPropsMenuID,"enabled",true)
5628 changeProperty(editorSUndoID,"visible",true)
5629 changeProperty(editorSRedoID,"visible",true)
5630 changeProperty(editorSPropResetButtonID,"visible",true)
5631 changeProperty(editorSPropConsoleMsgID,"visible",false)
5632
5633 pcall(getProperty(editorSPropsMenuID,"onChangeFunction"))
5634 fullRefresh()
5635 end
5636 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),old,copyOfNavMenu(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))))
5637 end)
5638 addElementToScreen(editorSPropNavMenuID,editorSID,1,7)
5639
5640 -- type CSTable
5641 addDynamicTextBox(editorSPropCSChangeID,"Change")
5642 changeProperty(editorSPropCSChangeID,"BGColor",colorPalette[3])
5643 changeProperty(editorSPropCSChangeID,"textColor",colorPalette[2])
5644 changeProperty(editorSPropCSChangeID,"borderColor",colorPalette[1])
5645 changeProperty(editorSPropCSChangeID,"borderThickness",1)
5646 changeProperty(editorSPropCSChangeID,"onClickMode","flash")
5647 changeProperty(editorSPropCSChangeID,"activeBGColor",colorPalette[2])
5648 changeProperty(editorSPropCSChangeID,"activeTextColor",colorPalette[3])
5649 changeProperty(editorSPropCSChangeID,"visible",false)
5650 changeProperty(editorSPropCSChangeID,"onActiveFunction",function()
5651 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="CSTable" then
5652 changeProperty(editorSPropsID,"visible",false)
5653 changeProperty(editorSPropsMenuID,"enabled",false)
5654 changeProperty(editorSUndoID,"visible",false)
5655 changeProperty(editorSRedoID,"visible",false)
5656 changeProperty(editorSPropResetButtonID,"visible",false)
5657 changeProperty(editorSPropConsoleMsgID,"visible",true)
5658 changeProperty(editorSPropCSChangeID,"visible",false)
5659 changeProperty(editorSPropCSRemoveID,"visible",false)
5660 changeProperty(editorSPropCSTableDDID,"enabled",false)
5661 changeProperty(editorSPropCSTableIndexDDID,"enabled",false)
5662
5663 refresh()
5664
5665 term.setBackgroundColor(colorPalette[2])
5666 term.setTextColor(colorPalette[1])
5667 term.clear()
5668 term.setCursorPos(1,1)
5669
5670 local index = tonumber(string.sub(getProperty(editorSPropCSTableDDID,"entries")[getProperty(editorSPropCSTableDDID,"selectionID")],1,string.find(getProperty(editorSPropCSTableDDID,"entries")[getProperty(editorSPropCSTableDDID,"selectionID")],":")-1))
5671 local _string = "graph "..getProperty(editorSPropCSTableIndexDDID,"entries")[getProperty(editorSPropCSTableIndexDDID,"selectionID")].." coordinate x="..index
5672 print("Please enter a new value for property '"..(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]).."' ("..elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]..", ".._string..") To remove coordinate press enter.")
5673 print("Enter a new Y Coordinate:")
5674
5675 local input
5676 local valid = false
5677 repeat
5678 input = read()
5679 if input~="" then
5680 if tonumber(input)~=nil then
5681 input = (tonumber(input))
5682 valid = true
5683 else
5684 print("Must be a number!")
5685 end
5686 else
5687 valid = true
5688 end
5689 until valid
5690
5691 if input~="" then
5692 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),function(prop,var1,var2,var3,var4,var5) getProperty(editorSElementID,prop)[var3][var4] = var1 end, function(prop,var1,var2,var3,var4,var5) getProperty(editorSElementID,prop)[var3][var4] = var2 end,getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[tonumber(getProperty(editorSPropCSTableIndexDDID,"entries")[getProperty(editorSPropCSTableIndexDDID,"selectionID")])][index],input,tonumber(getProperty(editorSPropCSTableIndexDDID,"entries")[getProperty(editorSPropCSTableIndexDDID,"selectionID")]),index)
5693 getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[tonumber(getProperty(editorSPropCSTableIndexDDID,"entries")[getProperty(editorSPropCSTableIndexDDID,"selectionID")])][index] = input
5694 else
5695 local old = copyOfCSTable(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])))
5696 table.remove(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[tonumber(getProperty(editorSPropCSTableIndexDDID,"entries")[getProperty(editorSPropCSTableIndexDDID,"selectionID")])],index)
5697 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),old,getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])))
5698 end
5699 changeProperty(editorSPropsID,"visible",true)
5700 changeProperty(editorSPropsMenuID,"enabled",true)
5701 changeProperty(editorSUndoID,"visible",true)
5702 changeProperty(editorSRedoID,"visible",true)
5703 changeProperty(editorSPropResetButtonID,"visible",true)
5704 changeProperty(editorSPropConsoleMsgID,"visible",false)
5705 changeProperty(editorSPropCSChangeID,"visible",true)
5706 changeProperty(editorSPropCSRemoveID,"visible",true)
5707 changeProperty(editorSPropCSTableDDID,"enabled",true)
5708 changeProperty(editorSPropCSTableIndexDDID,"enabled",true)
5709 pcall(getProperty(editorSPropsMenuID,"onChangeFunction"))
5710 fullRefresh()
5711 end
5712 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="CSDesignsTable" then
5713 changeProperty(editorSPropsID,"visible",false)
5714 changeProperty(editorSPropsMenuID,"enabled",false)
5715 changeProperty(editorSUndoID,"visible",false)
5716 changeProperty(editorSRedoID,"visible",false)
5717 changeProperty(editorSPropResetButtonID,"visible",false)
5718 changeProperty(editorSPropConsoleMsgID,"visible",true)
5719 changeProperty(editorSPropCSChangeID,"visible",false)
5720 changeProperty(editorSPropCSDesignsDDID,"enabled",false)
5721 changeProperty(editorSPropCSDesignsIndexDDID,"enabled",false)
5722
5723 refresh()
5724
5725 term.setBackgroundColor(colorPalette[2])
5726 term.setTextColor(colorPalette[1])
5727 term.clear()
5728 term.setCursorPos(1,1)
5729 print("Please enter a new value for property '"..(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]).."' ("..elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]..", graph number "..getProperty(editorSPropCSDesignsIndexDDID,"selectionID")..", character)")
5730
5731 local input = read()
5732
5733 if input~="" then
5734 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),function(prop,var1,var2,var3) getProperty(editorSElementID,prop)[var3]["character"] = var1 end,function(prop,var1,var2,var3) getProperty(editorSElementID,prop)[var3]["character"] = var2 end,getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[getProperty(editorSPropCSDesignsIndexDDID,"selectionID")]["character"],string.sub(input,1,1),getProperty(editorSPropCSDesignsIndexDDID,"selectionID"))
5735 getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[getProperty(editorSPropCSDesignsIndexDDID,"selectionID")]["character"] = string.sub(input,1,1)
5736 end
5737
5738 changeProperty(editorSPropsID,"visible",true)
5739 changeProperty(editorSPropsMenuID,"enabled",true)
5740 changeProperty(editorSUndoID,"visible",true)
5741 changeProperty(editorSRedoID,"visible",true)
5742 changeProperty(editorSPropResetButtonID,"visible",true)
5743 changeProperty(editorSPropConsoleMsgID,"visible",false)
5744 changeProperty(editorSPropCSChangeID,"visible",true)
5745 changeProperty(editorSPropCSDesignsDDID,"enabled",true)
5746 changeProperty(editorSPropCSDesignsIndexDDID,"enabled",true)
5747 pcall(getProperty(editorSPropsMenuID,"onChangeFunction"))
5748 fullRefresh()
5749 end
5750 end)
5751 addElementToScreen(editorSPropCSChangeID,editorSID,1,designerY-8)
5752
5753 addDynamicTextBox(editorSPropCSRemoveID,"Remove")
5754 changeProperty(editorSPropCSRemoveID,"BGColor",colorPalette[3])
5755 changeProperty(editorSPropCSRemoveID,"textColor",colorPalette[2])
5756 changeProperty(editorSPropCSRemoveID,"borderColor",colorPalette[1])
5757 changeProperty(editorSPropCSRemoveID,"borderThickness",1)
5758 changeProperty(editorSPropCSRemoveID,"onClickMode","flash")
5759 changeProperty(editorSPropCSRemoveID,"activeBGColor",colorPalette[2])
5760 changeProperty(editorSPropCSRemoveID,"activeTextColor",colorPalette[3])
5761 changeProperty(editorSPropCSRemoveID,"visible",false)
5762 changeProperty(editorSPropCSRemoveID,"onActiveFunction",function()
5763 if table.getn(getProperty(editorSPropCSTableIndexDDID,"entries"))>2 then
5764 local old = copyOfCSTable(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])))
5765 getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[getProperty(editorSPropCSTableIndexDDID,"selectionID")] = ""
5766 table.remove(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])),getProperty(editorSPropCSTableIndexDDID,"selectionID"))
5767 table.remove(getProperty(editorSPropCSTableIndexDDID,"entries"),getProperty(editorSPropCSTableIndexDDID,"selectionID"))
5768 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),old,copyOfCSTable(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))))
5769 changeProperty(editorSPropCSTableIndexDDID,"selectionID",getProperty(editorSPropCSTableIndexDDID,"selectionID")-1)
5770 pcall(getProperty(editorSPropCSTableIndexDDID,"onChangeFunction"),editorSPropCSTableIndexDDID,getProperty(editorSPropCSTableIndexDDID,"selectionID"))
5771 end
5772 end)
5773 addElementToScreen(editorSPropCSRemoveID,editorSID,relX(50,editorSID)+1-9,designerY-8)
5774
5775 addDropDownMenu(editorSPropCSTableIndexDDID,{"Use"},1)
5776 changeProperty(editorSPropCSTableIndexDDID,"selectionID",1)
5777 changeProperty(editorSPropCSTableIndexDDID,"expanded",false)
5778 changeProperty(editorSPropCSTableIndexDDID,"highlightID",nil)
5779 changeProperty(editorSPropCSTableIndexDDID,"borderThickness",1)
5780 changeProperty(editorSPropCSTableIndexDDID,"borderColor",colorPalette[3])
5781 changeProperty(editorSPropCSTableIndexDDID,"highlightTextColor",colorPalette[2])
5782 changeProperty(editorSPropCSTableIndexDDID,"highlightBGColor",colorPalette[1])
5783 changeProperty(editorSPropCSTableIndexDDID,"visible",false)
5784 changeProperty(editorSPropCSTableIndexDDID,"width",8)
5785 changeProperty(editorSPropCSTableIndexDDID,"expandedMaxHeight",designerY-8)
5786 changeProperty(editorSPropCSTableIndexDDID,"onExpandFunction",function(ID)
5787 if getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))==nil then
5788 changeProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),{[1]={}})
5789 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),nil,copyOfCSTable(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))))
5790 changeProperty(editorSPropCSTableDDID,"entries",{"+add"})
5791 changeProperty(editorSPropCSTableIndexDDID,"entries",{"1","+add"})
5792 changeProperty(editorSPropCSTableDDID,"selectionID",1)
5793 changeProperty(editorSPropCSTableDDID,"visible",true)
5794 changeProperty(editorSPropCSChangeID,"visible",true)
5795 changeProperty(editorSPropCSRemoveID,"visible",true)
5796 end
5797 end)
5798 changeProperty(editorSPropCSTableIndexDDID,"onChangeFunction",function(ID,selection)
5799 if selection~=table.getn(getProperty(editorSPropCSTableIndexDDID,"entries")) then
5800 local array = {}
5801 for name,data in pairs(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[selection]) do
5802 table.insert(array,name..":"..data)
5803 end
5804 table.insert(array,"+add")
5805 changeProperty(editorSPropCSTableDDID,"entries",array)
5806 changeProperty(editorSPropCSTableDDID,"selectionID",1)
5807 changeProperty(editorSPropCSTableDDID,"visible",true)
5808 changeProperty(editorSPropCSChangeID,"visible",true)
5809 changeProperty(editorSPropCSRemoveID,"visible",true)
5810 else
5811 local old = copyOfCSTable(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])))
5812 getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[selection] = {}
5813 getProperty(editorSPropCSTableIndexDDID,"entries")[selection] = ""..selection
5814 getProperty(editorSPropCSTableIndexDDID,"entries")[selection+1] = "+add"
5815 pcall(editorSPropCSTableIndexDDID,"onChangeFunction",ID,selection)
5816 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),old,copyOfCSTable(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))))
5817 end
5818 end)
5819 addElementToScreen(editorSPropCSTableIndexDDID,editorSID,relX(50,editorSID)+1-9,7)
5820
5821 addDropDownMenu(editorSPropCSTableDDID,{},1)
5822 changeProperty(editorSPropCSTableDDID,"selectionID",1)
5823 changeProperty(editorSPropCSTableDDID,"expanded",false)
5824 changeProperty(editorSPropCSTableDDID,"highlightID",nil)
5825 changeProperty(editorSPropCSTableDDID,"borderThickness",1)
5826 changeProperty(editorSPropCSTableDDID,"borderColor",colorPalette[3])
5827 changeProperty(editorSPropCSTableDDID,"highlightTextColor",colorPalette[2])
5828 changeProperty(editorSPropCSTableDDID,"highlightBGColor",colorPalette[1])
5829 changeProperty(editorSPropCSTableDDID,"visible",false)
5830 changeProperty(editorSPropCSTableDDID,"expandedMaxHeight",designerY-8)
5831 changeProperty(editorSPropCSTableDDID,"onChangeFunction",function(ID,selection)
5832 if selection==table.getn(getProperty(editorSPropCSTableDDID,"entries")) then
5833 changeProperty(editorSPropsID,"visible",false)
5834 changeProperty(editorSPropsMenuID,"enabled",false)
5835 changeProperty(editorSUndoID,"visible",false)
5836 changeProperty(editorSRedoID,"visible",false)
5837 changeProperty(editorSPropResetButtonID,"visible",false)
5838 changeProperty(editorSPropConsoleMsgID,"visible",true)
5839 changeProperty(editorSPropCSChangeID,"visible",false)
5840 changeProperty(editorSPropCSRemoveID,"visible",false)
5841 changeProperty(editorSPropCSTableDDID,"enabled",false)
5842 changeProperty(editorSPropCSTableIndexDDID,"enabled",false)
5843
5844 refresh()
5845
5846 term.setBackgroundColor(colorPalette[2])
5847 term.setTextColor(colorPalette[1])
5848 term.clear()
5849 term.setCursorPos(1,1)
5850 print("Enter a new x coordinate:")
5851
5852 local input
5853 local valid = false
5854 repeat
5855 input = read()
5856 if tonumber(input)~=nil then
5857 input = (tonumber(input))
5858 valid = true
5859 else
5860 print("Must be a number!")
5861 end
5862 until valid
5863
5864 getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[tonumber(getProperty(editorSPropCSTableIndexDDID,"entries")[getProperty(editorSPropCSTableIndexDDID,"selectionID")])][input] = 0
5865
5866 changeProperty(editorSPropsID,"visible",true)
5867 changeProperty(editorSPropsMenuID,"enabled",true)
5868 changeProperty(editorSUndoID,"visible",true)
5869 changeProperty(editorSRedoID,"visible",true)
5870 changeProperty(editorSPropResetButtonID,"visible",true)
5871 changeProperty(editorSPropConsoleMsgID,"visible",false)
5872 changeProperty(editorSPropCSChangeID,"visible",true)
5873 changeProperty(editorSPropCSRemoveID,"visible",true)
5874 changeProperty(editorSPropCSTableDDID,"enabled",true)
5875 changeProperty(editorSPropCSTableIndexDDID,"enabled",true)
5876
5877 getProperty(editorSPropCSTableDDID,"entries")[selection] = input..":0"
5878
5879 pcall(getProperty(editorSPropCSChangeID,"onActiveFunction"))
5880 end
5881 end)
5882 addElementToScreen(editorSPropCSTableDDID,editorSID,1,7)
5883
5884 --type CSDesigns
5885 addDropDownMenu(editorSPropCSDesignsIndexDDID,{"Use"})
5886 changeProperty(editorSPropCSDesignsIndexDDID,"selectionID",1)
5887 changeProperty(editorSPropCSDesignsIndexDDID,"expanded",false)
5888 changeProperty(editorSPropCSDesignsIndexDDID,"highlightID",nil)
5889 changeProperty(editorSPropCSDesignsIndexDDID,"borderThickness",1)
5890 changeProperty(editorSPropCSDesignsIndexDDID,"borderColor",colorPalette[3])
5891 changeProperty(editorSPropCSDesignsIndexDDID,"highlightTextColor",colorPalette[2])
5892 changeProperty(editorSPropCSDesignsIndexDDID,"highlightBGColor",colorPalette[1])
5893 changeProperty(editorSPropCSDesignsIndexDDID,"visible",false)
5894 changeProperty(editorSPropCSDesignsIndexDDID,"width",8)
5895 changeProperty(editorSPropCSDesignsIndexDDID,"expandedMaxHeight",designerY-8)
5896 changeProperty(editorSPropCSDesignsIndexDDID,"onExpandFunction",function()
5897 if getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))==nil then
5898 local array = {}
5899 local array2 = {}
5900 for name,data in ipairs(getProperty(editorSElementID,"graphTables")) do
5901 array[name] = name..""
5902 array2[name] = {}
5903 end
5904 changeProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),array2)
5905 addToUndoRedoTable((getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]),nil,copyOfCSDesignsTable(array2))
5906 changeProperty(editorSPropCSDesignsIndexDDID,"entries",array)
5907 end
5908 end)
5909 changeProperty(editorSPropCSDesignsIndexDDID,"onChangeFunction",function(id,selection)
5910 changeProperty(editorSPropCSDesignsDDID,"visible",true)
5911 pcall(getProperty(editorSPropCSDesignsDDID,"onChangeFunction"))
5912 end)
5913 addElementToScreen(editorSPropCSDesignsIndexDDID,editorSID,relX(50,editorSID)+1-9,7)
5914
5915 addDropDownMenu(editorSPropCSDesignsDDID,{"color","BG","char"})
5916 changeProperty(editorSPropCSDesignsDDID,"selectionID",1)
5917 changeProperty(editorSPropCSDesignsDDID,"expanded",false)
5918 changeProperty(editorSPropCSDesignsDDID,"highlightID",nil)
5919 changeProperty(editorSPropCSDesignsDDID,"borderThickness",1)
5920 changeProperty(editorSPropCSDesignsDDID,"borderColor",colorPalette[3])
5921 changeProperty(editorSPropCSDesignsDDID,"highlightTextColor",colorPalette[2])
5922 changeProperty(editorSPropCSDesignsDDID,"highlightBGColor",colorPalette[1])
5923 changeProperty(editorSPropCSDesignsDDID,"visible",false)
5924 changeProperty(editorSPropCSDesignsDDID,"width",9)
5925 changeProperty(editorSPropCSDesignsDDID,"expandedMaxHeight",designerY-8)
5926 changeProperty(editorSPropCSDesignsDDID,"onChangeFunction",function(id,selection)
5927 if selection==nil then
5928 selection = getProperty(editorSPropCSDesignsDDID,"selectionID")
5929 end
5930 if selection~=3 then
5931 changeProperty(editorSPropCSChangeID,"visible",false)
5932 changeProperty(editorSPropCSDesignsDisplayID,"visible",false)
5933 changeProperty(editorSPropColorPickID,"visible",true)
5934 local color = nil
5935 if selection==1 then
5936 if getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[getProperty(editorSPropCSDesignsIndexDDID,"selectionID")]["color"]~=nil then
5937 color = getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[getProperty(editorSPropCSDesignsIndexDDID,"selectionID")]["color"]
5938 end
5939 else
5940 if getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[getProperty(editorSPropCSDesignsIndexDDID,"selectionID")]["BGColor"]~=nil then
5941 color = getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[getProperty(editorSPropCSDesignsIndexDDID,"selectionID")]["BGColor"]
5942 end
5943 end
5944 changeProperty(editorSPropColorPickID,"selection",color)
5945 else
5946 changeProperty(editorSPropCSChangeID,"visible",true)
5947 changeProperty(editorSPropCSDesignsDisplayID,"visible",true)
5948 changeProperty(editorSPropColorPickID,"visible",false)
5949 end
5950 end)
5951 addElementToScreen(editorSPropCSDesignsDDID,editorSID,relX(50,editorSID)+1-10,designerY-8)
5952
5953 addDynamicTextBox(editorSPropCSDesignsDisplayID,"Current char: §?$var§-")
5954 changeProperty(editorSPropCSDesignsDisplayID,"width",relX(50,editorSID)-1-9)
5955 changeProperty(editorSPropCSDesignsDisplayID,"variables",{["var"]=function() return getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))[getProperty(editorSPropCSDesignsIndexDDID,"selectionID")]["character"] or "nil" end})
5956 changeProperty(editorSPropCSDesignsDisplayID,"textAlignmentHorizontal","center")
5957 changeProperty(editorSPropCSDesignsDisplayID,"visible",false)
5958 addElementToScreen(editorSPropCSDesignsDisplayID,editorSID,1,7)
5959
5960 --type linesArray
5961 addDynamicTextBox(editorSPropPicEditButtonID,"Edit")
5962 changeProperty(editorSPropPicEditButtonID,"BGColor",colorPalette[3])
5963 changeProperty(editorSPropPicEditButtonID,"textColor",colorPalette[2])
5964 changeProperty(editorSPropPicEditButtonID,"borderColor",colorPalette[1])
5965 changeProperty(editorSPropPicEditButtonID,"borderThickness",1)
5966 changeProperty(editorSPropPicEditButtonID,"onClickMode","flash")
5967 changeProperty(editorSPropPicEditButtonID,"width",relX(50,editorSID)-1)
5968 changeProperty(editorSPropPicEditButtonID,"activeBGColor",colorPalette[2])
5969 changeProperty(editorSPropPicEditButtonID,"activeTextColor",colorPalette[3])
5970 changeProperty(editorSPropPicEditButtonID,"visible",false)
5971 changeProperty(editorSPropPicEditButtonID,"onActiveFunction",function()
5972 addElementToScreen(editorSElementID,pictureESID,editorSElementX,editorSElementY)
5973 addElementToScreen(editorSUndoID,pictureESID,relX(50,editorSID)-6,designerY)
5974 addElementToScreen(editorSRedoID,pictureESID,relX(50,editorSID)+1,designerY)
5975 addElementToScreen(pictureESButtonBackID,pictureESID,1,designerY)
5976 addElementToScreen(pictureESCoordsDisplayID,pictureESID,designerX-11,designerY)
5977 addElementToScreen(pictureESControlPicID,pictureESID,designerX-5,designerY-5)
5978 addElementToScreen(pictureESIndicatorID,pictureESID,editorSElementX,editorSElementY)
5979 addElementToScreen(pictureESUseDefault2ID,pictureESID,designerX-8,designerY-7)
5980 addElementToScreen(pictureESColorPick2ID,pictureESID,designerX-5,designerY-11)
5981 addElementToScreen(pictureESUseDefault1ID,pictureESID,designerX-8,designerY-12)
5982 addElementToScreen(pictureESColorPick1ID,pictureESID,designerX-5,designerY-16)
5983 addElementToScreen(pictureESChangeID,pictureESID,designerX-7,designerY-18)
5984 addElementToScreen(pictureESTransparentID,pictureESID,designerX-12,designerY-1)
5985 pictureESCurrentX = 1
5986 pictureESCurrentY = 1
5987 setProcessClickEventFunction(function(type_,id,part)
5988 if id==editorSElementID then
5989 pictureESCurrentX = tonumber(string.sub(part,1,string.find(part,":")-1))
5990 pictureESCurrentY = tonumber(string.sub(part,string.find(part,":")+1))
5991 changePos(pictureESIndicatorID,pictureESID,pictureESCurrentX+editorSElementX-1,pictureESCurrentY+editorSElementY-1)
5992 onPixelSelecChange()
5993 refresh()
5994 end
5995 if id==pictureESControlPicID then
5996 --y gets smaller
5997 if part=="3:1" then
5998 pictureESCurrentY = math.max(pictureESCurrentY-1,1)
5999 end
6000 --y gets bigger
6001 if part=="3:3" then
6002 pictureESCurrentY = math.min(pictureESCurrentY+1,getProperty(editorSElementID,"height"))
6003 end
6004 --x gets smaller
6005 if part=="1:2" then
6006 pictureESCurrentX = math.max(pictureESCurrentX-1,1)
6007 end
6008 --x gets bigger
6009 if part=="5:2" then
6010 pictureESCurrentX = math.min(pictureESCurrentX+1,getProperty(editorSElementID,"width"))
6011 end
6012 if part=="3:2" then
6013 changeProperty(pictureESIndicatorID,"visible",not getProperty(pictureESIndicatorID,"visible"))
6014 end
6015
6016 changePos(pictureESIndicatorID,pictureESID,pictureESCurrentX+editorSElementX-1,pictureESCurrentY+editorSElementY-1)
6017 onPixelSelecChange()
6018 refresh()
6019 end
6020 end)
6021
6022 setProcessEventFunction(function(event,var1)
6023 if name=="timer" then
6024 if var1==saveTimerID then
6025 saveElement(editorSElementID,editorSElementType)
6026 saveTimerID = os.startTimer(180)
6027 lastSave = os.clock()
6028 end
6029 end
6030 if event=="key" then
6031 if var1==200 then
6032 pictureESCurrentY = math.max(pictureESCurrentY-1,1)
6033 end
6034 if var1==208 then
6035 pictureESCurrentY = math.min(pictureESCurrentY+1,getProperty(editorSElementID,"height"))
6036 end
6037 if var1==203 then
6038 pictureESCurrentX = math.max(pictureESCurrentX-1,1)
6039 end
6040 if var1==205 then
6041 pictureESCurrentX = math.min(pictureESCurrentX+1,getProperty(editorSElementID,"width"))
6042 end
6043 changePos(pictureESIndicatorID,pictureESID,pictureESCurrentX+editorSElementX-1,pictureESCurrentY+editorSElementY-1)
6044 onPixelSelecChange()
6045 refresh()
6046 end
6047 if event=="char" then
6048 local new = var1
6049 local s = getPixelString()
6050 if string.len(s)==0 then
6051 writePixelString("*:#:"..new)
6052 end
6053 if string.len(s)==1 then
6054 writePixelString("*:"..s..":"..new)
6055 end
6056 if string.len(s)==5 then
6057 writePixelString(string.sub(s,1,4)..new)
6058 end
6059 pictureESCurrentX = math.min(pictureESCurrentX+1,getProperty(editorSElementID,"width"))
6060 changePos(pictureESIndicatorID,pictureESID,pictureESCurrentX+editorSElementX-1,pictureESCurrentY+editorSElementY-1)
6061 onPixelSelecChange()
6062 refresh()
6063 end
6064 if event=="paste" then
6065 for i=1,string.len(var1) do
6066 os.queueEvent("char",string.sub(var1,i,i))
6067 end
6068 end
6069 end)
6070
6071 setDesignerScreen(pictureESID)
6072 onPixelSelecChange()
6073 fullRefresh()
6074 end)
6075 addElementToScreen(editorSPropPicEditButtonID,editorSID,1,7)
6076
6077 addScreen(pictureESID,designerX,designerY,colorPalette[1],colorPalette[2])
6078 addDynamicTextBox(pictureESButtonBackID,"§?<§-Back§?>§-")
6079 changeProperty(pictureESButtonBackID,"onClickMode","flash")
6080 changeProperty(pictureESButtonBackID,"onActiveFunction",function()
6081 removeElementFromScreen(editorSElementID,pictureESID)
6082 removeElementFromScreen(editorSUndoID,pictureESID)
6083 removeElementFromScreen(editorSRedoID,pictureESID)
6084 removeElementFromScreen(pictureESButtonBackID,pictureESID)
6085 removeElementFromScreen(pictureESCoordsDisplayID,pictureESID)
6086 removeElementFromScreen(pictureESControlPicID,pictureESID)
6087 removeElementFromScreen(pictureESIndicatorID,pictureESID)
6088 removeElementFromScreen(pictureESColorPick2ID,pictureESID)
6089 removeElementFromScreen(pictureESUseDefault2ID,pictureESID)
6090 removeElementFromScreen(pictureESColorPick1ID,pictureESID)
6091 removeElementFromScreen(pictureESUseDefault1ID,pictureESID)
6092 removeElementFromScreen(pictureESTransparentID,pictureESID)
6093 removeElementFromScreen(pictureESChangeID,pictureESID)
6094 setProcessEventFunction(processEditorEvents)
6095 setProcessClickEventFunction(nil)
6096
6097 setDesignerScreen(editorSID)
6098 fullRefresh()
6099 end)
6100
6101 local c = colorsArrayNumToString[colorPalette[3]]
6102 addDynamicTextBox(pictureESCoordsDisplayID,"Pixel: §?$x§-:§?$y§-")
6103 changeProperty(pictureESCoordsDisplayID,"textAlignmentHorizontal","right")
6104 changeProperty(pictureESCoordsDisplayID,"width",12)
6105 changeProperty(pictureESCoordsDisplayID,"variables",{["x"]=function() return pictureESCurrentX end,["y"]=function() return pictureESCurrentY end})
6106
6107 addPicture(pictureESControlPicID,5,3,{";;*:#:^;;;","*:#:<;;"..c..":#:+;;*:#:>;",";;*:#:v;;;"})
6108 addDynamicTextBox(pictureESIndicatorID," ")
6109 changeProperty(pictureESIndicatorID,"BGColor",colorPalette[3])
6110
6111 addDynamicTextBox(pictureESUseDefault1ID,"§?<§-Default§?>§-")
6112 changeProperty(pictureESUseDefault1ID,"onClickMode","toggle")
6113 changeProperty(pictureESUseDefault1ID,"activeBGColor",colorPalette[1])
6114 changeProperty(pictureESUseDefault1ID,"activeTextColor",colorPalette[2])
6115 changeProperty(pictureESUseDefault1ID,"onActiveFunction",function()
6116 changeProperty(pictureESTransparentID,"active",false)
6117 changeProperty(pictureESColorPick1ID,"selection",nil)
6118 local s = getPixelString()
6119 if string.len(s)==0 then
6120 writePixelString("*:#: ")
6121 end
6122 if string.len(s)==1 then
6123 writePixelString("*:"..s..": ")
6124 end
6125 if string.len(s)==5 then
6126 writePixelString("*"..string.sub(s,2))
6127 end
6128 refresh()
6129 end)
6130 changeProperty(pictureESUseDefault1ID,"onInactiveFunction",function()
6131 changeProperty(pictureESUseDefault1ID,"active",true)
6132 refresh()
6133 end)
6134
6135 addDynamicTextBox(pictureESUseDefault2ID,"§?<§-Default§?>§-")
6136 changeProperty(pictureESUseDefault2ID,"onClickMode","toggle")
6137 changeProperty(pictureESUseDefault2ID,"activeBGColor",colorPalette[1])
6138 changeProperty(pictureESUseDefault2ID,"activeTextColor",colorPalette[2])
6139 changeProperty(pictureESUseDefault2ID,"onActiveFunction",function()
6140 changeProperty(pictureESTransparentID,"active",false)
6141 changeProperty(pictureESColorPick2ID,"selection",nil)
6142 local s = getPixelString()
6143 if string.len(s)==0 or string.len(s)==1 then
6144 writePixelString("#")
6145 end
6146 if string.len(s)==5 then
6147 writePixelString(string.sub(s,1,2).."#"..string.sub(s,4,5))
6148 end
6149 refresh()
6150 end)
6151 changeProperty(pictureESUseDefault2ID,"onInactiveFunction",function()
6152 changeProperty(pictureESUseDefault2ID,"active",true)
6153 refresh()
6154 end)
6155
6156 addColorPicker(pictureESColorPick1ID,nil)
6157 changeProperty(pictureESColorPick1ID,"onChangeFunction",function(ID,selection)
6158 changeProperty(pictureESUseDefault1ID,"active",false)
6159 changeProperty(pictureESTransparentID,"active",false)
6160 local s = getPixelString()
6161 if string.len(s)==0 then
6162 writePixelString(colorsArrayNumToString[selection]..":#: ")
6163 end
6164 if string.len(s)==1 then
6165 writePixelString(colorsArrayNumToString[selection]..":"..s..": ")
6166 end
6167 if string.len(s)==5 then
6168 writePixelString(colorsArrayNumToString[selection]..string.sub(s,2))
6169 end
6170 refresh()
6171 end)
6172
6173 addColorPicker(pictureESColorPick2ID,nil)
6174 changeProperty(pictureESColorPick2ID,"onChangeFunction",function(ID,selection)
6175 changeProperty(pictureESUseDefault2ID,"active",false)
6176 changeProperty(pictureESTransparentID,"active",false)
6177 local s = getPixelString()
6178 if string.len(s)==0 or string.len(s)==1 then
6179 writePixelString(colorsArrayNumToString[selection])
6180 end
6181 if string.len(s)==5 then
6182 writePixelString(string.sub(s,1,2)..colorsArrayNumToString[selection]..string.sub(s,4,5))
6183 end
6184 refresh()
6185 end)
6186
6187 addDynamicTextBox(pictureESChangeID,"Char: §?$c§- §?<§-Change§?>§-")
6188 changeProperty(pictureESChangeID,"onClickMode","flash")
6189 changeProperty(pictureESChangeID,"variables",{["c"]=function() return " " end})
6190 changeProperty(pictureESChangeID,"onActiveFunction",function()
6191 changeProperty(pictureESChangeID,"content","Check term!")
6192
6193 term.setBackgroundColor(colorPalette[2])
6194 term.setTextColor(colorPalette[1])
6195 term.clear()
6196 term.setCursorPos(1,1)
6197
6198 print("Enter a new character for coordinate "..pictureESCurrentX..":"..pictureESCurrentY)
6199
6200 local new = read()
6201 if new=="" then new = " " end
6202 new = string.sub(new,1,1)
6203
6204 local s = getPixelString()
6205 if string.len(s)==0 then
6206 writePixelString("*:#:"..new)
6207 end
6208 if string.len(s)==1 then
6209 writePixelString("*:"..s..":"..new)
6210 end
6211 if string.len(s)==5 then
6212 writePixelString(string.sub(s,1,4)..new)
6213 end
6214
6215 changeProperty(pictureESChangeID,"content","Char: $c <Change>")
6216 onPixelSelecChange()
6217 fullRefresh()
6218 end)
6219
6220 addDynamicTextBox(pictureESTransparentID,"§?<§-Transparent§?>§-")
6221 changeProperty(pictureESTransparentID,"onClickMode","toggle")
6222 changeProperty(pictureESTransparentID,"activeBGColor",colorPalette[1])
6223 changeProperty(pictureESTransparentID,"activeTextColor",colorPalette[2])
6224 changeProperty(pictureESTransparentID,"onActiveFunction",function()
6225 writePixelString("")
6226 changeProperty(pictureESUseDefault1ID,"active",false)
6227 changeProperty(pictureESUseDefault2ID,"active",false)
6228 end)
6229 changeProperty(pictureESTransparentID,"onInactiveFunction",function()
6230 writePixelString("#")
6231 changeProperty(pictureESUseDefault1ID,"active",false)
6232 changeProperty(pictureESUseDefault2ID,"active",true)
6233 end)
6234
6235 addDropDownMenu(editorSPropsMenuID,nil,1)
6236 changeProperty(editorSPropsMenuID,"selectionID",1)
6237 changeProperty(editorSPropsMenuID,"expanded",false)
6238 changeProperty(editorSPropsMenuID,"highlightID",nil)
6239 changeProperty(editorSPropsMenuID,"borderThickness",1)
6240 changeProperty(editorSPropsMenuID,"borderColor",colorPalette[3])
6241 changeProperty(editorSPropsMenuID,"highlightTextColor",colorPalette[2])
6242 changeProperty(editorSPropsMenuID,"highlightBGColor",colorPalette[1])
6243 changeProperty(editorSPropsMenuID,"visible",false)
6244 changeProperty(editorSPropsMenuID,"width",relX(50,editorSID)-1)
6245 changeProperty(editorSPropsMenuID,"expandedMaxHeight",designerY-4)
6246 changeProperty(editorSPropsMenuID,"onChangeFunction",function() changeProperty(editorSDescID,"content",elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["desc"])
6247 changeProperty(editorSPropColorPickID,"visible",false)
6248 changeProperty(editorSPropDDMenuID,"visible",false)
6249 changeProperty(editorSPropDisplayID,"visible",false)
6250 changeProperty(editorSPropConsoleInputButtonID,"visible",false)
6251 changeProperty(editorSPropColorPickID,"selection",nil)
6252 changeProperty(editorSPropColorsArrayDDID,"visible",false)
6253 changeProperty(editorSPropStringArrayDDID,"visible",false)
6254 changeProperty(editorSPropNavMenuID,"visible",false)
6255 changeProperty(editorSPropNavMenuHintID,"visible",false)
6256 changeProperty(editorSPropCSTableIndexDDID,"visible",false)
6257 changeProperty(editorSPropCSTableDDID,"visible",false)
6258 changeProperty(editorSPropCSChangeID,"visible",false)
6259 changeProperty(editorSPropCSRemoveID,"visible",false)
6260 changeProperty(editorSPropCSDesignsDDID,"visible",false)
6261 changeProperty(editorSPropCSDesignsIndexDDID,"visible",false)
6262 changeProperty(editorSPropCSDesignsDisplayID,"visible",false)
6263 changeProperty(editorSPropPicEditButtonID,"visible",false)
6264
6265 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]~="manual" then
6266 changeProperty(editorSPropResetButtonID,"visible",true)
6267 else
6268 changeProperty(editorSPropResetButtonID,"visible",false)
6269 end
6270 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="color" then
6271 changeProperty(editorSPropColorPickID,"visible",true)
6272 changeProperty(editorSPropColorPickID,"selection",getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])))
6273 end
6274 if string.sub(elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"],1,3)=="DDM" then
6275 changeProperty(editorSPropDDMenuID,"visible",true)
6276 local array = {""}
6277 local menusS = string.sub(elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"],5)
6278 while string.find(menusS,":") do
6279 table.insert(array,string.sub(menusS,1,string.find(menusS,":")-1))
6280 menusS = string.sub(menusS,string.find(menusS,":")+1)
6281 end
6282 table.insert(array,menusS)
6283 changeProperty(editorSPropDDMenuID,"entries",array)
6284 changeProperty(editorSPropDDMenuID,"selectionID",1)
6285 for i,entry in ipairs(array) do
6286 if entry==getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])) then
6287 changeProperty(editorSPropDDMenuID,"selectionID",i)
6288 end
6289 end
6290 end
6291 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="number" or elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="decimal" or elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="string" then
6292 changeProperty(editorSPropDisplayID,"visible",true)
6293 changeProperty(editorSPropConsoleInputButtonID,"visible",true)
6294 end
6295 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="colorsArray" then
6296 changeProperty(editorSPropColorsArrayDDID,"visible",true)
6297 if getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))~=nil then
6298 local array = {}
6299 for i=1,table.getn(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))) do
6300 array[i] = i
6301 end
6302 changeProperty(editorSPropColorsArrayDDID,"entries",array)
6303 pcall(getProperty(editorSPropColorsArrayDDID,"onChangeFunction"),editorSPropColorsArrayDDID,1)
6304 else
6305 changeProperty(editorSPropColorsArrayDDID,"entries",{"Use"})
6306 end
6307 end
6308 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="stringArray" then
6309 changeProperty(editorSPropStringArrayDDID,"visible",true)
6310 local array = {}
6311 for i,current in ipairs(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))) do
6312 table.insert(array,current)
6313 end
6314 table.insert(array,"+add")
6315 changeProperty(editorSPropStringArrayDDID,"entries",array)
6316 changeProperty(editorSPropConsoleInputButtonID,"visible",true)
6317 end
6318 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="navMenuArray" then
6319 changeProperty(editorSPropNavMenuID,"menuArray",prepNavMenu(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])),{}))
6320 changeProperty(editorSPropNavMenuID,"visible",true)
6321 changeProperty(editorSPropNavMenuID,"expanded",false)
6322 changeProperty(editorSPropNavMenuHintID,"visible",true)
6323 end
6324 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="CSTable" then
6325 changeProperty(editorSPropCSTableIndexDDID,"visible",true)
6326 if getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))~=nil then
6327 local array = {}
6328 for i,data in ipairs(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))) do
6329 array[i] = ""..i
6330 end
6331 table.insert(array,"+add")
6332 changeProperty(editorSPropCSTableIndexDDID,"entries",array)
6333 pcall(getProperty(editorSPropCSTableIndexDDID,"onChangeFunction"),editorSPropCSTableIndexDDID,getProperty(editorSPropCSTableIndexDDID,"selectionID"))
6334 else
6335 changeProperty(editorSPropCSTableIndexDDID,"entries",{"Use"})
6336 end
6337 end
6338 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="CSDesignsTable" then
6339 if getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))~=nil then
6340 local array = {}
6341 for i,data in ipairs(getProperty(editorSElementID,(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")]))) do
6342 array[i] = ""..i
6343 end
6344 changeProperty(editorSPropCSDesignsIndexDDID,"entries",array)
6345 changeProperty(editorSPropCSDesignsIndexDDID,"visible",true)
6346 pcall(getProperty(editorSPropCSDesignsIndexDDID,"onChangeFunction"))
6347 else
6348 if getProperty(editorSElementID,"graphTables")~=nil then
6349 changeProperty(editorSPropCSDesignsIndexDDID,"visible",true)
6350 changeProperty(editorSPropCSDesignsIndexDDID,"entries",{"Use"})
6351 end
6352 end
6353 end
6354 if elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["input"]=="picArray" then
6355 changeProperty(editorSPropPicEditButtonID,"visible",true)
6356 end
6357 end)
6358 addElementToScreen(editorSPropsMenuID,editorSID,1,3)
6359
6360 addDynamicTextBox(editorSHideUIID,"§?<§-Hide UI§?>§-")
6361 changeProperty(editorSHideUIID,"onClickMode","flash")
6362 changeProperty(editorSHideUIID,"activeDuration",3)
6363 changeProperty(editorSHideUIID,"onActiveFunction",function()
6364 changeProperty(editorSExitID,"visible",false)
6365 changeProperty(editorSPropsID,"visible",false)
6366 changeProperty(editorSUndoID,"visible",false)
6367 changeProperty(editorSRelocateButtonID,"visible",false)
6368 changeProperty(editorSLastSaveID,"visible",false)
6369 changeProperty(editorSRedoID,"visible",false)
6370 changeProperty(editorSHideUIID,"visible",false) end)
6371 changeProperty(editorSHideUIID,"onInactiveFunction",function()
6372 changeProperty(editorSExitID,"visible",true)
6373 changeProperty(editorSPropsID,"visible",true)
6374 changeProperty(editorSUndoID,"visible",true)
6375 changeProperty(editorSRelocateButtonID,"visible",true)
6376 changeProperty(editorSLastSaveID,"visible",true)
6377 changeProperty(editorSRedoID,"visible",true)
6378 changeProperty(editorSHideUIID,"visible",true) end)
6379 addElementToScreen(editorSHideUIID,editorSID,12,1)
6380
6381 setDesignerScreen(editorSID)
6382 refresh()
6383end
6384
6385function getPixelString(x_,y_)
6386 local x
6387 local y
6388 if x_==nil then x = pictureESCurrentX else x = x_ end
6389 if y_==nil then y = pictureESCurrentY else y = y_ end
6390 local s = getProperty(editorSElementID,"linesArray")[y]
6391 for i=1,x-1 do
6392 s = string.sub(s,string.find(s,";")+1)
6393 end
6394 return string.sub(s,1,string.find(s,";")-1)
6395end
6396
6397function writePixelString(new,x_,y_,bool)
6398 local x
6399 local y
6400 if x_==nil then x = pictureESCurrentX else x = x_ end
6401 if y_==nil then y = pictureESCurrentY else y = y_ end
6402 if not bool then
6403 addToUndoRedoTable("linesArray",function(prop,var1,var2,var3,var4) writePixelString(var1,var3,var4,true) end, function(prop,var1,var2,var3,var4) writePixelString(var2,var3,var4,true) end,getPixelString(x,y),new,x,y)
6404 end
6405 local s = getProperty(editorSElementID,"linesArray")[y]
6406 local count = 0
6407 for i=1,x-1 do
6408 count = count + string.find(s,";")
6409 s = string.sub(s,string.find(s,";")+1)
6410 end
6411 s = string.sub(s,string.find(s,";")+1)
6412 getProperty(editorSElementID,"linesArray")[y] = string.sub(getProperty(editorSElementID,"linesArray")[y],1,count) ..new..";"..s
6413end
6414
6415function onPixelSelecChange()
6416 if editorSElementType == "picture" then
6417 local s = getPixelString()
6418 if string.len(s)==0 then
6419 changeProperty(pictureESColorPick1ID,"selection",nil)
6420 changeProperty(pictureESColorPick2ID,"selection",nil)
6421 changeProperty(pictureESUseDefault1ID,"active",false)
6422 changeProperty(pictureESUseDefault2ID,"active",false)
6423 changeProperty(pictureESTransparentID,"active",true)
6424 changeProperty(pictureESChangeID,"variables",{["c"]=function() return " " end})
6425 end
6426 if string.len(s)==1 then
6427 changeProperty(pictureESColorPick1ID,"selection",nil)
6428 changeProperty(pictureESUseDefault1ID,"active",false)
6429 changeProperty(pictureESTransparentID,"active",false)
6430 changeProperty(pictureESChangeID,"variables",{["c"]=function() return " " end})
6431
6432 if s =="#" then
6433 changeProperty(pictureESUseDefault2ID,"active",true)
6434 changeProperty(pictureESColorPick2ID,"selection",nil)
6435 else
6436 changeProperty(pictureESUseDefault2ID,"active",false)
6437 changeProperty(pictureESColorPick2ID,"selection",colorsArrayStrToNum[s])
6438 end
6439 end
6440 if string.len(s)==5 then
6441 changeProperty(pictureESTransparentID,"active",false)
6442 changeProperty(pictureESChangeID,"variables",{["c"]=function() return string.sub(s,5) end})
6443
6444 if string.sub(s,3,3) =="#" then
6445 changeProperty(pictureESUseDefault2ID,"active",true)
6446 changeProperty(pictureESColorPick2ID,"selection",nil)
6447 else
6448 changeProperty(pictureESUseDefault2ID,"active",false)
6449 changeProperty(pictureESColorPick2ID,"selection",colorsArrayStrToNum[string.sub(s,3,3)])
6450 end
6451
6452 if string.sub(s,1,1) =="*" then
6453 changeProperty(pictureESUseDefault1ID,"active",true)
6454 changeProperty(pictureESColorPick1ID,"selection",nil)
6455 else
6456 changeProperty(pictureESUseDefault1ID,"active",false)
6457 changeProperty(pictureESColorPick1ID,"selection",colorsArrayStrToNum[string.sub(s,1,1)])
6458 end
6459 end
6460 end
6461end
6462
6463function prepNavMenu(array,new,first)
6464 local number
6465 if first==1 then
6466 new[1]={["text"]="<- edit"}
6467 else
6468 first = 0
6469 end
6470 for i,data in ipairs(array) do
6471 new[i+first] = {["text"]=data["text"]}
6472 if data["submenu"]~=nil then
6473 new[i+first]["submenu"] = {}
6474 prepNavMenu(data["submenu"],new[i+first]["submenu"],1)
6475 else
6476 new[i+first]["submenu"] = {[1]={["text"]="<- edit"},[2]={["text"]="+add sub"}}
6477 end
6478 number = i+first
6479 end
6480 new[number+1] = {["text"]="+add"}
6481 return new
6482end
6483
6484function copyOfSimpleArray(old,new)
6485 if new==nil then new = {} end
6486 for i,data in ipairs(old) do
6487 new[i] = data
6488 end
6489 return new
6490end
6491
6492function copyOfCSTable(old,new)
6493 if new==nil then new = {} end
6494 for i,data in ipairs(old) do
6495 new[i] = {}
6496 for x,y in pairs(old[i]) do
6497 new[i][x] = y
6498 end
6499 end
6500 return new
6501end
6502
6503function copyOfCSDesignsTable(old,new)
6504 if new==nil then new = {} end
6505 for i,data in ipairs(old) do
6506 new[i] = {}
6507 new[i]["color"] = old[i]["color"]
6508 new[i]["BGColor"] = old[i]["BGColor"]
6509 new[i]["character"] = old[i]["character"]
6510 end
6511 return new
6512end
6513
6514function copyOfNavMenu(old,new)
6515 if new==nil then new = {} end
6516 for i,data in ipairs(old) do
6517 new[i] = {["text"]=data["text"]}
6518 if data["submenu"]~=nil then
6519 new[i]["submenu"] = {}
6520 copyOfNavMenu(data["submenu"],new[i]["submenu"])
6521 end
6522 end
6523 return new
6524end
6525
6526function refreshPropsMenu()
6527 local array = {}
6528 for name,data in pairs(elementProperties[editorSElementType]) do
6529 table.insert(array,name)
6530 end
6531 changeProperty(editorSPropsMenuID,"entries",array)
6532 changeProperty(editorSDescID,"content",elementProperties[editorSElementType][(getProperty(editorSPropsMenuID,"entries")[getProperty(editorSPropsMenuID,"selectionID")])]["desc"])
6533end
6534
6535function relocateOn()
6536 changeProperty(editorSElementID,"enabled",false)
6537 changeProperty(editorSExitID,"enabled",false)
6538 changeProperty(editorSPropsID,"enabled",false)
6539 changeProperty(editorSUndoID,"enabled",false)
6540 changeProperty(editorSRedoID,"enabled",false)
6541 changeProperty(editorSHideUIID,"enabled",false)
6542 setProcessEventFunction(relocate)
6543end
6544
6545function processEditorEvents(name,var1,var2,var3)
6546 if name=="timer" then
6547 if var1==saveTimerID then
6548 saveElement(editorSElementID,editorSElementType)
6549 saveTimerID = os.startTimer(180)
6550 lastSave = os.clock()
6551 end
6552 end
6553 if name=="key" then
6554 if var1==31 and CTRLHeld then
6555 saveElement(editorSElementID,editorSElementType)
6556 saveTimerID = os.startTimer(180)
6557 lastSave = os.clock()
6558 refresh()
6559 end
6560 if var1==44 and CTRLHeld then
6561 processClickEvent(terminalID,getPos(editorSUndoID,editorSID))
6562 end
6563 if var1==21 and CTRLHeld then
6564 processClickEvent(terminalID,getPos(editorSRedoID,editorSID))
6565 end
6566 end
6567end
6568
6569function relocate(name,var1,var2,var3)
6570 if name=="monitor_touch" or name=="mouse_click" or name=="mouse_drag" then
6571 changePos(editorSElementID,editorSID,var2,var3)
6572 editorSElementX = var2
6573 editorSElementY = var3
6574 refresh()
6575 end
6576 processEditorEvents(name,var1,var2,var3)
6577end
6578
6579function relocateOff()
6580 changeProperty(editorSElementID,"enabled",true)
6581 changeProperty(editorSExitID,"enabled",true)
6582 changeProperty(editorSPropsID,"enabled",true)
6583 changeProperty(editorSUndoID,"enabled",true)
6584 changeProperty(editorSRedoID,"enabled",true)
6585 changeProperty(editorSHideUIID,"enabled",true)
6586 setProcessEventFunction(processEditorEvents)
6587end
6588
6589function addToUndoRedoTable(prop,undo,redo,var1,var2,var3,var4,var5)
6590 local n = undoRedoIndex+1
6591 while undoRedoTable[n]~=nil do
6592 undoRedoTable[n]=nil
6593 n = n + 1
6594 end
6595 table.insert(undoRedoTable,{["prop"]=prop,["undo"]=undo,["redo"]=redo,["var1"]=var1,["var2"]=var2,["var3"]=var3,["var4"]=var4,["var5"]=var5})
6596 undoRedoIndex = table.getn(undoRedoTable)
6597end
6598
6599function startDesigner(ID)
6600 setDesignerScreen(ID)
6601 designerSID = ID
6602 designerSmaxX = screens[ID]["sizeX"]
6603 designerSmaxY = screens[ID]["sizeY"]
6604 designerSSelection = ""
6605 designerRefresh = true
6606 undoRedoTable = {}
6607 undoRedoIndex = 0
6608 lastSave = os.clock()
6609 saveTimerID = os.startTimer(180)
6610 setProcessEventFunction(function(name,var1,var2,var3,var4,var5)
6611 if name=="timer" and var1==saveTimerID then
6612 lastSave = os.clock()
6613 saveScreen(designerSID)
6614 saveTimerID = os.startTimer(180)
6615 end
6616 if name=="mouse_up" then
6617 designerSButtonHeld = false
6618 changeProperty(designerSIndicatorID,"BGColor",colorPalette[3])
6619 refresh()
6620 end
6621 if name=="mouse_drag" and designerSButtonHeld then
6622 if var2<=designerSmaxX and var3 <=designerSmaxY then
6623 local currX,currY = getPos(designerSIndicatorID,designerSID)
6624 addToUndoRedoTable(designerSSelection,function(prop,var1,var2,var3,var4) changePos(prop,designerSID,var1,var2) changePos(designerSIndicatorID,designerSID,var1,var2) end, function(prop,var1,var2,var3,var4) changePos(prop,designerSID,var3,var4) changePos(designerSIndicatorID,designerSID,var3,var4) end,currX,currY,var2,var3)
6625 changePos(designerSIndicatorID,designerSID,var2,var3)
6626 changePos(designerSSelection,designerSID,var2,var3)
6627 refresh()
6628 end
6629 end
6630 if name=="monitor_touch" then
6631 if var2<=designerSmaxX and var3 <=designerSmaxY and getProperty(designerSIndicatorID,"active") then
6632 local currX,currY = getPos(designerSIndicatorID,designerSID)
6633 addToUndoRedoTable(designerSSelection,function(prop,var1,var2,var3,var4) changePos(prop,designerSID,var1,var2) changePos(designerSIndicatorID,designerSID,var1,var2) end, function(prop,var1,var2,var3,var4) changePos(prop,designerSID,var3,var4) changePos(designerSIndicatorID,designerSID,var3,var4) end,currX,currY,var2,var3)
6634 changePos(designerSIndicatorID,designerSID,var2,var3)
6635 changePos(designerSSelection,designerSID,var2,var3)
6636 refresh()
6637 end
6638 end
6639 if name=="key" then
6640 local x,y = getPos(designerSControlPicID,designerSID)
6641 if var1==200 then
6642 processClickEvent(terminalID,x+2,y)
6643 end
6644 if var1==208 then
6645 processClickEvent(terminalID,x+2,y+2)
6646 end
6647 if var1==203 then
6648 processClickEvent(terminalID,x,y+1)
6649 end
6650 if var1==205 then
6651 processClickEvent(terminalID,x+4,y+1)
6652 end
6653 if var1==31 and CTRLHeld then
6654 lastSave = os.clock()
6655 saveScreen(designerSID)
6656 saveTimerID = os.startTimer(180)
6657 refresh()
6658 end
6659 if var1==44 and CTRLHeld then
6660 processClickEvent(terminalID,getPos(designerSUndoID,designerSID))
6661 end
6662 if var1==21 and CTRLHeld then
6663 processClickEvent(terminalID,getPos(designerSRedoID,designerSID))
6664 end
6665 end
6666 end)
6667
6668 if designerX>designerSmaxX then
6669 addDynamicTextBox(designerSBox1ID,"")
6670 changeProperty(designerSBox1ID,"BGColor",colorPalette[2])
6671 changeProperty(designerSBox1ID,"width",designerX-designerSmaxX)
6672 changeProperty(designerSBox1ID,"height",designerSmaxY)
6673 addElementToScreen(designerSBox1ID,designerSID,designerSmaxX+1,1)
6674 end
6675 if designerY>designerSmaxY then
6676 addDynamicTextBox(designerSBox2ID,"")
6677 changeProperty(designerSBox2ID,"BGColor",colorPalette[2])
6678 changeProperty(designerSBox2ID,"width",designerX)
6679 changeProperty(designerSBox2ID,"height",designerY-designerSmaxY)
6680 addElementToScreen(designerSBox2ID,designerSID,1,designerSmaxY+1)
6681 end
6682
6683 addDynamicTextBox(designerSExitButtonID,"§?<§-Save&Exit§?>§-")
6684 changeProperty(designerSExitButtonID,"onClickMode","flash")
6685 changeProperty(designerSExitButtonID,"textColor",colorPalette[1])
6686 changeProperty(designerSExitButtonID,"BGColor",colorPalette[2])
6687 changeProperty(designerSExitButtonID,"onActiveFunction",function()
6688 removeElementFromScreen(designerSLastSaveID,designerSID)
6689 removeElementFromScreen(designerSHideUIID,designerSID)
6690 removeElementFromScreen(designerSBox1ID,designerSID)
6691 removeElementFromScreen(designerSBox2ID,designerSID)
6692 removeElementFromScreen(designerSUndoID,designerSID)
6693 removeElementFromScreen(designerSRedoID,designerSID)
6694 removeElementFromScreen(designerSExitButtonID,designerSID)
6695 removeElementFromScreen(designerSAddID,designerSID)
6696 removeElementFromScreen(designerSRemoveID,designerSID)
6697 removeElementFromScreen(designerSSelectionID,designerSID)
6698 removeElementFromScreen(designerSControlPicID,designerSID)
6699 removeElementFromScreen(designerSIndicatorID,designerSID)
6700 removeElementFromScreen(elementsSDDMenu2ID,designerSID)
6701 changeProperty(elementsSDDMenu2ID,"onChangeFunction",nil)
6702 saveScreen(designerSID)
6703 designerSID = nil
6704 designerSSelection = ""
6705 lastSave = nil
6706 setDesignerScreen(screensSID)
6707 setProcessClickEventFunction(nil)
6708 setProcessEventFunction(nil)
6709 designerRefresh = false
6710 fullRefresh()
6711 end)
6712 addElementToScreen(designerSExitButtonID,designerSID,designerX-10,designerY)
6713
6714 addDynamicTextBox(designerSLastSaveID,"Last save: §?$time §-min ago.")
6715 changeProperty(designerSLastSaveID,"variables",{["time"]=function () return math.floor((os.clock()-lastSave)/60) end})
6716 changeProperty(designerSLastSaveID,"textColor",colorPalette[1])
6717 changeProperty(designerSLastSaveID,"BGColor",colorPalette[2])
6718 addElementToScreen(designerSLastSaveID,designerSID,designerX-9,1)
6719
6720 addDynamicTextBox(designerSHideUIID,"§?<§-Hide UI§?>§-")
6721 changeProperty(designerSHideUIID,"onClickMode","flash")
6722 changeProperty(designerSHideUIID,"activeDuration",3)
6723 changeProperty(designerSHideUIID,"textColor",colorPalette[1])
6724 changeProperty(designerSHideUIID,"BGColor",colorPalette[2])
6725 changeProperty(designerSHideUIID,"onActiveFunction",function()
6726 changeProperty(designerSLastSaveID,"visible",false)
6727 changeProperty(designerSIndicatorID,"visible",false)
6728 changeProperty(designerSUndoID,"visible",false)
6729 changeProperty(designerSRedoID,"visible",false)
6730 changeProperty(designerSAddID,"visible",false)
6731 changeProperty(designerSRemoveID,"visible",false)
6732 changeProperty(designerSSelectionID,"visible",false)
6733 changeProperty(designerSExitButtonID,"visible",false)
6734 changeProperty(designerSHideUIID,"visible",false)
6735 changeProperty(designerSControlPicID,"visible",false)
6736 end)
6737 changeProperty(designerSHideUIID,"onInactiveFunction",function()
6738 changeProperty(designerSLastSaveID,"visible",true)
6739 changeProperty(designerSUndoID,"visible",true)
6740 changeProperty(designerSRedoID,"visible",true)
6741 changeProperty(designerSAddID,"visible",true)
6742 changeProperty(designerSExitButtonID,"visible",true)
6743 changeProperty(designerSHideUIID,"visible",true) end)
6744 addElementToScreen(designerSHideUIID,designerSID,designerX-8,3)
6745
6746 addDynamicTextBox(designerSUndoID,"§?<§-Undo§?>§-")
6747 changeProperty(designerSUndoID,"onClickMode","flash")
6748 changeProperty(designerSUndoID,"textColor",colorPalette[1])
6749 changeProperty(designerSUndoID,"BGColor",colorPalette[2])
6750 changeProperty(designerSUndoID,"activeTextColor",colorPalette[2])
6751 changeProperty(designerSUndoID,"activeBGColor",colorPalette[1])
6752 changeProperty(designerSUndoID,"onActiveFunction",function()
6753 if undoRedoIndex~=0 then
6754 if type(undoRedoTable[undoRedoIndex]["undo"])=="function" then
6755 pcall(undoRedoTable[undoRedoIndex]["undo"],undoRedoTable[undoRedoIndex]["prop"],undoRedoTable[undoRedoIndex]["var1"],undoRedoTable[undoRedoIndex]["var2"],undoRedoTable[undoRedoIndex]["var3"],undoRedoTable[undoRedoIndex]["var4"],undoRedoTable[undoRedoIndex]["var5"])
6756 refresh()
6757 end
6758 pcall(getProperty(designerSSelectionID,"onActiveFunction"))
6759 undoRedoIndex = undoRedoIndex - 1
6760 end
6761 end)
6762 screens[designerSID]["sizeX"] = designerX
6763 screens[designerSID]["sizeY"] = designerY
6764 addElementToScreen(designerSUndoID,designerSID,relX(50,designerSID)-6,designerY)
6765 screens[designerSID]["sizeX"] = designerSmaxX
6766 screens[designerSID]["sizeY"] = designerSmaxY
6767
6768 addDynamicTextBox(designerSRedoID,"§?<§-Redo§?>§-")
6769 changeProperty(designerSRedoID,"onClickMode","flash")
6770 changeProperty(designerSRedoID,"textColor",colorPalette[1])
6771 changeProperty(designerSRedoID,"BGColor",colorPalette[2])
6772 changeProperty(designerSRedoID,"activeTextColor",colorPalette[2])
6773 changeProperty(designerSRedoID,"activeBGColor",colorPalette[1])
6774 changeProperty(designerSRedoID,"onActiveFunction",function()
6775 if undoRedoIndex~=table.getn(undoRedoTable) then
6776 undoRedoIndex = undoRedoIndex + 1
6777 if type(undoRedoTable[undoRedoIndex]["redo"])=="function" then
6778 pcall(undoRedoTable[undoRedoIndex]["redo"],undoRedoTable[undoRedoIndex]["prop"],undoRedoTable[undoRedoIndex]["var1"],undoRedoTable[undoRedoIndex]["var2"],undoRedoTable[undoRedoIndex]["var3"],undoRedoTable[undoRedoIndex]["var4"],undoRedoTable[undoRedoIndex]["var5"])
6779 refresh()
6780 end
6781 pcall(getProperty(designerSSelectionID,"onActiveFunction"))
6782 end
6783 end)
6784 screens[designerSID]["sizeX"] = designerX
6785 screens[designerSID]["sizeY"] = designerY
6786 addElementToScreen(designerSRedoID,designerSID,relX(50,designerSID)+1,designerY)
6787 screens[designerSID]["sizeX"] = designerSmaxX
6788 screens[designerSID]["sizeY"] = designerSmaxY
6789
6790 onLoadElementsS()
6791 addDynamicTextBox(designerSAddID,"§?<§-Add§?>§-")
6792 changeProperty(designerSAddID,"onClickMode","toggle")
6793 changeProperty(designerSAddID,"textColor",colorPalette[1])
6794 changeProperty(designerSAddID,"BGColor",colorPalette[2])
6795 changeProperty(designerSAddID,"activeTextColor",colorPalette[2])
6796 changeProperty(designerSAddID,"activeBGColor",colorPalette[1])
6797 changeProperty(designerSAddID,"onActiveFunction",function()
6798 addElementToScreen(elementsSDDMenu2ID,designerSID,2,2)
6799 changeProperty(elementsSDDMenu2ID,"onChangeFunction",function()
6800 removeElementFromScreen(elementsSDDMenu2ID,designerSID)
6801 addElementToScreen(getProperty(elementsSDDMenu2ID,"entries")[getProperty(elementsSDDMenu2ID,"selectionID")],designerSID,1,1)
6802 addToUndoRedoTable(getProperty(elementsSDDMenu2ID,"entries")[getProperty(elementsSDDMenu2ID,"selectionID")],removeElementFromScreen,addElementToScreen,designerSID,1,1)
6803 changeProperty(designerSAddID,"active",false)
6804 end)
6805 end)
6806 changeProperty(designerSAddID,"onInactiveFunction",function()
6807 removeElementFromScreen(elementsSDDMenu2ID,designerSID)
6808 end)
6809 addElementToScreen(designerSAddID,designerSID,1,designerY)
6810
6811 addDynamicTextBox(designerSRemoveID,"§?<§-Remove§?>§-")
6812 changeProperty(designerSRemoveID,"onClickMode","flash")
6813 changeProperty(designerSRemoveID,"textColor",colorPalette[1])
6814 changeProperty(designerSRemoveID,"BGColor",colorPalette[2])
6815 changeProperty(designerSRemoveID,"activeTextColor",colorPalette[2])
6816 changeProperty(designerSRemoveID,"activeBGColor",colorPalette[1])
6817 changeProperty(designerSRemoveID,"visible",false)
6818 changeProperty(designerSRemoveID,"onActiveFunction",function()
6819 local x,y = getPos(designerSSelection,designerSID)
6820 addToUndoRedoTable(designerSSelection,addElementToScreen,removeElementFromScreen,designerSID,x,y)
6821 removeElementFromScreen(designerSSelection,designerSID)
6822 pcall(getProperty(designerSSelectionID,"onActiveFunction"))
6823 end)
6824 addElementToScreen(designerSRemoveID,designerSID,7,designerY)
6825
6826 local b = colorsArrayNumToString[colorPalette[2]]
6827 local t = colorsArrayNumToString[colorPalette[1]]
6828 local a = colorsArrayNumToString[colorPalette[3]]
6829 addPicture(designerSControlPicID,5,3,{""..b..";"..b..";"..t..":"..b..":^;"..b..";"..b..";",""..t..":"..b..":<;"..b..";"..a..":"..b..":o;"..b..";"..t..":"..b..":>;",""..b..";"..b..";"..t..":"..b..":v;"..b..";"..b..";"})
6830 changeProperty(designerSControlPicID,"visible",false)
6831 screens[designerSID]["sizeX"] = designerX
6832 screens[designerSID]["sizeY"] = designerY
6833 addElementToScreen(designerSControlPicID,designerSID,designerX-5,relY(50,designerSID))
6834 screens[designerSID]["sizeX"] = designerSmaxX
6835 screens[designerSID]["sizeY"] = designerSmaxY
6836
6837 addDynamicTextBox(designerSIndicatorID," ")
6838 changeProperty(designerSIndicatorID,"BGColor",colorPalette[3])
6839 addElementToScreen(designerSIndicatorID,designerSID,1,1)
6840 if designerMonitor==terminalID then
6841 changeProperty(designerSIndicatorID,"onClickMode","flash")
6842 changeProperty(designerSIndicatorID,"onActiveFunction",function()
6843 designerSButtonHeld = true
6844 changeProperty(designerSIndicatorID,"BGColor",colorPalette[1])
6845 refresh()
6846 end)
6847 else
6848 changeProperty(designerSIndicatorID,"onClickMode","toggle")
6849 changeProperty(designerSIndicatorID,"activeBGColor",colorPalette[1])
6850 end
6851 changeProperty(designerSIndicatorID,"visible",false)
6852
6853 addDynamicTextBox(designerSSelectionID,"$coords: $ele (§?$type§-):$part")
6854 changeProperty(designerSSelectionID,"textColor",colorPalette[1])
6855 changeProperty(designerSSelectionID,"BGColor",colorPalette[2])
6856 changeProperty(designerSSelectionID,"height",1)
6857 changeProperty(designerSSelectionID,"variables",{["ele"]=function() return designerSSelection end,["type"]=function() return getType(designerSSelection) end,["part"]="",["coords"]=function() local x,y = getPos(designerSSelection,designerSID) return "§?"..x.."§-:§?"..y.."§-" end})
6858 changeProperty(designerSSelectionID,"visible",false)
6859 changeProperty(designerSSelectionID,"onClickMode","flash")
6860 changeProperty(designerSSelectionID,"onActiveFunction",function()
6861 designerSSelection = ""
6862 changeProperty(designerSIndicatorID,"visible",false)
6863 changeProperty(designerSControlPicID,"visible",false)
6864 changeProperty(designerSRemoveID,"visible",false)
6865 changeProperty(designerSSelectionID,"visible",false)
6866 end)
6867 addElementToScreen(designerSSelectionID,designerSID,1,designerY-1)
6868
6869 setProcessClickEventFunction(function(type_,ID,part)
6870 if string.len(ID)<32 then
6871 designerSSelection = ID
6872 local x,y = getPos(ID,designerSID)
6873 local b = colorsArrayNumToString[colorPalette[2]]
6874 local t = colorsArrayNumToString[colorPalette[1]]
6875 local a = colorsArrayNumToString[colorPalette[3]]
6876
6877 changePos(designerSIndicatorID,designerSID,x,y)
6878 changeProperty(designerSIndicatorID,"visible",true)
6879 changeProperty(designerSControlPicID,"visible",true)
6880 changeProperty(designerSRemoveID,"visible",true)
6881 changeProperty(designerSSelectionID,"visible",true)
6882 getProperty(designerSSelectionID,"variables")["part"] = part
6883 refresh()
6884 end
6885
6886 if ID==designerSControlPicID then
6887 if part=="3:1" then
6888 local currX,currY = getPos(designerSSelection,designerSID)
6889 local newY = math.max(1,currY-1)
6890 changePos(designerSIndicatorID,designerSID,currX,newY)
6891 changePos(designerSSelection,designerSID,currX,newY)
6892 addToUndoRedoTable(designerSSelection,function(prop,var1,var2,var3,var4) changePos(prop,designerSID,var1,var2) changePos(designerSIndicatorID,designerSID,var1,var2) end, function(prop,var1,var2,var3,var4) changePos(prop,designerSID,var3,var4) changePos(designerSIndicatorID,designerSID,var3,var4) end,currX,currY,currX,newY)
6893 end
6894 if part=="1:2" then
6895 local currX,currY = getPos(designerSSelection,designerSID)
6896 local newX = math.max(1,currX-1)
6897 changePos(designerSIndicatorID,designerSID,newX,currY)
6898 changePos(designerSSelection,designerSID,newX,currY)
6899 addToUndoRedoTable(designerSSelection,function(prop,var1,var2,var3,var4) changePos(prop,designerSID,var1,var2) changePos(designerSIndicatorID,designerSID,var1,var2) end, function(prop,var1,var2,var3,var4) changePos(prop,designerSID,var3,var4) changePos(designerSIndicatorID,designerSID,var3,var4) end,currX,currY,newX,currY)
6900 end
6901 if part=="5:2" then
6902 local currX,currY = getPos(designerSSelection,designerSID)
6903 local newX = math.min(designerSmaxX,currX+1)
6904 changePos(designerSIndicatorID,designerSID,newX,currY)
6905 changePos(designerSSelection,designerSID,newX,currY)
6906 addToUndoRedoTable(designerSSelection,function(prop,var1,var2,var3,var4) changePos(prop,designerSID,var1,var2) changePos(designerSIndicatorID,designerSID,var1,var2) end, function(prop,var1,var2,var3,var4) changePos(prop,designerSID,var3,var4) changePos(designerSIndicatorID,designerSID,var3,var4) end,currX,currY,newX,currY)
6907 end
6908 if part=="3:3" then
6909 local currX,currY = getPos(designerSSelection,designerSID)
6910 local newY = math.min(designerSmaxY,currY+1)
6911 changePos(designerSIndicatorID,designerSID,currX,newY)
6912 changePos(designerSSelection,designerSID,currX,newY)
6913 addToUndoRedoTable(designerSSelection,function(prop,var1,var2,var3,var4) changePos(prop,designerSID,var1,var2) changePos(designerSIndicatorID,designerSID,var1,var2) end, function(prop,var1,var2,var3,var4) changePos(prop,designerSID,var3,var4) changePos(designerSIndicatorID,designerSID,var3,var4) end,currX,currY,currX,newY)
6914 end
6915 refresh()
6916 end
6917 end)
6918
6919 fullRefresh()
6920end
6921
6922--PROGRAM START
6923if not term.isColor() then
6924 error("EasyGUI is only supported on advanced computers. It's worth spending those gold ingots, trust me.")
6925end
6926term.clear()
6927term.setCursorPos(1,1)
6928
6929if fs.exists(fs.combine(root,"EasyGUI/log.txt")) then
6930 fs.delete(fs.combine(root,"EasyGUI/log.txt"))
6931end
6932logFile = fs.open(fs.combine(root,"EasyGUI/log.txt"),"a")
6933logFile.writeLine("--------------------------------")
6934logFile.writeLine("Log level: "..writingLogLevel)
6935
6936writeToLog("Starting Program. ",2)
6937
6938if shell~=nil then
6939 writeToLog("Loaded as program.",2)
6940 term.clear()
6941 setupStuff()
6942 if fs.exists(fs.combine(root,"EasyGUI/monitors.xml")) then
6943 loadMonitors()
6944 else
6945 findMonitors()
6946 saveMonitors()
6947 end
6948 transferDesigner()
6949 if designerMonitor==terminalID then
6950 designerX,designerY = term.getSize()
6951 if designerX<51 then
6952 term.clear()
6953 term.setCursorPos(1,1)
6954 term.setBackgroundColor(colors.black)
6955 error("Turtle and pocket screens are to small to run EasyGUI designer. You can either switch to a computer or run the designer on an attached monitor.")
6956 end
6957 else
6958 monitors[designerMonitor]["peripheral"].setTextScale(tonumber(getProperty(changeMonSScaleDDID,"entries")[getProperty(changeMonSScaleDDID,"selectionID")]))
6959 designerX,designerY = monitors[designerMonitor]["peripheral"].getSize()
6960 end
6961 --main program start
6962 addScreen(mainSID,designerX,designerY,colorPalette[1],colorPalette[2])
6963 setScreenToRenderOnTerminal(nil)
6964 term.setTextColor(colorPalette[1])
6965 term.setBackgroundColor(colorPalette[2])
6966 term.clear()
6967 term.setCursorPos(1,1)
6968 term.write("EasyGUI Designer running on monitor.")
6969 setDesignerScreen(mainSID)
6970 addDynamicTextBox(mainSBorderID,"")
6971 changeProperty(mainSBorderID,"borderThickness",1)
6972 changeProperty(mainSBorderID,"borderColor",colorPalette[3])
6973 changeProperty(mainSBorderID,"width",designerX)
6974 changeProperty(mainSBorderID,"height",designerY)
6975 addElementToScreen(mainSBorderID,mainSID,1,1)
6976
6977 addDynamicTextBox(mainSHeadingID,"EasyGUI Designer §?Main§- Menu")
6978 changeProperty(mainSHeadingID,"width",designerX-2)
6979 addElementToScreen(mainSHeadingID,mainSID,2,3)
6980
6981 addDynamicTextBox(mainSButton1ID,"Screens")
6982 changeProperty(mainSButton1ID,"BGColor",colorPalette[3])
6983 changeProperty(mainSButton1ID,"textColor",colorPalette[2])
6984 changeProperty(mainSButton1ID,"borderColor",colorPalette[1])
6985 changeProperty(mainSButton1ID,"width",relX(80,mainSID))
6986 changeProperty(mainSButton1ID,"height",relY(15,mainSID))
6987 changeProperty(mainSButton1ID,"borderThickness",1)
6988 changeProperty(mainSButton1ID,"onClickMode","flash")
6989 changeProperty(mainSButton1ID,"onActiveFunction",function() setDesignerScreen(screensSID)
6990 onLoadScreensS() end)
6991 addElementToScreen(mainSButton1ID,mainSID,relX(10,mainSID),relY(25,mainSID))
6992
6993 addDynamicTextBox(mainSButton2ID,"Elements")
6994 changeProperty(mainSButton2ID,"BGColor",colorPalette[3])
6995 changeProperty(mainSButton2ID,"textColor",colorPalette[2])
6996 changeProperty(mainSButton2ID,"borderColor",colorPalette[1])
6997 changeProperty(mainSButton2ID,"width",relX(80,mainSID))
6998 changeProperty(mainSButton2ID,"height",relY(15,mainSID))
6999 changeProperty(mainSButton2ID,"borderThickness",1)
7000 changeProperty(mainSButton2ID,"onClickMode","flash")
7001 changeProperty(mainSButton2ID,"onActiveFunction",function() setDesignerScreen(elementsSID)
7002 onLoadElementsS() end)
7003 addElementToScreen(mainSButton2ID,mainSID,relX(10,mainSID),relY(50,mainSID))
7004
7005 addDynamicTextBox(mainSButton3ID,"Exit")
7006 changeProperty(mainSButton3ID,"BGColor",colorPalette[3])
7007 changeProperty(mainSButton3ID,"textColor",colorPalette[2])
7008 changeProperty(mainSButton3ID,"borderColor",colorPalette[1])
7009 changeProperty(mainSButton3ID,"width",relX(80,mainSID))
7010 changeProperty(mainSButton3ID,"height",relY(15,mainSID))
7011 changeProperty(mainSButton3ID,"borderThickness",1)
7012 changeProperty(mainSButton3ID,"onClickMode","flash")
7013 changeProperty(mainSButton3ID,"onActiveFunction",function()
7014 os.queueEvent("terminate") end)
7015 addElementToScreen(mainSButton3ID,mainSID,relX(10,mainSID),relY(75,mainSID))
7016
7017 addScreen(screensSID,designerX,designerY,colorPalette[1],colorPalette[2])
7018 addDynamicTextBox(screensSHeadingID,"EasyGUI Designer §?Screens §-Menu")
7019 changeProperty(screensSHeadingID,"width",designerX-2)
7020 addElementToScreen(mainSBorderID,screensSID,1,1)
7021 addElementToScreen(screensSHeadingID,screensSID,2,3)
7022
7023 addScreen(newScreenSID,designerX,designerY,colorPalette[1],colorPalette[2])
7024 addElementToScreen(mainSBorderID,newScreenSID,1,1)
7025 addDynamicTextBox(newScreenSHeadingID,"EasyGUI Create §?new screen§-")
7026 changeProperty(newScreenSHeadingID,"width",designerX-2)
7027 addElementToScreen(newScreenSHeadingID,newScreenSID,2,3)
7028
7029 addDynamicTextBox(newScreenSTextID,"Please choose the §?size §-of the §?new screen§-.")
7030 changeProperty(newScreenSTextID,"width",designerX-2)
7031 addElementToScreen(newScreenSTextID,newScreenSID,2,5)
7032
7033 addColorPicker(newScreenSColor1ID,nil)
7034 addColorPicker(newScreenSColor2ID,nil)
7035 changeProperty(newScreenSColor1ID,"visible",false)
7036 changeProperty(newScreenSColor2ID,"visible",false)
7037 addElementToScreen(newScreenSColor1ID,newScreenSID,3,relY(40,newScreenSID))
7038 addElementToScreen(newScreenSColor2ID,newScreenSID,designerX-5,relY(40,newScreenSID))
7039
7040 addDynamicTextBox(newScreenSResultID,"Resulting size: $size §?<§-Continue§?>§-")
7041 changeProperty(newScreenSResultID,"width",designerX-2)
7042 changeProperty(newScreenSResultID,"variables",{["size"]=function() return "§?51§-:§?19§-" end})
7043 changeProperty(newScreenSResultID,"onClickMode","flash")
7044 changeProperty(newScreenSResultID,"onActiveFunction",function()
7045 if getProperty(newScreenSColor1ID,"visible") then
7046 if getProperty(newScreenSColor1ID,"selection")~=nil and getProperty(newScreenSColor2ID,"selection")~=nil then
7047 term.setTextColor(colorPalette[1])
7048 term.setBackgroundColor(colorPalette[2])
7049 term.clear()
7050 term.setCursorPos(1,1)
7051 print("Please enter an unique ID for the new screen:")
7052 repeat
7053 local input = read()
7054 if input~="" and input~=nil then
7055 if string.len(input)<32 then
7056 if not IDExists(input) then
7057 ID = input
7058 else
7059 print("ID already taken!")
7060 end
7061 else
7062 print("Must be less than 32 characters!")
7063 end
7064 else
7065 print("Cannot be an empty string.")
7066 end
7067 until ID~=nil
7068
7069 local bool,s = pcall(getProperty(newScreenSResultID,"variables")["size"])
7070 local x = tonumber(string.sub(s,1,string.find(s,":")-1))
7071 local y = tonumber(string.sub(s,string.find(s,":")+1))
7072 addScreen(ID,x,y,getProperty(newScreenSColor1ID,"selection"),getProperty(newScreenSColor2ID,"selection"))
7073 saveScreen(ID)
7074 changeProperty(newScreenSDDM1ID,"visible",true)
7075 changeProperty(newScreenSColor1ID,"visible",false)
7076 changeProperty(newScreenSColor2ID,"visible",false)
7077 changeProperty(newScreenSTextID,"content","Please choose the §?size §-of the §?new screen§-.")
7078 changeProperty(newScreenSResultID,"content","Resulting size: $size <Continue>")
7079 startDesigner(ID)
7080 end
7081 else
7082 changeProperty(newScreenSDDM1ID,"visible",false)
7083 changeProperty(newScreenSDDM2ID,"visible",false)
7084 changeProperty(newScreenSDDM3ID,"visible",false)
7085 changeProperty(newScreenSTextID,"content","[§?text§-] choose §?default§- colors [§?background§-]")
7086 changeProperty(newScreenSResultID,"content","<Continue>")
7087 changeProperty(newScreenSColor1ID,"visible",true)
7088 changeProperty(newScreenSColor2ID,"visible",true)
7089 refresh()
7090 end
7091 end)
7092 addElementToScreen(newScreenSResultID,newScreenSID,2,designerY-2)
7093
7094 local array = {}
7095 for name,data in pairs(monitors) do
7096 table.insert(array,name)
7097 end
7098 addDropDownMenu(newScreenSDDM2ID,array,1)
7099 changeProperty(newScreenSDDM2ID,"borderThickness",1)
7100 changeProperty(newScreenSDDM2ID,"borderColor",colorPalette[3])
7101 changeProperty(newScreenSDDM2ID,"highlightTextColor",colorPalette[2])
7102 changeProperty(newScreenSDDM2ID,"highlightBGColor",colorPalette[1])
7103 changeProperty(newScreenSDDM2ID,"visible",false)
7104 addElementToScreen(newScreenSDDM2ID,newScreenSID,relX(15,newScreenSID),relY(65,newScreenSID))
7105
7106 addDropDownMenu(newScreenSDDM3ID,{"0.5","1","1.5","2"},1)
7107 changeProperty(newScreenSDDM3ID,"borderThickness",1)
7108 changeProperty(newScreenSDDM3ID,"borderColor",colorPalette[3])
7109 changeProperty(newScreenSDDM3ID,"highlightTextColor",colorPalette[2])
7110 changeProperty(newScreenSDDM3ID,"highlightBGColor",colorPalette[1])
7111 changeProperty(newScreenSDDM3ID,"visible",false)
7112 addElementToScreen(newScreenSDDM3ID,newScreenSID,relX(60,newScreenSID),relY(65,newScreenSID))
7113
7114 addDropDownMenu(newScreenSDDM1ID,{"computer (51:19)","turtle (39:13)","pocket com (26:20)","monitor (variable)","custom"},1)
7115 changeProperty(newScreenSDDM1ID,"borderThickness",1)
7116 changeProperty(newScreenSDDM1ID,"borderColor",colorPalette[3])
7117 changeProperty(newScreenSDDM1ID,"highlightTextColor",colorPalette[2])
7118 changeProperty(newScreenSDDM1ID,"highlightBGColor",colorPalette[1])
7119 changeProperty(newScreenSDDM1ID,"onChangeFunction",function(ID,selec)
7120 if selec==4 then
7121 changeProperty(newScreenSDDM2ID,"visible",true)
7122 changeProperty(newScreenSDDM3ID,"visible",true)
7123 changeProperty(newScreenSResultID,"variables",{["size"]=function() monitors[getProperty(newScreenSDDM2ID,"entries")[getProperty(newScreenSDDM2ID,"selectionID")]]["peripheral"].setTextScale(tonumber(getProperty(newScreenSDDM3ID,"entries")[getProperty(newScreenSDDM3ID,"selectionID")]))
7124 local a,b = monitors[getProperty(newScreenSDDM2ID,"entries")[getProperty(newScreenSDDM2ID,"selectionID")]]["peripheral"].getSize()
7125 return a..":"..b end})
7126 refresh()
7127 else
7128 if selec==1 then
7129 changeProperty(newScreenSResultID,"variables",{["size"]=function() return "§?51§-:§?19§-" end })
7130 end
7131 if selec==2 then
7132 changeProperty(newScreenSResultID,"variables",{["size"]=function() return "§?39§-:§?13§-" end })
7133 end
7134 if selec==3 then
7135 changeProperty(newScreenSResultID,"variables",{["size"]=function() return "§?26§-:§?20§-" end })
7136 end
7137 if selec==5 then
7138 term.setBackgroundColor(colorPalette[2])
7139 term.setTextColor(colorPalette[1])
7140 term.clear()
7141 term.setCursorPos(1,1)
7142 print("Enter size X for new screen:")
7143 local a = read()
7144 print("Enter size Y for new screen:")
7145 local b = read()
7146 changeProperty(newScreenSResultID,"variables",{["size"]=function() return "§?"..a.."§-:§?"..b.."§-" end })
7147 fullRefresh()
7148 end
7149 changeProperty(newScreenSDDM2ID,"visible",false)
7150 changeProperty(newScreenSDDM3ID,"visible",false)
7151 end
7152 end)
7153 addElementToScreen(newScreenSDDM1ID,newScreenSID,relX(15,newScreenSID),relY(35,newScreenSID))
7154
7155 addDynamicTextBox(screensSMsgID,"Please check term!")
7156 changeProperty(screensSMsgID,"width",relX(80,screensSID))
7157 changeProperty(screensSMsgID,"height",relY(15,screensSID))
7158 changeProperty(screensSMsgID,"borderThickness",1)
7159 changeProperty(screensSMsgID,"visible",false)
7160 addElementToScreen(screensSMsgID,screensSID,relX(10,screensSID),relY(25,screensSID))
7161
7162 addDynamicTextBox(screensSButton1ID,"New Screen")
7163 changeProperty(screensSButton1ID,"BGColor",colorPalette[3])
7164 changeProperty(screensSButton1ID,"textColor",colorPalette[2])
7165 changeProperty(screensSButton1ID,"borderColor",colorPalette[1])
7166 changeProperty(screensSButton1ID,"width",relX(80,screensSID))
7167 changeProperty(screensSButton1ID,"height",relY(15,screensSID))
7168 changeProperty(screensSButton1ID,"borderThickness",1)
7169 changeProperty(screensSButton1ID,"onClickMode","flash")
7170 changeProperty(screensSButton1ID,"onActiveFunction",function()
7171 setDesignerScreen(newScreenSID)
7172 fullRefresh()
7173 end)
7174 addElementToScreen(screensSButton1ID,screensSID,relX(10,screensSID),relY(25,screensSID))
7175
7176 addDynamicTextBox(screensSButton2ID,"Edit")
7177 changeProperty(screensSButton2ID,"BGColor",colorPalette[3])
7178 changeProperty(screensSButton2ID,"textColor",colorPalette[2])
7179 changeProperty(screensSButton2ID,"borderColor",colorPalette[1])
7180 changeProperty(screensSButton2ID,"width",relX(40,screensSID)-1)
7181 changeProperty(screensSButton2ID,"height",relY(15,screensSID))
7182 changeProperty(screensSButton2ID,"borderThickness",1)
7183 changeProperty(screensSButton2ID,"onClickMode","flash")
7184 changeProperty(screensSButton2ID,"onActiveFunction",function() startDesigner(getProperty(screensSDDMenuID,"entries")[getProperty(screensSDDMenuID,"selectionID")]) end)
7185 addElementToScreen(screensSButton2ID,screensSID,relX(10,screensSID)+relX(80,screensSID)-relX(40,screensSID)+1,relY(50,screensSID))
7186
7187 addDynamicTextBox(screensSButton3ID,"Back")
7188 changeProperty(screensSButton3ID,"BGColor",colorPalette[3])
7189 changeProperty(screensSButton3ID,"textColor",colorPalette[2])
7190 changeProperty(screensSButton3ID,"borderColor",colorPalette[1])
7191 changeProperty(screensSButton3ID,"width",relX(80,screensSID))
7192 changeProperty(screensSButton3ID,"height",relY(15,screensSID))
7193 changeProperty(screensSButton3ID,"borderThickness",1)
7194 changeProperty(screensSButton3ID,"onClickMode","flash")
7195 changeProperty(screensSButton3ID,"onActiveFunction",function() setDesignerScreen(mainSID) end)
7196 addElementToScreen(screensSButton3ID,screensSID,relX(10,screensSID),relY(75,screensSID))
7197
7198 addDropDownMenu(screensSDDMenuID,nil,1)
7199 changeProperty(screensSDDMenuID,"borderThickness",1)
7200 changeProperty(screensSDDMenuID,"borderColor",colorPalette[3])
7201 changeProperty(screensSDDMenuID,"highlightTextColor",colorPalette[2])
7202 changeProperty(screensSDDMenuID,"highlightBGColor",colorPalette[1])
7203 changeProperty(screensSDDMenuID,"width",relX(40,screensSID)-1)
7204 addElementToScreen(screensSDDMenuID,screensSID,relX(10,screensSID),relY(50,screensSID))
7205
7206 addScreen(elementsSID,designerX,designerY,colorPalette[1],colorPalette[2])
7207 addDynamicTextBox(elementsSHeadingID,"EasyGUI Designer §?Elements §-Menu")
7208 changeProperty(elementsSHeadingID,"width",designerX-2)
7209 addElementToScreen(mainSBorderID,elementsSID,1,1)
7210 addElementToScreen(elementsSHeadingID,elementsSID,2,3)
7211 addElementToScreen(screensSButton3ID,elementsSID,relX(10,screensSID),relY(75,screensSID))
7212
7213 addElementToScreen(screensSMsgID,elementsSID,relX(10,elementsSID),relY(25,elementsSID))
7214
7215 local array = {"dynTextBox","slider","dropDownMenu","navMenu","colorPicker","progressBar","coordsSystem","picture"}
7216
7217 addDynamicTextBox(elementsSButton1ID,"Add")
7218 changeProperty(elementsSButton1ID,"BGColor",colorPalette[3])
7219 changeProperty(elementsSButton1ID,"textColor",colorPalette[2])
7220 changeProperty(elementsSButton1ID,"borderColor",colorPalette[1])
7221 changeProperty(elementsSButton1ID,"width",relX(40,elementsSID)-1)
7222 changeProperty(elementsSButton1ID,"height",relY(15,elementsSID))
7223 changeProperty(elementsSButton1ID,"borderThickness",1)
7224 changeProperty(elementsSButton1ID,"onClickMode","flash")
7225 changeProperty(elementsSButton1ID,"onActiveFunction",function() startEditor(newElement(array[getProperty(elementsSDDMenu1ID,"selectionID")])) end)
7226 addElementToScreen(elementsSButton1ID,elementsSID,relX(10,screensSID)+relX(80,screensSID)-relX(40,screensSID)+1,relY(25,elementsSID))
7227
7228 addDynamicTextBox(elementsSButton2ID,"Edit")
7229 changeProperty(elementsSButton2ID,"BGColor",colorPalette[3])
7230 changeProperty(elementsSButton2ID,"textColor",colorPalette[2])
7231 changeProperty(elementsSButton2ID,"borderColor",colorPalette[1])
7232 changeProperty(elementsSButton2ID,"width",relX(40,elementsSID)-1)
7233 changeProperty(elementsSButton2ID,"height",relY(15,elementsSID))
7234 changeProperty(elementsSButton2ID,"borderThickness",1)
7235 changeProperty(elementsSButton2ID,"onClickMode","flash")
7236 changeProperty(elementsSButton2ID,"onActiveFunction",function() startEditor(getProperty(elementsSDDMenu2ID,"entries")[getProperty(elementsSDDMenu2ID,"selectionID")],getType(getProperty(elementsSDDMenu2ID,"entries")[getProperty(elementsSDDMenu2ID,"selectionID")])) end)
7237 addElementToScreen(elementsSButton2ID,elementsSID,relX(10,screensSID)+relX(80,screensSID)-relX(40,screensSID)+1,relY(50,elementsSID))
7238
7239 addDropDownMenu(elementsSDDMenu2ID,nil,1)
7240 changeProperty(elementsSDDMenu2ID,"borderThickness",1)
7241 changeProperty(elementsSDDMenu2ID,"borderColor",colorPalette[3])
7242 changeProperty(elementsSDDMenu2ID,"highlightTextColor",colorPalette[2])
7243 changeProperty(elementsSDDMenu2ID,"highlightBGColor",colorPalette[1])
7244 changeProperty(elementsSDDMenu2ID,"width",relX(40,elementsSID)-1)
7245 addElementToScreen(elementsSDDMenu2ID,elementsSID,relX(10,elementsSID),relY(50,elementsSID))
7246
7247 addDropDownMenu(elementsSDDMenu1ID,array,1)
7248 changeProperty(elementsSDDMenu1ID,"borderThickness",1)
7249 changeProperty(elementsSDDMenu1ID,"borderColor",colorPalette[3])
7250 changeProperty(elementsSDDMenu1ID,"highlightTextColor",colorPalette[2])
7251 changeProperty(elementsSDDMenu1ID,"highlightBGColor",colorPalette[1])
7252 changeProperty(elementsSDDMenu1ID,"width",relX(40,elementsSID)-1)
7253 addElementToScreen(elementsSDDMenu1ID,elementsSID,relX(10,elementsSID),relY(25,elementsSID))
7254
7255 run(nil)
7256else
7257 writeToLog("Loaded as API.",2)
7258 if fs.exists(fs.combine(root,"EasyGUI/monitors.xml")) then
7259 loadMonitors()
7260 else
7261 print("EasyGUI was loaded as API, but there is no monitor file present. Starting monitor initialization sequence.")
7262 sleep(5)
7263 term.clear()
7264 setupStuff()
7265 findMonitors()
7266 saveMonitors()
7267 end
7268end
7269
7270--END OF EASYGUI API
7271-----------------------------