Exemple #1
0
        // Check if there are entries that should have help buttons
        public void UpdateHelpButtons()
        {
            IList <ValueReference> refs = valueReferenceGroup.GetValueReferences();

            for (int i = 0; i < refs.Count; i++)
            {
                Gtk.Container container = helpButtonContainers[i];
                if (container == null)
                {
                    continue;
                }

                // Remove previous help button
                foreach (Gtk.Widget widget in container.Children)
                {
                    container.Remove(widget);
                    widget.Destroy();
                }

                ValueReference r = refs[i];
                if (r.Documentation != null)
                {
                    Gtk.Button helpButton = new Gtk.Button("?");
                    helpButton.CanFocus = false;
                    helpButton.Clicked += delegate(object sender, EventArgs e) {
                        DocumentationDialog d = new DocumentationDialog(r.Documentation);
                    };
                    container.Add(helpButton);
                }
            }
            this.ShowAll();
        }
 public ValueReferenceGroup(IList <ValueReference> refs)
 {
     valueReferences = new List <ValueReference>();
     foreach (var vref in refs)
     {
         ValueReference copy =
             (ValueReference)Activator.CreateInstance(vref.GetType(), new object[] { vref });
         valueReferences.Add(copy);
     }
 }
Exemple #3
0
        public string GetValue(string s)   // Get a value based on a value reference name
        {
            ValueReference r = GetValueReference(s);

            if (r == null)
            {
                ThrowException(new InvalidLookupException("Couldn't find ValueReference corresponding to \"" + s + "\"."));
            }
            return(r.GetStringValue());
        }
 public ValueReference(ValueReference r)
 {
     data                   = r.data;
     valueIndex             = r.valueIndex;
     ValueType              = r.ValueType;
     Name                   = r.Name;
     startBit               = r.startBit;
     endBit                 = r.endBit;
     Editable               = r.Editable;
     constantsMappingString = r.constantsMappingString;
     constantsMapping       = r.constantsMapping;
 }
        // Check if there are entries that should have help buttons
        public void UpdateHelpButtons()
        {
            IList <ValueReference> refs = valueReferenceGroup.GetValueReferences();

            for (int i = 0; i < refs.Count; i++)
            {
                if (widgetLists[i][1] is ComboBoxFromConstants) // These deal with documentation themselves
                {
                    continue;
                }

                Gtk.Container container = widgetLists[i][2] as Gtk.Container;
                if (container == null)
                {
                    continue;
                }

                bool isHelpButton = true;

                // Remove previous help button
                foreach (Gtk.Widget widget in container.Children)
                {
                    // Really hacky way to check whether this is the help button as we expect, or
                    // whether the "AddWidgetToRight" function was called to replace it, in which
                    // case we don't try to add the help button at all
                    if (!(widget is Gtk.Button && (widget as Gtk.Button).Label == "?"))
                    {
                        isHelpButton = false;
                        continue;
                    }
                    container.Remove(widget);
                    widget.Dispose();
                }

                if (!isHelpButton)
                {
                    continue;
                }

                ValueReference r = refs[i];
                if (r.Documentation != null)
                {
                    Gtk.Button helpButton = new Gtk.Button("?");
                    helpButton.FocusOnClick = false;
                    helpButton.Clicked     += delegate(object sender, EventArgs e) {
                        DocumentationDialog d = new DocumentationDialog(r.Documentation);
                    };
                    container.Add(helpButton);
                }
            }
            this.ShowAll();
        }
Exemple #6
0
        public int GetIntValue(string s)
        {
            ValueReference r = GetValueReference(s);

            if (r == null)
            {
                throw new InvalidLookupException("Couldn't find ValueReference corresponding to \"" + s + "\".");
            }
            else
            {
                return(r.GetIntValue());
            }
        }
Exemple #7
0
        // Adds a new WarpDestData to the end of the group, returns the index
        public WarpDestData AddDestData()
        {
            WarpDestData newData = new WarpDestData(Project,
                                                    WarpDestData.WarpCommand,
                                                    null,
                                                    fileParser, new List <int> {
                -1
            });

            ValueReference.InitializeDataValues(newData, newData.GetValueReferences());

            newData.Transition = 1;

            newData.DestGroup = this;
            newData.DestIndex = warpDestDataList.Count;

            fileParser.InsertComponentAfter(warpDestDataList[warpDestDataList.Count - 1], newData);
            warpDestDataList.Add(newData);

            return(newData);
        }
Exemple #8
0
        public void InsertObject(int index, ObjectType type)
        {
            if (GetNumObjects() == 0 && !IsIsolated())
            {
                // If this map is sharing data with other maps (as when "blank"), need to make
                // a unique section for this map.

                parser.RemoveLabel(Identifier);

                parser.InsertParseableTextAfter(null, new String[] { "" }); // Newline
                parser.InsertComponentAfter(null, new Label(parser, Identifier));

                ObjectData endData = new ObjectData(Project,
                                                    ObjectCommands[(int)ObjectType.End],
                                                    null,
                                                    parser,
                                                    new string[] { "\t" }, // Tab at start of line
                                                    ObjectType.End);
                parser.InsertComponentAfter(null, endData);
                objectDataList[0] = endData;
            }

            ObjectData data = new ObjectData(Project,
                                             ObjectCommands[(int)type],
                                             null,
                                             parser,
                                             new string[] { "\t" }, // Tab at start of line
                                             type);

            ValueReference.InitializeDataValues(data, data.GetValueReferences());

            if (type >= ObjectType.Pointer && type <= ObjectType.AntiBossPointer)
            {
                data.SetValue(0, "objectData4000"); // Compileable default pointer
            }
            data.InsertIntoParserBefore(objectDataList[index]);
            objectDataList.Insert(index, data);
        }
Exemple #9
0
        void UpdatePointerTextBox(Gtk.Entry entry, ValueReference r)
        {
            pointerFrame.Remove(pointerFrame.Child);

            subEditor = new ObjectGroupEditor();
            Gtk.Alignment alignment = new Gtk.Alignment(0.5F, 0.5F, 0.0F, 0.8F);
            try {
                Project.GetFileWithLabel(entry.Text.Trim());
                subEditor.SetObjectGroup(Project.GetDataType <ObjectGroup>(r.GetStringValue()));
                subEditor.ShowAll();
                alignment.Add(subEditor);
                r.SetValue(entry.Text.Trim());
            }
            catch (InvalidLookupException) {
                subEditor.SetObjectGroup(null);
                Gtk.Label label = new Gtk.Label("Error: label \"" + entry.Text + "\" not found.");
                label.Show();
                alignment.Add(label);
            }
            pointerFrame.Label = entry.Text;
            pointerFrame.Add(alignment);
            pointerFrame.ShowAll();
        }
Exemple #10
0
 public void SetTooltip(ValueReference r, string tooltip)
 {
     SetTooltip(valueReferenceGroup.GetIndexOf(r), tooltip);
 }
        void UpdatePointerTextBox(Gtk.Entry entry, ValueReference r)
        {
            pointerFrame.Remove(pointerFrame.Child);

            subEditor = new ObjectGroupEditor();
            Gtk.Alignment alignment = new Gtk.Alignment(0.5F, 0.5F, 0.0F, 0.8F);
            try {
                Project.GetFileWithLabel(entry.Text.Trim());
                subEditor.SetObjectGroup(Project.GetDataType<ObjectGroup>(r.GetStringValue()));
                subEditor.ShowAll();
                alignment.Add(subEditor);
                r.SetValue(entry.Text.Trim());
            }
            catch (LabelNotFoundException) {
                subEditor.SetObjectGroup(null);
                Gtk.Label label = new Gtk.Label("Error: label \"" + entry.Text + "\" not found.");
                label.Show();
                alignment.Add(label);
            }
            pointerFrame.Label = entry.Text;
            pointerFrame.Add(alignment);
            pointerFrame.ShowAll();
        }
 // This function might not work because it's making copies of the
 // ValueReferences passed to it in the constructor?
 public int GetIndexOf(ValueReference r)
 {
     return(valueReferences.IndexOf(r));
 }
Exemple #13
0
 public ValueReference(ValueReference r)
 {
     data = r.data;
     valueIndex = r.valueIndex;
     ValueType = r.ValueType;
     Name = r.Name;
     startBit = r.startBit;
     endBit = r.endBit;
     Editable = r.Editable;
     constantsMappingString = r.constantsMappingString;
     constantsMapping = r.constantsMapping;
 }
Exemple #14
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();
        }
Exemple #15
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();
        }
 // This function might not work because it's making copies of the
 // ValueReferences passed to it in the constructor?
 public int GetIndexOf(ValueReference r)
 {
     return valueReferences.IndexOf(r);
 }