-
Notifications
You must be signed in to change notification settings - Fork 4
/
substancemanagerapp.h
155 lines (127 loc) · 4.56 KB
/
substancemanagerapp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#ifndef SUBSTANCEMANAGERAPP_H
#define SUBSTANCEMANAGERAPP_H
#include "sbsarloader.h"
#include <QDomDocument>
#include <QJsonObject>
#include <QLabel>
#include <QMainWindow>
#include <QProcess>
#include <QPushButton>
#include <QSettings>
#include <QTextCharFormat>
class SubstancePresetPreview;
namespace Ui {
class SubstanceManagerApp;
}
const QString k_formatStrings = "SBSAR Library Manager Project (*.smproj);;All files (*)";
struct Category
{
QString name;
QList<SBSPreset*> presets;
// Later: Add per-category settings
~Category();
void CheckPresets();
QList<SBSPreset*> GetPresetsByName(QString name);
};
class SubstanceManagerApp : public QMainWindow
{
Q_OBJECT
public:
static SubstanceManagerApp* instance;
explicit SubstanceManagerApp(QWidget *parent = nullptr);
~SubstanceManagerApp();
// init apps
void initSAT();
void init7z();
// Projects:
void NewProject(QString path);
void LoadProject(QString path, bool createIfNotExist);
void CloseProject();
void SaveProject();
void closeEvent(QCloseEvent *e);
void showEvent(QShowEvent *);
QSettings* settings;
// Workflow/project/the like
QList<SBSPreset*> m_library;
QList<Category*> m_categories;
Category* GetCategoryByName(QString name);
bool isKnownPresetPtr(SBSPreset* ptr);
Category* GetPresetCategory(SBSPreset* ptr);
// EXE Tools
static QString sbsRenderExe;
static QString sbs7zExe;
QString GetCategoryCacheDir(Category* cat);
QString GetPresetCacheDir(SBSPreset* preset, QSize size, QString suffix = "");
QString GetPresetCacheRootDir(SBSPreset* preset, QString suffix);
QProcess* CreateProcessForSbsPresetRender(SBSPreset* preset, QSize size, QString suffix = "", bool useRootDir = false, QStringList *outputsToBake = nullptr);
QString ConvertToRelativePath(QString path);
QString projectDir() const;
void setProjectDir(const QString &projectDir);
QString projectFilePath() const;
void setProjectFilePath(const QString &projectFilePath);
// Event Filtering
bool eventFilter(QObject *watched, QEvent *event);
bool KeyboardEvents(QKeyEvent* event);
bool LibraryDragEvent(QEvent* event);
bool CategoryButtonEvent(QPushButton* button, QEvent* event);
bool PresetEvent(SubstancePresetPreview* watched, QEvent* event);
bool PresetViewEvent(QWidget* watched, QEvent* event);
bool CategoriesLayout(QSize size);
bool InspectorLabelResetEvent(QLabel* label, QMouseEvent* event);
QList<QPushButton*> categoryButtons;
public slots:
//void OnTextLogged(QString text, QTextCharFormat format);
void ReimportSubstances();
void UpdateLibraryUI();
void UpdateCategoryButtons();
void UpdatePresetsUI(Category* cat);
void BuildCategoryUI(Category* cat);
void BuildObjectInspectorUI();
void OnPresetRendered(SBSPreset* p);
private slots:
void on_actionCreate_Variation_triggered();
void on_actionNew_Project_triggered();
void on_actionOpen_Project_triggered();
void on_actionSave_Project_triggered();
void on_actionThemeDefault_triggered();
void on_actionThemeDark_triggered();
void on_actionFusion_triggered();
void on_actionTest1_triggered();
void on_actionTest2_triggered();
void on_actionTest3_triggered();
void on_reimport_clicked();
void on_refresh_clicked();
void on_addCategory_clicked();
void on_deleteCategory_clicked();
void on_sz64_clicked();
void on_sz100_clicked();
void on_sz256_clicked();
void on_lineEdit_textChanged(const QString &arg1);
void on_importVisible_clicked();
void on_actionSettings_triggered();
void on_actionBake_Selected_Presets_triggered();
void on_actionBake_All_Presets_triggered();
private:
QPalette defaultPalette;
Ui::SubstanceManagerApp *ui;
QString m_projectFilePath;
QString m_projectDir;
QJsonObject m_projectData;
Category* m_currentCategory;
// For now, only single preset edit at a time
QSet<SBSPreset*> m_selectedPresets;
QSize m_thumbSize;
int presetQualityFactor;
struct WidgetPair
{
QWidget *label, *field;
};
WidgetPair CreateWidgetForInput(SBSPreset::Input& input, QString value, bool isMulti, bool isTweaked);
void setCurrentPresetProperty(QString property, QString value);
void unsetCurrentPresetProperty(QString property);
QString getCurrentPresetProperty(QString property);
bool CheckProjectSettings();
QImage GetDefaultImageForChannel(QString channel);
void BakePresets(QQueue<SBSPreset*> presets);
};
#endif // SUBSTANCEMANAGERAPP_H