mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-11 10:25:43 -05:00
Merge pull request #543 from GriffinRichards/options
Add Project Settings Editor
This commit is contained in:
61
include/ui/customscriptseditor.h
Normal file
61
include/ui/customscriptseditor.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef CUSTOMSCRIPTSEDITOR_H
|
||||
#define CUSTOMSCRIPTSEDITOR_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QListWidget>
|
||||
#include <QAbstractButton>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "customscriptslistitem.h"
|
||||
|
||||
namespace Ui {
|
||||
class CustomScriptsEditor;
|
||||
}
|
||||
|
||||
|
||||
class CustomScriptsEditor : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CustomScriptsEditor(QWidget *parent = nullptr);
|
||||
~CustomScriptsEditor();
|
||||
|
||||
signals:
|
||||
void reloadScriptEngine();
|
||||
|
||||
public slots:
|
||||
void applyUserShortcuts();
|
||||
|
||||
private:
|
||||
Ui::CustomScriptsEditor *ui;
|
||||
|
||||
bool hasUnsavedChanges = false;
|
||||
QString importDir;
|
||||
const QString baseDir;
|
||||
|
||||
void displayScript(const QString &filepath, bool enabled);
|
||||
QString chooseScript(QString dir);
|
||||
void removeScript(QListWidgetItem * item);
|
||||
void replaceScript(QListWidgetItem * item);
|
||||
void openScript(QListWidgetItem * item);
|
||||
QString getScriptFilepath(QListWidgetItem * item, bool absolutePath = true) const;
|
||||
void setScriptFilepath(QListWidgetItem * item, QString filepath) const;
|
||||
bool getScriptEnabled(QListWidgetItem * item) const;
|
||||
void markEdited();
|
||||
int prompt(const QString &text, QMessageBox::StandardButton defaultButton);
|
||||
void save();
|
||||
void closeEvent(QCloseEvent*);
|
||||
void restoreWindowState();
|
||||
void initShortcuts();
|
||||
QObjectList shortcutableObjects() const;
|
||||
|
||||
private slots:
|
||||
void dialogButtonClicked(QAbstractButton *button);
|
||||
void addNewScript();
|
||||
void reloadScripts();
|
||||
void removeSelectedScripts();
|
||||
void openSelectedScripts();
|
||||
};
|
||||
|
||||
#endif // CUSTOMSCRIPTSEDITOR_H
|
||||
22
include/ui/customscriptslistitem.h
Normal file
22
include/ui/customscriptslistitem.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef CUSTOMSCRIPTSLISTITEM_H
|
||||
#define CUSTOMSCRIPTSLISTITEM_H
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
namespace Ui {
|
||||
class CustomScriptsListItem;
|
||||
}
|
||||
|
||||
class CustomScriptsListItem : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CustomScriptsListItem(QWidget *parent = nullptr);
|
||||
~CustomScriptsListItem();
|
||||
|
||||
public:
|
||||
Ui::CustomScriptsListItem *ui;
|
||||
};
|
||||
|
||||
#endif // CUSTOMSCRIPTSLISTITEM_H
|
||||
@@ -11,8 +11,10 @@ public:
|
||||
explicit NoScrollComboBox(QWidget *parent = nullptr);
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
void setTextItem(const QString &text);
|
||||
void setNumberItem(int value);
|
||||
|
||||
private:
|
||||
void setItem(int index, const QString &text);
|
||||
};
|
||||
|
||||
#endif // NOSCROLLCOMBOBOX_H
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
void initPrefabUI(MetatileSelector *selector, QWidget *prefabWidget, QLabel *emptyPrefabLabel, Map *map);
|
||||
void addPrefab(MetatileSelection selection, Map *map, QString name);
|
||||
void updatePrefabUi(Map *map);
|
||||
void tryImportDefaultPrefabs(Map *map);
|
||||
bool tryImportDefaultPrefabs(QWidget * parent, BaseGameVersion version, QString filepath = "");
|
||||
|
||||
private:
|
||||
MetatileSelector *selector;
|
||||
|
||||
@@ -18,6 +18,7 @@ class PreferenceEditor : public QMainWindow
|
||||
public:
|
||||
explicit PreferenceEditor(QWidget *parent = nullptr);
|
||||
~PreferenceEditor();
|
||||
void updateFields();
|
||||
|
||||
signals:
|
||||
void preferencesSaved();
|
||||
@@ -27,9 +28,10 @@ private:
|
||||
Ui::PreferenceEditor *ui;
|
||||
NoScrollComboBox *themeSelector;
|
||||
|
||||
void populateFields();
|
||||
void initFields();
|
||||
void saveFields();
|
||||
|
||||
|
||||
private slots:
|
||||
void dialogButtonClicked(QAbstractButton *button);
|
||||
};
|
||||
|
||||
60
include/ui/projectsettingseditor.h
Normal file
60
include/ui/projectsettingseditor.h
Normal file
@@ -0,0 +1,60 @@
|
||||
#ifndef PROJECTSETTINGSEDITOR_H
|
||||
#define PROJECTSETTINGSEDITOR_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "project.h"
|
||||
|
||||
class NoScrollComboBox;
|
||||
class QAbstractButton;
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class ProjectSettingsEditor;
|
||||
}
|
||||
|
||||
class ProjectSettingsEditor : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ProjectSettingsEditor(QWidget *parent = nullptr, Project *project = nullptr);
|
||||
~ProjectSettingsEditor();
|
||||
|
||||
signals:
|
||||
void reloadProject();
|
||||
|
||||
private:
|
||||
Ui::ProjectSettingsEditor *ui;
|
||||
Project *project;
|
||||
|
||||
bool hasUnsavedChanges = false;
|
||||
bool projectNeedsReload = false;
|
||||
bool refreshing = false;
|
||||
const QString baseDir;
|
||||
|
||||
void initUi();
|
||||
void connectSignals();
|
||||
void restoreWindowState();
|
||||
void save();
|
||||
void refresh();
|
||||
void closeEvent(QCloseEvent*);
|
||||
int prompt(const QString &, QMessageBox::StandardButton = QMessageBox::Yes);
|
||||
bool promptSaveChanges();
|
||||
bool promptRestoreDefaults();
|
||||
|
||||
void setBorderMetatilesUi(bool customSize);
|
||||
void setBorderMetatileIds(bool customSize, QList<uint16_t> metatileIds);
|
||||
QList<uint16_t> getBorderMetatileIds(bool customSize);
|
||||
|
||||
void createProjectPathsTable();
|
||||
QString chooseProjectFile(const QString &defaultFilepath);
|
||||
|
||||
private slots:
|
||||
void dialogButtonClicked(QAbstractButton *button);
|
||||
void choosePrefabsFileClicked(bool);
|
||||
void importDefaultPrefabsClicked(bool);
|
||||
void updateAttributeLimits(const QString &attrSize);
|
||||
void markEdited();
|
||||
};
|
||||
|
||||
#endif // PROJECTSETTINGSEDITOR_H
|
||||
@@ -138,7 +138,6 @@ private:
|
||||
void copyMetatile(bool cut);
|
||||
void pasteMetatile(const Metatile * toPaste, QString label);
|
||||
bool replaceMetatile(uint16_t metatileId, const Metatile * src, QString label);
|
||||
void setComboValue(QComboBox * combo, int value);
|
||||
void commitMetatileChange(Metatile * prevMetatile);
|
||||
void commitMetatileAndLabelChange(Metatile * prevMetatile, QString prevLabel);
|
||||
|
||||
|
||||
67
include/ui/uintspinbox.h
Normal file
67
include/ui/uintspinbox.h
Normal file
@@ -0,0 +1,67 @@
|
||||
#ifndef UINTSPINBOX_H
|
||||
#define UINTSPINBOX_H
|
||||
|
||||
#include <QAbstractSpinBox>
|
||||
#include <QLineEdit>
|
||||
|
||||
/*
|
||||
QSpinBox stores minimum/maximum/value as ints. This class is a version of QAbstractSpinBox for values above 0x7FFFFFFF.
|
||||
It minimally implements some QSpinBox-specific features like prefixes to simplify support for hex value input.
|
||||
It also implements the scroll focus requirements of NoScrollSpinBox.
|
||||
*/
|
||||
|
||||
class UIntSpinBox : public QAbstractSpinBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UIntSpinBox(QWidget *parent = nullptr);
|
||||
~UIntSpinBox() {};
|
||||
|
||||
uint32_t value() const { return m_value; }
|
||||
uint32_t minimum() const { return m_minimum; }
|
||||
uint32_t maximum() const { return m_maximum; }
|
||||
QString prefix() const { return m_prefix; }
|
||||
int displayIntegerBase() const { return m_displayIntegerBase; }
|
||||
bool hasPadding() const { return m_hasPadding; }
|
||||
|
||||
void setMinimum(uint32_t min);
|
||||
void setMaximum(uint32_t max);
|
||||
void setRange(uint32_t min, uint32_t max);
|
||||
void setPrefix(const QString &prefix);
|
||||
void setDisplayIntegerBase(int base);
|
||||
void setHasPadding(bool enabled);
|
||||
|
||||
private:
|
||||
uint32_t m_minimum;
|
||||
uint32_t m_maximum;
|
||||
uint32_t m_value;
|
||||
QString m_prefix;
|
||||
int m_displayIntegerBase;
|
||||
bool m_hasPadding;
|
||||
int m_numChars;
|
||||
|
||||
void updateEdit();
|
||||
QString stripped(QString input) const;
|
||||
|
||||
virtual void stepBy(int steps) override;
|
||||
virtual void wheelEvent(QWheelEvent *event) override;
|
||||
virtual void focusOutEvent(QFocusEvent *event) override;
|
||||
|
||||
protected:
|
||||
virtual uint32_t valueFromText(const QString &text) const;
|
||||
virtual QString textFromValue(uint32_t val) const;
|
||||
virtual QValidator::State validate(QString &input, int &pos) const override;
|
||||
virtual QAbstractSpinBox::StepEnabled stepEnabled() const override;
|
||||
|
||||
|
||||
public slots:
|
||||
void setValue(uint32_t val);
|
||||
void onEditFinished();
|
||||
|
||||
signals:
|
||||
void valueChanged(uint32_t val);
|
||||
void textChanged(const QString &text);
|
||||
};
|
||||
|
||||
#endif // UINTSPINBOX_H
|
||||
Reference in New Issue
Block a user