public EditorActorBrush(EditorViewportControllerWidget editorWidget, ActorInfo actor, PlayerReference owner, WorldRenderer wr) { this.editorWidget = editorWidget; worldRenderer = wr; world = wr.World; editorLayer = world.WorldActor.Trait <EditorActorLayer>(); Actor = actor; this.owner = owner; preview = editorWidget.Get <ActorPreviewWidget>("DRAG_ACTOR_PREVIEW"); preview.GetScale = () => worldRenderer.Viewport.Zoom; preview.IsVisible = () => editorWidget.CurrentBrush == this; var buildingInfo = actor.Traits.GetOrDefault <BuildingInfo>(); if (buildingInfo != null) { locationOffset = -FootprintUtils.AdjustForBuildingSize(buildingInfo); previewOffset = FootprintUtils.CenterOffset(world, buildingInfo); } var td = new TypeDictionary(); td.Add(new FacingInit(facing)); td.Add(new TurretFacingInit(facing)); td.Add(new OwnerInit(owner.Name)); td.Add(new RaceInit(owner.Race)); preview.SetPreview(actor, td); // The preview widget may be rendered by the higher-level code before it is ticked. // Force a manual tick to ensure the bounds are set correctly for this first draw. Tick(); }
public EditorActorBrush(EditorViewportControllerWidget editorWidget, ActorInfo actor, PlayerReference owner, WorldRenderer wr) { this.editorWidget = editorWidget; worldRenderer = wr; world = wr.World; editorLayer = world.WorldActor.Trait<EditorActorLayer>(); Actor = actor; this.owner = owner; preview = editorWidget.Get<ActorPreviewWidget>("DRAG_ACTOR_PREVIEW"); preview.GetScale = () => worldRenderer.Viewport.Zoom; preview.IsVisible = () => editorWidget.CurrentBrush == this; var buildingInfo = actor.Traits.GetOrDefault<BuildingInfo>(); if (buildingInfo != null) { locationOffset = -FootprintUtils.AdjustForBuildingSize(buildingInfo); previewOffset = FootprintUtils.CenterOffset(world, buildingInfo); } var td = new TypeDictionary(); td.Add(new FacingInit(facing)); td.Add(new TurretFacingInit(facing)); td.Add(new OwnerInit(owner.Name)); td.Add(new RaceInit(owner.Race)); preview.SetPreview(actor, td); // The preview widget may be rendered by the higher-level code before it is ticked. // Force a manual tick to ensure the bounds are set correctly for this first draw. Tick(); }
public EditorCopyPasteBrush(EditorViewportControllerWidget editorWidget, WorldRenderer wr) { this.editorWidget = editorWidget; worldRenderer = wr; selectionLayer = wr.World.WorldActor.Trait <EditorSelectionLayer>(); editorLayer = wr.World.WorldActor.Trait <EditorActorLayer>(); }
public EditorCopyPasteBrush(EditorViewportControllerWidget editorWidget, WorldRenderer wr) { this.editorWidget = editorWidget; worldRenderer = wr; selectionLayer = wr.World.WorldActor.Trait<EditorSelectionLayer>(); editorLayer = wr.World.WorldActor.Trait<EditorActorLayer>(); }
public EditorCopyPasteBrush(EditorViewportControllerWidget editorWidget, WorldRenderer wr, Func <MapCopyFilters> getCopyFilters) { this.editorWidget = editorWidget; worldRenderer = wr; selectionLayer = wr.World.WorldActor.Trait <EditorSelectionLayer>(); editorLayer = wr.World.WorldActor.Trait <EditorActorLayer>(); this.getCopyFilters = getCopyFilters; }
public EditorActorBrush(EditorViewportControllerWidget editorWidget, ActorInfo actor, PlayerReference owner, WorldRenderer wr) { this.editorWidget = editorWidget; worldRenderer = wr; world = wr.World; editorLayer = world.WorldActor.Trait <EditorActorLayer>(); editorActionManager = world.WorldActor.Trait <EditorActionManager>(); Actor = actor; this.owner = owner; var ownerName = owner.Name; preview = editorWidget.Get <ActorPreviewWidget>("DRAG_ACTOR_PREVIEW"); preview.GetScale = () => worldRenderer.Viewport.Zoom; preview.IsVisible = () => editorWidget.CurrentBrush == this; var buildingInfo = actor.TraitInfoOrDefault <BuildingInfo>(); if (buildingInfo != null) { centerOffset = buildingInfo.CenterOffset(world); } // Enforce first entry of ValidOwnerNames as owner if the actor has RequiresSpecificOwners var specificOwnerInfo = actor.TraitInfoOrDefault <RequiresSpecificOwnersInfo>(); if (specificOwnerInfo != null && !specificOwnerInfo.ValidOwnerNames.Contains(ownerName)) { ownerName = specificOwnerInfo.ValidOwnerNames.First(); } var td = new TypeDictionary(); td.Add(new FacingInit(facing)); td.Add(new TurretFacingInit(facing)); td.Add(new OwnerInit(ownerName)); td.Add(new FactionInit(owner.Faction)); preview.SetPreview(actor, td); var ios = actor.TraitInfoOrDefault <IOccupySpaceInfo>(); if (ios != null) { footprint = ios.OccupiedCells(actor, CPos.Zero) .Select(c => c.Key - CPos.Zero) .ToArray(); } else { footprint = new CVec[0]; } // The preview widget may be rendered by the higher-level code before it is ticked. // Force a manual tick to ensure the bounds are set correctly for this first draw. Tick(); }
public EditorDefaultBrush(EditorViewportControllerWidget editorWidget, WorldRenderer wr) { this.editorWidget = editorWidget; worldRenderer = wr; world = wr.World; editorLayer = world.WorldActor.Trait<EditorActorLayer>(); resources = world.WorldActor.TraitsImplementing<ResourceType>() .ToDictionary(r => r.Info.ResourceType, r => r); }
public EditorActorBrush(EditorViewportControllerWidget editorWidget, ActorInfo actor, PlayerReference owner, WorldRenderer wr) { this.editorWidget = editorWidget; world = wr.World; editorLayer = world.WorldActor.Trait <EditorActorLayer>(); editorCursor = world.WorldActor.Trait <EditorCursorLayer>(); editorActionManager = world.WorldActor.Trait <EditorActionManager>(); cursorToken = editorCursor.SetActor(wr, actor, owner); }
public EditorDefaultBrush(EditorViewportControllerWidget editorWidget, WorldRenderer wr) { this.editorWidget = editorWidget; worldRenderer = wr; world = wr.World; editorLayer = world.WorldActor.Trait <EditorActorLayer>(); editorActionManager = world.WorldActor.Trait <EditorActionManager>(); resourceLayer = world.WorldActor.Trait <IResourceLayer>(); }
public EditorDefaultBrush(EditorViewportControllerWidget editorWidget, WorldRenderer wr) { this.editorWidget = editorWidget; worldRenderer = wr; world = wr.World; editorLayer = world.WorldActor.Trait <EditorActorLayer>(); resources = world.WorldActor.TraitsImplementing <ResourceType>() .ToDictionary(r => r.Info.ResourceType, r => r); }
public EditorResourceBrush(EditorViewportControllerWidget editorWidget, ResourceTypeInfo resource, WorldRenderer wr) { this.editorWidget = editorWidget; ResourceType = resource; worldRenderer = wr; world = wr.World; editorActionManager = world.WorldActor.Trait <EditorActionManager>(); editorCursor = world.WorldActor.Trait <EditorCursorLayer>(); action = new AddResourcesEditorAction(world.Map, ResourceType); cursorToken = editorCursor.SetResource(wr, resource); }
public EditorTileBrush(EditorViewportControllerWidget editorWidget, ushort id, WorldRenderer wr) { this.editorWidget = editorWidget; worldRenderer = wr; world = wr.World; editorActionManager = world.WorldActor.Trait <EditorActionManager>(); editorCursor = world.WorldActor.Trait <EditorCursorLayer>(); Template = id; worldRenderer = wr; world = wr.World; var template = world.Map.Rules.TileSet.Templates.First(t => t.Value.Id == id).Value; cursorToken = editorCursor.SetTerrainTemplate(wr, template); }
public ActorSelectorLogic(Widget widget, World world, WorldRenderer worldRenderer, Ruleset modRules) { this.modRules = modRules; this.world = world; this.worldRenderer = worldRenderer; editor = widget.Parent.Get<EditorViewportControllerWidget>("MAP_EDITOR"); ownersDropDown = widget.Get<DropDownButtonWidget>("OWNERS_DROPDOWN"); panel = widget.Get<ScrollPanelWidget>("ACTORTEMPLATE_LIST"); itemTemplate = panel.Get<ScrollItemWidget>("ACTORPREVIEW_TEMPLATE"); panel.Layout = new GridLayout(panel); var editorLayer = world.WorldActor.Trait<EditorActorLayer>(); selectedOwner = editorLayer.Players.Players.Values.First(); Func<PlayerReference, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) => { var item = ScrollItemWidget.Setup(template, () => selectedOwner == option, () => { selectedOwner = option; ownersDropDown.Text = selectedOwner.Name; ownersDropDown.TextColor = selectedOwner.Color.RGB; IntializeActorPreviews(); }); item.Get<LabelWidget>("LABEL").GetText = () => option.Name; item.GetColor = () => option.Color.RGB; return item; }; ownersDropDown.OnClick = () => { var owners = editorLayer.Players.Players.Values.OrderBy(p => p.Name); ownersDropDown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 270, owners, setupItem); }; ownersDropDown.Text = selectedOwner.Name; ownersDropDown.TextColor = selectedOwner.Color.RGB; IntializeActorPreviews(); }
public EditorTileBrush(EditorViewportControllerWidget editorWidget, ushort template, WorldRenderer wr) { this.editorWidget = editorWidget; Template = template; worldRenderer = wr; world = wr.World; preview = editorWidget.Get <TerrainTemplatePreviewWidget>("DRAG_TILE_PREVIEW"); preview.GetScale = () => worldRenderer.Viewport.Zoom; preview.IsVisible = () => editorWidget.CurrentBrush == this; preview.Template = world.TileSet.Templates.First(t => t.Value.Id == template).Value; bounds = worldRenderer.Theater.TemplateBounds(preview.Template, Game.ModData.Manifest.TileSize, world.Map.TileShape); // The preview widget may be rendered by the higher-level code before it is ticked. // Force a manual tick to ensure the bounds are set correctly for this first draw. Tick(); }
public EditorTileBrush(EditorViewportControllerWidget editorWidget, ushort template, WorldRenderer wr) { this.editorWidget = editorWidget; Template = template; worldRenderer = wr; world = wr.World; preview = editorWidget.Get<TerrainTemplatePreviewWidget>("DRAG_TILE_PREVIEW"); preview.GetScale = () => worldRenderer.Viewport.Zoom; preview.IsVisible = () => editorWidget.CurrentBrush == this; preview.Template = world.TileSet.Templates.First(t => t.Value.Id == template).Value; bounds = worldRenderer.Theater.TemplateBounds(preview.Template, Game.ModData.Manifest.TileSize, world.Map.TileShape); // The preview widget may be rendered by the higher-level code before it is ticked. // Force a manual tick to ensure the bounds are set correctly for this first draw. Tick(); }
public EditorResourceBrush(EditorViewportControllerWidget editorWidget, ResourceTypeInfo resource, WorldRenderer wr) { this.editorWidget = editorWidget; ResourceType = resource; worldRenderer = wr; world = wr.World; preview = editorWidget.Get<SpriteWidget>("DRAG_LAYER_PREVIEW"); preview.Palette = resource.Palette; preview.GetScale = () => worldRenderer.Viewport.Zoom; preview.IsVisible = () => editorWidget.CurrentBrush == this; var variant = resource.Sequences.FirstOrDefault(); var sequence = wr.World.Map.Rules.Sequences.GetSequence("resources", variant); var sprite = sequence.GetSprite(resource.MaxDensity - 1); preview.GetSprite = () => sprite; // The preview widget may be rendered by the higher-level code before it is ticked. // Force a manual tick to ensure the bounds are set correctly for this first draw. Tick(); }
public EditorResourceBrush(EditorViewportControllerWidget editorWidget, ResourceTypeInfo resource, WorldRenderer wr) { this.editorWidget = editorWidget; ResourceType = resource; worldRenderer = wr; world = wr.World; preview = editorWidget.Get <SpriteWidget>("DRAG_LAYER_PREVIEW"); preview.Palette = resource.Palette; preview.GetScale = () => worldRenderer.Viewport.Zoom; preview.IsVisible = () => editorWidget.CurrentBrush == this; var variant = resource.Variants.FirstOrDefault(); var sequence = wr.World.Map.Rules.Sequences.GetSequence("resources", variant); var sprite = sequence.GetSprite(resource.MaxDensity - 1); preview.GetSprite = () => sprite; // The preview widget may be rendered by the higher-level code before it is ticked. // Force a manual tick to ensure the bounds are set correctly for this first draw. Tick(); }
public EditorTileBrush(EditorViewportControllerWidget editorWidget, ushort id, WorldRenderer wr) { this.editorWidget = editorWidget; worldRenderer = wr; world = wr.World; terrainInfo = world.Map.Rules.TerrainInfo as ITemplatedTerrainInfo; if (terrainInfo == null) { throw new InvalidDataException("EditorTileBrush can only be used with template-based tilesets"); } editorActionManager = world.WorldActor.Trait <EditorActionManager>(); editorCursor = world.WorldActor.Trait <EditorCursorLayer>(); Template = id; worldRenderer = wr; world = wr.World; var template = terrainInfo.Templates.First(t => t.Value.Id == id).Value; cursorToken = editorCursor.SetTerrainTemplate(wr, template); }