Example #1
0
  public static void handleDevMapClick(LatLng position) {
    if (WindowInformation.locationPanel.isRoadMode()) {
      if (location1ID != -1 && position != null) {
        roadPoints.add(position);
        // Window.alert("Road point added");
      }
    } else {
      String locationName = Window.prompt("Name for this location:", "NULL" + locationCounter++);
      if (locationName != null) {
        GameServices.devService.createLocation(
            GameInfo.getInstance().getPlayer(),
            locationName,
            position.getLatitude(),
            position.getLongitude(),
            new AsyncCallback<Void>() {
              public void onFailure(Throwable caught) {}

              public void onSuccess(Void result) {
                // TODO: Keep the auto-refresh when creating locations?
                // GameInformation.getInstance().refreshAll(true);
              }
            });
      }
    }
  }
Example #2
0
  public static void handleDevLocationClick(LocationDTO location) {
    if (location1ID == -1) {
      location1ID = location.getId();
    } else {
      String roadPointsString = MapUtil.roadPointsToString(roadPoints);
      GameServices.devService.createRoad(
          GameInfo.getInstance().getPlayer(),
          "Road" + roadNum++,
          location1ID,
          location.getId(),
          roadPointsString,
          new AsyncCallback<Void>() {
            public void onFailure(Throwable caught) {
              // Window.alert("Failure because: " + caught.getMessage());
              InfoWindow alert =
                  new InfoWindow(200, 100, "Failure because: " + caught.getMessage());
              alert.center();
            }

            public void onSuccess(Void result) {
              //					Window.alert("Success");
              // TODO: Keep the auto-refresh when creating roads?
              // GameInformation.getInstance().refreshAll(true);
            }
          });
      location1ID = -1;
      roadPoints.clear();
      // Window.alert("Location 2 added - Road sent for creation");
    }
  }