From 3482d59ed88d495da103632748b11707a004fb49 Mon Sep 17 00:00:00 2001 From: Yoshman29 Date: Wed, 19 Oct 2022 00:36:54 +0200 Subject: [PATCH] window stuff imma go sleep now --- assets/images/desktop/captionButtons.png | Bin 0 -> 250 bytes assets/images/desktop/cursor.png | Bin 0 -> 182 bytes assets/images/desktop/windowFrame.png | Bin 0 -> 152 bytes buildnumber.txt | 2 +- source/funkin/desktop/DesktopMain.hx | 67 +++++++++++++++++++ source/funkin/desktop/Window.hx | 39 +++++++++++ source/funkin/desktop/WindowCaptionButton.hx | 38 +++++++++++ source/funkin/desktop/WindowGroup.hx | 7 ++ source/funkin/menus/MainMenuState.hx | 3 + source/funkin/system/CoolUtil.hx | 8 +++ 10 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 assets/images/desktop/captionButtons.png create mode 100644 assets/images/desktop/cursor.png create mode 100644 assets/images/desktop/windowFrame.png create mode 100644 source/funkin/desktop/DesktopMain.hx create mode 100644 source/funkin/desktop/Window.hx create mode 100644 source/funkin/desktop/WindowCaptionButton.hx create mode 100644 source/funkin/desktop/WindowGroup.hx diff --git a/assets/images/desktop/captionButtons.png b/assets/images/desktop/captionButtons.png new file mode 100644 index 0000000000000000000000000000000000000000..dd4a02ddc42f8f5cb976bbd5d04ba8bd683ff1e0 GIT binary patch literal 250 zcmeAS@N?(olHy`uVBq!ia0vp^Q9vxj!3HF6FFwf(q&N#aB8wRq_zr_G zt(o`C#*@FV=1rBE;kRgWr2dlyccZ%8RFtGox195;tJ1r*+(-Q4^_*SpN52|6FFO3^ zLVaTHH06tlbua91vhTd-rGC-6kFWaVswY!lC{-OlKH(o@Ps*b3`*TjQU6{F>PxR(~ xG2T*!;;{ON7sro&VEEfq4766r*J+XGoE+usyDlj+76RSP;OXk;vd$@?2>=6lXv6>j literal 0 HcmV?d00001 diff --git a/assets/images/desktop/cursor.png b/assets/images/desktop/cursor.png new file mode 100644 index 0000000000000000000000000000000000000000..63d819005f6bf028763a4d1878647788cc187f87 GIT binary patch literal 182 zcmeAS@N?(olHy`uVBq!ia0vp^JU}eU!3HFY*6?ouQk(@Ik;M!Qe1}1p@p%4<6rf;+ zr;B4q#jUlMZu1>b;9$P+?Z5r4*g4&KBD+%d%&ahBn}Ik btl66w1?Dfm8TW8A$UO|6u6{1-oD!M1|%O$WD@{!3Opi<85sBugD~Uq{1qucK`&1i z$B>F!$#d-f9;w&V)MTq^5M07> { + public var windowFrame:FlxUI9SliceSprite; + public var captionButtons:FlxTypedSpriteGroup; + + public var windowWidth:Int = 0; + public var windowHeight:Int = 0; + 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]); + add(windowFrame); + + captionButtons = new FlxTypedSpriteGroup(); + for(i in 0...3) { + var btn = new WindowCaptionButton(this, i); + btn.x = (i+1) * -18; + captionButtons.add(btn); + } + add(captionButtons); + + windowWidth = width; + windowHeight = height; + + scrollFactor.set(0.5, 0.5); + updateWindowFrame(); + } + + public function updateWindowFrame() { + captionButtons.setPosition(windowWidth - 4, 4); + windowFrame.resize(windowWidth, windowHeight); + } +} \ No newline at end of file diff --git a/source/funkin/desktop/WindowCaptionButton.hx b/source/funkin/desktop/WindowCaptionButton.hx new file mode 100644 index 00000000..cb763869 --- /dev/null +++ b/source/funkin/desktop/WindowCaptionButton.hx @@ -0,0 +1,38 @@ +package funkin.desktop; + +import flixel.addons.ui.FlxUIButton; +import flixel.FlxSprite; + +class WindowCaptionButton extends FlxUIButton { + public var icon:FlxSprite; + + public function new(window:Window, i:Int) { + super(0, 0, "", function() { + switch(i) { + default: + trace(i); + } + }); + ID = i; + resize(18, 18); + color = (i > 0) ? 0xFF8888FF : 0xFFFF0000; + + icon = new FlxSprite(0, 0).loadGraphic(Paths.image('desktop/captionButtons'), true, 18, 18); + icon.animation.add("button", [switch(i) { + case 0: 2; + case 1: 1; + case 2: 0; + default: i; + }]); + icon.animation.play("button"); + } + + public override function draw() { + super.draw(); + + icon.setPosition(x, y); + icon.cameras = this.cameras; + icon.draw(); + icon.scrollFactor.set(scrollFactor.x, scrollFactor.y); + } +} \ No newline at end of file diff --git a/source/funkin/desktop/WindowGroup.hx b/source/funkin/desktop/WindowGroup.hx new file mode 100644 index 00000000..e2808d3f --- /dev/null +++ b/source/funkin/desktop/WindowGroup.hx @@ -0,0 +1,7 @@ +package funkin.desktop; + +import flixel.group.FlxGroup.FlxTypedGroup; + +class WindowGroup extends FlxTypedGroup { + // not removing, may be interesting +} \ No newline at end of file diff --git a/source/funkin/menus/MainMenuState.hx b/source/funkin/menus/MainMenuState.hx index 77cd676b..0d697fd9 100644 --- a/source/funkin/menus/MainMenuState.hx +++ b/source/funkin/menus/MainMenuState.hx @@ -122,6 +122,9 @@ class MainMenuState extends MusicBeatState if (!selectedSomethin) { + if (FlxG.keys.justPressed.SEVEN) + FlxG.switchState(new funkin.desktop.DesktopMain()); + if (controls.UP_P) { CoolUtil.playMenuSFX(0); diff --git a/source/funkin/system/CoolUtil.hx b/source/funkin/system/CoolUtil.hx index 73e7548c..249d822d 100644 --- a/source/funkin/system/CoolUtil.hx +++ b/source/funkin/system/CoolUtil.hx @@ -6,6 +6,7 @@ import flixel.animation.FlxAnimation; import flixel.util.FlxColor; import flixel.math.FlxMath; import flixel.FlxG; +import flixel.FlxSprite; using StringTools; @@ -130,6 +131,13 @@ class CoolUtil anim2.frames = old; } + public static function setUnstretchedGraphicSize(sprite:FlxSprite, width:Int, height:Int, fill:Bool = true) { + sprite.setGraphicSize(width, height); + sprite.updateHitbox(); + var nScale = (fill ? Math.max : Math.min)(sprite.scale.x, sprite.scale.y); + sprite.scale.set(nScale, nScale); + } + public static function keyToString(key:Null):String { return switch(key) { case null | 0 | NONE: "---";