Initial commit

This commit is contained in:
Brian Beck 2025-09-11 16:56:30 -07:00
parent 2211ed7650
commit ebb3dc9cdd
10121 changed files with 801 additions and 4 deletions

View file

@ -0,0 +1,166 @@
new GuiControlProfile ("TR2BonusBigText")
{
fontType = "Verdana Bold";
fontSize = $TR2Pref::BonusHud::BonusFontSize;
fontColor = "255 255 51";
};
new GuiControlProfile ("TR2BonusHUGEText")
{
fontType = "Verdana Bold";
fontSize = 36;
fontColor = "255 255 51";
};
new GuiControlProfile ("TR2BonusPopupProfile")
{
bitmapbase = "gui/hud_new_window";
};
function createBonusHud()
{
if( isObject(TR2BonusHud) )
TR2BonusHud.delete();
new ShellFieldCtrl(TR2BonusHud) {
profile = "TR2BonusPopupProfile";
horizSizing = "center";
vertSizing = "bottom";
position = "0 0";
extent = "77 52";
minExtent = "70 48";
visible = "0";
helpTag = "0";
};
%profile[1] = "TR2BonusBigText";
%profile[2] = "TR2BonusHUGEText";
%sizing[1] = "bottom";
%sizing[2] = "top";
%pos[1] = 3;
%pos[2] = 17;
%size[1] = "77 22";
%size[2] = "77 50";
for( %i = 1; %i <= 2; %i++ )
{
$TR2BonusText[%i] = new GuiMLTextCtrl()
{
profile = %profile[%i];
horizSizing = "center";
vertSizing = %sizing[%i];
position = "0 " @ %pos[%i];
extent = %size[%i];
minExtent = "8 8";
visible = "1";
helpTag = "0";
lineSpacing = "2";
allowColorChars = "0";
maxChars = "256";
};
TR2BonusHud.add($TR2BonusText[%i]);
}
$TR2BonusText[1].setText("<just:center><color:4682B4>JACKPOT");
}
function TR2BonusHud::dockToChat(%this)
{
%x = getWord(outerChatHud.extent, 2);
%y = getWord(outerChatHud.position, 1);
%this.setPosition(%x, %y);
}
function TR2BonusObject::flashText(%this, %count, %delay)
{
for( %i = 0; %i < %count; %i++ )
{
%isNewBonus = %i % 2;
%text = %isNewBonus ? $TR2Bonus::NewBonus : $TR2Bonus::OldBonus;
%extraDelay = %isNewBonus ? 0 : 250;
$TR2BonusText[2].schedule(%delay * %i + %extraDelay, "setText", %text);
}
$TR2BonusText[2].schedule(%delay * %count, "setText", $TR2Bonus::NewBonus);
}
function TR2BonusObject::doBonus(%this, %text, %color)
{
if( %color $= "" )
%color = "ffffff";
TR2BonusHud.setVisible(1);
$TR2Bonus::OldBonus = "<just:center><color:229922>" @ %this.currentBonus;
$TR2Bonus::NewBonus = "<just:center><color:" @ %color @ ">" @ %text;
// No flash if old score == new score
if( %text !$= %this.currentBonus || (%text $= %this.currentBonus && %color !$= %this.currentColor) )
%this.flashText(5, 500);
%this.currentBonus = %text;
%this.currentColor = %color;
}
function handleNewBonus(%msgType, %msgString, %text, %color)
{
if( $TR2Bonus::Gametype $= "TR2Game")
TR2BonusObject.doBonus(%text, %color);
}
function updateBonusTitle(%msgType, %msgString, %newTitle)
{
$TR2BonusText[1].setText(%newTitle);
}
function captureGameType(%msgType, %msgString, %game)
{
$TR2Bonus::Gametype = detag(%game);
if( detag(%game) $= "TR2Game" )
TR2BonusHud.setVisible(1);
else
TR2BonusHud.setVisible(0);
}
function setBonusHudState(%msgType, %msgString, %a, %b, %c)
{
if( $TR2Bonus::Gametype $= "TR2Game" )
TR2BonusHud.setVisible(1);
else
TR2BonusHud.setVisible(0);
}
createBonusHud();
PlayGui.add(TR2BonusHud);
$TR2BonusText[2].setText("<just:center><color:fffff0>0");
if( !isObject(TR2BonusObject) )
{
new ScriptObject(TR2BonusObject)
{
class = TR2BonusObject;
currentBonus = 0;
};
}
//package TR2BonusHud
//{
//function PlayGui::onWake(%this)
//{
// if( $TRBonus::Gametype $= "TR2Game" )
// TR2BonusHud.setVisible(1);
// else
// TR2BonusHud.setVisible(0);
//
// parent::onWake(%this);
//}
//
//function PlayGui::onSleep(%this)
//{
// TR2BonusHud.setVisible(0);
// parent::onSleep(%this);
//}
//};
//activatePackage(TR2BonusHud);
addMessageCallback('MsgTR2Bonus', handleNewBonus);
addMessageCallback('MsgTR2BonusTitle', updateBonusTitle);
addMessageCallback('MsgClientReady', captureGameType);
addMessageCallback('MsgMissionStart', setBonusHudState);
addMessageCallback('MsgMissionEnd', setBonusHudState);

View file

@ -0,0 +1,363 @@
// Complete Event Hud
// Resizes when adding new/deleting old messages
// Message to tell clients to add a line to the HUD is:
// 'MsgTR2Event'
// v0.9
// As of 05-11-2002
// 07-09-2002
//
// Redid HUD so that all GUI objects are defined in PlayGui.gui.
// Resulting script code to manipulate HUD is pretty ugly from a logical standpoint
// eg: that wouldn't work in C or C++ but you can do it in Tribes script..
// 05-13-2002
//
// Adjusted spacing/size of the hud. text is a little closer together now
// Lengthened the "popup" effect and the duration of individual events in the hud
//
// Usage:
// Server side: messageAll('MsgTR2Event', "", <name of player(s)>, <sequence description>, <sequence value>);
// ALL color formatting is currently handled serverside.
// Any message from the server matching that message type invokes a client side callback
// The client message callback calls: TR2EventHud.addEvent(<player name(s)>, <sequence description>, <sequence value>);
// TR2 GUI Profiles
// KP: Added these to match team name colors to skin colors
new GuiControlProfile ("GuiTextObjGoldLeftProfile")
{
fontType = "Univers Condensed";
fontSize = 16;
fontColor = "204 204 0";
fontColors[6] = $PlayerNameColor;
fontColors[7] = $TribeTagColor;
fontColors[8] = $SmurfNameColor;
fontColors[9] = $BotNameColor;
justify = "left";
};
new GuiControlProfile ("GuiTextObjGoldCenterProfile")
{
fontType = "Univers Condensed";
fontSize = 16;
fontColor = "204 204 0";
fontColors[6] = $PlayerNameColor;
fontColors[7] = $TribeTagColor;
fontColors[8] = $SmurfNameColor;
fontColors[9] = $BotNameColor;
justify = "center";
};
new GuiControlProfile ("GuiTextObjSilverLeftProfile")
{
fontType = "Univers Condensed";
fontSize = 16;
fontColor = "170 170 170";
fontColors[6] = $PlayerNameColor;
fontColors[7] = $TribeTagColor;
fontColors[8] = $SmurfNameColor;
fontColors[9] = $BotNameColor;
justify = "left";
};
new GuiControlProfile ("GuiTextObjSilverCenterProfile")
{
fontType = "Univers Condensed";
fontSize = 16;
fontColor = "170 170 170";
fontColors[6] = $PlayerNameColor;
fontColors[7] = $TribeTagColor;
fontColors[8] = $SmurfNameColor;
fontColors[9] = $BotNameColor;
justify = "center";
};
new GuiControlProfile ("TR2TextProfile")
{
fontType = "Univers";
fontSize = 14;
fontColor = "255 250 250";
};
new GuiControlProfile ("TR2BoldTextProfile")
{
fontType = "Univers Bold";
fontSize = 16;
fontColor = "160 160 255";
};
new GuiControlProfile ("TR2LargeBoldTextProfile")
{
fontType = "Univers Bold";
fontSize = 30;
fontColor = "255 255 255";
};
new GuiControlProfile ("TR2EventPopupProfile")
{
bitmapbase = "gui/hud_new_window";
};
function handleNewEvent(%msgType, %msgString, %name, %message, %value)
{
if( objectiveHud.gameType $= "TR2Game") // prevent server-initiated popups in non-TR2 games
TR2EventHud.addEvent(%name, %message, %value);
else
return 0;
}
function TR2EventHud::resize(%this, %bigger)
{
%offset = 0;
if( %bigger > 0 )
{
if( %this.lines < 4 )
{
%this.lines++;
%offset = %this.size[%this.lines - 1] - %this.size[%this.lines];
}
else
%this.lines = 4;
}
else if( %bigger < 0 )
{
if( %this.lines > 0 )
{
%this.lines--;
%offset = (%this.size[%this.lines + 1] - %this.size[%this.lines]);
}
else
%this.lines = 0;
}
else
{
// no change...
%offset = 0;
}
if( $TR2Pref::EventHud::DockToChat )
{
if( $TR2Pref::EventHud::ResizeUp )
{
%posx = getWord(OuterChatHud.position, 0);
%posy = getWord(OuterChatHud.position, 1) + getWord(OuterChatHud.extent, 1) + 40 + %offset;
}
else
{
%posx = getWord(OuterChatHud.position, 0);
%posy = getWord(OuterChatHud.position, 1) + getWord(OuterChatHud.extent, 1) + 40;
}
}
else
{
if( $TR2Pref::EventHud::ResizeUp )
{
%posx = getWord(TR2EventPopup.position, 0);
%posy = getWord(TR2EventPopup.position, 1) + %offset;
}
else
{
%posx = getWord(TR2EventPopup.position, 0);
%posy = getWord(TR2EventPopup.position, 1);
}
}
%extentx = getWord(TR2EventPopup.extent, 0);
%extenty = %this.size[%this.lines];
TR2EventPopup.resize(%posx, %posy, %extentx, %extenty);
}
function TR2EventHud::addEvent(%this, %player, %message, %value)
{
%this.pushBack();
$TR2Event[1].player = %player;
$TR2Event[1].message = %message;
$TR2Event[1].value = %value;
$TR2EventName.setText(%player);
$TR2EventText[1].setText(%message);
$TR2EventValue[1].setText(%value);
%this.resize(1);
TR2EventPopup.setVisible(1);
// remove old events after %this.lineLife duration
%this.schedule(%this.lineLife, "removeEvent");
}
function TR2EventHud::removeEvent(%this)
{
// always remove last line...
%line = %this.lines;
if( %line > 4 || %line < 0 )
return;
%this.resize(-1);
$TR2Event[%line].player = "";
$TR2Event[%line].message = "";
$TR2Event[%line].value = "";
$TR2EventText[%line].setText("");
$TR2EventValue[%line].setText("");
if( %line == 1 )
{
$TR2EventName.setText("");
}
if( %this.lines == 0 )
{
TR2EventPopup.setVisible(0);
}
}
function TR2EventHud::pushBack(%this) // move old messages down the HUD
{
for( %i = 4; %i > 0; %i-- )
{
$TR2Event[%i].message = $TR2Event[(%i - 1)].message;
$TR2Event[%i].player = $TR2Event[(%i - 1)].player;
$TR2Event[%i].value = $TR2Event[(%i - 1)].value;
}
$TR2EventName.setText($TR2Event[1].player);
for( %j = 1; %j <= 4; %j++ )
{
$TR2EventText[%j].setText($TR2Event[%j].message);
$TR2EventValue[%j].setText($TR2Event[%j].value);
}
}
package TR2Event
{
function MainChatHud::nextChatHudLen(%this)
{
if( $TR2Pref::EventHud::DockToChat )
TR2EventPopup.setPosition(getWord(OuterChatHud.position, 0), getWord(OuterChatHud.position, 1) + getWord(OuterChatHud.extent, 1) + 40);
parent::nextChatHudLen(%this);
}
};
activatePackage(TR2Event);
addMessageCallback('MsgTR2Event', handleNewEvent);
function createBonusPopup()
{
if( isObject(TR2EventPopup) )
TR2EventPopup.delete();
new ShellFieldCtrl(TR2EventPopup) {
profile = "TR2EventPopupProfile";
horizSizing = "right";
vertSizing = "top";
position = "0 400";
extent = "315 34";
minExtent = "220 34";
visible = "0";
helpTag = "0";
};
for( %i = 1; %i <= 4; %i++ )
{
%profile = %i == 1 ? "TR2BoldTextProfile" : "TR2TextProfile";
%ypos = %i > 1 ? 16 * (%i-2) + 34 : 1;
%yext = 16; //%i == 1 ? 16 : 16;
$TR2EventText[%i] = new GuiMLTextCtrl() // GuiMLTextCtrl - ML = meta language..? kinda like html
{
profile = %profile;
horizSizing = "left";
vertSizing = "bottom";
position = "4 " @ %ypos;
extent = "276 " @ %yext;
minExtent = "8 8";
visible = "1";
helpTag = "0";
lineSpacing = "2";
allowColorChars = "0";
maxChars = "256";
};
TR2EventPopup.add($TR2EventText[%i]);
$TR2EventValue[%i] = new GuiMLTextCtrl() // Sequence value field
{
profile = %profile;
horizSizing = "right";
vertSizing = "bottom";
position = getWord($TR2EventText[%i].extent, 0) + 5 SPC %ypos;
extent = "30 " @ %yext;
minExtent = "8 8";
visible = "1";
helpTag = "0";
lineSpacing = "2";
allowColorChars = "0";
maxChars = "5";
};
TR2EventPopup.add($TR2EventValue[%i]);
}
$TR2EventName = new GuiMLTextCtrl()
{
profile = "TR2BoldTextProfile"; // display the name...
horizSizing = "left";
vertSizing = "bottom";
position = "25 17";
extent = "286 16";
minExtent = "8 8";
visible = "1";
helpTag = "0";
lineSpacing = "2";
allowColorChars = "0";
maxChars = "256";
};
TR2EventPopup.add($TR2EventName);
}
function createEventHudObjects()
{
if( isObject(TR2EventHud) )
TR2EventHud.delete();
new ScriptObject("TR2EventHud")
{
class = "TR2EventHud";
lines = 0;
lifetime = 6000; // time after last popup that hud will disappear from screen
lineLife = 6000; // time before a event in the hud is removed
size[0] = 34;
size[1] = 34;
size[2] = 52;
size[3] = 70;
size[4] = 88;
};
}
function createEventStorage()
{
for(%j = 1; %j <= 4; %j++ ) // storing the sequence data in a script object
{
if( isObject($TR2Event[%j]) )
$TR2Event[%j].delete();
$TR2Event[%j] = new ScriptObject()
{
player = "";
message = "";
value = "";
};
}
}
createBonusPopup();
PlayGui.add(TR2EventPopup);
createEventHudObjects();
createEventStorage();
TR2EventHud.resize(0);

View file

@ -0,0 +1,84 @@
$TR2FGauge::Reset = 3000; // 3 seconds
$TR2FGauge::Duration = 1200; // 1.2 seconds
$TR2FGauge::Increase = 0.01; // 1%
$IHaveFlag = 0;
new GuiControlProfile ("TR2StrengthBar")
{
opaque = false;
fillColor = $TR2Pref::FlagToss::FillColor;
border = true;
borderColor = $TR2Pref::FlagToss::BorderColor;
};
function doFlagGauge(%val)
{
if( %val && $IHaveFlag )
{
TR2_ThrowStrength.setVisible(1);
TR2StrengthBar.border = true;
%level = TR2_ThrowStrength.getValue();
if( %level < 1 )
{
TR2_ThrowStrength.setValue(%level + $TR2FGauge::Increase);
$TR2FGaugeThread = schedule($TR2FGauge::Duration/100, 0, "doFlagGauge", 1);
}
if( !isEventPending($TR2FGauge::HideThread) )
$TR2FGauge::HideThread = schedule($TR2FGauge::Reset, 0, "hideFlagGauge");
}
else
{
if( isEventPending($TR2FGauge::HideThread) )
cancel($TR2FGauge::HideThread);
hideFlagGauge();
}
}
function hideFlagGauge()
{
if( isEventPending($TR2FGaugeThread) )
cancel($TR2FGaugeThread);
$TR2FGaugeThread = 0;
TR2_ThrowStrength.setVisible(0);
TR2_ThrowStrength.setValue(0);
TR2StrengthBar.border = false;
}
function flagTossHandleGrab(%msgType, %msgString, %name, %teamName, %team, %nameBase)
{
if( strstr(%msgString, "You took the flag." ) >= 0 )
$IHaveFlag = true;
}
function flagTossHandleDrop(%msgType, %msgString, %teamName, %team)
{
if( strstr( %msgString, "You dropped the flag." ) >= 0 )
$IHaveFlag = false;
}
function createFlagTossGauge()
{
if( !isObject(TR2_ThrowStrength) )
{
new GuiProgressCtrl(TR2_ThrowStrength) {
profile = "TR2StrengthBar";
horizSizing = "center";
vertSizing = "relative";
position = "340 280";
extent = "100 7";
minExtent = "8 8";
visible = "0";
hideCursor = "0";
bypassHideCursor = "0";
helpTag = "0";
};
}
}
createFlagTossGauge();
PlayGui.add(TR2_ThrowStrength);
addMessageCallback('MsgTR2FlagDropped', flagTossHandleDrop);
addMessageCallback('MsgTR2FlagTaken', flagTossHandleGrab);