mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-05-09 10:21:50 +00:00
Add keybind to open chat with "/" pre-written
This commit is contained in:
parent
09d29d8e98
commit
1805004135
17 changed files with 87 additions and 14 deletions
|
|
@ -107,6 +107,7 @@ DEADZONE = "Deadzone"
|
|||
RUMBLE_STRENGTH = "Síla vibrace"
|
||||
|
||||
CHAT = "Chat"
|
||||
CHAT_COMMAND = "Chat (Příkaz)"
|
||||
PLAYERS = "Hráči"
|
||||
D_UP = "D-Pad nahoru"
|
||||
D_DOWN = "D-Pad dolů"
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ DEADZONE = "Doode-zone"
|
|||
RUMBLE_STRENGTH = "Rommel Kracht"
|
||||
|
||||
CHAT = "Chat"
|
||||
CHAT_COMMAND = "Chat (Commando)"
|
||||
PLAYERS = "Spelers"
|
||||
D_UP = "D Omhoog"
|
||||
D_DOWN = "D Naar Beneden"
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ DEADZONE = "Deadzone"
|
|||
RUMBLE_STRENGTH = "Rumble Strength"
|
||||
|
||||
CHAT = "Chat"
|
||||
CHAT_COMMAND = "Chat (Command)"
|
||||
PLAYERS = "Players"
|
||||
D_UP = "D-Up"
|
||||
D_DOWN = "D-Down"
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ DEADZONE = "Zone Morte"
|
|||
RUMBLE_STRENGTH = "Vibrations"
|
||||
|
||||
CHAT = "Chat"
|
||||
CHAT_COMMAND = "Chat (Commande)"
|
||||
PLAYERS = "Joueurs"
|
||||
D_UP = "D Haut"
|
||||
D_DOWN = "D Bas"
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ DEADZONE = "Tote Zone"
|
|||
RUMBLE_STRENGTH = "Vibration-Stärke"
|
||||
|
||||
CHAT = "Chat"
|
||||
CHAT_COMMAND = "Chat (Befehl)"
|
||||
PLAYERS = "Spieler"
|
||||
D_UP = "D-Hoch"
|
||||
D_DOWN = "D-Unten"
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ GAMEPAD = "Controller"
|
|||
DEADZONE = "Zona Morta"
|
||||
RUMBLE_STRENGTH = "Intesità Vibrazione"
|
||||
CHAT = "Chat"
|
||||
CHAT_COMMAND = "Chat (Comando)"
|
||||
PLAYERS = "Giocatori"
|
||||
D_UP = "D Su"
|
||||
D_DOWN = "D Giù"
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ DEADZONE = "デッドゾーン"
|
|||
RUMBLE_STRENGTH = "振動の強さ"
|
||||
|
||||
CHAT = "チャット"
|
||||
CHAT_COMMAND = "チャット(コマンド)"
|
||||
PLAYERS = "プレイヤーリストの表示"
|
||||
D_UP = "十字キー 上"
|
||||
D_DOWN = "十字キー 下"
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ DEADZONE = "Martwa Strefa"
|
|||
RUMBLE_STRENGTH = "Siła Wibracji"
|
||||
|
||||
CHAT = "Czat"
|
||||
CHAT_COMMAND = "Czat (Komenda)"
|
||||
PLAYERS = "Gracze"
|
||||
D_UP = "Kierunek w Górę"
|
||||
D_DOWN = "Kierunek w Dół"
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ DEADZONE = "Zona morta"
|
|||
RUMBLE_STRENGTH = "Força de vibração"
|
||||
|
||||
CHAT = "Chat"
|
||||
CHAT_COMMAND = "Chat (Comando)"
|
||||
PLAYERS = "Jogadores"
|
||||
D_UP = "D-Cima"
|
||||
D_DOWN = "D-Baixo"
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ DEADZONE = "Mёртвая зона"
|
|||
RUMBLE_STRENGTH = "Вибрация"
|
||||
|
||||
CHAT = "Чат"
|
||||
CHAT_COMMAND = "Чат (Команда)"
|
||||
PLAYERS = "Игроки"
|
||||
D_UP = "Крестовина вверх"
|
||||
D_DOWN = "Крестовина вниз"
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ DEADZONE = "Zona muerta"
|
|||
RUMBLE_STRENGTH = "Intensidad de vibración"
|
||||
|
||||
CHAT = "Chat"
|
||||
CHAT_COMMAND = "Chat (Comando)"
|
||||
PLAYERS = "Jugadores"
|
||||
D_UP = "Cruz Arriba"
|
||||
D_DOWN = "Cruz Abajo"
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
|
@ -114,6 +117,7 @@ unsigned int configKeyStickDown[MAX_BINDS] = { 0x001F, VK_INVALID, VK
|
|||
unsigned int configKeyStickLeft[MAX_BINDS] = { 0x001E, VK_INVALID, VK_INVALID };
|
||||
unsigned int configKeyStickRight[MAX_BINDS] = { 0x0020, VK_INVALID, VK_INVALID };
|
||||
unsigned int configKeyChat[MAX_BINDS] = { 0x001C, VK_INVALID, VK_INVALID };
|
||||
unsigned int configKeyChatCommand[MAX_BINDS] = { VK_INVALID, VK_INVALID, VK_INVALID };
|
||||
unsigned int configKeyPlayerList[MAX_BINDS] = { 0x000F, 0x1004, VK_INVALID };
|
||||
unsigned int configKeyDUp[MAX_BINDS] = { 0x0147, 0x100b, VK_INVALID };
|
||||
unsigned int configKeyDDown[MAX_BINDS] = { 0x014f, 0x100c, VK_INVALID };
|
||||
|
|
@ -257,6 +261,7 @@ static const struct ConfigOption options[] = {
|
|||
{.name = "key_stickleft", .type = CONFIG_TYPE_BIND, .uintValue = configKeyStickLeft},
|
||||
{.name = "key_stickright", .type = CONFIG_TYPE_BIND, .uintValue = configKeyStickRight},
|
||||
{.name = "key_chat", .type = CONFIG_TYPE_BIND, .uintValue = configKeyChat},
|
||||
{.name = "key_chat_command", .type = CONFIG_TYPE_BIND, .uintValue = configKeyChatCommand},
|
||||
{.name = "key_playerlist", .type = CONFIG_TYPE_BIND, .uintValue = configKeyPlayerList},
|
||||
{.name = "key_dup", .type = CONFIG_TYPE_BIND, .uintValue = configKeyDUp},
|
||||
{.name = "key_ddown", .type = CONFIG_TYPE_BIND, .uintValue = configKeyDDown},
|
||||
|
|
@ -666,6 +671,23 @@ static void configfile_load_internal(const char *filename, bool* error) {
|
|||
if (file == NULL) {
|
||||
// Create a new config file and save defaults
|
||||
printf("Config file '%s' not found. Creating it.\n", filename);
|
||||
// set sensible default for chat command key depending on keyboard layout
|
||||
if (configKeyChatCommand[0] == VK_INVALID && configKeyChatCommand[1] == VK_INVALID && configKeyChatCommand[2] == VK_INVALID) {
|
||||
#ifdef _WIN32
|
||||
HKL hkl = GetKeyboardLayout(0);
|
||||
LANGID lang = LOWORD(hkl);
|
||||
switch (PRIMARYLANGID(lang)) {
|
||||
case LANG_GERMAN:
|
||||
configKeyChatCommand[0] = 0x002B; // '#' on QWERTZ (OEM_5 position)
|
||||
break;
|
||||
default:
|
||||
configKeyChatCommand[0] = 0x0035; // '/' on US QWERTY
|
||||
break;
|
||||
}
|
||||
#else
|
||||
configKeyChatCommand[0] = 0x0035; // '/' default on non-Windows
|
||||
#endif
|
||||
}
|
||||
configfile_save(filename);
|
||||
return;
|
||||
}
|
||||
|
|
@ -777,6 +799,23 @@ NEXT_OPTION:
|
|||
}
|
||||
|
||||
fs_close(file);
|
||||
// If user has no chat command bind yet, set a default based on layout
|
||||
if (configKeyChatCommand[0] == VK_INVALID && configKeyChatCommand[1] == VK_INVALID && configKeyChatCommand[2] == VK_INVALID) {
|
||||
#ifdef _WIN32
|
||||
HKL hkl = GetKeyboardLayout(0);
|
||||
LANGID lang = LOWORD(hkl);
|
||||
switch (PRIMARYLANGID(lang)) {
|
||||
case LANG_GERMAN:
|
||||
configKeyChatCommand[0] = 0x002B; // '#'
|
||||
break;
|
||||
default:
|
||||
configKeyChatCommand[0] = 0x0035; // '/'
|
||||
break;
|
||||
}
|
||||
#else
|
||||
configKeyChatCommand[0] = 0x0035;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (configFramerateMode < 0 || configFramerateMode > RRM_MAX) { configFramerateMode = 0; }
|
||||
if (configFrameLimit < 30) { configFrameLimit = 30; }
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ extern unsigned int configKeyStickDown[MAX_BINDS];
|
|||
extern unsigned int configKeyStickLeft[MAX_BINDS];
|
||||
extern unsigned int configKeyStickRight[MAX_BINDS];
|
||||
extern unsigned int configKeyChat[MAX_BINDS];
|
||||
extern unsigned int configKeyChatCommand[MAX_BINDS];
|
||||
extern unsigned int configKeyPlayerList[MAX_BINDS];
|
||||
extern unsigned int configKeyDUp[MAX_BINDS];
|
||||
extern unsigned int configKeyDDown[MAX_BINDS];
|
||||
|
|
|
|||
|
|
@ -542,6 +542,19 @@ void djui_chat_box_toggle(void) {
|
|||
gDjuiChatBox->chatFlow->base.y.value = gDjuiChatBox->chatContainer->base.elem.height - gDjuiChatBox->chatFlow->base.height.value;
|
||||
}
|
||||
|
||||
void djui_chat_box_open_with_text(const char* text) {
|
||||
if (gDjuiChatBox == NULL) { return; }
|
||||
if (!gDjuiChatBoxFocus) {
|
||||
sDjuiChatBoxClearText = false;
|
||||
gDjuiChatBoxFocus = true;
|
||||
djui_chat_box_set_focus_style();
|
||||
}
|
||||
if (gDjuiChatBox->chatInput != NULL && text != NULL) {
|
||||
djui_inputbox_set_text(gDjuiChatBox->chatInput, (char*)text);
|
||||
djui_inputbox_move_cursor_to_end(gDjuiChatBox->chatInput);
|
||||
}
|
||||
}
|
||||
|
||||
struct DjuiChatBox* djui_chat_box_create(void) {
|
||||
if (gDjuiChatBox != NULL) {
|
||||
djui_base_destroy(&gDjuiChatBox->base);
|
||||
|
|
|
|||
|
|
@ -14,4 +14,5 @@ extern struct DjuiChatBox* gDjuiChatBox;
|
|||
extern bool gDjuiChatBoxFocus;
|
||||
|
||||
void djui_chat_box_toggle(void);
|
||||
void djui_chat_box_open_with_text(const char* text);
|
||||
struct DjuiChatBox* djui_chat_box_create(void);
|
||||
|
|
|
|||
|
|
@ -211,16 +211,23 @@ bool djui_interactable_on_key_down(int scancode) {
|
|||
}
|
||||
}
|
||||
|
||||
if (gDjuiChatBox != NULL && !gDjuiChatBoxFocus) {
|
||||
if (gDjuiChatBox != NULL) {
|
||||
bool pressChat = false;
|
||||
bool pressChatCommand = false;
|
||||
for (int i = 0; i < MAX_BINDS; i++) {
|
||||
if (scancode == (int)configKeyChat[i]) { pressChat = true; }
|
||||
if (scancode == (int)configKeyChatCommand[i]) { pressChatCommand = true; }
|
||||
}
|
||||
|
||||
if (pressChat && !gDjuiConsoleFocus) {
|
||||
if (pressChat && !gDjuiConsoleFocus && !gDjuiChatBoxFocus) {
|
||||
djui_chat_box_toggle();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pressChatCommand && !gDjuiConsoleFocus) {
|
||||
djui_chat_box_open_with_text("/");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((gDjuiPlayerList != NULL || gDjuiModList != NULL)) {
|
||||
|
|
|
|||
|
|
@ -15,18 +15,19 @@ void djui_panel_controls_extra_create(struct DjuiBase* caller) {
|
|||
djui_base_set_color(&bindBody->base, 0, 0, 0, 0);
|
||||
djui_flow_layout_set_margin(bindBody, 1);
|
||||
{
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, CHAT), configKeyChat);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, PLAYERS), configKeyPlayerList);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, D_UP), configKeyDUp);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, D_DOWN), configKeyDDown);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, D_LEFT), configKeyDLeft);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, D_RIGHT), configKeyDRight);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, X), configKeyX);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, Y), configKeyY);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, CONSOLE), configKeyConsole);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, PREV), configKeyPrevPage);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, NEXT), configKeyNextPage);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, DISCONNECT), configKeyDisconnect);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, CHAT), configKeyChat);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, CHAT_COMMAND), configKeyChatCommand);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, PLAYERS), configKeyPlayerList);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, D_UP), configKeyDUp);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, D_DOWN), configKeyDDown);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, D_LEFT), configKeyDLeft);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, D_RIGHT), configKeyDRight);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, X), configKeyX);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, Y), configKeyY);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, CONSOLE), configKeyConsole);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, PREV), configKeyPrevPage);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, NEXT), configKeyNextPage);
|
||||
djui_bind_create(&bindBody->base, DLANG(CONTROLS, DISCONNECT), configKeyDisconnect);
|
||||
}
|
||||
|
||||
djui_button_create(body, DLANG(MENU, BACK), DJUI_BUTTON_STYLE_BACK, djui_panel_menu_back);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue