示例#1
0
        void SetTileset(Tileset t)
        {
            if (t == tileset)
            {
                return;
            }
            tileset = t;

            tilesetEventWrapper.ReplaceEventSource(tileset);

            subTileEditor.SetTileset(tileset);
            if (tileset != null)
            {
                subTileGfxViewer.SetGraphicsState(tileset.GraphicsState, 0x2000, 0x3000);
            }

            tilesetviewer1.SetTileset(tileset);

            ValueReferenceGroup vrg = tileset.GetValueReferenceGroup();

            if (tilesetVre == null)
            {
                tilesetVre = new ValueReferenceEditor(Project, vrg, 8);
                tilesetVreContainer.Add(tilesetVre);
            }
            else
            {
                tilesetVre.ReplaceValueReferenceGroup(vrg);
            }

            OnPalettesChanged(null, null);

            tilesetSpinButton.Value            = tileset.Index;
            tilesetSpinButton.Adjustment.Upper = Project.NumTilesets - 1;
        }
示例#2
0
        void SetObjectData(ObjectData data)
        {
            activeData = data;

            Action handler = delegate() {
                if (RoomEditor != null)
                {
                    RoomEditor.OnObjectsModified();
                }

                UpdateDocumentation();
            };

            foreach (Gtk.Widget widget in objectDataContainer.Children)
            {
                objectDataContainer.Remove(widget);
                widget.Destroy();
            }
            if (ObjectDataEditor != null)
            {
                ObjectDataEditor.RemoveDataModifiedHandler(handler);
                ObjectDataEditor = null;
            }

            if (RoomEditor != null)
            {
                RoomEditor.OnObjectsModified();
            }

            if (data == null)
            {
                frameLabel.Text = "";
                return;
            }
            frameLabel.Text = ObjectNames[(int)activeData.GetObjectType()];

            ObjectDataEditor = new ValueReferenceEditor(Project, data);
            ObjectDataEditor.AddDataModifiedHandler(handler);

            if (SubEditor != null)
            {
                SubEditor.RoomEditor = RoomEditor;
            }

            objectDataContainer.Add(ObjectDataEditor);
            objectDataContainer.ShowAll();

            UpdateDocumentation();
        }
示例#3
0
        // This can be a warp that isn't in the warp list (as when editing a warp destination).
        public void SetSelectedWarp(Warp warp)
        {
            if (_selectedWarp == warp)
            {
                return;
            }
            _selectedWarp = warp;

            valueEditorContainer.Foreach((c) => c.Dispose());

            if (warp == null)
            {
                warpSourceFrame.Hide();
                return;
            }

            int index = GetWarpIndex(warp);

            warpSourceBox.SelectedIndex = index;

            Gtk.HBox hbox = new Gtk.HBox();

            if (warp.WarpSourceType == WarpSourceType.Pointed)
            {
                warpSourceTypeLabel.Text = "<b>Type</b>: Position Warp";
            }
            else
            {
                warpSourceTypeLabel.Text = "<b>Type</b>: Screen Warp";
            }

            warpSourceTypeLabel.UseMarkup = true;

            sourceEditor = new ValueReferenceEditor(Project, warp.ValueReferenceGroup);

            valueEditorContainer.Add(sourceEditor);
            warpSourceFrame.ShowAll();

            if (SelectedWarpEvent != null)
            {
                SelectedWarpEvent(this, null);
            }
        }
示例#4
0
        void SetObject(ObjectDefinition obj)
        {
            if (activeObject == obj)
            {
                return;
            }
            activeObject = obj;

            foreach (Gtk.Widget widget in objectDataContainer.Children)
            {
                objectDataContainer.Remove(widget);
                widget.Dispose();
            }
            if (ObjectDataEditor != null)
            {
                ObjectDataEditor.RemoveDataModifiedHandler(OnObjectDataModified);
                ObjectDataEditor = null;
            }

            if (RoomEditor != null)
            {
                RoomEditor.OnObjectSelected();
            }

            if (obj == null)
            {
                frameLabel.Text = "";
                return;
            }
            frameLabel.Text = ObjectNames[(int)activeObject.GetObjectType()];

            ObjectDataEditor = new ValueReferenceEditor(Project, obj);
            ObjectDataEditor.AddDataModifiedHandler(OnObjectDataModified);

            objectDataContainer.Add(ObjectDataEditor);
            objectDataContainer.ShowAll();

            UpdateDocumentation();
        }
示例#5
0
        void SetDestIndex(int group, int index)
        {
            destGroupSpinButton.Value = group;
            destIndexSpinButton.Value = index;

            destEditorContainer.Remove(destEditorContainer.Child);

            if (group != -1 && group < Project.GetNumGroups())
            {
                destGroup = Project.GetIndexedDataType <WarpDestGroup>(group);
            }

            if (group == -1 || group >= Project.GetNumGroups() ||
                index == -1 || index >= destGroup.GetNumWarpDests())
            {
                frame2.Hide();
                return;
            }

            WarpDestData         destData = destGroup.GetWarpDest(index);
            ValueReferenceEditor editor   = new ValueReferenceEditor(Project, destData);

            int numReferences = destData.GetNumReferences();

            if (numReferences == 2)
            {
                destInfoLabel.Text = "Used by " + (numReferences - 1) + " other source";
            }
            else
            {
                destInfoLabel.Text = "Used by " + (numReferences - 1) + " other sources";
            }

            destEditorContainer.Add(editor);
            destEditorContainer.ShowAll();
            frame2.ShowAll();
        }
示例#6
0
        // Load the i'th warp in the current map.
        void SetWarpIndex(int i)
        {
            List <WarpSourceData> sourceDataList = sourceGroup.GetMapWarpSourceData(map);

            indexSpinButton.Adjustment.Lower = -1;
            indexSpinButton.Adjustment.Upper = sourceDataList.Count - 1;

            if (i > indexSpinButton.Adjustment.Upper)
            {
                i = (int)indexSpinButton.Adjustment.Upper;
            }

            indexSpinButton.Value = i;

            valueEditorContainer.Remove(valueEditorContainer.Child);

            if (i == -1)
            {
                SetDestIndex(-1, -1);
                return;
            }

            Gtk.HBox hbox = new Gtk.HBox();

            WarpSourceData warpSourceData = sourceDataList[i];

            if (warpSourceData.WarpSourceType == WarpSourceType.StandardWarp)
            {
                SetDestIndex(warpSourceData.DestGroup, warpSourceData.DestIndex);
            }

            sourceEditor = new ValueReferenceEditor(Project,
                                                    warpSourceData);

            Alignment a = new Alignment(0, 0, 0, 0);

            a.Add(sourceEditor);
            hbox.Add(a);

            if (warpSourceData.WarpSourceType == WarpSourceType.PointerWarp)
            {
                Table table = new Table(1, 1, false);
                table.ColumnSpacing = 6;
                table.RowSpacing    = 6;

                SpinButton pointerSpinButton = new SpinButton(0, 10, 1);

                EventHandler valueChangedHandler = delegate(object sender, EventArgs e) {
                    WarpSourceData pointedData = warpSourceData.GetPointedWarp();

                    pointerSpinButton.Adjustment.Lower = 0;
                    pointerSpinButton.Adjustment.Upper = warpSourceData.GetPointedChainLength() - 1;

                    if (pointerSpinButton.ValueAsInt > pointerSpinButton.Adjustment.Upper)
                    {
                        pointerSpinButton.Value = pointerSpinButton.Adjustment.Upper;
                    }
                    int index = pointerSpinButton.ValueAsInt;

                    while (index > 0)
                    {
                        pointedData = pointedData.GetNextWarp();
                        index--;
                    }

                    table.Remove(destEditor);

                    destEditor = new ValueReferenceEditor(Project, pointedData);

                    destEditor.AddDataModifiedHandler(delegate() {
                        SetDestIndex(pointedData.DestGroup, pointedData.DestIndex);
                    });

                    table.Attach(destEditor, 0, 2, 1, 2);

                    SetDestIndex(pointedData.DestGroup, pointedData.DestIndex);
                };

                pointerSpinButton.ValueChanged += valueChangedHandler;

                // Button which, when clicked, adds a new PointedData to the
                // "chain".
                Gtk.Button addPointedWarpButton =
                    new Gtk.Button(new Gtk.Image(Gtk.Stock.Add, Gtk.IconSize.Button));

                addPointedWarpButton.Clicked += delegate(object sender, EventArgs e) {
                    WarpSourceData pointedData = warpSourceData.GetPointedWarp();

                    while (pointedData.GetNextWarp() != null)
                    {
                        pointedData = pointedData.GetNextWarp();
                    }

                    WarpSourceData nextData = new WarpSourceData(Project,
                                                                 WarpSourceData.WarpCommands[(int)WarpSourceType.PointedWarp],
                                                                 WarpSourceData.DefaultValues[(int)WarpSourceType.PointedWarp],
                                                                 pointedData.FileParser,
                                                                 new List <int> {
                        -1
                    });
                    pointedData.SetNextWarp(nextData);

                    pointerSpinButton.Adjustment.Upper++;
                    pointerSpinButton.Value = warpSourceData.GetPointedChainLength() - 1;
                    valueChangedHandler(null, null);
                };

                // Button which removes a PointedData from the "chain", unless
                // there is only one remaining.
                Gtk.Button removePointedWarpButton =
                    new Gtk.Button(new Gtk.Image(Gtk.Stock.Remove, Gtk.IconSize.Button));

                removePointedWarpButton.Clicked += delegate(object sender, EventArgs e) {
                    int            index       = pointerSpinButton.ValueAsInt;
                    WarpSourceData pointedData = warpSourceData.GetPointedWarp();

                    if (pointedData.GetPointedChainLength() <= 1) // Don't delete the last one
                    {
                        return;
                    }

                    while (index > 0)
                    {
                        pointedData = pointedData.GetNextWarp();
                        index--;
                    }

                    pointedData.FileParser.RemoveFileComponent(pointedData);

                    valueChangedHandler(null, null);
                };

                table.Attach(new Gtk.Label("Pointer index"), 0, 1, 0, 1);
                table.Attach(pointerSpinButton, 1, 2, 0, 1);
                table.Attach(addPointedWarpButton, 2, 3, 0, 1);
                table.Attach(removePointedWarpButton, 3, 4, 0, 1);

                // Invoke handler
                valueChangedHandler(pointerSpinButton, null);

                Frame frame = new Frame(warpSourceData.PointerString);
                frame.Add(table);

                hbox.Add(frame);
            }
            else   // Not pointerWarp
            {
                sourceEditor.AddDataModifiedHandler(delegate() {
                    SetDestIndex(warpSourceData.DestGroup, warpSourceData.DestIndex);
                });
            }

            valueEditorContainer.Add(hbox);
            valueEditorContainer.ShowAll();
        }
示例#7
0
        public override void Clicked()
        {
            Box tmpBox, tmpBox2;
            Alignment tmpAlign;
            Box vbox = new Gtk.VBox();
            vbox.Spacing = 3;
            Box hbox = new Gtk.HBox();
            hbox.Spacing = 3;

            Box dungeonVreContainer = new Gtk.VBox();
            Box roomVreContainer = new Gtk.VBox();
            ValueReferenceEditor dungeonVre = null;
            ValueReferenceEditor roomVre = null;

            Alignment frame = new Alignment(0,0,0,0);
            var dungeonSpinButton = new SpinButton(0,15,1);
            var floorSpinButton = new SpinButton(0,15,1);
            var roomSpinButton = new SpinButtonHexadecimal(0,255,1);
            roomSpinButton.Digits = 2;
            Minimap minimap = null;

            System.Action RoomChanged = () => {
                Dungeon dungeon = minimap.Map as Dungeon;
                Room room = minimap.GetRoom();

                roomSpinButton.Value = room.Index&0xff;

                var vrs = new List<ValueReference>();
                vrs.Add(new StreamValueReference("Up", room.Index&0xff, 0,0, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Right", room.Index&0xff, 1,1, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Down", room.Index&0xff, 2,2, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Left", room.Index&0xff, 3,3, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Key", room.Index&0xff, 4,4, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Chest", room.Index&0xff, 5,5, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Boss", room.Index&0xff, 6,6, DataValueType.ByteBit));
                vrs.Add(new StreamValueReference("Dark", room.Index&0xff, 7,7, DataValueType.ByteBit));

                Stream stream = Project.GetBinaryFile("rooms/group" + dungeon.Group + "DungeonProperties.bin");
                foreach (StreamValueReference r in vrs)
                    r.SetStream(stream);

                if (roomVre != null)
                    roomVreContainer.Remove(roomVre);

                var vrg = new ValueReferenceGroup(vrs);
                roomVre = new ValueReferenceEditor(Project, vrg, 4, "Minimap Data");

                roomVreContainer.Add(roomVre);
            };

            System.Action DungeonChanged = () => {
                Dungeon dungeon = Project.GetIndexedDataType<Dungeon>(dungeonSpinButton.ValueAsInt);

                floorSpinButton.Adjustment.Upper = dungeon.NumFloors-1;
                if (floorSpinButton.ValueAsInt >= dungeon.NumFloors)
                    floorSpinButton.Value = dungeon.NumFloors-1;

                var vrs = new List<ValueReference>();
                vrs.Add(new ValueReference("Group", 0, DataValueType.String, false));
                vrs.Add(new ValueReference("Wallmaster dest room", 0, DataValueType.Byte));
                vrs.Add(new ValueReference("Bottom floor layout", 0, DataValueType.Byte, false));
                vrs.Add(new ValueReference("# of floors", 0, DataValueType.Byte, false));
                vrs.Add(new ValueReference("Base floor name", 0, DataValueType.Byte));
                vrs.Add(new ValueReference("Floors unlocked with compass", 0, DataValueType.Byte));

                Data data = dungeon.DataStart;
                foreach (ValueReference r in vrs) {
                    r.SetData(data);
                    data = data.NextData;
                }

                // Remove last ValueReferenceEditor
                if (dungeonVre != null)
                    dungeonVreContainer.Remove(dungeonVre);

                var vrg = new ValueReferenceGroup(vrs);
                dungeonVre = new ValueReferenceEditor(Project, vrg, "Base Data");

                dungeonVre.AddDataModifiedHandler(() => {
                            floorSpinButton.Adjustment.Upper = dungeon.NumFloors;
                            minimap.GenerateImage();
                            RoomChanged();
                        });

                // Replace the "group" option with a custom widget for finer
                // control.
                SpinButton groupSpinButton = new SpinButton(4,5,1);
                groupSpinButton.Value = dungeon.Group;
                groupSpinButton.ValueChanged += (c,d) => {
                    vrg.SetValue("Group", ">wGroup" + groupSpinButton.ValueAsInt + "Flags");
                };
                dungeonVre.ReplaceWidget(0, groupSpinButton);
                dungeonVre.ShowAll();

                // Tooltips
                dungeonVre.AddTooltip(0, "Also known as the high byte of the room index.");
                dungeonVre.AddTooltip(1, "The low byte of the room index wallmasters will send you to.");
                dungeonVre.AddTooltip(2, "The index of the layout for the bottom floor. Subsequent floors will use subsequent indices.");
                dungeonVre.AddTooltip(4, "Determines what the game will call the bottom floor. For a value of:\n$00: The bottom floor is 'B3'.\n$01: The bottom floor is 'B2'.\n$02: The bottom floor is 'B1'.\n$03: The bottom floor is 'F1'.");
                dungeonVre.AddTooltip(5, "A bitset of floors that will appear on the map when the compass is obtained.\n\nEg. If this is $05, then floors 0 and 2 will be unlocked (bits 0 and 2 are set).");

                dungeonVreContainer.Add(dungeonVre);
                minimap.SetMap(dungeon);
                minimap.Floor = floorSpinButton.ValueAsInt;

                RoomChanged();
            };

            dungeonSpinButton.ValueChanged += (a,b) => { DungeonChanged(); };
            floorSpinButton.ValueChanged += (a,b) => { DungeonChanged(); };

            frame.Add(vbox);

            tmpBox = new Gtk.HBox();
            tmpBox.Add(new Gtk.Label("Dungeon "));
            tmpBox.Add(dungeonSpinButton);
            tmpBox.Add(new Gtk.Label("Floor "));
            tmpBox.Add(floorSpinButton);
            tmpAlign = new Alignment(0,0,0,0);
            tmpAlign.Add(tmpBox);

            vbox.Add(tmpAlign);
            vbox.Add(hbox);

            // Leftmost column

            tmpBox = new VBox();
            tmpBox.Add(dungeonVreContainer);

            var addFloorButton = new Button("Add Floor");
            addFloorButton.Image = new Gtk.Image(Gtk.Stock.Add, Gtk.IconSize.Button);
            addFloorButton.Clicked += (a,b) => {
                Dungeon dungeon = minimap.Map as Dungeon;

                int newFloorIndex = dungeon.FirstLayoutIndex + dungeon.NumFloors;

                // Shift all subsequent layouts 64 bytes down in the data file
                Stream layoutFile = Project.GetBinaryFile("rooms/dungeonLayouts.bin");
                layoutFile.SetLength(layoutFile.Length+64);
                for (int i=(int)layoutFile.Length/64-1; i>newFloorIndex; i--) {
                    var buf = new byte[64];
                    layoutFile.Position = (i-1)*64;
                    layoutFile.Read(buf, 0, 64);
                    layoutFile.Write(buf, 0, 64);
                }

                // Clear the new floor
                layoutFile.Position = newFloorIndex*64;
                for (int j=0;j<64;j++)
                    layoutFile.WriteByte(0);

                // Shift each dungeon's "FirstLayoutIndex" to match the shifted layouts.
                for (int i=0; i<Project.GetNumDungeons(); i++) {
                    Dungeon d2 = Project.GetIndexedDataType<Dungeon>(i);
                    if (d2.FirstLayoutIndex >= newFloorIndex)
                        d2.FirstLayoutIndex++;
                }

                dungeon.NumFloors = dungeon.NumFloors+1;
                floorSpinButton.Value = dungeon.NumFloors-1;
                DungeonChanged();
            };
            tmpAlign = new Gtk.Alignment(0.5f,0,0,0);
            tmpAlign.Add(addFloorButton);
            tmpBox.PackStart(tmpAlign);

            var removeFloorButton = new Button("Remove Top Floor");
            removeFloorButton.Image = new Gtk.Image(Gtk.Stock.Remove, Gtk.IconSize.Button);
            removeFloorButton.Clicked += (a,b) => {
                Dungeon dungeon = minimap.Map as Dungeon;

                if (dungeon.NumFloors <= 1)
                    return;

                Gtk.MessageDialog d = new MessageDialog(null,
                        DialogFlags.DestroyWithParent,
                        MessageType.Warning,
                        ButtonsType.YesNo,
                        "Are you quite certain that you wish to delete the top floor of this dungeon?");
                var response = (ResponseType)d.Run();
                d.Destroy();

                if (response == Gtk.ResponseType.Yes) {
                    int deletedFloorIndex = dungeon.FirstLayoutIndex + dungeon.NumFloors-1;

                    // Shift all subsequent layouts 64 bytes up in the data file
                    Stream layoutFile = Project.GetBinaryFile("rooms/dungeonLayouts.bin");
                    for (int i=deletedFloorIndex; i<layoutFile.Length/64-1; i++) {
                        var buf = new byte[64];
                        layoutFile.Position = (i+1)*64;
                        layoutFile.Read(buf, 0, 64);
                        layoutFile.Position = i*64;
                        layoutFile.Write(buf, 0, 64);
                    }

                    layoutFile.SetLength(layoutFile.Length-64);

                    // Shift each dungeon's "FirstLayoutIndex" to match the shifted layouts.
                    for (int i=0; i<Project.GetNumDungeons(); i++) {
                        Dungeon d2 = Project.GetIndexedDataType<Dungeon>(i);
                        if (d2.FirstLayoutIndex > deletedFloorIndex)
                            d2.FirstLayoutIndex--;
                    }

                    dungeon.NumFloors = dungeon.NumFloors-1;

                    DungeonChanged();
                }
            };
            tmpAlign = new Gtk.Alignment(0.5f,0,0,0);
            tmpAlign.Add(removeFloorButton);
            tmpBox.PackStart(tmpAlign);

            hbox.PackStart(tmpBox);

            // Middle column (minimap)

            minimap = new Minimap();
            minimap.TileSelectedEvent += (sender) => {
                RoomChanged();
            };

            hbox.PackStart(minimap);

            // Rightmost column

            tmpAlign = new Alignment(0,0,0,0);
            tmpAlign.Add(roomVreContainer);

            tmpBox2 = new HBox();
            tmpBox2.Add(new Gtk.Label("Room "));
            roomSpinButton.ValueChanged += (a,b) => {
                (minimap.Map as Dungeon).SetRoom(minimap.SelectedX, minimap.SelectedY,
                        minimap.Floor, roomSpinButton.ValueAsInt);
                minimap.GenerateImage();
                RoomChanged();
            };
            tmpBox2.Add(roomSpinButton);

            tmpBox = new VBox();
            tmpBox.Add(tmpBox2);
            tmpBox.Add(tmpAlign);

            hbox.PackStart(tmpBox);

            Window w = new Window(null);
            w.Add(frame);
            w.ShowAll();

            Map map = manager.GetActiveMap();
            if (map is Dungeon)
                dungeonSpinButton.Value = map.Index;

            DungeonChanged();
        }
示例#8
0
        public void SetTreasure(int index)
        {
            int hIndex = index>>8;
            int lIndex = index&0xff;

            int hMax = Treasure.GetNumHighIndices();
            if (hIndex >= hMax)
                hIndex = hMax-1;

            int lMax = Treasure.GetNumLowIndices(hIndex);
            if (lIndex >= lMax)
                lIndex = lMax-1;

            highIndexButton.Adjustment.Upper = hMax-1;
            lowIndexButton.Adjustment.Upper = lMax-1;
            highIndexButton.Value = hIndex;
            lowIndexButton.Value = lIndex;

            index = hIndex<<8|lIndex;

            vrContainer.Remove(vrEditor);

            Data data = Treasure.GetTreasureDataBase(index);
            ValueReference v1 = new ValueReference("Spawn Mode", 0, 4,6, DataValueType.ByteBits);
            v1.SetData(data);
            ValueReference v5 = new ValueReference("Grab Mode", 0, 0,2, DataValueType.ByteBits);
            v5.SetData(data);
            ValueReference v6 = new ValueReference("Unknown", 0, 3,3, DataValueType.ByteBit);
            v6.SetData(data);

            data = data.NextData;
            ValueReference v2 = new ValueReference("Parameter", 0, DataValueType.Byte);
            v2.SetData(data);
            data = data.NextData;
            ValueReference v3 = new ValueReference("Text ID", 0, DataValueType.Byte);
            v3.SetData(data);
            data = data.NextData;
            ValueReference v4 = new ValueReference("Gfx", 0, DataValueType.Byte);
            v4.SetData(data);
            data = data.NextData;

            // Byte 1 is sometimes set to 0x80 for unused treasures?
            v1.SetValue(v1.GetIntValue()&0x7f);

            ValueReferenceGroup vrGroup = new ValueReferenceGroup(new ValueReference[] {v1, v5, v6, v2, v3, v4});

            var vr = new ValueReferenceEditor(
                    Project,
                    vrGroup,
                    "Data");
            vr.SetMaxBound(0, 0x7f); // Max bound for Spawn Mode

            vr.AddDataModifiedHandler(() => {
                    if (TreasureChangedEvent != null)
                        TreasureChangedEvent();
                });

            vrEditor = vr;
            vrContainer.Add(vrEditor);

            if (TreasureChangedEvent != null)
                TreasureChangedEvent();
        }
示例#9
0
        public void SetRoom(int room)
        {
            indexSpinButton.Value = room;

            vrContainer.Remove(vrEditor);
            vrEditor = null;
            v1 = null;
            v2 = null;
            v3 = null;
            v4 = null;

            Data data = Chest.GetChestData(room);

            if (data == null) {
                VBox vbox = new VBox();

                Button addButton = new Button("Add");
                addButton.Clicked += (a,b) => {
                    Chest.AddChestData(RoomIndex);
                    SetRoom(RoomIndex);
                };
                addButton.Label = "gtk-add";
                addButton.UseStock = true;

                var l = new Gtk.Label("No chest data\nexists for this room.");
                vbox.Add(l);
                var btnAlign = new Alignment(0.5f,0.5f,0.0f,0.2f);
                btnAlign.TopPadding = 3;
                btnAlign.Add(addButton);
                vbox.Add(btnAlign);

                vrEditor = vbox;
            }
            else {

                v1 = new ValueReference("YX", 0, DataValueType.Byte);
                v1.SetData(data);
                data = data.NextData;
                v2 = new ValueReference("Room", 0, DataValueType.Byte, false);
                v2.SetData(data);
                data = data.NextData;
                v3 = new ValueReference("ID1", 0, DataValueType.Byte);
                v3.SetData(data);
                data = data.NextData;
                v4 = new ValueReference("ID2", 0, DataValueType.Byte);
                v4.SetData(data);
                data = data.NextData;

                ValueReferenceGroup vrGroup = new ValueReferenceGroup(new ValueReference[] {v1, v2, v3, v4});

                var vr = new ValueReferenceEditor(
                        Project,
                        vrGroup,
                        "Data");
                vr.SetMaxBound(0, 0xfe); // Max bound for YX

                vr.AddDataModifiedHandler(() => {
                        if (ChestChangedEvent != null)
                            ChestChangedEvent();
                        });

                VBox vbox = new VBox();
                vbox.Add(vr);

                Button delButton = new Button("Remove");
                delButton.Clicked += (a,b) => {
                    Chest.DeleteChestData(RoomIndex);
                    SetRoom(RoomIndex);
                };
                delButton.Label = "gtk-delete";
                delButton.UseStock = true;

                Alignment btnAlign = new Alignment(0.5f,0.5f,0.0f,0.2f);
                btnAlign.TopPadding = 3;
                btnAlign.Add(delButton);
                vbox.Add(btnAlign);

                vrEditor = vbox;
            }

            if (ChestChangedEvent != null)
                ChestChangedEvent();

            vrContainer.Add(vrEditor);
            vrContainer.ShowAll();
        }
示例#10
0
        // Load the i'th warp in the current map.
        void SetWarpIndex(int i)
        {
            List<WarpSourceData> sourceDataList = sourceGroup.GetMapWarpSourceData(map);

            indexSpinButton.Adjustment.Lower = -1;
            indexSpinButton.Adjustment.Upper = sourceDataList.Count-1;

            if (i > indexSpinButton.Adjustment.Upper)
                i = (int)indexSpinButton.Adjustment.Upper;

            indexSpinButton.Value = i;

            valueEditorContainer.Remove(valueEditorContainer.Child);

            if (i == -1) {
                SetDestIndex(-1,-1);
                return;
            }

            Gtk.HBox hbox = new Gtk.HBox();

            WarpSourceData warpSourceData = sourceDataList[i];

            if (warpSourceData.WarpSourceType == WarpSourceType.StandardWarp)
                SetDestIndex(warpSourceData.DestGroup, warpSourceData.DestIndex);

            sourceEditor = new ValueReferenceEditor(Project,
                    warpSourceData);

            Alignment a = new Alignment(0,0,0,0);
            a.Add(sourceEditor);
            hbox.Add(a);

            if (warpSourceData.WarpSourceType == WarpSourceType.PointerWarp) {
                Table table = new Table(1, 1, false);
                table.ColumnSpacing = 6;
                table.RowSpacing = 6;

                SpinButton pointerSpinButton = new SpinButton(0,10,1);

                EventHandler valueChangedHandler = delegate(object sender, EventArgs e) {
                    WarpSourceData pointedData = warpSourceData.GetPointedWarp();

                    pointerSpinButton.Adjustment.Lower = 0;
                    pointerSpinButton.Adjustment.Upper = warpSourceData.GetPointedChainLength()-1;

                    if (pointerSpinButton.ValueAsInt > pointerSpinButton.Adjustment.Upper) {
                        pointerSpinButton.Value = pointerSpinButton.Adjustment.Upper;
                    }
                    int index = pointerSpinButton.ValueAsInt;

                    while (index > 0) {
                        pointedData = pointedData.GetNextWarp();
                        index--;
                    }

                    table.Remove(destEditor);

                    destEditor = new ValueReferenceEditor(Project, pointedData);

                    destEditor.AddDataModifiedHandler(delegate() {
                            SetDestIndex(pointedData.DestGroup, pointedData.DestIndex);
                        });

                    table.Attach(destEditor, 0, 2, 1, 2);

                    SetDestIndex(pointedData.DestGroup, pointedData.DestIndex);
                };

                pointerSpinButton.ValueChanged += valueChangedHandler;

                // Button which, when clicked, adds a new PointedData to the
                // "chain".
                Gtk.Button addPointedWarpButton =
                    new Gtk.Button(new Gtk.Image(Gtk.Stock.Add, Gtk.IconSize.Button));

                addPointedWarpButton.Clicked += delegate(object sender, EventArgs e) {
                    WarpSourceData pointedData = warpSourceData.GetPointedWarp();

                    while (pointedData.GetNextWarp() != null) {
                        pointedData = pointedData.GetNextWarp();
                    }

                    WarpSourceData nextData = new WarpSourceData(Project,
                            WarpSourceData.WarpCommands[(int)WarpSourceType.PointedWarp],
                            WarpSourceData.DefaultValues[(int)WarpSourceType.PointedWarp],
                            pointedData.FileParser,
                            new List<int>{-1});
                    pointedData.SetNextWarp(nextData);

                    pointerSpinButton.Adjustment.Upper++;
                    pointerSpinButton.Value = warpSourceData.GetPointedChainLength()-1;
                    valueChangedHandler(null, null);
                };

                // Button which removes a PointedData from the "chain", unless
                // there is only one remaining.
                Gtk.Button removePointedWarpButton =
                    new Gtk.Button(new Gtk.Image(Gtk.Stock.Remove, Gtk.IconSize.Button));

                removePointedWarpButton.Clicked += delegate(object sender, EventArgs e) {
                    int index = pointerSpinButton.ValueAsInt;
                    WarpSourceData pointedData = warpSourceData.GetPointedWarp();

                    if (pointedData.GetPointedChainLength() <= 1) // Don't delete the last one
                        return;

                    while (index > 0) {
                        pointedData = pointedData.GetNextWarp();
                        index--;
                    }

                    pointedData.FileParser.RemoveFileComponent(pointedData);

                    valueChangedHandler(null, null);
                };

                table.Attach(new Gtk.Label("Pointer index"), 0, 1, 0, 1);
                table.Attach(pointerSpinButton, 1, 2, 0, 1);
                table.Attach(addPointedWarpButton, 2, 3, 0, 1);
                table.Attach(removePointedWarpButton, 3, 4, 0, 1);

                // Invoke handler
                valueChangedHandler(pointerSpinButton, null);

                Frame frame = new Frame(warpSourceData.PointerString);
                frame.Add(table);

                hbox.Add(frame);
            }
            else { // Not pointerWarp
                sourceEditor.AddDataModifiedHandler(delegate() {
                        SetDestIndex(warpSourceData.DestGroup, warpSourceData.DestIndex);
                        });
            }

            valueEditorContainer.Add(hbox);
            valueEditorContainer.ShowAll();
        }
示例#11
0
        void SetDestIndex(int group, int index)
        {
            destGroupSpinButton.Value = group;
            destIndexSpinButton.Value = index;

            destEditorContainer.Remove(destEditorContainer.Child);

            if (group != -1 && group < Project.GetNumGroups())
                destGroup = Project.GetIndexedDataType<WarpDestGroup>(group);

            if (group == -1 || group >= Project.GetNumGroups() ||
                    index == -1 || index >= destGroup.GetNumWarpDests())
            {
                frame2.Hide();
                return;
            }

            WarpDestData destData = destGroup.GetWarpDest(index);
            ValueReferenceEditor editor = new ValueReferenceEditor(Project,destData);

            int numReferences = destData.GetNumReferences();
            if (numReferences == 2)
                destInfoLabel.Text = "Used by " + (numReferences-1) + " other source";
            else
                destInfoLabel.Text = "Used by " + (numReferences-1) + " other sources";

            destEditorContainer.Add(editor);
            destEditorContainer.ShowAll();
            frame2.ShowAll();
        }