private void LoadPreset(ImporterPreset preset) { TextBoxX_BankAddr.Text = TextValueConverter.TextFromValue(preset.RamAddress); TextBoxX_RomAddr.Text = TextValueConverter.TextFromValue(preset.RomAddress); TextBoxX_MaxLength.Text = TextValueConverter.TextFromValue(preset.MaxLength); string colText = ""; foreach (int cp in preset.CollisionPointers) { if (!string.IsNullOrEmpty(colText)) { colText += ", "; } colText += TextValueConverter.TextFromValue(cp); } TextBoxX2.Text = colText; string geoText = ""; foreach (int gp in preset.GeometryPointers) { if (!string.IsNullOrEmpty(geoText)) { geoText += ", "; } geoText += TextValueConverter.TextFromValue(gp); } TextBoxX1.Text = geoText; }
private void LoadRgbInfo() { var e = RGBEditInfo; TextBoxX_Name.Text = e.Name; bool enableLight = e.LightAddress is object; SwitchButton_Light.Value = enableLight; if (enableLight) { SwitchButton_LightMult.Value = e.DoubleLightRGB; TextBoxX_Light.Text = TextValueConverter.TextFromValue((long)e.LightAddress); } bool enableDark = e.DarkAddress is object; SwitchButton_Dark.Value = enableDark; if (enableDark) { SwitchButton_DarkMult.Value = e.DoubleDarkRGB; TextBoxX_Dark.Text = TextValueConverter.TextFromValue((long)e.DarkAddress); } bool enableAlpha = e.AlphaAddress is object; SwitchButton_Alpha.Value = enableAlpha; if (enableAlpha) { TextBoxX_Alpha.Text = TextValueConverter.TextFromValue((long)e.AlphaAddress); } }
private void ListEverything() { BeginTreeUpdate(); ObdTree.Nodes.Clear(); var nRoot = new Node() { Text = "Object Bank Data Collection", Name = "nRoot", Tag = ObdListCollection }; nRoot.Expand(); foreach (KeyValuePair <byte, ObjectBankDataList> kvp in ObdListCollection) { var nObdList = new Node() { Text = TextValueConverter.TextFromValue(kvp.Key), Tag = kvp, ContextMenu = ButtonItem_CM_ObdList }; // Data foreach (ObjectBankData obd in kvp.Value) { var nObd = GetNodeFromObd(obd); nObdList.Nodes.Add(nObd); } nObdList.Expand(); nRoot.Nodes.Add(nObdList); } ObdTree.Nodes.Add(nRoot); EndTreeUpdate(); }
private void UpdateSequenceInList(int index, ButtonItem buttonItem) { var infos = Controller.GetMusicSequenceInfos(index); string tName = $"{TextValueConverter.TextFromValue(index, charCount: 2)} - {infos.name}"; buttonItem.Text = tName; }
private void ShowTextItemData() { var selectedIndicies = GetSelectedIndicies(); if (!string.IsNullOrEmpty(selectedIndicies.tableName) && selectedIndicies.tableIndex > -1) { TM_LoadingItem = true; var groupInfo = TMController.GetTextGroupInfos(selectedIndicies.tableName); var itemInfo = TMController.GetTextItemInfos(selectedIndicies.tableName, selectedIndicies.tableIndex); TextBoxX_TM_TextEditor.Text = itemInfo.text; var isDescNull = itemInfo.dialogDescription == null; TextBoxX_ItemDescription.ReadOnly = isDescNull && !TMController.UsingDefaultTextProfileInfo(); if (isDescNull) { TextBoxX_ItemDescription.Text = TMController.GetTextNameList(selectedIndicies.tableName).ElementAtOrDefault(selectedIndicies.tableIndex); } else { TextBoxX_ItemDescription.Text = itemInfo.dialogDescription; } if (groupInfo.isDialogGroup) { IntegerInput_TM_DialogSize.Value = itemInfo.linesPerSite; int vIndex = Array.IndexOf(Enum.GetValues(typeof(SM64Lib.Text.DialogVerticalPosition)), itemInfo.verticalPosition); if (vIndex >= 0) { ComboBoxEx_TM_DialogPosX.SelectedIndex = vIndex; } else { ComboBoxEx_TM_DialogPosX.Text = TextValueConverter.TextFromValue((long)itemInfo.verticalPosition); } int hIndex = Array.IndexOf(Enum.GetValues(typeof(SM64Lib.Text.DialogHorizontalPosition)), itemInfo.horizontalPosition); if (hIndex >= 0) { ComboBoxEx_TM_DialogPosY.SelectedIndex = hIndex; } else { ComboBoxEx_TM_DialogPosY.Text = TextValueConverter.TextFromValue((long)itemInfo.horizontalPosition); } foreach (ComboItem cbitem in ComboBoxEx_SoundEffect.Items) { if ((DialogSoundEffect)cbitem.Tag == itemInfo.soundEffect) { ComboBoxEx_SoundEffect.SelectedItem = cbitem; } } } TM_LoadingItem = false; } }
private void AdvPropertyGrid1_ConvertPropertyValueToString(object sender, ConvertValueEventArgs e) { var switchExpr = e.PropertyDescriptor.PropertyType; switch (switchExpr) { case var @case when @case == typeof(bool): if (Conversions.ToBoolean(Operators.ConditionalCompareObjectEqual(e.TypedValue, true, false))) { e.StringValue = "Yes"; } else { e.StringValue = "No"; } e.IsConverted = true; break; case var case1 when case1 == typeof(byte): case var case2 when case2 == typeof(sbyte): case var case3 when case3 == typeof(short): case var case4 when case4 == typeof(ushort): case var case5 when case5 == typeof(int): case var case6 when case6 == typeof(uint): e.StringValue = TextValueConverter.TextFromValue(Conversions.ToLong(e.TypedValue)); e.IsConverted = true; break; } }
private void SaveRgbInfo() { var e = RGBEditInfo; e.Name = TextBoxX_Name.Text; if (SwitchButton_Light.Value) { e.LightAddress = (uint?)TextValueConverter.ValueFromText(TextBoxX_Light.Text); e.DoubleLightRGB = SwitchButton_LightMult.Value; } else { e.LightAddress = default; } if (SwitchButton_Dark.Value) { e.DarkAddress = (uint?)TextValueConverter.ValueFromText(TextBoxX_Dark.Text); e.DoubleDarkRGB = SwitchButton_DarkMult.Value; } else { e.DarkAddress = default; } if (SwitchButton_Alpha.Value) { e.AlphaAddress = (uint?)TextValueConverter.ValueFromText(TextBoxX_Alpha.Text); } else { e.AlphaAddress = default; } }
private void SetToolTip(object[] data) { var info = new SuperTooltipInfo(); info.HeaderText = $"{TextValueConverter.TextFromValue(Conversions.ToLong(data[0]))}: {data[1]}"; info.BodyText = $"<u>Description:</u>{data[2]}<br/><br/><u>Notes:</u>{data[3]}"; SuperTooltip1.SetSuperTooltip(ComboBox_ColType, info); }
private void LoadCustomObject(CustomModel obj) { curObj = obj; LayoutGroups_Enabled = true; TextBoxX_ModelID.Text = TextValueConverter.TextFromValue(obj.ModelID); TextBoxX_Name.Text = obj.Config.Name; LabelX_CollisionPointerDestinationsCount.Text = Conversions.ToString(obj.Config.CollisionPointerDestinations.Count); }
private void TextBoxX_BankAddr_TextChanged(object sender, EventArgs e) { var p = SelectedPreset(); if (p is object) { p.RamAddress = TextValueConverter.ValueFromText(TextBoxX_BankAddr.Text); } }
private void CopyRamAddress() { string name = SelectedName; if (!string.IsNullOrEmpty(name)) { Clipboard.SetText(TextValueConverter.TextFromValue(dicCommands[name].BankAddress)); } }
private void TextBoxX_MaxLength_TextChanged(object sender, EventArgs e) { var p = SelectedPreset(); if (p is object) { p.MaxLength = TextValueConverter.ValueFromText(TextBoxX_MaxLength.Text); } }
private BaseItem GetAddressItem(int addr) { var item = new ButtonItem() { Text = TextValueConverter.TextFromValue(addr) }; item.Click += (sender, e) => ItemPanel_Values.SelectedItem = (BaseItem)sender; return(item); }
private string TextForButtonItem(CustomModel obj) { string txt = $"Model-ID: {TextValueConverter.TextFromValue(obj.ModelID, charCount: 3)}"; if (!string.IsNullOrEmpty(obj.Config.Name)) { txt += $" - {obj.Config.Name}"; } return(txt); }
private void TextBoxX1_TextChanged(object sender, EventArgs e) { byte id = Conversions.ToByte(TextValueConverter.ValueFromText(TextBoxX1.Text)); SetParamTipp(id); SuperTooltip1.SetSuperTooltip(ComboBox_ColType, null); if (!LoadingColItemSettings) { UpdateTextureListItemSettings(id); } }
private void AddCmd(Node nCmds) { var bytesStartCount = default(int); bool allowOpenHexEditor = true; // Set start bytes count if (General.GetCurrentHexEditMode() == HexEditModes.BuildInHexEditor) { var valueInputDialog = new ValueInputDialog(); valueInputDialog.InfoLabel.Text = "Count of Bytes"; valueInputDialog.ValueTextBox.Text = Conversions.ToString(8); if (valueInputDialog.ShowDialog() == DialogResult.OK) { bytesStartCount = TextValueConverter.ValueFromText(valueInputDialog.ValueTextBox.Text); } allowOpenHexEditor = bytesStartCount > 0; } else { bytesStartCount = 0; } // Create Buffer var cmdBuf = new byte[bytesStartCount]; // Create new if (allowOpenHexEditor) { General.OpenHexEditor(ref cmdBuf); } if (cmdBuf?.Any() == true) { ObjectBankData obd = (ObjectBankData)nCmds.Tag; var cmd = new ObjectBankDataCommand(cmdBuf); var nCmd = GetNodeFromCmd(cmd); // Add cmd obd.Commands.Add(cmd); // Add node BeginTreeUpdate(); nCmds.Nodes.Add(nCmd); nCmds.Expand(); EndTreeUpdate(); // Raise event ChangedObjectBankDataCommand?.Invoke(obd); } }
private short GetValueFromComboBox(string selText, Type posType) { var names = Enum.GetNames(posType); foreach (string n in names) { if (n.ToLower().Equals(selText.ToLower())) { var v = Enum.GetValues(posType); return((short)v.GetValue(Array.IndexOf(names, n))); } } return(Conversions.ToShort(TextValueConverter.ValueFromText(selText, short.MinValue))); }
private void TextBoxX1_TextChanged(object sender, EventArgs e) { var preset = SelectedPreset(); if (preset is object) { preset.GeometryPointers.Clear(); foreach (string gp in TextBoxX1.Text.Split(',')) { if (!string.IsNullOrEmpty(gp)) { preset.GeometryPointers.Add(TextValueConverter.ValueFromText(gp.Trim())); } } } }
private void UpdateTextureListItemSettings(byte ct) { if (ListViewEx1.SelectedIndices.Count > 0) { byte cp1 = Conversions.ToByte(TextValueConverter.ValueFromText(TextBoxX_ColParam1.Text)); byte cp2 = Conversions.ToByte(TextValueConverter.ValueFromText(TextBoxX_ColParam2.Text)); foreach (ListViewItem item in ListViewEx1.SelectedItems) { KeyValuePair <string, Material> mat = (KeyValuePair <string, Material>)item.Tag; var curEntry = CollisionSettings.GetEntry(mat.Key); curEntry.CollisionType = ct; curEntry.CollisionParam1 = cp1; curEntry.CollisionParam2 = cp2; curEntry.IsNonSolid = CheckBoxX_IsNonSolid.Checked; } } }
private void UpdateAllListViewItems() { int counter = 1; foreach (ListViewItem item in ListViewEx_LM_ScrollTexList.Items) { ScrollTexPropertyClass scrollTex = (ScrollTexPropertyClass)item.Tag; SetLvGroup(item, scrollTex.GroupID); item.SubItems[0].Text = Conversions.ToString(counter); item.SubItems[1].Text = scrollTex.Behavior.ToString(); item.SubItems[2].Text = scrollTex.Type.ToString(); item.SubItems[3].Text = Conversions.ToString(scrollTex.CycleDuration); item.SubItems[4].Text = Conversions.ToString(scrollTex.ScrollingSpeed); item.SubItems[5].Text = Conversions.ToString(TextValueConverter.ValueFromText(Conversions.ToString(scrollTex.VertexPointer))); item.SubItems[6].Text = Conversions.ToString(scrollTex.FacesCount); counter += 1; } }
private void ListBoxAdv_CI_Textures_ItemClick(object sender, EventArgs e) { if (ListViewEx1.SelectedIndices.Count > 0) { var curItem = ListViewEx1.SelectedItems[0]; KeyValuePair <string, Material> mat = (KeyValuePair <string, Material>)curItem.Tag; var curEntry = CollisionSettings.GetEntry(mat.Key); bool found = false; LoadingColItemSettings = true; foreach (ComboItem item in ComboBox_ColType.Items) { if (!found && (byte)((object[])item.Tag)[0] == curEntry.CollisionType) { ComboBox_ColType.SelectedItem = item; found = true; } } CheckBoxX_IsNonSolid.Checked = curEntry.IsNonSolid; CheckBoxX1.Checked = !found; TextBoxX1.Text = TextValueConverter.TextFromValue(curEntry.CollisionType); TextBoxX_ColParam1.Text = TextValueConverter.TextFromValue(curEntry.CollisionParam1); TextBoxX_ColParam2.Text = TextValueConverter.TextFromValue(curEntry.CollisionParam2); if (curItem.ImageIndex > -1) { Image realImg; if (realTextures.ContainsKey(curItem.ImageIndex)) { realImg = realTextures[curItem.ImageIndex]; } else { realImg = ListViewEx1.LargeImageList.Images[curItem.ImageIndex]; } PictureBox1.Image = realImg; } else { PictureBox1.Image = null; } LoadingColItemSettings = false; } }
private void AdvPropertyGrid1_ConvertPropertyValueToString(object sender, ConvertValueEventArgs e) { if (!e.IsConverted && !e.PropertyName.StartsWith(bParamPropName)) { var switchExpr = e.PropertyDescriptor.PropertyType; switch (switchExpr) { case var @case when @case == typeof(bool): if (Conversions.ToBoolean(e.TypedValue)) { e.StringValue = "Yes"; } else { e.StringValue = "No"; } e.IsConverted = true; break; case var case1 when case1 == typeof(byte): case var case2 when case2 == typeof(sbyte): case var case3 when case3 == typeof(short): case var case4 when case4 == typeof(ushort): case var case5 when case5 == typeof(int): case var case6 when case6 == typeof(uint): if ((e.PropertyName ?? "") == (behaviorPropName ?? "")) { } else if (LikeOperator.LikeString(e.PropertyName, "Position?", CompareMethod.Binary) || LikeOperator.LikeString(e.PropertyName, "Rotation?", CompareMethod.Binary)) { e.StringValue = Conversions.ToString(e.TypedValue); e.IsConverted = true; } else { e.StringValue = TextValueConverter.TextFromValue(Conversions.ToLong(e.TypedValue)); e.IsConverted = true; } break; } } }
private void LoadCurrentSequence(int index) { int cIndex = index; bool IsNoIndex = cIndex < 0; bool IsIndex0 = cIndex == 0; GroupBox_MS_SelectedSequence.Enabled = !IsIndex0; GroupBox_MS_SeqProperties.Enabled = !IsIndex0; ButtonX_MS_RemoveSequence.Enabled = !IsIndex0; // Load Sequence Informations if (!IsNoIndex) { int tID = ListBoxAdv_MS_MusicSequences.SelectedIndex; var info = Controller.GetMusicSequenceInfos(index); TextBoxX_MS_Sequencename.ReadOnly = true; TextBoxX_MS_Sequencename.Text = info.name; LabelX_MS_SequenceID.Text = string.Format("{0}", TextValueConverter.TextFromValue(tID)); LabelX_MS_SeqSize.Text = string.Format("{0} Bytes", TextValueConverter.TextFromValue(info.length)); ComboBox_MS_NInst.SelectedIndex = info.instSet; TextBoxX_MS_Sequencename.ReadOnly = false; } }
public void ReadFromFile(string fileName) { Clear(); var jarr = JArray.Parse(File.ReadAllText(fileName)); if (jarr is object) { foreach (JObject entry in jarr) { var info = new BehaviorInfo(); info.Name = entry["Name"].Value <string>(); info.BehaviorAddress = Conversions.ToUInteger(TextValueConverter.ValueFromText(entry["Behavior"].Value <string>(), useIVM: 0)); for (int i = 1; i <= 4; i++) { if (entry.ContainsKey($"BP{i} Name")) { info.GetValue <BehaviorInfo.BParam>($"BParam{i}").Name = entry[$"BP{i} Name"].Value <string>(); } if (entry.ContainsKey($"BP{i} Entries")) { BehaviorInfo.BParam param = (BehaviorInfo.BParam)info.GetValue($"BParam{i}"); foreach (JObject kvp in entry[$"BP{i} Entries"]) { param.Values.Add(new BehaviorInfo.BParamValue() { Name = kvp["Name"].Value <string>(), Value = Conversions.ToByte(kvp["Value"].Value <string>()) }); } } } Add(info); } } }
public void WriteToFile(string fileName) { var jarr = new JArray(); foreach (BehaviorInfo info in this) { var entry = new JObject(); entry["Name"] = info.Name; entry["Behavior"] = info.BehaviorAddress; for (int i = 1; i <= 4; i++) { var param = info.GetValue <BehaviorInfo.BParam>($"BParam{i}"); if (param is object) { entry[$"BP{i} Name"] = param.Name; if (param.Values.Any()) { var parr = new JArray(); foreach (BehaviorInfo.BParamValue value in param.Values) { var vobj = new JObject(); vobj["Value"] = TextValueConverter.TextFromValue(value.Value); vobj["Name"] = value.Name; parr.Add(vobj); } entry[$"BP{i} Entries"] = parr; } } } jarr.Add(entry); } File.WriteAllText(fileName, jarr.ToString()); }
private void AdvPropertyGrid1_ConvertFromStringToPropertyValue(object sender, ConvertValueEventArgs e) { var switchExpr = e.PropertyDescriptor.PropertyType; switch (switchExpr) { case var @case when @case == typeof(bool): { if (e.StringValue == "Yes") { e.TypedValue = true; } else { e.TypedValue = false; } e.IsConverted = true; break; } case var case1 when case1 == typeof(byte): { e.TypedValue = Conversions.ToByte(TextValueConverter.ValueFromText(e.StringValue.Trim())); e.IsConverted = true; break; } case var case2 when case2 == typeof(sbyte): { e.TypedValue = Conversions.ToSByte(TextValueConverter.ValueFromText(e.StringValue.Trim())); e.IsConverted = true; break; } case var case3 when case3 == typeof(short): { e.TypedValue = Conversions.ToShort(TextValueConverter.ValueFromText(e.StringValue.Trim())); e.IsConverted = true; break; } case var case4 when case4 == typeof(ushort): { e.TypedValue = Conversions.ToUShort(TextValueConverter.ValueFromText(e.StringValue.Trim())); e.IsConverted = true; break; } case var case5 when case5 == typeof(int): { e.TypedValue = Conversions.ToInteger(TextValueConverter.ValueFromText(e.StringValue.Trim())); e.IsConverted = true; break; } case var case6 when case6 == typeof(uint): { e.TypedValue = Conversions.ToUInteger(TextValueConverter.LongFromText(e.StringValue.Trim())); e.IsConverted = true; break; } case var case7 when case7 == typeof(float): { e.TypedValue = Conversions.ToSingle(e.StringValue.Trim()); e.IsConverted = true; break; } case var case8 when case8 == typeof(double): { e.TypedValue = Conversions.ToDouble(e.StringValue.Trim()); e.IsConverted = true; break; } case var case9 when case9 == typeof(decimal): { e.TypedValue = Conversions.ToDecimal(e.StringValue.Trim()); e.IsConverted = true; break; } } }
// G u i private void ButtonX_Hinzufügen_Click(object sender, EventArgs e) { AddAddress(TextValueConverter.ValueFromText(TextBoxX_Value.Text)); }
private void TextBoxX_Value_TextChanged(object sender, EventArgs e) { SetSelectedAddress(TextValueConverter.ValueFromText(TextBoxX_Value.Text)); }
private void ItemPanel_Values_SelectedIndexChanged(object sender, EventArgs e) { TextBoxX_Value.Text = TextValueConverter.TextFromValue(GetSelectedAddress()); EnableAddressItemControls = ItemPanel_Values.SelectedItem is object; }
private void UpdateButtonText(int index, int addr) { ItemPanel_Values.Items[index].Text = TextValueConverter.TextFromValue(addr); }