private void UpdateUIFromEntry( Database.Entry _Entry ) { textBoxRelativePath.Text = _Entry != null ? _Entry.RelativePath : ""; textBoxFriendlyName.Text = _Entry != null ? _Entry.FriendlyName : ""; textBoxDescription.Text = _Entry != null ? _Entry.Description : ""; textBoxOverviewImage.Text = _Entry != null && _Entry.OverviewImageFileName != null ? _Entry.OverviewImageFileName.FullName : ""; panelOverviewImage.SourceImage = _Entry != null ? _Entry.OverviewImage : null; panelThumbnail.SourceImage = _Entry != null ? _Entry.Thumbnail : null; UpdateTagsUIFromEntry( _Entry ); Database.Manifest M = _Entry != null ? _Entry.Manifest : null; if ( M != null ) M.LoadTextures(); // Make sure textures are ready panelSwatchMin.BackColor = M != null ? M.m_SwatchMin.Color : BackColor; panelSwatchMax.BackColor = M != null ? M.m_SwatchMax.Color : BackColor; panelSwatchAvg.BackColor = M != null ? M.m_SwatchAvg.Color : BackColor; Panel[] CustomSwatchPanels = new Panel[] { panelCS0, panelCS1, panelCS2, panelCS3, panelCS4, panelCS5, panelCS6, panelCS7, panelCS8, }; for ( int i=0; i < CustomSwatchPanels.Length; i++ ) { bool Available = M != null && i < M.m_CustomSwatches.Length; CustomSwatchPanels[i].BackColor = Available ? M.m_CustomSwatches[i].Color : BackColor; panelTexture.CustomSwatches[i] = Available ? new WMath.Vector4D( M.m_CustomSwatches[i].m_LocationTopLeft.x, M.m_CustomSwatches[i].m_LocationTopLeft.y, M.m_CustomSwatches[i].m_LocationBottomRight.x, M.m_CustomSwatches[i].m_LocationBottomRight.y ) : null; } panelTexture.SourceImage = M != null ? M.m_Texture : null; }
private void UpdateTagsUIFromEntry( Database.Entry _Entry ) { m_ModifyingCheckboxes = true; SetMutuallyExclusiveChoice( _Entry != null ? (int) _Entry.TagType : 0, c0 ); // SetMutuallyExclusiveChoice( _Entry != null ? (int) _Entry.TagColor : 0, c1 ); SetFlagChoice( _Entry != null ? (int) _Entry.TagColor : 0, c1 ); SetMutuallyExclusiveChoice( _Entry != null ? (int) _Entry.TagShade : 0, c2 ); SetMutuallyExclusiveChoiceWithMaster( _Entry != null ? (int) _Entry.TagNature : 0, (int) Database.Entry.TAGS_NATURE.NATURE, c3 ); SetMutuallyExclusiveChoiceWithMaster( _Entry != null ? (int) _Entry.TagFurniture : 0, (int) Database.Entry.TAGS_FURNITURE.FURNITURE, c4 ); SetMutuallyExclusiveChoiceWithMaster( _Entry != null ? (int) _Entry.TagConstruction : 0, (int) Database.Entry.TAGS_CONSTRUCTION.CONSTRUCTION, c5 ); SetFlagChoice( _Entry != null ? (int) _Entry.TagModifiers : 0, c6 ); m_ModifyingCheckboxes = false; }
private void buttonLoadDatabase_Click( object sender, EventArgs e ) { if ( m_Database != null && m_Database.Entries.Length > 0 ) { // Caution! if ( MessageBox( "Loading a new database will lose existing database data, do you wish to continue?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning ) != DialogResult.Yes ) return; } string OldFileName = GetRegKey( "DatabaseFileName", Path.Combine( m_ApplicationPath, "Database.rdb" ) ); openFileDialogDatabase.InitialDirectory = Path.GetFullPath( OldFileName ); openFileDialogDatabase.FileName = Path.GetFileName( OldFileName ); if ( openFileDialogDatabase.ShowDialog( this ) != DialogResult.OK ) return; SetRegKey( "DatabaseFileName", openFileDialogDatabase.FileName ); try { Database D = new Database(); try { D.Load( new FileInfo( openFileDialogDatabase.FileName ) ); } catch ( Database.InvalidDatabaseRootPathException _e ) { MessageBox( "The database could not be opened completely as it did not manage to reconnect manifest files on disk based on its embedded location path.\nConsider changing the root folder location to a valid path.\n\nError: " + _e.Message, MessageBoxButtons.OK, MessageBoxIcon.Warning ); } if ( m_Database != null ) m_Database.Dispose(); Database = D; // Update UI textBoxDatabaseFileName.Text = openFileDialogDatabase.FileName; UpdateDatabaseEntries(); } catch ( Exception _e ) { MessageBox( "An error occurred while opening the database:\n\n", _e ); } }
public void Save( Database _Owner, XmlElement _EntryElement ) { _Owner.SetAttribute( _EntryElement, "RelativePath", m_RelativePath ); _Owner.SetAttribute( _Owner.AppendElement( _EntryElement, "FriendlyName" ), "Value", m_FriendlyName ); _Owner.SetAttribute( _Owner.AppendElement( _EntryElement, "Description" ), "Value", m_Description ); if ( m_OverviewImageRelativePath != null ) _Owner.SetAttribute( _Owner.AppendElement( _EntryElement, "EnvironmentImage" ), "RelativePath", m_OverviewImageRelativePath ); XmlElement TagsElement = _Owner.AppendElement( _EntryElement, "Tags" ); _Owner.SetAttribute( _Owner.AppendElement( TagsElement, "Type" ), "Value", m_TagType.ToString() ); _Owner.SetAttribute( _Owner.AppendElement( TagsElement, "Color" ), "Value", m_TagColor.ToString() ); _Owner.SetAttribute( _Owner.AppendElement( TagsElement, "Shade" ), "Value", m_TagShade.ToString() ); _Owner.SetAttribute( _Owner.AppendElement( TagsElement, "Nature" ), "Value", m_TagNature.ToString() ); _Owner.SetAttribute( _Owner.AppendElement( TagsElement, "Furniture" ), "Value", m_TagFurniture.ToString() ); _Owner.SetAttribute( _Owner.AppendElement( TagsElement, "Construction" ), "Value", m_TagConstruction.ToString() ); _Owner.SetAttribute( _Owner.AppendElement( TagsElement, "Modifiers" ), "Value", m_TagModifiers.ToString() ); }
public void Load( Database _Owner, XmlElement _EntryElement ) { m_RelativePath = _EntryElement.GetAttribute( "RelativePath" ); m_FriendlyName = _EntryElement["FriendlyName"].GetAttribute( "Value" ); m_Description = _EntryElement["Description"].GetAttribute( "Value" ); if ( _EntryElement["EnvironmentImage"] != null ) m_OverviewImageRelativePath = _EntryElement["EnvironmentImage"].GetAttribute( "RelativePath" ); XmlElement TagsElement = _EntryElement["Tags"]; if ( TagsElement == null ) throw new Exception( "Failed to retrieve \"Tags\" element!" ); m_TagType = (TAGS_TYPE) Enum.Parse( typeof(TAGS_TYPE), TagsElement["Type"].GetAttribute( "Value" ) ); m_TagColor = (TAGS_COLOR) Enum.Parse( typeof(TAGS_COLOR), TagsElement["Color"].GetAttribute( "Value" ) ); m_TagShade = (TAGS_SHADE) Enum.Parse( typeof(TAGS_SHADE), TagsElement["Shade"].GetAttribute( "Value" ) ); m_TagNature = (TAGS_NATURE) Enum.Parse( typeof(TAGS_NATURE), TagsElement["Nature"].GetAttribute( "Value" ) ); m_TagFurniture = (TAGS_FURNITURE) Enum.Parse( typeof(TAGS_FURNITURE), TagsElement["Furniture"].GetAttribute( "Value" ) ); m_TagConstruction = (TAGS_CONSTRUCTION) Enum.Parse( typeof(TAGS_CONSTRUCTION), TagsElement["Construction"].GetAttribute( "Value" ) ); m_TagModifiers = (TAGS_MODIFIERS) Enum.Parse( typeof(TAGS_MODIFIERS), TagsElement["Modifiers"].GetAttribute( "Value" ) ); }
public Entry( Database _Owner ) { m_Owner = _Owner; }