|
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
| 3 | +using System.Globalization; |
3 | 4 | using System.Runtime.InteropServices; |
4 | 5 | using System.Text; |
5 | 6 |
|
@@ -447,6 +448,56 @@ public void Css0(CCSPlayerController player, CommandInfo info) |
447 | 448 | menuState.HandleInput(PlayerKey.SelectItem0, info.CallingContext == CommandCallingContext.Console); |
448 | 449 | } |
449 | 450 |
|
| 451 | + [ConsoleCommand("css_sharpmodmenu_pos_x")] |
| 452 | + public void SharpModMenuPosX(CCSPlayerController player, CommandInfo info) |
| 453 | + { |
| 454 | + if (player is null || !player.IsValid) |
| 455 | + return; |
| 456 | + var menuState = DriverInstance?.GetMenuState(player, create: true); |
| 457 | + if (menuState is null) |
| 458 | + return; |
| 459 | + |
| 460 | + if (info.ArgCount != 2) |
| 461 | + { |
| 462 | + info.ReplyToCommand($"css_sharpmodmenu_pos_x: Invalid number of arguments provided"); |
| 463 | + return; |
| 464 | + } |
| 465 | + |
| 466 | + var valStr = info.ArgByIndex(1); |
| 467 | + if (!float.TryParse(valStr, CultureInfo.InvariantCulture, out var val)) |
| 468 | + { |
| 469 | + info.ReplyToCommand($"css_sharpmodmenu_pos_x: Failed to parse argument as float: {valStr}"); |
| 470 | + return; |
| 471 | + } |
| 472 | + |
| 473 | + menuState.MenuPosition = menuState.MenuPosition with { X = val }; |
| 474 | + } |
| 475 | + |
| 476 | + [ConsoleCommand("css_sharpmodmenu_pos_y")] |
| 477 | + public void SharpModMenuPosY(CCSPlayerController player, CommandInfo info) |
| 478 | + { |
| 479 | + if (player is null || !player.IsValid) |
| 480 | + return; |
| 481 | + var menuState = DriverInstance?.GetMenuState(player, create: true); |
| 482 | + if (menuState is null) |
| 483 | + return; |
| 484 | + |
| 485 | + if (info.ArgCount != 2) |
| 486 | + { |
| 487 | + info.ReplyToCommand($"css_sharpmodmenu_pos_y: Invalid number of arguments provided"); |
| 488 | + return; |
| 489 | + } |
| 490 | + |
| 491 | + var valStr = info.ArgByIndex(1); |
| 492 | + if (!float.TryParse(valStr, CultureInfo.InvariantCulture, out var val)) |
| 493 | + { |
| 494 | + info.ReplyToCommand($"css_sharpmodmenu_pos_y: failed to parse argument as float: {valStr}"); |
| 495 | + return; |
| 496 | + } |
| 497 | + |
| 498 | + menuState.MenuPosition = menuState.MenuPosition with { Y = val }; |
| 499 | + } |
| 500 | + |
450 | 501 |
|
451 | 502 | public static string[] PrimaryGuns { get; } = |
452 | 503 | { |
|
0 commit comments