RMenu
Class RuneMenuMapListClientWindow

source: c:\runehov\RMenu\Classes\RuneMenuMaplistClientWindow.uc
Core.Object
   |
   +--UWindow.UWindowBase
      |
      +--UWindow.UWindowWindow
         |
         +--UWindow.UWindowClientWindow
            |
            +--UWindow.UWindowDialogClientWindow
               |
               +--UWindow.UWindowPageWindow
                  |
                  +--RMenu.RuneMenuPageWindow
                     |
                     +--RMenu.RuneMenuMapListClientWindow
Direct Known Subclasses:None

class RuneMenuMapListClientWindow
extends RMenu.RuneMenuPageWindow


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

End Source Code