Command Add

Command Add

Postby ismellike » 21 Jun 2013, 23:05

This plugin is to add commands easier :)!

Picture at the bottom

The code also has the method _x and _y which I found extremely useful in making the gui.

The plugin is pretty self explanatory so not much else to talk about.

Code: Select all
using System;
using System.Windows.Forms;
using System.Drawing;
using System.IO;

namespace MCDzienny.Plugins
{
    public class LevelShare : Plugin
    {
        // The name of the plugin.
        string name = "Command Add";

        // A relatively short description of the plugin.
        string description = "Add a command easily.";

        // A name or names of the authors of the plugin.
        string author = "ismellike";

        // A version number that is displayed to the end users.
        string version = "1.0";

        // A version number that is used for update checking. It's an absolute number that
        // represents a release number. It should be incremented by 1 each time the new version
        // is released.
        int versionNumber = 1;

        // A user control that contains graphical user interface of the plugin.
        UserControl gui = new GuiExample();

        public override string Description
        {
            get { return description; }
        }

        public override string Author
        {
            get { return author; }
        }
        public override string Name
        {
            get { return name; }
        }

        public override UserControl MainInterface
        {
            get { return gui; }
        }

        public override string Version
        {
            get { return version; }
        }

        public override int VersionNumber
        {
            get { return versionNumber; }
        }

        public override void Initialize()
        {
        }

        public override void Terminate()
        {
        }
    }
}



namespace MCDzienny.Plugins
{
    public partial class GuiExample : UserControl
    {
        public GuiExample()
        {
            InitializeComponent();
        }
    }
}

namespace MCDzienny.Plugins
{
    partial class GuiExample
    {
        private string cmdname;
        private System.ComponentModel.IContainer components = null;
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code
        private void Add_Command(object sender, EventArgs e)
        {
            try
            {
                if (commandname.Text.Length == 0)
                {
                    MessageBox.Show("Command name cannot be left blank");
                    return;
                }
                cmdname = commandname.Text;
                if (code.Text.Length == 0)
                {
                    MessageBox.Show("Code cannot be left blank");
                    return;
                }
                if (File.Exists(@"extra\\commands\\source\\Cmd" + cmdname + ".cs") && Override.Checked != true)
                {
                    MessageBox.Show("Command already exists");
                    return;
                }
                //transfer code to a code file
                File.WriteAllText(@"extra\\commands\\source\\Cmd" + cmdname + ".cs", code.Text);
                string done = "";
                if (compile.Checked)
                {
                    Command.all.Find("compile").Use(null, cmdname);
                    done += "+compile ";
                }
                if (unload.Checked)
                {
                    Command.all.Find("cmdunload").Use(null, cmdname);
                    done += "+unload ";
                }
                if (load.Checked)
                {
                    Command.all.Find("cmdload").Use(null, cmdname);
                    done += "+load ";
                }
                if (cmdautoload.Checked)
                {
                    if (!File.ReadAllText("text/cmdautoload.txt").Contains(cmdname))
                    {
                        File.AppendAllText("text/cmdautoload.txt", Environment.NewLine + cmdname);
                        done += "+auto ";
                    }
                    else
                    {
                        MessageBox.Show(cmdname + " is already on the autoload list");
                    }
                }
                MessageBox.Show("Command added " + done);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void Clear_Click(object sender, EventArgs e)
        {
            code.Text = "";
            commandname.Text = "";
        }
        private int _x(Control x)
        {
            return Convert.ToInt32(x.Size.Width + x.Location.X + 10);
        }
        private int _y(Control y)
        {
            return Convert.ToInt32(y.Height + y.Location.Y + 10);
        }
        private void InitializeComponent()
        {
            try
            {
                lcode = new Label();
                lname = new Label();
                lcs = new Label();
                Clear = new Button();
                Override = new CheckBox();
                compile = new CheckBox();
                unload = new CheckBox();
                load = new CheckBox();
                cmdautoload = new CheckBox();
                code = new TextBox();
                commandname = new TextBox();
                Cmdadd = new Button();
                SuspendLayout();
                //Top Labels
                lcode.AutoSize = lcs.AutoSize = lname.AutoSize = true;
                lcode.TabIndex = lcs.TabIndex = lname.TabIndex = 0;
                lcode.ForeColor = lcs.ForeColor = lname.ForeColor = Color.Black;
                lcode.Location = new Point(10, 10);
                lcode.Name = "label1";
                lcode.Size = new Size(40, 20);
                lcode.Text = "Code:";
                lcode.Font = lcs.Font = lname.Font = new Font("Courier New", 12F);
                //
                // code : TextBox
                //
                code.Location = new Point(10, _y(lcode) - 10);
                code.Name = "code";
                code.Size = new Size(480, 500);
                code.TabIndex = 0;
                code.Multiline = true;
                code.ScrollBars = ScrollBars.Vertical;
                //
                // CHECKBOXES
                //
                this.compile.AutoSize = unload.AutoSize = load.AutoSize = cmdautoload.AutoSize = Override.AutoSize = true;
                this.compile.Size = unload.Size = load.Size = cmdautoload.Size = Override.Size = new Size(80, 20);
                this.compile.TabIndex = unload.TabIndex = load.TabIndex = cmdautoload.TabIndex = Override.TabIndex = 0;
                this.compile.UseVisualStyleBackColor = unload.UseVisualStyleBackColor = load.UseVisualStyleBackColor = cmdautoload.UseVisualStyleBackColor = Override.UseVisualStyleBackColor = false;
                //^same for all checkboxes
                this.compile.Text = compile.Name = "Compile";
                this.compile.Location = new Point(10, _y(code));
                unload.Text = unload.Name = "Unload";
                unload.Location = new Point(_x(compile), compile.Location.Y);
                load.Text = load.Name = "load";
                load.Location = new Point(_x(unload), compile.Location.Y);
                cmdautoload.Text = cmdautoload.Name = "cmdautoload";
                cmdautoload.Location = new Point(_x(load), compile.Location.Y);
                Override.Text = Override.Name = "override";
                Override.Location = new Point(_x(cmdautoload), compile.Location.Y);
                //
                // Cmdadd : Button
                //
                Cmdadd.BackColor = Clear.BackColor = Color.Black;
                Cmdadd.ForeColor = Clear.ForeColor = Color.Yellow;
                Cmdadd.Location = new Point(10, _y(compile));
                Cmdadd.Name = "download";
                Cmdadd.Size = new Size(480, 25);
                Cmdadd.TabIndex = 0;
                Cmdadd.Text = "Add!";
                Cmdadd.UseVisualStyleBackColor = Clear.UseVisualStyleBackColor = false;
                Cmdadd.Click += new EventHandler(Add_Command);
                //Cmd label
                lname.Location = new Point(10, _y(Cmdadd)+3);
                lname.Name = "Cmd";
                lname.Size = new Size(40, 40);
                lname.Text = "Cmd";
                // Command name : Textbox
                commandname.Location = new Point(_x(lname) - 15, _y(Cmdadd));
                commandname.Name = "cmdname";
                commandname.Size = new Size(50, 30);
                commandname.TabIndex = 0;
                //.cs label
                lcs.Location = new Point(_x(commandname) - 15, _y(Cmdadd) + 3);
                lcs.Name = ".cs";
                lcs.Size = new Size(40, 40);
                lcs.Text = ".cs";
                // clear : Button
                Clear.Location = new Point(_x(lcs)+10, commandname.Location.Y);
                Clear.Name = "clear text";
                Clear.Size = new Size(340, 30);
                Clear.TabIndex = 0;
                Clear.Text = "Clear Text";
                Clear.Click += new EventHandler(Clear_Click);
                //
                // Gui
                //
                AutoScaleDimensions = new SizeF(6F, 13F);
                AutoScaleMode = AutoScaleMode.Font;
                BackColor = Color.LightSlateGray;
                Name = "Gui";
                Size = new Size(465, 378);
                Controls.Add(Cmdadd);
                Controls.Add(code);
                Controls.Add(compile);
                Controls.Add(unload);
                Controls.Add(load);
                Controls.Add(cmdautoload);
                Controls.Add(Override);
                Controls.Add(commandname);
                Controls.Add(Clear);
                Controls.Add(lcode);
                Controls.Add(lcs);
                Controls.Add(lname);
                ResumeLayout(false);
                PerformLayout();
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        #endregion
        private Label lcode, lname, lcs;
        private Button Cmdadd, Clear;
        private TextBox code, commandname;
        private CheckBox compile, unload, load, cmdautoload, Override;
    }
}


screen.PNG
screen.PNG (6.65 KiB) Viewed 3947 times
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: Command Add

Postby joppiesaus » 22 Jun 2013, 10:58

Usefull and awsome!
Really great work
joppiesaus
 
Posts: 379
Joined: 20 Aug 2012, 07:28
Location: in a obsedian house, with glass in it so i can see the lava!

Re: Command Add

Postby dzienny » 22 Jun 2013, 12:37

It's really sweet. If there were a must-have list of the plugins, it would be somewhere on top :)
User avatar
dzienny
Administrator
 
Posts: 1181
Joined: 23 Jan 2011, 14:27

Re: Command Add

Postby jacobdynomite » 24 Jul 2013, 12:56

when in consol how do i scroll down to see like the add button and all that?
jacobdynomite
 
Posts: 1
Joined: 24 Jul 2013, 12:16

Re: Command Add

Postby HETAL » 24 Jul 2013, 13:44

You have to do full screen with the console
YOU HAVENT SEEN THE LAST OF ME ISMELLIKE
HETAL
 
Posts: 397
Joined: 24 May 2013, 12:10

Re: Command Add

Postby D3athdog » 27 Jul 2013, 13:03

when i add this plugin it doesn't show the "add command" part and when i go full screen it still won't show. how do i fix this :?:
D3athdog
 
Posts: 1
Joined: 26 Jul 2013, 16:38

Re: Command Add

Postby joppiesaus » 27 Jul 2013, 14:46

D3athdog wrote:when i add this plugin it doesn't show the "add command" part and when i go full screen it still won't show. how do i fix this :?:

Did you selected it in the listbox? (The thing on the side where command add is displayed in a list)
joppiesaus
 
Posts: 379
Joined: 20 Aug 2012, 07:28
Location: in a obsedian house, with glass in it so i can see the lava!

Re: Command Add

Postby asdfmovie2121 » 07 May 2014, 06:25

This plugin doesn't work anymore take a look at the errors
-------------------------

Error #CS0006
Message: Metadata file 'Mono.Data.Sqlite.dll' could not be found
Line: 0

-------------------------

Error #CS0006
Message: Metadata file 'SuperWebSocket.dll' could not be found
Line: 0

-------------------------

Error #CS0006
Message: Metadata file 'SuperSocket.SocketBase.dll' could not be found
Line: 0
Owner of DeadIsland Survival[New]
asdfmovie2121
 
Posts: 26
Joined: 29 Dec 2012, 13:18

Re: Command Add

Postby _Retaliate_ » 07 May 2014, 08:51

It's because of the update, dzienny, you should make the updater.exe download any new dlls that you've started using as well.
Image
_Retaliate_
 
Posts: 68
Joined: 26 Sep 2013, 11:16

Re: Command Add

Postby dzienny » 08 May 2014, 20:15

I added a websocket library to support the new remote client. The library was embedded into MCDzienny_.dll. And it seems that the compiler can't find it. It will be fixed in the release. Thank you for the information.

Also, if you wonder why it's embedded instead of being provided as a separate library. I would have to rewrite the updater to make it possible because currently it can only update three files: MCDzienny.exe, MCDzienny_.dll and changelog.txt.
User avatar
dzienny
Administrator
 
Posts: 1181
Joined: 23 Jan 2011, 14:27

Next

Return to Plugins

Who is online

Users browsing this forum: No registered users and 1 guest

cron