Permalink
Browse files

Update other keybinding views when keybinding is set somewhere else

  • Loading branch information...
1 parent 471ee1a commit a25add42cc3f441730a5e350e6a8027c556d58b8 @DolceTriade DolceTriade committed Feb 16, 2016
Showing with 15 additions and 1 deletion.
  1. +15 −1 src/cgame/rocket/rocketKeyBinder.h
@@ -42,6 +42,10 @@ Maryland 20850 USA.
#define DEFAULT_BINDING 0
+static const Rocket::Core::String KEY_SET_EVENT = "key_set_event";
+static const Rocket::Core::String KEY_TEAM = "team";
+static const Rocket::Core::String KEY_KEY = "key";
+
class RocketKeyBinder : public Rocket::Core::Element, public Rocket::Core::EventListener
{
public:
@@ -73,6 +77,7 @@ class RocketKeyBinder : public Rocket::Core::Element, public Rocket::Core::Event
context = GetContext();
context->AddEventListener( "mousemove", this );
context->AddEventListener( "keydown", this );
+ context->AddEventListener( KEY_SET_EVENT, this );
}
}
@@ -83,6 +88,7 @@ class RocketKeyBinder : public Rocket::Core::Element, public Rocket::Core::Event
{
context->RemoveEventListener( "mousemove", this );
context->RemoveEventListener( "keydown", this );
+ context->RemoveEventListener( KEY_SET_EVENT, this );
context = nullptr;
}
}
@@ -99,7 +105,11 @@ class RocketKeyBinder : public Rocket::Core::Element, public Rocket::Core::Event
void ProcessEvent( Rocket::Core::Event &event )
{
Element::ProcessEvent( event );
- if ( !waitingForKeypress && event == "mousedown" && event.GetTargetElement() == this )
+ if ( event == KEY_SET_EVENT )
+ {
+ dirty_key = true;
+ }
+ else if ( !waitingForKeypress && event == "mousedown" && event.GetTargetElement() == this )
{
waitingForKeypress = true;
SetInnerRML( "Enter desired key..." );
@@ -166,6 +176,10 @@ class RocketKeyBinder : public Rocket::Core::Element, public Rocket::Core::Event
key = newKey;
dirty_key = true;
waitingForKeypress = false;
+ Rocket::Core::Dictionary dict;
+ dict.Set( KEY_TEAM, team );
+ dict.Set( KEY_KEY, key );
+ DispatchEvent( KEY_SET_EVENT, dict );
}
int GetTeam( Rocket::Core::String team )

0 comments on commit a25add4

Please sign in to comment.