Initial no-frills mod selector
This commit is contained in:
@@ -18,6 +18,7 @@ namespace OpenRA.FileFormats
|
|||||||
{
|
{
|
||||||
public class Mod
|
public class Mod
|
||||||
{
|
{
|
||||||
|
public string Id;
|
||||||
public string Title;
|
public string Title;
|
||||||
public string Description;
|
public string Description;
|
||||||
public string Version;
|
public string Version;
|
||||||
@@ -40,6 +41,7 @@ namespace OpenRA.FileFormats
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
ret.Add(m, FieldLoader.Load<Mod>(yaml.NodesDict["Metadata"]));
|
ret.Add(m, FieldLoader.Load<Mod>(yaml.NodesDict["Metadata"]));
|
||||||
|
ret[m].Id = m;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,7 @@
|
|||||||
<Compile Include="Widgets\CncInstallLogic.cs" />
|
<Compile Include="Widgets\CncInstallLogic.cs" />
|
||||||
<Compile Include="Widgets\CncMusicPlayerLogic.cs" />
|
<Compile Include="Widgets\CncMusicPlayerLogic.cs" />
|
||||||
<Compile Include="CncColorPickerPaletteModifier.cs" />
|
<Compile Include="CncColorPickerPaletteModifier.cs" />
|
||||||
|
<Compile Include="Widgets\CncModBrowserLogic.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||||
|
|||||||
@@ -44,7 +44,14 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
panel.GetWidget<CncMenuButtonWidget>("QUIT_BUTTON").OnClick = Game.Exit;
|
panel.GetWidget<CncMenuButtonWidget>("QUIT_BUTTON").OnClick = Game.Exit;
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
panel.GetWidget<CncMenuButtonWidget>("MODS_BUTTON").IsDisabled = () => true;
|
panel.GetWidget<CncMenuButtonWidget>("MODS_BUTTON").OnClick = () =>
|
||||||
|
{
|
||||||
|
Widget.OpenWindow("MODS_PANEL", new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
{ "onExit", new Action(Widget.CloseWindow) },
|
||||||
|
{ "onSwitch", new Action(Widget.CloseWindow) },
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,13 +98,22 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
var settingsMenu = widget.GetWidget("SETTINGS_MENU");
|
var settingsMenu = widget.GetWidget("SETTINGS_MENU");
|
||||||
settingsMenu.IsVisible = () => Menu == MenuType.Settings;
|
settingsMenu.IsVisible = () => Menu == MenuType.Settings;
|
||||||
|
|
||||||
settingsMenu.GetWidget<CncMenuButtonWidget>("MODS_BUTTON").IsDisabled = () => true;
|
settingsMenu.GetWidget<CncMenuButtonWidget>("MODS_BUTTON").OnClick = () =>
|
||||||
|
{
|
||||||
|
Menu = MenuType.None;
|
||||||
|
Widget.OpenWindow("MODS_PANEL", new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
{ "onExit", new Action(() => ReturnToMenu(MenuType.Settings)) },
|
||||||
|
{ "onSwitch", new Action(RemoveShellmapUI) }
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
settingsMenu.GetWidget<CncMenuButtonWidget>("MUSIC_BUTTON").OnClick = () =>
|
settingsMenu.GetWidget<CncMenuButtonWidget>("MUSIC_BUTTON").OnClick = () =>
|
||||||
{
|
{
|
||||||
Menu = MenuType.None;
|
Menu = MenuType.None;
|
||||||
Widget.OpenWindow("MUSIC_PANEL", new Dictionary<string, object>()
|
Widget.OpenWindow("MUSIC_PANEL", new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
{ "onExit", new Action(() => ReturnToMenu(MenuType.Main)) },
|
{ "onExit", new Action(() => ReturnToMenu(MenuType.Settings)) },
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
88
OpenRA.Mods.Cnc/Widgets/CncModBrowserLogic.cs
Normal file
88
OpenRA.Mods.Cnc/Widgets/CncModBrowserLogic.cs
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation. For more information,
|
||||||
|
* see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Mods.RA.Widgets.Delegates;
|
||||||
|
using OpenRA.Server;
|
||||||
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Cnc.Widgets
|
||||||
|
{
|
||||||
|
public class CncModBrowserLogic : IWidgetDelegate
|
||||||
|
{
|
||||||
|
Mod currentMod;
|
||||||
|
|
||||||
|
[ObjectCreator.UseCtor]
|
||||||
|
public CncModBrowserLogic([ObjectCreator.Param] Widget widget,
|
||||||
|
[ObjectCreator.Param] Action onSwitch,
|
||||||
|
[ObjectCreator.Param] Action onExit)
|
||||||
|
{
|
||||||
|
var panel = widget.GetWidget("MODS_PANEL");
|
||||||
|
var modList = panel.GetWidget<ScrollPanelWidget>("MOD_LIST");
|
||||||
|
var loadButton = panel.GetWidget<CncMenuButtonWidget>("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.IsDisabled = () => currentMod.Id == Game.CurrentMods.Keys.First();
|
||||||
|
|
||||||
|
panel.GetWidget<CncMenuButtonWidget>("BACK_BUTTON").OnClick = onExit;
|
||||||
|
currentMod = Mod.AllMods[Game.modData.Manifest.Mods[0]];
|
||||||
|
|
||||||
|
// Mod list
|
||||||
|
var modTemplate = modList.GetWidget("MOD_TEMPLATE");
|
||||||
|
|
||||||
|
foreach (var m in Mod.AllMods)
|
||||||
|
{
|
||||||
|
var mod = m.Value;
|
||||||
|
var template = modTemplate.Clone() as ContainerWidget;
|
||||||
|
template.GetBackground = () => (template.RenderBounds.Contains(Viewport.LastMousePos) ? "button-hover" : (currentMod == mod) ? "button-pressed" : null);
|
||||||
|
template.OnMouseDown = mi => { if (mi.Button != MouseButton.Left) return false; currentMod = mod; return true; };
|
||||||
|
template.IsVisible = () => true;
|
||||||
|
template.GetWidget<LabelWidget>("TITLE").GetText = () => mod.Title;
|
||||||
|
template.GetWidget<LabelWidget>("VERSION").GetText = () => mod.Version;
|
||||||
|
template.GetWidget<LabelWidget>("AUTHOR").GetText = () => mod.Author;
|
||||||
|
modList.AddChild(template);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
// 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);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
94
mods/cnc/chrome/modchooser.yaml
Normal file
94
mods/cnc/chrome/modchooser.yaml
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
Container@MODS_PANEL:
|
||||||
|
Id:MODS_PANEL
|
||||||
|
Delegate:CncModBrowserLogic
|
||||||
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
|
Y:(WINDOW_BOTTOM - 500)/2
|
||||||
|
Width:740
|
||||||
|
Height:535
|
||||||
|
Children:
|
||||||
|
Label@TITLE:
|
||||||
|
Text:Select Mod
|
||||||
|
Width:740
|
||||||
|
Y:0-25
|
||||||
|
Font:BigBold
|
||||||
|
Contrast:true
|
||||||
|
Align:Center
|
||||||
|
Background@bg:
|
||||||
|
Width:740
|
||||||
|
Height:500
|
||||||
|
Background:panel-black
|
||||||
|
Children:
|
||||||
|
CncScrollPanel@MOD_LIST:
|
||||||
|
Id:MOD_LIST
|
||||||
|
X:15
|
||||||
|
Y:30
|
||||||
|
Width:710
|
||||||
|
Height:455
|
||||||
|
Children:
|
||||||
|
Container@MOD_TEMPLATE:
|
||||||
|
Id:MOD_TEMPLATE
|
||||||
|
Width:PARENT_RIGHT-27
|
||||||
|
Height:25
|
||||||
|
X:2
|
||||||
|
Y:0
|
||||||
|
Visible:false
|
||||||
|
Children:
|
||||||
|
Label@TITLE:
|
||||||
|
X:10
|
||||||
|
Id:TITLE
|
||||||
|
Width:200
|
||||||
|
Height:25
|
||||||
|
Label@AUTHOR:
|
||||||
|
Id:AUTHOR
|
||||||
|
X:PARENT_RIGHT-300
|
||||||
|
Align:Center
|
||||||
|
Width:50
|
||||||
|
Height:25
|
||||||
|
Label@VERSION:
|
||||||
|
Id:VERSION
|
||||||
|
Width:140
|
||||||
|
X:PARENT_RIGHT-150
|
||||||
|
Align:Center
|
||||||
|
Height:25
|
||||||
|
Container@MOD_LABELS:
|
||||||
|
Width:710-25
|
||||||
|
Height:25
|
||||||
|
X:15
|
||||||
|
Y:5
|
||||||
|
Children:
|
||||||
|
Label@TITLE:
|
||||||
|
Width:125
|
||||||
|
Height:25
|
||||||
|
X:0
|
||||||
|
Y:0
|
||||||
|
Text:Title
|
||||||
|
Align:Center
|
||||||
|
Font:Bold
|
||||||
|
Label@AUTHOR:
|
||||||
|
X:PARENT_RIGHT-300
|
||||||
|
Align:Center
|
||||||
|
Width:50
|
||||||
|
Height:25
|
||||||
|
Text:Author
|
||||||
|
Font:Bold
|
||||||
|
Label@VERSION:
|
||||||
|
Width:140
|
||||||
|
X:PARENT_RIGHT-150
|
||||||
|
Align:Center
|
||||||
|
Height:25
|
||||||
|
Text:Version
|
||||||
|
Font:Bold
|
||||||
|
CncMenuButton@BACK_BUTTON:
|
||||||
|
Id:BACK_BUTTON
|
||||||
|
X:0
|
||||||
|
Y:499
|
||||||
|
Width:140
|
||||||
|
Height:35
|
||||||
|
Text:Back
|
||||||
|
CncMenuButton@LOAD_BUTTON:
|
||||||
|
Id:LOAD_BUTTON
|
||||||
|
X:600
|
||||||
|
Y:499
|
||||||
|
Width:140
|
||||||
|
Height:35
|
||||||
|
Text:Load Mod
|
||||||
@@ -73,6 +73,7 @@ ChromeLayout:
|
|||||||
mods/cnc/chrome/ingame.yaml
|
mods/cnc/chrome/ingame.yaml
|
||||||
mods/cnc/chrome/ingamemenu.yaml
|
mods/cnc/chrome/ingamemenu.yaml
|
||||||
mods/cnc/chrome/music.yaml
|
mods/cnc/chrome/music.yaml
|
||||||
|
mods/cnc/chrome/modchooser.yaml
|
||||||
|
|
||||||
Weapons:
|
Weapons:
|
||||||
mods/cnc/weapons.yaml
|
mods/cnc/weapons.yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user