RC to copy
This commit is contained in:
1 parent
c35c5f97d6
commit
e7a8dcacd5
5 files changed
+112
-8
No files matched your search
+1
-1
@@ -8,4 +8,4 @@ fabric_api_version=0.43.1+1.18
|
||||
malilib_version = 0.10.0-dev.26
|
||||
startParameter.excludedTaskNames=spotlessCheck
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
advancedchat_version=1.4.0-build7
|
||||
advancedchat_version=1.4.2-build3
|
||||
+1
-1
@@ -1,10 +1,10 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
jcenter()
|
||||
maven {
|
||||
name = 'Fabric'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
@@ -180,12 +180,12 @@ public class ChatWindow {
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawRect(
|
||||
public static void drawRect(
|
||||
MatrixStack stack, int x, int y, int width, int height, int color) {
|
||||
DrawableHelper.fill(stack, x, y, x + width, y + height, color);
|
||||
}
|
||||
|
||||
private static void fill(MatrixStack stack, int x, int y, int x2, int y2, int color) {
|
||||
public static void fill(MatrixStack stack, int x, int y, int x2, int y2, int color) {
|
||||
DrawableHelper.fill(stack, x, y, x2, y2, color);
|
||||
}
|
||||
|
||||
@@ -670,6 +670,56 @@ public class ChatWindow {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ChatMessage getMessage(double mouseX, double mouseY) {
|
||||
if (!WindowManager.getInstance().isChatFocused()) {
|
||||
return null;
|
||||
}
|
||||
double relX = mouseX;
|
||||
double relY = getConvertedY() - mouseY;
|
||||
double trueX = relX / getScale() - getPaddedLeftX();
|
||||
double trueY = relY / getScale();
|
||||
// Divide it by chat scale to get where it actually is
|
||||
if (trueX < 0.0D || trueY < 0.0D) {
|
||||
return null;
|
||||
}
|
||||
if (trueY > getScaledHeight() || trueX > getScaledWidth()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int lines = 0;
|
||||
int lineCount = this.lines.size();
|
||||
LimitedInteger y = new LimitedInteger(getScaledHeight(), HudConfigStorage.General.BOTTOM_PAD.config.getIntegerValue());
|
||||
for (ChatMessage message : this.lines) {
|
||||
// To get the proper index of reversed
|
||||
for (int i = message.getLineCount() - 1; i >= 0; i--) {
|
||||
lines++;
|
||||
if (lines < scrolledLines) {
|
||||
continue;
|
||||
}
|
||||
if (!y.incrementIfPossible(HudConfigStorage.General.LINE_SPACE.config.getIntegerValue())) {
|
||||
break;
|
||||
}
|
||||
if (trueY <= y.getValue() && trueY >= y.getValue() - HudConfigStorage.General.LINE_SPACE.config.getIntegerValue()) {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
if (lines >= scrolledLines) {
|
||||
if (lines == lineCount) {
|
||||
break;
|
||||
}
|
||||
if (!y.isPossible(
|
||||
HudConfigStorage.General.LINE_SPACE.config.getIntegerValue()
|
||||
+ HudConfigStorage.General.MESSAGE_SPACE.config
|
||||
.getIntegerValue())
|
||||
|| !y.incrementIfPossible(
|
||||
HudConfigStorage.General.MESSAGE_SPACE.config.getIntegerValue())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isMouseOverDragBar(double mouseX, double mouseY) {
|
||||
int x = getConvertedX();
|
||||
int y = getConvertedY();
|
||||
|
||||
@@ -8,25 +8,31 @@
|
||||
package io.github.darkkronicle.advancedchathud.gui;
|
||||
|
||||
import fi.dy.masa.malilib.gui.button.ButtonBase;
|
||||
import fi.dy.masa.malilib.util.InfoUtils;
|
||||
import io.github.darkkronicle.advancedchatcore.chat.AdvancedChatScreen;
|
||||
import io.github.darkkronicle.advancedchatcore.chat.ChatMessage;
|
||||
import io.github.darkkronicle.advancedchatcore.gui.ContextMenu;
|
||||
import io.github.darkkronicle.advancedchatcore.gui.IconButton;
|
||||
import io.github.darkkronicle.advancedchatcore.interfaces.AdvancedChatScreenSection;
|
||||
import io.github.darkkronicle.advancedchatcore.util.Color;
|
||||
import io.github.darkkronicle.advancedchatcore.util.RawText;
|
||||
import io.github.darkkronicle.advancedchatcore.util.RowList;
|
||||
import io.github.darkkronicle.advancedchathud.AdvancedChatHud;
|
||||
import io.github.darkkronicle.advancedchathud.config.ChatTab;
|
||||
import io.github.darkkronicle.advancedchathud.config.HudConfigStorage;
|
||||
import io.github.darkkronicle.advancedchathud.itf.IChatHud;
|
||||
import io.github.darkkronicle.advancedchathud.tabs.AbstractChatTab;
|
||||
import io.github.darkkronicle.advancedchathud.tabs.CustomChatTab;
|
||||
import io.github.darkkronicle.advancedchathud.tabs.MainChatTab;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Style;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@@ -38,6 +44,10 @@ public class HudSection extends AdvancedChatScreenSection {
|
||||
private static final Identifier RESET_ICON =
|
||||
new Identifier(AdvancedChatHud.MOD_ID, "textures/gui/chatwindow/reset_windows.png");
|
||||
|
||||
private ContextMenu menu = null;
|
||||
|
||||
private ChatMessage message = null;
|
||||
|
||||
public HudSection(AdvancedChatScreen screen) {
|
||||
super(screen);
|
||||
}
|
||||
@@ -56,8 +66,6 @@ public class HudSection extends AdvancedChatScreenSection {
|
||||
@Override
|
||||
public void initGui() {
|
||||
boolean left = !HudConfigStorage.General.TAB_BUTTONS_ON_RIGHT.config.getBooleanValue();
|
||||
int x = left ? 2 : MinecraftClient.getInstance().getWindow().getScaledWidth() - 2;
|
||||
int y = MinecraftClient.getInstance().getWindow().getScaledHeight() - 31;
|
||||
List<AbstractChatTab> tabs = AdvancedChatHud.MAIN_CHAT_TAB.getAllChatTabs();
|
||||
if (!left) {
|
||||
Collections.reverse(tabs);
|
||||
@@ -90,8 +98,37 @@ public class HudSection extends AdvancedChatScreenSection {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
|
||||
if (menu != null) {
|
||||
menu.render(mouseX, mouseY, true, matrixStack);
|
||||
}
|
||||
}
|
||||
|
||||
public void createContextMenu(int mouseX, int mouseY) {
|
||||
LinkedHashMap<Text, ContextMenu.ContextConsumer> actions = new LinkedHashMap<>();
|
||||
message = WindowManager.getInstance().getMessage(mouseX, mouseY);
|
||||
if (message != null) {
|
||||
actions.put(RawText.withStyle("Copy", Style.EMPTY), (x, y) -> {
|
||||
MinecraftClient.getInstance().keyboard.setClipboard(message.getOriginalText().getString());
|
||||
InfoUtils.printActionbarMessage("§aCopied");
|
||||
});
|
||||
}
|
||||
actions.put(RawText.withStyle("Remove All Windows", Style.EMPTY), (x, y) -> WindowManager.getInstance().reset());
|
||||
actions.put(RawText.withStyle("Clear All Messages", Style.EMPTY), (x, y) -> WindowManager.getInstance().clear());
|
||||
actions.put(RawText.withStyle("Add Window Here", Style.EMPTY), (x, y) -> WindowManager.getInstance().createTab(x, y));
|
||||
menu = new ContextMenu(mouseX, mouseY, actions, () -> menu = null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if (button == 1) {
|
||||
createContextMenu((int) mouseX, (int) mouseY);
|
||||
return true;
|
||||
}
|
||||
if (menu != null && menu.onMouseClicked((int) mouseX, (int) mouseY, button)) {
|
||||
return true;
|
||||
}
|
||||
return WindowManager.getInstance().mouseClicked(getScreen(), mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import fi.dy.masa.malilib.interfaces.IRenderer;
|
||||
import io.github.darkkronicle.advancedchatcore.chat.AdvancedChatScreen;
|
||||
import io.github.darkkronicle.advancedchatcore.chat.ChatMessage;
|
||||
import io.github.darkkronicle.advancedchatcore.util.SyncTaskQueue;
|
||||
import io.github.darkkronicle.advancedchathud.AdvancedChatHud;
|
||||
import io.github.darkkronicle.advancedchathud.HudChatMessage;
|
||||
@@ -141,6 +142,15 @@ public class WindowManager implements IRenderer, ResolutionEventHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ChatMessage getMessage(double mouseX, double mouseY) {
|
||||
for (ChatWindow w : windows) {
|
||||
if (w.isMouseOver(mouseX, mouseY)) {
|
||||
return w.getMessage(mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isChatFocused() {
|
||||
return this.client.currentScreen instanceof AdvancedChatScreen;
|
||||
}
|
||||
@@ -259,6 +269,13 @@ public class WindowManager implements IRenderer, ResolutionEventHandler {
|
||||
setSelected(window);
|
||||
}
|
||||
|
||||
public void createTab(int x, int y) {
|
||||
ChatWindow window = new ChatWindow(IChatHud.getInstance().getTab());
|
||||
window.setPosition(x, y);
|
||||
windows.add(window);
|
||||
setSelected(window);
|
||||
}
|
||||
|
||||
public void deleteWindow(ChatWindow chatWindow) {
|
||||
windows.remove(chatWindow);
|
||||
if (!windows.isEmpty()) {
|
||||
|
||||
Reference in new issue
Block a user