Initial release of the TribesNext scripts for Tribes 2. This contains incomplete in-game GUI code for player and clan profile management.

This commit is contained in:
Thyth 2015-02-07 21:24:47 -08:00
commit 62c22f43f8
27 changed files with 8810 additions and 0 deletions

View file

@ -0,0 +1,185 @@
$IRCClient::NickName = getField(wonGetAuthInfo(),0);
$IRCClient::NickName = strReplace($IRCClient::NickName," ","_");
$IRCClient::NickName = stripChars($IRCClient::NickName,"~@#$!+%/|^{&*()<>");
package t2csri_ircfix {
function GetIRCServerList(%arg1) {
return "IP:irc.arloria.net:6667";
}
function IRCClient::notify(%event)
{
if (isObject(ServerConnection) && getSubStr(%event,0,9) $= "IDIRC_ERR") return;
Parent::notify(%event);
}
function IRCClient::away(%params)
{
%me = $IRCClient::people.getObject(0);
%me.flags = %me.flags & ~$PERSON_AWAY;
if (strlen(%params))
{
if ($IRCClient::awaytimeout)
{
cancel($IRCClient::awaytimeout);
$IRCClient::awaytimeout = 0;
}
IRCClient::send("AWAY :" @ %params);
} else IRCClient::send("AWAY");
}
function IRCTCP::onDisconnect(%this)
{
$IRCClient::state = IDIRC_DISCONNECTED;
IRCClient::reset();
//IRCClient::notify(IDIRC_ERR_DROPPED);
parent::onDisconnect(%this);
}
function IRCTCP::onConnected(%this)
{
IRCClient::newMessage("","IRCClient: Established TCP/IP connection");
%me = $IRCClient::people.getObject(0);
%me.displayName = $IRCClient::NickName;
%me.setName(%me.displayName);
$IRCClient::tcp.schedule(500, "send", "NICK " @ $IRCClient::NickName @ "\r\n");
$IRCClient::tcp.schedule(500, "send", "USER " @ $IRCClient::NickName @ " x x :" @ $IRCClient::NickName @ "\r\n");
$IRCClient::tcp.schedule(2000, "send", "WHOIS " @ $IRCClient::NickName @ "\r\n");
$IRCClient::state = IDIRC_CONNECTING_WAITING;
}
function IRCClient::relogin()
{
if($IRCClient::state !$= IDIRC_CONNECTED)
IRCClient::connect();
%me = $IRCClient::people.getObject(0);
%me.displayName = $IRCClient::NickName;
%me.setName(%me.displayName);
%me.tagged = %me.displayName;
IRCClient::correctNick(%me);
IRCClient::newMessage("","IRCClient: Reauthentication starting");
$IRCClient::tcp.schedule(500, "send", "NICK " @ $IRCClient::NickName @ "\r\n");
$IRCClient::tcp.schedule(500, "send", "USER " @ $IRCClient::NickName @ " x x :" @ $IRCClient::NickName @ "\r\n");
$IRCClient::tcp.schedule(2000, "send", "WHOIS " @ $IRCClient::NickName @ "\r\n");
$IRCClient::state = IDIRC_CONNECTING_WAITING;
}
function IRCClient::dispatch(%prefix,%command,%params)
{
if (%command == 378) {IRCClient::onConFrom(%prefix,%params); return true;}
else parent::dispatch(%prefix,%command,%params);
}
function chatMemberPopup::add(%this,%name,%index) {
if (%index == 10 || %index == 11) return;
parent::add(%this,%name,%index);
}
function JoinChatDlg::onWake(%this)
{
if ($IRCClient::state $= IDIRC_CONNECTING_WAITING)
MessageBoxOK("CONNECTING...","Waiting for IRC server to respond, please wait.");
else
parent::onWake(%this);
}
function ChatTabView::onSelect(%this,%obj,%name)
{
parent::onSelect(%this,%obj,%name);
if (%name $= "welcome" && $IRCClient::channels.getObject(0) != %obj)
{
ChatPanel.setVisible(true);
WelcomePanel.setVisible(false);
ChatEditOptionsBtn.setVisible(false);
}
}
function IRCClient::onConFrom(%prefix,%params)
{
//IP acquisition test... may remove
//Krash-T2 Krash-T2 :is connecting from *@24.108.153.184 24.108.153.184
if ($IPv4::InetAddress $= "" && getWord(%params,0) $= $IRCClient::people.getObject(0).displayName) $IPv4::InetAddress = getWord(%params,getWordCount(%params)-1);
}
function IRCClient::onBadNick(%prefix,%params)
{
$IRCClient::NickName = getField(wonGetAuthInfo(),0) @ "-"@getRandom(0,99);
$IRCClient::NickName = strReplace($IRCClient::NickName," ","_");
IRCClient::relogin();
}
function IRCClient::onNick(%prefix,%params)
{
%person = IRCClient::findPerson2(%prefix,false);
if (%person) {
%person.displayName = %params;
%person.tagged = %params;
IRCClient::correctNick(%person);
ChatRoomMemberList_rebuild();
}
parent::onNick(%prefix,%params);
}
function IRCClient::newMessage(%channel,%message)
{
//quick UE fix, rewrite later
for (%i = 0;%i < getWordCount(%message);%i++) {
%word = getWord(%message,%i);
%first = strstr(%word,"<");
if (%first != -1) {
%word1 = getSubstr(%word,%first,strlen(%word));
%second = strstr(%word1,">");
if (%second == -1)
%message = stripChars(%message,"<>");
}
}
parent::newMessage(%channel,%message);
}
function IRCClient::setIdentity(%p,%ident)
{
parent::setIdentity(%p,%ident);
if(%p.getName() !$= %p.displayName) %p.setName(%p.displayName);
if(%p.untagged $= "")%p.untagged = %p.displayName;
}
function IRCClient::onMode(%prefix,%params)
{
parent::onMode(%prefix,%params);
ChatRoomMemberList_rebuild();
}
function IRCClient::onJoinServer(%mission,%server,%address,%mayprequire,%prequire)
{
if(strstr(strlwr($IRCClient::currentChannel.getName(),"tribes")) != -1) return;
parent::onJoinServer(%mission,%server,%address,%mayprequire,%prequire);
}
function IRCClient::onNameReply(%prefix,%params)
{
%params = strreplace(%params,"~","@");
%params = strreplace(%params,"&","@");
%params = strreplace(%params,"*","@");
%params = strreplace(%params,"%","@");
%params = strreplace(%params,"^","@");
parent::onNameReply(%prefix,%params);
}
function IRCClient::onPing(%prefix,%params)
{
//echo(%prefix SPC %params);
if (!$PingStarted) {
$IRCClient::tcp.schedule(1000, "send", "PONG " @ %params @ "\r\n");
$PingStarted = true;
} else $IRCClient::tcp.send("PONG " @ %params @ "\r\n");
}
function IRCClient::onPart(%prefix,%params)
{
%params = firstWord(%params);
parent::onPart(%prefix,%params);
ChatRoomMemberList_rebuild();
}
function IRCClient::notify(%event)
{
if (%event $= IDIRC_CHANNEL_LIST) {
JoinChatList.clear();
for (%i = 0; %i < $IRCClient::numChannels; %i++)
{
switch$ ( $IRCClient::channelNames[%i] ) {
case "#the_construct" or "#help" or "#welcome": %temp = 1;
default: %temp = 0;
}
if (strStr(strlwr($IRCClient::channelNames[%i]),"tribes") != -1) %temp = 1;
JoinChatList.addRow(%i, IRCClient::displayChannel( $IRCClient::channelNames[%i]) TAB $IRCClient::channelUsers[%i] TAB %temp );
JoinChatList.setRowStyle( %i, %temp > 0 );
}
JoinChatList.sort();
JoinChatName.onCharInput();
} else parent::notify(%event);
}
}; activatePackage(t2csri_ircfix);

View file

@ -0,0 +1,459 @@
// Tribes 2 Unofficial Authentication System
// http://www.tribesnext.com/
// Written by Krash
// Copyright 2008 by Krash and the Tribes 2 Community System Reengineering Intitiative
// Master listing / Queries.
if ($Host::TN::beat $= "") $Host::TN::beat = 3; //Time between beats in minutes.
if ($Host::TN::echo $= "") $Host::TN::echo = 1; //Enable the MS echoes.
function NewsGui::onWake( %this )
{
Canvas.pushDialog( LaunchToolbarDlg );
%this.pane = "News";
NM_TabView.setSelected( 1 );
}
function NM_TabView::onAdd( %this )
{
%this.addSet( 1, "gui/shll_horztabbuttonB", "5 5 5", "50 50 0", "5 5 5" );
%this.addTab(1,"NEWS",1);
%this.addTab(2,"FORUMS");
%this.setTabActive(2,0);
%this.addTab(3,"DOWNLOADS");
%this.setTabActive(3,0);
}
function NM_TabView::onSelect( %this, %id, %text )
{
NM_NewsPane.setVisible( %id == 1 );
//NM_ForumPane.setVisible( %id == 2 );
//NM_FilePane.setVisible( %id == 3 );
NM_TabFrame.setAltColor( %id == 1 );
%ctrl = "NM_" @ NewsGui.pane @ "Pane";
if ( isObject( %ctrl ) )
%ctrl.onDeactivate();
switch ( %id )
{
case 1: // News
NM_NewsPane.onActivate();
}
}
function NM_NewsPane::onActivate(%this) {
NewsGui.pane = "News";
}
function NM_NewsPane::onDeactivate(%this) {}
function NewsGui::setKey(%this) {}
function LaunchNews() {
if (!isObject(NewsGui)){
new GuiChunkedBitmapCtrl(NewsGui) {
profile = "GuiContentProfile";
horizSizing = "width";
vertSizing = "height";
position = "0 0";
extent = "640 480";
minExtent = "8 8";
visible = "1";
hideCursor = "0";
bypassHideCursor = "0";
variable = "$ShellBackground";
helpTag = "0";
useVariable = "1";
new ShellPaneCtrl() {
profile = "ShellPaneProfile";
horizSizing = "width";
vertSizing = "height";
position = "12 13";
extent = "620 423";
minExtent = "48 92";
visible = "1";
hideCursor = "0";
bypassHideCursor = "0";
helpTag = "0";
text = "TRIBESNEXT";
maxLength = "255";
noTitleBar = "0";
new ShellTabFrame(NM_TabFrame) {
profile = "ShellHorzTabFrameProfile";
horizSizing = "width";
vertSizing = "height";
position = "22 54";
extent = "576 351";
minExtent = "26 254";
visible = "1";
hideCursor = "0";
bypassHideCursor = "0";
helpTag = "0";
isVertical = "0";
useCloseButton = "0";
edgeInset = "0";
};
new ShellTabGroupCtrl(NM_TabView) {
profile = "TabGroupProfile";
horizSizing = "width";
vertSizing = "bottom";
position = "30 25";
extent = "560 29";
minExtent = "38 29";
visible = "1";
hideCursor = "0";
bypassHideCursor = "0";
helpTag = "0";
glowOffset = "7";
tabSpacing = "2";
maxTabWidth = "150";
stretchToFit = "0";
};
new GuiControl(NM_NewsPane) {
profile = "GuiDefaultProfile";
horizSizing = "width";
vertSizing = "height";
position = "0 0";
extent = "586 423";
minExtent = "8 8";
visible = "0";
hideCursor = "0";
bypassHideCursor = "0";
helpTag = "0";
new ShellFieldCtrl(NewsPanel) {
profile = "ShellFieldProfile";
horizSizing = "width";
vertSizing = "height";
position = "31 92";
extent = "559 315";
minExtent = "16 18";
visible = "1";
hideCursor = "0";
bypassHideCursor = "0";
helpTag = "0";
new ShellScrollCtrl() {
profile = "NewScrollCtrlProfile";
horizSizing = "width";
vertSizing = "height";
position = "195 5";
extent = "360 303";
minExtent = "24 52";
visible = "1";
hideCursor = "0";
bypassHideCursor = "0";
helpTag = "0";
willFirstRespond = "1";
hScrollBar = "alwaysOff";
vScrollBar = "alwaysOn";
constantThumbHeight = "0";
defaultLineHeight = "15";
childMargin = "0 2";
fieldBase = "gui/shll_field";
new GuiScrollContentCtrl() {
profile = "GuiDefaultProfile";
horizSizing = "width";
vertSizing = "height";
position = "4 6";
extent = "336 291";
minExtent = "8 8";
visible = "1";
hideCursor = "0";
bypassHideCursor = "0";
helpTag = "0";
new GuiMLTextCtrl(NewsText) {
profile = "NewTextEditProfile";
horizSizing = "width";
vertSizing = "bottom";
position = "0 0";
extent = "362 2376";
minExtent = "8 8";
visible = "1";
hideCursor = "0";
bypassHideCursor = "0";
helpTag = "0";
lineSpacing = "2";
allowColorChars = "0";
maxChars = "-1";
deniedSound = "InputDeniedSound";
};
};
};
new ShellScrollCtrl() {
profile = "NewScrollCtrlProfile";
horizSizing = "right";
vertSizing = "height";
position = "2 21";
extent = "195 287";
minExtent = "24 52";
visible = "1";
hideCursor = "0";
bypassHideCursor = "0";
helpTag = "0";
willFirstRespond = "1";
hScrollBar = "alwaysOff";
vScrollBar = "dynamic";
constantThumbHeight = "0";
defaultLineHeight = "15";
childMargin = "0 3";
fieldBase = "gui/shll_field";
new GuiScrollContentCtrl() {
profile = "GuiDefaultProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "4 7";
extent = "187 273";
minExtent = "8 8";
visible = "1";
hideCursor = "0";
bypassHideCursor = "0";
helpTag = "0";
new ShellTextList(NewsHeadlines) {
profile = "ShellTextArrayProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "0 0";
extent = "187 180";
minExtent = "8 8";
visible = "1";
hideCursor = "0";
bypassHideCursor = "0";
helpTag = "0";
enumerate = "0";
resizeCell = "1";
columns = "0";
fitParentWidth = "1";
clipColumnText = "0";
};
};
};
new GuiTextCtrl() {
profile = "ShellAltTextProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "12 6";
extent = "72 20";
minExtent = "8 8";
visible = "1";
hideCursor = "0";
bypassHideCursor = "0";
helpTag = "0";
text = "HEADLINES:";
longTextBuffer = "0";
maxLength = "255";
};
};
};
};
};
} else LaunchTabView.viewTab( "TRIBESNEXT", NewsGui, 0 );
}
//================================================================
function queryTNServers(%filter,%mod,%maptype,%minplayers,%maxplayers,%maxBots,%flags) {
%server = "master.tribesnext.com:80";
if (!isObject(TNbite))
%bite = new TCPObject(TNbite){};
else %bite = TNbite;
%bite.mode = 0;
%filename = "/list";
if (%filter)
%filename = "/list/"@%mod@"/"@%maptype@"/"@%minplayers@"/"@%maxplayers@"/"@%maxBots@"/"@%flags;
if (%filter $= "types") {
%filename = "/listtypes";
%bite.mode = 2;
} else queryFavoriteServers(); // Filtering fix, since the old master query isn't used.
%bite.get(%server, %filename);
}
function queryMasterGameTypes(){
clearGameTypes();
clearMissionTypes();
queryTNServers("types");
}
function queryMasterServer(%port, %flags, %rulesSet, %missionType, %minPlayers, %maxPlayers, %maxBots, %regionMask, %maxPing, %minCpu, %filtFlags, %buddy )
{
if (%flags !$= "") queryTNServers(1,%rulesSet,%missionType,%minplayers,%maxplayers,%maxBots,%filtFlags SPC %buddy);
else queryTNServers();
}
function TNbite::onLine(%this, %line) {
if (trim(%line) $= "") {
if (!%this.primed) %this.primed = true;
if (%this.mode != 5) return;
}
if (!%this.primed) return;
if (%this.mode == 1)
switch (%line) { // heartbeats
case 0: if ($Host::TN::echo) echo(" - Server added to list.");
case 1: if ($Host::TN::echo) { echo(" - Your server could not be contacted.");
echo(" - Check your IP / port configuration."); }
case 2: if ($Host::TN::echo) echo(" - Heartbeat confirmed.");
}
else if (%this.mode == 2) //filter retrieval
switch (firstWord(%line)) {
case 0: addGameType( restWords(%line) );
case 1: addMissionType( restWords(%line) );
}
else if (%this.mode == 5) // news retrieval
NewsGui.addLine(%line);
else // and finally, the server list...
if ( strpos(%line,":") != -1 && strstr(%line,".") != -1) {
querySingleServer( %line );
if (!%this.fnd) %this.fnd = true;
}
}
function TNbite::onConnectFailed(%this) {
if ($Host::TN::echo) echo("-- Could not connect to master server.");
}
function TNbite::onDNSFailed(%this) {
if ($Host::TN::echo) echo("-- Could not connect to DNS server.");
}
function TNbite::onDisconnect(%this) {
if (!%this.fnd && %this.mode == 0)
if (!GMJ_Browser.rowCount())
updateServerBrowserStatus( "No servers found.", 0 );
%this.delete();
}
function NewsGui::addLine( %this, %line ) {
%this = NewsText;
if (firstWord(%line) $= "<tag>") {
%line = setWord(%line,0,"<tag:"@%this.index++@">");
NewsHeadlines.addRow(%this.index,stripMLControlChars(%line));
}
if (%line $= "#EOF") {NewsText.upToDate = true; NewsHeadlines.setSelectedRow(0); return;}
%text = %this.getText();
%line = detag( %line );
%text = (%text $= "") ? %line : %text NL %line;
%this.setText( %text );
}
function NewsText::update( %this, %online ) {
%this.setText("");
NewsHeadlines.clear();
%this.index = -1;
if (%online) {
%server = "www.tribesnext.com:80";
if (!isObject(TNbite))
%bite = new TCPObject(TNbite){};
else %bite = TNbite;
%bite.mode = 5;
%filename = "/news";
%bite.get(%server, %filename);
}
}
function NewsHeadlines::onSelect( %this, %id, %text )
{
NewsText.scrollToTag( %id );
}
//================================================================
package t2csri_webs {
function TNbite::get(%this, %server, %query)
{
if ($t2csri::isOfflineMode)
{
warn("TribesNext: Running in offline mode. Aborting query to the Master List Server.");
return;
}
%this.server = %server;
%this.query = %query;
%this.connect(%server);
}
function TNbite::onConnected(%this)
{
if (%this.query !$= "") {
%query = "GET " @ %this.query @ " HTTP/1.1\r\nHost: " @ %this.server @ "\r\nUser-Agent: Tribes 2\r\nConnection: close\r\n\r\n";
%this.send(%query);
}
}
function LaunchTabView::addLaunchTab( %this, %text, %gui, %makeInactive ) {
// disable currently unused tabs
//if (%text $= "EMAIL" || %text $= "BROWSER") parent::addLaunchTab( %this, %text, %gui, 1 );
if (%text $= "BROWSER") parent::addLaunchTab( %this, %text, %gui, 1 );
else parent::addLaunchTab( %this, %text, %gui, %makeInactive );
}
function LaunchToolbarMenu::add(%this,%id,%text) {
parent::add(%this,%id,%text);
if ($PlayingOnline && %text $= "BROWSER") {
LaunchToolbarMenu.add( 1, "TRAINING" );
LaunchToolbarMenu.add( 2, "TRIBESNEXT" );
}
}
function OpenLaunchTabs( %gotoWarriorSetup ) {
parent::OpenLaunchTabs( %gotoWarriorSetup );
if ($PlayingOnline && !TrainingGui.added) {
LaunchTabView.addLaunchTab( "TRAINING", TrainingGui );
LaunchTabView.addLaunchTab( "TRIBESNEXT", NewsGui );
LaunchNews();
NewsText.update(1);
TrainingGui.added = true;
}
}
function JoinSelectedGame() {
if (($IPv4::InetAddress $= "" || strstr($IPv4::InetAddress,".") == -1) && $PlayingOnline) {
messageBoxOK("IP ERROR","Your external address has not been set or is set incorrectly. \n\nAttempting to reset...");
ipv4_getInetAddress();
return;
} else parent::JoinSelectedGame();
}
function ClientReceivedDataBlock(%index, %total)
{
DB_LoadingProgress.setValue( %index / %total );
parent::ClientReceivedDataBlock(%index, %total);
}
function CreateServer(%mission, %missionType) {
parent::CreateServer(%mission, %missionType);
if (!isActivePackage(t2csri_server)) schedule(2000,0,"exec","t2csri/serverGlue.cs");
}
function StartHeartbeat() {
if ($playingOnline) {
if(isEventPending($TNBeat)) cancel($TNBeat);
%server = "master.tribesnext.com:80";
if ($Host::BindAddress !$= "")
%path = "/add/" @ $Host::Port @"/"@ $Host::BindAddress;
else %path = "/add/" @ $Host::Port;
if (!isObject(TNbite))
%bite = new TCPObject(TNbite){};
else %bite = TNbite;
%bite.mode = 1;
%bite.get(%server, %path);
if ($Host::TN::echo)
echo("-- Sent heartbeat to TN Master. ("@%server@")");
$TNBeat = schedule($Host::TN::beat*60000,0,"StartHeartBeat");
} else parent::StartHeartbeat();
}
function StopHeartbeat() {
if ($playingOnline) {
if(isEventPending($TNBeat)) cancel($TNBeat);
} else parent::StartHeartbeat();
}
//================================================================
};
if (!isActivePackage(t2csri_webs)) activatepackage (t2csri_webs);
exec("t2csri/postLogin.cs");

View file

@ -0,0 +1,8 @@
// Tribes 2 Unofficial Authentication System
// http://www.tribesnext.com/
// Written by Electricutioner/Thyth
// Copyright 2008 by Electricutioner/Thyth and the Tribes 2 Community System Reengineering Intitiative
// Version 1.0 initialization and glue file (server side)
schedule(0, 0, exec, "t2csri/serverglue.cs");