added multiplayer menu
This commit is contained in:
1 parent
a8700af1d0
commit
0babfff28b
4 files changed
+323
-19
No files matched your search
+65
-16
@@ -405,10 +405,54 @@ namespace ZL
|
||||
std::cerr << "Single button pressed: " << name << " -> load gameplay UI\n";
|
||||
loadGameplayUI();
|
||||
});
|
||||
uiManager.setButtonCallback("multiplayerButton", [loadGameplayUI](const std::string& name) {
|
||||
/*uiManager.setButtonCallback("multiplayerButton", [loadGameplayUI](const std::string& name) {
|
||||
std::cerr << "Multiplayer button pressed: " << name << " -> load gameplay UI\n";
|
||||
loadGameplayUI();
|
||||
});
|
||||
});*/
|
||||
|
||||
uiManager.setButtonCallback("multiplayerButton", [this](const std::string& name) {
|
||||
std::cerr << "Multiplayer button pressed → opening multiplayer menu\n";
|
||||
|
||||
uiManager.startAnimationOnNode("playButton", "buttonsExit");
|
||||
uiManager.startAnimationOnNode("settingsButton", "buttonsExit");
|
||||
uiManager.startAnimationOnNode("multiplayerButton", "buttonsExit");
|
||||
uiManager.startAnimationOnNode("exitButton", "buttonsExit");
|
||||
|
||||
if (uiManager.pushMenuFromFile("resources/config/multiplayer_menu.json", this->renderer, CONST_ZIP_FILE)) {
|
||||
|
||||
// Callback для кнопки подключения
|
||||
uiManager.setButtonCallback("connectButton", [this](const std::string& buttonName) {
|
||||
std::string serverAddress = uiManager.getTextFieldValue("serverInputField");
|
||||
|
||||
if (serverAddress.empty()) {
|
||||
uiManager.setText("statusText", "Please enter server address");
|
||||
return;
|
||||
}
|
||||
|
||||
uiManager.setText("statusText", "Connecting to " + serverAddress + "...");
|
||||
std::cerr << "Connecting to server: " << serverAddress << std::endl;
|
||||
|
||||
// Здесь добавить вашу логику подключения к серверу
|
||||
// connectToServer(serverAddress);
|
||||
});
|
||||
|
||||
// Callback для кнопки назад
|
||||
uiManager.setButtonCallback("backButton", [this](const std::string& buttonName) {
|
||||
uiManager.popMenu();
|
||||
});
|
||||
|
||||
// Callback для отслеживания ввода текста
|
||||
uiManager.setTextFieldCallback("serverInputField",
|
||||
[this](const std::string& fieldName, const std::string& newText) {
|
||||
std::cout << "Server input field changed to: " << newText << std::endl;
|
||||
});
|
||||
|
||||
std::cerr << "Multiplayer menu loaded successfully\n";
|
||||
}
|
||||
else {
|
||||
std::cerr << "Failed to load multiplayer menu\n";
|
||||
}
|
||||
});
|
||||
uiManager.setButtonCallback("exitButton", [](const std::string& name) {
|
||||
std::cerr << "Exit from main menu pressed: " << name << " -> exiting\n";
|
||||
Environment::exitGameLoop = true;
|
||||
@@ -1338,10 +1382,8 @@ namespace ZL
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __ANDROID__
|
||||
if (event.type == SDL_FINGERDOWN) {
|
||||
// Координаты Finger в SDL нормализованы от 0.0 до 1.0
|
||||
int mx = static_cast<int>(event.tfinger.x * Environment::width);
|
||||
int my = static_cast<int>(event.tfinger.y * Environment::height);
|
||||
handleDown(mx, my);
|
||||
@@ -1357,24 +1399,20 @@ namespace ZL
|
||||
handleMotion(mx, my);
|
||||
}
|
||||
#else
|
||||
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN) {
|
||||
int mx = event.button.x;
|
||||
int my = event.button.y;
|
||||
handleDown(mx, my);
|
||||
}
|
||||
if (event.type == SDL_MOUSEBUTTONUP) {
|
||||
|
||||
int mx = event.button.x;
|
||||
int my = event.button.y;
|
||||
handleUp(mx, my);
|
||||
}
|
||||
if (event.type == SDL_MOUSEMOTION) {
|
||||
|
||||
int mx = event.motion.x;
|
||||
int my = event.motion.y;
|
||||
handleMotion(mx, my);
|
||||
|
||||
}
|
||||
|
||||
if (event.type == SDL_MOUSEWHEEL) {
|
||||
@@ -1389,18 +1427,29 @@ namespace ZL
|
||||
Environment::zoom = zoomstep;
|
||||
}
|
||||
}
|
||||
if (event.type == SDL_KEYUP)
|
||||
{
|
||||
if (event.key.keysym.sym == SDLK_i)
|
||||
{
|
||||
|
||||
// Обработка ввода текста
|
||||
if (event.type == SDL_KEYDOWN) {
|
||||
if (event.key.keysym.sym == SDLK_BACKSPACE) {
|
||||
uiManager.onKeyBackspace();
|
||||
}
|
||||
}
|
||||
|
||||
if (event.type == SDL_TEXTINPUT) {
|
||||
// Пропускаем ctrl+c и другие команды
|
||||
if ((event.text.text[0] & 0x80) == 0) { // ASCII символы
|
||||
uiManager.onKeyPress((unsigned char)event.text.text[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.type == SDL_KEYUP) {
|
||||
if (event.key.keysym.sym == SDLK_i) {
|
||||
x = x + 1;
|
||||
}
|
||||
if (event.key.keysym.sym == SDLK_k)
|
||||
{
|
||||
if (event.key.keysym.sym == SDLK_k) {
|
||||
x = x - 1;
|
||||
}
|
||||
if (event.key.keysym.sym == SDLK_a)
|
||||
{
|
||||
if (event.key.keysym.sym == SDLK_a) {
|
||||
Environment::shipState.position = { 9466.15820, 1046.00159, 18531.2090 };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user