diff --git a/buildnumber.txt b/buildnumber.txt index 01b67236..89395971 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -688 \ No newline at end of file +693 \ No newline at end of file diff --git a/source/funkin/desktop/editors/HelloWorld.hx b/source/funkin/desktop/editors/HelloWorld.hx index ceeea689..e65ee466 100644 --- a/source/funkin/desktop/editors/HelloWorld.hx +++ b/source/funkin/desktop/editors/HelloWorld.hx @@ -5,7 +5,7 @@ import flixel.addons.ui.FlxUIText; class HelloWorld extends WindowContent { public override function new() { - super("Test Window", 250, 250, 640, 480); + super("Test Window", 100, 100, 640, 480); } public override function create() { @@ -16,5 +16,20 @@ class HelloWorld extends WindowContent { helloWorldText.scrollFactor.set(0.5, 0.5); helloWorldText.cameraCenter(camera); add(helloWorldText); + + var t = new FlxUIText(0, 0, 0, "Bottom right text!"); + t.color = 0xFF000000; + t.setPosition(630 - t.width, 470 - t.height); + t.scrollFactor.set(1, 1); + add(t); + } + + public var time:Float = 0; + public override function update(elapsed:Float) { + super.update(elapsed); + time += elapsed; + width = 500 + Std.int(Math.cos(time * Math.PI) * 250); + height = 500 + Std.int(Math.sin(time * Math.PI) * 250); + parent.updateWindowFrame(); } } \ No newline at end of file diff --git a/source/funkin/desktop/windows/Window.hx b/source/funkin/desktop/windows/Window.hx index 882883dd..5404f89e 100644 --- a/source/funkin/desktop/windows/Window.hx +++ b/source/funkin/desktop/windows/Window.hx @@ -14,6 +14,13 @@ import flixel.tweens.FlxTween; import flixel.tweens.FlxEase; import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup; + +typedef WindowCam = { + var camera:FlxCamera; + var resizeScroll:Bool; + var width:Int; + var height:Int; +} class Window extends FlxTypedGroup { public var windowFrame:FlxUI9SliceSprite; public var captionButtons:FlxTypedSpriteGroup; @@ -22,20 +29,25 @@ class Window extends FlxTypedGroup { public var windowHeight:Int = 0; public var windowCaptionCamera:FlxCamera; - public var windowCameras:Array = []; + public var windowCameras:Array = []; private var __captionTweens:Array = []; public var content:WindowContent; public var caption:FlxUIText; + public var icon:FlxSprite; + public function loadIcon(path:String) { + icon.loadGraphic(path); + icon.setUnstretchedGraphicSize(16, 16, false); + } public function new(content:WindowContent) { super(); windowFrame = new FlxUI9SliceSprite(0, 0, Paths.image('desktop/windowFrame'), new Rectangle(10, 10), [3, 3, 6, 6]); add(windowFrame); - caption = new FlxUIText(4, 4, 0, content.title); + caption = new FlxUIText(24, 4, 0, content.title); captionButtons = new FlxTypedSpriteGroup(); for(i in 0...3) { var btn = new WindowCaptionButton(this, i); @@ -43,6 +55,11 @@ class Window extends FlxTypedGroup { captionButtons.add(btn); } add(caption); + + icon = new FlxSprite(4, 4); + add(icon); + loadIcon(content.icon); + add(captionButtons); this.content = content; @@ -65,23 +82,30 @@ class Window extends FlxTypedGroup { } content.cameras = [content.windowCamera]; content.parent = this; + addCamera(content.windowCamera); content.create(); add(content); windowWidth = content.width; windowHeight = content.height; - FlxG.cameras.add(content.windowCamera, false); - windowCameras.push(content.windowCamera); - - popupCamera(windowCaptionCamera); - for(e in windowCameras) popupCamera(e); + for(e in windowCameras) popupCamera(e.camera); resize(content.width, content.height); move(content.winX, content.winY); } + public function addCamera(camera:FlxCamera, useResizeTechnique:Bool = true) { + FlxG.cameras.add(camera, false); + windowCameras.push({ + camera: camera, + resizeScroll: useResizeTechnique, + width: camera.width, + height: camera.height + }); + } + public function changeCaption(text:String) { caption.text = text; } @@ -98,7 +122,12 @@ class Window extends FlxTypedGroup { super.destroy(); for(e in __captionTweens) e.cancel(); FlxG.cameras.remove(windowCaptionCamera, true); - for(cam in windowCameras) FlxG.cameras.remove(cam, true); + for(cam in windowCameras) { + FlxG.cameras.remove(cam.camera, true); + } + windowCameras = null; + windowCaptionCamera = null; + __captionTweens = null; } public function resize(width:Int, height:Int) { @@ -111,8 +140,8 @@ class Window extends FlxTypedGroup { windowCaptionCamera.x = x; windowCaptionCamera.y = y; for(e in windowCameras) { - e.x = x + 4; - e.y = y + 23; + e.camera.x = x + 4; + e.camera.y = y + 23; } } @@ -126,7 +155,10 @@ class Window extends FlxTypedGroup { windowCaptionCamera.setSize(windowWidth + 4 + 4, windowHeight + 23 + 4); captionButtons.setPosition(windowWidth + 4, 4); for(e in windowCameras) { - e.setSize(windowWidth, windowHeight); + e.camera.setSize(windowWidth, windowHeight); + if (e.resizeScroll) { + e.camera.scroll.set(-Std.int(e.camera.width - e.width), -Std.int(e.camera.height - e.height)); + } } } } \ No newline at end of file diff --git a/source/funkin/desktop/windows/WindowContent.hx b/source/funkin/desktop/windows/WindowContent.hx index 3f562c00..c12e6c39 100644 --- a/source/funkin/desktop/windows/WindowContent.hx +++ b/source/funkin/desktop/windows/WindowContent.hx @@ -8,13 +8,33 @@ class WindowContent extends FlxTypedGroup { public var winX(default, set):Float = 0; public var winY(default, set):Float = 0; public var title(default, set):String = "Window"; + public var icon(default, set):String = 'flixel/images/logo/default.png'; public var windowCamera:FlxCamera = null; public var parent:Window = null; - public var width:Int = 0; - public var height:Int = 0; + public var width(default, set):Int = 0; + public var height(default, set):Int = 0; + private var __noParentUpdate:Bool = false; + private function set_width(w:Int):Int { + width = w; + if (parent != null) { + parent.windowWidth = w; + if (!__noParentUpdate) + parent.updateWindowFrame(); + } + return width; + } + private function set_height(h:Int):Int { + height = h; + if (parent != null) { + parent.windowHeight = h; + if (!__noParentUpdate) + parent.updateWindowFrame(); + } + return height; + } private function set_winX(v:Float):Float { winX = v; if (parent != null) parent.move(winX, winY); @@ -26,12 +46,26 @@ class WindowContent extends FlxTypedGroup { if (parent != null) parent.changeCaption(title); return title; } + + private function set_title(text:String):String { + icon = text; + if (parent != null) parent.loadIcon(icon); + return icon; + } private function set_winY(v:Float):Float { winY = v; if (parent != null) parent.move(winX, winY); return winY; } + public function setSize(width:Int, height:Int) { + __noParentUpdate = true; + this.width = width; + this.height = height; + __noParentUpdate = false; + if (parent != null) parent.updateWindowFrame(); + } + public function new(caption:String, x:Float, y:Float, width:Int, height:Int) { super(); this.width = width;