mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-22 20:02:48 +00:00
open map dialog added
This commit is contained in:
parent
c14e45f7c5
commit
a2d62cae12
20 changed files with 1107 additions and 109 deletions
|
@ -1,10 +1,10 @@
|
|||
|
||||
mainwindow
|
||||
{
|
||||
positionx = 27;
|
||||
sizeheight = 572;
|
||||
positiony = 15;
|
||||
positionx = 209;
|
||||
windowstate = 2;
|
||||
positiony = 137;
|
||||
sizeheight = 572;
|
||||
sizewidth = 739;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,12 @@
|
|||
<Compile Include="Interface\MapOptionsForm.Designer.cs">
|
||||
<DependentUpon>MapOptionsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Interface\OpenMapOptionsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Interface\OpenMapOptionsForm.Designer.cs">
|
||||
<DependentUpon>OpenMapOptionsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Interface\ResourceOptionsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
@ -74,6 +80,7 @@
|
|||
<Compile Include="IO\Configuration.cs" />
|
||||
<Compile Include="General\General.cs" />
|
||||
<Compile Include="IO\ClippedStream.cs" />
|
||||
<Compile Include="IO\DoomMapSetIO.cs" />
|
||||
<Compile Include="IO\IMapSetIO.cs" />
|
||||
<Compile Include="IO\Lump.cs" />
|
||||
<Compile Include="IO\WAD.cs" />
|
||||
|
@ -123,6 +130,10 @@
|
|||
<SubType>Designer</SubType>
|
||||
<DependentUpon>MapOptionsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Interface\OpenMapOptionsForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>OpenMapOptionsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Interface\ResourceOptionsForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>ResourceOptionsForm.cs</DependentUpon>
|
||||
|
|
|
@ -99,6 +99,15 @@ namespace CodeImp.DoomBuilder
|
|||
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return null;
|
||||
}
|
||||
// Check if this is a Doom Builder 1 config
|
||||
else if(cfg.ReadSetting("type", "") != "Doom Builder 2 Game Configuration")
|
||||
{
|
||||
// Old configuration
|
||||
MessageBox.Show(mainwindow, "Unable to load the game configuration file \"" + filename + "\".\n" +
|
||||
"This configuration is not a Doom Builder 2 game configuration.",
|
||||
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Return config
|
||||
|
@ -132,7 +141,7 @@ namespace CodeImp.DoomBuilder
|
|||
foreach(string filepath in filenames)
|
||||
{
|
||||
// Check if it can be loaded
|
||||
cfg = LoadGameConfiguration(filepath);
|
||||
cfg = LoadGameConfiguration(Path.GetFileName(filepath));
|
||||
if(cfg != null)
|
||||
{
|
||||
// Get name and filename
|
||||
|
@ -177,6 +186,7 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// Create main window
|
||||
mainwindow = new MainForm();
|
||||
mainwindow.UpdateMenus();
|
||||
|
||||
// Show main window
|
||||
mainwindow.Show();
|
||||
|
@ -223,9 +233,6 @@ namespace CodeImp.DoomBuilder
|
|||
// Open map options dialog
|
||||
optionswindow = new MapOptionsForm(newoptions);
|
||||
if(optionswindow.ShowDialog(mainwindow) == DialogResult.OK)
|
||||
{
|
||||
// Ask to save the map if not saved yet
|
||||
if(AskSaveMap())
|
||||
{
|
||||
// Display status
|
||||
mainwindow.DisplayStatus("Creating new map...");
|
||||
|
@ -253,22 +260,11 @@ namespace CodeImp.DoomBuilder
|
|||
return false;
|
||||
}
|
||||
|
||||
// TEST:
|
||||
Vertex v1 = map.Data.CreateVertex(new Vector2D(20f, 20f));
|
||||
Vertex v2 = map.Data.CreateVertex(new Vector2D(-20f, 20f));
|
||||
Vertex v3 = map.Data.CreateVertex(new Vector2D(-20f, -20f));
|
||||
Vertex v4 = map.Data.CreateVertex(new Vector2D(20f, -20f));
|
||||
map.Data.CreateLinedef(v1, v2);
|
||||
map.Data.CreateLinedef(v2, v3);
|
||||
map.Data.CreateLinedef(v3, v4);
|
||||
map.Data.CreateLinedef(v4, v1);
|
||||
|
||||
// Done
|
||||
mainwindow.UpdateMenus();
|
||||
mainwindow.DisplayReady();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Cancelled
|
||||
return false;
|
||||
|
@ -276,9 +272,6 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// This closes the current map
|
||||
public static bool CloseMap()
|
||||
{
|
||||
// Ask to save the map if not saved yet
|
||||
if(AskSaveMap())
|
||||
{
|
||||
// Display status
|
||||
mainwindow.DisplayStatus("Closing map...");
|
||||
|
@ -295,16 +288,66 @@ namespace CodeImp.DoomBuilder
|
|||
mainwindow.DisplayReady();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
||||
// This loads a map from file
|
||||
public static bool OpenMap()
|
||||
{
|
||||
// Cancelled
|
||||
OpenFileDialog openfile;
|
||||
OpenMapOptionsForm openmapwindow;
|
||||
|
||||
// Open map file dialog
|
||||
openfile = new OpenFileDialog();
|
||||
openfile.Filter = "Doom WAD Files (*.wad)|*.wad";
|
||||
openfile.Title = "Open Map";
|
||||
if(openfile.ShowDialog(mainwindow) == DialogResult.OK)
|
||||
{
|
||||
// Update main window
|
||||
mainwindow.Update();
|
||||
|
||||
// Open map options dialog
|
||||
openmapwindow = new OpenMapOptionsForm(openfile.FileName);
|
||||
if(openmapwindow.ShowDialog(mainwindow) == DialogResult.OK)
|
||||
{
|
||||
// Display status
|
||||
mainwindow.DisplayStatus("Opening map file...");
|
||||
|
||||
// Clear the display
|
||||
mainwindow.ClearDisplay();
|
||||
|
||||
// Trash the current map, if any
|
||||
if(map != null) map.Dispose();
|
||||
|
||||
// Create map manager with given options
|
||||
map = new MapManager();
|
||||
if(!map.InitializeOpenMap(openfile.FileName, openmapwindow.Options))
|
||||
{
|
||||
// Unable to create map manager
|
||||
map.Dispose();
|
||||
map = null;
|
||||
|
||||
// Show splash logo on display
|
||||
mainwindow.ShowSplashDisplay();
|
||||
|
||||
// Failed
|
||||
mainwindow.UpdateMenus();
|
||||
mainwindow.DisplayReady();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Done
|
||||
mainwindow.UpdateMenus();
|
||||
mainwindow.DisplayReady();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Cancelled
|
||||
return false;
|
||||
}
|
||||
|
||||
// This asks to save the map if needed
|
||||
// Returns false when action was cancelled
|
||||
private static bool AskSaveMap()
|
||||
public static bool AskSaveMap()
|
||||
{
|
||||
DialogResult result;
|
||||
|
||||
|
|
|
@ -112,9 +112,33 @@ namespace CodeImp.DoomBuilder
|
|||
this.options = options;
|
||||
|
||||
// Create objects
|
||||
data = new MapSet();
|
||||
graphics = new Graphics(General.MainWindow.Display);
|
||||
config = General.LoadGameConfiguration(options.ConfigFile);
|
||||
data = new MapSet();
|
||||
|
||||
// Initiate graphics
|
||||
if(!graphics.Initialize()) return false;
|
||||
|
||||
// Set default mode
|
||||
ChangeMode(typeof(FrozenOverviewMode));
|
||||
|
||||
// Success
|
||||
return true;
|
||||
}
|
||||
|
||||
// Initializes for an existing map
|
||||
public bool InitializeOpenMap(string filepathname, MapOptions options)
|
||||
{
|
||||
// Apply settings
|
||||
this.filetitle = Path.GetFileName(filepathname);
|
||||
this.filepathname = filepathname;
|
||||
this.changed = false;
|
||||
this.options = options;
|
||||
|
||||
// Create objects
|
||||
graphics = new Graphics(General.MainWindow.Display);
|
||||
config = General.LoadGameConfiguration(options.ConfigFile);
|
||||
data = new MapSet();
|
||||
|
||||
// Initiate graphics
|
||||
if(!graphics.Initialize()) return false;
|
||||
|
@ -152,6 +176,9 @@ namespace CodeImp.DoomBuilder
|
|||
Debug.WriteLine(e.InnerException.StackTrace);
|
||||
throw e.InnerException;
|
||||
}
|
||||
|
||||
// Redraw the display
|
||||
mode.RedrawDisplay();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -79,14 +79,14 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// Not already disposed?
|
||||
if(!isdisposed)
|
||||
{
|
||||
// Already set isdisposed to prevent recursion
|
||||
isdisposed = true;
|
||||
|
||||
// Clean up
|
||||
basestream = null;
|
||||
|
||||
// Dispose base
|
||||
base.Dispose();
|
||||
|
||||
// Done
|
||||
isdisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// This closes the stream
|
||||
public override void Close()
|
||||
{
|
||||
basestream.Close();
|
||||
basestream = null;
|
||||
base.Close();
|
||||
this.Dispose();
|
||||
}
|
||||
|
|
|
@ -967,14 +967,14 @@ namespace CodeImp.DoomBuilder.IO
|
|||
{
|
||||
// Output the value with a postfixed f
|
||||
db.Append(leveltabs); db.Append(de.Key); db.Append(spacing); db.Append("=");
|
||||
db.Append(spacing); db.Append(de.Value); db.Append("f;"); db.Append(newline);
|
||||
db.Append(spacing); db.Append(String.Format(CultureInfo.InvariantCulture, "{0}", de.Value)); db.Append("f;"); db.Append(newline);
|
||||
}
|
||||
// Check if value is of other numeric type
|
||||
else if(de.Value.GetType().IsPrimitive)
|
||||
{
|
||||
// Output the value unquoted
|
||||
db.Append(leveltabs); db.Append(de.Key); db.Append(spacing); db.Append("=");
|
||||
db.Append(spacing); db.Append(de.Value); db.Append(";"); db.Append(newline);
|
||||
db.Append(spacing); db.Append(String.Format(CultureInfo.InvariantCulture, "{0}", de.Value)); db.Append(";"); db.Append(newline);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
59
Source/IO/DoomMapSetIO.cs
Normal file
59
Source/IO/DoomMapSetIO.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace CodeImp.DoomBuilder.IO
|
||||
{
|
||||
internal class DoomMapSetIO : IDisposable
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
// Disposing
|
||||
private bool isdisposed = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
// Disposing
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public DoomMapSetIO()
|
||||
{
|
||||
// Initialize
|
||||
|
||||
// We have no destructor
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
// Diposer
|
||||
public void Dispose()
|
||||
{
|
||||
// Not already disposed?
|
||||
if(!isdisposed)
|
||||
{
|
||||
// Clean up
|
||||
|
||||
// Done
|
||||
isdisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -102,8 +102,13 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// This makes the normal name from fixed name
|
||||
private static string MakeNormalName(byte[] fixedname, Encoding encoding)
|
||||
{
|
||||
// Return the name as a string
|
||||
return encoding.GetString(fixedname);
|
||||
int length = 0;
|
||||
|
||||
// Figure out the length of the lump name
|
||||
while((length < fixedname.Length) && (fixedname[length] != 0)) length++;
|
||||
|
||||
// Make normal name
|
||||
return encoding.GetString(fixedname, 0, length);
|
||||
}
|
||||
|
||||
// This makes the fixed name from normal name
|
||||
|
|
63
Source/Interface/MainForm.Designer.cs
generated
63
Source/Interface/MainForm.Designer.cs
generated
|
@ -41,17 +41,16 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
this.itemsavemapinto = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.itemexit = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuhelp = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.itemhelpabout = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolbar = new System.Windows.Forms.ToolStrip();
|
||||
this.statusbar = new System.Windows.Forms.StatusStrip();
|
||||
this.statuslabel = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.panelinfo = new System.Windows.Forms.Panel();
|
||||
this.display = new System.Windows.Forms.PictureBox();
|
||||
this.redrawtimer = new System.Windows.Forms.Timer(this.components);
|
||||
this.menuhelp = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.itemhelpabout = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.display = new System.Windows.Forms.Panel();
|
||||
this.menumain.SuspendLayout();
|
||||
this.statusbar.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.display)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// menumain
|
||||
|
@ -93,6 +92,7 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
this.itemopenmap.Name = "itemopenmap";
|
||||
this.itemopenmap.Size = new System.Drawing.Size(167, 22);
|
||||
this.itemopenmap.Text = "Open Map...";
|
||||
this.itemopenmap.Click += new System.EventHandler(this.itemopenmap_Click);
|
||||
//
|
||||
// itemclosemap
|
||||
//
|
||||
|
@ -136,6 +136,21 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
this.itemexit.Text = "Exit";
|
||||
this.itemexit.Click += new System.EventHandler(this.itemexit_Click);
|
||||
//
|
||||
// menuhelp
|
||||
//
|
||||
this.menuhelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.itemhelpabout});
|
||||
this.menuhelp.Name = "menuhelp";
|
||||
this.menuhelp.Size = new System.Drawing.Size(40, 20);
|
||||
this.menuhelp.Text = "Help";
|
||||
//
|
||||
// itemhelpabout
|
||||
//
|
||||
this.itemhelpabout.Name = "itemhelpabout";
|
||||
this.itemhelpabout.Size = new System.Drawing.Size(191, 22);
|
||||
this.itemhelpabout.Text = "About Doom Builder...";
|
||||
this.itemhelpabout.Click += new System.EventHandler(this.itemhelpabout_Click);
|
||||
//
|
||||
// toolbar
|
||||
//
|
||||
this.toolbar.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
|
||||
|
@ -172,48 +187,32 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
this.panelinfo.Size = new System.Drawing.Size(731, 101);
|
||||
this.panelinfo.TabIndex = 4;
|
||||
//
|
||||
// redrawtimer
|
||||
//
|
||||
this.redrawtimer.Interval = 1;
|
||||
this.redrawtimer.Tick += new System.EventHandler(this.redrawtimer_Tick);
|
||||
//
|
||||
// display
|
||||
//
|
||||
this.display.BackColor = System.Drawing.SystemColors.AppWorkspace;
|
||||
this.display.BackgroundImage = global::CodeImp.DoomBuilder.Properties.Resources.Splash2;
|
||||
this.display.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.display.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
||||
this.display.CausesValidation = false;
|
||||
this.display.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.display.ErrorImage = null;
|
||||
this.display.InitialImage = null;
|
||||
this.display.Location = new System.Drawing.Point(0, 49);
|
||||
this.display.Name = "display";
|
||||
this.display.Size = new System.Drawing.Size(731, 373);
|
||||
this.display.TabIndex = 5;
|
||||
this.display.TabStop = false;
|
||||
this.display.MouseLeave += new System.EventHandler(this.display_MouseLeave);
|
||||
this.display.MouseDown += new System.Windows.Forms.MouseEventHandler(this.display_MouseDown);
|
||||
this.display.MouseMove += new System.Windows.Forms.MouseEventHandler(this.display_MouseMove);
|
||||
this.display.Paint += new System.Windows.Forms.PaintEventHandler(this.display_Paint);
|
||||
this.display.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.display_MouseDoubleClick);
|
||||
this.display.MouseClick += new System.Windows.Forms.MouseEventHandler(this.display_MouseClick);
|
||||
this.display.MouseUp += new System.Windows.Forms.MouseEventHandler(this.display_MouseUp);
|
||||
this.display.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.display_MouseDoubleClick);
|
||||
this.display.Resize += new System.EventHandler(this.display_Resize);
|
||||
this.display.MouseEnter += new System.EventHandler(this.display_MouseEnter);
|
||||
//
|
||||
// redrawtimer
|
||||
//
|
||||
this.redrawtimer.Interval = 1;
|
||||
this.redrawtimer.Tick += new System.EventHandler(this.redrawtimer_Tick);
|
||||
//
|
||||
// menuhelp
|
||||
//
|
||||
this.menuhelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.itemhelpabout});
|
||||
this.menuhelp.Name = "menuhelp";
|
||||
this.menuhelp.Size = new System.Drawing.Size(40, 20);
|
||||
this.menuhelp.Text = "Help";
|
||||
//
|
||||
// itemhelpabout
|
||||
//
|
||||
this.itemhelpabout.Name = "itemhelpabout";
|
||||
this.itemhelpabout.Size = new System.Drawing.Size(191, 22);
|
||||
this.itemhelpabout.Text = "About Doom Builder...";
|
||||
this.itemhelpabout.Click += new System.EventHandler(this.itemhelpabout_Click);
|
||||
this.display.Paint += new System.Windows.Forms.PaintEventHandler(this.display_Paint);
|
||||
this.display.MouseUp += new System.Windows.Forms.MouseEventHandler(this.display_MouseUp);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
|
@ -224,7 +223,6 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
this.Controls.Add(this.statusbar);
|
||||
this.Controls.Add(this.toolbar);
|
||||
this.Controls.Add(this.menumain);
|
||||
this.DoubleBuffered = true;
|
||||
this.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.KeyPreview = true;
|
||||
|
@ -240,7 +238,6 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
this.menumain.PerformLayout();
|
||||
this.statusbar.ResumeLayout(false);
|
||||
this.statusbar.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.display)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
@ -252,7 +249,6 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
private System.Windows.Forms.ToolStrip toolbar;
|
||||
private System.Windows.Forms.StatusStrip statusbar;
|
||||
private System.Windows.Forms.Panel panelinfo;
|
||||
private System.Windows.Forms.PictureBox display;
|
||||
private System.Windows.Forms.ToolStripMenuItem menufile;
|
||||
private System.Windows.Forms.ToolStripMenuItem itemnewmap;
|
||||
private System.Windows.Forms.ToolStripMenuItem itemopenmap;
|
||||
|
@ -267,5 +263,6 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
private System.Windows.Forms.Timer redrawtimer;
|
||||
private System.Windows.Forms.ToolStripMenuItem menuhelp;
|
||||
private System.Windows.Forms.ToolStripMenuItem itemhelpabout;
|
||||
private System.Windows.Forms.Panel display;
|
||||
}
|
||||
}
|
|
@ -41,11 +41,15 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
private Point lastposition;
|
||||
private Size lastsize;
|
||||
|
||||
// Mouse in display
|
||||
private bool mouseinside;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public PictureBox Display { get { return display; } }
|
||||
public bool MouseInDisplay { get { return mouseinside; } }
|
||||
public Panel Display { get { return display; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -163,7 +167,7 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
// Change display to show splash logo
|
||||
display.BackColor = System.Drawing.SystemColors.AppWorkspace;
|
||||
display.BackgroundImage = global::CodeImp.DoomBuilder.Properties.Resources.Splash2;
|
||||
display.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
//display.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.Update();
|
||||
}
|
||||
|
||||
|
@ -173,7 +177,7 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
// Clear the display
|
||||
display.BackColor = Color.Black;
|
||||
display.BackgroundImage = null;
|
||||
display.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Tile;
|
||||
//display.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Tile;
|
||||
this.Update();
|
||||
}
|
||||
|
||||
|
@ -194,6 +198,19 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
if(General.Map != null) General.Map.Mode.RedrawDisplay();
|
||||
}
|
||||
|
||||
// Display size changes
|
||||
private void display_Resize(object sender, EventArgs e)
|
||||
{
|
||||
// Reset graphics to match changes
|
||||
if(General.Map != null) General.Map.Graphics.Reset();
|
||||
|
||||
// Make sure control is repainted
|
||||
display.Update();
|
||||
|
||||
// Redraw display
|
||||
if(General.Map != null) General.Map.Mode.RedrawDisplay();
|
||||
}
|
||||
|
||||
// Mouse click
|
||||
private void display_MouseClick(object sender, MouseEventArgs e) { if(General.Map != null) General.Map.Mode.MouseClick(e); }
|
||||
|
||||
|
@ -204,10 +221,18 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
private void display_MouseDown(object sender, MouseEventArgs e) { if(General.Map != null) General.Map.Mode.MouseDown(e); }
|
||||
|
||||
// Mouse enters
|
||||
private void display_MouseEnter(object sender, EventArgs e) { if(General.Map != null) General.Map.Mode.MouseEnter(e); }
|
||||
private void display_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
mouseinside = true;
|
||||
if(General.Map != null) General.Map.Mode.MouseEnter(e);
|
||||
}
|
||||
|
||||
// Mouse leaves
|
||||
private void display_MouseLeave(object sender, EventArgs e) { if(General.Map != null) General.Map.Mode.MouseLeave(e); }
|
||||
private void display_MouseLeave(object sender, EventArgs e)
|
||||
{
|
||||
mouseinside = false;
|
||||
if(General.Map != null) General.Map.Mode.MouseLeave(e);
|
||||
}
|
||||
|
||||
// Mouse moves
|
||||
private void display_MouseMove(object sender, MouseEventArgs e) { if(General.Map != null) General.Map.Mode.MouseMove(e); }
|
||||
|
@ -231,10 +256,13 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
#region ================== File Menu
|
||||
|
||||
// New map clicked
|
||||
private void itemnewmap_Click(object sender, EventArgs e) { General.NewMap(); }
|
||||
private void itemnewmap_Click(object sender, EventArgs e) { if(General.AskSaveMap()) General.NewMap(); }
|
||||
|
||||
// Open map clicked
|
||||
private void itemopenmap_Click(object sender, EventArgs e) { if(General.AskSaveMap()) General.OpenMap(); }
|
||||
|
||||
// Close map clicked
|
||||
private void itemclosemap_Click(object sender, EventArgs e) { General.CloseMap(); }
|
||||
private void itemclosemap_Click(object sender, EventArgs e) { if(General.AskSaveMap()) General.CloseMap(); }
|
||||
|
||||
// Exit clicked
|
||||
private void itemexit_Click(object sender, EventArgs e) { this.Close(); }
|
||||
|
|
|
@ -117,12 +117,12 @@
|
|||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menumain.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="menumain.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="menumain.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="toolbar.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
|
@ -138,12 +138,12 @@
|
|||
<metadata name="panelinfo.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="display.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="redrawtimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>304, 17</value>
|
||||
</metadata>
|
||||
<metadata name="display.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
|
||||
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
||||
* This program is released under GNU General Public License
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
@ -6,6 +24,8 @@ using System.Text;
|
|||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Interface
|
||||
{
|
||||
internal partial class MapOptionsForm : Form
|
||||
|
@ -91,9 +111,14 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
private void addresource_Click(object sender, EventArgs e)
|
||||
{
|
||||
ResourceOptionsForm resoptions;
|
||||
Point startposition;
|
||||
|
||||
// Open resource options dialog
|
||||
resoptions = new ResourceOptionsForm(new ResourceLocation(), "Add Resource");
|
||||
resoptions.StartPosition = FormStartPosition.Manual;
|
||||
startposition = this.Location;
|
||||
startposition.Offset(50, 160);
|
||||
resoptions.Location = startposition;
|
||||
if(resoptions.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
// Add resource
|
||||
|
@ -105,12 +130,17 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
private void editresource_Click(object sender, EventArgs e)
|
||||
{
|
||||
ResourceOptionsForm resoptions;
|
||||
Point startposition;
|
||||
|
||||
// Anything selected?
|
||||
if(resources.SelectedIndex > -1)
|
||||
{
|
||||
// Open resource options dialog
|
||||
resoptions = new ResourceOptionsForm((ResourceLocation)resources.SelectedItem, "Resource Options");
|
||||
resoptions.StartPosition = FormStartPosition.Manual;
|
||||
startposition = this.Location;
|
||||
startposition.Offset(50, 160);
|
||||
resoptions.Location = startposition;
|
||||
if(resoptions.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
// Replace resource
|
||||
|
|
217
Source/Interface/OpenMapOptionsForm.Designer.cs
generated
Normal file
217
Source/Interface/OpenMapOptionsForm.Designer.cs
generated
Normal file
|
@ -0,0 +1,217 @@
|
|||
namespace CodeImp.DoomBuilder.Interface
|
||||
{
|
||||
partial class OpenMapOptionsForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if(disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.panelres = new System.Windows.Forms.GroupBox();
|
||||
this.deleteresource = new System.Windows.Forms.Button();
|
||||
this.editresource = new System.Windows.Forms.Button();
|
||||
this.addresource = new System.Windows.Forms.Button();
|
||||
this.resources = new System.Windows.Forms.ListBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.apply = new System.Windows.Forms.Button();
|
||||
this.cancel = new System.Windows.Forms.Button();
|
||||
this.config = new System.Windows.Forms.ComboBox();
|
||||
this.mapslist = new System.Windows.Forms.ListView();
|
||||
this.panelres.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panelres
|
||||
//
|
||||
this.panelres.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.panelres.Controls.Add(this.deleteresource);
|
||||
this.panelres.Controls.Add(this.editresource);
|
||||
this.panelres.Controls.Add(this.addresource);
|
||||
this.panelres.Controls.Add(this.resources);
|
||||
this.panelres.Location = new System.Drawing.Point(12, 214);
|
||||
this.panelres.Name = "panelres";
|
||||
this.panelres.Size = new System.Drawing.Size(365, 165);
|
||||
this.panelres.TabIndex = 11;
|
||||
this.panelres.TabStop = false;
|
||||
this.panelres.Text = " Custom Resources ";
|
||||
//
|
||||
// deleteresource
|
||||
//
|
||||
this.deleteresource.Enabled = false;
|
||||
this.deleteresource.Location = new System.Drawing.Point(268, 125);
|
||||
this.deleteresource.Name = "deleteresource";
|
||||
this.deleteresource.Size = new System.Drawing.Size(74, 25);
|
||||
this.deleteresource.TabIndex = 13;
|
||||
this.deleteresource.Text = "Remove";
|
||||
this.deleteresource.UseVisualStyleBackColor = true;
|
||||
this.deleteresource.Click += new System.EventHandler(this.deleteresource_Click);
|
||||
//
|
||||
// editresource
|
||||
//
|
||||
this.editresource.Enabled = false;
|
||||
this.editresource.Location = new System.Drawing.Point(139, 125);
|
||||
this.editresource.Name = "editresource";
|
||||
this.editresource.Size = new System.Drawing.Size(123, 25);
|
||||
this.editresource.TabIndex = 12;
|
||||
this.editresource.Text = "Resource Options...";
|
||||
this.editresource.UseVisualStyleBackColor = true;
|
||||
this.editresource.Click += new System.EventHandler(this.editresource_Click);
|
||||
//
|
||||
// addresource
|
||||
//
|
||||
this.addresource.Location = new System.Drawing.Point(21, 125);
|
||||
this.addresource.Name = "addresource";
|
||||
this.addresource.Size = new System.Drawing.Size(112, 25);
|
||||
this.addresource.TabIndex = 11;
|
||||
this.addresource.Text = "Add Resource...";
|
||||
this.addresource.UseVisualStyleBackColor = true;
|
||||
this.addresource.Click += new System.EventHandler(this.addresource_Click);
|
||||
//
|
||||
// resources
|
||||
//
|
||||
this.resources.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.resources.FormattingEnabled = true;
|
||||
this.resources.ItemHeight = 14;
|
||||
this.resources.Location = new System.Drawing.Point(21, 31);
|
||||
this.resources.Name = "resources";
|
||||
this.resources.Size = new System.Drawing.Size(321, 88);
|
||||
this.resources.TabIndex = 10;
|
||||
this.resources.SelectedIndexChanged += new System.EventHandler(this.resources_SelectedIndexChanged);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(30, 24);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(105, 14);
|
||||
this.label1.TabIndex = 14;
|
||||
this.label1.Text = "Game Configuration:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.Location = new System.Drawing.Point(12, 57);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(365, 30);
|
||||
this.label2.TabIndex = 16;
|
||||
this.label2.Text = "With the above selected configuration, the maps shown below were found in the cho" +
|
||||
"sen WAD file. Please select the map to load for editing.";
|
||||
//
|
||||
// apply
|
||||
//
|
||||
this.apply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.apply.Location = new System.Drawing.Point(147, 399);
|
||||
this.apply.Name = "apply";
|
||||
this.apply.Size = new System.Drawing.Size(112, 25);
|
||||
this.apply.TabIndex = 12;
|
||||
this.apply.Text = "OK";
|
||||
this.apply.UseVisualStyleBackColor = true;
|
||||
this.apply.Click += new System.EventHandler(this.apply_Click);
|
||||
//
|
||||
// cancel
|
||||
//
|
||||
this.cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancel.Location = new System.Drawing.Point(265, 399);
|
||||
this.cancel.Name = "cancel";
|
||||
this.cancel.Size = new System.Drawing.Size(112, 25);
|
||||
this.cancel.TabIndex = 13;
|
||||
this.cancel.Text = "Cancel";
|
||||
this.cancel.UseVisualStyleBackColor = true;
|
||||
this.cancel.Click += new System.EventHandler(this.cancel_Click);
|
||||
//
|
||||
// config
|
||||
//
|
||||
this.config.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.config.FormattingEnabled = true;
|
||||
this.config.Location = new System.Drawing.Point(141, 21);
|
||||
this.config.Name = "config";
|
||||
this.config.Size = new System.Drawing.Size(213, 22);
|
||||
this.config.TabIndex = 15;
|
||||
this.config.SelectedIndexChanged += new System.EventHandler(this.config_SelectedIndexChanged);
|
||||
//
|
||||
// mapslist
|
||||
//
|
||||
this.mapslist.AutoArrange = false;
|
||||
this.mapslist.FullRowSelect = true;
|
||||
this.mapslist.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
|
||||
this.mapslist.HideSelection = false;
|
||||
this.mapslist.LabelWrap = false;
|
||||
this.mapslist.Location = new System.Drawing.Point(12, 90);
|
||||
this.mapslist.MultiSelect = false;
|
||||
this.mapslist.Name = "mapslist";
|
||||
this.mapslist.ShowGroups = false;
|
||||
this.mapslist.Size = new System.Drawing.Size(365, 110);
|
||||
this.mapslist.Sorting = System.Windows.Forms.SortOrder.Ascending;
|
||||
this.mapslist.TabIndex = 18;
|
||||
this.mapslist.UseCompatibleStateImageBehavior = false;
|
||||
this.mapslist.View = System.Windows.Forms.View.List;
|
||||
//
|
||||
// OpenMapOptionsForm
|
||||
//
|
||||
this.AcceptButton = this.apply;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 14F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.cancel;
|
||||
this.ClientSize = new System.Drawing.Size(389, 436);
|
||||
this.Controls.Add(this.mapslist);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.config);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.cancel);
|
||||
this.Controls.Add(this.apply);
|
||||
this.Controls.Add(this.panelres);
|
||||
this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "OpenMapOptionsForm";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Open Map Options";
|
||||
this.Shown += new System.EventHandler(this.OpenMapOptionsForm_Shown);
|
||||
this.panelres.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button deleteresource;
|
||||
private System.Windows.Forms.Button editresource;
|
||||
private System.Windows.Forms.Button addresource;
|
||||
private System.Windows.Forms.ListBox resources;
|
||||
private System.Windows.Forms.Button apply;
|
||||
private System.Windows.Forms.Button cancel;
|
||||
private System.Windows.Forms.ComboBox config;
|
||||
private System.Windows.Forms.GroupBox panelres;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.ListView mapslist;
|
||||
|
||||
|
||||
}
|
||||
}
|
364
Source/Interface/OpenMapOptionsForm.cs
Normal file
364
Source/Interface/OpenMapOptionsForm.cs
Normal file
|
@ -0,0 +1,364 @@
|
|||
|
||||
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
||||
* This program is released under GNU General Public License
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Interface
|
||||
{
|
||||
internal partial class OpenMapOptionsForm : Form
|
||||
{
|
||||
// Variables
|
||||
private Configuration mapsettings;
|
||||
private MapOptions options;
|
||||
private WAD wadfile;
|
||||
private string filepathname;
|
||||
|
||||
// Properties
|
||||
public string FilePathName { get { return filepathname; } }
|
||||
public MapOptions Options { get { return options; } }
|
||||
|
||||
// Constructor
|
||||
public OpenMapOptionsForm(string filepathname)
|
||||
{
|
||||
// Initialize
|
||||
InitializeComponent();
|
||||
this.filepathname = filepathname;
|
||||
this.options = new MapOptions();
|
||||
}
|
||||
|
||||
// This loads the settings and attempt to find a suitable config
|
||||
private void LoadSettings()
|
||||
{
|
||||
string dbsfile;
|
||||
string gameconfig;
|
||||
|
||||
// Busy
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
|
||||
try
|
||||
{
|
||||
// Open the WAD file
|
||||
wadfile = new WAD(filepathname, true);
|
||||
|
||||
// Open the Map Settings configuration
|
||||
dbsfile = filepathname.Substring(0, filepathname.Length - 4) + ".dbs";
|
||||
if(File.Exists(dbsfile))
|
||||
mapsettings = new Configuration(dbsfile, true);
|
||||
else
|
||||
mapsettings = new Configuration(true);
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
// Unable to open WAD file (or its config)
|
||||
MessageBox.Show(this, "Could not open the WAD file for reading. Please make sure the file you selected is valid and is not in use by any other application.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
if(wadfile != null) wadfile.Dispose();
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Hide();
|
||||
}
|
||||
|
||||
// Check what game configuration is preferred
|
||||
gameconfig = mapsettings.ReadSetting("gameconfig", "");
|
||||
|
||||
// Go for all configurations
|
||||
for(int i = 0; i < General.Configs.Count; i++)
|
||||
{
|
||||
// Add config name to list
|
||||
config.Items.Add(General.Configs[i].name);
|
||||
|
||||
// This is the preferred game configuration?
|
||||
if(General.Configs[i].filename == gameconfig)
|
||||
{
|
||||
// Select this item
|
||||
config.SelectedIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Still no configuration selected?
|
||||
if(config.SelectedIndex == -1)
|
||||
{
|
||||
// Then go for all configurations to find a suitable one
|
||||
for(int i = 0; i < General.Configs.Count; i++)
|
||||
{
|
||||
// TODO: Check if an IWAD is set for this configuration
|
||||
|
||||
// Match the wad against this configuration
|
||||
if(MatchConfiguration(General.Configs[i].filename, wadfile))
|
||||
{
|
||||
// Select this item
|
||||
config.SelectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Done
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
|
||||
// This matches a WAD file with the specified game configuration
|
||||
// by checking if the specific lumps are detected
|
||||
private bool MatchConfiguration(string configfile, WAD wadfile)
|
||||
{
|
||||
Configuration cfg;
|
||||
IDictionary detectlumps;
|
||||
Lump lumpresult;
|
||||
bool result = false;
|
||||
|
||||
// Load the configuration
|
||||
cfg = General.LoadGameConfiguration(configfile);
|
||||
|
||||
// Get the lumps to detect
|
||||
detectlumps = cfg.ReadSetting("gamedetect", new Hashtable());
|
||||
|
||||
// Go for all the lumps
|
||||
foreach(DictionaryEntry lmp in detectlumps)
|
||||
{
|
||||
// Setting not broken?
|
||||
if((lmp.Value is int) && (lmp.Key is string))
|
||||
{
|
||||
// Find the lump in the WAD file
|
||||
lumpresult = wadfile.FindLump((string)lmp.Key);
|
||||
|
||||
// If one of these lumps must exist, and it is found
|
||||
if(((int)lmp.Value == 1) && (lumpresult != null))
|
||||
{
|
||||
// Good result.
|
||||
result = true;
|
||||
}
|
||||
// If this lumps may not exist, and it is found
|
||||
else if(((int)lmp.Value == 2) && (lumpresult != null))
|
||||
{
|
||||
// Bad result.
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
// If this lumps must exist, and it is missing
|
||||
else if(((int)lmp.Value == 3) && (lumpresult == null))
|
||||
{
|
||||
// Bad result.
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return result
|
||||
return result;
|
||||
}
|
||||
|
||||
// Configuration is selected
|
||||
private void config_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
List<ListViewItem> mapnames;
|
||||
Configuration cfg;
|
||||
IDictionary maplumpnames;
|
||||
int scanindex, checkoffset;
|
||||
int lumpsfound, lumpsrequired = 0;
|
||||
string lumpname, selectedname = "";
|
||||
|
||||
// Keep selected name, if any
|
||||
if(mapslist.SelectedItems.Count > 0)
|
||||
selectedname = mapslist.SelectedItems[0].Text;
|
||||
|
||||
// Make an array for the map names
|
||||
mapnames = new List<ListViewItem>();
|
||||
|
||||
// Load this configuration
|
||||
cfg = General.LoadGameConfiguration(General.Configs[config.SelectedIndex].filename);
|
||||
|
||||
// Get the map lump names
|
||||
maplumpnames = cfg.ReadSetting("maplumpnames", new Hashtable());
|
||||
|
||||
// Count how many required lumps we have to find
|
||||
foreach(DictionaryEntry ml in maplumpnames)
|
||||
{
|
||||
// Read lump setting and count it
|
||||
if(cfg.ReadSetting("maplumpnames." + ml.Key + ".required", false)) lumpsrequired++;
|
||||
}
|
||||
|
||||
// Go for all the lumps in the wad
|
||||
for(scanindex = 0; scanindex < (wadfile.Lumps.Count - 1); scanindex++)
|
||||
{
|
||||
// Make sure this lump is not part of the map
|
||||
if(!maplumpnames.Contains(wadfile.Lumps[scanindex].Name))
|
||||
{
|
||||
// Check the required map lumps
|
||||
lumpsfound = 0;
|
||||
checkoffset = 1;
|
||||
do
|
||||
{
|
||||
// Count the lump when it is marked as required
|
||||
lumpname = wadfile.Lumps[scanindex + checkoffset].Name;
|
||||
if(cfg.ReadSetting("maplumpnames." + lumpname + ".required", false)) lumpsfound++;
|
||||
|
||||
// Check the next lump
|
||||
checkoffset++;
|
||||
}
|
||||
// Continue while still within bounds and lumps are still recognized
|
||||
while(((scanindex + checkoffset) < wadfile.Lumps.Count) &&
|
||||
maplumpnames.Contains(wadfile.Lumps[scanindex + checkoffset].Name));
|
||||
|
||||
// Map found? Then add it to the list
|
||||
if(lumpsfound >= lumpsrequired)
|
||||
mapnames.Add(new ListViewItem(wadfile.Lumps[scanindex].Name));
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the list and add the new map names
|
||||
mapslist.Items.Clear();
|
||||
mapslist.Items.AddRange(mapnames.ToArray());
|
||||
mapslist.Sort();
|
||||
|
||||
// Go for all items in the list
|
||||
foreach(ListViewItem item in mapslist.Items)
|
||||
{
|
||||
// Was this item previously selected?
|
||||
if(item.Text == selectedname)
|
||||
{
|
||||
// Select it again
|
||||
item.Selected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// OK clicked
|
||||
private void apply_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Configuration selected?
|
||||
if(config.SelectedIndex == -1)
|
||||
{
|
||||
// Select a configuration!
|
||||
MessageBox.Show(this, "Please select a game configuration to use for editing your map.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
config.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
// No map selected?
|
||||
if(mapslist.SelectedItems.Count == 0)
|
||||
{
|
||||
// Choose a map!
|
||||
MessageBox.Show(this, "Please select a map to load for editing.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
mapslist.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply changes
|
||||
options.ClearResources();
|
||||
options.ConfigFile = General.Configs[config.SelectedIndex].filename;
|
||||
options.CurrentName = mapslist.SelectedItems[0].ToString();
|
||||
foreach(ResourceLocation res in resources.Items) options.AddResource(res);
|
||||
|
||||
// Hide window
|
||||
wadfile.Dispose();
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Hide();
|
||||
}
|
||||
|
||||
// Cancel clicked
|
||||
private void cancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Just hide window
|
||||
wadfile.Dispose();
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Hide();
|
||||
}
|
||||
|
||||
// Add Resource clicked
|
||||
private void addresource_Click(object sender, EventArgs e)
|
||||
{
|
||||
ResourceOptionsForm resoptions;
|
||||
Point startposition;
|
||||
|
||||
// Open resource options dialog
|
||||
resoptions = new ResourceOptionsForm(new ResourceLocation(), "Add Resource");
|
||||
resoptions.StartPosition = FormStartPosition.Manual;
|
||||
startposition = this.Location;
|
||||
startposition.Offset(50, 230);
|
||||
resoptions.Location = startposition;
|
||||
if(resoptions.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
// Add resource
|
||||
resources.Items.Add(resoptions.ResourceLocation);
|
||||
}
|
||||
}
|
||||
|
||||
// Resource Options clicked
|
||||
private void editresource_Click(object sender, EventArgs e)
|
||||
{
|
||||
ResourceOptionsForm resoptions;
|
||||
Point startposition;
|
||||
|
||||
// Anything selected?
|
||||
if(resources.SelectedIndex > -1)
|
||||
{
|
||||
// Open resource options dialog
|
||||
resoptions = new ResourceOptionsForm((ResourceLocation)resources.SelectedItem, "Resource Options");
|
||||
resoptions.StartPosition = FormStartPosition.Manual;
|
||||
startposition = this.Location;
|
||||
startposition.Offset(50, 230);
|
||||
resoptions.Location = startposition;
|
||||
if(resoptions.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
// Replace resource
|
||||
resources.Items[resources.SelectedIndex] = resoptions.ResourceLocation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove resource clicked
|
||||
private void deleteresource_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Anything selected?
|
||||
if(resources.SelectedIndex > -1)
|
||||
{
|
||||
// Remove it
|
||||
resources.Items.RemoveAt(resources.SelectedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// Resource selection changes
|
||||
private void resources_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
// Enable/disable buttons
|
||||
editresource.Enabled = (resources.SelectedIndex > -1);
|
||||
deleteresource.Enabled = (resources.SelectedIndex > -1);
|
||||
}
|
||||
|
||||
// Window is shown
|
||||
private void OpenMapOptionsForm_Shown(object sender, EventArgs e)
|
||||
{
|
||||
// Update window
|
||||
this.Update();
|
||||
|
||||
// Load settings
|
||||
LoadSettings();
|
||||
}
|
||||
}
|
||||
}
|
156
Source/Interface/OpenMapOptionsForm.resx
Normal file
156
Source/Interface/OpenMapOptionsForm.resx
Normal file
|
@ -0,0 +1,156 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="panelres.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="deleteresource.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="editresource.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="addresource.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="resources.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="label1.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="label2.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="apply.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="cancel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="config.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="mapslist.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
2
Source/Interface/ResourceOptionsForm.Designer.cs
generated
2
Source/Interface/ResourceOptionsForm.Designer.cs
generated
|
@ -197,7 +197,7 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
//
|
||||
// wadfiledialog
|
||||
//
|
||||
this.wadfiledialog.Filter = "Doom WAD Files|*.wad";
|
||||
this.wadfiledialog.Filter = "Doom WAD Files (*.wad)|*.wad";
|
||||
this.wadfiledialog.Title = "Browse WAD File";
|
||||
//
|
||||
// dirdialog
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
|
||||
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
||||
* This program is released under GNU General Public License
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
@ -7,6 +25,8 @@ using System.Windows.Forms;
|
|||
using CodeImp.DoomBuilder.Map;
|
||||
using System.IO;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Interface
|
||||
{
|
||||
internal partial class ResourceOptionsForm : Form
|
||||
|
|
|
@ -82,6 +82,41 @@ namespace CodeImp.DoomBuilder.Map
|
|||
this.resources = new List<ResourceLocation>();
|
||||
}
|
||||
|
||||
// Constructor to load from Doom Builder Map Settings Configuration
|
||||
public MapOptions(Configuration cfg, string mapname)
|
||||
{
|
||||
IDictionary mapinfo, resinfo;
|
||||
ResourceLocation res;
|
||||
|
||||
// Initialize
|
||||
this.previousname = "";
|
||||
this.currentname = mapname;
|
||||
this.configfile = cfg.ReadSetting("config", "");
|
||||
this.resources = new List<ResourceLocation>();
|
||||
|
||||
// Go for all items in the map info
|
||||
mapinfo = cfg.ReadSetting(mapname, new Hashtable());
|
||||
foreach(DictionaryEntry mp in mapinfo)
|
||||
{
|
||||
// Item is a structure?
|
||||
if(mp.Value is IDictionary)
|
||||
{
|
||||
// Create resource
|
||||
resinfo = (IDictionary)mp.Value;
|
||||
res = new ResourceLocation();
|
||||
|
||||
// Copy information from Configuration to ResourceLocation
|
||||
if(resinfo.Contains("type") && (resinfo["type"] is int)) res.type = (int)resinfo["type"];
|
||||
if(resinfo.Contains("location") && (resinfo["location"] is string)) res.location = (string)resinfo["location"];
|
||||
if(resinfo.Contains("textures") && (resinfo["textures"] is bool)) res.textures = (bool)resinfo["textures"];
|
||||
if(resinfo.Contains("flats") && (resinfo["flats"] is bool)) res.flats = (bool)resinfo["flats"];
|
||||
|
||||
// Add resource
|
||||
AddResource(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~MapOptions()
|
||||
{
|
||||
// Clean up
|
||||
|
@ -129,6 +164,12 @@ namespace CodeImp.DoomBuilder.Map
|
|||
resources.RemoveAt(index);
|
||||
}
|
||||
|
||||
// This displays the current map name
|
||||
public override string ToString()
|
||||
{
|
||||
return currentname;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -261,7 +261,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
#region ================== Resetting
|
||||
|
||||
// This resets the device and returns true on success
|
||||
private bool Reset()
|
||||
public bool Reset()
|
||||
{
|
||||
PresentParameters displaypp;
|
||||
|
||||
|
|
Loading…
Reference in a new issue