-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathproject.hxp
More file actions
238 lines (183 loc) · 6.44 KB
/
Copy pathproject.hxp
File metadata and controls
238 lines (183 loc) · 6.44 KB
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
package;
import hxp.*;
import lime.tools.*;
import sys.FileSystem;
using StringTools;
class Project extends HXProject
{
// =========================================================================
// Application Settings
// =========================================================================
static final APP_TITLE:String = "Friday Night Funkin': Crow Engine";
static final APP_FILE:String = "CrowEngine";
static final APP_MAIN:String = "crow.Main";
static final APP_VERSION:String = "1.0.0";
static final APP_COMPANY:String = "EyeDaleHim";
static final APP_PRELOADER:String = "crow.Preloader";
static final APP_PACKAGE:String = "com.eyedalehim.fnfcrowengine";
static final PREBUILD_HX:String = "build/Prebuild.hx";
static final POSTBUILD_HX:String = "build/Postbuild.hx";
// =========================================================================
// Path Settings
// =========================================================================
static final SOURCE_DIR:String = "source";
static final BUILD_DIR:String = "export";
static final LAUNCH_IMAGE_PATH:String = "assets/images/splash.png";
public function new()
{
super();
// Display basic info
info('Crow Engine ${APP_VERSION} - ${APP_COMPANY}');
// Configure core application properties
configureApp();
// Configure window properties
configureWindow();
// Configure paths and directories
configurePaths();
// Configure required libraries
configureHaxelibs();
// Configure compile-time definitions (haxedefs)
configureHaxedefs();
// Configure custom build backend.macros
configureMacros();
}
function configureApp()
{
meta.title = APP_TITLE;
meta.version = APP_VERSION;
meta.company = APP_COMPANY;
meta.packageName = APP_PACKAGE;
app.main = APP_MAIN;
app.file = APP_FILE;
app.preloader = APP_PRELOADER;
this.preBuildCallbacks.push(buildHaxeCLICommand(PREBUILD_HX));
this.postBuildCallbacks.push(buildHaxeCLICommand(POSTBUILD_HX));
}
function configureWindow()
{
window.width = 1280;
window.height = 720;
window.fps = 60;
window.background = 0xFF000000;
window.hardware = true;
window.vsync = false;
// Desktop-specific settings
if (isDesktop())
{
window.orientation = Orientation.LANDSCAPE;
window.fullscreen = false;
window.resizable = true;
}
}
function configurePaths()
{
sources.push(SOURCE_DIR);
var buildDir = '$BUILD_DIR/${isDebug() ? 'debug' : 'release'}';
buildDir += "/";
info('Output directory: $buildDir');
app.path = buildDir;
}
function configureHaxelibs()
{
addHaxelib("flixel");
addHaxelib("flixel-addons");
addHaxelib("hscript");
if (isDebug() && isCpp())
addHaxelib("hxcpp-debug-server");
}
function configureHaxedefs()
{
// setHaxedef("ASSETS_PACKAGING");
// setHaxedef("ASSETS_PACKAGING_COMPRESSION", "0"); // max is 9
// setHaxedef("PRELOAD_ALL_ASSETS_VALUE", "20"); // measured in MB, if the asset bundle is below this size, all assets will be preloaded
// If JSON_TO_MESSAGEPACK is defined, then all JSON assets will be converted to MessagePack.
// This is useful for reducing file size and improving parsing performance.
// This is only recommended for release builds, as it will make the assets unreadable.
if (!isDebug())
setHaxedef("JSON_TO_MESSAGEPACK");
// If SBS_SPARROW is defined, then XML assets that are clearly related to spritesheets
// will be converted to .sbs format.
if (!isDebug())
setHaxedef("SBS_SPARROW");
// If USE_TEXTURE is defined, then PNG assets will be compressed to a texture format,
// .sbs files will also store image blobs as BC7 instead of uncompressed PNG.
if (!isDebug())
setHaxedef("USE_TEXTURE");
// If USE_MULTITHREADING is defined, mulithreading is used wherever possible.
// setHaxedef("USE_MULTITHREADING");
setHaxedef("hscriptPos");
if (isCpp())
{
setHaxedef("openfl-enable-handle-error");
if (this.haxedefs.exists("TRACY_ENABLED"))
{
setHaxedef("HXCPP_TELEMETRY");
setHaxedef("HXCPP_TRACY");
setHaxedef("HXCPP_TRACY_MEMORY");
setHaxedef("HXCPP_TRACY_ON_DEMAND");
}
setHaxedef("HXCPP_CHECK_POINTER");
setHaxedef("HXCPP_STACK_LINE");
setHaxedef("HXCPP_STACK_TRACE");
}
if (isDesktop() && isDebug())
setHaxedef("EDITORS_ALLOWED");
setHaxedef("FLX_NO_HEALTH");
setHaxedef("FLX_NO_FOCUS_LOST_SCREEN");
if (!isDebug())
setHaxedef("FLX_NO_DEBUG");
// Input Optimizations (Conditional)
if (isMobile())
{
setHaxedef("FLX_NO_MOUSE");
setHaxedef("FLX_NO_KEYBOARD");
}
if (isDesktop())
setHaxedef("FLX_NO_TOUCH");
// Compiler / Build Settings
setHaxedef("message.reporting", "pretty");
}
function configureMacros()
{
addHaxeFlag("--macro crow.macros.AssetProcessorMacro.run()");
if (this.haxedefs.exists("ASSETS_PACKAGING"))
addHaxeFlag("--macro crow.macros.BundleMacro.build()");
else
addHaxeFlag("--macro crow.macros.AssetsMacro.buildAssets()");
addHaxeFlag("--macro addMetadata('@:build(crow.macros.FlxMacro.buildFlxBasic())', 'flixel.FlxBasic')");
}
public function buildHaxeCLICommand(path:String):CLICommand {
return CommandHelper.interpretHaxe(path);
}
inline function isDesktop():Bool
return this.platformType == PlatformType.DESKTOP;
inline function isMobile():Bool
return this.platformType == PlatformType.MOBILE;
inline function isDebug():Bool
return this.debug;
public function isHashLink():Bool
return this.targetFlags.exists("hl");
public function isNeko():Bool
return this.targetFlags.exists("neko");
public function isJava():Bool
return this.targetFlags.exists("java");
public function isNodeJS():Bool
return this.targetFlags.exists("nodejs");
public function isCSharp():Bool
return this.targetFlags.exists("cs");
public function isCpp():Bool // no target flag for cpp, wtf???
return !isHashLink() && !isNeko() && !isJava() && !isNodeJS() && !isCSharp();
inline function setHaxedef(name:String, ?value:String):Void
this.haxedefs.set(name, value == null ? "" : value);
inline function addHaxelib(name:String, ?version:String):Void
this.haxelibs.push(new Haxelib(name, version));
inline function addHaxeFlag(value:String):Void
this.haxeflags.push(value);
inline function info(message:String):Void
{
if (command != "display")
{
Log.info('[INFO] ${message}');
}
}
}