// process events
internal static void KeyDown(object sender, KeyboardKeyEventArgs e)
{
switch (e.Key)
{
case Key.LShift:
case Key.RShift:
ShiftPressed = true;
break;
case Key.F5:
// reset
ReducedMode = false;
LightingRelative = -1.0;
Game.Reset();
TextureManager.UnuseAllTextures();
Fonts.Initialize();
Interface.ClearMessages();
for (int i = 0; i < Files.Length; i++)
{
#if !DEBUG
try {
#endif
ObjectManager.UnifiedObject o = ObjectManager.LoadObject(Files[i], System.Text.Encoding.UTF8,
ObjectManager.ObjectLoadMode.Normal, false, false, false);
ObjectManager.CreateObject(o, new Vector3(0.0, 0.0, 0.0),
new World.Transformation(0.0, 0.0, 0.0), new World.Transformation(0.0, 0.0, 0.0), true, 0.0,
0.0, 25.0, 0.0);
#if !DEBUG
}
catch (Exception ex) {
Interface.AddMessage(Interface.MessageType.Critical, false, "Unhandled error (" + ex.Message + ") encountered while processing the file " + Files[i] + ".");
}
#endif
}
ObjectManager.InitializeVisibility();
ObjectManager.UpdateVisibility(0.0, true);
ObjectManager.UpdateAnimatedWorldObjects(0.01, true);
break;
case Key.F7:
{
OpenFileDialog Dialog = new OpenFileDialog();
Dialog.CheckFileExists = true;
Dialog.Multiselect = true;
Dialog.Filter = "CSV/B3D/X/ANIMATED files|*.csv;*.b3d;*.x;*.animated;*.l3dobj;*.l3dgrp|All files|*";
if (Dialog.ShowDialog() == DialogResult.OK)
{
Application.DoEvents();
string[] f = Dialog.FileNames;
int n = Files.Length;
Array.Resize <string>(ref Files, n + f.Length);
for (int i = 0; i < f.Length; i++)
{
Files[n + i] = f[i];
}
// reset
ReducedMode = false;
LightingRelative = -1.0;
Game.Reset();
TextureManager.UnuseAllTextures();
Fonts.Initialize();
Interface.ClearMessages();
for (int i = 0; i < Files.Length; i++)
{
#if !DEBUG
try
{
#endif
ObjectManager.UnifiedObject o = ObjectManager.LoadObject(Files[i], System.Text.Encoding.UTF8,
ObjectManager.ObjectLoadMode.Normal, false, false, false);
ObjectManager.CreateObject(o, new Vector3(0.0, 0.0, 0.0),
new World.Transformation(0.0, 0.0, 0.0), new World.Transformation(0.0, 0.0, 0.0), true, 0.0, 0.0, 25.0,
0.0);
#if !DEBUG
}
catch (Exception ex)
{
Interface.AddMessage(Interface.MessageType.Critical, false,
"Unhandled error (" + ex.Message + ") encountered while processing the file " +
Files[i] + ".");
}
#endif
}
ObjectManager.InitializeVisibility();
ObjectManager.FinishCreatingObjects();
ObjectManager.UpdateVisibility(0.0, true);
ObjectManager.UpdateAnimatedWorldObjects(0.01, true);
}
else
{
if (Program.CurrentlyRunOnMono)
{
//HACK: Dialog doesn't close properly when pressing the ESC key under Mono
//Avoid calling Application.DoEvents() unless absolutely necessary though!
Application.DoEvents();
}
}
Dialog.Dispose();
}
break;
case Key.F9:
if (Interface.MessageCount != 0)
{
formMessages.ShowMessages();
Application.DoEvents();
}
break;
case Key.Delete:
ReducedMode = false;
LightingRelative = -1.0;
Game.Reset();
TextureManager.UnuseAllTextures();
Fonts.Initialize();
Interface.ClearMessages();
Files = new string[] {};
break;
case Key.Left:
RotateX = -1;
ReducedMode = false;
break;
case Key.Right:
RotateX = 1;
ReducedMode = false;
break;
case Key.Up:
RotateY = -1;
ReducedMode = false;
break;
case Key.Down:
RotateY = 1;
ReducedMode = false;
break;
case Key.A:
case Key.Keypad4:
MoveX = -1;
ReducedMode = false;
break;
case Key.D:
case Key.Keypad6:
MoveX = 1;
ReducedMode = false;
break;
case Key.Keypad8:
MoveY = 1;
ReducedMode = false;
break;
case Key.Keypad2:
MoveY = -1;
ReducedMode = false;
break;
case Key.W:
case Key.Keypad9:
MoveZ = 1;
ReducedMode = false;
break;
case Key.S:
case Key.Keypad3:
MoveZ = -1;
ReducedMode = false;
break;
case Key.Keypad5:
ResetCamera();
break;
case Key.F:
case Key.F1:
Renderer.OptionWireframe = !Renderer.OptionWireframe;
if (Renderer.OptionWireframe)
{
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
}
else
{
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
}
break;
case Key.N:
case Key.F2:
Renderer.OptionNormals = !Renderer.OptionNormals;
break;
case Key.L:
case Key.F3:
LightingTarget = 1 - LightingTarget;
ReducedMode = false;
break;
case Key.I:
case Key.F4:
Renderer.OptionInterface = !Renderer.OptionInterface;
ReducedMode = false;
break;
case Key.F8:
formOptions.ShowOptions();
Application.DoEvents();
break;
case Key.G:
case Key.C:
Renderer.OptionCoordinateSystem = !Renderer.OptionCoordinateSystem;
ReducedMode = false;
break;
case Key.B:
if (ShiftPressed)
{
ColorDialog dialog = new ColorDialog();
dialog.FullOpen = true;
if (dialog.ShowDialog() == DialogResult.OK)
{
Renderer.BackgroundColor = -1;
Renderer.ApplyBackgroundColor(dialog.Color.R, dialog.Color.G, dialog.Color.B);
}
}
else
{
Renderer.BackgroundColor++;
if (Renderer.BackgroundColor >= Renderer.MaxBackgroundColor)
{
Renderer.BackgroundColor = 0;
}
Renderer.ApplyBackgroundColor();
}
ReducedMode = false;
break;
}
}