diff --git a/resources/config/multiplayer_menu.json b/resources/config/multiplayer_menu.json index 17bf917..acbbe09 100644 --- a/resources/config/multiplayer_menu.json +++ b/resources/config/multiplayer_menu.json @@ -3,103 +3,156 @@ "type": "LinearLayout", "x": 0, "y": 0, - "width": 1920, - "height": 1080, - "orientation": "vertical", - "spacing": 20, + "width": 1280, + "height": 720, "children": [ { - "type": "TextView", - "name": "titleText", - "x": 300, - "y": 100, - "width": 1320, - "height": 100, - "text": "Multiplayer", - "fontPath": "resources/fonts/DroidSans.ttf", - "fontSize": 72, - "color": [1, 1, 1, 1], - "centered": true - }, - { - "type": "TextView", - "name": "serverLabel", - "x": 400, - "y": 250, - "width": 1120, - "height": 50, - "text": "Enter server name or IP:", - "fontPath": "resources/fonts/DroidSans.ttf", - "fontSize": 32, - "color": [1, 1, 1, 1], - "centered": false - }, + "type": "Button", + "name": "langButton", + "x": 1100, + "y": 580, + "width": 142, + "height": 96, + "textures": { + "normal": "resources/main_menu/lang.png", + "hover": "resources/main_menu/lang.png", + "pressed": "resources/main_menu/lang.png" + } + }, + { + "type": "Button", + "name": "titleBtn", + "x": 512, + "y": 500, + "width": 254, + "height": 35, + "textures": { + "normal": "resources/multiplayer_menu/title.png", + "hover": "resources/multiplayer_menu/title.png", + "pressed": "resources/multiplayer_menu/title.png" + } + }, + { + "type": "Button", + "name": "subtitle", + "x": 596.5, + "y": 470, + "width": 87, + "height": 11, + "textures": { + "normal": "resources/multiplayer_menu/JoinServer.png", + "hover": "resources/multiplayer_menu/JoinServer.png", + "pressed": "resources/multiplayer_menu/JoinServer.png" + } + }, + { + "type": "Button", + "name": "subtitleBtn", + "x": 450, + "y": 445, + "width": 94, + "height": 9, + "textures": { + "normal": "resources/multiplayer_menu/ServerName.png", + "hover": "resources/multiplayer_menu/ServerName.png", + "pressed": "resources/multiplayer_menu/ServerName.png" + } + }, { "type": "TextField", "name": "serverInputField", - "x": 400, - "y": 320, - "width": 1120, - "height": 60, + "x": 449, + "y": 390, + "width": 382, + "height": 56, "placeholder": "Enter server name or IP", "fontPath": "resources/fonts/DroidSans.ttf", - "fontSize": 28, + "fontSize": 16, "maxLength": 256, - "color": [1, 1, 1, 1], - "placeholderColor": [0.6, 0.6, 0.6, 1], - "backgroundColor": [0.15, 0.15, 0.15, 1], - "borderColor": [0.7, 0.7, 0.7, 1] + "color": [122, 156, 198, 1], + "placeholderColor": [122, 156, 198, 1], + "backgroundColor": [15, 29, 51, 1], + "borderColor": [15, 29, 51, 1] }, { - "type": "LinearLayout", - "x": 400, - "y": 450, - "width": 1120, - "height": 80, - "orientation": "horizontal", - "spacing": 30, - "children": [ - { - "type": "Button", - "name": "connectButton", - "x": 0, - "y": 0, - "width": 530, - "height": 80, - "textures": { - "normal": "resources/main_menu/single.png", - "hover": "resources/main_menu/single.png", - "pressed": "resources/main_menu/single.png" - } - }, + "type": "Button", + "name": "connectButton", + "x": 449, + "y": 350, + "width": 382, + "height": 56, + "textures": { + "normal": "resources/multiplayer_menu/Filledbuttons.png", + "hover": "resources/multiplayer_menu/Filledbuttons.png", + "pressed": "resources/multiplayer_menu/Filledbuttons.png" + } + }, + { "type": "Button", "name": "backButton", - "x": 590, - "y": 0, - "width": 530, - "height": 80, + "x": 449, + "y": 280, + "width": 382, + "height": 56, "textures": { - "normal": "resources/main_menu/exit.png", - "hover": "resources/main_menu/exit.png", - "pressed": "resources/main_menu/exit.png" + "normal": "resources/multiplayer_menu/Backbutton.png", + "hover": "resources/multiplayer_menu/Backbutton.png", + "pressed": "resources/multiplayer_menu/Backbutton.png" + } + }, + { + "type": "Button", + "name": "AvailableServers", + "x": 450, + "y": 240, + "width": 139, + "height": 9, + "textures": { + "normal": "resources/multiplayer_menu/AvailableServers.png", + "hover": "resources/multiplayer_menu/AvailableServers.png", + "pressed": "resources/multiplayer_menu/AvailableServers.png" + } + }, + { + "type": "Button", + "name": "SerButton", + "x": 436.5, + "y": 170, + "width": 407, + "height": 62, + "textures": { + "normal": "resources/multiplayer_menu/Button.png", + "hover": "resources/multiplayer_menu/Button.png", + "pressed": "resources/multiplayer_menu/Button.png" + } + }, + { + "type": "Button", + "name": "SerButton2", + "x": 436.5, + "y": 88, + "width": 407, + "height": 62, + "textures": { + "normal": "resources/multiplayer_menu/Button2.png", + "hover": "resources/multiplayer_menu/Button2.png", + "pressed": "resources/multiplayer_menu/Button2.png" + } + }, + { + "type": "Button", + "name": "SerButton3", + "x": 436.5, + "y": 6, + "width": 407, + "height": 62, + "textures": { + "normal": "resources/multiplayer_menu/Button3.png", + "hover": "resources/multiplayer_menu/Button3.png", + "pressed": "resources/multiplayer_menu/Button3.png" + } } - } ] - }, - { - "type": "TextView", - "name": "statusText", - "x": 400, - "y": 580, - "width": 1120, - "height": 50, - "text": "Ready to connect", - "fontPath": "resources/fonts/DroidSans.ttf", - "fontSize": 24, - "color": [0.8, 0.8, 0.8, 1], - "centered": false - } - ] } } \ No newline at end of file diff --git a/resources/multiplayer_menu/AvailableServers.png b/resources/multiplayer_menu/AvailableServers.png new file mode 100644 index 0000000..8a5759d --- /dev/null +++ b/resources/multiplayer_menu/AvailableServers.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b6c6555671ec968eff10211ef2efd8ac097c52bf602b314d101f78c57f4a7059 +size 1823 diff --git a/resources/multiplayer_menu/Backbutton.png b/resources/multiplayer_menu/Backbutton.png new file mode 100644 index 0000000..9ee46af --- /dev/null +++ b/resources/multiplayer_menu/Backbutton.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e0bcfe59a76449bd26a8558bbcf59a2bb06227d4ad99f5686a41ff567ca4b2bb +size 1814 diff --git a/resources/multiplayer_menu/Button.png b/resources/multiplayer_menu/Button.png new file mode 100644 index 0000000..a08abec --- /dev/null +++ b/resources/multiplayer_menu/Button.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e9ef4f2c9e8b45419915f4630e9ec3228388e6eff9c1f6fffd8a7762f0437c7 +size 3508 diff --git a/resources/multiplayer_menu/Button2.png b/resources/multiplayer_menu/Button2.png new file mode 100644 index 0000000..49b0468 --- /dev/null +++ b/resources/multiplayer_menu/Button2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9b9dc0b621e0125c32d21cf2a941638fc758ababd52b933b3aa806d8fba2d2bb +size 3575 diff --git a/resources/multiplayer_menu/Button3.png b/resources/multiplayer_menu/Button3.png new file mode 100644 index 0000000..b7f3804 --- /dev/null +++ b/resources/multiplayer_menu/Button3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fcb8c3d841ab6e449adf66263e4bd27d80240f591e090e6047bc1206dd4d9b10 +size 3742 diff --git a/resources/multiplayer_menu/Filledbuttons.png b/resources/multiplayer_menu/Filledbuttons.png new file mode 100644 index 0000000..ae03c85 --- /dev/null +++ b/resources/multiplayer_menu/Filledbuttons.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eb124591fa4995b4f958f082976d87cf3bc22b560dc790d0dac6d89c158c9a78 +size 2315 diff --git a/resources/multiplayer_menu/JoinServer.png b/resources/multiplayer_menu/JoinServer.png new file mode 100644 index 0000000..aec320d --- /dev/null +++ b/resources/multiplayer_menu/JoinServer.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:66448d4bc67ad1cd0ed4ddd4e3671b17ffe97d11e59185d123b1b621badb6449 +size 1282 diff --git a/resources/multiplayer_menu/ServerName.png b/resources/multiplayer_menu/ServerName.png new file mode 100644 index 0000000..b8b0d63 --- /dev/null +++ b/resources/multiplayer_menu/ServerName.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b8bd3c9e3fa4fff2c9f5cba2858e8a964be237406162ed7dd7046690a8543eb4 +size 1367 diff --git a/resources/multiplayer_menu/title.png b/resources/multiplayer_menu/title.png new file mode 100644 index 0000000..4702a8a --- /dev/null +++ b/resources/multiplayer_menu/title.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ffcfc5e1d00f135259a94122d60c9524524b6f40d9cf7d26d17dd25b793ade40 +size 1830 diff --git a/src/Game.cpp b/src/Game.cpp index d6c28c0..a6981b9 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -109,7 +109,6 @@ namespace ZL spaceGameStarted = 1; }; - menuManager.onMultiplayerPressed = [this]() { #ifdef NETWORK #ifdef EMSCRIPTEN diff --git a/src/UiManager.cpp b/src/UiManager.cpp index d051f8c..647d72f 100644 --- a/src/UiManager.cpp +++ b/src/UiManager.cpp @@ -906,22 +906,28 @@ namespace ZL { } void UiManager::onMouseUp(int x, int y) { + std::vector> clicked; + for (auto& b : buttons) { + if (!b) continue; bool contains = b->rect.contains((float)x, (float)y); + if (b->state == ButtonState::Pressed) { if (contains && pressedButton == b) { - if (b->onClick) { - b->onClick(b->name); - } + clicked.push_back(b); } b->state = contains ? ButtonState::Hover : ButtonState::Normal; } } - pressedButton.reset(); - if (pressedSlider) { - pressedSlider.reset(); + for (auto& b : clicked) { + if (b->onClick) { + b->onClick(b->name); + } } + + pressedButton.reset(); + if (pressedSlider) pressedSlider.reset(); } void UiManager::onKeyPress(unsigned char key) {