Esempio n. 1
0
        public Nclr()
        {
            this.nitro = new NitroFile("NCLR", "1.0", BlockTypes);
            this.pltt  = new Pltt(this.nitro);

            this.nitro.Blocks.Add(this.pltt);
        }
Esempio n. 2
0
        private void GetInfo()
        {
            this.pltt = this.nitro.GetBlock <Pltt>(0);

            int numColors   = (this.pltt.Depth == ColorFormat.Indexed_8bpp) ? 0x100 : 0x10;
            int numPalettes = 0;

            ushort[] index = null;

            if (this.nitro.Blocks.ContainsType("PCMP"))
            {
                this.pcmp   = this.nitro.GetBlock <Pcmp>(0);
                index       = this.pcmp.PaletteIndex;
                numPalettes = this.pcmp.NumPalettes;
            }
            else
            {
                numPalettes = this.pltt.PaletteColors.Length / numColors;
                if (this.pltt.PaletteColors.Length % numColors != 0)
                {
                    numPalettes++;
                }
            }

            this.SetPalette(DividePalette(numColors, numPalettes, this.pltt.PaletteColors, index));
        }
Esempio n. 3
0
        void lstPLTT_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstPltt.SelectedIndex == -1)
            {
                return;
            }
            Pltt plt = new Pltt(txtFile.Text, _plttOffsets[lstPltt.SelectedIndex]);

            lblPltt.Text  = "StartIndex: " + plt.StartIndex + "\nEndIndex: " + plt.EndIndex;
            lblColor.Text = "R:\nG:\nB:\nIndex:";
            for (int i = 0; i < plt.StartIndex; i++)
            {
                _swatches[i].BackColor = Color.Black;
                _swatches[i].Enabled   = false;
            }
            for (int i = plt.StartIndex; i <= plt.EndIndex; i++)
            {
                _swatches[i].Enabled   = true;
                _swatches[i].BackColor = plt.Entries[i];
            }
            for (int i = plt.EndIndex + 1; i < 256; i++)
            {
                _swatches[i].BackColor = Color.Black;
                _swatches[i].Enabled   = false;
            }
        }
Esempio n. 4
0
 private void opnFile_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
 {
     _loading        = true;
     _itemsPanl      = null;
     panView.Enabled = false;
     cmdPanl.Enabled = false;
     try
     {
         cmdMask.Enabled        = true;
         lblFile.Text           = opnFile.FileName;
         _cockpit               = new TieInt(opnFile.FileName);
         cboView.SelectedIndex  = -1;
         cboView.SelectedIndex  = 0;
         cboItems.SelectedIndex = 0;
         panView.Enabled        = true;
         Text = "Cockpit Editor - TIE - " + _cockpit.FileName;
     }
     catch
     {
         MessageBox.Show("Error loading cockpit data, please ensure file is proper TIE95 cockpit INT");
         lblFile.Text  = "(No File open)";
         _cockpit      = null;
         _viewPltt     = null;
         _viewMask     = null;
         _viewPanl     = null;
         pctMask.Image = null;
     }
     _loading = false;
 }
Esempio n. 5
0
 void opnLFD_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
 {
     foreach (PictureBox p in _swatches)
     {
         p.BackColor = Color.Black;
         p.Enabled   = false;
     }
     txtFile.Text = opnLFD.FileName;
     lstPltt.Items.Clear();
     lblPltt.Text  = "StartIndex:\nEndIndex:";
     lblColor.Text = "R:\nG:\nB:\nIndex:";
     try
     {
         Rmap rmp = new Rmap(opnLFD.FileName);
         _plttOffsets = new long[rmp.NumberOfHeaders];
         int pltt = 0;
         for (int i = 0; i < rmp.NumberOfHeaders; i++)
         {
             if (rmp.SubHeaders[i].Type == Resource.ResourceType.Pltt)
             {
                 _plttOffsets[pltt] = rmp.SubHeaders[i].Offset;
                 pltt++;
                 lstPltt.Items.Add(rmp.SubHeaders[i].Name);
             }
         }
     }
     catch             // Cockpit LFD, doesn't have an RMAP but there is a PLTT
     {
         _plttOffsets = new long[1];
         Pltt pal = (Pltt)(new LfdFile(opnLFD.FileName).Resources[2]);
         _plttOffsets[0] = pal.Offset;
         lstPltt.Items.Add(pal.Name);
     }
 }
Esempio n. 6
0
        public Nclr()
        {
            this.nitro = new NitroFile("NCLR", "1.0", BlockTypes);
            this.pltt = new Pltt(this.nitro);

            this.nitro.Blocks.Add(this.pltt);
        }
Esempio n. 7
0
 void setPltt(Pltt palette)
 {
     // NOTE: there are PLTTs that use FF00FF and 0000FF as either placeholders or "skip" markers, not sure.
     // if that gets figured out, will need to add that filtering here.
     for (int i = palette.StartIndex; i < palette.EndIndex; i++)
     {
         _palette.Entries[i] = palette.Entries[i];
     }
     System.Diagnostics.Debug.WriteLine(palette.ToString() + " loaded");
 }
Esempio n. 8
0
        void loadPltt(string id)
        {
            Pltt p = (Pltt)_lfd.Resources[id];

            if (p != null)
            {
                for (int i = p.StartIndex; i <= p.EndIndex; i++)
                {
                    _palette.Entries[i] = p.Entries[i];
                }
            }
            _palette.Entries[0] = Color.Fuchsia;
        }
Esempio n. 9
0
        void setPltt(string path, long filePosition)
        {
            FileStream fsFile = null;

            try
            {
                fsFile = File.OpenRead(path);
                Pltt pltFile = new Pltt(fsFile, filePosition);
                setPltt(pltFile);
            }
            catch
            {
                System.Diagnostics.Debug.WriteLine("failed to set external PLTT");
            }
            if (fsFile != null)
            {
                fsFile.Close();
            }
        }
Esempio n. 10
0
 public BattleForm(Settings config)
 {
     InitializeComponent();
     //this.Height = 342;
     if (!config.TieInstalled)
     {
         MessageBox.Show("TIE95 installation not found, Battle function not available", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.Close();
         return;
     }
     else
     {
         _installPath = config.TiePath;
         // dummy bitmap to create a 256 color palette
         //palette definition
         // start with EMPIRE.PLTTstandard
         Pltt standard = (Pltt)(new LfdFile(_installPath + "\\RESOURCE\\EMPIRE.LFD").Resources["PLTTstandard"]);
         // then open up TOURDESK for the rest
         LfdFile tourdesk = new LfdFile(_installPath + "\\RESOURCE\\TOURDESK.LFD");
         Pltt    toddesk  = (Pltt)tourdesk.Resources["PLTTtoddesk"];
         _systemPalette = Pltt.ConvertToPalette(new Pltt[] { standard, toddesk });
         Delt galaxy = (Delt)tourdesk.Resources["DELTgalaxy"];
         galaxy.Palette       = _systemPalette;
         _galaxyImage         = galaxy.Image;
         picGalaxy.Image      = _galaxyImage;
         picGalaxy.Size       = _galaxyImage.Size;
         numFrameLeft.Maximum = _galaxyImage.Width - 1;
         numFrameTop.Maximum  = _galaxyImage.Height - 1;
     }
     _battlePath = _installPath + "\\RESOURCE\\Battle1.lfd";
     opnMission.InitialDirectory = _installPath + "\\MISSION";
     try { loadFile(_battlePath); }
     catch (Exception x)
     {
         MessageBox.Show(x.Message + " Battle function not available", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
 }
Esempio n. 11
0
 public OfficerPreviewForm(Questions questions)
 {
     try
     {
         string path = new Settings().TiePath + "\\RESOURCE\\";
         _empire = new LfdFile(path + "EMPIRE.LFD");
         _talk   = new LfdFile(path + "TALK.LFD");
     }
     catch (System.IO.FileNotFoundException)
     {
         MessageBox.Show("TIE resource files not found, preview unavailable", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Close();
     }
     _questions = questions;
     InitializeComponent();
     #region Pltt assignments
     Pltt         standard = (Pltt)_empire.Resources["PLTTstandard"];
     Pltt         offcr21  = (Pltt)_talk.Resources["PLTToffcr21"];
     Pltt         offbak   = (Pltt)_talk.Resources["PLTToffbak"];
     Pltt         ssrobe9  = (Pltt)_talk.Resources["PLTTssrobe9"];
     Pltt         ssbak    = (Pltt)_talk.Resources["PLTTssbak"];
     Pltt         doffbak  = (Pltt)_talk.Resources["PLTTdoffbak"];
     Pltt         dssbak   = (Pltt)_talk.Resources["PLTTdssbak"];
     ColorPalette brf_off  = Pltt.ConvertToPalette(new Pltt[] { standard, offcr21, offbak });
     ColorPalette brf_ss   = Pltt.ConvertToPalette(new Pltt[] { standard, ssrobe9, ssbak });
     ColorPalette dbrf_off = Pltt.ConvertToPalette(new Pltt[] { standard, offcr21, doffbak });
     ColorPalette dbrf_ss  = Pltt.ConvertToPalette(new Pltt[] { standard, ssrobe9, dssbak });
     ((Delt)_talk.Resources["DELToffbak"]).Palette = brf_off;
     Delt temp = (Delt)_talk.Resources["DELTofftxt"];
     temp.Palette = brf_off;
     temp.Image.MakeTransparent(Color.Black);
     ((Delt)_talk.Resources["DELTdoffbak"]).Palette = dbrf_off;
     temp         = (Delt)_talk.Resources["DELTdofftxt"];
     temp.Palette = dbrf_off;
     temp.Image.MakeTransparent(Color.Black);
     temp         = (Delt)_talk.Resources["DELToffcr21"];
     temp.Palette = brf_off;
     temp.Image.MakeTransparent(Color.Black);
     ((Anim)_talk.Resources["ANIMeyes"]).SetPalette(brf_off);
     ((Anim)_talk.Resources["ANIMmouth"]).SetPalette(brf_off);
     ((Delt)_talk.Resources["DELTssbak"]).Palette = brf_ss;
     temp         = (Delt)_talk.Resources["DELTsstxt"];
     temp.Palette = brf_ss;
     temp.Image.MakeTransparent(Color.Black);
     ((Delt)_talk.Resources["DELTdssbak"]).Palette = dbrf_ss;
     temp         = (Delt)_talk.Resources["DELTdsstxt"];
     temp.Palette = dbrf_ss;
     temp.Image.MakeTransparent(Color.Black);
     temp         = (Delt)_talk.Resources["DELTssrobe9"];
     temp.Palette = brf_ss;
     temp.Image.MakeTransparent(Color.Black);
     ((Anim)_talk.Resources["ANIMssface"]).SetPalette(brf_ss);
     // offcr21, eyes, mouth, ssrobe9 and ssface technically change between brf and dbrf, but not really
     ((LfdReader.Font)_empire.Resources[_fontID]).SetColor(_normalText);
     #endregion
     #region array declarations
     _opts[0] = optPreOff;
     _opts[1] = optPreSec;
     _opts[2] = optPostOff;
     _opts[3] = optPostSec;
     for (int i = 0; i < 4; i++)
     {
         _opts[i].CheckedChanged += new EventHandler(optsArr_CheckedChanged);
     }
     _opts[0].Checked = true;
     #endregion
 }
 public OfficerPreviewForm(Questions questions, int officer, int question, Settings config)
 {
     try
     {
         string path = config.TiePath + "\\RESOURCE\\";
         _empire = new LfdFile(path + "EMPIRE.LFD");
         _talk   = new LfdFile(path + "TALK.LFD");
     }
     catch (System.IO.FileNotFoundException)
     {
         MessageBox.Show("TIE resource files not found, preview unavailable", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Close();
     }
     _questions = questions;
     InitializeComponent();
     #region Pltt assignments
     Pltt         standard = (Pltt)_empire.Resources["PLTTstandard"];
     Pltt         offcr21  = (Pltt)_talk.Resources["PLTToffcr21"];
     Pltt         offbak   = (Pltt)_talk.Resources["PLTToffbak"];
     Pltt         ssrobe9  = (Pltt)_talk.Resources["PLTTssrobe9"];
     Pltt         ssbak    = (Pltt)_talk.Resources["PLTTssbak"];
     Pltt         doffbak  = (Pltt)_talk.Resources["PLTTdoffbak"];
     Pltt         dssbak   = (Pltt)_talk.Resources["PLTTdssbak"];
     ColorPalette brf_off  = Pltt.ConvertToPalette(new Pltt[] { standard, offcr21, offbak });
     ColorPalette brf_ss   = Pltt.ConvertToPalette(new Pltt[] { standard, ssrobe9, ssbak });
     ColorPalette dbrf_off = Pltt.ConvertToPalette(new Pltt[] { standard, offcr21, doffbak });
     ColorPalette dbrf_ss  = Pltt.ConvertToPalette(new Pltt[] { standard, ssrobe9, dssbak });
     ((Delt)_talk.Resources["DELToffbak"]).Palette = brf_off;
     Delt temp = (Delt)_talk.Resources["DELTofftxt"];
     temp.Palette = brf_off;
     temp.Image.MakeTransparent(Color.Black);
     ((Delt)_talk.Resources["DELTdoffbak"]).Palette = dbrf_off;
     temp         = (Delt)_talk.Resources["DELTdofftxt"];
     temp.Palette = dbrf_off;
     temp.Image.MakeTransparent(Color.Black);
     temp         = (Delt)_talk.Resources["DELToffcr21"];
     temp.Palette = brf_off;
     temp.Image.MakeTransparent(Color.Black);
     ((Anim)_talk.Resources["ANIMeyes"]).SetPalette(brf_off);
     ((Anim)_talk.Resources["ANIMmouth"]).SetPalette(brf_off);
     ((Delt)_talk.Resources["DELTssbak"]).Palette = brf_ss;
     temp         = (Delt)_talk.Resources["DELTsstxt"];
     temp.Palette = brf_ss;
     temp.Image.MakeTransparent(Color.Black);
     ((Delt)_talk.Resources["DELTdssbak"]).Palette = dbrf_ss;
     temp         = (Delt)_talk.Resources["DELTdsstxt"];
     temp.Palette = dbrf_ss;
     temp.Image.MakeTransparent(Color.Black);
     temp         = (Delt)_talk.Resources["DELTssrobe9"];
     temp.Palette = brf_ss;
     temp.Image.MakeTransparent(Color.Black);
     ((Anim)_talk.Resources["ANIMssface"]).SetPalette(brf_ss);
     // offcr21, eyes, mouth, ssrobe9 and ssface technically change between brf and dbrf, but not really
     ((LfdReader.Font)_empire.Resources[_fontID]).SetColor(_normalText);
     #endregion
     #region array declarations
     _opts[0] = optPreOff;
     _opts[1] = optPreSec;
     _opts[2] = optPostOff;
     _opts[3] = optPostSec;
     for (int i = 0; i < 4; i++)
     {
         _opts[i].CheckedChanged += new EventHandler(optsArr_CheckedChanged);
     }
     #endregion
     _activeColor = _normalText;
     if (officer < 0 || officer >= 4)
     {
         officer = 0;
     }
     _opts[officer].Checked = true;
     if (question >= 0 && question <= 4)
     {
         _selectedIndex = -1;  //Prevent "selecting" the wrong question when drawing the selection highlight.
         loadBackAndQuestions();
         for (int i = 0; i < _indexes.Length; i++)
         {
             if (question == _indexes[i])
             {
                 displayQuestion(i);  //This will set the actual _selectedIndex
             }
         }
     }
 }
Esempio n. 13
0
        private void DisplayView()
        {
            _mirror = false;
            string path;

            path = _cockpit.FileDirectory + _cockpit.Views[(int)_currentView].Lfd + ".lfd";
            TieInt.ViewStatus stat = _cockpit.Views[(int)_currentView].Status;
            if (stat == TieInt.ViewStatus.Default)
            {
                path = _cockpit.FileDirectory + _cockpit.Views[(int)TieInt.ViewIndex.Default].Lfd + ".lfd";
            }
            if ((int)stat >= 0xC0)
            {
                _mirror = true;
                path    = _cockpit.FileDirectory + _cockpit.Views[(int)stat - 0xC0].Lfd + ".lfd";
            }
            if (stat != TieInt.ViewStatus.Absent && path != _cockpit.FileDirectory + ".lfd")
            {
                _offsets[0]         = Resource.GetLength(path, 0) + Resource.HeaderLength;
                _offsets[1]         = Resource.GetLength(path, _offsets[0]) + _offsets[0] + Resource.HeaderLength;
                _viewPltt           = new Pltt(path, _offsets[1]);
                _viewMask           = new Mask(path, _offsets[0]);
                _palette            = _viewPltt.Palette;
                _palette.Entries[0] = Color.FromArgb(255, 0, 255);                      // transparent marker
                _viewPanl           = new Panl(path, 0, _palette);
                if (_currentView == TieInt.ViewIndex.Forward && _itemsPanl == null)
                {
                    path       = _cockpit.FileDirectory + _cockpit.Panel + ".pnl";
                    _itemsPanl = new Panl(path, 0, _palette);
                }
                _view = new Bitmap(_viewPanl.Images[0]);
            }
            else
            {
                _view           = new Bitmap(1, 1);
                _viewMask       = null;
                _viewPanl       = null;
                _viewPltt       = null;
                cmdMask.Enabled = false;
            }
            numMaskX.Value      = _cockpit.Views[(int)_currentView].MaskX;
            numMaskY.Value      = _cockpit.Views[(int)_currentView].MaskY;
            numMaskWidth.Value  = _cockpit.Views[(int)_currentView].MaskWidth;
            numMaskHeight.Value = _cockpit.Views[(int)_currentView].MaskHeight;
            numYAxis.Value      = _cockpit.Views[(int)_currentView].YAxis;
            txtLfd.Text         = _cockpit.Views[(int)_currentView].Lfd;
            txtName.Text        = _cockpit.Views[(int)_currentView].Name;
            int[] status = (int[])Enum.GetValues(typeof(TieInt.ViewStatus));
            for (int i = 0; i < status.Length; i++)
            {
                if ((int)stat == status[i])
                {
                    cboStatus.SelectedIndex = i;
                    break;
                }
            }
            pctMask.Invalidate();
            if (_currentView == TieInt.ViewIndex.Forward || _currentView == TieInt.ViewIndex.ThreatDisplay)
            {
                panItems.Enabled = true;
            }
            else
            {
                panItems.Enabled = false;
            }
        }
Esempio n. 14
0
        private void GetInfo()
        {
            this.pltt = this.nitro.GetBlock<Pltt>(0);

            int numColors = (this.pltt.Depth == ColorFormat.Indexed_8bpp) ? 0x100 : 0x10;
            int numPalettes = 0;
            ushort[] index = null;

            if (this.nitro.Blocks.ContainsType("PCMP")) {
                this.pcmp = this.nitro.GetBlock<Pcmp>(0);
                index = this.pcmp.PaletteIndex;
                numPalettes = this.pcmp.NumPalettes;
            } else {
                numPalettes = this.pltt.PaletteColors.Length / numColors;
                if (this.pltt.PaletteColors.Length % numColors != 0) numPalettes++;
            }

            this.SetPalette(DividePalette(numColors, numPalettes, this.pltt.PaletteColors, index));
        }