UMenu
Class UMenuMapListCW

source: e:\games\UnrealTournament\UMenu\Classes\UMenuMapListCW.uc
Core.Object
   |
   +--UWindow.UWindowBase
      |
      +--UWindow.UWindowWindow
         |
         +--UWindow.UWindowClientWindow
            |
            +--UWindow.UWindowDialogClientWindow
               |
               +--UMenu.UMenuDialogClientWindow
                  |
                  +--UMenu.UMenuMapListCW
Direct Known Subclasses:None

class UMenuMapListCW
extends UMenu.UMenuDialogClientWindow


Variables
 UMenuBotmatchClientWindow BotmatchParent
 string CustomText
 UWindowComboControl DefaultCombo
 string DefaultHelp
 string DefaultText
 UMenuMapListExclude Exclude
 string ExcludeCaption
 string ExcludeHelp
 UMenuMapListFrameCW FrameExclude
 UMenuMapListFrameCW FrameInclude
 UMenuMapListInclude Include
 string IncludeCaption
 string IncludeHelp
 UWindowHSplitter Splitter
 bool bChangingDefault


Function Summary
 void Created()
 void DefaultComboChanged()
 void LoadDefaultClasses()
 void LoadMapList()
 void Notify(UWindowDialogControl C, byte E)
 void Paint(Canvas C, float X, float Y)
 void Resized()
 void SaveConfigs()



Source Code


00001	class UMenuMapListCW expands UMenuDialogClientWindow;
00002	
00003	var UMenuBotmatchClientWindow BotmatchParent;
00004	var UWindowHSplitter Splitter;
00005	
00006	var UMenuMapListExclude Exclude;
00007	var UMenuMapListInclude Include;
00008	
00009	var UMenuMapListFrameCW FrameExclude;
00010	var UMenuMapListFrameCW FrameInclude;
00011	
00012	var UWindowComboControl DefaultCombo;
00013	var localized string DefaultText;
00014	var localized string DefaultHelp;
00015	var localized string CustomText;
00016	
00017	var localized string ExcludeCaption;
00018	var localized string ExcludeHelp;
00019	var localized string IncludeCaption;
00020	var localized string IncludeHelp;
00021	
00022	var bool bChangingDefault;
00023	
00024	function Created()
00025	{
00026		Super.Created();
00027		
00028		BotmatchParent = UMenuBotmatchClientWindow(OwnerWindow);
00029	
00030		Splitter = UWindowHSplitter(CreateWindow(class'UWindowHSplitter', 0, 0, WinWidth, WinHeight));
00031		
00032		FrameExclude = UMenuMapListFrameCW(Splitter.CreateWindow(class'UMenuMapListFrameCW', 0, 0, 100, 100));
00033		FrameInclude = UMenuMapListFrameCW(Splitter.CreateWindow(class'UMenuMapListFrameCW', 0, 0, 100, 100));
00034	
00035		Splitter.LeftClientWindow  = FrameExclude;
00036		Splitter.RightClientWindow = FrameInclude;
00037	
00038		Exclude = UMenuMapListExclude(CreateWindow(class'UMenuMapListExclude', 0, 0, 100, 100, Self));
00039		FrameExclude.Frame.SetFrame(Exclude);
00040		Include = UMenuMapListInclude(CreateWindow(class'UMenuMapListInclude', 0, 0, 100, 100, Self));
00041		FrameInclude.Frame.SetFrame(Include);
00042	
00043		Exclude.Register(Self);
00044		Include.Register(Self);
00045	
00046		Exclude.SetHelpText(ExcludeHelp);
00047		Include.SetHelpText(IncludeHelp);
00048	
00049		Include.DoubleClickList = Exclude;
00050		Exclude.DoubleClickList = Include;
00051		
00052		Splitter.bSizable = False;
00053		Splitter.bRightGrow = True;
00054		Splitter.SplitPos = WinWidth/2;
00055	
00056		DefaultCombo = UWindowComboControl(CreateControl(class'UWindowComboControl', 10, 2, 200, 1));
00057		DefaultCombo.SetText(DefaultText);
00058		DefaultCombo.SetHelpText(DefaultHelp);
00059		DefaultCombo.SetFont(F_Normal);
00060		DefaultCombo.SetEditable(False);
00061		DefaultCombo.AddItem(CustomText, "");
00062		DefaultCombo.SetSelectedIndex(0);
00063		DefaultCombo.EditBoxWidth = 120;
00064		LoadDefaultClasses();
00065		LoadMapList();
00066	}
00067	
00068	function Paint(Canvas C, float X, float Y)
00069	{
00070		local Texture T;
00071	
00072		Super.Paint(C, X, Y);
00073	
00074		T = GetLookAndFeelTexture();
00075		DrawUpBevel( C, 0, 20, WinWidth, 15, T);
00076	
00077		C.Font = Root.Fonts[F_Normal];
00078		C.DrawColor.R = 0;
00079		C.DrawColor.G = 0;
00080		C.DrawColor.B = 0;
00081	
00082		ClipText(C, 10, 23, ExcludeCaption, True);
00083		ClipText(C, WinWidth/2 + 10, 23, IncludeCaption, True);
00084	}
00085	
00086	function Resized()
00087	{
00088		Super.Resized();
00089	
00090		Splitter.WinTop = 35;
00091		Splitter.SetSize(WinWidth, WinHeight-35);
00092		Splitter.SplitPos = WinWidth/2;
00093	}
00094	
00095	function LoadDefaultClasses()
00096	{
00097		local int NumDefaultClasses;
00098		local string DefaultBaseClass;
00099		local string NextDefault, NextDesc;
00100		local int j;
00101	
00102		DefaultBaseClass = string(BotmatchParent.GameClass.Default.MapListType);
00103	
00104		GetPlayerOwner().GetNextIntDesc(DefaultBaseClass, 0, NextDefault, NextDesc);
00105		while( (NextDefault != "") && (NumDefaultClasses < 50) )
00106		{
00107			DefaultCombo.AddItem(NextDesc, NextDefault);
00108			NumDefaultClasses++;
00109			GetPlayerOwner().GetNextIntDesc(DefaultBaseClass, NumDefaultClasses, NextDefault, NextDesc);
00110		}
00111	}
00112	
00113	function LoadMapList()
00114	{
00115		local string FirstMap, NextMap, TestMap, MapName;
00116		local int i, IncludeCount;
00117		local UMenuMapList L;
00118	
00119		Exclude.Items.Clear();
00120		FirstMap = GetPlayerOwner().GetMapName(BotmatchParent.GameClass.Default.MapPrefix, "", 0);
00121		NextMap = FirstMap;
00122		while (!(FirstMap ~= TestMap))
00123		{
00124			// Add the map.
00125			if(!(Left(NextMap, Len(NextMap) - 4) ~= (BotmatchParent.GameClass.Default.MapPrefix$"-tutorial")))
00126			{
00127				L = UMenuMapList(Exclude.Items.Append(class'UMenuMapList'));
00128				L.MapName = NextMap;
00129				if(Right(NextMap, 4) ~= ".unr")
00130					L.DisplayName = Left(NextMap, Len(NextMap) - 4);
00131				else
00132					L.DisplayName = NextMap;
00133			}
00134	
00135			NextMap = GetPlayerOwner().GetMapName(BotmatchParent.GameClass.Default.MapPrefix, NextMap, 1);
00136			TestMap = NextMap;
00137		}
00138	
00139		// Now load the current maplist into Include, and remove them from Exclude.
00140		Include.Items.Clear();
00141		IncludeCount = ArrayCount(BotmatchParent.GameClass.Default.MapListType.Default.Maps);
00142		for(i=0;i<IncludeCount;i++)
00143		{
00144			MapName = BotmatchParent.GameClass.Default.MapListType.Default.Maps[i];
00145			if(MapName == "")
00146				break;
00147	
00148			L = UMenuMapList(Exclude.Items).FindMap(MapName);
00149	
00150			if(L != None)
00151			{
00152				L.Remove();
00153				Include.Items.AppendItem(L);
00154			}
00155			else
00156				Log("Unknown map in Map List: "$MapName);
00157		}
00158	
00159		Exclude.Sort();
00160	}
00161	
00162	function DefaultComboChanged()
00163	{
00164		local class<MapList> C;
00165		local int i, Count;
00166	
00167		if(bChangingDefault)
00168			return;
00169	
00170		if(DefaultCombo.GetSelectedIndex() == 0)
00171			return;
00172	
00173		bChangingDefault = True;
00174	
00175		C = class<MapList>(DynamicLoadObject(DefaultCombo.GetValue2(), class'Class'));
00176		if(C != None)
00177		{
00178			Count = ArrayCount(C.Default.Maps);
00179			for(i=0;i<Count;i++)
00180				BotmatchParent.GameClass.Default.MapListType.Default.Maps[i] = C.Default.Maps[i];
00181	
00182			BotmatchParent.GameClass.Default.MapListType.static.StaticSaveConfig();
00183	
00184			LoadMapList();	
00185		}
00186	
00187		bChangingDefault = False;
00188	}
00189	
00190	function SaveConfigs()
00191	{
00192		local int i, IncludeCount;
00193		local UMenuMapList L;
00194	
00195		Super.SaveConfigs();
00196	
00197		L = UMenuMapList(Include.Items.Next);
00198	
00199		IncludeCount = ArrayCount(BotmatchParent.GameClass.Default.MapListType.Default.Maps);
00200		for(i=0;i<IncludeCount;i++)
00201		{
00202			if(L == None)
00203				BotmatchParent.GameClass.Default.MapListType.Default.Maps[i] = "";
00204			else
00205			{
00206				BotmatchParent.GameClass.Default.MapListType.Default.Maps[i] = L.MapName;
00207				L = UMenuMapList(L.Next);
00208			}
00209		}
00210	
00211		BotmatchParent.GameClass.Default.MapListType.static.StaticSaveConfig();
00212	}
00213	
00214	function Notify(UWindowDialogControl C, byte E)
00215	{
00216		Super.Notify(C, E);
00217	
00218		switch(E)
00219		{
00220		case DE_Change:
00221			switch(C)
00222			{
00223			case DefaultCombo:
00224				DefaultComboChanged();
00225				break;
00226			case Exclude:
00227			case Include:
00228				DefaultCombo.SetSelectedIndex(0);
00229				break;
00230			}
00231			break;
00232		}
00233	}
00234	
00235	defaultproperties
00236	{
00237	     DefaultText="Use Map List: "
00238	     DefaultHelp="Choose a default map list to load, or choose Custom and configure the map list by hand."
00239	     CustomText="Custom"
00240	     ExcludeCaption="Maps Not Cycled"
00241	     ExcludeHelp="Click and drag a map to the right hand column to include that map in the map cycle list."
00242	     IncludeCaption="Maps Cycled"
00243	     IncludeHelp="Click and drag a map to the left hand column to remove it from the map cycle list, or drag it up or down to re-order it in the map cycle list."
00244	}

End Source Code