Mercurial > repos > IBBoard.WarFoundry.GUI.QtSharp
view NewArmyDialog.cs @ 6:bbf40d66dfe4
Re #242: Create Qt# UI for WarFoundry
* Fix warnings about Connect strings not being signals
Re #243: Create new Qt# "Create Army" dialog
* Change from List View to List Widget (views need models, which only handle QVariants and not arbitrary objects)
* Populate Game System list
* Populate races list on game system selection changed
* Set text on some labels
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 27 Jan 2010 20:58:56 +0000 |
parents | ac1bf60edf63 |
children | 8a8735679d55 |
line wrap: on
line source
// This file (NewArmyDialog.cs) is a part of the IBBoard.WarFoundry.GUI.QtSharp project and is copyright 2010 IBBoard // // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. using System; using System.Collections.Generic; using Qyoto; using IBBoard.WarFoundry.API; using IBBoard.WarFoundry.API.Objects; namespace IBBoard.WarFoundry.GUI.QtSharp { public class NewArmyDialog : QDialog { private Ui_CreateNewArmyLayout layout; //TODO: Replace local cached arrays with some kind of storing as user data on controls, if possible //Qt doesn't seem to support it by default, but there should be a better alternative private GameSystem[] gameSystems; private Race[] races; public NewArmyDialog () { layout = new Ui_CreateNewArmyLayout(); layout.SetupUi(this); PopulateControls(); layout.gameSystems.CurrentIndex = -1; QObject.Connect(layout.gameSystems, SIGNAL("currentIndexChanged(int)"), GameSystemSelectionChanged); } private void PopulateControls() { gameSystems = WarFoundryLoader.GetDefault().GetGameSystems(); foreach (GameSystem system in gameSystems) { layout.gameSystems.AddItem(system.Name); } } private void GameSystemSelectionChanged() { layout.raceList.Clear(); if (layout.gameSystems.CurrentIndex != -1) { races = WarFoundryLoader.GetDefault().GetRaces(GetSelectedSystem()); foreach (Race race in races) { layout.raceList.AddItem(race.Name); } } } private GameSystem GetSelectedSystem() { GameSystem system = null; int selectedIndex = layout.gameSystems.CurrentIndex; if (selectedIndex != -1) { system = gameSystems[selectedIndex]; } return system; } } }