HasXY() public method

public HasXY ( ) : bool
return bool
Beispiel #1
0
        void OnDragged(int x, int y)
        {
            if (!ViewObjects)
            {
                OnClicked(x, y);
            }
            else
            {
                if (!draggingObject)
                {
                    return;
                }

                ObjectData data = objectEditor.SelectedObjectData;
                if (data != null && data.HasXY())
                {
                    int newX, newY;
                    if (gdkState.HasFlag(Gdk.ModifierType.ControlMask) || data.HasShortenedXY())
                    {
                        newX = x - XOffset;
                        newY = y - XOffset;
                    }
                    else
                    {
                        // Move objects in increments of 8 pixels
                        int unit    = 8;
                        int unitLog = (int)Math.Log(unit, 2);

                        int dataX  = data.GetX() + unit / 2;
                        int dataY  = data.GetY() + unit / 2;
                        int alignX = (dataX) % unit;
                        int alignY = (dataY) % unit;
                        newX = (x - XOffset - alignX) >> unitLog;
                        newY = (y - YOffset - alignY) >> unitLog;
                        newX = newX * unit + alignX + unit / 2;
                        newY = newY * unit + alignY + unit / 2;
                    }

                    if (newX >= 0 && newX < 256 && newY >= 0 && newY < 256)
                    {
                        data.SetX((byte)newX);
                        data.SetY((byte)newY);
                    }

                    QueueDraw();
                }
            }
        }
Beispiel #2
0
        void OnDragged(int x, int y)
        {
            if (!ViewObjects)
            {
                OnClicked(x, y);
            }
            else
            {
                if (!IsInBounds(x, y))
                {
                    return;
                }
                if (!draggingObject)
                {
                    return;
                }

                ObjectData data = objectEditor.SelectedObjectData;
                if (data != null && data.HasXY())
                {
                    // Move objects in increments of 16 pixels
                    int dataX  = data.GetX() + 8;
                    int dataY  = data.GetY() + 8;
                    int alignX = (dataX) % 16;
                    int alignY = (dataY) % 16;
                    int newX   = (x - alignX) / 16;
                    int newY   = (y - alignY) / 16;
                    newX = (newX * 16 + alignX + 8) % 256;
                    newY = (newY * 16 + alignY + 8) % 256;

                    data.SetX(newX);
                    data.SetY(newY);

                    QueueDraw();
                }
            }
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }