0) { this.onImportStart(null); this.importManager.clearScene(); this.importManager.startImport(File(loc2[0])); } else { this.libraryManager.loadGivenLibraries(loc2); } } private function onBatchProcessingComplete(param1:Event):void { this.hideProgressBar(); } private function onBatchProcessingProgress(param1:EditorProgressEvent):void { this.progressBar.setProgress(param1.progress, 1); } private function waitForContextAndInitFunctionalLibrary() : void { var device:Device = View.getStaticDevice(); if(device.getContext3D() != null) { initFunctionalLibrary(); return; } device.addEventListener(Event.CONTEXT3D_CREATE, context3DCreated); } private function context3DCreated(e:Event):void { View.getStaticDevice().removeEventListener(Event.CONTEXT3D_CREATE, context3DCreated); initFunctionalLibrary(); } private function initFunctionalLibrary():void { this.libraryManager.addLibrary(FunctionalProps.getFunctionalLibrary()); this.cbPropLibNames.selectedItem = "Functional"; this.onComboBoxChange(null); } private function initMenuItems():void { this.miVisulaGeometry = this.getMenuItem(2, 0); this.miCollisionGeometry = this.getMenuItem(2, 1); this.miShowGrid = this.getMenuItem(2, 4); this.miSnap = this.getMenuItem(4, 1); this.miUnlock = this.getMenuItemByLabel("All intersections allowed"); this.miLockGroup = this.getMenuItemByLabel("Same props intersections denied"); this.miLock = this.getMenuItemByLabel("All intersections denied"); this.miShowLayers = this.getMenuItem(2, 5); } private function getMenuItem(...rest):NativeMenuItem { var loc2:NativeMenuItem = menu.nativeMenu.getItemAt(rest[0]); var loc3:int = 1; while (loc3 < rest.length) { loc2 = loc2.submenu.getItemAt(rest[loc3]); loc3++; } return loc2; } private function getMenuItemByLabel(param1:String, param2:NativeMenu = null):NativeMenuItem { var loc4:NativeMenuItem = null; if (!param2) { param2 = this.menu.nativeMenu; } var loc3:int = 0; while (loc3 < param2.numItems) { loc4 = param2.getItemAt(loc3); if (loc4.label == param1) { return loc4; } if (Boolean(loc4.submenu) && Boolean(this.getMenuItemByLabel(param1, loc4.submenu))) { return this.getMenuItemByLabel(param1, loc4.submenu); } loc3++; } return null; } private function onPropSelect(param1:PropListEvent):void { preview.showProp(param1.selectedItem); this.workspace.setFocus(); this.cursorScene.object = param1.selectedItem.clone(); } private function onPropListClick(param1:MouseEvent):void { this.workspace.setFocus(); } private function onLibraryManagerChange(param1:Event):void { this.cursorScene.clear(); var loc2:Array = this.libraryManager.libraryNames; this.cbPropLibNames.selectedItem = loc2[loc2.length - 1]; this.onComboBoxChange(null); this.hideProgressBar(); } private function onKeyDown(param1:KeyboardEvent):void { var loc2:Prop = null; switch (param1.keyCode) { case KeyboardUtils.SPACE: if (!this.showCollisionGeometry) { if (this.cursorScene.visible) { loc2 = this.cursorScene.object; if (loc2) { this.sceneContainer.addProp(loc2); break; } Alert.show("Select prop for pasting!"); break; } if (this.propertyPanel.enabled && this.showPropertyButton.down && this.mainScene.isTexturePanel) { this.mainScene.onTexturePanelSelect(); } break; } } this.workspace.setFocus(); } private function toggleSnapMode():void { this.setSnapping(!this.snappingEnabled); } private function setSnapping(param1:Boolean):void { this.snappingEnabled = param1; this.sceneContainer.snapMode = param1; this.miSnap.checked = param1; this.snapButton.down = param1; } private function toggleGrid():void { this.showGrid = !this.showGrid; this.btnToggleGrid.down = this.showGrid; this.miShowGrid.checked = this.showGrid; if (this.showGrid) { this.mainScene.showGrid(); } else { this.mainScene.hideGrid(); } } private function showPropertyPanel():void { if (this.showPropertyButton.down) { this.vbox.addChild(this.propertyPanel); } else { this.vbox.removeChild(this.propertyPanel); } } private function toggleGeometryViewMode():void { this.showCollisionGeometry = !this.showCollisionGeometry; this.viewButton.down = this.showCollisionGeometry; this.miVisulaGeometry.checked = !this.showCollisionGeometry; this.miCollisionGeometry.checked = this.showCollisionGeometry; if (this.showCollisionGeometry) { this.mainScene.showCollisionBoxes(); } else { this.mainScene.hideCollisionBoxes(); } } private function onComboBoxChange(param1:Event):void { var loc2:Array = null; var loc3:int = 0; var loc4:Prop = null; this.proplistPanel.deleteAllProps(); if (this.cbPropLibNames.selectedLabel) { loc2 = this.libraryManager.getPropsByLibName(this.cbPropLibNames.selectedLabel); loc3 = 0; while (loc3 < loc2.length) { loc4 = loc2[loc3]; this.proplistPanel.addProp(loc4.groupName, loc4.name, loc4.icon, loc4); loc3++; } } } private function onSelectionTypeChange(param1:Event):void { switch (this.typeSelecting.selectedIndex) { case 0: this.mainScene.selectablePropTypes = DEFAULT_SELECTABLE_TYPES; break; case 1: this.mainScene.selectablePropTypes = [MeshProp]; break; case 2: this.mainScene.selectablePropTypes = [Sprite3DProp]; break; case 3: this.mainScene.selectablePropTypes = [SpawnPoint, BonusRegion, CTFFlagBase, ControlPoint, FreeBonusRegion]; } this.workspace.setFocus(); } private function hideSelectedProps():void { this.mainScene.hideSelectedProps(); } private function showAll():void { this.mainScene.showAll(); } private function onBatchFileSelect(param1:Event):void { this.showProgressBar("Batch processing"); this.progressBar.setProgress(0, 1); this.batchProcessor.run(this.batchSelector.getDirectoryListing()); } private function menuHandler(param1:FlexNativeMenuEvent):void { var handlerName:String = param1.item.@click; var loc2:Function = this[handlerName]; //var loc2:Function = param1.item.@click; if (loc2 != null) { loc2.call(this, param1.nativeMenuItem); } this.workspace.setFocus(); } private function onNewLevelClick(param1:NativeMenuItem):void { var item:NativeMenuItem = param1; if (this.mainScene.changed) { Alert.show("Discard changes?", "Scene has been changed", Alert.YES | Alert.CANCEL, null, function(param1:CloseEvent):void { if (param1.detail == Alert.YES) { newLevel(); } }); } else { this.newLevel(); } } private function newLevel():void { this.mainScene.clear(); //this.cursorScene.updateMaterial(); this.cursorScene.clear(); } private function onImportFromTanksClick(param1:NativeMenuItem):void { var item:NativeMenuItem = param1; if (this.mainScene.changed) { Alert.show("Discard changes?", "Scene has been changed", Alert.YES | Alert.CANCEL, null, function(param1:CloseEvent):void { if (param1.detail == Alert.YES) { importFromXML(); } }); } else { this.importFromXML(); } } private function importFromXML():void { this.importManager.clearScene(); this.importManager.importFromXML(); } private function appendFromXMLClick(param1:NativeMenuItem):void { this.importManager.importFromXML(); } private function specialAppendFromXMLClick(param1:Event):void { this.importManager.importFromXML(true); } private function onImportStart(param1:Event):void { this.showProgressBar("Importing level"); } private function onImportProgress(param1:EditorProgressEvent):void { this.progressBar.setProgress(param1.progress, 1); } private function onImportComplete(param1:Event):void { this.hideProgressBar(); } private function onExportToTanksV1Click(param1:NativeMenuItem):void { this.exportManager.exportMap(FileType.MAP_XML_VERSION_1_LITE); } private function onExportToTanksV1FullClick(param1:Event):void { this.exportManager.exportMap(FileType.MAP_XML_VERSION_1_FULL); } private function onExportToTanksV3Click(param1:NativeMenuItem):void { this.exportManager.exportMap(FileType.MAP_XML_VERSION_3); } private function onBatchProcessingClick(param1:NativeMenuItem):void { this.batchSelector.browseForDirectory("Levels"); } private function onUndoClick(param1:NativeMenuItem):void { this.sceneContainer.undo(); } private function onRedoClick(param1:NativeMenuItem):void { this.sceneContainer.redo(); } private function onClearLevelClick(param1:NativeMenuItem):void { this.mainScene.clear(); this.mainScene.changed = true; //this.cursorScene.updateMaterial(); this.cursorScene.clear(); } private function onSelectAll(param1:NativeMenuItem):void { this.mainScene.selectAll(); } private function onClearAndLoadLibClick(param1:NativeMenuItem):void { this.libraryManager.clearAndLoadLibrary(); } private function onLoadLibClick(param1:NativeMenuItem):void { this.libraryManager.loadLibrary(); } private function onStartLibLoading(param1:Event):void { this.showProgressBar("Loading libraries"); } private function onLibraryLoadingProgress(param1:EditorProgressEvent):void { this.progressBar.setProgress(param1.progress, 1); } public function onToggleIntersectionCheckMode(param1:NativeMenuItem):void { this.getMenuItemByLabel("All intersections allowed").checked = false; this.getMenuItemByLabel("Same props intersections denied").checked = false; this.getMenuItemByLabel("All intersections denied").checked = false; switch (param1) { case this.getMenuItemByLabel("All intersections allowed"): this.sceneContainer.multiplePropMode = MultiPropMode.ANY; break; case this.getMenuItemByLabel("Same props intersections denied"): this.sceneContainer.multiplePropMode = MultiPropMode.GROUP; break; case this.getMenuItemByLabel("All intersections denied"): this.sceneContainer.multiplePropMode = MultiPropMode.NONE; } param1.checked = true; } private function onToggleGeometryClick(param1:NativeMenuItem):void { if (param1 == this.miCollisionGeometry && !this.showCollisionGeometry || param1 == this.miVisulaGeometry && this.showCollisionGeometry) { this.toggleGeometryViewMode(); } else { param1.checked = true; } } private function onSnapClick(param1:NativeMenuItem):void { this.toggleSnapMode(); } private function onShowBoundBoxesClick(param1:NativeMenuItem):void { this.sceneContainer.showBoundBoxes = !this.sceneContainer.showBoundBoxes; param1.checked = this.sceneContainer.showBoundBoxes; } private function onShowGridClick(param1:NativeMenuItem):void { this.toggleGrid(); } private function onHelpClick(param1:NativeMenuItem):void { Alert.show(helpText, "Help"); } private function showProgressBar(param1:String):void { if (this.progressBar == null) { this.progressBar = PopUpProgressBar(PopUpManager.createPopUp(this, PopUpProgressBar, true)); } this.progressBar.setLabel(param1); } private function hideProgressBar():void { if (this.progressBar != null) { PopUpManager.removePopUp(this.progressBar); this.progressBar = null; } } private function onObjectGroupCheckboxChange(param1:Event):void { } private function createPropPreview():void { preview = new Preview(); this.previewPanel.addChild(preview); this.previewPanel.addEventListener(Event.RESIZE, onPreviewPanelResize); } private function initPropList():void { this.proplistPanel.addEventListener(PropListEvent.SELECT, this.onPropSelect); this.proplistPanel.addEventListener(MouseEvent.CLICK, this.onPropListClick); } private function createPropertyPanel():void { this.propertyPanel = new Panel(); this.propertyPanel.title = "Properties"; this.propertyPanel.percentWidth = 100; this.propertyPanel.height = 200; this.mainScene.setPropertyPanel(this.propertyPanel); } private function createLibraryManager():void { this.libraryManager = new LibraryManager(); this.libraryManager.addEventListener(Event.OPEN, this.onStartLibLoading); this.libraryManager.addEventListener(Event.COMPLETE, this.onLibraryManagerChange); this.libraryManager.addEventListener(EditorProgressEvent.PROGRESS, this.onLibraryLoadingProgress); this.cbPropLibNames.dataProvider = this.libraryManager.libraryNames; } private function createImportManager():void { this.importManager = new ImportManager(this.mainScene, this.libraryManager); this.importManager.addEventListener(Event.COMPLETE, this.onImportComplete); this.importManager.addEventListener(EditorProgressEvent.PROGRESS, this.onImportProgress); this.importManager.addEventListener(Event.OPEN, this.onImportStart); } private function onShowLayersWindow(param1:NativeMenuItem):void { if (param1.checked) { this.showLayersWindow(); } else { this.closeLayersWindow(); } } private function showLayersWindow():void { if (this.layersWindow == null) { this.layersWindow = LayersWindowBase(PopUpManager.createPopUp(this, LayersWindow)); this.layersWindow.addEventListener(Event.CLOSE, this.closeLayersWindow); PopUpManager.centerPopUp(this.layersWindow); } this.layersWindow.visible = true; } private function closeLayersWindow(param1:Event = null):void { this.layersWindow.visible = false; this.miShowLayers.checked = false; } private function onClearLibClick(param1:NativeMenuItem):void { this.libraryManager.clearLibraries(); } ]]>