Exemple #1
0
        /// <summary>
        /// A function used in order to easily parse the MissionGroup for classes . I'm pretty
        /// sure at this point the function can be easily modified to search the any group as well.
        /// </summary>
        /// <param name="className"></param>
        /// <param name="childGroup"></param>
        public static bool parseMissionGroup(string className, SimGroup childGroup = null)
        {
            if (childGroup == null)
            {
                childGroup = Sim.FindObject <SimGroup>("MissionGroup");
            }

            for (uint i = 0; i < childGroup.getCount(); i++)
            {
                if (childGroup.getObject(i).getClassName().Equals(className))
                {
                    return(true);
                }

                if (childGroup.getObject(i).getClassName().Equals("SimGroup"))
                {
                    if (parseMissionGroup(className, childGroup.getObject(i).As <SimGroup>()))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemple #2
0
        public void restoreMaterials()
        {
            if (!"TerrainMaterialDlgSnapshot".isObject())
            {
                Util._error("TerrainMaterial::restoreMaterials - no snapshot present");
                return;
            }

            SimGroup TerrainMaterialDlgSnapshot = "TerrainMaterialDlgSnapshot";

            int count = TerrainMaterialDlgSnapshot.getCount();

            for (uint i = 0; i < count; i++)
            {
                ScriptObject obj = TerrainMaterialDlgSnapshot.getObject(i);

                TerrainMaterial mat = obj["material"];
                mat.setInternalName(obj.internalName);
                mat.diffuseMap           = obj["diffuseMap"];
                mat.normalMap            = obj["normalMap"];
                mat.detailMap            = obj["detailMap"];
                mat.macroMap             = obj["macroMap"];
                mat["detailSize"]        = obj["detailSize"];
                mat["diffuseSize"]       = obj["diffuseSize"];
                mat["detailStrength"]    = obj["detailStrength"];
                mat["detailDistance"]    = obj["detailDistance"];
                mat["macroSize"]         = obj["macroSize"];
                mat["macroStrength"]     = obj["macroStrength"];
                mat["macroDistance"]     = obj["macroDistance"];
                mat["useSideProjection"] = obj["useSideProjection"];
                mat["parallaxScale"]     = obj["parallaxScale"];
            }
        }
Exemple #3
0
        public void dialogCancel()
        {
            PersistenceManager ETerrainMaterialPersistMan    = "ETerrainMaterialPersistMan";
            SimGroup           TerrainMaterialDlgNewGroup    = "TerrainMaterialDlgNewGroup";
            SimGroup           TerrainMaterialDlgDeleteGroup = "TerrainMaterialDlgDeleteGroup";

            // Restore material properties we have changed.
            this.restoreMaterials();

            // Clear the persistence manager state.

            ETerrainMaterialPersistMan.clearAll();

            // Delete all new object we have created.

            TerrainMaterialDlgNewGroup.clear();

            // Restore materials we have marked for deletion.

            int deletedCount = TerrainMaterialDlgDeleteGroup.getCount();

            for (uint i = 0; i < deletedCount; i++)
            {
                SimObject mat = TerrainMaterialDlgDeleteGroup.getObject(i);
                mat.parentGroup = "RootGroup";

                ((SimSet)"TerrainMaterialSet").add(mat);
            }
            ((GuiCanvas)"Canvas").popDialog(this);
        }
Exemple #4
0
        public void init(SimGroup qualityGroup)
        {
            // Clear the existing content first.
            this.clear();
            // Fill it.
            int select = -1;

            for (uint i = 0; i < qualityGroup.getCount(); i++)
            {
                GraphicsQualityLevel level = qualityGroup.getObject(i);
                if (level.isCurrent())
                {
                    select = (int)i;
                }

                this.add(level.getInternalName(), (int)i);
            }
            // Setup a default selection.
            if (select == -1)
            {
                this.setText("Custom");
            }
            else
            {
                this.setSelected(select);
            }

            //this.setText(select.AsString());
        }
Exemple #5
0
        public static string parseMissionGroupForIds(string className, SimGroup childGroup = null)
        {
            if (childGroup == null)
            {
                childGroup = Sim.FindObject <SimGroup>(Globals.GetString("Game::MissionGroup"));
            }

            string classIds = "";

            for (uint i = 0; i < childGroup.getCount(); i++)
            {
                if (childGroup.getObject(i).getClassName().Equals(className))
                {
                    classIds += childGroup.getObject(i).getId() + " ";
                }

                if (childGroup.getObject(i).getClassName().Equals("SimGroup"))
                {
                    classIds += parseMissionGroupForIds(className, childGroup.getObject(i).As <SimGroup>());
                }
            }

            return(classIds);
        }
Exemple #6
0
        //-----------------------------------------------------------------------------
        //This is the first call made by the server to kick the loading process off
        public static void loadMission(string missionName, bool isFirstMission)
        {
            endMission();
            Global.echo("*** LOADING MISSION: " + missionName);
            Global.echo("*** Stage 1 load");

            // increment the mission sequence (used for ghost sequencing)
            Globals.Increment("missionSequence");
            Globals.SetBool("missionRunning", false);
            Globals.SetString("Server::MissionFile", missionName);
            Globals.SetString("Server::LoadFailMsg", "");

            // Extract mission info from the mission file,
            // including the display name and stuff to send
            // to the client.
            LevelInfo.buildLoadInfo(missionName);

            SimGroup ClientGroup = Sim.FindObject <SimGroup>("ClientGroup");

            // Download mission info to the clients
            int count = ClientGroup.getCount();

            for (uint cl = 0; cl < count; cl++)
            {
                GameConnectionToClient client = ClientGroup.getObject(cl).As <GameConnectionToClient>();

                if (!client.isAIControlled())
                {
                    LevelInfo.sendLoadInfoToClient(client);
                }
            }

            // Now that we've sent the LevelInfo to the clients
            // clear it so that it won't conflict with the actual
            // LevelInfo loaded in the level
            LevelInfo.clearLoadInfo();

            // if this isn't the first mission, allow some time for the server
            // to transmit information to the clients:
            if (isFirstMission || Globals.GetString("Server::ServerType").Equals("SinglePlayer"))
            {
                loadMissionStage2();
            }
            else
            {
                Global.schedule(Globals.GetString("MissionLoadPause"), "ServerGroup", "loadMissionStage2");
            };
        }
        private bool isNameUnique(string name)
        {
            SimGroup ClientGroup = Sim.FindObject <SimGroup>("ClientGroup");

            for (uint i = 0; i < ClientGroup.getCount(); i++)
            {
                GameConnectionToClient test = ClientGroup.getObject(i).As <GameConnectionToClient>();
                string rawName = Global.stripChars(Global.detag(test.PlayerName.Tag()),
                                                   "\\cp\\co\\c6\\c7\\c8\\c9".ColorEscape());
                if (name.Equals(rawName))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemple #8
0
        //-----------------------------------------------------------------------------
        // AudioStateExclusive class.
        //
        // Automatically deactivates sibling SFXStates in its parent SimGroup
        // when activated.
        public override void onActivate()
        {
            base.onActivate();

            SimGroup group = parentGroup.ID;

            for (uint i = 0; i < group.getCount(); i++)
            {
                SFXState obj = group.getObject(i);

                if (obj.getId() != this.getId() && isMemberOfClass("SFXState") && isActive())
                {
                    obj.deactivate();
                }
            }
        }
Exemple #9
0
 // Return the first active SFXState in the given SimSet/SimGroup.
 public static SFXState sfxGetActiveStateInGroup(SimGroup group)
 {
     for (uint i = 0; i < group.getCount(); i++)
     {
         SFXState obj = group.getObject(i);
         if (!obj.isMemberOfClass("SFXState"))
         {
             continue;
         }
         if (obj.isActive())
         {
             return(obj);
         }
     }
     return("0");
 }
Exemple #10
0
        public void dialogApply()
        {
            SimGroup           TerrainMaterialDlgNewGroup    = "TerrainMaterialDlgNewGroup";
            SimGroup           TerrainMaterialDlgDeleteGroup = "TerrainMaterialDlgDeleteGroup";
            PersistenceManager ETerrainMaterialPersistMan    = "ETerrainMaterialPersistMan";
            TerrainPainter     TerrainPainter = "TerrainPainter";
            SimGroup           RootGroup      = "RootGroup";
            TerrainEditor      ETerrainEditor = "ETerrainEditor";

            // Move all new materials we have created to the root group.
            int newCount = TerrainMaterialDlgNewGroup.getCount();

            for (uint i = 0; i < newCount; i++)
            {
                RootGroup.add(TerrainMaterialDlgNewGroup.getObject(i));
            }

            // Finalize deletion of all removed materials.
            int deletedCount = TerrainMaterialDlgDeleteGroup.getCount();

            for (uint i = 0; i < deletedCount; i++)
            {
                SimObject mat = TerrainMaterialDlgDeleteGroup.getObject(i);
                ETerrainMaterialPersistMan.removeObjectFromFile(mat);

                int _matIndex = ETerrainEditor.getMaterialIndex(mat.internalName);
                if (_matIndex != -1)
                {
                    ETerrainEditor.removeMaterial(matIndex);
                    TerrainPainter.updateLayers("");
                }
                mat.delete();
            }
            // Make sure we save any changes to the current selection.
            saveDirtyMaterial(this["activeMat"]);
            // Save all changes.
            ETerrainMaterialPersistMan.saveDirty();

            // Delete the snapshot.
            "TerrainMaterialDlgSnapshot".delete();

            ((GuiCanvas)"Canvas").popDialog(this);

            Util._call(onApplyCallback, this["activeMat"], this.matIndex.AsString());
        }
        /// <summary>
        /// Return the first active SFXState in the given SimSet/SimGroup.
        /// </summary>
        /// <param name="group"></param>
        public static SFXState sfxGetActiveStateInGroup(SimGroup group)
        {
            for (uint i = 0; i < group.getCount(); i++)
            {
                SimObject obj = group.getObject(i);
                if (!obj.isMemberOfClass("SFXState"))
                {
                    continue;
                }

                SFXState state = obj.As <SFXState>();
                if (state.isActive())
                {
                    return(state);
                }
            }

            return(null);
        }
Exemple #12
0
        /// <summary>
        /// Shut down the server
        /// </summary>
        public static void destroyServer()
        {
            Globals.SetString("Server::ServerType", "");
            Globals.SetBool("Server::Running", false);

            Global.allowConnections(false);
            Global.stopHeartbeat();
            Globals.SetBool("missionRunning", false);

            // End any running levels and shut down the physics sim
            onServerDestroyed();

            Global.physicsDestroy();

            // Delete all the server objects
            if (Global.isObject("ServerGroup"))
            {
                Sim.FindObject <SimGroup>("ServerGroup").delete();
            }

            SimGroup ClientGroup = Sim.FindObject <SimGroup>("ClientGroup");

            // Delete all the connections:
            while (ClientGroup.getCount() > 0)
            {
                GameConnection client = ClientGroup.getObject(0).As <GameConnection>();
                client.delete();
            }

            Globals.SetString("Server::GuidList", "");

            // Delete all the data blocks...
            Global.deleteDataBlocks();

            // Save any server settings
            Global.echo("Exporting server prefs...");
            Global.export("$Pref::Server::*", "data/clientServer/scripts/server/prefs.cs", false);

            // Increase the server session number.  This is used to make sure we're
            // working with the server session we think we are.
            Globals.Increment("Server::Session");
        }
        public virtual void scanGroup(SimGroup group, GuiPopUpMenuCtrl list, int indentLevel)
        {
            // Create a display name for the group.
            string text = group.getName();

            if (text == "")
            {
                text = group.getClassName();
            }

            string internalName = group.getInternalName();

            if (internalName != "")
            {
                text = text + "[" + internalName + "]";
            }

            // Indent the name according to the depth in the hierarchy.

            if (indentLevel > 0)
            {
                text = Util.strrepeat(" ", indentLevel, "") + text;
            }

            // Add it to the list.

            list.add(text, group.getId());

            // Recurse into SimSets with at least one child.

            for (uint i = 0; i < group.getCount(); i++)
            {
                SimObject obj = group.getObject(i);
                if (!obj.isMemberOfClass("SimSet") || obj.call("getCount").AsInt() == 0)
                {
                    continue;
                }

                scanGroup(obj.GetID(), list, indentLevel + 1);
            }
        }
        public static void IODropdown(string title, string message, SimGroup simgroup, string callback, string cancelCallback)
        {
            ((GuiWindowCtrl)"IODropdownFrame").text = title;
            //bug GuiCanvas.pushDialog doesn't seem to work the mouse right.
            ((GuiCanvas)"Canvas").pushDialog("IODropdownDlg");
            MBSetText("IODropdownText", "IODropdownFrame", message);
            GuiPopUpMenuCtrl IODropdownMenu = "IODropdownMenu";

            if (simgroup.isObject())
            {
                for (uint i = 0; i < simgroup.getCount(); i++)
                {
                    IODropdownMenu.add(simgroup.getObject(i).getName());
                }
            }

            IODropdownMenu.sort();
            IODropdownMenu.setFirstSelected(false);
            ((GuiControl)"IODropdownDlg")["callback"]       = callback;
            ((GuiControl)"IODropdownDlg")["cancelCallback"] = cancelCallback;
        }
Exemple #15
0
        public bool apply(SimGroup qualityGroup, bool testNeedApply)
        {
            string quality = getText();
            int    index   = findText(quality);

            if (index == -1)
            {
                return(false);
            }

            GraphicsQualityLevel level = qualityGroup.getObject((uint)index);

            if (level.isObject() && !level.isCurrent())
            {
                if (testNeedApply)
                {
                    return(true);
                }
                level.apply();
            }
            return(false);
        }
        public override void onActivate()
        {
            base.onActivate();

            SimGroup group = ParentGroup.As <SimGroup>();

            for (uint i = 0; i < group.getCount(); i++)
            {
                SimObject obj = group.getObject(i);

                if (obj.getId() == getId() || !obj.isMemberOfClass("SFXState"))
                {
                    continue;
                }

                SFXState state = obj.As <SFXState>();
                if (state.isActive())
                {
                    state.deactivate();
                }
            }
        }
Exemple #17
0
        public static void onServerDestroyed()
        {
            Global.physicsStopSimulation("server");

            if (!Global.isObject("MissionGroup"))
            {
                return;
            }

            Global.echo("*** ENDING MISSION");

            // Inform the game code we're done.
            Torque3D.LevelInfo TheLevelInfo = Sim.FindObject <Torque3D.LevelInfo>("TheLevelInfo");
            //todo onMissionEnded
            TheLevelInfo.call("onMissionEnded");

            SimGroup ClientGroup = Sim.FindObject <SimGroup>("ClientGroup");

            // Inform the clients
            for (uint clientIndex = 0; clientIndex < ClientGroup.getCount(); clientIndex++)
            {
                // clear ghosts and paths from all clients
                GameConnectionToClient cl = ClientGroup.getObject(clientIndex).As <GameConnectionToClient>();
                cl.endMission();
                cl.resetGhosting();
                cl.clearPaths();
            }

            SimGroup MissionGroup   = Sim.FindObject <SimGroup>("MissionGroup");
            SimGroup MissionCleanup = Sim.FindObject <SimGroup>("MissionCleanup");

            // Delete everything
            MissionGroup.delete();
            MissionCleanup.delete();

            Global.clearServerPaths();
        }
        public override void onWorldEditorStartup()
        {
            EditorGui EditorGui = "EditorGui";

            // Add ourselves to the window menu.
            string accel = EditorGui.addToEditorsMenu("Shape Editor", "", this);

            // Add ourselves to the ToolsToolbar
            string tooltip = "Shape Editor (" + accel + ")";

            EditorGui.addToToolsToolbar("ShapeEditorPlugin", "ShapeEditorPalette",
                                        Util._expandFilename("tools/worldEditor/images/toolbar/shape-editor"), tooltip);

            // Add ourselves to the Editor Settings window
            //exec( "./gui/ShapeEditorSettingsTab.gui" );
            //console.Call("ShapeEditorSettingsTab_initialize");
            ShapeEditorSettingsTab.initialize();


            ESettingsWindow ESettingsWindow = "ESettingsWindow";

            ESettingsWindow.addTabPage("EShapeEditorSettingsPage");

            ShapeEdPropWindow ShapeEdPropWindow = "ShapeEdPropWindow";

            ShapeEdPropWindow.attachTo("ShapeEdSelectWindow");
            ShapeEdAnimWindow ShapeEdAnimWindow = "ShapeEdAnimWindow";

            ShapeEdAnimWindow.resize(-1, 526, 593, 53);

            // Initialise gui
            ShapeEditor.ShapeEdSeqNodeTabBook ShapeEdSeqNodeTabBook = "ShapeEdSeqNodeTabBook";
            ShapeEdSeqNodeTabBook.selectPage(0);
            ShapeEdAdvancedWindow ShapeEdAdvancedWindow        = "ShapeEdAdvancedWindow";
            GuiTabBookCtrl        ShapeEdAdvancedWindowtabBook = ShapeEdAdvancedWindow.FOT("tabBook");

            ShapeEdAdvancedWindowtabBook.selectPage(0);

            ShapeEdSelectWindow ShapeEdSelectWindow        = "ShapeEdSelectWindow";
            GuiTabBookCtrl      ShapeEdSelectWindowtabBook = ShapeEdSelectWindow.FOT("tabBook");

            ShapeEdSelectWindowtabBook.selectPage(0);
            ShapeEdSelectWindow.navigate("");

            ShapeEditorToolbar  ShapeEditorToolbar = "ShapeEditorToolbar";
            GuiBitmapButtonCtrl orbitNodeBtn       = ShapeEditorToolbar.FOT("orbitNodeBtn");

            SetToggleButtonValue(orbitNodeBtn, "0");
            GuiBitmapButtonCtrl ghostMode = ShapeEditorToolbar.FOT("ghostMode");

            SetToggleButtonValue(ghostMode, "0");

            // Initialise hints menu
            SimGroup ShapeHintGroup = "ShapeHintGroup";

            ShapeEditor.ShapeEdHintMenu ShapeEdHintMenu = "ShapeEdHintMenu";
            ShapeEdHintMenu.clear();
            int count = ShapeHintGroup.getCount();

            for (uint i = 0; i < count; i++)
            {
                SimObject hint = ShapeHintGroup.getObject(i);
                ShapeEdHintMenu.add(hint["objectType"], hint);
            }
        }