Project List BRIGADOON-0003
A script to display a project list menu in Open Simulator.
Loading...
Searching...
No Matches
project_list.osl
Go to the documentation of this file.
1
18
23integer LastUnix;
24
30
31
33integer NextCheck;
39
40integer DISPLAY_SIDE = 1;
41integer COLUMNS = 3;
42integer ROWS = 10;
43integer ALT_ROWS = ROWS + 8;
44string SOURCE_URL = "https://www.little-sense.au/";
45string LOGO = "images/Brigadoon_Logo_Small.png";
46string FAILURE = "images/question_mark.png";
47string NO_LOGO = "images/no_logo.png";
48string BLANK_LOGO = "images/blank_label.png";
49string FILE_DIRECTORY = "project_dynamic/";
50//string DEVELOPMENT_LIST = "project_dynamic/Destinations.txt";
51//string TASK_LIST = "project_dynamic/task_list.txt";
52
58{
59 integer TEXTURE_SIZE = 512;
60 integer FONT_SIZE = (TEXTURE_SIZE / ROWS) / 5;
61
62
63 string drawList;
64 drawList = osSetPenSize(drawList, 1);
65 drawList = osSetFontSize(drawList, FONT_SIZE);
66
67 drawList = osMovePen(drawList, 0, 0);
68 drawList = osSetPenColor(drawList, "Gray");
69 drawList = osDrawFilledRectangle(drawList, TEXTURE_SIZE, TEXTURE_SIZE);
70
71 integer x;
72 integer y;
73 string Logo;
74
75 // Step through the Column in the Display
76 for (x = 0; x < COLUMNS; x++)
77 {
78 // Step through the rows in each column
79 for (y = 0; y < ROWS; y++)
80 {
81 //Calculate the Cell Height and Vell Width
82 integer CELL_HEIGHT = TEXTURE_SIZE / (ROWS + 8);
83 integer CELL_WIDTH = TEXTURE_SIZE / COLUMNS;
84
85 // Calculate the Location of the Top Left Cell
86 integer xTopLeft = x * CELL_WIDTH;
87 integer yTopLeft = y * CELL_HEIGHT;
88
89 drawList = osSetPenColor(drawList, "White");
90 drawList = osMovePen(drawList, xTopLeft, yTopLeft);
91 drawList = osDrawRectangle(drawList, CELL_WIDTH, CELL_HEIGHT);
92
93 integer index = (y + x * ROWS);
94 string cellName = llList2String(DestinationsName, index);
95 integer cellValid = llList2Integer(DestinationsValid, index);
96
97 // If the cell is blank, use a blank logo as well
98 string cellBbackground;
99 if (cellName == "")
100 {
101 cellBbackground = "DarkGray";
102 Logo = SOURCE_URL + BLANK_LOGO;
103 }
104
105 // If the Cell is not blank check if it is valid
106 else
107 {
108 // If the Cell valid, give it a blue background and get its Logo
109 if (cellValid)
110 {
111 cellBbackground = "CadetBlue";
112 Logo = llList2String(DestinationsLogo, index);
113 }
114
115 // If the cell is isn't valid, make the background red & set the failed logo.
116 else
117 {
118 cellBbackground = "IndianRed";
119 Logo = SOURCE_URL + FAILURE;
120 }
121 }
122
123 // Fill the Cell with the Background Colour
124 drawList = osSetPenColor(drawList, cellBbackground);
125 drawList = osMovePen(drawList, xTopLeft + 2, yTopLeft + 2);
126 drawList = osDrawFilledRectangle(drawList, CELL_WIDTH - 3, CELL_HEIGHT - 3);
127
128 // Put the Logo onto into the adjacent cell/
129 xTopLeft += 2;
130 yTopLeft += 6;
131 drawList = osSetPenColor(drawList, "Black");
132 drawList = osMovePen(drawList, xTopLeft + 3, yTopLeft + 3);
133 drawList = osDrawImage(drawList, 16,16, Logo);
134
135 // Draw the Cell Name into the call
136 drawList = osMovePen(drawList, xTopLeft + 20, yTopLeft - 1);
137 drawList = osDrawText(drawList, cellName);
138 }
139 }
140
141 // Use the Instructions on the drawList string to draw the cells
142 osSetDynamicTextureDataBlendFace("", "vector", drawList, "alpha:false,width:" + (string)TEXTURE_SIZE + ",height:" + (string)TEXTURE_SIZE, FALSE, 1, 0, 255, DISPLAY_SIDE);
143}
144
145// *********** FOR DOXYGEN PROCESSING ONLY ****************
146//default
147default()
148//************ REMOVE COMMENTS AFTER DOXYGEN PROCESSING ***
149{
150
156 state_entry()
157 {
158 string display_list;
159
160 // Get the filename holding the information to be displayed
161 string description = llToLower(llGetObjectDesc()) + ".txt";;
162
163 // Create the URL and then send out a Request for the contents of the Data Text File
164 llHTTPRequest(SOURCE_URL + FILE_DIRECTORY + description, [HTTP_METHOD, "GET"], "");
165 }
166
167 /* \fn http_response(key Dummy, integer Status, list Meta, string Body)
168 * \brief Process the Data returned for the File by he HTTP Request
169 * \param Dummy The response key from the HTTP Request
170 * \param Status The Return Status from the HTTP Request
171 * \param Meta The List of Meta Data returned from the HTTP Request
172 * \param The contents of the Data file returned as a string
173 *
174 * This routine returns the contents of the data file.
175 *
176 */
177 http_response(key Dummy, integer Status, list Meta, string Body)
178 {
179 DestinationsLogo = [];
180 DestinationsName = [];
181 DestinationsLink = [];
183
184 // Split the Returned Data Text File into lines
185 list Parse = llParseString2List(Body, ["\n"], []);
186
187 // Step through each Line of Text
188 integer i;
189 for (i = 0; i < llGetListLength(Parse); ++i)
190 {
191 // If this isn't a blank Line, Process It
192 if (llList2String(Parse, i) != "")
193 {
194 // Break the LIne into components
195 list Line = llParseString2List(llList2String(Parse, i), ["="], []);
196
197 // Only process if None of the Information is missing
198 if (llGetListLength(Line) == 3 &&
199 llList2String(Line, 0) != "" &&
200 llList2String(Line, 1) != "" &&
201 llList2String(Line, 2) != "")
202 {
203 DestinationsName = DestinationsName + [llList2String(Line, 0)];
204 DestinationsLink = DestinationsLink + [llList2String(Line, 1)];
205 DestinationsLogo = DestinationsLogo + [llList2String(Line, 2)];
206
207 // Append a TRUE Flag to each line
209 }
210 }
211 }
212
213 // Update the Texture and move into the Ready state.
215 state Ready;
216 }
217 }
218
219// *************** FOR DOXGEN PROCESSING ONLY ***********************
220//state Ready
221void Ready()
222// *************** REMOVE AFTER DOXYGEN PROCESSING COMPLETE **********
223
224{
225 state_entry()
226 {
227 LastUnix = llGetUnixTime();
228 DestValidCheck = 0;
229 NextCheck = -1;
230 HasCheckedChanged = FALSE;
231 CheckRequest = llHTTPRequest(llList2String(DestinationsLink, DestValidCheck), [HTTP_METHOD, "GET"], "");
232 llSetTimerEvent(10);
233 }
234
235 http_response(key Dummy, integer Status, list Meta, string Body)
236 {
237 if (Dummy != CheckRequest)
238 {return;}
239 llSetText(".", <1, 0, 0>, 1);
240 if (Status == 200)
241 {
242 if (llList2Integer(DestinationsValid, DestValidCheck) == FALSE)
243 {HasCheckedChanged = TRUE;}
245 }
246 else
247 {
248 if (llList2Integer(DestinationsValid, DestValidCheck) == TRUE)
249 {HasCheckedChanged = TRUE;}
251 }
253 if (DestValidCheck > llGetListLength(DestinationsLink) - 1)
254 {
256 {UpdateTexture();}
257 NextCheck = llGetUnixTime();
258 llSetText("", <1, 0, 0>, 1);
259 return;
260 }
261 llSleep(1);
262 CheckRequest = llHTTPRequest(llList2String(DestinationsLink, DestValidCheck), [HTTP_METHOD, "GET"], "");
263 }
264
265 timer()
266 {
267 if (LastUnix + 3600 * 4 < llGetUnixTime())
268 {state default;}
269 if (NextCheck != -1 && NextCheck + 90 < llGetUnixTime())
270 {
271 NextCheck = -1;
272 DestValidCheck = 0;
273 HasCheckedChanged = FALSE;
274 CheckRequest = llHTTPRequest(llList2String(DestinationsLink, DestValidCheck), [HTTP_METHOD, "GET"], "");
275 }
276 }
277
278
279 touch_start(integer Dummy)
280 {
281 vector point = llDetectedTouchST(0);
282 integer face = llDetectedTouchFace(0);
283 integer link = llDetectedLinkNumber(0);
284
285// if (link != LINK_ROOT)
286// {return;}
287 if (point == TOUCH_INVALID_TEXCOORD)
288 {return;}
289 if (face != DISPLAY_SIDE)
290 {return;}
291
292 //integer y = (ALT_ROWS - 1) - llFloor(point.y * ALT_ROWS);
293 integer y = (ROWS - 1) - llFloor(point.y * ROWS);
294 integer x = llFloor(point.x * COLUMNS);
295 integer index = (y + x * ROWS);
296
297 if (llList2String(DestinationsLink, index) == "")
298 {return;}
299
300 if (llList2Integer(DestinationsValid, index) == TRUE)
301 {
302 key id = llDetectedKey(0);
303 string info = "Dummy Information";
304 llLoadURL(id, info, llList2String(DestinationsLink, index));
305 }
306 else
307 {
308 llDialog(llDetectedKey(0), "This link is invalid.", ["Ok"], -5);
309 }
310 }
311}
312
list DestinationsLink
string LOGO
integer ALT_ROWS
integer DISPLAY_SIDE
string BLANK_LOGO
string FAILURE
void Ready()
list DestinationsLogo
integer ROWS
integer DestValidCheck
Validity Check Flag.
string SOURCE_URL
list DestinationsValid
list DestinationsName
UpdateTexture()
Update the Face's Texture based on Project list.
integer COLUMNS
key CheckRequest
string FILE_DIRECTORY
string NO_LOGO
integer LastUnix
Last Update Time (Unix timestamp)
integer NextCheck
integer HasCheckedChanged