v4.8
This commit is contained in:
1 parent
67cc34a08c
commit
531c3ef9aa
16 files changed
+516
-52
No files matched your search
+3
-5
@@ -1,18 +1,16 @@
|
|||||||
# v4.7
|
# v4.8
|
||||||
|
|
||||||
## novedades
|
## novedades
|
||||||
|
|
||||||
### adiciones
|
### adiciones
|
||||||
|
|
||||||
- sistema de amigos
|
- panel para gestionar los amigos, y la habilidad de añadirles motes
|
||||||
|
|
||||||
#### módulos nuevos:
|
#### módulos nuevos:
|
||||||
|
|
||||||
- amigos: añade o elimina amigos con la rueda del ratón, para evitar atacarles por accidente
|
|
||||||
|
|
||||||
### arreglos / mejoras
|
### arreglos / mejoras
|
||||||
|
|
||||||
- `destello de enchants.` ya funciona en items 2d
|
- `puntos de desconexión` ya renderiza la caja correctamente
|
||||||
|
|
||||||
## problemas reconocidos
|
## problemas reconocidos
|
||||||
|
|
||||||
|
|||||||
+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.7
|
mod_version=4.8
|
||||||
maven_group=me.retucio
|
maven_group=me.retucio
|
||||||
archives_base_name=sputnik
|
archives_base_name=sputnik
|
||||||
@@ -4,6 +4,7 @@ import com.github.retucio.neutrino.EventListener;
|
|||||||
import me.retucio.sputnik.event.sputnik.*;
|
import me.retucio.sputnik.event.sputnik.*;
|
||||||
import me.retucio.sputnik.module.setting.settings.*;
|
import me.retucio.sputnik.module.setting.settings.*;
|
||||||
import me.retucio.sputnik.ui.screen.ClickGui;
|
import me.retucio.sputnik.ui.screen.ClickGui;
|
||||||
|
import me.retucio.sputnik.ui.widgets.panels.FriendsPanel;
|
||||||
import me.retucio.sputnik.util.ChatUtil;
|
import me.retucio.sputnik.util.ChatUtil;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
@@ -130,6 +131,24 @@ public class ClientConfig {
|
|||||||
ConfigManager.save();
|
ConfigManager.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventListener
|
||||||
|
public void onExtendFriendsPanel(FriendPanelEvent.Extend event) {
|
||||||
|
extendablePanels.put("F", new PanelData(
|
||||||
|
ClickGui.INSTANCE.getFriendsPanel().getX(),
|
||||||
|
ClickGui.INSTANCE.getFriendsPanel().getY(),
|
||||||
|
ClickGui.INSTANCE.getFriendsPanel().extended));
|
||||||
|
ConfigManager.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventListener
|
||||||
|
public void onMoveFriendsPanel(FriendPanelEvent.Move event) {
|
||||||
|
extendablePanels.replace("F", new PanelData(
|
||||||
|
ClickGui.INSTANCE.getFriendsPanel().getX(),
|
||||||
|
ClickGui.INSTANCE.getFriendsPanel().getY(),
|
||||||
|
ClickGui.INSTANCE.getFriendsPanel().extended));
|
||||||
|
ConfigManager.save();
|
||||||
|
}
|
||||||
|
|
||||||
@EventListener
|
@EventListener
|
||||||
public void onAddFriend(FriendEvent.Add event) {
|
public void onAddFriend(FriendEvent.Add event) {
|
||||||
String uuid = event.getFriend().getUuid().toString();
|
String uuid = event.getFriend().getUuid().toString();
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import me.retucio.sputnik.module.ModuleManager;
|
|||||||
import me.retucio.sputnik.module.setting.*;
|
import me.retucio.sputnik.module.setting.*;
|
||||||
import me.retucio.sputnik.module.setting.settings.*;
|
import me.retucio.sputnik.module.setting.settings.*;
|
||||||
import me.retucio.sputnik.ui.widgets.Panel;
|
import me.retucio.sputnik.ui.widgets.Panel;
|
||||||
|
import me.retucio.sputnik.ui.widgets.panels.FriendsPanel;
|
||||||
import me.retucio.sputnik.ui.widgets.panels.ModulePanel;
|
import me.retucio.sputnik.ui.widgets.panels.ModulePanel;
|
||||||
import me.retucio.sputnik.ui.screen.ClickGui;
|
import me.retucio.sputnik.ui.screen.ClickGui;
|
||||||
import me.retucio.sputnik.ui.widgets.panels.settings.ClientSettingsPanel;
|
import me.retucio.sputnik.ui.widgets.panels.settings.ClientSettingsPanel;
|
||||||
@@ -117,12 +118,12 @@ public class ConfigManager {
|
|||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPanelPosition(SettingsPanel frame) {
|
public static void setPanelPosition(SettingsPanel panel) {
|
||||||
ensureConfig();
|
ensureConfig();
|
||||||
if (!config.settingsPanels.containsKey(frame.getModule().getName()))
|
if (!config.settingsPanels.containsKey(panel.getModule().getName()))
|
||||||
config.settingsPanels.put(frame.getModule().getName(), new int[] {frame.getX(), frame.getY()});
|
config.settingsPanels.put(panel.getModule().getName(), new int[] {panel.getX(), panel.getY()});
|
||||||
else
|
else
|
||||||
config.settingsPanels.replace(frame.getModule().getName(), new int[] {frame.getX(), frame.getY()});
|
config.settingsPanels.replace(panel.getModule().getName(), new int[] {panel.getX(), panel.getY()});
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,6 +232,7 @@ public class ConfigManager {
|
|||||||
private static void applyExtendablePanels() {
|
private static void applyExtendablePanels() {
|
||||||
applyExtendablePanel(ClickGui.INSTANCE.getModulesPanel());
|
applyExtendablePanel(ClickGui.INSTANCE.getModulesPanel());
|
||||||
applyExtendablePanel(ClickGui.INSTANCE.getClientSettingsPanel());
|
applyExtendablePanel(ClickGui.INSTANCE.getClientSettingsPanel());
|
||||||
|
applyExtendablePanel(ClickGui.INSTANCE.getFriendsPanel());
|
||||||
|
|
||||||
Sputnik.LOGGER.info("posiciones de marcos extendibles aplicadas");
|
Sputnik.LOGGER.info("posiciones de marcos extendibles aplicadas");
|
||||||
ClickGui.INSTANCE.refreshListButtons();
|
ClickGui.INSTANCE.refreshListButtons();
|
||||||
@@ -238,20 +240,30 @@ 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)
|
|
||||||
panelData = config.extendablePanels.get("M");
|
|
||||||
|
|
||||||
if (panel instanceof ClientSettingsPanel)
|
if (panel instanceof ModulePanel) {
|
||||||
|
panelData = config.extendablePanels.get("M");
|
||||||
|
}
|
||||||
|
if (panel instanceof ClientSettingsPanel) {
|
||||||
panelData = config.extendablePanels.get("S");
|
panelData = config.extendablePanels.get("S");
|
||||||
|
}
|
||||||
|
if (panel instanceof FriendsPanel) {
|
||||||
|
panelData = config.extendablePanels.get("F");
|
||||||
|
}
|
||||||
|
|
||||||
if (panelData != null) {
|
if (panelData != null) {
|
||||||
panel.setX(panelData.x());
|
panel.setX(panelData.x());
|
||||||
panel.setY(panelData.y());
|
panel.setY(panelData.y());
|
||||||
|
|
||||||
if (panel instanceof ModulePanel mFrame)
|
if (panel instanceof ModulePanel mPanel) {
|
||||||
mFrame.extended = panelData.extended();
|
mPanel.extended = panelData.extended();
|
||||||
if (panel instanceof ClientSettingsPanel sFrame)
|
}
|
||||||
sFrame.extended = panelData.extended();
|
if (panel instanceof ClientSettingsPanel sPanel) {
|
||||||
|
sPanel.extended = panelData.extended();
|
||||||
|
}
|
||||||
|
if (panel instanceof FriendsPanel fPanel) {
|
||||||
|
fPanel.extended = panelData.extended();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package me.retucio.sputnik.event.sputnik;
|
||||||
|
|
||||||
|
import com.github.retucio.neutrino.Event;
|
||||||
|
|
||||||
|
public class FriendPanelEvent {
|
||||||
|
|
||||||
|
public static class Extend extends Event {} // al extenderlo / contraerlo
|
||||||
|
public static class Move extends Event {} // al cambiarlo de posición
|
||||||
|
}
|
||||||
@@ -15,6 +15,8 @@ public class Friend {
|
|||||||
private String name;
|
private String name;
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
|
|
||||||
|
private boolean searchMatch;
|
||||||
|
|
||||||
public Friend(UUID uuid) {
|
public Friend(UUID uuid) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
@@ -38,6 +40,14 @@ public class Friend {
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSearchMatch() {
|
||||||
|
return searchMatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSearchMatch(boolean searchMatch) {
|
||||||
|
this.searchMatch = searchMatch;
|
||||||
|
}
|
||||||
|
|
||||||
public enum Status {
|
public enum Status {
|
||||||
SUCCESS,
|
SUCCESS,
|
||||||
ALREADY_BEFRIENDED,
|
ALREADY_BEFRIENDED,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package me.retucio.sputnik.mixin.mixins.player;
|
|||||||
|
|
||||||
import me.retucio.sputnik.Sputnik;
|
import me.retucio.sputnik.Sputnik;
|
||||||
import me.retucio.sputnik.event.interact.ClipAtLedgeEvent;
|
import me.retucio.sputnik.event.interact.ClipAtLedgeEvent;
|
||||||
|
import me.retucio.sputnik.friend.FriendManager;
|
||||||
import me.retucio.sputnik.module.ModuleManager;
|
import me.retucio.sputnik.module.ModuleManager;
|
||||||
import me.retucio.sputnik.module.modules.render.Nametags;
|
import me.retucio.sputnik.module.modules.render.Nametags;
|
||||||
|
|
||||||
@@ -54,7 +55,12 @@ public abstract class PlayerMixin extends LivingEntity {
|
|||||||
: "") +
|
: "") +
|
||||||
ChatFormatting.RESET + "]";
|
ChatFormatting.RESET + "]";
|
||||||
|
|
||||||
return original.copy().append(text);
|
// mote de amigo
|
||||||
|
Component name = FriendManager.INSTANCE.isFriend((Player) (Object) this) && nametags.friendNick.getValue()
|
||||||
|
? Component.literal(FriendManager.INSTANCE.get(uuid).getName())
|
||||||
|
: original;
|
||||||
|
|
||||||
|
return name.copy().append(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "isStayingOnGroundSurface", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "isStayingOnGroundSurface", at = @At("HEAD"), cancellable = true)
|
||||||
|
|||||||
@@ -233,8 +233,8 @@ public class LogoutSpots extends Module {
|
|||||||
|
|
||||||
AABB box = player.getBoundingBox();
|
AABB box = player.getBoundingBox();
|
||||||
this.xWidth = box.getXsize();
|
this.xWidth = box.getXsize();
|
||||||
this.zWidth = box.getYsize();
|
this.height = box.getYsize();
|
||||||
this.height = box.getZsize();
|
this.zWidth = box.getZsize();
|
||||||
|
|
||||||
this.uuid = player.getUUID();
|
this.uuid = player.getUUID();
|
||||||
this.name = player.getName().getString();
|
this.name = player.getName().getString();
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ import net.minecraft.world.level.entity.UniquelyIdentifyable;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -60,6 +62,7 @@ public class Nametags extends Module {
|
|||||||
|
|
||||||
public final BooleanSetting alwaysVisible = sgGeneral.add(new BooleanSetting("siempre mostrar nametags", "mostrar nametag cuando el jugador está agachado o es invisible", false));
|
public final BooleanSetting alwaysVisible = sgGeneral.add(new BooleanSetting("siempre mostrar nametags", "mostrar nametag cuando el jugador está agachado o es invisible", false));
|
||||||
public final BooleanSetting showSelf = sgGeneral.add(new BooleanSetting("mostrar propio", "mostrar nametag propio", false));
|
public final BooleanSetting showSelf = sgGeneral.add(new BooleanSetting("mostrar propio", "mostrar nametag propio", false));
|
||||||
|
public final BooleanSetting friendNick = sgGeneral.add(new BooleanSetting("motes", "usar los motes de amigos", true));
|
||||||
|
|
||||||
public final BooleanSetting countItems = sgInfo.add(new BooleanSetting("contar items", "muestra cuánto de un item hay en un stack dropeado", true));
|
public final BooleanSetting countItems = sgInfo.add(new BooleanSetting("contar items", "muestra cuánto de un item hay en un stack dropeado", true));
|
||||||
public final BooleanSetting showProjectileDamage = sgInfo.add(new BooleanSetting("daño del proyectil", "muestra cuánto daño hace un proyectil en su nametag", true));
|
public final BooleanSetting showProjectileDamage = sgInfo.add(new BooleanSetting("daño del proyectil", "muestra cuánto daño hace un proyectil en su nametag", true));
|
||||||
|
|||||||
@@ -6,13 +6,16 @@ import me.retucio.sputnik.event.input.KeyEvent;
|
|||||||
import me.retucio.sputnik.event.input.MouseClickEvent;
|
import me.retucio.sputnik.event.input.MouseClickEvent;
|
||||||
import me.retucio.sputnik.event.input.MouseScrollEvent;
|
import me.retucio.sputnik.event.input.MouseScrollEvent;
|
||||||
import me.retucio.sputnik.event.sputnik.SettingsPanelEvent;
|
import me.retucio.sputnik.event.sputnik.SettingsPanelEvent;
|
||||||
|
import me.retucio.sputnik.friend.Friend;
|
||||||
import me.retucio.sputnik.module.Category;
|
import me.retucio.sputnik.module.Category;
|
||||||
import me.retucio.sputnik.module.Module;
|
import me.retucio.sputnik.module.Module;
|
||||||
import me.retucio.sputnik.module.setting.Setting;
|
import me.retucio.sputnik.module.setting.Setting;
|
||||||
import me.retucio.sputnik.module.setting.settings.ColorSetting;
|
import me.retucio.sputnik.module.setting.settings.ColorSetting;
|
||||||
|
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.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;
|
||||||
import me.retucio.sputnik.ui.widgets.panels.ModulePanel;
|
import me.retucio.sputnik.ui.widgets.panels.ModulePanel;
|
||||||
@@ -22,6 +25,7 @@ import me.retucio.sputnik.ui.widgets.Panel;
|
|||||||
import me.retucio.sputnik.ui.widgets.Widget;
|
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.util.KeyUtil;
|
import me.retucio.sputnik.util.KeyUtil;
|
||||||
|
|
||||||
import me.retucio.sputnik.util.MiscUtil;
|
import me.retucio.sputnik.util.MiscUtil;
|
||||||
@@ -57,9 +61,10 @@ public class ClickGui extends Screen {
|
|||||||
private final ModulePanel modulesPanel = new ModulePanel(20, 30, 100, 20);
|
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(200, 30, 100, 20);
|
||||||
|
private final FriendsPanel friendsPanel = new FriendsPanel(770, 30, 100, 20);
|
||||||
|
|
||||||
private final ScrollBarWidget scrollBar = new ScrollBarWidget();
|
private final ScrollBarWidget scrollBar = new ScrollBarWidget();
|
||||||
private final SearchBarWidget searchBar = new SearchBarWidget(340, 16, 320, 20);
|
private final SearchBarWidget searchBar = new SearchBarWidget(500, 30, 320, 20);
|
||||||
private final List<Widget> miscWidgets = Arrays.asList(scrollBar, searchBar);
|
private final List<Widget> miscWidgets = Arrays.asList(scrollBar, searchBar);
|
||||||
|
|
||||||
public ClickGui() {
|
public ClickGui() {
|
||||||
@@ -82,6 +87,7 @@ public class ClickGui extends Screen {
|
|||||||
|
|
||||||
// actualizar la posición de renderizado vertical de los marcos cada tick
|
// actualizar la posición de renderizado vertical de los marcos cada tick
|
||||||
modulesPanel.updateRenderY(scrollOffset);
|
modulesPanel.updateRenderY(scrollOffset);
|
||||||
|
friendsPanel.updateRenderY(scrollOffset);
|
||||||
for (SettingsPanel sp : settingsPanels)
|
for (SettingsPanel sp : settingsPanels)
|
||||||
sp.updateRenderY(scrollOffset);
|
sp.updateRenderY(scrollOffset);
|
||||||
|
|
||||||
@@ -95,8 +101,12 @@ public class ClickGui extends Screen {
|
|||||||
modulesPanel.render(gui, mouseX, mouseY, delta);
|
modulesPanel.render(gui, mouseX, mouseY, delta);
|
||||||
modulesPanel.updatePosition(mouseX, mouseY);
|
modulesPanel.updatePosition(mouseX, mouseY);
|
||||||
|
|
||||||
for (SettingsPanel sp : settingsPanels)
|
for (SettingsPanel sp : settingsPanels) {
|
||||||
sp.drawTooltips(gui, mouseX, mouseY);
|
sp.drawTooltips(gui, mouseX, mouseY);
|
||||||
|
}
|
||||||
|
|
||||||
|
friendsPanel.render(gui, mouseX, mouseY, delta);
|
||||||
|
friendsPanel.updatePosition(mouseX, mouseY);
|
||||||
|
|
||||||
filterSearchResults();
|
filterSearchResults();
|
||||||
|
|
||||||
@@ -133,31 +143,37 @@ public class ClickGui extends Screen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(MouseButtonEvent click, boolean doubled) {
|
public boolean mouseClicked(MouseButtonEvent click, boolean doubled) {
|
||||||
|
int x = (int) click.x();
|
||||||
|
int y = (int) click.y();
|
||||||
|
|
||||||
miscWidgets.forEach(w -> w.mouseClicked(
|
miscWidgets.forEach(w -> w.mouseClicked(
|
||||||
(int) click.x(),
|
x, y, click.button()
|
||||||
(int) click.y(),
|
|
||||||
click.button()
|
|
||||||
));
|
));
|
||||||
|
|
||||||
// detectar clics sobre los marcos
|
// detectar clics sobre los marcos
|
||||||
modulesPanel.mouseClicked((int) click.x(), (int) click.y(), click.button());
|
modulesPanel.mouseClicked(x, y, click.button());
|
||||||
for (SettingsPanel sp : new ArrayList<>(settingsPanels))
|
friendsPanel.mouseClicked(x, y, click.button());
|
||||||
sp.mouseClicked((int) click.x(), (int) click.y(), click.button());
|
for (SettingsPanel sp : new ArrayList<>(settingsPanels)) {
|
||||||
|
sp.mouseClicked(x, y, click.button());
|
||||||
|
}
|
||||||
|
|
||||||
return super.mouseClicked(click, doubled);
|
return super.mouseClicked(click, doubled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseReleased(MouseButtonEvent click) {
|
public boolean mouseReleased(MouseButtonEvent click) {
|
||||||
|
int x = (int) click.x();
|
||||||
|
int y = (int) click.y();
|
||||||
|
|
||||||
miscWidgets.forEach(w -> w.mouseReleased(
|
miscWidgets.forEach(w -> w.mouseReleased(
|
||||||
(int) click.x(),
|
x, y, click.button()));
|
||||||
(int) click.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((int) click.x(), (int) click.y(), click.button());
|
modulesPanel.mouseReleased(x, y, click.button());
|
||||||
for (SettingsPanel sp : new ArrayList<>(settingsPanels))
|
friendsPanel.mouseReleased(x, y, click.button());
|
||||||
sp.mouseReleased((int) click.x(), (int) click.y(), click.button());
|
for (SettingsPanel sp : new ArrayList<>(settingsPanels)) {
|
||||||
|
sp.mouseReleased(x, y, click.button());
|
||||||
|
}
|
||||||
|
|
||||||
return super.mouseReleased(click);
|
return super.mouseReleased(click);
|
||||||
}
|
}
|
||||||
@@ -207,7 +223,7 @@ public class ClickGui extends Screen {
|
|||||||
if (!clientSettings.matchCase.getValue()) searchInput = searchInput.toLowerCase();
|
if (!clientSettings.matchCase.getValue()) searchInput = searchInput.toLowerCase();
|
||||||
|
|
||||||
for (Button b : modulesPanel.getButtons()) {
|
for (Button b : modulesPanel.getButtons()) {
|
||||||
if (!(b instanceof ModuleButton mb)) return;
|
if (!(b instanceof ModuleButton mb)) continue;
|
||||||
Module module = mb.getModule();
|
Module module = mb.getModule();
|
||||||
|
|
||||||
if (getCategoryFilter() != Category.ALL) {
|
if (getCategoryFilter() != Category.ALL) {
|
||||||
@@ -238,7 +254,7 @@ public class ClickGui extends Screen {
|
|||||||
|
|
||||||
for (SettingsPanel sp : settingsPanels) {
|
for (SettingsPanel sp : settingsPanels) {
|
||||||
for (Button b : sp.getButtons()) {
|
for (Button b : sp.getButtons()) {
|
||||||
if (!(b instanceof SettingButton<?> sb)) return;
|
if (!(b instanceof SettingButton<?> sb)) continue;
|
||||||
Setting<?> setting = sb.getSetting();
|
Setting<?> setting = sb.getSetting();
|
||||||
|
|
||||||
if (searchInput.isEmpty()) {
|
if (searchInput.isEmpty()) {
|
||||||
@@ -259,6 +275,26 @@ public class ClickGui extends Screen {
|
|||||||
setting.setSearchMatch(name.contains(searchInput) || description.contains(searchInput) || sgName.contains(searchInput));
|
setting.setSearchMatch(name.contains(searchInput) || description.contains(searchInput) || sgName.contains(searchInput));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Button b : friendsPanel.getButtons()) {
|
||||||
|
if (!(b instanceof FriendButton fb)) continue;
|
||||||
|
Friend friend = fb.getFriend();
|
||||||
|
|
||||||
|
if (searchInput.isEmpty()) {
|
||||||
|
friend.setSearchMatch(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String name = MiscUtil.removeAccentMarks(friend.getName());
|
||||||
|
String uuid = MiscUtil.removeAccentMarks(friend.getUuid().toString());
|
||||||
|
|
||||||
|
if (!clientSettings.matchCase.getValue()) {
|
||||||
|
name = name.toLowerCase();
|
||||||
|
uuid = uuid.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
friend.setSearchMatch(name.contains(searchInput) || uuid.contains(searchInput));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SettingsPanel getSettingsPanelOfModule(Module module) {
|
public SettingsPanel getSettingsPanelOfModule(Module module) {
|
||||||
@@ -337,6 +373,33 @@ public class ClickGui extends Screen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFriendSettingsPanelOpen(Friend friend) {
|
||||||
|
for (SettingsPanel sp : getSettingsPanels()) {
|
||||||
|
if (sp instanceof FriendSettingsPanel fsp) {
|
||||||
|
if (fsp.getFriend().getUuid().equals(friend.getUuid())) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openFriendSettingsPanel(Friend friend, int x, int y) {
|
||||||
|
FriendSettingsPanel panel = new FriendSettingsPanel(friend, x + 80, y + 5, 153, 20);
|
||||||
|
if (isFriendSettingsPanelOpen(friend)) {
|
||||||
|
closeFriendSettingsPanel(friend);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
settingsPanels.add(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeFriendSettingsPanel(Friend friend) {
|
||||||
|
for (SettingsPanel sp : getSettingsPanels()) {
|
||||||
|
if (sp instanceof FriendSettingsPanel fsp && fsp.getFriend().getUuid().equals(friend.getUuid())) {
|
||||||
|
settingsPanels.remove(fsp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void refreshListButtons() {
|
public void refreshListButtons() {
|
||||||
for (SettingsPanel panel : settingsPanels)
|
for (SettingsPanel panel : settingsPanels)
|
||||||
for (Button button : panel.getButtons())
|
for (Button button : panel.getButtons())
|
||||||
@@ -392,6 +455,10 @@ public class ClickGui extends Screen {
|
|||||||
return clientSettingsPanel;
|
return clientSettingsPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FriendsPanel getFriendsPanel() {
|
||||||
|
return friendsPanel;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Widget> getMiscWidgets() { return miscWidgets; }
|
public List<Widget> getMiscWidgets() { return miscWidgets; }
|
||||||
|
|
||||||
public List<SettingsPanel> getSettingsPanels() {
|
public List<SettingsPanel> getSettingsPanels() {
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package me.retucio.sputnik.ui.widgets.buttons;
|
||||||
|
|
||||||
|
import me.retucio.sputnik.friend.Friend;
|
||||||
|
import me.retucio.sputnik.module.Module;
|
||||||
|
import me.retucio.sputnik.ui.screen.ClickGui;
|
||||||
|
import me.retucio.sputnik.ui.widgets.panels.FriendsPanel;
|
||||||
|
import me.retucio.sputnik.ui.widgets.panels.ModulePanel;
|
||||||
|
import me.retucio.sputnik.ui.widgets.Button;
|
||||||
|
import me.retucio.sputnik.util.Colors;
|
||||||
|
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
|
|
||||||
|
// clase para el botón para cada módulo
|
||||||
|
public class FriendButton extends Button {
|
||||||
|
|
||||||
|
private final Friend friend;
|
||||||
|
public final int height = 18;
|
||||||
|
|
||||||
|
public FriendButton(Friend friend, FriendsPanel parent, int offset) {
|
||||||
|
super(parent, offset);
|
||||||
|
this.friend = friend;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) {
|
||||||
|
gui.fill( // dibujar el contorno del botón
|
||||||
|
parent.getX() + 2, parent.getRenderY() + offset + 3,
|
||||||
|
parent.getX() + parent.getW() - 2 , parent.getRenderY() + height + offset,
|
||||||
|
determineColor(mouseX, mouseY));
|
||||||
|
|
||||||
|
gui.text( // dibujar el nombre del amigo
|
||||||
|
mc.font, friend.getName(),
|
||||||
|
parent.getX() + 5, parent.getRenderY() + offset + (height / 2) - (mc.font.lineHeight / 2) + 2,
|
||||||
|
-1, true);
|
||||||
|
|
||||||
|
// dibujar "tooltips" (cajas de texto) al pasar el puntero encima del botón, para mostrar su UUID
|
||||||
|
if (isHovered(mouseX, mouseY)) {
|
||||||
|
drawTooltip(gui, mouseX, mouseY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawTooltip(GuiGraphicsExtractor gui, int mouseX, int mouseY) {
|
||||||
|
gui.setTooltipForNextFrame(Component.literal(friend.getUuid().toString()), mouseX, mouseY + 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(int mouseX, int mouseY, int button) {
|
||||||
|
if (isHovered(mouseX, mouseY) && ClickGui.INSTANCE.trySelect(this)) {
|
||||||
|
ClickGui.INSTANCE.openFriendSettingsPanel(friend, mouseX, mouseY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// verifica si el puntero del ratón se encuentra sobre el botón
|
||||||
|
@Override
|
||||||
|
public boolean isHovered(int mouseX, int mouseY) {
|
||||||
|
return ClickGui.INSTANCE.canSelect(this)
|
||||||
|
&& mouseX > parent.getX()
|
||||||
|
&& mouseX < parent.getX() + parent.getW()
|
||||||
|
&& mouseY > parent.getRenderY() + offset
|
||||||
|
&& mouseY < parent.getRenderY() + height + offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int determineColor(double mouseX, double mouseY) {
|
||||||
|
// determina el color del botón, dependiendo de si está el puntero encima
|
||||||
|
return isHovered((int) mouseX, (int) mouseY)
|
||||||
|
? Colors.buttonColor.brighter().getRGB()
|
||||||
|
: Colors.buttonColor.getRGB();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Friend getFriend() {
|
||||||
|
return friend;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,167 @@
|
|||||||
|
package me.retucio.sputnik.ui.widgets.panels;
|
||||||
|
|
||||||
|
import com.github.retucio.neutrino.EventListener;
|
||||||
|
import me.retucio.sputnik.Sputnik;
|
||||||
|
import me.retucio.sputnik.event.sputnik.FriendEvent;
|
||||||
|
import me.retucio.sputnik.event.sputnik.FriendPanelEvent;
|
||||||
|
import me.retucio.sputnik.event.sputnik.ModulePanelEvent;
|
||||||
|
import me.retucio.sputnik.friend.Friend;
|
||||||
|
import me.retucio.sputnik.friend.FriendManager;
|
||||||
|
import me.retucio.sputnik.ui.screen.ClickGui;
|
||||||
|
import me.retucio.sputnik.ui.widgets.Panel;
|
||||||
|
import me.retucio.sputnik.ui.widgets.buttons.FriendButton;
|
||||||
|
import me.retucio.sputnik.ui.widgets.buttons.ModuleButton;
|
||||||
|
import me.retucio.sputnik.util.Colors;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public class FriendsPanel extends Panel<FriendButton> {
|
||||||
|
|
||||||
|
public boolean extended;
|
||||||
|
private int offset;
|
||||||
|
|
||||||
|
public FriendsPanel(int x, int y, int w, int h) {
|
||||||
|
super("amigos", x, y, w, h);
|
||||||
|
dragging = false;
|
||||||
|
extended = true;
|
||||||
|
|
||||||
|
Sputnik.EVENT_BUS.subscribe(this);
|
||||||
|
|
||||||
|
offset = h;
|
||||||
|
for (Friend friend : FriendManager.INSTANCE.getFriends()) {
|
||||||
|
buttons.add(new FriendButton(friend, this, offset));
|
||||||
|
offset += h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateWidth() {
|
||||||
|
// asegurarse de que todos los botones caben en el panel, haciendo
|
||||||
|
// que la anchura se ajuste al texto más largo
|
||||||
|
int maxWidth = mc.font.width(title) + mc.font.width(" +");
|
||||||
|
for (FriendButton button : buttons) {
|
||||||
|
String text = button.getFriend().getName();
|
||||||
|
int textWidth = mc.font.width(text);
|
||||||
|
maxWidth = Math.max(maxWidth, textWidth);
|
||||||
|
}
|
||||||
|
this.w = maxWidth + 22;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(GuiGraphicsExtractor gui, int mouseX, int mouseY, float delta) {
|
||||||
|
updateWidth();
|
||||||
|
gui.fill(x, renderY, x + w, renderY + h, Colors.mainColor.getRGB()); // cabeza del panel
|
||||||
|
|
||||||
|
// título del panel
|
||||||
|
gui.text(mc.font, Component.literal(title),
|
||||||
|
x + 8,
|
||||||
|
renderY + (h / 2) - (mc.font.lineHeight / 2),
|
||||||
|
-1, true);
|
||||||
|
|
||||||
|
gui.text(mc.font, extended ? "-" : "+",
|
||||||
|
x + w - mc.font.width("+") - 8, // '+' y '-' tienen la misma anchura, o sea que no importa cuál use
|
||||||
|
renderY + (h / 2) - (mc.font.lineHeight / 2),
|
||||||
|
-1, true);
|
||||||
|
|
||||||
|
List<FriendButton> visibleButtons = buttons.stream()
|
||||||
|
.filter(fb -> fb.getFriend().isSearchMatch())
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
// dibujar los botones solo si está extendido
|
||||||
|
if (extended) {
|
||||||
|
totalHeight = visibleButtons.size() * h + 3;
|
||||||
|
gui.fill( // fondo para los botones
|
||||||
|
x, renderY + h + 1,
|
||||||
|
x + w, renderY + h + totalHeight,
|
||||||
|
Colors.panelBgColor.getRGB());
|
||||||
|
|
||||||
|
// dibujar los botones para cada módulo
|
||||||
|
int buttonY = renderY + h + 1;
|
||||||
|
for (FriendButton moduleButton : visibleButtons) {
|
||||||
|
moduleButton.setOffset(buttonY - renderY);
|
||||||
|
moduleButton.render(gui, mouseX, mouseY, delta);
|
||||||
|
buttonY += h;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
totalHeight = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(int mouseX, int mouseY, int button) {
|
||||||
|
// registrar clics
|
||||||
|
if (isHovered(mouseX, mouseY) && ClickGui.INSTANCE.trySelect(this)) {
|
||||||
|
if (button == 0) { // clic izquierdo para arrastrarlo
|
||||||
|
dragging = true;
|
||||||
|
dragX = mouseX - x;
|
||||||
|
dragY = mouseY - y;
|
||||||
|
} else if (button == 1) { // clic derecho para extenderlo
|
||||||
|
extended = !extended;
|
||||||
|
Sputnik.EVENT_BUS.post(new FriendPanelEvent.Extend());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!extended) return; // solo dejar clicar en los botones si el marco está extendido
|
||||||
|
|
||||||
|
List<FriendButton> visibleFriendButtons = buttons.stream()
|
||||||
|
.filter(fb -> fb.getFriend().isSearchMatch())
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
for (FriendButton friendButton : visibleFriendButtons) {
|
||||||
|
friendButton.mouseClicked(mouseX, mouseY, button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(int mouseX, int mouseY, int button) {
|
||||||
|
ClickGui.INSTANCE.unselect(this);
|
||||||
|
if (button == 0 && dragging) {
|
||||||
|
dragging = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<FriendButton> visibleFriendButtons = buttons.stream()
|
||||||
|
.filter(fb -> fb.getFriend().isSearchMatch())
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
for (FriendButton friendButton : visibleFriendButtons) {
|
||||||
|
if (friendButton.isHovered(mouseX, mouseY)) {
|
||||||
|
friendButton.mouseReleased(mouseX, mouseY, button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHovered(mouseX, mouseY)) {
|
||||||
|
Sputnik.EVENT_BUS.post(new FriendPanelEvent.Move());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// actualizar la posición al arrastrar el panel
|
||||||
|
public void updatePosition(double mouseX, double mouseY) {
|
||||||
|
if (dragging) {
|
||||||
|
x = (int) (mouseX - dragX);
|
||||||
|
y = (int) (mouseY - dragY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventListener
|
||||||
|
private void onAddFriend(FriendEvent.Add event) {
|
||||||
|
buttons.add(new FriendButton(event.getFriend(), this, offset));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventListener
|
||||||
|
private void onRemoveFriend(FriendEvent.Remove event) {
|
||||||
|
buttons.remove(getButtonOfFriend(event.getFriend()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public FriendButton getButtonOfFriend(Friend friend) {
|
||||||
|
for (FriendButton button : buttons) {
|
||||||
|
if (button.getFriend().getUuid().equals(friend.getUuid())) {
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,13 +16,11 @@ import net.minecraft.network.chat.Component;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
// marco para los módulos
|
// panel para los módulos
|
||||||
public class ModulePanel extends Panel<ModuleButton> {
|
public class ModulePanel extends Panel<ModuleButton> {
|
||||||
|
|
||||||
public boolean extended;
|
public boolean extended;
|
||||||
|
|
||||||
public Minecraft mc = Minecraft.getInstance();
|
|
||||||
|
|
||||||
public ModulePanel(int x, int y, int w, int h) {
|
public ModulePanel(int x, int y, int w, int h) {
|
||||||
super("módulos", x, y, w, h);
|
super("módulos", x, y, w, h);
|
||||||
dragging = false;
|
dragging = false;
|
||||||
@@ -38,8 +36,8 @@ public class ModulePanel extends Panel<ModuleButton> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateWidth() {
|
protected void updateWidth() {
|
||||||
// asegurarse de que todos los botones caben en el marco, haciendo que la anchura se ajuste al texto más largo
|
// asegurarse de que todos los botones caben en el panel, haciendo
|
||||||
|
// que la anchura se ajuste al texto más largo
|
||||||
int maxWidth = mc.font.width(title);
|
int maxWidth = mc.font.width(title);
|
||||||
for (ModuleButton button : buttons) {
|
for (ModuleButton button : buttons) {
|
||||||
String text = button.getModule().getName();
|
String text = button.getModule().getName();
|
||||||
@@ -109,31 +107,35 @@ public class ModulePanel extends Panel<ModuleButton> {
|
|||||||
.filter(mb -> mb.getModule().isSearchMatch())
|
.filter(mb -> mb.getModule().isSearchMatch())
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
for (ModuleButton moduleButton : visibleModuleButtons)
|
for (ModuleButton moduleButton : visibleModuleButtons) {
|
||||||
moduleButton.mouseClicked(mouseX, mouseY, button);
|
moduleButton.mouseClicked(mouseX, mouseY, button);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// detectar cuándo se suelta el clic
|
// detectar cuándo se suelta el clic
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(int mouseX, int mouseY, int button) {
|
public void mouseReleased(int mouseX, int mouseY, int button) {
|
||||||
ClickGui.INSTANCE.unselect(this);
|
ClickGui.INSTANCE.unselect(this);
|
||||||
if (button == 0 && dragging)
|
if (button == 0 && dragging) {
|
||||||
dragging = false;
|
dragging = false;
|
||||||
|
}
|
||||||
|
|
||||||
List<ModuleButton> visibleModuleButtons = buttons.stream()
|
List<ModuleButton> visibleModuleButtons = buttons.stream()
|
||||||
.filter(mb -> mb.getModule().isSearchMatch())
|
.filter(mb -> mb.getModule().isSearchMatch())
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
for (ModuleButton moduleButton : visibleModuleButtons) {
|
for (ModuleButton moduleButton : visibleModuleButtons) {
|
||||||
if (moduleButton.isHovered(mouseX, mouseY))
|
if (moduleButton.isHovered(mouseX, mouseY)) {
|
||||||
moduleButton.mouseReleased(mouseX, mouseY, button);
|
moduleButton.mouseReleased(mouseX, mouseY, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isHovered(mouseX, mouseY))
|
|
||||||
Sputnik.EVENT_BUS.post(new ModulePanelEvent.Move());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// actualizar la posición al arrastrar el marco
|
if (isHovered(mouseX, mouseY)) {
|
||||||
|
Sputnik.EVENT_BUS.post(new ModulePanelEvent.Move());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// actualizar la posición al arrastrar el panel
|
||||||
public void updatePosition(double mouseX, double mouseY) {
|
public void updatePosition(double mouseX, double mouseY) {
|
||||||
if (dragging) {
|
if (dragging) {
|
||||||
x = (int) (mouseX - dragX);
|
x = (int) (mouseX - dragX);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class SettingsPanel extends Panel<SettingButton<? extends Setting<?>>> {
|
|||||||
|
|
||||||
private Module module;
|
private Module module;
|
||||||
protected List<SettingGroup> settingGroups;
|
protected List<SettingGroup> settingGroups;
|
||||||
private static final int PADDING = 4; // para ser consistente
|
protected static final int PADDING = 4; // para ser consistente
|
||||||
|
|
||||||
public SettingsPanel(Module module, int x, int y, int w, int h) {
|
public SettingsPanel(Module module, int x, int y, int w, int h) {
|
||||||
super("ajustes de " + module.getName(), x, y, w, h);
|
super("ajustes de " + module.getName(), x, y, w, h);
|
||||||
|
|||||||
@@ -332,19 +332,19 @@ public class ColorPickerPanel extends SettingsPanel {
|
|||||||
if (colorSetting != null) {
|
if (colorSetting != null) {
|
||||||
if (isSBPickerHovered(mouseX, mouseY)) {
|
if (isSBPickerHovered(mouseX, mouseY)) {
|
||||||
pickingSaturationBrightness = true;
|
pickingSaturationBrightness = true;
|
||||||
updateColorFromPicker((int) mouseX, (int) mouseY);
|
updateColorFromPicker(mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!colorSetting.isRainbow() && isHuePickerHovered(mouseX, mouseY)) {
|
if (!colorSetting.isRainbow() && isHuePickerHovered(mouseX, mouseY)) {
|
||||||
pickingHue = true;
|
pickingHue = true;
|
||||||
updateColorFromPicker((int) mouseX, (int) mouseY);
|
updateColorFromPicker(mouseX, mouseY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// opacidad
|
// opacidad
|
||||||
if (isAlphaPickerHovered(mouseX, mouseY)) {
|
if (isAlphaPickerHovered(mouseX, mouseY)) {
|
||||||
pickingAlpha = true;
|
pickingAlpha = true;
|
||||||
updateColorFromPicker((int) mouseX, (int) mouseY);
|
updateColorFromPicker(mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (SettingButton<?> sb : visibleButtons)
|
for (SettingButton<?> sb : visibleButtons)
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
package me.retucio.sputnik.ui.widgets.panels.settings;
|
||||||
|
|
||||||
|
import me.retucio.sputnik.config.ConfigManager;
|
||||||
|
import me.retucio.sputnik.friend.Friend;
|
||||||
|
import me.retucio.sputnik.friend.FriendManager;
|
||||||
|
import me.retucio.sputnik.module.Category;
|
||||||
|
import me.retucio.sputnik.module.Module;
|
||||||
|
import me.retucio.sputnik.module.ModuleManager;
|
||||||
|
import me.retucio.sputnik.module.modules.client.Friends;
|
||||||
|
import me.retucio.sputnik.module.setting.settings.StringSetting;
|
||||||
|
import me.retucio.sputnik.ui.screen.ClickGui;
|
||||||
|
import me.retucio.sputnik.ui.widgets.buttons.settings.TextButton;
|
||||||
|
import me.retucio.sputnik.ui.widgets.panels.SettingsPanel;
|
||||||
|
import me.retucio.sputnik.util.Colors;
|
||||||
|
import net.minecraft.client.gui.GuiGraphicsExtractor;
|
||||||
|
|
||||||
|
|
||||||
|
public class FriendSettingsPanel extends SettingsPanel {
|
||||||
|
|
||||||
|
private final Friend friend;
|
||||||
|
private final StringSetting nickname;
|
||||||
|
public final Module dummyModule;
|
||||||
|
|
||||||
|
private int removeButtonY;
|
||||||
|
|
||||||
|
public FriendSettingsPanel(Friend friend, int x, int y, int w, int h) {
|
||||||
|
super(ModuleManager.INSTANCE.getModuleByClass(Friends.class), x, y, w, h);
|
||||||
|
|
||||||
|
this.friend = friend;
|
||||||
|
|
||||||
|
dummyModule = new Module(friend.getName(), "gestiona a " + friend.getName(), Category.CLIENT) {
|
||||||
|
@Override public void onEnable() {}
|
||||||
|
@Override public void onDisable() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
dummyModule.getSettings().forEach(s -> s.visibility(false));
|
||||||
|
dummyModule.shouldSaveSettings(false);
|
||||||
|
|
||||||
|
setModule(dummyModule);
|
||||||
|
|
||||||
|
nickname = new StringSetting("nombre", "con qué nombre guardar al amigo", friend.getName(), 40);
|
||||||
|
dummyModule.getSgGeneral().add(nickname);
|
||||||
|
nickname.onUpdate(name -> {
|
||||||
|
friend.setName(name);
|
||||||
|
ConfigManager.getConfig().friends.put(friend.getUuid().toString(), name);
|
||||||
|
ConfigManager.save();
|
||||||
|
});
|
||||||
|
|
||||||
|
buttons.clear();
|
||||||
|
addButton(new TextButton(nickname, this, h));
|
||||||
|
|
||||||
|
setSettingGroups(dummyModule.getSgs());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(GuiGraphicsExtractor gui, int mx, int my, float delta) {
|
||||||
|
super.render(gui, mx, my, delta);
|
||||||
|
|
||||||
|
removeButtonY = renderY + h + totalHeight + PADDING;
|
||||||
|
int buttonH = h - h / 4;
|
||||||
|
|
||||||
|
gui.fill(x, removeButtonY, x + w, removeButtonY + buttonH + PADDING, Colors.panelBgColor.getRGB());
|
||||||
|
|
||||||
|
int color = isRemoveButtonHovered(mx, my)
|
||||||
|
? Colors.disabledToggleButtonColor.brighter().getRGB()
|
||||||
|
: Colors.disabledToggleButtonColor.getRGB();
|
||||||
|
|
||||||
|
gui.fill(x + PADDING, removeButtonY, x + w - PADDING, removeButtonY + buttonH, color);
|
||||||
|
|
||||||
|
String label = "eliminar amigo";
|
||||||
|
gui.text(mc.font, label,
|
||||||
|
x + w / 2 - mc.font.width(label) / 2,
|
||||||
|
removeButtonY + (buttonH - mc.font.lineHeight) / 2,
|
||||||
|
-1, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(int mouseX, int mouseY, int button) {
|
||||||
|
super.mouseClicked(mouseX, mouseY, button);
|
||||||
|
|
||||||
|
if (button == 0 && isRemoveButtonHovered(mouseX, mouseY)) {
|
||||||
|
FriendManager.INSTANCE.remove(friend);
|
||||||
|
ClickGui.INSTANCE.closeSettingsPanel(dummyModule);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isRemoveButtonHovered(int mouseX, int mouseY) {
|
||||||
|
int buttonH = h - h / 4;
|
||||||
|
return mouseX > x + PADDING && mouseX < x + w - PADDING
|
||||||
|
&& mouseY > removeButtonY && mouseY < removeButtonY + buttonH;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Friend getFriend() {
|
||||||
|
return friend;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user