Exemple #1
0
        internal void generateAddonLangs(MainForm mainForm)
        {
            abilityModifierNames.Clear();
            itemModifierNames.Clear();
            abilityEntries.Clear();
            itemEntries.Clear();
            unitEntries.Clear();
            heroEntries.Clear();
            alreadyHasKeys.Clear();

            string curr = "";

            try {
                // these functions populate the data structures with the tooltips before writing to the addon_lang file.
                // items
                curr = "npc_items_custom.txt";
                generateAbilityTooltips(true);
                // abils
                curr = "npc_abilities_custom.txt";
                generateAbilityTooltips(false);
                curr = "npc_units_custom.txt";
                generateUnitTooltips();
                curr = "npc_heroes_custom.txt";
                generateHeroTooltips();
                writeTooltips();
                mainForm.text_notification(strings.TooltipsSuccessfully, MetroColorStyle.Green, 2500);
            } catch (Exception ex) {
                Debug.WriteLine(ex.Message);
                Debug.WriteLine(ex.StackTrace);
                string msg = ex.Message;
                if (ex.InnerException != null)
                {
                    msg = ex.InnerException.Message;
                }

                MetroMessageBox.Show(mainForm, msg,
                                     "Parse error: " + curr,
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
            }

            // utf8 code
            if (generateUTF8)
            {
                string[] files = Directory.GetFiles(Path.Combine(gamePath, "resource"));
                foreach (string file in files)
                {
                    // skip the existing utf8 files.
                    if (file.Contains("utf8"))
                    {
                        continue;
                    }
                    string name = file.Substring(file.LastIndexOf("\\") + 1);
                    name = name.Replace(".txt", "");
                    //string firstPart = file.Substring(0, file.LastIndexOf("\\"));
                    name += "_utf8.txt";
                    File.WriteAllText(Path.Combine(contentPath, name), File.ReadAllText(file), Encoding.UTF8);
                }
            }
        }
        private void submitBtn_Click(object sender, EventArgs e)
        {
            bool allSuccess = true;

            foreach (Particle p in particles)
            {
                bool success = p.alterParticle(this, rgb, metroTrackBar1.Value);
                if (!success)
                {
                    allSuccess = false;
                }
            }
            if (allSuccess)
            {
                mainForm.text_notification(strings.ParticlesSuccessfullyDesigned, MetroColorStyle.Green, 2500);
            }
            else
            {
                mainForm.text_notification(strings.ParticleDesignFailed, MetroColorStyle.Red, 2500);
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Exemple #3
0
        internal void delete()
        {
            DialogResult dr = MetroMessageBox.Show(mainForm,
                                                   strings.AreYouSure + " '" + name + "'? " + strings.PermanentlyDelete,
                                                   strings.Warning,
                                                   MessageBoxButtons.OKCancel,
                                                   MessageBoxIcon.Warning);

            if (dr == DialogResult.OK)
            {
                try {
                    Directory.Delete(gamePath, true);
                    Directory.Delete(contentPath, true);
                } catch (Exception ex) {
                    MetroMessageBox.Show(mainForm,
                                         strings.PleaseClose,
                                         strings.CouldNotFullyDelete,
                                         MessageBoxButtons.OK,
                                         MessageBoxIcon.Error);
                    return;
                }

                string removed = name;
                mainForm.addons.Remove(name);

                // reset currAddon
                foreach (KeyValuePair <string, Addon> a in mainForm.addons)
                {
                    // pick the first one and break
                    mainForm.changeCurrAddon(a.Value);
                    break;
                }

                mainForm.text_notification(strings.TheAddon + " '" + removed + "' " + strings.WasSuccessfullyDeleted, MetroColorStyle.Green, 2500);
            }
        }
Exemple #4
0
        internal void generateAddonLangs(MainForm mainForm)
        {
            abilityModifierNames.Clear();
            itemModifierNames.Clear();
            abilityEntries.Clear();
            itemEntries.Clear();
            unitEntries.Clear();
            heroEntries.Clear();
            alreadyHasKeys.Clear();

            string curr = "";
            try {
                // these functions populate the data structures with the tooltips before writing to the addon_lang file.
                // items
                curr = "npc_items_custom.txt";
                generateAbilityTooltips(true);
                // abils
                curr = "npc_abilities_custom.txt";
                generateAbilityTooltips(false);
                curr = "npc_units_custom.txt";
                generateUnitTooltips();
                curr = "npc_heroes_custom.txt";
                generateHeroTooltips();
                writeTooltips();
                mainForm.text_notification("Tooltips successfully generated", MetroColorStyle.Green, 2500);
            } catch (Exception ex) {
                string msg = ex.Message;
                if (ex.InnerException != null) {
                    msg = ex.InnerException.Message;
                }

                MetroMessageBox.Show(mainForm, msg,
                    "Parse error: " + curr,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);

            }

            // utf8 code
            if (generateUTF8) {
                string[] files = Directory.GetFiles(Path.Combine(gamePath, "resource"));
                foreach (string file in files) {
                    // skip the existing utf8 files.
                    if (file.Contains("utf8")) {
                        continue;
                    }
                    string name = file.Substring(file.LastIndexOf("\\") + 1);
                    name = name.Replace(".txt", "");
                    //string firstPart = file.Substring(0, file.LastIndexOf("\\"));
                    name += "_utf8.txt";
                    File.WriteAllText(Path.Combine(contentPath, name), File.ReadAllText(file), Encoding.UTF8);
                }
            }
        }
Exemple #5
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();
        }