mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-13 20:36:19 -05:00
Merge branch 'master' of https://github.com/huderlem/porymap into fix-json
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#ifndef CUSTOMATTRIBUTESTABLE_H
|
||||
#define CUSTOMATTRIBUTESTABLE_H
|
||||
|
||||
#include "event.h"
|
||||
#include "events.h"
|
||||
#include <QObject>
|
||||
#include <QFrame>
|
||||
#include <QTableWidget>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "event.h"
|
||||
#include "events.h"
|
||||
|
||||
class Editor;
|
||||
|
||||
@@ -17,10 +17,10 @@ class DraggablePixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
public:
|
||||
DraggablePixmapItem(QPixmap pixmap): QGraphicsPixmapItem(pixmap) {}
|
||||
|
||||
DraggablePixmapItem(Event *event_, Editor *editor_) : QGraphicsPixmapItem(event_->pixmap) {
|
||||
event = event_;
|
||||
DraggablePixmapItem(Event *event, Editor *editor) : QGraphicsPixmapItem(event->getPixmap()) {
|
||||
this->event = event;
|
||||
event->setPixmapItem(this);
|
||||
editor = editor_;
|
||||
this->editor = editor;
|
||||
updatePosition();
|
||||
}
|
||||
|
||||
@@ -37,8 +37,6 @@ public:
|
||||
void moveTo(const QPoint &pos);
|
||||
void emitPositionChanged();
|
||||
void updatePixmap();
|
||||
void bind(QComboBox *combo, QString key);
|
||||
void bindToUserData(QComboBox *combo, QString key);
|
||||
|
||||
signals:
|
||||
void positionChanged(Event *event);
|
||||
@@ -49,25 +47,18 @@ signals:
|
||||
void onPropertyChanged(QString key, QString value);
|
||||
|
||||
public slots:
|
||||
void set_x(const QString &text) {
|
||||
event->put("x", text);
|
||||
void set_x(int x) {
|
||||
event->setX(x);
|
||||
updatePosition();
|
||||
}
|
||||
void set_y(const QString &text) {
|
||||
event->put("y", text);
|
||||
void set_y(int y) {
|
||||
event->setY(y);
|
||||
updatePosition();
|
||||
}
|
||||
void set_elevation(const QString &text) {
|
||||
event->put("elevation", text);
|
||||
void set_elevation(int z) {
|
||||
event->setElevation(z);
|
||||
updatePosition();
|
||||
}
|
||||
void set_sprite(const QString &text) {
|
||||
event->put("sprite", text);
|
||||
updatePixmap();
|
||||
}
|
||||
void set_script(const QString &text) {
|
||||
event->put("script_label", text);
|
||||
}
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||
|
||||
291
include/ui/eventframes.h
Normal file
291
include/ui/eventframes.h
Normal file
@@ -0,0 +1,291 @@
|
||||
#pragma once
|
||||
#ifndef EVENTRAMES_H
|
||||
#define EVENTRAMES_H
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "noscrollspinbox.h"
|
||||
#include "noscrollcombobox.h"
|
||||
|
||||
#include "events.h"
|
||||
|
||||
|
||||
|
||||
class Project;
|
||||
|
||||
class EventFrame : public QFrame {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EventFrame(Event *event, QWidget *parent = nullptr)
|
||||
: QFrame(parent), event(event) { }
|
||||
|
||||
virtual void setup();
|
||||
void initCustomAttributesTable();
|
||||
virtual void connectSignals();
|
||||
virtual void initialize();
|
||||
virtual void populate(Project *project);
|
||||
|
||||
void invalidateConnections();
|
||||
void invalidateUi();
|
||||
void invalidateValues();
|
||||
|
||||
virtual void setActive(bool active);
|
||||
|
||||
public:
|
||||
QLabel *label_id;
|
||||
|
||||
QVBoxLayout *layout_main;
|
||||
|
||||
QSpinBox *spinner_id;
|
||||
|
||||
NoScrollSpinBox *spinner_x;
|
||||
NoScrollSpinBox *spinner_y;
|
||||
NoScrollSpinBox *spinner_z;
|
||||
QLabel *hideable_label_z;
|
||||
|
||||
QLabel *label_icon;
|
||||
|
||||
QFrame *frame_contents;
|
||||
QVBoxLayout *layout_contents;
|
||||
|
||||
protected:
|
||||
bool populated = false;
|
||||
bool initialized = false;
|
||||
bool connected = false;
|
||||
|
||||
private:
|
||||
Event *event;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class ObjectFrame : public EventFrame {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ObjectFrame(ObjectEvent *object, QWidget *parent = nullptr)
|
||||
: EventFrame(object, parent), object(object) {}
|
||||
|
||||
virtual ~ObjectFrame() {
|
||||
delete this->scriptCompleter;
|
||||
}
|
||||
|
||||
virtual void setup() override;
|
||||
virtual void initialize() override;
|
||||
virtual void connectSignals() override;
|
||||
virtual void populate(Project *project) override;
|
||||
|
||||
public:
|
||||
NoScrollComboBox *combo_sprite;
|
||||
NoScrollComboBox *combo_movement;
|
||||
NoScrollSpinBox *spinner_radius_x;
|
||||
NoScrollSpinBox *spinner_radius_y;
|
||||
NoScrollComboBox *combo_script;
|
||||
QToolButton *button_script;
|
||||
NoScrollComboBox *combo_flag;
|
||||
NoScrollComboBox *combo_trainer_type;
|
||||
NoScrollComboBox *combo_radius_treeid;
|
||||
QCheckBox *check_in_connection;
|
||||
|
||||
private:
|
||||
ObjectEvent *object;
|
||||
|
||||
QCompleter *scriptCompleter = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CloneObjectFrame : public EventFrame {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CloneObjectFrame(CloneObjectEvent *clone, QWidget *parent = nullptr)
|
||||
: EventFrame(clone, parent), clone(clone) {}
|
||||
|
||||
virtual void setup() override;
|
||||
virtual void initialize() override;
|
||||
virtual void connectSignals() override;
|
||||
virtual void populate(Project *project) override;
|
||||
|
||||
public:
|
||||
NoScrollComboBox *combo_sprite;
|
||||
NoScrollSpinBox *spinner_target_id;
|
||||
NoScrollComboBox *combo_target_map;
|
||||
|
||||
private:
|
||||
CloneObjectEvent *clone;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class WarpFrame : public EventFrame {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WarpFrame(WarpEvent *warp, QWidget *parent = nullptr)
|
||||
: EventFrame(warp, parent), warp(warp) {}
|
||||
|
||||
virtual void setup() override;
|
||||
virtual void initialize() override;
|
||||
virtual void connectSignals() override;
|
||||
virtual void populate(Project *project) override;
|
||||
|
||||
public:
|
||||
NoScrollComboBox *combo_dest_map;
|
||||
NoScrollSpinBox *spinner_dest_warp;
|
||||
|
||||
private:
|
||||
WarpEvent *warp;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class TriggerFrame : public EventFrame {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TriggerFrame(TriggerEvent *trigger, QWidget *parent = nullptr)
|
||||
: EventFrame(trigger, parent), trigger(trigger) {}
|
||||
|
||||
virtual ~TriggerFrame() {
|
||||
delete this->scriptCompleter;
|
||||
}
|
||||
|
||||
virtual void setup() override;
|
||||
virtual void initialize() override;
|
||||
virtual void connectSignals() override;
|
||||
virtual void populate(Project *project) override;
|
||||
|
||||
public:
|
||||
NoScrollComboBox *combo_script;
|
||||
NoScrollComboBox *combo_var;
|
||||
NoScrollComboBox *combo_var_value;
|
||||
|
||||
private:
|
||||
TriggerEvent *trigger;
|
||||
|
||||
QCompleter *scriptCompleter = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class WeatherTriggerFrame : public EventFrame {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WeatherTriggerFrame(WeatherTriggerEvent *weatherTrigger, QWidget *parent = nullptr)
|
||||
: EventFrame(weatherTrigger, parent), weatherTrigger(weatherTrigger) {}
|
||||
|
||||
virtual void setup() override;
|
||||
virtual void initialize() override;
|
||||
virtual void connectSignals() override;
|
||||
virtual void populate(Project *project) override;
|
||||
|
||||
public:
|
||||
NoScrollComboBox *combo_weather;
|
||||
|
||||
private:
|
||||
WeatherTriggerEvent *weatherTrigger;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class SignFrame : public EventFrame {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SignFrame(SignEvent *sign, QWidget *parent = nullptr)
|
||||
: EventFrame(sign, parent), sign(sign) {}
|
||||
|
||||
virtual ~SignFrame() {
|
||||
delete this->scriptCompleter;
|
||||
}
|
||||
|
||||
virtual void setup() override;
|
||||
virtual void initialize() override;
|
||||
virtual void connectSignals() override;
|
||||
virtual void populate(Project *project) override;
|
||||
|
||||
public:
|
||||
NoScrollComboBox *combo_facing_dir;
|
||||
NoScrollComboBox *combo_script;
|
||||
|
||||
private:
|
||||
SignEvent *sign;
|
||||
|
||||
QCompleter *scriptCompleter = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class HiddenItemFrame : public EventFrame {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HiddenItemFrame(HiddenItemEvent *hiddenItem, QWidget *parent = nullptr)
|
||||
: EventFrame(hiddenItem, parent), hiddenItem(hiddenItem) {}
|
||||
|
||||
virtual void setup() override;
|
||||
virtual void initialize() override;
|
||||
virtual void connectSignals() override;
|
||||
virtual void populate(Project *project) override;
|
||||
|
||||
public:
|
||||
QFrame *hideable_quantity;
|
||||
QFrame *hideable_itemfinder;
|
||||
NoScrollComboBox *combo_item;
|
||||
NoScrollComboBox *combo_flag;
|
||||
NoScrollSpinBox *spinner_quantity;
|
||||
QCheckBox *check_itemfinder;
|
||||
|
||||
private:
|
||||
HiddenItemEvent *hiddenItem;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class SecretBaseFrame : public EventFrame {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SecretBaseFrame(SecretBaseEvent *secretBase, QWidget *parent = nullptr)
|
||||
: EventFrame(secretBase, parent), secretBase(secretBase) {}
|
||||
|
||||
virtual void setup() override;
|
||||
virtual void initialize() override;
|
||||
virtual void connectSignals() override;
|
||||
virtual void populate(Project *project) override;
|
||||
|
||||
public:
|
||||
NoScrollComboBox *combo_base_id;
|
||||
|
||||
private:
|
||||
SecretBaseEvent *secretBase;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class HealLocationFrame : public EventFrame {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HealLocationFrame(HealLocationEvent *healLocation, QWidget *parent = nullptr)
|
||||
: EventFrame(healLocation, parent), healLocation(healLocation) {}
|
||||
|
||||
virtual void setup() override;
|
||||
virtual void initialize() override;
|
||||
virtual void connectSignals() override;
|
||||
virtual void populate(Project *project) override;
|
||||
|
||||
public:
|
||||
QFrame *hideable_respawn_map;
|
||||
QFrame *hideable_respawn_npc;
|
||||
NoScrollComboBox *combo_respawn_map;
|
||||
NoScrollSpinBox *spinner_respawn_npc;
|
||||
|
||||
private:
|
||||
HealLocationEvent *healLocation;
|
||||
};
|
||||
|
||||
#endif // EVENTRAMES_H
|
||||
@@ -1,29 +0,0 @@
|
||||
#ifndef EVENTPROPERTIESFRAME_H
|
||||
#define EVENTPROPERTIESFRAME_H
|
||||
|
||||
#include "event.h"
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
namespace Ui {
|
||||
class EventPropertiesFrame;
|
||||
}
|
||||
|
||||
class EventPropertiesFrame : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EventPropertiesFrame(Event *event, QWidget *parent = nullptr);
|
||||
~EventPropertiesFrame();
|
||||
void paintEvent(QPaintEvent*);
|
||||
|
||||
public:
|
||||
Ui::EventPropertiesFrame *ui;
|
||||
|
||||
private:
|
||||
Event *event;
|
||||
bool firstShow = true;
|
||||
};
|
||||
|
||||
#endif // EVENTPROPERTIESFRAME_H
|
||||
@@ -44,9 +44,21 @@ public:
|
||||
Q_INVOKABLE int getOpacity(int layer = 0);
|
||||
Q_INVOKABLE void setOpacity(int opacity, int layer);
|
||||
Q_INVOKABLE void setOpacity(int opacity);
|
||||
Q_INVOKABLE qreal getHorizontalScale(int layer = 0);
|
||||
Q_INVOKABLE qreal getVerticalScale(int layer = 0);
|
||||
Q_INVOKABLE void setHorizontalScale(qreal scale, int layer);
|
||||
Q_INVOKABLE void setHorizontalScale(qreal scale);
|
||||
Q_INVOKABLE void setVerticalScale(qreal scale, int layer);
|
||||
Q_INVOKABLE void setVerticalScale(qreal scale);
|
||||
Q_INVOKABLE int getRotation(int layer = 0);
|
||||
Q_INVOKABLE void setRotation(int angle, int layer);
|
||||
Q_INVOKABLE void setRotation(int angle);
|
||||
Q_INVOKABLE void rotate(int degrees, int layer);
|
||||
Q_INVOKABLE void rotate(int degrees);
|
||||
Q_INVOKABLE void addText(QString text, int x, int y, QString color = "#000000", int fontSize = 12, int layer = 0);
|
||||
Q_INVOKABLE void addRect(int x, int y, int width, int height, QString color = "#000000", int layer = 0);
|
||||
Q_INVOKABLE void addFilledRect(int x, int y, int width, int height, QString color = "#000000", int layer = 0);
|
||||
Q_INVOKABLE void addRect(int x, int y, int width, int height, QString borderColor = "#000000", QString fillColor = "transparent", int rounding = 0, int layer = 0);
|
||||
Q_INVOKABLE void addPath(QList<QList<int>> coords, QString borderColor = "#000000", QString fillColor = "transparent", int layer = 0);
|
||||
Q_INVOKABLE void addPath(QList<int> xCoords, QList<int> yCoords, QString borderColor = "#000000", QString fillColor = "transparent", int layer = 0);
|
||||
Q_INVOKABLE void addImage(int x, int y, QString filepath, int layer = 0, bool useCache = true);
|
||||
Q_INVOKABLE void createImage(int x, int y, QString filepath,
|
||||
int width = -1, int height = -1, int xOffset = 0, int yOffset = 0,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef NEWEVENTTOOLBUTTON_H
|
||||
#define NEWEVENTTOOLBUTTON_H
|
||||
|
||||
#include "event.h"
|
||||
#include "events.h"
|
||||
#include <QToolButton>
|
||||
|
||||
class NewEventToolButton : public QToolButton
|
||||
@@ -9,7 +9,7 @@ class NewEventToolButton : public QToolButton
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NewEventToolButton(QWidget *parent = nullptr);
|
||||
QString getSelectedEventType();
|
||||
Event::Type getSelectedEventType();
|
||||
QAction *newObjectAction;
|
||||
QAction *newCloneObjectAction;
|
||||
QAction *newWarpAction;
|
||||
@@ -30,9 +30,9 @@ public slots:
|
||||
void newHiddenItem();
|
||||
void newSecretBase();
|
||||
signals:
|
||||
void newEventAdded(QString);
|
||||
void newEventAdded(Event::Type);
|
||||
private:
|
||||
QString selectedEventType;
|
||||
Event::Type selectedEventType;
|
||||
void init();
|
||||
};
|
||||
|
||||
|
||||
@@ -6,12 +6,13 @@
|
||||
#include <QColor>
|
||||
#include <QPainter>
|
||||
#include <QStaticText>
|
||||
#include <QPainterPath>
|
||||
|
||||
class OverlayItem {
|
||||
public:
|
||||
OverlayItem() {}
|
||||
virtual ~OverlayItem() {};
|
||||
virtual void render(QPainter *, int, int) {};
|
||||
virtual void render(QPainter *) {};
|
||||
};
|
||||
|
||||
class OverlayText : public OverlayItem {
|
||||
@@ -25,7 +26,7 @@ public:
|
||||
this->fontSize = fontSize;
|
||||
}
|
||||
~OverlayText() {}
|
||||
virtual void render(QPainter *painter, int x, int y);
|
||||
virtual void render(QPainter *painter);
|
||||
private:
|
||||
const QStaticText text;
|
||||
int x;
|
||||
@@ -34,25 +35,19 @@ private:
|
||||
int fontSize;
|
||||
};
|
||||
|
||||
class OverlayRect : public OverlayItem {
|
||||
class OverlayPath : public OverlayItem {
|
||||
public:
|
||||
OverlayRect(int x, int y, int width, int height, QColor color, bool filled) {
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
this->color = color;
|
||||
this->filled = filled;
|
||||
OverlayPath(QPainterPath path, QColor borderColor, QColor fillColor) {
|
||||
this->path = path;
|
||||
this->borderColor = borderColor;
|
||||
this->fillColor = fillColor;
|
||||
}
|
||||
~OverlayRect() {}
|
||||
virtual void render(QPainter *painter, int x, int y);
|
||||
~OverlayPath() {}
|
||||
virtual void render(QPainter *painter);
|
||||
private:
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
QColor color;
|
||||
bool filled;
|
||||
QPainterPath path;
|
||||
QColor borderColor;
|
||||
QColor fillColor;
|
||||
};
|
||||
|
||||
class OverlayImage : public OverlayItem {
|
||||
@@ -63,7 +58,7 @@ public:
|
||||
this->image = image;
|
||||
}
|
||||
~OverlayImage() {}
|
||||
virtual void render(QPainter *painter, int x, int y);
|
||||
virtual void render(QPainter *painter);
|
||||
private:
|
||||
int x;
|
||||
int y;
|
||||
@@ -76,6 +71,9 @@ public:
|
||||
Overlay() {
|
||||
this->x = 0;
|
||||
this->y = 0;
|
||||
this->angle = 0;
|
||||
this->hScale = 1.0;
|
||||
this->vScale = 1.0;
|
||||
this->hidden = false;
|
||||
this->opacity = 1.0;
|
||||
this->clippingRect = nullptr;
|
||||
@@ -91,6 +89,13 @@ public:
|
||||
int getY();
|
||||
void setX(int x);
|
||||
void setY(int y);
|
||||
qreal getHScale();
|
||||
qreal getVScale();
|
||||
void setHScale(qreal scale);
|
||||
void setVScale(qreal scale);
|
||||
int getRotation();
|
||||
void setRotation(int angle);
|
||||
void rotate(int degrees);
|
||||
void setClippingRect(QRectF rect);
|
||||
void clearClippingRect();
|
||||
void setPosition(int x, int y);
|
||||
@@ -98,14 +103,20 @@ public:
|
||||
void renderItems(QPainter *painter);
|
||||
QList<OverlayItem*> getItems();
|
||||
void clearItems();
|
||||
void addText(const QString text, int x, int y, QString color = "#000000", int fontSize = 12);
|
||||
void addRect(int x, int y, int width, int height, QString color = "#000000", bool filled = false);
|
||||
void addText(const QString text, int x, int y, QString colorStr, int fontSize);
|
||||
bool addRect(int x, int y, int width, int height, QString borderColorStr, QString fillColorStr, int rounding);
|
||||
bool addImage(int x, int y, QString filepath, bool useCache = true, int width = -1, int height = -1, int xOffset = 0, int yOffset = 0, qreal hScale = 1, qreal vScale = 1, QList<QRgb> palette = QList<QRgb>(), bool setTransparency = false);
|
||||
bool addImage(int x, int y, QImage image);
|
||||
bool addPath(QList<int> xCoords, QList<int> yCoords, QString borderColorStr, QString fillColorStr);
|
||||
private:
|
||||
void clampAngle();
|
||||
QColor getColor(QString colorStr);
|
||||
QList<OverlayItem*> items;
|
||||
int x;
|
||||
int y;
|
||||
int angle;
|
||||
qreal hScale;
|
||||
qreal vScale;
|
||||
bool hidden;
|
||||
qreal opacity;
|
||||
QRectF *clippingRect;
|
||||
|
||||
Reference in New Issue
Block a user