Split save into Save and Save As
parent
a7550bc8bb
commit
229649a961
|
@ -17,6 +17,7 @@ Project *NBEFileFormat::read(const std::string &filename, Project *project)
|
|||
} else {
|
||||
merging = false;
|
||||
project = new Project();
|
||||
project->file = std::string(filename);
|
||||
}
|
||||
SimpleFileCombiner fc;
|
||||
std::list<std::string> files = fc.read(filename.c_str(), tmpdir);
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
#include "../util/string.hpp"
|
||||
#include "../util/filesys.hpp"
|
||||
|
||||
void save_file(FileFormat *writer, EditorState *state, std::string file)
|
||||
void save_file(FileFormat *writer, EditorState *state, std::string file, bool check_ext)
|
||||
{
|
||||
if (!writer || !state)
|
||||
return;
|
||||
|
||||
std::string after(file);
|
||||
|
||||
if (after.find('.') == std::string::npos) {
|
||||
if (check_ext && after.find('.') == std::string::npos) {
|
||||
after += '.';
|
||||
after += writer->getExtension();
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "../common.hpp"
|
||||
#include "FileFormat.hpp"
|
||||
|
||||
void save_file(FileFormat *writer, EditorState *state, std::string file);
|
||||
void save_file(FileFormat *writer, EditorState *state, std::string file, bool check_ext=true);
|
||||
|
||||
void export_textures(std::string dir, EditorState *state);
|
||||
|
||||
|
|
|
@ -36,7 +36,8 @@ void MenuState::init()
|
|||
submenu = menubar->getSubMenu(0);
|
||||
//submenu->addItem(L"New", GUI_FILE_NEW_PROJECT);
|
||||
submenu->addItem(L"Open Project", GUI_FILE_OPEN_PROJECT);
|
||||
submenu->addItem(L"Save Project As", GUI_FILE_SAVE_PROJECT);
|
||||
submenu->addItem(L"Save Project", GUI_FILE_SAVE_PROJECT);
|
||||
submenu->addItem(L"Save Project As", GUI_FILE_SAVE_PROJECT_AS);
|
||||
submenu->addSeparator();
|
||||
submenu->addItem(L"Run in Minetest", GUI_FILE_RUN_IN_MINETEST);
|
||||
submenu->addItem(L"Export", -1, true, true);
|
||||
|
@ -45,7 +46,7 @@ void MenuState::init()
|
|||
submenu->addItem(L"Exit", GUI_FILE_EXIT);
|
||||
|
||||
// File > Export
|
||||
submenu = submenu->getSubMenu(4);
|
||||
submenu = submenu->getSubMenu(5);
|
||||
submenu->addItem(L"Standalone Lua File (.lua)", GUI_FILE_EXPORT_LUA);
|
||||
submenu->addItem(L"Voxelands (.cpp)", GUI_FILE_EXPORT_CPP);
|
||||
submenu->addItem(L"Minetest Mod", GUI_FILE_EXPORT_MOD);
|
||||
|
@ -98,7 +99,8 @@ void MenuState::init()
|
|||
sidebar->setNotClipped(true);
|
||||
}
|
||||
|
||||
bool MenuState::OnEvent(const SEvent& event){
|
||||
bool MenuState::OnEvent(const SEvent& event)
|
||||
{
|
||||
if (dialog)
|
||||
return dialog->OnEvent(event);
|
||||
|
||||
|
@ -138,6 +140,19 @@ bool MenuState::OnEvent(const SEvent& event){
|
|||
FileDialog_open_project(state);
|
||||
return true;
|
||||
case GUI_FILE_SAVE_PROJECT:
|
||||
if (!state->project) {
|
||||
state->device->getGUIEnvironment()->addMessageBox(
|
||||
L"Unable to save",
|
||||
L"You have not yet opened a project.");
|
||||
return true;
|
||||
}
|
||||
if (state->project->file != "") {
|
||||
save_file(getFromType(FILE_FORMAT_NBE, state), state, state->project->file, false);
|
||||
} else {
|
||||
FileDialog_save_project(state);
|
||||
}
|
||||
return true;
|
||||
case GUI_FILE_SAVE_PROJECT_AS:
|
||||
if (!state->project) {
|
||||
state->device->getGUIEnvironment()->addMessageBox(
|
||||
L"Unable to save",
|
||||
|
@ -243,7 +258,11 @@ bool MenuState::OnEvent(const SEvent& event){
|
|||
L"You have not yet opened a project.");
|
||||
return true;
|
||||
}
|
||||
FileDialog_save_project(state);
|
||||
if (state->project->file != "") {
|
||||
save_file(getFromType(FILE_FORMAT_NBE, state), state, state->project->file, false);
|
||||
} else {
|
||||
FileDialog_save_project(state);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ enum GUI_ID
|
|||
GUI_FILE_NEW_ITEM,
|
||||
GUI_FILE_OPEN_PROJECT,
|
||||
GUI_FILE_SAVE_PROJECT,
|
||||
GUI_FILE_SAVE_PROJECT_AS,
|
||||
GUI_FILE_RUN_IN_MINETEST,
|
||||
GUI_FILE_EXPORT_LUA,
|
||||
GUI_FILE_EXPORT_CPP,
|
||||
|
|
Loading…
Reference in New Issue