From 4c1f9f58e3fec3bf8d0c03166da24ee8dcfc385f Mon Sep 17 00:00:00 2001 From: Yoshman29 Date: Wed, 19 Oct 2022 23:29:55 +0200 Subject: [PATCH] desktop stuff, on hold --- buildnumber.txt | 2 +- source/funkin/desktop/DesktopMain.hx | 18 ++++++------- source/funkin/desktop/Window.hx | 20 +++++++++++++- source/funkin/desktop/WindowCaptionButton.hx | 4 +-- source/funkin/desktop/WindowContentSprite.hx | 28 ++++++++++++++++++++ 5 files changed, 58 insertions(+), 14 deletions(-) create mode 100644 source/funkin/desktop/WindowContentSprite.hx diff --git a/buildnumber.txt b/buildnumber.txt index 8853508e..551f8ca3 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -555 \ No newline at end of file +562 \ No newline at end of file diff --git a/source/funkin/desktop/DesktopMain.hx b/source/funkin/desktop/DesktopMain.hx index 8677fc21..b43cac29 100644 --- a/source/funkin/desktop/DesktopMain.hx +++ b/source/funkin/desktop/DesktopMain.hx @@ -9,20 +9,19 @@ import flixel.FlxSprite; import flixel.math.FlxPoint; class DesktopMain extends MusicBeatState { - var oldScaleMode:BaseScaleMode; - var wallpaper:FlxSprite; - var screenSize:FlxPoint; + public var oldScaleMode:BaseScaleMode; + public var wallpaper:FlxSprite; + public var screenSize:FlxPoint; - var windows:WindowGroup; + public var windows:WindowGroup; - public var instance:DesktopMain; + public static var instance:DesktopMain; public override function create() { super.create(); instance = this; - FlxG.mouse.visible = true; - FlxG.mouse.load(Paths.image('desktop/cursor')); + FlxG.mouse.useSystemCursor = FlxG.mouse.visible = true; oldScaleMode = FlxG.scaleMode; FlxG.scaleMode = new FixedScaleAdjustSizeScaleMode(false, false); @@ -34,7 +33,7 @@ class DesktopMain extends MusicBeatState { wallpaper.scrollFactor.set(0, 0); // anchor at top left add(wallpaper); - screenSize = new FlxPoint(FlxG.width, FlxG.height); + screenSize = new FlxPoint(-1, -1); windows = new WindowGroup(); add(windows); @@ -43,8 +42,6 @@ class DesktopMain extends MusicBeatState { public override function update(elapsed:Float) { super.update(elapsed); - - // trace(FlxG.width, FlxG.height); if (screenSize.x != FlxG.width || screenSize.y != FlxG.height) { screenSize.set(FlxG.width, FlxG.height); @@ -60,6 +57,7 @@ class DesktopMain extends MusicBeatState { public override function destroy() { super.destroy(); FlxG.scaleMode = oldScaleMode; + FlxG.mouse.useSystemCursor = FlxG.mouse.visible = false; // TODO: switch back while using config FlxG.resizeGame(1280, 720); diff --git a/source/funkin/desktop/Window.hx b/source/funkin/desktop/Window.hx index feab033a..52ca5d31 100644 --- a/source/funkin/desktop/Window.hx +++ b/source/funkin/desktop/Window.hx @@ -4,6 +4,8 @@ import flixel.group.FlxSpriteGroup; import openfl.geom.Rectangle; import flixel.addons.ui.FlxUI9SliceSprite; import flixel.FlxSprite; +import flixel.FlxCamera; +import flixel.FlxG; import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup; class Window extends FlxTypedSpriteGroup { @@ -12,9 +14,13 @@ class Window extends FlxTypedSpriteGroup { public var windowWidth:Int = 0; public var windowHeight:Int = 0; + + public var windowCamera:FlxCamera; + public var windowContentSprite:WindowContentSprite; + public function new(caption:String, width:Int = 640, height:Int = 480, x:Int = 20, y:Int = 20) { super(); - windowFrame = new FlxUI9SliceSprite(0, 0, Paths.image('desktop/windowFrame'), new Rectangle(width, height), [3, 3, 6, 6]); + windowFrame = new FlxUI9SliceSprite(0, 0, Paths.image('desktop/windowFrame'), new Rectangle(10, 10), [3, 3, 6, 6]); add(windowFrame); captionButtons = new FlxTypedSpriteGroup(); @@ -30,6 +36,18 @@ class Window extends FlxTypedSpriteGroup { scrollFactor.set(0.5, 0.5); updateWindowFrame(); + + windowContentSprite = new WindowContentSprite(4, 23, FlxG.camera); + add(windowContentSprite); + } + + public function resize(width:Int, height:Int) { + windowFrame.resize(width + 4 + 4, height + 23 + 4); + + } + + public function close() { + DesktopMain.instance.windows.remove(this, true); } public function updateWindowFrame() { diff --git a/source/funkin/desktop/WindowCaptionButton.hx b/source/funkin/desktop/WindowCaptionButton.hx index cb763869..ae46c3b5 100644 --- a/source/funkin/desktop/WindowCaptionButton.hx +++ b/source/funkin/desktop/WindowCaptionButton.hx @@ -9,8 +9,8 @@ class WindowCaptionButton extends FlxUIButton { public function new(window:Window, i:Int) { super(0, 0, "", function() { switch(i) { - default: - trace(i); + case 0: + window.close(); } }); ID = i; diff --git a/source/funkin/desktop/WindowContentSprite.hx b/source/funkin/desktop/WindowContentSprite.hx new file mode 100644 index 00000000..c8a2b8b9 --- /dev/null +++ b/source/funkin/desktop/WindowContentSprite.hx @@ -0,0 +1,28 @@ +package funkin.desktop; + +import flixel.FlxSprite; +import flixel.FlxCamera; + +class WindowContentSprite extends FlxSprite { + var cam:FlxCamera; + public override function get_width() { + return cam.width; + } + public override function get_height() { + return cam.height; + } + + public function new(x:Float, y:Float, cam:FlxCamera) { + super(x, y); + this.cam = cam; + makeGraphic(cam.width, cam.height, 0xFF000000); + } + + public override function update(elapsed:Float) { + super.update(elapsed); + cam.render() + } + public override function draw() { + super.draw(); + } +} \ No newline at end of file