parent
8763be8a21
commit
a6e1172f97
5 changed files with 131 additions and 3049 deletions
|
|
@ -109,6 +109,69 @@ namespace Server
|
|||
public AccessLevel AccessLevel { get; }
|
||||
|
||||
public int CompareTo(CommandEntry e) => string.CompareOrdinal(Command, e?.Command);
|
||||
|
||||
public static List<CommandEntry> GetList()
|
||||
{
|
||||
var commands = new List<CommandEntry>(CommandSystem.Entries.Values);
|
||||
|
||||
commands.Sort();
|
||||
commands.Reverse();
|
||||
|
||||
for (var i = 0; i < commands.Count; ++i)
|
||||
{
|
||||
var e = commands[i];
|
||||
|
||||
for (var j = i + 1; j < commands.Count; ++j)
|
||||
{
|
||||
var c = commands[j];
|
||||
|
||||
if (e.Handler.Method == c.Handler.Method)
|
||||
{
|
||||
commands.RemoveAt(j);
|
||||
--j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return commands;
|
||||
}
|
||||
}
|
||||
|
||||
public record CommandInfo
|
||||
{
|
||||
public CommandInfo(AccessLevel accessLevel, string name, string[] aliases, string usage, string description)
|
||||
{
|
||||
AccessLevel = accessLevel;
|
||||
Name = name;
|
||||
Aliases = aliases;
|
||||
Usage = usage;
|
||||
Description = description;
|
||||
}
|
||||
|
||||
public AccessLevel AccessLevel { get; }
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public string[] Aliases { get; }
|
||||
|
||||
public string Usage { get; }
|
||||
|
||||
public string Description { get; }
|
||||
}
|
||||
|
||||
public class CommandInfoSorter : IComparer<CommandInfo>
|
||||
{
|
||||
public int Compare(CommandInfo a, CommandInfo b)
|
||||
{
|
||||
if (a == null && b == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
var v = b?.AccessLevel.CompareTo(a?.AccessLevel) ?? 1;
|
||||
|
||||
return v != 0 ? v : string.CompareOrdinal(a?.Name, b?.Name);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CommandSystem
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -3,8 +3,6 @@ using System.Text;
|
|||
using Server.Commands.Generic;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
using CommandInfo = Server.Commands.Docs.DocCommandEntry;
|
||||
using CommandInfoSorter = Server.Commands.Docs.CommandEntrySorter;
|
||||
|
||||
namespace Server.Commands
|
||||
{
|
||||
|
|
@ -54,12 +52,8 @@ namespace Server.Commands
|
|||
|
||||
public static void FillTable()
|
||||
{
|
||||
var commands = new List<CommandEntry>(CommandSystem.Entries.Values);
|
||||
var list = new List<CommandInfo>();
|
||||
|
||||
commands.Sort();
|
||||
commands.Reverse();
|
||||
Docs.Clean(commands);
|
||||
var commands = CommandEntry.GetList();
|
||||
|
||||
for (var i = 0; i < commands.Count; ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -257,7 +257,6 @@ namespace Server.Gumps
|
|||
{
|
||||
AddHtml(10, 125, 400, 20, Color(Center("Generating"), LabelColor32));
|
||||
|
||||
AddButtonLabeled(20, 150, GetButtonID(3, 100), "Documentation");
|
||||
AddButtonLabeled(220, 150, GetButtonID(3, 107), "Rebuild Categorization");
|
||||
|
||||
AddButtonLabeled(20, 175, GetButtonID(3, 101), "Teleporters");
|
||||
|
|
@ -2103,10 +2102,6 @@ namespace Server.Gumps
|
|||
page = AdminGumpPage.Administer_Commands;
|
||||
break;
|
||||
|
||||
case 100:
|
||||
InvokeCommand("DocGen");
|
||||
notice = "Documentation has been generated.";
|
||||
break;
|
||||
case 101:
|
||||
InvokeCommand("TelGen");
|
||||
notice = "Teleporters have been generated.";
|
||||
|
|
@ -2115,10 +2110,6 @@ namespace Server.Gumps
|
|||
InvokeCommand("MoonGen");
|
||||
notice = "Moongates have been generated.";
|
||||
break;
|
||||
case 103:
|
||||
InvokeCommand("UOAMVendors");
|
||||
notice = "Vendor spawners have been generated.";
|
||||
break;
|
||||
case 104:
|
||||
InvokeCommand("DoorGen");
|
||||
notice = "Doors have been generated.";
|
||||
|
|
|
|||
|
|
@ -1,11 +1,22 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Server.Commands;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public enum ModelBodyType
|
||||
{
|
||||
Invalid = -1,
|
||||
Monsters,
|
||||
Sea,
|
||||
Animals,
|
||||
Human,
|
||||
Equipment
|
||||
}
|
||||
|
||||
public class SetBodyGump : Gump
|
||||
{
|
||||
private const int LabelColor32 = 0xFFFFFF;
|
||||
|
|
@ -227,6 +238,47 @@ namespace Server.Gumps
|
|||
}
|
||||
}
|
||||
|
||||
public static List<BodyEntry> LoadBodies()
|
||||
{
|
||||
var list = new List<BodyEntry>();
|
||||
|
||||
var path = Path.Combine(Core.BaseDirectory, "Data/models.txt");
|
||||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
using var ip = new StreamReader(path);
|
||||
string line;
|
||||
|
||||
while ((line = ip.ReadLine()) != null)
|
||||
{
|
||||
line = line.Trim();
|
||||
|
||||
if (line.Length == 0 || line.StartsWithOrdinal("#"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var split = line.Split('\t');
|
||||
|
||||
if (split.Length >= 9)
|
||||
{
|
||||
Body body = Utility.ToInt32(split[0]);
|
||||
var type = (ModelBodyType)Utility.ToInt32(split[1]);
|
||||
var name = split[8];
|
||||
|
||||
var entry = new BodyEntry(body, type, name);
|
||||
|
||||
if (!list.Contains(entry))
|
||||
{
|
||||
list.Add(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private static void LoadLists()
|
||||
{
|
||||
m_Monster = new List<InternalEntry>();
|
||||
|
|
@ -234,7 +286,7 @@ namespace Server.Gumps
|
|||
m_Sea = new List<InternalEntry>();
|
||||
m_Human = new List<InternalEntry>();
|
||||
|
||||
var entries = Docs.LoadBodies();
|
||||
var entries = LoadBodies();
|
||||
|
||||
for (var i = 0; i < entries.Count; ++i)
|
||||
{
|
||||
|
|
@ -335,5 +387,19 @@ namespace Server.Gumps
|
|||
return v == 0 ? Body.CompareTo(comp.Body) : v;
|
||||
}
|
||||
}
|
||||
|
||||
public record BodyEntry
|
||||
{
|
||||
public BodyEntry(Body body, ModelBodyType bodyType, string name)
|
||||
{
|
||||
Body = body;
|
||||
BodyType = bodyType;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public Body Body { get; }
|
||||
public ModelBodyType BodyType { get; }
|
||||
public string Name { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue