desktop progress
@@ -1,16 +1,23 @@
|
||||
<theme folder="desktop/ui/">
|
||||
<!-- WINDOW!! !-->
|
||||
<captionActive path="caption" textColor="#FFFFFF" left="5" top="30" right="5" bottom="5" textSize="16" />
|
||||
<captionInactive path="captionInactive" textColor="#AAFFFFFF" left="5" top="30" right="5" bottom="5" />
|
||||
<captionButtons path="captionButtons" size="21,21" margin="2,0" offset="4,6" />
|
||||
<window color="255,255,255" textColor="0,0,0" font="file://C:/Windows/fonts/tahoma.ttf" fontSize="11"/>
|
||||
<captionActive path="caption" textColor="#FFFFFF" left="5" top="30" right="5" bottom="5" textSize="16" />
|
||||
<captionInactive path="captionInactive" textColor="#AAFFFFFF" left="5" top="30" right="5" bottom="5" />
|
||||
<captionButtons path="captionButtons" size="21,21" margin="2,0" offset="4,6" />
|
||||
<window color="255,255,255" textColor="0,0,0" font="file://C:/Windows/fonts/tahoma.ttf" fontSize="11"/>
|
||||
|
||||
<!-- BUTTONS !-->
|
||||
<normalButton path="button" textColor="0,0,0" left="4" top="4" right="4" bottom="4" />
|
||||
<hoverButton path="buttonHover" textColor="0,0,0" left="4" top="4" right="4" bottom="4" />
|
||||
<pressedButton path="buttonPressed" textColor="0,0,0" left="4" top="4" right="4" bottom="4" />
|
||||
<disabledButton path="buttonDisabled" textColor="128,128,128" left="4" top="4" right="4" bottom="4" />
|
||||
<normalButton path="button" textColor="0,0,0" left="4" top="4" right="4" bottom="4" />
|
||||
<hoverButton path="buttonHover" textColor="0,0,0" left="4" top="4" right="4" bottom="4" />
|
||||
<pressedButton path="buttonPressed" textColor="0,0,0" left="4" top="4" right="4" bottom="4" />
|
||||
<disabledButton path="buttonDisabled" textColor="128,128,128" left="4" top="4" right="4" bottom="4" />
|
||||
|
||||
<!-- CHECKBOX -->
|
||||
<checkbox path="checkbox" width="16" height="16"/>
|
||||
<checkbox path="checkbox" width="16" height="16"/>
|
||||
|
||||
<!-- TABS -->
|
||||
<tabBackground path="tabBody" textColor="0,0,0" left="4" top="0" right="4" bottom="4" />
|
||||
<tabButtonSelected path="tab" textColor="255,255,255" left="4" top="4" right="4" bottom="0" />
|
||||
<tabButtonUnselected path="tabNonSelected" textColor="0,0,0" left="4" top="6" right="4" bottom="4" />
|
||||
<tabButtonHover path="tabHover" textColor="0,0,0" left="4" top="4" right="4" bottom="4" />
|
||||
<tabButtonPressed path="tabPressed" textColor="0,0,0" left="4" top="4" right="4" bottom="4" />
|
||||
</theme>
|
||||
|
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 245 B |
|
After Width: | Height: | Size: 156 B |
|
After Width: | Height: | Size: 141 B |
|
After Width: | Height: | Size: 245 B |
|
After Width: | Height: | Size: 160 B |
|
After Width: | Height: | Size: 442 B |
@@ -1 +1 @@
|
||||
1697
|
||||
1712
|
||||
@@ -22,20 +22,24 @@ class HelloWorld extends WindowContent {
|
||||
t.scrollFactor.set(1, 1);
|
||||
add(t);
|
||||
|
||||
var t = new WindowText(0, 0, 0, "Top right text!");
|
||||
t.setPosition(630 - t.width, 10);
|
||||
t.scrollFactor.set(1, 0);
|
||||
add(t);
|
||||
var tabs = new TabView(330, 10, 300, 500, ["Tab 1", "Tab 2", "Tab 3"]);
|
||||
tabs.updateScrollFactor(0, 0);
|
||||
add(tabs);
|
||||
|
||||
|
||||
var checkbox = new Checkbox(10, 40, 0, "Test Checkbox", CHECKED);
|
||||
var text = new WindowText(10, 10, 180, "Stuff in page 1");
|
||||
tabs.tabs[0].add(text);
|
||||
tabs.tabs[0].add(checkbox);
|
||||
|
||||
var text2 = new WindowText(10, 10, 180, "Stuff in page 2");
|
||||
tabs.tabs[1].add(text2);
|
||||
|
||||
var butt = new Button(10, 10, "Test", function() {
|
||||
parent.showMessage("Test", "Test", ERROR);
|
||||
});
|
||||
butt.scrollFactor.set();
|
||||
add(butt);
|
||||
|
||||
var checkbox = new Checkbox(10, 40, 0, "Test Checkbox", CHECKED);
|
||||
checkbox.scrollFactor.set();
|
||||
add(checkbox);
|
||||
}
|
||||
|
||||
public var time:Float = 0;
|
||||
|
||||
@@ -50,6 +50,7 @@ class MessageBox extends WindowContent {
|
||||
});
|
||||
button.x -= button.width;
|
||||
button.y -= button.height;
|
||||
button.scrollFactor.set(1, 1);
|
||||
add(button);
|
||||
if (firstButt == null) firstButt = button;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class Button extends FlxObject {
|
||||
return normalSprite.height;
|
||||
}
|
||||
|
||||
public function new(x:Float, y:Float, text:String = "", callback:Void->Void) {
|
||||
public function new(x:Float, y:Float, text:String = "", callback:Void->Void, ?normalButton:ThemeData, ?hoverButton:ThemeData, ?pressedButton:ThemeData, ?disabledButton:ThemeData) {
|
||||
super();
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -37,10 +37,12 @@ class Button extends FlxObject {
|
||||
this.height = 24;
|
||||
this.callback = callback;
|
||||
|
||||
var normalButton = DesktopMain.theme.normalButton;
|
||||
var hoverButton = DesktopMain.theme.hoverButton;
|
||||
var pressedButton = DesktopMain.theme.pressedButton;
|
||||
var disabledButton = DesktopMain.theme.disabledButton;
|
||||
scrollFactor.set();
|
||||
|
||||
if (normalButton == null) normalButton = DesktopMain.theme.normalButton;
|
||||
if (hoverButton == null) hoverButton = DesktopMain.theme.hoverButton;
|
||||
if (pressedButton == null) pressedButton = DesktopMain.theme.pressedButton;
|
||||
if (disabledButton == null) disabledButton = DesktopMain.theme.disabledButton;
|
||||
|
||||
normalSprite = new SpliceSprite(Paths.image(normalButton.sprite), x, y, 75, 24, normalButton.left, normalButton.top, normalButton.bottom, normalButton.right);
|
||||
hoverSprite = new SpliceSprite(Paths.image(hoverButton.sprite), x, y, 75, 24, hoverButton.left, hoverButton.top, hoverButton.bottom, hoverButton.right);
|
||||
|
||||
@@ -21,6 +21,8 @@ class Checkbox extends WindowText {
|
||||
checkboxSprite.loadGraphic(Paths.image(t.sprite), true, Std.int(t.width), Std.int(t.height));
|
||||
checkboxSprite.animation.add("checkbox", [for(i in 0...checkboxSprite.frames.frames.length) i], 0, true);
|
||||
checkboxSprite.animation.play("checkbox");
|
||||
|
||||
scrollFactor.set();
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
|
||||
@@ -28,6 +28,8 @@ class SpliceSprite extends FlxObject {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
scrollFactor.set();
|
||||
|
||||
__internalSprite = new FlxSprite(0, 0, spr);
|
||||
|
||||
slice = [Std.int(left), Std.int(bottom), Std.int(top), Std.int(right)];
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package funkin.desktop.sprites;
|
||||
|
||||
import flixel.math.FlxRect;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxBasic;
|
||||
import funkin.desktop.windows.WindowGroup;
|
||||
|
||||
class TabView extends WindowGroup<FlxBasic> {
|
||||
public var tabBG:SpliceSprite;
|
||||
public var tabButtons:Array<Button> = [];
|
||||
public var tabs:Array<WindowGroup<FlxBasic>> = [];
|
||||
public var bg:SpliceSprite;
|
||||
|
||||
public var selectedTab:Int = 0;
|
||||
|
||||
public var width:Float;
|
||||
public var height:Float;
|
||||
|
||||
public function new(x:Float, y:Float, width:Float, height:Float, tabs:Array<String>) {
|
||||
super();
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
var tabBG = DesktopMain.theme.tabBackground;
|
||||
bg = new SpliceSprite(Paths.image(tabBG.sprite), x, y, 75, 24, tabBG.left, tabBG.top, tabBG.bottom, tabBG.right);
|
||||
add(bg);
|
||||
for(k=>t in tabs) {
|
||||
// BUTTON
|
||||
var b = new Button(0, y, t, function() {
|
||||
switchTab(k);
|
||||
}, DesktopMain.theme.tabButtonUnselected, DesktopMain.theme.tabButtonHover, DesktopMain.theme.tabButtonPressed, DesktopMain.theme.tabButtonSelected);
|
||||
|
||||
tabButtons.push(b);
|
||||
add(b);
|
||||
|
||||
// TAB
|
||||
var tab = new WindowGroup<FlxBasic>();
|
||||
tab.y = 20;
|
||||
this.tabs.push(tab);
|
||||
add(tab);
|
||||
}
|
||||
resize(width, height);
|
||||
switchTab(0);
|
||||
}
|
||||
|
||||
public function resize(width:Float, height:Float) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
updateButtons();
|
||||
updateBG();
|
||||
}
|
||||
|
||||
public function updateButtons() {
|
||||
var bWidth:Float = Math.floor(width / tabs.length);
|
||||
for(k=>b in tabButtons) {
|
||||
var w = (k >= tabs.length - 1) ? (width - (bWidth * (tabs.length - 1))) : bWidth;
|
||||
b.resize(w, 24);
|
||||
b.x = x + (k * bWidth);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateBG() {
|
||||
bg.x = x;
|
||||
bg.y = y + 24;
|
||||
bg.resize(width, height - 24);
|
||||
}
|
||||
|
||||
public function switchTab(id:Int) {
|
||||
selectedTab = id;
|
||||
for(k=>b in tabButtons)
|
||||
b.disabled = k == selectedTab;
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
bg.update(elapsed);
|
||||
for(e in tabButtons)
|
||||
e.update(elapsed);
|
||||
if (tabs[selectedTab] != null)
|
||||
tabs[selectedTab].update(elapsed);
|
||||
|
||||
if (DesktopMain.mouseInput.overlapsRect(bg, new FlxRect(x, y, width, height), camera))
|
||||
DesktopMain.mouseInput.cancel();
|
||||
}
|
||||
|
||||
public override function draw() {
|
||||
bg.draw();
|
||||
for(e in tabButtons)
|
||||
e.draw();
|
||||
if (tabs[selectedTab] != null)
|
||||
tabs[selectedTab].draw();
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ class WindowText extends FlxText {
|
||||
scrollFactor.set();
|
||||
size = 12;
|
||||
applyFontSettings(DesktopMain.theme.window);
|
||||
|
||||
scrollFactor.set();
|
||||
}
|
||||
|
||||
public function applyFontSettings(data:ThemeData) {
|
||||
|
||||
@@ -44,6 +44,15 @@ class Theme {
|
||||
*/
|
||||
public var checkbox:ThemeData = new ThemeData();
|
||||
|
||||
/**
|
||||
* TABS
|
||||
*/
|
||||
public var tabBackground:ThemeData = new ThemeData();
|
||||
public var tabButtonSelected:ThemeData = new ThemeData();
|
||||
public var tabButtonUnselected:ThemeData = new ThemeData();
|
||||
public var tabButtonHover:ThemeData = new ThemeData();
|
||||
public var tabButtonPressed:ThemeData = new ThemeData();
|
||||
|
||||
public function new(content:String) {
|
||||
try {
|
||||
var access = new Access(Xml.parse(content).firstElement());
|
||||
|
||||
@@ -74,6 +74,7 @@ class WindowContent extends WindowGroup<FlxBasic> {
|
||||
this.height = height;
|
||||
this.winX = x;
|
||||
this.winY = y;
|
||||
this.updateScrolls = false;
|
||||
}
|
||||
|
||||
public function create() {
|
||||
|
||||
@@ -1,10 +1,59 @@
|
||||
package funkin.desktop.windows;
|
||||
|
||||
import flixel.math.FlxMath;
|
||||
import flixel.math.FlxPoint;
|
||||
import flixel.FlxObject;
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
import flixel.FlxBasic;
|
||||
import flixel.FlxCamera;
|
||||
|
||||
class WindowGroup<T:FlxBasic> extends FlxTypedGroup<T> {
|
||||
public var x:Float = 0;
|
||||
public var y:Float = 0;
|
||||
public var scrollFactor:FlxPoint = FlxPoint.get(0, 0);
|
||||
public var updateScrolls:Bool = true;
|
||||
|
||||
public override function add(obj:T) {
|
||||
super.add(obj);
|
||||
|
||||
if (!updateScrolls) return obj;
|
||||
if (obj is FlxObject) {
|
||||
var o = cast(obj, FlxObject);
|
||||
o.x += x;
|
||||
o.y += y;
|
||||
o.scrollFactor.x = scrollFactor.x;
|
||||
o.scrollFactor.y = scrollFactor.y;
|
||||
} else if (obj is WindowGroup) {
|
||||
var o:WindowGroup<FlxBasic> = cast obj;
|
||||
o.x += x;
|
||||
o.y += y;
|
||||
o.scrollFactor.x = scrollFactor.x;
|
||||
o.scrollFactor.y = scrollFactor.y;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function updateScrollFactor(x:Float, y:Float) {
|
||||
scrollFactor.set(x, y);
|
||||
if (!updateScrolls) return;
|
||||
for(obj in members)
|
||||
__updateObjScrollFactor(obj);
|
||||
}
|
||||
|
||||
private function __updateObjScrollFactor(obj:FlxBasic) {
|
||||
if (obj is FlxObject) {
|
||||
var o = cast(obj, FlxObject);
|
||||
o.scrollFactor.x = scrollFactor.x;
|
||||
o.scrollFactor.y = scrollFactor.y;
|
||||
} else if (obj is WindowGroup) {
|
||||
var o:WindowGroup<FlxBasic> = cast obj;
|
||||
o.updateScrollFactor(scrollFactor.x, scrollFactor.y);
|
||||
}
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
// update them backwards, so that the top most window gets the priority
|
||||
var i = length;
|
||||
@@ -22,4 +71,9 @@ class WindowGroup<T:FlxBasic> extends FlxTypedGroup<T> {
|
||||
|
||||
@:privateAccess FlxCamera._defaultCameras = oldDefaultCameras;
|
||||
}
|
||||
|
||||
public override function destroy() {
|
||||
super.destroy();
|
||||
scrollFactor.put();
|
||||
}
|
||||
}
|
||||