message.cpp 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. const ConnectionError ErrorManager::NO_INTERFACE_SELECTED(
  50. QT_TR_NOOP("No network interface is selected.\nPlease go to Configure -> System -> Network and "
  51. "make a selection."));
  52. static bool WarnMessage(const std::string& title, const std::string& text) {
  53. return QMessageBox::Ok == QMessageBox::warning(nullptr, QObject::tr(title.c_str()),
  54. QObject::tr(text.c_str()),
  55. QMessageBox::Ok | QMessageBox::Cancel);
  56. }
  57. void ErrorManager::ShowError(const ConnectionError& e) {
  58. QMessageBox::critical(nullptr, tr("Error"), tr(e.GetString().c_str()));
  59. }
  60. bool WarnGameRunning() {
  61. return WarnMessage(
  62. QT_TR_NOOP("Game already running"),
  63. QT_TR_NOOP("Joining a room when the game is already running is discouraged "
  64. "and can cause the room feature not to work correctly.\nProceed anyway?"));
  65. }
  66. bool WarnCloseRoom() {
  67. return WarnMessage(
  68. QT_TR_NOOP("Leave Room"),
  69. QT_TR_NOOP("You are about to close the room. Any network connections will be closed."));
  70. }
  71. bool WarnDisconnect() {
  72. return WarnMessage(
  73. QT_TR_NOOP("Disconnect"),
  74. QT_TR_NOOP("You are about to leave the room. Any network connections will be closed."));
  75. }
  76. } // namespace NetworkMessage