A wrapper for per-World metadata, designed to be usable with SortableBindingList. All these properties map directly to the UI controls.
Inheritance: ICloneable
Exemple #1
0
 public WorldListEntry( WorldListEntry original ) {
     name = original.Name;
     Hidden = original.Hidden;
     Backup = original.Backup;
     accessSecurity = new SecurityController( original.accessSecurity );
     buildSecurity = new SecurityController( original.buildSecurity );
 }
Exemple #2
0
 public WorldListEntry(WorldListEntry original)
 {
     name           = original.Name;
     Hidden         = original.Hidden;
     Backup         = original.Backup;
     accessSecurity = new SecurityController(original.accessSecurity);
     buildSecurity  = new SecurityController(original.buildSecurity);
 }
        public AddWorldPopup(WorldListEntry _world)
        {
            InitializeComponent();
            fileBrowser.Filter = MapLoadFilter;

            cBackup.Items.AddRange(World.BackupEnum);
            cTemplates.Items.AddRange(Enum.GetNames(typeof(MapGenTemplate)));
            cTheme.Items.AddRange(Enum.GetNames(typeof(MapGenTheme)));

            bwLoader.DoWork             += AsyncLoad;
            bwLoader.RunWorkerCompleted += AsyncLoadCompleted;

            bwGenerator.DoWork += AsyncGen;
            bwGenerator.WorkerReportsProgress = true;
            bwGenerator.ProgressChanged      += AsyncGenProgress;
            bwGenerator.RunWorkerCompleted   += AsyncGenCompleted;

            bwRenderer.WorkerReportsProgress      = true;
            bwRenderer.WorkerSupportsCancellation = true;
            bwRenderer.DoWork             += AsyncDraw;
            bwRenderer.ProgressChanged    += AsyncDrawProgress;
            bwRenderer.RunWorkerCompleted += AsyncDrawCompleted;

            nWidthX.Validating += MapDimensionValidating;
            nWidthY.Validating += MapDimensionValidating;
            nHeight.Validating += MapDimensionValidating;

            cAccess.Items.Add("(everyone)");
            cBuild.Items.Add("(everyone)");
            foreach (Rank rank in RankManager.Ranks)
            {
                cAccess.Items.Add(rank.ToComboBoxOption());
                cBuild.Items.Add(rank.ToComboBoxOption());
            }

            tStatus1.Text = "";
            tStatus2.Text = "";

            world = _world;

            savePreviewDialog.Filter = "PNG Image|*.png|TIFF Image|*.tif;*.tiff|Bitmap Image|*.bmp|JPEG Image|*.jpg;*.jpeg";
            savePreviewDialog.Title  = "Saving preview image...";

            browseTemplateDialog.Filter = "MapGenerator Template|*.ftpl";
            browseTemplateDialog.Title  = "Opening a MapGenerator template...";

            saveTemplateDialog.Filter = browseTemplateDialog.Filter;
            saveTemplateDialog.Title  = "Saving a MapGenerator template...";

            Shown += LoadMap;
        }
Exemple #4
0
        public AddWorldPopup( WorldListEntry _world ) {
            InitializeComponent();
            fileBrowser.Filter = MapLoadFilter;

            cBackup.Items.AddRange( World.BackupEnum );
            cTemplates.Items.AddRange( Enum.GetNames( typeof( MapGenTemplate ) ) );
            cTheme.Items.AddRange( Enum.GetNames( typeof( MapGenTheme ) ) );

            bwLoader.DoWork += AsyncLoad;
            bwLoader.RunWorkerCompleted += AsyncLoadCompleted;

            bwGenerator.DoWork += AsyncGen;
            bwGenerator.WorkerReportsProgress = true;
            bwGenerator.ProgressChanged += AsyncGenProgress;
            bwGenerator.RunWorkerCompleted += AsyncGenCompleted;

            bwRenderer.WorkerReportsProgress = true;
            bwRenderer.WorkerSupportsCancellation = true;
            bwRenderer.DoWork += AsyncDraw;
            bwRenderer.ProgressChanged += AsyncDrawProgress;
            bwRenderer.RunWorkerCompleted += AsyncDrawCompleted;

            nWidthX.Validating += MapDimensionValidating;
            nWidthY.Validating += MapDimensionValidating;
            nHeight.Validating += MapDimensionValidating;

            cAccess.Items.Add( "(everyone)" );
            cBuild.Items.Add( "(everyone)" );
            foreach( Rank rank in RankManager.Ranks ) {
                cAccess.Items.Add( rank.ToComboBoxOption() );
                cBuild.Items.Add( rank.ToComboBoxOption() );
            }

            tStatus1.Text = "";
            tStatus2.Text = "";

            world = _world;

            savePreviewDialog.Filter = "PNG Image|*.png|TIFF Image|*.tif;*.tiff|Bitmap Image|*.bmp|JPEG Image|*.jpg;*.jpeg";
            savePreviewDialog.Title = "Saving preview image...";

            browseTemplateDialog.Filter = "MapGenerator Template|*.ftpl";
            browseTemplateDialog.Title = "Opening a MapGenerator template...";

            saveTemplateDialog.Filter = browseTemplateDialog.Filter;
            saveTemplateDialog.Title = "Saving a MapGenerator template...";

            Shown += LoadMap;
        }
        void LoadMap(object sender, EventArgs args)
        {
            // Fill in the "Copy existing world" combobox
            foreach (WorldListEntry otherWorld in ConfigUI.worlds)
            {
                if (otherWorld != world)
                {
                    cWorld.Items.Add(otherWorld.name + " (" + otherWorld.Description + ")");
                    copyOptionsList.Add(otherWorld);
                }
            }

            if (world == null)
            {
                Text  = "Adding a New World";
                world = new WorldListEntry();
                int worldNameCounter = 1;
                for ( ; ConfigUI.IsWorldNameTaken("NewWorld" + worldNameCounter); worldNameCounter++)
                {
                    ;
                }
                world.name            = "NewWorld" + worldNameCounter;
                tName.Text            = world.Name;
                cAccess.SelectedIndex = 0;
                cBuild.SelectedIndex  = 0;
                cBackup.SelectedIndex = 5;
                map = null;
            }
            else
            {
                world                = new WorldListEntry(world);
                Text                 = "Editing World \"" + world.Name + "\"";
                originalWorldName    = world.Name;
                tName.Text           = world.Name;
                cAccess.SelectedItem = world.AccessPermission;
                cBuild.SelectedItem  = world.BuildPermission;
                cBackup.SelectedItem = world.Backup;
                xHidden.Checked      = world.Hidden;
            }

            // Disable "copy" tab if there are no other worlds
            if (cWorld.Items.Count > 0)
            {
                cWorld.SelectedIndex = 0;
            }
            else
            {
                tabs.TabPages.Remove(tabCopy);
            }

            // Disable "existing map" tab if there are no other worlds
            fileToLoad = Path.Combine(Paths.MapPath, world.Name + ".fcm");
            if (File.Exists(fileToLoad))
            {
                ShowMapDetails(tExistingMapInfo, fileToLoad);
                StartLoadingMap();
            }
            else
            {
                tabs.TabPages.Remove(tabExisting);
                tabs.SelectTab(tabLoad);
            }

            // Set Generator comboboxes to defaults
            cTemplates.SelectedIndex = (int)MapGenTemplate.River;

            savePreviewDialog.FileName = world.name;
        }
Exemple #6
0
        void LoadMap( object sender, EventArgs args ) {

            // Fill in the "Copy existing world" combobox
            foreach( WorldListEntry otherWorld in ConfigUI.worlds ) {
                if( otherWorld != world ) {
                    cWorld.Items.Add( otherWorld.name + " (" + otherWorld.Description + ")" );
                    copyOptionsList.Add( otherWorld );
                }
            }

            if( world == null ) {
                Text = "Adding a New World";
                world = new WorldListEntry();
                int worldNameCounter = 1;
                for( ; ConfigUI.IsWorldNameTaken( "NewWorld" + worldNameCounter ); worldNameCounter++ ) ;
                world.name = "NewWorld" + worldNameCounter;
                tName.Text = world.Name;
                cAccess.SelectedIndex = 0;
                cBuild.SelectedIndex = 0;
                cBackup.SelectedIndex = 5;
                map = null;
            } else {
                world = new WorldListEntry( world );
                Text = "Editing World \"" + world.Name + "\"";
                originalWorldName = world.Name;
                tName.Text = world.Name;
                cAccess.SelectedItem = world.AccessPermission;
                cBuild.SelectedItem = world.BuildPermission;
                cBackup.SelectedItem = world.Backup;
                xHidden.Checked = world.Hidden;
            }

            // Disable "copy" tab if there are no other worlds
            if( cWorld.Items.Count > 0 ) {
                cWorld.SelectedIndex = 0;
            } else {
                tabs.TabPages.Remove( tabCopy );
            }

            // Disable "existing map" tab if there are no other worlds
            fileToLoad = Path.Combine( Paths.MapPath, world.Name + ".fcm" );
            if( File.Exists( fileToLoad ) ) {
                ShowMapDetails( tExistingMapInfo, fileToLoad );
                StartLoadingMap();
            } else {
                tabs.TabPages.Remove( tabExisting );
                tabs.SelectTab( tabLoad );
            }

            // Set Generator comboboxes to defaults
            cTemplates.SelectedIndex = (int)MapGenTemplate.River;

            savePreviewDialog.FileName = world.name;
        }