public CustomTile(MainForm mainForm, MetroTile tile, int tileNum, string serializedTileInfo) {
			this.mainForm = mainForm;
			this.tile = tile;
			this.tileNum = tileNum;
			this.serializedTileInfo = serializedTileInfo;

			tile.Click += (s, e) => {
				if (path != "") {
					Process.Start(path);
				} else {
					// no value defined for this custom tile.
					CustomTileForm ctf = new CustomTileForm(mainForm, this);
					ctf.ShowDialog();
				}
			};

			if (serializedTileInfo == "") {
				return;
			}

			var serializedTileInfoArr = serializedTileInfo.Split(',');
			for (int i = 0; i < serializedTileInfoArr.Length; i++) {
				if (i==0) {
					path = serializedTileInfoArr[0];
					if (path == null) {
						return;
					}
					setPath(path);
				} else if (i == 1) {
					tile.Text = serializedTileInfoArr[1];
				}
			}
		}
Esempio n. 2
0
		public Updater(MainForm mainForm) {
			this.mainForm = mainForm;
			version = mainForm.version;

			checkForUpdates();
			clonePullBarebones();
        }
Esempio n. 3
0
        public UpdateForm(MainForm mainForm)
        {
            this.mainForm = mainForm;
            InitializeComponent();

            // the user wants to update D2ModKit.

            try {
                // delete D2ModKit.zip if exists.
                if (File.Exists(Path.Combine(Environment.CurrentDirectory, "D2ModKit.zip"))) {
                    File.Delete(Path.Combine(Environment.CurrentDirectory, "D2ModKit.zip"));
                }

                progressLabel.Text = "Downloading v" + mainForm.newVers + "...";

                WebClient wc = new WebClient();
                wc.DownloadFileCompleted += wc_DownloadFileCompleted;
                wc.DownloadProgressChanged += wc_DownloadProgressChanged;

                // start downloading.
                wc.DownloadFileAsync(new Uri(mainForm.newVersUrl), Path.Combine(Environment.CurrentDirectory, "D2ModKit.zip"));
            } catch (Exception ex) {
                MetroMessageBox.Show(this, ex.Message,
                    ex.ToString(),
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
        }
Esempio n. 4
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();
        }
Esempio n. 5
0
        static void Main()
        {
			// refresh the debug log
			//Util.Log("", true);

			AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

			// Check if application is already running.
			if (Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location)).Count() > 1) {
				MessageBox.Show("An instance of D2ModKit is already running. Exiting.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);

				Process.GetCurrentProcess().Kill();
			}

			Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
			MainForm mainForm = new MainForm();
            Application.Run(mainForm);
        }
        public ParticleDesignForm(MainForm mainForm, string[] particlePaths)
        {
            this.mainForm = mainForm;

            InitializeComponent();

            // setup hooks
            metroTrackBar1.Maximum = 200;
            metroTrackBar1.Minimum = -100;
            metroTrackBar1.Value = 0;
            metroTrackBar1.ValueChanged += MetroTrackBar1_ValueChanged;

            string suffix = " particles selected";
            if (particlePaths.Length == 1) {
                suffix = " particle selected";
            }
            particlesSelectedLabel.Text = particlePaths.Length + suffix;

            foreach (string path in particlePaths) {
                particles.Add(new Particle(path));
            }
        }
Esempio n. 7
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();
        }
Esempio n. 8
0
 public Initializer(MainForm mf)
 {
     this.mf = mf;
 }
Esempio n. 9
0
        internal void onChangedTo(MainForm mainForm)
        {
            this.mainForm = mainForm;

            // delete .bin files if the option is checked.
            if (autoDeleteBin) {
                deleteBinFiles();
            }

            using (var addonSizeWorker = new BackgroundWorker()) {
                addonSizeWorker.DoWork += AddonSizeWorker_DoWork;
                addonSizeWorker.RunWorkerCompleted += AddonSizeWorker_RunWorkerCompleted;
                addonSizeWorker.RunWorkerAsync();
            }

            if (barebonesLibUpdates) {
                // we need to allot time to pull or clone barebones, before checking for lib updates.
                // lib update code is called in Updater.cs in this case.
                if (!mainForm.firstAddonChange) {
                    mainForm.firstAddonChange = true;
                    return;
                }

                Timer onChangedToTimer = new Timer();
                onChangedToTimer.Interval = 500;
                onChangedToTimer.Tick += OnChangedToTimer_Tick;
                onChangedToTimer.Start();
            }
        }
Esempio n. 10
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);
                }
            }
        }
Esempio n. 11
0
		internal void onChangedTo(MainForm mainForm) {
			this.mainForm = mainForm;

			// delete .bin files if the option is checked.
			if (autoDeleteBin) {
				deleteBinFiles();
			}

			Util.CreateTimer(200, (timer) => {
				timer.Stop();
				mainForm.kvFeatures.setupNPCWatchers(this);
				mainForm.kvFeatures.setupCoffeeWatcher(this);
			});

			displayAddonSize();

			if (barebonesLibUpdates) {
				// we need to allot time to pull or clone barebones, before checking for lib updates.
				// lib update code is called in Updater.cs in this case.
				if (!mainForm.firstAddonChange) {
					mainForm.firstAddonChange = true;
					return;
				}

				Util.CreateTimer(200, (timer) => {
					timer.Stop();
					checkForDefaultLibs();

					foreach (KeyValuePair<string, Library> libKV in libraries) {
						Library lib = libKV.Value;
						lib.checkForUpdates();
					}
				});
			}
		}
Esempio n. 12
0
 public Updater(MainForm mainForm)
 {
     this.mainForm = mainForm;
     version = mainForm.version;
 }