refactoring
This commit is contained in:
parent
ce5e9e1593
commit
87823a1578
|
|
@ -1,69 +0,0 @@
|
||||||
#region Usings
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Xml;
|
|
||||||
using System.Xml.Serialization;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Content Provider Options
|
|
||||||
public class Provider
|
|
||||||
{
|
|
||||||
public string Name;
|
|
||||||
public string URL;
|
|
||||||
public string Icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
[XmlRoot("ContentProviders")]
|
|
||||||
public class ContentProviders
|
|
||||||
{
|
|
||||||
[XmlArray("Providers")]
|
|
||||||
public Provider[] Providers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class OnlineClothing
|
|
||||||
{
|
|
||||||
public static Provider[] GetContentProviders()
|
|
||||||
{
|
|
||||||
if (File.Exists(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ContentProviderXMLName))
|
|
||||||
{
|
|
||||||
XmlSerializer serializer = new XmlSerializer(typeof(ContentProviders));
|
|
||||||
ContentProviders providers;
|
|
||||||
|
|
||||||
using (FileStream fs = new FileStream(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ContentProviderXMLName, FileMode.Open))
|
|
||||||
{
|
|
||||||
providers = (ContentProviders)serializer.Deserialize(fs);
|
|
||||||
}
|
|
||||||
|
|
||||||
return providers.Providers;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Provider FindContentProviderByName(Provider[] providers, string query)
|
|
||||||
{
|
|
||||||
if (File.Exists(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ContentProviderXMLName))
|
|
||||||
{
|
|
||||||
return providers.SingleOrDefault(item => query.Contains(item.Name));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Provider FindContentProviderByURL(Provider[] providers, string query)
|
|
||||||
{
|
|
||||||
if (File.Exists(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ContentProviderXMLName))
|
|
||||||
{
|
|
||||||
return providers.SingleOrDefault(item => query.Contains(item.URL));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
#region Usings
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Icon Loader
|
|
||||||
|
|
||||||
public class IconLoader
|
|
||||||
{
|
|
||||||
private OpenFileDialog openFileDialog1;
|
|
||||||
private string installOutcome = "";
|
|
||||||
public bool CopyToItemDir = false;
|
|
||||||
public string ItemDir = "";
|
|
||||||
public string ItemName = "";
|
|
||||||
public string ItemPath = "";
|
|
||||||
|
|
||||||
public IconLoader()
|
|
||||||
{
|
|
||||||
openFileDialog1 = new OpenFileDialog()
|
|
||||||
{
|
|
||||||
FileName = "Select an icon .png file",
|
|
||||||
Filter = "Portable Network Graphics image (*.png)|*.png",
|
|
||||||
Title = "Open icon .png"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInstallOutcome(string text)
|
|
||||||
{
|
|
||||||
installOutcome = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string getInstallOutcome()
|
|
||||||
{
|
|
||||||
return installOutcome;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadImage()
|
|
||||||
{
|
|
||||||
string ItemNameFixed = ItemName.Replace(" ", "");
|
|
||||||
string dir = CopyToItemDir ? ItemDir + "\\" + ItemNameFixed : GlobalPaths.extradir + "\\icons\\" + GlobalVars.UserConfiguration.PlayerName;
|
|
||||||
|
|
||||||
if (openFileDialog1.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
GlobalFuncs.FixedFileCopy(openFileDialog1.FileName, dir + ".png", true);
|
|
||||||
|
|
||||||
if (CopyToItemDir)
|
|
||||||
{
|
|
||||||
ItemPath = ItemDir + "\\" + ItemNameFixed + ".png";
|
|
||||||
}
|
|
||||||
|
|
||||||
installOutcome = "Icon " + openFileDialog1.SafeFileName + " installed!";
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
installOutcome = "Error when installing icon: " + ex.Message;
|
|
||||||
#if URI || LAUNCHER || CMD
|
|
||||||
GlobalFuncs.LogExceptions(ex);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
@ -1,199 +0,0 @@
|
||||||
#region File Formats
|
|
||||||
|
|
||||||
using System.Diagnostics;
|
|
||||||
|
|
||||||
public class FileFormat
|
|
||||||
{
|
|
||||||
#region Client Information
|
|
||||||
public class ClientInfo
|
|
||||||
{
|
|
||||||
public ClientInfo()
|
|
||||||
{
|
|
||||||
UsesPlayerName = true;
|
|
||||||
UsesID = true;
|
|
||||||
Description = "";
|
|
||||||
Warning = "";
|
|
||||||
LegacyMode = false;
|
|
||||||
ClientMD5 = "";
|
|
||||||
ScriptMD5 = "";
|
|
||||||
Fix2007 = false;
|
|
||||||
AlreadyHasSecurity = false;
|
|
||||||
ClientLoadOptions = Settings.ClientLoadOptions.Client_2008AndUp;
|
|
||||||
SeperateFolders = false;
|
|
||||||
UsesCustomClientEXEName = false;
|
|
||||||
CustomClientEXEName = "";
|
|
||||||
CommandLineArgs = "%args%";
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool UsesPlayerName { get; set; }
|
|
||||||
public bool UsesID { get; set; }
|
|
||||||
public string Description { get; set; }
|
|
||||||
public string Warning { get; set; }
|
|
||||||
public bool LegacyMode { get; set; }
|
|
||||||
public string ClientMD5 { get; set; }
|
|
||||||
public string ScriptMD5 { get; set; }
|
|
||||||
public bool Fix2007 { get; set; }
|
|
||||||
public bool AlreadyHasSecurity { get; set; }
|
|
||||||
public bool SeperateFolders { get; set; }
|
|
||||||
public bool UsesCustomClientEXEName { get; set; }
|
|
||||||
public string CustomClientEXEName { get; set; }
|
|
||||||
public Settings.ClientLoadOptions ClientLoadOptions { get; set; }
|
|
||||||
public string CommandLineArgs { get; set; }
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Configuration
|
|
||||||
public class Config
|
|
||||||
{
|
|
||||||
public Config()
|
|
||||||
{
|
|
||||||
SelectedClient = "";
|
|
||||||
Map = "";
|
|
||||||
CloseOnLaunch = false;
|
|
||||||
UserID = 0;
|
|
||||||
PlayerName = "Player";
|
|
||||||
RobloxPort = 53640;
|
|
||||||
PlayerLimit = 12;
|
|
||||||
UPnP = false;
|
|
||||||
DisabledAssetSDKHelp = false;
|
|
||||||
DiscordPresence = true;
|
|
||||||
MapPath = "";
|
|
||||||
MapPathSnip = "";
|
|
||||||
GraphicsMode = Settings.Mode.Automatic;
|
|
||||||
ReShade = false;
|
|
||||||
QualityLevel = Settings.Level.Automatic;
|
|
||||||
LauncherStyle = Settings.Style.Stylish;
|
|
||||||
ReShadeFPSDisplay = false;
|
|
||||||
ReShadePerformanceMode = false;
|
|
||||||
AssetSDKFixerSaveBackups = true;
|
|
||||||
AlternateServerIP = "";
|
|
||||||
DisableReshadeDelete = false;
|
|
||||||
ShowServerNotifications = false;
|
|
||||||
ServerBrowserServerName = "Novetus";
|
|
||||||
ServerBrowserServerAddress = "localhost";
|
|
||||||
Priority = ProcessPriorityClass.RealTime;
|
|
||||||
FirstServerLaunch = true;
|
|
||||||
NewGUI = false;
|
|
||||||
URIQuickConfigure = true;
|
|
||||||
BootstrapperShowUI = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string SelectedClient { get; set; }
|
|
||||||
public string Map { get; set; }
|
|
||||||
public bool CloseOnLaunch { get; set; }
|
|
||||||
public int UserID { get; set; }
|
|
||||||
public string PlayerName { get; set; }
|
|
||||||
public int RobloxPort { get; set; }
|
|
||||||
public int PlayerLimit { get; set; }
|
|
||||||
public bool UPnP { get; set; }
|
|
||||||
public bool DisabledAssetSDKHelp { get; set; }
|
|
||||||
public bool DiscordPresence { get; set; }
|
|
||||||
public string MapPath { get; set; }
|
|
||||||
public string MapPathSnip { get; set; }
|
|
||||||
public Settings.Mode GraphicsMode { get; set; }
|
|
||||||
public bool ReShade { get; set; }
|
|
||||||
public Settings.Level QualityLevel { get; set; }
|
|
||||||
public Settings.Style LauncherStyle { get; set; }
|
|
||||||
public bool ReShadeFPSDisplay { get; set; }
|
|
||||||
public bool ReShadePerformanceMode { get; set; }
|
|
||||||
public bool AssetSDKFixerSaveBackups { get; set; }
|
|
||||||
public string AlternateServerIP { get; set; }
|
|
||||||
public bool DisableReshadeDelete { get; set; }
|
|
||||||
public bool ShowServerNotifications { get; set; }
|
|
||||||
public string ServerBrowserServerName { get; set; }
|
|
||||||
public string ServerBrowserServerAddress { get; set; }
|
|
||||||
public ProcessPriorityClass Priority { get; set; }
|
|
||||||
public bool FirstServerLaunch { get; set; }
|
|
||||||
public bool NewGUI { get; set; }
|
|
||||||
public bool URIQuickConfigure { get; set; }
|
|
||||||
public bool BootstrapperShowUI { get; set; }
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Customization Configuration
|
|
||||||
public class CustomizationConfig
|
|
||||||
{
|
|
||||||
public CustomizationConfig()
|
|
||||||
{
|
|
||||||
Hat1 = "NoHat.rbxm";
|
|
||||||
Hat2 = "NoHat.rbxm";
|
|
||||||
Hat3 = "NoHat.rbxm";
|
|
||||||
Face = "DefaultFace.rbxm";
|
|
||||||
Head = "DefaultHead.rbxm";
|
|
||||||
TShirt = "NoTShirt.rbxm";
|
|
||||||
Shirt = "NoShirt.rbxm";
|
|
||||||
Pants = "NoPants.rbxm";
|
|
||||||
Icon = "NBC";
|
|
||||||
Extra = "NoExtra.rbxm";
|
|
||||||
HeadColorID = 24;
|
|
||||||
TorsoColorID = 23;
|
|
||||||
LeftArmColorID = 24;
|
|
||||||
RightArmColorID = 24;
|
|
||||||
LeftLegColorID = 119;
|
|
||||||
RightLegColorID = 119;
|
|
||||||
HeadColorString = "Color [A=255, R=245, G=205, B=47]";
|
|
||||||
TorsoColorString = "Color [A=255, R=13, G=105, B=172]";
|
|
||||||
LeftArmColorString = "Color [A=255, R=245, G=205, B=47]";
|
|
||||||
RightArmColorString = "Color [A=255, R=245, G=205, B=47]";
|
|
||||||
LeftLegColorString = "Color [A=255, R=164, G=189, B=71]";
|
|
||||||
RightLegColorString = "Color [A=255, R=164, G=189, B=71]";
|
|
||||||
ExtraSelectionIsHat = false;
|
|
||||||
ShowHatsInExtra = false;
|
|
||||||
CharacterID = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Hat1 { get; set; }
|
|
||||||
public string Hat2 { get; set; }
|
|
||||||
public string Hat3 { get; set; }
|
|
||||||
public string Face { get; set; }
|
|
||||||
public string Head { get; set; }
|
|
||||||
public string TShirt { get; set; }
|
|
||||||
public string Shirt { get; set; }
|
|
||||||
public string Pants { get; set; }
|
|
||||||
public string Icon { get; set; }
|
|
||||||
public string Extra { get; set; }
|
|
||||||
public int HeadColorID { get; set; }
|
|
||||||
public int TorsoColorID { get; set; }
|
|
||||||
public int LeftArmColorID { get; set; }
|
|
||||||
public int RightArmColorID { get; set; }
|
|
||||||
public int LeftLegColorID { get; set; }
|
|
||||||
public int RightLegColorID { get; set; }
|
|
||||||
public string HeadColorString { get; set; }
|
|
||||||
public string TorsoColorString { get; set; }
|
|
||||||
public string LeftArmColorString { get; set; }
|
|
||||||
public string RightArmColorString { get; set; }
|
|
||||||
public string LeftLegColorString { get; set; }
|
|
||||||
public string RightLegColorString { get; set; }
|
|
||||||
public bool ExtraSelectionIsHat { get; set; }
|
|
||||||
public bool ShowHatsInExtra { get; set; }
|
|
||||||
public string CharacterID { get; set; }
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Program Information
|
|
||||||
public class ProgramInfo
|
|
||||||
{
|
|
||||||
public ProgramInfo()
|
|
||||||
{
|
|
||||||
Version = "";
|
|
||||||
Branch = "";
|
|
||||||
DefaultClient = "";
|
|
||||||
RegisterClient1 = "";
|
|
||||||
RegisterClient2 = "";
|
|
||||||
DefaultMap = "";
|
|
||||||
IsLite = false;
|
|
||||||
InitialBootup = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Version { get; set; }
|
|
||||||
public string Branch { get; set; }
|
|
||||||
public string DefaultClient { get; set; }
|
|
||||||
public string RegisterClient1 { get; set; }
|
|
||||||
public string RegisterClient2 { get; set; }
|
|
||||||
public string DefaultMap { get; set; }
|
|
||||||
public bool IsLite { get; set; }
|
|
||||||
public bool InitialBootup { get; set; }
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
@ -1,185 +0,0 @@
|
||||||
#region Usings
|
|
||||||
using System;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Drawing.Imaging;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Xml.Serialization;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Part Color Options
|
|
||||||
public class PartColor
|
|
||||||
{
|
|
||||||
public string ColorName;
|
|
||||||
public int ColorID;
|
|
||||||
public string ColorRGB;
|
|
||||||
[XmlIgnore]
|
|
||||||
public Color ColorObject;
|
|
||||||
[XmlIgnore]
|
|
||||||
public string ColorGroup;
|
|
||||||
[XmlIgnore]
|
|
||||||
public string ColorRawName;
|
|
||||||
[XmlIgnore]
|
|
||||||
public Bitmap ColorImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
[XmlRoot("PartColors")]
|
|
||||||
public class PartColors
|
|
||||||
{
|
|
||||||
[XmlArray("ColorList")]
|
|
||||||
public PartColor[] ColorList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class PartColorLoader
|
|
||||||
{
|
|
||||||
public static PartColor[] GetPartColors()
|
|
||||||
{
|
|
||||||
if (File.Exists(GlobalPaths.ConfigDir + "\\" + GlobalPaths.PartColorXMLName))
|
|
||||||
{
|
|
||||||
XmlSerializer serializer = new XmlSerializer(typeof(PartColors));
|
|
||||||
PartColors colors;
|
|
||||||
|
|
||||||
using (FileStream fs = new FileStream(GlobalPaths.ConfigDir + "\\" + GlobalPaths.PartColorXMLName, FileMode.Open))
|
|
||||||
{
|
|
||||||
colors = (PartColors)serializer.Deserialize(fs);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var item in colors.ColorList)
|
|
||||||
{
|
|
||||||
string colorFixed = Regex.Replace(item.ColorRGB, @"[\[\]\{\}\(\)\<\> ]", "");
|
|
||||||
string[] rgbValues = colorFixed.Split(',');
|
|
||||||
item.ColorObject = Color.FromArgb(Convert.ToInt32(rgbValues[0]), Convert.ToInt32(rgbValues[1]), Convert.ToInt32(rgbValues[2]));
|
|
||||||
|
|
||||||
if (!(item.ColorName.Contains("[") && item.ColorName.Contains("]")))
|
|
||||||
{
|
|
||||||
item.ColorRawName = item.ColorName;
|
|
||||||
item.ColorName = "[Uncategorized]" + item.ColorName;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
item.ColorRawName = item.ColorName;
|
|
||||||
}
|
|
||||||
|
|
||||||
int pFrom = item.ColorName.IndexOf("[");
|
|
||||||
int pTo = item.ColorName.IndexOf("]");
|
|
||||||
item.ColorGroup = item.ColorName.Substring(pFrom + 1, pTo - pFrom - 1);
|
|
||||||
item.ColorName = item.ColorName.Replace(item.ColorGroup, "").Replace("[", "").Replace("]", "");
|
|
||||||
item.ColorImage = GeneratePartColorIcon(item, 128);
|
|
||||||
}
|
|
||||||
|
|
||||||
return colors.ColorList;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//make faster
|
|
||||||
public static void AddPartColorsToListView(PartColor[] PartColorList, ListView ColorView, int imgsize, bool showIDs = false)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ImageList ColorImageList = new ImageList();
|
|
||||||
ColorImageList.ImageSize = new Size(imgsize, imgsize);
|
|
||||||
ColorImageList.ColorDepth = ColorDepth.Depth32Bit;
|
|
||||||
ColorView.LargeImageList = ColorImageList;
|
|
||||||
ColorView.SmallImageList = ColorImageList;
|
|
||||||
|
|
||||||
foreach (var item in PartColorList)
|
|
||||||
{
|
|
||||||
var lvi = new ListViewItem(item.ColorName);
|
|
||||||
lvi.Tag = item.ColorID;
|
|
||||||
|
|
||||||
if (showIDs)
|
|
||||||
{
|
|
||||||
lvi.Text = lvi.Text + " (" + item.ColorID + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
var group = ColorView.Groups.Cast<ListViewGroup>().FirstOrDefault(g => g.Header == item.ColorGroup);
|
|
||||||
|
|
||||||
if (group == null)
|
|
||||||
{
|
|
||||||
group = new ListViewGroup(item.ColorGroup);
|
|
||||||
ColorView.Groups.Add(group);
|
|
||||||
}
|
|
||||||
|
|
||||||
lvi.Group = group;
|
|
||||||
|
|
||||||
if (item.ColorImage != null)
|
|
||||||
{
|
|
||||||
ColorImageList.Images.Add(item.ColorName, item.ColorImage);
|
|
||||||
lvi.ImageIndex = ColorImageList.Images.IndexOfKey(item.ColorName);
|
|
||||||
}
|
|
||||||
|
|
||||||
ColorView.Items.Add(lvi);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*foreach (var group in ColorView.Groups.Cast<ListViewGroup>())
|
|
||||||
{
|
|
||||||
group.Header = group.Header + " (" + group.Items.Count + ")";
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
#if URI || LAUNCHER || CMD || BASICLAUNCHER
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.LogExceptions(ex);
|
|
||||||
#else
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Bitmap GeneratePartColorIcon(PartColor color, int imgsize)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Bitmap Bmp = new Bitmap(imgsize, imgsize, PixelFormat.Format32bppArgb);
|
|
||||||
using (Graphics gfx = Graphics.FromImage(Bmp))
|
|
||||||
using (SolidBrush brush = new SolidBrush(color.ColorObject))
|
|
||||||
{
|
|
||||||
gfx.FillRectangle(brush, 0, 0, imgsize, imgsize);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Bmp;
|
|
||||||
}
|
|
||||||
#if URI || LAUNCHER || CMD || BASICLAUNCHER
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.LogExceptions(ex);
|
|
||||||
#else
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PartColor FindPartColorByName(PartColor[] colors, string query)
|
|
||||||
{
|
|
||||||
if (File.Exists(GlobalPaths.ConfigDir + "\\" + GlobalPaths.PartColorXMLName))
|
|
||||||
{
|
|
||||||
return colors.SingleOrDefault(item => query.Contains(item.ColorName));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PartColor FindPartColorByID(PartColor[] colors, string query)
|
|
||||||
{
|
|
||||||
if (File.Exists(GlobalPaths.ConfigDir + "\\" + GlobalPaths.PartColorXMLName))
|
|
||||||
{
|
|
||||||
return colors.SingleOrDefault(item => query.Contains(item.ColorID.ToString()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
@ -1,332 +0,0 @@
|
||||||
#region Vector3
|
|
||||||
public class Vector3
|
|
||||||
{
|
|
||||||
public double X;
|
|
||||||
public double Y;
|
|
||||||
public double Z;
|
|
||||||
|
|
||||||
public Vector3(double aX, double aY, double aZ)
|
|
||||||
{
|
|
||||||
X = aX;
|
|
||||||
Y = aY;
|
|
||||||
Z = aZ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Roblox File Types
|
|
||||||
public enum RobloxFileType
|
|
||||||
{
|
|
||||||
//RBXL and RBXM
|
|
||||||
RBXL,
|
|
||||||
RBXM,
|
|
||||||
//Items
|
|
||||||
Hat,
|
|
||||||
Head,
|
|
||||||
Face,
|
|
||||||
TShirt,
|
|
||||||
Shirt,
|
|
||||||
Pants,
|
|
||||||
Script,
|
|
||||||
HeadNoCustomMesh
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Asset Cache Definition
|
|
||||||
public class AssetCacheDefBasic
|
|
||||||
{
|
|
||||||
public AssetCacheDefBasic(string clas, string[] id)
|
|
||||||
{
|
|
||||||
Class = clas;
|
|
||||||
Id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Class { get; set; }
|
|
||||||
public string[] Id { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class AssetCacheDef : AssetCacheDefBasic
|
|
||||||
{
|
|
||||||
public AssetCacheDef(string clas, string[] id, string[] ext,
|
|
||||||
string[] dir, string[] gamedir) : base(clas, id)
|
|
||||||
{
|
|
||||||
Ext = ext;
|
|
||||||
Dir = dir;
|
|
||||||
GameDir = gamedir;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string[] Ext { get; set; }
|
|
||||||
public string[] Dir { get; set; }
|
|
||||||
public string[] GameDir { get; set; }
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Roblox Type Definitions
|
|
||||||
public struct RobloxDefs
|
|
||||||
{
|
|
||||||
public static AssetCacheDef Fonts
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("SpecialMesh",
|
|
||||||
new string[] { "MeshId", "TextureId" },
|
|
||||||
new string[] { ".mesh", ".png" },
|
|
||||||
new string[] { GlobalPaths.AssetCacheDirFonts, GlobalPaths.AssetCacheDirTextures },
|
|
||||||
new string[] { GlobalPaths.AssetCacheFontsGameDir, GlobalPaths.AssetCacheTexturesGameDir });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef Sky
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("Sky",
|
|
||||||
new string[] { "SkyboxBk", "SkyboxDn", "SkyboxFt", "SkyboxLf", "SkyboxRt", "SkyboxUp" },
|
|
||||||
new string[] { ".png" },
|
|
||||||
new string[] { GlobalPaths.AssetCacheDirSky },
|
|
||||||
new string[] { GlobalPaths.AssetCacheSkyGameDir });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef Decal
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("Decal",
|
|
||||||
new string[] { "Texture" },
|
|
||||||
new string[] { ".png" },
|
|
||||||
new string[] { GlobalPaths.AssetCacheDirTextures },
|
|
||||||
new string[] { GlobalPaths.AssetCacheTexturesGameDir });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef Texture
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("Texture",
|
|
||||||
new string[] { "Texture" },
|
|
||||||
new string[] { ".png" },
|
|
||||||
new string[] { GlobalPaths.AssetCacheDirTextures },
|
|
||||||
new string[] { GlobalPaths.AssetCacheTexturesGameDir });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef HopperBin
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("HopperBin",
|
|
||||||
new string[] { "TextureId" },
|
|
||||||
new string[] { ".png" },
|
|
||||||
new string[] { GlobalPaths.AssetCacheDirTextures },
|
|
||||||
new string[] { GlobalPaths.AssetCacheTexturesGameDir });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef Tool
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("Tool",
|
|
||||||
new string[] { "TextureId" },
|
|
||||||
new string[] { ".png" },
|
|
||||||
new string[] { GlobalPaths.AssetCacheDirTextures },
|
|
||||||
new string[] { GlobalPaths.AssetCacheTexturesGameDir });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef Sound
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("Sound",
|
|
||||||
new string[] { "SoundId" },
|
|
||||||
new string[] { ".wav" },
|
|
||||||
new string[] { GlobalPaths.AssetCacheDirSounds },
|
|
||||||
new string[] { GlobalPaths.AssetCacheSoundsGameDir });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef ImageLabel
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("ImageLabel",
|
|
||||||
new string[] { "Image" },
|
|
||||||
new string[] { ".png" },
|
|
||||||
new string[] { GlobalPaths.AssetCacheDirTextures },
|
|
||||||
new string[] { GlobalPaths.AssetCacheTexturesGameDir });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef Shirt
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("Shirt",
|
|
||||||
new string[] { "ShirtTemplate" },
|
|
||||||
new string[] { ".png" },
|
|
||||||
new string[] { GlobalPaths.AssetCacheDirTextures },
|
|
||||||
new string[] { GlobalPaths.AssetCacheTexturesGameDir });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef ShirtGraphic
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("ShirtGraphic",
|
|
||||||
new string[] { "Graphic" },
|
|
||||||
new string[] { ".png" },
|
|
||||||
new string[] { GlobalPaths.AssetCacheDirTextures },
|
|
||||||
new string[] { GlobalPaths.AssetCacheTexturesGameDir });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef Pants
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("Pants",
|
|
||||||
new string[] { "PantsTemplate" },
|
|
||||||
new string[] { ".png" },
|
|
||||||
new string[] { GlobalPaths.AssetCacheDirTextures },
|
|
||||||
new string[] { GlobalPaths.AssetCacheTexturesGameDir });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef Script
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("Script",
|
|
||||||
new string[] { "LinkedSource" },
|
|
||||||
new string[] { ".lua" },
|
|
||||||
new string[] { GlobalPaths.AssetCacheDirScripts },
|
|
||||||
new string[] { GlobalPaths.AssetCacheScriptsGameDir });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef LocalScript
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("LocalScript",
|
|
||||||
new string[] { "LinkedSource" },
|
|
||||||
new string[] { ".lua" },
|
|
||||||
new string[] { GlobalPaths.AssetCacheDirScripts },
|
|
||||||
new string[] { GlobalPaths.AssetCacheScriptsGameDir });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//item defs below
|
|
||||||
public static AssetCacheDef ItemHatFonts
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("SpecialMesh",
|
|
||||||
new string[] { "MeshId", "TextureId" },
|
|
||||||
new string[] { ".mesh", ".png" },
|
|
||||||
new string[] { GlobalPaths.hatdirFonts, GlobalPaths.hatdirTextures },
|
|
||||||
new string[] { GlobalPaths.hatGameDirFonts, GlobalPaths.hatGameDirTextures });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef ItemHatSound
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("Sound",
|
|
||||||
new string[] { "SoundId" },
|
|
||||||
new string[] { ".wav" },
|
|
||||||
new string[] { GlobalPaths.hatdirSounds },
|
|
||||||
new string[] { GlobalPaths.hatGameDirSounds });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef ItemHatScript
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("Script",
|
|
||||||
new string[] { "LinkedSource" },
|
|
||||||
new string[] { ".lua" },
|
|
||||||
new string[] { GlobalPaths.hatdirScripts },
|
|
||||||
new string[] { GlobalPaths.hatGameDirScripts });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef ItemHatLocalScript
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("LocalScript",
|
|
||||||
new string[] { "LinkedSource" },
|
|
||||||
new string[] { ".lua" },
|
|
||||||
new string[] { GlobalPaths.hatdirScripts },
|
|
||||||
new string[] { GlobalPaths.hatGameDirScripts });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef ItemHeadFonts
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("SpecialMesh",
|
|
||||||
new string[] { "MeshId", "TextureId" },
|
|
||||||
new string[] { ".mesh", ".png" },
|
|
||||||
new string[] { GlobalPaths.headdirFonts, GlobalPaths.headdirTextures },
|
|
||||||
new string[] { GlobalPaths.headGameDirFonts, GlobalPaths.headGameDirTextures });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef ItemFaceTexture
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("Decal",
|
|
||||||
new string[] { "Texture" },
|
|
||||||
new string[] { ".png" },
|
|
||||||
new string[] { GlobalPaths.facedirTextures },
|
|
||||||
new string[] { GlobalPaths.faceGameDirTextures });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef ItemShirtTexture
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("Shirt",
|
|
||||||
new string[] { "ShirtTemplate" },
|
|
||||||
new string[] { ".png" },
|
|
||||||
new string[] { GlobalPaths.shirtdirTextures },
|
|
||||||
new string[] { GlobalPaths.shirtGameDirTextures });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef ItemTShirtTexture
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("ShirtGraphic",
|
|
||||||
new string[] { "Graphic" },
|
|
||||||
new string[] { ".png" },
|
|
||||||
new string[] { GlobalPaths.tshirtdirTextures },
|
|
||||||
new string[] { GlobalPaths.tshirtGameDirTextures });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AssetCacheDef ItemPantsTexture
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new AssetCacheDef("Pants",
|
|
||||||
new string[] { "PantsTemplate" },
|
|
||||||
new string[] { ".png" },
|
|
||||||
new string[] { GlobalPaths.pantsdirTextures },
|
|
||||||
new string[] { GlobalPaths.pantsGameDirTextures });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
@ -1,217 +0,0 @@
|
||||||
#region Usings
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Xml;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region XML Types
|
|
||||||
public enum XMLTypes
|
|
||||||
{
|
|
||||||
Token,
|
|
||||||
Bool,
|
|
||||||
Float,
|
|
||||||
String,
|
|
||||||
Vector2Int16,
|
|
||||||
Int
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Roblox XML Parser
|
|
||||||
public static class RobloxXML
|
|
||||||
{
|
|
||||||
public static void EditRenderSettings(XDocument doc, string setting, string value, XMLTypes type)
|
|
||||||
{
|
|
||||||
var v = from nodes in doc.Descendants("Item")
|
|
||||||
where nodes.Attribute("class").Value == "RenderSettings"
|
|
||||||
select nodes;
|
|
||||||
|
|
||||||
foreach (var item in v)
|
|
||||||
{
|
|
||||||
var v2 = from nodes in item.Descendants((type != XMLTypes.Vector2Int16 ? type.ToString().ToLower() : "Vector2int16"))
|
|
||||||
where nodes.Attribute("name").Value == setting
|
|
||||||
select nodes;
|
|
||||||
|
|
||||||
foreach (var item2 in v2)
|
|
||||||
{
|
|
||||||
if (type != XMLTypes.Vector2Int16)
|
|
||||||
{
|
|
||||||
item2.Value = value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string[] vals = value.Split('x');
|
|
||||||
|
|
||||||
var v3 = from nodes in item2.Descendants("X")
|
|
||||||
select nodes;
|
|
||||||
|
|
||||||
foreach (var item3 in v3)
|
|
||||||
{
|
|
||||||
item3.Value = vals[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
var v4 = from nodes in item2.Descendants("Y")
|
|
||||||
select nodes;
|
|
||||||
|
|
||||||
foreach (var item4 in v4)
|
|
||||||
{
|
|
||||||
item4.Value = vals[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsRenderSettingStringValid(XDocument doc, string setting, XMLTypes type)
|
|
||||||
{
|
|
||||||
if (type != XMLTypes.String)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var v = from nodes in doc.Descendants("Item")
|
|
||||||
where nodes.Attribute("class").Value == "RenderSettings"
|
|
||||||
select nodes;
|
|
||||||
|
|
||||||
foreach (var item in v)
|
|
||||||
{
|
|
||||||
var v2 = from nodes in item.Descendants(type.ToString().ToLower())
|
|
||||||
where nodes.Attribute("name").Value == setting
|
|
||||||
select nodes;
|
|
||||||
|
|
||||||
foreach (var item2 in v2)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetRenderSettings(XDocument doc, string setting, XMLTypes type)
|
|
||||||
{
|
|
||||||
var v = from nodes in doc.Descendants("Item")
|
|
||||||
where nodes.Attribute("class").Value == "RenderSettings"
|
|
||||||
select nodes;
|
|
||||||
|
|
||||||
foreach (var item in v)
|
|
||||||
{
|
|
||||||
var v2 = from nodes in item.Descendants((type != XMLTypes.Vector2Int16 ? type.ToString().ToLower() : "Vector2int16"))
|
|
||||||
where nodes.Attribute("name").Value == setting
|
|
||||||
select nodes;
|
|
||||||
|
|
||||||
foreach (var item2 in v2)
|
|
||||||
{
|
|
||||||
if (type != XMLTypes.Vector2Int16)
|
|
||||||
{
|
|
||||||
return item2.Value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string ValX = "";
|
|
||||||
string ValY = "";
|
|
||||||
|
|
||||||
var v3 = from nodes in item2.Descendants("X")
|
|
||||||
select nodes;
|
|
||||||
|
|
||||||
foreach (var item3 in v3)
|
|
||||||
{
|
|
||||||
ValX = item3.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
var v4 = from nodes in item2.Descendants("Y")
|
|
||||||
select nodes;
|
|
||||||
|
|
||||||
foreach (var item4 in v4)
|
|
||||||
{
|
|
||||||
ValY = item4.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ValX + "x" + ValY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DownloadFilesFromNode(string url, string path, string fileext, string id)
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrWhiteSpace(id))
|
|
||||||
{
|
|
||||||
Downloader download = new Downloader(url, id);
|
|
||||||
download.InitDownload(path, fileext, "", true, false);
|
|
||||||
if (download.getDownloadOutcome().Contains("Error"))
|
|
||||||
{
|
|
||||||
throw new IOException(download.getDownloadOutcome());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetURLInNodes(XDocument doc, string itemClassValue, string itemIdValue, string url)
|
|
||||||
{
|
|
||||||
var v = from nodes in doc.Descendants("Item")
|
|
||||||
where nodes.Attribute("class").Value == itemClassValue
|
|
||||||
select nodes;
|
|
||||||
|
|
||||||
foreach (var item in v)
|
|
||||||
{
|
|
||||||
var v2 = from nodes in item.Descendants("Content")
|
|
||||||
where nodes.Attribute("name").Value == itemIdValue
|
|
||||||
select nodes;
|
|
||||||
|
|
||||||
foreach (var item2 in v2)
|
|
||||||
{
|
|
||||||
var v3 = from nodes in item2.Descendants("url")
|
|
||||||
select nodes;
|
|
||||||
|
|
||||||
foreach (var item3 in v3)
|
|
||||||
{
|
|
||||||
if (!item3.Value.Contains("rbxassetid"))
|
|
||||||
{
|
|
||||||
if (!item3.Value.Contains("rbxasset"))
|
|
||||||
{
|
|
||||||
string oldurl = item3.Value;
|
|
||||||
string urlFixed = GlobalFuncs.FixURLString(oldurl, url);
|
|
||||||
string peram = "id=";
|
|
||||||
|
|
||||||
if (urlFixed.Contains(peram))
|
|
||||||
{
|
|
||||||
return urlFixed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string oldurl = item3.Value;
|
|
||||||
string rbxassetid = "rbxassetid://";
|
|
||||||
string urlFixed = url + oldurl.After(rbxassetid);
|
|
||||||
string peram = "id=";
|
|
||||||
|
|
||||||
if (urlFixed.Contains(peram))
|
|
||||||
{
|
|
||||||
return urlFixed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string RemoveInvalidXmlChars(string content)
|
|
||||||
{
|
|
||||||
return new string(content.Where(ch => XmlConvert.IsXmlChar(ch)).ToArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string ReplaceHexadecimalSymbols(string txt)
|
|
||||||
{
|
|
||||||
string r = "[\x00-\x08\x0B\x0C\x0E-\x1F]";
|
|
||||||
return Regex.Replace(txt, r, "", RegexOptions.Compiled);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
||||||
#region Usings
|
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Settings
|
|
||||||
public class Settings
|
|
||||||
{
|
|
||||||
public enum Mode
|
|
||||||
{
|
|
||||||
Automatic = 0,
|
|
||||||
OpenGLStable = 1,
|
|
||||||
OpenGLExperimental = 2,
|
|
||||||
DirectX = 3
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Level
|
|
||||||
{
|
|
||||||
Automatic = 0,
|
|
||||||
VeryLow = 1,
|
|
||||||
Low = 2,
|
|
||||||
Medium = 3,
|
|
||||||
High = 4,
|
|
||||||
Ultra = 5,
|
|
||||||
Custom = 6
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Style
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
Extended = 1,
|
|
||||||
Compact = 2,
|
|
||||||
Stylish = 3
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ClientLoadOptions
|
|
||||||
{
|
|
||||||
Client_2007_NoGraphicsOptions = 0,
|
|
||||||
Client_2007 = 1,
|
|
||||||
Client_2008AndUp = 2,
|
|
||||||
Client_2008AndUp_LegacyOpenGL = 3,
|
|
||||||
Client_2008AndUp_QualityLevel21 = 4,
|
|
||||||
Client_2008AndUp_NoGraphicsOptions = 5,
|
|
||||||
Client_2008AndUp_ForceAutomatic = 6,
|
|
||||||
Client_2008AndUp_ForceAutomaticQL21 = 7,
|
|
||||||
Client_2008AndUp_HasCharacterOnlyShadowsLegacyOpenGL = 8
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ClientLoadOptions GetClientLoadOptionsForBool(bool level)
|
|
||||||
{
|
|
||||||
switch (level)
|
|
||||||
{
|
|
||||||
case false:
|
|
||||||
return ClientLoadOptions.Client_2008AndUp;
|
|
||||||
default:
|
|
||||||
return ClientLoadOptions.Client_2007_NoGraphicsOptions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetPathForClientLoadOptions(ClientLoadOptions level)
|
|
||||||
{
|
|
||||||
string localAppdataRobloxPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Roblox";
|
|
||||||
string appdataRobloxPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Roblox";
|
|
||||||
|
|
||||||
if (!Directory.Exists(localAppdataRobloxPath))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(localAppdataRobloxPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Directory.Exists(appdataRobloxPath))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(appdataRobloxPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (level)
|
|
||||||
{
|
|
||||||
case ClientLoadOptions.Client_2008AndUp_QualityLevel21:
|
|
||||||
case ClientLoadOptions.Client_2008AndUp_LegacyOpenGL:
|
|
||||||
case ClientLoadOptions.Client_2008AndUp_NoGraphicsOptions:
|
|
||||||
case ClientLoadOptions.Client_2008AndUp_ForceAutomatic:
|
|
||||||
case ClientLoadOptions.Client_2008AndUp_ForceAutomaticQL21:
|
|
||||||
case ClientLoadOptions.Client_2008AndUp_HasCharacterOnlyShadowsLegacyOpenGL:
|
|
||||||
case ClientLoadOptions.Client_2008AndUp:
|
|
||||||
return localAppdataRobloxPath;
|
|
||||||
default:
|
|
||||||
return appdataRobloxPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
@ -9,30 +9,20 @@
|
||||||
<Import_RootNamespace>NovetusCore</Import_RootNamespace>
|
<Import_RootNamespace>NovetusCore</Import_RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="$(MSBuildThisFileDirectory)StorageAndFunctions\ClientManagement.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Classes\Downloader.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Classes\Downloader.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Classes\PartColors.cs" />
|
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)CharCustom\ContentProviders.cs" />
|
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)CharCustom\IconLoader.cs" />
|
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Classes\CommandLineArguments.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Classes\CommandLineArguments.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Classes\CryptoRandom.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Classes\CryptoRandom.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Classes\FileFormat.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)StorageAndFunctions\FileManagement.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Classes\IDiscordRPC.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Classes\IDiscordRPC.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Classes\INIFile.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Classes\INIFile.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Classes\RobloxHelpers.cs" />
|
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Classes\RobloxXML.cs" />
|
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Classes\Settings.cs" />
|
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Classes\TextLineRemover.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Classes\TextLineRemover.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Imported\UHWIDEngine.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Classes\UHWIDEngine.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)StorageAndFunctions\GlobalFuncs.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)StorageAndFunctions\NovetusFuncs.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)StorageAndFunctions\GlobalPaths.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)StorageAndFunctions\GlobalPaths.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)StorageAndFunctions\GlobalVars.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)StorageAndFunctions\GlobalVars.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)StorageAndFunctions\NETExt.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)StorageAndFunctions\Util.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)StorageAndFunctions\NetFuncs.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)StorageAndFunctions\NetFuncs.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)StorageAndFunctions\ScriptFuncs.cs" />
|
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)StorageAndFunctions\SecurityFuncs.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)StorageAndFunctions\SecurityFuncs.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)WinForms\FormExt.cs" />
|
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)WinForms\CustomFormControls.cs">
|
|
||||||
<SubType>Component</SubType>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -1,213 +0,0 @@
|
||||||
#region Usings
|
|
||||||
using System;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
|
||||||
using System.IO;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Net;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region .NET Extentions
|
|
||||||
|
|
||||||
//This code was brought to you by:
|
|
||||||
//https://stackoverflow.com/questions/1926264/color-different-parts-of-a-richtextbox-string
|
|
||||||
//https://stackoverflow.com/questions/262280/how-can-i-know-if-a-process-is-running
|
|
||||||
//https://stackoverflow.com/questions/444798/case-insensitive-containsstring
|
|
||||||
//https://stackoverflow.com/questions/6084940/how-do-i-search-a-multi-dimensional-array
|
|
||||||
//https://www.dotnetperls.com/between-before-after
|
|
||||||
//https://stackoverflow.com/questions/12422619/can-i-disable-the-close-button-of-a-form-using-c
|
|
||||||
//https://stackoverflow.com/questions/9031537/really-simple-encryption-with-c-sharp-and-symmetricalgorithm
|
|
||||||
|
|
||||||
public static class NETExt
|
|
||||||
{
|
|
||||||
#region Rich Text Box Extensions
|
|
||||||
public static void AppendText(this RichTextBox box, string text, Color color)
|
|
||||||
{
|
|
||||||
box.SelectionStart = box.TextLength;
|
|
||||||
box.SelectionLength = 0;
|
|
||||||
|
|
||||||
box.SelectionColor = color;
|
|
||||||
box.AppendText(text);
|
|
||||||
box.SelectionColor = box.ForeColor;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Process Extensions
|
|
||||||
public static bool IsRunning(this Process process)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Process.GetProcessById(process.Id);
|
|
||||||
}
|
|
||||||
catch (InvalidOperationException)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
catch (ArgumentException)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region String Extensions
|
|
||||||
public static bool Contains(this string source, string toCheck, StringComparison comp)
|
|
||||||
{
|
|
||||||
if (source == null)
|
|
||||||
return false;
|
|
||||||
return source.IndexOf(toCheck, comp) >= 0;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Substring Extensions
|
|
||||||
/// <summary>
|
|
||||||
/// Get string value between [first] a and [last] b.
|
|
||||||
/// </summary>
|
|
||||||
public static string Between(this string value, string a, string b)
|
|
||||||
{
|
|
||||||
int posA = value.IndexOf(a);
|
|
||||||
int posB = value.LastIndexOf(b);
|
|
||||||
if (posA == -1)
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
if (posB == -1)
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
int adjustedPosA = posA + a.Length;
|
|
||||||
if (adjustedPosA >= posB)
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return value.Substring(adjustedPosA, posB - adjustedPosA);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get string value after [first] a.
|
|
||||||
/// </summary>
|
|
||||||
public static string Before(this string value, string a)
|
|
||||||
{
|
|
||||||
int posA = value.IndexOf(a);
|
|
||||||
if (posA == -1)
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return value.Substring(0, posA);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get string value after [last] a.
|
|
||||||
/// </summary>
|
|
||||||
public static string After(this string value, string a)
|
|
||||||
{
|
|
||||||
int posA = value.LastIndexOf(a);
|
|
||||||
if (posA == -1)
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
int adjustedPosA = posA + a.Length;
|
|
||||||
if (adjustedPosA >= value.Length)
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return value.Substring(adjustedPosA);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region String Utilities
|
|
||||||
private static byte[] key = new byte[8] { 1, 2, 3, 4, 5, 6, 7, 8 };
|
|
||||||
private static byte[] iv = new byte[8] { 1, 2, 3, 4, 5, 6, 7, 8 };
|
|
||||||
|
|
||||||
public static string Crypt(this string text)
|
|
||||||
{
|
|
||||||
SymmetricAlgorithm algorithm = DES.Create();
|
|
||||||
ICryptoTransform transform = algorithm.CreateEncryptor(key, iv);
|
|
||||||
byte[] inputbuffer = Encoding.Unicode.GetBytes(text);
|
|
||||||
byte[] outputBuffer = transform.TransformFinalBlock(inputbuffer, 0, inputbuffer.Length);
|
|
||||||
return Convert.ToBase64String(outputBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string Decrypt(this string text)
|
|
||||||
{
|
|
||||||
SymmetricAlgorithm algorithm = DES.Create();
|
|
||||||
ICryptoTransform transform = algorithm.CreateDecryptor(key, iv);
|
|
||||||
byte[] inputbuffer = Convert.FromBase64String(text);
|
|
||||||
byte[] outputBuffer = transform.TransformFinalBlock(inputbuffer, 0, inputbuffer.Length);
|
|
||||||
return Encoding.Unicode.GetString(outputBuffer);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Exception Helpers
|
|
||||||
//https://github.com/AlexMelw/EasySharp/blob/master/NHelpers/ExceptionsDealing/Extensions/ExceptionExtensions.cs
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the entire stack trace consisting of exception's footprints (File, Method, LineNumber)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="exception">Source <see cref="Exception" /></param>
|
|
||||||
/// <returns>
|
|
||||||
/// <see cref="string" /> that represents the entire stack trace consisting of exception's footprints (File,
|
|
||||||
/// Method, LineNumber)
|
|
||||||
/// </returns>
|
|
||||||
public static string GetExceptionFootprints(this Exception exception)
|
|
||||||
{
|
|
||||||
StackTrace stackTrace = new StackTrace(exception, true);
|
|
||||||
StackFrame[] frames = stackTrace.GetFrames();
|
|
||||||
|
|
||||||
if (ReferenceEquals(frames, null))
|
|
||||||
{
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
var traceStringBuilder = new StringBuilder();
|
|
||||||
|
|
||||||
for (var i = 0; i < frames.Length; i++)
|
|
||||||
{
|
|
||||||
StackFrame frame = frames[i];
|
|
||||||
|
|
||||||
if (frame.GetFileLineNumber() < 1)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
traceStringBuilder.AppendLine($"File: {frame.GetFileName()}");
|
|
||||||
traceStringBuilder.AppendLine($"Method: {frame.GetMethod().Name}");
|
|
||||||
traceStringBuilder.AppendLine($"LineNumber: {frame.GetFileLineNumber()}");
|
|
||||||
|
|
||||||
if (i == frames.Length - 1)
|
|
||||||
break;
|
|
||||||
|
|
||||||
traceStringBuilder.AppendLine(" ---> ");
|
|
||||||
}
|
|
||||||
|
|
||||||
string stackTraceFootprints = traceStringBuilder.ToString();
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(stackTraceFootprints))
|
|
||||||
return "NO DETECTED FOOTPRINTS";
|
|
||||||
|
|
||||||
return stackTraceFootprints;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region DirectoryInfo Extensions
|
|
||||||
public static IEnumerable<FileInfo> GetFilesByExtensions(this DirectoryInfo dir, params string[] extensions)
|
|
||||||
{
|
|
||||||
if (extensions == null)
|
|
||||||
throw new ArgumentNullException("extensions");
|
|
||||||
IEnumerable<FileInfo> files = dir.EnumerateFiles();
|
|
||||||
return files.Where(f => extensions.Contains(f.Extension));
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region DateTime Extensions
|
|
||||||
//https://stackoverflow.com/questions/5672862/check-if-datetime-instance-falls-in-between-other-two-datetime-objects
|
|
||||||
public static bool IsBetweenTwoDates(this DateTime dt, DateTime start, DateTime end)
|
|
||||||
{
|
|
||||||
return dt >= start && dt <= end;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
@ -0,0 +1,852 @@
|
||||||
|
#region Usings
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using System.Linq;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Novetus Functions
|
||||||
|
public class NovetusFuncs
|
||||||
|
{
|
||||||
|
public static string CopyMapToRBXAsset()
|
||||||
|
{
|
||||||
|
string clientcontentpath = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\content\\temp.rbxl";
|
||||||
|
Util.FixedFileCopy(GlobalVars.UserConfiguration.MapPath, clientcontentpath, true);
|
||||||
|
return GlobalPaths.AltBaseGameDir + "temp.rbxl";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetItemTextureLocalPath(string item, string nameprefix)
|
||||||
|
{
|
||||||
|
//don't bother, we're offline.
|
||||||
|
if (GlobalVars.ExternalIP.Equals("localhost"))
|
||||||
|
return "";
|
||||||
|
|
||||||
|
if (!GlobalVars.SelectedClientInfo.CommandLineArgs.Contains("%localizeonlineclothing%"))
|
||||||
|
return "";
|
||||||
|
|
||||||
|
if (item.Contains("http://") || item.Contains("https://"))
|
||||||
|
{
|
||||||
|
string peram = "id=";
|
||||||
|
string fullname = nameprefix + "Temp.png";
|
||||||
|
|
||||||
|
if (item.Contains(peram))
|
||||||
|
{
|
||||||
|
string id = item.After(peram);
|
||||||
|
fullname = id + ".png";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
Downloader download = new Downloader(item, fullname, "", GlobalPaths.AssetCacheDirTextures);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string path = download.GetFullDLPath();
|
||||||
|
download.InitDownloadNoDialog(path);
|
||||||
|
return GlobalPaths.AssetCacheTexturesGameDir + download.fileName;
|
||||||
|
}
|
||||||
|
#if URI || LAUNCHER || CMD || BASICLAUNCHER
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Util.LogExceptions(ex);
|
||||||
|
#else
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetItemTextureID(string item, string name, AssetCacheDefBasic assetCacheDef)
|
||||||
|
{
|
||||||
|
//don't bother, we're offline.
|
||||||
|
if (GlobalVars.ExternalIP.Equals("localhost"))
|
||||||
|
return "";
|
||||||
|
|
||||||
|
if (!GlobalVars.SelectedClientInfo.CommandLineArgs.Contains("%localizeonlineclothing%"))
|
||||||
|
return "";
|
||||||
|
|
||||||
|
if (item.Contains("http://") || item.Contains("https://"))
|
||||||
|
{
|
||||||
|
string peram = "id=";
|
||||||
|
if (!item.Contains(peram))
|
||||||
|
{
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
Downloader download = new Downloader(item, name + "Temp.rbxm", "", GlobalPaths.AssetCacheDirFonts);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string path = download.GetFullDLPath();
|
||||||
|
download.InitDownloadNoDialog(path);
|
||||||
|
string oldfile = File.ReadAllText(path);
|
||||||
|
string fixedfile = RobloxXML.RemoveInvalidXmlChars(RobloxXML.ReplaceHexadecimalSymbols(oldfile)).Replace("	", "\t").Replace("#9;", "\t");
|
||||||
|
XDocument doc = null;
|
||||||
|
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings { CheckCharacters = false };
|
||||||
|
Stream filestream = Util.GenerateStreamFromString(fixedfile);
|
||||||
|
using (XmlReader xmlReader = XmlReader.Create(filestream, xmlReaderSettings))
|
||||||
|
{
|
||||||
|
xmlReader.MoveToContent();
|
||||||
|
doc = XDocument.Load(xmlReader);
|
||||||
|
}
|
||||||
|
|
||||||
|
return RobloxXML.GetURLInNodes(doc, assetCacheDef.Class, assetCacheDef.Id[0], item);
|
||||||
|
}
|
||||||
|
#if URI || LAUNCHER || CMD || BASICLAUNCHER
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Util.LogExceptions(ex);
|
||||||
|
#else
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void GeneratePlayerID()
|
||||||
|
{
|
||||||
|
int randomID = SecurityFuncs.GenerateRandomNumber();
|
||||||
|
//2147483647 is max id.
|
||||||
|
GlobalVars.UserConfiguration.UserID = randomID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GenerateAndReturnTripcode()
|
||||||
|
{
|
||||||
|
//Powered by https://github.com/davcs86/csharp-uhwid
|
||||||
|
return UHWID.UHWIDEngine.AdvancedUid;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if LAUNCHER
|
||||||
|
public static void PingMasterServer(bool online, string reason, RichTextBox box)
|
||||||
|
#else
|
||||||
|
public static void PingMasterServer(bool online, string reason)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if (online)
|
||||||
|
{
|
||||||
|
GlobalVars.ServerID = SecurityFuncs.RandomString(30) + SecurityFuncs.GenerateRandomNumber();
|
||||||
|
GlobalVars.PingURL = "http://" + GlobalVars.UserConfiguration.ServerBrowserServerAddress +
|
||||||
|
"/list.php?name=" + GlobalVars.UserConfiguration.ServerBrowserServerName +
|
||||||
|
"&ip=" + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : GlobalVars.ExternalIP) +
|
||||||
|
"&port=" + GlobalVars.UserConfiguration.RobloxPort +
|
||||||
|
"&client=" + GlobalVars.UserConfiguration.SelectedClient +
|
||||||
|
"&version=" + GlobalVars.ProgramInformation.Version +
|
||||||
|
"&id=" + GlobalVars.ServerID;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GlobalVars.PingURL = "http://" + GlobalVars.UserConfiguration.ServerBrowserServerAddress +
|
||||||
|
"/delist.php?id=" + GlobalVars.ServerID;
|
||||||
|
GlobalVars.ServerID = "N/A";
|
||||||
|
}
|
||||||
|
|
||||||
|
#if LAUNCHER
|
||||||
|
ConsolePrint("Pinging master server. " + reason, 4, box);
|
||||||
|
#elif CMD
|
||||||
|
ConsolePrint("Pinging master server. " + reason, 4);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LAUNCHER
|
||||||
|
Task.Factory.StartNew(() => TryPing(box));
|
||||||
|
#else
|
||||||
|
Task.Factory.StartNew(() => TryPing());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if LAUNCHER
|
||||||
|
public static void TryPing(RichTextBox box)
|
||||||
|
#else
|
||||||
|
private static void TryPing()
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
string response = Util.HttpGet(GlobalVars.PingURL);
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(response))
|
||||||
|
{
|
||||||
|
#if LAUNCHER
|
||||||
|
ConsolePrint(response, response.Contains("ERROR:") ? 2 : 4, box);
|
||||||
|
#elif CMD
|
||||||
|
ConsolePrint(response, response.Contains("ERROR:") ? 2 : 4);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (response.Contains("ERROR:"))
|
||||||
|
{
|
||||||
|
GlobalVars.ServerID = "N/A";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GlobalVars.ServerID.Equals("N/A"))
|
||||||
|
{
|
||||||
|
#if LAUNCHER
|
||||||
|
ConsolePrint("Your server's ID is " + GlobalVars.ServerID, 4, box);
|
||||||
|
#elif CMD
|
||||||
|
ConsolePrint("Your server's ID is " + GlobalVars.ServerID, 4);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
GlobalVars.PingURL = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
#if CMD
|
||||||
|
public static void CreateTXT()
|
||||||
|
{
|
||||||
|
if (GlobalVars.RequestToOutputInfo)
|
||||||
|
{
|
||||||
|
string[] lines1 = {
|
||||||
|
SecurityFuncs.Base64Encode(!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : GlobalVars.ExternalIP),
|
||||||
|
SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.RobloxPort.ToString()),
|
||||||
|
SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.SelectedClient)
|
||||||
|
};
|
||||||
|
string URI = "novetus://" + SecurityFuncs.Base64Encode(string.Join("|", lines1), true);
|
||||||
|
string[] lines2 = {
|
||||||
|
SecurityFuncs.Base64Encode("localhost"),
|
||||||
|
SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.RobloxPort.ToString()),
|
||||||
|
SecurityFuncs.Base64Encode(GlobalVars.UserConfiguration.SelectedClient)
|
||||||
|
};
|
||||||
|
string URI2 = "novetus://" + SecurityFuncs.Base64Encode(string.Join("|", lines2), true);
|
||||||
|
|
||||||
|
string[] text = {
|
||||||
|
"Process ID: " + (GlobalVars.ProcessID == 0 ? "N/A" : GlobalVars.ProcessID.ToString()),
|
||||||
|
"Don't copy the Process ID when sharing the server.",
|
||||||
|
"--------------------",
|
||||||
|
"Server Info:",
|
||||||
|
"Client: " + GlobalVars.UserConfiguration.SelectedClient,
|
||||||
|
"IP: " + (!string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.AlternateServerIP) ? GlobalVars.UserConfiguration.AlternateServerIP : GlobalVars.ExternalIP),
|
||||||
|
"Port: " + GlobalVars.UserConfiguration.RobloxPort.ToString(),
|
||||||
|
"Map: " + GlobalVars.UserConfiguration.Map,
|
||||||
|
"Players: " + GlobalVars.UserConfiguration.PlayerLimit,
|
||||||
|
"Version: Novetus " + GlobalVars.ProgramInformation.Version,
|
||||||
|
"Online URI Link:",
|
||||||
|
URI,
|
||||||
|
"Local URI Link:",
|
||||||
|
URI2
|
||||||
|
};
|
||||||
|
|
||||||
|
string txt = GlobalPaths.BasePath + "\\" + GlobalVars.ServerInfoFileName;
|
||||||
|
File.WriteAllLines(txt, text);
|
||||||
|
ConsolePrint("Server Information sent to file " + txt, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LAUNCHER || URI
|
||||||
|
public static void LaunchCharacterCustomization()
|
||||||
|
{
|
||||||
|
//https://stackoverflow.com/questions/9029351/close-all-open-forms-except-the-main-menu-in-c-sharp
|
||||||
|
FormCollection fc = Application.OpenForms;
|
||||||
|
|
||||||
|
foreach (Form frm in fc)
|
||||||
|
{
|
||||||
|
//iterate through
|
||||||
|
if (frm.Name == "CharacterCustomizationExtended" ||
|
||||||
|
frm.Name == "CharacterCustomizationCompact")
|
||||||
|
{
|
||||||
|
frm.Close();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (GlobalVars.UserConfiguration.LauncherStyle)
|
||||||
|
{
|
||||||
|
case Settings.Style.Extended:
|
||||||
|
CharacterCustomizationExtended ccustom = new CharacterCustomizationExtended();
|
||||||
|
ccustom.Show();
|
||||||
|
break;
|
||||||
|
case Settings.Style.Compact:
|
||||||
|
CharacterCustomizationCompact ccustom2 = new CharacterCustomizationCompact();
|
||||||
|
ccustom2.Show();
|
||||||
|
break;
|
||||||
|
case Settings.Style.Stylish:
|
||||||
|
default:
|
||||||
|
CharacterCustomizationExtended ccustom3 = new CharacterCustomizationExtended();
|
||||||
|
ccustom3.Show();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public static string FixURLString(string str, string str2)
|
||||||
|
{
|
||||||
|
string fixedStr = str.ToLower().Replace("?version=1&id=", "?id=")
|
||||||
|
.Replace("?version=1&id=", "?id=")
|
||||||
|
.Replace("&", "&")
|
||||||
|
.Replace("amp;", "&");
|
||||||
|
|
||||||
|
string baseurl = fixedStr.Before("/asset/?id=");
|
||||||
|
|
||||||
|
if (baseurl == "")
|
||||||
|
{
|
||||||
|
baseurl = fixedStr.Before("/asset?id=");
|
||||||
|
if (baseurl == "")
|
||||||
|
{
|
||||||
|
baseurl = fixedStr.Before("/item.aspx?id=");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string fixedUrl = fixedStr.Replace(baseurl + "/asset/?id=", str2)
|
||||||
|
.Replace(baseurl + "/asset?id=", str2)
|
||||||
|
.Replace(baseurl + "/item.aspx?id=", str2);
|
||||||
|
|
||||||
|
//...because scripts mess it up.
|
||||||
|
string id = fixedUrl.After("id=");
|
||||||
|
string fixedID = Regex.Replace(id, "[^0-9]", "");
|
||||||
|
|
||||||
|
//really fucking hacky.
|
||||||
|
string finalUrl = fixedUrl.Before("id=") + "id=" + fixedID;
|
||||||
|
|
||||||
|
return finalUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Roblox Helpers
|
||||||
|
#region Vector3
|
||||||
|
public class Vector3
|
||||||
|
{
|
||||||
|
public double X;
|
||||||
|
public double Y;
|
||||||
|
public double Z;
|
||||||
|
|
||||||
|
public Vector3(double aX, double aY, double aZ)
|
||||||
|
{
|
||||||
|
X = aX;
|
||||||
|
Y = aY;
|
||||||
|
Z = aZ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Roblox File Types
|
||||||
|
public enum RobloxFileType
|
||||||
|
{
|
||||||
|
//RBXL and RBXM
|
||||||
|
RBXL,
|
||||||
|
RBXM,
|
||||||
|
//Items
|
||||||
|
Hat,
|
||||||
|
Head,
|
||||||
|
Face,
|
||||||
|
TShirt,
|
||||||
|
Shirt,
|
||||||
|
Pants,
|
||||||
|
Script,
|
||||||
|
HeadNoCustomMesh
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Asset Cache Definition
|
||||||
|
public class AssetCacheDefBasic
|
||||||
|
{
|
||||||
|
public AssetCacheDefBasic(string clas, string[] id)
|
||||||
|
{
|
||||||
|
Class = clas;
|
||||||
|
Id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Class { get; set; }
|
||||||
|
public string[] Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AssetCacheDef : AssetCacheDefBasic
|
||||||
|
{
|
||||||
|
public AssetCacheDef(string clas, string[] id, string[] ext,
|
||||||
|
string[] dir, string[] gamedir) : base(clas, id)
|
||||||
|
{
|
||||||
|
Ext = ext;
|
||||||
|
Dir = dir;
|
||||||
|
GameDir = gamedir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string[] Ext { get; set; }
|
||||||
|
public string[] Dir { get; set; }
|
||||||
|
public string[] GameDir { get; set; }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Roblox Type Definitions
|
||||||
|
public struct RobloxDefs
|
||||||
|
{
|
||||||
|
public static AssetCacheDef Fonts
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("SpecialMesh",
|
||||||
|
new string[] { "MeshId", "TextureId" },
|
||||||
|
new string[] { ".mesh", ".png" },
|
||||||
|
new string[] { GlobalPaths.AssetCacheDirFonts, GlobalPaths.AssetCacheDirTextures },
|
||||||
|
new string[] { GlobalPaths.AssetCacheFontsGameDir, GlobalPaths.AssetCacheTexturesGameDir });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef Sky
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("Sky",
|
||||||
|
new string[] { "SkyboxBk", "SkyboxDn", "SkyboxFt", "SkyboxLf", "SkyboxRt", "SkyboxUp" },
|
||||||
|
new string[] { ".png" },
|
||||||
|
new string[] { GlobalPaths.AssetCacheDirSky },
|
||||||
|
new string[] { GlobalPaths.AssetCacheSkyGameDir });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef Decal
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("Decal",
|
||||||
|
new string[] { "Texture" },
|
||||||
|
new string[] { ".png" },
|
||||||
|
new string[] { GlobalPaths.AssetCacheDirTextures },
|
||||||
|
new string[] { GlobalPaths.AssetCacheTexturesGameDir });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef Texture
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("Texture",
|
||||||
|
new string[] { "Texture" },
|
||||||
|
new string[] { ".png" },
|
||||||
|
new string[] { GlobalPaths.AssetCacheDirTextures },
|
||||||
|
new string[] { GlobalPaths.AssetCacheTexturesGameDir });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef HopperBin
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("HopperBin",
|
||||||
|
new string[] { "TextureId" },
|
||||||
|
new string[] { ".png" },
|
||||||
|
new string[] { GlobalPaths.AssetCacheDirTextures },
|
||||||
|
new string[] { GlobalPaths.AssetCacheTexturesGameDir });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef Tool
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("Tool",
|
||||||
|
new string[] { "TextureId" },
|
||||||
|
new string[] { ".png" },
|
||||||
|
new string[] { GlobalPaths.AssetCacheDirTextures },
|
||||||
|
new string[] { GlobalPaths.AssetCacheTexturesGameDir });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef Sound
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("Sound",
|
||||||
|
new string[] { "SoundId" },
|
||||||
|
new string[] { ".wav" },
|
||||||
|
new string[] { GlobalPaths.AssetCacheDirSounds },
|
||||||
|
new string[] { GlobalPaths.AssetCacheSoundsGameDir });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef ImageLabel
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("ImageLabel",
|
||||||
|
new string[] { "Image" },
|
||||||
|
new string[] { ".png" },
|
||||||
|
new string[] { GlobalPaths.AssetCacheDirTextures },
|
||||||
|
new string[] { GlobalPaths.AssetCacheTexturesGameDir });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef Shirt
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("Shirt",
|
||||||
|
new string[] { "ShirtTemplate" },
|
||||||
|
new string[] { ".png" },
|
||||||
|
new string[] { GlobalPaths.AssetCacheDirTextures },
|
||||||
|
new string[] { GlobalPaths.AssetCacheTexturesGameDir });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef ShirtGraphic
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("ShirtGraphic",
|
||||||
|
new string[] { "Graphic" },
|
||||||
|
new string[] { ".png" },
|
||||||
|
new string[] { GlobalPaths.AssetCacheDirTextures },
|
||||||
|
new string[] { GlobalPaths.AssetCacheTexturesGameDir });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef Pants
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("Pants",
|
||||||
|
new string[] { "PantsTemplate" },
|
||||||
|
new string[] { ".png" },
|
||||||
|
new string[] { GlobalPaths.AssetCacheDirTextures },
|
||||||
|
new string[] { GlobalPaths.AssetCacheTexturesGameDir });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef Script
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("Script",
|
||||||
|
new string[] { "LinkedSource" },
|
||||||
|
new string[] { ".lua" },
|
||||||
|
new string[] { GlobalPaths.AssetCacheDirScripts },
|
||||||
|
new string[] { GlobalPaths.AssetCacheScriptsGameDir });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef LocalScript
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("LocalScript",
|
||||||
|
new string[] { "LinkedSource" },
|
||||||
|
new string[] { ".lua" },
|
||||||
|
new string[] { GlobalPaths.AssetCacheDirScripts },
|
||||||
|
new string[] { GlobalPaths.AssetCacheScriptsGameDir });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//item defs below
|
||||||
|
public static AssetCacheDef ItemHatFonts
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("SpecialMesh",
|
||||||
|
new string[] { "MeshId", "TextureId" },
|
||||||
|
new string[] { ".mesh", ".png" },
|
||||||
|
new string[] { GlobalPaths.hatdirFonts, GlobalPaths.hatdirTextures },
|
||||||
|
new string[] { GlobalPaths.hatGameDirFonts, GlobalPaths.hatGameDirTextures });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef ItemHatSound
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("Sound",
|
||||||
|
new string[] { "SoundId" },
|
||||||
|
new string[] { ".wav" },
|
||||||
|
new string[] { GlobalPaths.hatdirSounds },
|
||||||
|
new string[] { GlobalPaths.hatGameDirSounds });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef ItemHatScript
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("Script",
|
||||||
|
new string[] { "LinkedSource" },
|
||||||
|
new string[] { ".lua" },
|
||||||
|
new string[] { GlobalPaths.hatdirScripts },
|
||||||
|
new string[] { GlobalPaths.hatGameDirScripts });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef ItemHatLocalScript
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("LocalScript",
|
||||||
|
new string[] { "LinkedSource" },
|
||||||
|
new string[] { ".lua" },
|
||||||
|
new string[] { GlobalPaths.hatdirScripts },
|
||||||
|
new string[] { GlobalPaths.hatGameDirScripts });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef ItemHeadFonts
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("SpecialMesh",
|
||||||
|
new string[] { "MeshId", "TextureId" },
|
||||||
|
new string[] { ".mesh", ".png" },
|
||||||
|
new string[] { GlobalPaths.headdirFonts, GlobalPaths.headdirTextures },
|
||||||
|
new string[] { GlobalPaths.headGameDirFonts, GlobalPaths.headGameDirTextures });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef ItemFaceTexture
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("Decal",
|
||||||
|
new string[] { "Texture" },
|
||||||
|
new string[] { ".png" },
|
||||||
|
new string[] { GlobalPaths.facedirTextures },
|
||||||
|
new string[] { GlobalPaths.faceGameDirTextures });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef ItemShirtTexture
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("Shirt",
|
||||||
|
new string[] { "ShirtTemplate" },
|
||||||
|
new string[] { ".png" },
|
||||||
|
new string[] { GlobalPaths.shirtdirTextures },
|
||||||
|
new string[] { GlobalPaths.shirtGameDirTextures });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef ItemTShirtTexture
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("ShirtGraphic",
|
||||||
|
new string[] { "Graphic" },
|
||||||
|
new string[] { ".png" },
|
||||||
|
new string[] { GlobalPaths.tshirtdirTextures },
|
||||||
|
new string[] { GlobalPaths.tshirtGameDirTextures });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AssetCacheDef ItemPantsTexture
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new AssetCacheDef("Pants",
|
||||||
|
new string[] { "PantsTemplate" },
|
||||||
|
new string[] { ".png" },
|
||||||
|
new string[] { GlobalPaths.pantsdirTextures },
|
||||||
|
new string[] { GlobalPaths.pantsGameDirTextures });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region XML Types
|
||||||
|
public enum XMLTypes
|
||||||
|
{
|
||||||
|
Token,
|
||||||
|
Bool,
|
||||||
|
Float,
|
||||||
|
String,
|
||||||
|
Vector2Int16,
|
||||||
|
Int
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Roblox XML Parser
|
||||||
|
public static class RobloxXML
|
||||||
|
{
|
||||||
|
public static void EditRenderSettings(XDocument doc, string setting, string value, XMLTypes type)
|
||||||
|
{
|
||||||
|
var v = from nodes in doc.Descendants("Item")
|
||||||
|
where nodes.Attribute("class").Value == "RenderSettings"
|
||||||
|
select nodes;
|
||||||
|
|
||||||
|
foreach (var item in v)
|
||||||
|
{
|
||||||
|
var v2 = from nodes in item.Descendants((type != XMLTypes.Vector2Int16 ? type.ToString().ToLower() : "Vector2int16"))
|
||||||
|
where nodes.Attribute("name").Value == setting
|
||||||
|
select nodes;
|
||||||
|
|
||||||
|
foreach (var item2 in v2)
|
||||||
|
{
|
||||||
|
if (type != XMLTypes.Vector2Int16)
|
||||||
|
{
|
||||||
|
item2.Value = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string[] vals = value.Split('x');
|
||||||
|
|
||||||
|
var v3 = from nodes in item2.Descendants("X")
|
||||||
|
select nodes;
|
||||||
|
|
||||||
|
foreach (var item3 in v3)
|
||||||
|
{
|
||||||
|
item3.Value = vals[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
var v4 = from nodes in item2.Descendants("Y")
|
||||||
|
select nodes;
|
||||||
|
|
||||||
|
foreach (var item4 in v4)
|
||||||
|
{
|
||||||
|
item4.Value = vals[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsRenderSettingStringValid(XDocument doc, string setting, XMLTypes type)
|
||||||
|
{
|
||||||
|
if (type != XMLTypes.String)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var v = from nodes in doc.Descendants("Item")
|
||||||
|
where nodes.Attribute("class").Value == "RenderSettings"
|
||||||
|
select nodes;
|
||||||
|
|
||||||
|
foreach (var item in v)
|
||||||
|
{
|
||||||
|
var v2 = from nodes in item.Descendants(type.ToString().ToLower())
|
||||||
|
where nodes.Attribute("name").Value == setting
|
||||||
|
select nodes;
|
||||||
|
|
||||||
|
foreach (var item2 in v2)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetRenderSettings(XDocument doc, string setting, XMLTypes type)
|
||||||
|
{
|
||||||
|
var v = from nodes in doc.Descendants("Item")
|
||||||
|
where nodes.Attribute("class").Value == "RenderSettings"
|
||||||
|
select nodes;
|
||||||
|
|
||||||
|
foreach (var item in v)
|
||||||
|
{
|
||||||
|
var v2 = from nodes in item.Descendants((type != XMLTypes.Vector2Int16 ? type.ToString().ToLower() : "Vector2int16"))
|
||||||
|
where nodes.Attribute("name").Value == setting
|
||||||
|
select nodes;
|
||||||
|
|
||||||
|
foreach (var item2 in v2)
|
||||||
|
{
|
||||||
|
if (type != XMLTypes.Vector2Int16)
|
||||||
|
{
|
||||||
|
return item2.Value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string ValX = "";
|
||||||
|
string ValY = "";
|
||||||
|
|
||||||
|
var v3 = from nodes in item2.Descendants("X")
|
||||||
|
select nodes;
|
||||||
|
|
||||||
|
foreach (var item3 in v3)
|
||||||
|
{
|
||||||
|
ValX = item3.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
var v4 = from nodes in item2.Descendants("Y")
|
||||||
|
select nodes;
|
||||||
|
|
||||||
|
foreach (var item4 in v4)
|
||||||
|
{
|
||||||
|
ValY = item4.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ValX + "x" + ValY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DownloadFilesFromNode(string url, string path, string fileext, string id)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(id))
|
||||||
|
{
|
||||||
|
Downloader download = new Downloader(url, id);
|
||||||
|
download.InitDownload(path, fileext, "", true, false);
|
||||||
|
if (download.getDownloadOutcome().Contains("Error"))
|
||||||
|
{
|
||||||
|
throw new IOException(download.getDownloadOutcome());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetURLInNodes(XDocument doc, string itemClassValue, string itemIdValue, string url)
|
||||||
|
{
|
||||||
|
var v = from nodes in doc.Descendants("Item")
|
||||||
|
where nodes.Attribute("class").Value == itemClassValue
|
||||||
|
select nodes;
|
||||||
|
|
||||||
|
foreach (var item in v)
|
||||||
|
{
|
||||||
|
var v2 = from nodes in item.Descendants("Content")
|
||||||
|
where nodes.Attribute("name").Value == itemIdValue
|
||||||
|
select nodes;
|
||||||
|
|
||||||
|
foreach (var item2 in v2)
|
||||||
|
{
|
||||||
|
var v3 = from nodes in item2.Descendants("url")
|
||||||
|
select nodes;
|
||||||
|
|
||||||
|
foreach (var item3 in v3)
|
||||||
|
{
|
||||||
|
if (!item3.Value.Contains("rbxassetid"))
|
||||||
|
{
|
||||||
|
if (!item3.Value.Contains("rbxasset"))
|
||||||
|
{
|
||||||
|
string oldurl = item3.Value;
|
||||||
|
string urlFixed = NovetusFuncs.FixURLString(oldurl, url);
|
||||||
|
string peram = "id=";
|
||||||
|
|
||||||
|
if (urlFixed.Contains(peram))
|
||||||
|
{
|
||||||
|
return urlFixed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string oldurl = item3.Value;
|
||||||
|
string rbxassetid = "rbxassetid://";
|
||||||
|
string urlFixed = url + oldurl.After(rbxassetid);
|
||||||
|
string peram = "id=";
|
||||||
|
|
||||||
|
if (urlFixed.Contains(peram))
|
||||||
|
{
|
||||||
|
return urlFixed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string RemoveInvalidXmlChars(string content)
|
||||||
|
{
|
||||||
|
return new string(content.Where(ch => XmlConvert.IsXmlChar(ch)).ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ReplaceHexadecimalSymbols(string txt)
|
||||||
|
{
|
||||||
|
string r = "[\x00-\x08\x0B\x0C\x0E-\x1F]";
|
||||||
|
return Regex.Replace(txt, r, "", RegexOptions.Compiled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#endregion
|
||||||
|
|
@ -1,454 +0,0 @@
|
||||||
#region Usings
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Script Functions
|
|
||||||
public class ScriptFuncs
|
|
||||||
{
|
|
||||||
#region Script Generator/Signer
|
|
||||||
public class Generator
|
|
||||||
{
|
|
||||||
public static void SignGeneratedScript(string scriptFileName, bool newSigFormat = false, bool encodeInBase64 = true)
|
|
||||||
{
|
|
||||||
string privateKeyPath = Path.GetDirectoryName(scriptFileName) + "//privatekey.txt";
|
|
||||||
|
|
||||||
if (File.Exists(privateKeyPath))
|
|
||||||
{
|
|
||||||
//init vars
|
|
||||||
string format = (newSigFormat ? "--rbxsig" : "") + "%{0}%{1}";
|
|
||||||
byte[] blob = Encoding.Default.GetBytes(File.ReadAllText(privateKeyPath));
|
|
||||||
|
|
||||||
if (encodeInBase64)
|
|
||||||
{
|
|
||||||
blob = Convert.FromBase64String(Encoding.Default.GetString(blob));
|
|
||||||
}
|
|
||||||
|
|
||||||
//create cryptography providers
|
|
||||||
var shaCSP = new SHA1CryptoServiceProvider();
|
|
||||||
var rsaCSP = new RSACryptoServiceProvider();
|
|
||||||
rsaCSP.ImportCspBlob(blob);
|
|
||||||
|
|
||||||
// sign script
|
|
||||||
string script = "\r\n" + File.ReadAllText(scriptFileName);
|
|
||||||
byte[] signature = rsaCSP.SignData(Encoding.Default.GetBytes(script), shaCSP);
|
|
||||||
// override file.
|
|
||||||
GlobalFuncs.FixedFileDelete(scriptFileName);
|
|
||||||
File.WriteAllText(scriptFileName, string.Format(format, Convert.ToBase64String(signature), script));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//create the signature file if it doesn't exist
|
|
||||||
var signingRSACSP = new RSACryptoServiceProvider(1024);
|
|
||||||
byte[] privateKeyBlob = signingRSACSP.ExportCspBlob(true);
|
|
||||||
signingRSACSP.Dispose();
|
|
||||||
|
|
||||||
// save our text file in the script's directory
|
|
||||||
File.WriteAllText(privateKeyPath, encodeInBase64 ? Convert.ToBase64String(privateKeyBlob) : Encoding.Default.GetString(privateKeyBlob));
|
|
||||||
|
|
||||||
// try signing again.
|
|
||||||
SignGeneratedScript(scriptFileName, encodeInBase64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetScriptFuncForType(ScriptType type)
|
|
||||||
{
|
|
||||||
return GetScriptFuncForType(GlobalVars.UserConfiguration.SelectedClient, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetScriptFuncForType(string ClientName, ScriptType type)
|
|
||||||
{
|
|
||||||
FileFormat.ClientInfo info = GlobalFuncs.GetClientInfoValues(ClientName);
|
|
||||||
|
|
||||||
string rbxexe = "";
|
|
||||||
if (info.LegacyMode)
|
|
||||||
{
|
|
||||||
rbxexe = GlobalPaths.ClientDir + @"\\" + ClientName + @"\\RobloxApp.exe";
|
|
||||||
}
|
|
||||||
else if (info.SeperateFolders)
|
|
||||||
{
|
|
||||||
rbxexe = GlobalPaths.ClientDir + @"\\" + ClientName + @"\\client\\RobloxApp_client.exe";
|
|
||||||
}
|
|
||||||
else if (info.UsesCustomClientEXEName)
|
|
||||||
{
|
|
||||||
rbxexe = GlobalPaths.ClientDir + @"\\" + ClientName + @"\\" + info.CustomClientEXEName;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rbxexe = GlobalPaths.ClientDir + @"\\" + ClientName + @"\\RobloxApp_client.exe";
|
|
||||||
}
|
|
||||||
|
|
||||||
#if LAUNCHER
|
|
||||||
string md5dir = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(Assembly.GetExecutingAssembly().Location) : "";
|
|
||||||
#else
|
|
||||||
string md5dir = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.RootPathLauncher + "\\Novetus.exe") : "";
|
|
||||||
#endif
|
|
||||||
string md5script = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.ClientDir + @"\\" + ClientName + @"\\content\\scripts\\" + GlobalPaths.ScriptName + ".lua") : "";
|
|
||||||
string md5exe = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(rbxexe) : "";
|
|
||||||
string md5s = "'" + md5exe + "','" + md5dir + "','" + md5script + "'";
|
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case ScriptType.Client:
|
|
||||||
return "_G.CSConnect("
|
|
||||||
+ (info.UsesID ? GlobalVars.UserConfiguration.UserID : 0) + ",'"
|
|
||||||
+ GlobalVars.IP + "',"
|
|
||||||
+ GlobalVars.JoinPort + ",'"
|
|
||||||
+ (info.UsesPlayerName ? GlobalVars.UserConfiguration.PlayerName : "Player") + "',"
|
|
||||||
+ GlobalVars.Loadout + ","
|
|
||||||
+ md5s + ",'"
|
|
||||||
+ GlobalVars.PlayerTripcode
|
|
||||||
+ ((GlobalVars.ValidatedExtraFiles > 0) ? "'," + GlobalVars.ValidatedExtraFiles.ToString() + "," : "',0,")
|
|
||||||
+ GlobalVars.UserConfiguration.NewGUI.ToString().ToLower() + ");";
|
|
||||||
case ScriptType.Server:
|
|
||||||
return "_G.CSServer("
|
|
||||||
+ GlobalVars.UserConfiguration.RobloxPort + ","
|
|
||||||
+ GlobalVars.UserConfiguration.PlayerLimit + ","
|
|
||||||
+ md5s + ","
|
|
||||||
+ GlobalVars.UserConfiguration.ShowServerNotifications.ToString().ToLower()
|
|
||||||
+ ((GlobalVars.ValidatedExtraFiles > 0) ? "," + GlobalVars.ValidatedExtraFiles.ToString() + "," : ",0,")
|
|
||||||
+ GlobalVars.UserConfiguration.NewGUI.ToString().ToLower() + ");";
|
|
||||||
case ScriptType.Solo:
|
|
||||||
case ScriptType.EasterEgg:
|
|
||||||
return "_G.CSSolo("
|
|
||||||
+ (info.UsesID ? GlobalVars.UserConfiguration.UserID : 0) + ",'"
|
|
||||||
+ (info.UsesPlayerName ? GlobalVars.UserConfiguration.PlayerName : "Player") + "',"
|
|
||||||
+ GlobalVars.soloLoadout + ","
|
|
||||||
+ GlobalVars.UserConfiguration.NewGUI.ToString().ToLower() + ");";
|
|
||||||
case ScriptType.Studio:
|
|
||||||
return "_G.CSStudio("
|
|
||||||
+ GlobalVars.UserConfiguration.NewGUI.ToString().ToLower() + ");";
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetNameForType(ScriptType type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case ScriptType.Client:
|
|
||||||
return "Client";
|
|
||||||
case ScriptType.Server:
|
|
||||||
return "Server";
|
|
||||||
case ScriptType.Solo:
|
|
||||||
return "Play Solo";
|
|
||||||
case ScriptType.Studio:
|
|
||||||
return "Studio";
|
|
||||||
case ScriptType.EasterEgg:
|
|
||||||
return "A message from Bitl";
|
|
||||||
default:
|
|
||||||
return "N/A";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void GenerateScriptForClient(ScriptType type)
|
|
||||||
{
|
|
||||||
GenerateScriptForClient(GlobalVars.UserConfiguration.SelectedClient, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void GenerateScriptForClient(string ClientName, ScriptType type)
|
|
||||||
{
|
|
||||||
bool shouldUseLoadFile = GlobalVars.SelectedClientInfo.CommandLineArgs.Contains("%useloadfile%");
|
|
||||||
string execScriptMethod = shouldUseLoadFile ? "loadfile" : "dofile";
|
|
||||||
|
|
||||||
string[] code = {
|
|
||||||
"--Load Script",
|
|
||||||
//scriptcontents,
|
|
||||||
(GlobalVars.SelectedClientInfo.SeperateFolders ? "" +
|
|
||||||
execScriptMethod + "('rbxasset://../../content/scripts/" + GlobalPaths.ScriptName + ".lua')" + (shouldUseLoadFile ? "()" : "") :
|
|
||||||
execScriptMethod + "('rbxasset://scripts/" + GlobalPaths.ScriptName + ".lua')" + (shouldUseLoadFile ? "()" : "")),
|
|
||||||
GetScriptFuncForType(type),
|
|
||||||
};
|
|
||||||
|
|
||||||
if (GlobalVars.SelectedClientInfo.SeperateFolders)
|
|
||||||
{
|
|
||||||
string scriptsFolder = GlobalPaths.ClientDir + @"\\" + ClientName + @"\\" + GlobalFuncs.GetClientSeperateFolderName(type) + @"\\content\\scripts";
|
|
||||||
if (!Directory.Exists(scriptsFolder))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(scriptsFolder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
string outputPath = (GlobalVars.SelectedClientInfo.SeperateFolders ?
|
|
||||||
GlobalPaths.ClientDir + @"\\" + ClientName + @"\\" + GlobalFuncs.GetClientSeperateFolderName(type) + @"\\content\\scripts\\" + GlobalPaths.ScriptGenName + ".lua" :
|
|
||||||
GlobalPaths.ClientDir + @"\\" + ClientName + @"\\content\\scripts\\" + GlobalPaths.ScriptGenName + ".lua");
|
|
||||||
|
|
||||||
File.WriteAllLines(outputPath, code);
|
|
||||||
|
|
||||||
bool shouldSign = GlobalVars.SelectedClientInfo.CommandLineArgs.Contains("%signgeneratedjoinscript%");
|
|
||||||
bool shouldUseNewSigFormat = GlobalVars.SelectedClientInfo.CommandLineArgs.Contains("%usenewsignformat%");
|
|
||||||
|
|
||||||
if (shouldSign)
|
|
||||||
{
|
|
||||||
SignGeneratedScript(outputPath, shouldUseNewSigFormat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetGeneratedScriptName(string ClientName, ScriptType type)
|
|
||||||
{
|
|
||||||
GenerateScriptForClient(ClientName, type);
|
|
||||||
return GlobalFuncs.GetGenLuaFileName(ClientName, type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region ClientScript Parser
|
|
||||||
public class ClientScript
|
|
||||||
{
|
|
||||||
public static string GetArgsFromTag(string code, string tag, string endtag)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int pFrom = code.IndexOf(tag) + tag.Length;
|
|
||||||
int pTo = code.LastIndexOf(endtag);
|
|
||||||
string result = code.Substring(pFrom, pTo - pFrom);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
#if URI || LAUNCHER || CMD || BASICLAUNCHER
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.LogExceptions(ex);
|
|
||||||
#else
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
return "%donothing%";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ScriptType GetTypeFromTag(string tag)
|
|
||||||
{
|
|
||||||
switch (tag)
|
|
||||||
{
|
|
||||||
case string client when client.Contains("client"):
|
|
||||||
return ScriptType.Client;
|
|
||||||
case string server when server.Contains("server"):
|
|
||||||
case string no3d when no3d.Contains("no3d"):
|
|
||||||
return ScriptType.Server;
|
|
||||||
case string solo when solo.Contains("solo"):
|
|
||||||
return ScriptType.Solo;
|
|
||||||
case string studio when studio.Contains("studio"):
|
|
||||||
return ScriptType.Studio;
|
|
||||||
default:
|
|
||||||
return ScriptType.None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetTagFromType(ScriptType type, bool endtag, bool no3d)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case ScriptType.Client:
|
|
||||||
return endtag ? "</client>" : "<client>";
|
|
||||||
case ScriptType.Server:
|
|
||||||
return no3d ? (endtag ? "</no3d>" : "<no3d>") : (endtag ? "</server>" : "<server>");
|
|
||||||
case ScriptType.Solo:
|
|
||||||
return endtag ? "</solo>" : "<solo>";
|
|
||||||
case ScriptType.Studio:
|
|
||||||
return endtag ? "</studio>" : "<studio>";
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int ConvertIconStringToInt()
|
|
||||||
{
|
|
||||||
switch (GlobalVars.UserCustomization.Icon)
|
|
||||||
{
|
|
||||||
case "BC":
|
|
||||||
return 1;
|
|
||||||
case "TBC":
|
|
||||||
return 2;
|
|
||||||
case "OBC":
|
|
||||||
return 3;
|
|
||||||
case "NBC":
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetFolderAndMapName(string source, string seperator)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string result = source.Substring(0, source.IndexOf(seperator));
|
|
||||||
|
|
||||||
if (File.Exists(GlobalPaths.MapsDir + @"\\" + result + @"\\" + source))
|
|
||||||
{
|
|
||||||
return result + @"\\" + source;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#if URI || LAUNCHER || CMD || BASICLAUNCHER
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
GlobalFuncs.LogExceptions(ex);
|
|
||||||
#else
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetFolderAndMapName(string source)
|
|
||||||
{
|
|
||||||
return GetFolderAndMapName(source, " -");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetRawArgsForType(ScriptType type, string ClientName, string luafile)
|
|
||||||
{
|
|
||||||
FileFormat.ClientInfo info = GlobalFuncs.GetClientInfoValues(ClientName);
|
|
||||||
|
|
||||||
if (!info.Fix2007)
|
|
||||||
{
|
|
||||||
return Generator.GetScriptFuncForType(ClientName, type);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return luafile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string CompileScript(string code, string tag, string endtag, string mapfile, string luafile, string rbxexe, bool usesharedtags = true)
|
|
||||||
{
|
|
||||||
return CompileScript(GlobalVars.UserConfiguration.SelectedClient, code, tag, endtag, mapfile, luafile, rbxexe, usesharedtags);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string CompileScript(string ClientName, string code, string tag, string endtag, string mapfile, string luafile, string rbxexe, bool usesharedtags = true)
|
|
||||||
{
|
|
||||||
string start = tag;
|
|
||||||
string end = endtag;
|
|
||||||
|
|
||||||
FileFormat.ClientInfo info = GlobalFuncs.GetClientInfoValues(ClientName);
|
|
||||||
|
|
||||||
ScriptType type = GetTypeFromTag(start);
|
|
||||||
|
|
||||||
//we must have the ending tag before we continue.
|
|
||||||
if (string.IsNullOrWhiteSpace(end))
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (usesharedtags)
|
|
||||||
{
|
|
||||||
string sharedstart = "<shared>";
|
|
||||||
string sharedend = "</shared>";
|
|
||||||
|
|
||||||
if (code.Contains(sharedstart) && code.Contains(sharedend))
|
|
||||||
{
|
|
||||||
start = sharedstart;
|
|
||||||
end = sharedend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info.Fix2007)
|
|
||||||
{
|
|
||||||
Generator.GenerateScriptForClient(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
string extractedCode = GetArgsFromTag(code, start, end);
|
|
||||||
|
|
||||||
if (extractedCode.Contains("%donothing%"))
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
#if LAUNCHER
|
|
||||||
string md5dir = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(Assembly.GetExecutingAssembly().Location) : "";
|
|
||||||
#else
|
|
||||||
string md5dir = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.RootPathLauncher + "\\Novetus.exe") : "";
|
|
||||||
#endif
|
|
||||||
string md5script = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\content\\scripts\\" + GlobalPaths.ScriptName + ".lua") : "";
|
|
||||||
string md5exe = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(rbxexe) : "";
|
|
||||||
string md5sd = "'" + md5exe + "','" + md5dir + "','" + md5script + "'";
|
|
||||||
string md5s = "'" + info.ClientMD5 + "','" + md5dir + "','" + info.ScriptMD5 + "'";
|
|
||||||
string compiled = extractedCode.Replace("%version%", GlobalVars.ProgramInformation.Version)
|
|
||||||
.Replace("%mapfile%", mapfile)
|
|
||||||
.Replace("%luafile%", luafile)
|
|
||||||
.Replace("%charapp%", GlobalVars.UserCustomization.CharacterID)
|
|
||||||
.Replace("%ip%", GlobalVars.IP)
|
|
||||||
.Replace("%port%", GlobalVars.UserConfiguration.RobloxPort.ToString())
|
|
||||||
.Replace("%joinport%", GlobalVars.JoinPort.ToString())
|
|
||||||
.Replace("%name%", GlobalVars.UserConfiguration.PlayerName)
|
|
||||||
.Replace("%icone%", ConvertIconStringToInt().ToString())
|
|
||||||
.Replace("%icon%", GlobalVars.UserCustomization.Icon)
|
|
||||||
.Replace("%id%", GlobalVars.UserConfiguration.UserID.ToString())
|
|
||||||
.Replace("%face%", GlobalVars.UserCustomization.Face)
|
|
||||||
.Replace("%head%", GlobalVars.UserCustomization.Head)
|
|
||||||
.Replace("%tshirt%", GlobalVars.UserCustomization.TShirt)
|
|
||||||
.Replace("%shirt%", GlobalVars.UserCustomization.Shirt)
|
|
||||||
.Replace("%pants%", GlobalVars.UserCustomization.Pants)
|
|
||||||
.Replace("%hat1%", GlobalVars.UserCustomization.Hat1)
|
|
||||||
.Replace("%hat2%", GlobalVars.UserCustomization.Hat2)
|
|
||||||
.Replace("%hat3%", GlobalVars.UserCustomization.Hat3)
|
|
||||||
.Replace("%faced%", GlobalVars.UserCustomization.Face.Contains("http://") ? GlobalVars.UserCustomization.Face : GlobalPaths.faceGameDir + GlobalVars.UserCustomization.Face)
|
|
||||||
.Replace("%headd%", GlobalPaths.headGameDir + GlobalVars.UserCustomization.Head)
|
|
||||||
.Replace("%tshirtd%", GlobalVars.UserCustomization.TShirt.Contains("http://") ? GlobalVars.UserCustomization.TShirt : GlobalPaths.tshirtGameDir + GlobalVars.UserCustomization.TShirt)
|
|
||||||
.Replace("%shirtd%", GlobalVars.UserCustomization.Shirt.Contains("http://") ? GlobalVars.UserCustomization.Shirt : GlobalPaths.shirtGameDir + GlobalVars.UserCustomization.Shirt)
|
|
||||||
.Replace("%pantsd%", GlobalVars.UserCustomization.Pants.Contains("http://") ? GlobalVars.UserCustomization.Pants : GlobalPaths.pantsGameDir + GlobalVars.UserCustomization.Pants)
|
|
||||||
.Replace("%hat1d%", GlobalPaths.hatGameDir + GlobalVars.UserCustomization.Hat1)
|
|
||||||
.Replace("%hat2d%", GlobalPaths.hatGameDir + GlobalVars.UserCustomization.Hat2)
|
|
||||||
.Replace("%hat3d%", GlobalPaths.hatGameDir + GlobalVars.UserCustomization.Hat3)
|
|
||||||
.Replace("%headcolor%", GlobalVars.UserCustomization.HeadColorID.ToString())
|
|
||||||
.Replace("%torsocolor%", GlobalVars.UserCustomization.TorsoColorID.ToString())
|
|
||||||
.Replace("%larmcolor%", GlobalVars.UserCustomization.LeftArmColorID.ToString())
|
|
||||||
.Replace("%llegcolor%", GlobalVars.UserCustomization.LeftLegColorID.ToString())
|
|
||||||
.Replace("%rarmcolor%", GlobalVars.UserCustomization.RightArmColorID.ToString())
|
|
||||||
.Replace("%rlegcolor%", GlobalVars.UserCustomization.RightLegColorID.ToString())
|
|
||||||
.Replace("%md5launcher%", md5dir)
|
|
||||||
.Replace("%md5script%", info.ScriptMD5)
|
|
||||||
.Replace("%md5exe%", info.ClientMD5)
|
|
||||||
.Replace("%md5scriptd%", md5script)
|
|
||||||
.Replace("%md5exed%", md5exe)
|
|
||||||
.Replace("%md5s%", md5s)
|
|
||||||
.Replace("%md5sd%", md5sd)
|
|
||||||
.Replace("%limit%", GlobalVars.UserConfiguration.PlayerLimit.ToString())
|
|
||||||
.Replace("%extra%", GlobalVars.UserCustomization.Extra)
|
|
||||||
.Replace("%hat4%", GlobalVars.UserCustomization.Extra)
|
|
||||||
.Replace("%extrad%", GlobalPaths.extraGameDir + GlobalVars.UserCustomization.Extra)
|
|
||||||
.Replace("%hat4d%", GlobalPaths.hatGameDir + GlobalVars.UserCustomization.Extra)
|
|
||||||
.Replace("%mapfiled%", GlobalPaths.BaseGameDir + GlobalVars.UserConfiguration.MapPathSnip.Replace(@"\\", @"\").Replace(@"/", @"\"))
|
|
||||||
.Replace("%mapfilec%", extractedCode.Contains("%mapfilec%") ? GlobalFuncs.CopyMapToRBXAsset() : "")
|
|
||||||
.Replace("%tripcode%", GlobalVars.PlayerTripcode)
|
|
||||||
.Replace("%scripttype%", Generator.GetNameForType(type))
|
|
||||||
.Replace("%notifications%", GlobalVars.UserConfiguration.ShowServerNotifications.ToString().ToLower())
|
|
||||||
.Replace("%loadout%", code.Contains("<solo>") ? GlobalVars.soloLoadout : GlobalVars.Loadout)
|
|
||||||
.Replace("%doublequote%", "\"")
|
|
||||||
.Replace("%validatedextrafiles%", GlobalVars.ValidatedExtraFiles.ToString())
|
|
||||||
.Replace("%argstring%", GetRawArgsForType(type, ClientName, luafile))
|
|
||||||
.Replace("%tshirttexid%", GlobalVars.TShirtTextureID)
|
|
||||||
.Replace("%shirttexid%", GlobalVars.ShirtTextureID)
|
|
||||||
.Replace("%pantstexid%", GlobalVars.PantsTextureID)
|
|
||||||
.Replace("%facetexid%", GlobalVars.FaceTextureID)
|
|
||||||
.Replace("%tshirttexidlocal%", GlobalVars.TShirtTextureLocal)
|
|
||||||
.Replace("%shirttexidlocal%", GlobalVars.ShirtTextureLocal)
|
|
||||||
.Replace("%pantstexidlocal%", GlobalVars.PantsTextureLocal)
|
|
||||||
.Replace("%facetexlocal%", GlobalVars.FaceTextureLocal)
|
|
||||||
.Replace("%newgui%", GlobalVars.UserConfiguration.NewGUI.ToString().ToLower());
|
|
||||||
|
|
||||||
if (compiled.Contains("%disabled%"))
|
|
||||||
{
|
|
||||||
MessageBox.Show("This option has been disabled for this client.", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return compiled;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
@ -0,0 +1,725 @@
|
||||||
|
#region Usings
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Net;
|
||||||
|
using NLog;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Utils
|
||||||
|
|
||||||
|
//This code was brought to you by:
|
||||||
|
//https://stackoverflow.com/questions/1926264/color-different-parts-of-a-richtextbox-string
|
||||||
|
//https://stackoverflow.com/questions/262280/how-can-i-know-if-a-process-is-running
|
||||||
|
//https://stackoverflow.com/questions/444798/case-insensitive-containsstring
|
||||||
|
//https://stackoverflow.com/questions/6084940/how-do-i-search-a-multi-dimensional-array
|
||||||
|
//https://www.dotnetperls.com/between-before-after
|
||||||
|
//https://stackoverflow.com/questions/12422619/can-i-disable-the-close-button-of-a-form-using-c
|
||||||
|
//https://stackoverflow.com/questions/9031537/really-simple-encryption-with-c-sharp-and-symmetricalgorithm
|
||||||
|
|
||||||
|
public static class Util
|
||||||
|
{
|
||||||
|
#region Rich Text Box Extensions
|
||||||
|
public static void AppendText(this RichTextBox box, string text, Color color)
|
||||||
|
{
|
||||||
|
box.SelectionStart = box.TextLength;
|
||||||
|
box.SelectionLength = 0;
|
||||||
|
|
||||||
|
box.SelectionColor = color;
|
||||||
|
box.AppendText(text);
|
||||||
|
box.SelectionColor = box.ForeColor;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Process Extensions
|
||||||
|
public static bool IsRunning(this Process process)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Process.GetProcessById(process.Id);
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (ArgumentException)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region String Extensions
|
||||||
|
public static bool Contains(this string source, string toCheck, StringComparison comp)
|
||||||
|
{
|
||||||
|
if (source == null)
|
||||||
|
return false;
|
||||||
|
return source.IndexOf(toCheck, comp) >= 0;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Substring Extensions
|
||||||
|
/// <summary>
|
||||||
|
/// Get string value between [first] a and [last] b.
|
||||||
|
/// </summary>
|
||||||
|
public static string Between(this string value, string a, string b)
|
||||||
|
{
|
||||||
|
int posA = value.IndexOf(a);
|
||||||
|
int posB = value.LastIndexOf(b);
|
||||||
|
if (posA == -1)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (posB == -1)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
int adjustedPosA = posA + a.Length;
|
||||||
|
if (adjustedPosA >= posB)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return value.Substring(adjustedPosA, posB - adjustedPosA);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get string value after [first] a.
|
||||||
|
/// </summary>
|
||||||
|
public static string Before(this string value, string a)
|
||||||
|
{
|
||||||
|
int posA = value.IndexOf(a);
|
||||||
|
if (posA == -1)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return value.Substring(0, posA);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get string value after [last] a.
|
||||||
|
/// </summary>
|
||||||
|
public static string After(this string value, string a)
|
||||||
|
{
|
||||||
|
int posA = value.LastIndexOf(a);
|
||||||
|
if (posA == -1)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
int adjustedPosA = posA + a.Length;
|
||||||
|
if (adjustedPosA >= value.Length)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return value.Substring(adjustedPosA);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region String Utilities
|
||||||
|
private static byte[] key = new byte[8] { 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||||
|
private static byte[] iv = new byte[8] { 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||||
|
|
||||||
|
public static string Crypt(this string text)
|
||||||
|
{
|
||||||
|
SymmetricAlgorithm algorithm = DES.Create();
|
||||||
|
ICryptoTransform transform = algorithm.CreateEncryptor(key, iv);
|
||||||
|
byte[] inputbuffer = Encoding.Unicode.GetBytes(text);
|
||||||
|
byte[] outputBuffer = transform.TransformFinalBlock(inputbuffer, 0, inputbuffer.Length);
|
||||||
|
return Convert.ToBase64String(outputBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Decrypt(this string text)
|
||||||
|
{
|
||||||
|
SymmetricAlgorithm algorithm = DES.Create();
|
||||||
|
ICryptoTransform transform = algorithm.CreateDecryptor(key, iv);
|
||||||
|
byte[] inputbuffer = Convert.FromBase64String(text);
|
||||||
|
byte[] outputBuffer = transform.TransformFinalBlock(inputbuffer, 0, inputbuffer.Length);
|
||||||
|
return Encoding.Unicode.GetString(outputBuffer);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Exception Helpers
|
||||||
|
//https://github.com/AlexMelw/EasySharp/blob/master/NHelpers/ExceptionsDealing/Extensions/ExceptionExtensions.cs
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the entire stack trace consisting of exception's footprints (File, Method, LineNumber)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="exception">Source <see cref="Exception" /></param>
|
||||||
|
/// <returns>
|
||||||
|
/// <see cref="string" /> that represents the entire stack trace consisting of exception's footprints (File,
|
||||||
|
/// Method, LineNumber)
|
||||||
|
/// </returns>
|
||||||
|
public static string GetExceptionFootprints(this Exception exception)
|
||||||
|
{
|
||||||
|
StackTrace stackTrace = new StackTrace(exception, true);
|
||||||
|
StackFrame[] frames = stackTrace.GetFrames();
|
||||||
|
|
||||||
|
if (ReferenceEquals(frames, null))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
var traceStringBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
for (var i = 0; i < frames.Length; i++)
|
||||||
|
{
|
||||||
|
StackFrame frame = frames[i];
|
||||||
|
|
||||||
|
if (frame.GetFileLineNumber() < 1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
traceStringBuilder.AppendLine($"File: {frame.GetFileName()}");
|
||||||
|
traceStringBuilder.AppendLine($"Method: {frame.GetMethod().Name}");
|
||||||
|
traceStringBuilder.AppendLine($"LineNumber: {frame.GetFileLineNumber()}");
|
||||||
|
|
||||||
|
if (i == frames.Length - 1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
traceStringBuilder.AppendLine(" ---> ");
|
||||||
|
}
|
||||||
|
|
||||||
|
string stackTraceFootprints = traceStringBuilder.ToString();
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(stackTraceFootprints))
|
||||||
|
return "NO DETECTED FOOTPRINTS";
|
||||||
|
|
||||||
|
return stackTraceFootprints;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region DirectoryInfo Extensions
|
||||||
|
public static IEnumerable<FileInfo> GetFilesByExtensions(this DirectoryInfo dir, params string[] extensions)
|
||||||
|
{
|
||||||
|
if (extensions == null)
|
||||||
|
throw new ArgumentNullException("extensions");
|
||||||
|
IEnumerable<FileInfo> files = dir.EnumerateFiles();
|
||||||
|
return files.Where(f => extensions.Contains(f.Extension));
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region DateTime Extensions
|
||||||
|
//https://stackoverflow.com/questions/5672862/check-if-datetime-instance-falls-in-between-other-two-datetime-objects
|
||||||
|
public static bool IsBetweenTwoDates(this DateTime dt, DateTime start, DateTime end)
|
||||||
|
{
|
||||||
|
return dt >= start && dt <= end;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Form Extensions
|
||||||
|
[DllImport("user32")]
|
||||||
|
public static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
|
||||||
|
|
||||||
|
[DllImport("user32")]
|
||||||
|
public static extern bool EnableMenuItem(IntPtr hMenu, uint itemId, uint uEnable);
|
||||||
|
|
||||||
|
public static void DisableCloseButton(this Form form)
|
||||||
|
{
|
||||||
|
// The 1 parameter means to gray out. 0xF060 is SC_CLOSE.
|
||||||
|
EnableMenuItem(GetSystemMenu(form.Handle, false), 0xF060, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void EnableCloseButton(this Form form)
|
||||||
|
{
|
||||||
|
// The zero parameter means to enable. 0xF060 is SC_CLOSE.
|
||||||
|
EnableMenuItem(GetSystemMenu(form.Handle, false), 0xF060, 0);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Utility Functions
|
||||||
|
private static DialogResult ShowOverrideWarning(string dest)
|
||||||
|
{
|
||||||
|
DialogResult box = MessageBox.Show("A file with a similar name was detected in the directory as '" + dest +
|
||||||
|
"'.\n\nWould you like to override it?", "Novetus - Override Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||||
|
|
||||||
|
return box;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void FixedFileCopy(string src, string dest, bool overwrite, bool overwritewarning = false)
|
||||||
|
{
|
||||||
|
if (File.Exists(dest))
|
||||||
|
{
|
||||||
|
if (overwrite && overwritewarning)
|
||||||
|
{
|
||||||
|
if (ShowOverrideWarning(dest) == DialogResult.No)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
File.SetAttributes(dest, FileAttributes.Normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
File.Copy(src, dest, overwrite);
|
||||||
|
File.SetAttributes(dest, FileAttributes.Normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void FixedFileDelete(string src)
|
||||||
|
{
|
||||||
|
if (File.Exists(src))
|
||||||
|
{
|
||||||
|
File.SetAttributes(src, FileAttributes.Normal);
|
||||||
|
File.Delete(src);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void FixedFileMove(string src, string dest, bool overwrite, bool overwritewarning = false)
|
||||||
|
{
|
||||||
|
if (src.Equals(dest))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!File.Exists(dest))
|
||||||
|
{
|
||||||
|
File.SetAttributes(src, FileAttributes.Normal);
|
||||||
|
File.Move(src, dest);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (overwrite)
|
||||||
|
{
|
||||||
|
if (overwritewarning)
|
||||||
|
{
|
||||||
|
if (ShowOverrideWarning(dest) == DialogResult.No)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FixedFileDelete(dest);
|
||||||
|
File.SetAttributes(src, FileAttributes.Normal);
|
||||||
|
File.Move(src, dest);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new IOException("Cannot create a file when that file already exists. FixedFileMove cannot override files with overwrite disabled.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//modified from the following:
|
||||||
|
//https://stackoverflow.com/questions/28887314/performance-of-image-loading
|
||||||
|
//https://stackoverflow.com/questions/2479771/c-why-am-i-getting-the-process-cannot-access-the-file-because-it-is-being-u
|
||||||
|
public static Image LoadImage(string fileFullName, string fallbackFileFullName = "")
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(fileFullName))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
Image image = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (MemoryStream ms = new MemoryStream(File.ReadAllBytes(fileFullName)))
|
||||||
|
{
|
||||||
|
image = Image.FromStream(ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
// PropertyItems seem to get lost when fileStream is closed to quickly (?); perhaps
|
||||||
|
// this is the reason Microsoft didn't want to close it in the first place.
|
||||||
|
PropertyItem[] items = image.PropertyItems;
|
||||||
|
|
||||||
|
foreach (PropertyItem item in items)
|
||||||
|
{
|
||||||
|
image.SetPropertyItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if URI || LAUNCHER || CMD || BASICLAUNCHER
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogExceptions(ex);
|
||||||
|
#else
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
if (!string.IsNullOrWhiteSpace(fallbackFileFullName))
|
||||||
|
image = LoadImage(fallbackFileFullName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
//https://social.msdn.microsoft.com/Forums/vstudio/en-US/b0c31115-f6f0-4de5-a62d-d766a855d4d1/directorygetfiles-with-searchpattern-to-get-all-dll-and-exe-files-in-one-call?forum=netfxbcl
|
||||||
|
public static string[] GetFiles(string path, string searchPattern, SearchOption searchOption)
|
||||||
|
{
|
||||||
|
string[] searchPatterns = searchPattern.Split('|');
|
||||||
|
List<string> files = new List<string>();
|
||||||
|
foreach (string sp in searchPatterns)
|
||||||
|
files.AddRange(System.IO.Directory.GetFiles(path, sp, searchOption));
|
||||||
|
files.Sort();
|
||||||
|
return files.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Credit to Carrot for the original code. Rewote it to be smaller.
|
||||||
|
public static string CryptStringWithByte(string word)
|
||||||
|
{
|
||||||
|
byte[] bytes = Encoding.ASCII.GetBytes(word);
|
||||||
|
string result = "";
|
||||||
|
for (int i = 0; i < bytes.Length; i++) { result += Convert.ToChar(0x55 ^ bytes[i]); }
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//https://stackoverflow.com/questions/1879395/how-do-i-generate-a-stream-from-a-string
|
||||||
|
public static Stream GenerateStreamFromString(string s)
|
||||||
|
{
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var writer = new StreamWriter(stream);
|
||||||
|
writer.Write(s);
|
||||||
|
writer.Flush();
|
||||||
|
stream.Position = 0;
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
//https://stackoverflow.com/questions/14488796/does-net-provide-an-easy-way-convert-bytes-to-kb-mb-gb-etc
|
||||||
|
private static readonly string[] SizeSuffixes =
|
||||||
|
{ "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
|
||||||
|
public static string SizeSuffix(Int64 value, int decimalPlaces = 1)
|
||||||
|
{
|
||||||
|
if (decimalPlaces < 0) { throw new ArgumentOutOfRangeException("decimalPlaces"); }
|
||||||
|
if (value < 0) { return "-" + SizeSuffix(-value, decimalPlaces); }
|
||||||
|
if (value == 0) { return string.Format("{0:n" + decimalPlaces + "} bytes", 0); }
|
||||||
|
|
||||||
|
// mag is 0 for bytes, 1 for KB, 2, for MB, etc.
|
||||||
|
int mag = (int)Math.Log(value, 1024);
|
||||||
|
|
||||||
|
// 1L << (mag * 10) == 2 ^ (10 * mag)
|
||||||
|
// [i.e. the number of bytes in the unit corresponding to mag]
|
||||||
|
decimal adjustedSize = (decimal)value / (1L << (mag * 10));
|
||||||
|
|
||||||
|
// make adjustment when the value is large enough that
|
||||||
|
// it would round up to 1000 or more
|
||||||
|
if (Math.Round(adjustedSize, decimalPlaces) >= 1000)
|
||||||
|
{
|
||||||
|
mag += 1;
|
||||||
|
adjustedSize /= 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format("{0:n" + decimalPlaces + "} {1}",
|
||||||
|
adjustedSize,
|
||||||
|
SizeSuffixes[mag]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//https://stackoverflow.com/questions/11927116/getting-files-recursively-skip-files-directories-that-cannot-be-read
|
||||||
|
public static string[] FindAllFiles(string rootDir)
|
||||||
|
{
|
||||||
|
var pathsToSearch = new Queue<string>();
|
||||||
|
var foundFiles = new List<string>();
|
||||||
|
|
||||||
|
pathsToSearch.Enqueue(rootDir);
|
||||||
|
|
||||||
|
while (pathsToSearch.Count > 0)
|
||||||
|
{
|
||||||
|
var dir = pathsToSearch.Dequeue();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var files = Directory.GetFiles(dir);
|
||||||
|
foreach (var file in Directory.GetFiles(dir))
|
||||||
|
{
|
||||||
|
foundFiles.Add(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var subDir in Directory.GetDirectories(dir))
|
||||||
|
{
|
||||||
|
pathsToSearch.Enqueue(subDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#if URI || LAUNCHER || CMD || BASICLAUNCHER
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogExceptions(ex);
|
||||||
|
#else
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return foundFiles.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
//https://stackoverflow.com/questions/66667263/i-want-to-remove-special-characters-from-file-name-without-affecting-extension-i
|
||||||
|
//https://stackoverflow.com/questions/3218910/rename-a-file-in-c-sharp
|
||||||
|
|
||||||
|
public static bool FileHasInvalidChars(string path)
|
||||||
|
{
|
||||||
|
string fileName = Path.GetFileName(path);
|
||||||
|
|
||||||
|
if (Regex.Match(fileName, @"[^\w-.'_!()& ]") != Match.Empty)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RenameFileWithInvalidChars(string path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!FileHasInvalidChars(path))
|
||||||
|
return;
|
||||||
|
|
||||||
|
string pathWithoutFilename = Path.GetDirectoryName(path);
|
||||||
|
string fileName = Path.GetFileName(path);
|
||||||
|
fileName = Regex.Replace(fileName, @"[^\w-.'_!()& ]", "");
|
||||||
|
string finalPath = pathWithoutFilename + "\\" + fileName;
|
||||||
|
|
||||||
|
FixedFileMove(path, finalPath, File.Exists(finalPath));
|
||||||
|
}
|
||||||
|
#if URI || LAUNCHER || CMD || BASICLAUNCHER
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogExceptions(ex);
|
||||||
|
#else
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//http://stevenhollidge.blogspot.com/2012/06/async-taskdelay.html
|
||||||
|
public static Task Delay(int milliseconds)
|
||||||
|
{
|
||||||
|
var tcs = new TaskCompletionSource<object>();
|
||||||
|
new System.Threading.Timer(_ => tcs.SetResult(null)).Change(milliseconds, -1);
|
||||||
|
return tcs.Task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LogPrint(string text, int type = 1)
|
||||||
|
{
|
||||||
|
Logger log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case 2:
|
||||||
|
log.Error(text);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
log.Warn(text);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log.Info(text);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if LAUNCHER || CMD || URI || BASICLAUNCHER
|
||||||
|
public static void LogExceptions(Exception ex)
|
||||||
|
{
|
||||||
|
LogPrint("EXCEPTION|MESSAGE: " + (ex.Message != null ? ex.Message.ToString() : "N/A"), 2);
|
||||||
|
LogPrint("EXCEPTION|STACK TRACE: " + (!string.IsNullOrWhiteSpace(ex.StackTrace) ? ex.StackTrace : "N/A"), 2);
|
||||||
|
LogPrint("EXCEPTION|ADDITIONAL INFO: " + (ex != null ? ex.ToString() : "N/A"), 2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//https://stackoverflow.com/questions/27108264/how-to-properly-make-a-http-web-get-request
|
||||||
|
|
||||||
|
private static string HttpGetInternal(string uri)
|
||||||
|
{
|
||||||
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
|
||||||
|
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
|
||||||
|
|
||||||
|
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
||||||
|
{
|
||||||
|
using (Stream stream = response.GetResponseStream())
|
||||||
|
{
|
||||||
|
using (StreamReader reader = new StreamReader(stream))
|
||||||
|
{
|
||||||
|
return reader.ReadToEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static string HttpGet(string uri)
|
||||||
|
{
|
||||||
|
int tries = 0;
|
||||||
|
int triesMax = 5;
|
||||||
|
string exceptionMessage = "";
|
||||||
|
|
||||||
|
while (tries < triesMax)
|
||||||
|
{
|
||||||
|
tries++;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return HttpGetInternal(uri);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
#if URI || LAUNCHER || CMD || BASICLAUNCHER
|
||||||
|
LogExceptions(ex);
|
||||||
|
#endif
|
||||||
|
exceptionMessage = ex.Message;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "ERROR: " + exceptionMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DrawBorderSimple(Graphics graphics, Rectangle bounds, Color color, ButtonBorderStyle style, int width)
|
||||||
|
{
|
||||||
|
//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||||
|
ControlPaint.DrawBorder(graphics, bounds,
|
||||||
|
color, width, style,
|
||||||
|
color, width, style,
|
||||||
|
color, width, style,
|
||||||
|
color, width, style);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsIPValid(string IP)
|
||||||
|
{
|
||||||
|
IPAddress address;
|
||||||
|
if (IPAddress.TryParse(IP, out address))
|
||||||
|
{
|
||||||
|
switch (address.AddressFamily)
|
||||||
|
{
|
||||||
|
case System.Net.Sockets.AddressFamily.InterNetwork:
|
||||||
|
return true;
|
||||||
|
case System.Net.Sockets.AddressFamily.InterNetworkV6:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//converted from https://facreationz.wordpress.com/2014/12/11/c-know-if-running-under-wine/
|
||||||
|
public static bool IsWineRunning()
|
||||||
|
{
|
||||||
|
string processName = "winlogon";
|
||||||
|
var p = Process.GetProcessesByName(processName).Count();
|
||||||
|
return (p <= 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if LAUNCHER
|
||||||
|
public static void ConsolePrint(string text, int type, RichTextBox box, bool noLog = false, bool noTime = false)
|
||||||
|
{
|
||||||
|
if (box == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!noTime)
|
||||||
|
{
|
||||||
|
box.AppendText("[" + DateTime.Now.ToShortTimeString() + "] - ", Color.White);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
box.AppendText(text, Color.White);
|
||||||
|
if (!noLog)
|
||||||
|
LogPrint(text);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
box.AppendText(text, Color.Red);
|
||||||
|
if (!noLog)
|
||||||
|
LogPrint(text, 2);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
box.AppendText(text, Color.Lime);
|
||||||
|
if (!noLog)
|
||||||
|
LogPrint(text);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
box.AppendText(text, Color.Aqua);
|
||||||
|
if (!noLog)
|
||||||
|
LogPrint(text);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
box.AppendText(text, Color.Yellow);
|
||||||
|
if (!noLog)
|
||||||
|
LogPrint(text, 3);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
box.AppendText(text, Color.LightSalmon);
|
||||||
|
if (!noLog)
|
||||||
|
LogPrint(text);
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
box.AppendText(text, Color.Black);
|
||||||
|
if (!noLog)
|
||||||
|
LogPrint(text);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
box.AppendText(Environment.NewLine, Color.White);
|
||||||
|
}
|
||||||
|
#elif CMD
|
||||||
|
public static void ConsolePrint(string text, int type, bool notime = false, bool noLog = false)
|
||||||
|
{
|
||||||
|
if (!notime)
|
||||||
|
{
|
||||||
|
ConsoleText("[" + DateTime.Now.ToShortTimeString() + "] - ", ConsoleColor.White);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case 2:
|
||||||
|
ConsoleText(text, ConsoleColor.Red);
|
||||||
|
if (!noLog)
|
||||||
|
LogPrint(text, 2);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
ConsoleText(text, ConsoleColor.Green);
|
||||||
|
if (!noLog)
|
||||||
|
LogPrint(text);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
ConsoleText(text, ConsoleColor.Cyan);
|
||||||
|
if (!noLog)
|
||||||
|
LogPrint(text);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
ConsoleText(text, ConsoleColor.Yellow);
|
||||||
|
if (!noLog)
|
||||||
|
LogPrint(text, 3);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
default:
|
||||||
|
ConsoleText(text, ConsoleColor.White);
|
||||||
|
if (!noLog)
|
||||||
|
LogPrint(text);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConsoleText(Environment.NewLine, ConsoleColor.White);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ConsoleText(string text, ConsoleColor color)
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = color;
|
||||||
|
Console.Write(text);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Tab Control without Header
|
||||||
|
//https://stackoverflow.com/questions/23247941/c-sharp-how-to-remove-tabcontrol-border
|
||||||
|
|
||||||
|
public partial class TabControlWithoutHeader : TabControl
|
||||||
|
{
|
||||||
|
public TabControlWithoutHeader()
|
||||||
|
{
|
||||||
|
if (!DesignMode) Multiline = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void WndProc(ref Message m)
|
||||||
|
{
|
||||||
|
if (m.Msg == 0x1328 && !DesignMode)
|
||||||
|
m.Result = new IntPtr(1);
|
||||||
|
else
|
||||||
|
base.WndProc(ref m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
#region Usings
|
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Tab Control without Header
|
|
||||||
//https://stackoverflow.com/questions/23247941/c-sharp-how-to-remove-tabcontrol-border
|
|
||||||
|
|
||||||
public partial class TabControlWithoutHeader : TabControl
|
|
||||||
{
|
|
||||||
public TabControlWithoutHeader()
|
|
||||||
{
|
|
||||||
if (!DesignMode) Multiline = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void WndProc(ref Message m)
|
|
||||||
{
|
|
||||||
if (m.Msg == 0x1328 && !DesignMode)
|
|
||||||
m.Result = new IntPtr(1);
|
|
||||||
else
|
|
||||||
base.WndProc(ref m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
#region Usings
|
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Form Extensions
|
|
||||||
public static class FormExt
|
|
||||||
{
|
|
||||||
[DllImport("user32")]
|
|
||||||
public static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
|
|
||||||
|
|
||||||
[DllImport("user32")]
|
|
||||||
public static extern bool EnableMenuItem(IntPtr hMenu, uint itemId, uint uEnable);
|
|
||||||
|
|
||||||
public static void DisableCloseButton(this Form form)
|
|
||||||
{
|
|
||||||
// The 1 parameter means to gray out. 0xF060 is SC_CLOSE.
|
|
||||||
EnableMenuItem(GetSystemMenu(form.Handle, false), 0xF060, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void EnableCloseButton(this Form form)
|
|
||||||
{
|
|
||||||
// The zero parameter means to enable. 0xF060 is SC_CLOSE.
|
|
||||||
EnableMenuItem(GetSystemMenu(form.Handle, false), 0xF060, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
Loading…
Reference in New Issue