desktop updates

This commit is contained in:
Yoshman29
2022-12-21 17:24:18 +01:00
parent 2d1980ac84
commit 0c538e3367
16 changed files with 70 additions and 51 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 686 B

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 818 B

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 689 B

After

Width:  |  Height:  |  Size: 488 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 614 B

+1 -1
View File
@@ -1 +1 @@
1641
1667
+10 -2
View File
@@ -24,14 +24,22 @@ class DesktopMain extends MusicBeatState {
public static var instance:DesktopMain;
public var mouseInput:MouseInput = new MouseInput();
public static var mouseInput:MouseInput;
public static var theme:Theme = null;
public static function init() {
theme = Theme.loadFromAssets(Paths.getPath('images/desktop/ui.xml', TEXT, null));
mouseInput = new MouseInput();
FlxG.signals.preUpdate.add(function() {
mouseInput.set(FlxG.mouse.pressed, FlxG.mouse.justPressed, FlxG.mouse.justReleased);
});
}
public override function create() {
super.create();
theme = Theme.loadFromAssets(Paths.getPath('images/desktop/ui.xml', TEXT, null));
instance = this;
FlxG.mouse.useSystemCursor = FlxG.mouse.visible = true;
@@ -74,7 +74,7 @@ class EditorPlayState extends WindowContent {
public override function update(elapsed:Float) {
beforeStateShit();
super.update(elapsed);
state.update(elapsed);
state.tryUpdate(elapsed);
afterStateShit();
}
+1 -1
View File
@@ -53,7 +53,7 @@ class Button extends FlxObject {
public override function update(elapsed:Float) {
super.update(elapsed);
var mouseInput = DesktopMain.instance.mouseInput;
var mouseInput = DesktopMain.mouseInput;
if (mouseInput.overlaps(normalSprite, camera)) {
if (mouseInput.justReleased) {
callback();
+5 -5
View File
@@ -245,20 +245,20 @@ class Window extends FlxTypedGroup<FlxBasic> {
windowInactiveFrame.visible = !(windowFrame.visible = focused);
var i = members.length;
var shouldCancel = DesktopMain.instance.mouseInput.overlapsRect(this, new Rectangle(0, 0, windowCaptionCamera.width, windowCaptionCamera.height), windowCaptionCamera);
var shouldCancel = DesktopMain.mouseInput.overlapsRect(this, new Rectangle(0, 0, windowCaptionCamera.width, windowCaptionCamera.height), windowCaptionCamera);
if (curDialog != null && curDialog.exists) {
if (shouldCancel) {
if (DesktopMain.instance.mouseInput.justPressed) {
if (DesktopMain.mouseInput.justPressed) {
// TODO: sounds
DesktopMain.instance.focusWindow(curDialog);
}
DesktopMain.instance.mouseInput.cancel();
DesktopMain.mouseInput.cancel();
}
return;
} else if (shouldCancel && DesktopMain.instance.mouseInput.justPressed)
} else if (shouldCancel && DesktopMain.mouseInput.justPressed)
DesktopMain.instance.focusWindow(this);
// updates them backwards!!
while(i > 0) {
@@ -268,7 +268,7 @@ class Window extends FlxTypedGroup<FlxBasic> {
spr.update(elapsed);
}
if (shouldCancel) DesktopMain.instance.mouseInput.cancel();
if (shouldCancel) DesktopMain.mouseInput.cancel();
}
public function close() {
@@ -30,7 +30,7 @@ class WindowCaptionButton extends FlxSprite {
super.update(elapsed);
return;
}
var mouseInput = DesktopMain.instance.mouseInput;
var mouseInput = DesktopMain.mouseInput;
visible = switch(ID) {
case 1 | 2: window.resizeable || window.canMinimize;
@@ -45,7 +45,7 @@ class WindowCaptionButton extends FlxSprite {
case 3: window.canHelp;
default: true;
}) {
if (DesktopMain.instance.mouseInput.overlaps(this, camera)) {
if (DesktopMain.mouseInput.overlaps(this, camera)) {
if (mouseInput.justReleased) {
switch(ID) {
case 0:
@@ -38,21 +38,21 @@ class WindowDragHitbox extends FlxObject {
screenPos.x = FlxMath.bound(screenPos.x, 0, FlxG.camera.width);
screenPos.y = FlxMath.bound(screenPos.y, 0, FlxG.camera.height);
if (DesktopMain.instance.mouseInput.justReleased) {
if (DesktopMain.mouseInput.justReleased) {
dragging = false;
offset.put();
return;
}
parent.move(screenPos.x + offset.x, screenPos.y + offset.y);
DesktopMain.instance.mouseInput.cancel();
DesktopMain.mouseInput.cancel();
} else {
if (DesktopMain.instance.mouseInput.overlaps(this, camera)) {
if (DesktopMain.instance.mouseInput.justPressed) {
if (DesktopMain.mouseInput.overlaps(this, camera)) {
if (DesktopMain.mouseInput.justPressed) {
var screenPos = FlxG.mouse.getScreenPosition(FlxG.camera);
offset = FlxPoint.get(parent.content.winX - screenPos.x, parent.content.winY - screenPos.y);
dragging = true;
}
DesktopMain.instance.mouseInput.cancel();
DesktopMain.mouseInput.cancel();
}
}
}
+40 -29
View File
@@ -1,5 +1,6 @@
package funkin.multitasking;
import flixel.system.frontEnds.BitmapFrontEnd;
import openfl.Lib;
import openfl.display.Sprite;
import flash.events.Event;
@@ -14,8 +15,10 @@ import flixel.FlxG;
class StateWindow extends Sprite {
public var window:Window;
public var state:MusicBeatState;
public var cameras:Array<FlxCamera> = [new FlxCamera()];
public var camerasDefault:Array<FlxCamera> = [];
public var camera:FlxCamera;
public var cameras:Array<FlxCamera>;
public var camerasDefault:Array<FlxCamera>;
public var bmapFrontEnd:BitmapFrontEnd = new BitmapFrontEnd();
public function new(windowName:String, state:MusicBeatState) {
super();
@@ -36,6 +39,10 @@ class StateWindow extends Sprite {
window.stage.addChild(this);
camera = new FlxCamera();
cameras = [camera];
camerasDefault = [camera];
state.parentWindow = this;
this.state = state;
@@ -52,6 +59,7 @@ class StateWindow extends Sprite {
var oldCamDefaults:Array<FlxCamera>;
var oldCam:FlxCamera;
var oldState:FlxState;
var oldFrontEnd:BitmapFrontEnd;
public function beforeStateShit() {
oldSize.set(FlxG.width, FlxG.height);
@@ -66,10 +74,25 @@ class StateWindow extends Sprite {
FlxCamera._defaultCameras = FlxG.cameras.defaults = camerasDefault;
FlxG.cameras.list = cameras;
FlxG.camera = cameras[0];
FlxG.camera = camera;
oldState = FlxG.game._state;
FlxG.game._state = state;
if (this.numChildren != cameras.length) {
trace("readding cameras...");
while(this.numChildren > 0)
removeChild(getChildAt(0));
for(c in cameras) {
addChild(c.flashSprite);
c.flashSprite.x = c.flashSprite.y = 0;
}
}
oldFrontEnd = FlxG.bitmap;
FlxG.bitmap = bmapFrontEnd;
}
}
@@ -78,6 +101,7 @@ class StateWindow extends Sprite {
FlxG.width = Std.int(oldSize.x);
FlxG.height = Std.int(oldSize.y);
camera = FlxG.camera;
cameras = FlxG.cameras.list;
camerasDefault = FlxG.cameras.defaults;
@@ -89,49 +113,36 @@ class StateWindow extends Sprite {
oldCam = null;
FlxG.game._state = oldState;
FlxG.bitmap = oldFrontEnd;
oldFrontEnd = null;
}
}
public function update(elapsed:Float) {
beforeStateShit();
@:privateAccess
FlxG.cameras.update(FlxG.elapsed);
state.tryUpdate(elapsed);
afterStateShit();
}
public function draw() {
@:privateAccess {
beforeStateShit();
// for(c in cameras) {
// addChild(c.flashSprite);
// c.color = 0xFF0000;
// }
FlxG.cameras.lock();
state.draw();
FlxG.cameras.unlock();
afterStateShit();
}
}
/*
public override function __enterFrame(t:Float) {
super.__enterFrame(Std.int(t));
@:privateAccess {
beforeStateShit();
for(c in cameras) {
trace(c.x);
trace(c.y);
// c.bgColor = 0xFFFFFFFF;
}
stage.color = 0xFF0000;
FlxG.cameras.update(FlxG.elapsed);
state.tryUpdate(FlxG.elapsed);
FlxG.cameras.lock();
state.draw();
FlxG.cameras.render();
FlxG.cameras.unlock();
afterStateShit();
}
}
*/
}
+2
View File
@@ -1,5 +1,6 @@
package funkin.system;
import funkin.desktop.DesktopMain;
import openfl.utils.AssetLibrary;
import openfl.utils.AssetCache;
import openfl.text.TextFormat;
@@ -139,6 +140,7 @@ class Main extends Sprite
Logs.init();
Paths.init();
ModsFolder.init();
DesktopMain.init();
#if MOD_SUPPORT
ModsFolder.switchMod("introMod");
#end
+3 -5
View File
@@ -189,7 +189,9 @@ class MusicBeatState extends FlxUIState implements IBeatReceiver
}
public override function destroy() {
super.destroy();
if (parentWindow == null)
super.destroy();
call("onDestroy");
if (stateScript != null)
stateScript.destroy();
@@ -197,10 +199,6 @@ class MusicBeatState extends FlxUIState implements IBeatReceiver
public override function draw() {
super.draw();
#if ALLOW_MULTITASKING
if (parentWindow == null)
funkin.multitasking.MultiTaskingHandler.draw();
#end
}
public override function switchTo(nextState:FlxState) {