desktop stuff, on hold
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
555
|
||||
562
|
||||
@@ -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);
|
||||
@@ -44,8 +43,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);
|
||||
updateScreenRes();
|
||||
@@ -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);
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user