Merge remote-tracking branch 'upstream/development' into imageAsset_refactor_rev3
|
|
@ -111,8 +111,12 @@ function handleConnectionErrorMessage(%msgType, %msgString, %msgError)
|
|||
//-----------------------------------------------------------------------------
|
||||
// Disconnect
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function disconnect()
|
||||
{
|
||||
callOnModules("disconnect");
|
||||
}
|
||||
|
||||
function Core_ClientServer::disconnect(%this)
|
||||
{
|
||||
// We need to stop the client side simulation
|
||||
// else physics resources will not cleanup properly.
|
||||
|
|
@ -158,3 +162,16 @@ function disconnectedCleanup()
|
|||
|
||||
moduleExec("onDestroyClientConnection", "Game");
|
||||
}
|
||||
|
||||
function clientCmdsetMoveMap(%movemap)
|
||||
{
|
||||
if (!isObject(%movemap)) return;
|
||||
if(isObject(ServerConnection) && isObject(ServerConnection.curMoveMap))
|
||||
ServerConnection.curMoveMap.pop();
|
||||
|
||||
// clear movement
|
||||
$mvForwardAction = 0;
|
||||
$mvBackwardAction = 0;
|
||||
%movemap.push();
|
||||
ServerConnection.curMoveMap = %movemap;
|
||||
}
|
||||
|
|
@ -275,7 +275,9 @@ function GameConnection::onPostSpawn( %this )
|
|||
if (%this.numModsNeedingLoaded)
|
||||
callOnObjectList("onPostSpawn", %modulesIdList, %this);
|
||||
else
|
||||
%this.listener.onPostSpawnComplete(%this);
|
||||
%this.listener.onPostSpawnComplete(%this);
|
||||
if (isObject(%this.player.getDatablock().controlMap))
|
||||
commandToClient(%this, 'setMoveMap', %this.player.getDatablock().controlMap);
|
||||
}
|
||||
|
||||
function GameConnectionListener::onPostSpawnComplete(%this, %client)
|
||||
|
|
|
|||
|
|
@ -169,3 +169,20 @@ datablock LightAnimData( SpinLightAnim )
|
|||
rotKeys[2] = "az";
|
||||
rotSmooth[2] = true;
|
||||
};
|
||||
|
||||
datablock AIPlayerControllerData( aiPlayerControl )
|
||||
{
|
||||
moveTolerance = 0.25; followTolerance = 1.0; mAttackRadius = 2;
|
||||
};
|
||||
|
||||
datablock AIWheeledVehicleControllerData( aiCarControl )
|
||||
{
|
||||
moveTolerance = 1.0; followTolerance = 2.0; mAttackRadius = 5.0;
|
||||
};
|
||||
|
||||
datablock AIFlyingVehicleControllerData( aiPlaneControl )
|
||||
{
|
||||
moveTolerance = 2.0; followTolerance = 5.0; mAttackRadius = 10.0;
|
||||
FlightFloor = 15; FlightCeiling = 150;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -78,17 +78,15 @@ function spawnGameObject(%name, %addToScene)
|
|||
return 0;
|
||||
}
|
||||
|
||||
function GameBaseData::onNewDataBlock(%this, %obj)
|
||||
function GameBaseData::onNewDataBlock(%this, %obj, %reload)
|
||||
{
|
||||
if (%obj.firstDataCheck)
|
||||
if (%reload)
|
||||
{
|
||||
if(%this.isMethod("onRemove"))
|
||||
%this.onRemove(%obj);
|
||||
if(%this.isMethod("onAdd"))
|
||||
%this.onAdd(%obj);
|
||||
}
|
||||
else
|
||||
%obj.firstDataCheck = true;
|
||||
}
|
||||
|
||||
function saveGameObject(%name, %tamlPath, %scriptPath)
|
||||
|
|
|
|||
11
Templates/BaseGame/game/data/DamageModel/DamageModel.module
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<ModuleDefinition
|
||||
ModuleId="DamageModel"
|
||||
VersionId="1"
|
||||
Group="Game"
|
||||
scriptFile="DamageModel.tscript"
|
||||
CreateFunction="onCreate"
|
||||
DestroyFunction="onDestroy">
|
||||
<DeclaredAssets
|
||||
Extension="asset.taml"
|
||||
Recurse="true"/>
|
||||
</ModuleDefinition>
|
||||
48
Templates/BaseGame/game/data/DamageModel/DamageModel.tscript
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
function DamageModel::onCreate(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function DamageModel::onDestroy(%this)
|
||||
{
|
||||
}
|
||||
|
||||
//This is called when the server is initially set up by the game application
|
||||
function DamageModel::initServer(%this)
|
||||
{
|
||||
}
|
||||
|
||||
//This is called when the server is created for an actual game/map to be played
|
||||
function DamageModel::onCreateGameServer(%this)
|
||||
{
|
||||
%this.registerDatablock("./scripts/managedData/managedParticleData");
|
||||
%this.registerDatablock("./scripts/managedData/managedParticleEmitterData");
|
||||
%this.queueExec("./scripts/server/utility");
|
||||
%this.queueExec("./scripts/server/radiusDamage");
|
||||
%this.queueExec("./scripts/server/projectile");
|
||||
%this.queueExec("./scripts/server/weapon");
|
||||
%this.queueExec("./scripts/server/shapeBase");
|
||||
%this.queueExec("./scripts/server/vehicle");
|
||||
%this.queueExec("./scripts/server/player");
|
||||
}
|
||||
|
||||
//This is called when the server is shut down due to the game/map being exited
|
||||
function DamageModel::onDestroyGameServer(%this)
|
||||
{
|
||||
}
|
||||
|
||||
//This is called when the client is initially set up by the game application
|
||||
function DamageModel::initClient(%this)
|
||||
{
|
||||
%this.queueExec("./guis/damageGuiOverlay.gui");
|
||||
%this.queueExec("./scripts/client/playGui");
|
||||
}
|
||||
|
||||
//This is called when a client connects to a server
|
||||
function DamageModel::onCreateClientConnection(%this)
|
||||
{
|
||||
}
|
||||
|
||||
//This is called when a client disconnects from a server
|
||||
function DamageModel::onDestroyClientConnection(%this)
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
<GUIAsset canSave="true" canSaveDynamicFields="true" AssetName="damageGuiOverlay" scriptFile="@assetFile=damageGuiOverlay.gui" GUIFile="@assetFile=damageGuiOverlay.gui" VersionId="1"/>
|
||||
|
|
@ -0,0 +1,285 @@
|
|||
//--- OBJECT WRITE BEGIN ---
|
||||
$guiContent = new GuiContainer(DamageGuiOverlay) {
|
||||
isContainer = "1";
|
||||
Profile = "GuiContentProfile";
|
||||
HorizSizing = "relative";
|
||||
VertSizing = "relative";
|
||||
position = "0 0";
|
||||
Extent = "1024 768";
|
||||
MinExtent = "8 8";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
canSaveDynamicFields = "1";
|
||||
Enabled = "1";
|
||||
helpTag = "0";
|
||||
noCursor = "1";
|
||||
new GuiShapeNameHud() {
|
||||
fillColor = "0 0 0 0.25";
|
||||
frameColor = "0 1 0 1";
|
||||
textColor = "0 1 0 1";
|
||||
showFill = "0";
|
||||
showFrame = "0";
|
||||
verticalOffset = "0.2";
|
||||
distanceFade = "0.1";
|
||||
isContainer = "0";
|
||||
Profile = "GuiModelessDialogProfile";
|
||||
HorizSizing = "width";
|
||||
VertSizing = "height";
|
||||
position = "0 0";
|
||||
Extent = "1024 768";
|
||||
MinExtent = "8 8";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
canSaveDynamicFields = "0";
|
||||
};
|
||||
new GuiCrossHairHud(Reticle) {
|
||||
damageFillColor = "0 1 0 1";
|
||||
damageFrameColor = "1 0.6 0 1";
|
||||
damageRect = "50 4";
|
||||
damageOffset = "0 10";
|
||||
bitmapAsset = "FPSEquipment:blank_image";
|
||||
wrap = "0";
|
||||
isContainer = "0";
|
||||
Profile = "GuiModelessDialogProfile";
|
||||
HorizSizing = "center";
|
||||
VertSizing = "center";
|
||||
position = "496 368";
|
||||
Extent = "32 32";
|
||||
MinExtent = "8 8";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
canSaveDynamicFields = "0";
|
||||
};
|
||||
new GuiCrossHairHud(ZoomReticle) {
|
||||
damageFillColor = "0 1 0 1";
|
||||
damageFrameColor = "1 0.6 0 1";
|
||||
damageRect = "50 4";
|
||||
damageOffset = "0 10";
|
||||
bitmapAsset = "DamageModel:bino_image";
|
||||
wrap = "0";
|
||||
isContainer = "0";
|
||||
Profile = "GuiModelessDialogProfile";
|
||||
HorizSizing = "width";
|
||||
VertSizing = "height";
|
||||
position = "0 0";
|
||||
Extent = "1024 768";
|
||||
MinExtent = "8 8";
|
||||
canSave = "1";
|
||||
Visible = "0";
|
||||
tooltipprofile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
canSaveDynamicFields = "0";
|
||||
};
|
||||
new GuiBitmapBorderCtrl(WeaponHUD) {
|
||||
isContainer = "0";
|
||||
Profile = "ChatHudBorderProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "top";
|
||||
position = "78 693";
|
||||
Extent = "124 72";
|
||||
MinExtent = "8 8";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
canSaveDynamicFields = "0";
|
||||
|
||||
new GuiBitmapCtrl() {
|
||||
bitmap = "UI:hudfill_image";
|
||||
wrap = "0";
|
||||
isContainer = "0";
|
||||
Profile = "GuiDefaultProfile";
|
||||
HorizSizing = "width";
|
||||
VertSizing = "height";
|
||||
position = "8 8";
|
||||
Extent = "108 56";
|
||||
MinExtent = "8 8";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
canSaveDynamicFields = "0";
|
||||
};
|
||||
new GuiBitmapCtrl(PreviewImage) {
|
||||
bitmapAsset = "UI:hudfill_image";
|
||||
wrap = "0";
|
||||
isContainer = "0";
|
||||
Profile = "GuiDefaultProfile";
|
||||
HorizSizing = "width";
|
||||
VertSizing = "height";
|
||||
position = "8 8";
|
||||
Extent = "108 56";
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
canSaveDynamicFields = "0";
|
||||
};
|
||||
new GuiTextCtrl(AmmoAmount) {
|
||||
maxLength = "255";
|
||||
Margin = "0 0 0 0";
|
||||
Padding = "0 0 0 0";
|
||||
AnchorTop = "0";
|
||||
AnchorBottom = "0";
|
||||
AnchorLeft = "0";
|
||||
AnchorRight = "0";
|
||||
isContainer = "0";
|
||||
Profile = "HudTextItalicProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "top";
|
||||
position = "40 8";
|
||||
Extent = "120 16";
|
||||
MinExtent = "8 8";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
tooltipprofile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
canSaveDynamicFields = "0";
|
||||
};
|
||||
};
|
||||
new GuiHealthTextHud() {
|
||||
fillColor = "0 0 0 0.65";
|
||||
frameColor = "0 0 0 1";
|
||||
textColor = "1 1 1 1";
|
||||
warningColor = "1 0 0 1";
|
||||
showFill = "1";
|
||||
showFrame = "1";
|
||||
showTrueValue = "0";
|
||||
showEnergy = "0";
|
||||
warnThreshold = "25";
|
||||
pulseThreshold = "15";
|
||||
pulseRate = "750";
|
||||
position = "5 693";
|
||||
extent = "72 72";
|
||||
minExtent = "8 2";
|
||||
horizSizing = "right";
|
||||
vertSizing = "top";
|
||||
profile = "GuiBigTextProfile";
|
||||
visible = "1";
|
||||
active = "1";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
isContainer = "0";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "0";
|
||||
};
|
||||
new GuiControl(DamageHUD) {
|
||||
position = "384 256";
|
||||
extent = "256 256";
|
||||
minExtent = "8 2";
|
||||
horizSizing = "center";
|
||||
vertSizing = "center";
|
||||
profile = "GuiDefaultProfile";
|
||||
visible = "1";
|
||||
active = "1";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
isContainer = "1";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "0";
|
||||
|
||||
new GuiBitmapCtrl(DamageFront) {
|
||||
bitmapAsset = "DamageModel:damageFront_image";
|
||||
wrap = "0";
|
||||
position = "0 0";
|
||||
extent = "256 32";
|
||||
minExtent = "8 2";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
profile = "GuiDefaultProfile";
|
||||
visible = "0";
|
||||
active = "1";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
isContainer = "0";
|
||||
internalName = "Damage[Front]";
|
||||
hidden = "1";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "0";
|
||||
};
|
||||
new GuiBitmapCtrl(DamageTop) {
|
||||
bitmapAsset = "DamageModel:damageTop_image";
|
||||
wrap = "0";
|
||||
position = "0 0";
|
||||
extent = "256 32";
|
||||
minExtent = "8 2";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
profile = "GuiDefaultProfile";
|
||||
visible = "0";
|
||||
active = "1";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
isContainer = "0";
|
||||
internalName = "Damage[Top]";
|
||||
hidden = "1";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "0";
|
||||
};
|
||||
new GuiBitmapCtrl(DamageBottom) {
|
||||
bitmapAsset = "DamageModel:damageBottom_image";
|
||||
wrap = "0";
|
||||
position = "0 224";
|
||||
extent = "256 32";
|
||||
minExtent = "8 2";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
profile = "GuiDefaultProfile";
|
||||
visible = "0";
|
||||
active = "1";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
isContainer = "0";
|
||||
internalName = "Damage[Bottom]";
|
||||
hidden = "1";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "0";
|
||||
};
|
||||
new GuiBitmapCtrl(DamageLeft) {
|
||||
bitmapAsset = "DamageModel:damageLeft_image";
|
||||
wrap = "0";
|
||||
position = "0 0";
|
||||
extent = "32 256";
|
||||
minExtent = "8 2";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
profile = "GuiDefaultProfile";
|
||||
visible = "0";
|
||||
active = "1";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
isContainer = "0";
|
||||
internalName = "Damage[Left]";
|
||||
hidden = "1";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "0";
|
||||
};
|
||||
new GuiBitmapCtrl(DamageRight) {
|
||||
bitmapAsset = "DamageModel:damageRight_image";
|
||||
wrap = "0";
|
||||
position = "224 0";
|
||||
extent = "32 256";
|
||||
minExtent = "8 2";
|
||||
horizSizing = "right";
|
||||
vertSizing = "bottom";
|
||||
profile = "GuiDefaultProfile";
|
||||
visible = "0";
|
||||
active = "1";
|
||||
tooltipProfile = "GuiToolTipProfile";
|
||||
hovertime = "1000";
|
||||
isContainer = "0";
|
||||
internalName = "Damage[Right]";
|
||||
hidden = "1";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "0";
|
||||
};
|
||||
};
|
||||
};
|
||||
//--- OBJECT WRITE END ---
|
||||
BIN
Templates/BaseGame/game/data/DamageModel/images/crosshair.png
Normal file
|
After Width: | Height: | Size: 144 B |
|
After Width: | Height: | Size: 134 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="crosshair_blue_image"
|
||||
imageFile="@assetFile=crosshair_blue.png"/>
|
||||
BIN
Templates/BaseGame/game/data/DamageModel/images/damageBottom.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="damageBottom_image"
|
||||
imageFile="@assetFile=damageBottom.png"/>
|
||||
BIN
Templates/BaseGame/game/data/DamageModel/images/damageFront.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="damageFront_image"
|
||||
imageFile="@assetFile=damageFront.png"/>
|
||||
BIN
Templates/BaseGame/game/data/DamageModel/images/damageLeft.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="damageLeft_image"
|
||||
imageFile="@assetFile=damageLeft.png"/>
|
||||
BIN
Templates/BaseGame/game/data/DamageModel/images/damageRight.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="damageRight_image"
|
||||
imageFile="@assetFile=damageRight.png"/>
|
||||
BIN
Templates/BaseGame/game/data/DamageModel/images/damageTop.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="damageTop_image"
|
||||
imageFile="@assetFile=damageTop.png"/>
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// PlayGui is the main TSControl through which the game is viewed.
|
||||
// The PlayGui also contains the hud controls.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function DamageModel::Playgui_onWake(%this)
|
||||
{
|
||||
Canvas.pushDialog(DamageGuiOverlay);
|
||||
}
|
||||
|
||||
function DamageModel::Playgui_onSleep(%this)
|
||||
{
|
||||
Canvas.popDialog(DamageGuiOverlay);
|
||||
}
|
||||
|
||||
function DamageModel::Playgui_clearHud( %this )
|
||||
{
|
||||
Canvas.popDialog(DamageGuiOverlay);
|
||||
}
|
||||
|
||||
function clientCmdSetDamageDirection(%direction)
|
||||
{
|
||||
%ctrl = DamageHUD.findObjectByInternalName("damage[" @ %direction@"]");
|
||||
if (isObject(%ctrl))
|
||||
{
|
||||
// Show the indicator, and schedule an event to hide it again
|
||||
cancelAll(%ctrl);
|
||||
%ctrl.setVisible(true);
|
||||
%ctrl.schedule(1500, setVisible, false);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
function PlayerData::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
|
||||
{
|
||||
if (!isObject(%obj) || %obj.getDamageState() !$= "Enabled" || !%damage)
|
||||
return;
|
||||
|
||||
%rootObj = %obj;
|
||||
if (%obj.healthFromMount)
|
||||
%rootObj = findRootObject(%obj);
|
||||
|
||||
%rootObj.applyDamage(%damage);
|
||||
%this.onDamage(%rootObj, %damage);
|
||||
|
||||
%this.setDamageDirection(%rootObj, %sourceObject, %position);
|
||||
|
||||
// Deal with client callbacks here because we don't have this
|
||||
// information in the onDamage or onDisable methods
|
||||
%client = %rootObj.client;
|
||||
%sourceClient = %sourceObject ? %sourceObject.client : 0;
|
||||
|
||||
%location = "Body";
|
||||
if (isObject(%client))
|
||||
{
|
||||
if (%rootObj.getDamageState() !$= "Enabled")
|
||||
{
|
||||
callGamemodeFunction("onDeath", %client, %sourceObject, %sourceClient, %damageType, %location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function PlayerData::onDamage(%this, %obj, %delta)
|
||||
{
|
||||
Parent::onDamage(%this, %obj, %delta);
|
||||
|
||||
// This method is invoked by the ShapeBase code whenever the
|
||||
// object's damage level changes.
|
||||
if (%delta > 0 && %obj.getDamageState() !$= "Destroyed")
|
||||
{
|
||||
// If the pain is excessive, let's hear about it.
|
||||
if (%delta > 10)
|
||||
%obj.playPain();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// "Universal" script methods for projectile damage handling. You can easily
|
||||
// override these support functions with an equivalent namespace method if your
|
||||
// weapon needs a unique solution for applying damage.
|
||||
|
||||
function ProjectileData::onCollision(%data, %proj, %col, %fade, %pos, %normal)
|
||||
{
|
||||
//echo("ProjectileData::onCollision("@%data.getName()@", "@%proj@", "@%col.getClassName()@", "@%fade@", "@%pos@", "@%normal@")");
|
||||
|
||||
// Apply damage to the object all shape base objects
|
||||
if (%data.directDamage > 0)
|
||||
{
|
||||
if (%col.getType() & ($TypeMasks::ShapeBaseObjectType))
|
||||
%col.damage(%proj, %pos, %data.directDamage, %data.damageType);
|
||||
}
|
||||
}
|
||||
|
||||
function ProjectileData::onExplode(%data, %proj, %position, %mod)
|
||||
{
|
||||
//echo("ProjectileData::onExplode("@%data.getName()@", "@%proj@", "@%position@", "@%mod@")");
|
||||
|
||||
// Damage objects within the projectiles damage radius
|
||||
if (%data.damageRadius > 0)
|
||||
radiusDamage(%proj, %position, %data.damageRadius, %data.radiusDamage, %data.damageType, %data.areaImpulse);
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Support function which applies damage to objects within the radius of
|
||||
// some effect, usually an explosion. This function will also optionally
|
||||
// apply an impulse to each object.
|
||||
|
||||
function radiusDamage(%sourceObject, %position, %radius, %damage, %damageType, %impulse)
|
||||
{
|
||||
// Use the container system to iterate through all the objects
|
||||
// within our explosion radius. We'll apply damage to all ShapeBase
|
||||
// objects.
|
||||
InitContainerRadiusSearch(%position, %radius, $TypeMasks::ShapeBaseObjectType | $TypeMasks::DynamicShapeObjectType);
|
||||
|
||||
%halfRadius = %radius / 2;
|
||||
while ((%targetObject = containerSearchNext()) != 0)
|
||||
{
|
||||
// Calculate how much exposure the current object has to
|
||||
// the explosive force. The object types listed are objects
|
||||
// that will block an explosion. If the object is totally blocked,
|
||||
// then no damage is applied.
|
||||
%coverage = calcExplosionCoverage(%position, %targetObject,
|
||||
$TypeMasks::InteriorObjectType |
|
||||
$TypeMasks::TerrainObjectType |
|
||||
$TypeMasks::ForceFieldObjectType |
|
||||
$TypeMasks::StaticShapeObjectType |
|
||||
$TypeMasks::VehicleObjectType);
|
||||
if (%coverage == 0)
|
||||
continue;
|
||||
|
||||
// Radius distance subtracts out the length of smallest bounding
|
||||
// box axis to return an appriximate distance to the edge of the
|
||||
// object's bounds, as opposed to the distance to it's center.
|
||||
%dist = containerSearchCurrRadiusDist();
|
||||
|
||||
// Calculate a distance scale for the damage and the impulse.
|
||||
// Full damage is applied to anything less than half the radius away,
|
||||
// linear scale from there.
|
||||
%distScale = (%dist < %halfRadius)? 1.0 : 1.0 - ((%dist - %halfRadius) / %halfRadius);
|
||||
%distScale = mClamp(%distScale,0.0,1.0);
|
||||
|
||||
// Apply the damage
|
||||
%targetObject.damage(%sourceObject, %position, %damage * %coverage * %distScale, %damageType);
|
||||
|
||||
// Apply the impulse
|
||||
if (%impulse)
|
||||
{
|
||||
%impulseVec = VectorSub(%targetObject.getWorldBoxCenter(), %position);
|
||||
%impulseVec = VectorNormalize(%impulseVec);
|
||||
%impulseVec = VectorScale(%impulseVec, %impulse * %distScale);
|
||||
%targetObject.applyImpulse(%position, %impulseVec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,289 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// This file contains ShapeBase methods used by all the derived classes
|
||||
$DeathDuration = 10000;
|
||||
$CorpseTimeoutValue = 20000;
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShapeBase object
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// A raycast helper function to keep from having to duplicate code everytime
|
||||
// that a raycast is needed.
|
||||
// %this = the object doing the cast, usually a player
|
||||
// %range = range to search
|
||||
// %mask = what to look for
|
||||
|
||||
function ShapeBase::doRaycast(%this, %range, %mask)
|
||||
{
|
||||
// get the eye vector and eye transform of the player
|
||||
%eyeVec = %this.getEyeVector();
|
||||
%eyeTrans = %this.getEyeTransform();
|
||||
|
||||
// extract the position of the player's camera from the eye transform (first 3 words)
|
||||
%eyePos = getWord(%eyeTrans, 0) SPC getWord(%eyeTrans, 1) SPC getWord(%eyeTrans, 2);
|
||||
|
||||
// normalize the eye vector
|
||||
%nEyeVec = VectorNormalize(%eyeVec);
|
||||
|
||||
// scale (lengthen) the normalized eye vector according to the search range
|
||||
%scEyeVec = VectorScale(%nEyeVec, %range);
|
||||
|
||||
// add the scaled & normalized eye vector to the position of the camera
|
||||
%eyeEnd = VectorAdd(%eyePos, %scEyeVec);
|
||||
|
||||
// see if anything gets hit
|
||||
%searchResult = containerRayCast(%eyePos, %eyeEnd, %mask, %this);
|
||||
|
||||
return %searchResult;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function ShapeBase::damage(%this, %sourceObject, %position, %damage, %damageType)
|
||||
{
|
||||
// All damage applied by one object to another should go through this method.
|
||||
// This function is provided to allow objects some chance of overriding or
|
||||
// processing damage values and types. As opposed to having weapons call
|
||||
// ShapeBase::applyDamage directly. Damage is redirected to the datablock,
|
||||
// this is standard procedure for many built in callbacks.
|
||||
|
||||
if (isObject(%this))
|
||||
%this.getDataBlock().damage(%this, %sourceObject, %position, %damage, %damageType);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function ShapeBase::setDamageDt(%this, %damageAmount, %damageType)
|
||||
{
|
||||
// This function is used to apply damage over time. The damage is applied
|
||||
// at a fixed rate (50 ms). Damage could be applied over time using the
|
||||
// built in ShapBase C++ repair functions (using a neg. repair), but this
|
||||
// has the advantage of going through the normal script channels.
|
||||
|
||||
if (%this.getState() !$= "Dead")
|
||||
{
|
||||
%this.damage(0, "0 0 0", %damageAmount, %damageType);
|
||||
%this.damageSchedule = %this.schedule(50, "setDamageDt", %damageAmount, %damageType);
|
||||
}
|
||||
else
|
||||
%this.damageSchedule = "";
|
||||
}
|
||||
|
||||
function ShapeBase::clearDamageDt(%this)
|
||||
{
|
||||
if (%this.damageSchedule !$= "")
|
||||
{
|
||||
cancel(%this.damageSchedule);
|
||||
%this.damageSchedule = "";
|
||||
}
|
||||
}
|
||||
|
||||
function GameBase::damage(%this, %sourceObject, %position, %damage, %damageType)
|
||||
{
|
||||
// All damage applied by one object to another should go through this method.
|
||||
// This function is provided to allow objects some chance of overriding or
|
||||
// processing damage values and types. As opposed to having weapons call
|
||||
// ShapeBase::applyDamage directly. Damage is redirected to the datablock,
|
||||
// this is standard procedure for many built in callbacks.
|
||||
|
||||
%datablock = %this.getDataBlock();
|
||||
if ( isObject( %datablock ) )
|
||||
%datablock.damage(%this, %sourceObject, %position, %damage, %damageType);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ShapeBase datablock
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function GameBaseData::damage(%this, %obj, %source, %position, %amount, %damageType)
|
||||
{
|
||||
// Ignore damage by default. This empty method is here to
|
||||
// avoid console warnings.
|
||||
}
|
||||
|
||||
function ShapeBaseData::onAdd(%this, %obj)
|
||||
{
|
||||
%obj.setDamageState("Enabled");
|
||||
}
|
||||
|
||||
function ShapeBaseData::setDamageDirection(%this, %obj, %sourceObject, %damagePos)
|
||||
{
|
||||
%client = (%obj.client) ? %obj.client : %obj.getControllingClient();
|
||||
if (!%client) return;
|
||||
|
||||
if (%damagePos $= "" && isObject(%sourceObject))
|
||||
{
|
||||
if (%sourceObject.isField(initialPosition))
|
||||
{
|
||||
// Projectiles have this field set to the muzzle point of
|
||||
// the firing weapon at the time the projectile was created.
|
||||
// This gives a damage direction towards the firing object,
|
||||
// turret, vehicle, etc. Bullets and weapon fired grenades
|
||||
// are examples of projectiles.
|
||||
%damagePos = %sourceObject.initialPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Other objects that cause damage, such as mines, use their own
|
||||
// location as the damage position. This gives a damage direction
|
||||
// towards the explosive origin rather than the person that lay the
|
||||
// explosives.
|
||||
%damagePos = %sourceObject.getPosition();
|
||||
}
|
||||
}
|
||||
|
||||
// Rotate damage vector into object space
|
||||
%damageVec = VectorSub(%damagePos, %obj.getWorldBoxCenter());
|
||||
%damageVec = VectorNormalize(%damageVec);
|
||||
%damageVec = MatrixMulVector(%client.getCameraObject().getInverseTransform(), %damageVec);
|
||||
|
||||
// Determine largest component of damage vector to get direction
|
||||
%vecComponents = -%damageVec.x SPC %damageVec.x SPC -%damageVec.y SPC %damageVec.y SPC -%damageVec.z SPC %damageVec.z;
|
||||
%vecDirections = "Left" SPC "Right" SPC "Bottom" SPC "Front" SPC "Bottom" SPC "Top";
|
||||
|
||||
%max = -1;
|
||||
for (%i = 0; %i < 6; %i++)
|
||||
{
|
||||
%value = getWord(%vecComponents, %i);
|
||||
if (%value > %max)
|
||||
{
|
||||
%max = %value;
|
||||
%damageDir = getWord(%vecDirections, %i);
|
||||
}
|
||||
}
|
||||
commandToClient(%client, 'setDamageDirection', %damageDir);
|
||||
}
|
||||
|
||||
|
||||
function ShapeBaseData::onCollision(%this, %obj, %collObj, %vec, %len )
|
||||
{
|
||||
if (!isObject(%obj) || %obj.getDamageState() $= "Destroyed")
|
||||
return;
|
||||
|
||||
//echo(%this SPC %obj SPC %collObj SPC %vec SPC %len );
|
||||
%dmgPos = VectorSub(%obj.getPosition(), %vec);
|
||||
%dmgAmt = %len/%this.minImpactSpeed * %this.collisionMul;
|
||||
|
||||
%this.damage(%obj, %collObj, %dmgPos, %dmgAmt, "impact");
|
||||
}
|
||||
|
||||
function ShapeBaseData::onImpact(%this, %obj, %collObj, %vec, %len )
|
||||
{
|
||||
if (!isObject(%obj) || %obj.getDamageState() $= "Destroyed")
|
||||
return;
|
||||
|
||||
//echo(%this SPC %obj SPC %collObj SPC %vec SPC %len );
|
||||
%dmgPos = VectorSub(%obj.getPosition(), %vec);
|
||||
%dmgAmt = %len/%this.minImpactSpeed * %this.impactMul;
|
||||
|
||||
%this.damage(%obj, %collObj, %dmgPos, %dmgAmt, "impact");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function ShapeBaseData::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
|
||||
{
|
||||
if (!isObject(%obj) || %obj.getDamageState() $= "Destroyed" || !%damage)
|
||||
return;
|
||||
|
||||
%rootObj = %obj;
|
||||
if (%obj.healthFromMount)
|
||||
%rootObj = findRootObject(%obj);
|
||||
|
||||
%rootObj.applyDamage(%damage);
|
||||
%this.onDamage(%rootObj, %damage);
|
||||
|
||||
%this.setDamageDirection(%obj, %sourceObject, %position);
|
||||
|
||||
// Deal with client callbacks here because we don't have this
|
||||
// information in the onDamage or onDisable methods
|
||||
%client = %rootObj.client;
|
||||
%sourceClient = %sourceObject ? %sourceObject.client : 0;
|
||||
|
||||
if (isObject(%client))
|
||||
{
|
||||
if (%obj.getDamageState() $= "Destroyed")
|
||||
{
|
||||
callGamemodeFunction("onDeath", %client, %sourceObject, %sourceClient, %damageType, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ShapeBaseData::onDamage(%this, %obj, %delta)
|
||||
{
|
||||
// This method is invoked by the ShapeBase code whenever the
|
||||
// object's damage level changes.
|
||||
if (%delta > 0 && %obj.getDamageState() !$= "Destroyed")
|
||||
{
|
||||
// Apply a damage flash
|
||||
%obj.setDamageFlash(1);
|
||||
|
||||
//total raw damage allowed to be stored
|
||||
if (%this.maxDamage> 1.0 && %obj.getDamageLevel() >= %this.maxDamage)
|
||||
%obj.setDamageState("Destroyed");
|
||||
//damage before we are considered destroyed (can animate via "damage" thread)
|
||||
else if (%this.destroyedLevel> 1.0 && %obj.getDamageLevel() >= %this.destroyedLevel)
|
||||
%obj.setDamageState("Destroyed");
|
||||
//optional additional disabled level
|
||||
else if (%this.disabledLevel> 1.0 && %obj.getDamageLevel() >= %this.disabledLevel)
|
||||
%obj.setDamageState("Disabled");
|
||||
}
|
||||
}
|
||||
|
||||
function ShapeBaseData::onDisabled(%this, %obj, %state)
|
||||
{
|
||||
// Release the weapon triggers
|
||||
for (%slot = 0; %slot<4; %slot++)
|
||||
{
|
||||
if (%obj.getMountedImage(%slot))
|
||||
%obj.setImageTrigger(%slot, false);
|
||||
}
|
||||
}
|
||||
|
||||
function ShapeBaseData::onDestroyed(%this, %obj, %state)
|
||||
{
|
||||
// Release the weapon triggers
|
||||
for (%slot = 0; %slot<4; %slot++)
|
||||
{
|
||||
if (%obj.getMountedImage(%slot))
|
||||
%obj.setImageTrigger(%slot, false);
|
||||
}
|
||||
|
||||
if (%obj.client)
|
||||
{
|
||||
%obj.client.player = 0;
|
||||
%obj.client.schedule($DeathDuration, "spawnControlObject");
|
||||
}
|
||||
// Schedule corpse removal. Just keeping the place clean.
|
||||
%obj.schedule($CorpseTimeoutValue - 1000, "startFade", 1000, 0, true);
|
||||
%obj.schedule($CorpseTimeoutValue, "delete");
|
||||
%obj.schedule($CorpseTimeoutValue,"blowUp");
|
||||
}
|
||||
|
||||
function ShapeBaseData::onRemove(%this, %obj)
|
||||
{
|
||||
if (isMethod(Parent, "onRemove"))
|
||||
Parent::onRemove(%this, %obj);
|
||||
|
||||
deleteMountchain(%obj);
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
function findRootObject(%obj)
|
||||
{ if (!isObject(%obj)) return -1;
|
||||
%ret = %obj;
|
||||
if (isObject(%obj.getObjectMount()))
|
||||
%ret = findRootObject(%obj.getObjectMount());
|
||||
return %ret;
|
||||
}
|
||||
|
||||
function deleteMountchain(%obj)
|
||||
{
|
||||
if (!isObject(%obj)) return;
|
||||
%count = %obj.getMountedObjectCount();
|
||||
for (%i=%count; %i>=0; %i--)
|
||||
{
|
||||
if (isObject(%obj.getMountedObject(%i)))
|
||||
deleteMountchain(%obj.getMountedObject(%i));
|
||||
}
|
||||
if (%obj.isMounted())
|
||||
%obj.delete();
|
||||
}
|
||||
|
||||
|
||||
function setMountChainDamage(%obj,%damagePercent)
|
||||
{
|
||||
if (!isObject(%obj)) return;
|
||||
%count = %obj.getMountedObjectCount();
|
||||
for (%i=0; %i<%count; %i++)
|
||||
{
|
||||
if (isObject(%obj.getMountedObject(%i)))
|
||||
setMountChainDamage(%obj.getMountedObject(%i),%damagePercent);
|
||||
}
|
||||
|
||||
%obj.setDamageLevel(%obj.getMaxDamage()*%damagePercent);
|
||||
}
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Parenting is in place for WheeledVehicleData to VehicleData. This should
|
||||
// make it easier for people to simply drop in new (generic) vehicles. All that
|
||||
// the user needs to create is a set of datablocks for the new wheeled vehicle
|
||||
// to use. This means that no (or little) scripting should be necessary.
|
||||
|
||||
// Special, or unique vehicles however will still require some scripting. They
|
||||
// may need to override the onAdd() function in order to mount weapons,
|
||||
// differing tires/springs, etc., almost everything else is taken care of in the
|
||||
// WheeledVehicleData and VehicleData methods. This helps us by not having to
|
||||
// duplicate the same code for every new vehicle.
|
||||
|
||||
// In theory this would work for HoverVehicles and FlyingVehicles also, but
|
||||
// hasn't been tested or fully implemented for those classes -- yet.
|
||||
|
||||
function VehicleData::onAdd(%this, %obj)
|
||||
{
|
||||
%obj.setRechargeRate(%this.rechargeRate);
|
||||
%obj.setEnergyLevel(%this.MaxEnergy);
|
||||
%obj.setRepairRate(0);
|
||||
|
||||
if (%obj.mountable || %obj.mountable $= "")
|
||||
%this.isMountable(%obj, true);
|
||||
else
|
||||
%this.isMountable(%obj, false);
|
||||
|
||||
if (%this.nameTag !$= "")
|
||||
%obj.setShapeName(%this.nameTag);
|
||||
}
|
||||
|
||||
function VehicleData::onDestroyed(%this, %obj, %state)
|
||||
{
|
||||
//echo("\c4VehicleData::onRemove("@ %this.getName() @", "@ %obj.getClassName() @")");
|
||||
// if there are passengers/driver, kick them out
|
||||
if (!%this.killPassengers)
|
||||
{
|
||||
for(%i = 0; %i < %obj.getMountedObjectCount(); %i++)
|
||||
{
|
||||
if (%obj.getMountedObject(%i))
|
||||
{
|
||||
%passenger = %obj.getMountedObject(%i);
|
||||
if (%passenger.isMemberOfClass("Player"))
|
||||
%passenger.getDataBlock().doDismount(%passenger, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Parent::onDestroyed(%this, %obj, %state);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Vehicle player mounting and dismounting
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function VehicleData::isMountable(%this, %obj, %val)
|
||||
{
|
||||
%obj.mountable = %val;
|
||||
}
|
||||
|
||||
function VehicleData::mountPlayer(%this, %vehicle, %player)
|
||||
{
|
||||
//echo("\c4VehicleData::mountPlayer("@ %this.getName() @", "@ %vehicle @", "@ %player.client.nameBase @")");
|
||||
|
||||
if (isObject(%vehicle) && %vehicle.getDamageState() !$= "Destroyed")
|
||||
{
|
||||
%player.startFade(1000, 0, true);
|
||||
%this.schedule(1000, "setMountVehicle", %vehicle, %player);
|
||||
%player.schedule(1500, "startFade", 1000, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
function VehicleData::setMountVehicle(%this, %vehicle, %player)
|
||||
{
|
||||
//echo("\c4VehicleData::setMountVehicle("@ %this.getName() @", "@ %vehicle @", "@ %player.client.nameBase @")");
|
||||
|
||||
if (isObject(%vehicle) && %vehicle.getDamageState() !$= "Destroyed")
|
||||
{
|
||||
%node = %this.findEmptySeat(%vehicle, %player);
|
||||
if (%node >= 0)
|
||||
{
|
||||
//echo("\c4Mount Node: "@ %node);
|
||||
%vehicle.mountObject(%player, %node);
|
||||
//%player.playAudio(0, MountVehicleSound);
|
||||
%player.mVehicle = %vehicle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function VehicleData::findEmptySeat(%this, %vehicle, %player)
|
||||
{
|
||||
//echo("\c4This vehicle has "@ %this.numMountPoints @" mount points.");
|
||||
|
||||
for (%i = 0; %i < %this.numMountPoints; %i++)
|
||||
{
|
||||
%node = %vehicle.getMountNodeObject(%i);
|
||||
if (%node == 0)
|
||||
return %i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function VehicleData::switchSeats(%this, %vehicle, %player)
|
||||
{
|
||||
for (%i = 0; %i < %this.numMountPoints; %i++)
|
||||
{
|
||||
%node = %vehicle.getMountNodeObject(%i);
|
||||
if (%node == %player || %node > 0)
|
||||
continue;
|
||||
|
||||
if (%node == 0)
|
||||
return %i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -0,0 +1,645 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// This file contains Weapon and Ammo Class/"namespace" helper methods as well
|
||||
// as hooks into the inventory system. These functions are not attached to a
|
||||
// specific C++ class or datablock, but define a set of methods which are part
|
||||
// of dynamic namespaces "class". The Items include these namespaces into their
|
||||
// scope using the ItemData and ItemImageData "className" variable.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// All ShapeBase images are mounted into one of 8 slots on a shape. This weapon
|
||||
// system assumes all primary weapons are mounted into this specified slot:
|
||||
$WeaponSlot = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Weapon Class
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function Weapon::onUse(%data, %obj)
|
||||
{
|
||||
// Default behavior for all weapons is to mount it into the object's weapon
|
||||
// slot, which is currently assumed to be slot 0
|
||||
if (%obj.getMountedImage($WeaponSlot) != %data.image.getId())
|
||||
{
|
||||
serverPlay3D(WeaponUseSound, %obj.getTransform());
|
||||
|
||||
%obj.mountImage(%data.image, $WeaponSlot);
|
||||
if (%obj.client)
|
||||
{
|
||||
if (%data.description !$= "")
|
||||
messageClient(%obj.client, 'MsgWeaponUsed', '\c0%1 selected.', %data.description);
|
||||
else
|
||||
messageClient(%obj.client, 'MsgWeaponUsed', '\c0Weapon selected');
|
||||
}
|
||||
|
||||
// If this is a Player class object then allow the weapon to modify allowed poses
|
||||
if (%obj.isInNamespaceHierarchy("Player"))
|
||||
{
|
||||
// Start by allowing everything
|
||||
%obj.allowAllPoses();
|
||||
|
||||
// Now see what isn't allowed by the weapon
|
||||
|
||||
%image = %data.image;
|
||||
|
||||
if (%image.jumpingDisallowed)
|
||||
%obj.allowJumping(false);
|
||||
|
||||
if (%image.jetJumpingDisallowed)
|
||||
%obj.allowJetJumping(false);
|
||||
|
||||
if (%image.sprintDisallowed)
|
||||
%obj.allowSprinting(false);
|
||||
|
||||
if (%image.crouchDisallowed)
|
||||
%obj.allowCrouching(false);
|
||||
|
||||
if (%image.proneDisallowed)
|
||||
%obj.allowProne(false);
|
||||
|
||||
if (%image.swimmingDisallowed)
|
||||
%obj.allowSwimming(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Weapon::onPickup(%this, %obj, %shape, %amount)
|
||||
{
|
||||
// The parent Item method performs the actual pickup.
|
||||
// For player's we automatically use the weapon if the
|
||||
// player does not already have one in hand.
|
||||
if (Parent::onPickup(%this, %obj, %shape, %amount))
|
||||
{
|
||||
serverPlay3D(WeaponPickupSound, %shape.getTransform());
|
||||
if (%shape.getClassName() $= "Player" && %shape.getMountedImage($WeaponSlot) == 0)
|
||||
%shape.use(%this);
|
||||
}
|
||||
}
|
||||
|
||||
function Weapon::onInventory(%this, %obj, %amount)
|
||||
{
|
||||
// Weapon inventory has changed, make sure there are no weapons
|
||||
// of this type mounted if there are none left in inventory.
|
||||
if (!%amount && (%slot = %obj.getMountSlot(%this.image)) != -1)
|
||||
%obj.unmountImage(%slot);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Weapon Image Class
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function WeaponImage::onMount(%this, %obj, %slot)
|
||||
{
|
||||
// Images assume a false ammo state on load. We need to
|
||||
// set the state according to the current inventory.
|
||||
if(%this.isField("clip"))
|
||||
{
|
||||
// Use the clip system for this weapon. Check if the player already has
|
||||
// some ammo in a clip.
|
||||
if (%obj.getInventory(%this.ammo))
|
||||
{
|
||||
%obj.setImageAmmo(%slot, true);
|
||||
%currentAmmo = %obj.getInventory(%this.ammo);
|
||||
}
|
||||
else if(%obj.getInventory(%this.clip) > 0)
|
||||
{
|
||||
// Fill the weapon up from the first clip
|
||||
%obj.setInventory(%this.ammo, %this.ammo.maxInventory);
|
||||
%obj.setImageAmmo(%slot, true);
|
||||
|
||||
// Add any spare ammo that may be "in the player's pocket"
|
||||
%currentAmmo = %this.ammo.maxInventory;
|
||||
%amountInClips += %obj.getFieldValue( "remaining" @ %this.ammo.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
%currentAmmo = 0 + %obj.getFieldValue( "remaining" @ %this.ammo.getName());
|
||||
}
|
||||
|
||||
%amountInClips = %obj.getInventory(%this.clip);
|
||||
%amountInClips *= %this.ammo.maxInventory;
|
||||
|
||||
if (%obj.client !$= "" && !%obj.isAiControlled)
|
||||
%obj.client.RefreshWeaponHud(%currentAmmo, %this.item.previewImage, %this.item.reticle, %this.item.zoomReticle, %amountInClips);
|
||||
}
|
||||
else if(%this.ammo !$= "")
|
||||
{
|
||||
// Use the ammo pool system for this weapon
|
||||
if (%obj.getInventory(%this.ammo))
|
||||
{
|
||||
%obj.setImageAmmo(%slot, true);
|
||||
%currentAmmo = %obj.getInventory(%this.ammo);
|
||||
}
|
||||
else
|
||||
%currentAmmo = 0;
|
||||
|
||||
if (%obj.client !$= "" && !%obj.isAiControlled)
|
||||
%obj.client.RefreshWeaponHud( 1, %this.item.previewImage, %this.item.reticle, %this.item.zoomReticle, %currentAmmo );
|
||||
}
|
||||
}
|
||||
|
||||
function WeaponImage::onUnmount(%this, %obj, %slot)
|
||||
{
|
||||
if (%obj.client !$= "" && !%obj.isAiControlled)
|
||||
%obj.client.RefreshWeaponHud(0, "", "");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// A "generic" weaponimage onFire handler for most weapons. Can be overridden
|
||||
// with an appropriate namespace method for any weapon that requires a custom
|
||||
// firing solution.
|
||||
|
||||
// projectileSpread is a dynamic property declared in the weaponImage datablock
|
||||
// for those weapons in which bullet skew is desired. Must be greater than 0,
|
||||
// otherwise the projectile goes straight ahead as normal. lower values give
|
||||
// greater accuracy, higher values increase the spread pattern.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function WeaponImage::onFire(%this, %obj, %slot)
|
||||
{
|
||||
//echo("\c4WeaponImage::onFire( "@%this.getName()@", "@%obj.client.nameBase@", "@%slot@" )");
|
||||
|
||||
// Make sure we have valid data
|
||||
if (!isObject(%this.projectile))
|
||||
{
|
||||
error("WeaponImage::onFire() - Invalid projectile datablock");
|
||||
return;
|
||||
}
|
||||
|
||||
// Decrement inventory ammo. The image's ammo state is updated
|
||||
// automatically by the ammo inventory hooks.
|
||||
if ( !%this.infiniteAmmo )
|
||||
%obj.decInventory(%this.ammo, 1);
|
||||
|
||||
// Get the player's velocity, we'll then add it to that of the projectile
|
||||
%objectVelocity = %obj.getVelocity();
|
||||
|
||||
%numProjectiles = %this.projectileNum;
|
||||
if (%numProjectiles == 0)
|
||||
%numProjectiles = 1;
|
||||
|
||||
for (%i = 0; %i < %numProjectiles; %i++)
|
||||
{
|
||||
if (%this.projectileSpread)
|
||||
{
|
||||
// We'll need to "skew" this projectile a little bit. We start by
|
||||
// getting the straight ahead aiming point of the gun
|
||||
%vec = %obj.getMuzzleVector(%slot);
|
||||
|
||||
// Then we'll create a spread matrix by randomly generating x, y, and z
|
||||
// points in a circle
|
||||
%matrix = "";
|
||||
for(%j = 0; %j < 3; %j++)
|
||||
%matrix = %matrix @ (getRandom() - 0.5) * 2 * 3.1415926 * %this.projectileSpread @ " ";
|
||||
%mat = MatrixCreateFromEuler(%matrix);
|
||||
|
||||
// Which we'll use to alter the projectile's initial vector with
|
||||
%muzzleVector = MatrixMulVector(%mat, %vec);
|
||||
%muzzleVector = VectorScale(VectorNormalize(%muzzleVector), %this.projectileSpread *2);
|
||||
%muzzleVector = VectorAdd(%muzzleVector, %vec);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Weapon projectile doesn't have a spread factor so we fire it using
|
||||
// the straight ahead aiming point of the gun
|
||||
%muzzleVector = %obj.getMuzzleVector(%slot);
|
||||
}
|
||||
|
||||
// Add player's velocity
|
||||
%muzzleVelocity = VectorAdd(
|
||||
VectorScale(%muzzleVector, %this.projectile.muzzleVelocity),
|
||||
VectorScale(%objectVelocity, %this.projectile.velInheritFactor));
|
||||
|
||||
// Create the projectile object
|
||||
%p = new (%this.projectileType)()
|
||||
{
|
||||
dataBlock = %this.projectile;
|
||||
initialVelocity = %muzzleVelocity;
|
||||
initialPosition = %obj.getMuzzlePoint(%slot);
|
||||
sourceObject = %obj;
|
||||
sourceSlot = %slot;
|
||||
client = %obj.client;
|
||||
sourceClass = %obj.getClassName();
|
||||
};
|
||||
MissionCleanup.add(%p);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// A "generic" weaponimage onAltFire handler for most weapons. Can be
|
||||
// overridden with an appropriate namespace method for any weapon that requires
|
||||
// a custom firing solution.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function WeaponImage::onAltFire(%this, %obj, %slot)
|
||||
{
|
||||
//echo("\c4WeaponImage::onAltFire("@%this.getName()@", "@%obj.client.nameBase@", "@%slot@")");
|
||||
|
||||
// Decrement inventory ammo. The image's ammo state is updated
|
||||
// automatically by the ammo inventory hooks.
|
||||
%obj.decInventory(%this.ammo, 1);
|
||||
|
||||
// Get the player's velocity, we'll then add it to that of the projectile
|
||||
%objectVelocity = %obj.getVelocity();
|
||||
|
||||
%numProjectiles = %this.altProjectileNum;
|
||||
if (%numProjectiles == 0)
|
||||
%numProjectiles = 1;
|
||||
|
||||
for (%i = 0; %i < %numProjectiles; %i++)
|
||||
{
|
||||
if (%this.altProjectileSpread)
|
||||
{
|
||||
// We'll need to "skew" this projectile a little bit. We start by
|
||||
// getting the straight ahead aiming point of the gun
|
||||
%vec = %obj.getMuzzleVector(%slot);
|
||||
|
||||
// Then we'll create a spread matrix by randomly generating x, y, and z
|
||||
// points in a circle
|
||||
%matrix = "";
|
||||
for(%i = 0; %i < 3; %i++)
|
||||
%matrix = %matrix @ (getRandom() - 0.5) * 2 * 3.1415926 * %this.altProjectileSpread @ " ";
|
||||
%mat = MatrixCreateFromEuler(%matrix);
|
||||
|
||||
// Which we'll use to alter the projectile's initial vector with
|
||||
%muzzleVector = MatrixMulVector(%mat, %vec);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Weapon projectile doesn't have a spread factor so we fire it using
|
||||
// the straight ahead aiming point of the gun.
|
||||
%muzzleVector = %obj.getMuzzleVector(%slot);
|
||||
}
|
||||
|
||||
// Add player's velocity
|
||||
%muzzleVelocity = VectorAdd(
|
||||
VectorScale(%muzzleVector, %this.altProjectile.muzzleVelocity),
|
||||
VectorScale(%objectVelocity, %this.altProjectile.velInheritFactor));
|
||||
|
||||
// Create the projectile object
|
||||
%p = new (%this.projectileType)()
|
||||
{
|
||||
dataBlock = %this.altProjectile;
|
||||
initialVelocity = %muzzleVelocity;
|
||||
initialPosition = %obj.getMuzzlePoint(%slot);
|
||||
sourceObject = %obj;
|
||||
sourceSlot = %slot;
|
||||
client = %obj.client;
|
||||
};
|
||||
MissionCleanup.add(%p);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// A "generic" weaponimage onWetFire handler for most weapons. Can be
|
||||
// overridden with an appropriate namespace method for any weapon that requires
|
||||
// a custom firing solution.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function WeaponImage::onWetFire(%this, %obj, %slot)
|
||||
{
|
||||
//echo("\c4WeaponImage::onWetFire("@%this.getName()@", "@%obj.client.nameBase@", "@%slot@")");
|
||||
|
||||
// Decrement inventory ammo. The image's ammo state is updated
|
||||
// automatically by the ammo inventory hooks.
|
||||
%obj.decInventory(%this.ammo, 1);
|
||||
|
||||
// Get the player's velocity, we'll then add it to that of the projectile
|
||||
%objectVelocity = %obj.getVelocity();
|
||||
|
||||
%numProjectiles = %this.projectileNum;
|
||||
if (%numProjectiles == 0)
|
||||
%numProjectiles = 1;
|
||||
|
||||
for (%i = 0; %i < %numProjectiles; %i++)
|
||||
{
|
||||
if (%this.wetProjectileSpread)
|
||||
{
|
||||
// We'll need to "skew" this projectile a little bit. We start by
|
||||
// getting the straight ahead aiming point of the gun
|
||||
%vec = %obj.getMuzzleVector(%slot);
|
||||
|
||||
// Then we'll create a spread matrix by randomly generating x, y, and z
|
||||
// points in a circle
|
||||
%matrix = "";
|
||||
for(%j = 0; %j < 3; %j++)
|
||||
%matrix = %matrix @ (getRandom() - 0.5) * 2 * 3.1415926 * %this.wetProjectileSpread @ " ";
|
||||
%mat = MatrixCreateFromEuler(%matrix);
|
||||
|
||||
// Which we'll use to alter the projectile's initial vector with
|
||||
%muzzleVector = MatrixMulVector(%mat, %vec);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Weapon projectile doesn't have a spread factor so we fire it using
|
||||
// the straight ahead aiming point of the gun.
|
||||
%muzzleVector = %obj.getMuzzleVector(%slot);
|
||||
}
|
||||
|
||||
// Add player's velocity
|
||||
%muzzleVelocity = VectorAdd(
|
||||
VectorScale(%muzzleVector, %this.wetProjectile.muzzleVelocity),
|
||||
VectorScale(%objectVelocity, %this.wetProjectile.velInheritFactor));
|
||||
|
||||
// Create the projectile object
|
||||
%p = new (%this.projectileType)()
|
||||
{
|
||||
dataBlock = %this.wetProjectile;
|
||||
initialVelocity = %muzzleVelocity;
|
||||
initialPosition = %obj.getMuzzlePoint(%slot);
|
||||
sourceObject = %obj;
|
||||
sourceSlot = %slot;
|
||||
client = %obj.client;
|
||||
};
|
||||
MissionCleanup.add(%p);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Clip Management
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function WeaponImage::onClipEmpty(%this, %obj, %slot)
|
||||
{
|
||||
//echo("WeaponImage::onClipEmpty: " SPC %this SPC %obj SPC %slot);
|
||||
|
||||
// Attempt to automatically reload. Schedule this so it occurs
|
||||
// outside of the current state that called this method
|
||||
%this.schedule(0, "reloadAmmoClip", %obj, %slot);
|
||||
}
|
||||
|
||||
function WeaponImage::reloadAmmoClip(%this, %obj, %slot)
|
||||
{
|
||||
//echo("WeaponImage::reloadAmmoClip: " SPC %this SPC %obj SPC %slot);
|
||||
|
||||
// Make sure we're indeed the currect image on the given slot
|
||||
if (%this != %obj.getMountedImage(%slot))
|
||||
return;
|
||||
|
||||
if ( %this.isField("clip") )
|
||||
{
|
||||
if (%obj.getInventory(%this.clip) > 0)
|
||||
{
|
||||
%obj.decInventory(%this.clip, 1);
|
||||
%obj.setInventory(%this.ammo, %this.ammo.maxInventory);
|
||||
%obj.setImageAmmo(%slot, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
%amountInPocket = %obj.getFieldValue( "remaining" @ %this.ammo.getName());
|
||||
if ( %amountInPocket )
|
||||
{
|
||||
%obj.setFieldValue( "remaining" @ %this.ammo.getName(), 0);
|
||||
%obj.setInventory( %this.ammo, %amountInPocket );
|
||||
%obj.setImageAmmo( %slot, true );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function WeaponImage::clearAmmoClip( %this, %obj, %slot )
|
||||
{
|
||||
//echo("WeaponImage::clearAmmoClip: " SPC %this SPC %obj SPC %slot);
|
||||
|
||||
// if we're not empty put the remaining bullets from the current clip
|
||||
// in to the player's "pocket".
|
||||
|
||||
if ( %this.isField( "clip" ) )
|
||||
{
|
||||
// Commenting out this line will use a "hard clip" system, where
|
||||
// A player will lose any ammo currently in the gun when reloading.
|
||||
%pocketAmount = %this.stashSpareAmmo( %obj );
|
||||
|
||||
if ( %obj.getInventory( %this.clip ) > 0 || %pocketAmount != 0 )
|
||||
%obj.setImageAmmo(%slot, false);
|
||||
}
|
||||
}
|
||||
function WeaponImage::stashSpareAmmo( %this, %player )
|
||||
{
|
||||
// If the amount in our pocket plus what we are about to add from the clip
|
||||
// Is over a clip, add a clip to inventory and keep the remainder
|
||||
// on the player
|
||||
if (%player.getInventory( %this.ammo ) < %this.ammo.maxInventory )
|
||||
{
|
||||
%nameOfAmmoField = "remaining" @ %this.ammo.getName();
|
||||
|
||||
%amountInPocket = %player.getFieldValue( %nameOfAmmoField );
|
||||
|
||||
%amountInGun = %player.getInventory( %this.ammo );
|
||||
|
||||
%combinedAmmo = %amountInGun + %amountInPocket;
|
||||
|
||||
// Give the player another clip if the amount in our pocket + the
|
||||
// Amount in our gun is over the size of a clip.
|
||||
if ( %combinedAmmo >= %this.ammo.maxInventory )
|
||||
{
|
||||
%player.setFieldValue( %nameOfAmmoField, %combinedAmmo - %this.ammo.maxInventory );
|
||||
%player.incInventory( %this.clip, 1 );
|
||||
}
|
||||
else if ( %player.getInventory(%this.clip) > 0 )// Only put it back in our pocket if we have clips.
|
||||
%player.setFieldValue( %nameOfAmmoField, %combinedAmmo );
|
||||
|
||||
return %player.getFieldValue( %nameOfAmmoField );
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Clip Class
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function AmmoClip::onPickup(%this, %obj, %shape, %amount)
|
||||
{
|
||||
// The parent Item method performs the actual pickup.
|
||||
if (Parent::onPickup(%this, %obj, %shape, %amount))
|
||||
serverPlay3D(AmmoPickupSound, %shape.getTransform());
|
||||
|
||||
// The clip inventory state has changed, we need to update the
|
||||
// current mounted image using this clip to reflect the new state.
|
||||
if ((%image = %shape.getMountedImage($WeaponSlot)) > 0)
|
||||
{
|
||||
// Check if this weapon uses the clip we just picked up and if
|
||||
// there is no ammo.
|
||||
if (%image.isField("clip") && %image.clip.getId() == %this.getId())
|
||||
{
|
||||
%outOfAmmo = !%shape.getImageAmmo($WeaponSlot);
|
||||
|
||||
%currentAmmo = %shape.getInventory(%image.ammo);
|
||||
|
||||
if ( isObject( %image.clip ) )
|
||||
%amountInClips = %shape.getInventory(%image.clip);
|
||||
|
||||
%amountInClips *= %image.ammo.maxInventory;
|
||||
%amountInClips += %obj.getFieldValue( "remaining" @ %this.ammo.getName() );
|
||||
|
||||
%shape.client.setAmmoAmountHud(%currentAmmo, %amountInClips );
|
||||
|
||||
if (%outOfAmmo)
|
||||
{
|
||||
%image.onClipEmpty(%shape, $WeaponSlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Ammmo Class
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function Ammo::onPickup(%this, %obj, %shape, %amount)
|
||||
{
|
||||
// The parent Item method performs the actual pickup.
|
||||
if (Parent::onPickup(%this, %obj, %shape, %amount))
|
||||
serverPlay3D(AmmoPickupSound, %shape.getTransform());
|
||||
}
|
||||
|
||||
function Ammo::onInventory(%this, %obj, %amount)
|
||||
{
|
||||
// The ammo inventory state has changed, we need to update any
|
||||
// mounted images using this ammo to reflect the new state.
|
||||
for (%i = 0; %i < 8; %i++)
|
||||
{
|
||||
if ((%image = %obj.getMountedImage(%i)) > 0)
|
||||
if (isObject(%image.ammo) && %image.ammo.getId() == %this.getId())
|
||||
{
|
||||
%obj.setImageAmmo(%i, %amount != 0);
|
||||
%currentAmmo = %obj.getInventory(%this);
|
||||
|
||||
if (%obj.getClassname() $= "Player")
|
||||
{
|
||||
if ( isObject( %this.clip ) )
|
||||
{
|
||||
%amountInClips = %obj.getInventory(%this.clip);
|
||||
%amountInClips *= %this.maxInventory;
|
||||
%amountInClips += %obj.getFieldValue( "remaining" @ %this.getName() );
|
||||
}
|
||||
else //Is a single fire weapon, like the grenade launcher.
|
||||
{
|
||||
%amountInClips = %currentAmmo;
|
||||
%currentAmmo = 1;
|
||||
}
|
||||
|
||||
if (%obj.client !$= "" && !%obj.isAiControlled)
|
||||
%obj.client.setAmmoAmountHud(%currentAmmo, %amountInClips);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Weapon cycling
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function ShapeBase::clearWeaponCycle(%this)
|
||||
{
|
||||
%this.totalCycledWeapons = 0;
|
||||
}
|
||||
|
||||
function ShapeBase::addToWeaponCycle(%this, %weapon)
|
||||
{
|
||||
%this.cycleWeapon[%this.totalCycledWeapons++ - 1] = %weapon;
|
||||
}
|
||||
|
||||
function ShapeBase::cycleWeapon(%this, %direction)
|
||||
{
|
||||
// Can't cycle what we don't have
|
||||
if (%this.totalCycledWeapons == 0)
|
||||
return;
|
||||
|
||||
// Find out the index of the current weapon, if any (not all
|
||||
// available weapons may be part of the cycle)
|
||||
%currentIndex = -1;
|
||||
if (%this.getMountedImage($WeaponSlot) != 0)
|
||||
{
|
||||
%curWeapon = %this.getMountedImage($WeaponSlot).item.getName();
|
||||
for (%i=0; %i<%this.totalCycledWeapons; %i++)
|
||||
{
|
||||
if (%this.cycleWeapon[%i] $= %curWeapon)
|
||||
{
|
||||
%currentIndex = %i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the next weapon index
|
||||
%nextIndex = 0;
|
||||
%dir = 1;
|
||||
if (%currentIndex != -1)
|
||||
{
|
||||
if (%direction $= "prev")
|
||||
{
|
||||
%dir = -1;
|
||||
%nextIndex = %currentIndex - 1;
|
||||
if (%nextIndex < 0)
|
||||
{
|
||||
// Wrap around to the end
|
||||
%nextIndex = %this.totalCycledWeapons - 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
%nextIndex = %currentIndex + 1;
|
||||
if (%nextIndex >= %this.totalCycledWeapons)
|
||||
{
|
||||
// Wrap back to the beginning
|
||||
%nextIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We now need to check if the next index is a valid weapon. If not,
|
||||
// then continue to cycle to the next weapon, in the appropriate direction,
|
||||
// until one is found. If nothing is found, then do nothing.
|
||||
%found = false;
|
||||
for (%i=0; %i<%this.totalCycledWeapons; %i++)
|
||||
{
|
||||
%weapon = %this.cycleWeapon[%nextIndex];
|
||||
if (%weapon !$= "" && %this.hasInventory(%weapon) && %this.hasAmmo(%weapon))
|
||||
{
|
||||
// We've found out weapon
|
||||
%found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
%nextIndex = %nextIndex + %dir;
|
||||
if (%nextIndex < 0)
|
||||
{
|
||||
%nextIndex = %this.totalCycledWeapons - 1;
|
||||
}
|
||||
else if (%nextIndex >= %this.totalCycledWeapons)
|
||||
{
|
||||
%nextIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (%found)
|
||||
{
|
||||
%this.use(%this.cycleWeapon[%nextIndex]);
|
||||
}
|
||||
}
|
||||
|
|
@ -27,30 +27,9 @@ function initializeAssetBrowser()
|
|||
$AssetBrowser::collectionSetsFile = "tools/assetBrowser/searchCollectionSets.xml";
|
||||
$AssetBrowser::currentImportConfig = "";
|
||||
|
||||
if(!isObject(AssetFilterTypeList))
|
||||
{
|
||||
new ArrayObject(AssetFilterTypeList);
|
||||
if(!isObject(ABAssetTypesList))
|
||||
new ArrayObject(ABAssetTypesList){};
|
||||
|
||||
AssetFilterTypeList.add("All");
|
||||
AssetFilterTypeList.add("ComponentAsset");
|
||||
AssetFilterTypeList.add("CppAsset");
|
||||
AssetFilterTypeList.add("CubemapAsset");
|
||||
AssetFilterTypeList.add("GameObjectAsset");
|
||||
AssetFilterTypeList.add("GUIAsset");
|
||||
AssetFilterTypeList.add("ImageAsset");
|
||||
AssetFilterTypeList.add("LevelAsset");
|
||||
AssetFilterTypeList.add("MaterialAsset");
|
||||
AssetFilterTypeList.add("ParticleAsset");
|
||||
AssetFilterTypeList.add("PostFXAsset");
|
||||
AssetFilterTypeList.add("ScriptAsset");
|
||||
AssetFilterTypeList.add("ShapeAsset");
|
||||
AssetFilterTypeList.add("ShapeAnimationAsset");
|
||||
AssetFilterTypeList.add("SoundAsset");
|
||||
AssetFilterTypeList.add("StateMachineAsset");
|
||||
AssetFilterTypeList.add("TerrainAsset");
|
||||
AssetFilterTypeList.add("TerrainMaterialAsset");
|
||||
}
|
||||
|
||||
exec("./scripts/profiles." @ $TorqueScriptFileExtension);
|
||||
|
||||
exec("./guis/assetBrowser.gui");
|
||||
|
|
@ -90,19 +69,19 @@ function initializeAssetBrowser()
|
|||
exec("./scripts/utils." @ $TorqueScriptFileExtension);
|
||||
|
||||
//Processing for the different asset types
|
||||
exec("./scripts/assetTypes/component." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/genericAsset." @ $TorqueScriptFileExtension);
|
||||
|
||||
exec("./scripts/assetTypes/cpp." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/gameObject." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/gui." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/image." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/level." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/subScene." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/material." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/postFX." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/script." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/shape." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/shapeAnimation." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/sound." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/stateMachine." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/sound." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/cubemap." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/folder." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/assetTypes/terrain." @ $TorqueScriptFileExtension);
|
||||
|
|
|
|||
|
|
@ -1,86 +0,0 @@
|
|||
|
||||
//Builds the preview data of the asset for the Asset Browser
|
||||
function AssetBrowser::build_AssetPreview(%this, %assetDef, %previewData)
|
||||
{
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetPath = "";
|
||||
%previewData.doubleClickCommand = "";
|
||||
|
||||
%previewData.previewImage = "tools/assetBrowser/art/gameObjectIcon";
|
||||
|
||||
%previewData.assetFriendlyName = %assetDef.gameObjectName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = %assetDef.gameObjectName;
|
||||
}
|
||||
|
||||
//Some last-step setup for the creation of the new asset before we do the actual making
|
||||
//This is generally intended to just set up any type-specific fields for creation
|
||||
function AssetBrowser::setupCreateNew_Asset(%this)
|
||||
{
|
||||
}
|
||||
|
||||
//Performs the actual creation of the asset, including loose file copy or generation
|
||||
function AssetBrowser::create_Asset(%this)
|
||||
{
|
||||
}
|
||||
|
||||
//This is a pre-process step to prepare the asset item for import
|
||||
function AssetBrowser::prepareImport_Asset(%this, %assetItem)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//Performs the action of actually importing the asset item
|
||||
function AssetBrowser::import_Asset(%this, %assetDef)
|
||||
{
|
||||
}
|
||||
|
||||
//Editing the asset
|
||||
function AssetBrowser::edit_Asset(%this, %assetDef)
|
||||
{
|
||||
}
|
||||
|
||||
//Duplicates the asset
|
||||
function AssetBrowser::duplicate_Asset(%this, %assetDef, %targetModule)
|
||||
{
|
||||
}
|
||||
|
||||
//Renames the asset
|
||||
function AssetBrowser::rename_Asset(%this, %assetDef, %newAssetName)
|
||||
{
|
||||
}
|
||||
|
||||
//Deletes the asset
|
||||
function AssetBrowser::delete_Asset(%this, %assetDef)
|
||||
{
|
||||
}
|
||||
|
||||
//Moves the asset to a new path/module
|
||||
function AssetBrowser::move_Asset(%this, %assetDef, %destinationFolder)
|
||||
{
|
||||
}
|
||||
|
||||
//Drag and drop action onto a GUI control
|
||||
function AssetBrowser::dragAndDrop_Asset(%this, %assetDef, %dropTarget)
|
||||
{
|
||||
if(!isObject(%dropTarget))
|
||||
return;
|
||||
}
|
||||
|
||||
//Even for when
|
||||
function AssetBrowser::on_AssetEditorDropped(%this, %assetDef, %position)
|
||||
{
|
||||
}
|
||||
|
||||
//Clicking of the button for the asset type inspector field
|
||||
function GuiInspectorType_AssetPtr::onClick( %this, %fieldName )
|
||||
{
|
||||
//Get our data
|
||||
%obj = %this.getInspector().getInspectObject(0);
|
||||
}
|
||||
|
||||
//Drag and droppin onto the asset type inspector field
|
||||
function GuiInspectorType_AssetPtr::onControlDropped( %this, %payload, %position )
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -1,143 +0,0 @@
|
|||
function AssetBrowser::createComponentAsset(%this)
|
||||
{
|
||||
%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%tamlpath = %modulePath @ "/components/" @ %assetName @ ".asset.taml";
|
||||
%scriptPath = %modulePath @ "/components/" @ %assetName @ "." @ $TorqueScriptFileExtension;
|
||||
|
||||
%asset = new ComponentAsset()
|
||||
{
|
||||
AssetName = %assetName;
|
||||
versionId = 1;
|
||||
componentName = %assetName;
|
||||
componentClass = AssetBrowser.newAssetSettings.parentClass;
|
||||
friendlyName = AssetBrowser.newAssetSettings.friendlyName;
|
||||
componentType = AssetBrowser.newAssetSettings.componentGroup;
|
||||
description = AssetBrowser.newAssetSettings.description;
|
||||
scriptFile = %assetName @ "." @ $TorqueScriptFileExtension;
|
||||
};
|
||||
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
||||
%file = new FileObject();
|
||||
%templateFile = new FileObject();
|
||||
|
||||
%templateCodeFilePath = %this.templateFilesPath @ "componentFile." @ $TorqueScriptFileExtension @ ".template";
|
||||
|
||||
if(%file.openForWrite(%scriptPath) && %templateFile.openForRead(%templateCodeFilePath))
|
||||
{
|
||||
while( !%templateFile.isEOF() )
|
||||
{
|
||||
%line = %templateFile.readline();
|
||||
%line = strreplace( %line, "@@", %assetName );
|
||||
|
||||
%file.writeline(%line);
|
||||
echo(%line);
|
||||
}
|
||||
|
||||
%file.close();
|
||||
%templateFile.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
%file.close();
|
||||
%templateFile.close();
|
||||
|
||||
warnf("CreateComponentAsset - Something went wrong and we couldn't write the Component script file!");
|
||||
}
|
||||
|
||||
Canvas.popDialog(AssetBrowser_newComponentAsset);
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
|
||||
AssetBrowser.refresh();
|
||||
|
||||
return %tamlpath;
|
||||
}
|
||||
|
||||
function AssetBrowser::editComponentAsset(%this, %assetDef)
|
||||
{
|
||||
%scriptFile = %assetDef.scriptFile;
|
||||
|
||||
EditorOpenFileInTorsion(makeFullPath(%scriptFile), 0);
|
||||
}
|
||||
|
||||
function AssetBrowser::duplicateComponentAsset(%this, %assetId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function AssetBrowser::renameComponentAsset(%this, %assetDef, %newAssetId, %originalName, %newName)
|
||||
{
|
||||
%assetPath = AssetDatabase.getAssetFilePath(%newAssetId);
|
||||
|
||||
//rename the file to match
|
||||
%path = filePath(%assetPath);
|
||||
|
||||
%oldScriptFilePath = %assetDef.scriptFile;
|
||||
%scriptFilePath = filePath(%assetDef.scriptFile);
|
||||
%scriptExt = fileExt(%assetDef.scriptFile);
|
||||
|
||||
%newScriptFileName = %scriptFilePath @ "/" @ %newName @ %scriptExt;
|
||||
%newAssetFile = %path @ "/" @ %newName @ ".asset.taml";
|
||||
|
||||
%assetDef.componentName = %newName;
|
||||
%assetDef.scriptFile = %newScriptFileName;
|
||||
|
||||
TamlWrite(%assetDef, %newAssetFile);
|
||||
fileDelete(%assetPath);
|
||||
|
||||
pathCopy(%oldScriptFilePath, %newScriptFileName);
|
||||
fileDelete(%oldScriptFilePath);
|
||||
|
||||
//Go through our scriptfile and replace the old namespace with the new
|
||||
%editedFileContents = "";
|
||||
|
||||
%file = new FileObject();
|
||||
if ( %file.openForRead( %newScriptFileName ) )
|
||||
{
|
||||
while ( !%file.isEOF() )
|
||||
{
|
||||
%line = %file.readLine();
|
||||
%line = trim( %line );
|
||||
|
||||
%editedFileContents = %editedFileContents @ strreplace(%line, %originalName, %newName) @ "\n";
|
||||
}
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
if(%editedFileContents !$= "")
|
||||
{
|
||||
%file.openForWrite(%newScriptFileName);
|
||||
|
||||
%file.writeline(%editedFileContents);
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
exec(%newScriptFileName);
|
||||
}
|
||||
|
||||
//not used
|
||||
function AssetBrowser::importComponentAsset(%this, %assetId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function AssetBrowser::buildComponentAssetPreview(%this, %assetDef, %previewData)
|
||||
{
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetPath = %assetDef.scriptFile;
|
||||
%previewData.doubleClickCommand = "EditorOpenFileInTorsion( "@%previewData.assetPath@", 0 );";
|
||||
|
||||
%previewData.previewImage = "ToolsModule:componentIcon_image";
|
||||
|
||||
%previewData.assetFriendlyName = %assetDef.friendlyName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = %assetDef.friendlyName @ "\n" @ %assetDef;
|
||||
}
|
||||
|
|
@ -1,44 +1,21 @@
|
|||
function AssetBrowser::buildCppPreview(%this, %assetDef, %previewData)
|
||||
{
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetPath = %assetDef.codeFilePath;
|
||||
%previewData.doubleClickCommand = "echo(\"Not yet implemented to edit C++ files from the editor\");";//"EditorOpenFileInTorsion( "@%previewData.assetPath@", 0 );";
|
||||
|
||||
%previewData.previewImage = "ToolsModule:cppIcon_image";
|
||||
|
||||
%previewData.assetFriendlyName = %assetDef.assetName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = %assetDef.assetName;
|
||||
}
|
||||
AssetBrowser::registerAssetType("CppAsset", "C++ Assets", "");
|
||||
AssetBrowser::registerFileType("CPPFileType", "C++ Files", ".cpp;.h;.c", false);
|
||||
|
||||
function AssetBrowser::buildCppAssetPreview(%this, %assetDef, %previewData)
|
||||
function CppAsset::onCreateNew()
|
||||
{
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetPath = %assetDef.codeFilePath;
|
||||
%previewData.doubleClickCommand = "echo(\"Not yet implemented to edit C++ files from the editor\");";//"EditorOpenFileInTorsion( "@%previewData.assetPath@", 0 );";
|
||||
|
||||
%previewData.previewImage = "ToolsModule:cppIcon_image";
|
||||
|
||||
%previewData.assetFriendlyName = %assetDef.assetName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = %assetDef.assetName;
|
||||
}
|
||||
|
||||
function AssetBrowser::createCppAsset(%this)
|
||||
{
|
||||
%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||
%moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
%assetName = $CurrentAssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%assetPath = NewAssetTargetAddress.getText() @ "/";
|
||||
|
||||
//%tamlpath = %assetPath @ %assetName @ ".asset.taml";
|
||||
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
|
||||
%codePath = %assetPath @ %assetName @ ".cpp";
|
||||
%headerPath = %assetPath @ %assetName @ ".h";
|
||||
|
||||
//Do the work here
|
||||
/*%assetType = AssetBrowser.newAssetSettings.assetType;
|
||||
//%assetType = $CurrentAssetBrowser.newAssetSettings.assetType;
|
||||
|
||||
%asset = new CppAsset()
|
||||
{
|
||||
|
|
@ -48,7 +25,7 @@ function AssetBrowser::createCppAsset(%this)
|
|||
headerFile = %headerPath;
|
||||
};
|
||||
|
||||
TamlWrite(%asset, %tamlpath);*/
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
||||
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
|
||||
|
||||
|
|
@ -67,28 +44,28 @@ function AssetBrowser::createCppAsset(%this)
|
|||
|
||||
if($AssetBrowser::newAssetTypeOverride $= "StaticClass")
|
||||
{
|
||||
%cppTemplateCodeFilePath = %this.templateFilesPath @ "CppStaticClassFile.cpp.template";
|
||||
%cppTemplateHeaderFilePath = %this.templateFilesPath @ "CppStaticClassFile.h.template";
|
||||
%cppTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppStaticClassFile.cpp.template";
|
||||
%cppTemplateHeaderFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppStaticClassFile.h.template";
|
||||
}
|
||||
else if($AssetBrowser::newAssetTypeOverride $= "ScriptClass")
|
||||
{
|
||||
%cppTemplateCodeFilePath = %this.templateFilesPath @ "CppScriptClassFile.cpp.template";
|
||||
%cppTemplateHeaderFilePath = %this.templateFilesPath @ "CppScriptClassFile.h.template";
|
||||
%cppTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppScriptClassFile.cpp.template";
|
||||
%cppTemplateHeaderFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppScriptClassFile.h.template";
|
||||
}
|
||||
else if($AssetBrowser::newAssetTypeOverride $= "AssetTypeCppClass")
|
||||
{
|
||||
%cppTemplateCodeFilePath = %this.templateFilesPath @ "CppAssetTypeClassFile.cpp.template";
|
||||
%cppTemplateHeaderFilePath = %this.templateFilesPath @ "CppAssetTypeClassFile.h.template";
|
||||
%cppTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppAssetTypeClassFile.cpp.template";
|
||||
%cppTemplateHeaderFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppAssetTypeClassFile.h.template";
|
||||
}
|
||||
else if($AssetBrowser::newAssetTypeOverride $= "RenderCppClass")
|
||||
{
|
||||
%cppTemplateCodeFilePath = %this.templateFilesPath @ "CppRenderClassFile.cpp.template";
|
||||
%cppTemplateHeaderFilePath = %this.templateFilesPath @ "CppRenderClassFile.h.template";
|
||||
%cppTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppRenderClassFile.cpp.template";
|
||||
%cppTemplateHeaderFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppRenderClassFile.h.template";
|
||||
}
|
||||
else if($AssetBrowser::newAssetTypeOverride $= "SceneObjectCppClass")
|
||||
{
|
||||
%cppTemplateCodeFilePath = %this.templateFilesPath @ "CppSceneObjectClassFile.cpp.template";
|
||||
%cppTemplateHeaderFilePath = %this.templateFilesPath @ "CppSceneObjectClassFile.h.template";
|
||||
%cppTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppSceneObjectClassFile.cpp.template";
|
||||
%cppTemplateHeaderFilePath = $CurrentAssetBrowser.templateFilesPath @ "CppSceneObjectClassFile.h.template";
|
||||
}
|
||||
|
||||
$AssetBrowser::newAssetTypeOverride = "";
|
||||
|
|
@ -101,7 +78,6 @@ function AssetBrowser::createCppAsset(%this)
|
|||
%line = strreplace( %line, "@", %assetName );
|
||||
|
||||
%file.writeline(%line);
|
||||
//echo(%line);
|
||||
}
|
||||
|
||||
%file.close();
|
||||
|
|
@ -134,7 +110,7 @@ function AssetBrowser::createCppAsset(%this)
|
|||
%file.close();
|
||||
%templateFile.close();
|
||||
|
||||
warnf("CreateNewCppAsset - Something went wrong and we couldn't write the C++ header file!");
|
||||
warn("CreateNewCppAsset - Something went wrong and we couldn't write the C++ header file!");
|
||||
}
|
||||
|
||||
//Last, check that we have a C++ Module definition. If not, make one so anything important can be initialized on startup there
|
||||
|
|
@ -144,7 +120,7 @@ function AssetBrowser::createCppAsset(%this)
|
|||
%file = new FileObject();
|
||||
%templateFile = new FileObject();
|
||||
|
||||
if(%file.openForWrite(%cppModuleFilePath) && %templateFile.openForRead(%this.templateFilesPath @ "CppModuleFile.cpp"))
|
||||
if(%file.openForWrite(%cppModuleFilePath) && %templateFile.openForRead($CurrentAssetBrowser.templateFilesPath @ "CppModuleFile.cpp"))
|
||||
{
|
||||
while( !%templateFile.isEOF() )
|
||||
{
|
||||
|
|
@ -163,57 +139,133 @@ function AssetBrowser::createCppAsset(%this)
|
|||
%file.close();
|
||||
%templateFile.close();
|
||||
|
||||
warnf("CreateNewCppAsset - Something went wrong and we couldn't write the C++ module file!");
|
||||
warn("CreateNewCppAsset - Something went wrong and we couldn't write the C++ module file!");
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
function AssetBrowser::editCppAsset(%this, %assetDef)
|
||||
function CppAsset::buildBrowserElement(%this, %previewData)
|
||||
{
|
||||
%previewData.assetName = %this.assetName;
|
||||
%previewData.assetPath = %this.codeFilePath;
|
||||
//%previewData.doubleClickCommand = "echo(\"Not yet implemented to edit C++ files from the editor\");";//"EditorOpenFileInTorsion( "@%previewData.assetPath@", 0 );";
|
||||
|
||||
%previewData.previewImage = "ToolsModule:cppIcon_image";
|
||||
|
||||
%previewData.assetFriendlyName = %this.assetName;
|
||||
%previewData.assetDesc = %this.description;
|
||||
%previewData.tooltip = %this.assetName;
|
||||
}
|
||||
|
||||
//Renames the asset
|
||||
function AssetBrowser::renameCppAsset(%this, %assetDef, %newAssetName)
|
||||
function CppAsset::onEditCodeFile(%this, %filePath)
|
||||
{
|
||||
%newCodeLooseFilename = renameAssetLooseFile(%assetDef.codefile, %newAssetName);
|
||||
|
||||
if(!%newCodeLooseFilename $= "")
|
||||
return;
|
||||
|
||||
%newHeaderLooseFilename = renameAssetLooseFile(%assetDef.headerFile, %newAssetName);
|
||||
|
||||
if(!%newHeaderLooseFilename $= "")
|
||||
return;
|
||||
|
||||
%assetDef.codefile = %newCodeLooseFilename;
|
||||
%assetDef.headerFile = %newHeaderLooseFilename;
|
||||
%assetDef.saveAsset();
|
||||
|
||||
renameAssetFile(%assetDef, %newAssetName);
|
||||
if(isFunction("systemCommand"))
|
||||
eval("systemCommand(\"start \\\"\\\" \\\"" @ %this.getCodeFile() @ "\\\"\");");
|
||||
else
|
||||
warn("CppAsset::onEditCodeFile() - systemCommand function disabled in this build. Unable to launch application to edit file.");
|
||||
}
|
||||
|
||||
//Deletes the asset
|
||||
function AssetBrowser::deleteCppAsset(%this, %assetDef)
|
||||
function CppAsset::onEditHeaderFile(%this, %filePath)
|
||||
{
|
||||
AssetDatabase.deleteAsset(%assetDef.getAssetId(), true);
|
||||
if(isFunction("systemCommand"))
|
||||
eval("systemCommand(\"start \\\"\\\" \\\"" @ %this.getHeaderFile() @ "\\\"\");");
|
||||
else
|
||||
warn("CppAsset::onEditHeaderFile() - systemCommand function disabled in this build. Unable to launch application to edit file.");
|
||||
}
|
||||
|
||||
//Moves the asset to a new path/module
|
||||
function AssetBrowser::moveCppAsset(%this, %assetDef, %destination)
|
||||
function CppAsset::onShowActionMenu(%this)
|
||||
{
|
||||
%currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
|
||||
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
|
||||
GenericAsset::onShowActionMenu(%this);
|
||||
|
||||
%newAssetPath = moveAssetFile(%assetDef, %destination);
|
||||
|
||||
if(%newAssetPath $= "")
|
||||
return false;
|
||||
if( !isObject( EditCPPFilesSubmenuPopup ) )
|
||||
{
|
||||
new PopupMenu( EditCPPFilesSubmenuPopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
|
||||
moveAssetLooseFile(%assetDef.codeFile, %destination);
|
||||
moveAssetLooseFile(%assetDef.headerFile, %destination);
|
||||
jumpFileName = "";
|
||||
jumpLineNumber = "";
|
||||
};
|
||||
}
|
||||
|
||||
AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
|
||||
AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
|
||||
//Regen the menu so we're fully up and current with options and references
|
||||
EditCPPFilesSubmenuPopup.clearItems();
|
||||
|
||||
EditCPPFilesSubmenuPopup.item[ 0 ] = "Code file" TAB "" TAB %this @ ".onEditCodeFile();";
|
||||
EditCPPFilesSubmenuPopup.item[ 1 ] = "Header file" TAB "" TAB %this @ ".onEditHeaderFile();";
|
||||
|
||||
EditCPPFilesSubmenuPopup.reloadItems();
|
||||
|
||||
EditAssetPopup.item[ 0 ] = "Edit C++ Files" TAB EditCPPFilesSubmenuPopup;
|
||||
|
||||
EditAssetPopup.reloadItems();
|
||||
|
||||
EditAssetPopup.showPopup(Canvas);
|
||||
|
||||
$CurrentAssetBrowser.popupMenu = EditAssetPopup;
|
||||
}
|
||||
//==============================================================================
|
||||
function CPPFileType::buildBrowserElement(%filePath, %previewData)
|
||||
{
|
||||
%previewData.assetName = fileName(%filePath);
|
||||
%previewData.assetPath = %filePath;
|
||||
//%previewData.doubleClickCommand = "echo(\"Not yet implemented to edit C++ files from the editor\");";//"EditorOpenFileInTorsion( "@%previewData.assetPath@", 0 );";
|
||||
|
||||
%previewData.previewImage = "ToolsModule:cppIcon_image";
|
||||
|
||||
%previewData.assetFriendlyName = %previewData.assetName;
|
||||
%previewData.assetDesc = %filePath;
|
||||
%previewData.tooltip = %filePath;
|
||||
}
|
||||
|
||||
function CPPFileType::onEdit(%filePath)
|
||||
{
|
||||
if(isFunction("systemCommand"))
|
||||
eval("systemCommand(\"start \\\"\\\" \\\"" @ %filePath @ "\\\"\");");
|
||||
else
|
||||
warn("CPPFileType::onEdit() - systemCommand function disabled in this build. Unable to launch application to edit file.");
|
||||
}
|
||||
|
||||
function CPPFileType::onShowActionMenu(%filePath)
|
||||
{
|
||||
if( !isObject( EditCPPFileTypePopup ) )
|
||||
{
|
||||
new PopupMenu( EditCPPFileTypePopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
|
||||
jumpFileName = "";
|
||||
jumpLineNumber = "";
|
||||
};
|
||||
}
|
||||
|
||||
//Regen the menu so we're fully up and current with options and references
|
||||
EditCPPFileTypePopup.clearItems();
|
||||
|
||||
EditCPPFileTypePopup.item[ 0 ] = "Edit C++ File" TAB "" TAB $CurrentAssetBrowser @ ".editAsset();";
|
||||
EditCPPFileTypePopup.item[ 1 ] = "Rename File" TAB "" TAB $CurrentAssetBrowser @ ".renameAsset();";
|
||||
EditCPPFileTypePopup.item[ 2 ] = "-";
|
||||
EditCPPFileTypePopup.item[ 3 ] = "Duplicate File" TAB "" TAB $CurrentAssetBrowser @ ".duplicateAsset();";
|
||||
EditCPPFileTypePopup.item[ 4 ] = "-";
|
||||
EditCPPFileTypePopup.item[ 5 ] = "Open File Location" TAB "" TAB $CurrentAssetBrowser @ ".openFileLocation();";
|
||||
EditCPPFileTypePopup.item[ 6 ] = "-";
|
||||
EditCPPFileTypePopup.item[ 7 ] = "Delete File" TAB "" TAB $CurrentAssetBrowser @ ".deleteAsset();";
|
||||
|
||||
EditCPPFileTypePopup.objectData = %filePath;
|
||||
EditCPPFileTypePopup.objectType = "CPPFileType";
|
||||
|
||||
EditCPPFileTypePopup.reloadItems();
|
||||
|
||||
EditCPPFileTypePopup.showPopup(Canvas);
|
||||
|
||||
$CurrentAssetBrowser.popupMenu = EditCPPFileTypePopup;
|
||||
}
|
||||
|
||||
function CPPFileType::onEditProperties(%this, %inspector)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -1,9 +1,11 @@
|
|||
function AssetBrowser::createCubemapAsset(%this)
|
||||
AssetBrowser::registerAssetType("CubemapAsset", "Cubemaps");
|
||||
|
||||
function CubemapAsset::onCreateNew()
|
||||
{
|
||||
Canvas.pushDialog(CubemapEditor);
|
||||
return;
|
||||
|
||||
%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||
/*%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
|
|
@ -30,57 +32,13 @@ function AssetBrowser::createCubemapAsset(%this)
|
|||
|
||||
AssetBrowser.refresh();
|
||||
|
||||
return %tamlpath;
|
||||
return %tamlpath;*/
|
||||
}
|
||||
|
||||
function AssetBrowser::editCubemapAsset(%this, %assetDef)
|
||||
function CubemapAsset::onEdit(%this)
|
||||
{
|
||||
%this.hideDialog();
|
||||
CubemapEditor.openCubemapAsset(%assetDef);
|
||||
}
|
||||
|
||||
//Renames the asset
|
||||
function AssetBrowser::renameCubemapAsset(%this, %assetDef, %newAssetName)
|
||||
{
|
||||
/*%newCodeLooseFilename = renameAssetLooseFile(%assetDef.codefile, %newAssetName);
|
||||
|
||||
if(!%newCodeLooseFilename $= "")
|
||||
return;
|
||||
|
||||
%newHeaderLooseFilename = renameAssetLooseFile(%assetDef.headerFile, %newAssetName);
|
||||
|
||||
if(!%newHeaderLooseFilename $= "")
|
||||
return;
|
||||
|
||||
%assetDef.codefile = %newCodeLooseFilename;
|
||||
%assetDef.headerFile = %newHeaderLooseFilename;
|
||||
%assetDef.saveAsset();
|
||||
|
||||
renameAssetFile(%assetDef, %newAssetName);*/
|
||||
}
|
||||
|
||||
//Deletes the asset
|
||||
function AssetBrowser::deleteCubemapAsset(%this, %assetDef)
|
||||
{
|
||||
AssetDatabase.deleteAsset(%assetDef.getAssetId(), true);
|
||||
}
|
||||
|
||||
//Moves the asset to a new path/module
|
||||
function AssetBrowser::moveCubemapAsset(%this, %assetDef, %destination)
|
||||
{
|
||||
/*%currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
|
||||
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
|
||||
|
||||
%newAssetPath = moveAssetFile(%assetDef, %destination);
|
||||
|
||||
if(%newAssetPath $= "")
|
||||
return false;
|
||||
|
||||
moveAssetLooseFile(%assetDef.codeFile, %destination);
|
||||
moveAssetLooseFile(%assetDef.headerFile, %destination);
|
||||
|
||||
AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
|
||||
AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);*/
|
||||
CubemapEditor.openCubemapAsset(%this);
|
||||
}
|
||||
|
||||
function GuiInspectorTypeCubemapAssetPtr::onControlDropped( %this, %payload, %position )
|
||||
|
|
|
|||
|
|
@ -1,54 +1,29 @@
|
|||
function AssetBrowser::createNewDatablock(%this)
|
||||
{
|
||||
AssetBrowser_newFolderNameTxt.text = "NewFolder";
|
||||
Canvas.pushDialog(AssetBrowser_newFolder);
|
||||
}
|
||||
AssetBrowser::registerObjectType("DatablockObjectType", "Datablock Objects", "GameBaseData");
|
||||
|
||||
function AssetBrowser::doCreateNewDatablock(%this)
|
||||
function DatablockObjectType::onEdit(%this, %className)
|
||||
{
|
||||
%newFolderName = AssetBrowser_newFolderNameTxt.getText();
|
||||
|
||||
if(%newFolderName $= "")
|
||||
%newFolderName = "NewFolder";
|
||||
|
||||
%newFolderIdx = "";
|
||||
%matched = true;
|
||||
%newFolderPath = "";
|
||||
while(%matched == true)
|
||||
if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
|
||||
{
|
||||
%newFolderPath = AssetBrowser.dirHandler.currentAddress @ "/" @ %newFolderName @ %newFolderIdx;
|
||||
if(!isDirectory(%newFolderPath))
|
||||
{
|
||||
%matched = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
%newFolderIdx++;
|
||||
}
|
||||
$CurrentAssetBrowser.hideDialog();
|
||||
|
||||
DatablockEditorPlugin.openDatablock(%this);
|
||||
}
|
||||
|
||||
//make a dummy file
|
||||
%file = new FileObject();
|
||||
%file.openForWrite(%newFolderPath @ "/test");
|
||||
%file.close();
|
||||
|
||||
fileDelete(%newFolderPath @ "/test");
|
||||
|
||||
//refresh the directory
|
||||
AssetBrowser.loadDirectories();
|
||||
|
||||
%this.navigateTo(%newFolderPath);
|
||||
else
|
||||
{
|
||||
%this.onWorldEditorDropped();
|
||||
}
|
||||
}
|
||||
|
||||
function AssetBrowser::buildDatablockPreview(%this, %assetDef, %previewData)
|
||||
function DatablockObjectType::buildBrowserElement(%this, %className, %previewData)
|
||||
{
|
||||
%previewData.assetName = %assetDef;
|
||||
%previewData.assetPath = "";
|
||||
echo("DatablockObjectType::buildBrowserElement() - " @ %this @ ", " @ %previewData);
|
||||
%previewData.assetName = %this.getName();
|
||||
%previewData.assetPath = %this.getFileName();
|
||||
|
||||
%previewData.previewImage = "ToolsModule:datablockIcon_image";
|
||||
|
||||
//Lets see if we have a icon for specifically for this datablock type
|
||||
%dataClass = %assetDef.getClassName();
|
||||
%dataClass = %this.getClassName();
|
||||
%dataClass = strreplace(%dataClass, "Data", "");
|
||||
|
||||
%previewImage = "tools/classIcons/" @ %dataClass @ ".png";
|
||||
|
|
@ -58,27 +33,42 @@ function AssetBrowser::buildDatablockPreview(%this, %assetDef, %previewData)
|
|||
}
|
||||
|
||||
//%previewData.assetFriendlyName = %assetDef.assetName;
|
||||
%previewData.assetDesc = %assetDef;
|
||||
%previewData.tooltip = "\nDatablock Name: " @ %assetDef @
|
||||
"\nDatablock Type: " @ %assetDef.getClassName() @
|
||||
"\nDefinition Path: " @ %assetDef.getFilename();
|
||||
%previewData.assetDesc = %this;
|
||||
%previewData.tooltip = "\nDatablock Name: " @ %previewData.assetName @
|
||||
"\nDatablock Type: " @ %dataClass @
|
||||
"\nDefinition Path: " @ %previewData.assetPath;
|
||||
|
||||
}
|
||||
|
||||
function DatablockObjectType::onShowActionMenu(%this, %className)
|
||||
{
|
||||
if( !isObject( EditDatablockObjectTypePopup ) )
|
||||
{
|
||||
new PopupMenu( EditDatablockObjectTypePopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
|
||||
jumpFileName = "";
|
||||
jumpLineNumber = "";
|
||||
};
|
||||
}
|
||||
|
||||
if(%this.selectMode)
|
||||
{
|
||||
%previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
|
||||
{
|
||||
%previewData.doubleClickCommand = "DatablockEditorPlugin.openDatablock( "@%assetDef@" );";
|
||||
}
|
||||
else
|
||||
{
|
||||
%previewData.doubleClickCommand = "AssetBrowser.onDatablockEditorDropped( "@%assetDef@" );";
|
||||
}
|
||||
}
|
||||
EditDatablockObjectTypePopup.objectData = %this;
|
||||
EditDatablockObjectTypePopup.objectType = "DatablockObjectType";
|
||||
|
||||
//Regen the menu so we're fully up and current with options and references
|
||||
EditDatablockObjectTypePopup.clearItems();
|
||||
|
||||
EditDatablockObjectTypePopup.item[ 0 ] = "Edit Datablock" TAB "" TAB $CurrentAssetBrowser @ ".editAsset();";
|
||||
EditDatablockObjectTypePopup.item[ 1 ] = "-";
|
||||
EditDatablockObjectTypePopup.item[ 2 ] = "Open Datablock Location" TAB "" TAB $CurrentAssetBrowser @ ".openFolderLocation(" @ %this.getFilename() @ ");";
|
||||
|
||||
EditDatablockObjectTypePopup.reloadItems();
|
||||
|
||||
EditDatablockObjectTypePopup.showPopup(Canvas);
|
||||
|
||||
$CurrentAssetBrowser.popupMenu = EditDatablockObjectTypePopup;
|
||||
}
|
||||
|
||||
function spawnDatablockObject(%datablock)
|
||||
|
|
@ -92,96 +82,8 @@ function spawnDatablockObject(%datablock)
|
|||
return eval(%createCmd);//eval("showImportDialog( \"" @ %shapePath @ "\", \"" @ %createCmd @ "\" );");
|
||||
}
|
||||
|
||||
function AssetBrowser::renameDatablock(%this, %folderPath, %newFolderName)
|
||||
function DatablockObjectType::onWorldEditorDropped(%this, %position)
|
||||
{
|
||||
%fullPath = makeFullPath(%folderPath);
|
||||
%newFullPath = makeFullPath(%folderPath);
|
||||
|
||||
%fullPath = strreplace(%fullPath, "//", "/");
|
||||
|
||||
%count = getTokenCount(%fullPath, "/");
|
||||
%basePath = getTokens(%fullPath, "/", 0, %count-2);
|
||||
%oldName = getToken(%fullPath, "/", %count-1);
|
||||
|
||||
//We need to ensure that no files are 'active' while we try and clean up behind ourselves with the delete action
|
||||
//so, we nix any assets active for the module, do the delete action on the old folder, and then re-acquire our assets.
|
||||
//This will have the added benefit of updating paths for asset items
|
||||
|
||||
%module = AssetBrowser.dirHandler.getModuleFromAddress(AssetBrowser.dirHandler.currentAddress);
|
||||
%moduleId = %module.ModuleId;
|
||||
|
||||
AssetDatabase.removeDeclaredAssets(%moduleId);
|
||||
|
||||
%copiedSuccess = %this.dirHandler.copyDatablock(%fullPath, %basePath @ "/" @ %newFolderName);
|
||||
%this.dirHandler.deleteDatablock(%fullPath);
|
||||
|
||||
%this.loadDirectories();
|
||||
|
||||
AssetDatabase.addModuleDeclaredAssets(%moduleId);
|
||||
}
|
||||
|
||||
function AssetBrowser::moveDatablock(%this, %folderPath, %newFolderPath)
|
||||
{
|
||||
%fullPath = makeFullPath(%folderPath);
|
||||
%newFullPath = makeFullPath(%newFolderPath);
|
||||
|
||||
%fullPath = strreplace(%fullPath, "//", "/");
|
||||
%newFullPath = strreplace(%newFullPath, "//", "/");
|
||||
|
||||
%count = getTokenCount(%fullPath, "/");
|
||||
%basePath = getTokens(%fullPath, "/", 0, %count-2);
|
||||
%oldName = getToken(%fullPath, "/", %count-1);
|
||||
|
||||
%copiedSuccess = %this.dirHandler.copyDatablock(%fullPath, %newFullPath);
|
||||
%this.dirHandler.deleteDatablock(%fullPath);
|
||||
|
||||
%this.loadDirectories();
|
||||
|
||||
//thrash the modules and reload them
|
||||
%oldModule = %this.dirHandler.getModuleFromAddress(%folderPath);
|
||||
%newModule = %this.dirHandler.getModuleFromAddress(%newFolderPath);
|
||||
|
||||
//if we didn't move modules, then we don't need to do anything other than refresh the assets within it
|
||||
if(%oldModule == %newModule)
|
||||
{
|
||||
//only do a refresh to update asset loose file paths
|
||||
AssetDatabase.refreshAllAssets();
|
||||
}
|
||||
else
|
||||
{
|
||||
//they're different moduels now, so we gotta unload/reload both
|
||||
ModuleDatabase.unloadExplicit(%oldModule.getModuleId());
|
||||
ModuleDatabase.loadExplicit(%oldModule.getModuleId());
|
||||
|
||||
ModuleDatabase.unloadExplicit(%newModule.getModuleId());
|
||||
ModuleDatabase.loadExplicit(%newModule.getModuleId());
|
||||
}
|
||||
}
|
||||
|
||||
function AssetBrowser::deleteDatablock(%this, %folderPath)
|
||||
{
|
||||
%this.dirHandler.deleteDatablock(%folderPath);
|
||||
|
||||
%this.refresh();
|
||||
}
|
||||
|
||||
function AssetBrowser::onDatablockEditorDropped(%this, %assetDef, %position)
|
||||
{
|
||||
%targetPosition = EWorldEditor.unproject(%position SPC 1);
|
||||
%camPos = LocalClientConnection.camera.getPosition();
|
||||
%rayResult = containerRayCast(%camPos, %targetPosition, -1);
|
||||
|
||||
%pos = ObjectCreator.getCreateObjectPosition();
|
||||
|
||||
if(%rayResult != 0)
|
||||
{
|
||||
%pos = getWords(%rayResult, 1, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
%pos = "0 0 0";
|
||||
}
|
||||
|
||||
%newObj = spawnDatablockObject(%assetDef);
|
||||
%newObj.position = %pos;
|
||||
%newObj = spawnDatablockObject(%this);
|
||||
%newObj.position = %position;
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
function AssetBrowser::createNewFolder(%this)
|
||||
AssetBrowser::registerFileType("FolderObjectType", "Folder", "/", false);
|
||||
|
||||
function FolderObjectType::setupCreateNew()
|
||||
{
|
||||
AssetBrowser_newFolderNameTxt.text = "NewFolder";
|
||||
Canvas.pushDialog(AssetBrowser_newFolder, 99, true);
|
||||
|
|
@ -6,7 +8,7 @@ function AssetBrowser::createNewFolder(%this)
|
|||
AssetBrowser_newFolderNameTxt.selectAllText();
|
||||
}
|
||||
|
||||
function AssetBrowser::doCreateNewFolder(%this)
|
||||
function FolderObjectType::onCreateNew()
|
||||
{
|
||||
%newFolderName = AssetBrowser_newFolderNameTxt.getText();
|
||||
|
||||
|
|
@ -19,7 +21,7 @@ function AssetBrowser::doCreateNewFolder(%this)
|
|||
}
|
||||
else
|
||||
{
|
||||
%currentAddressPath = AssetBrowser.dirHandler.currentAddress;
|
||||
%currentAddressPath = $CurrentAssetBrowser.dirHandler.currentAddress;
|
||||
}
|
||||
|
||||
%newFolderIdx = "";
|
||||
|
|
@ -46,29 +48,65 @@ function AssetBrowser::doCreateNewFolder(%this)
|
|||
fileDelete(%newFolderPath @ "/test");
|
||||
|
||||
//refresh the directory
|
||||
AssetBrowser.loadDirectories();
|
||||
$CurrentAssetBrowser.loadDirectories();
|
||||
|
||||
%this.navigateTo(%newFolderPath);
|
||||
$CurrentAssetBrowser.navigateTo(%newFolderPath);
|
||||
|
||||
//On the off chance we're trying to select a path, we'll update the select path window too
|
||||
if(SelectAssetPath.isAwake())
|
||||
SelectAssetPath.showDialog(%newFolderPath, SelectAssetPath.callback);
|
||||
}
|
||||
|
||||
function AssetBrowser::buildFolderPreview(%this, %assetDef, %previewData)
|
||||
function FolderObjectType::buildBrowserElement(%folderPath, %previewData)
|
||||
{
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetPath = %assetDef.dirPath;
|
||||
%folderName = fileBase(%folderPath);
|
||||
|
||||
%previewData.assetName = %folderName;
|
||||
%previewData.assetPath = %folderPath;
|
||||
|
||||
%previewData.previewImage = "ToolsModule:FolderIcon_image";
|
||||
|
||||
//%previewData.assetFriendlyName = %assetDef.assetName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = %assetDef.dirPath;
|
||||
%previewData.doubleClickCommand = "AssetBrowser.schedule(10, \"navigateTo\",\""@ %assetDef.dirPath @ "/" @ %assetDef.assetName @"\");";//browseTo %assetDef.dirPath / %assetDef.assetName
|
||||
%previewData.assetDesc = "Folder";
|
||||
%previewData.tooltip = %folderPath;
|
||||
%previewData.doubleClickCommand = "AssetBrowser.schedule(10, \"navigateTo\",\""@ %folderPath @"\");"; //browseTo %this.dirPath / %this.assetName
|
||||
}
|
||||
|
||||
function AssetBrowser::renameFolder(%this, %folderPath, %newFolderName)
|
||||
function FolderObjectType::onShowActionMenu(%folderPath)
|
||||
{
|
||||
if( !isObject( EditFolderTypePopup ) )
|
||||
{
|
||||
new PopupMenu( EditFolderTypePopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
|
||||
jumpFileName = "";
|
||||
jumpLineNumber = "";
|
||||
};
|
||||
}
|
||||
|
||||
EditFolderTypePopup.objectData = %folderPath;
|
||||
EditFolderTypePopup.objectType = "FolderObjectType";
|
||||
|
||||
//Regen the menu so we're fully up and current with options and references
|
||||
EditFolderTypePopup.clearItems();
|
||||
|
||||
EditFolderTypePopup.item[ 0 ] = "Rename Folder" TAB "" TAB $CurrentAssetBrowser @ ".renameAsset();";
|
||||
EditFolderTypePopup.item[ 1 ] = "Duplicate Folder" TAB "" TAB $CurrentAssetBrowser @ ".duplicateAsset();";
|
||||
EditFolderTypePopup.item[ 2 ] = "-";
|
||||
EditFolderTypePopup.item[ 3 ] = "Open Folder Location" TAB "" TAB $CurrentAssetBrowser @ ".openFolderLocation(" @ %folderPath @ ");";
|
||||
EditFolderTypePopup.item[ 4 ] = "-";
|
||||
EditFolderTypePopup.item[ 5 ] = "Delete Folder" TAB "" TAB $CurrentAssetBrowser @ ".deleteAsset();";
|
||||
|
||||
EditFolderTypePopup.reloadItems();
|
||||
|
||||
EditFolderTypePopup.showPopup(Canvas);
|
||||
|
||||
$CurrentAssetBrowser.popupMenu = EditFolderTypePopup;
|
||||
}
|
||||
|
||||
function FolderObjectType::onRename(%folderPath, %newFolderName)
|
||||
{
|
||||
%fullPath = makeFullPath(%folderPath);
|
||||
%newFullPath = makeFullPath(%folderPath);
|
||||
|
|
@ -83,23 +121,40 @@ function AssetBrowser::renameFolder(%this, %folderPath, %newFolderName)
|
|||
//so, we nix any assets active for the module, do the delete action on the old folder, and then re-acquire our assets.
|
||||
//This will have the added benefit of updating paths for asset items
|
||||
|
||||
%module = AssetBrowser.dirHandler.getModuleFromAddress(AssetBrowser.dirHandler.currentAddress);
|
||||
%module = $CurrentAssetBrowser.dirHandler.getModuleFromAddress($CurrentAssetBrowser.dirHandler.currentAddress);
|
||||
%moduleId = %module.ModuleId;
|
||||
|
||||
AssetDatabase.removeDeclaredAssets(%moduleId);
|
||||
$CurrentAssetBrowser.removeDeclaredAssets(%moduleId);
|
||||
|
||||
%copiedSuccess = %this.dirHandler.copyFolder(%fullPath, %basePath @ "/" @ %newFolderName);
|
||||
%this.dirHandler.deleteFolder(%fullPath);
|
||||
%copiedSuccess = $CurrentAssetBrowser.dirHandler.copyFolder(%fullPath, %basePath @ "/" @ %newFolderName);
|
||||
$CurrentAssetBrowser.dirHandler.deleteFolder(%fullPath);
|
||||
|
||||
%this.loadDirectories();
|
||||
$CurrentAssetBrowser.loadDirectories();
|
||||
|
||||
AssetDatabase.addModuleDeclaredAssets(%moduleId);
|
||||
$CurrentAssetBrowser.addModuleDeclaredAssets(%moduleId);
|
||||
}
|
||||
|
||||
function AssetBrowser::moveFolder(%this, %folderPath, %newFolderPath)
|
||||
function FolderObjectType::onDelete(%folderPath)
|
||||
{
|
||||
$CurrentAssetBrowser.dirHandler.deleteFolder(%folderPath);
|
||||
|
||||
$CurrentAssetBrowser.refresh();
|
||||
}
|
||||
|
||||
function FolderObjectType::onWorldEditorDropped(%folderPath, %position)
|
||||
{
|
||||
//We do nothing with this as we don't process entire folders for spawning
|
||||
}
|
||||
|
||||
function FolderObjectType::onGuiEditorDropped(%folderPath, %position)
|
||||
{
|
||||
//We do nothing with this as we don't process entire folders for spawning
|
||||
}
|
||||
|
||||
function FolderObjectType::onMovePath(%folderPath, %destinationPath)
|
||||
{
|
||||
%fullPath = makeFullPath(%folderPath);
|
||||
%newFullPath = makeFullPath(%newFolderPath);
|
||||
%newFullPath = makeFullPath(%destinationPath);
|
||||
|
||||
%fullPath = strreplace(%fullPath, "//", "/");
|
||||
%newFullPath = strreplace(%newFullPath, "//", "/");
|
||||
|
|
@ -108,14 +163,20 @@ function AssetBrowser::moveFolder(%this, %folderPath, %newFolderPath)
|
|||
%basePath = getTokens(%fullPath, "/", 0, %count-2);
|
||||
%oldName = getToken(%fullPath, "/", %count-1);
|
||||
|
||||
%copiedSuccess = %this.dirHandler.copyFolder(%fullPath, %newFullPath);
|
||||
%this.dirHandler.deleteFolder(%fullPath);
|
||||
%copiedSuccess = $CurrentAssetBrowser.dirHandler.copyFolder(%fullPath, %newFullPath);
|
||||
$CurrentAssetBrowser.dirHandler.deleteFolder(%fullPath);
|
||||
|
||||
%this.loadDirectories();
|
||||
$CurrentAssetBrowser.loadDirectories();
|
||||
}
|
||||
|
||||
function FolderObjectType::onMoveModule(%folderPath, %destinationPath)
|
||||
{
|
||||
//Same logic as a regular folder move
|
||||
FolderObjectType::onMovePath(%folderPath, %destinationPath);
|
||||
|
||||
//thrash the modules and reload them
|
||||
%oldModule = %this.dirHandler.getModuleFromAddress(%folderPath);
|
||||
%newModule = %this.dirHandler.getModuleFromAddress(%newFolderPath);
|
||||
%oldModule = $CurrentAssetBrowser.dirHandler.getModuleFromAddress(%folderPath);
|
||||
%newModule = $CurrentAssetBrowser.dirHandler.getModuleFromAddress(%destinationPath);
|
||||
|
||||
//if we didn't move modules, then we don't need to do anything other than refresh the assets within it
|
||||
if(%oldModule == %newModule)
|
||||
|
|
@ -132,11 +193,4 @@ function AssetBrowser::moveFolder(%this, %folderPath, %newFolderPath)
|
|||
ModuleDatabase.unloadExplicit(%newModule.getModuleId());
|
||||
ModuleDatabase.loadExplicit(%newModule.getModuleId());
|
||||
}
|
||||
}
|
||||
|
||||
function AssetBrowser::deleteFolder(%this, %folderPath)
|
||||
{
|
||||
%this.dirHandler.deleteFolder(%folderPath);
|
||||
|
||||
%this.refresh();
|
||||
}
|
||||
|
|
@ -1,285 +0,0 @@
|
|||
function AssetBrowser::createGameObjectAsset(%this)
|
||||
{
|
||||
GameObjectCreatorObjectName.text = "";
|
||||
|
||||
%activeSelection = EWorldEditor.getActiveSelection();
|
||||
if( %activeSelection.getCount() == 0 )
|
||||
return;
|
||||
|
||||
GameObjectCreator.selectedEntity = %activeSelection.getObject( 0 );
|
||||
|
||||
Canvas.pushDialog(GameObjectCreator);
|
||||
}
|
||||
|
||||
function AssetBrowser::editGameObjectAsset(%this, %assetDef)
|
||||
{
|
||||
//We have no dedicated GO editor for now, so just defer to the script editing aspect
|
||||
%this.editGameObjectAssetScript(%assetDef);
|
||||
}
|
||||
|
||||
function AssetBrowser::editGameObjectAssetScript(%this, %assetDef)
|
||||
{
|
||||
%scriptFile = %assetDef.scriptFile;
|
||||
|
||||
if(%scriptFile !$= "")
|
||||
EditorOpenFileInTorsion(makeFullPath(%scriptFile), 0);
|
||||
}
|
||||
|
||||
function AssetBrowser::applyInstanceToGameObject(%this, %assetDef)
|
||||
{
|
||||
%obj = EditGameObjectAssetPopup.object;
|
||||
|
||||
//TODO add proper validation against the original GO asset
|
||||
%obj.dirtyGameObject = true;
|
||||
|
||||
TamlWrite(%obj, %assetDef.TAMLFilePath);
|
||||
}
|
||||
|
||||
function AssetBrowser::duplicateGameObjectAsset(%this, %assetDef, %targetModule)
|
||||
{
|
||||
//Check if we have a target module, if not we need to select one
|
||||
if(%targetModule $= "")
|
||||
{
|
||||
error("AssetBrowser::duplicateGameObjectAsset - No target module selected!");
|
||||
return;
|
||||
}
|
||||
|
||||
%assetId = %assetDef.getAssetId();
|
||||
%assetName = AssetDatabase.getAssetName(%assetId);
|
||||
|
||||
//First step, copy the files
|
||||
%modulePath = "data/" @ %targetModule @ "/gameObjects/";
|
||||
|
||||
if(!isDirectory(%modulePath))
|
||||
createPath(%modulePath);
|
||||
|
||||
%assetFile = AssetDatabase.getAssetFilePath(%assetId);
|
||||
%scriptFile = %assetDef.scriptFile;
|
||||
%gameObjectFile = %assetDef.TAMLFile;
|
||||
|
||||
echo("AssetBrowser::duplicateGameObjectAsset - duplicating! " @ %assetId @ " to " @ %targetModule);
|
||||
|
||||
%tamlPath = %modulePath @ fileName(%assetFile);
|
||||
|
||||
pathCopy(%assetFile, %tamlPath);
|
||||
pathCopy(%scriptFile, %modulePath @ fileName(%scriptFile));
|
||||
pathCopy(%gameObjectFile, %modulePath @ fileName(%gameObjectFile));
|
||||
|
||||
echo("AssetBrowser::duplicateGameObjectAsset - duplicated!");
|
||||
|
||||
//Register the asset
|
||||
%moduleDef = ModuleDatabase.findModule(%targetModule, 1);
|
||||
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlPath);
|
||||
|
||||
//Refresh the browser
|
||||
AssetBrowser.refresh();
|
||||
|
||||
//Rename it for convenience
|
||||
AssetBrowser.performRenameAsset(%assetName, "New" @ %assetName);
|
||||
}
|
||||
|
||||
//not used
|
||||
function AssetBrowser::importGameObjectAsset(%this, %assetId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function AssetBrowser::dragAndDropGameObjectAsset(%this, %assetDef, %dropTarget)
|
||||
{
|
||||
if(!isObject(%dropTarget))
|
||||
return;
|
||||
|
||||
if(%dropTarget.getId() == EWorldEditor.getId())
|
||||
{
|
||||
if(isObject(%assetDef))
|
||||
{
|
||||
%gameObject = %assetDef.createObject();
|
||||
|
||||
getScene(0).add(%gameObject);
|
||||
|
||||
%pos = ObjectCreator.getCreateObjectPosition(); //LocalClientConnection.camera.position;
|
||||
|
||||
%gameObject.position = %pos;
|
||||
|
||||
EWorldEditor.clearSelection();
|
||||
EWorldEditor.selectObject(%gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
error("WorldEditor::onControlDropped - unable to create GameObject");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function AssetBrowser::onGameObjectAssetEditorDropped(%this, %assetDef, %position)
|
||||
{
|
||||
//echo("DROPPED A SHAPE ON THE EDITOR WINDOW!");
|
||||
|
||||
%targetPosition = EWorldEditor.unproject(%position SPC 1);
|
||||
%camPos = LocalClientConnection.camera.getPosition();
|
||||
%rayResult = containerRayCast(%camPos, %targetPosition, -1);
|
||||
|
||||
%pos = ObjectCreator.getCreateObjectPosition();
|
||||
|
||||
if(%rayResult != 0)
|
||||
{
|
||||
%pos = getWords(%rayResult, 1, 3);
|
||||
}
|
||||
|
||||
%gameObject = %assetDef.createObject();
|
||||
|
||||
getScene(0).add(%gameObject);
|
||||
|
||||
%gameObject.position = %pos;
|
||||
|
||||
EWorldEditor.clearSelection();
|
||||
EWorldEditor.selectObject(%gameObject);
|
||||
|
||||
EWorldEditor.isDirty = true;
|
||||
|
||||
}
|
||||
|
||||
function AssetBrowser::renameGameObjectAsset(%this, %assetDef, %newAssetId, %originalName, %newName)
|
||||
{
|
||||
%oldScriptFilePath = %assetDef.scriptFile;
|
||||
%scriptFilePath = filePath(%assetDef.scriptFile);
|
||||
%scriptExt = fileExt(%assetDef.scriptFile);
|
||||
|
||||
%oldGOFilePath = %assetDef.TAMLFile;
|
||||
|
||||
%filepath = AssetDatabase.getAssetFilePath(%assetDef.getAssetId());
|
||||
%path = makeRelativePath(filePath(%filepath));
|
||||
|
||||
%newScriptFileName = %path @ "/" @ %newName @ %scriptExt;
|
||||
%newAssetFile = %path @ "/" @ %newName @ ".asset.taml";
|
||||
%newGOFile = %path @ "/" @ %newName @ ".taml";
|
||||
|
||||
%assetDef.gameObjectName = %newName;
|
||||
%assetDef.scriptFile = %newScriptFileName;
|
||||
%assetDef.TAMLFile = %newGOFile;
|
||||
|
||||
TamlWrite(%assetDef, %newAssetFile);
|
||||
fileDelete(%filepath);
|
||||
|
||||
//Quick check, if we duplicated the asset to a new module, the old path may not line up so we'll want to update that to be relevent
|
||||
if(filePath(%oldScriptFilePath) !$= %path)
|
||||
{
|
||||
%oldFileBase = fileName(%oldScriptFilePath);
|
||||
%oldScriptFilePath = %path @ "/" @ %oldFileBase;
|
||||
}
|
||||
|
||||
%scriptFileCopySuccess = pathCopy(%oldScriptFilePath, %newScriptFileName);
|
||||
fileDelete(%oldScriptFilePath);
|
||||
|
||||
if(!%scriptFileCopySuccess)
|
||||
error("AssetBrowser::renameGameObjectAsset - unable to copy scriptFile");
|
||||
|
||||
if(filePath(%oldGOFilePath) !$= %path)
|
||||
{
|
||||
%oldFileBase = fileName(%oldGOFilePath);
|
||||
%oldGOFilePath = %path @ "/" @ %oldFileBase;
|
||||
}
|
||||
|
||||
%goFileCopySuccess = pathCopy(%oldGOFilePath, %newGOFile);
|
||||
fileDelete(%oldGOFilePath);
|
||||
|
||||
if(!%scriptFileCopySuccess)
|
||||
error("AssetBrowser::renameGameObjectAsset - unable to copy gameObject");
|
||||
|
||||
//Go through our scriptfile and replace the old namespace with the new
|
||||
%editedFileContents = "";
|
||||
|
||||
%file = new FileObject();
|
||||
if ( %file.openForRead( %newScriptFileName ) )
|
||||
{
|
||||
while ( !%file.isEOF() )
|
||||
{
|
||||
%line = %file.readLine();
|
||||
%line = trim( %line );
|
||||
|
||||
%editedFileContents = %editedFileContents @ strreplace(%line, %originalName, %newName) @ "\n";
|
||||
}
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
if(%editedFileContents !$= "")
|
||||
{
|
||||
%file.openForWrite(%newScriptFileName);
|
||||
|
||||
%file.writeline(%editedFileContents);
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
exec(%newScriptFileName);
|
||||
|
||||
%gameObj = TAMLRead(%newGOFile);
|
||||
|
||||
%gameObj.className = %newName;
|
||||
%gameObj.GameObject = %assetDef.getAssetId();
|
||||
|
||||
TAMLWrite(%gameObj, %newGOFile);
|
||||
}
|
||||
|
||||
//Deletes the asset
|
||||
function AssetBrowser::deleteGameObjectAsset(%this, %assetDef)
|
||||
{
|
||||
AssetDatabase.deleteAsset(%assetDef.getAssetId(), true);
|
||||
}
|
||||
|
||||
//Moves the asset to a new path/module
|
||||
function AssetBrowser::moveGameObjectAsset(%this, %assetDef, %destination)
|
||||
{
|
||||
%currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
|
||||
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
|
||||
|
||||
%newAssetPath = moveAssetFile(%assetDef, %destination);
|
||||
|
||||
if(%newAssetPath $= "")
|
||||
return false;
|
||||
|
||||
moveAssetLooseFile(%assetDef.scriptFile, %destination);
|
||||
moveAssetLooseFile(%assetDef.TAMLFile, %destination);
|
||||
|
||||
AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
|
||||
AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
|
||||
}
|
||||
|
||||
|
||||
function AssetBrowser::buildGameObjectAssetPreview(%this, %assetDef, %previewData)
|
||||
{
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetPath = %assetDef.scriptFile;
|
||||
%previewData.doubleClickCommand = "EditorOpenFileInTorsion( "@%previewData.assetPath@", 0 );";
|
||||
|
||||
%previewData.previewImage = "ToolsModule:gameObjectIcon_image";
|
||||
|
||||
%previewData.assetFriendlyName = %assetDef.gameObjectName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = "Asset Name: " @ %assetDef.gameObjectName @ "\nDefinition Path: " @ %assetDef.getFilename();
|
||||
}
|
||||
|
||||
function GuiInspectorTypeGameObjectAssetPtr::onClick( %this, %fieldName )
|
||||
{
|
||||
//Get our data
|
||||
%obj = %this.getInspector().getInspectObject(0);
|
||||
|
||||
EditGameObjectAssetPopup.object = %obj;
|
||||
|
||||
%assetId = %obj.getFieldValue(%fieldName);
|
||||
|
||||
if(%assetId !$= "")
|
||||
{
|
||||
EditGameObjectAssetPopup.assetId = %assetId;
|
||||
|
||||
|
||||
EditGameObjectAssetPopup.showPopup(Canvas);
|
||||
}
|
||||
else
|
||||
{
|
||||
//We've gotta be trying to create a GameObject, so kick that off
|
||||
AssetBrowser.createGameObjectAsset();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,351 @@
|
|||
//This function registers the asset type, associated file extensions and human-readable name with the Asset Browser
|
||||
//This is primarily so there's an easy hook-in point for the 'type' namespace, as well as registration for AB
|
||||
//filter modes and file scanning
|
||||
AssetBrowser::registerAssetType("GenericAsset", "", "", false);
|
||||
|
||||
//This function is called when we want to have adjustable field information for a new asset
|
||||
//This could be a secondary name or description, a 'preview image' or anything else beyond
|
||||
//just the basic AssetName and AssetDescription files
|
||||
function GenericAsset::setupCreateNew()
|
||||
{
|
||||
echo("GenericAsset::setupCreateNew()");
|
||||
}
|
||||
|
||||
//This is called when we actually finally decide to create the new asset itself
|
||||
//We create the asset definition, supplemental files, save everything to disk and
|
||||
//then register with the AssetDatabase so it's available for use
|
||||
function GenericAsset::onCreateNew()
|
||||
{
|
||||
echo("GenericAsset::onCreateNew()");
|
||||
}
|
||||
|
||||
//This us called when we are creating a 'card' in the AssetBrowser for viewing
|
||||
//when navigating. It packs whatever relevent information such as the preview image
|
||||
//into the %previewData object that the AssetBrowser then uses to actually display
|
||||
function GenericAsset::buildBrowserElement(%this, %previewData)
|
||||
{
|
||||
%previewData.assetName = %this.assetName;
|
||||
%previewData.assetPath = %this.getFileName();
|
||||
%previewData.doubleClickCommand = "";
|
||||
|
||||
%previewData.previewImage = "ToolsModule:genericAssetIcon_image";
|
||||
|
||||
%previewData.assetFriendlyName = %this.assetName;
|
||||
%previewData.assetDesc = %this.description;
|
||||
%previewData.tooltip = "Asset Name: " @ %this.assetName @ "\nDefinition Path: " @ %previewData.assetPath;
|
||||
}
|
||||
|
||||
//This is called when we specifically need to special-handle generation of a preview image
|
||||
//Such as rendering a shape or material to a cached image file, rather than simply using a
|
||||
//basic image to represent the type in the AssetBrowser
|
||||
function GenericAsset::generatePreviewImage(%this, %previewButton, %forceRegenerate)
|
||||
{
|
||||
}
|
||||
|
||||
//Called when we rename the asset. The place we would change the asset definition name
|
||||
//as well as update the name for any associated files
|
||||
function GenericAsset::onRename(%this, %newAssetName)
|
||||
{
|
||||
%assetPath = makeFullPath($CurrentAssetBrowser.getAssetFilePath(%this.getAssetId()));
|
||||
%assetFilepath = filePath(%assetPath);
|
||||
%assetFileExt = fileExt(%assetPath);
|
||||
|
||||
%newAssetPath = %assetFilepath @ "/" @ %newAssetName @ ".asset.taml";
|
||||
|
||||
%copiedSuccess = pathCopy(%assetPath, %newAssetPath);
|
||||
|
||||
if(!%copiedSuccess)
|
||||
return "";
|
||||
|
||||
replaceInFile(%newAssetPath, %this.assetName, %newAssetName);
|
||||
|
||||
%looseFilesList = AssetDatabase.getAssetLooseFiles(%this.getAssetId());
|
||||
|
||||
for(%i=0; %i < getFieldCount(%looseFilesList); %i++)
|
||||
{
|
||||
%looseFile = getField(%looseFilesList, %i);
|
||||
|
||||
if(!isFile(%looseFile))
|
||||
{
|
||||
errorf("GenericAsset::onMovePath() - could not find loose file: " @ %looseFile);
|
||||
continue;
|
||||
}
|
||||
|
||||
%newLooseFileName = strReplace(fileName(%looseFile), %this.assetName, %newAssetName);
|
||||
%looseFileExt = fileExt(%looseFile);
|
||||
|
||||
echo("GenericAsset::onRename() - renamed loose file from: " @ %looseFile @ " to: " @ %assetPath @ "/" @ %newLooseFileName @ %looseFileExt);
|
||||
|
||||
%looseFileNewPath = %assetPath @ "/" @ %newLooseFileName @ %looseFileExt;
|
||||
%copiedSuccess = pathCopy(%looseFile, %looseFileNewPath);
|
||||
if(!%copiedSuccess)
|
||||
{
|
||||
errorf("GenericAsset::onDuplicate() - failed to duplicate loose file: " @ %looseFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
fileDelete(%looseFile);
|
||||
replaceInFile(%looseFileNewPath, %this.assetName, %newAssetName);
|
||||
}
|
||||
}
|
||||
|
||||
%module = getModuleFromAddress(%newAssetPath);
|
||||
|
||||
//Add with the new file
|
||||
$CurrentAssetBrowser.addDeclaredAsset(%module, %newAssetPath);
|
||||
|
||||
GenericAsset::onDelete(%this);
|
||||
|
||||
return %newAssetPath;
|
||||
}
|
||||
|
||||
//Called when duplicating the asset. A copy is made, and then we perform a rename action
|
||||
//on the copy to ensure there's no name conflicts
|
||||
function GenericAsset::onDuplicate(%this, %newAssetName)
|
||||
{
|
||||
%assetPath = makeFullPath($CurrentAssetBrowser.getAssetFilePath(%this.getAssetId()));
|
||||
%assetFilepath = filePath(%assetPath);
|
||||
%assetFileExt = fileExt(%assetPath);
|
||||
|
||||
%newAssetPath = %assetFilepath @ "/" @ %newAssetName @ ".asset.taml";
|
||||
|
||||
%copiedSuccess = pathCopy(%assetPath, %newAssetPath);
|
||||
|
||||
if(!%copiedSuccess)
|
||||
return "";
|
||||
|
||||
replaceInFile(%newAssetPath, %this.assetName, %newAssetName);
|
||||
|
||||
%looseFilesList = AssetDatabase.getAssetLooseFiles(%this.getAssetId());
|
||||
|
||||
for(%i=0; %i < getFieldCount(%looseFilesList); %i++)
|
||||
{
|
||||
%looseFile = getField(%looseFilesList, %i);
|
||||
|
||||
if(!isFile(%looseFile))
|
||||
{
|
||||
errorf("GenericAsset::onMovePath() - could not find loose file: " @ %looseFile);
|
||||
continue;
|
||||
}
|
||||
|
||||
%newLooseFileName = strReplace(fileName(%looseFile), %this.assetName, %newAssetName);
|
||||
%looseFileExt = fileExt(%looseFile);
|
||||
|
||||
echo("GenericAsset::onDuplicate() - renamed loose file from: " @ %looseFile @ " to: " @ %assetPath @ "/" @ %newLooseFileName @ %looseFileExt);
|
||||
|
||||
%looseFileNewPath = %assetPath @ "/" @ %newLooseFileName @ %looseFileExt;
|
||||
%copiedSuccess = pathCopy(%looseFile, %looseFileNewPath);
|
||||
if(!%copiedSuccess)
|
||||
{
|
||||
errorf("GenericAsset::onDuplicate() - failed to duplicate loose file: " @ %looseFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
replaceInFile(%looseFileNewPath, %this.assetName, %newAssetName);
|
||||
}
|
||||
}
|
||||
|
||||
%module = getModuleFromAddress(%newAssetPath);
|
||||
|
||||
//Add with the new file
|
||||
$CurrentAssetBrowser.addDeclaredAsset(%module, %newAssetPath);
|
||||
|
||||
$CurrentAssetBrowser.refresh();
|
||||
|
||||
return %newAssetPath;
|
||||
}
|
||||
|
||||
//Called when the asset is deleted. This would be where and associated files
|
||||
//are also removed from the system
|
||||
function GenericAsset::onDelete(%this)
|
||||
{
|
||||
AssetDatabase.deleteAsset(%this.getAssetId(), true);
|
||||
|
||||
$CurrentAssetBrowser.refresh();
|
||||
}
|
||||
|
||||
//Called when the asset is moved from one file path to another. Associated files would be
|
||||
//likewise moved
|
||||
function GenericAsset::onMovePath(%this, %destinationPath)
|
||||
{
|
||||
%assetPath = makeFullPath($CurrentAssetBrowser.getAssetFilePath(%this.getAssetId()));
|
||||
|
||||
moveAssetFile(%this, %destinationPath);
|
||||
|
||||
%looseFilesList = AssetDatabase.getAssetLooseFiles(%this.getAssetId());
|
||||
for(%i=0; %i < getFieldCount(%looseFilesList); %i++)
|
||||
{
|
||||
%looseFile = getField(%looseFilesList, %i);
|
||||
|
||||
moveAssetLooseFile(%looseFile, %destinationPath);
|
||||
}
|
||||
|
||||
AssetDatabase.refreshAsset(%this.getAssetId());
|
||||
|
||||
$CurrentAssetBrowser.refresh();
|
||||
}
|
||||
|
||||
function GenericAsset::onMoveModule(%this, %destinationPath)
|
||||
{
|
||||
%assetPath = makeFullPath($CurrentAssetBrowser.getAssetFilePath(%this.getAssetId()));
|
||||
|
||||
%newAssetPath = moveAssetFile(%this, %destinationPath);
|
||||
|
||||
%looseFilesList = AssetDatabase.getAssetLooseFiles(%this.getAssetId());
|
||||
for(%i=0; %i < getFieldCount(%looseFilesList); %i++)
|
||||
{
|
||||
%looseFile = getField(%looseFilesList, %i);
|
||||
|
||||
moveAssetLooseFile(%looseFile, %destinationPath);
|
||||
}
|
||||
|
||||
%targetModule = $CurrentAssetBrowser.dirHandler.getModuleFromAddress(%destinationPath);
|
||||
|
||||
AssetDatabase.removeDeclaredAsset(%this.getAssetId());
|
||||
AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
|
||||
|
||||
$CurrentAssetBrowser.refresh();
|
||||
}
|
||||
|
||||
//Called when there is an InspectorType field for this AssetType and a Asset preview
|
||||
//has been dragged and dropped from the AssetBrowser onto this field in the inspector
|
||||
//Generally this would see the field assigned with the dropped asset's ID
|
||||
/*function GuiInspectorType<AssetType>Ptr::onControlDropped(%this, %payload, %position)
|
||||
{
|
||||
}*/
|
||||
|
||||
//Called when the asset is edited. This can either open the asset in the respective
|
||||
//editor(MaterialAsset opens MaterialEd, etc) or performs some other action, such as loading
|
||||
//a LevelAsset in the editor or possibly opening an associated file in a system program for editing
|
||||
function GenericAsset::onEdit(%this)
|
||||
{
|
||||
echo("GenericAsset::onEdit() - " @ %this);
|
||||
}
|
||||
|
||||
//Called when the asset's Preview has been right-clicked to do a context popup menu
|
||||
//Allows for special-menu population per-type if desired, as not all assets will or should
|
||||
//offer the same 'actions' for editing and management
|
||||
function GenericAsset::onShowActionMenu(%this)
|
||||
{
|
||||
if( !isObject( EditAssetPopup ) )
|
||||
{
|
||||
new PopupMenu( EditAssetPopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
|
||||
jumpFileName = "";
|
||||
jumpLineNumber = "";
|
||||
};
|
||||
}
|
||||
|
||||
//Regen the menu so we're fully up and current with options and references
|
||||
EditAssetPopup.clearItems();
|
||||
|
||||
EditAssetPopup.item[ 0 ] = "Edit Asset" TAB "" TAB $CurrentAssetBrowser @ ".editAsset();";
|
||||
EditAssetPopup.item[ 1 ] = "Rename Asset" TAB "" TAB $CurrentAssetBrowser @ ".renameAsset();";
|
||||
EditAssetPopup.item[ 2 ] = "Reload Asset" TAB "" TAB $CurrentAssetBrowser @ ".refreshAsset();";
|
||||
EditAssetPopup.item[ 3 ] = "Asset Properties" TAB "" TAB $CurrentAssetBrowser @ ".editAssetInfo();";
|
||||
EditAssetPopup.item[ 4 ] = "-";
|
||||
EditAssetPopup.item[ 5 ] = "Duplicate Asset" TAB "" TAB $CurrentAssetBrowser @ ".duplicateAsset();";
|
||||
EditAssetPopup.item[ 6 ] = "-";
|
||||
EditAssetPopup.item[ 7 ] = "Regenerate Preview Image" TAB "" TAB $CurrentAssetBrowser @ ".regeneratePreviewImage();";
|
||||
EditAssetPopup.item[ 8 ] = "-";
|
||||
EditAssetPopup.item[ 9 ] = "Re-Import Asset" TAB "" TAB $CurrentAssetBrowser @ ".reImportAsset();";
|
||||
EditAssetPopup.item[ 10 ] = "-";
|
||||
EditAssetPopup.item[ 11 ] = "Open File Location" TAB "" TAB $CurrentAssetBrowser @ ".openFileLocation();";
|
||||
EditAssetPopup.item[ 12 ] = "-";
|
||||
EditAssetPopup.item[ 13 ] = "Delete Asset" TAB "" TAB $CurrentAssetBrowser @ ".deleteAsset();";
|
||||
|
||||
%assetId = %this.getAssetId();
|
||||
%assetType = AssetDatabase.getAssetType(%assetId);
|
||||
|
||||
EditAssetPopup.objectData = %assetId;
|
||||
EditAssetPopup.objectType = %assetType;
|
||||
|
||||
EditAssetPopup.reloadItems();
|
||||
|
||||
EditAssetPopup.showPopup(Canvas);
|
||||
|
||||
$CurrentAssetBrowser.popupMenu = EditAssetPopup;
|
||||
}
|
||||
|
||||
//Called when editing the asset's properties, generally presented via an inspector
|
||||
//This function allows for special type handling if just inspecting the Type's object
|
||||
//is insufficient
|
||||
function GenericAsset::onEditProperties(%this)
|
||||
{
|
||||
Canvas.pushDialog(AssetBrowser_editAsset);
|
||||
|
||||
AssetBrowser_editAssetWindow.text = "Asset Properties - " @ %this.getAssetId();
|
||||
|
||||
AssetEditInspector.tempAsset = %this.deepClone();
|
||||
|
||||
AssetEditInspector.inspect(AssetEditInspector.tempAsset);
|
||||
AssetBrowser_editAsset.editedObjectData = %this.getAssetId();
|
||||
AssetBrowser_editAsset.editedObject = AssetEditInspector.tempAsset;
|
||||
AssetBrowser_editAsset.editedObjectType = AssetDatabase.getAssetType(%this.getAssetId());
|
||||
|
||||
//remove some of the groups we don't need:
|
||||
for(%i=0; %i < AssetEditInspector.getCount(); %i++)
|
||||
{
|
||||
%caption = AssetEditInspector.getObject(%i).caption;
|
||||
|
||||
if(%caption $= "Ungrouped" || %caption $= "Object" || %caption $= "Editing"
|
||||
|| %caption $= "Persistence" || %caption $= "Dynamic Fields")
|
||||
{
|
||||
AssetEditInspector.remove(AssetEditInspector.getObject(%i));
|
||||
%i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Called when the AssetType has it's properties saved from the onEditProperties process
|
||||
function GenericAsset::onSaveProperties(%this)
|
||||
{
|
||||
%assetId = %this.getAssetId();
|
||||
%file = AssetDatabase.getAssetFilePath(%assetId);
|
||||
%success = TamlWrite(AssetBrowser_editAsset.editedObject, %file);
|
||||
|
||||
AssetDatabase.releaseAsset(%assetId);
|
||||
|
||||
$CurrentAssetBrowser.reloadAsset(%assetId);
|
||||
|
||||
$CurrentAssetBrowser.refresh();
|
||||
|
||||
%this.refreshAsset();
|
||||
}
|
||||
|
||||
//Called when the asset's Preview has been dragged and dropped into the world editor
|
||||
//This would usually spawn an associated instance, or a scene object that can utilize the
|
||||
//asset in question(ie, Dropping a SoundAsset spawns a SoundEmitter)
|
||||
function GenericAsset::onWorldEditorDropped(%this, %position)
|
||||
{
|
||||
echo("GenericAsset::onWorldEditorDropped() - " @ %this @ ", " @ %position);
|
||||
}
|
||||
|
||||
//Called when the asset's Preview has been dragged and dropped into the GUI editor
|
||||
//This would usually spawn an associated instance, or a gui object that can utilize the
|
||||
//asset in question(ie, Dropping a SoundAsset spawns a guiAudioCtrl)
|
||||
function GenericAsset::onGuiEditorDropped(%this, %position)
|
||||
{
|
||||
echo("GenericAsset::onGuiEditorDropped() - " @ %this @ ", " @ %position);
|
||||
}
|
||||
|
||||
//An example case of handling other specialized editors, such as dropping a Datablock
|
||||
//Preview into the DatablockEditor. This would be very case-by-case
|
||||
/*function GenericAsset::on<Editor>EditorDropped()
|
||||
{
|
||||
}*/
|
||||
|
||||
//Called when the asset has been detected as having had files on the system changed. Allows
|
||||
//for automatically responding to those changes, such as re-execing script files
|
||||
function GenericAsset::onChanged(%this)
|
||||
{
|
||||
echo("GenericAsset::onChanged() - " @ %this);
|
||||
}
|
||||
|
||||
function GenericAsset::onStatusChanged(%this, %newStstus)
|
||||
{
|
||||
echo("GenericAsset::onStatusChanged() - " @ %this @ ", " @ %newStstus);
|
||||
}
|
||||
|
|
@ -1,9 +1,12 @@
|
|||
function AssetBrowser::createGUIAsset(%this)
|
||||
AssetBrowser::registerFileType("GUIFileType", "GUI Files", ".gui;.gui.dso", false);
|
||||
AssetBrowser::registerAssetType("GUIAsset", "GUIs");
|
||||
|
||||
function GUIAsset::onCreateNew()
|
||||
{
|
||||
%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||
%moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
%assetName = $CurrentAssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%assetPath = NewAssetTargetAddress.getText() @ "/";
|
||||
|
||||
|
|
@ -24,7 +27,7 @@ function AssetBrowser::createGUIAsset(%this)
|
|||
%file = new FileObject();
|
||||
%templateFile = new FileObject();
|
||||
|
||||
%guiTemplateCodeFilePath = %this.templateFilesPath @ "guiFile.gui.template";
|
||||
%guiTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "guiFile.gui.template";
|
||||
|
||||
if(%file.openForWrite(%guipath) && %templateFile.openForRead(%guiTemplateCodeFilePath))
|
||||
{
|
||||
|
|
@ -45,10 +48,10 @@ function AssetBrowser::createGUIAsset(%this)
|
|||
%file.close();
|
||||
%templateFile.close();
|
||||
|
||||
warnf("CreateGUIAsset - Something went wrong and we couldn't write the GUI file!");
|
||||
warn("GUIAsset::onCreateNew() - Something went wrong and we couldn't write the GUI file!");
|
||||
}
|
||||
|
||||
%scriptTemplateCodeFilePath = %this.templateFilesPath @ "guiFile." @ $TorqueScriptFileExtension @ ".template";
|
||||
%scriptTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "guiFile." @ $TorqueScriptFileExtension @ ".template";
|
||||
|
||||
if(%file.openForWrite(%scriptPath) && %templateFile.openForRead(%scriptTemplateCodeFilePath))
|
||||
{
|
||||
|
|
@ -69,7 +72,7 @@ function AssetBrowser::createGUIAsset(%this)
|
|||
%file.close();
|
||||
%templateFile.close();
|
||||
|
||||
warnf("CreateGUIAsset - Something went wrong and we couldn't write the GUI script file!");
|
||||
warn("GUIAsset::onCreateNew() - Something went wrong and we couldn't write the GUI script file!");
|
||||
}
|
||||
|
||||
//load the gui
|
||||
|
|
@ -79,31 +82,17 @@ function AssetBrowser::createGUIAsset(%this)
|
|||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
|
||||
AssetBrowser.refresh();
|
||||
$CurrentAssetBrowser.refresh();
|
||||
|
||||
return %tamlpath;
|
||||
}
|
||||
|
||||
function AssetBrowser::inspectImportingGUIAsset(%this, %assetItem)
|
||||
function GUIAsset::onEdit(%this)
|
||||
{
|
||||
AssetImportCtrl-->NewAssetsInspector.startGroup("GUI");
|
||||
|
||||
AssetImportCtrl-->NewAssetsInspector.addField("GUIFile", "GUI File Path", "filename", "Intended usage case of this image. Used to map to material slots and set up texture profiles.", "",
|
||||
"", %assetItem);
|
||||
|
||||
//Make this a callback so that if it's set we can callback to a validator function
|
||||
//This function(and others for other asset types) would check if the loosefile audit window is open, and if it is, remove the file from the list
|
||||
AssetImportCtrl-->NewAssetsInspector.addField("ScriptFile", "Script File Path", "filename", "Intended usage case of this image. Used to map to material slots and set up texture profiles.", "",
|
||||
"", %assetItem);
|
||||
AssetImportCtrl-->NewAssetsInspector.endGroup();
|
||||
}
|
||||
|
||||
function AssetBrowser::editGUIAsset(%this, %assetDef)
|
||||
{
|
||||
if(!isObject(%assetDef.assetName))
|
||||
if(!isObject(%this.assetName))
|
||||
{
|
||||
exec(%assetDef.GUIFilePath);
|
||||
exec(%assetDef.mScriptFilePath);
|
||||
exec(%this.GUIFilePath);
|
||||
exec(%this.mScriptFilePath);
|
||||
}
|
||||
|
||||
if( EditorIsActive() && !GuiEditor.toggleIntoEditorGui )
|
||||
|
|
@ -112,63 +101,20 @@ function AssetBrowser::editGUIAsset(%this, %assetDef)
|
|||
if( !$InGuiEditor && !GuiEditorIsActive() )
|
||||
GuiEditor.open();
|
||||
|
||||
GuiEditContent(%assetDef.assetName);
|
||||
GuiEditContent(%this.assetName);
|
||||
}
|
||||
|
||||
//Renames the asset
|
||||
function AssetBrowser::renameGUIAsset(%this, %assetDef, %newAssetName)
|
||||
function GUIAsset::buildBrowserElement(%this, %previewData)
|
||||
{
|
||||
%newScriptLooseFilename = renameAssetLooseFile(%assetDef.scriptFile, %newAssetName);
|
||||
|
||||
if(!%newScriptLooseFilename $= "")
|
||||
return;
|
||||
|
||||
%newGUILooseFilename = renameAssetLooseFile(%assetDef.guiFile, %newAssetName);
|
||||
|
||||
if(!%newGUILooseFilename $= "")
|
||||
return;
|
||||
|
||||
%assetDef.scriptFile = %newScriptLooseFilename;
|
||||
%assetDef.guiFile = %newGUILooseFilename;
|
||||
%assetDef.saveAsset();
|
||||
|
||||
renameAssetFile(%assetDef, %newAssetName);
|
||||
}
|
||||
|
||||
//Deletes the asset
|
||||
function AssetBrowser::deleteGUIAsset(%this, %assetDef)
|
||||
{
|
||||
AssetDatabase.deleteAsset(%assetDef.getAssetId(), true);
|
||||
}
|
||||
|
||||
//Moves the asset to a new path/module
|
||||
function AssetBrowser::moveGUIAsset(%this, %assetDef, %destination)
|
||||
{
|
||||
%currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
|
||||
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
|
||||
|
||||
%newAssetPath = moveAssetFile(%assetDef, %destination);
|
||||
|
||||
if(%newAssetPath $= "")
|
||||
return false;
|
||||
|
||||
moveAssetLooseFile(%assetDef.getGUIPath(), %destination);
|
||||
moveAssetLooseFile(%assetDef.getScriptPath(), %destination);
|
||||
|
||||
AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
|
||||
AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
|
||||
}
|
||||
|
||||
|
||||
function AssetBrowser::buildGUIAssetPreview(%this, %assetDef, %previewData)
|
||||
{
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetPath = %assetDef.GUIFilePath;
|
||||
%previewData.assetName = %this.assetName;
|
||||
%previewData.assetPath = %this.getGUIPath();
|
||||
%previewData.doubleClickCommand = "";
|
||||
|
||||
%previewData.previewImage = "ToolsModule:guiIcon_image";
|
||||
|
||||
%previewData.assetFriendlyName = %assetDef.assetName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\nDefinition Path: " @ %assetDef.getScriptPath();
|
||||
}
|
||||
%previewData.assetFriendlyName = %this.assetName;
|
||||
%previewData.assetDesc = %this.description;
|
||||
%previewData.tooltip = "Asset Name: " @ %this.assetName @
|
||||
"\nGUI Path: " @ %this.getGUIPath() @
|
||||
"\nScript Path: " @ %this.getScriptPath();
|
||||
}
|
||||
|
|
@ -1,202 +1,33 @@
|
|||
function AssetBrowser::prepareImportImageAsset(%this, %assetItem)
|
||||
{
|
||||
if((getAssetImportConfigValue("Images/GenerateMaterialOnImport", "1") == 1 && %assetItem.parentAssetItem $= "") || %assetItem.parentAssetItem !$= "")
|
||||
{
|
||||
//First, see if this already has a suffix of some sort based on our import config logic. Many content pipeline tools like substance automatically appends them
|
||||
%foundSuffixType = parseImageSuffixes(%assetItem);
|
||||
|
||||
if(%foundSuffixType $= "")
|
||||
{
|
||||
%noSuffixName = %assetItem.AssetName;
|
||||
}
|
||||
else
|
||||
{
|
||||
%suffixPos = strpos(strlwr(%assetItem.AssetName), strlwr(%assetItem.ImageType), 0);
|
||||
%noSuffixName = getSubStr(%assetItem.AssetName, 0, %suffixPos);
|
||||
}
|
||||
|
||||
//Check if our material already exists
|
||||
//First, lets double-check that we don't already have an
|
||||
%materialAsset = ImportAssetWindow.findImportingAssetByName(%noSuffixName);
|
||||
%cratedNewMaterial = false;
|
||||
|
||||
//Sanity catch in the case we have some naming convention shenanigans in play
|
||||
if(%materialAsset != 0 && %materialAsset.assetType !$= "MaterialAsset")
|
||||
%materialAsset = 0;
|
||||
|
||||
if(%materialAsset == 0)
|
||||
{
|
||||
%filePath = %assetItem.filePath;
|
||||
if(%filePath !$= "")
|
||||
%materialAsset = AssetBrowser.addImportingAsset("MaterialAsset", "", "", %noSuffixName);
|
||||
|
||||
//%materialAsset.filePath = filePath(%assetItem.filePath) @ "/" @ %noSuffixName;
|
||||
|
||||
ImportAssetItems.add(%materialAsset);
|
||||
|
||||
%cratedNewMaterial = true;
|
||||
}
|
||||
|
||||
if(isObject(%materialAsset))
|
||||
{
|
||||
if(%assetItem.parentAssetItem !$= "")
|
||||
{
|
||||
%parentIndex = %assetItem.parentAssetItem.childAssetItems.getIndexFromKey(%assetItem);
|
||||
%assetItem.parentAssetItem.childAssetItems.erase(%parentIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if we didn't have a parent until now, we're going to pull from it from our ImportAssetItems list
|
||||
%itemIndex = ImportAssetItems.getIndexFromKey(%assetItem);
|
||||
ImportAssetItems.erase(%itemIndex);
|
||||
}
|
||||
|
||||
//Establish parentage
|
||||
%materialAsset.childAssetItems.add(%assetItem);
|
||||
%assetItem.parentAssetItem = %materialAsset;
|
||||
|
||||
ImportAssetWindow.assetHeirarchyChanged = true;
|
||||
}
|
||||
|
||||
//Lets do some cleverness here. If we're generating a material we can parse like assets being imported(similar file names) but different suffixes
|
||||
//if we find these, we'll just populate into the original's material
|
||||
|
||||
//If we need to append the diffuse suffix and indeed didn't find a suffix on the name, do that here
|
||||
if(%foundSuffixType $= "")
|
||||
{
|
||||
if(getAssetImportConfigValue("Images/UseDiffuseSuffixOnOriginImg", "1") == 1)
|
||||
{
|
||||
if(%foundSuffixType $= "")
|
||||
{
|
||||
%diffuseToken = getToken(getAssetImportConfigValue("Images/DiffuseTypeSuffixes", ""), ",", 0);
|
||||
%assetItem.AssetName = %assetItem.AssetName @ %diffuseToken;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//We need to ensure that our image asset doesn't match the same name as the material asset, so if we're not trying to force the diffuse suffix
|
||||
//we'll give it a generic one
|
||||
if(%materialAsset.assetName $= %assetItem.assetName)
|
||||
{
|
||||
%assetItem.AssetName = %assetItem.AssetName @ "_image";
|
||||
}
|
||||
}
|
||||
|
||||
%foundSuffixType = "diffuse";
|
||||
}
|
||||
|
||||
if(%foundSuffixType !$= "")
|
||||
{
|
||||
//otherwise, if we have some sort of suffix, we'll want to figure out if we've already got an existing material, and should append to it
|
||||
|
||||
if(getAssetImportConfigValue("Materials/PopulateMaterialMaps", "1") == 1)
|
||||
{
|
||||
if(%foundSuffixType $= "diffuse")
|
||||
%assetItem.ImageType = "Albedo";
|
||||
else if(%foundSuffixType $= "normal")
|
||||
%assetItem.ImageType = "Normal";
|
||||
else if(%foundSuffixType $= "metalness")
|
||||
%assetItem.ImageType = "metalness";
|
||||
else if(%foundSuffixType $= "roughness")
|
||||
%assetItem.ImageType = "roughness";
|
||||
else if(%foundSuffixType $= "specular")
|
||||
%assetItem.ImageType = "specular";
|
||||
else if(%foundSuffixType $= "AO")
|
||||
%assetItem.ImageType = "AO";
|
||||
else if(%foundSuffixType $= "composite")
|
||||
%assetItem.ImageType = "composite";
|
||||
}
|
||||
}
|
||||
|
||||
//If we JUST created this material, we need to do a process pass on it to do any other setup for it
|
||||
/*if(%cratedNewMaterial)
|
||||
{
|
||||
AssetBrowser.prepareImportMaterialAsset(%materialAsset);
|
||||
}*/
|
||||
}
|
||||
AssetBrowser::registerAssetType("ImageAsset", "Images");
|
||||
|
||||
%assetItem.processed = true;
|
||||
|
||||
refreshImportAssetWindow();
|
||||
}
|
||||
|
||||
function AssetBrowser::inspectImportingImageAsset(%this, %assetItem)
|
||||
{
|
||||
AssetImportCtrl-->NewAssetsInspector.startGroup("Image");
|
||||
AssetImportCtrl-->NewAssetsInspector.addField("ImageType", "Image Type", "list", "Intended usage case of this image. Used to map to material slots and set up texture profiles.", "GUI",
|
||||
"Albedo,Normal,Composite,Roughness,AO,Metalness,Glow,GUI,Particle,Decal", %assetItem);
|
||||
|
||||
AssetImportCtrl-->NewAssetsInspector.endGroup();
|
||||
}
|
||||
|
||||
function AssetBrowser::importImageAsset(%this, %assetItem)
|
||||
{
|
||||
%moduleName = AssetImportTargetModule.getText();
|
||||
|
||||
%assetType = %assetItem.AssetType;
|
||||
%filePath = %assetItem.filePath;
|
||||
%assetName = %assetItem.assetName;
|
||||
%assetImportSuccessful = false;
|
||||
%assetId = %moduleName@":"@%assetName;
|
||||
|
||||
%assetPath = NewAssetTargetAddress.getText() @ "/";
|
||||
|
||||
%assetFullPath = %assetPath @ "/" @ fileName(%filePath);
|
||||
|
||||
%newAsset = new ImageAsset()
|
||||
{
|
||||
assetName = %assetName;
|
||||
versionId = 1;
|
||||
imageFile = makeFullPath(%filePath);
|
||||
imageType = %assetItem.imageType;
|
||||
};
|
||||
|
||||
%assetImportSuccessful = TAMLWrite(%newAsset, %assetPath @ "/" @ %assetName @ ".asset.taml");
|
||||
|
||||
//and copy the file into the relevent directory
|
||||
%doOverwrite = !AssetBrowser.isAssetReImport;
|
||||
if(!pathCopy(%filePath, %assetFullPath, %doOverwrite))
|
||||
{
|
||||
error("Unable to import asset: " @ %filePath);
|
||||
return;
|
||||
}
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName,1);
|
||||
|
||||
if(!AssetBrowser.isAssetReImport)
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %assetPath @ "/" @ %assetName @ ".asset.taml");
|
||||
else
|
||||
AssetDatabase.refreshAsset(%assetId);
|
||||
}
|
||||
|
||||
function AssetBrowser::buildImageAssetPreview(%this, %assetDef, %previewData)
|
||||
function ImageAsset::buildBrowserElement(%this, %previewData)
|
||||
{
|
||||
//%module = %this.dirHandler.getModuleFromAddress(makeRelativePath(filePath(%assetDef.getImagePath())));
|
||||
|
||||
%previewData.previewImage = %assetDef.isNamedTarget() ? "Core_Rendering:namedTarget_image" : "ToolsModule:genericAssetIcon_image";
|
||||
%previewData.previewLoaded = %assetDef.isNamedTarget() ? true : false; //if image target we are loaded, else mark for loading later.
|
||||
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetPath = %assetDef.scriptFile;
|
||||
%previewData.assetName = %this.assetName;
|
||||
%previewData.assetPath = %this.scriptFile;
|
||||
|
||||
%previewData.assetFriendlyName = %assetDef.assetName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.assetFriendlyName = %this.assetName;
|
||||
%previewData.assetDesc = %this.description;
|
||||
|
||||
//image info
|
||||
//%info = %assetDef.getImageInfo();
|
||||
|
||||
%previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\n" @
|
||||
%previewData.tooltip = "Asset Name: " @ %this.assetName @ "\n" @
|
||||
"Asset Type: Image Asset\n" @
|
||||
"Asset Definition ID: " @ %assetDef @ "\n" @
|
||||
"Image Type: " @ %assetDef.imageType @ "\n" @
|
||||
"Asset Definition ID: " @ %this @ "\n" @
|
||||
"Image Type: " @ %this.imageType @ "\n" @
|
||||
/* "Format: " @ getWord(%info, 0) @ "\n" @
|
||||
"Height: " @ getWord(%info, 1) @ "\n" @
|
||||
"Width: " @ getWord(%info, 2) @ "\n" @
|
||||
"Depth: " @ getWord(%info, 3) @ "\n" @ */
|
||||
"Image File path: " @ %assetDef.getImagePath();
|
||||
"Image File path: " @ %this.getImagePath();
|
||||
}
|
||||
|
||||
function AssetBrowser::generateImageAssetPreviewImage(%this, %previewButton, %forceRegenerate)
|
||||
function ImageAsset::generatePreviewImage(%this, %previewButton, %forceRegenerate)
|
||||
{
|
||||
if(%forceRegenerate $= "")
|
||||
%forceRegenerate = false;
|
||||
|
|
@ -205,24 +36,20 @@ function AssetBrowser::generateImageAssetPreviewImage(%this, %previewButton, %fo
|
|||
|
||||
if(!IsDirectory(%previewPath))
|
||||
{
|
||||
%this.dirHandler.createFolder(%previewPath);
|
||||
$CurrentAssetBrowser.dirHandler.createFolder(%previewPath);
|
||||
}
|
||||
|
||||
%assetId = %previewButton.moduleName @ ":" @ %previewButton.assetName;
|
||||
|
||||
%assetDef = AssetDatabase.acquireAsset(%assetId);
|
||||
|
||||
%previewFilePath = %previewPath @ %assetDef.assetName @ "_Preview.png";
|
||||
if(!isFile(%previewFilePath) || (compareFileTimes(%assetDef.getImagePath(), %previewFilePath) == 1))
|
||||
%previewFilePath = %previewPath @ %this.assetName @ "_Preview.png";
|
||||
if(!isFile(%previewFilePath) || (compareFileTimes(%this.getImagePath(), %previewFilePath) == 1))
|
||||
{
|
||||
%generatePreview = true;
|
||||
}
|
||||
|
||||
%previewAssetName = %previewButton.moduleName @ "_" @ %assetDef.assetName @ "_PreviewImage";
|
||||
%previewAssetName = %previewButton.moduleName @ "_" @ %this.assetName @ "_PreviewImage";
|
||||
|
||||
if(%generatePreview || %forceRegenerate)
|
||||
{
|
||||
%success = saveScaledImage(%assetDef.getImagePath(), %previewFilePath, EditorSettings.value("Assets/Browser/PreviewImageSize"));
|
||||
%success = saveScaledImage(%this.getImagePath(), %previewFilePath, EditorSettings.value("Assets/Browser/PreviewImageSize"));
|
||||
|
||||
if(%success)
|
||||
{
|
||||
|
|
@ -248,79 +75,40 @@ function AssetBrowser::generateImageAssetPreviewImage(%this, %previewButton, %fo
|
|||
return false; //failed to register the preview image for some reason?
|
||||
}
|
||||
}
|
||||
|
||||
%previewButton.bitmapAsset = %previewAssetName;
|
||||
return true;
|
||||
|
||||
%previewButton.bitmapAsset = %previewAssetName;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//just map the existing one then
|
||||
if(AssetDatabase.isDeclaredAsset("ToolsModule:" @ %previewAssetName))
|
||||
{
|
||||
%previewButton.bitmapAsset = "ToolsModule:" @ %previewAssetName;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//just map the existing one then
|
||||
if(AssetDatabase.isDeclaredAsset("ToolsModule:" @ %previewAssetName))
|
||||
{
|
||||
%previewButton.bitmapAsset = "ToolsModule:" @ %previewAssetName;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//Renames the asset
|
||||
function AssetBrowser::renameImageAsset(%this, %assetDef, %newAssetName)
|
||||
function ImageAsset::onShowActionMenu(%this)
|
||||
{
|
||||
%newFilename = renameAssetLooseFile(%assetDef.getImagePath(), %newAssetName);
|
||||
|
||||
if(!%newFilename $= "")
|
||||
return;
|
||||
|
||||
%assetDef.imageFile = %newFilename;
|
||||
%assetDef.saveAsset();
|
||||
|
||||
renameAssetFile(%assetDef, %newAssetName);
|
||||
GenericAsset::onShowActionMenu(%this);
|
||||
}
|
||||
|
||||
//Duplicates the asset
|
||||
function AssetBrowser::duplicateImageAsset(%this, %assetDef, %newAssetName)
|
||||
function ImageAsset::onEditProperties(%this)
|
||||
{
|
||||
%duplicatedAsset = duplicateAssetFile(%assetDef, %newAssetName);
|
||||
|
||||
%newFilename = duplicateAssetLooseFile(%assetDef.imageFile, %newAssetName);
|
||||
|
||||
if(!%newFilename $= "")
|
||||
return;
|
||||
|
||||
%module = AssetBrowser.dirHandler.getModuleFromAddress(%duplicatedAsset);
|
||||
|
||||
%dupAssetDef = AssetDatabase.acquireAsset(%module.ModuleId @ ":" @ %newAssetName);
|
||||
|
||||
%dupAssetDef.imageFile = fileName(%newFilename);
|
||||
%dupAssetDef.saveAsset();
|
||||
GenericAsset::onEditProperties(%this);
|
||||
}
|
||||
|
||||
//Deletes the asset
|
||||
function AssetBrowser::deleteImageAsset(%this, %assetDef)
|
||||
//Called when the AssetType has it's properties saved from the onEditProperties process
|
||||
function ImageAsset::onSaveProperties(%this)
|
||||
{
|
||||
AssetDatabase.deleteAsset(%assetDef.getAssetId(), true);
|
||||
GenericAsset::onSaveProperties(%this);
|
||||
}
|
||||
|
||||
//Moves the asset to a new path/module
|
||||
function AssetBrowser::moveImageAsset(%this, %assetDef, %destination)
|
||||
{
|
||||
%currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
|
||||
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
|
||||
|
||||
%newAssetPath = moveAssetFile(%assetDef, %destination);
|
||||
|
||||
if(%newAssetPath $= "")
|
||||
return false;
|
||||
|
||||
moveAssetLooseFile(%assetDef.getImagePath(), %destination);
|
||||
|
||||
AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
|
||||
AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
|
||||
}
|
||||
|
||||
function GuiInspectorTypeImageAssetPtr::onControlDropped( %this, %payload, %position )
|
||||
{
|
||||
Canvas.popDialog(EditorDragAndDropLayer);
|
||||
|
|
@ -340,176 +128,4 @@ function GuiInspectorTypeImageAssetPtr::onControlDropped( %this, %payload, %posi
|
|||
}
|
||||
|
||||
EWorldEditor.isDirty = true;
|
||||
}
|
||||
|
||||
function parseImageSuffixes(%assetItem)
|
||||
{
|
||||
//diffuse
|
||||
%suffixCount = getTokenCount(getAssetImportConfigValue("Images/DiffuseTypeSuffixes", ""), ",;");
|
||||
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
|
||||
{
|
||||
%suffixToken = getToken(getAssetImportConfigValue("Images/DiffuseTypeSuffixes", ""), ",;", %sfx);
|
||||
if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
|
||||
{
|
||||
%assetItem.ImageType = %suffixToken;
|
||||
return "diffuse";
|
||||
}
|
||||
}
|
||||
|
||||
//normal
|
||||
%suffixCount = getTokenCount(getAssetImportConfigValue("Images/NormalTypeSuffixes", ""), ",;");
|
||||
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
|
||||
{
|
||||
%suffixToken = getToken(getAssetImportConfigValue("Images/NormalTypeSuffixes", ""), ",;", %sfx);
|
||||
if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
|
||||
{
|
||||
%assetItem.ImageType = %suffixToken;
|
||||
return "normal";
|
||||
}
|
||||
}
|
||||
|
||||
//roughness
|
||||
%suffixCount = getTokenCount(getAssetImportConfigValue("Images/RoughnessTypeSuffixes", ""), ",;");
|
||||
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
|
||||
{
|
||||
%suffixToken = getToken(getAssetImportConfigValue("Images/RoughnessTypeSuffixes", ""), ",;", %sfx);
|
||||
if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
|
||||
{
|
||||
%assetItem.ImageType = %suffixToken;
|
||||
return "roughness";
|
||||
}
|
||||
}
|
||||
|
||||
//Ambient Occlusion
|
||||
%suffixCount = getTokenCount(getAssetImportConfigValue("Images/AOTypeSuffixes", ""), ",;");
|
||||
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
|
||||
{
|
||||
%suffixToken = getToken(getAssetImportConfigValue("Images/AOTypeSuffixes", ""), ",;", %sfx);
|
||||
if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
|
||||
{
|
||||
%assetItem.ImageType = %suffixToken;
|
||||
return "AO";
|
||||
}
|
||||
}
|
||||
|
||||
//metalness
|
||||
%suffixCount = getTokenCount(getAssetImportConfigValue("Images/MetalnessTypeSuffixes", ""), ",;");
|
||||
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
|
||||
{
|
||||
%suffixToken = getToken(getAssetImportConfigValue("Images/MetalnessTypeSuffixes", ""), ",;", %sfx);
|
||||
if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
|
||||
{
|
||||
%assetItem.ImageType = %suffixToken;
|
||||
return "metalness";
|
||||
}
|
||||
}
|
||||
|
||||
//composite
|
||||
%suffixCount = getTokenCount(getAssetImportConfigValue("Images/CompositeTypeSuffixes", ""), ",;");
|
||||
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
|
||||
{
|
||||
%suffixToken = getToken(getAssetImportConfigValue("Images/CompositeTypeSuffixes", ""), ",;", %sfx);
|
||||
if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
|
||||
{
|
||||
%assetItem.ImageType = %suffixToken;
|
||||
return "composite";
|
||||
}
|
||||
}
|
||||
|
||||
//specular
|
||||
/*%suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.SpecularTypeSuffixes, ",;");
|
||||
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
|
||||
{
|
||||
%suffixToken = getToken(ImportAssetWindow.activeImportConfig.SpecularTypeSuffixes, ",;", %sfx);
|
||||
if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName))
|
||||
{
|
||||
%assetItem.imageSuffixType = %suffixToken;
|
||||
return "specular";
|
||||
}
|
||||
}*/
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
function parseImagePathSuffixes(%filePath)
|
||||
{
|
||||
//diffuse
|
||||
%diffuseSuffixes = getAssetImportConfigValue("Images/DiffuseTypeSuffixes", "");
|
||||
%suffixCount = getTokenCount(%diffuseSuffixes, ",;");
|
||||
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
|
||||
{
|
||||
%suffixToken = getToken(%diffuseSuffixes, ",;", %sfx);
|
||||
if(strIsMatchExpr("*"@%suffixToken, %filePath))
|
||||
{
|
||||
return "diffuse";
|
||||
}
|
||||
}
|
||||
|
||||
//normal
|
||||
%suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.NormalTypeSuffixes, ",;");
|
||||
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
|
||||
{
|
||||
%suffixToken = getToken(ImportAssetWindow.activeImportConfig.NormalTypeSuffixes, ",;", %sfx);
|
||||
if(strIsMatchExpr("*"@%suffixToken, %filePath))
|
||||
{
|
||||
return "normal";
|
||||
}
|
||||
}
|
||||
|
||||
//roughness
|
||||
%suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.RoughnessTypeSuffixes, ",;");
|
||||
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
|
||||
{
|
||||
%suffixToken = getToken(ImportAssetWindow.activeImportConfig.RoughnessTypeSuffixes, ",;", %sfx);
|
||||
if(strIsMatchExpr("*"@%suffixToken, %filePath))
|
||||
{
|
||||
return "roughness";
|
||||
}
|
||||
}
|
||||
|
||||
//Ambient Occlusion
|
||||
%suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.AOTypeSuffixes, ",;");
|
||||
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
|
||||
{
|
||||
%suffixToken = getToken(ImportAssetWindow.activeImportConfig.AOTypeSuffixes, ",;", %sfx);
|
||||
if(strIsMatchExpr("*"@%suffixToken, %filePath))
|
||||
{
|
||||
return "AO";
|
||||
}
|
||||
}
|
||||
|
||||
//metalness
|
||||
%suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.MetalnessTypeSuffixes, ",;");
|
||||
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
|
||||
{
|
||||
%suffixToken = getToken(ImportAssetWindow.activeImportConfig.MetalnessTypeSuffixes, ",;", %sfx);
|
||||
if(strIsMatchExpr("*"@%suffixToken, %filePath))
|
||||
{
|
||||
return "metalness";
|
||||
}
|
||||
}
|
||||
|
||||
//composite
|
||||
%suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.CompositeTypeSuffixes, ",;");
|
||||
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
|
||||
{
|
||||
%suffixToken = getToken(ImportAssetWindow.activeImportConfig.CompositeTypeSuffixes, ",;", %sfx);
|
||||
if(strIsMatchExpr("*"@%suffixToken, %filePath))
|
||||
{
|
||||
return "composite";
|
||||
}
|
||||
}
|
||||
|
||||
//specular
|
||||
%suffixCount = getTokenCount(ImportAssetWindow.activeImportConfig.SpecularTypeSuffixes, ",;");
|
||||
for(%sfx = 0; %sfx < %suffixCount; %sfx++)
|
||||
{
|
||||
%suffixToken = getToken(ImportAssetWindow.activeImportConfig.SpecularTypeSuffixes, ",;", %sfx);
|
||||
if(strIsMatchExpr("*"@%suffixToken, %filePath))
|
||||
{
|
||||
return "specular";
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
|
@ -1,30 +1,20 @@
|
|||
function AssetBrowser::setupCreateNewLevelAsset(%this)
|
||||
AssetBrowser::registerAssetType("LevelAsset", "Levels");
|
||||
|
||||
function LevelAsset::setupCreateNew()
|
||||
{
|
||||
NewAssetPropertiesInspector.startGroup("Level");
|
||||
NewAssetPropertiesInspector.addField("LevelName", "Level Name", "String", "Human-readable name of new level", "", "", %this.newAssetSettings);
|
||||
NewAssetPropertiesInspector.addField("levelPreviewImage", "Level Preview Image", "Image", "Preview Image for the level", "", "", %this.newAssetSettings);
|
||||
NewAssetPropertiesInspector.addField("LevelName", "Level Name", "String", "Human-readable name of new level", "", "", $CurrentAssetBrowser.newAssetSettings);
|
||||
NewAssetPropertiesInspector.addField("levelPreviewImage", "Level Preview Image", "Image", "Preview Image for the level", "", "", $CurrentAssetBrowser.newAssetSettings);
|
||||
|
||||
//If we forcefully set it elsewhere, adhere
|
||||
if($createLevelAssetIsSubScene == true)
|
||||
%this.newAssetSettings.isSubScene = true;
|
||||
else
|
||||
%this.newAssetSettings.isSubScene = false;
|
||||
|
||||
NewAssetPropertiesInspector.addField("isSubScene", "Is SubScene", "bool", "Is this levelAsset intended as a subScene", %this.newAssetSettings.isSubScene, "", %this.newAssetSettings);
|
||||
|
||||
NewAssetPropertiesInspector.endGroup();
|
||||
}
|
||||
|
||||
function AssetImporter::importLevelAsset(%this, %assetItem)
|
||||
function LevelAsset::onCreateNew(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function AssetBrowser::createLevelAsset(%this)
|
||||
{
|
||||
%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||
%moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
%assetName = $CurrentAssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%assetPath = NewAssetTargetAddress.getText() @ "/";
|
||||
|
||||
|
|
@ -43,10 +33,10 @@ function AssetBrowser::createLevelAsset(%this)
|
|||
PostFXPresetFile = %assetName @ ".postfxpreset." @ $TorqueScriptFileExtension;
|
||||
ForestFile = %assetName @ ".forest";
|
||||
NavmeshFile = %assetName @ ".nav";
|
||||
LevelName = AssetBrowser.newAssetSettings.levelName;
|
||||
AssetDescription = AssetBrowser.newAssetSettings.description;
|
||||
PreviewImage = AssetBrowser.newAssetSettings.levelPreviewImage;
|
||||
isSubScene = AssetBrowser.newAssetSettings.isSubScene;
|
||||
LevelName = $CurrentAssetBrowser.newAssetSettings.levelName;
|
||||
AssetDescription = $CurrentAssetBrowser.newAssetSettings.description;
|
||||
PreviewImage = $CurrentAssetBrowser.newAssetSettings.levelPreviewImage;
|
||||
isSubScene = $CurrentAssetBrowser.newAssetSettings.isSubScene;
|
||||
};
|
||||
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
|
@ -90,219 +80,42 @@ function AssetBrowser::createLevelAsset(%this)
|
|||
|
||||
if(!%addSuccess)
|
||||
{
|
||||
error("AssetBrowser::createLevelAsset() - failed to add declared asset: " @ %tamlpath @ " for module: " @ %moduleDef);
|
||||
error("LevelAsset::onCreateNew() - failed to add declared asset: " @ %tamlpath @ " for module: " @ %moduleDef);
|
||||
}
|
||||
|
||||
AssetBrowser.refresh();
|
||||
$CurrentAssetBrowser.refresh();
|
||||
|
||||
if(%addSuccess && isObject($createAndAssignField))
|
||||
{
|
||||
$createAndAssignField.apply(%moduleName @ ":" @ %assetName);
|
||||
$createAndAssignField = "";
|
||||
}
|
||||
|
||||
return %tamlpath;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//SubScene derivative
|
||||
//==============================================================================
|
||||
function AssetBrowser::setupCreateNewSubScene(%this)
|
||||
function LevelAsset::onEdit(%this)
|
||||
{
|
||||
%this.newAssetSettings.isSubScene = true;
|
||||
%this.newAssetSettings.assetType = "LevelAsset";
|
||||
schedule( 1, 0, "EditorOpenMission", %this);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
||||
function AssetBrowser::editLevelAsset(%this, %assetDef)
|
||||
function LevelAsset::buildBrowserElement(%this, %previewData)
|
||||
{
|
||||
echo("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
|
||||
echo(%assetDef @ ".isSubScene = " @ %assetDef.isSubScene);
|
||||
if(!%assetDef.isSubScene)
|
||||
schedule( 1, 0, "EditorOpenMission", %assetDef);
|
||||
}
|
||||
|
||||
//Renames the asset
|
||||
function AssetBrowser::renameLevelAsset(%this, %assetDef, %newAssetName)
|
||||
{
|
||||
%newFilename = renameAssetLooseFile(%assetDef.LevelFile, %newAssetName);
|
||||
%previewData.assetName = %this.assetName;
|
||||
%previewData.assetPath = %this.getLevelPath();
|
||||
%previewData.doubleClickCommand = "schedule( 1, 0, \"EditorOpenMission\", "@%this@");";
|
||||
|
||||
if(!%newFilename $= "")
|
||||
return;
|
||||
|
||||
//TODO the other loose files
|
||||
|
||||
%assetDef.LevelFile = %newFilename;
|
||||
%assetDef.saveAsset();
|
||||
|
||||
renameAssetFile(%assetDef, %newAssetName);
|
||||
}
|
||||
|
||||
//Duplicates the asset
|
||||
function AssetBrowser::duplicateLevelAsset(%this, %assetDef, %newAssetName)
|
||||
{
|
||||
%duplicatedAsset = duplicateAssetFile(%assetDef, %newAssetName);
|
||||
|
||||
%newFilename = duplicateAssetLooseFile(%assetDef.LevelFile, %newAssetName);
|
||||
|
||||
if(!%newFilename $= "")
|
||||
return;
|
||||
|
||||
%module = AssetBrowser.dirHandler.getModuleFromAddress(%duplicatedAsset);
|
||||
|
||||
%dupAssetDef = AssetDatabase.acquireAsset(%module.ModuleId @ ":" @ %newAssetName);
|
||||
|
||||
%dupAssetDef.LevelFile = fileName(%newFilename);
|
||||
%dupAssetDef.saveAsset();
|
||||
}
|
||||
|
||||
//Deletes the asset
|
||||
function AssetBrowser::deleteLevelAsset(%this, %assetDef)
|
||||
{
|
||||
AssetDatabase.deleteAsset(%assetDef.getAssetId(), true);
|
||||
}
|
||||
|
||||
//Moves the asset to a new path/module
|
||||
function AssetBrowser::moveLevelAsset(%this, %assetDef, %destination)
|
||||
{
|
||||
%currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
|
||||
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
|
||||
|
||||
%newAssetPath = moveAssetFile(%assetDef, %destination);
|
||||
|
||||
if(%newAssetPath $= "")
|
||||
return false;
|
||||
|
||||
moveAssetLooseFile(%assetDef.getLevelPath(), %destination);
|
||||
moveAssetLooseFile(%assetDef.getPreviewImagePath(), %destination);
|
||||
moveAssetLooseFile(%assetDef.getPostFXPresetPath(), %destination);
|
||||
moveAssetLooseFile(%assetDef.getDecalsPath(), %destination);
|
||||
moveAssetLooseFile(%assetDef.getForestPath(), %destination);
|
||||
moveAssetLooseFile(%assetDef.getNavmeshPath(), %destination);
|
||||
|
||||
AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
|
||||
AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
|
||||
}
|
||||
|
||||
function AssetBrowser::buildLevelAssetPreview(%this, %assetDef, %previewData)
|
||||
{
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetPath = %assetDef.getLevelPath();
|
||||
|
||||
if(%this.selectMode || %assetDef.isSubScene)
|
||||
{
|
||||
%previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );";
|
||||
}
|
||||
else
|
||||
{
|
||||
%previewData.doubleClickCommand = "schedule( 1, 0, \"EditorOpenMission\", "@%assetDef@");";
|
||||
}
|
||||
|
||||
%levelPreviewImage = %assetDef.PreviewImage;
|
||||
%levelPreviewImage = %this.PreviewImage;
|
||||
|
||||
if(isFile(%levelPreviewImage))
|
||||
%previewData.previewImage = %levelPreviewImage;
|
||||
else
|
||||
%previewData.previewImage = "ToolsModule:levelIcon_image";
|
||||
|
||||
%previewData.assetFriendlyName = %assetDef.assetName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\n" @
|
||||
%previewData.assetFriendlyName = %this.assetName;
|
||||
%previewData.assetDesc = %this.description;
|
||||
%previewData.tooltip = "Asset Name: " @ %this.assetName @ "\n" @
|
||||
"Asset Type: Level Asset\n" @
|
||||
"Asset Definition ID: " @ %assetDef @ "\n" @
|
||||
"Level File path: " @ %assetDef.getLevelPath();
|
||||
}
|
||||
|
||||
function createAndAssignLevelAsset(%moduleName, %assetName)
|
||||
{
|
||||
if(AssetDatabase.isDeclaredAsset(%moduleName))
|
||||
$createAndAssignField.apply(%moduleName);
|
||||
else
|
||||
$createAndAssignField.apply(%moduleName @ ":" @ %assetName);
|
||||
}
|
||||
|
||||
function EWorldEditor::createSelectedAsSubScene( %this, %object )
|
||||
{
|
||||
//create new level asset here
|
||||
AssetBrowser.setupCreateNewAsset("SubScene", AssetBrowser.selectedModule, "finishCreateSelectedAsSubScene");
|
||||
%this.contextActionObject = %object;
|
||||
}
|
||||
|
||||
function finishCreateSelectedAsSubScene(%assetId)
|
||||
{
|
||||
echo("finishCreateSelectedAsSubScene");
|
||||
|
||||
%subScene = new SubScene() {
|
||||
levelAsset = %assetId;
|
||||
};
|
||||
|
||||
%levelAssetDef = AssetDatabase.acquireAsset(%assetId);
|
||||
%levelFilePath = %levelAssetDef.getLevelPath();
|
||||
|
||||
//write out to file
|
||||
EWorldEditor.contextActionObject.save(%levelFilePath);
|
||||
|
||||
AssetDatabase.releaseAsset(%assetId);
|
||||
|
||||
getRootScene().add(%subScene);
|
||||
|
||||
EWorldEditor.contextActionObject.delete();
|
||||
|
||||
%subScene.load();
|
||||
|
||||
%subScene.recalculateBounds();
|
||||
|
||||
%scalar = $SubScene::createScalar;
|
||||
if(%scalar $= "")
|
||||
%scalar = 1.5;
|
||||
|
||||
//pad for loading boundary
|
||||
%subScene.scale = VectorScale(%subScene.scale, %scalar);
|
||||
}
|
||||
|
||||
function GuiInspectorTypeLevelAssetPtr::onControlDropped( %this, %payload, %position )
|
||||
{
|
||||
Canvas.popDialog(EditorDragAndDropLayer);
|
||||
|
||||
// Make sure this is a color swatch drag operation.
|
||||
if( !%payload.parentGroup.isInNamespaceHierarchy( "AssetPreviewControlType_AssetDrop" ) )
|
||||
return;
|
||||
|
||||
%assetType = %payload.assetType;
|
||||
%module = %payload.moduleName;
|
||||
%assetName = %payload.assetName;
|
||||
|
||||
if(%assetType $= "LevelAsset")
|
||||
{
|
||||
%cmd = %this @ ".apply(\""@ %module @ ":" @ %assetName @ "\");";
|
||||
eval(%cmd);
|
||||
}
|
||||
|
||||
EWorldEditor.isDirty = true;
|
||||
}
|
||||
|
||||
function AssetBrowser::onLevelAssetEditorDropped(%this, %assetDef, %position)
|
||||
{
|
||||
%assetId = %assetDef.getAssetId();
|
||||
|
||||
if(!%assetDef.isSubScene)
|
||||
{
|
||||
errorf("Cannot drag-and-drop LevelAsset into WorldEditor");
|
||||
return;
|
||||
}
|
||||
|
||||
%newSubScene = new SubScene()
|
||||
{
|
||||
position = %position;
|
||||
levelAsset = %assetId;
|
||||
};
|
||||
|
||||
getScene(0).add(%newSubScene);
|
||||
|
||||
%newSubScene.load();
|
||||
%newSubScene.recalculateBounds();
|
||||
|
||||
EWorldEditor.clearSelection();
|
||||
EWorldEditor.selectObject(%newSubScene);
|
||||
|
||||
EWorldEditor.dropSelection();
|
||||
|
||||
EWorldEditor.isDirty = true;
|
||||
|
||||
MECreateUndoAction::submit(%newSubScene );
|
||||
"Asset Definition ID: " @ %this @ "\n" @
|
||||
"Level File path: " @ %this.getLevelPath();
|
||||
}
|
||||
|
|
@ -1,14 +1,17 @@
|
|||
function AssetBrowser::buildLooseFilePreview(%this, %assetDef, %previewData)
|
||||
AssetBrowser::registerFileType("NonAssetLooseFile", "Loose Files", "-");
|
||||
|
||||
function NonAssetLooseFile::buildBrowserElement(%filePath, %previewData)
|
||||
{
|
||||
%fullPath = %assetDef.dirPath @ "/" @ %assetDef.assetName;
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetPath = %fullPath;
|
||||
%fileName = fileName(%filePath);
|
||||
|
||||
%previewData.assetName = %fileName;
|
||||
%previewData.assetPath = %filePath;
|
||||
|
||||
%previewData.previewImage = "ToolsModule:looseFileIcon_image";
|
||||
|
||||
//%previewData.assetFriendlyName = %assetDef.assetName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = %fullPath;
|
||||
%previewData.assetDesc = %filePath;
|
||||
%previewData.tooltip = %filePath;
|
||||
//%previewData.doubleClickCommand = "AssetBrowser.schedule(10, \"navigateTo\",\""@ %assetDef.dirPath @ "/" @ %assetDef.assetName @"\");";//browseTo %assetDef.dirPath / %assetDef.assetName
|
||||
%previewData.doubleClickCommand = "AssetBrowser.autoImportFile(\"" @ %fullPath @ "\");";
|
||||
//%previewData.doubleClickCommand = "AssetBrowser.autoImportFile(\"" @ %fullPath @ "\");";
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
function AssetBrowser::createMaterialAsset(%this)
|
||||
AssetBrowser::registerAssetType("MaterialAsset", "Materials");
|
||||
|
||||
function MaterialAsset::createMaterialAsset(%this)
|
||||
{
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
|
|
@ -33,15 +35,15 @@ function AssetBrowser::createMaterialAsset(%this)
|
|||
return %tamlpath;
|
||||
}
|
||||
|
||||
function AssetBrowser::editMaterialAsset(%this, %assetDef)
|
||||
function MaterialAsset::onEdit(%this)
|
||||
{
|
||||
%assetDef.materialDefinitionName.reload();
|
||||
%this.materialDefinitionName.reload();
|
||||
|
||||
EditorGui.setEditor(MaterialEditorPlugin);
|
||||
|
||||
MaterialEditorGui.currentMaterialAsset = %assetDef.getAssetId();
|
||||
MaterialEditorGui.currentMaterial = %assetDef.materialDefinitionName;
|
||||
MaterialEditorGui.setActiveMaterial( %assetDef.materialDefinitionName );
|
||||
MaterialEditorGui.currentMaterialAsset = %this.getAssetId();
|
||||
MaterialEditorGui.currentMaterial = %this.materialDefinitionName;
|
||||
MaterialEditorGui.setActiveMaterial( %this.materialDefinitionName );
|
||||
|
||||
AssetBrowser.hideDialog();
|
||||
}
|
||||
|
|
@ -60,451 +62,82 @@ function AssetBrowser::renameMaterialAsset(%this, %assetDef, %newAssetName)
|
|||
renameAssetFile(%assetDef, %newAssetName);
|
||||
}
|
||||
|
||||
//Deletes the asset
|
||||
function AssetBrowser::deleteMaterialAsset(%this, %assetDef)
|
||||
{
|
||||
AssetDatabase.deleteAsset(%assetDef.getAssetId(), true);
|
||||
}
|
||||
|
||||
//Moves the asset to a new path/module
|
||||
function AssetBrowser::moveMaterialAsset(%this, %assetDef, %destination)
|
||||
{
|
||||
%currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
|
||||
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
|
||||
|
||||
%newAssetPath = moveAssetFile(%assetDef, %destination);
|
||||
|
||||
if(%newAssetPath $= "")
|
||||
return false;
|
||||
|
||||
moveAssetLooseFile(%assetDef.getScriptPath(), %destination);
|
||||
|
||||
AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
|
||||
AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
|
||||
}
|
||||
|
||||
function AssetBrowser::prepareImportMaterialAsset(%this, %assetItem)
|
||||
{
|
||||
ImportActivityLog.add("Preparing Material for Import: " @ %assetItem.assetName);
|
||||
|
||||
//Iterate over to find appropriate images for
|
||||
|
||||
//Fetch just the fileBase name
|
||||
%fileDir = filePath(%assetItem.filePath);
|
||||
%fileName = fileBase(%assetItem.filePath);
|
||||
%fileExt = fileExt(%assetItem.filePath);
|
||||
|
||||
%assetItem.generatedAsset = true;
|
||||
|
||||
//Check if we need to filter this material out or not
|
||||
if(getAssetImportConfigValue("Materials/IgnoreMaterials", "") !$= "")
|
||||
{
|
||||
%ignoredMatNamesCount = getTokenCount(getAssetImportConfigValue("Materials/IgnoreMaterials", ""), ",;");
|
||||
for(%i=0; %i < %ignoredMatNamesCount; %i++)
|
||||
{
|
||||
%ignoreName = getToken(getAssetImportConfigValue("Materials/IgnoreMaterials", ""), ",;", %i);
|
||||
|
||||
if(strIsMatchExpr(%ignoreName, %fileName))
|
||||
{
|
||||
//We fit the bill, ignore this material and skip it
|
||||
%assetItem.skip = true;
|
||||
|
||||
ImportActivityLog.add(%assetItem.assetName @ " has been ignored due to config Materials/IgnoreMaterials settings");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(getAssetImportConfigValue("Materials/PopulateMaterialMaps", "1") == 1)
|
||||
{
|
||||
ImportActivityLog.add("Attempting to Auto-Populate Material Maps");
|
||||
|
||||
for(%i=0; %i < %assetItem.childAssetItems.count(); %i++)
|
||||
{
|
||||
%childAssetItem = %assetItem.childAssetItems.getKey(%i);
|
||||
|
||||
if(!isObject(%childAssetItem) || %childAssetItem.skip || %childAssetItem.processed == true || %childAssetItem.assetType !$= "ImageAsset")
|
||||
return;
|
||||
|
||||
if(%childAssetItem.imageType $= "Albedo")
|
||||
{
|
||||
%assetItem.diffuseImageAsset = %childAssetItem;
|
||||
}
|
||||
}
|
||||
|
||||
/*%materialItemId = ImportAssetTree.findItemByObjectId(%assetItem);
|
||||
|
||||
if(%assetItem.diffuseImageAsset $= "")
|
||||
{
|
||||
%diffuseTypeSuffixes = getAssetImportConfigValue("Images/DiffuseTypeSuffixes", "");
|
||||
|
||||
%targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %diffuseTypeSuffixes);
|
||||
|
||||
if(%targetFilePath !$= "")
|
||||
{
|
||||
ImportActivityLog.add("Auto-Populated Diffuse Map Image Asset via file: " @ %targetFilePath);
|
||||
|
||||
%diffuseAsset = AssetBrowser.addImportingAsset("ImageAsset", %targetFilePath, %assetItem);
|
||||
%assetItem.diffuseImageAsset = %diffuseAsset;
|
||||
}
|
||||
}
|
||||
|
||||
//Now, iterate over our comma-delimited suffixes to see if we have any matches. We'll use the first match in each case, if any.
|
||||
if(%assetItem.normalImageAsset $= "")
|
||||
{
|
||||
%normalTypeSuffixes = getAssetImportConfigValue("Images/NormalTypeSuffixes", "");
|
||||
|
||||
//First, normal map
|
||||
%targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %normalTypeSuffixes);
|
||||
|
||||
if(%targetFilePath !$= "")
|
||||
{
|
||||
ImportActivityLog.add("Auto-Populated Normal Map Image Asset via file: " @ %targetFilePath);
|
||||
|
||||
%normalAsset = AssetBrowser.addImportingAsset("ImageAsset", %targetFilePath, %assetItem);
|
||||
%assetItem.normalImageAsset = %normalAsset;
|
||||
}
|
||||
}
|
||||
|
||||
if(%assetItem.metalImageAsset $= "")
|
||||
{
|
||||
%metalnessTypeSuffixes = getAssetImportConfigValue("Images/MetalnessTypeSuffixes", "");
|
||||
|
||||
%targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %metalnessTypeSuffixes);
|
||||
|
||||
if(%targetFilePath !$= "")
|
||||
{
|
||||
ImportActivityLog.add("Auto-Populated Metalness Map Image Asset via file: " @ %targetFilePath);
|
||||
|
||||
%metalAsset = AssetBrowser.addImportingAsset("ImageAsset", %targetFilePath, %assetItem);
|
||||
%assetItem.metalImageAsset = %metalAsset;
|
||||
}
|
||||
}
|
||||
|
||||
if(%assetItem.roughnessImageAsset $= "")
|
||||
{
|
||||
%roughnessTypeSuffixes = getAssetImportConfigValue("Images/RoughnessTypeSuffixes", "");
|
||||
|
||||
%targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %roughnessTypeSuffixes);
|
||||
|
||||
if(%targetFilePath !$= "")
|
||||
{
|
||||
ImportActivityLog.add("Auto-Populated Roughness Map Image Asset via file: " @ %targetFilePath);
|
||||
|
||||
%roughnessAsset = AssetBrowser.addImportingAsset("ImageAsset", %targetFilePath, %assetItem);
|
||||
%assetItem.roughnessImageAsset = %roughnessAsset;
|
||||
}
|
||||
}
|
||||
|
||||
if(%assetItem.smoothnessImageAsset $= "")
|
||||
{
|
||||
%smoothnessTypeSuffixes = getAssetImportConfigValue("Images/SmoothnessTypeSuffixes", "");
|
||||
|
||||
%targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %smoothnessTypeSuffixes);
|
||||
|
||||
if(%targetFilePath !$= "")
|
||||
{
|
||||
ImportActivityLog.add("Auto-Populated Smoothness Map Image Asset via file: " @ %targetFilePath);
|
||||
|
||||
%smoothnessAsset = AssetBrowser.addImportingAsset("ImageAsset", %targetFilePath, %assetItem);
|
||||
%assetItem.SmoothnessImageAsset = %smoothnessAsset;
|
||||
}
|
||||
}
|
||||
|
||||
if(%assetItem.AOImageAsset $= "")
|
||||
{
|
||||
%aoTypeSuffixes = getAssetImportConfigValue("Images/AOTypeSuffixes", "");
|
||||
|
||||
%targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %aoTypeSuffixes);
|
||||
|
||||
if(%targetFilePath !$= "")
|
||||
{
|
||||
ImportActivityLog.add("Auto-Populated AO Map Image Asset via file: " @ %targetFilePath);
|
||||
|
||||
%AOAsset = AssetBrowser.addImportingAsset("ImageAsset", %targetFilePath, %assetItem);
|
||||
%assetItem.AOImageAsset = %AOAsset;
|
||||
}
|
||||
}
|
||||
|
||||
if(%assetItem.compositeImageAsset $= "")
|
||||
{
|
||||
%compositeTypeSuffixes = getAssetImportConfigValue("Images/CompositeTypeSuffixes", "");
|
||||
|
||||
%targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %compositeTypeSuffixes);
|
||||
|
||||
if(%targetFilePath !$= "")
|
||||
{
|
||||
ImportActivityLog.add("Auto-Populated Composite Map Image Asset via file: " @ %targetFilePath);
|
||||
|
||||
%compositeAsset = AssetBrowser.addImportingAsset("ImageAsset", %targetFilePath, %assetItem);
|
||||
%assetItem.compositeImageAsset = %compositeAsset;
|
||||
}
|
||||
}
|
||||
|
||||
//If after the above we didn't find any, check to see if we should be generating one
|
||||
if(%assetItem.compositeImageAsset $= "" &&
|
||||
(%assetItem.roughnessImageAsset !$= "" || %assetItem.AOImageAsset !$= "" || %assetItem.metalnessImageAsset !$= "") &&
|
||||
getAssetImportConfigValue("Materials/CreateComposites", "1") == 1)
|
||||
{
|
||||
%assetItem.roughnessImageAsset.skip = true;
|
||||
%assetItem.AOImageAsset.skip = true;
|
||||
%assetItem.metalnessImageAsset.skip = true;
|
||||
|
||||
%compositeAssetPath = AssetBrowser.dirHandler.currentAddress @ "/";
|
||||
%saveAsPath = %compositeAssetPath @ "/" @ %assetItem.assetName @ "_composite.png";
|
||||
|
||||
ImportActivityLog.add("Auto-Generated Composite Map from ORM maps");
|
||||
|
||||
%compositeAsset = AssetBrowser.addImportingAsset("ImageAsset", "", %assetItem, %assetItem.assetName @ "_composite");
|
||||
%compositeAsset.generatedAsset = true;
|
||||
%compositeAsset.filePath = %saveAsPath;
|
||||
|
||||
%assetItem.compositeImageAsset = %compositeAsset;
|
||||
}*/
|
||||
}
|
||||
|
||||
%assetItem.processed = true;
|
||||
|
||||
refreshImportAssetWindow();
|
||||
}
|
||||
|
||||
function AssetBrowser::findMaterialMapFileWSuffix(%this, %fileDir, %filename, %fileExt, %suffixesList)
|
||||
{
|
||||
%listCount = getTokenCount(%suffixesList, ",;");
|
||||
|
||||
%foundFile = 0;
|
||||
%filePath = "";
|
||||
for(%i=0; %i < %listCount; %i++)
|
||||
{
|
||||
%entryText = getToken(%suffixesList, ",;", %i);
|
||||
|
||||
if(%fileExt $= "")
|
||||
{
|
||||
%filePath = findFirstFile(%fileDir @ "/" @ %filename @ %entryText @ ".*");
|
||||
%foundFile = isFile(%filePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
%filePath = %fileDir @ "/" @ %filename @ %entryText @ %fileExt;
|
||||
%foundFile = isFile(%filePath);
|
||||
}
|
||||
|
||||
if(%foundFile)
|
||||
{
|
||||
return %filePath;
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
function AssetBrowser::importMaterialAsset(%this, %assetItem)
|
||||
{
|
||||
%moduleName = AssetImportTargetModule.getText();
|
||||
|
||||
%assetType = %assetItem.AssetType;
|
||||
%filePath = %assetItem.filePath;
|
||||
%assetName = %assetItem.assetName;
|
||||
%assetImportSuccessful = false;
|
||||
%assetId = %moduleName@":"@%assetName;
|
||||
|
||||
%assetPath = NewAssetTargetAddress.getText() @ "/";
|
||||
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
|
||||
%sgfPath = %assetPath @ %assetName @ ".sgf";
|
||||
%scriptPath = %assetPath @ %assetName @ "." @ $TorqueScriptFileExtension;
|
||||
|
||||
%newAsset = new MaterialAsset()
|
||||
{
|
||||
assetName = %assetName;
|
||||
versionId = 1;
|
||||
shaderGraph = %sgfPath;
|
||||
scriptFile = %assetName @ "." @ $TorqueScriptFileExtension;
|
||||
materialDefinitionName = %assetName;
|
||||
};
|
||||
|
||||
//No point in indicating the original path data if it was imported in-place
|
||||
%mainPath = getMainDotCsDir();
|
||||
if(!startsWith(makeFullPath(%filePath), getMainDotCsDir()))
|
||||
{
|
||||
%newAsset.originalFilePath = %filePath;
|
||||
}
|
||||
|
||||
//check dependencies
|
||||
%dependencySlotId = 0;
|
||||
for(%i=0; %i < %assetItem.childAssetItems.count(); %i++)
|
||||
{
|
||||
%childAssetItem = %assetItem.childAssetItems.getKey(%i);
|
||||
|
||||
if(!isObject(%childAssetItem) || %childAssetItem.skip || %childAssetItem.processed == false)
|
||||
continue;
|
||||
|
||||
%depAssetType = %childAssetItem.assetType;
|
||||
if(%depAssetType $= "ImageAsset")
|
||||
{
|
||||
%matSet = "%newAsset.imageMap"@%dependencySlotId@"=\"@asset="@%moduleName@":"@%childAssetItem.assetName@"\";";
|
||||
eval(%matSet);
|
||||
%dependencySlotId++;
|
||||
}
|
||||
}
|
||||
|
||||
%assetImportSuccessful = TamlWrite(%newAsset, %tamlpath);
|
||||
|
||||
//if we're set to save a composite image, we do that first
|
||||
if(getAssetImportConfigValue("Materials/CreateComposites", "1") == 1)
|
||||
{
|
||||
//don't save a composite if we've already got one bound
|
||||
if(%assetItem.compositeImageAsset !$= "" && %assetItem.compositeImageAsset.generatedAsset)
|
||||
{
|
||||
if(%assetItem.roughnessImageAsset !$= "" || %assetItem.AOImageAsset !$= "" || %assetItem.metalnessImageAsset !$= "")
|
||||
{
|
||||
%channelKey = "0 1 2 3";
|
||||
|
||||
saveCompositeTexture(%assetItem.AOImageAsset.filePath,
|
||||
%assetItem.roughnessImageAsset.filePath,
|
||||
%assetItem.metalnessImageAsset.filePath,"",
|
||||
%channelKey,
|
||||
%assetItem.compositeImageAsset.filePath);
|
||||
|
||||
%compositeAssetId = %moduleName @ ":" @ assetItem.compositeImageAsset.assetName;
|
||||
AssetDatabase.refreshAsset(%compositeAssetId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%file = new FileObject();
|
||||
|
||||
if(%file.openForWrite(%scriptPath))
|
||||
{
|
||||
%file.writeline("//--- OBJECT WRITE BEGIN ---");
|
||||
%file.writeline("singleton Material(" @ %assetName @ ") {");
|
||||
|
||||
//TODO: pass along the shape's target material for this just to be sure
|
||||
%file.writeLine(" mapTo = \"" @ %assetName @ "\";");
|
||||
|
||||
//now we re-iterate back over our child items so we can map them correctly
|
||||
for(%i=0; %i < %assetItem.childAssetItems.count(); %i++)
|
||||
{
|
||||
%childAssetItem = %assetItem.childAssetItems.getKey(%i);
|
||||
|
||||
if(!isObject(%childAssetItem) || %childAssetItem.skip || %childAssetItem.processed == false)
|
||||
continue;
|
||||
|
||||
if(%childAssetItem.assetType $= "ImageAsset")
|
||||
{
|
||||
%mapFieldName = "";
|
||||
if(%childAssetItem.imageType $= "Albedo")
|
||||
%mapFieldName = "DiffuseMap";
|
||||
else if(%childAssetItem.imageType $= "Normal")
|
||||
%mapFieldName = "NormalMap";
|
||||
else if(%childAssetItem.imageType $= "Metalness")
|
||||
%mapFieldName = "MetalMap";
|
||||
else if(%childAssetItem.imageType $= "Roughness")
|
||||
%mapFieldName = "RoughnessMap";
|
||||
else if(%childAssetItem.imageType $= "AO")
|
||||
%mapFieldName = "AOMap";
|
||||
else if(%childAssetItem.imageType $= "Composite")
|
||||
%mapFieldName = "ORMConfigMap";
|
||||
|
||||
%path = fileName(%childAssetItem.filePath);
|
||||
%file.writeline(" "@ %mapFieldName @ "[0] = \"" @ %path @"\";");
|
||||
%file.writeline(" "@ %mapFieldName @ "Asset[0] = \"" @ %moduleName @ ":" @ %childAssetItem.assetName @"\";");
|
||||
}
|
||||
}
|
||||
%file.writeline("};");
|
||||
%file.writeline("//--- OBJECT WRITE END ---");
|
||||
|
||||
%file.close();
|
||||
}
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName,1);
|
||||
|
||||
if(!AssetBrowser.isAssetReImport)
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
else
|
||||
AssetDatabase.refreshAsset(%assetId);
|
||||
}
|
||||
|
||||
function AssetBrowser::buildMaterialAssetPreview(%this, %assetDef, %previewData, %forcePreviewRegenerate)
|
||||
function MaterialAsset::buildBrowserElement(%this, %previewData)
|
||||
{
|
||||
%previewData.previewImage = "ToolsModule:genericAssetIcon_image";
|
||||
%previewData.previewLoaded = false; //this marks it for loading progressively later
|
||||
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetPath = %assetDef.scriptFile;
|
||||
%previewData.assetName = %this.assetName;
|
||||
%previewData.assetPath = %this.scriptFile;
|
||||
|
||||
%previewData.assetFriendlyName = %assetDef.assetName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.assetFriendlyName = %this.assetName;
|
||||
%previewData.assetDesc = %this.description;
|
||||
|
||||
if(%this.selectMode)
|
||||
%previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );";
|
||||
%previewData.doubleClickCommand = $CurrentAssetBrowser @ ".selectAsset( " @ $CurrentAssetBrowser @ ".selectedAsset );";
|
||||
else
|
||||
%previewData.doubleClickCommand = "AssetBrowser.editAsset( "@%assetDef@" );";
|
||||
%previewData.doubleClickCommand = $CurrentAssetBrowser @ ".editAsset( "@%this@" );";
|
||||
|
||||
%definitionPath = %assetDef.getScriptPath();
|
||||
%definitionPath = %this.getScriptPath();
|
||||
if(%definitionPath $= "")
|
||||
%definitionPath = %assetDef.getFilename();
|
||||
%definitionPath = %this.getFilename();
|
||||
|
||||
%previewData.tooltip = "Asset Name: " @ %assetDef.assetName @
|
||||
%previewData.tooltip = "Asset Name: " @ %this.assetName @
|
||||
"\nAsset Type: Material Asset" @
|
||||
"\nAsset Definition ID: " @ %assetDef @
|
||||
"\nAsset Definition ID: " @ %this @
|
||||
"\nDefinition Path: " @ %definitionPath;
|
||||
|
||||
if(!%this.selectMode)
|
||||
if(!$CurrentAssetBrowser.selectMode)
|
||||
{
|
||||
%previewData.doubleClickCommand = "AssetBrowser.editAsset( "@%assetDef@" );";
|
||||
%previewData.doubleClickCommand = $CurrentAssetBrowser @ ".editAsset( "@%this@" );";
|
||||
}
|
||||
}
|
||||
|
||||
function AssetBrowser::generateMaterialAssetPreviewImage(%this, %previewButton, %forceRegenerate)
|
||||
function MaterialAsset::generatePreviewImage(%this, %previewButton, %forceRegenerate)
|
||||
{
|
||||
if(%forceRegenerate $= "")
|
||||
%forceRegenerate = false;
|
||||
|
||||
%assetId = %previewButton.moduleName @ ":" @ %previewButton.assetName;
|
||||
|
||||
%assetDef = AssetDatabase.acquireAsset(%assetId);
|
||||
|
||||
%module = %this.dirHandler.getModuleFromAddress(makeRelativePath(filePath(AssetDatabase.getAssetFilePath(%assetDef.getAssetId()))));
|
||||
%module = $CurrentAssetBrowser.dirHandler.getModuleFromAddress(makeRelativePath(filePath(AssetDatabase.getAssetFilePath(%this.getAssetId()))));
|
||||
%previewPath = "tools/resources/previewCache/" @ %module.moduleId @ "/";
|
||||
|
||||
if(!IsDirectory(%previewPath))
|
||||
{
|
||||
%this.dirHandler.createFolder(%previewPath);
|
||||
$CurrentAssetBrowser.dirHandler.createFolder(%previewPath);
|
||||
}
|
||||
|
||||
%generatePreview = false;
|
||||
|
||||
%previewFilePath = %previewPath @ %assetDef.assetName @ "_Preview.dds";
|
||||
%previewFilePath = %previewPath @ %this.assetName @ "_Preview.dds";
|
||||
if(!isFile(%previewFilePath))
|
||||
{
|
||||
%generatePreview = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isObject(%assetDef.materialDefinitionName))
|
||||
if(isObject(%this.materialDefinitionName))
|
||||
{
|
||||
if(compareFileTimes(%assetDef.materialDefinitionName.getDiffuseMap(0), %previewFilePath) == 1 ||
|
||||
compareFileTimes(%assetDef.materialDefinitionName.getFilename(), %previewFilePath) == 1)
|
||||
if(compareFileTimes(%this.materialDefinitionName.getDiffuseMap(0), %previewFilePath) == 1 ||
|
||||
compareFileTimes(%this.materialDefinitionName.getFilename(), %previewFilePath) == 1)
|
||||
%generatePreview = true;
|
||||
}
|
||||
}
|
||||
|
||||
%previewAssetName = %module.moduleId @ "_" @ %assetDef.assetName @ "_PreviewImage";
|
||||
%previewAssetName = %module.moduleId @ "_" @ %this.assetName @ "_PreviewImage";
|
||||
|
||||
if(%generatePreview || %forceRegenerate)
|
||||
{
|
||||
if(isObject(%assetDef.materialDefinitionName))
|
||||
if(isObject(%this.materialDefinitionName))
|
||||
{
|
||||
//real fast, we'll be 100% sure that the image resource we need is loaded
|
||||
%diffuseMapAssetId = %assetDef.materialDefinitionName.getDiffuseMapAsset(0);
|
||||
%diffuseMapAssetId = %this.materialDefinitionName.getDiffuseMapAsset(0);
|
||||
if(AssetDatabase.isDeclaredAsset(%diffuseMapAssetId))
|
||||
{
|
||||
%diffuseMapAsset = AssetDatabase.acquireAsset(%diffuseMapAssetId);
|
||||
AssetDatabase.releaseAsset(%diffuseMapAssetId);
|
||||
}
|
||||
%previewShapeDef = AssetDatabase.acquireAsset("ToolsModule:previewSphereShape");
|
||||
%generatedFilePath = %previewShapeDef.generateCachedPreviewImage(256, %assetDef.materialDefinitionName);
|
||||
%generatedFilePath = %previewShapeDef.generateCachedPreviewImage(256, %this.materialDefinitionName);
|
||||
|
||||
pathCopy(%generatedFilePath, %previewFilePath, false);
|
||||
fileDelete(%generatedFilePath);
|
||||
|
|
@ -548,7 +181,7 @@ function AssetBrowser::generateMaterialAssetPreviewImage(%this, %previewButton,
|
|||
return false;
|
||||
}
|
||||
|
||||
function AssetBrowser::onMaterialAssetEditorDropped(%this, %assetDef, %position)
|
||||
function MaterialAsset::onWorldEditorDropped(%this, %position)
|
||||
{
|
||||
//echo("DROPPED A SHAPE ON THE EDITOR WINDOW!");
|
||||
//first, see if we hit a static shape
|
||||
|
|
@ -558,26 +191,24 @@ function AssetBrowser::onMaterialAssetEditorDropped(%this, %assetDef, %position)
|
|||
%camPos = LocalClientConnection.camera.getPosition();
|
||||
%rayResult = materialRayCast(%camPos, %targetPosition, -1, 0, false);
|
||||
|
||||
%validTarget = false;
|
||||
if(%rayResult != 0)
|
||||
{
|
||||
%obj = getWord(%rayResult, 0);
|
||||
if(%obj.isMemberOfClass("TSStatic"))
|
||||
{
|
||||
//oh, cool a valid target!
|
||||
%obj.materialSlot0 = %assetDef.getAssetId();
|
||||
echo("MaterialSlot0 set to " @ %assetDef.getAssetId());
|
||||
%obj.materialSlot0 = %this.getAssetId();
|
||||
//echo("MaterialSlot0 set to " @ %this.getAssetId());
|
||||
}
|
||||
else if(%obj.isField("materialAsset"))
|
||||
{
|
||||
%obj.materialAsset = %assetDef.getAssetId();
|
||||
echo("materialAsset set to " @ %assetDef.getAssetId());
|
||||
%obj.materialAsset = %this.getAssetId();
|
||||
//echo("materialAsset set to " @ %this.getAssetId());
|
||||
}
|
||||
%obj.inspectPostApply();
|
||||
|
||||
EWorldEditor.isDirty = true;
|
||||
}
|
||||
|
||||
EWorldEditor.isDirty = true;
|
||||
|
||||
}
|
||||
|
||||
function GuiInspectorTypeMaterialAssetPtr::onControlDropped( %this, %payload, %position )
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
function AssetBrowser::createPostEffectAsset(%this)
|
||||
AssetBrowser::registerAssetType("PostEffectAsset", "Post Effects");
|
||||
|
||||
function PostEffectAsset::onCreateNew()
|
||||
{
|
||||
%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||
%moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
|
||||
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
%assetName = $CurrentAssetBrowser.newAssetSettings.assetName;
|
||||
%assetPath = NewAssetTargetAddress.getText() @ "/";
|
||||
|
||||
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
|
||||
|
|
@ -27,7 +29,7 @@ function AssetBrowser::createPostEffectAsset(%this)
|
|||
%file = new FileObject();
|
||||
%templateFile = new FileObject();
|
||||
|
||||
%postFXTemplateCodeFilePath = %this.templateFilesPath @ "postFXFile." @ $TorqueScriptFileExtension @ ".template";
|
||||
%postFXTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "postFXFile." @ $TorqueScriptFileExtension @ ".template";
|
||||
|
||||
if(%file.openForWrite(%scriptPath) && %templateFile.openForRead(%postFXTemplateCodeFilePath))
|
||||
{
|
||||
|
|
@ -37,7 +39,7 @@ function AssetBrowser::createPostEffectAsset(%this)
|
|||
%line = strreplace( %line, "@@", %assetName );
|
||||
|
||||
%file.writeline(%line);
|
||||
echo(%line);
|
||||
//echo(%line);
|
||||
}
|
||||
|
||||
%file.close();
|
||||
|
|
@ -48,11 +50,11 @@ function AssetBrowser::createPostEffectAsset(%this)
|
|||
%file.close();
|
||||
%templateFile.close();
|
||||
|
||||
warnf("CreatePostFXAsset - Something went wrong and we couldn't write the PostFX script file!");
|
||||
warn("PostEffectAsset::onCreateNew() - Something went wrong and we couldn't write the PostFX script file!");
|
||||
}
|
||||
|
||||
//hlsl shader
|
||||
%postFXTemplateCodeFilePath = %this.templateFilesPath @ "postFXFileP.hlsl.template";
|
||||
%postFXTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "postFXFileP.hlsl.template";
|
||||
|
||||
if(%file.openForWrite(%hlslPath) && %templateFile.openForRead(%postFXTemplateCodeFilePath))
|
||||
{
|
||||
|
|
@ -62,7 +64,7 @@ function AssetBrowser::createPostEffectAsset(%this)
|
|||
%line = strreplace( %line, "@@", %assetName );
|
||||
|
||||
%file.writeline(%line);
|
||||
echo(%line);
|
||||
//echo(%line);
|
||||
}
|
||||
|
||||
%file.close();
|
||||
|
|
@ -73,11 +75,11 @@ function AssetBrowser::createPostEffectAsset(%this)
|
|||
%file.close();
|
||||
%templateFile.close();
|
||||
|
||||
warnf("CreatePostFXAsset - Something went wrong and we couldn't write the PostFX hlsl file!");
|
||||
warn("PostEffectAsset::onCreateNew() - Something went wrong and we couldn't write the PostFX hlsl file!");
|
||||
}
|
||||
|
||||
//glsl shader
|
||||
%postFXTemplateCodeFilePath = %this.templateFilesPath @ "postFXFileP.glsl.template";
|
||||
%postFXTemplateCodeFilePath = $CurrentAssetBrowser.templateFilesPath @ "postFXFileP.glsl.template";
|
||||
|
||||
if(%file.openForWrite(%glslPath) && %templateFile.openForRead(%postFXTemplateCodeFilePath))
|
||||
{
|
||||
|
|
@ -87,7 +89,7 @@ function AssetBrowser::createPostEffectAsset(%this)
|
|||
%line = strreplace( %line, "@@", %assetName );
|
||||
|
||||
%file.writeline(%line);
|
||||
echo(%line);
|
||||
//echo(%line);
|
||||
}
|
||||
|
||||
%file.close();
|
||||
|
|
@ -98,72 +100,80 @@ function AssetBrowser::createPostEffectAsset(%this)
|
|||
%file.close();
|
||||
%templateFile.close();
|
||||
|
||||
warnf("CreatePostFXAsset - Something went wrong and we couldn't write the PostFX glsl file!");
|
||||
warn("PostEffectAsset::onCreateNew() - Something went wrong and we couldn't write the PostFX glsl file!");
|
||||
}
|
||||
|
||||
return %tamlpath;
|
||||
}
|
||||
|
||||
//Renames the asset
|
||||
function AssetBrowser::renamePostEffectAsset(%this, %assetDef, %newAssetName)
|
||||
function PostEffectAsset::buildBrowserElement(%this, %previewData)
|
||||
{
|
||||
%newScriptFilename = renameAssetLooseFile(%assetDef.scriptPath, %newAssetName);
|
||||
|
||||
if(!%newScriptFilename $= "")
|
||||
return;
|
||||
|
||||
%newHLSLFilename = renameAssetLooseFile(%assetDef.hlslShader, %newAssetName);
|
||||
|
||||
if(!%newHLSLFilename $= "")
|
||||
return;
|
||||
|
||||
%newGLSLFilename = renameAssetLooseFile(%assetDef.glslShader, %newAssetName);
|
||||
|
||||
if(!%newGLSLFilename $= "")
|
||||
return;
|
||||
|
||||
%assetDef.scriptPath = %newScriptFilename;
|
||||
%assetDef.hlslShader = %newHLSLFilename;
|
||||
%assetDef.glslShader = %newGLSLFilename;
|
||||
%assetDef.saveAsset();
|
||||
|
||||
renameAssetFile(%assetDef, %newAssetName);
|
||||
}
|
||||
|
||||
//Deletes the asset
|
||||
function AssetBrowser::deletePostEffectAsset(%this, %assetDef)
|
||||
{
|
||||
AssetDatabase.deleteAsset(%assetDef.getAssetId(), true);
|
||||
}
|
||||
|
||||
//Moves the asset to a new path/module
|
||||
function AssetBrowser::movePostEffectAsset(%this, %assetDef, %destination)
|
||||
{
|
||||
%currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
|
||||
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
|
||||
|
||||
%newAssetPath = moveAssetFile(%assetDef, %destination);
|
||||
|
||||
if(%newAssetPath $= "")
|
||||
return false;
|
||||
|
||||
moveAssetLooseFile(%assetDef.getScriptPath(), %destination);
|
||||
moveAssetLooseFile(%assetDef.getHLSLShaderPath(), %destination);
|
||||
moveAssetLooseFile(%assetDef.getGLSLShaderPath(), %destination);
|
||||
|
||||
AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
|
||||
AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
|
||||
}
|
||||
|
||||
function AssetBrowser::buildPostEffectAssetPreview(%this, %assetDef, %previewData)
|
||||
{
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetPath = %assetDef.scriptFilePath;
|
||||
%previewData.assetName = %this.assetName;
|
||||
%previewData.assetPath = %this.scriptFilePath;
|
||||
%previewData.doubleClickCommand = "";
|
||||
|
||||
%previewData.previewImage = "ToolsModule:postEffectIcon_image";
|
||||
|
||||
%previewData.assetFriendlyName = %assetDef.assetName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\nDefinition Path: " @ %assetDef.getFilename();
|
||||
%previewData.assetFriendlyName = %this.assetName;
|
||||
%previewData.assetDesc = %this.description;
|
||||
%previewData.tooltip = "Asset Name: " @ %this.assetName @
|
||||
"\nDefinition Path: " @ %this.getFilename();
|
||||
}
|
||||
|
||||
function PostEffectAsset::onShowActionMenu(%this)
|
||||
{
|
||||
GenericAsset::onShowActionMenu(%this);
|
||||
|
||||
if( !isObject( EditPostFXAssetSubmenuPopup ) )
|
||||
{
|
||||
new PopupMenu( EditPostFXAssetSubmenuPopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
|
||||
jumpFileName = "";
|
||||
jumpLineNumber = "";
|
||||
};
|
||||
}
|
||||
|
||||
//Regen the menu so we're fully up and current with options and references
|
||||
EditPostFXAssetSubmenuPopup.clearItems();
|
||||
|
||||
EditPostFXAssetSubmenuPopup.item[ 0 ] = "Script file" TAB "" TAB %this @ ".onEditScriptFile();";
|
||||
EditPostFXAssetSubmenuPopup.item[ 1 ] = "HLSL file" TAB "" TAB %this @ ".onEditHLSLFile();";
|
||||
EditPostFXAssetSubmenuPopup.item[ 2 ] = "GLSL file" TAB "" TAB %this @ ".onEditHLSLFile();";
|
||||
|
||||
EditPostFXAssetSubmenuPopup.reloadItems();
|
||||
|
||||
EditAssetPopup.item[ 0 ] = "Edit PostFX Asset Files" TAB EditPostFXAssetSubmenuPopup;
|
||||
|
||||
EditAssetPopup.reloadItems();
|
||||
|
||||
EditAssetPopup.showPopup(Canvas);
|
||||
|
||||
$CurrentAssetBrowser.popupMenu = EditAssetPopup;
|
||||
}
|
||||
|
||||
function PostEffectAsset::onEditScriptFile(%this)
|
||||
{
|
||||
if(isFunction("systemCommand"))
|
||||
eval("systemCommand(\"start \\\"\\\" \\\"" @ %this.getScriptPath() @ "\\\"\");");
|
||||
else
|
||||
warn("PostEffectAsset::onEditScriptFile() - systemCommand function disabled in this build. Unable to launch application to edit file.");
|
||||
}
|
||||
|
||||
function PostEffectAsset::onEditHLSLFile(%this)
|
||||
{
|
||||
if(isFunction("systemCommand"))
|
||||
eval("systemCommand(\"start \\\"\\\" \\\"" @ %this.getHLSLShaderPath() @ "\\\"\");");
|
||||
else
|
||||
warn("PostEffectAsset::onEditHLSLFile() - systemCommand function disabled in this build. Unable to launch application to edit file.");
|
||||
}
|
||||
|
||||
function PostEffectAsset::onEditGLSLFile(%this)
|
||||
{
|
||||
if(isFunction("systemCommand"))
|
||||
eval("systemCommand(\"start \\\"\\\" \\\"" @ %this.getGLSLShaderPath() @ "\\\"\");");
|
||||
else
|
||||
warn("PostEffectAsset::onEditGLSLFile() - systemCommand function disabled in this build. Unable to launch application to edit file.");
|
||||
}
|
||||
|
|
@ -1,9 +1,11 @@
|
|||
function AssetBrowser::createPrefab(%this)
|
||||
AssetBrowser::registerFileType("PrefabFileType", "Prefabs", ".prefab");
|
||||
|
||||
function PrefabFileType::onCreateNew()
|
||||
{
|
||||
%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||
%moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
%assetName = $CurrentAssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%assetPath = NewAssetTargetAddress.getText() @ "/";
|
||||
|
||||
|
|
@ -13,46 +15,32 @@ function AssetBrowser::createPrefab(%this)
|
|||
EWorldEditor.makeSelectionPrefab( %prefabFilePath );
|
||||
|
||||
EditorTree.buildVisibleTree( true );
|
||||
|
||||
$CurrentAssetBrowser.refresh();
|
||||
}
|
||||
|
||||
function AssetBrowser::buildPrefabPreview(%this, %assetDef, %previewData)
|
||||
function PrefabFileType::buildBrowserElement(%filePath, %previewData)
|
||||
{
|
||||
%fullPath = %assetDef.dirPath @ "/" @ %assetDef.assetName;
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetPath = %fullPath;
|
||||
%previewData.assetName = fileName(%filePath);
|
||||
%previewData.assetPath = %filePath;
|
||||
|
||||
echo("PrefabFileType::buildBrowserElement() - name, path: " @ %previewData.assetName @ ", " @ %filePath);
|
||||
|
||||
%previewData.previewImage = "ToolsModule:prefabIcon_image";
|
||||
|
||||
//%previewData.assetFriendlyName = %assetDef.assetName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = %fullPath;
|
||||
%previewData.assetDesc = %filePath;
|
||||
%previewData.tooltip = %filePath;
|
||||
//%previewData.doubleClickCommand = "AssetBrowser.schedule(10, \"navigateTo\",\""@ %assetDef.dirPath @ "/" @ %assetDef.assetName @"\");";//browseTo %assetDef.dirPath / %assetDef.assetName
|
||||
%previewData.doubleClickCommand = "AssetBrowser.autoImportFile(\"" @ %fullPath @ "\");";
|
||||
%previewData.doubleClickCommand = "AssetBrowser.autoImportFile(\"" @ %filePath @ "\");";
|
||||
}
|
||||
|
||||
function AssetBrowser::onPrefabEditorDropped(%this, %assetDef, %position)
|
||||
function PrefabFileType::onWorldEditorDropped(%filePath, %position)
|
||||
{
|
||||
//echo("DROPPED A SHAPE ON THE EDITOR WINDOW!");
|
||||
|
||||
%targetPosition = EWorldEditor.unproject(%position SPC 1);
|
||||
%camPos = LocalClientConnection.camera.getPosition();
|
||||
%rayResult = containerRayCast(%camPos, %targetPosition, -1);
|
||||
|
||||
%pos = ObjectCreator.getCreateObjectPosition();
|
||||
|
||||
if(%rayResult != 0)
|
||||
{
|
||||
%pos = getWords(%rayResult, 1, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
%pos = "0 0 0";
|
||||
}
|
||||
|
||||
%newPrefab = new Prefab()
|
||||
{
|
||||
position = %pos;
|
||||
fileName = %assetDef;
|
||||
position = %position;
|
||||
fileName = %filePath;
|
||||
};
|
||||
|
||||
getScene(0).add(%newPrefab);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
function AssetBrowser::createScriptAsset(%this)
|
||||
AssetBrowser::registerFileType("ScriptFileType", "Script Files", ".tscript;.cs;.dso;.tscript.dso;.cs.dso", false);
|
||||
AssetBrowser::registerAssetType("ScriptAsset", "Scripts");
|
||||
|
||||
function ScriptAsset::onCreateNew()
|
||||
{
|
||||
%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||
%moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
%assetName = $CurrentAssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%assetPath = NewAssetTargetAddress.getText() @ "/";
|
||||
|
||||
|
|
@ -32,97 +35,122 @@ function AssetBrowser::createScriptAsset(%this)
|
|||
return %tamlpath;
|
||||
}
|
||||
|
||||
function AssetBrowser::editScriptAsset(%this, %assetDef)
|
||||
function ScriptAsset::onEdit(%this)
|
||||
{
|
||||
%scriptFile = %assetDef.scriptFile;
|
||||
%scriptFile = %this.scriptFile;
|
||||
|
||||
//EditorOpenFileInTorsion(makeFullPath(%scriptFile), 0);
|
||||
if(isFunction("systemCommand"))
|
||||
eval("systemCommand(\"start \\\"\\\" \\\"" @ %this.fileName @ "\\\"\");");
|
||||
else
|
||||
warn("ScriptAsset::onEdit() - systemCommand function disabled in this build. Unable to launch application to edit file.");
|
||||
}
|
||||
|
||||
function AssetBrowser::duplicateScriptAsset(%this, %assetDef, %targetModule)
|
||||
function ScriptAsset::buildBrowserElement(%this, %previewData)
|
||||
{
|
||||
}
|
||||
|
||||
function AssetBrowser::importScriptAsset(%this, %assetId)
|
||||
{
|
||||
}
|
||||
|
||||
function AssetBrowser::onScriptAssetEditorDropped(%this, %assetDef, %position)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//Renames the asset
|
||||
function AssetBrowser::renameScriptAsset(%this, %assetDef, %newAssetName)
|
||||
{
|
||||
%newFilename = renameAssetLooseFile(%assetDef.scriptFile, %newAssetName);
|
||||
%previewData.assetName = %this.assetName;
|
||||
%previewData.assetPath = %this.fileName;
|
||||
|
||||
if(!%newFilename $= "")
|
||||
return;
|
||||
|
||||
%assetDef.scriptFile = %newFilename;
|
||||
%assetDef.saveAsset();
|
||||
|
||||
renameAssetFile(%assetDef, %newAssetName);
|
||||
}
|
||||
|
||||
//Deletes the asset
|
||||
function AssetBrowser::deleteScriptAsset(%this, %assetDef)
|
||||
{
|
||||
AssetDatabase.deleteAsset(%assetDef.getAssetId(), true);
|
||||
}
|
||||
|
||||
//Moves the asset to a new path/module
|
||||
function AssetBrowser::moveScriptAsset(%this, %assetDef, %destination)
|
||||
{
|
||||
%currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
|
||||
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
|
||||
|
||||
%newAssetPath = moveAssetFile(%assetDef, %destination);
|
||||
|
||||
if(%newAssetPath $= "")
|
||||
return false;
|
||||
|
||||
moveAssetLooseFile(%assetDef.getScriptPath(), %destination);
|
||||
|
||||
AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
|
||||
AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
|
||||
}
|
||||
|
||||
function AssetBrowser::buildScriptAssetPreview(%this, %assetDef, %previewData)
|
||||
{
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetPath = %assetDef.scriptFile;
|
||||
//%previewData.doubleClickCommand = "EditorOpenFileInTorsion( \""@%previewData.assetPath@"\", 0 );";
|
||||
|
||||
if(%assetDef.isServerSide)
|
||||
if(%this.isServerSide)
|
||||
%previewData.previewImage = "ToolsModule:serverScriptIcon_image";
|
||||
else
|
||||
%previewData.previewImage = "ToolsModule:clientScriptIcon_image";
|
||||
|
||||
%previewData.assetFriendlyName = %assetDef.assetName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\nDefinition Path: " @ %assetDef.getFilename();
|
||||
}
|
||||
|
||||
function AssetBrowser::buildTScriptPreview(%this, %assetDef, %previewData)
|
||||
{
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetPath = %assetDef.scriptFile;
|
||||
//%previewData.doubleClickCommand = "EditorOpenFileInTorsion( \""@%previewData.assetPath@"\", 0 );";
|
||||
|
||||
if(%assetDef.isServerSide)
|
||||
%previewData.previewImage = "ToolsModule:serverScriptIcon_image";
|
||||
else
|
||||
%previewData.previewImage = "ToolsModule:clientScriptIcon_image";
|
||||
|
||||
%previewData.assetFriendlyName = %assetDef.assetName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\nDefinition Path: " @ %assetDef.getFilename();
|
||||
%previewData.assetFriendlyName = %this.assetName;
|
||||
%previewData.assetDesc = %this.fileName;
|
||||
%previewData.tooltip = "Script Asset: " @ %this.getAssetId() @ "\n" @
|
||||
"File path: " @ %this.fileName;
|
||||
}
|
||||
|
||||
function GuiInspectorTypeScriptAssetPtr::onClick( %this, %fieldName )
|
||||
{
|
||||
//Get our data
|
||||
%obj = %this.getInspector().getInspectObject(0);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Handling for random script files in the browser
|
||||
//==============================================================================
|
||||
function ScriptFileType::buildBrowserElement(%filePath, %previewData)
|
||||
{
|
||||
%previewData.assetName = fileName(%filePath);
|
||||
%previewData.assetPath = %filePath;
|
||||
%previewData.doubleClickCommand = "systemCommand(\"start \\\"\\\" \\\"" @ %filePath @ "\\\"\");";
|
||||
|
||||
/*if(%assetDef.isServerSide)
|
||||
%previewData.previewImage = "ToolsModule:serverScriptIcon_image";
|
||||
else
|
||||
%previewData.previewImage = "ToolsModule:clientScriptIcon_image";*/
|
||||
%previewData.previewImage = "ToolsModule:clientScriptIcon_image";
|
||||
|
||||
%previewData.assetFriendlyName = %previewData.assetName;
|
||||
%previewData.assetDesc = %filePath;
|
||||
%previewData.tooltip = "Script File: " @ %filePath;
|
||||
}
|
||||
|
||||
function ScriptAssetType::onEdit(%filePath)
|
||||
{
|
||||
if(isFunction("systemCommand"))
|
||||
eval("systemCommand(\"start \\\"\\\" \\\"" @ %filePath @ "\\\"\");");
|
||||
else
|
||||
warn("ScriptAssetType::onEdit() - systemCommand function disabled in this build. Unable to launch application to edit file.");
|
||||
}
|
||||
|
||||
function ScriptFileType::onShowActionMenu(%filePath)
|
||||
{
|
||||
if( !isObject( EditScriptFileTypePopup ) )
|
||||
{
|
||||
new PopupMenu( EditScriptFileTypePopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
|
||||
jumpFileName = "";
|
||||
jumpLineNumber = "";
|
||||
};
|
||||
}
|
||||
|
||||
//Regen the menu so we're fully up and current with options and references
|
||||
EditScriptFileTypePopup.clearItems();
|
||||
|
||||
EditScriptFileTypePopup.item[ 0 ] = "Edit File" TAB "" TAB $CurrentAssetBrowser @ ".editAsset();";
|
||||
EditScriptFileTypePopup.item[ 1 ] = "Rename File" TAB "" TAB $CurrentAssetBrowser @ ".renameAsset();";
|
||||
EditScriptFileTypePopup.item[ 2 ] = "-";
|
||||
EditScriptFileTypePopup.item[ 3 ] = "Duplicate File" TAB "" TAB $CurrentAssetBrowser @ ".duplicateAsset();";
|
||||
EditScriptFileTypePopup.item[ 4 ] = "-";
|
||||
EditScriptFileTypePopup.item[ 5 ] = "Open File Location" TAB "" TAB $CurrentAssetBrowser @ ".openFileLocation();";
|
||||
EditScriptFileTypePopup.item[ 6 ] = "-";
|
||||
EditScriptFileTypePopup.item[ 7 ] = "Delete File" TAB "" TAB $CurrentAssetBrowser @ ".deleteAsset();";
|
||||
EditScriptFileTypePopup.item[ 8 ] = "-";
|
||||
EditScriptFileTypePopup.item[ 9 ] = "File Properties" TAB "" TAB $CurrentAssetBrowser @ ".editAssetInfo();";
|
||||
|
||||
EditScriptFileTypePopup.objectData = %filePath;
|
||||
EditScriptFileTypePopup.objectType = "ScriptFileType";
|
||||
|
||||
EditScriptFileTypePopup.reloadItems();
|
||||
|
||||
EditScriptFileTypePopup.showPopup(Canvas);
|
||||
|
||||
$CurrentAssetBrowser.popupMenu = EditScriptFileTypePopup;
|
||||
}
|
||||
|
||||
function ScriptFileType::onEditProperties(%filePath)
|
||||
{
|
||||
Canvas.pushDialog(AssetBrowser_editAsset);
|
||||
|
||||
AssetBrowser_editAssetWindow.text = "Script File Properties - " @ %filePath;
|
||||
|
||||
AssetBrowser_editAsset.editedObjectData = %filePath;
|
||||
//AssetBrowser_editAsset.editedObject = SpecialAssetEditInspector.tempAsset;
|
||||
AssetBrowser_editAsset.editedObjectType = "ScriptFileType";
|
||||
|
||||
AssetEditInspector.startGroup("Script File Properties");
|
||||
AssetEditInspector.addField("$ScriptFileType::ExecutionMode", "Execution Mode", "list", "How should this script file be executed by the module", "Server", "Client;Server;Shared;None");
|
||||
AssetEditInspector.addField("$ScriptFileType::ExecutionOverride", "Do Execution Override", "bool", "Should this execution override files that share the same name?", "false");
|
||||
AssetEditInspector.addField("$ScriptFileType::ExecutionConditions", "Execution Conditional", "command", "Does the execution of this script file have special conditionals?", "");
|
||||
AssetEditInspector.endGroup("Script File Properties");
|
||||
}
|
||||
|
||||
function ScriptFileType::onSaveProperties(%filePath)
|
||||
{
|
||||
//Do voodoo here
|
||||
}
|
||||
|
|
@ -1,285 +1,60 @@
|
|||
function AssetBrowser::createShapeAsset(%this)
|
||||
AssetBrowser::registerAssetType("ShapeAsset", "Shapes");
|
||||
|
||||
function ShapeAsset::onEdit(%this)
|
||||
{
|
||||
%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%assetPath = NewAssetTargetAddress.getText() @ "/";
|
||||
|
||||
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
|
||||
%shapeFilePath = %assetPath @ %assetName @ ".dae";
|
||||
|
||||
%asset = new ShapeAsset()
|
||||
if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
|
||||
{
|
||||
AssetName = %assetName;
|
||||
versionId = 1;
|
||||
friendlyName = AssetBrowser.newAssetSettings.friendlyName;
|
||||
description = AssetBrowser.newAssetSettings.description;
|
||||
fileName = %assetName @ ".dae";
|
||||
};
|
||||
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
||||
Canvas.popDialog(AssetBrowser_newComponentAsset);
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
|
||||
AssetBrowser.refresh();
|
||||
|
||||
return %tamlpath;
|
||||
}
|
||||
|
||||
function AssetBrowser::editShapeAsset(%this, %assetDef)
|
||||
{
|
||||
%this.hideDialog();
|
||||
EditorGui.setEditor( ShapeEditorPlugin );
|
||||
ShapeEditorPlugin.openShapeAsset(%assetDef);
|
||||
}
|
||||
|
||||
function AssetBrowser::onShapeAssetChanged(%this, %assetDef)
|
||||
{
|
||||
}
|
||||
|
||||
function AssetBrowser::deleteShapeAsset(%this, %assetDef)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function AssetBrowser::moveShapeAsset(%this, %assetDef, %destination)
|
||||
{
|
||||
%currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
|
||||
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
|
||||
|
||||
%newAssetPath = moveAssetFile(%assetDef, %destination);
|
||||
|
||||
if(%newAssetPath $= "")
|
||||
return false;
|
||||
|
||||
moveAssetLooseFile(%assetDef.getShapePath(), %destination);
|
||||
moveAssetLooseFile(%assetDef.getShapeConstructorFilePath(), %destination);
|
||||
|
||||
AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
|
||||
AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
|
||||
}
|
||||
|
||||
function AssetBrowser::prepareImportShapeAsset(%this, %assetItem)
|
||||
{
|
||||
ImportActivityLog.add("Preparing Shape for Import: " @ %assetItem.assetName);
|
||||
|
||||
%fileExt = fileExt(%assetItem.filePath);
|
||||
|
||||
if(!isObject(%assetItem.shapeInfo))
|
||||
{
|
||||
%shapeInfo = new GuiTreeViewCtrl();
|
||||
if(%fileExt $= ".dae")
|
||||
{
|
||||
enumColladaForImport(%assetItem.filePath, %shapeInfo, false);
|
||||
}
|
||||
else if(%fileExt $= ".dts")
|
||||
{
|
||||
%shapeInfo.insertItem(0, "Shape", 1);
|
||||
%shapeInfo.insertItem(0, "Animations", 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetShapeInfo(%assetItem.filePath, %shapeInfo, false);
|
||||
}
|
||||
|
||||
%assetItem.shapeInfo = %shapeInfo;
|
||||
$CurrentAssetBrowser.hideDialog();
|
||||
EditorGui.setEditor( ShapeEditorPlugin );
|
||||
ShapeEditorPlugin.openShapeAsset(%this);
|
||||
}
|
||||
|
||||
%shapeCount = %assetItem.shapeInfo._meshCount;
|
||||
%shapeItem = %assetItem.shapeInfo.findItemByName("Meshes");
|
||||
|
||||
//%shapeId = ImportAssetTree.findItemByObjectId(%assetItem);
|
||||
|
||||
if(getAssetImportConfigValue("Meshes/ImportMesh", "1") == 1 && %shapeCount > 0)
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
%animCount = %assetItem.shapeInfo._animCount;
|
||||
%animItem = %assetItem.shapeInfo.findItemByName("Animations");
|
||||
|
||||
if(getAssetImportConfigValue("Animations/ImportAnimations", "1") == 1 && %animCount > 0)
|
||||
{
|
||||
}
|
||||
|
||||
%matCount = %assetItem.shapeInfo._materialCount;
|
||||
%matItem = %assetItem.shapeInfo.findItemByName("Materials");
|
||||
|
||||
ImportActivityLog.add(" Shape Info: Mesh Count: " @ %shapeCount @ " | Material Count: " @ %matCount @ " | Anim Count: " @ %animCount);
|
||||
|
||||
if(getAssetImportConfigValue("Materials/ImportMaterials", "1") == 1 && %matCount > 0)
|
||||
{
|
||||
%materialItem = %assetItem.shapeInfo.getChild(%matItem);
|
||||
processShapeMaterialInfo(%assetItem, %materialItem);
|
||||
|
||||
%materialItem = %assetItem.shapeInfo.getNextSibling(%materialItem);
|
||||
while(%materialItem != 0)
|
||||
{
|
||||
processShapeMaterialInfo(%assetItem, %materialItem);
|
||||
|
||||
%materialItem = %assetItem.shapeInfo.getNextSibling(%materialItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function AssetBrowser::importShapeAsset(%this, %assetItem)
|
||||
{
|
||||
%moduleName = AssetImportTargetModule.getText();
|
||||
|
||||
%assetType = %assetItem.AssetType;
|
||||
%filePath = %assetItem.filePath;
|
||||
%assetName = %assetItem.assetName;
|
||||
%assetImportSuccessful = false;
|
||||
%assetId = %moduleName@":"@%assetName;
|
||||
|
||||
%assetPath = NewAssetTargetAddress.getText() @ "/";
|
||||
%assetFullPath = %assetPath @ fileName(%filePath);
|
||||
|
||||
%newAsset = new ShapeAsset()
|
||||
{
|
||||
assetName = %assetName;
|
||||
versionId = 1;
|
||||
fileName = fileName(%filePath);
|
||||
isNewShape = true;
|
||||
};
|
||||
|
||||
//No point in indicating the original path data if it was imported in-place
|
||||
if(!startsWith(makeFullPath(%filePath), getMainDotCsDir()))
|
||||
{
|
||||
%newAsset.originalFilePath = %filePath;
|
||||
}
|
||||
|
||||
//check dependencies
|
||||
%dependencySlotId = 0;
|
||||
for(%i=0; %i < %assetItem.childAssetItems.count(); %i++)
|
||||
{
|
||||
%childAssetItem = %assetItem.childAssetItems.getKey(%i);
|
||||
|
||||
if(!isObject(%childAssetItem) || %childAssetItem.skip || %childAssetItem.processed == false)
|
||||
continue;
|
||||
|
||||
%depAssetType = %childAssetItem.assetType;
|
||||
if(%childAssetItem.assetType $= "MaterialAsset")
|
||||
{
|
||||
%matSet = "%newAsset.materialSlot"@%dependencySlotId@"=\"@asset="@%moduleName@":"@%childAssetItem.assetName@"\";";
|
||||
eval(%matSet);
|
||||
%dependencySlotId++;
|
||||
}
|
||||
else if(%depAssetType $= "AnimationAsset")
|
||||
{
|
||||
%matSet = "%newAsset.animationSequence"@%dependencySlotId@"=\"@asset="@%moduleName@":"@%childAssetItem.assetName@"\";";
|
||||
eval(%matSet);
|
||||
%dependencySlotId++;
|
||||
}
|
||||
}
|
||||
|
||||
%assetImportSuccessful = TAMLWrite(%newAsset, %assetPath @ %assetName @ ".asset.taml");
|
||||
|
||||
//and copy the file into the relevent directory
|
||||
if(filePath(%filePath) !$= filePath(%assetFullPath))
|
||||
{
|
||||
%doOverwrite = !AssetBrowser.isAssetReImport;
|
||||
if(!pathCopy(%filePath, %assetFullPath, %doOverwrite))
|
||||
{
|
||||
error("Unable to import asset: " @ %filePath);
|
||||
}
|
||||
}
|
||||
|
||||
%constructor = ShapeEditor.findConstructor( %assetFullPath );
|
||||
|
||||
if(!isObject(%constructor))
|
||||
%constructor = ShapeEditor.createConstructor(%assetFullPath);
|
||||
|
||||
//We'll update any relevent bits to the ShapeConstructor here
|
||||
$TSShapeConstructor::neverImportMat = "";
|
||||
|
||||
if(getAssetImportConfigValue("Materials/IgnoreMaterials", "") !$= "")
|
||||
{
|
||||
%ignoreMaterialList = getAssetImportConfigValue("Materials/IgnoreMaterials", "");
|
||||
%ignoredMatNamesCount = getTokenCount(%ignoreMaterialList, ",;");
|
||||
for(%i=0; %i < %ignoredMatNamesCount; %i++)
|
||||
{
|
||||
if(%i==0)
|
||||
$TSShapeConstructor::neverImportMat = getToken(%ignoreMaterialList, ",;", %i);
|
||||
else
|
||||
$TSShapeConstructor::neverImportMat = $TSShapeConstructor::neverImportMat TAB getToken(%ignoreMaterialList, ",;", %i);
|
||||
}
|
||||
%this.onWorldEditorDropped();
|
||||
}
|
||||
|
||||
if(getAssetImportConfigValue("Materials/DoUpAxisOverride", "") $= "1")
|
||||
%constructor.upAxis = getAssetImportConfigValue("Meshes/UpAxisOverride", "Z_AXIS");
|
||||
|
||||
if(getAssetImportConfigValue("Meshes/DoScaleOverride", "0") $= "1")
|
||||
%constructor.unit = getAssetImportConfigValue("Meshes/ScaleOverride", "1");
|
||||
else
|
||||
%constructor.unit = -1;
|
||||
|
||||
%constructor.lodType = getAssetImportConfigValue("Meshes/LODType", "0");
|
||||
//%constructor.singleDetailSize = getAssetImportConfigValue("Meshes/convertLeftHanded", "0");
|
||||
%constructor.alwaysImport = getAssetImportConfigValue("Meshes/AlwaysImportedNodes", "");
|
||||
%constructor.neverImport = getAssetImportConfigValue("Meshes/AlwaysIgnoreNodes", "");
|
||||
%constructor.alwaysImportMesh = getAssetImportConfigValue("Meshes/AlwaysImportMeshes", "");
|
||||
%constructor.neverImportMesh = getAssetImportConfigValue("Meshes/AlwaysIgnoreMeshes", "");
|
||||
%constructor.ignoreNodeScale = getAssetImportConfigValue("Meshes/IgnoreNodeScale", "0");
|
||||
%constructor.adjustCenter = getAssetImportConfigValue("Meshes/AdjustCenter", "0");
|
||||
%constructor.adjustFloor = getAssetImportConfigValue("Meshes/AdjustFloor", "0");
|
||||
|
||||
%constructor.convertLeftHanded = getAssetImportConfigValue("Meshes/convertLeftHanded", "0");
|
||||
%constructor.calcTangentSpace = getAssetImportConfigValue("Meshes/calcTangentSpace", "0");
|
||||
%constructor.genUVCoords = getAssetImportConfigValue("Meshes/genUVCoords", "0");
|
||||
%constructor.flipUVCoords = getAssetImportConfigValue("Meshes/flipUVCoords", "0");
|
||||
%constructor.findInstances = getAssetImportConfigValue("Meshes/findInstances", "0");
|
||||
%constructor.limitBoneWeights = getAssetImportConfigValue("Meshes/limitBoneWeights", "0");
|
||||
%constructor.joinIdenticalVerts = getAssetImportConfigValue("Meshes/joinIdenticalVerts", "0");
|
||||
%constructor.reverseWindingOrder = getAssetImportConfigValue("Meshes/reverseWindingOrder", "0");
|
||||
%constructor.invertNormals = getAssetImportConfigValue("Meshes/invertNormals", "0");
|
||||
%constructor.removeRedundantMats = getAssetImportConfigValue("Meshes/removeRedundantMats", "0");
|
||||
%constructor.animTiming = getAssetImportConfigValue("Animations/animTiming", "Seconds");
|
||||
%constructor.animFPS = getAssetImportConfigValue("Animations/animFPS", "2");
|
||||
|
||||
%constructor.neverImportMat = $TSShapeConstructor::neverImportMat;
|
||||
ShapeEditor.saveConstructor( %constructor );
|
||||
|
||||
//now, force-load the file if it's collada
|
||||
/*%fileExt = fileExt(%assetFullPath);
|
||||
if(isSupportedFormat(getSubStr(%fileExt,1)))
|
||||
{
|
||||
%tempShape = new TSStatic()
|
||||
{
|
||||
shapeName = %assetFullPath;
|
||||
};
|
||||
|
||||
%tempShape.delete();
|
||||
}*/
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName,1);
|
||||
|
||||
if(!AssetBrowser.isAssetReImport)
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %assetPath @ %assetName @ ".asset.taml");
|
||||
else
|
||||
AssetDatabase.refreshAsset(%assetId);
|
||||
}
|
||||
|
||||
function AssetBrowser::buildShapeAssetPreview(%this, %assetDef, %previewData, %forcePreviewRegenerate)
|
||||
function ShapeAsset::onShowActionMenu(%assetDef)
|
||||
{
|
||||
GenericAsset::onShowActionMenu(%assetDef);
|
||||
}
|
||||
|
||||
function ShapeAsset::onChanged(%this)
|
||||
{
|
||||
echo("ShapeAsset::onChanged() - asset " @ %this.assetId @ " has changed!");
|
||||
}
|
||||
|
||||
function ShapeAsset::onDelete(%this)
|
||||
{
|
||||
//Special handle the cache preview image
|
||||
%module = $CurrentAssetBrowser.dirHandler.getModuleFromAddress(makeRelativePath(filePath(%this.getShapePath())));
|
||||
%previewPath = "tools/resources/previewCache/" @ %module.moduleId @ "/" @ %this.assetName @ "_Preview.dds";
|
||||
|
||||
if(isFile(%previewPath))
|
||||
{
|
||||
$CurrentAssetBrowser.dirHandler.deleteFile(%previewPath);
|
||||
}
|
||||
|
||||
//then just let the Generic function handle the rest
|
||||
GenericAsset::onDelete(%this);
|
||||
}
|
||||
|
||||
function ShapeAsset::buildBrowserElement(%this, %previewData)
|
||||
{
|
||||
%previewData.previewImage = "ToolsModule:genericAssetIcon_image";
|
||||
%previewData.previewLoaded = false; //this marks it for loading progressively later
|
||||
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetPath = %assetDef.fileName;
|
||||
%previewData.assetName = %this.assetName;
|
||||
%previewData.assetPath = %this.fileName;
|
||||
|
||||
%previewData.assetFriendlyName = %assetDef.assetName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\n" @
|
||||
%previewData.assetFriendlyName = %this.assetName;
|
||||
%previewData.assetDesc = %this.description;
|
||||
%previewData.tooltip = "Asset Name: " @ %this.assetName @ "\n" @
|
||||
"Asset Type: Shape Asset\n" @
|
||||
"Asset Definition ID: " @ %assetDef @ "\n" @
|
||||
"Shape File path: " @ %assetDef.getShapePath();
|
||||
"Asset Definition ID: " @ %this @ "\n" @
|
||||
"Shape File path: " @ %this.getShapePath();
|
||||
|
||||
if(%this.selectMode)
|
||||
/*if(%this.selectMode)
|
||||
{
|
||||
%previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );";
|
||||
}
|
||||
|
|
@ -293,41 +68,39 @@ function AssetBrowser::buildShapeAssetPreview(%this, %assetDef, %previewData, %f
|
|||
{
|
||||
%previewData.doubleClickCommand = "AssetBrowser.onShapeAssetEditorDropped( "@%assetDef@" );";
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
function AssetBrowser::generateShapeAssetPreviewImage(%this, %previewButton, %forceRegenerate)
|
||||
function ShapeAsset::generatePreviewImage(%this, %previewButton, %forceRegenerate)
|
||||
{
|
||||
if(%forceRegenerate $= "")
|
||||
%forceRegenerate = false;
|
||||
|
||||
%assetId = %previewButton.moduleName @ ":" @ %previewButton.assetName;
|
||||
|
||||
%assetDef = AssetDatabase.acquireAsset(%assetId);
|
||||
|
||||
%module = %this.dirHandler.getModuleFromAddress(makeRelativePath(filePath(%assetDef.getShapePath())));
|
||||
%assetId = %this.getAssetId();
|
||||
|
||||
%module = %previewButton.assetBrowser.dirHandler.getModuleFromAddress(makeRelativePath(filePath(%this.getShapePath())));
|
||||
%previewPath = "tools/resources/previewCache/" @ %module.moduleId @ "/";
|
||||
|
||||
if(!IsDirectory(%previewPath))
|
||||
{
|
||||
%this.dirHandler.createFolder(%previewPath);
|
||||
%previewButton.assetBrowser.dirHandler.createFolder(%previewPath);
|
||||
}
|
||||
|
||||
%generatePreview = false;
|
||||
|
||||
%previewFilePath = %previewPath @ %assetDef.assetName @ "_Preview.dds";
|
||||
if(!isFile(%previewFilePath) || (compareFileTimes(%assetDef.getShapePath(), %previewFilePath) == 1))
|
||||
%previewFilePath = %previewPath @ %this.assetName @ "_Preview.dds";
|
||||
if(!isFile(%previewFilePath) || (compareFileTimes(%this.getShapePath(), %previewFilePath) == 1))
|
||||
{
|
||||
%generatePreview = true;
|
||||
}
|
||||
|
||||
%previewAssetName = %module.moduleId @ "_" @ %assetDef.assetName @ "_PreviewImage";
|
||||
%previewAssetName = %module.moduleId @ "_" @ %this.assetName @ "_PreviewImage";
|
||||
|
||||
if(%generatePreview || %forceRegenerate)
|
||||
{
|
||||
//real fast, we'll be 100% sure that the image resource we need is loaded
|
||||
|
||||
%matSlot0AssetId = %assetDef.materialSlot0;
|
||||
%matSlot0AssetId = %this.materialSlot0;
|
||||
if(AssetDatabase.isDeclaredAsset(%matSlot0AssetId))
|
||||
{
|
||||
%matAsset = AssetDatabase.acquireAsset(%matSlot0AssetId);
|
||||
|
|
@ -337,7 +110,7 @@ function AssetBrowser::generateShapeAssetPreviewImage(%this, %previewButton, %fo
|
|||
//This is slightly hacky, but we're going to utilize the imposter/last detail system
|
||||
//to generate our previews for us and then clean up the unneeded bits
|
||||
|
||||
%filePath = %assetDef.generateCachedPreviewImage();
|
||||
%filePath = %this.generateCachedPreviewImage();
|
||||
|
||||
pathCopy(%filePath, %previewFilePath, false);
|
||||
fileDelete(%filePath); //cleanup
|
||||
|
|
@ -380,7 +153,7 @@ function AssetBrowser::generateShapeAssetPreviewImage(%this, %previewButton, %fo
|
|||
return false;
|
||||
}
|
||||
|
||||
function AssetBrowser::onShapeAssetEditorDropped(%this, %assetDef, %position)
|
||||
function ShapeAsset::onWorldEditorDropped(%assetDef, %position)
|
||||
{
|
||||
%assetId = %assetDef.getAssetId();
|
||||
|
||||
|
|
@ -402,6 +175,11 @@ function AssetBrowser::onShapeAssetEditorDropped(%this, %assetDef, %position)
|
|||
MECreateUndoAction::submit(%newStatic );
|
||||
}
|
||||
|
||||
function ShapeAsset::onGUIEditorDropped(%assetDef, %position)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function GuiInspectorTypeShapeAssetPtr::onControlDropped( %this, %payload, %position )
|
||||
{
|
||||
Canvas.popDialog(EditorDragAndDropLayer);
|
||||
|
|
|
|||
|
|
@ -1,57 +1,16 @@
|
|||
function AssetBrowser::createShapeAnimationAsset(%this)
|
||||
{
|
||||
%dlg = new OpenFileDialog()
|
||||
{
|
||||
Filters = "Animation Files(*.dae, *.cached.dts)|*.dae;*.cached.dts";
|
||||
DefaultPath = $Pref::WorldEditor::LastPath;
|
||||
DefaultFile = "";
|
||||
ChangePath = false;
|
||||
OverwritePrompt = true;
|
||||
forceRelativePath = false;
|
||||
//MultipleFiles = true;
|
||||
};
|
||||
AssetBrowser::registerAssetType("ShapeAnimationAsset", "Shape Anims");
|
||||
|
||||
%ret = %dlg.Execute();
|
||||
|
||||
if ( %ret )
|
||||
{
|
||||
$Pref::WorldEditor::LastPath = filePath( %dlg.FileName );
|
||||
%fullPath = %dlg.FileName;
|
||||
}
|
||||
|
||||
%dlg.delete();
|
||||
|
||||
if ( !%ret )
|
||||
return;
|
||||
}
|
||||
|
||||
function AssetBrowser::editShapeAnimationAsset(%this, %assetDef)
|
||||
function ShapeAnimationAsset::onEdit(%this)
|
||||
{
|
||||
%this.hideDialog();
|
||||
$CurrentAssetBrowser.hideDialog();
|
||||
EditorGui.setEditor( ShapeEditorPlugin );
|
||||
ShapeEditorPlugin.openShapeAsset(%assetDef);
|
||||
ShapeEditorPlugin.openShapeAsset(%this);
|
||||
}
|
||||
|
||||
function AssetBrowser::moveShapeAnimationAsset(%this, %assetDef, %destination)
|
||||
function ShapeAnimationAsset::buildBrowserElement(%this, %previewData)
|
||||
{
|
||||
%currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
|
||||
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
|
||||
|
||||
%newAssetPath = moveAssetFile(%assetDef, %destination);
|
||||
|
||||
if(%newAssetPath $= "")
|
||||
return false;
|
||||
|
||||
moveAssetLooseFile(%assetDef.getAnimationPath(), %destination);
|
||||
|
||||
AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
|
||||
AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
|
||||
}
|
||||
|
||||
function AssetBrowser::buildShapeAnimationAssetPreview(%this, %assetDef, %previewData)
|
||||
{
|
||||
%previewData.assetName = %assetDef.animationName;
|
||||
%previewData.assetPath = %assetDef.scriptFile;
|
||||
%previewData.assetName = %this.animationName;
|
||||
%previewData.assetPath = %this.scriptFile;
|
||||
|
||||
//Lotta prepwork
|
||||
/*%previewData.doubleClickCommand = %assetDef@".materialDefinitionName.reload(); "
|
||||
|
|
@ -66,7 +25,9 @@ function AssetBrowser::buildShapeAnimationAssetPreview(%this, %assetDef, %previe
|
|||
|
||||
%previewData.previewImage = "ToolsModule:animationIcon_image";
|
||||
|
||||
%previewData.assetFriendlyName = %assetDef.assetName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = %assetDef.friendlyName @ "\n" @ %assetDef @ "\nShape File path: " @ %assetDef.getShapePath();
|
||||
%previewData.assetFriendlyName = %this.assetName;
|
||||
%previewData.assetDesc = %this.description;
|
||||
%previewData.tooltip = %this.friendlyName @ "\n"
|
||||
@ %this @ "\nShape File path: "
|
||||
@ %this.getShapePath();
|
||||
}
|
||||
|
|
@ -1,61 +1,50 @@
|
|||
function AssetBrowser::editSoundAsset(%this, %assetDef)
|
||||
AssetBrowser::registerAssetType("SoundAsset", "Sounds");
|
||||
|
||||
function SoundAsset::onEdit(%this)
|
||||
{
|
||||
if (isObject($PreviewSoundSource))
|
||||
sfxStop($PreviewSoundSource);
|
||||
$PreviewSoundSource = %assetDef.playSound();
|
||||
$PreviewSoundSource = %this.playSound();
|
||||
}
|
||||
|
||||
function AssetBrowser::onSoundAssetChanged(%this, %assetDef)
|
||||
function SoundAsset::onChanged(%this)
|
||||
{
|
||||
if (isObject($PreviewSoundSource))
|
||||
sfxStop($PreviewSoundSource);
|
||||
}
|
||||
|
||||
function AssetBrowser::moveSoundAsset(%this, %assetDef, %destination)
|
||||
function SoundAsset::buildBrowserElement(%this, %previewData)
|
||||
{
|
||||
%currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
|
||||
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
|
||||
|
||||
%newAssetPath = moveAssetFile(%assetDef, %destination);
|
||||
|
||||
if(%newAssetPath $= "")
|
||||
return false;
|
||||
|
||||
moveAssetLooseFile(%assetDef.getSoundPath(), %destination);
|
||||
|
||||
AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
|
||||
AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
|
||||
}
|
||||
|
||||
function AssetBrowser::buildSoundAssetPreview(%this, %assetDef, %previewData)
|
||||
{
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetPath = %assetDef.soundFilePath;
|
||||
%previewData.assetName = %this.assetName;
|
||||
%previewData.assetPath = %this.soundFilePath;
|
||||
|
||||
if(%this.selectMode)
|
||||
{
|
||||
%previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );";
|
||||
%previewData.doubleClickCommand = $CurrentAssetBrowser @ ".selectAsset( " @ $CurrentAssetBrowser @ ".selectedAsset );";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
|
||||
%previewData.doubleClickCommand = $CurrentAssetBrowser @ ".editAsset( "@ %this @" );";
|
||||
|
||||
/*if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
|
||||
{
|
||||
%previewData.doubleClickCommand = "AssetBrowser.editAsset( "@%assetDef@" );";
|
||||
%previewData.doubleClickCommand = $CurrentAssetBrowser @ ".editAsset( "@ %this @" );";
|
||||
}
|
||||
else
|
||||
{
|
||||
%previewData.doubleClickCommand = "AssetBrowser.onSoundAssetEditorDropped( "@%assetDef@" );";
|
||||
}
|
||||
%previewData.doubleClickCommand = $CurrentAssetBrowser @ ".onSoundAssetEditorDropped( "@ %this @" );";
|
||||
}*/
|
||||
}
|
||||
|
||||
%previewData.previewImage = "ToolsModule:soundIcon_image";
|
||||
|
||||
%previewData.assetFriendlyName = %assetDef.assetName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\nDefinition Path: " @ %assetDef.getFilename();
|
||||
%previewData.assetFriendlyName = %this.assetName;
|
||||
%previewData.assetDesc = %this.description;
|
||||
%previewData.tooltip = "Asset Name: " @ %this.assetName @
|
||||
"\nDefinition Path: " @ %this.getFilename();
|
||||
}
|
||||
|
||||
function AssetBrowser::onSoundAssetEditorDropped(%this, %assetDef, %position)
|
||||
function SoundAsset::onWorldEditorDropped(%this, %position)
|
||||
{
|
||||
%targetPosition = EWorldEditor.unproject(%position SPC 1);
|
||||
%camPos = LocalClientConnection.camera.getPosition();
|
||||
|
|
@ -72,14 +61,12 @@ function AssetBrowser::onSoundAssetEditorDropped(%this, %assetDef, %position)
|
|||
%pos = "0 0 0";
|
||||
}
|
||||
|
||||
%assetId = %assetDef.getAssetId();
|
||||
|
||||
%newSFXEmitter = new SFXEmitter()
|
||||
{
|
||||
position = %pos;
|
||||
soundAsset = %assetDef.getAssetId();
|
||||
pitch = %assetDef.pitchAdjust;
|
||||
volume = %assetDef.volumeAdjust;
|
||||
soundAsset = %this.getAssetId();
|
||||
pitch = %this.pitchAdjust;
|
||||
volume = %this.volumeAdjust;
|
||||
};
|
||||
|
||||
getScene(0).add(%newSFXEmitter);
|
||||
|
|
@ -91,15 +78,15 @@ function AssetBrowser::onSoundAssetEditorDropped(%this, %assetDef, %position)
|
|||
|
||||
}
|
||||
|
||||
function AssetBrowser::onSoundAssetGUIEditorDropped(%this, %assetDef, %position)
|
||||
function SoundAsset::onGUIEditorDropped(%this, %position)
|
||||
{
|
||||
%assetId = %assetDef.getAssetId();
|
||||
%assetId = %this.getAssetId();
|
||||
%cmd = "new GuiAudioCtrl(){";
|
||||
%cmd = %cmd @ "SoundAsset =\""@ %assetId @"\";";
|
||||
%cmd = %cmd @ "position =\""@ %position @"\";";
|
||||
%cmd = %cmd @ "};";
|
||||
%ctrl = GuiEditCanvas.createObject(%cmd);
|
||||
echo(%ctrl SPC "created");
|
||||
//echo(%ctrl SPC "created");
|
||||
}
|
||||
|
||||
function GuiInspectorTypeSoundAssetPtr::onControlDropped( %this, %payload, %position )
|
||||
|
|
|
|||
|
|
@ -1,161 +0,0 @@
|
|||
function AssetBrowser::createStateMachineAsset(%this)
|
||||
{
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
%moduleName = AssetBrowser.selectedModule;
|
||||
%assetPath = NewAssetTargetAddress.getText() @ "/";
|
||||
|
||||
%assetQuery = new AssetQuery();
|
||||
|
||||
%matchingAssetCount = AssetDatabase.findAssetName(%assetQuery, %assetName);
|
||||
|
||||
%i=1;
|
||||
while(%matchingAssetCount > 0)
|
||||
{
|
||||
%newAssetName = %assetName @ %i;
|
||||
%i++;
|
||||
|
||||
%matchingAssetCount = AssetDatabase.findAssetName(%assetQuery, %newAssetName);
|
||||
}
|
||||
|
||||
%assetName = %newAssetName;
|
||||
|
||||
%assetQuery.delete();
|
||||
|
||||
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
|
||||
%smFilePath = %assetPath @ %assetName @ ".xml";
|
||||
|
||||
%asset = new StateMachineAsset()
|
||||
{
|
||||
AssetName = %assetName;
|
||||
versionId = 1;
|
||||
stateMachineFile = %assetName @ ".xml";
|
||||
};
|
||||
|
||||
%xmlDoc = new SimXMLDocument();
|
||||
%xmlDoc.saveFile(%smFilePath);
|
||||
%xmlDoc.delete();
|
||||
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
||||
//Now write our XML file
|
||||
%xmlFile = new FileObject();
|
||||
%xmlFile.openForWrite(%smFilePath);
|
||||
%xmlFile.writeLine("<StateMachine>");
|
||||
%xmlFile.writeLine("</StateMachine>");
|
||||
%xmlFile.close();
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
|
||||
AssetBrowser.refresh();
|
||||
|
||||
return %tamlpath;
|
||||
}
|
||||
|
||||
function AssetBrowser::editStateMachineAsset(%this, %assetDef)
|
||||
{
|
||||
eval("AssetBrowser.tempAsset = new " @ %assetDef.getClassName() @ "();");
|
||||
AssetBrowser.tempAsset.assignFieldsFrom(%assetDef);
|
||||
|
||||
SMAssetEditInspector.inspect(AssetBrowser.tempAsset);
|
||||
AssetBrowser_editAsset.editedAssetId = EditAssetPopup.assetId;
|
||||
AssetBrowser_editAsset.editedAsset = AssetBrowser.tempAsset;
|
||||
|
||||
//remove some of the groups we don't need:
|
||||
for(%i=0; %i < SMAssetEditInspector.getCount(); %i++)
|
||||
{
|
||||
%caption = SMAssetEditInspector.getObject(%i).caption;
|
||||
|
||||
if(%caption $= "Ungrouped" || %caption $= "Object" || %caption $= "Editing"
|
||||
|| %caption $= "Persistence" || %caption $= "Dynamic Fields")
|
||||
{
|
||||
SMAssetEditInspector.remove(SMAssetEditInspector.getObject(%i));
|
||||
%i--;
|
||||
}
|
||||
}
|
||||
|
||||
Canvas.pushDialog(StateMachineEditor);
|
||||
StateMachineEditor.loadStateMachineAsset(EditAssetPopup.assetId);
|
||||
StateMachineEditor-->Window.text = "State Machine Editor ("@EditAssetPopup.assetId@")";
|
||||
}
|
||||
|
||||
function AssetBrowser::duplicateStateMachineAsset(%this, %assetDef)
|
||||
{
|
||||
// TODO:
|
||||
%targetModule = "";
|
||||
|
||||
//Check if we have a target module, if not we need to select one
|
||||
if(%targetModule $= "")
|
||||
{
|
||||
error("AssetBrowser::duplicateStateMachineAsset - No target module selected!");
|
||||
return;
|
||||
}
|
||||
|
||||
%assetId = %assetDef.getAssetId();
|
||||
%assetName = AssetDatabase.getAssetName(%assetId);
|
||||
|
||||
//First step, copy the files
|
||||
%modulePath = "data/" @ %targetModule @ "/stateMachines/";
|
||||
|
||||
if(!isDirectory(%modulePath))
|
||||
createPath(%modulePath);
|
||||
|
||||
%assetFile = AssetDatabase.getAssetFilePath(%assetId);
|
||||
%stateMachineFile = %assetDef.stateMachineFile;
|
||||
|
||||
echo("AssetBrowser::duplicateGameObjectAsset - duplicating! " @ %assetId @ " to " @ %targetModule);
|
||||
|
||||
%tamlPath = %modulePath @ fileName(%assetFile);
|
||||
|
||||
pathCopy(%assetFile, %tamlPath);
|
||||
pathCopy(%stateMachineFile, %modulePath @ fileName(%stateMachineFile));
|
||||
|
||||
echo("AssetBrowser::duplicateStateMachineAsset - duplicated!");
|
||||
|
||||
//Register the asset
|
||||
%moduleDef = ModuleDatabase.findModule(%targetModule, 1);
|
||||
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlPath);
|
||||
|
||||
//Refresh the browser
|
||||
AssetBrowser.refresh();
|
||||
|
||||
//Rename it for convenience
|
||||
AssetBrowser.performRenameAsset(%assetName, "New" @ %assetName);
|
||||
}
|
||||
|
||||
function AssetBrowser::renameGameObjectAsset(%this, %assetDef, %newAssetId, %originalName, %newName)
|
||||
{
|
||||
%assetPath = AssetDatabase.getAssetFilePath(%newAssetId);
|
||||
|
||||
//rename the file to match
|
||||
%path = filePath(%assetPath);
|
||||
|
||||
%oldScriptFilePath = %assetDef.stateMachineFile;
|
||||
%scriptFilePath = filePath(%assetDef.stateMachineFile);
|
||||
%scriptExt = fileExt(%assetDef.stateMachineFile);
|
||||
|
||||
%newScriptFileName = %scriptFilePath @ "/" @ %newName @ %scriptExt;
|
||||
%newAssetFile = %path @ "/" @ %newName @ ".asset.taml";
|
||||
|
||||
%assetDef.stateMachineFile = %newScriptFileName;
|
||||
|
||||
TamlWrite(%assetDef, %newAssetFile);
|
||||
fileDelete(%assetPath);
|
||||
|
||||
pathCopy(%oldScriptFilePath, %newScriptFileName);
|
||||
fileDelete(%oldScriptFilePath);
|
||||
}
|
||||
|
||||
function AssetBrowser::buildStateMachineAssetPreview(%this, %assetDef, %previewData)
|
||||
{
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetPath = %assetDef.scriptFile;
|
||||
%previewData.doubleClickCommand = "AssetBrowser.editStateMachineAsset( "@%assetDef@" );";
|
||||
|
||||
%previewData.previewImage = "ToolsModule:stateMachineIcon_image";
|
||||
|
||||
%previewData.assetFriendlyName = %assetDef.friendlyName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = %assetDef.friendlyName @ "\n" @ %assetDef;
|
||||
}
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
AssetBrowser::registerAssetType("SubSceneAsset", "SubScenes");
|
||||
|
||||
function SubSceneAsset::setupCreateNew()
|
||||
{
|
||||
NewAssetPropertiesInspector.startGroup("SubScene");
|
||||
NewAssetPropertiesInspector.addField("LevelName", "SubScene Name", "String", "Human-readable name of new subScene", "", "", $CurrentAssetBrowser.newAssetSettings);
|
||||
|
||||
NewAssetPropertiesInspector.endGroup();
|
||||
}
|
||||
|
||||
function SubSceneAsset::onCreateNew(%this)
|
||||
{
|
||||
%moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%assetName = $CurrentAssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%assetPath = NewAssetTargetAddress.getText() @ "/";
|
||||
|
||||
%misExtension = ".subMis";
|
||||
|
||||
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
|
||||
%levelPath = %assetPath @ %assetName @ %misExtension;
|
||||
|
||||
%asset = new SubSceneAsset()
|
||||
{
|
||||
AssetName = %assetName;
|
||||
versionId = 1;
|
||||
LevelFile = %assetName @ %misExtension;
|
||||
LevelName = $CurrentAssetBrowser.newAssetSettings.levelName;
|
||||
AssetDescription = $CurrentAssetBrowser.newAssetSettings.description;
|
||||
};
|
||||
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
||||
%fileObj = new FileObject();
|
||||
if (!%fileObj.openForWrite(%levelPath))
|
||||
{
|
||||
echo("Unable to write subScene file!");
|
||||
}
|
||||
else
|
||||
{
|
||||
%fileObj.writeLine("");
|
||||
%fileObj.close();
|
||||
%fileObj.delete();
|
||||
}
|
||||
|
||||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
%addSuccess = AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
|
||||
if(!%addSuccess)
|
||||
{
|
||||
error("SubSceneAsset::onCreateNew() - failed to add declared asset: " @ %tamlpath @ " for module: " @ %moduleDef);
|
||||
}
|
||||
|
||||
$CurrentAssetBrowser.refresh();
|
||||
|
||||
if(%addSuccess && isObject($createAndAssignField))
|
||||
{
|
||||
$createAndAssignField.apply(%moduleName @ ":" @ %assetName);
|
||||
$createAndAssignField = "";
|
||||
}
|
||||
|
||||
return %tamlpath;
|
||||
}
|
||||
|
||||
function SubSceneAsset::buildBrowserElement(%this, %previewData)
|
||||
{
|
||||
%previewData.assetName = %this.assetName;
|
||||
%previewData.assetPath = %this.getLevelPath();
|
||||
%previewData.doubleClickCommand = "AssetBrowser.selectAsset(" @ %this @ ");";
|
||||
|
||||
%levelPreviewImage = %this.PreviewImage;
|
||||
|
||||
if(isFile(%levelPreviewImage))
|
||||
%previewData.previewImage = %levelPreviewImage;
|
||||
else
|
||||
%previewData.previewImage = "ToolsModule:levelIcon_image";
|
||||
|
||||
%previewData.assetFriendlyName = %this.assetName;
|
||||
%previewData.assetDesc = %this.description;
|
||||
%previewData.tooltip = "Asset Name: " @ %this.assetName @ "\n" @
|
||||
"Asset Type: SubScene Asset\n" @
|
||||
"Asset Definition ID: " @ %this @ "\n" @
|
||||
"SubScene File path: " @ %this.getLevelPath();
|
||||
}
|
||||
|
||||
function EWorldEditor::createSelectedAsSubScene( %this, %object )
|
||||
{
|
||||
//create new level asset here
|
||||
AssetBrowser.setupCreateNewAsset("SubSceneAsset", AssetBrowser.selectedModule, "finishCreateSelectedAsSubScene");
|
||||
%this.contextActionObject = %object;
|
||||
}
|
||||
|
||||
function finishCreateSelectedAsSubScene(%assetId)
|
||||
{
|
||||
//echo("finishCreateSelectedAsSubScene");
|
||||
|
||||
%subScene = new SubScene() {
|
||||
levelAsset = %assetId;
|
||||
};
|
||||
|
||||
%levelAssetDef = AssetDatabase.acquireAsset(%assetId);
|
||||
%levelFilePath = %levelAssetDef.getLevelPath();
|
||||
|
||||
//write out to file
|
||||
EWorldEditor.contextActionObject.save(%levelFilePath);
|
||||
|
||||
AssetDatabase.releaseAsset(%assetId);
|
||||
|
||||
getRootScene().add(%subScene);
|
||||
|
||||
EWorldEditor.contextActionObject.delete();
|
||||
|
||||
%subScene.load();
|
||||
|
||||
%subScene.recalculateBounds();
|
||||
|
||||
%scalar = $SubScene::createScalar;
|
||||
if(%scalar $= "")
|
||||
%scalar = 1.5;
|
||||
|
||||
//pad for loading boundary
|
||||
%subScene.scale = VectorScale(%subScene.scale, %scalar);
|
||||
}
|
||||
|
||||
function SubSceneAsset::onWorldEditorDropped(%assetDef, %position)
|
||||
{
|
||||
%assetId = %assetDef.getAssetId();
|
||||
|
||||
if(!%assetDef.isSubScene)
|
||||
{
|
||||
errorf("Cannot drag-and-drop LevelAsset into WorldEditor");
|
||||
return;
|
||||
}
|
||||
|
||||
%newSubScene = new SubScene()
|
||||
{
|
||||
position = %position;
|
||||
levelAsset = %assetId;
|
||||
};
|
||||
|
||||
getScene(0).add(%newSubScene);
|
||||
|
||||
%newSubScene.load();
|
||||
%newSubScene.recalculateBounds();
|
||||
|
||||
EWorldEditor.clearSelection();
|
||||
EWorldEditor.selectObject(%newSubScene);
|
||||
|
||||
EWorldEditor.dropSelection();
|
||||
|
||||
EWorldEditor.isDirty = true;
|
||||
|
||||
MECreateUndoAction::submit(%newSubScene );
|
||||
}
|
||||
|
|
@ -1,23 +1,25 @@
|
|||
function AssetBrowser::setupCreateNewTerrainAsset(%this)
|
||||
AssetBrowser::registerAssetType("TerrainAsset", "Terrains");
|
||||
|
||||
function TerrainAsset::setupCreateNew()
|
||||
{
|
||||
NewAssetPropertiesInspector.startGroup("Terrain");
|
||||
NewAssetPropertiesInspector.addField("resolution", "Terrain Texture Resolution", "list", "Is this script used on the server?", "1024", "256,512,1024,2048,4096", %this.newAssetSettings);
|
||||
NewAssetPropertiesInspector.addField("genWithNoise", "Generate Terrain With Noise", "bool", "Is this script used on the server?", "0", "2", %this.newAssetSettings);
|
||||
NewAssetPropertiesInspector.addField("resolution", "Terrain Texture Resolution", "list", "Is this script used on the server?", "1024", "256,512,1024,2048,4096", $CurrentAssetBrowser.newAssetSettings);
|
||||
NewAssetPropertiesInspector.addField("genWithNoise", "Generate Terrain With Noise", "bool", "Is this script used on the server?", "0", "2", $CurrentAssetBrowser.newAssetSettings);
|
||||
NewAssetPropertiesInspector.endGroup();
|
||||
|
||||
/*NewAssetPropertiesInspector.startGroup("Terrain - Import");
|
||||
NewAssetPropertiesInspector.addField("importDetails", "Import Heightmap", "button", "Import an existing heightmap", "", "Canvas.pushDialog( TerrainImportGui );", %this.newAssetSettings);
|
||||
NewAssetPropertiesInspector.addField("importDetails", "Import Heightmap", "button", "Import an existing heightmap", "", "Canvas.pushDialog( TerrainImportGui );", $CurrentAssetBrowser.newAssetSettings);
|
||||
NewAssetPropertiesInspector.endGroup();*/
|
||||
}
|
||||
|
||||
function AssetBrowser::createTerrainAsset(%this)
|
||||
function TerrainAsset::onCreateNew()
|
||||
{
|
||||
%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||
%moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
%assetName = $CurrentAssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%assetType = AssetBrowser.newAssetSettings.assetType;
|
||||
%assetType = $CurrentAssetBrowser.newAssetSettings.assetType;
|
||||
%assetPath = NewAssetTargetAddress.getText() @ "/";
|
||||
|
||||
//Ensure anything we generate goes into the right directory
|
||||
|
|
@ -31,8 +33,8 @@ function AssetBrowser::createTerrainAsset(%this)
|
|||
AssetName = %assetName;
|
||||
versionId = 1;
|
||||
terrainFile = %assetName @ ".ter";
|
||||
resolution = %this.newAssetSettings.resolution;
|
||||
genWithNoise = %this.newAssetSettings.genWithNoise;
|
||||
resolution = $CurrentAssetBrowser.newAssetSettings.resolution;
|
||||
genWithNoise = $CurrentAssetBrowser.newAssetSettings.genWithNoise;
|
||||
};
|
||||
|
||||
TamlWrite(%asset, %tamlpath);
|
||||
|
|
@ -40,9 +42,9 @@ function AssetBrowser::createTerrainAsset(%this)
|
|||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
||||
AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath);
|
||||
|
||||
AssetBrowser.refresh();
|
||||
$CurrentAssetBrowser.refresh();
|
||||
|
||||
$createdTerrainBlock = TerrainBlock::createNew( %assetName, %this.newAssetSettings.resolution, "", %this.newAssetSettings.genWithNoise );
|
||||
$createdTerrainBlock = TerrainBlock::createNew( %assetName, $CurrentAssetBrowser.newAssetSettings.resolution, "", $CurrentAssetBrowser.newAssetSettings.genWithNoise );
|
||||
|
||||
MECreateUndoAction::submit($createdTerrainBlock);
|
||||
|
||||
|
|
@ -55,12 +57,12 @@ function AssetBrowser::createTerrainAsset(%this)
|
|||
// This will update an existing terrain with the name %terrainName,
|
||||
// or create a new one if %terrainName isn't a TerrainBlock
|
||||
$createdTerrainBlock = TerrainBlock::import( $createdTerrainBlock,
|
||||
AssetBrowser.newAssetSettings.heightMapPng,
|
||||
AssetBrowser.newAssetSettings.metersPerPixel,
|
||||
AssetBrowser.newAssetSettings.heightScale,
|
||||
AssetBrowser.newAssetSettings.opacityNames,
|
||||
AssetBrowser.newAssetSettings.materialNames,
|
||||
AssetBrowser.newAssetSettings.flipYAxis );
|
||||
$CurrentAssetBrowser.newAssetSettings.heightMapPng,
|
||||
$CurrentAssetBrowser.newAssetSettings.metersPerPixel,
|
||||
$CurrentAssetBrowser.newAssetSettings.heightScale,
|
||||
$CurrentAssetBrowser.newAssetSettings.opacityNames,
|
||||
$CurrentAssetBrowser.newAssetSettings.materialNames,
|
||||
$CurrentAssetBrowser.newAssetSettings.flipYAxis );
|
||||
|
||||
if ( isObject( $createdTerrainBlock ) )
|
||||
{
|
||||
|
|
@ -130,87 +132,35 @@ function createTerrainBlock(%assetId)
|
|||
//
|
||||
}
|
||||
|
||||
function AssetBrowser::editTerrainAsset(%this, %assetDef)
|
||||
|
||||
function TerrainAsset::onWorldEditorDropped(%this, %position)
|
||||
{
|
||||
createTerrainBlock(%this.getAssetId());
|
||||
}
|
||||
|
||||
function AssetBrowser::duplicateTerrainAsset(%this, %assetDef, %targetModule)
|
||||
function TerrainAsset::buildBrowserElement(%this, %previewData)
|
||||
{
|
||||
}
|
||||
|
||||
function AssetBrowser::importTerrainAsset(%this, %assetDef)
|
||||
{
|
||||
}
|
||||
|
||||
function AssetBrowser::dragAndDropTerrainAsset(%this, %assetDef, %dropTarget)
|
||||
{
|
||||
if(!isObject(%dropTarget))
|
||||
return;
|
||||
}
|
||||
|
||||
function AssetBrowser::onTerrainAssetEditorDropped(%this, %assetDef, %position)
|
||||
{
|
||||
createTerrainBlock(%assetDef.getAssetId());
|
||||
}
|
||||
|
||||
function AssetBrowser::renameTerrainAsset(%this, %assetDef, %newAssetId, %originalName, %newName)
|
||||
{
|
||||
}
|
||||
|
||||
function AssetBrowser::deleteTerrainAsset(%this, %assetDef)
|
||||
{
|
||||
}
|
||||
|
||||
function AssetBrowser::moveTerrainAsset(%this, %assetDef, %destination)
|
||||
{
|
||||
%currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
|
||||
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
|
||||
|
||||
%newAssetPath = moveAssetFile(%assetDef, %destination);
|
||||
|
||||
if(%newAssetPath $= "")
|
||||
return false;
|
||||
|
||||
moveAssetLooseFile(%assetDef.getTerrainFilePath(), %destination);
|
||||
|
||||
AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
|
||||
AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
|
||||
}
|
||||
|
||||
function AssetBrowser::buildTerrainAssetPreview(%this, %assetDef, %previewData)
|
||||
{
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetName = %this.assetName;
|
||||
%previewData.assetPath = "";
|
||||
|
||||
%previewData.previewImage = "ToolsModule:terrainIcon_image";
|
||||
|
||||
%previewData.assetFriendlyName = %assetDef.gameObjectName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = "Asset Name: " @ %assetDef.assetName @
|
||||
%previewData.assetFriendlyName = %this.gameObjectName;
|
||||
%previewData.assetDesc = %this.description;
|
||||
%previewData.tooltip = "Asset Name: " @ %this.assetName @
|
||||
"\nAsset Type: Terrain Asset" @
|
||||
"\nAsset Definition ID: " @ %assetDef @
|
||||
"\nDefinition Path: " @ %assetDef.getTerrainFilePath();
|
||||
"\nAsset Definition ID: " @ %this @
|
||||
"\nDefinition Path: " @ %this.getTerrainFilePath();
|
||||
|
||||
if(%this.selectMode)
|
||||
{
|
||||
%previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );";
|
||||
%previewData.doubleClickCommand = $CurrentAssetBrowser @ ".selectAsset( " @ $CurrentAssetBrowser @ ".selectedAsset );";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset")
|
||||
%previewData.doubleClickCommand = "";
|
||||
else
|
||||
%previewData.doubleClickCommand = "createTerrainBlock(\""@%assetDef.getAssetId()@"\");";
|
||||
%previewData.doubleClickCommand = "createTerrainBlock(\""@%this.getAssetId()@"\");";
|
||||
}
|
||||
}
|
||||
|
||||
function GuiInspectorTypeTerrainAssetPtr::onClick( %this, %fieldName )
|
||||
{
|
||||
//Get our data
|
||||
%obj = %this.getInspector().getInspectObject(0);
|
||||
}
|
||||
|
||||
function GuiInspectorTypeTerrainAssetPtr::onControlDropped( %this, %payload, %position )
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -1,11 +1,13 @@
|
|||
function AssetBrowser::createTerrainMaterialAsset(%this)
|
||||
AssetBrowser::registerAssetType("TerrainMaterialAsset", "Terrain Materials");
|
||||
|
||||
function TerrainMaterialAsset::onCreateNew()
|
||||
{
|
||||
%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
||||
%moduleName = $CurrentAssetBrowser.newAssetSettings.moduleName;
|
||||
%modulePath = "data/" @ %moduleName;
|
||||
|
||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
||||
%assetName = $CurrentAssetBrowser.newAssetSettings.assetName;
|
||||
|
||||
%assetType = AssetBrowser.newAssetSettings.assetType;
|
||||
%assetType = $CurrentAssetBrowser.newAssetSettings.assetType;
|
||||
%assetPath = NewAssetTargetAddress.getText() @ "/";
|
||||
|
||||
%tamlpath = %assetPath @ %assetName @ ".asset.taml";
|
||||
|
|
@ -57,7 +59,7 @@ function AssetBrowser::createTerrainMaterialAsset(%this)
|
|||
|
||||
AssetDatabase.acquireAsset("\"" @ %moduleName @ ":" @ %assetName @ "\"");
|
||||
|
||||
AssetBrowser.refresh();
|
||||
$CurrentAssetBrowser.refresh();
|
||||
|
||||
//If we've got the terrain mat editor open, go ahead and update it all
|
||||
TerrainMaterialDlg.onWake();
|
||||
|
|
@ -65,112 +67,70 @@ function AssetBrowser::createTerrainMaterialAsset(%this)
|
|||
return %tamlpath;
|
||||
}
|
||||
|
||||
function AssetBrowser::editTerrainMaterialAsset(%this, %assetDef)
|
||||
function TerrainAssetMaterial::onEdit(%this)
|
||||
{
|
||||
TerrainMaterialDlg.show(0, 0, 0);
|
||||
TerrainMaterialDlg.setActiveMaterial(%assetDef.assetName);
|
||||
TerrainMaterialDlg.setActiveMaterial(%this.assetName);
|
||||
}
|
||||
|
||||
function AssetBrowser::duplicateTerrainMaterialAsset(%this, %assetDef, %targetModule)
|
||||
{
|
||||
}
|
||||
|
||||
function AssetBrowser::importTerrainMaterialAsset(%this, %assetDef)
|
||||
{
|
||||
}
|
||||
|
||||
function AssetBrowser::dragAndDropTerrainMaterialAsset(%this, %assetDef, %dropTarget)
|
||||
{
|
||||
if(!isObject(%dropTarget))
|
||||
return;
|
||||
}
|
||||
|
||||
function AssetBrowser::renameTerrainMaterialAsset(%this, %assetDef, %newAssetId, %originalName, %newName)
|
||||
{
|
||||
}
|
||||
|
||||
function AssetBrowser::deleteTerrainMaterialAsset(%this, %assetDef)
|
||||
{
|
||||
}
|
||||
|
||||
function AssetBrowser::moveTerrainMaterialAsset(%this, %assetDef, %destination)
|
||||
{
|
||||
%currentModule = AssetDatabase.getAssetModule(%assetDef.getAssetId());
|
||||
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(%destination);
|
||||
|
||||
%newAssetPath = moveAssetFile(%assetDef, %destination);
|
||||
|
||||
if(%newAssetPath $= "")
|
||||
return false;
|
||||
|
||||
moveAssetLooseFile(%assetDef.getScriptPath(), %destination);
|
||||
|
||||
AssetDatabase.removeDeclaredAsset(%assetDef.getAssetId());
|
||||
AssetDatabase.addDeclaredAsset(%targetModule, %newAssetPath);
|
||||
}
|
||||
|
||||
function AssetBrowser::buildTerrainMaterialAssetPreview(%this, %assetDef, %previewData, %forcePreviewRegenerate)
|
||||
function TerrainAssetMaterial::buildBrowserElement(%this, %previewData)
|
||||
{
|
||||
%previewData.previewImage = "ToolsModule:genericAssetIcon_image";
|
||||
%previewData.previewLoaded = false; //this marks it for loading progressively later
|
||||
|
||||
%previewData.assetName = %assetDef.assetName;
|
||||
%previewData.assetName = %this.assetName;
|
||||
%previewData.assetPath = "";
|
||||
%previewData.doubleClickCommand = "";
|
||||
|
||||
%previewData.assetFriendlyName = %assetDef.gameObjectName;
|
||||
%previewData.assetDesc = %assetDef.description;
|
||||
%previewData.tooltip = %assetDef.gameObjectName;
|
||||
%previewData.assetFriendlyName = %this.gameObjectName;
|
||||
%previewData.assetDesc = %this.description;
|
||||
%previewData.tooltip = %this.gameObjectName;
|
||||
|
||||
%definitionPath = %assetDef.getScriptPath();
|
||||
%definitionPath = %this.getScriptPath();
|
||||
if(%definitionPath $= "")
|
||||
%definitionPath = %assetDef.getFilename();
|
||||
%definitionPath = %this.getFilename();
|
||||
|
||||
%previewData.tooltip = "Asset Name: " @ %assetDef.assetName @
|
||||
%previewData.tooltip = "Asset Name: " @ %this.assetName @
|
||||
"\nAsset Type: Terrain Material Asset" @
|
||||
"\nAsset Definition ID: " @ %assetDef @
|
||||
"\nAsset Definition ID: " @ %this @
|
||||
"\nDefinition Path: " @ %definitionPath;
|
||||
}
|
||||
|
||||
function AssetBrowser::generateTerrainMaterialAssetPreviewImage(%this, %previewButton, %forceRegenerate)
|
||||
function TerrainAssetMaterial::generatePreviewImage(%this, %previewButton, %forceRegenerate)
|
||||
{
|
||||
if(%forceRegenerate $= "")
|
||||
%forceRegenerate = false;
|
||||
|
||||
%assetId = %previewButton.moduleName @ ":" @ %previewButton.assetName;
|
||||
|
||||
%assetDef = AssetDatabase.acquireAsset(%assetId);
|
||||
|
||||
%module = %this.dirHandler.getModuleFromAddress(makeRelativePath(filePath(AssetDatabase.getAssetFilePath(%assetDef.getAssetId()))));
|
||||
%module = $CurrentAssetBrowser.dirHandler.getModuleFromAddress(makeRelativePath(filePath(AssetDatabase.getAssetFilePath(%this.getAssetId()))));
|
||||
%previewPath = "tools/resources/previewCache/" @ %module.moduleId @ "/";
|
||||
|
||||
if(!IsDirectory(%previewPath))
|
||||
{
|
||||
%this.dirHandler.createFolder(%previewPath);
|
||||
$CurrentAssetBrowser.dirHandler.createFolder(%previewPath);
|
||||
}
|
||||
|
||||
%generatePreview = false;
|
||||
|
||||
%previewFilePath = %previewPath @ %assetDef.assetName @ "_Preview.dds";
|
||||
%previewFilePath = %previewPath @ %this.assetName @ "_Preview.dds";
|
||||
if(!isFile(%previewFilePath))
|
||||
{
|
||||
%generatePreview = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isObject(%assetDef.materialDefinitionName))
|
||||
if(isObject(%this.materialDefinitionName))
|
||||
{
|
||||
if(compareFileTimes(%assetDef.materialDefinitionName.getDiffuseMap(), %previewFilePath) == 1 ||
|
||||
compareFileTimes(%assetDef.materialDefinitionName.getFilename(), %previewFilePath) == 1)
|
||||
if(compareFileTimes(%this.materialDefinitionName.getDiffuseMap(), %previewFilePath) == 1 ||
|
||||
compareFileTimes(%this.materialDefinitionName.getFilename(), %previewFilePath) == 1)
|
||||
%generatePreview = true;
|
||||
}
|
||||
}
|
||||
|
||||
%previewAssetName = %module.moduleId @ "_" @ %assetDef.assetName @ "_PreviewImage";
|
||||
%previewAssetName = %module.moduleId @ "_" @ %this.assetName @ "_PreviewImage";
|
||||
|
||||
if(%generatePreview || %forceRegenerate)
|
||||
{
|
||||
if(isObject(%assetDef.materialDefinitionName))
|
||||
if(isObject(%this.materialDefinitionName))
|
||||
{
|
||||
%previewShapeDef = AssetDatabase.acquireAsset("ToolsModule:previewSphereShape");
|
||||
%generatedFilePath = %previewShapeDef.generateCachedPreviewImage(256, DummyTerrMatPreview);
|
||||
|
|
@ -178,7 +138,6 @@ function AssetBrowser::generateTerrainMaterialAssetPreviewImage(%this, %previewB
|
|||
pathCopy(%generatedFilePath, %previewFilePath);
|
||||
fileDelete(%generatedFilePath);
|
||||
|
||||
|
||||
if(!AssetDatabase.isDeclaredAsset("ToolsModule:" @ %previewAssetName))
|
||||
{
|
||||
%previewAsset = new ImageAsset()
|
||||
|
|
@ -216,15 +175,4 @@ function AssetBrowser::generateTerrainMaterialAssetPreviewImage(%this, %previewB
|
|||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function GuiInspectorTypeTerrainMaterialAssetPtr::onClick( %this, %fieldName )
|
||||
{
|
||||
//Get our data
|
||||
%obj = %this.getInspector().getInspectObject(0);
|
||||
}
|
||||
|
||||
function GuiInspectorTypeTerrainMaterialAssetPtr::onControlDropped( %this, %payload, %position )
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -179,6 +179,39 @@ function directoryHandler::getModuleFromAddress(%this, %address)
|
|||
return "";
|
||||
}
|
||||
|
||||
function getModuleFromAddress(%address)
|
||||
{
|
||||
%moduleList = ModuleDatabase.findModules();
|
||||
|
||||
for(%i=0; %i < getWordCount(%moduleList); %i++)
|
||||
{
|
||||
%module = getWord(%moduleList, %i);
|
||||
%modulePath = makeRelativePath(%module.ModulePath);
|
||||
|
||||
//We don't want to add stuff directly to the root core or tools modules
|
||||
//if(%modulePath $= "Core" || %modulePath $= "Tools")
|
||||
// continue;
|
||||
|
||||
if(startsWith(%address, %modulePath))
|
||||
{
|
||||
return %module;
|
||||
}
|
||||
}
|
||||
/*//break down the address
|
||||
%folderCount = getTokenCount(%address, "/");
|
||||
|
||||
for(%f=0; %f < %folderCount; %f++)
|
||||
{
|
||||
%folderName = getToken(%address, "/", %f);
|
||||
|
||||
%module = ModuleDatabase.findModule(%folderName);
|
||||
if(%module !$= "")
|
||||
return %module;
|
||||
}*/
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
function directoryHandler::getFolderTreeItemFromAddress(%this, %address)
|
||||
{
|
||||
//break down the address
|
||||
|
|
|
|||
|
|
@ -1,67 +1,30 @@
|
|||
function AssetBrowser_editAsset::saveAsset(%this)
|
||||
{
|
||||
%file = AssetDatabase.getAssetFilePath(%this.editedAssetId);
|
||||
%success = TamlWrite(AssetBrowser_editAsset.editedAsset, %file);
|
||||
AssetBrowser_editAssetWindow.text = "Asset Properties";
|
||||
|
||||
AssetBrowser.reloadAsset(%this.editedAssetId);
|
||||
|
||||
AssetBrowser.refresh();
|
||||
|
||||
%assetType = AssetDatabase.getAssetType(%this.editedAssetId);
|
||||
%assetDef = AssetDatabase.acquireAsset(%this.editedAssetId);
|
||||
%assetDef.refreshAsset();
|
||||
|
||||
AssetBrowser.call("on" @ %assetType @ "Changed", %assetDef);
|
||||
AssetDatabase.releaseAsset(%this.editedAssetId);
|
||||
AssetBrowser.callAssetTypeFunc(%this.editedObjectType, "onSaveProperties", %this.editedObjectData);
|
||||
AssetBrowser.callAssetTypeFunc(%this.editedObjectType, "onChanged", %this.editedObjectData);
|
||||
|
||||
Canvas.popDialog(AssetBrowser_editAsset);
|
||||
}
|
||||
|
||||
function AssetBrowser::editAsset(%this, %assetDef)
|
||||
{
|
||||
//Find out what type it is
|
||||
//If the passed-in definition param is blank, then we're likely called via a popup
|
||||
if(%assetDef $= "")
|
||||
if(%this.selectMode)
|
||||
{
|
||||
if(AssetDatabase.isDeclaredAsset(EditAssetPopup.assetId))
|
||||
{
|
||||
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if it's not a valid asset at all, then it's probably a folder
|
||||
%folder = strreplace(EditAssetPopup.assetId, ":", "/");
|
||||
if(isDirectory(%folder))
|
||||
{
|
||||
AssetBrowser.navigateTo(%folder);
|
||||
}
|
||||
else
|
||||
{
|
||||
%object = getToken(EditAssetPopup.assetId, ":", 1);
|
||||
if(isObject(%object))
|
||||
{
|
||||
if(%object.isMemberOfClass("SimDatablock"))
|
||||
{
|
||||
DatablockEditorPlugin.openDatablock( %object );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
%this.selectAsset(%this.selectedAsset);
|
||||
}
|
||||
else if(AssetDatabase.isDeclaredAsset(%assetDef))
|
||||
else
|
||||
{
|
||||
//Turns out we were passed an assetid, not an asset definition.
|
||||
//Grab the asset def from that
|
||||
%assetDef = AssetDatabase.acquireAsset(%assetDef);
|
||||
}
|
||||
|
||||
if(%assetDef !$= "")
|
||||
{
|
||||
%assetType = %assetDef.getClassName();
|
||||
|
||||
//Build out the edit command
|
||||
%buildCommand = %this @ ".edit" @ %assetType @ "(" @ %assetDef @ ");";
|
||||
eval(%buildCommand);
|
||||
if(isObject(%assetDef))
|
||||
{
|
||||
%assetType = AssetDatabase.getAssetType(%assetDef.getAssetId());
|
||||
%this.callAssetTypeFunc(%assetType, "onEdit", %assetDef);
|
||||
}
|
||||
else if(%this.popupMenu.objectType !$= "" && %this.popupMenu.objectData !$= "")
|
||||
{
|
||||
%this.callAssetTypeFunc(%this.popupMenu.objectType, "onEdit", %this.popupMenu.objectData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -75,27 +38,9 @@ function AssetBrowser::appendSubLevel(%this)
|
|||
|
||||
function AssetBrowser::editAssetInfo(%this)
|
||||
{
|
||||
Canvas.pushDialog(AssetBrowser_editAsset);
|
||||
|
||||
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
||||
|
||||
AssetBrowser.tempAsset = %assetDef.deepClone();
|
||||
|
||||
AssetEditInspector.inspect(AssetBrowser.tempAsset);
|
||||
AssetBrowser_editAsset.editedAssetId = EditAssetPopup.assetId;
|
||||
AssetBrowser_editAsset.editedAsset = AssetBrowser.tempAsset;
|
||||
|
||||
//remove some of the groups we don't need:
|
||||
for(%i=0; %i < AssetEditInspector.getCount(); %i++)
|
||||
if(%this.popupMenu.objectType !$= "" && %this.popupMenu.objectData !$= "")
|
||||
{
|
||||
%caption = AssetEditInspector.getObject(%i).caption;
|
||||
|
||||
if(%caption $= "Ungrouped" || %caption $= "Object" || %caption $= "Editing"
|
||||
|| %caption $= "Persistence" || %caption $= "Dynamic Fields")
|
||||
{
|
||||
AssetEditInspector.remove(AssetEditInspector.getObject(%i));
|
||||
%i--;
|
||||
}
|
||||
%this.callAssetTypeFunc(%this.popupMenu.objectType, "onEditProperties", %this.popupMenu.objectData);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -127,17 +72,17 @@ function AssetBrowser::refreshAsset(%this, %assetId)
|
|||
//------------------------------------------------------------
|
||||
function AssetBrowser::regeneratePreviewImage(%this)
|
||||
{
|
||||
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
||||
%assetDef = AssetDatabase.acquireAsset(AssetBrowser.popupMenu.objectData);
|
||||
%dummyObj = new ScriptObject();
|
||||
%dummyObj.moduleName = AssetDatabase.getAssetModule(EditAssetPopup.assetId).moduleId;
|
||||
%dummyObj.assetName = AssetDatabase.getAssetName(EditAssetPopup.assetId);
|
||||
|
||||
%regenCommand = "AssetBrowser.generate" @ EditAssetPopup.assetType @
|
||||
"PreviewImage(" @ %dummyObj @ ", true);";
|
||||
eval(%regenCommand);
|
||||
%dummyObj.moduleName = AssetDatabase.getAssetModule(AssetBrowser.popupMenu.objectData).moduleId;
|
||||
%dummyObj.assetName = AssetDatabase.getAssetName(AssetBrowser.popupMenu.objectData);
|
||||
|
||||
%assetType = AssetBrowser.popupMenu.objectType;
|
||||
|
||||
AssetBrowser.callAssetTypeFunc(%assetType, "generatePreviewImage", %dummyObj, true);
|
||||
|
||||
%dummyObj.delete();
|
||||
AssetDatabase.releaseAsset(EditAssetPopup.assetId);
|
||||
AssetDatabase.releaseAsset(AssetBrowser.popupMenu.objectData);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
|
@ -344,8 +289,8 @@ function moveAssetLooseFile(%file, %destinationPath)
|
|||
|
||||
function AssetBrowser::duplicateAsset(%this)
|
||||
{
|
||||
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
||||
%assetType = AssetDatabase.getAssetType(EditAssetPopup.assetId);
|
||||
%assetDef = AssetDatabase.acquireAsset(%this.popupMenu.objectData);
|
||||
%assetType = %this.popupMenu.objectType;
|
||||
|
||||
%trailingNum = getTrailingNumber(%assetDef.assetName);
|
||||
if(%trailingNum != -1)
|
||||
|
|
@ -370,18 +315,16 @@ function AssetBrowser::duplicateAsset(%this)
|
|||
|
||||
function AssetBrowser::doDuplicateAsset(%this)
|
||||
{
|
||||
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
||||
%assetType = AssetDatabase.getAssetType(EditAssetPopup.assetId);
|
||||
%assetType = %this.popupMenu.objectType;
|
||||
%assetDef = AssetDatabase.acquireAsset(%this.popupMenu.objectData);
|
||||
|
||||
if(AssetBrowser_assetNameEditTxt.text !$= "" && AssetBrowser_assetNameEditTxt.text !$= %assetDef.assetName)
|
||||
{
|
||||
//this acts as a redirect based on asset type and will enact the appropriate function
|
||||
//so for a GameObjectAsset, it'll become %this.duplicateGameObjectAsset(%assetDef, %targetModule);
|
||||
//and call to the tools/assetBrowser/scripts/assetTypes/gameObject.tscript file for implementation
|
||||
if(%this.isMethod("duplicate"@%assetType))
|
||||
eval(%this @ ".duplicate"@%assetType@"("@%assetDef@","@AssetBrowser_assetNameEditTxt.text@");");
|
||||
|
||||
AssetBrowser.refresh();
|
||||
AssetDatabase.releaseAsset(%this.popupMenu.objectData);
|
||||
|
||||
%this.callAssetTypeFunc(%assetType, "onDuplicate", %this.popupMenu.objectData, AssetBrowser_assetNameEditTxt.text);
|
||||
|
||||
%this.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -440,31 +383,8 @@ function AssetBrowser::confirmDeleteAsset(%this)
|
|||
%currentSelectedItem = AssetBrowserFilterTree.getSelectedItem();
|
||||
%currentItemParent = AssetBrowserFilterTree.getParentItem(%currentSelectedItem);
|
||||
|
||||
if(EditFolderPopup.visible)
|
||||
{
|
||||
if(EditFolderPopup.dirPath !$= "")
|
||||
%folderPath = EditFolderPopup.dirPath;
|
||||
else
|
||||
%folderPath = AssetBrowserFilterTree.getItemValue(%currentSelectedItem) @ "/" @ AssetBrowserFilterTree.getItemText(%currentSelectedItem);
|
||||
|
||||
if(%this.isMethod("deleteFolder"))
|
||||
eval(%this @ ".deleteFolder(\""@%folderPath@"\");");
|
||||
}
|
||||
else
|
||||
{
|
||||
%assetDef = AssetDatabase.acquireAsset(EditAssetPopup.assetId);
|
||||
%assetType = AssetDatabase.getAssetType(EditAssetPopup.assetType);
|
||||
|
||||
if(!isObject(%assetDef))
|
||||
return;
|
||||
|
||||
//Do any cleanup required given the type
|
||||
if(%this.isMethod("delete"@%assetType))
|
||||
eval(%this @ ".delete"@%assetType@"("@%assetDef@");");
|
||||
|
||||
AssetDatabase.deleteAsset(EditAssetPopup.assetId, true, false);
|
||||
}
|
||||
|
||||
%this.callAssetTypeFunc(%this.popupMenu.objectType, "onDelete", %this.popupMenu.objectData);
|
||||
|
||||
%this.refresh();
|
||||
}
|
||||
|
||||
|
|
@ -522,21 +442,27 @@ function AssetBrowser::updateAssetReference(%this, %targetPath, %oldAssetId, %ne
|
|||
|
||||
function AssetBrowser::openFileLocation(%this)
|
||||
{
|
||||
%filePath = "";
|
||||
if(EditAssetPopup.assetId !$= "")
|
||||
if(isFunction("systemCommand"))
|
||||
{
|
||||
if(AssetDatabase.isDeclaredAsset(EditAssetPopup.assetId))
|
||||
warnf("AssetBrowser::openFileLocation() - systemCommand function disabled in this build. Unable to launch application to edit file.");
|
||||
return;
|
||||
}
|
||||
|
||||
%filePath = "";
|
||||
if(%this.popuMenu.assetId !$= "")
|
||||
{
|
||||
if(AssetDatabase.isDeclaredAsset(%this.popuMenu.objectData))
|
||||
{
|
||||
%filePath = AssetDatabase.getAssetPath(EditAssetPopup.assetId);
|
||||
%filePath = AssetDatabase.getAssetPath(%this.popuMenu.objectData);
|
||||
}
|
||||
else
|
||||
{
|
||||
//probably a file path
|
||||
%pathSplit = strpos(EditAssetPopup.assetId, ":");
|
||||
%pathSplit = strpos(%this.popuMenu.objectData, ":");
|
||||
if(%pathSplit != -1)
|
||||
{
|
||||
%path = getSubStr(EditAssetPopup.assetId, 0, %pathSplit);
|
||||
%file = getSubStr(EditAssetPopup.assetId, %pathSplit + 1);
|
||||
%path = getSubStr(%this.popuMenu.objectData, 0, %pathSplit);
|
||||
%file = getSubStr(%this.popuMenu.objectData, %pathSplit + 1);
|
||||
|
||||
//datablocks pack the originator file in the parent path as-is, so check that
|
||||
if(fileExt(%path) !$= "")
|
||||
|
|
@ -550,14 +476,6 @@ function AssetBrowser::openFileLocation(%this)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(EditLevelAssetPopup.assetId !$= "")
|
||||
{
|
||||
%filePath = AssetDatabase.getAssetPath(EditAssetPopup.assetId);
|
||||
}
|
||||
else if(EditTerrainAssetPopup.assetId !$= "")
|
||||
{
|
||||
%filePath = AssetDatabase.getAssetPath(EditAssetPopup.assetId);
|
||||
}
|
||||
|
||||
if(isFile(%filePath) || isDirectory(%filePath))
|
||||
{
|
||||
|
|
@ -578,20 +496,27 @@ function AssetBrowser::openFileLocation(%this)
|
|||
}
|
||||
}
|
||||
|
||||
function AssetBrowser::openFolderLocation(%this)
|
||||
function AssetBrowser::openFolderLocation(%this, %folderPath)
|
||||
{
|
||||
%filePath = AssetBrowser.dirHandler.currentAddress;
|
||||
if(!isFunction("systemCommand"))
|
||||
{
|
||||
warn("AssetBrowser::openFolderLocation() - systemCommand function disabled in this build. Unable to launch application to open this folder.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(%filePath !$= "")
|
||||
if(%folderPath $= "")
|
||||
%folderPath = filePath(%this.dirHandler.currentAddress);
|
||||
|
||||
if(%folderPath !$= "")
|
||||
{
|
||||
if($platform $= "windows")
|
||||
{
|
||||
%cmd = "cd \"" @ makeFullPath(%filePath) @ "\" && start .";
|
||||
%cmd = "cd \"" @ makeFullPath(%folderPath) @ "\" && start .";
|
||||
systemCommand(%cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
%cmd = "open \"" @ makeFullPath(%filePath) @ "\"";
|
||||
%cmd = "open \"" @ makeFullPath(%folderPath) @ "\"";
|
||||
systemCommand(%cmd);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,11 +119,7 @@ function AssetBrowser::setupCreateNewAsset(%this, %assetType, %moduleName, %call
|
|||
NewAssetPropertiesInspector.addCallbackField("description", "Description", "Command", "Description of the new asset", "", "", "updateNewAssetField", %this.newAssetSettings);
|
||||
NewAssetPropertiesInspector.endGroup();
|
||||
|
||||
if(%this.isMethod("setupCreateNew"@%assetType))
|
||||
{
|
||||
%command = %this @ ".setupCreateNew"@%assetType @"();";
|
||||
eval(%command);
|
||||
}
|
||||
%this.callAssetTypeFunc(%assetType, "setupCreateNew");
|
||||
|
||||
NewAssetPropertiesInspector.refresh();
|
||||
}
|
||||
|
|
@ -255,7 +251,7 @@ function CreateNewAsset()
|
|||
return;
|
||||
}
|
||||
|
||||
%assetFilePath = eval(AssetBrowser @ ".create"@%assetType@"();");
|
||||
%assetFilePath = AssetBrowser.callAssetTypeFunc(%assetType, "onCreateNew");
|
||||
|
||||
Canvas.popDialog(AssetBrowser_newAsset);
|
||||
|
||||
|
|
|
|||
|
|
@ -183,8 +183,6 @@ function AssetBrowser::buildPopupMenus(%this)
|
|||
item[12] = "View Loose Files" TAB "" TAB "AssetBrowser.importLooseFiles();";
|
||||
Item[ 13 ] = "-";
|
||||
item[ 14 ] = "Open Folder Location" TAB "" TAB "AssetBrowser.openFolderLocation();";
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -266,13 +264,18 @@ function AssetBrowser::buildPopupMenus(%this)
|
|||
radioSelection = false;
|
||||
};
|
||||
|
||||
AssetTypeListPopup.addItem(0, AssetFilterTypeList.getKey(0) TAB "" TAB "AssetBrowser.toggleAssetTypeFilter(" @ 0 @ ");");
|
||||
AssetTypeListPopup.addItem(0, "All" TAB "" TAB %this @ ".toggleAssetTypeFilter(0);");
|
||||
AssetTypeListPopup.addItem(1, "-");
|
||||
|
||||
for(%i=1; %i < AssetFilterTypeList.Count(); %i++)
|
||||
%listIndex = 1;
|
||||
for(%i=0; %i < ABAssetTypesList.Count(); %i++)
|
||||
{
|
||||
%assetTypeName = AssetFilterTypeList.getKey(%i);
|
||||
AssetTypeListPopup.addItem(%i+1, %assetTypeName TAB "" TAB "AssetBrowser.toggleAssetTypeFilter(" @ %i + 1 @ ");");
|
||||
%assetTypeData = ABAssetTypesList.getValue(%i);
|
||||
if(getField(%assetTypeData, 3) != true)
|
||||
continue;
|
||||
|
||||
AssetTypeListPopup.addItem(%listIndex, getField(%assetTypeData,1) TAB "" TAB %this @ ".toggleAssetTypeFilter(" @ %listIndex @ ");");
|
||||
%listIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -315,44 +318,6 @@ function AssetBrowser::buildPopupMenus(%this)
|
|||
};
|
||||
}
|
||||
|
||||
if( !isObject( EditGameObjectAssetPopup ) )
|
||||
{
|
||||
new PopupMenu( EditGameObjectAssetPopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
//isPopup = true;
|
||||
|
||||
item[ 0 ] = "Open GameObject Editor" TAB "" TAB "echo(\"Not yet implemented.\");";
|
||||
item[ 1 ] = "Edit GameObject Script" TAB "" TAB "AssetBrowser.editGameObjectAssetScript(AssetDatabase.acquireAsset(EditGameObjectAssetPopup.assetId));";
|
||||
item[ 2 ] = "-";
|
||||
item[ 3 ] = "Apply Instance to GameObject" TAB "" TAB "AssetBrowser.applyInstanceToGameObject(AssetDatabase.acquireAsset(EditGameObjectAssetPopup.assetId));";
|
||||
item[ 4 ] = "Reset Instance to GameObject" TAB "" TAB "echo(\"Not yet implemented.\");";
|
||||
item[ 5 ] = "-";
|
||||
item[ 6 ] = "Create Child GameObject" TAB "" TAB "echo(\"Not yet implemented.\");";
|
||||
};
|
||||
}
|
||||
|
||||
//Asset Import Resolution menus
|
||||
if( !isObject( ImportAssetResolutionsPopup ) )
|
||||
{
|
||||
%this.ImportAssetResolutionsPopup = new PopupMenu( ImportAssetResolutionsPopup )
|
||||
{
|
||||
superClass = "MenuBuilder";
|
||||
class = "EditorWorldMenu";
|
||||
|
||||
item[0] = "Use original Asset for duplicates" TAB "" TAB "";
|
||||
item[1] = "Override duplicate with new Asset" TAB "" TAB "";
|
||||
item[2] = "-";
|
||||
item[3] = "Rename Asset" TAB "" TAB "";
|
||||
item[4] = "-";
|
||||
item[5] = "Find missing file" TAB "" TAB "ImportAssetWindow.findMissingFile(ImportAssetResolutionsPopup.assetItem);";
|
||||
item[6] = "-";
|
||||
item[7] = "Edit Asset properties" TAB "" TAB "";
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
//
|
||||
// Import Asset Actions
|
||||
//
|
||||
|
|
|
|||
|
|
@ -87,11 +87,11 @@ function GuiInspectorVariableGroup::buildListField(%this, %fieldName, %fieldLabe
|
|||
eval(%setCommand);
|
||||
}
|
||||
|
||||
%listCount = getTokenCount(%fieldDataVals, ",");
|
||||
%listCount = getTokenCount(%fieldDataVals, ",;");
|
||||
|
||||
for(%i=0; %i < %listCount; %i++)
|
||||
{
|
||||
%entryText = getToken(%fieldDataVals, ",", %i);
|
||||
%entryText = getToken(%fieldDataVals, ",;", %i);
|
||||
%editControl.add(%entryText);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -485,7 +485,7 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) {
|
|||
VertSizing = "bottom";
|
||||
Extent = "90 18";
|
||||
text = "Stop";
|
||||
command = "NavEditorGui.getPlayer().stop();";
|
||||
command = "NavEditorGui.stop();";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ function NavEditorPlugin::onWorldEditorStartup(%this)
|
|||
|
||||
// Add ourselves to the Editor Settings window.
|
||||
exec("./NavEditorSettingsTab.gui");
|
||||
//ESettingsWindow.addTabPage(ENavEditorSettingsPage);
|
||||
ESettingsWindow.addTabPage(ENavEditorSettingsPage);
|
||||
ENavEditorSettingsPage.init();
|
||||
|
||||
// Add items to World Editor Creator
|
||||
|
|
@ -104,6 +104,7 @@ function ENavEditorSettingsPage::init(%this)
|
|||
{
|
||||
// Initialises the settings controls in the settings dialog box.
|
||||
%this-->SpawnClassOptions.clear();
|
||||
%this-->SpawnClassOptions.add("Player");
|
||||
%this-->SpawnClassOptions.add("AIPlayer");
|
||||
%this-->SpawnClassOptions.setFirstSelected();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -459,6 +459,14 @@ function NavEditorGui::onLinkSelected(%this, %flags)
|
|||
|
||||
function NavEditorGui::onPlayerSelected(%this, %flags)
|
||||
{
|
||||
if (!isObject(%this.getPlayer().aiController) && (!(%this.getPlayer().isMemberOfClass("AIPlayer"))))
|
||||
{
|
||||
%this.getPlayer().aiController = new AIController(){ ControllerData = %this.getPlayer().getDatablock().aiControllerData; };
|
||||
%this.getPlayer().setAIController(%this.getPlayer().aiController);
|
||||
}
|
||||
NavMeshIgnore(%this.getPlayer(), true);
|
||||
%this.getPlayer().setDamageState("Enabled");
|
||||
|
||||
updateLinkData(NavEditorOptionsWindow-->TestProperties, %flags);
|
||||
}
|
||||
|
||||
|
|
@ -526,7 +534,7 @@ function NavEditorGui::findCover(%this)
|
|||
%text = NavEditorOptionsWindow-->TestProperties->CoverPosition.getText();
|
||||
if(%text !$= "")
|
||||
%pos = eval("return " @ %text);
|
||||
%this.getPlayer().findCover(%pos, NavEditorOptionsWindow-->TestProperties->CoverRadius.getText());
|
||||
%this.getPlayer().getAIController().findCover(%pos, NavEditorOptionsWindow-->TestProperties->CoverRadius.getText());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -547,10 +555,19 @@ function NavEditorGui::followObject(%this)
|
|||
toolsMessageBoxOk("Error", "Cannot find object" SPC %text);
|
||||
}
|
||||
if(isObject(%obj))
|
||||
%this.getPlayer().followObject(%obj, NavEditorOptionsWindow-->TestProperties->FollowRadius.getText());
|
||||
%this.getPlayer().getAIController().followObject(%obj, NavEditorOptionsWindow-->TestProperties->FollowRadius.getText());
|
||||
}
|
||||
}
|
||||
|
||||
function NavEditorGui::stop(%this)
|
||||
{
|
||||
if (isObject(%this.getPlayer().aiController))
|
||||
%this.getPlayer().aiController.stop();
|
||||
else
|
||||
{
|
||||
NavEditorGui.getPlayer().stop();
|
||||
}
|
||||
}
|
||||
function NavInspector::inspect(%this, %obj)
|
||||
{
|
||||
%name = "";
|
||||
|
|
|
|||
|
|
@ -23,4 +23,13 @@ function ToolsModule::onCreate(%this)
|
|||
function ToolsModule::onDestroy(%this)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function ToolsModule::disconnect(%this)
|
||||
{
|
||||
if ( isObject( Editor ) && Editor.isEditorEnabled() )
|
||||
{
|
||||
EditorGui.saveAs = false; //whatever edits we were doing are irrelevent now
|
||||
Editor.close(MainMenuGui);
|
||||
}
|
||||
}
|
||||
|
|
@ -164,40 +164,3 @@ function toggleEditor(%make)
|
|||
//------------------------------------------------------------------------------
|
||||
// The editor action maps are defined in editor.bind.tscript
|
||||
GlobalActionMap.bind(keyboard, "f11", fastLoadWorldEdit);
|
||||
|
||||
|
||||
// The scenario:
|
||||
// The editor is open and the user closes the level by any way other than
|
||||
// the file menu ( exit level ), eg. typing disconnect() in the console.
|
||||
//
|
||||
// The problem:
|
||||
// Editor::close() is not called in this scenario which means onEditorDisable
|
||||
// is not called on objects which hook into it and also gEditingMission will no
|
||||
// longer be valid.
|
||||
//
|
||||
// The solution:
|
||||
// Override the stock disconnect() function which is in game scripts from here
|
||||
// in tools so we avoid putting our code in there.
|
||||
//
|
||||
// Disclaimer:
|
||||
// If you think of a better way to do this feel free. The thing which could
|
||||
// be dangerous about this is that no one will ever realize this code overriding
|
||||
// a fairly standard and core game script from a somewhat random location.
|
||||
// If it 'did' have unforscene sideeffects who would ever find it?
|
||||
|
||||
package EditorDisconnectOverride
|
||||
{
|
||||
function disconnect()
|
||||
{
|
||||
if ( isObject( Editor ) && Editor.isEditorEnabled() )
|
||||
{
|
||||
EditorGui.saveAs = false; //whatever edits we were doing are irrelevent now
|
||||
%mainMenuGUI = ProjectSettings.value("UI/mainMenuName");
|
||||
if (isObject( %mainMenuGUI ))
|
||||
Editor.close( %mainMenuGUI );
|
||||
}
|
||||
|
||||
Parent::disconnect();
|
||||
}
|
||||
};
|
||||
activatePackage( EditorDisconnectOverride );
|
||||
|
|
|
|||
|
|
@ -721,32 +721,7 @@ function EditorExplodePrefab()
|
|||
}
|
||||
|
||||
function makeSelectedAMesh(%assetId)
|
||||
{
|
||||
|
||||
/*%dlg = new SaveFileDialog()
|
||||
{
|
||||
Filters = "Collada file (*.dae)|*.dae|";
|
||||
DefaultPath = $Pref::WorldEditor::LastPath;
|
||||
DefaultFile = "";
|
||||
ChangePath = false;
|
||||
OverwritePrompt = true;
|
||||
};
|
||||
|
||||
%ret = %dlg.Execute();
|
||||
if ( %ret )
|
||||
{
|
||||
$Pref::WorldEditor::LastPath = filePath( %dlg.FileName );
|
||||
%saveFile = %dlg.FileName;
|
||||
}
|
||||
|
||||
if( fileExt( %saveFile ) !$= ".dae" )
|
||||
%saveFile = %saveFile @ ".dae";
|
||||
|
||||
%dlg.delete();
|
||||
|
||||
if ( !%ret )
|
||||
return;*/
|
||||
|
||||
{
|
||||
%assetDef = AssetDatabase.acquireAsset(%assetId);
|
||||
|
||||
%assetPath = AssetDatabase.getAssetPath(%assetId);
|
||||
|
|
@ -762,16 +737,12 @@ function makeSelectedAMesh(%assetId)
|
|||
AssetDatabase.refreshAsset(%assetId);
|
||||
|
||||
if(%success)
|
||||
{
|
||||
//ok, cool it worked, so clear out the old
|
||||
//First, get our center of the currently selected objects
|
||||
%selectionCenter = EWorldEditor.getSelectionCentroid();
|
||||
|
||||
{
|
||||
//Next, for safety purposes(and convenience!) we'll make them a prefab aping off the filepath/name provided
|
||||
//TODO: Make this an editor option
|
||||
%prefabPath = %assetPath @ "/" @ %assetDef.AssetName @ ".prefab";
|
||||
EWorldEditor.makeSelectionPrefab(%prefabPath, true);
|
||||
|
||||
EWorldEditor.makeSelectionPrefab(%prefabPath, false);
|
||||
%selectionPos = EWorldEditor.getSelectedObject(0).getPosition();
|
||||
//Next, nuke 'em
|
||||
EditorMenuEditDelete();
|
||||
|
||||
|
|
@ -779,7 +750,7 @@ function makeSelectedAMesh(%assetId)
|
|||
%newStatic = new TSStatic()
|
||||
{
|
||||
shapeAsset = %assetId;
|
||||
position = %selectionCenter;
|
||||
position = %selectionPos;
|
||||
};
|
||||
|
||||
getRootScene().add(%newStatic);
|
||||
|
|
|
|||