mirror of
https://github.com/MapMakersAndProgrammers/alternativa-editor-mod.git
synced 2025-10-25 17:39:15 -07:00
prop collision toggle added
This commit is contained in:
49
src/alternativa/editor/PropGeneralPropertiesPanel.mxml
Normal file
49
src/alternativa/editor/PropGeneralPropertiesPanel.mxml
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<mx:Panel xmlns:fx="http://ns.adobe.com/mxml/2009"
|
||||||
|
xmlns:s="library://ns.adobe.com/flex/spark"
|
||||||
|
xmlns:mx="library://ns.adobe.com/flex/mx"
|
||||||
|
creationComplete="onCreationComplete()" percentWidth="15" percentHeight="100"
|
||||||
|
title="Prop Parameters">
|
||||||
|
|
||||||
|
<fx:Script>
|
||||||
|
<![CDATA[
|
||||||
|
import alternativa.types.Set;
|
||||||
|
import alternativa.editor.prop.MeshProp;
|
||||||
|
import alternativa.editor.prop.Sprite3DProp;
|
||||||
|
|
||||||
|
private const _selectedProps:Vector.<MeshProp> = new Vector.<MeshProp>();
|
||||||
|
|
||||||
|
private function onCreationComplete():void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onCollisionChanged(param1:Event):void
|
||||||
|
{
|
||||||
|
for each(var prop:MeshProp in _selectedProps)
|
||||||
|
{
|
||||||
|
prop.collisionEnabled = this.collision.selected;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function init(selectedProps:Set, collisionEnabled:Boolean) : void
|
||||||
|
{
|
||||||
|
_selectedProps.length = 0;
|
||||||
|
for(var prop:* in selectedProps)
|
||||||
|
{
|
||||||
|
if(prop is MeshProp && !(prop is Sprite3DProp))
|
||||||
|
{
|
||||||
|
_selectedProps.push(prop as MeshProp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.collision.selected = collisionEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</fx:Script>
|
||||||
|
|
||||||
|
<mx:VBox paddingTop="5" paddingBottom="5" paddingLeft="5" paddingRight="5">
|
||||||
|
<mx:CheckBox id="collision" label="Collision enabled" change="onCollisionChanged(event)"/>
|
||||||
|
</mx:VBox>
|
||||||
|
|
||||||
|
</mx:Panel>
|
||||||
@@ -34,6 +34,12 @@ package alternativa.editor
|
|||||||
|
|
||||||
public class SceneContainer extends UIComponent
|
public class SceneContainer extends UIComponent
|
||||||
{
|
{
|
||||||
|
private static var _instance:SceneContainer;
|
||||||
|
public static function get instance() : SceneContainer
|
||||||
|
{
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
|
||||||
private static const cameraPoint:Point3D = new Point3D(0,0,1000);
|
private static const cameraPoint:Point3D = new Point3D(0,0,1000);
|
||||||
|
|
||||||
private static const cameraOffset:Point3D = new Point3D();
|
private static const cameraOffset:Point3D = new Point3D();
|
||||||
@@ -100,6 +106,7 @@ package alternativa.editor
|
|||||||
|
|
||||||
public function SceneContainer()
|
public function SceneContainer()
|
||||||
{
|
{
|
||||||
|
_instance = this;
|
||||||
this.multiplePropMode = MultiPropMode.NONE;
|
this.multiplePropMode = MultiPropMode.NONE;
|
||||||
this.mouseDownPoint = new Point();
|
this.mouseDownPoint = new Point();
|
||||||
this.rectProps = new Set();
|
this.rectProps = new Set();
|
||||||
|
|||||||
@@ -236,6 +236,10 @@ package alternativa.editor.mapexport
|
|||||||
|
|
||||||
protected function createTileCollisionXml(param1:MeshProp, param2:XML) : void
|
protected function createTileCollisionXml(param1:MeshProp, param2:XML) : void
|
||||||
{
|
{
|
||||||
|
if(!param1.collisionEnabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
var loc4:CollisionPrimitive = null;
|
var loc4:CollisionPrimitive = null;
|
||||||
var loc3:Vector.<CollisionPrimitive> = this.collPrimCache.getPrimitives(param1.libraryName,param1.groupName,param1.name);
|
var loc3:Vector.<CollisionPrimitive> = this.collPrimCache.getPrimitives(param1.libraryName,param1.groupName,param1.name);
|
||||||
if(loc3 == null)
|
if(loc3 == null)
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ package alternativa.editor.prop
|
|||||||
|
|
||||||
public class MeshProp extends Prop
|
public class MeshProp extends Prop
|
||||||
{
|
{
|
||||||
|
[Embed(source="no_collision_texture.png")]
|
||||||
|
private static const NO_COLLISION_TEXTURE_MASK_Class:Class;
|
||||||
|
|
||||||
|
private static const NO_COLLISION_TEXTURE_Bitmap:BitmapData = new NO_COLLISION_TEXTURE_MASK_Class().bitmapData;
|
||||||
|
|
||||||
public var bitmaps:Map;
|
public var bitmaps:Map;
|
||||||
|
|
||||||
protected var _textureName:String = "";
|
protected var _textureName:String = "";
|
||||||
@@ -33,6 +38,12 @@ package alternativa.editor.prop
|
|||||||
private var bound:Mesh;
|
private var bound:Mesh;
|
||||||
|
|
||||||
private var _objects:Vector.<Object3D>;
|
private var _objects:Vector.<Object3D>;
|
||||||
|
|
||||||
|
private var _collisionEnabled:Boolean = true;
|
||||||
|
|
||||||
|
private var _noCollisionTexture:BitmapData = null;
|
||||||
|
private var _noCollisionMaterial:TextureMaterial = null;
|
||||||
|
|
||||||
|
|
||||||
public function MeshProp(mainObject:Object3D, objects:Vector.<Object3D>, param2:String, param3:String, param4:String, param5:Boolean = true)
|
public function MeshProp(mainObject:Object3D, objects:Vector.<Object3D>, param2:String, param3:String, param4:String, param5:Boolean = true)
|
||||||
{
|
{
|
||||||
@@ -121,6 +132,7 @@ package alternativa.editor.prop
|
|||||||
{
|
{
|
||||||
loc2 = loc1 as Mesh;
|
loc2 = loc1 as Mesh;
|
||||||
loc2.setMaterialToAllFaces(this.collisionMaterial);
|
loc2.setMaterialToAllFaces(this.collisionMaterial);
|
||||||
|
addChild(loc2);
|
||||||
}
|
}
|
||||||
setMaterial(null);
|
setMaterial(null);
|
||||||
}
|
}
|
||||||
@@ -133,6 +145,7 @@ package alternativa.editor.prop
|
|||||||
{
|
{
|
||||||
loc2 = loc1 as Mesh;
|
loc2 = loc1 as Mesh;
|
||||||
loc2.setMaterialToAllFaces(null);
|
loc2.setMaterialToAllFaces(null);
|
||||||
|
removeChild(loc2);
|
||||||
}
|
}
|
||||||
setMaterial(_material);
|
setMaterial(_material);
|
||||||
}
|
}
|
||||||
@@ -162,17 +175,27 @@ package alternativa.editor.prop
|
|||||||
{
|
{
|
||||||
_material.dispose();
|
_material.dispose();
|
||||||
}
|
}
|
||||||
_material = new TextureMaterial(bitmapData);
|
|
||||||
if(_selected)
|
|
||||||
{
|
|
||||||
this.disposeSelectTexture();
|
|
||||||
|
|
||||||
|
_material = new TextureMaterial(bitmapData);
|
||||||
|
|
||||||
|
this.disposeSelectTexture();
|
||||||
|
|
||||||
|
if(_selected)
|
||||||
|
{
|
||||||
select();
|
select();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setMaterial(_material);
|
setMaterial(_material);
|
||||||
}
|
}
|
||||||
|
if(_noCollisionTexture != null)
|
||||||
|
{
|
||||||
|
_noCollisionMaterial.dispose();
|
||||||
|
_noCollisionMaterial = null;
|
||||||
|
_noCollisionTexture.dispose();
|
||||||
|
_noCollisionTexture = null;
|
||||||
|
}
|
||||||
|
this.setToCollisionDisabledTextureIfNeeded();
|
||||||
if(this._textureName == "DEFAULT")
|
if(this._textureName == "DEFAULT")
|
||||||
{
|
{
|
||||||
this._textureName = "";
|
this._textureName = "";
|
||||||
@@ -216,6 +239,7 @@ package alternativa.editor.prop
|
|||||||
loc2.bitmaps = this.bitmaps;
|
loc2.bitmaps = this.bitmaps;
|
||||||
loc2._textureName = this._textureName;
|
loc2._textureName = this._textureName;
|
||||||
loc2.height = height;
|
loc2.height = height;
|
||||||
|
loc2.collisionEnabled = this._collisionEnabled;
|
||||||
return loc2;
|
return loc2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,6 +283,53 @@ package alternativa.editor.prop
|
|||||||
this.bound = null;
|
this.bound = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get collisionEnabled() : Boolean
|
||||||
|
{
|
||||||
|
return this._collisionEnabled;
|
||||||
|
}
|
||||||
|
public function set collisionEnabled(enabled:Boolean) : void
|
||||||
|
{
|
||||||
|
if(this._collisionEnabled == enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this._collisionEnabled = enabled;
|
||||||
|
|
||||||
|
this.setToCollisionDisabledTextureIfNeeded();
|
||||||
|
}
|
||||||
|
private function setToCollisionDisabledTextureIfNeeded() : void
|
||||||
|
{
|
||||||
|
if(_collisionEnabled)
|
||||||
|
return;
|
||||||
|
if(_selected) //shouldn't change texture of 'selected'
|
||||||
|
return;
|
||||||
|
if(hidden)
|
||||||
|
return;
|
||||||
|
if(this._textureName == InvisibleTexture.TEXTURE_NAME)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(_noCollisionTexture == null)
|
||||||
|
{
|
||||||
|
_noCollisionTexture = this.bitmapData.clone();
|
||||||
|
|
||||||
|
_matrix.a = this.bitmapData.width / NO_COLLISION_TEXTURE_Bitmap.width;
|
||||||
|
_matrix.d = this.bitmapData.height / NO_COLLISION_TEXTURE_Bitmap.height;
|
||||||
|
|
||||||
|
_noCollisionTexture.draw(NO_COLLISION_TEXTURE_Bitmap, _matrix);
|
||||||
|
|
||||||
|
//_noCollisionTexture = NO_COLLISION_TEXTURE_Bitmap.clone();
|
||||||
|
_noCollisionMaterial = new TextureMaterial(_noCollisionTexture);
|
||||||
|
}
|
||||||
|
|
||||||
|
setMaterial(_noCollisionMaterial);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override function deselect() : void
|
||||||
|
{
|
||||||
|
super.deselect();
|
||||||
|
|
||||||
|
this.setToCollisionDisabledTextureIfNeeded();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ package alternativa.editor.prop
|
|||||||
|
|
||||||
public static const KILL_GEOMETRY:int = 6;
|
public static const KILL_GEOMETRY:int = 6;
|
||||||
|
|
||||||
private static const _matrix:Matrix = new Matrix();
|
protected static const _matrix:Matrix = new Matrix();
|
||||||
|
|
||||||
private static var redClass:Class = Prop_redClass;
|
private static var redClass:Class = Prop_redClass;
|
||||||
|
|
||||||
|
|||||||
BIN
src/alternativa/editor/prop/no_collision_texture.png
Normal file
BIN
src/alternativa/editor/prop/no_collision_texture.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
@@ -44,6 +44,10 @@ package alternativa.editor.scene
|
|||||||
import flash.geom.Vector3D;
|
import flash.geom.Vector3D;
|
||||||
import alternativa.engine3d.core.Object3DContainer;
|
import alternativa.engine3d.core.Object3DContainer;
|
||||||
import alternativa.editor.prop.CTFFlagBase;
|
import alternativa.editor.prop.CTFFlagBase;
|
||||||
|
import alternativa.editor.PropGeneralPropertiesPanel;
|
||||||
|
import mx.controls.Alert;
|
||||||
|
import mx.containers.HBox;
|
||||||
|
import alternativa.editor.SceneContainer;
|
||||||
|
|
||||||
public class MainScene extends EditorScene
|
public class MainScene extends EditorScene
|
||||||
{
|
{
|
||||||
@@ -64,7 +68,7 @@ package alternativa.editor.scene
|
|||||||
|
|
||||||
private var texturePanel:TexturePanel;
|
private var texturePanel:TexturePanel;
|
||||||
|
|
||||||
private var propertyPanel:Panel;
|
private const propertyPanel:HBox = new HBox();
|
||||||
|
|
||||||
private var bonusTypesPanel:BonusRegionPropertiesPanel;
|
private var bonusTypesPanel:BonusRegionPropertiesPanel;
|
||||||
|
|
||||||
@@ -85,12 +89,15 @@ package alternativa.editor.scene
|
|||||||
private var domSpawnPoint:SpawnPoint;
|
private var domSpawnPoint:SpawnPoint;
|
||||||
|
|
||||||
private var controlPointNameField:ControlPointNameField;
|
private var controlPointNameField:ControlPointNameField;
|
||||||
|
|
||||||
|
private var propGeneralProperties:PropGeneralPropertiesPanel;
|
||||||
|
|
||||||
public function MainScene()
|
public function MainScene()
|
||||||
{
|
{
|
||||||
this.hiddenProps = [];
|
this.hiddenProps = [];
|
||||||
this.bonusTypesPanel = new BonusRegionPropertiesPanel();
|
this.bonusTypesPanel = new BonusRegionPropertiesPanel();
|
||||||
this.killZonePanel = new KillZonePropertiesPanel();
|
this.killZonePanel = new KillZonePropertiesPanel();
|
||||||
|
this.propGeneralProperties = new PropGeneralPropertiesPanel();
|
||||||
this._selectablePropTypes = new Set();
|
this._selectablePropTypes = new Set();
|
||||||
this.exporters = {};
|
this.exporters = {};
|
||||||
this.layers = new Layers();
|
this.layers = new Layers();
|
||||||
@@ -112,6 +119,7 @@ package alternativa.editor.scene
|
|||||||
this.createControlPointNameTextField();
|
this.createControlPointNameTextField();
|
||||||
collider = new EllipsoidCollider(30,30,30);
|
collider = new EllipsoidCollider(30,30,30);
|
||||||
__root = root;
|
__root = root;
|
||||||
|
this.propertyPanel.percentHeight = this.propertyPanel.percentWidth = 100;
|
||||||
GlobalEventDispatcher.addListener(LayerVisibilityChangeEvent.VISIBILITY_CHANGED,this.onLayerVisibilityChange);
|
GlobalEventDispatcher.addListener(LayerVisibilityChangeEvent.VISIBILITY_CHANGED,this.onLayerVisibilityChange);
|
||||||
GlobalEventDispatcher.addListener(LayerContentChangeEvent.LAYER_CONTENT_CHANGED,this.onLayerContentChange);
|
GlobalEventDispatcher.addListener(LayerContentChangeEvent.LAYER_CONTENT_CHANGED,this.onLayerContentChange);
|
||||||
GlobalEventDispatcher.addListener(DominationSpawnLinkStartEvent.DOMINATION_SPAWN_LINK_START,this.onDominationLinkStart);
|
GlobalEventDispatcher.addListener(DominationSpawnLinkStartEvent.DOMINATION_SPAWN_LINK_START,this.onDominationLinkStart);
|
||||||
@@ -178,6 +186,7 @@ package alternativa.editor.scene
|
|||||||
|
|
||||||
public function exportScene(param1:FileType, param2:FileStream) : void
|
public function exportScene(param1:FileType, param2:FileStream) : void
|
||||||
{
|
{
|
||||||
|
SceneContainer.instance.cursorScene.clear();
|
||||||
FileExporter(this.exporters[param1]).exportToFileStream(param2);
|
FileExporter(this.exporters[param1]).exportToFileStream(param2);
|
||||||
this._changed = false;
|
this._changed = false;
|
||||||
}
|
}
|
||||||
@@ -391,7 +400,7 @@ package alternativa.editor.scene
|
|||||||
|
|
||||||
public function setPropertyPanel(param1:Panel) : void
|
public function setPropertyPanel(param1:Panel) : void
|
||||||
{
|
{
|
||||||
this.propertyPanel = param1;
|
param1.addChild(this.propertyPanel);
|
||||||
this.texturePanel = new TexturePanel();
|
this.texturePanel = new TexturePanel();
|
||||||
this.texturePanel.addEventListener(PropListEvent.SELECT,this.onTexturePanelSelect);
|
this.texturePanel.addEventListener(PropListEvent.SELECT,this.onTexturePanelSelect);
|
||||||
}
|
}
|
||||||
@@ -553,8 +562,7 @@ package alternativa.editor.scene
|
|||||||
}
|
}
|
||||||
this.selectedProps.clear();
|
this.selectedProps.clear();
|
||||||
this.selectedProp = null;
|
this.selectedProp = null;
|
||||||
this.hidePropertyPanelItem(this.bonusTypesPanel);
|
this.hideAllPropertyPanelItems();
|
||||||
this.hidePropertyPanelItem(this.texturePanel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deselectProp(param1:Prop) : void
|
public function deselectProp(param1:Prop) : void
|
||||||
@@ -569,6 +577,7 @@ package alternativa.editor.scene
|
|||||||
|
|
||||||
if(this.selectedProps.length > 0)
|
if(this.selectedProps.length > 0)
|
||||||
{
|
{
|
||||||
|
this.selectedProp = this.selectedProps.peek();
|
||||||
this.showPropertyPanel();
|
this.showPropertyPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -593,7 +602,10 @@ package alternativa.editor.scene
|
|||||||
this.selectedProp = loc3;
|
this.selectedProp = loc3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.showPropertyPanel();
|
if(this.selectedProp != null)
|
||||||
|
{
|
||||||
|
this.showPropertyPanel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function selectConflictingProps() : void
|
public function selectConflictingProps() : void
|
||||||
@@ -847,7 +859,7 @@ package alternativa.editor.scene
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showPropertyPanel() : void
|
private function showPropertyPanel() : void
|
||||||
{
|
{
|
||||||
var loc1:Map = null;
|
var loc1:Map = null;
|
||||||
this.hideAllPropertyPanelItems();
|
this.hideAllPropertyPanelItems();
|
||||||
@@ -874,15 +886,34 @@ package alternativa.editor.scene
|
|||||||
}
|
}
|
||||||
this.bonusTypesPanel.setBonusRegion(null);
|
this.bonusTypesPanel.setBonusRegion(null);
|
||||||
|
|
||||||
for(var item:* in this.selectedProps)
|
|
||||||
|
var item:*;
|
||||||
|
for(item in this.selectedProps)
|
||||||
{
|
{
|
||||||
if(!(item is MeshProp))
|
if(!(item is MeshProp))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.showTexturePanel();
|
||||||
|
|
||||||
|
|
||||||
|
var collisionEnabled:Boolean = (this.selectedProp as MeshProp).collisionEnabled;
|
||||||
|
|
||||||
|
for(item in this.selectedProps)
|
||||||
|
{
|
||||||
|
if(item is Sprite3DProp)
|
||||||
|
continue;
|
||||||
|
if(collisionEnabled != (item as MeshProp).collisionEnabled)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showTexturePanel();
|
this.texturePanel.percentWidth = 100 - this.propGeneralProperties.percentWidth;
|
||||||
|
|
||||||
|
this.showPropertyPanelItem(this.propGeneralProperties);
|
||||||
|
|
||||||
|
this.propGeneralProperties.init(this.selectedProps, collisionEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function showTexturePanel() : void
|
private function showTexturePanel() : void
|
||||||
@@ -891,6 +922,8 @@ package alternativa.editor.scene
|
|||||||
if(!loc1)
|
if(!loc1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
this.texturePanel.percentWidth = 100;
|
||||||
|
|
||||||
this.showPropertyPanelItem(this.texturePanel);
|
this.showPropertyPanelItem(this.texturePanel);
|
||||||
if(loc1 != this.currentBitmaps)
|
if(loc1 != this.currentBitmaps)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user