//edit a mod
        public FormModEditer(oMod sMod)
        {
            this.voidnew();
            this.ButtonReturnToForm1.Visible = false;

            this.SetMod(sMod);
        }
        private void ButtonOpen_Click(object sender, EventArgs e)
        {
            bool canceled = this.AutoAskUserToSaveCurrent();

            if (!canceled)
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Multiselect = false;
                DialogResult rep = ofd.ShowDialog();
                if (rep == DialogResult.OK)
                {
                    try
                    {
                        string OpenFilePath = ofd.FileName;

                        oMod newmod = new oMod(OpenFilePath);
                        this.SetMod(newmod);


                        //set this to the new file opened
                        this.DefineActualFile(OpenFilePath);
                        this.EditsWereMade = false;                         //reset this variable
                    }
                    catch
                    {
                        MessageBox.Show("An error occurred.");
                    }
                }
            }
        }
Пример #3
0
        private void ButtonLoadSingleMod_MouseClick(object sender, MouseEventArgs e)
        {
            //create and setup an open file dialog
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect = false;
            DialogResult rep = ofd.ShowDialog();

            if (rep == DialogResult.OK)
            {
                string FilePath = ofd.FileName;

                try
                {
                    //load the mod object
                    oMod NewMod = new oMod(FilePath);


                    //mods load faster when the tab container does have to refresh while the process.
                    this.TabContainer.Visible = false;
                    Crafts.AddMod(NewMod);
                    this.TabContainer.Visible = true;

                    this.Editer.RefreshImage();
                }
                catch
                {
                    MessageBox.Show("An error occurred");
                }
            }
        }
        public void SetMod(oMod ModToLoad)
        {
            this.Mod = ModToLoad;
            this.ManagerItem.SetMod(ModToLoad);
            this.ManagerCraft.SetMod(ModToLoad);
            //this.ManagerImage.SetMod(ModToLoad);


            this.tbModName.Text = ModToLoad.ModName;             //the event text changed of the textbox will be raised, but because we previously changed this.Mod to the new mod, nothing bad will happen.


            //refresh the managers
            this.ManagerItem.RefreshImage();
            this.ManagerCraft.RefreshImage();
        }
Пример #5
0
        private void Crafts_ModAdded(object sender, ModEventArgs e)
        {
            if (this.Visible)
            {
                //gets the new mod
                oMod newmod = e.Mod;

                //gets the mod name
                string newmodname = newmod.ModName;

                //create the new tool box
                uiToolBox newtb = new uiToolBox(this.Editer, newmodname);

                //create the new tabpage
                this.AddTabPage(newtb, newmodname);
            }
            else
            {
                this.DestroyCraftsEvents();
            }
        }
        private void ButtonNew_Click(object sender, EventArgs e)
        {
            ////TESTEST
            //for (int i = 1; i < 350; i++)
            //{
            //	//create the bitmap
            //	Bitmap miimg = new Bitmap(32, 32);
            //	Graphics g = Graphics.FromImage(miimg);
            //	g.Clear(Color.White);
            //	g.DrawString("_" + i.ToString(), new Font("consolas", 10f), Brushes.Black, 0f, 0f);
            //	g.Dispose();

            //	oMod.ModItem mi = new oMod.ModItem("TestItem_" + i.ToString().PadLeft(4, "0".ToCharArray()[0]), "-", miimg);

            //	//add it
            //	this.Mod.AddItem(mi);

            //}


            bool canceled = this.AutoAskUserToSaveCurrent();

            if (!canceled)
            {
                //build a new mod object
                oMod newmod = new oMod();

                //set the new mod
                this.SetMod(newmod);

                //reset the actual defined file
                this.ClearActualFile();

                //we reset the edits variable
                this.EditsWereMade = false;
            }
        }
 public ModEventArgs(oMod sMod)
 {
     this.Mod = sMod;
 }
Пример #8
0
        //load, in the correct order, every mods (identified by the file extension) found inside a folder.
        private void LoadModsInFolder(string FolderPath)
        {
            //generate a list of every extensions associated to a fomod file.
            //System.IO.Path.GetExtension return the . and the text file path after that dot. for this reason, everything put into this list begins with a .
            List <string> extensions = new List <string>();

            extensions.Add(".fomod");
            for (int i = 1; i <= 9; i++)
            {
                extensions.Add(".fomod" + i.ToString());
                extensions.Add(".fomod" + i.ToString().PadLeft(2, "0".ToCharArray()[0]));
            }
            for (int i = 10; i <= 99; i++)
            {
                extensions.Add(".fomod" + i.ToString().PadLeft(2, "0".ToCharArray()[0]));
            }

            //get every file in this path
            List <string> EveryFilePath = System.IO.Directory.GetFiles(FolderPath).ToList();

            ////filter for fomod files.
            //this list contain, in the appropriate loading order, every mod file's path to load.
            List <string> EveryModPath = new List <string>();

            //because extension array is our first loop, the mod files will be added according to mod load order
            foreach (string ext in extensions)
            {
                //we search every file with this extension
                int index = EveryFilePath.Count - 1;
                while (index >= 0)
                {
                    //the actual file path
                    string FilePath = EveryFilePath[index];
                    try
                    {
                        //get this file's extension
                        string FileExt = System.IO.Path.GetExtension(FilePath);

                        //check if this file's extension is the extension we are actually looking for.
                        if (FileExt == ext)
                        {
                            //because this file's extension is the extension we are actually looking for, we add it to the EveryModPath list
                            EveryModPath.Add(FilePath);

                            //we remove this file from the list, because we know we won't have to analyse it anymore.
                            EveryFilePath.RemoveAt(index);
                        }
                    }
                    catch
                    {
                    }

                    //next iteration
                    index--;
                }

                //if there's no file left in the EveryFilePath list, we can stop because there's nothing left.
                if (EveryFilePath.Count <= 0)
                {
                    break;
                }
            }

            ////create the mod objects for every file
            List <oMod> listMods = new List <oMod>();

            //we create a mod for every file
            foreach (string ModFilePath in EveryModPath)
            {
                try
                {
                    //generate the mod for this file
                    oMod newmod = new oMod(ModFilePath);

                    //add the mod to the list of mod to load
                    listMods.Add(newmod);
                }
                catch
                {
                    MessageBox.Show("An error occurred when loading " + ModFilePath);
                }
            }

            ////load the mods

            //mods load faster when the tab container does have to refresh while the process.
            this.TabContainer.Visible = false;
            Crafts.AddMod(listMods);
            this.TabContainer.Visible = true;

            this.Editer.RefreshImage();
        }