1 using System; 2 using System.Globalization; 3 using System.Windows.Forms; 4 using OpenBveApi.Colors; 5 using OpenBveApi.Sounds; 6 using SoundManager; 7 8 namespace OpenBve 9 { 10 internal static partial class HUD 11 { 12 /// <summary>The current HUD elements to render</summary> 13 internal static Element[] CurrentHudElements = { }; 14 15 /// <summary>Sound source used by the accessibility station adjust tone</summary> 16 internal static SoundSource stationAdjustBeepSource; 17 /// <summary>Station adjust beep sound used by accessibility</summary> 18 internal static SoundBuffer stationAdjustBeep; 19 20 /// <summary>Loads the current HUD</summary> LoadHUD()21 internal static void LoadHUD() 22 { 23 CultureInfo Culture = CultureInfo.InvariantCulture; 24 string Folder = Program.FileSystem.GetDataFolder("In-game", Interface.CurrentOptions.UserInterfaceFolder); 25 string File = OpenBveApi.Path.CombineFile(Folder, "interface.cfg"); 26 Program.CurrentHost.RegisterSound(OpenBveApi.Path.CombineFile(Program.FileSystem.GetDataFolder("In-game"), "beep.wav"), 50, out var beep); 27 stationAdjustBeep = beep as SoundBuffer; 28 CurrentHudElements = new Element[16]; 29 int Length = 0; 30 if (System.IO.File.Exists(File)) 31 { 32 string[] Lines = System.IO.File.ReadAllLines(File, new System.Text.UTF8Encoding()); 33 for (int i = 0; i < Lines.Length; i++) 34 { 35 int j = Lines[i].IndexOf(';'); 36 if (j >= 0) 37 { 38 Lines[i] = Lines[i].Substring(0, j).Trim(new char[] { }); 39 } 40 else 41 { 42 Lines[i] = Lines[i].Trim(new char[] { }); 43 } 44 if (Lines[i].Length != 0) 45 { 46 if (!Lines[i].StartsWith(";", StringComparison.Ordinal)) 47 { 48 if (Lines[i].Equals("[element]", StringComparison.OrdinalIgnoreCase)) 49 { 50 Length++; 51 if (Length > CurrentHudElements.Length) 52 { 53 Array.Resize(ref CurrentHudElements, CurrentHudElements.Length << 1); 54 } 55 56 CurrentHudElements[Length - 1] = new Element(); 57 } 58 else if (Length == 0) 59 { 60 MessageBox.Show("Line outside of [element] structure encountered at line " + (i + 1).ToString(Culture) + " in " + File); 61 } 62 else 63 { 64 j = Lines[i].IndexOf("=", StringComparison.Ordinal); 65 if (j >= 0) 66 { 67 string Command = Lines[i].Substring(0, j).TrimEnd(); 68 string[] Arguments = Lines[i].Substring(j + 1).TrimStart().Split(new[] { ','}, StringSplitOptions.None); 69 for (j = 0; j < Arguments.Length; j++) 70 { 71 Arguments[j] = Arguments[j].Trim(new char[] { }); 72 } 73 switch (Command.ToLowerInvariant()) 74 { 75 case "subject": 76 if (Arguments.Length == 1) 77 { 78 CurrentHudElements[Length - 1].Subject = Arguments[0]; 79 } 80 else 81 { 82 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 83 } 84 break; 85 case "position": 86 if (Arguments.Length == 2) 87 { 88 float x, y; 89 if (!float.TryParse(Arguments[0], NumberStyles.Float, Culture, out x)) 90 { 91 MessageBox.Show("X is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 92 } 93 else if (!float.TryParse(Arguments[1], NumberStyles.Float, Culture, out y)) 94 { 95 MessageBox.Show("Y is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 96 } 97 else 98 { 99 CurrentHudElements[Length - 1].Position.X = x; 100 CurrentHudElements[Length - 1].Position.Y = y; 101 } 102 } 103 else 104 { 105 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 106 } 107 break; 108 case "alignment": 109 if (Arguments.Length == 2) 110 { 111 int x, y; 112 if (!int.TryParse(Arguments[0], NumberStyles.Integer, Culture, out x)) 113 { 114 MessageBox.Show("X is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 115 } 116 else if (!int.TryParse(Arguments[1], NumberStyles.Integer, Culture, out y)) 117 { 118 MessageBox.Show("Y is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 119 } 120 else 121 { 122 CurrentHudElements[Length - 1].Alignment.X = Math.Sign(x); 123 CurrentHudElements[Length - 1].Alignment.Y = Math.Sign(y); 124 } 125 } 126 else 127 { 128 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 129 } 130 break; 131 case "topleft": 132 if (Arguments.Length == 2) 133 { 134 if (Arguments[0].Length != 0 & !Arguments[0].Equals("null", StringComparison.OrdinalIgnoreCase)) 135 { 136 Program.Renderer.TextureManager.RegisterTexture(OpenBveApi.Path.CombineFile(Folder, Arguments[0]), out CurrentHudElements[Length - 1].TopLeft.BackgroundTexture); 137 } 138 139 if (Arguments[1].Length != 0 & !Arguments[1].Equals("null", StringComparison.OrdinalIgnoreCase)) 140 { 141 Program.Renderer.TextureManager.RegisterTexture(OpenBveApi.Path.CombineFile(Folder, Arguments[1]), out CurrentHudElements[Length - 1].TopLeft.OverlayTexture); 142 } 143 } 144 else 145 { 146 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 147 } 148 break; 149 case "topmiddle": 150 if (Arguments.Length == 2) 151 { 152 if (Arguments[0].Length != 0 & !Arguments[0].Equals("null", StringComparison.OrdinalIgnoreCase)) 153 { 154 Program.Renderer.TextureManager.RegisterTexture(OpenBveApi.Path.CombineFile(Folder, Arguments[0]), out CurrentHudElements[Length - 1].TopMiddle.BackgroundTexture); 155 } 156 157 if (Arguments[1].Length != 0 & !Arguments[1].Equals("null", StringComparison.OrdinalIgnoreCase)) 158 { 159 Program.Renderer.TextureManager.RegisterTexture(OpenBveApi.Path.CombineFile(Folder, Arguments[1]), out CurrentHudElements[Length - 1].TopMiddle.OverlayTexture); 160 } 161 } 162 else 163 { 164 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 165 } 166 break; 167 case "topright": 168 if (Arguments.Length == 2) 169 { 170 if (Arguments[0].Length != 0 & !Arguments[0].Equals("null", StringComparison.OrdinalIgnoreCase)) 171 { 172 Program.Renderer.TextureManager.RegisterTexture(OpenBveApi.Path.CombineFile(Folder, Arguments[0]), out CurrentHudElements[Length - 1].TopRight.BackgroundTexture); 173 } 174 175 if (Arguments[1].Length != 0 & !Arguments[1].Equals("null", StringComparison.OrdinalIgnoreCase)) 176 { 177 Program.Renderer.TextureManager.RegisterTexture(OpenBveApi.Path.CombineFile(Folder, Arguments[1]), out CurrentHudElements[Length - 1].TopRight.OverlayTexture); 178 } 179 } 180 else 181 { 182 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 183 } 184 break; 185 case "centerleft": 186 if (Arguments.Length == 2) 187 { 188 if (Arguments[0].Length != 0 & !Arguments[0].Equals("null", StringComparison.OrdinalIgnoreCase)) 189 { 190 Program.Renderer.TextureManager.RegisterTexture(OpenBveApi.Path.CombineFile(Folder, Arguments[0]), out CurrentHudElements[Length - 1].CenterLeft.BackgroundTexture); 191 } 192 193 if (Arguments[1].Length != 0 & !Arguments[1].Equals("null", StringComparison.OrdinalIgnoreCase)) 194 { 195 Program.Renderer.TextureManager.RegisterTexture(OpenBveApi.Path.CombineFile(Folder, Arguments[1]), out CurrentHudElements[Length - 1].CenterLeft.OverlayTexture); 196 } 197 } 198 else 199 { 200 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 201 } 202 break; 203 case "centermiddle": 204 if (Arguments.Length == 2) 205 { 206 if (Arguments[0].Length != 0 & !Arguments[0].Equals("null", StringComparison.OrdinalIgnoreCase)) 207 { 208 Program.Renderer.TextureManager.RegisterTexture(OpenBveApi.Path.CombineFile(Folder, Arguments[0]), out CurrentHudElements[Length - 1].CenterMiddle.BackgroundTexture); 209 } 210 211 if (Arguments[1].Length != 0 & !Arguments[1].Equals("null", StringComparison.OrdinalIgnoreCase)) 212 { 213 Program.Renderer.TextureManager.RegisterTexture(OpenBveApi.Path.CombineFile(Folder, Arguments[1]), out CurrentHudElements[Length - 1].CenterMiddle.OverlayTexture); 214 } 215 } 216 else 217 { 218 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 219 } 220 break; 221 case "centerright": 222 if (Arguments.Length == 2) 223 { 224 if (Arguments[0].Length != 0 & !Arguments[0].Equals("null", StringComparison.OrdinalIgnoreCase)) 225 { 226 Program.Renderer.TextureManager.RegisterTexture(OpenBveApi.Path.CombineFile(Folder, Arguments[0]), out CurrentHudElements[Length - 1].CenterRight.BackgroundTexture); 227 } 228 229 if (Arguments[1].Length != 0 & !Arguments[1].Equals("null", StringComparison.OrdinalIgnoreCase)) 230 { 231 Program.Renderer.TextureManager.RegisterTexture(OpenBveApi.Path.CombineFile(Folder, Arguments[1]), out CurrentHudElements[Length - 1].CenterRight.OverlayTexture); 232 } 233 } 234 else 235 { 236 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 237 } 238 break; 239 case "bottomleft": 240 if (Arguments.Length == 2) 241 { 242 if (Arguments[0].Length != 0 & !Arguments[0].Equals("null", StringComparison.OrdinalIgnoreCase)) 243 { 244 Program.Renderer.TextureManager.RegisterTexture(OpenBveApi.Path.CombineFile(Folder, Arguments[0]), out CurrentHudElements[Length - 1].BottomLeft.BackgroundTexture); 245 } 246 247 if (Arguments[1].Length != 0 & !Arguments[1].Equals("null", StringComparison.OrdinalIgnoreCase)) 248 { 249 Program.Renderer.TextureManager.RegisterTexture(OpenBveApi.Path.CombineFile(Folder, Arguments[1]), out CurrentHudElements[Length - 1].BottomLeft.OverlayTexture); 250 } 251 } 252 else 253 { 254 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 255 } 256 break; 257 case "bottommiddle": 258 if (Arguments.Length == 2) 259 { 260 if (Arguments[0].Length != 0 & !Arguments[0].Equals("null", StringComparison.OrdinalIgnoreCase)) 261 { 262 Program.Renderer.TextureManager.RegisterTexture(OpenBveApi.Path.CombineFile(Folder, Arguments[0]), out CurrentHudElements[Length - 1].BottomMiddle.BackgroundTexture); 263 } 264 265 if (Arguments[1].Length != 0 & !Arguments[1].Equals("null", StringComparison.OrdinalIgnoreCase)) 266 { 267 Program.Renderer.TextureManager.RegisterTexture(OpenBveApi.Path.CombineFile(Folder, Arguments[1]), out CurrentHudElements[Length - 1].BottomMiddle.OverlayTexture); 268 } 269 } 270 else 271 { 272 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 273 } 274 break; 275 case "bottomright": 276 if (Arguments.Length == 2) 277 { 278 if (Arguments[0].Length != 0 & !Arguments[0].Equals("null", StringComparison.OrdinalIgnoreCase)) 279 { 280 Program.Renderer.TextureManager.RegisterTexture(OpenBveApi.Path.CombineFile(Folder, Arguments[0]), out CurrentHudElements[Length - 1].BottomRight.BackgroundTexture); 281 } 282 283 if (Arguments[1].Length != 0 & !Arguments[1].Equals("null", StringComparison.OrdinalIgnoreCase)) 284 { 285 Program.Renderer.TextureManager.RegisterTexture(OpenBveApi.Path.CombineFile(Folder, Arguments[1]), out CurrentHudElements[Length - 1].BottomRight.OverlayTexture); 286 } 287 } 288 else 289 { 290 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 291 } 292 break; 293 case "backcolor": 294 if (Arguments.Length == 4) 295 { 296 int r, g, b, a; 297 if (!int.TryParse(Arguments[0], NumberStyles.Integer, Culture, out r)) 298 { 299 MessageBox.Show("R is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 300 } 301 else if (!int.TryParse(Arguments[1], NumberStyles.Integer, Culture, out g)) 302 { 303 MessageBox.Show("G is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 304 } 305 else if (!int.TryParse(Arguments[2], NumberStyles.Integer, Culture, out b)) 306 { 307 MessageBox.Show("B is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 308 } 309 else if (!int.TryParse(Arguments[3], NumberStyles.Integer, Culture, out a)) 310 { 311 MessageBox.Show("A is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 312 } 313 else 314 { 315 r = r < 0 ? 0 : r > 255 ? 255 : r; 316 g = g < 0 ? 0 : g > 255 ? 255 : g; 317 b = b < 0 ? 0 : b > 255 ? 255 : b; 318 a = a < 0 ? 0 : a > 255 ? 255 : a; 319 CurrentHudElements[Length - 1].BackgroundColor = new Color32((byte) r, (byte) g, (byte) b, (byte) a); 320 } 321 322 break; 323 } 324 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 325 break; 326 case "overlaycolor": 327 if (Arguments.Length == 4) 328 { 329 int r, g, b, a; 330 if (!int.TryParse(Arguments[0], NumberStyles.Integer, Culture, out r)) 331 { 332 MessageBox.Show("R is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 333 } 334 else if (!int.TryParse(Arguments[1], NumberStyles.Integer, Culture, out g)) 335 { 336 MessageBox.Show("G is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 337 } 338 else if (!int.TryParse(Arguments[2], NumberStyles.Integer, Culture, out b)) 339 { 340 MessageBox.Show("B is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 341 } 342 else if (!int.TryParse(Arguments[3], NumberStyles.Integer, Culture, out a)) 343 { 344 MessageBox.Show("A is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 345 } 346 else 347 { 348 r = r < 0 ? 0 : r > 255 ? 255 : r; 349 g = g < 0 ? 0 : g > 255 ? 255 : g; 350 b = b < 0 ? 0 : b > 255 ? 255 : b; 351 a = a < 0 ? 0 : a > 255 ? 255 : a; 352 CurrentHudElements[Length - 1].OverlayColor = new Color32((byte) r, (byte) g, (byte) b, (byte) a); 353 } 354 355 break; 356 } 357 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 358 break; 359 case "textcolor": 360 if (Arguments.Length == 4) 361 { 362 int r, g, b, a; 363 if (!int.TryParse(Arguments[0], NumberStyles.Integer, Culture, out r)) 364 { 365 MessageBox.Show("R is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 366 } 367 else if (!int.TryParse(Arguments[1], NumberStyles.Integer, Culture, out g)) 368 { 369 MessageBox.Show("G is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 370 } 371 else if (!int.TryParse(Arguments[2], NumberStyles.Integer, Culture, out b)) 372 { 373 MessageBox.Show("B is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 374 } 375 else if (!int.TryParse(Arguments[3], NumberStyles.Integer, Culture, out a)) 376 { 377 MessageBox.Show("A is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 378 } 379 else 380 { 381 r = r < 0 ? 0 : r > 255 ? 255 : r; 382 g = g < 0 ? 0 : g > 255 ? 255 : g; 383 b = b < 0 ? 0 : b > 255 ? 255 : b; 384 a = a < 0 ? 0 : a > 255 ? 255 : a; 385 CurrentHudElements[Length - 1].TextColor = new Color32((byte) r, (byte) g, (byte) b, (byte) a); 386 } 387 388 break; 389 } 390 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 391 break; 392 case "textposition": 393 if (Arguments.Length == 2) 394 { 395 float x, y; 396 if (!float.TryParse(Arguments[0], NumberStyles.Float, Culture, out x)) 397 { 398 MessageBox.Show("X is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 399 } 400 else if (!float.TryParse(Arguments[1], NumberStyles.Float, Culture, out y)) 401 { 402 MessageBox.Show("Y is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 403 } 404 else 405 { 406 CurrentHudElements[Length - 1].TextPosition.X = x; 407 CurrentHudElements[Length - 1].TextPosition.Y = y; 408 } 409 } 410 else 411 { 412 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 413 } 414 break; 415 case "textalignment": 416 if (Arguments.Length == 2) 417 { 418 int x, y; 419 if (!int.TryParse(Arguments[0], NumberStyles.Integer, Culture, out x)) 420 { 421 MessageBox.Show("X is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 422 } 423 else if (!int.TryParse(Arguments[1], NumberStyles.Integer, Culture, out y)) 424 { 425 MessageBox.Show("Y is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 426 } 427 else 428 { 429 CurrentHudElements[Length - 1].TextAlignment.X = Math.Sign(x); 430 CurrentHudElements[Length - 1].TextAlignment.Y = Math.Sign(y); 431 } 432 } 433 else 434 { 435 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 436 } 437 break; 438 case "textsize": 439 if (Arguments.Length == 1) 440 { 441 int s; 442 if (!int.TryParse(Arguments[0], NumberStyles.Integer, Culture, out s)) 443 { 444 MessageBox.Show("SIZE is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 445 } 446 else 447 { 448 switch (s) 449 { 450 case 0: 451 CurrentHudElements[Length - 1].Font = Program.Renderer.Fonts.VerySmallFont; 452 break; 453 case 1: 454 CurrentHudElements[Length - 1].Font = Program.Renderer.Fonts.SmallFont; 455 break; 456 case 2: 457 CurrentHudElements[Length - 1].Font = Program.Renderer.Fonts.NormalFont; 458 break; 459 case 3: 460 CurrentHudElements[Length - 1].Font = Program.Renderer.Fonts.LargeFont; 461 break; 462 case 4: 463 CurrentHudElements[Length - 1].Font = Program.Renderer.Fonts.VeryLargeFont; 464 break; 465 default: 466 CurrentHudElements[Length - 1].Font = Program.Renderer.Fonts.NormalFont; 467 break; 468 } 469 } 470 } 471 else 472 { 473 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 474 } 475 break; 476 case "textshadow": 477 if (Arguments.Length == 1) 478 { 479 int s; 480 if (!int.TryParse(Arguments[0], NumberStyles.Integer, Culture, out s)) 481 { 482 MessageBox.Show("SHADOW is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 483 } 484 else 485 { 486 CurrentHudElements[Length - 1].TextShadow = s != 0; 487 } 488 } 489 else 490 { 491 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 492 } 493 break; 494 case "text": 495 if (Arguments.Length == 1) 496 { 497 CurrentHudElements[Length - 1].Text = Arguments[0]; 498 } 499 else 500 { 501 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 502 } 503 break; 504 case "value": 505 if (Arguments.Length == 1) 506 { 507 int n; 508 if (!int.TryParse(Arguments[0], NumberStyles.Integer, Culture, out n)) 509 { 510 MessageBox.Show("VALUE1 is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 511 } 512 else 513 { 514 CurrentHudElements[Length - 1].Value1 = n; 515 } 516 } 517 else if (Arguments.Length == 2) 518 { 519 float a, b; 520 if (!float.TryParse(Arguments[0], NumberStyles.Float, Culture, out a)) 521 { 522 MessageBox.Show("VALUE1 is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 523 } 524 else if (!float.TryParse(Arguments[1], NumberStyles.Float, Culture, out b)) 525 { 526 MessageBox.Show("VALUE2 is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 527 } 528 else 529 { 530 CurrentHudElements[Length - 1].Value1 = a; 531 CurrentHudElements[Length - 1].Value2 = b; 532 } 533 } 534 else 535 { 536 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 537 } 538 break; 539 case "transition": 540 if (Arguments.Length == 1) 541 { 542 int n; 543 if (!int.TryParse(Arguments[0], NumberStyles.Integer, Culture, out n)) 544 { 545 MessageBox.Show("TRANSITION is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 546 } 547 else 548 { 549 CurrentHudElements[Length - 1].Transition = (HUD.Transition) n; 550 } 551 } 552 else 553 { 554 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 555 } 556 break; 557 case "transitionvector": 558 if (Arguments.Length == 2) 559 { 560 float x, y; 561 if (!float.TryParse(Arguments[0], NumberStyles.Float, Culture, out x)) 562 { 563 MessageBox.Show("X is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 564 } 565 else if (!float.TryParse(Arguments[1], NumberStyles.Float, Culture, out y)) 566 { 567 MessageBox.Show("Y is invalid in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 568 } 569 else 570 { 571 CurrentHudElements[Length - 1].TransitionVector.X = x; 572 CurrentHudElements[Length - 1].TransitionVector.Y = y; 573 } 574 } 575 else 576 { 577 MessageBox.Show("Incorrect number of arguments supplied in " + Command + " at line " + (i + 1).ToString(Culture) + " in " + File); 578 } 579 580 break; 581 default: 582 MessageBox.Show("Invalid command encountered at line " + (i + 1).ToString(Culture) + " in " + File); 583 break; 584 } 585 } 586 else 587 { 588 MessageBox.Show("Invalid statement encountered at line " + (i + 1).ToString(Culture) + " in " + File); 589 } 590 } 591 } 592 } 593 } 594 } 595 596 Array.Resize(ref CurrentHudElements, Length); 597 } 598 } 599 } 600