Showing the changes to interface/src/Menu.cpp (1 of 9 files). Show all
Unified · Split
| @@ -109,7 +109,7 @@ Menu::Menu() : · 108 unmodified lines | ||
| 109 | 109 | MenuOption::GoToDomain, |
| 110 | 110 | Qt::CTRL | Qt::Key_D, |
| 111 | 111 | this, |
| 112 | − SLOT(goToDomain())); | |
| 112 | + SLOT(goToDomainDialog())); | |
| 113 | 113 | addActionToQMenuAndActionHash(fileMenu, |
| 114 | 114 | MenuOption::GoToLocation, |
| 115 | 115 | Qt::CTRL | Qt::SHIFT | Qt::Key_L, |
| @@ -889,7 +889,18 @@ void Menu::editPreferences() { · 773 unmodified lines | ||
| 889 | 889 | sendFakeEnterEvent(); |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | −void Menu::goToDomain() { | |
| 892 | +void Menu::goToDomain(const QString newDomain) { | |
| 893 | + if (NodeList::getInstance()->getDomainHostname() != newDomain) { | |
| 894 | + | |
| 895 | + // send a node kill request, indicating to other clients that they should play the "disappeared" effect | |
| 896 | + Application::getInstance()->getAvatar()->sendKillAvatar(); | |
| 897 | + | |
| 898 | + // give our nodeList the new domain-server hostname | |
| 899 | + NodeList::getInstance()->setDomainHostname(newDomain); | |
| 900 | + } | |
| 901 | +} | |
| 902 | + | |
| 903 | +void Menu::goToDomainDialog() { | |
| 893 | 904 | |
| 894 | 905 | QString currentDomainHostname = NodeList::getInstance()->getDomainHostname(); |
| 895 | 906 | |
| @@ -913,17 +924,46 @@ void Menu::goToDomain() { · 17 unmodified lines | ||
| 913 | 924 | // the user input a new hostname, use that |
| 914 | 925 | newHostname = domainDialog.textValue(); |
| 915 | 926 | } |
| 916 | − | |
| 917 | − // send a node kill request, indicating to other clients that they should play the "disappeared" effect | |
| 918 | − Application::getInstance()->getAvatar()->sendKillAvatar(); | |
| 919 | − | |
| 920 | − // give our nodeList the new domain-server hostname | |
| 921 | − NodeList::getInstance()->setDomainHostname(domainDialog.textValue()); | |
| 927 | + | |
| 928 | + goToDomain(newHostname); | |
| 922 | 929 | } |
| 923 | 930 | |
| 924 | 931 | sendFakeEnterEvent(); |
| 925 | 932 | } |
| 926 | 933 | |
| 934 | +bool Menu::goToDestination(QString destination) { | |
| 935 | + | |
| 936 | + QStringList coordinateItems = destination.split(QRegExp("_|,"), QString::SkipEmptyParts); | |
| 937 | + | |
| 938 | + const int NUMBER_OF_COORDINATE_ITEMS = 3; | |
| 939 | + const int X_ITEM = 0; | |
| 940 | + const int Y_ITEM = 1; | |
| 941 | + const int Z_ITEM = 2; | |
| 942 | + if (coordinateItems.size() == NUMBER_OF_COORDINATE_ITEMS) { | |
| 943 | + | |
| 944 | + double x = replaceLastOccurrence('-', '.', coordinateItems[X_ITEM].trimmed()).toDouble(); | |
| 945 | + double y = replaceLastOccurrence('-', '.', coordinateItems[Y_ITEM].trimmed()).toDouble(); | |
| 946 | + double z = replaceLastOccurrence('-', '.', coordinateItems[Z_ITEM].trimmed()).toDouble(); | |
| 947 | + | |
| 948 | + glm::vec3 newAvatarPos(x, y, z); | |
| 949 | + | |
| 950 | + MyAvatar* myAvatar = Application::getInstance()->getAvatar(); | |
| 951 | + glm::vec3 avatarPos = myAvatar->getPosition(); | |
| 952 | + if (newAvatarPos != avatarPos) { | |
| 953 | + // send a node kill request, indicating to other clients that they should play the "disappeared" effect | |
| 954 | + MyAvatar::sendKillAvatar(); | |
| 955 | + | |
| 956 | + qDebug("Going To Location: %f, %f, %f...", x, y, z); | |
| 957 | + myAvatar->setPosition(newAvatarPos); | |
| 958 | + } | |
| 959 | + | |
| 960 | + return true; | |
| 961 | + } | |
| 962 | + | |
| 963 | + // no coordinates were parsed | |
| 964 | + return false; | |
| 965 | +} | |
| 966 | + | |
| 927 | 967 | void Menu::goTo() { |
| 928 | 968 | |
| 929 | 969 | QInputDialog gotoDialog(Application::getInstance()->getWindow()); |
| @@ -939,31 +979,8 @@ void Menu::goTo() { · 9 unmodified lines | ||
| 939 | 979 | |
| 940 | 980 | destination = gotoDialog.textValue(); |
| 941 | 981 | |
| 942 | − QStringList coordinateItems = destination.split(QRegExp("_|,"), QString::SkipEmptyParts); | |
| 943 | − | |
| 944 | − const int NUMBER_OF_COORDINATE_ITEMS = 3; | |
| 945 | − const int X_ITEM = 0; | |
| 946 | − const int Y_ITEM = 1; | |
| 947 | − const int Z_ITEM = 2; | |
| 948 | − if (coordinateItems.size() == NUMBER_OF_COORDINATE_ITEMS) { | |
| 949 | − | |
| 950 | − double x = replaceLastOccurrence('-', '.', coordinateItems[X_ITEM].trimmed()).toDouble(); | |
| 951 | − double y = replaceLastOccurrence('-', '.', coordinateItems[Y_ITEM].trimmed()).toDouble(); | |
| 952 | − double z = replaceLastOccurrence('-', '.', coordinateItems[Z_ITEM].trimmed()).toDouble(); | |
| 953 | − | |
| 954 | − glm::vec3 newAvatarPos(x, y, z); | |
| 955 | − | |
| 956 | − MyAvatar* myAvatar = Application::getInstance()->getAvatar(); | |
| 957 | − glm::vec3 avatarPos = myAvatar->getPosition(); | |
| 958 | − if (newAvatarPos != avatarPos) { | |
| 959 | − // send a node kill request, indicating to other clients that they should play the "disappeared" effect | |
| 960 | − MyAvatar::sendKillAvatar(); | |
| 961 | − | |
| 962 | − qDebug("Going To Location: %f, %f, %f...", x, y, z); | |
| 963 | − myAvatar->setPosition(newAvatarPos); | |
| 964 | − } | |
| 965 | − | |
| 966 | − } else { | |
| 982 | + // go to coordinate destination or to Username | |
| 983 | + if (!goToDestination(destination)) { | |
| 967 | 984 | // there's a username entered by the user, make a request to the data-server |
| 968 | 985 | DataServerClient::getValuesForKeysAndUserString( |
| 969 | 986 | QStringList() |
| @@ -994,29 +1011,7 @@ void Menu::goToLocation() { · 24 unmodified lines | ||
| 994 | 1011 | |
| 995 | 1012 | int dialogReturn = coordinateDialog.exec(); |
| 996 | 1013 | if (dialogReturn == QDialog::Accepted && !coordinateDialog.textValue().isEmpty()) { |
| 997 | − QByteArray newCoordinates; | |
| 998 | − | |
| 999 | − QString delimiterPattern(","); | |
| 1000 | − QStringList coordinateItems = coordinateDialog.textValue().split(delimiterPattern); | |
| 1001 | − | |
| 1002 | − const int NUMBER_OF_COORDINATE_ITEMS = 3; | |
| 1003 | − const int X_ITEM = 0; | |
| 1004 | − const int Y_ITEM = 1; | |
| 1005 | − const int Z_ITEM = 2; | |
| 1006 | − if (coordinateItems.size() == NUMBER_OF_COORDINATE_ITEMS) { | |
| 1007 | − double x = coordinateItems[X_ITEM].toDouble(); | |
| 1008 | − double y = coordinateItems[Y_ITEM].toDouble(); | |
| 1009 | − double z = coordinateItems[Z_ITEM].toDouble(); | |
| 1010 | − glm::vec3 newAvatarPos(x, y, z); | |
| 1011 | − | |
| 1012 | − if (newAvatarPos != avatarPos) { | |
| 1013 | − // send a node kill request, indicating to other clients that they should play the "disappeared" effect | |
| 1014 | − MyAvatar::sendKillAvatar(); | |
| 1015 | − | |
| 1016 | − qDebug("Going To Location: %f, %f, %f...", x, y, z); | |
| 1017 | − myAvatar->setPosition(newAvatarPos); | |
| 1018 | − } | |
| 1019 | − } | |
| 1014 | + goToDestination(coordinateDialog.textValue()); | |
| 1020 | 1015 | } |
| 1021 | 1016 | |
| 1022 | 1017 | sendFakeEnterEvent(); |