Project List BRIGADOON-0003
A script to display a project list menu in Open Simulator.
Loading...
Searching...
No Matches
project_list.lsl File Reference

Go to the source code of this file.

Functions

 UpdateTexture ()
 
 default ()
 
void Ready ()
 

Variables

integer LastUnix
 
integer DestValidCheck
 
integer HasCheckedChanged
 
integer NextCheck
 
list DestinationsName
 
list DestinationsLink
 
list DestinationsLogo
 
list DestinationsValid
 
key CheckRequest
 
integer DISPLAY_SIDE = 1
 
integer COLUMNS = 3
 
integer ROWS = 10
 
integer ALT_ROWS = ROWS + 8
 
string SOURCE_URL = "https://www.little-sense.au/"
 
string LOGO = "images/Brigadoon_Logo_Small.png"
 
string FAILURE = "images/question_mark.png"
 
string NO_LOGO = "images/no_logo.png"
 
string BLANK_LOGO = "images/blank_label.png"
 
string FILE_DIRECTORY = "project_dynamic/"
 

Function Documentation

◆ default()

default ( )

Definition at line 97 of file project_list.lsl.

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 }
list DestinationsLink
void Ready()
list DestinationsLogo
string SOURCE_URL
list DestinationsValid
list DestinationsName
UpdateTexture()
string FILE_DIRECTORY

References DestinationsLink, DestinationsLogo, DestinationsName, DestinationsValid, FILE_DIRECTORY, Ready(), SOURCE_URL, and UpdateTexture().

Here is the call graph for this function:

◆ Ready()

void Ready ( )

Definition at line 140 of file project_list.lsl.

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}
integer DISPLAY_SIDE
integer ROWS
integer DestValidCheck
integer COLUMNS
key CheckRequest
integer LastUnix
integer NextCheck
integer HasCheckedChanged

References CheckRequest, COLUMNS, DestinationsLink, DestinationsValid, DestValidCheck, DISPLAY_SIDE, HasCheckedChanged, LastUnix, NextCheck, ROWS, and UpdateTexture().

Referenced by default().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateTexture()

UpdateTexture ( )

Definition at line 24 of file project_list.lsl.

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}
string BLANK_LOGO
string FAILURE

References BLANK_LOGO, COLUMNS, DestinationsLogo, DestinationsName, DestinationsValid, DISPLAY_SIDE, FAILURE, ROWS, and SOURCE_URL.

Referenced by default(), and Ready().

Here is the caller graph for this function:

Variable Documentation

◆ ALT_ROWS

integer ALT_ROWS = ROWS + 8

Definition at line 14 of file project_list.lsl.

◆ BLANK_LOGO

string BLANK_LOGO = "images/blank_label.png"

Definition at line 19 of file project_list.lsl.

Referenced by UpdateTexture().

◆ CheckRequest

key CheckRequest

Definition at line 9 of file project_list.lsl.

Referenced by Ready().

◆ COLUMNS

integer COLUMNS = 3

Definition at line 12 of file project_list.lsl.

Referenced by Ready(), and UpdateTexture().

◆ DestinationsLink

list DestinationsLink

Definition at line 6 of file project_list.lsl.

Referenced by default(), and Ready().

◆ DestinationsLogo

list DestinationsLogo

Definition at line 7 of file project_list.lsl.

Referenced by default(), and UpdateTexture().

◆ DestinationsName

list DestinationsName

Definition at line 5 of file project_list.lsl.

Referenced by default(), and UpdateTexture().

◆ DestinationsValid

list DestinationsValid

Definition at line 8 of file project_list.lsl.

Referenced by default(), Ready(), and UpdateTexture().

◆ DestValidCheck

integer DestValidCheck

Definition at line 2 of file project_list.lsl.

Referenced by Ready().

◆ DISPLAY_SIDE

integer DISPLAY_SIDE = 1

Definition at line 11 of file project_list.lsl.

Referenced by Ready(), and UpdateTexture().

◆ FAILURE

string FAILURE = "images/question_mark.png"

Definition at line 17 of file project_list.lsl.

Referenced by UpdateTexture().

◆ FILE_DIRECTORY

string FILE_DIRECTORY = "project_dynamic/"

Definition at line 20 of file project_list.lsl.

Referenced by default().

◆ HasCheckedChanged

integer HasCheckedChanged

Definition at line 3 of file project_list.lsl.

Referenced by Ready().

◆ LastUnix

integer LastUnix

Definition at line 1 of file project_list.lsl.

Referenced by Ready().

◆ LOGO

string LOGO = "images/Brigadoon_Logo_Small.png"

Definition at line 16 of file project_list.lsl.

◆ NextCheck

integer NextCheck

Definition at line 4 of file project_list.lsl.

Referenced by Ready().

◆ NO_LOGO

string NO_LOGO = "images/no_logo.png"

Definition at line 18 of file project_list.lsl.

◆ ROWS

integer ROWS = 10

Definition at line 13 of file project_list.lsl.

Referenced by Ready(), and UpdateTexture().

◆ SOURCE_URL

string SOURCE_URL = "https://www.little-sense.au/"

Definition at line 15 of file project_list.lsl.

Referenced by default(), and UpdateTexture().