T to open chat.

extracted from #412
fixes the first half of #428
This commit is contained in:
IntegratedQuantum 2024-09-09 21:11:59 +02:00
parent c5a9ea53cd
commit f9079be9ca
3 changed files with 16 additions and 1 deletions

View File

@ -134,6 +134,14 @@ pub fn mainButtonReleased(self: *TextInput, mousePosition: Vec2f) void {
}
}
pub fn select(self: *TextInput) void {
gui.setSelectedTextInput(self);
self.pressed = false;
self.selectionStart = null;
if(self.cursor == null)
self.cursor = @intCast(self.currentString.items.len);
}
pub fn deselect(self: *TextInput) void {
self.cursor = null;
self.selectionStart = null;

View File

@ -36,7 +36,7 @@ var messageQueue: main.List([]const u8) = undefined;
var expirationTime: main.List(i32) = undefined;
var historyStart: u32 = 0;
var fadeOutEnd: u32 = 0;
var input: *TextInput = undefined;
pub var input: *TextInput = undefined;
var hideInput: bool = true;
fn refresh() void {

View File

@ -268,6 +268,12 @@ fn openCreativeInventory() void {
gui.toggleGameMenu();
gui.openWindow("creative_inventory");
}
fn openChat() void {
if(game.world == null) return;
ungrabMouse();
gui.openWindow("chat");
gui.windowlist.chat.input.select();
}
fn takeBackgroundImageFn() void {
if(game.world == null) return;
renderer.MenuBackGround.takeBackgroundImage();
@ -324,6 +330,7 @@ pub const KeyBoard = struct { // MARK: KeyBoard
.{.name = "escape", .key = c.GLFW_KEY_ESCAPE, .releaseAction = &escape},
.{.name = "openInventory", .key = c.GLFW_KEY_E, .releaseAction = &openInventory},
.{.name = "openCreativeInventory(aka cheat inventory)", .key = c.GLFW_KEY_C, .releaseAction = &openCreativeInventory},
.{.name = "openChat", .key = c.GLFW_KEY_T, .releaseAction = &openChat},
.{.name = "mainGuiButton", .mouseButton = c.GLFW_MOUSE_BUTTON_LEFT, .pressAction = &gui.mainButtonPressed, .releaseAction = &gui.mainButtonReleased},
.{.name = "secondaryGuiButton", .mouseButton = c.GLFW_MOUSE_BUTTON_RIGHT, .pressAction = &gui.secondaryButtonPressed, .releaseAction = &gui.secondaryButtonReleased},
// text: