diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index 125c5891d..767cb44f1 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -200,7 +200,7 @@ void LightningStrikeEvent::unpack(NetConnection* con, BitStream* stream) { if(!stream->readFlag()) return; - S32 mClientId = stream->readRangedU32(0, NetConnection::MaxGhostCount); + mClientId = stream->readRangedU32(0, NetConnection::MaxGhostCount); mLightning = NULL; NetObject* pObject = con->resolveGhost(mClientId); if (pObject) @@ -214,10 +214,10 @@ void LightningStrikeEvent::unpack(NetConnection* con, BitStream* stream) // target id S32 mTargetID = stream->readRangedU32(0, NetConnection::MaxGhostCount); - NetObject* pObject = con->resolveGhost(mTargetID); - if( pObject != NULL ) + NetObject* tObject = con->resolveGhost(mTargetID); + if(tObject != NULL ) { - mTarget = dynamic_cast(pObject); + mTarget = dynamic_cast(tObject); } if( bool(mTarget) == false ) { @@ -243,6 +243,7 @@ LightningData::LightningData() dMemset( strikeTextureNames, 0, sizeof( strikeTextureNames ) ); dMemset( strikeTextures, 0, sizeof( strikeTextures ) ); dMemset( thunderSounds, 0, sizeof( thunderSounds ) ); + mNumStrikeTextures = 0; } LightningData::~LightningData() @@ -297,10 +298,14 @@ bool LightningData::preload(bool server, String &errorStr) if( !sfxResolve( &strikeSound, sfxErrorStr ) ) Con::errorf(ConsoleLogEntry::General, "LightningData::preload: Invalid packet: %s", sfxErrorStr.c_str()); + mNumStrikeTextures = 0; for (U32 i = 0; i < MaxTextures; i++) { if (strikeTextureNames[i][0]) + { strikeTextures[i] = GFXTexHandle(strikeTextureNames[i], &GFXDefaultStaticDiffuseProfile, avar("%s() - strikeTextures[%d] (line %d)", __FUNCTION__, i, __LINE__)); + mNumStrikeTextures++; + } } } @@ -317,7 +322,11 @@ void LightningData::packData(BitStream* stream) U32 i; for (i = 0; i < MaxThunders; i++) sfxWrite( stream, thunderSounds[ i ] ); - for (i = 0; i < MaxTextures; i++) { + + stream->writeInt(mNumStrikeTextures, 4); + + for (i = 0; i < MaxTextures; i++) + { stream->writeString(strikeTextureNames[i]); } @@ -331,7 +340,11 @@ void LightningData::unpackData(BitStream* stream) U32 i; for (i = 0; i < MaxThunders; i++) sfxRead( stream, &thunderSounds[ i ] ); - for (i = 0; i < MaxTextures; i++) { + + mNumStrikeTextures = stream->readInt(4); + + for (i = 0; i < MaxTextures; i++) + { strikeTextureNames[i] = stream->readSTString(); } @@ -368,16 +381,16 @@ Lightning::~Lightning() { while( mThunderListHead ) { - Thunder* next = mThunderListHead->next; + Thunder* nextThunder = mThunderListHead->next; delete mThunderListHead; - mThunderListHead = next; + mThunderListHead = nextThunder; } while( mStrikeListHead ) { - Strike* next = mStrikeListHead->next; + Strike* nextStrike = mStrikeListHead->next; delete mStrikeListHead; - mStrikeListHead = next; + mStrikeListHead = nextStrike; } } @@ -478,11 +491,16 @@ void Lightning::renderObject(ObjectRenderInst *ri, SceneRenderState *state, Base desc.setBlend( true, GFXBlendSrcAlpha, GFXBlendOne); desc.setCullMode(GFXCullNone); desc.zWriteEnable = false; - desc.samplersDefined = true; - desc.samplers[0].magFilter = GFXTextureFilterLinear; - desc.samplers[0].minFilter = GFXTextureFilterLinear; - desc.samplers[0].addressModeU = GFXAddressWrap; - desc.samplers[0].addressModeV = GFXAddressWrap; + desc.vertexColorEnable = true; + + if (mDataBlock->mNumStrikeTextures != 0) + { + desc.samplersDefined = true; + desc.samplers[0].magFilter = GFXTextureFilterLinear; + desc.samplers[0].minFilter = GFXTextureFilterLinear; + desc.samplers[0].addressModeU = GFXAddressWrap; + desc.samplers[0].addressModeV = GFXAddressWrap; + } mLightningSB = GFX->createStateBlock(desc); @@ -494,9 +512,16 @@ void Lightning::renderObject(ObjectRenderInst *ri, SceneRenderState *state, Base Strike* walk = mStrikeListHead; while (walk != NULL) { - GFX->setTexture(0, mDataBlock->strikeTextures[0]); + if (mDataBlock->mNumStrikeTextures > 1) + { + GFX->setTexture(0, mDataBlock->strikeTextures[sgLightningRand.randI(0, mDataBlock->mNumStrikeTextures - 1)]); + } + else if (mDataBlock->mNumStrikeTextures > 0) + { + GFX->setTexture(0, mDataBlock->strikeTextures[0]); + } - for( U32 i=0; i<3; i++ ) + for( U32 i=0; ibolt[i].isFading ) { @@ -515,8 +540,8 @@ void Lightning::renderObject(ObjectRenderInst *ri, SceneRenderState *state, Base } //GFX->setZWriteEnable(true); - //GFX->setAlphaTestEnable(false); - //GFX->setAlphaBlendEnable(false); + //GFX->setAlphaTestEnable(false); + //GFX->setAlphaBlendEnable(false); } void Lightning::scheduleThunder(Strike* newStrike) @@ -589,7 +614,7 @@ void Lightning::advanceTime(F32 dt) while (*pWalker != NULL) { Strike* pStrike = *pWalker; - for( U32 i=0; i<3; i++ ) + for( U32 i=0; ibolt[i].update( dt ); } @@ -673,7 +698,7 @@ void Lightning::processEvent(LightningStrikeEvent* pEvent) pStrike->currentAge = 0.0f; pStrike->next = mStrikeListHead; - for( U32 i=0; i<3; i++ ) + for( U32 i=0; ibegin(); itr != pClientGroup->end(); itr++) { @@ -717,6 +743,9 @@ void Lightning::warningFlashes() { LightningStrikeEvent* pEvent = new LightningStrikeEvent; pEvent->mLightning = this; + + pEvent->mStart.x = strikePoint.x; + pEvent->mStart.y = strikePoint.y; nc->postNetEvent(pEvent); } @@ -731,18 +760,19 @@ void Lightning::strikeRandomPoint() Point3F strikePoint( gRandGen.randF( 0.0f, 1.0f ), gRandGen.randF( 0.0f, 1.0f ), 0.0f ); // check if an object is within target range + Point3F worldPosStrikePoint = strikePoint; - strikePoint *= mObjScale; - strikePoint += getPosition(); - strikePoint += Point3F( -mObjScale.x * 0.5f, -mObjScale.y * 0.5f, 0.0f ); + worldPosStrikePoint *= mObjScale; + worldPosStrikePoint += getPosition(); + worldPosStrikePoint += Point3F( -mObjScale.x * 0.5f, -mObjScale.y * 0.5f, 0.0f ); Box3F queryBox; F32 boxWidth = strikeRadius * 2.0f; queryBox.minExtents.set( -boxWidth * 0.5f, -boxWidth * 0.5f, -mObjScale.z * 0.5f ); queryBox.maxExtents.set( boxWidth * 0.5f, boxWidth * 0.5f, mObjScale.z * 0.5f ); - queryBox.minExtents += strikePoint; - queryBox.maxExtents += strikePoint; + queryBox.minExtents += worldPosStrikePoint; + queryBox.maxExtents += worldPosStrikePoint; SimpleQueryList sql; getContainer()->findObjects(queryBox, DAMAGEABLE_TYPEMASK, @@ -837,13 +867,53 @@ void Lightning::strikeRandomPoint() } //-------------------------------------------------------------------------- -void Lightning::strikeObject(ShapeBase*) +void Lightning::strikeObject(ShapeBase* targetObj) { AssertFatal(isServerObject(), "Error, client objects may not initiate lightning!"); - AssertFatal(false, "Lightning::strikeObject is not implemented."); -} + Point3F strikePoint = targetObj->getPosition(); + Point3F objectCenter; + Box3F wb = getWorldBox(); + if (!wb.isContained(strikePoint)) + return; + + Point3F targetRel = strikePoint - getPosition(); + Point3F length(wb.len_x() / 2.0f, wb.len_y() / 2.0f, wb.len_z() / 2.0f); + + Point3F strikePos = targetRel / length; + + bool playerInWarmup = false; + Player *playerObj = dynamic_cast< Player * >(targetObj); + if (playerObj) + { + if (!playerObj->getControllingClient()) + { + playerInWarmup = true; + } + } + + if (!playerInWarmup) + { + applyDamage_callback(targetObj->getWorldSphere().center, VectorF(0.0, 0.0, 1.0), targetObj); + } + + SimGroup* pClientGroup = Sim::getClientGroup(); + for (SimGroup::iterator itr = pClientGroup->begin(); itr != pClientGroup->end(); itr++) { + NetConnection* nc = static_cast(*itr); + if (nc != NULL) + { + LightningStrikeEvent* pEvent = new LightningStrikeEvent; + pEvent->mLightning = this; + + pEvent->mStart.x = strikePoint.x; + pEvent->mStart.y = strikePoint.y; + pEvent->mTarget = targetObj; + + nc->postNetEvent(pEvent); + } + } +} //-------------------------------------------------------------------------- U32 Lightning::packUpdate(NetConnection* con, U32 mask, BitStream* stream) @@ -864,6 +934,7 @@ U32 Lightning::packUpdate(NetConnection* con, U32 mask, BitStream* stream) stream->write(color.red); stream->write(color.green); stream->write(color.blue); + stream->write(color.alpha); stream->write(fadeColor.red); stream->write(fadeColor.green); stream->write(fadeColor.blue); @@ -895,6 +966,7 @@ void Lightning::unpackUpdate(NetConnection* con, BitStream* stream) stream->read(&color.red); stream->read(&color.green); stream->read(&color.blue); + stream->read(&color.alpha); stream->read(&fadeColor.red); stream->read(&fadeColor.green); stream->read(&fadeColor.blue); @@ -930,7 +1002,7 @@ DefineEngineMethod(Lightning, strikeRandomPoint, void, (),, object->strikeRandomPoint(); } -DefineEngineMethod(Lightning, strikeObject, void, (ShapeBase* pSB),, +DefineEngineMethod(Lightning, strikeObject, void, (ShapeBase* pSB), (nullAsType()), "Creates a LightningStrikeEvent which strikes a specific object.\n" "@note This method is currently unimplemented.\n" ) { @@ -1028,7 +1100,7 @@ void LightningBolt::render( const Point3F &camPos ) renderSegment(mMinorNodes[i], camPos, false); } - PrimBuild::end(); + PrimBuild::end(); for(LightingBoltList::Iterator i = splitList.begin(); i != splitList.end(); ++i) { @@ -1154,26 +1226,26 @@ void LightningBolt::generateMinorNodes() //---------------------------------------------------------------------------- // Recursive algo to create bolts that split off from main bolt //---------------------------------------------------------------------------- -void LightningBolt::createSplit( const Point3F &startPoint, const Point3F &endPoint, U32 depth, F32 width ) +void LightningBolt::createSplit( const Point3F &startingPoint, const Point3F &endingPoint, U32 depth, F32 splitWidth ) { if( depth == 0 ) return; - + F32 chanceToEnd = gRandGen.randF(); if( chanceToEnd > 0.70f ) return; - if( width < 0.75f ) - width = 0.75f; + if(splitWidth < 0.75f ) + splitWidth = 0.75f; - VectorF diff = endPoint - startPoint; + VectorF diff = endingPoint - startingPoint; F32 length = diff.len(); diff.normalizeSafe(); LightningBolt newBolt; - newBolt.startPoint = startPoint; - newBolt.endPoint = endPoint; - newBolt.width = width; + newBolt.startPoint = startingPoint; + newBolt.endPoint = endingPoint; + newBolt.width = splitWidth; newBolt.numMajorNodes = 3; newBolt.maxMajorAngle = 30.0f; newBolt.numMinorNodes = 3; @@ -1184,13 +1256,13 @@ void LightningBolt::createSplit( const Point3F &startPoint, const Point3F &endPo splitList.pushBack( newBolt ); VectorF newDir1 = MathUtils::randomDir( diff, 10.0f, 45.0f ); - Point3F newEndPoint1 = endPoint + newDir1 * gRandGen.randF( 0.5f, 1.5f ) * length; + Point3F newEndPoint1 = endingPoint + newDir1 * gRandGen.randF( 0.5f, 1.5f ) * length; VectorF newDir2 = MathUtils::randomDir( diff, 10.0f, 45.0f ); - Point3F newEndPoint2 = endPoint + newDir2 * gRandGen.randF( 0.5f, 1.5f ) * length; + Point3F newEndPoint2 = endingPoint + newDir2 * gRandGen.randF( 0.5f, 1.5f ) * length; - createSplit( endPoint, newEndPoint1, depth - 1, width * 0.30f ); - createSplit( endPoint, newEndPoint2, depth - 1, width * 0.30f ); + createSplit(endingPoint, newEndPoint1, depth - 1, splitWidth * 0.30f ); + createSplit(endingPoint, newEndPoint2, depth - 1, splitWidth * 0.30f ); } @@ -1203,7 +1275,7 @@ void LightningBolt::startSplits() for( U32 i=0; i 0.3f ) - continue; + continue; Node node = mMajorNodes.nodeList[i]; Node node2 = mMajorNodes.nodeList[i+1]; diff --git a/Engine/source/T3D/fx/lightning.h b/Engine/source/T3D/fx/lightning.h index 20620fca5..ed08bbd82 100644 --- a/Engine/source/T3D/fx/lightning.h +++ b/Engine/source/T3D/fx/lightning.h @@ -47,6 +47,7 @@ class ShapeBase; class LightningStrikeEvent; class SFXTrack; +#define MAX_LIGHTNING 3 // ------------------------------------------------------------------------- class LightningData : public GameBaseData @@ -70,6 +71,7 @@ class LightningData : public GameBaseData GFXTexHandle strikeTextures[MaxTextures]; U32 numThunders; + U32 mNumStrikeTextures; protected: bool onAdd(); @@ -227,7 +229,7 @@ class Lightning : public GameBase void warningFlashes(); void strikeRandomPoint(); - void strikeObject(ShapeBase*); + void strikeObject(ShapeBase* targetObj); void processEvent(LightningStrikeEvent*); DECLARE_CONOBJECT(Lightning); diff --git a/Engine/source/console/consoleFunctions.cpp b/Engine/source/console/consoleFunctions.cpp index 1cf0335c0..bdf1d5cfe 100644 --- a/Engine/source/console/consoleFunctions.cpp +++ b/Engine/source/console/consoleFunctions.cpp @@ -2141,13 +2141,18 @@ DefineEngineFunction( gotoWebPage, void, ( const char* address ),, //----------------------------------------------------------------------------- -DefineEngineFunction( displaySplashWindow, bool, (const char* path), ("art/gui/splash.bmp"), +DefineEngineFunction( displaySplashWindow, bool, (const char* path), (""), "Display a startup splash window suitable for showing while the engine still starts up.\n\n" "@note This is currently only implemented on Windows.\n\n" "@param path relative path to splash screen image to display.\n" "@return True if the splash window could be successfully initialized.\n\n" "@ingroup Platform" ) { + if (path == "") + { + path = Con::getVariable("$Core::splashWindowImage"); + } + return Platform::displaySplashWindow(path); } diff --git a/Engine/source/forest/editor/forestSelectionTool.cpp b/Engine/source/forest/editor/forestSelectionTool.cpp index a01c6cf86..3d3e9d022 100644 --- a/Engine/source/forest/editor/forestSelectionTool.cpp +++ b/Engine/source/forest/editor/forestSelectionTool.cpp @@ -197,6 +197,9 @@ void ForestSelectionTool::_selectItem( const ForestItem &item ) void ForestSelectionTool::deleteSelection() { + if (!mEditor) + return; + ForestDeleteUndoAction *action = new ForestDeleteUndoAction( mForest->getData(), mEditor ); for ( U32 i=0; i < mSelection.size(); i++ ) diff --git a/Engine/source/gfx/bitmap/gBitmap.cpp b/Engine/source/gfx/bitmap/gBitmap.cpp index e5ef6b407..019e92a57 100644 --- a/Engine/source/gfx/bitmap/gBitmap.cpp +++ b/Engine/source/gfx/bitmap/gBitmap.cpp @@ -327,7 +327,10 @@ void GBitmap::allocateBitmap(const U32 in_width, const U32 in_height, const bool mNumMipLevels++; allocPixels += currWidth * currHeight * mBytesPerPixel; - } while (currWidth != 1 && currHeight != 1); + } while (currWidth != 1 || currHeight != 1); + + U32 expectedMips = mFloor(mLog2(mMax(in_width, in_height))) + 1; + AssertFatal(mNumMipLevels == expectedMips, "GBitmap::allocateBitmap: mipmap count wrong"); } AssertFatal(mNumMipLevels <= c_maxMipLevels, "GBitmap::allocateBitmap: too many miplevels"); @@ -608,31 +611,31 @@ bool GBitmap::checkForTransparency() //------------------------------------------------------------------------------ ColorF GBitmap::sampleTexel(F32 u, F32 v) const { - ColorF col(0.5f, 0.5f, 0.5f); - // normally sampling wraps all the way around at 1.0, - // but locking doesn't support this, and we seem to calc - // the uv based on a clamped 0 - 1... - Point2F max((F32)(getWidth()-1), (F32)(getHeight()-1)); - Point2F posf; - posf.x = mClampF(((u) * max.x), 0.0f, max.x); - posf.y = mClampF(((v) * max.y), 0.0f, max.y); - Point2I posi((S32)posf.x, (S32)posf.y); + ColorF col(0.5f, 0.5f, 0.5f); + // normally sampling wraps all the way around at 1.0, + // but locking doesn't support this, and we seem to calc + // the uv based on a clamped 0 - 1... + Point2F max((F32)(getWidth()-1), (F32)(getHeight()-1)); + Point2F posf; + posf.x = mClampF(((u) * max.x), 0.0f, max.x); + posf.y = mClampF(((v) * max.y), 0.0f, max.y); + Point2I posi((S32)posf.x, (S32)posf.y); - const U8 *buffer = getBits(); - U32 lexelindex = ((posi.y * getWidth()) + posi.x) * mBytesPerPixel; + const U8 *buffer = getBits(); + U32 lexelindex = ((posi.y * getWidth()) + posi.x) * mBytesPerPixel; - if(mBytesPerPixel == 2) - { - //U16 *buffer = (U16 *)lockrect->pBits; - } - else if(mBytesPerPixel > 2) - { - col.red = F32(buffer[lexelindex + 0]) / 255.0f; + if(mBytesPerPixel == 2) + { + //U16 *buffer = (U16 *)lockrect->pBits; + } + else if(mBytesPerPixel > 2) + { + col.red = F32(buffer[lexelindex + 0]) / 255.0f; col.green = F32(buffer[lexelindex + 1]) / 255.0f; - col.blue = F32(buffer[lexelindex + 2]) / 255.0f; - } + col.blue = F32(buffer[lexelindex + 2]) / 255.0f; + } - return col; + return col; } //-------------------------------------------------------------------------- diff --git a/Engine/source/gfx/gfxTextureManager.cpp b/Engine/source/gfx/gfxTextureManager.cpp index b656fcffd..781e0daa2 100644 --- a/Engine/source/gfx/gfxTextureManager.cpp +++ b/Engine/source/gfx/gfxTextureManager.cpp @@ -1085,21 +1085,7 @@ void GFXTextureManager::_validateTexParams( const U32 width, const U32 height, // NOTE: Does this belong here? if( inOutNumMips == 0 && !autoGenSupp ) { - U32 currWidth = width; - U32 currHeight = height; - - inOutNumMips = 1; - do - { - currWidth >>= 1; - currHeight >>= 1; - if( currWidth == 0 ) - currWidth = 1; - if( currHeight == 0 ) - currHeight = 1; - - inOutNumMips++; - } while ( currWidth != 1 && currHeight != 1 ); + inOutNumMips = mFloor(mLog2(mMax(width, height))) + 1; } } } diff --git a/Engine/source/gfx/video/videoCapture.cpp b/Engine/source/gfx/video/videoCapture.cpp index 8f7b7e52e..a966bbe01 100644 --- a/Engine/source/gfx/video/videoCapture.cpp +++ b/Engine/source/gfx/video/videoCapture.cpp @@ -314,6 +314,9 @@ DefineEngineFunction( startVideoCapture, void, "@see stopVideoCapture\n" "@ingroup Rendering\n" ) { +#ifdef TORQUE_DEBUG + Con::errorf("Recording video is disabled in debug!"); +#else if ( !canvas ) { Con::errorf("startVideoCapture -Please specify a GuiCanvas object to record from!"); @@ -328,6 +331,7 @@ DefineEngineFunction( startVideoCapture, void, VIDCAP->setResolution(resolution); VIDCAP->begin(canvas); +#endif } DefineEngineFunction( stopVideoCapture, void, (),, diff --git a/Engine/source/math/mMathFn.h b/Engine/source/math/mMathFn.h index 1855656e7..93596f63f 100644 --- a/Engine/source/math/mMathFn.h +++ b/Engine/source/math/mMathFn.h @@ -320,6 +320,11 @@ inline F32 mLog(const F32 val) return (F32) log(val); } +inline F32 mLog2(const F32 val) +{ + return (F32) log2(val); +} + inline F32 mExp(const F32 val) { return (F32) exp(val); @@ -380,6 +385,10 @@ inline F64 mLog(const F64 val) return (F64) log(val); } +inline F64 mLog2(const F64 val) +{ + return (F64) log2(val); +} inline F32 mCatmullrom(F32 t, F32 p0, F32 p1, F32 p2, F32 p3) { diff --git a/Engine/source/platform/input/event.h b/Engine/source/platform/input/event.h index b77caa202..1c6d1f1dc 100644 --- a/Engine/source/platform/input/event.h +++ b/Engine/source/platform/input/event.h @@ -429,7 +429,7 @@ struct InputEventInfo U16 ascii; /// Modifiers to action: SI_LSHIFT, SI_LCTRL, etc. - InputModifiers modifier; + U32 modifier; inline void postToSignal(InputEvent &ie) { diff --git a/Engine/source/renderInstance/renderMeshMgr.cpp b/Engine/source/renderInstance/renderMeshMgr.cpp index 476c5e9b8..ce27a09c2 100644 --- a/Engine/source/renderInstance/renderMeshMgr.cpp +++ b/Engine/source/renderInstance/renderMeshMgr.cpp @@ -245,7 +245,7 @@ void RenderMeshMgr::render(SceneRenderState * state) if ( passRI->accuTex != lastAccuTex ) { sgData.accuTex = passRI->accuTex; - lastAccuTex = lastAccuTex; + lastAccuTex = passRI->accuTex; dirty = true; } diff --git a/Engine/source/renderInstance/renderParticleMgr.cpp b/Engine/source/renderInstance/renderParticleMgr.cpp index dcae9756c..ad0811f91 100644 --- a/Engine/source/renderInstance/renderParticleMgr.cpp +++ b/Engine/source/renderInstance/renderParticleMgr.cpp @@ -589,43 +589,51 @@ bool RenderParticleMgr::_initShader() void RenderParticleMgr::_onLMActivate( const char*, bool activate ) { - RenderPassManager *rpm = getRenderPass(); - if ( !rpm ) - return; - - // Hunt for the pre-pass manager/target - RenderPrePassMgr *prePassBin = NULL; - for( U32 i = 0; i < rpm->getManagerCount(); i++ ) + if ( activate ) { - RenderBinManager *bin = rpm->getManager(i); - if( bin->getRenderInstType() == RenderPrePassMgr::RIT_PrePass ) + RenderPassManager *rpm = getRenderPass(); + if ( !rpm ) + return; + + // Hunt for the pre-pass manager/target + RenderPrePassMgr *prePassBin = NULL; + for( U32 i = 0; i < rpm->getManagerCount(); i++ ) { - prePassBin = (RenderPrePassMgr*)bin; - break; + RenderBinManager *bin = rpm->getManager(i); + if( bin->getRenderInstType() == RenderPrePassMgr::RIT_PrePass ) + { + prePassBin = (RenderPrePassMgr*)bin; + break; + } } - } - // If we found the prepass bin, set this bin to render very shortly afterwards - // and re-add this render-manager. If there is no pre-pass bin, or it doesn't - // have a depth-texture, we can't render offscreen. - mOffscreenRenderEnabled = prePassBin && (prePassBin->getTargetChainLength() > 0); - if(mOffscreenRenderEnabled) - { - rpm->removeManager(this); - setRenderOrder( prePassBin->getRenderOrder() + 0.011f ); - rpm->addManager(this); - } + // If we found the prepass bin, set this bin to render very shortly afterwards + // and re-add this render-manager. If there is no pre-pass bin, or it doesn't + // have a depth-texture, we can't render offscreen. + mOffscreenRenderEnabled = prePassBin && (prePassBin->getTargetChainLength() > 0); + if(mOffscreenRenderEnabled) + { + rpm->removeManager(this); + setRenderOrder( prePassBin->getRenderOrder() + 0.011f ); + rpm->addManager(this); + } - // Find the targets we use - mPrepassTarget = NamedTexTarget::find( "prepass" ); - mEdgeTarget = NamedTexTarget::find( "edge" ); + // Find the targets we use + mPrepassTarget = NamedTexTarget::find( "prepass" ); + mEdgeTarget = NamedTexTarget::find( "edge" ); - // Setup the shader - if ( activate ) + // Setup the shader _initShader(); - if ( mScreenQuadVertBuff.isNull() ) - _initGFXResources(); + if ( mScreenQuadVertBuff.isNull() ) + _initGFXResources(); + } + else + { + mStencilClearSB = NULL; + mScreenQuadPrimBuff = NULL; + mScreenQuadVertBuff = NULL; + } } GFXStateBlockRef RenderParticleMgr::_getOffscreenStateBlock(ParticleRenderInst *ri) diff --git a/Engine/source/renderInstance/renderPassManager.cpp b/Engine/source/renderInstance/renderPassManager.cpp index f620a627b..3ed2671dc 100644 --- a/Engine/source/renderInstance/renderPassManager.cpp +++ b/Engine/source/renderInstance/renderPassManager.cpp @@ -124,6 +124,7 @@ RenderPassManager::RenderBinEventSignal& RenderPassManager::getRenderBinSignal() void RenderPassManager::initPersistFields() { + Parent::initPersistFields(); } RenderPassManager::RenderPassManager() diff --git a/Engine/source/renderInstance/renderPrePassMgr.cpp b/Engine/source/renderInstance/renderPrePassMgr.cpp index 81f8782eb..88accf3c7 100644 --- a/Engine/source/renderInstance/renderPrePassMgr.cpp +++ b/Engine/source/renderInstance/renderPrePassMgr.cpp @@ -480,7 +480,7 @@ void RenderPrePassMgr::render( SceneRenderState *state ) if (passRI->accuTex != lastAccuTex) { sgData.accuTex = passRI->accuTex; - lastAccuTex = lastAccuTex; + lastAccuTex = passRI->accuTex; dirty = true; } diff --git a/Engine/source/windowManager/sdl/sdlSplashScreen.cpp b/Engine/source/windowManager/sdl/sdlSplashScreen.cpp index bf0931a9c..9a508951b 100644 --- a/Engine/source/windowManager/sdl/sdlSplashScreen.cpp +++ b/Engine/source/windowManager/sdl/sdlSplashScreen.cpp @@ -22,7 +22,7 @@ #include "platform/platform.h" #include "console/console.h" - +#include "gfx/bitmap/gBitmap.h" #include "SDL.h" #include "windowManager/sdl/sdlWindow.h" @@ -36,7 +36,52 @@ bool Platform::displaySplashWindow( String path ) if(path.isEmpty()) return false; - gSplashImage = SDL_LoadBMP(path); + Torque::Path iconPath = Torque::Path(path); + + if (iconPath.getExtension() == String("bmp")) + { + Con::errorf("Unable to use bmp format images for the splash screen. Please use a different format."); + return false; + } + + Resource img = GBitmap::load(iconPath); + if (img != NULL) + { + U32 pitch; + U32 width = img->getWidth(); + bool hasAlpha = img->getHasTransparency(); + U32 depth; + + if (hasAlpha) + { + pitch = 4 * width; + depth = 32; + } + else + { + pitch = 3 * width; + depth = 24; + } + + Uint32 rmask, gmask, bmask, amask; + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + { + S32 shift = hasAlpha ? 8 : 0; + rmask = 0xff000000 >> shift; + gmask = 0x00ff0000 >> shift; + bmask = 0x0000ff00 >> shift; + amask = 0x000000ff >> shift; + } + else + { + rmask = 0x000000ff; + gmask = 0x0000ff00; + bmask = 0x00ff0000; + amask = hasAlpha ? 0xff000000 : 0; + } + + gSplashImage = SDL_CreateRGBSurfaceFrom(img->getAddress(0, 0), img->getWidth(), img->getHeight(), depth, pitch, rmask, gmask, bmask, amask); + } //now the pop-up window if (gSplashImage) @@ -53,7 +98,7 @@ bool Platform::displaySplashWindow( String path ) SDL_RenderPresent(gSplashRenderer); } - return true; + return true; } bool Platform::closeSplashWindow() diff --git a/Engine/source/windowManager/sdl/sdlWindow.cpp b/Engine/source/windowManager/sdl/sdlWindow.cpp index 510834fca..a48e3743d 100644 --- a/Engine/source/windowManager/sdl/sdlWindow.cpp +++ b/Engine/source/windowManager/sdl/sdlWindow.cpp @@ -51,23 +51,41 @@ namespace { U32 ret = 0; - if(mod & KMOD_LSHIFT) - ret |= IM_LSHIFT; + if (mod & KMOD_LSHIFT) + { + ret |= SI_LSHIFT; + ret |= SI_SHIFT; + } - if(mod & KMOD_RSHIFT) - ret |= IM_RSHIFT; + if (mod & KMOD_RSHIFT) + { + ret |= SI_RSHIFT; + ret |= SI_SHIFT; + } - if(mod & KMOD_LCTRL) - ret |= IM_LCTRL; + if (mod & KMOD_LCTRL) + { + ret |= SI_LCTRL; + ret |= SI_CTRL; + } - if(mod & KMOD_RCTRL) - ret |= IM_RCTRL; + if (mod & KMOD_RCTRL) + { + ret |= SI_RCTRL; + ret |= SI_CTRL; + } - if(mod & KMOD_LALT) - ret |= IM_LALT; + if (mod & KMOD_LALT) + { + ret |= SI_LALT; + ret |= SI_ALT; + } - if(mod & KMOD_RALT) - ret |= IM_RALT; + if (mod & KMOD_RALT) + { + ret |= SI_RALT; + ret |= SI_ALT; + } return ret; } @@ -86,37 +104,37 @@ mShouldLockMouse(false), mSuppressReset(false), mMenuHandle(NULL) { - mCursorController = new PlatformCursorControllerSDL( this ); + mCursorController = new PlatformCursorControllerSDL( this ); - mVideoMode.bitDepth = 32; - mVideoMode.fullScreen = false; - mVideoMode.refreshRate = 60; - mVideoMode.resolution.set(800,600); + mVideoMode.bitDepth = 32; + mVideoMode.fullScreen = false; + mVideoMode.refreshRate = 60; + mVideoMode.resolution.set(800,600); } PlatformWindowSDL::~PlatformWindowSDL() { - // delete our sdl handle.. - SDL_DestroyWindow(mWindowHandle); + // delete our sdl handle.. + SDL_DestroyWindow(mWindowHandle); - // unlink ourselves from the window list... - AssertFatal(mOwningManager, "PlatformWindowSDL::~PlatformWindowSDL - orphan window, cannot unlink!"); - mOwningManager->unlinkWindow(this); + // unlink ourselves from the window list... + AssertFatal(mOwningManager, "PlatformWindowSDL::~PlatformWindowSDL - orphan window, cannot unlink!"); + mOwningManager->unlinkWindow(this); } GFXDevice * PlatformWindowSDL::getGFXDevice() { - return mDevice; + return mDevice; } GFXWindowTarget * PlatformWindowSDL::getGFXTarget() { - return mTarget; + return mTarget; } const GFXVideoMode & PlatformWindowSDL::getVideoMode() { - return mVideoMode; + return mVideoMode; } void* PlatformWindowSDL::getSystemWindow(const WindowSystem system) @@ -144,41 +162,41 @@ void PlatformWindowSDL::setVideoMode( const GFXVideoMode &mode ) mVideoMode = mode; mSuppressReset = true; - // Set our window to have the right style based on the mode + // Set our window to have the right style based on the mode if(mode.fullScreen && !Platform::getWebDeployment() && !mOffscreenRender) - { + { setSize(mode.resolution); SDL_SetWindowFullscreen( mWindowHandle, SDL_WINDOW_FULLSCREEN); // When switching to Fullscreen, reset device after setting style - if(mTarget.isValid()) - mTarget->resetMode(); - } - else - { + if(mTarget.isValid()) + mTarget->resetMode(); + } + else + { // Reset device *first*, so that when we call setSize() and let it - // access the monitor settings, it won't end up with our fullscreen - // geometry that is just about to change. + // access the monitor settings, it won't end up with our fullscreen + // geometry that is just about to change. - if(mTarget.isValid()) - mTarget->resetMode(); + if(mTarget.isValid()) + mTarget->resetMode(); if (!mOffscreenRender) { - SDL_SetWindowFullscreen( mWindowHandle, 0); + SDL_SetWindowFullscreen( mWindowHandle, 0); } setSize(mode.resolution); centerWindow(); - } + } - mSuppressReset = false; + mSuppressReset = false; } bool PlatformWindowSDL::clearFullscreen() { - return true; + return true; } bool PlatformWindowSDL::isFullscreen() @@ -192,32 +210,32 @@ bool PlatformWindowSDL::isFullscreen() void PlatformWindowSDL::_setFullscreen(const bool fullscreen) { - if( isFullscreen() ) - return; + if( isFullscreen() ) + return; - if(fullscreen && !mOffscreenRender) - { - Con::printf("PlatformWindowSDL::setFullscreen (full) enter"); - SDL_SetWindowFullscreen( mWindowHandle, SDL_WINDOW_FULLSCREEN); - } - else - { - Con::printf("PlatformWindowSDL::setFullscreen (windowed) enter"); + if(fullscreen && !mOffscreenRender) + { + Con::printf("PlatformWindowSDL::setFullscreen (full) enter"); + SDL_SetWindowFullscreen( mWindowHandle, SDL_WINDOW_FULLSCREEN); + } + else + { + Con::printf("PlatformWindowSDL::setFullscreen (windowed) enter"); if (!mOffscreenRender) { - SDL_SetWindowFullscreen( mWindowHandle, SDL_WINDOW_FULLSCREEN_DESKTOP); + SDL_SetWindowFullscreen( mWindowHandle, SDL_WINDOW_FULLSCREEN_DESKTOP); } setSize(mVideoMode.resolution); - } - Con::printf("PlatformWindowSDL::setFullscreen exit"); + } + Con::printf("PlatformWindowSDL::setFullscreen exit"); } bool PlatformWindowSDL::setCaption( const char *cap ) { SDL_SetWindowTitle(mWindowHandle, cap); - return true; + return true; } const char * PlatformWindowSDL::getCaption() @@ -232,45 +250,45 @@ void PlatformWindowSDL::setFocus() void PlatformWindowSDL::setClientExtent( const Point2I newExtent ) { - Point2I oldExtent = getClientExtent(); - if (oldExtent == newExtent) - return; + Point2I oldExtent = getClientExtent(); + if (oldExtent == newExtent) + return; SDL_SetWindowSize(mWindowHandle, newExtent.x, newExtent.y); } const Point2I PlatformWindowSDL::getClientExtent() { - // Fetch Client Rect from Windows + // Fetch Client Rect from Windows Point2I size; - SDL_GetWindowSize(mWindowHandle, &size.x, &size.y); + SDL_GetWindowSize(mWindowHandle, &size.x, &size.y); - return size; + return size; } void PlatformWindowSDL::setBounds( const RectI &newBounds ) { - // TODO SDL + // TODO SDL } const RectI PlatformWindowSDL::getBounds() const { - // TODO SDL - return RectI(0, 0, 0, 0); + // TODO SDL + return RectI(0, 0, 0, 0); } void PlatformWindowSDL::setPosition( const Point2I newPosition ) { - SDL_SetWindowPosition( mWindowHandle, newPosition.x, newPosition.y ); + SDL_SetWindowPosition( mWindowHandle, newPosition.x, newPosition.y ); } const Point2I PlatformWindowSDL::getPosition() { - Point2I position; - SDL_GetWindowPosition( mWindowHandle, &position.x, &position.y ); + Point2I position; + SDL_GetWindowPosition( mWindowHandle, &position.x, &position.y ); - // Return position - return position; + // Return position + return position; } Point2I PlatformWindowSDL::clientToScreen( const Point2I& pos ) @@ -293,7 +311,7 @@ void PlatformWindowSDL::centerWindow() SDL_GetWindowSize(mWindowHandle, &sizeX, &sizeY); SDL_DisplayMode mode; - SDL_GetDesktopDisplayMode(0, &mode); + SDL_GetDesktopDisplayMode(0, &mode); U32 posX = (mode.w/2) - (sizeX/2); U32 posY = (mode.h/2) - (sizeY/2); @@ -307,21 +325,21 @@ bool PlatformWindowSDL::setSize( const Point2I &newSize ) // Let GFX get an update about the new resolution if (mTarget.isValid()) - mTarget->resetMode(); + mTarget->resetMode(); - return true; + return true; } bool PlatformWindowSDL::isOpen() { - return mWindowHandle; + return mWindowHandle; } bool PlatformWindowSDL::isVisible() { - // Is the window open and visible, ie. not minimized? - if(!mWindowHandle) - return false; + // Is the window open and visible, ie. not minimized? + if(!mWindowHandle) + return false; if (mOffscreenRender) return true; @@ -330,7 +348,7 @@ bool PlatformWindowSDL::isVisible() if( flags & SDL_WINDOW_SHOWN) return true; - return false; + return false; } bool PlatformWindowSDL::isFocused() @@ -371,7 +389,7 @@ bool PlatformWindowSDL::isMaximized() WindowId PlatformWindowSDL::getWindowId() { - return mWindowId; + return mWindowId; } void PlatformWindowSDL::minimize() @@ -379,7 +397,7 @@ void PlatformWindowSDL::minimize() if (mOffscreenRender) return; - SDL_MinimizeWindow( mWindowHandle ); + SDL_MinimizeWindow( mWindowHandle ); } void PlatformWindowSDL::maximize() @@ -387,7 +405,7 @@ void PlatformWindowSDL::maximize() if (mOffscreenRender) return; - SDL_MaximizeWindow( mWindowHandle ); + SDL_MaximizeWindow( mWindowHandle ); } void PlatformWindowSDL::restore() @@ -395,7 +413,7 @@ void PlatformWindowSDL::restore() if (mOffscreenRender) return; - SDL_RestoreWindow( mWindowHandle ); + SDL_RestoreWindow( mWindowHandle ); } void PlatformWindowSDL::hide() @@ -403,7 +421,7 @@ void PlatformWindowSDL::hide() if (mOffscreenRender) return; - SDL_HideWindow( mWindowHandle ); + SDL_HideWindow( mWindowHandle ); } void PlatformWindowSDL::show() @@ -411,17 +429,17 @@ void PlatformWindowSDL::show() if (mOffscreenRender) return; - SDL_ShowWindow( mWindowHandle ); + SDL_ShowWindow( mWindowHandle ); } void PlatformWindowSDL::close() { - delete this; + delete this; } void PlatformWindowSDL::defaultRender() { - // TODO SDL + // TODO SDL } void PlatformWindowSDL::_triggerMouseLocationNotify(const SDL_Event& evt) @@ -597,7 +615,7 @@ void PlatformWindowSDL::setMouseLocked( bool enable ) if (mOffscreenRender) return; - mMouseLocked = enable; + mMouseLocked = enable; SDL_SetWindowGrab( mWindowHandle, SDL_bool(enable) ); SDL_SetRelativeMouseMode( SDL_bool(enable) ); diff --git a/Engine/source/windowManager/sdl/sdlWindowMgr.cpp b/Engine/source/windowManager/sdl/sdlWindowMgr.cpp index 9dbe1708d..489377082 100644 --- a/Engine/source/windowManager/sdl/sdlWindowMgr.cpp +++ b/Engine/source/windowManager/sdl/sdlWindowMgr.cpp @@ -24,6 +24,7 @@ #include "gfx/gfxDevice.h" #include "core/util/journal/process.h" #include "core/strings/unicode.h" +#include "gfx/bitmap/gBitmap.h" #include "SDL.h" @@ -165,6 +166,59 @@ PlatformWindow *PlatformWindowManagerSDL::createWindow(GFXDevice *device, const window->mOwningManager = this; mWindowMap[ window->mWindowId ] = window; + //Now, fetch our window icon, if any + Torque::Path iconPath = Torque::Path(Con::getVariable( "$Core::windowIcon" )); + + if (iconPath.getExtension() == String("bmp")) + { + Con::errorf("Unable to use bmp format images for the window icon. Please use a different format."); + } + else + { + Resource img = GBitmap::load(iconPath); + if (img != NULL) + { + U32 pitch; + U32 width = img->getWidth(); + bool hasAlpha = img->getHasTransparency(); + U32 depth; + + if (hasAlpha) + { + pitch = 4 * width; + depth = 32; + } + else + { + pitch = 3 * width; + depth = 24; + } + + Uint32 rmask, gmask, bmask, amask; + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + { + S32 shift = hasAlpha ? 8 : 0; + rmask = 0xff000000 >> shift; + gmask = 0x00ff0000 >> shift; + bmask = 0x0000ff00 >> shift; + amask = 0x000000ff >> shift; + } + else + { + rmask = 0x000000ff; + gmask = 0x0000ff00; + bmask = 0x00ff0000; + amask = hasAlpha ? 0xff000000 : 0; + } + + SDL_Surface* iconSurface = SDL_CreateRGBSurfaceFrom(img->getAddress(0, 0), img->getWidth(), img->getHeight(), depth, pitch, rmask, gmask, bmask, amask); + + SDL_SetWindowIcon(window->mWindowHandle, iconSurface); + + SDL_FreeSurface(iconSurface); + } + } + if(device) { window->mDevice = device; diff --git a/Engine/source/windowManager/windowInputGenerator.cpp b/Engine/source/windowManager/windowInputGenerator.cpp index c31bad1ba..6c9e45b71 100644 --- a/Engine/source/windowManager/windowInputGenerator.cpp +++ b/Engine/source/windowManager/windowInputGenerator.cpp @@ -95,7 +95,7 @@ void WindowInputGenerator::generateInputEvent( InputEventInfo &inputEvent ) { const AccKeyMap &acc = mAcceleratorMap[i]; if (!mWindow->getKeyboardTranslation() && - (acc.modifier & inputEvent.modifier || (acc.modifier == 0 && inputEvent.modifier == 0)) + ((acc.modifier == inputEvent.modifier && acc.modifier != 0) || (acc.modifier == 0 && inputEvent.modifier == 0)) && acc.keyCode == inputEvent.objInst) { Con::evaluatef(acc.cmd); @@ -145,7 +145,11 @@ void WindowInputGenerator::handleMouseMove( WindowId did, U32 modifier, S32 x, S event.deviceType = MouseDeviceType; event.deviceInst = 0; event.objType = SI_AXIS; - event.modifier = convertModifierBits(modifier); +#ifdef TORQUE_SDL + event.modifier = modifier; +#else + event.modifier = convertModifierBits(modifier); +#endif event.ascii = 0; // Generate delta movement along each axis @@ -231,7 +235,11 @@ void WindowInputGenerator::handleMouseButton( WindowId did, U32 modifiers, U32 a event.deviceInst = 0; event.objType = SI_BUTTON; event.objInst = (InputObjectInstances)(KEY_BUTTON0 + button); - event.modifier = convertModifierBits(modifiers); +#ifdef TORQUE_SDL + event.modifier = modifiers; +#else + event.modifier = convertModifierBits(modifiers); +#endif event.ascii = 0; event.action = (action==IA_MAKE) ? SI_MAKE : SI_BREAK; event.fValue = (action==IA_MAKE) ? 1.0 : 0.0; @@ -248,7 +256,11 @@ void WindowInputGenerator::handleMouseWheel( WindowId did, U32 modifiers, S32 wh event.deviceType = MouseDeviceType; event.deviceInst = 0; event.objType = SI_AXIS; - event.modifier = convertModifierBits(modifiers); +#ifdef TORQUE_SDL + event.modifier = modifiers; +#else + event.modifier = convertModifierBits(modifiers); +#endif event.ascii = 0; event.action = SI_MOVE; @@ -281,7 +293,11 @@ void WindowInputGenerator::handleCharInput( WindowId did, U32 modifier, U16 key event.deviceInst = 0; event.objType = SI_KEY; event.objInst = KEY_NULL; - event.modifier = convertModifierBits(modifier); +#ifdef TORQUE_SDL + event.modifier = modifier; +#else + event.modifier = convertModifierBits(modifier); +#endif event.ascii = key; event.action = SI_MAKE; event.fValue = 1.0; @@ -303,7 +319,11 @@ void WindowInputGenerator::handleKeyboard( WindowId did, U32 modifier, U32 actio event.deviceInst = 0; event.objType = SI_KEY; event.objInst = (InputObjectInstances)key; - event.modifier = convertModifierBits(modifier); +#ifdef TORQUE_SDL + event.modifier = modifier; +#else + event.modifier = convertModifierBits(modifier); +#endif event.ascii = 0; switch(action) diff --git a/Templates/Empty/game/art/gui/mainMenuGui.gui b/Templates/Empty/game/art/gui/mainMenuGui.gui index e9d575093..212944c56 100644 --- a/Templates/Empty/game/art/gui/mainMenuGui.gui +++ b/Templates/Empty/game/art/gui/mainMenuGui.gui @@ -106,7 +106,7 @@ profile = "GuiMenuButtonProfile"; visible = "1"; active = "1"; - command = "GuiEdit();"; + command = "toggleGuiEditor(1);"; tooltipProfile = "GuiToolTipProfile"; tooltip = "The GUI Editor is accessible in-game by pressing F10"; hovertime = "1000"; diff --git a/Templates/Empty/game/art/gui/splash.bmp b/Templates/Empty/game/art/gui/splash.bmp deleted file mode 100644 index 47cb47f97..000000000 Binary files a/Templates/Empty/game/art/gui/splash.bmp and /dev/null differ diff --git a/Templates/Empty/game/art/gui/splash.png b/Templates/Empty/game/art/gui/splash.png new file mode 100644 index 000000000..333df9eb3 Binary files /dev/null and b/Templates/Empty/game/art/gui/splash.png differ diff --git a/Templates/Empty/game/core/scripts/client/screenshot.cs b/Templates/Empty/game/core/scripts/client/screenshot.cs index 897325a1a..3c78aa2cd 100644 --- a/Templates/Empty/game/core/scripts/client/screenshot.cs +++ b/Templates/Empty/game/core/scripts/client/screenshot.cs @@ -55,6 +55,9 @@ function formatSessionNumber(%number) // Records a movie file from the Canvas content using the specified fps. // Possible encoder values are "PNG" and "THEORA" (default). //--------------------------------------------------------------------------------------------- + +$RecordingMovie = false; + function recordMovie(%movieName, %fps, %encoder) { // If the canvas doesn't exist yet, setup a flag so it'll @@ -65,12 +68,24 @@ function recordMovie(%movieName, %fps, %encoder) if (%encoder $= "") %encoder = "THEORA"; %resolution = Canvas.getVideoMode(); + + // Start the movie recording + ChatHud.AddLine( "\c4Recording movie file to [\c2" @ %movieName @ "\cr].ogv."); + echo("Recording movie to: " @ %movieName); startVideoCapture(Canvas, %movieName, %encoder, %fps); + + $RecordingMovie = true; } function stopMovie() { + // Stop the current recording + ChatHud.AddLine( "\c4Recording movie file finished."); + echo("Stopped movie recording"); + stopVideoCapture(); + + $RecordingMovie = false; } /// This is bound in initializeCommon() to take diff --git a/Templates/Empty/game/core/torque.png b/Templates/Empty/game/core/torque.png new file mode 100644 index 000000000..1023f2bb6 Binary files /dev/null and b/Templates/Empty/game/core/torque.png differ diff --git a/Templates/Empty/game/main.cs b/Templates/Empty/game/main.cs index 22a3ab2ff..44b333b87 100644 --- a/Templates/Empty/game/main.cs +++ b/Templates/Empty/game/main.cs @@ -28,6 +28,8 @@ $defaultGame = "scripts"; // Set profile directory $Pref::Video::ProfilePath = "core/profile"; +$Core::windowIcon = "core/torque.png"; +$Core::splashWindowImage = "art/gui/splash.png"; function createCanvas(%windowTitle) { diff --git a/Templates/Empty/game/scripts/client/default.bind.cs b/Templates/Empty/game/scripts/client/default.bind.cs index 51dc53d4b..b4216a33d 100644 --- a/Templates/Empty/game/scripts/client/default.bind.cs +++ b/Templates/Empty/game/scripts/client/default.bind.cs @@ -409,6 +409,49 @@ function stopRecordingDemo( %val ) moveMap.bind( keyboard, F3, startRecordingDemo ); moveMap.bind( keyboard, F4, stopRecordingDemo ); +//------------------------------------------------------------------------------ +// Theora Video Capture (Records a movie file) +//------------------------------------------------------------------------------ + +function toggleMovieRecording(%val) +{ + if (!%val) + return; + + %movieEncodingType = "THEORA"; // Valid encoder values are "PNG" and "THEORA" (default). + %movieFPS = 30; // video capture frame rate. + + if (!$RecordingMovie) + { + // locate a non-existent filename to use + for(%i = 0; %i < 1000; %i++) + { + %num = %i; + if(%num < 10) + %num = "0" @ %num; + if(%num < 100) + %num = "0" @ %num; + + %filePath = "movies/movie" @ %num; + if(!isfile(%filePath)) + break; + } + if(%i == 1000) + return; + + // Start the movie recording + recordMovie(%filePath, %movieFPS, %movieEncodingType); + + } + else + { + // Stop the current recording + stopMovie(); + } +} + +// Key binding works at any time and not just while in a game. +GlobalActionMap.bind(keyboard, "alt m", toggleMovieRecording); //------------------------------------------------------------------------------ // Helper Functions diff --git a/Templates/Empty/game/tools/base/utils/inspector.ed.cs b/Templates/Empty/game/tools/base/utils/inspector.ed.cs index 9df8c7e98..f7c27ecf0 100644 --- a/Templates/Empty/game/tools/base/utils/inspector.ed.cs +++ b/Templates/Empty/game/tools/base/utils/inspector.ed.cs @@ -105,7 +105,7 @@ function EditorInspectorBase::onAdd( %this ) superClass = "MenuBuilder"; isPopup = true; - item[ 0 ] = "Edit Profile" TAB "" TAB "if( !$InGuiEditor ) toggleGuiEditor( true ); GuiEditor.editProfile( %this.inspectorField.getData() );"; + item[ 0 ] = "Edit Profile" TAB "" TAB "if( !GuiEditorIsActive() ) toggleGuiEditor( true ); GuiEditor.editProfile( %this.inspectorField.getData() );"; item[ 1 ] = "Jump to Definition in Torsion" TAB "" TAB "EditorOpenDeclarationInTorsion( %this.inspectorField.getData() );"; item[ 2 ] = "Inspect Object" TAB "" TAB "inspectObject( %this.inspectorField.getData() );"; item[ 3 ] = "-"; diff --git a/Templates/Empty/game/tools/forestEditor/forestEditorGui.gui b/Templates/Empty/game/tools/forestEditor/forestEditorGui.gui index ca40147bf..e46a09f3d 100644 --- a/Templates/Empty/game/tools/forestEditor/forestEditorGui.gui +++ b/Templates/Empty/game/tools/forestEditor/forestEditorGui.gui @@ -252,7 +252,7 @@ objectNamesOnly = "1"; useInspectorTooltips = "0"; tooltipOnWidthOnly = "0"; - compareToObjectID = "1"; + compareToObjectID = "0"; canRenameObjects = "1"; renameInternal = "0"; isContainer = "1"; diff --git a/Templates/Empty/game/tools/guiEditor/gui/guiEditor.ed.gui b/Templates/Empty/game/tools/guiEditor/gui/guiEditor.ed.gui index e387f1bc0..cc03cbd07 100644 --- a/Templates/Empty/game/tools/guiEditor/gui/guiEditor.ed.gui +++ b/Templates/Empty/game/tools/guiEditor/gui/guiEditor.ed.gui @@ -86,7 +86,7 @@ minExtent = "8 8"; canSave = "1"; visible = "1"; - command = "GuiEditor.switchToWorldEditor();"; + command = "toggleEditor(1);"; tooltipProfile = "ToolsGuiToolTipProfile"; ToolTip = "World Editor"; hovertime = "1000"; diff --git a/Templates/Empty/game/tools/guiEditor/scripts/guiEditor.ed.cs b/Templates/Empty/game/tools/guiEditor/scripts/guiEditor.ed.cs index eace7d43b..61dc8c5e7 100644 --- a/Templates/Empty/game/tools/guiEditor/scripts/guiEditor.ed.cs +++ b/Templates/Empty/game/tools/guiEditor/scripts/guiEditor.ed.cs @@ -75,11 +75,26 @@ function toggleGuiEditor( %make ) if( EditorIsActive() && !GuiEditor.toggleIntoEditorGui ) toggleEditor( true ); - GuiEdit(); + if( !isObject( GuiEditCanvas ) ) + new GuiControl( GuiEditCanvas, EditorGuiGroup ); - // Cancel the scheduled event to prevent - // the level from cycling after it's duration - // has elapsed. + if( GuiEditorIsActive() ) + { + GuiEditor.close(); + } + else + { + GuiEditor.open(); + + // Cancel the scheduled event to prevent + // the level from cycling after it's duration + // has elapsed. + cancel($Game::Schedule); + } + + // Cancel the scheduled event to prevent + // the level from cycling after it's duration + // has elapsed. cancel($Game::Schedule); } } @@ -98,6 +113,26 @@ package GuiEditor_BlockDialogs //--------------------------------------------------------------------------------------------- +function GuiEditor::open(%this) +{ + GuiEditCanvas.onCreateMenu(); + + GuiEditContent(Canvas.getContent()); +} + +function GuiEditor::close(%this) +{ + // prevent the mission editor from opening while the GuiEditor is open. + if(Canvas.getContent() != GuiEditorGui.getId()) + return; + + GuiGroup.add(GuiEditorGui); + + Canvas.setContent(GuiEditor.lastContent); + + GuiEditCanvas.onDestroyMenu(); +} + function GuiEditor::openForEditing( %this, %content ) { Canvas.setContent( GuiEditorGui ); diff --git a/Templates/Empty/game/tools/worldEditor/gui/EditorGui.ed.gui b/Templates/Empty/game/tools/worldEditor/gui/EditorGui.ed.gui index 445bacf63..3eb8558e4 100644 --- a/Templates/Empty/game/tools/worldEditor/gui/EditorGui.ed.gui +++ b/Templates/Empty/game/tools/worldEditor/gui/EditorGui.ed.gui @@ -67,7 +67,7 @@ MinExtent = "8 8"; canSave = "1"; Visible = "1"; - Command = "toggleEditor( true ); GuiEdit(); $GuiEditorBtnPressed = true;"; + Command = "toggleGuiEditor(true); $GuiEditorBtnPressed = true;"; tooltipprofile = "ToolsGuiToolTipProfile"; ToolTip = "Open the GuiEditor"; hovertime = "1000"; diff --git a/Templates/Empty/game/tools/worldEditor/scripts/EditorGui.ed.cs b/Templates/Empty/game/tools/worldEditor/scripts/EditorGui.ed.cs index 38a180e64..31f794d17 100644 --- a/Templates/Empty/game/tools/worldEditor/scripts/EditorGui.ed.cs +++ b/Templates/Empty/game/tools/worldEditor/scripts/EditorGui.ed.cs @@ -35,8 +35,6 @@ function EditorGui::init(%this) $NextOperationId = 1; $HeightfieldDirtyRow = -1; - %this.buildMenus(); - if( !isObject( %this-->ToolsPaletteWindow ) ) { // Load Creator/Inspector GUI @@ -1914,6 +1912,8 @@ function Editor::open(%this) if(Canvas.getContent() == GuiEditorGui.getId()) return; + EditorGui.buildMenus(); + if( !EditorGui.isInitialized ) EditorGui.init(); @@ -1929,6 +1929,21 @@ function Editor::close(%this, %gui) if(isObject(MessageHud)) MessageHud.close(); EditorGui.writeCameraSettings(); + + EditorGui.onDestroyMenu(); +} + +function EditorGui::onDestroyMenu(%this) +{ + if( !isObject( %this.menuBar ) ) + return; + + // Destroy menus + while( %this.menuBar.getCount() != 0 ) + %this.menuBar.getObject( 0 ).delete(); + + %this.menuBar.removeFromCanvas(); + %this.menuBar.delete(); } $RelightCallback = ""; diff --git a/Templates/Empty/game/tools/worldEditor/scripts/editor.ed.cs b/Templates/Empty/game/tools/worldEditor/scripts/editor.ed.cs index 74b34e0a9..8545c9d67 100644 --- a/Templates/Empty/game/tools/worldEditor/scripts/editor.ed.cs +++ b/Templates/Empty/game/tools/worldEditor/scripts/editor.ed.cs @@ -99,18 +99,12 @@ function Editor::checkActiveLoadDone() //------------------------------------------------------------------------------ function toggleEditor(%make) { - if (Canvas.isFullscreen()) - { - MessageBoxOK("Windowed Mode Required", "Please switch to windowed mode to access the Mission Editor."); - return; - } - if (%make) - { + { %timerId = startPrecisionTimer(); - if( $InGuiEditor ) - GuiEdit(); + if( GuiEditorIsActive() ) + toggleGuiEditor(1); if( !$missionRunning ) { @@ -141,29 +135,21 @@ function toggleEditor(%make) Editor.close("PlayGui"); } } - else + else { - if ( !$GuiEditorBtnPressed ) - { - canvas.pushDialog( EditorLoadingGui ); - canvas.repaint(); - } - else - { - $GuiEditorBtnPressed = false; - } + canvas.pushDialog( EditorLoadingGui ); + canvas.repaint(); Editor.open(); - // Cancel the scheduled event to prevent - // the level from cycling after it's duration - // has elapsed. + // Cancel the scheduled event to prevent + // the level from cycling after it's duration + // has elapsed. cancel($Game::Schedule); if (theLevelInfo.type $= "DemoScene") commandToServer('dropCameraAtPlayer', true); - canvas.popDialog(EditorLoadingGui); } diff --git a/Templates/Empty/game/tools/worldEditor/scripts/menus.ed.cs b/Templates/Empty/game/tools/worldEditor/scripts/menus.ed.cs index b6c4200d4..be068b9ed 100644 --- a/Templates/Empty/game/tools/worldEditor/scripts/menus.ed.cs +++ b/Templates/Empty/game/tools/worldEditor/scripts/menus.ed.cs @@ -42,47 +42,59 @@ function EditorGui::buildMenus(%this) } // Sub menus (temporary, until MenuBuilder gets updated) - // The speed increments located here are overwritten in EditorCameraSpeedMenu::setupDefaultState. - // The new min/max for the editor camera speed range can be set in each level's levelInfo object. - %this.cameraSpeedMenu = new PopupMenu(EditorCameraSpeedOptions) + // The speed increments located here are overwritten in EditorCameraSpeedMenu::setupDefaultState. + // The new min/max for the editor camera speed range can be set in each level's levelInfo object. + if(!isObject(EditorCameraSpeedOptions)) { - superClass = "MenuBuilder"; - class = "EditorCameraSpeedMenu"; - - item[0] = "Slowest" TAB %cmdCtrl @ "-Shift 1" TAB "5"; - item[1] = "Slow" TAB %cmdCtrl @ "-Shift 2" TAB "35"; - item[2] = "Slower" TAB %cmdCtrl @ "-Shift 3" TAB "70"; - item[3] = "Normal" TAB %cmdCtrl @ "-Shift 4" TAB "100"; - item[4] = "Faster" TAB %cmdCtrl @ "-Shift 5" TAB "130"; - item[5] = "Fast" TAB %cmdCtrl @ "-Shift 6" TAB "165"; - item[6] = "Fastest" TAB %cmdCtrl @ "-Shift 7" TAB "200"; - }; - %this.freeCameraTypeMenu = new PopupMenu(EditorFreeCameraTypeOptions) + %this.cameraSpeedMenu = new PopupMenu(EditorCameraSpeedOptions) + { + superClass = "MenuBuilder"; + class = "EditorCameraSpeedMenu"; + + item[0] = "Slowest" TAB %cmdCtrl @ "-Shift 1" TAB "5"; + item[1] = "Slow" TAB %cmdCtrl @ "-Shift 2" TAB "35"; + item[2] = "Slower" TAB %cmdCtrl @ "-Shift 3" TAB "70"; + item[3] = "Normal" TAB %cmdCtrl @ "-Shift 4" TAB "100"; + item[4] = "Faster" TAB %cmdCtrl @ "-Shift 5" TAB "130"; + item[5] = "Fast" TAB %cmdCtrl @ "-Shift 6" TAB "165"; + item[6] = "Fastest" TAB %cmdCtrl @ "-Shift 7" TAB "200"; + }; + } + if(!isObject(EditorFreeCameraTypeOptions)) { - superClass = "MenuBuilder"; - class = "EditorFreeCameraTypeMenu"; - - item[0] = "Standard" TAB "Ctrl 1" TAB "EditorGuiStatusBar.setCamera(\"Standard Camera\");"; - item[1] = "Orbit Camera" TAB "Ctrl 2" TAB "EditorGuiStatusBar.setCamera(\"Orbit Camera\");"; - Item[2] = "-"; - item[3] = "Smoothed" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Camera\");"; - item[4] = "Smoothed Rotate" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Rot Camera\");"; - }; - %this.playerCameraTypeMenu = new PopupMenu(EditorPlayerCameraTypeOptions) + %this.freeCameraTypeMenu = new PopupMenu(EditorFreeCameraTypeOptions) + { + superClass = "MenuBuilder"; + class = "EditorFreeCameraTypeMenu"; + + item[0] = "Standard" TAB "Ctrl 1" TAB "EditorGuiStatusBar.setCamera(\"Standard Camera\");"; + item[1] = "Orbit Camera" TAB "Ctrl 2" TAB "EditorGuiStatusBar.setCamera(\"Orbit Camera\");"; + Item[2] = "-"; + item[3] = "Smoothed" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Camera\");"; + item[4] = "Smoothed Rotate" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Rot Camera\");"; + }; + } + if(!isObject(EditorPlayerCameraTypeOptions)) { - superClass = "MenuBuilder"; - class = "EditorPlayerCameraTypeMenu"; - - Item[0] = "First Person" TAB "" TAB "EditorGuiStatusBar.setCamera(\"1st Person Camera\");"; - Item[1] = "Third Person" TAB "" TAB "EditorGuiStatusBar.setCamera(\"3rd Person Camera\");"; - }; - %this.cameraBookmarksMenu = new PopupMenu(EditorCameraBookmarks) + %this.playerCameraTypeMenu = new PopupMenu(EditorPlayerCameraTypeOptions) + { + superClass = "MenuBuilder"; + class = "EditorPlayerCameraTypeMenu"; + + Item[0] = "First Person" TAB "" TAB "EditorGuiStatusBar.setCamera(\"1st Person Camera\");"; + Item[1] = "Third Person" TAB "" TAB "EditorGuiStatusBar.setCamera(\"3rd Person Camera\");"; + }; + } + if(!isObject(EditorCameraBookmarks)) { - superClass = "MenuBuilder"; - class = "EditorCameraBookmarksMenu"; - - //item[0] = "None"; - }; + %this.cameraBookmarksMenu = new PopupMenu(EditorCameraBookmarks) + { + superClass = "MenuBuilder"; + class = "EditorCameraBookmarksMenu"; + + //item[0] = "None"; + }; + } %this.viewTypeMenu = new PopupMenu() { superClass = "MenuBuilder"; @@ -98,7 +110,7 @@ function EditorGui::buildMenus(%this) }; // Menu bar - %this.menuBar = new MenuBar() + %this.menuBar = new MenuBar(WorldEditorMenubar) { dynamicItemInsertPos = 3; }; diff --git a/Templates/Full/game/art/datablocks/environment.cs b/Templates/Full/game/art/datablocks/environment.cs index c9d2b0a51..ab9af14d3 100644 --- a/Templates/Full/game/art/datablocks/environment.cs +++ b/Templates/Full/game/art/datablocks/environment.cs @@ -83,6 +83,8 @@ datablock LightningData(DefaultStorm) thunderSounds[1] = ThunderCrash2Sound; thunderSounds[2] = ThunderCrash3Sound; thunderSounds[3] = ThunderCrash4Sound; + + strikeTextures[0] = "art/environment/lightning"; }; datablock ReflectorDesc( DefaultCubeDesc ) diff --git a/Templates/Full/game/art/environment/lightning.png b/Templates/Full/game/art/environment/lightning.png new file mode 100644 index 000000000..fc19efad9 Binary files /dev/null and b/Templates/Full/game/art/environment/lightning.png differ diff --git a/Templates/Full/game/art/gui/mainMenuGui.gui b/Templates/Full/game/art/gui/mainMenuGui.gui index bde78491f..895f48200 100644 --- a/Templates/Full/game/art/gui/mainMenuGui.gui +++ b/Templates/Full/game/art/gui/mainMenuGui.gui @@ -126,7 +126,7 @@ profile = "GuiMenuButtonProfile"; visible = "1"; active = "1"; - command = "GuiEdit();"; + command = "toggleGuiEditor(1);"; tooltipProfile = "GuiToolTipProfile"; tooltip = "The GUI Editor is accessible in-game by pressing F10"; hovertime = "1000"; diff --git a/Templates/Full/game/art/gui/splash.bmp b/Templates/Full/game/art/gui/splash.bmp deleted file mode 100644 index 47cb47f97..000000000 Binary files a/Templates/Full/game/art/gui/splash.bmp and /dev/null differ diff --git a/Templates/Full/game/art/gui/splash.png b/Templates/Full/game/art/gui/splash.png new file mode 100644 index 000000000..333df9eb3 Binary files /dev/null and b/Templates/Full/game/art/gui/splash.png differ diff --git a/Templates/Full/game/core/scripts/client/screenshot.cs b/Templates/Full/game/core/scripts/client/screenshot.cs index 897325a1a..3c78aa2cd 100644 --- a/Templates/Full/game/core/scripts/client/screenshot.cs +++ b/Templates/Full/game/core/scripts/client/screenshot.cs @@ -55,6 +55,9 @@ function formatSessionNumber(%number) // Records a movie file from the Canvas content using the specified fps. // Possible encoder values are "PNG" and "THEORA" (default). //--------------------------------------------------------------------------------------------- + +$RecordingMovie = false; + function recordMovie(%movieName, %fps, %encoder) { // If the canvas doesn't exist yet, setup a flag so it'll @@ -65,12 +68,24 @@ function recordMovie(%movieName, %fps, %encoder) if (%encoder $= "") %encoder = "THEORA"; %resolution = Canvas.getVideoMode(); + + // Start the movie recording + ChatHud.AddLine( "\c4Recording movie file to [\c2" @ %movieName @ "\cr].ogv."); + echo("Recording movie to: " @ %movieName); startVideoCapture(Canvas, %movieName, %encoder, %fps); + + $RecordingMovie = true; } function stopMovie() { + // Stop the current recording + ChatHud.AddLine( "\c4Recording movie file finished."); + echo("Stopped movie recording"); + stopVideoCapture(); + + $RecordingMovie = false; } /// This is bound in initializeCommon() to take diff --git a/Templates/Full/game/core/torque.png b/Templates/Full/game/core/torque.png new file mode 100644 index 000000000..1023f2bb6 Binary files /dev/null and b/Templates/Full/game/core/torque.png differ diff --git a/Templates/Full/game/main.cs b/Templates/Full/game/main.cs index 2a261201d..65aae6d7f 100644 --- a/Templates/Full/game/main.cs +++ b/Templates/Full/game/main.cs @@ -28,6 +28,8 @@ $defaultGame = "scripts"; // Set profile directory $Pref::Video::ProfilePath = "core/profile"; +$Core::windowIcon = "core/torque.png"; +$Core::splashWindowImage = "art/gui/splash.png"; function createCanvas(%windowTitle) { diff --git a/Templates/Full/game/scripts/client/default.bind.cs b/Templates/Full/game/scripts/client/default.bind.cs index 1af881a81..ed804bbb2 100644 --- a/Templates/Full/game/scripts/client/default.bind.cs +++ b/Templates/Full/game/scripts/client/default.bind.cs @@ -583,6 +583,49 @@ function stopRecordingDemo( %val ) moveMap.bind( keyboard, F3, startRecordingDemo ); moveMap.bind( keyboard, F4, stopRecordingDemo ); +//------------------------------------------------------------------------------ +// Theora Video Capture (Records a movie file) +//------------------------------------------------------------------------------ + +function toggleMovieRecording(%val) +{ + if (!%val) + return; + + %movieEncodingType = "THEORA"; // Valid encoder values are "PNG" and "THEORA" (default). + %movieFPS = 30; // video capture frame rate. + + if (!$RecordingMovie) + { + // locate a non-existent filename to use + for(%i = 0; %i < 1000; %i++) + { + %num = %i; + if(%num < 10) + %num = "0" @ %num; + if(%num < 100) + %num = "0" @ %num; + + %filePath = "movies/movie" @ %num; + if(!isfile(%filePath)) + break; + } + if(%i == 1000) + return; + + // Start the movie recording + recordMovie(%filePath, %movieFPS, %movieEncodingType); + + } + else + { + // Stop the current recording + stopMovie(); + } +} + +// Key binding works at any time and not just while in a game. +GlobalActionMap.bind(keyboard, "alt m", toggleMovieRecording); //------------------------------------------------------------------------------ // Helper Functions diff --git a/Templates/Full/game/tools/base/utils/inspector.ed.cs b/Templates/Full/game/tools/base/utils/inspector.ed.cs index 9df8c7e98..f7c27ecf0 100644 --- a/Templates/Full/game/tools/base/utils/inspector.ed.cs +++ b/Templates/Full/game/tools/base/utils/inspector.ed.cs @@ -105,7 +105,7 @@ function EditorInspectorBase::onAdd( %this ) superClass = "MenuBuilder"; isPopup = true; - item[ 0 ] = "Edit Profile" TAB "" TAB "if( !$InGuiEditor ) toggleGuiEditor( true ); GuiEditor.editProfile( %this.inspectorField.getData() );"; + item[ 0 ] = "Edit Profile" TAB "" TAB "if( !GuiEditorIsActive() ) toggleGuiEditor( true ); GuiEditor.editProfile( %this.inspectorField.getData() );"; item[ 1 ] = "Jump to Definition in Torsion" TAB "" TAB "EditorOpenDeclarationInTorsion( %this.inspectorField.getData() );"; item[ 2 ] = "Inspect Object" TAB "" TAB "inspectObject( %this.inspectorField.getData() );"; item[ 3 ] = "-"; diff --git a/Templates/Full/game/tools/forestEditor/forestEditorGui.gui b/Templates/Full/game/tools/forestEditor/forestEditorGui.gui index ca40147bf..e46a09f3d 100644 --- a/Templates/Full/game/tools/forestEditor/forestEditorGui.gui +++ b/Templates/Full/game/tools/forestEditor/forestEditorGui.gui @@ -252,7 +252,7 @@ objectNamesOnly = "1"; useInspectorTooltips = "0"; tooltipOnWidthOnly = "0"; - compareToObjectID = "1"; + compareToObjectID = "0"; canRenameObjects = "1"; renameInternal = "0"; isContainer = "1"; diff --git a/Templates/Full/game/tools/guiEditor/gui/guiEditor.ed.gui b/Templates/Full/game/tools/guiEditor/gui/guiEditor.ed.gui index e387f1bc0..cc03cbd07 100644 --- a/Templates/Full/game/tools/guiEditor/gui/guiEditor.ed.gui +++ b/Templates/Full/game/tools/guiEditor/gui/guiEditor.ed.gui @@ -86,7 +86,7 @@ minExtent = "8 8"; canSave = "1"; visible = "1"; - command = "GuiEditor.switchToWorldEditor();"; + command = "toggleEditor(1);"; tooltipProfile = "ToolsGuiToolTipProfile"; ToolTip = "World Editor"; hovertime = "1000"; diff --git a/Templates/Full/game/tools/guiEditor/scripts/guiEditor.ed.cs b/Templates/Full/game/tools/guiEditor/scripts/guiEditor.ed.cs index eace7d43b..61dc8c5e7 100644 --- a/Templates/Full/game/tools/guiEditor/scripts/guiEditor.ed.cs +++ b/Templates/Full/game/tools/guiEditor/scripts/guiEditor.ed.cs @@ -75,11 +75,26 @@ function toggleGuiEditor( %make ) if( EditorIsActive() && !GuiEditor.toggleIntoEditorGui ) toggleEditor( true ); - GuiEdit(); + if( !isObject( GuiEditCanvas ) ) + new GuiControl( GuiEditCanvas, EditorGuiGroup ); - // Cancel the scheduled event to prevent - // the level from cycling after it's duration - // has elapsed. + if( GuiEditorIsActive() ) + { + GuiEditor.close(); + } + else + { + GuiEditor.open(); + + // Cancel the scheduled event to prevent + // the level from cycling after it's duration + // has elapsed. + cancel($Game::Schedule); + } + + // Cancel the scheduled event to prevent + // the level from cycling after it's duration + // has elapsed. cancel($Game::Schedule); } } @@ -98,6 +113,26 @@ package GuiEditor_BlockDialogs //--------------------------------------------------------------------------------------------- +function GuiEditor::open(%this) +{ + GuiEditCanvas.onCreateMenu(); + + GuiEditContent(Canvas.getContent()); +} + +function GuiEditor::close(%this) +{ + // prevent the mission editor from opening while the GuiEditor is open. + if(Canvas.getContent() != GuiEditorGui.getId()) + return; + + GuiGroup.add(GuiEditorGui); + + Canvas.setContent(GuiEditor.lastContent); + + GuiEditCanvas.onDestroyMenu(); +} + function GuiEditor::openForEditing( %this, %content ) { Canvas.setContent( GuiEditorGui ); diff --git a/Templates/Full/game/tools/worldEditor/gui/EditorGui.ed.gui b/Templates/Full/game/tools/worldEditor/gui/EditorGui.ed.gui index 445bacf63..3eb8558e4 100644 --- a/Templates/Full/game/tools/worldEditor/gui/EditorGui.ed.gui +++ b/Templates/Full/game/tools/worldEditor/gui/EditorGui.ed.gui @@ -67,7 +67,7 @@ MinExtent = "8 8"; canSave = "1"; Visible = "1"; - Command = "toggleEditor( true ); GuiEdit(); $GuiEditorBtnPressed = true;"; + Command = "toggleGuiEditor(true); $GuiEditorBtnPressed = true;"; tooltipprofile = "ToolsGuiToolTipProfile"; ToolTip = "Open the GuiEditor"; hovertime = "1000"; diff --git a/Templates/Full/game/tools/worldEditor/scripts/EditorGui.ed.cs b/Templates/Full/game/tools/worldEditor/scripts/EditorGui.ed.cs index 38a180e64..31f794d17 100644 --- a/Templates/Full/game/tools/worldEditor/scripts/EditorGui.ed.cs +++ b/Templates/Full/game/tools/worldEditor/scripts/EditorGui.ed.cs @@ -35,8 +35,6 @@ function EditorGui::init(%this) $NextOperationId = 1; $HeightfieldDirtyRow = -1; - %this.buildMenus(); - if( !isObject( %this-->ToolsPaletteWindow ) ) { // Load Creator/Inspector GUI @@ -1914,6 +1912,8 @@ function Editor::open(%this) if(Canvas.getContent() == GuiEditorGui.getId()) return; + EditorGui.buildMenus(); + if( !EditorGui.isInitialized ) EditorGui.init(); @@ -1929,6 +1929,21 @@ function Editor::close(%this, %gui) if(isObject(MessageHud)) MessageHud.close(); EditorGui.writeCameraSettings(); + + EditorGui.onDestroyMenu(); +} + +function EditorGui::onDestroyMenu(%this) +{ + if( !isObject( %this.menuBar ) ) + return; + + // Destroy menus + while( %this.menuBar.getCount() != 0 ) + %this.menuBar.getObject( 0 ).delete(); + + %this.menuBar.removeFromCanvas(); + %this.menuBar.delete(); } $RelightCallback = ""; diff --git a/Templates/Full/game/tools/worldEditor/scripts/editor.ed.cs b/Templates/Full/game/tools/worldEditor/scripts/editor.ed.cs index 74b34e0a9..8545c9d67 100644 --- a/Templates/Full/game/tools/worldEditor/scripts/editor.ed.cs +++ b/Templates/Full/game/tools/worldEditor/scripts/editor.ed.cs @@ -99,18 +99,12 @@ function Editor::checkActiveLoadDone() //------------------------------------------------------------------------------ function toggleEditor(%make) { - if (Canvas.isFullscreen()) - { - MessageBoxOK("Windowed Mode Required", "Please switch to windowed mode to access the Mission Editor."); - return; - } - if (%make) - { + { %timerId = startPrecisionTimer(); - if( $InGuiEditor ) - GuiEdit(); + if( GuiEditorIsActive() ) + toggleGuiEditor(1); if( !$missionRunning ) { @@ -141,29 +135,21 @@ function toggleEditor(%make) Editor.close("PlayGui"); } } - else + else { - if ( !$GuiEditorBtnPressed ) - { - canvas.pushDialog( EditorLoadingGui ); - canvas.repaint(); - } - else - { - $GuiEditorBtnPressed = false; - } + canvas.pushDialog( EditorLoadingGui ); + canvas.repaint(); Editor.open(); - // Cancel the scheduled event to prevent - // the level from cycling after it's duration - // has elapsed. + // Cancel the scheduled event to prevent + // the level from cycling after it's duration + // has elapsed. cancel($Game::Schedule); if (theLevelInfo.type $= "DemoScene") commandToServer('dropCameraAtPlayer', true); - canvas.popDialog(EditorLoadingGui); } diff --git a/Templates/Full/game/tools/worldEditor/scripts/menus.ed.cs b/Templates/Full/game/tools/worldEditor/scripts/menus.ed.cs index b6c4200d4..be068b9ed 100644 --- a/Templates/Full/game/tools/worldEditor/scripts/menus.ed.cs +++ b/Templates/Full/game/tools/worldEditor/scripts/menus.ed.cs @@ -42,47 +42,59 @@ function EditorGui::buildMenus(%this) } // Sub menus (temporary, until MenuBuilder gets updated) - // The speed increments located here are overwritten in EditorCameraSpeedMenu::setupDefaultState. - // The new min/max for the editor camera speed range can be set in each level's levelInfo object. - %this.cameraSpeedMenu = new PopupMenu(EditorCameraSpeedOptions) + // The speed increments located here are overwritten in EditorCameraSpeedMenu::setupDefaultState. + // The new min/max for the editor camera speed range can be set in each level's levelInfo object. + if(!isObject(EditorCameraSpeedOptions)) { - superClass = "MenuBuilder"; - class = "EditorCameraSpeedMenu"; - - item[0] = "Slowest" TAB %cmdCtrl @ "-Shift 1" TAB "5"; - item[1] = "Slow" TAB %cmdCtrl @ "-Shift 2" TAB "35"; - item[2] = "Slower" TAB %cmdCtrl @ "-Shift 3" TAB "70"; - item[3] = "Normal" TAB %cmdCtrl @ "-Shift 4" TAB "100"; - item[4] = "Faster" TAB %cmdCtrl @ "-Shift 5" TAB "130"; - item[5] = "Fast" TAB %cmdCtrl @ "-Shift 6" TAB "165"; - item[6] = "Fastest" TAB %cmdCtrl @ "-Shift 7" TAB "200"; - }; - %this.freeCameraTypeMenu = new PopupMenu(EditorFreeCameraTypeOptions) + %this.cameraSpeedMenu = new PopupMenu(EditorCameraSpeedOptions) + { + superClass = "MenuBuilder"; + class = "EditorCameraSpeedMenu"; + + item[0] = "Slowest" TAB %cmdCtrl @ "-Shift 1" TAB "5"; + item[1] = "Slow" TAB %cmdCtrl @ "-Shift 2" TAB "35"; + item[2] = "Slower" TAB %cmdCtrl @ "-Shift 3" TAB "70"; + item[3] = "Normal" TAB %cmdCtrl @ "-Shift 4" TAB "100"; + item[4] = "Faster" TAB %cmdCtrl @ "-Shift 5" TAB "130"; + item[5] = "Fast" TAB %cmdCtrl @ "-Shift 6" TAB "165"; + item[6] = "Fastest" TAB %cmdCtrl @ "-Shift 7" TAB "200"; + }; + } + if(!isObject(EditorFreeCameraTypeOptions)) { - superClass = "MenuBuilder"; - class = "EditorFreeCameraTypeMenu"; - - item[0] = "Standard" TAB "Ctrl 1" TAB "EditorGuiStatusBar.setCamera(\"Standard Camera\");"; - item[1] = "Orbit Camera" TAB "Ctrl 2" TAB "EditorGuiStatusBar.setCamera(\"Orbit Camera\");"; - Item[2] = "-"; - item[3] = "Smoothed" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Camera\");"; - item[4] = "Smoothed Rotate" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Rot Camera\");"; - }; - %this.playerCameraTypeMenu = new PopupMenu(EditorPlayerCameraTypeOptions) + %this.freeCameraTypeMenu = new PopupMenu(EditorFreeCameraTypeOptions) + { + superClass = "MenuBuilder"; + class = "EditorFreeCameraTypeMenu"; + + item[0] = "Standard" TAB "Ctrl 1" TAB "EditorGuiStatusBar.setCamera(\"Standard Camera\");"; + item[1] = "Orbit Camera" TAB "Ctrl 2" TAB "EditorGuiStatusBar.setCamera(\"Orbit Camera\");"; + Item[2] = "-"; + item[3] = "Smoothed" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Camera\");"; + item[4] = "Smoothed Rotate" TAB "" TAB "EditorGuiStatusBar.setCamera(\"Smooth Rot Camera\");"; + }; + } + if(!isObject(EditorPlayerCameraTypeOptions)) { - superClass = "MenuBuilder"; - class = "EditorPlayerCameraTypeMenu"; - - Item[0] = "First Person" TAB "" TAB "EditorGuiStatusBar.setCamera(\"1st Person Camera\");"; - Item[1] = "Third Person" TAB "" TAB "EditorGuiStatusBar.setCamera(\"3rd Person Camera\");"; - }; - %this.cameraBookmarksMenu = new PopupMenu(EditorCameraBookmarks) + %this.playerCameraTypeMenu = new PopupMenu(EditorPlayerCameraTypeOptions) + { + superClass = "MenuBuilder"; + class = "EditorPlayerCameraTypeMenu"; + + Item[0] = "First Person" TAB "" TAB "EditorGuiStatusBar.setCamera(\"1st Person Camera\");"; + Item[1] = "Third Person" TAB "" TAB "EditorGuiStatusBar.setCamera(\"3rd Person Camera\");"; + }; + } + if(!isObject(EditorCameraBookmarks)) { - superClass = "MenuBuilder"; - class = "EditorCameraBookmarksMenu"; - - //item[0] = "None"; - }; + %this.cameraBookmarksMenu = new PopupMenu(EditorCameraBookmarks) + { + superClass = "MenuBuilder"; + class = "EditorCameraBookmarksMenu"; + + //item[0] = "None"; + }; + } %this.viewTypeMenu = new PopupMenu() { superClass = "MenuBuilder"; @@ -98,7 +110,7 @@ function EditorGui::buildMenus(%this) }; // Menu bar - %this.menuBar = new MenuBar() + %this.menuBar = new MenuBar(WorldEditorMenubar) { dynamicItemInsertPos = 3; }; diff --git a/Tools/CMake/torque3d.cmake b/Tools/CMake/torque3d.cmake index 02378671b..e934e37b4 100644 --- a/Tools/CMake/torque3d.cmake +++ b/Tools/CMake/torque3d.cmake @@ -67,17 +67,63 @@ endif() option(TORQUE_SFX_OPENAL "OpenAL Sound" ON) #windows uses openal-soft if(WIN32) -#disable a few things that are not required -set(ALSOFT_TESTS OFF CACHE BOOL "Build and install test programs" FORCE) -set(ALSOFT_UTILS OFF CACHE BOOL "Build and install utility programs" FORCE) -set(ALSOFT_EXAMPLES OFF CACHE BOOL "Build and install example programs" FORCE) -set(ALSOFT_CONFIG OFF CACHE BOOL "Install alsoft.conf sample configuration file" FORCE) -set(ALSOFT_INSTALL OFF CACHE BOOL "Install headers and libraries" FORCE) -set(ALSOFT_NO_CONFIG_UTIL OFF CACHE BOOL "Disable building the alsoft-config utility" FORCE) -set(ALSOFT_HRTF_DEFS OFF CACHE BOOL "Install HRTF definition files" FORCE) -set(ALSOFT_AMBDEC_PRESETS OFF CACHE BOOL "Install AmbDec presets" FORCE) -add_subdirectory( ${libDir}/openal-soft ${CMAKE_CURRENT_BINARY_DIR}/openal-soft) + #disable a few things that are not required + set(ALSOFT_TESTS OFF CACHE BOOL "Build and install test programs" FORCE) + set(ALSOFT_UTILS OFF CACHE BOOL "Build and install utility programs" FORCE) + set(ALSOFT_EXAMPLES OFF CACHE BOOL "Build and install example programs" FORCE) + set(ALSOFT_CONFIG OFF CACHE BOOL "Install alsoft.conf sample configuration file" FORCE) + set(ALSOFT_INSTALL OFF CACHE BOOL "Install headers and libraries" FORCE) + set(ALSOFT_NO_CONFIG_UTIL OFF CACHE BOOL "Disable building the alsoft-config utility" FORCE) + set(ALSOFT_HRTF_DEFS OFF CACHE BOOL "Install HRTF definition files" FORCE) + set(ALSOFT_AMBDEC_PRESETS OFF CACHE BOOL "Install AmbDec presets" FORCE) + + add_subdirectory( ${libDir}/openal-soft ${CMAKE_CURRENT_BINARY_DIR}/openal-soft) endif() + +if(TORQUE_SFX_OPENAL) + #Hide some unnecessary fields as advanced + mark_as_advanced(ALSOFT_AMBDEC_PRESETS) + mark_as_advanced(ALSOFT_BACKEND_DSOUND) + mark_as_advanced(ALSOFT_BACKEND_MMDEVAPI) + mark_as_advanced(ALSOFT_BACKEND_WAVE) + mark_as_advanced(ALSOFT_BACKEND_WINMM) + mark_as_advanced(ALSOFT_CONFIG) + mark_as_advanced(ALSOFT_CPUEXT_SSE) + mark_as_advanced(ALSOFT_CPUEXT_SSE2) + mark_as_advanced(ALSOFT_CPUEXT_SSE3) + mark_as_advanced(ALSOFT_CPUEXT_SSE4_1) + mark_as_advanced(ALSOFT_DLOPEN) + mark_as_advanced(ALSOFT_EMBED_HRTF_DATA) + mark_as_advanced(ALSOFT_EXAMPLES) + mark_as_advanced(ALSOFT_HRTF_DEFS) + mark_as_advanced(ALSOFT_INSTALL) + mark_as_advanced(ALSOFT_NO_CONFIG_UTIL) + mark_as_advanced(ALSOFT_NO_UID_DEFS) + mark_as_advanced(ALSOFT_REQUIRE_ALSA) + mark_as_advanced(ALSOFT_REQUIRE_COREAUDIO) + mark_as_advanced(ALSOFT_REQUIRE_DSOUND) + mark_as_advanced(ALSOFT_REQUIRE_JACK) + mark_as_advanced(ALSOFT_REQUIRE_MMDEVAPI) + mark_as_advanced(ALSOFT_REQUIRE_NEON) + mark_as_advanced(ALSOFT_REQUIRE_OPENSL) + mark_as_advanced(ALSOFT_REQUIRE_OSS) + mark_as_advanced(ALSOFT_REQUIRE_PORTAUDIO) + mark_as_advanced(ALSOFT_REQUIRE_PULSEAUDIO) + mark_as_advanced(ALSOFT_REQUIRE_QSA) + mark_as_advanced(ALSOFT_REQUIRE_SNDIO) + mark_as_advanced(ALSOFT_REQUIRE_SOLARIS) + mark_as_advanced(ALSOFT_REQUIRE_SSE) + mark_as_advanced(ALSOFT_REQUIRE_SSE2) + mark_as_advanced(ALSOFT_REQUIRE_SSE4_1) + mark_as_advanced(ALSOFT_REQUIRE_WINMM) + mark_as_advanced(ALSOFT_TESTS) + mark_as_advanced(ALSOFT_UTILS) + mark_as_advanced(ALSOFT_WERROR) + mark_as_advanced(COREAUDIO_FRAMEWORK) + mark_as_advanced(CMAKE_DEBUG_POSTFIX) + mark_as_advanced(FORCE_STATIC_VCRT) +endif() + mark_as_advanced(TORQUE_SFX_OPENAL) option(TORQUE_HIFI "HIFI? support" OFF) mark_as_advanced(TORQUE_HIFI) @@ -691,6 +737,63 @@ if(TORQUE_SDL) addDef(TORQUE_SDL) addInclude(${libDir}/sdl/include) addLib(SDL2) + + SET(VIDEO_WAYLAND OFF CACHE BOOL "" FORCE) + mark_as_advanced(3DNOW) + mark_as_advanced(ALSA) + mark_as_advanced(ALTIVEC) + mark_as_advanced(ARTS) + mark_as_advanced(ASSEMBLY) + mark_as_advanced(ASSERTIONS) + mark_as_advanced(DIRECTX) + mark_as_advanced(DISKAUDIO) + mark_as_advanced(DUMMYAUDIO) + mark_as_advanced(ESD) + mark_as_advanced(FUSIONSOUND) + mark_as_advanced(INPUT_TSLIB) + mark_as_advanced(LIBC) + mark_as_advanced(MMX) + mark_as_advanced(NAS) + mark_as_advanced(NAS_SHARED) + mark_as_advanced(OSS) + mark_as_advanced(PTHREADS) + mark_as_advanced(PULSEAUDIO) + mark_as_advanced(RENDER_D3D) + mark_as_advanced(RPATH) + mark_as_advanced(SNDIO) + mark_as_advanced(SSE) + mark_as_advanced(SSE2) + mark_as_advanced(SSEMATH) + mark_as_advanced(WINDRES) + mark_as_advanced(SDL_ATOMIC) + mark_as_advanced(SDL_AUDIO) + mark_as_advanced(SDL_CPUINFO) + mark_as_advanced(SDL_DLOPEN) + mark_as_advanced(SDL_EVENTS) + mark_as_advanced(SDL_FILE) + mark_as_advanced(SDL_FILESYSTEM) + mark_as_advanced(SDL_HAPTIC) + mark_as_advanced(SDL_JOYSTICK) + mark_as_advanced(SDL_LOADSO) + mark_as_advanced(SDL_POWER) + mark_as_advanced(SDL_RENDER) + mark_as_advanced(SDL_SHARED) + mark_as_advanced(SDL_STATIC) + mark_as_advanced(SDL_THREADS) + mark_as_advanced(SDL_TIMERS) + mark_as_advanced(SDL_VIDEO) + mark_as_advanced(CLOCK_GETTIME) + mark_as_advanced(GCC_ATOMICS) + mark_as_advanced(VIDEO_WAYLAND) + mark_as_advanced(VIDEO_COCOA) + mark_as_advanced(VIDEO_DIRECTFB) + mark_as_advanced(VIDEO_DUMMY) + mark_as_advanced(VIDEO_MIR) + mark_as_advanced(VIDEO_OPENGL) + mark_as_advanced(VIDEO_OPENGLES) + mark_as_advanced(VIDEO_RPI) + mark_as_advanced(VIDEO_VIVANTE) + mark_as_advanced(VIDEO_X11) endif() if(TORQUE_STATIC_CODE_ANALYSIS)