Skip to content

Commit

Permalink
Calculate the chatbox position when dragging each frame
Browse files Browse the repository at this point in the history
Makes the drag buttery
  • Loading branch information
mattmess1221 committed Jun 14, 2019
1 parent 3e79f9f commit 875cc66
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main/java/mnm/mods/tabbychat/client/gui/ChatBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,13 @@ public void clearMessages() {
setStatus(DefaultChannel.INSTANCE, ChannelStatus.ACTIVE);
}


public AbstractChannel getActiveChannel() {
return active;
}

public void setActiveChannel(AbstractChannel channel) {
TextBox text = this.txtChatInput;


if (active.isPrefixHidden()
? text.getText().trim().isEmpty()
: text.getText().trim().equals(active.getPrefix())) {
Expand Down Expand Up @@ -231,6 +229,8 @@ private void runActivationCommand(AbstractChannel channel) {

@Override
public void render(int mouseX, int mouseY, float parTicks) {
handleDragging(mouseX, mouseY);

super.render(mouseX, mouseY, parTicks);
if (mc.field_71456_v/*ingameGUI*/.getChatGUI().getChatOpen() && chat != null) {
FontRenderer fr = Minecraft.getInstance().fontRenderer;
Expand Down Expand Up @@ -274,8 +274,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
return super.mouseClicked(mouseX, mouseY, button);
}

@Override
public boolean mouseDragged(double mx, double my, int mb, double mxd, double myd) {
private void handleDragging(double mx, double my) {
if (drag != null) {

if (!dragMode) {
Expand All @@ -291,7 +290,6 @@ public boolean mouseDragged(double mx, double my, int mb, double mxd, double myd
.setYPos(tempbox.getYPos() + (int) my - drag.y));
}
}
return super.mouseDragged(mx, my, mb, mxd, myd);
}

@Override
Expand Down Expand Up @@ -435,7 +433,7 @@ private class TCRect extends Rectangle2d {

private final Rectangle2d parent;

public TCRect(Rectangle2d parent) {
private TCRect(Rectangle2d parent) {
super(0, 0, 0, 0);
this.parent = parent;
}
Expand Down

0 comments on commit 875cc66

Please sign in to comment.