mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Update status according the play state
This commit is contained in:
parent
1e40bd09ba
commit
1be8f5e422
@ -5,6 +5,9 @@ use conrod_core::{
|
||||
|
||||
use super::{img_ids::Imgs, settings_window::SettingsTab, Fonts, TEXT_COLOR};
|
||||
|
||||
#[cfg(feature = "discord")]
|
||||
use crate::{discord, discord_instance};
|
||||
|
||||
widget_ids! {
|
||||
struct Ids {
|
||||
esc_bg,
|
||||
@ -150,6 +153,14 @@ impl<'a> Widget for EscMenu<'a> {
|
||||
.set(state.ids.menu_button_5, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
#[cfg(feature = "discord")]
|
||||
{
|
||||
match discord_instance.lock() {
|
||||
Ok(mut disc) => discord::send_menu(&mut disc),
|
||||
Err(e) => log::error!("couldn't send Update to discord: {}", e),
|
||||
}
|
||||
}
|
||||
|
||||
return Some(Event::Logout);
|
||||
};
|
||||
// Quit
|
||||
|
@ -41,6 +41,9 @@ use specs::Join;
|
||||
use std::collections::VecDeque;
|
||||
use vek::*;
|
||||
|
||||
#[cfg(feature = "discord")]
|
||||
use crate::{discord, discord_instance};
|
||||
|
||||
const XP_COLOR: Color = Color::Rgba(0.59, 0.41, 0.67, 1.0);
|
||||
const TEXT_COLOR: Color = Color::Rgba(1.0, 1.0, 1.0, 1.0);
|
||||
const TEXT_COLOR_2: Color = Color::Rgba(0.0, 0.0, 0.0, 1.0);
|
||||
@ -681,7 +684,17 @@ impl Hud {
|
||||
self.show.want_grab = false;
|
||||
self.force_ungrab = true;
|
||||
}
|
||||
Some(esc_menu::Event::Logout) => events.push(Event::Logout),
|
||||
Some(esc_menu::Event::Logout) => {
|
||||
events.push(Event::Logout);
|
||||
|
||||
#[cfg(feature = "discord")]
|
||||
{
|
||||
match discord_instance.lock() {
|
||||
Ok(mut disc) => discord::send_menu(&mut disc),
|
||||
Err(e) => log::error!("couldn't send Update to discord: {}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(esc_menu::Event::Quit) => events.push(Event::Quit),
|
||||
Some(esc_menu::Event::CharacterSelection) => events.push(Event::CharacterSelection),
|
||||
None => {}
|
||||
|
@ -8,6 +8,9 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
#[cfg(feature = "discord")]
|
||||
use crate::{discord, discord_instance};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
// Error parsing input string or error resolving host name.
|
||||
@ -54,6 +57,24 @@ impl ClientInit {
|
||||
Ok(mut client) => {
|
||||
client.register(player);
|
||||
let _ = tx.send(Ok(client));
|
||||
|
||||
#[cfg(feature = "discord")]
|
||||
{
|
||||
match discord_instance.lock() {
|
||||
Ok(mut disc) => {
|
||||
if !server_address.eq("127.0.0.1") {
|
||||
discord::send_singleplayer(&mut disc);
|
||||
disc.tx.send(discord::DiscordUpdate::Details(
|
||||
server_address,
|
||||
));
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("couldn't send Update to discord: {}", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
Err(err) => {
|
||||
|
@ -10,6 +10,9 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
#[cfg(feature = "discord")]
|
||||
use crate::{discord, discord_instance};
|
||||
|
||||
const TPS: u64 = 30;
|
||||
|
||||
enum Msg {
|
||||
@ -66,6 +69,14 @@ fn run_server(mut server: Server, rec: Receiver<Msg>) {
|
||||
|
||||
// Set up an fps clock
|
||||
let mut clock = Clock::start();
|
||||
|
||||
#[cfg(feature = "discord")]
|
||||
{
|
||||
match discord_instance.lock() {
|
||||
Ok(mut disc) => discord::send_singleplayer(&mut disc),
|
||||
Err(e) => log::error!("couldn't send Update to discord: {}", e),
|
||||
}
|
||||
}
|
||||
|
||||
loop {
|
||||
let events = server
|
||||
|
Loading…
Reference in New Issue
Block a user