From f8d22e47ac3b6392d68f1a8a45383798f5751101 Mon Sep 17 00:00:00 2001 From: Chuck Miller Date: Sat, 13 Nov 2010 17:00:46 -0500 Subject: Replace config listeners with the event system Reviewed-by: Jared Adams --- src/localplayer.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/localplayer.cpp') diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 79f814a3..4aec2399 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -91,15 +91,14 @@ LocalPlayer::LocalPlayer(int id, int subtype): mUpdateName = true; - config.addListener("showownname", this); setShowName(config.getValue("showownname", 1)); + listen(CHANNEL_CONFIG); listen(CHANNEL_ACTORSPRITE); } LocalPlayer::~LocalPlayer() { - config.removeListener("showownname", this); } void LocalPlayer::logic() @@ -1076,14 +1075,6 @@ void LocalPlayer::addMessageToQueue(const std::string &message, int color) mMessages.push_back(MessagePair(message, color)); } -void LocalPlayer::optionChanged(const std::string &value) -{ - if (value == "showownname") - { - setShowName(config.getValue("showownname", 1)); - } -} - void LocalPlayer::event(Channels channel, const Mana::Event &event) { if (channel == CHANNEL_ACTORSPRITE) @@ -1112,6 +1103,15 @@ void LocalPlayer::event(Channels channel, const Mana::Event &event) } } } + else if (channel == CHANNEL_CONFIG) + { + if (event.getName() == EVENT_CONFIGOPTIONCHANGED && + event.getString("option") == "showownname") + { + setShowName(config.getValue("showownname", 1)); + } + + } Being::event(channel, event); } -- cgit v1.2.3-70-g09d2