Esempio n. 1
0
        public Interfaces.Plugin.IToolResult ShowDialog(ref SimPe.Interfaces.Files.IPackedFileDescriptor pfd, ref SimPe.Interfaces.Files.IPackageFile package)
        {
            System.Windows.Forms.DialogResult dr =
                System.Windows.Forms.MessageBox.Show("Using this Tool can serioulsy mess up all of your Neighborhoods. However if some of your Neighborhoods are missing in the Neighborhood Selection of the Game, this Tool might help fixing it.\n\nMake sure you have a Backup of ALL your Neighborhoods befor starting this Tool!\n\nDo you want to start this Tool?", "Confirmation", System.Windows.Forms.MessageBoxButtons.YesNo);


            if (dr == System.Windows.Forms.DialogResult.Yes)
            {
                Wait.SubStop();
                try
                {
                    System.Collections.Hashtable ht = Idno.FindUids(PathProvider.SimSavegameFolder, true);
                    foreach (string file in ht.Keys)
                    {
                        Wait.Message = file;

                        SimPe.Packages.GeneratableFile fl = SimPe.Packages.GeneratableFile.LoadFromFile(file);
                        SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = fl.FindFiles(Data.MetaData.IDNO);
                        foreach (SimPe.Interfaces.Files.IPackedFileDescriptor spfd in pfds)
                        {
                            Idno idno = new Idno();
                            idno.ProcessData(spfd, fl);
                            idno.MakeUnique(ht);

                            idno.SynchronizeUserData();
                        }

                        fl.Save();
                    }
                }
                catch (Exception ex)
                {
                    Helper.ExceptionMessage("", ex);
                }
                finally
                {
                    Wait.SubStop();
                }
            }
            return(new ToolResult(false, false));
        }
Esempio n. 2
0
        private void MakeUnique(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            if (selection == null)
            {
                return;
            }

            WaitingScreen.Wait();
            bool chg = false;

            try
            {
                Hashtable ids = Idno.FindUids(PathProvider.SimSavegameFolder, true);
                foreach (ScannerItem si in selection)
                {
                    if (si.PackageCacheItem.Thumbnail != null)
                    {
                        WaitingScreen.Update(si.PackageCacheItem.Thumbnail, si.FileName);
                    }
                    else
                    {
                        WaitingScreen.UpdateMessage(si.FileName);
                    }

                    SimPe.Cache.PackageState ps = si.PackageCacheItem.FindState(this.Uid, true);
                    if (si.PackageCacheItem.Type == PackageType.Neighborhood)
                    {
                        Interfaces.Files.IPackedFileDescriptor[] pfds = si.Package.FindFiles(Data.MetaData.IDNO);
                        if (pfds.Length > 0)
                        {
                            Idno idno = new Idno();
                            idno.ProcessData(pfds[0], si.Package);
                            idno.MakeUnique(ids);


                            if (ps.Data.Length < 2)
                            {
                                ps.Data = new uint[2];
                            }
                            if (idno.Uid != ps.Data[1])
                            {
                                idno.SynchronizeUserData();
                                si.Package.Save();
                                chg = true;

                                ps.Data[1] = idno.Uid;
                                ps.State   = TriState.True;
                            }
                        }
                    }
                }

                if (chg && this.CallbackFinish != null)
                {
                    this.CallbackFinish(false, false);
                }
            }
#if !DEBUG
            catch (Exception ex) { Helper.ExceptionMessage("", ex); }
#endif
            finally { WaitingScreen.Stop(); }
        }