-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.js
132 lines (101 loc) · 2.92 KB
/
main.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
/*
Copyright 2014 "Neppy"
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
"use strict";
require("./boot.js");
window.$ = window.jQuery = require("./Libs/jQueryUI/external/jquery/jquery.js");
window.jQueryUI = require("./Libs/jQueryUI/jquery-ui.js");
require("./Libs/jQueryUI/layout/jquery.layout.js");
require("./Libs/Bootstrap/bootstrap.js");
var g = window.g;
g.levelWidth = 64;
g.levelHeight = 64;
g.tileWidth = 16;
g.tileHeight = 16;
var game = new Phaser.Game(g.levelWidth * g.tileWidth, g.levelHeight * g.tileHeight, Phaser.CANVAS, "level_render");
var layout;
var ipc = require("ipc");
$("document").ready(function () {
var fileNew = function() {
g.manager.newLevel();
};
var fileOpen = function() {
var files = ipc.sendSync("openFile");
if(files != null) {
g.manager.openLevel(files[0]);
}
};
var fileSave = function() {
g.manager.saveLevel();
};
var fileClose = function() {
g.manager.closeLevel();
};
var doUndo = function() {
g.manager.doUndo();
};
var doRedo = function() {
g.manager.doRedo();
};
$("#menu_open").click(fileOpen);
$("#menu_exit").click(function() {
ipc.sendSync("close");
});
$("#menu_new").click(fileNew);
$("#menu_save").click(fileSave);
$("#menu_saveAs").click(function() {
g.manager.saveLevel(null, true);
});
$("#menu_about").click(function() {
$("#about_dialog").dialog({});
});
$("#menu_undo").click(doUndo);
$("#toolbar_undo").click(doUndo);
$("#menu_redo").click(doRedo);
$("#toolbar_redo").click(doRedo);
$("#menu_close").click(fileClose);
//$("#side_tabs_tiles").click();
layout = $("body").layout( {
defaults: {
applyDefaultStyles: true,
closable: false,
resizable: false,
slideable: false
},
north: {
size: "auto"
},
east: {
resizable: true
},
south: {
size: 30
}
});
var graalFolder = ipc.sendSync("chooseFolder");
if(graalFolder == null) {
ipc.sendSync("close");
}
g.graalFolder = graalFolder[0];
$("#toolbar_new").click(fileNew);
$("#toolbar_open").click(fileOpen);
$("#toolbar_save").click(fileSave);
$("#toolbar_close").click(fileClose);
});
require("./States/load.js")(game);
require("./Prefabs/load.js");
require("./Libs/NWTools.js");
g.manager = new g.Prefabs.Manager(game);
g.fileManager = new g.Prefabs.FileManager(game);
g.uiManager = new g.Prefabs.UIManager(game);
g.game = game;
game.state.start("Startup");