message.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include <QMessageBox>
  4. #include <QString>
  5. #include "yuzu/multiplayer/message.h"
  6. namespace NetworkMessage {
  7. const ConnectionError ErrorManager::USERNAME_NOT_VALID(
  8. QT_TR_NOOP("Username is not valid. Must be 4 to 20 alphanumeric characters."));
  9. const ConnectionError ErrorManager::ROOMNAME_NOT_VALID(
  10. QT_TR_NOOP("Room name is not valid. Must be 4 to 20 alphanumeric characters."));
  11. const ConnectionError ErrorManager::USERNAME_NOT_VALID_SERVER(
  12. QT_TR_NOOP("Username is already in use or not valid. Please choose another."));
  13. const ConnectionError ErrorManager::IP_ADDRESS_NOT_VALID(
  14. QT_TR_NOOP("IP is not a valid IPv4 address."));
  15. const ConnectionError ErrorManager::PORT_NOT_VALID(
  16. QT_TR_NOOP("Port must be a number between 0 to 65535."));
  17. const ConnectionError ErrorManager::GAME_NOT_SELECTED(QT_TR_NOOP(
  18. "You must choose a Preferred Game to host a room. If you do not have any games in your game "
  19. "list yet, add a game folder by clicking on the plus icon in the game list."));
  20. const ConnectionError ErrorManager::NO_INTERNET(
  21. QT_TR_NOOP("Unable to find an internet connection. Check your internet settings."));
  22. const ConnectionError ErrorManager::UNABLE_TO_CONNECT(
  23. QT_TR_NOOP("Unable to connect to the host. Verify that the connection settings are correct. If "
  24. "you still cannot connect, contact the room host and verify that the host is "
  25. "properly configured with the external port forwarded."));
  26. const ConnectionError ErrorManager::ROOM_IS_FULL(
  27. QT_TR_NOOP("Unable to connect to the room because it is already full."));
  28. const ConnectionError ErrorManager::COULD_NOT_CREATE_ROOM(
  29. QT_TR_NOOP("Creating a room failed. Please retry. Restarting yuzu might be necessary."));
  30. const ConnectionError ErrorManager::HOST_BANNED(
  31. QT_TR_NOOP("The host of the room has banned you. Speak with the host to unban you "
  32. "or try a different room."));
  33. const ConnectionError ErrorManager::WRONG_VERSION(
  34. QT_TR_NOOP("Version mismatch! Please update to the latest version of yuzu. If the problem "
  35. "persists, contact the room host and ask them to update the server."));
  36. const ConnectionError ErrorManager::WRONG_PASSWORD(QT_TR_NOOP("Incorrect password."));
  37. const ConnectionError ErrorManager::GENERIC_ERROR(QT_TR_NOOP(
  38. "An unknown error occurred. If this error continues to occur, please open an issue"));
  39. const ConnectionError ErrorManager::LOST_CONNECTION(
  40. QT_TR_NOOP("Connection to room lost. Try to reconnect."));
  41. const ConnectionError ErrorManager::HOST_KICKED(
  42. QT_TR_NOOP("You have been kicked by the room host."));
  43. const ConnectionError ErrorManager::IP_COLLISION(
  44. QT_TR_NOOP("IP address is already in use. Please choose another."));
  45. const ConnectionError ErrorManager::PERMISSION_DENIED(
  46. QT_TR_NOOP("You do not have enough permission to perform this action."));
  47. const ConnectionError ErrorManager::NO_SUCH_USER(QT_TR_NOOP(
  48. "The user you are trying to kick/ban could not be found.\nThey may have left the room."));
  49. static bool WarnMessage(const std::string& title, const std::string& text) {
  50. return QMessageBox::Ok == QMessageBox::warning(nullptr, QObject::tr(title.c_str()),
  51. QObject::tr(text.c_str()),
  52. QMessageBox::Ok | QMessageBox::Cancel);
  53. }
  54. void ErrorManager::ShowError(const ConnectionError& e) {
  55. QMessageBox::critical(nullptr, tr("Error"), tr(e.GetString().c_str()));
  56. }
  57. bool WarnCloseRoom() {
  58. return WarnMessage(
  59. QT_TR_NOOP("Leave Room"),
  60. QT_TR_NOOP("You are about to close the room. Any network connections will be closed."));
  61. }
  62. bool WarnDisconnect() {
  63. return WarnMessage(
  64. QT_TR_NOOP("Disconnect"),
  65. QT_TR_NOOP("You are about to leave the room. Any network connections will be closed."));
  66. }
  67. } // namespace NetworkMessage