Showing the changes to interface/src/Menu.cpp (1 of 4 files). Show all
Unified · Split
| @@ -913,6 +913,39 @@ void Menu::goToDomain() { · 912 unmodified lines | ||
| 913 | 913 | sendFakeEnterEvent(); |
| 914 | 914 | } |
| 915 | 915 | |
| 916 | +bool Menu::goToDestination(QString destination) { | |
| 917 | + | |
| 918 | + QStringList coordinateItems = destination.split(QRegExp("_|,"), QString::SkipEmptyParts); | |
| 919 | + | |
| 920 | + const int NUMBER_OF_COORDINATE_ITEMS = 3; | |
| 921 | + const int X_ITEM = 0; | |
| 922 | + const int Y_ITEM = 1; | |
| 923 | + const int Z_ITEM = 2; | |
| 924 | + if (coordinateItems.size() == NUMBER_OF_COORDINATE_ITEMS) { | |
| 925 | + | |
| 926 | + double x = replaceLastOccurrence('-', '.', coordinateItems[X_ITEM].trimmed()).toDouble(); | |
| 927 | + double y = replaceLastOccurrence('-', '.', coordinateItems[Y_ITEM].trimmed()).toDouble(); | |
| 928 | + double z = replaceLastOccurrence('-', '.', coordinateItems[Z_ITEM].trimmed()).toDouble(); | |
| 929 | + | |
| 930 | + glm::vec3 newAvatarPos(x, y, z); | |
| 931 | + | |
| 932 | + MyAvatar* myAvatar = Application::getInstance()->getAvatar(); | |
| 933 | + glm::vec3 avatarPos = myAvatar->getPosition(); | |
| 934 | + if (newAvatarPos != avatarPos) { | |
| 935 | + // send a node kill request, indicating to other clients that they should play the "disappeared" effect | |
| 936 | + MyAvatar::sendKillAvatar(); | |
| 937 | + | |
| 938 | + qDebug("Going To Location: %f, %f, %f...", x, y, z); | |
| 939 | + myAvatar->setPosition(newAvatarPos); | |
| 940 | + } | |
| 941 | + | |
| 942 | + return true; | |
| 943 | + } | |
| 944 | + | |
| 945 | + // no coordinates were parsed | |
| 946 | + return false; | |
| 947 | +} | |
| 948 | + | |
| 916 | 949 | void Menu::goTo() { |
| 917 | 950 | |
| 918 | 951 | QInputDialog gotoDialog(Application::getInstance()->getWindow()); |
| @@ -928,31 +961,8 @@ void Menu::goTo() { · 9 unmodified lines | ||
| 928 | 961 | |
| 929 | 962 | destination = gotoDialog.textValue(); |
| 930 | 963 | |
| 931 | − QStringList coordinateItems = destination.split(QRegExp("_|,"), QString::SkipEmptyParts); | |
| 932 | − | |
| 933 | − const int NUMBER_OF_COORDINATE_ITEMS = 3; | |
| 934 | − const int X_ITEM = 0; | |
| 935 | − const int Y_ITEM = 1; | |
| 936 | − const int Z_ITEM = 2; | |
| 937 | − if (coordinateItems.size() == NUMBER_OF_COORDINATE_ITEMS) { | |
| 938 | − | |
| 939 | − double x = replaceLastOccurrence('-', '.', coordinateItems[X_ITEM].trimmed()).toDouble(); | |
| 940 | − double y = replaceLastOccurrence('-', '.', coordinateItems[Y_ITEM].trimmed()).toDouble(); | |
| 941 | − double z = replaceLastOccurrence('-', '.', coordinateItems[Z_ITEM].trimmed()).toDouble(); | |
| 942 | − | |
| 943 | − glm::vec3 newAvatarPos(x, y, z); | |
| 944 | − | |
| 945 | − MyAvatar* myAvatar = Application::getInstance()->getAvatar(); | |
| 946 | − glm::vec3 avatarPos = myAvatar->getPosition(); | |
| 947 | − if (newAvatarPos != avatarPos) { | |
| 948 | − // send a node kill request, indicating to other clients that they should play the "disappeared" effect | |
| 949 | − MyAvatar::sendKillAvatar(); | |
| 950 | − | |
| 951 | − qDebug("Going To Location: %f, %f, %f...", x, y, z); | |
| 952 | − myAvatar->setPosition(newAvatarPos); | |
| 953 | − } | |
| 954 | − | |
| 955 | − } else { | |
| 964 | + // go to coordinate destination or to Username | |
| 965 | + if (!goToDestination(destination)) { | |
| 956 | 966 | // there's a username entered by the user, make a request to the data-server |
| 957 | 967 | DataServerClient::getValuesForKeysAndUserString( |
| 958 | 968 | QStringList() |
| @@ -983,29 +993,7 @@ void Menu::goToLocation() { · 24 unmodified lines | ||
| 983 | 993 | |
| 984 | 994 | int dialogReturn = coordinateDialog.exec(); |
| 985 | 995 | if (dialogReturn == QDialog::Accepted && !coordinateDialog.textValue().isEmpty()) { |
| 986 | − QByteArray newCoordinates; | |
| 987 | − | |
| 988 | − QString delimiterPattern(","); | |
| 989 | − QStringList coordinateItems = coordinateDialog.textValue().split(delimiterPattern); | |
| 990 | − | |
| 991 | − const int NUMBER_OF_COORDINATE_ITEMS = 3; | |
| 992 | − const int X_ITEM = 0; | |
| 993 | − const int Y_ITEM = 1; | |
| 994 | − const int Z_ITEM = 2; | |
| 995 | − if (coordinateItems.size() == NUMBER_OF_COORDINATE_ITEMS) { | |
| 996 | − double x = coordinateItems[X_ITEM].toDouble(); | |
| 997 | − double y = coordinateItems[Y_ITEM].toDouble(); | |
| 998 | − double z = coordinateItems[Z_ITEM].toDouble(); | |
| 999 | − glm::vec3 newAvatarPos(x, y, z); | |
| 1000 | − | |
| 1001 | − if (newAvatarPos != avatarPos) { | |
| 1002 | − // send a node kill request, indicating to other clients that they should play the "disappeared" effect | |
| 1003 | − MyAvatar::sendKillAvatar(); | |
| 1004 | − | |
| 1005 | − qDebug("Going To Location: %f, %f, %f...", x, y, z); | |
| 1006 | − myAvatar->setPosition(newAvatarPos); | |
| 1007 | − } | |
| 1008 | − } | |
| 996 | + goToDestination(coordinateDialog.textValue()); | |
| 1009 | 997 | } |
| 1010 | 998 | |
| 1011 | 999 | sendFakeEnterEvent(); |