Example #1
0
 /** <summary> Opens the water object. </summary> */
 private void Open(object sender, EventArgs e)
 {
     if (fileName == "")
     {
         openFileDialog.InitialDirectory = "";
         openFileDialog.FileName         = "";
     }
     else
     {
         openFileDialog.InitialDirectory = Path.GetDirectoryName(fileName);
         openFileDialog.FileName         = Path.GetFileNameWithoutExtension(fileName);
     }
     if (!changed || WarningMessageBox.Show(this, "Scenery group has been changed.", "Are you sure you want to continue?") == DialogResult.Yes)
     {
         if (openFileDialog.ShowDialog(this) == DialogResult.OK)
         {
             fileName = openFileDialog.FileName;
             ObjectData obj     = ObjectData.FromFile(fileName);
             bool       invalid = false;
             if (obj is SceneryGroup && (obj as SceneryGroup).GraphicsData.NumImages == 2)
             {
                 this.sceneryGroup = (SceneryGroup)obj;
                 LoadSceneryGroup();
             }
             else
             {
                 invalid = true;
             }
             if (invalid)
             {
                 ErrorMessageBox.Show(this, "Failed to load scenery group.", "Object may be invalid.");
             }
         }
     }
 }
Example #2
0
 /** <summary> Opens the water object. </summary> */
 private void Open(object sender, EventArgs e)
 {
     if (fileName == "")
     {
         openFileDialog.InitialDirectory = "";
         openFileDialog.FileName         = "";
     }
     else
     {
         openFileDialog.InitialDirectory = Path.GetDirectoryName(fileName);
         openFileDialog.FileName         = Path.GetFileNameWithoutExtension(fileName);
     }
     if (!changed || WarningMessageBox.Show(this, "Water object has been changed.", "Are you sure you want to continue?") == DialogResult.Yes)
     {
         if (openFileDialog.ShowDialog(this) == DialogResult.OK)
         {
             fileName = openFileDialog.FileName;
             ObjectData obj     = ObjectData.FromFile(fileName);
             bool       invalid = false;
             if (obj is Water)
             {
                 waterObject = (Water)obj;
                 if (waterObject.GraphicsData.NumPalettes == 7 && waterObject.GraphicsData.NumImages == 0 &&
                     waterObject.GraphicsData.GetPalette(0).Colors.Length == 236 &&
                     waterObject.GraphicsData.GetPalette(1).Colors.Length == 15 &&
                     waterObject.GraphicsData.GetPalette(2).Colors.Length == 15 &&
                     waterObject.GraphicsData.GetPalette(3).Colors.Length == 15 &&
                     waterObject.GraphicsData.GetPalette(4).Colors.Length == 15 &&
                     waterObject.GraphicsData.GetPalette(5).Colors.Length == 15 &&
                     waterObject.GraphicsData.GetPalette(6).Colors.Length == 15)
                 {
                     LoadFromObject();
                     SelectColor();
                     changed = false;
                 }
                 else
                 {
                     invalid = true;
                 }
             }
             else
             {
                 invalid = true;
             }
             if (invalid)
             {
                 ErrorMessageBox.Show(this, "Failed to load water object.", "Object may be invalid.");
             }
         }
     }
 }
Example #3
0
        //============= TABS =============
        #region Tabs

        /** <summary> Called when an object is selected from the list. </summary> */
        private void ObjectChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            if (e.Item.Selected && ((sender as ListView).SelectedItems.Count == 0 || (sender as ListView).SelectedItems[0] == e.Item))
            {
                objectIndex = e.ItemIndex;
                objectData  = ObjectData.FromFile(Path.Combine(directory, e.Item.SubItems[2].Text));
                this.UpdateImages();
                this.labelCurrentObject.Text = (objectData != null ? objectData.ObjectHeader.FileName + ".DAT" : "");
                if (objectData == null)
                {
                    this.labelCurrentObject.Text = "";
                }
                else
                {
                    this.labelCurrentObject.Text = objectData.ObjectHeader.FileName + ".DAT";
                }
            }
        }