Initial commit
This commit is contained in:
+79
@@ -0,0 +1,79 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Engines.UOStore
|
||||
{
|
||||
public class PlayerProfile
|
||||
{
|
||||
public const StoreCategory DefaultCategory = StoreCategory.Featured;
|
||||
public const SortBy DefaultSortBy = SortBy.Newest;
|
||||
|
||||
public Dictionary<StoreEntry, int> Cart { get; private set; }
|
||||
|
||||
public Mobile Player { get; private set; }
|
||||
|
||||
public StoreCategory Category { get; set; }
|
||||
public SortBy SortBy { get; set; }
|
||||
|
||||
public PlayerProfile(Mobile m)
|
||||
{
|
||||
Cart = new Dictionary<StoreEntry, int>();
|
||||
|
||||
Player = m;
|
||||
|
||||
Category = DefaultCategory;
|
||||
SortBy = DefaultSortBy;
|
||||
}
|
||||
|
||||
public PlayerProfile(GenericReader reader)
|
||||
{
|
||||
Cart = new Dictionary<StoreEntry, int>();
|
||||
|
||||
Deserialize(reader);
|
||||
}
|
||||
|
||||
public void AddToCart(StoreEntry entry, int amount)
|
||||
{
|
||||
if (Cart.Count < Configuration.CartCapacity)
|
||||
{
|
||||
Cart[entry] = amount;
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveFromCart(StoreEntry entry)
|
||||
{
|
||||
Cart.Remove(entry);
|
||||
}
|
||||
|
||||
public void SetCartAmount(StoreEntry entry, int amount)
|
||||
{
|
||||
if (amount > 0)
|
||||
{
|
||||
AddToCart(entry, amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveFromCart(entry);
|
||||
}
|
||||
}
|
||||
|
||||
public void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.Write(0);
|
||||
|
||||
writer.Write(Player);
|
||||
|
||||
writer.Write((int)Category);
|
||||
writer.Write((int)SortBy);
|
||||
}
|
||||
|
||||
public void Deserialize(GenericReader reader)
|
||||
{
|
||||
reader.ReadInt();
|
||||
|
||||
Player = reader.ReadMobile();
|
||||
|
||||
Category = (StoreCategory)reader.ReadInt();
|
||||
SortBy = (SortBy)reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
+302
@@ -0,0 +1,302 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Mobiles;
|
||||
using Server.Commands;
|
||||
|
||||
namespace Server.Engines.UOStore
|
||||
{
|
||||
public static class PromoCodeSystem
|
||||
{
|
||||
private static readonly string FilePath = Path.Combine(Core.BaseDirectory, "Data/PromoCodes.json");
|
||||
|
||||
// Category → List of codes
|
||||
public static Dictionary<string, List<string>> Codes = new Dictionary<string, List<string>>();
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
Load();
|
||||
|
||||
CommandSystem.Register("PromoReload", AccessLevel.Administrator, e =>
|
||||
{
|
||||
Load();
|
||||
e.Mobile.SendMessage("Promo codes reloaded.");
|
||||
});
|
||||
|
||||
CommandSystem.Register("PromoSave", AccessLevel.Administrator, e =>
|
||||
{
|
||||
Save();
|
||||
e.Mobile.SendMessage("Promo codes saved.");
|
||||
});
|
||||
}
|
||||
|
||||
#region JSON LOAD/SAVE
|
||||
|
||||
public static void Load()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!File.Exists(FilePath))
|
||||
{
|
||||
Console.WriteLine("[PromoCodes] No JSON file found, creating empty file.");
|
||||
Save();
|
||||
return;
|
||||
}
|
||||
|
||||
string json = File.ReadAllText(FilePath);
|
||||
var root = MiniJson.Parse(json) as Dictionary<string, object>;
|
||||
|
||||
Codes.Clear();
|
||||
|
||||
if (root != null)
|
||||
{
|
||||
foreach (var kvp in root)
|
||||
{
|
||||
var list = new List<string>();
|
||||
|
||||
foreach (var code in (List<object>)kvp.Value)
|
||||
list.Add(code.ToString());
|
||||
|
||||
Codes[kvp.Key] = list;
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("[PromoCodes] Loaded " + Codes.Count + " categories.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("[PromoCodes] ERROR loading JSON: " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Save()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var sw = new StreamWriter(FilePath))
|
||||
{
|
||||
sw.WriteLine("{");
|
||||
|
||||
int ci = 0;
|
||||
foreach (var kvp in Codes)
|
||||
{
|
||||
sw.Write($" \"{kvp.Key}\": [");
|
||||
|
||||
for (int i = 0; i < kvp.Value.Count; i++)
|
||||
{
|
||||
sw.Write($"\"{kvp.Value[i]}\"");
|
||||
if (i < kvp.Value.Count - 1)
|
||||
sw.Write(", ");
|
||||
}
|
||||
|
||||
sw.Write("]");
|
||||
|
||||
if (ci < Codes.Count - 1)
|
||||
sw.Write(",");
|
||||
|
||||
sw.WriteLine();
|
||||
ci++;
|
||||
}
|
||||
|
||||
sw.WriteLine("}");
|
||||
}
|
||||
|
||||
Console.WriteLine("[PromoCodes] Saved promo code JSON.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("[PromoCodes] ERROR saving JSON: " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Redemption
|
||||
|
||||
public static bool TryRedeem(PlayerMobile pm, string code)
|
||||
{
|
||||
foreach (var kvp in Codes)
|
||||
{
|
||||
string category = kvp.Key;
|
||||
List<string> list = kvp.Value;
|
||||
|
||||
if (list.Contains(code))
|
||||
{
|
||||
list.Remove(code);
|
||||
Save();
|
||||
|
||||
GiveReward(pm, category);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void GiveReward(PlayerMobile pm, string category)
|
||||
{
|
||||
switch (category)
|
||||
{
|
||||
case "MountTokens":
|
||||
pm.AddToBackpack(new EtherealHorse());
|
||||
pm.SendMessage(0x55, "You received an Ethereal Mount!");
|
||||
break;
|
||||
|
||||
case "StarterPack":
|
||||
pm.AddToBackpack(new BagOfReagents());
|
||||
pm.AddToBackpack(new Gold(5000));
|
||||
pm.SendMessage(0x55, "You received a Starter Pack!");
|
||||
break;
|
||||
|
||||
case "HolidayGifts":
|
||||
pm.AddToBackpack(new GiftBox());
|
||||
pm.SendMessage(0x55, "Happy Holidays!");
|
||||
break;
|
||||
case "SoulStoneTokens":
|
||||
pm.AddToBackpack(new SoulstoneToken());
|
||||
pm.SendMessage(0x55, "You received a Soul Stone Token!");
|
||||
break;
|
||||
|
||||
default:
|
||||
pm.SendMessage(0x22, "Unknown promo reward category: " + category);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region Mini JSON Parser (No Dependencies)
|
||||
|
||||
public static class MiniJson
|
||||
{
|
||||
public static object Parse(string json)
|
||||
{
|
||||
return new JsonParser(json).ParseValue();
|
||||
}
|
||||
|
||||
private class JsonParser
|
||||
{
|
||||
private readonly string _json;
|
||||
private int _i;
|
||||
|
||||
public JsonParser(string json)
|
||||
{
|
||||
_json = json;
|
||||
}
|
||||
|
||||
public object ParseValue()
|
||||
{
|
||||
Skip();
|
||||
|
||||
if (_i >= _json.Length)
|
||||
return null;
|
||||
|
||||
char c = _json[_i];
|
||||
|
||||
if (c == '{') return ParseObject();
|
||||
if (c == '[') return ParseArray();
|
||||
if (c == '"') return ParseString();
|
||||
if (char.IsDigit(c) || c == '-') return ParseNumber();
|
||||
|
||||
if (Match("true")) return true;
|
||||
if (Match("false")) return false;
|
||||
if (Match("null")) return null;
|
||||
|
||||
throw new Exception("Invalid JSON at " + _i);
|
||||
}
|
||||
|
||||
private Dictionary<string, object> ParseObject()
|
||||
{
|
||||
var dict = new Dictionary<string, object>();
|
||||
_i++; // skip {
|
||||
|
||||
while (true)
|
||||
{
|
||||
Skip();
|
||||
if (_json[_i] == '}') { _i++; break; }
|
||||
|
||||
string key = ParseString();
|
||||
|
||||
Skip();
|
||||
_i++; // skip :
|
||||
|
||||
object val = ParseValue();
|
||||
dict[key] = val;
|
||||
|
||||
Skip();
|
||||
if (_json[_i] == ',') { _i++; continue; }
|
||||
if (_json[_i] == '}') { _i++; break; }
|
||||
}
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
private List<object> ParseArray()
|
||||
{
|
||||
var list = new List<object>();
|
||||
_i++; // skip [
|
||||
|
||||
while (true)
|
||||
{
|
||||
Skip();
|
||||
if (_json[_i] == ']') { _i++; break; }
|
||||
|
||||
list.Add(ParseValue());
|
||||
|
||||
Skip();
|
||||
if (_json[_i] == ',') { _i++; continue; }
|
||||
if (_json[_i] == ']') { _i++; break; }
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private string ParseString()
|
||||
{
|
||||
_i++; // skip "
|
||||
int start = _i;
|
||||
|
||||
while (_json[_i] != '"')
|
||||
_i++;
|
||||
|
||||
string s = _json.Substring(start, _i - start);
|
||||
_i++; // skip closing "
|
||||
return s;
|
||||
}
|
||||
|
||||
private double ParseNumber()
|
||||
{
|
||||
int start = _i;
|
||||
|
||||
while (_i < _json.Length &&
|
||||
(char.IsDigit(_json[_i]) || _json[_i] == '.' || _json[_i] == '-'))
|
||||
{
|
||||
_i++;
|
||||
}
|
||||
|
||||
return double.Parse(_json.Substring(start, _i - start));
|
||||
}
|
||||
|
||||
private void Skip()
|
||||
{
|
||||
while (_i < _json.Length && char.IsWhiteSpace(_json[_i]))
|
||||
_i++;
|
||||
}
|
||||
|
||||
private bool Match(string s)
|
||||
{
|
||||
if (_json.Substring(_i).StartsWith(s))
|
||||
{
|
||||
_i += s.Length;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
Configuration File: Scripts/Services/UltimaStore/SystemConfig.cs
|
||||
|
||||
Recommend you use custom currency when using this system. EA uses sovreigns which come to about 5,000 for 49.95 US dollars. This is a good base on how to value the items. The item cost in the store are per EA, so careful attention should be made when balancing out your currency system, and how that currency will be obtained. Flooding your market with some of these items will not be a good idea.
|
||||
|
||||
Also, if you're like me, and hate the flashy hues, you can comment out the store entries in UltimaStore.cs to your liking.
|
||||
|
||||
Currently, the system supports Gold or points system currency. For a list of various points systems, go to PointsSystems.cs where a solid list can be viewed. If you use a custom currency [recommended], you will need to modify the following functions in SystemConfig.cs:
|
||||
|
||||
public static double GetCustomCurrency(Mobile m)
|
||||
|
||||
- this needs to return the currency for that player. THis is to ensure they have sufficient currency before an item can be purchased.
|
||||
|
||||
public static void DeductCustomCurrecy(Mobile m)
|
||||
|
||||
- This ensures that the currency points are actually deducted after the sale. It's a good idea to get this right.
|
||||
|
||||
CurrencyType description:
|
||||
|
||||
None - disables the system
|
||||
Sovereigns - Sovereigns, added as a seperate account currency, will be up to the shard owners how to be implemented.
|
||||
Gold - uses standard gold currency. If you use this, I would suggest your increase the PointMultiplier, significantly so your not flooding your market with these items
|
||||
PointsSystem - using this, you will have to designate PointsSystemCurrency as to which points system your going to use. Check PointsSystem.cs for a list of all the points systems, ie Despise Crystals, Void Pool points, etc
|
||||
Custom - see above on how to implement custom currency
|
||||
Executable
+111
@@ -0,0 +1,111 @@
|
||||
using System;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Engines.UOStore
|
||||
{
|
||||
public class StoreEntry
|
||||
{
|
||||
private static int m_GlobalIndex = 0;
|
||||
public int Index { get; private set; }
|
||||
public Type ItemType { get; private set; }
|
||||
public TextDefinition[] Name { get; private set; }
|
||||
public int Tooltip { get; private set; }
|
||||
public string TooltipText { get; private set; }
|
||||
public int GumpID { get; private set; }
|
||||
public int ItemID { get; private set; }
|
||||
public int Hue { get; private set; }
|
||||
public int Price { get; private set; }
|
||||
public StoreCategory Category { get; private set; }
|
||||
public Func<Mobile, StoreEntry, Item> Constructor { get; private set; }
|
||||
|
||||
public int Cost { get { return (int)Math.Ceiling(Price * Configuration.CostMultiplier); } }
|
||||
|
||||
public StoreEntry(Type itemType, TextDefinition name, int tooltip, int itemID, int gumpID, int hue, int cost, StoreCategory cat, Func<Mobile, StoreEntry, Item> constructor = null)
|
||||
: this(itemType, new[] { name }, tooltip, itemID, gumpID, hue, cost, cat, constructor)
|
||||
{ }
|
||||
|
||||
public StoreEntry(Type itemType, TextDefinition name, string tooltipText, int itemID, int gumpID, int hue, int cost, StoreCategory cat, Func<Mobile, StoreEntry, Item> constructor = null)
|
||||
: this(itemType, new[] { name }, tooltipText, itemID, gumpID, hue, cost, cat, constructor)
|
||||
{ }
|
||||
|
||||
public StoreEntry(Type itemType, TextDefinition[] name, int tooltip, int itemID, int gumpID, int hue, int cost, StoreCategory cat, Func<Mobile, StoreEntry, Item> constructor = null)
|
||||
{
|
||||
ItemType = itemType;
|
||||
Name = name;
|
||||
Tooltip = tooltip;
|
||||
TooltipText = null;
|
||||
ItemID = itemID;
|
||||
GumpID = gumpID;
|
||||
Hue = hue;
|
||||
Price = cost;
|
||||
Category = cat;
|
||||
Constructor = constructor;
|
||||
Index = m_GlobalIndex++;
|
||||
}
|
||||
|
||||
public StoreEntry(Type itemType, TextDefinition[] name, string tooltipText, int itemID, int gumpID, int hue, int cost, StoreCategory cat, Func<Mobile, StoreEntry, Item> constructor = null)
|
||||
: this(itemType, name, 0, itemID, gumpID, hue, cost, cat, constructor)
|
||||
{
|
||||
TooltipText = tooltipText;
|
||||
}
|
||||
|
||||
public bool Construct(Mobile m, bool test = false)
|
||||
{
|
||||
Item item;
|
||||
|
||||
if (Constructor != null)
|
||||
{
|
||||
item = Constructor(m, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
item = Activator.CreateInstance(ItemType) as Item;
|
||||
}
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
if (item is IAccountRestricted)
|
||||
{
|
||||
((IAccountRestricted)item).Account = m.Account.Username;
|
||||
}
|
||||
|
||||
if (m.Backpack == null || !m.Alive || !m.Backpack.TryDropItem(m, item, false))
|
||||
{
|
||||
UltimaStore.AddPendingItem(m, item);
|
||||
|
||||
// Your purchased will be delivered to you once you free up room in your backpack.
|
||||
// Your purchased item will be delivered to you once you are resurrected.
|
||||
m.SendLocalizedMessage(m.Alive ? 1156846 : 1156848);
|
||||
}
|
||||
else if (item is IPromotionalToken && ((IPromotionalToken)item).ItemName != null)
|
||||
{
|
||||
// A token has been placed in your backpack. Double-click it to redeem your ~1_PROMO~.
|
||||
m.SendLocalizedMessage(1075248, ((IPromotionalToken)item).ItemName.ToString());
|
||||
}
|
||||
else if (item.LabelNumber > 0 || item.Name != null)
|
||||
{
|
||||
var name = item.LabelNumber > 0 ? ("#" + item.LabelNumber) : item.Name;
|
||||
|
||||
// Your purchase of ~1_ITEM~ has been placed in your backpack.
|
||||
m.SendLocalizedMessage(1156844, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Your purchased item has been placed in your backpack.
|
||||
m.SendLocalizedMessage(1156843);
|
||||
}
|
||||
|
||||
if (test)
|
||||
{
|
||||
item.Delete();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Utility.WriteConsoleColor(ConsoleColor.Red, String.Format("[Ultima Store Warning]: {0} failed to construct.", ItemType.Name));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+87
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using Server.Engines.Points;
|
||||
|
||||
namespace Server.Engines.UOStore
|
||||
{
|
||||
public enum CurrencyType
|
||||
{
|
||||
None,
|
||||
Sovereigns,
|
||||
Gold,
|
||||
PointsSystem,
|
||||
Custom
|
||||
}
|
||||
|
||||
public delegate int CustomCurrencyHandler(Mobile m, int consume);
|
||||
|
||||
public static class Configuration
|
||||
{
|
||||
public static bool Enabled { get; set; }
|
||||
public static Expansion Expansion { get; set; }
|
||||
public static string Website { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A hook to allow handling of custom currencies.
|
||||
/// This implementation should be treated as such;
|
||||
/// If 'consume' is less than zero, return the currency total.
|
||||
/// Else deduct from the currency total, return the amount consumed.
|
||||
/// </summary>
|
||||
public static CustomCurrencyHandler ResolveCurrency { get; set; }
|
||||
|
||||
public static CurrencyType CurrencyImpl { get; set; }
|
||||
public static string CurrencyName { get; set; }
|
||||
public static bool CurrencyDisplay { get; set; }
|
||||
|
||||
public static PointsType PointsImpl { get; set; }
|
||||
|
||||
public static double CostMultiplier { get; set; }
|
||||
|
||||
public static int CartCapacity { get; set; }
|
||||
|
||||
static Configuration()
|
||||
{
|
||||
Enabled = Config.Get("Store.Enabled", true);
|
||||
Expansion = Config.GetEnum("Store.Expansion", Expansion.TOL);
|
||||
Website = Config.Get("Store.Website", "https://uo.com/ultima-store/");
|
||||
|
||||
ResolveCurrency = Config.GetDelegate("Store.ResolveCurrency", (CustomCurrencyHandler)null);
|
||||
|
||||
CurrencyImpl = Config.GetEnum("Store.CurrencyImpl", CurrencyType.Sovereigns);
|
||||
CurrencyName = Config.Get("Store.CurrencyName", "Sovereigns");
|
||||
CurrencyDisplay = Config.Get("Store.CurrencyDisplay", true);
|
||||
|
||||
PointsImpl = Config.GetEnum("Store.PointsImpl", PointsType.None);
|
||||
|
||||
CostMultiplier = Config.Get("Store.CostMultiplier", 1.0);
|
||||
CartCapacity = Config.Get("Store.CartCapacity", 10);
|
||||
}
|
||||
|
||||
public static int GetCustomCurrency(Mobile m)
|
||||
{
|
||||
if (ResolveCurrency != null)
|
||||
{
|
||||
return ResolveCurrency(m, -1);
|
||||
}
|
||||
|
||||
m.SendMessage(1174, "Currency is not set up for this system. Contact a shard administrator.");
|
||||
|
||||
Utility.WriteConsoleColor(ConsoleColor.Red, "[Ultima Store]: No custom currency method has been implemented.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int DeductCustomCurrecy(Mobile m, int amount)
|
||||
{
|
||||
if (ResolveCurrency != null)
|
||||
{
|
||||
return ResolveCurrency(m, amount);
|
||||
}
|
||||
|
||||
m.SendMessage(1174, "Currency is not set up for this system. Contact a shard administrator.");
|
||||
|
||||
Utility.WriteConsoleColor(ConsoleColor.Red, "[Ultima Store]: No custom currency deduction method has been implemented.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+960
@@ -0,0 +1,960 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Server.Commands;
|
||||
using Server.Mobiles;
|
||||
using Server.Items;
|
||||
using Server.Engines.VendorSearching;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
using Server.Engines.Points;
|
||||
using Server.Multis;
|
||||
|
||||
namespace Server.Engines.UOStore
|
||||
{
|
||||
public enum StoreCategory
|
||||
{
|
||||
None,
|
||||
Featured,
|
||||
Character,
|
||||
Equipment,
|
||||
Decorations,
|
||||
Mounts,
|
||||
Misc,
|
||||
Cart
|
||||
}
|
||||
|
||||
public enum SortBy
|
||||
{
|
||||
Name,
|
||||
PriceLower,
|
||||
PriceHigher,
|
||||
Newest,
|
||||
Oldest
|
||||
}
|
||||
|
||||
public static class UltimaStore
|
||||
{
|
||||
public static readonly string FilePath = Path.Combine("Saves/Misc", "UltimaStore.bin");
|
||||
|
||||
public static bool Enabled { get { return Configuration.Enabled; } set { Configuration.Enabled = value; } }
|
||||
|
||||
public static List<StoreEntry> Entries { get; private set; }
|
||||
public static Dictionary<Mobile, List<Item>> PendingItems { get; private set; }
|
||||
|
||||
private static UltimaStoreContainer _UltimaStoreContainer;
|
||||
|
||||
public static UltimaStoreContainer UltimaStoreContainer
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_UltimaStoreContainer != null && _UltimaStoreContainer.Deleted)
|
||||
{
|
||||
_UltimaStoreContainer = null;
|
||||
}
|
||||
|
||||
return _UltimaStoreContainer ?? (_UltimaStoreContainer = new UltimaStoreContainer());
|
||||
}
|
||||
}
|
||||
|
||||
static UltimaStore()
|
||||
{
|
||||
Entries = new List<StoreEntry>();
|
||||
PendingItems = new Dictionary<Mobile, List<Item>>();
|
||||
PlayerProfiles = new Dictionary<Mobile, PlayerProfile>();
|
||||
}
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
PacketHandlers.Register(0xFA, 1, true, UOStoreRequest);
|
||||
CommandSystem.Register("Store", AccessLevel.Player, e => OpenStore(e.Mobile as PlayerMobile));
|
||||
|
||||
LoadJson(); // ⭐ REQUIRED
|
||||
|
||||
EventSink.WorldSave += OnSave;
|
||||
EventSink.WorldLoad += OnLoad;
|
||||
|
||||
PromoCodeSystem.Initialize();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
|
||||
}
|
||||
public static void LoadJson()
|
||||
{
|
||||
string path = Path.Combine(Core.BaseDirectory, "Data/UltimaStore.json");
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Console.WriteLine("UltimaStore: JSON file not found: " + path);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
string json = File.ReadAllText(path);
|
||||
|
||||
var root = MiniJson.Parse(json) as Dictionary<string, object>;
|
||||
|
||||
if (root == null)
|
||||
{
|
||||
Console.WriteLine("UltimaStore: JSON root is null or invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
Entries.Clear();
|
||||
|
||||
foreach (var kvp in root)
|
||||
{
|
||||
string categoryName = kvp.Key;
|
||||
StoreCategory category;
|
||||
|
||||
if (!Enum.TryParse(categoryName, true, out category))
|
||||
category = StoreCategory.Misc;
|
||||
|
||||
var list = kvp.Value as List<object>;
|
||||
if (list == null)
|
||||
continue;
|
||||
|
||||
foreach (var obj in list)
|
||||
{
|
||||
var dict = obj as Dictionary<string, object>;
|
||||
if (dict == null)
|
||||
continue;
|
||||
|
||||
//
|
||||
// 1. Resolve Item Type
|
||||
//
|
||||
string typeName = dict["Type"].ToString();
|
||||
|
||||
// Remove namespace if present
|
||||
if (typeName.Contains("."))
|
||||
typeName = typeName.Split('.').Last();
|
||||
|
||||
Type itemType = ScriptCompiler.FindTypeByName(typeName);
|
||||
|
||||
if (itemType == null)
|
||||
{
|
||||
Console.WriteLine($"UltimaStore JSON: Unknown item type '{typeName}'");
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// 2. Build Name (TextDefinition[])
|
||||
//
|
||||
TextDefinition[] nameDefs = new TextDefinition[0];
|
||||
|
||||
if (dict.ContainsKey("NameLines"))
|
||||
{
|
||||
var arr = dict["NameLines"] as List<object>;
|
||||
|
||||
if (arr != null)
|
||||
{
|
||||
nameDefs = new TextDefinition[arr.Count];
|
||||
|
||||
for (int i = 0; i < arr.Count; i++)
|
||||
{
|
||||
string raw = arr[i].ToString().Trim();
|
||||
|
||||
if (int.TryParse(raw, out int cliloc))
|
||||
nameDefs[i] = new TextDefinition(cliloc);
|
||||
else
|
||||
nameDefs[i] = new TextDefinition(raw);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 3. Tooltip
|
||||
//
|
||||
int tooltip = dict.ContainsKey("Tooltip") ? Convert.ToInt32(dict["Tooltip"]) : 0;
|
||||
string tooltipText = dict.ContainsKey("TooltipText") ? dict["TooltipText"].ToString() : null;
|
||||
|
||||
//
|
||||
// 4. Other fields
|
||||
//
|
||||
int itemID = dict.ContainsKey("ItemID") ? Convert.ToInt32(dict["ItemID"]) : 0;
|
||||
int gumpID = dict.ContainsKey("GumpID") ? Convert.ToInt32(dict["GumpID"]) : 0;
|
||||
int hue = dict.ContainsKey("Hue") ? Convert.ToInt32(dict["Hue"]) : 0;
|
||||
int price = dict.ContainsKey("Price") ? Convert.ToInt32(dict["Price"]) : 0;
|
||||
|
||||
//
|
||||
// 5. Create StoreEntry using the correct constructor
|
||||
//
|
||||
StoreEntry entry;
|
||||
|
||||
if (!string.IsNullOrEmpty(tooltipText))
|
||||
{
|
||||
entry = new StoreEntry(itemType, nameDefs, tooltipText, itemID, gumpID, hue, price, category);
|
||||
}
|
||||
else
|
||||
{
|
||||
entry = new StoreEntry(itemType, nameDefs, tooltip, itemID, gumpID, hue, price, category);
|
||||
}
|
||||
|
||||
//
|
||||
// 6. Add to store
|
||||
//
|
||||
Entries.Add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"UltimaStore: Loaded {Entries.Count} entries from JSON.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("UltimaStore JSON Load Error: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void Register<T>(TextDefinition name, int tooltip, int itemID, int gumpID, int hue, int cost, StoreCategory cat, Func<Mobile, StoreEntry, Item> constructor = null) where T : Item
|
||||
{
|
||||
Register(typeof(T), name, tooltip, itemID, gumpID, hue, cost, cat, constructor);
|
||||
}
|
||||
|
||||
public static void Register(Type itemType, TextDefinition name, int tooltip, int itemID, int gumpID, int hue, int cost, StoreCategory cat, Func<Mobile, StoreEntry, Item> constructor = null)
|
||||
{
|
||||
Register(new StoreEntry(itemType, name, tooltip, itemID, gumpID, hue, cost, cat, constructor));
|
||||
}
|
||||
|
||||
public static void Register<T>(TextDefinition[] name, int tooltip, int itemID, int gumpID, int hue, int cost, StoreCategory cat, Func<Mobile, StoreEntry, Item> constructor = null) where T : Item
|
||||
{
|
||||
Register(typeof(T), name, tooltip, itemID, gumpID, hue, cost, cat, constructor);
|
||||
}
|
||||
|
||||
public static void Register(Type itemType, TextDefinition[] name, int tooltip, int itemID, int gumpID, int hue, int cost, StoreCategory cat, Func<Mobile, StoreEntry, Item> constructor = null)
|
||||
{
|
||||
Register(new StoreEntry(itemType, name, tooltip, itemID, gumpID, hue, cost, cat, constructor));
|
||||
}
|
||||
|
||||
public static void Register<T>(TextDefinition name, string tooltipText, int itemID, int gumpID, int hue, int cost, StoreCategory cat, Func<Mobile, StoreEntry, Item> constructor = null) where T : Item
|
||||
{
|
||||
Register(typeof(T), name, tooltipText, itemID, gumpID, hue, cost, cat, constructor);
|
||||
}
|
||||
|
||||
public static void Register(Type itemType, TextDefinition name, string tooltipText, int itemID, int gumpID, int hue, int cost, StoreCategory cat, Func<Mobile, StoreEntry, Item> constructor = null)
|
||||
{
|
||||
Register(new StoreEntry(itemType, name, tooltipText, itemID, gumpID, hue, cost, cat, constructor));
|
||||
}
|
||||
|
||||
public static void Register<T>(TextDefinition[] name, string tooltipText, int itemID, int gumpID, int hue, int cost, StoreCategory cat, Func<Mobile, StoreEntry, Item> constructor = null) where T : Item
|
||||
{
|
||||
Register(typeof(T), name, tooltipText, itemID, gumpID, hue, cost, cat, constructor);
|
||||
}
|
||||
|
||||
public static void Register(Type itemType, TextDefinition[] name, string tooltipText, int itemID, int gumpID, int hue, int cost, StoreCategory cat, Func<Mobile, StoreEntry, Item> constructor = null)
|
||||
{
|
||||
Register(new StoreEntry(itemType, name, tooltipText, itemID, gumpID, hue, cost, cat, constructor));
|
||||
}
|
||||
|
||||
public static void Register(StoreEntry entry)
|
||||
{
|
||||
Entries.Add(entry);
|
||||
}
|
||||
|
||||
public static bool CanSearch(Mobile m)
|
||||
{
|
||||
return m != null && m.Region.GetLogoutDelay(m) <= TimeSpan.Zero;
|
||||
}
|
||||
|
||||
public static void UOStoreRequest(NetState state, PacketReader pvSrc)
|
||||
{
|
||||
OpenStore(state.Mobile as PlayerMobile);
|
||||
}
|
||||
|
||||
public static void OpenStore(PlayerMobile user)
|
||||
{
|
||||
if (user == null || user.NetState == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Enabled || (Configuration.Expansion != Expansion.None && Core.Expansion < Configuration.Expansion))
|
||||
{
|
||||
// The promo code redemption system is currently unavailable. Please try again later.
|
||||
user.SendLocalizedMessage(1062904);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Configuration.CurrencyImpl == CurrencyType.None)
|
||||
{
|
||||
// The promo code redemption system is currently unavailable. Please try again later.
|
||||
user.SendLocalizedMessage(1062904);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!user.NetState.UltimaStore)
|
||||
{
|
||||
user.SendMessage("You must update Ultima Online in order to use the in game store.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.AccessLevel < AccessLevel.Counselor && !CanSearch(user))
|
||||
{
|
||||
// Before using the in game store, you must be in a safe log-out location
|
||||
// such as an inn or a house which has you on its Owner, Co-owner, or Friends list.
|
||||
user.SendLocalizedMessage(1156586);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!user.HasGump(typeof(UltimaStoreGump)))
|
||||
{
|
||||
BaseGump.SendGump(new UltimaStoreGump(user));
|
||||
}
|
||||
}
|
||||
|
||||
#region Constructors
|
||||
public static Item ConstructHairDye(Mobile m, StoreEntry entry)
|
||||
{
|
||||
var info = NaturalHairDye.Table.FirstOrDefault(x => x.Localization == entry.Name[1].Number);
|
||||
|
||||
if (info != null)
|
||||
{
|
||||
return new NaturalHairDye(info.Type);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Item ConstructHaochisPigment(Mobile m, StoreEntry entry)
|
||||
{
|
||||
var info = HaochisPigment.Table.FirstOrDefault(x => x.Localization == entry.Name[1].Number);
|
||||
|
||||
if (info != null)
|
||||
{
|
||||
return new HaochisPigment(info.Type, 50);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Item ConstructPigments(Mobile m, StoreEntry entry)
|
||||
{
|
||||
PigmentType type = PigmentType.None;
|
||||
|
||||
for (int i = 0; i < PigmentsOfTokuno.Table.Length; i++)
|
||||
{
|
||||
if (PigmentsOfTokuno.Table[i][1] == entry.Name[1].Number)
|
||||
{
|
||||
type = (PigmentType)i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (type != PigmentType.None)
|
||||
{
|
||||
return new PigmentsOfTokuno(type, 50);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Item ConstructEarrings(Mobile m, StoreEntry entry)
|
||||
{
|
||||
AosElementAttribute ele = AosElementAttribute.Physical;
|
||||
|
||||
switch (entry.Name[0].Number)
|
||||
{
|
||||
case 1071092: ele = AosElementAttribute.Fire; break;
|
||||
case 1071093: ele = AosElementAttribute.Cold; break;
|
||||
case 1071094: ele = AosElementAttribute.Poison; break;
|
||||
case 1071095: ele = AosElementAttribute.Energy; break;
|
||||
}
|
||||
|
||||
return new EarringsOfProtection(ele);
|
||||
}
|
||||
|
||||
public static Item ConstructRobe(Mobile m, StoreEntry entry)
|
||||
{
|
||||
return new HoodedBritanniaRobe(entry.ItemID);
|
||||
}
|
||||
|
||||
public static Item ConstructMiniHouseDeed(Mobile m, StoreEntry entry)
|
||||
{
|
||||
int label = entry.Name[1].Number;
|
||||
|
||||
switch (label)
|
||||
{
|
||||
default:
|
||||
for (int i = 0; i < MiniHouseInfo.Info.Length; i++)
|
||||
{
|
||||
if (MiniHouseInfo.Info[i].LabelNumber == entry.Name[1].Number)
|
||||
{
|
||||
var type = (MiniHouseType)i;
|
||||
|
||||
return new MiniHouseDeed(type);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
case 1157015: return new MiniHouseDeed(MiniHouseType.TwoStoryWoodAndPlaster);
|
||||
case 1157014: return new MiniHouseDeed(MiniHouseType.TwoStoryStoneAndPlaster);
|
||||
}
|
||||
}
|
||||
|
||||
public static Item ConstructRaisedGarden(Mobile m, StoreEntry entry)
|
||||
{
|
||||
var bag = new Bag();
|
||||
|
||||
bag.DropItem(new RaisedGardenDeed());
|
||||
bag.DropItem(new RaisedGardenDeed());
|
||||
bag.DropItem(new RaisedGardenDeed());
|
||||
|
||||
return bag;
|
||||
}
|
||||
|
||||
public static Item ConstructLampPost(Mobile m, StoreEntry entry)
|
||||
{
|
||||
var item = new LampPost2
|
||||
{
|
||||
Movable = true,
|
||||
LootType = LootType.Blessed
|
||||
};
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public static Item ConstructForgedMetal(Mobile m, StoreEntry entry)
|
||||
{
|
||||
switch (entry.Name[1].Number)
|
||||
{
|
||||
case 1156686: return new ForgedMetalOfArtifacts(10);
|
||||
case 1156687: return new ForgedMetalOfArtifacts(5);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Item ConstructSoulstone(Mobile m, StoreEntry entry)
|
||||
{
|
||||
switch (entry.Name[0].Number)
|
||||
{
|
||||
case 1078835: return new SoulstoneToken(SoulstoneType.Blue);
|
||||
case 1078834: return new SoulstoneToken(SoulstoneType.Green);
|
||||
case 1158404: return new SoulstoneToken(SoulstoneType.Violet);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Item ConstructMerchantsTrinket(Mobile m, StoreEntry entry)
|
||||
{
|
||||
switch (entry.Name[0].Number)
|
||||
{
|
||||
case 1156827: return new MerchantsTrinket(false);
|
||||
case 1156828: return new MerchantsTrinket(true);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Item ConstructBOBCoverOne(Mobile m, StoreEntry entry)
|
||||
{
|
||||
return new BagOfBulkOrderCovers(12, 25);
|
||||
}
|
||||
|
||||
public static Item ConstructBOBCoverTwo(Mobile m, StoreEntry entry)
|
||||
{
|
||||
return new BagOfBulkOrderCovers(1, 11);
|
||||
}
|
||||
|
||||
public static Item ConstructHitchingPost(Mobile m, StoreEntry entry)
|
||||
{
|
||||
return new HitchingPost(false);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static void AddPendingItem(Mobile m, Item item)
|
||||
{
|
||||
if (!PendingItems.TryGetValue(m, out List<Item> list))
|
||||
{
|
||||
PendingItems[m] = list = new List<Item>();
|
||||
}
|
||||
|
||||
if (!list.Contains(item))
|
||||
{
|
||||
list.Add(item);
|
||||
}
|
||||
|
||||
UltimaStoreContainer.DropItem(item);
|
||||
}
|
||||
|
||||
public static bool HasPendingItem(PlayerMobile pm)
|
||||
{
|
||||
return PendingItems.ContainsKey(pm);
|
||||
}
|
||||
|
||||
public static void CheckPendingItem(Mobile m)
|
||||
{
|
||||
if (PendingItems.TryGetValue(m, out List<Item> list))
|
||||
{
|
||||
var index = list.Count;
|
||||
|
||||
while (--index >= 0)
|
||||
{
|
||||
if (index >= list.Count)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var item = list[index];
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
if (m.Backpack != null && m.Alive && m.Backpack.TryDropItem(m, item, false))
|
||||
{
|
||||
if (item is IPromotionalToken && ((IPromotionalToken)item).ItemName != null)
|
||||
{
|
||||
// A token has been placed in your backpack. Double-click it to redeem your ~1_PROMO~.
|
||||
m.SendLocalizedMessage(1075248, ((IPromotionalToken)item).ItemName.ToString());
|
||||
}
|
||||
else if (item.LabelNumber > 0 || item.Name != null)
|
||||
{
|
||||
var name = item.LabelNumber > 0 ? ("#" + item.LabelNumber) : item.Name;
|
||||
|
||||
// Your purchase of ~1_ITEM~ has been placed in your backpack.
|
||||
m.SendLocalizedMessage(1156844, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Your purchased item has been placed in your backpack.
|
||||
m.SendLocalizedMessage(1156843);
|
||||
}
|
||||
|
||||
list.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
list.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
if (list.Count == 0 && PendingItems.Remove(m))
|
||||
{
|
||||
list.TrimExcess();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<StoreEntry> GetSortedList(string searchString)
|
||||
{
|
||||
var list = new List<StoreEntry>();
|
||||
|
||||
list.AddRange(Entries.Where(e => Insensitive.Contains(GetStringName(e.Name), searchString)));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static string GetStringName(TextDefinition[] text)
|
||||
{
|
||||
var str = string.Empty;
|
||||
|
||||
foreach (var td in text)
|
||||
{
|
||||
if (td.Number > 0 && VendorSearch.StringList != null)
|
||||
{
|
||||
str += String.Format("{0} ", VendorSearch.StringList.GetString(td.Number));
|
||||
}
|
||||
else if (!String.IsNullOrWhiteSpace(td.String))
|
||||
{
|
||||
str += String.Format("{0} ", td.String);
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
public static string GetStringName(TextDefinition text)
|
||||
{
|
||||
var str = text.String;
|
||||
|
||||
if (text.Number > 0 && VendorSearch.StringList != null)
|
||||
{
|
||||
str = VendorSearch.StringList.GetString(text.Number);
|
||||
}
|
||||
|
||||
return str ?? String.Empty;
|
||||
}
|
||||
|
||||
public static List<StoreEntry> GetList(StoreCategory cat)
|
||||
{
|
||||
return Entries.Where(e => e.Category == cat).ToList();
|
||||
}
|
||||
|
||||
public static void SortList(List<StoreEntry> list, SortBy sort)
|
||||
{
|
||||
switch (sort)
|
||||
{
|
||||
case SortBy.Name:
|
||||
list.Sort((a, b) => String.CompareOrdinal(GetStringName(a.Name), GetStringName(b.Name)));
|
||||
break;
|
||||
case SortBy.PriceLower:
|
||||
list.Sort((a, b) => a.Price.CompareTo(b.Price));
|
||||
break;
|
||||
case SortBy.PriceHigher:
|
||||
list.Sort((a, b) => b.Price.CompareTo(a.Price));
|
||||
break;
|
||||
case SortBy.Newest:
|
||||
break;
|
||||
case SortBy.Oldest:
|
||||
list.Reverse();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static int CartCount(Mobile m)
|
||||
{
|
||||
var profile = GetProfile(m, false);
|
||||
|
||||
if (profile != null)
|
||||
{
|
||||
return profile.Cart.Count;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int GetSubTotal(Dictionary<StoreEntry, int> cart)
|
||||
{
|
||||
if (cart == null || cart.Count == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
var sub = 0.0;
|
||||
|
||||
foreach (var kvp in cart)
|
||||
{
|
||||
sub += kvp.Key.Cost * kvp.Value;
|
||||
}
|
||||
|
||||
return (int)sub;
|
||||
}
|
||||
|
||||
public static int GetCurrency(Mobile m, bool sendMessage = false)
|
||||
{
|
||||
switch (Configuration.CurrencyImpl)
|
||||
{
|
||||
case CurrencyType.Sovereigns:
|
||||
{
|
||||
if (m is PlayerMobile)
|
||||
{
|
||||
return ((PlayerMobile)m).AccountSovereigns;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CurrencyType.Gold:
|
||||
return Banker.GetBalance(m);
|
||||
case CurrencyType.PointsSystem:
|
||||
{
|
||||
var sys = PointsSystem.GetSystemInstance(Configuration.PointsImpl);
|
||||
|
||||
if (sys != null)
|
||||
{
|
||||
return (int)Math.Min(Int32.MaxValue, sys.GetPoints(m));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CurrencyType.Custom:
|
||||
return Configuration.GetCustomCurrency(m);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void TryPurchase(Mobile m)
|
||||
{
|
||||
var cart = GetCart(m);
|
||||
var total = GetSubTotal(cart);
|
||||
|
||||
if (cart == null || cart.Count == 0 || total == 0)
|
||||
{
|
||||
// Purchase failed due to your cart being empty.
|
||||
m.SendLocalizedMessage(1156842);
|
||||
}
|
||||
else if (total > GetCurrency(m, true))
|
||||
{
|
||||
if (m is PlayerMobile)
|
||||
{
|
||||
BaseGump.SendGump(new NoFundsGump((PlayerMobile)m));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var subtotal = 0;
|
||||
var fail = false;
|
||||
|
||||
var remove = new List<StoreEntry>();
|
||||
|
||||
foreach (var entry in cart)
|
||||
{
|
||||
for (var i = 0; i < entry.Value; i++)
|
||||
{
|
||||
if (!entry.Key.Construct(m))
|
||||
{
|
||||
fail = true;
|
||||
|
||||
try
|
||||
{
|
||||
using (var op = File.AppendText("UltimaStoreError.log"))
|
||||
{
|
||||
op.WriteLine("Bad Constructor: {0}", entry.Key.ItemType.Name);
|
||||
|
||||
Utility.WriteConsoleColor(ConsoleColor.Red, "[Ultima Store]: Bad Constructor: {0}", entry.Key.ItemType.Name);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
else
|
||||
{
|
||||
remove.Add(entry.Key);
|
||||
|
||||
subtotal += entry.Key.Cost;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (subtotal > 0)
|
||||
{
|
||||
DeductCurrency(m, subtotal);
|
||||
}
|
||||
|
||||
var profile = GetProfile(m);
|
||||
|
||||
foreach (var entry in remove)
|
||||
{
|
||||
profile.RemoveFromCart(entry);
|
||||
}
|
||||
|
||||
if (fail)
|
||||
{
|
||||
// Failed to process one of your items. Please check your cart and try again.
|
||||
m.SendLocalizedMessage(1156853);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Should have already passed GetCurrency
|
||||
/// </summary>
|
||||
/// <param name="m"></param>
|
||||
/// <param name="amount"></param>
|
||||
public static int DeductCurrency(Mobile m, int amount)
|
||||
{
|
||||
switch (Configuration.CurrencyImpl)
|
||||
{
|
||||
case CurrencyType.Sovereigns:
|
||||
{
|
||||
if (m is PlayerMobile && ((PlayerMobile)m).WithdrawSovereigns(amount))
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CurrencyType.Gold:
|
||||
{
|
||||
if (Banker.Withdraw(m, amount, true))
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CurrencyType.PointsSystem:
|
||||
{
|
||||
var sys = PointsSystem.GetSystemInstance(Configuration.PointsImpl);
|
||||
|
||||
if (sys != null && sys.DeductPoints(m, amount, true))
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CurrencyType.Custom:
|
||||
return Configuration.DeductCustomCurrecy(m, amount);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#region Player Persistence
|
||||
public static Dictionary<Mobile, PlayerProfile> PlayerProfiles { get; private set; }
|
||||
|
||||
public static PlayerProfile GetProfile(Mobile m, bool create = true)
|
||||
{
|
||||
PlayerProfile profile;
|
||||
|
||||
if ((!PlayerProfiles.TryGetValue(m, out profile) || profile == null) && create)
|
||||
{
|
||||
PlayerProfiles[m] = profile = new PlayerProfile(m);
|
||||
}
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
public static Dictionary<StoreEntry, int> GetCart(Mobile m)
|
||||
{
|
||||
var profile = GetProfile(m, false);
|
||||
|
||||
if (profile != null)
|
||||
{
|
||||
return profile.Cart;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void OnSave(WorldSaveEventArgs e)
|
||||
{
|
||||
Persistence.Serialize(FilePath, Serialize);
|
||||
}
|
||||
|
||||
public static void OnLoad()
|
||||
{
|
||||
Persistence.Deserialize(FilePath, Deserialize);
|
||||
}
|
||||
|
||||
private static void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.Write(0);
|
||||
|
||||
writer.Write(_UltimaStoreContainer);
|
||||
|
||||
writer.Write(PendingItems.Count);
|
||||
|
||||
foreach (var kvp in PendingItems)
|
||||
{
|
||||
writer.Write(kvp.Key);
|
||||
writer.WriteItemList(kvp.Value, true);
|
||||
}
|
||||
|
||||
writer.Write(PlayerProfiles.Count);
|
||||
|
||||
foreach (var pe in PlayerProfiles)
|
||||
{
|
||||
pe.Value.Serialize(writer);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Deserialize(GenericReader reader)
|
||||
{
|
||||
reader.ReadInt();
|
||||
|
||||
_UltimaStoreContainer = reader.ReadItem<UltimaStoreContainer>();
|
||||
|
||||
var count = reader.ReadInt();
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var m = reader.ReadMobile();
|
||||
var list = reader.ReadStrongItemList<Item>();
|
||||
|
||||
if (m != null && list.Count > 0)
|
||||
{
|
||||
PendingItems[m] = list;
|
||||
}
|
||||
}
|
||||
|
||||
count = reader.ReadInt();
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var pe = new PlayerProfile(reader);
|
||||
|
||||
if (pe.Player != null)
|
||||
{
|
||||
PlayerProfiles[pe.Player] = pe;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
[DeleteConfirm("This is the Ultima Store item display container. You should not delete this.")]
|
||||
public sealed class UltimaStoreContainer : Container
|
||||
{
|
||||
private static readonly List<Item> _DisplayItems = new List<Item>();
|
||||
|
||||
public override bool Decays { get { return false; } }
|
||||
|
||||
public override string DefaultName { get { return "Ultima Store Display Container"; } }
|
||||
|
||||
public UltimaStoreContainer()
|
||||
: base(0) // No Draw
|
||||
{
|
||||
Movable = false;
|
||||
Visible = false;
|
||||
|
||||
Internalize();
|
||||
}
|
||||
|
||||
public UltimaStoreContainer(Serial serial)
|
||||
: base(serial)
|
||||
{ }
|
||||
|
||||
public void AddDisplayItem(Item item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_DisplayItems.Contains(item))
|
||||
{
|
||||
_DisplayItems.Add(item);
|
||||
}
|
||||
|
||||
DropItem(item);
|
||||
}
|
||||
|
||||
public Item FindDisplayItem(Type t)
|
||||
{
|
||||
var item = GetDisplayItem(t);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
item = Loot.Construct(t);
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
AddDisplayItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public Item GetDisplayItem(Type t)
|
||||
{
|
||||
return _DisplayItems.FirstOrDefault(x => x.GetType() == t);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0);
|
||||
|
||||
writer.WriteItemList(_DisplayItems, true);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
reader.ReadInt();
|
||||
|
||||
var list = reader.ReadStrongItemList();
|
||||
|
||||
if (list.Count > 0)
|
||||
{
|
||||
Timer.DelayCall(o => o.ForEach(AddDisplayItem), list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+856
@@ -0,0 +1,856 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Server.Mobiles;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Engines.UOStore
|
||||
{
|
||||
public class UltimaStoreGump : BaseGump
|
||||
{
|
||||
private readonly int[][] _Offset =
|
||||
{
|
||||
new[] { 167, 74 },
|
||||
new[] { 354, 74 },
|
||||
new[] { 541, 74 },
|
||||
new[] { 167, 294 },
|
||||
new[] { 354, 294 },
|
||||
new[] { 541, 294 }
|
||||
};
|
||||
|
||||
public StoreCategory Category
|
||||
{
|
||||
get
|
||||
{
|
||||
var profile = UltimaStore.GetProfile(User, false);
|
||||
|
||||
if (profile != null)
|
||||
{
|
||||
return profile.Category;
|
||||
}
|
||||
|
||||
return PlayerProfile.DefaultCategory;
|
||||
}
|
||||
}
|
||||
|
||||
public SortBy SortBy
|
||||
{
|
||||
get
|
||||
{
|
||||
var profile = UltimaStore.GetProfile(User, false);
|
||||
|
||||
if (profile != null)
|
||||
{
|
||||
return profile.SortBy;
|
||||
}
|
||||
|
||||
return PlayerProfile.DefaultSortBy;
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<StoreEntry, int> Cart
|
||||
{
|
||||
get
|
||||
{
|
||||
var profile = UltimaStore.GetProfile(User, false);
|
||||
|
||||
if (profile != null)
|
||||
{
|
||||
return profile.Cart;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int Page { get; private set; }
|
||||
public string SearchText { get; private set; }
|
||||
public List<StoreEntry> StoreList { get; private set; }
|
||||
|
||||
public bool Search { get; private set; }
|
||||
|
||||
public UltimaStoreGump(PlayerMobile pm)
|
||||
: base(pm, 100, 200)
|
||||
{
|
||||
StoreList = UltimaStore.GetList(Category);
|
||||
|
||||
UltimaStore.SortList(StoreList, SortBy);
|
||||
|
||||
pm.Frozen = true;
|
||||
pm.Hidden = true;
|
||||
pm.TempSquelched = true;
|
||||
}
|
||||
|
||||
public override void OnDispose()
|
||||
{
|
||||
ColUtility.Free(StoreList);
|
||||
|
||||
StoreList = null;
|
||||
}
|
||||
|
||||
public override void AddGumpLayout()
|
||||
{
|
||||
AddPage(0);
|
||||
AddImage(0, 0, 0x9C49);
|
||||
|
||||
AddECHandleInput();
|
||||
|
||||
AddButton(36, 97, Category == StoreCategory.Featured ? 0x9C5F : 0x9C55, 0x9C5F, 100, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(36, 100, 125, 25, 1114513, "#1156587", 0x7FFF, false, false); // Featured
|
||||
|
||||
AddECHandleInput();
|
||||
AddECHandleInput();
|
||||
|
||||
AddButton(36, 126, Category == StoreCategory.Character ? 0x9C5F : 0x9C55, 0x9C5F, 101, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(36, 129, 125, 25, 1114513, "#1156588", 0x7FFF, false, false); // Character
|
||||
|
||||
AddECHandleInput();
|
||||
AddECHandleInput();
|
||||
|
||||
AddButton(36, 155, Category == StoreCategory.Equipment ? 0x9C5F : 0x9C55, 0x9C5F, 102, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(36, 158, 125, 25, 1114513, "#1078237", 0x7FFF, false, false); // Equipment
|
||||
|
||||
AddECHandleInput();
|
||||
AddECHandleInput();
|
||||
|
||||
AddButton(36, 184, Category == StoreCategory.Decorations ? 0x9C5F : 0x9C55, 0x9C5F, 103, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(36, 187, 125, 25, 1114513, "#1044501", 0x7FFF, false, false); // Decorations
|
||||
|
||||
AddECHandleInput();
|
||||
AddECHandleInput();
|
||||
|
||||
AddButton(36, 213, Category == StoreCategory.Mounts ? 0x9C5F : 0x9C55, 0x9C5F, 104, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(36, 216, 125, 25, 1114513, "#1154981", 0x7FFF, false, false); // Mounts
|
||||
|
||||
AddECHandleInput();
|
||||
AddECHandleInput();
|
||||
|
||||
AddButton(36, 242, Category == StoreCategory.Misc ? 0x9C5F : 0x9C55, 0x9C5F, 105, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(36, 245, 125, 25, 1114513, "#1011173", 0x7FFF, false, false); // Miscellaneous
|
||||
|
||||
AddECHandleInput();
|
||||
AddECHandleInput();
|
||||
|
||||
AddButton(36, 271, 0x9C55, 0x9C5F, 106, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(36, 274, 125, 25, 1114513, "#1156589", 0x7FFF, false, false); // Promotional Code
|
||||
|
||||
AddECHandleInput();
|
||||
AddECHandleInput();
|
||||
|
||||
AddButton(36, 300, 0x9C55, 0x9C5F, 107, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(36, 303, 125, 25, 1114513, "#1156875", 0x7FFF, false, false); // FAQ
|
||||
|
||||
AddECHandleInput();
|
||||
|
||||
AddImage(36, 331, 0x9C4A);
|
||||
|
||||
AddHtmlLocalized(36, 334, 125, 25, 1114513, "#1044580", 0x2945, false, false); // Sort By
|
||||
|
||||
AddButton(43, 360, SortBy == SortBy.Name ? 0x9C4F : 0x9C4E, SortBy == SortBy.Name ? 0x9C4F : 0x9C4E, 108, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(68, 360, 88, 25, 1037013, 0x6B55, false, false); // Name
|
||||
|
||||
AddButton(43, 386, SortBy == SortBy.PriceLower ? 0x9C4F : 0x9C4E, SortBy == SortBy.PriceLower ? 0x9C4F : 0x9C4E, 109, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(68, 386, 88, 25, 1062218, 0x6B55, false, false); // Price Down
|
||||
AddImage(110, 386, 0x9C60);
|
||||
|
||||
AddButton(43, 412, SortBy == SortBy.PriceHigher ? 0x9C4F : 0x9C4E, SortBy == SortBy.PriceHigher ? 0x9C4F : 0x9C4E, 110, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(68, 412, 88, 25, 1062218, 0x6B55, false, false); // Price Up
|
||||
AddImage(110, 412, 0x9C61);
|
||||
|
||||
AddButton(43, 438, SortBy == SortBy.Newest ? 0x9C4F : 0x9C4E, SortBy == SortBy.Newest ? 0x9C4F : 0x9C4E, 111, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(68, 438, 88, 25, 1156590, 0x6B55, false, false); // Newest
|
||||
|
||||
AddButton(43, 464, SortBy == SortBy.Oldest ? 0x9C4F : 0x9C4E, SortBy == SortBy.Oldest ? 0x9C4F : 0x9C4E, 112, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(68, 464, 88, 25, 1156591, 0x6B55, false, false); // Oldest
|
||||
|
||||
AddECHandleInput();
|
||||
|
||||
AddButton(598, 36, Category == StoreCategory.Cart ? 0x9C5E : 0x9C54, 0x9C5E, 113, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(628, 39, 123, 25, 1156593, String.Format("@{0}@{1}", UltimaStore.CartCount(User), Configuration.CartCapacity), 0x7FFF, false, false);
|
||||
|
||||
AddECHandleInput();
|
||||
|
||||
AddBackground(167, 516, 114, 22, 0x2486);
|
||||
AddTextEntry(169, 518, 110, 18, 0, 16, "", 169);
|
||||
|
||||
AddECHandleInput();
|
||||
|
||||
AddButton(286, 516, 0x9C52, 0x9C5C, 114, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(286, 519, 64, 22, 1114513, "#1154641", 0x7FFF, false, false); // Search
|
||||
|
||||
AddECHandleInput();
|
||||
|
||||
AddImage(36, 74, 0x9C56);
|
||||
AddLabelCropped(59, 74, 100, 14, 0x1C7, UltimaStore.GetCurrency(User).ToString("N0"));
|
||||
|
||||
AddECHandleInput();
|
||||
|
||||
if (!Search && Category == StoreCategory.Cart)
|
||||
{
|
||||
var profile = UltimaStore.GetProfile(User);
|
||||
|
||||
AddImage(167, 74, 0x9C4C);
|
||||
|
||||
if (profile != null && profile.Cart != null && profile.Cart.Count > 0)
|
||||
{
|
||||
var i = 0;
|
||||
|
||||
foreach (var kvp in profile.Cart)
|
||||
{
|
||||
var entry = kvp.Key;
|
||||
var amount = kvp.Value;
|
||||
|
||||
var index = UltimaStore.Entries.IndexOf(entry);
|
||||
|
||||
if (entry.Name[0].Number > 0)
|
||||
AddHtmlLocalized(175, 84 + (35 * i), 256, 25, entry.Name[0].Number, 0x6B55, false, false);
|
||||
else
|
||||
AddHtml(175, 84 + (35 * i), 256, 25, Color(C16232(0x6B55), entry.Name[0].String), false, false);
|
||||
|
||||
AddButton(431, 81 + (35 * i), 0x9C52, 0x9C5C, index + 2000, GumpButtonType.Reply, 0);
|
||||
|
||||
AddLabelCropped(457, 82 + (35 * i), 38, 22, 0x9C2, amount.ToString());
|
||||
AddLabelCropped(531, 82 + (35 * i), 100, 14, 0x1C7, (entry.Cost * amount).ToString("N0"));
|
||||
|
||||
AddButton(653, 81 + (35 * i), 0x9C52, 0x9C5C, index + 3000, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(653, 84 + (35 * i), 64, 22, 1114513, "#1011403", 0x7FFF, false, false); // Remove
|
||||
|
||||
AddImage(175, 109 + (35 * i), 0x9C4D);
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
AddHtmlLocalized(508, 482, 125, 25, 1156594, 0x6B55, false, false); // Subtotal:
|
||||
AddImage(588, 482, 0x9C56);
|
||||
AddLabelCropped(611, 480, 100, 14, 0x1C7, UltimaStore.GetSubTotal(Cart).ToString("N0"));
|
||||
|
||||
AddECHandleInput();
|
||||
AddECHandleInput();
|
||||
|
||||
AddButton(653, 516, 0x9C52, 0x9C52, 115, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(653, 519, 64, 22, 1114513, "#1062219", 0x7FFF, false, false); // Buy
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Search)
|
||||
{
|
||||
StoreList = UltimaStore.GetSortedList(SearchText);
|
||||
|
||||
UltimaStore.SortList(StoreList, SortBy);
|
||||
|
||||
if (StoreList.Count == 0)
|
||||
{
|
||||
User.SendLocalizedMessage(1154587, "", 1281); // No items matched your search.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var listIndex = Page * 6;
|
||||
var pageIndex = 0;
|
||||
var pages = (int)Math.Ceiling((double)StoreList.Count / 6);
|
||||
|
||||
for (var i = listIndex; i < StoreList.Count && pageIndex < 6; i++)
|
||||
{
|
||||
var entry = StoreList[i];
|
||||
var x = _Offset[pageIndex][0];
|
||||
var y = _Offset[pageIndex][1];
|
||||
|
||||
AddButton(x, y, 0x9C4B, 0x9C4B, i + 1000, GumpButtonType.Reply, 0);
|
||||
|
||||
if (entry.Tooltip > 0)
|
||||
{
|
||||
AddTooltip(entry.Tooltip);
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(entry.TooltipText))
|
||||
{
|
||||
AddTooltipText(entry.TooltipText.Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
var item = UltimaStore.UltimaStoreContainer.FindDisplayItem(entry.ItemType);
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
AddItemProperty(item);
|
||||
}
|
||||
}
|
||||
|
||||
if (IsFeatured(entry))
|
||||
{
|
||||
AddImage(x, y + 189, 0x9C58);
|
||||
}
|
||||
|
||||
for (int j = 0; j < entry.Name.Length; j++)
|
||||
{
|
||||
if (entry.Name[j].Number > 0)
|
||||
AddHtmlLocalized(x, y + (j * 14) + 4, 183, 25, 1114513, String.Format("#{0}", entry.Name[j].Number.ToString()), 0x7FFF, false, false);
|
||||
else
|
||||
AddHtml(x, y + (j * 14) + 4, 183, 25, ColorAndCenter("#FFFFFF", entry.Name[j].String), false, false);
|
||||
}
|
||||
|
||||
if (entry.ItemID > 0)
|
||||
{
|
||||
var b = ItemBounds.Table[entry.ItemID];
|
||||
|
||||
AddItem((x + 91) - b.Width / 2 - b.X, (y + 108) - b.Height / 2 - b.Y, entry.ItemID, entry.Hue);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddImage((x + 91) - 72, (y + 108) - 72, entry.GumpID);
|
||||
}
|
||||
|
||||
AddImage(x + 60, y + 192, 0x9C56);
|
||||
AddLabelCropped(x + 80, y + 190, 143, 25, 0x9C2, entry.Cost.ToString("N0"));
|
||||
|
||||
AddECHandleInput();
|
||||
AddECHandleInput();
|
||||
|
||||
++pageIndex;
|
||||
++listIndex;
|
||||
}
|
||||
|
||||
if (Page + 1 < pages)
|
||||
{
|
||||
AddButton(692, 516, 0x9C51, 0x9C5B, 116, GumpButtonType.Reply, 0);
|
||||
}
|
||||
|
||||
if (Page > 0)
|
||||
{
|
||||
AddButton(648, 516, 0x9C50, 0x9C5A, 117, GumpButtonType.Reply, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (Configuration.CurrencyDisplay)
|
||||
{
|
||||
AddHtml(43, 496, 120, 16, Color("#FFFFFF", "Currency:"), false, false);
|
||||
AddHtml(43, 518, 120, 16, Color("#FFFFFF", Configuration.CurrencyName), false, false);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsFeatured(StoreEntry entry)
|
||||
{
|
||||
return entry.Category == StoreCategory.Featured ||
|
||||
UltimaStore.Entries.Any(e => e.ItemType == entry.ItemType && e.Category == StoreCategory.Featured);
|
||||
}
|
||||
|
||||
public static void ReleaseHidden(PlayerMobile pm)
|
||||
{
|
||||
if (pm.HasGump(typeof(UltimaStoreGump)) || pm.HasGump(typeof(NoFundsGump)) ||
|
||||
pm.HasGump(typeof(ConfirmPurchaseGump)) || pm.HasGump(typeof(ConfirmCartGump)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pm.Frozen = false;
|
||||
pm.TempSquelched = false;
|
||||
pm.SendLocalizedMessage(501235, "", 0x35); // Help request aborted.
|
||||
|
||||
if (pm.AccessLevel < AccessLevel.Counselor)
|
||||
{
|
||||
pm.RevealingAction();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnServerClose(NetState owner)
|
||||
{
|
||||
if (owner.Mobile is PlayerMobile)
|
||||
{
|
||||
ReleaseHidden((PlayerMobile)owner.Mobile);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResponse(RelayInfo info)
|
||||
{
|
||||
var id = info.ButtonID;
|
||||
|
||||
if (id == 0)
|
||||
{
|
||||
ReleaseHidden(User);
|
||||
return;
|
||||
}
|
||||
|
||||
var profile = UltimaStore.GetProfile(User);
|
||||
|
||||
switch (id)
|
||||
{
|
||||
// Change Category
|
||||
case 100:
|
||||
case 101:
|
||||
case 102:
|
||||
case 103:
|
||||
case 104:
|
||||
case 105:
|
||||
{
|
||||
Search = false;
|
||||
|
||||
var oldCat = profile.Category;
|
||||
|
||||
profile.Category = (StoreCategory)id - 99;
|
||||
|
||||
if (oldCat != profile.Category)
|
||||
{
|
||||
StoreList = UltimaStore.GetList(Category);
|
||||
Page = 0;
|
||||
}
|
||||
|
||||
Refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
// Promo Code
|
||||
case 106:
|
||||
{
|
||||
Refresh();
|
||||
SendGump(new PromoCodeGump(User, this));
|
||||
return;
|
||||
}
|
||||
|
||||
// FAQ
|
||||
case 107:
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(Configuration.Website))
|
||||
{
|
||||
User.LaunchBrowser(Configuration.Website);
|
||||
}
|
||||
else
|
||||
{
|
||||
User.LaunchBrowser("https://uo.com/ultima-store/");
|
||||
}
|
||||
|
||||
Refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
// Change Sort Method
|
||||
case 108:
|
||||
case 109:
|
||||
case 110:
|
||||
case 111:
|
||||
case 112:
|
||||
{
|
||||
var oldSort = profile.SortBy;
|
||||
|
||||
profile.SortBy = (SortBy)id - 108;
|
||||
|
||||
if (oldSort != profile.SortBy)
|
||||
{
|
||||
// re-orders the list
|
||||
if (oldSort == SortBy.Newest || oldSort == SortBy.Oldest)
|
||||
{
|
||||
ColUtility.Free(StoreList);
|
||||
|
||||
StoreList = UltimaStore.GetList(Category);
|
||||
}
|
||||
|
||||
UltimaStore.SortList(StoreList, profile.SortBy);
|
||||
|
||||
Page = 0;
|
||||
}
|
||||
|
||||
Refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
// Cart View
|
||||
case 113:
|
||||
{
|
||||
if (profile != null)
|
||||
{
|
||||
profile.Category = StoreCategory.Cart;
|
||||
}
|
||||
|
||||
Refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
// Search
|
||||
case 114:
|
||||
{
|
||||
var searchTxt = info.GetTextEntry(0);
|
||||
|
||||
if (searchTxt != null && !String.IsNullOrEmpty(searchTxt.Text))
|
||||
{
|
||||
Search = true;
|
||||
SearchText = searchTxt.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
User.SendLocalizedMessage(1150315); // That text is unacceptable.
|
||||
}
|
||||
|
||||
Refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
// Buy
|
||||
case 115:
|
||||
{
|
||||
if (UltimaStore.CartCount(User) == 0)
|
||||
{
|
||||
if (profile != null)
|
||||
{
|
||||
profile.Category = StoreCategory.Cart;
|
||||
}
|
||||
|
||||
Refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
int total = UltimaStore.GetSubTotal(Cart);
|
||||
|
||||
if (total <= UltimaStore.GetCurrency(User, true))
|
||||
{
|
||||
SendGump(new ConfirmPurchaseGump(User));
|
||||
}
|
||||
else
|
||||
{
|
||||
SendGump(new NoFundsGump(User));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Next Page
|
||||
case 116:
|
||||
{
|
||||
++Page;
|
||||
|
||||
Refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
// Previous Page
|
||||
case 117:
|
||||
{
|
||||
--Page;
|
||||
|
||||
Refresh();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (id < 2000) // Add To Cart
|
||||
{
|
||||
Refresh();
|
||||
|
||||
var entry = StoreList[id - 1000];
|
||||
|
||||
if (Cart == null || Cart.Count < 10)
|
||||
{
|
||||
SendGump(new ConfirmCartGump(User, this, entry));
|
||||
return;
|
||||
}
|
||||
|
||||
User.SendLocalizedMessage(1156745); // Your store cart is currently full.
|
||||
}
|
||||
else if (id < 3000) // Change Amount In Cart
|
||||
{
|
||||
Refresh();
|
||||
|
||||
var entry = UltimaStore.Entries[id - 2000];
|
||||
|
||||
SendGump(new ConfirmCartGump(User, this, entry, Cart != null && Cart.ContainsKey(entry) ? Cart[entry] : 0));
|
||||
return;
|
||||
}
|
||||
else if (id < 4000) // Remove From Cart
|
||||
{
|
||||
var entry = UltimaStore.Entries[id - 3000];
|
||||
|
||||
if (profile != null)
|
||||
{
|
||||
profile.RemoveFromCart(entry);
|
||||
}
|
||||
|
||||
Refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
ReleaseHidden(User);
|
||||
}
|
||||
private void AddTooltipText(string text)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text))
|
||||
return;
|
||||
|
||||
AddTooltip(text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ConfirmCartGump : BaseGump
|
||||
{
|
||||
public UltimaStoreGump Gump { get; private set; }
|
||||
public StoreEntry Entry { get; private set; }
|
||||
public int Current { get; private set; }
|
||||
|
||||
public ConfirmCartGump(PlayerMobile pm, UltimaStoreGump gump, StoreEntry entry, int current = 0)
|
||||
: base(pm, gump.X + (760 / 2) - 205, gump.Y + (574 / 2) - 100)
|
||||
{
|
||||
Gump = gump;
|
||||
Entry = entry;
|
||||
Current = current;
|
||||
|
||||
pm.CloseGump(typeof(ConfirmCartGump));
|
||||
}
|
||||
|
||||
public override void AddGumpLayout()
|
||||
{
|
||||
AddBackground(0, 0, 410, 200, 0x9C40);
|
||||
AddHtmlLocalized(10, 10, 400, 20, 1114513, "#1077826", 0x7FFF, false, false); // Quantity
|
||||
|
||||
for (var i = 0; i < Entry.Name.Length; i++)
|
||||
{
|
||||
if (Entry.Name[i].Number > 0)
|
||||
{
|
||||
AddHtmlLocalized(10, 60 + (i * 14), 400, 20, 1114513, String.Format("#{0}", Entry.Name[i].Number), 0x6B45, false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddHtml(10, 60 + (i * 14), 400, 20, ColorAndCenter(C16232(0x6B45), Entry.Name[i].String), false, false);
|
||||
}
|
||||
}
|
||||
|
||||
AddHtmlLocalized(30, 100, 200, 20, 1114514, "#1150152", 0x7FFF, false, false); // Quantity to Buy:
|
||||
|
||||
AddBackground(233, 100, 50, 20, 0x2486);
|
||||
AddTextEntry(238, 100, 50, 20, 0, 0, Current > 0 ? Current.ToString() : "", 2);
|
||||
|
||||
AddECHandleInput();
|
||||
|
||||
AddButton(45, 150, 0x9C53, 0x9C5D, 195, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(45, 153, 126, 25, 1114513, "#1156596", 0x7FFF, false, false); // Okay
|
||||
|
||||
AddECHandleInput();
|
||||
AddECHandleInput();
|
||||
|
||||
AddButton(240, 150, 0x9C53, 0x9C5D, 0, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(240, 153, 126, 25, 1114513, "#1006045", 0x7FFF, false, false); // Cancel
|
||||
|
||||
AddECHandleInput();
|
||||
}
|
||||
|
||||
public override void OnServerClose(NetState owner)
|
||||
{
|
||||
if (owner.Mobile is PlayerMobile)
|
||||
{
|
||||
UltimaStoreGump.ReleaseHidden(User);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResponse(RelayInfo info)
|
||||
{
|
||||
if (info.ButtonID == 195)
|
||||
{
|
||||
var amtText = info.GetTextEntry(0);
|
||||
|
||||
if (amtText != null && !String.IsNullOrWhiteSpace(amtText.Text))
|
||||
{
|
||||
var amount = Utility.ToInt32(amtText.Text);
|
||||
|
||||
if (amount > 0)
|
||||
{
|
||||
if (amount <= 10)
|
||||
{
|
||||
UltimaStore.GetProfile(User).SetCartAmount(Entry, amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
User.SendLocalizedMessage(1150315); // That text is unacceptable.
|
||||
//User.SendLocalizedMessage(1156836); // You can't exceed 125 items per purchase.
|
||||
}
|
||||
|
||||
Gump.Refresh();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
User.SendLocalizedMessage(1150315); // That text is unacceptable.
|
||||
}
|
||||
}
|
||||
|
||||
UltimaStoreGump.ReleaseHidden(User);
|
||||
}
|
||||
}
|
||||
|
||||
public class ConfirmPurchaseGump : BaseGump
|
||||
{
|
||||
public ConfirmPurchaseGump(PlayerMobile pm)
|
||||
: base(pm, 150, 150)
|
||||
{
|
||||
pm.CloseGump(typeof(ConfirmPurchaseGump));
|
||||
}
|
||||
|
||||
public override void AddGumpLayout()
|
||||
{
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, 410, 200, 0x9C40);
|
||||
AddHtmlLocalized(10, 10, 400, 20, 1114513, "#1156750", 0x7FFF, false, false); // Purchase Confirmation
|
||||
|
||||
AddHtmlLocalized(30, 60, 350, 60, 1156749, 0x7FFF, false, false); // Are you sure you want to complete this purchase?
|
||||
|
||||
AddECHandleInput();
|
||||
|
||||
AddButton(45, 150, 0x9C53, 0x9C5D, 195, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(45, 153, 126, 25, 1114513, "#1156596", 0x7FFF, false, false); // Okay
|
||||
|
||||
AddECHandleInput();
|
||||
AddECHandleInput();
|
||||
|
||||
AddButton(240, 150, 0x9C53, 0x9C5D, 0, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(240, 153, 126, 25, 1114513, "#1006045", 0x7FFF, false, false); // Cancel
|
||||
|
||||
AddECHandleInput();
|
||||
}
|
||||
|
||||
public override void OnServerClose(NetState owner)
|
||||
{
|
||||
if (owner.Mobile is PlayerMobile)
|
||||
{
|
||||
UltimaStoreGump.ReleaseHidden(User);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResponse(RelayInfo info)
|
||||
{
|
||||
if (info.ButtonID == 195)
|
||||
{
|
||||
UltimaStore.TryPurchase(User);
|
||||
}
|
||||
|
||||
UltimaStoreGump.ReleaseHidden(User);
|
||||
}
|
||||
}
|
||||
|
||||
public class NoFundsGump : BaseGump
|
||||
{
|
||||
public NoFundsGump(PlayerMobile pm)
|
||||
: base(pm, 150, 150)
|
||||
{
|
||||
pm.CloseGump(typeof(NoFundsGump));
|
||||
}
|
||||
|
||||
public override void AddGumpLayout()
|
||||
{
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, 410, 200, 0x9C40);
|
||||
AddHtmlLocalized(10, 10, 400, 20, 1114513, "#1156747", 0x7FFF, false, false); // Insufficient Funds
|
||||
|
||||
AddHtml(30, 60, 350, 60, Color("#da0000", String.Format("This transaction cannot be completed due to insufficient funds available. Visit your shards website for more information on how to obtain {0}.", Configuration.CurrencyName)), false, false);
|
||||
|
||||
AddECHandleInput();
|
||||
|
||||
AddButton(45, 150, 0x9C53, 0x9C5D, 195, GumpButtonType.Reply, 0);
|
||||
AddHtml(45, 153, 126, 25, ColorAndCenter("#FFFFFF", "Information"), false, false); // Information
|
||||
|
||||
AddECHandleInput();
|
||||
AddECHandleInput();
|
||||
|
||||
AddButton(240, 150, 0x9C53, 0x9C5D, 0, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(240, 153, 126, 25, 1114513, "#1006045", 0x7FFF, false, false); // Cancel
|
||||
|
||||
AddECHandleInput();
|
||||
}
|
||||
|
||||
public override void OnServerClose(NetState owner)
|
||||
{
|
||||
if (owner.Mobile is PlayerMobile)
|
||||
{
|
||||
UltimaStoreGump.ReleaseHidden(User);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnResponse(RelayInfo info)
|
||||
{
|
||||
if (info.ButtonID == 195)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(Configuration.Website))
|
||||
{
|
||||
User.LaunchBrowser(Configuration.Website);
|
||||
}
|
||||
else
|
||||
{
|
||||
User.LaunchBrowser("https://uo.com/ultima-store/");
|
||||
}
|
||||
}
|
||||
|
||||
UltimaStoreGump.ReleaseHidden(User);
|
||||
}
|
||||
}
|
||||
|
||||
public class PromoCodeGump : BaseGump
|
||||
{
|
||||
public BaseGump Gump { get; private set; }
|
||||
|
||||
public PromoCodeGump(PlayerMobile pm, BaseGump gump)
|
||||
: base(pm, 10, 10)
|
||||
{
|
||||
Gump = gump;
|
||||
|
||||
pm.CloseGump(typeof(PromoCodeGump));
|
||||
}
|
||||
|
||||
public override void AddGumpLayout()
|
||||
{
|
||||
AddPage(0);
|
||||
|
||||
AddBackground(0, 0, 400, 340, 0x9C40);
|
||||
|
||||
AddHtmlLocalized(0, 10, 400, 20, 1114513, "#1062516", 0x7FFF, false, false); // Enter Promotional Code
|
||||
AddHtmlLocalized(20, 60, 355, 160, 1062869, C32216(0xFFFF00), false, true); // Enter your promotional code EXACTLY as it was given to you (including dashes). Enter no other text in the box aside from your promotional code.
|
||||
|
||||
AddECHandleInput();
|
||||
|
||||
AddBackground(80, 220, 240, 22, 0x2486);
|
||||
AddTextEntry(81, 220, 239, 20, 0, 0, "");
|
||||
|
||||
AddButton(40, 260, 0x9C53, 0x9C5D, 1, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(40, 262, 125, 25, 1114513, "#1156596", 0x7FFF, false, false);
|
||||
|
||||
AddECHandleInput();
|
||||
AddECHandleInput();
|
||||
|
||||
AddButton(234, 260, 0x9C53, 0x9C5D, 1, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(234, 262, 126, 25, 1114513, "#1006045", 0x7FFF, false, false);
|
||||
|
||||
AddECHandleInput();
|
||||
}
|
||||
|
||||
public override void OnServerClose(NetState owner)
|
||||
{
|
||||
if (owner.Mobile is PlayerMobile)
|
||||
{
|
||||
UltimaStoreGump.ReleaseHidden(User);
|
||||
}
|
||||
}
|
||||
public override void OnResponse(RelayInfo info)
|
||||
{
|
||||
Mobile from = User; // BaseGump stores the player as "User"
|
||||
|
||||
if (info.ButtonID == 1) // OK button
|
||||
{
|
||||
TextRelay entry = info.GetTextEntry(0);
|
||||
string code = entry?.Text?.Trim();
|
||||
|
||||
if (string.IsNullOrEmpty(code))
|
||||
{
|
||||
from.SendMessage(0x22, "You must enter a code.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (PromoCodeSystem.TryRedeem(from as PlayerMobile, code))
|
||||
{
|
||||
from.SendMessage(0x55, "Promo code redeemed successfully!");
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage(0x22, "Invalid or already used promo code.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Engines.UOStore;
|
||||
|
||||
|
||||
namespace Server.Engines.UOStore
|
||||
{
|
||||
public static class UltimaStoreJsonLoader
|
||||
{
|
||||
private const string JsonPath = "Data/UltimaStore.json";
|
||||
|
||||
public static void Load()
|
||||
{
|
||||
string fullPath = Path.Combine(Core.BaseDirectory, JsonPath);
|
||||
|
||||
if (!File.Exists(fullPath))
|
||||
{
|
||||
Console.WriteLine("UltimaStoreJsonLoader: JSON file not found: " + fullPath);
|
||||
return;
|
||||
}
|
||||
|
||||
string json = File.ReadAllText(fullPath);
|
||||
|
||||
var data = MiniJson.Parse(json) as Dictionary<string, object>;
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
Console.WriteLine("UltimaStoreJsonLoader: Failed to parse JSON.");
|
||||
return;
|
||||
}
|
||||
|
||||
UltimaStore.Entries.Clear();
|
||||
|
||||
foreach (var kvp in data)
|
||||
{
|
||||
if (!Enum.TryParse(kvp.Key, out StoreCategory cat))
|
||||
{
|
||||
Console.WriteLine("UltimaStoreJsonLoader: Unknown category " + kvp.Key);
|
||||
continue;
|
||||
}
|
||||
|
||||
var list = kvp.Value as List<object>;
|
||||
if (list == null)
|
||||
continue;
|
||||
|
||||
foreach (var entryObj in list)
|
||||
{
|
||||
var entry = entryObj as Dictionary<string, object>;
|
||||
if (entry == null)
|
||||
continue;
|
||||
|
||||
LoadEntry(entry, cat);
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("UltimaStoreJsonLoader: JSON store loaded.");
|
||||
}
|
||||
|
||||
public static void WriteJson(string json)
|
||||
{
|
||||
string fullPath = Path.Combine(Core.BaseDirectory, JsonPath);
|
||||
File.WriteAllText(fullPath, json);
|
||||
}
|
||||
|
||||
private static void LoadEntry(Dictionary<string, object> e, StoreCategory cat)
|
||||
{
|
||||
string full = e["Type"] as string;
|
||||
|
||||
string typeName = full.Contains(".")
|
||||
? full.Substring(full.LastIndexOf('.') + 1)
|
||||
: full;
|
||||
|
||||
Type itemType = ScriptCompiler.FindTypeByName(typeName);
|
||||
|
||||
if (itemType == null)
|
||||
{
|
||||
Console.WriteLine("UltimaStoreJsonLoader: Type not found: " + typeName);
|
||||
return;
|
||||
}
|
||||
|
||||
var nameList = e["NameLines"] as List<object>;
|
||||
TextDefinition[] names = new TextDefinition[nameList.Count];
|
||||
for (int i = 0; i < nameList.Count; i++)
|
||||
names[i] = new TextDefinition(nameList[i].ToString());
|
||||
|
||||
int tooltip = Convert.ToInt32(e["Tooltip"]);
|
||||
string tooltipText = e["TooltipText"] as string;
|
||||
int itemID = Convert.ToInt32(e["ItemID"]);
|
||||
int gumpID = Convert.ToInt32(e["GumpID"]);
|
||||
int hue = Convert.ToInt32(e["Hue"]);
|
||||
int price = Convert.ToInt32(e["Price"]);
|
||||
|
||||
if (!string.IsNullOrEmpty(tooltipText))
|
||||
{
|
||||
UltimaStore.Register(itemType, names, tooltipText, itemID, gumpID, hue, price, cat);
|
||||
}
|
||||
else
|
||||
{
|
||||
UltimaStore.Register(itemType, names, tooltip, itemID, gumpID, hue, price, cat);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public static class MiniJson
|
||||
{
|
||||
public static object Parse(string json)
|
||||
{
|
||||
return new Parser(json).ParseValue();
|
||||
}
|
||||
|
||||
private class Parser
|
||||
{
|
||||
private readonly string _json;
|
||||
private int _index;
|
||||
|
||||
public Parser(string json)
|
||||
{
|
||||
_json = json;
|
||||
}
|
||||
|
||||
public object ParseValue()
|
||||
{
|
||||
SkipWhitespace();
|
||||
|
||||
if (_index >= _json.Length)
|
||||
return null;
|
||||
|
||||
char c = _json[_index];
|
||||
|
||||
if (c == '{') return ParseObject();
|
||||
if (c == '[') return ParseArray();
|
||||
if (c == '"') return ParseString();
|
||||
if (char.IsDigit(c) || c == '-') return ParseNumber();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Dictionary<string, object> ParseObject()
|
||||
{
|
||||
var dict = new Dictionary<string, object>();
|
||||
_index++; // skip {
|
||||
|
||||
while (true)
|
||||
{
|
||||
SkipWhitespace();
|
||||
if (_json[_index] == '}')
|
||||
{
|
||||
_index++;
|
||||
return dict;
|
||||
}
|
||||
|
||||
string key = ParseString();
|
||||
|
||||
SkipWhitespace();
|
||||
_index++; // skip :
|
||||
|
||||
object value = ParseValue();
|
||||
dict[key] = value;
|
||||
|
||||
SkipWhitespace();
|
||||
if (_json[_index] == ',')
|
||||
{
|
||||
_index++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_json[_index] == '}')
|
||||
{
|
||||
_index++;
|
||||
return dict;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<object> ParseArray()
|
||||
{
|
||||
var list = new List<object>();
|
||||
_index++; // skip [
|
||||
|
||||
while (true)
|
||||
{
|
||||
SkipWhitespace();
|
||||
if (_json[_index] == ']')
|
||||
{
|
||||
_index++;
|
||||
return list;
|
||||
}
|
||||
|
||||
list.Add(ParseValue());
|
||||
|
||||
SkipWhitespace();
|
||||
if (_json[_index] == ',')
|
||||
{
|
||||
_index++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_json[_index] == ']')
|
||||
{
|
||||
_index++;
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string ParseString()
|
||||
{
|
||||
_index++; // skip "
|
||||
int start = _index;
|
||||
|
||||
while (_json[_index] != '"')
|
||||
_index++;
|
||||
|
||||
string s = _json.Substring(start, _index - start);
|
||||
_index++; // skip closing "
|
||||
return s;
|
||||
}
|
||||
|
||||
private object ParseNumber()
|
||||
{
|
||||
int start = _index;
|
||||
|
||||
while (_index < _json.Length && (char.IsDigit(_json[_index]) || _json[_index] == '-'))
|
||||
_index++;
|
||||
|
||||
string num = _json.Substring(start, _index - start);
|
||||
return int.Parse(num);
|
||||
}
|
||||
|
||||
private void SkipWhitespace()
|
||||
{
|
||||
while (_index < _json.Length && char.IsWhiteSpace(_json[_index]))
|
||||
_index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user