comparison FrmMainWindow.cs @ 43:4e127ce8682f

Re #86: Complete initial GTK# UI * Keep UI tidier by hiding category tree until we have an army * Implement reloading files
author IBBoard <dev@ibboard.co.uk>
date Wed, 11 Aug 2010 19:23:43 +0000
parents 35ad26ac59c0
children 44e6833bb41a
comparison
equal deleted inserted replaced
42:35ad26ac59c0 43:4e127ce8682f
367 CreateNewArmy(); 367 CreateNewArmy();
368 } 368 }
369 369
370 protected virtual void OnReloadFilesActivated(object sender, System.EventArgs e) 370 protected virtual void OnReloadFilesActivated(object sender, System.EventArgs e)
371 { 371 {
372 WarFoundryLoader.GetDefault().LoadFiles();
372 } 373 }
373 374
374 protected virtual void OnSaveArmyAsActivated(object sender, System.EventArgs e) 375 protected virtual void OnSaveArmyAsActivated(object sender, System.EventArgs e)
375 { 376 {
376 SaveCurrentArmyAs(); 377 SaveCurrentArmyAs();
453 { 454 {
454 loadedArmyPath = null; 455 loadedArmyPath = null;
455 SetAppTitle(); 456 SetAppTitle();
456 SetArmyTree(newArmy); 457 SetArmyTree(newArmy);
457 458
458 if (oldArmy!=null) 459 if (oldArmy != null)
459 { 460 {
460 oldArmy.UnitAdded-= UnitAddedMethod; 461 oldArmy.UnitAdded -= UnitAddedMethod;
461 oldArmy.UnitRemoved-= UnitRemovedMethod; 462 oldArmy.UnitRemoved -= UnitRemovedMethod;
462 oldArmy.PointsValueChanged-= PointsValueChangedMethod; 463 oldArmy.PointsValueChanged -= PointsValueChangedMethod;
463 oldArmy.FailedRequirement-=FailedUnitRequirementMethod; 464 oldArmy.FailedRequirement -= FailedUnitRequirementMethod;
464 } 465 }
465 466
466 unitToWidgetMap.Clear(); 467 unitToWidgetMap.Clear();
467 468
468 while (unitsNotebook.NPages > 0) 469 while (unitsNotebook.NPages > 0)
469 { 470 {
470 unitsNotebook.RemovePage(0); 471 unitsNotebook.RemovePage(0);
471 } 472 }
472 473
473 if (newArmy==null) 474 if (newArmy == null)
474 { 475 {
475 DisableCategoryButtons(); 476 DisableCategoryButtons();
476 } 477 }
477 else 478 else
478 { 479 {
479 newArmy.UnitAdded+= UnitAddedMethod; 480 newArmy.UnitAdded += UnitAddedMethod;
480 newArmy.UnitRemoved+= UnitRemovedMethod; 481 newArmy.UnitRemoved += UnitRemovedMethod;
481 newArmy.PointsValueChanged+= PointsValueChangedMethod; 482 newArmy.PointsValueChanged += PointsValueChangedMethod;
482 newArmy.FailedRequirement+=FailedUnitRequirementMethod; 483 newArmy.FailedRequirement += FailedUnitRequirementMethod;
483 //TODO: Clear all buttons 484 //TODO: Clear all buttons
484 EnableCategoryButtons(); 485 EnableCategoryButtons();
485 486
486 if (newArmy.Race.HasCategoryOverrides()) 487 if (newArmy.Race.HasCategoryOverrides())
487 { 488 {
488 RemoveCategoryButtons(); 489 RemoveCategoryButtons();
489 AddCategoryButtons(newArmy.Race.Categories); 490 AddCategoryButtons(newArmy.Race.Categories);
490 } 491 }
491 } 492 }
492 493
493 miCloseArmy.Sensitive = newArmy!=null; 494 bool nonNullNewArmy = (newArmy != null);
494 miSaveArmyAs.Sensitive = newArmy!=null; 495 miCloseArmy.Sensitive = nonNullNewArmy;
495 miExportArmy.Sensitive = newArmy!=null; 496 miSaveArmyAs.Sensitive = nonNullNewArmy;
497 miExportArmy.Sensitive = nonNullNewArmy;
498 hpaned2.Visible = nonNullNewArmy;
496 loadedArmyPath = null; 499 loadedArmyPath = null;
497 //New army has no changes, so we can't save it 500 //New army has no changes, so we can't save it
498 miSaveArmy.Sensitive = false; 501 miSaveArmy.Sensitive = false;
499 saveArmyButton.Sensitive = false; 502 saveArmyButton.Sensitive = false;
500 503