|
@@ -12,7 +12,7 @@ class WelcomeFrame extends ScriptWidget {
|
|
|
|
|
|
|
|
this.load("AtomicEditor/editor/ui/welcomeframe.tb.txt");
|
|
this.load("AtomicEditor/editor/ui/welcomeframe.tb.txt");
|
|
|
|
|
|
|
|
- var recentProjects = <Atomic.UILayout> this.getWidget("recentprojects");
|
|
|
|
|
|
|
+ var recentProjects = <Atomic.UILayout>this.getWidget("recentprojects");
|
|
|
this.gravity = Atomic.UI_GRAVITY_ALL;
|
|
this.gravity = Atomic.UI_GRAVITY_ALL;
|
|
|
|
|
|
|
|
this.recentList = new Atomic.UIListView();
|
|
this.recentList = new Atomic.UIListView();
|
|
@@ -20,7 +20,7 @@ class WelcomeFrame extends ScriptWidget {
|
|
|
|
|
|
|
|
recentProjects.addChild(this.recentList);
|
|
recentProjects.addChild(this.recentList);
|
|
|
|
|
|
|
|
- var container = <Atomic.UILayout> parent.getWidget("resourceviewcontainer");
|
|
|
|
|
|
|
+ var container = <Atomic.UILayout>parent.getWidget("resourceviewcontainer");
|
|
|
|
|
|
|
|
container.addChild(this);
|
|
container.addChild(this);
|
|
|
|
|
|
|
@@ -29,7 +29,112 @@ class WelcomeFrame extends ScriptWidget {
|
|
|
this.subscribeToEvent(EditorEvents.CloseProject, () => {
|
|
this.subscribeToEvent(EditorEvents.CloseProject, () => {
|
|
|
this.updateRecentProjects();
|
|
this.updateRecentProjects();
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ this.initExampleBrowser();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ addExample(example: ExampleFormat) {
|
|
|
|
|
+
|
|
|
|
|
+ var exlayout = <Atomic.UILayout>this.getWidget("examples_layout");
|
|
|
|
|
+
|
|
|
|
|
+ if (!this.currentExampleLayout) {
|
|
|
|
|
+ this.currentExampleLayout = new Atomic.UILayout();
|
|
|
|
|
+ this.currentExampleLayout.spacing = 8;
|
|
|
|
|
+ exlayout.addChild(this.currentExampleLayout);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 200x150
|
|
|
|
|
+
|
|
|
|
|
+ var exampleLayout = new Atomic.UILayout();
|
|
|
|
|
+ exampleLayout.skinBg = "StarCondition";
|
|
|
|
|
+ exampleLayout.axis = Atomic.UI_AXIS_Y;
|
|
|
|
|
+ exampleLayout.layoutDistribution = Atomic.UI_LAYOUT_DISTRIBUTION_GRAVITY;
|
|
|
|
|
+ exampleLayout.layoutSize = Atomic.UI_LAYOUT_SIZE_AVAILABLE;
|
|
|
|
|
+
|
|
|
|
|
+ // IMAGE BUTTON
|
|
|
|
|
+
|
|
|
|
|
+ var id = example.name;
|
|
|
|
|
+
|
|
|
|
|
+ var button = new Atomic.UIButton();
|
|
|
|
|
+ button.skinBg = "StarButton";
|
|
|
|
|
+ button.id = id;
|
|
|
|
|
+ var image = new Atomic.UIImageWidget();
|
|
|
|
|
+
|
|
|
|
|
+ image.image = this.exampleInfoDir + example.screenshot;
|
|
|
|
|
+ image.skinBg = "ImageFrame";
|
|
|
|
|
+ var rect = [0, 0, image.imageWidth / 2, image.imageHeight / 2];
|
|
|
|
|
+ image.rect = rect;
|
|
|
|
|
+
|
|
|
|
|
+ // NAME FIELD
|
|
|
|
|
+ var nameField = new Atomic.UITextField();
|
|
|
|
|
+ nameField.skinBg = "ImageCaption";
|
|
|
|
|
+ nameField.text = example.name;
|
|
|
|
|
+
|
|
|
|
|
+ var nameRect = [0, image.imageHeight / 2 - 16, image.imageWidth / 2, 16];
|
|
|
|
|
+ nameField.rect = nameRect;
|
|
|
|
|
+
|
|
|
|
|
+ nameField.gravity = Atomic.UI_GRAVITY_BOTTOM;
|
|
|
|
|
+
|
|
|
|
|
+ image.addChild(nameField);
|
|
|
|
|
+
|
|
|
|
|
+ button.addChild(image);
|
|
|
|
|
+
|
|
|
|
|
+ var lp = new Atomic.UILayoutParams();
|
|
|
|
|
+ lp.minWidth = image.imageWidth / 2;
|
|
|
|
|
+ lp.minHeight = image.imageHeight / 2;
|
|
|
|
|
+
|
|
|
|
|
+ button.layoutParams = lp;
|
|
|
|
|
+
|
|
|
|
|
+ button.gravity = Atomic.UI_GRAVITY_LEFT;
|
|
|
|
|
+
|
|
|
|
|
+ exampleLayout.addChild(button);
|
|
|
|
|
+
|
|
|
|
|
+ // DESC TEXT
|
|
|
|
|
+
|
|
|
|
|
+ var descField = new Atomic.UIEditField();
|
|
|
|
|
+ descField.styling = true;
|
|
|
|
|
+ descField.multiline = true;
|
|
|
|
|
+ descField.readOnly = true;
|
|
|
|
|
+ descField.wrapping = true;
|
|
|
|
|
+
|
|
|
|
|
+ var styleDesc = "<color #A9A9A9>" + example.desc + "</color>";
|
|
|
|
|
+
|
|
|
|
|
+ descField.text = styleDesc;
|
|
|
|
|
+
|
|
|
|
|
+ descField.adaptToContentSize = true;
|
|
|
|
|
+
|
|
|
|
|
+ lp.minWidth /= 2;
|
|
|
|
|
+ lp.maxHeight = lp.minHeight;
|
|
|
|
|
+ lp.maxWidth = lp.minWidth;
|
|
|
|
|
+ descField.layoutParams = lp;
|
|
|
|
|
+
|
|
|
|
|
+ exampleLayout.addChild(descField);
|
|
|
|
|
+
|
|
|
|
|
+ this.currentExampleLayout.addChild(exampleLayout);
|
|
|
|
|
+
|
|
|
|
|
+ this.exampleCount++;
|
|
|
|
|
+ // three across, todo, be smarter about this
|
|
|
|
|
+ if (!(this.exampleCount % 3)) {
|
|
|
|
|
+ this.currentExampleLayout = null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ initExampleBrowser() {
|
|
|
|
|
+
|
|
|
|
|
+ this.exampleInfoDir = "/Users/josh/Dev/atomic/AtomicGameEngine/Data/AtomicEditor/ExampleInfo/";
|
|
|
|
|
+
|
|
|
|
|
+ var exampleJsonFile = this.exampleInfoDir + "Examples.json";
|
|
|
|
|
+
|
|
|
|
|
+ var jsonFile = new Atomic.File(exampleJsonFile, Atomic.FILE_READ);
|
|
|
|
|
+ var examples = <ExamplesFormat> JSON.parse(jsonFile.readText());
|
|
|
|
|
+
|
|
|
|
|
+ for (var i in examples.examples) {
|
|
|
|
|
+
|
|
|
|
|
+ this.addExample(examples.examples[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
|
|
handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
|
|
@@ -82,10 +187,10 @@ class WelcomeFrame extends ScriptWidget {
|
|
|
updateRecentProjects() {
|
|
updateRecentProjects() {
|
|
|
|
|
|
|
|
this.recentList.deleteAllItems();
|
|
this.recentList.deleteAllItems();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
var prefs = Preferences.getInstance();
|
|
var prefs = Preferences.getInstance();
|
|
|
prefs.updateRecentProjects();
|
|
prefs.updateRecentProjects();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
this.recent = prefs.recentProjects;
|
|
this.recent = prefs.recentProjects;
|
|
|
|
|
|
|
|
for (var i in this.recent) {
|
|
for (var i in this.recent) {
|
|
@@ -101,9 +206,28 @@ class WelcomeFrame extends ScriptWidget {
|
|
|
menu.show(menuButtons, x, y);
|
|
menu.show(menuButtons, x, y);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // examples
|
|
|
|
|
+ exampleInfoDir: string;
|
|
|
|
|
+ exampleCount = 0;
|
|
|
|
|
+ currentExampleLayout: Atomic.UILayout;
|
|
|
|
|
+
|
|
|
recent: string[] = [];
|
|
recent: string[] = [];
|
|
|
recentList: Atomic.UIListView;
|
|
recentList: Atomic.UIListView;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+class ExamplesFormat {
|
|
|
|
|
+
|
|
|
|
|
+ examples: [ExampleFormat];
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+class ExampleFormat {
|
|
|
|
|
+ name: string;
|
|
|
|
|
+ desc: string;
|
|
|
|
|
+ screenshot: string;
|
|
|
|
|
+ folder: string;
|
|
|
|
|
+ module: string;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
export = WelcomeFrame;
|
|
export = WelcomeFrame;
|