public void Update(int number, VClip clip, PIGFile piggyFile, Palette palette) { isLocked = true; vclipID = number; this.clip = clip; this.piggyFile = piggyFile; this.palette = palette; FrameTimeTextBox.Text = clip.FrameTime.ToString(); TotalTimeTextBox.Text = clip.PlayTime.ToString(); LightValueTextBox.Text = clip.LightValue.ToString(); SoundComboBox.SelectedIndex = clip.SoundNum + 1; FrameCountTextBox.Text = clip.NumFrames.ToString(); VClipRodFlag.Checked = clip.DrawAsRod; if (!transactionManager.TransactionInProgress) { FrameSpinner.Value = 0; UpdateAnimationFrame(0); } else { UpdateAnimationFrame((int)FrameSpinner.Value); } isLocked = false; }
public void Init(List <string> SoundNames, List <string> VClipNames, List <string> WeaponNames, List <string> ModelNames, PIGFile piggyFile, Palette palette) { this.piggyFile = piggyFile; this.palette = palette; isLocked = true; cbWeaponFireSound.Items.Clear(); cbWeaponFireSound.Items.Add("None"); cbWeaponRobotHitSound.Items.Clear(); cbWeaponRobotHitSound.Items.Add("None"); cbWeaponWallHitSound.Items.Clear(); cbWeaponWallHitSound.Items.Add("None"); string[] stringarray = SoundNames.ToArray(); cbWeaponFireSound.Items.AddRange(stringarray); cbWeaponRobotHitSound.Items.AddRange(stringarray); cbWeaponWallHitSound.Items.AddRange(stringarray); cbWeaponMuzzleFlash.Items.Clear(); cbWeaponMuzzleFlash.Items.Add("None"); cbWeaponWallHit.Items.Clear(); cbWeaponWallHit.Items.Add("None"); cbWeaponRobotHit.Items.Clear(); cbWeaponRobotHit.Items.Add("None"); cbWeaponVClip.Items.Clear(); cbWeaponVClip.Items.Add("None"); stringarray = VClipNames.ToArray(); cbWeaponMuzzleFlash.Items.AddRange(stringarray); cbWeaponWallHit.Items.AddRange(stringarray); cbWeaponRobotHit.Items.AddRange(stringarray); cbWeaponVClip.Items.AddRange(stringarray); cbWeaponChildren.Items.Clear(); cbWeaponChildren.Items.Add("None"); //this will be fun since my own size can change. ugh cbWeaponChildren.Items.AddRange(WeaponNames.ToArray()); cbWeaponModel1.Items.Clear(); cbWeaponModel1.Items.Add("None"); cbWeaponModel2.Items.Clear(); cbWeaponModel2.Items.Add("None"); stringarray = ModelNames.ToArray(); cbWeaponModel1.Items.AddRange(stringarray); cbWeaponModel2.Items.AddRange(stringarray); isLocked = false; }
public void Update(int number, EClip clip, PIGFile piggyFile) { isLocked = true; eclipID = number; this.clip = clip; this.piggyFile = piggyFile; //vclip specific data txtEffectFrameSpeed.Text = clip.Clip.FrameTime.ToString(); txtEffectTotalTime.Text = clip.Clip.PlayTime.ToString(); txtEffectLight.Text = clip.Clip.LightValue.ToString(); txtEffectFrameCount.Text = clip.Clip.NumFrames.ToString(); //eclip stuff cbEClipBreakEClip.SelectedIndex = clip.ExplosionEClip + 1; cbEClipBreakVClip.SelectedIndex = clip.ExplosionVClip + 1; txtEffectExplodeSize.Text = clip.ExplosionSize.ToString(); txtEffectBrokenID.Text = clip.DestroyedBitmapNum.ToString(); cbEClipBreakSound.SelectedIndex = clip.SoundNum + 1; cbEClipMineCritical.SelectedIndex = clip.CriticalClip + 1; FrameSpinner.Value = 0; UpdateEffectFrame(0); isLocked = false; }
public PolymodelPanel(TransactionManager transactionManager, int tabPage, PIGFile piggyFile, Palette palette, EditorHAMFile datafile = null) { InitializeComponent(); this.transactionManager = transactionManager; this.tabPage = tabPage; //Create the model viewer baround the template control ModelViewControl = new OpenTK.GLControl(); ModelViewControl.BackColor = System.Drawing.Color.Black; ModelViewControl.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; ModelViewControl.Location = new System.Drawing.Point(452, 61); ModelViewControl.Anchor = GLControlStandin.Anchor; ModelViewControl.Name = "glControl1"; ModelViewControl.Size = new System.Drawing.Size(256, 256); ModelViewControl.TabIndex = 0; ModelViewControl.VSync = false; ModelViewControl.Load += new System.EventHandler(this.ModelViewControl_Load); ModelViewControl.Paint += new System.Windows.Forms.PaintEventHandler(this.ModelViewControl_Paint); Controls.Add(ModelViewControl); if (datafile != null) { modelRenderer = new ModelRenderer(datafile, piggyFile, palette); } else { modelRenderer = new ModelRenderer(piggyFile, palette); } }
public ImageSelector(PIGFile pigFile, Palette palette, bool animOnly) { InitializeComponent(); this.pigFile = pigFile; this.palette = palette; this.animOnly = animOnly; }
public void Update(EditorHAMFile datafile, PIGFile piggyFile, int textureID, TMAPInfo info) { isLocked = true; this.textureID = textureID; this.datafile = datafile; this.piggyFile = piggyFile; this.info = info; TextureIDTextBox.Text = datafile.Textures[textureID].ToString(); txtTexLight.Text = info.Lighting.ToString(); txtTexDamage.Text = info.Damage.ToString(); cbTexEClip.SelectedIndex = info.EClipNum + 1; txtTexSlideU.Text = GetFloatFromFixed88(info.SlideU).ToString(); txtTexSlideV.Text = GetFloatFromFixed88(info.SlideV).ToString(); TextureDestroyedTextBox.Text = info.DestroyedID.ToString(); cbTexLava.Checked = info.Volatile; cbTexWater.Checked = info.Water; cbTexForcefield.Checked = info.ForceField; cbTexRedGoal.Checked = info.RedGoal; cbTexBlueGoal.Checked = info.BlueGoal; cbTexHoardGoal.Checked = info.HoardGoal; UpdatePictureBox(PiggyBitmapUtilities.GetBitmap(piggyFile, palette, datafile.Textures[textureID]), pbTexPrev); isLocked = false; }
public EditorHAMFile(HAMFile baseFile, PIGFile piggyFile) { BaseFile = baseFile; this.piggyFile = piggyFile; EClipNameMapping = new Dictionary <string, EClip>(); ObjBitmapMapping = new Dictionary <string, int>(); Textures = new List <ushort>(); TMapInfo = new List <TMAPInfo>(); VClips = new List <VClip>(); EClips = new List <EClip>(); WClips = new List <WClip>(); Robots = new List <Robot>(); Joints = new List <JointPos>(); Weapons = new List <Weapon>(); Models = new List <Polymodel>(); Gauges = new List <ushort>(); GaugesHires = new List <ushort>(); ObjBitmaps = new List <ushort>(); ObjBitmapPointers = new List <ushort>(); Cockpits = new List <ushort>(); Reactors = new List <Reactor>(); Powerups = new List <Powerup>(); BitmapXLATData = new ushort[2620]; SoundNames = new List <string>(); }
public TMapInfoTransaction(string label, int page, int tab, EditorHAMFile datafile, PIGFile pigfile, int index, int newtexture) : base(label, null, "", page, tab) { newValue = Math.Max(0, Math.Min(pigfile.Bitmaps.Count-1, newtexture)); this.index = index; this.datafile = datafile; this.pigfile = pigfile; }
public void Update(int number, WClip clip, EditorHAMFile hamFile, PIGFile piggyFile, Palette palette) { isLocked = true; wclipID = number; this.clip = clip; this.hamFile = hamFile; this.palette = palette; TotalTimeTextBox.Text = clip.PlayTime.ToString(); UIUtil.SafeFillComboBox(OpenSoundComboBox, clip.OpenSound + 1); UIUtil.SafeFillComboBox(CloseSoundComboBox, clip.CloseSound + 1); FilenameTextBox.Text = new string(clip.Filename); NumFramesTextBox.Text = clip.NumFrames.ToString(); ExplodesCheckBox.Checked = clip.Explodes; ShootableCheckBox.Checked = clip.Blastable; OnPrimaryTMapCheckBox.Checked = clip.PrimaryTMap; HiddenCheckBox.Checked = clip.SecretDoor; if (!transactionManager.TransactionInProgress) { FrameSpinner.Value = 0; UpdateWallFrame(0); } else { UpdateWallFrame((int)FrameSpinner.Value); } isLocked = false; }
public TMapInfoEClipTransaction(string label, int page, int tab, EditorHAMFile datafile, PIGFile pigfile, int index, int newEClip) : base(label, null, "", page, tab) { newValue = newEClip; tmapIndex = index; this.datafile = datafile; this.pigfile = pigfile; }
public VClipRemapTransaction(string label, int page, int tab, VClip clip, PIGFile piggyFile, int clipFirstFrame) : base(label, clip, "", page, tab) { this.clip = clip; this.piggyFile = piggyFile; this.frame = clipFirstFrame; framebackup = new ushort[clip.Frames.Length]; }
public PIGEditor(PIGFile data, Palette palette, string filename) { datafile = data; this.filename = filename; InitializeComponent(); this.Text = string.Format("{0} - PIG Editor", filename); this.palette = palette; }
public HAMEditor(EditorHAMFile data, StandardUI host, PIGFile piggyFile, Palette palette, SaveHandler saveHandler) { InitializeComponent(); this.palette = palette; this.piggyFile = piggyFile; datafile = data; this.host = host; this.saveHandler = saveHandler; texturePanel = new TMAPInfoPanel(transactionManager); components.Add(texturePanel); texturePanel.Dock = DockStyle.Fill; vclipPanel = new VClipPanel(transactionManager); components.Add(vclipPanel); vclipPanel.Dock = DockStyle.Fill; eclipPanel = new EClipPanel(transactionManager); components.Add(eclipPanel); eclipPanel.Dock = DockStyle.Fill; wclipPanel = new WClipPanel(transactionManager); components.Add(wclipPanel); wclipPanel.Dock = DockStyle.Fill; robotPanel = new RobotPanel(transactionManager, 4); components.Add(robotPanel); robotPanel.Dock = DockStyle.Fill; weaponPanel = new WeaponPanel(transactionManager, 5); components.Add(weaponPanel); weaponPanel.Dock = DockStyle.Fill; polymodelPanel = new PolymodelPanel(transactionManager, 6, piggyFile, palette, data); components.Add(polymodelPanel); polymodelPanel.Dock = DockStyle.Fill; soundPanel = new SoundPanel(transactionManager, 7, datafile, host.DefaultSoundFile); components.Add(soundPanel); soundPanel.Dock = DockStyle.Fill; reactorPanel = new ReactorPanel(transactionManager, 8); components.Add(reactorPanel); reactorPanel.Dock = DockStyle.Fill; TextureTabPage.Controls.Add(texturePanel); VClipTabPage.Controls.Add(vclipPanel); EffectsTabPage.Controls.Add(eclipPanel); DoorTabPage.Controls.Add(wclipPanel); RobotTabPage.Controls.Add(robotPanel); WeaponTabPage.Controls.Add(weaponPanel); ModelTabPage.Controls.Add(polymodelPanel); SoundTabPage.Controls.Add(soundPanel); ReactorTabPage.Controls.Add(reactorPanel); string currentFilename = "Untitled"; if (saveHandler != null) { currentFilename = saveHandler.GetUIName(); } this.Text = string.Format("{0} - HAM Editor", currentFilename); transactionManager.undoEvent += DoUndoEvent; datafile.CompatObjBitmaps = StandardUI.options.GetOption("CompatObjBitmaps", bool.FalseString) == bool.TrueString; }
public List <int> LoadPolymodelTextures(Polymodel model, Palette palette, PIGFile pigFile) { List <int> textureIDs = new List <int>(); Bitmap image; foreach (string textureName in model.TextureList) { image = PiggyBitmapUtilities.GetBitmap(pigFile, palette, textureName); textureIDs.Add(LoadTexture(image)); } return(textureIDs); }
public List <int> LoadPolymodelTexturesHack(Polymodel model, PIGFile pigFile) { List <int> textureIDs = new List <int>(); Bitmap image; image = (Bitmap)Image.FromFile("c:/dev/d2test/tex0.png"); textureIDs.Add(LoadTexture(image)); image.Dispose(); image = (Bitmap)Image.FromFile("c:/dev/d2test/tex1.png"); textureIDs.Add(LoadTexture(image)); image.Dispose(); return(textureIDs); }
public static void DumpPIGToBBM(PIGFile pigFile, Palette palette, string outputFilename) { LBMDecoder encoder = new LBMDecoder(); string directory = Path.GetDirectoryName(outputFilename); int numFrames = 0; PIGImage[] frames = new PIGImage[50]; PIGImage image; for (int i = 0; i < pigFile.Bitmaps.Count; i++) { if (pigFile.Bitmaps[i].IsAnimated) //Special animation hacks { image = pigFile.Bitmaps[i]; if (image.Frame == 0) //Start at the first frame { numFrames = 0; frames[numFrames++] = image; if ((i + 1) >= pigFile.Bitmaps.Count) { return; //out of images } while (image.Name == pigFile.Bitmaps[i + 1].Name) { frames[numFrames] = pigFile.Bitmaps[i + 1]; i++; numFrames++; if ((i + 1) >= pigFile.Bitmaps.Count) { break; //out of images } } BinaryWriter bw = new BinaryWriter(File.OpenWrite(string.Format("{0}{1}{2}.abm", directory, Path.DirectorySeparatorChar, image.Name))); encoder.WriteABM(frames, numFrames, palette, bw); bw.Close(); bw.Dispose(); } } else { image = pigFile.Bitmaps[i]; BinaryWriter bw = new BinaryWriter(File.OpenWrite(string.Format("{0}{1}{2}.bbm", directory, Path.DirectorySeparatorChar, image.Name))); encoder.WriteBBM(image, palette, bw); bw.Close(); bw.Dispose(); } } }
public HAMEditor(EditorHAMFile data, StandardUI host, PIGFile piggyFile, Palette palette, string filename) { InitializeComponent(); this.glControl1 = new OpenTK.GLControl(); this.glControl1.BackColor = System.Drawing.Color.Black; this.glControl1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.glControl1.Location = new System.Drawing.Point(452, 61); this.glControl1.Name = "glControl1"; this.glControl1.Size = new System.Drawing.Size(256, 256); this.glControl1.TabIndex = 0; this.glControl1.VSync = false; this.glControl1.Load += new System.EventHandler(this.glControl1_Load); this.glControl1.Paint += new System.Windows.Forms.PaintEventHandler(this.glControl1_Paint); texturePanel = new TMAPInfoPanel(transactionManager); components.Add(texturePanel); texturePanel.Dock = DockStyle.Fill; vclipPanel = new VClipPanel(transactionManager); components.Add(vclipPanel); vclipPanel.Dock = DockStyle.Fill; eclipPanel = new EClipPanel(transactionManager); components.Add(eclipPanel); eclipPanel.Dock = DockStyle.Fill; wclipPanel = new WClipPanel(transactionManager); components.Add(wclipPanel); wclipPanel.Dock = DockStyle.Fill; robotPanel = new RobotPanel(); components.Add(robotPanel); robotPanel.Dock = DockStyle.Fill; weaponPanel = new WeaponPanel(); components.Add(weaponPanel); weaponPanel.Dock = DockStyle.Fill; TextureTabPage.Controls.Add(texturePanel); VClipTabPage.Controls.Add(vclipPanel); EffectsTabPage.Controls.Add(eclipPanel); DoorTabPage.Controls.Add(wclipPanel); RobotTabPage.Controls.Add(robotPanel); WeaponTabPage.Controls.Add(weaponPanel); this.palette = palette; this.piggyFile = piggyFile; if (!noPMView) { this.ModelTabPage.Controls.Add(this.glControl1); } datafile = data; this.host = host; modelRenderer = new ModelRenderer(datafile, piggyFile, palette); currentFilename = filename; this.Text = string.Format("{0} - HAM Editor", currentFilename); transactionManager.undoEvent += DoUndoEvent; }
public void Init(List <string> SoundNames, List <VClip> VClips, List <Weapon> Weapons, List <Polymodel> Models, PIGFile piggyFile, Palette palette) { this.piggyFile = piggyFile; this.palette = palette; isLocked = true; cbWeaponFireSound.Items.Clear(); cbWeaponFireSound.Items.Add("None"); cbWeaponRobotHitSound.Items.Clear(); cbWeaponRobotHitSound.Items.Add("None"); cbWeaponWallHitSound.Items.Clear(); cbWeaponWallHitSound.Items.Add("None"); string[] stringarray = SoundNames.ToArray(); cbWeaponFireSound.Items.AddRange(stringarray); cbWeaponRobotHitSound.Items.AddRange(stringarray); cbWeaponWallHitSound.Items.AddRange(stringarray); cbWeaponMuzzleFlash.Items.Clear(); cbWeaponMuzzleFlash.Items.Add("None"); cbWeaponWallHit.Items.Clear(); cbWeaponWallHit.Items.Add("None"); cbWeaponRobotHit.Items.Clear(); cbWeaponRobotHit.Items.Add("None"); cbWeaponVClip.Items.Clear(); cbWeaponVClip.Items.Add("None"); stringarray = new string[VClips.Count]; for (int i = 0; i < VClips.Count; i++) { stringarray[i] = VClips[i].Name; } cbWeaponMuzzleFlash.Items.AddRange(stringarray); cbWeaponWallHit.Items.AddRange(stringarray); cbWeaponRobotHit.Items.AddRange(stringarray); cbWeaponVClip.Items.AddRange(stringarray); stringarray = new string[Weapons.Count]; for (int i = 0; i < Weapons.Count; i++) { stringarray[i] = Weapons[i].Name; } cbWeaponChildren.Items.Clear(); cbWeaponChildren.Items.Add("None"); //this will be fun since my own size can change. ugh cbWeaponChildren.Items.AddRange(stringarray); cbWeaponModel1.Items.Clear(); cbWeaponModel1.Items.Add("None"); cbWeaponModel2.Items.Clear(); cbWeaponModel2.Items.Add("None"); stringarray = new string[Models.Count]; for (int i = 0; i < Models.Count; i++) { stringarray[i] = Models[i].Name; } cbWeaponModel1.Items.AddRange(stringarray); cbWeaponModel2.Items.AddRange(stringarray); isLocked = false; }
public PIGEditor(PIGFile data, Palette palette, string filename) { datafile = data; this.filename = filename; InitializeComponent(); this.Text = string.Format("{0} - PIG Editor", filename); this.palette = palette; panel = new ImageEditorPanel(data, false); panel.SetPalette(palette); Controls.Add(panel); components.Add(panel); panel.Dock = DockStyle.Fill; #if DEBUG == false mainMenu1.MenuItems.Remove(ExportILBMMenuItem); mainMenu1.MenuItems.Remove(DebugMenuSeparator); #endif }
public List <int> LoadPolymodelTextures(Polymodel model, PIGFile pigFile, Palette palette, EditorHAMFile hamFile) { List <int> textureIDs = new List <int>(); Bitmap image; EClip clip; foreach (string textureName in model.TextureList) { if (hamFile.EClipNameMapping.ContainsKey(textureName.ToLower())) { clip = hamFile.EClipNameMapping[textureName.ToLower()]; image = PiggyBitmapUtilities.GetBitmap(pigFile, palette, clip.Clip.Frames[0]); } else { image = PiggyBitmapUtilities.GetBitmap(pigFile, palette, textureName); } textureIDs.Add(LoadTexture(image)); } return(textureIDs); }
public static Bitmap GetBitmap(PIGFile piggyFile, Palette palette, string name) { PIGImage image = piggyFile.GetImage(name); Bitmap bitmap = new Bitmap(image.Width, image.Height); int[] rgbData = new int[image.Width * image.Height]; byte[] rawData = image.GetData(); byte b; for (int i = 0; i < rawData.Length; i++) { b = rawData[i]; rgbData[i] = ((b == 255 ? 0 : 255) << 24) + (palette[b].R << 16) + (palette[b].G << 8) + (palette[b].B); } BitmapData bits = bitmap.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); System.Runtime.InteropServices.Marshal.Copy(rgbData, 0, bits.Scan0, image.Width * image.Height); bitmap.UnlockBits(bits); return(bitmap); }
public EditorHAMFile(PIGFile piggyFile) : this(new HAMFile(), piggyFile) { }
public static EditorHAMFile TranslatePIGToHam(Descent1PIGFile pigfile, PIGFile convertedPigFile) { HAMFile file = new HAMFile(); foreach (ushort texture in pigfile.Textures) { file.Textures.Add(texture); } foreach (TMAPInfo tmapInfo in pigfile.TMapInfo) { file.TMapInfo.Add(tmapInfo); } for (int i = 0; i < pigfile.SoundIDs.Length; i++) { file.Sounds[i] = pigfile.SoundIDs[i]; } for (int i = 0; i < pigfile.AltSounds.Length; i++) { file.AltSounds[i] = pigfile.AltSounds[i]; } foreach (VClip clip in pigfile.VClips) { file.VClips.Add(clip); } foreach (EClip clip in pigfile.EClips) { file.EClips.Add(clip); } foreach (WClip clip in pigfile.WClips) { file.WClips.Add(clip); } foreach (Robot robot in pigfile.Robots) { file.Robots.Add(robot); } foreach (JointPos joint in pigfile.Joints) { file.Joints.Add(joint); } foreach (Weapon weapon in pigfile.Weapons) { if (weapon.ModelNum == 255) { weapon.ModelNum = 0; } if (weapon.ModelNumInner == 255) { weapon.ModelNumInner = 0; } file.Weapons.Add(weapon); } foreach (Polymodel model in pigfile.Models) { if (model != null) { file.Models.Add(model); } } foreach (ushort gauge in pigfile.Gauges) { file.Gauges.Add(gauge); file.GaugesHires.Add(gauge); } foreach (ushort cockpit in pigfile.Cockpits) { file.Cockpits.Add(cockpit); } for (int i = 0; i < pigfile.ObjBitmaps.Length; i++) { file.ObjBitmaps.Add(pigfile.ObjBitmaps[i]); file.ObjBitmapPointers.Add(pigfile.ObjBitmapPointers[i]); } foreach (Powerup powerup in pigfile.Powerups) { file.Powerups.Add(powerup); } file.PlayerShip = pigfile.PlayerShip; file.Reactors.Add(pigfile.reactor); file.FirstMultiBitmapNum = pigfile.FirstMultiBitmapNum; for (int i = 0; i < pigfile.BitmapXLATData.Length; i++) { file.BitmapXLATData[i] = pigfile.BitmapXLATData[i]; } EditorHAMFile res = new EditorHAMFile(file, convertedPigFile); res.CreateLocalLists(); res.GenerateDefaultNamelists(); res.TranslateData(); return(res); }