make nodes smaller when zoomed out
This commit is contained in:
+1
-1
@@ -48,7 +48,7 @@ mod_name=Fretux's Skill Engine
|
|||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=All Rights Reserved
|
mod_license=All Rights Reserved
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=1.4.7
|
mod_version=1.4.8
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
# This should match the base package used for the mod sources.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import java.util.List;
|
|||||||
public class SkilltreeScreen extends Screen {
|
public class SkilltreeScreen extends Screen {
|
||||||
private static final int NODE_RADIUS = 12;
|
private static final int NODE_RADIUS = 12;
|
||||||
private static final int ABILITY_RADIUS = 12;
|
private static final int ABILITY_RADIUS = 12;
|
||||||
|
private static final int NODE_ICON_SIZE = 16;
|
||||||
private static final int OVERLAY_WIDTH = 240;
|
private static final int OVERLAY_WIDTH = 240;
|
||||||
private static final int OVERLAY_HEIGHT = 180;
|
private static final int OVERLAY_HEIGHT = 180;
|
||||||
private static final int OVERLAY_CONTENT_HEIGHT = 160;
|
private static final int OVERLAY_CONTENT_HEIGHT = 160;
|
||||||
@@ -212,6 +213,7 @@ public class SkilltreeScreen extends Screen {
|
|||||||
}
|
}
|
||||||
for (AbilityNode ability : AbilityNodeRegistry.all()) {
|
for (AbilityNode ability : AbilityNodeRegistry.all()) {
|
||||||
int[] pos = worldToScreen(ability.getX(), ability.getY());
|
int[] pos = worldToScreen(ability.getX(), ability.getY());
|
||||||
|
int radius = getRenderedNodeRadius(ABILITY_RADIUS);
|
||||||
boolean unlocked = SkilltreeClientState.isAbilityUnlocked(ability.getId());
|
boolean unlocked = SkilltreeClientState.isAbilityUnlocked(ability.getId());
|
||||||
int color;
|
int color;
|
||||||
if (ability.getId().equals(highlightedAbility)) {
|
if (ability.getId().equals(highlightedAbility)) {
|
||||||
@@ -225,28 +227,33 @@ public class SkilltreeScreen extends Screen {
|
|||||||
} else {
|
} else {
|
||||||
color = 0xFF223355;
|
color = 0xFF223355;
|
||||||
}
|
}
|
||||||
renderNodeFrame(gfx, pos[0], pos[1], ABILITY_RADIUS, color,
|
renderNodeFrame(gfx, pos[0], pos[1], radius, color,
|
||||||
ability == hoveredAbility, ability == selectedAbility, true);
|
ability == hoveredAbility, ability == selectedAbility, true);
|
||||||
ResourceLocation icon = ability.getIcon();
|
ResourceLocation icon = ability.getIcon();
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
gfx.blit(icon, pos[0] - 8, pos[1] - 8, 0, 0, 16, 16, 16, 16);
|
int size = getRenderedNodeIconSize();
|
||||||
|
gfx.blit(icon, pos[0] - size / 2, pos[1] - size / 2,
|
||||||
|
size, size, 0, 0,
|
||||||
|
NODE_ICON_SIZE, NODE_ICON_SIZE, NODE_ICON_SIZE, NODE_ICON_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (SkillNode node : activeSkillNodes()) {
|
for (SkillNode node : activeSkillNodes()) {
|
||||||
int[] pos = worldToScreen(node.getX(), node.getY());
|
int[] pos = worldToScreen(node.getX(), node.getY());
|
||||||
|
int radius = getRenderedNodeRadius(NODE_RADIUS);
|
||||||
int color = getNodeColor(node);
|
int color = getNodeColor(node);
|
||||||
renderNodeFrame(gfx, pos[0], pos[1], NODE_RADIUS, color,
|
renderNodeFrame(gfx, pos[0], pos[1], radius, color,
|
||||||
node == hoveredNode, node == selectedNode, false);
|
node == hoveredNode, node == selectedNode, false);
|
||||||
ResourceLocation icon = node.getIcons();
|
ResourceLocation icon = node.getIcons();
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
int size = 16;
|
int size = getRenderedNodeIconSize();
|
||||||
gfx.blit(
|
gfx.blit(
|
||||||
icon,
|
icon,
|
||||||
pos[0] - size / 2,
|
pos[0] - size / 2,
|
||||||
pos[1] - size / 2,
|
pos[1] - size / 2,
|
||||||
0, 0,
|
|
||||||
size, size,
|
size, size,
|
||||||
size, size
|
0, 0,
|
||||||
|
NODE_ICON_SIZE, NODE_ICON_SIZE,
|
||||||
|
NODE_ICON_SIZE, NODE_ICON_SIZE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -484,9 +491,10 @@ public class SkilltreeScreen extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SkillNode findNodeAt(double mouseX, double mouseY) {
|
private SkillNode findNodeAt(double mouseX, double mouseY) {
|
||||||
|
int radius = getRenderedNodeRadius(NODE_RADIUS);
|
||||||
for (SkillNode node : activeSkillNodes()) {
|
for (SkillNode node : activeSkillNodes()) {
|
||||||
int[] pos = worldToScreen(node.getX(), node.getY());
|
int[] pos = worldToScreen(node.getX(), node.getY());
|
||||||
if (isPointInCircle(mouseX, mouseY, pos[0], pos[1], NODE_RADIUS)) {
|
if (isPointInCircle(mouseX, mouseY, pos[0], pos[1], radius)) {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -494,15 +502,24 @@ public class SkilltreeScreen extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private AbilityNode findAbilityAt(double mouseX, double mouseY) {
|
private AbilityNode findAbilityAt(double mouseX, double mouseY) {
|
||||||
|
int radius = getRenderedNodeRadius(ABILITY_RADIUS);
|
||||||
for (AbilityNode ability : AbilityNodeRegistry.all()) {
|
for (AbilityNode ability : AbilityNodeRegistry.all()) {
|
||||||
int[] pos = worldToScreen(ability.getX(), ability.getY());
|
int[] pos = worldToScreen(ability.getX(), ability.getY());
|
||||||
if (isPointInCircle(mouseX, mouseY, pos[0], pos[1], ABILITY_RADIUS)) {
|
if (isPointInCircle(mouseX, mouseY, pos[0], pos[1], radius)) {
|
||||||
return ability;
|
return ability;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getRenderedNodeRadius(int baseRadius) {
|
||||||
|
return Math.max(1, Math.round(baseRadius * Math.min(1.0f, zoom)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getRenderedNodeIconSize() {
|
||||||
|
return Math.max(1, Math.round(NODE_ICON_SIZE * Math.min(1.0f, zoom)));
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isPointInCircle(double mx, double my, int cx, int cy, int radius) {
|
private boolean isPointInCircle(double mx, double my, int cx, int cy, int radius) {
|
||||||
return mx >= cx - radius && mx <= cx + radius &&
|
return mx >= cx - radius && mx <= cx + radius &&
|
||||||
my >= cy - radius && my <= cy + radius;
|
my >= cy - radius && my <= cy + radius;
|
||||||
|
|||||||
Reference in New Issue
Block a user