00001 #ifndef CSHADEREDITOR_H 00002 #define CSHADEREDITOR_H 00003 00004 /****************************************************************************\ 00005 * REQUIRED HEADERS * 00006 \****************************************************************************/ 00007 00008 //QT 00009 #include <QWidget> 00010 #include <QSettings> 00011 //OWN 00012 #include "ui_CShaderEditor.h" 00013 #include "Definitions.h" 00014 #include "Memory/mmgr.h" 00015 00016 #include "CShaderFile.h" 00017 00018 /****************************************************************************\ 00019 * DEFINITIONS * 00020 \****************************************************************************/ 00021 00022 class QMessageBox; 00023 class QFileDialog; 00024 class VStudio; 00025 00026 /****************************************************************************\ 00027 * CLASS * 00028 \****************************************************************************/ 00029 class CShaderEditor : public QWidget 00030 { 00031 Q_OBJECT 00032 00033 /**************************************************************************\ 00034 * PUBLIC CLASS FUNCTIONS * 00035 \**************************************************************************/ 00036 public: 00037 00038 CShaderEditor(VStudio * const control,QWidget *parent = 0); 00039 ~CShaderEditor(); 00040 00041 bool OpenAndApplyVertex(); 00042 bool OpenAndApplyFragment(); 00043 bool LoadVertex(QString & fileName); 00044 bool LoadFragment(QString & fileName); 00045 void setValidatorPath(QString path){validatorPath = path;} 00046 void setEditor(QString & path,QStringList & args){editorPath = path; editorArgs = args;} 00047 00048 QString getValidatorPath(){return validatorPath;} 00049 QString getEditor(){return editorPath;} 00050 QStringList getEditorArgs(){return editorArgs;} 00051 00052 void SaveState(QSettings & sceneFile); 00053 void OpenState(QSettings & sceneFile); 00054 void ResetState(); 00055 00056 /**************************************************************************\ 00057 * PRIVATE CLASS FUNCTIONS * 00058 \**************************************************************************/ 00059 private: 00060 00061 QString ShowOpenDialog(); 00062 QString ShowSaveDialog(); 00063 bool ShowQuestionDialog(); 00064 00065 bool OpenShader(); 00066 bool LoadShader(QString & fileName); 00067 bool SaveShader(); 00068 QString Validate(QString & shaderText); 00069 void EditInEditor(); 00070 void Fetch(); 00071 void Attach(); 00072 void Detach(); 00073 void Close(); 00074 00075 void AddShaderTab(CShaderFile *); 00076 void ResetUI(); 00077 void SetShaderStatus(); 00078 void AppendOutput(QString &action,QString &content); 00079 00080 void logShaderLoadResult(); 00081 void logShaderSaveResult(); 00082 00083 void SetFileEdit(bool enable); 00084 00085 /**************************************************************************\ 00086 * PRIVATE CLASS MEMBERS * 00087 \**************************************************************************/ 00088 00089 Ui::CShaderEditorClass ui; 00090 00091 //Dialogs 00092 QMessageBox * pQuestionSave; 00093 QFileDialog * pOpenSaveDialog; 00094 00095 //Shaderfiles in Tabs 00096 QList<CShaderFile *> shaderList; 00097 //Current shaderFile 00098 CShaderFile * pCSFile; 00099 00100 short shaderLoadResult; 00101 short shaderSaveResult; 00102 00103 QString validatorPath; 00104 QString editorPath; 00105 00106 QStringList editorArgs; 00107 QString editStringSent; 00108 00109 //reference to vStudio 00110 VStudio * pControl; 00111 00112 bool documentModified; 00113 QString lastShaderFilePath; 00114 00115 /**************************************************************************\ 00116 * PRIVATE SLOTS * 00117 \**************************************************************************/ 00118 private slots: 00119 00120 void on_close_btn_clicked(); 00121 void on_open_fragment_released(); 00122 void on_open_vertex_released(); 00123 void on_new_fragment_released(); 00124 void on_new_Vertex_released(); 00125 00126 void FileModified(); 00127 void on_tabWidget_currentChanged(int); 00128 00129 void on_detach_btn_released(); 00130 void on_attach_btn_released(); 00131 void on_validate_btn_released(); 00132 void on_save_btn_released(); 00133 void on_fetch_btn_released(); 00134 void on_edit_btn_released(); 00135 }; 00136 00137 #endif // CSHADEREDITOR_H