Project List BRIGADOON-0003
A script to display a project list menu in Open Simulator.
Loading...
Searching...
No Matches
project_list.lsl
Go to the documentation of this file.
1integer LastUnix;
4integer NextCheck;
10
11integer DISPLAY_SIDE = 1;
12integer COLUMNS = 3;
13integer ROWS = 10;
14integer ALT_ROWS = ROWS + 8;
15string SOURCE_URL = "https://www.little-sense.au/";
16string LOGO = "images/Brigadoon_Logo_Small.png";
17string FAILURE = "images/question_mark.png";
18string NO_LOGO = "images/no_logo.png";
19string BLANK_LOGO = "images/blank_label.png";
20string FILE_DIRECTORY = "project_dynamic/";
21//string DEVELOPMENT_LIST = "project_dynamic/Destinations.txt";
22//string TASK_LIST = "project_dynamic/task_list.txt";
23
25{
26 integer TEXTURE_SIZE = 512;
27 integer FONT_SIZE = (TEXTURE_SIZE / ROWS) / 5;
28
29
30 string drawList;
31 drawList = osSetPenSize(drawList, 1);
32 drawList = osSetFontSize(drawList, FONT_SIZE);
33
34 drawList = osMovePen(drawList, 0, 0);
35 drawList = osSetPenColor(drawList, "Gray");
36 drawList = osDrawFilledRectangle(drawList, TEXTURE_SIZE, TEXTURE_SIZE);
37
38 integer x;
39 integer y;
40 string Logo;
41
42 for (x = 0; x < COLUMNS; x++)
43 {
44 for (y = 0; y < ROWS; y++)
45 {
46 integer CELL_HEIGHT = TEXTURE_SIZE / (ROWS + 8);
47 integer CELL_WIDHT = TEXTURE_SIZE / COLUMNS;
48 integer xTopLeft = x * CELL_WIDHT;
49 integer yTopLeft = y * CELL_HEIGHT;
50
51 drawList = osSetPenColor(drawList, "White");
52 drawList = osMovePen(drawList, xTopLeft, yTopLeft);
53 drawList = osDrawRectangle(drawList, CELL_WIDHT, CELL_HEIGHT);
54
55 integer index = (y + x * ROWS);
56 string cellName = llList2String(DestinationsName, index);
57 integer cellValid = llList2Integer(DestinationsValid, index);
58
59 string cellBbackground;
60 if (cellName == "")
61 {
62 cellBbackground = "DarkGray";
63 Logo = SOURCE_URL + BLANK_LOGO;
64 }
65 else
66 {
67 if (cellValid)
68 {
69 cellBbackground = "CadetBlue";
70 Logo = llList2String(DestinationsLogo, index);
71 }
72 else
73 {
74 cellBbackground = "IndianRed";
75 Logo = SOURCE_URL + FAILURE;
76 }
77 }
78
79 drawList = osSetPenColor(drawList, cellBbackground);
80 drawList = osMovePen(drawList, xTopLeft + 2, yTopLeft + 2);
81 drawList = osDrawFilledRectangle(drawList, CELL_WIDHT - 3, CELL_HEIGHT - 3);
82
83 xTopLeft += 2;
84 yTopLeft += 6;
85 drawList = osSetPenColor(drawList, "Black");
86 drawList = osMovePen(drawList, xTopLeft + 3, yTopLeft + 3);
87 drawList = osDrawImage(drawList, 16,16, Logo);
88 drawList = osMovePen(drawList, xTopLeft + 20, yTopLeft - 1);
89 drawList = osDrawText(drawList, cellName);
90 }
91 }
92 osSetDynamicTextureDataBlendFace("", "vector", drawList, "alpha:false,width:" + (string)TEXTURE_SIZE + ",height:" + (string)TEXTURE_SIZE, FALSE, 1, 0, 255, DISPLAY_SIDE);
93}
94
95// *********** FOR DOXYGEN PROCESSING ONLY ****************
96//default
97default()
98//************ REMOVE COMMENTS AFTER DOXYGEN PROCESSING ***
99{
100 state_entry()
101 {
102 string display_list;
103 string description = llToLower(llGetObjectDesc()) + ".txt";;
104
105 llHTTPRequest(SOURCE_URL + FILE_DIRECTORY + description, [HTTP_METHOD, "GET"], "");
106 }
107
108 http_response(key Dummy, integer Status, list Meta, string Body)
109 {
110 DestinationsLogo = [];
111 DestinationsName = [];
112 DestinationsLink = [];
114 list Parse = llParseString2List(Body, ["\n"], []);
115 integer i;
116 for (i = 0; i < llGetListLength(Parse); ++i)
117 {
118 if (llList2String(Parse, i) != "")
119 {
120 list Line = llParseString2List(llList2String(Parse, i), ["="], []);
121 if (llGetListLength(Line) == 3 &&
122 llList2String(Line, 0) != "" &&
123 llList2String(Line, 1) != "" &&
124 llList2String(Line, 2) != "")
125 {
126 DestinationsName = DestinationsName + [llList2String(Line, 0)];
127 DestinationsLink = DestinationsLink + [llList2String(Line, 1)];
128 DestinationsLogo = DestinationsLogo + [llList2String(Line, 2)];
130 }
131 }
132 }
134 state Ready;
135 }
136 }
137
138// *************** FOR DOXGEN PROCESSING ONLY ***********************
139//state Ready
140void Ready()
141// *************** REMOVE AFTER DOXYGEN PROCESSING COMPLETE **********
142
143{
144 state_entry()
145 {
146 LastUnix = llGetUnixTime();
147 DestValidCheck = 0;
148 NextCheck = -1;
149 HasCheckedChanged = FALSE;
150 CheckRequest = llHTTPRequest(llList2String(DestinationsLink, DestValidCheck), [HTTP_METHOD, "GET"], "");
151 llSetTimerEvent(10);
152 }
153
154 http_response(key Dummy, integer Status, list Meta, string Body)
155 {
156 if (Dummy != CheckRequest)
157 {return;}
158 llSetText(".", <1, 0, 0>, 1);
159 if (Status == 200)
160 {
161 if (llList2Integer(DestinationsValid, DestValidCheck) == FALSE)
162 {HasCheckedChanged = TRUE;}
164 }
165 else
166 {
167 if (llList2Integer(DestinationsValid, DestValidCheck) == TRUE)
168 {HasCheckedChanged = TRUE;}
170 }
172 if (DestValidCheck > llGetListLength(DestinationsLink) - 1)
173 {
175 {UpdateTexture();}
176 NextCheck = llGetUnixTime();
177 llSetText("", <1, 0, 0>, 1);
178 return;
179 }
180 llSleep(1);
181 CheckRequest = llHTTPRequest(llList2String(DestinationsLink, DestValidCheck), [HTTP_METHOD, "GET"], "");
182 }
183
184 timer()
185 {
186 if (LastUnix + 3600 * 4 < llGetUnixTime())
187 {state default;}
188 if (NextCheck != -1 && NextCheck + 90 < llGetUnixTime())
189 {
190 NextCheck = -1;
191 DestValidCheck = 0;
192 HasCheckedChanged = FALSE;
193 CheckRequest = llHTTPRequest(llList2String(DestinationsLink, DestValidCheck), [HTTP_METHOD, "GET"], "");
194 }
195 }
196
197
198 touch_start(integer Dummy)
199 {
200 vector point = llDetectedTouchST(0);
201 integer face = llDetectedTouchFace(0);
202 integer link = llDetectedLinkNumber(0);
203
204// if (link != LINK_ROOT)
205// {return;}
206 if (point == TOUCH_INVALID_TEXCOORD)
207 {return;}
208 if (face != DISPLAY_SIDE)
209 {return;}
210
211 //integer y = (ALT_ROWS - 1) - llFloor(point.y * ALT_ROWS);
212 integer y = (ROWS - 1) - llFloor(point.y * ROWS);
213 integer x = llFloor(point.x * COLUMNS);
214 integer index = (y + x * ROWS);
215
216 if (llList2String(DestinationsLink, index) == "")
217 {return;}
218
219 if (llList2Integer(DestinationsValid, index) == TRUE)
220 {
221 key id = llDetectedKey(0);
222 string info = "Dummy Information";
223 llLoadURL(id, info, llList2String(DestinationsLink, index));
224 }
225 else
226 {
227 llDialog(llDetectedKey(0), "This link is invalid.", ["Ok"], -5);
228 }
229 }
230}
231
list DestinationsLink
string LOGO
integer ALT_ROWS
integer DISPLAY_SIDE
string BLANK_LOGO
string FAILURE
void Ready()
list DestinationsLogo
integer ROWS
integer DestValidCheck
string SOURCE_URL
list DestinationsValid
list DestinationsName
UpdateTexture()
integer COLUMNS
key CheckRequest
string FILE_DIRECTORY
string NO_LOGO
integer LastUnix
integer NextCheck
integer HasCheckedChanged