Brought up to date with the newest T2BoL I've located

This commit is contained in:
Robert MacGregor 2015-08-30 02:30:29 -04:00
parent 8c96cba3e1
commit accd31895e
287 changed files with 108557 additions and 107608 deletions

View file

@ -0,0 +1,334 @@
//------------------------------------------------------------------------------
// Scripts/RPGBrowserGUI.cs
// One of the highlights of T2Bol.
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
function RPGBrowserGui::onWake(%this)
{
if (RPGBrowserGui.pane $= "")
RPG_NewsPane.onActivate();
LaunchTabView.viewTab( "MOD BROWSER", RPGBrowserGui, 0 );
Canvas.pushDialog( LaunchToolbarDlg );
// This is essentially an "isInitialized" flag...
if ( RPG_TabView.tabCount() == 0 )
{
RPG_TabView.addSet(1, "gui/shll_horztabbuttonB", "5 5 5", "50 50 0", "5 5 5" );
RPG_TabView.addTab(1,"NEWS",1);
RPG_TabView.setSelected( 1 );
RPG_TabView.addTab(2,"ENCYCLOPEDIA");
RPG_TabView.addTab(3,"DOWNLOADS");
RPG_TabView.setTabActive(3,0);
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
function RPGBrowserGui::onSleep(%this)
{
%ctrl = "RPG_" @ %this.pane @ "Pane";
if ( isObject( %ctrl ) )
%ctrl.onDeactivate();
}
//------------------------------------------------------------------------------
function BrowserDoSave() //A good ol' converter for browser files. Should work on ANY browser file. Including ones that you insert yourself.
{
%file = new fileObject();
%item = RPG_ItemList.getValue();
%category = RPG_Category.getValue();
%file.openForWrite("savedDocs/" @ %item @ ".txt");
%read = new fileObject();
%read.openForRead("Data/Browser/" @ %category @ "/" @ %item @ ".txt");
%skip = false;
while (!%read.isEOF())
{
%line = %read.readLine();
%lineTest = strLwr(strReplace(%line," ","")); //strip spaces to test for tags to skip
%spush = getSubStr(%lineTest,0,7);
%just = getSubStr(%lineTest,0,6);
//Ok.. we need to cipher out some useless information before we're through
if (%just !$= "<just:")
{
if (%spush $= "<spush>")
%skip = true;
if (%skip == true) //Try to find our <spop> tag
{
%search = strStr(%lineTest,"<spop>");
if (%search != -1)
%skip = false; //We found our <spop> tag, set %skip to false for the next turn
}
else //Otherwise the data is safe -- but we still got to look for my special <a:select> tag
{
%select = strStr(%lineTest,"<a:select");
if (%select != -1) //It exists -- we must convert it
{
%line = strReplace(%line,"-","\t"); //Apparently special tags don't work when read from a file, so the negative sign represents \t
%tag = strStr(%line,"<a:select"); //Find the position of my select tag
if (%tag != -1) //Ok, it exists. We need to grab our entire tag as a string
{
%start = strStr(%line,"<");
for (%i = 0; %i < strLen(%line); %i++)
{
%testC = getSubStr(%line, %i + %start, 3);
if (%testC $= "</a")
{
%end = %i;
break;
}
}
}
}
if (%line !$= "") //If the line is totally blank, don't do shit. Otherwise, attempt to space out the file (for easier read)
{
for (%i = 0; %i < strLen(%line); %i++) //Was up a little higher in the function; figured it should be moved down here
{
%test = getSubStr(%line,%i,9);
if (%test $= "<a:select") //We found a select tag.
{
%start = %i;
%end = strLen(%line) - strStr(%line,"</a>") - 3;
%test = getSubStr(%line,%start,%end);
%str = getWord(%test,0);
%line = strReplace(%line,%str,getNameFromSelectTag(%str));
}
}
for (%i = 0; %i < strLen(%line); %i++)
{
%sub = getSubStr(%line, %i, 1);
if (%sub $= ".") //Ok, we found a period. %i is where we are in the string. So we grab everything up until this period and move on
{
%file.writeLine(getSubStr(%line, 0, %i+1));
%line = getSubStr(%line, %i+1, strLen(%line));
}
}
}
}
}
}
//Detach our file objects (scripts/fileProcessing.cs)
%file.detach();
%read.detach();
messageBoxOk("SUCCESS","The contents of item "@%item@" in category "@%category@" have been saved. Check your mod Directory's sub-dir, /savedDocs for "@%item@".txt."); //YES! After all that the file should be good.
return true;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
function getNameFromSelectTag(%string) //Since the tag should be directly inserted, there is no start.
{
%len = strLen(%string);
%start = strStr(%string,">");
%end = strStr(%string,"</a>");
%sub = getSubStr(%string,%start,%end);
%sub = stripTrailingSpaces(stripChars(strReplace(%sub,"</a>",""),">"));
return %sub;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
function RPGBrowserGui::setKey( %this, %key )
{
// To avoid console error
}
//------------------------------------------------------------------------------
function RPGBrowserGui::onClose( %this, %key )
{
// To avoid console error
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// News pane:
//------------------------------------------------------------------------------
function RPG_NewsPane::onActivate(%this)
{
RPGBrowserGui.pane = "News";
}
//------------------------------------------------------------------------------
function RPG_NewsPane::onDeactivate(%this)
{
//RPGBrowserGui.pane = "News";
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Browser pane:
//------------------------------------------------------------------------------
function RPG_BrowserPane::onActivate(%this)
{
RPGBrowserGui.pane = "Browser";
RPG_Category.PopulateList();
//Make sure our DL button is properly placed (resolution may have changed)
RPG_DownloadButton.setPosition("5", getWord(Canvas.getExtent(), 1) - 163);
RPG_BrowserPane.refresh();
}
//------------------------------------------------------------------------------
function RPG_BrowserPane::Refresh(%this,%val)
{
//Ok, we must make the browser dynamic for convenience.
%text = RPG_Category.getText();
if (%text $= "Select Category" || %text $= "")
return RPG_Text.readFromFile("Data/Browser/Introduction.txt");
RPG_ItemList.clear();
%path = "Data/Game/" @ %text @ "/*.des";
%count = 0;
for( %file = findFirstFile( %path ); %file !$= ""; %file = findNextFile( %path ) )
{
%name = getFileNameFromString(strReplace(%file,".des","")); //Get the fileName from our string (used in the item List)
if (%name !$= "Introduction")
{
RPG_ItemList.addRow(%count, %name);
%count++;
}
}
RPG_ItemList.sortNumerical(0,0); //Sort the items from A-Z
//RPG_ItemList.setSelectedRow(RPG_ItemList.findTextIndex($Browser::SelectedText));
RPG_ItemList.setSelectedRow(RPGBrowserGUI.selectedID[%text]);
}
//------------------------------------------------------------------------------
function RPG_BrowserPane::onDeactivate(%this)
{
//RPGBrowserGui.pane = "Browser";
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Downloads pane:
//------------------------------------------------------------------------------
function RPG_DownloadsPane::onActivate(%this)
{
RPGBrowserGui.pane = "Downloads";
}
//------------------------------------------------------------------------------
function RPG_DownloadsPane::onDeactivate(%this)
{
//RPGBrowserGui.pane = "Downloads";
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
function RPG_TabView::onSelect( %this, %id, %text )
{
RPG_BrowserPane.setVisible( %id == 2 );
RPG_NewsPane.setVisible( %id == 1 );
%ctrl = "RPG_" @ RPGBrowserGui.pane @ "Pane";
if ( isObject( %ctrl ) )
%ctrl.onDeactivate();
switch ( %id )
{
case 1: // News
RPG_NewsPane.onActivate();
case 2: // Encyclopedia
RPG_BrowserPane.onActivate();
case 3: // Downloads
RPG_DownloadsPane.onActivate();
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
function RPG_Category::PopulateList() //Listing is now alphabatized
{
RPG_Category.clear();
%file = "Data/Game/encyclopediaData.txt";
%count = getBlockData(%file,"Encyclopedia",1,"categoryCount");
RPG_Category.count = %count;
for (%i = 0; %i < %count; %i++)
{
%category = getBlockData(%file,"Encyclopedia",1,"category" @ %i);
RPG_Category.add(%category,%i);
}
if (RPG_Category.selected !$= "") //Fixes the category dropdown resetting
RPG_Category.setSelected(RPG_Category.selected);
else
RPG_Category.setValue("Select Category");
//Force the browser to have an introduction.
RPG_Text.readFromFile("Data/Game/Encyclopedia_Intro.des");
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
function RPG_Category::onSelect(%this, %id, %text)
{
RPG_ItemList.clear();
RPG_Text.setValue("");
RPG_Category.selected = %id;
RPG_Text.readFromFile("Data/Game/" @ %text @ "/Introduction.des"); //Display the intro for the category we selected
RPG_BrowserPane.refresh();
if (RPG_ItemList.getSelectedID() == -1) //Does our button really need to be inactive?
RPG_DownloadButton.setActive(false); //YES!
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
function RPG_ItemList::onSelect(%this, %id, %text)
{
$Browser::SelectedText = %text;
RPG_DownloadButton.setActive(true);
%category = RPG_Category.getvalue();
RPGBrowserGUI.selectedID[%category] = %id;
RPG_Text.readFromFile("Data/Game/" @ %category @ "/" @ %text @ ".des");
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
function RPG_Text::readFromFile(%this,%file)
{
RPG_Text.setValue(""); //Clear the info, for some odd reason .clear() won't work..
if (!IsFile(%file))
return -1;
%fileobj = new FileObject();
%fileobj.openForRead(%file);
while (!%fileobj.isEOF())
{
%line = %fileobj.readLine() @ "\n";
RPG_Text.addText(%line,1);
}
%fileobj.detach();
}
//------------------------------------------------------------------------------
RPG_DownloadButton.setActive(false); //Eh.. for some reason setting isActive in the GUI file isn't working

View file

@ -0,0 +1,97 @@
//------------------------------------------------------------------------------
// Scripts/DO_NOT_DELETE/clientFunctions.cs (OPEN SOURCE)
// If you see this text, you have obtained the official copy of this file from
// one of the developers. Otherwise, your decompiler is so advanced that it can
// somehow get commented lines in a script. If this is not the case, someone has
// betrayed my trust.
// -- Dark Dragon DX (as of 2011).
//------------------------------------------------------------------------------
//Different from modVersionText, is used to compare our mod to the update server
//Since TribesNext will soon allow binary transfers, this is stored here.
$ModVersion = 1.0; //Looks better as whole numbuhs
//All clientCmds are secured here (so certain funcs can't simply just be disabled)
//Although, hooks can be attached for custom actions.
function clientCmdHandleScriptedCommand(%num,%arg1,%arg2,%arg3,%arg4)
{
switch(%num)
{
case 0: //Pop Dialog
Canvas.popDialog(%arg1);
case 1: //BoxYesNo
messageBoxYesNo(%arg1,%arg2,%arg3,%arg4);
case 2: //FadeIn
ServerConnection.setBlackOut(true, %arg1);
case 3: //Fadeout
ServerConnection.setBlackOut(false, %arg1);
case 4: //Show Cursor
$cursorControlled = %arg1;
lockMouse(%arg1);
if (%arg1)
{
Canvas.cursorOn();
GlobalActionMap.bind(mouse, button0, RTS_LeftButton);
GlobalActionMap.bind(mouse, button1, RTS_RightButton);
RTS_Command.push();
$RTS::ButtonPress = false;
}
else
{
Canvas.cursorOff();
GlobalActionMap.unbind(mouse, button0);
GlobalActionMap.unbind(mouse, button1);
Canvas.setCursor(DefaultCursor);
RTS_Command.pop();
$RTS::ButtonPress = true;
}
case 5: //Verify Client
if (%arg1)
ScoreParent.settext("PDA - PERSONAL DATA ASSISTANT");
$Pref::LANAccount::GUID = stripNonNumericCharacters($Pref::LANAccount::GUID); //Make sure the GUID is pure before sending. Monkee, you won't be breaking anything here. The server does the same on its side. :)
//Let the server know we're an actual client.. and if we're offline, send my GUID
if (!$PlayingOnline)
commandToServer('VerifyClient',$Pref::LANAccount::GUID,$ModVersion);
else
commandToServer('VerifyClient',0,$ModVersion);
//Turn off the 'continue' button if it's T2Bol.
if (%arg2)
DB_ContinueBTN.setActive(0);
case 6: //Is RTS Game
hudClusterBack.opacity = 0; //Make it invisible
clientCmdHandleScriptedCommand(4,true); //Show our cursor
case 7: //Music fadeout
alxMusicFadeout($Pref::Audio::MusicVolume);
case 8: //Music Fadein
alxMusicFadein(0);
case 9: //Set client Time
clockHud.setVisible(0);
%pos = ClockHud.getPosition();
%x = getWord(%pos,0);
%y = getWord(%pos,1);
%x = %x - -14;
%y = %y - -4;
if (!IsObject(timeHud))
{
new GuiTextCtrl(timeHud)
{
profile ="ClockProfile";
position = %x SPC %y;
extent = "41 12";
text = %arg1 SPC "Hrs";
horizSizing = "left";
vertSizing = "bottom";
};
playGui.add(timeHud);
}
timeHud.setValue(%arg1);
timeHud.setVisible(1);
default: //If for some reason we got an invalid command ID, report it to console
if ($Pref::DeveloperMode) //If dev mode is on (just a value set on the clientside to tell scripts to echo shit to the console)
error("Scripted Command Handler: Received unknown command request ("@%num@") from server.");
return false;
}
return true;
}

View file

@ -0,0 +1,9 @@
//------------------------------------------------------------------------------
// initialise.cs
// Client Scripts Init
// Copright (c) 2012 The DarkDragonDX
//==============================================================================
exec("scripts/modScripts/client/clientFunctions.cs");
exec("scripts/modScripts/client/serverRequestHandler.cs");
exec("scripts/modScripts/client/RPGBrowserGUI.cs");

View file

@ -0,0 +1,7 @@
//------------------------------------------------------------------------------
// initialise.cs
// Client Scripts Init
// Copright (c) 2012 The DarkDragonDX
//==============================================================================
exec("scripts/modScripts/client/clientFunctions.cs");
exec("scripts/modScripts/client/serverRequestHandler.cs");

View file

@ -0,0 +1,218 @@
//------------------------------------------------------------------------------
// serverRequestHandler.cs
// Server Request Handler
// Copyright (c) 2012 The DarkDragonDX
//==============================================================================
function InteractWithObject(%val)
{
}
function IcreaseRadioFrequency(%val)
{
}
function DecreaseRadioFrequency(%val)
{
}
//These are just here.. just in case.
function OnLANPasswordInput()
{
return 1;
}
function OnLANNameInput()
{
return 1;
}
function clientCmdSetScoreText(%text)
{
ScoreParent.settext(%text);
return 1;
}
function alxMusicFadeout(%startvol)
{
%startvol = %startvol - 0.1;
if (%startvol <= 0)
{
alxstopmusic();
alxsetmusicvolume($pref::audio::musicvolume);
return;
}
alxsetmusicvolume(%startvol);
schedule(500,0,"alxmusicfadeout",%startvol);
return 1;
}
function alxMusicFadein(%startvol)
{
%startvol = %startvol + 0.1;
if (%startvol > 1)
{
alxsetmusicvolume($pref::audio::musicvolume);
return;
}
alxsetmusicvolume(%startvol);
schedule(500,0,"alxmusicfadein",%startvol);
return 1;
}
function clientCmdAlxMusicFadeout()
{
alxmusicfadeout($pref::audio::musicvolume);
return 1;
}
function alxSetMusicVolume(%vol)
{
OP_MusicVolumeSlider.setvalue(%vol);
return %vol;
}
function reLightMission() {
if ($SceneLighting::lightingProgress == 0 || $SceneLighting::lightingProgress == 1)
lightScene("",forceAlways);
}
function clientCmdReLightMission() {
if (!$pref::disallowRelight)
reLightMission();
}
// -----------------------------------------------------
// Client Hook
// -----------------------------------------------------
package clientMod{
function DispatchLaunchMode()
{
parent::DispatchLaunchMode();
// check T2 command line arguments
for(%i = 1; %i < $Game::argc ; %i++)
{
%arg = $Game::argv[%i];
%nextArg = $Game::argv[%i+1];
%hasNextArg = $Game::argc - %i > 1;
if( !stricmp(%arg, "-CleanDSO")) //Remove DSO's on shutdown
{
$CleanDSO = true;
}
}
}
function Disconnect()
{
parent::Disconnect();
//Play the menu audio
alxplaymusic("T2BOL/Music/Menu.mp3");
alxMusicFadein(0);
//Fix the score menu
ScoreParent.settext("SCORE");
//Enable continue
DB_ContinueBTN.setActive(1);
//Show other elements
clockHud.setVisible(1);
timeHud.setVisible(0);
return 1;
}
function OptionsDLG::OnSleep(%this)
{
parent::OnSleep(%this);
if ($pref::Audio::musicEnabled && !IsObject(ServerConnection))
{
alxplaymusic("T2BOL/Music/Menu.mp3");
alxMusicFadein(0);
}
}
function GuiMLTextCtrl::onURL(%this, %url)
{
%url = strReplace(%url,"-","\t"); //Reading from files causes some funny issues..
switch$( getField(%url, 0) )
{
case "select":
%cb = getField(%url, 1);
if(%cb $= "")
return;
%i = 0;
while((%p[%i] = getField(%url, %i + 2)) !$= "")
%i++;
RPG_Category.setText(%cb); //Set the dropdown Text
RPG_BrowserPane.refresh(); //Force a refresh
for (%i = 0; %i < RPG_ItemList.rowCount(); %i++)
{
%text = RPG_ItemList.getRowText(%i);
if (%text $= %p0)
{
RPG_ItemList.setSelectedRow(%i);
break; //Tell the for loop to stop and continue executing
}
}
//Now make our category select the correct row
for (%i = 0; %i < RPG_Category.count; %i++)
{
%text = RPG_Category.getTextByID(%i);
if (%text $= %cb)
{
RPG_Category.setSelected(%i);
return;
}
}
case "call": //Dunno if anybody will use this..
%cb = getField(%url, 1);
if(%cb $= "")
return;
%i = 0;
while((%p[%i] = getField(%url, %i + 2)) !$= "")
%i++;
call(%cb, %p0, %p1, %p2, %p3, %p4);
case "input": //Should only be used on the PDA.
%cb = getField(%url, 1);
if(%cb $= "")
return;
%i = 0;
while((%p[%i] = getField(%url, %i + 2)) !$= "")
%i++;
//%cb is our data type
//%p0 is the text that shows up above the input box
//%p1 is the text for the box itself
InputText.setText(%p0);
InputTransFrame.setText(%p1);
Input.setValue("");
canvas.pushDialog(InputDLG);
$InputType = %cb;
default:
Parent::onURL(%this, %url);
}
return;
}
};
activatePackage(clientMod);