/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (Editor game = new Editor()) { game.Run(); } }
public MapEntPropertiesView(Editor e) : base() { editor = e; engine = e.engine; Text = "MapEnt properties"; enttypes = new ListBox(); enttypes.Location = new System.Drawing.Point(10, 10); enttypes.Items.Clear(); foreach (string s in MapEnt.enttypes) enttypes.Items.Add(s); enttypes.Show(); Controls.Add(enttypes); entprops = new TextBox[5]; int x = 10; int y = enttypes.Bottom + 5; for (int i = 0; i < numprops; i++) { entprops[i] = new TextBox(); entprops[i].Location = new System.Drawing.Point(x, y); entprops[i].Show(); Controls.Add(entprops[i]); y = entprops[i].Bottom + 5; } }
public Workspace(IConsole console) { _console = console; commandPalette = new CommandPalette(_console, 20, 1, 40); commandPalette.CommandRecieved += (object sender, CommandArgs commandArgs) => { string command = commandArgs.Command; switch (command) { case "new": NewEditor(); lastEditor = Editors[0]; ActiveEditor = commandPalette; return; case "open": //OpenEditor(); case "save": //SaveEditor(); default: return; } }; }
public override bool Create(Editor.Editor editor, [NotNullWhen(true)] out Component?component) { ImGui.SetNextItemWidth(80); if (ImGui.InputInt("Bits", ref this.bits, 1, 1)) { this.bits = Math.Max(2, this.bits); } ImGui.Button("Create"); if (ImGui.IsItemClicked()) { ImGui.CloseCurrentPopup(); component = new LogicGate(editor.GetWorldMousePos(), this.bits, this.logic); return(true); } component = null; return(false); }
public ObstructionMode(Editor e) { editor = e; engine = e.engine; }
protected override void LoadContent() { graph = new XNAGraph(graphics.GraphicsDevice, this.Content); input = new InputHandler(); tileset = new BitmapSprite(graph, "mantiles", 16, 16, 19, new Microsoft.Xna.Framework.Rectangle(0, 0, 16, 16)); TabbySprite = new BitmapSprite(graph, "tabpis", 64, 64, 8, new Rectangle(24, 24, 16, 40)); DoorSprite = new BitmapSprite(graph, "door", 16, 64, 7, new Rectangle(0, 0, 16, 64)); RipperSprite = new BitmapSprite(graph, "ripper", 16, 32, 4, new Rectangle(0, 0, 16, 20)); BoomSprite = new BitmapSprite(graph, "boom", 16, 16, 7, new Rectangle(0, 0, 16, 16)); BulletSprite = new BitmapSprite(graph, "bullet", 8, 8, 8, new Rectangle(0, 0, 8, 8)); player = new Player(this); cameraTarget = player; player.X = player.Y = 32; // arbitrary, if the map doesn't stipulate a starting point. map = v2Map.Load("map00.map"); MapSwitch("data/maps/test.map"); obs = new VectorObstructionMap(map.Obs); time = new Timer(100); editor = new Editor.Editor(this); editor.OnExit += StopEditor; }
public EntityEditMode(Editor e) { editor = e; engine = e.engine; }
public MainForm() { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; if (File.Exists(shaderPath)) { shaderSource = File.ReadAllText(shaderPath); } else { MessageBox.Show("Base shader not found."); } Log.Filename = "log.txt"; InitializeComponent(); Text = "Zwerg " + Application.ProductVersion.Substring(0, 5) + " - Distance Field Editor by movAX13h"; string nl = Environment.NewLine + Environment.NewLine; usageLabel.Text = "Use right mouse button context menu of the scene panel to add and remove nodes." + nl + "Click the 'Apply changes' button or press ENTER to update the preview at any time." + nl + "Use the wasd-keys or move your mouse while holding the left button to rotate the camera around the selected object." + nl + "In free fly mode use the wasd-keys to move the camera and left mouse button drag to look around." + nl + "Mouse wheel increases/decreases the distance to the target." + nl + "A mouse click on a distance object in the preview selects the node in the scene view (experimental)." + nl + "Right mouse button controls light direction (rotates around y-axis)."; propertiesPanel = new PropertiesPanel(propertiesPanelControl); editor = new Editor.Editor(sceneTreeView, propertiesPanel, shaderSource); if (!editor.Setup(functionsXmlPath)) { MessageBox.Show(editor.Errors + "\n\nNo nodes available.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } cameraRotationModeBox.SelectedItem = cameraRotationModeBox.Items[0]; // setup project tree view context menu ToolStripMenuItem menuItem; ContextMenuStrip contextMenu = new ContextMenuStrip(); contextMenu.RenderMode = ToolStripRenderMode.System; contextMenu.ShowImageMargin = false; contextMenu.ShowCheckMargin = false; contextMenu.ItemClicked += contextMenu_ItemClicked; contextMenu.Opening += contextMenu_Opening; ToolStripMenuItem i = new ToolStripMenuItem(); i.Text = "Primitives"; i.DropDownItemClicked += contextMenu_ItemClicked; foreach (DistancePrimitive type in editor.DistanceFieldTypes) { menuItem = newToolStripMenuItem(); menuItem.Text = type.Name; menuItem.Tag = type; i.DropDownItems.Add(menuItem); } contextMenu.Items.Add(i); i = new ToolStripMenuItem(); i.Text = "Operations"; i.DropDownItemClicked += contextMenu_ItemClicked; foreach (DistanceOperation type in editor.DistanceOperations) { menuItem = newToolStripMenuItem(); menuItem.Text = type.Name; menuItem.Tag = type; i.DropDownItems.Add(menuItem); } contextMenu.Items.Add(i); i = new ToolStripMenuItem(); i.Text = "Domain"; i.DropDownItemClicked += contextMenu_ItemClicked; foreach (DomainOperation type in editor.DomainOperations) { menuItem = newToolStripMenuItem(); menuItem.Text = type.Name; menuItem.Tag = type; i.DropDownItems.Add(menuItem); } contextMenu.Items.Add(i); deleteItem = newToolStripMenuItem(); deleteItem.Text = "Delete [DEL]"; deleteItem.Tag = "delete"; contextMenu.Items.Add(deleteItem); sceneTreeView.ContextMenuStrip = contextMenu; resetView(); keys = new List <Keys>(); stopwatch = new Stopwatch(); assets = new List <Asset>(); canvas = new Canvas(glControl1.Width, glControl1.Height); }
public EdgeMode(Editor e) : base(e, "Edge Mode") { }
public abstract bool Create(Editor.Editor editor, [NotNullWhen(true)] out Component?component);
public CopyPasteMode(Editor e) { editor = e; engine = e.engine; }
public void Run() { if (Editors.Count == 0) { _console.Clear(); _console.CursorTop = 2; _console.CursorLeft = 4; _console.Write("* No editors! Press Ctrl+N to create or Ctrl+O to open!"); } else { RedrawEditors(); } while (true) { var keyInfo = _console.ReadKey(true); if (keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control)) { switch (keyInfo.Key) { case ConsoleKey.N: NewEditor(); break; case ConsoleKey.O: OpenEditor(); break; case ConsoleKey.LeftArrow: { var idx = Editors.FindIndex(x => x == ActiveEditor); ActiveEditor = Editors[idx == 0 ? Editors.Count - 1 : idx - 1]; ActiveEditor.ActivateCursor(); continue; } case ConsoleKey.RightArrow: { var idx = Editors.FindIndex(x => x == ActiveEditor); ActiveEditor = Editors[(idx + 1) % Editors.Count]; ActiveEditor.ActivateCursor(); continue; } } } if (Editors.Count == 0) { continue; } bool redraw = false; switch (keyInfo.Key) { case ConsoleKey.UpArrow: redraw = ActiveEditor.HandleInput(EditorInput.UpArrow); break; case ConsoleKey.DownArrow: redraw = ActiveEditor.HandleInput(EditorInput.DownArrow); break; case ConsoleKey.LeftArrow: redraw = ActiveEditor.HandleInput(EditorInput.LeftArrow); break; case ConsoleKey.RightArrow: redraw = ActiveEditor.HandleInput(EditorInput.RightArrow); break; case ConsoleKey.Enter: redraw = ActiveEditor.HandleInput(EditorInput.Enter); break; case ConsoleKey.Backspace: redraw = ActiveEditor.HandleInput(EditorInput.Backspace); break; case ConsoleKey.Tab: if (keyInfo.Modifiers.HasFlag(ConsoleModifiers.Shift)) redraw = ActiveEditor.HandleInput(EditorInput.ShiftTab); else redraw = ActiveEditor.HandleInput(EditorInput.Tab); break; } if (!Char.IsControl(keyInfo.KeyChar)) { redraw = ActiveEditor.HandleInput(keyInfo.KeyChar.ToString()); } if (redraw) { ActiveEditor.AdjustWindow(); ActiveEditor.Render(); } else if (ActiveEditor.AdjustWindow()) { ActiveEditor.Render(); } ActiveEditor.ActivateCursor(); } }
private void NewEditor() { Editors.Insert(0, new Editor(_console, string.Format("untitled {0}", ++numUntitled), 0, 0, 80, 24)); ActiveEditor = Editors[0]; ResizeEditors(); RedrawEditors(); }
// heh, probably need more things here at some point. ;) public MapInfoView(Editor e) { editor = e; engine = e.engine; Text = "Map Properties"; curlay = new ListBox(); Controls.Add(curlay); curlay.Left = 10; curlay.Top = 10; curlay.SelectedIndexChanged += new EventHandler(SwitchLayer); object[][] layerbuttons = new object[][] { new object[] { "Move &Up", new EventHandler(MoveLayerUp) }, new object[] { "Move &Down", new EventHandler(MoveLayerDown) }, new object[] { "&Remove", new EventHandler(RemoveLayer) }, new object[] { "Insert &New", new EventHandler(InsertNewLayer)}, new object[] { "&Add New", new EventHandler(AddNewLayer) }, new object[] { "&Hide", new EventHandler(HideLayer) }, new object[] { "&Show", new EventHandler(ShowLayer) }, new object[] { "Show &Only", new EventHandler(ShowLayerOnly) }, new object[] { "Show A&ll", new EventHandler(ShowAll) }, }; int x = 140; int y = 10; foreach (object[] o in layerbuttons) { Button b = new Button(); b.Text = (string)o[0]; b.Click += (EventHandler)o[1]; b.Location = new Point(x, y); y += b.Height + 5; Controls.Add(b); } Height = y + 30; x = 280; y = 10; Label l = new Label(); l.Text = "Name"; l.Location = new Point(x, y); Controls.Add(l); layername = new TextBox(); layername.Location = new Point(x + l.Width, y); Controls.Add(layername); Button renamelay = new Button(); renamelay.Text = "Rename"; renamelay.Click += new EventHandler(RenameLayer); renamelay.Location = new Point(layername.Right + 5, layername.Top); Controls.Add(renamelay); Width = renamelay.Right + 10; y += l.Height + 15; Label lw = new Label(); lw.Text = "Width"; lw.Location = new Point(x, y); Controls.Add(lw); widthbox = new TextBox(); widthbox.Location = new Point(x + lw.Width, y); widthbox.Text = engine.map.Width.ToString(); Controls.Add(widthbox); Button resize = new Button(); resize.Text = "Resize"; resize.Click += new EventHandler(ChangeDims); resize.Location = new Point(widthbox.Right + 5, widthbox.Top + 10); Controls.Add(resize); y += l.Height + 5; Label lh = new Label(); lh.Text = "Height"; lh.Location = new Point(x, y); Controls.Add(lh); heightbox = new TextBox(); heightbox.Location = new Point(x + lh.Width, y); heightbox.Text = engine.map.Height.ToString(); Controls.Add(heightbox); Update(); }
public void Run() { if (Editors.Count == 0) { _console.Clear(); _console.CursorTop = 2; _console.CursorLeft = 4; _console.Write("* No editors! Press Ctrl+N to create or Ctrl+O to open!"); } else { RedrawEditors(); } while (true) { var keyInfo = _console.ReadKey(true); if (keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control)) { switch (keyInfo.Key) { case ConsoleKey.X: //if (commandPalette.Focused) break; lastEditor = (Editor) ActiveEditor; commandPalette.Show(); ActiveEditor = commandPalette; break; case ConsoleKey.N: NewEditor(); break; case ConsoleKey.O: OpenEditor(); break; case ConsoleKey.LeftArrow: { var idx = Editors.FindIndex(x => x == ActiveEditor); ActiveEditor = Editors[idx == 0 ? Editors.Count - 1 : idx - 1]; ActiveEditor.ActivateCursor(); continue; } case ConsoleKey.RightArrow: { var idx = Editors.FindIndex(x => x == ActiveEditor); ActiveEditor = Editors[(idx + 1) % Editors.Count]; ActiveEditor.ActivateCursor(); continue; } } } if (Editors.Count == 0 && !commandPalette.Focused) { continue; } bool redraw = false; switch (keyInfo.Key) { case ConsoleKey.UpArrow: if (keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control)) redraw = ActiveEditor.HandleInput(EditorInput.ControlUpArrow); else redraw = ActiveEditor.HandleInput(EditorInput.UpArrow); break; case ConsoleKey.DownArrow: if (keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control)) redraw = ActiveEditor.HandleInput(EditorInput.ControlDownArrow); else redraw = ActiveEditor.HandleInput(EditorInput.DownArrow); break; case ConsoleKey.LeftArrow: redraw = ActiveEditor.HandleInput(EditorInput.LeftArrow); break; case ConsoleKey.RightArrow: redraw = ActiveEditor.HandleInput(EditorInput.RightArrow); break; case ConsoleKey.Enter: // I dont f*****g care, sue me // This is why we need to f*****g refactor redraw = ActiveEditor.HandleInput(EditorInput.Enter); if (ActiveEditor is CommandPalette && lastEditor != null) { ActiveEditor = lastEditor; RedrawEditors(); } else if(Editors.Count == 0) { lastEditor = null; ActiveEditor = null; _console.ResetColor(); _console.Clear(); _console.CursorTop = 2; _console.CursorLeft = 4; _console.Write("* No editors! Press Ctrl+N to create or Ctrl+O to open!"); continue; } break; case ConsoleKey.Backspace: redraw = ActiveEditor.HandleInput(EditorInput.Backspace); break; case ConsoleKey.Tab: if (keyInfo.Modifiers.HasFlag(ConsoleModifiers.Shift)) redraw = ActiveEditor.HandleInput(EditorInput.ShiftTab); else redraw = ActiveEditor.HandleInput(EditorInput.Tab); break; case ConsoleKey.Home: if (keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control)) redraw = ActiveEditor.HandleInput(EditorInput.ControlHome); else redraw = ActiveEditor.HandleInput(EditorInput.Home); break; case ConsoleKey.End: if (keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control)) redraw = ActiveEditor.HandleInput(EditorInput.ControlEnd); else redraw = ActiveEditor.HandleInput(EditorInput.End); break; case ConsoleKey.PageDown: if (keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control)) redraw = ActiveEditor.HandleInput(EditorInput.ControlPageDown); else redraw = ActiveEditor.HandleInput(EditorInput.PageDown); break; case ConsoleKey.PageUp: if (keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control)) redraw = ActiveEditor.HandleInput(EditorInput.ControlPageUp); else redraw = ActiveEditor.HandleInput(EditorInput.PageUp); break; case ConsoleKey.Delete: redraw = ActiveEditor.HandleInput(EditorInput.Delete); break; } if (!Char.IsControl(keyInfo.KeyChar)) { redraw = ActiveEditor.HandleInput(keyInfo.KeyChar.ToString()); } if (redraw) { ActiveEditor.AdjustWindow(); ActiveEditor.Render(); } else if (ActiveEditor.AdjustWindow()) { ActiveEditor.Render(); } ActiveEditor.ActivateCursor(); } }