mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Refactor GUIScreenToolAbility to support tooltips
This commit is contained in:
parent
bf1e14c08f
commit
61917ddc2f
@ -3,12 +3,9 @@ package com.hbm.inventory.gui;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.special.ItemHolotapeImage.EnumHoloImage;
|
||||
import com.hbm.items.tool.ItemToolAbility;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.util.EnumUtil;
|
||||
@ -17,11 +14,8 @@ import com.hbm.util.I18nUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemTool;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIScreenToolAbility extends GuiScreen {
|
||||
@ -55,19 +49,19 @@ public class GUIScreenToolAbility extends GuiScreen {
|
||||
public static final List<AbilityInfo> abilitiesHarvest = new ArrayList<>();
|
||||
|
||||
static {
|
||||
abilitiesArea.add(new AbilityInfo(null, 0, 76, false));
|
||||
abilitiesArea.add(new AbilityInfo("tool.ability.recursion", 32, 76, false));
|
||||
abilitiesArea.add(new AbilityInfo("tool.ability.hammer", 64, 76, true));
|
||||
abilitiesArea.add(new AbilityInfo("tool.ability.explosion", 96, 76, true));
|
||||
abilitiesArea.add(new AbilityInfo(null, 0, 91, false));
|
||||
abilitiesArea.add(new AbilityInfo("tool.ability.recursion", 32, 91, false));
|
||||
abilitiesArea.add(new AbilityInfo("tool.ability.hammer", 64, 91, true));
|
||||
abilitiesArea.add(new AbilityInfo("tool.ability.explosion", 96, 91, true));
|
||||
|
||||
abilitiesHarvest.add(new AbilityInfo(null, 0, 92, false));
|
||||
abilitiesHarvest.add(new AbilityInfo("tool.ability.silktouch", 32, 92, false));
|
||||
abilitiesHarvest.add(new AbilityInfo("tool.ability.luck", 64, 92, false));
|
||||
abilitiesHarvest.add(new AbilityInfo("tool.ability.smelter", 96, 92, false));
|
||||
abilitiesHarvest.add(new AbilityInfo("tool.ability.shredder", 128, 92, false));
|
||||
abilitiesHarvest.add(new AbilityInfo("tool.ability.centrifuge", 160, 92, false));
|
||||
abilitiesHarvest.add(new AbilityInfo("tool.ability.crystallizer", 192, 92, false));
|
||||
abilitiesHarvest.add(new AbilityInfo("tool.ability.mercury", 224, 92, false));
|
||||
abilitiesHarvest.add(new AbilityInfo(null, 0, 107, false));
|
||||
abilitiesHarvest.add(new AbilityInfo("tool.ability.silktouch", 32, 107, false));
|
||||
abilitiesHarvest.add(new AbilityInfo("tool.ability.luck", 64, 107, false));
|
||||
abilitiesHarvest.add(new AbilityInfo("tool.ability.smelter", 96, 107, false));
|
||||
abilitiesHarvest.add(new AbilityInfo("tool.ability.shredder", 128, 107, false));
|
||||
abilitiesHarvest.add(new AbilityInfo("tool.ability.centrifuge", 160, 107, false));
|
||||
abilitiesHarvest.add(new AbilityInfo("tool.ability.crystallizer", 192, 107, false));
|
||||
abilitiesHarvest.add(new AbilityInfo("tool.ability.mercury", 224, 107, false));
|
||||
}
|
||||
|
||||
// TODO: availability status for abilities; list of presets; selected preset index;
|
||||
@ -121,12 +115,8 @@ public class GUIScreenToolAbility extends GuiScreen {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
|
||||
// Draw window background
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 100, ySize);
|
||||
for (int i = 0; i < insetWidth; i += 20) {
|
||||
drawTexturedModalRect(guiLeft + 100 + i, guiTop, 80, 0, 20, ySize);
|
||||
}
|
||||
drawTexturedModalRect(guiLeft + 100 + insetWidth, guiTop, 100, 0, xSize - insetWidth - 100, ySize);
|
||||
|
||||
drawStretchedRect(guiLeft, guiTop, 0, 0, xSize, xSize - insetWidth, ySize, 74, 76);
|
||||
|
||||
// Draw the switches
|
||||
drawSwitches(abilitiesArea, selectionIdxArea, selectedLevelArea, guiLeft + 15, guiTop + 25, mouseX, mouseY);
|
||||
drawSwitches(abilitiesHarvest, selectionIdxHarvest, selectedLevelHarvest, guiLeft + 15, guiTop + 45, mouseX, mouseY);
|
||||
@ -143,9 +133,24 @@ public class GUIScreenToolAbility extends GuiScreen {
|
||||
drawTexturedModalRect(extraBtnsX + i * 11, guiTop + 11, 186 + i * 9, 18, 9, 9);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw tooltip
|
||||
// TODO
|
||||
}
|
||||
|
||||
protected void drawStretchedRect(int x, int y, int u, int v, int realWidth, int width, int height, int keepLeft, int keepRight) {
|
||||
int midWidth = width - keepLeft - keepRight;
|
||||
int realMidWidth = realWidth - keepLeft - keepRight;
|
||||
drawTexturedModalRect(x, y, u, v, keepLeft, height);
|
||||
for (int i = 0; i < realMidWidth; i += midWidth) {
|
||||
drawTexturedModalRect(x + keepLeft + i, y, u + keepLeft, v, Math.min(midWidth, realMidWidth - i), height);
|
||||
}
|
||||
drawTexturedModalRect(x + keepLeft + realMidWidth, y, u + keepLeft + midWidth, v, keepRight, height);
|
||||
}
|
||||
|
||||
protected void drawSwitches(List<AbilityInfo> abilities, int selectionIdx, int selectedLevel, int x, int y, int mouseX, int mouseY) {
|
||||
// TODO: Store hovered ability, use it in click handling and the dynamic tooltip
|
||||
|
||||
for (int i = 0; i < abilities.size(); ++i) {
|
||||
AbilityInfo abilityInfo = abilities.get(i);
|
||||
boolean available = true; // TODO
|
||||
@ -181,7 +186,7 @@ public class GUIScreenToolAbility extends GuiScreen {
|
||||
}
|
||||
|
||||
protected void drawDigit(int digit, int x, int y) {
|
||||
drawTexturedModalRect(x, y, digit * 10, 108, 10, 15);
|
||||
drawTexturedModalRect(x, y, digit * 10, 123, 10, 15);
|
||||
}
|
||||
|
||||
private boolean isInAABB(int mouseX, int mouseY, int x, int y, int width, int height) {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
Loading…
x
Reference in New Issue
Block a user