Skip to content

Commit

Permalink
- player outline based on class
Browse files Browse the repository at this point in the history
Signed-off-by: syeyoung <[email protected]>
  • Loading branch information
cyoung06 committed Aug 13, 2024
1 parent f0ff449 commit e45e93c
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import kr.syeyoung.dungeonsguide.mod.guiv2.GuiScreenAdapterChestOverride;
import kr.syeyoung.dungeonsguide.mod.parallelUniverse.tab.TabListEntry;
import kr.syeyoung.dungeonsguide.mod.utils.TabListUtil;
import kr.syeyoung.dungeonsguide.mod.utils.TextUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.Gui;
Expand All @@ -27,12 +28,23 @@ public class MapOverlayPlayerClickable implements MapOverlay {
private String name;
private MapConfiguration.PlayerHeadSettings settings;
private WarpTarget target;
private String clazz;

public MapOverlayPlayerClickable(TabListEntry entry, MapConfiguration.PlayerHeadSettings headSettings, WarpTarget target) {
this.name = TabListUtil.getPlayerNameWithChecks(entry);
this.entry = entry;
this.settings = headSettings;
this.target = target;


if (entry == null) {
this.clazz = "";
} else {
int idx = entry.getEffectiveName().indexOf("§r§f(");
String clazzThing = entry.getEffectiveName().substring(idx);

this.clazz = TextUtils.stripColor(clazzThing).substring(1);
}
}

public Vector3d getLocation(float partialTicks) {
Expand Down Expand Up @@ -112,6 +124,22 @@ public void doRender(float rotation, float partialTicks, double scale, double re
// cutting out the player head out of the skin texture
if (relMouseX > -4 * settings.getIconSize() && relMouseX < 4 * settings.getIconSize() && relMouseY > -4 * settings.getIconSize() && relMouseY < 4 * settings.getIconSize()) {
Gui.drawRect(-5, -5, 5, 5, 0xFF00FF00);
} else {
int color = 0xFFFFFFFF;
if (clazz.startsWith("Archer")) {
color = (0xFF5cae76); // green
} else if (clazz.startsWith("Berserk")) {
color = (0xFFdb4d46); // red
} else if (clazz.startsWith("Mage")) {
color = (0xFFba75e6); // purple
} else if (clazz.startsWith("Healer")) {
color = (0xFFe4b64e); // yellow
} else if (clazz.startsWith("Tank")) {
color = (0xFF8fd1c9); // blue
} else if (clazz.startsWith("DEAD")) {
color = (0xFF333333); // black
}
Gui.drawRect(-5, -5, 5, 5, color);
}
GlStateManager.color(1,1,1,1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind;
import kr.syeyoung.dungeonsguide.mod.parallelUniverse.tab.TabListEntry;
import kr.syeyoung.dungeonsguide.mod.utils.RenderUtils;
import kr.syeyoung.dungeonsguide.mod.utils.TextUtils;
import kr.syeyoung.dungeonsguide.mod.utils.cursor.EnumCursor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
Expand All @@ -24,6 +25,7 @@ public class WidgetLeapPlayer extends AnnotatedImportOnlyWidget {
public final BindableAttribute<Integer> borderColor = new BindableAttribute<>(Integer.class);

private WarpTarget warpTarget;
private String clazz;

public WidgetLeapPlayer(WarpTarget target, TabListEntry entry) {
super(new ResourceLocation("dungeonsguide:gui/features/spiritleap/leapplayer.gui"));
Expand All @@ -33,10 +35,40 @@ public WidgetLeapPlayer(WarpTarget target, TabListEntry entry) {
this.playerName.setValue(target.getItemStack().getDisplayName());
this.texture.setValue(entry != null ? entry.getLocationSkin().toString() : "dungeonsguide:map/maptexture.png");
this.warpTarget = target;

if (entry == null) {
this.clazz = "";
} else {
int idx = entry.getEffectiveName().indexOf("§r§f(");
String clazzThing = entry.getEffectiveName().substring(idx);

this.clazz = TextUtils.stripColor(clazzThing).substring(1);
}
// based on Adaptive
if (clazz.startsWith("Archer")) {
this.borderColor.setValue(0xFF5cae76); // green
this.playerName.setValue("§c[A] §r"+target.getItemStack().getDisplayName());
} else if (clazz.startsWith("Berserk")) {
this.borderColor.setValue(0xFFdb4d46); // red
this.playerName.setValue("§c[B] §r"+target.getItemStack().getDisplayName());
} else if (clazz.startsWith("Mage")) {
this.borderColor.setValue(0xFFba75e6); // purple
this.playerName.setValue("§c[M] §r"+target.getItemStack().getDisplayName());
} else if (clazz.startsWith("Healer")) {
this.borderColor.setValue(0xFFe4b64e); // yellow
this.playerName.setValue("§c[H] §r"+target.getItemStack().getDisplayName());
} else if (clazz.startsWith("Tank")) {
this.borderColor.setValue(0xFF8fd1c9); // blue
this.playerName.setValue("§c[T] §r"+target.getItemStack().getDisplayName());
} else if (clazz.startsWith("DEAD")) {
this.borderColor.setValue(0xFF333333); // black
this.playerName.setValue("§c[Dead] §r"+target.getItemStack().getDisplayName());
}
}

@Override
public boolean mouseMoved(int absMouseX, int absMouseY, double relMouseX0, double relMouseY0, boolean childHandled) {
if (clazz.startsWith("DEAD")) return false;

getDomElement().setCursor(EnumCursor.POINTING_HAND);

Expand All @@ -47,11 +79,13 @@ public boolean mouseMoved(int absMouseX, int absMouseY, double relMouseX0, doubl

@Override
public void mouseExited(int absMouseX, int absMouseY, double relMouseX, double relMouseY) {
if (clazz.startsWith("DEAD")) return;
this.backgroundColor.setValue(0xFF555555);
}

@Override
public boolean mouseClicked(int absMouseX, int absMouseY, double relMouseX, double relMouseY, int mouseButton, boolean childHandled) {
if (clazz.startsWith("DEAD")) return false;
getDomElement().obtainFocus();

this.backgroundColor.setValue(0xFF888888);
Expand All @@ -61,6 +95,7 @@ public boolean mouseClicked(int absMouseX, int absMouseY, double relMouseX, doub

@Override
public void mouseReleased(int absMouseX, int absMouseY, double relMouseX, double relMouseY, int state) {
if (clazz.startsWith("DEAD")) return;
if (getDomElement().getAbsBounds().contains(absMouseX, absMouseY) && getDomElement().isFocused()) {
this.backgroundColor.setValue(0xFF777777);
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void onChestUpdate(WindowUpdateEvent windowUpdateEvent) {
if (stack != null && stack.getItem() == Items.skull) {
// if (prev == null) prev = new WidgetPartyElement(this, i);
// prev.update(PartyFinderParty.fromItemStack(stack));
System.out.println(stack.getTagCompound());
// System.out.println(stack.getTagCompound());
slotMap.put(i, new WarpTarget(stack, i));
}
}
Expand Down Expand Up @@ -152,11 +152,8 @@ public void update() {
if (name == null) continue;

map.put(name, playerInfo);


}


for (Map.Entry<Integer, WarpTarget> integerWarpTargetEntry : slotMap.entrySet()) {
this.api.getValue().addWidget(new WidgetLeapPlayer(integerWarpTargetEntry.getValue(), map.get(TextUtils.stripColor(integerWarpTargetEntry.getValue().getItemStack().getDisplayName()))));
}
Expand Down

0 comments on commit e45e93c

Please sign in to comment.