Exemple #1
0
        private void EditPckMenuItem_Click(object sender, EventArgs e)
        {
            var dependencyName = GetSelectedDependencyName();

            if (dependencyName != null)
            {
                var image = GameInfo.ImageInfo[dependencyName];
                if (image != null)
                {
                    var path = image.BasePath + image.BaseName + ".PCK";
                    if (!File.Exists(path))
                    {
                        MessageBox.Show("File does not exist: " + path);
                    }
                    else
                    {
                        _mainWindowsShowAllManager.HideAll();

                        using (var editor = new PckViewForm())
                        {
                            var pckFile = image.GetPckFile();
                            editor.SelectedPalette = pckFile.Pal.Name;
                            editor.LoadPckFile(path, pckFile.Bpp);

                            var parent = FindForm();

                            Form owner = null;
                            if (parent != null)
                            {
                                owner = parent.Owner;
                            }

                            if (owner == null)
                            {
                                owner = parent;
                            }

                            editor.ShowDialog(owner);
                            if (editor.SavedFile)
                            {
                                GameInfo.ImageInfo.Images[dependencyName].ClearMcd();
                                GameInfo.ClearPckCache(image.BasePath, image.BaseName);

                                OnMapChanged();
                            }
                        }

                        _mainWindowsShowAllManager.RestoreAll();
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Opens PckView with the tileset of the currently selected tile loaded.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal void OnPckEditorClick(object sender, EventArgs e)
        {
            if (SelectedTilepart != null)
            {
                var terrain = ((MapFileChild)MapBase).GetTerrain(SelectedTilepart);

                string terr = terrain.Item1;
                string path = terrain.Item2;

                path = MapBase.Descriptor.GetTerrainDirectory(path);

                string pfePck = Path.Combine(path, terr + GlobalsXC.PckExt);
                string pfeTab = Path.Combine(path, terr + GlobalsXC.TabExt);

                if (!File.Exists(pfePck))
                {
                    MessageBox.Show(
                        this,
                        "File does not exist"
                        + Environment.NewLine + Environment.NewLine
                        + pfePck,
                        "Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        0);
                }
                else if (!File.Exists(pfeTab))
                {
                    MessageBox.Show(
                        this,
                        "File does not exist"
                        + Environment.NewLine + Environment.NewLine
                        + pfeTab,
                        "Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        0);
                }
                else
                {
                    using (var fPckView = new PckViewForm())
                    {
                        fPckView.LoadSpriteset(pfePck);
                        fPckView.SetPalette(MapBase.Descriptor.Pal.Label);

                        _showHideManager.HideViewers();
                        fPckView.ShowDialog(FindForm());
                        _showHideManager.RestoreViewers();

                        if (fPckView.SpritesChanged)                         // (re)load the selected Map.
                        {
                            string notice = "The Map needs to reload to show any"
                                            + " changes that were made to its terrainset.";

                            string changed = String.Empty;
                            if (MapBase.MapChanged)
                            {
                                changed = "Map";
                            }

                            if (MapBase.RoutesChanged)
                            {
                                if (!String.IsNullOrEmpty(changed))
                                {
                                    changed += " and its ";
                                }

                                changed += "Routes";
                            }

                            if (!String.IsNullOrEmpty(changed))
                            {
                                notice += Environment.NewLine + Environment.NewLine
                                          + "You will be asked to save the current"
                                          + " changes to the " + changed + ".";
                            }

                            if (MessageBox.Show(
                                    this,
                                    notice,
                                    "Reload Map",
                                    MessageBoxButtons.OKCancel,
                                    MessageBoxIcon.Information,
                                    MessageBoxDefaultButton.Button1,
                                    0) == DialogResult.OK)
                            {
                                TriggerPckSaved();
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show(
                    this,
                    "Select a Tile.",
                    String.Empty,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Asterisk,
                    MessageBoxDefaultButton.Button1,
                    0);
            }
        }
Exemple #3
0
        /// <summary>
        /// Opens PckView with the tileset of the currently selected tile loaded.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal void OnPckEditorClick(object sender, EventArgs e)
        {
            string terrain = GetTerrainLabel();

            if (!String.IsNullOrEmpty(terrain))
            {
//				string dirTerrain = Path.Combine(MapBase.Descriptor.BasePath, Descriptor.PathTerrain);
                string dirTerrain = (MapBase.Descriptor.Pal == Palette.UfoBattle) ? SharedSpace.ResourceDirectoryUfo
                                                                                                                                                                  : SharedSpace.ResourceDirectoryTftd;
                dirTerrain = Path.Combine(SharedSpace.Instance.GetShare(dirTerrain), Descriptor.PathTerrain);
                string pfePck = Path.Combine(
                    dirTerrain,
                    terrain + SpriteCollection.PckExt);
                string pfeTab = Path.Combine(
                    dirTerrain,
                    terrain + SpriteCollection.TabExt);

                if (!File.Exists(pfePck))
                {
                    MessageBox.Show(
                        this,
                        "File does not exist"
                        + Environment.NewLine + Environment.NewLine
                        + pfePck,
                        "Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        0);
                }
                else if (!File.Exists(pfeTab))
                {
                    MessageBox.Show(
                        this,
                        "File does not exist"
                        + Environment.NewLine + Environment.NewLine
                        + pfeTab,
                        "Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1,
                        0);
                }
                else
                {
                    using (var fPckView = new PckViewForm())
                    {
                        fPckView.LoadSpriteset(pfePck);
                        fPckView.SetPalette(MapBase.Descriptor.Pal.Label);

                        _showHideManager.HideViewers();
                        fPckView.ShowDialog(FindForm());
                        _showHideManager.RestoreViewers();

                        if (fPckView.SpritesChanged)                         // (re)load the selected Map.
                        {
                            string notice = "The Map needs to reload to show any"
                                            + " changes that were made to its terrainset.";

                            string changed = String.Empty;
                            if (MapBase.MapChanged)
                            {
                                changed = "Map";
                            }

                            if (MapBase.RoutesChanged)
                            {
                                if (!String.IsNullOrEmpty(changed))
                                {
                                    changed += " and its ";
                                }

                                changed += "Routes";
                            }

                            if (!String.IsNullOrEmpty(changed))
                            {
                                notice += Environment.NewLine + Environment.NewLine
                                          + "You will be asked to save the current"
                                          + " changes to the " + changed + ".";
                            }

                            if (MessageBox.Show(
                                    this,
                                    notice,
                                    "Reload Map",
                                    MessageBoxButtons.OKCancel,
                                    MessageBoxIcon.Information,
                                    MessageBoxDefaultButton.Button1,
                                    0) == DialogResult.OK)
                            {
                                TriggerPckSaved();
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show(
                    this,
                    "Select a Tile.",
                    String.Empty,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Asterisk,
                    MessageBoxDefaultButton.Button1,
                    0);
            }
        }