示例#1
0
        public TextAttributeEditor(string name, MapEditorState state, bool scrollable, bool monospace, ref int currentY) : base(name, state, ref currentY)
        {
            if (scrollable)
            {
                State.ScrollableTextFields.Add("editor-" + GetType().Name + "-" + Name, ScrollableTextField = new ScrollableTextField()
                {
                    Label = name + ": ",
                    Text  = "",
                    Area  = new TweenedRectangle(state.Game, new Rectangle(state.Game.GraphicsDevice.Viewport.Bounds.Width / 2 - 400 / 2, currentY, 400, 140)),
                    Font  = monospace ? state.Game.DefaultFonts.MonoBold : state.Game.DefaultFonts.Bold,
                });

                currentY += ScrollableTextField.Area.Value.Height + 4;
            }
            else
            {
                State.TextFields.Add("editor-" + GetType().Name + "-" + Name, TextField = new TextField()
                {
                    Label    = name + ": ",
                    Text     = "",
                    Position = new TweenedVector2(state.Game, new Vector2(state.Game.GraphicsDevice.Viewport.Bounds.Width / 2 - 400 / 2, currentY)),
                    Font     = monospace ? state.Game.DefaultFonts.MonoBold : state.Game.DefaultFonts.Bold,
                    Width    = 400,
                    Lines    = 1
                });

                currentY += TextField.Rectangle.Height + 4;
            }
        }
示例#2
0
 private void b_PlayerSpawn_Click(object sender, EventArgs e)
 {
     if (MapImage != null)
     {
         b_PlayerSpawn.Text = "Click on Tile to Set Spawn";
         CurrentState       = MapEditorState.PlayerSpawn;
     }
 }
示例#3
0
 /// <param name="state">The map editor state to create the editors in.</param>
 /// <param name="currentY">The current Y position the editor is placing elements in.</param>
 /// <returns>Tile attribute editors for this tile.</returns>
 public virtual TileAttributeEditor[] AttributeEditors(MapEditorState state, ref int currentY)
 {
     if (_attribEditorsFunc != null)
     {
         return(_attribEditorsFunc(state, ref currentY));
     }
     return(null);
 }
示例#4
0
        // The user clicked in the map window
        private void pan_MapWindow_MClick(object sender, MouseEventArgs e)
        {
            // Make sure we have a map open
            if (!MapCreated)
            {
                return;
            }

            // If we're editing terrain add the current tile to the tile clicked on
            if (CurrentState == MapEditorState.Terrain)
            {
                Size Offset = new Size(pan_MapWindow.AutoScrollPosition);

                // loop through all the tiles and find which one was clicked
                for (int i = 0; i < mapsize; i++)
                {
                    for (int j = 0; j < mapsize; j++)
                    {
                        if (MapArray[i, j].TileClicked(e.X - Offset.Width, e.Y - Offset.Height))
                        {
                            MapArray[i, j].TileImage = TileSet[SelectedTileIndex].TileImage;
                            MapArray[i, j].Name      = TileSet[SelectedTileIndex].Name;
                            AddTileToMap(i, j);
                            pan_MapWindow.Invalidate();
                            return;
                        }
                    }
                }
            }

            // If we adding the player spawn
            if (CurrentState == MapEditorState.PlayerSpawn)
            {
                Size Offset = new Size(pan_MapWindow.AutoScrollPosition);

                // loop through all the tiles and find which one was clicked
                for (int i = 0; i < mapsize; i++)
                {
                    for (int j = 0; j < mapsize; j++)
                    {
                        if (MapArray[i, j].TileClicked(e.X - Offset.Width, e.Y - Offset.Height))
                        {
                            // Now that we found the clicked tile, add the player spawn
                            int playertileindex = TileSet.FindIndex(TileNamedPlayer);
                            MapArray[i, j].TileImage = TileSet[playertileindex].TileImage;
                            AddTileToMap(i, j);
                            pan_MapWindow.Invalidate();
                            PlayeySpawn.X        = i;
                            PlayeySpawn.Y        = j;
                            b_PlayerSpawn.Text   = "Set Player Spawn Tile";
                            CurrentState         = MapEditorState.Terrain;
                            lab_PlayerSpawn.Text = "Player Spawn: (" + PlayeySpawn.X + ", " + PlayeySpawn.Y + ")";
                            return;
                        }
                    }
                }
            }
        }
示例#5
0
        public BoolAttributeEditor(string name, MapEditorState state, bool defaultIsTrue, ref int currentY) : base(name, state, ref currentY)
        {
            DefaultIsTrue = defaultIsTrue;

            if (DefaultIsTrue)
            {
                ChoiceField.Choice = 1;
            }
        }
示例#6
0
    ////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////
    // State-dependent functions

    void SetState(MapEditorState newState)
    {
        if (this.state == MapEditorState.Normal)
        {
            this.mapDisplay.DisableHoveredTile();
        }
        else if (this.state == MapEditorState.SelectionPaint || this.state == MapEditorState.SelectionErase)
        {
            var he = (SelectionChangeHistoryEvent)this.inProgressHistoryEvent;
            he.newSelectedTiles = new List <Vector2i>(this.selectedTiles.Select(x => x.pos));
            if (he.oldSelectedTiles.SequenceEqual(he.newSelectedTiles) == false)
            {
                this.AddNewHistoryEvent(he);
            }

            this.inProgressHistoryEvent = null;
        }

        this.state = newState;

        if (newState == MapEditorState.SelectionPaint)
        {
            var he = new SelectionChangeHistoryEvent();
            he.oldSelectedTiles         = new List <Vector2i>(this.selectedTiles.Select(x => x.pos));
            this.inProgressHistoryEvent = he;

            if (
                this.lastEnteredTile != null &&
                this.selectedTiles.Contains(this.lastEnteredTile) == false
                )
            {
                this.selectedTiles.Add(this.lastEnteredTile);
                this.mapDisplay.SetSelectedTiles(this.selectedTiles);
            }
        }
        else if (newState == MapEditorState.SelectionErase)
        {
            var he = new SelectionChangeHistoryEvent();
            he.oldSelectedTiles         = new List <Vector2i>(this.selectedTiles.Select(x => x.pos));
            this.inProgressHistoryEvent = he;

            if (
                this.lastEnteredTile != null &&
                this.selectedTiles.Contains(this.lastEnteredTile) == true
                )
            {
                this.selectedTiles.Remove(this.lastEnteredTile);
                this.mapDisplay.SetSelectedTiles(this.selectedTiles);
            }
        }

        this.UpdateUI();
    }
示例#7
0
        public TextAttributeEditor(string name, MapEditorState state, int maxLines, bool monospace, ref int currentY) : base(name, state, ref currentY)
        {
            State.TextFields.Add("editor-" + GetType().Name + "-" + Name, TextField = new TextField()
            {
                Label    = name + ": ",
                Text     = "",
                Position = new TweenedVector2(state.Game, new Vector2(state.Game.GraphicsDevice.Viewport.Bounds.Width / 2 - 400 / 2, currentY)),
                Font     = monospace ? state.Game.DefaultFonts.MonoBold : state.Game.DefaultFonts.Bold,
                Width    = 400,
                Lines    = maxLines
            });

            currentY += TextField.Rectangle.Height + 4;
        }
示例#8
0
        public IntAttributeEditor(string name, MapEditorState state, int minValue, int maxValue, ref int currentY) : base(name, state, ref currentY)
        {
            State.ChoiceFields.Add("editor-" + GetType().Name + "-" + Name, ChoiceField = new ChoiceField()
            {
                Game  = state.Game,
                Label = name + ": ",
                // https://stackoverflow.com/questions/4138454/elegant-way-to-transform-arrays-in-c
                Choices  = null,
                Choice   = minValue,
                MinValue = minValue,
                MaxValue = maxValue,
                Position = new TweenedVector2(state.Game, new Vector2(state.Game.GraphicsDevice.Viewport.Bounds.Width / 2 - 400 / 2, currentY)),
                Font     = state.Game.DefaultFonts.Bold,
                Width    = 400
            });

            currentY += ChoiceField.Rectangle.Height + 4;
        }
示例#9
0
        public EnumAttributeEditor(string name, MapEditorState state, ref int currentY) : base(name, state, ref currentY)
        {
            Values = Enum.GetValues(typeof(T)).Cast <T>().ToList();

            State.ChoiceFields.Add("editor-" + GetType().Name + "-" + Name, ChoiceField = new ChoiceField()
            {
                Game  = state.Game,
                Label = name + ": ",
                // https://stackoverflow.com/questions/4138454/elegant-way-to-transform-arrays-in-c
                Choices  = Values.Select(e => e.ToString()).ToArray(),
                Choice   = 0,
                Position = new TweenedVector2(state.Game, new Vector2(state.Game.GraphicsDevice.Viewport.Bounds.Width / 2 - 400 / 2, currentY)),
                Font     = state.Game.DefaultFonts.Bold,
                Width    = 400
            });

            currentY += ChoiceField.Rectangle.Height + 4;
        }
示例#10
0
    public void PlaceNode(Node node)
    {
        // Updates the node's position to the visual's position.
        node.PositionX = current.transform.position.x;
        node.PositionY = current.transform.position.y;

        // Tests if it is a new node or not.
        if (interactiveMap.Count < 1 ||
            node.Id > interactiveMap.Get(interactiveMap.Count - 1).Id)
        {
            interactiveMap.MapNodes.Add(node);
        }

        // Resets the state.
        NodeEditor.StartEdit(current, node);
        state   = MapEditorState.Idle;
        current = null;
        Editor.StartEditingNode();
    }
示例#11
0
    void Start()
    {
        // this.game = GameObject.Find("Game").GetComponent<Game>();

        this.state                = MapEditorState.Normal;
        this.map                  = this.defaultMap;
        this.selectedTiles        = new List <MapTile>();
        this.historyEvents        = new LinkedList <BaseHistoryEvent>();
        this.lastHistoryEventNode = null;

        this.mapDisplay.Init(this, this.map.size);

        this.RebuildMapDisplay();

        // UI stuff

        this.uiRefs.selectedEntityDropdown.ClearOptions();
        foreach (MapEditorEntityType e in Enum.GetValues(typeof(MapEditorEntityType)))
        {
            string text = e.ToString();
            if (e == MapEditorEntityType.Invalid)
            {
                text = " ";
            }
            this.uiRefs.selectedEntityDropdown.options.Add(new Dropdown.OptionData(text));
        }

        this.UpdateUI();

        Utility.AddInputFieldChangedListener(this.uiRefs.mapNameTextbox, this.InputFieldChanged);
        Utility.AddInputFieldChangedListener(this.uiRefs.sizeXTextbox, this.InputFieldChanged);
        Utility.AddInputFieldChangedListener(this.uiRefs.sizeYTextbox, this.InputFieldChanged);
        Utility.AddInputFieldChangedListener(this.uiRefs.selectedTilesTextbox, this.InputFieldChanged);

        Utility.AddButtonClickListener(this.uiRefs.saveButton, this.ButtonPressed);
        Utility.AddButtonClickListener(this.uiRefs.loadButton, this.ButtonPressed);
        Utility.AddButtonClickListener(this.uiRefs.undoButton, this.ButtonPressed);
        Utility.AddButtonClickListener(this.uiRefs.redoButton, this.ButtonPressed);
        Utility.AddButtonClickListener(this.uiRefs.selectNoneButton, this.ButtonPressed);

        Utility.AddDropdownChangedListener(this.uiRefs.selectedEntityDropdown, this.DropdownChanged);
    }
示例#12
0
 protected TileAttributeEditor(string name, MapEditorState state, ref int currentY)
 {
     Name  = name;
     State = state;
 }
        public void S_1_017_ApplyWorkflowTest()
        {
            //TODO delete this after issue IR-077818 "Some columns aren't displayed multilingual label in InBasket" will be fixed
            if (localeLabel.Equals("ja") || localeLabel.Equals("fr"))
            {
                planningActivityLabel = "S_017_Planning";
            }

            //b, f
            Actor.AttemptsTo(
                Open.NavigationPanel,
                Pin.NavigationPanel,
                Open.SearchPanel.OfTocItemWithPath("S1017 Chair").ByLoupeIcon,
                Clear.SearchCriteria.InMainGrid,
                Search.WithCurrentSearchCriteria.InMainGrid);

            //g, h
            var rowNumber = Actor.AsksFor(
                MainGridState.Unfrozen.IndexOfRowByValueInColumn(DateTime.Today.ToShortInnovatorDateString(Settings.CultureInfo),
                                                                 dateCreatedLabel + " [...]"));

            var dialogContainer = Actor.AsksFor(SearchPanelContent.DialogsContainer);

            Actor.AttemptsTo(
                Open.Dialog.Properties.FromMainGrid.ByContextMenuOnRow(rowNumber),
                Click.On(PropertiesDialogElements.CopyIdButton(dialogContainer)),
                Close.Dialog(dialogContainer).ByCloseButton);

            //i
            //Now this test is failed here because of I-002119 "Translations of the same resources are different in dif. places"
            Actor.AttemptsTo(
                Open.SearchPanel.OfTocItemWithPath(inBasketTocPath).ByLoupeIcon);

            //j-n
            Actor.AttemptsTo(Open.Dialog.WfActivityCompletion.FromMainGrid.ForActivityWithLabel(planningActivityLabel).
                             ByContextMenu);

            var dialogTitle =
                Actor.AsksFor(
                    LocaleState.LabelOf.DialogTitle(LocaleKeys.Innovator.Dialog.WfActivityCompletion.Title));

            Actor.ChecksThat(WfActivityCompletionDialogState.Title(dialogContainer),
                             Is.EqualTo(dialogTitle));

            Actor.AttemptsTo(Set.VotingTo(confirmPathLabel).InActivityCompletionDialog(dialogContainer),
                             Set.Comment(votingComment).InActivityCompletionDialog(dialogContainer),
                             Click.On(WfActivityCompletionDialogElements.CompleteButton(dialogContainer)));

            expectedReport.ActivityItems.ElementAt(0).WhenVoted = DateTime.Now;

            Actor.ChecksThat(MainGridState.VisibleRowsCount, Is.EqualTo(0));

            //o, p, q, r
            Actor.AttemptsTo(
                LogOut.FromInnovator,
                LogIn.ToInnovator.As(Actor2.ActorInfo),
                Open.NavigationPanel,
                Pin.NavigationPanel,
                Open.SearchPanel.OfTocItemWithPath(inBasketTocPath).ByLoupeIcon);

            //s
            var columnActivityLabel = Actor.AsksFor(LocaleState.LabelOf.GridColumn(sourceItemTypeName, "name"));

            var columnAssignedToLabel =
                string.Concat(Actor.AsksFor(LocaleState.LabelOf.GridColumn(sourceItemTypeName, "assigned_to")),
                              " [...]");

            var searchForConfirming = new Dictionary <string, string>
            {
                [columnActivityLabel]   = confirmingActivityName,
                [columnAssignedToLabel] = Actor2.ActorInfo.LoginName
            };

            Actor.AttemptsTo(
                Clear.SearchCriteria.InMainGrid,
                Search.Simple.InMainGrid.With(searchForConfirming));

            //t
            var columnSourceItemLabel = Actor.AsksFor(LocaleState.LabelOf.GridColumn(sourceItemTypeName, "container"));
            var columnNumber          = Actor.AsksFor(MainGridState.Unfrozen.IndexOfColumn(columnSourceItemLabel));

            Actor.AttemptsTo(Open.Dialog.WfProcess.FromMainGrid.ByLinkInCell(1, columnNumber));

            dialogContainer = Actor.AsksFor(SearchPanelContent.DialogsContainer);
            var mapEditor = WfProcessDialogElements.MapEditor(dialogContainer);

            Actor.ChecksThat(MapEditorState.YellowHighlightedElement(mapEditor),
                             wfActivity => Assert.AreEqual(wfActivity.Label, confirmingActivityName));

            //u
            Actor.AttemptsTo(
                Click.On(WfProcessDialogElements.ViewSignOffsButton(dialogContainer)),
                Close.Dialog(dialogContainer).ByCloseButton);

            var currentPageContainer = Actor.AsksFor(PagesContent.CurrentPageContainer);

            Actor.ChecksThat(WfHistoryPanelState.WorkflowHistoryReport(currentPageContainer),
                             report => Assert.AreEqual(expectedReport, report));

            //v
            Actor.AttemptsTo(Close.Tab.Current);

            //w, x, y
            Actor.AttemptsTo(
                Clear.SearchCriteria.InMainGrid,
                Search.WithCurrentSearchCriteria.InMainGrid,
                Complete.Activity.WithLabel(confirmingActivityName).VotingTo(finishVote).ByContextMenu);

            Actor.ChecksThat(
                MainGridState.Unfrozen.HasItemWithValueInColumn(Actor2.ActorInfo.LoginName, columnAssignedToLabel),
                Is.False);

            //z
            Actor.AttemptsTo(Close.Tab.Current);
        }
示例#14
0
 public void StopPlacingNode()
 {
     Destroy(current.gameObject);
     state = MapEditorState.Idle;
 }
示例#15
0
 public void StartMovingNode(VisualNode node)
 {
     node.IsPlaced = false;
     current       = node;
     state         = MapEditorState.MovingNode;
 }