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