Use new mechanism for mod list

This commit is contained in:
Paul Chote
2011-05-22 17:09:36 +12:00
parent 078972e3be
commit 0c9692c0b1
2 changed files with 46 additions and 59 deletions

View File

@@ -29,24 +29,7 @@ namespace OpenRA.Mods.Cnc.Widgets
var panel = widget.GetWidget("MODS_PANEL");
var modList = panel.GetWidget<ScrollPanelWidget>("MOD_LIST");
var loadButton = panel.GetWidget<ButtonWidget>("LOAD_BUTTON");
loadButton.OnClick = () =>
{
// TODO: This is crap
var mods = new List<string>() { currentMod.Id };
var m = currentMod;
while (!string.IsNullOrEmpty(m.Requires))
{
m = Mod.AllMods[currentMod.Requires];
mods.Add(m.Id);
}
Game.RunAfterTick(() =>
{
Widget.CloseWindow();
onSwitch();
Game.InitializeWithMods(mods.ToArray());
});
};
loadButton.OnClick = () => LoadMod(currentMod.Id, onSwitch);
loadButton.IsDisabled = () => currentMod.Id == Game.CurrentMods.Keys.First();
panel.GetWidget<ButtonWidget>("BACK_BUTTON").OnClick = () => { Widget.CloseWindow(); onExit(); };
@@ -64,17 +47,23 @@ namespace OpenRA.Mods.Cnc.Widgets
item.GetWidget<LabelWidget>("AUTHOR").GetText = () => mod.Author;
modList.AddChild(item);
}
/*
// Server info
var infoPanel = panel.GetWidget("SERVER_INFO");
infoPanel.IsVisible = () => currentServer != null;
infoPanel.GetWidget<LabelWidget>("SERVER_IP").GetText = () => currentServer.Address;
infoPanel.GetWidget<LabelWidget>("SERVER_MODS").GetText = () => ServerBrowserDelegate.GenerateModsLabel(currentServer);
infoPanel.GetWidget<LabelWidget>("MAP_TITLE").GetText = () => (CurrentMap() != null) ? CurrentMap().Title : "Unknown";
infoPanel.GetWidget<LabelWidget>("MAP_PLAYERS").GetText = () => GetPlayersLabel(currentServer);
*/
}
void LoadMod(string mod, Action onSwitch)
{
var mods = new List<string>();
while (!string.IsNullOrEmpty(mod))
{
mods.Add(mod);
mod = Mod.AllMods[mod].Requires;
}
Game.RunAfterTick(() =>
{
Widget.CloseWindow();
onSwitch();
Game.InitializeWithMods(mods.ToArray());
});
}
}
}