diff --git a/DBEditor/.gitignore b/DBEditor/.gitignore new file mode 100644 index 00000000..4eddcb59 --- /dev/null +++ b/DBEditor/.gitignore @@ -0,0 +1,55 @@ + +# Compiled source # +################### +*.com +*.class +*.dll +*.exe +*.o +*.so +*/bin/* +*/obj/* +bin/* +obj/* + +# Packages # +############ +# it's better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z +*.dmg +*.gz +*.iso +*.jar +*.rar +*.tar +*.zip + +# Logs and databases # +###################### +*.log +*.sql +*.sqlite + +# OS generated files # +###################### +.DS_Store? +ehthumbs.db +Icon? +Thumbs.db + + +# Visual Studio shit Motherfucka # +################################## +*.suo +*.sdf +*.opensdf +*.cache +*.pdb +*.csproj.user +*/_ReSharper*/* +*.user + +#Template Bat file# +################### +myass.bat \ No newline at end of file diff --git a/DBEditor/CommandList.cs b/DBEditor/CommandList.cs new file mode 100644 index 00000000..617ae9f5 --- /dev/null +++ b/DBEditor/CommandList.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace TShockDBEditor +{ + public class Commandlist + { + public static List CommandList = new List(); + + public static void AddCommands() + { + CommandList.Add("reservedslot"); + CommandList.Add("canwater"); + CommandList.Add("canlava"); + CommandList.Add("warp"); + CommandList.Add("kick"); + CommandList.Add("ban"); + CommandList.Add("unban"); + CommandList.Add("whitelist"); + CommandList.Add("maintenace"); + CommandList.Add("causeevents"); + CommandList.Add("spawnboss"); + CommandList.Add("spawnmob"); + CommandList.Add("tp"); + CommandList.Add("tphere"); + CommandList.Add("managewarp"); + CommandList.Add("editspawn"); + CommandList.Add("cfg"); + CommandList.Add("time"); + CommandList.Add("pvpfun"); + CommandList.Add("logs"); + CommandList.Add("kill"); + CommandList.Add("butcher"); + CommandList.Add("cheat"); + CommandList.Add("immunetokick"); + CommandList.Add("immunetoban"); + CommandList.Add("ignorecheatdetection"); + CommandList.Add("ignoregriefdetection"); + CommandList.Add("usebanneditem"); + } + } +} diff --git a/DBEditor/DbExt.cs b/DBEditor/DbExt.cs new file mode 100644 index 00000000..1fcf2f36 --- /dev/null +++ b/DBEditor/DbExt.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace TShockDBEditor +{ + public static class DbExt + { + public static IDbDataParameter AddParameter(this IDbCommand command, string name, object data) + { + var parm = command.CreateParameter(); + parm.ParameterName = name; + parm.Value = data; + command.Parameters.Add(parm); + return parm; + } + + static Dictionary> ReadFuncs = new Dictionary>() + { + {typeof(bool), (s, i) => s.GetBoolean(i)}, + {typeof(byte), (s, i) => s.GetByte(i)}, + {typeof(Int16), (s, i) => s.GetInt16(i)}, + {typeof(Int32), (s, i) => s.GetInt32(i)}, + {typeof(Int64), (s, i) => s.GetInt64(i)}, + {typeof(string), (s, i) => s.GetString(i)}, + {typeof(decimal), (s, i) => s.GetDecimal(i)}, + {typeof(float), (s, i) => s.GetFloat(i)}, + {typeof(double), (s, i) => s.GetDouble(i)}, + }; + + public static T Get(this IDataReader reader, string column) + { + return reader.Get(reader.GetOrdinal(column)); + } + + public static T Get(this IDataReader reader, int column) + { + if (ReadFuncs.ContainsKey(typeof(T))) + return (T)ReadFuncs[typeof(T)](reader, column); + + throw new NotImplementedException(); + } + } +} diff --git a/DBEditor/Group.cs b/DBEditor/Group.cs new file mode 100644 index 00000000..acedf451 --- /dev/null +++ b/DBEditor/Group.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; + +namespace TShockDBEditor +{ + public class Group + { + public readonly List permissions = new List(); + private readonly List negatedpermissions = new List(); + + public int ID { get; protected set; } + public string Name { get; set; } + public Group Parent { get; set; } + public int Order { get; set; } + + public Group(int id, string groupname, int order, Group parentgroup = null) + { + Order = order; + ID = id; + Name = groupname; + Parent = parentgroup; + } + } +} \ No newline at end of file diff --git a/DBEditor/Itemlist.cs b/DBEditor/Itemlist.cs new file mode 100644 index 00000000..e4462e33 --- /dev/null +++ b/DBEditor/Itemlist.cs @@ -0,0 +1,342 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace TShockDBEditor +{ + public class Itemlist + { + public static List ItemList = new List(); + + public static void AddItems() + { + ItemList.Add("Iron Pickaxe"); + ItemList.Add("Dirt Block"); + ItemList.Add("Stone Block"); + ItemList.Add("Iron Broadsword"); + ItemList.Add("Mushroom"); + ItemList.Add("Iron Shortsword"); + ItemList.Add("Iron Hammer"); + ItemList.Add("Torch"); + ItemList.Add("Wood"); + ItemList.Add("Iron Axe"); + ItemList.Add("Iron Ore"); + ItemList.Add("Copper Ore"); + ItemList.Add("Gold Ore"); + ItemList.Add("Silver Ore"); + ItemList.Add("Copper Watch"); + ItemList.Add("Silver Watch"); + ItemList.Add("Gold Watch"); + ItemList.Add("Depth Meter"); + ItemList.Add("Gold Bar"); + ItemList.Add("Copper Bar"); + ItemList.Add("Silver Bar"); + ItemList.Add("Iron Bar"); + ItemList.Add("Gel"); + ItemList.Add("Wooden Sword"); + ItemList.Add("Wooden Door"); + ItemList.Add("Stone Wall"); + ItemList.Add("Acorn"); + ItemList.Add("Lesser Healing Potion"); + ItemList.Add("Life Crystal"); + ItemList.Add("Dirt Wall"); + ItemList.Add("Bottle"); + ItemList.Add("Wooden Table"); + ItemList.Add("Furnace"); + ItemList.Add("Wooden Chair"); + ItemList.Add("Iron Anvil"); + ItemList.Add("Work Bench"); + ItemList.Add("Goggles"); + ItemList.Add("Lens"); + ItemList.Add("Wooden Bow"); + ItemList.Add("Wooden Arrow"); + ItemList.Add("Flaming Arrow"); + ItemList.Add("Shuriken"); + ItemList.Add("Suspicious Looking Eye"); + ItemList.Add("Demon Bow"); + ItemList.Add("War Axe of the Night"); + ItemList.Add("Light's Bane"); + ItemList.Add("Unholy Arrow"); + ItemList.Add("Chest"); + ItemList.Add("Band of Regeneration"); + ItemList.Add("Magic Mirror"); + ItemList.Add("Jester's Arrow"); + ItemList.Add("Angel Statue"); + ItemList.Add("Cloud in a Bottle"); + ItemList.Add("Hermes Boots"); + ItemList.Add("Enchanted Boomerang"); + ItemList.Add("Demonite Ore"); + ItemList.Add("Demonite Bar"); + ItemList.Add("Heart"); + ItemList.Add("Corrupt Seeds"); + ItemList.Add("Vile Mushroom"); + ItemList.Add("Ebonstone Block"); + ItemList.Add("Grass Seeds"); + ItemList.Add("Sunflower"); + ItemList.Add("Vilethorn"); + ItemList.Add("Starfury"); + ItemList.Add("Purification Powder"); + ItemList.Add("Vile Powder"); + ItemList.Add("Rotten Chunk"); + ItemList.Add("Worm Tooth"); + ItemList.Add("Worm Food"); + ItemList.Add("Copper Coin"); + ItemList.Add("Silver Coin"); + ItemList.Add("Gold Coin"); + ItemList.Add("Platinum Coin"); + ItemList.Add("Fallen Star"); + ItemList.Add("Copper Greaves"); + ItemList.Add("Iron Greaves"); + ItemList.Add("Silver Greaves"); + ItemList.Add("Gold Greaves"); + ItemList.Add("Copper Chainmail"); + ItemList.Add("Iron Chainmail"); + ItemList.Add("Silver Chainmail"); + ItemList.Add("Gold Chainmail"); + ItemList.Add("Grappling Hook"); + ItemList.Add("Iron Chain"); + ItemList.Add("Shadow Scale"); + ItemList.Add("Piggy Bank"); + ItemList.Add("Mining Helmet"); + ItemList.Add("Copper Helmet"); + ItemList.Add("Iron Helmet"); + ItemList.Add("Silver Helmet"); + ItemList.Add("Gold Helmet"); + ItemList.Add("Wood Wall"); + ItemList.Add("Wood Platform"); + ItemList.Add("Flintlock Pistol"); + ItemList.Add("Musket"); + ItemList.Add("Musket Ball"); + ItemList.Add("Minishark"); + ItemList.Add("Iron Bow"); + ItemList.Add("Shadow Greaves"); + ItemList.Add("Shadow Scalemail"); + ItemList.Add("Shadow Helmet"); + ItemList.Add("Nightmare Pickaxe"); + ItemList.Add("The Breaker"); + ItemList.Add("Candle"); + ItemList.Add("Copper Chandelier"); + ItemList.Add("Silver Chandelier"); + ItemList.Add("Gold Chandelier"); + ItemList.Add("Mana Crystal"); + ItemList.Add("Lesser Mana Potion"); + ItemList.Add("Band of Starpower"); + ItemList.Add("Flower of Fire"); + ItemList.Add("Magic Missile"); + ItemList.Add("Dirt Rod"); + ItemList.Add("Orb of Light"); + ItemList.Add("Meteorite"); + ItemList.Add("Meteorite Bar"); + ItemList.Add("Hook"); + ItemList.Add("Flamarang"); + ItemList.Add("Molten Fury"); + ItemList.Add("Fiery Greatsword"); + ItemList.Add("Molten Pickaxe"); + ItemList.Add("Meteor Helmet"); + ItemList.Add("Meteor Suit"); + ItemList.Add("Meteor Leggings"); + ItemList.Add("Bottled Water"); + ItemList.Add("Space Gun"); + ItemList.Add("Rocket Boots"); + ItemList.Add("Gray Brick"); + ItemList.Add("Gray Brick Wall"); + ItemList.Add("Red Brick"); + ItemList.Add("Red Brick Wall"); + ItemList.Add("Clay Block"); + ItemList.Add("Blue Brick"); + ItemList.Add("Blue Brick Wall"); + ItemList.Add("Chain Lantern"); + ItemList.Add("Green Brick"); + ItemList.Add("Green Brick Wall"); + ItemList.Add("Pink Brick"); + ItemList.Add("Pink Brick Wall"); + ItemList.Add("Gold Brick"); + ItemList.Add("Gold Brick Wall"); + ItemList.Add("Silver Brick"); + ItemList.Add("Silver Brick Wall"); + ItemList.Add("Copper Brick"); + ItemList.Add("Copper Brick Wall"); + ItemList.Add("Spike"); + ItemList.Add("Water Candle"); + ItemList.Add("Book"); + ItemList.Add("Cobweb"); + ItemList.Add("Necro Helmet"); + ItemList.Add("Necro Breastplate"); + ItemList.Add("Necro Greaves"); + ItemList.Add("Bone"); + ItemList.Add("Muramasa"); + ItemList.Add("Cobalt Shield"); + ItemList.Add("Aqua Scepter"); + ItemList.Add("Lucky Horseshoe"); + ItemList.Add("Shiny Red Balloon"); + ItemList.Add("Harpoon"); + ItemList.Add("Spiky Ball"); + ItemList.Add("Ball 'O Hurt"); + ItemList.Add("Blue Moon"); + ItemList.Add("Handgun"); + ItemList.Add("Water Bolt"); + ItemList.Add("Bomb"); + ItemList.Add("Dynamite"); + ItemList.Add("Grenade"); + ItemList.Add("Sand Block"); + ItemList.Add("Glass"); + ItemList.Add("Sign"); + ItemList.Add("Ash Block"); + ItemList.Add("Obsidian"); + ItemList.Add("Hellstone"); + ItemList.Add("Hellstone Bar"); + ItemList.Add("Mud Block"); + ItemList.Add("Sapphire"); + ItemList.Add("Ruby"); + ItemList.Add("Emerald"); + ItemList.Add("Topaz"); + ItemList.Add("Amethyst"); + ItemList.Add("Diamond"); + ItemList.Add("Glowing Mushroom"); + ItemList.Add("Star"); + ItemList.Add("Ivy Whip"); + ItemList.Add("Breathing Reed"); + ItemList.Add("Flipper"); + ItemList.Add("Healing Potion"); + ItemList.Add("Mana Potion"); + ItemList.Add("Blade of Grass"); + ItemList.Add("Thorn Chakrum"); + ItemList.Add("Obsidian Brick"); + ItemList.Add("Obsidian Skull"); + ItemList.Add("Mushroom Grass Seeds"); + ItemList.Add("Jungle Grass Seeds"); + ItemList.Add("Wooden Hammer"); + ItemList.Add("Star Cannon"); + ItemList.Add("Blue Phaseblade"); + ItemList.Add("Red Phaseblade"); + ItemList.Add("Green Phaseblade"); + ItemList.Add("Purple Phaseblade"); + ItemList.Add("White Phaseblade"); + ItemList.Add("Yellow Phaseblade"); + ItemList.Add("Meteor Hamaxe"); + ItemList.Add("Empty Bucket"); + ItemList.Add("Water Bucket"); + ItemList.Add("Lava Bucket"); + ItemList.Add("Jungle Rose"); + ItemList.Add("Stinger"); + ItemList.Add("Vine"); + ItemList.Add("Feral Claws"); + ItemList.Add("Anklet of the Wind"); + ItemList.Add("Staff of Regrowth"); + ItemList.Add("Hellstone Brick"); + ItemList.Add("Whoopie Cushion"); + ItemList.Add("Shackle"); + ItemList.Add("Molten Hamaxe"); + ItemList.Add("Flamelash"); + ItemList.Add("Phoenix Blaster"); + ItemList.Add("Sunfury"); + ItemList.Add("Hellforge"); + ItemList.Add("Clay Pot"); + ItemList.Add("Nature's Gift"); + ItemList.Add("Bed"); + ItemList.Add("Silk"); + ItemList.Add("Lesser Restoration Potion"); + ItemList.Add("Restoration Potion"); + ItemList.Add("Jungle Hat"); + ItemList.Add("Jungle Shirt"); + ItemList.Add("Jungle Pants"); + ItemList.Add("Molten Helmet"); + ItemList.Add("Molten Breastplate"); + ItemList.Add("Molten Greaves"); + ItemList.Add("Meteor Shot"); + ItemList.Add("Sticky Bomb"); + ItemList.Add("Black Lens"); + ItemList.Add("Sunglasses"); + ItemList.Add("Wizard Hat"); + ItemList.Add("Top Hat"); + ItemList.Add("Tuxedo Shirt"); + ItemList.Add("Tuxedo Pants"); + ItemList.Add("Summer Hat"); + ItemList.Add("Bunny Hood"); + ItemList.Add("Plumber's Hat"); + ItemList.Add("Plumber's Shirt"); + ItemList.Add("Plumber's Pants"); + ItemList.Add("Hero's Hat"); + ItemList.Add("Hero's Shirt"); + ItemList.Add("Hero's Pants"); + ItemList.Add("Fish Bowl"); + ItemList.Add("Archaeologist's Hat"); + ItemList.Add("Archaeologist's Jacket"); + ItemList.Add("Archaeologist's Pants"); + ItemList.Add("Black Dye"); + ItemList.Add("Green Dye"); + ItemList.Add("Ninja Hood"); + ItemList.Add("Ninja Shirt"); + ItemList.Add("Ninja Pants"); + ItemList.Add("Leather"); + ItemList.Add("Red Hat"); + ItemList.Add("Goldfish"); + ItemList.Add("Robe"); + ItemList.Add("Robot Hat"); + ItemList.Add("Gold Crown"); + ItemList.Add("Hellfire Arrow"); + ItemList.Add("Sandgun"); + ItemList.Add("Guide Voodoo Doll"); + ItemList.Add("Diving Helmet"); + ItemList.Add("Familiar Shirt"); + ItemList.Add("Familiar Pants"); + ItemList.Add("Familiar Wig"); + ItemList.Add("Demon Scythe"); + ItemList.Add("Night's Edge"); + ItemList.Add("Dark Lance"); + ItemList.Add("Coral"); + ItemList.Add("Cactus"); + ItemList.Add("Trident"); + ItemList.Add("Silver Bullet"); + ItemList.Add("Throwing Knife"); + ItemList.Add("Spear"); + ItemList.Add("Blowpipe"); + ItemList.Add("Glowstick"); + ItemList.Add("Seed"); + ItemList.Add("Wooden Boomerang"); + ItemList.Add("Aglet"); + ItemList.Add("Sticky Glowstick"); + ItemList.Add("Poisoned Knife"); + ItemList.Add("Obsidian Skin Potion"); + ItemList.Add("Regeneration Potion"); + ItemList.Add("Swiftness Potion"); + ItemList.Add("Gills potion"); + ItemList.Add("Ironskin Potion"); + ItemList.Add("Mana Regeneration Potion"); + ItemList.Add("Magic Power Potion"); + ItemList.Add("Featherfall Potion"); + ItemList.Add("Spelunker Potion"); + ItemList.Add("Invisibility Potion"); + ItemList.Add("Shine Potion"); + ItemList.Add("Night Owl Potion"); + ItemList.Add("Battle Potion"); + ItemList.Add("Thorns Potion"); + ItemList.Add("Water Walking Potion"); + ItemList.Add("Archery Potion"); + ItemList.Add("Hunter Potion"); + ItemList.Add("Gravitation Potion"); + ItemList.Add("Gold Chest"); + ItemList.Add("Daybloom Seeds"); + ItemList.Add("Moonglow Seeds"); + ItemList.Add("Blinkroot Seeds"); + ItemList.Add("Deathweed Seeds"); + ItemList.Add("Waterleaf Seeds"); + ItemList.Add("Fireblossom Seeds"); + ItemList.Add("Daybloom"); + ItemList.Add("Moonglow"); + ItemList.Add("Blinkroot"); + ItemList.Add("Deathweed"); + ItemList.Add("Waterleaf"); + ItemList.Add("Fireblossom"); + ItemList.Add("Shark Fin"); + ItemList.Add("Feather"); + ItemList.Add("Tombstone"); + ItemList.Add("Mime Mask"); + ItemList.Add("Antlion Mandible"); + ItemList.Add("Illegal Gun Parts"); + ItemList.Add("The Doctor's Shirt"); + ItemList.Add("The Doctor's Pants"); + } + } +} diff --git a/DBEditor/Main.Designer.cs b/DBEditor/Main.Designer.cs new file mode 100644 index 00000000..21366eb3 --- /dev/null +++ b/DBEditor/Main.Designer.cs @@ -0,0 +1,579 @@ +namespace TShockDBEditor +{ + partial class TShockDBEditor + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.itemListBanned = new System.Windows.Forms.ListBox(); + this.itemListAvailable = new System.Windows.Forms.ListBox(); + this.tabControl = new System.Windows.Forms.TabControl(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.btn_moveAllLeft = new System.Windows.Forms.Button(); + this.btn_moveAllRight = new System.Windows.Forms.Button(); + this.btn_moveLeft = new System.Windows.Forms.Button(); + this.btn_moveRight = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.tabPage2 = new System.Windows.Forms.TabPage(); + this.lst_inheritgrps = new System.Windows.Forms.ComboBox(); + this.label11 = new System.Windows.Forms.Label(); + this.txt_grpname = new System.Windows.Forms.TextBox(); + this.label10 = new System.Windows.Forms.Label(); + this.btn_deletegroup = new System.Windows.Forms.Button(); + this.btn_newgroup = new System.Windows.Forms.Button(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.btn_moveAllLeftCmd = new System.Windows.Forms.Button(); + this.btn_moveLeftCmd = new System.Windows.Forms.Button(); + this.btn_moveRightCmd = new System.Windows.Forms.Button(); + this.lst_AvailableCmds = new System.Windows.Forms.ListBox(); + this.btn_moveAllRightCmd = new System.Windows.Forms.Button(); + this.lst_bannedCmds = new System.Windows.Forms.ListBox(); + this.lst_groupList = new System.Windows.Forms.ListBox(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPage3 = new System.Windows.Forms.TabPage(); + this.btn_OpenLocalDB = new System.Windows.Forms.Button(); + this.tabPage4 = new System.Windows.Forms.TabPage(); + this.btn_connect = new System.Windows.Forms.Button(); + this.label9 = new System.Windows.Forms.Label(); + this.txt_password = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); + this.txt_username = new System.Windows.Forms.TextBox(); + this.txt_port = new System.Windows.Forms.TextBox(); + this.txt_dbname = new System.Windows.Forms.TextBox(); + this.txt_hostname = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label12 = new System.Windows.Forms.Label(); + this.lbl_grpchild = new System.Windows.Forms.Label(); + this.tabControl.SuspendLayout(); + this.tabPage1.SuspendLayout(); + this.tabPage2.SuspendLayout(); + this.tabControl1.SuspendLayout(); + this.tabPage3.SuspendLayout(); + this.tabPage4.SuspendLayout(); + this.SuspendLayout(); + // + // itemListBanned + // + this.itemListBanned.FormattingEnabled = true; + this.itemListBanned.Location = new System.Drawing.Point(321, 19); + this.itemListBanned.Name = "itemListBanned"; + this.itemListBanned.Size = new System.Drawing.Size(275, 290); + this.itemListBanned.TabIndex = 1; + // + // itemListAvailable + // + this.itemListAvailable.FormattingEnabled = true; + this.itemListAvailable.Location = new System.Drawing.Point(7, 19); + this.itemListAvailable.Name = "itemListAvailable"; + this.itemListAvailable.Size = new System.Drawing.Size(275, 290); + this.itemListAvailable.TabIndex = 2; + // + // tabControl + // + this.tabControl.Controls.Add(this.tabPage1); + this.tabControl.Controls.Add(this.tabPage2); + this.tabControl.Location = new System.Drawing.Point(12, 143); + this.tabControl.Name = "tabControl"; + this.tabControl.SelectedIndex = 0; + this.tabControl.Size = new System.Drawing.Size(610, 407); + this.tabControl.TabIndex = 3; + this.tabControl.Visible = false; + // + // tabPage1 + // + this.tabPage1.Controls.Add(this.btn_moveAllLeft); + this.tabPage1.Controls.Add(this.btn_moveAllRight); + this.tabPage1.Controls.Add(this.btn_moveLeft); + this.tabPage1.Controls.Add(this.btn_moveRight); + this.tabPage1.Controls.Add(this.label2); + this.tabPage1.Controls.Add(this.label1); + this.tabPage1.Controls.Add(this.itemListAvailable); + this.tabPage1.Controls.Add(this.itemListBanned); + this.tabPage1.Location = new System.Drawing.Point(4, 22); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding(3); + this.tabPage1.Size = new System.Drawing.Size(602, 381); + this.tabPage1.TabIndex = 0; + this.tabPage1.Text = "Item Bans"; + this.tabPage1.UseVisualStyleBackColor = true; + // + // btn_moveAllLeft + // + this.btn_moveAllLeft.Location = new System.Drawing.Point(288, 193); + this.btn_moveAllLeft.Name = "btn_moveAllLeft"; + this.btn_moveAllLeft.Size = new System.Drawing.Size(27, 23); + this.btn_moveAllLeft.TabIndex = 8; + this.btn_moveAllLeft.Text = "<<"; + this.btn_moveAllLeft.UseVisualStyleBackColor = true; + this.btn_moveAllLeft.Click += new System.EventHandler(this.btn_moveAllLeftItems_Click); + // + // btn_moveAllRight + // + this.btn_moveAllRight.Location = new System.Drawing.Point(288, 106); + this.btn_moveAllRight.Name = "btn_moveAllRight"; + this.btn_moveAllRight.Size = new System.Drawing.Size(27, 23); + this.btn_moveAllRight.TabIndex = 7; + this.btn_moveAllRight.Text = ">>"; + this.btn_moveAllRight.UseVisualStyleBackColor = true; + this.btn_moveAllRight.Click += new System.EventHandler(this.btn_moveAllRightItems_Click); + // + // btn_moveLeft + // + this.btn_moveLeft.Location = new System.Drawing.Point(288, 164); + this.btn_moveLeft.Name = "btn_moveLeft"; + this.btn_moveLeft.Size = new System.Drawing.Size(27, 23); + this.btn_moveLeft.TabIndex = 6; + this.btn_moveLeft.Text = "<"; + this.btn_moveLeft.UseVisualStyleBackColor = true; + this.btn_moveLeft.Click += new System.EventHandler(this.btn_moveLeftItems_Click); + // + // btn_moveRight + // + this.btn_moveRight.Location = new System.Drawing.Point(288, 135); + this.btn_moveRight.Name = "btn_moveRight"; + this.btn_moveRight.Size = new System.Drawing.Size(27, 23); + this.btn_moveRight.TabIndex = 5; + this.btn_moveRight.Text = ">"; + this.btn_moveRight.UseVisualStyleBackColor = true; + this.btn_moveRight.Click += new System.EventHandler(this.btn_moveRightItems_Click); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(318, 3); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(86, 13); + this.label2.TabIndex = 4; + this.label2.Text = "Blacklisted Items"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(6, 3); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(87, 13); + this.label1.TabIndex = 3; + this.label1.Text = "Whitelisted Items"; + // + // tabPage2 + // + this.tabPage2.Controls.Add(this.lbl_grpchild); + this.tabPage2.Controls.Add(this.label12); + this.tabPage2.Controls.Add(this.lst_inheritgrps); + this.tabPage2.Controls.Add(this.label11); + this.tabPage2.Controls.Add(this.txt_grpname); + this.tabPage2.Controls.Add(this.label10); + this.tabPage2.Controls.Add(this.btn_deletegroup); + this.tabPage2.Controls.Add(this.btn_newgroup); + this.tabPage2.Controls.Add(this.label4); + this.tabPage2.Controls.Add(this.label3); + this.tabPage2.Controls.Add(this.btn_moveAllLeftCmd); + this.tabPage2.Controls.Add(this.btn_moveLeftCmd); + this.tabPage2.Controls.Add(this.btn_moveRightCmd); + this.tabPage2.Controls.Add(this.lst_AvailableCmds); + this.tabPage2.Controls.Add(this.btn_moveAllRightCmd); + this.tabPage2.Controls.Add(this.lst_bannedCmds); + this.tabPage2.Controls.Add(this.lst_groupList); + this.tabPage2.Location = new System.Drawing.Point(4, 22); + this.tabPage2.Name = "tabPage2"; + this.tabPage2.Padding = new System.Windows.Forms.Padding(3); + this.tabPage2.Size = new System.Drawing.Size(602, 381); + this.tabPage2.TabIndex = 1; + this.tabPage2.Text = "Group Manager"; + this.tabPage2.UseVisualStyleBackColor = true; + // + // lst_inheritgrps + // + this.lst_inheritgrps.FormattingEnabled = true; + this.lst_inheritgrps.Location = new System.Drawing.Point(375, 84); + this.lst_inheritgrps.Name = "lst_inheritgrps"; + this.lst_inheritgrps.Size = new System.Drawing.Size(100, 21); + this.lst_inheritgrps.TabIndex = 23; + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Location = new System.Drawing.Point(299, 87); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(65, 13); + this.label11.TabIndex = 22; + this.label11.Text = "Inherit From:"; + // + // txt_grpname + // + this.txt_grpname.Location = new System.Drawing.Point(375, 55); + this.txt_grpname.Name = "txt_grpname"; + this.txt_grpname.Size = new System.Drawing.Size(100, 20); + this.txt_grpname.TabIndex = 21; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(299, 58); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(70, 13); + this.label10.TabIndex = 20; + this.label10.Text = "Group Name:"; + // + // btn_deletegroup + // + this.btn_deletegroup.Location = new System.Drawing.Point(215, 82); + this.btn_deletegroup.Name = "btn_deletegroup"; + this.btn_deletegroup.Size = new System.Drawing.Size(78, 23); + this.btn_deletegroup.TabIndex = 19; + this.btn_deletegroup.Text = "Delete Group"; + this.btn_deletegroup.UseVisualStyleBackColor = true; + this.btn_deletegroup.Click += new System.EventHandler(this.btn_deletegroup_Click); + // + // btn_newgroup + // + this.btn_newgroup.Location = new System.Drawing.Point(215, 53); + this.btn_newgroup.Name = "btn_newgroup"; + this.btn_newgroup.Size = new System.Drawing.Size(78, 23); + this.btn_newgroup.TabIndex = 18; + this.btn_newgroup.Text = "New Group"; + this.btn_newgroup.UseVisualStyleBackColor = true; + this.btn_newgroup.Click += new System.EventHandler(this.btn_newgroup_Click); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(324, 144); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(114, 13); + this.label4.TabIndex = 17; + this.label4.Text = "Whitelisted Commands"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(6, 145); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(99, 13); + this.label3.TabIndex = 16; + this.label3.Text = "Banned Commands"; + // + // btn_moveAllLeftCmd + // + this.btn_moveAllLeftCmd.Location = new System.Drawing.Point(291, 300); + this.btn_moveAllLeftCmd.Name = "btn_moveAllLeftCmd"; + this.btn_moveAllLeftCmd.Size = new System.Drawing.Size(27, 23); + this.btn_moveAllLeftCmd.TabIndex = 15; + this.btn_moveAllLeftCmd.Text = "<<"; + this.btn_moveAllLeftCmd.UseVisualStyleBackColor = true; + this.btn_moveAllLeftCmd.Click += new System.EventHandler(this.btn_moveAllLeftCmd_Click); + // + // btn_moveLeftCmd + // + this.btn_moveLeftCmd.Location = new System.Drawing.Point(291, 270); + this.btn_moveLeftCmd.Name = "btn_moveLeftCmd"; + this.btn_moveLeftCmd.Size = new System.Drawing.Size(27, 23); + this.btn_moveLeftCmd.TabIndex = 14; + this.btn_moveLeftCmd.Text = "<"; + this.btn_moveLeftCmd.UseVisualStyleBackColor = true; + this.btn_moveLeftCmd.Click += new System.EventHandler(this.btn_moveLeftCmd_Click); + // + // btn_moveRightCmd + // + this.btn_moveRightCmd.Location = new System.Drawing.Point(291, 240); + this.btn_moveRightCmd.Name = "btn_moveRightCmd"; + this.btn_moveRightCmd.Size = new System.Drawing.Size(27, 23); + this.btn_moveRightCmd.TabIndex = 13; + this.btn_moveRightCmd.Text = ">"; + this.btn_moveRightCmd.UseVisualStyleBackColor = true; + this.btn_moveRightCmd.Click += new System.EventHandler(this.btn_moveRightCmd_Click); + // + // lst_AvailableCmds + // + this.lst_AvailableCmds.FormattingEnabled = true; + this.lst_AvailableCmds.Location = new System.Drawing.Point(324, 161); + this.lst_AvailableCmds.Name = "lst_AvailableCmds"; + this.lst_AvailableCmds.Size = new System.Drawing.Size(272, 212); + this.lst_AvailableCmds.TabIndex = 12; + // + // btn_moveAllRightCmd + // + this.btn_moveAllRightCmd.Location = new System.Drawing.Point(291, 210); + this.btn_moveAllRightCmd.Name = "btn_moveAllRightCmd"; + this.btn_moveAllRightCmd.Size = new System.Drawing.Size(27, 23); + this.btn_moveAllRightCmd.TabIndex = 11; + this.btn_moveAllRightCmd.Text = ">>"; + this.btn_moveAllRightCmd.UseVisualStyleBackColor = true; + this.btn_moveAllRightCmd.Click += new System.EventHandler(this.btn_moveAllRightCmd_Click); + // + // lst_bannedCmds + // + this.lst_bannedCmds.FormattingEnabled = true; + this.lst_bannedCmds.Location = new System.Drawing.Point(9, 161); + this.lst_bannedCmds.Name = "lst_bannedCmds"; + this.lst_bannedCmds.Size = new System.Drawing.Size(275, 212); + this.lst_bannedCmds.TabIndex = 10; + // + // lst_groupList + // + this.lst_groupList.FormattingEnabled = true; + this.lst_groupList.Location = new System.Drawing.Point(9, 8); + this.lst_groupList.Name = "lst_groupList"; + this.lst_groupList.Size = new System.Drawing.Size(200, 134); + this.lst_groupList.TabIndex = 0; + this.lst_groupList.SelectedIndexChanged += new System.EventHandler(this.lst_groupList_SelectedIndexChanged); + // + // tabControl1 + // + this.tabControl1.Controls.Add(this.tabPage3); + this.tabControl1.Controls.Add(this.tabPage4); + this.tabControl1.Location = new System.Drawing.Point(12, 12); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(610, 125); + this.tabControl1.TabIndex = 6; + // + // tabPage3 + // + this.tabPage3.Controls.Add(this.btn_OpenLocalDB); + this.tabPage3.Location = new System.Drawing.Point(4, 22); + this.tabPage3.Name = "tabPage3"; + this.tabPage3.Padding = new System.Windows.Forms.Padding(3); + this.tabPage3.Size = new System.Drawing.Size(602, 99); + this.tabPage3.TabIndex = 0; + this.tabPage3.Text = "Local Database (SQLite)"; + this.tabPage3.UseVisualStyleBackColor = true; + // + // btn_OpenLocalDB + // + this.btn_OpenLocalDB.Location = new System.Drawing.Point(9, 6); + this.btn_OpenLocalDB.Name = "btn_OpenLocalDB"; + this.btn_OpenLocalDB.Size = new System.Drawing.Size(96, 23); + this.btn_OpenLocalDB.TabIndex = 0; + this.btn_OpenLocalDB.Text = "Open Database"; + this.btn_OpenLocalDB.UseVisualStyleBackColor = true; + this.btn_OpenLocalDB.Click += new System.EventHandler(this.btn_OpenLocalDB_Click); + // + // tabPage4 + // + this.tabPage4.Controls.Add(this.btn_connect); + this.tabPage4.Controls.Add(this.label9); + this.tabPage4.Controls.Add(this.txt_password); + this.tabPage4.Controls.Add(this.label8); + this.tabPage4.Controls.Add(this.txt_username); + this.tabPage4.Controls.Add(this.txt_port); + this.tabPage4.Controls.Add(this.txt_dbname); + this.tabPage4.Controls.Add(this.txt_hostname); + this.tabPage4.Controls.Add(this.label7); + this.tabPage4.Controls.Add(this.label6); + this.tabPage4.Controls.Add(this.label5); + this.tabPage4.Location = new System.Drawing.Point(4, 22); + this.tabPage4.Name = "tabPage4"; + this.tabPage4.Padding = new System.Windows.Forms.Padding(3); + this.tabPage4.Size = new System.Drawing.Size(602, 99); + this.tabPage4.TabIndex = 1; + this.tabPage4.Text = "Remote Database (MySql)"; + this.tabPage4.UseVisualStyleBackColor = true; + // + // btn_connect + // + this.btn_connect.Location = new System.Drawing.Point(213, 63); + this.btn_connect.Name = "btn_connect"; + this.btn_connect.Size = new System.Drawing.Size(75, 23); + this.btn_connect.TabIndex = 10; + this.btn_connect.Text = "Connect"; + this.btn_connect.UseVisualStyleBackColor = true; + this.btn_connect.Click += new System.EventHandler(this.btn_connect_Click); + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(210, 36); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(56, 13); + this.label9.TabIndex = 9; + this.label9.Text = "Password:"; + // + // txt_password + // + this.txt_password.Location = new System.Drawing.Point(272, 33); + this.txt_password.Name = "txt_password"; + this.txt_password.Size = new System.Drawing.Size(100, 20); + this.txt_password.TabIndex = 8; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(208, 10); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(58, 13); + this.label8.TabIndex = 7; + this.label8.Text = "Username:"; + // + // txt_username + // + this.txt_username.Location = new System.Drawing.Point(272, 7); + this.txt_username.Name = "txt_username"; + this.txt_username.Size = new System.Drawing.Size(100, 20); + this.txt_username.TabIndex = 6; + // + // txt_port + // + this.txt_port.Location = new System.Drawing.Point(102, 60); + this.txt_port.Name = "txt_port"; + this.txt_port.Size = new System.Drawing.Size(100, 20); + this.txt_port.TabIndex = 5; + this.txt_port.Text = "3306"; + // + // txt_dbname + // + this.txt_dbname.Location = new System.Drawing.Point(102, 33); + this.txt_dbname.Name = "txt_dbname"; + this.txt_dbname.Size = new System.Drawing.Size(100, 20); + this.txt_dbname.TabIndex = 4; + // + // txt_hostname + // + this.txt_hostname.Location = new System.Drawing.Point(102, 7); + this.txt_hostname.Name = "txt_hostname"; + this.txt_hostname.Size = new System.Drawing.Size(100, 20); + this.txt_hostname.TabIndex = 3; + this.txt_hostname.Text = "localhost"; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(70, 63); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(26, 13); + this.label7.TabIndex = 2; + this.label7.Text = "Port"; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(9, 36); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(87, 13); + this.label6.TabIndex = 1; + this.label6.Text = "Database Name:"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(38, 10); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(58, 13); + this.label5.TabIndex = 0; + this.label5.Text = "Hostname:"; + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Location = new System.Drawing.Point(215, 8); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(65, 13); + this.label12.TabIndex = 24; + this.label12.Text = "Group Child:"; + // + // lbl_grpchild + // + this.lbl_grpchild.AutoSize = true; + this.lbl_grpchild.Location = new System.Drawing.Point(286, 8); + this.lbl_grpchild.Name = "lbl_grpchild"; + this.lbl_grpchild.Size = new System.Drawing.Size(16, 13); + this.lbl_grpchild.TabIndex = 25; + this.lbl_grpchild.Text = " "; + // + // TShockDBEditor + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(634, 562); + this.Controls.Add(this.tabControl1); + this.Controls.Add(this.tabControl); + this.Name = "TShockDBEditor"; + this.Text = "TShockDBEditor"; + this.tabControl.ResumeLayout(false); + this.tabPage1.ResumeLayout(false); + this.tabPage1.PerformLayout(); + this.tabPage2.ResumeLayout(false); + this.tabPage2.PerformLayout(); + this.tabControl1.ResumeLayout(false); + this.tabPage3.ResumeLayout(false); + this.tabPage4.ResumeLayout(false); + this.tabPage4.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.ListBox itemListBanned; + private System.Windows.Forms.ListBox itemListAvailable; + private System.Windows.Forms.TabControl tabControl; + private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button btn_moveAllLeft; + private System.Windows.Forms.Button btn_moveAllRight; + private System.Windows.Forms.Button btn_moveLeft; + private System.Windows.Forms.Button btn_moveRight; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPage3; + private System.Windows.Forms.TabPage tabPage4; + private System.Windows.Forms.Button btn_OpenLocalDB; + private System.Windows.Forms.Button btn_moveAllLeftCmd; + private System.Windows.Forms.Button btn_moveLeftCmd; + private System.Windows.Forms.Button btn_moveRightCmd; + private System.Windows.Forms.ListBox lst_AvailableCmds; + private System.Windows.Forms.Button btn_moveAllRightCmd; + private System.Windows.Forms.ListBox lst_bannedCmds; + private System.Windows.Forms.ListBox lst_groupList; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Button btn_connect; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.TextBox txt_password; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.TextBox txt_username; + private System.Windows.Forms.TextBox txt_port; + private System.Windows.Forms.TextBox txt_dbname; + private System.Windows.Forms.TextBox txt_hostname; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Button btn_deletegroup; + private System.Windows.Forms.Button btn_newgroup; + private System.Windows.Forms.ComboBox lst_inheritgrps; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.TextBox txt_grpname; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.Label lbl_grpchild; + private System.Windows.Forms.Label label12; + } +} + diff --git a/DBEditor/Main.cs b/DBEditor/Main.cs new file mode 100644 index 00000000..77a485ad --- /dev/null +++ b/DBEditor/Main.cs @@ -0,0 +1,435 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.IO; +using MySql.Data.MySqlClient; +using Community.CsharpSqlite.SQLiteClient; +using System.Windows.Forms; + +namespace TShockDBEditor +{ + public partial class TShockDBEditor : Form + { + public OpenFileDialog dialog = new OpenFileDialog(); + public List groups = new List(); + public IDbConnection DB; + public string dbtype = ""; + + public TShockDBEditor() + { + InitializeComponent(); + Itemlist.AddItems(); + Commandlist.AddCommands(); + dialog.FileOk += new CancelEventHandler(dialog_FileOk); + dialog.Filter = "SQLite Database (*.sqlite)|*.sqlite"; + } + + public void LoadSqliteDatabase(string path) + { + string sql = dialog.FileName; + DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql)); + DB.Open(); + dbtype = "sqlite"; + itemListBanned.Items.Clear(); + lst_groupList.Items.Clear(); + lst_AvailableCmds.Items.Clear(); + lst_bannedCmds.Items.Clear(); + itemListAvailable.Items.Clear(); + + using (var com = DB.CreateCommand()) + { + com.CommandText = + "SELECT * FROM Itembans"; + + using (var reader = com.ExecuteReader()) + { + while (reader.Read()) + itemListBanned.Items.Add(reader.Get("ItemName")); + } + } + using (var com = DB.CreateCommand()) + { + com.CommandText = + "SELECT * FROM GroupList"; + + using (var reader = com.ExecuteReader()) + { + while (reader.Read()) + { + lst_groupList.Items.Add(reader.Get("GroupName")); + lst_inheritgrps.Items.Add(reader.Get("GroupName")); + } + } + } + + for (int i = 0; i < Itemlist.ItemList.Count; i++) + { + if (!itemListBanned.Items.Contains(Itemlist.ItemList[i])) + itemListAvailable.Items.Add(Itemlist.ItemList[i]); + } + } + + public void LoadMySqlDatabase(string hostname = "localhost", string port = "3306", string database = "", string username = "", string password = "") + { + DB = new MySqlConnection(); + DB.ConnectionString = + "Server='" + hostname + + "';Port='" + port + + "';Database='" + database + + "';Uid='" + username + + "';Pwd='" + password + "';"; + DB.Open(); + dbtype = "mysql"; + itemListBanned.Items.Clear(); + lst_groupList.Items.Clear(); + lst_AvailableCmds.Items.Clear(); + lst_bannedCmds.Items.Clear(); + itemListAvailable.Items.Clear(); + + using (var com = DB.CreateCommand()) + { + com.CommandText = + "SELECT * FROM Itembans"; + + using (var reader = com.ExecuteReader()) + { + while (reader.Read()) + itemListBanned.Items.Add(reader.Get("ItemName")); + } + } + using (var com = DB.CreateCommand()) + { + com.CommandText = + "SELECT * FROM GroupList"; + + using (var reader = com.ExecuteReader()) + { + while (reader.Read()) + { + lst_groupList.Items.Add(reader.Get("GroupName")); + } + } + } + + for (int i = 0; i < Itemlist.ItemList.Count; i++) + { + if (!itemListBanned.Items.Contains(Itemlist.ItemList[i])) + itemListAvailable.Items.Add(Itemlist.ItemList[i]); + } + } + + #region BannedItemsTab + public void btn_moveAllRightItems_Click(object sender, EventArgs e) + { + foreach (object item in itemListAvailable.Items) + { + itemListBanned.Items.Add(item); + + using (var com = DB.CreateCommand()) + { + com.CommandText = "INSERT INTO ItemBans (ItemName) VALUES (@itemname);"; + com.AddParameter("@itemname", item.ToString()); + com.ExecuteNonQuery(); + com.Parameters.Clear(); + } + } + itemListAvailable.Items.Clear(); + } + + private void btn_moveAllLeftItems_Click(object sender, EventArgs e) + { + foreach (object item in itemListBanned.Items) + { + itemListAvailable.Items.Add(item); + + using (var com = DB.CreateCommand()) + { + com.CommandText = "DELETE FROM ItemBans WHERE ItemName=@itemname;"; + com.AddParameter("@itemname", item.ToString()); + com.ExecuteNonQuery(); + com.Parameters.Clear(); + } + } + itemListBanned.Items.Clear(); + } + + private void btn_moveRightItems_Click(object sender, EventArgs e) + { + if (itemListAvailable.SelectedItem != null) + { + itemListBanned.Items.Add(itemListAvailable.SelectedItem); + + using (var com = DB.CreateCommand()) + { + com.CommandText = "INSERT INTO ItemBans (ItemName) VALUES (@itemname);"; + com.AddParameter("@itemname", itemListAvailable.SelectedItem.ToString()); + com.ExecuteNonQuery(); + } + + itemListAvailable.Items.Remove(itemListAvailable.SelectedItem); + } + } + + private void btn_moveLeftItems_Click(object sender, EventArgs e) + { + if (itemListBanned.SelectedItem != null) + { + itemListAvailable.Items.Add(itemListBanned.SelectedItem); + + using (var com = DB.CreateCommand()) + { + com.CommandText = "DELETE FROM ItemBans WHERE ItemName=@itemname;"; + com.AddParameter("@itemname", itemListBanned.SelectedItem.ToString()); + com.ExecuteNonQuery(); + } + + itemListBanned.Items.Remove(itemListBanned.SelectedItem); + } + } + #endregion + + #region GroupTab + + private void lst_groupList_SelectedIndexChanged(object sender, EventArgs e) + { + UpdateGroupIndex(lst_groupList.SelectedIndex); + } + + private void UpdateGroupIndex(int index) + { + try + { + using (var com = DB.CreateCommand()) + { + lst_AvailableCmds.Items.Clear(); + lst_bannedCmds.Items.Clear(); + + com.CommandText = + "SELECT * FROM GroupList WHERE GroupName=@groupname"; + com.AddParameter("@groupname", lst_groupList.Items[index].ToString()); + + lbl_grpchild.Text = ""; + + using (var reader = com.ExecuteReader()) + { + while (reader.Read()) + { + foreach (string command in reader.Get("Commands").Split(',')) + { + if (lst_groupList.Items.Contains(command) || command == "") + lbl_grpchild.Text = command; + else + lst_AvailableCmds.Items.Add(command); + } + } + } + + if (lbl_grpchild.Text == "") + lbl_grpchild.Text = "none"; + + for (int i = 0; i < Commandlist.CommandList.Count; i++) + { + if (!lst_AvailableCmds.Items.Contains(Commandlist.CommandList[i])) + lst_bannedCmds.Items.Add(Commandlist.CommandList[i]); + } + } + } + catch { } + } + + private void btn_moveAllRightCmd_Click(object sender, EventArgs e) + { + try + { + var sb = new StringBuilder(); + + foreach (object cmd in lst_bannedCmds.Items) + { + lst_AvailableCmds.Items.Add(cmd); + + if (string.IsNullOrEmpty(sb.ToString())) + sb.Append(cmd.ToString()); + else + sb.Append(",").Append(cmd.ToString()); + } + + using (var com = DB.CreateCommand()) + { + com.CommandText = "UPDATE GroupList SET Commands=@cmds WHERE GroupName=@name;"; + com.AddParameter("@name", lst_groupList.Items[lst_groupList.SelectedIndex].ToString()); + com.AddParameter("@cmds", sb.ToString()); + com.ExecuteNonQuery(); + } + lst_bannedCmds.Items.Clear(); + } + catch { } + } + + private void btn_moveRightCmd_Click(object sender, EventArgs e) + { + try + { + lst_AvailableCmds.Items.Add(lst_bannedCmds.Items[lst_bannedCmds.SelectedIndex]); + var sb = new StringBuilder(); + + foreach (object cmd in lst_AvailableCmds.Items) + { + if (string.IsNullOrEmpty(sb.ToString())) + sb.Append(cmd.ToString()); + else + sb.Append(",").Append(cmd.ToString()); + } + + using (var com = DB.CreateCommand()) + { + com.CommandText = "UPDATE GroupList SET Commands=@cmds WHERE GroupName=@name;"; + com.AddParameter("@name", lst_groupList.Items[lst_groupList.SelectedIndex].ToString()); + com.AddParameter("@cmds", sb.ToString()); + com.ExecuteNonQuery(); + } + + lst_bannedCmds.Items.Remove(lst_bannedCmds.Items[lst_bannedCmds.SelectedIndex]); + } + catch { } + } + + private void btn_moveLeftCmd_Click(object sender, EventArgs e) + { + try + { + lst_bannedCmds.Items.Add(lst_AvailableCmds.Items[lst_AvailableCmds.SelectedIndex]); + lst_AvailableCmds.Items.Remove(lst_AvailableCmds.Items[lst_AvailableCmds.SelectedIndex]); + var sb = new StringBuilder(); + + foreach (object cmd in lst_AvailableCmds.Items) + { + if (string.IsNullOrEmpty(sb.ToString())) + sb.Append(cmd.ToString()); + else + sb.Append(",").Append(cmd.ToString()); + } + + using (var com = DB.CreateCommand()) + { + com.CommandText = "UPDATE GroupList SET Commands=@cmds WHERE GroupName=@name;"; + com.AddParameter("@name", lst_groupList.Items[lst_groupList.SelectedIndex].ToString()); + com.AddParameter("@cmds", sb.ToString()); + com.ExecuteNonQuery(); + } + } + catch { } + } + + private void btn_moveAllLeftCmd_Click(object sender, EventArgs e) + { + try + { + foreach (object cmd in lst_AvailableCmds.Items) + { + lst_bannedCmds.Items.Add(cmd); + } + + using (var com = DB.CreateCommand()) + { + com.CommandText = "UPDATE GroupList SET Commands=@cmds WHERE GroupName=@name;"; + com.AddParameter("@name", lst_groupList.Items[lst_groupList.SelectedIndex].ToString()); + com.AddParameter("@cmds", ""); + com.ExecuteNonQuery(); + } + + lst_AvailableCmds.Items.Clear(); + } + catch { } + } + + private void btn_newgroup_Click(object sender, EventArgs e) + { + try + { + if (txt_grpname.Text != "") + { + using (var com = DB.CreateCommand()) + { + if (dbtype == "sqlite") + com.CommandText = "INSERT OR IGNORE INTO GroupList (GroupName, Commands) VALUES (@groupname, @commands);"; + else if (dbtype == "mysql") + com.CommandText = "INSERT IGNORE INTO GroupList SET GroupName=@groupname, Commands=@commands;"; + com.AddParameter("@groupname", txt_grpname.Text); + + if(lst_inheritgrps.SelectedIndex > -1) + com.AddParameter("@commands", lst_inheritgrps.Items[lst_inheritgrps.SelectedIndex]); + else + com.AddParameter("@commands", ""); + + using (var reader = com.ExecuteReader()) + { + if (reader.RecordsAffected > 0) + { + lst_groupList.Items.Add(txt_grpname.Text); + lst_inheritgrps.Items.Add(txt_grpname.Text); + txt_grpname.Text = ""; + } + } + + com.Parameters.Clear(); + } + } + } + catch { } + } + + private void btn_deletegroup_Click(object sender, EventArgs e) + { + try + { + using (var com = DB.CreateCommand()) + { + com.CommandText = "DELETE FROM Grouplist WHERE GroupName = @groupname"; + com.AddParameter("@groupname", lst_groupList.Items[lst_groupList.SelectedIndex]); + com.ExecuteNonQuery(); + + lst_groupList.Items.Remove(lst_groupList.Items[lst_groupList.SelectedIndex]); + + lst_inheritgrps.Items.Clear(); + com.CommandText = + "SELECT * FROM GroupList"; + using (var reader = com.ExecuteReader()) + { + while (reader.Read()) + { + lst_inheritgrps.Items.Add(reader.Get("GroupName")); + } + } + } + } + catch { } + } + + #endregion + + #region FileOpenTabs + + private void btn_OpenLocalDB_Click(object sender, EventArgs e) + { + dialog.ShowDialog(); + } + + void dialog_FileOk(object sender, CancelEventArgs e) + { + LoadSqliteDatabase(dialog.FileName); + tabControl.Visible = true; + } + + private void btn_connect_Click(object sender, EventArgs e) + { + LoadMySqlDatabase(txt_hostname.Text, txt_port.Text, txt_dbname.Text, txt_username.Text, txt_password.Text); + tabControl.Visible = true; + } + + #endregion + } +} \ No newline at end of file diff --git a/DBEditor/Main.resx b/DBEditor/Main.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/DBEditor/Main.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DBEditor/Program.cs b/DBEditor/Program.cs new file mode 100644 index 00000000..b2ca7986 --- /dev/null +++ b/DBEditor/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; +using TShockDBEditor; + +namespace TShockDBEditor +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new TShockDBEditor()); + } + } +} diff --git a/DBEditor/Properties/AssemblyInfo.cs b/DBEditor/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..441f6b69 --- /dev/null +++ b/DBEditor/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("WindowsFormsApplication2")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("WindowsFormsApplication2")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ffdb92d1-7f89-4f59-a671-22ea6cda680c")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/DBEditor/Properties/Resources.Designer.cs b/DBEditor/Properties/Resources.Designer.cs new file mode 100644 index 00000000..aa2d1063 --- /dev/null +++ b/DBEditor/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace TShockDBEditor.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TShockDBEditor.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/DBEditor/Properties/Resources.resx b/DBEditor/Properties/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/DBEditor/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DBEditor/Properties/Settings.Designer.cs b/DBEditor/Properties/Settings.Designer.cs new file mode 100644 index 00000000..f7730805 --- /dev/null +++ b/DBEditor/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace TShockDBEditor.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/DBEditor/Properties/Settings.settings b/DBEditor/Properties/Settings.settings new file mode 100644 index 00000000..39645652 --- /dev/null +++ b/DBEditor/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/DBEditor/TShockDBEditor.csproj b/DBEditor/TShockDBEditor.csproj new file mode 100644 index 00000000..5b6091c2 --- /dev/null +++ b/DBEditor/TShockDBEditor.csproj @@ -0,0 +1,111 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {F1AE395C-6B4D-40E0-8BF8-0D8A126488D3} + WinExe + Properties + TShockDBEditor + TShockDBEditor + v4.0 + + + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\..\..\..\Public\Documents\C3Mod\TShock Testing Environment\Community.CsharpSqlite.dll + + + ..\..\..\..\..\..\Public\Documents\C3Mod\TShock Testing Environment\Community.CsharpSqlite.SQLiteClient.dll + + + False + ..\..\..\..\..\..\Public\Documents\C3Mod\TShock Testing Environment\MySql.Data.dll + + + False + ..\..\..\..\..\..\Public\Documents\C3Mod\TShock Testing Environment\MySql.Web.dll + + + + + + + + + + + + + + + + + + Form + + + Main.cs + + + + + + Main.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + \ No newline at end of file diff --git a/DBEditor/app.config b/DBEditor/app.config new file mode 100644 index 00000000..e3656033 --- /dev/null +++ b/DBEditor/app.config @@ -0,0 +1,3 @@ + + + diff --git a/Terraria.sln b/Terraria.sln index 3c46c488..ec50424c 100644 --- a/Terraria.sln +++ b/Terraria.sln @@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TShockAPI", "TShockAPI\TShockAPI.csproj", "{49606449-072B-4CF5-8088-AA49DA586694}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TShockDBEditor", "..\dbeditor\DBEditor\TShockDBEditor.csproj", "{F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -23,6 +25,16 @@ Global {49606449-072B-4CF5-8088-AA49DA586694}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {49606449-072B-4CF5-8088-AA49DA586694}.Release|Mixed Platforms.Build.0 = Release|Any CPU {49606449-072B-4CF5-8088-AA49DA586694}.Release|x86.ActiveCfg = Release|Any CPU + {F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Debug|Any CPU.ActiveCfg = Debug|x86 + {F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Debug|x86.ActiveCfg = Debug|x86 + {F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Debug|x86.Build.0 = Debug|x86 + {F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Release|Any CPU.ActiveCfg = Release|x86 + {F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Release|Mixed Platforms.Build.0 = Release|x86 + {F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Release|x86.ActiveCfg = Release|x86 + {F1AE395C-6B4D-40E0-8BF8-0D8A126488D3}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE