示例#1
0
        private void LoadPosition(HUDOptionsBlock b)
        {
            bool isCords          = b?.Cords is HUDOptionsCords;
            bool isValueSelection = b?.ValueSelection is HUDOptionsValueSelection;
            bool isAny            = isCords || isValueSelection;

            Invoke(new Action(() =>
            {
                LayoutControlItem_PosX.Visible     = isCords;
                LayoutControlItem_PosY.Visible     = isCords;
                layoutControlItem_ComboBox.Visible = isValueSelection;
                LayoutControl1.Enabled             = isAny;
            }));

            if (isCords)
            {
                hud.OpenRomRead();
                var pos = hud.GetPosition(b);
                hud.CloseRom();
                Invoke(new Action(() =>
                {
                    IntegerInput_PosX.Value = pos.X;
                    IntegerInput_PosY.Value = pos.Y;
                }));
            }
            else if (isValueSelection)
            {
                hud.OpenRomRead();
                var value = hud.GetValue(b);
                hud.CloseRom();
                Invoke(new Action(() =>
                {
                    bool found = false;
                    ComboBoxEx_Values.Items.Clear();
                    ComboBoxEx_Values.DropDownStyle = b.ValueSelection.AllowFreeMode ? ComboBoxStyle.DropDown : ComboBoxStyle.DropDownList;
                    foreach (var kvp in b.ValueSelection.Values)
                    {
                        ComboBoxEx_Values.Items.Add(new ComboItem
                        {
                            Text = $"{TextFromValue(kvp.Value)}: {HUDOptionsLangRes.ResourceManager.GetString($"HUDPosVals_{b.Name}_{kvp.Key}")}",
                            Tag  = kvp.Value
                        });
                    }
                    foreach (ComboItem item in ComboBoxEx_Values.Items)
                    {
                        if (!found && (bool)Microsoft.VisualBasic.CompilerServices.Operators.CompareObjectEqual(item.Tag, value, false))
                        {
                            ComboBoxEx_Values.SelectedItem = item;
                            found = true;
                        }
                    }
                    if (!found && b.ValueSelection.AllowFreeMode)
                    {
                        ComboBoxEx_Values.Text = TextFromValue((long)value);
                    }
                }));
            }
        }
示例#2
0
 public void SetValue(HUDOptionsBlock b, object value)
 {
     if (b?.ValueSelection is HUDOptionsValueSelection && (bool)binaryData?.CanWrite)
     {
         binaryData.Position = b.ValueSelection.RomPos;
         switch (b.ValueSelection.ValueType)
         {
         case HUDOptionsValueTypes.Byte:
             binaryData.Write((byte)value);
             break;
         }
     }
 }
示例#3
0
        public Point GetPosition(HUDOptionsBlock b)
        {
            Point GetPositionRet = default;

            GetPositionRet = Point.Empty;
            if (b?.Cords is object && binaryData?.CanRead == true)
            {
                binaryData.Position = (long)b.Cords.RomPosX;
                GetPositionRet.X    = binaryData.ReadInt16();
                binaryData.Position = (long)b.Cords.RomPosY;
                GetPositionRet.Y    = binaryData.ReadInt16();
            }

            return(GetPositionRet);
        }
示例#4
0
        public void SetPosition(HUDOptionsBlock b, Point p)
        {
            if (b?.Cords is object && binaryData?.CanWrite == true)
            {
                if (b.Cords.RomPosX is object)
                {
                    binaryData.Position = (long)b.Cords.RomPosX;
                    binaryData.Write(Conversions.ToShort(p.X));
                }

                if (b.Cords.RomPosY is object)
                {
                    binaryData.Position = (long)b.Cords.RomPosY;
                    binaryData.Write(Conversions.ToShort(p.Y));
                }
            }
        }
示例#5
0
        public object GetValue(HUDOptionsBlock b)
        {
            object value = -1;

            if (b?.ValueSelection is HUDOptionsValueSelection && (bool)binaryData?.CanRead)
            {
                binaryData.Position = b.ValueSelection.RomPos;
                switch (b.ValueSelection.ValueType)
                {
                case HUDOptionsValueTypes.Byte:
                    value = binaryData.ReadByte();
                    break;
                }
            }

            return(value);
        }
示例#6
0
        private void LoadBlock(HUDOptionsBlock b, NodeCollection parentCollection)
        {
            var n = new Node()
            {
                Text = HUDOptionsLangRes.ResourceManager.GetString("HUDPos_" + b.Name),
                Tag  = b
            };

            Invoke(new Action(() => parentCollection.Add(n)));
            if (b.Childs is object)
            {
                foreach (HUDOptionsBlock bb in b.Childs)
                {
                    LoadBlock(bb, n.Nodes);
                }
            }
        }
示例#7
0
 private void SavePosition(HUDOptionsBlock b)
 {
     if (b?.Cords is HUDOptionsCords)
     {
         hud.OpenRomWrite();
         hud.SetPosition(b, new Point(IntegerInput_PosX.Value, IntegerInput_PosY.Value));
         hud.CloseRom();
     }
     else if (b?.ValueSelection is HUDOptionsValueSelection)
     {
         hud.OpenRomWrite();
         if (b.ValueSelection.AllowFreeMode)
         {
             hud.SetValue(b, ValueFromText(ComboBoxEx_Values.Text));
         }
         else if (ComboBoxEx_Values.SelectedItem is ComboItem)
         {
             hud.SetValue(b, ((ComboItem)ComboBoxEx_Values.SelectedItem).Tag);
         }
         hud.CloseRom();
     }
 }