tge/example/starter.fps/client/ui/startMissionGui.gui
2017-04-17 06:17:10 -06:00

219 lines
6.0 KiB
Plaintext
Executable File

//--- OBJECT WRITE BEGIN ---
new GuiChunkedBitmapCtrl(startMissionGui) {
profile = "GuiContentProfile";
horizSizing = "width";
vertSizing = "height";
position = "0 0";
extent = "640 480";
minExtent = "8 8";
visible = "1";
bitmap = "./background";
useVariable = "0";
tile = "0";
helpTag = "0";
new GuiControl() {
profile = "GuiWindowProfile";
horizSizing = "center";
vertSizing = "center";
position = "92 86";
extent = "455 308";
minExtent = "8 8";
visible = "1";
helpTag = "0";
new GuiTextCtrl() {
profile = "GuiTextProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "12 36";
extent = "72 18";
minExtent = "8 8";
visible = "1";
text = "Select Mission:";
maxLength = "255";
helpTag = "0";
};
new GuiCheckBoxCtrl(ML_isMultiplayer) {
profile = "GuiCheckBoxProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "155 272";
extent = "147 23";
minExtent = "8 8";
visible = "1";
variable = "pref::HostMultiPlayer";
text = "Host Multiplayer";
groupNum = "-1";
buttonType = "ToggleButton";
helpTag = "0";
maxLength = "255";
};
new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "320 271";
extent = "127 23";
minExtent = "8 8";
visible = "1";
command = "SM_StartMission();";
text = "Launch Mission!";
groupNum = "-1";
buttonType = "PushButton";
helpTag = "0";
};
new GuiScrollCtrl() {
profile = "GuiScrollProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "10 62";
extent = "436 200";
minExtent = "8 8";
visible = "1";
willFirstRespond = "1";
hScrollBar = "dynamic";
vScrollBar = "alwaysOn";
constantThumbHeight = "0";
childMargin = "0 0";
helpTag = "0";
defaultLineHeight = "15";
new GuiTextListCtrl(SM_missionList) {
profile = "GuiTextArrayProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "2 2";
extent = "414 16";
minExtent = "8 8";
visible = "1";
enumerate = "0";
resizeCell = "1";
columns = "0";
fitParentWidth = "1";
clipColumnText = "0";
helpTag = "0";
noDuplicates = "false";
};
};
new GuiTextEditCtrl() {
profile = "GuiTextEditProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "98 15";
extent = "134 18";
minExtent = "8 8";
visible = "1";
variable = "pref::Player::Name";
maxLength = "255";
historySize = "0";
password = "0";
tabComplete = "0";
sinkAllKeyEvents = "0";
helpTag = "0";
};
new GuiTextCtrl() {
profile = "GuiTextProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "12 11";
extent = "63 18";
minExtent = "8 8";
visible = "1";
text = "Player Name:";
maxLength = "255";
helpTag = "0";
};
new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "10 272";
extent = "127 23";
minExtent = "8 8";
visible = "1";
command = "Canvas.setContent(mainMenuGui);";
text = "<< Back";
groupNum = "-1";
buttonType = "PushButton";
helpTag = "0";
};
};
};
//--- OBJECT WRITE END ---
//----------------------------------------
function SM_StartMission()
{
%id = SM_missionList.getSelectedId();
%mission = getField(SM_missionList.getRowTextById(%id), 1);
if ($pref::HostMultiPlayer)
%serverType = "MultiPlayer";
else
%serverType = "SinglePlayer";
createServer(%serverType, %mission);
%conn = new GameConnection(ServerConnection);
RootGroup.add(ServerConnection);
%conn.setConnectArgs($pref::Player::Name);
%conn.setJoinPassword($Client::Password);
%conn.connectLocal();
}
//----------------------------------------
function startMissionGui::onWake()
{
SM_missionList.clear();
%i = 0;
for(%file = findFirstFile($Server::MissionFileSpec); %file !$= ""; %file = findNextFile($Server::MissionFileSpec))
if (strStr(%file, "/CVS/") == -1)
SM_missionList.addRow(%i++, getMissionDisplayName(%file) @ "\t" @ %file );
SM_missionList.sort(0);
SM_missionList.setSelectedRow(0);
SM_missionList.scrollVisible(0);
}
//----------------------------------------
function getMissionDisplayName( %missionFile )
{
%file = new FileObject();
%MissionInfoObject = "";
if ( %file.openForRead( %missionFile ) ) {
%inInfoBlock = false;
while ( !%file.isEOF() ) {
%line = %file.readLine();
%line = trim( %line );
if( %line $= "new ScriptObject(MissionInfo) {" )
%inInfoBlock = true;
else if( %inInfoBlock && %line $= "};" ) {
%inInfoBlock = false;
%MissionInfoObject = %MissionInfoObject @ %line;
break;
}
if( %inInfoBlock )
%MissionInfoObject = %MissionInfoObject @ %line @ " ";
}
%file.close();
}
%MissionInfoObject = "%MissionInfoObject = " @ %MissionInfoObject;
eval( %MissionInfoObject );
%file.delete();
if( %MissionInfoObject.name !$= "" )
return %MissionInfoObject.name;
else
return fileBase(%missionFile);
}