you can maximize windows now + messageboxes
This commit is contained in:
@@ -6,15 +6,9 @@ class WindowCaptionButton extends FlxSprite {
|
||||
public var icon:FlxSprite;
|
||||
public var window:Window;
|
||||
|
||||
public static var anims:Array<String> = ["minimize", "maximize", "close", "restore", "help"];
|
||||
public static var anims:Array<String> = ["close", "maximize", "minimize", "help", "restore"];
|
||||
|
||||
public function new(window:Window, i:Int) {
|
||||
// super(0, 0, "", function() {
|
||||
// switch(i) {
|
||||
// case 0:
|
||||
// window.close();
|
||||
// }
|
||||
// });
|
||||
super(0, 0);
|
||||
this.window = window;
|
||||
ID = i;
|
||||
@@ -22,12 +16,9 @@ class WindowCaptionButton extends FlxSprite {
|
||||
loadGraphic(Paths.image(DesktopMain.theme.captionButtons.sprite), true, Std.int(DesktopMain.theme.captionButtons.size.x), Std.int(DesktopMain.theme.captionButtons.size.y));
|
||||
|
||||
for(k=>e in anims) {
|
||||
animation.add(e, [for(l in 0...6) k + (l * anims.length)], 0, true);
|
||||
animation.add(e, [for(l in 0...8) k + (l * anims.length)], 0, true);
|
||||
}
|
||||
animation.play(anims[ID]);
|
||||
|
||||
// resize(18, 18);
|
||||
// color = (i > 0) ? 0xFF8888FF : 0xFFFF0000;
|
||||
}
|
||||
|
||||
public override function draw() {
|
||||
@@ -40,26 +31,45 @@ class WindowCaptionButton extends FlxSprite {
|
||||
return;
|
||||
}
|
||||
var mouseInput = DesktopMain.instance.mouseInput;
|
||||
if (DesktopMain.instance.mouseInput.overlaps(this, camera)) {
|
||||
if (mouseInput.justReleased) {
|
||||
switch(ID) {
|
||||
case 0:
|
||||
window.close();
|
||||
case 1:
|
||||
|
||||
|
||||
visible = switch(ID) {
|
||||
case 1 | 2: window.resizeable || window.canMinimize;
|
||||
case 3: window.canHelp;
|
||||
default: true;
|
||||
};
|
||||
|
||||
if(switch(ID) {
|
||||
case 0: window.canClose;
|
||||
case 1: window.resizeable;
|
||||
case 2: window.canMinimize;
|
||||
case 3: window.canHelp;
|
||||
default: true;
|
||||
}) {
|
||||
if (DesktopMain.instance.mouseInput.overlaps(this, camera)) {
|
||||
if (mouseInput.justReleased) {
|
||||
switch(ID) {
|
||||
case 0:
|
||||
if (window.canClose) window.close();
|
||||
case 1:
|
||||
if (window.resizeable) (window.maximized ? window.restore : window.maximize)();
|
||||
case 2:
|
||||
if (window.canMinimize) window.minimize();
|
||||
}
|
||||
mouseInput.cancel();
|
||||
return;
|
||||
}
|
||||
mouseInput.cancel();
|
||||
return;
|
||||
}
|
||||
if (mouseInput.pressed || mouseInput.justPressed) {
|
||||
animation.curAnim.curFrame = 2;
|
||||
} else {
|
||||
animation.curAnim.curFrame = 1;
|
||||
}
|
||||
mouseInput.cancel(); // prevents controls behind this one from updating input
|
||||
} else
|
||||
animation.curAnim.curFrame = 0;
|
||||
if (!window.focused) animation.curAnim.curFrame += 3;
|
||||
if (mouseInput.pressed || mouseInput.justPressed) {
|
||||
animation.curAnim.curFrame = 2;
|
||||
} else {
|
||||
animation.curAnim.curFrame = 1;
|
||||
}
|
||||
mouseInput.cancel(); // prevents controls behind this one from updating input
|
||||
} else
|
||||
animation.curAnim.curFrame = 0;
|
||||
} else {
|
||||
animation.curAnim.curFrame = 3;
|
||||
}
|
||||
if (!window.focused) animation.curAnim.curFrame += 4;
|
||||
|
||||
super.update(elapsed);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user