diff --git a/Engine/source/T3D/assets/CubemapAsset.cpp b/Engine/source/T3D/assets/CubemapAsset.cpp new file mode 100644 index 000000000..7929eddad --- /dev/null +++ b/Engine/source/T3D/assets/CubemapAsset.cpp @@ -0,0 +1,252 @@ +//----------------------------------------------------------------------------- +// Copyright (c) 2013 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. +//----------------------------------------------------------------------------- + +#ifndef CUBEMAP_ASSET_H +#include "CubemapAsset.h" +#endif + +#ifndef _ASSET_MANAGER_H_ +#include "assets/assetManager.h" +#endif + +#ifndef _CONSOLETYPES_H_ +#include "console/consoleTypes.h" +#endif + +#ifndef _TAML_ +#include "persistence/taml/taml.h" +#endif + +#ifndef _ASSET_PTR_H_ +#include "assets/assetPtr.h" +#endif + +// Debug Profiling. +#include "platform/profiler.h" + +//----------------------------------------------------------------------------- + +IMPLEMENT_CONOBJECT(CubemapAsset); + +ConsoleType(CubemapAssetPtr, TypeCubemapAssetPtr, CubemapAsset, ASSET_ID_FIELD_PREFIX) + +//----------------------------------------------------------------------------- + +ConsoleGetType(TypeCubemapAssetPtr) +{ + // Fetch asset Id. + return (*((AssetPtr*)dptr)).getAssetId(); +} + +//----------------------------------------------------------------------------- + +ConsoleSetType(TypeCubemapAssetPtr) +{ + // Was a single argument specified? + if (argc == 1) + { + // Yes, so fetch field value. + const char* pFieldValue = argv[0]; + + // Fetch asset pointer. + AssetPtr* pAssetPtr = dynamic_cast*>((AssetPtrBase*)(dptr)); + + // Is the asset pointer the correct type? + if (pAssetPtr == NULL) + { + // No, so fail. + //Con::warnf("(TypeCubemapAssetPtr) - Failed to set asset Id '%d'.", pFieldValue); + return; + } + + // Set asset. + pAssetPtr->setAssetId(pFieldValue); + + return; + } + + // Warn. + Con::warnf("(TypeCubemapAssetPtr) - Cannot set multiple args to a single asset."); +} + +//----------------------------------------------------------------------------- + +CubemapAsset::CubemapAsset() +{ + mComponentName = StringTable->EmptyString(); + mComponentClass = StringTable->EmptyString(); + mFriendlyName = StringTable->EmptyString(); + mComponentType = StringTable->EmptyString(); + mDescription = StringTable->EmptyString(); + + mScriptFile = StringTable->EmptyString(); +} + +//----------------------------------------------------------------------------- + +CubemapAsset::~CubemapAsset() +{ + // If the asset manager does not own the asset then we own the + // asset definition so delete it. + if (!getOwned()) + delete mpAssetDefinition; +} + +//----------------------------------------------------------------------------- + +void CubemapAsset::initPersistFields() +{ + // Call parent. + Parent::initPersistFields(); + + addField("componentName", TypeString, Offset(mComponentName, CubemapAsset), "Unique Name of the component. Defines the namespace of the scripts for the component."); + addField("componentClass", TypeString, Offset(mComponentClass, CubemapAsset), "Class of object this component uses."); + addField("friendlyName", TypeString, Offset(mFriendlyName, CubemapAsset), "The human-readble name for the component."); + addField("componentType", TypeString, Offset(mComponentType, CubemapAsset), "The category of the component for organizing in the editor."); + addField("description", TypeString, Offset(mDescription, CubemapAsset), "Simple description of the component."); + + addProtectedField("scriptFile", TypeAssetLooseFilePath, Offset(mScriptFile, CubemapAsset), + &setScriptFile, &getScriptFile, "A script file with additional scripted functionality for this component."); +} + +//------------------------------------------------------------------------------ + +void CubemapAsset::copyTo(SimObject* object) +{ + // Call to parent. + Parent::copyTo(object); +} + +void CubemapAsset::initializeAsset() +{ + mScriptFile = expandAssetFilePath(mScriptFile); + + if(Platform::isFile(mScriptFile)) + Con::executeFile(mScriptFile, false, false); +} + +void CubemapAsset::onAssetRefresh() +{ + mScriptFile = expandAssetFilePath(mScriptFile); + + if (Platform::isFile(mScriptFile)) + Con::executeFile(mScriptFile, false, false); +} + +void CubemapAsset::setScriptFile(const char* pScriptFile) +{ + // Sanity! + AssertFatal(pScriptFile != NULL, "Cannot use a NULL script file."); + + // Fetch image file. + pScriptFile = StringTable->insert(pScriptFile); + + // Ignore no change, + if (pScriptFile == mScriptFile) + return; + + // Update. + mScriptFile = getOwned() ? expandAssetFilePath(pScriptFile) : StringTable->insert(pScriptFile); + + // Refresh the asset. + refreshAsset(); +} + +//----------------------------------------------------------------------------- +// GuiInspectorTypeAssetId +//----------------------------------------------------------------------------- + +IMPLEMENT_CONOBJECT(GuiInspectorTypeCubemapAssetPtr); + +ConsoleDocClass(GuiInspectorTypeCubemapAssetPtr, + "@brief Inspector field type for Shapes\n\n" + "Editor use only.\n\n" + "@internal" +); + +void GuiInspectorTypeCubemapAssetPtr::consoleInit() +{ + Parent::consoleInit(); + + ConsoleBaseType::getType(TypeCubemapAssetPtr)->setInspectorFieldType("GuiInspectorTypeCubemapAssetPtr"); +} + +GuiControl* GuiInspectorTypeCubemapAssetPtr::constructEditControl() +{ + // Create base filename edit controls + GuiControl* retCtrl = Parent::constructEditControl(); + if (retCtrl == NULL) + return retCtrl; + + // Change filespec + char szBuffer[512]; + dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.showDialog(\"CubemapAsset\", \"AssetBrowser.changeAsset\", %d, %s);", + mInspector->getComponentGroupTargetId(), mCaption); + mBrowseButton->setField("Command", szBuffer); + + setDataField(StringTable->insert("ComponentOwner"), NULL, String::ToString(mInspector->getComponentGroupTargetId()).c_str()); + + // Create "Open in ShapeEditor" button + mShapeEdButton = new GuiBitmapButtonCtrl(); + + dSprintf(szBuffer, sizeof(szBuffer), "CubemapEditor.openCubemapAsset(%d.getText());", retCtrl->getId()); + mShapeEdButton->setField("Command", szBuffer); + + char bitmapName[512] = "tools/worldEditor/images/toolbar/shape-editor"; + mShapeEdButton->setBitmap(bitmapName); + + mShapeEdButton->setDataField(StringTable->insert("Profile"), NULL, "GuiButtonProfile"); + mShapeEdButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile"); + mShapeEdButton->setDataField(StringTable->insert("hovertime"), NULL, "1000"); + mShapeEdButton->setDataField(StringTable->insert("tooltip"), NULL, "Open this file in the Shape Editor"); + + mShapeEdButton->registerObject(); + addObject(mShapeEdButton); + + return retCtrl; +} + +bool GuiInspectorTypeCubemapAssetPtr::updateRects() +{ + S32 dividerPos, dividerMargin; + mInspector->getDivider(dividerPos, dividerMargin); + Point2I fieldExtent = getExtent(); + Point2I fieldPos = getPosition(); + + mCaptionRect.set(0, 0, fieldExtent.x - dividerPos - dividerMargin, fieldExtent.y); + mEditCtrlRect.set(fieldExtent.x - dividerPos + dividerMargin, 1, dividerPos - dividerMargin - 34, fieldExtent.y); + + bool resized = mEdit->resize(mEditCtrlRect.point, mEditCtrlRect.extent); + if (mBrowseButton != NULL) + { + mBrowseRect.set(fieldExtent.x - 32, 2, 14, fieldExtent.y - 4); + resized |= mBrowseButton->resize(mBrowseRect.point, mBrowseRect.extent); + } + + if (mShapeEdButton != NULL) + { + RectI shapeEdRect(fieldExtent.x - 16, 2, 14, fieldExtent.y - 4); + resized |= mShapeEdButton->resize(shapeEdRect.point, shapeEdRect.extent); + } + + return resized; +} diff --git a/Engine/source/T3D/assets/CubemapAsset.h b/Engine/source/T3D/assets/CubemapAsset.h new file mode 100644 index 000000000..0cd956aa9 --- /dev/null +++ b/Engine/source/T3D/assets/CubemapAsset.h @@ -0,0 +1,113 @@ +#pragma once +//----------------------------------------------------------------------------- +// Copyright (c) 2013 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. +//----------------------------------------------------------------------------- +#ifndef CUBEMAP_ASSET_H +#define CUBEMAP_ASSET_H + +#ifndef _ASSET_BASE_H_ +#include "assets/assetBase.h" +#endif + +#ifndef _ASSET_DEFINITION_H_ +#include "assets/assetDefinition.h" +#endif + +#ifndef _STRINGUNIT_H_ +#include "string/stringUnit.h" +#endif + +#ifndef _ASSET_FIELD_TYPES_H_ +#include "assets/assetFieldTypes.h" +#endif + +#include "gui/editor/guiInspectorTypes.h" + +//----------------------------------------------------------------------------- +class CubemapAsset : public AssetBase +{ + typedef AssetBase Parent; + + StringTableEntry mComponentName; + StringTableEntry mComponentClass; + StringTableEntry mFriendlyName; + StringTableEntry mComponentType; + StringTableEntry mDescription; + + StringTableEntry mScriptFile; + +public: + CubemapAsset(); + virtual ~CubemapAsset(); + + /// Engine. + static void initPersistFields(); + virtual void copyTo(SimObject* object); + + /// Declare Console Object. + DECLARE_CONOBJECT(CubemapAsset); + + StringTableEntry getComponentName() { return mComponentName; } + StringTableEntry getComponentClass() { return mComponentClass; } + StringTableEntry getFriendlyName() { return mFriendlyName; } + StringTableEntry getComponentType() { return mComponentType; } + StringTableEntry getDescription() { return mDescription; } + + void setComponentName(StringTableEntry name) { mComponentName = name; } + void setComponentClass(StringTableEntry name) { mComponentClass = name; } + void setFriendlyName(StringTableEntry name) { mFriendlyName = name; } + void setComponentType(StringTableEntry typeName) { mComponentType = typeName; } + void setDescription(StringTableEntry description) { mDescription = description; } + + AssetDefinition* getAssetDefinition() { return mpAssetDefinition; } + + void setScriptFile(const char* pScriptFile); + inline StringTableEntry getScriptFile(void) const { return mScriptFile; }; + +protected: + virtual void initializeAsset(void); + virtual void onAssetRefresh(void); + + static bool setScriptFile(void *obj, const char *index, const char *data) { static_cast(obj)->setScriptFile(data); return false; } + static const char* getScriptFile(void* obj, const char* data) { return static_cast(obj)->getScriptFile(); } +}; + +DefineConsoleType(TypeCubemapAssetPtr, CubemapAsset) + +//----------------------------------------------------------------------------- +// TypeAssetId GuiInspectorField Class +//----------------------------------------------------------------------------- +class GuiInspectorTypeCubemapAssetPtr : public GuiInspectorTypeFileName +{ + typedef GuiInspectorTypeFileName Parent; +public: + + GuiBitmapButtonCtrl* mShapeEdButton; + + DECLARE_CONOBJECT(GuiInspectorTypeCubemapAssetPtr); + static void consoleInit(); + + virtual GuiControl* constructEditControl(); + virtual bool updateRects(); +}; + +#endif // _ASSET_BASE_H_ + diff --git a/Engine/source/T3D/assets/ScriptAsset.cpp b/Engine/source/T3D/assets/ScriptAsset.cpp index d4968aa3f..25ded7f9e 100644 --- a/Engine/source/T3D/assets/ScriptAsset.cpp +++ b/Engine/source/T3D/assets/ScriptAsset.cpp @@ -123,6 +123,50 @@ void ScriptAsset::copyTo(SimObject* object) Parent::copyTo(object); } +void ScriptAsset::initializeAsset() +{ + mScriptFile = expandAssetFilePath(mScriptFile); + + if (Platform::isFile(mScriptFile)) + { + //We're initialized properly, so we'll go ahead and kick along any dependencies we may have as well + AssetManager::typeAssetDependsOnHash::Iterator assetDependenciesItr = mpOwningAssetManager->getDependedOnAssets()->find(mpAssetDefinition->mAssetId); + + // Does the asset have any dependencies? + if (assetDependenciesItr != mpOwningAssetManager->getDependedOnAssets()->end()) + { + // Iterate all dependencies. + while (assetDependenciesItr != mpOwningAssetManager->getDependedOnAssets()->end() && assetDependenciesItr->key == mpAssetDefinition->mAssetId) + { + AssetPtr scriptAsset = assetDependenciesItr->value; + + mScriptAssets.push_front(scriptAsset); + + // Next dependency. + assetDependenciesItr++; + } + } + + Con::executeFile(mScriptFile, false, false); + } +} + +void ScriptAsset::onAssetRefresh() +{ + mScriptFile = expandAssetFilePath(mScriptFile); + + if (Platform::isFile(mScriptFile)) + { + //Refresh any dependencies we may have + for (U32 i = 0; i < mScriptAssets.size(); i++) + { + mScriptAssets[i]->onAssetRefresh(); + } + + Con::executeFile(mScriptFile, false, false); + } +} + void ScriptAsset::setScriptFile(const char* pScriptFile) { // Sanity! @@ -144,6 +188,13 @@ void ScriptAsset::setScriptFile(const char* pScriptFile) bool ScriptAsset::execScript() { + AssetBase* handle = mpOwningAssetManager->acquireAsset(getAssetId()); + + if (handle) + return true; + + return false; + if (Platform::isFile(mScriptFile)) { return Con::executeFile(mScriptFile, false, false); diff --git a/Engine/source/T3D/assets/ScriptAsset.h b/Engine/source/T3D/assets/ScriptAsset.h index 39eccdf95..bf18438f6 100644 --- a/Engine/source/T3D/assets/ScriptAsset.h +++ b/Engine/source/T3D/assets/ScriptAsset.h @@ -39,6 +39,10 @@ #include "assets/assetFieldTypes.h" #endif +#ifndef _ASSET_PTR_H_ +#include "assets/assetPtr.h" +#endif + //----------------------------------------------------------------------------- class ScriptAsset : public AssetBase { @@ -47,6 +51,8 @@ class ScriptAsset : public AssetBase StringTableEntry mScriptFile; bool mIsServerSide; + Vector> mScriptAssets; + public: ScriptAsset(); virtual ~ScriptAsset(); @@ -64,8 +70,8 @@ public: bool execScript(); protected: - virtual void initializeAsset(void) {} - virtual void onAssetRefresh(void) {} + virtual void initializeAsset(void); + virtual void onAssetRefresh(void); static bool setScriptFile(void *obj, const char *index, const char *data) { static_cast(obj)->setScriptFile(data); return false; } static const char* getScriptFile(void* obj, const char* data) { return static_cast(obj)->getScriptFile(); } diff --git a/Templates/BaseGame/game/core/clientServer/scripts/server/levelDownload.cs b/Templates/BaseGame/game/core/clientServer/scripts/server/levelDownload.cs index 6ddeb646b..de2f5e500 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/server/levelDownload.cs +++ b/Templates/BaseGame/game/core/clientServer/scripts/server/levelDownload.cs @@ -148,8 +148,6 @@ function serverCmdMissionStartPhase3Ack(%client, %seq) %entity.notify("onClientConnect", %client); } - %activeSceneCount = getSceneCount(); - %hasGameMode = callGamemodeFunction("onClientEnterGame", %client); //if that also failed, just spawn a camera diff --git a/Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.cs b/Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.cs index db889bdde..fa3b77c3e 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.cs +++ b/Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.cs @@ -123,6 +123,8 @@ function loadMissionStage2() // Make the MissionCleanup group the place where all new objects will automatically be added. $instantGroup = MissionCleanup; + %hasGameMode = callGamemodeFunction("onCreateGame"); + // Construct MOD paths pathOnMissionLoadDone(); @@ -135,8 +137,6 @@ function loadMissionStage2() ClientGroup.getObject(%clientIndex).loadMission(); // Go ahead and launch the game - %activeSceneCount = getSceneCount(); - %hasGameMode = callGamemodeFunction("onMissionStart"); } @@ -148,8 +148,6 @@ function endMission() echo("*** ENDING MISSION"); // Inform the game code we're done. - %activeSceneCount = getSceneCount(); - %hasGameMode = callGamemodeFunction("onMissionEnded"); // Inform the clients @@ -181,7 +179,5 @@ function resetMission() clearServerPaths(); // Inform the game code we're resetting. - %activeSceneCount = getSceneCount(); - %hasGameMode = callGamemodeFunction("onMissionReset", %client); } \ No newline at end of file diff --git a/Templates/BaseGame/game/core/clientServer/scripts/server/server.cs b/Templates/BaseGame/game/core/clientServer/scripts/server/server.cs index 702c93b62..5663d8bc6 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/server/server.cs +++ b/Templates/BaseGame/game/core/clientServer/scripts/server/server.cs @@ -267,35 +267,7 @@ function onServerDestroyed() echo("*** ENDING MISSION"); // Inform the game code we're done. - %activeSceneCount = getSceneCount(); - - %hasGameMode = 0; - for(%i=0; %i < %activeSceneCount; %i++) - { - if(getScene(%i).gameModeName !$= "") - { - //if the scene defines a game mode, go ahead and envoke it here - if(isMethod(getScene(%i).gameModeName, "onMissionEnded")) - { - eval(getScene(%i).gameModeName @ "::onMissionEnded();" ); - %hasGameMode = 1; - } - } - } - - //if none of our scenes have gamemodes, we need to kick off a default - if(%hasGameMode == 0) - { - %defaultModeName = ProjectSettings.value("Gameplay/GameModes/defaultModeName"); - if(%defaultModeName !$= "") - { - if(isMethod(%defaultModeName, "onMissionEnded")) - { - eval(%defaultModeName @ "::onMissionEnded();" ); - %hasGameMode = 1; - } - } - } + %hasGameMode = callGamemodeFunction("onMissionEnded"); // Inform the clients for( %clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++ ) { diff --git a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl index cb01f627a..cc15a3a90 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl @@ -129,7 +129,7 @@ Surface createSurface(vec4 normDepth, sampler2D colorBuffer, sampler2D matInfoBu vec4 gbuffer2 = texture(matInfoBuffer, uv); surface.depth = normDepth.a; surface.P = wsEyePos + wsEyeRay * surface.depth; - surface.N = tMul(invView, vec4(normDepth.xyz,0)).xyz; //TODO move t3d to use WS normals + surface.N = tMul(invView, vec4(normDepth.xyz,0)).xyz; surface.V = normalize(wsEyePos - surface.P); surface.baseColor = gbuffer1; const float minRoughness=1e-4; @@ -148,7 +148,7 @@ Surface createForwardSurface(vec4 baseColor, vec4 normal, vec4 pbrProperties, in surface.depth = 0; surface.P = wsPosition; - surface.N = tMul(invView, vec4(normal.xyz,0)).xyz; //TODO move t3d to use WS normals + surface.N = tMul(invView, vec4(normal.xyz,0)).xyz; surface.V = normalize(wsEyePos - surface.P); surface.baseColor = baseColor; const float minRoughness=1e-4; diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index 8cf17c939..71f10fb09 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -108,7 +108,7 @@ inline Surface createSurface(float4 gbuffer0, TORQUE_SAMPLER2D(gbufferTex1), TOR surface.depth = gbuffer0.a; surface.P = wsEyePos + wsEyeRay * surface.depth; - surface.N = mul(invView, float4(gbuffer0.xyz,0)).xyz; //TODO move t3d to use WS normals + surface.N = mul(invView, float4(gbuffer0.xyz,0)).xyz; surface.V = normalize(wsEyePos - surface.P); surface.baseColor = gbuffer1; const float minRoughness=1e-4; diff --git a/Templates/BaseGame/game/core/utility/scripts/scene.cs b/Templates/BaseGame/game/core/utility/scripts/scene.cs index da9008f0a..67fc35ad0 100644 --- a/Templates/BaseGame/game/core/utility/scripts/scene.cs +++ b/Templates/BaseGame/game/core/utility/scripts/scene.cs @@ -3,18 +3,29 @@ function callGamemodeFunction(%gameModeFuncName, %data) if(%data !$= "") %data = "\""@%data@"\""; + %activeSceneCount = getSceneCount(); + %hasGameMode = 0; for(%i=0; %i < %activeSceneCount; %i++) { - if(getScene(%i).gameModeName !$= "") + %gamemodeName = getScene(%i).gameModeName; + if(%gamemodeName !$= "") { //if the scene defines a game mode, go ahead and envoke it here - if(isMethod(getScene(%i).gameModeName, %gameModeFuncName)) + if(isObject(%gamemodeName) && %gamemodeName.isMethod(%gameModeFuncName)) { - - eval(getScene(%i).gameModeName @ "::"@%gameModeFuncName@"("@%data@");" ); + eval(%gamemodeName @ "."@%gameModeFuncName@"("@%data@");" ); %hasGameMode = 1; } + else + { + //if we don't have an object, attempt the static call + if(isMethod(%gamemodeName, %gameModeFuncName)) + { + eval(%gamemodeName @ "::"@%gameModeFuncName@"("@%data@");" ); + %hasGameMode = 1; + } + } } } @@ -24,11 +35,19 @@ function callGamemodeFunction(%gameModeFuncName, %data) %defaultModeName = ProjectSettings.value("Gameplay/GameModes/defaultModeName"); if(%defaultModeName !$= "") { - if(isMethod(%defaultModeName, %gameModeFuncName)) + if(isObject(%defaultModeName) && %defaultModeName.isMethod(%gameModeFuncName)) { - eval(%defaultModeName @ "::"@%gameModeFuncName@"("@%data@");" ); + eval(%defaultModeName @ "."@%gameModeFuncName@"("@%data@");" ); %hasGameMode = 1; } + else + { + if(isMethod(%defaultModeName, %gameModeFuncName)) + { + eval(%defaultModeName @ "::"@%gameModeFuncName@"("@%data@");" ); + %hasGameMode = 1; + } + } } } diff --git a/Templates/BaseGame/game/data/ExampleModule/ExampleModule.cs b/Templates/BaseGame/game/data/ExampleModule/ExampleModule.cs index 1739659df..02e316f13 100644 --- a/Templates/BaseGame/game/data/ExampleModule/ExampleModule.cs +++ b/Templates/BaseGame/game/data/ExampleModule/ExampleModule.cs @@ -6,7 +6,7 @@ //else. function ExampleModule::onCreate(%this) { - + %bool = true; } //Similar to the create function, this is defined in thye module file, and called @@ -51,7 +51,7 @@ function ExampleModule::onCreateGameServer(%this) //onServerCreated(), it loads the datablocks via this array, and when when the server goes //to pass data to the client, it iterates over this list and processes it, ensuring all datablocks //are the most up to date possible for transmission to the connecting client - %this.registerDatablock("./datablocks/ExampleDatablock.cs"); + //%this.registerDatablock("./datablocks/ExampleDatablock.cs"); } //This is called when a game session server is destroyed, when the game shuts down. It's called from @@ -69,6 +69,8 @@ function ExampleModule::onDestroyGameServer(%this) //and the like function ExampleModule::initClient(%this) { + AssetDatabase.acquireAsset("ExampleModule:exampleDatablock"); + //client scripts //Here, we exec out keybind scripts so the player is able to move when they get into a game exec("./scripts/default.keybinds.cs"); diff --git a/Templates/BaseGame/game/data/ExampleModule/datablocks/ExampleDatablock.asset.taml b/Templates/BaseGame/game/data/ExampleModule/datablocks/ExampleDatablock.asset.taml new file mode 100644 index 000000000..cf4f7aa9b --- /dev/null +++ b/Templates/BaseGame/game/data/ExampleModule/datablocks/ExampleDatablock.asset.taml @@ -0,0 +1,7 @@ + diff --git a/Templates/BaseGame/game/data/ExampleModule/datablocks/ExampleDatablock.cs b/Templates/BaseGame/game/data/ExampleModule/datablocks/ExampleDatablock.cs index e69de29bb..8ac6b0300 100644 --- a/Templates/BaseGame/game/data/ExampleModule/datablocks/ExampleDatablock.cs +++ b/Templates/BaseGame/game/data/ExampleModule/datablocks/ExampleDatablock.cs @@ -0,0 +1,4 @@ +new ScriptObject(DummyObjectTestThing) +{ + +}; \ No newline at end of file diff --git a/Templates/BaseGame/game/data/ExampleModule/scripts/ExampleGamemodeScript.cs b/Templates/BaseGame/game/data/ExampleModule/scripts/ExampleGamemodeScript.cs index f79ce355e..fc046e020 100644 --- a/Templates/BaseGame/game/data/ExampleModule/scripts/ExampleGamemodeScript.cs +++ b/Templates/BaseGame/game/data/ExampleModule/scripts/ExampleGamemodeScript.cs @@ -19,72 +19,78 @@ //triggers for a CTF mode. The subscene would then have it's GameModeName defined to run the CTF gamemode logic //and the levelLoad code will execute it. +function ExampleGameMode::onCreateGame() +{ + // Note: The Game object will be cleaned up by MissionCleanup. Therefore its lifetime is + // limited to that of the mission. + new ScriptObject(ExampleGameMode){}; + + return ExampleGameMode; +} + //This function is called when the level finishes loading. It sets up the initial configuration, variables and //spawning and dynamic objects, timers or rules needed for the gamemode to run -function ExampleGameMode::onMissionStart() +function ExampleGameMode::onMissionStart(%this) { //set up the game and game variables - ExampleGameMode::initGameVars(); + %this.initGameVars(); - if ($Game::Running) + if (%this.running) { error("onMissionStart: End the game first!"); return; } // Start the game timer - if ($Game::Duration) - $Game::Schedule = schedule($Game::Duration * 1000, "onGameDurationEnd"); + if (%this.duration) + %this.gameSchedule = schedule(%this.duration * 1000, "onGameDurationEnd"); - $Game::Running = true; - - $Game = ExampleGameMode; + %this.running = true; } //This function is called when the level ends. It can be envoked due to the gamemode ending //but is also kicked off when the game server is shut down as a form of cleanup for anything the gamemode //created or is managing like the above mentioned dynamic objects or timers -function ExampleGameMode::onMissionEnded() +function ExampleGameMode::onMissionEnded(%this) { - if (!$Game::Running) + if (!%this.running) { error("onMissionEnded: No game running!"); return; } // Stop any game timers - cancel($Game::Schedule); + cancel(%this.gameSchedule); - $Game::Running = false; - $Game = ""; + %this.running = false; } //This function is called in the event the server resets and is used to re-initialize the gamemode -function ExampleGameMode::onMissionReset() +function ExampleGameMode::onMissionReset(%this) { // Called by resetMission(), after all the temporary mission objects // have been deleted. - ExampleGameMode::initGameVars(); + %this.initGameVars(); } //This sets up our gamemode's duration time -function ExampleGameMode::initGameVars() +function ExampleGameMode::initGameVars(%this) { // Set the gameplay parameters - $Game::Duration = 30 * 60; + %this.duration = 30 * 60; } //This is called when the timer runs out, allowing the gamemode to end -function ExampleGameMode::onGameDurationEnd() +function ExampleGameMode::onGameDurationEnd(%this) { //we don't end if we're currently editing the level - if ($Game::Duration && !(EditorIsActive() && GuiEditorIsActive())) - ExampleGameMode::onMissionEnded(); + if (%this.duration && !(EditorIsActive() && GuiEditorIsActive())) + %this.onMissionEnded(); } //This is called to actually spawn a control object for the player to utilize //A player character, spectator camera, etc. -function ExampleGameMode::spawnControlObject(%client) +function ExampleGameMode::spawnControlObject(%this, %client) { //In this example, we just spawn a camera if (!isObject(%client.camera)) @@ -116,25 +122,25 @@ function ExampleGameMode::spawnControlObject(%client) //It's used for setting up anything ahead of time for the client, such as loading in client-passed //config stuffs, saved data or the like that should be handled BEFORE the client has actually entered //the game itself -function ExampleGameMode::onClientConnect(%client) +function ExampleGameMode::onClientConnect(%this, %client) { } //This is called when a client enters the game server. It's used to spawn a player object //set up any client-specific properties such as saved configs, values, their name, etc //These callbacks are activated in core/clientServer/scripts/server/levelDownload.cs -function ExampleGameMode::onClientEnterGame(%client) +function ExampleGameMode::onClientEnterGame(%this, %client) { //Set the player name based on the client's connection data %client.setPlayerName(%client.connectData); - ExampleGameMode::spawnControlObject(%client); + %this.spawnControlObject(%client); } //This is called when the player leaves the game server. It's used to clean up anything that //was spawned or setup for the client when it connected, in onClientEnterGame //These callbacks are activated in core/clientServer/scripts/server/levelDownload.cs -function ExampleGameMode::onClientLeaveGame(%client) +function ExampleGameMode::onClientLeaveGame(%this, %client) { // Cleanup the camera if (isObject(%client.camera)) diff --git a/Templates/BaseGame/game/data/ui/UI.cs b/Templates/BaseGame/game/data/ui/UI.cs index cbd2999a7..0a27d952b 100644 --- a/Templates/BaseGame/game/data/ui/UI.cs +++ b/Templates/BaseGame/game/data/ui/UI.cs @@ -14,6 +14,7 @@ function UI::onCreate( %this ) { + %bool = true; } function UI::onDestroy( %this ) @@ -30,7 +31,7 @@ function UI::initClient(%this) { //Load UI stuff //we need to load this because some of the menu profiles use the sounds here - exec("./datablocks/guiSounds.cs"); + //exec("./datablocks/guiSounds.cs"); //Profiles exec("./scripts/profiles.cs"); @@ -81,6 +82,9 @@ function UI::initClient(%this) exec("./scripts/help.cs"); exec("./scripts/cursors.cs"); + exec("./guis/menuGraphics.gui"); + exec("./guis/menuGraphics.cs"); + //exec("./scripts/GuiTreeViewCtrl.cs"); loadStartup(); diff --git a/Templates/BaseGame/game/data/ui/UI.module b/Templates/BaseGame/game/data/ui/UI.module index c2e38d7b9..889e2d259 100644 --- a/Templates/BaseGame/game/data/ui/UI.module +++ b/Templates/BaseGame/game/data/ui/UI.module @@ -6,4 +6,9 @@ CreateFunction="onCreate" DestroyFunction="onDestroy" Group="Game"> + \ No newline at end of file diff --git a/Templates/BaseGame/game/data/ui/datablocks/guiSounds.asset.taml b/Templates/BaseGame/game/data/ui/datablocks/guiSounds.asset.taml new file mode 100644 index 000000000..81e2a8e24 --- /dev/null +++ b/Templates/BaseGame/game/data/ui/datablocks/guiSounds.asset.taml @@ -0,0 +1,6 @@ + diff --git a/Templates/BaseGame/game/data/ui/scripts/controlsMenu.cs b/Templates/BaseGame/game/data/ui/scripts/controlsMenu.cs index 7f4bce345..fe76f4485 100644 --- a/Templates/BaseGame/game/data/ui/scripts/controlsMenu.cs +++ b/Templates/BaseGame/game/data/ui/scripts/controlsMenu.cs @@ -51,12 +51,12 @@ $RemapCount++; function ControlsMenu::loadSettings(%this) { - ControlSetList.clear(); + /*ControlSetList.clear(); ControlSetList.add( "Movement", "Movement" ); ControlSetList.add( "Combat", "Combat" ); - ControlSetList.add( "Miscellaneous", "Miscellaneous" ); + ControlSetList.add( "Miscellaneous", "Miscellaneous" );*/ - ControlSetList.setSelected( "Movement", false ); + //ControlSetList.setSelected( "Movement", false ); OptionsSettingStack.clear(); loadGroupKeybinds("Movement"); @@ -118,9 +118,10 @@ function addKeybindOption() { %tamlReader = new Taml(); - %graphicsOption = %tamlReader.read("data/ui/guis/controlsMenuSetting.taml"); + %controlOption = %tamlReader.read("data/ui/guis/controlsMenuSetting.taml"); + %controlOption.extent.x = OptionsSettingStack.extent.x; - OptionsSettingStack.add(%graphicsOption); + OptionsSettingStack.add(%controlOption); return %graphicsOption; } diff --git a/Templates/BaseGame/game/tools/assetBrowser/main.cs b/Templates/BaseGame/game/tools/assetBrowser/main.cs index 394cd47f6..8a5051599 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/main.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/main.cs @@ -66,6 +66,7 @@ function initializeAssetBrowser() exec("./scripts/assetTypes/shapeAnimation.cs"); exec("./scripts/assetTypes/sound.cs"); exec("./scripts/assetTypes/stateMachine.cs"); + exec("./scripts/assetTypes/cubemap.cs"); exec("./scripts/fieldTypes.cs"); diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImport.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImport.cs index 86afa80bf..0eaea9682 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImport.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImport.cs @@ -381,6 +381,7 @@ function AssetBrowser::addImportingAsset( %this, %assetType, %filePath, %parentA statusInfo = ""; skip = false; processed = false; + generatedAsset = false; }; //little bit of interception here @@ -425,6 +426,11 @@ function AssetBrowser::addImportingAsset( %this, %assetType, %filePath, %parentA } } + if(%assetType $= "Material") + { + %assetItem.generatedAsset = true; + } + if(%parentAssetItem $= "") { ImportAssetTree.insertObject(1, %assetItem); @@ -723,10 +729,10 @@ function ImportAssetWindow::_findImportingAssetByName(%this, %id, %assetName) function ImportAssetWindow::parseImageSuffixes(%this, %assetItem) { //diffuse - %suffixCount = getTokenCount(getAssetImportConfigValue("Image/DiffuseTypeSuffixes", ""), ",;"); + %suffixCount = getTokenCount(getAssetImportConfigValue("Images/DiffuseTypeSuffixes", ""), ",;"); for(%sfx = 0; %sfx < %suffixCount; %sfx++) { - %suffixToken = getToken(getAssetImportConfigValue("Image/DiffuseTypeSuffixes", ""), ",;", %sfx); + %suffixToken = getToken(getAssetImportConfigValue("Images/DiffuseTypeSuffixes", ""), ",;", %sfx); if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName)) { %assetItem.imageSuffixType = %suffixToken; @@ -735,10 +741,10 @@ function ImportAssetWindow::parseImageSuffixes(%this, %assetItem) } //normal - %suffixCount = getTokenCount(getAssetImportConfigValue("Image/NormalTypeSuffixes", ""), ",;"); + %suffixCount = getTokenCount(getAssetImportConfigValue("Images/NormalTypeSuffixes", ""), ",;"); for(%sfx = 0; %sfx < %suffixCount; %sfx++) { - %suffixToken = getToken(getAssetImportConfigValue("Image/NormalTypeSuffixes", ""), ",;", %sfx); + %suffixToken = getToken(getAssetImportConfigValue("Images/NormalTypeSuffixes", ""), ",;", %sfx); if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName)) { %assetItem.imageSuffixType = %suffixToken; @@ -747,10 +753,10 @@ function ImportAssetWindow::parseImageSuffixes(%this, %assetItem) } //roughness - %suffixCount = getTokenCount(getAssetImportConfigValue("Image/RoughnessTypeSuffixes", ""), ",;"); + %suffixCount = getTokenCount(getAssetImportConfigValue("Images/RoughnessTypeSuffixes", ""), ",;"); for(%sfx = 0; %sfx < %suffixCount; %sfx++) { - %suffixToken = getToken(getAssetImportConfigValue("Image/RoughnessTypeSuffixes", ""), ",;", %sfx); + %suffixToken = getToken(getAssetImportConfigValue("Images/RoughnessTypeSuffixes", ""), ",;", %sfx); if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName)) { %assetItem.imageSuffixType = %suffixToken; @@ -759,10 +765,10 @@ function ImportAssetWindow::parseImageSuffixes(%this, %assetItem) } //Ambient Occlusion - %suffixCount = getTokenCount(getAssetImportConfigValue("Image/AOTypeSuffixes", ""), ",;"); + %suffixCount = getTokenCount(getAssetImportConfigValue("Images/AOTypeSuffixes", ""), ",;"); for(%sfx = 0; %sfx < %suffixCount; %sfx++) { - %suffixToken = getToken(getAssetImportConfigValue("Image/AOTypeSuffixes", ""), ",;", %sfx); + %suffixToken = getToken(getAssetImportConfigValue("Images/AOTypeSuffixes", ""), ",;", %sfx); if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName)) { %assetItem.imageSuffixType = %suffixToken; @@ -771,10 +777,10 @@ function ImportAssetWindow::parseImageSuffixes(%this, %assetItem) } //metalness - %suffixCount = getTokenCount(getAssetImportConfigValue("Image/MetalnessTypeSuffixes", ""), ",;"); + %suffixCount = getTokenCount(getAssetImportConfigValue("Images/MetalnessTypeSuffixes", ""), ",;"); for(%sfx = 0; %sfx < %suffixCount; %sfx++) { - %suffixToken = getToken(getAssetImportConfigValue("Image/MetalnessTypeSuffixes", ""), ",;", %sfx); + %suffixToken = getToken(getAssetImportConfigValue("Images/MetalnessTypeSuffixes", ""), ",;", %sfx); if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName)) { %assetItem.imageSuffixType = %suffixToken; @@ -783,10 +789,10 @@ function ImportAssetWindow::parseImageSuffixes(%this, %assetItem) } //composite - %suffixCount = getTokenCount(getAssetImportConfigValue("Image/CompositeTypeSuffixes", ""), ",;"); + %suffixCount = getTokenCount(getAssetImportConfigValue("Images/CompositeTypeSuffixes", ""), ",;"); for(%sfx = 0; %sfx < %suffixCount; %sfx++) { - %suffixToken = getToken(getAssetImportConfigValue("Image/CompositeTypeSuffixes", ""), ",;", %sfx); + %suffixToken = getToken(getAssetImportConfigValue("Images/CompositeTypeSuffixes", ""), ",;", %sfx); if(strIsMatchExpr("*"@%suffixToken, %assetItem.AssetName)) { %assetItem.imageSuffixType = %suffixToken; @@ -1017,10 +1023,10 @@ function ImportAssetWindow::refreshChildItem(%this, %id) //Check if it's a generated type, like materials %inputPathProfile = ToolsGuiTextEditProfile; %generatedField = false; - if(%assetType $= "Material") + if(%assetItem.generatedAsset) { - %inputField = "(Generated)"; %generatedField = true; + %inputField = "(Generated)"; } else { @@ -1251,7 +1257,7 @@ function ImportAssetWindow::validateAsset(%this, %id) } //Check if we were given a file path(so not generated) but somehow isn't a valid file - if(%assetItem.filePath !$= "" && %assetItem.AssetType !$= "Material" && !isFile(%assetItem.filePath)) + if(%assetItem.filePath !$= "" && !%assetItem.generatedAsset && !isFile(%assetItem.filePath)) { %hasIssues = true; %assetItem.status = "error"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/cubemap.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/cubemap.cs new file mode 100644 index 000000000..80fd69807 --- /dev/null +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/cubemap.cs @@ -0,0 +1,70 @@ +function AssetBrowser::createCubemapAsset(%this) +{ + Canvas.pushDialog(CubemapEditor); + return; + + %moduleName = AssetBrowser.newAssetSettings.moduleName; + %modulePath = "data/" @ %moduleName; + + %assetName = AssetBrowser.newAssetSettings.assetName; + + %tamlpath = %modulePath @ "/cubemaps/" @ %assetName @ ".asset.taml"; + %shapeFilePath = %modulePath @ "/cubemaps/" @ %assetName @ ".dae"; + + %asset = new CubemapAsset() + { + 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.loadFilters(); + + %treeItemId = AssetBrowserFilterTree.findItemByName(%moduleName); + %smItem = AssetBrowserFilterTree.findChildItemByName(%treeItemId, "CubemapAsset"); + + AssetBrowserFilterTree.onSelect(%smItem); + + return %tamlpath; +} + +function AssetBrowser::editCubemapAsset(%this, %assetDef) +{ + %this.hideDialog(); + CubemapEditor.openCubemapAsset(%assetDef); +} + +function GuiInspectorTypeCubemapAssetPtr::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.dragSourceControl.parentGroup.assetType; + + if(%assetType $= "CubemapAsset") + { + echo("DROPPED A CUBEMAP ON A CUBEMAP ASSET COMPONENT FIELD!"); + + %module = %payload.dragSourceControl.parentGroup.moduleName; + %asset = %payload.dragSourceControl.parentGroup.assetName; + + %targetComponent = %this.ComponentOwner; + %targetComponent.CubemapAsset = %module @ ":" @ %asset; + + //Inspector.refresh(); + } + + EWorldEditor.isDirty = true; +} \ No newline at end of file diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/image.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/image.cs index 92491ab74..f5dbd9f76 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/image.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/image.cs @@ -18,11 +18,17 @@ function AssetBrowser::prepareImportImageAsset(%this, %assetItem) //Check if our material already exists //First, lets double-check that we don't already have an %materialAsset = ImportAssetWindow.findImportingAssetByName(%noSuffixName); + %cratedNewMaterial = false; + if(%materialAsset == 0) { %filePath = %assetItem.filePath; if(%filePath !$= "") %materialAsset = AssetBrowser.addImportingAsset("Material", "", "", %noSuffixName); + + %materialAsset.filePath = filePath(%assetItem.filePath) @ "/" @ %noSuffixName; + + %cratedNewMaterial = true; } if(isObject(%materialAsset)) @@ -45,51 +51,60 @@ function AssetBrowser::prepareImportImageAsset(%this, %assetItem) //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(getAssetImportConfigValue("Images/UseDiffuseSuffixOnOriginImg", "1") == 1) + if(%foundSuffixType $= "") { - if(%foundSuffixType $= "") + if(getAssetImportConfigValue("Images/UseDiffuseSuffixOnOriginImg", "1") == 1) { - %diffuseToken = getToken(getAssetImportConfigValue("Images/DiffuseTypeSuffixes", ""), ",", 0); - %assetItem.AssetName = %assetItem.AssetName @ %diffuseToken; - - if(getAssetImportConfigValue("Materials/PopulateMaterialMaps", "1") == 1) - %materialAsset.diffuseImageAsset = %assetItem; - } - else 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 $= "") { - if(%foundSuffixType $= "diffuse") - %materialAsset.diffuseImageAsset = %assetItem; - else if(%foundSuffixType $= "normal") - %materialAsset.normalImageAsset = %assetItem; - else if(%foundSuffixType $= "metalness") - %materialAsset.metalnessImageAsset = %assetItem; - else if(%foundSuffixType $= "roughness") - %materialAsset.roughnessImageAsset = %assetItem; - else if(%foundSuffixType $= "specular") - %materialAsset.specularImageAsset = %assetItem; - else if(%foundSuffixType $= "AO") - %materialAsset.AOImageAsset = %assetItem; - else if(%foundSuffixType $= "composite") - %materialAsset.compositeImageAsset = %assetItem; + %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) + else { - %assetItem.AssetName = %assetItem.AssetName @ "_image"; + //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") + %materialAsset.diffuseImageAsset = %assetItem; + else if(%foundSuffixType $= "normal") + %materialAsset.normalImageAsset = %assetItem; + else if(%foundSuffixType $= "metalness") + %materialAsset.metalnessImageAsset = %assetItem; + else if(%foundSuffixType $= "roughness") + %materialAsset.roughnessImageAsset = %assetItem; + else if(%foundSuffixType $= "specular") + %materialAsset.specularImageAsset = %assetItem; + else if(%foundSuffixType $= "AO") + %materialAsset.AOImageAsset = %assetItem; + else if(%foundSuffixType $= "composite") + %materialAsset.compositeImageAsset = %assetItem; } } - %assetItem.processed = true; + //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); + } } + + %assetItem.processed = true; } function AssetBrowser::importImageAsset(%this, %assetItem) diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs index 5cbd3689e..1b7fbc935 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs @@ -84,29 +84,15 @@ function AssetBrowser::prepareImportMaterialAsset(%this, %assetItem) if(%assetItem.diffuseImageAsset $= "") { - //First, load our diffuse map, as set to the material in the shape - //We're going to presume(for now) that the specifically-mentioned file for a given material is the diffuse/albedo - %diffuseImagePath = %fileDir @ "/" @ %filename @ %fileExt; + %diffuseTypeSuffixes = getAssetImportConfigValue("Images/DiffuseTypeSuffixes", ""); - %diffuseImageSuffix = ImportAssetWindow.parseImagePathSuffixes(%diffuseImagePath); + %targetFilePath = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %diffuseTypeSuffixes); - if(getAssetImportConfigValue("Images/UseDiffuseSuffixOnOriginImage", "1") == 1 && %diffuseImageSuffix $= "") + if(%targetFilePath !$= "") { - %diffuseTypeSuffixes = getAssetImportConfigValue("Images/DiffuseTypeSuffixes", ""); - - %diffuseFilename = %this.findMaterialMapFileWSuffix(%fileDir, %fileName, %fileExt, %diffuseTypeSuffixes); - - if(%diffuseFilename !$= "") - %diffuseAsset = AssetBrowser.addImportingAsset("Image", %diffuseFilename, %assetItem, fileBase(%diffuseFilename)); - else - %diffuseAsset = AssetBrowser.addImportingAsset("Image", %diffuseImagePath, %assetItem, %filename @ getToken(%diffuseTypeSuffixes, ",;", 0)); + %diffuseAsset = AssetBrowser.addImportingAsset("Image", %targetFilePath, %assetItem); + %assetItem.diffuseImageAsset = %diffuseAsset; } - else - { - %diffuseAsset = AssetBrowser.addImportingAsset("Image", %diffuseImagePath, %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. @@ -209,7 +195,25 @@ function AssetBrowser::prepareImportMaterialAsset(%this, %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 $= "" && getAssetImportConfigValue("Materials/CreateComposites", "1") == 1) + { + %assetItem.roughnessImageAsset.skip = true; + %assetItem.AOImageAsset.skip = true; + %assetItem.metalnessImageAsset.skip = true; + + %compositeAssetPath = "data/" @ %assetItem.moduleName @ "/images"; + %saveAsPath = %compositeAssetPath @ "/" @ %assetItem.assetName @ "_composite.png"; + %compositeAsset = AssetBrowser.addImportingAsset("Image", "", %assetItem, %assetItem.assetName @ "_composite"); + %compositeAsset.generatedAsset = true; + %compositeAsset.filePath = %saveAsPath; + + %assetItem.compositeImageAsset = %compositeAsset; + } } + + %assetItem.processed = true; } function AssetBrowser::findMaterialMapFileWSuffix(%this, %fileDir, %filename, %fileExt, %suffixesList) @@ -291,6 +295,28 @@ function AssetBrowser::importMaterialAsset(%this, %assetItem) %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)) @@ -317,22 +343,22 @@ function AssetBrowser::importMaterialAsset(%this, %assetItem) %file.writeline(" SpecularMap[0] = \"" @ %assetItem.specularImageAsset.filePath @"\";"); %file.writeline(" SpecularMapAsset[0] = \"" @ %moduleName @ ":" @ %assetItem.specularImageAsset.assetName @"\";"); }*/ - if(%assetItem.roughnessImageAsset) + if(%assetItem.roughnessImageAsset && %assetItem.roughnessImageAsset.skip == false) { %file.writeline(" RoughMap[0] = \"" @ %assetItem.roughnessImageAsset.filePath @"\";"); %file.writeline(" RoughMapAsset[0] = \"" @ %moduleName @ ":" @ %assetItem.roughnessImageAsset.assetName @"\";"); } - if(%assetItem.smoothnessImageAsset) + if(%assetItem.smoothnessImageAsset && %assetItem.smoothnessImageAsset.skip == false) { %file.writeline(" SmoothnessMap[0] = \"" @ %assetItem.smoothnessImageAsset.filePath @"\";"); %file.writeline(" SmoothnessMapAsset[0] = \"" @ %moduleName @ ":" @ %assetItem.smoothnessImageAsset.assetName @"\";"); } - if(%assetItem.metalnessImageAsset) + if(%assetItem.metalnessImageAsset && %assetItem.metalnessImageAsset.skip == false) { %file.writeline(" MetalMap[0] = \"" @ %assetItem.metalnessImageAsset.filePath @"\";"); %file.writeline(" MetalMapAsset[0] = \"" @ %moduleName @ ":" @ %assetItem.metalnessImageAsset.assetName @"\";"); } - if(%assetItem.AOImageAsset) + if(%assetItem.AOImageAsset && %assetItem.AOImageAsset.skip == false) { %file.writeline(" AOMap[0] = \"" @ %assetItem.AOImageAsset.filePath @"\";"); %file.writeline(" AOMapAsset[0] = \"" @ %moduleName @ ":" @ %assetItem.AOImageAsset.assetName @"\";"); diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/popupMenus.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/popupMenus.cs index 63e9858fa..edd999baa 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/popupMenus.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/popupMenus.cs @@ -115,6 +115,8 @@ function AssetBrowser::buildPopupMenus(%this) item[ 10 ] = "Create Sound" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"SoundAsset\", AssetBrowser.selectedModule);";//"AssetBrowser.createNewSoundAsset(\"NewSound\", AssetBrowser.selectedModule);"; item[ 11 ] = "-"; item[ 12 ] = "Create Particle Effect" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"ParticleEffectAsset\", AssetBrowser.selectedModule);";//"AssetBrowser.createNewParticleEffectAsset(\"NewParticleEffect\", AssetBrowser.selectedModule);"; + item[ 13 ] = "-"; + item[ 14 ] = "Create Cubemap" TAB "" TAB "AssetBrowser.setupCreateNewAsset(\"CubemapAsset\", AssetBrowser.selectedModule);"; }; } diff --git a/Templates/BaseGame/game/tools/gui/cubemapEditor.gui b/Templates/BaseGame/game/tools/gui/cubemapEditor.gui new file mode 100644 index 000000000..26ae7877d --- /dev/null +++ b/Templates/BaseGame/game/tools/gui/cubemapEditor.gui @@ -0,0 +1,454 @@ +%guiContent = new GuiControl(CubemapEditor) { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "1"; + Profile = "ToolsGuiDefaultProfile"; + HorizSizing = "width"; + VertSizing = "height"; + Position = "0 0"; + Extent = "800 600"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + hovertime = "1000"; + + new GuiWindowCtrl(CubemapEditorWindow) { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "1"; + Profile = "ToolsGuiWindowProfile"; + HorizSizing = "center"; + VertSizing = "center"; + position = "200 257"; + Extent = "478 248"; + MinExtent = "478 248"; + canSave = "1"; + Visible = "1"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + resizeWidth = "0"; + resizeHeight = "0"; + canMove = "1"; + canClose = "1"; + canMinimize = "0"; + canMaximize = "0"; + minSize = "50 50"; + EdgeSnap = "1"; + closeCommand = "MaterialEditorGui.hideCubemapEditor(true);"; + text = "Cubemap Editor"; + + new GuiTextCtrl(){ + Profile = "ToolsGuiTextProfile"; + position = "307 40"; + Extent = "30 16"; + text = "Name"; + }; + new GuiTextEditCtrl(CubemapEditor_Name) { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiTextEditProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "338 40"; + Extent = "131 18"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + text = "myCubemap 1"; + maxLength = "1024"; + AltCommand = "MaterialEditorGui.editCubemapName($ThisControl.getText());"; + }; + new GuiButtonCtrl(){ + Profile = "ToolsGuiButtonProfile"; + position = "339 216"; + Extent = "74 24"; + text = "Select"; + command = "MaterialEditorGui.selectCubemap();"; // needs hookup use selected cubemap + }; + new GuiButtonCtrl(){ + Profile = "ToolsGuiButtonProfile"; + position = "417 216"; + Extent = "52 24"; + text = "Cancel"; + command = "MaterialEditorGui.hideCubemapEditor(true);"; // needs hookup Cancel + }; + new GuiScrollCtrl(matEd_cubemapEd_availableCubemapScroller) { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "1"; + Profile = "ToolsGuiScrollProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "5 40"; + Extent = "154 203"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + hovertime = "1000"; + willFirstRespond = "1"; + hScrollBar = "alwaysOff"; + vScrollBar = "dynamic"; + lockHorizScroll = "true"; + lockVertScroll = "false"; + constantThumbHeight = "0"; + childMargin = "0 0"; + + new GuiListBoxCtrl(matEd_cubemapEd_availableCubemapList) { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiListBoxProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "2 2"; + Extent = "128 2"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + hovertime = "1000"; + AllowMultipleSelections = "0"; + fitParentWidth = "1"; + }; + }; + new GuiTextCtrl(){ + Profile = "ToolsGuiTextProfile"; + position = "6 22"; + Extent = "67 16"; + text = "Cubemaps"; + }; + // ------------------------------ Right X Positive ------------------------------------ + new GuiBitmapCtrl(matEd_cubemapEd_XPos) { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiDefaultProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "299 106"; + Extent = "64 64"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + hovertime = "1000"; + bitmap = "tools/materialEditor/gui/unknownImage"; + wrap = "0"; + }; + new GuiTextCtrl(matEd_cubeMapEd_xPosTxt) { + position = "304 110"; + Extent = "57 10"; + text = "+ X Right"; + }; + new GuiBitmapButtonCtrl(matEd_cubeMapEd_updateXPOSImg) { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiDefaultProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "299 106"; + Extent = "64 64"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "MaterialEditorGui.editCubemapImage(\"0\", $ThisControl.bitmap );"; + tooltipprofile = "ToolsGuiDefaultProfile"; + ToolTip = "When using Static Cubemaps, select your CubeMap by clicking here."; + hovertime = "1000"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + bitmap = "tools/materialEditor/gui/cubemapBtnBorder"; + }; + // ------------------------------ X Negitive ------------------------------------ + new GuiBitmapCtrl(matEd_cubemapEd_XNeg) { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiDefaultProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "167 106"; + Extent = "64 64"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + hovertime = "1000"; + bitmap = "tools/materialEditor/gui/unknownImage"; + wrap = "0"; + }; + new GuiTextCtrl(matEd_cubeMapEd_xNegTxt) { + position = "171 110"; + Extent = "57 10"; + text = "- X Left"; + }; + new GuiBitmapButtonCtrl(matEd_cubeMapEd_updateXNEGImg) { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiDefaultProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "167 106"; + Extent = "64 64"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "MaterialEditorGui.editCubemapImage(\"1\", $ThisControl.bitmap );"; + tooltipprofile = "ToolsGuiDefaultProfile"; + ToolTip = "When using Static Cubemaps, select your CubeMap by clicking here."; + hovertime = "1000"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + bitmap = "tools/materialEditor/gui/cubemapBtnBorder"; + }; + // ------------------------------ Y Positive ------------------------------------ + new GuiBitmapCtrl(matEd_cubemapEd_YPos) { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiDefaultProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "233 172"; + Extent = "64 64"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + hovertime = "1000"; + bitmap = "tools/materialEditor/gui/unknownImage"; + wrap = "0"; + }; + new GuiTextCtrl(matEd_cubeMapEd_yPosTxt) { + position = "237 175"; + Extent = "57 10"; + text = "+ Y Front"; + }; + new GuiBitmapButtonCtrl(matEd_cubeMapEd_updateYPOSImg) { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiDefaultProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "233 172"; + Extent = "64 64"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "MaterialEditorGui.editCubemapImage(\"3\", $ThisControl.bitmap );"; + tooltipprofile = "ToolsGuiDefaultProfile"; + ToolTip = "When using Static Cubemaps, select your CubeMap by clicking here."; + hovertime = "1000"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + bitmap = "tools/materialEditor/gui/cubemapBtnBorder"; + }; + // ------------------------------ Y Negitive ------------------------------------ + new GuiBitmapCtrl(matEd_cubemapEd_YNeG) { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiDefaultProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "233 40"; + Extent = "64 64"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + hovertime = "1000"; + bitmap = "tools/materialEditor/gui/unknownImage"; + wrap = "0"; + }; + new GuiTextCtrl(matEd_cubeMapEd_yNegTxt) { + position = "237 44"; + Extent = "57 10"; + text = "- Y Back"; + }; + new GuiBitmapButtonCtrl(matEd_cubeMapEd_updateYNegImg) { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiDefaultProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "233 40"; + Extent = "64 64"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "MaterialEditorGui.editCubemapImage(\"2\", $ThisControl.bitmap );"; + tooltipprofile = "ToolsGuiDefaultProfile"; + ToolTip = "When using Static Cubemaps, select your CubeMap by clicking here."; + hovertime = "1000"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + bitmap = "tools/materialEditor/gui/cubemapBtnBorder"; + }; + // ------------------------------ Z Positive ------------------------------------ + new GuiBitmapCtrl(matEd_cubemapEd_ZPos) { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiDefaultProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "233 106"; + Extent = "64 64"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + hovertime = "1000"; + bitmap = "tools/materialEditor/gui/unknownImage"; + wrap = "0"; + }; + new GuiTextCtrl(matEd_cubeMapEd_zPosTxt) { + position = "237 110"; + Extent = "57 10"; + text = "+ Z Top"; + }; + new GuiBitmapButtonCtrl(matEd_cubeMapEd_updateZPosImg) { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiDefaultProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "233 106"; + Extent = "64 64"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "MaterialEditorGui.editCubemapImage(\"4\", $ThisControl.bitmap );"; + tooltipprofile = "ToolsGuiDefaultProfile"; + ToolTip = "When using Static Cubemaps, select your CubeMap by clicking here."; + hovertime = "1000"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + bitmap = "tools/materialEditor/gui/cubemapBtnBorder"; + }; + // ------------------------------ Z Negitive ------------------------------------ + new GuiBitmapCtrl(matEd_cubemapEd_ZNeg) { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiDefaultProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "365 106"; + Extent = "64 64"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + hovertime = "1000"; + bitmap = "tools/materialEditor/gui/unknownImage"; + wrap = "0"; + }; + new GuiTextCtrl(matEd_cubeMapEd_zNegTxt) { + position = "369 110"; + Extent = "57 10"; + text = "- Z Bottom"; + }; + new GuiBitmapButtonCtrl(matEd_cubeMapEd_updateZNegImg) { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiDefaultProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "365 106"; + Extent = "64 64"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "MaterialEditorGui.editCubemapImage(\"5\", $ThisControl.bitmap );"; + tooltipprofile = "ToolsGuiDefaultProfile"; + ToolTip = "When using Static Cubemaps, select your CubeMap by clicking here."; + hovertime = "1000"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + bitmap = "tools/materialEditor/gui/cubemapBtnBorder"; + }; + + // Create New Cubemap + new GuiBitmapButtonCtrl() { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiDefaultProfile"; + HorizSizing = "right"; + VertSizing = "top"; + position = "128 23"; + Extent = "17 17"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "matEd_addCubemapWindow.setVisible(1);"; // -------------- Needs Hookup Create New Cubemap + hovertime = "1000"; + tooltip = "Create New Cubemap"; + bitmap = "tools/gui/images/new"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + }; + new GuiBitmapButtonCtrl() { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiDefaultProfile"; + HorizSizing = "right"; + VertSizing = "top"; + position = "143 23"; + Extent = "17 17"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "MaterialEditorGui.showDeleteCubemapDialog();"; // -------------- Needs Hookup Delete Cubemap + hovertime = "1000"; + tooltip = "Delete Cubemap"; + bitmap = "tools/gui/images/delete"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + }; + new GuiBitmapButtonCtrl() { + internalName = "saveCubemap"; + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "0"; + Profile = "ToolsGuiDefaultProfile"; + HorizSizing = "right"; + VertSizing = "top"; + position = "106 23"; + Extent = "17 17"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + Command = "MaterialEditorGui.showSaveCubemapDialog();"; // -------------- Needs Hookup Save Cubemap + hovertime = "1000"; + tooltip = "Save Cubemap"; + bitmap = "tools/gui/images/save-icon"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + }; + }; +}; \ No newline at end of file diff --git a/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPreviewWindow.ed.gui b/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPreviewWindow.ed.gui index 8110d2c34..8b6dedb44 100644 --- a/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPreviewWindow.ed.gui +++ b/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPreviewWindow.ed.gui @@ -234,445 +234,6 @@ text ="Preview in World"; }; }; - new GuiWindowCtrl(matEd_cubemapEditor) { - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "1"; - Profile = "ToolsGuiWindowProfile"; - HorizSizing = "center"; - VertSizing = "center"; - position = "200 257"; - Extent = "478 248"; - MinExtent = "478 248"; - canSave = "1"; - Visible = "0"; - hovertime = "1000"; - Margin = "0 0 0 0"; - Padding = "0 0 0 0"; - AnchorTop = "1"; - AnchorBottom = "0"; - AnchorLeft = "1"; - AnchorRight = "0"; - resizeWidth = "0"; - resizeHeight = "0"; - canMove = "1"; - canClose = "1"; - canMinimize = "0"; - canMaximize = "0"; - minSize = "50 50"; - EdgeSnap = "1"; - closeCommand = "MaterialEditorGui.hideCubemapEditor(true);"; - text = "Cubemap Editor"; - - new GuiTextCtrl(){ - Profile = "ToolsGuiTextProfile"; - position = "307 40"; - Extent = "30 16"; - text = "Name"; - }; - new GuiTextEditCtrl(matEd_cubemapEd_activeCubemapNameTxt) { - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiTextEditProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "338 40"; - Extent = "131 18"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; - Margin = "0 0 0 0"; - Padding = "0 0 0 0"; - AnchorTop = "1"; - AnchorBottom = "0"; - AnchorLeft = "1"; - AnchorRight = "0"; - text = "myCubemap 1"; - maxLength = "1024"; - AltCommand = "MaterialEditorGui.editCubemapName($ThisControl.getText());"; - }; - new GuiButtonCtrl(){ - Profile = "ToolsGuiButtonProfile"; - position = "339 216"; - Extent = "74 24"; - text = "Select"; - command = "MaterialEditorGui.selectCubemap();"; // needs hookup use selected cubemap - }; - new GuiButtonCtrl(){ - Profile = "ToolsGuiButtonProfile"; - position = "417 216"; - Extent = "52 24"; - text = "Cancel"; - command = "MaterialEditorGui.hideCubemapEditor(true);"; // needs hookup Cancel - }; - new GuiScrollCtrl(matEd_cubemapEd_availableCubemapScroller) { - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "1"; - Profile = "ToolsGuiScrollProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "5 40"; - Extent = "154 203"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; - willFirstRespond = "1"; - hScrollBar = "alwaysOff"; - vScrollBar = "dynamic"; - lockHorizScroll = "true"; - lockVertScroll = "false"; - constantThumbHeight = "0"; - childMargin = "0 0"; - - new GuiListBoxCtrl(matEd_cubemapEd_availableCubemapList) { - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiListBoxProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "2 2"; - Extent = "128 2"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; - AllowMultipleSelections = "0"; - fitParentWidth = "1"; - }; - }; - new GuiTextCtrl(){ - Profile = "ToolsGuiTextProfile"; - position = "6 22"; - Extent = "67 16"; - text = "Cubemaps"; - }; - // ------------------------------ Right X Positive ------------------------------------ - new GuiBitmapCtrl(matEd_cubemapEd_XPos) { - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiDefaultProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "299 106"; - Extent = "64 64"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; - bitmap = "tools/materialEditor/gui/unknownImage"; - wrap = "0"; - }; - new GuiTextCtrl(matEd_cubeMapEd_xPosTxt) { - position = "304 110"; - Extent = "57 10"; - text = "+ X Right"; - }; - new GuiBitmapButtonCtrl(matEd_cubeMapEd_updateXPOSImg) { - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiDefaultProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "299 106"; - Extent = "64 64"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "MaterialEditorGui.editCubemapImage(\"0\", $ThisControl.bitmap );"; - tooltipprofile = "ToolsGuiDefaultProfile"; - ToolTip = "When using Static Cubemaps, select your CubeMap by clicking here."; - hovertime = "1000"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - bitmap = "tools/materialEditor/gui/cubemapBtnBorder"; - }; - // ------------------------------ X Negitive ------------------------------------ - new GuiBitmapCtrl(matEd_cubemapEd_XNeg) { - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiDefaultProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "167 106"; - Extent = "64 64"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; - bitmap = "tools/materialEditor/gui/unknownImage"; - wrap = "0"; - }; - new GuiTextCtrl(matEd_cubeMapEd_xNegTxt) { - position = "171 110"; - Extent = "57 10"; - text = "- X Left"; - }; - new GuiBitmapButtonCtrl(matEd_cubeMapEd_updateXNEGImg) { - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiDefaultProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "167 106"; - Extent = "64 64"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "MaterialEditorGui.editCubemapImage(\"1\", $ThisControl.bitmap );"; - tooltipprofile = "ToolsGuiDefaultProfile"; - ToolTip = "When using Static Cubemaps, select your CubeMap by clicking here."; - hovertime = "1000"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - bitmap = "tools/materialEditor/gui/cubemapBtnBorder"; - }; - // ------------------------------ Y Positive ------------------------------------ - new GuiBitmapCtrl(matEd_cubemapEd_YPos) { - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiDefaultProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "233 172"; - Extent = "64 64"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; - bitmap = "tools/materialEditor/gui/unknownImage"; - wrap = "0"; - }; - new GuiTextCtrl(matEd_cubeMapEd_yPosTxt) { - position = "237 175"; - Extent = "57 10"; - text = "+ Y Front"; - }; - new GuiBitmapButtonCtrl(matEd_cubeMapEd_updateYPOSImg) { - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiDefaultProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "233 172"; - Extent = "64 64"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "MaterialEditorGui.editCubemapImage(\"3\", $ThisControl.bitmap );"; - tooltipprofile = "ToolsGuiDefaultProfile"; - ToolTip = "When using Static Cubemaps, select your CubeMap by clicking here."; - hovertime = "1000"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - bitmap = "tools/materialEditor/gui/cubemapBtnBorder"; - }; - // ------------------------------ Y Negitive ------------------------------------ - new GuiBitmapCtrl(matEd_cubemapEd_YNeG) { - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiDefaultProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "233 40"; - Extent = "64 64"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; - bitmap = "tools/materialEditor/gui/unknownImage"; - wrap = "0"; - }; - new GuiTextCtrl(matEd_cubeMapEd_yNegTxt) { - position = "237 44"; - Extent = "57 10"; - text = "- Y Back"; - }; - new GuiBitmapButtonCtrl(matEd_cubeMapEd_updateYNegImg) { - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiDefaultProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "233 40"; - Extent = "64 64"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "MaterialEditorGui.editCubemapImage(\"2\", $ThisControl.bitmap );"; - tooltipprofile = "ToolsGuiDefaultProfile"; - ToolTip = "When using Static Cubemaps, select your CubeMap by clicking here."; - hovertime = "1000"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - bitmap = "tools/materialEditor/gui/cubemapBtnBorder"; - }; - // ------------------------------ Z Positive ------------------------------------ - new GuiBitmapCtrl(matEd_cubemapEd_ZPos) { - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiDefaultProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "233 106"; - Extent = "64 64"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; - bitmap = "tools/materialEditor/gui/unknownImage"; - wrap = "0"; - }; - new GuiTextCtrl(matEd_cubeMapEd_zPosTxt) { - position = "237 110"; - Extent = "57 10"; - text = "+ Z Top"; - }; - new GuiBitmapButtonCtrl(matEd_cubeMapEd_updateZPosImg) { - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiDefaultProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "233 106"; - Extent = "64 64"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "MaterialEditorGui.editCubemapImage(\"4\", $ThisControl.bitmap );"; - tooltipprofile = "ToolsGuiDefaultProfile"; - ToolTip = "When using Static Cubemaps, select your CubeMap by clicking here."; - hovertime = "1000"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - bitmap = "tools/materialEditor/gui/cubemapBtnBorder"; - }; - // ------------------------------ Z Negitive ------------------------------------ - new GuiBitmapCtrl(matEd_cubemapEd_ZNeg) { - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiDefaultProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "365 106"; - Extent = "64 64"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; - bitmap = "tools/materialEditor/gui/unknownImage"; - wrap = "0"; - }; - new GuiTextCtrl(matEd_cubeMapEd_zNegTxt) { - position = "369 110"; - Extent = "57 10"; - text = "- Z Bottom"; - }; - new GuiBitmapButtonCtrl(matEd_cubeMapEd_updateZNegImg) { - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiDefaultProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "365 106"; - Extent = "64 64"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "MaterialEditorGui.editCubemapImage(\"5\", $ThisControl.bitmap );"; - tooltipprofile = "ToolsGuiDefaultProfile"; - ToolTip = "When using Static Cubemaps, select your CubeMap by clicking here."; - hovertime = "1000"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - bitmap = "tools/materialEditor/gui/cubemapBtnBorder"; - }; - - // Create New Cubemap - new GuiBitmapButtonCtrl() { - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiDefaultProfile"; - HorizSizing = "right"; - VertSizing = "top"; - position = "128 23"; - Extent = "17 17"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "matEd_addCubemapWindow.setVisible(1);"; // -------------- Needs Hookup Create New Cubemap - hovertime = "1000"; - tooltip = "Create New Cubemap"; - bitmap = "tools/gui/images/new"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - }; - new GuiBitmapButtonCtrl() { - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiDefaultProfile"; - HorizSizing = "right"; - VertSizing = "top"; - position = "143 23"; - Extent = "17 17"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "MaterialEditorGui.showDeleteCubemapDialog();"; // -------------- Needs Hookup Delete Cubemap - hovertime = "1000"; - tooltip = "Delete Cubemap"; - bitmap = "tools/gui/images/delete"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - }; - new GuiBitmapButtonCtrl() { - internalName = "saveCubemap"; - canSaveDynamicFields = "0"; - Enabled = "1"; - isContainer = "0"; - Profile = "ToolsGuiDefaultProfile"; - HorizSizing = "right"; - VertSizing = "top"; - position = "106 23"; - Extent = "17 17"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "MaterialEditorGui.showSaveCubemapDialog();"; // -------------- Needs Hookup Save Cubemap - hovertime = "1000"; - tooltip = "Save Cubemap"; - bitmap = "tools/gui/images/save-icon"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - }; - }; new GuiWindowCtrl(matEd_addCubemapWindow) { canSaveDynamicFields = "0"; diff --git a/Templates/BaseGame/game/tools/settings.xml b/Templates/BaseGame/game/tools/settings.xml index 372e22b2c..92139fc39 100644 --- a/Templates/BaseGame/game/tools/settings.xml +++ b/Templates/BaseGame/game/tools/settings.xml @@ -1,5 +1,117 @@ + + AIPlayer + + + 72 70 68 255 + 234 232 230 255 + 59 58 57 255 + 255 255 255 255 + 72 70 68 255 + 240 240 240 255 + 178 175 172 255 + 236 234 232 255 + 59 58 57 255 + 50 49 48 255 + 50 49 48 255 + 50 49 48 255 + 37 36 35 255 + 32 31 30 255 + 17 16 15 255 + 43 43 43 255 + 96 94 92 255 + 100 98 96 255 + + + lowerHeight + + 1.000000 0.833333 0.666667 0.500000 0.333333 0.166667 0.000000 + 0.1 + 0 + 1.000000 0.833333 0.666667 0.500000 0.333333 0.166667 0.000000 + 90 + 1 + 100 + 10 + 50 + 1 + + + ellipse + 40 40 + 1 + 40 40 + 1 + + + + 50 + 40 + WorldEditorInspectorPlugin + 6 + 1 + 0 + AssetWork_Debug.exe + screenCenter + + 2 + 1 + 0 + 100 + 0 + 0 + 1 + + + 0 255 0 255 + 100 100 100 255 + 0 0 255 255 + 255 255 0 255 + 255 0 0 255 + 255 255 0 255 + 255 255 255 255 + + + ../../../Documentation/Official Documentation.html + ../../../Documentation/Torque 3D - Script Manual.chm + http://www.garagegames.com/products/torque-3d/documentation/user + http://www.garagegames.com/products/torque-3d/forums + + + 1 + 0 + 255 + 20 + 8 + + + 1 + 1 + 1 + 1 + 1 + + + 102 102 102 100 + 51 51 51 100 + 0 + 255 255 255 100 + 1 + + + 180 180 180 255 + 255 255 255 255 + 50 50 50 255 + 48 48 48 255 + 215 215 215 255 + + + tools/worldEditor/images/LockedHandle + tools/worldEditor/images/DefaultHandle + tools/worldEditor/images/SelectHandle + + data/FPSGameplay/levels @@ -11,176 +123,64 @@ - - 50 - screenCenter - AssetWork_Debug.exe - 0 - 1 - 40 - 6 - WorldEditorInspectorPlugin - - 0 - 1 - 8 - 20 - 255 - - - 0 - 2 - 100 - 1 - 0 - 0 - 1 - - - http://www.garagegames.com/products/torque-3d/documentation/user - http://www.garagegames.com/products/torque-3d/forums - ../../../Documentation/Torque 3D - Script Manual.chm - ../../../Documentation/Official Documentation.html - - - 255 255 0 255 - 0 255 0 255 - 255 0 0 255 - 255 255 255 255 - 255 255 0 255 - 0 0 255 255 - 100 100 100 255 - - - tools/worldEditor/images/LockedHandle - tools/worldEditor/images/SelectHandle - tools/worldEditor/images/DefaultHandle - - - 102 102 102 100 - 0 - 1 - 51 51 51 100 - 255 255 255 100 - - - 1 - 1 - 1 - 1 - 1 - - - 180 180 180 255 - 48 48 48 255 - 255 255 255 255 - 215 215 215 255 - 50 50 50 255 - - - - 1024 768 - tools/gui - - 2 - 8 - 0 - 1 - 1 - 1 - 1 - 1 - - - Categorized - - - http://www.garagegames.com/products/torque-3d/documentation/user - ../../../Documentation/Official Documentation.html - ../../../Documentation/Torque 3D - Script Manual.chm - - - 1 - 1 - - - 0 - 0 - 0 - - - 0 - - - - 32 31 30 255 - 59 58 57 255 - 50 49 48 255 - 17 16 15 255 - 240 240 240 255 - 59 58 57 255 - 50 49 48 255 - 178 175 172 255 - 43 43 43 255 - 37 36 35 255 - 100 98 96 255 - 50 49 48 255 - 255 255 255 255 - 72 70 68 255 - 234 232 230 255 - 72 70 68 255 - 236 234 232 255 - 96 94 92 255 - - - lowerHeight - - 1 - 1 - 1.000000 0.833333 0.666667 0.500000 0.333333 0.166667 0.000000 - 90 - 10 - 1.000000 0.833333 0.666667 0.500000 0.333333 0.166667 0.000000 - 0.1 - 50 - 100 - 0 - - - 40 40 - 1 - 40 40 - 1 - ellipse - - + 15 0 0.8 100 0.8 0 1 - 15 - 0 - 10 10 10 500 - 0 - 255 255 255 20 0 + 10 10 10 + 0 + 255 255 255 20 + 0 + 0 255 0 255 + 255 255 255 255 255 0 0 255 5 - 10 - 255 255 255 255 - 0 255 0 255 0 0 1 + 10 - - AIPlayer + + tools/gui + 1024 768 + + 0 + 0 + 0 + + + 1 + 1 + + + 1 + 0 + 1 + 1 + 2 + 1 + 1 + 8 + + + ../../../Documentation/Torque 3D - Script Manual.chm + ../../../Documentation/Official Documentation.html + http://www.garagegames.com/products/torque-3d/documentation/user + + + Categorized + + + 0 + Grid_512_Orange diff --git a/Templates/BaseGame/game/tools/worldEditor/main.cs b/Templates/BaseGame/game/tools/worldEditor/main.cs index a503d23a6..6c87dfefe 100644 --- a/Templates/BaseGame/game/tools/worldEditor/main.cs +++ b/Templates/BaseGame/game/tools/worldEditor/main.cs @@ -46,6 +46,8 @@ function initializeWorldEditor() exec("./gui/shadowViz.gui" ); exec("./gui/probeBakeDlg.gui" ); + exec("tools/gui/cubemapEditor.gui" ); + // Load Scripts. exec("./scripts/menus.ed.cs"); exec("./scripts/menuHandlers.ed.cs");