ToByte() public static method

public static ToByte ( byte data ) : string
data byte
return string
Beispiel #1
0
        public static void AddChestData(int room)
        {
            int group = room >> 8;

            room &= 0xff;

            FileParser chestFileParser = Project.GetFileWithLabel("chestDataGroupTable");
            Data       chestPointer    = chestFileParser.GetData("chestDataGroupTable", group * 2);
            string     pointerString   = chestPointer.GetValue(0);
            Data       chestGroupData  = Project.GetData(pointerString);

            Data newData = new Data(Project, ".db", new string[] { "$00" }, -1, null, new List <int> {
                -1
            });

            newData.EndsLine = false;
            chestFileParser.InsertComponentBefore(chestGroupData, newData);

            newData = new Data(Project, ".db", new string[] { Wla.ToByte((byte)room) }, -1, null, null);
            newData.PrintCommand = false;
            newData.EndsLine     = false;
            chestFileParser.InsertComponentBefore(chestGroupData, newData);

            newData = new Data(Project, ".db", new string[] { "$00" }, -1, null, null);
            newData.PrintCommand = false;
            newData.EndsLine     = false;
            chestFileParser.InsertComponentBefore(chestGroupData, newData);

            newData = new Data(Project, ".db", new string[] { "$00" }, -1, null, null);
            newData.PrintCommand = false;
            chestFileParser.InsertComponentBefore(chestGroupData, newData);
        }
Beispiel #2
0
        /// <summary>
        ///  Returns a list of all possible values (human-readable; shows both the byte and the
        ///  corresponding string), along with their description if they have one.
        /// </summary>
        public IList <Tuple <string, string> > GetAllValuesWithDescriptions()
        {
            var list = new List <Tuple <string, string> >();

            foreach (byte key in byteToString.Keys)
            {
                string name = Wla.ToByte(key) + ": " + RemovePrefix(byteToString[key].str);
                string desc = GetDocumentationForValue(key)?.GetField("desc") ?? "";
                var    tup  = new Tuple <string, string>(name, desc);
                list.Add(tup);
            }
            return(list);
        }
Beispiel #3
0
        public TreasureEditorGui(PluginManager manager)
            : base(0.5f, 0.0f, 0.0f, 0.0f)
        {
            this.manager = manager;

            highIndexButton               = new SpinButtonHexadecimal(0, 0xff);
            highIndexButton.Digits        = 2;
            highIndexButton.ValueChanged += (a, b) => {
                SetTreasure(Index);
            };

            Button hAddButton = new Gtk.Button();

            hAddButton.Clicked += (a, b) => {
                Treasure.AddHighIndex();
                SetTreasure(0xffff);
            };
            hAddButton.UseStock     = true;
            hAddButton.UseUnderline = true;
            hAddButton.Image        = new Gtk.Image(Gtk.Stock.Add, Gtk.IconSize.Button);

            Button hRemoveButton = new Gtk.Button();

            hRemoveButton.Clicked += (a, b) => {
                Gtk.MessageDialog d = new MessageDialog(null,
                                                        DialogFlags.DestroyWithParent,
                                                        MessageType.Warning,
                                                        ButtonsType.YesNo,
                                                        "This will shift the indices for all treasures starting from " +
                                                        Wla.ToByte((byte)(Index >> 8)) + "! All treasures after this WILL BREAK! " +
                                                        "Are you sure you want to continue?"
                                                        );
                var r = (ResponseType)d.Run();
                d.Destroy();
                if (r != Gtk.ResponseType.Yes)
                {
                    return;
                }
                Treasure.RemoveHighIndex(Index >> 8);
                SetTreasure(Index);
            };
            hRemoveButton.UseStock     = true;
            hRemoveButton.UseUnderline = true;
            hRemoveButton.Image        = new Gtk.Image(Gtk.Stock.Remove, Gtk.IconSize.Button);

            lowIndexButton               = new SpinButtonHexadecimal(0, 0xff);
            lowIndexButton.Digits        = 2;
            lowIndexButton.ValueChanged += (a, b) => {
                SetTreasure(Index);
            };

            Button addButton = new Gtk.Button();

            addButton.Clicked += (a, b) => {
                Treasure.AddSubIndex(Index >> 8);
                SetTreasure((Index & 0xff00) + 0xff);
            };
            addButton.UseStock     = true;
            addButton.UseUnderline = true;
            addButton.Image        = new Gtk.Image(Gtk.Stock.Add, Gtk.IconSize.Button);

            Button removeButton = new Gtk.Button();

            removeButton.Clicked += (a, b) => {
                if ((Index & 0xff) < Treasure.GetNumLowIndices(Index >> 8) - 1)
                {
                    Gtk.MessageDialog d = new MessageDialog(null,
                                                            DialogFlags.DestroyWithParent,
                                                            MessageType.Warning,
                                                            ButtonsType.YesNo,
                                                            "This will shift all sub-indices for treasure " +
                                                            Wla.ToByte((byte)(Index >> 8)) + " starting from sub-index " +
                                                            Wla.ToByte((byte)(Index & 0xff)) + "! Are you sure you want to continue?"
                                                            );
                    var r = (ResponseType)d.Run();
                    d.Destroy();
                    if (r != Gtk.ResponseType.Yes)
                    {
                        return;
                    }
                }
                Treasure.RemoveSubIndex(Index);
                SetTreasure((Index & 0xff00) + 0xff);
            };
            removeButton.UseStock     = true;
            removeButton.UseUnderline = true;
            removeButton.Image        = new Gtk.Image(Gtk.Stock.Remove, Gtk.IconSize.Button);

            var table = new Table(3, 2, false);

            uint y = 0;

            table.Attach(new Gtk.Label("ID1"), 0, 1, y, y + 1);
            table.Attach(highIndexButton, 1, 2, y, y + 1);
            // Disable high add and remove buttons for now, they're not useful
            // yet
//             table.Attach(hAddButton,2,3,y,y+1);
//             table.Attach(hRemoveButton,3,4,y,y+1);
            y++;
            table.Attach(new Gtk.Label("ID2"), 0, 1, y, y + 1);
            table.Attach(lowIndexButton, 1, 2, y, y + 1);
            table.Attach(addButton, 2, 3, y, y + 1);
            table.Attach(removeButton, 3, 4, y, y + 1);

            vrContainer = new Alignment(1.0f, 1.0f, 1.0f, 1.0f);

            VBox vbox = new VBox();

            vbox.Add(table);
            vbox.Add(vrContainer);

            Add(vbox);

            SetTreasure(0);
        }
Beispiel #4
0
 public void SetByteValue(int i, byte value)
 {
     SetValue(i, Wla.ToByte(value));
 }