Exemplo n.º 1
0
 private void UpdateProjectClick(object sender, EventArgs e)
 {
     if (CurrentProject != null)
     {
         NewProjectMenu.SetupVersions();
         bool updatedForgeVersion = UpdateProject(NewProjectMenu.Versions[CurrentProject.mcVersion].First(), true);
         bool updateMCPMapping    = UpdateProjectMCP(true);
         if (updatedForgeVersion || updateMCPMapping)
         {
             SetupProject(" --refresh-dependencies");
         }
     }
     else
     {
         MessageBox.Show("Please open a project!", "No open project", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 2
0
 public FMB()
 {
     ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
     InitializeComponent();       //Create the default form stuff
     Resize += ResizeWindow;      //To allow for window resizing
     SetupLayout();               //Setup the layout of the form
     UpdateProjects(false, true); //Receive the projects from the projects.json file
     UpdateOptions(false, true);  //Receive the options from the options.json file
     FormClosed += FMBClosed;     //Handle when the form closes
     optionsToolStripMenuItem.DropDown.Closing += (sender, e) => {
         if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked)
         {
             e.Cancel = true;
         }
         else
         {
             Dictionary <string, bool> checkVersions = new Dictionary <string, bool>();
             foreach (ToolStripMenuItem dropDownItem in SelectVersionsToCheckMenuItem.DropDownItems)
             {
                 checkVersions.Add(dropDownItem.Text, dropDownItem.Checked);
             }
             if (Options.ContainsKey("sync_versions"))
             {
                 Options["sync_versions"] = checkVersions;
             }
             else
             {
                 Options.Add("sync_versions", checkVersions);
             }
             UpdateOptions(true, false);
         }
     };
     SelectVersionsToCheckMenuItem.DropDown.Closing += (sender, e) => {
         if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked)
         {
             e.Cancel = true;
         }
     };
     Load += (sender, e) =>
     {
         UpdateChecker.CheckForUpdates(UpdateChecker.UpdateURL); //When it loads the form, check for updates
         AddBuildFileText("No project loaded");
         BuildFile.ReadOnly = true;
         NewProjectMenu.SetupVersions();
     };
 }
Exemplo n.º 3
0
        //Show the form
        public static DialogResult ShowNewProjectMenu()
        {
            NewProjectMenu menu = new NewProjectMenu();

            return(menu.ShowDialog());
        }
Exemplo n.º 4
0
 //Create a new project
 public void NewProject()
 {
     System.Console.WriteLine("Creating a new project!");
     AddConsoleText("Creating a new project!");
     NewProjectMenu.ShowNewProjectMenu();
 }
Exemplo n.º 5
0
        //Update the projects in the file or in the variable
        public void UpdateProjects(bool saveFile, bool readFromFile)
        {
            if (saveFile)                          //If you want to save
            {
                if (File.Exists(ProjectsFilePath)) //Make sure the file exists
                {
                    JsonSerializer js = new JsonSerializer();
                    js.NullValueHandling = NullValueHandling.Ignore;
                    using (StreamWriter sw = new StreamWriter(ProjectsFilePath))
                        using (JsonWriter jw = new JsonTextWriter(sw))
                        {
                            js.Serialize(jw, Projects); //Write all the data in Projects to the file
                        }
                }
                else //The file does not exist so create it
                {
                    if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/ForgeModBuilder")) //Does the folder not exist?
                    {
                        Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/ForgeModBuilder"); //Create the folder
                    }
                    File.Create(ProjectsFilePath).Dispose();
                    UpdateProjects(saveFile, readFromFile); //Recall the method now that it can find the file
                }
            }
            if (readFromFile)                      //If you want to read data from the file
            {
                if (File.Exists(ProjectsFilePath)) //Make srue the file exists
                {
                    JsonSerializer js = new JsonSerializer();
                    js.NullValueHandling = NullValueHandling.Ignore;
                    using (StreamReader sr = new StreamReader(ProjectsFilePath))
                        using (JsonReader jr = new JsonTextReader(sr))
                        {
                            Projects = js.Deserialize <List <Project> >(jr); //Read the projects
                        }
                    if (Projects == null)
                    {
                        Projects = new List <Project>(); //If the file was empty, initialise Projects to a blank list
                    }
                }
                else //If the file did not exist
                {
                    if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/ForgeModBuilder")) //Does the folder not exist?
                    {
                        Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/ForgeModBuilder"); //Create the folder
                    }
                    File.Create(ProjectsFilePath).Dispose();
                    UpdateProjects(saveFile, readFromFile); //Recall the method now that it can find the file
                }
            }

            //Clear all the menu items which allow you to load that project and run the action as well
            OpenProjectMenuItem.DropDownItems.Clear();
            BuildProjectMenuItem.DropDownItems.Clear();
            SetupProjectMenuItem.DropDownItems.Clear();
            UpdateProjectMenuItem.DropDownItems.Clear();
            ChangeProjectVersionMenuItem.DropDownItems.Clear();
            RefreshProjectMenuItem.DropDownItems.Clear();
            foreach (Project p in Projects) //Add a dropdown for each project
            {
                ToolStripMenuItem i = new ToolStripMenuItem(p.path);
                i.Click += (sender, e) =>
                {
                    if (CurrentProject != p)
                    {
                        OpenProject(p.path); //Make it open the current project if it is not already open
                    }
                };
                OpenProjectMenuItem.DropDownItems.Add(i);
                i        = new ToolStripMenuItem(p.path);
                i.Click += (sender, e) =>
                {
                    if (CurrentProject != p)
                    {
                        OpenProject(p.path); //Make it open the current project if it is not already open
                    }
                    BuildProject();
                };
                BuildProjectMenuItem.DropDownItems.Add(i);
                i        = new ToolStripMenuItem(p.path);
                i.Click += (sender, e) =>
                {
                    if (CurrentProject != p)
                    {
                        OpenProject(p.path); //Make it open the current project if it is not already open
                    }
                    SetupProject("");
                };
                SetupProjectMenuItem.DropDownItems.Add(i);
                i        = new ToolStripMenuItem(p.path);
                i.Click += (sender, e) =>
                {
                    if (CurrentProject != p)
                    {
                        OpenProject(p.path); //Make it open the current project if it is not already open
                    }
                    NewProjectMenu.SetupVersions();
                    UpdateProject(NewProjectMenu.Versions[CurrentProject.mcVersion].First(), true);
                };
                UpdateProjectMenuItem.DropDownItems.Add(i);
                i        = new ToolStripMenuItem(p.path);
                i.Click += (sender, e) =>
                {
                    if (CurrentProject != p)
                    {
                        OpenProject(p.path); //Make it open the current project if it is not already open
                    }
                    ChangeProjectVersionMenu.ShowChangeProjectVersionMenu();
                };
                ChangeProjectVersionMenuItem.DropDownItems.Add(i);
                i        = new ToolStripMenuItem(p.path);
                i.Click += (sender, e) =>
                {
                    if (CurrentProject != p)
                    {
                        OpenProject(p.path); //Make it open the current project if it is not already open
                    }
                    RefreshProject();
                };
                RefreshProjectMenuItem.DropDownItems.Add(i);
            }
        }
Exemplo n.º 6
0
 private void CheckVersionsMenuItem_Click(object sender, EventArgs e)
 {
     NewProjectMenu.Sync = true;
     NewProjectMenu.SetupVersions();
 }
Exemplo n.º 7
0
 private void ClearVersionsCacheMenuItem_Click(object sender, EventArgs e)
 {
     NewProjectMenu.Versions.Clear();
     NewProjectMenu.UpdateVersions(true, false);
     NewProjectMenu.Sync = true;
 }
 public ChangeProjectVersionMenu()
 {
     InitializeComponent();
     NewProjectMenu.SetupVersions();
     LoadVersions();
 }
Exemplo n.º 9
0
 private void CheckVersionsMenuItem_Click(object sender, EventArgs e)
 {
     NewProjectMenu.SyncVersions();
     NewProjectMenu.UpdateVersions(true, false);
     NewProjectMenu.Sync = false;
 }
Exemplo n.º 10
0
 private void UpdateProjectClick(object sender, EventArgs e)
 {
     NewProjectMenu.SetupVersions();
     UpdateProject(NewProjectMenu.Versions[CurrentProject.mcVersion].First(), true);
 }