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