| Line | |
|---|
| 1 | using System;
|
|---|
| 2 | using System.Collections.Generic;
|
|---|
| 3 |
|
|---|
| 4 | namespace AllocsFixes.CustomCommands
|
|---|
| 5 | {
|
|---|
| 6 | public class ListItems : ConsoleCmdAbstract
|
|---|
| 7 | {
|
|---|
| 8 | public override string GetDescription ()
|
|---|
| 9 | {
|
|---|
| 10 | return "lists all items that contain the given substring";
|
|---|
| 11 | }
|
|---|
| 12 |
|
|---|
| 13 | public override string[] GetCommands ()
|
|---|
| 14 | {
|
|---|
| 15 | return new string[] { "listitems", "li" };
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | public override string GetHelp () {
|
|---|
| 19 | return "List all available item names\n" +
|
|---|
| 20 | "Usage:\n" +
|
|---|
| 21 | " 1. listitems <searchString>\n" +
|
|---|
| 22 | " 2. listitems *\n" +
|
|---|
| 23 | "1. List only names that contain the given string.\n" +
|
|---|
| 24 | "2. List all names.";
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | public override void Execute (List<string> _params, CommandSenderInfo _senderInfo)
|
|---|
| 28 | {
|
|---|
| 29 | try {
|
|---|
| 30 | if (_params.Count != 1 || _params [0].Length == 0) {
|
|---|
| 31 | SdtdConsole.Instance.Output ("Usage: listitems <searchString>");
|
|---|
| 32 | return;
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | int count = ItemClass.ItemNames.Count;
|
|---|
| 36 | bool showAll = _params[0].Trim().Equals("*");
|
|---|
| 37 |
|
|---|
| 38 | int listed = 0;
|
|---|
| 39 | for (int i = 0; i < count; i++) {
|
|---|
| 40 | string s = ItemClass.ItemNames [i];
|
|---|
| 41 | if (showAll || s.IndexOf (_params [0], StringComparison.OrdinalIgnoreCase) >= 0) {
|
|---|
| 42 | SdtdConsole.Instance.Output (" " + s);
|
|---|
| 43 | listed++;
|
|---|
| 44 | }
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | SdtdConsole.Instance.Output ("Listed " + listed + " matching items.");
|
|---|
| 48 | } catch (Exception e) {
|
|---|
| 49 | Log.Out ("Error in ListItems.Run: " + e);
|
|---|
| 50 | }
|
|---|
| 51 | }
|
|---|
| 52 | }
|
|---|
| 53 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.