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(); }
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(); } }