예제 #1
0
        internal static SelectMode GetSelectMode(EditLevel edit, ComponentMode component)
        {
            switch (edit)
            {
            case EditLevel.Top:
                return(SelectMode.Object);

            case EditLevel.Geometry:
            {
                switch (component)
                {
                case ComponentMode.Vertex:
                    return(SelectMode.Vertex);

                case ComponentMode.Edge:
                    return(SelectMode.Edge);

                default:
                    return(SelectMode.Face);
                }
            }

            case EditLevel.Texture:
                return(SelectMode.TextureFace);

            default:
                return(SelectMode.None);
            }
        }
예제 #2
0
        /// <summary>
        /// Create a window based on a given IC and IC List.  Provide
        /// an edit level of either View or Edit as appropriate.
        /// </summary>
        /// <param name="IC"></param>
        /// <param name="useicl"></param>
        /// <param name="el"></param>
        public Window1(UIGates.IC IC, ICList useicl, EditLevel el)
            : this(el)
        {
            icl = useicl;

            gateCanvas.ICL          = icl;
            gateCanvas.UndoProvider = (UndoRedo.UndoManager)Resources["undoManager"];
            spGates.ICList          = icl;
            _filename = IC.AbGate.Name;


            this.Loaded += (sender, e) =>
            {
                RefreshGateCanvas(IC);

                spGates.ICName = IC.AbGate.Name;
                if (el == EditLevel.VIEW)
                {
                    gateCanvas.IsReadOnly = true;
                }

                Dispatcher.BeginInvoke(
                    new Action(() =>
                {
                    Activate();
                    Focus();
                }));
            };
        }
예제 #3
0
    /// <summary>
    /// Checks if LevelName is valid before going to next step of edit level when the Next button is pressed
    /// </summary>
    private void _on_NextStepBtn_pressed()
    {
        string levelName = levelNameLine.Text;
        int    monsterId = monsterList[count].MonsterId;
        int    timeLimit = Int32.Parse(timeLimitBtn.Text);

        //GD.Print("Level Name: " + levelName + "\nMonsterId: " + monsterId + "\nTimeLimit: " + timeLimit);

        if (levelName == "")
        {
            GD.Print("Level name field is empty!");
            errorMessageLabel.SetText("Level name field is empty!");
        }
        else if (EditLevelBL.CheckValidLevelName(oldName, levelName) != 1)
        {
            GD.Print("Level name already exist!");
            errorMessageLabel.SetText("Level name already exist!");
        }
        else
        {
            EditLevel.SetLevelInitInfo(levelName, monsterId, timeLimit);
            GetTree().ChangeScene("res://Presentation/EditLevel/EditLevel.tscn");
        }
    }
예제 #4
0
 public bool IsEditable(EditLevel level)
 {
     bool CanEdit;
     CanEdit = HttpContext.Current.User.IsInRole("Survey Administrator") || HttpContext.Current.User.IsInRole("Administrator") ? true : false;
     switch (level)
     {
         case EditLevel.Admin:
             return CanEdit;
         case EditLevel.Sponsor:
             return (CanEdit || (IsSponsorContact && IsInEditMode)) ? true : false;
             //Model.Project.IsEditable(DRCOG.Domain.Models.Survey.InstanceSecurity.EditLevel.Admin) || (Model.Project.IsSponsorContact && (Model.Project.IsEditable() || Model.Current.IsOpen()))
         default:
             return CanEdit;
     }
 }
예제 #5
0
        private void OpenExistingMapCommand()
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.DefaultExt = ".dfl"; // Default file extension
            dlg.Filter = "DotNetFish Level (.dfl)|*.dfl";

            Nullable<bool> result = dlg.ShowDialog();

            if (result == true)
            {
                // Open document
                string filename = dlg.FileName;
                GameWorld gameWorld = DotNetFish.LevelBuilder.FileIO.LoadMap(filename);

                EditLevel editLevel = new EditLevel(gameWorld);
                Point currentPoint = new Point(gameWorld.GameMap.GetLength(0) / 2, gameWorld.GameMap.GetLength(1) / 2);
                editLevel.DataContext = new EditLevelViewModel(gameWorld,currentPoint);
                editLevel.Show();
                this.OnRequestClose();
            }
        }
예제 #6
0
    public override void OnInspectorGUI()
    {
        // in the editor, get the reference to the map if you don't already have it
        if (Application.isPlaying && !gotMap)
        {
            ((EditLevel)target).getCurrentMap();
            gotMap = true;
        }
        EditLvl = (EditLevel)target;

        // A plethora of buttons used to call the methods in the EditLevel class/
        // Do exactly what they says on the tin.
        GUILayout.BeginHorizontal();            // buttons & variables for level loading/saving/creating
        if (GUILayout.Button("Make New Level"))
        {
            ((EditLevel)target).getNewMap();
        }
        if (GUILayout.Button("Save Level"))
        {
            ((EditLevel)target).saveLevel();
        }
        if (GUILayout.Button("Load Level"))
        {
            ((EditLevel)target).loadLevelByName();
        }
        GUILayout.EndHorizontal();
        if (GUILayout.Button("Load & Update Map Version"))              // load old map version, call method that converts to new map type that uses the new node type
        {
            ((EditLevel)target).updateMapVer();
        }
        GUILayout.BeginHorizontal();
        //playerLevel = GUILayout.TextField(playerLevel);
        GUILayout.Label("Level Name", GUILayout.Width(labelWidth));
        EditLvl.levelName = GUILayout.TextField(EditLvl.levelName);
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUILayout.Label("Level Path", GUILayout.Width(labelWidth));
        EditLvl.levelPath = GUILayout.TextField(EditLvl.levelPath);
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        EditLvl.overwriteLevel = GUILayout.Toggle(EditLvl.overwriteLevel, "Overwrite Level");
        GUILayout.EndHorizontal();
        GUILayout.Space(10f);

        // button for regenerating the level generated by scripts
        if (GUILayout.Button("Re-generate levels from scripts"))
        {
            BatchGenerate.GenerateRooms();
        }
        GUILayout.Space(10f);

        // button & variables for creating a new chunk and linking to it
        if (GUILayout.Button("Create New Tile-Chunk"))
        {
            ((EditLevel)target).createTileChunk();
        }
        EditLvl.methodDirection = (GameManager.Direction)EditorGUILayout.EnumPopup("Direction", (System.Enum)EditLvl.methodDirection);
        GUILayout.BeginHorizontal();
        EditLvl.newChunkWidth  = EditorGUILayout.IntField("Chunk Width", EditLvl.newChunkWidth);
        EditLvl.newChunkHeight = EditorGUILayout.IntField("Chunk Height", EditLvl.newChunkHeight);
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        EditLvl.linkX = EditorGUILayout.IntSlider("X to link to", EditLvl.linkX, 0, EditLvl.newChunkWidth - 1);
        EditLvl.linkY = EditorGUILayout.IntSlider("Y to link to", EditLvl.linkY, 0, EditLvl.newChunkHeight - 1);
        GUILayout.EndHorizontal();
        EditLvl.newChunkColor = EditorGUILayout.ColorField("New Chunk Color", EditLvl.newChunkColor);
        GUILayout.Space(10f);

        // buttons & variables for "doing something" in the given direction: create a link/wall/delete a tile in the given direction.
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Create link"))
        {
            ((EditLevel)target).createLink();
        }
        if (GUILayout.Button("Create wall"))
        {
            ((EditLevel)target).createWall();
            //Debug.Log("Error: createWall() does not exist right now");
        }
        if (GUILayout.Button("Delete tile"))
        {
            ((EditLevel)target).deleteTile();
        }
        GUILayout.EndHorizontal();
        EditLvl.methodDirection    = (GameManager.Direction)EditorGUILayout.EnumPopup("Direction", (System.Enum)EditLvl.methodDirection);
        EditLvl.linkToIndex        = EditorGUILayout.IntField("Index to link", EditLvl.linkToIndex);
        EditLvl.linkDirectionality = (EditLevel.LinkDirectionality)EditorGUILayout.EnumPopup(
            "Link directionality",
            (System.Enum)EditLvl.linkDirectionality);
        GUILayout.Space(10f);

        // set the type of the current tile
        if (GUILayout.Button("Set type"))
        {
            ((EditLevel)target).setType();
        }
        EditLvl.type = (Node.TileType)EditorGUILayout.EnumPopup("Tile type", (System.Enum)EditLvl.type);
        GUILayout.Space(10f);

        // redraw the map on the screen after changes are made manually
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Redraw Enviroment"))
        {
            ((EditLevel)target).redraw();
        }
        if (GUILayout.Button("redo corner visibility"))                 // re-calculate the visibility of corners.
        {
            ((EditLevel)target).updateCornerDrawing();
        }
        GUILayout.EndHorizontal();
        GUILayout.Space(10f);

        // buttons & variables for changes to the current node
        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical();
        if (GUILayout.Button("Apply changes to node"))
        {
            ((EditLevel)target).applyToNode();
        }
        if (GameManager.istates[(int)GameManager.IStateType.gameplay] != null)
        {
            ((Gameplay)GameManager.istates[(int)GameManager.IStateType.gameplay]).pitWalk =             // toggle ability to walk over pits
                                                                                            GUILayout.Toggle(
                ((Gameplay)GameManager.istates[(int)GameManager.IStateType.gameplay]).pitWalk,
                "Toggle ignore pits");
        }
        else
        {
            GUILayout.Toggle(false, "Toggle ignore pits");              // prevent null-reference exception in editor
        }
        GUILayout.EndVertical();
        GUILayout.BeginVertical();
        if (GUILayout.Button("Sample node appearance"))
        {
            ((EditLevel)target).sampleTile();
        }
        EditLvl.drawing = GUILayout.Toggle(EditLvl.drawing, "Toggle drawing");
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        // node goes here
        GUILayout.EndHorizontal();

        /*
         * GUILayout.BeginHorizontal();
         * GUILayout.EndHorizontal();
         */

        // show the current node and map variables.
        // getting these to show up in a structed way, the same as the rest of this,
        // is probably possible, but is too much work at this time.
        base.OnInspectorGUI();
    }
예제 #7
0
        /// <summary>
        /// Create a window based on a given IC and IC List.  Provide
        /// an edit level of either View or Edit as appropriate.
        /// </summary>
        /// <param name="IC"></param>
        /// <param name="useicl"></param>
        /// <param name="el"></param>
        public Window1(UIGates.IC IC, ICList useicl, EditLevel el)
            : this(el)
        {
            icl = useicl;

            gateCanvas.ICL = icl;
            gateCanvas.UndoProvider = (UndoRedo.UndoManager)Resources["undoManager"];
            spGates.ICList = icl;
            _filename = IC.AbGate.Name;


            this.Loaded += (sender, e) =>
            {
                RefreshGateCanvas(IC);

                spGates.ICName = IC.AbGate.Name;
                if (el == EditLevel.VIEW)
                    gateCanvas.IsReadOnly = true;

                Dispatcher.BeginInvoke(
                    new Action(() =>
                    {
                        Activate();
                        Focus();

                    }));

            };

        }
예제 #8
0
        protected Window1(EditLevel e)
        {
            InitializeComponent();
            _myEditLevel = e;

            EventDispatcher.BatchDispatcher = Dispatcher;

            gateCanvas.Circuit.Start();
            

            // Everybody gets zoom
            sbZoom = new ShadowBox();
            sbZoom.Margin = new Thickness(20);
            Grid1.Children.Remove(spZoom);
            sbZoom.Children.Add(spZoom);
            spZoom.Background = Brushes.Transparent;
            sbZoom.VerticalAlignment = VerticalAlignment.Top;
            sbZoom.HorizontalAlignment = HorizontalAlignment.Right;
            Grid1.Children.Add(sbZoom);
            Grid.SetColumn(sbZoom, 1);
            Grid.SetRow(sbZoom, 1);

            // everybody gets view keys
            this.PreviewKeyDown += new KeyEventHandler(Window1_View_KeyDown);

            Grid1.Children.Remove(spGates);
            if (e == EditLevel.FULL ||
                e == EditLevel.EDIT)
            {
                

                // delete for edit or full
                this.PreviewKeyDown += new KeyEventHandler(Window1_EditFull_KeyDown);

                this.PreviewKeyUp += (s2, e2) =>
                {
                    // add moves if needed
                    if (moves != null)
                        ((UndoRedo.UndoManager)Resources["undoManager"]).Add(moves);
                    
                    moves = null;
                };

                // drag/drop for edit or full
                DragDrop.DragDropHelper.ItemDropped += new EventHandler<DragDrop.DragDropEventArgs>(DragDropHelper_ItemDropped);

                // gates for edit or full

                sbGates = new ShadowBox();
                sbGates.Margin = new Thickness(20, 20, 20, 20);
                sbGates.Children.Add(spGates);
                spGates.Background = Brushes.Transparent;
                sbGates.VerticalAlignment = VerticalAlignment.Center;
                sbGates.HorizontalAlignment = HorizontalAlignment.Left;
                Grid1.Children.Add(sbGates);
                Grid.SetColumn(sbGates, 1);
                Grid.SetRow(sbGates, 1);

                // edit or full get undo and edit
                tbUndo.Visibility = Visibility.Visible;
                tbEdit.Visibility = Visibility.Visible;

                // monitor the clipboard to provide cut/copy/paste visibility
                gateCanvas.selected.ListChanged += (s2, e2) =>
                {
                    btnCopy.IsEnabled = gateCanvas.selected.Count > 0;
                    btnCut.IsEnabled = gateCanvas.selected.Count > 0;
                    btnCopyAsImage.IsEnabled = gateCanvas.selected.Count > 0;
                };
                this.Activated += (s2, e2) =>
                {
                    btnPaste.IsEnabled = Clipboard.ContainsData("IC");
                };
            } 


            Grid1.Children.Remove(spSpeed);
            if (e == EditLevel.FULL)
            {
                // speed only for the main window
                sbSpeed = new ShadowBox();
                sbSpeed.Margin = new Thickness(20, 20, 175, 20);
                sbSpeed.Children.Add(spSpeed);
                spSpeed.Background = Brushes.Transparent;
                sbSpeed.VerticalAlignment = VerticalAlignment.Top;
                sbSpeed.HorizontalAlignment = HorizontalAlignment.Right;
                Grid1.Children.Add(sbSpeed);
                Grid.SetColumn(sbSpeed, 1);
                Grid.SetRow(sbSpeed, 1);

                // otherwise the defaults mess it up when you open a new window
                slSpeed.ValueChanged += (sender2, e2) =>
                {
                    Gates.PropagationThread.SLEEP_TIME = (int)slSpeed.Value;
                };

                // full also gets file and ic
                tbFile.Visibility = Visibility.Visible;
                tbIC.Visibility = Visibility.Visible;
            }

            if (e == EditLevel.EDIT)
            {
                // can't edit the user gates in this view
                spGates.IsReadOnly = true;
            }

            /*
            this.Loaded += (sender2, e2) => 
            {
                ((UndoRedo.UndoManager)Resources["undoManager"]).SetSavePoint(); 
                UpdateTitle();
                lblAppTitle.Text = APP_TITLE;
                lblAppVersion.Text = APP_VERSION;
                lblAppCopyright.Text = APP_COPYRIGHT;

            };
             * 
             * */

            this.PreviewMouseWheel += (sender, e2) =>
            {
                if (e2.Delta > 0)
                    slZoom.Value += 0.1;
                else
                    slZoom.Value -= 0.1;
                
                e2.Handled = true;
                
            };


            //BOKANG
            /*

            ((UndoRedo.UndoManager)Resources["undoManager"]).PropertyChanged += (sender2, e2) =>
            {
                UpdateTitle(); // look for modified or not
            };
             * 
             * */

            //BOKANG
            //InfoLine.GetInstance().PropertyChanged += InfoLine_PropertyChanged;


            //BOKANG

            if (sbSpeed != null)
                sbSpeed.Visibility = Visibility.Collapsed;

            if (myToolbarTray != null)
                myToolbarTray.Visibility = Visibility.Collapsed;

            spAppInfo.Visibility = Visibility.Collapsed;

            lblInfoLine.Visibility = Visibility.Collapsed;

            spGates.Visibility = Visibility.Collapsed;
        }
예제 #9
0
        protected Window1(EditLevel e)
        {
            InitializeComponent();
            _myEditLevel = e;

            EventDispatcher.BatchDispatcher = Dispatcher;

            gateCanvas.Circuit.Start();


            // Everybody gets zoom
            sbZoom        = new ShadowBox();
            sbZoom.Margin = new Thickness(20);
            Grid1.Children.Remove(spZoom);
            sbZoom.Children.Add(spZoom);
            spZoom.Background          = Brushes.Transparent;
            sbZoom.VerticalAlignment   = VerticalAlignment.Top;
            sbZoom.HorizontalAlignment = HorizontalAlignment.Right;
            Grid1.Children.Add(sbZoom);
            Grid.SetColumn(sbZoom, 1);
            Grid.SetRow(sbZoom, 1);

            // everybody gets view keys
            this.PreviewKeyDown += new KeyEventHandler(Window1_View_KeyDown);

            Grid1.Children.Remove(spGates);
            if (e == EditLevel.FULL ||
                e == EditLevel.EDIT)
            {
                // delete for edit or full
                this.PreviewKeyDown += new KeyEventHandler(Window1_EditFull_KeyDown);

                this.PreviewKeyUp += (s2, e2) =>
                {
                    // add moves if needed
                    if (moves != null)
                    {
                        ((UndoRedo.UndoManager)Resources["undoManager"]).Add(moves);
                    }

                    moves = null;
                };

                // drag/drop for edit or full
                DragDrop.DragDropHelper.ItemDropped += new EventHandler <DragDrop.DragDropEventArgs>(DragDropHelper_ItemDropped);

                // gates for edit or full

                sbGates        = new ShadowBox();
                sbGates.Margin = new Thickness(20, 20, 20, 20);
                sbGates.Children.Add(spGates);
                spGates.Background          = Brushes.Transparent;
                sbGates.VerticalAlignment   = VerticalAlignment.Center;
                sbGates.HorizontalAlignment = HorizontalAlignment.Left;
                Grid1.Children.Add(sbGates);
                Grid.SetColumn(sbGates, 1);
                Grid.SetRow(sbGates, 1);

                // edit or full get undo and edit
                tbUndo.Visibility = Visibility.Visible;
                tbEdit.Visibility = Visibility.Visible;

                // monitor the clipboard to provide cut/copy/paste visibility
                gateCanvas.selected.ListChanged += (s2, e2) =>
                {
                    btnCopy.IsEnabled        = gateCanvas.selected.Count > 0;
                    btnCut.IsEnabled         = gateCanvas.selected.Count > 0;
                    btnCopyAsImage.IsEnabled = gateCanvas.selected.Count > 0;
                };
                this.Activated += (s2, e2) =>
                {
                    btnPaste.IsEnabled = Clipboard.ContainsData("IC");
                };
            }


            Grid1.Children.Remove(spSpeed);
            if (e == EditLevel.FULL)
            {
                // speed only for the main window
                sbSpeed        = new ShadowBox();
                sbSpeed.Margin = new Thickness(20, 20, 175, 20);
                sbSpeed.Children.Add(spSpeed);
                spSpeed.Background          = Brushes.Transparent;
                sbSpeed.VerticalAlignment   = VerticalAlignment.Top;
                sbSpeed.HorizontalAlignment = HorizontalAlignment.Right;
                Grid1.Children.Add(sbSpeed);
                Grid.SetColumn(sbSpeed, 1);
                Grid.SetRow(sbSpeed, 1);

                // otherwise the defaults mess it up when you open a new window
                slSpeed.ValueChanged += (sender2, e2) =>
                {
                    Gates.PropagationThread.SLEEP_TIME = (int)slSpeed.Value;
                };

                // full also gets file and ic
                tbFile.Visibility = Visibility.Visible;
                tbIC.Visibility   = Visibility.Visible;
            }

            if (e == EditLevel.EDIT)
            {
                // can't edit the user gates in this view
                spGates.IsReadOnly = true;
            }

            this.Loaded += (sender2, e2) =>
            {
                ((UndoRedo.UndoManager)Resources["undoManager"]).SetSavePoint();
                UpdateTitle();
                lblAppTitle.Text     = APP_TITLE;
                lblAppVersion.Text   = APP_VERSION;
                lblAppCopyright.Text = APP_COPYRIGHT;
            };

            // green team: added if statement to determine if ctrl keys are pressed
            // then fires mouse wheel zoom event

            this.PreviewMouseWheel += (sender, e2) =>
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    gateCanvas.UseZoomCenter = true;
                    double centerX = (Mouse.GetPosition(this).X + gateCanvas.GCScroller.HorizontalOffset) / gateCanvas.Zoom;
                    double centerY = (Mouse.GetPosition(this).Y + gateCanvas.GCScroller.VerticalOffset) / gateCanvas.Zoom;
                    gateCanvas.ZoomCenter = new Point(centerX, centerY);

                    if (e2.Delta > 0)
                    {
                        slZoom.Value += 0.1;
                    }
                    else
                    {
                        slZoom.Value -= 0.1;
                    }

                    e2.Handled = true;
                }
            };



            ((UndoRedo.UndoManager)Resources["undoManager"]).PropertyChanged += (sender2, e2) =>
            {
                UpdateTitle(); // look for modified or not
            };

            InfoLine.GetInstance().PropertyChanged += InfoLine_PropertyChanged;
        }
예제 #10
0
        /**
         * Update the highlight and wireframe graphics.
         */
        public void RebuildGraphics(pb_Object[] selection, pb_Edge[][] universalEdgesDistinct, EditLevel editLevel, SelectMode selectionMode)
        {
            // in the event that the editor starts calling UpdateGraphics before the object has run OnEnable() (which happens on script reloads)
            if (pool == null)
            {
                return;
            }

            // clear t he current renderables
            foreach (pb_Renderable ren in pbRenderer.renderables)
            {
                pool.Put(ren);
            }

            pbRenderer.renderables.Clear();

            // update wireframe
            wireframeMaterial.SetColor("_Color", (selectionMode == SelectMode.Edge && editLevel == EditLevel.Geometry) ? edgeSelectionColor : wireframeColor);

            for (int i = 0; i < selection.Length; i++)
            {
                pbRenderer.renderables.Add(BuildEdgeMesh(selection[i], universalEdgesDistinct[i]));
            }

            if (editLevel == EditLevel.Geometry)
            {
                // update vert / edge / face
                switch (selectionMode)
                {
                case SelectMode.Face:
                    foreach (pb_Object pb in selection)
                    {
                        pbRenderer.renderables.Add(BuildFaceMesh(pb));
                    }
                    break;

                case SelectMode.Vertex:
                    foreach (pb_Object pb in selection)
                    {
                        pbRenderer.renderables.Add(BuildVertexMesh(pb));
                    }
                    break;

                default:
                    break;
                }
            }
        }
예제 #11
0
	/**
	 * Changes the current Editor level - switches between Object, Sub-object, and Texture (hidden).
	 */
	public void SetEditLevel(EditLevel el)
	{	
		previousEditLevel = editLevel;
		editLevel = el;

		switch(el)
		{
			case EditLevel.Top:
				ClearFaceSelection();		
				UpdateSelection(true);

				SetSelection(Selection.gameObjects);
				break;

			case EditLevel.Geometry:
				
				Tools.current = Tool.None;

				UpdateSelection(false);
				SceneView.RepaintAll();
				break;

			case EditLevel.Plugin:
				UpdateSelection(false);
				SceneView.RepaintAll();
				break;

			#if !PROTOTYPE
			case EditLevel.Texture:
				
				previousHandleAlignment = handleAlignment;
				previousSelectMode = selectionMode;

				SetHandleAlignment(HandleAlignment.Plane);
				break;
			#endif
		}


		#if !PROTOTYPE
		if(previousEditLevel == EditLevel.Texture && el != EditLevel.Texture)
		{
			SetSelectionMode(previousSelectMode);
			SetHandleAlignment(previousHandleAlignment);
		}
		#endif

		if(editLevel != EditLevel.Texture)
			EditorPrefs.SetInt(pb_Constant.pbDefaultEditLevel, (int)editLevel);
	}