added multi_menu
This commit is contained in:
parent
84006380db
commit
cb2e8318e7
@ -3,102 +3,155 @@
|
|||||||
"type": "LinearLayout",
|
"type": "LinearLayout",
|
||||||
"x": 0,
|
"x": 0,
|
||||||
"y": 0,
|
"y": 0,
|
||||||
"width": 1920,
|
"width": 1280,
|
||||||
"height": 1080,
|
"height": 720,
|
||||||
"orientation": "vertical",
|
|
||||||
"spacing": 20,
|
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"type": "TextView",
|
"type": "Button",
|
||||||
"name": "titleText",
|
"name": "langButton",
|
||||||
"x": 300,
|
"x": 1100,
|
||||||
"y": 100,
|
"y": 580,
|
||||||
"width": 1320,
|
"width": 142,
|
||||||
"height": 100,
|
"height": 96,
|
||||||
"text": "Multiplayer",
|
"textures": {
|
||||||
"fontPath": "resources/fonts/DroidSans.ttf",
|
"normal": "resources/main_menu/lang.png",
|
||||||
"fontSize": 72,
|
"hover": "resources/main_menu/lang.png",
|
||||||
"color": [1, 1, 1, 1],
|
"pressed": "resources/main_menu/lang.png"
|
||||||
"centered": true
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextView",
|
"type": "Button",
|
||||||
"name": "serverLabel",
|
"name": "titleBtn",
|
||||||
"x": 400,
|
"x": 512,
|
||||||
"y": 250,
|
"y": 500,
|
||||||
"width": 1120,
|
"width": 254,
|
||||||
"height": 50,
|
"height": 35,
|
||||||
"text": "Enter server name or IP:",
|
"textures": {
|
||||||
"fontPath": "resources/fonts/DroidSans.ttf",
|
"normal": "resources/multiplayer_menu/title.png",
|
||||||
"fontSize": 32,
|
"hover": "resources/multiplayer_menu/title.png",
|
||||||
"color": [1, 1, 1, 1],
|
"pressed": "resources/multiplayer_menu/title.png"
|
||||||
"centered": false
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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",
|
"type": "TextField",
|
||||||
"name": "serverInputField",
|
"name": "serverInputField",
|
||||||
"x": 400,
|
"x": 449,
|
||||||
"y": 320,
|
"y": 390,
|
||||||
"width": 1120,
|
"width": 382,
|
||||||
"height": 60,
|
"height": 56,
|
||||||
"placeholder": "Enter server name or IP",
|
"placeholder": "Enter server name or IP",
|
||||||
"fontPath": "resources/fonts/DroidSans.ttf",
|
"fontPath": "resources/fonts/DroidSans.ttf",
|
||||||
"fontSize": 28,
|
"fontSize": 16,
|
||||||
"maxLength": 256,
|
"maxLength": 256,
|
||||||
"color": [1, 1, 1, 1],
|
"color": [122, 156, 198, 1],
|
||||||
"placeholderColor": [0.6, 0.6, 0.6, 1],
|
"placeholderColor": [122, 156, 198, 1],
|
||||||
"backgroundColor": [0.15, 0.15, 0.15, 1],
|
"backgroundColor": [15, 29, 51, 1],
|
||||||
"borderColor": [0.7, 0.7, 0.7, 1]
|
"borderColor": [15, 29, 51, 1]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "LinearLayout",
|
|
||||||
"x": 400,
|
|
||||||
"y": 450,
|
|
||||||
"width": 1120,
|
|
||||||
"height": 80,
|
|
||||||
"orientation": "horizontal",
|
|
||||||
"spacing": 30,
|
|
||||||
"children": [
|
|
||||||
{
|
{
|
||||||
"type": "Button",
|
"type": "Button",
|
||||||
"name": "connectButton",
|
"name": "connectButton",
|
||||||
"x": 0,
|
"x": 449,
|
||||||
"y": 0,
|
"y": 350,
|
||||||
"width": 530,
|
"width": 382,
|
||||||
"height": 80,
|
"height": 56,
|
||||||
"textures": {
|
"textures": {
|
||||||
"normal": "resources/main_menu/single.png",
|
"normal": "resources/multiplayer_menu/Filledbuttons.png",
|
||||||
"hover": "resources/main_menu/single.png",
|
"hover": "resources/multiplayer_menu/Filledbuttons.png",
|
||||||
"pressed": "resources/main_menu/single.png"
|
"pressed": "resources/multiplayer_menu/Filledbuttons.png"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"type": "Button",
|
||||||
|
"name": "backButton",
|
||||||
|
"x": 449,
|
||||||
|
"y": 280,
|
||||||
|
"width": 382,
|
||||||
|
"height": 56,
|
||||||
|
"textures": {
|
||||||
|
"normal": "resources/multiplayer_menu/Backbutton.png",
|
||||||
|
"hover": "resources/multiplayer_menu/Backbutton.png",
|
||||||
|
"pressed": "resources/multiplayer_menu/Backbutton.png"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "Button",
|
"type": "Button",
|
||||||
"name": "backButton",
|
"name": "AvailableServers",
|
||||||
"x": 590,
|
"x": 450,
|
||||||
"y": 0,
|
"y": 240,
|
||||||
"width": 530,
|
"width": 139,
|
||||||
"height": 80,
|
"height": 9,
|
||||||
"textures": {
|
"textures": {
|
||||||
"normal": "resources/main_menu/exit.png",
|
"normal": "resources/multiplayer_menu/AvailableServers.png",
|
||||||
"hover": "resources/main_menu/exit.png",
|
"hover": "resources/multiplayer_menu/AvailableServers.png",
|
||||||
"pressed": "resources/main_menu/exit.png"
|
"pressed": "resources/multiplayer_menu/AvailableServers.png"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextView",
|
"type": "Button",
|
||||||
"name": "statusText",
|
"name": "SerButton",
|
||||||
"x": 400,
|
"x": 436.5,
|
||||||
"y": 580,
|
"y": 170,
|
||||||
"width": 1120,
|
"width": 407,
|
||||||
"height": 50,
|
"height": 62,
|
||||||
"text": "Ready to connect",
|
"textures": {
|
||||||
"fontPath": "resources/fonts/DroidSans.ttf",
|
"normal": "resources/multiplayer_menu/Button.png",
|
||||||
"fontSize": 24,
|
"hover": "resources/multiplayer_menu/Button.png",
|
||||||
"color": [0.8, 0.8, 0.8, 1],
|
"pressed": "resources/multiplayer_menu/Button.png"
|
||||||
"centered": false
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
resources/multiplayer_menu/AvailableServers.png
(Stored with Git LFS)
Normal file
BIN
resources/multiplayer_menu/AvailableServers.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
resources/multiplayer_menu/Backbutton.png
(Stored with Git LFS)
Normal file
BIN
resources/multiplayer_menu/Backbutton.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
resources/multiplayer_menu/Button.png
(Stored with Git LFS)
Normal file
BIN
resources/multiplayer_menu/Button.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
resources/multiplayer_menu/Button2.png
(Stored with Git LFS)
Normal file
BIN
resources/multiplayer_menu/Button2.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
resources/multiplayer_menu/Button3.png
(Stored with Git LFS)
Normal file
BIN
resources/multiplayer_menu/Button3.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
resources/multiplayer_menu/Filledbuttons.png
(Stored with Git LFS)
Normal file
BIN
resources/multiplayer_menu/Filledbuttons.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
resources/multiplayer_menu/JoinServer.png
(Stored with Git LFS)
Normal file
BIN
resources/multiplayer_menu/JoinServer.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
resources/multiplayer_menu/ServerName.png
(Stored with Git LFS)
Normal file
BIN
resources/multiplayer_menu/ServerName.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
resources/multiplayer_menu/title.png
(Stored with Git LFS)
Normal file
BIN
resources/multiplayer_menu/title.png
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -109,7 +109,6 @@ namespace ZL
|
|||||||
spaceGameStarted = 1;
|
spaceGameStarted = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
menuManager.onMultiplayerPressed = [this]() {
|
menuManager.onMultiplayerPressed = [this]() {
|
||||||
#ifdef NETWORK
|
#ifdef NETWORK
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
|
|||||||
@ -906,24 +906,30 @@ namespace ZL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UiManager::onMouseUp(int x, int y) {
|
void UiManager::onMouseUp(int x, int y) {
|
||||||
|
std::vector<std::shared_ptr<UiButton>> clicked;
|
||||||
|
|
||||||
for (auto& b : buttons) {
|
for (auto& b : buttons) {
|
||||||
|
if (!b) continue;
|
||||||
bool contains = b->rect.contains((float)x, (float)y);
|
bool contains = b->rect.contains((float)x, (float)y);
|
||||||
|
|
||||||
if (b->state == ButtonState::Pressed) {
|
if (b->state == ButtonState::Pressed) {
|
||||||
if (contains && pressedButton == b) {
|
if (contains && pressedButton == b) {
|
||||||
if (b->onClick) {
|
clicked.push_back(b);
|
||||||
b->onClick(b->name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
b->state = contains ? ButtonState::Hover : ButtonState::Normal;
|
b->state = contains ? ButtonState::Hover : ButtonState::Normal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pressedButton.reset();
|
|
||||||
|
|
||||||
if (pressedSlider) {
|
for (auto& b : clicked) {
|
||||||
pressedSlider.reset();
|
if (b->onClick) {
|
||||||
|
b->onClick(b->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pressedButton.reset();
|
||||||
|
if (pressedSlider) pressedSlider.reset();
|
||||||
|
}
|
||||||
|
|
||||||
void UiManager::onKeyPress(unsigned char key) {
|
void UiManager::onKeyPress(unsigned char key) {
|
||||||
if (!focusedTextField) return;
|
if (!focusedTextField) return;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user