comparison FrmMain.cs @ 190:1ca23c47345a

Re #327: Point names used in the GUI
author snowblizz
date Mon, 24 Jan 2011 16:50:31 +0000
parents 75afd724a825
children 70575ace029b
comparison
equal deleted inserted replaced
189:cb86380cbf61 190:1ca23c47345a
22 using IBBoard.Xml; 22 using IBBoard.Xml;
23 using IBBoard.WarFoundry.API; 23 using IBBoard.WarFoundry.API;
24 using IBBoard.WarFoundry.API.Commands; 24 using IBBoard.WarFoundry.API.Commands;
25 using IBBoard.WarFoundry.API.Exporters; 25 using IBBoard.WarFoundry.API.Exporters;
26 using IBBoard.WarFoundry.API.Objects; 26 using IBBoard.WarFoundry.API.Objects;
27 using IBBoard.WarFoundry.API.Util;
27 using IBBoard.WarFoundry.API.Savers; 28 using IBBoard.WarFoundry.API.Savers;
28 using IBBoard.WarFoundry.API.Factories; 29 using IBBoard.WarFoundry.API.Factories;
29 using IBBoard.WarFoundry.API.Factories.Xml; 30 using IBBoard.WarFoundry.API.Factories.Xml;
30 31
31 namespace IBBoard.WarFoundry.GUI.WinForms 32 namespace IBBoard.WarFoundry.GUI.WinForms
36 public class FrmMain : System.Windows.Forms.Form 37 public class FrmMain : System.Windows.Forms.Form
37 { 38 {
38 private static readonly string AppTitle = "WarFoundry"; 39 private static readonly string AppTitle = "WarFoundry";
39 internal static readonly string VERSION = "0.1"; 40 internal static readonly string VERSION = "0.1";
40 const string DefaultDataDir = "data"; 41 const string DefaultDataDir = "data";
42 /* public static string pointsAbbrevSingle;
43 public static string pointsAbbrevPlural;
44 public static string pointsAbbreviation;
45 public static string pointsNameSingle;
46 public static string pointsNamePlural;
47 public static string pointsName;*/
41 48
42 private Preferences preferences; 49 private Preferences preferences;
43 private readonly ILog log = LogManager.GetLogger(typeof(FrmMain)); 50 private readonly ILog log = LogManager.GetLogger(typeof(FrmMain));
44 51
45 private CommandStack commandStack; 52 private CommandStack commandStack;
92 private ToolStripPanel toolStripPanel; 99 private ToolStripPanel toolStripPanel;
93 private ToolStripSeparator toolStripSeparator4; 100 private ToolStripSeparator toolStripSeparator4;
94 private IBBToolStripMenuItem miPreferences; 101 private IBBToolStripMenuItem miPreferences;
95 private IBBToolStripMenuItem miAbout; 102 private IBBToolStripMenuItem miAbout;
96 103
104
97 /// <summary> 105 /// <summary>
98 /// The main entry point for the application. 106 /// The main entry point for the application.
99 /// </summary> 107 /// </summary>
100 [STAThread] 108 [STAThread]
101 static void Main(string[] args) 109 static void Main(string[] args)
144 UnitAddedMethod = new ObjectAddDelegate(FrmMain_UnitAddedMethod); 152 UnitAddedMethod = new ObjectAddDelegate(FrmMain_UnitAddedMethod);
145 UnitRemovedMethod = new ObjectRemoveDelegate(FrmMain_UnitRemovedMethod); 153 UnitRemovedMethod = new ObjectRemoveDelegate(FrmMain_UnitRemovedMethod);
146 PointsValueChangedMethod = new DoubleValChangedDelegate(FrmMain_PointsValueChangedMethod); 154 PointsValueChangedMethod = new DoubleValChangedDelegate(FrmMain_PointsValueChangedMethod);
147 //FailedUnitRequirementMethod = new FailedUnitRequirementDelegate(FrmMain_FailedUnitRequirement); 155 //FailedUnitRequirementMethod = new FailedUnitRequirementDelegate(FrmMain_FailedUnitRequirement);
148 156
157
149 sbErrorPanel.Color = Color.Red; 158 sbErrorPanel.Color = Color.Red;
150 sbPointsPanel.ToolTipText = Translation.GetTranslation("statusPanelPointsToolTip", "total points value"); 159 SetPointsPanelToolTipText();
151 160
152 // hack to load default files 161 // hack to load default files
153 WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Constants.ExecutablePath + Constants.DirectoryString + DefaultDataDir)); 162 WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Constants.ExecutablePath + Constants.DirectoryString + DefaultDataDir));
154 WarFoundryLoader.GetDefault().RegisterFactory(WarFoundryXmlFactory.GetFactory()); 163 WarFoundryLoader.GetDefault().RegisterFactory(WarFoundryXmlFactory.GetFactory());
155 WarFoundryLoader.GetDefault().FileLoadingFinished += FileLoadingFinished; 164 WarFoundryLoader.GetDefault().FileLoadingFinished += FileLoadingFinished;
178 { 187 {
179 ControlTranslator.TranslateControls(Controls); 188 ControlTranslator.TranslateControls(Controls);
180 ControlTranslator.TranslateComponents(components.Components); 189 ControlTranslator.TranslateComponents(components.Components);
181 ControlTranslator.TranslateComponent(openArmyDialog); 190 ControlTranslator.TranslateComponent(openArmyDialog);
182 ControlTranslator.TranslateComponent(saveArmyDialog); 191 ControlTranslator.TranslateComponent(saveArmyDialog);
183 } 192 //make sure translations exist for gamesystem pointsnames
193 if (CurrentGameSystem != null)
194 {
195 CurrentGameSystem.LoadPointsSystemNames();
196 }
197 //translate pointspanel and tooltip
198 SetPointsPanelToolTipText();
199 SetPointsPanelText();
200 }
184 201
185 void TranslationChanged() 202 void TranslationChanged()
186 { 203 {
187 TranslateControls(); 204 TranslateControls();
188 } 205 }
866 883
867 private void FrmMain_GameSystemChanged(GameSystem oldSystem, GameSystem newSystem) 884 private void FrmMain_GameSystemChanged(GameSystem oldSystem, GameSystem newSystem)
868 { 885 {
869 SetAppTitle(); 886 SetAppTitle();
870 RemoveCategoryButtons(); 887 RemoveCategoryButtons();
888 newSystem.LoadPointsSystemNames();
871 } 889 }
872 890
873 private void FrmMain_ArmyChanged(Army oldArmy, Army newArmy) 891 private void FrmMain_ArmyChanged(Army oldArmy, Army newArmy)
874 { 892 {
875 CommandStack.Reset(); 893 CommandStack.Reset();
1272 if (obj is Army) 1290 if (obj is Army)
1273 { 1291 {
1274 SetPointsPanelText(); 1292 SetPointsPanelText();
1275 } 1293 }
1276 } 1294 }
1277 1295 /*
1278 private void SetPointsPanelText() 1296 public static string UsePointsAbbrev(double pointTemp)
1297 {
1298 if (pointTemp == 1)
1299 {
1300 pointsAbbreviation = pointsAbbrevSingle;
1301 }
1302 else
1303 {
1304 pointsAbbreviation = pointsAbbrevPlural;
1305 }
1306 return pointsAbbreviation;
1307 }
1308
1309 public static string UsePointsName(double pointTemp)
1310 {
1311
1312 if (pointTemp == 1)
1313 {
1314 pointsName = pointsNameSingle;
1315 }
1316 else
1317 {
1318 pointsName = pointsNamePlural;
1319 }
1320 return pointsName;
1321 }
1322
1323 private void LoadPointsSystemNames()
1324 {
1325 LoadPointsAbbrevPlural();
1326 LoadPointsAbbrevSingle();
1327 LoadPointsNamePlural();
1328 LoadPointsNameSingle();
1329 }
1330 private void LoadPointsAbbrevPlural()
1331 {
1332 // Use this before calling on pointsAbbreviationPlural to "populate" the variable
1333 if (CurrentGameSystem != null )
1334 {
1335 if (CurrentGameSystem.SystemPtsAbbrevPlural == "")
1336 {
1337 pointsAbbrevPlural = String.Format(Translation.GetTranslation("PointsLocalisationAbbrevPlural"));
1338 }
1339 else
1340 {
1341 pointsAbbrevPlural = CurrentGameSystem.SystemPtsAbbrevPlural;
1342 }
1343 }
1344 }
1345 private void LoadPointsAbbrevSingle()
1346 {
1347 // Use this before calling on pointsAbbreviationSingle to "populate" the variable
1348 if (CurrentGameSystem != null )
1349 {
1350 if (CurrentGameSystem.SystemPtsAbbrevSingle == "")
1351 {
1352 pointsAbbrevSingle = String.Format(Translation.GetTranslation("PointsLocalisationAbbrevSingle"));
1353 }
1354 else
1355 {
1356 pointsAbbrevSingle = CurrentGameSystem.SystemPtsAbbrevSingle;
1357 }
1358 }
1359 }
1360 private void LoadPointsNamePlural()
1361 {
1362 if (CurrentGameSystem != null )
1363 {
1364 // Use this before calling on pointsNamePlural to "populate" the variable
1365 if (CurrentGameSystem.SystemPtsNamePlural == "")
1366 {
1367 pointsNamePlural = String.Format(Translation.GetTranslation("PointsLocalisationNamePlural"));
1368 }
1369 else
1370 {
1371 pointsNamePlural = CurrentGameSystem.SystemPtsNamePlural;
1372 }
1373 }
1374 }
1375
1376 private void LoadPointsNameSingle()
1377 {
1378 if (CurrentGameSystem != null )
1379 {
1380 // Use this before calling on pointsNameSingle to "populate" the variable
1381 if (CurrentGameSystem.SystemPtsNameSingle == "")
1382 {
1383 pointsNameSingle = String.Format(Translation.GetTranslation("PointsLocalisationNameSingle"));
1384 }
1385 else
1386 {
1387 pointsNameSingle = CurrentGameSystem.SystemPtsNameSingle;
1388 }
1389 }
1390 }
1391 */
1392 private void SetPointsPanelText()
1279 { 1393 {
1280 if (CurrentArmy==null) 1394 if (CurrentArmy==null)
1281 { 1395 {
1282 sbPointsPanel.Text = ""; 1396 sbPointsPanel.Text = "";
1283 sbPointsPanel.ResetColor(); 1397 sbPointsPanel.ResetColor();
1284 } 1398 }
1285 else 1399 else
1286 { 1400 {
1287 sbPointsPanel.Text = String.Format(Translation.GetTranslation("statusPanelPoints"), CurrentArmy.Points, CurrentArmy.MaxPoints); 1401 string pointsPanelText = String.Format(Translation.GetTranslation("statusPanelPoints"), CurrentArmy.Points, CurrentGameSystem.UsePointsName(CurrentArmy.Points), CurrentArmy.MaxPoints, CurrentGameSystem.UsePointsName(CurrentArmy.MaxPoints));
1402 sbPointsPanel.Text = pointsPanelText;
1288 1403
1289 if (CurrentArmy.Points>CurrentArmy.MaxPoints) 1404 if (CurrentArmy.Points>CurrentArmy.MaxPoints)
1290 { 1405 {
1291 sbPointsPanel.Color = Color.Red; 1406 sbPointsPanel.Color = Color.Red;
1292 } 1407 }
1294 { 1409 {
1295 sbPointsPanel.ResetColor(); 1410 sbPointsPanel.ResetColor();
1296 } 1411 }
1297 } 1412 }
1298 } 1413 }
1414
1415 private void SetPointsPanelToolTipText()
1416 {
1417 sbPointsPanel.ToolTipText = Translation.GetTranslation("statusPanelPointsToolTip", "total points value");
1418 }
1299 1419
1300 private void redoMenu_Click(object sender, EventArgs e) 1420 private void redoMenu_Click(object sender, EventArgs e)
1301 { 1421 {
1302 if (sender is ToolStripDropDownItem) 1422 if (sender is ToolStripDropDownItem)
1303 { 1423 {