mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-30 07:57:59 +01:00
Fix layering of tooltips and make buttons more hmmmhmmmhmmm
This commit is contained in:
parent
063d9bfbd0
commit
25230a384c
9 changed files with 71 additions and 97 deletions
|
@ -0,0 +1,7 @@
|
||||||
|
package com.minelittlepony.gui;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
|
public interface IGuiTooltipped {
|
||||||
|
void renderToolTip(Minecraft mc, int mouseX, int mouseY);
|
||||||
|
}
|
|
@ -7,7 +7,7 @@ import com.google.common.base.Splitter;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
|
||||||
public class Button extends GuiButton implements IActionable {
|
public class Button extends GuiButton implements IActionable, IGuiTooltipped {
|
||||||
|
|
||||||
private IGuiAction<Button> action;
|
private IGuiAction<Button> action;
|
||||||
|
|
||||||
|
@ -38,8 +38,8 @@ public class Button extends GuiButton implements IActionable {
|
||||||
return setTooltip(Splitter.on("\r\n").splitToList(GameGui.format(tooltip)));
|
return setTooltip(Splitter.on("\r\n").splitToList(GameGui.format(tooltip)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
|
@Override
|
||||||
super.drawButton(mc, mouseX, mouseY, partialTicks);
|
public void renderToolTip(Minecraft mc, int mouseX, int mouseY) {
|
||||||
if (visible && isMouseOver() && tooltip != null) {
|
if (visible && isMouseOver() && tooltip != null) {
|
||||||
mc.currentScreen.drawHoveringText(tooltip, mouseX, mouseY);
|
mc.currentScreen.drawHoveringText(tooltip, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,4 +16,19 @@ public abstract class GameGui extends GuiScreen {
|
||||||
protected static String format(String string) {
|
protected static String format(String string) {
|
||||||
return I18n.format(string);
|
return I18n.format(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||||
|
drawContents(mouseX, mouseY, partialTicks);
|
||||||
|
|
||||||
|
buttonList.forEach(button -> {
|
||||||
|
if (button instanceof IGuiTooltipped) {
|
||||||
|
((IGuiTooltipped)button).renderToolTip(mc, mouseX, mouseY);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void drawContents(int mouseX, int mouseY, float partialTicks) {
|
||||||
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,28 +271,28 @@ public final class HDSkinManager implements IResourceManagerReloadListener {
|
||||||
clearListeners.add(listener);
|
clearListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearSkinCache() {
|
public void clearSkinCache() {
|
||||||
LiteLoaderLogger.info("Clearing local player skin cache");
|
LiteLoaderLogger.info("Clearing local player skin cache");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileUtils.deleteDirectory(new File(LiteLoader.getAssetsDirectory(), "skins"));
|
FileUtils.deleteDirectory(new File(LiteLoader.getAssetsDirectory(), "skins"));
|
||||||
FileUtils.deleteDirectory(new File(LiteLoader.getAssetsDirectory(), "hd"));
|
FileUtils.deleteDirectory(new File(LiteLoader.getAssetsDirectory(), "hd"));
|
||||||
TextureManager textures = Minecraft.getMinecraft().getTextureManager();
|
TextureManager textures = Minecraft.getMinecraft().getTextureManager();
|
||||||
INSTANCE.skinCache.values().stream()
|
skinCache.values().stream()
|
||||||
.flatMap(m -> m.values().stream())
|
.flatMap(m -> m.values().stream())
|
||||||
.forEach(textures::deleteTexture);
|
.forEach(textures::deleteTexture);
|
||||||
INSTANCE.skinCache.clear();
|
skinCache.clear();
|
||||||
INSTANCE.skins.invalidateAll();
|
skins.invalidateAll();
|
||||||
} catch (IOException var1) {
|
} catch (IOException e) {
|
||||||
var1.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANCE.clearListeners = INSTANCE.clearListeners.stream()
|
clearListeners = clearListeners.stream()
|
||||||
.filter(HDSkinManager::onSkinCacheCleared)
|
.filter(this::onSkinCacheCleared)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean onSkinCacheCleared(ISkinCacheClearListener callback) {
|
private boolean onSkinCacheCleared(ISkinCacheClearListener callback) {
|
||||||
try {
|
try {
|
||||||
return callback.onSkinCacheCleared();
|
return callback.onSkinCacheCleared();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class LiteModHDSkins implements InitCompleteListener, ViewportListener, C
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void upgradeSettings(String version, File configPath, File oldConfigPath) {
|
public void upgradeSettings(String version, File configPath, File oldConfigPath) {
|
||||||
HDSkinManager.clearSkinCache();
|
HDSkinManager.INSTANCE.clearSkinCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,12 +20,14 @@ import com.voxelmodpack.hdskins.skins.SkinUploadResponse;
|
||||||
import com.voxelmodpack.hdskins.upload.awt.ThreadOpenFilePNG;
|
import com.voxelmodpack.hdskins.upload.awt.ThreadOpenFilePNG;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||||
import net.minecraft.client.gui.Gui;
|
import net.minecraft.client.gui.Gui;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiMainMenu;
|
import net.minecraft.client.gui.GuiMainMenu;
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
import net.minecraft.client.renderer.RenderHelper;
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.init.SoundEvents;
|
||||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
|
@ -242,7 +244,7 @@ public class GuiSkins extends GameGui {
|
||||||
})).setEnabled(!thinArmType).setTooltip("hdskins.mode.skinny");
|
})).setEnabled(!thinArmType).setTooltip("hdskins.mode.skinny");
|
||||||
|
|
||||||
addButton(new Button(width - 25, height - 65, 20, 20, "?", sender -> {
|
addButton(new Button(width - 25, height - 65, 20, 20, "?", sender -> {
|
||||||
|
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.ENTITY_VILLAGER_YES, 1));
|
||||||
})).setTooltip(Splitter.on("\r\n").splitToList(HDSkinManager.INSTANCE.getGatewayServer().toString()));
|
})).setTooltip(Splitter.on("\r\n").splitToList(HDSkinManager.INSTANCE.getGatewayServer().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,6 +290,8 @@ public class GuiSkins extends GameGui {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void switchSkinMode(Button sender, boolean thin, Type newType, ItemStack stack) {
|
protected void switchSkinMode(Button sender, boolean thin, Type newType, ItemStack stack) {
|
||||||
|
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.BLOCK_BREWING_STAND_BREW, 1));
|
||||||
|
|
||||||
thinArmType = thin;
|
thinArmType = thin;
|
||||||
textureType = newType;
|
textureType = newType;
|
||||||
|
|
||||||
|
@ -360,7 +364,7 @@ public class GuiSkins extends GameGui {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTick) {
|
protected void drawContents(int mouseX, int mouseY, float partialTick) {
|
||||||
float deltaTime = panorama.getDelta(partialTick);
|
float deltaTime = panorama.getDelta(partialTick);
|
||||||
panorama.render(partialTick, zLevel);
|
panorama.render(partialTick, zLevel);
|
||||||
|
|
||||||
|
@ -376,7 +380,7 @@ public class GuiSkins extends GameGui {
|
||||||
drawGradientRect(30, horizon, mid - 30, bottom, 0x80FFFFFF, 0xffffff);
|
drawGradientRect(30, horizon, mid - 30, bottom, 0x80FFFFFF, 0xffffff);
|
||||||
drawGradientRect(mid + 30, horizon, width - 30, bottom, 0x80FFFFFF, 0xffffff);
|
drawGradientRect(mid + 30, horizon, width - 30, bottom, 0x80FFFFFF, 0xffffff);
|
||||||
|
|
||||||
super.drawScreen(mouseX, mouseY, partialTick);
|
super.drawContents(mouseX, mouseY, partialTick);
|
||||||
|
|
||||||
popAttrib();
|
popAttrib();
|
||||||
enableClipping(bottom);
|
enableClipping(bottom);
|
||||||
|
|
|
@ -1,50 +1,23 @@
|
||||||
package com.voxelmodpack.hdskins.gui;
|
package com.voxelmodpack.hdskins.gui;
|
||||||
|
|
||||||
import com.mumfrey.liteloader.client.gui.GuiCheckbox;
|
import com.minelittlepony.gui.Button;
|
||||||
|
import com.minelittlepony.gui.Checkbox;
|
||||||
|
import com.minelittlepony.gui.SettingsPanel;
|
||||||
import com.mumfrey.liteloader.core.LiteLoader;
|
import com.mumfrey.liteloader.core.LiteLoader;
|
||||||
import com.mumfrey.liteloader.modconfig.ConfigPanel;
|
|
||||||
import com.mumfrey.liteloader.modconfig.ConfigPanelHost;
|
|
||||||
import com.voxelmodpack.hdskins.HDSkinManager;
|
import com.voxelmodpack.hdskins.HDSkinManager;
|
||||||
import com.voxelmodpack.hdskins.LiteModHDSkins;
|
import com.voxelmodpack.hdskins.LiteModHDSkins;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
public class HDSkinsConfigPanel extends SettingsPanel {
|
||||||
import net.minecraft.client.gui.GuiButton;
|
|
||||||
|
|
||||||
public class HDSkinsConfigPanel implements ConfigPanel {
|
|
||||||
|
|
||||||
private GuiButton button;
|
|
||||||
|
|
||||||
private GuiCheckbox checkbox;
|
|
||||||
|
|
||||||
private LiteModHDSkins mod;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPanelShown(ConfigPanelHost host) {
|
public void initGui() {
|
||||||
this.mod = LiteLoader.getInstance().getMod(LiteModHDSkins.class);
|
final LiteModHDSkins mod = LiteLoader.getInstance().getMod(LiteModHDSkins.class);
|
||||||
|
|
||||||
this.button = new GuiButton(0, 40, 70, 100, 20, "Clear Skin Cache");
|
addButton(new Button(40, 70, 100, 20, "Clear Skin Cache", sender ->{
|
||||||
this.checkbox = new GuiCheckbox(1, 40, 40, "Experimental Skin Drop");
|
HDSkinManager.INSTANCE.clearSkinCache();
|
||||||
|
}));
|
||||||
this.checkbox.checked = mod.experimentalSkinDrop;
|
addButton(new Checkbox(40, 40, "Experimental Skin Drop", mod.experimentalSkinDrop, checked -> {
|
||||||
}
|
System.out.println(checked);
|
||||||
|
mod.experimentalSkinDrop = checked;
|
||||||
@Override
|
|
||||||
public void drawPanel(ConfigPanelHost host, int mouseX, int mouseY, float partialTicks) {
|
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
|
|
||||||
this.button.drawButton(mc, mouseX, mouseY, partialTicks);
|
|
||||||
this.checkbox.drawButton(mc, mouseX, mouseY, partialTicks);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mousePressed(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton) {
|
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
|
|
||||||
if (button.mousePressed(mc, mouseX, mouseY)) {
|
|
||||||
HDSkinManager.clearSkinCache();
|
|
||||||
} else if (checkbox.mousePressed(mc, mouseX, mouseY)) {
|
|
||||||
checkbox.checked = !checkbox.checked;
|
|
||||||
mod.experimentalSkinDrop = checkbox.checked;
|
|
||||||
|
|
||||||
LiteLoader.getInstance().writeConfig(mod);
|
LiteLoader.getInstance().writeConfig(mod);
|
||||||
|
|
||||||
|
@ -53,40 +26,13 @@ public class HDSkinsConfigPanel implements ConfigPanel {
|
||||||
} else {
|
} else {
|
||||||
GLWindow.dispose();
|
GLWindow.dispose();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return checked;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPanelTitle() {
|
protected String getTitle() {
|
||||||
return "HD Skins Settings";
|
return "HD Skins Settings";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getContentHeight() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void keyPressed(ConfigPanelHost host, char keyChar, int keyCode) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseMoved(ConfigPanelHost host, int mouseX, int mouseY) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseReleased(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPanelHidden() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPanelResize(ConfigPanelHost host) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTick(ConfigPanelHost host) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,9 @@ public class GuiPonySettings extends SettingsPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
public void drawContents(int mouseX, int mouseY, float partialTicks) {
|
||||||
drawDefaultBackground();
|
drawDefaultBackground();
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
super.drawContents(mouseX, mouseY, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,7 +10,9 @@ import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
|
||||||
import com.voxelmodpack.hdskins.gui.GuiItemStackButton;
|
import com.voxelmodpack.hdskins.gui.GuiItemStackButton;
|
||||||
import com.voxelmodpack.hdskins.gui.GuiSkins;
|
import com.voxelmodpack.hdskins.gui.GuiSkins;
|
||||||
|
|
||||||
|
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.init.SoundEvents;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
@ -42,17 +44,11 @@ public class GuiSkinsMineLP extends GuiSkins {
|
||||||
super.initGui();
|
super.initGui();
|
||||||
|
|
||||||
addButton(btnModeWet = new GuiItemStackButton(width - 25, 139, new ItemStack(Items.WATER_BUCKET), sender -> {
|
addButton(btnModeWet = new GuiItemStackButton(width - 25, 139, new ItemStack(Items.WATER_BUCKET), sender -> {
|
||||||
if (!isWet) {
|
|
||||||
setWet(true);
|
setWet(true);
|
||||||
}
|
|
||||||
})).setTooltip("minelp.mode.wet");
|
})).setTooltip("minelp.mode.wet");
|
||||||
addButton(btnModeDry = new GuiItemStackButton(width - 25, 120, new ItemStack(Items.BUCKET), sender -> {
|
addButton(btnModeDry = new GuiItemStackButton(width - 25, 120, new ItemStack(Items.BUCKET), sender -> {
|
||||||
if (isWet) {
|
|
||||||
setWet(false);
|
|
||||||
}
|
|
||||||
})).setTooltip("minelp.mode.dry");
|
|
||||||
|
|
||||||
setWet(false);
|
setWet(false);
|
||||||
|
})).setEnabled(false).setTooltip("minelp.mode.dry");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -63,6 +59,12 @@ public class GuiSkinsMineLP extends GuiSkins {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setWet(boolean wet) {
|
protected void setWet(boolean wet) {
|
||||||
|
if (wet == isWet) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.BLOCK_BREWING_STAND_BREW, 1));
|
||||||
|
|
||||||
isWet = wet;
|
isWet = wet;
|
||||||
localPlayer.releaseTextures();
|
localPlayer.releaseTextures();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue