Esempio n. 1
0
        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;
            }
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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;
            }
        }
Esempio n. 4
0
        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 UpdateSequenceInList(int index, ButtonItem buttonItem)
        {
            var    infos = Controller.GetMusicSequenceInfos(index);
            string tName = $"{TextValueConverter.TextFromValue(index, charCount: 2)} - {infos.name}";

            buttonItem.Text = tName;
        }
Esempio n. 6
0
        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();
        }
Esempio n. 7
0
        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);
 }
Esempio n. 9
0
        private void CopyRamAddress()
        {
            string name = SelectedName;

            if (!string.IsNullOrEmpty(name))
            {
                Clipboard.SetText(TextValueConverter.TextFromValue(dicCommands[name].BankAddress));
            }
        }
Esempio n. 10
0
        private BaseItem GetAddressItem(int addr)
        {
            var item = new ButtonItem()
            {
                Text = TextValueConverter.TextFromValue(addr)
            };

            item.Click += (sender, e) => ItemPanel_Values.SelectedItem = (BaseItem)sender;
            return(item);
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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;
                }
            }
        }
Esempio n. 14
0
        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;
            }
        }
Esempio n. 15
0
        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());
        }
Esempio n. 16
0
        public InputDialog(InputValueType valType, RomManager rommgr, object defaultValue = null)
        {
            InitializeComponent();
            ValueType   = valType;
            this.rommgr = rommgr;

            string infoText = string.Empty;

            switch (valType)
            {
            case InputValueType.Byte:
                infoText = "Input a 8 Bit value (Byte)";
                break;

            case InputValueType.UInt16:
                infoText = "Input a 16 Bit value (2 Bytes)";
                break;

            case InputValueType.UInt32:
                infoText = "Input a 32 Bit value (4 Bytes)";
                break;

            case InputValueType.Single:
                infoText = "Input a float value";
                break;

            case InputValueType.String:
                infoText = "Input a string";
                break;

            case InputValueType.Sequence:
                infoText = "Input a Sequence ID";
                break;

            case InputValueType.LevelID:
                infoText = "Input a Level ID";
                break;
            }

            switch (valType)
            {
            case InputValueType.Byte:
            case InputValueType.UInt16:
            case InputValueType.UInt32:
            {
                ComboBoxEx1.Text = defaultValue is null ? "0" : TextValueConverter.TextFromValue(Conversions.ToLong(defaultValue));
                break;
            }

            case InputValueType.Single:
            {
                ComboBoxEx1.Text = $"0{CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator}00";
                break;
            }

            case InputValueType.String:
            {
                ComboBoxEx1.Text = Conversions.ToString(defaultValue is null ? "Text" : defaultValue);
                break;
            }

            case InputValueType.Sequence:
            {
                if (rommgr is object)
                {
                    byte id = 0;
                    foreach (MusicSequence ms in rommgr.MusicList)
                    {
                        ComboBoxEx1.Items.Add($"{id.ToString("X2")} - {ms.Name}");
                        id += 1;
                    }

                    ComboBoxEx1.DropDownStyle = ComboBoxStyle.DropDownList;
                    ComboBoxEx1.SelectedIndex = 0;
                }

                break;
            }

            case InputValueType.LevelID:
            {
                if (rommgr is object)
                {
                    foreach (SM64Lib.Levels.LevelInfoDataTabelList.Level lvi in rommgr.LevelInfoData)
                    {
                        ComboBoxEx1.Items.Add($"{lvi.ID.ToString("X2")} - {lvi.Name}");
                    }
                    ComboBoxEx1.DropDownStyle = ComboBoxStyle.DropDownList;
                    ComboBoxEx1.SelectedIndex = 0;
                }

                break;
            }
            }

            if (infoText != null)
            {
                LabelX1.Text = infoText;
            }

            base.UpdateAmbientColors();
        }
Esempio n. 17
0
 private void ItemPanel_Values_SelectedIndexChanged(object sender, EventArgs e)
 {
     TextBoxX_Value.Text       = TextValueConverter.TextFromValue(GetSelectedAddress());
     EnableAddressItemControls = ItemPanel_Values.SelectedItem is object;
 }
Esempio n. 18
0
 private void UpdateButtonText(int index, int addr)
 {
     ItemPanel_Values.Items[index].Text = TextValueConverter.TextFromValue(addr);
 }