public ExpansionEditor() { InitializeComponent(); _newEditorState = _oldEditorState = EditorState.FixedOutput; _fixedInputPointsIndex = -1; _fixedOutputPointsIndex = -1; _inputPlanetIndex = -1; _outputPlanetIndex = -1; this.FieldPanel.MouseDown += new MouseEventHandler(FieldPanel_MouseDown); SetStatusText(); SetTreeView(); DisableAllSaving(); _painter = new Painter(_strandNodeList); _fieldPanelGraphicsBuffer = _bufferedGraphicsContext.Allocate(FieldPanel.CreateGraphics(), FieldPanel.DisplayRectangle); _painter.DrawBackground(_fieldPanelGraphicsBuffer.Graphics); PointGroupParameters.InitSamplePanel(_painter._inputDotSize, _painter._outputDotSize, _painter._theLinePen, _painter._theOutputFillBrush); PointGroupParameters.UpdateFieldEditor += new PointGroupParameters.PointGroupParametersChangedHandler(PointGroupParametersChangedDelegate); ZoomComboBox.SelectedIndex = 4; }
void AccessoriesButton() { if (currentEditorState != EditorState.ACCESSORIES) { if (GUILayout.Button("Accessories")) currentEditorState = EditorState.ACCESSORIES; } }
public void ShowEditor(GameObject baseObject, float maxDistanceFromBase, GameObject[] blockPrefabs, Texture2D[] blockImages) { this.baseObject = baseObject; this.maxDistanceFromBase = maxDistanceFromBase; this.blockPrefabs = blockPrefabs; this.blockImages = blockImages; editorState = EditorState.Starting; }
void Start () { _editorState = GameObject.Find ("UICanvas").GetComponent<EditorState> (); _materialsController = GameObject.Find ("MaterialsCanvas").GetComponent<MaterialsController> (); int width = 2 * EDITOR_SPACE_HALF_WIDTH + 1; _editSpace = new int[width, width, width]; if (use_lerp_color) { GenNearestVoxelPointForEdgePointTable (); } else { GenNearestVoxelPointTable (); } }
private void Initialize() { if (m_Initialized) { return; } m_Animator = GetComponent <Animator>(); m_Animator.updateMode = m_UpdateMode; m_Animator.cullingMode = m_CullingMode; m_Graph = PlayableGraph.Create(); m_Graph.SetTimeUpdateMode(DirectorUpdateMode.GameTime); SimpleAnimationPlayable template = new SimpleAnimationPlayable(); var playable = ScriptPlayable <SimpleAnimationPlayable> .Create(m_Graph, template, 1); m_Playable = playable.GetBehaviour(); m_Playable.onDone += OnPlayableDone; if (m_States == null) { m_States = new EditorState[1]; m_States[0] = new EditorState(); m_States[0].defaultState = true; m_States[0].name = "Default"; } if (m_States != null) { foreach (var state in m_States) { if (state.clip) { m_Playable.AddClip(state.clip, state.name); } } } EnsureDefaultStateExists(); AnimationPlayableUtilities.Play(m_Animator, m_Playable.playable, m_Graph); Play(); Kick(); m_Initialized = true; }
public virtual void OnStateChanged(EditorState state) { switch (state) { case EditorState.Select: gameObject.SetActive(false); break; case EditorState.Editor: gameObject.SetActive(true); break; default: gameObject.SetActive(false); break; } }
const string selectFirst = "Please select a Vertex (or Crease) first!"; //error message /// <summary> /// constructor /// </summary> /// <param name="commandData">selected floor (or slab)</param> /// <param name="commandData">contains reference of Revit Application</param> public SlabShapeEditingForm(Floor floor, ExternalCommandData commandData) { InitializeComponent(); m_commandData = commandData; m_slabProfile = new SlabProfile(floor, commandData); m_slabShapeEditor = floor.SlabShapeEditor; m_lineTool = new LineTool(); m_pointTool = new LineTool(); editorState = EditorState.AddVertex; m_graphicsPaths = new ArrayList(); m_createdVertices = new ArrayList(); m_createCreases = new ArrayList(); m_selectIndex = -1; m_clickedIndex = -1; m_toolPen = new Pen(System.Drawing.Color.Blue, 2); m_selectPen = new Pen(System.Drawing.Color.Red, 2); m_profilePen = new Pen(System.Drawing.Color.Black, (float)(0.5)); }
public virtual void OnStateChanged(EditorState state) { switch (state) { case EditorState.Select: camera.gameObject.SetActive(true); break; case EditorState.Editor: // Use labyrinth camera camera.gameObject.SetActive(false); break; //default: // camera.gameObject.SetActive(false); // break; } }
private Tuple <bool, Exception> IOSaveFile(EditorState editorState) { try { using (StreamWriter writer = new StreamWriter(editorState.FilePath, false, editorState.FileEncoding)) { writer.Write(editorState.GetText()); writer.Flush(); } editorState.IsChanged = false; UpdateTabState(editorState); return(new Tuple <bool, Exception>(true, null)); } catch (IOException e) { return(new Tuple <bool, Exception>(false, e)); } }
public EditorToolsController() { _leftClick = false; _dragging = false; _state = EditorState.None; _clicks = 0; _moveTime = -1; _rotateTime = -1; _externalRotateTime = -1; _prefabs = new List <string>(PrefabRepository.Instance.PrefabNames); _selectedPrefab = 0; _lastLayerSelected = Category.Cat1; _lastSelectedZ = 0f; _specialRotationBigOperator = ( float )(Math.PI / 6f); _specialRotationSmallOperator = ( float )(Math.PI / 18f); _inputAggregator = Platform.Instance.Input; }
void ShowCreateWindow() { editScrollPos = EditorGUILayout.BeginScrollView(editScrollPos, false, false, GUILayout.MinWidth(540), GUILayout.MinHeight(550)); spellName = EditorGUILayout.TextField("Name: ", spellName, GUILayout.Width(300)); spellID = EditorGUILayout.IntField("ID: ", spellID, GUILayout.Width(300)); spellDesc = EditorGUILayout.TextField("Description: ", spellDesc, GUILayout.Width(450)); spellCastTime = EditorGUILayout.DoubleField("Cast Time: ", spellCastTime, GUILayout.Width(300)); spellCooldown = EditorGUILayout.DoubleField("Cooldown: ", spellCooldown, GUILayout.Width(300)); spellIcon = EditorGUILayout.ObjectField("Icon: ", spellIcon, typeof(Texture2D), true, GUILayout.Width(450)) as Texture2D; spellCastType = (SpellCastType)EditorGUILayout.EnumPopup("Cast Type: ", spellCastType, GUILayout.Width(450)); DisplayAuraList(targetAuras, addedTargetAuraScrollPos, targetAuraScrollPos, "TARGET"); DisplayAuraList(casterAuras, addedCasterAuraScrollPos, casterAuraScrollPos, "CASTER"); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Save", GUILayout.Width(150.0f))) { // Save this item to the database, either as a new item // or as an existing item. if (editorState == EditorState.Create) { SaveNewSpell(); } else { SaveExistingSpell(); } EditorUtility.SetDirty(spellDatabase); editorState = EditorState.Home; } if (GUILayout.Button("Cancel", GUILayout.Width(150.0f))) { EditorUtility.SetDirty(spellDatabase); editorState = EditorState.Home; } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndScrollView(); }
void ShowCreateWindow() { editScrollPos = EditorGUILayout.BeginScrollView(editScrollPos, false, false, GUILayout.MinWidth(600), GUILayout.MinHeight(550)); skillName = EditorGUILayout.TextField("Name: ", skillName, GUILayout.Width(300)); skillID = EditorGUILayout.IntField("ID: ", skillID, GUILayout.Width(300)); skillShortDesc = EditorGUILayout.TextField("Description: ", skillShortDesc, GUILayout.Width(450)); EditorGUILayout.LabelField("Long description:"); skillLongDesc = EditorGUILayout.TextArea(skillLongDesc, GUILayout.Width(450), GUILayout.MinHeight(100)); skillIcon = EditorGUILayout.ObjectField("Icon: ", skillIcon, typeof(Texture2D), true, GUILayout.Width(450)) as Texture2D; EditorGUILayout.Space(); DisplayPerks(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Save", GUILayout.Width(150.0f))) { // Save this skill to the database, either as a new skill // or as an existing skill. if (editorState == EditorState.Create) { SaveNewSkill(); } else { SaveExistingSkill(); } EditorUtility.SetDirty(skillDatabase); editorState = EditorState.Home; } if (GUILayout.Button("Cancel", GUILayout.Width(150.0f))) { EditorUtility.SetDirty(skillDatabase); editorState = EditorState.Home; } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndScrollView(); }
// Initialization Logic /// <summary> /// Called by anything attempting to open a project file editor window, usually by a command. This will show the window frame, creating it if /// has not already been created. /// </summary> public async Task OpenEditorAsync() { // We access _windowFrame inside the lock, so we must be on the UI thread in that case await _threadingService.SwitchToUIThread(); lock (_lock) { // If the editor is already open, just show it and return if (_currentState != EditorState.NoEditor) { // If we're initializing, _windowFrame might be null. In that case, when the initialization code // is done, it'll take care of showing the frame. _windowFrame?.Show(); return; } _currentState = EditorState.Initializing; } // Set up the buffer manager, which will create the temp file. Nothing else in OpenEditor requires the UI thread (tasks aquire it as needed) // so we don't need to resume on the same thread. _textBufferManager = _textBufferManagerFactory.CreateExport().Value; await _textBufferManager.InitializeBufferAsync().ConfigureAwait(false); // Open and show the editor frame. _windowFrame = await _shellHelper.OpenDocumentWithSpecificEditorAsync(_serviceProvider, _textBufferManager.FilePath, XmlFactoryGuid, Guid.Empty).ConfigureAwait(false); // Set up the save listener _textBufferStateListener = _textBufferListenerFactory.CreateExport().Value; await _textBufferStateListener.InitializeListenerAsync(_textBufferManager.FilePath).ConfigureAwait(false); // Set up the listener that will check for when the frame is closed. _frameEventsListener = _frameEventsListenerFactory.CreateExport().Value; await _frameEventsListener.InitializeEventsAsync(_windowFrame).ConfigureAwait(false); // Set up the project file watcher, so changes to the project file are detected and the buffer is updated. _projectFileModelWatcher = _projectFileWatcherFactory.CreateExport().Value; _projectFileModelWatcher.InitializeModelWatcher(); // Finally, move to the editor open state lock (_lock) { _currentState = EditorState.EditorOpen; } }
public Task EditorSelectionChangedNotificationAsync(Uri uri, EditorState editorState, List <Range> visibleRanges, int?totalLines, CodemarkType codemarkType, CancellationToken?cancellationToken = null) { if (!IsReady) { return(Task.CompletedTask); } try { _ = BrowserService.NotifyAsync(new HostDidChangeEditorSelectionNotificationType { Params = new HostDidChangeEditorSelectionNotification(uri, editorState.ToEditorSelectionsSafe(), visibleRanges, totalLines) }); } catch (Exception ex) { Log.Error(ex, $"{nameof(EditorSelectionChangedNotificationAsync)} Uri={uri}"); } return(Task.CompletedTask); }
void Start() { _editorState = GameObject.Find("UICanvas").GetComponent <EditorState> (); _materialsController = GameObject.Find("MaterialsCanvas").GetComponent <MaterialsController> (); int width = 2 * EDITOR_SPACE_HALF_WIDTH + 1; _editSpace = new int[width, width, width]; if (use_lerp_color) { GenNearestVoxelPointForEdgePointTable(); } else { GenNearestVoxelPointTable(); } }
public void OnEditorState(EditorState state) { switch (state) { case EditorState.Editor: break; case EditorState.Select: if (LabyrinthObject != null) { LabyrinthObject.gameObject.Destroy(); LabyrinthObject = null; } Labyrinth = null; break; } }
public void Push_State_Should_Be_Pass(List <Editor> sources, int expectedIndex, string content) { sources.ForEach(d => { var editorState = new EditorState <Editor>(d); manager.PushState(editorState); }); int lastIndex = manager.Index; var states = manager.States; var expectedText = manager.States[expectedIndex].Object.ToString(); var actualText = manager.States[lastIndex].Object.ToString(); bool equal = expectedText == actualText; Assert.IsTrue(lastIndex == expectedIndex); Assert.IsTrue(equal); }
public void HandleInput(InputHelper inputHelper) { Load.HandleInput(inputHelper); New.HandleInput(inputHelper); //selecting load/new if (Load.Pressed) { EditorState editorState = GameEnvironment.GameStateManager.GetGameState("editorState") as EditorState; editorState.LoadLevel("Content/1.txt"); GameEnvironment.GameStateManager.SwitchTo("editorState"); } if (New.Pressed) { EditorState editorState = GameEnvironment.GameStateManager.GetGameState("editorState") as EditorState; editorState.NewLevel(60, 60); GameEnvironment.GameStateManager.SwitchTo("editorState"); } }
void SetEditorStateVars(EditorState aEditorState) { switch (aEditorState.activeTab) { case EditTabEnum.PICKER: if (!this.pickerModePanel.activeInHierarchy) { this.pickerModePanel.SetActive(true); this.editModePanel.SetActive(false); this.optionsModePanel.SetActive(false); } if (aEditorState.selectedSchema == null && this.selectedItem != null) { ClearSelectedItem(); } SetPickerItems(aEditorState.isFront); break; case EditTabEnum.EDIT: if (!this.editModePanel.activeInHierarchy) { this.pickerModePanel.SetActive(false); this.editModePanel.SetActive(true); this.optionsModePanel.SetActive(false); } EditModePanelSetup(aEditorState); break; case EditTabEnum.OPTIONS: if (!this.optionsModePanel.activeInHierarchy) { this.pickerModePanel.SetActive(false); this.editModePanel.SetActive(false); this.optionsModePanel.SetActive(true); } SetTitleField(GM.boardManager.currentState.title); SetParPickerText(GM.boardManager.currentState.par); break; default: throw new ArgumentOutOfRangeException(); } }
private void HandleDrag() { if (HeldEntity.StretchableX) { Hold.X = (int)MathHelper.Min(Start.X, MiscHelper.GetMousePosition().X); Hold.Width = Math.Abs(Start.X - MiscHelper.GetMousePosition().X); if (EditorState.PixelPerfect()) { Hold.Width += 1; } else { Hold.Width += 8; } } else { Hold.X = Start.X; Hold.Width = 0; } if (HeldEntity.StretchableY) { Hold.Y = (int)MathHelper.Min(Start.Y, MiscHelper.GetMousePosition().Y); Hold.Height = Math.Abs(Start.Y - MiscHelper.GetMousePosition().Y); if (EditorState.PixelPerfect()) { Hold.Height += 1; } else { Hold.Height += 8; } } else { Hold.Y = Start.Y; Hold.Height = 0; } HeldEntity.SetArea(Hold); }
void ShowCreateWindow() { editScrollPos = EditorGUILayout.BeginScrollView(editScrollPos, false, false, GUILayout.MinWidth(540), GUILayout.MinHeight(550)); perkName = EditorGUILayout.TextField("Name: ", perkName, GUILayout.Width(300)); perkID = EditorGUILayout.IntField("ID: ", perkID, GUILayout.Width(300)); perkDesc = EditorGUILayout.TextField("Description: ", perkDesc, GUILayout.Width(450)); perkIcon = EditorGUILayout.ObjectField("Icon: ", perkIcon, typeof(Texture2D), true, GUILayout.Width(450)) as Texture2D; // Perk conditions editor DisplayPerkAuras(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Save", GUILayout.Width(150.0f))) { // Save this perk to the database, either as a new perk // or as an existing perk. if (editorState == EditorState.Create) { SaveNewPerk(); } else { SaveExistingPerk(); } EditorUtility.SetDirty(perkDatabase); AssetDatabase.SaveAssets(); editorState = EditorState.Home; } if (GUILayout.Button("Cancel", GUILayout.Width(150.0f))) { EditorUtility.SetDirty(perkDatabase); AssetDatabase.SaveAssets(); editorState = EditorState.Home; } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndScrollView(); }
private static void HandleNodeActionStart(EditorInputInfo inputInfo) { CombinMeshEditor cme = inputInfo.editorState.editor as CombinMeshEditor; if (cme.focusedNode == null || inputInfo.inputEvent.button != 0) { return; } EditorState state = inputInfo.editorState; Vector2 pos = inputInfo.inputEvent.mousePosition; state.action = EditorState.Action.None; int pivotIndex = -1; for (int i = 0; i < 4; ++i) { if (cme.currentPivotRect[i].Contains(pos)) { pivotIndex = i; state.action = EditorState.Action.Scale; break; } } if (pivotIndex == -1) { if (cme.focusedNode.drawRect.Contains(pos)) { state.action = EditorState.Action.Move; } } if (state.action != EditorState.Action.None) { state.pivot = (EditorState.Pivot)(pivotIndex + 1); state.dragMouseStart = pos; state.dragOffset = Vector2.zero; } }
void CreatePickerItems(EditorState aEditorState) { this.pickerItemList = new List <GUIPickerItem>(); foreach (EntitySchema entitySchema in aEditorState.frontContentList) { GameObject pickerItemGameObject = Instantiate(this.pickerItemMaster, this.pickerScrollRectContent.transform); GUIPickerItem pickerItem = pickerItemGameObject.GetComponent <GUIPickerItem>(); pickerItem.Init(entitySchema, OnPickerItemClick); this.pickerItemList.Add(pickerItem); } foreach (EntitySchema entitySchema in aEditorState.backContentList) { GameObject pickerItemGameObject = Instantiate(this.pickerItemMaster, this.pickerScrollRectContent.transform); GUIPickerItem pickerItem = pickerItemGameObject.GetComponent <GUIPickerItem>(); pickerItem.Init(entitySchema, OnPickerItemClick); this.pickerItemList.Add(pickerItem); } // SetPickerItems(aEditorState.isFront); }
void OnUpdateEditorState(EditorState aNewEditorState) { switch (GM.instance.currentState.gameMode) { case GameModeEnum.PLAYING: throw new Exception("received OnUpdateEditorState but GameState.gameMode = PLAYING"); case GameModeEnum.EDITING: this.isFront = aNewEditorState.isFront; this.selectedSchema = aNewEditorState.selectedSchema; this.cursorMode = EditModeChooseMode(aNewEditorState); break; case GameModeEnum.PLAYTESTING: throw new Exception("received OnUpdateEditorState updated but GameState.gameMode = PLAYING"); default: throw new ArgumentOutOfRangeException(); } }
private void buttonResetDefaults_Click(object sender, EventArgs e) { if (MessageBox.Show(this, "This will replace your settings with the defaults.", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { EditorState.SavedPrefs.CopyFrom(EditorState.DefaultPrefs); EditorState.Prefs.CopyFrom(EditorState.SavedPrefs); if (EditorState.ShouldDisplayMessage(InformationLevel.Normal)) { MessageBox.Show(this, "Default settings have been restored.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
public void StartCode() { //Grid grid = new Grid(21, 9, 1f); testBlockPrivate = TestBlockPublic; blockList = new List <GameObject>(); debugList = new List <GameObject>(); currentState = EditorState.Painting; Mouse.GetComponent <MouseModeManager>().setMode(currentState); currentMaterial = MAT_TYPE.WOOD; Material.GetComponent <MaterialLabelManager>().setMaterial(currentMaterial); remainingComponents = 50; Components.GetComponent <CostLabelManager>().setNumber(remainingComponents); }
private void OnMenuSelect(ContextMenuView c, ContextMenuEvent e) { switch (e.SelectedSlice.Type) { case MenuSlice.Cancel: { // Do nothing break; } case MenuSlice.Delete: { // Deleting a node. Debug.Assert(SelectedNode != null); DeleteNode(SelectedNode); SelectedNode = null; UpdateView(); break; } case MenuSlice.Properties: { Debug.Assert(SelectedNode != null); Text = "Visual Pipes <Command>"; s = EditorState.EditProperties; NodePropertiesForm props = new NodePropertiesForm(SelectedNode.Model); props.FormClosed += PropertiesClosed; props.ShowDialog(this); break; } case MenuSlice.Start: { Debug.Assert(SelectedNode != null); runner.Start(SelectedNode.Model, nodems); break; } } }
void DisplayListArea() { EditorGUILayout.BeginVertical(GUILayout.Width(250)); EditorGUILayout.Space(); _scrollPosList = EditorGUILayout.BeginScrollView(_scrollPosList, "box", GUILayout.ExpandHeight(true)); for (int i = 0; i < consumableDb.Database.Count; i++) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("-", GUILayout.Width(25))) { consumableDb.Database.RemoveAt(i); EditorUtility.SetDirty(consumableDb); state = EditorState.BLANK; return; } if (GUILayout.Button(consumableDb.Database[i].Name, "box", GUILayout.ExpandWidth(true))) { selected = i; state = EditorState.EDIT; } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); EditorGUILayout.LabelField("Consumables " + consumableDb.Database.Count, GUILayout.Width(100)); if (GUILayout.Button("New Consumable")) { state = EditorState.ADD; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); }
public MainViewModel(MusicLoader musicLoader) { CurrentState = new Saved(this); _pressedKeys = new List <Key>(); _keyHandlerChain = new CommandKeyHandler(); RegularKeyHandler keyHandlerChain2 = new RegularKeyHandler(); RegularKeyHandler keyHandlerChain3 = new RegularKeyHandler(); _keyHandlerChain.Next = keyHandlerChain2; keyHandlerChain2.Next = keyHandlerChain3; _commands = new Dictionary <string, IEditorCommand>(); IEditorCommand saveCommand = new OpenFileCommand(); _commands.Add(saveCommand.Pattern, saveCommand); _musicLoader = musicLoader; FileName = @"Files/Alle-eendjes-zwemmen-in-het-water.mid"; }
private void Serialize() { var keyValues = new Dictionary <string, string>(); foreach (var window in this.Windows) { window.Save(keyValues); } var openWindows = this.OpenWindows.Where(kv => kv.Value).Select(kv => kv.Key).ToList(); var state = new EditorState ( openWindows, this.SceneManager.CurrentScene, this.FrameService.CameraComponent.Camera.Position, this.FrameService.CameraComponent.Camera.Forward, keyValues ); this.State.Save(state); }
protected MessageEditor( SetupConfig config, MessageDescriptor descriptor, ProtoMessageType messageType, MessageInfo defaultMessage, FileInfo protoFile, EnumInfoHelper enumInfoHelper) { this.m_Config = config; this.m_DefaultMessage = defaultMessage; this.m_MessageType = messageType; this.m_Descriptor = descriptor; this.m_EnumInfoHelper = enumInfoHelper; this.m_EditorStatePrefs = new EditorStatePrefs <EditorState>(messageType.ToString(), new EditorState(m_Config.GetUseAdvanced(m_MessageType), defaultMessage)); this.m_EditorState = m_EditorStatePrefs.Get(); this.m_ProtoFile = protoFile; this.m_SavedEditorState = new EditorState(m_Config.GetUseAdvanced(m_MessageType), new MessageInfo(m_Descriptor)); CheckValidationErrors(); }
SystemManagerState GetStateForEnum(State state) { SystemManagerState newState = null; switch (state) { case State.Editor: newState = new EditorState(); break; case State.Playing: Debug.LogError("Attempting to change state to a default Playing State. This is not allowed."); return(null); // call from Play function in this editor instead case State.Menu: return(menuState); case State.Loading: return(loadingState); default: break; } PopulatePersistentSystemsForNewState(state, newState); return(newState); }
private void buttonExportXML_Click(object sender, EventArgs e) { var result = xmlSaveFileDialog.ShowDialog(this); if (result == DialogResult.OK) { var tempSettings = new EditorSettingsSaved(); tempSettings.CopyFrom(EditorState.SavedPrefs); tempSettings.CopyFrom(EditorState.Prefs); tempSettings.RecentFiles.Clear(); // don't save recent files tempSettings.SaveToFile(xmlSaveFileDialog.FileName); if (EditorState.ShouldDisplayMessage(InformationLevel.Normal)) { MessageBox.Show(this, "Settings have been successfully exported.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private Tuple <bool, Exception> IOOpenFile(EditorState editorState, string filePath) { try { using (StreamReader reader = new StreamReader(filePath)) { string contents = reader.ReadToEnd(); editorState.FileEncoding = reader.CurrentEncoding; editorState.SetText(contents); } } catch (IOException e) { return(new Tuple <bool, Exception>(false, e)); } editorState.Name = Path.GetFileName(filePath); editorState.FilePath = filePath; editorState.IsChanged = false; UpdateTabState(editorState); return(new Tuple <bool, Exception>(true, null)); }
public Editor() { Logger.Instance.log("Editor creation started."); Instance = this; state = EditorState.idle; SelectedItems = new List<Item>(); initialpos = new List<Vector2>(); initialrot = new List<float>(); initialscale = new List<Vector2>(); Version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); Logger.Instance.log("Loading Resources."); Stream resStream; resStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("GLEED2D.Resources.cursors.dragcopy.cur"); cursorDup = new Forms.Cursor(resStream); resStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("GLEED2D.Resources.cursors.rotate.cur"); cursorRot = new Forms.Cursor(resStream); resStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("GLEED2D.Resources.cursors.scale.cur"); cursorScale = new Forms.Cursor(resStream); resStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("GLEED2D.Resources.circle.png"); dummytexture = Texture2D.FromFile(Game1.Instance.GraphicsDevice, resStream); Logger.Instance.log("Resources loaded."); Logger.Instance.log("Loading Settings."); Constants.Instance.import("settings.xml"); MainForm.Instance.ViewGrid.Checked = Constants.Instance.ShowGrid; MainForm.Instance.ViewSnapToGrid.Checked = Constants.Instance.SnapToGrid; MainForm.Instance.ViewWorldOrigin.Checked = Constants.Instance.ShowWorldOrigin; Logger.Instance.log("Settings loaded."); Logger.Instance.log("Creating new level."); MainForm.Instance.newLevel(); Logger.Instance.log("New level created."); Logger.Instance.log("Editor creation ended."); }
void OnGUI() { if (currentState == EditorState.Creation) { GUI.BeginGroup (new Rect (Screen.width / 2 - 100, Screen.height / 2 - 100, 200, 200)); GUI.Box (new Rect (0, 0, 200, 200), "Options"); GUI.Label (new Rect (10, 10, 180, 20), "Width"); width = GUI.TextField (new Rect (10, 40, 180, 20), width); GUI.Label (new Rect (10, 60, 180, 20), "Height"); height = GUI.TextField (new Rect (10, 90, 180, 20), height); GUI.Label (new Rect (10, 110, 180, 20), "Export To"); fileName = GUI.TextField (new Rect(10, 130, 180, 20), fileName); float testW = 0; float testH = 0; if (float.TryParse (width, out testW) && float.TryParse (height, out testH) && fileName != "") { if (GUI.Button (new Rect (40, 160, 120, 30), "Create Map")) { canvas = new GameObject ("Canvas"); MeshFilter newFilter = canvas.AddComponent<MeshFilter> (); newFilter.mesh = new Mesh (); float widthNum = float.Parse (width) / 2; float heightNum = float.Parse (height) / 2; newFilter.mesh.vertices = new Vector3[4] { new Vector3 (-widthNum, -heightNum, 0), new Vector3 (widthNum, -heightNum, 0), new Vector3 (widthNum, heightNum, 0), new Vector3 (-widthNum, heightNum, 0) }; newFilter.mesh.triangles = new int[6]{0,2,1,0,3,2}; newFilter.mesh.RecalculateNormals (); MeshRenderer newRenderer = canvas.AddComponent<MeshRenderer> (); newRenderer.material.shader = Shader.Find ("Sprites/Default"); newRenderer.material.color = Color.grey; canvas.AddComponent<MeshCollider> (); CanvasClick newClick = new CanvasClick(); newClick.parentCC = this; currentClick = newClick; CameraMove cameraMove = Camera.main.GetComponent<CameraMove>(); cameraMove.xBound = widthNum; cameraMove.yBound = heightNum; currentState = EditorState.Editing; } } GUI.EndGroup (); } else if (currentState == EditorState.Editing) { GUI.BeginGroup (new Rect (0, 0, 200, 150)); GUI.Box (new Rect (0, 0, 200, 150), "Options"); GUI.Label (new Rect (20, 30, 160, 20), "Node count: " + nodes.Count.ToString ()); GUI.Label (new Rect (20, 50, 160, 20), "Link count: " + links.Count.ToString ()); if (nodes.Count == 0) { if (GUI.Button (new Rect (40, 70, 120, 30), "Delete Canvas")) { GameObject.Destroy (canvas); } } else { if (GUI.Button (new Rect (40, 110, 120, 30), "Convert Countries")) { if(ConvertCountries ()) { foreach(CNode node in nodes) { Destroy (node.gameObject); } Destroy(canvas); currentClick = new CountryClick(); currentState = EditorState.Finalising; } } } GUI.EndGroup (); } else if (currentState == EditorState.Finalising) { int groupWidth = 100; GUI.BeginGroup(new Rect(0, 0, groupWidth*factions.Count + 50, 180)); for(int factionCount = 0; factionCount < factions.Count; factionCount++) { Faction faction = factions[factionCount]; GUI.Box( new Rect(groupWidth*factionCount, 0, groupWidth, 180), faction.factionName); if(factionCount != 0) { faction.factionName = GUI.TextField(new Rect(groupWidth*factionCount + 10, 20, groupWidth-20, 30), faction.factionName); } else { GUI.Label(new Rect(groupWidth*factionCount + 10, 20, groupWidth-20, 30), faction.factionName); } GUI.Label (new Rect(groupWidth*factionCount + 10, 60, groupWidth-20, 20), "Countries: " + faction.countries.Count.ToString()); faction.colorString = GUI.TextField(new Rect(groupWidth*factionCount + 10, 80, groupWidth-20, 20), faction.colorString); if(faction.colorString.Length == 6) { bool canParse = true; for(int i = 0; i < faction.colorString.Length; i += 2) { byte outByte; if(!byte.TryParse(faction.colorString.Substring(0,2), System.Globalization.NumberStyles.HexNumber, null, out outByte)) { canParse = false; } } if(canParse) { if(GUI.Button (new Rect(groupWidth*factionCount + 10, 110, groupWidth-20, 20), "Colour")) { faction.factionColor = MeshMaker.HexToColor(faction.colorString); faction.ColorCountries(); } } } if(factionCount != 0) { if(GUI.Button (new Rect(groupWidth*factionCount + 10, 140, groupWidth-20, 20), "Delete")) { factions.Remove (faction); while(faction.countries.Count != 0) { factions[0].AddCountry(faction.countries[0]); } factionCount--; } } } GUI.Box (new Rect(groupWidth*factions.Count, 50, 50, 50), ""); if(GUI.Button (new Rect(groupWidth*factions.Count, 50, 50, 50), "+")) { factions.Add (new Faction()); } GUI.EndGroup(); GUI.BeginGroup (new Rect(0, Screen.height - 90, 100, 90)); GUI.Box (new Rect(0, 0, 100, 90), "Final Conversion"); if(GUI.Button(new Rect(10, 30, 90, 30), "Convert")) { warningLabel = CanExportMap(); if(warningLabel == "") { ExportMap(); } } GUI.Label (new Rect(10, 70, 90, 20), warningLabel); GUI.EndGroup(); } }
void Update() { int index = 0; LSObject o = objects[currentObject]; objectPrevew.GetComponent<LineRenderer>().SetVertexCount(o.events.Count); foreach (LSObject.Event e in o.events) { objectPrevew.GetComponent<LineRenderer>().SetPosition(index, new Vector3(e.position.x, e.position.y, -1)); if (!objectPrevew.transform.FindChild(index.ToString())) { previewObjects.Insert(index, Instantiate(previewObjectPrefab)); previewObjects[index].transform.SetParent(objectPrevew.transform); previewObjects[index].name = index.ToString(); int i = index; previewObjects[index].transform.FindChild("name").GetComponent<Text>().text = i.ToString(); previewObjects[index].GetComponent<SelectEvent>().editor = this.gameObject; previewObjects[index].GetComponent<SelectEvent>().selection = i; } else { previewObjects[index].transform.position = e.position; if (e.scale.x > 0 && e.scale.y > 0) previewObjects[index].GetComponent<RectTransform>().sizeDelta = e.scale; else previewObjects[index].GetComponent<RectTransform>().sizeDelta = new Vector2(0.25f, 0.25f); previewObjects[index].GetComponent<RectTransform>().rotation = Quaternion.Euler(0, 0, e.rotation); } index++; } gridSizeX = Mathf.RoundToInt(Camera.main.orthographicSize * 3.75f); gridSizeY = Mathf.RoundToInt(Camera.main.orthographicSize * 2.25f); startX = Mathf.RoundToInt(Camera.main.transform.position.x) - gridSizeX / 2f; startY = Mathf.RoundToInt(Camera.main.transform.position.y) - gridSizeY / 2f; float temp = 1 / smallStep; mousePos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10)); mousePos = new Vector3((Mathf.RoundToInt(mousePos.x * temp))/temp, (Mathf.RoundToInt(mousePos.y * temp))/temp, mousePos.z); snapVisual.transform.position = mousePos; if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) { clickLeft = Input.GetMouseButtonDown(0); clickBegin = true; clickPos = new Vector2(mousePos.x, mousePos.y); } if (clickBegin) { clickMove = clickPos - new Vector2(mousePos.x, mousePos.y); clickMove = new Vector3((Mathf.RoundToInt(clickMove.x * temp)) / temp, (Mathf.RoundToInt(clickMove.y * temp)) / temp); } if (clickBegin && Input.GetMouseButton(0) || clickBegin && Input.GetMouseButton(1)) { if (clickMove != Vector2.zero) { if (clickLeft) { state = EditorState.position; objects[currentObject].events[currentEvent].position = clickPos - clickMove; } else { state = EditorState.scale; objects[currentObject].events[currentEvent].scale = new Vector2(Mathf.Abs(-clickMove.x), Mathf.Abs(-clickMove.y)) * 2; } } } if (clickBegin && Input.GetMouseButtonUp(0) || clickBegin && Input.GetMouseButtonUp(1)) { if (clickMove == Vector2.zero) { if (clickLeft) { state = EditorState.rotation; objects[currentObject].events[currentEvent].rotation += 45; if (objects[currentObject].events[currentEvent].rotation >= 360) objects[currentObject].events[currentEvent].rotation = 0; clicks.Add(new click(new Vector2(mousePos.x, mousePos.y))); } else { state = EditorState.color; objects[currentObject].events[currentEvent].color += 1; clicks.Add(new click(new Vector2(mousePos.x, mousePos.y))); } } else { if (clickLeft) { state = EditorState.position; objects[currentObject].events[currentEvent].position = clickPos - clickMove; drags.Add(new drag(clickPos, clickPos - clickMove, -clickMove)); } else { state = EditorState.scale; objects[currentObject].events[currentEvent].scale = new Vector2(Mathf.Abs(-clickMove.x), Mathf.Abs(-clickMove.y)) * 2; drags.Add(new drag(clickPos, clickPos - clickMove, -clickMove)); } } } }
void EnemiesButton() { if (currentEditorState != EditorState.ENEMIES) { if (GUILayout.Button("Enemies")) currentEditorState = EditorState.ENEMIES; } }
public Simulator(CommanderScene scene, LevelDescriptor descriptor) { Scene = scene; Scene.Particles.Add( new List<string>() { @"projectileMissileDeplacement", @"projectileBaseExplosion", @"etoile", @"etoileBleue", @"planeteGazeuse", @"etoilesScintillantes", @"projectileMissileExplosion", @"projectileLaserSimple", @"projectileLaserMultiple", @"selectionCorpsCeleste", @"traineeMissile", @"etincelleLaser", @"toucherTerre", @"anneauTerreMeurt", @"anneauTerreMeurt2", @"bouleTerreMeurt", @"missileAlien", @"implosionAlien", @"explosionEnnemi", @"mineral1", @"mineral2", @"mineral3", @"mineralPointsVie", @"mineralPris", @"etincelleMissile", @"etincelleLaserSimple", @"etincelleSlowMotion", @"etincelleSlowMotionTouche", @"etoileFilante", @"trouRose", @"boosterTurret", @"gunnerTurret", @"nanobots", @"nanobots2", @"railgun", @"railgunExplosion", @"pulseEffect", @"shieldEffect", @"spaceshipTrail", @"spaceshipTrail2", @"darkSideEffect", @"starExplosion", @"mothershipMissile", @"nextWave", @"mothershipAbduction" }, true); Scene.Particles.SetMaxInstances(@"toucherTerre", 3); TurretsFactory = new TurretsFactory(this); PowerUpsFactory = new PowerUpsFactory(this); EnemiesFactory = new EnemiesFactory(this); MineralsFactory = new MineralsFactory(this); BulletsFactory = new BulletsFactory(this); TurretsFactory.Initialize(); PowerUpsFactory.Initialize(); EnemiesFactory.Initialize(); MineralsFactory.Initialize(); BulletsFactory.Initialize(); Level = new Level(this, descriptor); TweakingController = new TweakingController(this); CollisionsController = new CollisionsController(this); BulletsController = new BulletsController(this); EnemiesController = new EnemiesController(this); SimPlayersController = new SimPlayersController(this); TurretsController = new TurretsController(this); PlanetarySystemController = new PlanetarySystemController(this); SpaceshipsController = new SpaceshipsController(this); MessagesController = new MessagesController(this); GUIController = new GUIController(this); PowerUpsController = new PowerUpsController(this); LevelsController = new LevelsController(this); EditorController = new EditorController(this); EditorGUIController = new EditorGUIController(this); PanelsController = new PanelsController(this); AudioController = new AudioController(this); WorldMode = false; DemoMode = false; CutsceneMode = false; EditorMode = false; CanSelectCelestialBodies = true; EditorState = EditorState.Editing; DebugMode = Preferences.Debug; PausedGameChoice = PausedGameChoice.None; NewGameChoice = NewGameChoice.None; CollisionsController.ObjectHit += new PhysicalObjectPhysicalObjectHandler(EnemiesController.DoObjectHit); CollisionsController.ObjectHit += new PhysicalObjectPhysicalObjectHandler(BulletsController.DoObjectHit); CollisionsController.ObjectOutOfBounds += new PhysicalObjectHandler(BulletsController.DoObjectOutOfBounds); SimPlayersController.BuyTurretAsked += new TurretSimPlayerHandler(TurretsController.DoBuyTurret); EnemiesController.WaveEnded += new NoneHandler(LevelsController.DoWaveEnded); EnemiesController.ObjectDestroyed += new PhysicalObjectHandler(SimPlayersController.DoObjectDestroyed); CollisionsController.InTurretRange += new TurretPhysicalObjectHandler(TurretsController.DoInRangeTurret); TurretsController.ObjectCreated += new PhysicalObjectHandler(BulletsController.DoObjectCreated); BulletsController.ObjectDestroyed += new PhysicalObjectHandler(CollisionsController.DoObjectDestroyed); EnemiesController.WaveStarted += new NoneHandler(GUIController.DoWaveStarted); SimPlayersController.SellTurretAsked += new TurretSimPlayerHandler(TurretsController.DoSellTurret); TurretsController.TurretSold += new TurretSimPlayerHandler(SimPlayersController.DoTurretSold); TurretsController.TurretBought += new TurretSimPlayerHandler(SimPlayersController.DoTurretBought); EnemiesController.EnemyReachedEndOfPath += new EnemyCelestialBodyHandler(PlanetarySystemController.DoEnemyReachedEnd); TurretsController.TurretUpgraded += new TurretSimPlayerHandler(SimPlayersController.DoTurretUpgraded); TurretsController.TurretUpgraded += new TurretSimPlayerHandler(GUIController.DoTurretUpgraded); SimPlayersController.UpgradeTurretAsked += new TurretSimPlayerHandler(TurretsController.DoUpgradeTurret); PlanetarySystemController.ObjectDestroyed += new PhysicalObjectHandler(TurretsController.DoObjectDestroyed); PlanetarySystemController.ObjectDestroyed += new PhysicalObjectHandler(SimPlayersController.DoObjectDestroyed); SimPlayersController.NextWaveAsked += new NoneHandler(EnemiesController.DoNextWaveAsked); SpaceshipsController.ObjectCreated += new PhysicalObjectHandler(BulletsController.DoObjectCreated); SpaceshipsController.ObjectCreated += new PhysicalObjectHandler(SimPlayersController.DoObjectCreated); PlanetarySystemController.ObjectDestroyed += new PhysicalObjectHandler(CollisionsController.DoObjectDestroyed); SpaceshipsController.ObjectCreated += new PhysicalObjectHandler(CollisionsController.DoObjectCreated); EnemiesController.ObjectCreated += new PhysicalObjectHandler(CollisionsController.DoObjectCreated); PlanetarySystemController.ObjectHit += new PhysicalObjectHandler(LevelsController.DoObjectHit); PlanetarySystemController.ObjectDestroyed += new PhysicalObjectHandler(LevelsController.DoObjectDestroyed); EnemiesController.EnemyReachedEndOfPath += new EnemyCelestialBodyHandler(this.DoEnemyReachedEndOfPath); PlanetarySystemController.ObjectDestroyed += new PhysicalObjectHandler(this.DoCelestialBodyDestroyed); SimPlayersController.CommonStashChanged += new CommonStashHandler(GUIController.DoCommonStashChanged); LevelsController.NewGameState += new NewGameStateHandler(GUIController.DoGameStateChanged); SimPlayersController.PlayerSelectionChanged += new SimPlayerHandler(GUIController.DoPlayerSelectionChanged); SimPlayersController.PlayerSelectionChanged += new SimPlayerHandler(this.DoPlayerSelectionChanged); TurretsController.TurretReactivated += new TurretHandler(SimPlayersController.DoTurretReactivated); SimPlayersController.PlayerMoved += new SimPlayerHandler(GUIController.DoPlayerMoved); LevelsController.NewGameState += new NewGameStateHandler(this.DoNewGameState); //must come after GUIController.DoGameStateChanged LevelsController.CommonStashChanged += new CommonStashHandler(GUIController.DoCommonStashChanged); SimPlayersController.TurretToPlaceSelected += new TurretSimPlayerHandler(GUIController.DoTurretToPlaceSelected); SimPlayersController.TurretToPlaceDeselected += new TurretSimPlayerHandler(GUIController.DoTurretToPlaceDeselected); SimPlayersController.BuyTurretAsked += new TurretSimPlayerHandler(GUIController.DoTurretBought); SimPlayersController.SellTurretAsked += new TurretSimPlayerHandler(GUIController.DoTurretSold); SimPlayersController.ActivatePowerUpAsked += new PowerUpTypeSimPlayerHandler(PowerUpsController.DoActivatePowerUpAsked); PowerUpsController.PowerUpStarted += new PowerUpSimPlayerHandler(SpaceshipsController.DoPowerUpStarted); PowerUpsController.PowerUpStopped += new PowerUpSimPlayerHandler(SpaceshipsController.DoPowerUpStopped); PowerUpsController.PowerUpStarted += new PowerUpSimPlayerHandler(GUIController.DoPowerUpStarted); PowerUpsController.PowerUpStopped += new PowerUpSimPlayerHandler(GUIController.DoPowerUpStopped); PowerUpsController.PowerUpStarted += new PowerUpSimPlayerHandler(SimPlayersController.DoPowerUpStarted); PowerUpsController.PowerUpStopped += new PowerUpSimPlayerHandler(SimPlayersController.DoPowerUpStopped); PowerUpsController.PowerUpStarted += new PowerUpSimPlayerHandler(CollisionsController.DoPowerUpStarted); PowerUpsController.PowerUpStarted += new PowerUpSimPlayerHandler(BulletsController.DoPowerUpStarted); PowerUpsController.PowerUpStopped += new PowerUpSimPlayerHandler(BulletsController.DoPowerUpStopped); PowerUpsController.PowerUpStarted += new PowerUpSimPlayerHandler(PlanetarySystemController.DoPowerUpStarted); PowerUpsController.PowerUpStopped += new PowerUpSimPlayerHandler(PlanetarySystemController.DoPowerUpStopped); PowerUpsController.PowerUpStarted += new PowerUpSimPlayerHandler(LevelsController.DoPowerUpStarted); CollisionsController.TurretBoosted += new TurretTurretHandler(TurretsController.DoTurretBoosted); SimPlayersController.PlayerMoved += new SimPlayerHandler(PowerUpsController.DoPlayerMoved); LevelsController.NewGameState += new NewGameStateHandler(PowerUpsController.DoNewGameState); TurretsController.ObjectCreated += new PhysicalObjectHandler(SimPlayersController.DoObjectCreated); CollisionsController.BulletDeflected += new EnemyBulletHandler(BulletsController.DoBulletDeflected); BulletsController.ObjectDestroyed += new PhysicalObjectHandler(TurretsController.DoObjectDestroyed); SimPlayersController.DesactivatePowerUpAsked += new PowerUpTypeSimPlayerHandler(PowerUpsController.DoDesactivatePowerUpAsked); SimPlayersController.PlayerConnected += new SimPlayerHandler(GUIController.DoPlayerConnected); SimPlayersController.PlayerDisconnected += new SimPlayerHandler(GUIController.DoPlayerDisconnected); SimPlayersController.PlayerConnected += new SimPlayerHandler(PowerUpsController.DoPlayerConnected); SimPlayersController.PlayerDisconnected += new SimPlayerHandler(PowerUpsController.DoPlayerDisconnected); SimPlayersController.PlayerConnected += new SimPlayerHandler(PanelsController.DoPlayerConnected); SimPlayersController.PlayerDisconnected += new SimPlayerHandler(PanelsController.DoPlayerDisconnected); SimPlayersController.ShowAdvancedViewAsked += new SimPlayerHandler(GUIController.DoShowAdvancedViewAsked); SimPlayersController.HideAdvancedViewAsked += new SimPlayerHandler(GUIController.DoHideAdvancedViewAsked); CollisionsController.ObjectHit += new PhysicalObjectPhysicalObjectHandler(SimPlayersController.DoObjectHit); SimPlayersController.PlayerConnected += new SimPlayerHandler(EditorController.DoPlayerConnected); SimPlayersController.PlayerDisconnected += new SimPlayerHandler(EditorController.DoPlayerDisconnected); EditorController.PlayerConnected += new EditorPlayerHandler(EditorGUIController.DoPlayerConnected); EditorController.PlayerDisconnected += new EditorPlayerHandler(EditorGUIController.DoPlayerDisconnected); SimPlayersController.PlayerMoved += new SimPlayerHandler(EditorController.DoPlayerMoved); EditorController.PlayerChanged += new EditorPlayerHandler(EditorGUIController.DoPlayerChanged); EditorController.EditorCommandExecuted += new EditorCommandHandler(PlanetarySystemController.DoEditorCommandExecuted); //must be executed before sync of gui EditorController.EditorCommandExecuted += new EditorCommandHandler(EditorGUIController.DoEditorCommandExecuted); EditorController.EditorCommandExecuted += new EditorCommandHandler(PowerUpsController.DoEditorCommandExecuted); //must be done before the Players Controller EditorController.EditorCommandExecuted += new EditorCommandHandler(SimPlayersController.DoEditorCommandExecuted); //must be done before the GUI EditorController.EditorCommandExecuted += new EditorCommandHandler(LevelsController.DoEditorCommandExecuted); // must be donne before the GUI EditorController.EditorCommandExecuted += new EditorCommandHandler(GUIController.DoEditorCommandExecuted); SimPlayersController.ObjectCreated += new PhysicalObjectHandler(BulletsController.DoObjectCreated); LevelsController.NewGameState += new NewGameStateHandler(PanelsController.DoGameStateChanged); PanelsController.PanelOpened += new NoneHandler(GUIController.DoPanelOpened); PanelsController.PanelClosed += new NoneHandler(GUIController.DoPanelClosed); EnemiesController.ObjectDestroyed += new PhysicalObjectHandler(GUIController.DoObjectDestroyed); EnemiesController.NextWaveCompositionChanged += new NextWaveHandler(GUIController.DoNextWaveCompositionChanged); LevelsController.NewGameState += new NewGameStateHandler(SimPlayersController.DoNewGameState); CollisionsController.PlayersCollided += new SimPlayerSimPlayerHandler(SimPlayersController.DoPlayersCollided); CollisionsController.PlayersCollided += new SimPlayerSimPlayerHandler(AudioController.DoPlayersCollided); CollisionsController.StartingPathCollision += new BulletCelestialBodyHandler(BulletsController.DoStartingPathCollision); CollisionsController.StartingPathCollision += new BulletCelestialBodyHandler(GUIController.DoStartingPathCollision); CollisionsController.StartingPathCollision += new BulletCelestialBodyHandler(AudioController.DoStartingPathCollision); CollisionsController.ShieldCollided += new CollidableBulletHandler(SpaceshipsController.DoShieldCollided); CollisionsController.ShieldCollided += new CollidableBulletHandler(BulletsController.DoShieldCollided); BulletsController.ObjectDestroyed += new PhysicalObjectHandler(AudioController.DoObjectDestroyed); EnemiesController.WaveStarted += new NoneHandler(AudioController.DoWaveStarted); PowerUpsController.PowerUpStarted += new PowerUpSimPlayerHandler(AudioController.DoPowerUpStarted); PowerUpsController.PowerUpStopped += new PowerUpSimPlayerHandler(AudioController.DoPowerUpStopped); TurretsController.TurretBought += new TurretSimPlayerHandler(AudioController.DoTurretBought); TurretsController.TurretSold += new TurretSimPlayerHandler(AudioController.DoTurretSold); TurretsController.TurretFired += new TurretHandler(AudioController.DoTurretFired); TurretsController.TurretReactivated += new TurretHandler(AudioController.DoTurretReactivated); PowerUpsController.PowerUpInputCanceled += new PowerUpSimPlayerHandler(AudioController.DoPowerUpInputCanceled); PowerUpsController.PowerUpInputPressed += new PowerUpSimPlayerHandler(AudioController.DoPowerUpInputPressed); PowerUpsController.PowerUpInputReleased += new PowerUpSimPlayerHandler(AudioController.DoPowerUpInputReleased); EnemiesController.ObjectHit += new PhysicalObjectHandler(AudioController.DoObjectHit); EnemiesController.ObjectDestroyed += new PhysicalObjectHandler(AudioController.DoObjectDestroyed); PlanetarySystemController.ObjectHit += new PhysicalObjectHandler(AudioController.DoObjectHit); PlanetarySystemController.ObjectDestroyed += new PhysicalObjectHandler(AudioController.DoObjectDestroyed); SimPlayersController.PlayerBounced += new SimPlayerHandler(AudioController.DoPlayerBounced); TurretsController.TurretWandered += new TurretHandler(AudioController.DoTurretWandered); TurretsController.TurretUpgraded += new TurretSimPlayerHandler(AudioController.DoTurretUpgraded); BulletsController.BulletDeflected += new BulletHandler(AudioController.DoBulletDeflected); EnemiesController.WaveNearToStart += new NoneHandler(AudioController.DoWaveNearToStart); SimPlayersController.PlayerConnected += new SimPlayerHandler(AudioController.DoPlayerConnected); SimPlayersController.PlayerDisconnected += new SimPlayerHandler(AudioController.DoPlayerDisconnected); EnemiesController.WaveEnded += new NoneHandler(AudioController.DoWaveEnded); SimPlayersController.PlayerFired += new SimPlayerHandler(AudioController.DoPlayerFired); SimPlayersController.PlayerSelectionChanged += new SimPlayerHandler(AudioController.DoPlayerSelectionChanged); SimPlayersController.PlayerActionRefused += new SimPlayerHandler(AudioController.DoPlayerActionRefused); Main.CheatsController.CheatActivated += new StringHandler(DoCheatActivated); Main.Options.ShowHelpBarChanged += new BooleanHandler(DoShowHelpBarChanged); }
/// <summary> Called whenever the user clicks on one of the toolbar buttons on the toolbar returned by ActivateEditor /// </summary> /// <param name="pMapView">the current map view /// </param> /// <param name="lButtonCommandId">lButtonCommandId zero-based index of the button that was clicked /// </param> /// <remarks> /// If a toolbar "object" is used rather than implemented on "this", then prefer the OnButtonPressed event /// of the IFvToolbarEvents interface on that object /// </remarks> public void OnToolbarButtonClick(FalconViewOverlayLib.IFvMapView pMapView, int lButtonCommandId) { // TODO: Respond to the toolbar button press if (lButtonCommandId == m_SelectionButton) { m_EditorState = EditorState.VIEWDATA; } else if (lButtonCommandId == m_DropPointsButton) { m_EditorState = EditorState.ADDPOINTS; } else if (lButtonCommandId == m_QueryButton) { m_EditorState = EditorState.AOI_SELECT; } else if (lButtonCommandId == m_EraseButton) { m_EditorState = EditorState.DELETEMODE; } // Then Set the UI state of the toolbar SetButtonStates(); }
protected void OnEditFinished() { editorState = EditorState.Finished; }
void StatesButton() { if (currentEditorState != EditorState.STATES) { if (GUILayout.Button("States")) currentEditorState = EditorState.STATES; } }
/// <summary> /// get location where right button click down. /// </summary> /// <param name="sender">object who sent this event</param> /// <param name="e">event args</param> private void SlabShapePictureBox_MouseDown(object sender, MouseEventArgs e) { if (MouseButtons.Right == e.Button) { m_mouseRightDownLocation = e.Location; editorState = EditorState.Rotate; m_clickedIndex = m_selectIndex = -1; } }
void QuestsButton() { if (currentEditorState != EditorState.QUESTS) { if (GUILayout.Button("Quests")) currentEditorState = EditorState.QUESTS; } }
void SkillsButton() { if (currentEditorState != EditorState.SKILLS) { if (GUILayout.Button("Skills")) currentEditorState = EditorState.SKILLS; } }
void OnEnable() { currentEditorState = EditorState.TERMS; currentDetailsState = DetailsState.NONE; if (Character_DB == null) { Character_DB = ScriptableObjectDatabase<CharacterDB>.GetDatabase<CharacterDB>(DATABASE_FOLDER_NAME, DATABASE_CHARACTERS_NAME); } if (Terms_DB == null) { Terms_DB = ScriptableObjectDatabase<TermsDB>.GetDatabase<TermsDB>(DATABASE_FOLDER_NAME, DATABASE_TERMS_NAME); } if (Element_DB == null) { Element_DB = ScriptableObjectDatabase<ElementDB>.GetDatabase<ElementDB>(DATABASE_FOLDER_NAME, DATABASE_ELEMENTS_NAME); } if (Weapon_DB == null) { Weapon_DB = ScriptableObjectDatabase<WeaponDB>.GetDatabase<WeaponDB>(DATABASE_FOLDER_NAME, DATABASE_WEAPONS_NAME); } if (System_DB == null) { System_DB = ScriptableObjectDatabase<SystemDB>.GetDatabase<SystemDB>(DATABASE_FOLDER_NAME, DATABASE_SYSTEM_NAME); } if (Armour_DB == null) { Armour_DB = ScriptableObjectDatabase<ArmourDB>.GetDatabase<ArmourDB>(DATABASE_FOLDER_NAME, DATABASE_ARMOURS_NAME); } }
void ItemsButton() { if (currentEditorState != EditorState.ITEMS) { if (GUILayout.Button("Items")) currentEditorState = EditorState.ITEMS; } }
void EnemyGroupsButton() { if (currentEditorState != EditorState.ENEMYGROUPS) { if (GUILayout.Button("Enemy Groups")) currentEditorState = EditorState.ENEMYGROUPS; } }
/// <summary> /// get ready to move vertex and crease /// </summary> /// <param name="sender">object who sent this event</param> /// <param name="e">event args</param> private void MoveButton_Click(object sender, EventArgs e) { editorState = EditorState.Select; m_slabProfile.ClearRotateMatrix(); this.SlabShapePictureBox.Cursor = Cursors.Arrow; }
//Method that allows to save on a file the actual editor's state public void SaveState(string path) { EditorState state = new EditorState(); state.VRPNTrackerDevice = VRPNTrackerDevice; state.VRPNAnalogDevice = VRPNAnalogDevice; state.VRPNButtonDevice = VRPNButtonDevice; state.timeLineTime = timeLineTime; state.timeLineZoom = timeLineZoom; state.timeLineProportion = timeLineProportion; BinaryFormatter bf = new BinaryFormatter(); bool canEdit = false; FileStream file = null; while (!canEdit) { try { file = File.Create(path); canEdit = true; } #pragma warning disable 0168 catch (Exception e) #pragma warning restore 0168 { canEdit = false; } } bf.Serialize(file, state); file.Close(); }
/// <summary> /// get ready to add vertex /// </summary> /// <param name="sender">object who sent this event</param> /// <param name="e">event args</param> private void PointButton_Click(object sender, EventArgs e) { editorState = EditorState.AddVertex; m_slabProfile.ClearRotateMatrix(); this.SlabShapePictureBox.Cursor = Cursors.Cross; }
public void destroyTextureBrush() { state = EditorState.idle; currentbrush = null; }
Pen m_toolPen; //pen use to draw new created vertex and crease #endregion Fields #region Constructors /// <summary> /// constructor /// </summary> /// <param name="commandData">selected floor (or slab)</param> /// <param name="commandData">contains reference of Revit Application</param> public SlabShapeEditingForm(Floor floor, ExternalCommandData commandData) { InitializeComponent(); m_commandData = commandData; m_slabProfile = new SlabProfile(floor, commandData); m_slabShapeEditor = floor.SlabShapeEditor; m_lineTool = new LineTool(); m_pointTool = new LineTool(); editorState = EditorState.AddVertex; m_graphicsPaths = new ArrayList(); m_createdVertices = new ArrayList(); m_createCreases = new ArrayList(); m_selectIndex = -1; m_clickedIndex = -1; m_toolPen = new Pen(System.Drawing.Color.Blue, 2); m_selectPen = new Pen(System.Drawing.Color.Red, 2); m_profilePen = new Pen(System.Drawing.Color.Black, (float)(0.5)); }
public void createTextureBrush(string fullpath) { state = EditorState.brush; currentbrush = new Brush(fullpath); }
protected override void Update(GameTime gameTime) { KeyboardState keys = Keyboard.GetState(); GamePadState pad = GamePad.GetState(PlayerIndex.One); help.Update(); if (pad.Buttons.Back == ButtonState.Pressed || keys.IsKeyDown(Keys.Escape)) this.Exit(); switch (gameState) { #region MainMenu case GameState.MainMenu: if (keys.IsKeyDown(Keys.P) || pad.IsButtonDown(Buttons.A)) gameState = GameState.Game; if (keys.IsKeyDown(Keys.E) || pad.IsButtonDown(Buttons.X)) gameState = GameState.EditorSelect; break; #endregion #region Game case GameState.Game: p1.Update(keys); p2.Update(pad); r.Update(players); break; #endregion #region EditorSelect case GameState.EditorSelect: levelName.focused = true; levelName.Update(keys.GetPressedKeys()); if (keys.IsKeyDown(Keys.Enter) || pad.IsButtonDown(Buttons.A)) { int w, h; Functions.CreateLevel(levelName.value, 10, 10); if (File.Exists(levelName.value + ".dat")) { Functions.LoadHeader(levelName.value, out w, out h); editor = new Room(levelName.value, w, h, Content.Load<Texture2D>("tileset")); } else { Functions.LoadHeader(levelName.value, out w, out h); Functions.CreateLevel(levelName.value, 10, 10); editor = new Room(levelName.value, 10, 10, Content.Load<Texture2D>("tileset")); } gameState = GameState.Editor; } break; #endregion #region Editor case GameState.Editor: switch(editorState) { case EditorState.Tiles: if (help.IsNewPress(Keys.W) || help.IsNewPress(Buttons.DPadUp)) { if (tileSelected.Y >= 1) tileSelected.Y--; } if (help.IsNewPress(Keys.S) || help.IsNewPress(Buttons.DPadDown)) { if (tileSelected.Y <= editor.height - 2) tileSelected.Y++; } if (help.IsNewPress(Keys.D) || help.IsNewPress(Buttons.DPadRight)) { if (tileSelected.X <= editor.width - 2) tileSelected.X++; } if (help.IsNewPress(Keys.A) || help.IsNewPress(Buttons.DPadLeft)) { if (tileSelected.X >= 1) tileSelected.X--; } if (help.IsNewPress(Keys.Space) || help.IsNewPress(Buttons.A)) editor.data[(int)tileSelected.Y, (int)tileSelected.X] = editSelected; if (help.IsNewPress(Keys.E) || help.IsNewPress(Buttons.X)) editorState = EditorState.Grid; if (help.IsNewPress(Keys.C) || help.IsNewPress(Buttons.Y)) editorState = EditorState.Collision; break; case EditorState.Grid: if (help.IsNewPress(Keys.W) || help.IsNewPress(Buttons.DPadUp)) { if (editSelected >= 6) editSelected -= 6; } if (help.IsNewPress(Keys.S) || help.IsNewPress(Buttons.DPadDown)) { if (editSelected <= 41) editSelected += 6; } if (help.IsNewPress(Keys.A) || help.IsNewPress(Buttons.DPadLeft)) { if (editSelected > 1) editSelected--; } if (help.IsNewPress(Keys.D) || help.IsNewPress(Buttons.DPadRight)) { if (editSelected < 47) editSelected++; } if (help.IsNewPress(Keys.E) || help.IsNewPress(Buttons.X)) editorState = EditorState.Tiles; if (help.IsNewPress(Keys.C) || help.IsNewPress(Buttons.Y)) editorState = EditorState.Collision; break; case EditorState.Collision: if (help.IsNewPress(Keys.W) || help.IsNewPress(Buttons.DPadUp)) { if (tileSelected.Y >= 1) tileSelected.Y--; } if (help.IsNewPress(Keys.S) || help.IsNewPress(Buttons.DPadDown)) { if (tileSelected.Y <= editor.height - 2) tileSelected.Y++; } if (help.IsNewPress(Keys.D) || help.IsNewPress(Buttons.DPadRight)) { if (tileSelected.X <= editor.width - 2) tileSelected.X++; } if (help.IsNewPress(Keys.A) || help.IsNewPress(Buttons.DPadLeft)) { if (tileSelected.X >= 1) tileSelected.X--; } if (help.IsNewPress(Keys.D0) || help.IsNewPress(Buttons.B)) editor.col[(int)tileSelected.X, (int)tileSelected.Y] = 0; if (help.IsNewPress(Keys.D1) || help.IsNewPress(Buttons.A)) editor.col[(int)tileSelected.X, (int)tileSelected.Y] = 1; if (help.IsNewPress(Keys.E) || help.IsNewPress(Buttons.X)) editorState = EditorState.Tiles; break; } if (help.IsNewPress(Keys.F1) || help.IsNewPress(Buttons.Start)) { editor.Save(); gameState = GameState.MainMenu; } break; #endregion } base.Update(gameTime); }
public void createPrimitiveBrush(PrimitiveType primitiveType) { if (SelectedLayer == null) { System.Windows.Forms.MessageBox.Show(Resources.No_Layer); return; } state = EditorState.brush_primitive; primitivestarted = false; clickedPoints.Clear(); currentprimitive = primitiveType; MainForm.Instance.pictureBox1.Cursor = Forms.Cursors.Cross; MainForm.Instance.listView2.Cursor = Forms.Cursors.Cross; switch (primitiveType) { case PrimitiveType.Rectangle: MainForm.Instance.toolStripStatusLabel1.Text = Resources.Rectangle_Entered; break; case PrimitiveType.Circle: MainForm.Instance.toolStripStatusLabel1.Text = Resources.Circle_Entered; break; case PrimitiveType.Path: MainForm.Instance.toolStripStatusLabel1.Text = Resources.Path_Entered; break; } }
void Start() { _editorState = GameObject.Find ("UICanvas").GetComponent<EditorState> (); Refresh (); }
public void update(GameTime gt) { if (level == null) return; oldkstate = kstate; oldmstate = mstate; kstate = Keyboard.GetState(); mstate = Mouse.GetState(); int mwheeldelta = mstate.ScrollWheelValue - oldmstate.ScrollWheelValue; if (mwheeldelta > 0 /* && kstate.IsKeyDown(Keys.LeftControl)*/) { float zoom = (float)Math.Round(camera.Scale * 10) * 10.0f + 10.0f; MainForm.Instance.zoomcombo.Text = zoom.ToString() + "%"; camera.Scale = zoom / 100.0f; } if (mwheeldelta < 0 /* && kstate.IsKeyDown(Keys.LeftControl)*/) { float zoom = (float)Math.Round(camera.Scale * 10) * 10.0f - 10.0f; if (zoom <= 0.0f) return; MainForm.Instance.zoomcombo.Text = zoom.ToString() + "%"; camera.Scale = zoom / 100.0f; } //Camera movement float delta; if (kstate.IsKeyDown(Keys.LeftShift)) delta = Constants.Instance.CameraFastSpeed * (float)gt.ElapsedGameTime.TotalSeconds; else delta = Constants.Instance.CameraSpeed * (float)gt.ElapsedGameTime.TotalSeconds; if (kstate.IsKeyDown(Keys.W) && kstate.IsKeyUp(Keys.LeftControl)) camera.Position += (new Vector2(0, -delta)); if (kstate.IsKeyDown(Keys.S) && kstate.IsKeyUp(Keys.LeftControl)) camera.Position += (new Vector2(0, +delta)); if (kstate.IsKeyDown(Keys.A) && kstate.IsKeyUp(Keys.LeftControl)) camera.Position += (new Vector2(-delta, 0)); if (kstate.IsKeyDown(Keys.D) && kstate.IsKeyUp(Keys.LeftControl)) camera.Position += (new Vector2(+delta, 0)); if (kstate.IsKeyDown(Keys.Subtract)) { float zoom = (float)(camera.Scale * 0.995); MainForm.Instance.zoomcombo.Text = (zoom * 100).ToString("###0.0") + "%"; camera.Scale = zoom; } if (kstate.IsKeyDown(Keys.Add)) { float zoom = (float)(camera.Scale * 1.005); MainForm.Instance.zoomcombo.Text = (zoom * 100).ToString("###0.0") + "%"; camera.Scale = zoom; } //get mouse world position considering the ScrollSpeed of the current layer Vector2 maincameraposition = camera.Position; if (SelectedLayer != null) camera.Position *= SelectedLayer.ScrollSpeed; mouseworldpos = Vector2.Transform(new Vector2(mstate.X, mstate.Y), Matrix.Invert(camera.matrix)); mouseworldpos = mouseworldpos.Round(); MainForm.Instance.toolStripStatusLabel3.Text = "Mouse: (" + mouseworldpos.X + ", " + mouseworldpos.Y + ")"; camera.Position = maincameraposition; if (state == EditorState.idle) { //get item under mouse cursor Item item = getItemAtPos(mouseworldpos); if (item != null) { MainForm.Instance.toolStripStatusLabel1.Text = item.Name; item.onMouseOver(mouseworldpos); if (kstate.IsKeyDown(Keys.LeftControl)) MainForm.Instance.pictureBox1.Cursor = cursorDup; } else { MainForm.Instance.toolStripStatusLabel1.Text = ""; } if (item != lastitem && lastitem != null) lastitem.onMouseOut(); lastitem = item; //LEFT MOUSE BUTTON CLICK if ((mstate.LeftButton == ButtonState.Pressed && oldmstate.LeftButton == ButtonState.Released) || (kstate.IsKeyDown(Keys.D1) && oldkstate.IsKeyUp(Keys.D1))) { if (item != null) item.onMouseButtonDown(mouseworldpos); if (kstate.IsKeyDown(Keys.LeftControl) && item != null) { if (!SelectedItems.Contains(item)) selectitem(item); beginCommand("Add Item(s)"); List<Item> selecteditemscopy = new List<Item>(); foreach (Item selitem in SelectedItems) { Item i2 = (Item)selitem.clone(); selecteditemscopy.Add(i2); } foreach (Item selitem in selecteditemscopy) { selitem.Name = selitem.getNamePrefix() + level.getNextItemNumber(); addItem(selitem); } selectitem(selecteditemscopy[0]); updatetreeview(); for (int i = 1; i < selecteditemscopy.Count; i++) SelectedItems.Add(selecteditemscopy[i]); startMoving(); } else if (kstate.IsKeyDown(Keys.LeftShift) && item != null) { if (SelectedItems.Contains(item)) SelectedItems.Remove(item); else SelectedItems.Add(item); } else if (SelectedItems.Contains(item)) { beginCommand("Change Item(s)"); startMoving(); } else if (!SelectedItems.Contains(item)) { selectitem(item); if (item != null) { beginCommand("Change Item(s)"); startMoving(); } else { grabbedpoint = mouseworldpos; selectionrectangle = Rectangle.Empty; state = EditorState.selecting; } } } //MIDDLE MOUSE BUTTON CLICK if ((mstate.MiddleButton == ButtonState.Pressed && oldmstate.MiddleButton == ButtonState.Released) || (kstate.IsKeyDown(AdesExtensions.KEY_ROTATE) && oldkstate.IsKeyUp(AdesExtensions.KEY_ROTATE))) { if (item != null) item.onMouseOut(); if (kstate.IsKeyDown(Keys.LeftControl)) { grabbedpoint = new Vector2(mstate.X, mstate.Y); initialcampos = camera.Position; state = EditorState.cameramoving; MainForm.Instance.pictureBox1.Cursor = Forms.Cursors.SizeAll; } else { if (SelectedItems.Count > 0) { grabbedpoint = mouseworldpos - SelectedItems[0].pPosition; //save the initial rotation for each item initialrot.Clear(); foreach (Item selitem in SelectedItems) { if (selitem.CanRotate()) { initialrot.Add(selitem.getRotation()); } } state = EditorState.rotating; MainForm.Instance.pictureBox1.Cursor = cursorRot; beginCommand("Rotate Item(s)"); } } } //RIGHT MOUSE BUTTON CLICK if ((mstate.RightButton == ButtonState.Pressed && oldmstate.RightButton == ButtonState.Released) || (kstate.IsKeyDown(Keys.D3) && oldkstate.IsKeyUp(Keys.D3))) { if (item != null) item.onMouseOut(); if (SelectedItems.Count > 0) { grabbedpoint = mouseworldpos - SelectedItems[0].pPosition; //save the initial scale for each item initialscale.Clear(); foreach (Item selitem in SelectedItems) { if (selitem.CanScale()) { initialscale.Add(selitem.getScale()); } } state = EditorState.scaling; MainForm.Instance.pictureBox1.Cursor = cursorScale; beginCommand("Scale Item(s)"); } } if (kstate.IsKeyDown(Keys.H) && oldkstate.GetPressedKeys().Length == 0 && SelectedItems.Count > 0) { beginCommand("Flip Item(s) Horizontally"); foreach (Item selitem in SelectedItems) { if (selitem is TextureItem) { TextureItem ti = (TextureItem)selitem; ti.FlipHorizontally = !ti.FlipHorizontally; } } MainForm.Instance.propertyGrid1.Refresh(); endCommand(); } if (kstate.IsKeyDown(Keys.V) && oldkstate.GetPressedKeys().Length == 0 && SelectedItems.Count > 0) { beginCommand("Flip Item(s) Vertically"); foreach (Item selitem in SelectedItems) { if (selitem is TextureItem) { TextureItem ti = (TextureItem)selitem; ti.FlipVertically = !ti.FlipVertically; } } MainForm.Instance.propertyGrid1.Refresh(); endCommand(); } } if (state == EditorState.moving) { int i = 0; foreach (Item selitem in SelectedItems) { newPosition = initialpos[i] + mouseworldpos - grabbedpoint; if (AdesExtensions.shouldSnapPosition(kstate) || kstate.IsKeyDown(Keys.G)) newPosition = snapToGrid(newPosition); drawSnappedPoint = false; selitem.setPosition(newPosition); i++; } MainForm.Instance.propertyGrid1.Refresh(); if ((mstate.LeftButton == ButtonState.Released && oldmstate.LeftButton == ButtonState.Pressed) || (kstate.IsKeyUp(Keys.D1) && oldkstate.IsKeyDown(Keys.D1))) { foreach (Item selitem in SelectedItems) selitem.onMouseButtonUp(mouseworldpos); state = EditorState.idle; MainForm.Instance.pictureBox1.Cursor = Forms.Cursors.Default; if (mouseworldpos != grabbedpoint) endCommand(); else abortCommand(); } } if (state == EditorState.rotating) { Vector2 newpos = mouseworldpos - SelectedItems[0].pPosition; float deltatheta = (float)Math.Atan2(grabbedpoint.Y, grabbedpoint.X) - (float)Math.Atan2(newpos.Y, newpos.X); int i = 0; foreach (Item selitem in SelectedItems) { if (selitem.CanRotate()) { selitem.setRotation(initialrot[i] - deltatheta); if (AdesExtensions.shouldSnapRotation(kstate)) { selitem.setRotation((float)Math.Round(selitem.getRotation() / MathHelper.PiOver4) * MathHelper.PiOver4); } i++; } } MainForm.Instance.propertyGrid1.Refresh(); if ((mstate.MiddleButton == ButtonState.Released && oldmstate.MiddleButton == ButtonState.Pressed) || (kstate.IsKeyUp(AdesExtensions.KEY_ROTATE) && oldkstate.IsKeyDown(AdesExtensions.KEY_ROTATE))) { state = EditorState.idle; MainForm.Instance.pictureBox1.Cursor = Forms.Cursors.Default; endCommand(); } } if (state == EditorState.scaling) { Vector2 newdistance = mouseworldpos - SelectedItems[0].pPosition; float factor = newdistance.Length() / grabbedpoint.Length(); int i = 0; foreach (Item selitem in SelectedItems) { if (selitem.CanScale()) { if (selitem is TextureItem) { MainForm.Instance.toolStripStatusLabel1.Text = "Hold down [X] or [Y] to limit scaling to the according dimension."; } Vector2 newscale = initialscale[i]; if (!kstate.IsKeyDown(Keys.Y)) newscale.X = initialscale[i].X * (((factor - 1.0f) * 0.5f) + 1.0f); if (!kstate.IsKeyDown(Keys.X)) newscale.Y = initialscale[i].Y * (((factor - 1.0f) * 0.5f) + 1.0f); selitem.setScale(newscale); if (kstate.IsKeyDown(Keys.LeftControl)) { Vector2 scale; scale.X = (float)Math.Round(selitem.getScale().X * 10) / 10; scale.Y = (float)Math.Round(selitem.getScale().Y * 10) / 10; selitem.setScale(scale); } i++; } } MainForm.Instance.propertyGrid1.Refresh(); if ((mstate.RightButton == ButtonState.Released && oldmstate.RightButton == ButtonState.Pressed) || (kstate.IsKeyUp(Keys.D3) && oldkstate.IsKeyDown(Keys.D3))) { state = EditorState.idle; MainForm.Instance.pictureBox1.Cursor = Forms.Cursors.Default; endCommand(); } } if (state == EditorState.cameramoving) { Vector2 newpos = new Vector2(mstate.X, mstate.Y); Vector2 distance = (newpos - grabbedpoint) / camera.Scale; if (distance.Length() > 0) { camera.Position = initialcampos - distance; } if (mstate.MiddleButton == ButtonState.Released) { state = EditorState.idle; MainForm.Instance.pictureBox1.Cursor = Forms.Cursors.Default; } } if (state == EditorState.selecting) { if (SelectedLayer == null) return; Vector2 distance = mouseworldpos - grabbedpoint; if (distance.Length() > 0) { SelectedItems.Clear(); selectionrectangle = Extensions.RectangleFromVectors(grabbedpoint, mouseworldpos); foreach (Item i in SelectedLayer.Items) { if (i.Visible && selectionrectangle.Contains((int)i.pPosition.X, (int)i.pPosition.Y)) SelectedItems.Add(i); } updatetreeviewselection(); } if (mstate.LeftButton == ButtonState.Released) { state = EditorState.idle; MainForm.Instance.pictureBox1.Cursor = Forms.Cursors.Default; } } if (state == EditorState.brush) { if (Constants.Instance.SnapToGrid || kstate.IsKeyDown(Keys.G)) { mouseworldpos = snapToGrid(mouseworldpos); } if (mstate.RightButton == ButtonState.Pressed && oldmstate.RightButton == ButtonState.Released) state = EditorState.idle; if (mstate.LeftButton == ButtonState.Pressed && oldmstate.LeftButton == ButtonState.Released) paintTextureBrush(true); } if (state == EditorState.brush_primitive) { if (Constants.Instance.SnapToGrid || kstate.IsKeyDown(Keys.G)) mouseworldpos = snapToGrid(mouseworldpos); if (kstate.IsKeyDown(Keys.LeftControl) && primitivestarted && currentprimitive == PrimitiveType.Rectangle) { Vector2 distance = mouseworldpos - clickedPoints[0]; float squareside = Math.Max(distance.X, distance.Y); mouseworldpos = clickedPoints[0] + new Vector2(squareside, squareside); } if ((mstate.LeftButton == ButtonState.Pressed && oldmstate.LeftButton == ButtonState.Released) || (kstate.IsKeyDown(Keys.D1) && oldkstate.IsKeyUp(Keys.D1))) { clickedPoints.Add(mouseworldpos); if (primitivestarted == false) { primitivestarted = true; switch (currentprimitive) { case PrimitiveType.Rectangle: MainForm.Instance.toolStripStatusLabel1.Text = Resources.Rectangle_Started; break; case PrimitiveType.Circle: MainForm.Instance.toolStripStatusLabel1.Text = Resources.Circle_Started; break; case PrimitiveType.Path: MainForm.Instance.toolStripStatusLabel1.Text = Resources.Path_Started; break; } } else { if (currentprimitive != PrimitiveType.Path) { paintPrimitiveBrush(); clickedPoints.Clear(); primitivestarted = false; } } } if (kstate.IsKeyDown(Keys.Back) && oldkstate.IsKeyUp(Keys.Back)) { if (currentprimitive == PrimitiveType.Path && clickedPoints.Count > 1) { clickedPoints.RemoveAt(clickedPoints.Count-1); } } if ((mstate.MiddleButton == ButtonState.Pressed && oldmstate.MiddleButton == ButtonState.Released) || (kstate.IsKeyDown(Keys.D2) && oldkstate.IsKeyUp(Keys.D2))) { if (currentprimitive == PrimitiveType.Path && primitivestarted) { paintPrimitiveBrush(); clickedPoints.Clear(); primitivestarted = false; MainForm.Instance.toolStripStatusLabel1.Text = Resources.Path_Entered; } } if ((mstate.RightButton == ButtonState.Pressed && oldmstate.RightButton == ButtonState.Released) || (kstate.IsKeyDown(Keys.D3) && oldkstate.IsKeyUp(Keys.D3))) { if (primitivestarted) { clickedPoints.Clear(); primitivestarted = false; switch (currentprimitive) { case PrimitiveType.Rectangle: MainForm.Instance.toolStripStatusLabel1.Text = Resources.Rectangle_Entered; break; case PrimitiveType.Circle: MainForm.Instance.toolStripStatusLabel1.Text = Resources.Circle_Entered; break; case PrimitiveType.Path: MainForm.Instance.toolStripStatusLabel1.Text = Resources.Path_Entered; break; } } else { destroyPrimitiveBrush(); clickedPoints.Clear(); primitivestarted = false; } } } }
public void destroyPrimitiveBrush() { state = EditorState.idle; MainForm.Instance.pictureBox1.Cursor = Forms.Cursors.Default; MainForm.Instance.listView2.Cursor = Forms.Cursors.Default; }
public void startMoving() { grabbedpoint = mouseworldpos; //save the distance to mouse for each item initialpos.Clear(); foreach (Item selitem in SelectedItems) { initialpos.Add(selitem.pPosition); } state = EditorState.moving; //MainForm.Instance.pictureBox1.Cursor = Forms.Cursors.SizeAll; }