diff --git a/.gitignore b/.gitignore
index ec822f57..bee4df7e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,5 +2,6 @@ export/
dump/
latest/windows/obj/
latest/windows/haxe/
-.vscode/
+.vscode/*
+!.vscode/settings.json
.haxelib/
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 00000000..5eee2d85
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,4 @@
+{
+ "editor.detectIndentation": false,
+ "editor.insertSpaces": false
+}
\ No newline at end of file
diff --git a/assets/images/editors/charter/note.png b/assets/images/editors/charter/note.png
new file mode 100644
index 00000000..c30bc664
Binary files /dev/null and b/assets/images/editors/charter/note.png differ
diff --git a/assets/images/editors/ui/selection.xml b/assets/images/editors/ui/selection.xml
new file mode 100644
index 00000000..8fab7d3d
--- /dev/null
+++ b/assets/images/editors/ui/selection.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/assets/shaders/engine/README.txt b/assets/shaders/engine/README.txt
new file mode 100644
index 00000000..d5534429
--- /dev/null
+++ b/assets/shaders/engine/README.txt
@@ -0,0 +1,3 @@
+THOSE SHADERS ARE USED INTERNALLY BY THE ENGINE
+
+MODIFY THEM AT YOUR OWN RISK!! IF IT CRASHES IT AINT MY FAULT
\ No newline at end of file
diff --git a/assets/shaders/circleProfilePicture.frag b/assets/shaders/engine/circleProfilePicture.frag
similarity index 100%
rename from assets/shaders/circleProfilePicture.frag
rename to assets/shaders/engine/circleProfilePicture.frag
diff --git a/assets/shaders/editorBlur.frag b/assets/shaders/engine/editorBlur.frag
similarity index 100%
rename from assets/shaders/editorBlur.frag
rename to assets/shaders/engine/editorBlur.frag
diff --git a/assets/shaders/updaterShader.frag b/assets/shaders/engine/updaterShader.frag
similarity index 100%
rename from assets/shaders/updaterShader.frag
rename to assets/shaders/engine/updaterShader.frag
diff --git a/buildnumber.txt b/buildnumber.txt
index b12dd8d9..4cbaed0a 100644
--- a/buildnumber.txt
+++ b/buildnumber.txt
@@ -1,5 +1 @@
-<<<<<<< HEAD
-2632
-=======
2651
->>>>>>> 139d5daefa486263cbcb36ac18995d654dfcf2a8
diff --git a/source/away3d/core/managers/Stage3DProxy.hx b/source/away3d/core/managers/Stage3DProxy.hx
index 63edb50b..057da05b 100644
--- a/source/away3d/core/managers/Stage3DProxy.hx
+++ b/source/away3d/core/managers/Stage3DProxy.hx
@@ -51,12 +51,12 @@ class Stage3DProxy extends EventDispatcher
public var bufferClear(get, set):Bool;
public var mouse3DManager(get, set):Mouse3DManager;
public var touch3DManager(get, set):Touch3DManager;
-
+
private static var _frameEventDriver:Shape = new Shape();
@:allow(away3d) private var _context3D:Context3D;
@:allow(away3d) private var _stage3DIndex:Int = -1;
-
+
private var _usesSoftwareRendering:Bool;
private var _profile:String;
private var _stage3D:Stage3D;
@@ -83,46 +83,46 @@ class Stage3DProxy extends EventDispatcher
private var _bufferClear:Bool;
private var _mouse3DManager:Mouse3DManager;
private var _touch3DManager:Touch3DManager;
-
+
private function notifyViewportUpdated():Void
{
if (_viewportDirty)
return;
-
+
_viewportDirty = true;
-
+
if (!hasEventListener(Stage3DEvent.VIEWPORT_UPDATED))
return;
-
+
//TODO: investigate bug causing coercion error
//if (!_viewportUpdated)
_viewportUpdated = new Stage3DEvent(Stage3DEvent.VIEWPORT_UPDATED);
-
+
dispatchEvent(_viewportUpdated);
}
-
+
private function notifyEnterFrame():Void
{
if (!hasEventListener(Event.ENTER_FRAME))
return;
-
+
if (_enterFrame == null)
_enterFrame = new Event(Event.ENTER_FRAME);
-
+
dispatchEvent(_enterFrame);
}
-
+
private function notifyExitFrame():Void
{
if (!hasEventListener(Event.EXIT_FRAME))
return;
-
+
if (_exitFrame == null)
_exitFrame = new Event(Event.EXIT_FRAME);
-
+
dispatchEvent(_exitFrame);
}
-
+
/**
* Creates a Stage3DProxy object. This method should not be called directly. Creation of Stage3DProxy objects should
* be handled by Stage3DManager.
@@ -134,7 +134,7 @@ class Stage3DProxy extends EventDispatcher
public function new(stage3DIndex:Int, stage3D:Stage3D, stage3DManager:Stage3DManager, forceSoftware:Bool = false, profile:String = "baseline")
{
vertexBufferCount = indexBufferCount = drawTriangleCount = 0;
-
+
_stage3DIndex = stage3DIndex;
_stage3D = stage3D;
_stage3D.x = 0;
@@ -143,15 +143,15 @@ class Stage3DProxy extends EventDispatcher
_stage3DManager = stage3DManager;
_viewPort = new Rectangle();
_enableDepthAndStencil = true;
-
+
super();
-
+
// whatever happens, be sure this has highest priority
_stage3D.addEventListener(Event.CONTEXT3D_CREATE, onContext3DUpdate, false, 1000, false);
-
+
this.forceSoftware = forceSoftware;
this._profile = profile;
-
+
if (_stage3D.context3D != null) {
onContext3DUpdate(null);
}
@@ -159,14 +159,14 @@ class Stage3DProxy extends EventDispatcher
requestContext(forceSoftware, _profile);
}
}
-
+
private var forceSoftware:Bool;
-
+
private function get_profile():String
{
return _profile;
}
-
+
/**
* Disposes the Stage3DProxy object, freeing the Context3D attached to the Stage3D.
*/
@@ -193,22 +193,22 @@ class Stage3DProxy extends EventDispatcher
if(backBufferHeight<50) backBufferHeight = 50;
var oldWidth:Int = _backBufferWidth;
var oldHeight:Int = _backBufferHeight;
-
+
_backBufferWidth = backBufferWidth;
_backBufferHeight = backBufferHeight;
_viewPort.width = backBufferWidth;
_viewPort.height = backBufferHeight;
-
+
if (oldWidth != _backBufferWidth || oldHeight != _backBufferHeight)
notifyViewportUpdated();
-
+
_antiAlias = antiAlias;
_enableDepthAndStencil = enableDepthAndStencil;
if (_context3D != null)
_context3D.configureBackBuffer(backBufferWidth, backBufferHeight, antiAlias, enableDepthAndStencil, true, true);
}
-
+
/*
* Indicates whether the depth and stencil buffer is used
*/
@@ -216,24 +216,24 @@ class Stage3DProxy extends EventDispatcher
{
return _enableDepthAndStencil;
}
-
+
private function set_enableDepthAndStencil(enableDepthAndStencil:Bool):Bool
{
_enableDepthAndStencil = enableDepthAndStencil;
_backBufferDirty = true;
return enableDepthAndStencil;
}
-
+
private function get_renderTarget():TextureBase
{
return _renderTarget;
}
-
+
private function get_renderSurfaceSelector():Int
{
return _renderSurfaceSelector;
}
-
+
public function setRenderTarget(target:TextureBase, enableDepthAndStencil:Bool = false, surfaceSelector:Int = 0):Void
{
if (_renderTarget == target && surfaceSelector == _renderSurfaceSelector && _enableDepthAndStencil == enableDepthAndStencil)
@@ -241,13 +241,13 @@ class Stage3DProxy extends EventDispatcher
_renderTarget = target;
_renderSurfaceSelector = surfaceSelector;
_enableDepthAndStencil = enableDepthAndStencil;
-
+
if (target != null)
_context3D.setRenderToTexture(target, enableDepthAndStencil, _antiAlias, surfaceSelector);
else
_context3D.setRenderToBackBuffer();
}
-
+
/*
* Clear and reset the back buffer when using a shared context
*/
@@ -255,21 +255,21 @@ class Stage3DProxy extends EventDispatcher
{
if (_context3D == null)
return;
-
+
if (_backBufferDirty) {
configureBackBuffer(_backBufferWidth, _backBufferHeight, _antiAlias, _enableDepthAndStencil);
_backBufferDirty = false;
}
-
+
_context3D.clear(
((_color >> 16) & 0xff)/255.0,
((_color >> 8) & 0xff)/255.0,
(_color & 0xff)/255.0,
((_color >> 24) & 0xff)/255.0);
-
+
_bufferClear = true;
}
-
+
/*
* Display the back rendering buffer
*/
@@ -277,15 +277,15 @@ class Stage3DProxy extends EventDispatcher
{
if (_context3D == null)
return;
-
+
_context3D.present();
-
+
_activeProgram3D = null;
-
+
if (_mouse3DManager != null)
_mouse3DManager.fireMouseEvents();
}
-
+
/**
* Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event. Special case for enterframe and exitframe events - will switch Stage3DProxy into automatic render mode.
* You can register event listeners on all nodes in the display list for a specific type of event, phase, and priority.
@@ -299,11 +299,11 @@ class Stage3DProxy extends EventDispatcher
override public function addEventListener(type:String, listener:Dynamic -> Void, useCapture:Bool = false, priority:Int = 0, useWeakReference:Bool = false):Void
{
super.addEventListener(type, listener, useCapture, priority, useWeakReference);
-
+
if ((type == Event.ENTER_FRAME || type == Event.EXIT_FRAME) && !_frameEventDriver.hasEventListener(Event.ENTER_FRAME))
_frameEventDriver.addEventListener(Event.ENTER_FRAME, onEnterFrame, useCapture, priority, useWeakReference);
}
-
+
/**
* Removes a listener from the EventDispatcher object. Special case for enterframe and exitframe events - will switch Stage3DProxy out of automatic render mode.
* If there is no matching listener registered with the EventDispatcher object, a call to this method has no effect.
@@ -315,24 +315,24 @@ class Stage3DProxy extends EventDispatcher
override public function removeEventListener(type:String, listener:Dynamic -> Void, useCapture:Bool = false):Void
{
super.removeEventListener(type, listener, useCapture);
-
+
// Remove the main rendering listener if no EnterFrame listeners remain
if (!hasEventListener(Event.ENTER_FRAME) && !hasEventListener(Event.EXIT_FRAME) && _frameEventDriver.hasEventListener(Event.ENTER_FRAME))
_frameEventDriver.removeEventListener(Event.ENTER_FRAME, onEnterFrame, useCapture);
}
-
+
private function get_scissorRect():Rectangle
{
return _scissorRect;
}
-
+
private function set_scissorRect(value:Rectangle):Rectangle
{
_scissorRect = value;
_context3D.setScissorRectangle(_scissorRect);
return value;
}
-
+
/**
* The index of the Stage3D which is managed by this instance of Stage3DProxy.
*/
@@ -340,7 +340,7 @@ class Stage3DProxy extends EventDispatcher
{
return _stage3DIndex;
}
-
+
/**
* The base Stage3D object associated with this proxy.
*/
@@ -348,7 +348,7 @@ class Stage3DProxy extends EventDispatcher
{
return _stage3D;
}
-
+
/**
* The Context3D object associated with the given Stage3D object.
*/
@@ -356,7 +356,7 @@ class Stage3DProxy extends EventDispatcher
{
return _context3D;
}
-
+
/**
* The driver information as reported by the Context3D object (if any)
*/
@@ -364,7 +364,7 @@ class Stage3DProxy extends EventDispatcher
{
return (_context3D != null)? _context3D.driverInfo : null;
}
-
+
/**
* Indicates whether the Stage3D managed by this proxy is running in software mode.
* Remember to wait for the CONTEXT3D_CREATED event before checking this property,
@@ -374,7 +374,7 @@ class Stage3DProxy extends EventDispatcher
{
return _usesSoftwareRendering;
}
-
+
/**
* The x position of the Stage3D.
*/
@@ -382,18 +382,18 @@ class Stage3DProxy extends EventDispatcher
{
return _stage3D.x;
}
-
+
private function set_x(value:Float):Float
{
if (_viewPort.x == value)
return value;
-
+
_stage3D.x = _viewPort.x = value;
-
+
notifyViewportUpdated();
return value;
}
-
+
/**
* The y position of the Stage3D.
*/
@@ -401,18 +401,18 @@ class Stage3DProxy extends EventDispatcher
{
return _stage3D.y;
}
-
+
private function set_y(value:Float):Float
{
if (_viewPort.y == value)
return value;
-
+
_stage3D.y = _viewPort.y = value;
-
+
notifyViewportUpdated();
return value;
}
-
+
/**
* The width of the Stage3D.
*/
@@ -420,7 +420,7 @@ class Stage3DProxy extends EventDispatcher
{
return _backBufferWidth;
}
-
+
private function set_width(width:Int):Int
{
if (_viewPort.width == width)
@@ -433,7 +433,7 @@ class Stage3DProxy extends EventDispatcher
notifyViewportUpdated();
return width;
}
-
+
/**
* The height of the Stage3D.
*/
@@ -441,7 +441,7 @@ class Stage3DProxy extends EventDispatcher
{
return _backBufferHeight;
}
-
+
private function set_height(height:Int):Int
{
if (_viewPort.height == height)
@@ -450,11 +450,11 @@ class Stage3DProxy extends EventDispatcher
if(height<50) height = 50;
_viewPort.height = _backBufferHeight = height;
_backBufferDirty = true;
-
+
notifyViewportUpdated();
return height;
}
-
+
/**
* The antiAliasing of the Stage3D.
*/
@@ -462,24 +462,24 @@ class Stage3DProxy extends EventDispatcher
{
return _antiAlias;
}
-
+
private function set_antiAlias(antiAlias:Int):Int
{
_antiAlias = antiAlias;
_backBufferDirty = true;
return antiAlias;
}
-
+
/**
* A viewPort rectangle equivalent of the Stage3D size and position.
*/
private function get_viewPort():Rectangle
{
_viewportDirty = false;
-
+
return _viewPort;
}
-
+
/**
* The background color of the Stage3D.
*/
@@ -487,13 +487,13 @@ class Stage3DProxy extends EventDispatcher
{
return _color;
}
-
+
private function set_color(color:Int):Int
{
_color = color;
return color;
}
-
+
/**
* The visibility of the Stage3D.
*/
@@ -501,13 +501,13 @@ class Stage3DProxy extends EventDispatcher
{
return _stage3D.visible;
}
-
+
private function set_visible(value:Bool):Bool
{
_stage3D.visible = value;
return value;
}
-
+
/**
* The freshly cleared state of the backbuffer before any rendering
*/
@@ -515,13 +515,13 @@ class Stage3DProxy extends EventDispatcher
{
return _bufferClear;
}
-
+
private function set_bufferClear(newBufferClear:Bool):Bool
{
_bufferClear = newBufferClear;
return newBufferClear;
}
-
+
/*
* Access to fire mouseevents across multiple layered view3D instances
*/
@@ -529,24 +529,24 @@ class Stage3DProxy extends EventDispatcher
{
return _mouse3DManager;
}
-
+
private function set_mouse3DManager(value:Mouse3DManager):Mouse3DManager
{
_mouse3DManager = value;
return value;
}
-
+
private function get_touch3DManager():Touch3DManager
{
return _touch3DManager;
}
-
+
private function set_touch3DManager(value:Touch3DManager):Touch3DManager
{
_touch3DManager = value;
return value;
}
-
+
/**
* Frees the Context3D associated with this Stage3DProxy.
*/
@@ -554,11 +554,11 @@ class Stage3DProxy extends EventDispatcher
{
if (_context3D != null) {
dispatchEvent(new Stage3DEvent(Stage3DEvent.CONTEXT3D_DISPOSED));
- _context3D.dispose();
+ _context3D.dispose();
}
_context3D = null;
}
-
+
/*
* Called whenever the Context3D is retrieved or lost.
* @param event The event dispatched.
@@ -569,7 +569,7 @@ class Stage3DProxy extends EventDispatcher
var hadContext:Bool = (_context3D != null);
_context3D = _stage3D.context3D;
_context3D.enableErrorChecking = Debug.active;
-
+
_usesSoftwareRendering = (_context3D.driverInfo.indexOf('Software') == 0);
// Only configure back buffer if width and height have been set,
@@ -577,15 +577,15 @@ class Stage3DProxy extends EventDispatcher
// invoked for the first time.
if (_backBufferWidth > 0 && _backBufferHeight > 0)
_context3D.configureBackBuffer(_backBufferWidth, _backBufferHeight, _antiAlias, _enableDepthAndStencil, true, true);
-
+
// Dispatch the appropriate event depending on whether context was
// created for the first time or recreated after a device loss.
dispatchEvent(new Stage3DEvent(hadContext? Stage3DEvent.CONTEXT3D_RECREATED : Stage3DEvent.CONTEXT3D_CREATED));
-
+
} else
throw new Error("Rendering context lost!");
}
-
+
/**
* Requests a Context3D object to attach to the managed Stage3D.
*/
@@ -598,7 +598,7 @@ class Stage3DProxy extends EventDispatcher
if (!_usesSoftwareRendering)
_usesSoftwareRendering = forceSoftware;
_profile = profile;
-
+
// ugly stuff for backward compatibility
var renderMode:Context3DRenderMode = forceSoftware? Context3DRenderMode.SOFTWARE : Context3DRenderMode.AUTO;
if (profile == "baseline")
@@ -610,10 +610,10 @@ class Stage3DProxy extends EventDispatcher
throw "An error occurred creating a context using the given profile. Profiles are not supported for the SDK this was compiled with.";
}
}
-
+
_contextRequested = true;
}
-
+
/**
* The Enter_Frame handler for processing the proxy.ENTER_FRAME and proxy.EXIT_FRAME event handlers.
* Typically the proxy.ENTER_FRAME listener would render the layers for this Stage3D instance.
@@ -622,20 +622,20 @@ class Stage3DProxy extends EventDispatcher
{
if (_context3D == null)
return;
-
+
// Clear the stage3D instance
clear();
-
+
//notify the enterframe listeners
notifyEnterFrame();
-
+
// Call the present() to render the frame
present();
-
+
//notify the exitframe listeners
notifyExitFrame();
}
-
+
public function recoverFromDisposal():Bool
{
if (_context3D == null)
@@ -647,29 +647,29 @@ class Stage3DProxy extends EventDispatcher
}
return true;
}
-
+
public function clearDepthBuffer():Void
{
if (_context3D == null)
return;
_context3D.clear(0, 0, 0, 1, 1, 0, cast Context3DClearMask.DEPTH);
}
-
+
/*
Moving all creation methods here, so we can trace the usages of vertexbuffers or indexbuffers.
Flash will throw the ERROR, when the vertexbuffer creation reached 4096..
*/
-
+
public static var vertexBufferCount(default, default) : UInt;
public static var indexBufferCount(default, default) : UInt;
public static var drawTriangleCount(default, default) : UInt;
-
+
private static var _vbUploadCount : UInt = 0;
private static var _ibUploadCount : UInt = 0;
-
+
private static var _bmpUploadCount : UInt = 0;
private static var _atfUploadCount : UInt = 0;
-
+
public function createVertexBuffer(numVertices:Int, data32PerVertex:Int):VertexBuffer3D
{
vertexBufferCount++;
@@ -681,31 +681,31 @@ class Stage3DProxy extends EventDispatcher
vb.dispose();
vertexBufferCount--;
}
-
+
public function createIndexBuffer(numIndices:Int):IndexBuffer3D
{
indexBufferCount++;
return _context3D.createIndexBuffer(numIndices);
}
-
+
public static function disposeIndexBuffer(ib:IndexBuffer3D):Void
{
ib.dispose();
indexBufferCount--;
}
-
+
public function drawTriangles(indexBuffer:IndexBuffer3D, firstIndex:Int = 0, numTriangles:Int = -1)
{
drawTriangleCount++;
_context3D.drawTriangles(indexBuffer, firstIndex, numTriangles);
}
-
+
public static function uploadVertexBufferFromVector(vb:VertexBuffer3D, data:Vector, startVertex:Int, numVertices:Int):Void
{
vb.uploadFromVector(data, startVertex, numVertices);
_vbUploadCount++;
}
-
+
public static function uploadIndexBufferFromVector(ib:IndexBuffer3D, data:Vector, startOffset:Int, count:Int):Void
{
ib.uploadFromVector(data, startOffset, count);
diff --git a/source/flx3d/Flx3DCamera.hx b/source/flx3d/Flx3DCamera.hx
index 4b153819..d81fc75d 100644
--- a/source/flx3d/Flx3DCamera.hx
+++ b/source/flx3d/Flx3DCamera.hx
@@ -40,7 +40,6 @@ class Flx3DCamera extends FlxCamera {
super(X, Y, Width, Height, DefaultZoom);
__cur3DStageID = __3DIDS++;
-
view = new View3D();
view.width = this.width;
view.height = this.height;
diff --git a/source/flx3d/Flx3DUtil.hx b/source/flx3d/Flx3DUtil.hx
index 53d6bf44..f23788ae 100644
--- a/source/flx3d/Flx3DUtil.hx
+++ b/source/flx3d/Flx3DUtil.hx
@@ -7,7 +7,7 @@ import flixel.FlxG;
/**
* @author lunarclient
* @see https://twitter.com/lunarcleint
- *
+ *
* Help from Ne_Eo
* @see https://twitter.com/Ne_Eo_Twitch
*/
diff --git a/source/flxanimate/frames/FlxAnimateFrames.hx b/source/flxanimate/frames/FlxAnimateFrames.hx
index b61a3282..0e91db5a 100644
--- a/source/flxanimate/frames/FlxAnimateFrames.hx
+++ b/source/flxanimate/frames/FlxAnimateFrames.hx
@@ -38,14 +38,14 @@ class FlxAnimateFrames extends FlxAtlasFrames
public var parents:Array;
/**
* Parses the spritemaps into small sprites to use in the animation.
- *
+ *
* @param Path Where the Sprites are, normally you use it once when calling FlxAnimate already
* @return new sliced limbs for you to use ;)
*/
public static function fromTextureAtlas(Path:String):FlxAtlasFrames
{
var frames:FlxAnimateFrames = new FlxAnimateFrames();
-
+
if (zip != null || haxe.io.Path.extension(Path) == "zip")
{
#if html5
@@ -54,7 +54,7 @@ class FlxAnimateFrames extends FlxAtlasFrames
#end
var imagemap:Map = new Map();
var jsonMap:Map = new Map();
- var thing = (zip != null) ? zip : Zip.unzip(Zip.readZip(Assets.getBytes(Path)));
+ var thing = (zip != null) ? zip : Zip.unzip(Zip.readZip(Assets.getBytes(Path)));
for (list in thing)
{
if (haxe.io.Path.extension(list.fileName) == "json")
@@ -182,7 +182,7 @@ class FlxAnimateFrames extends FlxAtlasFrames
var rotated = (texture.has.rotated && texture.att.rotated == "true");
var flipX = (texture.has.flipX && texture.att.flipX == "true");
var flipY = (texture.has.flipY && texture.att.flipY == "true");
-
+
var rect = FlxRect.get(Std.parseFloat(texture.att.x), Std.parseFloat(texture.att.y), Std.parseFloat(width),
Std.parseFloat(height));
@@ -203,7 +203,7 @@ class FlxAnimateFrames extends FlxAtlasFrames
return frames;
}
/**
- *
+ *
* @param Path the Json in specific, can be the path of it or the actual json
* @param Image the image which the file is referencing **WARNING:** if you set the path as a json, it's obligatory to set the image!
* @return A new instance of `FlxAtlasFrames`
@@ -294,7 +294,7 @@ class FlxAnimateFrames extends FlxAtlasFrames
return null;
}
}
-
+
var graphic:FlxGraphic = FlxG.bitmap.add(Image, false);
if (graphic == null)
@@ -438,7 +438,7 @@ class FlxAnimateFrames extends FlxAtlasFrames
Frames.addAtlasFrame(frameRect, sourceSize, offset, name, angle);
}
-
+
static function starlingHelper(FrameName:String, FrameData:Dynamic, Frames:FlxAtlasFrames):Void
{
var rotated:Bool = FrameData.rotated;
@@ -474,7 +474,7 @@ class FlxAnimateFrames extends FlxAtlasFrames
matrix.translate(0, height);
}
sprite.draw(SpriteMap, matrix);
-
+
@:privateAccess
var curFrame = new FlxFrame(FlxG.bitmap.add(sprite));
curFrame.name = limb.name;
@@ -482,7 +482,7 @@ class FlxAnimateFrames extends FlxAtlasFrames
curFrame.frame = new FlxRect(0,0, width, height);
return curFrame;
}
-
+
static function texturePackerHelper(FrameName:String, FrameData:Dynamic, Frames:FlxAtlasFrames):Void
{
var rotated:Bool = FrameData.rotated;
@@ -508,7 +508,7 @@ class FlxAnimateFrames extends FlxAtlasFrames
return a < b ? b : a;
}
// code made by noonat 11 years ago, not mine lol
-class PropertyList
+class PropertyList
{
static var _dateRegex:EReg = ~/(\d{4}-\d{2}-\d{2})(?:T(\d{2}:\d{2}:\d{2})Z)?/;
@@ -517,20 +517,20 @@ class PropertyList
* the property list is empty, an empty object will be returned.
* @param text Text contents of the property list file.
*/
- static public function parse(text:String):Dynamic
+ static public function parse(text:String):Dynamic
{
var fast = new Access(Xml.parse(text).firstElement());
return fast.hasNode.dict ? parseDict(fast.node.dict) : {};
}
- static function parseDate(text:String):Date
+ static function parseDate(text:String):Date
{
- if (!_dateRegex.match(text))
+ if (!_dateRegex.match(text))
{
throw 'Invalid date "' + text + '" (only yyyy-mm-dd and yyyy-mm-ddThh:mm:ssZ supported)';
}
text = _dateRegex.matched(1);
- if (_dateRegex.matched(2) != null)
+ if (_dateRegex.matched(2) != null)
{
text += ' ' + _dateRegex.matched(2);
}
@@ -541,12 +541,12 @@ class PropertyList
{
var key:String = null;
var result:Dynamic = {};
- for (childNode in node.elements)
+ for (childNode in node.elements)
{
- if (childNode.name == 'key')
+ if (childNode.name == 'key')
{
key = childNode.innerData;
- } else if (key != null)
+ } else if (key != null)
{
Reflect.setField(result, key, parseValue(childNode));
}
@@ -557,21 +557,21 @@ class PropertyList
static function parseValue(node:Access):Dynamic
{
var value:Dynamic = null;
- switch (node.name)
+ switch (node.name)
{
case 'array':
value = new Array();
- for (childNode in node.elements)
+ for (childNode in node.elements)
{
value.push(parseValue(childNode));
}
-
+
case 'dict':
value = parseDict(node);
-
+
case 'date':
value = parseDate(node.innerData);
-
+
case 'string':
var thing:Dynamic = node.innerData;
if (thing.charAt(0) == "{")
@@ -583,16 +583,16 @@ class PropertyList
value = thing;
case 'data':
value = node.innerData;
-
+
case 'true':
value = true;
-
+
case 'false':
value = false;
-
+
case 'real':
value = Std.parseFloat(node.innerData);
-
+
case 'integer':
value = Std.parseInt(node.innerData);
}
@@ -602,7 +602,7 @@ class PropertyList
typedef JSJson =
{
var images:Array;
- var frames:Array>;
+ var frames:Array>;
}
typedef FlxSparrow = OneOfTwo;
typedef FlxJson = OneOfTwo;
@@ -612,7 +612,7 @@ typedef JsonNormal =
frames:Dynamic,
meta:Meta
}
-typedef Plist =
+typedef Plist =
{
frames:Dynamic,
metadata:Dynamic
diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx
index 6920486b..3cbbdbea 100644
--- a/source/funkin/editors/charter/Charter.hx
+++ b/source/funkin/editors/charter/Charter.hx
@@ -1,107 +1,55 @@
package funkin.editors.charter;
+import flixel.math.FlxPoint;
+import funkin.editors.charter.CharterBackdrop.CharterBackdropDummy;
+import funkin.system.Conductor;
+import funkin.chart.*;
+import funkin.chart.ChartData;
import openfl.display.BitmapData;
import flixel.util.FlxColor;
import flixel.addons.display.FlxBackdrop;
import funkin.editors.ui.UIContextMenu.UIContextMenuOption;
import funkin.editors.ui.UIState;
+import openfl.net.FileReference;
class Charter extends UIState {
var __song:String;
var __diff:String;
- /**
- * CONFIG (might make this customizable later)
- */
- private var gridColor1:FlxColor = 0xFF404040; // white
- private var gridColor2:FlxColor = 0xFF212121; // gray
+ var chart(get, null):ChartData;
+ private function get_chart()
+ return PlayState.SONG;
- public var topMenu:Array = [
- {
- label: "File",
- childs: [
- {
- label: "New"
- },
- null,
- {
- label: "Exit",
- onSelect: function() {
- FlxG.switchState(new CharterSelection());
- }
- }
- ]
- },
- {
- label: "Edit",
- childs: [
- {
- label: "Undo"
- },
- {
- label: "Redo"
- },
- null,
- {
- label: "Cut"
- },
- {
- label: "Copy"
- },
- {
- label: "Paste"
- },
- null,
- {
- label: "Delete"
- }
- ]
- },
- {
- label: "Chart",
- childs: [
- {
- label: "Playtest"
- },
- {
- label: "Playtest here"
- },
- null,
- {
- label: "Playtest as opponent"
- },
- {
- label: "Playtest as opponent here"
- },
- null,
- {
- label: "Edit metadata information"
- }
- ]
- },
- {
- label: "Playback",
- childs: [
- {
- label: "Play/Pause"
- },
- null,
- {
- label: "Go back a section"
- },
- {
- label: "Go forward a section"
- },
- null,
- {
- label: "Go back to the start"
- }
- ]
- }
- ];
+ /**
+ * CONFIG & UI (might make this customizable later)
+ */
+ public var uiGroup:FlxTypedGroup = new FlxTypedGroup();
+ private var gridColor1:FlxColor = 0xFF272727; // white
+ private var gridColor2:FlxColor = 0xFF545454; // gray
+
+ public var topMenu:Array;
public var topMenuSpr:UITopMenu;
- public var gridBackdrop:FlxBackdrop;
+ public var gridBackdrop:CharterBackdrop;
+ public var gridBackdropDummy:CharterBackdropDummy;
+
+ /**
+ * ACTUAL CHART DATA
+ */
+ public var strumLines:Array = [];
+ public var notesGroup:FlxTypedGroup = new FlxTypedGroup();
+
+ /**
+ * CAMERAS
+ */
+ // camera for the chart itself so that it can be unzoomed/zoomed in again
+ public var charterCamera:FlxCamera;
+ // camera for the ui
+ public var uiCamera:FlxCamera;
+ // selection box for the ui
+ public var selectionBox:UISliceSprite;
+
+ public var selection:Array = [];
public function new(song:String, diff:String) {
super();
@@ -111,32 +59,255 @@ class Charter extends UIState {
public override function create() {
super.create();
+
+ topMenu = [
+ {
+ label: "File",
+ childs: [
+ {
+ label: "New"
+ },
+ null,
+ {
+ label: "Exit",
+ onSelect: _file_exit
+ }
+ ]
+ },
+ {
+ label: "Edit",
+ childs: [
+ {
+ label: "Undo"
+ },
+ {
+ label: "Redo"
+ },
+ null,
+ {
+ label: "Cut"
+ },
+ {
+ label: "Copy"
+ },
+ {
+ label: "Paste"
+ },
+ null,
+ {
+ label: "Delete",
+ onSelect: _edit_delete
+ }
+ ]
+ },
+ {
+ label: "Chart",
+ childs: [
+ {
+ label: "Playtest"
+ },
+ {
+ label: "Playtest here"
+ },
+ null,
+ {
+ label: "Playtest as opponent"
+ },
+ {
+ label: "Playtest as opponent here"
+ },
+ null,
+ {
+ label: "Edit metadata information"
+ }
+ ]
+ },
+ {
+ label: "Playback",
+ childs: [
+ {
+ label: "Play/Pause"
+ },
+ null,
+ {
+ label: "Go back a section"
+ },
+ {
+ label: "Go forward a section"
+ },
+ null,
+ {
+ label: "Go back to the start"
+ }
+ ]
+ }
+ ];
+
trace('Entering Charter for song $__song with difficulty $__diff.');
+
+
+ charterCamera = FlxG.camera;
+ uiCamera = new FlxCamera();
+ uiCamera.bgColor = 0;
+ FlxG.cameras.add(uiCamera);
+
+
+ gridBackdrop = new CharterBackdrop();
+
+ add(gridBackdropDummy = new CharterBackdropDummy(gridBackdrop));
+
+ selectionBox = new UISliceSprite(0, 0, 2, 2, 'editors/ui/selection');
+ selectionBox.visible = false;
+ selectionBox.scrollFactor.set(1, 1);
+ selectionBox.incorporeal = true;
+
+ selectionBox.cameras = notesGroup.cameras = gridBackdrop.cameras = [charterCamera];
+
+
+ topMenuSpr = new UITopMenu(topMenu);
+ topMenuSpr.cameras = uiGroup.cameras = [uiCamera];
+
+
+ // adds grid and notes so that they're ALWAYS behind the UI
+ add(gridBackdrop);
+ add(notesGroup);
+ add(selectionBox);
+ // add the ui group
+ add(uiGroup);
+ // add the top menu last OUT of the ui group so that it stays on top
+ add(topMenuSpr);
+
+ loadSong();
+ }
+
+ public function loadSong() {
CoolUtil.loadSong(__song, __diff, false, false);
- gridBackdrop = new FlxBackdrop(null, 1, 1, true, true);
- gridBackdrop.makeGraphic(4, 4, gridColor1, true);
- gridBackdrop.pixels.lock();
- for(y in 0...4)
- for(x in 0...2)
- gridBackdrop.pixels.setPixel32((x*2)+(y%2), y, gridColor2);
- gridBackdrop.pixels.unlock();
- gridBackdrop.scale.set(40, 40);
- gridBackdrop.updateHitbox();
- gridBackdrop.loadFrame(gridBackdrop.frame);
- gridBackdrop.cameras = cameras;
- add(gridBackdrop);
-
-
- // ALWAYS ADD LAST
- topMenuSpr = new UITopMenu(topMenu);
- add(topMenuSpr);
+ Conductor.setupSong(PlayState.SONG);
+
+ for(strID=>strL in PlayState.SONG.strumLines) {
+ for(note in strL.notes) {
+ var n = new CharterNote();
+ n.updatePos(Conductor.getStepForTime(note.time), (strID * 4) + note.id, note.sLen, note.type);
+ notesGroup.add(n);
+ }
+ }
}
+ /**
+ * NOTE AND CHARTER GRID LOGIC HERE
+ */
+ #if REGION
+ var selectionBoxEnabled:Bool = false;
+ var dragStartPos:FlxPoint = new FlxPoint();
+
+ public function updateNoteLogic(elapsed:Float) {
+ notesGroup.forEach(function(n) {
+ n.selected = false;
+ if (n.hovered && !selectionBoxEnabled) {
+ if (FlxG.mouse.justReleased) {
+ if (FlxG.keys.pressed.CONTROL)
+ selection.push(n);
+ else
+ selection = [n];
+ }
+ if (FlxG.mouse.justReleasedRight) {
+ if (!selection.contains(n))
+ selection = [n];
+ openContextMenu(topMenu[1].childs);
+ }
+ }
+ });
+ for(n in selection)
+ n.selected = true;
+
+ if (gridBackdropDummy.hovered || (selectionBoxEnabled && gridBackdropDummy.hoveredByChild)) {
+ var mousePos = FlxG.mouse.getWorldPosition(charterCamera);
+ if (FlxG.mouse.justPressed) {
+ selectionBoxEnabled = false;
+ FlxG.mouse.getWorldPosition(charterCamera, dragStartPos);
+ }
+ if (FlxG.mouse.pressed) {
+ if (Math.abs(mousePos.x - dragStartPos.x) > 20 || Math.abs(mousePos.y - dragStartPos.y) > 20) {
+ selectionBoxEnabled = true;
+ }
+ if (selectionBoxEnabled) {
+ selectionBox.x = Math.min(mousePos.x, dragStartPos.x);
+ selectionBox.y = Math.min(mousePos.y, dragStartPos.y);
+ selectionBox.bWidth = Std.int(Math.abs(mousePos.x - dragStartPos.x));
+ selectionBox.bHeight = Std.int(Math.abs(mousePos.y - dragStartPos.y));
+ }
+ }
+ if (FlxG.mouse.justReleased) {
+ if (selectionBoxEnabled) {
+ var minX = Std.int(Math.round(selectionBox.x / 40));
+ var minY = Math.round(selectionBox.y / 40) - 1;
+ var maxX = Std.int(Math.round((selectionBox.x + selectionBox.bWidth) / 40));
+ var maxY = Math.round((selectionBox.y + selectionBox.bHeight) / 40);
+
+ selection = [];
+ notesGroup.forEach(function(n) {
+ if (n.id >= minX && n.id <= maxX && n.step >= minY && n.step <= maxY)
+ selection.push(n);
+ });
+
+ selectionBoxEnabled = false;
+ } else {
+ // place note
+ var note = new CharterNote();
+ note.updatePos(FlxG.keys.pressed.SHIFT ? (mousePos.y / 40) : Std.int(mousePos.y / 40), Std.int(mousePos.x / 40), 0, 0);
+ notesGroup.add(note);
+ selection = [note];
+ }
+ }
+ if (FlxG.mouse.justReleasedRight)
+ openContextMenu(topMenu[2].childs);
+ }
+ selectionBox.visible = selectionBoxEnabled;
+ }
+ #end
public override function update(elapsed:Float) {
+ // TODO: do optimization like NoteGroup
+ updateNoteLogic(elapsed);
+
+
super.update(elapsed);
- // TODO: remove this bs!!
- if (controls.BACK)
- FlxG.switchState(new funkin.menus.MainMenuState());
+
+ gridBackdrop.strumlinesAmount = 3;
+
+ // TODO: canTypeText in case an ui input element is focused
+ if (true) {
+ if (controls.LEFT)
+ FlxG.camera.scroll.x -= 250 * elapsed;
+ if (controls.RIGHT)
+ FlxG.camera.scroll.x += 250 * elapsed;
+ if (controls.UP)
+ FlxG.camera.scroll.y -= 250 * elapsed;
+ if (controls.DOWN)
+ FlxG.camera.scroll.y += 250 * elapsed;
+
+ if (FlxG.keys.justPressed.DELETE)
+ _edit_delete();
+ }
}
+
+ public function deleteNote(note:CharterNote):CharterNote {
+ notesGroup.remove(note, true);
+ note.kill();
+ note.destroy();
+ return null;
+ }
+
+
+ // TOP MENU OPTIONS
+ #if REGION
+ function _file_exit() {
+ FlxG.switchState(new CharterSelection());
+ }
+ function _edit_delete() {
+ if (selection == null) return;
+ for(s in selection)
+ deleteNote(s);
+ }
+ #end
}
\ No newline at end of file
diff --git a/source/funkin/editors/charter/CharterBackdrop.hx b/source/funkin/editors/charter/CharterBackdrop.hx
new file mode 100644
index 00000000..ee5326f9
--- /dev/null
+++ b/source/funkin/editors/charter/CharterBackdrop.hx
@@ -0,0 +1,54 @@
+package funkin.editors.charter;
+
+import openfl.geom.Rectangle;
+import flixel.addons.display.FlxBackdrop;
+
+class CharterBackdrop extends FlxBackdrop {
+ public var strumlinesAmount:Int = 1;
+
+ public function new() {
+ super(null, 1, 1, false, true);
+
+ makeGraphic(160, 160, 0xFF272727, true);
+ pixels.lock();
+ for(y in 0...4)
+ for(x in 0...2)
+ pixels.fillRect(new Rectangle(40*((x*2)+(y%2)), 40*y, 40, 40), 0xFF545454);
+ pixels.fillRect(new Rectangle(0, 0, 1, 160), 0xFFDDDDDD);
+ pixels.fillRect(new Rectangle(159, 0, 1, 160), 0xFFDDDDDD);
+ pixels.unlock();
+ loadFrame(frame);
+ }
+
+ public override function draw() {
+ var ogX:Float = x;
+ for(_ in 0...strumlinesAmount) {
+ super.draw();
+ x += width;
+ }
+ x = ogX;
+ }
+}
+
+class CharterBackdropDummy extends UISprite {
+ var parent:CharterBackdrop;
+ public function new(parent:CharterBackdrop) {
+ super();
+ this.parent = parent;
+ cameras = parent.cameras;
+ scrollFactor.set(1, 0);
+ }
+
+ public override function updateButton() {
+ __rect.x = parent.x;
+ __rect.y = 0 - (FlxG.height * (1 - (1 / FlxG.camera.zoom)));
+ __rect.width = parent.frameWidth * parent.scale.x * parent.strumlinesAmount;
+ __rect.height = FlxG.height / FlxG.camera.zoom;
+ UIState.state.updateRectButtonHandler(this, __rect, onHovered);
+ }
+
+ public override function draw() {
+ @:privateAccess
+ __lastDrawCameras = [for(c in cameras) c];
+ }
+}
\ No newline at end of file
diff --git a/source/funkin/editors/charter/CharterNote.hx b/source/funkin/editors/charter/CharterNote.hx
new file mode 100644
index 00000000..d0aaccef
--- /dev/null
+++ b/source/funkin/editors/charter/CharterNote.hx
@@ -0,0 +1,59 @@
+package funkin.editors.charter;
+
+import flixel.tweens.FlxTween;
+import funkin.shaders.CustomShader;
+import flixel.util.FlxColor;
+
+class CharterNote extends UISprite {
+ var angleTween:FlxTween;
+
+ public var selected:Bool = false;
+
+ public function new() {
+ super();
+ antialiasing = true;
+ loadGraphic(Paths.image('editors/charter/note'), true, 157, 154);
+ animation.add("note", [for(i in 0...frames.frames.length) i], 0, true);
+ animation.play("note");
+ this.setUnstretchedGraphicSize(40, 40, false);
+
+ angle = 45; // green-red inbetween
+
+ cursor = BUTTON;
+ }
+
+
+ public var step:Float;
+ public var id:Int;
+ public var susLength:Float;
+ public var type:Int;
+
+ public function updatePos(step:Float, id:Int, susLength:Float = 0, type:Int = 0) {
+ this.step = step;
+ this.id = id;
+ this.susLength = susLength;
+ this.type = type;
+
+ x = id * 40;
+ y = step * 40;
+
+ if (angleTween != null) angleTween.cancel();
+
+ angleTween = FlxTween.tween(this, {angle: switch(animation.curAnim.curFrame = (id % 4)) {
+ case 0: -90;
+ case 1: 180;
+ case 2: 0;
+ case 3: 90;
+ default: 0; // how is that even possible
+ }}, 2/3, {ease: function(t) {
+ return ((Math.sin(t * Math.PI) * 0.35) * 3 * t * Math.sqrt(1 - t)) + t;
+ }});
+ }
+
+ public override function update(elapsed:Float) {
+ super.update(elapsed);
+ colorTransform.redMultiplier = colorTransform.greenMultiplier = colorTransform.blueMultiplier = selected ? 0.75 : 1;
+ colorTransform.redOffset = colorTransform.greenOffset = selected ? 96 : 0;
+ colorTransform.blueOffset = selected ? 168 : 0;
+ }
+}
\ No newline at end of file
diff --git a/source/funkin/editors/ui/UIContextMenu.hx b/source/funkin/editors/ui/UIContextMenu.hx
index 0ff38131..449d9e40 100644
--- a/source/funkin/editors/ui/UIContextMenu.hx
+++ b/source/funkin/editors/ui/UIContextMenu.hx
@@ -67,6 +67,12 @@ class UIContextMenu extends MusicBeatSubstate {
}
bg.bWidth = maxW + 8;
bg.bHeight = Std.int(lastY - bg.y + 4);
+
+ if (bg.y + bg.bHeight > FlxG.height) {
+ bg.y -= bg.bHeight;
+ for(o in contextMenuOptions)
+ o.y -= bg.bHeight;
+ }
}
public function select(option:UIContextMenuOption) {
@@ -123,7 +129,7 @@ class UIContextMenuOptionSpr extends UISliceSprite {
public override function draw() {
alpha = hovered ? 1 : 0;
- label.follow(this, 20, 0);
+ label.follow(this, 20, 2);
super.draw();
}
diff --git a/source/funkin/editors/ui/UISliceSprite.hx b/source/funkin/editors/ui/UISliceSprite.hx
index ec6afc27..eebdf1e9 100644
--- a/source/funkin/editors/ui/UISliceSprite.hx
+++ b/source/funkin/editors/ui/UISliceSprite.hx
@@ -7,6 +7,8 @@ class UISliceSprite extends UISprite {
public var bHeight:Int = 20;
public var framesOffset:Int = 0;
+ public var incorporeal:Bool = false;
+
public function new(x:Float, y:Float, w:Int, h:Int, path:String) {
super(x, y);
@@ -15,6 +17,7 @@ class UISliceSprite extends UISprite {
}
public override function updateButton() {
+ if (incorporeal) return;
__rect.x = x;
__rect.y = y;
__rect.width = bWidth;
@@ -41,7 +44,7 @@ class UISliceSprite extends UISprite {
var bottom:FlxFrame = frames.frames[framesOffset + 7];
var bottomright:FlxFrame = frames.frames[framesOffset + 8];
- @:privateAccess {
+ @:privateAccess if (visible) {
// TOP LEFT
frame = topleft;
setPosition(x, y);
@@ -49,10 +52,12 @@ class UISliceSprite extends UISprite {
super.drawSuper();
// TOP
- frame = top;
- setPosition(x + topleft.frame.width, y);
- __setSize(bWidth - topleft.frame.width - topright.frame.width, top.frame.height);
- super.drawSuper();
+ if (bWidth > topleft.frame.width + topright.frame.width) {
+ frame = top;
+ setPosition(x + topleft.frame.width, y);
+ __setSize(bWidth - topleft.frame.width - topright.frame.width, top.frame.height);
+ super.drawSuper();
+ }
// TOP RIGHT
frame = topright;
@@ -61,22 +66,26 @@ class UISliceSprite extends UISprite {
super.drawSuper();
// MIDDLE LEFT
- frame = middleleft;
- setPosition(x, y + top.frame.height);
- __setSize(middleleft.frame.width, bHeight - topleft.frame.height - bottomleft.frame.height);
- super.drawSuper();
-
- // MIDDLE
- frame = middle;
- setPosition(x + topleft.frame.width, y + top.frame.height);
- __setSize(bWidth - middleleft.frame.width - middleright.frame.width, bHeight - topleft.frame.height - bottomleft.frame.height);
- super.drawSuper();
+ if (bHeight > top.frame.height + bottom.frame.height) {
+ frame = middleleft;
+ setPosition(x, y + top.frame.height);
+ __setSize(middleleft.frame.width, bHeight - topleft.frame.height - bottomleft.frame.height);
+ super.drawSuper();
+
+ if (bWidth > middleleft.frame.width + middleright.frame.width) {
+ // MIDDLE
+ frame = middle;
+ setPosition(x + topleft.frame.width, y + top.frame.height);
+ __setSize(bWidth - middleleft.frame.width - middleright.frame.width, bHeight - topleft.frame.height - bottomleft.frame.height);
+ super.drawSuper();
+ }
- // MIDDLE RIGHT
- frame = middleright;
- setPosition(x + bWidth - topright.frame.width, y + top.frame.height);
- __setSize(middleright.frame.width, bHeight - topleft.frame.height - bottomleft.frame.height);
- super.drawSuper();
+ // MIDDLE RIGHT
+ frame = middleright;
+ setPosition(x + bWidth - topright.frame.width, y + top.frame.height);
+ __setSize(middleright.frame.width, bHeight - topleft.frame.height - bottomleft.frame.height);
+ super.drawSuper();
+ }
// BOTTOM LEFT
frame = bottomleft;
@@ -84,11 +93,13 @@ class UISliceSprite extends UISprite {
__setSize(bottomleft.frame.width, bottomleft.frame.height);
super.drawSuper();
- // BOTTOM
- frame = bottom;
- setPosition(x + bottomleft.frame.width, y + bHeight - bottom.frame.height);
- __setSize(bWidth - bottomleft.frame.width - bottomright.frame.width, bottom.frame.height);
- super.drawSuper();
+ if (bWidth > bottomleft.frame.width + bottomright.frame.width) {
+ // BOTTOM
+ frame = bottom;
+ setPosition(x + bottomleft.frame.width, y + bHeight - bottom.frame.height);
+ __setSize(bWidth - bottomleft.frame.width - bottomright.frame.width, bottom.frame.height);
+ super.drawSuper();
+ }
// BOTTOM RIGHT
frame = bottomright;
diff --git a/source/funkin/editors/ui/UIWarningSubstate.hx b/source/funkin/editors/ui/UIWarningSubstate.hx
index 38365f4a..11fe9b8d 100644
--- a/source/funkin/editors/ui/UIWarningSubstate.hx
+++ b/source/funkin/editors/ui/UIWarningSubstate.hx
@@ -6,7 +6,7 @@ import funkin.shaders.CustomShader;
class UIWarningSubstate extends MusicBeatSubstate {
var camShaders:Array = [];
- var blurShader:CustomShader = new CustomShader("editorBlur");
+ var blurShader:CustomShader = new CustomShader("engine/editorBlur");
var title:String;
var message:String;
diff --git a/source/funkin/game/Highscore.hx b/source/funkin/game/Highscore.hx
index b8707798..a77ae329 100644
--- a/source/funkin/game/Highscore.hx
+++ b/source/funkin/game/Highscore.hx
@@ -85,14 +85,13 @@ class Highscore
{
songScores = CoolUtil.getDefault(FlxG.save.data.songScores, new Map());
weekScores = CoolUtil.getDefault(FlxG.save.data.weekScores, new Map());
-
+
for(k=>e in songScores)
if (e is Int)
songScores.remove(k);
}
}
-
typedef SongScore = {
@:optional var score:Int;
@:optional var accuracy:Float;
diff --git a/source/funkin/macros/ScriptsMacro.hx b/source/funkin/macros/ScriptsMacro.hx
index f9e7a925..0fecee52 100644
--- a/source/funkin/macros/ScriptsMacro.hx
+++ b/source/funkin/macros/ScriptsMacro.hx
@@ -27,7 +27,7 @@ class ScriptsMacro {
#if !web
Compiler.include("haxe.extern");
#end
-
+
Compiler.include("scripting");
// FOR ABSTRACTS
diff --git a/source/funkin/menus/credits/CreditsCodename.hx b/source/funkin/menus/credits/CreditsCodename.hx
index d1728d56..611e3296 100644
--- a/source/funkin/menus/credits/CreditsCodename.hx
+++ b/source/funkin/menus/credits/CreditsCodename.hx
@@ -77,7 +77,7 @@ class CreditsCodename extends OptionsScreen {
spr.antialiasing = true;
spr.setUnstretchedGraphicSize(96, 96, false);
spr.updateHitbox();
- spr.shader = new CustomShader('circleProfilePicture');
+ spr.shader = new CustomShader('engine/circleProfilePicture');
contributorsSprites.push(spr);
add(spr);
}
diff --git a/source/funkin/options/Options.hx b/source/funkin/options/Options.hx
index acace74f..1a14a7a1 100644
--- a/source/funkin/options/Options.hx
+++ b/source/funkin/options/Options.hx
@@ -10,7 +10,7 @@ class Options
{
@:dox(hide) public static var __save:FlxSave;
@:dox(hide) private static var __eventAdded = false;
-
+
/**
* SETTINGS
*/
diff --git a/source/funkin/options/TreeMenu.hx b/source/funkin/options/TreeMenu.hx
index 0d8a60b7..ec13e9f1 100644
--- a/source/funkin/options/TreeMenu.hx
+++ b/source/funkin/options/TreeMenu.hx
@@ -1,5 +1,6 @@
package funkin.options;
+import flixel.FlxState;
import funkin.ui.FunkinText;
import flixel.tweens.FlxTween;
import funkin.menus.MainMenuState;
@@ -16,6 +17,8 @@ class TreeMenu extends MusicBeatState {
public var pathDesc:FunkinText;
public var pathBG:FlxSprite;
+ public var lastState:Class = Type.getClass(FlxG.state);
+
public function new() {
super();
}
@@ -76,7 +79,7 @@ class TreeMenu extends MusicBeatState {
}
public function exit() {
- FlxG.switchState(new MainMenuState());
+ FlxG.switchState((lastState != null) ? Type.createInstance(lastState, []) : new MainMenuState());
}
public function onMenuClose(m:OptionsScreen) {
diff --git a/source/funkin/shaders/CustomShader.hx b/source/funkin/shaders/CustomShader.hx
index 3119c180..09f599cc 100644
--- a/source/funkin/shaders/CustomShader.hx
+++ b/source/funkin/shaders/CustomShader.hx
@@ -6,28 +6,28 @@ import hscript.IHScriptCustomBehaviour;
/**
* Class for custom shaders.
- *
+ *
* To create one, create a `shaders` folder in your assets/mod folder, then add a file named `my-shader.frag` or/and `my-shader.vert`.
- *
+ *
* Non-existent shaders will only load the default one, and throw a warning in the console.
- *
+ *
* To access the shader's uniform variables, use `shader.variable`
*/
class CustomShader extends FunkinShader {
- /**
- * Creates a new custom shader
- * @param name Name of the frag and vert files.
- * @param glslVersion GLSL version to use. Defaults to `120`.
- */
- public function new(name:String, glslVersion:String = "120") {
- var fragShaderPath = Paths.fragShader(name);
- var vertShaderPath = Paths.vertShader(name);
- var fragCode = Assets.exists(fragShaderPath) ? Assets.getText(fragShaderPath) : null;
- var vertCode = Assets.exists(vertShaderPath) ? Assets.getText(vertShaderPath) : null;
+ /**
+ * Creates a new custom shader
+ * @param name Name of the frag and vert files.
+ * @param glslVersion GLSL version to use. Defaults to `120`.
+ */
+ public function new(name:String, glslVersion:String = "120") {
+ var fragShaderPath = Paths.fragShader(name);
+ var vertShaderPath = Paths.vertShader(name);
+ var fragCode = Assets.exists(fragShaderPath) ? Assets.getText(fragShaderPath) : null;
+ var vertCode = Assets.exists(vertShaderPath) ? Assets.getText(vertShaderPath) : null;
- if (fragCode == null && vertCode == null)
- Logs.trace('Shader "$name" couldn\'t be found.', ERROR);
-
- super(fragCode, vertCode, glslVersion);
- }
+ if (fragCode == null && vertCode == null)
+ Logs.trace('Shader "$name" couldn\'t be found.', ERROR);
+
+ super(fragCode, vertCode, glslVersion);
+ }
}
\ No newline at end of file
diff --git a/source/funkin/shaders/FunkinShader.hx b/source/funkin/shaders/FunkinShader.hx
index 84f69dd1..6212357f 100644
--- a/source/funkin/shaders/FunkinShader.hx
+++ b/source/funkin/shaders/FunkinShader.hx
@@ -18,50 +18,76 @@ import openfl.display.ShaderParameter;
import openfl.display.BitmapData;
import openfl.display.ShaderInput;
+@:access(openfl.display3D.Context3D)
+@:access(openfl.display3D.Program3D)
+@:access(openfl.display.ShaderInput)
+@:access(openfl.display.ShaderParameter)
class FunkinShader extends FlxShader implements IHScriptCustomBehaviour {
- private static var __instanceFields = Type.getInstanceFields(FunkinShader);
-
- public var glslVer:String = "120";
+ private static var __instanceFields = Type.getInstanceFields(FunkinShader);
- /**
- * Creates a new shader from the specified fragment and vertex source.
- * Accepts `#pragma header`.
- * @param frag Fragment source (pass `null` to use default)
- * @param vert Vertex source (pass `null` to use default)
- * @param glslVer Version of GLSL to use (defaults to 120)
- */
- public override function new(frag:String, vert:String, glslVer:String = "120") {
- if (frag == null) frag = ShaderTemplates.defaultFragmentSource;
- if (vert == null) vert = ShaderTemplates.defaultVertexSource;
- this.glFragmentSource = frag.replace("#pragma header", ShaderTemplates.fragHeader).replace("#pragma body", ShaderTemplates.fragBody);
- this.glVertexSource = vert.replace("#pragma header", ShaderTemplates.vertHeader).replace("#pragma body", ShaderTemplates.vertBody);
+ public var glslVer:String = "120";
- this.glslVer = glslVer;
- super();
- }
+ /**
+ * Creates a new shader from the specified fragment and vertex source.
+ * Accepts `#pragma header`.
+ * @param frag Fragment source (pass `null` to use default)
+ * @param vert Vertex source (pass `null` to use default)
+ * @param glslVer Version of GLSL to use (defaults to 120)
+ */
+ public override function new(frag:String, vert:String, glslVer:String = "120") {
+ if (frag == null) frag = ShaderTemplates.defaultFragmentSource;
+ if (vert == null) vert = ShaderTemplates.defaultVertexSource;
+ this.glFragmentSource = frag;
+ this.glVertexSource = vert;
- @:noCompletion private override function __initGL():Void
- {
- if (__glSourceDirty || __paramBool == null)
- {
- __glSourceDirty = false;
- program = null;
+ this.glslVer = glslVer;
+ super();
+ }
- __inputBitmapData = new Array();
- __paramBool = new Array();
- __paramFloat = new Array();
- __paramInt = new Array();
+ @:noCompletion override private function set_glFragmentSource(value:String):String
+ {
+ value = value.replace("#pragma header", ShaderTemplates.fragHeader).replace("#pragma body", ShaderTemplates.fragBody);
+ if (value != __glFragmentSource)
+ {
+ __glSourceDirty = true;
+ }
- __processGLData(glVertexSource, "attribute");
- __processGLData(glVertexSource, "uniform");
- __processGLData(glFragmentSource, "uniform");
- }
+ return __glFragmentSource = value;
+ }
- if (__context != null && program == null)
- {
- var prefix = '#version ${glslVer}\n';
+ @:noCompletion override private function set_glVertexSource(value:String):String
+ {
+ value = value.replace("#pragma header", ShaderTemplates.vertHeader).replace("#pragma body", ShaderTemplates.vertBody);
+ if (value != __glVertexSource)
+ {
+ __glSourceDirty = true;
+ }
- @:privateAccess var gl = __context.gl;
+ return __glVertexSource = value;
+ }
+
+ @:noCompletion private override function __initGL():Void
+ {
+ if (__glSourceDirty || __paramBool == null)
+ {
+ __glSourceDirty = false;
+ program = null;
+
+ __inputBitmapData = new Array();
+ __paramBool = new Array();
+ __paramFloat = new Array();
+ __paramInt = new Array();
+
+ __processGLData(glVertexSource, "attribute");
+ __processGLData(glVertexSource, "uniform");
+ __processGLData(glFragmentSource, "uniform");
+ }
+
+ if (__context != null && program == null)
+ {
+ var prefix = '#version ${glslVer}\n';
+
+ var gl = __context.gl;
prefix += "#ifdef GL_ES
"
@@ -78,503 +104,501 @@ class FunkinShader extends FlxShader implements IHScriptCustomBehaviour {
var fragment = prefix + glFragmentSource;
var id = vertex + fragment;
- @:privateAccess
+
if (__context.__programs.exists(id))
{
- @:privateAccess program = __context.__programs.get(id);
+ program = __context.__programs.get(id);
}
else
{
program = __context.createProgram(GLSL);
- @:privateAccess program.__glProgram = __createGLProgram(vertex, fragment);
+ program.__glProgram = __createGLProgram(vertex, fragment);
- @:privateAccess __context.__programs.set(id, program);
+ __context.__programs.set(id, program);
}
if (program != null)
{
- @:privateAccess glProgram = program.__glProgram;
+ glProgram = program.__glProgram;
for (input in __inputBitmapData)
{
- @:privateAccess
+
if (input.__isUniform)
{
- @:privateAccess input.index = gl.getUniformLocation(glProgram, input.name);
+ input.index = gl.getUniformLocation(glProgram, input.name);
}
else
{
- @:privateAccess input.index = gl.getAttribLocation(glProgram, input.name);
+ input.index = gl.getAttribLocation(glProgram, input.name);
}
}
for (parameter in __paramBool)
{
- @:privateAccess
+
if (parameter.__isUniform)
{
- @:privateAccess parameter.index = gl.getUniformLocation(glProgram, parameter.name);
+ parameter.index = gl.getUniformLocation(glProgram, parameter.name);
}
else
{
- @:privateAccess parameter.index = gl.getAttribLocation(glProgram, parameter.name);
+ parameter.index = gl.getAttribLocation(glProgram, parameter.name);
}
}
for (parameter in __paramFloat)
{
- @:privateAccess
+
if (parameter.__isUniform)
{
- @:privateAccess parameter.index = gl.getUniformLocation(glProgram, parameter.name);
+ parameter.index = gl.getUniformLocation(glProgram, parameter.name);
}
else
{
- @:privateAccess parameter.index = gl.getAttribLocation(glProgram, parameter.name);
+ parameter.index = gl.getAttribLocation(glProgram, parameter.name);
}
}
for (parameter in __paramInt)
{
- @:privateAccess
+
if (parameter.__isUniform)
{
- @:privateAccess
+
parameter.index = gl.getUniformLocation(glProgram, parameter.name);
}
else
{
- @:privateAccess
+
parameter.index = gl.getAttribLocation(glProgram, parameter.name);
}
}
}
- }
- }
+ // initInstance(vertex, fragment); // btw make sure to disable the prefixes for ._isInstance
+ }
+ }
-
@:noCompletion private override function __processGLData(source:String, storageType:String):Void
- {
- var lastMatch = 0, position, regex, name, type;
-
- if (storageType == "uniform")
- {
- regex = ~/uniform ([A-Za-z0-9]+) ([A-Za-z0-9_]+)/;
- }
- else
- {
- regex = ~/attribute ([A-Za-z0-9]+) ([A-Za-z0-9_]+)/;
- }
-
- while (regex.matchSub(source, lastMatch))
- {
- type = regex.matched(1);
- name = regex.matched(2);
-
- if (StringTools.startsWith(name, "gl_"))
- {
- continue;
- }
-
- var isUniform = (storageType == "uniform");
-
- if (StringTools.startsWith(type, "sampler"))
- {
- var input = new ShaderInput();
- input.name = name;
- @:privateAccess
- input.__isUniform = isUniform;
- __inputBitmapData.push(input);
-
- switch (name)
- {
- case "openfl_Texture":
- __texture = input;
- case "bitmap":
- __bitmap = input;
- default:
- }
-
- Reflect.setField(__data, name, input);
- try{Reflect.setField(this, name, input);} catch(e) {}
- }
- else if (!Reflect.hasField(__data, name) || Reflect.field(__data, name) == null)
- {
- var parameterType:ShaderParameterType = switch (type)
- {
- case "bool": BOOL;
- case "double", "float": FLOAT;
- case "int", "uint": INT;
- case "bvec2": BOOL2;
- case "bvec3": BOOL3;
- case "bvec4": BOOL4;
- case "ivec2", "uvec2": INT2;
- case "ivec3", "uvec3": INT3;
- case "ivec4", "uvec4": INT4;
- case "vec2", "dvec2": FLOAT2;
- case "vec3", "dvec3": FLOAT3;
- case "vec4", "dvec4": FLOAT4;
- case "mat2", "mat2x2": MATRIX2X2;
- case "mat2x3": MATRIX2X3;
- case "mat2x4": MATRIX2X4;
- case "mat3x2": MATRIX3X2;
- case "mat3", "mat3x3": MATRIX3X3;
- case "mat3x4": MATRIX3X4;
- case "mat4x2": MATRIX4X2;
- case "mat4x3": MATRIX4X3;
- case "mat4", "mat4x4": MATRIX4X4;
- default: null;
- }
-
- var length = switch (parameterType)
- {
- case BOOL2, INT2, FLOAT2: 2;
- case BOOL3, INT3, FLOAT3: 3;
- case BOOL4, INT4, FLOAT4, MATRIX2X2: 4;
- case MATRIX3X3: 9;
- case MATRIX4X4: 16;
- default: 1;
- }
-
- var arrayLength = switch (parameterType)
- {
- case MATRIX2X2: 2;
- case MATRIX3X3: 3;
- case MATRIX4X4: 4;
- default: 1;
- }
-
- switch (parameterType)
- {
- case BOOL, BOOL2, BOOL3, BOOL4:
- var parameter = new ShaderParameter();
- parameter.name = name;
- @:privateAccess
- parameter.type = parameterType;
- @:privateAccess
- parameter.__arrayLength = arrayLength;
- @:privateAccess
- parameter.__isBool = true;
- @:privateAccess
- parameter.__isUniform = isUniform;
- @:privateAccess
- parameter.__length = length;
- __paramBool.push(parameter);
-
- if (name == "openfl_HasColorTransform")
- {
- __hasColorTransform = parameter;
- }
-
- Reflect.setField(__data, name, parameter);
- try{Reflect.setField(this, name, parameter);} catch(e) {}
-
- case INT, INT2, INT3, INT4:
- var parameter = new ShaderParameter();
- parameter.name = name;
- @:privateAccess
- parameter.type = parameterType;
- @:privateAccess
- parameter.__arrayLength = arrayLength;
- @:privateAccess
- parameter.__isInt = true;
- @:privateAccess
- parameter.__isUniform = isUniform;
- @:privateAccess
- parameter.__length = length;
- @:privateAccess
- __paramInt.push(parameter);
- Reflect.setField(__data, name, parameter);
- try{Reflect.setField(this, name, parameter);} catch(e) {}
-
- default:
- var parameter = new ShaderParameter();
- parameter.name = name;
- @:privateAccess
- parameter.type = parameterType;
- @:privateAccess
- parameter.__arrayLength = arrayLength;
- #if lime
- @:privateAccess
- if (arrayLength > 0) parameter.__uniformMatrix = new Float32Array(arrayLength * arrayLength);
- #end
- @:privateAccess
- parameter.__isFloat = true;
- @:privateAccess
- parameter.__isUniform = isUniform;
- @:privateAccess
- parameter.__length = length;
- __paramFloat.push(parameter);
-
- if (StringTools.startsWith(name, "openfl_"))
- {
- switch (name)
- {
- case "openfl_Alpha": __alpha = parameter;
- case "openfl_ColorMultiplier": __colorMultiplier = parameter;
- case "openfl_ColorOffset": __colorOffset = parameter;
- case "openfl_Matrix": __matrix = parameter;
- case "openfl_Position": __position = parameter;
- case "openfl_TextureCoord": __textureCoord = parameter;
- case "openfl_TextureSize": __textureSize = parameter;
- default:
- }
- }
-
- Reflect.setField(__data, name, parameter);
- try{Reflect.setField(this, name, parameter);} catch(e) {}
- }
- }
-
- position = regex.matchedPos();
- lastMatch = position.pos + position.len;
- }
- }
+ {
+ var lastMatch = 0, position, regex, name, type;
-
+ if (storageType == "uniform")
+ {
+ regex = ~/uniform ([A-Za-z0-9]+) ([A-Za-z0-9_]+)/;
+ }
+ else
+ {
+ regex = ~/attribute ([A-Za-z0-9]+) ([A-Za-z0-9_]+)/;
+ }
- public function hget(v:String):Dynamic {
- if (__instanceFields.contains(v) || __instanceFields.contains('get_${v}')) {
- return Reflect.getProperty(this, v);
- }
- if (!Reflect.hasField(data, v)) return null;
- var field = Reflect.field(data, v);
- var cl = Std.string(Type.getClass(field));
+ while (regex.matchSub(source, lastMatch))
+ {
+ type = regex.matched(1);
+ name = regex.matched(2);
- // cant do "field is ShaderInput" for some reason
- if (cl.startsWith("openfl.display.ShaderInput")) {
- var si = cast(field, ShaderInput);
- return si.input;
- } else if (field is ShaderParameter) {
- var sp = cast(field, ShaderParameter);
- @:privateAccess
- return (sp.__length > 1) ? sp.value : sp.value[0];
- }
- return field;
- }
+ if (StringTools.startsWith(name, "gl_"))
+ {
+ continue;
+ }
- public function hset(v:String, val:Dynamic):Dynamic {
- if (__instanceFields.contains(v) || __instanceFields.contains('set_${v}')) {
- Reflect.setProperty(this, v, val);
- return val;
- }
+ var isUniform = (storageType == "uniform");
- if (!Reflect.hasField(data, v)) {
- Reflect.setField(data, v, val);
- return val;
- } else {
- var field = Reflect.field(data, v);
- var cl = Std.string(Type.getClass(field));
+ if (StringTools.startsWith(type, "sampler"))
+ {
+ var input = new ShaderInput();
+ input.name = name;
+ @:privateAccess
+ input.__isUniform = isUniform;
+ __inputBitmapData.push(input);
- // cant do "field is ShaderInput" for some reason
- if (cl.startsWith("openfl.display.ShaderInput")) {
- // shader input!!
- if (!(val is BitmapData)) {
- throw new ShaderTypeException(v, Type.getClass(val), BitmapData);
- return null;
- }
- field.input = cast val;
- } else if (cl.startsWith("openfl.display.ShaderParameter")) {
- @:privateAccess
- if (field.__length <= 1) {
- // that means we wait for a single number, instead of an array
- @:privateAccess
- if (field.__isInt && !(val is Int)) {
- throw new ShaderTypeException(v, Type.getClass(val), 'Int');
- return null;
- } else
- @:privateAccess
- if (field.__isBool && !(val is Bool)) {
- throw new ShaderTypeException(v, Type.getClass(val), 'Bool');
- return null;
- } else
- @:privateAccess
- if (field.__isFloat && !(val is Float)) {
- throw new ShaderTypeException(v, Type.getClass(val), 'Float');
- return null;
- }
- return field.value = [val];
- } else {
- if (!(val is Array)) {
- throw new ShaderTypeException(v, Type.getClass(val), Array);
- return null;
- }
- return field.value = val;
- }
- }
- }
+ switch (name)
+ {
+ case "openfl_Texture":
+ __texture = input;
+ case "bitmap":
+ __bitmap = input;
+ default:
+ }
- return val;
- }
+ Reflect.setField(__data, name, input);
+ try{Reflect.setField(this, name, input);} catch(e) {}
+ }
+ else if (!Reflect.hasField(__data, name) || Reflect.field(__data, name) == null)
+ {
+ var parameterType:ShaderParameterType = switch (type)
+ {
+ case "bool": BOOL;
+ case "double", "float": FLOAT;
+ case "int", "uint": INT;
+ case "bvec2": BOOL2;
+ case "bvec3": BOOL3;
+ case "bvec4": BOOL4;
+ case "ivec2", "uvec2": INT2;
+ case "ivec3", "uvec3": INT3;
+ case "ivec4", "uvec4": INT4;
+ case "vec2", "dvec2": FLOAT2;
+ case "vec3", "dvec3": FLOAT3;
+ case "vec4", "dvec4": FLOAT4;
+ case "mat2", "mat2x2": MATRIX2X2;
+ case "mat2x3": MATRIX2X3;
+ case "mat2x4": MATRIX2X4;
+ case "mat3x2": MATRIX3X2;
+ case "mat3", "mat3x3": MATRIX3X3;
+ case "mat3x4": MATRIX3X4;
+ case "mat4x2": MATRIX4X2;
+ case "mat4x3": MATRIX4X3;
+ case "mat4", "mat4x4": MATRIX4X4;
+ default: null;
+ }
+
+ var length = switch (parameterType)
+ {
+ case BOOL2, INT2, FLOAT2: 2;
+ case BOOL3, INT3, FLOAT3: 3;
+ case BOOL4, INT4, FLOAT4, MATRIX2X2: 4;
+ case MATRIX3X3: 9;
+ case MATRIX4X4: 16;
+ default: 1;
+ }
+
+ var arrayLength = switch (parameterType)
+ {
+ case MATRIX2X2: 2;
+ case MATRIX3X3: 3;
+ case MATRIX4X4: 4;
+ default: 1;
+ }
+
+ switch (parameterType)
+ {
+ case BOOL, BOOL2, BOOL3, BOOL4:
+ var parameter = new ShaderParameter();
+ parameter.name = name;
+ @:privateAccess
+ parameter.type = parameterType;
+ @:privateAccess
+ parameter.__arrayLength = arrayLength;
+ @:privateAccess
+ parameter.__isBool = true;
+ @:privateAccess
+ parameter.__isUniform = isUniform;
+ @:privateAccess
+ parameter.__length = length;
+ __paramBool.push(parameter);
+
+ if (name == "openfl_HasColorTransform")
+ {
+ __hasColorTransform = parameter;
+ }
+
+ Reflect.setField(__data, name, parameter);
+ try{Reflect.setField(this, name, parameter);} catch(e) {}
+
+ case INT, INT2, INT3, INT4:
+ var parameter = new ShaderParameter();
+ parameter.name = name;
+ @:privateAccess
+ parameter.type = parameterType;
+ @:privateAccess
+ parameter.__arrayLength = arrayLength;
+ @:privateAccess
+ parameter.__isInt = true;
+ @:privateAccess
+ parameter.__isUniform = isUniform;
+ @:privateAccess
+ parameter.__length = length;
+ @:privateAccess
+ __paramInt.push(parameter);
+ Reflect.setField(__data, name, parameter);
+ try{Reflect.setField(this, name, parameter);} catch(e) {}
+
+ default:
+ var parameter = new ShaderParameter();
+ parameter.name = name;
+ @:privateAccess
+ parameter.type = parameterType;
+ @:privateAccess
+ parameter.__arrayLength = arrayLength;
+ #if lime
+ @:privateAccess
+ if (arrayLength > 0) parameter.__uniformMatrix = new Float32Array(arrayLength * arrayLength);
+ #end
+ @:privateAccess
+ parameter.__isFloat = true;
+ @:privateAccess
+ parameter.__isUniform = isUniform;
+ @:privateAccess
+ parameter.__length = length;
+ __paramFloat.push(parameter);
+
+ if (StringTools.startsWith(name, "openfl_"))
+ {
+ switch (name)
+ {
+ case "openfl_Alpha": __alpha = parameter;
+ case "openfl_ColorMultiplier": __colorMultiplier = parameter;
+ case "openfl_ColorOffset": __colorOffset = parameter;
+ case "openfl_Matrix": __matrix = parameter;
+ case "openfl_Position": __position = parameter;
+ case "openfl_TextureCoord": __textureCoord = parameter;
+ case "openfl_TextureSize": __textureSize = parameter;
+ default:
+ }
+ }
+
+ Reflect.setField(__data, name, parameter);
+ try{Reflect.setField(this, name, parameter);} catch(e) {}
+ }
+ }
+
+ position = regex.matchedPos();
+ lastMatch = position.pos + position.len;
+ }
+ }
+
+ public function hget(v:String):Dynamic {
+ if (__instanceFields.contains(v) || __instanceFields.contains('get_${v}')) {
+ return Reflect.getProperty(this, v);
+ }
+ if (!Reflect.hasField(data, v)) return null;
+ var field = Reflect.field(data, v);
+ var cl = Std.string(Type.getClass(field));
+
+ // cant do "field is ShaderInput" for some reason
+ if (cl.startsWith("openfl.display.ShaderParameter")) {
+ var sp = cast(field, ShaderParameter);
+ @:privateAccess
+ return (sp.__length > 1) ? sp.value : sp.value[0];
+ } else if (cl.startsWith("openfl.display.ShaderInput")) {
+ var si = cast(field, ShaderInput);
+ return si.input;
+ }
+ return field;
+ }
+
+ public function hset(v:String, val:Dynamic):Dynamic {
+ if (__instanceFields.contains(v) || __instanceFields.contains('set_${v}')) {
+ Reflect.setProperty(this, v, val);
+ return val;
+ }
+
+ if (!Reflect.hasField(data, v)) {
+ Reflect.setField(data, v, val);
+ return val;
+ } else {
+ var field = Reflect.field(data, v);
+ var cl = Std.string(Type.getClass(field));
+
+ // cant do "field is ShaderInput" for some reason
+ if (cl.startsWith("openfl.display.ShaderParameter")) {
+ @:privateAccess
+ if (field.__length <= 1) {
+ // that means we wait for a single number, instead of an array
+ @:privateAccess
+ if (field.__isInt && !(val is Int)) {
+ throw new ShaderTypeException(v, Type.getClass(val), 'Int');
+ return null;
+ } else
+ @:privateAccess
+ if (field.__isBool && !(val is Bool)) {
+ throw new ShaderTypeException(v, Type.getClass(val), 'Bool');
+ return null;
+ } else
+ @:privateAccess
+ if (field.__isFloat && !(val is Float)) {
+ throw new ShaderTypeException(v, Type.getClass(val), 'Float');
+ return null;
+ }
+ return field.value = [val];
+ } else {
+ if (!(val is Array)) {
+ throw new ShaderTypeException(v, Type.getClass(val), Array);
+ return null;
+ }
+ return field.value = val;
+ }
+ } else if (cl.startsWith("openfl.display.ShaderInput")) {
+ // shader input!!
+ if (!(val is BitmapData)) {
+ throw new ShaderTypeException(v, Type.getClass(val), BitmapData);
+ return null;
+ }
+ field.input = cast val;
+ }
+ }
+
+ return val;
+ }
}
class ShaderTemplates {
- public static final fragHeader:String = "varying float openfl_Alphav;
- varying vec4 openfl_ColorMultiplierv;
- varying vec4 openfl_ColorOffsetv;
- varying vec2 openfl_TextureCoordv;
+ public static final fragHeader:String = "varying float openfl_Alphav;
+varying vec4 openfl_ColorMultiplierv;
+varying vec4 openfl_ColorOffsetv;
+varying vec2 openfl_TextureCoordv;
- uniform bool openfl_HasColorTransform;
- uniform vec2 openfl_TextureSize;
- uniform sampler2D bitmap;
+uniform bool openfl_HasColorTransform;
+uniform vec2 openfl_TextureSize;
+uniform sampler2D bitmap;
- uniform bool hasTransform;
- uniform bool hasColorTransform;
+uniform bool hasTransform;
+uniform bool hasColorTransform;
- vec4 flixel_texture2D(sampler2D bitmap, vec2 coord)
- {
- vec4 color = texture2D(bitmap, coord);
- if (!hasTransform)
- {
- return color;
- }
+vec4 flixel_texture2D(sampler2D bitmap, vec2 coord)
+{
+ vec4 color = texture2D(bitmap, coord);
+ if (!hasTransform)
+ {
+ return color;
+ }
- if (color.a == 0.0)
- {
- return vec4(0.0, 0.0, 0.0, 0.0);
- }
+ if (color.a == 0.0)
+ {
+ return vec4(0.0, 0.0, 0.0, 0.0);
+ }
- if (!hasColorTransform)
- {
- return color * openfl_Alphav;
- }
+ if (!hasColorTransform)
+ {
+ return color * openfl_Alphav;
+ }
- color = vec4(color.rgb / color.a, color.a);
+ color = vec4(color.rgb / color.a, color.a);
- mat4 colorMultiplier = mat4(0);
- colorMultiplier[0][0] = openfl_ColorMultiplierv.x;
- colorMultiplier[1][1] = openfl_ColorMultiplierv.y;
- colorMultiplier[2][2] = openfl_ColorMultiplierv.z;
- colorMultiplier[3][3] = openfl_ColorMultiplierv.w;
+ mat4 colorMultiplier = mat4(0);
+ colorMultiplier[0][0] = openfl_ColorMultiplierv.x;
+ colorMultiplier[1][1] = openfl_ColorMultiplierv.y;
+ colorMultiplier[2][2] = openfl_ColorMultiplierv.z;
+ colorMultiplier[3][3] = openfl_ColorMultiplierv.w;
- color = clamp(openfl_ColorOffsetv + (color * colorMultiplier), 0.0, 1.0);
+ color = clamp(openfl_ColorOffsetv + (color * colorMultiplier), 0.0, 1.0);
- if (color.a > 0.0)
- {
- return vec4(color.rgb * color.a * openfl_Alphav, color.a * openfl_Alphav);
- }
- return vec4(0.0, 0.0, 0.0, 0.0);
- }
+ if (color.a > 0.0)
+ {
+ return vec4(color.rgb * color.a * openfl_Alphav, color.a * openfl_Alphav);
+ }
+ return vec4(0.0, 0.0, 0.0, 0.0);
+}
- uniform vec4 _camSize;
-
- float map(float value, float min1, float max1, float min2, float max2) {
- return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
- }
-
- vec2 getCamPos(vec2 pos) {
- vec4 size = _camSize / vec4(openfl_TextureSize, openfl_TextureSize);
- return vec2(map(pos.x, size.x, size.x + size.z, 0.0, 1.0), map(pos.y, size.y, size.y + size.w, 0.0, 1.0));
- }
- vec2 camToOg(vec2 pos) {
- vec4 size = _camSize / vec4(openfl_TextureSize, openfl_TextureSize);
- return vec2(map(pos.x, 0.0, 1.0, size.x, size.x + size.z), map(pos.y, 0.0, 1.0, size.y, size.y + size.w));
- }
- vec4 textureCam(sampler2D bitmap, vec2 pos) {
- return flixel_texture2D(bitmap, camToOg(pos));
- }";
+uniform vec4 _camSize;
- public static final fragBody:String = "vec4 color = texture2D (bitmap, openfl_TextureCoordv);
+float map(float value, float min1, float max1, float min2, float max2) {
+ return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
+}
- if (color.a == 0.0) {
+vec2 getCamPos(vec2 pos) {
+ vec4 size = _camSize / vec4(openfl_TextureSize, openfl_TextureSize);
+ return vec2(map(pos.x, size.x, size.x + size.z, 0.0, 1.0), map(pos.y, size.y, size.y + size.w, 0.0, 1.0));
+}
+vec2 camToOg(vec2 pos) {
+ vec4 size = _camSize / vec4(openfl_TextureSize, openfl_TextureSize);
+ return vec2(map(pos.x, 0.0, 1.0, size.x, size.x + size.z), map(pos.y, 0.0, 1.0, size.y, size.y + size.w));
+}
+vec4 textureCam(sampler2D bitmap, vec2 pos) {
+ return flixel_texture2D(bitmap, camToOg(pos));
+}";
- gl_FragColor = vec4 (0.0, 0.0, 0.0, 0.0);
+ public static final fragBody:String = "vec4 color = texture2D (bitmap, openfl_TextureCoordv);
- } else if (openfl_HasColorTransform) {
+if (color.a == 0.0) {
- color = vec4 (color.rgb / color.a, color.a);
+ gl_FragColor = vec4 (0.0, 0.0, 0.0, 0.0);
- mat4 colorMultiplier = mat4 (0);
- colorMultiplier[0][0] = openfl_ColorMultiplierv.x;
- colorMultiplier[1][1] = openfl_ColorMultiplierv.y;
- colorMultiplier[2][2] = openfl_ColorMultiplierv.z;
- colorMultiplier[3][3] = 1.0; // openfl_ColorMultiplierv.w;
+} else if (openfl_HasColorTransform) {
- color = clamp (openfl_ColorOffsetv + (color * colorMultiplier), 0.0, 1.0);
+ color = vec4 (color.rgb / color.a, color.a);
- if (color.a > 0.0) {
+ mat4 colorMultiplier = mat4 (0);
+ colorMultiplier[0][0] = openfl_ColorMultiplierv.x;
+ colorMultiplier[1][1] = openfl_ColorMultiplierv.y;
+ colorMultiplier[2][2] = openfl_ColorMultiplierv.z;
+ colorMultiplier[3][3] = 1.0; // openfl_ColorMultiplierv.w;
- gl_FragColor = vec4 (color.rgb * color.a * openfl_Alphav, color.a * openfl_Alphav);
+ color = clamp (openfl_ColorOffsetv + (color * colorMultiplier), 0.0, 1.0);
- } else {
+ if (color.a > 0.0) {
- gl_FragColor = vec4 (0.0, 0.0, 0.0, 0.0);
+ gl_FragColor = vec4 (color.rgb * color.a * openfl_Alphav, color.a * openfl_Alphav);
- }
+ } else {
- } else {
+ gl_FragColor = vec4 (0.0, 0.0, 0.0, 0.0);
- gl_FragColor = color * openfl_Alphav;
+ }
- }";
- public static final vertHeader:String = "attribute float openfl_Alpha;
- attribute vec4 openfl_ColorMultiplier;
- attribute vec4 openfl_ColorOffset;
- attribute vec4 openfl_Position;
- attribute vec2 openfl_TextureCoord;
+} else {
- varying float openfl_Alphav;
- varying vec4 openfl_ColorMultiplierv;
- varying vec4 openfl_ColorOffsetv;
- varying vec2 openfl_TextureCoordv;
+ gl_FragColor = color * openfl_Alphav;
- uniform mat4 openfl_Matrix;
- uniform bool openfl_HasColorTransform;
- uniform vec2 openfl_TextureSize;";
+}";
+ public static final vertHeader:String = "attribute float openfl_Alpha;
+attribute vec4 openfl_ColorMultiplier;
+attribute vec4 openfl_ColorOffset;
+attribute vec4 openfl_Position;
+attribute vec2 openfl_TextureCoord;
- public static final vertBody:String = "openfl_Alphav = openfl_Alpha;
- openfl_TextureCoordv = openfl_TextureCoord;
+varying float openfl_Alphav;
+varying vec4 openfl_ColorMultiplierv;
+varying vec4 openfl_ColorOffsetv;
+varying vec2 openfl_TextureCoordv;
- if (openfl_HasColorTransform) {
+uniform mat4 openfl_Matrix;
+uniform bool openfl_HasColorTransform;
+uniform vec2 openfl_TextureSize;";
- openfl_ColorMultiplierv = openfl_ColorMultiplier;
- openfl_ColorOffsetv = openfl_ColorOffset / 255.0;
+ public static final vertBody:String = "openfl_Alphav = openfl_Alpha;
+openfl_TextureCoordv = openfl_TextureCoord;
- }
+if (openfl_HasColorTransform) {
- gl_Position = openfl_Matrix * openfl_Position;";
+ openfl_ColorMultiplierv = openfl_ColorMultiplier;
+ openfl_ColorOffsetv = openfl_ColorOffset / 255.0;
+
+}
+
+gl_Position = openfl_Matrix * openfl_Position;";
- public static final defaultVertexSource:String = "#pragma header
-
- attribute float alpha;
- attribute vec4 colorMultiplier;
- attribute vec4 colorOffset;
- uniform bool hasColorTransform;
-
- void main(void)
- {
- #pragma body
-
- openfl_Alphav = openfl_Alpha * alpha;
-
- if (hasColorTransform)
- {
- openfl_ColorOffsetv = colorOffset / 255.0;
- openfl_ColorMultiplierv = colorMultiplier;
- }
- }";
+ public static final defaultVertexSource:String = "#pragma header
+
+attribute float alpha;
+attribute vec4 colorMultiplier;
+attribute vec4 colorOffset;
+uniform bool hasColorTransform;
+
+void main(void)
+{
+ #pragma body
+
+ openfl_Alphav = openfl_Alpha * alpha;
+
+ if (hasColorTransform)
+ {
+ openfl_ColorOffsetv = colorOffset / 255.0;
+ openfl_ColorMultiplierv = colorMultiplier;
+ }
+}";
- // TODO: camera stuff
- public static final defaultFragmentSource:String = "#pragma header
-
- void main(void)
- {
- gl_FragColor = flixel_texture2D(bitmap, openfl_TextureCoordv);
- }";
+ // TODO: camera stuff
+ public static final defaultFragmentSource:String = "#pragma header
+
+void main(void)
+{
+ gl_FragColor = flixel_texture2D(bitmap, openfl_TextureCoordv);
+}";
}
class ShaderTypeException extends Exception {
- var has:Class;
- var want:Class;
- var name:String;
+ var has:Class;
+ var want:Class;
+ var name:String;
- public function new(name:String, has:Class, want:Dynamic) {
- this.has = has;
- this.want = want;
- this.name = name;
- super('ShaderTypeException - Tried to set the shader uniform "${name}" as a ${Type.getClassName(has)}, but the shader uniform is a ${Std.string(want)}.');
- }
+ public function new(name:String, has:Class, want:Dynamic) {
+ this.has = has;
+ this.want = want;
+ this.name = name;
+ super('ShaderTypeException - Tried to set the shader uniform "${name}" as a ${Type.getClassName(has)}, but the shader uniform is a ${Std.string(want)}.');
+ }
}
\ No newline at end of file
diff --git a/source/funkin/shaders/OverlayShader.hx b/source/funkin/shaders/OverlayShader.hx
index caaaaa8c..08eb410f 100644
--- a/source/funkin/shaders/OverlayShader.hx
+++ b/source/funkin/shaders/OverlayShader.hx
@@ -5,27 +5,27 @@ import flixel.system.FlxAssets.FlxShader;
class OverlayShader extends FlxShader
{
@:glFragmentSource('
- #pragma header
- uniform vec4 uBlendColor;
+#pragma header
+uniform vec4 uBlendColor;
- vec3 blendLighten(base:Vec3, blend:Vec3) : Vec3 {
- return mix(
- 1.0 - 2.0 * (1.0 - base) * (1.0 - blend),
- 2.0 * base * blend,
- step( base, vec3(0.5) )
- );
- }
+vec3 blendLighten(base:Vec3, blend:Vec3) : Vec3 {
+ return mix(
+ 1.0 - 2.0 * (1.0 - base) * (1.0 - blend),
+ 2.0 * base * blend,
+ step( base, vec3(0.5) )
+ );
+}
- vec4 blendLighten(vec4 base, vec4 blend, float opacity)
- {
- return (blendLighten(base, blend) * opacity + base * (1.0 - opacity));
- }
+vec4 blendLighten(vec4 base, vec4 blend, float opacity)
+{
+ return (blendLighten(base, blend) * opacity + base * (1.0 - opacity));
+}
- void main()
- {
- vec4 base = texture2D(bitmap, openfl_TextureCoordv);
- gl_FragColor = blendLighten(base, uBlendColor, uBlendColor.a);
- }')
+void main()
+{
+ vec4 base = texture2D(bitmap, openfl_TextureCoordv);
+ gl_FragColor = blendLighten(base, uBlendColor, uBlendColor.a);
+}')
public function new()
{
super();
diff --git a/source/funkin/shaders/WiggleEffect.hx b/source/funkin/shaders/WiggleEffect.hx
index 291c8a85..bb9bdd84 100644
--- a/source/funkin/shaders/WiggleEffect.hx
+++ b/source/funkin/shaders/WiggleEffect.hx
@@ -62,70 +62,70 @@ class WiggleEffect
class WiggleShader extends FlxShader
{
@:glFragmentSource('
- #pragma header
- //uniform float tx, ty; // x,y waves phase
- uniform float uTime;
-
- const int EFFECT_TYPE_DREAMY = 0;
- const int EFFECT_TYPE_WAVY = 1;
- const int EFFECT_TYPE_HEAT_WAVE_HORIZONTAL = 2;
- const int EFFECT_TYPE_HEAT_WAVE_VERTICAL = 3;
- const int EFFECT_TYPE_FLAG = 4;
-
- uniform int effectType;
-
- /**
- * How fast the waves move over time
- */
- uniform float uSpeed;
-
- /**
- * Number of waves over time
- */
- uniform float uFrequency;
-
- /**
- * How much the pixels are going to stretch over the waves
- */
- uniform float uWaveAmplitude;
+#pragma header
+//uniform float tx, ty; // x,y waves phase
+uniform float uTime;
- vec2 sineWave(vec2 pt)
- {
- float x = 0.0;
- float y = 0.0;
-
- if (effectType == EFFECT_TYPE_DREAMY)
- {
- float offsetX = sin(pt.y * uFrequency + uTime * uSpeed) * uWaveAmplitude;
- pt.x += offsetX; // * (pt.y - 1.0); // <- Uncomment to stop bottom part of the screen from moving
- }
- else if (effectType == EFFECT_TYPE_WAVY)
- {
- float offsetY = sin(pt.x * uFrequency + uTime * uSpeed) * uWaveAmplitude;
- pt.y += offsetY; // * (pt.y - 1.0); // <- Uncomment to stop bottom part of the screen from moving
- }
- else if (effectType == EFFECT_TYPE_HEAT_WAVE_HORIZONTAL)
- {
- x = sin(pt.x * uFrequency + uTime * uSpeed) * uWaveAmplitude;
- }
- else if (effectType == EFFECT_TYPE_HEAT_WAVE_VERTICAL)
- {
- y = sin(pt.y * uFrequency + uTime * uSpeed) * uWaveAmplitude;
- }
- else if (effectType == EFFECT_TYPE_FLAG)
- {
- y = sin(pt.y * uFrequency + 10.0 * pt.x + uTime * uSpeed) * uWaveAmplitude;
- x = sin(pt.x * uFrequency + 5.0 * pt.y + uTime * uSpeed) * uWaveAmplitude;
- }
-
- return vec2(pt.x + x, pt.y + y);
- }
+const int EFFECT_TYPE_DREAMY = 0;
+const int EFFECT_TYPE_WAVY = 1;
+const int EFFECT_TYPE_HEAT_WAVE_HORIZONTAL = 2;
+const int EFFECT_TYPE_HEAT_WAVE_VERTICAL = 3;
+const int EFFECT_TYPE_FLAG = 4;
- void main()
- {
- vec2 uv = sineWave(openfl_TextureCoordv);
- gl_FragColor = texture2D(bitmap, uv);
- }')
+uniform int effectType;
+
+/**
+ * How fast the waves move over time
+ */
+uniform float uSpeed;
+
+/**
+ * Number of waves over time
+ */
+uniform float uFrequency;
+
+/**
+ * How much the pixels are going to stretch over the waves
+ */
+uniform float uWaveAmplitude;
+
+vec2 sineWave(vec2 pt)
+{
+ float x = 0.0;
+ float y = 0.0;
+
+ if (effectType == EFFECT_TYPE_DREAMY)
+ {
+ float offsetX = sin(pt.y * uFrequency + uTime * uSpeed) * uWaveAmplitude;
+ pt.x += offsetX; // * (pt.y - 1.0); // <- Uncomment to stop bottom part of the screen from moving
+ }
+ else if (effectType == EFFECT_TYPE_WAVY)
+ {
+ float offsetY = sin(pt.x * uFrequency + uTime * uSpeed) * uWaveAmplitude;
+ pt.y += offsetY; // * (pt.y - 1.0); // <- Uncomment to stop bottom part of the screen from moving
+ }
+ else if (effectType == EFFECT_TYPE_HEAT_WAVE_HORIZONTAL)
+ {
+ x = sin(pt.x * uFrequency + uTime * uSpeed) * uWaveAmplitude;
+ }
+ else if (effectType == EFFECT_TYPE_HEAT_WAVE_VERTICAL)
+ {
+ y = sin(pt.y * uFrequency + uTime * uSpeed) * uWaveAmplitude;
+ }
+ else if (effectType == EFFECT_TYPE_FLAG)
+ {
+ y = sin(pt.y * uFrequency + 10.0 * pt.x + uTime * uSpeed) * uWaveAmplitude;
+ x = sin(pt.x * uFrequency + 5.0 * pt.y + uTime * uSpeed) * uWaveAmplitude;
+ }
+
+ return vec2(pt.x + x, pt.y + y);
+}
+
+void main()
+{
+ vec2 uv = sineWave(openfl_TextureCoordv);
+ gl_FragColor = texture2D(bitmap, uv);
+}')
public function new()
{
super();
diff --git a/source/funkin/system/Conductor.hx b/source/funkin/system/Conductor.hx
index 44705092..0d3c19d9 100644
--- a/source/funkin/system/Conductor.hx
+++ b/source/funkin/system/Conductor.hx
@@ -250,4 +250,32 @@ class Conductor
onBPMChange.dispatch(bpm);
}
+
+ public static function getTimeForStep(step:Float) {
+ var bpmChange:BPMChangeEvent = {
+ stepTime: 0,
+ songTime: 0,
+ bpm: bpm
+ };
+
+ for(change in bpmChangeMap)
+ if (change.stepTime < step && change.stepTime >= bpmChange.stepTime)
+ bpmChange = change;
+
+ return bpmChange.songTime + ((step - bpmChange.stepTime) * ((60 / bpmChange.bpm) * 250));
+ }
+
+ public static function getStepForTime(time:Float) {
+ var bpmChange:BPMChangeEvent = {
+ stepTime: 0,
+ songTime: 0,
+ bpm: bpm
+ };
+
+ for(change in bpmChangeMap)
+ if (change.songTime < time && change.songTime >= bpmChange.songTime)
+ bpmChange = change;
+
+ return bpmChange.stepTime + ((time - bpmChange.songTime) / ((60 / bpmChange.bpm) * 250));
+ }
}
diff --git a/source/funkin/system/Main.hx b/source/funkin/system/Main.hx
index e9b0f64a..15c2976d 100644
--- a/source/funkin/system/Main.hx
+++ b/source/funkin/system/Main.hx
@@ -108,6 +108,8 @@ class Main extends Sprite
// addChild(new FramerateField(10, 3, 0xFFFFFF));
addChild(new funkin.system.framerate.Framerate());
#end
+
+ trace("Hello", "World");
}
@:dox(hide)
diff --git a/source/funkin/ui/Alphabet.hx b/source/funkin/ui/Alphabet.hx
index 97f3a48c..a0cd3695 100644
--- a/source/funkin/ui/Alphabet.hx
+++ b/source/funkin/ui/Alphabet.hx
@@ -142,7 +142,7 @@ class Alphabet extends FlxSpriteGroup
letter.createLetter(character);
// anim not found
- if (!letter.visible)
+ if (!letter.visible)
xPos += 40;
letter.setColor(color, isBold);
@@ -190,7 +190,7 @@ class Alphabet extends FlxSpriteGroup
override function update(elapsed:Float)
{
super.update(elapsed);
-
+
if (isMenuItem)
{
var scaledY = FlxMath.remapToRange(targetY, 0, 1, 0, 1.3);
diff --git a/source/funkin/ui/FunkinText.hx b/source/funkin/ui/FunkinText.hx
index 72b7ea22..b7b35937 100644
--- a/source/funkin/ui/FunkinText.hx
+++ b/source/funkin/ui/FunkinText.hx
@@ -4,13 +4,13 @@ import flixel.util.FlxColor;
import flixel.text.FlxText;
class FunkinText extends FlxText {
- public function new(X:Float = 0, Y:Float = 0, FieldWidth:Float = 0, ?Text:String, Size:Int = 16, Border:Bool = true) {
- super(X, Y, FieldWidth, Text, Size);
- setFormat(Paths.font("vcr.ttf"), Size, FlxColor.WHITE);
- if (Border) {
- borderStyle = OUTLINE;
- borderSize = 1;
- borderColor = 0xFF000000;
- }
- }
+ public function new(X:Float = 0, Y:Float = 0, FieldWidth:Float = 0, ?Text:String, Size:Int = 16, Border:Bool = true) {
+ super(X, Y, FieldWidth, Text, Size);
+ setFormat(Paths.font("vcr.ttf"), Size, FlxColor.WHITE);
+ if (Border) {
+ borderStyle = OUTLINE;
+ borderSize = 1;
+ borderColor = 0xFF000000;
+ }
+ }
}
\ No newline at end of file
diff --git a/source/funkin/updating/UpdateScreen.hx b/source/funkin/updating/UpdateScreen.hx
index 1b6a3bb6..dfcc9b0c 100644
--- a/source/funkin/updating/UpdateScreen.hx
+++ b/source/funkin/updating/UpdateScreen.hx
@@ -61,7 +61,7 @@ class UpdateScreen extends MusicBeatState {
updater.execute();
- FlxG.camera.addShader(rainbowShader = new CustomShader("updaterShader"));
+ FlxG.camera.addShader(rainbowShader = new CustomShader("engine/updaterShader"));
}
diff --git a/source/funkin/utils/BitmapUtil.hx b/source/funkin/utils/BitmapUtil.hx
index ce22e81e..2346cbee 100644
--- a/source/funkin/utils/BitmapUtil.hx
+++ b/source/funkin/utils/BitmapUtil.hx
@@ -4,66 +4,66 @@ import openfl.display.BitmapData;
import flixel.util.FlxColor;
class BitmapUtil {
- /**
- * Returns the most present color in a Bitmap.
- * @param bmap Bitmap
- * @return FlxColor Color that is the most present.
- */
- public static function getMostPresentColor(bmap:BitmapData):FlxColor {
- // map containing all the colors and the number of times they've been assigned.
- var colorMap:Map = [];
- var color:FlxColor = 0;
- var fixedColor:FlxColor = 0;
+ /**
+ * Returns the most present color in a Bitmap.
+ * @param bmap Bitmap
+ * @return FlxColor Color that is the most present.
+ */
+ public static function getMostPresentColor(bmap:BitmapData):FlxColor {
+ // map containing all the colors and the number of times they've been assigned.
+ var colorMap:Map = [];
+ var color:FlxColor = 0;
+ var fixedColor:FlxColor = 0;
- for(y in 0...bmap.height) {
- for(x in 0...bmap.width) {
- color = bmap.getPixel32(x, y);
- fixedColor = 0xFF000000 + (color % 0x1000000);
- if (colorMap[fixedColor] == null)
- colorMap[fixedColor] = 0;
- colorMap[fixedColor] += color.alphaFloat;
- }
- }
+ for(y in 0...bmap.height) {
+ for(x in 0...bmap.width) {
+ color = bmap.getPixel32(x, y);
+ fixedColor = 0xFF000000 + (color % 0x1000000);
+ if (colorMap[fixedColor] == null)
+ colorMap[fixedColor] = 0;
+ colorMap[fixedColor] += color.alphaFloat;
+ }
+ }
- var mostPresentColor:FlxColor = 0;
- var mostPresentColorCount:Float = -1;
- for(c=>n in colorMap) {
- if (n > mostPresentColorCount) {
- mostPresentColorCount = n;
- mostPresentColor = c;
- }
- }
- return mostPresentColor;
- }
- /**
- * Returns the most present saturated color in a Bitmap.
- * @param bmap Bitmap
- * @return FlxColor Color that is the most present.
- */
- public static function getMostPresentSaturatedColor(bmap:BitmapData):FlxColor {
- // map containing all the colors and the number of times they've been assigned.
- var colorMap:Map = [];
- var color:FlxColor = 0;
- var fixedColor:FlxColor = 0;
+ var mostPresentColor:FlxColor = 0;
+ var mostPresentColorCount:Float = -1;
+ for(c=>n in colorMap) {
+ if (n > mostPresentColorCount) {
+ mostPresentColorCount = n;
+ mostPresentColor = c;
+ }
+ }
+ return mostPresentColor;
+ }
+ /**
+ * Returns the most present saturated color in a Bitmap.
+ * @param bmap Bitmap
+ * @return FlxColor Color that is the most present.
+ */
+ public static function getMostPresentSaturatedColor(bmap:BitmapData):FlxColor {
+ // map containing all the colors and the number of times they've been assigned.
+ var colorMap:Map = [];
+ var color:FlxColor = 0;
+ var fixedColor:FlxColor = 0;
- for(y in 0...bmap.height) {
- for(x in 0...bmap.width) {
- color = bmap.getPixel32(x, y);
- fixedColor = 0xFF000000 + (color % 0x1000000);
- if (colorMap[fixedColor] == null)
- colorMap[fixedColor] = 0;
- colorMap[fixedColor] += color.alphaFloat * 0.33 + (0.67 * (color.saturation * (2 * (color.lightness > 0.5 ? 0.5 - (color.lightness) : color.lightness))));
- }
- }
+ for(y in 0...bmap.height) {
+ for(x in 0...bmap.width) {
+ color = bmap.getPixel32(x, y);
+ fixedColor = 0xFF000000 + (color % 0x1000000);
+ if (colorMap[fixedColor] == null)
+ colorMap[fixedColor] = 0;
+ colorMap[fixedColor] += color.alphaFloat * 0.33 + (0.67 * (color.saturation * (2 * (color.lightness > 0.5 ? 0.5 - (color.lightness) : color.lightness))));
+ }
+ }
- var mostPresentColor:FlxColor = 0;
- var mostPresentColorCount:Float = -1;
- for(c=>n in colorMap) {
- if (n > mostPresentColorCount) {
- mostPresentColorCount = n;
- mostPresentColor = c;
- }
- }
- return mostPresentColor;
- }
+ var mostPresentColor:FlxColor = 0;
+ var mostPresentColorCount:Float = -1;
+ for(c=>n in colorMap) {
+ if (n > mostPresentColorCount) {
+ mostPresentColorCount = n;
+ mostPresentColor = c;
+ }
+ }
+ return mostPresentColor;
+ }
}
\ No newline at end of file
diff --git a/source/funkin/utils/DiscordUtil.hx b/source/funkin/utils/DiscordUtil.hx
index 8e81c272..dfcf4bfa 100644
--- a/source/funkin/utils/DiscordUtil.hx
+++ b/source/funkin/utils/DiscordUtil.hx
@@ -11,142 +11,142 @@ import lime.app.Application;
#end
class DiscordUtil {
- public static var currentID:String = null;
- public static var discordThread:#if DISCORD_RPC Thread #else Dynamic #end = null;
- public static var ready:Bool = false;
- public static var data:DiscordJson = null;
+ public static var currentID:String = null;
+ public static var discordThread:#if DISCORD_RPC Thread #else Dynamic #end = null;
+ public static var ready:Bool = false;
+ public static var data:DiscordJson = null;
+
+ public static function init() {
+ #if DISCORD_RPC
+ reloadJsonData();
+ discordThread = Thread.create(function() {
+ while (true)
+ {
+ while(!ready) {
+ Sys.sleep(1/60);
+ }
+ trace("Processing Discord RPC...");
+ DiscordRpc.process();
+ Sys.sleep(2);
+ }
+ });
- public static function init() {
- #if DISCORD_RPC
- reloadJsonData();
- discordThread = Thread.create(function() {
- while (true)
- {
- while(!ready) {
- Sys.sleep(1/60);
- }
- trace("Processing Discord RPC...");
- DiscordRpc.process();
- Sys.sleep(2);
- }
- });
-
Application.current.onExit.add(function(exitCode) {
shutdown();
});
- #end
- }
+ #end
+ }
- public static function reloadJsonData() {
- #if DISCORD_RPC
- data = {};
- var jsonPath = Paths.json("config/discord");
- if (Assets.exists(jsonPath)) {
- try {
- data = Json.parse(Assets.getText(jsonPath));
- } catch(e) {
- Logs.trace('Couldn\'t load Discord RPC configuration: ${e.toString()}', ERROR);
- }
- }
- trace(data);
- data.setFieldDefault("clientID", "1027994136193810442");
- data.setFieldDefault("logoKey", "icon");
- data.setFieldDefault("logoText", Application.current.meta.get('title'));
+ public static function reloadJsonData() {
+ #if DISCORD_RPC
+ data = {};
+ var jsonPath = Paths.json("config/discord");
+ if (Assets.exists(jsonPath)) {
+ try {
+ data = Json.parse(Assets.getText(jsonPath));
+ } catch(e) {
+ Logs.trace('Couldn\'t load Discord RPC configuration: ${e.toString()}', ERROR);
+ }
+ }
+ trace(data);
+ data.setFieldDefault("clientID", "1027994136193810442");
+ data.setFieldDefault("logoKey", "icon");
+ data.setFieldDefault("logoText", Application.current.meta.get('title'));
- changeClientID(data.clientID);
- #end
- }
+ changeClientID(data.clientID);
+ #end
+ }
- public static function changePresence(details:String, state:String, ?smallImageKey : String) {
- #if DISCORD_RPC
- changePresenceAdvanced({
- state: state,
- details: details,
- smallImageKey: smallImageKey
- });
- #end
- }
+ public static function changePresence(details:String, state:String, ?smallImageKey : String) {
+ #if DISCORD_RPC
+ changePresenceAdvanced({
+ state: state,
+ details: details,
+ smallImageKey: smallImageKey
+ });
+ #end
+ }
- public static function changeSongPresence(details:String, state:String, audio:FlxSound, ?smallImageKey : String) {
- #if DISCORD_RPC
- var start:Float = 0;
- var end:Float = 0;
+ public static function changeSongPresence(details:String, state:String, audio:FlxSound, ?smallImageKey : String) {
+ #if DISCORD_RPC
+ var start:Float = 0;
+ var end:Float = 0;
- if (audio != null && audio.playing) {
- start = Date.now().getTime();
- end = start + (audio.length - audio.time);
- }
+ if (audio != null && audio.playing) {
+ start = Date.now().getTime();
+ end = start + (audio.length - audio.time);
+ }
- changePresenceAdvanced({
- state: state,
- details: details,
- smallImageKey: smallImageKey,
- startTimestamp: Std.int(start / 1000),
- endTimestamp: Std.int(end / 1000)
- });
- #end
- }
+ changePresenceAdvanced({
+ state: state,
+ details: details,
+ smallImageKey: smallImageKey,
+ startTimestamp: Std.int(start / 1000),
+ endTimestamp: Std.int(end / 1000)
+ });
+ #end
+ }
- public static function changePresenceAdvanced(data:#if DISCORD_RPC DiscordPresenceOptions #else Dynamic #end) {
- #if DISCORD_RPC
- if (data == null) return;
+ public static function changePresenceAdvanced(data:#if DISCORD_RPC DiscordPresenceOptions #else Dynamic #end) {
+ #if DISCORD_RPC
+ if (data == null) return;
- if (data.largeImageKey == null)
- data.largeImageKey = DiscordUtil.data.logoKey;
- if (data.largeImageText == null)
- data.largeImageText = DiscordUtil.data.logoText;
-
- #if GLOBAL_SCRIPT
- var event = funkin.scripting.GlobalScript.event("onDiscordPresenceUpdate", EventManager.get(DiscordPresenceUpdateEvent).recycle(data));
- if (event.cancelled) return;
-
- #end
- DiscordRpc.presence(data);
- #end
- }
- public static function changeClientID(id:String) {
- #if DISCORD_RPC
- if (currentID != null) {
- DiscordRpc.shutdown();
- }
+ if (data.largeImageKey == null)
+ data.largeImageKey = DiscordUtil.data.logoKey;
+ if (data.largeImageText == null)
+ data.largeImageText = DiscordUtil.data.logoText;
- ready = false;
+ #if GLOBAL_SCRIPT
+ var event = funkin.scripting.GlobalScript.event("onDiscordPresenceUpdate", EventManager.get(DiscordPresenceUpdateEvent).recycle(data));
+ if (event.cancelled) return;
- DiscordRpc.start({
+ #end
+ DiscordRpc.presence(data);
+ #end
+ }
+ public static function changeClientID(id:String) {
+ #if DISCORD_RPC
+ if (currentID != null) {
+ DiscordRpc.shutdown();
+ }
+
+ ready = false;
+
+ DiscordRpc.start({
clientID: id,
onReady: function() {
- Logs.trace('Discord RPC started');
- ready = true;
- },
+ Logs.trace('Discord RPC started');
+ ready = true;
+ },
onError: onError,
onDisconnected: onDisconnected
});
- currentID = id;
+ currentID = id;
- #end
- }
+ #end
+ }
- public static function shutdown() {
- #if DISCORD_RPC
- DiscordRpc.shutdown();
- #end
- }
+ public static function shutdown() {
+ #if DISCORD_RPC
+ DiscordRpc.shutdown();
+ #end
+ }
- // HANDLERS
- #if DISCORD_RPC
- static function onError(_code:Int, _message:String) {
- Logs.trace('Discord RPC Error: ${_message} (Code: $_code)', ERROR);
- }
+ // HANDLERS
+ #if DISCORD_RPC
+ static function onError(_code:Int, _message:String) {
+ Logs.trace('Discord RPC Error: ${_message} (Code: $_code)', ERROR);
+ }
- static function onDisconnected(_code:Int, _message:String) {
- Logs.trace('Discord RPC Disconnected: ${_message} (Code: $_code)', WARNING);
- }
- #end
+ static function onDisconnected(_code:Int, _message:String) {
+ Logs.trace('Discord RPC Disconnected: ${_message} (Code: $_code)', WARNING);
+ }
+ #end
}
typedef DiscordJson = {
- var ?clientID:String;
- var ?logoKey:String;
- var ?logoText:String;
+ var ?clientID:String;
+ var ?logoKey:String;
+ var ?logoText:String;
}
\ No newline at end of file
diff --git a/source/funkin/utils/EngineUtil.hx b/source/funkin/utils/EngineUtil.hx
index 536357cb..cb6d68e6 100644
--- a/source/funkin/utils/EngineUtil.hx
+++ b/source/funkin/utils/EngineUtil.hx
@@ -4,12 +4,12 @@ import funkin.scripting.Script;
import funkin.scripting.MultiThreadedScript;
class EngineUtil {
- /**
- * Starts a new multithreaded script.
- * This script will share all the variables with the current one, which means already existing callbacks will be replaced by new ones on conflict.
- * @param path
- */
- public static function startMultithreadedScript(path:String) {
- return new MultiThreadedScript(path, Script.curScript);
- }
+ /**
+ * Starts a new multithreaded script.
+ * This script will share all the variables with the current one, which means already existing callbacks will be replaced by new ones on conflict.
+ * @param path
+ */
+ public static function startMultithreadedScript(path:String) {
+ return new MultiThreadedScript(path, Script.curScript);
+ }
}
\ No newline at end of file
diff --git a/source/funkin/utils/FlxInterpolateColor.hx b/source/funkin/utils/FlxInterpolateColor.hx
index 2c4c8d32..370e0707 100644
--- a/source/funkin/utils/FlxInterpolateColor.hx
+++ b/source/funkin/utils/FlxInterpolateColor.hx
@@ -7,37 +7,37 @@ import flixel.util.FlxColor;
* Gets rid of precision issues with `FlxColor.interpolate`
*/
class FlxInterpolateColor {
- public var red:Float = 0;
- public var green:Float = 0;
- public var blue:Float = 0;
- public var alpha:Float = 0;
+ public var red:Float = 0;
+ public var green:Float = 0;
+ public var blue:Float = 0;
+ public var alpha:Float = 0;
- public var color(get, set):FlxColor;
+ public var color(get, set):FlxColor;
- private inline function get_color()
- return FlxColor.fromRGBFloat(red, green, blue, alpha);
+ private inline function get_color()
+ return FlxColor.fromRGBFloat(red, green, blue, alpha);
- private inline function set_color(c:FlxColor):FlxColor {
- red = c.redFloat;
- green = c.greenFloat;
- blue = c.blueFloat;
- alpha = c.alphaFloat;
- return c;
- }
+ private inline function set_color(c:FlxColor):FlxColor {
+ red = c.redFloat;
+ green = c.greenFloat;
+ blue = c.blueFloat;
+ alpha = c.alphaFloat;
+ return c;
+ }
- public inline function toString()
- return '[FlxInterpolateColor - (R:${red} | G:${green} | B:${blue} | A:${alpha})]';
- public function new(color:FlxColor) {
- this.color = color;
- }
+ public inline function toString()
+ return '[FlxInterpolateColor - (R:${red} | G:${green} | B:${blue} | A:${alpha})]';
+ public function new(color:FlxColor) {
+ this.color = color;
+ }
- public function lerpTo(color:FlxColor, ratio:Float) {
- red = (color.redFloat - red) * ratio + red;
+ public function lerpTo(color:FlxColor, ratio:Float) {
+ red = (color.redFloat - red) * ratio + red;
green = (color.greenFloat - green) * ratio + green;
blue = (color.blueFloat - blue) * ratio + blue;
alpha = (color.alphaFloat - alpha) * ratio + alpha;
- }
+ }
- public inline function fpsLerpTo(color:FlxColor, ratio:Float)
- lerpTo(color, ratio * 60 * FlxG.elapsed);
+ public inline function fpsLerpTo(color:FlxColor, ratio:Float)
+ lerpTo(color, ratio * 60 * FlxG.elapsed);
}
\ No newline at end of file
diff --git a/source/funkin/utils/IniUtil.hx b/source/funkin/utils/IniUtil.hx
index 48ebeb16..662156f6 100644
--- a/source/funkin/utils/IniUtil.hx
+++ b/source/funkin/utils/IniUtil.hx
@@ -5,36 +5,36 @@ package funkin.utils;
* DOESNT SUPPORT CATEGORIES YET!!
*/
class IniUtil {
- public static inline function parseAsset(assetPath:String, ?defaultVariables:Map)
- return parseString(Assets.getText(assetPath), defaultVariables);
+ public static inline function parseAsset(assetPath:String, ?defaultVariables:Map)
+ return parseString(Assets.getText(assetPath), defaultVariables);
- public static function parseString(data:String, ?defaultVariables:Map) {
- var trimmed:String;
- var splitContent = [for(e in data.split("\n")) if ((trimmed = e.trim()) != "") trimmed];
-
- var finalMap:Map = [];
- if (defaultVariables != null)
- for(k=>e in defaultVariables)
- finalMap[k] = e;
+ public static function parseString(data:String, ?defaultVariables:Map) {
+ var trimmed:String;
+ var splitContent = [for(e in data.split("\n")) if ((trimmed = e.trim()) != "") trimmed];
- for(line in splitContent) {
- // comment
- if (line.startsWith(";")) continue;
- // categories; not supported yet
- if (line.startsWith("[") && line.endsWith("]")) continue;
+ var finalMap:Map = [];
+ if (defaultVariables != null)
+ for(k=>e in defaultVariables)
+ finalMap[k] = e;
- var index = line.indexOf("=");
- var name = line.substr(0, index).trim();
- var value = line.substr(index+1).trim();
+ for(line in splitContent) {
+ // comment
+ if (line.startsWith(";")) continue;
+ // categories; not supported yet
+ if (line.startsWith("[") && line.endsWith("]")) continue;
- if (value.startsWith("\"") && value.endsWith("\""))
- value = value.substr(1, value.length - 2);
+ var index = line.indexOf("=");
+ var name = line.substr(0, index).trim();
+ var value = line.substr(index+1).trim();
- if (value.length == 0 || name.length == 0)
- continue;
-
- finalMap[name] = value;
- }
- return finalMap;
- }
+ if (value.startsWith("\"") && value.endsWith("\""))
+ value = value.substr(1, value.length - 2);
+
+ if (value.length == 0 || name.length == 0)
+ continue;
+
+ finalMap[name] = value;
+ }
+ return finalMap;
+ }
}
\ No newline at end of file
diff --git a/source/funkin/utils/MarkdownUtil.hx b/source/funkin/utils/MarkdownUtil.hx
index 1f240f96..3b50aa2b 100644
--- a/source/funkin/utils/MarkdownUtil.hx
+++ b/source/funkin/utils/MarkdownUtil.hx
@@ -4,84 +4,84 @@ import flixel.util.FlxColor;
import flixel.text.FlxText;
class MarkdownUtil {
- public static function applyMarkdownText(text:FlxText, str:String) {
- text.textField.htmlText = Markdown.markdownToHtml(prepareMarkdown(str));
- var changes:Array = [
- createAdvancedMarkerPair("{title}", 0xFFFFFFFF, text.size * 2, false, true, true),
- createAdvancedMarkerPair("{subtitle}", 0xFFFFFFFF, text.size * 1.5, false, true, true),
- createAdvancedMarkerPair("{subsubtitle}", 0xFFFFFFFF, text.size * 1.25, false, true, true),
- createAdvancedMarkerPair("{ident1}", 0xFFFFFFFF, null, false, false, false, text.size * 2, true),
- createAdvancedMarkerPair("{ident2}", 0xFFFFFFFF, null, false, false, false, text.size * 4, true),
- createAdvancedMarkerPair("{ident3}", 0xFFFFFFFF, null, false, false, false, text.size * 6, true),
- createAdvancedMarkerPair("{ident4}", 0xFFFFFFFF, null, false, false, false, text.size * 8, true),
- new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFFFFF00, false, true), "{o}"),
- new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFFF0000, false, true), "{r}"),
- new FlxTextFormatMarkerPair(new FlxTextFormat(0xFF00FF08, false, true), "{g}"),
- new FlxTextFormatMarkerPair(new FlxTextFormat(0xFF7D7D7D, false, true), "{gray}"),
- new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFFFFFFF, false, true, 0xFF222222), "{italic}"),
- new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFFFFFFF, false, true, 0xFF666666), "{bold}"),
- new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFFFFFFF, false, true, 0xFF888888), "{bold-italic}"),
- ];
+ public static function applyMarkdownText(text:FlxText, str:String) {
+ text.textField.htmlText = Markdown.markdownToHtml(prepareMarkdown(str));
+ var changes:Array = [
+ createAdvancedMarkerPair("{title}", 0xFFFFFFFF, text.size * 2, false, true, true),
+ createAdvancedMarkerPair("{subtitle}", 0xFFFFFFFF, text.size * 1.5, false, true, true),
+ createAdvancedMarkerPair("{subsubtitle}", 0xFFFFFFFF, text.size * 1.25, false, true, true),
+ createAdvancedMarkerPair("{ident1}", 0xFFFFFFFF, null, false, false, false, text.size * 2, true),
+ createAdvancedMarkerPair("{ident2}", 0xFFFFFFFF, null, false, false, false, text.size * 4, true),
+ createAdvancedMarkerPair("{ident3}", 0xFFFFFFFF, null, false, false, false, text.size * 6, true),
+ createAdvancedMarkerPair("{ident4}", 0xFFFFFFFF, null, false, false, false, text.size * 8, true),
+ new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFFFFF00, false, true), "{o}"),
+ new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFFF0000, false, true), "{r}"),
+ new FlxTextFormatMarkerPair(new FlxTextFormat(0xFF00FF08, false, true), "{g}"),
+ new FlxTextFormatMarkerPair(new FlxTextFormat(0xFF7D7D7D, false, true), "{gray}"),
+ new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFFFFFFF, false, true, 0xFF222222), "{italic}"),
+ new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFFFFFFF, false, true, 0xFF666666), "{bold}"),
+ new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFFFFFFF, false, true, 0xFF888888), "{bold-italic}"),
+ ];
- text.applyMarkup(
- parseWarnings(text.textField.text),
- changes
- );
- @:privateAccess {
- // hacky fix for the text cutting when bigger text formats are used
- text._regen = true;
- text.regenGraphic();
- text._regen = true;
- text.regenGraphic();
- }
- }
+ text.applyMarkup(
+ parseWarnings(text.textField.text),
+ changes
+ );
+ @:privateAccess {
+ // hacky fix for the text cutting when bigger text formats are used
+ text._regen = true;
+ text.regenGraphic();
+ text._regen = true;
+ text.regenGraphic();
+ }
+ }
- public static function createAdvancedMarkerPair(marker:String, color:FlxColor, size:Null, bold:Bool = false, italic:Bool = false, ?underline:Bool = false, ?blockIndent:Int, ?bullet:Bool) {
- @:privateAccess {
- var format = new FlxTextFormat(color, bold, italic);
- format.format.size = size == null ? null : Std.int(size);
- format.format.underline = underline;
- format.format.blockIndent = blockIndent;
- format.format.bullet = bullet;
- return new FlxTextFormatMarkerPair(format, marker);
- }
- }
+ public static function createAdvancedMarkerPair(marker:String, color:FlxColor, size:Null, bold:Bool = false, italic:Bool = false, ?underline:Bool = false, ?blockIndent:Int, ?bullet:Bool) {
+ @:privateAccess {
+ var format = new FlxTextFormat(color, bold, italic);
+ format.format.size = size == null ? null : Std.int(size);
+ format.format.underline = underline;
+ format.format.blockIndent = blockIndent;
+ format.format.bullet = bullet;
+ return new FlxTextFormatMarkerPair(format, marker);
+ }
+ }
- public static function parseWarnings(text:String) {
- text = text.replace(" ", " ");
- text = parseEmote(text, "⚠", "{o}(!)", "{o}");
- text = parseEmote(text, "❌", "{r}(X)", "{r}");
- text = parseEmote(text, "✔", "{g}(+)", "{g}");
- return text;
- }
+ public static function parseWarnings(text:String) {
+ text = text.replace(" ", " ");
+ text = parseEmote(text, "⚠", "{o}(!)", "{o}");
+ text = parseEmote(text, "❌", "{r}(X)", "{r}");
+ text = parseEmote(text, "✔", "{g}(+)", "{g}");
+ return text;
+ }
- public static function prepareMarkdown(text:String) {
- text = "\n" + text;
- text = parseEmote(text, "\n- ", "\n{ident1} • ", "{ident1}");
- text = parseEmote(text, "\n - ", "\n{ident2} • ", "{ident2}");
- text = parseEmote(text, "\n - ", "\n{ident3} • ", "{ident3}");
- text = parseEmote(text, "\n - ", "\n{ident4} • ", "{ident4}");
- text = parseEmote(text, "\n> ", "\n{gray}", "{gray}");
- text = parseEmote(text, "\n### ", "\n{subsubtitle}", "{subsubtitle}");
- text = parseEmote(text, "\n## ", "\n{subtitle}", "{subtitle}");
- text = parseEmote(text, "\n# ", "\n{title}", "{title}");
- text = parseEmote(text, "***", "{bold-italic}", "{bold-italic}", "***");
- text = parseEmote(text, "**", "{bold}", "{bold}", "**");
- text = parseEmote(text, "*", "{italic}", "{italic}", "*");
- text = parseEmote(text, "_", "{italic}", "{italic}", "*");
- text = parseEmote(text, "__", "{bold}", "{bold}", "*");
- text.substr("\n".length);
- return text;
- }
+ public static function prepareMarkdown(text:String) {
+ text = "\n" + text;
+ text = parseEmote(text, "\n- ", "\n{ident1} • ", "{ident1}");
+ text = parseEmote(text, "\n - ", "\n{ident2} • ", "{ident2}");
+ text = parseEmote(text, "\n - ", "\n{ident3} • ", "{ident3}");
+ text = parseEmote(text, "\n - ", "\n{ident4} • ", "{ident4}");
+ text = parseEmote(text, "\n> ", "\n{gray}", "{gray}");
+ text = parseEmote(text, "\n### ", "\n{subsubtitle}", "{subsubtitle}");
+ text = parseEmote(text, "\n## ", "\n{subtitle}", "{subtitle}");
+ text = parseEmote(text, "\n# ", "\n{title}", "{title}");
+ text = parseEmote(text, "***", "{bold-italic}", "{bold-italic}", "***");
+ text = parseEmote(text, "**", "{bold}", "{bold}", "**");
+ text = parseEmote(text, "*", "{italic}", "{italic}", "*");
+ text = parseEmote(text, "_", "{italic}", "{italic}", "*");
+ text = parseEmote(text, "__", "{bold}", "{bold}", "*");
+ text.substr("\n".length);
+ return text;
+ }
- public static function parseEmote(text:String, emote:String, beginning:String, end:String, emoteEnd:String = "\n") {
- var index:Int;
- while((index = text.indexOf(emote)) >= 0) {
- var nextIndex = text.indexOf(emoteEnd, index + emote.length);
- if (nextIndex < 0)
- nextIndex = text.length;
- text = text.substr(0, index) + beginning + text.substring(index + emote.length, nextIndex) + end + (emote == emoteEnd ? "" : emoteEnd) + text.substring(nextIndex + emoteEnd.length);
- }
- return text;
- }
+ public static function parseEmote(text:String, emote:String, beginning:String, end:String, emoteEnd:String = "\n") {
+ var index:Int;
+ while((index = text.indexOf(emote)) >= 0) {
+ var nextIndex = text.indexOf(emoteEnd, index + emote.length);
+ if (nextIndex < 0)
+ nextIndex = text.length;
+ text = text.substr(0, index) + beginning + text.substring(index + emote.length, nextIndex) + end + (emote == emoteEnd ? "" : emoteEnd) + text.substring(nextIndex + emoteEnd.length);
+ }
+ return text;
+ }
}
\ No newline at end of file
diff --git a/source/funkin/utils/MemoryUtil.hx b/source/funkin/utils/MemoryUtil.hx
index 451442f1..7635512c 100644
--- a/source/funkin/utils/MemoryUtil.hx
+++ b/source/funkin/utils/MemoryUtil.hx
@@ -30,7 +30,7 @@ class MemoryUtil {
}
public static function init() {}
-
+
public static function clearMinor() {
#if (cpp || java || neko)
Gc.run(false);
diff --git a/source/funkin/utils/NdllUtil.hx b/source/funkin/utils/NdllUtil.hx
index 9780d6d8..a23fd527 100644
--- a/source/funkin/utils/NdllUtil.hx
+++ b/source/funkin/utils/NdllUtil.hx
@@ -4,12 +4,12 @@ import lime.app.Application;
/**
* Small util that allows you to load any function from ndlls via `getFunction`.
- *
+ *
* NDLLs must be in your mod's "ndlls" folder, and must follow this name scheme:
* - `name-windows.ndll` for Windows targeted ndlls
* - `name-linux.ndll` for Linux targeted ndlls
* - `name-mac.ndll` for Mac targeted ndlls
- *
+ *
* If:
* - The platform does not support NDLLs
* - The NDLL is not found
@@ -17,52 +17,52 @@ import lime.app.Application;
* then an empty function will be returned instead, and a message will be shown in logs.
*/
class NdllUtil {
- #if NDLLS_SUPPORTED
- #if windows public static final os:String = "windows"; #end
- #if linux public static final os:String = "linux"; #end
- #if macos public static final os:String = "mac"; #end
- #if android public static final os:String = "android"; #end
- #end
+ #if NDLLS_SUPPORTED
+ #if windows public static final os:String = "windows"; #end
+ #if linux public static final os:String = "linux"; #end
+ #if macos public static final os:String = "mac"; #end
+ #if android public static final os:String = "android"; #end
+ #end
- /**
- * Returns an function from a Haxe NDLL.
- *
- * @param ndll Name of the NDLL.
- * @param name Name of the function.
- * @param args Number of arguments of that function.
- */
- public static function getFunction(ndll:String, name:String, args:Int) {
- #if NDLLS_SUPPORTED
- return getFunctionFromPath(Paths.ndll('$ndll-$os'), name, args);
- #else
- Logs.trace('NDLLs are not supported on this platform.', WARNING);
- return function() {};
- #end
- }
-
- /**
- * Returns an function from a Haxe NDLL at specified path.
- *
- * @param ndll Asset path to the NDLL.
- * @param name Name of the function.
- * @param args Number of arguments of that function.
- */
- public static function getFunctionFromPath(ndll:String, name:String, args:Int) {
- #if NDLLS_SUPPORTED
- if (!Assets.exists(ndll)) {
- Logs.trace('Couldn\'t find ndll at ${ndll}.', WARNING);
- return function() {};
+ /**
+ * Returns an function from a Haxe NDLL.
+ *
+ * @param ndll Name of the NDLL.
+ * @param name Name of the function.
+ * @param args Number of arguments of that function.
+ */
+ public static function getFunction(ndll:String, name:String, args:Int) {
+ #if NDLLS_SUPPORTED
+ return getFunctionFromPath(Paths.ndll('$ndll-$os'), name, args);
+ #else
+ Logs.trace('NDLLs are not supported on this platform.', WARNING);
+ return function() {};
+ #end
+ }
+
+ /**
+ * Returns an function from a Haxe NDLL at specified path.
+ *
+ * @param ndll Asset path to the NDLL.
+ * @param name Name of the function.
+ * @param args Number of arguments of that function.
+ */
+ public static function getFunctionFromPath(ndll:String, name:String, args:Int) {
+ #if NDLLS_SUPPORTED
+ if (!Assets.exists(ndll)) {
+ Logs.trace('Couldn\'t find ndll at ${ndll}.', WARNING);
+ return function() {};
}
var func = lime.system.CFFI.load(Assets.getPath(ndll), name, args);
-
- if (func == null) {
+
+ if (func == null) {
Logs.trace('Method ${name} in ndll ${ndll} with ${args} args was not found.', ERROR);
- return function() {};
+ return function() {};
}
- return func;
- #else
- Logs.trace('NDLLs are not supported on this platform.', WARNING);
- #end
- return function() {};
- }
+ return func;
+ #else
+ Logs.trace('NDLLs are not supported on this platform.', WARNING);
+ #end
+ return function() {};
+ }
}
\ No newline at end of file
diff --git a/source/funkin/utils/ThreadUtil.hx b/source/funkin/utils/ThreadUtil.hx
index 2ecab02a..3415f49c 100644
--- a/source/funkin/utils/ThreadUtil.hx
+++ b/source/funkin/utils/ThreadUtil.hx
@@ -2,31 +2,31 @@ package funkin.utils;
#if ALLOW_MULTITHREADING
class ThreadUtil {
- /**
- * Creates a new Thread with an error handler.
- * @param func Function to execute
- * @param autoRestart Whenever the thread should auto restart itself after crashing.
- */
- public static function createSafe(func:Void->Void, autoRestart:Bool = false) {
- if (autoRestart) {
- return sys.thread.Thread.create(function() {
- while(true) {
- try {
- func();
- } catch(e) {
- trace(e.details());
- }
- }
- });
- } else {
- return sys.thread.Thread.create(function() {
- try {
- func();
- } catch(e) {
- trace(e.details());
- }
- });
- }
- }
+ /**
+ * Creates a new Thread with an error handler.
+ * @param func Function to execute
+ * @param autoRestart Whenever the thread should auto restart itself after crashing.
+ */
+ public static function createSafe(func:Void->Void, autoRestart:Bool = false) {
+ if (autoRestart) {
+ return sys.thread.Thread.create(function() {
+ while(true) {
+ try {
+ func();
+ } catch(e) {
+ trace(e.details());
+ }
+ }
+ });
+ } else {
+ return sys.thread.Thread.create(function() {
+ try {
+ func();
+ } catch(e) {
+ trace(e.details());
+ }
+ });
+ }
+ }
}
#end
\ No newline at end of file
diff --git a/source/funkin/utils/XMLUtil.hx b/source/funkin/utils/XMLUtil.hx
index b3e3fdd3..af62c1cd 100644
--- a/source/funkin/utils/XMLUtil.hx
+++ b/source/funkin/utils/XMLUtil.hx
@@ -13,34 +13,34 @@ using StringTools;
*/
class XMLUtil {
- /**
- * Applies a property XML node to an object.
- * @param object Object to which the xml property will be applied
- * @param property `property` node.
- */
- public static function applyXMLProperty(object:Dynamic, property:Access):ErrorCode {
- if (!property.has.name || !property.has.type || !property.has.value) {
- Logs.trace('Failed to apply XML property: XML Element misses name, type, or value attributes.', WARNING);
- return MISSING_PROPERTY;
- }
+ /**
+ * Applies a property XML node to an object.
+ * @param object Object to which the xml property will be applied
+ * @param property `property` node.
+ */
+ public static function applyXMLProperty(object:Dynamic, property:Access):ErrorCode {
+ if (!property.has.name || !property.has.type || !property.has.value) {
+ Logs.trace('Failed to apply XML property: XML Element misses name, type, or value attributes.', WARNING);
+ return MISSING_PROPERTY;
+ }
- var value:Dynamic = switch(property.att.type.toLowerCase()) {
- case "float" | "number": Std.parseFloat(property.att.value);
- case "int" | "integer" | "color": Std.parseInt(property.att.value);
- case "string" | "str" | "text": property.att.value;
- case "bool" | "boolean": property.att.value.toLowerCase() == "true";
- default: return TYPE_INCORRECT;
- }
- if (value == null) return VALUE_NULL;
+ var value:Dynamic = switch(property.att.type.toLowerCase()) {
+ case "float" | "number": Std.parseFloat(property.att.value);
+ case "int" | "integer" | "color": Std.parseInt(property.att.value);
+ case "string" | "str" | "text": property.att.value;
+ case "bool" | "boolean": property.att.value.toLowerCase() == "true";
+ default: return TYPE_INCORRECT;
+ }
+ if (value == null) return VALUE_NULL;
- try {
- Reflect.setProperty(object, property.att.name, value);
- } catch(e) {
- Logs.trace('Failed to apply XML property: $e on ${Type.getClass(object)}', WARNING);
- return REFLECT_ERROR;
- }
- return OK;
- }
+ try {
+ Reflect.setProperty(object, property.att.name, value);
+ } catch(e) {
+ Logs.trace('Failed to apply XML property: $e on ${Type.getClass(object)}', WARNING);
+ return REFLECT_ERROR;
+ }
+ return OK;
+ }
/**
* Creates a new sprite based on a XML node.
@@ -69,11 +69,11 @@ class XMLUtil {
if (node.has.scrollx) {
var scroll:Null = Std.parseFloat(node.att.scrollx);
if (scroll != null) spr.scrollFactor.x = scroll;
- }
+ }
if (node.has.scrolly) {
var scroll:Null = Std.parseFloat(node.att.scrolly);
if (scroll != null) spr.scrollFactor.y = scroll;
- }
+ }
}
if (node.has.antialiasing) spr.antialiasing = node.att.antialiasing == "true";
if (node.has.scale) {
@@ -83,7 +83,7 @@ class XMLUtil {
if (node.has.updateHitbox && node.att.updateHitbox == "true") spr.updateHitbox();
spr.zoomFactor = Std.parseFloat(node.getAtt("zoomfactor")).getDefault(spr.zoomFactor);
-
+
for(anim in node.nodes.anim)
addXMLAnimation(spr, anim);
@@ -116,7 +116,7 @@ class XMLUtil {
if (i != null)
animData.indices.push(i);
}
- }
+ }
return animData;
}
@@ -164,9 +164,9 @@ class XMLUtil {
// nothing
}
}
- return OK;
+ return OK;
}
- return MISSING_PROPERTY;
+ return MISSING_PROPERTY;
}
public static inline function fixXMLText(text:String) {
diff --git a/source/funkin/utils/ZipUtil.hx b/source/funkin/utils/ZipUtil.hx
index 99594616..a4fa8e8e 100644
--- a/source/funkin/utils/ZipUtil.hx
+++ b/source/funkin/utils/ZipUtil.hx
@@ -24,81 +24,81 @@ using StringTools;
// import ZipUtils; var e = ZipUtils.createZipFile("gjnsdghs.ycemod"); ZipUtils.writeFolderToZip(e, "./mods/Friday Night Funkin'/", "Friday Night Funkin'/"); e.flush(); e.close();
class ZipUtil {
- public static var bannedNames:Array = [".git", ".gitignore", ".github", ".vscode", ".gitattributes", "readme.txt"];
+ public static var bannedNames:Array = [".git", ".gitignore", ".github", ".vscode", ".gitattributes", "readme.txt"];
/**
* [Description] Uncompresses `zip` into the `destFolder` folder
- * @param zip
- * @param destFolder
+ * @param zip
+ * @param destFolder
*/
public static function uncompressZip(zip:Reader, destFolder:String, ?prefix:String, ?prog:ZipProgress):ZipProgress {
// we never know
FileSystem.createDirectory(destFolder);
- var fields = zip.read();
+ var fields = zip.read();
- try {
- if (prefix != null) {
- var f = fields;
- fields = new List();
- for(field in f) {
- if (field.fileName.startsWith(prefix)) {
- fields.push(field);
- }
- }
- }
-
- if (prog == null)
- prog = new ZipProgress();
- prog.fileCount = fields.length;
- for(k=>field in fields) {
- prog.curFile = k;
- var isFolder = field.fileName.endsWith("/") && field.fileSize == 0;
- if (isFolder) {
- FileSystem.createDirectory('${destFolder}/${field.fileName}');
- } else {
- var split = [for(e in field.fileName.split("/")) e.trim()];
- split.pop();
- FileSystem.createDirectory('${destFolder}/${split.join("/")}');
-
- var data = unzip(field);
- File.saveBytes('${destFolder}/${field.fileName}', data);
- }
- }
- prog.curFile = fields.length;
- prog.done = true;
- } catch(e) {
- prog.done = true;
- prog.error = e;
- }
- return prog;
+ try {
+ if (prefix != null) {
+ var f = fields;
+ fields = new List();
+ for(field in f) {
+ if (field.fileName.startsWith(prefix)) {
+ fields.push(field);
+ }
+ }
+ }
+
+ if (prog == null)
+ prog = new ZipProgress();
+ prog.fileCount = fields.length;
+ for(k=>field in fields) {
+ prog.curFile = k;
+ var isFolder = field.fileName.endsWith("/") && field.fileSize == 0;
+ if (isFolder) {
+ FileSystem.createDirectory('${destFolder}/${field.fileName}');
+ } else {
+ var split = [for(e in field.fileName.split("/")) e.trim()];
+ split.pop();
+ FileSystem.createDirectory('${destFolder}/${split.join("/")}');
+
+ var data = unzip(field);
+ File.saveBytes('${destFolder}/${field.fileName}', data);
+ }
+ }
+ prog.curFile = fields.length;
+ prog.done = true;
+ } catch(e) {
+ prog.done = true;
+ prog.error = e;
+ }
+ return prog;
}
- #if (!macro && sys)
- public static function uncompressZipAsync(zip:Reader, destFolder:String, ?prog:ZipProgress, ?prefix:String):ZipProgress {
- if (prog == null)
- prog = new ZipProgress();
- Thread.create(function() {
- uncompressZip(zip, destFolder, prefix, prog);
- });
- return prog;
- }
- #end
+ #if (!macro && sys)
+ public static function uncompressZipAsync(zip:Reader, destFolder:String, ?prog:ZipProgress, ?prefix:String):ZipProgress {
+ if (prog == null)
+ prog = new ZipProgress();
+ Thread.create(function() {
+ uncompressZip(zip, destFolder, prefix, prog);
+ });
+ return prog;
+ }
+ #end
- /**
- * [Description] Returns a `zip.Reader` instance from path.
- * @param zipPath
- * @return Reader
- */
- public static function openZip(zipPath:String):Reader {
- return new ZipReader(File.read(zipPath));
- }
+ /**
+ * [Description] Returns a `zip.Reader` instance from path.
+ * @param zipPath
+ * @return Reader
+ */
+ public static function openZip(zipPath:String):Reader {
+ return new ZipReader(File.read(zipPath));
+ }
- /**
- * [Description] Copy of haxe's Zip unzip function cause lime replaced it.
- * @param f Zip entry
- */
- public static function unzip(f:Entry) {
+ /**
+ * [Description] Copy of haxe's Zip unzip function cause lime replaced it.
+ * @param f Zip entry
+ */
+ public static function unzip(f:Entry) {
if (!f.compressed)
return f.data;
var c = new haxe.zip.Uncompress(-15);
@@ -113,156 +113,156 @@ class ZipUtil {
return f.data;
}
- /**
- * [Description] Creates a ZIP file at the specified location and returns the Writer.
- * @param path
- * @return Writer
- */
- public static function createZipFile(path:String):ZipWriter {
- var output = File.write(path);
- return new ZipWriter(output);
- }
+ /**
+ * [Description] Creates a ZIP file at the specified location and returns the Writer.
+ * @param path
+ * @return Writer
+ */
+ public static function createZipFile(path:String):ZipWriter {
+ var output = File.write(path);
+ return new ZipWriter(output);
+ }
- /**
- [Description] Writes the entirety of a folder to a zip file.
- @param zip ZIP file to write to
- @param path Folder path
- @param prefix (Additional) allows you to set a prefix in the zip itself.
- **/
- public static function writeFolderToZip(zip:ZipWriter, path:String, ?prefix:String, ?prog:ZipProgress, ?whitelist:Array):ZipProgress {
- if (prefix == null) prefix = "";
- if (whitelist == null) whitelist = [];
- if (prog == null) prog = new ZipProgress();
+ /**
+ [Description] Writes the entirety of a folder to a zip file.
+ @param zip ZIP file to write to
+ @param path Folder path
+ @param prefix (Additional) allows you to set a prefix in the zip itself.
+ **/
+ public static function writeFolderToZip(zip:ZipWriter, path:String, ?prefix:String, ?prog:ZipProgress, ?whitelist:Array):ZipProgress {
+ if (prefix == null) prefix = "";
+ if (whitelist == null) whitelist = [];
+ if (prog == null) prog = new ZipProgress();
- try {
- var curPath:Array = ['$path'];
- var destPath:Array = [];
- if (prefix != "") {
- prefix = prefix.replace("\\", "/");
- while(prefix.charAt(0) == "/") prefix = prefix.substr(1);
- while(prefix.charAt(prefix.length-1) == "/") prefix = prefix.substr(0, prefix.length-1);
- destPath.push(prefix);
- }
-
- var files:Array = [];
-
- var doFolder:Void->Void = null;
- (doFolder = function() {
- var path = curPath.join("/");
- var zipPath = destPath.join("/");
- for(e in FileSystem.readDirectory(path)) {
- if (bannedNames.contains(e.toLowerCase()) && !whitelist.contains(e.toLowerCase())) continue;
- if (FileSystem.isDirectory('$path/$e')) {
- // is directory, so loop into that function again
- for(p in [curPath, destPath]) p.push(e);
- doFolder();
- for(p in [curPath, destPath]) p.pop();
- } else {
- // is file, put it in the list
- var zipPath = '$zipPath/$e';
- while(zipPath.charAt(0) == "/") zipPath = zipPath.substr(1);
- files.push(new StrNameLabel('$path/$e', zipPath));
- }
- }
- })();
-
- prog.fileCount = files.length;
- for(k=>file in files) {
- prog.curFile = k;
-
- var fileContent = File.getBytes(file.name);
- var fileInfo = FileSystem.stat(file.name);
- var entry:Entry = {
- fileName: file.label,
- fileSize: fileInfo.size,
- fileTime: Date.now(),
- dataSize: 0,
- data: fileContent,
- crc32: Crc32.make(fileContent),
- compressed: false
- };
- Tools.compress(entry, 1);
- zip.writeFile(entry);
- }
- zip.writeCDR();
- } catch(e) {
- prog.error = e;
- }
- prog.done = true;
- return prog;
- }
+ try {
+ var curPath:Array = ['$path'];
+ var destPath:Array = [];
+ if (prefix != "") {
+ prefix = prefix.replace("\\", "/");
+ while(prefix.charAt(0) == "/") prefix = prefix.substr(1);
+ while(prefix.charAt(prefix.length-1) == "/") prefix = prefix.substr(0, prefix.length-1);
+ destPath.push(prefix);
+ }
- public static function writeFolderToZipAsync(zip:ZipWriter, path:String, ?prefix:String):ZipProgress {
- var zipProg = new ZipProgress();
- Thread.create(function() {
- writeFolderToZip(zip, path, prefix, zipProg);
- });
- return zipProg;
- }
+ var files:Array = [];
- /**
- * [Description] Converts an `Array` to a `List`.
- * @param array
- * @return List
- */
- public static function arrayToList(array:Array):List {
- var list = new List();
- for(e in array) list.push(e);
- return list;
- }
+ var doFolder:Void->Void = null;
+ (doFolder = function() {
+ var path = curPath.join("/");
+ var zipPath = destPath.join("/");
+ for(e in FileSystem.readDirectory(path)) {
+ if (bannedNames.contains(e.toLowerCase()) && !whitelist.contains(e.toLowerCase())) continue;
+ if (FileSystem.isDirectory('$path/$e')) {
+ // is directory, so loop into that function again
+ for(p in [curPath, destPath]) p.push(e);
+ doFolder();
+ for(p in [curPath, destPath]) p.pop();
+ } else {
+ // is file, put it in the list
+ var zipPath = '$zipPath/$e';
+ while(zipPath.charAt(0) == "/") zipPath = zipPath.substr(1);
+ files.push(new StrNameLabel('$path/$e', zipPath));
+ }
+ }
+ })();
+
+ prog.fileCount = files.length;
+ for(k=>file in files) {
+ prog.curFile = k;
+
+ var fileContent = File.getBytes(file.name);
+ var fileInfo = FileSystem.stat(file.name);
+ var entry:Entry = {
+ fileName: file.label,
+ fileSize: fileInfo.size,
+ fileTime: Date.now(),
+ dataSize: 0,
+ data: fileContent,
+ crc32: Crc32.make(fileContent),
+ compressed: false
+ };
+ Tools.compress(entry, 1);
+ zip.writeFile(entry);
+ }
+ zip.writeCDR();
+ } catch(e) {
+ prog.error = e;
+ }
+ prog.done = true;
+ return prog;
+ }
+
+ public static function writeFolderToZipAsync(zip:ZipWriter, path:String, ?prefix:String):ZipProgress {
+ var zipProg = new ZipProgress();
+ Thread.create(function() {
+ writeFolderToZip(zip, path, prefix, zipProg);
+ });
+ return zipProg;
+ }
+
+ /**
+ * [Description] Converts an `Array` to a `List`.
+ * @param array
+ * @return List
+ */
+ public static function arrayToList(array:Array):List {
+ var list = new List();
+ for(e in array) list.push(e);
+ return list;
+ }
}
class ZipProgress {
- public var error:Exception = null;
-
- public var curFile:Int = 0;
- public var fileCount:Int = 0;
- public var done:Bool = false;
- public var percentage(get, null):Float;
+ public var error:Exception = null;
- private function get_percentage() {
- return fileCount <= 0 ? 0 : curFile / fileCount;
- }
+ public var curFile:Int = 0;
+ public var fileCount:Int = 0;
+ public var done:Bool = false;
+ public var percentage(get, null):Float;
- public function new() {}
+ private function get_percentage() {
+ return fileCount <= 0 ? 0 : curFile / fileCount;
+ }
+
+ public function new() {}
}
class ZipReader extends Reader {
- public var files:List;
+ public var files:List;
- public override function read() {
- if (files != null) return files;
- try {
- var files = super.read();
- return this.files = files;
- } catch(e) {
- }
- return new List();
- }
+ public override function read() {
+ if (files != null) return files;
+ try {
+ var files = super.read();
+ return this.files = files;
+ } catch(e) {
+ }
+ return new List();
+ }
}
class ZipWriter extends Writer {
- public function flush() {
- o.flush();
- }
+ public function flush() {
+ o.flush();
+ }
- public function writeFile(entry:Entry) {
- writeEntryHeader(entry);
- o.writeFullBytes(entry.data, 0, entry.data.length);
- }
+ public function writeFile(entry:Entry) {
+ writeEntryHeader(entry);
+ o.writeFullBytes(entry.data, 0, entry.data.length);
+ }
- public function close() {
- o.close();
- }
+ public function close() {
+ o.close();
+ }
}
class StrNameLabel {
- public var name:String;
- public var label:String;
+ public var name:String;
+ public var label:String;
- public function new(name:String, label:String) {
- this.name = name;
- this.label = label;
- }
+ public function new(name:String, label:String) {
+ this.name = name;
+ this.label = label;
+ }
}
#end
\ No newline at end of file
diff --git a/source/funkin/windows/WindowsAPI.hx b/source/funkin/windows/WindowsAPI.hx
index 2d7f017d..fc35756b 100644
--- a/source/funkin/windows/WindowsAPI.hx
+++ b/source/funkin/windows/WindowsAPI.hx
@@ -7,103 +7,103 @@ package funkin.windows;
* Does not have any effect on other platforms.
*/
class WindowsAPI {
- @:dox(hide) public static function registerAudio() {
- #if windows
- native.WinAPI.registerAudio();
- #end
- }
+ @:dox(hide) public static function registerAudio() {
+ #if windows
+ native.WinAPI.registerAudio();
+ #end
+ }
- @:dox(hide) public static function registerAsDPICompatible() {
- #if windows
- native.WinAPI.registerAsDPICompatible();
- #end
- }
-
- /**
- * Allocates a new console. The console will automatically be opened
- */
- public static function allocConsole() {
- #if windows
- native.WinAPI.allocConsole();
- native.WinAPI.clearScreen();
- #end
- }
+ @:dox(hide) public static function registerAsDPICompatible() {
+ #if windows
+ native.WinAPI.registerAsDPICompatible();
+ #end
+ }
- /**
- * Sets the window titlebar to dark mode (Windows 10 only)
- */
- public static function setDarkMode(enable:Bool) {
- #if windows
- native.WinAPI.setDarkMode(enable);
- #end
- }
+ /**
+ * Allocates a new console. The console will automatically be opened
+ */
+ public static function allocConsole() {
+ #if windows
+ native.WinAPI.allocConsole();
+ native.WinAPI.clearScreen();
+ #end
+ }
- /**
- * Shows a message box
- */
- public static function showMessageBox(caption:String, message:String, icon:MessageBoxIcon = MSG_WARNING) {
- #if windows
- native.WinAPI.showMessageBox(caption, message, icon);
- #else
- lime.app.Application.current.window.alert(message, caption);
- #end
- }
+ /**
+ * Sets the window titlebar to dark mode (Windows 10 only)
+ */
+ public static function setDarkMode(enable:Bool) {
+ #if windows
+ native.WinAPI.setDarkMode(enable);
+ #end
+ }
- /**
- * Sets the console colors
- */
- public static function setConsoleColors(foregroundColor:ConsoleColor = LIGHTGRAY, ?backgroundColor:ConsoleColor = BLACK) {
- #if windows
- var fg = cast(foregroundColor, Int);
- var bg = cast(backgroundColor, Int);
- native.WinAPI.setConsoleColors((bg * 16) + fg);
- #end
- }
+ /**
+ * Shows a message box
+ */
+ public static function showMessageBox(caption:String, message:String, icon:MessageBoxIcon = MSG_WARNING) {
+ #if windows
+ native.WinAPI.showMessageBox(caption, message, icon);
+ #else
+ lime.app.Application.current.window.alert(message, caption);
+ #end
+ }
- public static function consoleColorToOpenFL(color:ConsoleColor) {
- return switch(color) {
- case BLACK: 0xFF000000;
- case DARKBLUE: 0xFF000088;
- case DARKGREEN: 0xFF008800;
- case DARKCYAN: 0xFF008888;
- case DARKRED: 0xFF880000;
- case DARKMAGENTA: 0xFF880000;
- case DARKYELLOW: 0xFF888800;
- case LIGHTGRAY: 0xFFBBBBBB;
- case GRAY: 0xFF888888;
- case BLUE: 0xFF0000FF;
- case GREEN: 0xFF00FF00;
- case CYAN: 0xFF00FFFF;
- case RED: 0xFFFF0000;
- case MAGENTA: 0xFFFF00FF;
- case YELLOW: 0xFFFFFF00;
- case WHITE | _: 0xFFFFFFFF;
- }
- }
+ /**
+ * Sets the console colors
+ */
+ public static function setConsoleColors(foregroundColor:ConsoleColor = LIGHTGRAY, ?backgroundColor:ConsoleColor = BLACK) {
+ #if windows
+ var fg = cast(foregroundColor, Int);
+ var bg = cast(backgroundColor, Int);
+ native.WinAPI.setConsoleColors((bg * 16) + fg);
+ #end
+ }
+
+ public static function consoleColorToOpenFL(color:ConsoleColor) {
+ return switch(color) {
+ case BLACK: 0xFF000000;
+ case DARKBLUE: 0xFF000088;
+ case DARKGREEN: 0xFF008800;
+ case DARKCYAN: 0xFF008888;
+ case DARKRED: 0xFF880000;
+ case DARKMAGENTA: 0xFF880000;
+ case DARKYELLOW: 0xFF888800;
+ case LIGHTGRAY: 0xFFBBBBBB;
+ case GRAY: 0xFF888888;
+ case BLUE: 0xFF0000FF;
+ case GREEN: 0xFF00FF00;
+ case CYAN: 0xFF00FFFF;
+ case RED: 0xFFFF0000;
+ case MAGENTA: 0xFFFF00FF;
+ case YELLOW: 0xFFFFFF00;
+ case WHITE | _: 0xFFFFFFFF;
+ }
+ }
}
@:enum abstract ConsoleColor(Int) {
- var BLACK:ConsoleColor = 0;
- var DARKBLUE:ConsoleColor = 1;
- var DARKGREEN:ConsoleColor = 2;
- var DARKCYAN:ConsoleColor = 3;
- var DARKRED:ConsoleColor = 4;
- var DARKMAGENTA:ConsoleColor = 5;
- var DARKYELLOW:ConsoleColor = 6;
- var LIGHTGRAY:ConsoleColor = 7;
- var GRAY:ConsoleColor = 8;
- var BLUE:ConsoleColor = 9;
- var GREEN:ConsoleColor = 10;
- var CYAN:ConsoleColor = 11;
- var RED:ConsoleColor = 12;
- var MAGENTA:ConsoleColor = 13;
- var YELLOW:ConsoleColor = 14;
- var WHITE:ConsoleColor = 15;
+ var BLACK:ConsoleColor = 0;
+ var DARKBLUE:ConsoleColor = 1;
+ var DARKGREEN:ConsoleColor = 2;
+ var DARKCYAN:ConsoleColor = 3;
+ var DARKRED:ConsoleColor = 4;
+ var DARKMAGENTA:ConsoleColor = 5;
+ var DARKYELLOW:ConsoleColor = 6;
+ var LIGHTGRAY:ConsoleColor = 7;
+ var GRAY:ConsoleColor = 8;
+ var BLUE:ConsoleColor = 9;
+ var GREEN:ConsoleColor = 10;
+ var CYAN:ConsoleColor = 11;
+ var RED:ConsoleColor = 12;
+ var MAGENTA:ConsoleColor = 13;
+ var YELLOW:ConsoleColor = 14;
+ var WHITE:ConsoleColor = 15;
}
@:enum abstract MessageBoxIcon(Int) {
- var MSG_ERROR:MessageBoxIcon = 0x00000010;
- var MSG_QUESTION:MessageBoxIcon = 0x00000020;
- var MSG_WARNING:MessageBoxIcon = 0x00000030;
- var MSG_INFORMATION:MessageBoxIcon = 0x00000040;
+ var MSG_ERROR:MessageBoxIcon = 0x00000010;
+ var MSG_QUESTION:MessageBoxIcon = 0x00000020;
+ var MSG_WARNING:MessageBoxIcon = 0x00000030;
+ var MSG_INFORMATION:MessageBoxIcon = 0x00000040;
}
\ No newline at end of file