diff options
author | Chuck Miller <shadowmil@gmail.com> | 2010-11-13 17:00:46 -0500 |
---|---|---|
committer | Chuck Miller <shadowmil@gmail.com> | 2010-11-13 17:39:15 -0500 |
commit | f8d22e47ac3b6392d68f1a8a45383798f5751101 (patch) | |
tree | e29b42821ec8f6e579f2cfd4d2a20bc8c248b930 /src/client.cpp | |
parent | 8e7e63a2473eedd36eeef726e45dacc9d17d157a (diff) | |
download | mana-f8d22e47ac3b6392d68f1a8a45383798f5751101.tar.gz mana-f8d22e47ac3b6392d68f1a8a45383798f5751101.tar.bz2 mana-f8d22e47ac3b6392d68f1a8a45383798f5751101.tar.xz mana-f8d22e47ac3b6392d68f1a8a45383798f5751101.zip |
Replace config listeners with the event system
Reviewed-by: Jared Adams
Diffstat (limited to 'src/client.cpp')
-rw-r--r-- | src/client.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/client.cpp b/src/client.cpp index d584d168..20d85ede 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -450,8 +450,13 @@ Client::Client(const Options &options): // Initialize frame limiting SDL_initFramerate(&mFpsManager); - config.addListener("fpslimit", this); - optionChanged("fpslimit"); + + listen(CHANNEL_CONFIG); + + //TODO: fix having to fake a option changed event + Mana::Event fakeevent(EVENT_CONFIGOPTIONCHANGED); + fakeevent.setString("option", "fpslimit"); + event(CHANNEL_CONFIG, fakeevent); // Initialize PlayerInfo PlayerInfo::init(); @@ -1022,12 +1027,18 @@ int Client::exec() return 0; } -void Client::optionChanged(const std::string &name) +void Client::event(Channels channel, const Mana::Event &event) { - const int fpsLimit = config.getIntValue("fpslimit"); - mLimitFps = fpsLimit > 0; - if (mLimitFps) - SDL_setFramerate(&mFpsManager, fpsLimit); + if (channel == CHANNEL_CONFIG && + event.getName() == EVENT_CONFIGOPTIONCHANGED && + event.getString("option") == "fpslimit") + { + const int fpsLimit = config.getIntValue("fpslimit"); + mLimitFps = fpsLimit > 0; + if (mLimitFps) + SDL_setFramerate(&mFpsManager, fpsLimit); + } + } void Client::action(const gcn::ActionEvent &event) |