mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
fixed the chat
This commit is contained in:
parent
68c52dd5ef
commit
8f23204eef
|
@ -1,3 +1,9 @@
|
|||
#include <string.h> // strcmp
|
||||
|
||||
extern "C" {
|
||||
#include <engine/e_console.h>
|
||||
}
|
||||
|
||||
#include <engine/e_client_interface.h>
|
||||
#include <game/generated/g_protocol.hpp>
|
||||
#include <game/generated/gc_data.hpp>
|
||||
|
@ -17,6 +23,35 @@ void CHAT::on_reset()
|
|||
}
|
||||
|
||||
|
||||
|
||||
void CHAT::con_say(void *result, void *user_data)
|
||||
{
|
||||
((CHAT*)user_data)->say(0, console_arg_string(result, 0));
|
||||
}
|
||||
|
||||
void CHAT::con_sayteam(void *result, void *user_data)
|
||||
{
|
||||
((CHAT*)user_data)->say(1, console_arg_string(result, 0));
|
||||
}
|
||||
|
||||
void CHAT::con_chat(void *result, void *user_data)
|
||||
{
|
||||
const char *mode = console_arg_string(result, 0);
|
||||
if(strcmp(mode, "all") == 0)
|
||||
((CHAT*)user_data)->enable_mode(0);
|
||||
else if(strcmp(mode, "team") == 0)
|
||||
((CHAT*)user_data)->enable_mode(1);
|
||||
else
|
||||
dbg_msg("console", "expected all or team as mode");
|
||||
}
|
||||
|
||||
void CHAT::on_init()
|
||||
{
|
||||
MACRO_REGISTER_COMMAND("say", "r", con_say, this);
|
||||
MACRO_REGISTER_COMMAND("say_team", "r", con_sayteam, this);
|
||||
MACRO_REGISTER_COMMAND("chat", "s", con_chat, this);
|
||||
}
|
||||
|
||||
bool CHAT::on_input(INPUT_EVENT e)
|
||||
{
|
||||
if(mode == MODE_NONE)
|
||||
|
@ -63,8 +98,6 @@ void CHAT::on_message(int msgtype, void *rawmsg)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CHAT::add_line(int client_id, int team, const char *line)
|
||||
{
|
||||
current_line = (current_line+1)%MAX_LINES;
|
||||
|
@ -176,20 +209,6 @@ void CHAT::on_render()
|
|||
gfx_text_color(1,1,1,1);
|
||||
}
|
||||
|
||||
void con_chat(void *result, void *user_data)
|
||||
{
|
||||
/*
|
||||
const char *mode = console_arg_string(result, 0);
|
||||
if(strcmp(mode, "all") == 0)
|
||||
chat_enable_mode(0);
|
||||
else if(strcmp(mode, "team") == 0)
|
||||
chat_enable_mode(1);
|
||||
else
|
||||
dbg_msg("console", "expected all or team as mode");
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void CHAT::say(int team, const char *line)
|
||||
{
|
||||
// send chat message
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
class CHAT : public COMPONENT
|
||||
{
|
||||
public:
|
||||
LINEINPUT input;
|
||||
|
||||
enum
|
||||
|
@ -34,6 +33,12 @@ public:
|
|||
|
||||
int mode;
|
||||
|
||||
static void con_say(void *result, void *user_data);
|
||||
static void con_sayteam(void *result, void *user_data);
|
||||
static void con_chat(void *result, void *user_data);
|
||||
|
||||
public:
|
||||
|
||||
void add_line(int client_id, int team, const char *line);
|
||||
//void chat_reset();
|
||||
//bool chat_input_handle(INPUT_EVENT e, void *user_data);
|
||||
|
@ -42,6 +47,7 @@ public:
|
|||
|
||||
void say(int team, const char *line);
|
||||
|
||||
virtual void on_init();
|
||||
virtual void on_reset();
|
||||
virtual void on_render();
|
||||
virtual void on_message(int msgtype, void *rawmsg);
|
||||
|
|
Loading…
Reference in a new issue