mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 16:25:42 +00:00
Adds utility function and method to be able to enact a load of subscenes at a specific world position
Adds loadIf conditional logic to evaluate if a subscene is 'allowed' to load when tested Adds isAlwaysActive to GameMode to be able to flag a gamemode as being defaulted to on and used automatically Updated GetGameModesList function to return an arrayObject of the gamemodes found Overhauled CallGameModeFunction to utilize the gamemodes list with active/alwaysActive modes being called against, rather than level-scanning Updated ChooseLevelMenu to be able to toggle on/off multiple gamemodes with an image indicator if it's active or not
This commit is contained in:
parent
20a01d9f02
commit
e4d07c7e8d
14 changed files with 259 additions and 198 deletions
|
|
@ -391,6 +391,21 @@ Vector<SceneObject*> Scene::getObjectsByClass(String className)
|
||||||
return Vector<SceneObject*>();
|
return Vector<SceneObject*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Scene::loadAtPosition(const Point3F& position)
|
||||||
|
{
|
||||||
|
for (U32 i = 0; i < mSubScenes.size(); i++)
|
||||||
|
{
|
||||||
|
Box3F testBox = Box3F(0.5);
|
||||||
|
testBox.setCenter(position);
|
||||||
|
|
||||||
|
if (mSubScenes[i]->testBox(testBox))
|
||||||
|
{
|
||||||
|
mSubScenes[i]->setUnloadTimeMS(-1);
|
||||||
|
mSubScenes[i]->load();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DefineEngineFunction(getScene, Scene*, (U32 sceneId), (0),
|
DefineEngineFunction(getScene, Scene*, (U32 sceneId), (0),
|
||||||
"Get the root Scene object that is loaded.\n"
|
"Get the root Scene object that is loaded.\n"
|
||||||
"@return The id of the Root Scene. Will be 0 if no root scene is loaded")
|
"@return The id of the Root Scene. Will be 0 if no root scene is loaded")
|
||||||
|
|
@ -489,3 +504,9 @@ DefineEngineMethod(Scene, save, bool, (const char* fileName), (""),
|
||||||
{
|
{
|
||||||
return object->saveScene(StringTable->insert(fileName));
|
return object->saveScene(StringTable->insert(fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DefineEngineMethod(Scene, loadAtPosition, void, (Point3F position), (Point3F::Zero),
|
||||||
|
"Loads any subscenes at a given point by force.\n")
|
||||||
|
{
|
||||||
|
object->loadAtPosition(position);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,8 @@ public:
|
||||||
template <class T>
|
template <class T>
|
||||||
Vector<T*> getObjectsByClass();
|
Vector<T*> getObjectsByClass();
|
||||||
|
|
||||||
|
void loadAtPosition(const Point3F& position);
|
||||||
|
|
||||||
static Scene *getRootScene()
|
static Scene *getRootScene()
|
||||||
{
|
{
|
||||||
if (Scene::smSceneList.empty())
|
if (Scene::smSceneList.empty())
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ void SubScene::initPersistFields()
|
||||||
addGroup("SubScene");
|
addGroup("SubScene");
|
||||||
addField("isGlobalLayer", TypeBool, Offset(mGlobalLayer, SubScene), "");
|
addField("isGlobalLayer", TypeBool, Offset(mGlobalLayer, SubScene), "");
|
||||||
INITPERSISTFIELD_LEVELASSET(Level, SubScene, "The level asset to load.");
|
INITPERSISTFIELD_LEVELASSET(Level, SubScene, "The level asset to load.");
|
||||||
|
addField("loadIf", TypeCommand, Offset(mLoadIf, SubScene), "evaluation condition (true/false)");
|
||||||
addField("gameModes", TypeGameModeList, Offset(mGameModesNames, SubScene), "The game modes that this subscene is associated with.");
|
addField("gameModes", TypeGameModeList, Offset(mGameModesNames, SubScene), "The game modes that this subscene is associated with.");
|
||||||
endGroup("SubScene");
|
endGroup("SubScene");
|
||||||
|
|
||||||
|
|
@ -143,9 +144,18 @@ bool SubScene::testBox(const Box3F& testBox)
|
||||||
if (mGlobalLayer)
|
if (mGlobalLayer)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
bool isOverlapped = getWorldBox().isOverlapped(testBox);
|
bool passes = getWorldBox().isOverlapped(testBox);
|
||||||
|
if (passes && !mLoadIf.isEmpty())
|
||||||
return getWorldBox().isOverlapped(testBox);
|
{
|
||||||
|
//test the mapper plugged in condition line
|
||||||
|
String resVar = getIdString() + String(".result");
|
||||||
|
Con::setBoolVariable(resVar.c_str(), false);
|
||||||
|
String command = resVar + "=" + mLoadIf + ";";
|
||||||
|
Con::evaluatef(command.c_str());
|
||||||
|
passes = Con::getBoolVariable(resVar.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
return passes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubScene::write(Stream& stream, U32 tabStop, U32 flags)
|
void SubScene::write(Stream& stream, U32 tabStop, U32 flags)
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ private:
|
||||||
S32 mStartUnloadTimerMS;
|
S32 mStartUnloadTimerMS;
|
||||||
|
|
||||||
bool mLoaded;
|
bool mLoaded;
|
||||||
|
String mLoadIf;
|
||||||
|
|
||||||
bool mGlobalLayer;
|
bool mGlobalLayer;
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
#include "gui/containers/guiDynamicCtrlArrayCtrl.h"
|
#include "gui/containers/guiDynamicCtrlArrayCtrl.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "console/arrayObject.h"
|
||||||
|
|
||||||
IMPLEMENT_CONOBJECT(GameMode);
|
IMPLEMENT_CONOBJECT(GameMode);
|
||||||
|
|
||||||
IMPLEMENT_CALLBACK(GameMode, onActivated, void, (), (),
|
IMPLEMENT_CALLBACK(GameMode, onActivated, void, (), (),
|
||||||
|
|
@ -47,7 +49,9 @@ ConsoleSetType(TypeGameModeList)
|
||||||
|
|
||||||
GameMode::GameMode() :
|
GameMode::GameMode() :
|
||||||
mGameModeName(StringTable->EmptyString()),
|
mGameModeName(StringTable->EmptyString()),
|
||||||
mGameModeDesc(StringTable->EmptyString())
|
mGameModeDesc(StringTable->EmptyString()),
|
||||||
|
mIsActive(false),
|
||||||
|
mIsAlwaysActive(false)
|
||||||
{
|
{
|
||||||
INIT_ASSET(PreviewImage);
|
INIT_ASSET(PreviewImage);
|
||||||
}
|
}
|
||||||
|
|
@ -62,6 +66,7 @@ void GameMode::initPersistFields()
|
||||||
INITPERSISTFIELD_IMAGEASSET(PreviewImage, GameMode, "Preview Image");
|
INITPERSISTFIELD_IMAGEASSET(PreviewImage, GameMode, "Preview Image");
|
||||||
|
|
||||||
addField("active", TypeBool, Offset(mIsActive, GameMode), "Is the gamemode active");
|
addField("active", TypeBool, Offset(mIsActive, GameMode), "Is the gamemode active");
|
||||||
|
addField("alwaysActive", TypeBool, Offset(mIsAlwaysActive, GameMode), "Is the gamemode always active");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameMode::onAdd()
|
bool GameMode::onAdd()
|
||||||
|
|
@ -110,6 +115,11 @@ void GameMode::setActive(const bool& active)
|
||||||
onDeactivated_callback();
|
onDeactivated_callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameMode::setAlwaysActive(const bool& alwaysActive)
|
||||||
|
{
|
||||||
|
mIsAlwaysActive = alwaysActive;
|
||||||
|
}
|
||||||
|
|
||||||
DefineEngineMethod(GameMode, isActive, bool, (), ,
|
DefineEngineMethod(GameMode, isActive, bool, (), ,
|
||||||
"Returns if the GameMode is currently active.\n"
|
"Returns if the GameMode is currently active.\n"
|
||||||
"@return The active status of the GameMode")
|
"@return The active status of the GameMode")
|
||||||
|
|
@ -124,24 +134,38 @@ DefineEngineMethod(GameMode, setActive, void, (bool active), (true),
|
||||||
object->setActive(active);
|
object->setActive(active);
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineEngineFunction(getGameModesList, const char*, (), , "")
|
DefineEngineMethod(GameMode, isALwaysActive, bool, (), ,
|
||||||
|
"Returns if the GameMode is currently active.\n"
|
||||||
|
"@return The active status of the GameMode")
|
||||||
{
|
{
|
||||||
char* returnBuffer = Con::getReturnBuffer(1024);
|
return object->isActive();
|
||||||
|
}
|
||||||
|
|
||||||
String formattedList;
|
DefineEngineMethod(GameMode, setAlwaysActive, void, (bool alwaysActive), (true),
|
||||||
|
"Sets the active state of the GameMode.\n"
|
||||||
|
"@param active A bool of the state the GameMode should be set to")
|
||||||
|
{
|
||||||
|
object->setAlwaysActive(alwaysActive);
|
||||||
|
}
|
||||||
|
|
||||||
|
DefineEngineFunction(getGameModesList, ArrayObject*, (), , "")
|
||||||
|
{
|
||||||
|
ArrayObject* dictionary = new ArrayObject();
|
||||||
|
dictionary->registerObject();
|
||||||
|
|
||||||
|
char activeValBuffer[16];
|
||||||
|
|
||||||
for (SimGroup::iterator itr = Sim::getRootGroup()->begin(); itr != Sim::getRootGroup()->end(); itr++)
|
for (SimGroup::iterator itr = Sim::getRootGroup()->begin(); itr != Sim::getRootGroup()->end(); itr++)
|
||||||
{
|
{
|
||||||
GameMode* gm = dynamic_cast<GameMode*>(*itr);
|
GameMode* gm = dynamic_cast<GameMode*>(*itr);
|
||||||
if (gm)
|
if (gm)
|
||||||
{
|
{
|
||||||
formattedList += String(gm->getName()) + ";";
|
dSprintf(activeValBuffer, 16, "%d", (gm->mIsActive || gm->mIsAlwaysActive));
|
||||||
|
dictionary->push_back(gm->getName(), activeValBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dSprintf(returnBuffer, 1024, "%s", formattedList.c_str());
|
return dictionary;
|
||||||
|
|
||||||
return returnBuffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ private:
|
||||||
DECLARE_ASSET_SETGET(GameMode, PreviewImage);
|
DECLARE_ASSET_SETGET(GameMode, PreviewImage);
|
||||||
|
|
||||||
bool mIsActive;
|
bool mIsActive;
|
||||||
|
bool mIsAlwaysActive;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
@ -34,6 +35,9 @@ public:
|
||||||
bool isActive() { return mIsActive; }
|
bool isActive() { return mIsActive; }
|
||||||
void setActive(const bool& active);
|
void setActive(const bool& active);
|
||||||
|
|
||||||
|
bool isAlwaysActive() { return mIsAlwaysActive; }
|
||||||
|
void setAlwaysActive(const bool& alwaysActive);
|
||||||
|
|
||||||
DECLARE_CONOBJECT(GameMode);
|
DECLARE_CONOBJECT(GameMode);
|
||||||
|
|
||||||
static void findGameModes(const char* gameModeList, Vector<GameMode*>* outGameModes);
|
static void findGameModes(const char* gameModeList, Vector<GameMode*>* outGameModes);
|
||||||
|
|
|
||||||
|
|
@ -1,52 +1,22 @@
|
||||||
function callGamemodeFunction(%gameModeFuncName, %arg0, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6)
|
function callGamemodeFunction(%gameModeFuncName, %arg0, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6)
|
||||||
{
|
{
|
||||||
%activeSceneCount = getSceneCount();
|
%validGameModeCall = false;
|
||||||
|
%gamemodeList = getGameModesList();
|
||||||
%hasGameMode = 0;
|
%gameModeCount = %gamemodeList.count();
|
||||||
for(%i=0; %i < %activeSceneCount; %i++)
|
for(%i=0; %i < %gameModeCount; %i++)
|
||||||
{
|
{
|
||||||
%gamemodeName = getScene(%i).gameModeName;
|
%gameModeObj = %gamemodeList.getKey(%i);
|
||||||
if(%gamemodeName !$= "")
|
%active = %gamemodeList.getValue(%i);
|
||||||
|
|
||||||
|
if(!isObject(%gameModeObj) || !%active)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(%gameModeObj.isMethod(%gameModeFuncName))
|
||||||
{
|
{
|
||||||
//if the scene defines a game mode, go ahead and envoke it here
|
eval(%gameModeObj @ "."@%gameModeFuncName@"(\""@%arg0@"\", \""@%arg1@"\", \""@%arg2@"\", \""@%arg3@"\", \""@%arg4@"\", \""@%arg5@"\", \""@%arg6@"\");" );
|
||||||
if(isObject(%gamemodeName) && %gamemodeName.isMethod(%gameModeFuncName))
|
%validGameModeCall = true;
|
||||||
{
|
|
||||||
eval(%gamemodeName @ "."@%gameModeFuncName@"(\""@%arg0@"\", \""@%arg1@"\", \""@%arg2@"\", \""@%arg3@"\", \""@%arg4@"\", \""@%arg5@"\", \""@%arg6@"\");" );
|
|
||||||
%hasGameMode = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//if we don't have an object, attempt the static call
|
|
||||||
if(isMethod(%gamemodeName, %gameModeFuncName))
|
|
||||||
{
|
|
||||||
eval(%gamemodeName @ "::"@%gameModeFuncName@"(\""@%arg0@"\", \""@%arg1@"\", \""@%arg2@"\", \""@%arg3@"\", \""@%arg4@"\", \""@%arg5@"\", \""@%arg6@"\");" );
|
|
||||||
%hasGameMode = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if none of our scenes have gamemodes, we need to kick off a default
|
return %validGameModeCall;
|
||||||
if(%hasGameMode == 0)
|
|
||||||
{
|
|
||||||
%defaultModeName = ProjectSettings.value("Gameplay/GameModes/defaultModeName");
|
|
||||||
if(%defaultModeName !$= "")
|
|
||||||
{
|
|
||||||
if(isObject(%defaultModeName) && %defaultModeName.isMethod(%gameModeFuncName))
|
|
||||||
{
|
|
||||||
eval(%defaultModeName @ "."@%gameModeFuncName@"(\""@%arg0@"\", \""@%arg1@"\", \""@%arg2@"\", \""@%arg3@"\", \""@%arg4@"\", \""@%arg5@"\", \""@%arg6@"\");" );
|
|
||||||
%hasGameMode = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(isMethod(%defaultModeName, %gameModeFuncName))
|
|
||||||
{
|
|
||||||
eval(%defaultModeName @ "::"@%gameModeFuncName@"(\""@%arg0@"\", \""@%arg1@"\", \""@%arg2@"\", \""@%arg3@"\", \""@%arg4@"\", \""@%arg5@"\", \""@%arg6@"\");" );
|
|
||||||
%hasGameMode = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return %hasGameMode;
|
|
||||||
}
|
}
|
||||||
|
|
@ -11,7 +11,6 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
||||||
canSaveDynamicFields = "1";
|
canSaveDynamicFields = "1";
|
||||||
currentMenuIdx = "0";
|
currentMenuIdx = "0";
|
||||||
launchInEditor = "0";
|
launchInEditor = "0";
|
||||||
previewButtonSize = "445 120";
|
|
||||||
|
|
||||||
new GuiInputCtrl(ChooseLevelInputHandler) {
|
new GuiInputCtrl(ChooseLevelInputHandler) {
|
||||||
ignoreMouseEvents = "1";
|
ignoreMouseEvents = "1";
|
||||||
|
|
@ -40,8 +39,8 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
||||||
new GuiStackControl(ChooseLevelMenuTabList) {
|
new GuiStackControl(ChooseLevelMenuTabList) {
|
||||||
stackingType = "Horizontal";
|
stackingType = "Horizontal";
|
||||||
padding = "10";
|
padding = "10";
|
||||||
position = "405 61";
|
position = "485 61";
|
||||||
extent = "470 41";
|
extent = "310 41";
|
||||||
horizSizing = "center";
|
horizSizing = "center";
|
||||||
profile = "GuiDefaultProfile";
|
profile = "GuiDefaultProfile";
|
||||||
tooltipProfile = "GuiToolTipProfile";
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
|
|
@ -73,10 +72,12 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
||||||
position = "320 0";
|
position = "320 0";
|
||||||
extent = "150 41";
|
extent = "150 41";
|
||||||
profile = "GuiMenuButtonProfile";
|
profile = "GuiMenuButtonProfile";
|
||||||
|
visible = "0";
|
||||||
command = "ChooseLevelMenu.openMenu(2);";
|
command = "ChooseLevelMenu.openMenu(2);";
|
||||||
tooltipProfile = "GuiToolTipProfile";
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
internalName = "ConfigBtn";
|
internalName = "ConfigBtn";
|
||||||
class = "ChooseLevelMenuButton";
|
class = "ChooseLevelMenuButton";
|
||||||
|
hidden = "1";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
new GuiControl(ChooseLevelMenuNavButtonOverlay) {
|
new GuiControl(ChooseLevelMenuNavButtonOverlay) {
|
||||||
|
|
@ -89,7 +90,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
||||||
|
|
||||||
new GuiBitmapCtrl(ChooseLevelMenuPrevNavIcon) {
|
new GuiBitmapCtrl(ChooseLevelMenuPrevNavIcon) {
|
||||||
BitmapAsset = "UI:Keyboard_Black_Q_image";
|
BitmapAsset = "UI:Keyboard_Black_Q_image";
|
||||||
position = "405 24";
|
position = "485 24";
|
||||||
extent = "40 40";
|
extent = "40 40";
|
||||||
vertSizing = "top";
|
vertSizing = "top";
|
||||||
profile = "GuiNonModalDefaultProfile";
|
profile = "GuiNonModalDefaultProfile";
|
||||||
|
|
@ -97,7 +98,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
||||||
};
|
};
|
||||||
new GuiBitmapCtrl(ChooseLevelMenuNextNavIcon) {
|
new GuiBitmapCtrl(ChooseLevelMenuNextNavIcon) {
|
||||||
BitmapAsset = "UI:Keyboard_Black_E_image";
|
BitmapAsset = "UI:Keyboard_Black_E_image";
|
||||||
position = "515 24";
|
position = "595 24";
|
||||||
extent = "40 40";
|
extent = "40 40";
|
||||||
vertSizing = "top";
|
vertSizing = "top";
|
||||||
profile = "GuiNonModalDefaultProfile";
|
profile = "GuiNonModalDefaultProfile";
|
||||||
|
|
@ -121,8 +122,8 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
||||||
|
|
||||||
new GuiStackControl(GameModePreviewArray) {
|
new GuiStackControl(GameModePreviewArray) {
|
||||||
padding = "5";
|
padding = "5";
|
||||||
position = "0 1";
|
position = "1 1";
|
||||||
extent = "445 120";
|
extent = "443 60";
|
||||||
horizSizing = "width";
|
horizSizing = "width";
|
||||||
vertSizing = "height";
|
vertSizing = "height";
|
||||||
profile = "GuiMenuDefaultProfile";
|
profile = "GuiMenuDefaultProfile";
|
||||||
|
|
@ -130,15 +131,16 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
new GuiBitmapCtrl(GameModePreviewBitmap) {
|
new GuiBitmapCtrl(GameModePreviewBitmap) {
|
||||||
BitmapAsset = "UI:no_preview_image";
|
|
||||||
position = "448 0";
|
position = "448 0";
|
||||||
extent = "440 440";
|
extent = "440 440";
|
||||||
horizSizing = "left";
|
horizSizing = "left";
|
||||||
profile = "GuiNonModalDefaultProfile";
|
profile = "GuiNonModalDefaultProfile";
|
||||||
|
visible = "0";
|
||||||
tooltipProfile = "GuiToolTipProfile";
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
|
hidden = "1";
|
||||||
};
|
};
|
||||||
new GuiTextCtrl(GameModeNameText) {
|
new GuiTextCtrl(GameModeNameText) {
|
||||||
text = "Example Level";
|
text = "DeathMatchGame";
|
||||||
position = "448 445";
|
position = "448 445";
|
||||||
extent = "440 20";
|
extent = "440 20";
|
||||||
horizSizing = "left";
|
horizSizing = "left";
|
||||||
|
|
@ -175,7 +177,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
||||||
new GuiStackControl(LevelPreviewArray) {
|
new GuiStackControl(LevelPreviewArray) {
|
||||||
padding = "5";
|
padding = "5";
|
||||||
position = "0 1";
|
position = "0 1";
|
||||||
extent = "445 120";
|
extent = "445 60";
|
||||||
horizSizing = "width";
|
horizSizing = "width";
|
||||||
vertSizing = "height";
|
vertSizing = "height";
|
||||||
profile = "GuiMenuDefaultProfile";
|
profile = "GuiMenuDefaultProfile";
|
||||||
|
|
@ -277,6 +279,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
||||||
tooltipProfile = "GuiToolTipProfile";
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
};
|
};
|
||||||
new GuiTextEditCtrl(serverNameCTRL) {
|
new GuiTextEditCtrl(serverNameCTRL) {
|
||||||
|
text = "Torque 3D Server";
|
||||||
position = "606 4";
|
position = "606 4";
|
||||||
extent = "295 22";
|
extent = "295 22";
|
||||||
horizSizing = "left";
|
horizSizing = "left";
|
||||||
|
|
@ -374,8 +377,8 @@ $guiContent = new GuiControl(ChooseLevelMenu) {
|
||||||
profile = "GuiMenuPanelProfile";
|
profile = "GuiMenuPanelProfile";
|
||||||
tooltipProfile = "GuiToolTipProfile";
|
tooltipProfile = "GuiToolTipProfile";
|
||||||
|
|
||||||
new GuiIconButtonCtrl(ChooseLevelStartBtn) {
|
new GuiIconButtonCtrl(ChooseLevelNextBtn) {
|
||||||
BitmapAsset = "UI:Keyboard_Black_Space_image";
|
BitmapAsset = "UI:Keyboard_Black_Blank_image";
|
||||||
sizeIconToButton = "1";
|
sizeIconToButton = "1";
|
||||||
makeIconSquare = "1";
|
makeIconSquare = "1";
|
||||||
textLocation = "Center";
|
textLocation = "Center";
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ function ChooseLevelMenu::onAdd( %this )
|
||||||
if(!isObject(ChooseLevelAssetQuery))
|
if(!isObject(ChooseLevelAssetQuery))
|
||||||
new AssetQuery(ChooseLevelAssetQuery);
|
new AssetQuery(ChooseLevelAssetQuery);
|
||||||
|
|
||||||
%this.previewButtonSize = "445 120";
|
$LevelPreviewButtonSize = "445 60";
|
||||||
}
|
}
|
||||||
|
|
||||||
function ChooseLevelMenu::fillPrefEntries( %this )
|
function ChooseLevelMenu::fillPrefEntries( %this )
|
||||||
|
|
@ -40,9 +40,9 @@ function ChooseLevelMenu::fillPrefEntries( %this )
|
||||||
function ChooseLevelMenu::onWake(%this)
|
function ChooseLevelMenu::onWake(%this)
|
||||||
{
|
{
|
||||||
%this.fillPrefEntries();
|
%this.fillPrefEntries();
|
||||||
LevelPreviewArray.clear();
|
|
||||||
|
|
||||||
refreshGameModesList();
|
refreshGameModesList();
|
||||||
|
refreshLevelsList();
|
||||||
|
|
||||||
if(!$pref::HostMultiPlayer)
|
if(!$pref::HostMultiPlayer)
|
||||||
ChooseLevelTitleText.setText("SINGLE PLAYER");
|
ChooseLevelTitleText.setText("SINGLE PLAYER");
|
||||||
|
|
@ -66,35 +66,48 @@ function refreshGameModesList()
|
||||||
|
|
||||||
//popilate the gamemodes list first
|
//popilate the gamemodes list first
|
||||||
%gamemodeList = getGameModesList();
|
%gamemodeList = getGameModesList();
|
||||||
for(%i=0; %i < getTokenCount(%gamemodeList, ";"); %i++)
|
%gameModeCount = %gamemodeList.count();
|
||||||
|
|
||||||
|
for (%i=0; %i<%gameModeCount; %i++)
|
||||||
{
|
{
|
||||||
%gameModeObj = getToken(%gamemodeList, ";", %i);
|
%gameModeObj = %gamemodeList.getKey(%i);
|
||||||
|
|
||||||
if(isObject(%gameModeObj))
|
if(isObject(%gameModeObj))
|
||||||
{
|
{
|
||||||
%gameModeName = %gameModeObj.gameModeName;
|
%gameModeName = %gameModeObj.gameModeName;
|
||||||
if(%gameModeName $= "")
|
if(%gameModeName $= "")
|
||||||
%gameModeName = %gameModeObj.getName();
|
%gameModeName = %gameModeObj.getName();
|
||||||
|
|
||||||
%preview = new GuiButtonCtrl() {
|
%preview = new GuiContainer() {
|
||||||
position = "0 0";
|
position = "0 0";
|
||||||
extent = ChooseLevelMenu.previewButtonSize;
|
extent = $LevelPreviewButtonSize;
|
||||||
buttonType = "PushButton";
|
horizSizing = "right";
|
||||||
profile = GuiMenuButtonLeftJustProfile;
|
vertSizing = "bottom";
|
||||||
horizSizing = "right";
|
gameModeObj = %gameModeObj;
|
||||||
vertSizing = "bottom";
|
gameModeDesc = %gameModeObj.description;
|
||||||
internalName = "button";
|
previewImage = %gameModeObj.previewImage;
|
||||||
class = "GameModePreviewButton";
|
cansave = false;
|
||||||
//command = "ChooseGameModeBegin(" @ %i @ ");";
|
|
||||||
altCommand = "ChooseGameModeBegin(" @ %i @ ");"; //allow doubleclick to quick action it
|
new GuiToggleButtonCtrl() {
|
||||||
text = %gameModeName;
|
position = $LevelPreviewButtonSize.y SPC 0;
|
||||||
gameModeObj = %gameModeObj;
|
extent = $LevelPreviewButtonSize.x - $LevelPreviewButtonSize.y - 5 SPC $LevelPreviewButtonSize.y;
|
||||||
gameModeDesc = %gameModeObj.description;
|
profile = GuiMenuButtonProfile;
|
||||||
previewImage = %gameModeObj.previewImage;
|
horizSizing = "right";
|
||||||
textMargin = 120;
|
vertSizing = "bottom";
|
||||||
groupNum = 2;
|
internalName = "button";
|
||||||
cansave = false;
|
class = "GameModePreviewButton";
|
||||||
};
|
text = %gameModeName;
|
||||||
|
command = "ToggleGameMode(" @ %i @ ");"; //allow doubleclick to quick action it
|
||||||
|
textMargin = 120;
|
||||||
|
};
|
||||||
|
|
||||||
|
new GuiBitmapCtrl() {
|
||||||
|
position = "0 0";
|
||||||
|
extent = $LevelPreviewButtonSize.y SPC $LevelPreviewButtonSize.y;
|
||||||
|
internalName = "checkbox";
|
||||||
|
bitmapAsset = "UI:toggleMarker_image";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
GameModePreviewArray.add(%preview);
|
GameModePreviewArray.add(%preview);
|
||||||
}
|
}
|
||||||
|
|
@ -122,6 +135,7 @@ function refreshLevelsList()
|
||||||
}
|
}
|
||||||
|
|
||||||
//filter the levelAssets by the gamemode selected
|
//filter the levelAssets by the gamemode selected
|
||||||
|
%filteredIndex = 0;
|
||||||
for(%i=0; %i < %count; %i++)
|
for(%i=0; %i < %count; %i++)
|
||||||
{
|
{
|
||||||
%assetId = ChooseLevelAssetQuery.getAsset(%i);
|
%assetId = ChooseLevelAssetQuery.getAsset(%i);
|
||||||
|
|
@ -142,21 +156,26 @@ function refreshLevelsList()
|
||||||
//filter for selected gamemode
|
//filter for selected gamemode
|
||||||
%levelGameModes = %levelAsset.gameModesNames;
|
%levelGameModes = %levelAsset.gameModesNames;
|
||||||
|
|
||||||
echo("LevelAsset gamemodes: " @ %levelGameModes);
|
|
||||||
|
|
||||||
%foundGameModeMatch = false;
|
%foundGameModeMatch = false;
|
||||||
for(%gm = 0; %gm < getTokenCount(%levelGameModes, ";"); %gm++)
|
for(%gm = 0; %gm < getTokenCount(%levelGameModes, ";"); %gm++)
|
||||||
{
|
{
|
||||||
%gameModeName = getToken(%levelGameModes, ";", %gm);
|
%gameModeName = getToken(%levelGameModes, ";", %gm);
|
||||||
|
|
||||||
echo("testing gamemode: " @ %gameModeName);
|
for(%g=0; %g < GameModePreviewArray.getCount(); %g++)
|
||||||
echo("selected gamemode: " @ $pref::Server::GameMode.getName());
|
|
||||||
|
|
||||||
if(%gameModeName $= $pref::Server::GameMode.getName())
|
|
||||||
{
|
{
|
||||||
%foundGameModeMatch = true;
|
%gmb = GameModePreviewArray.getObject(%g);
|
||||||
break;
|
if(!isObject(%gmb.gameModeObj) || (!%gmb.gameModeObj.active && !%gmb.gameModeObj.alwaysActive))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(%gameModeName $= %gmb.gameModeObj.getName())
|
||||||
|
{
|
||||||
|
%foundGameModeMatch = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(%foundGameModeMatch)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!%foundGameModeMatch)
|
if(!%foundGameModeMatch)
|
||||||
|
|
@ -169,7 +188,7 @@ function refreshLevelsList()
|
||||||
|
|
||||||
%preview = new GuiIconButtonCtrl() {
|
%preview = new GuiIconButtonCtrl() {
|
||||||
position = "0 0";
|
position = "0 0";
|
||||||
extent = ChooseLevelMenu.previewButtonSize;
|
extent = $LevelPreviewButtonSize;
|
||||||
buttonType = "PushButton";
|
buttonType = "PushButton";
|
||||||
profile = GuiMenuButtonLeftJustProfile;
|
profile = GuiMenuButtonLeftJustProfile;
|
||||||
horizSizing = "right";
|
horizSizing = "right";
|
||||||
|
|
@ -177,7 +196,7 @@ function refreshLevelsList()
|
||||||
internalName = "button";
|
internalName = "button";
|
||||||
class = "LevelPreviewButton";
|
class = "LevelPreviewButton";
|
||||||
//command = "$selectedLevelAsset = " @ %assetId @ ";";
|
//command = "$selectedLevelAsset = " @ %assetId @ ";";
|
||||||
altCommand = "ChooseLevelBegin(" @ %i @ ");"; //allow doubleclick to quick action it
|
altCommand = "ChooseLevelBegin(" @ %filteredIndex @ ");"; //allow doubleclick to quick action it
|
||||||
text = %levelAsset.levelName;
|
text = %levelAsset.levelName;
|
||||||
bitmapAsset = %levelPreviewImg;
|
bitmapAsset = %levelPreviewImg;
|
||||||
levelAsset = %levelAsset;
|
levelAsset = %levelAsset;
|
||||||
|
|
@ -192,8 +211,11 @@ function refreshLevelsList()
|
||||||
};
|
};
|
||||||
|
|
||||||
LevelPreviewArray.add(%preview);
|
LevelPreviewArray.add(%preview);
|
||||||
|
|
||||||
|
%filteredIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameModePreviewArray.listPosition = 0;
|
||||||
LevelPreviewArray.listPosition = 0;
|
LevelPreviewArray.listPosition = 0;
|
||||||
|
|
||||||
// Also add the new level mission as defined in the world editor settings
|
// Also add the new level mission as defined in the world editor settings
|
||||||
|
|
@ -236,10 +258,31 @@ function ChooseLevelMenu::syncGUI(%this)
|
||||||
|
|
||||||
ChooseLevelBackBtn.setBitmap(BaseUIActionMap.getCommandButtonBitmap(%device, "BaseUIBackOut"));
|
ChooseLevelBackBtn.setBitmap(BaseUIActionMap.getCommandButtonBitmap(%device, "BaseUIBackOut"));
|
||||||
|
|
||||||
ChooseLevelStartBtn.setBitmap(ChooseLevelActionMap.getCommandButtonBitmap(%device, "ChooseLevelBegin"));
|
if(ChooseLevelMenu.currentMenuIdx == 0)
|
||||||
|
ChooseLevelNextBtn.text = "Toggle Mode";
|
||||||
|
else
|
||||||
|
ChooseLevelNextBtn.text = "Start Game";
|
||||||
|
|
||||||
|
ChooseLevelNextBtn.setBitmap(ChooseLevelActionMap.getCommandButtonBitmap(%device, "ChooseLevelMenuOption"));
|
||||||
|
|
||||||
ChooseLevelMenuPrevNavIcon.setBitmap(ChooseLevelActionMap.getCommandButtonBitmap(%device, "ChooseLevelMenuPrevMenu"));
|
ChooseLevelMenuPrevNavIcon.setBitmap(ChooseLevelActionMap.getCommandButtonBitmap(%device, "ChooseLevelMenuPrevMenu"));
|
||||||
ChooseLevelMenuNextNavIcon.setBitmap(ChooseLevelActionMap.getCommandButtonBitmap(%device, "ChooseLevelMenuNextMenu"));
|
ChooseLevelMenuNextNavIcon.setBitmap(ChooseLevelActionMap.getCommandButtonBitmap(%device, "ChooseLevelMenuNextMenu"));
|
||||||
|
|
||||||
|
%hasActiveGameMode = false;
|
||||||
|
for(%i=0; %i < GameModePreviewArray.getCount(); %i++)
|
||||||
|
{
|
||||||
|
%btn = GameModePreviewArray.getObject(%i);
|
||||||
|
if(!isObject(%btn.gameModeObj))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if((%btn.gameModeObj.isActive() || %btn.gameModeObj.isAlwaysActive()) == true)
|
||||||
|
{
|
||||||
|
%hasActiveGameMode = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ChooseLevelMenuTabList-->LevelBtn.active = %hasActiveGameMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
function LevelPreviewArray::syncGUI(%this)
|
function LevelPreviewArray::syncGUI(%this)
|
||||||
|
|
@ -252,10 +295,19 @@ function LevelPreviewArray::syncGUI(%this)
|
||||||
|
|
||||||
function GameModePreviewArray::syncGUI(%this)
|
function GameModePreviewArray::syncGUI(%this)
|
||||||
{
|
{
|
||||||
%btn = %this.getObject(%this.listPosition);
|
for(%i=0; %i < %this.getCount(); %i++)
|
||||||
%btn.setHighlighted(true);
|
{
|
||||||
|
%btn = %this.getObject(%i);
|
||||||
|
%btn-->button.setHighlighted(false);
|
||||||
|
|
||||||
|
%bitmapAst = (%btn.gameModeObj.active || %btn.gameModeObj.alwaysActive) ? "UI:toggleMarker_h_image" : "UI:toggleMarker_image";
|
||||||
|
%btn-->checkbox.setBitmap(%bitmapAst);
|
||||||
|
}
|
||||||
|
|
||||||
$pref::Server::GameMode = %btn.gameModeObject;
|
%btn = %this.getObject(%this.listPosition);
|
||||||
|
%btn-->button.setHighlighted(true);
|
||||||
|
|
||||||
|
//$pref::Server::GameMode = %btn.gameModeObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ChooseLevelMenuPrevMenu(%val)
|
function ChooseLevelMenuPrevMenu(%val)
|
||||||
|
|
@ -270,6 +322,13 @@ function ChooseLevelMenuPrevMenu(%val)
|
||||||
%endIndex = 2;
|
%endIndex = 2;
|
||||||
|
|
||||||
ChooseLevelMenu.currentMenuIdx = mClamp(ChooseLevelMenu.currentMenuIdx, 0, %endIndex);
|
ChooseLevelMenu.currentMenuIdx = mClamp(ChooseLevelMenu.currentMenuIdx, 0, %endIndex);
|
||||||
|
|
||||||
|
//bail if we're trying to step into a hidden or disabled menu
|
||||||
|
if(!ChooseLevelMenu.isMenuAvailable(ChooseLevelMenu.currentMenuIdx))
|
||||||
|
{
|
||||||
|
ChooseLevelMenu.currentMenuIdx = %currentIdx;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(%currentIdx == ChooseLevelMenu.currentMenuIdx)
|
if(%currentIdx == ChooseLevelMenu.currentMenuIdx)
|
||||||
return;
|
return;
|
||||||
|
|
@ -290,6 +349,13 @@ function ChooseLevelMenuNextMenu(%val)
|
||||||
%endIndex = 2;
|
%endIndex = 2;
|
||||||
|
|
||||||
ChooseLevelMenu.currentMenuIdx = mClamp(ChooseLevelMenu.currentMenuIdx, 0, %endIndex);
|
ChooseLevelMenu.currentMenuIdx = mClamp(ChooseLevelMenu.currentMenuIdx, 0, %endIndex);
|
||||||
|
|
||||||
|
//bail if we're trying to step into a hidden or disabled menu
|
||||||
|
if(!ChooseLevelMenu.isMenuAvailable(ChooseLevelMenu.currentMenuIdx))
|
||||||
|
{
|
||||||
|
ChooseLevelMenu.currentMenuIdx = %currentIdx;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(%currentIdx == ChooseLevelMenu.currentMenuIdx)
|
if(%currentIdx == ChooseLevelMenu.currentMenuIdx)
|
||||||
return;
|
return;
|
||||||
|
|
@ -319,33 +385,48 @@ function ChooseLevelMenu::openMenu(%this, %menuIdx)
|
||||||
%this.syncGui();
|
%this.syncGui();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ChooseLevelMenu::isMenuAvailable(%this, %menuIdx)
|
||||||
|
{
|
||||||
|
if(%menuIdx == 0)
|
||||||
|
%btn = %this-->GameModeBtn;
|
||||||
|
else if(%menuIdx == 1)
|
||||||
|
%btn = %this-->LevelBtn;
|
||||||
|
else if(%menuIdx == 2)
|
||||||
|
%btn = %this-->ConfigBtn;
|
||||||
|
|
||||||
|
return %btn.isActive() && %btn.isVisible();
|
||||||
|
}
|
||||||
|
|
||||||
function ChooseLevelMenuOption(%val)
|
function ChooseLevelMenuOption(%val)
|
||||||
{
|
{
|
||||||
if(%val)
|
if(%val)
|
||||||
{
|
{
|
||||||
if(ChooseLevelMenu.currentMenuIdx == 0)
|
if(ChooseLevelMenu.currentMenuIdx == 0)
|
||||||
ChooseGameModeBegin(ChooseLevelMenu.listPosition);
|
ToggleGameMode(ChooseLevelMenu.listPosition);
|
||||||
else if(ChooseLevelMenu.currentMenuIdx == 1)
|
else if(ChooseLevelMenu.currentMenuIdx == 1)
|
||||||
ChooseLevelBegin(ChooseLevelMenu.listPosition);
|
ChooseLevelBegin(ChooseLevelMenu.listPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ChooseGameModeBegin(%index)
|
function ToggleGameMode(%index)
|
||||||
{
|
{
|
||||||
|
if(%index $= "")
|
||||||
|
%index = $MenuList.listPosition;
|
||||||
|
|
||||||
%entry = GameModePreviewArray.getObject(%index);
|
%entry = GameModePreviewArray.getObject(%index);
|
||||||
if(!isObject(%entry) || !isObject(%entry.gameModeObj))
|
if(!isObject(%entry) || !isObject(%entry.gameModeObj))
|
||||||
{
|
{
|
||||||
MessageBoxOK("Error", "Selected game mode does not have a valid mode");
|
MessageBoxOK("Error", "Selected game mode does not have a valid mode");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pref::Server::GameMode = %entry.gameModeObj;
|
%entry.gameModeObj.active = !%entry.gameModeObj.active;
|
||||||
|
|
||||||
ChooseLevelMenuTabList-->LevelBtn.active = true;
|
|
||||||
|
|
||||||
refreshLevelsList();
|
refreshLevelsList();
|
||||||
|
|
||||||
ChooseLevelMenu.openMenu(1);
|
$MenuList.syncGui();
|
||||||
|
ChooseLevelMenu.syncGui();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function ChooseLevelBegin(%index)
|
function ChooseLevelBegin(%index)
|
||||||
|
|
@ -399,7 +480,7 @@ function GameModePreviewButton::onHighlighted(%this, %highlighted)
|
||||||
{
|
{
|
||||||
if(%highlighted)
|
if(%highlighted)
|
||||||
{
|
{
|
||||||
$MenuList.listPosition = $MenuList.getObjectIndex(%this);
|
$MenuList.listPosition = $MenuList.getObjectIndex(%this.getParent());
|
||||||
|
|
||||||
GameModePreviewBitmap.bitmapAsset = %this.previewImage;
|
GameModePreviewBitmap.bitmapAsset = %this.previewImage;
|
||||||
|
|
||||||
|
|
|
||||||
BIN
Templates/BaseGame/game/data/UI/images/toggleMarker.png
Normal file
BIN
Templates/BaseGame/game/data/UI/images/toggleMarker.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.6 KiB |
BIN
Templates/BaseGame/game/data/UI/images/toggleMarker_h.png
Normal file
BIN
Templates/BaseGame/game/data/UI/images/toggleMarker_h.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.6 KiB |
|
|
@ -0,0 +1,3 @@
|
||||||
|
<ImageAsset
|
||||||
|
AssetName="toggleMarker_h_image"
|
||||||
|
imageFile="@assetFile=toggleMarker_h.png"/>
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<ImageAsset
|
||||||
|
AssetName="toggleMarker_image"
|
||||||
|
imageFile="@assetFile=toggleMarker.png"/>
|
||||||
|
|
@ -1,96 +1,35 @@
|
||||||
function AssetBrowser::createGameMode(%this)
|
AssetBrowser::registerObjectType("GameModeType", "Gamemode Objects", "Gamemode");
|
||||||
|
|
||||||
|
function GameModeType::setupCreateNew()
|
||||||
{
|
{
|
||||||
%moduleName = AssetBrowser.newAssetSettings.moduleName;
|
|
||||||
%moduleDef = ModuleDatabase.findModule(%moduleName, 1);
|
|
||||||
|
|
||||||
%assetName = AssetBrowser.newAssetSettings.assetName;
|
|
||||||
%assetPath = NewAssetTargetAddress.getText() @ "/";
|
|
||||||
|
|
||||||
%scriptPath = %assetPath @ %assetName @ "." @ $TorqueScriptFileExtension;
|
}
|
||||||
%fullScriptPath = makeFullPath(%scriptPath);
|
|
||||||
|
|
||||||
%file = new FileObject();
|
function GameModeType::onCreateNew()
|
||||||
%templateFile = new FileObject();
|
{
|
||||||
|
|
||||||
%postFXTemplateCodeFilePath = %this.templateFilesPath @ "gameMode." @ $TorqueScriptFileExtension @ ".template";
|
|
||||||
|
|
||||||
if(%file.openForWrite(%fullScriptPath) && %templateFile.openForRead(%postFXTemplateCodeFilePath))
|
}
|
||||||
{
|
|
||||||
while( !%templateFile.isEOF() )
|
|
||||||
{
|
|
||||||
%line = %templateFile.readline();
|
|
||||||
%line = strreplace( %line, "@@", %assetName );
|
|
||||||
|
|
||||||
%file.writeline(%line);
|
|
||||||
}
|
|
||||||
|
|
||||||
%file.close();
|
|
||||||
%templateFile.close();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
%file.close();
|
|
||||||
%templateFile.close();
|
|
||||||
|
|
||||||
warnf("createGameMode - Something went wrong and we couldn't write the gameMode script file!");
|
|
||||||
}
|
|
||||||
|
|
||||||
%localScriptPath = strReplace(%scriptPath, "data/" @ %moduleName @ "/", "./");
|
function GameModeType::buildBrowserElement(%this, %className, %previewData)
|
||||||
%execLine = " %this.queueExec(\"" @ %localScriptPath @ "\");";
|
{
|
||||||
|
//echo("DatablockObjectType::buildBrowserElement() - " @ %datablock @ ", " @ %name @ ", " @ %previewData);
|
||||||
|
%previewData.assetName = %this.getName();
|
||||||
|
%previewData.assetPath = %this.getFileName();
|
||||||
|
|
||||||
%moduleScriptPath = makeFullPath(%moduleDef.ModuleScriptFilePath @ "." @ $TorqueScriptFileExtension);
|
%previewData.previewImage = "ToolsModule:genericAssetIcon_image";
|
||||||
|
|
||||||
echo("Attempting exec insert for file: " @ %moduleScriptPath);
|
//Lets see if we have a icon for specifically for this datablock type
|
||||||
|
%dataClass = %this.getClassName();
|
||||||
|
%dataClass = strreplace(%dataClass, "Data", "");
|
||||||
|
|
||||||
%lineIdx = Tools::findInFile(%moduleScriptPath, "*function*" @ %moduleName @ "::initClient*");
|
%previewImage = "tools/classIcons/" @ %dataClass @ ".png";
|
||||||
if(%lineIdx != -1)
|
if(isFile(%previewImage))
|
||||||
{
|
{
|
||||||
echo("INIT CLIENT FUNCTION LINE FOUND ON: " @ %lineIdx);
|
%previewData.previewImage = %previewImage;
|
||||||
|
|
||||||
%insertLineIdx = Tools::findInFunction(%moduleScriptPath, %moduleName, "initClient", "*//--FILE EXEC END--*");
|
|
||||||
echo("FILE EXEC END LINE FOUND ON: " @ %insertLineIdx);
|
|
||||||
|
|
||||||
if(%insertLineIdx == -1)
|
|
||||||
{
|
|
||||||
//If there are not 'blocking' comments, then just slap the exec on the end of the function def
|
|
||||||
//as it doesn't really matter now
|
|
||||||
Tools::appendLineToFunction(%moduleScriptPath, %moduleName, "initClient", %execLine);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Tools::insertInFile(%moduleScriptPath, %insertLineIdx, %execLine, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%lineIdx = Tools::findInFile(%moduleScriptPath, "*function*" @ %moduleName @ "::initServer*");
|
//%previewData.assetFriendlyName = %assetDef.assetName;
|
||||||
if(%lineIdx != -1)
|
%previewData.assetDesc = %this;
|
||||||
{
|
%previewData.tooltip = "\nGameMode Name: " @ %previewData.assetName @
|
||||||
echo("INIT SERVER FUNCTION LINE FOUND ON: " @ %lineIdx);
|
"\nPath: " @ %previewData.assetPath;
|
||||||
|
|
||||||
%insertLineIdx = Tools::findInFunction(%moduleScriptPath, %moduleName, "initServer", "*//--FILE EXEC END--*");
|
|
||||||
echo("FILE EXEC END LINE FOUND ON: " @ %insertLineIdx);
|
|
||||||
|
|
||||||
if(%insertLineIdx == -1)
|
|
||||||
{
|
|
||||||
//If there are not 'blocking' comments, then just slap the exec on the end of the function def
|
|
||||||
//as it doesn't really matter now
|
|
||||||
Tools::appendLineToFunction(%moduleScriptPath, %moduleName, "initServer", %execLine);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Tools::insertInFile(%moduleScriptPath, %insertLineIdx, %execLine, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//and we'll go ahead and force execute the script file so the gamemode is 'available' for use immediately
|
|
||||||
exec(%scriptPath);
|
|
||||||
|
|
||||||
if(isObject(%assetName))
|
|
||||||
{
|
|
||||||
//it's possible it got moved to an instant group upon execution, so we'll just
|
|
||||||
//shove it back to the RootGroup by force to be 100% sure
|
|
||||||
RootGroup.add(%assetName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return %scriptPath;
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue