Disable user template editing if directory not writable
This commit is contained in:
parent
28f96e91c2
commit
374d836154
|
@ -41,7 +41,7 @@
|
||||||
"url": "https://github.com/jackoalan/LibCommon",
|
"url": "https://github.com/jackoalan/LibCommon",
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"head": "dew",
|
"head": "dew",
|
||||||
"ref": "7d35c8ce1ee944a3430325ec733b550de48afa12"
|
"ref": "9b9d4df6477cc9a9e08359e0eea1ceb82f49f1c0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "lzo",
|
"name": "lzo",
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
using namespace tinyxml2;
|
using namespace tinyxml2;
|
||||||
TString gDataDir;
|
TString gDataDir;
|
||||||
|
bool gResourcesWritable = false;
|
||||||
|
bool gTemplatesWritable = false;
|
||||||
CResourceStore *gpResourceStore = nullptr;
|
CResourceStore *gpResourceStore = nullptr;
|
||||||
CResourceStore *gpEditorStore = nullptr;
|
CResourceStore *gpEditorStore = nullptr;
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
extern TString gDataDir;
|
extern TString gDataDir;
|
||||||
|
extern bool gResourcesWritable;
|
||||||
|
extern bool gTemplatesWritable;
|
||||||
extern CResourceStore *gpResourceStore;
|
extern CResourceStore *gpResourceStore;
|
||||||
extern CResourceStore *gpEditorStore;
|
extern CResourceStore *gpEditorStore;
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,16 @@ CPropertyView::CPropertyView(QWidget *pParent)
|
||||||
mpShowNameValidityAction->setChecked(false);
|
mpShowNameValidityAction->setChecked(false);
|
||||||
connect(mpShowNameValidityAction, SIGNAL(triggered(bool)), this, SLOT(ToggleShowNameValidity(bool)));
|
connect(mpShowNameValidityAction, SIGNAL(triggered(bool)), this, SLOT(ToggleShowNameValidity(bool)));
|
||||||
|
|
||||||
mpEditTemplateAction = new QAction("Edit template", this);
|
if (gTemplatesWritable)
|
||||||
connect(mpEditTemplateAction, SIGNAL(triggered()), this, SLOT(EditPropertyTemplate()));
|
{
|
||||||
|
mpEditTemplateAction = new QAction("Edit template", this);
|
||||||
|
connect(mpEditTemplateAction, SIGNAL(triggered()), this, SLOT(EditPropertyTemplate()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mpEditTemplateAction = new QAction("Template files not writable", this);
|
||||||
|
mpEditTemplateAction->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
mpGenNamesForPropertyAction = new QAction("Generate names for this property", this);
|
mpGenNamesForPropertyAction = new QAction("Generate names for this property", this);
|
||||||
mpGenNamesForSiblingsAction = new QAction(this); // Text set in CreateContextMenu()
|
mpGenNamesForSiblingsAction = new QAction(this); // Text set in CreateContextMenu()
|
||||||
|
|
|
@ -989,7 +989,8 @@ void CResourceBrowser::ImportAssetNameMap()
|
||||||
|
|
||||||
void CResourceBrowser::ExportAssetNames()
|
void CResourceBrowser::ExportAssetNames()
|
||||||
{
|
{
|
||||||
QString OutFile = UICommon::SaveFileDialog(this, "Export asset name map", "*.xml", *(gDataDir + "resources/gameinfo/"));
|
QString OutFile = UICommon::SaveFileDialog(this, "Export asset name map", "*.xml",
|
||||||
|
gResourcesWritable ? *(gDataDir + "resources/gameinfo/") : "");
|
||||||
if (OutFile.isEmpty()) return;
|
if (OutFile.isEmpty()) return;
|
||||||
TString OutFileStr = TO_TSTRING(OutFile);
|
TString OutFileStr = TO_TSTRING(OutFile);
|
||||||
|
|
||||||
|
|
|
@ -190,7 +190,10 @@ CWorldEditor::CWorldEditor(QWidget *parent)
|
||||||
|
|
||||||
connect(ui->ActionEditTweaks, SIGNAL(triggered()), mpTweakEditor, SLOT(show()));
|
connect(ui->ActionEditTweaks, SIGNAL(triggered()), mpTweakEditor, SLOT(show()));
|
||||||
connect(ui->ActionEditLayers, SIGNAL(triggered()), this, SLOT(EditLayers()));
|
connect(ui->ActionEditLayers, SIGNAL(triggered()), this, SLOT(EditLayers()));
|
||||||
connect(ui->ActionGeneratePropertyNames, SIGNAL(triggered()), mpGeneratePropertyNamesDialog, SLOT(show()));
|
if (gTemplatesWritable)
|
||||||
|
connect(ui->ActionGeneratePropertyNames, SIGNAL(triggered()), mpGeneratePropertyNamesDialog, SLOT(show()));
|
||||||
|
else
|
||||||
|
ui->ActionGeneratePropertyNames->setEnabled(false);
|
||||||
|
|
||||||
connect(ui->ActionDrawWorld, SIGNAL(triggered()), this, SLOT(ToggleDrawWorld()));
|
connect(ui->ActionDrawWorld, SIGNAL(triggered()), this, SLOT(ToggleDrawWorld()));
|
||||||
connect(ui->ActionDrawObjects, SIGNAL(triggered()), this, SLOT(ToggleDrawObjects()));
|
connect(ui->ActionDrawObjects, SIGNAL(triggered()), this, SLOT(ToggleDrawObjects()));
|
||||||
|
|
|
@ -103,8 +103,10 @@ public:
|
||||||
if (!Initialized) UICommon::ErrorMsg(0, "Couldn't open log file. Logging will not work for this session.");
|
if (!Initialized) UICommon::ErrorMsg(0, "Couldn't open log file. Logging will not work for this session.");
|
||||||
qInstallMessageHandler(QtLogRedirect);
|
qInstallMessageHandler(QtLogRedirect);
|
||||||
|
|
||||||
// Locate data directory
|
// Locate data directory and check write permissions
|
||||||
gDataDir = LocateDataDirectory();
|
gDataDir = LocateDataDirectory();
|
||||||
|
gResourcesWritable = FileUtil::IsDirectoryWritable(gDataDir + "resources");
|
||||||
|
gTemplatesWritable = FileUtil::IsDirectoryWritable(gDataDir + "templates");
|
||||||
|
|
||||||
// Create editor resource store
|
// Create editor resource store
|
||||||
gpEditorStore = new CResourceStore(gDataDir + "resources/");
|
gpEditorStore = new CResourceStore(gDataDir + "resources/");
|
||||||
|
|
Loading…
Reference in New Issue