comparison FrmMain.cs @ 9:b42ba80ec613

Fixes #319: WarFoundry Forge - No Factory set failure * Use new dummy factory when creating a new game system
author IBBoard <dev@ibboard.co.uk>
date Fri, 17 Dec 2010 20:14:43 +0000
parents d63df495cf5a
children
comparison
equal deleted inserted replaced
8:0dadaa315430 9:b42ba80ec613
37 public class FrmMain : System.Windows.Forms.Form 37 public class FrmMain : System.Windows.Forms.Form
38 { 38 {
39 private static readonly string AppTitle = "WarFoundry Forge"; 39 private static readonly string AppTitle = "WarFoundry Forge";
40 internal static readonly string VERSION = "0.0.2"; 40 internal static readonly string VERSION = "0.0.2";
41 const string DefaultDataDir = "data"; 41 const string DefaultDataDir = "data";
42
43 private Preferences preferences; 42 private Preferences preferences;
44 private readonly ILog log = LogManager.GetLogger(typeof(FrmMain)); 43 private readonly ILog log = LogManager.GetLogger(typeof(FrmMain));
45
46 private CommandStack commandStack; 44 private CommandStack commandStack;
47
48 private string loadedFilePath; 45 private string loadedFilePath;
49 46
50 // Form contents 47 // Form contents
51 private System.ComponentModel.IContainer components; 48 private System.ComponentModel.IContainer components;
52 private System.Windows.Forms.MainMenu mainMenu; 49 private System.Windows.Forms.MainMenu mainMenu;
195 192
196 // 193 //
197 // menuStrip 194 // menuStrip
198 // 195 //
199 this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 196 this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
200 this.menuFile, 197 this.menuFile,
201 this.menuHelp}); 198 this.menuHelp});
202 this.menuStrip.Location = new System.Drawing.Point(0, 0); 199 this.menuStrip.Location = new System.Drawing.Point(0, 0);
203 this.menuStrip.Name = "menuStrip"; 200 this.menuStrip.Name = "menuStrip";
204 this.menuStrip.Size = new System.Drawing.Size(790, 24); 201 this.menuStrip.Size = new System.Drawing.Size(790, 24);
205 this.menuStrip.TabIndex = 6; 202 this.menuStrip.TabIndex = 6;
206 this.menuStrip.Text = "menuStrip1"; 203 this.menuStrip.Text = "menuStrip1";
207 // 204 //
208 // menuFile 205 // menuFile
209 // 206 //
210 this.menuFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 207 this.menuFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
211 this.menuNew, 208 this.menuNew,
212 this.menuOpen, 209 this.menuOpen,
213 this.toolStripSeparator2, 210 this.toolStripSeparator2,
214 this.miExit}); 211 this.miExit});
215 this.menuFile.Name = "menuFile"; 212 this.menuFile.Name = "menuFile";
216 this.menuFile.Size = new System.Drawing.Size(33, 20); 213 this.menuFile.Size = new System.Drawing.Size(33, 20);
217 this.menuFile.Text = "&file"; 214 this.menuFile.Text = "&file";
218 // 215 //
219 // menuNew 216 // menuNew
259 this.miExit.Click += new System.EventHandler(this.miExit_Click); 256 this.miExit.Click += new System.EventHandler(this.miExit_Click);
260 // 257 //
261 // menuHelp 258 // menuHelp
262 // 259 //
263 this.menuHelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 260 this.menuHelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
264 this.miAbout}); 261 this.miAbout});
265 this.menuHelp.Name = "menuHelp"; 262 this.menuHelp.Name = "menuHelp";
266 this.menuHelp.Size = new System.Drawing.Size(39, 20); 263 this.menuHelp.Size = new System.Drawing.Size(39, 20);
267 this.menuHelp.Text = "&help"; 264 this.menuHelp.Text = "&help";
268 // 265 //
269 // miAbout 266 // miAbout
286 this.menuStrip.ResumeLayout(false); 283 this.menuStrip.ResumeLayout(false);
287 this.menuStrip.PerformLayout(); 284 this.menuStrip.PerformLayout();
288 this.ResumeLayout(false); 285 this.ResumeLayout(false);
289 this.PerformLayout(); 286 this.PerformLayout();
290 } 287 }
288
291 #endregion 289 #endregion
292 290
293 private void FileLoadingFinished(List<FileLoadFailure> failures) 291 private void FileLoadingFinished(List<FileLoadFailure> failures)
294 { 292 {
295 foreach (FileLoadFailure failure in failures) 293 foreach (FileLoadFailure failure in failures)
296 { 294 {
297 log.Warn("Failed to load " + failure.FailedFile.FullName + ": " + failure.Message); 295 log.Warn("Failed to load " + failure.FailedFile.FullName + ": " + failure.Message);
298 } 296 }
299 } 297 }
300 298
301 private void miNewSystem_Click(object sender, System.EventArgs e) 299 private void miNewSystem_Click(object sender, System.EventArgs e)
302 { 300 {
303 FrmSystem system = new FrmSystem(new GameSystem(" ", " ", null)); 301 FrmSystem system = new FrmSystem(new GameSystem(" ", " ", new DummyWarFoundryFactory()));
304 system.ShowDialog(this); 302 system.ShowDialog(this);
305 } 303 }
306 304
307 private void miOpenSystem_Click(object sender, System.EventArgs e) 305 private void miOpenSystem_Click(object sender, System.EventArgs e)
308 { 306 {
309 if(OpenFile()) 307 if (OpenFile())
310 { 308 {
311 FrmSystem system = new FrmSystem(CurrentGameSystem); 309 FrmSystem system = new FrmSystem(CurrentGameSystem);
312 system.ShowDialog(this); 310 system.ShowDialog(this);
313 } 311 }
314 } 312 }
315 313
316 private bool OpenFile() 314 private bool OpenFile()
317 { 315 {
318 if (openFile.Filter == "") 316 if (openFile.Filter == "")
319 { 317 {
320 string savePath = DataPath; 318 string savePath = DataPath;
336 try 334 try
337 { 335 {
338 string newFilePath = openFile.FileName; 336 string newFilePath = openFile.FileName;
339 ICollection<IWarFoundryObject> fileContents = WarFoundryLoader.GetDefault().LoadFile(new FileInfo(newFilePath)); 337 ICollection<IWarFoundryObject> fileContents = WarFoundryLoader.GetDefault().LoadFile(new FileInfo(newFilePath));
340 338
341 if(fileContents.Count > 0) 339 if (fileContents.Count > 0)
342 { 340 {
343 foreach(IWarFoundryObject fileObject in fileContents) 341 foreach (IWarFoundryObject fileObject in fileContents)
344 { 342 {
345 if(fileObject is GameSystem) 343 if (fileObject is GameSystem)
346 { 344 {
347 CurrentGameSystem = (GameSystem)fileObject; 345 CurrentGameSystem = (GameSystem)fileObject;
348 } 346 }
349 } 347 }
350 } 348 }