The 'Big Whine' patch:

Any use of a file from another package without a declared dependency will give a warning;

Also added some more _LOCALE_123_ macros so we need less format_string calls

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@753 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-09-24 20:24:22 +00:00
parent efcccb79c4
commit 36a36356c5
51 changed files with 246 additions and 132 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ void KeywordReminderTextValue::store() {
String new_value = untag(value);
// Try to parse the script
vector<ScriptParseError> parse_errors;
ScriptP new_script = parse(new_value, true, parse_errors);
ScriptP new_script = parse(new_value, nullptr, true, parse_errors);
if (parse_errors.empty()) {
// parsed okay, assign
errors.clear();
+3 -3
View File
@@ -356,7 +356,7 @@ AddSymbolPartAction::AddSymbolPartAction(Symbol& symbol, const SymbolPartP& part
{}
String AddSymbolPartAction::getName(bool to_undo) const {
return format_string(_ACTION_("add part"), part->name);
return _ACTION_1_("add part", part->name);
}
void AddSymbolPartAction::perform(bool to_undo) {
@@ -395,7 +395,7 @@ void RemoveSymbolPartsAction::check(SymbolGroup& group, const set<SymbolPartP>&
}
String RemoveSymbolPartsAction::getName(bool to_undo) const {
return format_string(_ACTION_("remove parts"), removals.size() == 1 ? _TYPE_("shape") : _TYPE_("shapes"));
return _ACTION_1_("remove parts", removals.size() == 1 ? _TYPE_("shape") : _TYPE_("shapes"));
}
void RemoveSymbolPartsAction::perform(bool to_undo) {
@@ -433,7 +433,7 @@ DuplicateSymbolPartsAction::DuplicateSymbolPartsAction(Symbol& symbol, const set
}
String DuplicateSymbolPartsAction::getName(bool to_undo) const {
return format_string(_ACTION_("duplicate"), duplications.size() == 1 ? _TYPE_("shape") : _TYPE_("shapes"));
return _ACTION_1_("duplicate", duplications.size() == 1 ? _TYPE_("shape") : _TYPE_("shapes"));
}
void DuplicateSymbolPartsAction::perform(bool to_undo) {
+1 -1
View File
@@ -19,7 +19,7 @@
// ----------------------------------------------------------------------------- : ValueAction
String ValueAction::getName(bool to_undo) const {
return format_string(_ACTION_("change"), valueP->fieldP->name);
return _ACTION_1_("change", valueP->fieldP->name);
}
// ----------------------------------------------------------------------------- : Simple
+1 -1
View File
@@ -31,7 +31,7 @@ String serialize_for_clipboard(Package& package, T& object) {
template <typename T>
void deserialize_from_clipboard(T& object, Package& package, const String& data) {
shared_ptr<wxStringInputStream> stream( new wxStringInputStream(data) );
Reader reader(stream, _("clipboard"));
Reader reader(stream, nullptr, _("clipboard"));
WITH_DYNAMIC_ARG(clipboard_package, &package);
reader.handle_greedy(object);
}
+17 -13
View File
@@ -42,12 +42,12 @@ void Installer::installFrom(const String& filename, bool message_on_success, boo
i.open(filename);
try {
i.install(local);
}
catch (Error& e) {
} catch (const Error& e) {
handle_error(e);
return;
}
if (message_on_success) {
//wxMessageBox(_ERROR_2_("successful install", i.name(), String() << i.packaged.size(),
wxMessageBox(String::Format(_("'%s' successfully installed %d package%s."), i.name().c_str(), i.packages.size(), i.packages.size() == 1 ? _("") : _("s")),
_("Magic Set Editor"), wxOK | wxICON_INFORMATION);
}
@@ -65,15 +65,17 @@ struct dependency_check : public unary_function<bool, PackagedP> {
void Installer::install(bool local) {
// Destination directory
String install_dir = local ? ::packages.getLocalDataDir() : ::packages.getGlobalDataDir();
if (!wxDirExists(install_dir))
if (!wxDirExists(install_dir)) {
wxMkdir(install_dir, 0755);
}
// All the packages we're installing.
vector<PackagedP> new_packages;
FOR_EACH(p, packages) {
if (wxDirExists(install_dir + _("/") + p) || wxFileExists(install_dir + _("/") + p))
if (wxDirExists(install_dir + _("/") + p) || wxFileExists(install_dir + _("/") + p)) {
throw PackageError(_("Package ") + p + _(" is already installed. Overwriting currently not supported."));
}
PackagedP pack;
wxString fn(wxFileName(p).GetExt());
if (fn == _("mse-game")) pack = new_intrusive<Game>();
@@ -90,7 +92,6 @@ void Installer::install(bool local) {
new_packages.push_back(pack);
}
// Check dependencies for each and every package.
FOR_EACH(p, new_packages) {
FOR_EACH(d, p->dependencies) {
@@ -100,28 +101,31 @@ void Installer::install(bool local) {
}
}
}
const FileInfos& file_infos = getFileInfos();
for (FileInfos::const_iterator it = file_infos.begin() ; it != file_infos.end() ; ++it) {
String file = it->first;
wxFileName fn(file);
wxArrayString dirs = fn.GetDirs();
if (fn.IsDir() || !dirs.GetCount() || find(packages.begin(), packages.end(), dirs[0]) == packages.end())
if (fn.IsDir() || !dirs.GetCount() || find(packages.begin(), packages.end(), dirs[0]) == packages.end()) {
continue;
}
String current_dir = install_dir;
for (size_t j = 0; j < dirs.GetCount(); ++j) {
current_dir += _("/") + dirs[j];
if (!wxDirExists(current_dir) && !wxMkdir(current_dir, 0755))
if (!wxDirExists(current_dir) && !wxMkdir(current_dir, 0755)) {
throw PackageError(_("Cannot create folder ") + current_dir + _(" for install. Warning: some packages may have been installed anyway, and some may only be partially installed."));
}
}
InputStreamP is = openIn(file);
wxFileOutputStream os (install_dir + _("/") + file);
if (!os.IsOk())
if (!os.IsOk()) {
throw PackageError(_("Cannot create file ") + install_dir + _("/") + file + _(" for install. Warning: some packages may have been installed anyway, and some may only be partially installed."));
}
os.Write(*is);
}
}
+1 -1
View File
@@ -206,7 +206,7 @@ DECLARE_TYPEOF(map<String COMMA KeyValidator>);
void Locale::validate(Version ver) {
// load locale validator
LocaleValidator v;
Reader r(load_resource_text(_("expected_locale_keys")), _("expected_locale_keys"));
Reader r(load_resource_text(_("expected_locale_keys")), nullptr, _("expected_locale_keys"));
r.handle_greedy(v);
// validate
String errors;
+1 -1
View File
@@ -248,7 +248,7 @@ void Settings::read() {
// settings file not existing is not an error
shared_ptr<wxFileInputStream> file = new_shared1<wxFileInputStream>(filename);
if (!file->Ok()) return; // failure is not an error
Reader reader(file, filename);
Reader reader(file, nullptr, filename);
reader.handle_greedy(*this);
}
}