Exemplo n.º 1
0
 public LocalMod(OnlineMod online, ModConfig installed)
 {
     online_mod = online;
     installed_mod = installed;
     is_online = true;
     is_installed = true;
 }
Exemplo n.º 2
0
        private void save_button_Click(object sender, EventArgs e)
        {
            var dialog = new SaveFileDialog();
            dialog.Filter = "Zip File (*.zip)|*.zip";
            dialog.ShowDialog();
            if (dialog.FileName.Trim() == "")
            {
                //do nothing lol
                return;
            }
            if (name_text_box.Text.Trim() == "")
            {
                MessageBox.Show(
            "The mod name is empty or invalid.",
            "Mod Naming Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (author_name_text_box.Text.Trim() == "")
            {
                MessageBox.Show(
            "The author name is empty or invalid.",
            "Mod Naming Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (game_combo_box.Text.ToLower() != "brawl" && game_combo_box.Text.ToLower() != "projectm")
            {
                MessageBox.Show(
            "The game name is empty or invalid.",
            "Mod Naming Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (lua_script_location.Trim() == "")
            {
                MessageBox.Show(
            "You must select a valid Lua script.",
            "Lua Script Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (mod_root_folder.Trim() == "")
            {
                MessageBox.Show(
            "You must select a valid mod root folder.",
            "Mod root error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            ModConfig config = new ModConfig();

            //id is 0 because it gets changed during install lol
            config.id = 0;
            config.name = name_text_box.Text.Trim();
            config.author = author_name_text_box.Text.Trim();
            config.game = game_combo_box.Text;
            config.online_mod = false;
            config.install_script = "init.lua";
            config.version = (float)numeric_version_select.Value;
            config.requires_brawlex = brawlex_checkbox.Checked;
            TempFolder.clean_temp_folder();
            Directory.CreateDirectory(ModulousLib.Globals.temporary_path);
            DirectoryCopyExt.DirectoryCopy(mod_root_folder, ModulousLib.Globals.temporary_path, true);
            string content = JsonConvert.SerializeObject(config, Formatting.Indented);
            File.WriteAllText( Path.Combine(ModulousLib.Globals.temporary_path, "mod.json") , content);
            File.Copy(lua_script_location, Path.Combine(ModulousLib.Globals.temporary_path, "init.lua"));
            System.IO.Compression.ZipFile.CreateFromDirectory(ModulousLib.Globals.temporary_path, Path.Combine(ModulousLib.Globals.temporary_path, "temp.zip"));
            File.Copy(Path.Combine(ModulousLib.Globals.temporary_path, "temp.zip"), dialog.FileName, true);
        }
Exemplo n.º 3
0
        private void reload_mods()
        {
            mods_list_view.Items.Clear();
            ModPage mod_page = new ModPage();
            try
            {
                mod_page = ModPage.browse_mods_from_api();
            }
            catch (Exception EX)
            {
                Console.WriteLine(EX.Message);
                MessageBox.Show(
                "Modulous seems to be down, or you are not connected to the internet",
                "Connection", MessageBoxButtons.OK, MessageBoxIcon.Error);

                Application.Exit();
                return;
            }
            foreach (var mod in mod_page.result)
            {
                ModConfig mod_config = new ModConfig();
                if (mod.versions[0].ksp_version == "Brawl" || mod.versions[0].ksp_version == "ProjectM" ||
                    mod.versions[0].ksp_version == "test" || mod.versions[0].ksp_version == "Project M")
                {
                    var mod_config_found = false;
                    var item = new ListViewItem(mod.name);
                    if (mod.other_authors != "" && mod.other_authors != null)
                    {
                        item.SubItems.Add(mod.author + ", " + mod.other_authors);
                    }
                    else
                    {
                        item.SubItems.Add(mod.author);
                    }

                    item.SubItems.Add(mod.versions[0].ksp_version);
                    if (!Directory.Exists(SDCard.sd_card_mod_store_path))
                    {
                        Directory.CreateDirectory(SDCard.sd_card_mod_store_path);
                    }
                    foreach (var directory in Directory.GetDirectories(SDCard.sd_card_mod_store_path))
                    {
                        if (File.Exists(Path.Combine(directory, "mod.json")))
                        {
                            var config = ModConfig.FromFile(Path.Combine(directory, "mod.json"));
                            if (config.online_mod)
                            {
                                if (config.id == mod.id)
                                {
                                    Console.WriteLine("wat");
                                    item.SubItems.Add(config.version.ToString());
                                    item.SubItems.Add(mod.versions[0].friendly_version);
                                    mod_config_found = true;
                                    item.Tag = new LocalMod(mod, config);
                                    mod_config = config;

                                }
                            }
                        }

                    }
                    if (!mod_config_found)
                    {
                        Console.WriteLine(mod.name);
                        item.Tag = new LocalMod(mod);
                        Console.WriteLine("INFO#Mod Config Not Found");
                        item.SubItems.Add("Not Installed");
                        item.SubItems.Add("Not Installed");
                    }
                    mods_list_view.Items.Add(item);

                }
            }
            foreach (var directory in Directory.GetDirectories(SDCard.sd_card_mod_store_path))
            {
                if (File.Exists(Path.Combine(directory, "mod.json")))
                {
                    var config = ModConfig.FromFile(Path.Combine(directory, "mod.json"));
                    if (!config.online_mod)
                    {
                        Console.WriteLine("INFO#Found Local Mod: " + config.name);
                        var item = new ListViewItem(config.name);
                        item.SubItems.Add(config.author);
                        item.SubItems.Add(config.game);
                        item.SubItems.Add(config.version.ToString());
                        item.SubItems.Add("Not a website mod");
                        item.Tag = new LocalMod(config);
                        mods_list_view.Items.Add(item);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public LocalMod get_local_mod()
        {
            OnlineMod mod = this;
            ModConfig mod_config = new ModConfig();
            foreach (var directory in Directory.GetDirectories(SDCard.sd_card_mod_store_path))
            {
                if (File.Exists(Path.Combine(directory, "mod.json")))
                {
                    var config = ModConfig.FromFile(Path.Combine(directory, "mod.json"));
                    if (config.online_mod)
                    {
                        if (config.id == mod.id)
                        {
                            Console.WriteLine("wat");
                            mod_config = config;
                            return new LocalMod(mod, mod_config);

                        }
                    }
                }

            }
                return new LocalMod(mod);
        }
Exemplo n.º 5
0
 public static void update_mod_from_metafile(ModConfig config, int id = 0)
 {
     Directory.CreateDirectory(Globals.temporary_path);
     /*
      * Runs the installation thread.
      */
     var state = new Lua();
     state.LoadCLRPackage();
     state.DoFile(Path.Combine(Globals.AssemblyDirectory, "data/lua/init.lua"));
     state.DoFile(Path.Combine(Globals.temporary_path, config.install_script));
     Directory.CreateDirectory(Path.Combine(new string[] { SDCard.sd_card_mod_store_path, config.name }));
     var json_contents = File.ReadAllText(Path.Combine(Globals.temporary_path, "mod.json"));
     var mod = JsonConvert.DeserializeObject<ModConfig>(json_contents);
     mod.id = id;
     var content = JsonConvert.SerializeObject(mod, Formatting.Indented);
     File.WriteAllText(Path.Combine(Globals.temporary_path, "mod.json"), content);
     File.Copy(Path.Combine(Globals.temporary_path, "mod.json"),
         Path.Combine(new string[] { SDCard.sd_card_mod_store_path, config.name, "mod.json" }));
 }
Exemplo n.º 6
0
        public static void install_mod_from_metafile(ModConfig config, int id = 0)
        {
            Directory.CreateDirectory(Globals.temporary_path);
            /*
             * Runs the installation thread.
             */
            if (config.requires_brawlex == true)
            {
                if (!File.Exists(Path.Combine(SDCard.sd_card_path, "private/wii/app/RSBE/pf/BrawlEx/CSSRoster.dat")))
                {
                    TopMostMessageBox.Show("BrawlEX + CSS Extension is required for this mod to install.", "BrawlEX Error");

                    return;
                }
                if (!Directory.Exists(Path.Combine(SDCard.sd_card_path, "private/wii/app/RSBE/pf/BrawlEx/CosmeticConfig")));
                {
                    Directory.CreateDirectory(Path.Combine(SDCard.sd_card_path, "private/wii/app/RSBE/pf/BrawlEx/CosmeticConfig"));
                }
                if (!Directory.Exists(Path.Combine(SDCard.sd_card_path, "private/wii/app/RSBE/pf/BrawlEx/CSSSlotConfig")));
                {
                    Directory.CreateDirectory(Path.Combine(SDCard.sd_card_path, "private/wii/app/RSBE/pf/BrawlEx/CSSSlotConfig"));
                }
                if (!Directory.Exists(Path.Combine(SDCard.sd_card_path, "private/wii/app/RSBE/pf/BrawlEx/FighterConfig")));
                {
                    Directory.CreateDirectory(Path.Combine(SDCard.sd_card_path,
                        "private/wii/app/RSBE/pf/BrawlEx/FighterConfig"));
                }
                if (!Directory.Exists(Path.Combine(SDCard.sd_card_path, "private/wii/app/RSBE/pf/BrawlEx/SlotConfig")));
                {
                    Directory.CreateDirectory(Path.Combine(SDCard.sd_card_path,
                        "private/wii/app/RSBE/pf/BrawlEx/SlotConfig"));
                }
            }
            var state = new Lua();
            state.LoadCLRPackage();
            Globals.current_mod_config = config;
            state.DoFile(Path.Combine(Globals.AssemblyDirectory, "data/lua/init.lua"));
            state.DoFile(Path.Combine(Globals.temporary_path, config.install_script));
            Directory.CreateDirectory(Path.Combine(new string[] {SDCard.sd_card_mod_store_path, config.name}));
            var json_contents = File.ReadAllText(Path.Combine(Globals.temporary_path, "mod.json"));
            var mod = JsonConvert.DeserializeObject<ModConfig>(json_contents);
            mod.id = id;
            if (id != 0)
            {
                mod.online_mod = true;
            }
            var content = JsonConvert.SerializeObject(mod, Formatting.Indented);
            File.WriteAllText(Path.Combine(Globals.temporary_path, "mod.json"), content);
            File.Copy(Path.Combine(Globals.temporary_path, "mod.json"),
                Path.Combine(new string[] {SDCard.sd_card_mod_store_path, config.name, "mod.json"}));
            File.Copy(Path.Combine(Globals.temporary_path, "init.lua"),
                Path.Combine(new string[] { SDCard.sd_card_mod_store_path, config.name, "init.lua" }));
        }
Exemplo n.º 7
0
 public LocalMod(ModConfig installed)
 {
     installed_mod = installed;
     is_online = false;
     is_installed = true;
 }