Draw editor terrain/resource preview as part of the world.
This commit is contained in:
@@ -20,6 +20,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
readonly EditorViewportControllerWidget editor;
|
||||
readonly WorldRenderer worldRenderer;
|
||||
readonly EditorCursorLayer editorCursor;
|
||||
|
||||
readonly ScrollPanelWidget layerTemplateList;
|
||||
readonly ScrollItemWidget layerPreviewTemplate;
|
||||
@@ -29,6 +30,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
this.worldRenderer = worldRenderer;
|
||||
editor = widget.Parent.Get<EditorViewportControllerWidget>("MAP_EDITOR");
|
||||
editorCursor = worldRenderer.World.WorldActor.Trait<EditorCursorLayer>();
|
||||
|
||||
layerTemplateList = widget.Get<ScrollPanelWidget>("LAYERTEMPLATE_LIST");
|
||||
layerTemplateList.Layout = new GridLayout(layerTemplateList);
|
||||
@@ -46,7 +48,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
foreach (var resource in resources)
|
||||
{
|
||||
var newResourcePreviewTemplate = ScrollItemWidget.Setup(layerPreviewTemplate,
|
||||
() => { var brush = editor.CurrentBrush as EditorResourceBrush; return brush != null && brush.ResourceType == resource; },
|
||||
() => editorCursor.Type == EditorCursorType.Resource && editorCursor.Resource == resource,
|
||||
() => editor.SetBrush(new EditorResourceBrush(editor, resource, worldRenderer)));
|
||||
|
||||
newResourcePreviewTemplate.Bounds.X = 0;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
@@ -36,6 +37,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
readonly TileSet tileset;
|
||||
readonly TileSelectorTemplate[] allTemplates;
|
||||
readonly EditorCursorLayer editorCursor;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public TileSelectorLogic(Widget widget, World world, WorldRenderer worldRenderer)
|
||||
@@ -43,6 +45,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
tileset = world.Map.Rules.TileSet;
|
||||
allTemplates = tileset.Templates.Values.Select(t => new TileSelectorTemplate(t)).ToArray();
|
||||
editorCursor = world.WorldActor.Trait<EditorCursorLayer>();
|
||||
|
||||
allCategories = allTemplates.SelectMany(t => t.Categories)
|
||||
.Distinct()
|
||||
@@ -98,7 +101,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
var tileId = t.Template.Id;
|
||||
var item = ScrollItemWidget.Setup(ItemTemplate,
|
||||
() => { var brush = Editor.CurrentBrush as EditorTileBrush; return brush != null && brush.Template == tileId; },
|
||||
() => editorCursor.Type == EditorCursorType.TerrainTemplate && editorCursor.TerrainTemplate.Id == tileId,
|
||||
() => Editor.SetBrush(new EditorTileBrush(Editor, tileId, WorldRenderer)));
|
||||
|
||||
var preview = item.Get<TerrainTemplatePreviewWidget>("TILE_PREVIEW");
|
||||
|
||||
Reference in New Issue
Block a user