Skip to content

Commit

Permalink
Final tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
iChun committed Apr 9, 2021
1 parent c352861 commit ffbacf8
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 15 deletions.
31 changes: 28 additions & 3 deletions src/main/java/me/ichun/mods/hats/client/gui/TutorialHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,32 @@
import me.ichun.mods.hats.common.Hats;
import me.ichun.mods.hats.common.hats.HatHandler;
import me.ichun.mods.hats.common.packet.PacketGiveHat;
import me.ichun.mods.ichunutil.client.gui.bns.window.Window;
import me.ichun.mods.ichunutil.client.gui.bns.window.WindowGreyout;
import net.minecraft.client.resources.I18n;

public class TutorialHandler
{
private static void disableGreyoutClickOut(WorkspaceHats workspace)
{
for(Window<?> window : workspace.windows)
{
if(window instanceof WindowGreyout)
{
((WindowGreyout)window).disableClickOut();
}
}
}

public static void startTutorial(WorkspaceHats workspace)
{
if(Hats.eventHandlerClient.serverHasMod && HatHandler.getPlayerInventory(workspace.getMinecraft().player).isEmpty())
if(Hats.eventHandlerClient.serverHasMod && workspace.windowHatsList.getCurrentView().list.elements.isEmpty())
{
workspace.popup(0.6D, 0.5D, w -> cameraIntro((WorkspaceHats)w), I18n.format("hats.gui.tutorial.noHat"));
disableGreyoutClickOut(workspace);

workspace.windowHatsList.getCurrentView().textField.setText("");
workspace.windowHatsList.getCurrentView().updateSearch("");

Hats.channel.sendToServer(new PacketGiveHat());
}
Expand All @@ -26,10 +43,11 @@ private static void cameraIntro(WorkspaceHats workspace)
{
WindowTutorial camTut = new WindowTutorial(workspace, WindowTutorial.Direction.LEFT, workspace.windowHatsList.getLeft() - 10, workspace.windowHatsList.getTop() + (workspace.windowHatsList.getHeight() / 2), (int)(workspace.windowHatsList.getWidth() * 0.8F), 200, w ->
{
WindowTutorial hatsTut = new WindowTutorial(workspace, WindowTutorial.Direction.RIGHT, workspace.windowHatsList.getLeft() + 40, workspace.windowHatsList.getTop() + (workspace.windowHatsList.getHeight() / 2), (int)(workspace.windowHatsList.getLeft() * 0.8F), 100, w2 -> {
WindowTutorial hatsTut = new WindowTutorial(workspace, WindowTutorial.Direction.RIGHT, workspace.windowHatsList.getLeft() + 40, workspace.windowHatsList.getTop() + (workspace.windowHatsList.getHeight() / 2), (int)(workspace.windowHatsList.getLeft() * 0.8F), 150, w2 -> {
if(workspace.windowHatsList.getCurrentView().list.elements.isEmpty())
{
workspace.popup(0.6D, 0.5D, w1 -> hatSelectIntro((WorkspaceHats)w1), I18n.format("hats.gui.tutorial.clickForHatMissing"));
disableGreyoutClickOut(workspace);
}
else
{
Expand All @@ -38,37 +56,44 @@ private static void cameraIntro(WorkspaceHats workspace)

}, I18n.format("hats.gui.tutorial.hatsHere"));
workspace.addWindowWithGreyout(hatsTut);
disableGreyoutClickOut(workspace);
hatsTut.init();

}, I18n.format(workspace.fallback ? "hats.gui.tutorial.cameraFallback" : "hats.gui.tutorial.camera"));
workspace.addWindowWithHalfGreyout(camTut);
disableGreyoutClickOut(workspace);
camTut.init();
}

private static void hatSelectIntro(WorkspaceHats workspace)
{
WindowTutorial hatSelectTut = new WindowTutorial(workspace, WindowTutorial.Direction.RIGHT, workspace.windowHatsList.getCurrentView().list.getLeft() + 25, workspace.windowHatsList.getCurrentView().list.getTop() + 40, (int)(workspace.windowHatsList.getLeft() * 0.8F), 200, w -> {
WindowTutorial hatSelectTut = new WindowTutorial(workspace, WindowTutorial.Direction.RIGHT, workspace.windowHatsList.getCurrentView().list.getLeft() + 25, workspace.windowHatsList.getCurrentView().list.getTop() + 40, (int)(workspace.windowHatsList.getLeft() * 0.8F), 150, w -> {
WindowTutorial searchTut = new WindowTutorial(workspace, WindowTutorial.Direction.RIGHT, workspace.windowHatsList.getCurrentView().textField.getLeft(), workspace.windowHatsList.getCurrentView().textField.getTop() + (workspace.windowHatsList.getCurrentView().textField.getHeight() / 2), (int)(workspace.windowHatsList.getLeft() * 0.8F), 150, w1 -> {
WindowTutorial addBtnTut = new WindowTutorial(workspace, WindowTutorial.Direction.RIGHT, workspace.windowSidebar.getCurrentView().randomButton.getLeft(), workspace.windowSidebar.getCurrentView().randomButton.getBottom(), (int)(workspace.windowHatsList.getLeft() * 0.8F), 150, w2 -> {
WindowTutorial dragTut = new WindowTutorial(workspace, WindowTutorial.Direction.RIGHT, workspace.windowHatsList.getLeft(), workspace.windowHatsList.getTop() + (workspace.windowHatsList.getHeight() / 2), (int)(workspace.windowHatsList.getLeft() * 0.8F), 200, w7 -> {
workspace.popup(0.6D, 0.5D, w4 -> {
workspace.finishTutorial();
}, I18n.format("hats.gui.tutorial.conclusion"));
disableGreyoutClickOut(workspace);

}, I18n.format("hats.gui.tutorial.dragBar"));
workspace.addWindowWithGreyout(dragTut);
disableGreyoutClickOut(workspace);
dragTut.init();

}, I18n.format("hats.gui.tutorial.additionalButtons"));
workspace.addWindowWithGreyout(addBtnTut);
disableGreyoutClickOut(workspace);
addBtnTut.init();

}, I18n.format("hats.gui.tutorial.search"));
workspace.addWindowWithGreyout(searchTut);
disableGreyoutClickOut(workspace);
searchTut.init();

}, I18n.format("hats.gui.tutorial.clickForHat"));
workspace.addWindowWithGreyout(hatSelectTut);
disableGreyoutClickOut(workspace);
hatSelectTut.init();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,20 @@ public void render(MatrixStack stack, int mouseX, int mouseY, float partialTick)
if(!parent.getEventListeners().contains(attachedWindow))
{
parent.removeWindow(this);
if(closeConsumer != null)
{
closeConsumer.accept(this);
}
}
}

@Override
public boolean mouseClicked(double mouseX, double mouseY, int button)
{
if(mouseX > parent.windowHatsList.getLeft() && isMouseOver(mouseX, mouseY)) //only the second half of the screen
if(!disableClickOut && mouseX > parent.windowHatsList.getLeft() && isMouseOver(mouseX, mouseY)) //only the second half of the screen
{
parent.removeWindow(attachedWindow);
parent.removeWindow(this);
if(closeConsumer != null)
{
closeConsumer.accept(this);
}
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ public void addHatSorterToList(ElementList<?> list, HatSorter filterSorter, int
}
}

btn.toggleState = true;

item.getObject().isInverse = false;
});
btnStack.setSize(14, 14).setId("btnDisabled");
Expand All @@ -182,6 +184,8 @@ public void addHatSorterToList(ElementList<?> list, HatSorter filterSorter, int
}
}

btn.toggleState = true;

item.getObject().isInverse = true;
});
btnStack.setSize(14, 14).setId("btnInverse");
Expand All @@ -199,6 +203,8 @@ public void addHatSorterToList(ElementList<?> list, HatSorter filterSorter, int
}
}

btn.toggleState = true;

item.getObject().isInverse = false;
});
btnStack.setSize(14, 14).setId("btnEnabled");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public ViewTutorial(@Nonnull WindowTutorial parent, @Nullable Consumer<Workspace

ElementTextWrapper text1 = new ElementTextWrapper(this);
text1.setText(text);
text1.constraints().top(this, Constraint.Property.Type.TOP, padding).bottom(this, Constraint.Property.Type.BOTTOM, 30).left(this, Constraint.Property.Type.LEFT, padding).right(this, Constraint.Property.Type.RIGHT, padding);
text1.constraints().top(this, Constraint.Property.Type.TOP, padding).bottom(this, Constraint.Property.Type.BOTTOM, 30).left(this, Constraint.Property.Type.LEFT, 10).right(this, Constraint.Property.Type.RIGHT, 10);
elements.add(text1);

ElementButton<?> button = new ElementButton<>(this, I18n.format("gui.ok"), elementClickable ->
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/me/ichun/mods/hats/common/hats/HatInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class HatInfo
public final @Nonnull Project project;
public final ArrayList<HatInfo> accessories = new ArrayList<>();
public final ArrayList<String> hideParent = new ArrayList<>();
public final ArrayList<Project.Part> allParts = new ArrayList<>();

private EnumRarity rarity; //Config synching should set this for the client
private int worth = -1;
Expand Down Expand Up @@ -69,6 +70,7 @@ public HatInfo(@Nonnull String name, @Nonnull Project project) //TODO head top/e
this.name = name;
this.project = project;
this.project.name = name;
this.allParts.addAll(this.project.getAllParts()); //yay optimising?

if(FMLEnvironment.dist.isClient())
{
Expand Down Expand Up @@ -154,7 +156,7 @@ public void render(MatrixStack stack, IRenderTypeBuffer bufferIn, int packedLigh
{
if(!hidden)
{
for(Project.Part part : project.getAllParts())
for(Project.Part part : allParts)
{
part.showModel = true;
}
Expand All @@ -165,7 +167,7 @@ public void render(MatrixStack stack, IRenderTypeBuffer bufferIn, int packedLigh
{
for(String s : accessory.hideParent)
{
for(Project.Part part : project.getAllParts())
for(Project.Part part : allParts)
{
if(part.name.equals(s))
{
Expand Down Expand Up @@ -585,7 +587,7 @@ public float[] getDimensions() //gets y min + y-max + width
float y2 = -10000;


for(Project.Part part : project.getAllParts())
for(Project.Part part : allParts)
{
for(Project.Part.Box box : part.boxes)
{
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/assets/hats/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@
"hats.gui.tutorial.noHat": "Uh oh, it looks like you have no hats yet.\n\nWe've asked the server to give you one.\n\nDon't worry, that one's on me!",
"hats.gui.tutorial.camera": "You can control the view on the left using your mouse.\n\nFeel free to click and drag using your mouse buttons and scroll wheel.\n\nGo ahead and try it out now!",
"hats.gui.tutorial.cameraFallback": "You can control the view on the left using your mouse.\n\nUsually, you can click and drag using your mouse buttons and scroll wheel, but we are in fallback mode right now, so maybe try it later?",
"hats.gui.tutorial.hatsHere": "Hats you have unlocked are here.",
"hats.gui.tutorial.hatsHere": "Hats you have unlocked are here.\n\n(Don't actually click now, the interactive part of the tutorial is over)",
"hats.gui.tutorial.clickForHatMissing": "You're supposed to have a hat now, but it seems we can't find one.\n\nMaybe your filters may have hidden them?\n\nAnyways...",
"hats.gui.tutorial.clickForHat": "You can click on a hat to wear it, or right click for additional options\n\n(Don't actually click now, the interactive part of the tutorial is over, you'll just cancel the tutorial)",
"hats.gui.tutorial.search": "You can search for a specific hat here.\n\nRight click to clear.",
"hats.gui.tutorial.clickForHat": "You can click on a hat to wear it, or right click for additional options",
"hats.gui.tutorial.search": "You can search for a specific hat here.\n\nYou can also Right click to clear.",
"hats.gui.tutorial.additionalButtons": "Additional buttons up here.\n\nMouse over for tooltips.",
"hats.gui.tutorial.dragBar": "Need more space to see your hats?\n\nDrag this to the left.",
"hats.gui.tutorial.conclusion": "And that's it!\n\nThank you for playing and enjoy Hats!",
Expand Down

0 comments on commit ffbacf8

Please sign in to comment.