|
@@ -1,8 +1,23 @@
|
|
|
//
|
|
//
|
|
|
-// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
|
|
|
|
|
-// LICENSE: Atomic Game Engine Editor and Tools EULA
|
|
|
|
|
-// Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
|
|
|
|
|
-// license information: https://github.com/AtomicGameEngine/AtomicGameEngine
|
|
|
|
|
|
|
+// Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
|
|
|
|
|
+//
|
|
|
|
|
+// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
+// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
+// in the Software without restriction, including without limitation the rights
|
|
|
|
|
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
+// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
+// furnished to do so, subject to the following conditions:
|
|
|
|
|
+//
|
|
|
|
|
+// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
+// all copies or substantial portions of the Software.
|
|
|
|
|
+//
|
|
|
|
|
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
+// THE SOFTWARE.
|
|
|
//
|
|
//
|
|
|
|
|
|
|
|
import ScriptWidget = require("ui/ScriptWidget");
|
|
import ScriptWidget = require("ui/ScriptWidget");
|
|
@@ -10,6 +25,7 @@ import Editor = require("editor/Editor");
|
|
|
import EditorEvents = require("editor/EditorEvents");
|
|
import EditorEvents = require("editor/EditorEvents");
|
|
|
import ProjectFrameMenu = require("./menus/ProjectFrameMenu");
|
|
import ProjectFrameMenu = require("./menus/ProjectFrameMenu");
|
|
|
import MenuItemSources = require("./menus/MenuItemSources");
|
|
import MenuItemSources = require("./menus/MenuItemSources");
|
|
|
|
|
+import SearchBarFiltering = require("resources/SearchBarFiltering");
|
|
|
|
|
|
|
|
class ProjectFrame extends ScriptWidget {
|
|
class ProjectFrame extends ScriptWidget {
|
|
|
|
|
|
|
@@ -19,6 +35,13 @@ class ProjectFrame extends ScriptWidget {
|
|
|
resourceFolder: ToolCore.Asset;
|
|
resourceFolder: ToolCore.Asset;
|
|
|
assetGUIDToItemID = {};
|
|
assetGUIDToItemID = {};
|
|
|
resourcesID: number = -1;
|
|
resourcesID: number = -1;
|
|
|
|
|
+ assetReferencePath: string = null;
|
|
|
|
|
+ currentReferencedButton: Atomic.UIButton = null;
|
|
|
|
|
+ containerScrollToHeight: number;
|
|
|
|
|
+ containerScrollToHeightCounter: number;
|
|
|
|
|
+ uiSearchBar: SearchBarFiltering.UISearchBar = new SearchBarFiltering.UISearchBar();
|
|
|
|
|
+ search: boolean = false;
|
|
|
|
|
+ searchEdit: Atomic.UIEditField;
|
|
|
|
|
|
|
|
constructor(parent: Atomic.UIWidget) {
|
|
constructor(parent: Atomic.UIWidget) {
|
|
|
|
|
|
|
@@ -30,6 +53,8 @@ class ProjectFrame extends ScriptWidget {
|
|
|
|
|
|
|
|
this.gravity = Atomic.UI_GRAVITY_TOP_BOTTOM;
|
|
this.gravity = Atomic.UI_GRAVITY_TOP_BOTTOM;
|
|
|
|
|
|
|
|
|
|
+ this.searchEdit = <Atomic.UIEditField>this.getWidget("filter");
|
|
|
|
|
+
|
|
|
var projectviewcontainer = parent.getWidget("projectviewcontainer");
|
|
var projectviewcontainer = parent.getWidget("projectviewcontainer");
|
|
|
|
|
|
|
|
projectviewcontainer.addChild(this);
|
|
projectviewcontainer.addChild(this);
|
|
@@ -44,12 +69,13 @@ class ProjectFrame extends ScriptWidget {
|
|
|
|
|
|
|
|
// events
|
|
// events
|
|
|
this.subscribeToEvent("ProjectLoaded", (data) => this.handleProjectLoaded(data));
|
|
this.subscribeToEvent("ProjectLoaded", (data) => this.handleProjectLoaded(data));
|
|
|
- this.subscribeToEvent("ProjectUnloaded", (data) => this.handleProjectUnloaded(data));
|
|
|
|
|
|
|
+ this.subscribeToEvent(EditorEvents.ProjectUnloadedNotification, (data) => this.handleProjectUnloaded(data));
|
|
|
this.subscribeToEvent("DragEnded", (data: Atomic.DragEndedEvent) => this.handleDragEnded(data));
|
|
this.subscribeToEvent("DragEnded", (data: Atomic.DragEndedEvent) => this.handleDragEnded(data));
|
|
|
|
|
|
|
|
this.subscribeToEvent("ResourceAdded", (ev: ToolCore.ResourceAddedEvent) => this.handleResourceAdded(ev));
|
|
this.subscribeToEvent("ResourceAdded", (ev: ToolCore.ResourceAddedEvent) => this.handleResourceAdded(ev));
|
|
|
this.subscribeToEvent("ResourceRemoved", (ev: ToolCore.ResourceRemovedEvent) => this.handleResourceRemoved(ev));
|
|
this.subscribeToEvent("ResourceRemoved", (ev: ToolCore.ResourceRemovedEvent) => this.handleResourceRemoved(ev));
|
|
|
this.subscribeToEvent("AssetRenamed", (ev: ToolCore.AssetRenamedEvent) => this.handleAssetRenamed(ev));
|
|
this.subscribeToEvent("AssetRenamed", (ev: ToolCore.AssetRenamedEvent) => this.handleAssetRenamed(ev));
|
|
|
|
|
+ this.subscribeToEvent(EditorEvents.InspectorProjectReference, (ev: EditorEvents.InspectorProjectReferenceEvent) => { this.handleInspectorProjectReferenceHighlight(ev.path) });
|
|
|
|
|
|
|
|
folderList.subscribeToEvent("UIListViewSelectionChanged", (event: Atomic.UIListViewSelectionChangedEvent) => this.handleFolderListSelectionChangedEvent(event));
|
|
folderList.subscribeToEvent("UIListViewSelectionChanged", (event: Atomic.UIListViewSelectionChangedEvent) => this.handleFolderListSelectionChangedEvent(event));
|
|
|
|
|
|
|
@@ -62,6 +88,17 @@ class ProjectFrame extends ScriptWidget {
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ // Activates search while user is typing in search widget
|
|
|
|
|
+ this.searchEdit.subscribeToEvent(this.searchEdit, "WidgetEvent", (data) => {
|
|
|
|
|
+
|
|
|
|
|
+ if (!ToolCore.toolSystem.project) return;
|
|
|
|
|
+
|
|
|
|
|
+ if (data.type == Atomic.UI_EVENT_TYPE_KEY_UP) {
|
|
|
|
|
+ this.search = true;
|
|
|
|
|
+ this.refreshContent(this.currentFolder);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
handleAssetRenamed(ev: ToolCore.AssetRenamedEvent) {
|
|
handleAssetRenamed(ev: ToolCore.AssetRenamedEvent) {
|
|
@@ -162,6 +199,12 @@ class ProjectFrame extends ScriptWidget {
|
|
|
|
|
|
|
|
var id = data.target.id;
|
|
var id = data.target.id;
|
|
|
|
|
|
|
|
|
|
+ // cancel search - goes back to the last selected folder
|
|
|
|
|
+ if (id == "cancel search") {
|
|
|
|
|
+ if (!ToolCore.toolSystem.project) return;
|
|
|
|
|
+ this.searchEdit.text = "";
|
|
|
|
|
+ this.refreshContent(this.currentFolder);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (this.menu.handlePopupMenu(data.target, data.refid))
|
|
if (this.menu.handlePopupMenu(data.target, data.refid))
|
|
|
return true;
|
|
return true;
|
|
@@ -213,13 +256,17 @@ class ProjectFrame extends ScriptWidget {
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
|
|
this.sendEvent(EditorEvents.EditResource, { "path": asset.path });
|
|
this.sendEvent(EditorEvents.EditResource, { "path": asset.path });
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (this.currentReferencedButton) {
|
|
|
|
|
+ this.currentReferencedButton.setState(4, false);
|
|
|
|
|
+ this.currentReferencedButton = null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
return false;
|
|
@@ -382,6 +429,38 @@ class ProjectFrame extends ScriptWidget {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // Shows referenced file in projectframe
|
|
|
|
|
+ handleInspectorProjectReferenceHighlight(path: string): void {
|
|
|
|
|
+ this.assetReferencePath = path;
|
|
|
|
|
+ var db = ToolCore.getAssetDatabase();
|
|
|
|
|
+ var asset = db.getAssetByPath(this.resourceFolder.getPath() + "/" + path);
|
|
|
|
|
+
|
|
|
|
|
+ this.folderList.selectAllItems(false);
|
|
|
|
|
+ this.folderList.selectItemByID(asset.parent.guid, true);
|
|
|
|
|
+ this.refreshContent(asset.parent);
|
|
|
|
|
+ this.folderList.scrollToSelectedItem();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Searches folders within folders recursively
|
|
|
|
|
+ searchProjectFolder(folderPath: string, container: Atomic.UILayout, searchText: string, db: ToolCore.AssetDatabase) {
|
|
|
|
|
+
|
|
|
|
|
+ if (folderPath == "")
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ var assets = db.getFolderAssets(folderPath);
|
|
|
|
|
+
|
|
|
|
|
+ for (var i in assets) {
|
|
|
|
|
+
|
|
|
|
|
+ var childAsset = assets[i];
|
|
|
|
|
+
|
|
|
|
|
+ if (childAsset.isFolder()) {
|
|
|
|
|
+ this.searchProjectFolder(childAsset.path, container, searchText, db);
|
|
|
|
|
+ } else if (this.uiSearchBar.searchPopulate(searchText, childAsset.name + childAsset.extension)) {
|
|
|
|
|
+ container.addChild(this.createButtonLayout(childAsset));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private refreshContent(folder: ToolCore.Asset) {
|
|
private refreshContent(folder: ToolCore.Asset) {
|
|
|
|
|
|
|
|
if (this.currentFolder != folder) {
|
|
if (this.currentFolder != folder) {
|
|
@@ -397,15 +476,26 @@ class ProjectFrame extends ScriptWidget {
|
|
|
var container: Atomic.UILayout = <Atomic.UILayout>this.getWidget("contentcontainer");
|
|
var container: Atomic.UILayout = <Atomic.UILayout>this.getWidget("contentcontainer");
|
|
|
container.deleteAllChildren();
|
|
container.deleteAllChildren();
|
|
|
|
|
|
|
|
- var assets = db.getFolderAssets(folder.path);
|
|
|
|
|
|
|
+ if (this.currentFolder != null) {
|
|
|
|
|
+ var assets = db.getFolderAssets(folder.path);
|
|
|
|
|
|
|
|
- for (var i in assets) {
|
|
|
|
|
|
|
+ this.containerScrollToHeightCounter = 0;
|
|
|
|
|
|
|
|
- var asset = assets[i];
|
|
|
|
|
|
|
+ if (this.searchEdit.text == "" || !this.search) {
|
|
|
|
|
|
|
|
- container.addChild(this.createButtonLayout(asset));
|
|
|
|
|
|
|
+ for (var i in assets) {
|
|
|
|
|
+ var asset = assets[i];
|
|
|
|
|
+ container.addChild(this.createButtonLayout(asset));
|
|
|
|
|
+ this.containerScrollToHeightCounter++;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (this.search) {
|
|
|
|
|
+ this.searchProjectFolder(this.resourceFolder.path, container, this.searchEdit.text, db);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ var containerScroll: Atomic.UIScrollContainer = <Atomic.UIScrollContainer>this.getWidget("contentcontainerscroll");
|
|
|
|
|
+ containerScroll.scrollTo(0, this.containerScrollToHeight);
|
|
|
|
|
+ this.search = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private createButtonLayout(asset: ToolCore.Asset): Atomic.UILayout {
|
|
private createButtonLayout(asset: ToolCore.Asset): Atomic.UILayout {
|
|
@@ -442,11 +532,25 @@ class ProjectFrame extends ScriptWidget {
|
|
|
|
|
|
|
|
var button = new Atomic.UIButton();
|
|
var button = new Atomic.UIButton();
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
// setup the drag object
|
|
// setup the drag object
|
|
|
button.dragObject = new Atomic.UIDragObject(asset, asset.name);
|
|
button.dragObject = new Atomic.UIDragObject(asset, asset.name);
|
|
|
|
|
|
|
|
var lp = new Atomic.UILayoutParams;
|
|
var lp = new Atomic.UILayoutParams;
|
|
|
- lp.height = 20;
|
|
|
|
|
|
|
+ var buttonHeight = lp.height = 20;
|
|
|
|
|
+
|
|
|
|
|
+ //Get the path of the button and compare it to the asset's path to highlight
|
|
|
|
|
+ var resourcePath = this.resourceFolder.getPath() + "/" + this.assetReferencePath;
|
|
|
|
|
+
|
|
|
|
|
+ //Highlight Button UI
|
|
|
|
|
+ if (resourcePath == asset.path) {
|
|
|
|
|
+
|
|
|
|
|
+ button.setState(4, true);
|
|
|
|
|
+ this.currentReferencedButton = button;
|
|
|
|
|
+ this.containerScrollToHeight = this.containerScrollToHeightCounter * buttonHeight;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
var fd = new Atomic.UIFontDescription();
|
|
var fd = new Atomic.UIFontDescription();
|
|
|
fd.id = "Vera";
|
|
fd.id = "Vera";
|