Cleanup in MapEditorTabsLogic
This commit is contained in:
@@ -16,34 +16,31 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{
|
{
|
||||||
public class MapEditorTabsLogic : ChromeLogic
|
public class MapEditorTabsLogic : ChromeLogic
|
||||||
{
|
{
|
||||||
|
readonly Widget widget;
|
||||||
|
|
||||||
protected enum MenuType { Tiles, Layers, Actors }
|
protected enum MenuType { Tiles, Layers, Actors }
|
||||||
protected MenuType menuType = MenuType.Tiles;
|
protected MenuType menuType = MenuType.Tiles;
|
||||||
|
readonly Widget tabContainer;
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public MapEditorTabsLogic(Widget widget, WorldRenderer worldRenderer)
|
public MapEditorTabsLogic(Widget widget, WorldRenderer worldRenderer)
|
||||||
{
|
{
|
||||||
var tabContainer = widget.Get("MAP_EDITOR_TAB_CONTAINER");
|
this.widget = widget;
|
||||||
|
tabContainer = widget.Get("MAP_EDITOR_TAB_CONTAINER");
|
||||||
|
|
||||||
var tilesTab = tabContainer.Get<ButtonWidget>("TILES_TAB");
|
SetupTab("TILES_TAB", "TILE_WIDGETS", MenuType.Tiles);
|
||||||
tilesTab.IsHighlighted = () => menuType == MenuType.Tiles;
|
SetupTab("OVERLAYS_TAB", "LAYER_WIDGETS", MenuType.Layers);
|
||||||
tilesTab.OnClick = () => { menuType = MenuType.Tiles; };
|
SetupTab("ACTORS_TAB", "ACTOR_WIDGETS", MenuType.Actors);
|
||||||
|
}
|
||||||
|
|
||||||
var overlaysTab = tabContainer.Get<ButtonWidget>("OVERLAYS_TAB");
|
void SetupTab(string buttonId, string tabId, MenuType tabType)
|
||||||
overlaysTab.IsHighlighted = () => menuType == MenuType.Layers;
|
{
|
||||||
overlaysTab.OnClick = () => { menuType = MenuType.Layers; };
|
var tab = tabContainer.Get<ButtonWidget>(buttonId);
|
||||||
|
tab.IsHighlighted = () => menuType == tabType;
|
||||||
|
tab.OnClick = () => { menuType = tabType; };
|
||||||
|
|
||||||
var actorsTab = tabContainer.Get<ButtonWidget>("ACTORS_TAB");
|
var container = widget.Parent.Get<ContainerWidget>(tabId);
|
||||||
actorsTab.IsHighlighted = () => menuType == MenuType.Actors;
|
container.IsVisible = () => menuType == tabType;
|
||||||
actorsTab.OnClick = () => { menuType = MenuType.Actors; };
|
|
||||||
|
|
||||||
var tileContainer = widget.Parent.Get<ContainerWidget>("TILE_WIDGETS");
|
|
||||||
tileContainer.IsVisible = () => menuType == MenuType.Tiles;
|
|
||||||
|
|
||||||
var layerContainer = widget.Parent.Get<ContainerWidget>("LAYER_WIDGETS");
|
|
||||||
layerContainer.IsVisible = () => menuType == MenuType.Layers;
|
|
||||||
|
|
||||||
var actorContainer = widget.Parent.Get<ContainerWidget>("ACTOR_WIDGETS");
|
|
||||||
actorContainer.IsVisible = () => menuType == MenuType.Actors;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user