From 72085b320a057845ff9a166a0dd472575cd4f1c9 Mon Sep 17 00:00:00 2001 From: Austin Hellyer Date: Fri, 18 Nov 2016 16:42:02 -0800 Subject: Add Context::set_game_name --- src/client/context.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/client/context.rs b/src/client/context.rs index 5dd3053..4811748 100644 --- a/src/client/context.rs +++ b/src/client/context.rs @@ -1218,6 +1218,24 @@ impl Context { .set_presence(game, OnlineStatus::Online, false); } + /// Set the current game, passing in only its name. This will automatically + /// set the current user's [`OnlineStatus`] to [`Online`], and its + /// [`GameType`] as [`Playing`]. + /// + /// Pass `None` to remove the current user's current game. + /// + /// [`GameType`]: ../model/enum.GameType.html + /// [`Online`]: ../model/enum.OnlineStatus.html#variant.Online + /// [`OnlineStatus`]: ../model/enum.OnlineStatus.html + /// [`Playing`]: ../model/enum.GameType.html#variant.Playing + pub fn set_game_name(&self, game: Option<&str>) { + self.connection.lock() + .unwrap() + .set_presence(game.map(|x| Game::playing(x.to_owned())), + OnlineStatus::Online, + false); + } + pub fn set_presence(&self, game: Option, status: OnlineStatus, -- cgit v1.2.3