|
|
@@ -23,19 +23,60 @@
|
|
|
import EditorUI = require("../EditorUI");
|
|
|
import EditorEvents = require("../../editor/EditorEvents");
|
|
|
import ModalWindow = require("./ModalWindow");
|
|
|
+import SearchBarFiltering = require("resources/SearchBarFiltering");
|
|
|
|
|
|
class ResourceSelection extends ModalWindow {
|
|
|
|
|
|
+ uiSearchBar: SearchBarFiltering.UISearchBar = new SearchBarFiltering.UISearchBar();
|
|
|
folderList: Atomic.UIListView;
|
|
|
callback: (returnObject: any, args: any) => void;
|
|
|
args: any;
|
|
|
resourceType: string;
|
|
|
+ importerType: string;
|
|
|
+ searchEdit: Atomic.UIEditField;
|
|
|
|
|
|
- populate(importerType: string, resourceType: string) {
|
|
|
+
|
|
|
+ constructor(windowText: string, importerType: string, resourceType: string, callback: (asset: ToolCore.Asset, args: any) => void, args: any) {
|
|
|
+
|
|
|
+ super();
|
|
|
+
|
|
|
+ this.importerType = importerType;
|
|
|
+ this.resourceType = resourceType;
|
|
|
+ this.callback = callback;
|
|
|
+ this.args = args;
|
|
|
+ this.load("AtomicEditor/editor/ui/resourceselection.tb.txt");
|
|
|
+ this.searchEdit = <Atomic.UIEditField>this.getWidget("filter");
|
|
|
+ this.populate(importerType, resourceType, false);
|
|
|
+
|
|
|
+ this.text = windowText;
|
|
|
+ this.setSize(800, 600);
|
|
|
+ this.center();
|
|
|
+
|
|
|
+ //Activates the search as the user types
|
|
|
+ this.searchEdit.subscribeToEvent(this.searchEdit, "WidgetEvent", (data) => {
|
|
|
+
|
|
|
+ if (data.type == Atomic.UI_EVENT_TYPE_KEY_UP) {
|
|
|
+ this.populate(this.importerType, this.resourceType, true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //adjusted to delete current folderlist and replace with search list if search is activated
|
|
|
+ populate(importerType: string, resourceType: string, search: boolean) {
|
|
|
|
|
|
var db = ToolCore.assetDatabase;
|
|
|
var assets = db.getAssetsByImporterType(importerType, resourceType);
|
|
|
|
|
|
+ if (search)
|
|
|
+ this.folderList.remove();
|
|
|
+
|
|
|
+ //Constructor Stuff
|
|
|
+ var foldercontainer = this.getWidget("resourcecontainer");
|
|
|
+ var folderList = this.folderList = new Atomic.UIListView();
|
|
|
+ folderList.rootList.id = "resourceList_";
|
|
|
+ foldercontainer.addChild(folderList);
|
|
|
+
|
|
|
this.folderList.addRootItem("None", "", "");
|
|
|
|
|
|
for (var i in assets) {
|
|
|
@@ -57,49 +98,28 @@ class ResourceSelection extends ModalWindow {
|
|
|
|
|
|
for (var i in animations) {
|
|
|
|
|
|
- this.folderList.addRootItem(animations[i].animationName + " : " + asset.name, "", animations[i].name);
|
|
|
-
|
|
|
+ if (!search || this.searchEdit.text == "")
|
|
|
+ this.folderList.addRootItem(animations[i].animationName + " : " + asset.name, "", animations[i].name);
|
|
|
+ else if (search) {
|
|
|
+ if (this.uiSearchBar.searchPopulate(this.searchEdit.text, animations[i].animationName + " : " + asset.name))
|
|
|
+ this.folderList.addRootItem(animations[i].animationName + " : " + asset.name, "", animations[i].name);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- this.folderList.addRootItem(asset.relativePath, "", asset.guid);
|
|
|
-
|
|
|
+ if (!search || this.searchEdit.text == "")
|
|
|
+ this.folderList.addRootItem(asset.relativePath, "", asset.guid);
|
|
|
+ else if (search) {
|
|
|
+ if (this.uiSearchBar.searchPopulate(this.searchEdit.text, asset.relativePath))
|
|
|
+ this.folderList.addRootItem(asset.relativePath, "", asset.guid);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- constructor(windowText: string, importerType: string, resourceType: string, callback: (asset: ToolCore.Asset, args: any) => void, args: any) {
|
|
|
-
|
|
|
- super();
|
|
|
-
|
|
|
- this.resourceType = resourceType;
|
|
|
- this.callback = callback;
|
|
|
- this.args = args;
|
|
|
-
|
|
|
- this.load("AtomicEditor/editor/ui/resourceselection.tb.txt");
|
|
|
-
|
|
|
- var foldercontainer = this.getWidget("resourcecontainer");
|
|
|
-
|
|
|
- var folderList = this.folderList = new Atomic.UIListView();
|
|
|
-
|
|
|
- folderList.rootList.id = "resourceList_";
|
|
|
-
|
|
|
- foldercontainer.addChild(folderList);
|
|
|
-
|
|
|
- this.populate(importerType, resourceType);
|
|
|
-
|
|
|
- this.text = windowText;
|
|
|
- this.setSize(800, 600);
|
|
|
- this.center();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
|
|
|
|
|
|
if (ev.count >= 2) {
|
|
|
@@ -119,12 +139,15 @@ class ResourceSelection extends ModalWindow {
|
|
|
}
|
|
|
|
|
|
if (id == "cancel") {
|
|
|
-
|
|
|
this.hide();
|
|
|
-
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ if (id == "cancel search") {
|
|
|
+ this.searchEdit.text = "";
|
|
|
+ this.populate(this.importerType, this.resourceType, true);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|