Skip to content

Commit 447db0e

Browse files
committed
preview and clear button
1 parent 52d23ba commit 447db0e

7 files changed

Lines changed: 148 additions & 25 deletions

File tree

Project.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<!-- _________________________ Application Settings _________________________ -->
66

7-
<app title="Setup Solar Files" file="Setup Solar Files" main="Main" version="0.1.0" company="Team-SolarEngine" />
7+
<app title="Solar Submit" file="Solar Submit" main="Main" version="0.1.0" company="Team-SolarEngine" />
88

99
<!--The flixel preloader is not accurate in Chrome. You can use it regularly if you embed the swf into a html file
1010
or you can set the actual size of your file manually at "FlxPreloaderBase-onUpdate-bytesTotal"-->
@@ -40,7 +40,7 @@
4040
<haxelib name="haxeui-flixel"/>
4141

4242
<!--In case you want to use the addons package-->
43-
<!--<haxelib name="flixel-addons" />-->
43+
<haxelib name="flixel-addons" />
4444

4545
<!--In case you want to use the ui package-->
4646
<!--<haxelib name="flixel-ui" />-->

assets/ui/mainview.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,8 @@
5353
</list-item-picker>
5454
</grid>
5555
</hbox>
56-
<button text="Create Folder" id="finish"/>
56+
<hbox>
57+
<button text="Save" id="finish"/>
58+
<button text="Clear" id="clearbtn"/>
59+
</hbox>
5760
</vbox>

assets/ui/preview.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<hbox style="padding:5px;" width="300" height="300">
2+
<style>
3+
.label{
4+
font-size: 12px;
5+
}
6+
</style>
7+
<grid width="100%" height="100%">
8+
<vbox width="50%" height="100%">
9+
<label text="Banner" id="bannerLabel" width="100%" horizontalAlign="center" style="text-align: center;" />
10+
<box width="100%" height="100%" style="padding: 5px;">
11+
<image id="bannerPreview" width="100%" height="100%" scaleMode="fitinside"
12+
imageVerticalAlign="center" imageHorizontalAlign="center" />
13+
</box>
14+
</vbox>
15+
<vbox width="50%" height="100%">
16+
<label text="Icon" id="iconLabel" width="100%" horizontalAlign="center" style="text-align: center;" />
17+
<box width="100%" height="100%" style="padding: 5px;">
18+
<image id="iconPreview" width="100%" height="100%" scaleMode="fitinside"
19+
imageVerticalAlign="center" imageHorizontalAlign="center" />
20+
</box>
21+
</vbox>
22+
</grid>
23+
</hbox>

source/PlayState.hx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
package;
22

33
import haxe.ui.backend.flixel.UIState;
4+
import flixel.addons.display.FlxBackdrop;
5+
import flixel.addons.display.FlxGridOverlay;
46

5-
import ui.MainUI;
7+
import ui.FullView;
68

79
class PlayState extends UIState
810
{
9-
var ui:MainUI;
11+
var ui:FullView;
12+
13+
var bg:FlxBackdrop;
1014

1115
override public function create()
1216
{
13-
ui = new MainUI();
17+
bg = new FlxBackdrop(FlxGridOverlay.createGrid(80, 80, 160, 160, true, 0x337F7F7F, 0x0));
18+
bg.velocity.set(20, 20);
19+
add(bg);
20+
21+
ui = new FullView();
1422
add(ui);
1523
super.create();
1624
}

source/ui/FullView.hx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package ui;
2+
3+
import haxe.ui.containers.HBox;
4+
5+
import ui.*;
6+
7+
class FullView extends HBox{
8+
9+
var mainUI:MainUI;
10+
var previewUI:PreviewUI;
11+
12+
public function new(){
13+
super();
14+
15+
mainUI = new MainUI();
16+
previewUI = new PreviewUI();
17+
18+
addComponent(mainUI);
19+
addComponent(previewUI);
20+
}
21+
}

source/ui/MainUI.hx

Lines changed: 72 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import haxe.ui.containers.dialogs.MessageBox.MessageBoxType;
77
import sys.FileSystem;
88
import sys.io.File;
99
import haxe.Json;
10+
import haxe.ui.ToolkitAssets;
11+
import haxe.ui.containers.dialogs.Dialog.DialogButton;
1012

1113
using StringTools;
1214

@@ -23,20 +25,29 @@ typedef Data = {
2325
}
2426

2527
@:build(haxe.ui.ComponentBuilder.build("assets/ui/mainview.xml"))
26-
class MainUI extends VBox{
27-
var bannerBytes:Bytes = null;
28-
var iconBytes:Bytes = null;
28+
class MainUI extends VBox {
29+
var bannerBytes:Bytes = null;
30+
var iconBytes:Bytes = null;
2931

3032
var options:Array<String> = ["yes", "no"];
3133

32-
public function new(){
33-
super();
34+
public function new() {
35+
super();
3436
banner.onClick = function(event) {
3537
Dialogs.openBinaryFile("Open Banner", [{label: "Banner File (.png)", extension: "png"}], function(selectedFile) {
3638
if (selectedFile != null && selectedFile.bytes != null) {
3739
trace("Selected file: " + selectedFile.name);
38-
bannerBytes = selectedFile.bytes;
40+
bannerBytes = selectedFile.bytes;
3941
banner.text = "Banner Success!";
42+
43+
ToolkitAssets.instance.imageFromBytes(bannerBytes, function(imageInfo) {
44+
if (imageInfo != null) {
45+
try {
46+
PreviewUI.instance.bannerPreview.resource = imageInfo.data;
47+
PreviewUI.instance.bannerLabel.show();
48+
} catch (_) {}
49+
}
50+
});
4051
}
4152
});
4253
}
@@ -45,36 +56,51 @@ class MainUI extends VBox{
4556
Dialogs.openBinaryFile("Open Icon", [{label: "Icon File (.png)", extension: "png"}], function(selectedFile) {
4657
if (selectedFile != null && selectedFile.bytes != null) {
4758
trace("Selected file: " + selectedFile.name);
48-
iconBytes = selectedFile.bytes;
59+
iconBytes = selectedFile.bytes;
4960
iconbtn.text = "Icon Success!";
61+
62+
ToolkitAssets.instance.imageFromBytes(iconBytes, function(imageInfo) {
63+
if (imageInfo != null) {
64+
try {
65+
PreviewUI.instance.iconPreview.resource = imageInfo.data;
66+
PreviewUI.instance.iconLabel.show();
67+
} catch (_) {}
68+
}
69+
});
5070
}
5171
});
5272
}
5373

54-
finish.onClick = function(event){
74+
clearbtn.onClick = function(event){
75+
Dialogs.messageBox("Are you sure?", "QUESTION", MessageBoxType.TYPE_YESNO, function(callback){
76+
(callback == DialogButton.YES) ? clearInfo() : return;
77+
});
78+
}
79+
80+
finish.onClick = function(event) {
5581
FileSystem.createDirectory(".solar-engine");
5682

57-
if (bannerBytes == null){
83+
if (bannerBytes == null) {
5884
Dialogs.messageBox("Missing Banner file!", "ERROR", MessageBoxType.TYPE_ERROR);
5985
return;
6086
}
61-
if (iconBytes == null){
87+
if (iconBytes == null) {
6288
Dialogs.messageBox("Missing Icon file!", "ERROR", MessageBoxType.TYPE_ERROR);
6389
return;
6490
}
65-
if (txtTitle.text == null || txtTitle.text == ""){
91+
if (txtTitle.text == null || txtTitle.text == "") {
6692
Dialogs.messageBox("No Title!", "ERROR", MessageBoxType.TYPE_ERROR);
6793
return;
6894
}
69-
if (txtDescription.text == null || txtDescription.text == ""){
95+
if (txtDescription.text == null || txtDescription.text == "") {
7096
Dialogs.messageBox("No Description!", "ERROR", MessageBoxType.TYPE_ERROR);
7197
return;
7298
}
73-
if (txtMadeBy.text == null || txtMadeBy.text == ""){
99+
if (txtMadeBy.text == null || txtMadeBy.text == "") {
74100
Dialogs.messageBox("Missing Developer Info!", "ERROR", MessageBoxType.TYPE_ERROR);
75101
return;
76102
}
77-
if (downloadUrl.text == null || downloadUrl.text == ""){
103+
if (downloadUrl.text == null || downloadUrl.text == "") {
78104
Dialogs.messageBox("Missing Download URL!", "ERROR", MessageBoxType.TYPE_ERROR);
79105
return;
80106
}
@@ -89,18 +115,20 @@ class MainUI extends VBox{
89115
data.githubURL = githubUrl.text;
90116
data.madeByURL = madeUrl.text;
91117
data.downloadURL = downloadUrl.text;
92-
118+
93119
File.saveContent("./.solar-engine/config.json", Json.stringify(data));
94120
File.saveContent("./.solar-engine/readme.md", "Has to be filled in.");
95121

96122
File.saveBytes("./.solar-engine/banner.png", bannerBytes);
97123
File.saveBytes("./.solar-engine/icon.png", iconBytes);
98124

99125
Dialogs.messageBox("Info Saved!", "SUCCESS", MessageBoxType.TYPE_INFO);
100-
}
101-
}
102126

103-
function defaultData():Data{
127+
clearInfo();
128+
}
129+
}
130+
131+
function defaultData():Data {
104132
return {
105133
isOpenSource: "",
106134
canMessWithComputer: "",
@@ -113,4 +141,29 @@ class MainUI extends VBox{
113141
downloadURL: ""
114142
};
115143
}
116-
}
144+
145+
function clearInfo() {
146+
bannerBytes = null;
147+
iconBytes = null;
148+
149+
banner.text = "Banner";
150+
iconbtn.text = "Icon";
151+
152+
txtTitle.text = null;
153+
txtDescription.text = null;
154+
txtMadeBy.text = null;
155+
githubUrl.text = null;
156+
externalUrl.text = null;
157+
madeUrl.text = null;
158+
downloadUrl.text = null;
159+
160+
isOpenSourceSelect.listView.selectedIndex = 0;
161+
messesWithPC.listView.selectedIndex = 0;
162+
163+
PreviewUI.instance.bannerPreview.resource = null;
164+
PreviewUI.instance.iconPreview.resource = null;
165+
166+
PreviewUI.instance.bannerLabel.hide();
167+
PreviewUI.instance.iconLabel.hide();
168+
}
169+
}

source/ui/PreviewUI.hx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package ui;
2+
3+
import haxe.ui.containers.HBox;
4+
5+
@:build(haxe.ui.ComponentBuilder.build("assets/ui/preview.xml"))
6+
class PreviewUI extends HBox{
7+
public static var instance:PreviewUI;
8+
public function new(){
9+
super();
10+
instance = this;
11+
12+
bannerLabel.hide();
13+
iconLabel.hide();
14+
}
15+
}

0 commit comments

Comments
 (0)