| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- import EditorEvents = require("editor/EditorEvents");
- import EditorUI = require("../EditorUI");
- import ModalWindow = require("./ModalWindow");
- import ResourceOps = require("resources/ResourceOps");
- export class ResourceDelete extends ModalWindow {
- constructor(asset: ToolCore.Asset) {
- super();
- this.asset = asset;
- this.init("Delete Resource", "AtomicEditor/editor/ui/resourcedelete.tb.txt");
- var message = <Atomic.UIEditField> this.getWidget("message");
- var text = "Are you sure you want to delete resource:\n\n";
- text += asset.path;
- text += "\n\nThis operation cannot be undone";
- message.text = text;
- this.resizeToFitContent();
- this.center();
- }
- handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
- if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
- var id = ev.target.id;
- if (id == "delete") {
- this.hide();
- var db = ToolCore.getAssetDatabase();
- db.deleteAsset(this.asset);
- return true;
- }
- if (id == "cancel") {
- this.hide();
- return true;
- }
- }
- }
- asset: ToolCore.Asset;
- }
- export class CreateFolder extends ModalWindow {
- constructor(resourcePath: string) {
- super();
- this.resourcePath = resourcePath;
- this.init("New Folder", "AtomicEditor/editor/ui/resourcenewfolder.tb.txt");
- this.nameField = <Atomic.UIEditField> this.getWidget("folder_name");
- }
- handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
- if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
- var id = ev.target.id;
- if (id == "create") {
- var resourcePath = Atomic.addTrailingSlash(this.resourcePath) + this.nameField.text;
- if (ResourceOps.CreateNewFolder(resourcePath)) {
- this.hide();
- }
- return true;
- }
- if (id == "cancel") {
- this.hide();
- return true;
- }
- }
- }
- resourcePath: string;
- nameField: Atomic.UIEditField;
- }
- export class CreateComponent extends ModalWindow {
- constructor(resourcePath: string) {
- super();
- this.resourcePath = resourcePath;
- this.init("New Component", "AtomicEditor/editor/ui/resourcecreatecomponent.tb.txt");
- this.nameField = <Atomic.UIEditField> this.getWidget("component_name");
- }
- handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
- if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
- var id = ev.target.id;
- if (id == "create") {
- var componentName = this.nameField.text;
- var outputFile = Atomic.addTrailingSlash(this.resourcePath) + componentName;
- if (outputFile.indexOf(".js") == -1) outputFile += ".js";
- if (ResourceOps.CreateNewComponent(outputFile, componentName)) {
- this.hide();
- this.sendEvent(EditorEvents.EditResource, { path:outputFile});
- }
- return true;
- }
- if (id == "cancel") {
- this.hide();
- return true;
- }
- }
- }
- resourcePath: string;
- nameField: Atomic.UIEditField;
- }
- export class CreateScript extends ModalWindow {
- constructor(resourcePath: string) {
- super();
- this.resourcePath = resourcePath;
- this.init("New Script", "AtomicEditor/editor/ui/resourcecreatecomponent.tb.txt");
- this.nameField = <Atomic.UIEditField> this.getWidget("component_name");
- }
- handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
- if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
- var id = ev.target.id;
- if (id == "create") {
- var scriptName = this.nameField.text;
- var outputFile = Atomic.addTrailingSlash(this.resourcePath) + scriptName;
- if (outputFile.indexOf(".js") == -1) outputFile += ".js";
- if (ResourceOps.CreateNewScript(outputFile, scriptName)) {
- this.hide();
- this.sendEvent(EditorEvents.EditResource, { path:outputFile});
- }
- return true;
- }
- if (id == "cancel") {
- this.hide();
- return true;
- }
- }
- }
- resourcePath: string;
- nameField: Atomic.UIEditField;
- }
- export class CreateScene extends ModalWindow {
- constructor(resourcePath: string) {
- super();
- this.resourcePath = resourcePath;
- this.init("New Scene", "AtomicEditor/editor/ui/resourcecreatecomponent.tb.txt");
- this.nameField = <Atomic.UIEditField> this.getWidget("component_name");
- }
- handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
- if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
- var id = ev.target.id;
- if (id == "create") {
- var sceneName = this.nameField.text;
- var outputFile = Atomic.addTrailingSlash(this.resourcePath) + sceneName;
- if (outputFile.indexOf(".scene") == -1) outputFile += ".scene";
- if (ResourceOps.CreateNewScene(outputFile, sceneName)) {
- this.hide();
- this.sendEvent(EditorEvents.EditResource, { path:outputFile});
- }
- return true;
- }
- if (id == "cancel") {
- this.hide();
- return true;
- }
- }
- }
- resourcePath: string;
- nameField: Atomic.UIEditField;
- }
- export class CreateMaterial extends ModalWindow {
- constructor(resourcePath: string) {
- super();
- this.resourcePath = resourcePath;
- this.init("New Material", "AtomicEditor/editor/ui/resourcecreatecomponent.tb.txt");
- this.nameField = <Atomic.UIEditField> this.getWidget("component_name");
- }
- handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
- if (ev.type == Atomic.UI_EVENT_TYPE_CLICK) {
- var id = ev.target.id;
- if (id == "create") {
- var materialName = this.nameField.text;
- var outputFile = Atomic.addTrailingSlash(this.resourcePath) + materialName;
- if (outputFile.indexOf(".material") == -1) outputFile += ".material";
- if (ResourceOps.CreateNewMaterial(outputFile, materialName)) {
- this.hide();
- this.sendEvent(EditorEvents.EditResource, { path:outputFile});
- }
- return true;
- }
- if (id == "cancel") {
- this.hide();
- return true;
- }
- }
- }
- resourcePath: string;
- nameField: Atomic.UIEditField;
- }
|