Пример #1
0
        public OptionsForm(MainForm mainForm)
        {
            this.mainForm = mainForm;
            currAddon = mainForm.currAddon;

            InitializeComponent();
            tabControl.SelectedIndex = 0;

            TabControl.TabPageCollection tpc = tabControl.TabPages;
            tpc[0].Text = currAddon.name;
            getAddonOptions();
        }
		public ModifierEntry(Addon a, string _name) {
			this.addon = a;

			// prevent modifier_modifier names
			name = new Pair("DOTA_Tooltip_" + _name, getVal(_name));

			// Noya says modifier tooltips are like this DOTA_Tooltip_some_modifier
			/*if (_name.Length > 8)
			{
				if (_name.Substring(0, 8) == "modifier")
				{
					name = new Pair("DOTA_Tooltip_" + _name, getVal(_name));
				}
			}*/

			description = new Pair(name.key + "_Description", "");
		}
Пример #3
0
        public AbilityEntry(Addon a, string _name, List <string> keys)
        {
            this.addon  = a;
            name        = new Pair("DOTA_Tooltip_ability_" + _name, getVal(_name));
            description = new Pair(name.key + "_Description", "");
            note0       = new Pair(name.key + "_Note0", "");
            lore        = new Pair(name.key + "_Lore", "");

            if (keys != null)
            {
                abilitySpecials = new List <Pair>(keys.Count());
                for (int i = 0; i < keys.Count(); i++)
                {
                    string abilSpecial = keys.ElementAt(i);
                    abilitySpecials.Add(new Pair(name.key + "_" + abilSpecial, getAbilSpecialVal(abilSpecial)));
                }
            }
        }
Пример #4
0
        public ModifierEntry(Addon a, string _name)
        {
            this.addon = a;

            // prevent modifier_modifier names
            name = new Pair("DOTA_Tooltip_" + _name, getVal(_name));

            // Noya says modifier tooltips are like this DOTA_Tooltip_some_modifier

            /*if (_name.Length > 8)
             * {
             *      if (_name.Substring(0, 8) == "modifier")
             *      {
             *              name = new Pair("DOTA_Tooltip_" + _name, getVal(_name));
             *      }
             * }*/

            description = new Pair(name.key + "_Description", "");
        }
Пример #5
0
        private Dictionary <string, Addon> getAddons()
        {
            Dictionary <string, Addon> addons = new Dictionary <string, Addon>();

            string[] dirs = Directory.GetDirectories(gamePath);
            string   addons_constructed = "Addons constructed:\n";

            foreach (string s in dirs)
            {
                // construct a new addon from this dir path.
                Addon a = new Addon(s);
                addons_constructed += s + "\n";
                // skip the dirs that we know aren't addons.
                if (a.name == "vpks")
                {
                    continue;
                }

                // if constructor didn't return null, we have a valid addon.
                if (a != null)
                {
                    addons.Add(a.name, a);
                    if (firstAddonName == "")
                    {
                        firstAddonName = a.name;
                    }
                }
            }

            // does this computer have any dota addons?
            if (addons.Count == 0)
            {
                MetroMessageBox.Show(this, strings.NoDota2AddonsDetectedMsg,
                                     strings.NoDota2AddonsDetectedCaption,
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
                Environment.Exit(0);
                return(addons);
            }

            //Util.Log(addons_constructed, false);
            return(addons);
        }
Пример #6
0
        public Image findAddonThumbnail(Addon a)
        {
            string thumbnailDir = Path.Combine(dotaDir, "game", "bin", "win64");

            if (Directory.Exists(thumbnailDir) && a.workshopID != 0)
            {
                string imagePath = Path.Combine(thumbnailDir, a.workshopID + "_thumb.jpg");

                if (File.Exists(imagePath))
                {
                    Debug.WriteLine(imagePath + " found!");
                    Image thumbnail = Image.FromFile(imagePath, true);
                    Size  size      = new Size(addonTile.Width, addonTile.Height);
                    thumbnail = (Image) new Bitmap(thumbnail, size);

                    a.image = thumbnail;
                    return(thumbnail);
                }
            }
            return(null);
        }
		public AbilityEntry(Addon a, string _name, List<string> keys) {
			this.addon = a;
			name = new Pair("DOTA_Tooltip_ability_" + _name, getVal(_name));
			description = new Pair(name.key + "_Description", "");
			note0 = new Pair(name.key + "_Note0", "");
			lore = new Pair(name.key + "_Lore", "");

			if (keys != null) {
				abilitySpecials = new List<Pair>(keys.Count());
				for (int i = 0; i < keys.Count(); i++) {
					string abilSpecial = keys.ElementAt(i);
					abilitySpecials.Add(new Pair(name.key + "_" + abilSpecial, getAbilSpecialVal(abilSpecial)));
				}
			}
		}
		public HeroEntry(Addon a, string overrideHeroName, string name) {
			this.addon = a;
			try {
				// remove the npc_dota_hero part for the value.
				//this.name = new Pair(overrideHeroName, getVal(overrideHeroName.Substring(14)));
				this.name = new Pair(overrideHeroName, getVal(name));
			} catch (IndexOutOfRangeException) {
				this.name = new Pair(overrideHeroName, "");
			}
		}
		public UnitEntry(Addon a, string _name) {
			this.addon = a;
			name = new Pair(_name, getVal(_name));
		}
Пример #10
0
        public MainForm()
        {
            Instance = this;
            // bring up the UI
            InitializeComponent();

            // localize ModKit strings.
            Localizer localizer = new Localizer(this);

            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("zh-CN");
            Console.WriteLine(strings.Hello);

            // setup MainForm hooks.
            setupHooks();

            // check for updates
            updater = new Updater(this);

            // init mainform controls stuff
            initControls();

            // get the dota dir
            retrieveDotaDir();

            // get the master 'game' and 'content' paths.
            gamePath    = Path.Combine(dotaDir, "game", "dota_addons");
            contentPath = Path.Combine(dotaDir, "content", "dota_addons");

            // create these dirs if they don't exist.
            if (!Directory.Exists(gamePath))
            {
                Directory.CreateDirectory(gamePath);
            }
            if (!Directory.Exists(contentPath))
            {
                Directory.CreateDirectory(contentPath);
            }

            // get all the addons in the 'game' dir.
            addons = getAddons();

            // setup custom tiles
            setupCustomTiles();

            // deserialize settings
            deserializeSettings();

            // auto-retrieve the workshop IDs for published addons if there are any.
            getWorkshopIDs();

            // set currAddon to the addon that was last opened in last run of modkit.
            if (Settings.Default.LastAddon != "")
            {
                Addon a = getAddonFromName(Settings.Default.LastAddon);
                if (a != null)
                {
                    changeCurrAddon(a);
                }
            }

            // basically, if this is first run of modkit, set the currAddon to w/e the default addon is in the workshop tools.
            if (currAddon == null)
            {
                changeCurrAddon(addons[getDefaultAddonName()]);
            }

            // init our features of Modkit
            initFeatures();
        }
Пример #11
0
        public Image findAddonThumbnail(Addon a)
        {
            string thumbnailDir = Path.Combine(dotaDir, "game", "bin", "win64");

            if (Directory.Exists(thumbnailDir) && a.workshopID != 0) {
                string imagePath = Path.Combine(thumbnailDir, a.workshopID + "_thumb.jpg");

                if (File.Exists(imagePath)) {
                    Debug.WriteLine(imagePath + " found!");
                    Image thumbnail = Image.FromFile(imagePath, true);
                    Size size = new Size(addonTile.Width, addonTile.Height);
                    thumbnail = (Image)new Bitmap(thumbnail, size);

                    a.image = thumbnail;
                    return thumbnail;
                }
            }
            return null;
        }
Пример #12
0
        public AddonsForm(MainForm mainForm)
        {
            this.mainForm = mainForm;

            InitializeComponent();

            tabControl.SelectedIndex = 0;
            createAddonBtn.Enabled   = true;
            bmdRadioButton.Checked   = true;

            mts.Add(metroTile1);
            mts.Add(metroTile2);
            mts.Add(metroTile3);
            mts.Add(metroTile4);
            mts.Add(metroTile5);
            mts.Add(metroTile6);
            mts.Add(metroTile7);
            mts.Add(metroTile8);
            mts.Add(metroTile9);
            mts.Add(metroTile10);
            mts.Add(metroTile11);
            mts.Add(metroTile12);
            mts.Add(metroTile13);
            mts.Add(metroTile14);
            mts.Add(metroTile15);
            mts.Add(metroTile16);

            totalPages = mainForm.addons.Count / 16;

            if (mainForm.addons.Count % 16 != 0)
            {
                totalPages++;
            }

            if (totalPages == 1)
            {
                nextBtn.Visible = false;
            }

            int addonCount = 0;
            int pos        = 1;
            int page       = 1;

            foreach (KeyValuePair <string, Addon> kv in mainForm.addons)
            {
                Addon a = kv.Value;
                addonCount++;

                // store the page and pos of this addon
                a.libraryPos  = pos;
                a.libraryPage = page;

                //if ()

                pos++;

                if (addonCount % 16 == 0)
                {
                    page++;
                    pos = 1;
                }
            }

            backBtn.Visible = false;

            refreshPage();
        }
Пример #13
0
        private void createAddon()
        {
            dummyBtn.Select();

            // ensure an addon is selected.
            if (existingAddonRadioButton1.Checked)
            {
                version = "existing";
            }

            // check if stuff in textbox is fine.
            newAddonName = addonNameTextBox.Text;
            if (newAddonName == "" || !(newAddonName.Length > 2))
            {
                MetroMessageBox.Show(this, "Length must be > 2 characters.",
                                     "Invalid addon name",
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
                return;
            }

            // init some of the new addon stuff
            string lower = newAddonName.ToLowerInvariant();
            string upper = newAddonName.ToUpperInvariant();

            string newG = Path.Combine(mainForm.gamePath, lower);
            string newC = Path.Combine(mainForm.contentPath, lower);

            // Ensure the addon doesn't already exist.
            if (Directory.Exists(newG))
            {
                MetroMessageBox.Show(this, newG + " already exists!",
                                     "Directory already exists",
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
                return;
            }
            else if (Directory.Exists(newC))
            {
                MetroMessageBox.Show(this, newC + " already exists!",
                                     "Directory already exists",
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
                return;
            }

            // do inital specific forking stuff
            bool dontContinue = false;

            if (version == "existing")
            {
                if (!forkExisting())
                {
                    dontContinue = true;
                }
            }
            else if (version == "bmd")
            {
                //stringToReplaceTextbox.ReadOnly = true;
                //stringToReplaceTextbox.Text = "barebones";
                if (!forkBMD())
                {
                    dontContinue = true;
                }
            }

            if (dontContinue)
            {
                MetroMessageBox.Show(this, "Addon was not created.",
                                     "Error",
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
                return;
            }

            // do general forking stuff
            fork();

            // move the game and content dirs to the actual dirs
            string game    = Path.Combine(Environment.CurrentDirectory, lower, "game", "dota_addons", lower);
            string content = Path.Combine(Environment.CurrentDirectory, lower, "content", "dota_addons", lower);

            Directory.Move(game, newG);
            Directory.Move(content, newC);

            // delete the old dir now.
            Directory.Delete(Path.Combine(Environment.CurrentDirectory, lower), true);

            // change currAddon on the main form.
            Addon newAddon = new Addon(newG);

            mainForm.addons.Add(lower, newAddon);
            mainForm.changeCurrAddon(newAddon);

            mainForm.text_notification("Successfully created new addon: " + newAddonName.ToLowerInvariant(), MetroColorStyle.Green, 2500);
            Process.Start(Path.Combine(newG, "scripts", "vscripts"));
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Пример #14
0
 public UnitEntry(Addon a, string _name)
 {
     this.addon = a;
     name       = new Pair(_name, getVal(_name));
 }
Пример #15
0
		private Dictionary<string, Addon> getAddons() {
			Dictionary<string, Addon> addons = new Dictionary<string, Addon>();
			string[] dirs = Directory.GetDirectories(gamePath);
			string addons_constructed = "Addons constructed:\n";
			foreach (string s in dirs) {
				// construct a new addon from this dir path.
				Addon a = new Addon(s);
				addons_constructed += s + "\n";
				// skip the dirs that we know aren't addons.
				if (a.name == "vpks") {
					continue;
				}

				// if constructor didn't return null, we have a valid addon.
				if (a != null) {
					addons.Add(a.name, a);
					if (firstAddonName == "") {
						firstAddonName = a.name;
					}
				}
			}

			// does this computer have any dota addons?
			if (addons.Count == 0) {
				MetroMessageBox.Show(this, strings.NoDota2AddonsDetectedMsg,
					strings.NoDota2AddonsDetectedCaption,
					MessageBoxButtons.OK,
					MessageBoxIcon.Error);
				Environment.Exit(0);
				return addons;
			}

			//Util.Log(addons_constructed, false);
			return addons;
		}
Пример #16
0
 public Library(string local, Addon a)
 {
     this.local = local;
     this.addon = a;
     name       = local.Substring(local.LastIndexOf('\\') + 1);
 }
Пример #17
0
        public MainForm()
        {
            // bring up the UI
            InitializeComponent();

            Localizer localizer = new Localizer(this);

            localizer.localize();

            //Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("cn-CN");
            Console.WriteLine(strings.Hello);

            setupMainFormHooks();

            // check for updates
            updater = new Updater(this);
            updater.checkForUpdates();

            // init mainform controls stuff
            initControls();

            // get the dota dir
            retrieveDotaDir();

            // *** at this point assume valid dota dir. ***

            // save the dota dir
            Settings.Default.DotaDir = dotaDir;

            Debug.WriteLine("Directory: " + dotaDir);

            // get the master 'game' and 'content' paths.
            gamePath    = Path.Combine(dotaDir, "game", "dota_addons");
            contentPath = Path.Combine(dotaDir, "content", "dota_addons");

            // create these dirs if they don't exist.
            if (!Directory.Exists(gamePath))
            {
                Directory.CreateDirectory(gamePath);
            }
            if (!Directory.Exists(contentPath))
            {
                Directory.CreateDirectory(contentPath);
            }

            // get all the addons in the 'game' dir.
            addons = getAddons();

            // does this computer have any dota addons?
            if (addons.Count == 0)
            {
                MetroMessageBox.Show(this, strings.NoDota2AddonsDetectedMsg,
                                     strings.NoDota2AddonsDetectedCaption,
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
                Environment.Exit(0);
            }

            // setup custom tiles
            setupCustomTiles();

            // some functions in the Tick try and use mainform's controls on another thread. so we need to allot a very small amount of time for
            // mainform to init its controls. this is mainly for the very first run of modkit.
            Timer initTimer = new Timer();

            initTimer.Interval = 100;
            initTimer.Tick    += (s, e) => {
                // run it once
                Timer t = (Timer)s;
                t.Stop();

                // clone a barebones repo if we don't have one, pull if we do
                updater.clonePullBarebones();

                // deserialize settings
                deserializeSettings();

                // auto-retrieve the workshop IDs for published addons if there are any.
                getWorkshopIDs();

                // set currAddon to the addon that was last opened in last run of modkit.
                if (Settings.Default.LastAddon != "")
                {
                    Addon a = getAddonFromName(Settings.Default.LastAddon);
                    if (a != null)
                    {
                        changeCurrAddon(a);
                    }
                }

                // basically, if this is first run of modkit, set the currAddon to w/e the default addon is in the workshop tools.
                if (currAddon == null)
                {
                    changeCurrAddon(addons[getDefaultAddonName()]);
                }

                // init our features of Modkit
                initFeatures();
            };
            initTimer.Start();
        }
Пример #18
0
        public void changeCurrAddon(Addon a)
        {
            addonTile.Text = a.name;

            if (a.image != null) {
                addonTile.UseTileImage = true;
                addonTile.TileImage = a.image;
            } else {
                Image thumbnail = findAddonThumbnail(a);
                if (thumbnail != null) {
                    addonTile.UseTileImage = true;
                    addonTile.TileImage = thumbnail;
                } else {
                    addonTile.UseTileImage = false;
                    a.doesntHaveThumbnail = true;
                    addonTile.Style = a.tileColor;
                    //Debug.WriteLine(a.tileColor.GetType().ToString());
                }
            }
            currAddon = a;
            currAddon.onChangedTo(this);

            Settings.Default.LastAddon = a.name;
            //text_notification("Selected addon: " + a.name, MetroColorStyle.Green, 2500);
        }
Пример #19
0
 public Library(string local, Addon a)
 {
     this.local = local;
     this.addon = a;
     name = local.Substring(local.LastIndexOf('\\') + 1);
 }
Пример #20
0
        private Dictionary<string, Addon> getAddons()
        {
            Dictionary<string, Addon> addons = new Dictionary<string, Addon>();
            string[] dirs = Directory.GetDirectories(gamePath);
            string addons_constructed = "Addons constructed:\n";
            foreach (string s in dirs) {
                // construct a new addon from this dir path.
                Addon a = new Addon(s);
                addons_constructed += s + "\n";
                // skip the dirs that we know aren't addons.
                if (a.name == "vpks") {
                    continue;
                }

                // if constructor didn't return null, we have a valid addon.
                if (a != null) {
                    addons.Add(a.name, a);
                    if (firstAddonName == "") {
                        firstAddonName = a.name;
                    }
                }
            }

            //Util.Log(addons_constructed, false);
            return addons;
        }
Пример #21
0
        private void createAddon()
        {
            dummyRadioBtn.Select();

            // ensure an addon is selected.
            if (existingAddonRadioButton1.Checked) {
                version = "existing";
            }

            // check if stuff in textbox is fine.
            newAddonName = addonNameTextBox.Text;
            if (newAddonName == "" || !(newAddonName.Length > 2)) {
                MetroMessageBox.Show(this, "Length must be > 2 characters.",
                    "Invalid addon name",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            // init some of the new addon stuff
            string lower = newAddonName.ToLowerInvariant();
            string upper = newAddonName.ToUpperInvariant();

            string newG = Path.Combine(mainForm.gamePath, lower);
            string newC = Path.Combine(mainForm.contentPath, lower);

            // Ensure the addon doesn't already exist.
            if (Directory.Exists(newG)) {
                MetroMessageBox.Show(this, newG + " already exists!",
                    "Directory already exists",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            } else if (Directory.Exists(newC)) {
                MetroMessageBox.Show(this, newC + " already exists!",
                    "Directory already exists",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            // do inital specific forking stuff
            bool dontContinue = false;
            if (version == "existing") {
                if (!forkExisting()) {
                    dontContinue = true;
                }

            } else if (version == "bmd") {
                //stringToReplaceTextbox.ReadOnly = true;
                //stringToReplaceTextbox.Text = "barebones";
                if (!forkBMD()) {
                    dontContinue = true;
                }
            }

            if (dontContinue) {
                MetroMessageBox.Show(this, "Addon was not created.",
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            // do general forking stuff
            fork();

            // move the game and content dirs to the actual dirs
            string game = Path.Combine(Environment.CurrentDirectory, lower, "game", "dota_addons", lower);
            string content = Path.Combine(Environment.CurrentDirectory, lower, "content", "dota_addons", lower);
            Directory.Move(game, newG);
            Directory.Move(content, newC);

            // delete the old dir now.
            Directory.Delete(Path.Combine(Environment.CurrentDirectory, lower), true);

            // change currAddon on the main form.
            Addon newAddon = new Addon(newG);
            mainForm.addons.Add(lower, newAddon);
            mainForm.changeCurrAddon(newAddon);

            mainForm.text_notification("Successfully created new addon: " + newAddonName.ToLowerInvariant(), MetroColorStyle.Green, 2500);
            Process.Start(Path.Combine(newG, "scripts", "vscripts"));
            this.DialogResult = DialogResult.OK;
            this.Close();
        }