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