diff --git a/src/main/java/ru/dbotthepony/mc/otm/Registry.java b/src/main/java/ru/dbotthepony/mc/otm/Registry.java index f041061df..b7b8286de 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/Registry.java +++ b/src/main/java/ru/dbotthepony/mc/otm/Registry.java @@ -15,7 +15,6 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.registries.ForgeRegistry; import net.minecraftforge.registries.RegistryBuilder; import ru.dbotthepony.mc.otm.android.AndroidFeature; -import ru.dbotthepony.mc.otm.android.AndroidResearch; import ru.dbotthepony.mc.otm.android.AndroidResearchType; import ru.dbotthepony.mc.otm.block.*; import ru.dbotthepony.mc.otm.block.entity.*; @@ -290,11 +289,72 @@ public class Registry { } public static class AndroidResearch { + public static final ResourceLocation ICONS = new ResourceLocation(OverdriveThatMatters.MOD_ID, "textures/gui/android_upgrades.png"); + public static final SkinElement ICON_TRANSFER; + public static final SkinElement ICON_ATTACK_BOOST; + public static final SkinElement ICON_PLASMA_SHIELD_BOOST; + public static final SkinElement ICON_CLOAK; + public static final SkinElement ICON_GRAVITATIONAL_STABILIZER; + public static final SkinElement ICON_AIR_BAGS; + public static final SkinElement ICON_JUMP_BOOST; + + public static final SkinElement ICON_FEATHER_FALLING; + public static final SkinElement ICON_ARC; + public static final SkinElement ICON_ARROW; + public static final SkinElement ICON_ARMOR; + public static final SkinElement ICON_REGENERATIVE; + public static final SkinElement ICON_NIGHT_VISION; + public static final SkinElement ICON_OXYGEN_SUPPLY; + + public static final SkinElement ICON_PLASMA_SHIELD; + public static final SkinElement ICON_SHOCKWAVE; + public static final SkinElement ICON_LIMB_OVERCLOCKING; + public static final SkinElement ICON_STEP_ASSIST; + public static final SkinElement ICON_ENDER_TELEPORT; + public static final SkinElement ICON_WIRELESS_CHARGING; + public static final SkinElement ICON_UNKNOWN; + + static { + int x = 0; + int y = 0; + + ICON_TRANSFER = new SkinElement(ICONS, x, y, 18, 18, 126, 126); x += 18; + ICON_ATTACK_BOOST = new SkinElement(ICONS, x, y, 18, 18, 126, 126); x += 18; + ICON_PLASMA_SHIELD_BOOST = new SkinElement(ICONS, x, y, 18, 18, 126, 126); x += 18; + ICON_CLOAK = new SkinElement(ICONS, x, y, 18, 18, 126, 126); x += 18; + ICON_GRAVITATIONAL_STABILIZER = new SkinElement(ICONS, x, y, 18, 18, 126, 126); x += 18; + ICON_AIR_BAGS = new SkinElement(ICONS, x, y, 18, 18, 126, 126); x += 18; + ICON_JUMP_BOOST = new SkinElement(ICONS, x, y, 18, 18, 126, 126); + + y += 18; + x = 0; + + ICON_FEATHER_FALLING = new SkinElement(ICONS, x, y, 18, 18, 126, 126); x += 18; + ICON_ARC = new SkinElement(ICONS, x, y, 18, 18, 126, 126); x += 18; + ICON_ARROW = new SkinElement(ICONS, x, y, 18, 18, 126, 126); x += 18; + ICON_ARMOR = new SkinElement(ICONS, x, y, 18, 18, 126, 126); x += 18; + ICON_REGENERATIVE = new SkinElement(ICONS, x, y, 18, 18, 126, 126); x += 18; + ICON_NIGHT_VISION = new SkinElement(ICONS, x, y, 18, 18, 126, 126); x += 18; + ICON_OXYGEN_SUPPLY = new SkinElement(ICONS, x, y, 18, 18, 126, 126); + + y += 18; + x = 0; + + ICON_PLASMA_SHIELD = new SkinElement(ICONS, x, y, 18, 18, 126, 126); x += 18; + ICON_SHOCKWAVE = new SkinElement(ICONS, x, y, 18, 18, 126, 126); x += 18; + ICON_LIMB_OVERCLOCKING = new SkinElement(ICONS, x, y, 18, 18, 126, 126); x += 18; + ICON_STEP_ASSIST = new SkinElement(ICONS, x, y, 18, 18, 126, 126); x += 18; + ICON_ENDER_TELEPORT = new SkinElement(ICONS, x, y, 18, 18, 126, 126); x += 18; + ICON_WIRELESS_CHARGING = new SkinElement(ICONS, x, y, 18, 18, 126, 126); x += 18; + ICON_UNKNOWN = new SkinElement(ICONS, x, y, 18, 18, 126, 126); + } + public static final AndroidResearchType AIR_BAGS = new AndroidResearchType<>( new ru.dbotthepony.mc.otm.android.AndroidResearch.Builder() .setExperienceCost(18) .addFeatureResult(AndroidFeatures.AIR_BAGS) .withDescription() + .withIcon(ICON_AIR_BAGS) .build() ); diff --git a/src/main/java/ru/dbotthepony/mc/otm/android/AndroidResearch.java b/src/main/java/ru/dbotthepony/mc/otm/android/AndroidResearch.java index a04ef1880..5fc5fba51 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/android/AndroidResearch.java +++ b/src/main/java/ru/dbotthepony/mc/otm/android/AndroidResearch.java @@ -1,5 +1,6 @@ package ru.dbotthepony.mc.otm.android; +import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.nbt.CompoundTag; @@ -17,7 +18,9 @@ import ru.dbotthepony.mc.otm.capability.AndroidCapabilityPlayer; import ru.dbotthepony.mc.otm.capability.MatteryCapability; import ru.dbotthepony.mc.otm.network.MatteryNetworking; import ru.dbotthepony.mc.otm.network.android.AndroidResearchRequestPacket; +import ru.dbotthepony.mc.otm.screen.SkinElement; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -48,6 +51,11 @@ public abstract class AndroidResearch implements INBTSerializable { abstract public void consumeCost(); abstract public boolean canAfford(); + @Nullable + public SkinElement getIcon() { + return null; + } + public List getTooltip() { return List.of(type.getDisplayName()); } @@ -100,6 +108,7 @@ public abstract class AndroidResearch implements INBTSerializable { public final ArrayList items = new ArrayList<>(); public final ArrayList prerequisites = new ArrayList<>(); public final ArrayList feature_results = new ArrayList<>(); + public SkinElement icon; public Builder addPrerequisite(ResourceLocation location) { prerequisites.add(location); @@ -136,6 +145,11 @@ public abstract class AndroidResearch implements INBTSerializable { return this; } + public Builder withIcon(SkinElement icon) { + this.icon = icon; + return this; + } + private final ArrayList resolved_stacks = new ArrayList<>(); private final ArrayList> resolved_preq = new ArrayList<>(); private final ArrayList> resolved_features = new ArrayList<>(); @@ -181,6 +195,12 @@ public abstract class AndroidResearch implements INBTSerializable { resolve(); return new AndroidResearch(type, capability) { + @Nullable + @Override + public SkinElement getIcon() { + return icon; + } + @Override public List getTooltip() { var list = new ArrayList<>(super.getTooltip()); diff --git a/src/main/java/ru/dbotthepony/mc/otm/screen/AndroidStationScreen.java b/src/main/java/ru/dbotthepony/mc/otm/screen/AndroidStationScreen.java index d5ad9600d..ec4c54b69 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/screen/AndroidStationScreen.java +++ b/src/main/java/ru/dbotthepony/mc/otm/screen/AndroidStationScreen.java @@ -18,7 +18,7 @@ import java.util.ArrayList; public class AndroidStationScreen extends MatteryScreen { class AndroidResearchButton extends EditablePanel { - public static final int BUTTON_SIZE = 16; + public static final int BUTTON_SIZE = 18; private final AndroidResearch node; public static final RGBAColor RESEARCHED = new RGBAColor(150, 150, 200); @@ -36,14 +36,20 @@ public class AndroidStationScreen extends MatteryScreen { Minecraft.getInstance().player.getCapability(MatteryCapability.ANDROID).ifPresent(_cap -> { if (_cap instanceof AndroidCapabilityPlayer cap) { if (node.isResearched()) { - RenderHelper.setDrawColor(RESEARCHED); + RESEARCHED.setSystemColor(); } else if (node.canAfford()) { - RenderHelper.setDrawColor(CAN_BE_RESEARCHED); + CAN_BE_RESEARCHED.setSystemColor(); } else { - RenderHelper.setDrawColor(CAN_NOT_BE_RESEARCHED); + CAN_NOT_BE_RESEARCHED.setSystemColor(); } - RenderHelper.drawRect(stack, 0, 0, getWidth(), getHeight()); + var icon = node.getIcon(); + + if (icon != null) { + icon.render(stack, 0, 0, getWidth(), getHeight()); + } else { + RenderHelper.drawRect(stack, 0, 0, getWidth(), getHeight()); + } } }); } diff --git a/src/main/java/ru/dbotthepony/mc/otm/screen/RGBAColor.java b/src/main/java/ru/dbotthepony/mc/otm/screen/RGBAColor.java index 72855c4cb..5d1ef3d9f 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/screen/RGBAColor.java +++ b/src/main/java/ru/dbotthepony/mc/otm/screen/RGBAColor.java @@ -1,5 +1,7 @@ package ru.dbotthepony.mc.otm.screen; +import com.mojang.blaze3d.systems.RenderSystem; + public record RGBAColor(float r, float g, float b, float a) { public RGBAColor(float r, float g, float b, float a) { this.r = r; @@ -36,4 +38,17 @@ public record RGBAColor(float r, float g, float b, float a) { return r << 16 | g << 8 | b; } + + public void setSystemColor() { + setShaderColor(); + setDrawColor(); + } + + public void setShaderColor() { + RenderSystem.setShaderColor(r, g, b, a); + } + + public void setDrawColor() { + RenderHelper.setDrawColor(this); + } } diff --git a/src/main/java/ru/dbotthepony/mc/otm/screen/RenderHelper.java b/src/main/java/ru/dbotthepony/mc/otm/screen/RenderHelper.java index 7652e62d7..23673cb2f 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/screen/RenderHelper.java +++ b/src/main/java/ru/dbotthepony/mc/otm/screen/RenderHelper.java @@ -423,6 +423,10 @@ public class RenderHelper { RenderHelper.rect_color = rect_color; } + public static void setShaderColor(RGBAColor rect_color) { + RenderSystem.setShaderColor(rect_color.r(), rect_color.g(), rect_color.b(), rect_color.a()); + } + private static RGBAColor rect_color = new RGBAColor(255, 255, 255, 255); /** diff --git a/src/main/java/ru/dbotthepony/mc/otm/screen/SkinElement.java b/src/main/java/ru/dbotthepony/mc/otm/screen/SkinElement.java index b77c7ac28..2ba78bb50 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/screen/SkinElement.java +++ b/src/main/java/ru/dbotthepony/mc/otm/screen/SkinElement.java @@ -26,6 +26,10 @@ public record SkinElement(ResourceLocation texture, float image_x, float image_y (image_y + rect_h) / defined_height); } + public void render(PoseStack stack) { + render(stack, 0, 0); + } + public void render(PoseStack stack, float x, float y) { RenderSystem.setShaderTexture(0, texture); RenderSystem.enableBlend(); diff --git a/src/main/resources/assets/overdrive_that_matters/textures/gui/android_upgrades.png b/src/main/resources/assets/overdrive_that_matters/textures/gui/android_upgrades.png new file mode 100644 index 000000000..ea41b737a Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/gui/android_upgrades.png differ