mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Added SentChatMessages-History (including navigation)
Added Tab-Completion for Main-Commands
Added Tab-Completion for Sub-Commands
Added Tab-Completion for Player-Names [Now finally fixed and working correctly]
Improved some english translations
Improved a lot of german translations
Fixed a few bugs and bad code regarding "default commands"
Development started on a new chat command handling system (Not in use yet)
Fixed some stuff previously noted/criticized by other developers in a previous the code review
Added new Start-Parameter "--playername PLAYERNAME"
Added new Start-Parameter "--randomplayername"
37 lines
1,011 B
C
37 lines
1,011 B
C
#include "chat_command_manager.h"
|
|
#include <string.h>
|
|
|
|
#define MAX_COMMANDS 512
|
|
|
|
typedef struct {
|
|
const char* name;
|
|
bool (*execute)(char* args);
|
|
const char* description;
|
|
} CommandEntry;
|
|
|
|
static CommandEntry sCommands[MAX_COMMANDS];
|
|
static s32 sNumCommands = 0;
|
|
|
|
void register_chat_command(const char* commandName, bool (*execute)(char* args), const char* description) {
|
|
if (sNumCommands < MAX_COMMANDS) {
|
|
sCommands[sNumCommands].name = commandName;
|
|
sCommands[sNumCommands].execute = execute;
|
|
sCommands[sNumCommands].description = description;
|
|
sNumCommands++;
|
|
}
|
|
}
|
|
|
|
bool execute_chat_command(char* commandName, char* args) {
|
|
for (s32 i = 0; i < sNumCommands; i++) {
|
|
if (strcmp(sCommands[i].name, commandName) == 0) {
|
|
return sCommands[i].execute(args);
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void display_all_chat_commands() {
|
|
for (s32 i = 0; i < sNumCommands; i++) {
|
|
djui_chat_message_create(sCommands[i].description);
|
|
}
|
|
}
|