-
Notifications
You must be signed in to change notification settings - Fork 58
/
lodeRunner.info.js
492 lines (423 loc) · 15 KB
/
lodeRunner.info.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
var classicInfo = [
{type: 'TITLE', contain: " Classic Lode Runner " },
{type: 'TEXT' , contain: "Release year : 1983, 1984"},
{type: 'TEXT' , contain: "Platform : APPLE-II, Commodore 64, IBM PC, NES ..."},
{type: 'TEXT' , contain: "Publisher : Br\u00F8derbund & Ariolasoft" }, //Brøderbund
{type: 'TEXT' , contain: "Developer : Douglas E. Smith" },
{type: 'TEXT' , contain: "Difficulty : \u2605 \u2605 \u2605" } //★ ★ ★
];
//ref: http://www.gb64.com/game.php?id=5906&d=42
var proInfo = [
{type: 'TITLE', contain: " Professional Lode Runner " },
{type: 'TEXT' , contain: "Release year : 1984, 1985"},
{type: 'TEXT' , contain: "Platform : Commodore 64"},
{type: 'TEXT' , contain: "Publisher : DodoSoft & AlphaSoft" },
{type: 'TEXT' , contain: "Developer : Unknown" },
{type: 'TEXT' , contain: "Difficulty : \u2605 \u2605 \u2605 \u2605" } //★ ★ ★ ★
];
//ref:http://www.vizzed.com/play/revenge-of-lode-runner-appleii-online-apple-ii-6223-game
var revengeInfo = [
{type: 'TITLE', contain: " Revenge of Lode Runner " },
{type: 'TEXT' , contain: "Release year : 1985, 1986"},
{type: 'TEXT' , contain: "Platform : APPLE-II"},
{type: 'TEXT' , contain: "Publisher : Br\u00F8derbund" }, //Brøderbund
{type: 'TEXT' , contain: "Developer : Mad Man" },
{type: 'TEXT' , contain: "Difficulty : \u2605 \u2605 \u2605 \u2605" } //★ ★ ★ ★
];
var fanBookInfo = [
{type: 'TITLE', contain: " Lode Runner Fan Book " },
{type: 'TEXT' , contain: 'From : "Apple Lode Runner - The Remake 1.0h"'},
{type: 'TEXT' , contain: "Platform : Microsoft Windows"},
{type: 'TEXT' , contain: "Publisher : Spoonbill Software" },
{type: 'TEXT' , contain: 'Developer : Custom levels'},
{type: 'TEXT_LINK' , text: "URL : ",
textLink: "http://www.spoonbillsoftware.com.au/loderunner.htm",
url: "http://www.spoonbillsoftware.com.au/loderunner.htm"
},
{type: 'TEXT' , contain: "Difficulty : \u2605 \u2605 \u2605 \u2605 \u2605" } //★ ★ ★ ★ ★
];
var championInfo = [
{type: 'TITLE', contain: " Championship Lode Runner " },
{type: 'TEXT' , contain: "Release year : 1984, 1985"},
{type: 'TEXT' , contain: "Platform : APPLE-II, Commodore 64, NES ..."},
{type: 'TEXT' , contain: "Publisher : Br\u00F8derbund & Hudson Soft" }, //Brøderbund
{type: 'TEXT' , contain: "Developer : Douglas E. Smith" },
{type: 'TEXT' , contain: "Difficulty : \u2605 \u2605 \u2605 \u2605 \u2605" } //★ ★ ★ ★ ★
];
//=========================================================================================
var editInfo = [
{type: 'TITLE', contain: "Edit Custom Level"},
{type: 'TEXT' , contain: "NEW : New or clear editing level"},
{type: 'TEXT' , contain: "LOAD : Load exists level for customization"},
{type: 'TEXT' , contain: "TEST : Test editing level" },
{type: 'TEXT' , contain: "SAVE : Save current level" }
];
var testInfo = [
{type: 'TITLE', contain: "Test Custom Level"},
{type: 'TEXT' , contain: "If test success, players can save it. "}
];
var customInfo = [
{type: 'TITLE', contain: "Custom Levels"},
{type: 'TEXT' , contain: "Players can create new levels or edit exists levels."}
];
var demoHelp = [
{type: 'TITLE', contain: " Demo Mode "},
{type: 'TEXT' , contain: " Demo data collected from players," },
{type: 'TEXT' , contain: " Only demo the fastest passed levels or" },
{type: 'TEXT' , contain: "Recently passed levels of current player." }
];
function createDemoInfo()
{
var titleName = playDataToTitleName(playData);
var player = playerDemoData[curLevel-1].player;
if(player == "") player = "Unknown";
var demoInfo = [
{type: 'TITLE', contain: " " + playDataToTitleName(playData)+ " " },
{type: 'TEXT' , contain: "Demo level : " + curLevel},
{type: 'TEXT' , contain: "Player : " + player },
{type: 'TEXT_flagID_MSG' , text: "Location : ",
flagId: playerDemoData[curLevel-1].cId.toLowerCase(),
msg: " " + playerDemoData[curLevel-1].location
},
{type: 'TEXT' , contain: "Date : " + playerDemoData[curLevel-1].date+ " (" + playerDemoData[curLevel-1].ai+")" }
];
return demoInfo;
}
function infoMenu(callbackFun, args)
{
var infoMsg = null;
switch(playMode) {
case PLAY_CLASSIC:
case PLAY_MODERN:
if(playData == PLAY_DATA_USERDEF) {
infoMsg = customInfo;
} else {
infoMsg = getPlayVerInfo(playData);
}
break;
case PLAY_DEMO:
case PLAY_DEMO_ONCE:
infoMsg = createDemoInfo();
break;
case PLAY_EDIT:
infoMsg = editInfo;
break;
case PLAY_TEST:
infoMsg = testInfo;
break;
}
if(infoMsg) infoObj.showInfo(infoMsg, callbackFun, args);
else {
if(callbackFun) callbackFun(args);
error(arguments.callee.name, "Error: playMode = " + playMode);
}
}
function infoMenuClass(_stage, _scale)
{
var coverBackground, closeIcon;
var infoBorder, infoBackground;
var infoObj = [];
var INFO_BORDER_SIZE = 24 * _scale;
var INFO_BORDER_HALF = INFO_BORDER_SIZE / 2;
var TITLE_TEXT_SIZE = 40 * _scale;
var TITLE_TEXT_COLOR = "white";
var TITLE_TEXT_SHADOW_COLOR = "#FF0";
var ITEM_TEXT_SIZE = 32 * _scale;
var ITEM_TEXT_COLOR = "yellow";
var FLAG_SCALE = _scale * 5/4;
var FLAG_MSG_SIZE = 28 * _scale;
var FLAG_MSG_COLOR = "white";
var TOP_BORDER_SIZE = TITLE_TEXT_SIZE/2 | 0;
var BOTTOM_BORDER_SIZE = ITEM_TEXT_SIZE/ 2 | 0;
var BORDER_WIDTH = ITEM_TEXT_SIZE;
var CLOSE_BOX_SIZE = 12 * _scale + 2;
var menuX, menuY, startX, startY;
var callBackFun, callBackArgs;
var saveStateObj;
this.showInfo = function(info, callback, args)
{
if(typeof args == "undefined") args = null;
callBackFun = callback;
callBackArgs = args;
closeIcon = null;
initInfo(info);
drawBackground();
drawInfoBackground();
drawInfo();
drawCloseIcon(0);
_stage.update();
saveStateObj = saveKeyHandler(InfoKeyDown);
}
function initInfo(infoList)
{
var textLength;
var maxTextWidth =0;
infoObj = [];
menuX = menuY = 0;
for(var i = 0; i < infoList.length; i++) {
switch( infoList[i].type) {
case 'TITLE':
infoObj[i] = {};
infoObj[i].type = 'TITLE';
infoObj[i].text = new createjs.Text(infoList[i].contain,
"bold " + TITLE_TEXT_SIZE + "px Helvetica",TITLE_TEXT_COLOR);
infoObj[i].text.shadow = new createjs.Shadow(TITLE_TEXT_SHADOW_COLOR, 1, 1, 1 );
infoObj[i].width = infoObj[i].text.getBounds().width;
infoObj[i].height = infoObj[i].text.getBounds().height;
menuY += (infoObj[i].height * 3/2|0);
break;
case 'TEXT':
infoObj[i] = {};
infoObj[i].type = 'TEXT';
infoObj[i].text = new createjs.Text(infoList[i].contain,
"bold " + ITEM_TEXT_SIZE + "px Helvetica",ITEM_TEXT_COLOR);
infoObj[i].width = infoObj[i].text.getBounds().width;
infoObj[i].height = infoObj[i].text.getBounds().height;
menuY += (infoObj[i].height * 3/2|0);
break;
case 'TEXT_flagID_MSG':
infoObj[i] = {};
infoObj[i].type = 'TEXT_flagID_MSG';
infoObj[i].text = new createjs.Text(infoList[i].text,
"bold " + ITEM_TEXT_SIZE + "px Helvetica", ITEM_TEXT_COLOR);
infoObj[i].textWidth = infoObj[i].text.getBounds().width;
infoObj[i].textHeight = infoObj[i].text.getBounds().height;
if(infoList[i].flagId in countryId) {
infoObj[i].flag = new createjs.Sprite(countryFlagData, infoList[i].flagId);
} else {
infoObj[i].flag = new createjs.Sprite(countryFlagData, "unknown");
}
infoObj[i].flag.setTransform(0, 0, FLAG_SCALE, FLAG_SCALE);
infoObj[i].flagWidth = infoObj[i].flag.getTransformedBounds().width;
infoObj[i].flagHeight = infoObj[i].flag.getTransformedBounds().height;
infoObj[i].msg = new createjs.Text(infoList[i].msg,
"bold " + FLAG_MSG_SIZE + "px Helvetica", FLAG_MSG_COLOR);
infoObj[i].msg.set({alpha:0});
infoObj[i].msgWidth = infoObj[i].msg.getBounds().width;
infoObj[i].msgHeight = infoObj[i].msg.getBounds().height;
infoObj[i].flag.msgObj = infoObj[i].msg;
infoObj[i].flag.on('mouseover',function(evt) {
this.msgObj.set({alpha:1});
_stage.update();
});
infoObj[i].flag.on('mouseout', function(evt){
this.msgObj.set({alpha:0});
_stage.update();
});
infoObj[i].width = infoObj[i].textWidth + infoObj[i].flagWidth + infoObj[i].msgWidth;
menuY += (infoObj[i].textHeight * 3/2|0);
break;
case 'TEXT_LINK':
infoObj[i] = {};
infoObj[i].type = 'TEXT_LINK';
infoObj[i].text = new createjs.Text(infoList[i].text,
"bold " + ITEM_TEXT_SIZE + "px Helvetica", ITEM_TEXT_COLOR);
infoObj[i].textWidth = infoObj[i].text.getBounds().width;
infoObj[i].textHeight = infoObj[i].text.getBounds().height;
infoObj[i].textLink = new createjs.Text(infoList[i].textLink,
"bold " + ITEM_TEXT_SIZE + "px Helvetica", ITEM_TEXT_COLOR);
infoObj[i].texLinktWidth = infoObj[i].textLink.getBounds().width;
infoObj[i].texLinktHeight = infoObj[i].textLink.getBounds().height;
infoObj[i].textLink.url = infoList[i].url;
infoObj[i].textLink.on('mouseover',function(evt) {
_stage.cursor = "pointer";
_stage.update();
});
infoObj[i].textLink.on('mouseout', function(evt){
_stage.cursor = "default";
_stage.update();
});
infoObj[i].textLink.on('click', function(evt){
window.open(this.url).focus();
_stage.cursor = "default";
_stage.update();
});
infoObj[i].width = infoObj[i].textWidth + infoObj[i].texLinktWidth;
menuY += (infoObj[i].textHeight * 3/2|0);
break;
default:
error(arguments.callee.name, "Error: type don't support, type = " + infoList[i].type);
continue;
}
if(maxTextWidth < infoObj[i].width) maxTextWidth = infoObj[i].width;
}
menuX = maxTextWidth + BORDER_WIDTH * 2;
menuY += (TOP_BORDER_SIZE + BOTTOM_BORDER_SIZE);
startX = (_stage.canvas.width-menuX)/2|0;
startY = (_stage.canvas.height-menuY)/2|0;
if(startX < 0) startX = 0;
if(startY < 0) startY = 0;
}
function drawBackground()
{
coverBackground = new createjs.Shape();
coverBackground.graphics.beginFill("black").drawRect(0, 0, _stage.canvas.width, _stage.canvas.height).endFill();
coverBackground.alpha = 0.3;
_stage.addChild(coverBackground);
}
function removeBackground()
{
_stage.removeChild(coverBackground);
}
function drawInfoBackground()
{
infoBorder = new createjs.Shape();
infoBackground = new createjs.Shape();
infoBorder.alpha = 0.8;
infoBorder.graphics.beginFill("#FF0")
.drawRoundRect(startX-INFO_BORDER_HALF, startY-INFO_BORDER_HALF, menuX+INFO_BORDER_SIZE, menuY+INFO_BORDER_SIZE, INFO_BORDER_HALF).endFill();
infoBackground.alpha = 0.6;
infoBackground.graphics.beginFill("#190218")
.drawRoundRect(startX, startY, menuX, menuY, INFO_BORDER_HALF/2).endFill();
_stage.addChild(infoBorder);
_stage.addChild(infoBackground);
}
function removeInfoBackground()
{
_stage.removeChild(infoBackground);
_stage.removeChild(infoBorder);
}
function drawInfo()
{
var tmpY = startY;
for(var i = 0; i < infoObj.length; i++) {
switch( infoObj[i].type) {
case 'TITLE':
tmpY += (infoObj[i].height/2|0);
infoObj[i].text.x = startX + (menuX - infoObj[i].width)/2|0;
infoObj[i].text.y = tmpY;
tmpY += infoObj[i].height *3/2|0;
_stage.addChild(infoObj[i].text);
break;
case 'TEXT':
infoObj[i].text.x = startX + BORDER_WIDTH;
infoObj[i].text.y = tmpY;
tmpY += infoObj[i].height *3/2|0;
_stage.addChild(infoObj[i].text);
break;
case 'TEXT_flagID_MSG':
infoObj[i].text.x = startX + BORDER_WIDTH;
infoObj[i].text.y = tmpY;
infoObj[i].flag.x = startX + BORDER_WIDTH + infoObj[i].textWidth;
infoObj[i].flag.y = tmpY+ (infoObj[i].textHeight - infoObj[i].flagHeight)/3;
infoObj[i].msg.x = startX + BORDER_WIDTH + infoObj[i].textWidth + infoObj[i].flagWidth;
infoObj[i].msg.y = tmpY+ (infoObj[i].textHeight - infoObj[i].msgHeight);
tmpY += infoObj[i].textHeight *3/2|0;
_stage.addChild(infoObj[i].text);
_stage.addChild(infoObj[i].flag);
_stage.addChild(infoObj[i].msg);
break;
case 'TEXT_LINK':
infoObj[i].text.x = startX + BORDER_WIDTH;
infoObj[i].text.y = tmpY;
infoObj[i].textLink.x = startX + BORDER_WIDTH + infoObj[i].textWidth;
infoObj[i].textLink.y = tmpY;
tmpY += infoObj[i].textHeight *3/2|0;
_stage.addChild(infoObj[i].text);
_stage.addChild(infoObj[i].textLink);
break;
default:
error(arguments.callee.name, "Error: type don't support, type = " + infoObj[i].type);
continue;
}
}
}
function removeInfo()
{
for(var i = 0; i < infoObj.length; i++) {
switch(infoObj[i].type) {
case 'TITLE':
case 'TEXT':
_stage.removeChild(infoObj[i].text);
break;
case 'TEXT_flagID_MSG':
_stage.removeChild(infoObj[i].text);
_stage.removeChild(infoObj[i].flag);
break;
case 'TEXT_LINK':
_stage.removeChild(infoObj[i].text);
_stage.removeChild(infoObj[i].textLink);
break;
default:
error(arguments.callee.name, "Error: type don't support, type = " + infoObj[i].type);
continue;
}
}
}
function InfoKeyDown(event)
{
if(!event){ event = window.event; } //cross browser issues exist
if(event.keyCode == KEYCODE_ESC) {
closeInfoMenu();
}
return false;
}
function drawCloseIcon(mouseOver)
{
var cycle, cross;
var alpha, cycColor, crosColor;
if(closeIcon == null) {
closeIcon = new createjs.Container();
cross = new createjs.Shape();
cycle = new createjs.Shape();
closeIcon.addChild(cycle, cross);
closeIcon.on("mouseover", handleMouseOver);
closeIcon.on("mouseout", handleMouseOut);
closeIcon.on("click", closeInfoMenu);
closeIcon.x = startX+menuX - CLOSE_BOX_SIZE*3;
closeIcon.y = startY + CLOSE_BOX_SIZE*2;
_stage.enableMouseOver(30);
_stage.addChild(closeIcon);
} else {
cycle = closeIcon.getChildAt(0);
cross = closeIcon.getChildAt(1);
}
if(mouseOver) {
alpha = 0.6;
cycColor = "red";
crosColor = "white";
} else {
alpha = 0.01;
cycColor = "gold";
crosColor = "white";
}
var g = cycle.graphics;
g.clear();
cycle.alpha = alpha;
g.beginFill(cycColor).dc(CLOSE_BOX_SIZE/2, CLOSE_BOX_SIZE/2, CLOSE_BOX_SIZE*5/4);
g = cross.graphics;
g.clear();
//cross.alpha = 1;
g.setStrokeStyle(CLOSE_BOX_SIZE/4).beginStroke(crosColor).moveTo(0,0)
.lineTo(CLOSE_BOX_SIZE,CLOSE_BOX_SIZE).closePath();
g.moveTo(CLOSE_BOX_SIZE,0).lineTo(0,CLOSE_BOX_SIZE).closePath();
_stage.update();
}
function removeCloseIcon()
{
_stage.removeChild(closeIcon);
}
function handleMouseOver(event)
{
_stage.cursor = 'pointer';
drawCloseIcon(1);
}
function handleMouseOut(event)
{
_stage.cursor = 'default';
drawCloseIcon(0);
}
function closeInfoMenu()
{
removeCloseIcon();
removeInfo();
removeInfoBackground();
removeBackground();
_stage.cursor = 'default';
_stage.update();
_stage.enableMouseOver(0);
restoreKeyHandler(saveStateObj);
//add setTimeout just don't cause mouse event (click) cascade!
if(callBackFun) setTimeout(function() { callBackFun(callBackArgs);}, 10);
}
}