desktop stuff, on hold

This commit is contained in:
Yoshman29
2022-10-19 23:29:55 +02:00
parent cc726df316
commit 4c1f9f58e3
5 changed files with 58 additions and 14 deletions
+1 -1
View File
@@ -1 +1 @@
555
562
+8 -10
View File
@@ -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);
+19 -1
View File
@@ -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<FlxSprite> {
@@ -12,9 +14,13 @@ class Window extends FlxTypedSpriteGroup<FlxSprite> {
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<WindowCaptionButton>();
@@ -30,6 +36,18 @@ class Window extends FlxTypedSpriteGroup<FlxSprite> {
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() {
+2 -2
View File
@@ -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;
@@ -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();
}
}