Mercurial > repos > IBBoard.WarFoundry.GUI.QtSharp
diff MainWindow.cs @ 29:246237c88b9b
Re #244: Create "New Unit" dialog in Qt# app
* Add NewUnit dialog
* Fix layout (rename layout and make list enabled)
* Call dialog when clicking on buttons
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 03 Aug 2010 19:36:49 +0000 |
parents | 5ee15def17e7 |
children | 56771b8efdaf |
line wrap: on
line diff
--- a/MainWindow.cs Sat Jul 31 20:32:01 2010 +0000 +++ b/MainWindow.cs Tue Aug 03 19:36:49 2010 +0000 @@ -15,6 +15,7 @@ using IBBoard.WarFoundry.API.Objects; using IBBoard.WarFoundry.API.Savers; using IBBoard.WarFoundry.GUI.QtSharp.Handler; +using IBBoard.WarFoundry.API.Commands; namespace IBBoard.WarFoundry.GUI.QtSharp { @@ -110,7 +111,7 @@ if (CloseCurrentArmy()) { NewArmyDialog dialog = new NewArmyDialog(this); - int result = dialog.Exec (); + int result = dialog.Exec(); if (result == (int)QDialog.DialogCode.Accepted) { @@ -522,7 +523,7 @@ { QAction action = new QAction(this); action.icon = new QIcon("icons/ui/add.png"); - NewUnitEventHandler handler = new NewUnitEventHandler(category, AddUnit); + NewUnitEventHandler handler = new NewUnitEventHandler(category, AddUnitFromCategory); ConnectMenuAction(action, handler.CreateNewUnit); categoryActions[i] = action; layout.toolBar.AddAction(action); @@ -531,9 +532,22 @@ } } - private void AddUnit(Category cat) + private void AddUnitFromCategory(Category cat) { - QMessageBox.Information(this, "Add unit", cat.Name); + NewUnitDialog newUnit = new NewUnitDialog(this, CurrentArmy.Race, cat, CurrentArmy); + int result = newUnit.Exec(); + + if (result == (int)QDialog.DialogCode.Accepted) + { + CreateAndAddUnitCommand cmd = new CreateAndAddUnitCommand(newUnit.SelectedUnit, CurrentArmy.GetCategory(cat)); + CommandStack.Execute(cmd); + OpenUnitDialog(cmd.Unit); + } + } + + private void OpenUnitDialog(Unit unit) + { + } void EnableCategoryButtons ()