C#:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using ConVar;
using Newtonsoft.Json;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using UnityEngine;
using System.Linq;
using Newtonsoft.Json.Linq;
using System.Text;
using Oxide.Core.Libraries.Covalence;
using System.Text.RegularExpressions;
using Oxide.Core;
using System.Threading;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;
namespace Oxide.Plugins {
/*ПЛАГИН БЫЛ ПОФИКШЕН С ПОМОЩЬЮ ПРОГРАММЫ СКАЧАНОЙ С https://discord.gg/dNGbxafuJn */
[Info("IQModalMenu", "https://discord.gg/dNGbxafuJn", "0.0.1")]
[Description("Модальное меню")]
class IQModalMenu : RustPlugin {
#region Reference
[PluginReference]
Plugin ImageLibrary, IQEconomic, IQRankSystem, IQChat;
#region ImageLibrary
private string GetImage(string fileName, ulong skin = 0) {
var imageId = (string)plugins.Find("ImageLibrary").CallHook("GetImage", fileName, skin);
if (!string.IsNullOrEmpty(imageId)) return imageId;
return string.Empty;
}
public bool AddImage(string url, string shortname, ulong skin = 0) => (bool)ImageLibrary?.Call("AddImage", url, shortname, skin);
public void SendImage(BasePlayer player, string imageName, ulong imageId = 0) => ImageLibrary?.Call("SendImage", player, imageName, imageId);
public bool HasImage(string imageName) => (bool)ImageLibrary?.Call("HasImage", imageName);
private List<string> AllUrlsImage = new List<string>();
private void LoadedImage(string URL) {
if (!AllUrlsImage.Contains(URL)) AllUrlsImage.Add(URL);
}
private IEnumerator AddedImages() {
foreach (string URL in AllUrlsImage) {
string GenerateName = $"IQMODALMENU_{URL}";
if (!HasImage(GenerateName)) AddImage(URL, GenerateName);
yield return new WaitForSeconds(0.15f);
foreach (BasePlayer player in BasePlayer.activePlayerList) SendImage(player, GenerateName);
}
yield return new WaitForSeconds(0.15f);
PrintWarning("Плагин инициализировал контент! Приятного пользования!");
}
private IEnumerator CashedImagePlayer(BasePlayer player) {
foreach (string imageName in AllUrlsImage) {
string GenerateName = $"IQMODALMENU_{imageName}";
SendImage(player, GenerateName);
yield return new WaitForSeconds(0.15f);
}
}
#endregion
#region IQChat
private void SendChat(string Message, BasePlayer player, Chat.ChatChannel channel = Chat.ChatChannel.Global) {
var Chat = config.ReferenceSetting.IQChatSetting;
if (IQChat) if (Chat.UIAlertUse) IQChat?.Call("API_ALERT_PLAYER_UI", player, Message);
else IQChat?.Call("API_ALERT_PLAYER", player, Message, Chat.CustomPrefix, Chat.CustomAvatar);
else player.SendConsoleCommand("chat.add", channel, 0, Message);
}
#endregion
#region IQRankSystem
string GET_RANK_NAME(ulong userID) => (string)IQRankSystem.CallHook("API_GET_RANK_NAME", userID);
#endregion
#region IQEconomic
int GET_BALANCE(ulong userID) => (int)IQEconomic.CallHook("API_GET_BALANCE", userID);
#endregion
#endregion
#region Var
private readonly string PermissionController = "iqmodalmenu.controller";
private enum TypeResize {
QR, Photo
}
private enum TypeDeletedPost {
DeletePost, DeletePostListForTags
}
private static DateTime TimeCreatedSave = SaveRestore.SaveCreatedTime.Date;
private static string AVATAR_CIRCLE = "https://i.imgur.com/it2UliU.png";
private Dictionary<BasePlayer, SessionInformation> SessionUsers = new Dictionary<BasePlayer, SessionInformation>();
private Dictionary<BasePlayer, List<KillInformation>> KillHistory = new Dictionary<BasePlayer, List<KillInformation>>();
private class SessionInformation {
public int Wood;
public int Stones;
public int SulfurOre;
public int Metal;
public int HQM;
public int Killed;
public int Death;
public DateTime Time;
}
private class KillInformation {
public string DisplayName;
public string WeaponName;
public double Distantion;
public DateTime TimeKill;
}
#endregion
#region Data
private enum TitulsPost {
New, Popular, Important, None
}
[JsonProperty("Дата с постами")]
private List<PostInformation> PostList = new List<PostInformation>();
[JsonProperty("Дата с удаленными постами")]
private List<int> PostDeletedList = new List<int>();
private class PostInformation {
[JsonProperty("Отображаемое имя")]
public string DisplayName;
[JsonProperty("Текст")]
public string Text;
[JsonProperty("Фон поста")]
public string PostAvatar;
[JsonProperty("Тэг")]
public string Tag;
[JsonProperty("Дата")]
public int Date;
[JsonProperty("Титул поста")]
public TitulsPost TitulsPost;
[JsonProperty("Статистика поста")]
public Statistics StatisticsPost = new Statistics();
internal class Statistics {
[JsonProperty("Пользователи просмотревшие запись")]
public List<ulong> ViewsUser = new List<ulong>();
[JsonProperty("Пользователи лайкнувшие запись")]
public List<ulong> LikedUsers = new List<ulong>();
}
[JsonProperty("Фото для поста")]
public List<PhotoInformation> PhotoList = new List<PhotoInformation>();
internal class PhotoInformation {
[JsonProperty("Миниатюра")]
public string MiniaturePhoto;
[JsonProperty("Приблеженная")]
public string MediumPhoto;
[JsonProperty("FullHD")]
public string FullHDPhoto;
}
[JsonProperty("Уникальный ID от поста(Не изменяйте,если не знаете как это работает)")]
public int id;
}
private void ReadData() {
PostList = Oxide.Core.Interface.Oxide.DataFileSystem.ReadObject<List<PostInformation>>("IQModalMenu/Posts");
PostDeletedList = Oxide.Core.Interface.Oxide.DataFileSystem.ReadObject<List<int>>("IQModalMenu/PostsDeleted");
}
private void WriteData() {
Oxide.Core.Interface.Oxide.DataFileSystem.WriteObject("IQModalMenu/Posts", PostList);
Oxide.Core.Interface.Oxide.DataFileSystem.WriteObject("IQModalMenu/PostsDeleted", PostDeletedList);
}
#endregion
#region Metods
#region Posts
#region VK PARSE
private class ParseVK {
public Response response;
public class Response {
public List<item> items;
public class item {
public int id;
public string text;
public int date;
public List<attachment> attachments;
public class attachment {
public string type;
public photos photo;
public class photos {
public List<size> sizes;
public string id;
public class size {
public string url;
public string type;
}
}
}
}
}
}
private void ParseWall() {
var VK = config.PostSetting.VKSettings;
if (!config.PostSetting.UseParse) return;
if(VK.VKGroupID == "https://regvk.com/id/ ТУТ ВЫ СМОЖЕТЕ ВЗЯТЬ ID ГРУППЫ, ВСТАВЛЯЕТЕ В ПОЛЕ ВАШУ ССЫЛКУ НА ГРУППУ ВК И ЖМЕТЕ ОПРЕДЕЛИТЬ ID И СЮДА ВВОДИТЕ ЦИФРЫ (ПОСЛЕ ID публичной страницы: ЭТИ ЦИФРЫ ВАШ ID)") {
PrintWarning("Вы не установили ID группы с которой требуется искать новости, автоматический поиск записей остановлен!");
return;
}
if (VK.TokenVK == "https://vkhost.github.io/ ТУТ ВЫ СМОЖЕТЕ ВЗЯТЬ СВОЙ ТОКЕН ПО КНОПОЧКЕ VK API") {
PrintWarning("Вы не установили VKToken, автоматический поиск записей остановлен!");
return;
}
string URL = $"https://api.vk.com/method/wall.get?owner_id=-{VK.VKGroupID}&count=10&access_token={VK.TokenVK}&v=5.126";
webrequest.Enqueue(URL, null, (code, response) => {
if (code != 200 || response == null) return;
var ParseVK = JsonConvert.DeserializeObject<ParseVK>(response);
for (int tag = 0; tag < VK.TagList.Count; tag++) {
string Tag = VK.TagList[tag];
foreach (var Posts in ParseVK.response.items.Where(x => x.text.Contains(Tag) && PostList.Count(p => p.id == x.id || PostDeletedList.Contains(p.id)) == 0).Take(10)) {
PostInformation PostContent = new PostInformation();
PostContent.id = Posts.id;
PostContent.Text = Posts.text;
PostContent.Date = Posts.date;
PostContent.DisplayName = Posts.text.Length >= 67 ? $"{Posts.text.Substring(0, 67).Replace(Tag, "").Replace("\n", "")}..." : $"{Posts.text.Replace(Tag, "").Replace("\n", "")}";
PostContent.Tag = Tag;
PostContent.TitulsPost = TitulsPost.New;
PostContent.StatisticsPost.LikedUsers = new List<ulong>();
PostContent.StatisticsPost.ViewsUser = new List<ulong>();
if (Posts.attachments != null) foreach (var PostPhoto in Posts.attachments.Where(p => p.type == "photo" && p.photo.sizes.Count != 0)) {
string PhotoUrl = PostPhoto.photo.sizes[PostPhoto.photo.sizes.Count - 1].url;
string MiniaturePhoto = GetResizeIMG(PhotoUrl, ResizeType.Miniature);
string MediumPhoto = GetResizeIMG(PhotoUrl, ResizeType.Medium);
string FullHD = GetResizeIMG(PhotoUrl, ResizeType.FullHD);
PostContent.PhotoList.Add(new PostInformation.PhotoInformation {
MiniaturePhoto = MiniaturePhoto, MediumPhoto = MediumPhoto, FullHDPhoto = FullHD
}
);
if (!HasImage($"IQMODALMENU_{MiniaturePhoto}")) AddImage(MiniaturePhoto, $"IQMODALMENU_{MiniaturePhoto}");
if (!HasImage($"IQMODALMENU_{MediumPhoto}")) AddImage(MediumPhoto, $"IQMODALMENU_{MediumPhoto}");
if (!HasImage($"IQMODALMENU_{FullHD}")) AddImage(FullHD, $"IQMODALMENU_{FullHD}");
foreach (BasePlayer player in BasePlayer.activePlayerList) {
SendImage(player, $"IQMODALMENU_{MiniaturePhoto}");
SendImage(player, $"IQMODALMENU_{MediumPhoto}");
SendImage(player, $"IQMODALMENU_{FullHD}");
}
}
if (PostContent.PhotoList.Count == 0) PostContent.PhotoList.Add(new PostInformation.PhotoInformation {
MiniaturePhoto = GetResizeIMG(VK.StaticBacgkroundPage, ResizeType.Miniature), MediumPhoto = GetResizeIMG(VK.StaticBacgkroundPage, ResizeType.Medium), FullHDPhoto = GetResizeIMG(VK.StaticBacgkroundPage, ResizeType.FullHD)
}
);
PostContent.PostAvatar = PostContent.PhotoList[0].FullHDPhoto;
PostList.Add(PostContent);
Puts($"Добавлен новый пост с названием : {PostContent.DisplayName} : Тэг : {PostContent.Tag}");
foreach (BasePlayer player in BasePlayer.activePlayerList) SendChat(GetLang("CHAT_MESSAGE_ALERT_NEW_POST", player.UserIDString, Tag), player);
}
}
WriteData();
}
, this, Core.Libraries.RequestMethod.GET);
// timer.Once(VK.ParseTimer, () => ParseWall());
timer.Once(30f, () => ParseWall());
}
public static byte[] Resize(byte[] bytes, int sizeX, int sizeY) {
Image img = (Bitmap)(new ImageConverter().ConvertFrom(bytes));
Bitmap cutPiece = new Bitmap(sizeX, sizeY);
System.Drawing.Graphics graphic = System.Drawing.Graphics.FromImage(cutPiece);
graphic.DrawImage(img, new Rectangle(0, 0, sizeX, sizeY), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel);
graphic.Dispose();
MemoryStream ms = new MemoryStream();
cutPiece.Save(ms, ImageFormat.Jpeg);
return ms.ToArray();
}
#endregion
#region SKY RESIZE
private enum ResizeType {
Miniature, Medium, FullHD
}
private string GetResizeIMG(string URL, ResizeType Type) {
string Size = Type == ResizeType.Miniature ? "480x270" : Type == ResizeType.Medium ? "1600x900" : "1920x1080";
string API = $"http://rust.skyplugins.ru/resize/{Size}/{URL}";
return API;
}
#endregion
#region DeletePosts
private void DeletePosts(TypeDeletedPost TypeDelete, PostInformation Post = null, string Tag = "", BasePlayer player = null) {
switch (TypeDelete) {
case TypeDeletedPost.DeletePost : {
if (Post != null && PostList.Contains(Post)) {
if (!PostDeletedList.Contains(Post.id)) PostDeletedList.Add(Post.id);
if (player != null) SendChat(GetLang("CHAT_MESSAGE_ALERT_DELETE_POST", player.UserIDString, Post.DisplayName), player);
PostList.Remove(Post);
}
else {
if (player != null) SendChat(GetLang("CHAT_MESSAGE_ERROR_DELETE_POST", player.UserIDString), player);
return;
}
break;
}
case TypeDeletedPost.DeletePostListForTags : {
List<PostInformation> FindedDeletedPost = (List<PostInformation>)PostList.Where(p => p.Tag == Tag).ToList();
if (FindedDeletedPost == null || FindedDeletedPost.Count == 0) {
if (player != null) SendChat(GetLang("CHAT_MESSAGE_ERROR_DELETE_POST_LIST_TAG_NOT_FOUND", player.UserIDString), player);
Puts(GetLang("CHAT_MESSAGE_ERROR_DELETE_POST_LIST_TAG_NOT_FOUND"));
return;
}
foreach (PostInformation FindPost in FindedDeletedPost) {
if (!PostDeletedList.Contains(Post.id)) PostDeletedList.Add(Post.id);
PostList.Remove(FindPost);
}
if (player != null) SendChat(GetLang("CHAT_MESSAGE_ALERT_DELETE_POST_LIST_TAG", player.UserIDString, Tag), player);
Puts(GetLang("CHAT_MESSAGE_ALERT_DELETE_POST_LIST_TAG", null, Tag));
break;
}
}
}
#endregion
#region AutoDeletePost
void AutoDeletePost() {
var ConfigPost = config.PostSetting;
if (!ConfigPost.AutoDeletePost) return;
List<PostInformation> PostListDeleted = PostList.Where(p => GetTimePost(p.Date) >= ConfigPost.AutoDeletePostTime).ToList();
if (PostListDeleted != null || PostListDeleted.Count != 0) foreach (PostInformation Post in PostListDeleted) {
Puts(GetLang("CHAT_MESSAGE_ALERT_AUTO_DELETE_POST", null, Post.DisplayName, Post.Tag));
DeletePosts(TypeDeletedPost.DeletePost, Post);
}
}
#endregion
#endregion
#region KillHistory
private void KillHistoryUpdate(BasePlayer player, string DisplayName, string WeaponShortname, double Distantion, DateTime TimeKill, BasePlayer InitiatorKilled) {
if (!SessionUsers.ContainsKey(player) || !SessionUsers.ContainsKey(InitiatorKilled)) return;
if (!KillHistory.ContainsKey(player)) KillHistory.Add(player, new List<KillInformation> {
}
);
KillInformation Information = new KillInformation();
Information.DisplayName = DisplayName;
Information.WeaponName = WeaponShortname;
Information.Distantion = Distantion;
Information.TimeKill = TimeKill;
KillHistory[player].Add(Information);
SessionUsers[player].Death++;
SessionUsers[InitiatorKilled].Killed++;
}
#endregion
#region Sessions
private void SessionUser(BasePlayer player) {
if (!SessionUsers.ContainsKey(player)) SessionUsers.Add(player, new SessionInformation {
Time = DateTime.Now, Death = 0, Killed = 0, Wood = 0, Stones = 0, Metal = 0, HQM = 0, SulfurOre = 0
}
);
else SessionUsers[player].Time = DateTime.Now;
ServerMgr.Instance.StartCoroutine(CashedImagePlayer(player));
}
private void SessionStatistickUpdate(BasePlayer player, string Shortname, int Amount) {
switch (Shortname) {
case "wood" : {
SessionUsers[player].Wood += Amount;
break;
}
case "stones" : {
SessionUsers[player].Stones += Amount;
break;
}
case "sulfur.ore" : {
SessionUsers[player].SulfurOre += Amount;
break;
}
case "metal.ore" : {
SessionUsers[player].Metal += Amount;
break;
}
case "hq.metal.ore" : {
SessionUsers[player].HQM += Amount;
break;
}
}
}
#endregion
#region Post Statistics
private void LikeController(BasePlayer player, CuiElementContainer container, string Tag, int Page, int Index, int PagePost) {
PostInformation Post = !String.IsNullOrEmpty(Tag) ? PostList.Where(x => x.Tag == Tag).OrderByDescending(p => p.TitulsPost == TitulsPost.Important).ThenByDescending(p => p.TitulsPost == TitulsPost.Popular).ThenByDescending(p => p.TitulsPost == TitulsPost.New).Skip(3 * Page).ElementAt(Index) : PostList.OrderByDescending(p => p.TitulsPost == TitulsPost.Important).ThenByDescending(p => p.TitulsPost == TitulsPost.Popular).ThenByDescending(p => p.TitulsPost == TitulsPost.New).Skip(3 * Page).ElementAt(Index);
if (Post.StatisticsPost.LikedUsers.Contains(player.userID)) Post.StatisticsPost.LikedUsers.Remove(player.userID);
else {
Post.StatisticsPost.LikedUsers.Add(player.userID);
LikePostAlert(player, container, PagePost);
}
LikePostInterface(player, container, Post, PagePost, Index, Page, Tag);
}
private void ViewsController(BasePlayer player, PostInformation Post) {
if (!Post.StatisticsPost.ViewsUser.Contains(player.userID)) Post.StatisticsPost.ViewsUser.Add(player.userID);
}
#endregion
#region Tituls Post
private void TitulPostsController() {
#region New Controller
foreach (PostInformation Post in PostList.Where(p => p.TitulsPost == TitulsPost.New && GetTimePost(p.Date) >= config.PostSetting.NewDaysPost)) Post.TitulsPost = TitulsPost.None;
#endregion
#region PopularController
PostInformation ExistingPopularPost = PostList.FirstOrDefault(p => p.TitulsPost == TitulsPost.Popular);
List<PostInformation> PostPopularList = PostList.Where(p => p.TitulsPost == TitulsPost.None).OrderByDescending(p => p.StatisticsPost.ViewsUser.Count).ThenByDescending(p => p.StatisticsPost.LikedUsers.Count).ToList();
if (ExistingPopularPost != null) {
if (ExistingPopularPost == PostPopularList[0]) return;
else {
ExistingPopularPost.TitulsPost = TitulsPost.None;
PostPopularList[0].TitulsPost = TitulsPost.Popular;
foreach (BasePlayer player in BasePlayer.activePlayerList) SendChat(GetLang("CHAT_MESSAGE_ALERT_POPULAR_POST", player.UserIDString, PostPopularList[0].Tag), player);
}
}
else if (PostPopularList != null && PostPopularList.Count != 0 && PostPopularList[0] != null) {
PostPopularList[0].TitulsPost = TitulsPost.Popular;
foreach (BasePlayer player in BasePlayer.activePlayerList) SendChat(GetLang("CHAT_MESSAGE_ALERT_POPULAR_POST", player.UserIDString, PostPopularList[0].Tag), player);
}
#endregion
timer.Once(10800f, () => TitulPostsController());
}
private void TitulPostSetImportant(PostInformation Post) {
PostInformation ExistingPopularPost = PostList.FirstOrDefault(p => p.TitulsPost == TitulsPost.Important);
if (ExistingPopularPost != null) ExistingPopularPost.TitulsPost = TitulsPost.None;
Post.TitulsPost = TitulsPost.Important;
foreach (BasePlayer player in BasePlayer.activePlayerList) SendChat(GetLang("CHAT_MESSAGE_ALERT_IMPORTANT_POST", player.UserIDString, Post.Tag), player);
}
#endregion
#region Utilites
private void LoadedAllImages() {
if (!ImageLibrary) {
PrintError("Не найден плагин ImageLibrary, иконки невозможно загрузить, плагин выгружен");
Interface.Oxide.UnloadPlugin(Name);
return;
}
var ImageQRS = config.BlockSetting.BlockUP.QRListPNG;
var ImageConfigInterface = config.InterfaceSetting.ImagesSetting.BlockImages.ImageBlock;
var VK = config.PostSetting.VKSettings;
if (!IsStringEmpty(VK.StaticBacgkroundPage)) {
LoadedImage(GetResizeIMG(VK.StaticBacgkroundPage, ResizeType.Miniature));
LoadedImage(GetResizeIMG(VK.StaticBacgkroundPage, ResizeType.Medium));
LoadedImage(GetResizeIMG(VK.StaticBacgkroundPage, ResizeType.FullHD));
}
if (!IsStringEmpty(ImageConfigInterface.CalendarWipe)) LoadedImage(ImageConfigInterface.CalendarWipe);
if (!IsStringEmpty(ImageConfigInterface.CloseButton)) LoadedImage(ImageConfigInterface.CloseButton);
if (!IsStringEmpty(ImageConfigInterface.FilterClose)) LoadedImage(ImageConfigInterface.FilterClose);
if (!IsStringEmpty(ImageConfigInterface.FilterOpen)) LoadedImage(ImageConfigInterface.FilterOpen);
if (!IsStringEmpty(ImageConfigInterface.FilterSet)) LoadedImage(ImageConfigInterface.FilterSet);
if (!IsStringEmpty(ImageConfigInterface.FriendList)) LoadedImage(ImageConfigInterface.FriendList);
if (!IsStringEmpty(ImageConfigInterface.KillHistory)) LoadedImage(ImageConfigInterface.KillHistory);
if (!IsStringEmpty(ImageConfigInterface.Online)) LoadedImage(ImageConfigInterface.Online);
if (!IsStringEmpty(ImageConfigInterface.PostStatisticsLikes)) LoadedImage(ImageConfigInterface.PostStatisticsLikes);
if (!IsStringEmpty(ImageConfigInterface.PostStatisticsViews)) LoadedImage(ImageConfigInterface.PostStatisticsViews);
if (!IsStringEmpty(ImageConfigInterface.Statistics)) LoadedImage(ImageConfigInterface.Statistics);
if (!IsStringEmpty(ImageConfigInterface.StatisticsReturnMe)) LoadedImage(ImageConfigInterface.StatisticsReturnMe);
if (!IsStringEmpty(ImageConfigInterface.PageDown)) LoadedImage(ImageConfigInterface.PageDown);
if (!IsStringEmpty(ImageConfigInterface.PageUp)) LoadedImage(ImageConfigInterface.PageUp);
if (!IsStringEmpty(ImageConfigInterface.SorterTimePost)) LoadedImage(ImageConfigInterface.SorterTimePost);
if (ImageQRS.Count != 0) foreach (string QR in ImageQRS.Where(qr => !IsStringEmpty(qr)).Take(3)) LoadedImage(QR);
LoadedImage(AVATAR_CIRCLE);
foreach (var PhotoPost in PostList) {
if (!String.IsNullOrWhiteSpace(PhotoPost.PostAvatar)) LoadedImage(PhotoPost.PostAvatar);
if (PhotoPost.PhotoList.Count != 0) for (int Photo = 0; Photo < PhotoPost.PhotoList.Count; Photo++) {
LoadedImage(PhotoPost.PhotoList[Photo].MiniaturePhoto);
LoadedImage(PhotoPost.PhotoList[Photo].MediumPhoto);
LoadedImage(PhotoPost.PhotoList[Photo].FullHDPhoto);
}
}
ServerMgr.Instance.StartCoroutine(DownloadImages());
ServerMgr.Instance.StartCoroutine(AddedImages());
}
private IEnumerator DownloadImages() {
Puts("AddImages SkyPlugins.ru...");
if (!HasImage($"wood_48px")) AddImage($"http://rust.skyplugins.ru/getimage/wood/48", $"wood_48px");
if (!HasImage($"stones_48px")) AddImage($"http://rust.skyplugins.ru/getimage/stones/48", $"stones_48px");
if (!HasImage($"metal_48px")) AddImage($"http://rust.skyplugins.ru/getimage/metal.fragments/48", $"metal_48px");
if (!HasImage($"hqv_48px")) AddImage($"http://rust.skyplugins.ru/getimage/metal.refined/48", $"hqv_48px");
if (!HasImage($"sulfur_48px")) AddImage($"http://rust.skyplugins.ru/getimage/sulfur.ore/48", $"sulfur_48px");
yield return new WaitForSeconds(0.04f);
Puts("AddImages SkyPlugins.ru - completed..");
}
private bool IsStringEmpty(string String) => String.IsNullOrWhiteSpace(String);
private List<string> TagListActive() {
List<string> TagResult = new List<string>();
foreach (var Tags in PostList.Where(x => !String.IsNullOrEmpty(x.Tag))) {
if (!TagResult.Contains(Tags.Tag)) TagResult.Add(Tags.Tag);
}
return TagResult;
}
private int GetTimePost(int Date) {
DateTime RealTime = DateTime.Now.Date;
int TimePost = RealTime.Subtract(new DateTime(1970, 1, 1).Add(TimeSpan.FromTicks(Date * TimeSpan.TicksPerSecond)).ToLocalTime()).Days;
return TimePost;
}
private void RegisteredPermissions() {
if (!permission.PermissionExists(PermissionController, this)) permission.RegisterPermission(PermissionController, this);
}
private static string HexToRustFormat(string hex) {
UnityEngine.Color color;
ColorUtility.TryParseHtmlString(hex, out color);
return string.Format("{0:F2} {1:F2} {2:F2} {3:F2}", color.r, color.g, color.b, color.a);
}
#endregion
#endregion
#region Configuration
private static Configuration config = new Configuration();
private class Configuration {
[JsonProperty("Настройка интерфейса")]
public InterfaceSettings InterfaceSetting = new InterfaceSettings();
[JsonProperty("Настройка блоков")]
public BlockSettings BlockSetting = new BlockSettings();
[JsonProperty("Настройка постов")]
public PostSettings PostSetting = new PostSettings();
[JsonProperty("Настройка поддерживаемых плагинов")]
public ReferenceSettings ReferenceSetting = new ReferenceSettings();
internal class ReferenceSettings {
[JsonProperty("IQChat : Настройки чата")]
public IQChatSettings IQChatSetting = new IQChatSettings();
internal class IQChatSettings {
[JsonProperty("IQChat : Кастомный префикс в чате")]
public string CustomPrefix;
[JsonProperty("IQChat : Кастомный аватар в чате(Если требуется)")]
public string CustomAvatar;
[JsonProperty("IQChat : Использовать UI уведомления")]
public bool UIAlertUse;
}
}
internal class BlockSettings {
[JsonProperty("Настройка вверхнего блока")]
public BlockUPSettings BlockUP = new BlockUPSettings();
[JsonProperty("Раз в сколько дней у вас происходит WIPE сервера")]
public int DayWiped;
internal class BlockUPSettings {
[JsonProperty("Ссылка отображаемая в шапке")]
public string LinkAdsSocial;
[JsonProperty("Ссылки на QR коды для вашего сервера(Не больше 3-х)")]
public List<string> QRListPNG = new List<string>();
}
}
internal class PostSettings {
[JsonProperty("Пост считается новым пока ему не исполнится N дней и имеет титул НОВЫЙ")]
public int NewDaysPost;
[JsonProperty("Включить поддержку стены ВК вашего сообщества(нужно будет настроить тэги)")]
public bool UseParse;
[JsonProperty("Включить автоматическое удаление постов, которым более N дней")]
public bool AutoDeletePost;
[JsonProperty("Сколько дней должно пройти после создания поста для его удаления(должно быть включено автоудаление)")]
public int AutoDeletePostTime;
[JsonProperty("Настройки парсинга постов ВК")]
public VKParse VKSettings = new VKParse();
internal class VKParse {
[JsonProperty("Включить уведомления о новых постах в чат")]
public bool UseAlertPost;
[JsonProperty("Раз во сколько N промежтку времени сканировать группу ВК на наличие новых постов(Таймер зациклен)")]
public int ParseTimer;
[JsonProperty("Токен от вашей страницы ВК(Вы должны быть Администратором вашего сообщества)")]
public string TokenVK;
[JsonProperty("ID группы с которой будут браться посты(Вы должны быть Администратором вашего сообщества)")]
public string VKGroupID;
[JsonProperty("Титульная фотография для каждого поста(в дата файле вы сможете ее менять каждому посту)")]
public string StaticBacgkroundPage;
[JsonProperty("Посты с какими тэгами в ВК отображать в плагине")]
public List<string> TagList = new List<string>();
}
}
internal class InterfaceSettings {
[JsonProperty("Настройка цветов")]
public ColorSettings ColorSetting = new ColorSettings();
[JsonProperty("Настройка иконок")]
public Images ImagesSetting = new Images();
internal class Images {
[JsonProperty("Настройка иконок в блоках меню")]
public BlockImage BlockImages;
internal class BlockImage {
[JsonProperty("Настройка PNG картинок в блоках | При установке,учтите что - пункт со Sprite должен быть пустой - иначе он имеет приоритет | Корректные размеры указаны в скобках - (NxN)")]
public Images ImageBlock;
[JsonProperty("Настройка спрайтов в блоках")]
public Sprites SpritesBlock;
internal class Sprites {
[JsonProperty("Sprite для отображения статуса онлайна")]
public string Online;
[JsonProperty("Sprite для кнопки ЗАКРЫТЬ")]
public string CloseButton;
[JsonProperty("Sprite на картинку в заглавлении списка друзей")]
public string FriendList;
[JsonProperty("Sprite на картинку в заглавлении истории смертей")]
public string KillHistory;
[JsonProperty("Sprite на картинку в заглавлении статистики за сессию")]
public string Statistics;
[JsonProperty("Sprite на картинку в заглавлении статистики за сессию для активной кнопки возврата к своей статистике")]
public string StatisticsReturnMe;
[JsonProperty("Sprite на картинку в заглавлении календаря вайпов")]
public string CalendarWipe;
[JsonProperty("Sprite на картинку в фильтре постов для развертывания списка фильтров")]
public string FilterOpen;
[JsonProperty("Sprite на картинку в фильтре постов для скрытия списка фильтров")]
public string FilterClose;
[JsonProperty("Sprite на картинку в фильтре постов для установки фильтра")]
public string FilterSet;
[JsonProperty("Sprite на картинку в сортировке постов по времени")]
public string SorterTimePost;
[JsonProperty("Sprite на картинку в статистике постов для количества просмотров")]
public string PostStatisticsViews;
[JsonProperty("Sprite на картинку в статистике постов для количества лайков")]
public string PostStatisticsLikes;
[JsonProperty("Sprite на страницы вниз в статье постов")]
public string PageDown;
[JsonProperty("Sprite на страницы вверх в статье постов")]
public string PageUp;
}
internal class Images {
[JsonProperty("Ссылка на картинку для отображения статуса онлайна (16х16)")]
public string Online;
[JsonProperty("Ссылка на картинку для кнопки ЗАКРЫТЬ (32х32)")]
public string CloseButton;
[JsonProperty("Ссылка на картинку в заглавлении списка друзей (32х32)")]
public string FriendList;
[JsonProperty("Ссылка на картинку в заглавлении истории смертей (32х32)")]
public string KillHistory;
[JsonProperty("PNG на картинку в заглавлении статистики за сессию (32x32)")]
public string Statistics;
[JsonProperty("PNG на картинку в заглавлении статистики за сессию для активной кнопки возврата к своей статистике (32x32)")]
public string StatisticsReturnMe;
[JsonProperty("PNG на картинку в заглавлении календаря вайпов (32x32)")]
public string CalendarWipe;
[JsonProperty("PNG на картинку в фильтре постов для развертывания списка фильтров (32x32)")]
public string FilterOpen;
[JsonProperty("PNG на картинку в фильтре постов для скрытия списка фильтров (32x32)")]
public string FilterClose;
[JsonProperty("PNG на картинку в фильтре постов для установки фильтра (32x32)")]
public string FilterSet;
[JsonProperty("PNG на картинку в сортировке постов по времени")]
public string SorterTimePost;
[JsonProperty("PNG на картинку в статистике постов для количества просмотров (32x32)")]
public string PostStatisticsViews;
[JsonProperty("PNG на картинку в статистике постов для количества лайков (32x32)")]
public string PostStatisticsLikes;
[JsonProperty("PNG на страницы в статье постов (64x64)")]
public string PageDown;
[JsonProperty("PNG на страницы вверх в статье постов (64x64)")]
public string PageUp;
}
}
}
internal class ColorSettings {
[JsonProperty("HEX : Задней панели")]
public string HexBackgroundPanel;
[JsonProperty("HEX : Панели с титлом")]
public string HexTitlePanel;
[JsonProperty("HEX : Текста")]
public string HexLabels;
[JsonProperty("HEX : Кнопок")]
public string HexButtons;
[JsonProperty("HEX : Панели блюра для увеличения QR")]
public string HexBlurPanelQR;
[JsonProperty("HEX : Второстепенных панелей")]
public string HexButtonsMorePanel;
[JsonProperty("HEX : Кнопок с действиями(Активных кнопок)")]
public string HexButtonActive;
[JsonProperty("HEX : Цвет показтеля онлайн если игрок в сети")]
public string HexOnlineTrue;
[JsonProperty("HEX : Цвет показтеля онлайн если игрок не в сети")]
public string HexOnlineFalse;
[JsonProperty("Настройка цветов панели с постами")]
public PostPanel PostsPanel;
[JsonProperty("Настройка панели с блоками")]
public BlocksPanel BlockPanel;
[JsonProperty("Настройка титулов для постов")]
public TitulSettings Tituls;
internal class PostPanel {
[JsonProperty("HEX : Кнопки активной страницы")]
public string HexButtonsPageActive;
[JsonProperty("HEX : Кнопки неактивной страницы")]
public string HexButtonsPageInActive;
[JsonProperty("HEX : Активного лайка на пост")]
public string HexLikedPostActive;
[JsonProperty("HEX : Активной сортировке постов по времени")]
public string HexActiveSorter;
[JsonProperty("HEX : Не активной сортировке постов по времени")]
public string HexInActiveSorter;
}
internal class BlocksPanel {
[JsonProperty("HEX : Заднего фона панели в блоках")]
public string HexBlockBackground;
[JsonProperty("HEX : Заднего фона панелей с контентом в блоках")]
public string HexBlockPanel;
}
internal class TitulSettings {
[JsonProperty("HEX : Титула НОВОЕ")]
public string HexTitulNew;
[JsonProperty("HEX : Титула ПОПУЛЯРНОЕ")]
public string HexTitulPopular;
[JsonProperty("HEX : Титула ВАЖНОЕ")]
public string HexTitulImportant;
}
}
}
public static Configuration GetNewConfiguration() {
return new Configuration {
BlockSetting = new BlockSettings {
DayWiped = 7, BlockUP = new BlockSettings.BlockUPSettings {
LinkAdsSocial = "https://vk.com/mercurydev", QRListPNG = new List<string> {
"https://i.imgur.com/qDpUEZc.png", "https://i.imgur.com/H8laBgJ.png", "https://i.imgur.com/47Gb3f4.png",
}
}
}
, PostSetting = new PostSettings {
VKSettings = new PostSettings.VKParse {
ParseTimer = 3600, UseAlertPost = true, StaticBacgkroundPage = "https://i.imgur.com/3dhQ0Kg.jpg", TagList = new List<string> {
"#news", "#sales", "#top",
}
, TokenVK = "https://vkhost.github.io/ ТУТ ВЫ СМОЖЕТЕ ВЗЯТЬ СВОЙ ТОКЕН ПО КНОПОЧКЕ VK API", VKGroupID = "https://regvk.com/id/ ТУТ ВЫ СМОЖЕТЕ ВЗЯТЬ ID ГРУППЫ, ВСТАВЛЯЕТЕ В ПОЛЕ ВАШУ ССЫЛКУ НА ГРУППУ ВК И ЖМЕТЕ ОПРЕДЕЛИТЬ ID И СЮДА ВВОДИТЕ ЦИФРЫ (ПОСЛЕ ID публичной страницы: ЭТИ ЦИФРЫ ВАШ ID)"
}
, UseParse = true, NewDaysPost = 2, AutoDeletePost = true, AutoDeletePostTime = 1,
}
, ReferenceSetting = new ReferenceSettings {
IQChatSetting = new ReferenceSettings.IQChatSettings {
CustomPrefix = "", CustomAvatar = "", UIAlertUse = false,
}
,
}
, InterfaceSetting = new InterfaceSettings {
ImagesSetting = new InterfaceSettings.Images {
BlockImages = new InterfaceSettings.Images.BlockImage {
SpritesBlock = new InterfaceSettings.Images.BlockImage.Sprites {
CalendarWipe = "assets/icons/stopwatch.png", Online = "assets/icons/circle_closed.png", CloseButton = "assets/icons/power.png", FilterClose = "assets/icons/vote_down.png", FilterOpen = "assets/icons/download.png", FilterSet = "assets/icons/vote_up.png", FriendList = "assets/icons/friends_servers.png", KillHistory = "assets/icons/bullet.png", PostStatisticsLikes = "", PostStatisticsViews = "", Statistics = "assets/icons/lightbulb.png", StatisticsReturnMe = "assets/icons/enter.png", PageDown = "", PageUp = "", SorterTimePost = "assets/icons/stopwatch.png",
}
, ImageBlock = new InterfaceSettings.Images.BlockImage.Images {
CalendarWipe = "https://i.imgur.com/dnNEMW8.png", Online = "https://i.imgur.com/ALoEjDs.png", CloseButton = "https://i.imgur.com/vU4yQ2o.png", FilterClose = "https://i.imgur.com/vU4yQ2o.png", FilterOpen = "https://i.imgur.com/mSDkHqv.png", FilterSet = "https://i.imgur.com/w3MwHLh.png", FriendList = "https://i.imgur.com/csfGhC8.png", KillHistory = "https://i.imgur.com/yu8FtKi.png", PostStatisticsLikes = "https://i.imgur.com/OsShbqo.png", PostStatisticsViews = "https://i.imgur.com/Mc84XOL.png", Statistics = "https://i.imgur.com/QwL00Hm.png", StatisticsReturnMe = "https://i.imgur.com/wjE2wmH.png", PageDown = "https://i.imgur.com/Xm7bJcP.png", PageUp = "https://i.imgur.com/txmqgZd.png", SorterTimePost = "https://i.imgur.com/Phqc0Ki.png"
}
}
}
, ColorSetting = new InterfaceSettings.ColorSettings {
HexBackgroundPanel = "#3c3a2e", HexTitlePanel = "#1c211b", HexLabels = "#efedee", HexButtons = "#252a24", HexButtonsMorePanel = "#171E16FF", HexButtonActive = "#cc4228", HexBlurPanelQR = "#1B211BC4", HexOnlineTrue = "#A7F64FFF", HexOnlineFalse = "#F65050FF", BlockPanel = new InterfaceSettings.ColorSettings.BlocksPanel {
HexBlockBackground = "#252a24", HexBlockPanel = "#171E16FF",
}
, PostsPanel = new InterfaceSettings.ColorSettings.PostPanel {
HexButtonsPageActive = "#171E16FF", HexButtonsPageInActive = "#171E16CC", HexLikedPostActive = "#ff3347", HexActiveSorter = "#efedee", HexInActiveSorter = "#EFEDEEB0",
}
, Tituls = new InterfaceSettings.ColorSettings.TitulSettings {
HexTitulNew = "#689628", HexTitulImportant = "#cd4632", HexTitulPopular = "#3bb8c6",
}
}
}
}
;
}
}
protected override void LoadConfig() {
base.LoadConfig();
try {
config = Config.ReadObject<Configuration>();
if (config == null) LoadDefaultConfig();
}
catch {
PrintWarning($"Ошибка чтения #57 конфигурации 'oxide/config/{Name}', создаём новую конфигурацию!!");
LoadDefaultConfig();
}
NextTick(SaveConfig);
}
protected override void LoadDefaultConfig() => config = Configuration.GetNewConfiguration();
protected override void SaveConfig() => Config.WriteObject(config);
#endregion
#region Interface
private float FadeOut = 0.3f;
private float FadeIn = 0.3f;
#region DestroyController
private void DestroyResize(BasePlayer player) {
CuiHelper.DestroyUi(player, "RESIZE_SHOW_ICO");
CuiHelper.DestroyUi(player, "RESIZE_SHOW_BTN_CLOSE");
CuiHelper.DestroyUi(player, "RESIZE_SHOW");
}
private void DestroyPostPage(BasePlayer player) {
CuiHelper.DestroyUi(player, "BUTTON_UP_PAGE");
CuiHelper.DestroyUi(player, "PANEL_CONTENT_PAGE_UP_ICO");
CuiHelper.DestroyUi(player, "BUTTON_DOWN_PAGE");
CuiHelper.DestroyUi(player, "PANEL_CONTENT_PAGE_DOWN_ICO");
CuiHelper.DestroyUi(player, "PANEL_CONTENT_LINE_THREE_PAGE");
CuiHelper.DestroyUi(player, "PANEL_CONTENT_LINE_TWO_PAGE");
CuiHelper.DestroyUi(player, "PANEL_CONTENT_TAG_INFO");
CuiHelper.DestroyUi(player, "PANEL_CONTENT_LINE_THREE");
CuiHelper.DestroyUi(player, "PANEL_CONTENT_LINE_TWO");
CuiHelper.DestroyUi(player, "PANEL_CONTENT_LINE");
CuiHelper.DestroyUi(player, "PANEL_CONTENT_TEXT_OUTPUT");
CuiHelper.DestroyUi(player, "PANEL_CONTENT_PANEL_BLUR");
CuiHelper.DestroyUi(player, "PANEL_CONTENT");
CuiHelper.DestroyUi(player, "POST_PAGE_BACKGROUND_DISPLAY_NAME");
CuiHelper.DestroyUi(player, "POST_PAGE_BACKGROUND_VIEWS_COUNT");
CuiHelper.DestroyUi(player, "POST_PAGE_BACKGROUND_LIKES_COUNT");
CuiHelper.DestroyUi(player, "POST_PAGE_BACKGROUND_VIEWS_BUTTON");
CuiHelper.DestroyUi(player, "POST_PAGE_BACKGROUND_LIKES_BUTTON");
CuiHelper.DestroyUi(player, "POST_PAGE_BACKGROUND_BUTTON_ELEMENT");
CuiHelper.DestroyUi(player, "POST_PAGE_BACKGROUND_BUTTON");
// ... [Code preview truncated due to length. Full source in attached file] ...