This commit is contained in:
codeimp 2007-11-14 22:53:48 +00:00
parent c2c7895364
commit 0d5c6c7457
6 changed files with 54 additions and 17 deletions

View file

@ -249,7 +249,7 @@ namespace CodeImp.DoomBuilder.Editing
#endregion
#region ================== Mouse input
#region ================== Input
// Mouse leaves the display
public override void MouseLeave(EventArgs e)

View file

@ -175,6 +175,7 @@ namespace CodeImp.DoomBuilder.Editing
public override void Disengage()
{
base.Disengage();
Cursor.Current = Cursors.WaitCursor;
// When not cancelled
if(!cancelled)
@ -204,6 +205,7 @@ namespace CodeImp.DoomBuilder.Editing
// Uncheck vertices button on main window
General.MainWindow.SetVerticesChecked(false);
Cursor.Current = Cursors.Default;
}
// This redraws the display
@ -225,12 +227,11 @@ namespace CodeImp.DoomBuilder.Editing
}
}
// Mouse moving
public override void MouseMove(MouseEventArgs e)
// This updates the dragging
private void Update()
{
base.MouseMove(e);
snaptogrid = !General.MainWindow.ShiftState;
// Move selected geometry
if(MoveGeometryRelative(mousemappos - dragstartmappos, snaptogrid))
{
@ -242,6 +243,13 @@ namespace CodeImp.DoomBuilder.Editing
}
}
// Mouse moving
public override void MouseMove(MouseEventArgs e)
{
base.MouseMove(e);
Update();
}
// Mouse button released
public override void MouseUp(MouseEventArgs e)
{
@ -254,6 +262,20 @@ namespace CodeImp.DoomBuilder.Editing
General.Map.ChangeMode(new VerticesMode());
}
}
// When a key is released
public override void KeyUp(KeyEventArgs e)
{
base.KeyUp(e);
if(snaptogrid != !General.MainWindow.ShiftState) Update();
}
// When a key is pressed
public override void KeyDown(KeyEventArgs e)
{
base.KeyDown(e);
if(snaptogrid != !General.MainWindow.ShiftState) Update();
}
#endregion
}

View file

@ -146,6 +146,8 @@ namespace CodeImp.DoomBuilder.Editing
public virtual void MouseUp(MouseEventArgs e) { }
public virtual void RedrawDisplay() { }
public virtual void RefreshDisplay() { }
public virtual void KeyDown(KeyEventArgs e) { }
public virtual void KeyUp(KeyEventArgs e) { }
#endregion
}

View file

@ -526,6 +526,7 @@ namespace CodeImp.DoomBuilder
// Clean up
if(map != null) map.Dispose();
map = null;
mainwindow.Dispose();
actions.Dispose();
clock.Dispose();

View file

@ -610,6 +610,9 @@ namespace CodeImp.DoomBuilder.Interface
// Invoke any actions associated with this key
General.Actions.InvokeByKey((int)e.KeyData);
// Invoke on editing mode
if(General.Map != null) General.Map.Mode.KeyDown(e);
}
// When a key is released
@ -619,6 +622,9 @@ namespace CodeImp.DoomBuilder.Interface
alt = e.Alt;
shift = e.Shift;
ctrl = e.Control;
// Invoke on editing mode
if(General.Map != null) General.Map.Mode.KeyUp(e);
}
#endregion

View file

@ -96,34 +96,39 @@ namespace CodeImp.DoomBuilder.Rendering
// This draws a pixel normally
public void DrawVertexSolid(int x, int y, int size, PixelColor c, PixelColor l, PixelColor d)
{
int x1 = x - size;
int x2 = x + size;
int y1 = y - size;
int y2 = y + size;
int xp, yp;
// Do unchecked?
if((x - size >= 0) && (x + size < visiblewidth) && (y - size >= 0) && (y + size < visibleheight))
if((x1 >= 0) && (x2 < visiblewidth) && (y1 >= 0) && (y2 < visibleheight))
{
// Filled square
for(yp = y - size; yp <= y + size; yp++)
for(xp = x - size; xp <= x + size; xp++)
for(yp = y1; yp <= y2; yp++)
for(xp = x1; xp <= x2; xp++)
pixels[yp * width + xp] = c;
// Vertical edges
for(yp = y - size + 1; yp <= y + size - 1; yp++)
for(yp = y1 + 1; yp <= y2 - 1; yp++)
{
pixels[yp * width + (x - size)] = l;
pixels[yp * width + (x + size)] = d;
pixels[yp * width + x1] = l;
pixels[yp * width + x2] = d;
}
// Horizontal edges
for(xp = x - size + 1; xp <= x + size - 1; xp++)
for(xp = x1 + 1; xp <= x2 - 1; xp++)
{
pixels[(y - size) * width + xp] = l;
pixels[(y + size) * width + xp] = d;
pixels[y1 * width + xp] = l;
pixels[y2 * width + xp] = d;
}
// Corners
pixels[(y + size) * width + (x + size)] = d;
pixels[(y - size) * width + (x - size)] = l;
pixels[y2 * width + x2] = d;
pixels[y1 * width + x1] = l;
}
/*
else
{
// Filled square
@ -149,6 +154,7 @@ namespace CodeImp.DoomBuilder.Rendering
DrawPixelSolid(x + size, y + size, d);
DrawPixelSolid(x - size, y - size, l);
}
*/
}
// This draws a dotted grid line horizontally