Don't send empty chat messages(which currently crashes) and display the correct name in the change name gui.

This commit is contained in:
IntegratedQuantum 2024-02-16 19:47:54 +01:00
parent 950933b03f
commit 50c20aa28f
3 changed files with 6 additions and 4 deletions

View File

@ -43,7 +43,7 @@ pub fn onOpen() void {
list.add(Label.init(.{0, 0}, width, "\\**italic*\\* \\*\\***bold**\\*\\* \\__underlined_\\_ \\_\\___strike-through__\\_\\_", .center)); list.add(Label.init(.{0, 0}, width, "\\**italic*\\* \\*\\***bold**\\*\\* \\__underlined_\\_ \\_\\___strike-through__\\_\\_", .center));
list.add(Label.init(.{0, 0}, width, "Even colors are possible, using the hexadecimal color code:", .center)); list.add(Label.init(.{0, 0}, width, "Even colors are possible, using the hexadecimal color code:", .center));
list.add(Label.init(.{0, 0}, width, "\\##ff0000ff#ffffff00#ffffff00#ff0000red#ffffff \\##ff0000ff#00770077#ffffff00#ff7700orange#ffffff \\##ffffff00#00ff00ff#ffffff00#00ff00green#ffffff \\##ffffff00#ffffff00#0000ffff#0000ffblue", .center)); list.add(Label.init(.{0, 0}, width, "\\##ff0000ff#ffffff00#ffffff00#ff0000red#ffffff \\##ff0000ff#00770077#ffffff00#ff7700orange#ffffff \\##ffffff00#00ff00ff#ffffff00#00ff00green#ffffff \\##ffffff00#ffffff00#0000ffff#0000ffblue", .center));
textComponent = TextInput.init(.{0, 0}, width, 32, "quanturmdoelvloper", .{.callback = &apply}); textComponent = TextInput.init(.{0, 0}, width, 32, settings.playerName, .{.callback = &apply});
list.add(textComponent); list.add(textComponent);
list.add(Button.initText(.{0, 0}, 100, "Apply", .{.callback = &apply})); list.add(Button.initText(.{0, 0}, 100, "Apply", .{.callback = &apply}));
list.finish(.center); list.finish(.center);

View File

@ -125,6 +125,8 @@ pub fn addMessage(message: []const u8) void {
} }
pub fn sendMessage(_: usize) void { pub fn sendMessage(_: usize) void {
if(input.currentString.items.len != 0) {
main.network.Protocols.chat.send(main.game.world.?.conn, input.currentString.items); main.network.Protocols.chat.send(main.game.world.?.conn, input.currentString.items);
input.clear(); input.clear();
} }
}

View File

@ -28,7 +28,7 @@ pub var bloom: bool = true;
pub var vsync: bool = true; pub var vsync: bool = true;
pub var playerName: []const u8 = ""; pub var playerName: []const u8 = "quanturmdoelvloper";
pub var lastUsedIPAddress: []const u8 = "127.0.0.1"; pub var lastUsedIPAddress: []const u8 = "127.0.0.1";