GetObjectType() public méthode

public GetObjectType ( ) : ObjectType
Résultat ObjectType
Exemple #1
0
        internal ObjectGroup(Project p, String id) : base(p, id)
        {
            parser = Project.GetFileWithLabel(Identifier);
            ObjectData data = parser.GetData(Identifier) as ObjectData;

            while (data.GetObjectType() != ObjectType.End && data.GetObjectType() != ObjectType.EndPointer)
            {
                objectDataList.Add(data);
                data = data.NextData as ObjectData;
            }
            objectDataList.Add(data);
        }
        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();
        }
Exemple #3
0
        void Shorten()
        {
            // Shortens the object if possible
            if (IsShortened() || !IsShortenable())
            {
                return;
            }

            ObjectData last = LastData as ObjectData;

            if (last == null || last.GetObjectType() != GetObjectType())
            {
                return;
            }
            if (last.GetValue(0) != GetValue(0))
            {
                return;
            }

            RemoveValue(0);
            SetSpacing(1, 5);
        }
Exemple #4
0
        // Same as base.GetValue except this keeps track of values "carried
        // over" from the last object, for SpecificEnemy and ItemDrop
        // objects.
        public override string GetValue(int i)
        {
            if (IsShortened())
            {
                ObjectData last = LastData as ObjectData;

                if (last == null || (last.GetObjectType() != GetObjectType()))
                {
                    this.ThrowException(new Exception("Malformatted object"));
                }

                if (i == 0)
                {
                    return((LastData as ObjectData).GetValue(0));
                }
                else
                {
                    return(base.GetValue(i - 1));
                }
            }

            return(base.GetValue(i));
        }
Exemple #5
0
 public override void SetValue(int i, string value)
 {
     if (IsShortened())
     {
         if (i == 0)
         {
             Elongate();
         }
         else
         {
             i--;
         }
     }
     if (IsShortenable())
     {
         // Check if the next object depends on this
         ObjectData next = NextData as ObjectData;
         if (next != null && next.GetObjectType() == GetObjectType())
         {
             next.Elongate();
         }
     }
     base.SetValue(i, value);
 }
Exemple #6
0
        int DrawObjectGroup(Graphics g, int index, ref int cursorX, ref int cursorY, ref int selectedX, ref int selectedY, ObjectGroup group, ObjectGroupEditor editor, ref List <int> objectIndices)
        {
            if (group == null)
            {
                return(index);
            }

            List <int> localObjectIndices = new List <int>(objectIndices);

            bool foundHoveringMatch = false;

            for (int i = 0; i < group.GetNumObjects(); i++)
            {
                ObjectData data = group.GetObjectData(i);
                if (data.GetObjectType() >= ObjectType.Pointer &&
                    data.GetObjectType() <= ObjectType.AntiBossPointer)
                {
                    ObjectGroup nextGroup = data.GetPointedObjectGroup();
                    if (nextGroup != null)
                    {
                        List <int> pointerObjectIndices = new List <int>(objectIndices);
                        pointerObjectIndices.Add(i);
                        if (editor != null && i == editor.SelectedIndex)
                        {
                            index = DrawObjectGroup(g, index, ref cursorX, ref cursorY,
                                                    ref selectedX, ref selectedY, nextGroup, editor.SubEditor, ref pointerObjectIndices);
                        }
                        else
                        {
                            index = DrawObjectGroup(g, index, ref cursorX, ref cursorY,
                                                    ref selectedX, ref selectedY, nextGroup, null, ref pointerObjectIndices);
                        }
                        if (pointerObjectIndices.Count > objectIndices.Count + 1)
                        {
                            localObjectIndices = pointerObjectIndices;
                        }
                    }
                }
                else
                {
                    Color color = data.GetColor();
                    int   x, y;
                    int   width;
                    if (data.HasXY())
                    {
                        x     = data.GetX();
                        y     = data.GetY();
                        width = 16;
                        // Objects with specific positions get
                        // transparency
                        color = Color.FromArgb(0xd0, color.R, color.G, color.B);
                    }
                    else
                    {
                        // No X/Y values exist
                        x = index;
                        y = 0;
                        while (x >= 0xf)
                        {
                            x -= 0xf;
                            y++;
                        }
                        x    *= 16;
                        y    *= 16;
                        x    += 8;
                        y    += 8;
                        width = 8;
                        index++;
                    }

                    if (editor != null && i == editor.SelectedIndex)
                    {
                        selectedX = x - 8;
                        selectedY = y - 8;
                    }
                    if (mouseX >= x - 8 && mouseX < x + 8 &&
                        mouseY >= y - 8 && mouseY < y + 8)
                    {
                        if (localObjectIndices.Count == objectIndices.Count)
                        {
                            if (foundHoveringMatch)
                            {
                                localObjectIndices[localObjectIndices.Count - 1] = i;
                            }
                            else
                            {
                                localObjectIndices.Add(i);
                            }
                            cursorX            = x - 8;
                            cursorY            = y - 8;
                            foundHoveringMatch = true;
                        }
                    }

                    x -= width / 2;
                    y -= width / 2;


                    g.FillRectangle(new SolidBrush(color), x, y, width, width);
                }
            }

            objectIndices = localObjectIndices;
            return(index);
        }
Exemple #7
0
        int DrawObjectGroup(Graphics g, int index, ref int cursorX, ref int cursorY, ref int selectedX, ref int selectedY, ObjectGroup group, ObjectGroupEditor editor, ref List <int> objectIndices)
        {
            if (group == null)
            {
                return(index);
            }

            List <int> localObjectIndices = new List <int>(objectIndices);

            bool foundHoveringMatch = false;

            for (int i = 0; i < group.GetNumObjects(); i++)
            {
                ObjectData data = group.GetObjectData(i);
                if (data.GetObjectType() >= ObjectType.Pointer &&
                    data.GetObjectType() <= ObjectType.AntiBossPointer)
                {
                    ObjectGroup nextGroup = data.GetPointedObjectGroup();
                    if (nextGroup != null)
                    {
                        List <int> pointerObjectIndices = new List <int>(objectIndices);
                        pointerObjectIndices.Add(i);
                        if (editor != null && i == editor.SelectedIndex)
                        {
                            index = DrawObjectGroup(g, index, ref cursorX, ref cursorY,
                                                    ref selectedX, ref selectedY, nextGroup, editor.SubEditor, ref pointerObjectIndices);
                        }
                        else
                        {
                            index = DrawObjectGroup(g, index, ref cursorX, ref cursorY,
                                                    ref selectedX, ref selectedY, nextGroup, null, ref pointerObjectIndices);
                        }
                        if (pointerObjectIndices.Count > objectIndices.Count + 1)
                        {
                            localObjectIndices = pointerObjectIndices;
                        }
                    }
                }
                else
                {
                    Color color = data.GetColor();
                    int   x, y;
                    int   width;
                    if (data.HasXY())
                    {
                        x     = data.GetX();
                        y     = data.GetY();
                        width = 16;
                        // Objects with specific positions get
                        // transparency
                        color = Color.FromArgb(0xd0, color.R, color.G, color.B);
                    }
                    else
                    {
                        // No X/Y values exist
                        x = index;
                        y = 0;
                        while (x >= 0xf)
                        {
                            x -= 0xf;
                            y++;
                        }
                        x    *= 16;
                        y    *= 16;
                        x    += 8;
                        y    += 8;
                        width = 8;
                        index++;
                    }

                    if (editor != null && i == editor.SelectedIndex)
                    {
                        selectedX = x - 8 + XOffset;
                        selectedY = y - 8 + YOffset;
                    }
                    if (mouseX - XOffset >= x - 8 && mouseX - XOffset < x + 8 &&
                        mouseY - YOffset >= y - 8 && mouseY - YOffset < y + 8)
                    {
                        if (localObjectIndices.Count == objectIndices.Count)
                        {
                            if (foundHoveringMatch)
                            {
                                localObjectIndices[localObjectIndices.Count - 1] = i;
                            }
                            else
                            {
                                localObjectIndices.Add(i);
                            }
                            cursorX            = x - 8 + XOffset;
                            cursorY            = y - 8 + YOffset;
                            foundHoveringMatch = true;
                        }
                    }

                    // x and y are the center coordinates for the object

                    if (ViewObjectBoxes)
                    {
                        g.FillRectangle(new SolidBrush(color), x - width / 2 + XOffset, y - width / 2 + YOffset, width, width);
                    }

                    if (data.GetGameObject() != null)
                    {
                        try {
                            ObjectAnimationFrame o = data.GetGameObject().DefaultAnimation.GetFrame(0);
                            o.Draw(g, x + XOffset, y + YOffset);
                        }
                        catch (NoAnimationException) {
                            // No animation defined
                        }
                        catch (InvalidAnimationException) {
                            // Error parsing an animation; draw a blue X to indicate the error
                            int xPos = x - width / 2 + XOffset;
                            int yPos = y - width / 2 + YOffset;
                            g.DrawLine(new Pen(Color.Blue), xPos, yPos, xPos + width - 1, yPos + width - 1);
                            g.DrawLine(new Pen(Color.Blue), xPos + width - 1, yPos, xPos, yPos + width - 1);
                        }
                    }
                }
            }

            objectIndices = localObjectIndices;
            return(index);
        }