diff --git a/aegisub/configure.in b/aegisub/configure.in index 721810803..e1ac47048 100644 --- a/aegisub/configure.in +++ b/aegisub/configure.in @@ -46,6 +46,7 @@ AC_CANONICAL_HOST ########################### build_darwin="no" build_linux="no" +build_bsd="no" build_default="no" AS_CASE([$host], @@ -57,11 +58,13 @@ AS_CASE([$host], AS_CASE([$host], [*-*-darwin*], [build_darwin="yes"; AC_SUBST(DARWIN_ARCH)], [*-*-linux*], [build_linux="yes"], + [*-*-*bsd*], [build_bsd="yes"], [build_default="yes"]) # Used for universalchardet. AC_AGI_MDCPUCFG($host) +AC_SUBST(build_bsd) AC_SUBST(build_linux) AC_SUBST(build_darwin) AC_SUBST(build_default) diff --git a/aegisub/src/preferences.cpp b/aegisub/src/preferences.cpp index dc7b2c22d..d44213e75 100644 --- a/aegisub/src/preferences.cpp +++ b/aegisub/src/preferences.cpp @@ -22,7 +22,6 @@ #ifndef AGI_PRE #include -#include #include #include #include @@ -511,8 +510,11 @@ Advanced_Video::Advanced_Video(wxTreebook *book, Preferences *parent): OptionPag SetSizerAndFit(sizer); } -void Preferences::SetOption(std::string const& name, wxAny value) { - pending_changes[name] = value; +void Preferences::SetOption(agi::OptionValue *new_value) { + std::string name = new_value->GetName(); + if (pending_changes.count(name)) + delete pending_changes[name]; + pending_changes[name] = new_value; if (IsEnabled()) applyButton->Enable(true); } @@ -529,27 +531,28 @@ void Preferences::OnOK(wxCommandEvent &event) { } void Preferences::OnApply(wxCommandEvent &) { - for (std::map::iterator cur = pending_changes.begin(); cur != pending_changes.end(); ++cur) { + for (std::map::iterator cur = pending_changes.begin(); cur != pending_changes.end(); ++cur) { agi::OptionValue *opt = OPT_SET(cur->first); switch (opt->GetType()) { case agi::OptionValue::Type_Bool: - opt->SetBool(cur->second.As()); + opt->SetBool(cur->second->GetBool()); break; case agi::OptionValue::Type_Colour: - opt->SetColour(cur->second.As()); + opt->SetColour(cur->second->GetColour()); break; case agi::OptionValue::Type_Double: - opt->SetDouble(cur->second.As()); + opt->SetDouble(cur->second->GetDouble()); break; case agi::OptionValue::Type_Int: - opt->SetInt(cur->second.As()); + opt->SetInt(cur->second->GetInt()); break; case agi::OptionValue::Type_String: - opt->SetString(cur->second.As()); + opt->SetString(cur->second->GetString()); break; default: throw PreferenceNotSupported("Unsupported type"); } + delete cur->second; } pending_changes.clear(); @@ -616,4 +619,7 @@ Preferences::Preferences(wxWindow *parent): wxDialog(parent, -1, _("Preferences" } Preferences::~Preferences() { + for (std::map::iterator cur = pending_changes.begin(); cur != pending_changes.end(); ++cur) { + delete cur->second; + } } diff --git a/aegisub/src/preferences.h b/aegisub/src/preferences.h index 3d08a8219..2c0d91ce6 100644 --- a/aegisub/src/preferences.h +++ b/aegisub/src/preferences.h @@ -29,9 +29,9 @@ #include -class wxAny; class wxButton; class wxTreebook; +namespace agi { class OptionValue; } DEFINE_BASE_EXCEPTION_NOINNER(PreferencesError, agi::Exception) DEFINE_SIMPLE_EXCEPTION_NOINNER(PreferenceIncorrectType, PreferencesError, "preferences/incorrect_type") @@ -44,7 +44,7 @@ private: wxTreebook *book; wxButton *applyButton; - std::map pending_changes; + std::map pending_changes; std::deque pending_callbacks; void OnOK(wxCommandEvent &event); @@ -55,6 +55,6 @@ public: Preferences(wxWindow *parent); ~Preferences(); - void SetOption(std::string const& name, wxAny value); + void SetOption(agi::OptionValue *new_value); void AddPendingChange(Thunk const& callback); }; diff --git a/aegisub/src/preferences_base.cpp b/aegisub/src/preferences_base.cpp index b0a388bdc..000e68d7a 100644 --- a/aegisub/src/preferences_base.cpp +++ b/aegisub/src/preferences_base.cpp @@ -48,20 +48,20 @@ #include "standard_paths.h" #include "video_provider_manager.h" -#define OPTION_UPDATER(type, evttype, body) \ - class type { \ - std::string name; \ - Preferences *parent; \ - public: \ - type(std::string const& n, Preferences *p) : name(n),parent(p) {} \ - void operator()(evttype& evt) { parent->SetOption(name, body); } \ +#define OPTION_UPDATER(type, evttype, opt, body) \ + class type { \ + std::string name; \ + Preferences *parent; \ + public: \ + type(std::string const& n, Preferences *p) : name(n), parent(p) {} \ + void operator()(evttype& evt) { parent->SetOption(new agi::opt(name, body)); } \ } -OPTION_UPDATER(StringUpdater, wxCommandEvent, STD_STR(evt.GetString())); -OPTION_UPDATER(IntUpdater, wxSpinEvent, evt.GetInt()); -OPTION_UPDATER(IntCBUpdater, wxCommandEvent, evt.GetInt()); -OPTION_UPDATER(DoubleUpdater, wxSpinEvent, evt.GetInt()); -OPTION_UPDATER(BoolUpdater, wxCommandEvent, !!evt.GetInt()); +OPTION_UPDATER(StringUpdater, wxCommandEvent, OptionValueString, STD_STR(evt.GetString())); +OPTION_UPDATER(IntUpdater, wxSpinEvent, OptionValueInt, evt.GetInt()); +OPTION_UPDATER(IntCBUpdater, wxCommandEvent, OptionValueInt, evt.GetInt()); +OPTION_UPDATER(DoubleUpdater, wxSpinEvent, OptionValueDouble, evt.GetInt()); +OPTION_UPDATER(BoolUpdater, wxCommandEvent, OptionValueBool, !!evt.GetInt()); class ColourUpdater { const char *name; Preferences *parent; @@ -70,7 +70,7 @@ public: void operator()(wxCommandEvent& evt) { ColourButton *btn = static_cast(evt.GetClientData()); if (btn) { - parent->SetOption(name, STD_STR(btn->GetColour().GetAsString(wxC2S_CSS_SYNTAX))); + parent->SetOption(new agi::OptionValueColour(name, STD_STR(btn->GetColour().GetAsString(wxC2S_CSS_SYNTAX)))); } else { evt.Skip();