There is no spoon

Difference between revisions of "User:Eliot/UE2:AddingCustomTabsToPlayerLoginMenu (UT2004)"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
(Created page with '{{Infobox_utility |name=Custom PlayerLoginMenu Tabs |description=Provides source code to add a tab to the PlayerLogin's menu. |author=Eliot |compatible=[[Unreal En…')
 
m (Typos)
 
Line 5: Line 5:
 
|compatible=[[Unreal Engine 2]]
 
|compatible=[[Unreal Engine 2]]
 
}}
 
}}
One day You might have wanted to modify the '''PlayerLoginMenu''' and think about replacing the whole menu class to just add a button or a tab to it, to do this you would search through the many classes of UT2004 taking a lot of time just to figure out where its creating menu then when done you realize only one mutator will be able to do this because of replacing menu, therefor the source code provided here provides the method to add a tab to the ''PlayerLoginMenu'' when the user opens the ''PlayerLoginMenu'' for the first time.
+
One day You might have wanted to modify the '''PlayerLoginMenu''' and think about replacing the whole menu class to just add a button or a tab to it, to do this you would search through the many classes of UT2004, taking a lot of time just to figure out where its creating the menu then when done you realize only one mutator will be able to do this because of replacing the menu, therefor the source code provided here provides a method to add a tab to the ''PlayerLoginMenu'' when the user opens the ''PlayerLoginMenu'' for the first time.
  
 
The basic procedure mutators do using this method is
 
The basic procedure mutators do using this method is

Latest revision as of 04:45, 30 May 2010

Custom PlayerLoginMenu Tabs
Provides source code to add a tab to the PlayerLogin's menu.


Author Eliot
Compatible Unreal Engine 2


When using any of the provided source code please credit the listed Author in your source code! e.g. "Custom PlayerLoginMenu Tabs utils written by Eliot.".
View more utils at UnrealScript Utils


One day You might have wanted to modify the PlayerLoginMenu and think about replacing the whole menu class to just add a button or a tab to it, to do this you would search through the many classes of UT2004, taking a lot of time just to figure out where its creating the menu then when done you realize only one mutator will be able to do this because of replacing the menu, therefor the source code provided here provides a method to add a tab to the PlayerLoginMenu when the user opens the PlayerLoginMenu for the first time.

The basic procedure mutators do using this method is

Make a mutator class with the defaultproperties as RemoteRole=SimulatedProxy and a event simulated event Tick( float DeltaTime ) to add a interaction for your mutator, this interaction will add the tab to the PlayerLoginMenu.

Make a interaction class(source code below).

The interaction will have bRequiresTick so that the interaction will receive the tick event, this tick event will be used to check if the user has the escape menu open so that we can add the tab and then either remove or disable the interaction or leave it.


The Interaction Class
class MyInteraction extends Interaction;
 
// Needed so that we don't call ModifyMenu again even when when it already added the new tab.
var private editconst bool bMenuModified;
 
// Needed so that this interaction removes itself after level change.
event NotifyLevelChange()
{
	Master.RemoveInteraction( self );
}
 
final private function ModifyMenu()
{
	local UT2K4PlayerLoginMenu Menu;
	local GUITabPanel Panel;
 
	// Try get the menu, will return none if the menu is not open!.
	Menu = UT2K4PlayerLoginMenu(GUIController(ViewportOwner.Actor.Player.GUIController).FindPersistentMenuByName( UnrealPlayer(ViewportOwner.Actor).LoginMenuClass ));
	if( Menu != none )
	{
                // You can use the panel reference to do the modifications to the tab etc.
		Panel = Menu.c_Main.AddTab( "Caption of my tab", string( Class'MyPanelClass' ),, "Hint of my tab" );
		bMenuModified = true;
 
		// Uncomment if tick is not needed for anything else than ModifyMenu.
		//Disable( 'Tick' );
		//bRequiresTick = false;
 
		// Uncomment if interaction is not needed for anything else than adding a tab to the menu.
		//Master.RemoveInteraction( self );
	}
}
 
function Tick( float DeltaTime )
{
	if( !bMenuModified )
	{
		ModifyMenu();
	}
}
 
defaultproperties
{
	bRequiresTick=true
}

Obviously you could port this code straight into the the mutator's Tick event if you won't use the interaction for more things than just adding a tab to the menu.

The Panel Class
class MyPanelClass extends MidGamePanel;

The panel class will be the panel that is visible when the added tab is selected, in this panel you should add your GUIComponents.

Screenshot

A screenshot of my mutators(MutBestTimes,MutCacheExtractor,TrialGroup) using this method together.

Modified PlayerLoginMenu