public void LoadEntry(ParamEntry entry) { paramEntry = entry; nameTB.Text = entry.HashString; typeCB.SelectedItem = entry.ParamType; dataTB.Text = entry.Value.ToString(); switch (paramEntry.ParamType) { case ParamType.Vector2F: var vec2 = (Vector2F)entry.Value; dataTB.Text = $"{vec2.X} {vec2.Y}"; break; case ParamType.Vector3F: var vec3 = (Vector3F)entry.Value; dataTB.Text = $"{vec3.X} {vec3.Y} {vec3.Z}"; break; case ParamType.Vector4F: case ParamType.Color4F: var vec4 = (Vector4F)entry.Value; dataTB.Text = $"{vec4.X} {vec4.Y} {vec4.Z} {vec4.W}"; break; } }
public void LoadEntry(ParamEntry entry) { typeCB.Items.Clear(); foreach (var type in Enum.GetValues(typeof(ParamType)).Cast <ParamType>()) { typeCB.Items.Add(type); } paramEntry = entry; nameTB.Text = entry.HashString; typeCB.SelectedItem = entry.ParamType; dataTB.Text = entry.Value.ToString(); switch (entry.ParamType) { case ParamType.Vector2F: var vec2 = (Vector2F)entry.Value; dataTB.Text = $"{vec2.X} {vec2.Y}"; break; case ParamType.Vector3F: var vec3 = (Vector3F)entry.Value; dataTB.Text = $"{vec3.X} {vec3.Y} {vec3.Z}"; break; case ParamType.Vector4F: case ParamType.Color4F: var vec4 = (Vector4F)entry.Value; dataTB.Text = $"{vec4.X} {vec4.Y} {vec4.Z} {vec4.W}"; break; } }
private static string getValueTypeString(ParamEntry pvalue) { switch (pvalue.Type) { case ParamType.s8: return("int8"); case ParamType.u8: return("uint8"); case ParamType.s16: return("int16"); case ParamType.u16: return("uint16"); case ParamType.s32: return("int32"); case ParamType.u32: return("uint32"); case ParamType.f32: return("float"); case ParamType.str: return("string"); default: return(""); } }
public override bool View(ViewModels.TabPageModel tabPage) { tabPage.Title = Text.ToString(); tabPage.SupportsLanguageSwitching = false; var view = Helpers.PrepareDataGrid(tabPage, this); var list = new List <ParamEntry>(); ParamEntry scrollTargetEntry = default; for (int row = 1; row <= module.Metadata.GetTableRowCount(TableIndex.Param); row++) { ParamEntry entry = new ParamEntry(module, MetadataTokens.ParameterHandle(row)); if (entry.RID == this.scrollTarget) { scrollTargetEntry = entry; } list.Add(entry); } view.ItemsSource = list; tabPage.Content = view; if (scrollTargetEntry.RID > 0) { ScrollItemIntoView(view, scrollTargetEntry); } return(true); }
public void UpdateEntryNode(EditableEntry node, ParamEntry entry) { node.ImageKey = "empty"; node.SelectedImageKey = "empty"; switch (entry.ParamType) { case ParamType.Boolean: case ParamType.Float: case ParamType.Int: case ParamType.Uint: case ParamType.String64: case ParamType.String32: case ParamType.String256: case ParamType.StringRef: node.Text = $"{entry.HashString} {entry.Value}"; break; case ParamType.Vector2F: var vec2 = (Vector2F)entry.Value; node.Text = $"{entry.HashString} {vec2.X} {vec2.Y}"; break; case ParamType.Vector3F: var vec3 = (Vector3F)entry.Value; node.Text = $"{entry.HashString} {vec3.X} {vec3.Y} {vec3.Z}"; break; case ParamType.Vector4F: var vec4 = (Vector4F)entry.Value; node.Text = $"{entry.HashString} {vec4.X} {vec4.Y} {vec4.Z} {vec4.W}"; break; case ParamType.Color4F: var col = (Vector4F)entry.Value; node.Text = $"{entry.HashString} {col.X} {col.Y} {col.Z} {col.W}"; int ImageIndex = Images.Count; node.ImageIndex = ImageIndex; var color = System.Drawing.Color.FromArgb( Utils.FloatToIntClamp(col.W), Utils.FloatToIntClamp(col.X), Utils.FloatToIntClamp(col.Y), Utils.FloatToIntClamp(col.Z)); Bitmap bmp = new Bitmap(32, 32); Graphics g = Graphics.FromImage(bmp); g.Clear(color); Images.Add(bmp); break; default: break; } }
private void OpenEditor(ParamEntry entry, ListViewItem SelectedItem) { EditBox editor = new EditBox(); editor.LoadEntry(entry); editor.ToggleNameEditing(true); if (editor.ShowDialog() == DialogResult.OK) { editor.SaveEntry(); SetListItemParamObject(entry, SelectedItem); } }
public override void AddParamEntry(TreeNode parentNode) { if (parentNode.Tag != null && parentNode.Tag is ParamObject) { ParamEntry entry = new ParamEntry(); entry.ParamType = ParamType.Float; entry.HashString = "NewEntry"; entry.Value = 0; ListViewItem item = new ListViewItem(); SetListItemParamObject(entry, item); OpenNewParamEditor(entry, (ParamObject)parentNode.Tag, item); } }
private void duplicateEntryToolStripMenuItem_Click(object sender, EventArgs e) { if (treeView1.SelectedNode != null && treeView1.SelectedNode.Level != 0) { int groupNum = treeView1.SelectedNode.Parent.Index; int entryNum = treeView1.SelectedNode.Index; int entrySize = ((ParamGroup)p.Groups[groupNum]).EntrySize; for (int j = 0; j < entrySize; j++) { ParamEntry temp = new ParamEntry(p.Groups[groupNum].Values[entrySize * entryNum + j].Value, p.Groups[groupNum].Values[entrySize * entryNum + j].Type); p.Groups[groupNum].Values.Add(temp); } ((ParamGroup)p.Groups[groupNum]).EntryCount++; TreeNode temp2 = new TreeNode(); temp2.Text = getEntryName(groupNum, ((ParamGroup)p.Groups[groupNum]).EntryCount - 1); treeView1.SelectedNode.Parent.Nodes.Add(temp2); fillTable(groupNum, ((ParamGroup)p.Groups[groupNum]).EntryCount - 1); treeView1.SelectedNode = treeView1.SelectedNode.Parent.LastNode; } }
private void LoadParams(string filePath) { if (filePath != "") { listBox1.Items.Clear(); if (Validation.ParamFilePath(filePath, out paramEntries)) { //List bin names to choose from ParamEntry testParamEntry = new ParamEntry(); fileNames.Clear(); int i = 0; foreach (var entry in paramEntries) { testParamEntry.Read(paramEntries, i); pType = testParamEntry.Type; if (pType == ParamEntry.ParamType.Normal) { fileNames.Add($"b{Int32.Parse(testParamEntry.CharacterId.ToString(), System.Globalization.NumberStyles.HexNumber).ToString("X3")}_{Int32.Parse(testParamEntry.ExpressionId.ToString(), System.Globalization.NumberStyles.HexNumber).ToString("X3")}_{Int32.Parse(testParamEntry.OutfitId.ToString(), System.Globalization.NumberStyles.HexNumber).ToString("X2")}.bin"); } else if (pType == ParamEntry.ParamType.Assist) { fileNames.Add($"b{Int32.Parse(testParamEntry.CharacterId.ToString(), System.Globalization.NumberStyles.HexNumber).ToString("X3")}_{Int32.Parse(testParamEntry.ExpressionId.ToString(), System.Globalization.NumberStyles.HexNumber).ToString("X3")}.bin"); } i++; } foreach (var fileName in fileNames) { listBox1.Items.Add(fileName); } listBox1.Enabled = true; //Enable controls saveToolStripMenuItem.Enabled = true; openBustupDirectoryToolStripMenuItem.Enabled = true; comboBox_InitAnim.Enabled = true; listBox1.SelectedIndex = 0; paramFilePath = filePath; } } }
public static void Save(ParamEntry pEntry, string paramFilePath) { ParamEntry.Write(pEntry.EntryData, 8, pEntry.OffsetX); if (pEntry.Type == ParamEntry.ParamType.Normal) { ParamEntry.Write(pEntry.EntryData, 12, pEntry.OffsetY); ParamEntry.Write(pEntry.EntryData, 16, pEntry.EyePositionX); ParamEntry.Write(pEntry.EntryData, 20, pEntry.EyepositionY); ParamEntry.Write(pEntry.EntryData, 24, pEntry.MouthPositionX); ParamEntry.Write(pEntry.EntryData, 28, pEntry.MouthPositionY); ParamEntry.WriteShort(pEntry.EntryData, 34, pEntry.InitialAnimation); } else { ParamEntry.Write(pEntry.EntryData, 12, pEntry.EyePositionX); ParamEntry.Write(pEntry.EntryData, 16, pEntry.EyepositionY); ParamEntry.Write(pEntry.EntryData, 20, pEntry.MouthPositionX); ParamEntry.Write(pEntry.EntryData, 24, pEntry.MouthPositionY); ParamEntry.WriteShort(pEntry.EntryData, 30, pEntry.InitialAnimation); } pEntry.Replace(pEntry.EntryData, pEntry.EntryIndex, paramFilePath, pEntry.Type); }
private void fillTable(int groupNum, int entryNum) { currentEntry[0] = groupNum; currentEntry[1] = entryNum; tbl.Clear(); if (p.Groups.Count > groupNum) { int entrySize = getEntrySize(groupNum); int count; if (entrySize == -1) { count = p.Groups[groupNum].Values.Count; entrySize = 0; } else { count = entrySize; } for (int i = 0; i < count; i++) { ParamEntry val = p.Groups[groupNum].Values[(entrySize * entryNum) + i]; DataRow tempRow = tbl.NewRow(); tempRow[(int)Columns.Name] = getValueName(groupNum, entryNum, i); tempRow[(int)Columns.Type] = getValueTypeString(val); tempRow[(int)Columns.Value] = val.Value; string toolTip = getValueToolTip(groupNum, entryNum, i); tbl.Rows.Add(tempRow); //The Cells property only exists through the dataGridView, so the tooltip can only be set after adding the row if (toolTip != null) { dataGridView1.Rows[i].Cells[0].ToolTipText = toolTip; } } } //I couldn't find any way to manually set a width for a DataColumn, so this will have to do dataGridView1.AutoResizeColumn((int)Columns.Type, System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells); }
private void OpenNewParamEditor(ParamEntry entry, ParamObject paramObject, ListViewItem SelectedItem) { EditBox editor = new EditBox(); editor.LoadEntry(entry); editor.ToggleNameEditing(true); if (editor.ShowDialog() == DialogResult.OK) { editor.SaveEntry(); SetListItemParamObject(entry, SelectedItem); listViewCustom1.Items.Add(SelectedItem); var entryList = new List <ParamEntry>(); for (int i = 0; i < paramObject.paramEntries.Length; i++) { entryList.Add(paramObject.paramEntries[i]); } entryList.Add(entry); paramObject.paramEntries = entryList.ToArray(); } }
private void SetListItemParamObject(ParamEntry entry, ListViewItem item) { item.SubItems.Clear(); item.Text = entry.HashString; item.Tag = entry; item.UseItemStyleForSubItems = false; item.SubItems.Add(entry.ParamType.ToString()); string ValueText = ""; System.Drawing.Color color = System.Drawing.Color.Empty; switch (entry.ParamType) { case ParamType.Boolean: case ParamType.Float: case ParamType.Int: case ParamType.Uint: ValueText = $"{entry.Value}"; break; case ParamType.String64: case ParamType.String32: case ParamType.String256: case ParamType.StringRef: ValueText = $"{((AampCommon.StringEntry)entry.Value).ToString()}"; break; case ParamType.Vector2F: var vec2 = (Vector2F)entry.Value; ValueText = $"{vec2.X} {vec2.Y}"; break; case ParamType.Vector3F: var vec3 = (Vector3F)entry.Value; ValueText = $"{vec3.X} {vec3.Y} {vec3.Z}"; break; case ParamType.Vector4F: var vec4 = (Vector4F)entry.Value; ValueText = $"{vec4.X} {vec4.Y} {vec4.Z} {vec4.W}"; break; case ParamType.Color4F: var col = (Vector4F)entry.Value; ValueText = $"{col.X} {col.Y} {col.Z} {col.W}"; int ImageIndex = Images.Count; color = System.Drawing.Color.FromArgb( EditBox.FloatToIntClamp(col.W), EditBox.FloatToIntClamp(col.X), EditBox.FloatToIntClamp(col.Y), EditBox.FloatToIntClamp(col.Z)); break; default: break; } item.SubItems.Add(ValueText); if (color != System.Drawing.Color.Empty) { item.SubItems[2].BackColor = color; } }
public static string TranslateAsmShaderToPseudocode(string shaderAsm) { var paramStart = Math.Max(shaderAsm.IndexOf("//\r\n//\r\n"), 0); var registersStart = Math.Max(shaderAsm.IndexOf("//\r\n//\r\n", paramStart + 2), 0); var codeStart = Math.Max(shaderAsm.IndexOf("//\r\n\r\n", registersStart + 2), 0); var paramLines = ParamPattern.Matches(shaderAsm.Substring(paramStart, registersStart - paramStart)); var registerLines = RegisterPattern.Matches(shaderAsm.Substring(registersStart, codeStart - registersStart)); var codeLines = CodeLinePattern.Matches(shaderAsm.Substring(codeStart)); var parms = new List <ParamEntry>(); var regs = new List <RegisterEntry>(); var ops = new List <Operation>(); foreach (Match p in paramLines) { parms.Add(ParamEntry.CreateFromGroup(p.Groups)); } foreach (Match r in registerLines) { regs.Add(RegisterEntry.CreateFromGroup(r.Groups)); } foreach (Match r in codeLines) { ops.Add(Operation.CreateFromString(r.Groups[1].Value)); } //parms.Dump(); //regs.Dump(); //ops.Dump(); // TODO: Decls and defs var pseudo = new StringBuilder(); var context = new GlslBuilderContext(); pseudo.AppendLine("#version 450"); pseudo.AppendLine(); foreach (var op in ops) { pseudo.Append(op.ToDeclarationalGlsl(context, parms)); } pseudo.AppendLine(); foreach (var reg in regs) { if (context.HasBeenSeen(reg.RegisterId)) { continue; } pseudo.AppendLine($"vec4 {reg.RegisterId};"); } pseudo.AppendLine(); pseudo.AppendLine("void main()"); pseudo.AppendLine("{"); foreach (var op in ops) { pseudo.Append(op.ToExecutableGlsl(context)); } pseudo.AppendLine("}"); return(pseudo.ToString()); }
private void Listbox_SelectionChanged(object sender, EventArgs e) { if (listBox1.SelectedItem != null) { numUpDwn_MouthFrame.Value = 0; numUpDwn_EyeFrame.Value = 0; btn_CreateBin.Enabled = false; btn_OpenImgFolder.Enabled = false; btn_RepackBin.Enabled = false; numUpDwn_EyeFrame.Enabled = false; numUpDwn_MouthFrame.Enabled = false; comboBox_InitAnim.Enabled = false; if (previousSelectedIndex != -1) { // Prompt to save changes if form != data entry on leave if (numUpDwn_OffsetX.Text != pEntry.OffsetX.ToString() || numUpDwn_OffsetY.Text != pEntry.OffsetY.ToString() || numUpDwn_EyePosX.Text != pEntry.EyePositionX.ToString() || numUpDwn_EyePosY.Text != pEntry.EyepositionY.ToString() || numUpDwn_MouthPosX.Text != pEntry.MouthPositionX.ToString() || numUpDwn_MouthPosY.Text != pEntry.MouthPositionY.ToString() || comboBox_InitAnim.SelectedIndex != Params.GetInitAnim(pEntry.InitialAnimation)) { DialogResult result = MessageBox.Show($"Save changes to {listBox1.Items[previousSelectedIndex].ToString()}?\nYour changes will be discarded if you select No.", "Unsaved Changes", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { pEntry.OffsetX = float.Parse(numUpDwn_OffsetX.Text); pEntry.OffsetY = float.Parse(numUpDwn_OffsetY.Text); pEntry.EyePositionX = float.Parse(numUpDwn_EyePosX.Text); pEntry.EyepositionY = float.Parse(numUpDwn_EyePosY.Text); pEntry.MouthPositionX = float.Parse(numUpDwn_MouthPosX.Text); pEntry.MouthPositionY = float.Parse(numUpDwn_MouthPosY.Text); pEntry.InitialAnimation = Params.SetInitAnim(comboBox_InitAnim.SelectedIndex); if (pEntry.EntryData != null) { Program.Save(pEntry, paramFilePath); } } } } // Attempt to load new data from selected param entry into form try { pEntry = Validation.SelectedEntry(paramEntries, listBox1.SelectedItem.ToString()); numUpDwn_OffsetX.Text = pEntry.OffsetX.ToString(); numUpDwn_OffsetY.Text = pEntry.OffsetY.ToString(); numUpDwn_EyePosX.Text = pEntry.EyePositionX.ToString(); numUpDwn_EyePosY.Text = pEntry.EyepositionY.ToString(); numUpDwn_MouthPosX.Text = pEntry.MouthPositionX.ToString(); numUpDwn_MouthPosY.Text = pEntry.MouthPositionY.ToString(); comboBox_InitAnim.SelectedIndex = Params.GetInitAnim(pEntry.InitialAnimation); previousSelectedIndex = listBox1.SelectedIndex; numUpDwn_OffsetX.Enabled = true; numUpDwn_OffsetY.Enabled = true; numUpDwn_EyePosX.Enabled = true; numUpDwn_EyePosY.Enabled = true; numUpDwn_MouthPosX.Enabled = true; numUpDwn_MouthPosY.Enabled = true; comboBox_InitAnim.Enabled = true; selectedBustup = $"{bustupDirPath}\\{listBox1.SelectedItem.ToString()}"; if (bustupDirPath != "" && File.Exists(selectedBustup)) { btn_OpenImgFolder.Enabled = true; btn_RepackBin.Enabled = true; btn_CreateBin.Enabled = false; numUpDwn_EyeFrame.Enabled = true; numUpDwn_MouthFrame.Enabled = true; extractedBustupDir = DDS2.Extract(selectedBustup); pngs = Directory.GetFiles($"{extractedBustupDir}\\PNG"); pictureBox_Base.ImageLocation = pngs[0]; pictureBox_Eyes.Parent = pictureBox_Base; pictureBox_Mouth.Parent = pictureBox_Base; pictureBox_Eyes.ImageLocation = pngs[1]; pictureBox_Mouth.ImageLocation = pngs[5]; pictureBox_Eyes.Size = new Size(Image.FromFile(pngs[2]).Width, Image.FromFile(pngs[2]).Height); pictureBox_Mouth.Size = new Size(Image.FromFile(pngs[3]).Width, Image.FromFile(pngs[3]).Height); pictureBox_Eyes.Location = new System.Drawing.Point(Convert.ToInt32(pEntry.EyePositionX), Convert.ToInt32(pEntry.EyepositionY)); pictureBox_Mouth.Location = new System.Drawing.Point(Convert.ToInt32(pEntry.MouthPositionX), Convert.ToInt32(pEntry.MouthPositionY)); } else { pictureBox_Base.ImageLocation = null; pictureBox_Mouth.ImageLocation = null; pictureBox_Eyes.ImageLocation = null; btn_CreateBin.Enabled = true; } } catch { numUpDwn_OffsetX.Enabled = false; numUpDwn_OffsetY.Enabled = false; numUpDwn_EyePosX.Enabled = false; numUpDwn_EyePosY.Enabled = false; numUpDwn_MouthPosX.Enabled = false; numUpDwn_MouthPosY.Enabled = false; } } }