protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            switch (e.Button)
            {
            case MouseButtons.Left:
                LevelSettings settings = _editor?.Level?.Settings;
                if (settings != null && settings.ImportedGeometries.All(geo => geo.LoadException != null))
                {
                    ImportedGeometry geoToUpdate = settings.ImportedGeometries.FirstOrDefault(geo => geo.LoadException != null);
                    if (geoToUpdate != null)
                    {
                        EditorActions.UpdateImportedGeometryFilePath(Parent, settings, geoToUpdate, true);
                    }
                    else
                    {
                        EditorActions.AddImportedGeometry(Parent);
                    }
                }
                else if (CurrentObject != null)
                {
                    DoDragDrop(CurrentObject, DragDropEffects.Copy);
                }
                break;
            }
        }
 private void SelectByFrame(IssoPoint2D pt1, bool over)
 {
     if (!SelectionStarted)
     {
         SelectionStarted     = true;
         SelectionRect.Left   = pt1.X;
         SelectionRect.Top    = pt1.Y;
         SelectionRect.Right  = SelectionRect.Left;
         SelectionRect.Bottom = SelectionRect.Top;
     }
     else
     {
         SelectionRect.Right  = pt1.X;
         SelectionRect.Bottom = pt1.Y;
     }
     if (over)
     {
         if (modelVM.SelectElementsByRect(SelectionRect) > 0)
         {
             OnComponentSelected?.Invoke(modelVM.FirstSelectedBeam, null);
         }
         SelectionStarted = false;
         EditorAction     = EditorActions.None;
         CancelAction();
         Invalidate();
     }
     ;
 }
        private void CreateNewLinear(IssoPoint2D pt1)
        {
            // НОВЫЙ ЛИНЕЙНЫЙ КОМПОНЕНТ
            // Компонент идёт в паре с двумя узлами.
            // Первый узел - в точке, указанной пользователем (pt1)
            // Если в этой точке уже есть другой узел, то берём его как начало элемента
            // Если тут нет узла - создаём его, и берём как стартовый
            // Если пользователь указал точку, лежащую на линейном компоненте - создаём в этом месте
            // узел, разделяя компонент на две части, и берём его как стартовый
            ComponentNode node = modelVM.GetNodeAtPoint(pt1);

            if (node == null)
            {
                IssoPoint2D    pt2;
                ComponentBasic b = modelVM.GetComponent(pt1, out pt2);
                if (b?.CompType == ComponentTypes.ctLinear)
                {
                    modelVM.SplitLinearAt((ComponentLinear)b, pt2);
                    node = modelVM.GetNodeAtPoint(pt2);
                }
                node = new ComponentNode(pt1);
            }
            pt1.X       += 0.1f;
            EditedComp   = new ComponentLinear(node, new ComponentNode(pt1), RModel);
            EditorAction = EditorActions.NewLinearLastPoint;
        }
Exemplo n.º 4
0
        private void RefreshRecentProjectsList()
        {
            openRecentToolStripMenuItem.DropDownItems.Clear();

            if (Properties.Settings.Default.RecentProjects != null && Properties.Settings.Default.RecentProjects.Count > 0)
            {
                foreach (var fileName in Properties.Settings.Default.RecentProjects)
                {
                    if (fileName == _editor.Level.Settings.LevelFilePath)   // Skip currently loaded level
                    {
                        continue;
                    }

                    var item = new ToolStripMenuItem()
                    {
                        Name = fileName, Text = fileName
                    };
                    item.Click += (s, e) => EditorActions.OpenLevel(this, ((ToolStripMenuItem)s).Text);
                    openRecentToolStripMenuItem.DropDownItems.Add(item);
                }
            }

            // Add "Clear recent files" option
            openRecentToolStripMenuItem.DropDownItems.Add(new ToolStripSeparator());
            var item2 = new ToolStripMenuItem()
            {
                Name = "clearRecentMenuItem", Text = "Clear recent file list"
            };

            item2.Click += (s, e) => { Properties.Settings.Default.RecentProjects.Clear(); RefreshRecentProjectsList(); Properties.Settings.Default.Save(); };
            openRecentToolStripMenuItem.DropDownItems.Add(item2);

            // Disable menu item, if list is empty
            openRecentToolStripMenuItem.Enabled = openRecentToolStripMenuItem.DropDownItems.Count > 2;
        }
Exemplo n.º 5
0
        private void cbLightQualityChanged(object sender, EventArgs e)
        {
            int          index      = cbLightQuality.SelectedIndex;
            LightQuality newQuality = (LightQuality)index;

            EditorActions.UpdateLightQuality(newQuality);
        }
Exemplo n.º 6
0
        void UpdateActions()
        {
            var settings = GetSettings();

            if (settings == null)
            {
                return;
            }
            var control = (HCItemProjectShortcutsForm)CreatedControlInsidePropertyItemControl;

            foreach (var item in control.contentBrowserAll.GetAllItems())
            {
                var action = item.Tag as EditorAction;
                if (action != null)
                {
                    var text = action.Name;

                    var actionItem = settings.GetActionItem(action.Name);
                    if (actionItem != null)
                    {
                        var keysString = EditorActions.ConvertShortcutKeysToString(actionItem.ToArray());
                        if (keysString != "")
                        {
                            text += " (" + keysString + ")";
                        }
                    }

                    ((ContentBrowserItem_Virtual)item).SetText(text);
                }
            }
        }
Exemplo n.º 7
0
        protected override void WndProc(ref Message message)
        {
            switch (message.Msg)
            {
            case SingleInstanceManagement.WM_COPYDATA:
                var fileName = SingleInstanceManagement.Catch(ref message);
                if (fileName != null && Path.GetExtension(fileName) == ".prj2")
                {
                    SingleInstanceManagement.RestoreWindowState(this);

                    if (_editor.Level.Settings.LevelFilePath != fileName)
                    {
                        // Try to open file only if main window is opened, otherwise try to close everything.
                        for (int i = Application.OpenForms.Count - 1; i >= 0; i--)
                        {
                            if (Application.OpenForms[i].Name != Name && !(Application.OpenForms[i] is PopUpInfo))
                            {
                                Application.OpenForms[i].Close();
                            }
                        }

                        EditorActions.OpenLevel(this, fileName);
                    }
                }
                break;

            case SingleInstanceManagement.WM_SHOWWINDOW:
                SingleInstanceManagement.RestoreWindowState(this);
                break;

            default:
                base.WndProc(ref message);
                break;
            }
        }
Exemplo n.º 8
0
        public AddRemoveGhostBlockUndoInstance(EditorUndoManager parent, GhostBlockInstance obj, bool created) : base(parent, obj.Room)
        {
            Created    = created;
            UndoObject = obj;

            Valid = () => UndoObject != null && ((Created && UndoObject.Room != null) ||
                                                 (!Created && Room.ExistsInLevel)) && !Room.CoordinateInvalid(UndoObject.SectorPosition);

            UndoAction = () =>
            {
                if (Created)
                {
                    EditorActions.DeleteObjectWithoutUpdate(UndoObject);
                }
                else
                {
                    var backupPos = obj.SectorPosition; // Preserve original position and reassign it after placement
                    EditorActions.PlaceGhostBlockWithoutUpdate(Room, obj.SectorPosition, UndoObject);
                }
            };

            RedoInstance = () =>
            {
                var result = new AddRemoveGhostBlockUndoInstance(Parent, UndoObject, !Created);
                result.Room = Room; // Relink parent room
                return(result);
            };
        }
Exemplo n.º 9
0
        private bool UpdateRoomPosition(Vector2 newRoomPos, Room roomReference, bool moveRooms)
        {
            VectorInt2 newRoomPosInt = VectorInt2.FromRounded(newRoomPos);
            VectorInt2 roomMovement  = newRoomPosInt - roomReference.SectorPos;

            if (roomMovement != new VectorInt2())
            {
                if (EditorActions.CheckForLockedRooms(this, _roomsToMove))
                {
                    _roomMouseClicked = null;
                }
                else
                {
                    var delta = new VectorInt3(roomMovement.X, 0, roomMovement.Y);

                    if (roomMovement.X != 0 || roomMovement.Y != 0)
                    {
                        _overallDelta += delta;
                        if (moveRooms)
                        {
                            EditorActions.MoveRooms(delta, _roomsToMove, true);
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Exemplo n.º 10
0
 private void butEditTrigger_Click(object sender, EventArgs e)
 {
     if (_editor.SelectedRoom == null || !(_editor.SelectedObject is TriggerInstance))
     {
         return;
     }
     EditorActions.EditObject(_editor.SelectedObject, this);
 }
Exemplo n.º 11
0
 public KeyboardHandler(EditorContext editorContext)
 {
     this.actions        = editorContext.Actions;
     this.editorState    = editorContext.EditorState;
     this.xmlRules       = editorContext.XmlRules;
     this.nativePlatform = editorContext.NativePlatform;
     this.nativePlatform.InputEvents.PreviewKey.Add(this.ControlKeyPreview);
 }
Exemplo n.º 12
0
 protected override void GizmoMove(Vector3 newPos)
 {
     if (_editor.SelectedObject is PositionBasedObjectInstance)
     {
         EditorActions.MoveObject(_editor.SelectedObject as PositionBasedObjectInstance,
                                  newPos - _editor.SelectedObject.Room.WorldPos, Control.ModifierKeys);
     }
 }
Exemplo n.º 13
0
        void RenderProjectLoadPanel()
        {
            ImGui.BulletText("New projects must be placed in an empty directory.");

            ImGui.Text("Project Title:");
            ImGui.SameLine();
            ImGui.InputText("##label", ref projectTitle);

            if (ImGui.Button("Create New"))
            {
                string path = EditorActions.OpenFolderPathDialog();
                if (path != null)
                {
                    if (!ProjectManager.CreateProject(path, projectTitle))
                    {
                        Console.WriteLine("ProjectManager error: " + ProjectManager.ErrorString);
                    }

                    projectTitle = defaultTitle;
                }
            }

            ImGui.Separator();
            if (ImGui.Button("Load Existing"))
            {
                string path = EditorActions.OpenFilePathDialog("Perhaps Project Files (*.phproject)|*.phproject");
                if (path != null)
                {
                    if (!ProjectManager.OpenProject(path))
                    {
                        Console.WriteLine("ProjectManager error: " + ProjectManager.ErrorString);
                    }

                    projectTitle = defaultTitle;
                }
            }

            ImGui.Separator();
            ImGui.BulletText("Recent Projects:");

            FileObject <PerhapsProject>[] projects = ProjectManager.GetRecentProjects();
            ImGui.Separator();
            for (int i = 0; i < projects.Length; i++)
            {
                FileObject <PerhapsProject> projectFile = projects[i];
                PerhapsProject project = projectFile.Object;

                ImGui.PushItemWidth(-1);
                if (ImGui.Button($"{project.ProjectTitle}\n{projectFile.FilePath}\nTime Created: {project.timeCreated.ToString()}"))
                {
                    ProjectManager.OpenProject(projectFile.FilePath);
                    break;
                }
                ImGui.PopItemWidth();

                ImGui.Separator();
            }
        }
Exemplo n.º 14
0
        private void butBrowseTexture_Click(object sender, EventArgs e)
        {
            LevelTexture texture = comboCurrentTexture.SelectedItem as LevelTexture;

            if (texture != null)
            {
                EditorActions.UpdateTextureFilepath(this, texture);
            }
        }
Exemplo n.º 15
0
    void EditLevelToggleGroup()
    {
        editingTiles = EditorGUILayout.BeginToggleGroup(new GUIContent("Edit the level", "The Toggle for the basic generation of the grid"), editingTiles);
        if (editingTiles)
        {
            SetColor(EditorActions.Nothing);
            if (GUILayout.Button("Stop Editing"))
            {
                currentAction = EditorActions.Nothing;
                ghostGridActive = false;
            }
            GUILayout.Space(10);


            SetColor(EditorActions.Add);
            if (GUILayout.Button("Create new tiles"))
            {
                currentAction = EditorActions.Add;
                ghostGridActive = true;
            }
            SetColor(EditorActions.Remove);
            if (GUILayout.Button("Remove existing tile"))
            {
                currentAction = EditorActions.Remove;
                ghostGridActive = false;
            }
            GUILayout.Space(10);
            SetColor(EditorActions.Change);
            if (GUILayout.Button("Change tiles"))
            {
                currentAction = EditorActions.Change;
                ghostGridActive = false;
            }

            if (currentAction == EditorActions.Change)
            {
                ChangeToggleGroup();
            }

            GUILayout.Space(10);
            SetColor(EditorActions.BlockAdd);
            if (GUILayout.Button("Add a pushable Block"))
            {
                currentAction = EditorActions.BlockAdd;
                ghostGridActive = false;
            }
            SetColor(EditorActions.BlockRemove);
            if (GUILayout.Button("Remove pushable Block"))
            {
                currentAction = EditorActions.BlockRemove;
                ghostGridActive = false;
            }
            GUI.color = Color.white;

        }
        EditorGUILayout.EndToggleGroup();
    }
Exemplo n.º 16
0
        private void butEditObject_Click(object sender, EventArgs e)
        {
            var instance = lstObjects.SelectedItem.Tag as ObjectInstance;

            if (instance != null)
            {
                EditorActions.EditObject(instance, this);
            }
        }
Exemplo n.º 17
0
        private void butDeleteTexture_Click(object sender, EventArgs e)
        {
            LevelTexture texture = comboCurrentTexture.SelectedItem as LevelTexture;

            if (texture != null)
            {
                EditorActions.RemoveTexture(this, texture);
            }
        }
        private void CheckVisualStates(EditorActions obj)
        {
            switch (obj)
            {
            case EditorActions.NewLinearFirstPoint: VisualStateManager.GoToState(ButtonLinear, "Pressed"); break;

            case EditorActions.NewLinearLastPoint: VisualStateManager.GoToState(ButtonLinear, "Pressed"); break;
            }
        }
Exemplo n.º 19
0
        public static EditorAction.GetStateContext EditorActionGetState(EditorAction.HolderEnum holder, string actionName)
        {
            var action = EditorActions.GetByName(actionName);

            if (action == null)
            {
                return(null);
            }
            return(EditorActionGetState(holder, action));
        }
Exemplo n.º 20
0
        public static void EditorActionClick(EditorAction.HolderEnum holder, string actionName)
        {
            var action = EditorActions.GetByName(actionName);

            if (action == null)
            {
                return;
            }
            EditorActionClick(holder, action);
        }
Exemplo n.º 21
0
        public static void AddTransformToolToMenu(ICollection <KryptonContextMenuItemBase> items, TransformTool transformTool)
        //public static void AddTransformToolToMenu( ICollection<KryptonContextMenuItemBase> items, string workareaModeName )// TransformTool transformTool )
        {
            KryptonContextMenuItem item;
            string text;

            //Move
            text = Translate("Move");
            item = new KryptonContextMenuItem(text, null, delegate(object sender, EventArgs e)
            {
                EditorAPI.EditorActionClick(EditorAction.HolderEnum.ContextMenu, "Move");
            });
            item.Checked = transformTool.Mode == TransformTool.ModeEnum.Position;
            //item.Checked = workareaModeName == "Transform Move";
            item.Image = EditorResourcesCache.Move;
            item.ShortcutKeyDisplayString = EditorActions.GetFirstShortcutKeyString("Move");
            items.Add(item);

            //Rotate
            text = Translate("Rotate");
            item = new KryptonContextMenuItem(text, null, delegate(object sender, EventArgs e)
            {
                EditorAPI.EditorActionClick(EditorAction.HolderEnum.ContextMenu, "Rotate");
            });
            item.Checked = transformTool.Mode == TransformTool.ModeEnum.Rotation;
            //item.Checked = workareaModeName == "Transform Rotate";
            item.Image = EditorResourcesCache.Rotate;
            item.ShortcutKeyDisplayString = EditorActions.GetFirstShortcutKeyString("Rotate");
            items.Add(item);

            //Scale
            text = Translate("Scale");
            item = new KryptonContextMenuItem(text, null, delegate(object sender, EventArgs e)
            {
                EditorAPI.EditorActionClick(EditorAction.HolderEnum.ContextMenu, "Scale");
            });
            item.Checked = transformTool.Mode == TransformTool.ModeEnum.Scale;
            //item.Checked = workareaModeName == "Transform Scale";
            item.Image = EditorResourcesCache.Scale;
            item.ShortcutKeyDisplayString = EditorActions.GetFirstShortcutKeyString("Scale");
            items.Add(item);

            //Select
            text = Translate("Select");
            item = new KryptonContextMenuItem(text, null, delegate(object sender, EventArgs e)
            {
                EditorAPI.EditorActionClick(EditorAction.HolderEnum.ContextMenu, "Select");
            });
            item.Checked = transformTool.Mode == TransformTool.ModeEnum.None;
            //item.Checked = workareaModeName == "Transform Select";
            item.Image = EditorResourcesCache.Select;
            item.ShortcutKeyDisplayString = EditorActions.GetFirstShortcutKeyString("Select");
            items.Add(item);
        }
Exemplo n.º 22
0
 void SetColor(EditorActions check)
 {
     if (currentAction == check)
     {
         GUI.color = Color.green;
     }
     else
     {
         GUI.color = Color.white;
     }
 }
Exemplo n.º 23
0
 private void panel2DMap_DragEnter(object sender, DragEventArgs e)
 {
     if (EditorActions.DragDropFileSupported(e, true))
     {
         e.Effect = DragDropEffects.Copy;
     }
     else
     {
         e.Effect = DragDropEffects.None;
     }
 }
Exemplo n.º 24
0
        private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0 || e.RowIndex >= _dataGridViewDataSource.Count)
            {
                return;
            }

            if (dataGridView.Columns[e.ColumnIndex].Name == searchButtonColumn.Name)
            {
                EditorActions.UpdateImportedGeometryFilePath(this, LevelSettings, _dataGridViewDataSource[e.RowIndex].Object);
            }
        }
            public bool AddAction(string actionName)
            {
                var action = EditorActions.GetByName(actionName);

                if (action == null)
                {
                    //Log.Fatal( "EditorRibbonDefaultConfiguration: Group: AddAction: No action with name \"{0}\".", actionName );
                    return(false);
                }
                Children.Add(action);
                return(true);
            }
Exemplo n.º 26
0
 protected override void GizmoScaleX(float scale)
 {
     if (_editor.SelectedObject is IScaleable)
     {
         EditorActions.ScaleObject(_editor.SelectedObject as IScaleable, scale, ScaleQuantization());
     }
     else if (_editor.SelectedObject is ISizeable)
     {
         var obj = _editor.SelectedObject as ISizeable;
         EditorActions.ResizeObject(obj, new Vector3(scale, obj.Size.Y, obj.Size.Z), SizeQuantization());
     }
 }
Exemplo n.º 27
0
        public MoveRoomsUndoInstance(EditorUndoManager parent, List <Room> rooms, VectorInt3 delta) : base(parent, null)
        {
            Delta = -delta;
            Rooms = rooms;
            Rooms.ForEach(room => Sizes.Add(room, room.SectorSize));

            Valid = () => Rooms != null && Rooms.All(room => room != null && room.ExistsInLevel && !room.Locked) &&
                    Rooms.All(room => !Parent.Editor.Level.GetConnectedRooms(room).Except(Rooms).Any()) &&
                    Rooms.All(room => Sizes.ContainsKey(room) && room.SectorSize == Sizes[room]);
            UndoAction   = () => EditorActions.MoveRooms(Delta, Rooms, true);
            RedoInstance = () => new MoveRoomsUndoInstance(Parent, Rooms, Delta);
        }
Exemplo n.º 28
0
        public static bool ProcessShortcuts(Keys keyCode)          //!!!!из старого, bool processCharactersWithoutModifiers )
        {
            Keys keys = keyCode | Control.ModifierKeys;

            var shortcuts = new Dictionary <Keys, Component_ProjectSettings.ShortcutSettingsClass.ActionItem>(64);

            foreach (var a in ProjectSettings.Get.ShortcutSettings.Actions)
            {
                if (a.Shortcut1 != Keys.None)
                {
                    shortcuts[a.Shortcut1] = a;
                }
                if (a.Shortcut2 != Keys.None)
                {
                    shortcuts[a.Shortcut2] = a;
                }
            }

            shortcuts.TryGetValue(keys, out var actionItem);

            if (actionItem != null)
            {
                var action = EditorActions.GetByName(actionItem.Name);
                if (action != null)
                {
                    foreach (var shortcut in actionItem.ToArray())
                    {
                        if (shortcut != Keys.None && shortcut == keys)
                        {
                            var c = EditorActionGetState(EditorAction.HolderEnum.ShortcutKey, action);
                            if (c.Enabled)
                            {
                                EditorActionClick(EditorAction.HolderEnum.ShortcutKey, action.Name);
                                return(true);
                            }
                        }
                    }
                }
            }

            //if( action.ShortcutKeys != null && Array.IndexOf( action.ShortcutKeys, keys ) != -1 )
            //{
            //	var c = EditorActionGetState( EditorAction.HolderEnum.ShortcutKey, action );
            //	if( c.Enabled )
            //	{
            //		EditorActionClick( EditorAction.HolderEnum.ShortcutKey, action.Name );
            //		return true;
            //	}
            //}
            //}

            return(false);
        }
Exemplo n.º 29
0
        protected override void OnDragEnter(DragEventArgs e)
        {
            base.OnDragEnter(e);

            if (EditorActions.DragDropFileSupported(e))
            {
                e.Effect = DragDropEffects.Move;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }
Exemplo n.º 30
0
        private void comboRoom_SelectedIndexChanged(object sender, EventArgs e)
        {
            Room selectedRoom = _editor.Level.Rooms[comboRoom.SelectedIndex];

            if (selectedRoom == null)
            {
                EditorActions.MakeNewRoom(comboRoom.SelectedIndex);
            }
            else
            {
                _editor.SelectRoom(selectedRoom);
            }
        }