Skip to content

Commit

Permalink
Add two buttons and rename everything from 'in' to 'up'
Browse files Browse the repository at this point in the history
  • Loading branch information
ustc-zzzz committed Jul 26, 2021
1 parent 5915c09 commit 6f5e7f2
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 12 deletions.
17 changes: 16 additions & 1 deletion src/main/java/org/teacon/signin/client/GuideMapScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector3i;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import org.teacon.signin.SignMeUp;
import org.teacon.signin.data.GuideMap;
Expand Down Expand Up @@ -52,6 +53,7 @@ public final class GuideMapScreen extends Screen {
private final List<ResourceLocation> waypointIds;

private ImageButton leftFlip, rightFlip;
private ImageButton mapTriggerPrev, mapTriggerNext;

private final List<TriggerButton> mapTriggers = Lists.newArrayList();
private final ListMultimap<ResourceLocation, TriggerButton> waypointTriggers = ArrayListMultimap.create();
Expand All @@ -73,6 +75,10 @@ protected void init() {
this.leftFlip = this.addButton(new ImageButton(x1 + 7, y0 + 20, 10, 54, 155, 163, 0, GUIDE_MAP_RIGHT, new FlipHandler(1)));
this.rightFlip = this.addButton(new ImageButton(x1 + 93, y0 + 20, 10, 54, 167, 163, 0, GUIDE_MAP_RIGHT, new FlipHandler(-1)));

// Prev and next page for map triggers
this.mapTriggerPrev = this.addButton(new ImageButton(x0 + 6, y0 + 138, 33, 17, 66, 163, 19, GUIDE_MAP_LEFT, (btn) -> --this.mapTriggerPage));
this.mapTriggerNext = this.addButton(new ImageButton(x0 + 39, y0 + 138, 33, 17, 99, 163, 19, GUIDE_MAP_LEFT, (btn) -> ++this.mapTriggerPage));

// Setup trigger buttons from GuideMap
List<ResourceLocation> mapTriggerIds = this.map.getTriggerIds();
for (int i = 0, mapTriggerIdSize = mapTriggerIds.size(); i < mapTriggerIdSize; ++i) {
Expand Down Expand Up @@ -105,7 +111,7 @@ protected void init() {
double distance = Math.sqrt(wp.getActualLocation().distanceSq(this.playerLocation, true));
this.renderTooltip(transform, Arrays.asList(
wp.getTitle().func_241878_f(),
new TranslationTextComponent("sign_me_in.waypoint.distance",
new TranslationTextComponent("sign_up.waypoint.distance",
Math.round(distance * 10.0) / 10.0).func_241878_f()
), mouseX, mouseY);
}, wp.getTitle()));
Expand All @@ -125,6 +131,8 @@ protected void init() {

@Override
public void tick() {
this.mapTriggerPrev.visible = this.mapTriggerPage >= 1;
this.mapTriggerNext.visible = this.mapTriggerPage < this.mapTriggerPageSize - 1;
Waypoint wp = this.selectedWaypoint == null ? null : SignMeUp.MANAGER.findWaypoint(this.selectedWaypoint);
this.leftFlip.visible = this.rightFlip.visible = wp != null && !wp.isDisabled() && wp.hasMoreThanOneImage();
for (Map.Entry<ResourceLocation, TriggerButton> entry : this.waypointTriggers.entries()) {
Expand Down Expand Up @@ -152,6 +160,12 @@ public void render(MatrixStack transforms, int mouseX, int mouseY, float partial
}

private void renderTextCollection(FontRenderer font, MatrixStack transforms, int x0, int y0, int x1) {
// Display labels for prev and next page buttons
final int prevColor = this.mapTriggerPrev.visible ? 0x404040 : 0xFFFFFF;
final int nextColor = this.mapTriggerNext.visible ? 0x404040 : 0xFFFFFF;
ITextComponent prevPage = new StringTextComponent("<"), nextPage = new StringTextComponent(">");
font.drawText(transforms, prevPage, x0 + 23F - font.getStringPropertyWidth(prevPage) / 2F, y0 + 143F, prevColor);
font.drawText(transforms, nextPage, x0 + 56F - font.getStringPropertyWidth(nextPage) / 2F, y0 + 143F, nextColor);
// Display the subtitle/desc of the map if no waypoint is selected
ITextComponent title = this.map.getTitle(), subtitle = this.map.getSubtitle(), desc = this.map.getDesc();
if (this.selectedWaypoint != null) {
Expand Down Expand Up @@ -206,6 +220,7 @@ private void renderBackgroundTexture(Minecraft mc, MatrixStack transforms, int x
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.textureManager.bindTexture(GUIDE_MAP_LEFT);
blit(transforms, x0, y0, 0, 0, 211, 161);
blit(transforms, x0 + 6, y0 + 138, 66, 201, 66, 17);
mc.textureManager.bindTexture(GUIDE_MAP_RIGHT);
blit(transforms, x1 + 5, y0, 5, 0, 174, 161);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/teacon/signin/data/GuideMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public final class GuideMap {
List<ResourceLocation> triggerIds = Collections.emptyList();

public ITextComponent getTitle() {
return this.title != null ? this.title : new TranslationTextComponent("sign_me_in.map.unnamed");
return this.title != null ? this.title : new TranslationTextComponent("sign_up.map.unnamed");
}

public ITextComponent getSubtitle() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/teacon/signin/data/Trigger.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public final class Trigger implements PlayerTracker {
transient Set<ServerPlayerEntity> visiblePlayers = Collections.newSetFromMap(new WeakHashMap<>());

public ITextComponent getTitle() {
return this.title == null ? new TranslationTextComponent("sign_me_in.trigger.unnamed") : this.title;
return this.title == null ? new TranslationTextComponent("sign_up.trigger.unnamed") : this.title;
}

public ITextComponent getDesc() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/teacon/signin/data/Waypoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public JsonElement serialize(Location src, Type typeOfSrc, JsonSerializationCont
transient Set<ServerPlayerEntity> visiblePlayers = Collections.newSetFromMap(new WeakHashMap<>());

public ITextComponent getTitle() {
return title == null ? new TranslationTextComponent("sign_me_in.waypoint.unnamed") : this.title;
return title == null ? new TranslationTextComponent("sign_up.waypoint.unnamed") : this.title;
}

public ITextComponent getDesc() {
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/assets/sign_up/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"sign_up.keybinding": "Sign me Up",
"sign_up.keybinding.open_map": "Open guide map",

"sign_me_in.map.unnamed": "New Guide Map",
"sign_me_in.waypoint.unnamed": "New Waypoint",
"sign_me_in.waypoint.distance": "%1$s block(s) away from you",
"sign_me_in.trigger.unnamed": "New Trigger",
"sign_up.map.unnamed": "New Guide Map",
"sign_up.waypoint.unnamed": "New Waypoint",
"sign_up.waypoint.distance": "%1$s block(s) away from you",
"sign_up.trigger.unnamed": "New Trigger",

"sign_up.status.no_map_available": "No maps currently available :( or you might be outside of map range",

Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/assets/sign_up/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"sign_up.keybinding": "签到",
"sign_up.keybinding.open_map": "打开导引图",

"sign_me_in.map.unnamed": "新的导引图",
"sign_me_in.waypoint.unnamed": "新的导引点",
"sign_me_in.waypoint.distance": "这个点距离你的直线距离为 %1$s 方块",
"sign_me_in.trigger.unnamed": "新的触发器",
"sign_up.map.unnamed": "新的导引图",
"sign_up.waypoint.unnamed": "新的导引点",
"sign_up.waypoint.distance": "这个点距离你的直线距离为 %1$s 方块",
"sign_up.trigger.unnamed": "新的触发器",

"sign_up.status.no_map_available": "没有可供查看的导引图 :( 或者您可能在导引图范围之外",

Expand Down

0 comments on commit 6f5e7f2

Please sign in to comment.