C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using System;
using System.Collections;
using System.Collections.Generic;
using Oxide.Core.Plugins;
using UnityEngine;
using System.Globalization;
using System.Linq;
using Facepunch.Extend;
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Game.Rust.Cui;
using Color = UnityEngine.Color;
namespace Oxide.Plugins
{
[Info("ZealShop", "Kira", "1.0.0")]
[Description("Game store")]
public class ZealShop : RustPlugin
{
#region [Reference] / [Запросы]
[PluginReference] Plugin ImageLibrary;
private StoredData _dataBase = new StoredData();
private string GetImg(string name)
{
return (string) ImageLibrary?.Call("GetImage", name) ?? "";
}
#endregion
#region [Configuraton] / [Конфигурация]
private static ConfigData _config;
public class ConfigData
{
[JsonProperty(PropertyName = "ZealShop")]
public ShopCfg ZealShop = new ShopCfg();
public class ShopCfg
{
[JsonProperty(PropertyName = "Кол-во рублей за 1 минуту наигранного времени")]
public float PlayingTimeAdd;
[JsonProperty(PropertyName = "Какая должна быить приписка к нику")]
public string ServerName;
[JsonProperty(PropertyName = "Предметы для обмена")]
public readonly Dictionary<string, TradeItem> TradeItems = new Dictionary<string, TradeItem>();
[JsonProperty(PropertyName = "Активные категории")]
public readonly List<string> Categories = new List<string>();
[JsonProperty(PropertyName = "Оружие")]
public List<ItemShop> Gun = new List<ItemShop>();
[JsonProperty(PropertyName = "Постройки")]
public List<ItemShop> Construction = new List<ItemShop>();
[JsonProperty(PropertyName = "Предметы")]
public List<ItemShop> Items = new List<ItemShop>();
[JsonProperty(PropertyName = "Ресурсы")]
public List<ItemShop> Resources = new List<ItemShop>();
[JsonProperty(PropertyName = "Одежда")]
public List<ItemShop> Attire = new List<ItemShop>();
[JsonProperty(PropertyName = "Еда")] public List<ItemShop> Food = new List<ItemShop>();
[JsonProperty(PropertyName = "Инструменты")]
public List<ItemShop> Tools = new List<ItemShop>();
[JsonProperty(PropertyName = "Медицина")]
public List<ItemShop> Medicals = new List<ItemShop>();
[JsonProperty(PropertyName = "Аммуниция")]
public List<ItemShop> Ammunations = new List<ItemShop>();
[JsonProperty(PropertyName = "Ловушки")]
public List<ItemShop> Traps = new List<ItemShop>();
[JsonProperty(PropertyName = "Компоненты")]
public List<ItemShop> Components = new List<ItemShop>();
[JsonProperty(PropertyName = "Прочее")]
public List<ItemShop> Misc = new List<ItemShop>();
[JsonProperty(PropertyName = "Процент от баланса, который остается после вайпа")]
public int WipeProcent;
}
}
private ConfigData GetDefaultConfig()
{
return new ConfigData
{
ZealShop = new ConfigData.ShopCfg
{
PlayingTimeAdd = 1,
ServerName = "Galaxy",
Resources = _resources,
Food = _food,
Components = _components,
Medicals = _medicals,
Ammunations = _ammunations,
Attire = _attire,
Tools = _tools,
Traps = _traps,
Misc = _misc,
Gun = _gun,
Items = _items,
Construction = _construction,
Categories =
{
"ОРУЖИЕ",
"ПОСТРОЙКИ",
"ПРЕДМЕТЫ",
"ОДЕЖДА",
"ИНСТРУМЕНТЫ",
"МЕДИКАМЕНТЫ",
"ЕДА",
"СНАРЯДЫ",
"ЛОВУШКИ",
"РАЗНОЕ",
"КОМПОНЕНТЫ"
},
TradeItems =
{
["rifle.ak"] = new TradeItem
{
Price = 350,
Stack = 1
}
}
}
};
}
protected override void LoadConfig()
{
base.LoadConfig();
try
{
_config = Config.ReadObject<ConfigData>();
}
catch
{
LoadDefaultConfig();
}
SaveConfig();
}
protected override void LoadDefaultConfig()
{
PrintError("Файл конфигурации поврежден (или не существует), создан новый!");
_config = GetDefaultConfig();
}
protected override void SaveConfig()
{
Config.WriteObject(_config);
}
#endregion
#region [MonoBehaviours]
public class PlayingTime : MonoBehaviour
{
private BasePlayer _player;
private void Awake()
{
_player = GetComponent<BasePlayer>();
_.CheckDataBase(_player);
InvokeRepeating(nameof(Timer), 60, 60);
}
public void Timer()
{
_._dataBase.ListPlayers[_player.userID].Balance += _config.ZealShop.PlayingTimeAdd;
}
private void OnDestroy()
{
_.PrintError("Dest");
}
}
#endregion
#region [Classes] / [Классы]
public class ItemShop
{
public string Shortname;
public string Name;
public ulong SkinID;
public int FixCount;
public float Price;
}
public class TradeItem
{
public int Price;
public int Stack;
}
#endregion
#region [Dictionary/Vars] / [Словари/Переменные]
private const string Sharp = "assets/content/ui/ui.background.tile.psd";
private const string Blur = "assets/content/ui/uibackgroundblur.mat";
private const string Radial = "assets/content/ui/ui.background.transparent.radial.psd";
private const string Regular = "robotocondensed-regular.ttf";
private static ZealShop _;
private const string Perm = "ZealShop.use";
#region [Categories]
private readonly List<ItemShop> _gun = new List<ItemShop>
{
new ItemShop
{
Name = "Assault Rifle",
Shortname = "rifle.ak",
FixCount = 1,
Price = 170
},
new ItemShop
{
Name = "LR-300 Assault Rifle",
Shortname = "rifle.lr300",
FixCount = 1,
Price = 240
},
new ItemShop
{
Name = "M249",
Shortname = "lmg.m249",
FixCount = 1,
Price = 700
},
new ItemShop
{
Name = "Bolt Action Rifle",
Shortname = "rifle.bolt",
FixCount = 1,
Price = 200
},
new ItemShop
{
Name = "L96 Rifle",
Shortname = "rifle.l96",
FixCount = 1,
Price = 350
},
new ItemShop
{
Name = "M39 Rifle",
Shortname = "rifle.m39",
FixCount = 1,
Price = 350
},
new ItemShop
{
Name = "M92 Pistol",
Shortname = "pistol.m92",
FixCount = 1,
Price = 120
},
new ItemShop
{
Name = "Python Revolver",
Shortname = "pistol.python",
FixCount = 1,
Price = 100
},
new ItemShop
{
Name = "Semi-Automatic Pistol",
Shortname = "pistol.semiauto",
FixCount = 1,
Price = 80
},
new ItemShop
{
Name = "Rocket Launcher",
Shortname = "rocket.launcher",
FixCount = 1,
Price = 280
},
new ItemShop
{
Name = "Flame Thrower",
Shortname = "flamethrower",
FixCount = 1,
Price = 130
},
new ItemShop
{
Name = "Muzzle Brake",
Shortname = "weapon.mod.muzzlebrake",
FixCount = 1,
Price = 60
},
new ItemShop
{
Name = "Silencer",
Shortname = "weapon.mod.silencer",
FixCount = 1,
Price = 45
},
new ItemShop
{
Name = "Simple Handmade Sight",
Shortname = "weapon.mod.simplesight",
FixCount = 1,
Price = 60
},
new ItemShop
{
Name = "Weapon Flashlight",
Shortname = "weapon.mod.flashlight",
FixCount = 1,
Price = 45
},
new ItemShop
{
Name = "Weapon Lasersight",
Shortname = "weapon.mod.lasersight",
FixCount = 1,
Price = 45
},
new ItemShop
{
Name = "Holosight",
Shortname = "weapon.mod.holosight",
FixCount = 1,
Price = 60
},
new ItemShop
{
Name = "4x Zoom Scope",
Shortname = "weapon.mod.small.scope",
FixCount = 1,
Price = 70
},
new ItemShop
{
Name = "8x Zoom Scope",
Shortname = "weapon.mod.8x.scope",
FixCount = 1,
Price = 85
},
new ItemShop
{
Name = "Beancan Grenade",
Shortname = "grenade.beancan",
FixCount = 10,
Price = 140
}
};
private readonly List<ItemShop> _construction = new List<ItemShop>
{
new ItemShop
{
Name = "ШКАФ",
Shortname = "cupboard.tool",
FixCount = 1,
Price = 150
}
};
private readonly List<ItemShop> _items = new List<ItemShop>
{
new ItemShop
{
Name = "СТУЛ",
Shortname = "chair",
FixCount = 1,
Price = 150
}
};
private readonly List<ItemShop> _resources = new List<ItemShop>
{
new ItemShop
{
Name = "Wood",
Shortname = "wood",
FixCount = 5000,
Price = 75
},
new ItemShop
{
Name = "Stones",
Shortname = "stones",
FixCount = 5000,
Price = 125
},
new ItemShop
{
Name = "Sulfur",
Shortname = "sulfur",
FixCount = 1000,
Price = 110
},
new ItemShop
{
Name = "Metal Fragments",
Shortname = "metal.fragments",
FixCount = 1000,
Price = 75
},
new ItemShop
{
Name = "High Quality Metal",
Shortname = "metal.refined",
FixCount = 100,
Price = 150
},
new ItemShop
{
Name = "Animal Fat",
Shortname = "fat.animal",
FixCount = 100,
Price = 25
},
new ItemShop
{
Name = "Low Grade Fuel",
Shortname = "lowgradefuel",
FixCount = 500,
Price = 100
},
new ItemShop
{
Name = "Cloth",
Shortname = "cloth",
FixCount = 100,
Price = 60
},
new ItemShop
{
Name = "Leather",
Shortname = "leather",
FixCount = 100,
Price = 45
},
new ItemShop
{
Name = "Scrap",
Shortname = "scrap",
FixCount = 100,
Price = 50
},
new ItemShop
{
Name = "Crude Oil",
Shortname = "crude.oil",
FixCount = 100,
Price = 180
}
};
private readonly List<ItemShop> _attire = new List<ItemShop>
{
new ItemShop
{
Name = "МВК МАСКА",
Shortname = "metal.facemask",
FixCount = 1,
Price = 150
}
};
private readonly List<ItemShop> _food = new List<ItemShop>
{
new ItemShop
{
Name = "ЧЕРНИЧЬКаА",
Shortname = "blueberries",
FixCount = 1,
Price = 150
}
};
private readonly List<ItemShop> _tools = new List<ItemShop>
{
new ItemShop
{
Name = "КИРКА",
Shortname = "pickaxe",
FixCount = 1,
Price = 150
}
};
private readonly List<ItemShop> _medicals = new List<ItemShop>
{
new ItemShop
{
Name = "ШПРИЦ",
Shortname = "syringe.medical",
FixCount = 1,
Price = 150
}
};
private readonly List<ItemShop> _ammunations = new List<ItemShop>
{
new ItemShop
{
Name = "ПАТРОНЫ 5x56",
Shortname = "ammo.rifle",
FixCount = 1,
Price = 150
}
};
private readonly List<ItemShop> _traps = new List<ItemShop>
{
new ItemShop
{
Name = "ГАН ТРАП",
Shortname = "guntrap",
FixCount = 1,
Price = 150
}
};
private readonly List<ItemShop> _misc = new List<ItemShop>
{
new ItemShop
{
Name = "МИШКА",
Shortname = "pookie.bear",
FixCount = 1,
Price = 150
}
};
private readonly List<ItemShop> _components = new List<ItemShop>
{
new ItemShop
{
Name = "НОУТБУК",
Shortname = "targeting.computer",
FixCount = 1,
Price = 150
}
};
#endregion
private const string Layer = "Box_Marketplace";
private const string LayerBuyMenu = "Box_BuyMenu";
private const string UITrade = "TradeBG";
#endregion
#region [DrawUI] / [Показ UI]
private void DrawUI_Shop(BasePlayer player, int page, List<ItemShop> category, string categoryname)
{
var gui = new CuiElementContainer();
CuiHelper.DestroyUi(player, Layer);
var db = _dataBase.ListPlayers[player.userID];
gui.Add(new CuiPanel
{
CursorEnabled = true,
Image =
{
Color = HexToRustFormat("#000000F9"),
Material = Blur,
Sprite = Radial
},
RectTransform =
{
AnchorMin = "0 0",
AnchorMax = "1 1"
}
}, "Overlay", Layer);
gui.Add(new CuiButton
{
Button =
{
Command = "close.shop",
Color = "0 0 0 0"
},
Text =
{
Text = " "
},
RectTransform =
{
AnchorMin = "0 0",
AnchorMax = "1 1"
}
}, Layer, "Button.close.shop");
#region [Box-ProfilePanel]
const string layerProfile = "BoxProfile";
gui.Add(new CuiElement
{
Name = "BoxProfile",
Parent = Layer,
Components =
{
new CuiImageComponent
{
Color = HexToRustFormat("#0000009E"),
Material = Blur,
Sprite = Radial
},
new CuiRectTransformComponent
{
AnchorMin = "0.0088541 0.8916666",
AnchorMax = "0.9885417 0.9842592"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#8ebf5b"),
Distance = "0.9 0.9"
}
}
});
gui.Add(new CuiElement
{
Name = "ShopTXT",
Parent = layerProfile,
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleCenter,
Color = HexToRustFormat("#EAEAEAFF"),
FontSize = 40,
Text = "МАГАЗИН"
},
new CuiRectTransformComponent
{
AnchorMin = "0.23126 0",
AnchorMax = "0.83094 1"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#000000AE"),
Distance = "0.5 0.5"
}
}
});
// gui.Add(new CuiElement
// {
// Name = "ICTradeButton",
// Parent = layerProfile,
// Components =
// {
// new CuiImageComponent
// {
// Sprite = "assets/icons/refresh.png",
// Color = HexToRustFormat("#EAEAEAFF")
// },
// new CuiRectTransformComponent
// {
// AnchorMin = "0.9537478 0.18",
// AnchorMax = "0.9877723 0.8199999"
// },
// new CuiOutlineComponent
// {
// Color = HexToRustFormat("#8ebf5b"),
// Distance = "0.4 0.4"
// }
// }
// });
//
// gui.Add(new CuiButton
// {
// Button =
// {
// Command = "trademoney",
// Color = "0 0 0 0"
// },
// Text =
// {
// Text = " "
// },
// RectTransform =
// {
// AnchorMin = "0 0",
// AnchorMax = "1 1"
// }
// }, "ICTradeButton");
#region [Profile]
gui.Add(new CuiElement
{
Name = "AvatarProfile",
Parent = layerProfile,
Components =
{
new CuiRawImageComponent
{
Png = (string) ImageLibrary.Call("GetImage", player.UserIDString),
Color = "1 1 1 1"
},
new CuiRectTransformComponent
{
AnchorMin = "0 0",
AnchorMax = "0.053 0.98"
}
}
});
gui.Add(new CuiElement
{
Name = "AvatarLine",
Parent = layerProfile,
Components =
{
new CuiImageComponent
{
Color = HexToRustFormat("#8ebf5b")
},
new CuiRectTransformComponent
{
AnchorMin = "0.053 0",
AnchorMax = "0.05301 0.99"
}
}
});
gui.Add(new CuiElement
{
Name = "Profile_Nick",
Parent = layerProfile,
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleLeft,
Font = Regular,
FontSize = 14,
Text = "Ник"
},
new CuiRectTransformComponent
{
AnchorMin = "0.05582141 0.689",
AnchorMax = "0.1 0.939"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#00000081"),
Distance = "0.9 0.9"
}
}
});
gui.Add(new CuiElement
{
Name = "Profile_Nick_Line",
Parent = layerProfile,
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleCenter,
Font = Regular,
FontSize = 14,
Text = "|"
},
new CuiRectTransformComponent
{
AnchorMin = "0.0978201 0.6899996",
AnchorMax = "0.1031366 0.9399999"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#00000081"),
Distance = "0.9 0.9"
}
}
});
gui.Add(new CuiElement
{
Name = "Profile_Nick_Value",
Parent = layerProfile,
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleLeft,
Font = Regular,
FontSize = 14,
Text = player.displayName
},
new CuiRectTransformComponent
{
AnchorMin = "0.1081366 0.6899995",
AnchorMax = "0.1939447 0.9399998"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#00000081"),
Distance = "0.9 0.9"
}
}
});
gui.Add(new CuiElement
{
Name = "Profile_Balance",
Parent = layerProfile,
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleLeft,
Font = Regular,
FontSize = 14,
Text = "Баланс"
},
new CuiRectTransformComponent
{
AnchorMin = "0.05582141 0.36",
AnchorMax = "0.1 0.6099994"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#00000081"),
Distance = "0.9 0.9"
}
}
});
gui.Add(new CuiElement
{
Name = "Profile_Balance_Line",
Parent = layerProfile,
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleCenter,
Font = Regular,
FontSize = 14,
Text = "|"
},
new CuiRectTransformComponent
{
AnchorMin = "0.0978201 0.36",
AnchorMax = "0.1031366 0.61"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#00000081"),
Distance = "0.9 0.9"
}
}
});
gui.Add(new CuiElement
{
Name = "Profile_Balance_Value",
Parent = layerProfile,
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleLeft,
Font = Regular,
FontSize = 14,
Text = $"{db.Balance} RUB"
},
new CuiRectTransformComponent
{
AnchorMin = "0.1081366 0.36",
AnchorMax = "0.1939447 0.61"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#00000081"),
Distance = "0.9 0.9"
}
}
});
gui.Add(new CuiElement
{
Name = "Profile_SteamID",
Parent = layerProfile,
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleLeft,
Font = Regular,
FontSize = 14,
Text = "SteamID"
},
new CuiRectTransformComponent
{
AnchorMin = "0.05582141 0.03",
AnchorMax = "0.1 0.28"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#00000081"),
Distance = "0.9 0.9"
}
}
});
gui.Add(new CuiElement
{
Name = "Profile_SteamID_Line",
Parent = layerProfile,
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleCenter,
Font = Regular,
FontSize = 14,
Text = "|"
},
new CuiRectTransformComponent
{
AnchorMin = "0.0978201 0.03",
AnchorMax = "0.1031366 0.29"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#00000081"),
Distance = "0.9 0.9"
}
}
});
gui.Add(new CuiElement
{
Name = "Profile_SteamID_Value",
Parent = layerProfile,
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleLeft,
Font = Regular,
FontSize = 14,
Text = $"{player.userID}"
},
new CuiRectTransformComponent
{
AnchorMin = "0.1081366 0.03",
AnchorMax = "0.1939447 0.29"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#00000081"),
Distance = "0.9 0.9"
}
}
});
#endregion
#endregion
#region [Box-Categories]
string layerCategories = "BoxCategories";
gui.Add(new CuiPanel
{
Image =
{
Color = "0 0 0 0"
},
RectTransform =
{
AnchorMin = "0.0088541 0.8444446",
AnchorMax = "0.9885417 0.8861113"
}
}, Layer, "BoxCategories");
int xc = 0;
double butanchor = (double) 1 / _config.ZealShop.Categories.Count;
foreach (var categories in _config.ZealShop.Categories)
{
gui.Add(new CuiElement
{
Name = $"Category{xc}",
Parent = layerCategories,
Components =
{
new CuiRawImageComponent
{
Color = HexToRustFormat("#00000062"),
Png = GetImg("CategoryBG"),
Material = Blur,
FadeIn = 0.1f + (xc * 0.1f)
},
new CuiRectTransformComponent
{
AnchorMin = $"{0 + ((xc * butanchor) + 0.0025)} {0.0666666}",
AnchorMax = $"{butanchor + ((xc * butanchor) - 0.0025)} {0.9333334}"
}
}
});
gui.Add(new CuiButton
{
Button =
{
Command = $"category {categories}",
Color = "0 0 0 0"
},
Text =
{
Align = TextAnchor.MiddleCenter,
FontSize = 13,
Font = Regular,
Text = categories
},
RectTransform =
{
AnchorMin = "0 0",
AnchorMax = "1 1"
}
}, $"Category{xc}", $"CategoryName{xc}");
xc++;
}
#endregion
gui.Add(new CuiButton
{
Button =
{
Command = $"page {page - 1}",
Color = "0 0 0 0"
},
Text =
{
Align = TextAnchor.MiddleCenter,
Color = HexToRustFormat("#EAEAEAFF"),
Font = Regular,
FontSize = 35,
Text = "<"
},
RectTransform =
{
AnchorMin = "0.002 0.0009",
AnchorMax = "0.022 0.8444"
}
}, Layer, "Page--");
gui.Add(new CuiButton
{
Button =
{
Command = $"page {page + 1}",
Color = "0 0 0 0"
},
Text =
{
Align = TextAnchor.MiddleCenter,
Color = HexToRustFormat("#EAEAEAFF"),
Font = Regular,
FontSize = 35,
Text = ">"
},
RectTransform =
{
AnchorMin = "0.974 0.0009",
AnchorMax = "0.994 0.8444"
}
}, Layer, "Page++");
CuiHelper.AddUi(player, gui);
DrawUI_Category(player, page, category, categoryname);
}
private void DrawUI_Category(BasePlayer player, int page, List<ItemShop> category, string categoryname)
{
var gui = new CuiElementContainer();
DestroyItems(player);
#region [Box-Items]
var countitem = 28;
if (category.Count < 28)
{
countitem = category.Count;
}
int xi = 0, y = 0, i = 0;
foreach (var item in category.Skip(page * 28).Take(28))
{
if (xi == 4)
{
xi = 0;
y++;
}
gui.Add(new CuiPanel
{
Image =
{
Color = "0 0 0 0"
},
RectTransform =
{
AnchorMin = $"{0.0427083 + (xi * 0.236)} {0.7370371 - (y * 0.1182292)}",
AnchorMax = $"{0.2479167 + (xi * 0.236)} {0.8296295 - (y * 0.1182292)}"
}
}, Layer, $"Box_Item{i}");
gui.Add(new CuiElement
{
Name = $"ItemICBG{i}",
Parent = $"Box_Item{i}",
Components =
{
new CuiImageComponent
{
Color = HexToRustFormat("#00000051"),
Material = Blur,
Sprite = Radial,
FadeIn = 0.05f + (i * 0.05f)
},
new CuiRectTransformComponent
{
AnchorMin = "0 0",
AnchorMax = "0.2538071 1"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#8ebf5b"),
Distance = "0.82 0.82"
}
}
});
gui.Add(new CuiElement
{
Name = $"ItemIC{i}",
Parent = $"ItemICBG{i}",
Components =
{
new CuiRawImageComponent
{
Png = GetImg($"{item.Shortname}_{128}_{item.SkinID}"),
FadeIn = 0.05f + (i * 0.05f)
},
new CuiRectTransformComponent
{
AnchorMin = "0.05 0.05",
AnchorMax = "0.95 0.95"
}
}
});
gui.Add(new CuiElement
{
Name = $"ItemStack{i}",
Parent = $"ItemICBG{i}",
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleRight,
FontSize = 11,
Font = Regular,
Text = $"x{item.FixCount}",
FadeIn = 0.05f + (i * 0.05f)
},
new CuiRectTransformComponent
{
AnchorMin = "0.45",
AnchorMax = "0.96 0.24"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#00000051"),
Distance = "0.5 0.5"
}
}
});
gui.Add(new CuiElement
{
Name = $"ItemDesc{i}",
Parent = $"Box_Item{i}",
Components =
{
new CuiImageComponent
{
Color = HexToRustFormat("#00000051"),
Material = Blur,
Sprite = Radial,
FadeIn = 0.05f + (i * 0.05f)
},
new CuiRectTransformComponent
{
AnchorMin = "0.28 0",
AnchorMax = "1 1"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#8ebf5b"),
Distance = "0.82 0.82"
}
}
});
gui.Add(new CuiElement
{
Name = $"ItemDescTXT{i}",
Parent = $"ItemDesc{i}",
Components =
{
new CuiTextComponent
{
Align = TextAnchor.UpperCenter,
FontSize = 12,
Font = Regular,
Text =
$"<b>{item.Name}</b>\n<size=10><color=#EAEAEA>СТОИМОСТЬ - {(item.Price / item.FixCount) * item.FixCount} RUB</color></size>",
FadeIn = 0.05f + (i * 0.05f)
},
new CuiRectTransformComponent
{
AnchorMin = "0 0",
AnchorMax = "1 0.94"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#00000051"),
Distance = "0.5 0.5"
}
}
});
gui.Add(new CuiPanel
{
Image =
{
Color = "1 1 1 1",
Sprite = "assets/icons/store.png"
},
RectTransform =
{
AnchorMin = "0.9024234 0.0499998",
AnchorMax = "0.9729254 0.2499993"
}
}, $"ItemDesc{i}", $"CartIC{i}");
gui.Add(new CuiButton
{
Button =
{
Command = $"buymenu {categoryname} {item.Shortname} {1}",
Color = "0 0 0 0"
},
Text =
{
Text = " "
},
RectTransform =
{
AnchorMin = "0 0",
AnchorMax = "1 1"
}
}, $"CartIC{i}", $"CartButton{i}");
xi++;
i++;
}
#endregion
CuiHelper.AddUi(player, gui);
}
private void DrawUI_BuyMenu(BasePlayer player, ItemShop item, string categoryname, int count)
{
var gui = new CuiElementContainer();
gui.Add(new CuiElement
{
Name = "BuyMenuBG",
Parent = LayerBuyMenu,
Components =
{
new CuiImageComponent
{
Color = HexToRustFormat("#0000009C"),
Material = Blur,
Sprite = Radial
},
new CuiRectTransformComponent
{
AnchorMin = "0.296874 0.5768518",
AnchorMax = "0.703125 0.7111106"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#8ebf5b"),
Distance = "0.82 0.82"
}
}
});
gui.Add(new CuiElement
{
Name = "ZagBuyMenuBG",
Parent = "BuyMenuBG",
Components =
{
new CuiImageComponent
{
Color = HexToRustFormat("#0000009C"),
Material = Blur
},
new CuiRectTransformComponent
{
AnchorMin = "0 0.7655199",
AnchorMax = "0.998 1"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#8ebf5b"),
Distance = "0 0.82"
}
}
});
gui.Add(new CuiElement
{
Name = "BuyMenuZagTXT",
Parent = "ZagBuyMenuBG",
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleCenter,
Color = HexToRustFormat("#EAEAEAFF"),
FontSize = 20,
Text = "ПОКУПКА ТОВАРА"
},
new CuiRectTransformComponent
{
AnchorMin = "0 0",
AnchorMax = "1 1"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#000000AE"),
Distance = "0.5 0.5"
}
}
});
gui.Add(new CuiElement
{
Name = "ItemICBG",
Parent = "BuyMenuBG",
Components =
{
new CuiImageComponent
{
Color = HexToRustFormat("#00000051"),
Material = Blur,
Sprite = Radial
},
new CuiRectTransformComponent
{
AnchorMin = "0.0102566 0.0316285",
AnchorMax = "0.1384618 0.7212864"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#8ebf5b"),
Distance = "0.82 0.82"
}
}
});
gui.Add(new CuiElement
{
Name = "ItemIC",
Parent = "ItemICBG",
Components =
{
new CuiRawImageComponent
{
Png = GetImg($"{item.Shortname}_{128}_{item.SkinID}")
},
new CuiRectTransformComponent
{
AnchorMin = "0.05 0.05",
AnchorMax = "0.95 0.95"
}
}
});
gui.Add(new CuiElement
{
Name = "BuyCount",
Parent = "BuyMenuBG",
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleLeft,
Color = HexToRustFormat("#EAEAEAFF"),
FontSize = 11,
Text = $"Купить : {count * item.FixCount} шт"
},
new CuiRectTransformComponent
{
AnchorMin = "0.1538465 0.5724156",
AnchorMax = "0.4115387 0.7241406"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#000000AE"),
Distance = "0.5 0.5"
}
}
});
double priceone = (double) item.Price / item.FixCount;
double price = priceone * (item.FixCount * count);
gui.Add(new CuiElement
{
Name = "BuyPrice",
Parent = "BuyMenuBG",
Components =
{
new CuiTextComponent
{
Align = TextAnchor.MiddleLeft,
Color = HexToRustFormat("#EAEAEAFF"),
FontSize = 11,
Text = $"Стоимость : {price} RUB"
},
new CuiRectTransformComponent
{
AnchorMin = "0.1538465 0.4137945",
AnchorMax = "0.4115387 0.5655191"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#000000AE"),
Distance = "0.5 0.5"
}
}
});
gui.Add(new CuiElement
{
Name = "BuyButtonBG",
Parent = "BuyMenuBG",
Components =
{
new CuiImageComponent
{
Color = HexToRustFormat("#0000004F"),
Material = Blur
},
new CuiRectTransformComponent
{
AnchorMin = "0.8564103 0.03448237",
AnchorMax = "0.9935897 0.2068968"
},
new CuiOutlineComponent
{
Color = HexToRustFormat("#8ebf5b"),
Distance = "0 0.82"
}
}
});
gui.Add(new CuiButton
{
Button =
{
Command = $"buymenu {categoryname} {item.Shortname} {count - 1}",
Color = "0 0 0 0"
},
Text =
{
Align = TextAnchor.MiddleCenter,
Color = "1 1 1 1",
FontSize = 14
// ... [Code preview truncated due to length. Full source in attached file] ...