public IEnumerable <IEditorAction> GetAdditionalEditorActions(string word)
        {
            // We have two additional editor actions.
            var addSensitiveAction = new EditorAction(
                "Add case-sensitive local words",
                new HierarchicalPath("/Plugins/Local Words/Add to Sensitive"),
                context => AddToSensitiveList(context, word));
            var addInsensitiveAction =
                new EditorAction(
                    "Add case-insensitive local words",
                    new HierarchicalPath("/Plugins/Local Words/Add to Insensitive"),
                    context => AddToInsensitiveList(context, word));

            // Return the resutling list.
            var results = new IEditorAction[]
            {
                addSensitiveAction, addInsensitiveAction
            };

            return(results);
        }
Exemple #2
0
        /// <summary>
        /// Determine which action would be taken if, subsequently, the left-mouse button will be clicked
        /// </summary>
        /// <param name="wantDragAction">Do we want a drag-action?</param>
        /// <param name="wantClickAction">Do we want a click-action?</param>
        /// <param name="mouseX">The current location of the mouse in x-direction</param>
        /// <param name="mouseY">The current location of the mouse in y-direction</param>
        public void DeterminePossibleActions(bool wantDragAction, bool wantClickAction, int mouseX, int mouseY)
        {
            CurrentActionDescription = "";
            activeMouseDragAction    = null;
            activeMouseClickAction   = null;
            if (wantDragAction)
            {
                foreach (EditorActionMouseDrag mouseDragAction in editorDragActionsMouseClicked)
                {
                    if (mouseDragAction.MenuState(CurrentTrainPath, activeNode, activeTrackLocation, UpdateAfterEdits,
                                                  mouseX, mouseY))
                    {
                        CurrentActionDescription = mouseDragAction.ToString();
                        activeMouseDragAction    = mouseDragAction;
                        return;
                    }
                }
            }
            else if (wantClickAction)
            {
                foreach (EditorAction action in editorActionsMouseClicked)
                {
                    bool actionCanBeExecuted = action.MenuState(CurrentTrainPath, activeNode, activeTrackLocation, UpdateAfterEdits,
                                                                mouseX, mouseY);
                    if (actionCanBeExecuted)
                    {
                        CurrentActionDescription = action.ToString();
                        activeMouseClickAction   = action;
                        return;
                    }
                }
            }

            //direct key actions
            activeAddEndAction = possibleAddEndAction.MenuState(CurrentTrainPath, activeNode, activeTrackLocation, UpdateAfterEdits, mouseX, mouseY) ?
                                 possibleAddEndAction : null;
            activeAddWaitAction = possibleAddWaitAction.MenuState(CurrentTrainPath, activeNode, activeTrackLocation, UpdateAfterEdits, mouseX, mouseY) ?
                                  possibleAddWaitAction : null;
        }
        public TournamentEditorViewModel(EditorAction action, TournamentModel tournament)
        {
            Action = action;
            Tournament = tournament;

            TournamentTypes = new List<SelectListItem>();
            TournamentTypes.Add(new SelectListItem
            {
                Selected = tournament != null && tournament.TournamentType == TournamentType.League,
                Text = "Liga",
                Value = TournamentType.League.ToString()
            });

            TournamentTypes.Add(new SelectListItem
            {
                Selected = tournament != null && tournament.TournamentType == TournamentType.SingleElimination,
                Text = "Eliminación Simple",
                Value = TournamentType.SingleElimination.ToString()
            });

            TournamentTypes.Add(new SelectListItem
            {
                Selected = tournament != null && tournament.TournamentType == TournamentType.DoubleElimination,
                Text = "Eliminación Doble",
                Value = TournamentType.DoubleElimination.ToString()
            });

            IList<PlayerModel> players = new List<PlayerModel>();

            if (tournament != null && tournament.Players != null)
                players = tournament.Players;

            PlayersJson = JsonConvert.SerializeObject(players);

            if (tournament != null)
            {
                TournamentTypeForDisplay = tournament.TournamentType == TournamentType.DoubleElimination ? "Eliminación" : "Liga";
            }
        }
Exemple #4
0
    public void SetRigidity(float rigidity)
    {
        if (Math.Abs(Rigidity - rigidity) < MathUtils.EPSILON)
        {
            return;
        }

        var cost = (int)(Math.Abs(rigidity - Rigidity) / 2 * 100);

        if (cost > 0)
        {
            if (cost > MutationPoints)
            {
                rigidity = Rigidity + (rigidity < Rigidity ? -MutationPoints : MutationPoints) * 2 / 100.0f;
                cost     = MutationPoints;
            }

            var newRigidity  = rigidity;
            var prevRigidity = Rigidity;

            var action = new EditorAction(this, cost,
                                          redo =>
            {
                Rigidity = newRigidity;
                gui.UpdateRigiditySlider(Rigidity, MutationPoints);
                gui.UpdateSpeed(CalculateSpeed());
            },
                                          undo =>
            {
                Rigidity = prevRigidity;
                gui.UpdateRigiditySlider(Rigidity, MutationPoints);
                gui.UpdateSpeed(CalculateSpeed());
            });

            EnqueueAction(action);
        }
    }
Exemple #5
0
    /// <summary>
    ///   Wipes clean the current cell.
    /// </summary>
    public void CreateNewMicrobe()
    {
        if (!FreeBuilding)
        {
            throw new InvalidOperationException("can't reset cell when not freebuilding");
        }

        var previousMP = MutationPoints;
        var oldEditedMicrobeOrganelles = new OrganelleLayout <OrganelleTemplate>();

        foreach (var organelle in editedMicrobeOrganelles)
        {
            oldEditedMicrobeOrganelles.Add(organelle);
        }

        var action = new EditorAction(this, 0,
                                      redo =>
        {
            MutationPoints = Constants.BASE_MUTATION_POINTS;
            editedMicrobeOrganelles.RemoveAll();
            editedMicrobeOrganelles.Add(new OrganelleTemplate(GetOrganelleDefinition("cytoplasm"),
                                                              new Hex(0, 0), 0));
        },
                                      undo =>
        {
            editedMicrobeOrganelles.RemoveAll();
            MutationPoints = previousMP;

            foreach (var organelle in oldEditedMicrobeOrganelles)
            {
                editedMicrobeOrganelles.Add(organelle);
            }
        });

        EnqueueAction(action);
    }
Exemple #6
0
        public static EditorAction ButtonPanel <T>(IList <T> list, int index, string up, string down, string duplicate, string remove, float buttonWidth, GUIStyle style)
        {
            if (index < 0 || index >= list.Count)
            {
                return(EditorAction.Null);
            }
            EditorAction action = EditorAction.Null;

            int buttonCount = new string[] { up, down, duplicate, remove }.Filter((s) => s != null).Count;

            buttonWidth -= buttonCount * 2 + 2;
            buttonWidth  = Mathf.Max(buttonCount * Layout.RawWidth(Constants.W.SmallButton), buttonWidth) / buttonCount;

            if (up != null && GUILayout.Button(up, Layout.Width(buttonWidth)))
            {
                list   = list.Move(index, -1);
                action = EditorAction.MoveUp;
            }
            if (down != null && GUILayout.Button(down, Layout.Width(buttonWidth)))
            {
                list   = list.Move(index, 1);
                action = EditorAction.MoveDown;
            }
            if (duplicate != null && GUILayout.Button(duplicate, Layout.Width(buttonWidth)))
            {
                list.Add(list[index]);
                action = EditorAction.Duplicate;
            }
            if (remove != null && GUILayout.Button(remove, Layout.Width(buttonWidth)))
            {
                list.RemoveAt(index);
                action = EditorAction.Remove;
            }

            return(action);
        }
Exemple #7
0
    private void RemoveOrganelleAt(Hex location)
    {
        var organelleHere = editedMicrobeOrganelles.GetOrganelleAt(location);

        if (organelleHere == null)
        {
            return;
        }

        // Dont allow deletion of nucleus or the last organelle
        // TODO: allow deleting the last cytoplasm if an organelle is about to be placed
        if (organelleHere.Definition.InternalName == "nucleus" || MicrobeSize < 2)
        {
            return;
        }

        int cost = Constants.ORGANELLE_REMOVE_COST;

        var action = new EditorAction(this, cost,
                                      DoOrganelleRemoveAction, UndoOrganelleRemoveAction,
                                      new RemoveActionData(organelleHere));

        EnqueueAction(action);
    }
Exemple #8
0
    private void UndoOrganelleRemoveAction(EditorAction action)
    {
        var data = (RemoveActionData)action.Data;

        editedMicrobeOrganelles.Add(data.Organelle);
    }
Exemple #9
0
 public RoutedActionPerformedEventArgs(EditorAction action, RoutedEvent ActionPerformedEvent) : base(ActionPerformedEvent)
 {
     Action = action;
 }
Exemple #10
0
		private void SetEnabled(EditorAction action, bool enabled)
		{
			ToolStripItem[] toolStripItemArray;
			if (!this.controls.TryGetValue(action, out toolStripItemArray))
				return;
			foreach (ToolStripItem toolStripItem in toolStripItemArray)
				toolStripItem.Enabled = enabled;
		}
Exemple #11
0
    public static void HandleAction(EditorAction action, bool redo)
    {
        if (redo)
        {
            switch (action.type)
            {
            case EditorAction.ActionType.EnvironmentChanged:
                // set map environment settings to new settings
                EnvironmentChanged ec = action as EnvironmentChanged;
                EditorMain.instance.LoadedMap.AmbientColor   = ec.newAmbientColor;
                EditorMain.instance.LoadedMap.BaseplateColor = ec.newBaseplateColor;
                EditorMain.instance.LoadedMap.SkyColor       = ec.newSkyColor;
                EditorMain.instance.LoadedMap.BaseplateSize  = ec.newBaseplateSize;
                EditorMain.instance.LoadedMap.SunIntensity   = ec.newSunIntensity;
                MapBuilder.instance.UpdateEnvironment(EditorMain.instance.LoadedMap);
                break;

            case EditorAction.ActionType.ElementsAdded:
                // add elements
                ElementsAdded ea = action as ElementsAdded;
                if (ea.bricksAdded != null)
                {
                    for (int i = 0; i < ea.bricksAdded.Length; i++)
                    {
                        EditorUI.instance.ImportBrick(ea.bricksAdded[i].ToBrick(false));
                    }
                }
                if (ea.groupsAdded != null)
                {
                    for (int i = 0; i < ea.groupsAdded.Length; i++)
                    {
                        EditorUI.instance.ImportGroup(ea.groupsAdded[i].ToGroup(false));
                    }
                }
                break;

            case EditorAction.ActionType.ElementsChanged:
                // set element settings to new settings
                ElementsChanged elc = action as ElementsChanged;
                for (int i = 0; i < elc.oldBricks.Length; i++)
                {
                    EditorMain.instance.SetBrickProperties(elc.newBricks[i], elc.oldBricks[i].ID);
                    EditorUI.instance.UpdateElement(elc.oldBricks[i].ID);
                }
                EditorUI.instance.UpdateInspector();
                break;

            case EditorAction.ActionType.ElementsRemoved:
                // remove elements
                ElementsRemoved er = action as ElementsRemoved;
                if (er.bricksRemoved != null)
                {
                    for (int i = 0; i < er.bricksRemoved.Length; i++)
                    {
                        EditorUI.instance.DeleteElement(er.bricksRemoved[i].ID);
                    }
                }
                if (er.groupsRemoved != null)
                {
                    for (int i = 0; i < er.groupsRemoved.Length; i++)
                    {
                        EditorUI.instance.DeleteElement(er.groupsRemoved[i].ID);
                    }
                }
                break;

            case EditorAction.ActionType.GenericMapChange:
                // load new saved map
                break;
            }
        }
        else
        {
            switch (action.type)
            {
            case EditorAction.ActionType.EnvironmentChanged:
                // revert map environment settings to old settings
                EnvironmentChanged ec = action as EnvironmentChanged;
                EditorMain.instance.LoadedMap.AmbientColor   = ec.oldAmbientColor;
                EditorMain.instance.LoadedMap.BaseplateColor = ec.oldBaseplateColor;
                EditorMain.instance.LoadedMap.SkyColor       = ec.oldSkyColor;
                EditorMain.instance.LoadedMap.BaseplateSize  = ec.oldBaseplateSize;
                EditorMain.instance.LoadedMap.SunIntensity   = ec.oldSunIntensity;
                MapBuilder.instance.UpdateEnvironment(EditorMain.instance.LoadedMap);
                break;

            case EditorAction.ActionType.ElementsAdded:
                // remove added elements
                ElementsAdded ea = action as ElementsAdded;
                if (ea.bricksAdded != null)
                {
                    for (int i = 0; i < ea.bricksAdded.Length; i++)
                    {
                        EditorUI.instance.DeleteElement(ea.bricksAdded[i].ID);
                    }
                }
                if (ea.groupsAdded != null)
                {
                    for (int i = 0; i < ea.groupsAdded.Length; i++)
                    {
                        EditorUI.instance.DeleteElement(ea.groupsAdded[i].ID);
                    }
                }
                break;

            case EditorAction.ActionType.ElementsChanged:
                // revert element settings to old settings
                ElementsChanged elc = action as ElementsChanged;
                for (int i = 0; i < elc.newBricks.Length; i++)
                {
                    EditorMain.instance.SetBrickProperties(elc.oldBricks[i], elc.newBricks[i].ID);
                    EditorUI.instance.UpdateElement(elc.newBricks[i].ID);
                }
                EditorUI.instance.UpdateInspector();
                break;

            case EditorAction.ActionType.ElementsRemoved:
                // add removed elements
                ElementsRemoved er = action as ElementsRemoved;
                if (er.bricksRemoved != null)
                {
                    for (int i = 0; i < er.bricksRemoved.Length; i++)
                    {
                        EditorUI.instance.ImportBrick(er.bricksRemoved[i].ToBrick(false));
                    }
                }
                if (er.groupsRemoved != null)
                {
                    for (int i = 0; i < er.groupsRemoved.Length; i++)
                    {
                        EditorUI.instance.ImportGroup(er.groupsRemoved[i].ToGroup(false));
                    }
                }
                break;

            case EditorAction.ActionType.GenericMapChange:
                // load old saved map
                GenericMapChange gmc = action as GenericMapChange;
                break;
            }
        }
    }
Exemple #12
0
 private void SetAction(EditorAction act)
 {
     EditorAction = act;
 }
Exemple #13
0
        private EditorAction action;                            // specifies the general action type


        public EditorEventArgs(EditorAction action)
        {
            this.action = action;
        }
        public override void Register()
        {
            //Upload to the Store
            {
                var a = new EditorAction();
                //!!!!
                a.Name = "Prepare for the Store";
                //a.Name = "Upload to the Store";
                a.Description        = "Uploads the selected product or all products in the selected folder to the NeoAxis Store.";
                a.CommonType         = EditorAction.CommonTypeEnum.General;
                a.ImageSmall         = Properties.Resources.Package_16;
                a.ImageBig           = Properties.Resources.Package_32;
                a.QatSupport         = true;
                a.ContextMenuSupport = EditorContextMenuWinForms.MenuTypeEnum.Resources;
                a.RibbonText         = ("Upload", "");

                a.GetState += delegate(EditorAction.GetStateContext context)
                {
                    if (context.ObjectsInFocus.DocumentWindow == null && context.ObjectsInFocus.Objects.Length != 0)
                    {
                        var fileItems = context.ObjectsInFocus.Objects.OfType <ContentBrowserItem_File>();
                        foreach (var fileItem in fileItems)
                        {
                            if (fileItem.IsDirectory)
                            {
                                bool skip = false;

                                if (context.Holder == EditorAction.HolderEnum.ContextMenu)
                                {
                                    var files = Directory.GetFiles(fileItem.FullPath, "*.store", SearchOption.AllDirectories);
                                    if (files.Length == 0)
                                    {
                                        skip = true;
                                    }
                                }

                                if (!skip)
                                {
                                    context.Enabled = true;
                                    break;
                                }
                            }

                            if (!fileItem.IsDirectory && Path.GetExtension(fileItem.FullPath).ToLower() == ".store")
                            {
                                context.Enabled = true;
                                break;
                            }
                        }
                    }
                };

                a.Click += delegate(EditorAction.ClickContext context)
                {
                    if (context.ObjectsInFocus.DocumentWindow == null && context.ObjectsInFocus.Objects.Length != 0)
                    {
                        var realFileNames = new ESet <string>();
                        {
                            var fileItems = context.ObjectsInFocus.Objects.OfType <ContentBrowserItem_File>();
                            foreach (var fileItem in fileItems)
                            {
                                if (fileItem.IsDirectory)
                                {
                                    realFileNames.AddRangeWithCheckAlreadyContained(Directory.GetFiles(fileItem.FullPath, "*.store", SearchOption.AllDirectories));
                                }

                                if (!fileItem.IsDirectory && Path.GetExtension(fileItem.FullPath).ToLower() == ".store")
                                {
                                    realFileNames.AddWithCheckAlreadyContained(fileItem.FullPath);
                                    break;
                                }
                            }
                        }

                        var virtualFileNames = new List <string>();
                        foreach (var realFileName in realFileNames)
                        {
                            var virtualFileName = VirtualPathUtility.GetVirtualPathByReal(realFileName);
                            if (VirtualFile.Exists(virtualFileName))
                            {
                                virtualFileNames.Add(virtualFileName);
                            }
                        }
                        if (virtualFileNames.Count == 0)
                        {
                            return;
                        }

                        var text = "Upload selected products to the store?\n\n";
                        foreach (var fileName in virtualFileNames)
                        {
                            text += fileName + "\n";
                        }
                        if (EditorMessageBox.ShowQuestion(text, EMessageBoxButtons.OKCancel) == EDialogResult.Cancel)
                        {
                            return;
                        }

                        //process
                        var item = ScreenNotifications.ShowSticky("Processing...");
                        try
                        {
                            foreach (var fileName in virtualFileNames)
                            {
                                var res = ResourceManager.LoadResource(fileName, true);
                                if (res != null)
                                {
                                    var product = res.ResultComponent as Component_StoreProduct;
                                    if (product != null)
                                    {
                                        if (!product.BuildArchive())
                                        {
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Log.Warning(e.Message);
                            return;
                        }
                        finally
                        {
                            item.Close();
                        }

                        if (virtualFileNames.Count > 1)
                        {
                            ScreenNotifications.Show("The products were prepared successfully.");
                        }
                        else
                        {
                            ScreenNotifications.Show("The product was prepared successfully.");
                        }

                        //open folder in the Explorer
                        Win32Utility.ShellExecuteEx(null, Component_StoreProduct.writeToDirectory);
                    }
                };

                EditorActions.Register(a);
            }
        }
Exemple #15
0
 public EditorActionItem(EditorAction action, params ToolStripItem[] items)
 {
     this.Action = action;
     this.Items  = items;
 }
Exemple #16
0
		public EditorActionProxy(EditorAction action, ToolStripItem[] items)
		{
			this.action = action;
			foreach (ToolStripItem toolStripItem in items)
				toolStripItem.Click += new EventHandler(this.item_Click);
		}
Exemple #17
0
        public void DoAction(EditorAction Action)
        {
            switch (Action)
            {
            case EditorAction.Comment_Out_Selected:
                CommentOutSelected();
                break;

            case EditorAction.Convert_Selected_RPG:
                ConvertSelectedRPG();
                break;

            case EditorAction.Format_CL:
                FormatCL();
                break;

            case EditorAction.Save:
                Save();
                break;

            case EditorAction.Save_As:
                SaveAs();
                break;

            case EditorAction.Zoom_In:
                Zoom(+1f);
                break;

            case EditorAction.Zoom_Out:
                Zoom(-1f);
                break;

            case EditorAction.Undo:
                textEditor.Undo();
                break;

            case EditorAction.Redo:
                textEditor.Redo();
                break;

            case EditorAction.Dupe_Line:
                DuplicateLine();
                break;

            case EditorAction.ParseCode:
                Parse();
                break;

            case EditorAction.OutlineUpdate:
                OutlineUpdate();
                break;

            case EditorAction.ShowContentAssist:
                ShowContentAssist();
                break;

            case EditorAction.TasksUpdate:
                TaskListUpdate();
                break;
            }
        }
 public void AddAction(EditorAction editorAction, ObjectMemento objectMemento)
 {
     Mementoes.Add(objectMemento);
     EditorActions.Add(editorAction);
 }
Exemple #19
0
 /// <summary>
 /// Draw the full (complete) path
 /// </summary>
 public void ExtendPathFull()
 {
     maxNodesToAdd = EditorAction.NodesToAddForLongExtend();
     numberToDraw  = practicalInfinityInt;
     CloseContextMenu();
 }
Exemple #20
0
 private bool AreActionsInSameGroup(EditorAction p_actionRed, EditorAction p_actionBlue)
 {
     if (p_actionRed.groupID != -1 && p_actionBlue.groupID != -1)
     {
         if (p_actionRed.groupID == p_actionBlue.groupID)
         {
             return true;
         }
     }
     return false;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AuthorizeContentAttribute"/> class.
 /// </summary>
 /// <param name="documentStore">The document store.</param>
 public AuthorizeContentAttribute(IDocumentStore documentStore)
 {
     this.documentStore = documentStore;
     this.EditorAction  = EditorAction.None;
 }
Exemple #22
0
		public EditorActionItem(EditorAction action, params ToolStripItem[] items)
		{
			this.Action = action;
			this.Items = items;
		}
    public void OnSceneGUI()
    {
        if( Selection.objects.Length > 1 )
        {
            return;
        }

        if( Event.current.isMouse && Event.current.button == 2 )
            return;

        var view = target as dfGUIManager;

        var evt = Event.current;
        var id = GUIUtility.GetControlID( GetType().Name.GetHashCode(), FocusType.Passive );
        var eventType = evt.GetTypeForControl( id );

        var showGuidesConfig = EditorPrefs.GetBool( "dfGUIManager.ShowGuides", true );
        var createVerticalGuideRect = new Rect();
        var createHorizontalGuideRect = new Rect();

        if( SceneView.currentDrawingSceneView.camera.orthographic )
        {

            //if( createNewGuide() )
            //{
            //    GUIUtility.hotControl = GUIUtility.keyboardControl = id;
            //    evt.Use();
            //}

            if( showGuidesConfig )
            {

                EditorGUIUtility.AddCursorRect( createVerticalGuideRect = getNewVerticalGuideRect(), MouseCursor.ResizeHorizontal );
                EditorGUIUtility.AddCursorRect( createHorizontalGuideRect = getNewHorizontalGuideRect(), MouseCursor.ResizeVertical );

                addGuideCursorRects();

            }

        }

        if( eventType == EventType.repaint )
        {
            drawActionHints( evt );
        }
        else if( eventType == EventType.mouseDown )
        {

            var modifierKeyPressed = evt.alt || evt.control || evt.shift;
            if( evt.button != 0 || modifierKeyPressed )
            {

                if( evt.button == 1 && !modifierKeyPressed )
                {

                    // Ensure that the mouse point is actually contained within the Manager
                    var ray = HandleUtility.GUIPointToWorldRay( evt.mousePosition );
                    RaycastHit hitInfo;
                    if( view.GetComponent<Collider>().Raycast( ray, out hitInfo, 1000 ) )
                    {

                        displayContextMenu();
                        evt.Use();

                        return;

                    }

                }

                GUIUtility.hotControl = GUIUtility.keyboardControl = 0;

            }

            if( Tools.current == Tool.Move && evt.button == 0 && showGuidesConfig )
            {

                if( createVerticalGuideRect.Contains( evt.mousePosition ) )
                {
                    view.guides.Add( selectedGuide = new dfDesignGuide() { orientation = dfControlOrientation.Vertical, position = 0 } );
                    GUIUtility.hotControl = GUIUtility.keyboardControl = id;
                    evt.Use();
                    currentAction = EditorAction.DraggingGuide;
                }
                else if( createHorizontalGuideRect.Contains( evt.mousePosition ) )
                {
                    view.guides.Add( selectedGuide = new dfDesignGuide() { orientation = dfControlOrientation.Horizontal, position = 0 } );
                    GUIUtility.hotControl = GUIUtility.keyboardControl = id;
                    evt.Use();
                    currentAction = EditorAction.DraggingGuide;
                }
                else
                {

                    var guide = getGuideUnderMouse();
                    if( guide != null )
                    {
                        currentAction = EditorAction.DraggingGuide;
                        selectedGuide = guide;
                        GUIUtility.hotControl = GUIUtility.keyboardControl = id;
                        evt.Use();
                        SceneView.RepaintAll();
                    }
                    else
                    {
                        var hit = HandleUtility.PickGameObject( evt.mousePosition, true );
                        if( hit != null )
                        {
                            Selection.activeGameObject = hit;
                            return;
                        }
                    }

                }

            }

        }
        else if( eventType == EventType.mouseUp && selectedGuide != null )
        {
            currentAction = EditorAction.None;
            endDraggingGuide();
            SceneView.RepaintAll();
        }
        else if( evt.keyCode == KeyCode.Escape && selectedGuide != null )
        {
            currentAction = EditorAction.None;
            endDraggingGuide();
            SceneView.RepaintAll();
        }
        else if( currentAction == EditorAction.DraggingGuide && selectedGuide != null )
        {
            dragDesignGuide( evt.mousePosition );
        }

        if( evt.type == EventType.keyDown && evt.keyCode == KeyCode.G && evt.shift && evt.control )
        {
            var showGuides = EditorPrefs.GetBool( "dfGUIManager.ShowGuides", true );
            EditorPrefs.SetBool( "dfGUIManager.ShowGuides", !showGuides );
            SceneView.RepaintAll();
        }
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="AuthorizeContentAttribute"/> class.
 /// </summary>
 /// <param name="documentStore">The document store.</param>
 public AuthorizeContentAttribute(IDocumentStore documentStore)
 {
     this.documentStore = documentStore;
     this.EditorAction = EditorAction.None;
 }
		public EditorActionEventArgs(EditorAction action)
		{
			this.Action = action;
		}
Exemple #26
0
        public void Tick()
        {
            if (!hasInit)
            {
                Init();
            }

            while (actionQueue.Count != 0)
            {
                EditorAction a = actionQueue.Dequeue();
                //Dispatcher.CurrentDispatcher.Invoke(a, DispatcherPriority.Normal);
                if (a == null)  //wait frame
                {
                    break;
                }
                a.a();
                if (a.mres != null)
                {
                    a.mres.Set();
                    a.mres.Dispose();
                }
            }

            if (!EditorSubsystem.getInstance().IsTesting())
            {
                //draw grid lines
                if (EngineCommandBindings.DrawGrid && EngineCommandBindings.GridSize > 0)
                {
                    Vector3 camPos = EditorSubsystem.getInstance().EditorCamera().gameObject.transform.GetGlobalPosition();
                    float   startX = camPos.X;
                    float   startY = camPos.Y;
                    float   startZ = camPos.Z;
                    startX = startX - (startX % EngineCommandBindings.GridSize);
                    if (startY > 0)
                    {
                        startY = startY - (startY % EngineCommandBindings.GridSize);
                    }
                    else
                    {
                        startY = startY + (startY % EngineCommandBindings.GridSize);
                    }
                    startZ = startZ - (startZ % EngineCommandBindings.GridSize);

                    for (int y = (int)startY; y <= (int)startY + EngineCommandBindings.gridExtent / 2; y += EngineCommandBindings.GridSize)
                    {
                        //for every y, draw an x,z plane
                        for (int x = (int)startX - EngineCommandBindings.gridExtent; x <= (int)startX + EngineCommandBindings.gridExtent; x += EngineCommandBindings.GridSize)
                        {
                            //draw z
                            Renderer.getInstance().DrawLinePerma(new Vector3(x, y, startZ - EngineCommandBindings.gridExtent), new Vector3(x, y, startZ + EngineCommandBindings.gridExtent),
                                                                 new Color(0.39f, 0.60f, 0.93f, .5f));
                            for (int z = (int)startZ - EngineCommandBindings.gridExtent; z <= (int)startZ + EngineCommandBindings.gridExtent; z += EngineCommandBindings.GridSize)
                            {
                                //draw x
                                Renderer.getInstance().DrawLinePerma(new Vector3(x - EngineCommandBindings.gridExtent, y, z), new Vector3(x + EngineCommandBindings.gridExtent, y, z),
                                                                     new Color(.4f, .4f, 0.0f, .3f));
                            }
                        }
                    }
                }

                //save occasionally
                autoSaveTimer += FrameController.DT();
                if (autoSaveTimer > 30.0f)
                {
                    QueueAction(() =>
                    {
                        try
                        {
                            StateSerializer ss = new StateSerializer();
                            ss.DoRecoverySave();
                        }
                        catch (Exception e)
                        {
                            Logger.Log("FAILED TO SAVE RECOVERY SAVE: " + e.Message);
                        }
                    });
                    autoSaveTimer = 0;
                }

                //occasionally check for available assets
                ++checkforChangedAssetsTimer;
                if (checkforChangedAssetsTimer > CHECKFORCHANGEDASSETS_TIME)
                {
                    AssetManager.getInstance().CheckForChangedAssets();
                    checkforChangedAssetsTimer = 0;
                }

                //do standard updates
                if (Input.GetIsMouseInWindow(true) && EngineManagerViewModel.instance.EngineEmbedHasVisibility && EngineManagerViewModel.instance._isFocused)
                {
                    //run sub systems
                    auto_builder.Update();

                    //set tooltips
                    mouseTooltipText.gameObject.transform.SetPosition(Input.GetMouseX(true) - Engine.getInstance().GetGameWnd().GetWindowWidth() * 0.5f,
                                                                      -(Input.GetMouseY(true) - Engine.getInstance().GetGameWnd().GetWindowHeight() * 0.5f), 0);
                    editorStatusText.gameObject.transform.SetPosition(-Engine.getInstance().GetGameWnd().GetWindowWidth() * 0.49f,
                                                                      Engine.getInstance().GetGameWnd().GetWindowHeight() * 0.44f, 0);
                    editorStatusText.mText = "--- STATUS ---\\n" +
                                             "Arrow Keys Snap Prec.: " + arrowSnapPrecision.ToString("0.0") +
                                             "\\nFPS: " + (1.0f / FrameController.DT()).ToString("0.0") +
                                             "\\n---------------";

                    CCamera editorCamera = EditorSubsystem.getInstance().EditorCamera();
                    if (Input.GetTriggered(0, "F2") == 1.0f)
                    {
                        //duplicate
                        EngineCommandBindings.CMD_DuplicateObjects();
                    }

                    //select objects naively
                    GameObject gobj = GameObject.From(PhysicEngine.getInstance().RayCast3D(editorCamera.gameObject.transform.position,
                                                                                           editorCamera.gameObject.transform.GetForwardVector(), editorCamera, Input.GetMouseX(true),
                                                                                           Input.GetMouseY(true), 10000.0f));
                    if (gobj != null && gobj.GetFlag("ArtWidget"))
                    {
                        //select widget's actual object
                        gobj = GameObject.From(EditorSubsystem.getInstance().widgetManager.GetAttachedObjFromWidgetObj(gobj));
                    }
                    if (gobj != null && !gobj.GetFlag("Widget"))
                    {
                        //show tooltip if mouse over
                        mouseTooltipText.mText = gobj.GetName();

                        //select if clicked on
                        if (Input.GetTriggered(0, "MouseLClick") == 1.0f)
                        {
                            Application.Current.Dispatcher.Invoke(new Action(() =>
                            {
                                try
                                {
                                    if (Input.GetHeld(0, "AdditiveMod") == 1.0f)
                                    {
                                        GameObjectSelectionManager.RequestAdditiveSelect(gobj);
                                    }
                                    else
                                    {
                                        GameObjectSelectionManager.RequestSelect(gobj);
                                    }
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine("Consumed Error in Hierarchy: " + e.ToString());
                                }
                            }
                                                                             ));
                        }
                    }
                    else
                    {
                        mouseTooltipText.mText = "";
                    }

                    //rotate camera and move camera
                    float dt = FrameController.getInstance().GetDeltaTime();
                    if (Input.GetHeld(0, "MoveFaster") == 1.0f)
                    {
                        dt *= 3;
                    }
                    Vector3 velocityThisFrame = new Vector3();
                    if (Input.GetHeld(0, "MouseRCLick") == 1.0f)
                    {
                        float dx = 0.25f * (Input.GetMouseDeltaX() * (3.14f / 180.0f));
                        float dy = 0.25f * (Input.GetMouseDeltaY() * (3.14f / 180.0f));
                        editorCamera.Pitch(dy);
                        editorCamera.RotateY(dx);

                        float val = Input.GetValue(0, "up");
                        velocityThisFrame.Z += val;
                        val = Input.GetValue(0, "right");
                        velocityThisFrame.X += val;
                        val = Input.GetValue(0, "down");
                        velocityThisFrame.Z -= val;
                        val = Input.GetValue(0, "left");
                        velocityThisFrame.X -= val;
                        cameraVelocity      += velocityThisFrame;
                        //cameraVelocity = cameraVelocity.Add(velocityThisFrame);
                        //MathHelper.Clamp
                        cameraVelocity.X = MathHelper.Clamp(cameraVelocity.X, -6, 6);
                        cameraVelocity.Y = MathHelper.Clamp(cameraVelocity.Y, -6, 6);
                        cameraVelocity.Z = MathHelper.Clamp(cameraVelocity.Z, -6, 6);
                        //cameraVelocity.Clamp(-6.0f, 6.0f);
                    }
                    if (velocityThisFrame.X == 0)
                    {
                        cameraVelocity.X *= 0.9f;
                    }
                    if (velocityThisFrame.Z == 0)
                    {
                        cameraVelocity.Z *= 0.9f;
                    }
                    editorCamera.Walk(cameraVelocity.Z * dt);
                    editorCamera.Strafe(cameraVelocity.X * dt);

                    //look at
                    if (_lookTimer != 0)
                    {
                        _lookTimer += FrameController.DT();
                    }
                    if (_lookTimer > 1.3f)
                    {
                        _lookTimer = 0;
                    }
                    if (Input.GetTriggered(0, "LookAt") == 1.0f)
                    {
                        if (EngineManagerViewModel.instance.SelectedGameObjects.Count == 0)
                        {
                            return;
                        }
                        GameObject selobj = EngineManagerViewModel.instance.SelectedGameObjects[0];
                        if (_lookTimer == 0)
                        {
                            _lookTimer = 1; //force the setup
                            if (selobj != null)
                            {
                                editorCamera.gameObject.transform.LookAt(selobj.transform.position);
                            }
                        }
                        else
                        {
                            editorCamera.gameObject.transform.LookAt(selobj.transform.position);
                            Vector3 forw = editorCamera.gameObject.transform.GetForwardVector();
                            editorCamera.gameObject.transform.SetPosition(selobj.transform.position - (forw * 8));
                            _lookTimer = 0;
                        }
                    }

                    //arrow keys moving
                    if (Input.GetTriggered(0, "Add") > 0)
                    {
                        arrowSnapPrecision += 0.1f;
                    }
                    if (Input.GetTriggered(0, "Sub") > 0)
                    {
                        arrowSnapPrecision -= 0.1f;
                    }
                    if (Input.GetTriggered(0, "ArrowUp") > 0)
                    {
                        foreach (var selobj in EngineManagerViewModel.instance.SelectedGameObjects)
                        {
                            selobj.transform.SetPositionZ(selobj.transform.position.z + arrowSnapPrecision);
                        }
                    }
                    if (Input.GetTriggered(0, "ArrowDown") > 0)
                    {
                        foreach (var selobj in EngineManagerViewModel.instance.SelectedGameObjects)
                        {
                            selobj.transform.SetPositionZ(selobj.transform.position.z - arrowSnapPrecision);
                        }
                    }
                    if (Input.GetTriggered(0, "ArrowRight") > 0)
                    {
                        foreach (var selobj in EngineManagerViewModel.instance.SelectedGameObjects)
                        {
                            selobj.transform.SetPositionX(selobj.transform.position.x + arrowSnapPrecision);
                        }
                    }
                    if (Input.GetTriggered(0, "ArrowLeft") > 0)
                    {
                        foreach (var selobj in EngineManagerViewModel.instance.SelectedGameObjects)
                        {
                            selobj.transform.SetPositionX(selobj.transform.position.x - arrowSnapPrecision);
                        }
                    }
                }
            }
        }