diff --git a/Templates/BaseGame/game/core/main.cs b/Templates/BaseGame/game/core/main.cs index 04216e59d..a8a396f41 100644 --- a/Templates/BaseGame/game/core/main.cs +++ b/Templates/BaseGame/game/core/main.cs @@ -83,13 +83,10 @@ exec("./gfxData/water.cs"); exec("./gfxData/scatterSky.cs"); exec("./gfxData/clouds.cs"); -exec("./screenshot.cs"); - // Initialize all core post effects. exec("./postFx.cs"); //VR stuff -exec("./oculusVROverlay.gui"); exec("./oculusVR.cs"); // Seed the random number generator. diff --git a/Templates/BaseGame/game/data/ui/UI.cs b/Templates/BaseGame/game/data/ui/UI.cs index bac90023c..eac7f9232 100644 --- a/Templates/BaseGame/game/data/ui/UI.cs +++ b/Templates/BaseGame/game/data/ui/UI.cs @@ -39,8 +39,9 @@ function UI::create( %this ) exec("./scripts/guis/profiler.gui"); exec("./scripts/guis/netGraphGui.gui"); - exec("./scripts/guis/FilDialog.gui"); + exec("./scripts/guis/FileDialog.gui"); exec("./scripts/guis/guiMusicPlayer.gui"); + exec("./scripts/guis/startupGui.gui"); //Load gui companion scripts exec("./scripts/chooseLevelDlg.cs"); @@ -59,10 +60,12 @@ function UI::create( %this ) exec("./scripts/FileDialog.cs"); exec("./scripts/GuiTreeViewCtrl.cs"); exec("./scripts/guiMusicPlayer.cs"); + exec("./scripts/startupGui.cs"); %dbList = new ArrayObject(LevelFilesList); - Canvas.pushDialog(MainMenuGui); + loadStartup(); + //Canvas.pushDialog(MainMenuGui); } function Game::destroy( %this ) diff --git a/Templates/BaseGame/game/data/ui/scripts/FileDialog.cs b/Templates/BaseGame/game/data/ui/scripts/FileDialog.cs index c5e693a80..4d67fd969 100644 --- a/Templates/BaseGame/game/data/ui/scripts/FileDialog.cs +++ b/Templates/BaseGame/game/data/ui/scripts/FileDialog.cs @@ -1,5 +1,3 @@ -exec("./FileDialog.gui"); - function PlatformFileDialog::buildFilters(%this) { %str = strreplace( %this.data.filters, "|", "\t"); diff --git a/Templates/BaseGame/game/data/ui/scripts/guis/startupGui.gui b/Templates/BaseGame/game/data/ui/scripts/guis/startupGui.gui new file mode 100644 index 000000000..ad7afcf63 --- /dev/null +++ b/Templates/BaseGame/game/data/ui/scripts/guis/startupGui.gui @@ -0,0 +1,79 @@ +//--- OBJECT WRITE BEGIN --- +%guiContent = new GuiFadeinBitmapCtrl(StartupGui) { + canSaveDynamicFields = "0"; + Enabled = "1"; + isContainer = "1"; + Profile = "GuiInputCtrlProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "0 0"; + Extent = "800 600"; + MinExtent = "8 8"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "GuiToolTipProfile"; + hovertime = "1000"; + bitmap = ""; + wrap = "0"; + fadeinTime = "1000"; + waitTime = "4000"; + fadeoutTime = "1000"; + done = "1"; + + new GuiBitmapButtonCtrl() { + canSaveDynamicFields = "1"; + internalName = "StartupLogo"; + Enabled = "1"; + isContainer = "0"; + Profile = "GuiDefaultProfile"; + HorizSizing = "center"; + VertSizing = "center"; + position = "399 302"; + Extent = "253 253"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "GuiToolTipProfile"; + hovertime = "1000"; + bitmap = ""; + wrap = "0"; + command = "StartupGui.click();"; + }; + new GuiBitmapButtonCtrl() { + canSaveDynamicFields = "1"; + internalName = "StartupLogoSecondary"; + Enabled = "1"; + isContainer = "0"; + Profile = "GuiDefaultProfile"; + HorizSizing = "left"; + VertSizing = "top"; + position = "275 440"; + Extent = "530 171"; + MinExtent = "8 2"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "GuiToolTipProfile"; + hovertime = "1000"; + bitmap = ""; + wrap = "0"; + command = "StartupGui.click();"; + }; +}; +//--- OBJECT WRITE END --- +//--- OBJECT WRITE BEGIN --- +new GuiFadeinBitmapCtrl(BlankGui) { + profile = "GuiInputCtrlProfile"; + horizSizing = "right"; + vertSizing = "bottom"; + position = "0 0"; + extent = "800 600"; + minExtent = "8 8"; + visible = "1"; + helpTag = "0"; + bitmap = ""; + wrap = "0"; + fadeinTime = "100"; + waitTime = "2000"; + fadeoutTime = "100"; +}; +//--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/ui/scripts/startupGui.cs b/Templates/BaseGame/game/data/ui/scripts/startupGui.cs new file mode 100644 index 000000000..fc5095c2d --- /dev/null +++ b/Templates/BaseGame/game/data/ui/scripts/startupGui.cs @@ -0,0 +1,155 @@ +//----------------------------------------------------------------------------- +// Copyright (c) 2012 GarageGames, LLC +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// StartupGui is the splash screen that initially shows when the game is loaded +//----------------------------------------------------------------------------- + +function loadStartup() +{ + // The index of the current splash screen + $StartupIdx = 0; + + // A list of the splash screens and logos + // to cycle through. Note that they have to + // be in consecutive numerical order + StartupGui.bitmap[0] = "data/ui/art/background-dark"; + StartupGui.logo[0] = "data/ui/art/Torque-3D-logo"; + StartupGui.logoPos[0] = "178 251"; + StartupGui.logoExtent[0] = "443 139"; + + // Call the next() function to set our firt + // splash screen + StartupGui.next(); + + // Play our startup sound + //SFXPlayOnce(AudioGui, "art/sound/gui/startup");//SFXPlay(startsnd); +} + +function StartupGui::onWake(%this) +{ + $enableDirectInput = "1"; + activateDirectInput(); +} + +function StartupGui::click(%this) +{ + %this.done = true; + %this.onDone(); +} + +function StartupGui::next(%this) +{ + // Set us to a blank screen while we load the next one + Canvas.setContent(BlankGui); + + // Set our bitmap and reset the done variable + %this.setBitmap(%this.bitmap[$StartupIdx]); + %this.done = false; + + // If we have a logo then set it + if (isObject(%this->StartupLogo)) + { + if (%this.logo[$StartupIdx] !$= "") + { + %this->StartupLogo.setBitmap(%this.logo[$StartupIdx]); + + if (%this.logoPos[$StartupIdx] !$= "") + { + %logoPosX = getWord(%this.logoPos[$StartupIdx], 0); + %logoPosY = getWord(%this.logoPos[$StartupIdx], 1); + + %this->StartupLogo.setPosition(%logoPosX, %logoPosY); + } + + if (%this.logoExtent[$StartupIdx] !$= "") + %this->StartupLogo.setExtent(%this.logoExtent[$StartupIdx]); + + %this->StartupLogo.setVisible(true); + } + else + %this->StartupLogo.setVisible(false); + } + + // If we have a secondary logo then set it + if (isObject(%this->StartupLogoSecondary)) + { + if (%this.seclogo[$StartupIdx] !$= "") + { + %this->StartupLogoSecondary.setBitmap(%this.seclogo[$StartupIdx]); + + if (%this.seclogoPos[$StartupIdx] !$= "") + { + %logoPosX = getWord(%this.seclogoPos[$StartupIdx], 0); + %logoPosY = getWord(%this.seclogoPos[$StartupIdx], 1); + + %this->StartupLogoSecondary.setPosition(%logoPosX, %logoPosY); + } + + if (%this.seclogoExtent[$StartupIdx] !$= "") + %this->StartupLogoSecondary.setExtent(%this.seclogoExtent[$StartupIdx]); + + %this->StartupLogoSecondary.setVisible(true); + } + else + %this->StartupLogoSecondary.setVisible(false); + } + + // Increment our screen index for the next screen + $StartupIdx++; + + // Set the Canvas to our newly updated GuiFadeinBitmapCtrl + Canvas.setContent(%this); +} + +function StartupGui::onDone(%this) +{ + // If we have been tagged as done decide if we need + // to end or cycle to the next one + if (%this.done) + { + // See if we have a valid bitmap for the next screen + if (%this.bitmap[$StartupIdx] $= "") + { + // Clear our data and load the main menu + %this.done = true; + + // NOTE: Don't ever ever delete yourself during a callback from C++. + // + // Deleting the whole gui itself seems a bit excessive, what if we want + // to return to the startup gui at a later time? Any bitmaps set on + // the controls should be unloaded automatically if the control is not + // awake, if this is not the case then that's what needs to be fixed. + + //%this.delete(); + //BlankGui.delete(); + //flushTextureCache(); + + Canvas.setContent(MainMenuGui); + } + else + { + // We do have a bitmap so cycle to it + %this.next(); + } + } +} diff --git a/Templates/Modules/FPSGameplay/FPSGameplay.cs b/Templates/Modules/FPSGameplay/FPSGameplay.cs index 0df11239a..8eaebce46 100644 --- a/Templates/Modules/FPSGameplay/FPSGameplay.cs +++ b/Templates/Modules/FPSGameplay/FPSGameplay.cs @@ -38,6 +38,7 @@ function FPSGameplay::create( %this ) exec("./scripts/server/vehicleWheeled.cs"); exec("./scripts/server/VolumetricFog.cs"); exec("./scripts/server/weapon.cs"); + exec("./scripts/server/physicsShape.cs"); //add DBs if(isObject(DatablockFilesList)) @@ -89,8 +90,10 @@ function FPSGameplay::create( %this ) exec("./scripts/gui/chatHud.gui"); exec("./scripts/gui/playerList.gui"); exec("./scripts/gui/playGui.gui"); + exec("./scripts/gui/hudlessGui.gui"); - exec("./scripts/gui/playGui.cs"); + exec("data/FPSGameplay/scripts/client/playGui.cs"); + exec("data/FPSGameplay/scripts/client/hudlessGui.cs"); exec("data/FPSGameplay/scripts/client/message.cs"); exec("data/FPSGameplay/scripts/client/chatHud.cs"); @@ -99,6 +102,8 @@ function FPSGameplay::create( %this ) exec("data/FPSGameplay/scripts/client/playerList.cs"); exec("data/FPSGameplay/scripts/client/centerPrint.cs"); exec("data/FPSGameplay/scripts/client/recordings.cs"); + + exec("data/FPSGameplay/scripts/client/screenshot.cs"); } } diff --git a/Templates/Modules/FPSGameplay/scripts/client/hudlessGui.cs b/Templates/Modules/FPSGameplay/scripts/client/hudlessGui.cs new file mode 100644 index 000000000..2fc4f20ad --- /dev/null +++ b/Templates/Modules/FPSGameplay/scripts/client/hudlessGui.cs @@ -0,0 +1,42 @@ +//----------------------------------------------------------------------------- +// Copyright (c) 2012 GarageGames, LLC +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +//----------------------------------------------------------------------------- + + +function HudlessPlayGui::onWake(%this) +{ + // just update the action map here + moveMap.push(); +} + +function HudlessPlayGui::onSleep(%this) +{ + // pop the keymaps + moveMap.pop(); +} + +function HudlessPlayGui::toggle(%this) +{ + if (%this.isAwake()) + Canvas.setContent(PlayGui); + else + Canvas.setContent(HudlessPlayGui); +} diff --git a/Templates/Modules/FPSGameplay/scripts/gui/playGui.cs b/Templates/Modules/FPSGameplay/scripts/client/playGui.cs similarity index 100% rename from Templates/Modules/FPSGameplay/scripts/gui/playGui.cs rename to Templates/Modules/FPSGameplay/scripts/client/playGui.cs diff --git a/Templates/BaseGame/game/core/screenshot.cs b/Templates/Modules/FPSGameplay/scripts/client/screenshot.cs similarity index 100% rename from Templates/BaseGame/game/core/screenshot.cs rename to Templates/Modules/FPSGameplay/scripts/client/screenshot.cs diff --git a/Templates/Modules/FPSGameplay/scripts/gui/hudlessGui.gui b/Templates/Modules/FPSGameplay/scripts/gui/hudlessGui.gui new file mode 100644 index 000000000..d8bc7466f --- /dev/null +++ b/Templates/Modules/FPSGameplay/scripts/gui/hudlessGui.gui @@ -0,0 +1,27 @@ +//--- OBJECT WRITE BEGIN --- +%guiContent = new GameTSCtrl(HudlessPlayGui) { + canSaveDynamicFields = "1"; + isContainer = "1"; + Profile = "GuiContentProfile"; + HorizSizing = "right"; + VertSizing = "bottom"; + position = "0 0"; + Extent = "1024 768"; + MinExtent = "8 8"; + canSave = "1"; + Visible = "1"; + tooltipprofile = "GuiToolTipProfile"; + hovertime = "1000"; + Margin = "0 0 0 0"; + Padding = "0 0 0 0"; + AnchorTop = "1"; + AnchorBottom = "0"; + AnchorLeft = "1"; + AnchorRight = "0"; + cameraZRot = "0"; + forceFOV = "0"; + Enabled = "1"; + helpTag = "0"; + noCursor = "1"; +}; +//--- OBJECT WRITE END --- \ No newline at end of file diff --git a/Templates/Modules/FPSGameplay/scripts/server/physicsShape.cs b/Templates/Modules/FPSGameplay/scripts/server/physicsShape.cs new file mode 100644 index 000000000..8818a1613 --- /dev/null +++ b/Templates/Modules/FPSGameplay/scripts/server/physicsShape.cs @@ -0,0 +1,68 @@ +//----------------------------------------------------------------------------- +// Copyright (c) 2012 GarageGames, LLC +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +//----------------------------------------------------------------------------- + +function PhysicsShapeData::damage(%this, %obj, %sourceObject, %position, %amount, %damageType) +{ + // Order of operations is extremely important here! + // Verify that any changes will not cause this method to overflow the stack + // recursively calling itself. + + // Note that invulerable, damageRadius, areaImpulse, radiusDamage, and damageType + // are only dynamic fields... This is fine so long as you are only calling + // this method server-side, just keep in mind these fields are NOT networked. + + if ( %this.invulnerable || + %amount < 0 || + ( %this.minDamageAmount != 0 && %amount < %this.minDamageAmount ) ) + return; + + // We cannot destroy things twice. + if ( %obj.isDestroyed() ) + return; + + // This sets a maskbit on the server PhysicsShape which will cause the + // client object to destroy ( spawn debris ) during the next ghost update. + %obj.destroy(); + + // Single-player hack... + // In a single-player situation the radial impulse NetEvent will + // be applied client-side immediately when we call it, which means it will + // happen before the next ghost update and the debris won't even exist yet! + // + // So we are explicitly calling destroy on the client-side object first, + // before sending the event. + // + if ( %obj.getClientObject() ) + %obj.getClientObject().destroy(); + + if ( %this.damageRadius > 0 ) + { + // Send impulse event to affect objects from the explosion of this object. + // Happens server-side and client-side. + if ( %this.areaImpulse > 0 ) + RadialImpulseEvent::send( %position, %this.damageRadius, %this.areaImpulse ); + + // Apply damage to objects from the explosion of this object. + if ( %this.radiusDamage > 0 ) + radiusDamage( %obj, %position, %this.damageRadius, %this.radiusDamage, %this.damageType ); + } +} \ No newline at end of file