v5.0
This commit is contained in:
1 parent
09ed268576
commit
b2bc2b36ab
9 files changed
+113
-129
No files matched your search
+3
-10
@@ -1,22 +1,15 @@
|
|||||||
# v4.9
|
# v5.0!!!
|
||||||
|
|
||||||
## novedades
|
## novedades
|
||||||
|
|
||||||
### adiciones
|
### adiciones
|
||||||
|
|
||||||
- panel para gestionar los amigos, y la habilidad de añadirles motes
|
- panel individual para cada categoría de módulos
|
||||||
|
|
||||||
#### módulos nuevos:
|
#### módulos nuevos:
|
||||||
|
|
||||||
- notificaciones: te avisa de ciertos eventos mediante notificaciones
|
|
||||||
|
|
||||||
### arreglos / mejoras
|
### arreglos / mejoras
|
||||||
|
|
||||||
- `puntos de desconexión` ya renderiza la caja correctamente
|
|
||||||
- movido `aviso de baja durabilidad` a `notificaciones`
|
|
||||||
|
|
||||||
## problemas reconocidos
|
## problemas reconocidos
|
||||||
|
|
||||||
- lo de siempre, además de:
|
- lo de siempre.
|
||||||
- `inventario plus` no funciona en creativo
|
|
||||||
- `RPC de Discord` no funciona e incluso puede provocar crashes
|
|
||||||
+1
-1
@@ -10,6 +10,6 @@ discord_rpc_version=1.0.3
|
|||||||
neutrino_version=1.1.0
|
neutrino_version=1.1.0
|
||||||
jdk_version=25
|
jdk_version=25
|
||||||
|
|
||||||
mod_version=4.9
|
mod_version=5.0
|
||||||
maven_group=me.retucio
|
maven_group=me.retucio
|
||||||
archives_base_name=sputnik
|
archives_base_name=sputnik
|
||||||
@@ -97,25 +97,25 @@ public class ClientConfig {
|
|||||||
|
|
||||||
@EventListener
|
@EventListener
|
||||||
public void onExtendModulePanel(ModulePanelEvent.Extend event) {
|
public void onExtendModulePanel(ModulePanelEvent.Extend event) {
|
||||||
extendablePanels.put("M", new PanelData(
|
extendablePanels.put(event.getPanel().category.toString(), new PanelData(
|
||||||
ClickGui.INSTANCE.getModulesPanel().getX(),
|
event.getPanel().getX(),
|
||||||
ClickGui.INSTANCE.getModulesPanel().getY(),
|
event.getPanel().getY(),
|
||||||
ClickGui.INSTANCE.getModulesPanel().extended));
|
event.getPanel().extended));
|
||||||
ConfigManager.save();
|
ConfigManager.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventListener
|
@EventListener
|
||||||
public void onMoveModulePanel(ModulePanelEvent.Move event) {
|
public void onMoveModulePanel(ModulePanelEvent.Move event) {
|
||||||
extendablePanels.replace("M", new PanelData(
|
extendablePanels.replace(event.getPanel().category.toString(), new PanelData(
|
||||||
ClickGui.INSTANCE.getModulesPanel().getX(),
|
event.getPanel().getX(),
|
||||||
ClickGui.INSTANCE.getModulesPanel().getY(),
|
event.getPanel().getY(),
|
||||||
ClickGui.INSTANCE.getModulesPanel().extended));
|
event.getPanel().extended));
|
||||||
ConfigManager.save();
|
ConfigManager.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventListener
|
@EventListener
|
||||||
public void onExtendClientSettingsPanel(ClientSettingsPanelEvent.Extend event) {
|
public void onExtendClientSettingsPanel(ClientSettingsPanelEvent.Extend event) {
|
||||||
extendablePanels.put("S", new PanelData(
|
extendablePanels.put("ajustes", new PanelData(
|
||||||
ClickGui.INSTANCE.getClientSettingsPanel().getX(),
|
ClickGui.INSTANCE.getClientSettingsPanel().getX(),
|
||||||
ClickGui.INSTANCE.getClientSettingsPanel().getY(),
|
ClickGui.INSTANCE.getClientSettingsPanel().getY(),
|
||||||
ClickGui.INSTANCE.getClientSettingsPanel().extended));
|
ClickGui.INSTANCE.getClientSettingsPanel().extended));
|
||||||
@@ -124,7 +124,7 @@ public class ClientConfig {
|
|||||||
|
|
||||||
@EventListener
|
@EventListener
|
||||||
public void onMoveClientSettingsPanel(ClientSettingsPanelEvent.Move event) {
|
public void onMoveClientSettingsPanel(ClientSettingsPanelEvent.Move event) {
|
||||||
extendablePanels.replace("S", new PanelData(
|
extendablePanels.replace("ajustes", new PanelData(
|
||||||
ClickGui.INSTANCE.getClientSettingsPanel().getX(),
|
ClickGui.INSTANCE.getClientSettingsPanel().getX(),
|
||||||
ClickGui.INSTANCE.getClientSettingsPanel().getY(),
|
ClickGui.INSTANCE.getClientSettingsPanel().getY(),
|
||||||
ClickGui.INSTANCE.getClientSettingsPanel().extended));
|
ClickGui.INSTANCE.getClientSettingsPanel().extended));
|
||||||
@@ -133,7 +133,7 @@ public class ClientConfig {
|
|||||||
|
|
||||||
@EventListener
|
@EventListener
|
||||||
public void onExtendFriendsPanel(FriendPanelEvent.Extend event) {
|
public void onExtendFriendsPanel(FriendPanelEvent.Extend event) {
|
||||||
extendablePanels.put("F", new PanelData(
|
extendablePanels.put("amigos", new PanelData(
|
||||||
ClickGui.INSTANCE.getFriendsPanel().getX(),
|
ClickGui.INSTANCE.getFriendsPanel().getX(),
|
||||||
ClickGui.INSTANCE.getFriendsPanel().getY(),
|
ClickGui.INSTANCE.getFriendsPanel().getY(),
|
||||||
ClickGui.INSTANCE.getFriendsPanel().extended));
|
ClickGui.INSTANCE.getFriendsPanel().extended));
|
||||||
@@ -142,7 +142,7 @@ public class ClientConfig {
|
|||||||
|
|
||||||
@EventListener
|
@EventListener
|
||||||
public void onMoveFriendsPanel(FriendPanelEvent.Move event) {
|
public void onMoveFriendsPanel(FriendPanelEvent.Move event) {
|
||||||
extendablePanels.replace("F", new PanelData(
|
extendablePanels.replace("amigos", new PanelData(
|
||||||
ClickGui.INSTANCE.getFriendsPanel().getX(),
|
ClickGui.INSTANCE.getFriendsPanel().getX(),
|
||||||
ClickGui.INSTANCE.getFriendsPanel().getY(),
|
ClickGui.INSTANCE.getFriendsPanel().getY(),
|
||||||
ClickGui.INSTANCE.getFriendsPanel().extended));
|
ClickGui.INSTANCE.getFriendsPanel().extended));
|
||||||
|
|||||||
@@ -230,7 +230,9 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void applyExtendablePanels() {
|
private static void applyExtendablePanels() {
|
||||||
applyExtendablePanel(ClickGui.INSTANCE.getModulesPanel());
|
for (ModulePanel panel : ClickGui.INSTANCE.getModulePanels()) {
|
||||||
|
applyExtendablePanel(panel);
|
||||||
|
}
|
||||||
applyExtendablePanel(ClickGui.INSTANCE.getClientSettingsPanel());
|
applyExtendablePanel(ClickGui.INSTANCE.getClientSettingsPanel());
|
||||||
applyExtendablePanel(ClickGui.INSTANCE.getFriendsPanel());
|
applyExtendablePanel(ClickGui.INSTANCE.getFriendsPanel());
|
||||||
|
|
||||||
@@ -241,8 +243,8 @@ public class ConfigManager {
|
|||||||
private static void applyExtendablePanel(Panel<?> panel) {
|
private static void applyExtendablePanel(Panel<?> panel) {
|
||||||
ClientConfig.PanelData panelData = null;
|
ClientConfig.PanelData panelData = null;
|
||||||
|
|
||||||
if (panel instanceof ModulePanel) {
|
if (panel instanceof ModulePanel mp) {
|
||||||
panelData = config.extendablePanels.get("M");
|
panelData = config.extendablePanels.get(mp.category.toString());
|
||||||
}
|
}
|
||||||
if (panel instanceof ClientSettingsPanel) {
|
if (panel instanceof ClientSettingsPanel) {
|
||||||
panelData = config.extendablePanels.get("S");
|
panelData = config.extendablePanels.get("S");
|
||||||
|
|||||||
@@ -1,10 +1,28 @@
|
|||||||
package me.retucio.sputnik.event.sputnik;
|
package me.retucio.sputnik.event.sputnik;
|
||||||
|
|
||||||
import com.github.retucio.neutrino.Event;
|
import com.github.retucio.neutrino.Event;
|
||||||
|
import me.retucio.sputnik.ui.widgets.panels.ModulePanel;
|
||||||
|
|
||||||
// se genera cada que se interactúa con el marco de módulos
|
// se genera cada que se interactúa con un panel de módulos
|
||||||
public class ModulePanelEvent {
|
public class ModulePanelEvent extends Event {
|
||||||
|
|
||||||
public static class Extend extends Event {} // al extenderlo / contraerlo
|
protected ModulePanel panel;
|
||||||
public static class Move extends Event {} // al cambiarlo de posición
|
|
||||||
|
public ModulePanel getPanel() {
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
// al extenderlo / contraerlo
|
||||||
|
public static class Extend extends ModulePanelEvent {
|
||||||
|
public Extend(ModulePanel panel) {
|
||||||
|
this.panel = panel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// al cambiarlo de posición
|
||||||
|
public static class Move extends ModulePanelEvent {
|
||||||
|
public Move(ModulePanel panel) {
|
||||||
|
this.panel = panel;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -15,9 +15,7 @@ public enum Category {
|
|||||||
INVENTORY("inventario"),
|
INVENTORY("inventario"),
|
||||||
|
|
||||||
CLIENT("cliente"),
|
CLIENT("cliente"),
|
||||||
MISC("misc."),
|
MISC("misc.");
|
||||||
|
|
||||||
ALL("todos");
|
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
Category(String name) { this.name = name; }
|
Category(String name) { this.name = name; }
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package me.retucio.sputnik.ui.screen;
|
package me.retucio.sputnik.ui.screen;
|
||||||
|
|
||||||
import com.github.retucio.neutrino.EventListener;
|
import com.github.retucio.neutrino.EventListener;
|
||||||
|
|
||||||
import me.retucio.sputnik.Sputnik;
|
import me.retucio.sputnik.Sputnik;
|
||||||
import me.retucio.sputnik.event.input.KeyEvent;
|
import me.retucio.sputnik.event.input.KeyEvent;
|
||||||
import me.retucio.sputnik.event.input.MouseClickEvent;
|
import me.retucio.sputnik.event.input.MouseClickEvent;
|
||||||
@@ -15,7 +16,6 @@ import me.retucio.sputnik.ui.widgets.buttons.FriendButton;
|
|||||||
import me.retucio.sputnik.ui.widgets.buttons.settings.ListButton;
|
import me.retucio.sputnik.ui.widgets.buttons.settings.ListButton;
|
||||||
import me.retucio.sputnik.ui.widgets.buttons.ModuleButton;
|
import me.retucio.sputnik.ui.widgets.buttons.ModuleButton;
|
||||||
import me.retucio.sputnik.ui.widgets.buttons.SettingButton;
|
import me.retucio.sputnik.ui.widgets.buttons.SettingButton;
|
||||||
import me.retucio.sputnik.ui.widgets.misc.NotificationWidget;
|
|
||||||
import me.retucio.sputnik.ui.widgets.panels.FriendsPanel;
|
import me.retucio.sputnik.ui.widgets.panels.FriendsPanel;
|
||||||
import me.retucio.sputnik.ui.widgets.panels.settings.ClientSettingsPanel;
|
import me.retucio.sputnik.ui.widgets.panels.settings.ClientSettingsPanel;
|
||||||
import me.retucio.sputnik.ui.widgets.panels.settings.ColorPickerPanel;
|
import me.retucio.sputnik.ui.widgets.panels.settings.ColorPickerPanel;
|
||||||
@@ -27,6 +27,7 @@ import me.retucio.sputnik.ui.widgets.Widget;
|
|||||||
import me.retucio.sputnik.ui.widgets.misc.ScrollBarWidget;
|
import me.retucio.sputnik.ui.widgets.misc.ScrollBarWidget;
|
||||||
import me.retucio.sputnik.ui.widgets.misc.SearchBarWidget;
|
import me.retucio.sputnik.ui.widgets.misc.SearchBarWidget;
|
||||||
import me.retucio.sputnik.ui.widgets.panels.settings.FriendSettingsPanel;
|
import me.retucio.sputnik.ui.widgets.panels.settings.FriendSettingsPanel;
|
||||||
|
import me.retucio.sputnik.util.ChatUtil;
|
||||||
import me.retucio.sputnik.util.KeyUtil;
|
import me.retucio.sputnik.util.KeyUtil;
|
||||||
|
|
||||||
import me.retucio.sputnik.util.MiscUtil;
|
import me.retucio.sputnik.util.MiscUtil;
|
||||||
@@ -36,6 +37,7 @@ import net.minecraft.client.gui.GuiGraphicsExtractor;
|
|||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.client.input.MouseButtonEvent;
|
import net.minecraft.client.input.MouseButtonEvent;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jspecify.annotations.NonNull;
|
import org.jspecify.annotations.NonNull;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
@@ -48,7 +50,11 @@ import java.util.Optional;
|
|||||||
import static me.retucio.sputnik.ui.widgets.panels.settings.ClientSettingsPanel.clientSettings;
|
import static me.retucio.sputnik.ui.widgets.panels.settings.ClientSettingsPanel.clientSettings;
|
||||||
|
|
||||||
|
|
||||||
// interfaz gráfica, se abre con el shift derecho por defecto. aquí se encuentran los módulos y sus ajustes
|
/**
|
||||||
|
* interfaz gráfica, Screen que se abre con el shift derecho por defecto. aquí se encuentran los módulos y sus ajustes.
|
||||||
|
* @author retucio
|
||||||
|
*/
|
||||||
|
|
||||||
public class ClickGui extends Screen {
|
public class ClickGui extends Screen {
|
||||||
|
|
||||||
private final Minecraft mc = Minecraft.getInstance();
|
private final Minecraft mc = Minecraft.getInstance();
|
||||||
@@ -57,21 +63,26 @@ public class ClickGui extends Screen {
|
|||||||
private boolean anyFocused;
|
private boolean anyFocused;
|
||||||
private @Nullable Widget selected = null;
|
private @Nullable Widget selected = null;
|
||||||
|
|
||||||
private Category categoryFilter = Category.ALL;
|
private final List<ModulePanel> modulePanels = new ArrayList<>();
|
||||||
|
|
||||||
private final ModulePanel modulesPanel = new ModulePanel(20, 30, 100, 20);
|
|
||||||
private final List<SettingsPanel> settingsPanels = new ArrayList<>();
|
private final List<SettingsPanel> settingsPanels = new ArrayList<>();
|
||||||
private final ClientSettingsPanel clientSettingsPanel = new ClientSettingsPanel(200, 30, 100, 20);
|
private final ClientSettingsPanel clientSettingsPanel = new ClientSettingsPanel(620, 280, 100, 20);
|
||||||
private final FriendsPanel friendsPanel = new FriendsPanel(770, 30, 100, 20);
|
private final FriendsPanel friendsPanel = new FriendsPanel(40, 280, 100, 20);
|
||||||
|
|
||||||
private final ScrollBarWidget scrollBar = new ScrollBarWidget();
|
private final ScrollBarWidget scrollBar = new ScrollBarWidget();
|
||||||
private final SearchBarWidget searchBar = new SearchBarWidget(500, 30, 320, 20);
|
private final SearchBarWidget searchBar = new SearchBarWidget(320, 10, 320, 20);
|
||||||
private final List<Widget> miscWidgets = Arrays.asList(scrollBar, searchBar);
|
private final List<Widget> miscWidgets = List.of(scrollBar, searchBar);
|
||||||
|
|
||||||
public ClickGui() {
|
public ClickGui() {
|
||||||
super(Component.nullToEmpty("interfaz"));
|
super(Component.literal("interfaz"));
|
||||||
settingsPanels.add(clientSettingsPanel);
|
|
||||||
Sputnik.EVENT_BUS.subscribe(this);
|
Sputnik.EVENT_BUS.subscribe(this);
|
||||||
|
|
||||||
|
settingsPanels.add(clientSettingsPanel);
|
||||||
|
|
||||||
|
int x = 4;
|
||||||
|
for (Category category : Category.values()) {
|
||||||
|
modulePanels.add(new ModulePanel(category, x, 40, 100, 20));
|
||||||
|
x += 88;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -86,21 +97,26 @@ public class ClickGui extends Screen {
|
|||||||
searchBar.render(gui, mouseX, mouseY, delta);
|
searchBar.render(gui, mouseX, mouseY, delta);
|
||||||
searchBar.updatePosition(mouseX, mouseY);
|
searchBar.updatePosition(mouseX, mouseY);
|
||||||
|
|
||||||
// actualizar la posición de renderizado vertical de los marcos cada tick
|
// actualizar la posición de renderizado vertical de los paneles cada tick
|
||||||
modulesPanel.updateRenderY(scrollOffset);
|
|
||||||
friendsPanel.updateRenderY(scrollOffset);
|
friendsPanel.updateRenderY(scrollOffset);
|
||||||
for (SettingsPanel sp : settingsPanels)
|
for (ModulePanel mp : modulePanels) {
|
||||||
|
mp.updateRenderY(scrollOffset);
|
||||||
|
}
|
||||||
|
for (SettingsPanel sp : settingsPanels) {
|
||||||
sp.updateRenderY(scrollOffset);
|
sp.updateRenderY(scrollOffset);
|
||||||
|
}
|
||||||
|
|
||||||
// renderizar el marco de los ajustes de cada módulo que lo tenga abierto. se abre haciendo clic derecho sobre el módulo
|
// renderizar el panel de los ajustes de cada módulo que lo tenga abierto. se abre haciendo clic derecho sobre el módulo.
|
||||||
for (SettingsPanel sp : settingsPanels.reversed()) {
|
for (SettingsPanel sp : settingsPanels.reversed()) {
|
||||||
sp.render(gui, mouseX, mouseY, delta);
|
sp.render(gui, mouseX, mouseY, delta);
|
||||||
sp.updatePosition(mouseX, mouseY);
|
sp.updatePosition(mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// renderizar el marco de los módulos
|
// renderizar los paneles de los módulos
|
||||||
modulesPanel.render(gui, mouseX, mouseY, delta);
|
for (ModulePanel mp : modulePanels) {
|
||||||
modulesPanel.updatePosition(mouseX, mouseY);
|
mp.render(gui, mouseX, mouseY, delta);
|
||||||
|
mp.updatePosition(mouseX, mouseY);
|
||||||
|
}
|
||||||
|
|
||||||
for (SettingsPanel sp : settingsPanels) {
|
for (SettingsPanel sp : settingsPanels) {
|
||||||
sp.drawTooltips(gui, mouseX, mouseY);
|
sp.drawTooltips(gui, mouseX, mouseY);
|
||||||
@@ -135,9 +151,13 @@ public class ClickGui extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int calculateContentHeight() {
|
private int calculateContentHeight() {
|
||||||
int bottom = modulesPanel.getY() + modulesPanel.getH() + modulesPanel.getTotalHeight();
|
int bottom = mc.getWindow().getGuiScaledHeight();
|
||||||
for (SettingsPanel panel : settingsPanels)
|
for (ModulePanel mp : modulePanels) {
|
||||||
bottom = Math.max(bottom, panel.getY() + panel.getH() + panel.getTotalHeight());
|
bottom = mp.getY() + mp.getH() + mp.getTotalHeight();
|
||||||
|
}
|
||||||
|
for (SettingsPanel sp : settingsPanels) {
|
||||||
|
bottom = Math.max(bottom, sp.getY() + sp.getH() + sp.getTotalHeight());
|
||||||
|
}
|
||||||
|
|
||||||
return bottom + 20; // padding
|
return bottom + 20; // padding
|
||||||
}
|
}
|
||||||
@@ -147,13 +167,17 @@ public class ClickGui extends Screen {
|
|||||||
int x = (int) click.x();
|
int x = (int) click.x();
|
||||||
int y = (int) click.y();
|
int y = (int) click.y();
|
||||||
|
|
||||||
|
ChatUtil.info(x + " " + y);
|
||||||
|
|
||||||
miscWidgets.forEach(w -> w.mouseClicked(
|
miscWidgets.forEach(w -> w.mouseClicked(
|
||||||
x, y, click.button()
|
x, y, click.button()
|
||||||
));
|
));
|
||||||
|
|
||||||
// detectar clics sobre los marcos
|
// detectar clics sobre los marcos
|
||||||
modulesPanel.mouseClicked(x, y, click.button());
|
|
||||||
friendsPanel.mouseClicked(x, y, click.button());
|
friendsPanel.mouseClicked(x, y, click.button());
|
||||||
|
for (ModulePanel mp : new ArrayList<>(modulePanels)) {
|
||||||
|
mp.mouseClicked(x, y, click.button());
|
||||||
|
}
|
||||||
for (SettingsPanel sp : new ArrayList<>(settingsPanels)) {
|
for (SettingsPanel sp : new ArrayList<>(settingsPanels)) {
|
||||||
sp.mouseClicked(x, y, click.button());
|
sp.mouseClicked(x, y, click.button());
|
||||||
}
|
}
|
||||||
@@ -170,8 +194,10 @@ public class ClickGui extends Screen {
|
|||||||
x, y, click.button()));
|
x, y, click.button()));
|
||||||
|
|
||||||
// registrar cuándo se suelta el clic, en cada marco respectivamente
|
// registrar cuándo se suelta el clic, en cada marco respectivamente
|
||||||
modulesPanel.mouseReleased(x, y, click.button());
|
|
||||||
friendsPanel.mouseReleased(x, y, click.button());
|
friendsPanel.mouseReleased(x, y, click.button());
|
||||||
|
for (ModulePanel mp : new ArrayList<>(modulePanels)) {
|
||||||
|
mp.mouseReleased(x, y, click.button());
|
||||||
|
}
|
||||||
for (SettingsPanel sp : new ArrayList<>(settingsPanels)) {
|
for (SettingsPanel sp : new ArrayList<>(settingsPanels)) {
|
||||||
sp.mouseReleased(x, y, click.button());
|
sp.mouseReleased(x, y, click.button());
|
||||||
}
|
}
|
||||||
@@ -208,12 +234,12 @@ public class ClickGui extends Screen {
|
|||||||
if (Sputnik.mc.screen != this || event.getButton() != 2 || !KeyUtil.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)) return;
|
if (Sputnik.mc.screen != this || event.getButton() != 2 || !KeyUtil.isKeyDown(GLFW.GLFW_KEY_LEFT_SHIFT)) return;
|
||||||
|
|
||||||
int h = Sputnik.mc.getWindow().getGuiScaledHeight();
|
int h = Sputnik.mc.getWindow().getGuiScaledHeight();
|
||||||
int minY = Math.min(modulesPanel.getY(), settingsPanels.stream().mapToInt(Panel::getY).min().orElse(modulesPanel.getY()));
|
int minY = Math.min(modulePanels.stream().mapToInt(Panel::getY).min().getAsInt(), settingsPanels.stream().mapToInt(Panel::getY).min().getAsInt());
|
||||||
int maxY = Math.max(modulesPanel.getY() + modulesPanel.getH(), settingsPanels.stream().mapToInt(sp -> sp.getY() + sp.getH()).max().orElse(modulesPanel.getY() + modulesPanel.getH()));
|
int maxY = Math.max(modulePanels.stream().mapToInt(mp -> mp.getY() + mp.getH()).max().getAsInt(), settingsPanels.stream().mapToInt(sp -> sp.getY() + sp.getH()).max().getAsInt());
|
||||||
int correction = minY < 0 ? -minY + 4 : (maxY > h ? h - maxY - 4 : 0);
|
int correction = minY < 0 ? -minY + 4 : (maxY > h ? h - maxY - 4 : 0);
|
||||||
|
|
||||||
if (correction != 0) {
|
if (correction != 0) {
|
||||||
modulesPanel.setY(modulesPanel.getY() + correction);
|
modulePanels.forEach(mp -> mp.setY(mp.getY() + correction));
|
||||||
settingsPanels.forEach(sp -> sp.setY(sp.getY() + correction));
|
settingsPanels.forEach(sp -> sp.setY(sp.getY() + correction));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,16 +249,12 @@ public class ClickGui extends Screen {
|
|||||||
String searchInput = searchBar.getSearchInput().trim();
|
String searchInput = searchBar.getSearchInput().trim();
|
||||||
if (!clientSettings.matchCase.getValue()) searchInput = searchInput.toLowerCase();
|
if (!clientSettings.matchCase.getValue()) searchInput = searchInput.toLowerCase();
|
||||||
|
|
||||||
for (Button b : modulesPanel.getButtons()) {
|
|
||||||
|
for (ModulePanel mp : modulePanels) {
|
||||||
|
for (Button b : mp.getButtons()) {
|
||||||
if (!(b instanceof ModuleButton mb)) continue;
|
if (!(b instanceof ModuleButton mb)) continue;
|
||||||
Module module = mb.getModule();
|
Module module = mb.getModule();
|
||||||
|
|
||||||
if (getCategoryFilter() != Category.ALL) {
|
|
||||||
module.setSearchMatch(getCategoryFilter() == module.getCategory());
|
|
||||||
} else {
|
|
||||||
module.setSearchMatch(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (searchInput.isEmpty()) {
|
if (searchInput.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -252,6 +274,7 @@ public class ClickGui extends Screen {
|
|||||||
|| description.contains(searchInput)
|
|| description.contains(searchInput)
|
||||||
|| category.contains(searchInput));
|
|| category.contains(searchInput));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (SettingsPanel sp : settingsPanels) {
|
for (SettingsPanel sp : settingsPanels) {
|
||||||
for (Button b : sp.getButtons()) {
|
for (Button b : sp.getButtons()) {
|
||||||
@@ -408,19 +431,11 @@ public class ClickGui extends Screen {
|
|||||||
lb.refreshDummy();
|
lb.refreshDummy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCategoryFilter(Category category) {
|
|
||||||
this.categoryFilter = category;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Category getCategoryFilter() {
|
|
||||||
return categoryFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
// métodos del súper
|
// métodos del súper
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClose() { // evitar que al reabrir la interfaz sin previamente haber soltado el clic, se sigan arrastrando objetos
|
public void onClose() { // evitar que al reabrir la interfaz sin previamente haber soltado el clic, se sigan arrastrando objetos
|
||||||
modulesPanel.mouseReleased(0, 0, 0);
|
modulePanels.forEach(mp -> mp.mouseReleased(0, 0, 0));
|
||||||
settingsPanels.forEach(sp -> sp.mouseReleased(0, 0, 0));
|
settingsPanels.forEach(sp -> sp.mouseReleased(0, 0, 0));
|
||||||
scrollBar.mouseReleased(0, 0, 0);
|
scrollBar.mouseReleased(0, 0, 0);
|
||||||
searchBar.mouseReleased(0, 0, 0);
|
searchBar.mouseReleased(0, 0, 0);
|
||||||
@@ -448,8 +463,8 @@ public class ClickGui extends Screen {
|
|||||||
|
|
||||||
// getters y setters de widgets
|
// getters y setters de widgets
|
||||||
|
|
||||||
public ModulePanel getModulesPanel() {
|
public List<ModulePanel> getModulePanels() {
|
||||||
return modulesPanel;
|
return modulePanels;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientSettingsPanel getClientSettingsPanel() {
|
public ClientSettingsPanel getClientSettingsPanel() {
|
||||||
|
|||||||
@@ -32,27 +32,8 @@ public class SearchBarWidget extends Widget {
|
|||||||
private boolean focused;
|
private boolean focused;
|
||||||
private final StringBuilder buffer = new StringBuilder();
|
private final StringBuilder buffer = new StringBuilder();
|
||||||
|
|
||||||
// simular un módulo
|
|
||||||
private final Module dummy = new Module("", "", Category.ALL);
|
|
||||||
private final OptionSetting<Category> categories = dummy.getSgGeneral().add(
|
|
||||||
new OptionSetting<>(
|
|
||||||
"filtrar",
|
|
||||||
"filtrar módulos por categoría",
|
|
||||||
List.of(Category.values()),
|
|
||||||
Category.ALL
|
|
||||||
)
|
|
||||||
);
|
|
||||||
private final ChooseButton<Category> dummyButton = new ChooseButton<>(
|
|
||||||
categories, new SettingsPanel(dummy, 0, 0, 50, 50), 0
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
public SearchBarWidget(int x, int y, int w, int h) {
|
public SearchBarWidget(int x, int y, int w, int h) {
|
||||||
super(x, y, w, h);
|
super(x, y, w, h);
|
||||||
|
|
||||||
categories.onUpdate(v -> {
|
|
||||||
if (ClickGui.INSTANCE != null) ClickGui.INSTANCE.setCategoryFilter(v);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -73,14 +54,6 @@ public class SearchBarWidget extends Widget {
|
|||||||
|
|
||||||
gui.fill(x + 20, renderY + 2, x + w - 20, renderY + h - 2, textFieldColor.getRGB());
|
gui.fill(x + 20, renderY + 2, x + w - 20, renderY + h - 2, textFieldColor.getRGB());
|
||||||
|
|
||||||
gui.blit(RenderPipelines.GUI_TEXTURED, Textures.SEARCH_BAR_FILTER,
|
|
||||||
x + w - 35, renderY + h / 2 - 6,
|
|
||||||
0, 0, 12, 12, 12, 12,
|
|
||||||
isFilterButtonHovered(mouseX, mouseY)
|
|
||||||
? Colors.SILVER.getRGB()
|
|
||||||
: Colors.WHITE.getRGB()
|
|
||||||
);
|
|
||||||
|
|
||||||
// dibujar líneas en la parte agarrable, para indicárselo al usuario
|
// dibujar líneas en la parte agarrable, para indicárselo al usuario
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
gui.horizontalLine(x + 4, x + 16, renderY + 3 * i + 5, Color.LIGHT_GRAY.getRGB());
|
gui.horizontalLine(x + 4, x + 16, renderY + 3 * i + 5, Color.LIGHT_GRAY.getRGB());
|
||||||
@@ -95,10 +68,6 @@ public class SearchBarWidget extends Widget {
|
|||||||
// botón para borrar búsqueda actual
|
// botón para borrar búsqueda actual
|
||||||
gui.text(mc.font, "×", x + w - mc.font.width("×") - 6, renderY + (h / 2) - mc.font.lineHeight / 2,
|
gui.text(mc.font, "×", x + w - mc.font.width("×") - 6, renderY + (h / 2) - mc.font.lineHeight / 2,
|
||||||
isClearButtonHovered(mouseX, mouseY) ? Color.RED.getRGB() : -1, true);
|
isClearButtonHovered(mouseX, mouseY) ? Color.RED.getRGB() : -1, true);
|
||||||
|
|
||||||
if (isFilterButtonHovered(mouseX, mouseY)) {
|
|
||||||
gui.setTooltipForNextFrame(mc.font, Component.literal("filtrar por categoría"), mouseX + 7, mouseY + 20);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -110,8 +79,6 @@ public class SearchBarWidget extends Widget {
|
|||||||
dragY = mouseY - y;
|
dragY = mouseY - y;
|
||||||
} else if (isClearButtonHovered(mouseX, mouseY)) {
|
} else if (isClearButtonHovered(mouseX, mouseY)) {
|
||||||
buffer.setLength(0);
|
buffer.setLength(0);
|
||||||
} else if (isFilterButtonHovered(mouseX, mouseY)) {
|
|
||||||
openFilterPanel(mouseX, mouseY);
|
|
||||||
}
|
}
|
||||||
focused = isTextFieldHovered(mouseX, mouseY) && ClickGui.INSTANCE.trySelect(this);
|
focused = isTextFieldHovered(mouseX, mouseY) && ClickGui.INSTANCE.trySelect(this);
|
||||||
}
|
}
|
||||||
@@ -183,8 +150,7 @@ public class SearchBarWidget extends Widget {
|
|||||||
public boolean isTextFieldHovered(int mouseX, int mouseY) {
|
public boolean isTextFieldHovered(int mouseX, int mouseY) {
|
||||||
return ClickGui.INSTANCE.canSelect(this)
|
return ClickGui.INSTANCE.canSelect(this)
|
||||||
&& mouseX > x + 20 && mouseX < x + w - 20
|
&& mouseX > x + 20 && mouseX < x + w - 20
|
||||||
&& mouseY > renderY + 2 && mouseY < renderY + h - 2
|
&& mouseY > renderY + 2 && mouseY < renderY + h - 2;
|
||||||
&& !isFilterButtonHovered(mouseX, mouseY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isClearButtonHovered(int mouseX, int mouseY) {
|
public boolean isClearButtonHovered(int mouseX, int mouseY) {
|
||||||
@@ -193,12 +159,6 @@ public class SearchBarWidget extends Widget {
|
|||||||
&& mouseY > renderY + 3 && mouseY < renderY + h - 5;
|
&& mouseY > renderY + 3 && mouseY < renderY + h - 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFilterButtonHovered(int mouseX, int mouseY) {
|
|
||||||
return ClickGui.INSTANCE.canSelect(this)
|
|
||||||
&& mouseX > x + w - 37 && mouseX < x + w - 21
|
|
||||||
&& mouseY > renderY + h / 2 - 8 && mouseY < renderY + h / 2 + 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFocused() {
|
public boolean isFocused() {
|
||||||
return focused && ClientSettingsPanel.clientSettings.searchBar.getValue();
|
return focused && ClientSettingsPanel.clientSettings.searchBar.getValue();
|
||||||
}
|
}
|
||||||
@@ -219,10 +179,4 @@ public class SearchBarWidget extends Widget {
|
|||||||
ConfigManager.setSearchBarPosition(x, y);
|
ConfigManager.setSearchBarPosition(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openFilterPanel(int mouseX, int mouseY) {
|
|
||||||
dummyButton.getParent().setX(mouseX);
|
|
||||||
dummyButton.getParent().setY(mouseY);
|
|
||||||
dummyButton.openPanel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ package me.retucio.sputnik.ui.widgets.panels;
|
|||||||
|
|
||||||
import me.retucio.sputnik.Sputnik;
|
import me.retucio.sputnik.Sputnik;
|
||||||
import me.retucio.sputnik.event.sputnik.ModulePanelEvent;
|
import me.retucio.sputnik.event.sputnik.ModulePanelEvent;
|
||||||
|
import me.retucio.sputnik.module.Category;
|
||||||
import me.retucio.sputnik.module.Module;
|
import me.retucio.sputnik.module.Module;
|
||||||
import me.retucio.sputnik.module.ModuleManager;
|
import me.retucio.sputnik.module.ModuleManager;
|
||||||
import me.retucio.sputnik.ui.screen.ClickGui;
|
import me.retucio.sputnik.ui.screen.ClickGui;
|
||||||
@@ -20,15 +21,18 @@ import java.util.List;
|
|||||||
public class ModulePanel extends Panel<ModuleButton> {
|
public class ModulePanel extends Panel<ModuleButton> {
|
||||||
|
|
||||||
public boolean extended;
|
public boolean extended;
|
||||||
|
public final Category category;
|
||||||
|
|
||||||
public ModulePanel(int x, int y, int w, int h) {
|
public ModulePanel(Category category, int x, int y, int w, int h) {
|
||||||
super("módulos", x, y, w, h);
|
super(category.toString(), x, y, w, h);
|
||||||
|
this.category = category;
|
||||||
dragging = false;
|
dragging = false;
|
||||||
extended = true;
|
extended = true;
|
||||||
|
|
||||||
// determinar el saliente para cada botón de módulo
|
// determinar el saliente para cada botón de módulo
|
||||||
int offset = h;
|
int offset = h;
|
||||||
for (Module module : ModuleManager.INSTANCE.getModules()) {
|
for (Module module : ModuleManager.INSTANCE.getModules()) {
|
||||||
|
if (!module.getCategory().equals(this.category)) continue;
|
||||||
buttons.add(new ModuleButton(module, this, offset));
|
buttons.add(new ModuleButton(module, this, offset));
|
||||||
offset += h;
|
offset += h;
|
||||||
}
|
}
|
||||||
@@ -53,7 +57,7 @@ public class ModulePanel extends Panel<ModuleButton> {
|
|||||||
gui.fill(x, renderY, x + w, renderY + h, Colors.mainColor.getRGB()); // cabeza del marco
|
gui.fill(x, renderY, x + w, renderY + h, Colors.mainColor.getRGB()); // cabeza del marco
|
||||||
|
|
||||||
// título del marco
|
// título del marco
|
||||||
gui.text(mc.font, Component.literal(ChatFormatting.BOLD + title),
|
gui.text(mc.font, Component.literal(title),
|
||||||
x + 8,
|
x + 8,
|
||||||
renderY + (h / 2) - (mc.font.lineHeight / 2),
|
renderY + (h / 2) - (mc.font.lineHeight / 2),
|
||||||
-1, true);
|
-1, true);
|
||||||
@@ -97,7 +101,7 @@ public class ModulePanel extends Panel<ModuleButton> {
|
|||||||
dragY = mouseY - y;
|
dragY = mouseY - y;
|
||||||
} else if (button == 1) { // clic derecho para extenderlo
|
} else if (button == 1) { // clic derecho para extenderlo
|
||||||
extended = !extended;
|
extended = !extended;
|
||||||
Sputnik.EVENT_BUS.post(new ModulePanelEvent.Extend());
|
Sputnik.EVENT_BUS.post(new ModulePanelEvent.Extend(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +135,7 @@ public class ModulePanel extends Panel<ModuleButton> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isHovered(mouseX, mouseY)) {
|
if (isHovered(mouseX, mouseY)) {
|
||||||
Sputnik.EVENT_BUS.post(new ModulePanelEvent.Move());
|
Sputnik.EVENT_BUS.post(new ModulePanelEvent.Move(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user