diff --git a/scripts/Builders/yyPrimBuilder.js b/scripts/Builders/yyPrimBuilder.js
index 7443c494..1bed8eed 100644
--- a/scripts/Builders/yyPrimBuilder.js
+++ b/scripts/Builders/yyPrimBuilder.js
@@ -10,40 +10,9 @@
//
// *********************************************************************************************************************
-function draw_primitive_begin(kind) { ErrorFunction("draw_primitive_begin()"); }
-function draw_primitive_begin_texture(kind, texid) { ErrorFunction("draw_primitive_begin_texture()"); }
-function draw_vertex(x,y) { ErrorFunction("draw_vertex()"); }
-function draw_vertex_color(x,y,col,alpha) { ErrorFunction("draw_vertex_color()"); }
-var draw_vertex_colour = draw_vertex_color;
-function draw_vertex_texture(x,y,xtex,ytex) { ErrorFunction("draw_vertex_texture()"); }
-function draw_vertex_texture_color(x,y,xtex,ytex,col,alpha) { ErrorFunction("draw_vertex_texture_color()"); }
-var draw_vertex_texture_colour = draw_vertex_texture_color;
-function draw_primitive_end() { ErrorFunction("draw_primitive_end()"); }
-
-function d3d_primitive_begin(kind) { ErrorFunction("d3d_primitive_begin()"); }
-function d3d_primitive_begin_texture(kind,texid) { ErrorFunction("d3d_primitive_begin_texture()"); }
-function d3d_vertex(x,y,z) { ErrorFunction("d3d_vertex()"); }
-function d3d_vertex_color(x,y,z,col,alpha) { ErrorFunction("d3d_vertex_color()"); }
-var d3d_vertex_colour = d3d_vertex_color;
-function d3d_vertex_texture(x,y,z,xtex,ytex) { ErrorFunction("d3d_vertex_texture()"); }
-function d3d_vertex_texture_color(x,y,z,xtex,ytex,col,alpha) { ErrorFunction("d3d_vertex_texture_color()"); }
-var d3d_vertex_texture_colour = d3d_vertex_texture_color;
-function d3d_vertex_normal(x,y,z,nx,ny,nz) { ErrorFunction("d3d_vertex_normal()"); }
-function d3d_vertex_normal_color(x,y,z,nx,ny,nz,col,alpha) { ErrorFunction("d3d_vertex_normal_color()"); }
-var d3d_vertex_normal_colour = d3d_vertex_normal_color;
-function d3d_vertex_normal_texture(x,y,z,nx,ny,nz,xtex,ytex) { ErrorFunction("d3d_vertex_normal_texture()"); }
-function d3d_vertex_normal_texture_color(x,y,z,nx,ny,nz,xtex,ytex,col,alpha){ ErrorFunction("d3d_vertex_normal_texture_color()"); }
-var d3d_vertex_normal_texture_colour = d3d_vertex_normal_texture_color;
-function d3d_primitive_end() { ErrorFunction("d3d_primitive_end()"); }
-
-// ----------------------------------------------------------------------------------------------------------------------------------------
-var g_PrimBuffer = null; // raw ArrayBuffer data
-
-var g_PrimType = 0,
- g_PrimTexture = -1,
- g_PrimTPE = null,
- g_PrimVBuffer = null;
+// @if feature("gl") && (function("draw_primitive_*") || function("draw_vertex*") || function("vertex_*"))
+// primitive type translation is shared between draw_primitive_* and vertex_submit
var PrimType_POINTLIST = 1,
PrimType_LINELIST = 2,
PrimType_LINESTRIP = 3,
@@ -52,6 +21,55 @@ var PrimType_POINTLIST = 1,
PrimType_TRIFAN = 6,
PrimType_SPRITE = 7;
+function WebGL_translate_primitive_builder_type(_prim) {
+
+ switch (_prim) {
+ case PrimType_POINTLIST: return yyGL.PRIM_POINT;
+ case PrimType_LINELIST: return yyGL.PRIM_LINE;
+ case PrimType_LINESTRIP: return yyGL.PRIM_LINESTRIP;
+ case PrimType_TRILIST: return yyGL.PRIM_TRIANGLE;
+ case PrimType_TRISTRIP: return yyGL.PRIM_TRISTRIP;
+ case PrimType_TRIFAN: return yyGL.PRIM_TRIFAN;
+ case PrimType_SPRITE: return yyGL.PRIM_TRIANGLE;
+ }
+ return -1;
+}
+
+// @endif primitives or vertex buffers on WebGL
+
+// @if function("draw_primitive_*") || function("draw_vertex*")
+var draw_primitive_begin,
+ draw_primitive_begin_texture,
+ draw_vertex,
+ draw_vertex_color,
+ draw_vertex_colour,
+ draw_vertex_texture,
+ draw_vertex_texture_color,
+ draw_vertex_texture_colour,
+ draw_primitive_end;
+
+// @if feature("2d")
+(() => {
+ let _stub = (_name) => () => ErrorFunction(_name);
+ draw_primitive_begin = _stub("draw_primitive_begin");
+ draw_primitive_begin_texture = _stub("draw_primitive_begin_texture");
+ draw_vertex = _stub("draw_vertex");
+ draw_vertex_color = _stub("draw_vertex_color");
+ draw_vertex_colour = draw_vertex_color;
+ draw_vertex_texture = _stub("draw_vertex_texture");
+ draw_vertex_texture_color = _stub("draw_vertex_texture_color");
+ draw_vertex_texture_colour = draw_vertex_texture_color;
+ draw_primitive_end = _stub("draw_primitive_end");
+})();
+// @endif 2d
+
+// @if feature("gl")
+
+var g_PrimType = 0,
+ g_PrimTexture = -1,
+ g_PrimTPE = null,
+ g_PrimVBuffer = null;
+
// #############################################################################################
/// Function:
/// Bind primitive building functions to WebGL versions
@@ -68,41 +86,6 @@ function InitPrimBuilderFunctions() {
draw_vertex_texture_color = WebGL_draw_vertex_texture_color_RELEASE;
draw_vertex_texture_colour = WebGL_draw_vertex_texture_color_RELEASE;
draw_primitive_end = WebGL_draw_primitive_end_RELEASE;
-
- // 3D primitives
- d3d_primitive_begin = WebGL_d3d_primitive_begin_RELEASE;
- d3d_primitive_begin_texture = WebGL_d3d_primitive_begin_texture_RELEASE;
- d3d_vertex = WebGL_d3d_vertex_RELEASE;
- d3d_vertex_color = WebGL_d3d_vertex_color_RELEASE;
- d3d_vertex_colour = WebGL_d3d_vertex_color_RELEASE;
- d3d_vertex_texture = WebGL_d3d_vertex_texture_RELEASE;
- d3d_vertex_texture_color = WebGL_d3d_vertex_texture_color_RELEASE;
- d3d_vertex_texture_colour = WebGL_d3d_vertex_texture_color_RELEASE;
- d3d_vertex_normal = WebGL_d3d_vertex_normal_RELEASE;
- d3d_vertex_normal_color = WebGL_d3d_vertex_normal_color_RELEASE;
- d3d_vertex_normal_colour = WebGL_d3d_vertex_normal_color_RELEASE;
- d3d_vertex_normal_texture = WebGL_d3d_vertex_normal_texture_RELEASE;
- d3d_vertex_normal_texture_color = WebGL_d3d_vertex_normal_texture_color_RELEASE;
- d3d_vertex_normal_texture_colour = WebGL_d3d_vertex_normal_texture_color_RELEASE;
- d3d_primitive_end = WebGL_d3d_primitive_end_RELEASE;
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_translate_primitive_builder_type(_prim) {
-
- switch (_prim) {
- case PrimType_POINTLIST: return yyGL.PRIM_POINT;
- case PrimType_LINELIST: return yyGL.PRIM_LINE;
- case PrimType_LINESTRIP: return yyGL.PRIM_LINESTRIP;
- case PrimType_TRILIST: return yyGL.PRIM_TRIANGLE;
- case PrimType_TRISTRIP: return yyGL.PRIM_TRISTRIP;
- case PrimType_TRIFAN: return yyGL.PRIM_TRIFAN;
- case PrimType_SPRITE: return yyGL.PRIM_TRIANGLE;
- }
- return -1;
}
// #############################################################################################
@@ -251,42 +234,6 @@ function WebGL_draw_primitive_end_RELEASE() {
pBuff.Current += g_PrimVBuffer.Current;
}
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_primitive_begin_RELEASE(kind) {
-
- d3d_primitive_begin_texture(kind, -1);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_primitive_begin_texture_RELEASE(_kind, _tex) {
-
- g_PrimType = _kind;
- g_PrimTexture = null;
- g_PrimTPE = null;
-
- // The texture provided might be an actual texture object or an index
- if (typeof(_tex) == "object") {
- g_PrimTexture = _tex.WebGLTexture;
- g_PrimTPE = _tex.TPE;
- }
- else if ((_tex != -1) && g_Textures[_tex]) {
- g_PrimTexture = g_Textures[_tex];
- }
-
- // If they've managed to find a path through the code without this texture being bound...
- if (g_PrimTexture && !g_PrimTexture.webgl_textureid) {
- WebGL_BindTexture({texture: g_PrimTexture});
- }
-
- g_PrimVBuffer = new yyVBuffer(DEFAULT_VB_SIZE, g_webGL.GetVertexFormat(g_webGL.VERTEX_FORMAT_3D), false);
-}
-
// #############################################################################################
/// Function:
/// If we have a TPE available, adjust the UV accordingly
@@ -304,197 +251,6 @@ function vertex_uv(_u, _v) {
return ({ u: _u, v: _v });
}
};
+// @endif draw_primitive GL
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_vertex_RELEASE(_x, _y, _z) {
-
- var stride = g_PrimVBuffer.GetStride() >> 2;
- var index = g_PrimVBuffer.Current * stride;
- g_PrimVBuffer.IncreaseCurrent(1);
-
- g_PrimVBuffer.Coords[index + 0] = _x;
- g_PrimVBuffer.Coords[index + 1] = _y;
- g_PrimVBuffer.Coords[index + 2] = _z;
- g_PrimVBuffer.Normals[index + 0] = 0;
- g_PrimVBuffer.Normals[index + 1] = 0;
- g_PrimVBuffer.Normals[index + 2] = 0;
- g_PrimVBuffer.UVs[index + 0] = 0;
- g_PrimVBuffer.UVs[index + 1] = 0;
- g_PrimVBuffer.Colours[index] = ((g_GlobalAlpha * 255.0) << 24) | (g_GlobalColour & 0x00ffffff);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_vertex_color_RELEASE(_x, _y, _z, _col, _alpha) {
-
- var stride = g_PrimVBuffer.GetStride() >> 2;
- var index = g_PrimVBuffer.Current * stride;
- g_PrimVBuffer.IncreaseCurrent(1);
-
- g_PrimVBuffer.Coords[index + 0] = _x;
- g_PrimVBuffer.Coords[index + 1] = _y;
- g_PrimVBuffer.Coords[index + 2] = _z;
- g_PrimVBuffer.Normals[index + 0] = 0;
- g_PrimVBuffer.Normals[index + 1] = 0;
- g_PrimVBuffer.Normals[index + 2] = 0;
- g_PrimVBuffer.UVs[index + 0] = 0;
- g_PrimVBuffer.UVs[index + 1] = 0;
- g_PrimVBuffer.Colours[index] = ((_alpha * 255.0) << 24) | ConvertGMColour(_col);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_vertex_texture_RELEASE(_x, _y, _z, _xtex, _ytex) {
-
- var stride = g_PrimVBuffer.GetStride() >> 2;
- var index = g_PrimVBuffer.Current * stride;
- g_PrimVBuffer.IncreaseCurrent(1);
-
- g_PrimVBuffer.Coords[index + 0] = _x;
- g_PrimVBuffer.Coords[index + 1] = _y;
- g_PrimVBuffer.Coords[index + 2] = _z;
- g_PrimVBuffer.Normals[index + 0] = 0;
- g_PrimVBuffer.Normals[index + 1] = 0;
- g_PrimVBuffer.Normals[index + 2] = 0;
- var uv = vertex_uv(_xtex, _ytex);
- g_PrimVBuffer.UVs[index + 0] = uv.u;
- g_PrimVBuffer.UVs[index + 1] = uv.v;
- g_PrimVBuffer.Colours[index] = ((g_GlobalAlpha * 255.0) << 24) | (g_GlobalColour & 0x00ffffff);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_vertex_texture_color_RELEASE(_x, _y, _z, _xtex, _ytex, _col, _alpha) {
-
- var stride = g_PrimVBuffer.GetStride() >> 2;
- var index = g_PrimVBuffer.Current * stride;
- g_PrimVBuffer.IncreaseCurrent(1);
-
- g_PrimVBuffer.Coords[index + 0] = _x;
- g_PrimVBuffer.Coords[index + 1] = _y;
- g_PrimVBuffer.Coords[index + 2] = _z;
- g_PrimVBuffer.Normals[index + 0] = 0;
- g_PrimVBuffer.Normals[index + 1] = 0;
- g_PrimVBuffer.Normals[index + 2] = 0;
- var uv = vertex_uv(_xtex, _ytex);
- g_PrimVBuffer.UVs[index + 0] = uv.u;
- g_PrimVBuffer.UVs[index + 1] = uv.v;
- g_PrimVBuffer.Colours[index] = ((_alpha * 255.0) << 24) | ConvertGMColour(_col);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_vertex_normal_RELEASE(_x, _y, _z, _nx, _ny, _nz) {
-
- var stride = g_PrimVBuffer.GetStride() >> 2;
- var index = g_PrimVBuffer.Current * stride;
- g_PrimVBuffer.IncreaseCurrent(1);
-
- g_PrimVBuffer.Coords[index + 0] = _x;
- g_PrimVBuffer.Coords[index + 1] = _y;
- g_PrimVBuffer.Coords[index + 2] = _z;
- g_PrimVBuffer.Normals[index + 0] = _nx;
- g_PrimVBuffer.Normals[index + 1] = _ny;
- g_PrimVBuffer.Normals[index + 2] = _nz;
- g_PrimVBuffer.UVs[index + 0] = 0;
- g_PrimVBuffer.UVs[index + 1] = 0;
- g_PrimVBuffer.Colours[index] = ((g_GlobalAlpha * 255.0) << 24) | (g_GlobalColour & 0x00ffffff);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_vertex_normal_color_RELEASE(_x, _y, _z, _nx, _ny, _nz, _col, _alpha) {
-
- var stride = g_PrimVBuffer.GetStride() >> 2;
- var index = g_PrimVBuffer.Current * stride;
- g_PrimVBuffer.IncreaseCurrent(1);
-
- g_PrimVBuffer.Coords[index + 0] = _x;
- g_PrimVBuffer.Coords[index + 1] = _y;
- g_PrimVBuffer.Coords[index + 2] = _z;
- g_PrimVBuffer.Normals[index + 0] = _nx;
- g_PrimVBuffer.Normals[index + 1] = _ny;
- g_PrimVBuffer.Normals[index + 2] = _nz;
- g_PrimVBuffer.UVs[index + 0] = 0;
- g_PrimVBuffer.UVs[index + 1] = 0;
- g_PrimVBuffer.Colours[index] = ((_alpha * 255.0) << 24) | ConvertGMColour(_col);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_vertex_normal_texture_RELEASE(_x, _y, _z, _nx, _ny, _nz, _xtex, _ytex) {
-
- var stride = g_PrimVBuffer.GetStride() >> 2;
- var index = g_PrimVBuffer.Current * stride;
- g_PrimVBuffer.IncreaseCurrent(1);
-
- g_PrimVBuffer.Coords[index + 0] = _x;
- g_PrimVBuffer.Coords[index + 1] = _y;
- g_PrimVBuffer.Coords[index + 2] = _z;
- g_PrimVBuffer.Normals[index + 0] = _nx;
- g_PrimVBuffer.Normals[index + 1] = _ny;
- g_PrimVBuffer.Normals[index + 2] = _nz;
- var uv = vertex_uv(_xtex, _ytex);
- g_PrimVBuffer.UVs[index + 0] = uv.u;
- g_PrimVBuffer.UVs[index + 1] = uv.v;
- g_PrimVBuffer.Colours[index] = ((g_GlobalAlpha * 255.0) << 24) | (g_GlobalColour & 0x00ffffff);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_vertex_normal_texture_color_RELEASE(_x, _y, _z, _nx, _ny, _nz, _xtex, _ytex, _col, _alpha) {
-
- var stride = g_PrimVBuffer.GetStride() >> 2;
- var index = g_PrimVBuffer.Current * stride;
- g_PrimVBuffer.IncreaseCurrent(1);
-
- g_PrimVBuffer.Coords[index + 0] = _x;
- g_PrimVBuffer.Coords[index + 1] = _y;
- g_PrimVBuffer.Coords[index + 2] = _z;
- g_PrimVBuffer.Normals[index + 0] = _nx;
- g_PrimVBuffer.Normals[index + 1] = _ny;
- g_PrimVBuffer.Normals[index + 2] = _nz;
- var uv = vertex_uv(_xtex, _ytex);
- g_PrimVBuffer.UVs[index + 0] = uv.u;
- g_PrimVBuffer.UVs[index + 1] = uv.v;
- g_PrimVBuffer.Colours[index] = ((_alpha * 255.0) << 24) | ConvertGMColour(_col);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_primitive_end_RELEASE() {
-
- var prim = WebGL_translate_primitive_builder_type(g_PrimType);
- if (prim == -1) {
- return;
- }
-
- // Transfer the stored primitive block to the vbuffer manager
- var vertexData = g_PrimVBuffer.VertexData.subarray(0, g_PrimVBuffer.Current * g_PrimVBuffer.GetStride());
-
- // Alloc vertices
- var glTexture = g_PrimTexture ? g_PrimTexture.webgl_textureid : null;
- var pBuff = g_webGL.AllocVerts(prim, glTexture, g_webGL.VERTEX_FORMAT_3D, g_PrimVBuffer.Current);
-
- pBuff.VertexData.set(vertexData, pBuff.Current * pBuff.GetStride());
- pBuff.Current += g_PrimVBuffer.Current;
-}
\ No newline at end of file
+// @endif draw_primitive
diff --git a/scripts/CameraManager.js b/scripts/CameraManager.js
index 9535b733..358232ed 100644
--- a/scripts/CameraManager.js
+++ b/scripts/CameraManager.js
@@ -519,6 +519,7 @@ CCamera.prototype.ApplyMatrices = function () {
WebGL_SetMatrix(MATRIX_VIEW, this.m_viewMat);
}
else {
+ // @if feature("2d")
WebGL_SetMatrix(MATRIX_VIEW, this.m_viewMat);
// Work out port scaling
var wscale = g_clipw / g_worldw;
@@ -535,6 +536,7 @@ CCamera.prototype.ApplyMatrices = function () {
// for some reason this function takes the matrix transposed
graphics._setTransform(g_transform[0], g_transform[3], g_transform[1], g_transform[4], g_transform[2], g_transform[5]);
+ // @endif
}
if (g_RenderTargetActive == -1) {
diff --git a/scripts/Effects.js b/scripts/Effects.js
index 66f76c9f..e0a4efce 100644
--- a/scripts/Effects.js
+++ b/scripts/Effects.js
@@ -58,32 +58,14 @@ var types_created = false, // whether the types have been create
// #############################################################################################
function Speed_Factor()
{
- if(g_isZeus)
- {
-
- if( ( g_GameTimer.GetFPS() <= 30) || (Fps <= 30) ){
- return 1.0;
- }
-
- if( (g_GameTimer.GetFPS()/ Fps) < 1.2 ){
- return 30.0/g_GameTimer.GetFPS();
- }else{
- return 30.0/Fps;
- }
- }
- else
- {
-
-
- if( ( g_RunRoom.GetSpeed() <= 30) || (Fps <= 30) ){
- return 1.0;
- }
+ if( ( g_GameTimer.GetFPS() <= 30) || (Fps <= 30) ){
+ return 1.0;
+ }
- if( (g_RunRoom.GetSpeed() / Fps) < 1.2 ){
- return 30.0/g_RunRoom.GetSpeed();
- }else{
- return 30.0/Fps;
- }
+ if( (g_GameTimer.GetFPS()/ Fps) < 1.2 ){
+ return 30.0/g_GameTimer.GetFPS();
+ }else{
+ return 30.0/Fps;
}
}
diff --git a/scripts/Events.js b/scripts/Events.js
index 40e74de2..0ffc7559 100644
--- a/scripts/Events.js
+++ b/scripts/Events.js
@@ -93,6 +93,7 @@ function HandleOSEvents() {
// #############################################################################################
function HandleOther()
{
+ // @if event("OutsideEvent") || event("BoundaryEvent") || event("OutsideView*") || event("BoundaryView*")
var bbox, i, viewIndex;
var pViews = null;
if (g_RunRoom.m_enableviews)
@@ -111,6 +112,7 @@ function HandleOther()
if (!inst.marked && (inst.createCounter <= count))
{
// Outside events
+ // @if event("OutsideEvent")
if (pObject.REvent[EVENT_OTHER_OUTSIDE])
{
var outside = false;
@@ -131,8 +133,10 @@ function HandleOther()
}
inst.fOutsideRoom = outside;
}
+ // @endif OutsideEvent
// Boundary events
+ // @if event("BoundaryEvent")
if (pObject.REvent[EVENT_OTHER_BOUNDARY])
{
if (sprite_exists(inst.sprite_index) || sprite_exists(inst.mask_index))
@@ -151,10 +155,12 @@ function HandleOther()
}
}
}
+ // @endif
// Handle view related "other" events
//for (i in pViews)
+ // @if event("OutsideView*") || event("BoundaryView*")
if (pViews) {
for (viewIndex = 0; viewIndex < pViews.length; viewIndex++) {
//if (!pViews.hasOwnProperty(i)) continue;
@@ -179,6 +185,7 @@ function HandleOther()
}
// Outside view events
+ // @if event("OutsideView*")
if (pObject.REvent[EVENT_OTHER_OUTSIDE_VIEW0 + viewIndex]) {
// Make a distinction whether the instance has a mask (or sprite) || not
@@ -200,8 +207,10 @@ function HandleOther()
}
}
}
+ // @endif OutsideView
// Boundary view events
+ // @if event("BoundaryView*")
if (pObject.REvent[EVENT_OTHER_BOUNDARY_VIEW0 + viewIndex]) {
if (sprite_exists(inst.sprite_index) || sprite_exists(inst.mask_index)) {
@@ -238,12 +247,14 @@ function HandleOther()
}*/
}
}
+ // @endif BoundaryView
}
}
}
+ // @endif OutsideView || BoundaryView
}
}
-
+ // @endif Outside || Boundary || OutsideView || BoundaryView
}
@@ -369,45 +380,6 @@ function HandleCollision()
}*/
-// #############################################################################################
-/// Function:
-/// Given a point, do a collision test with each instance that has the desired
-/// event. (mouse click etc).
-///
-///
-/// In: Primary event
-/// Secondary event
-/// X Point to test with
-/// Y Point to test with
-///
-// #############################################################################################
-function DoPointToInstance( _event, _sub_event, _x,_y )
-{
- // First scale the coordinate into the current screen scale.
- //_x = _x * scale;
-
- // Might be better to loop through objects, rather than active instances... less getSprite stuff...
- for(var i=g_RunRoom.m_Active.length-1;i>=0;i-- )
- {
- var pInst = g_RunRoom.m_Active.Get(i);
- // with( pInst )
- {
- if (pInst.bbox_dirty) pInst.Compute_BoundingBox();
- if (!pInst.marked && pInst.pObject.REvent[_event | _sub_event])
- {
- var pSprite = g_pSpriteManager.Get( pInst.sprite_index );
- var ox = pSprite.xOrigin;
- var oy = pSprite.yOrigin;
- if ((_x >= pInst.bbox.left) && (_x < pInst.bbox.right) && (_y >= pInst.bbox.top) && (_y < pInst.bbox.bottom))
- {
- pInst.PerformEvent(_event, _sub_event, pInst, pInst); // timer enum starts at 1..
- }
- }
- }
- }
-}
-
-
// #############################################################################################
/// Function:
@@ -416,6 +388,7 @@ function DoPointToInstance( _event, _sub_event, _x,_y )
// #############################################################################################
function HandleMouse()
{
+ // @if eventType("Mouse")
if (g_RunRoom)
{
var ind;
@@ -554,7 +527,8 @@ function HandleMouse()
{
g_pInstanceManager.PerformEvent(EVENT_MOUSE_WHEEL_DOWN,0);
}
- }
+ }
+ // @endif mouse events
}
@@ -565,6 +539,7 @@ function HandleMouse()
// #############################################################################################
function HandleTimeLine()
{
+ // @if feature("timelines")
var ind1,ind2,j;
var pool = g_RunRoom.m_Active.pool;
var count = g_currentCreateCounter++;
@@ -616,6 +591,7 @@ function HandleTimeLine()
}
}
}
+ // @endif
}
// #############################################################################################
@@ -800,6 +776,7 @@ function event_lookup(_event, _subevent)
case GML_EVENT_OTHER_ENDOFPATH: return EVENT_OTHER_ENDOFPATH;
case GML_EVENT_OTHER_NOHEALTH: return EVENT_OTHER_NOHEALTH;
case GML_EVENT_OTHER_CLOSEBUTTON: return EVENT_OTHER_CLOSEBUTTON;
+ // @if event("OutsideView*")
case GML_EVENT_OTHER_OUTSIDE_VIEW0: return EVENT_OTHER_OUTSIDE_VIEW0;
case GML_EVENT_OTHER_OUTSIDE_VIEW1: return EVENT_OTHER_OUTSIDE_VIEW1;
case GML_EVENT_OTHER_OUTSIDE_VIEW2: return EVENT_OTHER_OUTSIDE_VIEW2;
@@ -808,6 +785,8 @@ function event_lookup(_event, _subevent)
case GML_EVENT_OTHER_OUTSIDE_VIEW5: return EVENT_OTHER_OUTSIDE_VIEW5;
case GML_EVENT_OTHER_OUTSIDE_VIEW6: return EVENT_OTHER_OUTSIDE_VIEW6;
case GML_EVENT_OTHER_OUTSIDE_VIEW7: return EVENT_OTHER_OUTSIDE_VIEW7;
+ // @endif
+ // @if event("BoundaryView*")
case GML_EVENT_OTHER_BOUNDARY_VIEW0: return EVENT_OTHER_BOUNDARY_VIEW0;
case GML_EVENT_OTHER_BOUNDARY_VIEW1: return EVENT_OTHER_BOUNDARY_VIEW1;
case GML_EVENT_OTHER_BOUNDARY_VIEW2: return EVENT_OTHER_BOUNDARY_VIEW2;
@@ -816,22 +795,25 @@ function event_lookup(_event, _subevent)
case GML_EVENT_OTHER_BOUNDARY_VIEW5: return EVENT_OTHER_BOUNDARY_VIEW5;
case GML_EVENT_OTHER_BOUNDARY_VIEW6: return EVENT_OTHER_BOUNDARY_VIEW6;
case GML_EVENT_OTHER_BOUNDARY_VIEW7: return EVENT_OTHER_BOUNDARY_VIEW7;
- case GML_ev_user0: return EVENT_OTHER_USER0;
- case GML_ev_user1: return EVENT_OTHER_USER1;
- case GML_ev_user2: return EVENT_OTHER_USER2;
- case GML_ev_user3: return EVENT_OTHER_USER3;
- case GML_ev_user4: return EVENT_OTHER_USER4;
- case GML_ev_user5: return EVENT_OTHER_USER5;
- case GML_ev_user6: return EVENT_OTHER_USER6;
- case GML_ev_user7: return EVENT_OTHER_USER7;
- case GML_ev_user8: return EVENT_OTHER_USER8;
- case GML_ev_user9: return EVENT_OTHER_USER9;
- case GML_ev_user10: return EVENT_OTHER_USER10;
- case GML_ev_user11: return EVENT_OTHER_USER11;
- case GML_ev_user12: return EVENT_OTHER_USER12;
- case GML_ev_user13: return EVENT_OTHER_USER13;
- case GML_ev_user14: return EVENT_OTHER_USER14;
- case GML_ev_user15: return EVENT_OTHER_USER15;
+ // @endif
+ // @if event("UserEvent*")
+ case GML_EVENT_OTHER_USER0: return EVENT_OTHER_USER0;
+ case GML_EVENT_OTHER_USER1: return EVENT_OTHER_USER1;
+ case GML_EVENT_OTHER_USER2: return EVENT_OTHER_USER2;
+ case GML_EVENT_OTHER_USER3: return EVENT_OTHER_USER3;
+ case GML_EVENT_OTHER_USER4: return EVENT_OTHER_USER4;
+ case GML_EVENT_OTHER_USER5: return EVENT_OTHER_USER5;
+ case GML_EVENT_OTHER_USER6: return EVENT_OTHER_USER6;
+ case GML_EVENT_OTHER_USER7: return EVENT_OTHER_USER7;
+ case GML_EVENT_OTHER_USER8: return EVENT_OTHER_USER8;
+ case GML_EVENT_OTHER_USER9: return EVENT_OTHER_USER9;
+ case GML_EVENT_OTHER_USER10: return EVENT_OTHER_USER10;
+ case GML_EVENT_OTHER_USER11: return EVENT_OTHER_USER11;
+ case GML_EVENT_OTHER_USER12: return EVENT_OTHER_USER12;
+ case GML_EVENT_OTHER_USER13: return EVENT_OTHER_USER13;
+ case GML_EVENT_OTHER_USER14: return EVENT_OTHER_USER14;
+ case GML_EVENT_OTHER_USER15: return EVENT_OTHER_USER15;
+ // @endif
case GML_EVENT_OTHER_ANIMATIONUPDATE: return EVENT_OTHER_ANIMATIONUPDATE;
case GML_EVENT_OTHER_ANIMATIONEVENT: return EVENT_OTHER_ANIMATIONEVENT;
case GML_EVENT_OTHER_WEB_IMAGE_LOAD: return EVENT_OTHER_WEB_IMAGE_LOAD;
diff --git a/scripts/Globals.js b/scripts/Globals.js
index 10120fc4..33197107 100644
--- a/scripts/Globals.js
+++ b/scripts/Globals.js
@@ -114,7 +114,8 @@
EVENT_OTHER_NOHEALTH = EVENT_OTHER|10,
EVENT_OTHER_CLOSEBUTTON = EVENT_OTHER|11,
- EVENT_OTHER_USER0 = EVENT_OTHER|14,
+ EVENT_OTHER_USER0 = EVENT_OTHER|14,
+ // @if event("UserEvent*")
EVENT_OTHER_USER1 = EVENT_OTHER|15,
EVENT_OTHER_USER2 = EVENT_OTHER|16,
EVENT_OTHER_USER3 = EVENT_OTHER|17,
@@ -129,8 +130,10 @@
EVENT_OTHER_USER12= EVENT_OTHER|26,
EVENT_OTHER_USER13= EVENT_OTHER|27,
EVENT_OTHER_USER14= EVENT_OTHER|28,
- EVENT_OTHER_USER15= EVENT_OTHER|29,
+ EVENT_OTHER_USER15= EVENT_OTHER|29,
+ // @endif
+ // @if event("OutsideView*")
EVENT_OTHER_OUTSIDE_VIEW0 = EVENT_OTHER|30,
EVENT_OTHER_OUTSIDE_VIEW1 = EVENT_OTHER|31,
EVENT_OTHER_OUTSIDE_VIEW2 = EVENT_OTHER|32,
@@ -139,7 +142,9 @@
EVENT_OTHER_OUTSIDE_VIEW5 = EVENT_OTHER|35,
EVENT_OTHER_OUTSIDE_VIEW6 = EVENT_OTHER|36,
EVENT_OTHER_OUTSIDE_VIEW7 = EVENT_OTHER|37,
+ // @endif
+ // @if event("BoundaryView*")
EVENT_OTHER_BOUNDARY_VIEW0 = EVENT_OTHER|40,
EVENT_OTHER_BOUNDARY_VIEW1 = EVENT_OTHER|41,
EVENT_OTHER_BOUNDARY_VIEW2 = EVENT_OTHER|42,
@@ -148,6 +153,7 @@
EVENT_OTHER_BOUNDARY_VIEW5 = EVENT_OTHER|45,
EVENT_OTHER_BOUNDARY_VIEW6 = EVENT_OTHER|46,
EVENT_OTHER_BOUNDARY_VIEW7 = EVENT_OTHER|47,
+ // @endif
EVENT_OTHER_ANIMATIONUPDATE = EVENT_OTHER | 58,
EVENT_OTHER_ANIMATIONEVENT = EVENT_OTHER | 59,
@@ -265,6 +271,7 @@ EVENT_GESTURE_GLOBAL_ROTATE_END = EVENT_GESTURE | 77,
GML_EVENT_OTHER_USER0 = 10,
+ // @if event("UserEvent*")
GML_EVENT_OTHER_USER1 = 11,
GML_EVENT_OTHER_USER2 = 12,
GML_EVENT_OTHER_USER3 = 13,
@@ -279,7 +286,8 @@ EVENT_GESTURE_GLOBAL_ROTATE_END = EVENT_GESTURE | 77,
GML_EVENT_OTHER_USER12 =22,
GML_EVENT_OTHER_USER13 =23,
GML_EVENT_OTHER_USER14 =24,
- GML_EVENT_OTHER_USER15= 25,
+ GML_EVENT_OTHER_USER15= 25,
+ // @endif
GML_MOUSE_LeftButton = 0,
GML_MOUSE_RightButton = 1,
@@ -372,6 +380,7 @@ GML_EVENT_STEP_NORMAL = 0,
GML_EVENT_OTHER_ENDOFPATH = 8,
GML_EVENT_OTHER_NOHEALTH = 9,
GML_EVENT_OTHER_CLOSEBUTTON = 30,
+ // @if event("OutsideView*")
GML_EVENT_OTHER_OUTSIDE_VIEW0 = 40,
GML_EVENT_OTHER_OUTSIDE_VIEW1 = 41,
GML_EVENT_OTHER_OUTSIDE_VIEW2 = 42,
@@ -380,6 +389,8 @@ GML_EVENT_STEP_NORMAL = 0,
GML_EVENT_OTHER_OUTSIDE_VIEW5 = 45,
GML_EVENT_OTHER_OUTSIDE_VIEW6 = 46,
GML_EVENT_OTHER_OUTSIDE_VIEW7 = 47,
+ // @endif
+ // @if event("BoundaryView*")
GML_EVENT_OTHER_BOUNDARY_VIEW0 = 50,
GML_EVENT_OTHER_BOUNDARY_VIEW1 = 51,
GML_EVENT_OTHER_BOUNDARY_VIEW2 = 52,
@@ -387,28 +398,12 @@ GML_EVENT_STEP_NORMAL = 0,
GML_EVENT_OTHER_BOUNDARY_VIEW4 = 54,
GML_EVENT_OTHER_BOUNDARY_VIEW5 = 55,
GML_EVENT_OTHER_BOUNDARY_VIEW6 = 56,
- GML_EVENT_OTHER_BOUNDARY_VIEW7 = 57,
+ GML_EVENT_OTHER_BOUNDARY_VIEW7 = 57,
+ // @endif
GML_EVENT_OTHER_ANIMATIONUPDATE = 58,
GML_EVENT_OTHER_ANIMATIONEVENT = 59,
-
- GML_ev_user0 = 10,
- GML_ev_user1 = 11,
- GML_ev_user2 = 12,
- GML_ev_user3 = 13,
- GML_ev_user4 = 14,
- GML_ev_user5 = 15,
- GML_ev_user6 = 16,
- GML_ev_user7 = 17,
- GML_ev_user8 = 18,
- GML_ev_user9 = 19,
- GML_ev_user10 = 20,
- GML_ev_user11 = 21,
- GML_ev_user12 = 22,
- GML_ev_user13 = 23,
- GML_ev_user14 = 24,
- GML_ev_user15 = 25,
-
+
GML_EVENT_OTHER_WEB_IMAGE_LOAD = 60,
GML_EVENT_OTHER_WEB_SOUND_LOAD = 61,
GML_EVENT_OTHER_WEB_ASYNC = 62,
@@ -426,7 +421,8 @@ GML_EVENT_STEP_NORMAL = 0,
GML_EVENT_OTHER_BROADCAST_MESSAGE = 76,
- GML_EVENT_KEYPRESS_NOKEY = EVENT_KEYPRESS|0,
+ // @if eventType("KeyPress")
+ GML_EVENT_KEYPRESS_NOKEY = EVENT_KEYPRESS|0,
GML_EVENT_KEYPRESS_ANY = EVENT_KEYPRESS|1,
GML_EVENT_KEYPRESS_ANYKEY = EVENT_KEYPRESS | 1,
GML_EVENT_KEYPRESS_BACKSPACE = EVENT_KEYPRESS | 8,
@@ -531,9 +527,11 @@ GML_EVENT_STEP_NORMAL = 0,
GML_EVENT_KEYPRESS_NUM_MINUS = EVENT_KEYPRESS | 109,
GML_EVENT_KEYPRESS_NUM_DOT = EVENT_KEYPRESS | 110,
GML_EVENT_KEYPRESS_NUM_DIV = EVENT_KEYPRESS | 111,
+ // @endif
// KeyDOWN events...
+ // @if eventType("Keyboard")
GML_EVENT_KEYBOARD_NOKEY = EVENT_KEYBOARD | 0,
GML_EVENT_KEYBOARD_ANY = EVENT_KEYBOARD | 1,
GML_EVENT_KEYBOARD_ANYKEY = EVENT_KEYBOARD | 1,
@@ -639,9 +637,11 @@ GML_EVENT_STEP_NORMAL = 0,
GML_EVENT_KEYBOARD_NUM_MINUS = EVENT_KEYBOARD | 109,
GML_EVENT_KEYBOARD_NUM_DOT = EVENT_KEYBOARD | 110,
GML_EVENT_KEYBOARD_NUM_DIV = EVENT_KEYBOARD | 111,
+ // @endif
// Key Released
+ // @if eventType("KeyRelease")
GML_EVENT_KEYRELEASE_NOKEY = EVENT_KEYRELEASE | 0,
GML_EVENT_KEYRELEASE_ANY = EVENT_KEYRELEASE | 1,
GML_EVENT_KEYRELEASE_ANYKEY = EVENT_KEYRELEASE | 1,
@@ -747,6 +747,7 @@ GML_EVENT_STEP_NORMAL = 0,
GML_EVENT_KEYRELEASE_NUM_MINUS = EVENT_KEYRELEASE | 109,
GML_EVENT_KEYRELEASE_NUM_DOT = EVENT_KEYRELEASE | 110,
GML_EVENT_KEYRELEASE_NUM_DIV = EVENT_KEYRELEASE | 111,
+ // @endif
@@ -870,12 +871,7 @@ Audio_WebAudio=1,
g_pTempTPE =null,
g_VirtualKeyDrawList =null,
g_HighScoreValues =null,
- g_HighScoreNames =null,
- g_HiscoreCaption =null,
g_HighscoreNobody =null,
- g_HighscoreEscape =null,
- g_HiscoreFont =null,
- g_HiscoreFontStyle =null,
g_Arguments =null,
g_ArgumentIndex =null,
g_ArgumentValue =null,
@@ -915,7 +911,6 @@ Audio_WebAudio=1,
g_AudioModel = Audio_Sound,
// assign to true
- g_HiscoreFontBorder =true,
Draw_Automatic = true, // Whether to automatically draw the room each step
// assign to false
@@ -965,11 +960,6 @@ Audio_WebAudio=1,
g_LastCanvasWidth = 0,
g_LastCanvasHeight = 0,
g_DynamicTileID = 0,
- g_HiscoreBackgroundColour = 0,
- g_HiscoreNewColour = 0,
- g_HiscoreOtherColour = 0,
- g_HiscoreFontSize = 0,
- g_HiscoreBackground = 0,
g_AsyncUserID = 0,
g_LastEventpObject = 0,
@@ -1041,6 +1031,13 @@ Audio_WebAudio=1,
g_CanvasName = 'canvas',
g_Hex='0123456789ABCDEF';
+/// With conditional compilation enabled, the call will be replaced with `expr`
+/// if `ident` (typically the function name) is used in GML code and will be stripped otherwise.
+/// If called with one argument, `expr` is presumed to be `ident` and `ident` is the first token
+/// of the expression (like `fun` in `compile_if_used(fun = fun_impl)`)
+function compile_if_used(ident, expr) {}
+/// Akin to above, but works based on referenes in final JS code.
+function compile_if_weak_ref(ident, expr) {}
// #############################################################################################
/// Function:
@@ -1116,7 +1113,8 @@ function InitAboyneGlobals() {
InitFastCRC();
DetectBrowser();
- if(g_AudioModel!= Audio_NoAudio) {
+ // @if feature("audio")
+ if(g_AudioModel!= Audio_NoAudio) {
try {
var pAudioTest = new Audio();
@@ -1134,6 +1132,7 @@ function InitAboyneGlobals() {
}
}
+ // @endif audio
if (g_canPlayMp3) debug("Browser CAN play MP3");
if (g_canPlayOgg) debug("Browser CAN play OGG");
@@ -1165,7 +1164,9 @@ function InitAboyneGlobals() {
g_ParticleTextures = [];
g_ParticleTypes = [];
g_ParticleSystems = [];
+ // @if function("ds_grid_*")
g_ActiveGrids = new yyAllocate(5);
+ // @endif
g_ActivePriorityQueues = new yyAllocate(5);
g_BufferStorage = new yyAllocate(5);
g_ListCollection = new yyAllocate(5);
@@ -1207,23 +1208,17 @@ function InitAboyneGlobals() {
g_RootDir = g_pGMFile.Options.GameDir + '/';
}
}
+ // @if function("virtual_key_*")
g_VirtualKeyDrawList = [];
+ // @endif
g_HighScoreValues = [];
g_HighScoreNames = [];
- g_HiscoreCaption = "Hiscore Table";
g_HighscoreNobody = "";
- g_HighscoreEscape ="Press to Continue";
- g_HiscoreBackgroundColour = 0x000000;
- g_HiscoreBackground = -1;
- g_HiscoreNewColour = 0xffff00;
- g_HiscoreOtherColour = 0xffffff;
- g_HiscoreFont = "verdana";
- g_HiscoreFontSize = 16;
- g_HiscoreFontStyle = "";
- g_HiscoreFontBorder = true;
-
+
+ // @if function("draw_highscore") || function("highscore_*")
highscore_clear();
+ // @endif
g_GUIWidth = -1;
g_GUIHeight = -1;
@@ -1268,17 +1263,7 @@ function InitAboyneGlobals() {
g_room_maxid = 100000;
g_GlobalAlpha = 1.0;
- if(g_isZeus)
- {
- draw_set_colour(g_pGMFile.Options.DrawColour);
- }
- else
- {
- g_GlobalColour_GM = 0x00000000;
- g_GlobalColour = 0x000000; // 0xffffff;
- g_GlobalColour_HTML_RGB = GetHTMLRGB(g_GlobalColour);
- g_GlobalColour_HTML_RGBA = GetHTMLRGBA(g_GlobalColour,g_GlobalAlpha);
- }
+ draw_set_color(g_pGMFile.Options.DrawColour);
c_black = GetHTMLRGB(0x000000);
c_white = GetHTMLRGB(0xffffff);
@@ -1444,12 +1429,12 @@ function ConvertGMColour( _col ){ return (((_col&0xff)<<16) | (_col&0xff00) |
// #############################################################################################
function Timing_Wait( _slp )
{
- var StartTime = YoYo_GetTimer();
+ var StartTime = get_timer();
// very simple delay loop - a proper sleep would be better.
while(_slp>0)
{
- var CurrTime= YoYo_GetTimer();
+ var CurrTime= get_timer();
_slp -= (CurrTime-StartTime);
StartTime = CurrTime;
}
@@ -2000,8 +1985,7 @@ function DetectBrowser()
{
if (document.URL.substring(0, 5) == "file:")
{
- alert("WARNING: Running this via a file and not a web server is not advised as the browser will enable additional security, and things like files and colours won't work correctly. " +
- chr(13) + chr(13) + "Please check the FAQ for more details. " + chr(13) + chr(13) + "https://help.yoyogames.com/hc/en-us/articles/360011372851");
+ alert("WARNING: Running this via a file and not a web server is not advised as the browser will enable additional security, and things like files and colours won't work correctly.\r\rPlease check the FAQ for more details.\r\rhttps://help.yoyogames.com/hc/en-us/articles/360011372851");
}
}
}
diff --git a/scripts/LoadGame.js b/scripts/LoadGame.js
index c419fbac..a665d559 100644
--- a/scripts/LoadGame.js
+++ b/scripts/LoadGame.js
@@ -36,7 +36,9 @@ function InitAboyne()
global = new yyGameGlobals();
g_pBuiltIn = new yyBuiltIn();
g_pIOManager = new yyIOManager();
+ /// @if feature("gamepad")
g_pGamepadManager = new yyGamepadManager();
+ /// @endif
g_pBuiltIn.pointer_null = new ArrayBuffer(1);
g_pBuiltIn.pointer_invalid = new ArrayBuffer(1);
@@ -48,30 +50,45 @@ function InitAboyne()
g_pInstanceManager = new yyInstanceManager();
g_pObjectManager = new yyObjectManager();
g_pRoomManager = new yyRoomManager();
+ // @if feature("sprites")
g_pSpriteManager = new yySpriteManager();
+ // @endif sprites
g_pTextureGroupInfoManager = new yyTextureGroupInfoManager();
g_pBackgroundManager = new yyBackgroundManager();
+ // @if feature("audio")
g_pSoundManager = new yySoundManager();
+ // @endif audio
+ // @if feature("fonts")
g_pFontManager = new yyFontManager();
+ // @endif fonts
g_pCollisionList = [];
+ // @if feature("paths")
g_pPathManager = new yyPathManager();
+ // @endif
+ // @if feature("timelines")
g_pTimelineManager = new yyTimelineManager();
+ // @endif
+ // @if feature("animcurves")
g_pAnimCurveManager = new yyAnimCurveManager();
+ // @endif
+ // @if feature("sequences")
g_pSequenceManager = new yySequenceManager();
+ // @endif
g_pTagManager = new TagManager();
g_pASyncManager = new yyASyncManager();
g_pLayerManager = new LayerManager();
+ // @if feature("layerEffects")
g_pEffectsManager = new yyEffectsManager();
+ // @endif
g_pCameraManager = new CameraManager();
InitAboyneGlobals();
- Audio_Init();
+ // @if feature("audio")
+ Audio_Init();
+ // @endif audio
- if (g_isZeus)
- {
- g_pCameraManager.Clean();
- CreateDefaultCamera();
- }
+ g_pCameraManager.Clean();
+ CreateDefaultCamera();
}
@@ -170,6 +187,7 @@ function LoadedGame_ExtensionError(_event) {
/// Callbacks for sound loading... (this is set to the image)
///
// #############################################################################################
+// @if feature("audio")
function ClearEventListeners(_snd) {
_snd.removeEventListener('canplaythrough', LoadGame_SoundLoad, false);
_snd.removeEventListener('error', LoadGame_SoundLoad_Error, false);
@@ -227,7 +245,7 @@ function LoadGame_SoundLoad_Suspended(_event) {
function LoadGame_SoundLoad_Stalled(_event) {
//debug(this.URL + ' loading stalled');
}
-
+// @endif audio
// #############################################################################################
@@ -339,7 +357,7 @@ function PreLoadExtensions(_GameFile) {
///
// #############################################################################################
function LoadSkeletonData(_filename) {
-
+ // @if feature("spine")
g_LoadingTotal++;
var request = new XMLHttpRequest();
request.open('GET', CheckWorkingDirectory(_filename), true);
@@ -349,6 +367,7 @@ function LoadSkeletonData(_filename) {
g_pSpriteManager.SkeletonLoad(request.responseText);
};
request.onerror = function (ev) { g_LoadingCount++; };
+ // @endif spine
}
@@ -358,7 +377,7 @@ function LoadSkeletonData(_filename) {
///
// #############################################################################################
function LoadSwfData(_filename) {
-
+ // @if feature("swf")
g_LoadingTotal++;
var request = new XMLHttpRequest();
request.open('GET', CheckWorkingDirectory(_filename), true);
@@ -369,6 +388,7 @@ function LoadSwfData(_filename) {
g_pSpriteManager.SWFLoad(request.response || request.responseText);
};
request.onerror = function (ev) { g_LoadingCount++; };
+ // @endif swf
}
// #############################################################################################
@@ -439,16 +459,21 @@ function LoadGame_PreLoadAssets(_GameFile)
}
// Load SWF data if it's present
+ // @if feature("swf")
if ((_GameFile.Swfs !== null) && (_GameFile.Swfs !== undefined)) {
LoadSwfData(_GameFile.Swfs);
}
+ // @endif
// Load Spine data if it's present
+ // @if feature("spine")
if ((_GameFile.Skel !== null) && (_GameFile.Skel !== undefined)) {
LoadSkeletonData(_GameFile.Skel);
}
+ // @endif
// Load the particle textures
+ // @if feature("particles") && feature("particle_images")
if (true == g_pGMFile.Options.UseParticles) {
for (var i = 2; i < 16; i++){
g_LoadingTotal++;
@@ -460,9 +485,11 @@ function LoadGame_PreLoadAssets(_GameFile)
g_Textures[t].URL = "particles/IDR_GIF" + i + ".png";
}
}
+ // @endif
// Now load WAV files (not mp3/ogg)
+ // @if feature("audio")
if(g_AudioModel == Audio_WebAudio)
{
for (index = 0; index < _GameFile.Sounds.length; index++)
@@ -531,6 +558,7 @@ function LoadGame_PreLoadAssets(_GameFile)
}
}
}
+ // @endif audio load
}
@@ -741,6 +769,7 @@ function LoadGame(_GameFile)
Graphics_SetEntryTable(_GameFile.TPageEntries);
// Load Sprites
+ // @if feature("sprites")
for(index=0; index<_GameFile.Sprites.length; index++ ){
if( _GameFile.Sprites[index]===null ){
g_pSpriteManager.AddSprite( null );
@@ -749,6 +778,7 @@ function LoadGame(_GameFile)
g_pSpriteManager.AddSprite( pSprite );
}
}
+ // @endif sprites
// Load Backgrounds
@@ -759,6 +789,7 @@ function LoadGame(_GameFile)
}
// Load Fonts
+ // @if feature("fonts")
for(index=0; index<_GameFile.Fonts.length; index++ ){
g_pFontManager.Add( _GameFile.Fonts[index]);
}
@@ -771,6 +802,7 @@ function LoadGame(_GameFile)
g_pFontManager.AddEmbedded(_GameFile.EmbeddedFonts[index]);
}
}
+ // @endif fonts
//Make Rooms
for (var index = 0; index < _GameFile.GMRooms.length; index++)
@@ -827,34 +859,43 @@ function LoadGame(_GameFile)
// Load Sounds
+ // @if feature("audio")
for(index=0; index<_GameFile.Sounds.length; index++ ){
g_pSoundManager.Add( _GameFile.Sounds[index]);
}
+ // @endif audio
// Load Timelines
+ // @if feature("timelines")
if (_GameFile.Timelines !== undefined) {
for(index=0; index<_GameFile.Timelines.length; index++ ){
g_pTimelineManager.Add( _GameFile.Timelines[index]);
}
}
+ // @endif
// Load AnimCurves
+ // @if feature("animcurves")
if (_GameFile.AnimCurves !== undefined) {
for (index = 0; index < _GameFile.AnimCurves.length; index++) {
g_pAnimCurveManager.Add(_GameFile.AnimCurves[index]);
}
}
+ // @endif
// Load Sequences
+ // @if feature("sequences")
if (_GameFile.Sequences !== undefined) {
for (index = 0; index < _GameFile.Sequences.length; index++) {
g_pSequenceManager.Add(_GameFile.Sequences[index]);
}
}
+ // @endif
// Load Particle System Emitters
+ // @if feature("particles")
if (_GameFile.PSEmitters !== undefined) {
ParticleSystem_Emitters_Load(_GameFile);
}
@@ -865,14 +906,17 @@ function LoadGame(_GameFile)
CParticleSystem.CreateFromJSON(_GameFile.ParticleSystems[index]);
}
}
+ // @endif
// Load Effect Defs
+ // @if feature("layerEffects")
if (_GameFile.FiltersAndEffectDefs !== undefined) {
for (index = 0; index < _GameFile.FiltersAndEffectDefs.length; index++) {
var def = _GameFile.FiltersAndEffectDefs[index];
g_pEffectsManager.AddEffectInfo(def.name, def.json);
}
}
+ // @endif
//Load Tags
if( Tags !== undefined && IDToTagList !== undefined ) {
@@ -895,6 +939,7 @@ function LoadGame(_GameFile)
pTGInfo.textures[i] = g_YYTextures[pStore.TextureIDs[i]]; // need to remap the texture IDs here
}
}
+ // @if feature("sprites")
if (pStore.SpriteIDs !== undefined)
{
for(var i = 0; i < pStore.SpriteIDs.length; i++)
@@ -902,6 +947,8 @@ function LoadGame(_GameFile)
pTGInfo.sprites[i] = pStore.SpriteIDs[i];
}
}
+ // @endif sprites
+ // @if feature("spine")
if (pStore.SpineSpriteIDs !== undefined)
{
for(var i = 0; i < pStore.SpineSpriteIDs.length; i++)
@@ -909,6 +956,8 @@ function LoadGame(_GameFile)
pTGInfo.spinesprites[i] = pStore.SpineSpriteIDs[i];
}
}
+ // @endif
+ // @if feature("fonts")
if (pStore.FontIDs !== undefined)
{
for(var i = 0; i < pStore.FontIDs.length; i++)
@@ -916,6 +965,7 @@ function LoadGame(_GameFile)
pTGInfo.fonts[i] = pStore.FontIDs[i];
}
}
+ // @endif fonts
if (pStore.TilesetIDs !== undefined)
{
for(var i = 0; i < pStore.TilesetIDs.length; i++)
@@ -931,8 +981,10 @@ function LoadGame(_GameFile)
}
// Load the games hiscore table
+ // @if function("draw_highscore") || function("highscore_*")
highscore_clear();
highscore_load();
+ // @endif
diff --git a/scripts/LocalStorage.js b/scripts/LocalStorage.js
index 7f0151d3..f210d3a8 100644
--- a/scripts/LocalStorage.js
+++ b/scripts/LocalStorage.js
@@ -35,25 +35,8 @@ function SupportsLocalStorage()
function GetLocalStorageRoot()
{
// Only use alpha-numeric characters, and underbars, from the display name
- var displayName = "";
- if (g_pGMFile.Options.DisplayName !== null && g_pGMFile.Options.DisplayName !== undefined) {
-
- for (var i = 0; i < g_pGMFile.Options.DisplayName.length; i++) {
-
- var chr = g_pGMFile.Options.DisplayName[i];
- if ((chr >= 'a' && chr <= 'z') ||
- (chr >= 'A' && chr <= 'Z') ||
- (chr >= '0' && chr <= '9') ||
- (chr === '_'))
- {
- displayName = displayName + g_pGMFile.Options.DisplayName[i];
- }
- }
- }
- if (displayName.length === 0) {
- displayName = "GameMaker";
- }
- return displayName + "." + g_pBuiltIn.game_id + ".";
+ let _displayName = (g_pGMFile.Options.DisplayName || "").replace(new RegExp("[^\\w]", "g"), "");
+ return (_displayName || "GameMaker") + "." + g_pBuiltIn.game_id + ".";
}
// #############################################################################################
diff --git a/scripts/SWF/yySWFBitmap.js b/scripts/SWF/yySWFBitmap.js
index c0a5b8c3..dd54237c 100644
--- a/scripts/SWF/yySWFBitmap.js
+++ b/scripts/SWF/yySWFBitmap.js
@@ -9,7 +9,7 @@
// Description:
//
// **********************************************************************************************************************
-
+// @if feature("swf")
var eBitmapType_JPEGNoHeader = 0,
eBitmapType_JPEG = 1,
eBitmapType_JPEGWithAlpha = 2,
@@ -314,4 +314,5 @@ function ReplaceTextureAlpha(_pTPE, _alpha) {
_pTPE.texture.m_Height = glTexture.Height;
return _pTPE.texture;
-}
\ No newline at end of file
+}
+// @endif
\ No newline at end of file
diff --git a/scripts/SWF/yySWFShape.js b/scripts/SWF/yySWFShape.js
index 1d3dee01..1f9db4c7 100644
--- a/scripts/SWF/yySWFShape.js
+++ b/scripts/SWF/yySWFShape.js
@@ -9,7 +9,7 @@
// Description:
//
// **********************************************************************************************************************
-
+// @if feature("swf")
var eDIType_Invalid = 0,
eDIType_Shape = 1,
eDIType_Bitmap = 2;
@@ -524,3 +524,4 @@ yySWFShape.prototype.BuildSubShapes = function (_styleGroup, _dataView, _byteOff
}
return _byteOffset;
};
+// @endif
\ No newline at end of file
diff --git a/scripts/SWF/yySWFTimeline.js b/scripts/SWF/yySWFTimeline.js
index 6c88cda4..632da32f 100644
--- a/scripts/SWF/yySWFTimeline.js
+++ b/scripts/SWF/yySWFTimeline.js
@@ -10,6 +10,7 @@
//
// **********************************************************************************************************************
+// @if feature("swf")
// convert from twips to pixels (each twip is 20 pixels)
var g_SWF_twipscale = 1.0 / 20.0;
@@ -165,4 +166,5 @@ yySWFTimeline.prototype.BuildTimelineData = function (_dataView, _byteOffset, _l
}
}
return _byteOffset;
-};
\ No newline at end of file
+};
+// @endif
\ No newline at end of file
diff --git a/scripts/Storage.js b/scripts/Storage.js
index 6abf9313..f1289273 100644
--- a/scripts/Storage.js
+++ b/scripts/Storage.js
@@ -52,6 +52,7 @@ function TPE_Copy(_pTPE)
}
+// @if feature("sprites")
/** @constructor */
function YYSprite()
{
@@ -71,6 +72,7 @@ function YYSprite()
this.yOrigin = 0;
this.TPageEntrys = []; // followed by count * (YYTPageEntry*)
}
+// @endif sprites
/** @constructor */
@@ -98,24 +100,6 @@ function YYInstancesStorage()
}
-/** @constructor */
-function YYTileStorage()
-{
- this.x = 0;
- this.y = 0;
- this.index = 0;
- this.xo = 0;
- this.yo = 0;
- this.w = 0;
- this.h = 0;
- this.depth = 0;
- this.id = 0;
- this.scaleX = 1.0;
- this.scaleY = 1.0;
- this.colour = -1;
-}
-
-
/** @constructor */
function YYViewStorage()
{
diff --git a/scripts/Unsupported.js b/scripts/Unsupported.js
index e56283e5..e21c379c 100644
--- a/scripts/Unsupported.js
+++ b/scripts/Unsupported.js
@@ -16,11 +16,6 @@
// Scripts
-function execute_string() { ErrorFunction("execute_string()");}
-function execute_file() { ErrorFunction("execute_file()");}
-function show_info() { ErrorFunction("show_info()");}
-function load_info(fname) { ErrorFunction("load_info()");}
-function script_get_text(ind) { ErrorFunction("script_get_text()"); }
function game_save(name) { ErrorFunction("game_save()"); }
function game_load(name) { ErrorFunction("game_load()"); }
function game_save_buffer(buffer) { ErrorFunction("game_save_buffer()"); }
@@ -28,49 +23,12 @@ function game_load_buffer(buffer) { ErrorFunction("game_load_buffer()"); }
// Splash screens
-function splash_show_video(fname,loop) { ErrorFunction("splash_show_video()"); }
-function splash_show_text(fname,delay) { ErrorFunction("splash_show_text()"); }
-function splash_show_image(fname,delay) { ErrorFunction("splash_show_image()"); }
-function splash_show_web(url,delay) { ErrorFunction("splash_show_web()"); }
-function splash_set_main(main) { ErrorFunction("splash_set_main()"); }
-function splash_set_scale(scale) { ErrorFunction("splash_set_scale()"); }
-function splash_set_cursor(vis) { ErrorFunction("splash_set_cursor()"); }
-function splash_set_color(col) { ErrorFunction("splash_set_color()"); }
-var splash_set_colour = splash_set_color;
-function splash_set_caption(cap) { ErrorFunction("splash_set_caption()"); }
-function splash_set_fullscreen(full) { ErrorFunction("splash_set_fullscreen()"); }
-function splash_set_border(border) { ErrorFunction("splash_set_border()"); }
-function splash_set_size(w,h) { ErrorFunction("splash_set_size()"); }
-function splash_set_position(x,y) { ErrorFunction("splash_set_position()"); }
-function splash_set_adapt(adapt) { ErrorFunction("splash_set_adapt()"); }
-function splash_set_top(top) { ErrorFunction("splash_set_top()"); }
-function splash_set_interrupt(interrupt) { ErrorFunction("splash_set_interrupt()"); }
-function splash_set_stop_key(stop) { ErrorFunction("splash_set_stop_key()"); }
-function splash_set_stop_mouse(stop) { ErrorFunction("splash_set_stop_mouse()"); }
-function splash_set_close_button(show) { ErrorFunction("splash_set_close_button()"); }
function os_set_orientation_lock() { ErrorFunction("os_set_orientation_lock()"); }
// general
-function screen_redraw() {ErrorFunction("screen_redraw()");}
-function screen_refresh() {ErrorFunction("screen_refresh()");}
-function set_automatic_draw(value) {ErrorFunction("set_automatic_draw()");}
-function set_synchronization(value) {ErrorFunction("set_synchronization()");}
-function screen_wait_vsync() {ErrorFunction("screen_wait_vsync()");}
-function window_set_region_size(w,h,adaptwindow) {ErrorFunction("window_set_region_size()");}
-function window_get_region_width() {ErrorFunction("window_get_region_width()");}
-function window_get_region_height() {ErrorFunction("window_get_region_height()");}
function screen_save(fname) {MissingFunction("screen_save()");}
function screen_save_part(fname,x,y,w,h) {MissingFunction("screen_save_part()");}
-function transition_define(kind,name) {MissingFunction("transition_define()");}
-function transition_exists(kind) {MissingFunction("transition_exists()");}
-
-function display_get_colordepth() {ErrorFunction("display_get_colordepth()");}
-function display_get_frequency() {ErrorFunction("display_get_frequency()");}
-function display_set_size(w,h) {ErrorFunction("display_set_size()");}
-function display_set_colordepth(coldepth) {ErrorFunction("display_set_colordepth()");}
-function display_set_frequency(frequency) {ErrorFunction("display_set_frequency()");}
-function display_set_all(w,h,frequency,coldepth) {ErrorFunction("display_set_all()");}
-function display_test_all(w,h,frequency,coldepth) {ErrorFunction("display_test_all()");}
+
function display_reset(AA) {ErrorFunction("display_reset()");}
function display_mouse_set(x,y) {ErrorFunction("display_mouse_set()");}
@@ -151,163 +109,22 @@ function clipboard_set_text(str) {
// --------------------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------------------
-function set_program_priority(priority) {MissingFunction("set_program_priority()");}
-
-
-
-
// IO
-function joystick_exists(id) { return false; }
-function joystick_name(id) {ErrorFunction("joystick_name()");}
-function joystick_axes(id) {ErrorFunction("joystick_axes()");}
-function joystick_buttons(id) {ErrorFunction("joystick_buttons()");}
-function joystick_has_pov(id) {ErrorFunction("joystick_has_pov()");}
-function joystick_direction(id) {ErrorFunction("joystick_direction()");}
-function joystick_check_button(id,numb) {ErrorFunction("joystick_check_button()");}
-function joystick_xpos(id) {ErrorFunction("joystick_xpos()");}
-function joystick_ypos(id) {ErrorFunction("joystick_ypos()");}
-function joystick_zpos(id) {ErrorFunction("joystick_zpos()");}
-function joystick_rpos(id) {ErrorFunction("joystick_rpos()");}
-function joystick_upos(id) {ErrorFunction("joystick_upos()");}
-function joystick_vpos(id) {ErrorFunction("joystick_vpos()");}
-function joystick_pov(id) {ErrorFunction("joystick_pov()");}
-
-function io_handle( ) {ErrorFunction("io_handle()");}
-function mouse_wait() {ErrorFunction("mouse_wait()");}
-function keyboard_wait() {ErrorFunction("keyboard_wait()");}
function keyboard_get_numlock() {ErrorFunction("keyboard_get_numlock()");}
function keyboard_set_numlock(on) {ErrorFunction("keyboard_set_numlock()");}
// Sprites. Backgrounds
-function background_save(ind,fname) {ErrorFunction("background_save()");}
function sprite_save_strip(ind,fname) {ErrorFunction("sprite_save_strip()");}
-
-// Objects
-function object_add() {ErrorFunction("object_add()");}
-function object_delete(ind) {ErrorFunction("object_delete()");}
-function object_event_add(ind,evtype,evnumb,codestr) {ErrorFunction("object_event_add()");}
-function object_event_clear(ind,evtype,evnumb) {ErrorFunction("object_event_clear()");}
-
-
-// Particles
-function part_changer_create(_ps) { ErrorFunction("part_changer_create()"); }
-function part_changer_destroy(_ps,_ind) { ErrorFunction("part_changer_destroy()"); }
-function part_changer_destroy_all(_ps) { ErrorFunction("part_changer_destroy_all()"); }
-function part_changer_exists(_ps,_ind) { ErrorFunction("part_changer_exists()"); }
-function part_changer_clear(_ps,_ind) { ErrorFunction("part_changer_clear()"); }
-function part_changer_region(_ps,_ind,_xmin,_xmax,_ymin,_ymax,_shape) { ErrorFunction("part_changer_region()"); }
-function part_changer_types(_ps,_ind,_parttype1,_parttype2) { ErrorFunction("part_changer_types()"); }
-function part_changer_kind(_ps,_ind,_kind) { ErrorFunction("part_changer_kind()"); }
-
-function part_deflector_create(ps) { ErrorFunction("part_deflector_create()"); }
-function part_deflector_destroy(ps,ind) { ErrorFunction("part_deflector_destroy()"); }
-function part_deflector_destroy_all(ps) { ErrorFunction("part_deflector_destroy_all()"); }
-function part_deflector_exists(ps,ind) { ErrorFunction("part_deflector_exists()"); }
-function part_deflector_clear(ps,ind) { ErrorFunction("part_deflector_clear()"); }
-function part_deflector_region(ps,ind,xmin,xmax,ymin,ymax) { ErrorFunction("part_deflector_region()"); }
-function part_deflector_kind(ps,ind,kind) { ErrorFunction("part_deflector_kind()"); }
-function part_deflector_friction(ps,ind,friction) { ErrorFunction("part_deflector_friction()"); }
-
-function part_destroyer_create(ps) { ErrorFunction("part_destroyer_create()"); }
-function part_destroyer_destroy(ps,ind) { ErrorFunction("part_destroyer_destroy()"); }
-function part_destroyer_destroy_all(ps) { ErrorFunction("part_destroyer_destroy_all()"); }
-function part_destroyer_exists(ps,ind) { ErrorFunction("part_destroyer_exists()"); }
-function part_destroyer_clear(ps,ind) { ErrorFunction("part_destroyer_clear()"); }
-function part_destroyer_region(ps,ind,xmin,xmax,ymin,ymax,shape) { ErrorFunction("part_destroyer_region()"); }
-
-function part_attractor_create(ps) { ErrorFunction("part_attractor_create()"); }
-function part_attractor_destroy(ps,ind) { ErrorFunction("part_attractor_destroy()"); }
-function part_attractor_destroy_all(ps) { ErrorFunction("part_attractor_destroy_all()"); }
-function part_attractor_exists(ps,ind) { ErrorFunction("part_attractor_exists()"); }
-function part_attractor_clear(ps,ind) { ErrorFunction("part_attractor_clear()"); }
-function part_attractor_position(ps,ind,x,y) { ErrorFunction("part_attractor_position()"); }
-function part_attractor_force(ps,ind,force,dist,kind,aditive) { ErrorFunction("part_attractor_force()"); }
-
-
-
-// executing programs
-function execute_program(prog,arg,wait) { ErrorFunction("execute_program()"); }
-function execute_shell(prog,arg) { ErrorFunction("execute_shell()"); }
-var secure_mode = true;
-
-
-// Registry
-function registry_write_string(name,str) { ErrorFunction("registry_write_string()"); }
-function registry_write_real(name,x) { ErrorFunction("registry_write_real()"); }
-function registry_read_string(name) { ErrorFunction("registry_read_string()"); }
-function registry_read_real(name) { ErrorFunction("registry_read_real()"); }
-function registry_exists(name) { ErrorFunction("registry_exists()"); }
-function registry_write_string_ext(key,name,str) { ErrorFunction("registry_write_string_ext()"); }
-function registry_write_real_ext(key,name,x) { ErrorFunction("registry_write_real_ext()"); }
-function registry_read_string_ext(key,name) { ErrorFunction("registry_read_string_ext()"); }
-function registry_read_real_ext(key,name) { ErrorFunction("registry_read_real_ext()"); }
-function registry_exists_ext(key,name) { ErrorFunction("registry_exists_ext()"); }
-function registry_set_root(root) { ErrorFunction("registry_set_root()"); }
-
-
// Message boxes/dialogs etc.
-function message_text_font(_name,_size,_color,_style) {ErrorFunction("message_text_font()");}
-function message_button(_spr) {ErrorFunction("message_button()");}
-function message_button_font(_name,_size,_color,_style) {ErrorFunction("message_button_font()");}
-function message_input_font(_name, _size, _color, _style) {ErrorFunction("message_input_font()");}
-function message_text_charset() { ErrorFunction("message_text_charset()"); }
-function message_mouse_color(col) { ErrorFunction("message_mouse_color()"); }
-function message_input_color(col) { ErrorFunction("message_input_color()"); }
-function message_caption(show, str) { ErrorFunction("message_caption()"); }
-function message_position(x, y) { ErrorFunction("message_position()"); }
-function message_size(w, h) { ErrorFunction("message_size()"); }
-function show_menu(str, def) { ErrorFunction("show_menu()"); }
-function show_menu_pos(x, y, str, def) { ErrorFunction("show_menu_pos()"); }
-function get_color(defcol) { ErrorFunction("get_color()"); }
function get_open_filename(filter, fname) { ErrorFunction("get_open_filename()"); }
function get_save_filename(filter, fname) { ErrorFunction("get_save_filename()"); }
function get_open_filename_ext(filter, fname, dir, title) { ErrorFunction("get_open_filename_ext()"); }
function get_save_filename_ext(filter, fname, dir, title) { ErrorFunction("get_save_filename_ext()"); }
-function get_directory(dname) { ErrorFunction("get_directory()"); }
-function get_directory_alt(capt, root) { ErrorFunction("get_directory_alt()"); }
-//function show_error(str, abort) { ErrorFunction("show_error()"); }
// sound
-function sound_3d_set_sound_position(snd,x,y,z) { ErrorFunction("sound_3d_set_sound_position()"); }
-function sound_3d_set_sound_velocity(snd,x,y,z) { ErrorFunction("sound_3d_set_sound_velocity()"); }
-function sound_3d_set_sound_distance(snd,mindist,maxdist) { ErrorFunction("sound_3d_set_sound_distance()"); }
-function sound_3d_set_sound_cone(snd,x,y,z,anglein,angleout,voloutside) { ErrorFunction("sound_3d_set_sound_cone()"); }
-function sound_background_tempo(factor) { ErrorFunction("sound_background_tempo()"); }
-function sound_pan(index,value) { ErrorFunction("sound_pan()"); }
-function sound_set_search_directory(dir) { ErrorFunction("sound_set_search_directory()"); }
-function sound_effect_set(snd,effect) { ErrorFunction("sound_effect_set()"); }
-function sound_effect_chorus(snd,wetdry,depth,feedback,frequency,wave,delay,phase) { ErrorFunction("sound_effect_chorus()"); }
-function sound_effect_echo(snd,wetdry,feedback,leftdelay,rightdelay,pandelay) { ErrorFunction("sound_effect_echo()"); }
-function sound_effect_flanger(snd,wetdry,depth,feedback,frequency,wave,delay,phase) { ErrorFunction("sound_effect_flanger()"); }
-function sound_effect_gargle(snd,rate,wave) { ErrorFunction("sound_effect_gargle()"); }
-function sound_effect_reverb(snd,gain,mix,time,ratio) { ErrorFunction("sound_effect_reverb()"); }
-function sound_effect_compressor(snd,gain,attack,release,threshold,ratio,delay) { ErrorFunction("sound_effect_compressor()"); }
-function sound_effect_equalizer(snd,center,bandwidth,gain) { ErrorFunction("sound_effect_equalizer()"); }
-function sound_discard(index) { ErrorFunction("sound_discard()"); }
-function sound_restore(index) { ErrorFunction("sound_restore()"); }
-function sound_get_preload(index) { ErrorFunction("sound_get_preload()"); }
-
-function cd_init() { ErrorFunction("cd_init()"); }
-function cd_present() { ErrorFunction("cd_present()"); }
-function cd_number() { ErrorFunction("cd_number()"); }
-function cd_playing() { ErrorFunction("cd_playing()"); }
-function cd_paused() { ErrorFunction("cd_paused()"); }
-function cd_track() { ErrorFunction("cd_track()"); }
-function cd_length() { ErrorFunction("cd_length()"); }
-function cd_track_length(n) { ErrorFunction("cd_track_length()"); }
-function cd_position() { ErrorFunction("cd_position()"); }
-function cd_track_position() { ErrorFunction("cd_track_position()"); }
-function cd_play(first,last) { ErrorFunction("cd_play()"); }
-function cd_stop() { ErrorFunction("cd_stop()"); }
-function cd_pause() { ErrorFunction("cd_pause()"); }
-function cd_resume() { ErrorFunction("cd_resume()"); }
-function cd_set_position(pos) { ErrorFunction("cd_set_position()"); }
-function cd_set_track_position(pos) { ErrorFunction("cd_set_track_position()"); }
-function cd_open_door() { ErrorFunction("cd_open_door()"); }
-function cd_close_door() { ErrorFunction("cd_close_door()"); }
function MCI_command(str) { ErrorFunction("MCI_command()"); }
function texture_preload(texid) { ErrorFunction("texture_preload()"); }
@@ -323,113 +140,6 @@ function texture_set_interpolation_ext(stage, linear) { ErrorFunction("textur
function texture_get_uvs(_tex) { ErrorFunction("texture_get_uvs()"); }
function texture_global_scale(pow2integer) { ErrorFunction("texture_global_scale()"); }
-
-function file_open_read() { ErrorFunction("file_open_read()"); }
-function file_open_write() { ErrorFunction("file_open_write()"); }
-function file_open_append() { ErrorFunction("file_open_append()"); }
-function file_read_real() { ErrorFunction("file_read_real()"); }
-function file_read_string() { ErrorFunction("file_read_string()"); }
-function file_readln() { ErrorFunction("file_readln()"); }
-function file_write_real() { ErrorFunction("file_write_real()"); }
-function file_write_string() { ErrorFunction("file_write_string()"); }
-function file_writeln() { ErrorFunction("file_writeln()"); }
-function file_eof() { ErrorFunction("file_eof()"); }
-function file_eoln() { ErrorFunction("file_eoln()"); }
-function file_close() { ErrorFunction("file_close()"); }
-
-//steam functions
-function steam_activate_overlay() { ErrorFunction("steam_activate_overlay()"); return -1; }
-function steam_is_overlay_enabled() { ErrorFunction("steam_is_overlay_enabled()"); return -1; }
-function steam_is_overlay_activated() { ErrorFunction("steam_is_overlay_activated()"); return -1; }
-function steam_get_persona_name() { ErrorFunction("steam_get_persona_name()"); return "";}
-function steam_initialised() { ErrorFunction("steam_initialised()"); return -1; }
-function steam_is_cloud_enabled_for_app() { ErrorFunction("steam_is_cloud_enabled_for_app()"); return -1; }
-function steam_is_cloud_enabled_for_account() { ErrorFunction("steam_is_cloud_enabled_for_account()"); return -1; }
-function steam_file_persisted() { ErrorFunction("steam_file_persisted()"); return -1; }
-function steam_get_quota_total() { ErrorFunction("steam_get_quota_total()"); return -1;}
-function steam_get_quota_free() { ErrorFunction("steam_get_quota_free()"); return -1;}
-function steam_file_write() { ErrorFunction("steam_file_write()"); return -1;}
-function steam_file_write_file() { ErrorFunction("steam_file_write_file()"); return -1;}
-function steam_file_read() { ErrorFunction("steam_file_read()"); return "";}
-function steam_file_delete() { ErrorFunction("steam_file_delete()"); return -1;}
-function steam_file_exists() { ErrorFunction("steam_file_exists()"); return -1; }
-function steam_file_size() { ErrorFunction("steam_file_size()"); return -1; }
-function steam_file_share() { ErrorFunction("steam_file_share()"); return -1; }
-function steam_publish_workshop_file() { ErrorFunction("steam_publish_workshop_file()"); return -1; }
-function steam_is_screenshot_requested() { ErrorFunction("steam_is_screenshot_requested()"); return -1; }
-function steam_send_screenshot() { ErrorFunction("steam_send_screenshot()"); return -1; }
-function steam_is_user_logged_on() { ErrorFunction("steam_is_user_logged_on()"); return -1; }
-function steam_get_user_steam_id() { ErrorFunction("steam_get_user_steam_id()"); return -1; }
-function steam_user_owns_dlc() { ErrorFunction("steam_user_owns_dlc()"); return -1; }
-function steam_user_installed_dlc() { ErrorFunction("steam_user_installed_dlc()"); return -1; }
-function steam_set_achievement() { ErrorFunction("steam_set_achievement()"); return -1; }
-function steam_get_achievement() { ErrorFunction("steam_get_achievement()"); return -1; }
-function steam_clear_achievement() { ErrorFunction("steam_clear_achievement()"); return -1; }
-function steam_set_stat_int() { ErrorFunction("steam_set_stat_int()"); return -1; }
-function steam_set_stat_float() { ErrorFunction("steam_set_stat_float()"); return -1; }
-function steam_set_stat_avg_rate() { ErrorFunction("steam_set_stat_avg_rate()"); return -1; }
-function steam_get_stat_int() { ErrorFunction("steam_get_stat_int()"); return -1; }
-function steam_get_stat_float() { ErrorFunction("steam_get_stat_float()"); return -1; }
-function steam_get_stat_avg_rate() { ErrorFunction("steam_get_stat_avg_rate()"); return -1; }
-function steam_reset_all_stats() { ErrorFunction("steam_reset_all_stats()"); return -1; }
-function steam_reset_all_stats_achievements() { ErrorFunction("steam_reset_all_stats_achievements()"); return -1; }
-function steam_stats_ready() { ErrorFunction("steam_stats_ready()"); return -1; }
-function steam_create_leaderboard() { ErrorFunction("steam_create_leaderboard()"); return -1; }
-function steam_upload_score() { ErrorFunction("steam_upload_score()"); return -1; }
-function steam_upload_score_ext() { ErrorFunction("steam_upload_score_ext()"); return -1; }
-function steam_download_scores_around_user() { ErrorFunction("steam_download_scores_around_user()"); return -1; }
-function steam_download_scores() { ErrorFunction("steam_download_scores()"); return -1; }
-function steam_download_friends_scores() { ErrorFunction("steam_download_friends_scores()"); return -1; }
-function steam_upload_score_buffer() { ErrorFunction("steam_upload_score_buffer()"); return -1; }
-function steam_upload_score_buffer_ext() { ErrorFunction("steam_upload_score_buffer_ext()"); return -1; }
-function steam_activate_overlay_browser() { ErrorFunction("steam_activate_overlay_browser()"); return -1; }
-function steam_activate_overlay_user() { ErrorFunction("steam_activate_overlay_user()"); return -1; }
-function steam_activate_overlay_store() { ErrorFunction("steam_activate_overlay_store()"); return -1; }
-function steam_get_user_persona_name() { ErrorFunction("steam_get_user_persona_name()"); return -1; }
-
-
-//steam ugc functions
-function steam_get_app_id() { ErrorFunction("steam_get_app_id()"); return -1; }
-function steam_get_user_account_id() { ErrorFunction("steam_get_user_account_id()"); return -1; }
-function steam_ugc_download() { ErrorFunction("steam_ugc_download()"); return -1; }
-function steam_ugc_create_item() { ErrorFunction("steam_ugc_create_item()"); return -1; }
-function steam_ugc_start_item_update() { ErrorFunction("steam_ugc_start_item_update()"); return -1; }
-function steam_ugc_set_item_title() { ErrorFunction("steam_ugc_set_item_title()"); return -1; }
-function steam_ugc_set_item_description() { ErrorFunction("steam_ugc_set_item_description()"); return -1; }
-function steam_ugc_set_item_visibility() { ErrorFunction("steam_ugc_set_item_visibility()"); return -1; }
-function steam_ugc_set_item_tags() { ErrorFunction("steam_ugc_set_item_tags()"); return -1; }
-function steam_ugc_set_item_content() { ErrorFunction("steam_ugc_set_item_content()"); return -1; }
-function steam_ugc_set_item_preview() { ErrorFunction("steam_ugc_set_item_preview()"); return -1; }
-function steam_ugc_submit_item_update() { ErrorFunction("steam_ugc_submit_item_update()"); return -1; }
-function steam_ugc_get_item_update_progress() { ErrorFunction("steam_ugc_get_item_update_progress()"); return -1; }
-function steam_ugc_subscribe_item() { ErrorFunction("steam_ugc_subscribe_item()"); return -1; }
-function steam_ugc_unsubscribe_item() { ErrorFunction("steam_ugc_unsubscribe_item()"); return -1; }
-function steam_ugc_num_subscribed_items() { ErrorFunction("steam_ugc_num_subscribed_items()"); return -1; }
-function steam_ugc_get_subscribed_items() { ErrorFunction("steam_ugc_get_subscribed_items()"); return -1; }
-function steam_ugc_get_item_install_info() { ErrorFunction("steam_ugc_get_item_install_info()"); return -1; }
-function steam_ugc_get_item_update_info() { ErrorFunction("steam_ugc_get_item_update_info()"); return -1; }
-function steam_ugc_request_item_details() { ErrorFunction("steam_ugc_request_item_details()"); return -1; }
-function steam_ugc_create_query_user() { ErrorFunction("steam_ugc_create_query_user()"); return -1; }
-function steam_ugc_create_query_user_ex() { ErrorFunction("steam_ugc_create_query_user_ex()"); return -1; }
-function steam_ugc_create_query_all() { ErrorFunction("steam_ugc_create_query_all()"); return -1; }
-function steam_ugc_create_query_all_ex() { ErrorFunction("steam_ugc_create_query_all_ex()"); return -1; }
-function steam_ugc_query_set_cloud_filename_filter() { ErrorFunction("steam_ugc_query_set_cloud_filename_filter()"); return -1; }
-function steam_ugc_query_set_match_any_tag() { ErrorFunction("steam_ugc_query_set_match_any_tag()"); return -1; }
-function steam_ugc_query_set_search_text() { ErrorFunction("steam_ugc_query_set_search_text()"); return -1; }
-function steam_ugc_query_set_ranked_by_trend_days() { ErrorFunction("steam_ugc_query_set_ranked_by_trend_days()"); return -1; }
-function steam_ugc_query_add_required_tag() { ErrorFunction("steam_ugc_query_add_required_tag()"); return -1; }
-function steam_ugc_query_add_excluded_tag() { ErrorFunction("steam_ugc_query_add_excluded_tag()"); return -1; }
-function steam_ugc_query_set_return_long_description() { ErrorFunction("steam_ugc_query_set_return_long_description()"); return -1; }
-function steam_ugc_query_set_return_total_only() { ErrorFunction("steam_ugc_query_set_return_total_only()"); return -1; }
-function steam_ugc_query_set_allow_cached_response() { ErrorFunction("steam_ugc_query_set_allow_cached_response()"); return -1; }
-function steam_ugc_send_query(ugc_query_handle) { ErrorFunction("steam_ugc_send_query( ugc_query_handle )"); return -1; }
-function steam_current_game_language() { ErrorFunction("steam_current_game_language()"); return -1; }
-function steam_available_languages() { ErrorFunction("steam_available_languages()"); return -1; }
-
-
-
-
-
function draw_set_alpha_test() { ErrorFunction("draw_set_alpha_test()"); }
function draw_set_alpha_test_ref_value() { ErrorFunction("draw_set_alpha_test_ref_value()"); }
function draw_get_alpha_test() { ErrorFunction("draw_get_alpha_test()"); return 0; }
diff --git a/scripts/_GameMaker.js b/scripts/_GameMaker.js
index a86b92ea..27d09bcd 100644
--- a/scripts/_GameMaker.js
+++ b/scripts/_GameMaker.js
@@ -209,6 +209,7 @@ window.addEventListener( "unhandledrejection", yyUnhandledRejectionHandler );
//external access for js extensions
+// @if feature("extension_api")
var GMS_API = {
"debug_msg": show_debug_message,
"ds_list_size": ds_list_size,
@@ -220,6 +221,7 @@ var GMS_API = {
"get_facebook_app_id": YYGetFacebookAppId,
"get_app_version_string": YYGetAppVersionString
};
+// @endif
function YYGetFacebookAppId() {
return g_pGMFile.Options.Facebook;
@@ -297,6 +299,7 @@ function ToggleDebugPause() {
///
///
// #############################################################################################
+// @if feature("debug")
function CreateDebugConsole() {
try
@@ -356,6 +359,7 @@ function CreateDebugConsole() {
debug(e.message);
}
}
+// @endif
@@ -562,8 +566,10 @@ function GameMaker_Init()
graphics = null;
if( !canvas) return;
+ // @if function("parameter_*")
ParseURL( window.location );
- g_pGMFile = JSON_game;
+ // @endif
+ g_pGMFile = JSON_game;
// initialise the map of obfuscated names to var
if (typeof g_var2obf !== "undefined") {
@@ -638,9 +644,11 @@ function GameMaker_Init()
g_LastCanvasWidth = canvas.width;
g_LastCanvasHeight = canvas.height;
+ // @if feature("audio")
if ((g_pGMFile.Options.UseNewAudio == true) || g_isZeus) {
g_AudioModel = Audio_WebAudio;
}
+ // @endif audio
@@ -678,10 +686,12 @@ function GameMaker_Init()
console.log("using internal runtime facebook");
YoYoFBInit(g_pGMFile.Options.Facebook);
}
+ // @if feature("debug")
else if (g_pGMFile.Options && g_pGMFile.Options.debugMode)
{
CreateDebugConsole();
}
+ // @endif
// Remember these settings, as FULLSCREEN will mess them up.
RememberCanvasSettings();
@@ -812,7 +822,9 @@ function animate() {
case -2:
{
if (g_LoadingCanvasCreated) DeleteLoadingCanvas();
+ // @if feature("gl")
yyWebGLRequiredError(graphics, DISPLAY_WIDTH, DISPLAY_HEIGHT);
+ // @endif gl
break;
}
@@ -1130,15 +1142,23 @@ function StartRoom( _numb, _starting )
// This must be set before performing the room_end event else the event will be blocked
New_Room = -1;
+ // @if feature("particles") && function("effect_")
effect_clear();
-
+ // @endif
+
+ // @if feature("layerEffects")
g_pEffectsManager.ExecuteEffectEventsForRoom(EFFECT_ROOM_END_FUNC, g_RunRoom);
+ // @endif
g_pInstanceManager.PerformEvent(EVENT_OTHER_ENDROOM, 0);
+ // @if feature("particles")
ParticleSystem_RemoveAllFromLayers();
+ // @endif
+ // @if function("virtual_key_*")
DeleteAllVirtualKeys();
+ // @endif
// Extract all persistent instances from the room currently in use.
// NB: This is done first since clearing the rooms m_Active list means that if
@@ -1203,7 +1223,9 @@ function StartRoom( _numb, _starting )
// Some global initialization
//g_pIOManager.Clear();
+ /// @if feature("gamepad")
g_pGamepadManager.Clear();
+ /// @endif
// Kill all particles currently in flight
//ParticleSystem_ClearParticles(); // don't do this, to match C++ runner
@@ -1268,20 +1290,26 @@ function StartRoom( _numb, _starting )
CreateRoomBackgrounds( g_RunRoom );
// Initialise effects
+ // @if feature("layerEffects")
g_pEffectsManager.Init();
+ // @endif
// Set up runtime data for this room's layers
if(g_pLayerManager!=null)
g_pLayerManager.BuildRoomLayerRuntimeData(g_RunRoom);
+ // @if feature("particles")
ParticleSystem_AddAllToLayers();
+ // @endif
// If this room is NOT persistent then we need to recreate all instances EXCEPT those that already exist in the persistent list
// Any instance created in here will perform the create event... including "new" PERSISTENT instances
if (ispersistent === false)
{
// Build the physics world for this room if not persistent and one is required
+ // @if feature("physics")
g_RunRoom.BuildPhysicsWorld();
+ // @endif
// Loop through all instances in the storage of the room and create the ones NOT in the persistent list...
g_RunRoom.ClearInstances(false);
@@ -1356,7 +1384,9 @@ function StartRoom( _numb, _starting )
for (var u=0; u < persistent.length; u++)
{
g_RunRoom.m_Active.Add(persistent[u]);
+ // @if feature("physics")
persistent[u].RebuildPhysicsBody();
+ // @endif
// Add persistent object to layer system
if (g_isZeus)
@@ -1413,7 +1443,9 @@ function StartRoom( _numb, _starting )
}
g_pInstanceManager.PerformEvent(EVENT_OTHER_STARTROOM,0);
+ // @if feature("layerEffects")
g_pEffectsManager.ExecuteEffectEventsForRoom(EFFECT_ROOM_START_FUNC, g_RunRoom);
+ // @endif
g_RunRoom.m_Initialised = true;
@@ -1466,11 +1498,13 @@ function StartGame()
g_pBuiltIn.fps = Fps;
g_pBuiltIn.fps_real = Fps;
+ // @if feature("audio")
if(g_AudioModel == Audio_WebAudio)
{
// Audio: Report current device status to the newly created room
Audio_EngineReportState();
}
+ // @endif audio
}
// #############################################################################################
@@ -1529,13 +1563,15 @@ function Run_EndGame(_reset) {
}
g_pInstanceManager.Clear();
- if (_reset) {
+ // @if feature("audio")
+ if (_reset) {
// Just stops all audio instances.
audio_stop_all();
} else {
// Destroys the AudioContext instance.
Audio_Quit();
}
+ // @endif audio
}
@@ -1577,7 +1613,7 @@ function UpdateActiveLists() {
///
// #############################################################################################
function UpdateInstancePositions() {
-
+ // @if feature("physics")
if (g_RunRoom.m_pPhysicsWorld) {
if(g_isZeus)
{
@@ -1586,9 +1622,9 @@ function UpdateInstancePositions() {
else
g_RunRoom.m_pPhysicsWorld.Update(g_RunRoom.m_speed);
}
- else {
- g_pInstanceManager.UpdatePositions();
- }
+ else // ->
+ // @endif
+ g_pInstanceManager.UpdatePositions();
}
// #############################################################################################
@@ -1613,12 +1649,16 @@ function GameMaker_DoAStep() {
g_pBuiltIn.delta_time = (g_CurrentTime - g_pBuiltIn.last_time)*1000;
g_pBuiltIn.last_time = g_CurrentTime;
+ // @if feature("sequences_min")
ResetSpriteMessageEvents();
+ // @endif sequences_min
g_pIOManager.StartStep();
HandleOSEvents();
+ /// @if feature("gamepad")
g_pGamepadManager.Update();
+ /// @endif
g_pInstanceManager.RememberOldPositions(); // Remember old positions
g_pInstanceManager.UpdateImages();
@@ -1628,7 +1668,9 @@ function GameMaker_DoAStep() {
g_pLayerManager.UpdateLayers();
// Handle events that must react to the old position
+ // @if feature("sequences")
g_pSequenceManager.PerformInstanceEvents(g_RunRoom, EVENT_STEP_BEGIN);
+ // @endif
g_pInstanceManager.PerformEvent(EVENT_STEP_BEGIN, 0);
UpdateActiveLists();
if (New_Room != -1) return;
@@ -1657,7 +1699,9 @@ function GameMaker_DoAStep() {
UpdateActiveLists();
if (New_Room != -1) return;
- HandleKeyboard();
+ // @if feature("keyboard")
+ HandleKeyboard();
+ // @endif
UpdateActiveLists();
if (New_Room != -1) return;
@@ -1667,15 +1711,21 @@ function GameMaker_DoAStep() {
HandleMouse();
UpdateActiveLists();
if (New_Room != -1) return;
-
+
+ // @if feature("layerEffects")
g_pEffectsManager.StepEffectsForRoom(g_RunRoom);
+ // @endif
+ // @if feature("sequences")
g_pSequenceManager.UpdateInstancesForRoom(g_RunRoom); // update this at the same time as the step event
g_pSequenceManager.PerformInstanceEvents(g_RunRoom, EVENT_STEP_NORMAL);
+ // @endif
g_pInstanceManager.PerformEvent(EVENT_STEP_NORMAL, 0); //HandleStep(EVENT_STEP_END);
UpdateActiveLists();
if (New_Room != -1) return;
+ // @if feature("sequences_min")
ProcessSpriteMessageEvents();
+ // @endif sequences_min
UpdateInstancePositions();
@@ -1693,13 +1743,17 @@ function GameMaker_DoAStep() {
UpdateActiveLists();
if (New_Room != -1) return;
- g_pSequenceManager.PerformInstanceEvents(g_RunRoom, EVENT_STEP_END);
+ // @if feature("sequences")
+ g_pSequenceManager.PerformInstanceEvents(g_RunRoom, EVENT_STEP_END);
+ // @endif
g_pInstanceManager.PerformEvent(EVENT_STEP_END, 0); //HandleStep(EVENT_STEP_END);
UpdateActiveLists();
if (New_Room != -1) return;
// Handle the particle systems
+ // @if feature("particles")
ParticleSystem_UpdateAll();
+ // @endif
// Bookkeeping && drawing
@@ -1722,7 +1776,9 @@ function GameMaker_DoAStep() {
RenderSystemOverlays();
- audio_update();
+ // @if feature("audio")
+ audio_update();
+ // @endif audio
}
@@ -2032,22 +2088,6 @@ function IntToHex(_val)
}
return s;
}
-function YYUDID()
-{
- //Needs to return a udid for the machine we are running on
-
- var fingerprint = new Fingerprint().get();
-
-
- return fingerprint;
-
- // return "e2770c0a-928f-4985-b331-cf6e2c3c56b5";
-}
-// #############################################################################################
-/// Function:
-/// Process HTML5 "pingback"
-///
-// #############################################################################################
function StringToArray8(str)
{
@@ -2211,17 +2251,8 @@ function GameMaker_Tick()
}
//
- var TargetSpeed;
- if (g_isZeus) {
- g_GameTimer.Update();
- TargetSpeed = g_GameTimer.GetFPS();
- } else {
- TargetSpeed = g_RunRoom.GetSpeed();
- if (TargetSpeed <= 0) {
- TargetSpeed = 1;
- g_RunRoom.SetSpeed(1);
- }
- }
+ g_GameTimer.Update();
+ var TargetSpeed = g_GameTimer.GetFPS();
const last_time_ms = g_CurrentTime;
g_CurrentTime = Date.now();
@@ -2340,7 +2371,9 @@ function GameMaker_Tick()
}
// if in DEBUG mode, do debug "stuff"
+ // @if feature("debug")
if (g_pGMFile.Options && g_pGMFile.Options.debugMode) {
UpdateDebugWindow();
}
+ // @endif
}
diff --git a/scripts/animation/yySkeletonInstance.js b/scripts/animation/yySkeletonInstance.js
index 92f32735..ab49c5b3 100644
--- a/scripts/animation/yySkeletonInstance.js
+++ b/scripts/animation/yySkeletonInstance.js
@@ -10,6 +10,7 @@
//
// **********************************************************************************************************************
+// @if feature("spine")
// #############################################################################################
/// Function:
/// Initialise storage for the instance specific portion of a Skeleton animation
@@ -153,6 +154,8 @@ yySkeletonInstance.prototype.FrameCount = function (_sprite, _track) {
return ~~((updatesCount * this.m_animationState.tracks[_track].animation.duration) + 0.5);
};
+// @endif
+
function fwrap(_val, _div)
{
// _div needs to be positive
@@ -166,6 +169,8 @@ function fwrap(_val, _div)
return scaledfrac;
}
+// @if feature("spine")
+
// #############################################################################################
/// Function:
/// Get the index of the animation on the specified track
@@ -1562,3 +1567,4 @@ yySkeletonInstance.prototype.GetSlotData = function (_list)
ds_list_add(_list, map);
}
};
+// @endif spine
diff --git a/scripts/animation/yySkeletonSkin.js b/scripts/animation/yySkeletonSkin.js
index 1a7e57f7..697d8f30 100644
--- a/scripts/animation/yySkeletonSkin.js
+++ b/scripts/animation/yySkeletonSkin.js
@@ -15,9 +15,11 @@
/// Create a new SkeletonSkin object
///
// #############################################################################################
+// @if feature("spine")
/** @constructor */
function yySkeletonSkin(_skin)
{
this.__type = "[SkeletonSkin]";
this.m_skin = _skin;
}
+// @endif
diff --git a/scripts/animation/yySkeletonSprite.js b/scripts/animation/yySkeletonSprite.js
index 9b43c647..a5237fa0 100644
--- a/scripts/animation/yySkeletonSprite.js
+++ b/scripts/animation/yySkeletonSprite.js
@@ -36,7 +36,7 @@ var REGIONATTACHMENT_OY4 = 7;
function SetSkeletonDrawInstance(_instance) {
g_skeletonDrawInstance = _instance;
};
-
+// @if feature("spine")
function yyImageProxy()
{
this.width = null;
@@ -1830,3 +1830,4 @@ yySkeletonSprite.prototype.GetAttachmentsForSlot = function(_slotName)
return attachmentNames;
};
+// @endif spine
\ No newline at end of file
diff --git a/scripts/device/Gamepad.js b/scripts/device/Gamepad.js
index 4cf961bb..1f1a59af 100644
--- a/scripts/device/Gamepad.js
+++ b/scripts/device/Gamepad.js
@@ -7,6 +7,7 @@
// Project: HTML5
// Description: GameMaker HTML5 gamepad interface.
// **********************************************************************************************************************
+/// @if feature("gamepad")
var g_pGamepadManager = null;
var g_GamePadDeadZones = [];
@@ -685,3 +686,4 @@ function yyGamepadManager() {
return 0;
};
};
+/// @endif
\ No newline at end of file
diff --git a/scripts/fingerprintjs/fingerprint.js b/scripts/fingerprintjs/fingerprint.js
index bd1dff15..e69de29b 100644
--- a/scripts/fingerprintjs/fingerprint.js
+++ b/scripts/fingerprintjs/fingerprint.js
@@ -1,285 +0,0 @@
-/*
-* fingerprintJS 0.5.4 - Fast browser fingerprint library
-* https://github.com/Valve/fingerprintjs
-* Copyright (c) 2013 Valentin Vasilyev (valentin.vasilyev@outlook.com)
-* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-;(function (name, context, definition) {
- if (typeof module !== 'undefined' && module.exports) { module.exports = definition(); }
- else if (typeof define === 'function' && define.amd) { define(definition); }
- else { context[name] = definition(); }
-})('Fingerprint', this, function () {
- 'use strict';
-
- var Fingerprint = function (options) {
- var nativeForEach, nativeMap;
- nativeForEach = Array.prototype.forEach;
- nativeMap = Array.prototype.map;
-
- this.each = function (obj, iterator, context) {
- if (obj === null) {
- return;
- }
- if (nativeForEach && obj.forEach === nativeForEach) {
- obj.forEach(iterator, context);
- } else if (obj.length === +obj.length) {
- for (var i = 0, l = obj.length; i < l; i++) {
- if (iterator.call(context, obj[i], i, obj) === {}) return;
- }
- } else {
- for (var key in obj) {
- if (obj.hasOwnProperty(key)) {
- if (iterator.call(context, obj[key], key, obj) === {}) return;
- }
- }
- }
- };
-
- this.map = function(obj, iterator, context) {
- var results = [];
- // Not using strict equality so that this acts as a
- // shortcut to checking for `null` and `undefined`.
- if (obj == null) return results;
- if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
- this.each(obj, function(value, index, list) {
- results[results.length] = iterator.call(context, value, index, list);
- });
- return results;
- };
-
- if (typeof options == 'object'){
- this.hasher = options.hasher;
- this.screen_resolution = options.screen_resolution;
- this.screen_orientation = options.screen_orientation;
- this.canvas = options.canvas;
- this.ie_activex = options.ie_activex;
- } else if(typeof options == 'function'){
- this.hasher = options;
- }
- };
-
- Fingerprint.prototype = {
- get: function(){
- var keys = [];
- keys.push(navigator.userAgent);
- keys.push(navigator.language);
- keys.push(screen.colorDepth);
- if (this.screen_resolution) {
- var resolution = this.getScreenResolution();
- if (typeof resolution !== 'undefined'){ // headless browsers, such as phantomjs
- keys.push(resolution.join('x'));
- }
- }
- keys.push(new Date().getTimezoneOffset());
- keys.push(this.hasSessionStorage());
- keys.push(this.hasLocalStorage());
- keys.push(!!window.indexedDB);
- //body might not be defined at this point or removed programmatically
- if(document.body){
- keys.push(typeof(document.body.addBehavior));
- } else {
- keys.push(typeof undefined);
- }
- keys.push(typeof(window.openDatabase));
- keys.push(navigator.cpuClass);
- keys.push(navigator.platform);
- keys.push(navigator.doNotTrack);
- keys.push(this.getPluginsString());
- if(this.canvas && this.isCanvasSupported()){
- keys.push(this.getCanvasFingerprint());
- }
- if(this.hasher){
- return this.hasher(keys.join('###'), 31);
- } else {
- return this.murmurhash3_32_gc(keys.join('###'), 31);
- }
- },
-
- /**
- * JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)
- *
- * @author Gary Court
- * @see http://github.com/garycourt/murmurhash-js
- * @author Austin Appleby
- * @see http://sites.google.com/site/murmurhash/
- *
- * @param {string} key ASCII only
- * @param {number} seed Positive integer only
- * @return {number} 32-bit positive integer hash
- */
-
- murmurhash3_32_gc: function(key, seed) {
- var remainder, bytes, h1, h1b, c1, c2, k1, i;
-
- remainder = key.length & 3; // key.length % 4
- bytes = key.length - remainder;
- h1 = seed;
- c1 = 0xcc9e2d51;
- c2 = 0x1b873593;
- i = 0;
-
- while (i < bytes) {
- k1 =
- ((key.charCodeAt(i) & 0xff)) |
- ((key.charCodeAt(++i) & 0xff) << 8) |
- ((key.charCodeAt(++i) & 0xff) << 16) |
- ((key.charCodeAt(++i) & 0xff) << 24);
- ++i;
-
- k1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff;
- k1 = (k1 << 15) | (k1 >>> 17);
- k1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff;
-
- h1 ^= k1;
- h1 = (h1 << 13) | (h1 >>> 19);
- h1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff;
- h1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16));
- }
-
- k1 = 0;
-
- switch (remainder) {
- case 3: k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16;
- case 2: k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8;
- case 1: k1 ^= (key.charCodeAt(i) & 0xff);
-
- k1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff;
- k1 = (k1 << 15) | (k1 >>> 17);
- k1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff;
- h1 ^= k1;
- }
-
- h1 ^= key.length;
-
- h1 ^= h1 >>> 16;
- h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff;
- h1 ^= h1 >>> 13;
- h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;
- h1 ^= h1 >>> 16;
-
- return h1 >>> 0;
- },
-
- // https://bugzilla.mozilla.org/show_bug.cgi?id=781447
- hasLocalStorage: function () {
- try{
- return !!window.localStorage;
- } catch(e) {
- return true; // SecurityError when referencing it means it exists
- }
- },
-
- hasSessionStorage: function () {
- try{
- return !!window.sessionStorage;
- } catch(e) {
- return true; // SecurityError when referencing it means it exists
- }
- },
-
- isCanvasSupported: function () {
- var elem = document.createElement('canvas');
- return !!(elem.getContext && elem.getContext('2d'));
- },
-
- isIE: function () {
- if(navigator.appName === 'Microsoft Internet Explorer') {
- return true;
- } else if(navigator.appName === 'Netscape' && new RegExp('Trident').test(navigator.userAgent)){// IE 11
- return true;
- }
- return false;
- },
-
- getPluginsString: function () {
- if(this.isIE() && this.ie_activex){
- return this.getIEPluginsString();
- } else {
- return this.getRegularPluginsString();
- }
- },
-
- getRegularPluginsString: function () {
- return this.map(navigator.plugins, function (p) {
- var mimeTypes = this.map(p, function(mt){
- return [mt.type, mt.suffixes].join('~');
- }).join(',');
- return [p.name, p.description, mimeTypes].join('::');
- }, this).join(';');
- },
-
- getIEPluginsString: function () {
- if(window.ActiveXObject){
- var names = ['ShockwaveFlash.ShockwaveFlash',//flash plugin
- 'AcroPDF.PDF', // Adobe PDF reader 7+
- 'PDF.PdfCtrl', // Adobe PDF reader 6 and earlier, brrr
- 'QuickTime.QuickTime', // QuickTime
- // 5 versions of real players
- 'rmocx.RealPlayer G2 Control',
- 'rmocx.RealPlayer G2 Control.1',
- 'RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)',
- 'RealVideo.RealVideo(tm) ActiveX Control (32-bit)',
- 'RealPlayer',
- 'SWCtl.SWCtl', // ShockWave player
- 'WMPlayer.OCX', // Windows media player
- 'AgControl.AgControl', // Silverlight
- 'Skype.Detection'];
-
- // starting to detect plugins in IE
- return this.map(names, function(name){
- try{
- new ActiveXObject(name);
- return name;
- } catch(e){
- return null;
- }
- }).join(';');
- } else {
- return ""; // behavior prior version 0.5.0, not breaking backwards compat.
- }
- },
-
- getScreenResolution: function () {
- var resolution;
- if(this.screen_orientation){
- resolution = (screen.height > screen.width) ? [screen.height, screen.width] : [screen.width, screen.height];
- }else{
- resolution = [screen.height, screen.width];
- }
- return resolution;
- },
-
- getCanvasFingerprint: function () {
- var canvas = document.createElement('canvas');
- var ctx = canvas.getContext('2d');
- // https://www.browserleaks.com/canvas#how-does-it-work
- var txt = 'http://valve.github.io';
- ctx.textBaseline = "top";
- ctx.font = "14px 'Arial'";
- ctx.textBaseline = "alphabetic";
- ctx.fillStyle = "#f60";
- ctx.fillRect(125,1,62,20);
- ctx.fillStyle = "#069";
- ctx.fillText(txt, 2, 15);
- ctx.fillStyle = "rgba(102, 204, 0, 0.7)";
- ctx.fillText(txt, 4, 17);
- return canvas.toDataURL();
- }
- };
-
-
- return Fingerprint;
-
-});
diff --git a/scripts/fontjs/Font.js b/scripts/fontjs/Font.js
index 82d02f5f..70847e80 100644
--- a/scripts/fontjs/Font.js
+++ b/scripts/fontjs/Font.js
@@ -1,3 +1,4 @@
+// @if function("font_add")
/**
Font.js v2012.01.25
@@ -824,4 +825,5 @@
*/
window.Font = Font;
-} (window));
\ No newline at end of file
+} (window));
+// @endif
\ No newline at end of file
diff --git a/scripts/functions/Function_Action.js b/scripts/functions/Function_Action.js
index 9f2e4b54..54bf31e4 100644
--- a/scripts/functions/Function_Action.js
+++ b/scripts/functions/Function_Action.js
@@ -17,1639 +17,3 @@
// Whether the arguments to a function are relative
var Argument_Relative = false;
-
-// Error messages
-var error_a0003 = 'Trying to stop non-existing sound.',
- error_a0004 = 'Trying to draw a non-existing sprite.',
- error_a0005 = 'Trying to draw a non-existing background.',
- error_a0006 = 'Cannot compare arguments.',
- //error_a0007 = 'Video file not found (or name too long).',
- error_a0008 = 'Trying to replace non-existing resource.',
- error_a0009 = 'File does not exist.',
- //error_a0010 = 'Trying to save screen to empty image file name.',
- //error_a0011 = 'In secure mode you cannot open webpages.',
- //error_a0012 = 'Failed to open the webpage.',
- //error_a0013 = 'The particle system must first be created.',
- error_a0014 = 'The particle emitter must first be created.';
-
-// Track particle systems
-var g_ParticleSystem = -1,
- g_ParticleType = [],
- g_ParticleEmit = [];
-
-
-function action_execute_script() { ErrorFunction("action_execute_script()"); }
-function action_show_info() { ErrorFunction("action_show_info()"); }
-function action_show_video() { ErrorFunction("action_show_video()"); }
-
-function action_unknown() {}
-function action_path_old() { action_unknown(); }
-function action_draw_font() { action_unknown(); }
-function action_draw_font_old() { action_unknown(); }
-function action_fill_color() { action_unknown(); }
-function action_line_color() { action_unknown(); }
-function action_highscore() { action_unknown(); }
-
-function action_if_question(_arg)
-{
- return show_question(_arg);
-}
-
-function action_set_relative(rel)
-{
- Argument_Relative = (rel < 0.5) ? false : true;
-}
-
-
-function action_set_cursor(_spr, _show) {
- window_set_cursor(_spr);
- g_CurrentCursor = _spr;
- if( !_show ){
- EnableCursor(false);
- }else{
- EnableCursor(true);
- }
-}
-
-
-function action_set_sprite(_inst, _spr, _scale)
-{
- // Left in for compatibility
- var sprIndex = Round(_spr);
- if (sprite_exists(sprIndex))
- {
- _inst.sprite_index = sprIndex;
- }
-
- if (_scale > 0 )
- {
- _inst.image_xscale = _scale;
- _inst.image_yscale = _scale;
- }
-}
-
-function action_set_motion(_inst, _dir, _val)
-{
- if ( true == Argument_Relative )
- {
- _inst.AddTo_Speed(_dir, _val);
- }
- else
- {
- _inst.direction = _dir;
- _inst.speed = _val;
- }
-}
-
-function action_set_hspeed(_inst, _speed)
-{
- if ( Argument_Relative )
- {
- _inst.hspeed = _inst.hspeed + _speed;
- }
- else
- {
- _inst.hspeed = _speed;
- }
-}
-
-function action_set_vspeed(_inst, _speed)
-{
- if ( Argument_Relative )
- {
- _inst.vspeed = _inst.vspeed+_speed;
- }
- else
- {
- _inst.vspeed = _speed;
- }
-}
-
-function action_set_gravity(_inst, _gdir, _gravity)
-{
- if (true == Argument_Relative )
- {
- _inst.gravity_direction += _gdir;
- _inst.gravity += _gravity;
- }
- else
- {
- _inst.gravity_direction = _gdir;
- _inst.gravity = _gravity;
- }
-}
-
-function action_set_friction(_inst, _friction)
-{
- if (true == Argument_Relative )
- {
- _inst.friction += _friction;
- }
- else
- {
- _inst.friction = _friction;
- }
-}
-
-function action_move(_inst, direction, size)
-{
- var b = false;
- var d = 0;
-
- // Check whether any direction allowed
- if (direction.length != 9)
- {
- debug("Incorrect argument for action_move()");
- return;
- }
-
- for ( d=0 ; d<9 ; d++ )
- {
- b = ((true==b) || (direction[d] == '1')) ? true : false;
- }
-
- if ( true != b ) {
- return;
- }
-
- // Adapt the speed
- if ( true == Argument_Relative )
- {
- _inst.speed = _inst.speed + size;
- }
- else
- {
- _inst.speed = size ;
- }
-
- // Find a valid direction
- do
- {
- d = floor(YYRandom(9));
- } while ( !(direction[d] == '1') );
-
- switch(d)
- {
- case 0: _inst.direction = 225; break;
- case 1: _inst.direction = 270; break;
- case 2: _inst.direction = 315; break;
- case 3: _inst.direction = 180; break;
- case 4: { _inst.direction = 0; _inst.speed = 0; break; }
- case 5: _inst.direction = 0; break;
- case 6: _inst.direction = 135; break;
- case 7: _inst.direction = 90; break;
- case 8: _inst.direction = 45; break;
- }
-}
-
-function action_move_point(_inst, _x, _y, _speed)
-{
- if ( true == Argument_Relative )
- {
- move_towards_point(_inst, _x + _inst.x, _y + _inst.y, _speed);
- }
- else
- {
- move_towards_point(_inst, _x, _y, _speed);
- }
-}
-
-function action_move_to(_inst, _x, _y)
-{
- if ( true == Argument_Relative )
- {
- _inst.SetPosition(_x + _inst.x, _y + _inst.y);
- }
- else
- {
- _inst.SetPosition(_x, _y);
- }
-}
-
-function action_move_start(_inst)
-{
- _inst.SetPosition(_inst.xstart, _inst.ystart);
-}
-
-function action_move_random(_inst, _sx, _sy)
-{
- move_random(_inst, _sx, _sy);
-}
-
-function action_snap(_inst, _hsnap, _vsnap)
-{
- move_snap(_inst, _hsnap, _vsnap);
-}
-
-function action_wrap(_inst, _wrap)
-{
- var wrap = Round(_wrap);
- _inst.wrap((wrap == 0) || (wrap == 2) ? true : false, (wrap == 1) || (wrap == 2) ? true : false);
-}
-
-function action_reverse_xdir(_inst)
-{
- _inst.hspeed = -_inst.hspeed;
-}
-
-function action_reverse_ydir(_inst)
-{
- _inst.vspeed = -_inst.vspeed;
-}
-
-function action_move_contact(_inst, _dir, _maxdist, _useall)
-{
- move_contact(_inst, _dir, _maxdist, _useall);
-}
-
-function action_bounce(_inst, _adv, _useall)
-{
- Command_Bounce(_inst, (_adv >= 0.5) ? true : false, (_useall == 1) ? true : false);
-}
-
-function action_kill_object(_inst)
-{
- instance_destroy(_inst );
-}
-
-function action_create_object(_inst, _objid, _x, _y)
-{
- var objid = Round(_objid);
- if (true != object_exists(objid))
- {
- debug("Creating existence for non-existent object: " + objid.toString());
- return;
- }
-
- var inst = null;
- if ( true == Argument_Relative )
- {
- inst = g_RunRoom.GML_AddInstance(_x + _inst.x, _y + _inst.y, objid);
- }
- else
- {
- inst = g_RunRoom.GML_AddInstance(_x, _y, objid);
- }
-
- inst.PerformEvent(EVENT_PRE_CREATE, 0, inst, inst);
- inst.PerformEvent(EVENT_CREATE, 0, inst, inst);
- inst.created = true;
-}
-
-function action_create_object_motion(_inst, _objid, _x, _y, _speed, _dir)
-{
- var objid = Round(_objid);
- if (true != object_exists(objid))
- {
- debug("Creating instance for non-existent object: " + objid);
- return;
- }
-
- var inst = null;
- if ( true == Argument_Relative )
- {
- inst = g_RunRoom.GML_AddInstance(_x + _inst.x, _y + _inst.y, objid);
- }
- else
- {
- inst = g_RunRoom.GML_AddInstance(_x, _y, objid);
- }
-
- inst.speed = _speed;
- inst.direction =_dir;
- inst.PerformEvent(EVENT_PRE_CREATE, 0, inst, inst);
- inst.PerformEvent(EVENT_CREATE, 0, inst, inst);
- inst.created = true;
-}
-
-function action_create_object_random(_inst, _objid0, _objid1, _objid2, _objid3, _x, _y)
-{
- if (!object_exists(_objid0 | 0) && !object_exists(_objid1 | 0) && !object_exists(_objid2 | 0) && !object_exists(_objid3 | 0))
- {
- return;
- }
-
- while ( true )
- {
- var n = ~~YYRandom(4);
- var id = arguments[n + 1] | 0;
- if (!object_exists(id)) {
- continue;
- }
-
- var inst;
- if (true == Argument_Relative)
- {
- inst = g_RunRoom.GML_AddInstance(_x + _inst.x, _y + _inst.y, id);
- }
- else
- {
- inst = g_RunRoom.GML_AddInstance(_x, _y, id);
- }
-
- inst.PerformEvent(EVENT_PRE_CREATE, 0, inst, inst);
- inst.PerformEvent(EVENT_CREATE, 0, inst, inst);
- inst.created = true;
- return;
- }
-}
-
-function action_sprite_set(_inst, _spr, _subimg, _imgspeed)
-{
- var sprIndex = Round(_spr);
- if (sprite_exists(sprIndex)) {
- _inst.sprite_index = sprIndex;
- }
-
- if (_subimg >= 0) {
- _inst.image_index = _subimg;
- }
-
- _inst.image_speed = _imgspeed;
-}
-
-function action_sprite_color(_inst, _col, _alpha)
-{
- _inst.image_blend = Round(_col);
- _inst.image_alpha = _alpha;
-}
-var action_sprite_colour = action_sprite_color;
-
-
-function action_sound(_snd, _loop) {
- if (g_AudioModel == Audio_WebAudio) {
- var snd = Round(_snd);
- audio_play_sound(snd, 1, _loop >= 0.5 ? true : false);
-/* audio_music fns DEPRECATED
- switch (audio_get_type(snd)) {
- case 0:
- audio_play_sound(snd, 1, _loop >= 0.5 ? true : false);
- break;
- case 1:
- audio_play_music(snd, _loop >= 0.5 ? true : false);
- break;
- } // end switch
-*/
- }
- else {
- var snd = Round(_snd);
- if (_loop >= 0.5) {
- g_pSoundManager.Loop(snd);
- }
- g_pSoundManager.Play(snd);
- }
-}
-
-function action_set_alarm(_inst, _time, _alarm)
-{
- var alarm = Round(_alarm);
- var time = Round(_time);
- if (!Argument_Relative || (_inst.get_timer(alarm) < 0) )
- {
- _inst.set_timer(alarm, time);
- }
- else
- {
- _inst.set_timer(alarm, _inst.get_timer(alarm) + time);
- }
-}
-
-function action_end_game()
-{
- game_end();
-}
-
-function action_restart_game()
-{
- game_restart();
-}
-
-function action_if_dice(_arg)
-{
- var Result;
- if (_arg <= 1 )
- {
- Result = 1;
- }
- else
- {
- Result = (YYRandom(Round(1000*_arg)) <= 1000) ? 1 : 0;
- }
- return Result;
-}
-
-function action_if_variable()
-{
- var r = 0;
- if (typeof(arguments[0]) != typeof(arguments[1]))
- {
- // It's fine to compare a boolean against a number so convert if necessary
- if ((typeof(arguments[0] == "boolean") && (typeof(arguments[1]) == "number"))) {
- r = (arguments[0] == true) ? (1 - arguments[1]) : (0 - arguments[1]);
- }
- else if ((typeof(arguments[1] == "boolean") && (typeof(arguments[0]) == "number"))) {
- r = (arguments[1] == true) ? (arguments[0] - 1) : (arguments[0] - 0);
- }
- else {
- debug(error_a0006);
- return;
- }
- }
- else {
- if (typeof(arguments[0]) == "string")
- {
- // From the C => "r = strcmp( _val1.str, _val2.str)"
- r = (arguments[0] == arguments[1]) ? 0 : 1;
- }
- else
- {
- r = arguments[0] - arguments[1];
- }
- }
-
- var result;
- if (Round(arguments[2]) == 1)
- {
- result = (r < 0) ? 1 : 0;
- }
- else if (Round(arguments[2]) == 2)
- {
- result = (r > 0) ? 1 : 0;
- }
- else if (Round(arguments[2]) == 3)
- {
- result = (r <= 0) ? 1 : 0;
- }
- else if (Round(arguments[2]) == 4)
- {
- result = (r >= 0) ? 1 : 0;
- }
- else
- {
- result = (r == 0) ? 1 : 0;
- }
- return result;
-}
-
-function action_draw_variable(_inst, _var, _x, _y)
-{
- var str = "";
- if (typeof(arguments[0]) == "number")
- {
- if (_var == Round(_var))
- {
- str = (Round(_var) | 0).toString();
- }
- else
- {
- str = _var.toFixed(2).toString(); // should be 10.2 and not hard-coded like this
- }
- }
- else
- {
- str = _var.toString();
- }
-
-
- if (Argument_Relative )
- {
- draw_text(_x + _inst.x, _y + _inst.y, str);
- }
- else
- {
- draw_text(_x, _y, str);
- }
-}
-
-function action_set_score(_score)
-{
- if (Argument_Relative)
- {
- g_pBuiltIn.score += Round(_score);
- }
- else
- {
- g_pBuiltIn.score = Round(_score);
- }
-}
-
-function action_if_score()
-{
- var result;
- if (Round(arguments[1]) == 1)
- {
- result = (g_pBuiltIn.score < arguments[0]) ? 1 : 0;
- }
- else if (Round(arguments[1]) == 2)
- {
- result = (g_pBuiltIn.score > arguments[0]) ? 1 : 0;
- }
- else
- {
- result = (g_pBuiltIn.score == arguments[0]) ? 1 : 0;
- }
- return result;
-}
-
-function action_draw_score(_inst, _x, _y, _score_str)
-{
- var scoreStr = "";
- if (_score_str)
- {
- scoreStr = _score_str;
- }
-
- var score = scoreStr + g_pBuiltIn.score.toString();
- if (Argument_Relative)
- {
- draw_text(_x + _inst.x, _y + _inst.y, score);
- }
- else
- {
- draw_text(_x, _y, score);
- }
-}
-
-function action_set_life(_lives)
-{
- var oldlives = g_pBuiltIn.lives;
- if ( true == Argument_Relative )
- {
- g_pBuiltIn.lives += Round(_lives);
- }
- else
- {
- g_pBuiltIn.lives = Round(_lives);
- }
-
- if ((oldlives > 0) && (g_pBuiltIn.lives <= 0) )
- {
- g_pInstanceManager.PerformEvent(EVENT_OTHER_NOLIVES, 0);
- }
-}
-
-function action_if_life()
-{
- var result;
- if (Round(arguments[1]) == 1)
- {
- result = (g_pBuiltIn.lives < arguments[0]) ? 1 : 0;
- }
- else if (Round(arguments[1]) == 2)
- {
- result = (g_pBuiltIn.lives > arguments[0]) ? 1 : 0;
- }
- else
- {
- result = (g_pBuiltIn.lives == arguments[0]) ? 1 : 0;
- }
- return result;
-}
-
-function action_draw_life(_inst, _x, _y, _life_str)
-{
- var lifeStr = _life_str;
- if (!lifeStr)
- {
- lifeStr = "";
- }
-
- var lives = lifeStr + g_pBuiltIn.lives.toString();
- if (Argument_Relative )
- {
- draw_text(_x + _inst.x, _y + _inst.y, lives);
- }
- else
- {
- draw_text(_x, _y, lives);
- }
-}
-
-function action_draw_life_images(_inst, _x, _y, _spr)
-{
- if (sprite_exists(Round(_spr)))
- {
- var spr = g_pSpriteManager.Get(Round(_spr));
- var w = spr.width;
- for (var i=0; i < g_pBuiltIn.lives; i++)
- {
- if (Argument_Relative)
- {
- spr.Draw(0, _x + _inst.x + (i*w), _y + _inst.y, 1, 1, 0, clWhite, 1);
- }
- else
- {
- spr.Draw(0, _x + (i*w), _y, 1, 1, 0, clWhite, 1);
- }
- }
- }
-}
-
-function action_set_health(_inst, _health)
-{
- var oldhealth = 0.0;
-
- oldhealth = g_pBuiltIn.health;
- if ( true == Argument_Relative )
- {
- g_pBuiltIn.health += _health;
- }
- else
- {
- g_pBuiltIn.health = _health;
- }
-
- if ((oldhealth > 0) && (g_pBuiltIn.health <= 0))
- {
- g_pInstanceManager.PerformEvent(EVENT_OTHER_NOHEALTH, 0);
- }
-}
-
-function action_if_health(_inst, _value, _op)
-{
- var result;
- _op = ~ ~_op;
- if (_op == 1)
- {
- result = (g_pBuiltIn.health < _value) ? 1 : 0;
- }
- else if (_op == 2)
- {
- result = (g_pBuiltIn.health > _value) ? 1 : 0;
- }
- else
- {
- result = (g_pBuiltIn.health == _value) ? 1 : 0;
- }
- return result;
-}
-
-function action_set_caption(_show_score_caption, _score_caption, _show_lives_caption, _lives_caption, _show_health_caption, _health_caption)
-{
- g_pBuiltIn.show_score = Round(_show_score_caption) == 1 ? true : false;
- g_pBuiltIn.caption_score = _score_caption;
-
- g_pBuiltIn.show_lives = Round(_show_lives_caption) == 1 ? true : false;
- g_pBuiltIn.caption_lives = _lives_caption;
-
- g_pBuiltIn.show_health = Round(_show_health_caption) == 1 ? true : false;
- g_pBuiltIn.caption_health = _health_caption;
-}
-
-function action_draw_sprite(_inst, _spr, _x, _y, _subimg)
-{
- if (!sprite_exists(Round(_spr)) )
- {
- debug(error_a0004);
- return;
- }
-
- var subimg;
- if (_subimg < 0) {
- subimg = _inst.image_index;
- }
- else {
- subimg = Math.floor(_subimg);
- }
-
- var spr = g_pSpriteManager.Get(Round(_spr));
- if (Argument_Relative)
- {
- spr.Draw(subimg, _x + _inst.x, _y + _inst.y, 1, 1, 0, clWhite, 1);
- }
- else
- {
- spr.Draw(subimg, _x, _y, 1, 1, 0, clWhite, 1);
- }
-}
-
-function action_draw_background(_inst, _bg, _x, _y, _tiled)
-{
-
- //Fritz: Seems to have been disabled at some point in the past & throwing multiple errors so going to nuke it
- ErrorFunction("action_draw_background()");
- /*
- if ( true != Background_Exists(Round(_bg)) )
- {
- debug(error_a0005);
- return;
- }
-
- var background = g_pBackgroundManager.Get(Round(_bg));
- var tiled = (_tiled >= 0.5) ? true : false;
- */
-/*
- if (Argument_Relative)
- {
- // bg.DrawTiled(_x + _inst.x, _y + _inst.y, 1.0, 1.0, tiled, tiled, 0,0, g_RunRoom.GetWidth(), g_Run_Room.GetHeight(), clWhite, 1.0);
- }
- else
- {
- // bg.DrawTiled(_x, _y, 1.0, 1.0, tiled, tiled, 0,0, g_RunRoom.GetWidth(), g_Run_Room.GetHeight(), clWhite, 1.0);
- }
-*/
-}
-
-function action_draw_text(_inst, _str, _x, _y)
-{
- if (Argument_Relative)
- {
- draw_text(_x + _inst.x, _y + _inst.y, _str);
- }
- else
- {
- draw_text(_x, _y, _str);
- }
-}
-
-function action_draw_text_transformed(_inst, _text, _x, _y, _xscale, _yscale, _rot)
-{
- if (Argument_Relative)
- {
- draw_text_transformed(_x + _inst.x, _y + _inst.y, _text, _xscale, _yscale, _rot);
- }
- else
- {
- draw_text_transformed(_x, _y, _text, _xscale, _yscale, _rot);
- }
-}
-
-function action_draw_rectangle(_inst, _x, _y, _x2, _y2, _outline)
-{
- if (Argument_Relative )
- {
- draw_rectangle(_x + _inst.x, _y + _inst.y, _x2 + _inst.x, _y2 + _inst.y, (_outline >= 0.5) ? true : false);
- }
- else
- {
- draw_rectangle(_x, _y, _x2, _y2, (_outline >= 0.5) ? true : false);
- }
-}
-
-function action_draw_line(_inst, _x, _y, _x2, _y2)
-{
- if (Argument_Relative )
- {
- draw_line(_x + _inst.x, _y + _inst.y, _x2 + _inst.x, _y2 + _inst.y);
- }
- else
- {
- draw_line(_x, _y, _x2, _y2);
- }
-}
-
-function action_color(_col)
-{
- draw_set_color(_col);
-}
-var action_colour = action_color;
-
-
-function action_font(_font, _halign)
-{
- draw_set_font(_font);
- draw_set_halign(_halign);
-}
-
-
-function action_draw_health(_inst, _x, _y, _x2, _y2, _col, _col2)
-{
- var col1 = 0;
- var col2 = 0;
- var col3 = 0;
- var col4 = 0;
- switch (Round(_col))
- {
- case 0: col1 = clBlack; break;
- case 1: col1 = clBlack; break;
- case 2: col1 = clGray; break;
- case 3: col1 = clSilver; break;
- case 4: col1 = clWhite; break;
- case 5: col1 = clMaroon; break;
- case 6: col1 = clGreen; break;
- case 7: col1 = clOlive; break;
- case 8: col1 = clNavy; break;
- case 9: col1 = clPurple; break;
- case 10: col1 = clTeal; break;
- case 11: col1 = clRed; break;
- case 12: col1 = clLime; break;
- case 13: col1 = clYellow; break;
- case 14: col1 = clBlue; break;
- case 15: col1 = clFuchsia; break;
- case 16: col1 = clAqua; break;
- }
-
- switch (Round(_col2))
- {
- case 0: { col2 = clRed; col3 = clYellow; col4 = clLime; } break;
- case 1: { col2 = clBlack; col3 = clGray; col4 = clWhite; } break;
- case 2: col2 = clBlack; break;
- case 3: col2 = clGray; break;
- case 4: col2 = clSilver; break;
- case 5: col2 = clWhite; break;
- case 6: col2 = clMaroon; break;
- case 7: col2 = clGreen; break;
- case 8: col2 = clOlive; break;
- case 9: col2 = clNavy; break;
- case 10: col2 = clPurple; break;
- case 11: col2 = clTeal; break;
- case 12: col2 = clRed; break;
- case 13: col2 = clLime; break;
- case 14: col2 = clYellow; break;
- case 15: col2 = clBlue; break;
- case 16: col2 = clFuchsia; break;
- case 17: col2 = clAqua; break;
- }
-
- if (Round(_col2) > 1)
- {
- col3 = col2;
- col4 = col2;
- }
-
- if (Argument_Relative )
- {
- draw_healthbar_ex(_x+_inst.x,_y+_inst.y, _x2+_inst.x, _y2+_inst.y, g_pBuiltIn.health, col1, col2, col3, col4, 0, (_col >= 0.5)?true:false, true);
- }
- else
- {
- draw_healthbar_ex(_x, _y, _x2, _y2, g_pBuiltIn.health, col1, col2, col3, col4, 0, (_col >= 0.5) ? true : false, true);
- }
-}
-
-function action_another_room(_room, _transition)
-{
- room_goto(Round(_room));
-}
-
-function action_current_room()
-{
- room_restart();
-}
-
-function action_previous_room()
-{
- room_goto_previous();
-}
-
-function action_next_room()
-{
- room_goto_next();
-}
-
-function action_if_previous_room()
-{
- return ((g_pBuiltIn.get_current_room() != g_pBuiltIn.room_first) ? 1 : 0);
-}
-
-function action_if_next_room()
-{
- return ((g_pBuiltIn.get_current_room() != g_pBuiltIn.room_last) ? 1 : 0);
-}
-
-function action_partsyst_create(_depth)
-{
- if (g_ParticleSystem < 0) {
- g_ParticleSystem = ParticleSystem_Create();
- }
- ParticleSystem_Clear(g_ParticleSystem);
- ParticleSystem_Depth(g_ParticleSystem, Round(_depth));
-
- g_ParticleType = new Array(16);
- g_ParticleEmit = new Array(16);
- for (var i = 0 ; i < 16; i++ ) {
- g_ParticleType[i] = -1;
- g_ParticleEmit[i] = -1;
- }
-}
-
-function action_partsyst_destroy()
-{
- if (g_ParticleSystem >= 0) {
- ParticleSystem_Destroy(g_ParticleSystem);
- }
- g_ParticleSystem = -1;
-}
-
-function action_partsyst_clear()
-{
- if (g_ParticleSystem >= 0) {
- ParticleSystem_Particles_Clear(g_ParticleSystem);
- }
-}
-
-function action_parttype_create_old(_type, _shape, _sizeMin, _sizeMax, _colStart, _colEnd)
-{
- var type = Round(_type);
- var shape = Round(_shape);
- var colStart = Round(_colStart);
- var colEnd = Round(_colEnd);
-
- if (g_ParticleSystem < 0) {
- g_ParticleSystem = ParticleSystem_Create();
- }
- if (g_ParticleType[type] < 0 ) {
- g_ParticleType[type] = ParticleType_Create();
- }
- var pt = g_ParticleType[type];
- ParticleType_Shape(pt, shape);
- ParticleType_Size(pt, _sizeMin, _sizeMax, 0, 0);
- ParticleType_Color2(pt, colStart, colEnd);
-}
-
-function action_parttype_create(_type, _shape, _spr, _sizeMin, _sizeMax, _sizeIncr)
-{
- var type = Round(_type);
- var shape = Round(_shape);
- var spr = Round(_spr);
-
- if (g_ParticleSystem < 0) {
- g_ParticleSystem = ParticleSystem_Create();
- }
-
- if (g_ParticleType[type] < 0) {
- g_ParticleType[type] = ParticleType_Create();
- }
- var pt = g_ParticleType[type];
- ParticleType_Shape(pt, shape);
- ParticleType_Sprite(pt, spr, true, false, false);
- ParticleType_Size(pt, _sizeMin, _sizeMax, _sizeIncr, 0);
-}
-
-function action_parttype_color(_type, _mixCol, _colStart, _colEnd, _alphaStart, _alphaEnd)
-{
- var type = Round(_type);
- var mixCol = Round(_mixCol);
- var colStart = Round(_colStart);
- var colEnd = Round(_colEnd);
-
- if (g_ParticleSystem < 0) {
- g_ParticleSystem = ParticleSystem_Create();
- }
- if (g_ParticleType[type] < 0 ) {
- g_ParticleType[type] = ParticleType_Create();
- }
- var pt = g_ParticleType[type];
- if (mixCol == 0)
- {
- ParticleType_Colour_Mix(pt, colStart, colEnd);
- }
- else
- {
- ParticleType_Color2(pt, colStart, colEnd);
- }
- ParticleType_Alpha2(pt, _alphaStart, _alphaEnd);
-}
-var action_parttype_colour = action_parttype_color;
-
-function action_parttype_life(_type, _lifeMin, _lifeMax)
-{
- var type = Round(_type);
- var lifeMin = Round(_lifeMin);
- var lifeMax = Round(_lifeMax);
-
- if (g_ParticleSystem < 0) {
- g_ParticleSystem = ParticleSystem_Create();
- }
- if (g_ParticleType[type] < 0 ) {
- g_ParticleType[type] = ParticleType_Create();
- }
- var pt = g_ParticleType[type];
- ParticleType_Life(pt, lifeMin, lifeMax);
-}
-
-function action_parttype_speed(_type, _speedMin, _speedMax, _dirMin, _dirMax, _speedIncr)
-{
- var type = Round(_type);
-
- if (g_ParticleSystem < 0) {
- g_ParticleSystem = ParticleSystem_Create();
- }
- if (g_ParticleType[type] < 0 ) {
- g_ParticleType[type] = ParticleType_Create();
- }
- var pt = g_ParticleType[type];
- ParticleType_Speed(pt, _speedMin, _speedMax, -_speedIncr, 0);
- ParticleType_Direction(pt, _dirMin, _dirMax, 0, 0);
-}
-
-function action_parttype_gravity(_type, _gravStrength, _gravDir)
-{
- var type = Round(_type);
-
- if (g_ParticleSystem < 0) {
- g_ParticleSystem = ParticleSystem_Create();
- }
- if (g_ParticleType[type] < 0 ) {
- g_ParticleType[type] = ParticleType_Create();
- }
- var pt = g_ParticleType[type];
- ParticleType_Gravity(pt, _gravStrength, _gravDir);
-}
-
-function action_parttype_secondary(_type, _stepType, _stepNumber, _deathType, _deathNumber)
-{
- var type = Round(_type);
- var stepNumber = Round(_stepNumber);
- var stepType = Round(_stepType);
- var deathNumber = Round(_deathNumber);
- var deathType = Round(_deathType);
-
- if (g_ParticleSystem < 0) {
- g_ParticleSystem = ParticleSystem_Create();
- }
- if (g_ParticleType[type] < 0 ) {
- g_ParticleType[type] = ParticleType_Create();
- }
- var pt = g_ParticleType[type];
-
- ParticleType_Step(pt, stepNumber, g_ParticleType[stepType]);
- ParticleType_Death(pt, deathNumber, g_ParticleType[deathType]);
-}
-
-function action_partemit_create(_emit, _shape, _xmin, _xmax, _ymin, _ymax)
-{
- var emit = Round(_emit);
- var shape = Round(_shape);
-
- if (g_ParticleSystem < 0) {
- g_ParticleSystem = ParticleSystem_Create();
- }
- if (g_ParticleEmit[emit] < 0 ) {
- g_ParticleEmit[emit] = ParticleSystem_Emitter_Create(g_ParticleSystem);
- }
- var pe = g_ParticleEmit[emit];
- ParticleSystem_Emitter_Region(g_ParticleSystem, pe, _xmin, _xmax, _ymin, _ymax, shape, PART_EDISTR_LINEAR);
-}
-
-function action_partemit_destroy(_emit)
-{
- var emit = Round(_emit);
-
- if (g_ParticleSystem < 0) {
- g_ParticleSystem = ParticleSystem_Create();
- }
- if (g_ParticleEmit[emit] < 0 ) {
- return;
- }
- var pe = g_ParticleEmit[emit];
- ParticleSystem_Emitter_Destroy(g_ParticleSystem, pe);
-}
-
-function action_partemit_burst(_emit, _type, _number)
-{
- var emit = Round(_emit);
- var type = Round(_type);
- var number = Round(_number);
-
- if (g_ParticleSystem < 0) {
- g_ParticleSystem = ParticleSystem_Create();
- }
- if (g_ParticleEmit[emit] < 0 )
- {
- debug(error_a0014);
- return;
- }
- var pe = g_ParticleEmit[emit];
- ParticleSystem_Emitter_Burst(g_ParticleSystem, pe, g_ParticleType[type], number);
-}
-
-function action_partemit_stream(_emit, _type, _number)
-{
- var emit = Round(_emit);
- var type = Round(_type);
- var number = Round(_number);
-
- if (g_ParticleSystem < 0) {
- g_ParticleSystem = ParticleSystem_Create();
- }
- if (g_ParticleEmit[emit] < 0 )
- {
- debug(error_a0014);
- return;
- }
- var pe = g_ParticleEmit[emit];
- ParticleSystem_Emitter_Stream(g_ParticleSystem, pe, g_ParticleType[type], number);
-}
-
-function action_draw_gradient_hor(_inst, _x, _y, _x2, _y2, _col1, _col2)
-{
- if (Argument_Relative)
- {
- draw_rectangle_gradient(_x + _inst.x, _y + _inst.y, _x2 + _inst.x, _y2 + _inst.y, _col1, _col2, false, false);
- }
- else
- {
- draw_rectangle_gradient(_x, _y, _x2, _y2, _col1, _col2, false, false);
- }
-}
-
-function action_draw_gradient_vert(_inst, _x, _y, _x2, _y2, _col1, _col2)
-{
- if (Argument_Relative)
- {
- draw_rectangle_gradient(_x + _inst.x, _y + _inst.y, _x2 + _inst.x, _y2 + _inst.y, _col1, _col2, true, false);
- }
- else
- {
- draw_rectangle_gradient(_x, _y, _x2, _y2, _col1, _col2, true, false);
- }
-}
-
-function action_draw_arrow(_inst, _x, _y, _x2, _y2, _size)
-{
- if (Argument_Relative)
- {
- draw_arrow(_x + _inst.x, _y + _inst.y, _x2 + _inst.x, _y2 + _inst.y, _size);
- }
- else
- {
- draw_arrow(_x, _y, _x2, _y2, _size);
- }
-}
-
-function action_if_empty(_inst, _arg0, _arg1, _arg2)
-{
- var val1 = _arg0;
- var val2 = _arg1;
-
- if (Argument_Relative)
- {
- val1 += _inst.x;
- val2 += _inst.y;
- }
- if (Round(_arg2) == 0)
- {
- return place_free(_inst, val1, val2) ? 1 : 0;
- }
-
- return place_empty(_inst, val1, val2) ? 1 : 0;
-}
-
-function action_if_collision(_inst, _arg0, _arg1, _arg2)
-{
- var val1 = _arg0;
- var val2 = _arg1;
- if (Argument_Relative )
- {
- val1 += _inst.x;
- val2 += _inst.y;
- }
-
- if (Round(_arg2) == 0)
- {
- return !place_free(_inst, val1, val2) ? 1 : 0;
- }
- return !place_empty(_inst, val1, val2) ? 1 : 0;
-}
-
-function action_if(_arg0)
-{
- return _arg0;
-}
-
-function action_if_number(_arg0, _arg1, _arg2)
-{
- var n = instance_number(Round(_arg0));
-
- var result;
- if (Round(_arg2) == 1)
- {
- result = (n < _arg1) ? 1 : 0;
- }
- else if (Round(_arg2) == 2)
- {
- result = (n > _arg1) ? 1 : 0;
- }
- else
- {
- result = (n == _arg1) ? 1 : 0;
- }
-
- return result;
-}
-
-function action_if_object(_inst, _obj, _x, _y)
-{
- if (Argument_Relative)
- {
- return place_meeting(_inst, _x + _inst.x, _y + _inst.y, Round(_obj)) ? 1 : 0;
- }
- return place_meeting(_inst, _x, _y, Round(_obj)) ? 1 : 0;
-}
-
-function action_if_mouse(_arg0)
-{
- var result;
- switch (Round(_arg0))
- {
- case 1: result = (g_pIOManager.Button_Down(1) || g_pIOManager.Button_Released(1)) ? 1 : 0; break;
- case 2: result = (g_pIOManager.Button_Down(2) || g_pIOManager.Button_Released(2)) ? 1 : 0; break;
- case 3: result = (g_pIOManager.Button_Down(3) || g_pIOManager.Button_Released(3)) ? 1 : 0; break;
- default:result = (g_pIOManager.Button_Current_Get() == 0) ? 1 : 0;
- }
-
- return result;
-}
-
-function action_if_aligned(_inst, _x, _y)
-{
- if (_x > 0)
- {
- if (Math.abs(_inst.x - _x * Round(_inst.x / _x)) >= 0.001 ) {
- return 0;
- }
- }
-
- if (_y > 0)
- {
- if (Math.abs(_inst.y - _y * Round(_inst.y / _y)) >= 0.001 ) {
- return 0;
- }
- }
-
- return 1;
-}
-
-function action_path(_inst, _path, _speed, _atend, _relative)
-{
- _inst.Assign_Path(Round(_path), _speed, 1, 0, (_relative >= 0.5) ? true : false, Round(_atend));
-}
-
-function action_path_end(_inst)
-{
- _inst.Assign_Path(-1, 0, 1, 0, false, 0);
-}
-
-function action_path_position(_inst, _pos)
-{
- if (Argument_Relative)
- {
- _inst.path_position += _pos;
- }
- else
- {
- _inst.path_position = _pos;
- }
-}
-
-function action_path_speed(_inst, _speed)
-{
- if (Argument_Relative)
- {
- _inst.path_speed = _inst.path_speed + _speed;
- }
- else
- {
- _inst.path_speed = _speed;
- }
-}
-
-function action_linear_step(_inst, _x, _y, _stepsize, _checkall)
-{
- if (Argument_Relative)
- {
- mp_linear_step(_inst, _x + _inst.x, _y + _inst.y, _stepsize, (_checkall >= 0.5) ? true : false);
- }
- else
- {
- mp_linear_step(_inst, _x, _y, _stepsize, (_checkall >= 0.5) ? true : false);
- }
-}
-
-function action_potential_step(_inst, _x, _y, _stepsize, _checkall)
-{
- if (Argument_Relative)
- {
- mp_potential_step(_inst, _x + _inst.x, _y + _inst.y, _stepsize, (_checkall >= 0.5) ? true : false);
- }
- else
- {
- mp_potential_step(_inst, _x, _y, _stepsize, (_checkall >= 0.5) ? true : false);
- }
-}
-
-// #############################################################################################
-/// Function:
-///
-///
-///
-/// In:
-/// Out:
-///
-///
-// #############################################################################################
-function action_inherited(_inst, _other) {
-
- if (!_inst) return;
- event_inherited(_inst, _other);
-
- /*if (!object_exists(_inst)) {
- return;
- }
- var parent = _inst.pObject.pParent;
- if( _inst.pObject.pParent!=null )
- {
- if (!object_exists(parent)) {
- return;
- }
- parent.PerformEvent(Current_Event_Type, Current_Event_Number, _inst, _inst);
- }*/
-}
-
-function action_change_object(_inst, _newobj, _perform_events)
-{
- instance_change(_inst, _newobj | 0, (_perform_events >= 0.5) ? true : false);
-}
-
-function action_kill_position(_inst, _x, _y)
-{
- if (Argument_Relative)
- {
- position_destroy(_inst, _x + _inst.x, _y + _inst.y);
- }
- else
- {
- position_destroy(_inst, _x, _y);
- }
-}
-
-function action_end_sound(_snd) {
-
- if (g_AudioModel == Audio_WebAudio) {
- var snd = Round(_snd);
-
- audio_stop_sound(snd);
-
- }
- else {
- var snd = g_pSoundManager.Get(Round(_snd));
- if ((snd != null) && (snd != undefined)) {
- g_pSoundManager.Stop(_snd);
- }
- else {
- debug(error_a0003);
- }
- }
-}
-
-function action_if_sound(_snd) {
- if (g_AudioModel == Audio_WebAudio) {
- var snd = Round(_snd);
-
- return audio_is_playing(snd);
-
- }
- else {
- var snd = g_pSoundManager.Get(Round(_snd));
- if ((snd != null) && (snd != undefined)) {
- return (g_pSoundManager.SoundIsPlaying(_snd) ? 1 : 0);
- }
- return 0;
- }
-}
-
-function action_effect(_inst, _kind, _x, _y, _size, _col, _below)
-{
- var ps = (_below < 0.5) ? ps_above : ps_false;
-
- if (Argument_Relative)
- {
- Effect_Create(ps, Round(_kind), _x + _inst.x, _y + _inst.y, Round(_size), Round(_col));
- }
- else
- {
- Effect_Create(ps, Round(_kind), _x, _y, Round(_size), Round(_col));
- }
-}
-
-function action_message(_message)
-{
- alert(_message);
-}
-
-function action_sprite_transform(_inst, _sx, _sy, _angle, _dir)
-{
- _inst.image_xscale = _sx;
- _inst.image_yscale = _sy;
- _inst.image_angle = _angle;
- if ((_dir == 1) || (_dir == 3)) {
- _inst.image_xscale = -_inst.image_xscale;
- }
- if ((_dir == 2) || (_dir == 3)) {
- _inst.image_yscale = -_inst.image_yscale;
- }
-}
-
-function action_sleep(_sleepTime, _refresh)
-{
- if (_refresh >= 0.5 )
- {
- g_RunRoom.Draw();
- }
-
- Timing_Wait(_sleepTime);
-}
-
-function action_snapshot(_fname)
-{
- surface_save(0, _fname);
-}
-
-function action_replace_sprite(_spr, _fname, _imgNum)
-{
- if (!sprite_exists(Round(_spr)))
- {
- debug(error_a0008);
- return;
- }
-
- if (!file_exists(_fname))
- {
- debug(error_a0009);
- return;
- }
-
- var spr = g_pSpriteManager.Get(Round(_spr));
- sprite_replace(Round(_spr), _fname, Round(_imgNum), spr.colcheck, spr.transparent, spr.smooth, spr.preload, spr.xOrigin, spr.yOrigin);
-}
-
-function action_replace_sound(_snd, _fname)
-{
- if (!sound_exists(Round(_snd)))
- {
- debug(error_a0008);
- return;
- }
- if ( true != file_exists(_fname))
- {
- debug(error_a0009);
- return;
- }
-
- var snd = g_pSoundManager.Get(Round(_snd));
- sound_replace(Round(_snd), _fname, snd.kind, snd.preload);
-}
-
-function action_replace_background(_bg, _fname)
-{
- if (!background_exists(Round(_bg)) )
- {
- debug(error_a0008);
- return;
- }
- if (!file_exists(_fname)) //Fritz: was FileExists() which doesn't
- {
- debug(error_a0009);
- return;
- }
- var back = g_pBackgroundManager.Get(Round(_bg));
- background_replace(Round(_bg), _fname, back.transparent, back.smooth, back.preload);
-}
-
-function action_set_timeline(_inst, _index, _pos)
-{
- action_timeline_set(_inst, _index, _pos, 0, 0);
-}
-
-function action_timeline_set(_inst, _index, _pos, _paused, _loop)
-{
- _inst.timeline_index = _index;
- _inst.timeline_position = _pos;
- _inst.timeline_paused = _paused;
- _inst.timeline_looped = _loop;
-}
-
-function action_set_timeline_position(_inst, _pos)
-{
- if (Argument_Relative)
- {
- _inst.timeline_position += _pos;
- }
- else
- {
- _inst.timeline_position = _pos;
- }
-}
-
-function action_set_timeline_speed(_inst, _speed)
-{
- if (Argument_Relative)
- {
- _inst.timeline_speed += _speed;
- }
- else
- {
- _inst.timeline_speed = _speed;
- }
-}
-
-function action_timeline_start(_inst)
-{
- _inst.timeline_paused = false;
-}
-
-function action_timeline_stop(_inst)
-{
- _inst.timeline_paused = true;
- _inst.timeline_position = 0;
-}
-
-function action_timeline_pause(_inst)
-{
- _inst.timeline_paused = true;
-}
-
-function action_draw_ellipse(_inst, _x, _y, _x2, _y2, _outline)
-{
- if (Argument_Relative)
- {
- draw_ellipse(_x + _inst.x, _y + _inst.y, _x2 + _inst.x, _y2 + _inst.y, (_outline >= 0.5) ? true : false);
- }
- else
- {
- draw_ellipse(_x, _y, _x2, _y2, (_outline >= 0.5) ? true : false);
- }
-}
-
-function action_draw_ellipse_gradient(_inst, _x, _y, _x2, _y2, _col1, _col2) {
-
- if (Argument_Relative)
- {
- draw_ellipse_gradient(_x + _inst.x, _y + _inst.y, _x2 + _inst.x, _y2 + _inst.y, _col1, _col2, false);
- }
- else
- {
- draw_ellipse_gradient(_x, _y, _x2, _y2, _col1, _col2, false);
- }
-}
-
-function action_splash_web(_url)
-{
- YoYo_OpenURL(_url);
-}
-
-function action_webpage(_url)
-{
- YoYo_OpenURL(_url);
-}
-
-function action_highscore_show(_background, _border, _col1, _col2, _fontname, _fontsize, _fontstyle)
-{
- var x, y;
- x = (g_pBuiltIn.room_width / 2) - 100;
- y = (g_pBuiltIn.room_height / 2) - 100;
- draw_highscore(x, y, x + 200, y + 200);
-}
-
-// #############################################################################################
-/// Function:
-/// Action to clear hiscores.
-///
-// #############################################################################################
-function action_highscore_clear()
-{
- highscore_clear();
- highscore_save();
-}
-
-
-// #############################################################################################
-/// Function:
-/// Action to toggle/clear/set fullscreen mode
-///
-///
-/// In: 0,1 or 2
-/// Out:
-///
-///
-// #############################################################################################
-function action_fullscreen(_mode) {
-/*
- var full;
-
- // toggle?
- if (_mode == 0)
- {
- if (window_get_fullscreen())
- {
- full = false;
- } else
- {
- full = false;
- }
- } else if (_mode == 1)
- {
- full = false; // into windowed
- } else if (_mode == 2)
- {
- full = true; // into fullscreen
- } else
- return;
-
-
- window_set_fullscreen(full);
-*/
-}
-
-
diff --git a/scripts/functions/Function_Background.js b/scripts/functions/Function_Background.js
index e1d2d4b8..065cc6d3 100644
--- a/scripts/functions/Function_Background.js
+++ b/scripts/functions/Function_Background.js
@@ -245,7 +245,9 @@ function background_create_color(_w,_h,_colour)
return g_pBackgroundManager.AddBackgroundImage(pNew);
}
+// @if function("background_create_colour")
var background_create_colour = background_create_color;
+// @endif
// #############################################################################################
/// Function:
diff --git a/scripts/functions/Function_D3D.js b/scripts/functions/Function_D3D.js
index bcbd1dc0..26e474f2 100644
--- a/scripts/functions/Function_D3D.js
+++ b/scripts/functions/Function_D3D.js
@@ -12,88 +12,206 @@
// --------------------------------------------------------------------------------------------------------------------------------------------------
// WebGL supported
-function d3d_start() { ErrorFunction("d3d_start()"); }
-function d3d_end() { ErrorFunction("d3d_end()"); }
-
-function d3d_set_hidden(enable) { ErrorFunction("d3d_set_hidden()"); }
-function d3d_set_culling(cull) { ErrorFunction("d3d_set_culling()"); }
-function d3d_set_shading(smooth) { ErrorFunction("d3d_set_shading()"); }
-function d3d_set_zwriteenable(on_off) { ErrorFunction("d3d_set_zwriteenable()"); }
-function d3d_set_depth(depth) { ErrorFunction("d3d_set_depth()"); }
-function draw_set_color_write_enable(red, green, blue, alpha) { ErrorFunction("draw_set_color_write_enable()"); }
-var draw_set_colour_write_enable = draw_set_color_write_enable;
-
-function d3d_set_lighting(enable) { ErrorFunction("d3d_set_shading()"); }
-function d3d_light_define_direction(ind,dx,dy,dz,col) { ErrorFunction("d3d_light_define_direction()"); }
-function d3d_light_define_point(ind,x,y,z,range,col) { ErrorFunction("d3d_light_define_point()"); }
-function d3d_light_enable(ind,enable) { ErrorFunction("d3d_light_enable()"); }
-function d3d_light_define_ambient( colour ) { ErrorFunction("d3d_light_define_ambient()"); }
-function d3d_set_fog(enable,color,start,end) { ErrorFunction("d3d_set_fog()"); }
-function d3d_light_get(index) { ErrorFunction("d3d_light_get()"); }
-function d3d_light_get_ambient(index) { ErrorFunction("d3d_light_get_ambient()"); }
-function d3d_get_lighting() { ErrorFunction("d3d_get_lighting()"); }
-
-
-function d3d_draw_floor(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat) { ErrorFunction("d3d_draw_floor()"); }
-function d3d_draw_ellipsoid(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat,steps) { ErrorFunction("d3d_draw_ellipsoid()"); }
-function d3d_draw_block(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat) { ErrorFunction("d3d_draw_block()"); }
-function d3d_draw_cylinder(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat,closed,steps) { ErrorFunction("d3d_draw_cylinder()"); }
-function d3d_draw_cone(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat,closed,steps) { ErrorFunction("d3d_draw_cone()"); }
-function d3d_draw_wall(x1,y1,z1,x2,y2,z2,texid,hrepeat,vrepeat) { ErrorFunction("d3d_draw_wall()"); }
-
-function d3d_model_create() { ErrorFunction("d3d_model_create()"); }
-function d3d_model_destroy(ind) { ErrorFunction("d3d_model_destroy()"); }
-function d3d_model_clear(ind) { ErrorFunction("d3d_model_clear()"); }
-function d3d_model_save(ind,fname) { ErrorFunction("d3d_model_save()"); }
-function d3d_model_load(ind,fname) { ErrorFunction("d3d_model_load()"); }
-function d3d_model_save_buffer(ind,fname) { ErrorFunction("d3d_model_save_buffer()"); }
-function d3d_model_load_buffer(ind,fname) { ErrorFunction("d3d_model_load_buffer()"); }
-
-
-
-function d3d_model_draw(ind,x,y,z,texid) { ErrorFunction("d3d_model_draw()"); }
-function d3d_model_primitive_begin(ind,kind) { ErrorFunction("d3d_model_primitive_begin()"); }
-function d3d_model_vertex(ind,x,y,z) { ErrorFunction("d3d_model_vertex()"); }
-function d3d_model_vertex_colour(ind, x, y, z, col, alpha) { ErrorFunction("d3d_model_vertex_colour()"); }
-function d3d_model_vertex_color(ind, x, y, z, col, alpha) { ErrorFunction("d3d_model_vertex_color()"); }
-function d3d_model_vertex_texture(ind,x,y,z,xtex,ytex) { ErrorFunction("d3d_model_vertex_texture()"); }
-function d3d_model_vertex_texture_colour(ind, x, y, z, xtex, ytex, col, alpha) { ErrorFunction("d3d_model_vertex_texture_colour()"); }
-function d3d_model_vertex_texture_color(ind, x, y, z, xtex, ytex, col, alpha) { ErrorFunction("d3d_model_vertex_texture_color()"); }
-function d3d_model_vertex_normal(ind,x,y,z,nx,ny,nz) { ErrorFunction("d3d_model_vertex_normal()"); }
-function d3d_model_vertex_normal_color(ind,x,y,z,nx,ny,nz,col,alpha) { ErrorFunction("d3d_model_vertex_normal_color()"); }
-function d3d_model_vertex_normal_texture(ind,x,y,z,nx,ny,nz,xtex,ytex) { ErrorFunction("d3d_model_vertex_normal_texture()"); }
-function d3d_model_vertex_normal_texture_color(ind, x, y, z, nx, ny, nz, xtex, ytex, col, alpha) { ErrorFunction("d3d_model_vertex_normal_texture_color()"); }
-function d3d_model_vertex_normal_texture_colour(ind, x, y, z, nx, ny, nz, xtex, ytex, col, alpha) { ErrorFunction("d3d_model_vertex_normal_texture_colour()"); }
-function d3d_model_primitive_end(ind) { ErrorFunction("d3d_model_primitive_end()"); }
-function d3d_model_block(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat) { ErrorFunction("d3d_model_block()"); }
-function d3d_model_cylinder(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,closed,steps) { ErrorFunction("d3d_model_cylinder()"); }
-function d3d_model_cone(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,closed,steps) { ErrorFunction("d3d_model_cone()"); }
-function d3d_model_ellipsoid(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,steps) { ErrorFunction("d3d_model_ellipsoid()"); }
-function d3d_model_wall(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat) { ErrorFunction("d3d_model_wall()"); }
-function d3d_model_floor(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat) { ErrorFunction("d3d_model_floor()"); }
-
-function d3d_set_perspective(enable) { ErrorFunction("d3d_set_perspective()"); }
-function d3d_set_projection(xfrom,yfrom,zfrom,xto,yto,zto,xup,yup,zup) { ErrorFunction("d3d_set_projection()"); }
-function d3d_set_projection_ext(xfrom,yfrom,zfrom,xto,yto,zto,xup,yup,zup,angle,aspect,zn,zf) { ErrorFunction("d3d_set_projection_ext()"); }
-function d3d_set_projection_ortho(x,y,w,h,angle) { ErrorFunction("d3d_set_projection_ortho()"); }
-function d3d_set_projection_perspective(x,y,w,h,angle) { ErrorFunction("d3d_set_projection_perspective()"); }
-
-function d3d_transform_set_identity() { ErrorFunction("d3d_transform_set_identity()"); }
-function d3d_transform_set_translation(xt,yt,zt) { ErrorFunction("d3d_transform_set_translation()"); }
-function d3d_transform_set_scaling(xs,ys,zs) { ErrorFunction("d3d_transform_set_scaling()"); }
-function d3d_transform_set_rotation_x(angle) { ErrorFunction("d3d_transform_set_rotation_x()"); }
-function d3d_transform_set_rotation_y(angle) { ErrorFunction("d3d_transform_set_rotation_y()"); }
-function d3d_transform_set_rotation_z(angle) { ErrorFunction("d3d_transform_set_rotation_z()"); }
-function d3d_transform_set_rotation_axis(xa,ya,za,angle) { ErrorFunction("d3d_transform_set_rotation_axis()"); }
-function d3d_transform_add_translation(xt,yt,zt) { ErrorFunction("d3d_transform_add_translation()"); }
-function d3d_transform_add_scaling(xs,ys,zs) { ErrorFunction("d3d_transform_add_scaling()"); }
-function d3d_transform_add_rotation_x(angle) { ErrorFunction("d3d_transform_add_rotation_x()"); }
-function d3d_transform_add_rotation_y(angle) { ErrorFunction("d3d_transform_add_rotation_y()"); }
-function d3d_transform_add_rotation_z(angle) { ErrorFunction("d3d_transform_add_rotation_axis()"); }
-function d3d_transform_add_rotation_axis(xa,ya,za,angle) { ErrorFunction("d3d_transform_add_rotation_z()"); }
-function d3d_transform_vertex(_x, _y, _z) { ErrorFunction("d3d_transform_vertex()"); }
-function matrix_get(_type) { ErrorFunction("matrix_get()"); }
-function matrix_set(_type, _matrix) { ErrorFunction("matrix_set()"); }
+function d3d_set_depth(){}
+function draw_set_color_write_enable(){}
+function draw_set_colour_write_enable(){}
+
+function d3d_set_lighting(){}
+function d3d_light_define_direction(){}
+function d3d_light_define_point(){}
+function d3d_light_enable(){}
+function d3d_light_define_ambient(){}
+function d3d_set_fog(){}
+function d3d_light_get(){}
+function d3d_light_get_ambient(){}
+function d3d_get_lighting(){}
+function d3d_set_perspective(){}
+
+function matrix_get(){}
+function matrix_set(){}
+
+function gpu_set_blendenable(){}
+function gpu_set_ztestenable(){}
+function gpu_set_zfunc(){}
+function gpu_set_zwriteenable(){}
+function gpu_set_fog(){}
+function gpu_set_cullmode(){}
+function gpu_set_blendmode(){}
+function gpu_set_blendmode_ext(){}
+function gpu_set_blendmode_ext_sepalpha(){}
+function gpu_set_colorwriteenable(){}
+function gpu_set_colourwriteenable(){}
+function gpu_set_alphatestenable(){}
+function gpu_set_alphatestref(){}
+function gpu_set_texfilter(){}
+function gpu_set_texfilter_ext(){}
+function gpu_set_texrepeat(){}
+function gpu_set_texrepeat_ext(){}
+function gpu_set_tex_filter(){}
+function gpu_set_tex_filter_ext(){}
+function gpu_set_tex_repeat(){}
+function gpu_set_tex_repeat_ext(){}
+
+function gpu_set_tex_mip_filter(){}
+function gpu_set_tex_mip_filter_ext(){}
+function gpu_set_tex_mip_bias(){}
+function gpu_set_tex_mip_bias_ext(){}
+function gpu_set_tex_min_mip(){}
+function gpu_set_tex_min_mip_ext(){}
+function gpu_set_tex_max_mip(){}
+function gpu_set_tex_max_mip_ext(){}
+function gpu_set_tex_max_aniso(){}
+function gpu_set_tex_max_aniso_ext(){}
+function gpu_set_tex_mip_enable(){}
+function gpu_set_tex_mip_enable_ext(){}
+
+function gpu_get_blendenable(){}
+function gpu_get_ztestenable(){}
+function gpu_get_zfunc(){}
+function gpu_get_zwriteenable(){}
+function gpu_get_fog(){}
+function gpu_get_cullmode(){}
+function gpu_get_blendmode(){}
+function gpu_get_blendmode_ext(){}
+function gpu_get_blendmode_ext_sepalpha(){}
+function gpu_get_blendmode_src(){}
+function gpu_get_blendmode_dest(){}
+function gpu_get_blendmode_srcalpha(){}
+function gpu_get_blendmode_destalpha(){}
+function gpu_get_colorwriteenable(){}
+function gpu_get_colourwriteenable(){}
+function gpu_get_alphatestenable(){}
+function gpu_get_alphatestref(){}
+function gpu_get_texfilter(){}
+function gpu_get_texfilter_ext(){}
+function gpu_get_texrepeat(){}
+function gpu_get_texrepeat_ext(){}
+function gpu_get_tex_filter(){}
+function gpu_get_tex_filter_ext(){}
+function gpu_get_tex_repeat(){}
+function gpu_get_tex_repeat_ext(){}
+
+function gpu_get_tex_mip_filter(){}
+function gpu_get_tex_mip_filter_ext(){}
+function gpu_get_tex_mip_bias(){}
+function gpu_get_tex_mip_bias_ext(){}
+function gpu_get_tex_min_mip(){}
+function gpu_get_tex_min_mip_ext(){}
+function gpu_get_tex_max_mip(){}
+function gpu_get_tex_max_mip_ext(){}
+function gpu_get_tex_max_aniso(){}
+function gpu_get_tex_max_aniso_ext(){}
+function gpu_get_tex_mip_enable(){}
+function gpu_get_tex_mip_enable_ext(){}
+
+function gpu_push_state(){}
+function gpu_pop_state(){}
+function gpu_get_state(){}
+function gpu_set_state(){}
+
+// @if feature("2d")
+(() => {
+ let _stub = (_name, _val) => () => ErrorFunction(_name, _val);
+ compile_if_used(d3d_set_depth = _stub("d3d_set_depth"));
+ compile_if_used(draw_set_color_write_enable = _stub("draw_set_color_write_enable"));
+ compile_if_used(draw_set_colour_write_enable = _stub("draw_set_colour_write_enable"));
+
+ compile_if_used(draw_set_lighting, d3d_set_lighting = _stub("d3d_set_lighting"));
+ compile_if_used(draw_light_define_direction, d3d_light_define_direction = _stub("d3d_light_define_direction"));
+ compile_if_used(draw_light_define_point, d3d_light_define_point = _stub("d3d_light_define_point"));
+ compile_if_used(draw_light_enable, d3d_light_enable = _stub("d3d_light_enable"));
+ compile_if_used(draw_light_define_ambient, d3d_light_define_ambient = _stub("d3d_light_define_ambient"));
+ compile_if_used(draw_light_get, d3d_light_get = _stub("d3d_light_get"));
+ compile_if_used(draw_light_get_ambient, d3d_light_get_ambient = _stub("d3d_light_get_ambient"));
+ compile_if_used(draw_get_lighting, d3d_get_lighting = _stub("d3d_get_lighting"));
+
+ compile_if_used(d3d_set_perspective = _stub("d3d_set_perspective"));
+ d3d_set_fog = _stub("d3d_set_fog"); // used by yyWebGL
+
+ compile_if_used(matrix_get = _stub("matrix_get"));
+ compile_if_used(matrix_set = _stub("matrix_set"));
+
+ compile_if_used(gpu_set_blendenable = _stub("gpu_set_blendenable"));
+ compile_if_used(gpu_set_ztestenable = _stub("gpu_set_ztestenable"));
+ compile_if_used(gpu_set_zfunc = _stub("gpu_set_zfunc"));
+ compile_if_used(gpu_set_zwriteenable = _stub("gpu_set_zwriteenable"));
+ compile_if_used(gpu_set_fog = _stub("gpu_set_fog"));
+ compile_if_used(gpu_set_cullmode = _stub("gpu_set_cullmode"));
+ compile_if_used(gpu_set_blendmode = _stub("gpu_set_blendmode"));
+ compile_if_used(gpu_set_blendmode_ext = _stub("gpu_set_blendmode_ext"));
+ compile_if_used(gpu_set_blendmode_ext_sepalpha = _stub("gpu_set_blendmode_ext_sepalpha"));
+ compile_if_used(gpu_set_colorwriteenable = _stub("gpu_set_colorwriteenable"));
+ compile_if_used(gpu_set_colourwriteenable = _stub("gpu_set_colourwriteenable"));
+ compile_if_used(gpu_set_alphatestenable = _stub("gpu_set_alphatestenable"));
+ compile_if_used(gpu_set_alphatestref = _stub("gpu_set_alphatestref"));
+ compile_if_used(gpu_set_texfilter = _stub("gpu_set_texfilter"));
+ gpu_set_texfilter_ext = _stub("gpu_set_texfilter_ext"); // used by SDF
+ compile_if_used(gpu_set_texrepeat = _stub("gpu_set_texrepeat"));
+ gpu_set_texrepeat_ext = _stub("gpu_set_texrepeat_ext"); // used by yyEffects
+ compile_if_used(gpu_set_tex_filter = _stub("gpu_set_tex_filter"));
+ gpu_set_tex_filter_ext = _stub("gpu_set_tex_filter_ext"); // used by yyEffects
+ compile_if_used(gpu_set_tex_repeat = _stub("gpu_set_tex_repeat"));
+ compile_if_used(gpu_set_tex_repeat_ext = _stub("gpu_set_tex_repeat_ext"));
+
+ compile_if_used(gpu_set_tex_mip_filter = _stub("gpu_set_tex_mip_filter"));
+ compile_if_used(gpu_set_tex_mip_filter_ext = _stub("gpu_set_tex_mip_filter_ext"));
+ compile_if_used(gpu_set_tex_mip_bias = _stub("gpu_set_tex_mip_bias"));
+ compile_if_used(gpu_set_tex_mip_bias_ext = _stub("gpu_set_tex_mip_bias_ext"));
+ compile_if_used(gpu_set_tex_min_mip = _stub("gpu_set_tex_min_mip"));
+ compile_if_used(gpu_set_tex_min_mip_ext = _stub("gpu_set_tex_min_mip_ext"));
+ compile_if_used(gpu_set_tex_max_mip = _stub("gpu_set_tex_max_mip"));
+ compile_if_used(gpu_set_tex_max_mip_ext = _stub("gpu_set_tex_max_mip_ext"));
+ compile_if_used(gpu_set_tex_max_aniso = _stub("gpu_set_tex_max_aniso"));
+ compile_if_used(gpu_set_tex_max_aniso_ext = _stub("gpu_set_tex_max_aniso_ext"));
+ compile_if_used(gpu_set_tex_mip_enable = _stub("gpu_set_tex_mip_enable"));
+ compile_if_used(gpu_set_tex_mip_enable_ext = _stub("gpu_set_tex_mip_enable_ext"));
+
+ compile_if_used(gpu_get_blendenable = _stub("gpu_get_blendenable"));
+ gpu_get_ztestenable = _stub("gpu_get_ztestenable"); // used in a few places
+ compile_if_used(gpu_get_zfunc = _stub("gpu_get_zfunc"));
+ gpu_get_zwriteenable = _stub("gpu_get_zwriteenable");
+ compile_if_used(gpu_get_fog = _stub("gpu_get_fog"));
+ gpu_get_cullmode = _stub("gpu_get_cullmode");
+ compile_if_used(gpu_get_blendmode = _stub("gpu_get_blendmode"));
+ compile_if_used(gpu_get_blendmode_ext = _stub("gpu_get_blendmode_ext"));
+ compile_if_used(gpu_get_blendmode_ext_sepalpha = _stub("gpu_get_blendmode_ext_sepalpha"));
+ compile_if_used(gpu_get_blendmode_src = _stub("gpu_get_blendmode_src"));
+ compile_if_used(gpu_get_blendmode_dest = _stub("gpu_get_blendmode_dest"));
+ compile_if_used(gpu_get_blendmode_srcalpha = _stub("gpu_get_blendmode_srcalpha"));
+ compile_if_used(gpu_get_blendmode_destalpha = _stub("gpu_get_blendmode_destalpha"));
+ compile_if_used(gpu_get_colorwriteenable = _stub("gpu_get_colorwriteenable"));
+ compile_if_used(gpu_get_colourwriteenable = _stub("gpu_get_colourwriteenable"));
+ gpu_get_alphatestenable = _stub("gpu_get_alphatestenable"); // used by application_surface drawer
+ compile_if_used(gpu_get_alphatestref = _stub("gpu_get_alphatestref"));
+ compile_if_used(gpu_get_texfilter = _stub("gpu_get_texfilter"));
+ compile_if_used(gpu_get_texfilter_ext = _stub("gpu_get_texfilter_ext"));
+ compile_if_used(gpu_get_texrepeat = _stub("gpu_get_texrepeat"));
+ compile_if_used(gpu_get_texrepeat_ext = _stub("gpu_get_texrepeat_ext"));
+ compile_if_used(gpu_get_tex_filter = _stub("gpu_get_tex_filter"));
+ compile_if_used(gpu_get_tex_filter_ext = _stub("gpu_get_tex_filter_ext"));
+ compile_if_used(gpu_get_tex_repeat = _stub("gpu_get_tex_repeat"));
+ compile_if_used(gpu_get_tex_repeat_ext = _stub("gpu_get_tex_repeat_ext"));
+
+ compile_if_used(gpu_get_tex_mip_filter = _stub("gpu_get_tex_mip_filter"));
+ compile_if_used(gpu_get_tex_mip_filter_ext = _stub("gpu_get_tex_mip_filter_ext"));
+ compile_if_used(gpu_get_tex_mip_bias = _stub("gpu_get_tex_mip_bias"));
+ compile_if_used(gpu_get_tex_mip_bias_ext = _stub("gpu_get_tex_mip_bias_ext"));
+ compile_if_used(gpu_get_tex_min_mip = _stub("gpu_get_tex_min_mip"));
+ compile_if_used(gpu_get_tex_min_mip_ext = _stub("gpu_get_tex_min_mip_ext"));
+ compile_if_used(gpu_get_tex_max_mip = _stub("gpu_get_tex_max_mip"));
+ compile_if_used(gpu_get_tex_max_mip_ext = _stub("gpu_get_tex_max_mip_ext"));
+ compile_if_used(gpu_get_tex_max_aniso = _stub("gpu_get_tex_max_aniso"));
+ compile_if_used(gpu_get_tex_max_aniso_ext = _stub("gpu_get_tex_max_aniso_ext"));
+ compile_if_used(gpu_get_tex_mip_enable = _stub("gpu_get_tex_mip_enable"));
+ compile_if_used(gpu_get_tex_mip_enable_ext = _stub("gpu_get_tex_mip_enable_ext"));
+
+ compile_if_used(gpu_push_state = _stub("gpu_push_state"));
+ compile_if_used(gpu_pop_state = _stub("gpu_pop_state"));
+ compile_if_used(gpu_get_state = _stub("gpu_get_state"));
+ compile_if_used(gpu_set_state = _stub("gpu_set_state"));
+})();
+// @endif
+
// RK :: Changed these as they are mathematical in nature and not specific to WebGL
// These should be separated out from WebGL to a new maths class
var matrix_build = WebGL_Matrix_Build;
@@ -114,103 +232,7 @@ var matrix_build_projection_perspective = WebGL_matrix_build_projection_perspect
var matrix_build_projection_perspective_fov = WebGL_matrix_build_projection_perspective_fov;
-
-function d3d_transform_stack_clear() { ErrorFunction("d3d_transform_stack_clear()"); }
-function d3d_transform_stack_empty() { ErrorFunction("d3d_transform_stack_empty()"); }
-function d3d_transform_stack_push() { ErrorFunction("d3d_transform_stack_push()"); }
-function d3d_transform_stack_pop() { ErrorFunction("d3d_transform_stack_pop()"); }
-function d3d_transform_stack_top() { ErrorFunction("d3d_transform_stack_top()"); }
-function d3d_transform_stack_discard() { ErrorFunction("d3d_transform_stack_discard()"); }
-
-
-function gpu_set_blendenable(enable) { ErrorFunction("gpu_set_blendenable()"); }
-function gpu_set_ztestenable(enable) { ErrorFunction("gpu_set_ztestenable()"); }
-function gpu_set_depth(_depth) { ErrorFunction("gpu_set_depth()"); }
-function gpu_set_zfunc(cmp_func) { ErrorFunction("gpu_set_zfunc()"); }
-function gpu_set_zwriteenable(enable) { ErrorFunction("gpu_set_zwriteenable()"); }
-//function gpu_set_lightingenable(enable) { ErrorFunction("gpu_set_lightingenable()"); }
-function gpu_set_fog(enable,col,start,end) { ErrorFunction("gpu_set_fog()"); }
-function gpu_set_cullmode(cullmode) { ErrorFunction("gpu_set_cullmode()"); }
-function gpu_set_blendmode(mode) { ErrorFunction("gpu_set_blendmode()"); }
-function gpu_set_blendmode_ext(src,dest) { ErrorFunction("gpu_set_blendmode_ext()"); }
-function gpu_set_blendmode_ext_sepalpha(src,dest,srcalpha,destalpha) { ErrorFunction("gpu_set_blendmode_ext_sepalpha()"); }
-function gpu_set_colorwriteenable(red,green,blue,alpha) { ErrorFunction("gpu_set_colorwriteenable()"); }
-function gpu_set_colourwriteenable(red,green,blue,alpha) { ErrorFunction("gpu_set_colourwriteenable()"); }
-function gpu_set_alphatestenable(enable) { ErrorFunction("gpu_set_alphatestenable()"); }
-function gpu_set_alphatestref(value) { ErrorFunction("gpu_set_alphatestref()"); }
-function gpu_set_texfilter(linear) { ErrorFunction("gpu_set_texfilter()"); }
-function gpu_set_texfilter_ext(sampler_id,linear) { ErrorFunction("gpu_set_texfilter_ext()"); }
-function gpu_set_texrepeat(repeat) { ErrorFunction("gpu_set_texrepeat()"); }
-function gpu_set_texrepeat_ext(sampler_id,repeat) { ErrorFunction("gpu_set_texrepeat_ext()"); }
-function gpu_set_tex_filter(linear) { ErrorFunction("gpu_set_tex_filter()"); }
-function gpu_set_tex_filter_ext(sampler_id, linear) { ErrorFunction("gpu_set_tex_filter_ext()"); }
-function gpu_set_tex_repeat(repeat) { ErrorFunction("gpu_set_tex_repeat()"); }
-function gpu_set_tex_repeat_ext(sampler_id, repeat) { ErrorFunction("gpu_set_tex_repeat_ext()"); }
-
-function gpu_set_tex_mip_filter(filter) { ErrorFunction("gpu_set_tex_mip_filter(filter)"); }
-function gpu_set_tex_mip_filter_ext(sampler_id, filter) { ErrorFunction("gpu_set_tex_mip_filter_ext(sampler_id, filter)"); }
-function gpu_set_tex_mip_bias(bias) { ErrorFunction("gpu_set_tex_mip_bias(bias)"); }
-function gpu_set_tex_mip_bias_ext(sampler_id, bias) { ErrorFunction("gpu_set_tex_mip_bias_ext(sampler_id, bias)"); }
-function gpu_set_tex_min_mip(minmip) { ErrorFunction("gpu_set_tex_min_mip(minmip)"); }
-function gpu_set_tex_min_mip_ext(sampler_id, minmip) { ErrorFunction("gpu_set_tex_min_mip_ext(sampler_id, minmip)"); }
-function gpu_set_tex_max_mip(maxmip) { ErrorFunction("gpu_set_tex_max_mip(maxmip)"); }
-function gpu_set_tex_max_mip_ext(sampler_id, maxmip) { ErrorFunction("gpu_set_tex_max_mip_ext(sampler_id, maxmip)"); }
-function gpu_set_tex_max_aniso(maxaniso) { ErrorFunction("gpu_set_tex_max_aniso(maxaniso)"); }
-function gpu_set_tex_max_aniso_ext(sampler_id, maxaniso) { ErrorFunction("gpu_set_tex_max_aniso_ext(sampler_id, maxaniso)"); }
-function gpu_set_tex_mip_enable(setting) { ErrorFunction("gpu_set_tex_mip_enable(setting)"); }
-function gpu_set_tex_mip_enable_ext(sampler_id, setting) { ErrorFunction("gpu_set_tex_mip_enable_ext(sampler_id, setting)"); }
-
-
-function gpu_get_blendenable() { ErrorFunction("gpu_get_blendenable()"); }
-function gpu_get_ztestenable() { ErrorFunction("gpu_get_ztestenable()"); }
-function gpu_get_depth() { ErrorFunction("gpu_get_depth()"); }
-function gpu_get_zfunc() { ErrorFunction("gpu_get_zfunc()"); }
-function gpu_get_zwriteenable() { ErrorFunction("gpu_get_zwriteenable()"); }
-//function gpu_get_lightingenable() { ErrorFunction("gpu_get_lightingenable()"); }
-function gpu_get_fog() { ErrorFunction("gpu_get_fog()"); }
-function gpu_get_cullmode() { ErrorFunction("gpu_get_cullmode()"); }
-function gpu_get_blendmode() { ErrorFunction("gpu_get_blendmode()"); }
-function gpu_get_blendmode_ext() { ErrorFunction("gpu_get_blendmode_ext()"); }
-function gpu_get_blendmode_ext_sepalpha() { ErrorFunction("gpu_get_blendmode_ext_sepalpha()"); }
-function gpu_get_blendmode_src() { ErrorFunction("gpu_get_blendmode_src()"); }
-function gpu_get_blendmode_dest() { ErrorFunction("gpu_get_blendmode_dest()"); }
-function gpu_get_blendmode_srcalpha() { ErrorFunction("gpu_get_blendmode_srcalpha()"); }
-function gpu_get_blendmode_destalpha() { ErrorFunction("gpu_get_blendmode_destalpha()"); }
-function gpu_get_colorwriteenable() { ErrorFunction("gpu_get_colorwriteenable()"); }
-function gpu_get_colourwriteenable() { ErrorFunction("gpu_get_colourwriteenable()"); }
-function gpu_get_alphatestenable() { ErrorFunction("gpu_get_alphatestenable()"); }
-function gpu_get_alphatestref() { ErrorFunction("gpu_get_alphatestref()"); }
-function gpu_get_texfilter() { ErrorFunction("gpu_get_texfilter()"); }
-function gpu_get_texfilter_ext(sampler_id) { ErrorFunction("gpu_get_texfilter_ext()"); }
-function gpu_get_texrepeat() { ErrorFunction("gpu_get_texrepeat()"); }
-function gpu_get_texrepeat_ext(sampler_id) { ErrorFunction("gpu_get_texrepeat_ext()"); }
-function gpu_get_tex_filter() { ErrorFunction("gpu_get_tex_filter()"); }
-function gpu_get_tex_filter_ext(sampler_id) { ErrorFunction("gpu_get_tex_filter_ext()"); }
-function gpu_get_tex_repeat() { ErrorFunction("gpu_get_tex_repeat()"); }
-function gpu_get_tex_repeat_ext(sampler_id) { ErrorFunction("gpu_get_tex_repeat_ext()"); }
-
-function gpu_get_tex_mip_filter() { ErrorFunction("gpu_get_tex_mip_filter()"); }
-function gpu_get_tex_mip_filter_ext(sampler_id) { ErrorFunction("gpu_get_tex_mip_filter_ext(sampler_id)"); }
-function gpu_get_tex_mip_bias() { ErrorFunction("gpu_get_tex_mip_bias()"); }
-function gpu_get_tex_mip_bias_ext(sampler_id) { ErrorFunction("gpu_get_tex_mip_bias_ext(sampler_id)"); }
-function gpu_get_tex_min_mip() { ErrorFunction("gpu_get_tex_min_mip()"); }
-function gpu_get_tex_min_mip_ext(sampler_id) { ErrorFunction("gpu_get_tex_min_mip_ext(sampler_id)"); }
-function gpu_get_tex_max_mip() { ErrorFunction("gpu_get_tex_max_mip()"); }
-function gpu_get_tex_max_mip_ext(sampler_id) { ErrorFunction("gpu_get_tex_max_mip_ext(sampler_id)"); }
-function gpu_get_tex_max_aniso() { ErrorFunction("gpu_get_tex_max_aniso()"); }
-function gpu_get_tex_max_aniso_ext(sampler_id) { ErrorFunction("gpu_get_tex_max_aniso_ext(sampler_id)"); }
-function gpu_get_tex_mip_enable() { ErrorFunction("gpu_get_tex_mip_enable()"); }
-function gpu_get_tex_mip_enable_ext(sampler_id) { ErrorFunction("gpu_get_tex_mip_enable_ext(sampler_id)"); }
-
-function gpu_push_state() { ErrorFunction("gpu_push_state()"); }
-function gpu_pop_state() { ErrorFunction("gpu_pop_state()"); }
-
-function gpu_get_state() { ErrorFunction("gpu_get_state()"); }
-function gpu_set_state(map) { ErrorFunction("gpu_set_state()"); }
-
// --------------------------------------------------------------------------------------------------------------------------------------------------
-
-var g_3DModels = [];
var g_maxmatstack = 50;
var g_matstacktop = 0;
@@ -228,1379 +250,366 @@ function InitD3DFunctions() {
return;
}
// 3D state
- d3d_start = WebGL_d3d_start_RELEASE;
- d3d_end = WebGL_d3d_end_RELEASE;
-
- d3d_set_culling = WebGL_d3d_set_culling_RELEASE;
- d3d_set_shading = WebGL_d3d_set_shading_RELEASE;
- d3d_set_zwriteenable = WebGL_d3d_set_zwriteenable_RELEASE;
d3d_set_depth = WebGL_d3d_set_depth_RELEASE;
- d3d_set_hidden = WebGL_d3d_set_hidden_RELEASE;
- draw_set_color_write_enable = WebGL_draw_set_color_write_enable_RELEASE;
- draw_set_colour_write_enable = WebGL_draw_set_color_write_enable_RELEASE;
+ compile_if_used(draw_set_color_write_enable = WebGL_draw_set_color_write_enable_RELEASE);
+ compile_if_used(draw_set_colour_write_enable = WebGL_draw_set_color_write_enable_RELEASE);
// Matrix operations
d3d_set_perspective = WebGL_d3d_set_perspective_RELEASE;
- d3d_set_projection = WebGL_d3d_set_projection_RELEASE;
- d3d_set_projection_ext = WebGL_d3d_set_projection_ext_RELEASE;
- d3d_set_projection_ortho = WebGL_d3d_set_projection_ortho_RELEASE;
- d3d_set_projection_perspective = WebGL_d3d_set_projection_perspective_RELEASE;
-
- d3d_transform_set_identity = WebGL_d3d_transform_set_identity_RELEASE;
- d3d_transform_set_translation = WebGL_d3d_transform_set_translation_RELEASE;
- d3d_transform_set_scaling = WebGL_d3d_transform_set_scaling_RELEASE;
- d3d_transform_set_rotation_x = WebGL_d3d_transform_set_rotation_x_RELEASE;
- d3d_transform_set_rotation_y = WebGL_d3d_transform_set_rotation_y_RELEASE;
- d3d_transform_set_rotation_z = WebGL_d3d_transform_set_rotation_z_RELEASE;
- d3d_transform_set_rotation_axis = WebGL_d3d_transform_set_rotation_axis_RELEASE;
- d3d_transform_add_translation = WebGL_d3d_transform_add_translation_RELEASE;
- d3d_transform_add_scaling = WebGL_d3d_transform_add_scaling_RELEASE;
- d3d_transform_add_rotation_x = WebGL_d3d_transform_add_rotation_x_RELEASE;
- d3d_transform_add_rotation_y = WebGL_d3d_transform_add_rotation_y_RELEASE;
- d3d_transform_add_rotation_z = WebGL_d3d_transform_add_rotation_z_RELEASE;
- d3d_transform_add_rotation_axis = WebGL_d3d_transform_add_rotation_axis_RELEASE;
- d3d_transform_vertex = WebGL_d3d_transform_vertex_RELEASE;
-
- d3d_transform_stack_clear = WebGL_d3d_transform_stack_clear_RELEASE;
- d3d_transform_stack_empty = WebGL_d3d_transform_stack_empty_RELEASE;
- d3d_transform_stack_push = WebGL_d3d_transform_stack_push_RELEASE;
- d3d_transform_stack_pop = WebGL_d3d_transform_stack_pop_RELEASE;
- d3d_transform_stack_top = WebGL_d3d_transform_stack_top_RELEASE;
- d3d_transform_stack_discard = WebGL_d3d_transform_stack_discard_RELEASE;
-
- // Stock geometry primitive drawing routines
- d3d_draw_floor = WebGL_d3d_draw_floor_RELEASE;
- d3d_draw_ellipsoid = WebGL_d3d_draw_ellipsoid_RELEASE;
- d3d_draw_block = WebGL_d3d_draw_block_RELEASE;
- d3d_draw_cylinder = WebGL_d3d_draw_cylinder_RELEASE;
- d3d_draw_cone = WebGL_d3d_draw_cone_RELEASE;
- d3d_draw_wall = WebGL_d3d_draw_wall_RELEASE;
-
// Lighting
- d3d_set_lighting = WebGL_d3d_set_lighting_RELEASE;
- d3d_light_define_direction = WebGL_d3d_light_define_direction_RELEASE;
- d3d_light_define_point = WebGL_d3d_light_define_point_RELEASE;
- d3d_light_enable = WebGL_d3d_light_enable_RELEASE;
- d3d_light_define_ambient = WebGL_d3d_light_define_ambient_RELEASE;
+ compile_if_used(draw_set_lighting, d3d_set_lighting = WebGL_d3d_set_lighting_RELEASE);
+ compile_if_used(draw_light_define_direction, d3d_light_define_direction = WebGL_d3d_light_define_direction_RELEASE);
+ compile_if_used(draw_light_define_point, d3d_light_define_point = WebGL_d3d_light_define_point_RELEASE);
+ compile_if_used(draw_light_enable, d3d_light_enable = WebGL_d3d_light_enable_RELEASE);
+ compile_if_used(draw_light_define_ambient, d3d_light_define_ambient = WebGL_d3d_light_define_ambient_RELEASE);
+ compile_if_used(draw_light_get, d3d_light_get = WebGL_d3d_light_get_RELEASE);
+ compile_if_used(draw_light_get_ambient, d3d_light_get_ambient = WebGL_d3d_light_get_ambient_RELEASE);
+ compile_if_used(draw_get_lighting, d3d_get_lighting = WebGL_d3d_get_lighting_RELEASE);
d3d_set_fog = WebGL_d3d_set_fog_RELEASE;
- d3d_light_get = WebGL_d3d_light_get_RELEASE;
- d3d_light_get_ambient = WebGL_d3d_light_get_ambient_RELEASE;
- d3d_get_lighting = WebGL_d3d_get_lighting_RELEASE;
-
- // 3D models
- d3d_model_create = WebGL_d3d_model_create_RELEASE;
- d3d_model_destroy = WebGL_d3d_model_destroy_RELEASE;
- d3d_model_clear = WebGL_d3d_model_clear_RELEASE;
- d3d_model_save = WebGL_d3d_model_save_RELEASE;
- d3d_model_load = WebGL_d3d_model_load_RELEASE;
- d3d_model_save_buffer = WebGL_d3d_model_save_buffer_RELEASE;
- d3d_model_load_buffer = WebGL_d3d_model_load_buffer_RELEASE;
- d3d_model_draw = WebGL_d3d_model_draw_RELEASE;
- d3d_model_primitive_begin = WebGL_d3d_model_primitive_begin_RELEASE;
- d3d_model_vertex = WebGL_d3d_model_vertex_RELEASE;
- d3d_model_vertex_color = WebGL_d3d_model_vertex_color_RELEASE;
- d3d_model_vertex_colour = WebGL_d3d_model_vertex_color_RELEASE;
- d3d_model_vertex_texture = WebGL_d3d_model_vertex_texture_RELEASE;
- d3d_model_vertex_texture_color = WebGL_d3d_model_vertex_texture_color_RELEASE;
- d3d_model_vertex_texture_colour = WebGL_d3d_model_vertex_texture_color_RELEASE;
- d3d_model_vertex_normal = WebGL_d3d_model_vertex_normal_RELEASE;
- d3d_model_vertex_normal_color = WebGL_d3d_model_vertex_normal_color_RELEASE;
- d3d_model_vertex_normal_texture = WebGL_d3d_model_vertex_normal_texture_RELEASE;
- d3d_model_vertex_normal_texture_color = WebGL_d3d_model_vertex_normal_texture_color_RELEASE;
- d3d_model_primitive_end = WebGL_d3d_model_primitive_end_RELEASE;
-
- d3d_model_block = WebGL_d3d_model_block_RELEASE;
- d3d_model_cylinder = WebGL_d3d_model_cylinder_RELEASE;
- d3d_model_cone = WebGL_d3d_model_cone_RELEASE;
- d3d_model_ellipsoid = WebGL_d3d_model_ellipsoid_RELEASE;
- d3d_model_wall = WebGL_d3d_model_wall_RELEASE;
- d3d_model_floor = WebGL_d3d_model_floor_RELEASE;
-
- matrix_get = WebGL_Matrix_Get;
- matrix_set = WebGL_Matrix_Set;
- matrix_build = WebGL_Matrix_Build;
- matrix_multiply = WebGL_Matrix_Multiply;
- matrix_transform_vertex = WebGL_Matrix_Transform_Vertex;
-
- matrix_stack_push = WebGL_matrix_stack_push;
- matrix_stack_pop = WebGL_matrix_stack_pop;
- matrix_stack_set = WebGL_matrix_stack_set;
- matrix_stack_clear = WebGL_matrix_stack_clear;
- matrix_stack_top = WebGL_matrix_stack_top;
- matrix_stack_is_empty = WebGL_matrix_stack_is_empty;
+
+ compile_if_used(matrix_get = WebGL_Matrix_Get);
+ compile_if_used(matrix_set = WebGL_Matrix_Set);
+ // rest of the matrix functions are already assigned
// GPU functions
- gpu_set_blendmode = WebGL_gpu_set_blendmode;
- gpu_set_blendenable = WebGL_gpu_set_blendenable;
- gpu_set_ztestenable = WebGL_gpu_set_ztestenable;
- gpu_set_depth = WebGL_gpu_set_depth;
- gpu_set_zfunc = WebGL_gpu_set_zfunc;
- gpu_set_zwriteenable = WebGL_gpu_set_zwriteenable;
- gpu_set_fog = WebGL_gpu_set_fog;
- gpu_set_cullmode = WebGL_gpu_set_cullmode;
- gpu_set_blendmode = WebGL_gpu_set_blendmode;
- gpu_set_blendmode_ext = WebGL_gpu_set_blendmode_ext;
- gpu_set_blendmode_ext_sepalpha = WebGL_gpu_set_blendmode_ext_sepalpha;
- gpu_set_colorwriteenable = WebGL_gpu_set_colorwriteenable;
- gpu_set_colourwriteenable = WebGL_gpu_set_colourwriteenable;
- gpu_set_alphatestenable = WebGL_gpu_set_alphatestenable;
- gpu_set_alphatestref = WebGL_gpu_set_alphatestref;
- gpu_set_texfilter = WebGL_gpu_set_texfilter;
+ compile_if_used(gpu_set_blendmode = WebGL_gpu_set_blendmode);
+ compile_if_used(gpu_set_blendenable = WebGL_gpu_set_blendenable);
+ compile_if_used(gpu_set_ztestenable = WebGL_gpu_set_ztestenable);
+ compile_if_used(gpu_set_depth = WebGL_gpu_set_depth);
+ compile_if_used(gpu_set_zfunc = WebGL_gpu_set_zfunc);
+ compile_if_used(gpu_set_zwriteenable = WebGL_gpu_set_zwriteenable);
+ compile_if_used(gpu_set_fog = WebGL_gpu_set_fog);
+ compile_if_used(gpu_set_cullmode = WebGL_gpu_set_cullmode);
+ compile_if_used(gpu_set_blendmode = WebGL_gpu_set_blendmode);
+ compile_if_used(gpu_set_blendmode_ext = WebGL_gpu_set_blendmode_ext);
+ compile_if_used(gpu_set_blendmode_ext_sepalpha = WebGL_gpu_set_blendmode_ext_sepalpha);
+ compile_if_used(gpu_set_colorwriteenable = WebGL_gpu_set_colorwriteenable);
+ compile_if_used(gpu_set_colourwriteenable = WebGL_gpu_set_colourwriteenable);
+ compile_if_used(gpu_set_alphatestenable = WebGL_gpu_set_alphatestenable);
+ compile_if_used(gpu_set_alphatestref = WebGL_gpu_set_alphatestref);
+ compile_if_used(gpu_set_texfilter = WebGL_gpu_set_texfilter);
gpu_set_texfilter_ext = WebGL_gpu_set_texfilter_ext;
- gpu_set_texrepeat = WebGL_gpu_set_texrepeat;
+ compile_if_used(gpu_set_texrepeat = WebGL_gpu_set_texrepeat);
gpu_set_texrepeat_ext = WebGL_gpu_set_texrepeat_ext;
- gpu_set_tex_filter = WebGL_gpu_set_texfilter;
+ compile_if_used(gpu_set_tex_filter = WebGL_gpu_set_texfilter);
gpu_set_tex_filter_ext = WebGL_gpu_set_texfilter_ext;
- gpu_set_tex_repeat = WebGL_gpu_set_texrepeat;
- gpu_set_tex_repeat_ext = WebGL_gpu_set_texrepeat_ext;
-
- gpu_set_tex_mip_filter = WebGL_gpu_set_tex_mip_filter;
- gpu_set_tex_mip_filter_ext = WebGL_gpu_set_tex_mip_filter_ext;
- gpu_set_tex_mip_bias = WebGL_gpu_set_tex_mip_bias;
- gpu_set_tex_mip_bias_ext = WebGL_gpu_set_tex_mip_bias_ext;
- gpu_set_tex_min_mip = WebGL_gpu_set_tex_min_mip;
- gpu_set_tex_min_mip_ext = WebGL_gpu_set_tex_min_mip_ext;
- gpu_set_tex_max_mip = WebGL_gpu_set_tex_max_mip;
- gpu_set_tex_max_mip_ext = WebGL_gpu_set_tex_max_mip_ext;
- gpu_set_tex_max_aniso = WebGL_gpu_set_tex_max_aniso;
- gpu_set_tex_max_aniso_ext = WebGL_gpu_set_tex_max_aniso_ext;
- gpu_set_tex_mip_enable = WebGL_gpu_set_tex_mip_enable;
- gpu_set_tex_mip_enable_ext = WebGL_gpu_set_tex_mip_enable_ext;
-
- gpu_get_blendenable = WebGL_gpu_get_blendenable;
+ compile_if_used(gpu_set_tex_repeat = WebGL_gpu_set_texrepeat);
+ compile_if_used(gpu_set_tex_repeat_ext = WebGL_gpu_set_texrepeat_ext);
+
+ compile_if_used(gpu_set_tex_mip_filter = WebGL_gpu_set_tex_mip_filter);
+ compile_if_used(gpu_set_tex_mip_filter_ext = WebGL_gpu_set_tex_mip_filter_ext);
+ compile_if_used(gpu_set_tex_mip_bias = WebGL_gpu_set_tex_mip_bias);
+ compile_if_used(gpu_set_tex_mip_bias_ext = WebGL_gpu_set_tex_mip_bias_ext);
+ compile_if_used(gpu_set_tex_min_mip = WebGL_gpu_set_tex_min_mip);
+ compile_if_used(gpu_set_tex_min_mip_ext = WebGL_gpu_set_tex_min_mip_ext);
+ compile_if_used(gpu_set_tex_max_mip = WebGL_gpu_set_tex_max_mip);
+ compile_if_used(gpu_set_tex_max_mip_ext = WebGL_gpu_set_tex_max_mip_ext);
+ compile_if_used(gpu_set_tex_max_aniso = WebGL_gpu_set_tex_max_aniso);
+ compile_if_used(gpu_set_tex_max_aniso_ext = WebGL_gpu_set_tex_max_aniso_ext);
+ compile_if_used(gpu_set_tex_mip_enable = WebGL_gpu_set_tex_mip_enable);
+ compile_if_used(gpu_set_tex_mip_enable_ext = WebGL_gpu_set_tex_mip_enable_ext);
+
+ compile_if_used(gpu_get_blendenable = WebGL_gpu_get_blendenable);
gpu_get_ztestenable = WebGL_gpu_get_ztestenable;
- gpu_get_depth = WebGL_gpu_get_depth;
- gpu_get_zfunc = WebGL_gpu_get_zfunc;
+ compile_if_used(gpu_get_depth = WebGL_gpu_get_depth);
+ compile_if_used(gpu_get_zfunc = WebGL_gpu_get_zfunc);
gpu_get_zwriteenable = WebGL_gpu_get_zwriteenable;
- gpu_get_fog = WebGL_gpu_get_fog;
+ compile_if_used(gpu_get_fog = WebGL_gpu_get_fog);
gpu_get_cullmode = WebGL_gpu_get_cullmode;
- gpu_get_blendmode = WebGL_gpu_get_blendmode;
- gpu_get_blendmode_ext = WebGL_gpu_get_blendmode_ext;
- gpu_get_blendmode_ext_sepalpha = WebGL_gpu_get_blendmode_ext_sepalpha;
- gpu_get_blendmode_src = WebGL_gpu_get_blendmode_src;
- gpu_get_blendmode_dest = WebGL_gpu_get_blendmode_dest;
- gpu_get_blendmode_srcalpha = WebGL_gpu_get_blendmode_srcalpha;
- gpu_get_blendmode_destalpha = WebGL_gpu_get_blendmode_destalpha;
- gpu_get_colorwriteenable = WebGL_gpu_get_colorwriteenable;
- gpu_get_colourwriteenable = WebGL_gpu_get_colourwriteenable;
- gpu_get_alphatestenable = WebGL_gpu_get_alphatestenable;
- gpu_get_alphatestref = WebGL_gpu_get_alphatestref;
- gpu_get_texfilter = WebGL_gpu_get_texfilter;
- gpu_get_texfilter_ext = WebGL_gpu_get_texfilter_ext;
- gpu_get_texrepeat = WebGL_gpu_get_texrepeat;
- gpu_get_texrepeat_ext = WebGL_gpu_get_texrepeat_ext;
- gpu_get_tex_filter = WebGL_gpu_get_texfilter;
- gpu_get_tex_filter_ext = WebGL_gpu_get_texfilter_ext;
- gpu_get_tex_repeat = WebGL_gpu_get_texrepeat;
- gpu_get_tex_repeat_ext = WebGL_gpu_get_texrepeat_ext;
-
- gpu_get_tex_mip_filter = WebGL_gpu_get_tex_mip_filter;
- gpu_get_tex_mip_filter_ext = WebGL_gpu_get_tex_mip_filter_ext;
- gpu_get_tex_mip_bias = WebGL_gpu_get_tex_mip_bias;
- gpu_get_tex_mip_bias_ext = WebGL_gpu_get_tex_mip_bias_ext;
- gpu_get_tex_min_mip = WebGL_gpu_get_tex_min_mip;
- gpu_get_tex_min_mip_ext = WebGL_gpu_get_tex_min_mip_ext;
- gpu_get_tex_max_mip = WebGL_gpu_get_tex_max_mip;
- gpu_get_tex_max_mip_ext = WebGL_gpu_get_tex_max_mip_ext;
- gpu_get_tex_max_aniso = WebGL_gpu_get_tex_max_aniso;
- gpu_get_tex_max_aniso_ext = WebGL_gpu_get_tex_max_aniso_ext;
- gpu_get_tex_mip_enable = WebGL_gpu_get_tex_mip_enable;
- gpu_get_tex_mip_enable_ext = WebGL_gpu_get_tex_mip_enable_ext;
-
- gpu_push_state = WebGL_gpu_push_state;
- gpu_pop_state = WebGL_gpu_pop_state;
-
- gpu_get_state = WebGL_gpu_get_state;
- gpu_set_state = WebGL_gpu_set_state;
-
- g_matstack[0] = new Matrix(); // this should create a unit matrix
-}
-
-// #############################################################################################
-/// Function:
-/// Indicate we should use perspective projection matrices and 3D vertices
-///
-// #############################################################################################
-function WebGL_d3d_start_RELEASE() {
-
- GR_3DMode = true;
-
- // Force in 3D specific states
- g_webGL.SetZEnable(GR_ZEnable);
- g_webGL.SetZWriteEnable(GR_ZWriteEnable);
- g_webGL.SetCull(GR_Cull);
-}
-
-// #############################################################################################
-/// Function:
-/// Indicate we're dropping back to 2D rendering
-///
-// #############################################################################################
-function WebGL_d3d_end_RELEASE() {
-
- GR_3DMode = false;
-
- // Force in states that're default to 2D mode
- g_webGL.SetZEnable(false);
- g_webGL.SetZWriteEnable(false);
- g_webGL.SetCull(false);
-}
-
-// #############################################################################################
-/// Function:
-/// Set back face culling state
-///
-// #############################################################################################
-function WebGL_d3d_set_culling_RELEASE(_cull) {
-
- GR_Cull = _cull > 0.5;
- g_webGL.SetCull(GR_Cull);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_set_shading_RELEASE(_smooth) {
-
- // shadeModel is not available on webgl (gl_ES)
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_set_zwriteenable_RELEASE(_onoff) {
-
- GR_ZWriteEnable = (_onoff > 0.5);
- g_webGL.SetZWriteEnable(GR_ZWriteEnable);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_set_depth_RELEASE(_newdepth) {
-
- // _depth is a new depth value used for drawing...
- if (GR_3DMode || g_isZeus) {
- GR_Depth = Math.min(16000.0, Math.max(-16000.0, _newdepth) );
- }
- else {
- GR_Depth = 0.0;
- }
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_set_hidden_RELEASE(_hidden) {
-
- GR_ZEnable = (_hidden > 0.5);
- g_webGL.SetZEnable(GR_ZEnable);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_draw_set_color_write_enable_RELEASE(red, green, blue, alpha) {
-
- GR_ColourWriteEnable.red = (red >= 0.5);
- GR_ColourWriteEnable.green = (green >= 0.5);
- GR_ColourWriteEnable.blue = (blue >= 0.5);
- GR_ColourWriteEnable.alpha = (alpha >= 0.5);
- g_webGL.SetColorWriteEnable(GR_ColourWriteEnable.red, GR_ColourWriteEnable.green, GR_ColourWriteEnable.blue, GR_ColourWriteEnable.alpha);
-}
-
-// #############################################################################################
-/// Function:
-/// Set to use perspective matrices rather than orthographic
-/// Not entirely sure what the point of this is so it does nowt
-///
-// #############################################################################################
-function WebGL_d3d_set_perspective_RELEASE(_enable) {
- g_set_perspective = _enable;
-}
-
-// #############################################################################################
-/// Function:
-/// Sets whether or not lighting should be enabled
-/// If true then we need normals in the vertex data
-///
-// #############################################################################################
-function WebGL_d3d_set_lighting_RELEASE(_enable) {
-
- if (GR_LightingEnabled != _enable) {
-
- GR_LightingEnabled = _enable;
- // This doesn't feel right... if a proprietary shader hasn't been set then switch, otherwise leave alone I reckon
- g_webGL.SetShader(WebGL_GetDefaultShader());
- }
-}
-
-function WebGL_d3d_get_lighting_RELEASE() {
- return GR_LightingEnabled;
-}
-
-// #############################################################################################
-/// Function:
-/// It's called set_project. It sets the view matrix.
-/// Sometimes I don't cry myself to sleep. Sometimes.
-///
-// #############################################################################################
-function WebGL_d3d_set_projection_RELEASE(xfrom, yfrom, zfrom, xto, yto, zto, xup, yup, zup) {
-
- var view = new Matrix();
-
- var pos = new Vector3(xfrom, yfrom, zfrom);
- var at = new Vector3(xto, yto, zto);
- var up = new Vector3(xup, yup, zup);
- view.LookAtLH(pos, at, up);
-
- g_webGL.SetViewMatrix(view);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_set_projection_ext_RELEASE(xfrom, yfrom, zfrom, xto, yto, zto, xup, yup, zup, angle, aspect, znear, zfar) {
-
- var view = new Matrix();
-
- var pos = new Vector3(xfrom, yfrom, zfrom);
- var at = new Vector3(xto, yto, zto);
- var up = new Vector3(xup, yup, zup);
- view.LookAtLH(pos, at, up);
-
- var proj = new Matrix();
- proj.PerspectiveFovLH(angle, aspect, znear, zfar);
- proj.m[_22] *= g_RenderTargetActive;
-
- g_webGL.SetViewMatrix(view);
- g_webGL.SetProjectionMatrix(proj);
- //g_webGL.SetCullOrder((g_RenderTargetActive < 0) ? yyGL.Cull_CCW : yyGL.Cull_CW);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_set_projection_ortho_RELEASE(x,y,w,h,angle) {
-
- var view = new Matrix();
- var v1 = new Vector3(x + (w/2.0), y + (h/2.0), -w);
- var v2 = new Vector3(x + (w/2.0), y + (h/2.0), 0.0);
- var v3 = new Vector3(Math.sin(-angle*(Math.PI/180.0)), Math.cos(-angle*(Math.PI/180.0)), 0.0);
- view.LookAtLH(v1, v2, v3);
-
- var ortho = new Matrix();
- ortho.OrthoLH(w, -h * g_RenderTargetActive, 1.0, 32000.0);
-
- g_webGL.SetViewMatrix(view);
- g_webGL.SetProjectionMatrix(ortho);
-// g_webGL.SetCullOrder((g_RenderTargetActive < 0) ? yyGL.Cull_CCW : yyGL.Cull_CW);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_set_projection_perspective_RELEASE(x,y,w,h,angle) {
-
- var view = new Matrix();
- var v1 = new Vector3(x + (w/2.0), y + (h/2.0), -w);
- var v2 = new Vector3(x + (w/2.0), y + (h/2.0), 0.0);
- var v3 = new Vector3(Math.sin(-angle*(Math.PI/180.0)), Math.cos(-angle*(Math.PI/180.0)), 0.0);
- view.LookAtLH(v1, v2, v3);
-
- var proj = new Matrix();
- proj.PerspectiveLH(1.0, ( h/w), 1.0, 32000.0);
- proj.m[_22] *= g_RenderTargetActive;
-
- g_webGL.SetViewMatrix(view);
- g_webGL.SetProjectionMatrix(proj);
- // g_webGL.SetCullOrder((g_RenderTargetActive < 0) ? yyGL.Cull_CCW : yyGL.Cull_CW);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_draw_floor_RELEASE(x1, y1, z1, x2, y2, z2, texid, hrepeat, vrepeat) {
-
- var oldrep = texture_get_repeat();
- texture_set_repeat(true);
-
- // Draw the primitive
- d3d_primitive_begin_texture(PrimType_TRIFAN, texid);
- {
- d3d_vertex_normal_texture(x1,y1,z1,0,0,1,0,0);
- d3d_vertex_normal_texture(x1,y2,z1,0,0,1,0,vrepeat);
- d3d_vertex_normal_texture(x2,y2,z2,0,0,1,hrepeat,vrepeat);
- d3d_vertex_normal_texture(x2,y1,z2,0,0,1,hrepeat,0);
- }
- d3d_primitive_end();
-
- // Restore things
- texture_set_repeat(oldrep);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_draw_ellipsoid_RELEASE(x1, y1, z1, x2, y2, z2, texid, hrep, vrep, steps) {
-
- var oldrep = texture_get_repeat();
- texture_set_repeat(true);
-
- // Correct number of steps
- if (steps < 3) {
- steps = 3;
- }
- if (steps > 128) {
- steps = 128;
- }
-
- // Create sin and cos tables
- var cc = []; // [129]
- var ss = []; // [129]
- for (var i = 0; i <= steps; i++)
- {
- cc[i] = Math.cos(i*2.0*Math.PI / steps);
- ss[i] = Math.sin(i*2.0*Math.PI / steps);
- }
-
- var mx = (x2 + x1) / 2,
- my = (y2 + y1) / 2,
- mz = (z2 + z1) / 2,
- rx = (x2 - x1) / 2,
- ry = (y2 - y1) / 2,
- rz = (z2 - z1) / 2;
-
- // Draw the primitive in the box
- var rows = (steps + 1) / 2;
- for (var j= 0; j < rows; j++)
- {
- var rh1 = Math.cos(j * Math.PI / rows),
- rd1 = Math.sin(j * Math.PI / rows),
- rh2 = Math.cos((j+1) * Math.PI / rows),
- rd2 = Math.sin((j+1) * Math.PI / rows);
-
- d3d_primitive_begin_texture(PrimType_TRISTRIP, texid);
- for (var i = 0; i <= steps; i++)
- {
- d3d_vertex_normal_texture(mx+rx*rd1*cc[i], my+ry*rd1*ss[i], mz+rz*rh1,rd1*cc[i], rd1*ss[i], rh1, hrep*i/steps, j*vrep/rows);
- d3d_vertex_normal_texture(mx+rx*rd2*cc[i], my+ry*rd2*ss[i], mz+rz*rh2,rd2*cc[i], rd2*ss[i], rh2, hrep*i/steps, (j+1)*vrep/rows);
- }
- d3d_primitive_end();
- }
-
- // Restore things
- texture_set_repeat(oldrep);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_draw_block_RELEASE(x1,y1,z1,x2,y2,z2,texid,hrep,vrep) {
-
- var oldrep = texture_get_repeat();
- texture_set_repeat(true);
-
- d3d_primitive_begin_texture(PrimType_TRILIST, texid);
- {
- d3d_vertex_normal_texture(x1,y1,z1,0,0,-1,0,0);
- d3d_vertex_normal_texture(x1,y2,z1,0,0,-1,0,vrep);
- d3d_vertex_normal_texture(x2,y2,z1,0,0,-1,hrep,vrep);
-
- d3d_vertex_normal_texture(x2,y2,z1,0,0,-1,hrep,vrep);
- d3d_vertex_normal_texture(x2,y1,z1,0,0,-1,hrep,0);
- d3d_vertex_normal_texture(x1,y1,z1,0,0,-1,0,0);
- }
-
- {
- d3d_vertex_normal_texture(x1,y1,z2,0,0,1,0,0);
- d3d_vertex_normal_texture(x2,y1,z2,0,0,1,hrep,0);
- d3d_vertex_normal_texture(x2,y2,z2,0,0,1,hrep,vrep);
-
- d3d_vertex_normal_texture(x2,y2,z2,0,0,1,hrep,vrep);
- d3d_vertex_normal_texture(x1,y2,z2,0,0,1,0,vrep);
- d3d_vertex_normal_texture(x1,y1,z2,0,0,1,0,0);
- }
-
- {
- d3d_vertex_normal_texture(x1,y2,z1,0,1,0,0,0);
- d3d_vertex_normal_texture(x1,y2,z2,0,1,0,0,vrep);
- d3d_vertex_normal_texture(x2,y2,z2,0,1,0,hrep,vrep);
-
- d3d_vertex_normal_texture(x2,y2,z2,0,1,0,hrep,vrep);
- d3d_vertex_normal_texture(x2,y2,z1,0,1,0,hrep,0);
- d3d_vertex_normal_texture(x1,y2,z1,0,1,0,0,0);
- }
-
- {
- d3d_vertex_normal_texture(x2,y2,z1,1,0,0,0,0);
- d3d_vertex_normal_texture(x2,y2,z2,1,0,0,0,vrep);
- d3d_vertex_normal_texture(x2,y1,z2,1,0,0,hrep,vrep);
-
- d3d_vertex_normal_texture(x2,y1,z2,1,0,0,hrep,vrep);
- d3d_vertex_normal_texture(x2,y1,z1,1,0,0,hrep,0);
- d3d_vertex_normal_texture(x2,y2,z1,1,0,0,0,0);
- }
-
- {
- d3d_vertex_normal_texture(x2,y1,z1,0,-1,0,0,0);
- d3d_vertex_normal_texture(x2,y1,z2,0,-1,0,0,vrep);
- d3d_vertex_normal_texture(x1,y1,z2,0,-1,0,hrep,vrep);
-
- d3d_vertex_normal_texture(x1,y1,z2,0,-1,0,hrep,vrep);
- d3d_vertex_normal_texture(x1,y1,z1,0,-1,0,hrep,0);
- d3d_vertex_normal_texture(x2,y1,z1,0,-1,0,0,0);
- }
-
- {
- d3d_vertex_normal_texture(x1,y1,z1,-1,0,0,0,0);
- d3d_vertex_normal_texture(x1,y1,z2,-1,0,0,0,vrep);
- d3d_vertex_normal_texture(x1,y2,z2,-1,0,0,hrep,vrep);
-
- d3d_vertex_normal_texture(x1,y2,z2,-1,0,0,hrep,vrep);
- d3d_vertex_normal_texture(x1,y2,z1,-1,0,0,hrep,0);
- d3d_vertex_normal_texture(x1,y1,z1,-1,0,0,0,0);
- }
- d3d_primitive_end();
-
- // Restore things
- texture_set_repeat(oldrep);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_draw_cylinder_RELEASE(x1,y1,z1,x2,y2,z2,texid,hrep,vrep,closed,steps) {
-
- var cc = [];
- var ss = [];
-
- var oldrep = texture_get_repeat();
- texture_set_repeat(true);
-
- // Correct number of steps
- if (steps < 3) { steps = 3; }
- if (steps > 128){ steps = 128; }
-
-
- // Create sin and cos tables
- for (var i = 0; i <= steps; i++)
- {
- cc[i] = Math.cos(i * 2.0 * Math.PI / steps);
- ss[i] = Math.sin(i * 2.0 * Math.PI / steps);
- }
- var mx = (x2+x1)/2.0;
- var my = (y2+y1)/2.0;
- var rx = (x2-x1)/2.0;
- var ry = (y2-y1)/2.0;
-
- // Draw the primitive in the box
- if (true == closed)
- {
- d3d_primitive_begin_texture(PrimType_TRIFAN, texid);
- d3d_vertex_normal_texture(mx,my,z2,0,0,1,0,vrep);
- for (var i = 0; i <= steps; i++)
- {
- d3d_vertex_normal_texture(mx+cc[i]*rx,my+ss[i]*ry,z2,0,0,1,0,vrep);
- }
- d3d_primitive_end();
- }
-
-
- d3d_primitive_begin_texture(PrimType_TRISTRIP, texid);
- for (var i = 0; i <= steps; i++)
- {
- d3d_vertex_normal_texture(mx+cc[i]*rx,my+ss[i]*ry,z2,cc[i],ss[i],0,hrep*i/steps,vrep);
- d3d_vertex_normal_texture(mx+cc[i]*rx,my+ss[i]*ry,z1,cc[i],ss[i],0,hrep*i/steps,0);
- }
- d3d_primitive_end();
-
-
- if (true == closed)
- {
- d3d_primitive_begin_texture(PrimType_TRIFAN, texid);
- d3d_vertex_normal_texture(mx,my,z1,0,0,-1,0,0);
- for (var i = steps; i >= 0; i--)
- {
- d3d_vertex_normal_texture(mx+cc[i]*rx,my+ss[i]*ry,z1,0,0,-1,0,0);
- }
- d3d_primitive_end();
- }
-
- // Restore things
- texture_set_repeat(oldrep);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_draw_cone_RELEASE(x1,y1,z1,x2,y2,z2,texid,hrep,vrep,closed,steps) {
-
- var cc = [];
- var ss = [];
-
- var oldrep = texture_get_repeat();
- texture_set_repeat(true);
-
- // Correct number of steps
- if (steps < 3) { steps = 3; }
- if (steps > 128){ steps = 128; }
-
- // Create sin and cos tables
- for (var i = 0; i <= steps; i++)
- {
- cc[i] = Math.cos(i * 2.0 * Math.PI / steps);
- ss[i] = Math.sin(i * 2.0 * Math.PI / steps);
- }
-
- var mx = (x2+x1)/2.0;
- var my = (y2+y1)/2.0;
- var rx = (x2-x1)/2.0;
- var ry = (y2-y1)/2.0;
-
- // Draw the primitive in the box
- d3d_primitive_begin_texture(PrimType_TRISTRIP, texid);
- for (var i = 0; i <= steps; i++)
- {
- d3d_vertex_normal_texture(mx,my,z2,0,0,1,hrep*i/steps,vrep);
- d3d_vertex_normal_texture(mx+cc[i]*rx,my+ss[i]*ry,z1,cc[i],ss[i],0,hrep*i/steps,0);
- }
- d3d_primitive_end();
-
- if (true == closed)
- {
- d3d_primitive_begin_texture(PrimType_TRIFAN, texid);
- d3d_vertex_normal_texture(mx,my,z1,0,0,-1,0,0);
- for (var i = steps; i >= 0; i--)
- {
- d3d_vertex_normal_texture(mx+cc[i]*rx,my+ss[i]*ry,z1,0,0,-1,0,0);
- }
- d3d_primitive_end();
- }
-
- // Restore things
- texture_set_repeat(oldrep);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_draw_wall_RELEASE(x1,y1,z1,x2,y2,z2,texid,hrep,vrep) {
-
- var oldrep = texture_get_repeat();
- texture_set_repeat(true);
-
- // Draw the primitive
- var l = Math.sqrt(Sqr(x2 - x1) + Sqr(y2 - y1));
- if (l == 0.0) {
- return;
- }
-
- var nx = (y2-y1) / l;
- var ny = -(x2-x1) / l;
- d3d_primitive_begin_texture(PrimType_TRIFAN, texid);
- {
- d3d_vertex_normal_texture(x1,y1,z1,nx,ny,0,0,0);
- d3d_vertex_normal_texture(x2,y2,z1,nx,ny,0,hrep,0);
- d3d_vertex_normal_texture(x2,y2,z2,nx,ny,0,hrep,vrep);
- d3d_vertex_normal_texture(x1,y1,z2,nx,ny,0,0,vrep);
- }
- d3d_primitive_end();
-
- // Restore things
- texture_set_repeat(oldrep);
-}
-
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_light_define_direction_RELEASE(ind, dx, dy, dz, col) {
-
- // Make sure the direction is normalised
- var vec = new Vector3(dx, dy, dz);
- vec.Normalise();
-
- var baseIndex = ind * 4;
- GR_DirectionalLights[baseIndex + 0] = vec.X;
- GR_DirectionalLights[baseIndex + 1] = vec.Y;
- GR_DirectionalLights[baseIndex + 2] = vec.Z;
- GR_DirectionalLights[baseIndex + 3] = 0.0;
-
- GR_LightColours[baseIndex + 0] = (col & 0xff) / 255.0;
- GR_LightColours[baseIndex + 1] = ((col >> 8) & 0xff) / 255.0;
- GR_LightColours[baseIndex + 2] = ((col >> 16) & 0xff) / 255.0;
- GR_LightColours[baseIndex + 3] = 1.0;
-
- GR_LightType[ind] = LIGHT_TYPE_DIR;
-
- // Make sure the partnered point light is set to have no effect
- GR_PointLights[baseIndex + 0] = 0;
- GR_PointLights[baseIndex + 1] = 0;
- GR_PointLights[baseIndex + 2] = 0;
- GR_PointLights[baseIndex + 3] = 0;
-
- g_webGL.SetLight(ind,
- GR_PointLights.subarray(ind*4, (ind+1)*4),
- GR_DirectionalLights.subarray(ind*4, (ind+1)*4),
- GR_LightColours.subarray(ind*4, (ind+1)*4));
-}
-
-function WebGL_d3d_light_get_ambient_RELEASE()
-{
-
- var col = (((GR_AmbientLight[0] * 255.0) ) & 0xff)
- | (((GR_AmbientLight[1] * 255.0) << 8) & 0xff00)
- | (((GR_AmbientLight[2] * 255.0) << 16) & 0xff0000)
- | (((GR_AmbientLight[3] * 255.0) << 24) & 0xff000000);
-
-
- return col;
-
-}
-
-function WebGL_d3d_light_get_RELEASE(index)
-{
- var ret = [];
-
- if (index < 0 || index > 7) {
- console.log("draw_light_get() - light index out of range");
- return;
- }
-
- var baseIndex = index * 4;
-
- ret[0] = GR_LightEnabled[index];
- ret[1] = GR_LightType[index];
-
- if (GR_LightType[index] == LIGHT_TYPE_DIR)
- {
- ret[2] = GR_DirectionalLights[baseIndex + 0];
- ret[3] = GR_DirectionalLights[baseIndex + 1];
- ret[4] = GR_DirectionalLights[baseIndex + 2];
- ret[5] = GR_DirectionalLights[baseIndex + 3];
- }
- else
- {
-
- ret[2] = GR_PointLights[baseIndex + 0];
- ret[3] = GR_PointLights[baseIndex + 1];
- ret[4] = GR_PointLights[baseIndex + 2];
- ret[5] = GR_PointLights[baseIndex + 3];
- }
-
-
- var r = (((GR_LightColours[baseIndex + 0] * 255.0)) & 0xff);
- var g = (((GR_LightColours[baseIndex + 1] * 255.0) << 8) & 0xff00);
- var b = (((GR_LightColours[baseIndex + 2] * 255.0) << 16) & 0xff0000);
- var a = (((GR_LightColours[baseIndex + 3] * 255.0) << 24) & 0xff000000);
-
-
- var col = r|g|b|a;
-
- ret[6] = col;
-
- return ret;
-
-}
-
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_light_define_point_RELEASE(ind,x,y,z,range,col) {
-
- var baseIndex = ind * 4;
- GR_PointLights[baseIndex + 0] = x;
- GR_PointLights[baseIndex + 1] = y;
- GR_PointLights[baseIndex + 2] = z;
- GR_PointLights[baseIndex + 3] = range;
-
- GR_LightColours[baseIndex + 0] = (col & 0xff) / 255.0;
- GR_LightColours[baseIndex + 1] = ((col >> 8) & 0xff) / 255.0;
- GR_LightColours[baseIndex + 2] = ((col >> 16) & 0xff) / 255.0;
- GR_LightColours[baseIndex + 3] = 1.0;
-
-
- GR_LightType[ind] = LIGHT_TYPE_POINT;
-
- // Make sure the partnered directional light is set to have no effect
- GR_DirectionalLights[baseIndex + 0] = 0;
- GR_DirectionalLights[baseIndex + 1] = 0;
- GR_DirectionalLights[baseIndex + 2] = 0;
- GR_DirectionalLights[baseIndex + 3] = 0;
-
- g_webGL.SetLight(ind,
- GR_PointLights.subarray(ind*4, (ind+1)*4),
- GR_DirectionalLights.subarray(ind*4, (ind+1)*4),
- GR_LightColours.subarray(ind*4, (ind+1)*4));
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_light_enable_RELEASE(ind, enable) {
-
- GR_LightEnabled[ind] = enable;
-
- // We need to pass in the actual colour of the light since the off is handled by setting the colour to black
- g_webGL.SetLightEnable(ind, enable, GR_LightColours.subarray(ind*4, (ind+1)*4));
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_light_define_ambient_RELEASE(colour) {
-
- // Pull apart and put into float array
- GR_AmbientLight[0] = (colour & 0xff) / 255.0;
- GR_AmbientLight[1] = ((colour >> 8) & 0xff) / 255.0;
- GR_AmbientLight[2] = ((colour >> 16) & 0xff) / 255.0;
- GR_AmbientLight[3] = ((colour >> 24) & 0xff) / 255.0;
-
- g_webGL.SetAmbientLighting(GR_AmbientLight);
-}
-
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_set_fog_RELEASE(enable,colour,start,end) {
-
- if (GR_FogParameters == null) {
- GR_FogParameters = new Float32Array(8); // Two vec4s
- }
- GR_FogParameters[0] = enable;
- var range = end - start;
- GR_FogParameters[1] = (range == 0.0) ? 0.0 : (1.0 / range);
- GR_FogParameters[2] = end;
- GR_FogParameters[3] = 0.0;
-
- // Pull apart colour and put into second vec4
- GR_FogParameters[4] = (colour & 0xff) / 255.0;
- GR_FogParameters[5] = ((colour >> 8) & 0xff) / 255.0;
- GR_FogParameters[6] = ((colour >> 16) & 0xff) / 255.0;
- GR_FogParameters[7] = ((colour >> 24) & 0xff) / 255.0;
-
- g_webGL.SetFogData(GR_FogParameters);
-}
-
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_create_RELEASE() {
-
- return (g_3DModels.push(new yy3DModel()) - 1);
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_destroy_RELEASE(ind) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].Clear();
- g_3DModels[ind] = null;
- }
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_clear_RELEASE(ind) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].Clear();
- }
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_save_RELEASE(ind, fname) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].Save(fname);
- }
-}
-
-function WebGL_d3d_model_save_buffer_RELEASE(ind, buffer_index) {
-
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_load_RELEASE(ind, fname) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].Load(fname);
- }
-}
-
-function WebGL_d3d_model_load_buffer_RELEASE(ind, buffer_index) {
-
-
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_draw_RELEASE(ind,x,y,z,texid) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].Draw(x, y, z, texid);
- }
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_primitive_begin_RELEASE(ind,kind) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].Begin(kind);
- }
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_vertex_RELEASE(ind,x,y,z) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].Vertex(x, y, z);
- }
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_vertex_color_RELEASE(ind,x,y,z,col,alpha) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].VertexColor(x, y, z, col, alpha);
- }
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_vertex_texture_RELEASE(ind,x,y,z,xtex,ytex) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].VertexTexture(x, y, z, xtex, ytex);
- }
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_vertex_texture_color_RELEASE(ind,x,y,z,xtex,ytex,col,alpha) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].VertexTextureColor(x, y, z, xtex, ytex, col, alpha);
- }
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_vertex_normal_RELEASE(ind,x,y,z,nx,ny,nz) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].VertexNormal(x, y, z, nx, ny, nz);
- }
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_vertex_normal_color_RELEASE(ind,x,y,z,nx,ny,nz,col,alpha) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].VertexNormalColor(x, y, z, nx, ny, nz, col, alpha);
- }
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_vertex_normal_texture_RELEASE(ind,x,y,z,nx,ny,nz,xtex,ytex) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].VertexNormalTexture(x, y, z, nx, ny, nz, xtex, ytex);
- }
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_vertex_normal_texture_color_RELEASE(ind,x,y,z,nx,ny,nz,xtex,ytex,col,alpha) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].VertexNormalTextureColor(x, y, z, nx, ny, nz, xtex, ytex, col, alpha);
- }
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_primitive_end_RELEASE(ind) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].End();
- }
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_block_RELEASE(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].Block(x1,y1,z1,x2,y2,z2,hrepeat,vrepeat);
- }
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_cylinder_RELEASE(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,closed,steps) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].Cylinder(x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,closed,steps);
- }
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_cone_RELEASE(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,closed,steps) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].Cone(x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,closed,steps);
- }
-}
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_model_ellipsoid_RELEASE(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,steps) {
+ compile_if_used(gpu_get_blendmode = WebGL_gpu_get_blendmode);
+ compile_if_used(gpu_get_blendmode_ext = WebGL_gpu_get_blendmode_ext);
+ compile_if_used(gpu_get_blendmode_ext_sepalpha = WebGL_gpu_get_blendmode_ext_sepalpha);
+ compile_if_used(gpu_get_blendmode_src = WebGL_gpu_get_blendmode_src);
+ compile_if_used(gpu_get_blendmode_dest = WebGL_gpu_get_blendmode_dest);
+ compile_if_used(gpu_get_blendmode_srcalpha = WebGL_gpu_get_blendmode_srcalpha);
+ compile_if_used(gpu_get_blendmode_destalpha = WebGL_gpu_get_blendmode_destalpha);
+ compile_if_used(gpu_get_colorwriteenable = WebGL_gpu_get_colorwriteenable);
+ compile_if_used(gpu_get_colourwriteenable = WebGL_gpu_get_colourwriteenable);
+ gpu_get_alphatestenable = WebGL_gpu_get_alphatestenable;
+ compile_if_used(gpu_get_alphatestref = WebGL_gpu_get_alphatestref);
+ compile_if_used(gpu_get_texfilter = WebGL_gpu_get_texfilter);
+ gpu_get_texfilter_ext = WebGL_gpu_get_texfilter_ext;
+ compile_if_used(gpu_get_texrepeat = WebGL_gpu_get_texrepeat);
+
+ compile_if_used(gpu_get_tex_filter = WebGL_gpu_get_texfilter);
+ compile_if_used(gpu_get_tex_filter_ext = WebGL_gpu_get_texfilter_ext);
+ compile_if_used(gpu_get_tex_repeat = WebGL_gpu_get_texrepeat);
+ compile_if_used(gpu_get_tex_repeat_ext = WebGL_gpu_get_texrepeat_ext);
+
+ compile_if_used(gpu_get_tex_mip_filter = WebGL_gpu_get_tex_mip_filter);
+ compile_if_used(gpu_get_tex_mip_filter_ext = WebGL_gpu_get_tex_mip_filter_ext);
+ compile_if_used(gpu_get_tex_mip_bias = WebGL_gpu_get_tex_mip_bias);
+ compile_if_used(gpu_get_tex_mip_bias_ext = WebGL_gpu_get_tex_mip_bias_ext);
+ compile_if_used(gpu_get_tex_min_mip = WebGL_gpu_get_tex_min_mip);
+ compile_if_used(gpu_get_tex_min_mip_ext = WebGL_gpu_get_tex_min_mip_ext);
+ compile_if_used(gpu_get_tex_max_mip = WebGL_gpu_get_tex_max_mip);
+ compile_if_used(gpu_get_tex_max_mip_ext = WebGL_gpu_get_tex_max_mip_ext);
+ compile_if_used(gpu_get_tex_max_aniso = WebGL_gpu_get_tex_max_aniso);
+ compile_if_used(gpu_get_tex_max_aniso_ext = WebGL_gpu_get_tex_max_aniso_ext);
+ compile_if_used(gpu_get_tex_mip_enable = WebGL_gpu_get_tex_mip_enable);
+ compile_if_used(gpu_get_tex_mip_enable_ext = WebGL_gpu_get_tex_mip_enable_ext);
+
+ compile_if_used(gpu_push_state = WebGL_gpu_push_state);
+ compile_if_used(gpu_pop_state = WebGL_gpu_pop_state);
+
+ compile_if_used(gpu_get_state = WebGL_gpu_get_state);
+ compile_if_used(gpu_set_state = WebGL_gpu_set_state);
- if (g_3DModels[ind]) {
- g_3DModels[ind].Ellipsoid(x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,steps);
- }
+ g_matstack[0] = new Matrix(); // this should create a unit matrix
}
// #############################################################################################
/// Function:
///
// #############################################################################################
-function WebGL_d3d_model_wall_RELEASE(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].Wall(x1,y1,z1,x2,y2,z2,hrepeat,vrepeat);
- }
+function WebGL_d3d_set_depth_RELEASE(_newdepth) {
+
+ // _depth is a new depth value used for drawing...
+ GR_Depth = Math.min(16000.0, Math.max(-16000.0, _newdepth) );
}
// #############################################################################################
/// Function:
///
// #############################################################################################
-function WebGL_d3d_model_floor_RELEASE(ind,x1,y1,z1,x2,y2,z2,hrepeat,vrepeat) {
-
- if (g_3DModels[ind]) {
- g_3DModels[ind].Floor(x1,y1,z1,x2,y2,z2,hrepeat,vrepeat);
- }
+function WebGL_draw_set_color_write_enable_RELEASE(red, green, blue, alpha) {
+
+ GR_ColourWriteEnable.red = (red >= 0.5);
+ GR_ColourWriteEnable.green = (green >= 0.5);
+ GR_ColourWriteEnable.blue = (blue >= 0.5);
+ GR_ColourWriteEnable.alpha = (alpha >= 0.5);
+ g_webGL.SetColorWriteEnable(GR_ColourWriteEnable.red, GR_ColourWriteEnable.green, GR_ColourWriteEnable.blue, GR_ColourWriteEnable.alpha);
}
-
// #############################################################################################
/// Function:
+/// Set to use perspective matrices rather than orthographic
+/// Not entirely sure what the point of this is so it does nowt
///
// #############################################################################################
-function WebGL_d3d_transform_set_identity_RELEASE() {
-
- WebGL_SetMatrix(MATRIX_WORLD, new Matrix());
+function WebGL_d3d_set_perspective_RELEASE(_enable) {
+ g_set_perspective = _enable;
}
// #############################################################################################
/// Function:
+/// Sets whether or not lighting should be enabled
+/// If true then we need normals in the vertex data
///
// #############################################################################################
-function WebGL_d3d_transform_set_translation_RELEASE(xt,yt,zt) {
+function WebGL_d3d_set_lighting_RELEASE(_enable) {
+
+ if (GR_LightingEnabled != _enable) {
+
+ GR_LightingEnabled = _enable;
+ // This doesn't feel right... if a proprietary shader hasn't been set then switch, otherwise leave alone I reckon
+ g_webGL.SetShader(WebGL_GetDefaultShader());
+ }
+}
- var m = new Matrix();
- m.SetTranslation(xt, yt, zt);
- WebGL_SetMatrix(MATRIX_WORLD, m);
+function WebGL_d3d_get_lighting_RELEASE() {
+ return GR_LightingEnabled;
}
// #############################################################################################
/// Function:
///
// #############################################################################################
-function WebGL_d3d_transform_set_scaling_RELEASE(xs,ys,zs) {
+function WebGL_d3d_set_projection_ortho_RELEASE(x,y,w,h,angle) {
- var m = new Matrix();
- m.SetScale(xs, ys, zs);
- WebGL_SetMatrix(MATRIX_WORLD, m);
+ var view = new Matrix();
+ var v1 = new Vector3(x + (w/2.0), y + (h/2.0), -w);
+ var v2 = new Vector3(x + (w/2.0), y + (h/2.0), 0.0);
+ var v3 = new Vector3(Math.sin(-angle*(Math.PI/180.0)), Math.cos(-angle*(Math.PI/180.0)), 0.0);
+ view.LookAtLH(v1, v2, v3);
+
+ var ortho = new Matrix();
+ ortho.OrthoLH(w, -h * g_RenderTargetActive, 1.0, 32000.0);
+
+ g_webGL.SetViewMatrix(view);
+ g_webGL.SetProjectionMatrix(ortho);
+// g_webGL.SetCullOrder((g_RenderTargetActive < 0) ? yyGL.Cull_CCW : yyGL.Cull_CW);
}
// #############################################################################################
/// Function:
///
// #############################################################################################
-function WebGL_d3d_transform_set_rotation_x_RELEASE(angle) {
+function WebGL_d3d_light_define_direction_RELEASE(ind, dx, dy, dz, col) {
- var m = new Matrix();
- m.SetXRotation(angle);
- WebGL_SetMatrix(MATRIX_WORLD, m);
-}
+ // Make sure the direction is normalised
+ var vec = new Vector3(dx, dy, dz);
+ vec.Normalise();
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_transform_set_rotation_y_RELEASE(angle) {
+ var baseIndex = ind * 4;
+ GR_DirectionalLights[baseIndex + 0] = vec.X;
+ GR_DirectionalLights[baseIndex + 1] = vec.Y;
+ GR_DirectionalLights[baseIndex + 2] = vec.Z;
+ GR_DirectionalLights[baseIndex + 3] = 0.0;
- var m = new Matrix();
- m.SetYRotation(angle);
- WebGL_SetMatrix(MATRIX_WORLD, m);
+ GR_LightColours[baseIndex + 0] = (col & 0xff) / 255.0;
+ GR_LightColours[baseIndex + 1] = ((col >> 8) & 0xff) / 255.0;
+ GR_LightColours[baseIndex + 2] = ((col >> 16) & 0xff) / 255.0;
+ GR_LightColours[baseIndex + 3] = 1.0;
+
+ GR_LightType[ind] = LIGHT_TYPE_DIR;
+
+ // Make sure the partnered point light is set to have no effect
+ GR_PointLights[baseIndex + 0] = 0;
+ GR_PointLights[baseIndex + 1] = 0;
+ GR_PointLights[baseIndex + 2] = 0;
+ GR_PointLights[baseIndex + 3] = 0;
+
+ g_webGL.SetLight(ind,
+ GR_PointLights.subarray(ind*4, (ind+1)*4),
+ GR_DirectionalLights.subarray(ind*4, (ind+1)*4),
+ GR_LightColours.subarray(ind*4, (ind+1)*4));
}
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_transform_set_rotation_z_RELEASE(angle) {
+function WebGL_d3d_light_get_ambient_RELEASE()
+{
- var m = new Matrix();
- m.SetZRotation(angle);
- WebGL_SetMatrix(MATRIX_WORLD, m);
-}
+ var col = (((GR_AmbientLight[0] * 255.0) ) & 0xff)
+ | (((GR_AmbientLight[1] * 255.0) << 8) & 0xff00)
+ | (((GR_AmbientLight[2] * 255.0) << 16) & 0xff0000)
+ | (((GR_AmbientLight[3] * 255.0) << 24) & 0xff000000);
+
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_transform_set_rotation_axis_RELEASE(xa,ya,za,angle) {
+ return col;
- var m = new Matrix();
- m.SetRotationAxis(new Vector3(xa, ya, za), -angle);
- WebGL_SetMatrix(MATRIX_WORLD, m);
}
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_transform_add_translation_RELEASE(xt,yt,zt) {
+function WebGL_d3d_light_get_RELEASE(index)
+{
+ var ret = [];
- var mt = new Matrix();
- mt.SetTranslation(xt, yt, zt);
-
- var mo = WebGL_GetMatrix(MATRIX_WORLD);
- var m = new Matrix();
- m.Multiply(mo, mt);
-
- WebGL_SetMatrix(MATRIX_WORLD, m);
-}
+ if (index < 0 || index > 7) {
+ console.log("draw_light_get() - light index out of range");
+ return;
+ }
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_transform_add_scaling_RELEASE(xs,ys,zs) {
+ var baseIndex = index * 4;
- var ms = new Matrix();
- ms.SetScale(xs, ys, zs);
-
- var mo = WebGL_GetMatrix(MATRIX_WORLD);
- var m = new Matrix();
- m.Multiply(mo, ms);
-
- WebGL_SetMatrix(MATRIX_WORLD, m);
-}
+ ret[0] = GR_LightEnabled[index];
+ ret[1] = GR_LightType[index];
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_transform_add_rotation_x_RELEASE(angle) {
+ if (GR_LightType[index] == LIGHT_TYPE_DIR)
+ {
+ ret[2] = GR_DirectionalLights[baseIndex + 0];
+ ret[3] = GR_DirectionalLights[baseIndex + 1];
+ ret[4] = GR_DirectionalLights[baseIndex + 2];
+ ret[5] = GR_DirectionalLights[baseIndex + 3];
+ }
+ else
+ {
+
+ ret[2] = GR_PointLights[baseIndex + 0];
+ ret[3] = GR_PointLights[baseIndex + 1];
+ ret[4] = GR_PointLights[baseIndex + 2];
+ ret[5] = GR_PointLights[baseIndex + 3];
+ }
- var mr = new Matrix();
- mr.SetXRotation(angle);
-
- var mo = WebGL_GetMatrix(MATRIX_WORLD);
- var m = new Matrix();
- m.Multiply(mo, mr);
-
- WebGL_SetMatrix(MATRIX_WORLD, m);
-}
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_transform_add_rotation_y_RELEASE(angle) {
+ var r = (((GR_LightColours[baseIndex + 0] * 255.0)) & 0xff);
+ var g = (((GR_LightColours[baseIndex + 1] * 255.0) << 8) & 0xff00);
+ var b = (((GR_LightColours[baseIndex + 2] * 255.0) << 16) & 0xff0000);
+ var a = (((GR_LightColours[baseIndex + 3] * 255.0) << 24) & 0xff000000);
- var mr = new Matrix();
- mr.SetYRotation(angle);
-
- var mo = WebGL_GetMatrix(MATRIX_WORLD);
- var m = new Matrix();
- m.Multiply(mo, mr);
-
- WebGL_SetMatrix(MATRIX_WORLD, m);
-}
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_transform_add_rotation_z_RELEASE(angle) {
+ var col = r|g|b|a;
+
+ ret[6] = col;
+
+ return ret;
- var mr = new Matrix();
- mr.SetZRotation(angle);
-
- var mo = WebGL_GetMatrix(MATRIX_WORLD);
- var m = new Matrix();
- m.Multiply(mo, mr);
-
- WebGL_SetMatrix(MATRIX_WORLD, m);
}
+
// #############################################################################################
/// Function:
///
// #############################################################################################
-function WebGL_d3d_transform_add_rotation_axis_RELEASE(xa,ya,za,angle) {
+function WebGL_d3d_light_define_point_RELEASE(ind,x,y,z,range,col) {
- var mr = new Matrix();
- mr.SetRotationAxis(new Vector3(xa, ya, za), -angle);
+ var baseIndex = ind * 4;
+ GR_PointLights[baseIndex + 0] = x;
+ GR_PointLights[baseIndex + 1] = y;
+ GR_PointLights[baseIndex + 2] = z;
+ GR_PointLights[baseIndex + 3] = range;
- var mo = WebGL_GetMatrix(MATRIX_WORLD);
- var m = new Matrix();
- m.Multiply(mo, mr);
+ GR_LightColours[baseIndex + 0] = (col & 0xff) / 255.0;
+ GR_LightColours[baseIndex + 1] = ((col >> 8) & 0xff) / 255.0;
+ GR_LightColours[baseIndex + 2] = ((col >> 16) & 0xff) / 255.0;
+ GR_LightColours[baseIndex + 3] = 1.0;
- WebGL_SetMatrix(MATRIX_WORLD, m);
-}
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_transform_vertex_RELEASE(_x, _y, _z) {
+ GR_LightType[ind] = LIGHT_TYPE_POINT;
- var mo = WebGL_GetMatrix(MATRIX_WORLD);
- var xx = (mo.m[_11]*_x) + (mo.m[_21]*_y) + (mo.m[_31]*_z) + mo.m[_41];
- var yy = (mo.m[_12]*_x) + (mo.m[_22]*_y) + (mo.m[_32]*_z) + mo.m[_42];
- var zz = (mo.m[_13]*_x) + (mo.m[_23]*_y) + (mo.m[_33]*_z) + mo.m[_43];
-
- var r=[];
- r[0]=xx;
- r[1]=yy;
- r[2]=zz;
- return r;
+ // Make sure the partnered directional light is set to have no effect
+ GR_DirectionalLights[baseIndex + 0] = 0;
+ GR_DirectionalLights[baseIndex + 1] = 0;
+ GR_DirectionalLights[baseIndex + 2] = 0;
+ GR_DirectionalLights[baseIndex + 3] = 0;
+
+ g_webGL.SetLight(ind,
+ GR_PointLights.subarray(ind*4, (ind+1)*4),
+ GR_DirectionalLights.subarray(ind*4, (ind+1)*4),
+ GR_LightColours.subarray(ind*4, (ind+1)*4));
}
// #############################################################################################
/// Function:
///
// #############################################################################################
-function WebGL_d3d_transform_stack_clear_RELEASE() {
- MatrixStackClear();
-}
+function WebGL_d3d_light_enable_RELEASE(ind, enable) {
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_transform_stack_empty_RELEASE() {
- return MatrixStackEmpty();
+ GR_LightEnabled[ind] = enable;
+
+ // We need to pass in the actual colour of the light since the off is handled by setting the colour to black
+ g_webGL.SetLightEnable(ind, enable, GR_LightColours.subarray(ind*4, (ind+1)*4));
}
// #############################################################################################
/// Function:
///
// #############################################################################################
-function WebGL_d3d_transform_stack_push_RELEASE() {
-
- var mo = WebGL_GetMatrix(MATRIX_WORLD);
- return PushMatrix(mo);
-}
+function WebGL_d3d_light_define_ambient_RELEASE(colour) {
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_transform_stack_pop_RELEASE() {
- return PopMatrix();
+ // Pull apart and put into float array
+ GR_AmbientLight[0] = (colour & 0xff) / 255.0;
+ GR_AmbientLight[1] = ((colour >> 8) & 0xff) / 255.0;
+ GR_AmbientLight[2] = ((colour >> 16) & 0xff) / 255.0;
+ GR_AmbientLight[3] = ((colour >> 24) & 0xff) / 255.0;
+
+ g_webGL.SetAmbientLighting(GR_AmbientLight);
}
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-function WebGL_d3d_transform_stack_top_RELEASE() {
- return SetTopMatrix();
-}
// #############################################################################################
/// Function:
///
// #############################################################################################
-function WebGL_d3d_transform_stack_discard_RELEASE() {
- return DiscardTopMatrix();
+function WebGL_d3d_set_fog_RELEASE(enable,colour,start,end) {
+
+ if (GR_FogParameters == null) {
+ GR_FogParameters = new Float32Array(8); // Two vec4s
+ }
+ GR_FogParameters[0] = enable;
+ var range = end - start;
+ GR_FogParameters[1] = (range == 0.0) ? 0.0 : (1.0 / range);
+ GR_FogParameters[2] = end;
+ GR_FogParameters[3] = 0.0;
+
+ // Pull apart colour and put into second vec4
+ GR_FogParameters[4] = (colour & 0xff) / 255.0;
+ GR_FogParameters[5] = ((colour >> 8) & 0xff) / 255.0;
+ GR_FogParameters[6] = ((colour >> 16) & 0xff) / 255.0;
+ GR_FogParameters[7] = ((colour >> 24) & 0xff) / 255.0;
+
+ g_webGL.SetFogData(GR_FogParameters);
}
-//matrix_get = WebGL_Matrix_Get;
-//matrix_set = WebGL_Matrix_Set;
-//matrix_build = WebGL_Matrix_Build;
-//matrix_multiply = WebGL_Matrix_Multiply;
-
// #############################################################################################
/// Function:
@@ -1930,7 +939,6 @@ function WebGL_gpu_set_zwriteenable(_enable)
g_webGL.RSMan.SetRenderState(yyGL.RenderState_ZWriteEnable, yyGetInt32(_enable) >= 0.5);
}
-//function WebGL_gpu_set_lightingenable(_enable) { ErrorFunction("gpu_set_lightingenable()"); }
function WebGL_gpu_set_fog(_enable,_col,_start,_end)
{
if (Array.isArray(_enable))
@@ -2373,7 +1381,6 @@ function WebGL_gpu_get_zwriteenable()
return g_webGL.RSMan.GetRenderState(yyGL.RenderState_ZWriteEnable) ? 1.0 : 0.0;
}
-//function WebGL_gpu_get_lightingenable() { ErrorFunction("gpu_get_lightingenable()"); }
function WebGL_gpu_get_fog()
{
var params = new Array();
@@ -2767,4 +1774,4 @@ function WebGL_gpu_set_state(_map)
function WebGL_Generic_Stub()
{
-}
\ No newline at end of file
+}
diff --git a/scripts/functions/Function_Debug.js b/scripts/functions/Function_Debug.js
index ba03f65b..3ef754dd 100644
--- a/scripts/functions/Function_Debug.js
+++ b/scripts/functions/Function_Debug.js
@@ -176,7 +176,7 @@ function ErrorOnce(_text) {
///
///
// #############################################################################################
-function ErrorFunction(_text)
+function ErrorFunction(_text, _returnValue)
{
if( !g_MissingFunction_done[_text] )
{
@@ -184,6 +184,11 @@ function ErrorFunction(_text)
var txt = "Error: function " + _text + " is not supported.";
debug( txt );
}
+ return _returnValue;
+}
+function GetErrorFunction(name, returnValue)
+{
+ return () => ErrorFunction(name, returnValue);
}
@@ -453,7 +458,7 @@ function show_message(_txt)
{
var msg = yyGetString(_txt);
if (!msg) return;
- alert(SplitText(msg));
+ alert(msg);
}
// #############################################################################################
@@ -503,13 +508,8 @@ function show_question_async(_str) {
///
// #############################################################################################
function show_question(_str) {
- _str = yyGetString(_str);
-
- if (!_str) {
- _str = "";
- }
if (window.confirm) {
- return confirm(SplitText(_str)) ? 1.0 : 0.0;
+ return confirm(yyGetString(_str) || "") ? 1.0 : 0.0;
}
ErrorFunction("show_question()");
return 0;
@@ -552,6 +552,7 @@ function get_integer(_str,_def)
}
+/// @if function("get_login_async")
// #############################################################################################
/// Function:
/// Create a login dialog
@@ -636,12 +637,14 @@ function createLoginDialog( _dialogData )
login_dialog_update();
g_pASyncManager.Add(_dialogData.id, null, ASYNC_USER, g_dialogName);
} // end createLoginDialog
+/// @endif
// #############################################################################################
/// Function:
/// Create an input dialog
///
// #############################################################################################
+// @if function("get_integer_async") || function("get_string_async")
function createInputDialog( _dialogData )
{
//show_debug_message( "createInputDialog = " + _dialogData );
@@ -715,12 +718,14 @@ function createInputDialog( _dialogData )
login_dialog_update();
g_pASyncManager.Add(_dialogData.id, null, ASYNC_USER, g_dialogName);
} // end createInputDialog
+// @endif
// #############################################################################################
/// Function:
/// Create a question dialog
///
// #############################################################################################
+// @if function("show_question_async")
function createQuestionDialog( _dialogData )
{
//show_debug_message( "createQuestionDialog = " + _dialogData );
@@ -787,12 +792,14 @@ function createQuestionDialog( _dialogData )
login_dialog_update();
g_pASyncManager.Add(_dialogData.id, null, ASYNC_USER, g_dialogName);
} // end createQuestionDialog
+// @endif
// #############################################################################################
/// Function:
/// Create a message dialog
///
// #############################################################################################
+// @if function("show_message_async")
function createMessageDialog( _dialogData )
{
//show_debug_message( "createMessageDialog = " + _dialogData );
@@ -859,6 +866,7 @@ function createMessageDialog( _dialogData )
login_dialog_update();
g_pASyncManager.Add(_dialogData.id, null, ASYNC_USER, g_dialogName);
} // end createMessageDialog
+// @endif
// #############################################################################################
/// Function:
@@ -885,18 +893,26 @@ function YYDialogKick() {
// get the first entry and kick that one
switch( g_dialogs[0].type ) {
+ // @if function("get_login_async")
case DIALOG_TYPE_LOGIN: // login dialog
createLoginDialog( g_dialogs[0] );
break;
+ // @endif
+ // @if function("get_integer_async") || function("get_string_async")
case DIALOG_TYPE_INPUT: // input dialog
createInputDialog( g_dialogs[0] );
break;
+ // @endif
+ // @if function("show_question_async")
case DIALOG_TYPE_QUESTION: // show question
createQuestionDialog( g_dialogs[0] );
break;
+ // @endif
+ // @if function("show_message_async")
case DIALOG_TYPE_MESSAGE: // show message
createMessageDialog( g_dialogs[0] );
break;
+ // @endif
} // end switch
} // end if
@@ -1191,7 +1207,7 @@ function getStacktraceArray(_error) {
return ret;
}
-
+// @if feature("debug")
// #############################################################################################
/// Function:
/// Update the debug windows "instance" list
@@ -1367,3 +1383,5 @@ function UpdateDebugWindow() {
UpdateDebugInstanceList();
UpdateInsanceData();
}
+
+// @endif
diff --git a/scripts/functions/Function_File.js b/scripts/functions/Function_File.js
index fcab4e07..802ac6f3 100644
--- a/scripts/functions/Function_File.js
+++ b/scripts/functions/Function_File.js
@@ -1023,6 +1023,7 @@ const _regexp_int64_parse = new RegExp("@i64@([0-9a-f]+?)\\$i64\\$", "i");
// ########### JSON_ENCODE & JSON_DECODE ###########
+// @if feature("extension_api") || function("json_decode")
function _json_decode_value(value) {
switch (typeof (value)) {
@@ -1135,7 +1136,9 @@ function json_decode(_string) {
}
return _json_decode_object(pObj);
} // end json_decode
+// @endif json_decode
+// @if feature("extension_api") || function("json_encode")
var g_ENCODE_VISITED_LIST = new Map();
function _json_encode_value(value) {
@@ -1256,6 +1259,7 @@ function json_encode(_map, _prettify) {
return JSON.stringify(obj, null, _prettify ? 2 : 0);
} // end json_encode
+// @endif json_encode
// ########### JSON_STRINGIFY & JSON_PARSE ###########
diff --git a/scripts/functions/Function_Font.js b/scripts/functions/Function_Font.js
index b840c14e..dc4865fe 100644
--- a/scripts/functions/Function_Font.js
+++ b/scripts/functions/Function_Font.js
@@ -80,7 +80,6 @@ function draw_text(_x, _y, _text) {
///
///
// #############################################################################################
-var draw_text_colour = draw_text_color;
function draw_text_color(_x, _y, _text, _c1, _c2, _c3, _c4, _alpha)
{
if (!g_webGL) WarningFunction("draw_text_color() only uses the 1st colour");
@@ -106,6 +105,9 @@ function draw_text_color(_x, _y, _text, _c1, _c2, _c3, _c4, _alpha)
g_GlobalAlpha = oldalpha;
draw_set_color(oldcol);
}
+// @if function("draw_text_colour")
+var draw_text_colour = draw_text_color;
+// @endif
// #############################################################################################
/// Function:
@@ -126,7 +128,6 @@ function draw_text_color(_x, _y, _text, _c1, _c2, _c3, _c4, _alpha)
///
///
// #############################################################################################
-var draw_text_ext_colour = draw_text_ext_color;
function draw_text_ext_color(_x, _y, _text, _sep, _w, _c1, _c2, _c3, _c4, _alpha)
{
if (!g_webGL) WarningFunction("draw_text_ext_color() only uses the 1st colour");
@@ -151,7 +152,9 @@ function draw_text_ext_color(_x, _y, _text, _sep, _w, _c1, _c2, _c3, _c4, _alpha
g_GlobalAlpha = oldalpha;
draw_set_color(oldcol);
}
-
+// @if function("draw_text_ext_colour")
+var draw_text_ext_colour = draw_text_ext_color;
+// @endif
@@ -245,7 +248,6 @@ function draw_text_ext_transformed(_x, _y, _text, _sep, _w, _xscale, _yscale, _a
///
///
// #############################################################################################
-var draw_text_ext_transformed_colour = draw_text_ext_transformed_color;
function draw_text_ext_transformed_color(_x, _y, _text, _sep, _w, _xscale, _yscale, _angle, _c1, _c2, _c3, _c4, _alpha) {
if (!g_webGL) WarningFunction("draw_text_ext_transformed_color() only uses the 1st colour");
@@ -262,6 +264,9 @@ function draw_text_ext_transformed_color(_x, _y, _text, _sep, _w, _xscale, _ysca
g_GlobalAlpha = oldalpha;
draw_set_color(oldcol);
}
+// @if function("draw_text_ext_transformed_colour")
+var draw_text_ext_transformed_colour = draw_text_ext_transformed_color;
+// @endif
// #############################################################################################
@@ -284,7 +289,6 @@ function draw_text_ext_transformed_color(_x, _y, _text, _sep, _w, _xscale, _ysca
///
///
// #############################################################################################
-var draw_text_transformed_colour = draw_text_transformed_color;
function draw_text_transformed_color(_x, _y, _text, _xscale, _yscale, _angle, _c1, _c2, _c3, _c4, _alpha) {
if (!g_webGL) WarningFunction("draw_text_transformed_color() only uses the 1st colour");
@@ -301,7 +305,9 @@ function draw_text_transformed_color(_x, _y, _text, _xscale, _yscale, _angle, _c
g_GlobalAlpha = oldalpha;
draw_set_color(oldcol);
}
-
+// @if function("draw_text_transformed_colour")
+var draw_text_transformed_colour = draw_text_transformed_color;
+// @endif
// #############################################################################################
@@ -452,7 +458,6 @@ function font_get_name(_id) {
if (!pFont) return "";
return pFont.pName;
}
-var font_name = font_get_name;
// #############################################################################################
/// Function:
diff --git a/scripts/functions/Function_Game.js b/scripts/functions/Function_Game.js
index 5ea763b3..a0c6b9cf 100644
--- a/scripts/functions/Function_Game.js
+++ b/scripts/functions/Function_Game.js
@@ -67,20 +67,7 @@ function display_set_timing_method(_method){
function display_get_timing_method() {
return TimingMethod;
}
-// #############################################################################################
-/// Function:
-/// get a list of instances for this object (recursive)
-///
-///
-/// In: object ID to use
-/// Out:
-/// list of active instances - recursive
-///
-// #############################################################################################
-//function instance_number( _obj )
-//{
-// return g_pObjectManager.Get(_obj).Instances_Recursive.length;
-//}
+
// #############################################################################################
@@ -94,7 +81,7 @@ function yy_HiScoreContainer(_value, _name) {
this.value = _value;
}
-
+// @if function("draw_highscore") || function("highscore_*")
// #############################################################################################
/// Function:
@@ -138,8 +125,6 @@ function highscore_save() {
var file = JSON.stringify(HighScores);
SaveTextFile_Block("hiscores_data_", file);
}
-
-
// #############################################################################################
/// Function:
/// Draws the highscore table in the room in the indicated box, using the current font.
@@ -155,6 +140,7 @@ function highscore_save() {
// #############################################################################################
function draw_highscore(_x1, _y1, _x2, _y2)
{
+ // @if feature("fonts")
_x1 = yyGetInt32(_x1);
_y1 = yyGetInt32(_y1);
_x2 = yyGetInt32(_x2);
@@ -173,11 +159,9 @@ function draw_highscore(_x1, _y1, _x2, _y2)
_y1 += dy;
}
g_pFontManager.halign = halign;
+ // @endif fonts
}
-
-
-
// #############################################################################################
/// Function:
/// Clears the highscore list.
@@ -189,26 +173,11 @@ function draw_highscore(_x1, _y1, _x2, _y2)
// #############################################################################################
function highscore_clear()
{
- g_HighScoreValues[0]=
- g_HighScoreValues[1]=
- g_HighScoreValues[2]=
- g_HighScoreValues[3]=
- g_HighScoreValues[4]=
- g_HighScoreValues[5]=
- g_HighScoreValues[6]=
- g_HighScoreValues[7]=
- g_HighScoreValues[8]=
- g_HighScoreValues[9]=0;
- g_HighScoreNames[0]=
- g_HighScoreNames[1]=
- g_HighScoreNames[2]=
- g_HighScoreNames[3]=
- g_HighScoreNames[4]=
- g_HighScoreNames[5]=
- g_HighScoreNames[6]=
- g_HighScoreNames[7]=
- g_HighScoreNames[8]=
- g_HighScoreNames[9] = g_HighscoreNobody;
+ for (var i = 0; i < 10; i++)
+ {
+ g_HighScoreValues[i] = 0;
+ g_HighScoreNames[i] = g_HighscoreNobody;
+ }
}
// #############################################################################################
@@ -286,7 +255,7 @@ function highscore_name(_place)
if (_place < 1 || _place > MAX_HIGHSCORE) return "";
return g_HighScoreNames[_place-1];
}
-
+// @endif
// #############################################################################################
/// Function:
@@ -426,6 +395,7 @@ function event_perform_async(_pInst, _pOther, _event, _ds_map)
// #############################################################################################
function event_perform_timeline(_pInst, _other, _timelineInd, _eventInd)
{
+ // @if feature("timelines")
var timeline = g_pTimelineManager.Get(_timelineInd);
if ((timeline != null) && (timeline != undefined))
{
@@ -436,6 +406,7 @@ function event_perform_timeline(_pInst, _other, _timelineInd, _eventInd)
eventData.Event(_pInst, _pInst);
}
}
+ // @endif
}
// #############################################################################################
@@ -516,8 +487,10 @@ function event_user(_pInst, _pOther, _subevent) {
{
yyError("Error: illegal user event ID: " + _subevent);
}
- _subevent += GML_ev_user0;
+ // @if event("UserEvent*")
+ _subevent += GML_EVENT_OTHER_USER0;
event_perform(_pInst, _pOther, GML_EVENT_OTHER, _subevent);
+ // @endif
}
@@ -1073,6 +1046,7 @@ function sha1_file(_fname) { return "unsupported"; }
* See http://pajhome.org.uk/crypt/md5 for more info.
*/
+// @if function("md5_*")
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
@@ -1128,6 +1102,7 @@ function rstr_hmac_md5(key, data)
var hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
return binl2rstr(binl_md5(opad.concat(hash), 512 + 128));
}
+// @endif md5
/*
* Convert a raw string to a hex string
@@ -1304,6 +1279,7 @@ function binl2rstr(input)
return output;
}
+// @if function("md5_*")
/*
* Calculate the MD5 of an array of little-endian words, and a bit length.
*/
@@ -1424,6 +1400,7 @@ function md5_ii(a, b, c, d, x, s, t)
{
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
+// @endif md5
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
@@ -1444,7 +1421,7 @@ function bit_rol(num, cnt)
return (num << cnt) | (num >>> (32 - cnt));
}
-
+// @if function("sha1_string_*") || function("ds_map_secure_*") || function("buffer_sha1")
//and the sha-1 version from same place
function hex_sha1(s) { return rstr2hex(rstr_sha1(str2rstr_utf8(s))); }
@@ -1606,6 +1583,7 @@ function sha1_kt(t)
return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
(t < 60) ? -1894007588 : -899497514;
}
+// @endif sha1
// #############################################################################################
/// Function:
@@ -1678,12 +1656,20 @@ function ResourceGetTypeIndex(_name )
if ((ret = Resource_Find(_name, g_pGMFile.Backgrounds)) >= 0) { typeId.type= g_isZeus ? AT_Tiles : AT_Background, typeId.id = ret; return typeId; }
if ((ret = Resource_Find(_name, g_pGMFile.Paths)) >= 0) { typeId.type=AT_Path; typeId.id = ret; return typeId; }
if ((ret = Resource_Find(_name, g_pGMFile.Fonts)) >= 0) { typeId.type=AT_Font; typeId.id = ret; return typeId; }
+ // @if feature("timelines")
if ((ret = Resource_Find(_name, g_pGMFile.Timelines)) >= 0) { typeId.type=AT_Timeline; typeId.id = ret; return typeId; }
+ // @endif
if ((ret = Resource_Find_Script(_name, g_pGMFile.ScriptNames)) >= 0) { typeId.type=AT_Script; typeId.id = ret; return typeId; }
if ((ret = Resource_Find_Shader(_name, g_pGMFile.Shaders)) >= 0) { typeId.type=AT_Shader; typeId.id = ret; return typeId; }
+ // @if feature("sequences")
if ((ret = Resource_Find(_name, g_pGMFile.Sequences)) >= 0) { typeId.type=AT_Sequence; typeId.id = ret; return typeId; }
+ // @endif
+ // @if feature("animcurves")
if ((ret = Resource_Find(_name, g_pGMFile.AnimCurves)) >= 0) { typeId.type=AT_AnimCurve; typeId.id = ret; return typeId; }
+ // @endif
+ // @if feature("particles")
if ((ret = CParticleSystem.Find(_name)) >= 0) { typeId.type=AT_ParticleSystem; typeId.id = ret; return typeId; }
+ // @endif
return typeId;
}
@@ -1701,10 +1687,16 @@ function ResourceGetName( _index, _assetType )
case AT_Path: return ( path_exists(_index)) ? path_get_name(_index) : "";
case AT_Script: return ( script_exists(_index)) ? script_get_name(_index) : "";
case AT_Font: return ( font_exists(_index)) ? font_get_name(_index) : "";
+ // @if feature("timelines")
case AT_Timeline: return ( timeline_exists(_index)) ? timeline_get_name(_index) : "";
+ // @endif
case AT_Shader: return ( shader_exists(_index)) ? shader_get_name(_index) : "";
+ // @if feature("sequences")
case AT_Sequence: return ( _sequence_exists(_index)) ? sequence_get_name(_index) : "";
+ // @endif
+ // @if feature("animcurves")
case AT_AnimCurve: return ( _animcurve_exists(_index)) ? animcurve_get_name(_index) : "";
+ // @endif
case AT_ParticleSystem: {
var ps = CParticleSystem.Get(_index);
return (ps != null) ? ps.name : "";
@@ -1890,7 +1882,7 @@ CTimingSource.prototype.Reset= function()
this.m_elapsed_micros = 0;
if(this.m_fps >0.0)
{
- this.m_last_micros = YoYo_GetTimer();
+ this.m_last_micros = get_timer();
}
else
{
@@ -1909,7 +1901,7 @@ CTimingSource.prototype.Update=function()
current = this.m_last_micros + 1000000.0/this.m_fps;
}
else
- current = YoYo_GetTimer();
+ current = get_timer();
this.m_delta_micros = current - this.m_last_micros;
diff --git a/scripts/functions/Function_Graphics.js b/scripts/functions/Function_Graphics.js
index bfe3eff5..ed04e910 100644
--- a/scripts/functions/Function_Graphics.js
+++ b/scripts/functions/Function_Graphics.js
@@ -122,8 +122,9 @@ function display_set_gui_maximise(_xscale, _yscale, _xoffset, _yoffset)
Calc_GUI_Scale();
}
}
-
+// @if function("display_set_gui_maximize")
var display_set_gui_maximize = display_set_gui_maximise;
+// @endif
// #############################################################################################
/// Function:
@@ -218,9 +219,9 @@ function draw_clear( _col )
///
///
// #############################################################################################
-var draw_clear_alpha = draw_clear_alpha_RELEASE;
-function draw_clear_alpha_RELEASE(_col, _alpha)
-{
+function draw_clear_alpha(){}
+// @if feature("2d")
+draw_clear_alpha = (_col, _alpha) => {
_col = yyGetInt32(_col);
_alpha = yyGetReal(_alpha);
@@ -250,7 +251,8 @@ function draw_clear_alpha_RELEASE(_col, _alpha)
}
Graphics_Restore();
-}
+};
+// @endif
// #############################################################################################
@@ -270,9 +272,9 @@ function make_color_rgb(_red,_green,_blue)
{
return (yyGetInt32(_red)) | (yyGetInt32(_green) << 8) | (yyGetInt32(_blue) << 16);
}
-function make_color(_r, _g, _b) { return make_color_rgb(_r, _g, _b); }
+// @if function("make_colour_rgb")
var make_colour_rgb = make_color_rgb;
-var make_colour = make_color;
+// @endif
// #############################################################################################
/// Function:
@@ -288,7 +290,9 @@ function color_get_blue(_col)
{
return (yyGetInt32(_col) >> 16) & 0xff;
}
+// @if function("colour_get_blue")
var colour_get_blue = color_get_blue;
+// @endif
// #############################################################################################
/// Function:
@@ -304,7 +308,9 @@ function color_get_green(_col)
{
return (yyGetInt32(_col) >> 8) & 0xff;
}
+// @if function("colour_get_green")
var colour_get_green = color_get_green;
+// @endif
// #############################################################################################
@@ -321,7 +327,9 @@ function color_get_red(_col)
{
return (yyGetInt32(_col) & 0xff);
}
+// @if function("colour_get_red")
var colour_get_red = color_get_red;
+// @endif
// #############################################################################################
@@ -385,7 +393,9 @@ function color_get_hue(_col)
var hsv = Color_RGBtoHSV(_col);
return hsv.h;
}
+// @if function("colour_get_hue")
var colour_get_hue = color_get_hue;
+// @endif
// #############################################################################################
/// Function:
@@ -402,7 +412,9 @@ function color_get_saturation(_col)
var hsv = Color_RGBtoHSV(_col);
return hsv.s;
}
+// @if function("colour_get_saturation")
var colour_get_saturation = color_get_saturation;
+// @endif
// #############################################################################################
/// Function:
@@ -419,7 +431,9 @@ function color_get_value(_col)
var hsv = Color_RGBtoHSV(_col);
return hsv.v;
}
+// @if function("colour_get_value")
var colour_get_value = color_get_value;
+// @endif
// #############################################################################################
/// Function:
@@ -457,7 +471,8 @@ function merge_color(_col1,_col2,_amount)
return ((r<<16)&0xff0000) | ((g<<8)&0xff00) | (b&0xff);
}
-var merge_colour = merge_color;
+function merge_colour(){}
+compile_if_used(merge_colour = merge_color);
// #############################################################################################
/// Function:
@@ -523,7 +538,8 @@ function make_color_hsv( _hue,_saturation,_value )
return Result;
}
-var make_colour_hsv = make_color_hsv;
+function make_colour_hsv(){}
+compile_if_used(make_colour_hsv = make_color_hsv);
// #############################################################################################
@@ -539,10 +555,7 @@ function draw_set_alpha( _alpha )
_alpha = yyGetReal(_alpha);
// cap _alpha to between 0 and 1
- if (_alpha < 0) { _alpha = 0; }
- if (_alpha > 1) { _alpha = 1; }
-
- g_GlobalAlpha = _alpha;
+ g_GlobalAlpha = _alpha < 0 ? 0 : (_alpha > 1 ? 1 : _alpha);
g_GlobalColour_HTML_RGBA = GetHTMLRGBA(g_GlobalColour, g_GlobalAlpha);
}
@@ -573,7 +586,8 @@ function draw_get_color( )
{
return g_GlobalColour_GM;
}
-var draw_get_colour = draw_get_color;
+function draw_get_colour(){}
+compile_if_used(draw_get_colour = draw_get_color);
// #############################################################################################
/// Function:
@@ -592,8 +606,9 @@ function draw_set_color( _colour )
g_GlobalColour_HTML_RGB = GetHTMLRGB(g_GlobalColour);
g_GlobalColour_HTML_RGBA = GetHTMLRGBA(g_GlobalColour,g_GlobalAlpha);
}
-
+// @if function("draw_set_colour")
var draw_set_colour = draw_set_color;
+// @endif
function draw_set_lighting(_enable)
{
@@ -682,7 +697,9 @@ function draw_roundrect_ext(_x1, _y1, _x2, _y2, _radx, _rady, _outline) {
function draw_roundrect_color(_x1, _y1, _x2, _y2, _col1, _col2, _outline) {
draw_roundrect_color_ext(_x1, _y1, _x2, _y2, 10, 10, _col1, _col2, _outline);
}
+// @if function("draw_roundrect_colour")
var draw_roundrect_colour = draw_roundrect_color;
+// @endif
// #############################################################################################
/// Function:
@@ -696,8 +713,9 @@ var draw_roundrect_colour = draw_roundrect_color;
/// Outline the rect?
///
// #############################################################################################
-var draw_roundrect_color_ext = draw_roundrect_color_EXT_RELEASE;
-var draw_roundrect_colour_ext = draw_roundrect_color_EXT_RELEASE;
+function draw_roundrect_color_ext(){}
+function draw_roundrect_colour_ext(){}
+// @if feature("2d")
function draw_roundrect_color_EXT_RELEASE(_x1, _y1, _x2, _y2, _radx, _rady, _col1, _col2, _outline)
{
_x1 = yyGetReal(_x1);
@@ -758,6 +776,9 @@ function draw_roundrect_color_EXT_RELEASE(_x1, _y1, _x2, _y2, _radx, _rady, _col
graphics.fill();
}
}
+draw_roundrect_color_ext = draw_roundrect_color_EXT_RELEASE;
+compile_if_used(draw_roundrect_colour_ext = draw_roundrect_color_EXT_RELEASE);
+// @endif
// #############################################################################################
/// Function:
@@ -771,7 +792,8 @@ function draw_roundrect_color_EXT_RELEASE(_x1, _y1, _x2, _y2, _radx, _rady, _col
/// Outline the rect?
///
// #############################################################################################
-var draw_rectangle = draw_rectangle_RELEASE;
+function draw_rectangle(){}
+// @if feature("2d")
function draw_rectangle_RELEASE ( _x1,_y1, _x2,_y2, _outline )
{
_x1 = yyGetReal(_x1);
@@ -807,6 +829,8 @@ function draw_rectangle_RELEASE ( _x1,_y1, _x2,_y2, _outline )
graphics._fillRect(_x1,_y1, _x2-_x1+1,_y2-_y1+1);
}
}
+draw_rectangle = draw_rectangle_RELEASE; // used for vkeys
+// @endif
// #############################################################################################
/// Function:
@@ -821,8 +845,9 @@ function draw_rectangle_RELEASE ( _x1,_y1, _x2,_y2, _outline )
/// Whether or not to draw the rect as an outline
///
// #############################################################################################
-var draw_rectangle_color = draw_rectangle_color_RELEASE;
-var draw_rectangle_colour = draw_rectangle_color_RELEASE;
+function draw_rectangle_color(){}
+function draw_rectangle_colour(){}
+// @if feature("2d")
function draw_rectangle_color_RELEASE( _x1,_y1, _x2,_y2, _col1, _col2,_col3,_col4, _outline ) {
//return;
@@ -866,74 +891,9 @@ function draw_rectangle_color_RELEASE( _x1,_y1, _x2,_y2, _col1, _col2,_col3,_
graphics._fillRect(_x1 + 0.5, _y1 + 0.5, (_x2 - _x1), (_y2 - _y1));
}
}
-
-// #############################################################################################
-/// Function:
-/// Draw a rectangle with a gradient
-///
-///
-/// In: Top X coordinate
-/// Top Y coordinate
-/// Bottom X coordinate
-/// Bottom X coordinate
-/// Start colour of the rect as a number
-/// End colour of the rect as a number
-/// Whether or not the gradient should be vertical (or horizontal)
-/// Whether or not to draw the rect as an outline
-///
-// #############################################################################################
-var draw_rectangle_gradient = draw_rectangle_gradient_RELEASE;
-function draw_rectangle_gradient_RELEASE(_x1, _y1, _x2, _y2, _col1, _col2, _vert, _outline)
-{
- _x1 = yyGetReal(_x1);
- _y1 = yyGetReal(_y1);
- _x2 = yyGetReal(_x2);
- _y2 = yyGetReal(_y2);
- _col1 = yyGetInt32(_col1);
- _col2 = yyGetInt32(_col2);
- _vert = yyGetBool(_vert);
- _outline = yyGetBool(_outline);
-
- graphics.globalAlpha = g_GlobalAlpha;
- graphics.lineWidth = 1;
-
- var col1 = GetHTMLRGBA( ConvertGMColour(_col1), 1.0 );
- var col2 = GetHTMLRGBA( ConvertGMColour(_col2), 1.0 );
- var gradient;
- if (_vert) {
- gradient = graphics.createLinearGradient(_x1, _y1, _x1, _y2);
- }
- else {
- gradient = graphics.createLinearGradient(_x1, _y1, _x2, _y1);
- }
- gradient.addColorStop(0, col1 );
- gradient.addColorStop(1, col2 );
-
- if (_outline)
- {
- if (offsethack != 0.0)
- {
- _x1 += offsethack;
- _y1 += offsethack;
- _x2 += offsethack;
- _y2 += offsethack;
- }
-
- graphics.strokeStyle = gradient;
- graphics._strokeRect(_x1 + 0.5, _y1 + 0.5, _x2 - _x1, _y2 - _y1);
- }
- else
- {
- if (offsethack != 0.0)
- {
- _x2 += offsethack;
- _y2 += offsethack;
- }
-
- graphics.fillStyle = gradient;
- graphics._fillRect(_x1 + 0.5, _y1 + 0.5, _x2 - _x1, _y2 - _y1);
- }
-}
+draw_rectangle_color = draw_rectangle_color_RELEASE; // NB! used to clear screen
+compile_if_used(draw_rectangle_colour = draw_rectangle_color_RELEASE);
+// @endif
// #############################################################################################
/// Function:
@@ -946,9 +906,9 @@ function draw_rectangle_gradient_RELEASE(_x1, _y1, _x2, _y2, _col1, _col2, _vert
///
///
// #############################################################################################
-var draw_point = draw_point_RELEASE;
-function draw_point_RELEASE(_x, _y)
-{
+function draw_point(){}
+// @if feature("2d")
+draw_point = (_x, _y) => {
_x = yyGetReal(_x);
_y = yyGetReal(_y);
@@ -961,8 +921,8 @@ function draw_point_RELEASE(_x, _y)
graphics.globalAlpha = g_GlobalAlpha;
graphics.fillStyle = g_GlobalColour_HTML_RGBA;
graphics._fillRect(_x, _y, 1, 1);
-}
-
+};
+// @endif
// #############################################################################################
@@ -977,7 +937,9 @@ function draw_point_RELEASE(_x, _y)
///
///
// #############################################################################################
-function draw_line_width(_x1, _y1, _x2, _y2, _w) {
+function draw_line_width(){}
+// @if feature("2d")
+draw_line_width = (_x1, _y1, _x2, _y2, _w) => {
_x1 = yyGetReal(_x1);
_y1 = yyGetReal(_y1);
@@ -1003,8 +965,8 @@ function draw_line_width(_x1, _y1, _x2, _y2, _w) {
graphics._closePath();
graphics._stroke();
graphics._fillRect(_x2, _y2, 1, 1); // CHROME doesn't fill in the bottom pixel!
-}
-
+};
+// @endif
@@ -1037,13 +999,10 @@ function draw_line(_x1,_y1,_x2,_y2)
/// The colour of the pixel, or 0 for off screen/canvas.
///
// #############################################################################################
-var draw_getpixel = draw_getpixel_RELEASE;
-var draw_getpixel_ext = draw_getpixel_ext_RELEASE;
-function draw_getpixel_RELEASE(_x, _y)
-{
- return draw_getpixel_ext_RELEASE(yyGetReal(_x), yyGetReal(_y)) & 0x00ffffff;
-}
+function draw_getpixel(){}
+function draw_getpixel_ext(){}
+// @if feature("2d")
function draw_getpixel_ext_RELEASE(_x, _y)
{
var ws = canvas.width / g_OriginalWidth;
@@ -1053,6 +1012,9 @@ function draw_getpixel_ext_RELEASE(_x, _y)
var col = GetCanvasPixel(canvas, yyGetReal(_x) * ws, yyGetReal(_y) * hs);
return col;
}
+compile_if_used(draw_getpixel = (_x, _y) => draw_getpixel_ext_RELEASE(yyGetReal(_x), yyGetReal(_y)) & 0x00ffffff);
+compile_if_used(draw_getpixel_ext = draw_getpixel_ext_RELEASE);
+// @endif
// #############################################################################################
/// Function:
@@ -1070,7 +1032,8 @@ function draw_getpixel_ext_RELEASE(_x, _y)
///
///
// #############################################################################################
-var draw_triangle = draw_triangle_RELEASE;
+function draw_triangle(){}
+// @if feature("2d")
function draw_triangle_RELEASE(_x1, _y1, _x2, _y2, _x3, _y3, _outline) {
_x1 = yyGetReal(_x1);
@@ -1128,6 +1091,10 @@ function draw_triangle_RELEASE(_x1, _y1, _x2, _y2, _x3, _y3, _outline) {
}
}
+// @if function("draw_triangle") || function("draw_arrow") || function("physics_world_draw_debug")
+draw_triangle = draw_triangle_RELEASE;
+// @endif
+// @endif
// #############################################################################################
/// Function:
@@ -1148,8 +1115,9 @@ function draw_triangle_RELEASE(_x1, _y1, _x2, _y2, _x3, _y3, _outline) {
///
///
// #############################################################################################
-var draw_triangle_color = draw_triangle_color_RELEASE;
-var draw_triangle_colour = draw_triangle_color_RELEASE;
+function draw_triangle_color(){}
+function draw_triangle_colour(){}
+// @if feature("2d")
function draw_triangle_color_RELEASE(_x1, _y1, _x2, _y2, _x3, _y3, _col1, _col2, _col3, _outline) {
var col1 = GetHTMLRGB(ConvertGMColour(_col1)|0xff000000);
@@ -1160,7 +1128,6 @@ function draw_triangle_color_RELEASE(_x1, _y1, _x2, _y2, _x3, _y3, _col1, _col2,
_col1 = yyGetInt32(_col1);
_col2 = yyGetInt32(_col2);
_col3 = yyGetInt32(_col3);
- _col4 = yyGetInt32(_col4);
_outline = yyGetBool(_outline);
/*_x1 += 0.5;
@@ -1210,6 +1177,9 @@ function draw_triangle_color_RELEASE(_x1, _y1, _x2, _y2, _x3, _y3, _col1, _col2,
graphics.lineJoin = "miter";
}
}
+compile_if_used(draw_triangle_color = draw_triangle_color_RELEASE);
+compile_if_used(draw_triangle_colour = draw_triangle_color_RELEASE);
+// @endif
// #############################################################################################
/// Function:
@@ -1233,8 +1203,7 @@ function draw_triangle_color_RELEASE(_x1, _y1, _x2, _y2, _x3, _y3, _col1, _col2,
///
///
// #############################################################################################
-var draw_healthbar_ex = draw_healthbar_ex_RELEASE;
-function draw_healthbar_ex_RELEASE(_x1, _y1, _x2, _y2, _amount, _backcol, _mincol, _midcol, _maxcol, _direction, _showback, _showborder)
+function draw_healthbar_ex(_x1, _y1, _x2, _y2, _amount, _backcol, _mincol, _midcol, _maxcol, _direction, _showback, _showborder)
{
_x1 = yyGetReal(_x1);
_y1 = yyGetReal(_y1);
@@ -1369,8 +1338,7 @@ function draw_get_circle_precision()
///
///
// #############################################################################################
-var draw_arrow = draw_arrow_RELEASE;
-function draw_arrow_RELEASE(x1, y1, x2, y2, size)
+function draw_arrow(x1, y1, x2, y2, size)
{
x1 = yyGetReal(x1);
y1 = yyGetReal(y1);
@@ -1427,8 +1395,9 @@ function draw_ellipse(_x1, _y1, _x2, _y2, _outline) {
///
///
// #############################################################################################
-var draw_ellipse_color = draw_ellipse_color_RELEASE;
-var draw_ellipse_colour = draw_ellipse_color_RELEASE;
+function draw_ellipse_color(){}
+function draw_ellipse_colour(){}
+// @if feature("2d")
function draw_ellipse_color_RELEASE(x, y, x1, y1, _col1, _col2, outline)
{
x = yyGetReal(x);
@@ -1486,6 +1455,11 @@ function draw_ellipse_color_RELEASE(x, y, x1, y1, _col1, _col2, outline)
graphics.fill();
}
}
+// @if function("draw_ellipse") || function("draw_ellipse_color")
+draw_ellipse_color = draw_ellipse_color_RELEASE;
+// @endif
+compile_if_used(draw_ellipse_colour = draw_ellipse_color_RELEASE);
+// @endif
// #############################################################################################
@@ -1502,10 +1476,10 @@ function draw_ellipse_color_RELEASE(x, y, x1, y1, _col1, _col2, outline)
///
///
// #############################################################################################
-var draw_circle_color = draw_circle_color_RELEASE;
-var draw_circle_colour = draw_circle_color_RELEASE;
-function draw_circle_color_RELEASE(_x, _y, _r, _col1, _col2, _outline)
-{
+function draw_circle_color(){}
+function draw_circle_colour(){}
+// @if feature("2d")
+function draw_circle_color_RELEASE(_x, _y, _r, _col1, _col2, _outline) {
_x = yyGetReal(_x);
_y = yyGetReal(_y);
_r = yyGetReal(_r);
@@ -1542,6 +1516,11 @@ function draw_circle_color_RELEASE(_x, _y, _r, _col1, _col2, _outline)
}
graphics._closePath();
}
+// @if function("draw_circle") || function("draw_circle_color")
+draw_circle_color = draw_circle_color_RELEASE; // used for draw_circle
+// @endif
+compile_if_used(draw_circle_colour = draw_circle_color_RELEASE);
+// @endif
// #############################################################################################
/// Function:
@@ -1573,10 +1552,10 @@ function draw_circle(_x,_y,_r,_outline) {
///
///
// #############################################################################################
-var draw_point_color = draw_point_color_RELEASE;
-var draw_point_colour = draw_point_color_RELEASE;
-function draw_point_color_RELEASE(_x, _y, _col)
-{
+function draw_point_color(){};
+function draw_point_colour(){};
+// @if feature("2d")
+function draw_point_color_RELEASE(_x, _y, _col) {
_x = yyGetReal(_x);
_y = yyGetReal(_y);
@@ -1592,8 +1571,9 @@ function draw_point_color_RELEASE(_x, _y, _col)
graphics.fillStyle = col1;
graphics._fillRect(_x,_y,1,1);
}
-
-
+compile_if_used(draw_point_color = draw_point_color_RELEASE);
+compile_if_used(draw_point_colour = draw_point_color_RELEASE);
+// @endif
// #############################################################################################
@@ -1608,10 +1588,10 @@ function draw_point_color_RELEASE(_x, _y, _col)
///
///
// #############################################################################################
-var draw_line_width_color = draw_line_width_color_RELEASE;
-var draw_line_width_colour = draw_line_width_color_RELEASE;
-function draw_line_width_color_RELEASE(_x1, _y1, _x2, _y2, _w, _col1, _col2)
-{
+function draw_line_width_color(){}
+function draw_line_width_colour(){}
+// @if feature("2d")
+function draw_line_width_color_RELEASE(_x1, _y1, _x2, _y2, _w, _col1, _col2) {
_x1 = yyGetReal(_x1);
_y1 = yyGetReal(_y1);
_x2 = yyGetReal(_x2);
@@ -1646,6 +1626,9 @@ function draw_line_width_color_RELEASE(_x1, _y1, _x2, _y2, _w, _col1, _col2)
graphics._stroke();
graphics._closePath();
}
+draw_line_width_color = draw_line_width_color_RELEASE;
+compile_if_used(draw_line_width_colour = draw_line_width_color_RELEASE);
+// @endif
// #############################################################################################
@@ -1664,7 +1647,9 @@ function draw_line_color(_x1,_y1,_x2,_y2,_col1,_col2)
{
draw_line_width_color(_x1,_y1, _x2,_y2, 1, _col1,_col2);
}
+// @if function("draw_line_colour")
var draw_line_colour = draw_line_color;
+// @endif
// #############################################################################################
@@ -1716,27 +1701,6 @@ function draw_button(_x1, _y1, _x2, _y2, _down)
draw_rectangle_color(_x1,_y1, _x2,_y2, g_GlobalColour_GM, g_GlobalColour_GM, g_GlobalColour_GM, g_GlobalColour_GM, false);
}
-
-// #############################################################################################
-/// Function:
-/// Draws an ellipse with the given bounding box with a gradient from the centre
-/// of the ellipse to the max radius of the ellipse
-///
-///
-/// In:
-///
-///
-///
-///
-/// Out:
-///
-///
-// #############################################################################################
-function draw_ellipse_gradient(x, y, x1, y1, col1, col2, outline)
-{
- draw_ellipse_color(x, y, x1, y1, col1, col2, outline);
-}
-
// #############################################################################################
/// Function:
/// Indicates what blend mode to use. The following values are possible:
@@ -1783,8 +1747,7 @@ function draw_set_blend_mode(_blend)
///
///
// #############################################################################################
-var draw_set_blend_mode_ext = draw_set_blend_mode_ext_html5;
-function draw_set_blend_mode_ext_html5(src, dest) {
+function draw_set_blend_mode_ext(src, dest) {
ErrorFunction("Blend modes only available in WebGL mode.");
}
diff --git a/scripts/functions/Function_IAP.js b/scripts/functions/Function_IAP.js
index 4268ffac..2200ebc2 100644
--- a/scripts/functions/Function_IAP.js
+++ b/scripts/functions/Function_IAP.js
@@ -10,99 +10,3 @@
//
// **********************************************************************************************************************
-// #############################################################################################
-
-
-// #############################################################################################
-// Deprecated functions
-function iap_store_status() { return iap_status(); }
-function iap_event_queue() { ErrorFunction("iap_event_queue()"); }
-function iap_product_status() { ErrorFunction("iap_product_status()"); }
-//function iap_is_purchased() { ErrorFunction("iap_is_purchased()"); }
-function iap_is_downloaded() { ErrorFunction("iap_is_downloaded()"); }
-function iap_product_files() { ErrorFunction("iap_product_files()"); }
-function iap_files_purchased() { ErrorFunction("iap_files_purchased()"); }
-
-
-
-// #############################################################################################
-/// Function:
-/// Enable in app purchase
-///
-// #############################################################################################
-function iap_activate(_val) {
-
-}
-
-// #############################################################################################
-/// Function:
-/// Return the current status of the store
-///
-// #############################################################################################
-function iap_status() {
- return -1;
-}
-
-// #############################################################################################
-/// Function:
-/// Acquire a product
-///
-// #############################################################################################
-function iap_acquire(_product, _payload) {
-
-
- return -1;
-}
-
-// #############################################################################################
-/// Function:
-/// Consume an acquired product
-///
-// #############################################################################################
-function iap_consume(_product) {
-
-
-}
-
-
-// #############################################################################################
-/// Function:
-/// Check to see if the product has been purchased as far as we're concerned
-///
-// #############################################################################################
-function iap_restore_all() {
-
-
-}
-
-// #############################################################################################
-/// Function:
-/// Return the full set of iap products known about
-///
-// #############################################################################################
-function iap_enumerate_products(_list) {
-
-
-}
-
-// #############################################################################################
-/// Function:
-/// Fill out the provided ds_map with the product information
-///
-// #############################################################################################
-function iap_product_details(_product, _map) {
-
- return 0; //return 0 if product was not found, to be consistent with native
-}
-
-// #############################################################################################
-/// Function:
-/// Fill out the provided ds_map with the purchase information
-///
-// #############################################################################################
-function iap_purchase_details(_purchase, _map) {
-
- return 0; //return 0 if purchase was not found, to be consistent with native
-}
-
-
diff --git a/scripts/functions/Function_Instance.js b/scripts/functions/Function_Instance.js
index 7983fa12..1b210566 100644
--- a/scripts/functions/Function_Instance.js
+++ b/scripts/functions/Function_Instance.js
@@ -1531,6 +1531,7 @@ function instance_copy(_inst, _performevent)
/// Perform destroy and create events?
///
// #############################################################################################
+// @if function("position_change") || function("instance_change")
function instance_change_RELEASE(_inst, _objindex, _perf)
{
_perf = yyGetBool(_perf);
@@ -1544,7 +1545,9 @@ function instance_change_RELEASE(_inst, _objindex, _perf)
_inst.UpdateSpriteIndex(_inst.pObject.SpriteIndex);
// Change over the physics body if one exists/should exist
+ // @if feature("physics")
_inst.RebuildPhysicsBody(g_RunRoom);
+ // @endif
if( _perf ) {
_inst.PerformEvent(EVENT_PRE_CREATE, 0, _inst, _inst );
@@ -1562,7 +1565,8 @@ function instance_change_DEBUG(_inst, _objindex, _perf)
}
instance_change_RELEASE(_inst, _objindex, yyGetBool(_perf));
}
-var instance_change = instance_change_DEBUG;
+var instance_change = instance_change_DEBUG;
+// @endif
// #############################################################################################
/// Function:
diff --git a/scripts/functions/Function_Layers.js b/scripts/functions/Function_Layers.js
index a5880e5c..7afabe11 100644
--- a/scripts/functions/Function_Layers.js
+++ b/scripts/functions/Function_Layers.js
@@ -452,9 +452,11 @@ LayerManager.prototype.RemoveElementFromLayer= function(_room,_el,_layer,_remove
case eLayerElementType_OldTilemap:
this.RemoveOldTilemapElement(layer,element);
break;
+ // @if feature("sprites")
case eLayerElementType_Sprite:
this.RemoveSpriteElement(layer,element);
break;
+ // @endif sprites
case eLayerElementType_Tilemap:
this.RemoveTilemapElement(layer,element);
break;
@@ -464,9 +466,11 @@ LayerManager.prototype.RemoveElementFromLayer= function(_room,_el,_layer,_remove
case eLayerElementType_Tile:
this.RemoveTileElement(layer,element);
break;
+ // @if feature("sequences")
case eLayerElementType_Sequence:
this.RemoveSequenceElement(layer,element);
- break;
+ break;
+ // @endif
};
// This doesn't exist just now - need to implement
@@ -628,11 +632,12 @@ LayerManager.prototype.BuildTilemapElementRuntimeData = function( _room ,_layer,
LayerManager.prototype.BuildParticleElementRuntimeData = function( _room ,_layer,_element)
{
+ // @if feature("particles")
if (_element.m_ps != -1 && _element.m_systemID == -1)
{
CParticleSystem.Get(_element.m_ps).MakeInstance(_layer.m_id, false, _element);
}
-
+ // @endif
_element.m_bRuntimeDataInitialised=true;
};
@@ -643,6 +648,7 @@ LayerManager.prototype.BuildTileElementRuntimeData = function( _room ,_layer,_el
LayerManager.prototype.BuildSequenceElementRuntimeData = function (_room, _layer, _element)
{
+ // @if feature("sequences")
var sequenceInstance = g_pSequenceManager.GetNewInstance();
sequenceInstance.m_sequenceIndex = _element.m_sequenceIndex;
@@ -658,6 +664,7 @@ LayerManager.prototype.BuildSequenceElementRuntimeData = function (_room, _layer
g_pSequenceManager.HandleInstanceEvent(sequenceInstance, EVENT_CREATE);
_element.m_bRuntimeDataInitialised = true;
+ // @endif
};
LayerManager.prototype.BuildElementRuntimeData = function( _room ,_layer,_element)
@@ -684,7 +691,9 @@ LayerManager.prototype.BuildElementRuntimeData = function( _room ,_layer,_elemen
case eLayerElementType_Tilemap: this.BuildTilemapElementRuntimeData(_room, _layer, _element); break;
case eLayerElementType_ParticleSystem: this.BuildParticleElementRuntimeData(_room, _layer, _element); break;
case eLayerElementType_Tile: this.BuildTileElementRuntimeData(_room, _layer, _element); break;
+ // @if feature("sequences")
case eLayerElementType_Sequence: this.BuildSequenceElementRuntimeData(_room, _layer, _element); break;
+ // @endif
}
};
@@ -701,7 +710,7 @@ LayerManager.prototype.BuildRoomLayerRuntimeData = function(_room)
for(var i=0;i<_room.m_Layers.length;i++)
{
var player = _room.m_Layers.Get(i);
- player.m_timer = YoYo_GetTimer();
+ player.m_timer = get_timer();
for(var j=0;j0)
@@ -1913,8 +1932,10 @@ LayerManager.prototype.BuildRoomLayers = function(_room,_roomLayers)
}
}
+ // @endif sprites
// Sequences
+ // @if feature("sequences")
var numsequences = 0;
if (pLayer.ecount != undefined) numsequences = pLayer.ecount;
if (numsequences > 0) {
@@ -1940,8 +1961,10 @@ LayerManager.prototype.BuildRoomLayers = function(_room,_roomLayers)
this.AddNewElement(_room, NewLayer, NewSequence, false);
}
}
+ // @endif
// Particles
+ // @if feature("particles")
var numparticles = 0;
if (pLayer.pcount != undefined) numparticles = pLayer.pcount;
@@ -1965,6 +1988,7 @@ LayerManager.prototype.BuildRoomLayers = function(_room,_roomLayers)
this.AddNewElement(_room, NewLayer, NewParticle, false);
}
}
+ // @endif
}
else if(pLayer.type === YYLayerType_Tile)
{
@@ -2810,6 +2834,7 @@ function layer_sprite_index( arg1,arg2)
el.m_imageIndex = yyGetInt32(arg2);
var frame = yyGetInt32(arg2);
+ // @if feature("sprites")
var sprite = g_pSpriteManager.Get(el.m_spriteIndex);
if (sprite != null)
@@ -2845,6 +2870,7 @@ function layer_sprite_index( arg1,arg2)
}
}
else
+ // @endif sprites
{
el.m_imageIndex = frame; // just use value as-is
}
diff --git a/scripts/functions/Function_Maths.js b/scripts/functions/Function_Maths.js
index 0421dfa6..9078f7d2 100644
--- a/scripts/functions/Function_Maths.js
+++ b/scripts/functions/Function_Maths.js
@@ -282,7 +282,6 @@ function point_direction(_x1,_y1, _x2,_y2)
}
}
}
-function ComputeDir(_x1,_y1, _x2,_y2){ return point_direction(_x1,_y1, _x2,_y2); }
// #############################################################################################
@@ -987,8 +986,8 @@ function radtodeg(_x) {
// #############################################################################################
function mean()
{
- var args = mean.arguments;
- var argc = mean.arguments.length;
+ var args = arguments;
+ var argc = arguments.length;
if (argc == 0) return 0;
@@ -1012,8 +1011,8 @@ function mean()
// #############################################################################################
function median()
{
- var args = median.arguments;
- var argc = median.arguments.length;
+ var args = arguments;
+ var argc = arguments.length;
if (argc == 0) return 0;
@@ -1120,7 +1119,9 @@ function dot_product_normalised(_x1,_y1,_x2,_y2)
// return DOT product
return (_x1 * _x2 + _y1 * _y2) / (mag1 * mag2);
}
+// @if function("dot_product_normalized")
var dot_product_normalized = dot_product_normalised;
+// @endif
// #############################################################################################
/// Function:
@@ -1154,7 +1155,9 @@ function dot_product_3d_normalised(_x1, _y1, _z1, _x2, _y2, _z2) {
// return DOT product
return (_x1 * _x2 + _y1 * _y2 + _z1 * _z2) / (mag1 * mag2);
}
+// @if function("dot_product_3d_normalized")
var dot_product_3d_normalized = dot_product_3d_normalised;
+// @endif
// #############################################################################################
/// Function:
diff --git a/scripts/functions/Function_MotionPlanning.js b/scripts/functions/Function_MotionPlanning.js
index 18a5fccc..0fb7dba9 100644
--- a/scripts/functions/Function_MotionPlanning.js
+++ b/scripts/functions/Function_MotionPlanning.js
@@ -20,32 +20,6 @@ var MPPot_Maxrot = 30,
MPPot_Ahead = 3,
MPPot_OnSpot = true;
-// #############################################################################################
-/// Function:
-/// Computes the difference between the directions (positive <= 180)
-///
-///
-/// In:
-///
-/// Out:
-///
-///
-// #############################################################################################
-function DiffDir( _dir1 , _dir2)
-{
- var Result = 0.0;
-
- while ( _dir1 <= 0.0 ) { _dir1 = _dir1 + 360; }
- while ( _dir1 >= 360.0 ) { _dir1 = _dir1 - 360; }
- while ( _dir2 < 0.0 ) { _dir2 = _dir2 + 360; }
- while ( _dir2 >= 360. ) { _dir2 = _dir2 - 360; }
- Result = _dir2 - _dir1;
- if ( Result < 0 ) { Result = -Result; }
- if ( Result > 180 ) { Result = 360-Result; }
-
- return Result;
-}
-
// #############################################################################################
/// Function:
@@ -191,44 +165,6 @@ function mp_linear_step_object( _pInst, _x,_y,_stepsize,_obj)
return mp_linear_step_common( _pInst, _x,_y,_stepsize, _obj, true);
}
-
-// #############################################################################################
-/// Function:
-/// Take a step towards the indicated position with the given speed
-/// avoiding obstacles using some potential field approach
-/// returns whether the goal was reached
-///
-// #############################################################################################
-function TryDir(_dir, _pInst, _speed, _objind, _checkall)
-{
- var Result = false;
-
- var xnew = 0.0;
- var ynew = 0.0;
-
- // see whether angle is acceptable
- if (DiffDir(_dir, _pInst.direction) > MPPot_Maxrot) {
- return Result;
- }
- // check position a bit ahead
- xnew = _pInst.x + _speed * MPPot_Ahead * cos( Pi * _dir / 180 );
- ynew = _pInst.y - _speed * MPPot_Ahead * sin( Pi * _dir / 180 );
- if (true != TestFree(_pInst, xnew, ynew, _objind, _checkall)) {
- return Result;
- }
- //check next position
- xnew = _pInst.x + _speed * cos(Pi * _dir / 180);
- ynew = _pInst.y - _speed * sin(Pi * _dir / 180);
- if (true != TestFree(_pInst, xnew, ynew, _objind, _checkall)) {
- return Result;
- }
- // OK, so set the position
- _pInst.direction = _dir;
- _pInst.SetPosition(xnew, ynew);
- Result = true;
- return Result;
-}
-
// #############################################################################################
/// Function:
/// Common functionality for mp_potential_step* calls
@@ -269,7 +205,7 @@ function mp_potential_step_common(_pInst, _x,_y, _stepsize, _objindex, _checkall
{
if (TestFree(_pInst, _x, _y, _objindex, _checkall))
{
- _pInst.direction = ComputeDir(_pInst.x, _pInst.y, _x, _y);
+ _pInst.direction = point_direction(_pInst.x, _pInst.y, _x, _y);
_pInst.SetPosition(_x, _y);
}
Result = true;
@@ -277,7 +213,7 @@ function mp_potential_step_common(_pInst, _x,_y, _stepsize, _objindex, _checkall
}
// Try directions as much as possible towards the goal
- goaldir = ComputeDir(_pInst.x, _pInst.y, _x, _y);
+ goaldir = point_direction(_pInst.x, _pInst.y, _x, _y);
curdir = 0;
Result = false;
while ( curdir < 180 )
@@ -416,7 +352,7 @@ function Motion_Linear_Step(_inst, _x, _y, _speed, _objind, _checkall)
{
return Result;
}
- _inst.direction = ComputeDir(_inst.x, _inst.y, newx, newy);
+ _inst.direction = point_direction(_inst.x, _inst.y, newx, newy);
_inst.SetPosition( newx, newy );
return Result;
@@ -599,14 +535,14 @@ function Motion_Potential_Step(_inst, _x, _y, _speed,_objind, _checkall)
{
if (true == TestFree(_inst, _x, _y, _objind, _checkall))
{
- _inst.direction = ComputeDir(_inst.x,_inst.y,_x,_y);
+ _inst.direction = point_direction(_inst.x,_inst.y,_x,_y);
_inst.SetPosition(_x,_y);
}
return true;
}
// Try directions as much as possible towards the goal
- goaldir = ComputeDir(_inst.x, _inst.y,_x,_y);
+ goaldir = point_direction(_inst.x, _inst.y,_x,_y);
curdir = 0;
Result = false;
while ( curdir < 180 )
@@ -764,7 +700,7 @@ function mp_potential_path_object(_pInst, _path,_xg,_yg,_stepsize,_factor,_obj)
-
+// @if function("mp_grid_*")
// ##########################################################################################################################################################################################
// ##########################################################################################################################################################################################
@@ -1362,6 +1298,7 @@ function mp_grid_path(_pInst, _id, _path, _xstart, _ystart, _xgoal, _ygoal, _all
function mp_grid_to_ds_grid(_src, _dest)
{
+ // @if function("ds_grid_*")
_src = yyGetInt32(_src);
_dest = yyGetInt32(_dest);
@@ -1403,6 +1340,7 @@ function mp_grid_to_ds_grid(_src, _dest)
pGrid.m_pGrid[x + (y * pGrid.m_Width)] = pMPGrid.m_cells[(x * pMPGrid.m_vcells) + y];
}
}
+ // @endif
}
-
+// @endif mp_grid
diff --git a/scripts/functions/Function_Movement.js b/scripts/functions/Function_Movement.js
index 7d00160e..9be0354b 100644
--- a/scripts/functions/Function_Movement.js
+++ b/scripts/functions/Function_Movement.js
@@ -418,8 +418,6 @@ function move_bounce_all(_pInst, _adv)
Command_Bounce( _pInst, yyGetBool(_adv), true );
}
-var move_bounce = move_bounce_solid;
-
// #############################################################################################
/// Function:
diff --git a/scripts/functions/Function_Networking.js b/scripts/functions/Function_Networking.js
index b9d7812a..ee767405 100644
--- a/scripts/functions/Function_Networking.js
+++ b/scripts/functions/Function_Networking.js
@@ -14,6 +14,7 @@
//
// **********************************************************************************************************************
+// @if function("network_*")
var NETWORK_SOCKET_WS = 6;
var NETWORK_SOCKET_WSS = 7;
@@ -506,3 +507,5 @@ function network_destroy(_socket) {
yyWebSocketList_remove(wrap);
return 0;
}
+
+// @endif
diff --git a/scripts/functions/Function_Object.js b/scripts/functions/Function_Object.js
index 2fee4a84..f2fc0cab 100644
--- a/scripts/functions/Function_Object.js
+++ b/scripts/functions/Function_Object.js
@@ -51,7 +51,6 @@ function object_get_name(_ind)
if( !pObj ) return "";
return pObj.Name;
}
-var object_name = object_get_name;
// #############################################################################################
/// Function:
diff --git a/scripts/functions/Function_Particles.js b/scripts/functions/Function_Particles.js
index 033a0a6a..1d5b9d85 100644
--- a/scripts/functions/Function_Particles.js
+++ b/scripts/functions/Function_Particles.js
@@ -223,6 +223,7 @@ function ParticleSystemGetInfoImpl(_ind, _isInstance)
return pPSI;
}
+// @if feature("particles")
// #############################################################################################
/// Function:
///
@@ -1430,6 +1431,8 @@ function part_emitter_relative(_ps, _ind, _enable)
return ParticleSystem_Emitter_Relative(_ps, _ind, _enable);
}
+// @endif particles
+
// #############################################################################################
/// Function:
/// Creates an effect of the given kind (see above) at the indicated position.
diff --git a/scripts/functions/Function_Path.js b/scripts/functions/Function_Path.js
index 58ee226b..f90a435d 100644
--- a/scripts/functions/Function_Path.js
+++ b/scripts/functions/Function_Path.js
@@ -15,7 +15,7 @@
//
// **********************************************************************************************************************
-
+// @if feature("paths")
// #############################################################################################
/// Function:
@@ -767,4 +767,5 @@ function path_clear_points(_ind) {
pPath.Clear();
}
+// @endif
diff --git a/scripts/functions/Function_Physics.js b/scripts/functions/Function_Physics.js
index b9320f36..cfb78d2d 100644
--- a/scripts/functions/Function_Physics.js
+++ b/scripts/functions/Function_Physics.js
@@ -13,9 +13,11 @@
// 15/02/2012 1.0 CPH 1st version
//
// **********************************************************************************************************************
+// @if feature("physics")
var g_physicsFixtures = new yyAllocate();
var g_physicsObjects = new yyAllocate();
var g_physicsJoints = new yyAllocate();
+// @endif
// #############################################################################################
/// Function:
@@ -28,26 +30,11 @@ function physics_world_create(_pixelToMetreScale) {
if (g_RunRoom.m_pPhysicsWorld) {
g_RunRoom.m_pPhysicsWorld.SetPixelToMetreScale(_pixelToMetreScale);
- if(g_isZeus)
- {
- g_RunRoom.m_pPhysicsWorld.SetUpdateSpeed(g_GameTimer.GetFPS());
- }
- else
- {
- g_RunRoom.m_pPhysicsWorld.SetUpdateSpeed(g_RunRoom.GetSpeed());
- }
+ g_RunRoom.m_pPhysicsWorld.SetUpdateSpeed(g_GameTimer.GetFPS());
}
else {
- if(g_isZeus)
- {
- var physicsWorld = new yyPhysicsWorld(_pixelToMetreScale, g_GameTimer.GetFPS());
- g_RunRoom.m_pPhysicsWorld = physicsWorld;
- }
- else
- {
- var physicsWorld = new yyPhysicsWorld(_pixelToMetreScale, g_RunRoom.GetSpeed());
- g_RunRoom.m_pPhysicsWorld = physicsWorld;
- }
+ var physicsWorld = new yyPhysicsWorld(_pixelToMetreScale, g_GameTimer.GetFPS());
+ g_RunRoom.m_pPhysicsWorld = physicsWorld;
}
}
@@ -1025,11 +1012,12 @@ function physics_particle_group_delete(ind) {
///
// #############################################################################################
function physics_particle_draw(typemask, category, sprite, subimg) {
-
+ // @if feature("sprites")
var pSpr = g_pSpriteManager.Get(yyGetInt32(sprite));
if (pSpr !== null) {
g_RunRoom.m_pPhysicsWorld.DrawParticles(yyGetInt32(typemask), yyGetInt32(category), pSpr, yyGetInt32(subimg));
}
+ // @endif sprites
}
// #############################################################################################
@@ -1037,11 +1025,12 @@ function physics_particle_draw(typemask, category, sprite, subimg) {
///
// #############################################################################################
function physics_particle_draw_ext(typemask, category, sprite, subimg, xscale, yscale, angle, col, alpha) {
-
+ // @if feature("sprites")
var pSpr = g_pSpriteManager.Get(yyGetInt32(sprite));
if (pSpr !== null) {
g_RunRoom.m_pPhysicsWorld.DrawParticlesExt(yyGetInt32(typemask), yyGetInt32(category), pSpr, yyGetInt32(subimg), yyGetReal(xscale), yyGetReal(yscale), yyGetReal(angle), yyGetInt32(col), yyGetReal(alpha));
}
+ // @endif sprites
}
// #############################################################################################
diff --git a/scripts/functions/Function_Room.js b/scripts/functions/Function_Room.js
index fe8e7abe..32420fe1 100644
--- a/scripts/functions/Function_Room.js
+++ b/scripts/functions/Function_Room.js
@@ -139,7 +139,9 @@ function room_set_background_color(_ind,_colour,_show)
pRoom.m_pStorage.showColour = yyGetBool(_show);
}
+// @if function("room_set_background_colour")
var room_set_background_colour = room_set_background_color;
+// @endif
diff --git a/scripts/functions/Function_Shaders.js b/scripts/functions/Function_Shaders.js
index 39877f3a..64401849 100644
--- a/scripts/functions/Function_Shaders.js
+++ b/scripts/functions/Function_Shaders.js
@@ -11,23 +11,43 @@
// **********************************************************************************************************************
// WebGL.js redefines these to useful functions
-var fn_texture_get_texel_width = function() { ErrorFunction("yy_texture_get_texel_width()"); };
-var fn_texture_get_texel_height = function() { ErrorFunction("yy_texture_get_texel_height()"); };
-var fn_texture_set_stage = function() { ErrorFunction("texture_set_stage()"); };
-
-var fn_shader_is_compiled = function() { ErrorFunction("shader_is_compiled()"); };
-var fn_shader_set = function() { ErrorFunction("shader_set()"); };
-var fn_shader_get_uniform = function() { ErrorFunction("shader_get_uniform()"); };
-var fn_shader_set_uniform_i = function() { ErrorFunction("shader_set_uniform_i()"); };
-var fn_shader_set_uniform_f = function() { ErrorFunction("shader_set_uniform_f()"); };
-var fn_shader_set_uniform_matrix = function() { ErrorFunction("shader_set_uniform_matrix()"); };
-var fn_shader_get_sampler_index = function() { ErrorFunction("shader_set_uniform_matrix()"); };
-var fn_shader_enable_corner_id = function() { ErrorFunction("shader_enable_corner_id()"); };
-var fn_shader_set_uniform_i_array = function() { ErrorFunction("shader_set_uniform_array_i()"); };
-var fn_shader_set_uniform_f_array = function() { ErrorFunction("shader_set_uniform_array_f()"); };
-var fn_shader_set_uniform_f_buffer = function() { ErrorFunction("shader_set_uniform_buffer_f()"); };
-var fn_shader_set_uniform_matrix_array = function() { ErrorFunction("shader_set_uniform_matrix_array()"); };
-var fn_shader_get_name = function (index) { ErrorFunction("shader_get_name()"); };
+function fn_texture_get_texel_width(){}
+function fn_texture_get_texel_height(){}
+function fn_texture_set_stage(){}
+function fn_shader_is_compiled(){}
+function fn_shader_set(){}
+function fn_shader_get_uniform(){}
+function fn_shader_set_uniform_i(){}
+function fn_shader_set_uniform_f(){}
+function fn_shader_set_uniform_matrix(){}
+function fn_shader_get_sampler_index(){}
+function fn_shader_enable_corner_id(){}
+function fn_shader_set_uniform_i_array(){}
+function fn_shader_set_uniform_f_array(){}
+function fn_shader_set_uniform_f_buffer(){}
+function fn_shader_set_uniform_matrix_array(){}
+function fn_shader_get_name(){}
+// @if feature("2d") && (function("shader_*") || function("texture_get_texel_*") || function("texture_set_stage"))
+(() => {
+ let _stub = (_name, _val) => () => ErrorFunction(_name, _val);
+ compile_if_used(texture_get_texel_width, fn_texture_get_texel_width = _stub("fn_texture_get_texel_width", 0));
+ compile_if_used(texture_get_texel_height, fn_texture_get_texel_height = _stub("fn_texture_get_texel_height", 0));
+ compile_if_used(texture_set_stage, fn_texture_set_stage = _stub("fn_texture_set_stage"));
+ compile_if_used(shader_is_compiled, fn_shader_is_compiled = _stub("fn_shader_is_compiled", 0));
+ fn_shader_set = _stub("fn_shader_set");
+ compile_if_used(shader_get_uniform, fn_shader_get_uniform = _stub("fn_shader_get_uniform", -1));
+ compile_if_used(shader_set_uniform_i, fn_shader_set_uniform_i = _stub("fn_shader_set_uniform_i"));
+ compile_if_used(shader_set_uniform_f, fn_shader_set_uniform_f = _stub("fn_shader_set_uniform_f"));
+ compile_if_used(shader_set_uniform_matrix, fn_shader_set_uniform_matrix = _stub("fn_shader_set_uniform_matrix"));
+ compile_if_used(shader_get_sampler_index, fn_shader_get_sampler_index = _stub("fn_shader_get_sampler_index", -1));
+ compile_if_used(shader_enable_corner_id, fn_shader_enable_corner_id = _stub("fn_shader_enable_corner_id"));
+ compile_if_used(shader_set_uniform_i_array, fn_shader_set_uniform_i_array = _stub("fn_shader_set_uniform_i_array"));
+ compile_if_used(shader_set_uniform_f_array, fn_shader_set_uniform_f_array = _stub("fn_shader_set_uniform_f_array"));
+ compile_if_used(shader_set_uniform_f_buffer, fn_shader_set_uniform_f_buffer = _stub("fn_shader_set_uniform_f_buffer"));
+ compile_if_used(shader_set_uniform_matrix_array, fn_shader_set_uniform_matrix_array = _stub("fn_shader_set_uniform_matrix_array"));
+ compile_if_used(shader_get_name, fn_shader_get_name = _stub("fn_shader_get_name", ""));
+})();
+// @endif
var g_CurrentShader = -1;
// --------------------------------------------------------------------------------------------------------------------
diff --git a/scripts/functions/Function_Sound.js b/scripts/functions/Function_Sound.js
index eedfbcb9..04d83f8f 100644
--- a/scripts/functions/Function_Sound.js
+++ b/scripts/functions/Function_Sound.js
@@ -14,6 +14,7 @@
//
// **********************************************************************************************************************
+// @if feature("audio")
var audio_sounds = [];
var BASE_SOUND_INDEX = 300000;
var audio_sounds_index = BASE_SOUND_INDEX;
@@ -1060,6 +1061,7 @@ function Audio_EngineReportState()
ds_map_destroy(map);
g_pBuiltIn.async_load = -1;
}
+// @endif audio
function audio_system_is_available()
{
@@ -2429,6 +2431,7 @@ function audio_get_listener_info(index)
}
function audio_debug(trueFalse) {}
+// @if feature("audio")
//loading -------------------------
/** @this {XMLHttpRequest} */
function Audio_SoundError(e)
@@ -2929,6 +2932,7 @@ function AudioGroups_Init()
}
}
}
+// @endif audio
function audio_group_load( _groupId )
{
diff --git a/scripts/functions/Function_Sprite.js b/scripts/functions/Function_Sprite.js
index 427155ff..a1d4493b 100644
--- a/scripts/functions/Function_Sprite.js
+++ b/scripts/functions/Function_Sprite.js
@@ -33,8 +33,11 @@ var MASK_PRECISE = 0,
// #############################################################################################
function sprite_exists( _index )
{
- if( g_pSpriteManager.Get(yyGetInt32(_index)) == null ) return false;
- return true;
+ // @if feature("sprites")
+ return g_pSpriteManager.Get(yyGetInt32(_index)) != null;
+ // @else
+ return false;
+ // @endif sprites
}
@@ -51,9 +54,11 @@ function sprite_exists( _index )
// #############################################################################################
function sprite_get_width( _index )
{
+ // @if feature("sprites")
var pSpr = g_pSpriteManager.Get(yyGetInt32(_index));
- if( pSpr==null) return 0;
- return pSpr.width;
+ if( pSpr!=null) return pSpr.width;
+ // @endif sprites
+ return 0;
}
@@ -69,9 +74,11 @@ function sprite_get_width( _index )
// #############################################################################################
function sprite_get_height( _index )
{
+ // @if feature("sprites")
var pSpr = g_pSpriteManager.Get(yyGetInt32(_index));
- if( pSpr==null) return 0;
- return pSpr.height;
+ if( pSpr!=null) return pSpr.height;;
+ // @endif sprites
+ return 0;
}
@@ -381,7 +388,8 @@ function sprite_set_alpha_from_sprite( _dest, _src )
///
///
// #############################################################################################
-var sprite_add_from_screen = sprite_add_from_screen_RELEASE;
+function sprite_add_from_screen(){}
+// @if feature("2d")
function sprite_add_from_screen_RELEASE(_ind, _x, _y, _w, _h, _removeback, _smooth) {
_ind = yyGetInt32(_ind);
@@ -433,6 +441,8 @@ function sprite_add_from_screen_RELEASE(_ind, _x, _y, _w, _h, _removeback, _smoo
return _ind;
}
+compile_if_used(sprite_add_from_screen = sprite_add_from_screen_RELEASE);
+// @endif
// #############################################################################################
@@ -453,7 +463,8 @@ function sprite_add_from_screen_RELEASE(_ind, _x, _y, _w, _h, _removeback, _smoo
///
///
// #############################################################################################
-var sprite_create_from_surface = sprite_create_from_surface_RELEASE;
+function sprite_create_from_surface(){}
+// @if feature("2d")
function sprite_create_from_surface_RELEASE(_id, _x, _y, _w, _h, _removeback, _smooth, _xorig, _yorig)
{
_id = yyGetInt32(_id);
@@ -531,6 +542,8 @@ function sprite_create_from_surface_RELEASE(_id, _x, _y, _w, _h, _removeback, _s
return newindex;
}
+compile_if_used(sprite_create_from_surface = sprite_create_from_surface_RELEASE);
+// @endif
@@ -551,7 +564,8 @@ function sprite_create_from_surface_RELEASE(_id, _x, _y, _w, _h, _removeback, _s
///
///
// #############################################################################################
-var sprite_add_from_surface = sprite_add_from_surface_RELEASE;
+function sprite_add_from_surface(){}
+// @if feature("2d")
function sprite_add_from_surface_RELEASE(_ind, _id, _x, _y, _w, _h, _removeback, _smooth)
{
_ind = yyGetInt32(_ind);
@@ -603,6 +617,8 @@ function sprite_add_from_surface_RELEASE(_ind, _id, _x, _y, _w, _h, _removeback,
return _ind;
}
+compile_if_used(sprite_add_from_surface = sprite_add_from_surface_RELEASE);
+// @endif
@@ -652,8 +668,7 @@ function sprite_save(_ind,_subimg,_fname)
///
///
// #############################################################################################
-var sprite_duplicate = sprite_duplicate_RELEASE;
-function sprite_duplicate_RELEASE(_ind)
+function sprite_duplicate(_ind)
{
var pSpr = g_pSpriteManager.Get(yyGetInt32(_ind));
if (pSpr == null) return 0;
@@ -1488,9 +1503,7 @@ function sprite_get_texture(_spriteIndex, _frameIndex)
{
WebGLTexture: pTPE.texture,
TPE: pTPE,
- toString: () => {
- return "Texture:" + pTPE.texture.URL;
- }
+ toString: () => "Texture:" + pTPE.texture.URL
}
);
}
@@ -1812,6 +1825,7 @@ function sprite_get_info( _spriteIndex )
break;
case 1: // SWF
break;
+ // @if feature("spine")
case 2: // SPINE
if (pSpr.m_skeletonSprite != undefined) {
@@ -1888,10 +1902,12 @@ function sprite_get_info( _spriteIndex )
variable_struct_set(ret, "slots", slotsArray); //ret.gmlslots = slotsArray;
} // end if
break;
-
+ // @endif
} // end switch
-
+
+ // @if feature("nineslice")
variable_struct_set(ret, "nineslice", (pSpr.nineslicedata != undefined) ? pSpr.nineslicedata : undefined); //ret.gmlnineslice = (pSpr.nineslicedata != undefined) ? pSpr.nineslicedata : undefined;
+ // @endif
if (pSpr.sequence != undefined) {
// get broadcast messages
diff --git a/scripts/functions/Function_String.js b/scripts/functions/Function_String.js
index 143c64f4..939407b8 100644
--- a/scripts/functions/Function_String.js
+++ b/scripts/functions/Function_String.js
@@ -949,7 +949,22 @@ function string_count(_substr,_str)
// #############################################################################################
function string_hash_to_newline( _str )
{
- return String_Replace_Hash(yyGetString(_str), g_pFontManager.Font_Get(g_pFontManager.fontid), true);
+ let _result = "",
+ _start = 0,
+ i = 0, c, lc;
+ for (; i < _str.length; i++) {
+ c = _str[i];
+ if (c == "#") {
+ if (lc != "\\") {
+ _result += _str.substring(_start, i) + "\r\n";
+ } else {
+ _result += _str.substring(_start, i - 1) + "#";
+ }
+ _start = i + 1;
+ }
+ lc = c;
+ }
+ return _result + _str.substring(_start, i);
}
// #############################################################################################
diff --git a/scripts/functions/Function_Surface.js b/scripts/functions/Function_Surface.js
index d382a154..8a93f80f 100644
--- a/scripts/functions/Function_Surface.js
+++ b/scripts/functions/Function_Surface.js
@@ -30,8 +30,7 @@ var g_createsurfacedepthbuffers = true;
///
///
// #############################################################################################
-var surface_resize = surface_resize_RELEASE;
-function surface_resize_RELEASE(_id, _w, _h)
+function surface_resize(_id, _w, _h)
{
_id = yyGetInt32(_id);
_w = yyGetInt32(_w);
@@ -526,12 +525,7 @@ function surface_set_target_RELEASE(_id)
Graphics_SetViewPort(0, 0, pSurf.m_Width, pSurf.m_Height);
- if (g_isZeus) {
- UpdateDefaultCamera(0, 0, pSurf.m_Width, pSurf.m_Height, 0);
- }
- else {
- Graphics_SetViewArea(0, 0, pSurf.m_Width, pSurf.m_Height, 0);
- }
+ UpdateDefaultCamera(0, 0, pSurf.m_Width, pSurf.m_Height, 0);
if (g_webGL) g_webGL.Flush();
DirtyRoomExtents();
@@ -607,22 +601,17 @@ function surface_reset_target_RELEASE()
Calc_GUI_Scale();
} else {
Graphics_SetViewPort(g_clipx, g_clipy, g_clipw, g_cliph);
- if (g_isZeus) {
- var currcam = g_pCameraManager.GetActiveCamera();
- if ((activeCam == true) && (currcam != null))
- {
- UpdateCamera(camx, camy, camw, camh, cama, currcam);
- currcam.SetViewMat(new Matrix(camviewmat));
- currcam.SetProjMat(new Matrix(camprojmat));
- currcam.ApplyMatrices();
- }
- else
- {
- UpdateDefaultCamera(g_worldx, g_worldy, g_worldw, g_worldh, 0);
- }
+ var currcam = g_pCameraManager.GetActiveCamera();
+ if ((activeCam == true) && (currcam != null))
+ {
+ UpdateCamera(camx, camy, camw, camh, cama, currcam);
+ currcam.SetViewMat(new Matrix(camviewmat));
+ currcam.SetProjMat(new Matrix(camprojmat));
+ currcam.ApplyMatrices();
}
- else {
- Graphics_SetViewArea(g_worldx, g_worldy, g_worldw, g_worldh, 0);
+ else
+ {
+ UpdateDefaultCamera(g_worldx, g_worldy, g_worldw, g_worldh, 0);
}
}
}
@@ -687,12 +676,9 @@ function GetCanvasPixel(_buffer, _x, _y)
///
///
// #############################################################################################
-var surface_getpixel = surface_getpixel_RELEASE;
-var surface_getpixel_ext = surface_getpixel_ext_RELEASE;
-function surface_getpixel_RELEASE(_id, _x, _y)
-{
- return surface_getpixel_ext_RELEASE(_id, _x, _y) &0xffffff;
-}
+function surface_getpixel(){}
+function surface_getpixel_ext(){}
+// @if feature("2d")
function surface_getpixel_ext_RELEASE(_id, _x, _y)
{
var pSurf = g_Surfaces.Get(yyGetInt32(_id));
@@ -702,6 +688,9 @@ function surface_getpixel_ext_RELEASE(_id, _x, _y)
}
return 0x00000000;
}
+compile_if_used(surface_getpixel = (_id, _x, _y) => surface_getpixel_ext_RELEASE(_id, _x, _y) & 0xffffff);
+compile_if_used(surface_getpixel_ext = surface_getpixel_ext_RELEASE);
+// @endif
@@ -775,7 +764,8 @@ function surface_save_part(_id,_fname,_x,_y,_w,_h)
///
///
// #############################################################################################
-var draw_surface = draw_surface_RELEASE;
+function draw_surface(){}
+// @if feature("2d")
function draw_surface_RELEASE(_id, _x, _y)
{
var pSurf = g_Surfaces.Get(yyGetInt32(_id));
@@ -793,6 +783,8 @@ function draw_surface_RELEASE(_id, _x, _y)
}
graphics.globalAlpha = alpha;
}
+compile_if_used(draw_surface = draw_surface_RELEASE);
+// @endif
// #############################################################################################
/// Function:
@@ -1100,7 +1092,9 @@ function draw_surface_general(_id,_left,_top,_width,_height,_x,_y,_xscale,_yscal
///
///
// #############################################################################################
-function surface_copy(_destination,_x,_y,_source) {
+function surface_copy(){}
+// @if feature("2d") && function("surface_copy")
+surface_copy = (_destination,_x,_y,_source) => {
var pDest = g_Surfaces.Get(yyGetInt32(_destination));
var pSrc = g_Surfaces.Get(yyGetInt32(_source));
@@ -1113,7 +1107,8 @@ function surface_copy(_destination,_x,_y,_source) {
pImg.drawImage(pSrc, yyGetInt32(_x), yyGetInt32(_y));
pImg.restore();
}
-}
+};
+// @endif
// #############################################################################################
/// Function:
@@ -1133,8 +1128,9 @@ function surface_copy(_destination,_x,_y,_source) {
///
///
// #############################################################################################
-function surface_copy_part(_destination,_x,_y, _source,_xs,_ys,_ws,_hs)
-{
+function surface_copy_part(){}
+// @if feature("2d") && function("surface_copy_part")
+surface_copy_part = (_destination,_x,_y, _source,_xs,_ys,_ws,_hs) => {
var pDest = g_Surfaces.Get(yyGetInt32(_destination));
var pSrc = g_Surfaces.Get(yyGetInt32(_source));
if( pDest!=null && pSrc!=null)
@@ -1167,7 +1163,8 @@ function surface_copy_part(_destination,_x,_y, _source,_xs,_ys,_ws,_hs)
pImg.drawImage(pSrc, _xs,_ys,_ws,_hs, _x, _y, _ws,_hs);
pImg.restore();
}
-}
+};
+// @endif
function SurfaceFormatSupported(_format)
{
diff --git a/scripts/functions/Function_Texture.js b/scripts/functions/Function_Texture.js
index a854c682..8a715a65 100644
--- a/scripts/functions/Function_Texture.js
+++ b/scripts/functions/Function_Texture.js
@@ -120,11 +120,12 @@ function draw_sprite_stretched(_pInst, _sprite, _sub_index, _x, _y, _w,_h)
_sub_index = (~ ~_sub_index) % pSpr.numb;
if (_sub_index < 0) _sub_index = _sub_index + pSpr.numb;
- if ((pSpr.nineslicedata != null) && (pSpr.nineslicedata.enabled == true))
+ // @if feature("nineslice")
+ if ((pSpr.nineslicedata != null) && (pSpr.nineslicedata.enabled == true))
{
pSpr.nineslicedata.Draw(yyGetReal(_x), yyGetReal(_y), yyGetReal(_w), yyGetReal(_h), 0, 0xffffff, g_GlobalAlpha, _sub_index, pSpr, true);
- }
- else
+ } else // ->
+ // @endif
{
Graphics_DrawStretchedExt(pSpr.ppTPE[_sub_index], yyGetReal(_x), yyGetReal(_y), yyGetReal(_w), yyGetReal(_h), 0xffffff, g_GlobalAlpha);
}
@@ -160,11 +161,12 @@ function draw_sprite_stretched_ext( _pInst, _sprite, _sub_index, _x,_y, _w, _
_sub_index = (~ ~_sub_index) % pSpr.numb;
if (_sub_index < 0) _sub_index = _sub_index + pSpr.numb;
- if ((pSpr.nineslicedata != null) && (pSpr.nineslicedata.enabled == true))
+ // @if feature("nineslice")
+ if ((pSpr.nineslicedata != null) && (pSpr.nineslicedata.enabled == true))
{
pSpr.nineslicedata.Draw(yyGetReal(_x), yyGetReal(_y), yyGetReal(_w), yyGetReal(_h), 0, ConvertGMColour(yyGetInt32(_colour)), yyGetReal(_alpha), _sub_index, pSpr, true);
- }
- else
+ } else // ->
+ // @endif
{
Graphics_DrawStretchedExt(pSpr.ppTPE[_sub_index], yyGetReal(_x), yyGetReal(_y), yyGetReal(_w), yyGetReal(_h), ConvertGMColour(yyGetInt32(_colour)), yyGetReal(_alpha));
}
diff --git a/scripts/functions/Function_Tiles.js b/scripts/functions/Function_Tiles.js
index c837c61a..a458f418 100644
--- a/scripts/functions/Function_Tiles.js
+++ b/scripts/functions/Function_Tiles.js
@@ -14,751 +14,3 @@
// 17/05/2011 V1.0 MJD Stub functions added
//
// **********************************************************************************************************************
-
-
-
-// #############################################################################################
-/// Function:
-/// Adds a new tile to the room with the indicated values (see above for their meaning).
-/// The function returns the id of the tile that can be used later on.
-///
-///
-/// In: Background index
-/// X texel start
-/// Y texel start
-/// width of tile in texels
-/// height of tile in texels
-/// X coordinate of tile in pixels
-/// Y coordinate of tile in pixels
-/// Depth value of tile
-/// Out:
-/// Retuns tile ID.
-///
-// #############################################################################################
-function tile_add(_background, _left, _top, _width, _height, _x, _y, _depth)
-{
- var pTile = new yyTile();
- pTile.x = _x;
- pTile.y = _y;
- pTile.depth = _depth;
- pTile.xo = _left;
- pTile.yo = _top;
- pTile.w = _width;
- pTile.h = _height;
- pTile.index = _background;
- pTile.ClampDrawingRange();
-
- g_RunRoom.AddTile(pTile);
- return pTile.id;
-}
-
-// #############################################################################################
-/// Function:
-/// Deletes the tile with the given id.
-///
-///
-/// In: ID of tile to delete
-// #############################################################################################
-function tile_delete(_id)
-{
- g_RunRoom.DeleteTile(_id);
-}
-
-// #############################################################################################
-/// Function:
-///
-///
-///
-/// In:
-/// Out:
-///
-///
-// #############################################################################################
-function tile_exists(_id)
-{
- if( g_RunRoom.m_Tiles[_id] == null ) return false;
- return true;
-}
-
-// #############################################################################################
-/// Function:
-///
-///
-///
-/// In:
-/// Out:
-///
-///
-// #############################################################################################
-function tile_get_x(_id)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if(!pTile) return 0;
-
- return pTile.x;
-}
-
-// #############################################################################################
-/// Function:
-/// Returns the y-position of the tile with the given id.
-///
-///
-/// In: ID of tile
-/// Out:
-/// Y texel coordinate
-///
-// #############################################################################################
-function tile_get_y(_id)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if(!pTile) return 0;
-
- return pTile.y;
-}
-
-// #############################################################################################
-/// Function:
-/// Returns the left value of the tile with the given id.
-///
-///
-/// In: ID of tile
-/// Out:
-/// X texel coordinate
-///
-// #############################################################################################
-function tile_get_left(_id)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if(!pTile) return 0;
-
- return pTile.xo;
-}
-
-// #############################################################################################
-/// Function:
-/// Returns the top value of the tile with the given id.
-///
-///
-/// In: ID of tile
-/// Out:
-/// Y texel coordinate
-///
-// #############################################################################################
-function tile_get_top(_id)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if(!pTile) return 0;
-
- return pTile.yo;
-}
-
-// #############################################################################################
-/// Function:
-/// Returns the width of the tile with the given id.
-///
-// #############################################################################################
-function tile_get_width(_id)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if(!pTile) return 0;
-
- return pTile.w;
-}
-
-
-// #############################################################################################
-/// Function:
-/// Returns the height of the tile with the given id.
-///
-///
-/// In:
-/// Out:
-///
-///
-// #############################################################################################
-function tile_get_height(_id)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if(!pTile) return 0;
-
- return pTile.h;
-}
-
-// #############################################################################################
-/// Function:
-/// Returns the depth of the tile with the given id.
-///
-///
-/// In:
-/// Out:
-/// return depth
-///
-// #############################################################################################
-function tile_get_depth(_id)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if(!pTile) return 0;
-
- return pTile.depth;
-}
-
-// #############################################################################################
-/// Function:
-/// Returns whether the tile with the given id is visible.
-///
-///
-/// In:
-/// Out:
-/// returns visibility
-///
-// #############################################################################################
-function tile_get_visible(_id)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if(!pTile) return 0;
-
- return pTile.visible;
-}
-
-
-// #############################################################################################
-/// Function:
-/// Returns the xscale of the tile with the given id.
-///
-///
-/// In:
-/// Out:
-/// retutrn x scale
-///
-// #############################################################################################
-function tile_get_xscale(_id)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if(!pTile) return 0;
-
- return pTile.xscale;
-}
-
-
-// #############################################################################################
-/// Function:
-/// Returns the yscale of the tile with the given id.
-///
-///
-/// In:
-/// Out:
-/// return y scale
-///
-// #############################################################################################
-function tile_get_yscale(_id)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if(!pTile) return 0;
-
- return pTile.yscale;
-}
-
-// #############################################################################################
-/// Function:
-/// Returns the background of the tile with the given id.
-///
-///
-/// In:
-/// Out:
-/// return background id
-///
-// #############################################################################################
-function tile_get_background(_id)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if( !pTile ) return 0;
-
- return pTile.index;
-}
-
-// #############################################################################################
-/// Function:
-/// Returns the blending color of the tile with the given id.
-///
-///
-/// In:
-/// Out:
-/// return tile tinting colour
-///
-// #############################################################################################
-function tile_get_blend(_id)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if( !pTile ) return 0;
-
- return pTile.blend;
-}
-
-// #############################################################################################
-/// Function:
-/// Returns the alpha value of the tile with the given id.
-///
-///
-/// In:
-/// Out:
-/// return tile alpha
-///
-// #############################################################################################
-function tile_get_alpha(_id)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if( !pTile ) return 0;
-
- return pTile.alpha;
-}
-
-
-// #############################################################################################
-/// Function:
-/// Sets the position of the tile with the given id.
-///
-///
-/// In:
-///
-///
-/// Out:
-///
-///
-// #############################################################################################
-function tile_set_position(_id,_x,_y)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if (pTile) {
- pTile.x = _x;
- pTile.y = _y;
- }
-}
-
-// #############################################################################################
-/// Function:
-/// Sets the region of the tile with the given id in its background.
-/// UVs WILL BE CLAMPED TO TILE SPACE.
-///
-///
-/// In: ID of tile to change
-/// new left edge texel
-/// new top edge texel
-/// new width of tile
-///
-/// Out:
-///
-///
-// #############################################################################################
-function tile_set_region(_id,_left,_top,_width,_height)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if (pTile) {
- pTile.xo = _left;
- pTile.yo = _top;
- pTile.w = _width;
- pTile.h = _height;
- pTile.ClampDrawingRange();
- }
-}
-
-// #############################################################################################
-/// Function:
-/// Sets the background for the tile with the given id.
-/// UVs WILL BE CLAMPED TO TILE SPACE.
-///
-///
-/// In:
-///
-/// Out:
-/// set background
-///
-// #############################################################################################
-function tile_set_background(_id,_background)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if (pTile) {
- pTile.index = _background;
- pTile.ClampDrawingRange();
- }
-}
-
-// #############################################################################################
-/// Function:
-/// Sets whether the tile with the given id is visible.
-///
-///
-/// In:
-///
-/// Out:
-///
-///
-// #############################################################################################
-function tile_set_visible(_id,_visible)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if (pTile) {
- pTile.visible = _visible;
- }
-}
-
-
-// #############################################################################################
-/// Function:
-/// Sets the depth of the tile with the given id.
-///
-///
-/// In:
-///
-/// Out:
-///
-///
-// #############################################################################################
-function tile_set_depth(_id,_depth)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if (pTile)
- {
- g_RunRoom.m_PlayfieldManager.DeleteTile(pTile);
- pTile.depth = _depth;
- g_RunRoom.m_PlayfieldManager.Add(pTile);
- }
-}
-
-
-// #############################################################################################
-/// Function:
-/// Sets the scaling of the tile with the given id.
-///
-///
-/// In:
-///
-///
-/// Out:
-///
-///
-// #############################################################################################
-function tile_set_scale(_id,_xscale,_yscale)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if( !pTile ) return;
- pTile.xscale = _xscale;
- pTile.yscale = _yscale;
-}
-
-// #############################################################################################
-/// Function:
-/// Sets the blending color of the tile with the given id.
-///
-///
-/// In:
-///
-/// Out:
-///
-///
-// #############################################################################################
-function tile_set_blend(_id,_colour)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if( !pTile ) return;
- pTile.blend = ConvertGMColour(_colour);
-}
-
-// #############################################################################################
-/// Function:
-/// Sets the alpha value of the tile with the given id.
-///
-///
-/// In:
-///
-/// Out:
-///
-///
-// #############################################################################################
-function tile_set_alpha(_id,_alpha)
-{
- var pTile = g_RunRoom.m_Tiles[_id];
- if( !pTile ) return 0;
- pTile.alpha = _alpha;
-}
-
-
-
-// #############################################################################################
-/// Function:
-/// Hides all tiles at the indicated depth layer.
-///
-///
-/// In:
-/// Out:
-///
-///
-// #############################################################################################
-function tile_layer_hide(_depth)
-{
- g_RunRoom.m_PlayfieldManager.SetPlayfieldVisibility(_depth,false);
-}
-
-// #############################################################################################
-/// Function:
-/// Shows all tiles at the indicated depth layer.
-///
-///
-/// In:
-/// Out:
-///
-///
-// #############################################################################################
-function tile_layer_show(_depth) {
- g_RunRoom.m_PlayfieldManager.SetPlayfieldVisibility(_depth, true);
-}
-
-// #############################################################################################
-/// Function:
-/// Deletes all tiles at the indicated depth layer.
-///
-///
-/// In:
-/// Out:
-///
-///
-// #############################################################################################
-function tile_layer_delete(_depth) {
- g_RunRoom.DeleteTileLayer(_depth);
-}
-
-// #############################################################################################
-/// Function:
-/// Shifts all tiles at the indicated depth layer over the vector x,y. Can be used to create scrolling layers of tiles.
-///
-///
-/// In:
-///
-///
-/// Out:
-///
-///
-// #############################################################################################
-function tile_layer_shift(_depth,_x,_y)
-{
- var pPlayfield = g_RunRoom.m_PlayfieldManager.Get(_depth);
- if( !pPlayfield ) return;
-
- var pool = pPlayfield.GetPool();
-
- // Delete all tile that exist in this layer.
- for (var tile = 0; tile < pool.length; tile++)
- {
- var pTile = pool[tile];
- if (pTile)
- {
- pTile.x += _x;
- pTile.y += _y;
- }
- }
-}
-
-
-// #############################################################################################
-/// Function:
-/// Returns the id of the tile with the given depth at position (x,y). When no tile
-/// exists at the position -1 is returned. When multiple tiles with the given
-/// depth exist at the position the first one is returned.
-///
-///
-/// In:
-///
-///
-/// Out:
-///
-///
-// #############################################################################################
-function tile_layer_find(_depth,_x,_y)
-{
- for (var index in g_RunRoom.m_Tiles) {
- if (!g_RunRoom.m_Tiles.hasOwnProperty(index)) continue;
-
- var pTile = g_RunRoom.m_Tiles[index];
- if (pTile != null) {
- if((_depth == pTile.depth) && (_x >= pTile.x) && (_x < (pTile.x + (pTile.w*pTile.xscale))) && (_y >= pTile.y) && (_y < (pTile.y + (pTile.h*pTile.yscale))) )
- {
- return pTile.id;
- }
- }
- }
- return -1;
-}
-
-
-// #############################################################################################
-/// Function:
-/// Deletes the tile with the given depth at position (x,y). When multiple
-/// tiles with the given depth exist at the position they are all deleted.
-///
-///
-/// In:
-///
-///
-/// Out:
-///
-///
-// #############################################################################################
-function tile_layer_delete_at(_depth,_x,_y)
-{
- var tiles = [];
- for (var index in g_RunRoom.m_Tiles) {
- if (!g_RunRoom.m_Tiles.hasOwnProperty(index)) continue;
-
- // Find the tile.
- var pTile = g_RunRoom.m_Tiles[index];
- if (pTile) {
- if ((_depth == pTile.depth) && (_x >= pTile.x) && (_x < (pTile.x + (pTile.w * pTile.xscale))) && (_y >= pTile.y) && (_y < (pTile.y + (pTile.h * pTile.yscale)))) {
- // IF found, remember it.
- tiles[tiles.length] = index;
- }
- }
- }
-
-
- // Now nuke them all.
- for (var i = 0; i < tiles.length; i++)
- {
- g_RunRoom.DeleteTile(tiles[i]);
- }
-}
-
-// #############################################################################################
-/// Function:
-/// Changes the depth of all tiles at the indicated depth to the new depth. With this
-/// function you can move whole tile layers to a new depth.
-///
-///
-/// In:
-///
-/// Out:
-///
-///
-// #############################################################################################
-function tile_layer_depth(_depth,_newdepth) {
-
- // Loop through all tiles and get the ones at a specific depth
- var tiles = [];
- for (var index in g_RunRoom.m_Tiles) {
- if (!g_RunRoom.m_Tiles.hasOwnProperty(index)) continue;
-
- var pTile = g_RunRoom.m_Tiles[index];
- if (pTile) {
- if (_depth == pTile.depth) {
- tiles[tiles.length] = pTile;
- }
- }
- }
-
-
- // Now move them all to a new layer
- for (var i = 0; i < tiles.length; i++)
- {
- var pTile = tiles[i];
-
- g_RunRoom.m_PlayfieldManager.Delete(pTile);
- pTile.depth = _newdepth;
- g_RunRoom.m_PlayfieldManager.Add(pTile);
- }
-}
-
-// #############################################################################################
-/// Function:
-/// Return the total number of tiles in the current room
-///
-///
-/// Out:
-/// the number of tiles
-///
-// #############################################################################################
-function tile_get_count()
-{
- // loop through all tiles and get the ACTUAL number of tiles, ignoring nulls and undefined slots
- var count = 0;
- for (var index in g_RunRoom.m_Tiles)
- {
- if (!g_RunRoom.m_Tiles.hasOwnProperty(index)) continue;
-
- var pTile = g_RunRoom.m_Tiles[index];
- if (pTile) count++;
- }
- return count;
-}
-
-
-// #############################################################################################
-/// Function:
-/// Return tile ID at tile index "_index"
-///
-///
-/// Out:
-/// the number of tiles
-///
-// #############################################################################################
-function tile_get_id(_index) {
- // Loop through all tiles and get the ones at a specific depth
- if (_index < 0 || _index >= g_RunRoom.m_NumTiles) return -1;
-
- for (var index in g_RunRoom.m_Tiles) {
- if (!g_RunRoom.m_Tiles.hasOwnProperty(index)) continue;
-
- var pTile = g_RunRoom.m_Tiles[index];
- if (pTile) {
- if (_index == 0) return pTile.id;
- _index--;
- }
- }
- return -1;
-}
-
-// #############################################################################################
-/// Function:
-/// Return a list if ALL tile IDs in the room
-///
-///
-/// Out:
-/// Array holding the tile ids
-///
-// #############################################################################################
-function tile_get_ids()
-{
- var tiles = [];
- var index=0;
- for (var tile in g_RunRoom.m_Tiles) {
- if (!g_RunRoom.m_Tiles.hasOwnProperty(tile)) continue;
-
- var pTile = g_RunRoom.m_Tiles[tile];
- if (pTile) {
- tiles[index] = pTile.id;
- index++;
- }
- }
- return tiles;
-}
-
-// #############################################################################################
-/// Function:
-/// Return a list if ALL tile IDs in the room
-///
-///
-/// Out:
-/// Array holding the tile ids
-///
-// #############################################################################################
-function tile_get_ids_at_depth(_depth) {
- var tiles = [];
- var index = 0;
- for (var tile in g_RunRoom.m_Tiles) {
- if (!g_RunRoom.m_Tiles.hasOwnProperty(tile)) continue;
-
- var pTile = g_RunRoom.m_Tiles[tile];
- if (pTile && pTile.depth == _depth) {
- tiles[index] = pTile.id;
- index++;
- }
- }
- return tiles;
-}
diff --git a/scripts/functions/Function_Window.js b/scripts/functions/Function_Window.js
index 7990c769..23c899a0 100644
--- a/scripts/functions/Function_Window.js
+++ b/scripts/functions/Function_Window.js
@@ -385,7 +385,9 @@ function window_set_color(_colour)
{
g_WindowColour = ConvertGMColour(yyGetInt32(_colour));
}
+// @if function("window_set_colour")
var window_set_colour = window_set_color;
+// @endif
@@ -402,7 +404,9 @@ function window_get_color()
{
return ConvertGMColour( g_WindowColour );
}
+// @if function("window_get_colour")
var window_get_colour = window_get_color;
+// @endif
// #############################################################################################
diff --git a/scripts/functions/Function_YoYo.js b/scripts/functions/Function_YoYo.js
index 270a8dd3..9642e3be 100644
--- a/scripts/functions/Function_YoYo.js
+++ b/scripts/functions/Function_YoYo.js
@@ -44,45 +44,6 @@ var eDS_TypeMap=1,
var g_GameMakerIdentifier = aa_1241_kz();
function aa_1241_kz() { return 0x87155211; }
-// #############################################################################################
-/// Function:
-/// Create a security request object that works out the type of http request to
-/// create and allows us to send security checks
-///
-///
-/// In: The canvcas handle
-/// Out:
-///
-///
-// #############################################################################################
-/** @constructor */
-function SecurityCheck()
-{
- var xmlHttp = null;
- if (window.XMLHttpRequest) {
- //for firefox, opera and safari browswers
- xmlHttp = new XMLHttpRequest();
- }
- if (typeof(XMLHttpRequest) == "undefined")
- {
- xmlHttp = function () {
- try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); }
- catch (e) {}
- try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); }
- catch (e) {}
- try { return new ActiveXObject("Msxml2.XMLHTTP"); }
- catch (e) {}
- //Microsoft.XMLHTTP points to Msxml2.XMLHTTP.3.0 and is redundant
- throw new yyError("This browser does not support XMLHttpRequest.");
- };
- }
- this.securityRequest = xmlHttp;
- this.securityRequestInFlight = false;
-}
-
-// Global security check object and session key
-var g_securityCheck = new SecurityCheck();
-
function YYPushEventsDispatch() {
}
@@ -96,8 +57,7 @@ function code_is_compiled() { return true; }
/// In:
///
// #############################################################################################
-var draw_enable_alphablend = draw_enable_alphablend_html5;
-function draw_enable_alphablend_html5(_on_off)
+function draw_enable_alphablend(_on_off)
{
}
@@ -110,7 +70,6 @@ function draw_enable_alphablend_html5(_on_off)
/// true/false for yes/no
///
// #############################################################################################
-var YoYo_AchievementsAvailable = achievement_available;
function achievement_available()
{
return false;
@@ -121,7 +80,6 @@ function achievement_available()
/// Log into achievement system
///
// #############################################################################################
-var YoYo_LoginAchievements = achievement_login;
function achievement_login()
{
}
@@ -131,50 +89,36 @@ function achievement_login()
/// Log out of online achievements
///
// #############################################################################################
-var YoYo_LogoutAchievements = achievement_logout;
function achievement_logout()
{
}
-var YoYo_achievement_login_status = achievement_login_status;
function achievement_login_status() { }
-var YoYo_achievement_reset = achievement_reset;
function achievement_reset() { }
-var YoYo_achievement_show_achievements = achievement_show_achievements;
function achievement_show_achievements() { }
-var YoYo_achievement_show_leaderboards = achievement_show_leaderboards;
function achievement_show_leaderboards() { }
-var YoYo_achievement_load_friends = achievement_load_friends;
function achievement_load_friends() { }
-var YoYo_achievement_load_leaderboard = achievement_load_leaderboard;
function achievement_load_leaderboard(){}
-var YoYo_achievement_get_pic = achievement_get_pic;
function achievement_get_pic(){}
-var YoYo_achievement_load_progress = achievement_load_progress;
function achievement_load_progress() { }
-var YoYo_achievement_send_challenge = achievement_send_challenge;
function achievement_send_challenge() { }
-var YoYo_os_get_info = os_get_info;
function os_get_info() {return -1; }
-var YoYo_achievement_event = achievement_event;
function achievement_event() { }
-var YoYo_achievement_show = achievement_show;
function achievement_show() { }
-var YoYo_achievement_get_info = achievement_get_info;
function achievement_get_info() { }
// #############################################################################################
@@ -186,86 +130,11 @@ function achievement_get_info() { }
///
///
// #############################################################################################
-var YoYo_GetConfig = os_get_config;
function os_get_config()
{
return g_YoYoConfig; //"YOYO_PAID";
}
-
-// #############################################################################################
-/// Function:
-/// Get the platform we're running on (if known)
-///
-///
-/// Out:
-/// BROWSER_UNKNOWN = -1,
-/// BROWSER_WIN32 = 0,
-/// BROWSER_WIN64 = 1,
-/// BROWSER_MACOSX = 2,
-/// BROWSER_PSP = 3,
-/// BROWSER_IOS = 4,
-/// BROWSER_ANDROID = 5,
-/// BROWSER_LINUX = 6,
-///
-// #############################################################################################
-function YoYo_GetPlatform() {
- return g_OSPlatform;
-}
-
-// #############################################################################################
-/// Function:
-/// Get the "device" type - if knowns
-///
-///
-/// Out:
-/// BROWSER_TYPE = 0,
-/// BROWSER_TYPE_UNKNOWN = 255,
-/// BROWSER_IPHONE = 0,
-/// BROWSER_IPHONE_RETENA = 1,
-/// BROWSER_IPAD = 2,
-///
-// #############################################################################################
-function YoYo_GetDevice(){
- return g_DeviceType;
-}
-
-
-// #############################################################################################
-/// Function:
-/// Get the browser type.
-///
-///
-/// Out:
-/// BROWSER_NOT_A_BROWSER = -1, // game is not being played in a browser.
-/// BROWSER_UNKNOWN = 0, // Unknown browser...
-/// BROWSER_IE = 1,
-/// BROWSER_FIREFOX = 2,
-/// BROWSER_CHROME = 3,
-/// BROWSER_SAFARI = 4,
-/// BROWSER_OPERA = 5,
-/// BROWSER_SAFARI_MOBILE = 6,
-/// BROWSER_DEFAULT_ANDROID = 7,
-/// BROWSER_WINDOWS_STORE = 8
-///
-// #############################################################################################
-function YoYo_GetBrowser() {
- return g_OSBrowser;
-}
-
-// #############################################################################################
-/// Function:
-/// Return the OS version number
-///
-///
-/// Out:
-/// The OS version, or -1
-///
-// #############################################################################################
-function YoYo_GetVersion() {
- return g_OSVersion;
-}
-
// #############################################################################################
/// Function:
///
@@ -278,10 +147,9 @@ function YoYo_GetVersion() {
///
///
// #############################################################################################
-var YoYo_OpenURL_full = url_open_full;
function url_open_full(_url, _target, _options) {
if (_target != "_self" && _target != "_blank" && _target != "_parent" && _target != "_top"){
- yyError("Error: invalid TARGET specified. Only '_self', '_blank', 'parent' or '_top' supported. (YoYo_OpenURL)");
+ yyError("Error: invalid TARGET specified. Only '_self', '_blank', 'parent' or '_top' supported. (url_open)");
return;
}
var loaded = window.open(yyGetString(_url), yyGetString(_target), yyGetString(_options));
@@ -296,9 +164,8 @@ function url_open_full(_url, _target, _options) {
/// Target to open in
///
// #############################################################################################
-var YoYo_OpenURL_ext = url_open_ext;
function url_open_ext(_url, _target) {
- YoYo_OpenURL_full(_url, _target, "scrollbars=yes,menubar=yes,resizable=yes,toolbar=yes,location=yes,status=yes");
+ url_open_full(_url, _target, "scrollbars=yes,menubar=yes,resizable=yes,toolbar=yes,location=yes,status=yes");
}
// #############################################################################################
@@ -309,9 +176,8 @@ function url_open_ext(_url, _target) {
/// In: URL to open
///
// #############################################################################################
-var YoYo_OpenURL = url_open;
function url_open(_url) {
- YoYo_OpenURL_ext(_url, "_self");
+ url_open_ext(_url, "_self");
}
@@ -324,7 +190,6 @@ function url_open(_url) {
/// Score to post
///
// #############################################################################################
-var YoYo_PostScore = achievement_post_score;
function achievement_post_score(_scoreboard, _score)
{
}
@@ -338,7 +203,6 @@ function achievement_post_score(_scoreboard, _score)
/// Score to post
///
// #############################################################################################
-var YoYo_PostAchievement = achievement_post;
function achievement_post( _scoreboard, _achivement )
{
}
@@ -360,7 +224,6 @@ function achievement_post( _scoreboard, _achivement )
///
///
// #############################################################################################
-var YoYo_LeaveRating = shop_leave_rating;
function shop_leave_rating(_text, _yes, _no, _URL)
{
}
@@ -374,23 +237,9 @@ function shop_leave_rating(_text, _yes, _no, _URL)
/// time value since start of app
///
// #############################################################################################
-var get_timer = (performance.now) ? function() {
- return performance.now() * 1000;
- } :
- function() {
- var t = new Date().getTime() * 1000;
- return t - g_YoYoTimerStart;
- };
-
-var YoYo_GetTimer = get_timer;
-
-
-
-
-
-
-
-
+var get_timer = typeof performance !== "undefined" && performance.now
+ ? function() { return performance.now() * 1000; }
+ : function() { return new Date().getTime() * 1000 - g_YoYoTimerStart; };
// #############################################################################################
/// Function:
@@ -406,7 +255,6 @@ var YoYo_GetTimer = get_timer;
/// virtual key "id"
///
// #############################################################################################
-var YoYo_AddVirtualKey = virtual_key_add;
function virtual_key_add(_x, _y, _w, _h, _keycode)
{
_x = yyGetInt32(_x);
@@ -440,7 +288,6 @@ function virtual_key_add(_x, _y, _w, _h, _keycode)
///
///
// #############################################################################################
-var YoYo_DeleteVirtualKey = virtual_key_delete;
function virtual_key_delete(_id) {
_id = yyGetInt32(_id);
@@ -482,7 +329,6 @@ function UpdateVirtualKeyDrawList() {
///
///
// #############################################################################################
-var YoYo_ShowVirtualKey = virtual_key_show;
function virtual_key_show(_id) {
_id = yyGetInt32(_id);
@@ -505,7 +351,6 @@ function virtual_key_show(_id) {
///
///
// #############################################################################################
-var YoYo_HideVirtualKey = virtual_key_hide;
function virtual_key_hide(_id) {
_id = yyGetInt32(_id);
@@ -527,7 +372,6 @@ function virtual_key_hide(_id) {
/// -1 to 1 tilt value
///
// #############################################################################################
-var YoYo_GetTiltX = device_get_tilt_x;
function device_get_tilt_x()
{
return 0;
@@ -543,7 +387,6 @@ function device_get_tilt_x()
/// -1 to 1 tilt value
///
// #############################################################################################
-var YoYo_GetTiltY = device_get_tilt_y;
function device_get_tilt_y()
{
return 0;
@@ -559,7 +402,6 @@ function device_get_tilt_y()
/// -1 to 1 tilt value
///
// #############################################################################################
-var YoYo_GetTiltZ = device_get_tilt_z;
function device_get_tilt_z()
{
return 0;
@@ -574,7 +416,6 @@ function device_get_tilt_z()
///
///
// #############################################################################################
-var YoYo_SelectPicture = device_ios_get_imagename;
function device_ios_get_imagename()
{
MissingFunction("device_ios_get_imagename()");
@@ -589,7 +430,6 @@ function device_ios_get_imagename()
///
///
// #############################################################################################
-var YoYo_GetPictureSprite = device_ios_get_image;
function device_ios_get_image()
{
MissingFunction("device_ios_get_image()");
@@ -604,7 +444,6 @@ function device_ios_get_image()
///
///
// #############################################################################################
-var YoYo_OF_StartDashboard = openfeint_start;
function openfeint_start()
{
MissingFunction("openfeint_start()");
@@ -620,7 +459,6 @@ function openfeint_start()
///
///
// #############################################################################################
-var YoYo_OF_AddAchievement = achievement_map_achievement;
function achievement_map_achievement(_a, _b)
{
MissingFunction("achievement_map_achievement()");
@@ -637,7 +475,6 @@ function achievement_map_achievement(_a, _b)
///
///
// #############################################################################################
-var YoYo_OF_AddLeaderboard = achievement_map_leaderboard;
function achievement_map_leaderboard(_a, _b, _c)
{
MissingFunction("achievement_map_leaderboard()");
@@ -654,7 +491,6 @@ function achievement_map_leaderboard(_a, _b, _c)
///
///
// #############################################################################################
-var YoYo_OF_SendChallenge = openfeint_send_challenge;
function openfeint_send_challenge(_a, _b, _c)
{
MissingFunction("openfeint_send_challenge()");
@@ -669,7 +505,6 @@ function openfeint_send_challenge(_a, _b, _c)
///
///
// #############################################################################################
-var YoYo_OF_SendInvite = openfeint_send_invite;
function openfeint_send_invite(_a)
{
MissingFunction("openfeint_send_invite()");
@@ -686,7 +521,6 @@ function openfeint_send_invite(_a)
///
///
// #############################################################################################
-var YoYo_OF_SendSocial = openfeint_send_social;
function openfeint_send_social(_a, _b, _c)
{
MissingFunction("openfeint_send_social()");
@@ -701,7 +535,6 @@ function openfeint_send_social(_a, _b, _c)
///
///
// #############################################################################################
-var YoYo_OF_SetURL = openfeint_set_url;
function openfeint_set_url(_a)
{
MissingFunction("openfeint_set_url()");
@@ -715,7 +548,6 @@ function openfeint_set_url(_a)
///
///
// #############################################################################################
-var YoYo_OF_AcceptChallenge = openfeint_accept_challenge;
function openfeint_accept_challenge()
{
MissingFunction("openfeint_accept_challenge()");
@@ -730,7 +562,6 @@ function openfeint_accept_challenge()
///
///
// #############################################################################################
-var YoYo_OF_IsOnline = achievement_is_online;
function achievement_is_online()
{
MissingFunction("achievement_is_online()");
@@ -747,7 +578,6 @@ function achievement_is_online()
///
///
// #############################################################################################
-var YoYo_OF_SendChallengeResult = openfeint_send_result;
function openfeint_send_result(_a, _b)
{
MissingFunction("openfeint_send_result()");
@@ -763,7 +593,6 @@ function openfeint_send_result(_a, _b)
///
///
// #############################################################################################
-var YoYo_IsKeypadOpen = device_is_keypad_open;
function device_is_keypad_open() {
return false;
}
@@ -803,100 +632,6 @@ function YoYo_Init()
leaderboard_type_time_mins_secs = 1;
}
-// #############################################################################################
-/// Function:
-/// What to do if the end user fails the security key check (grief the user)
-///
-// #############################################################################################
-function YoYo_SecurityFail()
-{
- var t = setTimeout(function() {
- for (var sprIndex in g_pSpriteManager.Sprites)
- {
- if (!g_pSpriteManager.Sprites.hasOwnProperty(sprIndex)) continue;
-
- g_pSpriteManager.Delete(sprIndex);
- break;
- }
- // And recurse...
- YoYo_SecurityFail();
-
- }, 1000); // delete a sprite every second
-}
-
-// #############################################################################################
-/// Function:
-/// Read the session key from the document element as set by the server .php
-///
-// #############################################################################################
-function YoYo_GetSessionKey()
-{
- if (!document.getElementById('b4f6074452b74d86ce6d00904fcd389c')) {
- // NM-156 is an arbitrary choice (Queensryche song if you must know...)
- var sessionKeyElement = document.getElementById('NM-156');
- if (sessionKeyElement)
- {
- sessionKey = sessionKeyElement.innerHTML;
- sessionKeyElement.parentNode.removeChild(sessionKeyElement);
- }
- else {
- YoYo_SecurityFail();
- }
- }
-}
-
-// #############################################################################################
-/// Function:
-/// On intialisation this grabs the security key from the server
-///
-// #############################################################################################
-function YoYo_CheckSecurity(_url)
-{
- if (!document.getElementById('42f28d8caa0d96b967645dce4278ed50'))
- {
- // Construct the final url that includes the request data used by the server to check the session state
- var finalUrl = _url + "?" + sessionKey + "=2239";
- // var finalUrl = "http://localhost:80/check_purchase.php?" + sessionKey + "=2239";
-
- // If a prior security check is in flight then do nothing
- if (!g_securityCheck.securityRequestInFlight)
- {
- g_securityCheck.securityRequestInFlight = true;
- var t = setTimeout(function() {
- g_securityCheck.securityRequest.open("GET", finalUrl, true);
- g_securityCheck.securityRequest.onreadystatechange = function () {
- if (g_securityCheck.securityRequest.readyState == 4)
- {
- switch (g_securityCheck.securityRequest.status)
- {
- case 200:
- {
- // Check response against our session key
- if (g_securityCheck.securityRequest.responseText != sessionKey)
- {
- // Do something unpleasant to the user
- YoYo_SecurityFail();
- }
- g_securityCheck.securityRequestInFlight = false;
- }
- break;
- default:
- alert("ERROR: The game has lost connection to the server. " + g_securityCheck.securityRequest.statusText);
- // Enact a reload of the page. Don't use window.location.reload() as that requests the user
- // resubmits data and allows them to deny the request and carry on playing
- window.location.href = window.location.href;
- break;
- }
- }
- };
- g_securityCheck.securityRequest.send(null);
- }, 5000); // delay sending for 5 seconds
- }
- }
-}
-
-
-
// #############################################################################################
/// Function:
/// Return the domain the page has been loaded from.
@@ -906,9 +641,8 @@ function YoYo_CheckSecurity(_url)
/// The domain (127.0.0.1, www.blah.com etc.)
///
// #############################################################################################
-var YoYo_GetDomain = url_get_domain;
function url_get_domain() {
- return document.domain;
+ return location.hostname;
}
// #############################################################################################
@@ -947,7 +681,6 @@ function getAsyncRequestObject() {
/// 0 or 1
///
// #############################################################################################
-var YoYo_MouseCheckButton = device_mouse_check_button;
function device_mouse_check_button(_dev, _button) {
_dev = yyGetInt32(_dev);
@@ -978,7 +711,6 @@ function device_mouse_check_button(_dev, _button) {
/// 0 or 1
///
// #############################################################################################
-var YoYo_MouseCheckButtonPressed = device_mouse_check_button_pressed;
function device_mouse_check_button_pressed(_dev, _button) {
_dev = yyGetInt32(_dev);
@@ -1009,7 +741,6 @@ function device_mouse_check_button_pressed(_dev, _button) {
/// 0 or 1
///
// #############################################################################################
-var YoYo_MouseCheckButtonReleased = device_mouse_check_button_released;
function device_mouse_check_button_released(_dev, _button) {
_dev = yyGetInt32(_dev);
@@ -1039,7 +770,6 @@ function device_mouse_check_button_released(_dev, _button) {
/// mouse coordinate
///
// #############################################################################################
-var YoYo_MouseX = device_mouse_x;
function device_mouse_x(_dev) {
_dev = yyGetInt32(_dev);
@@ -1063,7 +793,6 @@ function device_mouse_x(_dev) {
///
///
// #############################################################################################
-var YoYo_MouseXRaw = device_mouse_raw_x;
function device_mouse_raw_x(_dev) {
_dev = yyGetInt32(_dev);
@@ -1085,7 +814,6 @@ function device_mouse_raw_x(_dev) {
/// mouse coordinate
///
// #############################################################################################
-var YoYo_MouseY = device_mouse_y;
function device_mouse_y(_dev) {
_dev = yyGetInt32(_dev);
@@ -1109,7 +837,6 @@ function device_mouse_y(_dev) {
/// mouse coordinate
///
// #############################################################################################
-var YoYo_MouseYRaw = device_mouse_raw_y;
function device_mouse_raw_y(_dev) {
_dev = yyGetInt32(_dev);
@@ -1189,13 +916,11 @@ function device_mouse_y_to_gui(_dev) {
/// Checks to see if a pause activity came from the OS activity in this frame
///
// #############################################################################################
-var YoYo_OSPauseEvent = os_is_paused;
function os_is_paused() {
return g_OSPauseEvent;
}
-var YoYo_OSHasFocusEvent = window_has_focus;
function window_has_focus() {
return g_GameFocus;
}
@@ -1218,7 +943,9 @@ function ds_exists(_ind, _type) {
case eDS_TypeList: return (g_ListCollection.Get(_ind) ? 1.0 : 0.0);
case eDS_TypeStack: return (g_StackCollection.Get(_ind) ? 1.0 : 0.0);
case eDS_TypeQueue: return (g_ActiveQueues.Get(_ind) ? 1.0 : 0.0);
+ // @if function("ds_grid_*")
case eDS_TypeGrid: return (g_ActiveGrids.Get(_ind) ? 1.0 : 0.0);
+ // @endif
case eDS_TypePriority: return (g_ActivePriorityQueues.Get(_ind) ? 1.0 : 0.0);
}
return 0;
@@ -1334,7 +1061,9 @@ function script_execute( _self, _other, _index )
return 0;
} // end script_execute
+// @if function("method_call")
var method_call = script_execute_ext;
+// @endif
function script_execute_ext( _self, _other, _index, _array, _offset, _length )
{
_array = _array || [];
@@ -1413,19 +1142,23 @@ function script_execute_ext( _self, _other, _index, _array, _offset, _length )
// #############################################################################################
function gml_release_mode(_enable) {
if (yyGetBool(_enable)) {
+ // @if function("position_change") || function("instance_change")
instance_change = instance_change_RELEASE;
+ // @endif
yyInst = yyInst_RELEASE;
- ds_grid_get = ds_grid_get_RELEASE;
- ds_grid_set = ds_grid_set_RELEASE;
- ds_grid_set_pre = ds_grid_set_pre_RELEASE;
- ds_grid_set_post = ds_grid_set_post_RELEASE;
+ compile_if_used(ds_grid_get = ds_grid_get_RELEASE);
+ compile_if_used(ds_grid_set = ds_grid_set_RELEASE);
+ compile_if_used(ds_grid_set_pre = ds_grid_set_pre_RELEASE);
+ compile_if_used(ds_grid_set_post = ds_grid_set_post_RELEASE);
} else {
+ // @if function("position_change") || function("instance_change")
instance_change = instance_change_DEBUG;
+ // @endif
yyInst = yyInst_DEBUG;
- ds_grid_get = ds_grid_get_DEBUG;
- ds_grid_set = ds_grid_set_DEBUG;
- ds_grid_set_pre = ds_grid_set_pre_DEBUG;
- ds_grid_set_post = ds_grid_set_post_DEBUG;
+ compile_if_used(ds_grid_get = ds_grid_get_DEBUG);
+ compile_if_used(ds_grid_set = ds_grid_set_DEBUG);
+ compile_if_used(ds_grid_set_pre = ds_grid_set_pre_DEBUG);
+ compile_if_used(ds_grid_set_post = ds_grid_set_post_DEBUG);
}
}
diff --git a/scripts/functions/collections/ds_grid.js b/scripts/functions/collections/ds_grid.js
index 8ef0f275..cc53456f 100644
--- a/scripts/functions/collections/ds_grid.js
+++ b/scripts/functions/collections/ds_grid.js
@@ -34,7 +34,7 @@ function ds_set_precision(_prec)
g_Precsision = yyGetReal(_prec);
}
-
+/// @if function("ds_grid_*")
// #############################################################################################
/// Function:
@@ -2048,4 +2048,6 @@ function ds_grid_to_mp_grid(_src, _dest, _predicate) {
}
}
}
-}
\ No newline at end of file
+}
+
+/// @endif
diff --git a/scripts/functions/collections/ds_priority.js b/scripts/functions/collections/ds_priority.js
index bec1f5ac..326ba2fa 100644
--- a/scripts/functions/collections/ds_priority.js
+++ b/scripts/functions/collections/ds_priority.js
@@ -15,7 +15,7 @@
//
// **********************************************************************************************************************
-
+// @if function("ds_priority_*")
// #############################################################################################
/** @constructor */
function yyPriorityQueue_Save(_depth, _obj) {
@@ -586,4 +586,4 @@ function ds_priority_read(_id, _pJSON)
return true;
}
-
+// @endif
diff --git a/scripts/jsBox2D/jsliquidfun.js b/scripts/jsBox2D/jsliquidfun.js
index 83bb5c30..19fdf4c8 100644
--- a/scripts/jsBox2D/jsliquidfun.js
+++ b/scripts/jsBox2D/jsliquidfun.js
@@ -1,3 +1,4 @@
+// @if feature("physics")
(function()
{
'use strict';
@@ -21114,4 +21115,5 @@ if (typeof(module) !== "undefined")
else
window["b2"] = b2;
}
-})();
\ No newline at end of file
+})();
+// @endif
\ No newline at end of file
diff --git a/scripts/jsgif/GIFEncoder.js b/scripts/jsgif/GIFEncoder.js
index 534b28cf..ca678b69 100644
--- a/scripts/jsgif/GIFEncoder.js
+++ b/scripts/jsgif/GIFEncoder.js
@@ -1,3 +1,4 @@
+/// @if function("gif_*")
/**
* This class lets you encode animated GIF files
* Base class : http://www.java2s.com/Code/Java/2D-Graphics-GUI/AnimatedGifEncoder.htm
@@ -619,3 +620,4 @@ GIFEncoder = function() {
return exports;
};
+/// @endif
diff --git a/scripts/jsgif/LZWEncoder.js b/scripts/jsgif/LZWEncoder.js
index 5a37bbb3..23f59092 100644
--- a/scripts/jsgif/LZWEncoder.js
+++ b/scripts/jsgif/LZWEncoder.js
@@ -1,3 +1,4 @@
+/// @if function("gif_*")
/**
* This class handles LZW encoding
* Adapted from Jef Poskanzer's Java port by way of J. M. G. Elliott.
@@ -275,3 +276,4 @@ LZWEncoder = function() {
LZWEncoder.apply(this, arguments);
return exports;
};
+/// @endif
diff --git a/scripts/jsgif/NeuQuant.js b/scripts/jsgif/NeuQuant.js
index 12ceede0..61997c71 100644
--- a/scripts/jsgif/NeuQuant.js
+++ b/scripts/jsgif/NeuQuant.js
@@ -1,3 +1,4 @@
+/// @if function("gif_*")
/*
* NeuQuant Neural-Net Quantization Algorithm
* ------------------------------------------
@@ -527,3 +528,4 @@ NeuQuant = function() {
NeuQuant.apply(this, arguments);
return exports;
};
+/// @endif
\ No newline at end of file
diff --git a/scripts/physics/yyPhysicsDebugRender.js b/scripts/physics/yyPhysicsDebugRender.js
index 3736ec11..834b35ef 100644
--- a/scripts/physics/yyPhysicsDebugRender.js
+++ b/scripts/physics/yyPhysicsDebugRender.js
@@ -9,6 +9,7 @@
// Description:
//
// **********************************************************************************************************************
+// @if feature("physics")
// #############################################################################################
/// Function:
@@ -157,4 +158,4 @@ function yyBox2DDrawParticles(centers, radius, colors, count) {
true);
}
}
-
+// @endif
diff --git a/scripts/physics/yyPhysicsFixture.js b/scripts/physics/yyPhysicsFixture.js
index 3ad51091..899d420e 100644
--- a/scripts/physics/yyPhysicsFixture.js
+++ b/scripts/physics/yyPhysicsFixture.js
@@ -13,6 +13,7 @@
// 15/02/2012 1.0 CPH 1st version
//
// **********************************************************************************************************************
+// @if feature("physics")
/** @constructor */
function yyPhysicsFixture() {
//function yyPhysicsFixture(_fixtureID) {
@@ -225,4 +226,5 @@ yyPhysicsFixture.prototype.SetAwake = function(_awake) {
yyPhysicsFixture.prototype.SetKinematic = function() {
this.m_kinematic = true;
-};
\ No newline at end of file
+};
+// @endif
diff --git a/scripts/physics/yyPhysicsJoint.js b/scripts/physics/yyPhysicsJoint.js
index 9ae07a33..ee4630ba 100644
--- a/scripts/physics/yyPhysicsJoint.js
+++ b/scripts/physics/yyPhysicsJoint.js
@@ -13,6 +13,7 @@
// 15/02/2012 1.0 CPH 1st version
//
// **********************************************************************************************************************
+// @if feature("physics")
var JOINT_ANCHOR_1_X = 0,
JOINT_ANCHOR_1_Y = 1,
JOINT_ANCHOR_2_X = 2,
@@ -377,4 +378,5 @@ yyPhysicsJoint.prototype.SetValue = function(_field, _value) {
}
break;
}
-};
\ No newline at end of file
+};
+// @endif
diff --git a/scripts/physics/yyPhysicsObject.js b/scripts/physics/yyPhysicsObject.js
index 0485f3eb..877402e0 100644
--- a/scripts/physics/yyPhysicsObject.js
+++ b/scripts/physics/yyPhysicsObject.js
@@ -13,6 +13,7 @@
// 15/02/2012 1.0 CPH 1st version
//
// **********************************************************************************************************************
+// @if feature("physics")
/** @constructor */
function yyPhysicsObject(_b2Body, _collisionCategory, _xo, _yo) {
@@ -455,4 +456,5 @@ yyPhysicsObject.prototype.SetRestitution = function(_fixtureIndex, _val) {
this.m_fixtures[_fixtureIndex].SetRestitution(_val);
}
-};
\ No newline at end of file
+};
+// @endif
diff --git a/scripts/physics/yyPhysicsWorld.js b/scripts/physics/yyPhysicsWorld.js
index 4efd0f2a..6b89c2ba 100644
--- a/scripts/physics/yyPhysicsWorld.js
+++ b/scripts/physics/yyPhysicsWorld.js
@@ -13,6 +13,7 @@
// 15/02/2012 1.0 CPH 1st version
//
// **********************************************************************************************************************
+// @if feature("physics")
var PHYSICS_DEFAULT_UPDATE_ITERATIONS = 10,
PHYSICS_COLLISION_CATEGORIES = 32,
PHYSICS_DEBUG_RENDER_SHAPE = (1 << 0),
@@ -2385,3 +2386,4 @@ yyPhysicsWorld.prototype.SetParticleRadius = function (_radius) { this.m_wor
yyPhysicsWorld.prototype.SetParticleDensity = function (_density) { this.m_world.SetParticleDensity(_density); };
yyPhysicsWorld.prototype.SetParticleDamping = function (_damping) { this.m_world.SetParticleDamping(_damping); };
yyPhysicsWorld.prototype.SetParticleGravityScale = function (_scale){ this.m_world.SetParticleGravityScale(_scale); };
+// @endif
diff --git a/scripts/sound/AudioBus.js b/scripts/sound/AudioBus.js
index 74c3304c..a7199526 100644
--- a/scripts/sound/AudioBus.js
+++ b/scripts/sound/AudioBus.js
@@ -1,3 +1,4 @@
+// @if feature("audio")
function AudioBus() {
// GML object props
this.__type = "[AudioBus]";
@@ -217,3 +218,4 @@ DummyAudioBus.prototype.handleValue = function(_value)
throw new Error("Value must be Struct.AudioEffect or undefined");
};
+// @endif audio
diff --git a/scripts/sound/AudioEffect.js b/scripts/sound/AudioEffect.js
index f12ababc..943fe602 100644
--- a/scripts/sound/AudioEffect.js
+++ b/scripts/sound/AudioEffect.js
@@ -1,3 +1,4 @@
+// @if feature("audio_effects")
function AudioEffect() {}
AudioEffect.PARAM_TIME_CONSTANT = 0.005; // 5ms
@@ -135,3 +136,4 @@ AudioEffectStruct.prototype.removeNode = function(_node) {
this.nodes.splice(idx, 1);
}
};
+// @endif
\ No newline at end of file
diff --git a/scripts/sound/AudioEmitter.js b/scripts/sound/AudioEmitter.js
index 454855a5..a54a9d02 100644
--- a/scripts/sound/AudioEmitter.js
+++ b/scripts/sound/AudioEmitter.js
@@ -1,3 +1,4 @@
+// @if feature("audio")
class AudioEmitter {
constructor() {
if (Audio_IsMainBusInitialised() === false) {
@@ -100,3 +101,4 @@ AudioEmitter.prototype.setPosition = function(_x, _y, _z) {
this.pannerNode.positionY.value = _y;
this.pannerNode.positionZ.value = _z;
};
+// @endif audio
diff --git a/scripts/sound/AudioPlaybackProps.js b/scripts/sound/AudioPlaybackProps.js
index fd5ca4fa..1c728548 100644
--- a/scripts/sound/AudioPlaybackProps.js
+++ b/scripts/sound/AudioPlaybackProps.js
@@ -1,3 +1,4 @@
+// @if feature("audio")
var AudioPlaybackType = {
NON_POSITIONAL: 0,
POSITIONAL_SPECIFIED: 1,
@@ -96,3 +97,4 @@ AudioPlaybackProps.prototype.invalid = function() {
return false;
};
+// @endif audio
diff --git a/scripts/sound/AudioPropsCalc.js b/scripts/sound/AudioPropsCalc.js
index 07b2daeb..1a2f0230 100644
--- a/scripts/sound/AudioPropsCalc.js
+++ b/scripts/sound/AudioPropsCalc.js
@@ -1,3 +1,4 @@
+// @if feature("audio")
function AudioPropsCalc() {}
AudioPropsCalc.invalid_index = -1;
@@ -81,3 +82,4 @@ AudioPropsCalc.GetGroupProps = function(_assetIndex) {
gain: new TimeRampedParamLinear(AudioPropsCalc.default_gain),
}))();
};
+// @endif audio
diff --git a/scripts/sound/WorkletNodeManager.js b/scripts/sound/WorkletNodeManager.js
index dc1842c1..229f645c 100644
--- a/scripts/sound/WorkletNodeManager.js
+++ b/scripts/sound/WorkletNodeManager.js
@@ -1,3 +1,4 @@
+// @if feature("audio")
function WorkletNodeManager() {
this.nodes = [];
this.handle = setInterval(() => this.cleanup(), 5000);
@@ -87,3 +88,4 @@ WorkletNodeManager.prototype.killNode = function(_node) {
};
var g_WorkletNodeManager = new WorkletNodeManager();
+// @endif
diff --git a/scripts/sound/effects/Bitcrusher.js b/scripts/sound/effects/Bitcrusher.js
index 9815ee11..cf1f825f 100644
--- a/scripts/sound/effects/Bitcrusher.js
+++ b/scripts/sound/effects/Bitcrusher.js
@@ -1,3 +1,4 @@
+// @if feature("audio_effects")
function BitcrusherEffectStruct(_params) {
AudioEffectStruct.call(this, AudioEffect.Type.Bitcrusher);
Object.setPrototypeOf(this, AudioEffectStruct.prototype);
@@ -72,3 +73,4 @@ BitcrusherEffectStruct.paramDescriptors = () => ({
resolution: { name: "resolution", integer: true, defaultValue: 8, minValue: 2, maxValue: 16 },
mix: { name: "mix", integer: false, defaultValue: 0.8, minValue: 0.0, maxValue: 1.0 }
});
+// @endif
diff --git a/scripts/sound/effects/Compressor.js b/scripts/sound/effects/Compressor.js
index fa3772b5..5cdf5872 100644
--- a/scripts/sound/effects/Compressor.js
+++ b/scripts/sound/effects/Compressor.js
@@ -1,3 +1,4 @@
+// @if feature("audio_effects")
function CompressorEffectStruct(_params) {
AudioEffectStruct.call(this, AudioEffect.Type.Compressor);
Object.setPrototypeOf(this, AudioEffectStruct.prototype);
@@ -100,4 +101,5 @@ CompressorEffectStruct.paramDescriptors = () => ({
attack: { name: "attack", integer: false, defaultValue: 0.05, minValue: 1e-3, maxValue: 1e-1},
release: { name: "release", integer: false, defaultValue: 0.25, minValue: 1e-2, maxValue: 1 },
outgain: { name: "outgain", integer: false, defaultValue: 1, minValue: 1e-6, maxValue: Number.MAX_VALUE }
-});
\ No newline at end of file
+});
+// @endif
diff --git a/scripts/sound/effects/Delay.js b/scripts/sound/effects/Delay.js
index 864f5c5a..a38aa50d 100644
--- a/scripts/sound/effects/Delay.js
+++ b/scripts/sound/effects/Delay.js
@@ -1,3 +1,4 @@
+// @if feature("audio_effects")
function DelayEffectStruct(_params) {
AudioEffectStruct.call(this, AudioEffect.Type.Delay);
Object.setPrototypeOf(this, AudioEffectStruct.prototype);
@@ -57,3 +58,4 @@ DelayEffectStruct.paramDescriptors = () => ({
feedback: { name: "feedback", integer: false, defaultValue: 0.5, minValue: 0.0, maxValue: 1.0 },
mix: { name: "mix", integer: false, defaultValue: 0.35, minValue: 0.0, maxValue: 1.0 }
});
+// @endif
diff --git a/scripts/sound/effects/EQ.js b/scripts/sound/effects/EQ.js
index 366c21ce..19a052de 100644
--- a/scripts/sound/effects/EQ.js
+++ b/scripts/sound/effects/EQ.js
@@ -1,3 +1,4 @@
+// @if feature("audio_effects")
function EQEffectStruct(_params) {
AudioEffectStruct.call(this, AudioEffect.Type.EQ);
Object.setPrototypeOf(this, AudioEffectStruct.prototype);
@@ -178,3 +179,4 @@ function EQEffectStruct(_params) {
EQEffectStruct.paramDescriptors = () => ({
bypass: AudioEffectStruct.paramDescriptors().bypass
});
+// @endif
diff --git a/scripts/sound/effects/Gain.js b/scripts/sound/effects/Gain.js
index 1c62a8fe..d717f9ab 100644
--- a/scripts/sound/effects/Gain.js
+++ b/scripts/sound/effects/Gain.js
@@ -1,3 +1,4 @@
+// @if feature("audio_effects")
function GainEffectStruct(_params) {
AudioEffectStruct.call(this, AudioEffect.Type.Gain);
Object.setPrototypeOf(this, AudioEffectStruct.prototype);
@@ -27,3 +28,4 @@ GainEffectStruct.paramDescriptors = () => ({
bypass: AudioEffectStruct.paramDescriptors().bypass,
gain: { name: "gain", integer: false, defaultValue: 0.5, minValue: 0.0, maxValue: Number.MAX_VALUE }
});
+// @endif
diff --git a/scripts/sound/effects/HPF2.js b/scripts/sound/effects/HPF2.js
index 3f23423f..1b27f20c 100644
--- a/scripts/sound/effects/HPF2.js
+++ b/scripts/sound/effects/HPF2.js
@@ -1,3 +1,4 @@
+// @if feature("audio_effects")
function HPF2EffectStruct(_params) {
AudioEffectStruct.call(this, AudioEffect.Type.HPF2);
Object.setPrototypeOf(this, AudioEffectStruct.prototype);
@@ -48,3 +49,4 @@ HPF2EffectStruct.paramDescriptors = () => ({
return this.freq;
}
});
+// @endif
diff --git a/scripts/sound/effects/HiShelf.js b/scripts/sound/effects/HiShelf.js
index 892d6271..50d23837 100644
--- a/scripts/sound/effects/HiShelf.js
+++ b/scripts/sound/effects/HiShelf.js
@@ -1,3 +1,4 @@
+// @if feature("audio_effects")
function HiShelfEffectStruct(_params) {
AudioEffectStruct.call(this, AudioEffect.Type.HiShelf);
Object.setPrototypeOf(this, AudioEffectStruct.prototype);
@@ -63,3 +64,4 @@ HiShelfEffectStruct.paramDescriptors = () => ({
return this.__freq;
}
});
+// @endif
diff --git a/scripts/sound/effects/LPF2.js b/scripts/sound/effects/LPF2.js
index 9a31d277..01bbe940 100644
--- a/scripts/sound/effects/LPF2.js
+++ b/scripts/sound/effects/LPF2.js
@@ -1,3 +1,4 @@
+// @if feature("audio_effects")
function LPF2EffectStruct(_params) {
AudioEffectStruct.call(this, AudioEffect.Type.LPF2);
Object.setPrototypeOf(this, AudioEffectStruct.prototype);
@@ -48,3 +49,4 @@ LPF2EffectStruct.paramDescriptors = () => ({
return this.freq;
}
});
+// @endif
diff --git a/scripts/sound/effects/LoShelf.js b/scripts/sound/effects/LoShelf.js
index 152f530f..3e5cee25 100644
--- a/scripts/sound/effects/LoShelf.js
+++ b/scripts/sound/effects/LoShelf.js
@@ -1,3 +1,4 @@
+// @if feature("audio_effects")
function LoShelfEffectStruct(_params) {
AudioEffectStruct.call(this, AudioEffect.Type.LoShelf);
Object.setPrototypeOf(this, AudioEffectStruct.prototype);
@@ -63,3 +64,4 @@ LoShelfEffectStruct.paramDescriptors = () => ({
return this.__freq;
}
});
+// @endif
diff --git a/scripts/sound/effects/PeakEQ.js b/scripts/sound/effects/PeakEQ.js
index 2064474a..5a2a3a59 100644
--- a/scripts/sound/effects/PeakEQ.js
+++ b/scripts/sound/effects/PeakEQ.js
@@ -1,3 +1,4 @@
+// @if feature("audio_effects")
function PeakEQEffectStruct(_params) {
AudioEffectStruct.call(this, AudioEffect.Type.PeakEQ);
Object.setPrototypeOf(this, AudioEffectStruct.prototype);
@@ -63,3 +64,4 @@ PeakEQEffectStruct.paramDescriptors = () => ({
return this.__freq;
}
});
+// @endif
diff --git a/scripts/sound/effects/Reverb1.js b/scripts/sound/effects/Reverb1.js
index 19bd1850..a7733d85 100644
--- a/scripts/sound/effects/Reverb1.js
+++ b/scripts/sound/effects/Reverb1.js
@@ -1,3 +1,4 @@
+// @if feature("audio_effects")
function Reverb1EffectStruct(_params) {
AudioEffectStruct.call(this, AudioEffect.Type.Reverb1);
Object.setPrototypeOf(this, AudioEffectStruct.prototype);
@@ -57,3 +58,4 @@ Reverb1EffectStruct.paramDescriptors = () => ({
damp: { name: "damp", integer: false, defaultValue: 0.1, minValue: 0.0, maxValue: 1.0 },
mix: { name: "mix", integer: false, defaultValue: 0.35, minValue: 0.0, maxValue: 1.0 }
});
+// @endif
diff --git a/scripts/sound/effects/Tremolo.js b/scripts/sound/effects/Tremolo.js
index 76f82c9a..2106c004 100644
--- a/scripts/sound/effects/Tremolo.js
+++ b/scripts/sound/effects/Tremolo.js
@@ -1,3 +1,4 @@
+// @if feature("audio_effects")
function TremoloEffectStruct(_params) {
AudioEffectStruct.call(this, AudioEffect.Type.Tremolo);
Object.setPrototypeOf(this, AudioEffectStruct.prototype);
@@ -72,3 +73,4 @@ TremoloEffectStruct.paramDescriptors = () => ({
offset: { name: "offset", integer: false, defaultValue: 0.0, minValue: 0.0, maxValue: 1.0 },
shape: { name: "shape", integer: true, defaultValue: 0, minValue: 0, maxValue: 4 }
});
+// @endif
diff --git a/scripts/spine/spine-core.js b/scripts/spine/spine-core.js
index 5a38af29..7b57a988 100644
--- a/scripts/spine/spine-core.js
+++ b/scripts/spine/spine-core.js
@@ -1,3 +1,4 @@
+// @if feature("spine")
var spine = (() => {
var __defProp = Object.defineProperty;
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
@@ -8652,4 +8653,5 @@ var spine = (() => {
var SwirlEffect = _SwirlEffect;
SwirlEffect.interpolation = new PowOut(2);
return src_exports;
-})();
\ No newline at end of file
+})();
+// @endif
\ No newline at end of file
diff --git a/scripts/utils/TimeRampedParamLinear.js b/scripts/utils/TimeRampedParamLinear.js
index ea5f4d86..2c7fd715 100644
--- a/scripts/utils/TimeRampedParamLinear.js
+++ b/scripts/utils/TimeRampedParamLinear.js
@@ -1,3 +1,4 @@
+// @if feature("audio")
function TimeRampedParamLinear(_initialVal) {
this.__val = _initialVal;
this.__origin = _initialVal;
@@ -46,3 +47,4 @@ TimeRampedParamLinear.prototype.update = function() {
return this.__val;
};
+// @endif
diff --git a/scripts/yy3DModel.js b/scripts/yy3DModel.js
index f0a4be43..8b723b2a 100644
--- a/scripts/yy3DModel.js
+++ b/scripts/yy3DModel.js
@@ -9,932 +9,3 @@
// Description:
//
// **********************************************************************************************************************
-
-var M_PRIMITIVE_BEGIN = 0,
- M_PRIMITIVE_END = 1,
- M_VERTEX = 2,
- M_VERTEX_COLOR = 3,
- M_VERTEX_TEX = 4,
- M_VERTEX_TEX_COLOR = 5,
- M_VERTEX_N = 6,
- M_VERTEX_N_COLOR = 7,
- M_VERTEX_N_TEX = 8,
- M_VERTEX_N_TEX_COLOR = 9,
- M_SHAPE_BLOCK = 10,
- M_SHAPE_CYLINDER = 11,
- M_SHAPE_CONE = 12,
- M_SHAPE_ELLIPSOID = 13,
- M_SHAPE_WALL = 14,
- M_SHAPE_FLOOR = 15;
-
-// #############################################################################################
-/// Function:
-/// 3DModel Constructor
-///
-// #############################################################################################
-/** @constructor */
-function yy3DModel() {
-
- this.Clear();
-}
-
-// #############################################################################################
-/// Function:
-/// Reset the model's data
-///
-// #############################################################################################
-yy3DModel.prototype.Clear = function() {
-
- // Command list set
- this.CmdList = [];
- this.Cached = [];
-};
-
-// #############################################################################################
-/// Function:
-/// Generates the model data used for saving
-///
-// #############################################################################################
-yy3DModel.prototype.BuildModelData = function() {
-
- // Write version number
- var outputData = "100\n";
-
- // Write number of commands
- outputData += this.CmdList.length.toString() + "\n";
- for (var i = 0; i < this.CmdList.length; i++) {
-
- // To stay compatible with the C++, all lines should have 10 floats of data
- var cmd = this.CmdList[i];
- outputData += cmd.Command.toString() + " ";
- switch (cmd.Command) {
- case M_PRIMITIVE_END:
- break;
-
- case M_PRIMITIVE_BEGIN:
- outputData += cmd.PrimType.toString();
- break;
-
- case M_VERTEX:
- outputData += cmd.x.toString() + " ";
- outputData += cmd.y.toString() + " ";
- outputData += cmd.z.toString() + " ";
- outputData += "0.0 0.0 0.0 0.0 0.0 0.0 0.0\n";
- break;
-
- case M_VERTEX_COLOR:
- outputData += cmd.x.toString() + " ";
- outputData += cmd.y.toString() + " ";
- outputData += cmd.z.toString() + " ";
- outputData += (cmd.color * 1.0).toString() + " ";
- outputData += cmd.alpha.toString() + " ";
- outputData += "0.0 0.0 0.0 0.0 0.0\n";
- break;
-
- case M_VERTEX_TEX:
- outputData += cmd.x.toString() + " ";
- outputData += cmd.y.toString() + " ";
- outputData += cmd.z.toString() + " ";
- outputData += cmd.u.toString() + " ";
- outputData += cmd.v.toString() + " ";
- outputData += "0.0 0.0 0.0 0.0 0.0\n";
- break;
-
- case M_VERTEX_TEX_COLOR:
- outputData += cmd.x.toString() + " ";
- outputData += cmd.y.toString() + " ";
- outputData += cmd.z.toString() + " ";
- outputData += cmd.u.toString() + " ";
- outputData += cmd.v.toString() + " ";
- outputData += (cmd.color * 1.0).toString() + " ";
- outputData += cmd.alpha.toString() + " ";
- outputData += "0.0 0.0 0.0\n";
- break;
-
- case M_VERTEX_N:
- outputData += cmd.x.toString() + " ";
- outputData += cmd.y.toString() + " ";
- outputData += cmd.z.toString() + " ";
- outputData += cmd.nx.toString() + " ";
- outputData += cmd.ny.toString() + " ";
- outputData += cmd.nz.toString() + " ";
- outputData += "0.0 0.0 0.0 0.0\n";
- break;
-
- case M_VERTEX_N_COLOR:
- outputData += cmd.x.toString() + " ";
- outputData += cmd.y.toString() + " ";
- outputData += cmd.z.toString() + " ";
- outputData += cmd.nx.toString() + " ";
- outputData += cmd.ny.toString() + " ";
- outputData += cmd.nz.toString() + " ";
- outputData += (cmd.color * 1.0).toString() + " ";
- outputData += cmd.alpha.toString() + " ";
- outputData += "0.0 0.0\n";
- break;
-
- case M_VERTEX_N_TEX:
- outputData += cmd.x.toString() + " ";
- outputData += cmd.y.toString() + " ";
- outputData += cmd.z.toString() + " ";
- outputData += cmd.nx.toString() + " ";
- outputData += cmd.ny.toString() + " ";
- outputData += cmd.nz.toString() + " ";
- outputData += cmd.u.toString() + " ";
- outputData += cmd.v.toString() + " ";
- outputData += "0.0 0.0\n";
- break;
-
- case M_VERTEX_N_TEX_COLOR:
- outputData += cmd.x.toString() + " ";
- outputData += cmd.y.toString() + " ";
- outputData += cmd.z.toString() + " ";
- outputData += cmd.nx.toString() + " ";
- outputData += cmd.ny.toString() + " ";
- outputData += cmd.nz.toString() + " ";
- outputData += cmd.u.toString() + " ";
- outputData += cmd.v.toString() + " ";
- outputData += (cmd.color * 1.0).toString() + " ";
- outputData += cmd.alpha.toString() + " ";
- outputData += "\n";
- break;
-
- case M_SHAPE_BLOCK:
- case M_SHAPE_WALL:
- case M_SHAPE_FLOOR:
- outputData += cmd.x1.toString() + " ";
- outputData += cmd.y1.toString() + " ";
- outputData += cmd.z1.toString() + " ";
- outputData += cmd.x2.toString() + " ";
- outputData += cmd.y2.toString() + " ";
- outputData += cmd.z2.toString() + " ";
- outputData += (cmd.hrep ? 1.0 : 0.0).toString() + " ";
- outputData += (cmd.vrep ? 1.0 : 0.0).toString() + " ";
- outputData += "0.0 0.0\n";
- break;
-
- case M_SHAPE_ELLIPSOID:
- outputData += cmd.x1.toString() + " ";
- outputData += cmd.y1.toString() + " ";
- outputData += cmd.z1.toString() + " ";
- outputData += cmd.x2.toString() + " ";
- outputData += cmd.y2.toString() + " ";
- outputData += cmd.z2.toString() + " ";
- outputData += (cmd.hrep ? 1.0 : 0.0).toString() + " ";
- outputData += (cmd.vrep ? 1.0 : 0.0).toString() + " ";
- outputData += (cmd.steps * 1.0).toString() + " ";
- outputData += "0.0\n";
- break;
-
- case M_SHAPE_CYLINDER:
- case M_SHAPE_CONE:
- outputData += cmd.x1.toString() + " ";
- outputData += cmd.y1.toString() + " ";
- outputData += cmd.z1.toString() + " ";
- outputData += cmd.x2.toString() + " ";
- outputData += cmd.y2.toString() + " ";
- outputData += cmd.z2.toString() + " ";
- outputData += (cmd.hrep ? 1.0 : 0.0).toString() + " ";
- outputData += (cmd.vrep ? 1.0 : 0.0).toString() + " ";
- outputData += (cmd.closed ? 1.0 : 0.0).toString() + " ";
- outputData += (cmd.steps * 1.0).toString() + " ";
- outputData += "\n";
- break;
- }
- }
- return outputData;
-};
-
-// #############################################################################################
-/// Function:
-/// Store 3D model to a buffer and save to the given file
-///
-// #############################################################################################
-yy3DModel.prototype.Save = function(_fname) {
-
- if (g_SupportsLocalStorage === true) {
-
- var modelData = this.BuildModelData();
- var fileid = file_text_open_write(_fname);
- file_text_write_string(fileid, modelData);
- file_text_close(fileid);
- }
- else {
- debug("d3d_model_save() browser does not support local storage\n");
- }
-};
-
-// #############################################################################################
-/// Function:
-// Used when loading a 3D model since we can't use regular expressions
-///
-// #############################################################################################
-yy3DModel.prototype.StripExtraneousSpaces = function(_lineData) {
-
- var destLineData = "";
- var space = false;
- for (var i = 0; i < _lineData.length; i++) {
-
- var currChar = _lineData.charAt(i);
- if (currChar == ' ') {
- if (!space) {
- destLineData = destLineData + currChar;
- }
- space = true;
- }
- else {
- space = false;
- destLineData = destLineData + currChar;
- }
- }
- return destLineData;
-};
-
-// #############################################################################################
-/// Function:
-/// Load 3D model from the given file
-///
-// #############################################################################################
-yy3DModel.prototype.ParseModelData = function(_modelData) {
-
- var lineDataArray = _modelData.split("\n");
-
- var version = parseInt(lineDataArray[0]);
- if (version == 100) {
-
- var modelEntries = parseInt(lineDataArray[1]);
- for (var i = 2; i < lineDataArray.length; i++) {
-
- var cmd = {};
-
- var lineData = this.StripExtraneousSpaces(lineDataArray[i]);
- var lineElements = lineData.split(" ");
-
- cmd.Command = parseInt(lineElements[0]);
- switch (cmd.Command) {
-
- case M_PRIMITIVE_END:
- break;
-
- case M_PRIMITIVE_BEGIN:
- {
- cmd.PrimType = parseInt(lineElements[1]);
- break;
- }
-
- case M_VERTEX:
- {
- cmd.x = parseFloat(lineElements[1]);
- cmd.y = parseFloat(lineElements[2]);
- cmd.z = parseFloat(lineElements[3]);
- break;
- }
-
- case M_VERTEX_COLOR:
- {
- cmd.x = parseFloat(lineElements[1]);
- cmd.y = parseFloat(lineElements[2]);
- cmd.z = parseFloat(lineElements[3]);
- cmd.color = parseInt(lineElements[4]);
- cmd.alpha = parseFloat(lineElements[5]);
- break;
- }
-
- case M_VERTEX_TEX:
- {
- cmd.x = parseFloat(lineElements[1]);
- cmd.y = parseFloat(lineElements[2]);
- cmd.z = parseFloat(lineElements[3]);
- cmd.u = parseFloat(lineElements[4]);
- cmd.v = parseFloat(lineElements[5]);
- break;
- }
-
- case M_VERTEX_TEX_COLOR:
- {
- cmd.x = parseFloat(lineElements[1]);
- cmd.y = parseFloat(lineElements[2]);
- cmd.z = parseFloat(lineElements[3]);
- cmd.u = parseFloat(lineElements[4]);
- cmd.v = parseFloat(lineElements[5]);
- cmd.color = parseInt(lineElements[6]);
- cmd.alpha = parseFloat(lineElements[7]);
- break;
- }
-
- case M_VERTEX_N:
- {
- cmd.x = parseFloat(lineElements[1]);
- cmd.y = parseFloat(lineElements[2]);
- cmd.z = parseFloat(lineElements[3]);
- cmd.nx = parseFloat(lineElements[4]);
- cmd.ny = parseFloat(lineElements[5]);
- cmd.nz = parseFloat(lineElements[6]);
- break;
- }
-
- case M_VERTEX_N_COLOR:
- {
- cmd.x = parseFloat(lineElements[1]);
- cmd.y = parseFloat(lineElements[2]);
- cmd.z = parseFloat(lineElements[3]);
- cmd.nx = parseFloat(lineElements[4]);
- cmd.ny = parseFloat(lineElements[5]);
- cmd.nz = parseFloat(lineElements[6]);
- cmd.color = parseInt(lineElements[7]);
- cmd.alpha = parseFloat(lineElements[8]);
- break;
- }
-
- case M_VERTEX_N_TEX:
- {
- cmd.x = parseFloat(lineElements[1]);
- cmd.y = parseFloat(lineElements[2]);
- cmd.z = parseFloat(lineElements[3]);
- cmd.nx = parseFloat(lineElements[4]);
- cmd.ny = parseFloat(lineElements[5]);
- cmd.nz = parseFloat(lineElements[6]);
- cmd.u = parseFloat(lineElements[7]);
- cmd.v = parseFloat(lineElements[8]);
- break;
- }
-
- case M_VERTEX_N_TEX_COLOR:
- {
- cmd.x = parseFloat(lineElements[1]);
- cmd.y = parseFloat(lineElements[2]);
- cmd.z = parseFloat(lineElements[3]);
- cmd.nx = parseFloat(lineElements[4]);
- cmd.ny = parseFloat(lineElements[5]);
- cmd.nz = parseFloat(lineElements[6]);
- cmd.u = parseFloat(lineElements[7]);
- cmd.v = parseFloat(lineElements[8]);
- cmd.color = parseInt(lineElements[9]);
- cmd.alpha = parseFloat(lineElements[10]);
- break;
- }
-
- case M_SHAPE_BLOCK:
- case M_SHAPE_WALL:
- case M_SHAPE_FLOOR:
- {
- cmd.x1 = parseFloat(lineElements[1]);
- cmd.y1 = parseFloat(lineElements[2]);
- cmd.z1 = parseFloat(lineElements[3]);
- cmd.x2 = parseFloat(lineElements[4]);
- cmd.y2 = parseFloat(lineElements[5]);
- cmd.z2 = parseFloat(lineElements[6]);
- cmd.hrep = (parseFloat(lineElements[7]) >= 0.5) ? true : false;
- cmd.vrep = (parseFloat(lineElements[8]) >= 0.5) ? true : false;
- break;
- }
-
- case M_SHAPE_ELLIPSOID:
- {
- cmd.x1 = parseFloat(lineElements[1]);
- cmd.y1 = parseFloat(lineElements[2]);
- cmd.z1 = parseFloat(lineElements[3]);
- cmd.x2 = parseFloat(lineElements[4]);
- cmd.y2 = parseFloat(lineElements[5]);
- cmd.z2 = parseFloat(lineElements[6]);
- cmd.hrep = (parseFloat(lineElements[7]) >= 0.5) ? true : false;
- cmd.vrep = (parseFloat(lineElements[8]) >= 0.5) ? true : false;
- cmd.steps = ~~parseFloat(lineElements[9]);
- break;
- }
-
- case M_SHAPE_CYLINDER:
- case M_SHAPE_CONE:
- {
- cmd.x1 = parseFloat(lineElements[1]);
- cmd.y1 = parseFloat(lineElements[2]);
- cmd.z1 = parseFloat(lineElements[3]);
- cmd.x2 = parseFloat(lineElements[4]);
- cmd.y2 = parseFloat(lineElements[5]);
- cmd.z2 = parseFloat(lineElements[6]);
- cmd.hrep = (parseFloat(lineElements[7]) >= 0.5) ? true : false;
- cmd.vrep = (parseFloat(lineElements[8]) >= 0.5) ? true : false;
- cmd.closed = (parseFloat(lineElements[9]) >= 0.5) ? true : false;
- cmd.steps = ~~parseFloat(lineElements[10]);
- break;
- }
- }
- this.CmdList.push(cmd);
- }
- }
-};
-
-
-// #############################################################################################
-/// Function:
-/// Load 3D model from the given file
-///
-// #############################################################################################
-yy3DModel.prototype.Load = function(_fname) {
-
- // Check for local storage version
- var pTextFile = LoadTextFile_Block(_fname, true);
- if (pTextFile !== null && pTextFile !== undefined) {
- this.ParseModelData(pTextFile);
- }
- else {
- // Attempt to load it remotely
- var fname = CheckWorkingDirectory(_fname);
-
- var self = this;
- var modelXhr = new XMLHttpRequest();
- modelXhr.open("GET", fname, false); // synchronous
- modelXhr.onload = function() {
- if (modelXhr.readyState==4 && modelXhr.status==200) {
- self.ParseModelData(modelXhr.responseText);
- }
- };
- modelXhr.send(null);
- }
-};
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-yy3DModel.prototype.Begin = function (kind) {
-
- this.CmdList.push({
- Command: M_PRIMITIVE_BEGIN,
- PrimType: kind
- });
-};
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-yy3DModel.prototype.End = function () {
-
- this.CmdList.push({
- Command: M_PRIMITIVE_END
- });
-};
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-yy3DModel.prototype.Vertex = function (x,y,z) {
-
- this.CmdList.push({
- Command: M_VERTEX,
- x: x,
- y: y,
- z: z
- });
-};
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-yy3DModel.prototype.VertexColor = function (x,y,z,col,alpha) {
-
- this.CmdList.push({
- Command: M_VERTEX_COLOR,
- x: x,
- y: y,
- z: z,
- color: col,
- alpha: alpha
- });
-};
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-yy3DModel.prototype.VertexTexture = function (x,y,z,xtex,ytex) {
-
- this.CmdList.push({
- Command: M_VERTEX_TEX,
- x: x,
- y: y,
- z: z,
- u: xtex,
- v: ytex
- });
-};
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-yy3DModel.prototype.VertexTextureColor = function (x,y,z,xtex,ytex,col,alpha) {
-
- this.CmdList.push({
- Command: M_VERTEX_TEX_COLOR,
- x: x,
- y: y,
- z: z,
- u: xtex,
- v: ytex,
- color: col,
- alpha: alpha
- });
-};
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-yy3DModel.prototype.VertexNormal = function (x,y,z,nx,ny,nz) {
-
- this.CmdList.push({
- Command: M_VERTEX_N,
- x: x,
- y: y,
- z: z,
- nx: nx,
- ny: ny,
- nz: nz
- });
-};
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-yy3DModel.prototype.VertexNormalColor = function (x,y,z,nx,ny,nz,col,alpha) {
-
- this.CmdList.push({
- Command: M_VERTEX_N_COLOR,
- x: x,
- y: y,
- z: z,
- nx: nx,
- ny: ny,
- nz: nz,
- color: col,
- alpha: alpha
- });
-};
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-yy3DModel.prototype.VertexNormalTexture = function (x,y,z,nx,ny,nz,xtex,ytex) {
-
- this.CmdList.push({
- Command: M_VERTEX_N_TEX,
- x: x,
- y: y,
- z: z,
- nx: nx,
- ny: ny,
- nz: nz,
- u: xtex,
- v: ytex
- });
-};
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-yy3DModel.prototype.VertexNormalTextureColor = function (x,y,z,nx,ny,nz,xtex,ytex,col,alpha) {
-
- this.CmdList.push({
- Command: M_VERTEX_N_TEX_COLOR,
- x: x,
- y: y,
- z: z,
- nx: nx,
- ny: ny,
- nz: nz,
- u: xtex,
- v: ytex,
- color: col,
- alpha: alpha
- });
-};
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-yy3DModel.prototype.Block = function (x1,y1,z1,x2,y2,z2,hrepeat,vrepeat) {
-
- this.CmdList.push({
- Command: M_SHAPE_BLOCK,
- x1: x1,
- y1: y1,
- z1: z1,
- x2: x2,
- y2: y2,
- z2: z2,
- hrep: hrepeat,
- vrep: vrepeat
- });
-};
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-yy3DModel.prototype.Cylinder = function (x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,closed,steps) {
-
- this.CmdList.push({
- Command: M_SHAPE_CYLINDER,
- x1: x1,
- y1: y1,
- z1: z1,
- x2: x2,
- y2: y2,
- z2: z2,
- hrep: hrepeat,
- vrep: vrepeat,
- closed: closed,
- steps: steps
- });
-};
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-yy3DModel.prototype.Cone = function (x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,closed,steps) {
-
- this.CmdList.push({
- Command: M_SHAPE_CONE,
- x1: x1,
- y1: y1,
- z1: z1,
- x2: x2,
- y2: y2,
- z2: z2,
- hrep: hrepeat,
- vrep: vrepeat,
- closed: closed,
- steps: steps
- });
-};
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-yy3DModel.prototype.Ellipsoid = function (x1,y1,z1,x2,y2,z2,hrepeat,vrepeat,steps) {
-
- this.CmdList.push({
- Command: M_SHAPE_ELLIPSOID,
- x1: x1,
- y1: y1,
- z1: z1,
- x2: x2,
- y2: y2,
- z2: z2,
- hrep: hrepeat,
- vrep: vrepeat,
- steps: steps
- });
-};
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-yy3DModel.prototype.Wall = function (x1,y1,z1,x2,y2,z2,hrepeat,vrepeat) {
-
- this.CmdList.push({
- Command: M_SHAPE_WALL,
- x1: x1,
- y1: y1,
- z1: z1,
- x2: x2,
- y2: y2,
- z2: z2,
- hrep: hrepeat,
- vrep: vrepeat
- });
-};
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-yy3DModel.prototype.Floor = function (x1,y1,z1,x2,y2,z2,hrepeat,vrepeat) {
-
- this.CmdList.push({
- Command: M_SHAPE_FLOOR,
- x1: x1,
- y1: y1,
- z1: z1,
- x2: x2,
- y2: y2,
- z2: z2,
- hrep: hrepeat,
- vrep: vrepeat
- });
-};
-
-// #############################################################################################
-/// Function:
-/// If the primtype changes or they're using a triangle fan, we need a new vbuffer.
-/// This routine lets us create a new one consistently.
-///
-// #############################################################################################
-yy3DModel.prototype.CreateNewVBuffer = function () {
-
- this.vbufferCache = new yyVBuffer(DEFAULT_VB_SIZE, g_webGL.GetVertexFormat(g_webGL.VERTEX_FORMAT_3D), false);
- // Fudge in a store of the prim type
- this.vbufferCache.PrimType = -1;
- this.vbufferCache.PrimTexture = null;
-};
-
-// #############################################################################################
-/// Function:
-/// Certain prim types can't share a vbuffer, so test if they can
-///
-// #############################################################################################
-yy3DModel.prototype.CanConcatPrimType = function (_prim) {
-
- switch (_prim) {
- case PrimType_POINTLIST:
- case PrimType_LINELIST:
- case PrimType_TRILIST:
- return true;
- }
- return false;
-};
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-yy3DModel.prototype.CachePrimData = function (_cache) {
-
- var vbuff = this.vbufferCache;
- if ((vbuff.PrimType != -1) &&
- ((g_PrimType != vbuff.PrimType) ||
- (g_PrimTexture != vbuff.PrimTexture) ||
- (this.CanConcatPrimType(vbuff.PrimType) === false)))
- {
- vbuff.Freeze();
- _cache.push({
- PrimType: WebGL_translate_primitive_builder_type(vbuff.PrimType),
- PrimTexture: vbuff.PrimTexture,
- PrimVBuffer: vbuff
- });
-
- // Create a new vbuffer for the next lot of data
- this.CreateNewVBuffer();
- vbuff = this.vbufferCache;
- }
- vbuff.Concat(g_PrimVBuffer);
- vbuff.PrimType = g_PrimType;
- vbuff.PrimTexture = g_PrimTexture;
-
- primitive_builder_clear();
-};
-
-// #############################################################################################
-/// Function:
-///
-// #############################################################################################
-yy3DModel.prototype.FinalisePrimDataCache = function (_cache) {
-
- var vbuff = this.vbufferCache;
- vbuff.Freeze();
- _cache.push({
- PrimType: WebGL_translate_primitive_builder_type(vbuff.PrimType),
- PrimTexture: vbuff.PrimTexture,
- PrimVBuffer: vbuff
- });
- primitive_builder_clear();
-};
-
-// #############################################################################################
-/// Function:
-/// Dispatch and record the shape being drawn
-///
-// #############################################################################################
-yy3DModel.prototype.DrawShape = function (cmd, tex, _cache) {
-
- // Allow us to record multiple primitive blocks
- var fn_d3d_primitive_end = d3d_primitive_end;
- var self = this;
- d3d_primitive_end = function () {
-
- self.CachePrimData(_cache);
- };
-
- switch (cmd.Command) {
- case M_SHAPE_BLOCK: d3d_draw_block(cmd.x1, cmd.y1, cmd.z1, cmd.x2, cmd.y2, cmd.z2, tex, cmd.hrep, cmd.vrep);
- break;
- case M_SHAPE_CYLINDER: d3d_draw_cylinder(cmd.x1, cmd.y1, cmd.z1, cmd.x2, cmd.y2, cmd.z2, tex, cmd.hrep, cmd.vrep, cmd.closed, cmd.steps);
- break;
- case M_SHAPE_CONE: d3d_draw_cone(cmd.x1, cmd.y1, cmd.z1, cmd.x2, cmd.y2, cmd.z2, tex, cmd.hrep, cmd.vrep, cmd.closed, cmd.steps);
- break;
- case M_SHAPE_ELLIPSOID: d3d_draw_ellipsoid(cmd.x1, cmd.y1, cmd.z1, cmd.x2, cmd.y2, cmd.z2, tex, cmd.hrep, cmd.vrep, cmd.steps);
- break;
- case M_SHAPE_WALL: d3d_draw_wall(cmd.x1, cmd.y1, cmd.z1, cmd.x2, cmd.y2, cmd.z2, tex, cmd.hrep, cmd.vrep);
- break;
- case M_SHAPE_FLOOR: d3d_draw_floor(cmd.x1, cmd.y1, cmd.z1, cmd.x2, cmd.y2, cmd.z2, tex, cmd.hrep, cmd.vrep);
- break;
- }
- d3d_primitive_end = fn_d3d_primitive_end;
-};
-
-// #############################################################################################
-/// Function:
-/// Dispatch the model's draw data
-///
-// #############################################################################################
-yy3DModel.prototype.Draw = function(x, y, z, tex) {
-
- // Set the world transform for the data
- var i,mt = new Matrix();
- mt.SetTranslation(x, y, z);
-
- var mo = WebGL_GetMatrix(MATRIX_WORLD);
- var m = new Matrix();
- m.Multiply(mt, mo);
-
- WebGL_SetMatrix(MATRIX_WORLD, m);
-
- var colour = ((g_GlobalAlpha * 255.0) << 24) | (g_GlobalColour & 0x00ffffff);
- var texCache = this.Cached[colour];
- if (texCache === undefined) {
- texCache = [];
- this.Cached[colour] = texCache;
- } // end if
-
- if (texCache[tex] === undefined) {
-
- // They may be multiple sets of primitive data within this model
- texCache[tex] = [];
- var cache = texCache[tex];
-
- // As long as the prim type doesn't change we can store all data in one big vbuffer
- this.CreateNewVBuffer();
-
- // Dispatch the set of commands
- for (var i = 0; i < this.CmdList.length; i++) {
-
- var cmd = this.CmdList[i];
- switch (cmd.Command) {
-
- case M_PRIMITIVE_BEGIN:
- d3d_primitive_begin_texture(cmd.PrimType, tex);
- break;
- case M_PRIMITIVE_END:
- this.CachePrimData(cache);
- break;
- case M_VERTEX:
- d3d_vertex(cmd.x, cmd.y, cmd.z);
- break;
- case M_VERTEX_COLOR:
- d3d_vertex_color(cmd.x, cmd.y, cmd.z, cmd.color, cmd.alpha);
- break;
- case M_VERTEX_TEX:
- d3d_vertex_texture(cmd.x, cmd.y, cmd.z, cmd.u, cmd.v);
- break;
- case M_VERTEX_TEX_COLOR:
- d3d_vertex_texture_color(cmd.x, cmd.y, cmd.z, cmd.u, cmd.v, cmd.color, cmd.alpha);
- break;
- case M_VERTEX_N:
- d3d_vertex_normal(cmd.x, cmd.y, cmd.z, cmd.nx, cmd.ny, cmd.nz);
- break;
- case M_VERTEX_N_COLOR:
- d3d_vertex_normal_color(cmd.x, cmd.y, cmd.z, cmd.nx, cmd.ny, cmd.nz, cmd.color, cmd.alpha);
- break;
- case M_VERTEX_N_TEX:
- d3d_vertex_normal_texture(cmd.x, cmd.y, cmd.z, cmd.nx, cmd.ny, cmd.nz, cmd.u, cmd.v);
- break;
- case M_VERTEX_N_TEX_COLOR:
- d3d_vertex_normal_texture_color(cmd.x, cmd.y, cmd.z, cmd.nx, cmd.ny, cmd.nz, cmd.u, cmd.v, cmd.color, cmd.alpha);
- break;
- case M_SHAPE_BLOCK:
- case M_SHAPE_CYLINDER:
- case M_SHAPE_CONE:
- case M_SHAPE_ELLIPSOID:
- case M_SHAPE_WALL:
- case M_SHAPE_FLOOR:
- this.DrawShape(cmd, tex, cache);
- break;
- }
- }
- this.FinalisePrimDataCache(cache);
- this.vbufferCache = null;
- }
-
- // Always draw the cached model (since we don't dispatch on primitive end now)
- var cachedArray = texCache[tex];
- for (i = 0; i < cachedArray.length; i++) {
-
- var cachedData = cachedArray[i];
- var glTexture = cachedData.PrimTexture ? cachedData.PrimTexture.webgl_textureid : null;
- g_webGL.DispatchVBuffer(cachedData.PrimType, glTexture, cachedData.PrimVBuffer, 0);
- }
-
- // Restore world matrix
- WebGL_SetMatrix(MATRIX_WORLD, mo);
-};
\ No newline at end of file
diff --git a/scripts/yyASync.js b/scripts/yyASync.js
index eb9708f7..71aecdca 100644
--- a/scripts/yyASync.js
+++ b/scripts/yyASync.js
@@ -104,7 +104,7 @@ function ASync_ImageLoad_Callback(_event) {
pFile.m_Complete = true;
pFile.m_Status = ASYNC_STATUS_LOADED;
-
+ // @if feature("sprites")
if( pFile.m_Type == ASYNC_SPRITE )
{
// Now actually UPDATE the sprite and TPage stuff.
@@ -170,6 +170,7 @@ function ASync_ImageLoad_Callback(_event) {
}
return;
}
+ // @endif sprites
if( pFile.m_Type == ASYNC_BACKGROUND )
{
@@ -349,7 +350,9 @@ yyASyncManager.prototype.Process = function () {
ds_map_add(map, "result", pFile.result);
ds_map_add(map, "value", pFile.value);
ds_map_add(map, "http_status", 0);
- } else if (pFile.m_Type == ASYNC_AUDIO_PLAYBACK) {
+ }
+ // @if feature("audio")
+ else if (pFile.m_Type == ASYNC_AUDIO_PLAYBACK) {
ds_map_add(map, "queue_id", pFile.queue_id);
ds_map_add(map, "buffer_id", pFile.buffer_id);
ds_map_add(map, "queue_shutdown", pFile.queue_shutdown);
@@ -357,7 +360,9 @@ yyASyncManager.prototype.Process = function () {
ds_map_add(map, "sound_id", pFile.voiceHandle);
ds_map_add(map, "asset_id", pFile.assetIndex);
ds_map_add(map, "was_stopped", pFile.wasStopped);
- } else if (pFile.m_Type == ASYNC_SYSTEM_EVENT) {
+ }
+ // @endif audio
+ else if (pFile.m_Type == ASYNC_SYSTEM_EVENT) {
ds_map_add(map, "event_type", pFile.event_type);
ds_map_add(map, "pad_index", pFile.pad_index);
}else{
@@ -375,15 +380,19 @@ yyASyncManager.prototype.Process = function () {
}
if (pFile.m_Type == ASYNC_IMAGE) g_pObjectManager.ThrowEvent(EVENT_OTHER_WEB_IMAGE_LOAD, 0, true); // Throw an event for the image
+ // @if feature("sprites")
else if (pFile.m_Type == ASYNC_SPRITE) g_pObjectManager.ThrowEvent(EVENT_OTHER_WEB_IMAGE_LOAD, 0, true); // Throw an event for the image
+ // @endif sprites
else if (pFile.m_Type == ASYNC_BACKGROUND) g_pObjectManager.ThrowEvent(EVENT_OTHER_WEB_IMAGE_LOAD, 0, true); // Throw an event for the image
else if (pFile.m_Type == ASYNC_SOUND) g_pObjectManager.ThrowEvent(EVENT_OTHER_WEB_SOUND_LOAD, 0, true);
else if (pFile.m_Type == ASYNC_WEB) g_pObjectManager.ThrowEvent(EVENT_OTHER_WEB_ASYNC, 0, true);
else if (pFile.m_Type == ASYNC_USER) g_pObjectManager.ThrowEvent(EVENT_OTHER_WEB_USER_INTERACTION, 0, true);
else if (pFile.m_Type == ASYNC_BINARY) g_pObjectManager.ThrowEvent(EVENT_OTHER_ASYNC_SAVE_LOAD, 0, true);
else if (pFile.m_Type == ASYNC_NETWORKING) g_pObjectManager.ThrowEvent(EVENT_OTHER_NETWORKING, 0, true);
+ // @if feature("audio")
else if (pFile.m_Type == ASYNC_AUDIO_PLAYBACK) g_pObjectManager.ThrowEvent(EVENT_OTHER_AUDIO_PLAYBACK, 0, true);
else if (pFile.m_Type == ASYNC_AUDIO_PLAYBACK_ENDED) g_pObjectManager.ThrowEvent(EVENT_OTHER_AUDIO_PLAYBACK_ENDED, 0, true);
+ // @endif audio
else if (pFile.m_Type == ASYNC_SYSTEM_EVENT) g_pObjectManager.ThrowEvent(EVENT_OTHER_SYSTEM_EVENT, 0, true);
// Done load, so delete handle.
diff --git a/scripts/yyAnimCurve.js b/scripts/yyAnimCurve.js
index cf084d75..db866ef7 100644
--- a/scripts/yyAnimCurve.js
+++ b/scripts/yyAnimCurve.js
@@ -15,6 +15,7 @@
//
// **********************************************************************************************************************
+// @if feature("animcurves")
// #############################################################################################
/// Function:
/// Create a new AnimCurvePoint object
@@ -828,3 +829,4 @@ function animcurve_get_name( _index )
return pCurve.pName;
return "";
}
+// @endif
\ No newline at end of file
diff --git a/scripts/yyBuffer.js b/scripts/yyBuffer.js
index 297737ba..bb50739e 100644
--- a/scripts/yyBuffer.js
+++ b/scripts/yyBuffer.js
@@ -537,6 +537,7 @@ function BufferSizeOf(_type) {
}
+// @if function("buffer_md5")
function yyMD5(){
this.i = new Uint32Array(2); //[2]; //uint32
this.buf = new Uint32Array(4); //[4]; //uint32
@@ -881,7 +882,9 @@ function DoMD5(_buff, _size,_offset)
MD5Final( mdContext );
return mdContext.yyb_hex();
}
+// @endif buffer_md5
+// @if function("buffer_crc32")
function crc32_init() {
var poly = -306674912;
var tab = new Array(256);
@@ -908,6 +911,7 @@ function crc32(b, pos, len) {
crc = (tab[(crc ^ b[i]) & 255] ^ ((crc >>> 8) & 0x00ffffff)) >>> 0;
return crc;
}
+// @endif
// #############################################################################################
@@ -954,6 +958,7 @@ yyBuffer.prototype.yyb_crc32 = function(_offset, _size)
/// Function:
///
// #############################################################################################
+// @if function("buffer_md5")
yyBuffer.prototype.yyb_md5 = function(_offset, _size) {
if (this.m_Size == 0)
@@ -988,12 +993,14 @@ yyBuffer.prototype.yyb_md5 = function(_offset, _size) {
return DoMD5( new Uint8Array(this.m_pRAWUnderlyingBuffer, _offset, _size),_size, 0 );
}
};
+// @endif
// #############################################################################################
/// Function:
///
// #############################################################################################
+// @if function("buffer_sha1")
yyBuffer.prototype.yyb_sha1 = function(_offset, _size) {
if (this.m_Size == 0)
@@ -1027,6 +1034,7 @@ yyBuffer.prototype.yyb_sha1 = function(_offset, _size) {
else
return sha1_string_utf8(String.fromCharCode.apply(null, new Uint8Array(this.m_pRAWUnderlyingBuffer, _offset, _size)));
};
+// @endif
// #############################################################################################
@@ -2786,11 +2794,12 @@ function buffer_set_surface(_buffer, _surface, _offset)
// Make new image data with space for the data
var imgData = pImg.createImageData(pSurf.m_Width, pSurf.m_Height);
var data = imgData.data;
+ var dataView = pBuff.m_DataView;
// Copy in data
var len = pSurf.m_Width * pSurf.m_Height * 4;
for (var i = 0; i < len; i++) {
- data[i] = pBuff.yyb_peek(eBuffer_U8, i+_offset);
+ data[i] = dataView.getUint8(i+_offset);
}
// SET the image data
diff --git a/scripts/yyBufferVertex.js b/scripts/yyBufferVertex.js
index 88005aa6..3b9c1e27 100644
--- a/scripts/yyBufferVertex.js
+++ b/scripts/yyBufferVertex.js
@@ -10,45 +10,81 @@
//
// **********************************************************************************************************************
+// Global storage for vertex buffers
+var g_vertexBuffers = [];
+
+// @if function("vertex_*")
// #############################################################################################
//
// Function definitions for Canvas mode
//
// #############################################################################################
-var vertex_create_buffer =function() { ErrorFunction("vertex_create_buffer"); };
-var vertex_create_buffer_ext = function (size) { ErrorFunction("vertex_create_buffer_ext"); };
-var vertex_delete_buffer = function (buffer) { ErrorFunction("vertex_delete_buffer"); };
-var vertex_begin = function (buffer, format) { ErrorFunction("vertex_begin"); };
-var vertex_end = function (buffer) { ErrorFunction("vertex_end"); };
-var vertex_position = function (buffer, x, y) { ErrorFunction("vertex_position"); };
-var vertex_position_3d = function (buffer, x, y, z) { ErrorFunction("vertex_position_3d"); };
-var vertex_colour = function (buffer, col, alpha) { ErrorFunction("vertex_colour"); };
-var vertex_color = function (buffer, col, alpha) { ErrorFunction("vertex_color"); };
-var vertex_rgba = function (buffer, r, g, b, a) { ErrorFunction("vertex_rgba"); };
-var vertex_argb = function (buffer, r, g, b, a) { ErrorFunction("vertex_argb"); };
-var vertex_texcoord = function (buffer, u, v) { ErrorFunction("vertex_texcoord"); };
-var vertex_normal = function (buffer, x, y, z) { ErrorFunction("vertex_normal"); };
-var vertex_float1 = function (buffer, x) { ErrorFunction("vertex_float1"); };
-var vertex_float2 = function (buffer, x, y) { ErrorFunction("vertex_float2"); };
-var vertex_float3 = function (buffer, x, y, z) { ErrorFunction("vertex_float3"); };
-var vertex_float4 = function (buffer, x, y, z, w) { ErrorFunction("vertex_float4"); };
-var vertex_ubyte4 = function (buffer, x, y, z, w) { ErrorFunction("vertex_ubyte4"); };
-var vertex_freeze = function (buffer) { ErrorFunction("vertex_freeze"); };
-var vertex_submit = function (buffer) { ErrorFunction("vertex_submit"); };
-var vertex_get_number = function (buffer) { ErrorFunction("vertex_get_number"); };
-var vertex_get_buffer_size = function (buffer) { ErrorFunction("vertex_get_buffer_size"); };
-var vertex_create_buffer_from_buffer = function (buffer) { ErrorFunction("vertex_create_buffer_from_buffer"); };
-var vertex_create_buffer_from_buffer_ext = function (buffer) { ErrorFunction("vertex_create_buffer_from_buffer_ext"); };
-var vertex_update_buffer_from_buffer = function (dest_vbuff, dest_offset, src_buffer, src_offset, src_size) { ErrorFunction("vertex_update_buffer_from_buffer"); };
-var vertex_update_buffer_from_vertex = function (dest_vbuff, dest_vert, src_vbuff, src_vert, src_vert_num) { ErrorFunction("vertex_update_buffer_from_vertex"); };
-var draw_flush = function () { };
+var vertex_create_buffer,
+ vertex_create_buffer_ext,
+ vertex_delete_buffer,
+ vertex_begin,
+ vertex_end,
+ vertex_position,
+ vertex_position_3d,
+ vertex_colour,
+ vertex_color,
+ vertex_rgba,
+ vertex_argb,
+ vertex_texcoord,
+ vertex_normal,
+ vertex_float1,
+ vertex_float2,
+ vertex_float3,
+ vertex_float4,
+ vertex_ubyte4,
+ vertex_freeze,
+ vertex_submit,
+ vertex_get_number,
+ vertex_get_buffer_size,
+ vertex_create_buffer_from_buffer,
+ vertex_create_buffer_from_buffer_ext,
+ vertex_update_buffer_from_buffer,
+ vertex_update_buffer_from_vertex,
+ draw_flush;
+
+// @if feature("2d")
+(() => {
+ let _stub = (_name, _val) => () => ErrorFunction(_name, _val);
+ vertex_create_buffer = _stub("vertex_create_buffer", -1);
+ vertex_create_buffer_ext = _stub("vertex_create_buffer_ext", -1);
+ vertex_delete_buffer = _stub("vertex_delete_buffer");
+ vertex_begin = _stub("vertex_begin");
+ vertex_end = _stub("vertex_end");
+ vertex_position = _stub("vertex_position");
+ vertex_position_3d = _stub("vertex_position_3d");
+ vertex_colour = _stub("vertex_colour");
+ vertex_color = vertex_colour;
+ vertex_rgba = _stub("vertex_rgba");
+ vertex_argb = _stub("vertex_argb");
+ vertex_texcoord = _stub("vertex_texcoord");
+ vertex_normal = _stub("vertex_normal");
+ vertex_float1 = _stub("vertex_float1");
+ vertex_float2 = _stub("vertex_float2");
+ vertex_float3 = _stub("vertex_float3");
+ vertex_float4 = _stub("vertex_float4");
+ vertex_ubyte4 = _stub("vertex_ubyte4");
+ vertex_freeze = _stub("vertex_freeze");
+ vertex_submit = _stub("vertex_submit");
+ vertex_get_number = _stub("vertex_get_number");
+ vertex_get_buffer_size = _stub("vertex_get_buffer_size");
+ vertex_create_buffer_from_buffer = _stub("vertex_create_buffer_from_buffer", -1);
+ vertex_create_buffer_from_buffer_ext = _stub("vertex_create_buffer_from_buffer_ext", -1);
+ vertex_update_buffer_from_buffer = _stub("vertex_update_buffer_from_buffer", -1);
+ vertex_update_buffer_from_vertex = _stub("vertex_update_buffer_from_vertex", -1);
+ draw_flush = ()=>{};
+})();
+// @endif
+
+// @if feature("gl")
// Constant for the default vertex buffer storage size
var DEFAULT_VERTEX_BUFFER_SIZE = 8 * 1024;
-// Global storage for vertex buffers
-var g_vertexBuffers = [];
-
// #############################################################################################
/// Function:
/// Initialise the vertex buffer function pointers.
@@ -711,3 +747,7 @@ function WebGL_vertex_get_buffer_size_RELEASE(_buffer)
return 0;
}
+
+// @endif gl
+
+// @endif vertex_
diff --git a/scripts/yyBuiltIn.js b/scripts/yyBuiltIn.js
index 9ee6d674..3d0d2842 100644
--- a/scripts/yyBuiltIn.js
+++ b/scripts/yyBuiltIn.js
@@ -182,10 +182,10 @@ yyBuiltIn.prototype.get_browser_height = function () { return GetBrowserHeight()
yyBuiltIn.prototype.get_delta_time = function () { return this.delta_time; };
-yyBuiltIn.prototype.get_os_type = function () { return g_OSPlatform; }; //{ return YoYo_GetPlatform(); };
-yyBuiltIn.prototype.get_os_device = function () { return YoYo_GetDevice(); };
-yyBuiltIn.prototype.get_os_browser = function () { return YoYo_GetBrowser(); };
-yyBuiltIn.prototype.get_os_version = function () { return YoYo_GetVersion(); };
+yyBuiltIn.prototype.get_os_type = function () { return g_OSPlatform; };
+yyBuiltIn.prototype.get_os_device = function () { return g_DeviceType; };
+yyBuiltIn.prototype.get_os_browser = function () { return g_OSBrowser; };
+yyBuiltIn.prototype.get_os_version = function () { return g_OSVersion; };
yyBuiltIn.prototype.get_async_load = function () { return this.async_load; };
yyBuiltIn.prototype.get_event_data = function () { return this.event_data; };
yyBuiltIn.prototype.get_display_aa = function () { return 0; };
@@ -279,8 +279,8 @@ yyBuiltIn.prototype.getbackground_blend = function () { return g_pBuiltIn.backgr
yyBuiltIn.prototype.getbackground_alpha = function () { return g_pBuiltIn.background_alpha[0]; };
-yyBuiltIn.prototype.set_room_speed = function (_val) { _val = yyGetReal(_val); if (g_isZeus) { return g_GameTimer.SetFrameRate(_val); } else { return g_RunRoom.SetSpeed(_val); } };
-yyBuiltIn.prototype.get_room_speed = function (_val) { if (g_isZeus) { return g_GameTimer.GetFPS(_val); } else { return g_RunRoom.m_speed; } };
+yyBuiltIn.prototype.set_room_speed = function (_val) { _val = yyGetReal(_val); return g_GameTimer.SetFrameRate(yyGetReal(_val)); };
+yyBuiltIn.prototype.get_room_speed = function (_val) { return g_GameTimer.GetFPS(_val); };
yyBuiltIn.prototype.set_room_caption = function (_val) { return g_RunRoom.SetCaption(yyGetString(_val)); };
yyBuiltIn.prototype.set_room_width = function (_val) { return g_RunRoom.SetWidth(yyGetReal(_val)); };
diff --git a/scripts/yyEffects.js b/scripts/yyEffects.js
index 26c0f7a8..973b9b86 100644
--- a/scripts/yyEffects.js
+++ b/scripts/yyEffects.js
@@ -15,6 +15,7 @@
//
// **********************************************************************************************************************
+// @if feature("layerEffects")
var EFFECT_CLEANUP_FUNC = "cleanup",
EFFECT_STEP_FUNC = "step",
EFFECT_LAYER_BEGIN_FUNC = "layer_begin",
@@ -319,11 +320,11 @@ yyFilterHost.prototype.Step = function ()
{
if (this.startTime == -1)
{
- this.startTime = YoYo_GetTimer();
+ this.startTime = get_timer();
}
else
{
- this.elapsedTime = YoYo_GetTimer() - this.startTime;
+ this.elapsedTime = get_timer() - this.startTime;
}
};
@@ -542,6 +543,7 @@ yyFilterHost.prototype.LayerEnd = function (_layerID)
} break;
case FAE_PARAM_SAMPLER:
{
+ // @if feature("sprites")
var spriteID = pVar;
var pSprite = g_pSpriteManager.Get(spriteID);
if ((pSprite != null) && (pSprite.SWFTimeline === undefined) && (pSprite.m_skeletonSprite === undefined))
@@ -580,6 +582,7 @@ yyFilterHost.prototype.LayerEnd = function (_layerID)
args[1].kind = VALUE_PTR;
args[1].ptr = YYGetPtr(pVar, 0);
F_Shader_Set_Texture(res, NULL, NULL, 2, args);*/
+ // @endif sprites
} break;
}
}
@@ -830,12 +833,14 @@ yyEffectInstance.prototype.SetParam = function (_pParamName, _type, _elements, _
case FAE_PARAM_FLOAT: pEntry = _data[j]; break;
case FAE_PARAM_INT: pEntry = _data[j]; break;
case FAE_PARAM_BOOL: pEntry = _data[j] ? 1 : 0; break;
+ // @if feature("sprites")
case FAE_PARAM_SAMPLER:
{
var spriteID = g_pSpriteManager.Sprite_Find(_data[j]);
pEntry = spriteID;
break;
}
+ // @endif sprites
}
pVar.push(pEntry);
@@ -848,12 +853,14 @@ yyEffectInstance.prototype.SetParam = function (_pParamName, _type, _elements, _
case FAE_PARAM_FLOAT: pVar = _data[0]; break;
case FAE_PARAM_INT: pVar = _data[0]; break;
case FAE_PARAM_BOOL: pVar = _data[0] ? 1 : 0; break;
+ // @if feature("sprites")
case FAE_PARAM_SAMPLER:
{
var spriteID = g_pSpriteManager.Sprite_Find(_data[0]);
pVar = spriteID;
break;
}
+ // @endif sprites
}
}
@@ -1609,4 +1616,5 @@ yyEffectsManager.prototype.CleanupOldTempSurfaces = function()
}
}
}
-};
\ No newline at end of file
+};
+// @endif
diff --git a/scripts/yyFont.js b/scripts/yyFont.js
index 16eb9edf..689633ef 100644
--- a/scripts/yyFont.js
+++ b/scripts/yyFont.js
@@ -45,6 +45,7 @@ function FontEffectParams( )
///
/// In:
// #############################################################################################
+// @if feature("fonts")
/** @constructor */
function yyFont( )
{
@@ -668,6 +669,7 @@ function getKerningInfo( ch, pGlyph)
// #############################################################################################
yyFont.prototype.Draw_String_GL_Full = function (_x, _y, _pStr, _xscale, _yscale, _angle, _col1, _col2,_col3,_col4, _charSpacing, _wordSpacing) //, _alpha) {
{
+ // @if feature("gl")
var TP = this.TPEntry; //g_Textures[this.TPEntry.tp];
if (!TP.texture.complete) return; // if texture hasn't loaded, return...
var len = _pStr.length;
@@ -722,6 +724,7 @@ yyFont.prototype.Draw_String_GL_Full = function (_x, _y, _pStr, _xscale, _yscale
}
}
//if (Math.abs(_angle) > 0.001) Graphics_SetTransform();
+ // @endif
};
// #############################################################################################
@@ -755,6 +758,7 @@ yyFont.prototype.BuildWorldMatrix = function(_x, _y, _angle) {
// #############################################################################################
yyFont.prototype.Draw_String_GL = function (_x, _y, _pStr, _xscale, _yscale, _angle, _col1, _col2,_col3,_col4, _charSpacing, _wordSpacing, _pFontParams) //, _alpha)
{
+ // @if feature("gl")
if( this.runtime_created)
{
//original
@@ -938,6 +942,7 @@ yyFont.prototype.Draw_String_GL = function (_x, _y, _pStr, _xscale, _yscale, _an
if (worldMatrix != undefined) {
WebGL_SetMatrix(MATRIX_WORLD, worldMatrix);
}
+ // @endif
};
@@ -957,6 +962,7 @@ yyFont.prototype.Draw_String_GL = function (_x, _y, _pStr, _xscale, _yscale, _an
// #############################################################################################
yyFont.prototype.Draw_String = function (_x, _y, _pStr, _xscale, _yscale, _angle, _col1, _col2, _col3, _col4, _charSpacing, _wordSpacing) //, _alpha) {
{
+ // @if feature("2d")
var cached_image = null;
var ch;
var TP = g_Textures[this.TPEntry.tp];
@@ -1125,6 +1131,7 @@ yyFont.prototype.Draw_String = function (_x, _y, _pStr, _xscale, _yscale, _angle
} // end else
} // end else
graphics.globalAlpha = la;
+ // @endif
};
@@ -1145,6 +1152,7 @@ yyFont.prototype.Draw_String = function (_x, _y, _pStr, _xscale, _yscale, _angle
// #############################################################################################
yyFont.prototype.Draw_Sprite_String = function (_x, _y, _pStr, _xscale, _yscale, _angle, _col1, _col2, _col3, _col4, _charSpacing, _wordSpacing)
{
+ // @if feature("2d")
if (this.pSprites == null) return;
var charSpacing = 0.0;
@@ -1213,6 +1221,7 @@ yyFont.prototype.Draw_Sprite_String = function (_x, _y, _pStr, _xscale, _yscale,
if (Math.abs(_angle) >= 0.001) Graphics_SetTransform();
graphics.globalAlpha = la;
+ // @endif
};
@@ -1235,6 +1244,7 @@ yyFont.prototype.Draw_Sprite_String = function (_x, _y, _pStr, _xscale, _yscale,
// #############################################################################################
yyFont.prototype.Draw_Sprite_String_GL = function (_x, _y, _pStr, _xscale, _yscale, _angle, _c1, _c2, _c3, _c4, _charSpacing, _wordSpacing)
{
+ // @if feature("gl")
if (this.pSprites == null) return;
var charSpacing = 0.0;
@@ -1335,7 +1345,9 @@ yyFont.prototype.Draw_Sprite_String_GL = function (_x, _y, _pStr, _xscale, _ysca
if (worldmat !== undefined) {
WebGL_SetMatrix(MATRIX_WORLD, worldmat);
}
+ // @endif
};
+// @endif fonts
@@ -1360,6 +1372,7 @@ var FONTSDFSHADER_DISABLED = -1,
/// Create a new Font manager
///
// #############################################################################################
+// @if feature("fonts")
/** @constructor */
function yyFontManager( )
{
@@ -1434,6 +1447,7 @@ function yyFontManager( )
yyFontManager.prototype.Start_Rendering_SDF = function(_pFont, _shadowPass, _pEffectOverride)
{
+ // @if function("font_enable_sdf") && feature("gl")
if (g_webGL)
{
if (shader_current() != -1)
@@ -1459,13 +1473,13 @@ yyFontManager.prototype.Start_Rendering_SDF = function(_pFont, _shadowPass, _pEf
}
var SDFshader = this.SDF_State.SDFShaders[shadertype];
- if ((SDFshader == -1) || (shader_is_compiled(SDFshader) == false))
+ if ((this.SDF_State.SDFShader == -1) || (!WebGL_shader_is_compiled_RELEASE(this.SDF_State.SDFShader)))
return; // our SDF shader either doesn't exist or hasn't been compiled
if (this.SDF_State.usingSDFShader != FONTSDFSHADER_DISABLED)
return; // already enabled (these calls can't be nested)
- shader_set(SDFshader);
+ WebGL_shader_set_RELEASE(this.SDF_State.SDFShader);
if (shadertype == FONTSDFSHADER_EFFECT)
{
@@ -1535,27 +1549,30 @@ yyFontManager.prototype.Start_Rendering_SDF = function(_pFont, _shadowPass, _pEf
var basetexstage = 0; // we always force the default texture sampler index to be 0
- this.SDF_State.currTexFilter = gpu_get_texfilter_ext(basetexstage); // we always force the default texture sampler index to be 0
- gpu_set_texfilter_ext(basetexstage, true);
+ this.SDF_State.currTexFilter = WebGL_gpu_get_texfilter_ext(basetexstage); // we always force the default texture sampler index to be 0
+ WebGL_gpu_set_texfilter_ext(basetexstage, true);
this.SDF_State.usingSDFShader = shadertype;
}
+ // @endif
};
yyFontManager.prototype.End_Rendering_SDF = function()
{
+ // @if function("font_enable_sdf") && feature("gl")
if (g_webGL)
{
if (this.SDF_State.usingSDFShader != FONTSDFSHADER_DISABLED)
{
- shader_reset();
+ WebGL_shader_set_RELEASE(-1);
var basetexstage = 0; // we always force the default texture sampler index to be 0
- gpu_set_texfilter_ext(basetexstage, this.SDF_State.currTexFilter);
+ WebGL_gpu_set_texfilter_ext(basetexstage, this.SDF_State.currTexFilter);
this.SDF_State.usingSDFShader = FONTSDFSHADER_DISABLED;
}
}
+ // @endif
};
yyFontManager.prototype.Should_Render_Drop_Shadow = function(_pFont, _pEffectOverride)
@@ -1760,6 +1777,7 @@ function String_Replace_Hash(str, thefont, _override_zeus)
}
return pD;
}
+// @endif fonts
@@ -1775,6 +1793,7 @@ function String_Replace_Hash(str, thefont, _override_zeus)
///
///
// #############################################################################################
+// @if feature("fonts")
yyFontManager.prototype.Split_TextBlock = function (_pStr, linewidth, thefont) {
if (_pStr == null) return;
@@ -1788,7 +1807,6 @@ yyFontManager.prototype.Split_TextBlock = function (_pStr, linewidth, thefont) {
var sl_index = 0;
// put newlines in
- if(!g_isZeus) _pStr = String_Replace_Hash(_pStr, thefont);
var len = _pStr.length;
// Allocate new space
@@ -1932,7 +1950,6 @@ yyFontManager.prototype.Split_TextBlock_IDEstyle = function (_pStr, _boundsWidth
var sl = [];
// put newlines in
- if(!g_isZeus) _pStr = String_Replace_Hash(_pStr, this.thefont);
var len = _pStr.length;
// Allocate new space
@@ -2612,3 +2629,4 @@ yyFontManager.prototype.GR_Text_Sizes = function (_str, x, y, linesep, linewidth
w = thefont.TextWidth(pStr, true);
if (g_ActualTextWidth < w) g_ActualTextWidth = w;
};
+// @endif fonts
diff --git a/scripts/yyGraphics.js b/scripts/yyGraphics.js
index 317b358e..3f0946e9 100644
--- a/scripts/yyGraphics.js
+++ b/scripts/yyGraphics.js
@@ -180,7 +180,7 @@ function Graphics_Init( _canvas )
g_transform[5] = 0;
if( !g_webGL ){
-
+ // @if feature("2d")
// Fill in RELEASE function pointers.
if (CACHE_SINGLE_IMAGE)
@@ -202,7 +202,9 @@ function Graphics_Init( _canvas )
Graphics_DrawPart = Graphics_DrawPart_RELEASE;
Graphics_Save = Graphics_Save_RELEASE;
Graphics_Restore = Graphics_Restore_RELEASE;
+ // @if feature("fonts")
Graphics_DrawText = Graphics_DrawText_RELEASE;
+ // @endif fonts
Graphics_StartFrame = Graphics_StartFrame_RELEASE;
Graphics_EndFrame = Graphics_EndFrame_RELEASE;
Graphics_DrawComment = Graphics_DrawComment_RELEASE;
@@ -225,9 +227,12 @@ function Graphics_Init( _canvas )
}
Graphics_TextureDrawTiled = Graphics_TextureDrawTiled_RELEASE;
Graphics_TextureDraw = Graphics_TextureDraw_DEBUG;
- }
+ }
+ // @endif
}else{
+ // @if feature("gl")
InitWebGLFunctions();
+ // @endif gl
}
@@ -1225,7 +1230,9 @@ function Graphics_ColouriseImage( _texture, _x, _y, _w, _h, _col )
///
///
// #############################################################################################
-function Graphics_TextureDrawPos(_pTPE, _x1, _y1, _x2, _y2, _x3, _y3, _x4, _y4, _alpha) {
+function Graphics_TextureDrawPos(){}
+// @if feature("2d") && function("draw_sprite_pos")
+Graphics_TextureDrawPos = function(_pTPE, _x1, _y1, _x2, _y2, _x3, _y3, _x4, _y4, _alpha) {
var pTexture = _pTPE.texture;
@@ -1235,7 +1242,7 @@ function Graphics_TextureDrawPos(_pTPE, _x1, _y1, _x2, _y2, _x3, _y3, _x4, _y4,
graphics.globalAlpha = _alpha;
drawTexturedTriangle(pTexture, _x1, _y1, _x2, _y2, _x3, _y3, _pTPE.x, _pTPE.y, _pTPE.x + _pTPE.w, _pTPE.y, _pTPE.x + _pTPE.w, _pTPE.y + _pTPE.h);
drawTexturedTriangle(pTexture, _x3, _y3, _x4, _y4, _x1, _y1, _pTPE.x + _pTPE.w, _pTPE.y + _pTPE.h, _pTPE.x, _pTPE.y + _pTPE.h, _pTPE.x, _pTPE.y);
-}
+};
// #############################################################################################
@@ -1336,6 +1343,7 @@ function drawTexturedTriangle(im, x0, y0, x1, y1, x2, y2, sx0, sy0, sx1, sy1, sx
graphics._drawImage(im, 0, 0);
Graphics_Restore();
}
+// @endif
@@ -1562,7 +1570,8 @@ function Graphics_DrawGeneral(_pTPE, _left,_top,_width,_height, _x,_y,_xscale
/// true for okay, false for error
///
// #############################################################################################
-var CopyImageToAlpha = CopyImageToAlpha_RELEASE;
+function CopyImageToAlpha(){}
+// @if feature("2d")
function CopyImageToAlpha_RELEASE(_pDestTPE, _pSrcTPE)
{
if ( g_webGL )
@@ -1608,6 +1617,10 @@ function CopyImageToAlpha_RELEASE(_pDestTPE, _pSrcTPE)
pDestImg.putImageData(DestDataLock, 0, 0);
return true;
}
+// @if function("sprite_set_alpha_from_sprite")
+CopyImageToAlpha = CopyImageToAlpha_RELEASE;
+// @endif
+// @endif
diff --git a/scripts/yyIOManager.js b/scripts/yyIOManager.js
index 248e23f3..b71277d5 100644
--- a/scripts/yyIOManager.js
+++ b/scripts/yyIOManager.js
@@ -18,9 +18,11 @@ var MAX_KEYS = 256;
var MAX_BUTTONS = 5;
var MAX_INPUT_STRING = 1024;
+// @if function("virtual_key_*")
var VIRTUALKEY_ACTIVE = 1;
var VIRTUALKEY_DRAW = 2;
var VIRTUALKEY_OUTLINE = 4;
+// @endif
var NEW_INPUT_EVENT = 1; // this is a new event
var TOUCH_INPUT_EVENT = 2; // this was done via mouse or touch
@@ -53,17 +55,21 @@ var g_KeyPressed = [];
var g_KeyUp = [];
// Used for virtual key-press tracking
+// @if function("virtual_key_*")
var g_VirtualKeys = [];
+// @endif
var g_InputEvents = [];
// Collects together the current set of input events, including holding onto the mouse down state
var g_CurrentInputEvents = [];
+// @if function("virtual_key_*")
var g_LastVirtualKeys = 0;
+// @endif
// Collects together all touch events as single-button mice
var g_TouchEvents = [];
-
+// @if feature("keyboard")
var g_UnshiftedKeyboardMapping = {
8: String.fromCharCode(8),
9:0,
@@ -280,7 +286,7 @@ var g_ShiftedKeyboardMapping = {
222: "~", //single quote 222
223: "¬"
};
-
+// @endif
// #############################################################################################
@@ -339,23 +345,11 @@ function hideshow(which)
function CheckJSON_Game(_ifr, _can) {
try
{
- if (_ifr)
- {
- if (_ifr.JSON_game)
- {
- if (_ifr.JSON_game.Options)
- {
- if (_ifr.JSON_game.Options.gameGuid)
- {
- if (_ifr.JSON_game.Options.gameGuid == JSON_game.Options.gameGuid)
- {
- _ifr.focus();
- _can.focus();
- return true;
- }
- }
- }
- }
+ let _guid = _ifr?.JSON_game?.Options?.gameGuid;
+ if (_guid && _guid == JSON_game.Options.gameGuid) {
+ _ifr.focus();
+ _can.focus();
+ return true;
}
} catch (err)
{
@@ -670,6 +664,7 @@ function CancelFullScreenMode() {
// #############################################################################################
function CaptureBrowserInput() {
if (g_InputCaught) return;
+ // @if feature("keyboard")
window.onkeyup = function () { yyKeyUpCallback(arguments[0] || window.event); };
window.onkeydown = function ()
{
@@ -695,6 +690,7 @@ function CaptureBrowserInput() {
return false;
}
};
+ // @endif
window.onmouseup = onMouseUp;
g_InputCaught = true;
}
@@ -707,8 +703,10 @@ function CaptureBrowserInput() {
// #############################################################################################
function ReleaseBrowserInput() {
if (g_InputCaught == false) return;
+ // @if feature("keyboard")
window.onkeydown = null;
window.onkeyup = null;
+ // @endif
window.onmouseup = null;
g_InputCaught = false;
@@ -1038,6 +1036,7 @@ function yyIOManager( )
this.Update = IO_Update;
//this.Clear = IO_Clear;
this.StartStep = IO_StartStep;
+ // @if feature("keyboard")
this.Char_Last_Get = Char_Last_Get;
this.Char_Last_Set = Char_Last_Set;
this.Key_Last_Get = Key_Last_Get;
@@ -1047,7 +1046,8 @@ function yyIOManager( )
this.Key_Down = Key_Down;
this.Key_Pressed = Key_Pressed;
this.Key_Released = Key_Released;
- this.Key_Clear = Key_Clear;
+ this.Key_Clear = Key_Clear;
+ // @endif keyboard
this.Button_Last_Get = Button_Last_Get;
this.Button_Current_Get = Button_Current_Get;
this.Button_Last_Set = Button_Last_Set;
@@ -1057,10 +1057,14 @@ function yyIOManager( )
this.Button_Released = Button_Released;
this.Button_Clear = Button_Clear;
this.Button_Clear_All = Button_Clear_All;
+ // @if feature("keyboard")
this.HandleKeyDown = IO_HandleKeyDown;
this.HandleKeyPressed= IO_HandleKeyPressed;
this.HandleKeyReleased= IO_HandleKeyReleased;
+ // @endif
+ // @if function("virtual_key_*")
this.ProcessVirtualKeys = ProcessVirtualKeys;
+ // @endif
// going from 0 to max makes it a "proper" packed array, and is much faster for some Javascript engines.
for (var l = 0; l < MAX_KEYS; l++){
@@ -1197,7 +1201,9 @@ function yyInputEvent()
// #############################################################################################
function Clear_Pressed()
{
+ // @if feature("keyboard")
IO_Key_Clear_All();
+ // @endif keyboard
IO_Button_Clear_All();
g_pBuiltIn.keyboard_key = 0;
g_pBuiltIn.keyboard_key = "";
@@ -1219,7 +1225,9 @@ function Clear_Pressed()
//function IO_Clear()
yyIOManager.prototype.Clear = function () {
//String_Clear();
+ // @if feature("keyboard")
this.Key_Clear_All();
+ // @endif keyboard
this.Button_Clear_All();
g_pBuiltIn.keyboard_key = 0;
@@ -1682,6 +1690,7 @@ function IO_Update()
g_CurrentInputEvents[eventIndex].Flags &= ~NEW_INPUT_EVENT;
}
+ // @if feature("keyboard")
if (g_LastKeyPressed_code)
{
if (g_LastKeyPressed)
@@ -1717,6 +1726,7 @@ function IO_Update()
g_pBuiltIn.keyboard_lastkey = g_pBuiltIn.keyboard_key;
g_pBuiltIn.keyboard_key = 0;
}
+ // @endif
this.MouseX = g_EventMouseX;
this.MouseY = g_EventMouseY;
@@ -1813,7 +1823,9 @@ function IO_Update()
g_pBuiltIn.mouse_button = g_EventButtonDown + 1;
g_pBuiltIn.mouse_lastbutton = g_EventLastButtonDown + 1;
+ // @if function("virtual_key_*")
this.ProcessVirtualKeys();
+ // @endif
}
// #############################################################################################
@@ -1822,6 +1834,7 @@ function IO_Update()
///
// #############################################################################################
/** @this {yyIOManager} */
+// @if function("virtual_key_*")
function ProcessVirtualKeys()
{
var CurrentVirtualKeyEvents = 0;
@@ -1895,6 +1908,7 @@ function ProcessVirtualKeys()
g_LastVirtualKeys = CurrentVirtualKeyEvents;
}
+// @endif virtualkey
// #############################################################################################
/// Function:
@@ -2194,6 +2208,7 @@ function HandleKeyboard()
g_pIOManager.HandleKeyReleased();
}
+// @if function("virtual_key_*")
// #############################################################################################
/// Function:
/// Constructor for a VirtualKey object
@@ -2261,6 +2276,8 @@ function DeleteAllVirtualKeys() {
g_VirtualKeys[l].flags = 0;
}
}
+// @endif virtualkey helpers
+
// #############################################################################################
/// Property:
/// Render IO specific stuff.
@@ -2283,7 +2300,7 @@ yyIOManager.prototype.Render = function () {
Graphics_SetTransform(trans);
//graphics._setTransform(trans[0], trans[1], trans[2], trans[3], trans[4], trans[5]);
-
+ // @if function("virtual_key_*")
var oldalpha = draw_get_alpha();
var oldcolour = draw_get_color();
@@ -2300,4 +2317,5 @@ yyIOManager.prototype.Render = function () {
draw_set_color(oldcolour);
draw_set_alpha(oldalpha);
Graphics_Restore();
+ // @endif virtualkey draw
};
diff --git a/scripts/yyIniFile.js b/scripts/yyIniFile.js
index 8a3f1a89..61dbe2a7 100644
--- a/scripts/yyIniFile.js
+++ b/scripts/yyIniFile.js
@@ -15,7 +15,7 @@
//
// **********************************************************************************************************************
-
+// @if function("ini_*")
var g_LastFileSize = 0,
g_LastErrorStatus = 0;
@@ -636,7 +636,7 @@ yyIniFile.prototype.WriteIniFile = function() {
return pFile;
};
-
+// @endif
// ##########################################################################################################################################################################################
diff --git a/scripts/yyInstance.js b/scripts/yyInstance.js
index b5b0c2a6..6b86d7a4 100644
--- a/scripts/yyInstance.js
+++ b/scripts/yyInstance.js
@@ -304,6 +304,7 @@ yyInstance.prototype = {
}
},
+ // @if feature("paths")
// path position property
get path_position() { return this.__path_position; },
set path_position(_val) {
@@ -357,7 +358,9 @@ yyInstance.prototype = {
this.__path_endaction = _val;
},
+ // @endif
+ // @if feature("timelines")
// timeline index property
get timeline_index() { return this.__timeline_index; },
set timeline_index(_val) {
@@ -384,6 +387,7 @@ yyInstance.prototype = {
this.__timeline_speed = _val;
},
+ // @endif timelines
// bbox_left property (NOTE: no setter)
get bbox_left() {
@@ -427,7 +431,7 @@ yyInstance.prototype = {
set image_index(_frame) {
_frame = yyGetReal(_frame);
-
+ // @if feature("sprites")
var sprite = g_pSpriteManager.Get(this.sprite_index);
if (sprite != null)
@@ -464,6 +468,7 @@ yyInstance.prototype = {
}
}
else
+ // @endif sprites
{
this.__image_index = _frame; // just use value as-is
}
@@ -490,46 +495,57 @@ yyInstance.prototype = {
// image_number property (no setter)
get image_number() {
+ // @if feature("sprites")
var pSprite = g_pSpriteManager.Get(this.sprite_index);
- if (!pSprite) return 0;
-
- var skeletonAnim = this.SkeletonAnimation();
- if (skeletonAnim) {
- return skeletonAnim.FrameCount(pSprite);
- }
- else if ((pSprite.SWFTimeline !== null) && (pSprite.SWFTimeline !== undefined)) {
- return pSprite.SWFTimeline.numFrames;
+ if (pSprite) {
+ // @if feature("spine")
+ var skeletonAnim = this.SkeletonAnimation();
+ if (skeletonAnim) return skeletonAnim.FrameCount(pSprite);
+ // @endif spine
+ // @if feature("swf")
+ if (pSprite.SWFTimeline != null) return pSprite.SWFTimeline.numFrames;
+ // @endif
+ return pSprite.ppTPE.length;
}
- return pSprite.ppTPE.length;
+ // @endif sprites
+ return 0;
},
// sprite_width property
get sprite_width() {
+ // @if feature("sprites")
var pSprite = g_pSpriteManager.Get(this.sprite_index);
- if (!pSprite) return 0;
- return pSprite.width * this.image_xscale;
+ if (pSprite) return pSprite.width * this.image_xscale;
+ // @endif sprites
+ return 0;
},
// sprite_height property
get sprite_height() {
+ // @if feature("sprites")
var pSprite = g_pSpriteManager.Get(this.sprite_index);
- if (!pSprite) return 0;
- return pSprite.height * this.image_yscale;
+ if (pSprite) return pSprite.height * this.image_yscale;
+ // @endif sprites
+ return 0;
},
// sprite_xoffset property
get sprite_xoffset() {
+ // @if feature("sprites")
var pSprite = g_pSpriteManager.Get(this.sprite_index);
- if (!pSprite) return 0;
- return pSprite.xOrigin * this.image_xscale;
+ if (pSprite) return pSprite.xOrigin * this.image_xscale;
+ // @endif sprites
+ return 0;
},
// sprite_yoffset property
get sprite_yoffset() {
+ // @if feature("sprites")
var pSprite = g_pSpriteManager.Get(this.sprite_index);
- if (!pSprite) return 0;
- return pSprite.yOrigin * this.image_yscale;
+ if (pSprite) return pSprite.yOrigin * this.image_yscale;
+ // @endif sprites
+ return 0;
},
// image_xscale property
@@ -587,6 +603,7 @@ yyInstance.prototype = {
this.m_pMaskSkeleton = null;
},
+ // @if feature("timelines")
// timeline_running property
get timeline_running() {
if( this.timeline_paused ){
@@ -610,7 +627,9 @@ yyInstance.prototype = {
set timeline_loop( _loop ) {
this.timeline_looped = yyGetBool(_loop);
},
-
+ // @endif timeline props
+
+ // @if feature("physics")
// phy_rotation property
get phy_rotation() { return this.__phy_rotation; },
set phy_rotation(_rotation) {
@@ -749,6 +768,7 @@ yyInstance.prototype = {
this.RefreshPhysicalProperties(this.m_physicsObject.m_physicsBody);
}
},
+ // @endif physics properties
// layer property
get layer() { return this.m_nLayerID; },
@@ -859,10 +879,12 @@ yyInstance.prototype.Assign = function (_pInst, _LinkToObjectType) {
}
// Any skeleton data needs to be not just a reference
+ // @if feature("spine")
var skeletonAnim = this.SkeletonAnimation();
if (skeletonAnim) {
this.m_pSkeletonAnimation = skeletonAnim.Clone();
- }
+ }
+ // @endif
this.m_nLayerID = _pInst.layer;
};
@@ -916,18 +938,6 @@ yyInstance.prototype.SetObjectIndex = function (_objindex, _LinkToObjectType, _S
// and copy the data over...
this.mask_index = this.pObject.SpriteMask;
- if(!g_isZeus)
- {
- //Zeus, no object has a depth defined
- if (_SetDepthNow)
- {
- // RK :: set the underlying variable rather than going through the property
- this.__depth = this.pObject.Depth;
- } else
- {
- this.depth = this.pObject.Depth;
- }
- }
this.solid = this.pObject.Solid;
this.visible = this.pObject.Visible;
this.persistent = this.pObject.Persistent;
@@ -944,7 +954,7 @@ yyInstance.prototype.SetObjectIndex = function (_objindex, _LinkToObjectType, _S
///
// #############################################################################################
yyInstance.prototype.UpdateSpriteIndex = function (_index) {
-
+ // @if feature("sprites")
var pSprite = g_pSpriteManager.Get(_index);
if (pSprite) {
this.bbox.left = pSprite.bbox.left;
@@ -952,6 +962,7 @@ yyInstance.prototype.UpdateSpriteIndex = function (_index) {
this.bbox.top = pSprite.bbox.top;
this.bbox.bottom = pSprite.bbox.bottom;
}
+ // @endif sprites
this.sprite_index = _index;
this.m_pSkeletonAnimation = null;
@@ -968,7 +979,7 @@ yyInstance.prototype.UpdateSpriteIndex = function (_index) {
///
// #############################################################################################
yyInstance.prototype.RebuildPhysicsBody = function (_room) {
-
+ // @if feature("physics")
// Null off pre-existing bodies to ensure that the data is entirely
// rebuilt either now or later in the logic (e.g. room start event)
if (_room && this.m_physicsObject) {
@@ -983,6 +994,7 @@ yyInstance.prototype.RebuildPhysicsBody = function (_room) {
this.BuildPhysicsBody();
this.bbox_dirty = true;
}
+ // @endif
};
// #############################################################################################
@@ -991,7 +1003,7 @@ yyInstance.prototype.RebuildPhysicsBody = function (_room) {
///
// #############################################################################################
yyInstance.prototype.BuildPhysicsBody = function () {
-
+ // @if feature("physics")
if (!this.pObject.PhysicsData.physicsObject) {
return;
}
@@ -1000,7 +1012,6 @@ yyInstance.prototype.BuildPhysicsBody = function () {
if (!sprite_exists(this.sprite_index)) {
return;
}
- var spr = g_pSpriteManager.Get(this.sprite_index);
// Without a physics world we won't get far
if (!g_RunRoom.m_pPhysicsWorld) {
@@ -1083,6 +1094,7 @@ yyInstance.prototype.BuildPhysicsBody = function () {
// And bind the fixture to get the physical object for this instance
physics_fixture_bind(this, fixtureID, this.id, xoffs, yoffs);
+ // @endif BuildPhysicsBody
};
// #############################################################################################
@@ -1218,14 +1230,18 @@ yyInstance.prototype.AdaptSpeed = function () {
///
// #############################################################################################
yyInstance.prototype.GetImageNumber = function () {
-
- var pSprite = g_pSpriteManager.Get(this.sprite_index);
-
+ // @if feature("sprites")
+ // @if feature("spine")
var skeletonAnim = this.SkeletonAnimation();
if (skeletonAnim) {
+ var pSprite = g_pSpriteManager.Get(this.sprite_index);
return skeletonAnim.FrameCount(pSprite);
}
+ // @endif spine
return g_pSpriteManager.GetImageCount(this.sprite_index);
+ // @else
+ return 0;
+ // @endif sprites
};
// #############################################################################################
@@ -1331,23 +1347,6 @@ yyInstance.prototype.PerformEventInherited = function (_event, _index, _pOther)
}
};
-// #############################################################################################
-/// Function:
-/// Perform an event on this instance.
-///
-///
-/// In: the event to perform
-/// the THIS to use in the event
-/// the OTHER to use in the event
-// #############################################################################################
-/*yyInstance.prototype.PerformEvent = function (_event, _index, _pInst, _pOther) {
-
- //if( pObject.Name == "oAssessmentBack" & _event==EVENT_DRAW){
- // this.testcode = 1;
- //}
- return this.PerformEvent_Common(_event, _index, _pInst, _pOther, _pInst.pObject);
-};*/
-
// #############################################################################################
/// Function:
@@ -1431,6 +1430,7 @@ yyInstance.prototype.Compute_BoundingBox = function() {
var maskCollisionSkel = this.MaskCollisionSkeleton();
var collisionSkel = this.GetCollisionSkeleton();
+ // @if feature("spine")
if(maskCollisionSkel !== null && g_pSpriteManager.Sprites[this.mask_index].bboxmode == 0 /* "Automatic" */) {
if (!this.bbox) {
this.bbox = new YYRECT(0, 0, 0, 0);
@@ -1452,7 +1452,7 @@ yyInstance.prototype.Compute_BoundingBox = function() {
this.bbox_dirty = false;
return;
}
- else if(collisionSkel !== null && g_pSpriteManager.Sprites[this.sprite_index].bboxmode == 0 /* "Automatic" */) {
+ if(collisionSkel !== null && g_pSpriteManager.Sprites[this.sprite_index].bboxmode == 0 /* "Automatic" */) {
if (!this.bbox) {
this.bbox = new YYRECT(0, 0, 0, 0);
}
@@ -1473,10 +1473,13 @@ yyInstance.prototype.Compute_BoundingBox = function() {
this.bbox_dirty = false;
return;
}
+ // @endif
var spr, t;
var ix = (this.mask_index >= 0) ? this.mask_index : this.sprite_index;
+ // @if feature("sprites")
if (ix < 0 || ix > g_pSpriteManager.Sprites.length) {
+ // @endif sprites
if (!this.bbox) {
this.bbox = new YYRECT(0, 0, 0, 0);
@@ -1487,13 +1490,14 @@ yyInstance.prototype.Compute_BoundingBox = function() {
this.bbox.bottom = this.y;
this.colcheck = yySprite_CollisionType.AXIS_ALIGNED_RECT;
+ // @if feature("sprites")
}
else
{
var bbox = this.bbox;
spr = g_pSpriteManager.Sprites[ix];
if (this.image_angle == 0) {
-
+ // @if feature("nineslice")
if ((spr.nineslicedata != null) && (spr.nineslicedata.GetEnabled()))
{
bbox = spr.GetScaledBoundingBox(this.image_xscale, this.image_yscale);
@@ -1503,8 +1507,8 @@ yyInstance.prototype.Compute_BoundingBox = function() {
bbox.top += this.y;
bbox.bottom += this.y;
- }
- else
+ } else // ->
+ // @endif
{
var pRect = spr.bbox;
var width = (pRect.right+1) - pRect.left;
@@ -1556,7 +1560,8 @@ yyInstance.prototype.Compute_BoundingBox = function() {
else {
var xmin, xmax;
var ymin, ymax;
-
+
+ // @if feature("nineslice")
if ((spr.nineslicedata != null) && (spr.nineslicedata.GetEnabled()))
{
bbox = spr.GetScaledBoundingBox(this.image_xscale, this.image_yscale);
@@ -1572,8 +1577,8 @@ yyInstance.prototype.Compute_BoundingBox = function() {
xmax += 1;
}
- }
- else
+ } else
+ // @endif
{
var pRect = spr.bbox;
@@ -1643,7 +1648,8 @@ yyInstance.prototype.Compute_BoundingBox = function() {
this.colcheck = spr.colcheck;
}
this.bbox = bbox;
- }
+ }
+ // @endif sprites
this.bbox_dirty = false;
};
@@ -1663,7 +1669,7 @@ yyInstance.prototype.Maybe_Compute_BoundingBox = function() {
this.Compute_BoundingBox();
return;
}
-
+ // @if feature("spine")
var collisionSkel = this.GetCollisionSkeleton();
if (collisionSkel !== null)
{
@@ -1679,6 +1685,7 @@ yyInstance.prototype.Maybe_Compute_BoundingBox = function() {
return;
}
}
+ // @endif spine
};
@@ -1720,6 +1727,8 @@ yyInstance.prototype.Collision_Point = function (_x, _y, _prec) {
return false;
}
}
+ var Result = false;
+ // @if feature("sprites")
var pSpr;
if (this.mask_index < 0) {
@@ -1736,12 +1745,13 @@ yyInstance.prototype.Collision_Point = function (_x, _y, _prec) {
// handle precise collision tests
- var Result = false;
+ // @if feature("spine")
var collisionSkel = this.GetCollisionSkeleton();
if (collisionSkel !== null) {
Result = collisionSkel.PointCollision(this.CollisionImageIndex(), this.x, this.y, this.image_xscale, this.image_yscale, this.image_angle, _x, _y);
- }
- else {
+ } else // ->
+ // @endif
+ {
Result = pSpr.PreciseCollisionPoint(Math.floor(this.image_index), bbox,
Round(this.x), Round(this.y),
this.image_xscale, this.image_yscale,
@@ -1749,6 +1759,7 @@ yyInstance.prototype.Collision_Point = function (_x, _y, _prec) {
Round(_x), Round(_y)
);
}
+ // @endif sprites
return Result;
};
@@ -1773,6 +1784,7 @@ yyInstance.prototype.Collision_Rectangle = function (_x1, _y1, _x2, _y2, _prec)
this.Maybe_Compute_BoundingBox();
// easy cases first
+ var Result = false;
var bbox = this.bbox;
var col_delta = 0; //To avoid floating point inaccuracies
@@ -1809,6 +1821,7 @@ yyInstance.prototype.Collision_Rectangle = function (_x1, _y1, _x2, _y2, _prec)
return Result;
}
+ // @if feature("sprites")
var pSpr;
if (this.mask_index < 0) {
pSpr = g_pSpriteManager.Get(this.sprite_index);
@@ -1843,14 +1856,15 @@ yyInstance.prototype.Collision_Rectangle = function (_x1, _y1, _x2, _y2, _prec)
}
// handle precise collision tests
- var Result = false;
+ // @if feature("spine")
var collisionSkel = this.GetCollisionSkeleton();
if (collisionSkel !== null) {
Result = collisionSkel.RectangleCollision(this.CollisionImageIndex(), this.x, this.y,
this.image_xscale, this.image_yscale, this.image_angle,
_x1, _y1, _x2, _y2);
- }
- else {
+ } else // ->
+ // @endif
+ {
//function Rect(ALeft, ATop, ARight, ABottom: Integer): TRect;
g_rr.left = Round(yymin(_x1, _x2));
g_rr.top = Round(yymin(_y1, _y2));
@@ -1860,6 +1874,7 @@ yyInstance.prototype.Collision_Rectangle = function (_x1, _y1, _x2, _y2, _prec)
Result = pSpr.PreciseCollisionRectangle(Math.floor(this.image_index), bbox, Round(this.x), Round(this.y),
this.image_xscale, this.image_yscale, this.image_angle, g_rr);
}
+ // @endif sprites
return Result;
};
@@ -1958,6 +1973,7 @@ yyInstance.prototype.Collision_Ellipse = function (_x1, _y1, _x2, _y2, _prec) {
return false;
}
+ // @if feature("sprites")
var pSpr;
if (this.mask_index < 0) {
pSpr = g_pSpriteManager.Get(this.sprite_index);
@@ -1980,13 +1996,17 @@ yyInstance.prototype.Collision_Ellipse = function (_x1, _y1, _x2, _y2, _prec) {
g_rr.bottom = max_y1y2;
// handle precise collision tests
+ // @if feature("spine")
var collisionSkel = this.GetCollisionSkeleton();
if (collisionSkel !== null) {
return collisionSkel.EllipseCollision(this.CollisionImageIndex(), this.x, this.y, this.image_xscale, this.image_yscale, this.image_angle, g_rr);
- }
- else {
+ } else // ->
+ // @endif
+ {
return pSpr.PreciseCollisionEllipse(Math.floor(this.image_index), bbox, Round(this.x), Round(this.y), this.image_xscale, this.image_yscale, this.image_angle, g_rr);
}
+ // @endif sprites
+ return false;
};
@@ -2048,6 +2068,7 @@ yyInstance.prototype.Collision_Line = function (_x1, _y1, _x2, _y2, _prec) {
if ((_y1 < i_bbox.top) && (_y2 < i_bbox.top)) { return false; }
if ((_y1 >= i_bbox.bottom + 1) && (_y2 >= i_bbox.bottom + 1)) { return false; }
+ // @if feature("sprites")
var pSpr;
if (this.mask_index < 0) {
pSpr = g_pSpriteManager.Get(this.sprite_index);
@@ -2068,13 +2089,15 @@ yyInstance.prototype.Collision_Line = function (_x1, _y1, _x2, _y2, _prec) {
if (!_prec || this.colcheck === yySprite_CollisionType.AXIS_ALIGNED_RECT) { return true; }
// handle precise collision tests
+ // @if feature("spine")
var collisionSkel = this.GetCollisionSkeleton();
if (collisionSkel !== null) {
return collisionSkel.LineCollision(this.CollisionImageIndex(), this.x, this.y, this.image_xscale, this.image_yscale, this.image_angle, _x1, _y1, _x2, _y2);
}
- else {
- return pSpr.PreciseCollisionLine(this.image_index | 0, i_bbox, Round(this.x), Round(this.y), this.image_xscale, this.image_yscale, this.image_angle, Round(_x1), Round(_y1), Round(_x2), Round(_y2));
- }
+ // @endif
+ return pSpr.PreciseCollisionLine(this.image_index | 0, i_bbox, Round(this.x), Round(this.y), this.image_xscale, this.image_yscale, this.image_angle, Round(_x1), Round(_y1), Round(_x2), Round(_y2));
+ // @endif sprites
+ return false;
};
@@ -2086,6 +2109,7 @@ yyInstance.prototype.Collision_Line = function (_x1, _y1, _x2, _y2, _prec) {
// #############################################################################################
yyInstance.prototype.Collision_Skeleton = function (inst, prec)
{
+ // @if feature("spine")
// Go ahead and get the bounding box for our animation
this.Maybe_Compute_BoundingBox();
inst.Maybe_Compute_BoundingBox();
@@ -2098,7 +2122,7 @@ yyInstance.prototype.Collision_Skeleton = function (inst, prec)
// If the other instance doesn't actually have a sprite then we can't do precise collision testing with it
- var spr1 = g_pSpriteManager.Get(this.sprite_index);
+ // @if feature("sprites")
var spr2 = (inst.mask_index < 0)
? g_pSpriteManager.Get(inst.sprite_index)
: g_pSpriteManager.Get(inst.mask_index);
@@ -2122,15 +2146,16 @@ yyInstance.prototype.Collision_Skeleton = function (inst, prec)
return skel1.SpriteCollision(this.CollisionImageIndex(), this.x, this.y, this.image_xscale, this.image_yscale, this.image_angle,
spr2, inst.bbox, inst.CollisionImageIndex(), inst.x, inst.y, inst.image_xscale, inst.image_yscale, inst.image_angle);
}
- else{
- /* inst/spr2 is using bounding box collisions - no more to do. */
- return true;
- }
+ // @endif spine
+ /* inst/spr2 is using bounding box collisions - no more to do. */
+ return true;
+ // @endif sprites
+ return false;
};
yyInstance.prototype.Animate = function() {
-
+ // @if feature("sprites")
if(g_isZeus)
{
var pImage = g_pSpriteManager.Get( this.sprite_index );
@@ -2152,6 +2177,7 @@ yyInstance.prototype.Animate = function() {
return;
}
}
+ // @endif sprites
// BUGFIX: 30634 If we have no valid image set, increment image_index anyway just like in the Win32 runner
this.image_index += this.image_speed;
@@ -2231,7 +2257,8 @@ function getPoints(i1)
var spr = g_pSpriteManager.Sprites[ix];
var xmin, xmax;
var ymin, ymax;
-
+
+ // @if feature("nineslice")
if ((spr.nineslicedata != null) && (spr.nineslicedata.GetEnabled()))
{
var bbox = spr.GetScaledBoundingBox(i1.image_xscale, i1.image_yscale);
@@ -2241,8 +2268,8 @@ function getPoints(i1)
ymin = bbox.top;
ymax = bbox.bottom + 1;
- }
- else
+ } else // ->
+ // @endif
{
var pRect = spr.bbox;
@@ -2469,12 +2496,14 @@ yyInstance.prototype.Collision_Instance = function (_pInst, _prec) {
if (this != _pInst && !this.marked && !_pInst.marked)
{
// Change code path if either instance is using a Spine animation
+ // @if feature("spine")
if (this.UseSkeletonCollision()) {
return this.Collision_Skeleton(_pInst, _prec);
}
if (_pInst.UseSkeletonCollision()) {
return _pInst.Collision_Skeleton(this, _prec);
}
+ // @endif
@@ -2505,6 +2534,7 @@ yyInstance.prototype.Collision_Instance = function (_pInst, _prec) {
}
// dealing with precise collision checking
+ // @if feature("sprites")
var pSpr1 = null;
var pSpr2 = null;
if (this.mask_index < 0) {
@@ -2550,6 +2580,7 @@ yyInstance.prototype.Collision_Instance = function (_pInst, _prec) {
if (g_Collision_Compatibility_Mode)
{
+ // @if feature("collision_compatibility")
return pSpr1.OrigPreciseCollision(this.image_index | 0, this.bbox, Round(this.x), Round(this.y),
this.image_xscale, this.image_yscale,
this.image_angle,
@@ -2557,9 +2588,11 @@ yyInstance.prototype.Collision_Instance = function (_pInst, _prec) {
_pInst.image_index | 0, _pInst.bbox, Round(_pInst.x), Round(_pInst.y),
_pInst.image_xscale, _pInst.image_yscale,
_pInst.image_angle);
+ // @endif
}
else
{
+ // @if !feature("collision_compatibility")
return pSpr1.PreciseCollision(this.image_index | 0, this.bbox, Round(this.x), Round(this.y),
this.image_xscale, this.image_yscale,
this.image_angle,
@@ -2567,14 +2600,16 @@ yyInstance.prototype.Collision_Instance = function (_pInst, _prec) {
_pInst.image_index | 0, _pInst.bbox, Round(_pInst.x), Round(_pInst.y),
_pInst.image_xscale, _pInst.image_yscale,
_pInst.image_angle);
+ // @endif
}
+ // @endif sprites
}
return false;
};
-
+// @if feature("paths")
// #############################################################################################
/// Function:
@@ -2634,7 +2669,7 @@ yyInstance.prototype.Assign_Path = function (_ind, _speed, _scale, _orient, _abs
this.path_xstart = this.x;
this.path_ystart = this.y;
};
-
+// @endif
// #############################################################################################
/// Function:
@@ -2646,6 +2681,7 @@ yyInstance.prototype.Assign_Path = function (_ind, _speed, _scale, _orient, _abs
///
// #############################################################################################
yyInstance.prototype.Adapt_Path = function () {
+ // @if feature("paths")
var sp, xx, yy;
@@ -2769,10 +2805,9 @@ yyInstance.prototype.Adapt_Path = function () {
this.SetPosition(newx, newy);
return atPathEnd;
+ // @endif
};
-
-
// #############################################################################################
/// Function:
/// get the alarm timer for the given index
@@ -2823,19 +2858,17 @@ yyInstance.prototype.get_bbox = function () {
// #############################################################################################
yyInstance.prototype.wrap = function(_hor, _vert)
{
- var w, h;
+ var w = 0, h = 0;
// find the sprite size
- if (!sprite_exists(this.sprite_index))
- {
- w = h =0;
- }
- else
+ // @if feature("sprites")
+ if (sprite_exists(this.sprite_index))
{
var pSpr = g_pSpriteManager.Get(this.sprite_index);
w = pSpr.width * this.image_xscale;
h = pSpr.height * this.image_yscale;
}
+ // @endif sprites
// do horizontal wrap
if (_hor)
@@ -2888,11 +2921,10 @@ yyInstance.prototype.ApplyVisualOffset = function (_angle, _visualOffs) {
/// Transfer across physics data to properties the user can access
///
// #############################################################################################
+// @if feature("physics")
yyInstance.prototype.RefreshPhysicalProperties = function (_physicsBody) {
- var TargetSpeed =g_RunRoom.GetSpeed();
- if(g_isZeus)
- TargetSpeed = g_GameTimer.GetFPS();
+ var TargetSpeed = g_GameTimer.GetFPS();
var metreToPixelScale = 1.0 / g_RunRoom.m_pPhysicsWorld.m_pixelToMetreScale;
@@ -2995,9 +3027,7 @@ yyInstance.prototype.set_physics_linear_velocity_y = function(_vel) {
// #############################################################################################
yyInstance.prototype.set_physics_speed_x = function(_speed) {
- var TargetSpeed = g_RunRoom.GetSpeed();
- if(g_isZeus)
- TargetSpeed = g_GameTimer.GetFPS();
+ var TargetSpeed = g_GameTimer.GetFPS();
this.m_physicsObject.SetLinearVelocityX(yyGetReal(_speed) * g_RunRoom.m_pPhysicsWorld.m_pixelToMetreScale * TargetSpeed);
this.RefreshPhysicalProperties(this.m_physicsObject.m_physicsBody);
@@ -3011,9 +3041,7 @@ yyInstance.prototype.set_physics_speed_x = function(_speed) {
yyInstance.prototype.set_physics_speed_y = function(_speed) {
- var TargetSpeed = g_RunRoom.GetSpeed();
- if(g_isZeus)
- TargetSpeed = g_GameTimer.GetFPS();
+ var TargetSpeed = g_GameTimer.GetFPS();
this.m_physicsObject.SetLinearVelocityY(yyGetReal(_speed) * g_RunRoom.m_pPhysicsWorld.m_pixelToMetreScale * TargetSpeed);
this.RefreshPhysicalProperties(this.m_physicsObject.m_physicsBody);
};
@@ -3072,7 +3100,7 @@ yyInstance.prototype.set_physics_active = function(_isActive) {
this.m_physicsObject.SetActive(yyGetBool(_isActive));
this.RefreshPhysicalProperties(this.m_physicsObject.m_physicsBody);
};
-
+// @endif physics helpers
// #############################################################################################
@@ -3082,7 +3110,7 @@ yyInstance.prototype.set_physics_active = function(_isActive) {
///
// #############################################################################################
yyInstance.prototype.SkeletonAnimation = function () {
-
+ // @if feature("spine")
if (sprite_exists(this.sprite_index)) {
var spr = g_pSpriteManager.Get(this.sprite_index);
@@ -3094,11 +3122,13 @@ yyInstance.prototype.SkeletonAnimation = function () {
}
}
}
+ // @endif
return this.m_pSkeletonAnimation;
};
yyInstance.prototype.MaskCollisionSkeleton = function()
{
+ // @if feature("spine")
var mask_sprite = null;
var use_mask_skeleton = false;
@@ -3123,6 +3153,7 @@ yyInstance.prototype.MaskCollisionSkeleton = function()
this.m_pMaskSkeleton = new yySkeletonInstance(mask_sprite.m_skeletonSprite);
this.bbox_dirty = true;
}
+ // @endif
return this.m_pMaskSkeleton;
};
@@ -3130,7 +3161,7 @@ yyInstance.prototype.MaskCollisionSkeleton = function()
yyInstance.prototype.GetCollisionSkeleton = function()
{
var skel = null;
-
+ // @if feature("spine")
if (this.mask_index >= 0)
{
skel = this.MaskCollisionSkeleton();
@@ -3149,23 +3180,24 @@ yyInstance.prototype.GetCollisionSkeleton = function()
}
}
}
-
+ // @endif
return skel;
};
yyInstance.prototype.CollisionImageIndex = function()
{
+ // @if feature("spine")
if (this.mask_index >= 0 && g_pSpriteManager.Sprites[this.mask_index].colcheck === yySprite_CollisionType.SPINE_MESH)
{
return 0.0;
}
- else{
- return this.image_index;
- }
+ // @endif
+ return this.image_index;
};
yyInstance.prototype.UseSkeletonCollision = function()
{
+ // @if feature("spine")
if (this.mask_index < 0)
{
return this.SkeletonAnimation()
@@ -3174,6 +3206,9 @@ yyInstance.prototype.UseSkeletonCollision = function()
else{
return g_pSpriteManager.Sprites[this.mask_index].colcheck === yySprite_CollisionType.SPINE_MESH
}
+ // @else
+ return false;
+ // @endif
};
yyInstance.prototype.GetLayerID=function() { return this.m_nLayerID; };
@@ -3496,86 +3531,79 @@ yyInstanceManager.prototype.UpdateImages = function () {
if (pInst.marked) continue;
if (!pInst.active) continue;
+ // @if feature("sprites")
var sprite = g_pSpriteManager.Get(pInst.sprite_index);
-
- var usesSpriteSequences = false;
-
- if (sprite != null)
+ if (sprite?.sequence != null)
{
- if(sprite.sequence != null)
- {
- /*
- var sequence_image_index = pInst.sequence_pos;
- if ((sprite.sequence.m_tracks != null) && (sprite.sequence.m_tracks[0].m_type == eSTT_SpriteFrames))
- {
- var pTrack = sprite.sequence.m_tracks[0];
- var pKey = pTrack.m_keyframeStore.GetKeyframeAtFrame(pInst.sequence_pos, sprite.sequence.m_length);
- if (pKey == null)
- {
- pInst.SetImageIndex(-1); // no key at this time
- }
- else if(pTrack.m_numTracks > 0)
- {
- sequence_image_index = pTrack.m_tracks[0].getValue(0, pInst.sequence_pos, sprite.sequence.m_length);
-
- if (Math.abs(pInst.image_index - sequence_image_index) > g_GMLMathEpsilon)
- {
- var newseqpos = ConvertImageIndexToSequencePos(pInst, sprite, pInst.image_index);
- SetNewSequencePosition(pInst, sprite, newseqpos, true);
- }
- }
- }
- */
- var sequence_image_index = pInst.sequence_pos;
- if ((sprite.sequence.m_tracks != null) && (sprite.sequence.m_tracks[0].m_type == eSTT_SpriteFrames))
- {
- var pTrack = sprite.sequence.m_tracks[0];
- if (pTrack != null)
- {
- sequence_image_index = pTrack.getValue(pInst.sequence_pos);
-
- if (Math.abs(pInst.image_index - sequence_image_index)>g_GMLMathEpsilon)
- {
- var numkeyframes = pTrack.m_keyframeStore.numKeyframes;
- if (numkeyframes > 0) {
- var keyindex = ~~(pInst.image_index);
- var fracval = pInst.image_index - keyindex;
-
- var newseqpos = pInst.image_index;
- if (keyindex >= numkeyframes)
- {
- newseqpos = pTrack.m_keyframeStore.keyframes[numkeyframes - 1].m_key + (pInst.image_index - (numkeyframes - 1));
- }
- else if (keyindex < 0)
- {
- newseqpos = pInst.image_index;
- }
- else
- newseqpos = (pTrack.m_keyframeStore.keyframes[keyindex].m_key + (fracval * pTrack.m_keyframeStore.keyframes[keyindex].m_length));
-
- newseqpos = ConvertImageIndexToSequencePos(pInst, sprite, pInst.image_index);
- SetNewSequencePosition(pInst, sprite, newseqpos, true);
- } // end if
- }
-
- }
+ /*
+ var sequence_image_index = pInst.sequence_pos;
+ if ((sprite.sequence.m_tracks != null) && (sprite.sequence.m_tracks[0].m_type == eSTT_SpriteFrames))
+ {
+ var pTrack = sprite.sequence.m_tracks[0];
+ var pKey = pTrack.m_keyframeStore.GetKeyframeAtFrame(pInst.sequence_pos, sprite.sequence.m_length);
+ if (pKey == null)
+ {
+ pInst.SetImageIndex(-1); // no key at this time
}
+ else if(pTrack.m_numTracks > 0)
+ {
+ sequence_image_index = pTrack.m_tracks[0].getValue(0, pInst.sequence_pos, sprite.sequence.m_length);
+
+ if (Math.abs(pInst.image_index - sequence_image_index) > g_GMLMathEpsilon)
+ {
+ var newseqpos = ConvertImageIndexToSequencePos(pInst, sprite, pInst.image_index);
+ SetNewSequencePosition(pInst, sprite, newseqpos, true);
+ }
+ }
+ }
+ */
+ var sequence_image_index = pInst.sequence_pos;
+ if ((sprite.sequence.m_tracks != null) && (sprite.sequence.m_tracks[0].m_type == eSTT_SpriteFrames))
+ {
+ var pTrack = sprite.sequence.m_tracks[0];
+ if (pTrack != null)
+ {
+ sequence_image_index = pTrack.getValue(pInst.sequence_pos);
+
+ if (Math.abs(pInst.image_index - sequence_image_index)>g_GMLMathEpsilon)
+ {
+ var numkeyframes = pTrack.m_keyframeStore.numKeyframes;
+ if (numkeyframes > 0) {
+ var keyindex = ~~(pInst.image_index);
+ var fracval = pInst.image_index - keyindex;
+
+ var newseqpos = pInst.image_index;
+ if (keyindex >= numkeyframes)
+ {
+ newseqpos = pTrack.m_keyframeStore.keyframes[numkeyframes - 1].m_key + (pInst.image_index - (numkeyframes - 1));
+ }
+ else if (keyindex < 0)
+ {
+ newseqpos = pInst.image_index;
+ }
+ else
+ newseqpos = (pTrack.m_keyframeStore.keyframes[keyindex].m_key + (fracval * pTrack.m_keyframeStore.keyframes[keyindex].m_length));
+
+ newseqpos = ConvertImageIndexToSequencePos(pInst, sprite, pInst.image_index);
+ SetNewSequencePosition(pInst, sprite, newseqpos, true);
+ } // end if
+ }
- usesSpriteSequences = true;
+ }
+ }
- var fps = g_GameTimer.GetFPS();
+ var fps = g_GameTimer.GetFPS();
- // Get sequence length
- var length = sprite.sequence.m_length;
-
- var seqSpeed = sprite.sequence.m_playbackSpeed;
- if (sprite.sequence.m_playbackSpeedType == ePlaybackSpeedType_FramesPerSecond) seqSpeed /= fps;
+ // Get sequence length
+ var length = sprite.sequence.m_length;
+
+ var seqSpeed = sprite.sequence.m_playbackSpeed;
+ if (sprite.sequence.m_playbackSpeedType == ePlaybackSpeedType_FramesPerSecond) seqSpeed /= fps;
- SetNewSequencePosition(pInst, sprite, (pInst.sequence_pos + (pInst.sequence_dir * pInst.image_speed * seqSpeed)), false);
- }
+ SetNewSequencePosition(pInst, sprite, (pInst.sequence_pos + (pInst.sequence_dir * pInst.image_speed * seqSpeed)), false);
}
-
- if(!usesSpriteSequences)
+ else
+ // @endif sprites
{
var num = pInst.GetImageNumber();
if (pInst.image_index >= num) {
diff --git a/scripts/yyNineSliceData.js b/scripts/yyNineSliceData.js
index fdc4796b..a5c62303 100644
--- a/scripts/yyNineSliceData.js
+++ b/scripts/yyNineSliceData.js
@@ -14,6 +14,7 @@
//
// **********************************************************************************************************************
+// @if feature("nineslice")
var NINESLICE_TILE_STRETCH = 0,
NINESLICE_TILE_REPEAT = 1,
NINESLICE_TILE_MIRROR = 2,
@@ -1941,6 +1942,7 @@ yyNineSliceData.prototype.Draw = function (_x, _y, _width, _height, _rot, _colou
if (g_webGL)
{
+ // @if feature("gl")
for (i = 0; i < 4; i++)
{
// Rescale texture coordinates into texture space
@@ -2117,9 +2119,11 @@ yyNineSliceData.prototype.Draw = function (_x, _y, _width, _height, _rot, _colou
bindex += stride;
}
}
+ // @endif
}
else
{
+ // @if feature("2d")
graphics.globalAlpha = _alpha;
if (_colour != g_CacheWhite)
@@ -2165,6 +2169,8 @@ yyNineSliceData.prototype.Draw = function (_x, _y, _width, _height, _rot, _colou
Graphics_SetTransform();
}
}
+ // @endif
}
}
-};
\ No newline at end of file
+};
+// @endif
\ No newline at end of file
diff --git a/scripts/yyObject.js b/scripts/yyObject.js
index a5eec53e..59c6a5b6 100644
--- a/scripts/yyObject.js
+++ b/scripts/yyObject.js
@@ -15,9 +15,11 @@
//
// **********************************************************************************************************************
+// @if feature("physics")
var OBJECT_PHYSICS_SHAPE_CIRCLE = 0,
OBJECT_PHYSICS_SHAPE_BOX = 1,
OBJECT_PHYSICS_SHAPE_POLY = 2;
+// @endif physics constants
// #############################################################################################
/// Function:
@@ -169,6 +171,7 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) {
if (_pObjectStorage.DrawResize) { pObj.DrawResize = _pObjectStorage.DrawResize; pObj.Event[EVENT_DRAW_RESIZE] = true; }
+ // @if eventType("Mouse")
if( _pObjectStorage.NoButtonPressed) {pObj.NoButtonPressed = _pObjectStorage.NoButtonPressed; pObj.Event[EVENT_MOUSE_NOBUTTON] = true; }
if( _pObjectStorage.LeftButtonDown) {pObj.LeftButtonDown = _pObjectStorage.LeftButtonDown; pObj.Event[EVENT_MOUSE_LBUTTON_DOWN] = true; }
if( _pObjectStorage.RightButtonDown) {pObj.RightButtonDown = _pObjectStorage.RightButtonDown; pObj.Event[EVENT_MOUSE_RBUTTON_DOWN] = true; }
@@ -194,7 +197,9 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) {
if( _pObjectStorage.MouseEnter) {pObj.MouseEnter = _pObjectStorage.MouseEnter; pObj.Event[EVENT_MOUSE_ENTER] = true; }
if (_pObjectStorage.MouseLeave) { pObj.MouseLeave = _pObjectStorage.MouseLeave; pObj.Event[EVENT_MOUSE_LEAVE] = true; }
+ // @endif
+ // @if eventType("Gesture")
if (_pObjectStorage.GestureTapEvent) { pObj.GestureTapEvent = _pObjectStorage.GestureTapEvent; pObj.Event[EVENT_GESTURE_TAP] = true; }
if (_pObjectStorage.GestureDoubleTapEvent) { pObj.GestureDoubleTapEvent = _pObjectStorage.GestureDoubleTapEvent; pObj.Event[EVENT_GESTURE_DOUBLE_TAP] = true; }
if (_pObjectStorage.GestureDragStartEvent) { pObj.GestureDragStartEvent = _pObjectStorage.GestureDragStartEvent; pObj.Event[EVENT_GESTURE_DRAG_START] = true; }
@@ -208,9 +213,14 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) {
if (_pObjectStorage.GestureGlobalDragMoveEvent) { pObj.GestureGlobalDragMoveEvent = _pObjectStorage.GestureGlobalDragMoveEvent; pObj.Event[EVENT_GESTURE_GLOBAL_DRAG_MOVE] = true; }
if (_pObjectStorage.GestureGlobalDragEndEvent) { pObj.GestureGlobalDragEndEvent = _pObjectStorage.GestureGlobalDragEndEvent; pObj.Event[EVENT_GESTURE_GLOBAL_DRAG_END] = true; }
if (_pObjectStorage.GestureGlobalFlickEvent) { pObj.GestureGlobalFlickEvent = _pObjectStorage.GestureGlobalFlickEvent; pObj.Event[EVENT_GESTURE_GLOBAL_FLICK] = true; }
+ // @endif
+ // @if event("OutsideEvent")
if( _pObjectStorage.OutsideEvent) {pObj.OutsideEvent = _pObjectStorage.OutsideEvent; pObj.Event[EVENT_OTHER_OUTSIDE] = true; }
+ // @endif
+ // @if event("BoundaryEvent")
if( _pObjectStorage.BoundaryEvent) {pObj.BoundaryEvent = _pObjectStorage.BoundaryEvent; pObj.Event[EVENT_OTHER_BOUNDARY] = true; }
+ // @endif
if( _pObjectStorage.StartGameEvent) {pObj.StartGameEvent = _pObjectStorage.StartGameEvent; pObj.Event[EVENT_OTHER_STARTGAME] = true; }
if( _pObjectStorage.EndGameEvent) {pObj.EndGameEvent = _pObjectStorage.EndGameEvent; pObj.Event[EVENT_OTHER_ENDGAME] = true; }
if( _pObjectStorage.StartRoomEvent) {pObj.StartRoomEvent = _pObjectStorage.StartRoomEvent; pObj.Event[EVENT_OTHER_STARTROOM] = true; }
@@ -220,6 +230,7 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) {
if( _pObjectStorage.EndOfPathEvent) {pObj.EndOfPathEvent = _pObjectStorage.EndOfPathEvent; pObj.Event[EVENT_OTHER_ENDOFPATH] = true; }
if( _pObjectStorage.NoHealthEvent) {pObj.NoHealthEvent = _pObjectStorage.NoHealthEvent; pObj.Event[EVENT_OTHER_NOHEALTH] = true; }
if( _pObjectStorage.CloseButtonEvent) {pObj.CloseButtonEvent = _pObjectStorage.CloseButtonEvent; pObj.Event[EVENT_OTHER_CLOSEBUTTON] = true; }
+ // @if event("OutsideView*")
if( _pObjectStorage.OutsideView0Event) {pObj.OutsideView0Event = _pObjectStorage.OutsideView0Event; pObj.Event[EVENT_OTHER_OUTSIDE_VIEW0] = true; }
if( _pObjectStorage.OutsideView1Event) {pObj.OutsideView1Event = _pObjectStorage.OutsideView1Event; pObj.Event[EVENT_OTHER_OUTSIDE_VIEW1] = true; }
if( _pObjectStorage.OutsideView2Event) {pObj.OutsideView2Event = _pObjectStorage.OutsideView2Event; pObj.Event[EVENT_OTHER_OUTSIDE_VIEW2] = true; }
@@ -228,6 +239,8 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) {
if( _pObjectStorage.OutsideView5Event) {pObj.OutsideView5Event = _pObjectStorage.OutsideView5Event; pObj.Event[EVENT_OTHER_OUTSIDE_VIEW5] = true; }
if( _pObjectStorage.OutsideView6Event) {pObj.OutsideView6Event = _pObjectStorage.OutsideView6Event; pObj.Event[EVENT_OTHER_OUTSIDE_VIEW6] = true; }
if( _pObjectStorage.OutsideView7Event) {pObj.OutsideView7Event = _pObjectStorage.OutsideView7Event; pObj.Event[EVENT_OTHER_OUTSIDE_VIEW7] = true; }
+ // @endif
+ // @if event("BoundaryView*")
if( _pObjectStorage.BoundaryView0Event) {pObj.BoundaryView0Event = _pObjectStorage.BoundaryView0Event; pObj.Event[EVENT_OTHER_BOUNDARY_VIEW0] = true; }
if( _pObjectStorage.BoundaryView1Event) {pObj.BoundaryView1Event = _pObjectStorage.BoundaryView1Event; pObj.Event[EVENT_OTHER_BOUNDARY_VIEW1] = true; }
if( _pObjectStorage.BoundaryView2Event) {pObj.BoundaryView2Event = _pObjectStorage.BoundaryView2Event; pObj.Event[EVENT_OTHER_BOUNDARY_VIEW2] = true; }
@@ -236,10 +249,12 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) {
if( _pObjectStorage.BoundaryView5Event) {pObj.BoundaryView5Event = _pObjectStorage.BoundaryView5Event; pObj.Event[EVENT_OTHER_BOUNDARY_VIEW5] = true; }
if( _pObjectStorage.BoundaryView6Event) {pObj.BoundaryView6Event = _pObjectStorage.BoundaryView6Event; pObj.Event[EVENT_OTHER_BOUNDARY_VIEW6] = true; }
if( _pObjectStorage.BoundaryView7Event) {pObj.BoundaryView7Event = _pObjectStorage.BoundaryView7Event; pObj.Event[EVENT_OTHER_BOUNDARY_VIEW7] = true; }
+ // @endif
if( _pObjectStorage.AnimationUpdateEvent) {pObj.AnimationUpdateEvent = _pObjectStorage.AnimationUpdateEvent; pObj.Event[EVENT_OTHER_ANIMATIONUPDATE] = true; }
+ // @if event("UserEvent*")
if( _pObjectStorage.UserEvent0) {pObj.UserEvent0 = _pObjectStorage.UserEvent0; pObj.Event[EVENT_OTHER_USER0] = true; }
if( _pObjectStorage.UserEvent1) {pObj.UserEvent1 = _pObjectStorage.UserEvent1; pObj.Event[EVENT_OTHER_USER1] = true; }
if( _pObjectStorage.UserEvent2) {pObj.UserEvent2 = _pObjectStorage.UserEvent2; pObj.Event[EVENT_OTHER_USER2] = true; }
@@ -256,6 +271,7 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) {
if( _pObjectStorage.UserEvent13) {pObj.UserEvent13 = _pObjectStorage.UserEvent13; pObj.Event[EVENT_OTHER_USER13] = true; }
if( _pObjectStorage.UserEvent14) {pObj.UserEvent14 = _pObjectStorage.UserEvent14; pObj.Event[EVENT_OTHER_USER14] = true; }
if( _pObjectStorage.UserEvent15) {pObj.UserEvent15 = _pObjectStorage.UserEvent15; pObj.Event[EVENT_OTHER_USER15] = true; }
+ // @endif
if (_pObjectStorage.WebImageLoadedEvent) { pObj.WebImageLoadedEvent = _pObjectStorage.WebImageLoadedEvent; pObj.Event[EVENT_OTHER_WEB_IMAGE_LOAD] = true; }
if (_pObjectStorage.WebSoundLoadedEvent) { pObj.WebSoundLoadedEvent = _pObjectStorage.WebSoundLoadedEvent; pObj.Event[EVENT_OTHER_WEB_SOUND_LOAD] = true; }
@@ -264,15 +280,20 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) {
if (_pObjectStorage.WebIAPEvent) { pObj.WebIAPEvent = _pObjectStorage.WebIAPEvent; pObj.Event[EVENT_OTHER_WEB_IAP] = true; }
if (_pObjectStorage.SocialEvent) { pObj.SocialEvent = _pObjectStorage.SocialEvent; pObj.Event[EVENT_OTHER_SOCIAL] = true; }
if (_pObjectStorage.PushNotificationEvent) { pObj.PushNotificationEvent = _pObjectStorage.PushNotificationEvent; pObj.Event[EVENT_OTHER_PUSH_NOTIFICATION] = true; }
- if (_pObjectStorage.AsyncSaveLoadEvent) { pObj.AsyncSaveLoadEvent = _pObjectStorage.AsyncSaveLoadEvent; pObj.Event[EVENT_OTHER_ASYNC_SAVE_LOAD] = true; }
- if (_pObjectStorage.NetworkingEvent) { pObj.NetworkingEvent = _pObjectStorage.NetworkingEvent; pObj.Event[EVENT_OTHER_NETWORKING] = true; }
+ if (_pObjectStorage.AsyncSaveLoadEvent) { pObj.AsyncSaveLoadEvent = _pObjectStorage.AsyncSaveLoadEvent; pObj.Event[EVENT_OTHER_ASYNC_SAVE_LOAD] = true; }
+ // @if event("NetworkingEvent")
+ if (_pObjectStorage.NetworkingEvent) { pObj.NetworkingEvent = _pObjectStorage.NetworkingEvent; pObj.Event[EVENT_OTHER_NETWORKING] = true; }
+ // @endif
+ // @if feature("audio")
if (_pObjectStorage.AudioPlaybackEvent) { pObj.AudioPlaybackEvent = _pObjectStorage.AudioPlaybackEvent; pObj.Event[EVENT_OTHER_AUDIO_PLAYBACK] = true; }
if (_pObjectStorage.AudioPlaybackEndedEvent) { pObj.AudioPlaybackEndedEvent = _pObjectStorage.AudioPlaybackEndedEvent; pObj.Event[EVENT_OTHER_AUDIO_PLAYBACK_ENDED] = true; }
if (_pObjectStorage.AudioRecordingEvent) { pObj.AudioRecordingEvent = _pObjectStorage.AudioRecordingEvent; pObj.Event[EVENT_OTHER_AUDIO_RECORDING] = true; }
+ // @endif audio
if (_pObjectStorage.AnimationEventEvent) { pObj.AnimationEventEvent = _pObjectStorage.AnimationEventEvent; pObj.Event[EVENT_OTHER_ANIMATIONEVENT] = true; }
if (_pObjectStorage.SystemEvent) { pObj.SystemEvent = _pObjectStorage.SystemEvent; pObj.Event[EVENT_OTHER_SYSTEM_EVENT] = true; }
if (_pObjectStorage.BroadcastMessageEvent) { pObj.BroadcastMessageEvent = _pObjectStorage.BroadcastMessageEvent; pObj.Event[EVENT_OTHER_BROADCAST_MESSAGE] = true; }
+ // @if eventType("Alarm")
if( _pObjectStorage.ObjAlarm0) {pObj.ObjAlarm[0] = _pObjectStorage.ObjAlarm0; pObj.Event[EVENT_ALARM_0] = true; }
if( _pObjectStorage.ObjAlarm1) {pObj.ObjAlarm[1] = _pObjectStorage.ObjAlarm1; pObj.Event[EVENT_ALARM_1] = true; }
if( _pObjectStorage.ObjAlarm2) {pObj.ObjAlarm[2] = _pObjectStorage.ObjAlarm2; pObj.Event[EVENT_ALARM_2] = true; }
@@ -285,9 +306,11 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) {
if( _pObjectStorage.ObjAlarm9) {pObj.ObjAlarm[9] = _pObjectStorage.ObjAlarm9; pObj.Event[EVENT_ALARM_9] = true; }
if( _pObjectStorage.ObjAlarm10) {pObj.ObjAlarm[10] = _pObjectStorage.ObjAlarm10; pObj.Event[EVENT_ALARM_10] = true; }
if( _pObjectStorage.ObjAlarm11) {pObj.ObjAlarm[11] = _pObjectStorage.ObjAlarm11; pObj.Event[EVENT_ALARM_11] = true; }
+ // @endif
// Keyboard Pressed events (horrible but here we go....)
+ // @if eventType("KeyPress")
//if( _pObjectStorage.KeyPressed_) { pObj.ObjKeyPressed[GML_EVENT_KEYPRESS_] = _pObjectStorage.KeyPressed_; pObj.Event[GML_EVENT_KEYPRESS_] = true; }
if( _pObjectStorage.KeyPressed_NOKEY) { pObj.ObjKeyPressed[GML_EVENT_KEYPRESS_NOKEY] = _pObjectStorage.KeyPressed_NOKEY; pObj.Event[GML_EVENT_KEYPRESS_NOKEY] = true; }
if( _pObjectStorage.KeyPressed_ANYKEY) { pObj.ObjKeyPressed[GML_EVENT_KEYPRESS_ANYKEY] = _pObjectStorage.KeyPressed_ANYKEY; pObj.Event[GML_EVENT_KEYPRESS_ANYKEY] = true; }
@@ -379,9 +402,11 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) {
if( _pObjectStorage.KeyPressed_NUM_MINUS) { pObj.ObjKeyPressed[GML_EVENT_KEYPRESS_NUM_MINUS] = (_pObjectStorage.KeyPressed_NUM_MINUS); pObj.Event[GML_EVENT_KEYPRESS_NUM_MINUS] = true; }
if( _pObjectStorage.KeyPressed_NUM_DOT ) { pObj.ObjKeyPressed[GML_EVENT_KEYPRESS_NUM_DOT ] = (_pObjectStorage.KeyPressed_NUM_DOT ); pObj.Event[GML_EVENT_KEYPRESS_NUM_DOT ] = true; }
if( _pObjectStorage.KeyPressed_NUM_DIV ) { pObj.ObjKeyPressed[GML_EVENT_KEYPRESS_NUM_DIV ] = (_pObjectStorage.KeyPressed_NUM_DIV ); pObj.Event[GML_EVENT_KEYPRESS_NUM_DIV ] = true; }
+ // @endif
// Keyboard (key down) events
+ // @if eventType("Keyboard")
if( _pObjectStorage.Key_NOKEY) { pObj.ObjKeyDown[GML_EVENT_KEYBOARD_NOKEY] = (_pObjectStorage.Key_NOKEY); pObj.Event[GML_EVENT_KEYBOARD_NOKEY] = true; }
if( _pObjectStorage.Key_ANYKEY) { pObj.ObjKeyDown[GML_EVENT_KEYBOARD_ANYKEY] = (_pObjectStorage.Key_ANYKEY); pObj.Event[GML_EVENT_KEYBOARD_ANYKEY] = true; }
if( _pObjectStorage.Key_BACKSPACE) { pObj.ObjKeyDown[GML_EVENT_KEYBOARD_BACKSPACE] = (_pObjectStorage.Key_BACKSPACE); pObj.Event[GML_EVENT_KEYBOARD_BACKSPACE] = true; }
@@ -472,10 +497,12 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) {
if( _pObjectStorage.Key_NUM_MINUS) { pObj.ObjKeyDown[GML_EVENT_KEYBOARD_NUM_MINUS] = (_pObjectStorage.Key_NUM_MINUS); pObj.Event[GML_EVENT_KEYBOARD_NUM_MINUS] = true; }
if( _pObjectStorage.Key_NUM_DOT ) { pObj.ObjKeyDown[GML_EVENT_KEYBOARD_NUM_DOT ] = (_pObjectStorage.Key_NUM_DOT ); pObj.Event[GML_EVENT_KEYBOARD_NUM_DOT ] = true; }
if( _pObjectStorage.Key_NUM_DIV ) { pObj.ObjKeyDown[GML_EVENT_KEYBOARD_NUM_DIV ] = (_pObjectStorage.Key_NUM_DIV ); pObj.Event[GML_EVENT_KEYBOARD_NUM_DIV ] = true; }
+ // @endif
// Key Released events
+ // @if eventType("KeyRelease")
if( _pObjectStorage.KeyReleased_NOKEY) { pObj.ObjKeyReleased[GML_EVENT_KEYRELEASE_NOKEY] = (_pObjectStorage.KeyReleased_NOKEY); pObj.Event[GML_EVENT_KEYRELEASE_NOKEY] = true; }
if( _pObjectStorage.KeyReleased_ANYKEY) { pObj.ObjKeyReleased[GML_EVENT_KEYRELEASE_ANYKEY] = (_pObjectStorage.KeyReleased_ANYKEY); pObj.Event[GML_EVENT_KEYRELEASE_ANYKEY] = true; }
if( _pObjectStorage.KeyReleased_BACKSPACE) { pObj.ObjKeyReleased[GML_EVENT_KEYRELEASE_BACKSPACE] = (_pObjectStorage.KeyReleased_BACKSPACE); pObj.Event[GML_EVENT_KEYRELEASE_BACKSPACE] = true; }
@@ -567,13 +594,15 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) {
if( _pObjectStorage.KeyReleased_NUM_MINUS) { pObj.ObjKeyReleased[GML_EVENT_KEYRELEASE_NUM_MINUS] = (_pObjectStorage.KeyReleased_NUM_MINUS); pObj.Event[GML_EVENT_KEYRELEASE_NUM_MINUS] = true; }
if( _pObjectStorage.KeyReleased_NUM_DOT ) { pObj.ObjKeyReleased[GML_EVENT_KEYRELEASE_NUM_DOT ] = (_pObjectStorage.KeyReleased_NUM_DOT ); pObj.Event[GML_EVENT_KEYRELEASE_NUM_DOT ] = true; }
if( _pObjectStorage.KeyReleased_NUM_DIV ) { pObj.ObjKeyReleased[GML_EVENT_KEYRELEASE_NUM_DIV ] = (_pObjectStorage.KeyReleased_NUM_DIV ); pObj.Event[GML_EVENT_KEYRELEASE_NUM_DIV ] = true; }
+ // @endif
// Triggers...
- var i = 0;
+ // @if eventType("Trigger")
if( _pObjectStorage.TriggerEvents != undefined )
{
+ var i = 0;
while (i < _pObjectStorage.TriggerEvents.length)
{
var key = parseInt(_pObjectStorage.TriggerEvents[i]) + 1; // get the object ID (no trigger 0 here)
@@ -592,13 +621,15 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) {
i += 2;
}
}
+ // @endif
// Collisions...
- i = 0;
+ // @if eventType("Collision")
if( _pObjectStorage.CollisionEvents != undefined )
{
+ var i = 0;
while (i < _pObjectStorage.CollisionEvents.length)
{
pObj.Event[EVENT_COLLISION] = true;
@@ -614,8 +645,10 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) {
i += 2;
}
}
+ // @endif
// Physics data
+ // @if feature("physics")
if (_pObjectStorage.physicsObject != undefined) {
pObj.PhysicsData.physicsObject = _pObjectStorage.physicsObject;
@@ -631,6 +664,7 @@ function CreateObjectFromStorage( _ID, _pObjectStorage ) {
pObj.PhysicsData.physicsKinematic = _pObjectStorage.physicsKinematic;
pObj.PhysicsData.physicsShapeVertices = _pObjectStorage.physicsShapeVertices;
}
+ // @endif physics
}
return pObj;
}
@@ -701,12 +735,19 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_
case EVENT_ALARM: done = false; break; // Shouldn't get called directly
case EVENT_STEP: done = false; break;
case EVENT_COLLISION: if (this.Collisions[index]) this.Collisions[index].m_pFunction(_pInst, _pOther); break;
+ // @if eventType("Keyboard")
case EVENT_KEYBOARD: if (this.ObjKeyDown[_event | index]) this.ObjKeyDown[_event | index](_pInst, _pOther); else done = false; break;
- case EVENT_MOUSE: done = false; break; // Shouldn't get called directly
+ // @endif
+ case EVENT_MOUSE: done = false; break; // Shouldn't get called directly
case EVENT_OTHER: done = false; break; // Shouldn't get called directly
case EVENT_DRAW: if (this.DrawEvent) this.DrawEvent(_pInst, _pOther); else done = false; break;
+ // @if eventType("KeyPress")
case EVENT_KEYPRESS: if (this.ObjKeyPressed[_event | index]) this.ObjKeyPressed[_event | index](_pInst, _pOther); else done = false; break;
- case EVENT_KEYRELEASE: if (this.ObjKeyReleased[_event | index]) this.ObjKeyReleased[_event | index](_pInst, _pOther); else done = false; break;
+ // @endif
+ // @if eventType("KeyRelease")
+ case EVENT_KEYRELEASE: if (this.ObjKeyReleased[_event | index]) this.ObjKeyReleased[_event | index](_pInst, _pOther); else done = false; break;
+ // @endif
+ // @if eventType("Trigger")
case EVENT_TRIGGER: if (this.Triggers[_event | index])
{
var pTriggerEvent = this.Triggers[_event | index]; // 1st get the trigger event block
@@ -718,6 +759,7 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_
}
}
break;
+ // @endif trigger
case EVENT_DRAW_GUI: if (this.DrawGUI) this.DrawGUI(_pInst, _pOther); else done = false; break;
case EVENT_DRAW_BEGIN: if (this.DrawEventBegin) this.DrawEventBegin(_pInst, _pOther); else done = false; break;
@@ -732,8 +774,12 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_
case EVENT_STEP_NORMAL: if (this.StepNormalEvent) this.StepNormalEvent(_pInst, _pOther); else done = false; break;
case EVENT_STEP_END: if (this.StepEndEvent) this.StepEndEvent(_pInst, _pOther); else done = false; break;
- case EVENT_OTHER_OUTSIDE: if (this.OutsideEvent) this.OutsideEvent(_pInst, _pOther); else done = false; break;
+ // @if event("OutsideEvent")
+ case EVENT_OTHER_OUTSIDE: if (this.OutsideEvent) this.OutsideEvent(_pInst, _pOther); else done = false; break;
+ // @endif
+ // @if event("BoundaryEvent")
case EVENT_OTHER_BOUNDARY: if (this.BoundaryEvent) this.BoundaryEvent(_pInst, _pOther); else done = false; break;
+ // @endif
case EVENT_OTHER_STARTGAME: if (this.StartGameEvent) this.StartGameEvent(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_ENDGAME: if (this.EndGameEvent) this.EndGameEvent(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_STARTROOM: if (this.StartRoomEvent) this.StartRoomEvent(_pInst, _pOther); else done = false; break;
@@ -743,6 +789,7 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_
case EVENT_OTHER_ENDOFPATH: if (this.EndOfPathEvent) this.EndOfPathEvent(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_NOHEALTH: if (this.NoHealthEvent) this.NoHealthEvent(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_CLOSEBUTTON: if (this.CloseButtonEvent) this.CloseButtonEvent(_pInst, _pOther); else done = false; break;
+ // @if event("OutsideView*")
case EVENT_OTHER_OUTSIDE_VIEW0: if (this.OutsideView0Event) this.OutsideView0Event(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_OUTSIDE_VIEW1: if (this.OutsideView1Event) this.OutsideView1Event(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_OUTSIDE_VIEW2: if (this.OutsideView2Event) this.OutsideView2Event(_pInst, _pOther); else done = false; break;
@@ -751,6 +798,8 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_
case EVENT_OTHER_OUTSIDE_VIEW5: if (this.OutsideView5Event) this.OutsideView5Event(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_OUTSIDE_VIEW6: if (this.OutsideView6Event) this.OutsideView6Event(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_OUTSIDE_VIEW7: if (this.OutsideView7Event) this.OutsideView7Event(_pInst, _pOther); else done = false; break;
+ // @endif
+ // @if event("BoundaryView*")
case EVENT_OTHER_BOUNDARY_VIEW0: if (this.BoundaryView0Event) this.BoundaryView0Event(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_BOUNDARY_VIEW1: if (this.BoundaryView1Event) this.BoundaryView1Event(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_BOUNDARY_VIEW2: if (this.BoundaryView2Event) this.BoundaryView2Event(_pInst, _pOther); else done = false; break;
@@ -759,6 +808,7 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_
case EVENT_OTHER_BOUNDARY_VIEW5: if (this.BoundaryView5Event) this.BoundaryView5Event(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_BOUNDARY_VIEW6: if (this.BoundaryView6Event) this.BoundaryView6Event(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_BOUNDARY_VIEW7: if (this.BoundaryView7Event) this.BoundaryView7Event(_pInst, _pOther); else done = false; break;
+ // @endif
case EVENT_OTHER_ANIMATIONUPDATE: if (this.AnimationUpdateEvent) this.AnimationUpdateEvent(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_ANIMATIONEVENT: if (this.AnimationEventEvent) this.AnimationEventEvent(_pInst, _pOther); else done = false; break;
@@ -772,14 +822,17 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_
case EVENT_OTHER_PUSH_NOTIFICATION: if( this.PushNotificationEvent) this.PushNotificationEvent( _pInst, _pOther); else done =false; break;
case EVENT_OTHER_ASYNC_SAVE_LOAD: if( this.AsyncSaveLoadEvent) this.AsyncSaveLoadEvent( _pInst, _pOther); else done =false; break;
case EVENT_OTHER_NETWORKING: if( this.NetworkingEvent) this.NetworkingEvent( _pInst, _pOther); else done =false; break;
+ // @if feature("audio")
case EVENT_OTHER_AUDIO_PLAYBACK: if (this.AudioPlaybackEvent) this.AudioPlaybackEvent( _pInst, _pOther); else done = false; break;
case EVENT_OTHER_AUDIO_PLAYBACK_ENDED: if (this.AudioPlaybackEndedEvent) this.AudioPlaybackEndedEvent( _pInst, _pOther); else done = false; break;
case EVENT_OTHER_AUDIO_RECORDING: if (this.AudioRecordingEvent) this.AudioRecordingEvent( _pInst, _pOther); else done = false; break;
+ // @endif audio
case EVENT_OTHER_SYSTEM_EVENT: if (this.SystemEvent) this.SystemEvent(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_BROADCAST_MESSAGE: if (this.BroadcastMessageEvent) this.BroadcastMessageEvent(_pInst, _pOther); else done = false; break;
- case EVENT_OTHER_USER0: if (this.UserEvent0) this.UserEvent0(_pInst, _pOther); else done = false; break;
+ // @if event("UserEvent*")
+ case EVENT_OTHER_USER0: if (this.UserEvent0) this.UserEvent0(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_USER1: if (this.UserEvent1) this.UserEvent1(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_USER2: if (this.UserEvent2) this.UserEvent2(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_USER3: if (this.UserEvent3) this.UserEvent3(_pInst, _pOther); else done = false; break;
@@ -795,9 +848,11 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_
case EVENT_OTHER_USER13: if (this.UserEvent13) this.UserEvent13(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_USER14: if (this.UserEvent14) this.UserEvent14(_pInst, _pOther); else done = false; break;
case EVENT_OTHER_USER15: if (this.UserEvent15) this.UserEvent15(_pInst, _pOther); else done = false; break;
+ // @endif
- case EVENT_MOUSE_NOBUTTON: if (this.NoButtonPressed) this.NoButtonPressed(_pInst, _pOther); else done = false; break;
+ // @if eventType("Mouse")
+ case EVENT_MOUSE_NOBUTTON: if (this.NoButtonPressed) this.NoButtonPressed(_pInst, _pOther); else done = false; break;
case EVENT_MOUSE_LBUTTON_DOWN: if (this.LeftButtonDown) this.LeftButtonDown(_pInst, _pOther); else done = false; break;
case EVENT_MOUSE_RBUTTON_DOWN: if (this.RightButtonDown) this.RightButtonDown(_pInst, _pOther); else done = false; break;
case EVENT_MOUSE_MBUTTON_DOWN: if (this.MiddleButtonDown) this.MiddleButtonDown(_pInst, _pOther); else done = false; break;
@@ -822,8 +877,10 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_
case EVENT_MOUSE_ENTER: if (this.MouseEnter) this.MouseEnter(_pInst, _pOther); else done = false; break;
case EVENT_MOUSE_LEAVE: if (this.MouseLeave) this.MouseLeave(_pInst, _pOther); else done = false; break;
+ // @endif
- case EVENT_GESTURE_TAP: if (this.GestureTapEvent) this.GestureTapEvent(_pInst, _pOther); else done = false; break;
+ // @if eventType("Gesture")
+ case EVENT_GESTURE_TAP: if (this.GestureTapEvent) this.GestureTapEvent(_pInst, _pOther); else done = false; break;
case EVENT_GESTURE_DOUBLE_TAP: if (this.GestureDoubleTapEvent) this.GestureDoubleTapEvent(_pInst, _pOther); else done = false; break;
case EVENT_GESTURE_DRAG_START: if (this.GestureDragStartEvent) this.GestureDragStartEvent(_pInst, _pOther); else done = false; break;
case EVENT_GESTURE_DRAG_MOVE: if (this.GestureDragMoveEvent) this.GestureDragMoveEvent(_pInst, _pOther); else done = false; break;
@@ -836,8 +893,10 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_
case EVENT_GESTURE_GLOBAL_DRAG_MOVE: if (this.GestureGlobalDragMoveEvent) this.GestureGlobalDragMoveEvent(_pInst, _pOther); else done = false; break;
case EVENT_GESTURE_GLOBAL_DRAG_END: if (this.GestureGlobalDragEndEvent) this.GestureGlobalDragEndEvent(_pInst, _pOther); else done = false; break;
case EVENT_GESTURE_GLOBAL_FLICK: if (this.GestureGlobalFlickEvent) this.GestureGlobalFlickEvent(_pInst, _pOther); else done = false; break;
+ // @endif
- case EVENT_ALARM_0: if (this.ObjAlarm[0] != null) this.ObjAlarm[0](_pInst, _pOther); else done = false; break;
+ // @if eventType("Alarm")
+ case EVENT_ALARM_0: if (this.ObjAlarm[0] != null) this.ObjAlarm[0](_pInst, _pOther); else done = false; break;
case EVENT_ALARM_1: if (this.ObjAlarm[1] != null) this.ObjAlarm[1](_pInst, _pOther); else done = false; break;
case EVENT_ALARM_2: if (this.ObjAlarm[2] != null) this.ObjAlarm[2](_pInst, _pOther); else done = false; break;
case EVENT_ALARM_3: if (this.ObjAlarm[3] != null) this.ObjAlarm[3](_pInst, _pOther); else done = false; break;
@@ -849,6 +908,7 @@ yyObject.prototype.PerformEvent = function (_event, index, _pInst, _pOther, _is_
case EVENT_ALARM_9: if (this.ObjAlarm[9] != null) this.ObjAlarm[9](_pInst, _pOther); else done = false; break;
case EVENT_ALARM_10: if (this.ObjAlarm[10] != null) this.ObjAlarm[10](_pInst, _pOther); else done = false; break;
case EVENT_ALARM_11: if (this.ObjAlarm[11] != null) this.ObjAlarm[11](_pInst, _pOther); else done = false; break;
+ // @endif
default:
done = false;
@@ -914,6 +974,7 @@ function ConvertEvent(_event)
case EVENT_OTHER_ENDOFPATH: return GML_EVENT_OTHER;
case EVENT_OTHER_NOHEALTH: return GML_EVENT_OTHER;
case EVENT_OTHER_CLOSEBUTTON: return GML_EVENT_OTHER;
+ // @if event("OutsideView*")
case EVENT_OTHER_OUTSIDE_VIEW0: return GML_EVENT_OTHER;
case EVENT_OTHER_OUTSIDE_VIEW1: return GML_EVENT_OTHER;
case EVENT_OTHER_OUTSIDE_VIEW2: return GML_EVENT_OTHER;
@@ -922,6 +983,8 @@ function ConvertEvent(_event)
case EVENT_OTHER_OUTSIDE_VIEW5: return GML_EVENT_OTHER;
case EVENT_OTHER_OUTSIDE_VIEW6: return GML_EVENT_OTHER;
case EVENT_OTHER_OUTSIDE_VIEW7: return GML_EVENT_OTHER;
+ // @endif
+ // @if event("BoundaryView*")
case EVENT_OTHER_BOUNDARY_VIEW0: return GML_EVENT_OTHER;
case EVENT_OTHER_BOUNDARY_VIEW1: return GML_EVENT_OTHER;
case EVENT_OTHER_BOUNDARY_VIEW2: return GML_EVENT_OTHER;
@@ -930,6 +993,7 @@ function ConvertEvent(_event)
case EVENT_OTHER_BOUNDARY_VIEW5: return GML_EVENT_OTHER;
case EVENT_OTHER_BOUNDARY_VIEW6: return GML_EVENT_OTHER;
case EVENT_OTHER_BOUNDARY_VIEW7: return GML_EVENT_OTHER;
+ // @endif
case EVENT_OTHER_ANIMATIONUPDATE: return GML_EVENT_OTHER;
case EVENT_OTHER_ANIMATIONEVENT: return GML_EVENT_OTHER;
@@ -943,11 +1007,14 @@ function ConvertEvent(_event)
case EVENT_OTHER_PUSH_NOTIFICATION: return GML_EVENT_OTHER;
case EVENT_OTHER_ASYNC_SAVE_LOAD: return GML_EVENT_OTHER;
case EVENT_OTHER_NETWORKING: return GML_EVENT_OTHER;
+ // @if feature("audio")
case EVENT_OTHER_AUDIO_PLAYBACK: return GML_EVENT_OTHER;
case EVENT_OTHER_AUDIO_PLAYBACK_ENDED: return GML_EVENT_OTHER;
case EVENT_OTHER_AUDIO_RECORDING: return GML_EVENT_OTHER;
+ // @endif audio
case EVENT_OTHER_SYSTEM_EVENT: return GML_EVENT_OTHER;
+ // @if event("UserEvent*")
case EVENT_OTHER_USER0: return GML_EVENT_OTHER;
case EVENT_OTHER_USER1: return GML_EVENT_OTHER;
case EVENT_OTHER_USER2: return GML_EVENT_OTHER;
@@ -964,8 +1031,10 @@ function ConvertEvent(_event)
case EVENT_OTHER_USER13: return GML_EVENT_OTHER;
case EVENT_OTHER_USER14: return GML_EVENT_OTHER;
case EVENT_OTHER_USER15: return GML_EVENT_OTHER;
+ // @endif
+ // @if eventType("Mouse")
case EVENT_MOUSE_NOBUTTON: return GML_EVENT_MOUSE;
case EVENT_MOUSE_LBUTTON_DOWN: return GML_EVENT_MOUSE;
case EVENT_MOUSE_RBUTTON_DOWN: return GML_EVENT_MOUSE;
@@ -991,7 +1060,9 @@ function ConvertEvent(_event)
case EVENT_MOUSE_ENTER: return GML_EVENT_MOUSE;
case EVENT_MOUSE_LEAVE: return GML_EVENT_MOUSE;
+ // @endif
+ // @if eventType("Gesture")
case EVENT_GESTURE_TAP: return GML_EVENT_GESTURE;
case EVENT_GESTURE_DOUBLE_TAP: return GML_EVENT_GESTURE;
case EVENT_GESTURE_DRAG_START: return GML_EVENT_GESTURE;
@@ -1005,7 +1076,9 @@ function ConvertEvent(_event)
case EVENT_GESTURE_GLOBAL_DRAG_MOVE: return GML_EVENT_GESTURE;
case EVENT_GESTURE_GLOBAL_DRAG_END: return GML_EVENT_GESTURE;
case EVENT_GESTURE_GLOBAL_FLICK: return GML_EVENT_GESTURE;
+ // @endif
+ // @if eventType("Alarm")
case EVENT_ALARM_0: return GML_EVENT_ALARM;
case EVENT_ALARM_1: return GML_EVENT_ALARM;
case EVENT_ALARM_2: return GML_EVENT_ALARM;
@@ -1018,6 +1091,7 @@ function ConvertEvent(_event)
case EVENT_ALARM_9: return GML_EVENT_ALARM;
case EVENT_ALARM_10: return GML_EVENT_ALARM;
case EVENT_ALARM_11: return GML_EVENT_ALARM;
+ // @endif
default:
return -1; // who knows
@@ -1088,6 +1162,7 @@ function ConvertSubEvent(_event, _subevent)
case EVENT_OTHER_ENDOFPATH: return GML_EVENT_OTHER_ENDOFPATH;
case EVENT_OTHER_NOHEALTH: return GML_EVENT_OTHER_NOHEALTH;
case EVENT_OTHER_CLOSEBUTTON: return GML_EVENT_OTHER_CLOSEBUTTON;
+ // @if event("OutsideView*")
case EVENT_OTHER_OUTSIDE_VIEW0: return GML_EVENT_OTHER_OUTSIDE_VIEW0;
case EVENT_OTHER_OUTSIDE_VIEW1: return GML_EVENT_OTHER_OUTSIDE_VIEW1;
case EVENT_OTHER_OUTSIDE_VIEW2: return GML_EVENT_OTHER_OUTSIDE_VIEW2;
@@ -1096,6 +1171,8 @@ function ConvertSubEvent(_event, _subevent)
case EVENT_OTHER_OUTSIDE_VIEW5: return GML_EVENT_OTHER_OUTSIDE_VIEW5;
case EVENT_OTHER_OUTSIDE_VIEW6: return GML_EVENT_OTHER_OUTSIDE_VIEW6;
case EVENT_OTHER_OUTSIDE_VIEW7: return GML_EVENT_OTHER_OUTSIDE_VIEW7;
+ // @endif
+ // @if event("BoundaryView*")
case EVENT_OTHER_BOUNDARY_VIEW0: return GML_EVENT_OTHER_BOUNDARY_VIEW0;
case EVENT_OTHER_BOUNDARY_VIEW1: return GML_EVENT_OTHER_BOUNDARY_VIEW1;
case EVENT_OTHER_BOUNDARY_VIEW2: return GML_EVENT_OTHER_BOUNDARY_VIEW2;
@@ -1104,6 +1181,7 @@ function ConvertSubEvent(_event, _subevent)
case EVENT_OTHER_BOUNDARY_VIEW5: return GML_EVENT_OTHER_BOUNDARY_VIEW5;
case EVENT_OTHER_BOUNDARY_VIEW6: return GML_EVENT_OTHER_BOUNDARY_VIEW6;
case EVENT_OTHER_BOUNDARY_VIEW7: return GML_EVENT_OTHER_BOUNDARY_VIEW7;
+ // @endif
case EVENT_OTHER_ANIMATIONUPDATE: return GML_EVENT_OTHER_ANIMATIONUPDATE;
case EVENT_OTHER_ANIMATIONEVENT: return GML_EVENT_OTHER_ANIMATIONEVENT;
@@ -1117,13 +1195,16 @@ function ConvertSubEvent(_event, _subevent)
case EVENT_OTHER_PUSH_NOTIFICATION: return GML_EVENT_OTHER_PUSH_NOTIFICATION;
case EVENT_OTHER_ASYNC_SAVE_LOAD: return GML_EVENT_OTHER_ASYNC_SAVE_LOAD;
case EVENT_OTHER_NETWORKING: return GML_EVENT_OTHER_NETWORKING;
+ // @if feature("audio")
case EVENT_OTHER_AUDIO_PLAYBACK: return GML_EVENT_OTHER_AUDIO_PLAYBACK;
case EVENT_OTHER_AUDIO_PLAYBACK_ENDED: return GML_EVENT_OTHER_AUDIO_PLAYBACK_ENDED;
case EVENT_OTHER_AUDIO_RECORDING: return EVENT_OTHER_AUDIO_RECORDING;
+ // @endif audio
case EVENT_OTHER_SYSTEM_EVENT: return GML_EVENT_OTHER_SYSTEM_EVENT;
case EVENT_OTHER_BROADCAST_MESSAGE: return GML_EVENT_OTHER_BROADCAST_MESSAGE;
+ // @if event("UserEvent*")
case EVENT_OTHER_USER0: return GML_EVENT_OTHER_USER0;
case EVENT_OTHER_USER1: return GML_EVENT_OTHER_USER1;
case EVENT_OTHER_USER2: return GML_EVENT_OTHER_USER2;
@@ -1140,8 +1221,10 @@ function ConvertSubEvent(_event, _subevent)
case EVENT_OTHER_USER13: return GML_EVENT_OTHER_USER13;
case EVENT_OTHER_USER14: return GML_EVENT_OTHER_USER14;
case EVENT_OTHER_USER15: return GML_EVENT_OTHER_USER15;
+ // @endif
+ // @if eventType("Mouse")
case EVENT_MOUSE_NOBUTTON: return GML_MOUSE_NoButton;
case EVENT_MOUSE_LBUTTON_DOWN: return GML_MOUSE_LeftButton;
case EVENT_MOUSE_RBUTTON_DOWN: return GML_MOUSE_RightButton;
@@ -1167,7 +1250,9 @@ function ConvertSubEvent(_event, _subevent)
case EVENT_MOUSE_ENTER: return GML_MOUSE_MOUSEEnter;
case EVENT_MOUSE_LEAVE: return GML_MOUSE_MOUSELeave;
+ // @endif
+ // @if eventType("Gesture")
case EVENT_GESTURE_TAP: return GML_EVENT_GESTURE_TAP;
case EVENT_GESTURE_DOUBLE_TAP: return GML_EVENT_GESTURE_DOUBLE_TAP;
case EVENT_GESTURE_DRAG_START: return GML_EVENT_GESTURE_DRAG_START;
@@ -1181,7 +1266,9 @@ function ConvertSubEvent(_event, _subevent)
case EVENT_GESTURE_GLOBAL_DRAG_MOVE: return GML_EVENT_GESTURE_GLOBAL_DRAG_MOVE;
case EVENT_GESTURE_GLOBAL_DRAG_END: return GML_EVENT_GESTURE_GLOBAL_DRAG_END;
case EVENT_GESTURE_GLOBAL_FLICK: return GML_EVENT_GESTURE_GLOBAL_FLICK;
+ // @endif
+ // @if eventType("Alarm")
case EVENT_ALARM_0: return 0;
case EVENT_ALARM_1: return 1;
case EVENT_ALARM_2: return 2;
@@ -1194,6 +1281,7 @@ function ConvertSubEvent(_event, _subevent)
case EVENT_ALARM_9: return 9;
case EVENT_ALARM_10: return 10;
case EVENT_ALARM_11: return 11;
+ // @endif
default:
return 0; // who knows
diff --git a/scripts/yyParticle.js b/scripts/yyParticle.js
index b490b1e5..7456cf05 100644
--- a/scripts/yyParticle.js
+++ b/scripts/yyParticle.js
@@ -65,6 +65,7 @@ var persistentsystemlayernames = [];
/// like. We will discuss the settings below.
///
// #############################################################################################
+// @if feature("particles")
/**@constructor*/
function yyParticleType()
{
@@ -448,6 +449,7 @@ CParticleSystem.prototype.MakeInstance = function (_layerID, _persistent, _pPart
return ps;
};
+// @endif particles
// #############################################################################################
/// Function:
@@ -2978,7 +2980,9 @@ function DrawParticle(_pPartSys, _pParticle, _xoff, _yoff, _color, _alpha)
// Fix for null particle HTML5 crash - happens when particle type is destroyed but emitter is still alive
if (pParType === null) return;
+ // @if feature("sprites")
spr = g_pSpriteManager.Get( pParType.sprite );
+ // @endif sprites
if( spr == null )
{
var shape = pParType.shape;
diff --git a/scripts/yyPath.js b/scripts/yyPath.js
index c755ee54..8f5af24e 100644
--- a/scripts/yyPath.js
+++ b/scripts/yyPath.js
@@ -15,6 +15,7 @@
//
// **********************************************************************************************************************
+// @if feature("paths")
var P_STRAIGHT = 0,
P_CURVED = 1;
@@ -869,3 +870,4 @@ yyPathManager.prototype.List = function () {
}
return ids;
};
+// @endif
diff --git a/scripts/yyPlayfield.js b/scripts/yyPlayfield.js
index c952c9e6..e6e0f386 100644
--- a/scripts/yyPlayfield.js
+++ b/scripts/yyPlayfield.js
@@ -14,225 +14,3 @@
// 17/05/2011 V1.0 MJD 1st version
//
// **********************************************************************************************************************
-
-
-// #############################################################################################
-/// Function:
-/// Create a new
-///
-// #############################################################################################
-/**@constructor*/
-function yyPlayfield( _depth )
-{
- this.depth = _depth;
- this.visible = true;
- this.Tiles = new yyList();
-}
-
-// #############################################################################################
-/// Function:
-/// Create a tile from its "loaded" data
-///
-///
-/// In: Tile data
-///
-// #############################################################################################
-yyPlayfield.prototype.Add = function (_pTile) {
- this.Tiles.Add(_pTile);
-};
-
-
-// #############################################################################################
-/// Function:
-/// Delete a tile from the
-///
-///
-/// In: Tile data
-///
-// #############################################################################################
-yyPlayfield.prototype.Delete = function (_pTile) {
- this.Tiles.DeleteItem(_pTile);
-};
-
-// #############################################################################################
-/// Function:
-/// Draw all the tiles in this playfield
-///
-// #############################################################################################
-yyPlayfield.prototype.Draw = function (_rect) {
-
- if (!this.visible) {
- return;
- }
-
- var pool = this.Tiles.pool;
- for (var index = 0; index < pool.length; index++)
- {
- var pTile = pool[index];
- if (pTile != null)
- {
- // Take into account the tile's scaling
- var xB = pTile.x + (pTile.xscale*pTile.w),
- yR = pTile.y + (pTile.yscale*pTile.h);
-
- var x1 = (pTile.x < xB) ? pTile.x : xB,
- x2 = (pTile.x > xB) ? pTile.x : xB,
- y1 = (pTile.y < yR) ? pTile.y : yR,
- y2 = (pTile.y > yR) ? pTile.y : yR;
-
- if ((x1 <= _rect.right) && (y1 <= _rect.bottom) &&
- (x2 >= _rect.left) && (y2 >= _rect.top))
- {
- pTile.Draw();
- }
- }
- }
-};
-
-
-// #############################################################################################
-/// Function:
-/// Get the actual POOL of tiles
-///
-///
-/// Out:
-/// the pool.
-///
-// #############################################################################################
-yyPlayfield.prototype.GetPool = function () {
- return this.Tiles.pool;
-};
-
-
-
-
-
-
-
-// ##########################################################################################################################################################################################
-// ##########################################################################################################################################################################################
-/// Function:
-/// Create a playfield manager
-///
-// ##########################################################################################################################################################################################
-// ##########################################################################################################################################################################################
-/**@constructor*/
-function yyPlayfieldManager()
-{
- this.m_Playfields = new yyOList();
- this.m_NextIndex = -1;
-}
-
-
-// #############################################################################################
-/// Property:
-/// Find the playfield with the correct depth.
-///
-///
-/// In: Playfield depth
-///
-// #############################################################################################
-yyPlayfieldManager.prototype.Get = function (_depth) {
- var pPlayfield;
-
- // Find playfield at tyile depth...
- for (var index = 0; index < this.m_Playfields.count; index++)
- {
- pPlayfield = this.m_Playfields.Get(index);
- if (pPlayfield.depth == _depth) return pPlayfield;
- }
- return null;
-};
-
-// #############################################################################################
-/// Property:
-/// Delete the playfield with the depth provided.
-///
-///
-/// In: Playfield depth
-///
-// #############################################################################################
-yyPlayfieldManager.prototype.Delete = function (_depth) {
- var pPlayfield = this.Get(_depth);
- if (pPlayfield)
- {
- this.m_Playfields.Delete(pPlayfield);
- }
-};
-
-// #############################################################################################
-/// Function:
-/// Create a tile from its "loaded" data
-///
-///
-/// In: Tile data
-///
-// #############################################################################################
-yyPlayfieldManager.prototype.Add = function (_pTile) {
- var pPlayfield;
-
- // Find playfield at tyile depth...
- pPlayfield = this.Get(_pTile.depth);
- if(!pPlayfield)
- {
- pPlayfield = new yyPlayfield(_pTile.depth);
- this.m_Playfields.Add(pPlayfield);
- }
- pPlayfield.Add(_pTile);
-};
-
-// #############################################################################################
-/// Function:
-/// Create a tile from its "loaded" data
-///
-///
-/// In: Tile data
-///
-// #############################################################################################
-yyPlayfieldManager.prototype.DeleteTile = function (_pTile) {
- // Find playfield at tyile depth...
- var pPlayfield = this.Get(_pTile.depth);
- if (pPlayfield)
- {
- pPlayfield.Delete(_pTile);
- }
-};
-
-
-// #############################################################################################
-/// Function:
-/// Create a tile from its "loaded" data
-///
-///
-/// In: Tile data
-///
-// #############################################################################################
-yyPlayfieldManager.prototype.GetFirst = function () {
- this.m_NextIndex = this.m_Playfields.length-1;
- return this.m_Playfields.Get(this.m_NextIndex);
-};
-
-// #############################################################################################
-/// Function:
-/// Create a tile from its "loaded" data
-///
-///
-/// In: Tile data
-///
-// #############################################################################################
-yyPlayfieldManager.prototype.GetNext = function () {
- this.m_NextIndex--;
- if( this.m_NextIndex<0 ) return null;
- return this.m_Playfields.Get(this.m_NextIndex);
-};
-
-
-// #############################################################################################
-/// Property:
-/// Hide/Show a playfield
-///
-// #############################################################################################
-yyPlayfieldManager.prototype.SetPlayfieldVisibility = function (_depth, _vis) {
- var pPlayfield = this.Get(_depth);
- if (pPlayfield) pPlayfield.visible = (_vis >= 0.5);
-};
diff --git a/scripts/yyQueue.js b/scripts/yyQueue.js
index 1188f82d..2aa7f5d9 100644
--- a/scripts/yyQueue.js
+++ b/scripts/yyQueue.js
@@ -14,6 +14,7 @@
//
// **********************************************************************************************************************
+// @if function("mp_grid_path")
// #############################################################################################
/// Function:
/// Create a new QUEUE
@@ -98,4 +99,4 @@ yyQueue.prototype.peek = function () {
return undefined;
}
};
-
+// @endif mp
diff --git a/scripts/yyRoom.js b/scripts/yyRoom.js
index 90b02470..d9a4909b 100644
--- a/scripts/yyRoom.js
+++ b/scripts/yyRoom.js
@@ -70,9 +70,6 @@ yyRoom.prototype.Init = function () {
//this.m_NewInstances = []; // When a new instance is added, its added to the layers at the end of the event
//this.m_ParticleChanges = []; // When a particle system changes depth (this needs to be global because it can be called before there is a room)
- this.m_NumTiles = 0;
- this.m_Tiles = [];
- this.m_PlayfieldManager = new yyPlayfieldManager();
this.m_Views = [];
this.m_Marked = [];
@@ -185,6 +182,7 @@ yyRoom.prototype.CloneStorage = function (_pStorage) {
}
// Physics world
+ // @if feature("physics")
if ( _pStorage.physicsWorld )
{
this.m_pStorage.physicsWorld = _pStorage.physicsWorld;
@@ -196,6 +194,7 @@ yyRoom.prototype.CloneStorage = function (_pStorage) {
this.m_pStorage.physicsGravityY = _pStorage.physicsGravityY;
this.m_pStorage.physicsPixToMeters = _pStorage.physicsPixToMeters;
}
+ // @endif physics world storage clone
// 1.x backgrounds
for (var i = 0; i < _pStorage.backgrounds.length; i++)
@@ -283,30 +282,6 @@ yyRoom.prototype.CloneStorage = function (_pStorage) {
};
}
}
-
- // Tiles
- this.m_pStorage.tiles = new Array(_pStorage.tiles.length);
- for (var i = 0; i < _pStorage.tiles.length; i++)
- {
- var sourceTile = _pStorage.tiles[i];
- if (sourceTile != null)
- {
- this.m_pStorage.tiles[i] = {
- x: sourceTile.x,
- y: sourceTile.y,
- index: sourceTile.index,
- xo: sourceTile.xo,
- yo: sourceTile.yo,
- w: sourceTile.w,
- h: sourceTile.h,
- depth: sourceTile.depth,
- id: sourceTile.id,
- scaleX: sourceTile.scaleX,
- scaleY: sourceTile.scaleY,
- colour: sourceTile.colour
- };
- }
- }
// Layers
this.m_pStorage.layers = new Array( _pStorage.layers.length );
@@ -332,18 +307,20 @@ yyRoom.prototype.CloneStorage = function (_pStorage) {
};
// Copy effect properties
+ // @if feature("layerEffects")
newLayer.effectProperties = new Array( sourceLayer.effectProperties.length );
var effectPropIdx;
for (effectPropIdx = 0; effectPropIdx < sourceLayer.effectProperties.length; effectPropIdx++)
{
- newLayer.EffectProperties[effectPropIdx] =
+ newLayer.effectProperties[effectPropIdx] =
{
type: sourceLayer.effectProperties[effectPropIdx].type,
name: sourceLayer.effectProperties[effectPropIdx].name,
value: sourceLayer.effectProperties[effectPropIdx].value
};
}
+ // @endif
// Type-specific properties
switch(sourceLayer.type)
@@ -514,21 +491,6 @@ yyRoom.prototype.CreateRoomFromStorage = function (_pRoomStorage)
this.SetPersistent(this.m_persistent);
this.m_Views = [];
-
- // Make Tiles
- this.m_NumTiles = 0;
- for (var index = 0; index < _pRoomStorage.tiles.length; index++)
- {
- var pTileStorage = _pRoomStorage.tiles[index];
- if (pTileStorage != null)
- {
- var pTile = CreateTileFromStorage(pTileStorage);
- this.m_PlayfieldManager.Add(pTile);
- this.m_Tiles[pTile.id] = pTile;
- this.m_NumTiles++;
- }
- }
-
if (_pRoomStorage.pCode != undefined) this.m_code = _pRoomStorage.pCode;
// Create views
@@ -551,22 +513,16 @@ yyRoom.prototype.CreateRoomFromStorage = function (_pRoomStorage)
///
///
// #############################################################################################
+// @if feature("physics")
yyRoom.prototype.BuildPhysicsWorld = function() {
// evaluates to true if value is not: null, undefined, NaN, empty string, 0, false
if (this.m_pStorage.physicsWorld) {
-
- if(g_isZeus)
- {
- this.m_pPhysicsWorld = new yyPhysicsWorld(this.m_pStorage.physicsPixToMeters, g_GameTimer.GetFPS());
- }
- else
- {
- this.m_pPhysicsWorld = new yyPhysicsWorld(this.m_pStorage.physicsPixToMeters, this.GetSpeed());
- }
+ this.m_pPhysicsWorld = new yyPhysicsWorld(this.m_pStorage.physicsPixToMeters, g_GameTimer.GetFPS());
this.m_pPhysicsWorld.SetGravity(this.m_pStorage.physicsGravityX, this.m_pStorage.physicsGravityY);
}
};
+// @endif BuildPhysicsWorld
// #############################################################################################
/// Function:
@@ -694,7 +650,9 @@ yyRoom.prototype.CreateInstance = function (_x, _y, _id, _objindex, _scaleX, _sc
g_pLayerManager.BuildElementRuntimeData(this, elandlay.layer, elandlay.element);
}
}
+ // @if feature("physics")
pinst.BuildPhysicsBody();
+ // @endif
// g_pLayerManager.AddInstance(this,pinst);
return pinst;
@@ -741,8 +699,10 @@ yyRoom.prototype.AddInstance = function (_x, _y, _id, _objindex, _overridedepth,
g_pLayerManager.BuildElementRuntimeData(this, elandlay.layer, elandlay.element);
}
}
-
+
+ // @if feature("physics")
pinst.BuildPhysicsBody();
+ // @endif
return pinst;
};
@@ -774,7 +734,9 @@ yyRoom.prototype.AddLayerInstance = function (_x, _y, _layer, _id, _objindex)
this.m_Active.Add(pinst);
g_pInstanceManager.Add(pinst);
+ // @if feature("physics")
pinst.BuildPhysicsBody();
+ // @endif
//this.m_NewInstances.push({ inst: pinst, type: 1, layer:_layer });
@@ -973,87 +935,6 @@ yyRoom.prototype.UpdateViews = function () {
}
}
}
- else if ((pView.visible) && (pView.objid >= 0))
- {
- // Find the pInstance to follow
- pInst = null;
- if (pView.objid < 100000)
- {
- // if they selected an OBJECT, then pick the 1st unmarked one!
- var pObj = g_pObjectManager.Get(pView.objid);
- if (pObj != null)
- {
- var pool = pObj.GetRPool();
- for (var o = 0; o < pool.length; o++)
- {
- pInst = pool[o];
- if (!pInst.marked) break; // if NOT marked, use this one!
- pInst = null; // makes sure we can tell we found one
- }
- }
-
- }
- else // pView object is an pInstance
- {
- pInst = g_pInstanceManager.Get(pView.objid);
- if (!pInst && pInst.marked) pInst = null;
- }
-
- // if we have an object to follow.... then follow it!
- if (pInst != null)
- {
- // Find the new position
- l = pView.worldx;
- t = pView.worldy;
- ix = pInst.x;
- iy = pInst.y;
-
- if (2 * pView.hborder >= pView.worldw)
- {
- l = ix - pView.worldw / 2;
- } else if (ix - pView.hborder < pView.worldx)
- {
- l = ix - pView.hborder;
- } else if (ix + pView.hborder > pView.worldx + pView.worldw)
- {
- l = ix + pView.hborder - pView.worldw;
- }
-
- if (2 * pView.vborder >= pView.worldh)
- {
- t = iy - pView.worldh / 2;
- } else if (iy - pView.vborder < pView.worldy)
- {
- t = iy - pView.vborder;
- } else if (iy + pView.vborder > pView.worldy + pView.worldh)
- {
- t = iy + pView.vborder - pView.worldh;
- }
-
-
- // Make sure it does not extend beyond the room
- if (l < 0) l = 0;
- if (l + pView.worldw > this.m_width) l = this.m_width - pView.worldw;
- if (t < 0) t = 0;
- if (t + pView.worldh > this.m_height) t = this.m_height - pView.worldh;
-
- // Restrict motion speed
- if (pView.hspeed >= 0)
- {
- if ((l < pView.worldx) && (pView.worldx - l > pView.hspeed)) l = pView.worldx - pView.hspeed;
- if ((l > pView.worldx) && (l - pView.worldx > pView.hspeed)) l = pView.worldx + pView.hspeed;
- }
- if (pView.vspeed >= 0)
- {
- if ((t < pView.worldy) && (pView.worldy - t > pView.vspeed)) t = pView.worldy - pView.vspeed;
- if ((t > pView.worldy) && (t - pView.worldy > pView.vspeed)) t = pView.worldy + pView.vspeed;
- }
- pView.worldx = l;
- pView.worldy = t;
-
- } //if (pInst != null)
-
- } // if((pView.visible) && (pView.objid>=0))
}
@@ -1108,6 +989,7 @@ yyRoom.prototype.DrawLayerInstanceElement = function(_rect,_layer,_el)
g_skeletonDrawInstance = null;
}
+ // @if feature("sprites")
else
{
@@ -1133,13 +1015,14 @@ yyRoom.prototype.DrawLayerInstanceElement = function(_rect,_layer,_el)
}
}
+ // @endif sprites
}
} // end if
}
};
yyRoom.prototype.DrawLayerOldTilemapElement = function(_rect,_layer,_el)
{
- //Don't have one of these in our project, so bit hard to test...
+/* //Don't have one of these in our project, so bit hard to test...
// LinkedList::iterator slabiter = _pOldTilemapEl->m_tiles.GetIterator();
// while (*slabiter != NULL)
@@ -1157,7 +1040,7 @@ yyRoom.prototype.DrawLayerOldTilemapElement = function(_rect,_layer,_el)
}
-/* {
+ {
CTileSlab* pSlab = *slabiter;
RTile* pTiles = pSlab->m_Tiles;
int numTiles = pSlab->m_nTilesUsed;
@@ -1217,6 +1100,7 @@ yyRoom.prototype.DrawLayerBackgroundElement = function(_rect,_layer,_el)
// Does this background have a sprite?
+ // @if feature("sprites")
if (sprite_exists(back.index))
{
// get sprite details
@@ -1239,6 +1123,7 @@ yyRoom.prototype.DrawLayerBackgroundElement = function(_rect,_layer,_el)
}
}
else
+ // @endif sprites
{
// Don't "just" clear - it doesn't respect the current viewport
var oldAlpha = g_GlobalAlpha;
@@ -1262,6 +1147,7 @@ yyRoom.prototype.DrawLayerBackgroundElement = function(_rect,_layer,_el)
// #############################################################################################
yyRoom.prototype.DrawLayerSpriteElement = function(_rect,_layer,_el)
{
+ // @if feature("sprites")
if (sprite_exists(_el.m_spriteIndex))
{
var pImage = g_pSpriteManager.Get( _el.m_spriteIndex );
@@ -1290,6 +1176,7 @@ yyRoom.prototype.DrawLayerSpriteElement = function(_rect,_layer,_el)
}
}
}
+ // @endif sprites
};
var g_DefaultCameraID = -1;
@@ -1694,6 +1581,7 @@ function draw_tile(_inst,_back,_tileindex,_frame,_x,_y)
yyRoom.prototype.DrawLayerTilemapElement = function(_rect,_layer,_el,_xpos,_ypos,_depth)
{
+ // @if feature("tilemaps")
if(background_exists(_el.m_backgroundIndex))
{
var backwidth = background_get_width(_el.m_backgroundIndex);
@@ -1801,6 +1689,7 @@ yyRoom.prototype.DrawLayerTilemapElement = function(_rect,_layer,_el,_xpos,_ypos
if(g_webGL)
{
+ // @if feature("gl")
for(var y=miny;y0)
pVerts.Current -= tilesinthisrun * 6;
-
+ // @endif
}
else
{
+ // @if feature("2d")
//Non Web-GL
for(var y=miny;y= 0)
{
var pSpr = g_pSpriteManager.Get(g_CurrentCursor);
@@ -3311,6 +3232,7 @@ yyRoom.prototype.DrawUserCursor = function () {
g_CurrentCursorFrame++;
if (g_CurrentCursorFrame > pSpr.numb) g_CurrentCursorFrame -= pSpr.numb;
}
+ // @endif sprites
};
// #############################################################################################
@@ -3359,6 +3281,7 @@ yyRoom.prototype.ClearEffectLayerIDs = function () {
function ExecuteEffectFunction(_pLayer, _funcname, _etype, _enumb)
{
+ // @if feature("layerEffects")
if (_pLayer === null)
return;
@@ -3400,6 +3323,7 @@ function ExecuteEffectFunction(_pLayer, _funcname, _etype, _enumb)
Current_Event_Type = oldtype;
Current_Event_Number = oldnumb;
*/
+ // @endif
};
function ExecuteLayerScript(layerid,script)
@@ -3423,18 +3347,22 @@ function ExecuteLayerScript(layerid,script)
function SetLayerShader(shaderid)
{
+ // @if feature("shaders")
if(shaderid!=-1)
{
shader_set(shaderid);
}
+ // @endif
};
function ResetLayerShader(shaderid)
{
+ // @if feature("shaders")
if(shaderid!=-1)
{
shader_reset();
}
+ // @endif
};
// #############################################################################################
/// Function:
@@ -3444,7 +3372,7 @@ function ResetLayerShader(shaderid)
/// In: Rect to "fit" in
// #############################################################################################
yyRoom.prototype.ExecuteDrawEvent = function (_rect, _event) {
- var pSprite, pInst, i, pool, pSprites;
+ var pSprite, pInst, i, pool;
Current_Event_Type = _event;
@@ -3466,8 +3394,10 @@ yyRoom.prototype.ExecuteDrawEvent = function (_rect, _event) {
Current_Event_Number = EVENT_DRAW_BEGIN;
+ // @if feature("layerEffects")
if (player.m_effectEnabled)
ExecuteEffectFunction(player, EFFECT_LAYER_BEGIN_FUNC, EVENT_DRAW_BEGIN, 0);
+ // @endif
SetLayerShader(player.m_shaderId);
ExecuteLayerScript(player.m_id, player.m_beginScript);
@@ -3499,8 +3429,10 @@ yyRoom.prototype.ExecuteDrawEvent = function (_rect, _event) {
ExecuteLayerScript(player.m_id,player.m_endScript);
ResetLayerShader(player.m_shaderId);
+ // @if feature("layerEffects")
if (player.m_effectEnabled)
ExecuteEffectFunction(player, EFFECT_LAYER_END_FUNC, EVENT_DRAW_BEGIN, 0);
+ // @endif
}
}
@@ -3509,7 +3441,6 @@ yyRoom.prototype.ExecuteDrawEvent = function (_rect, _event) {
pool = this.m_Active.pool;
- pSprites = g_pSpriteManager.Sprites;
for (i = pool.length - 1; i >= 0; i--)
{
@@ -3622,13 +3553,8 @@ yyRoom.prototype.DrawViews = function (r) {
Graphics_SetViewPort(0, 0, g_ApplicationWidth, g_ApplicationHeight);
- if (g_isZeus) {
- g_DefaultView.cameraID = g_DefaultCameraID;
- UpdateDefaultCamera(0, 0, g_RunRoom.m_width, g_RunRoom.m_height, 0);
- }
- else {
- Graphics_SetViewArea(0, 0, g_RunRoom.m_width, g_RunRoom.m_height, 0);
- }
+ g_DefaultView.cameraID = g_DefaultCameraID;
+ UpdateDefaultCamera(0, 0, g_RunRoom.m_width, g_RunRoom.m_height, 0);
}
else {
@@ -3689,51 +3615,17 @@ yyRoom.prototype.DrawViews = function (r) {
g_pCurrentView.portw * sx, g_pCurrentView.porth * sy );
}
- if(g_isZeus/* && (g_webGL!=null)*/)
- {
- g_pCameraManager.SetActiveCamera(g_pCurrentView.cameraID);
- var pCam = g_pCameraManager.GetActiveCamera();
- if(pCam!=null)
- {
- pCam.Begin();
- pCam.ApplyMatrices();
- }
- }
- else
- Graphics_SetViewArea(g_pCurrentView.worldx, g_pCurrentView.worldy, g_pCurrentView.worldw, g_pCurrentView.worldh, g_pCurrentView.angle);
-
- if(/*(g_webGL==null) || */(!g_isZeus))
- {
- // no Angle allowed on view....unless it's webgl...
- if( Math.abs( g_pCurrentView.angle) < 0.001)
- {
- r.left = g_pCurrentView.worldx;
- r.top = g_pCurrentView.worldy;
- r.right = g_pCurrentView.worldx + g_pCurrentView.worldw;
- r.bottom = g_pCurrentView.worldy + g_pCurrentView.worldh;
- }
- else
- {
- // We need a larger area here to make sure we draw enough - calculate extents from rotation
- var rad = g_pCurrentView.angle * (Pi/180);
- var s = Math.abs( Math.sin(rad));
- var c = Math.abs( Math.cos(rad));
- var ex = (c * g_pCurrentView.worldw) + (s * g_pCurrentView.worldh);
- var ey = (s * g_pCurrentView.worldw) + (c * g_pCurrentView.worldh);
- r.left = g_pCurrentView.worldx + (g_pCurrentView.worldw - ex)/2;
- r.right = g_pCurrentView.worldx + (g_pCurrentView.worldw + ex)/2;
- r.top = g_pCurrentView.worldy + (g_pCurrentView.worldh - ey)/2;
- r.bottom = g_pCurrentView.worldy + (g_pCurrentView.worldh + ey)/2;
- }
- g_pBuiltIn.view_current = i;
- this.DrawTheRoom(r);
- }
- else
- {
+ g_pCameraManager.SetActiveCamera(g_pCurrentView.cameraID);
+ var pCam = g_pCameraManager.GetActiveCamera();
+ if(pCam!=null)
+ {
+ pCam.Begin();
+ pCam.ApplyMatrices();
+ }
- g_pBuiltIn.view_current = i;
- this.DrawTheRoom(g_roomExtents);
- }
+
+ g_pBuiltIn.view_current = i;
+ this.DrawTheRoom(g_roomExtents);
if (g_pCurrentView.surface_id != -1) {
@@ -3742,16 +3634,12 @@ yyRoom.prototype.DrawViews = function (r) {
Current_View++;
- if (g_isZeus)
- {
-
- var pCam = g_pCameraManager.GetActiveCamera();
- if(pCam!=null)
- {
- pCam.End();
- }
- g_pCameraManager.SetActiveCamera(-1); // no active camera
- }
+ var pCam = g_pCameraManager.GetActiveCamera();
+ if(pCam!=null)
+ {
+ pCam.End();
+ }
+ g_pCameraManager.SetActiveCamera(-1); // no active camera
}
Graphics_Restore();
@@ -4082,82 +3970,7 @@ yyRoom.prototype.ActivateInstance = function (_pInst) {
}
};
-// #############################################################################################
-/// Property:
-/// Add a tile to the room.
-///
-// #############################################################################################
-yyRoom.prototype.AddTile = function (_pTile) {
-
- this.m_PlayfieldManager.Add(_pTile);
- this.m_Tiles[_pTile.id] = _pTile;
- this.m_NumTiles++;
-};
-
-
-
-// #############################################################################################
-/// Property:
-/// Add a tile to the room.
-///
-// #############################################################################################
-yyRoom.prototype.DeleteTile = function (_id) {
- var pTile = this.m_Tiles[_id];
- if (pTile)
- {
- this.m_PlayfieldManager.DeleteTile(pTile);
- this.m_Tiles[_id] = undefined;
- this.m_NumTiles--;
- }
-};
-
-// #############################################################################################
-/// Property:
-/// Add a tile to the room.
-///
-// #############################################################################################
-yyRoom.prototype.DeleteTileLayer = function (_depth) {
-
- var pPlayfield = this.m_PlayfieldManager.Get(_depth);
- if (pPlayfield != null && pPlayfield != undefined) {
-
- var pool = pPlayfield.GetPool();
-
- // Delete all tile that exist in this layer.
- for (var tile = 0; tile < pool.length; tile++)
- {
- var pTile = pool[tile];
- if (pTile)
- {
- this.m_Tiles[pTile.id] = null;
- this.m_NumTiles--;
- }
- }
- }
- this.m_PlayfieldManager.Delete(_depth);
-};
-
-
-// #############################################################################################
-/// Property:
-/// Remove all tiles currently in use
-///
-// #############################################################################################
-yyRoom.prototype.ClearTiles = function () {
- this.m_NumTiles = 0;
- this.m_Tiles = [];
-};
-
-
-// #############################################################################################
-/// Property:
-/// Remove all tiles specified in storage
-///
-// #############################################################################################
-yyRoom.prototype.ClearTilesFromStorage = function () {
- this.m_pStorage.tiles = [];
-};
@@ -4233,6 +4046,7 @@ yyRoom.prototype.ProcessNewInstanceList = function () {
*/
yyRoom.prototype.ProcessParticleDepthChange = function () {
+ // @if feature("particles")
// Particle systems changing depth
if (g_isZeus) {
var len = g_ParticleChanges.length;
@@ -4254,6 +4068,7 @@ yyRoom.prototype.ProcessParticleDepthChange = function () {
}
}
if( g_ParticleChanges.length!=0 ) g_ParticleChanges = []; // wipe array
+ // @endif
};
diff --git a/scripts/yySequence.js b/scripts/yySequence.js
index f7baad4a..f9d49159 100644
--- a/scripts/yySequence.js
+++ b/scripts/yySequence.js
@@ -34,6 +34,7 @@ function CHashMapCalculateHash(snap)
/// dirtiness and signals when instances need to be updated due to changes.
///
// #############################################################################################
+// @if feature("sequences_min")
/** @constructor */
function CSequenceBaseClass()
{
@@ -66,8 +67,6 @@ function CSequenceBaseClass()
};
}
-
-
eTT_Link = 0;
eTT_Invisible = 1;
eTT_Disable = 2;
@@ -106,6 +105,8 @@ eSTT_Text = 17;
eSTT_Particle = 18;
eSTT_Max = 19;
+// @if feature("sequences")
+
function TrackIsParameter(type) { return (type == eSTT_Real || type == eSTT_Color || type == eSTT_Bool || type == eSTT_String); }
eT_UserDefined = 0;
@@ -178,15 +179,14 @@ SEQ_KEY_LENGTH_EPSILON = -0.0001;
g_CurrSequenceID = 0;
g_CurrAnimCurveID = 0;
-g_CurrTrackID = 0;
+// @endif sequences
// used to track which sequences have been changed and need to be recomputed
-g_CurrSeqObjChangeIndex = 1;
-
g_CurrSequenceObjectID = 0;
g_SeqStack = [];
+g_CurrTrackID = 0;
// #############################################################################################
/// Function:
/// Returns a new Track ID
@@ -197,6 +197,8 @@ function GetTrackID()
return g_CurrTrackID++;
}
+g_CurrSeqObjChangeIndex = 1;
+
// #############################################################################################
/// Function:
/// Returns the current sequence object change index
@@ -217,6 +219,8 @@ function GetNextSeqObjChangeIndex()
return g_CurrSeqObjChangeIndex++;
}
+// @if feature("sequences")
+
// #############################################################################################
/// Function:
/// Multiplies the given matrix by a matrix composed of the given x, y,
@@ -273,6 +277,8 @@ function GetTrackKeyRanges(_headPos, _lastHeadPos, _headDir, _speedscale, _pTrac
return _pTrack.m_keyframeStore.GetKeyframeIndexRanges(_pSeq.m_playback, playbackspeed, _pSeq.m_length, _lastHeadPos, _headPos, headDir, _startKeys, _endKeys, false);
}
+// @endif
+
// #############################################################################################
/// Function:
/// Parses the give storage data and return a new Track object
@@ -285,12 +291,13 @@ function SequenceBaseTrack_Load(_pStorage) {
var newTrack;
switch (modelName) {
+ case "GMSpriteFramesTrack": newTrack = new yySequenceSpriteFramesTrack(_pStorage); break;
+ // @if feature("sequences")
case "GMRealTrack": newTrack = new yySequenceRealTrack(_pStorage); break;
case "GMGraphicTrack": newTrack = new yySequenceGraphicTrack(_pStorage); break;
case "GMInstanceTrack": newTrack = new yySequenceInstanceTrack(_pStorage); break;
case "GMParticleTrack": newTrack = new yySequenceParticleTrack(_pStorage); break;
case "GMColourTrack": newTrack = new yySequenceColourTrack(_pStorage); break;
- case "GMSpriteFramesTrack": newTrack = new yySequenceSpriteFramesTrack(_pStorage); break;
case "GMSequenceTrack": newTrack = new yySequenceSequenceTrack(_pStorage); break;
case "GMAudioTrack": newTrack = new yySequenceAudioTrack(_pStorage); break;
case "GMTextTrack": newTrack = new yySequenceTextTrack(_pStorage); break;
@@ -300,6 +307,7 @@ function SequenceBaseTrack_Load(_pStorage) {
case "GMClipMask_Subject": newTrack = new yySequenceClipMask_SubjectTrack(_pStorage); break;
case "GMStringTrack": newTrack = new yySequenceStringTrack(_pStorage); break;
case "GMBoolTrack": newTrack = new yySequenceBoolTrack(_pStorage); break;
+ // @endif
}
newTrack.m_keyframeStore = new yyKeyframeStore(newTrack.m_type, _pStorage.keyframeStore);
@@ -308,6 +316,8 @@ function SequenceBaseTrack_Load(_pStorage) {
}
}
+// @if feature("sequences")
+
// #############################################################################################
/// Function:
/// Create a new Real Track object
@@ -1017,6 +1027,8 @@ function yySequenceColourTrack(_pStorage) {
};
}
+// @endif
+
// #############################################################################################
/// Function:
/// Create a new Sprite Frames Track object
@@ -1083,6 +1095,8 @@ function yySequenceSpriteFramesTrack(_pStorage) {
};
}
+// @if feature("sequences")
+
// #############################################################################################
/// Function:
/// Create a new Sequence Track object
@@ -1266,6 +1280,8 @@ function yySequenceBoolTrack(_pStorage) {
this.m_type = eSTT_Bool;
}
+// @endif
+
// #############################################################################################
/// Function:
/// Create a new Track object
@@ -1327,6 +1343,7 @@ function yySequenceBaseTrack(_pStorage) {
}
}
+ // @if feature("sequences")
Object.defineProperties(this, {
gmlname: {
enumerable: true,
@@ -1413,6 +1430,7 @@ function yySequenceBaseTrack(_pStorage) {
}
}
});
+ // @endif
// #############################################################################################
/// Function:
@@ -1429,8 +1447,10 @@ function yySequenceBaseTrack(_pStorage) {
if(tagLink.track == null)
{
// Find the track if it exists
+ // @if feature("sequences")
var track = g_pSequenceManager.GetSequenceFromID(tagLink.trackIndex);
if(track != null) tagLink.track = track;
+ // @endif
}
return tagLink.track;
}
@@ -1445,6 +1465,7 @@ function yySequenceBaseTrack(_pStorage) {
/// being pointed to along the track.
///
// #############################################################################################
+ // @if feature("sequences")
this.EvaluateTrack = function (_head, _length, _result, _creationmask)
{
@@ -1774,7 +1795,7 @@ function yySequenceBaseTrack(_pStorage) {
tempcreationvalue.AndEquals(_creationmask);
_result.hascreationvalue = tempcreationvalue;
};
-
+
this.AssignBuiltinTrackName = function() {
if (this.pName == null) {
this.builtinName = eT_UserDefined;
@@ -1816,8 +1837,11 @@ function yySequenceBaseTrack(_pStorage) {
else if (this.pName == "textEffect_shadowColour") this.builtinName = eT_TextEffect_ShadowColour;
else this.builtinName = eT_UserDefined;
};
+ // @endif
}
+
+
// #############################################################################################
/// Function:
/// Constrctor for the abstract TrackKeyBase object
@@ -1878,6 +1902,8 @@ function yyMessageEventTrackKey(_pStorage)
});
}
+// @if feature("sequences")
+
// #############################################################################################
/// Function:
/// Create a new Code Event Track Key object
@@ -2502,6 +2528,8 @@ function yySequenceTrackKey(_pStorage)
this.__type = "[SequenceTrackKey]";
}
+// @endif sequence - tracks
+
// #############################################################################################
/// Function:
/// Create a new SpriteFrames Track Key object
@@ -2561,6 +2589,10 @@ function yyKeyframe(_type, _pStorage) {
switch(_type)
{
+ case eSTT_SpriteFrames:
+ newKeyframe = new yySpriteFramesTrackKey(data);
+ break;
+ // @if feature("sequences")
case eSTT_Graphic:
newKeyframe = new yyGraphicTrackKey(data);
break;
@@ -2588,12 +2620,10 @@ function yyKeyframe(_type, _pStorage) {
case eSTT_Sequence:
newKeyframe = new yySequenceTrackKey(data);
break;
- case eSTT_SpriteFrames:
- newKeyframe = new yySpriteFramesTrackKey(data);
- break;
case eSTT_Particle:
newKeyframe = new yyParticleTrackKey(data);
break;
+ // @endif
}
if(newKeyframe != null)
@@ -2610,7 +2640,7 @@ function yyKeyframe(_type, _pStorage) {
}
this.SignalChange();
-
+ // @if feature("sequences")
Object.defineProperties(this, {
gmlframe: {
enumerable: true,
@@ -2664,9 +2694,9 @@ function yyKeyframe(_type, _pStorage) {
}
}
});
+ // @endif
}
-
// #############################################################################################
/// Function:
/// Create a new KeyframeStore object
@@ -3314,7 +3344,7 @@ function yySequence(_pStorage) {
this.fromWAD = true;
}
-
+ // @if feature("sequences")
Object.defineProperties(this, {
gmlname: {
enumerable: true,
@@ -3476,6 +3506,7 @@ function yySequence(_pStorage) {
set: function (_val) { this["event_broadcast_message"] = _val; }
},
});
+ // @endif
}
// #############################################################################################
@@ -3497,7 +3528,7 @@ yySequence.prototype.GetObjectIDs = function() {
///
// #############################################################################################
yySequence.prototype.GetObjectIDsFromTrack = function(_tracks, _ids) {
-
+ // @if feature("sequences")
for (var trackIndex = 0; trackIndex < _tracks.length; ++trackIndex)
{
var track = _tracks[trackIndex];
@@ -3567,9 +3598,10 @@ yySequence.prototype.GetObjectIDsFromTrack = function(_tracks, _ids) {
// Check subtracks
this.GetObjectIDsFromTrack(track.m_tracks, _ids);
}
+ // @endif
};
-
+// @if feature("sequences")
// #############################################################################################
/// Function:
/// Create a new Sequences management object
@@ -3792,7 +3824,6 @@ yySequenceManager.prototype.GetNewInstance = function ()
var g_pMessageEvents = [];
var g_pMomentEvents = [];
-var g_pSpriteMessageEvents = [];
function AddMessageEvent(_pKey, _seqElementID)
{
@@ -3810,6 +3841,8 @@ function AddMomentEvent(_pKey, _pSeqInst)
g_pMomentEvents[g_pMomentEvents.length] = newEvt;
}
+// @endif
+
function AddSpriteMessageEvent(_pKey, _elementID)
{
var newEvt = new Object();
@@ -3825,11 +3858,14 @@ function AddSpriteMessageEvent(_pKey, _elementID)
///
// #############################################################################################
+var g_pSpriteMessageEvents = [];
function ResetSpriteMessageEvents()
{
g_pSpriteMessageEvents = [];
}
+// @if feature("sequences")
+
yySequenceManager.prototype.EvaluateLayerSequenceElement = function(_pSeqEl, _preDrawUpdate)
{
if (_pSeqEl == null)
@@ -4192,6 +4228,7 @@ yySequenceManager.prototype.HandleMomentEvents = function (_pSeqInst, _pSeq, _se
} while (true);
}
};
+// @endif
// #############################################################################################
/// Function:
@@ -4255,6 +4292,7 @@ function HandleSpriteMessageEvents(_pSeq, _elementID, _fps, _speedScale, _headDi
}
};
+// @if feature("sequences")
// #############################################################################################
/// Function:
/// Handles the throwing of events which are triggered
@@ -4311,6 +4349,7 @@ yySequenceManager.prototype.ProcessMomentEvents = function ()
}
}
};
+// @endif
// #############################################################################################
/// Function:
@@ -4335,8 +4374,9 @@ function ProcessSpriteMessageEvents()
ds_map_add(map, "event_type", "sprite event");
ds_map_add(map, "element_id", g_pSpriteMessageEvents[i].elementID);
ds_map_add(map, "message", eventlist.m_events[j]);
-
+ // @if feature("sequences")
g_pSequenceManager.PerformInstanceEvents(g_RunRoom, EVENT_OTHER_BROADCAST_MESSAGE);
+ // @endif
//g_pObjectManager.ThrowEvent(EVENT_OTHER_SYSTEM_EVENT, 0);
g_pObjectManager.ThrowEvent(EVENT_OTHER_BROADCAST_MESSAGE, 0);
@@ -4425,6 +4465,7 @@ function HandleSequenceWrapping(_sequence, _retVals)
return hasWrapped;
}
+// @if feature("sequences")
// #############################################################################################
/// Function:
/// Updates the tracks within the given sequence
@@ -4655,7 +4696,7 @@ yySequenceManager.prototype.HandleUpdateTracks = function (_el, _sequence, _inst
///
// #############################################################################################
yySequenceManager.prototype.HandleSpriteTrackUpdate = function(_node, _srcVars, _instance, _track, _fps, _headDir, _lastHeadPos, _headPosition, _seqlength) {
-
+ // @if feature("sprites")
_srcVars.spriteIndex = -1;
var keyframeStore = _track.m_keyframeStore;
@@ -4674,7 +4715,9 @@ yySequenceManager.prototype.HandleSpriteTrackUpdate = function(_node, _srcVars,
if (!_srcVars.Overrides(eT_OriginY)) _srcVars.yOrigin += sprite.yOrigin;
HandleSpriteSequenceMessageEvents(_node, _track, _instance, _fps, _headPosition, _lastHeadPos, _headDir, sprite.sequence, sprite, graphicKeyframe, keyframeStore);
+ // @endif sprites
};
+// @endif
function HandleSpriteSequenceMessageEvents(_node, _track, _inst, _fps, _headPosition, _lastHeadPosition, _headDirection, _sequence, _sprite, _spriteKey, _keyframes)
{
@@ -4756,6 +4799,7 @@ function HandleSpriteSequenceMessageEvents(_node, _track, _inst, _fps, _headPosi
}
+// @if feature("sequences")
// #############################################################################################
/// Function:
/// Updates the given sequence track
@@ -5147,6 +5191,7 @@ yySequenceManager.prototype.HandleInstanceTrackUpdate = function (_pEl, _pSeq, _
pInst.image_speed = _srcVars.imageSpeed;
//calculate image index from image speed track
+ // @if feature("sprites")
var sprite = g_pSpriteManager.Get(pInst.sprite_index);
if (sprite != null)
{
@@ -5190,6 +5235,7 @@ yySequenceManager.prototype.HandleInstanceTrackUpdate = function (_pEl, _pSeq, _
}
}
}
+ // @endif sprites
}
if (_srcVars.paramset.GetBit(eT_ImageIndex))
@@ -5267,7 +5313,7 @@ yySequenceManager.prototype.HandleParticleTrackUpdate = function (_pEl, _pSeq, _
}
}
};
-
+
yySequenceManager.prototype.HandleTextTrackUpdate = function(_srcVars, _track, _headPos, _seqLength)
{
var keyframeStore = _track.m_keyframeStore;
@@ -5285,7 +5331,9 @@ yySequenceManager.prototype.HandleTextTrackUpdate = function(_srcVars, _track, _
_srcVars.pFontEffectParams.dropShadowEnabled = textkey.m_channels[0].enableShadow;
}
};
-
+// @endif sequences - manager
+
+// @if feature("sequences")
// #############################################################################################
/// Function:
/// Create a new CSequenceInstance object
@@ -5941,7 +5989,9 @@ CSequenceInstance.prototype.SetInstanceInSequenceStatus = function (_inSequence)
}
};
+// @endif sequences - instance
+// @if feature("sequences")
// #############################################################################################
/// Function:
/// Create a new CSeqTrackAudioInfo object
@@ -7476,4 +7526,6 @@ function CSeqTrackInstanceInfo()
this.instanceID = -1;
this.ownedBySequence = false;
//bool beenCreated;
-};
\ No newline at end of file
+};
+// @endif sequences - tracks
+// @endif sequences_min
diff --git a/scripts/yySound.js b/scripts/yySound.js
index 3d7e5d92..6313e8f0 100644
--- a/scripts/yySound.js
+++ b/scripts/yySound.js
@@ -60,6 +60,7 @@ function canPlayAudioMP3(callback)
}
}
+// @if feature("audio")
// #############################################################################################
/// Function:
/// Initialise a Sound from storage
@@ -747,3 +748,4 @@ yySoundManager.prototype.Create = function () {
this.Sounds[this.Sounds.length] = pSnd;
return this.Sounds.length - 1;
};
+// @endif audio
diff --git a/scripts/yySprite.js b/scripts/yySprite.js
index 641d95bf..5d06ce2d 100644
--- a/scripts/yySprite.js
+++ b/scripts/yySprite.js
@@ -76,6 +76,7 @@ YYRECT.prototype.Copy = function (_bbox) {
};
+// @if feature("sprites")
// #############################################################################################
/// Function:
/// Create a new SPRITE object
@@ -147,6 +148,7 @@ var __floatToInt = function (x) { return ~~x; };
*/
yySprite.prototype.GetSkeletonSpriteSize = function (_skeleton)
{
+ // @if feature("spine")
var bounds = new YYRECT();
_skeleton.updateWorldTransform();
@@ -171,7 +173,7 @@ yySprite.prototype.GetSkeletonSpriteSize = function (_skeleton)
return [width, height];
}
}
-
+ // @endif
return null;
};
@@ -184,7 +186,7 @@ yySprite.prototype.GetSkeletonSpriteSize = function (_skeleton)
yySprite.prototype.GetSkeletonBounds = function (_skeleton, _bounds)
{
var retval = false;
-
+ // @if feature("spine")
_bounds.left = Number.MAX_SAFE_INTEGER;
_bounds.top = Number.MAX_SAFE_INTEGER;
_bounds.right = Number.MIN_SAFE_INTEGER;
@@ -240,7 +242,7 @@ yySprite.prototype.GetSkeletonBounds = function (_skeleton, _bounds)
}
}
}
-
+ // @endif spine
return retval;
};
@@ -258,7 +260,8 @@ yySprite.prototype.GetScaledBoundingBox = function(_xscale, _yscale)
tempBB.right = this.bbox.right + 1;
tempBB.top = this.bbox.top;
tempBB.bottom = this.bbox.bottom + 1;
-
+
+ // @if feature("nineslice")
if ((this.nineslicedata != null) && (this.nineslicedata.GetEnabled()))
{
// If bounding box covers entire sprite then we don't need to do anything clever
@@ -374,8 +377,8 @@ yySprite.prototype.GetScaledBoundingBox = function(_xscale, _yscale)
scaledBB.top -= this.yOrigin * abs_yscale;
scaledBB.bottom -= this.yOrigin * abs_yscale;
- }
- else
+ } else // ->
+ // @endif nineslice
{
scaledBB.left = (tempBB.left - this.xOrigin) * abs_xscale;
scaledBB.right = (tempBB.right - this.xOrigin) * abs_xscale;
@@ -445,7 +448,7 @@ yySprite.prototype.CalcCullRadius = function () {
///
// #############################################################################################
yySprite.prototype.BuildSWFData = function (_swfIndex, _xo, _yo) {
-
+ // @if feature("swf")
try {
if (g_pSpriteManager.swfSpriteData !== undefined) {
@@ -546,6 +549,7 @@ yySprite.prototype.BuildSWFData = function (_swfIndex, _xo, _yo) {
catch (e) {
debug("Cannot build SWF data " + e.message);
}
+ // @endif
};
@@ -555,7 +559,7 @@ yySprite.prototype.BuildSWFData = function (_swfIndex, _xo, _yo) {
///
// #############################################################################################
yySprite.prototype.SetupSWFCollisionMasks = function (_dataView, _byteOffset, _littleEndian) {
-
+ // @if feature("swf")
if (this.colcheck !== yySprite_CollisionType.PRECISE) {
return;
}
@@ -602,6 +606,7 @@ yySprite.prototype.SetupSWFCollisionMasks = function (_dataView, _byteOffset, _l
_byteOffset = offsetStore + ((colMaskSize + 3) & ~3);
}
this.maskcreated = true;
+ // @endif swf
return _byteOffset;
};
@@ -611,7 +616,7 @@ yySprite.prototype.SetupSWFCollisionMasks = function (_dataView, _byteOffset, _l
///
// #############################################################################################
yySprite.prototype.SetSWFDrawRoutines = function () {
-
+ // @if feature("swf")
this.Draw = function (_ind, _x, _y, _xscale, _yscale, _angle, _colour, _alpha) {
Graphics_SWFDraw(
this.SWFDictionaryItems, this.SWFTimeline, _ind, this.xOrigin, this.yOrigin, _x, _y, _xscale, _yscale, _angle, _colour, _alpha, this.ppTPE);
@@ -621,6 +626,7 @@ yySprite.prototype.SetSWFDrawRoutines = function () {
Graphics_SWFDraw(
this.SWFDictionaryItems, this.SWFTimeline, _ind, this.xOrigin, this.yOrigin, _x, _y, 1.0, 1.0, 0.0, 0xffffffff, _alpha, this.ppTPE);
};
+ // @endif swf
};
@@ -631,6 +637,7 @@ yySprite.prototype.SetSWFDrawRoutines = function () {
///
// #############################################################################################
yySprite.prototype.BuildSkeletonData = function (_skeletonData) {
+ // @if feature("spine")
if (_skeletonData) {
this.m_skeletonSprite = new yySkeletonSprite();
//this.m_skeletonSprite.Load(skeletonData.json, skeletonData.atlas, skeletonData.width, skeletonData.height);
@@ -651,6 +658,7 @@ yySprite.prototype.BuildSkeletonData = function (_skeletonData) {
};
this.numb = SKELETON_FRAMECOUNT;
+ // @endif spine
};
// #############################################################################################
@@ -659,6 +667,7 @@ yySprite.prototype.BuildSkeletonData = function (_skeletonData) {
///
// #############################################################################################
yySprite.prototype.LoadFromSpineAsync = function (_filename, _callback) {
+ // @if feature("spine")
var loadFileContents = function (_filename, _callback) {
var errorMessage = 'Could not load file contents!';
var request = new XMLHttpRequest();
@@ -791,6 +800,7 @@ yySprite.prototype.LoadFromSpineAsync = function (_filename, _callback) {
}
tryCallback(_err);
});
+ // @endif spine
};
// #############################################################################################
@@ -813,7 +823,9 @@ yySprite.prototype.BuildSequenceData = function (_sequenceData) {
// #############################################################################################
yySprite.prototype.BuildNineSliceData = function (_ninesliceData)
{
+ // @if feature("nineslice")
this.nineslicedata = new yyNineSliceData(_ninesliceData);
+ // @endif
};
// #############################################################################################
@@ -915,19 +927,22 @@ function CreateSpriteFromStorage( _pStore )
pSprite.Masks = null;
-
+ // @if feature("swf")
if (_pStore.swf !== undefined) {
pSprite.m_LoadedFromChunk = true;
pSprite.BuildSWFData(_pStore.swf, pSprite.xOrigin, pSprite.yOrigin);
}
+ // @endif
if (_pStore.sequence !== undefined) {
pSprite.BuildSequenceData(_pStore.sequence);
}
+ // @if feature("nineslice")
if (_pStore.nineslice !== undefined) {
pSprite.BuildNineSliceData(_pStore.nineslice);
}
+ // @endif
if(_pStore.Masks !== undefined) pSprite.Masks = _pStore.Masks;
@@ -952,12 +967,14 @@ function CreateSpriteFromStorage( _pStore )
}
// Do this after we've set up our TPEs
+ // @if feature("spine")
if (_pStore.skel !== undefined) {
var skeletonData = g_pSpriteManager.SkeletonData
? g_pSpriteManager.SkeletonData[_pStore.skel]
: undefined;
pSprite.BuildSkeletonData(skeletonData);
}
+ // @endif
pSprite.CalcCullRadius();
@@ -1037,13 +1054,14 @@ yySprite.prototype.DrawSimple = function (_sub_image, _x, _y, _alpha) {
// Make sure we're not dealing with a texture that's been downsized to fit the tpage
var pTPE = this.ppTPE[_sub_image];
if (!pTPE) return; // no loaded? texture group etc?
-
+
+ // @if feature("nineslice")
if ((this.nineslicedata != null) && (this.nineslicedata.enabled == true))
{
var col = 0xffffffff;
this.nineslicedata.Draw(_x, _y, this.width, this.height, 0, col, 1, _sub_image, this);
- }
- else
+ } else // ->
+ // @endif nineslice
{
if ((pTPE.w == pTPE.CropWidth) && (pTPE.h == pTPE.CropHeight))
{
@@ -1112,12 +1130,13 @@ yySprite.prototype.Draw = function (_ind, _x, _y, _xscale, _yscale, _angle, _col
if (_ind < 0) _ind += this.numb;
_angle = fmod(_angle, 360.0);
-
+
+ // @if feature("nineslice")
if ((this.nineslicedata != null) && (this.nineslicedata.enabled == true))
{
this.nineslicedata.Draw(_x, _y, this.width * _xscale, this.height * _yscale, _angle, _colour, _alpha, _ind, this);
- }
- else
+ } else // ->
+ // @endif
{
// undefined forces colour+alpha into ALL verts
Graphics_TextureDraw(this.ppTPE[_ind], this.xOrigin, this.yOrigin, _x, _y, _xscale, _yscale, _angle * Math.PI / 180.0, _colour, undefined, undefined, undefined, _alpha);
@@ -1128,9 +1147,9 @@ yySprite.prototype.Draw = function (_ind, _x, _y, _xscale, _yscale, _angle, _col
yySprite.prototype.GetSkeletonSlotsAtPoint = function(_inst, _x, _y, _list)
{
+ // @if feature("spine")
if ((this.m_skeletonSprite === undefined) || (this.m_skeletonSprite === null))
return; // not a Spine sprite
-
var xscale = _inst.image_xscale;
var yscale = _inst.image_yscale;
@@ -1147,7 +1166,7 @@ yySprite.prototype.GetSkeletonSlotsAtPoint = function(_inst, _x, _y, _list)
var angle = _inst.image_angle;
this.m_skeletonSprite.GetSlotsAtWorldPos(_inst, undefined, undefined, ind, x, y, xscale, yscale, angle, _x, _y, _list);
-
+ // @endif spine
};
@@ -1162,6 +1181,7 @@ yySprite.prototype.GetSkeletonSlotsAtPoint = function(_inst, _x, _y, _list)
/// The sprite data or null
///
// #############################################################################################
+// @if function("draw_sprite_pos")
yySprite.prototype.Sprite_DrawSimplePos = function (_sub_image, _x1, _y1, _x2, _y2, _x3, _y3, _x4, _y4, _alpha) {
if (this.numb <= 0) return;
@@ -1171,6 +1191,7 @@ yySprite.prototype.Sprite_DrawSimplePos = function (_sub_image, _x1, _y1, _x2, _
if (!this.ppTPE) return;
Graphics_TextureDrawPos(this.ppTPE[_sub_image], _x1, _y1, _x2, _y2, _x3, _y3, _x4, _y4, _alpha);
};
+// @endif
function _ColMaskSet(u, v, pMaskBase,width)
{
@@ -2386,9 +2407,11 @@ yySpriteManager.prototype.AddSprite = function (_pSprite) {
yySpriteManager.prototype.GetImageCount = function (_spr_number) {
var sprite = this.Sprites[_spr_number];
if (!sprite) return null;
+ // @if feature("swf")
if ((sprite.SWFTimeline !== null) && (sprite.SWFTimeline !== undefined)) {
return sprite.SWFTimeline.numFrames;
- }
+ }
+ // @endif
return sprite.ppTPE.length;
};
@@ -2483,7 +2506,7 @@ yySpriteManager.prototype.Delete = function(_id) {
///
// #############################################################################################
yySpriteManager.prototype.SWFLoad = function (_data) {
-
+ // @if feature("swf")
try {
// header consists of:
// "rswf";
@@ -2539,6 +2562,7 @@ yySpriteManager.prototype.SWFLoad = function (_data) {
catch (e) {
debug("Cannot parse SWF data " + e.message);
}
+ // @endif swf
};
@@ -2548,7 +2572,7 @@ yySpriteManager.prototype.SWFLoad = function (_data) {
///
// #############################################################################################
yySpriteManager.prototype.SkeletonLoad = function (_spineText) {
-
+ // @if feature("spine")
function multiply_uint32(a, b) {
var ah = (a >> 16) & 0xffff, al = a & 0xffff;
var bh = (b >> 16) & 0xffff, bl = b & 0xffff;
@@ -2652,4 +2676,6 @@ yySpriteManager.prototype.SkeletonLoad = function (_spineText) {
catch (e) {
debug("Cannot parse Spine data " + e.message);
}
+ // @endif spine
};
+// @endif sprites
diff --git a/scripts/yyTile.js b/scripts/yyTile.js
index 98bac5d3..85346392 100644
--- a/scripts/yyTile.js
+++ b/scripts/yyTile.js
@@ -14,175 +14,3 @@
// 17/02/2011
//
// **********************************************************************************************************************
-
-
-// #############################################################################################
-/// Function:
-/// Game Maker "ACTIVE" Room class
-///
-// #############################################################################################
-/** @constructor */
-function yyTile()
-{
- this.__type = "[Tile]";
- this.x = 0; // X coordinate
- this.y = 0; // Y coordinate
- this.index = 0; // Background index to use as the tileset
- this.xo = 0; // X texel index
- this.yo = 0; // Y texel index
- this.w = 0; // width in texels
- this.h = 0; // height in texels
- this.depth = 0.0; // depth (acts as layer ID)
- this.id = g_DynamicTileID++; // tile ID
- this.xscale = 1.0; // tile X scale
- this.yscale = 1.0; // tile Y scale
- this.blend = 0xffffff; // colour blend
- this.alpha = 1.0;
- this.visible = true;
- this.clamped = false; // used internally for fixing GM bleed-over on TPages
-}
-
-
-// #############################################################################################
-/// Function:
-/// In the IDE itself (this may be legacy issues now...) it's possible to setup a
-/// tile whose drawing range is outwith the actual image. Within GM there is no
-/// visible problem since the tiles are held individually and drawn clamped, but once
-/// the images are on a TPage any drawing outside the tile's range will potentially
-/// bleed over onto adjacent entries in the TPage. Here we fix those issues...
-///
-// #############################################################################################
-yyTile.prototype.ClampDrawingRange = function () {
-
- var pImage = g_pBackgroundManager.GetImage(this.index);
- if (pImage != null)
- {
- var pTPE = pImage.TPEntry;
-
- if (pTPE.tp >= g_Textures.length) return;
- if (!g_Textures[pTPE.tp].complete) return;
-
-
- if (this.xo < 0)
- {
- this.w += this.xo;
- this.xo = 0;
- }
- if (this.yo < 0)
- {
- this.h += this.yo;
- this.yo = 0;
- }
-
- if (pTPE != null)
- {
- if ((this.xo + this.w) >= pTPE.w)
- {
- this.w = pTPE.w - this.xo;
- }
- if ((this.yo + this.h) >= pTPE.h)
- {
- this.h = pTPE.h - this.yo;
- }
- }
- }
-};
-
-
-// #############################################################################################
-/// Function:
-/// Create a tile from its "loaded" data
-///
-///
-/// In: Tile data
-///
-// #############################################################################################
-function CreateTileFromStorage( _pTileStorage )
-{
- //{ "x":0, "y":0, "index":2, "xo":320, "yo":0, "w":64, "h":64, "depth":10, "id":10000235, },
- var pTile = new yyTile();
-
- if( _pTileStorage.x!=undefined ) pTile.x = _pTileStorage.x;
- if ( _pTileStorage.y!=undefined ) pTile.y = _pTileStorage.y;
- if( _pTileStorage.index!=undefined ) pTile.index = _pTileStorage.index;
- if( _pTileStorage.xo!=undefined ) pTile.xo = _pTileStorage.xo;
- if( _pTileStorage.yo!=undefined ) pTile.yo = _pTileStorage.yo;
- if( _pTileStorage.w!=undefined ) pTile.w = _pTileStorage.w;
- if( _pTileStorage.h!=undefined ) pTile.h= _pTileStorage.h;
- if( _pTileStorage.depth!=undefined ) pTile.depth = _pTileStorage.depth;
- if( _pTileStorage.id!=undefined ) pTile.id = _pTileStorage.id;
- if (_pTileStorage.scaleX != undefined) pTile.xscale = _pTileStorage.scaleX;
- if (_pTileStorage.scaleY != undefined) pTile.yscale = _pTileStorage.scaleY;
- if (_pTileStorage.colour != undefined) {
- pTile.blend = (_pTileStorage.colour&0xffffff);
- pTile.alpha = ((_pTileStorage.colour>>24)&0xff)/255.0;
- }
- pTile.ClampDrawingRange();
-
-
-
- if (g_DynamicTileID < _pTileStorage.id) g_DynamicTileID = _pTileStorage.id + 1;
- return pTile;
-}
-
-
-// #############################################################################################
-/// Function:
-/// Draw the tile.
-///
-///
-/// Out:
-///
-///
-// #############################################################################################
-yyTile.prototype.Draw = function() {
- if (!this.visible) return false;
- var pImage = g_pBackgroundManager.GetImage(this.index);
- if (pImage != null) {
- var pTPE = pImage.TPEntry;
-
- if ((pTPE.texture instanceof HTMLImageElement)
- && (pTPE.tp >= g_Textures.length)) return;
- if ((g_Textures[pTPE.tp] instanceof HTMLImageElement)
- && (!g_Textures[pTPE.tp].complete)) return;
-
- var scalex = pTPE.w / pTPE.ow;
- var scaley = pTPE.h / pTPE.oh;
- if (!g_webGL) {
-
- graphics.globalAlpha = this.alpha;
- if (this.blend != 0xffffff) {
- var cached_image = Graphics_CacheBlock(pTPE, this.blend);
- if (this.xscale <= 0 || this.yscale <= 0) {
- Graphics_PushTransform(this.x, this.y, this.xscale, this.yscale, 0.0);
- graphics._drawImage(cached_image, (this.xo * scalex), (this.yo * scaley), this.w * scalex, this.h * scaley, 0, 0, this.w, this.h);
- Graphics_SetTransform();
- }
- else {
- // otherwise, draw faster
- graphics._drawImage(cached_image, (this.xo * scalex), (this.yo * scaley), (this.w * scalex), (this.h * scaley), this.x, this.y, this.w * this.xscale, this.h * this.yscale);
- }
- }
- else {
- var pTexture = -1;
- if (pTPE.texture instanceof HTMLImageElement)
- pTexture = g_Textures[pTPE.tp];
- else
- pTexture = pTPE.texture;
- if (this.xscale <= 0 || this.yscale <= 0) {
-
- Graphics_PushTransform(this.x, this.y, this.xscale, this.yscale, 0.0);
- graphics._drawImage(pTexture, pTPE.x + (this.xo * scalex), pTPE.y + (this.yo * scalex), this.w * scalex, this.h * scaley, 0, 0, this.w, this.h);
- Graphics_SetTransform();
- }
- else {
- graphics._drawImage(pTexture, pTPE.x + (this.xo * scalex), pTPE.y + (this.yo * scalex), this.w * scalex, this.h * scaley, this.x, this.y, this.w * this.xscale, this.h * this.yscale);
- }
- }
- }
- else {
- var col = this.blend | ((this.alpha * 255) << 24);
- graphics._drawImage(pTPE, pTPE.x + (this.xo * scalex), pTPE.y + (this.yo * scalex), this.w * scalex, this.h * scalex, this.x, this.y, this.w * this.xscale, this.h * this.yscale, col);
- }
- }
-};
\ No newline at end of file
diff --git a/scripts/yyTimeline.js b/scripts/yyTimeline.js
index dbe5a913..ce9db079 100644
--- a/scripts/yyTimeline.js
+++ b/scripts/yyTimeline.js
@@ -15,7 +15,7 @@
//
// **********************************************************************************************************************
-
+// @if feature("timelines")
// #############################################################################################
/// Function:
/// Create a new TIMELINE object
@@ -270,4 +270,5 @@ yyTimelineManager.prototype.ClearEvent = function (_ind, _timeStamp) {
}
}
}
-};
\ No newline at end of file
+};
+// @endif timelines
diff --git a/scripts/yyVariable.js b/scripts/yyVariable.js
index c7620076..3d05c2aa 100644
--- a/scripts/yyVariable.js
+++ b/scripts/yyVariable.js
@@ -548,6 +548,7 @@ function computeIterationValues(_maxLength, _rawOffset, _rawLength) {
/// true for ===, false for !===
///
// #############################################################################################
+/// @if function("array_equals")
function array_equals(_a, _b)
{
// Both arguments must be arrays
@@ -574,6 +575,7 @@ function array_equals(_a, _b)
}
return true;
} // end array_equals
+/// @endif array_equals
function array_create( _size, _val )
{
diff --git a/scripts/yyVertexManager.js b/scripts/yyVertexManager.js
index b6c2cac6..6670ac97 100644
--- a/scripts/yyVertexManager.js
+++ b/scripts/yyVertexManager.js
@@ -10,18 +10,40 @@
//
// **********************************************************************************************************************
-function vertex_format_begin() { ErrorFunction("vertex_format_begin"); }
-function vertex_format_end() { ErrorFunction("vertex_format_end"); }
-function vertex_format_delete(format_id) { ErrorFunction("vertex_format_delete"); }
-function vertex_format_add_position() { ErrorFunction("vertex_format_add_position"); }
-function vertex_format_add_position_3d() { ErrorFunction("vertex_format_add_position_3d"); }
-function vertex_format_add_colour() { ErrorFunction("vertex_format_add_colour"); }
-function vertex_format_add_color() { ErrorFunction("vertex_format_add_color"); }
-function vertex_format_add_normal() { ErrorFunction("vertex_format_add_normal"); }
-function vertex_format_add_texcoord() { ErrorFunction("vertex_format_add_texcoord"); }
-function vertex_format_add_textcoord() { ErrorFunction("vertex_format_add_textcoord"); }
-function vertex_format_add_custom(type, usage) { ErrorFunction("vertex_format_add_custom"); }
-function vertex_format_get_info(format_id) { ErrorFunction("vertex_format_get_info"); }
+// @if function("vertex_*")
+
+var vertex_format_begin,
+ vertex_format_end,
+ vertex_format_delete,
+ vertex_format_add_position,
+ vertex_format_add_position_3d,
+ vertex_format_add_colour,
+ vertex_format_add_color,
+ vertex_format_add_normal,
+ vertex_format_add_texcoord,
+ vertex_format_add_textcoord,
+ vertex_format_add_custom,
+ vertex_format_get_info;
+
+// @if feature("2d")
+(() => {
+ let _stub = (_name, _val) => () => ErrorFunction(_name, _val);
+ vertex_format_begin = _stub("vertex_format_begin");
+ vertex_format_end = _stub("vertex_format_end", -1);
+ vertex_format_delete = _stub("vertex_format_delete");
+ vertex_format_add_position = _stub("vertex_format_add_position");
+ vertex_format_add_position_3d = _stub("vertex_format_add_position_3d");
+ vertex_format_add_colour = _stub("vertex_format_add_colour");
+ vertex_format_add_color = _stub("vertex_format_add_color");
+ vertex_format_add_normal = _stub("vertex_format_add_normal");
+ vertex_format_add_texcoord = _stub("vertex_format_add_texcoord");
+ vertex_format_add_textcoord = _stub("vertex_format_add_textcoord");
+ vertex_format_add_custom = _stub("vertex_format_add_custom");
+ vertex_format_get_info = _stub("vertex_format_get_info");
+})();
+// @endif 2d
+
+// @if feature("gl")
// ---------------------------------------------------------------------------------------------
// Tracks the format currently under construction
@@ -206,3 +228,6 @@ function WebGL_vertex_format_get_info_RELEASE(_format_id)
return pVFI;
}
+// @endif gl
+
+// @endif vertex_
diff --git a/scripts/yyVideo.js b/scripts/yyVideo.js
index 7b63ac78..7b72a4dc 100644
--- a/scripts/yyVideo.js
+++ b/scripts/yyVideo.js
@@ -10,6 +10,7 @@
//
// **********************************************************************************************************************
+// @if function("video_")
var g_VideoUserEnded = false; //For some reason I can't figure this from the video player...
function video_get_format() {
@@ -543,4 +544,5 @@ function video_get_volume()
}
return 0;
-}
\ No newline at end of file
+}
+// @endif
diff --git a/scripts/yyView.js b/scripts/yyView.js
index 43cdc31b..b687accf 100644
--- a/scripts/yyView.js
+++ b/scripts/yyView.js
@@ -103,35 +103,25 @@ yyView.prototype.GetMouseCoord = function(_x,_y,_horizontal) {
_x = (_x - pRect.left - this.scaledportx) / (pRect.scaleX || 1);
_y = (_y - pRect.top - this.scaledporty) / (pRect.scaleY || 1);
- if (g_isZeus) {
- var cam = g_pCameraManager.GetCamera(this.cameraID);
- if (cam == null) return 0;
- //
- var clipX = _x / this.scaledportw;
- var clipY = _y / this.scaledporth;
- clipX = clipX * 2.0 - 1.0;
- clipY = clipY * 2.0 - 1.0;
-
- // Now backtransform into room space
- var invViewProj = cam.GetInvViewProjMat();
+ var cam = g_pCameraManager.GetCamera(this.cameraID);
+ if (cam == null) return 0;
+ //
+ var clipX = _x / this.scaledportw;
+ var clipY = _y / this.scaledporth;
+ clipX = clipX * 2.0 - 1.0;
+ clipY = clipY * 2.0 - 1.0;
+
+ // Now backtransform into room space
+ var invViewProj = cam.GetInvViewProjMat();
- // we're treating z as 0 and w as 1
- var out;
- if (_horizontal) {
- out = ((clipX * invViewProj.m[_11]) + (clipY * invViewProj.m[_21]) + invViewProj.m[_41]);
- } else {
- out = ((clipX * invViewProj.m[_12]) + (clipY * invViewProj.m[_22]) + invViewProj.m[_42]);
- }
- return Math.floor(out);
+ // we're treating z as 0 and w as 1
+ var out;
+ if (_horizontal) {
+ out = ((clipX * invViewProj.m[_11]) + (clipY * invViewProj.m[_21]) + invViewProj.m[_41]);
} else {
- if (_horizontal) {
- _x /= this.WorldViewScaleX;
- return _x + this.worldx;
- } else {
- _y /= this.WorldViewScaleY;
- return _y + this.worldy;
- }
+ out = ((clipX * invViewProj.m[_12]) + (clipY * invViewProj.m[_22]) + invViewProj.m[_42]);
}
+ return Math.floor(out);
};
// #############################################################################################
@@ -182,20 +172,17 @@ function CreateViewFromStorage( _pViewStorage )
if( _pViewStorage.vspeed!=undefined ) view.vspeed = _pViewStorage.vspeed;
if( _pViewStorage.index!=undefined ) view.objid = _pViewStorage.index;
- if (g_isZeus)
+ // if we have a camera stored in the "storage" view, then clone that
+ if ( _pViewStorage.cameraID !== undefined && _pViewStorage.cameraID>=0) {
+ // Already been setup, so clone it... don't mess around with the storage one
+ view.cameraID = g_pCameraManager.CloneCamera(_pViewStorage.cameraID);
+ }
+ else
{
- // if we have a camera stored in the "storage" view, then clone that
- if ( _pViewStorage.cameraID !== undefined && _pViewStorage.cameraID>=0) {
- // Already been setup, so clone it... don't mess around with the storage one
- view.cameraID = g_pCameraManager.CloneCamera(_pViewStorage.cameraID);
- }
- else
- {
- // Create camera and attach it to the view
- var pCam = g_pCameraManager.CreateCameraFromView(view);
- pCam.SetCloned(true);
- view.cameraID = pCam.GetID();
- }
+ // Create camera and attach it to the view
+ var pCam = g_pCameraManager.CreateCameraFromView(view);
+ pCam.SetCloned(true);
+ view.cameraID = pCam.GetID();
}
return view;
diff --git a/scripts/yyWebGL.js b/scripts/yyWebGL.js
index 57e82bd3..f4434061 100644
--- a/scripts/yyWebGL.js
+++ b/scripts/yyWebGL.js
@@ -59,9 +59,7 @@ var GR_MarkVertCorners = false,
// Store the set of shader programs created from the user's project
var g_shaderPrograms = [];
-var g_Matrix = null,
- g_MatrixStack = null,
- g_MatrixSP = 0;
+var g_Matrix = null;
// Constants for matrix stack
var MATRIX_VIEW = 0,
@@ -107,11 +105,16 @@ var g_AppendDerivativesExtToShader = false;
///
// #############################################################################################
function InitWebGLFunctions() {
-
+ // VD: a lot of conditionals here, but oh well
+
InitD3DFunctions();
+ // @if function("vertex_*")
InitFVFFunctions();
InitBufferVertexFunctions();
+ // @endif
+ // @if function("draw_primitive_*") || function("draw_vertex*")
InitPrimBuilderFunctions();
+ // @endif
DrawCirclePrecision(g_circleSteps);
@@ -128,7 +131,9 @@ function InitWebGLFunctions() {
Graphics_PushMatrix = WebGL_PushMatrix_RELEASE;
Graphics_Save = WebGL_Save_RELEASE;
Graphics_Restore = WebGL_Restore_RELEASE;
+ // @if feature("fonts")
Graphics_DrawText = WebGL_DrawText_RELEASE;
+ // @endif fonts
Graphics_StartFrame = WebGL_StartFrame_RELEASE;
Graphics_EndFrame = WebGL_EndFrame_RELEASE;
Graphics_DrawComment = WEBGL_DrawComment_RELEASE;
@@ -138,101 +143,120 @@ function InitWebGLFunctions() {
Graphics_TextureDrawSimple = WebGL_TextureDrawSimple_RELEASE;
Graphics_TextureDrawTiled = WebGL_TextureDrawTiled_RELEASE;
Graphics_TextureDraw = WebGL_TextureDraw_RELEASE;
+ // @if function("draw_sprite_pos")
Graphics_TextureDrawPos = WebGL_TextureDrawPos_RELEASE;
+ // @endif
+ // @if feature("swf")
Graphics_SWFDraw = WebGL_DrawSWF_RELEASE;
Graphics_SWFDrawObject = WebGL_DrawSWFObject_RELEASE;
+ // @endif swf
Graphics_DrawPart = WebGL_DrawPart_RELEASE;
draw_rectangle = WebGL_draw_rectangle_RELEASE;
draw_roundrect_color_ext = WebGL_draw_roundrect_color_EXT_RELEASE;
- draw_rectangle_color = WebGL_draw_rectangle_color_RELEASE;
- draw_roundrect_colour_ext = WebGL_draw_roundrect_color_EXT_RELEASE;
- draw_rectangle_colour = WebGL_draw_rectangle_color_RELEASE;
- draw_rectangle_gradient = WebGL_draw_rectangle_gradient_RELEASE;
- draw_point = WebGL_draw_point_RELEASE;
- draw_getpixel = WebGL_draw_getpixel_RELEASE;
- draw_getpixel_ext = WebGL_draw_getpixel_ext_RELEASE;
+ draw_rectangle_color = WebGL_draw_rectangle_color_RELEASE; // NB! used to clear screen
+ compile_if_used(draw_roundrect_colour_ext = WebGL_draw_roundrect_color_EXT_RELEASE);
+ compile_if_used(draw_rectangle_colour = WebGL_draw_rectangle_color_RELEASE);
+ compile_if_used(draw_point = WebGL_draw_point_RELEASE);
+ compile_if_used(draw_getpixel = WebGL_draw_getpixel_RELEASE);
+ compile_if_used(draw_getpixel_ext = WebGL_draw_getpixel_ext_RELEASE);
+ // @if function("draw_triangle") || function("draw_arrow") || function("physics_world_draw_debug")
draw_triangle = WebGL_draw_triangle_RELEASE;
- draw_triangle_color = WebGL_draw_triangle_color_RELEASE;
+ // @endif
+
+ compile_if_used(draw_triangle_color = WebGL_draw_triangle_color_RELEASE);
+ // @if function("draw_ellipse") || function("draw_ellipse_color")
draw_ellipse_color = WebGL_draw_ellipse_color_RELEASE;
+ // @endif
+ // @if function("draw_circle") || function("draw_circle_color")
draw_circle_color = WebGL_draw_circle_color_RELEASE;
- draw_point_color = WebGL_draw_point_color_RELEASE;
+ // @endif
+ compile_if_used(draw_point_color = WebGL_draw_point_color_RELEASE);
+
draw_triangle_colour = WebGL_draw_triangle_color_RELEASE;
- draw_ellipse_colour = WebGL_draw_ellipse_color_RELEASE;
- draw_circle_colour = WebGL_draw_circle_color_RELEASE;
- draw_point_colour = WebGL_draw_point_color_RELEASE;
+ compile_if_used(draw_ellipse_colour = WebGL_draw_ellipse_color_RELEASE);
+ compile_if_used(draw_circle_colour = WebGL_draw_circle_color_RELEASE);
+ compile_if_used(draw_point_colour = WebGL_draw_point_color_RELEASE);
+
+ // line functions are used a lot, don't trim these
draw_line = WebGL_draw_line_RELEASE;
draw_line_width = WebGL_draw_line_width_RELEASE;
draw_line_width_color = WebGL_draw_line_width_color_RELEASE;
- draw_line_width_colour = WebGL_draw_line_width_color_RELEASE;
- draw_clear_alpha = WebGL_draw_clear_alpha_RELEASE;
+ compile_if_used(draw_line_width_colour = WebGL_draw_line_width_color_RELEASE);
+ draw_clear_alpha = WebGL_draw_clear_alpha_RELEASE; // used by yyEffects
draw_set_color = WebGL_draw_set_color_RELEASE;
- draw_set_colour = WebGL_draw_set_color_RELEASE;
- draw_set_alpha = WebGL_draw_set_alpha_RELEASE;
+ compile_if_used(draw_set_colour = WebGL_draw_set_color_RELEASE);
+ draw_set_alpha = WebGL_draw_set_alpha_RELEASE; // used for vkeys
draw_set_blend_mode_ext = WEBGL_draw_set_blend_mode_ext_RELEASE;
draw_enable_alphablend = WEBGL_draw_enable_alpha_blend_RELEASE;
- draw_surface = WebGL_draw_surface_RELEASE;
+ compile_if_used(draw_surface = WebGL_draw_surface_RELEASE);
+ // @if feature("paths")
draw_path = WEBGL_draw_path;
+ // @endif
+ // @if function("mp_grid_*")
mp_grid_draw = WEBGL_mp_grid_draw;
+ // @endif
g_webGL._drawImage = WebGL_drawImage_Replacement_RELEASE;
// Surfaces
surface_create = WebGL_surface_create_RELEASE;
surface_free = WebGL_surface_free_RELEASE;
- surface_getpixel = WebGL_surface_getpixel_RELEASE;
- surface_getpixel_ext = WebGL_surface_getpixel_ext_RELEASE;
- surface_copy = WebGL_surface_copy_RELEASE;
- surface_copy_part = WebGL_surface_copy_part_RELEASE;
+ compile_if_used(surface_getpixel = WebGL_surface_getpixel_RELEASE);
+ compile_if_used(surface_getpixel_ext = WebGL_surface_getpixel_ext_RELEASE);
+ compile_if_used(surface_copy = WebGL_surface_copy_RELEASE);
+ compile_if_used(surface_copy_part = WebGL_surface_copy_part_RELEASE);
- // Backgrounds
- background_create_from_screen = WebGL_background_create_from_screen_RELEASE;
- background_create_from_surface = WebGL_background_create_from_surface_RELEASE;
+ // Backgrounds (no longer needed..?)
+ //background_create_from_screen = WebGL_background_create_from_screen_RELEASE;
+ //background_create_from_surface = WebGL_background_create_from_surface_RELEASE;
// Sprites
- sprite_add_from_screen = WebGL_sprite_add_from_screen_RELEASE;
- sprite_create_from_surface = WebGL_sprite_create_from_surface_RELEASE;
- sprite_add_from_surface = WebGL_sprite_add_from_surface_RELEASE;
+ compile_if_used(sprite_add_from_screen = WebGL_sprite_add_from_screen_RELEASE);
+ compile_if_used(sprite_create_from_surface = WebGL_sprite_create_from_surface_RELEASE);
+ compile_if_used(sprite_add_from_surface = WebGL_sprite_add_from_surface_RELEASE);
- CopyImageToAlpha = WEBGL_CopyImageToAlpha_RELEASE;
+ compile_if_used(sprite_set_alpha_from_sprite, CopyImageToAlpha = WEBGL_CopyImageToAlpha_RELEASE);
// Shaders
- fn_texture_get_texel_width = WebGL_texture_get_texel_width_RELEASE;
- fn_texture_get_texel_height = WebGL_texture_get_texel_height_RELEASE;
- fn_texture_set_stage = WebGL_texture_set_stage_RELEASE;
- fn_shader_is_compiled = WebGL_shader_is_compiled_RELEASE;
+ compile_if_used(texture_get_texel_width, fn_texture_get_texel_width = WebGL_texture_get_texel_width_RELEASE);
+ compile_if_used(texture_get_texel_height, fn_texture_get_texel_height = WebGL_texture_get_texel_height_RELEASE);
+ compile_if_used(texture_set_stage, fn_texture_set_stage = WebGL_texture_set_stage_RELEASE);
+ compile_if_used(shader_is_compiled, fn_shader_is_compiled = WebGL_shader_is_compiled_RELEASE);
fn_shader_set = WebGL_shader_set_RELEASE;
- fn_shader_get_uniform = WebGL_shader_get_uniform_RELEASE;
- fn_shader_set_uniform_i = WebGL_shader_set_uniform_i_RELEASE;
- fn_shader_set_uniform_f = WebGL_shader_set_uniform_f_RELEASE;
- fn_shader_set_uniform_matrix = WebGL_shader_set_uniform_matrix_RELEASE;
- fn_shader_get_sampler_index = WebGL_shader_get_sampler_index_RELEASE;
- fn_shader_enable_corner_id = WebGL_shader_enable_corner_id_RELEASE;
- fn_shader_set_uniform_i_array = WebGL_shader_set_uniform_i_array_RELEASE;
- fn_shader_set_uniform_f_array = WebGL_shader_set_uniform_f_array_RELEASE;
- fn_shader_set_uniform_f_buffer = WebGL_shader_set_uniform_f_buffer_RELEASE;
- fn_shader_set_uniform_matrix_array = WebGL_shader_set_uniform_matrix_array_RELEASE;
- shaders_are_supported = WebGL_shaders_are_supported_RELEASE;
- fn_shader_get_name = WebGL_shader_get_name_RELEASE;
+ compile_if_used(shader_get_uniform, fn_shader_get_uniform = WebGL_shader_get_uniform_RELEASE);
+ compile_if_used(shader_set_uniform_i, fn_shader_set_uniform_i = WebGL_shader_set_uniform_i_RELEASE);
+ compile_if_used(shader_set_uniform_f, fn_shader_set_uniform_f = WebGL_shader_set_uniform_f_RELEASE);
+ compile_if_used(shader_set_uniform_matrix, fn_shader_set_uniform_matrix = WebGL_shader_set_uniform_matrix_RELEASE);
+ compile_if_used(shader_get_sampler_index, fn_shader_get_sampler_index = WebGL_shader_get_sampler_index_RELEASE);
+ compile_if_used(shader_enable_corner_id, fn_shader_enable_corner_id = WebGL_shader_enable_corner_id_RELEASE);
+ compile_if_used(shader_set_uniform_i_array, fn_shader_set_uniform_i_array = WebGL_shader_set_uniform_i_array_RELEASE);
+ compile_if_used(shader_set_uniform_f_array, fn_shader_set_uniform_f_array = WebGL_shader_set_uniform_f_array_RELEASE);
+ compile_if_used(shader_set_uniform_f_buffer, fn_shader_set_uniform_f_buffer = WebGL_shader_set_uniform_f_buffer_RELEASE);
+ compile_if_used(shader_set_uniform_matrix_array, fn_shader_set_uniform_matrix_array = WebGL_shader_set_uniform_matrix_array_RELEASE);
+ compile_if_used(shaders_are_supported = WebGL_shaders_are_supported_RELEASE);
+ compile_if_used(shader_get_name, fn_shader_get_name = WebGL_shader_get_name_RELEASE);
// textures
- texture_set_blending = WebGL_texture_set_blending_RELEASE;
- texture_set_repeat = WebGL_texture_set_repeat_RELEASE;
- texture_set_repeat_ext = WebGL_texture_set_repeat_ext_RELEASE;
- texture_set_interpolation = WebGL_texture_set_interpolation_RELEASE;
- texture_set_interpolation_ext = WebGL_texture_set_interpolation_ext_RELEASE;
- texture_get_repeat = WebGL_texture_get_repeat_RELEASE;
- texture_get_width = WebGL_texture_get_width_RELEASE;
- texture_get_height = WebGL_texture_get_height_RELEASE;
- texture_get_uvs = WebGL_texture_get_uvs_RELEASE;
+ compile_if_used(texture_set_blending = WebGL_texture_set_blending_RELEASE);
+ compile_if_used(texture_set_repeat = WebGL_texture_set_repeat_RELEASE);
+ compile_if_used(texture_set_repeat_ext = WebGL_texture_set_repeat_ext_RELEASE);
+ compile_if_used(texture_set_interpolation = WebGL_texture_set_interpolation_RELEASE);
+ compile_if_used(texture_set_interpolation_ext = WebGL_texture_set_interpolation_ext_RELEASE);
+ compile_if_used(texture_get_repeat = WebGL_texture_get_repeat_RELEASE);
+ compile_if_used(texture_get_width = WebGL_texture_get_width_RELEASE);
+ compile_if_used(texture_get_height = WebGL_texture_get_height_RELEASE);
+ compile_if_used(texture_get_uvs = WebGL_texture_get_uvs_RELEASE);
// alpha test
- draw_set_alpha_test = WebGL_draw_set_alpha_test_RELEASE;
- draw_set_alpha_test_ref_value = WebGL_draw_set_alpha_test_ref_value_RELEASE;
- draw_get_alpha_test = WebGL_draw_get_alpha_test_RELEASE;
- draw_get_alpha_test_ref_value = WebGL_draw_get_alpha_test_ref_value_RELEASE;
+ compile_if_used(draw_set_alpha_test = WebGL_draw_set_alpha_test_RELEASE);
+ compile_if_used(draw_set_alpha_test_ref_value = WebGL_draw_set_alpha_test_ref_value_RELEASE);
+ compile_if_used(draw_get_alpha_test = WebGL_draw_get_alpha_test_RELEASE);
+ compile_if_used(draw_get_alpha_test_ref_value = WebGL_draw_get_alpha_test_ref_value_RELEASE);
// Buffer surface stuff
- buffer_get_surface = WEBGL_buffer_get_surface;
+ compile_if_used(buffer_get_surface = WEBGL_buffer_get_surface);
+ // @if function("buffer_set_surface") || function("video_*")
buffer_set_surface = WEBGL_buffer_set_surface;
+ // @endif
//
PostInitWebGLFunctions();
}
@@ -242,7 +266,7 @@ function InitWebGLFunctions() {
///
// #############################################################################################
function InitWebGL(_canvas) {
-
+ // @if feature("gl")
var options = {
Stencil: ((g_pGMFile.Swfs !== undefined) ? true : false),
PreserveDrawingBuffer: (g_pGMFile.Options.WebGLPreserveDrawingBuffer ? true : false),
@@ -258,12 +282,6 @@ function InitWebGL(_canvas) {
if (!InitShaders()) return false;
if (!InitTextures()) return false;
if (!InitLightingEnv()) return false;
-
- g_MatrixStack = [];
- for (var i = 0; i < MATRIX_STACK_MAX; i++) {
- g_MatrixStack[i] = new Matrix();
- }
- g_MatrixSP = -1;
g_RenderTargetActive = 1;
g_pProjection = new Matrix();
@@ -274,6 +292,7 @@ function InitWebGL(_canvas) {
GR_TextureRepeat[i] = false;
}
return true;
+ // @endif gl
}
// #############################################################################################
@@ -447,7 +466,7 @@ function InitWebGLTextureGetFunctions() {
return texture;
};
- // And again for background textures
+ /*// And again for background textures
var fn_background_get_texture = background_get_texture;
background_get_texture = function(_ind) {
@@ -457,7 +476,7 @@ function InitWebGLTextureGetFunctions() {
WebGL_BindTexture(texture.TPE);
}
return texture;
- };
+ };*/
WebGL_StartFrame_RELEASE();// Call this to setup defaults..
}
@@ -516,12 +535,9 @@ function WebGL_Save_RELEASE(_storeSettings) {
g_savedWebGLState.GR_LightingEnabled = GR_LightingEnabled;
g_savedWebGLState.GR_FogParameters = new Float32Array(GR_FogParameters);
- if(g_isZeus)
- {
- g_savedWebGLState.GR_Cull=gpu_get_cullmode();
- g_savedWebGLState.GR_ZEnable=gpu_get_ztestenable();
- g_savedWebGLState.GR_ZWriteEnable=gpu_get_zwriteenable();
- }
+ g_savedWebGLState.GR_Cull=gpu_get_cullmode();
+ g_savedWebGLState.GR_ZEnable=gpu_get_ztestenable();
+ g_savedWebGLState.GR_ZWriteEnable=gpu_get_zwriteenable();
// Set to defaults
GR_3DMode = false;
@@ -560,22 +576,10 @@ function WebGL_Restore_RELEASE(_restoreSettings) {
g_webGL.SetFogData(GR_FogParameters);
// Setting either of these will flush the vertex buffer
- if (GR_3DMode || g_isZeus) {
-
-
- if(g_isZeus)
- {
- g_webGL.SetCull(g_savedWebGLState.GR_Cull);
- g_webGL.SetZEnable(g_savedWebGLState.GR_ZEnable);
- g_webGL.SetZWriteEnable(g_savedWebGLState.GR_ZWriteEnable);
- }
- else
- {
- g_webGL.SetZEnable(GR_ZEnable);
- g_webGL.SetZWriteEnable(GR_ZWriteEnable);
- g_webGL.SetCull(GR_Cull);
- }
- }
+ g_webGL.SetCull(g_savedWebGLState.GR_Cull);
+ g_webGL.SetZEnable(g_savedWebGLState.GR_ZEnable);
+ g_webGL.SetZWriteEnable(g_savedWebGLState.GR_ZWriteEnable);
+
g_webGL.SetShader(WebGL_GetDefaultShader());
}
if (_restoreSettings.RestoreState) {
@@ -868,103 +872,6 @@ function WebGL_DrawText_RELEASE(_font, _str, _x, _y, _xscale, _yscale, _angle, _
//WebGL_TextureDrawWH_RELEASE( g_webGL_textureFont, 0, 0, width, height, _x, _y, _xscale, _yscale, _angle, _col, _col, _col, _col, _alpha );
}
-// #############################################################################################
-/// Function:
-/// Push a matrix onto our stack
-///
-///
-/// In: Matrix to push onto the stack
-// #############################################################################################
-function PushMatrix(_matrix) {
-
- if (g_MatrixSP >= MATRIX_STACK_MAX) {
- return false;
- }
-
- g_MatrixSP++;
- if (g_MatrixSP == 0) {
- g_MatrixStack[g_MatrixSP] = new Matrix(_matrix);
- }
- else {
- g_MatrixStack[g_MatrixSP].Multiply(g_MatrixStack[g_MatrixSP - 1], _matrix);
- }
- return true;
-}
-
-// #############################################################################################
-/// Function:
-/// Pop the top matrix off the stack
-///
-///
-/// In:
-/// Out:
-///
-///
-// #############################################################################################
-function PopMatrix(_matrix) {
-
- if (g_MatrixSP < 0) {
- return false;
- }
-
- // Set Matrix to that currently on top
- WebGL_SetMatrix(MATRIX_WORLD, g_MatrixStack[g_MatrixSP]);
- g_MatrixSP--;
- return true;
-}
-
-// #############################################################################################
-/// Function:
-/// Clear off the matrix stack altogether
-///
-// #############################################################################################
-function MatrixStackClear() {
- g_MatrixSP = -1;
-}
-
-// #############################################################################################
-/// Function:
-/// Checks to see if the matrix stack is empty
-///
-// #############################################################################################
-function MatrixStackEmpty() {
-
- if (g_MatrixSP < 0) {
- return true;
- }
- return false;
-}
-
-// #############################################################################################
-/// Function:
-/// Set the top matrix as the current one but don't remove it
-///
-// #############################################################################################
-function SetTopMatrix() {
-
- if (g_MatrixSP < 0) {
- return false;
- }
- // Set Matrix to that currently on top
- WebGL_SetMatrix(MATRIX_WORLD, g_MatrixStack[g_MatrixSP]);
- return true;
-}
-
-
-// #############################################################################################
-/// Function:
-/// Discard the top matrix
-///
-// #############################################################################################
-function DiscardTopMatrix() {
-
- if (g_MatrixSP < 0) {
- return false;
- }
- g_MatrixSP--;
- return true;
-}
-
// #############################################################################################
/// Function:
/// Draw a simple TPage entry.
@@ -1307,7 +1214,8 @@ function WebGL_TextureDrawTiled_RELEASE( _pTPE, _x, _y, _xsc, _ysc, vtiled, htil
///
// #############################################################################################
function WebGL_DrawSWF_RELEASE(SWFDictionary, SWFTimeline, ind, xorig, yorig, x, y, xscale, yscale, angle, color, alpha, TPEs)
-{
+{
+ // @if feature("swf")
var oldColourWriteEnable = GR_ColourWriteEnable;
var oldZWriteEnable = GR_3DMode;
@@ -1458,7 +1366,8 @@ function WebGL_DrawSWF_RELEASE(SWFDictionary, SWFTimeline, ind, xorig, yorig, x,
// Restore render states
g_webGL.SetStencilEnable(false);
g_webGL.SetColorWriteEnable(oldColourWriteEnable.red, oldColourWriteEnable.green, oldColourWriteEnable.blue, oldColourWriteEnable.alpha);
- g_webGL.SetZWriteEnable(oldZWriteEnable);
+ g_webGL.SetZWriteEnable(oldZWriteEnable);
+ // @endif
}
// #############################################################################################
@@ -1468,6 +1377,8 @@ function WebGL_DrawSWF_RELEASE(SWFDictionary, SWFTimeline, ind, xorig, yorig, x,
// #############################################################################################
function WebGL_DrawSWFObject_RELEASE(SWFDictionaryItems, _pObject, _pPostMat, _pGradTransMat, _mulcolour, _colvals, _aa, TPEs)
{
+ var numtris = 0;
+ // @if feature("swf")
// Work out alpha colour for AA
var transcolvals = [];
transcolvals[0] = _colvals[0],
@@ -1493,7 +1404,6 @@ function WebGL_DrawSWFObject_RELEASE(SWFDictionaryItems, _pObject, _pPostMat, _p
transcoladd[i] = _pObject.colTransAddZeroAlpha[i];
}
- var numtris = 0;
// Could potentially optimise this a bit by collapsing all the style groups into a single contiguous list, storing an explicit colour for each triangle vertex and chaining untextured geometry together
// We'd still have to maintain rendering order so we couldn't chain *all* untextured geometry - just contiguous sections
// If we also precalculate how long each run is we could reduce the amount of conditionals and calls to AllocVerts
@@ -1692,6 +1602,7 @@ function WebGL_DrawSWFObject_RELEASE(SWFDictionaryItems, _pObject, _pPostMat, _p
}
}
}
+ // @endif
return numtris;
}
@@ -1704,6 +1615,8 @@ function WebGL_DrawSWFObject_RELEASE(SWFDictionaryItems, _pObject, _pPostMat, _p
function WebGL_Draw_BitmapGradientSWFShape(
SWFDictionaryItems, _pObject, _filltype, _pFillStyleData, _pSubShape, _pGradTransMat, _combinedMat, _colvals, _transcolvals, _mulcolour, _colmul, _coladd, _transcoladd, _aa, TPEs)
{
+ var numtris = 0;
+ // @if feature("swf")
var pCoords,
pColours,
pUVs,
@@ -1806,7 +1719,6 @@ function WebGL_Draw_BitmapGradientSWFShape(
}
}
- var numtris = 0;
if (pTPE !== null)
{
if (!pTPE.texture.webgl_textureid) {
@@ -1983,6 +1895,7 @@ function WebGL_Draw_BitmapGradientSWFShape(
currVert += stride;
}
}
+ // @endif
return numtris;
}
@@ -1992,7 +1905,8 @@ function WebGL_Draw_BitmapGradientSWFShape(
///
// #############################################################################################
function WebGL_Draw_SolidSWFShape(_pObject, _pFillStyleData, _pSubShape, _combinedMat, _colvals, _transcolvals, _colmul, _coladd, _transcoladd, _aa) {
-
+ var numtris = 0;
+ // @if feature("swf")
var aascale = 1.0;
if (_aa) {
aascale = WebGL_BuildAAScale(_pObject, _combinedMat) * GR_SWFAAScale;
@@ -2007,7 +1921,6 @@ function WebGL_Draw_SolidSWFShape(_pObject, _pFillStyleData, _pSubShape, _combin
// Get simpler access
var pFillData = _pFillStyleData,
col = pFillData.col,
- numtris = 0,
t = 0;
// Multiply our material colour and mul colour together using good old fashioned fixed point maths
@@ -2175,6 +2088,7 @@ function WebGL_Draw_SolidSWFShape(_pObject, _pFillStyleData, _pSubShape, _combin
currVert += stride;
}
+ // @endif
return numtris;
}
@@ -2184,7 +2098,7 @@ function WebGL_Draw_SolidSWFShape(_pObject, _pFillStyleData, _pSubShape, _combin
///
// #############################################################################################
function WebGL_BuildAAScale(_pObject, _combinedMat) {
-
+ // @if feature("swf")
// Work out the AA scaling required
if (GR_SWFAAEnabled) {
@@ -2270,6 +2184,7 @@ function WebGL_BuildAAScale(_pObject, _combinedMat) {
_pObject.aascale = aascale;
return aascale;
}
+ // @endif swf
return 1.0;
}
@@ -3128,31 +3043,6 @@ function WebGL_draw_triangle_RELEASE(_x1, _y1, _x2, _y2, _x3, _y3, _outline) {
pColours[v0] = pColours[v1] = pColours[v2] = pColours[v3] = ((g_GlobalAlpha * 255.0) << 24) | g_GlobalColour;
}
-// #############################################################################################
-/// Function:
-/// Draw a rectangle with a gradient
-///
-///
-/// In: Top X coordinate
-/// Top Y coordinate
-/// Bottom X coordinate
-/// Bottom X coordinate
-/// Start colour of the rect as a number
-/// End colour of the rect as a number
-/// Whether or not the gradient should be vertical (or horizontal)
-/// Whether or not to draw the rect as an outline
-///
-// #############################################################################################
-function WebGL_draw_rectangle_gradient_RELEASE(_x1, _y1, _x2, _y2, _col1, _col2, _vert, _outline) {
-
- if (_vert) {
- WebGL_draw_rectangle_color_RELEASE(_x1, _y1, _x2, _y2, _col1, _col1, _col2, _col2, _outline);
- }
- else {
- WebGL_draw_rectangle_color_RELEASE(_x1, _y1, _x2, _y2, _col1, _col2, _col2, _col1, _outline);
- }
-}
-
// #############################################################################################
/// Function:
/// Plot a single point
@@ -3813,7 +3703,7 @@ function DrawIt_Color(tex,
var z =(GR_Depth);
- var prim = WebGL_translate_primitive_builder_type(PrimType_TRISTRIP);
+ var prim = yyGL.PRIM_TRISTRIP;
var vvv = g_webGL.AllocVerts(prim, tex, g_webGL.VERTEX_FORMAT_2D, 6);
@@ -4613,12 +4503,7 @@ function WebGL_texture_set_stage_RELEASE(_stage, _texture) {
///
// #############################################################################################
function WebGL_shader_is_compiled_RELEASE(_shaderIndex) {
-
- _shaderIndex = yyGetInt32(_shaderIndex);
- if (g_shaderPrograms[_shaderIndex] && g_shaderPrograms[_shaderIndex].program) {
- return 1;
- }
- return 0;
+ return g_shaderPrograms[yyGetInt32(_shaderIndex)]?.program ? 1 : 0;
}
@@ -4704,17 +4589,12 @@ function WebGL_shader_set_uniform_matrix_RELEASE(_handle, _shaderData) {
///
// #############################################################################################
function WebGL_shader_get_sampler_index_RELEASE(_shaderIndex, _texture) {
-
- _shaderIndex = yyGetInt32(_shaderIndex);
- if (g_shaderPrograms[_shaderIndex]) {
-
- var shaderProgram = g_shaderPrograms[_shaderIndex];
- if (shaderProgram) {
- for (var i = 0; i < shaderProgram.texture_stages.length; i++) {
-
- if (shaderProgram.texture_stages[i] == _texture) {
- return Number(i);
- }
+ var shaderProgram = g_shaderPrograms[yyGetInt32(_shaderIndex)];
+ if (shaderProgram) {
+ for (var i = 0; i < shaderProgram.texture_stages.length; i++) {
+
+ if (shaderProgram.texture_stages[i] == _texture) {
+ return Number(i);
}
}
}
@@ -5006,6 +4886,7 @@ function WebGL_SetMatrix(_type, _matrix) {
g_ViewFrustumDirty |= (_type == MATRIX_VIEW || _type == MATRIX_PROJECTION);
+ // @if feature("gl")
if(g_webGL==null)
return;
switch (_type) {
@@ -5022,7 +4903,8 @@ function WebGL_SetMatrix(_type, _matrix) {
g_webGL.SetWorldMatrix(g_Matrix[_type]);
break;
}
- g_webGL.Flush();
+ g_webGL.Flush();
+ // @endif gl
}
// #############################################################################################
diff --git a/scripts/zlib/deflate.min.js b/scripts/zlib/deflate.min.js
index 510a86d4..976694b4 100644
--- a/scripts/zlib/deflate.min.js
+++ b/scripts/zlib/deflate.min.js
@@ -1,3 +1,4 @@
+// @if function("buffer_compress")
/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */(function() {'use strict';var n=void 0,w=!0,aa=this;function ba(f,d){var c=f.split("."),e=aa;!(c[0]in e)&&e.execScript&&e.execScript("var "+c[0]);for(var b;c.length&&(b=c.shift());)!c.length&&d!==n?e[b]=d:e=e[b]?e[b]:e[b]={}};var C="undefined"!==typeof Uint8Array&&"undefined"!==typeof Uint16Array&&"undefined"!==typeof Uint32Array&&"undefined"!==typeof DataView;function K(f,d){this.index="number"===typeof d?d:0;this.e=0;this.buffer=f instanceof(C?Uint8Array:Array)?f:new (C?Uint8Array:Array)(32768);if(2*this.buffer.length<=this.index)throw Error("invalid index");this.buffer.length<=this.index&&ca(this)}function ca(f){var d=f.buffer,c,e=d.length,b=new (C?Uint8Array:Array)(e<<1);if(C)b.set(d);else for(c=0;c>>8&255]<<16|L[f>>>16&255]<<8|L[f>>>24&255])>>32-d:L[f]>>8-d);if(8>d+a)g=g<>d-m-1&1,8===++a&&(a=0,e[b++]=L[g],g=0,b===e.length&&(e=ca(this)));e[b]=g;this.buffer=e;this.e=a;this.index=b};K.prototype.finish=function(){var f=this.buffer,d=this.index,c;0M;++M){for(var N=M,S=N,ea=7,N=N>>>1;N;N>>>=1)S<<=1,S|=N&1,--ea;da[M]=(S<>>0}var L=da;function ia(f){this.buffer=new (C?Uint16Array:Array)(2*f);this.length=0}ia.prototype.getParent=function(f){return 2*((f-2)/4|0)};ia.prototype.push=function(f,d){var c,e,b=this.buffer,a;c=this.length;b[this.length++]=d;for(b[this.length++]=f;0b[e])a=b[c],b[c]=b[e],b[e]=a,a=b[c+1],b[c+1]=b[e+1],b[e+1]=a,c=e;else break;return this.length};
@@ -24,3 +25,4 @@ function qa(f){var d=new (C?Uint16Array:Array)(f.length),c=[],e=[],b=0,a,g,m,k;a
Ka.prototype.f=function(){var f,d,c,e,b,a,g=0;a=this.a;switch(8){case 8:f=Math.LOG2E*Math.log(32768)-8;break;default:throw Error("invalid compression method");}d=f<<4|8;a[g++]=d;switch(8){case 8:switch(this.d){case V.NONE:e=0;break;case V.h:e=1;break;case V.g:e=2;break;default:throw Error("unsupported compression type");}break;default:throw Error("invalid compression method");}c=e<<6|0;a[g++]=c|31-(256*d+c)%31;var m=this.input;if("string"===typeof m){var k=m.split(""),p,t;p=0;for(t=k.length;p>>0;m=k}for(var u=1,l=0,h=m.length,q,s=0;0>>0;this.j.c=g;a=this.j.f();g=a.length;C&&(a=new Uint8Array(a.buffer),a.length<=g+4&&(this.a=new Uint8Array(a.length+4),this.a.set(a),a=this.a),a=a.subarray(0,g+4));a[g++]=b>>24&255;a[g++]=b>>16&255;a[g++]=b>>8&255;a[g++]=b&255;return a};ba("Zlib.Deflate",Ka);ba("Zlib.Deflate.compress",function(f,d){return(new Ka(f,d)).f()});ba("Zlib.Deflate.prototype.compress",Ka.prototype.f);var Ma={NONE:V.NONE,FIXED:V.h,DYNAMIC:V.g},Na,Oa,W,Pa;if(Object.keys)Na=Object.keys(Ma);else for(Oa in Na=[],W=0,Ma)Na[W++]=Oa;W=0;for(Pa=Na.length;Wa&&(a=b[p]),b[p]>=1;for(t=l;t>>=1;switch(b){case 0:var d=this.input,a=this.a,c=this.c,f=this.b,e=n,g=n,h=n,k=c.length,l=n;this.d=this.f=0;e=d[a++];e===n&&m(Error("invalid uncompressed block header: LEN (first byte)"));g=e;e=d[a++];e===n&&m(Error("invalid uncompressed block header: LEN (second byte)"));g|=e<<8;e=d[a++];e===n&&m(Error("invalid uncompressed block header: NLEN (first byte)"));h=e;e=d[a++];e===n&&m(Error("invalid uncompressed block header: NLEN (second byte)"));h|=
@@ -13,4 +14,5 @@ w.prototype.e=function(){var b=new (u?Uint8Array:Array)(this.b-32768),d=this.b-3
w.prototype.z=function(b){var d,a=this.input.length/this.a+1|0,c,f,e,g=this.input,h=this.c;b&&("number"===typeof b.p&&(a=b.p),"number"===typeof b.u&&(a+=b.u));2>a?(c=(g.length-this.a)/this.o[2],e=258*(c/2)|0,f=ed&&(this.c.length=d),b=this.c);return this.buffer=b};function U(b,d){var a,c;this.input=b;this.a=0;if(d||!(d={}))d.index&&(this.a=d.index),d.verify&&(this.A=d.verify);a=b[this.a++];c=b[this.a++];switch(a&15){case V:this.method=V;break;default:m(Error("unsupported compression method"))}0!==((a<<8)+c)%31&&m(Error("invalid fcheck flag:"+((a<<8)+c)%31));c&32&&m(Error("fdict flag is not supported"));this.q=new w(b,{index:this.a,bufferSize:d.bufferSize,bufferType:d.bufferType,resize:d.resize})}
-U.prototype.k=function(){var b=this.input,d,a;d=this.q.k();this.a=this.q.a;if(this.A){a=(b[this.a++]<<24|b[this.a++]<<16|b[this.a++]<<8|b[this.a++])>>>0;var c=d;if("string"===typeof c){var f=c.split(""),e,g;e=0;for(g=f.length;e>>0;c=f}for(var h=1,k=0,l=c.length,q,p=0;0>>0&&m(Error("invalid adler-32 checksum"))}return d};var V=8;s("Zlib.Inflate",U);s("Zlib.Inflate.prototype.decompress",U.prototype.k);var W={ADAPTIVE:z.s,BLOCK:z.t},X,Y,Z,$;if(Object.keys)X=Object.keys(W);else for(Y in X=[],Z=0,W)X[Z++]=Y;Z=0;for($=X.length;Z<$;++Z)Y=X[Z],s("Zlib.Inflate.BufferType."+Y,W[Y]);}).call(this); //@ sourceMappingURL=inflate.min.js.map
\ No newline at end of file
+U.prototype.k=function(){var b=this.input,d,a;d=this.q.k();this.a=this.q.a;if(this.A){a=(b[this.a++]<<24|b[this.a++]<<16|b[this.a++]<<8|b[this.a++])>>>0;var c=d;if("string"===typeof c){var f=c.split(""),e,g;e=0;for(g=f.length;e>>0;c=f}for(var h=1,k=0,l=c.length,q,p=0;0>>0&&m(Error("invalid adler-32 checksum"))}return d};var V=8;s("Zlib.Inflate",U);s("Zlib.Inflate.prototype.decompress",U.prototype.k);var W={ADAPTIVE:z.s,BLOCK:z.t},X,Y,Z,$;if(Object.keys)X=Object.keys(W);else for(Y in X=[],Z=0,W)X[Z++]=Y;Z=0;for($=X.length;Z<$;++Z)Y=X[Z],s("Zlib.Inflate.BufferType."+Y,W[Y]);}).call(this); //@ sourceMappingURL=inflate.min.js.map
+// @endif