Fix waypoint stringification logic
This commit is contained in:
parent
0e55d1cc37
commit
d950e45e49
|
@ -9,6 +9,8 @@ import xaero.common.minimap.waypoints.WaypointWorld;
|
||||||
import xaero.common.minimap.waypoints.WaypointWorldRootContainer;
|
import xaero.common.minimap.waypoints.WaypointWorldRootContainer;
|
||||||
import xaero.map.mods.gui.Waypoint;
|
import xaero.map.mods.gui.Waypoint;
|
||||||
import xaero.map.mods.SupportMods;
|
import xaero.map.mods.SupportMods;
|
||||||
|
import static xaero.common.settings.ModSettings.COLORS;
|
||||||
|
import static io.github.vftdan.xaeromapaddon.VftdansXaerosMapAddon.LOGGER;
|
||||||
|
|
||||||
public class ClipboardCopyWaypointAction implements WaypointAction {
|
public class ClipboardCopyWaypointAction implements WaypointAction {
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,6 +28,16 @@ public class ClipboardCopyWaypointAction implements WaypointAction {
|
||||||
return "gui.vftdan.xaero_right_click_waypoint.copy_to_clipboard";
|
return "gui.vftdan.xaero_right_click_waypoint.copy_to_clipboard";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int reverseLookupColor(int rgba) {
|
||||||
|
for (int i = 0; i < COLORS.length; ++i) {
|
||||||
|
if (COLORS[i] == rgba) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOGGER.warn("Failed to reverse-lookup color " + rgba);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public static String waypointToShareableString(Waypoint w) {
|
public static String waypointToShareableString(Waypoint w) {
|
||||||
WaypointWorld waypointWorld = SupportMods.xaeroMinimap.getWaypointWorld();
|
WaypointWorld waypointWorld = SupportMods.xaeroMinimap.getWaypointWorld();
|
||||||
String dimInfo;
|
String dimInfo;
|
||||||
|
@ -45,7 +57,7 @@ public class ClipboardCopyWaypointAction implements WaypointAction {
|
||||||
dim = "the_end";
|
dim = "the_end";
|
||||||
}
|
}
|
||||||
containerKeyElements[1] = dim;
|
containerKeyElements[1] = dim;
|
||||||
internalInfo = String.join("/", Arrays.copyOfRange(containerKeyElements, 1, containerKeyElements.length));
|
internalInfo = escapeWaypointComponent(String.join("/", Arrays.copyOfRange(containerKeyElements, 1, containerKeyElements.length))) + "_waypoints";
|
||||||
}
|
}
|
||||||
dimInfo = "Internal_" + internalInfo;
|
dimInfo = "Internal_" + internalInfo;
|
||||||
} else {
|
} else {
|
||||||
|
@ -57,11 +69,10 @@ public class ClipboardCopyWaypointAction implements WaypointAction {
|
||||||
String x = w.getX() + "";
|
String x = w.getX() + "";
|
||||||
String y = w.isyIncluded() ? Integer.valueOf(w.getY()) + "" : "~";
|
String y = w.isyIncluded() ? Integer.valueOf(w.getY()) + "" : "~";
|
||||||
String z = w.getZ() + "";
|
String z = w.getZ() + "";
|
||||||
String color = w.getColor() + "";
|
String color = reverseLookupColor(w.getColor()) + "";
|
||||||
String isRotation = w.isRotation() + "";
|
String isRotation = w.isRotation() + "";
|
||||||
String yaw = w.getYaw() + "";
|
String yaw = w.getYaw() + "";
|
||||||
String dimInfoEscaped = escapeWaypointComponent(dimInfo);
|
return "xaero-waypoint:" + title + ":" + icon + ":" + x + ":" + y + ":" + z + ":" + color + ":" + isRotation + ":" + yaw + ":" + dimInfo;
|
||||||
return "xaero-waypoint:" + title + ":" + icon + ":" + x + ":" + y + ":" + z + ":" + color + ":" + isRotation + ":" + yaw + ":" + dimInfoEscaped;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String escapeWaypointComponent(String unsafe) {
|
public static String escapeWaypointComponent(String unsafe) {
|
||||||
|
|
Loading…
Reference in New Issue