1 | |
---|
2 | // ===================================================================================== |
---|
3 | // Standard UI |
---|
4 | // ===================================================================================== |
---|
5 | |
---|
6 | // Vertical scrollbar |
---|
7 | |
---|
8 | VerticalScrollBar=function() { }; |
---|
9 | VerticalScrollBar.prototype=new MovieClip(); |
---|
10 | VerticalScrollBar.prototype.init=function(h,max,barheight,dragfunc) { |
---|
11 | this.max=max; |
---|
12 | this.height=h; |
---|
13 | this.barheight=barheight; |
---|
14 | this.dragsize=(h-20-barheight); |
---|
15 | this.doOnDrag=dragfunc; |
---|
16 | |
---|
17 | this.attachMovie("scroll_up" ,"up" ,1); this.up._y=0; |
---|
18 | this.up.onPress=startScrollBarUp; |
---|
19 | this.up.onRelease=stopScrollBarMove; |
---|
20 | |
---|
21 | this.attachMovie("scroll_down","down",2); this.down._y=h-10; |
---|
22 | this.down.onPress=startScrollBarDown; |
---|
23 | this.down.onRelease=stopScrollBarMove; |
---|
24 | |
---|
25 | this.lineStyle(1,0xCCCCCC,100); |
---|
26 | this.moveTo(0,10); this.lineTo(0 ,this.height-10); |
---|
27 | this.lineTo(10,this.height-10); this.lineTo(10,10); |
---|
28 | this.lineTo(0,10); |
---|
29 | |
---|
30 | this.createEmptyMovieClip("bar",3); |
---|
31 | this.bar.onPress=pressScrollBar; |
---|
32 | this.bar.onRelease=releaseScrollBar; |
---|
33 | this.bar._y=10; |
---|
34 | with (this.bar) { |
---|
35 | clear(); |
---|
36 | beginFill(0xBBBBBB,100); |
---|
37 | moveTo(0,0); lineTo(10,0); |
---|
38 | lineTo(10,this.barheight); lineTo(0,this.barheight); |
---|
39 | lineTo(0,0); endFill(); |
---|
40 | }; |
---|
41 | }; |
---|
42 | |
---|
43 | VerticalScrollBar.prototype.moveto=function(ppos) { |
---|
44 | this.bar._x=0; |
---|
45 | this.bar._y=ppos/this.max*this.dragsize+10; |
---|
46 | }; |
---|
47 | |
---|
48 | function startScrollBarUp() { clearInterval(this._parent.mover); this._parent.mover=setInterval(doScrollBarMove,10,this._parent,-2); } |
---|
49 | function startScrollBarDown() { clearInterval(this._parent.mover); this._parent.mover=setInterval(doScrollBarMove,10,this._parent, 2); } |
---|
50 | function stopScrollBarMove() { clearInterval(this._parent.mover); } |
---|
51 | function doScrollBarMove(sb,inc) { |
---|
52 | sb.bar._y=Math.min(Math.max(sb.bar._y+inc,10),sb.dragsize+10); |
---|
53 | sb.doOnDrag.call(sb, ((sb.bar._y-10)/sb.dragsize)*sb.max); |
---|
54 | } |
---|
55 | |
---|
56 | function pressScrollBar() { |
---|
57 | this.startDrag(false,0,10,0,this._parent.dragsize+10); |
---|
58 | this.onMouseMove=function() { |
---|
59 | this._parent.doOnDrag.call(this._parent, ((this._y-10)/this._parent.dragsize)*this._parent.max); |
---|
60 | }; |
---|
61 | }; |
---|
62 | |
---|
63 | function releaseScrollBar() { |
---|
64 | delete this.onMouseMove; |
---|
65 | this.stopDrag(); |
---|
66 | }; |
---|
67 | Object.registerClass("vertical",VerticalScrollBar); |
---|
68 | |
---|
69 | // Floating palette |
---|
70 | |
---|
71 | var palettecss=new TextField.StyleSheet(); |
---|
72 | palettecss.load("/potlatch/photos.css?d=1"); |
---|
73 | |
---|
74 | UIPalette=function() {}; |
---|
75 | UIPalette.prototype=new MovieClip(); |
---|
76 | |
---|
77 | UIPalette.prototype.init=function(x,y,w,h,n) { |
---|
78 | this.w=w; |
---|
79 | this.h=h; |
---|
80 | this.setPosition(x,y); |
---|
81 | this.createControls(); |
---|
82 | this.redraw(n); |
---|
83 | }; |
---|
84 | |
---|
85 | UIPalette.prototype.initHTML=function(x,y,n,tx) { |
---|
86 | this.createTextField('desc',1,5,5,190,290); |
---|
87 | with (this.desc) { |
---|
88 | multiline=true; wordWrap=true; selectable=true; type='dynamic'; |
---|
89 | autoSize='left'; |
---|
90 | styleSheet=_root.palettecss; |
---|
91 | html=true; |
---|
92 | htmlText=tx; |
---|
93 | htmlText=htmlText.split('TARGET=""').join(''); |
---|
94 | htmlText=htmlText.split('HREF="').join('href="'); |
---|
95 | htmlText=htmlText.split('href="').join('target="_blank" href="'); |
---|
96 | } |
---|
97 | this.w=this.desc._width+10; |
---|
98 | this.h=Math.max(150,this.desc._height+10); |
---|
99 | this.setPosition(x,y); |
---|
100 | this.createControls(n); |
---|
101 | this.redraw(); |
---|
102 | }; |
---|
103 | |
---|
104 | UIPalette.prototype.setPosition=function(x,y) { |
---|
105 | if (x>Stage.width-this.w) { x=x-this.w-20; } |
---|
106 | this._x=x; |
---|
107 | this._y=Math.max(20,y); |
---|
108 | }; |
---|
109 | |
---|
110 | UIPalette.prototype.createControls=function(n) { |
---|
111 | |
---|
112 | this.createEmptyMovieClip("drag",2); |
---|
113 | |
---|
114 | this.createEmptyMovieClip("resizeHandle",3); |
---|
115 | with (this.resizeHandle) { |
---|
116 | beginFill(0xFFFFFF,50); moveTo(0,0); lineTo(-10,0); |
---|
117 | lineTo(-10,-10); lineTo(0,-10); lineTo(0,0); endFill(); |
---|
118 | lineStyle(1,0xFFFFFF); |
---|
119 | moveTo(-9,-2); lineTo(-2,-9); |
---|
120 | moveTo(-6,-2); lineTo(-2,-6); |
---|
121 | moveTo(-3,-2); lineTo(-2,-3); |
---|
122 | } |
---|
123 | |
---|
124 | this.createTextField('titleText',4,20,-18,w-20,19); |
---|
125 | this.titleText.text=n; |
---|
126 | this.titleText.setTextFormat(plainWhite); |
---|
127 | this.titleText.selectable=false; |
---|
128 | |
---|
129 | this.drag.onPress=function() { this._parent.startDrag(); }; |
---|
130 | this.drag.onRelease=function() { this._parent.stopDrag(); }; |
---|
131 | |
---|
132 | this.attachMovie("closecross","closex",5); |
---|
133 | this.closex._x=10; |
---|
134 | this.closex._y=-9; |
---|
135 | this.closex.onPress=function() { removeMovieClip(this._parent); }; |
---|
136 | |
---|
137 | this.resizeHandle.onPress=function() { this.onMouseMove=function() { this._parent.resize(); }; }; |
---|
138 | this.resizeHandle.onMouseUp=function() { this.onMouseMove=null; }; |
---|
139 | }; |
---|
140 | |
---|
141 | UIPalette.prototype.resize=function() { |
---|
142 | var w=_root._xmouse-this._x; |
---|
143 | var h=_root._ymouse-this._y; |
---|
144 | if (w<50 || h<50) { return; } |
---|
145 | this.w=w; this.h=h; this.redraw(); |
---|
146 | }; |
---|
147 | |
---|
148 | UIPalette.prototype.redraw=function() { |
---|
149 | with (this) { |
---|
150 | clear(); |
---|
151 | beginFill(0,80); moveTo(0,0); lineTo(this.w,0); |
---|
152 | lineTo(this.w,this.h); lineTo(0,h); lineTo(0,0); endFill(); |
---|
153 | } |
---|
154 | with (this.drag) { |
---|
155 | clear(); |
---|
156 | beginFill(0,100); moveTo(0,0); lineTo(this.w,0); |
---|
157 | lineTo(this.w,-17); lineTo(0,-17); lineTo(0,0); endFill(); |
---|
158 | } |
---|
159 | with (this.resizeHandle) { _x=this.w; _y=this.h; } |
---|
160 | with (this.desc) { _width=this.w-10; _height=this.h-10; } |
---|
161 | this.titleText._width=this.w-20; |
---|
162 | }; |
---|
163 | |
---|
164 | Object.registerClass("palette",UIPalette); |
---|
165 | |
---|
166 | |
---|
167 | // Radio buttons |
---|
168 | // UIRadio.init |
---|
169 | // UIRadio.addButton(x,y,text) |
---|
170 | // UIRadio.select(n) |
---|
171 | |
---|
172 | UIRadio=function() { |
---|
173 | this.selected=0; |
---|
174 | this.buttons=0; |
---|
175 | this.xpos=new Array(); |
---|
176 | this.ypos=new Array(); |
---|
177 | this.doOnChange=null; |
---|
178 | }; |
---|
179 | UIRadio.prototype=new MovieClip(); |
---|
180 | UIRadio.prototype.addButton=function(x,y,prompttext) { |
---|
181 | var i=++this.buttons; |
---|
182 | this.createEmptyMovieClip(i,i); |
---|
183 | this[i].attachMovie('radio_off','radio',1); |
---|
184 | this[i]._x=this.xpos[i]=x; |
---|
185 | this[i]._y=this.ypos[i]=y; |
---|
186 | createHitRegion(this[i],prompttext,2,3); |
---|
187 | this[i].onPress=function() { if (this._alpha>60) { this._parent.select(this._name); } }; |
---|
188 | }; |
---|
189 | UIRadio.prototype.select=function(n) { |
---|
190 | var i,s; |
---|
191 | for (i=1; i<=this.buttons; i++) { |
---|
192 | if (i==n) { s='radio_on'; } else { s='radio_off'; } |
---|
193 | this[i].attachMovie(s,'radio',1); |
---|
194 | } |
---|
195 | this.selected=n; |
---|
196 | if (this.doOnChange!=null) { this.doOnChange(n); } |
---|
197 | }; |
---|
198 | UIRadio.prototype.enable =function(i) { this[i]._alpha=100; this[i].prompt.setTextFormat(plainSmall); }; |
---|
199 | UIRadio.prototype.disable=function(i) { this[i]._alpha= 50; this[i].prompt.setTextFormat(plainDim); }; |
---|
200 | Object.registerClass("radio",UIRadio); |
---|
201 | |
---|
202 | // Checkboxes |
---|
203 | // UICheckbox.init(x,y,text,state,changefunction,enabled?) |
---|
204 | |
---|
205 | UICheckbox=function() { |
---|
206 | }; |
---|
207 | UICheckbox.prototype=new MovieClip(); |
---|
208 | UICheckbox.prototype.init=function(x,y,prompttext,state,changefunction,enabled) { |
---|
209 | if (enabled==undefined) { enabled=true; } |
---|
210 | this._x=x; |
---|
211 | this._y=y; |
---|
212 | this.enabled=enabled; |
---|
213 | this.state=state; |
---|
214 | this.doOnChange=changefunction; |
---|
215 | createHitRegion(this,prompttext,0,1,enabled); |
---|
216 | if (enabled) { |
---|
217 | this.hitregion.onPress=function() { |
---|
218 | this._parent.state=!this._parent.state; |
---|
219 | this._parent.draw(); |
---|
220 | this._parent.doOnChange(this._parent.state); |
---|
221 | }; |
---|
222 | } |
---|
223 | this.createEmptyMovieClip('box',2); |
---|
224 | this.draw(); |
---|
225 | }; |
---|
226 | UICheckbox.prototype.draw=function() { |
---|
227 | with (this.box) { |
---|
228 | clear(); |
---|
229 | if (this.enabled) { lineStyle(2,0,100); } |
---|
230 | else { lineStyle(2,0,30); } |
---|
231 | moveTo(1,0); |
---|
232 | lineTo(9,0); lineTo(9,9); |
---|
233 | lineTo(0,9); lineTo(0,0); |
---|
234 | if (this.state) { |
---|
235 | lineStyle(2,0,100); |
---|
236 | moveTo(1,1); lineTo(8,8); |
---|
237 | moveTo(8,1); lineTo(1,8); |
---|
238 | } |
---|
239 | } |
---|
240 | }; |
---|
241 | Object.registerClass("checkbox",UICheckbox); |
---|
242 | |
---|
243 | // Pop-up menu |
---|
244 | // UIMenu.init(x,y,selected option,array of options,tooltip, |
---|
245 | // function to call on close,value of 'this' on close, |
---|
246 | // width) |
---|
247 | |
---|
248 | function UIMenu() { |
---|
249 | }; |
---|
250 | UIMenu.prototype=new MovieClip(); |
---|
251 | UIMenu.prototype.init=function(x,y,selected,options,tooltip,closefunction,closethis,menuwidth,closedtitle) { |
---|
252 | var i,w,h; |
---|
253 | this._x=x; this._y=y; |
---|
254 | this.selected=selected; this.original=selected; |
---|
255 | this.options=options; |
---|
256 | this.closedtitle=closedtitle ? closedtitle : ''; |
---|
257 | this.enable=[]; |
---|
258 | |
---|
259 | // create (invisible) movieclip for opened menu |
---|
260 | this.createEmptyMovieClip("opened",2); |
---|
261 | this.opened._visible=false; |
---|
262 | // create child for each option |
---|
263 | var tw=0; |
---|
264 | for (i=0; i<options.length; i+=1) { |
---|
265 | if (options[i]!='--') { |
---|
266 | this.opened.createTextField(i,i+1,3,i*16-1,100,19); |
---|
267 | this.opened[i].background=true; |
---|
268 | this.opened[i].backgroundColor=0x888888; |
---|
269 | this.opened[i].text=options[i]; |
---|
270 | this.opened[i].setTextFormat(menu_off); |
---|
271 | this.enable[i]=true; |
---|
272 | if (this.opened[i].textWidth*1.05>tw) { tw=this.opened[i].textWidth*1.05; } |
---|
273 | } |
---|
274 | }; |
---|
275 | // create box around menu |
---|
276 | this.opened.createEmptyMovieClip("box",0); |
---|
277 | w=tw+7; if (menuwidth>w) { w=menuwidth; } |
---|
278 | this.itemwidth=w-7; |
---|
279 | h=options.length*16+5; |
---|
280 | with (this.opened.box) { |
---|
281 | _y=-2; |
---|
282 | clear(); |
---|
283 | beginFill(0x888888,100); |
---|
284 | lineTo(w,0); lineTo(w,h); |
---|
285 | lineTo(0,h); lineTo(0,0); endFill(); |
---|
286 | }; |
---|
287 | // adjust all menus to have correct highlight, and draw dividers |
---|
288 | this.opened.box.lineStyle(1,0xFFFFFF,50); |
---|
289 | for (i=0; i<options.length; i+=1) { |
---|
290 | if (options[i]=='--') { |
---|
291 | this.opened.box.moveTo(5,i*16+10); |
---|
292 | this.opened.box.lineTo(this.itemwidth,i*16+10); |
---|
293 | } else { |
---|
294 | this.opened[i]._width=this.itemwidth; |
---|
295 | } |
---|
296 | } |
---|
297 | |
---|
298 | // create (visible) movieclip for closed menu |
---|
299 | if (menuwidth>0) { w=menuwidth; } else { w+=11; } |
---|
300 | this.createEmptyMovieClip("closed",1); |
---|
301 | this.closed.createEmptyMovieClip("box",0); |
---|
302 | with (this.closed.box) { |
---|
303 | clear(); |
---|
304 | beginFill(0x888888,100); |
---|
305 | lineTo(w,0 ); lineTo(w,17); |
---|
306 | lineTo(0,17); lineTo(0,0 ); endFill(); |
---|
307 | beginFill(0xFFFFFF,100); |
---|
308 | moveTo(w-11,7); lineTo(w-3,7); |
---|
309 | lineTo(w-7,13); lineTo(w-11,7); endFill(); |
---|
310 | }; |
---|
311 | this.closed.createTextField("current",2,3,-1,this.itemwidth,19); |
---|
312 | this.closed.current.text=(this.closedtitle=='') ? options[selected] : this.closedtitle; |
---|
313 | this.closed.current.setTextFormat(menu_off); |
---|
314 | this.closed.current.background=false; |
---|
315 | // this.closed.current.backgroundColor=0x888888; |
---|
316 | |
---|
317 | this.onPress=function() { clearFloater(); this.openMenu(); }; |
---|
318 | this.onRelease=function() { this.closeMenu(); }; |
---|
319 | this.onReleaseOutside=function() { this.closeMenu(); }; |
---|
320 | this.onMouseMove=function() { this.trackMenu(); }; |
---|
321 | this.doOnClose=closefunction; |
---|
322 | this.closeThis=closethis; |
---|
323 | this.opened[this.selected].backgroundColor=0xDDDDDD; |
---|
324 | this.opened[this.selected].setTextFormat(menu_on); |
---|
325 | |
---|
326 | if (tooltip!='') { |
---|
327 | this.onRollOver=function() { setFloater(tooltip); }; |
---|
328 | this.onRollOut =function() { clearFloater(); }; |
---|
329 | } |
---|
330 | }; |
---|
331 | UIMenu.prototype.trackMenu=function() { |
---|
332 | if (this.opened._visible) { |
---|
333 | this.opened[this.selected].backgroundColor=0x888888; |
---|
334 | this.opened[this.selected].setTextFormat(menu_off); |
---|
335 | this.selected=this.whichSelection(); |
---|
336 | if (this.selected>-1) { |
---|
337 | this.opened[this.selected].backgroundColor=0xDDDDDD; |
---|
338 | this.opened[this.selected].setTextFormat(menu_on); |
---|
339 | } |
---|
340 | } |
---|
341 | }; |
---|
342 | UIMenu.prototype.openMenu=function() { |
---|
343 | this.closed._alpha=50; |
---|
344 | this.opened._visible=true; |
---|
345 | // this.opened._y=-15*this.selected; |
---|
346 | this.opened._y=-15*this.original; |
---|
347 | |
---|
348 | t=new Object(); t.x=0; t.y=this.opened._height; |
---|
349 | this.opened.localToGlobal(t); |
---|
350 | while (t.y>Stage.height) { this.opened._y-=15; t.y-=15; } |
---|
351 | this.trackMenu(); |
---|
352 | }; |
---|
353 | UIMenu.prototype.closeMenu=function() { |
---|
354 | if (this.selected>-1) { |
---|
355 | this.original=this.selected; |
---|
356 | this.closed.current.text=(this.closedtitle=='') ? this.options[this.selected] : this.closedtitle; |
---|
357 | this.closed.current.setTextFormat(menu_off); |
---|
358 | this.closed._alpha=100; |
---|
359 | this.opened._visible=false; |
---|
360 | mflash=this; flashcount=2; |
---|
361 | mflashid=setInterval(function() { mflash.menuFlash(); }, 40); |
---|
362 | this.doOnClose.call(this.closeThis,this.selected); |
---|
363 | } else { |
---|
364 | this.closed.current.text=(this.closedtitle=='') ? this.options[this.original] : this.closedtitle; |
---|
365 | this.closed.current.setTextFormat(menu_off); |
---|
366 | this.closed._alpha=100; |
---|
367 | this.opened._visible=false; |
---|
368 | } |
---|
369 | }; |
---|
370 | UIMenu.prototype.setValue=function(n) { |
---|
371 | this.opened[this.selected].backgroundColor=0x888888; |
---|
372 | this.opened[this.selected].setTextFormat(menu_off); |
---|
373 | this.selected=n; this.original=n; |
---|
374 | this.closed.current.text=(this.closedtitle=='') ? this.options[this.selected] : this.closedtitle; |
---|
375 | this.closed.current.setTextFormat(menu_off); |
---|
376 | }; |
---|
377 | UIMenu.prototype.whichSelection=function() { |
---|
378 | mpos=new Object(); |
---|
379 | mpos.x=_root._xmouse; |
---|
380 | mpos.y=_root._ymouse; |
---|
381 | this.opened.globalToLocal(mpos); |
---|
382 | if (mpos.x>0 && mpos.x<this.itemwidth && mpos.y>0 && mpos.y<this.options.length*16) { |
---|
383 | var i=Math.floor((mpos.y)/16); |
---|
384 | if (this.opened[i] && this.enable[i]) { return i; } |
---|
385 | } |
---|
386 | return -1; |
---|
387 | }; |
---|
388 | UIMenu.prototype.menuFlash=function() { |
---|
389 | // ** flashcount and mflashid are globals, and really shouldn't be |
---|
390 | flashcount-=1; if (flashcount==0) { clearInterval(mflashid); }; |
---|
391 | if (flashcount/2!=Math.floor(flashcount/2)) { |
---|
392 | this.closed.current.backgroundColor=0xDDDDDD; |
---|
393 | this.closed.current.setTextFormat(menu_on); |
---|
394 | } else { |
---|
395 | this.closed.current.backgroundColor=0x888888; |
---|
396 | this.closed.current.setTextFormat(menu_off); |
---|
397 | } |
---|
398 | updateAfterEvent(); |
---|
399 | }; |
---|
400 | UIMenu.prototype.enableOption=function(i) { |
---|
401 | this.enable[i]=true; |
---|
402 | this.opened[i].setTextFormat(menu_off); |
---|
403 | }; |
---|
404 | UIMenu.prototype.disableOption=function(i) { |
---|
405 | this.enable[i]=false; |
---|
406 | this.opened[i].setTextFormat(menu_dis); |
---|
407 | }; |
---|
408 | UIMenu.prototype.renameOption=function(i,t) { |
---|
409 | this.opened[i].text=t; |
---|
410 | }; |
---|
411 | |
---|
412 | Object.registerClass("menu",UIMenu); |
---|
413 | |
---|
414 | |
---|
415 | // ======================================================================== |
---|
416 | // ModalDialogue |
---|
417 | |
---|
418 | // ModalDialogue.prototype.init(w,h,buttons,closefunction,leavepanel); |
---|
419 | // ModalDialogue.prototype.remove(); |
---|
420 | // ModalDialogue.prototype.drawAreas(); |
---|
421 | |
---|
422 | ModalDialogue=function() {}; |
---|
423 | ModalDialogue.prototype=new MovieClip(); |
---|
424 | ModalDialogue.prototype.init=function(w,h,buttons,closefunction,leavepanel) { |
---|
425 | clearFloater(); |
---|
426 | this.createEmptyMovieClip("blank",1); |
---|
427 | this.createEmptyMovieClip("box",2); |
---|
428 | this.modalwidth=w; // workaround for Stage.width suddenly changing |
---|
429 | this.modalheight=h; // | |
---|
430 | this.modalleave=leavepanel; |
---|
431 | this.drawAreas(); |
---|
432 | this.ypos=7; |
---|
433 | this.depthpos=5; |
---|
434 | |
---|
435 | // Create buttons |
---|
436 | for (var i=0; i<buttons.length; i+=1) { |
---|
437 | this.box.createEmptyMovieClip(i,i*2+1); |
---|
438 | drawButton(this.box[i],w-60*(buttons.length-i),h-30,buttons[i],""); |
---|
439 | this.box[i].onPress=function() { |
---|
440 | if (closefunction) { |
---|
441 | var keep = closefunction(buttons[this._name]); |
---|
442 | if ( !keep ) { this._parent._parent.remove(); } |
---|
443 | } else { |
---|
444 | this._parent._parent.remove(); |
---|
445 | } |
---|
446 | }; |
---|
447 | this.box[i].useHandCursor=true; |
---|
448 | } |
---|
449 | }; |
---|
450 | |
---|
451 | ModalDialogue.prototype.remove=function() { |
---|
452 | removeMovieClip(this); |
---|
453 | }; |
---|
454 | |
---|
455 | ModalDialogue.prototype.drawAreas=function() { |
---|
456 | var w=this.modalwidth; |
---|
457 | var h=this.modalheight; |
---|
458 | var ox=(Stage.width-w)/2; var oy=(Stage.height-panelheight-h)/2; |
---|
459 | |
---|
460 | // Blank all other areas |
---|
461 | var bh=Stage.height; |
---|
462 | if (this.modalleave==2) { bh-=20; } |
---|
463 | else if (this.modalleave) { bh-=panelheight; } |
---|
464 | with (this.blank) { |
---|
465 | clear(); |
---|
466 | beginFill(0xFFFFFF,20); moveTo(0,0); lineTo(Stage.width,0); |
---|
467 | lineTo(Stage.width,bh); lineTo(0,bh); lineTo(0,0); endFill(); |
---|
468 | } |
---|
469 | this.blank.onPress=null; |
---|
470 | this.blank.useHandCursor=false; |
---|
471 | |
---|
472 | // Create dialogue box |
---|
473 | with (this.box) { |
---|
474 | _x=ox; _y=oy; |
---|
475 | clear(); |
---|
476 | beginFill(0xBBBBBB,100); |
---|
477 | moveTo(0,0); |
---|
478 | lineTo(w,0); lineTo(w,h); |
---|
479 | lineTo(0,h); lineTo(0,0); endFill(); |
---|
480 | } |
---|
481 | }; |
---|
482 | |
---|
483 | ModalDialogue.prototype.addHeadline=function(objname,t) { this.addTextItem(boldText ,20,objname,t); }; |
---|
484 | ModalDialogue.prototype.addText =function(objname,t) { this.addTextItem(plainSmall,18,objname,t); }; |
---|
485 | ModalDialogue.prototype.addTextItem=function(textformat,textheight,objname,t) { |
---|
486 | this.box.createTextField(objname,this.depthpos++,7,this.ypos,this.modalwidth-14,textheight); |
---|
487 | this.box[objname].text = t; |
---|
488 | with (this.box[objname]) { wordWrap=true; setTextFormat(textformat); selectable=false; type='dynamic'; } |
---|
489 | adjustTextField(this.box[objname]); |
---|
490 | this.ypos+=textheight; |
---|
491 | }; |
---|
492 | |
---|
493 | ModalDialogue.prototype.addTextEntry=function(objname,t,fieldheight) { |
---|
494 | this.box.createTextField(objname,this.depthpos++,10,this.ypos+5,this.modalwidth-20,fieldheight); |
---|
495 | with (this.box[objname]) { |
---|
496 | setNewTextFormat(plainSmall); |
---|
497 | type='input'; |
---|
498 | backgroundColor=0xDDDDDD; |
---|
499 | background=true; |
---|
500 | border=true; |
---|
501 | borderColor=0xFFFFFF; |
---|
502 | wordWrap=true; |
---|
503 | text=t; |
---|
504 | } |
---|
505 | Selection.setFocus(this.box[objname]); |
---|
506 | this.ypos+=textheight+10; |
---|
507 | }; |
---|
508 | |
---|
509 | Object.registerClass("modal",ModalDialogue); |
---|
510 | |
---|
511 | // ======================================================================== |
---|
512 | // Support functions |
---|
513 | |
---|
514 | // drawButton - draw white-on-grey button |
---|
515 | // (object,x,y,button text, text to right,width) |
---|
516 | |
---|
517 | function drawButton(buttonobject,x,y,btext,ltext,bwidth,leftalign) { |
---|
518 | if (!bwidth) { bwidth=50; } |
---|
519 | buttonobject.useHandCursor=true; |
---|
520 | buttonobject.createTextField('btext',1,0,-1,bwidth-2,20); |
---|
521 | with (buttonobject.btext) { |
---|
522 | text=btext; setTextFormat(boldWhite); |
---|
523 | selectable=false; type='dynamic'; |
---|
524 | _x=(bwidth-5-textWidth)/2; |
---|
525 | } |
---|
526 | if (ltext!="") { |
---|
527 | buttonobject.createTextField("explain",2,bwidth+4,-1,300,20); |
---|
528 | buttonobject.explain.autoSize=true; |
---|
529 | writeText(buttonobject.explain,ltext); |
---|
530 | buttonobject.explain.wordWrap=false; |
---|
531 | } |
---|
532 | |
---|
533 | // Resize if button is bigger than text |
---|
534 | var t=buttonobject.btext.textWidth; |
---|
535 | if (t+6>buttonobject.btext._width) { buttonobject.btext._width=t+4; } |
---|
536 | if (t>bwidth) { |
---|
537 | if (!leftalign) { x-=(t-bwidth)/2; } |
---|
538 | buttonobject.btext._x+=(t-bwidth)/2+2; |
---|
539 | bwidth=t+4; |
---|
540 | } |
---|
541 | with (buttonobject) { |
---|
542 | _x=x; _y=y; |
---|
543 | beginFill(0x7F7F7F,100); |
---|
544 | moveTo(0,0); |
---|
545 | lineTo(bwidth,0); lineTo(bwidth,17); |
---|
546 | lineTo(0,17); lineTo(0,0); endFill(); |
---|
547 | } |
---|
548 | } |
---|
549 | |
---|
550 | // createHitRegion - write a prompt and draw a hit region around it |
---|
551 | // (object,prompt text,depth for text object,depth for hit region,enabled?) |
---|
552 | |
---|
553 | function createHitRegion(obj,prompttext,promptdepth,hitdepth,enabled) { |
---|
554 | if (enabled==undefined) { enabled=true; } |
---|
555 | obj.createTextField('prompt',promptdepth,13,-5,200,19); |
---|
556 | if (enabled) { obj.prompt.setNewTextFormat(plainSmall); } |
---|
557 | else { obj.prompt.setNewTextFormat(greySmall); } |
---|
558 | obj.prompt.text=prompttext; |
---|
559 | obj.prompt.selectable=false; |
---|
560 | tw=obj.prompt._width=obj.prompt.textWidth+5; |
---|
561 | |
---|
562 | obj.createEmptyMovieClip('hitregion',hitdepth); |
---|
563 | with (obj.hitregion) { |
---|
564 | clear(); beginFill(0,0); |
---|
565 | moveTo(0,0); lineTo(tw+15,0); |
---|
566 | lineTo(tw+15,15); lineTo(0,15); |
---|
567 | endFill(); |
---|
568 | }; |
---|
569 | }; |
---|