diff --git a/assets/images/desktop/ui.xml b/assets/images/desktop/ui.xml
new file mode 100644
index 00000000..66b00bf6
--- /dev/null
+++ b/assets/images/desktop/ui.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/images/desktop/ui/caption.png b/assets/images/desktop/ui/caption.png
new file mode 100644
index 00000000..c981a604
Binary files /dev/null and b/assets/images/desktop/ui/caption.png differ
diff --git a/assets/images/desktop/ui/captionButtons.png b/assets/images/desktop/ui/captionButtons.png
new file mode 100644
index 00000000..faadfa29
Binary files /dev/null and b/assets/images/desktop/ui/captionButtons.png differ
diff --git a/assets/images/desktop/ui/captionInactive.png b/assets/images/desktop/ui/captionInactive.png
new file mode 100644
index 00000000..6e562221
Binary files /dev/null and b/assets/images/desktop/ui/captionInactive.png differ
diff --git a/buildnumber.txt b/buildnumber.txt
index 2764f7b0..50ae8807 100644
--- a/buildnumber.txt
+++ b/buildnumber.txt
@@ -1 +1 @@
-708
\ No newline at end of file
+714
\ No newline at end of file
diff --git a/source/funkin/desktop/DesktopMain.hx b/source/funkin/desktop/DesktopMain.hx
index a056f76c..1b1fbac0 100644
--- a/source/funkin/desktop/DesktopMain.hx
+++ b/source/funkin/desktop/DesktopMain.hx
@@ -19,7 +19,7 @@ class DesktopMain extends MusicBeatState {
public var wallpaper:FlxSprite;
public var screenSize:FlxPoint;
- public var windows:WindowGroup;
+ public var windows:WindowGroup;
public static var instance:DesktopMain;
@@ -44,7 +44,7 @@ class DesktopMain extends MusicBeatState {
screenSize = new FlxPoint(-1, -1);
- windows = new WindowGroup();
+ windows = new WindowGroup();
add(windows);
}
@@ -76,6 +76,23 @@ class DesktopMain extends MusicBeatState {
// TODO: switch back while using config
FlxG.resizeGame(1280, 720);
}
+
+ public function focusWindow(window:Window) {
+ windows.remove(window, true);
+ windows.add(window);
+ layerCameras();
+ }
+
+ public function layerCameras() {
+ for(win in windows.members) {
+ FlxG.cameras.remove(win.windowCaptionCamera, false);
+ for(e in win.windowCameras) FlxG.cameras.remove(e.camera, false);
+ }
+ for(win in windows.members) {
+ FlxG.cameras.add(win.windowCaptionCamera, false);
+ for(e in win.windowCameras) FlxG.cameras.add(e.camera, false);
+ }
+ }
}
class MouseInput {
diff --git a/source/funkin/desktop/windows/Window.hx b/source/funkin/desktop/windows/Window.hx
index f60be5d8..4db01ca0 100644
--- a/source/funkin/desktop/windows/Window.hx
+++ b/source/funkin/desktop/windows/Window.hx
@@ -32,6 +32,7 @@ class Window extends FlxTypedGroup {
public var windowCameras:Array = [];
private var __captionTweens:Array = [];
+ private var __closing:Bool = false;
public var content:WindowContent;
@@ -39,9 +40,15 @@ class Window extends FlxTypedGroup {
public var icon:FlxSprite;
public var dragHitbox:WindowDragHitbox;
- public var draggable:Bool = true;
+ public var moveable:Bool = true;
public var resizeable:Bool = true;
+ public var focused(get, null):Bool;
+
+ private function get_focused() {
+ return DesktopMain.instance.windows.members.last() == this;
+ }
+
public function loadIcon(path:String) {
icon.loadGraphic(path);
icon.setUnstretchedGraphicSize(16, 16, false);
@@ -160,6 +167,10 @@ class Window extends FlxTypedGroup {
var i = members.length;
var shouldCancel = DesktopMain.instance.mouseInput.overlapsRect(this, new Rectangle(0, 0, windowCaptionCamera.width, windowCaptionCamera.height), windowCaptionCamera);
+
+ if (shouldCancel && DesktopMain.instance.mouseInput.justPressed)
+ DesktopMain.instance.focusWindow(this);
+
// updates them backwards!!
while(i > 0) {
i--;
@@ -172,6 +183,7 @@ class Window extends FlxTypedGroup {
}
public function close() {
+ __closing = true;
DesktopMain.instance.windows.remove(this, true);
destroy();
}
diff --git a/source/funkin/desktop/windows/WindowDragHitbox.hx b/source/funkin/desktop/windows/WindowDragHitbox.hx
index 1f95758b..3dc8ee02 100644
--- a/source/funkin/desktop/windows/WindowDragHitbox.hx
+++ b/source/funkin/desktop/windows/WindowDragHitbox.hx
@@ -31,6 +31,7 @@ class WindowDragHitbox extends FlxObject {
public override function update(elapsed:Float) {
super.update(elapsed);
+ if (!parent.moveable) return;
if (dragging) {
var screenPos = FlxG.mouse.getScreenPosition(FlxG.camera);
if (DesktopMain.instance.mouseInput.justReleased) {
diff --git a/source/funkin/desktop/windows/WindowGroup.hx b/source/funkin/desktop/windows/WindowGroup.hx
index ea7968c6..d7f84cba 100644
--- a/source/funkin/desktop/windows/WindowGroup.hx
+++ b/source/funkin/desktop/windows/WindowGroup.hx
@@ -1,20 +1,18 @@
package funkin.desktop.windows;
import flixel.group.FlxGroup.FlxTypedGroup;
+import flixel.FlxBasic;
-class WindowGroup extends FlxTypedGroup {
+class WindowGroup extends FlxTypedGroup {
public override function update(elapsed:Float) {
// update them backwards, so that the top most window gets the priority
- var i = length-1;
- while(i >= 0) {
- var window = members[i];
- if (window == null || !window.exists) {
- i--;
- continue;
- }
- window.update(elapsed);
-
+ var i = length;
+ while(i > 0) {
i--;
+ var window = members[i];
+ if (window == null || !window.exists)
+ continue;
+ window.update(elapsed);
}
}
}
\ No newline at end of file
diff --git a/source/funkin/system/CoolUtil.hx b/source/funkin/system/CoolUtil.hx
index e1d3bbb1..9d431a88 100644
--- a/source/funkin/system/CoolUtil.hx
+++ b/source/funkin/system/CoolUtil.hx
@@ -188,4 +188,11 @@ class CoolUtil
obj.y = (cam.height - obj.height) / 2;
}
}
+
+ /**
+ * Returns last member of array
+ */
+ public static function last(array:Array):T {
+ return array[array.length-1];
+ }
}
\ No newline at end of file