forked from Mirrors/openclonk
Editor: Add "Export packed" file menu item
parent
d77206338c
commit
1cde52e060
|
@ -523,6 +523,7 @@ IDS_MNU_DEFAULTRESOLUTION=Bildschirm
|
||||||
IDS_MNU_DELETE=Löschen
|
IDS_MNU_DELETE=Löschen
|
||||||
IDS_MNU_DUPLICATE=Duplizieren
|
IDS_MNU_DUPLICATE=Duplizieren
|
||||||
IDS_MNU_EXPLOREUSERPATH=Benutzerpfad anzeigen
|
IDS_MNU_EXPLOREUSERPATH=Benutzerpfad anzeigen
|
||||||
|
IDS_MNU_EXPORTSCENARIOPACKED=Gepackt exportieren...
|
||||||
IDS_MNU_FILE=Datei
|
IDS_MNU_FILE=Datei
|
||||||
IDS_MNU_FOCUSGLOBALSCRIPTBOX=Eingabefokus auf Scripteingabe (global)
|
IDS_MNU_FOCUSGLOBALSCRIPTBOX=Eingabefokus auf Scripteingabe (global)
|
||||||
IDS_MNU_FOCUSOBJECTSCRIPTBOX=Eingabefokus auf Scripteingabe (Objekt)
|
IDS_MNU_FOCUSOBJECTSCRIPTBOX=Eingabefokus auf Scripteingabe (Objekt)
|
||||||
|
|
|
@ -523,6 +523,7 @@ IDS_MNU_DEFAULTRESOLUTION=Screen
|
||||||
IDS_MNU_DELETE=Delete
|
IDS_MNU_DELETE=Delete
|
||||||
IDS_MNU_DUPLICATE=Duplicate
|
IDS_MNU_DUPLICATE=Duplicate
|
||||||
IDS_MNU_EXPLOREUSERPATH=Open user path
|
IDS_MNU_EXPLOREUSERPATH=Open user path
|
||||||
|
IDS_MNU_EXPORTSCENARIOPACKED=Pack and export...
|
||||||
IDS_MNU_FILE=File
|
IDS_MNU_FILE=File
|
||||||
IDS_MNU_FOCUSGLOBALSCRIPTBOX=Focus script box (global)
|
IDS_MNU_FOCUSGLOBALSCRIPTBOX=Focus script box (global)
|
||||||
IDS_MNU_FOCUSOBJECTSCRIPTBOX=Focus script box (object)
|
IDS_MNU_FOCUSOBJECTSCRIPTBOX=Focus script box (object)
|
||||||
|
|
|
@ -151,12 +151,33 @@ bool C4Console::SaveGame(const char * path)
|
||||||
return fOkay;
|
return fOkay;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool C4Console::SaveScenario(const char * path)
|
bool C4Console::SaveScenario(const char * path, bool export_packed)
|
||||||
{
|
{
|
||||||
// Open new scenario file
|
C4Group *save_target_group = &Game.ScenarioFile;
|
||||||
if (path)
|
C4Group export_group;
|
||||||
|
if (export_packed)
|
||||||
{
|
{
|
||||||
// Close current scenario file
|
// Export to packed file: Delete existing
|
||||||
|
if (FileExists(path))
|
||||||
|
{
|
||||||
|
if (ItemIdentical(Game.ScenarioFilename, path) || !EraseItem(path))
|
||||||
|
{
|
||||||
|
Message(FormatString(LoadResStr("IDS_CNS_SAVEASERROR"), path).getData());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Write into new, packed copy
|
||||||
|
if (!C4Group_PackDirectoryTo(Game.ScenarioFilename, path) || !export_group.Open(path))
|
||||||
|
{
|
||||||
|
Message(FormatString(LoadResStr("IDS_CNS_SAVEASERROR"), path).getData());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
save_target_group = &export_group;
|
||||||
|
}
|
||||||
|
else if (path)
|
||||||
|
{
|
||||||
|
// Open new scenario file
|
||||||
|
// Close current scenario file to allow re-opening at new path
|
||||||
Game.ScenarioFile.Close();
|
Game.ScenarioFile.Close();
|
||||||
// Copy current scenario file to target
|
// Copy current scenario file to target
|
||||||
if (!C4Group_CopyItem(Game.ScenarioFilename,path))
|
if (!C4Group_CopyItem(Game.ScenarioFilename,path))
|
||||||
|
@ -164,6 +185,7 @@ bool C4Console::SaveScenario(const char * path)
|
||||||
Message(FormatString(LoadResStr("IDS_CNS_SAVEASERROR"),path).getData());
|
Message(FormatString(LoadResStr("IDS_CNS_SAVEASERROR"),path).getData());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Re-open at new path (unless exporting, in which case the export is just a copy)
|
||||||
SCopy(path, Game.ScenarioFilename, _MAX_PATH);
|
SCopy(path, Game.ScenarioFilename, _MAX_PATH);
|
||||||
SetCaptionToFilename(Game.ScenarioFilename);
|
SetCaptionToFilename(Game.ScenarioFilename);
|
||||||
if (!Game.ScenarioFile.Open(Game.ScenarioFilename))
|
if (!Game.ScenarioFile.Open(Game.ScenarioFilename))
|
||||||
|
@ -183,11 +205,11 @@ bool C4Console::SaveScenario(const char * path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can't save to child groups
|
// Can't save to child groups
|
||||||
if (Game.ScenarioFile.GetMother() && Game.ScenarioFile.GetMother()->IsPacked())
|
if (save_target_group->GetMother() && save_target_group->GetMother()->IsPacked())
|
||||||
{
|
{
|
||||||
StdStrBuf str;
|
StdStrBuf str;
|
||||||
str.Format(LoadResStr("IDS_CNS_NOCHILDSAVE"),
|
str.Format(LoadResStr("IDS_CNS_NOCHILDSAVE"),
|
||||||
GetFilename(Game.ScenarioFile.GetName()));
|
GetFilename(save_target_group->GetName()));
|
||||||
Message(str.getData());
|
Message(str.getData());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -197,15 +219,22 @@ bool C4Console::SaveScenario(const char * path)
|
||||||
|
|
||||||
bool fOkay=true;
|
bool fOkay=true;
|
||||||
C4GameSave *pGameSave = new C4GameSaveScenario(!Console.Active || ::Landscape.GetMode() == LandscapeMode::Exact, false);
|
C4GameSave *pGameSave = new C4GameSaveScenario(!Console.Active || ::Landscape.GetMode() == LandscapeMode::Exact, false);
|
||||||
if (!pGameSave->Save(Game.ScenarioFile, false))
|
if (!pGameSave->Save(*save_target_group, false))
|
||||||
{ Out("Game::Save failed"); fOkay=false; }
|
{ Out("Game::Save failed"); fOkay=false; }
|
||||||
delete pGameSave;
|
delete pGameSave;
|
||||||
|
|
||||||
// Close and reopen scenario file to fix file changes
|
// Close and reopen scenario file to fix file changes
|
||||||
if (!Game.ScenarioFile.Close())
|
if (!export_packed)
|
||||||
{ Out("ScenarioFile::Close failed"); fOkay=false; }
|
{
|
||||||
if (!Game.ScenarioFile.Open(Game.ScenarioFilename))
|
if (!Game.ScenarioFile.Close())
|
||||||
{ Out("ScenarioFile::Open failed"); fOkay=false; }
|
{
|
||||||
|
Out("ScenarioFile::Close failed"); fOkay = false;
|
||||||
|
}
|
||||||
|
if (!Game.ScenarioFile.Open(Game.ScenarioFilename))
|
||||||
|
{
|
||||||
|
Out("ScenarioFile::Open failed"); fOkay = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SetCursor(C4ConsoleGUI::CURSOR_Normal);
|
SetCursor(C4ConsoleGUI::CURSOR_Normal);
|
||||||
|
|
||||||
|
@ -215,7 +244,7 @@ bool C4Console::SaveScenario(const char * path)
|
||||||
StdStrBuf str(LoadResStr("IDS_CNS_SCRIPTCREATEDOBJECTS"));
|
StdStrBuf str(LoadResStr("IDS_CNS_SCRIPTCREATEDOBJECTS"));
|
||||||
str += LoadResStr("IDS_CNS_WARNDOUBLE");
|
str += LoadResStr("IDS_CNS_WARNDOUBLE");
|
||||||
Message(str.getData());
|
Message(str.getData());
|
||||||
Game.fScriptCreatedObjects=false;
|
Game.fScriptCreatedObjects = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status report
|
// Status report
|
||||||
|
@ -232,22 +261,27 @@ bool C4Console::FileSave()
|
||||||
return SaveScenario(nullptr);
|
return SaveScenario(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool C4Console::FileSaveAs(bool fSaveGame)
|
bool C4Console::FileSaveAs(bool fSaveGame, bool export_packed)
|
||||||
{
|
{
|
||||||
// Do save-as dialog
|
// Do save-as dialog
|
||||||
StdCopyStrBuf filename("");
|
StdCopyStrBuf filename("");
|
||||||
filename.Copy(Game.ScenarioFile.GetName());
|
filename.Copy(Game.ScenarioFile.GetName());
|
||||||
|
if (export_packed)
|
||||||
|
{
|
||||||
|
RemoveExtension(&filename);
|
||||||
|
filename.Append("_packed.ocs");
|
||||||
|
}
|
||||||
if (!FileSelect(&filename,
|
if (!FileSelect(&filename,
|
||||||
"OpenClonk Scenario\0*.ocs\0\0",
|
"OpenClonk Scenario\0*.ocs\0\0",
|
||||||
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY,
|
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY,
|
||||||
true)) return false;
|
true)) return false;
|
||||||
DefaultExtension(&filename,"ocs");
|
DefaultExtension(&filename,"ocs");
|
||||||
::Config.Developer.AddRecentlyEditedScenario(filename.getData());
|
if (!export_packed) ::Config.Developer.AddRecentlyEditedScenario(filename.getData());
|
||||||
if (fSaveGame)
|
if (fSaveGame)
|
||||||
// Save game
|
// Save game
|
||||||
return SaveGame(filename.getData());
|
return SaveGame(filename.getData());
|
||||||
else
|
else
|
||||||
return SaveScenario(filename.getData());
|
return SaveScenario(filename.getData(), export_packed);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool C4Console::Message(const char *szMessage, bool fQuery)
|
bool C4Console::Message(const char *szMessage, bool fQuery)
|
||||||
|
|
|
@ -73,8 +73,8 @@ public:
|
||||||
void HelpAbout();
|
void HelpAbout();
|
||||||
bool FileSelect(StdStrBuf *sFilename, const char *szFilter, DWORD dwFlags, bool fSave=false);
|
bool FileSelect(StdStrBuf *sFilename, const char *szFilter, DWORD dwFlags, bool fSave=false);
|
||||||
bool SaveGame(const char * path);
|
bool SaveGame(const char * path);
|
||||||
bool SaveScenario(const char * path);
|
bool SaveScenario(const char * path, bool export_packed=false);
|
||||||
bool FileSaveAs(bool fSaveGame);
|
bool FileSaveAs(bool fSaveGame, bool export_packed=false);
|
||||||
bool FileSave();
|
bool FileSave();
|
||||||
bool FileNew();
|
bool FileNew();
|
||||||
bool FileOpen(const char *filename=nullptr, bool host_in_network=false);
|
bool FileOpen(const char *filename=nullptr, bool host_in_network=false);
|
||||||
|
|
|
@ -346,6 +346,7 @@
|
||||||
<addaction name="actionFileSaveScenario"/>
|
<addaction name="actionFileSaveScenario"/>
|
||||||
<addaction name="actionFileSaveScenarioAs"/>
|
<addaction name="actionFileSaveScenarioAs"/>
|
||||||
<addaction name="actionFileSaveGameAs"/>
|
<addaction name="actionFileSaveGameAs"/>
|
||||||
|
<addaction name="actionFileExportScenarioPacked"/>
|
||||||
<addaction name="actionFileReInitScenario"/>
|
<addaction name="actionFileReInitScenario"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionFileClose"/>
|
<addaction name="actionFileClose"/>
|
||||||
|
@ -1259,6 +1260,20 @@
|
||||||
<string comment="res">IDS_MNU_OPENNET</string>
|
<string comment="res">IDS_MNU_OPENNET</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionFileExportScenarioPacked">
|
||||||
|
<property name="text">
|
||||||
|
<string comment="res">IDS_MNU_EXPORTSCENARIOPACKED</string>
|
||||||
|
</property>
|
||||||
|
<property name="iconText">
|
||||||
|
<string comment="res">IDS_MNU_EXPORTSCENARIOPACKED</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string comment="res">IDS_MNU_EXPORTSCENARIOPACKED</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+Shift+E</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="resource.qrc"/>
|
<include location="resource.qrc"/>
|
||||||
|
@ -2016,6 +2031,22 @@
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>actionFileExportScenarioPacked</sender>
|
||||||
|
<signal>triggered()</signal>
|
||||||
|
<receiver>MainWindow</receiver>
|
||||||
|
<slot>FileExportPacked()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>-1</x>
|
||||||
|
<y>-1</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>477</x>
|
||||||
|
<y>312</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<slots>
|
<slots>
|
||||||
<slot>PlayPressed(bool)</slot>
|
<slot>PlayPressed(bool)</slot>
|
||||||
|
@ -2064,5 +2095,6 @@
|
||||||
<slot>GradeUp()</slot>
|
<slot>GradeUp()</slot>
|
||||||
<slot>GradeDown()</slot>
|
<slot>GradeDown()</slot>
|
||||||
<slot>FileOpenInNetwork()</slot>
|
<slot>FileOpenInNetwork()</slot>
|
||||||
|
<slot>FileExportPacked()</slot>
|
||||||
</slots>
|
</slots>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -342,6 +342,7 @@ void C4ConsoleQtMainWindow::FileRecord() { ::Console.FileRecord(); }
|
||||||
void C4ConsoleQtMainWindow::FileSave() { ::Console.FileSave(); }
|
void C4ConsoleQtMainWindow::FileSave() { ::Console.FileSave(); }
|
||||||
void C4ConsoleQtMainWindow::FileSaveAs() { ::Console.FileSaveAs(false); }
|
void C4ConsoleQtMainWindow::FileSaveAs() { ::Console.FileSaveAs(false); }
|
||||||
void C4ConsoleQtMainWindow::FileSaveGameAs() { ::Console.FileSaveAs(true); }
|
void C4ConsoleQtMainWindow::FileSaveGameAs() { ::Console.FileSaveAs(true); }
|
||||||
|
void C4ConsoleQtMainWindow::FileExportPacked() { ::Console.FileSaveAs(false, true); }
|
||||||
void C4ConsoleQtMainWindow::FileClose() { ::Console.FileClose(); }
|
void C4ConsoleQtMainWindow::FileClose() { ::Console.FileClose(); }
|
||||||
void C4ConsoleQtMainWindow::FileQuit() { ::Console.FileQuit(); }
|
void C4ConsoleQtMainWindow::FileQuit() { ::Console.FileQuit(); }
|
||||||
|
|
||||||
|
|
|
@ -135,6 +135,7 @@ public slots:
|
||||||
void FileSave();
|
void FileSave();
|
||||||
void FileSaveAs();
|
void FileSaveAs();
|
||||||
void FileSaveGameAs();
|
void FileSaveGameAs();
|
||||||
|
void FileExportPacked();
|
||||||
void FileClose();
|
void FileClose();
|
||||||
void FileQuit();
|
void FileQuit();
|
||||||
void FileReInitScenario();
|
void FileReInitScenario();
|
||||||
|
|
Loading…
Reference in New Issue