Skip to content

Commit

Permalink
feat: Shift middle click to place multiple markers on guild map [skip…
Browse files Browse the repository at this point in the history
… ci] (#2469)

feat: Shift middle click to place multiple markers on guild map
  • Loading branch information
ShadowCat117 committed May 7, 2024
1 parent b57566a commit 1d83ba3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,14 @@ protected List<Poi> getRenderedPois(
return filteredPois;
}

protected void setCompassToMouseCoords(double mouseX, double mouseY) {
protected void setCompassToMouseCoords(double mouseX, double mouseY, boolean removeAll) {
if (removeAll) {
Models.Marker.USER_WAYPOINTS_PROVIDER.removeAllLocations();
}

double gameX = (mouseX - centerX) / zoomRenderScale + mapCenterX;
double gameZ = (mouseY - centerZ) / zoomRenderScale + mapCenterZ;
Location compassLocation = Location.containing(gameX, 0, gameZ);
Models.Marker.USER_WAYPOINTS_PROVIDER.removeAllLocations();
Models.Marker.USER_WAYPOINTS_PROVIDER.addLocation(compassLocation);

McUtils.playSoundUI(SoundEvents.EXPERIENCE_ORB_PICKUP);
Expand Down
21 changes: 8 additions & 13 deletions common/src/main/java/com/wynntils/screens/maps/GuildMapScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.wynntils.utils.colors.CommonColors;
import com.wynntils.utils.mc.KeyboardUtils;
import com.wynntils.utils.mc.McUtils;
import com.wynntils.utils.mc.type.Location;
import com.wynntils.utils.render.FontRenderer;
import com.wynntils.utils.render.MapRenderer;
import com.wynntils.utils.render.RenderUtils;
Expand All @@ -42,7 +41,6 @@
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvents;
import org.lwjgl.glfw.GLFW;

public final class GuildMapScreen extends AbstractMapScreen {
Expand Down Expand Up @@ -84,7 +82,13 @@ protected void doInit() {
.append(Component.translatable("screens.wynntils.map.help.name")),
Component.literal("- ")
.withStyle(ChatFormatting.GRAY)
.append(Component.translatable("screens.wynntils.guildMap.help.description1")))));
.append(Component.translatable("screens.wynntils.guildMap.help.description1")),
Component.literal("- ")
.withStyle(ChatFormatting.GRAY)
.append(Component.translatable("screens.wynntils.guildMap.help.description2")),
Component.literal("- ")
.withStyle(ChatFormatting.GRAY)
.append(Component.translatable("screens.wynntils.guildMap.help.description3")))));

this.addRenderableWidget(
hybridModeButton = new BasicTexturedButton(
Expand Down Expand Up @@ -287,18 +291,9 @@ public boolean doMouseClicked(double mouseX, double mouseY, int button) {
Models.Marker.USER_WAYPOINTS_PROVIDER.removeLocation(
hovered.getLocation().asLocation());
return true;
} else if (hovered instanceof TerritoryPoi) {
McUtils.playSoundUI(SoundEvents.EXPERIENCE_ORB_PICKUP);

// If shift is not held down, clear all waypoints to only have the new one
if (!KeyboardUtils.isShiftDown()) {
Models.Marker.USER_WAYPOINTS_PROVIDER.removeAllLocations();
}

Models.Marker.USER_WAYPOINTS_PROVIDER.addLocation(new Location(hovered.getLocation()));
}
} else if (button == GLFW.GLFW_MOUSE_BUTTON_MIDDLE) {
setCompassToMouseCoords(mouseX, mouseY);
setCompassToMouseCoords(mouseX, mouseY, !KeyboardUtils.isShiftDown());
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public boolean doMouseClicked(double mouseX, double mouseY, int button) {
if (button == GLFW.GLFW_MOUSE_BUTTON_RIGHT) {
List<MarkerInfo> markers =
Models.Marker.USER_WAYPOINTS_PROVIDER.getMarkerInfos().toList();
if (McUtils.player().isShiftKeyDown() && !markers.isEmpty()) {
if (KeyboardUtils.isShiftDown() && !markers.isEmpty()) {
// -1 is fine as the index since we always increment it by 1
int index = markers.indexOf(focusedMarker);
MarkerInfo markerInfo = markers.get((index + 1) % markers.size());
Expand Down Expand Up @@ -441,7 +441,7 @@ public boolean doMouseClicked(double mouseX, double mouseY, int button) {
customPois.touched();
}
} else {
setCompassToMouseCoords(mouseX, mouseY);
setCompassToMouseCoords(mouseX, mouseY, true);
return true;
}
}
Expand Down
4 changes: 3 additions & 1 deletion common/src/main/resources/assets/wynntils/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,9 @@
"screens.wynntils.guildMap.cycleDefenseFilter.description3": "Middle click to turn off.",
"screens.wynntils.guildMap.cycleDefenseFilter.description4": "Current value: ",
"screens.wynntils.guildMap.cycleDefenseFilter.name": "Cycle Territory Defense Filter",
"screens.wynntils.guildMap.help.description1": "Shift-Right on a territory to open the territory management menu.",
"screens.wynntils.guildMap.help.description1": "Shift-Right click on a territory to open the territory management menu.",
"screens.wynntils.guildMap.help.description2": "Middle click to replace the compass marker on the map.",
"screens.wynntils.guildMap.help.description3": "Shift-Middle click to place an additional compass marker.",
"screens.wynntils.guildMap.hybridMode.advancement": "Advancement",
"screens.wynntils.guildMap.hybridMode.description1": "Click here to switch between hybrid mode and advancement mode. When in hybrid mode, the map will use the territory API combined with advancement data to show the most accurate information possible.",
"screens.wynntils.guildMap.hybridMode.description2": "Current mode: ",
Expand Down

0 comments on commit 1d83ba3

Please sign in to comment.