public BattleForm(Settings config) { InitializeComponent(); this.Height = 326; 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; } }
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 }
/// <summary>Opens the LFD and reads it into the program</summary> /// <param name="path">The full filename of the LFD to open</param> void loadFile(string path) { _battle = new LfdFile(path); Text txt = (Text)_battle.Resources[0]; txtBattle.Text = ""; txtCutscene.Text = ""; txtBTitle1.Text = ""; txtBTitle2.Text = ""; txtCTitle1.Text = ""; txtCTitle2.Text = ""; txtSystem.Text = ""; lstMiss.Items.Clear(); _missionFiles = new string[8]; _missionDescriptions = new string[8]; lblBattle.Text = txt.Name; _numMiss = txt.NumberOfStrings - 4; // Titles string[] strTemp = txt.Strings[0].Split('\0'); txtBattle.Text = strTemp[0]; txtCutscene.Text = strTemp[1]; // Text strTemp = txt.Strings[1].Split('\0'); txtBTitle1.Text = strTemp[0]; txtBTitle2.Text = strTemp[1]; txtCTitle1.Text = strTemp[2]; if (strTemp.Length == 4) txtCTitle2.Text = strTemp[3]; // TFW's fault, either left off, or only appends '\0', not '\0\0' // System strTemp = txt.Strings[2].Split('\0'); _deltName = strTemp[0]; txtSystem.Text = strTemp[1]; #region Image Frame _loading = true; string[] str_frame = strTemp[2].Split(' '); numFrameTop.Value = Convert.ToInt32(str_frame[0]); numFrameHeight.Value = Convert.ToInt32(str_frame[1]); numFrameLeft.Value = Convert.ToInt32(str_frame[2]); numFrameWidth.Value = Convert.ToInt32(str_frame[3]); _loading = false; drawFrame(); #endregion // Missions strTemp = txt.Strings[3].Split('\0'); for (int i=0;i<strTemp.Length;i++) _missionFiles[i] = strTemp[i]; for(int i=0;i<_numMiss;i++) lstMiss.Items.Add(_missionFiles[i]); // Descriptions for(int i=0;i<_numMiss;i++) { _missionDescriptions[i] = txt.Strings[4+i]; _missionDescriptions[i] = _missionDescriptions[i].TrimEnd('\0').Replace("\0","\r\n"); } txtDesc.Text = _missionDescriptions[0]; #region System image try { Delt delSystem = (Delt)_battle.Resources[1]; delSystem.Palette = _systemPalette; _systemImage = delSystem.Image; picSystem.Image = _systemImage; picSystem.Size = _systemImage.Size; } catch(Exception x) { MessageBox.Show(x.Message + " System image unavailable.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } #endregion }
/// <summary>Create a new Rmap instance with the specific LFD template</summary> /// <param name="category">The type of LFD file</param> /// <exception cref="System.ArgumentException">Cockpit LFDs do not contain Rmaps<br/><b>-or-</b><br/>Normal LFDs must be initialized with <see cref="Rmap(int)"/></exception> /// <remarks>Only usable with <see cref="LfdFile.LfdCategory.Battle"/> files, initializes for a <see cref="Text"/> and <see cref="Delt"/> resources.</remarks> public Rmap(LfdFile.LfdCategory category) { if (category == LfdFile.LfdCategory.Battle) { _name = _defaultName; _headers = new SubHeader[2]; _headers[0].Type = Resource.ResourceType.Text; _headers[0].Name = "battle#"; _headers[0].Offset = HeaderLength; _headers[0].Length = -1; _headers[1].Type = Resource.ResourceType.Delt; _headers[1].Name = "b#gal"; _headers[1].Offset = -1; _headers[1].Length = -1; } else if (category == LfdFile.LfdCategory.Cockpit) throw new ArgumentException("Cockpit LFDs do not use RMAP", "category"); else throw new ArgumentException("Normal LFDs must be initialized with Rmap(int)", "category"); _type = ResourceType.Rmap; }