Fix layering of tooltips and make buttons more hmmmhmmmhmmm

This commit is contained in:
Sollace 2018-07-27 19:42:37 +02:00
parent 380a23f932
commit 0f634e9ea6
7 changed files with 60 additions and 86 deletions

View file

@ -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);
} }

View file

@ -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);
}
} }

View file

@ -0,0 +1,7 @@
package com.minelittlepony.gui;
import net.minecraft.client.Minecraft;
public interface IGuiTooltipped {
void renderToolTip(Minecraft mc, int mouseX, int mouseY);
}

View file

@ -19,12 +19,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);

View file

@ -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");
this.checkbox.checked = mod.experimentalSkinDrop;
}
@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.INSTANCE.clearSkinCache(); HDSkinManager.INSTANCE.clearSkinCache();
} else if (checkbox.mousePressed(mc, mouseX, mouseY)) { }));
checkbox.checked = !checkbox.checked; addButton(new Checkbox(40, 40, "Experimental Skin Drop", mod.experimentalSkinDrop, checked -> {
mod.experimentalSkinDrop = checkbox.checked; System.out.println(checked);
mod.experimentalSkinDrop = 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) {
}
} }

View file

@ -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

View file

@ -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);
setWet(false); })).setEnabled(false).setTooltip("minelp.mode.dry");
}
})).setTooltip("minelp.mode.dry");
setWet(false);
} }
@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();