コード例 #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);
        }
コード例 #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);
        }
コード例 #3
0
ファイル: ValueReference.cs プロジェクト: turbo3001/LynnaLab
        public virtual void SetValue(int i)
        {
            switch (ValueType)
            {
            case DataValueType.HalfByte:
                data.SetValue(valueIndex, Wla.ToHalfByte((byte)i));
                break;

            case DataValueType.Byte:
            case DataValueType.WarpDestIndex:
            default:
                data.SetByteValue(valueIndex, (byte)i);
                break;

            case DataValueType.Word:
                data.SetWordValue(valueIndex, i);
                break;

            case DataValueType.ByteBits:
            case DataValueType.WordBits:
            {
                int andValue = ((1 << (endBit - startBit + 1)) - 1);
                int value    = data.GetIntValue(valueIndex) & (~(andValue << startBit));
                value |= ((i & andValue) << startBit);
                if (ValueType == DataValueType.ByteBits)
                {
                    data.SetByteValue(valueIndex, (byte)value);
                }
                else
                {
                    data.SetWordValue(valueIndex, value);
                }
            }
            break;

            case DataValueType.ByteBit:
            {
                int value = data.GetIntValue(valueIndex) & ~(1 << startBit);
                value |= ((i & 1) << startBit);
                data.SetByteValue(valueIndex, (byte)value);
            }
            break;
            }
        }
コード例 #4
0
            void SetSelected(int x, int y, bool val)
            {
                Data data = bitData;
                int  i    = y * Width + x;

                while (i >= 8)
                {
                    data = data.NextData;
                    i   -= 8;
                }
                int bit = (0x80 >> i);

                if (val)
                {
                    data.SetValue(0, Wla.ToBinary(data.GetIntValue(0) | bit));
                }
                else
                {
                    data.SetValue(0, Wla.ToBinary(data.GetIntValue(0) & ~bit));
                }
                QueueDrawArea(x * TileWidth, y * TileHeight, TileWidth, TileHeight);
            }
コード例 #5
0
        public override void Clicked()
        {
            Treasure.Project = Project;
            Chest.Project    = Project;

            Gtk.Window win = new Window(WindowType.Toplevel);
            Alignment  warningsContainer = new Alignment(0.1f, 0.1f, 0f, 0f);

            VBox vbox = new VBox();

            var chestGui = new ChestEditorGui(manager);

            chestGui.SetRoom(manager.GetActiveRoom().Index);
            chestGui.Destroyed += (sender2, e2) => win.Destroy();

            Frame chestFrame = new Frame();

            chestFrame.Label = "Chest Data";
            chestFrame.Add(chestGui);

            var   treasureGui   = new TreasureEditorGui(manager);
            Frame treasureFrame = new Frame();

            treasureFrame.Label = "Treasure Data";
            treasureFrame.Add(treasureGui);

            System.Action UpdateWarnings = () => {
                VBox warningBox = new VBox();
                warningBox.Spacing = 4;

                System.Action <string> AddWarning = (s) => {
                    Image img = new Image(Stock.DialogWarning, IconSize.Button);
                    HBox  hb  = new HBox();
                    hb.Spacing = 10;
                    hb.Add(img);
                    Gtk.Label l = new Gtk.Label(s);
                    l.LineWrap = true;
                    hb.Add(l);
                    Alignment a = new  Alignment(0, 0, 0, 0);
                    a.Add(hb);
                    warningBox.Add(a);
                };

                foreach (var c in warningsContainer.Children)
                {
                    warningsContainer.Remove(c);
                }

                int index = chestGui.GetTreasureIndex();
                if (index < 0)
                {
                    return;
                }

                if (!Treasure.IndexExists(index))
                {
                    AddWarning("Treasure " + Wla.ToWord(index) + " does not exist.");
                }
                else
                {
                    if (index != treasureGui.Index)
                    {
                        AddWarning("Your treasure index is different\nfrom the chest you're editing.");
                    }

                    int spawnMode = (Treasure.GetTreasureByte(index, 0) >> 4) & 7;

                    if (spawnMode != 3)
                    {
                        AddWarning("Treasure " + Wla.ToWord(index) + " doesn't have spawn\nmode $3 (needed for chests).");
                    }

                    int  yx = Chest.GetChestByte(chestGui.RoomIndex, 0);
                    int  x  = yx & 0xf;
                    int  y  = yx >> 4;
                    Room r  = Project.GetIndexedDataType <Room>(chestGui.RoomIndex);
                    if (x >= r.Width || y >= r.Height || r.GetTile(x, y) != 0xf1)
                    {
                        AddWarning("There is no chest at coordinates (" + x + "," + y + ").");
                    }
                }

                warningsContainer.Add(warningBox);

                win.ShowAll();
            };

            chestGui.SetTreasureEditor(treasureGui);
            chestGui.ChestChangedEvent += () => {
                UpdateWarnings();
            };
            treasureGui.TreasureChangedEvent += () => {
                UpdateWarnings();
            };

            HBox hbox = new Gtk.HBox();

            hbox.Spacing = 6;
            hbox.Add(chestFrame);
            hbox.Add(treasureFrame);

            Button okButton = new Gtk.Button();

            okButton.UseStock = true;
            okButton.Label    = "gtk-ok";
            okButton.Clicked += (a, b) => {
                win.Destroy();
            };

            Alignment buttonAlign = new Alignment(0.5f, 0.5f, 0f, 0f);

            buttonAlign.Add(okButton);

            vbox.Add(hbox);
            vbox.Add(warningsContainer);
            vbox.Add(buttonAlign);

            win.Add(vbox);

            UpdateWarnings();
            win.ShowAll();
        }
コード例 #6
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);
        }
コード例 #7
0
ファイル: Data.cs プロジェクト: turbo3001/LynnaLab
 public void SetWordValue(int i, int value)
 {
     SetValue(i, Wla.ToWord(value));
 }
コード例 #8
0
ファイル: Data.cs プロジェクト: turbo3001/LynnaLab
 public void SetByteValue(int i, byte value)
 {
     SetValue(i, Wla.ToByte(value));
 }