-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImperium.as
114 lines (93 loc) · 3.38 KB
/
Imperium.as
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
package {
import com.Application;
import com.StartupConfig;
import com.enum.TimeLogEnum;
import com.service.ExternalInterfaceAPI;
import com.util.TimeLog;
import com.util.FileHelper;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.system.Security;
import flash.text.TextField;
import flash.utils.getDefinitionByName;
import flash.filesystem.File;
import org.robotlegs.bundles.mvcs.MVCSBundle;
import org.robotlegs.framework.api.IContext;
import org.robotlegs.framework.impl.Context;
[SWF(frameRate = CONFIG::FRAMERATE, backgroundColor = CONFIG::BG_COLOR)]
public final
class Imperium extends Sprite {
protected var _ncontext: IContext;
public static var NativeApplicationTypeDef: Object;
public static var InvokeEventTypeDef: Object;
public static var authToken: String;
public static var language: String;
public static var country: String;
public static var entryTag: String;
public function Imperium() {
if (CONFIG::IS_DESKTOP) {
NativeApplicationTypeDef = getDefinitionByName("flash.desktop.NativeApplication");
InvokeEventTypeDef = getDefinitionByName("flash.events.InvokeEvent");
NativeApplicationTypeDef.nativeApplication.addEventListener(InvokeEventTypeDef.INVOKE, onInvoke);
} else {
ExternalInterfaceAPI.logConsole("Imperium Starts");
Application.ROOT = this;
try {
Security.allowDomain("*");
Security.allowInsecureDomain("*");
} catch (e) {
//This is the desktop client
}
TimeLog.endTimeLog(TimeLogEnum.GAME_INITIALIZED);
TimeLog.startTimeLog(TimeLogEnum.GAME_LOAD);
this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
}
private function onInvoke(e): void {
if (CONFIG::USE_DEBUG_CONNECTON) {
var debugConnectionConfig: Object = FileHelper.loadObject(File.applicationDirectory.resolvePath("debug-connection.json").nativePath);
authToken = debugConnectionConfig.token;
language = "en";
} else {
var args: Array = e.arguments;
var obj: Object = new Object();
try {
for (var i: int = 0; i < args.length; i++) {
var arg: String = args[i];
if (arg.indexOf("--") == 0) {
obj[arg] = args[i + 1];
}
}
authToken = obj["--xsolla-login-token"];
language = obj["--xsolla-locale"];
} catch (e) {
//something failed here, let the clients error handling system take care of it when the token fails.
}
}
ExternalInterfaceAPI.logConsole("Imperium Starts");
Application.ROOT = this;
TimeLog.endTimeLog(TimeLogEnum.GAME_INITIALIZED);
TimeLog.startTimeLog(TimeLogEnum.GAME_LOAD);
if (this.stage == null) this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
else onAddedToStage(null);
}
private function onAddedToStage(e: Event): void {
// Set it so that the stage resizes properly.
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.frameRate = CONFIG::FRAMERATE;
stage.showDefaultContextMenu = false;
stage.addEventListener(MouseEvent.RIGHT_CLICK, onRightClick);
_ncontext = new Context()
.extend(MVCSBundle)
.configure(StartupConfig, this);
}
private function onRightClick(e: MouseEvent): void {
//do nothing, just listening to the event prevents
//a right mouse click from opening the context menu
}
}
}