Added some application-wide macros, set up various parts of the editor to reference the application name via macro instead of hardcoded to a specific string

This commit is contained in:
parax0 2016-05-03 00:42:55 -06:00
parent 2db740e572
commit ab38205611
15 changed files with 108 additions and 40 deletions

13
src/.qmake.conf Normal file
View File

@ -0,0 +1,13 @@
# CONFIG += PUBLIC_RELEASE
DEFINES += 'APP_NAME=\"\\\"Prime World Editor\\\"\"' \
'APP_VERSION=\"\\\"1.1.0\\\"\"'
PUBLIC_RELEASE {
DEFINES += 'PUBLIC_RELEASE=1' \
'APP_FULL_NAME=\"APP_NAME \\\" v\\\" APP_VERSION\"'
}
else {
DEFINES += 'PUBLIC_RELEASE=0' \
'APP_FULL_NAME=\"APP_NAME \\\" v\\\" APP_VERSION \\\" (DEV)\\\"\"'
}

View File

@ -8,32 +8,50 @@
#define __FILE_SHORT__ strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__ #define __FILE_SHORT__ strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__
#define ASSERT_CHECK_BEGIN(Expression) \ #if _DEBUG
{ \ #define DEBUG_BREAK __debugbreak();
if (!(Expression)) \ #else
{ #define DEBUG_BREAK {}
#endif
#define ASSERT_CHECK_END \ #if !PUBLIC_RELEASE
} \
}
#define WRITE_FAILURE_TO_LOG(Expression) \ // Development Build
Log::Write(TString(__FILE_SHORT__) + "(" + TString::FromInt32(__LINE__, 0, 10) + "): ASSERT FAILED: " + #Expression); #define ASSERT_CHECK_BEGIN(Expression) \
{ \
if (!(Expression)) \
{
#define BREAK_ONLY_ASSERT(Expression) \ #define ASSERT_CHECK_END \
ASSERT_CHECK_BEGIN(Expression) \ } \
__debugbreak(); \ }
ASSERT_CHECK_END
#define LOG_ONLY_ASSERT(Expression) \ #define WRITE_FAILURE_TO_LOG(Expression) \
ASSERT_CHECK_BEGIN(Expression) \ Log::Write(TString(__FILE_SHORT__) + "(" + TString::FromInt32(__LINE__, 0, 10) + "): ASSERT FAILED: " + #Expression);
WRITE_FAILURE_TO_LOG(Expression) \
ASSERT_CHECK_END
#define ASSERT(Expression) \ #define BREAK_ONLY_ASSERT(Expression) \
ASSERT_CHECK_BEGIN(Expression) \ ASSERT_CHECK_BEGIN(Expression) \
WRITE_FAILURE_TO_LOG(Expression) \ DEBUG_BREAK \
__debugbreak(); \ ASSERT_CHECK_END
ASSERT_CHECK_END
#define LOG_ONLY_ASSERT(Expression) \
ASSERT_CHECK_BEGIN(Expression) \
WRITE_FAILURE_TO_LOG(Expression) \
ASSERT_CHECK_END
#define ASSERT(Expression) \
ASSERT_CHECK_BEGIN(Expression) \
WRITE_FAILURE_TO_LOG(Expression) \
DEBUG_BREAK \
ASSERT_CHECK_END
#else
// Public Release Build
#define BREAK_ONLY_ASSERT(Expression) {}
#define LOG_ONLY_ASSERT(Expression) {}
#define ASSERT(Expression) {}
#endif
#endif // ASSERT_H #endif // ASSERT_H

View File

@ -53,6 +53,9 @@ bool InitLog(const TString& rkFilename)
fprintf(gpLogFile, "Opened log file at %s\n", Buffer); fprintf(gpLogFile, "Opened log file at %s\n", Buffer);
fflush(gpLogFile); fflush(gpLogFile);
// Print app name and version
fprintf(gpLogFile, APP_FULL_NAME"\n");
// Print any messages that were attempted before we initialized // Print any messages that were attempted before we initialized
if (!gPreInitLogs.empty()) if (!gPreInitLogs.empty())
{ {

View File

@ -1,11 +1,16 @@
#include "CAboutDialog.h" #include "CAboutDialog.h"
#include "ui_CAboutDialog.h" #include "ui_CAboutDialog.h"
#include "UICommon.h"
CAboutDialog::CAboutDialog(QWidget *parent) : CAboutDialog::CAboutDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::CAboutDialog) ui(new Ui::CAboutDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
QString LabelText = ui->AboutLabel->text();
REPLACE_APPVARS(LabelText);
ui->AboutLabel->setText(LabelText);
} }
CAboutDialog::~CAboutDialog() CAboutDialog::~CAboutDialog()

View File

@ -15,9 +15,9 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="AboutLabel">
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:12pt; font-weight:600;&quot;&gt;Prime World Editor v1.0.0&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Prime World Editor is developed by &lt;span style=&quot; font-weight:600;&quot;&gt;Parax&lt;/span&gt;.&lt;br/&gt;All the games it edits are developed by &lt;span style=&quot; font-weight:600;&quot;&gt;Retro Studios&lt;/span&gt; and published by &lt;span style=&quot; font-weight:600;&quot;&gt;Nintendo&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;Special thanks to:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;&lt;li&gt; The community at &lt;span style=&quot; font-weight:600;&quot;&gt;Metroid2002&lt;/span&gt; that contributed to reverse engineering the game and documenting its internals and file formats; in particular, &lt;span style=&quot; font-weight:600;&quot;&gt;Antidote&lt;/span&gt; and &lt;span style=&quot; font-weight:600;&quot;&gt;jackoalan&lt;/span&gt;, among others!&lt;/li&gt;&lt;li&gt; &lt;span style=&quot; font-weight:600;&quot;&gt;Miles: &lt;/span&gt;In addition to helping reverse engineer a few formats (in particular MLVL and MREA), also contributed greatly to putting together the script object templates and documenting object properties.&lt;/li&gt;&lt;li&gt; &lt;span style=&quot; font-weight:600;&quot;&gt;Bearborg:&lt;/span&gt; Lots of testing and feedback, plus the UI icons and some script object assets.&lt;/li&gt;&lt;li&gt; &lt;span style=&quot; font-weight:600;&quot;&gt;Omega: &lt;/span&gt;Script object assets.&lt;/li&gt;&lt;/ul&gt;Check the &lt;a href=&quot;http://www.metroid2002.com/retromodding/wiki/Retro_Modding_Wiki&quot;&gt;Retro Modding Wiki&lt;/a&gt; for file format documentation.&lt;/p&gt;&lt;p&gt;Prime World Editor uses &lt;span style=&quot; font-weight:600;&quot;&gt;Assimp&lt;/span&gt; (Open Asset Import Library).&lt;br/&gt;Copyright © 2006-2015 assimp team&lt;br/&gt;All rights reserved.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:12pt; font-weight:600;&quot;&gt;%APP_FULL_NAME%&lt;/span&gt;&lt;/p&gt;&lt;p&gt;%APP_NAME% is developed by &lt;span style=&quot; font-weight:600;&quot;&gt;Parax&lt;/span&gt;.&lt;br/&gt;All the games it edits are developed by &lt;span style=&quot; font-weight:600;&quot;&gt;Retro Studios&lt;/span&gt; and published by &lt;span style=&quot; font-weight:600;&quot;&gt;Nintendo&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;Special thanks to:&lt;/p&gt;&lt;p&gt;&lt;ul&gt;&lt;li&gt; The community at &lt;span style=&quot; font-weight:600;&quot;&gt;Metroid2002&lt;/span&gt; that contributed to reverse engineering the game and documenting its internals and file formats; in particular, &lt;span style=&quot; font-weight:600;&quot;&gt;Antidote&lt;/span&gt; and &lt;span style=&quot; font-weight:600;&quot;&gt;jackoalan&lt;/span&gt;, among others!&lt;/li&gt;&lt;li&gt; &lt;span style=&quot; font-weight:600;&quot;&gt;Miles: &lt;/span&gt;In addition to helping reverse engineer a few formats (in particular MLVL and MREA), also contributed greatly to putting together the script object templates and documenting object properties.&lt;/li&gt;&lt;li&gt; &lt;span style=&quot; font-weight:600;&quot;&gt;Bearborg:&lt;/span&gt; Lots of testing and feedback, plus the UI icons and some script object assets.&lt;/li&gt;&lt;li&gt; &lt;span style=&quot; font-weight:600;&quot;&gt;Omega: &lt;/span&gt;Script object assets.&lt;/li&gt;&lt;/ul&gt;Check the &lt;a href=&quot;http://www.metroid2002.com/retromodding/wiki/Retro_Modding_Wiki&quot;&gt;Retro Modding Wiki&lt;/a&gt; for file format documentation.&lt;/p&gt;&lt;p&gt;%APP_NAME% uses &lt;span style=&quot; font-weight:600;&quot;&gt;Assimp&lt;/span&gt; (Open Asset Import Library).&lt;br/&gt;Copyright © 2006-2015 assimp team&lt;br/&gt;All rights reserved.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>

View File

@ -18,6 +18,8 @@ CStartWindow::CStartWindow(QWidget *parent)
, ui(new Ui::CStartWindow) , ui(new Ui::CStartWindow)
{ {
ui->setupUi(this); ui->setupUi(this);
REPLACE_WINDOWTITLE_APPVARS;
mpWorld = nullptr; mpWorld = nullptr;
mpWorldEditor = new CWorldEditor(0); mpWorldEditor = new CWorldEditor(0);
mpModelEditor = new CModelEditorWindow(this); mpModelEditor = new CModelEditorWindow(this);

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Prime World Editor</string> <string>%APP_FULL_NAME%</string>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">

View File

@ -23,6 +23,7 @@ CCharacterEditor::CCharacterEditor(QWidget *parent)
, mPlaybackSpeed(1.f) , mPlaybackSpeed(1.f)
{ {
ui->setupUi(this); ui->setupUi(this);
REPLACE_WINDOWTITLE_APPVARS;
ui->Viewport->SetNode(mpCharNode); ui->Viewport->SetNode(mpCharNode);
@ -195,7 +196,7 @@ void CCharacterEditor::Open()
{ {
mpSet = pSet; mpSet = pSet;
mpCharNode->SetCharSet(mpSet); mpCharNode->SetCharSet(mpSet);
setWindowTitle("Prime World Editor - Character Editor: " + TO_QSTRING(mpSet->Source())); SET_WINDOWTITLE_APPVARS("%APP_FULL_NAME% - Character Editor: " + TO_QSTRING(mpSet->Source()));
// Clear selected bone // Clear selected bone
ui->SkeletonHierarchyTreeView->selectionModel()->clear(); ui->SkeletonHierarchyTreeView->selectionModel()->clear();

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Prime World Editor - Character Editor</string> <string>%APP_FULL_NAME% - Character Editor</string>
</property> </property>
<widget class="QWidget" name="CentralWidget"> <widget class="QWidget" name="CentralWidget">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
@ -49,7 +49,7 @@
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
</widget> </widget>
<widget class="QWidget" name=""> <widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0"> <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0">
<item> <item>
<widget class="CCharacterEditorViewport" name="Viewport" native="true"> <widget class="CCharacterEditorViewport" name="Viewport" native="true">

View File

@ -11,12 +11,15 @@ RESOURCES += Icons.qrc
win32: RC_ICONS += icons/AppIcon.ico win32: RC_ICONS += icons/AppIcon.ico
CONFIG += console
TEMPLATE = app TEMPLATE = app
DESTDIR = $$PWD/../../bin DESTDIR = $$PWD/../../bin
UI_DIR = $$PWD/../../build/Editor UI_DIR = $$PWD/../../build/Editor
DEFINES += GLEW_STATIC DEFINES += GLEW_STATIC
!PUBLIC_RELEASE {
CONFIG += console
}
CONFIG(debug, debug|release) { CONFIG(debug, debug|release) {
# Debug Config # Debug Config
OBJECTS_DIR = $$PWD/../../build/Editor/debug OBJECTS_DIR = $$PWD/../../build/Editor/debug

View File

@ -33,6 +33,7 @@ CModelEditorWindow::CModelEditorWindow(QWidget *pParent)
, mIgnoreSignals(false) , mIgnoreSignals(false)
{ {
ui->setupUi(this); ui->setupUi(this);
REPLACE_WINDOWTITLE_APPVARS;
ui->Viewport->SetNode(mpCurrentModelNode); ui->Viewport->SetNode(mpCurrentModelNode);
ui->Viewport->SetClearColor(CColor(0.3f, 0.3f, 0.3f, 1.f)); ui->Viewport->SetClearColor(CColor(0.3f, 0.3f, 0.3f, 1.f));
@ -725,7 +726,7 @@ void CModelEditorWindow::Open()
if (pModel) if (pModel)
{ {
SetActiveModel(pModel); SetActiveModel(pModel);
setWindowTitle("Prime World Editor - Model Editor: " + TO_QSTRING(pModel->Source())); SET_WINDOWTITLE_APPVARS("%APP_FULL_NAME% - Model Editor: " + TO_QSTRING(pModel->Source()));
mOutputFilename = TO_QSTRING(pModel->FullSource()); mOutputFilename = TO_QSTRING(pModel->FullSource());
} }
@ -770,7 +771,7 @@ void CModelEditorWindow::Import()
pModel = CModelLoader::ImportAssimpNode(pScene->mRootNode, pScene, *pSet); pModel = CModelLoader::ImportAssimpNode(pScene->mRootNode, pScene, *pSet);
SetActiveModel(pModel); SetActiveModel(pModel);
setWindowTitle("Prime World Editor - Model Editor: Untitled"); SET_WINDOWTITLE_APPVARS("%APP_FULL_NAME% - Model Editor: Untitled");
mOutputFilename = ""; mOutputFilename = "";
gResCache.Clean(); gResCache.Clean();
} }
@ -799,7 +800,7 @@ void CModelEditorWindow::SaveAs()
Save(); Save();
TString Name = TString(FileName.toStdString()); TString Name = TString(FileName.toStdString());
setWindowTitle("Prime World Editor - Model Editor: " + TO_QSTRING(Name)); SET_WINDOWTITLE_APPVARS("%APP_FULL_NAME% - Model Editor: " + TO_QSTRING(Name));
} }
void CModelEditorWindow::ConvertToDDS() void CModelEditorWindow::ConvertToDDS()

View File

@ -17,7 +17,7 @@
</size> </size>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Prime World Editor - Model Editor</string> <string>%APP_FULL_NAME% - Model Editor</string>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout_7"> <layout class="QHBoxLayout" name="horizontalLayout_7">

View File

@ -5,11 +5,32 @@
#include <QMap> #include <QMap>
#include <QString> #include <QString>
#define TO_QSTRING(Str) UICommon::ToQString(Str) // App string variable handling - automatically fill in application name/version
#define TO_TSTRING(Str) UICommon::ToTString(Str) #define UI_APPVAR_NAME "%APP_NAME%"
#define UI_APPVAR_FULLNAME "%APP_FULL_NAME%"
#define UI_APPVAR_VERSION "%APP_VERSION%"
#define REPLACE_APPVARS(InQString) \
InQString.replace(UI_APPVAR_NAME, APP_NAME); \
InQString.replace(UI_APPVAR_FULLNAME, APP_FULL_NAME); \
InQString.replace(UI_APPVAR_VERSION, APP_VERSION);
#define SET_WINDOWTITLE_APPVARS(InString) \
{ \
QString APPVAR_MACRO_NEWTITLE = InString; \
REPLACE_APPVARS(APPVAR_MACRO_NEWTITLE) \
setWindowTitle(APPVAR_MACRO_NEWTITLE); \
}
#define REPLACE_WINDOWTITLE_APPVARS \
SET_WINDOWTITLE_APPVARS(windowTitle());
// Common conversion functions
#define TO_QSTRING(Str) UICommon::ToQString(Str)
#define TO_TSTRING(Str) UICommon::ToTString(Str)
#define TO_TWIDESTRING(Str) UICommon::ToTWideString(Str) #define TO_TWIDESTRING(Str) UICommon::ToTWideString(Str)
#define TO_CCOLOR(Clr) CColor::Integral(Clr.red(), Clr.green(), Clr.blue(), Clr.alpha()) #define TO_CCOLOR(Clr) CColor::Integral(Clr.red(), Clr.green(), Clr.blue(), Clr.alpha())
#define TO_QCOLOR(Clr) QColor(Clr.R * 255, Clr.G * 255, Clr.B * 255, Clr.A * 255) #define TO_QCOLOR(Clr) QColor(Clr.R * 255, Clr.G * 255, Clr.B * 255, Clr.A * 255)
namespace UICommon namespace UICommon
{ {

View File

@ -42,6 +42,7 @@ CWorldEditor::CWorldEditor(QWidget *parent)
{ {
Log::Write("Creating World Editor"); Log::Write("Creating World Editor");
ui->setupUi(this); ui->setupUi(this);
REPLACE_WINDOWTITLE_APPVARS;
mpSelection->SetAllowedNodeTypes(eScriptNode | eLightNode); mpSelection->SetAllowedNodeTypes(eScriptNode | eLightNode);
@ -238,7 +239,7 @@ void CWorldEditor::SetArea(CWorld *pWorld, CGameArea *pArea)
if (AreaName.IsEmpty()) if (AreaName.IsEmpty())
AreaName = "[Untitled Area]"; AreaName = "[Untitled Area]";
setWindowTitle(QString("Prime World Editor - %1 - %2[*]").arg(TO_QSTRING(WorldName)).arg(TO_QSTRING(AreaName))); SET_WINDOWTITLE_APPVARS( QString("%APP_FULL_NAME% - %1 - %2[*]").arg(TO_QSTRING(WorldName)).arg(TO_QSTRING(AreaName)) );
Log::Write("Loaded area: " + mpArea->Source() + " (" + TO_TSTRING(TO_QSTRING(AreaName)) + ")"); Log::Write("Loaded area: " + mpArea->Source() + " (" + TO_TSTRING(TO_QSTRING(AreaName)) + ")");
} }
@ -248,7 +249,7 @@ void CWorldEditor::SetArea(CWorld *pWorld, CGameArea *pArea)
if (pWorldNameTable) LevelName = TO_QSTRING(WorldName); if (pWorldNameTable) LevelName = TO_QSTRING(WorldName);
else LevelName = "!" + TO_QSTRING(mpWorld->AreaInternalName(mpArea->WorldIndex())); else LevelName = "!" + TO_QSTRING(mpWorld->AreaInternalName(mpArea->WorldIndex()));
setWindowTitle(QString("Prime World Editor - %1[*]").arg(LevelName)); SET_WINDOWTITLE_APPVARS( QString("%APP_FULL_NAME% - %1[*]").arg(LevelName) );
Log::Write("Loaded level: World " + mpWorld->Source() + " / Area " + mpArea->Source() + " (" + TO_TSTRING(LevelName) + ")"); Log::Write("Loaded level: World " + mpWorld->Source() + " / Area " + mpArea->Source() + " (" + TO_TSTRING(LevelName) + ")");
} }

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Prime World Editor</string> <string>%APP_FULL_NAME%</string>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_5">