Research icons?
This commit is contained in:
parent
bba2a1d9e0
commit
c66c64f87a
@ -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<ru.dbotthepony.mc.otm.android.AndroidResearch> AIR_BAGS = new AndroidResearchType<>(
|
||||
new ru.dbotthepony.mc.otm.android.AndroidResearch.Builder()
|
||||
.setExperienceCost(18)
|
||||
.addFeatureResult(AndroidFeatures.AIR_BAGS)
|
||||
.withDescription()
|
||||
.withIcon(ICON_AIR_BAGS)
|
||||
.build()
|
||||
);
|
||||
|
||||
|
@ -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<CompoundTag> {
|
||||
abstract public void consumeCost();
|
||||
abstract public boolean canAfford();
|
||||
|
||||
@Nullable
|
||||
public SkinElement getIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Component> getTooltip() {
|
||||
return List.of(type.getDisplayName());
|
||||
}
|
||||
@ -100,6 +108,7 @@ public abstract class AndroidResearch implements INBTSerializable<CompoundTag> {
|
||||
public final ArrayList<DeferredItemStack> items = new ArrayList<>();
|
||||
public final ArrayList<ResourceLocation> prerequisites = new ArrayList<>();
|
||||
public final ArrayList<ResourceLocation> 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<CompoundTag> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withIcon(SkinElement icon) {
|
||||
this.icon = icon;
|
||||
return this;
|
||||
}
|
||||
|
||||
private final ArrayList<ItemStack> resolved_stacks = new ArrayList<>();
|
||||
private final ArrayList<AndroidResearchType<?>> resolved_preq = new ArrayList<>();
|
||||
private final ArrayList<AndroidFeatureType<?>> resolved_features = new ArrayList<>();
|
||||
@ -181,6 +195,12 @@ public abstract class AndroidResearch implements INBTSerializable<CompoundTag> {
|
||||
resolve();
|
||||
|
||||
return new AndroidResearch(type, capability) {
|
||||
@Nullable
|
||||
@Override
|
||||
public SkinElement getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Component> getTooltip() {
|
||||
var list = new ArrayList<>(super.getTooltip());
|
||||
|
@ -18,7 +18,7 @@ import java.util.ArrayList;
|
||||
|
||||
public class AndroidStationScreen extends MatteryScreen<AndroidStationMenu> {
|
||||
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,15 +36,21 @@ public class AndroidStationScreen extends MatteryScreen<AndroidStationMenu> {
|
||||
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();
|
||||
}
|
||||
|
||||
var icon = node.getIcon();
|
||||
|
||||
if (icon != null) {
|
||||
icon.render(stack, 0, 0, getWidth(), getHeight());
|
||||
} else {
|
||||
RenderHelper.drawRect(stack, 0, 0, getWidth(), getHeight());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Loading…
Reference in New Issue
Block a user