public HistoryLogLogic(Widget widget, World world, WorldRenderer worldRenderer, Dictionary <string, MiniYaml> logicArgs) { panel = widget.Get <ScrollPanelWidget>("HISTORY_LIST"); template = panel.Get <ScrollItemWidget>("HISTORY_TEMPLATE"); editorActionManager = world.WorldActor.Trait <EditorActionManager>(); editorActionManager.ItemAdded += ItemAdded; editorActionManager.ItemRemoved += ItemRemoved; }
public EditorViewportControllerWidget(World world, WorldRenderer worldRenderer) { this.worldRenderer = worldRenderer; tooltipContainer = Exts.Lazy(() => Ui.Root.Get <TooltipContainerWidget>(TooltipContainer)); CurrentBrush = DefaultBrush = new EditorDefaultBrush(this, worldRenderer); editorActionManager = world.WorldActor.Trait <EditorActionManager>(); editorActionManager.OnChange += EditorActionManagerOnChange; }
public HistoryLogLogic(Widget widget, World world) { panel = widget.Get <ScrollPanelWidget>("HISTORY_LIST"); template = panel.Get <ScrollItemWidget>("HISTORY_TEMPLATE"); editorActionManager = world.WorldActor.Trait <EditorActionManager>(); editorActionManager.ItemAdded += ItemAdded; editorActionManager.ItemRemoved += ItemRemoved; }
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 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 EditorCopyPasteBrush(EditorViewportControllerWidget editorWidget, WorldRenderer wr, Func <MapCopyFilters> getCopyFilters) { this.editorWidget = editorWidget; worldRenderer = wr; editorActionManager = wr.World.WorldActor.Trait <EditorActionManager>(); selectionLayer = wr.World.WorldActor.Trait <EditorSelectionLayer>(); editorLayer = wr.World.WorldActor.Trait <EditorActorLayer>(); this.getCopyFilters = getCopyFilters; }
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); editorActionManager = world.WorldActor.Trait <EditorActionManager>(); }
public EditorViewportControllerWidget(World world, WorldRenderer worldRenderer) { this.worldRenderer = worldRenderer; tooltipContainer = Exts.Lazy(() => Ui.Root.Get <TooltipContainerWidget>(TooltipContainer)); CurrentBrush = DefaultBrush = new EditorDefaultBrush(this, worldRenderer); editorActionManager = world.WorldActor.Trait <EditorActionManager>(); editorActionManager.OnChange += EditorActionManagerOnChange; // Allow zooming out to full map size worldRenderer.Viewport.UnlockMinimumZoom(0.25f); }
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 StackedEditorResourceBrush(EditorViewportControllerWidget editorWidget, string resourceType, WorldRenderer wr) { this.editorWidget = editorWidget; ResourceType = resourceType; worldRenderer = wr; world = wr.World; editorActionManager = world.WorldActor.Trait <EditorActionManager>(); editorCursor = world.WorldActor.Trait <EditorCursorLayer>(); resourceLayer = world.WorldActor.Trait <IResourceLayer>(); action = new AddResourcesEditorAction(resourceType, resourceLayer); cursorToken = editorCursor.SetResource(wr, resourceType); }
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 EditorTileBrush(EditorViewportControllerWidget editorWidget, ushort template, WorldRenderer wr) { this.editorWidget = editorWidget; Template = template; worldRenderer = wr; world = wr.World; editorActionManager = world.WorldActor.Trait <EditorActionManager>(); preview = editorWidget.Get <TerrainTemplatePreviewWidget>("DRAG_TILE_PREVIEW"); preview.GetScale = () => worldRenderer.Viewport.Zoom; preview.IsVisible = () => editorWidget.CurrentBrush == this; preview.Template = world.Map.Rules.TileSet.Templates.First(t => t.Value.Id == template).Value; var grid = world.Map.Grid; bounds = worldRenderer.Theater.TemplateBounds(preview.Template, grid.TileSize, grid.Type); // 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); }
public EditorResourceBrush(EditorViewportControllerWidget editorWidget, ResourceTypeInfo resource, WorldRenderer wr) { this.editorWidget = editorWidget; ResourceType = resource; worldRenderer = wr; world = wr.World; editorActionManager = world.WorldActor.Trait <EditorActionManager>(); action = new AddResourcesEditorAction(world.Map, ResourceType); 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 ActorEditLogic(Widget widget, World world, WorldRenderer worldRenderer, Dictionary <string, MiniYaml> logicArgs) { this.worldRenderer = worldRenderer; editorActorLayer = world.WorldActor.Trait <EditorActorLayer>(); editorActionManager = world.WorldActor.Trait <EditorActionManager>(); editor = widget.Parent.Get <EditorViewportControllerWidget>("MAP_EDITOR"); actorEditPanel = editor.Get <BackgroundWidget>("ACTOR_EDIT_PANEL"); typeLabel = actorEditPanel.Get <LabelWidget>("ACTOR_TYPE_LABEL"); actorIDField = actorEditPanel.Get <TextFieldWidget>("ACTOR_ID"); initContainer = actorEditPanel.Get("ACTOR_INIT_CONTAINER"); buttonContainer = actorEditPanel.Get("BUTTON_CONTAINER"); checkboxOptionTemplate = initContainer.Get("CHECKBOX_OPTION_TEMPLATE"); sliderOptionTemplate = initContainer.Get("SLIDER_OPTION_TEMPLATE"); dropdownOptionTemplate = initContainer.Get("DROPDOWN_OPTION_TEMPLATE"); initContainer.RemoveChildren(); var deleteButton = actorEditPanel.Get <ButtonWidget>("DELETE_BUTTON"); var cancelButton = actorEditPanel.Get <ButtonWidget>("CANCEL_BUTTON"); var okButton = actorEditPanel.Get <ButtonWidget>("OK_BUTTON"); actorIDErrorLabel = actorEditPanel.Get <LabelWidget>("ACTOR_ID_ERROR_LABEL"); actorIDErrorLabel.IsVisible = () => actorIDStatus != ActorIDStatus.Normal; actorIDErrorLabel.GetText = () => actorIDStatus == ActorIDStatus.Duplicate ? "Duplicate Actor ID" : "Enter an Actor ID"; MiniYaml yaml; if (logicArgs.TryGetValue("EditPanelPadding", out yaml)) { editPanelPadding = FieldLoader.GetValue <int>("EditPanelPadding", yaml.Value); } okButton.IsDisabled = () => !IsValid() || !editActorPreview.IsDirty; okButton.OnClick = Save; cancelButton.OnClick = Cancel; deleteButton.OnClick = Delete; actorEditPanel.IsVisible = () => CurrentActor != null && editor.CurrentBrush == editor.DefaultBrush && Game.RunTime > lastScrollTime + scrollVisibleTimeout; actorIDField.OnEscKey = () => { actorIDField.YieldKeyboardFocus(); return(true); }; actorIDField.OnTextEdited = () => { var actorId = actorIDField.Text.Trim(); if (string.IsNullOrWhiteSpace(actorId)) { nextActorIDStatus = ActorIDStatus.Empty; return; } // Check for duplicate actor ID if (CurrentActor.ID.Equals(actorId, StringComparison.OrdinalIgnoreCase)) { if (editorActorLayer[actorId] != null) { nextActorIDStatus = ActorIDStatus.Duplicate; return; } } SetActorID(actorId); nextActorIDStatus = ActorIDStatus.Normal; }; actorIDField.OnLoseFocus = () => { // Reset invalid IDs back to their starting value if (actorIDStatus != ActorIDStatus.Normal) { SetActorID(initialActorID); } }; }
public void WorldLoaded(World w, WorldRenderer wr) { map = w.Map; editorActionManager = w.WorldActor.Trait <EditorActionManager>(); }