Browse Source

Work on creating/loading projects

Marko Pintera 13 years ago
parent
commit
826b809590

+ 30 - 9
CamelotEditor/CamelotEditor.vcxproj

@@ -76,7 +76,7 @@
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
-      <PreprocessorDefinitions>UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>UNICODE;WIN32;QT_NO_KEYWORDS;QT_LARGEFILE_SUPPORT;QT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <AdditionalIncludeDirectories>.\GeneratedFiles;.\Include;.\Dependencies\Include;.\GeneratedFiles\$(ConfigurationName);..\CamelotCore\Include;..\CamelotUtility\Include;..\Dependencies\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <Optimization>Disabled</Optimization>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
@@ -93,7 +93,7 @@
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <ClCompile>
-      <PreprocessorDefinitions>UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>UNICODE;WIN32;QT_NO_KEYWORDS;QT_LARGEFILE_SUPPORT;QT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <AdditionalIncludeDirectories>.\GeneratedFiles;.\Include;.\Dependencies\Include;.\GeneratedFiles\$(ConfigurationName);..\CamelotCore\Include;..\CamelotUtility\Include;..\Dependencies\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <Optimization>Disabled</Optimization>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
@@ -110,7 +110,7 @@
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
-      <PreprocessorDefinitions>UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>UNICODE;WIN32;QT_NO_KEYWORDS;QT_LARGEFILE_SUPPORT;QT_DLL;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <AdditionalIncludeDirectories>.\GeneratedFiles;.\Include;.\Dependencies\Include;.\GeneratedFiles\$(ConfigurationName);..\CamelotCore\Include;..\CamelotUtility\Include;..\Dependencies\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <DebugInformationFormat />
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -126,7 +126,7 @@
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <ClCompile>
-      <PreprocessorDefinitions>UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>UNICODE;WIN32;QT_NO_KEYWORDS;QT_LARGEFILE_SUPPORT;QT_DLL;QT_NO_DEBUG;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <AdditionalIncludeDirectories>.\GeneratedFiles;.\Include;.\Dependencies\Include;.\GeneratedFiles\$(ConfigurationName);..\CamelotCore\Include;..\CamelotUtility\Include;..\Dependencies\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <DebugInformationFormat>
       </DebugInformationFormat>
@@ -143,6 +143,7 @@
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClCompile Include="GeneratedFiles\moc_CmQtEditor.cpp" />
+    <ClCompile Include="GeneratedFiles\moc_CmQtNewProject.cpp" />
     <ClCompile Include="GeneratedFiles\moc_CmQtProjectSelection.cpp" />
     <ClCompile Include="GeneratedFiles\qrc_CmEditor.cpp">
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@@ -155,7 +156,9 @@
       </PrecompiledHeader>
     </ClCompile>
     <ClCompile Include="Source\CmEditorApplication.cpp" />
+    <ClCompile Include="Source\CmEditorPrefs.cpp" />
     <ClCompile Include="Source\CmQtEditor.cpp" />
+    <ClCompile Include="Source\CmQtNewProject.cpp" />
     <ClCompile Include="Source\CmQtProjectSelection.cpp" />
     <ClCompile Include="Source\main.cpp" />
   </ItemGroup>
@@ -168,7 +171,7 @@
       <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\moc_%(Filename).cpp</Outputs>
       <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles\moc_%(Filename).cpp</Outputs>
       <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\moc_%(Filename).cpp"  -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL  "-I.\GeneratedFiles" "-I.\Include" "-I.\Dependencies\Include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\CamelotCore\Include" "-I.\..\CamelotUtility\Include" "-I.\..\Dependencies\Include"</Command>
-      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\moc_%(Filename).cpp"  -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL  "-I.\GeneratedFiles" "-I.\Include" "-I.\Dependencies\Include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\CamelotCore\Include" "-I.\..\CamelotUtility\Include" "-I.\..\Dependencies\Include"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\moc_%(Filename).cpp"  -DQT_NO_KEYWORDS -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL  "-I.\GeneratedFiles" "-I.\Include" "-I.\Dependencies\Include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\CamelotCore\Include" "-I.\..\CamelotUtility\Include" "-I.\..\Dependencies\Include"</Command>
       <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
       <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
       <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Moc%27ing %(Filename)...</Message>
@@ -204,20 +207,38 @@
     <ClInclude Include="Include\CmEditorPrefs.h" />
     <ClInclude Include="Include\CmEditorPrerequisites.h" />
     <ClInclude Include="Include\CmLayoutManager.h" />
+    <CustomBuild Include="Include\CmQtNewProject.h">
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\moc_%(Filename).cpp"  -DQT_NO_KEYWORDS -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL  "-I.\GeneratedFiles" "-I.\Include" "-I.\Dependencies\Include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\CamelotCore\Include" "-I.\..\CamelotUtility\Include" "-I.\..\Dependencies\Include"</Command>
+      <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Moc%27ing %(Filename)...</Message>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles\moc_%(Filename).cpp</Outputs>
+      <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\moc_%(Filename).cpp"  -DQT_NO_KEYWORDS -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL  "-I.\GeneratedFiles" "-I.\Include" "-I.\Dependencies\Include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\CamelotCore\Include" "-I.\..\CamelotUtility\Include" "-I.\..\Dependencies\Include"</Command>
+      <Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Moc%27ing %(Filename)...</Message>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\moc_%(Filename).cpp</Outputs>
+      <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\moc_%(Filename).cpp"  -DQT_NO_KEYWORDS -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL  "-I.\GeneratedFiles" "-I.\Include" "-I.\Dependencies\Include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\CamelotCore\Include" "-I.\..\CamelotUtility\Include" "-I.\..\Dependencies\Include"</Command>
+      <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Moc%27ing %(Filename)...</Message>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\moc_%(Filename).cpp</Outputs>
+      <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\moc_%(Filename).cpp"  -DQT_NO_KEYWORDS -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL  "-I.\GeneratedFiles" "-I.\Include" "-I.\Dependencies\Include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\CamelotCore\Include" "-I.\..\CamelotUtility\Include" "-I.\..\Dependencies\Include"</Command>
+      <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Moc%27ing %(Filename)...</Message>
+      <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\moc_%(Filename).cpp</Outputs>
+      <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
+    </CustomBuild>
     <CustomBuild Include="Include\CmQtProjectSelection.h">
-      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\moc_%(Filename).cpp"  -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL  "-I.\GeneratedFiles" "-I.\Include" "-I.\Dependencies\Include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\CamelotCore\Include" "-I.\..\CamelotUtility\Include" "-I.\..\Dependencies\Include"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\moc_%(Filename).cpp"  -DQT_NO_KEYWORDS -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL  "-I.\GeneratedFiles" "-I.\Include" "-I.\Dependencies\Include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\CamelotCore\Include" "-I.\..\CamelotUtility\Include" "-I.\..\Dependencies\Include"</Command>
       <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Moc%27ing %(Filename)...</Message>
       <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles\moc_%(Filename).cpp</Outputs>
       <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
-      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\moc_%(Filename).cpp"  -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL  "-I.\GeneratedFiles" "-I.\Include" "-I.\Dependencies\Include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\CamelotCore\Include" "-I.\..\CamelotUtility\Include" "-I.\..\Dependencies\Include"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\moc_%(Filename).cpp"  -DQT_NO_KEYWORDS -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL  "-I.\GeneratedFiles" "-I.\Include" "-I.\Dependencies\Include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\CamelotCore\Include" "-I.\..\CamelotUtility\Include" "-I.\..\Dependencies\Include"</Command>
       <Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Moc%27ing %(Filename)...</Message>
       <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\moc_%(Filename).cpp</Outputs>
       <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
-      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\moc_%(Filename).cpp"  -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL  "-I.\GeneratedFiles" "-I.\Include" "-I.\Dependencies\Include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\CamelotCore\Include" "-I.\..\CamelotUtility\Include" "-I.\..\Dependencies\Include"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\moc_%(Filename).cpp"  -DQT_NO_KEYWORDS -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL  "-I.\GeneratedFiles" "-I.\Include" "-I.\Dependencies\Include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\CamelotCore\Include" "-I.\..\CamelotUtility\Include" "-I.\..\Dependencies\Include"</Command>
       <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Moc%27ing %(Filename)...</Message>
       <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\moc_%(Filename).cpp</Outputs>
       <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
-      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\moc_%(Filename).cpp"  -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL  "-I.\GeneratedFiles" "-I.\Include" "-I.\Dependencies\Include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\CamelotCore\Include" "-I.\..\CamelotUtility\Include" "-I.\..\Dependencies\Include"</Command>
+      <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe"  "%(FullPath)" -o ".\GeneratedFiles\moc_%(Filename).cpp"  -DQT_NO_KEYWORDS -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL  "-I.\GeneratedFiles" "-I.\Include" "-I.\Dependencies\Include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\..\CamelotCore\Include" "-I.\..\CamelotUtility\Include" "-I.\..\Dependencies\Include"</Command>
       <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Moc%27ing %(Filename)...</Message>
       <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\moc_%(Filename).cpp</Outputs>
       <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>

+ 12 - 0
CamelotEditor/CamelotEditor.vcxproj.filters

@@ -48,6 +48,15 @@
     <ClCompile Include="GeneratedFiles\moc_CmQtProjectSelection.cpp">
       <Filter>Generated Files</Filter>
     </ClCompile>
+    <ClCompile Include="Source\CmEditorPrefs.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmQtNewProject.cpp">
+      <Filter>Source Files\Qt</Filter>
+    </ClCompile>
+    <ClCompile Include="GeneratedFiles\moc_CmQtNewProject.cpp">
+      <Filter>Generated Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <CustomBuild Include="CmEditor.qrc">
@@ -59,6 +68,9 @@
     <CustomBuild Include="Include\CmQtProjectSelection.h">
       <Filter>Header Files\Qt</Filter>
     </CustomBuild>
+    <CustomBuild Include="Include\CmQtNewProject.h">
+      <Filter>Header Files\Qt</Filter>
+    </CustomBuild>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="Include\CmEditorPrefs.h">

+ 7 - 0
CamelotEditor/Include/CmEditorApplication.h

@@ -1,6 +1,7 @@
 #pragma once
 
 #include "CmEditorPrerequisites.h"
+#include <QtCore/QString>
 
 namespace CamelotEditor
 {
@@ -10,5 +11,11 @@ namespace CamelotEditor
 		void startUp();
 		void run();
 		void shutDown();
+
+		void loadProject(const QString& projPath);
+		void createProject(const QString& projPath);
+		bool isValidProjectDirectory(const QString& projPath);
 	};
+
+	EditorApplication& gEditorApp();
 }

+ 14 - 0
CamelotEditor/Include/CmEditorPrefs.h

@@ -2,11 +2,25 @@
 
 #include "CmEditorPrerequisites.h"
 #include "CmModule.h"
+#include <QtCore/QString>
 
 namespace CamelotEditor
 {
 	class EditorPrefs : public CamelotEngine::Module<EditorPrefs>
 	{
+	public:
+		UINT32 getNumRecentlyUsedProjects() const;
+		const QString& getRecentlyUsedProjectPath(UINT32 idx) const;
+		void addRecentlyUsedProjectPath(const QString& path);
+		void removeRecentlyUsedProjectPath(UINT32 idx);
 
+		void setLastUsedProjectDirectory(const QString& value);
+		const QString& getLastUsedProjectDirectory() const;
+
+	private:
+		vector<QString>::type mRecentlyUsedProjects;
+		QString mLastUsedProjectDirectory;
 	};
+
+	EditorPrefs& gEditorPrefs();
 }

+ 2 - 0
CamelotEditor/Include/CmEditorPrerequisites.h

@@ -2,6 +2,8 @@
 
 #include "CmPrerequisites.h"
 
+using namespace CamelotEngine; // Not great design, but I'm just using namespaces to make the distinction between engine and editor cleaner so its fine
+
 namespace CamelotEditor
 {
 	class LayoutManager;

+ 1 - 1
CamelotEditor/Include/CmQtEditor.h

@@ -9,7 +9,7 @@ namespace CamelotEditor
 		Q_OBJECT
 
 	public:
-		QtEditor(QWidget *parent = 0);
+		QtEditor(QWidget *parent = nullptr);
 		~QtEditor();
 
 	private:

+ 37 - 0
CamelotEditor/Include/CmQtNewProject.h

@@ -0,0 +1,37 @@
+#pragma once
+
+#include <QtWidgets/QDialog>
+#include <QtWidgets/QTextEdit>
+#include <QtWidgets/QPushButton>
+
+#ifndef Q_MOC_RUN // Qt MOC doesn't handle some of the macros inside this header
+#include <boost/signal.hpp>
+#endif
+
+namespace CamelotEditor
+{
+	class QtNewProject : public QDialog
+	{
+		Q_OBJECT
+
+	public:
+		QtNewProject(QWidget *parent = nullptr);
+		~QtNewProject();
+	public:
+		boost::signal<void(const QString&)> onProjectPathSelected;
+
+	private:
+		QTextEdit* mTxtProjectName;
+		QPushButton* mBtnCreate;
+		QTextEdit* mTxtProjectPath;
+		QPushButton* mBtnBrowse;
+
+		void setupUi();
+		void setupSignals();
+		void retranslateUi();
+
+		private Q_SLOTS:
+		void createProject();
+		void browseProjectPath();
+	};
+}

+ 26 - 3
CamelotEditor/Include/CmQtProjectSelection.h

@@ -1,19 +1,42 @@
 #pragma once
 
-#include <QtWidgets/QWidget>
+#include <QtWidgets/QDialog>
+#include <QtWidgets/QListWidget>
+#include <QtWidgets/QPushButton>
+
+#ifndef Q_MOC_RUN // Qt MOC doesn't handle some of the macros inside this header
+#include <boost/signal.hpp>
+#endif
 
 namespace CamelotEditor
 {
-	class QtProjectSelection : public QWidget
+	class QtProjectSelection : public QDialog
 	{
 		Q_OBJECT
 
 	public:
-		QtProjectSelection(QWidget *parent = 0);
+		QtProjectSelection(QWidget *parent = nullptr);
 		~QtProjectSelection();
+	public:
+		boost::signal<void(const QString&)> onProjectSelected;
 
 	private:
+		QListWidget* mListWidget;
+		QPushButton* mBtnOpen;
+		QPushButton* mBtnNew;
+		QPushButton* mBtnBrowse;
+
 		void setupUi();
+		void setupSignals();
 		void retranslateUi();
+
+		void openProject(const QString& path);
+		void addRecentlyUsedProject(const QString& path);
+		void removeRecentlyUsedProject(const QString& path);
+
+	private Q_SLOTS:
+		void newProject();
+		void browseProject();
+		void openSelectedProject();
 	};
 }

+ 27 - 2
CamelotEditor/Source/CmEditorApplication.cpp

@@ -5,8 +5,6 @@
 #include "CmQtProjectSelection.h"
 #include <QtWidgets/QApplication>
 
-using namespace CamelotEngine;
-
 namespace CamelotEditor
 {
 	void EditorApplication::startUp()
@@ -21,6 +19,11 @@ namespace CamelotEditor
 		QApplication a(argc, nullptr);
 		QtEditor w;
 		w.show();
+
+		QtProjectSelection projSelection;
+		projSelection.onProjectSelected.connect(boost::bind(&EditorApplication::loadProject, this, _1));
+		projSelection.exec();
+
 		a.exec();
 	}
 
@@ -29,4 +32,26 @@ namespace CamelotEditor
 		LayoutManager::shutDown();
 		EditorPrefs::shutDown();
 	}
+
+	void EditorApplication::loadProject(const QString& projPath)
+	{
+		// TODO
+	}
+
+	void EditorApplication::createProject(const QString& projPath)
+	{
+		// TODO
+	}
+
+	bool EditorApplication::isValidProjectDirectory(const QString& projPath)
+	{
+		// TODO
+		return true;
+	}
+
+	EditorApplication& gEditorApp()
+	{
+		static EditorApplication application;
+		return application;
+	}
 }

+ 39 - 0
CamelotEditor/Source/CmEditorPrefs.cpp

@@ -0,0 +1,39 @@
+#include "CmEditorPrefs.h"
+
+namespace CamelotEditor
+{
+	UINT32 EditorPrefs::getNumRecentlyUsedProjects() const
+	{
+		return (UINT32)mRecentlyUsedProjects.size();
+	}
+
+	const QString& EditorPrefs::getRecentlyUsedProjectPath(UINT32 idx) const
+	{
+		return mRecentlyUsedProjects.at(idx);
+	}
+
+	void EditorPrefs::addRecentlyUsedProjectPath(const QString& path)
+	{
+		mRecentlyUsedProjects.push_back(path);
+	}
+
+	void EditorPrefs::removeRecentlyUsedProjectPath(UINT32 idx)
+	{
+		mRecentlyUsedProjects.erase(mRecentlyUsedProjects.begin() + idx);
+	}
+
+	void EditorPrefs::setLastUsedProjectDirectory(const QString& value)
+	{
+		mLastUsedProjectDirectory = value;
+	}
+
+	const QString& EditorPrefs::getLastUsedProjectDirectory() const
+	{
+		return mLastUsedProjectDirectory;
+	}
+
+	EditorPrefs& gEditorPrefs()
+	{
+		return EditorPrefs::instance();
+	}
+}

+ 3 - 3
CamelotEditor/Source/CmQtEditor.cpp

@@ -57,9 +57,9 @@ namespace CamelotEditor
 
 	void QtEditor::retranslateUi()
 	{
-		setWindowTitle(QApplication::translate("CmQtEditor", "Camelot Editor"));
-		mFileMenu->setTitle(QApplication::translate("QtEditorTestClass", "File"));
-		mWindowMenu->setTitle(QApplication::translate("QtEditorTestClass", "Windows"));
+		setWindowTitle(tr("Camelot Editor"));
+		mFileMenu->setTitle(tr("File"));
+		mWindowMenu->setTitle(tr("Windows"));
 	}
 }
 

+ 74 - 0
CamelotEditor/Source/CmQtNewProject.cpp

@@ -0,0 +1,74 @@
+#include "CmQtNewProject.h"
+#include <QtWidgets/QHBoxLayout>
+#include <QtWidgets/QVBoxLayout>
+
+namespace CamelotEditor
+{
+	QtNewProject::QtNewProject(QWidget *parent)
+		:QDialog(parent)
+	{
+		setupUi();
+	}
+
+	QtNewProject::~QtNewProject()
+	{ }
+
+	QTextEdit* mTxtProjectName;
+	QPushButton* mBtnCreate;
+	QTextEdit* mTxtProjectPath;
+	QPushButton* mBtnBrowse;
+
+	void QtNewProject::setupUi()
+	{
+		setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint | Qt::MSWindowsFixedSizeDialogHint);
+		setFixedSize(400, 170);
+
+		mTxtProjectName = new QTextEdit(this);
+		mTxtProjectPath = new QTextEdit(this);
+
+		mBtnCreate = new QPushButton(this);
+		mBtnBrowse = new QPushButton(this);
+
+		QWidget* nameWidget = new QWidget(this);
+
+		QHBoxLayout* pathLayout = new QHBoxLayout(this); 
+		pathLayout->setMargin(0);
+		pathLayout->addWidget(mTxtProjectPath);
+		pathLayout->addWidget(mBtnBrowse);
+
+		nameWidget->setLayout(pathLayout);
+
+		QVBoxLayout* centralLayout = new QVBoxLayout(this);
+		centralLayout->setMargin(0);
+		centralLayout->addWidget(mTxtProjectName);
+		centralLayout->addWidget(nameWidget);
+		centralLayout->addWidget(mBtnCreate);
+
+		setLayout(centralLayout);
+
+		retranslateUi();
+		setupSignals();
+	}
+
+	void QtNewProject::setupSignals()
+	{
+		connect(mBtnCreate, SIGNAL(clicked()), this, SLOT(createProject()));
+		connect(mBtnBrowse, SIGNAL(clicked()), this, SLOT(browseProjectPath()));
+	}
+
+	void QtNewProject::retranslateUi()
+	{
+		mBtnCreate->setText(tr("Create"));
+		mBtnBrowse->setText(tr("Browse"));
+	}
+
+	void QtNewProject::createProject()
+	{
+
+	}
+
+	void QtNewProject::browseProjectPath()
+	{
+
+	}
+}

+ 140 - 1
CamelotEditor/Source/CmQtProjectSelection.cpp

@@ -1,9 +1,18 @@
 #include "CmQtProjectSelection.h"
+#include "CmEditorPrefs.h"
+#include "CmEditorApplication.h"
+#include "CmQtNewProject.h"
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QVBoxLayout>
+#include <QtWidgets/QHBoxLayout>
+#include <QtWidgets/QListWidget>
+#include <QtWidgets/QFileDialog>
+#include <QtWidgets/QMessageBox>
 
 namespace CamelotEditor
 {
 	QtProjectSelection::QtProjectSelection(QWidget *parent)
-		:QWidget(parent)
+		:QDialog(parent)
 	{
 		setupUi();
 	}
@@ -15,11 +24,141 @@ namespace CamelotEditor
 
 	void QtProjectSelection::setupUi()
 	{
+		setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint | Qt::MSWindowsFixedSizeDialogHint);
+		setFixedSize(400, 170);
+
+		mListWidget = new QListWidget(this);
+
+		QWidget* buttonsWidget = new QWidget(this);
+		mBtnNew = new QPushButton(buttonsWidget);
+		mBtnOpen = new QPushButton(buttonsWidget);
+		mBtnBrowse = new QPushButton(buttonsWidget);
+
+		QHBoxLayout* buttonLayout = new QHBoxLayout(this);
+		buttonLayout->setMargin(0);
+		buttonLayout->addWidget(mBtnNew);
+		buttonLayout->addWidget(mBtnBrowse);
+		buttonLayout->addWidget(mBtnOpen);
+		buttonsWidget->setLayout(buttonLayout);
+		
+		QVBoxLayout* centralLayout = new QVBoxLayout(this);
+		centralLayout->setMargin(0);
+		centralLayout->addWidget(mListWidget);
+		centralLayout->addWidget(buttonsWidget);
+		setLayout(centralLayout);
+
+		for(int i = 0; i < gEditorPrefs().getNumRecentlyUsedProjects(); i++)
+			mListWidget->insertItem(i, gEditorPrefs().getRecentlyUsedProjectPath(i));
+
 		retranslateUi();
+		setupSignals();
 	}
 
 	void QtProjectSelection::retranslateUi()
 	{
+		setWindowTitle(tr("Project selection"));
+		mBtnNew->setText(tr("New"));
+		mBtnBrowse->setText(tr("Browse"));
+		mBtnOpen->setText(tr("Open"));
+	}
+
+	void QtProjectSelection::setupSignals()
+	{
+		connect(mBtnNew, SIGNAL(clicked()), this, SLOT(newProject()));
+		connect(mBtnBrowse, SIGNAL(clicked()), this, SLOT(browseProject()));
+		connect(mBtnOpen, SIGNAL(clicked()), this, SLOT(openSelectedProject()));
+	}
+
+	void QtProjectSelection::newProject()
+	{
+		QtNewProject newProject;
+		newProject.exec();
+	}
+
+	void QtProjectSelection::browseProject()
+	{
+		QFileDialog dialog(this, tr("Select project directory"));
+		dialog.setFileMode(QFileDialog::Directory);
+		dialog.setOption(QFileDialog::ShowDirsOnly, true);
+
+		QDir lastUsedDir = gEditorPrefs().getLastUsedProjectDirectory();
+		if(lastUsedDir.exists())
+			dialog.setDirectory(lastUsedDir);
+
+		if(dialog.exec())
+		{
+			QStringList fileNames = dialog.selectedFiles();
+
+			if(fileNames.size() > 0)
+			{
+				openProject(fileNames[0]);
+			}
+		}
+	}
+
+	void QtProjectSelection::openSelectedProject()
+	{
+		QListWidgetItem* item = mListWidget->currentItem();
+
+		if(item == nullptr)
+		{
+			QMessageBox msgBox;
+			msgBox.setWindowTitle("Error");
+			msgBox.setText("Please select a project before continuing.");
+			msgBox.exec();
+
+			return;
+		}
+
+		openProject(item->text());
+	}
+
+	void QtProjectSelection::openProject(const QString& path)
+	{
+		if(gEditorApp().isValidProjectDirectory(path))
+		{
+			addRecentlyUsedProject(path);
+			gEditorPrefs().setLastUsedProjectDirectory(path);
+			onProjectSelected(path);
+			close();
+		}
+		else
+		{		
+			removeRecentlyUsedProject(path);
 
+			QMessageBox msgBox;
+			msgBox.setWindowTitle("Error");
+			msgBox.setText("Selected directory doesn't contain a valid Camelot project");
+			msgBox.exec();
+
+			return;
+		}
+	}
+
+	void QtProjectSelection::addRecentlyUsedProject(const QString& path)
+	{
+		bool found = false;
+		for(int i = 0; i < gEditorPrefs().getNumRecentlyUsedProjects(); i++)
+		{
+			if(path == gEditorPrefs().getRecentlyUsedProjectPath(i))
+			{
+				found = true;
+				break;
+			}
+		}
+
+		gEditorPrefs().addRecentlyUsedProjectPath(path);
+	}
+
+	void QtProjectSelection::removeRecentlyUsedProject(const QString& path)
+	{
+		for(int i = 0; i < gEditorPrefs().getNumRecentlyUsedProjects(); i++)
+		{
+			if(path == gEditorPrefs().getRecentlyUsedProjectPath(i))
+			{
+				gEditorPrefs().removeRecentlyUsedProjectPath(i);
+				break;
+			}
+		}
 	}
 }

+ 3 - 4
CamelotEditor/Source/main.cpp

@@ -10,10 +10,9 @@ int CALLBACK WinMain(
 	_In_  int nCmdShow
 	)
 {
-	EditorApplication app;
-	app.startUp();
+	gEditorApp().startUp();
 
-	app.run();
+	gEditorApp().run();
 
-	app.shutDown();
+	gEditorApp().shutDown();
 }

+ 1 - 1
Dependencies.txt

@@ -81,7 +81,7 @@ Compiling Qt using MSVC2012 compiler:
      preprocessed by MOC, and MOC output needs to be compiled with the project
   2. Example command line for preprocessing a single file: 
     "$(QTDIR)\bin\moc.exe"  ".\Include\CmQtEditor.h" -o ".\GeneratedFiles\moc_CmQtEditor.cpp"  
-	-DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL  "-I.\GeneratedFiles" "-I.\Include" "-I.\Dependencies\Include"
+	-DUNICODE -DWIN32 -DQT_NO_KEYWORDS -DQT_LARGEFILE_SUPPORT -DQT_DLL  "-I.\GeneratedFiles" "-I.\Include" "-I.\Dependencies\Include"
 	"-I.\..\CamelotRenderer\Include" "-I.\..\CamelotUtility\Include" "-I.\..\Dependencies\Include"
   3. (Optional step) With Visual Studio you can set up a custom build set so this is done automatically
   4. (Optional step) Qt also provides a Visual Studio Add-In that handles MOC for your, although it is currently very buggy with VS2012 so I do not use it.

+ 5 - 1
TODOEditor.txt

@@ -21,4 +21,8 @@ TODO for next few days:
    - Their layout data gets saved
    - The way I handle editor windows at the moment is pretty weird with alot of custom handling for resize/move
      - Attempt to get rid of that or at least dont use it until I have window look more fleshed out
- - Make sure entire interface is skinnable
+	 - Look at QSizeGrip for resizing
+	 - QStackWidget (or QStackLayout) for stacking and tabbed windows
+ - Make sure entire interface is skinnable
+ - Create a generic "Prefs" system that supports arrays and loading/saving to ini files
+   - Using EditorPrefs is too cumbersome and it won't allow extensions to use it anyway