From e9734f233ab68b1c4cabd103c66fc722b0315cdb Mon Sep 17 00:00:00 2001 From: Smyler Date: Fri, 23 Oct 2020 11:46:03 +0200 Subject: [PATCH] Show a message and do not crash with outdated Terra121 --- gradle.properties | 2 +- .../terramap/gui/TerramapScreen.java | 40 ++++++++++++------- .../resources/assets/terramap/lang/en_us.lang | 1 + .../resources/assets/terramap/lang/fr_fr.lang | 1 + 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/gradle.properties b/gradle.properties index 1be92924..08f98cef 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,6 +10,6 @@ forge_version = 1.12.2-14.23.5.2847 mcp_mappings = stable_39 # Mod stuff -mod_version = 1.0.0-beta6 +mod_version = 1.0.0-beta6.1 mod_group = fr.thesmyler.terramap mod_id = terramap diff --git a/src/main/java/fr/thesmyler/terramap/gui/TerramapScreen.java b/src/main/java/fr/thesmyler/terramap/gui/TerramapScreen.java index 214acc12..00177ffb 100644 --- a/src/main/java/fr/thesmyler/terramap/gui/TerramapScreen.java +++ b/src/main/java/fr/thesmyler/terramap/gui/TerramapScreen.java @@ -222,22 +222,36 @@ public void onUpdate(Screen parent) { double mouseLat = this.map.getMouseLatitude(); double mouseLon = this.map.getMouseLongitude(); - String displayLat = GeoServices.formatGeoCoordForDisplay(mouseLat); - String displayLon = GeoServices.formatGeoCoordForDisplay(mouseLon); String formatX = "-"; String formatZ = "-"; String formatScale = "-"; String formatOrientation = "-"; if(Math.abs(mouseLat) > WebMercatorUtils.LIMIT_LATITUDE) { - displayLat = "-"; - displayLon = "-"; - } else if(projection != null) { - double[] pos = projection.fromGeo(mouseLon, mouseLat); - formatX = "" + Math.round(pos[0]); - formatZ = "" + Math.round(pos[1]); - double[] dist = projection.tissot(mouseLon, mouseLat, 0.0000001f); - formatScale = "" + GeoServices.formatGeoCoordForDisplay(Math.sqrt(Math.abs(dist[0]))); - formatOrientation = "" + GeoServices.formatGeoCoordForDisplay(dist[1]*180.0/Math.PI); + this.distortionText.setText(I18n.format("terramap.terramapscreen.information.distortion", "-", "-")); + this.mouseGeoLocationText.setText(I18n.format("terramap.terramapscreen.information.mouse_geo", "-", "-")); + this.mouseMCLocationText.setText(I18n.format("terramap.terramapscreen.information.mouse_mc", "-", "-")); + } else { + String displayLat = GeoServices.formatGeoCoordForDisplay(mouseLat); + String displayLon = GeoServices.formatGeoCoordForDisplay(mouseLon); + this.mouseGeoLocationText.setText(I18n.format("terramap.terramapscreen.information.mouse_geo", displayLat, displayLon)); + if(projection != null) { + double[] pos = projection.fromGeo(mouseLon, mouseLat); + formatX = "" + Math.round(pos[0]); + formatZ = "" + Math.round(pos[1]); + this.mouseMCLocationText.setText(I18n.format("terramap.terramapscreen.information.mouse_mc", formatX, formatZ)); + try { + double[] dist = projection.tissot(mouseLon, mouseLat, 0.0000001f); + formatScale = "" + GeoServices.formatGeoCoordForDisplay(Math.sqrt(Math.abs(dist[0]))); + formatOrientation = "" + GeoServices.formatGeoCoordForDisplay(dist[1]*180.0/Math.PI); + this.distortionText.setText(I18n.format("terramap.terramapscreen.information.distortion", formatScale, formatOrientation)); + } catch(NoSuchMethodError e) { + this.distortionText.setText(I18n.format("terramap.terramapscreen.information.outdatedterra121")); + this.distortionText.setBaseColor(0xFFFF0000); + } + } else { + this.distortionText.setText(I18n.format("terramap.terramapscreen.information.distortion", "-", "-")); + this.mouseMCLocationText.setText(I18n.format("terramap.terramapscreen.information.mouse_mc", "-", "-")); + } } if(this.map.isTracking()) { @@ -266,10 +280,6 @@ public void onUpdate(Screen parent) { } else { this.playerGeoLocationText.setText(I18n.format("terramap.terramapscreen.information.noplayer")); } - - this.mouseGeoLocationText.setText(I18n.format("terramap.terramapscreen.information.mouse_geo", displayLat, displayLon)); - this.mouseMCLocationText.setText(I18n.format("terramap.terramapscreen.information.mouse_mc", formatX, formatZ)); - this.distortionText.setText(I18n.format("terramap.terramapscreen.information.distortion", formatScale, formatOrientation)); if(this.debugMode) { String dbText = ""; diff --git a/src/main/resources/assets/terramap/lang/en_us.lang b/src/main/resources/assets/terramap/lang/en_us.lang index eb9bf615..5da4f9a6 100644 --- a/src/main/resources/assets/terramap/lang/en_us.lang +++ b/src/main/resources/assets/terramap/lang/en_us.lang @@ -75,6 +75,7 @@ terramap.terramapscreen.information.playerout=You are outside the projection terramap.terramapscreen.information.playergeo=Player position: %1$s° %2$s° terramap.terramapscreen.information.noplayer=Player position: -° -° terramap.terramapscreen.information.distortion=Distortion: %1$s blocks/m ; ±%2$s° +terramap.terramapscreen.information.outdatedterra121=Please update Terra121 terramap.terramapscreen.markercontrollers.buttons.mainplayer=Toggle main player visibility terramap.terramapscreen.markercontrollers.buttons.otherplayer=Toggle other players visibility diff --git a/src/main/resources/assets/terramap/lang/fr_fr.lang b/src/main/resources/assets/terramap/lang/fr_fr.lang index dcbe08fd..9aafcab8 100644 --- a/src/main/resources/assets/terramap/lang/fr_fr.lang +++ b/src/main/resources/assets/terramap/lang/fr_fr.lang @@ -75,6 +75,7 @@ terramap.terramapscreen.information.playerout=Vous êtes en dehors de la project terramap.terramapscreen.information.playergeo=Position du joueur: %1$s° %2$s° terramap.terramapscreen.information.noplayer=Position du joueur: -° -° terramap.terramapscreen.information.distortion=Distortion: %1$s blocks/m ; ±%2$s° +terramap.terramapscreen.information.outdatedterra121=Merci de mettre à jour Terra121 terramap.terramapscreen.markercontrollers.buttons.mainplayer=Changer la visibilité du joueur principal terramap.terramapscreen.markercontrollers.buttons.otherplayer=Changer la visibilité des autres joueurs