diff --git a/src/main/java/betterquesting/api/enums/EnumFrameType.java b/src/main/java/betterquesting/api/enums/EnumFrameType.java new file mode 100644 index 000000000..948cf021b --- /dev/null +++ b/src/main/java/betterquesting/api/enums/EnumFrameType.java @@ -0,0 +1,40 @@ +package betterquesting.api.enums; + +public enum EnumFrameType { + DEFAULT, + SQUARE, + ROUNDED_SQUARE, + CIRCLE, + HEXAGON, + HEXAGON90, + PENTAGON, + DIAMOND, + STAR4, + CROSS, + DIAGONAL_CROSS, + DIAGONAL_STAR4, + PRICKLE, + GEAR, + GATE, + JAGGED, + EGG, + HEART, + COLLAPSED_SQUARE, + SKULL, + DIAMOND_ON_SQUARE, + CROSS_ON_SQUARE, + STAR4_ON_SQUARE, + DIAMOND_ON_CIRCLE, + DIAGONAL_STAR4_ON_CROSS, + STAR4_ON_HEXAGON, + DIAGONAL_STAR4_ON_HEXAGON, + STAR4_ON_HEXAGON90, + DIAGONAL_STAR4_ON_HEXAGON90, + DIAGONAL_CROSS_ON_DIAMOND, + DIAGONAL_STAR4_ON_DIAMOND, + DIAMOND_ON_CROSS, + STAR4_ON_CROSS, + CROSS_ON_DIAGONAL_STAR4, + DIAMOND_ON_DIAGONAL_STAR4, + SATAR4_ON_DIAGONAL_STAR4, +} diff --git a/src/main/java/betterquesting/api/enums/EnumQuestState.java b/src/main/java/betterquesting/api/enums/EnumQuestState.java index 24f4f29f9..7d8e1de7d 100644 --- a/src/main/java/betterquesting/api/enums/EnumQuestState.java +++ b/src/main/java/betterquesting/api/enums/EnumQuestState.java @@ -1,9 +1,37 @@ package betterquesting.api.enums; +import betterquesting.api2.client.gui.resources.colors.IGuiColor; +import betterquesting.api2.client.gui.themes.presets.PresetColor; + public enum EnumQuestState { + LOCKED, UNLOCKED, UNCLAIMED, COMPLETED, - REPEATABLE; + REPEATABLE + + ; + + public IGuiColor getColor() { + switch (this) { + case LOCKED -> { + return PresetColor.QUEST_ICON_LOCKED.getColor(); + } + case UNLOCKED -> { + return PresetColor.QUEST_ICON_UNLOCKED.getColor(); + } + case UNCLAIMED -> { + return PresetColor.QUEST_ICON_PENDING.getColor(); + } + case COMPLETED -> { + return PresetColor.QUEST_ICON_COMPLETE.getColor(); + } + case REPEATABLE -> { + return PresetColor.QUEST_ICON_REPEATABLE.getColor(); + } + default -> throw new IllegalStateException("Unexpected value: " + this); + } + } + } diff --git a/src/main/java/betterquesting/api/properties/NativeProps.java b/src/main/java/betterquesting/api/properties/NativeProps.java index 881235213..60405b2fb 100644 --- a/src/main/java/betterquesting/api/properties/NativeProps.java +++ b/src/main/java/betterquesting/api/properties/NativeProps.java @@ -1,8 +1,14 @@ package betterquesting.api.properties; +import betterquesting.api.enums.EnumFrameType; import betterquesting.api.enums.EnumLogic; import betterquesting.api.enums.EnumQuestVisibility; -import betterquesting.api.properties.basic.*; +import betterquesting.api.properties.basic.PropertyTypeBoolean; +import betterquesting.api.properties.basic.PropertyTypeEnum; +import betterquesting.api.properties.basic.PropertyTypeFloat; +import betterquesting.api.properties.basic.PropertyTypeInteger; +import betterquesting.api.properties.basic.PropertyTypeItemStack; +import betterquesting.api.properties.basic.PropertyTypeString; import betterquesting.api.storage.BQ_Settings; import betterquesting.api.utils.BigItemStack; import betterquesting.core.ModReference; @@ -15,6 +21,7 @@ * List of native properties used in BetterQuesting */ public class NativeProps { + public static final IPropertyType NAME = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "name"), "untitled.name"); public static final IPropertyType DESC = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "desc"), "untitled.desc"); @@ -28,19 +35,24 @@ public class NativeProps { public static final IPropertyType SIMULTANEOUS = new PropertyTypeBoolean(new ResourceLocation(ModReference.MODID, "simultaneous"), false); public static final IPropertyType IGNORES_VIEW_MODE = new PropertyTypeBoolean(new ResourceLocation(ModReference.MODID, "ignoresView"), false); - public static final IPropertyType VISIBILITY = new PropertyTypeEnum<>(new ResourceLocation(ModReference.MODID, "visibility"), findVisibility()); + public static final IPropertyType VISIBILITY = new PropertyTypeEnum<>(new ResourceLocation(ModReference.MODID, "visibility"), + findVisibility()); public static final IPropertyType LOGIC_TASK = new PropertyTypeEnum<>(new ResourceLocation(ModReference.MODID, "taskLogic"), EnumLogic.AND); public static final IPropertyType LOGIC_QUEST = new PropertyTypeEnum<>(new ResourceLocation(ModReference.MODID, "questLogic"), EnumLogic.AND); public static final IPropertyType REPEAT_TIME = new PropertyTypeInteger(new ResourceLocation(ModReference.MODID, "repeatTime"), -1); public static final IPropertyType REPEAT_REL = new PropertyTypeBoolean(new ResourceLocation(ModReference.MODID, "repeat_relative"), true); - public static final IPropertyType SOUND_UNLOCK = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "snd_unlock"), "minecraft:ui.button.click"); - public static final IPropertyType SOUND_UPDATE = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "snd_update"), "minecraft:entity.player.levelup"); - public static final IPropertyType SOUND_COMPLETE = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "snd_complete"), "minecraft:entity.player.levelup"); + public static final IPropertyType SOUND_UNLOCK = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "snd_unlock"), + "minecraft:ui.button.click"); + public static final IPropertyType SOUND_UPDATE = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "snd_update"), + "minecraft:entity.player.levelup"); + public static final IPropertyType SOUND_COMPLETE = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "snd_complete"), + "minecraft:entity.player.levelup"); - public static final IPropertyType ICON = new PropertyTypeItemStack(new ResourceLocation(ModReference.MODID, "icon"), new BigItemStack(Items.NETHER_STAR)); - //public static final IPropertyType FRAME = new PropertyTypeString(new ResourceLocation(ModReference.MODID,"frame"), ""); + public static final IPropertyType ICON = new PropertyTypeItemStack(new ResourceLocation(ModReference.MODID, "icon"), + new BigItemStack(Items.NETHER_STAR)); + public static final IPropertyType FRAME = new PropertyTypeEnum<>(new ResourceLocation(ModReference.MODID, "frame"), EnumFrameType.DEFAULT); public static final IPropertyType BG_IMAGE = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "bg_image"), ""); public static final IPropertyType BG_SIZE = new PropertyTypeInteger(new ResourceLocation(ModReference.MODID, "bg_size"), 256); @@ -53,7 +65,9 @@ public class NativeProps { public static final IPropertyType LIVES_DEF = new PropertyTypeInteger(new ResourceLocation(ModReference.MODID, "livesDef"), 3); public static final IPropertyType LIVES_MAX = new PropertyTypeInteger(new ResourceLocation(ModReference.MODID, "livesMax"), 10); - public static final IPropertyType HOME_IMAGE = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "home_image"), new ResourceLocation(ModReference.MODID, "textures/gui/default_title.png").toString()); + public static final IPropertyType HOME_IMAGE = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "home_image"), + new ResourceLocation(ModReference.MODID, "textures/gui/default_title.png") + .toString()); public static final IPropertyType HOME_ANC_X = new PropertyTypeFloat(new ResourceLocation(ModReference.MODID, "home_anchor_x"), 0.5F); public static final IPropertyType HOME_ANC_Y = new PropertyTypeFloat(new ResourceLocation(ModReference.MODID, "home_anchor_y"), 0F); public static final IPropertyType HOME_OFF_X = new PropertyTypeInteger(new ResourceLocation(ModReference.MODID, "home_offset_x"), -128); @@ -72,4 +86,5 @@ private static EnumQuestVisibility findVisibility() { return EnumQuestVisibility.NORMAL; } -} \ No newline at end of file + +} diff --git a/src/main/java/betterquesting/api2/client/gui/controls/PanelButtonQuest.java b/src/main/java/betterquesting/api2/client/gui/controls/PanelButtonQuest.java index 2ab6f5ec1..860526f04 100644 --- a/src/main/java/betterquesting/api2/client/gui/controls/PanelButtonQuest.java +++ b/src/main/java/betterquesting/api2/client/gui/controls/PanelButtonQuest.java @@ -2,6 +2,7 @@ import betterquesting.api.api.ApiReference; import betterquesting.api.api.QuestingAPI; +import betterquesting.api.enums.EnumFrameType; import betterquesting.api.enums.EnumQuestState; import betterquesting.api.properties.NativeProps; import betterquesting.api.questing.IQuest; @@ -43,33 +44,25 @@ public PanelButtonQuest(GuiRectangle rect, int id, String txt, DBEntry v player = Minecraft.getMinecraft().player; EnumQuestState qState = value == null ? EnumQuestState.LOCKED : value.getValue().getState(player); IGuiColor txIconCol = null; - boolean main = value == null ? false : value.getValue().getProperty(NativeProps.MAIN); boolean lock = false; - switch (qState) { - case LOCKED: - txFrame = main ? PresetTexture.QUEST_MAIN_0.getTexture() : PresetTexture.QUEST_NORM_0.getTexture(); - txIconCol = PresetColor.QUEST_ICON_LOCKED.getColor(); - lock = true; - break; - case UNLOCKED: - txFrame = main ? PresetTexture.QUEST_MAIN_1.getTexture() : PresetTexture.QUEST_NORM_1.getTexture(); - txIconCol = PresetColor.QUEST_ICON_UNLOCKED.getColor(); - break; - case UNCLAIMED: - txFrame = main ? PresetTexture.QUEST_MAIN_2.getTexture() : PresetTexture.QUEST_NORM_2.getTexture(); - txIconCol = PresetColor.QUEST_ICON_PENDING.getColor(); - break; - case COMPLETED: - txFrame = main ? PresetTexture.QUEST_MAIN_3.getTexture() : PresetTexture.QUEST_NORM_3.getTexture(); - txIconCol = PresetColor.QUEST_ICON_COMPLETE.getColor(); - break; - case REPEATABLE: - txFrame = main ? PresetTexture.QUEST_MAIN_4.getTexture() : PresetTexture.QUEST_NORM_4.getTexture(); - txIconCol = PresetColor.QUEST_ICON_REPEATABLE.getColor(); - break; - default: - txFrame = null; + if (value != null) { + if (value.getValue().getProperty(NativeProps.FRAME) == EnumFrameType.DEFAULT) { + boolean isMain = value.getValue().getProperty(NativeProps.MAIN); + txFrame = PresetTexture.getNormalQuestFrameTexture(qState, isMain); + txIconCol = qState.getColor(); + if (qState == EnumQuestState.LOCKED) + lock = true; + } else { + txFrame = PresetTexture.getExtraQuestFrameTexture(value.getValue().getProperty(NativeProps.FRAME), qState); + txIconCol = qState.getColor(); + if (qState == EnumQuestState.LOCKED) + lock = true; + } + } else { + txFrame = PresetTexture.QUEST_NORM_0.getTexture(); + txIconCol = PresetColor.QUEST_ICON_LOCKED.getColor(); + lock = true; } IGuiTexture btnTx = new GuiTextureColored(txFrame, txIconCol); diff --git a/src/main/java/betterquesting/api2/client/gui/panels/content/PanelQuestFrame.java b/src/main/java/betterquesting/api2/client/gui/panels/content/PanelQuestFrame.java new file mode 100644 index 000000000..3df1aadc1 --- /dev/null +++ b/src/main/java/betterquesting/api2/client/gui/panels/content/PanelQuestFrame.java @@ -0,0 +1,67 @@ +package betterquesting.api2.client.gui.panels.content; + +import betterquesting.api.enums.EnumFrameType; +import betterquesting.api.enums.EnumQuestState; +import betterquesting.api2.client.gui.controls.PanelButtonStorage; +import betterquesting.api2.client.gui.misc.GuiPadding; +import betterquesting.api2.client.gui.misc.IGuiRect; +import betterquesting.api2.client.gui.resources.textures.ColorTexture; +import betterquesting.api2.client.gui.resources.textures.GuiTextureColored; +import betterquesting.api2.client.gui.resources.textures.LayeredTexture; +import betterquesting.api2.client.gui.themes.presets.PresetColor; +import betterquesting.api2.client.gui.themes.presets.PresetTexture; + +public class PanelQuestFrame extends PanelButtonStorage { + + private EnumQuestState questState = EnumQuestState.LOCKED; + + public PanelQuestFrame(IGuiRect rect, int id, EnumFrameType value) { + super(rect, id, "", value); + + this.setTextures(PresetTexture.ITEM_FRAME.getTexture(), + PresetTexture.ITEM_FRAME.getTexture(), + new LayeredTexture(PresetTexture.ITEM_FRAME.getTexture(), + new ColorTexture(PresetColor.ITEM_HIGHLIGHT.getColor(), new GuiPadding(1, 1, 1, 1)))); + + setStoredValue(value); + } + + @Override + public PanelQuestFrame setStoredValue(EnumFrameType value) { + super.setStoredValue(value); + + if (value == EnumFrameType.DEFAULT) + this.setIcon(null); + else if (value != null && questState != null) + this.setIcon(new GuiTextureColored(PresetTexture.getExtraQuestFrameTexture(value, questState), questState.getColor()), 1); + else + this.setIcon(null); + this.setTooltip(null); + + return this; + } + + public void setQuestState(EnumQuestState questState) { + this.questState = questState; + EnumFrameType frameType = getStoredValue(); + if (frameType == EnumFrameType.DEFAULT) + this.setIcon(null); + else if (frameType != null && questState != null) + this.setIcon(new GuiTextureColored(PresetTexture.getExtraQuestFrameTexture(frameType, questState), questState.getColor()), 1); + else + this.setIcon(null); + } + + @Override + public void onButtonClick() { + if (getCallback() != null) + getCallback().setValue(getStoredValue()); + } + + @Override + public void onRightButtonClick() { + if (getCallback() != null) + getCallback().setValue(getStoredValue()); + } + +} diff --git a/src/main/java/betterquesting/api2/client/gui/panels/lists/CanvasQuestFrame.java b/src/main/java/betterquesting/api2/client/gui/panels/lists/CanvasQuestFrame.java new file mode 100644 index 000000000..462f74715 --- /dev/null +++ b/src/main/java/betterquesting/api2/client/gui/panels/lists/CanvasQuestFrame.java @@ -0,0 +1,54 @@ +package betterquesting.api2.client.gui.panels.lists; + +import betterquesting.api.enums.EnumFrameType; +import betterquesting.api.enums.EnumQuestState; +import betterquesting.api2.client.gui.misc.GuiRectangle; +import betterquesting.api2.client.gui.misc.IGuiRect; +import betterquesting.api2.client.gui.panels.IGuiPanel; +import betterquesting.api2.client.gui.panels.content.PanelQuestFrame; + +public class CanvasQuestFrame extends CanvasScrolling { + + private int resultWidth = 256; // Used for organising ongoing search results even if the size changes midway + + private final int btnId; + + public CanvasQuestFrame(IGuiRect rect, int buttonId) { + super(rect); + + this.btnId = buttonId; + } + + public void setQuestState(EnumQuestState questState) { + for (IGuiPanel panel : getChildren()) { + ((PanelQuestFrame) panel).setQuestState(questState); + } + } + + @Override + public void initPanel() { + super.initPanel(); + resetCanvas(); + this.resultWidth = this.getTransform().getWidth(); + updateResults(); + } + + @Override + public void drawPanel(int mx, int my, float partialTick) { + // updateResults(); + super.drawPanel(mx, my, partialTick); + } + + private void updateResults() { + EnumFrameType[] values = EnumFrameType.values(); + for (int i = 0; i < values.length; i++) { + EnumFrameType frameType = values[i]; + int x = (i % (resultWidth / 18)) * 18; + int y = (i / (resultWidth / 18)) * 18; + + this.addPanel(new PanelQuestFrame(new GuiRectangle(x, y, 18, 18, 0), btnId, frameType)); + } + + } + +} diff --git a/src/main/java/betterquesting/api2/client/gui/themes/presets/PresetIcon.java b/src/main/java/betterquesting/api2/client/gui/themes/presets/PresetIcon.java index f91329277..e61590689 100644 --- a/src/main/java/betterquesting/api2/client/gui/themes/presets/PresetIcon.java +++ b/src/main/java/betterquesting/api2/client/gui/themes/presets/PresetIcon.java @@ -44,6 +44,7 @@ public enum PresetIcon { ICON_REFRESH("icon_refresh"), ICON_ITEM("icon_item"), ICON_SCALE("icon_scale"), + ICON_CHANGE_FRAME("icon_change_frame"), ICON_EXIT("icon_exit"), ICON_NOTICE("icon_notice"), @@ -146,6 +147,7 @@ public static void registerIcons(IThemeRegistry reg) { reg.setDefaultTexture(ICON_REFRESH.key, new SimpleTexture(TX_ICONS, new GuiRectangle(128, 16, 16, 16)).maintainAspect(true)); reg.setDefaultTexture(ICON_ITEM.key, new SimpleTexture(TX_ICONS, new GuiRectangle(144, 0, 16, 16)).maintainAspect(true)); reg.setDefaultTexture(ICON_SCALE.key, new SimpleTexture(TX_ICONS, new GuiRectangle(144, 16, 16, 16)).maintainAspect(true)); + reg.setDefaultTexture(ICON_CHANGE_FRAME.key, new SimpleTexture(TX_ICONS, new GuiRectangle(240, 80, 16, 16)).maintainAspect(true)); reg.setDefaultTexture(ICON_EXIT.key, new SimpleTexture(TX_ICONS, new GuiRectangle(160, 0, 16, 16)).maintainAspect(true)); reg.setDefaultTexture(ICON_NOTICE.key, new SimpleTexture(TX_ICONS, new GuiRectangle(176, 0, 16, 16)).maintainAspect(true)); reg.setDefaultTexture(ICON_PARTY.key, new SimpleTexture(TX_ICONS, new GuiRectangle(192, 0, 16, 16)).maintainAspect(true)); diff --git a/src/main/java/betterquesting/api2/client/gui/themes/presets/PresetTexture.java b/src/main/java/betterquesting/api2/client/gui/themes/presets/PresetTexture.java index cf0d5de93..7ecbb5068 100644 --- a/src/main/java/betterquesting/api2/client/gui/themes/presets/PresetTexture.java +++ b/src/main/java/betterquesting/api2/client/gui/themes/presets/PresetTexture.java @@ -1,5 +1,9 @@ package betterquesting.api2.client.gui.themes.presets; +import java.util.Locale; + +import betterquesting.api.enums.EnumFrameType; +import betterquesting.api.enums.EnumQuestState; import betterquesting.api2.client.gui.misc.GuiPadding; import betterquesting.api2.client.gui.misc.GuiRectangle; import betterquesting.api2.client.gui.resources.textures.IGuiTexture; @@ -11,6 +15,7 @@ import net.minecraft.util.ResourceLocation; public enum PresetTexture { + PANEL_MAIN("panel_main"), PANEL_DARK("panel_dark"), PANEL_INNER("panel_inner"), @@ -64,13 +69,6 @@ public enum PresetTexture { QUEST_MAIN_3("quest_main_3"), QUEST_MAIN_4("quest_main_4"), - // Auxiliary quest frame (not normally used) - QUEST_AUX_0("quest_aux_0"), - QUEST_AUX_1("quest_aux_1"), - QUEST_AUX_2("quest_aux_2"), - QUEST_AUX_3("quest_aux_3"), - QUEST_AUX_4("quest_aux_4"), - TEXT_BOX_0("text_box_0"), TEXT_BOX_1("text_box_1"), TEXT_BOX_2("text_box_2"), @@ -87,13 +85,9 @@ public enum PresetTexture { this.key = new ResourceLocation(ModReference.MODID, key); } - public IGuiTexture getTexture() { - return ThemeRegistry.INSTANCE.getTexture(this.key); - } + public IGuiTexture getTexture() { return ThemeRegistry.INSTANCE.getTexture(this.key); } - public ResourceLocation getKey() { - return this.key; - } + public ResourceLocation getKey() { return this.key; } public static void registerTextures(IThemeRegistry reg) { reg.setDefaultTexture(PANEL_MAIN.key, new SlicedTexture(TX_SIMPLE, new GuiRectangle(0, 0, 12, 12), new GuiPadding(4, 4, 4, 4))); @@ -135,28 +129,86 @@ public static void registerTextures(IThemeRegistry reg) { reg.setDefaultTexture(METER_H_0.key, new SlicedTexture(TX_SIMPLE, new GuiRectangle(48, 12, 8, 8), new GuiPadding(3, 3, 3, 3))); reg.setDefaultTexture(METER_H_1.key, new SlicedTexture(TX_SIMPLE, new GuiRectangle(56, 12, 8, 8), new GuiPadding(3, 3, 3, 3))); - reg.setDefaultTexture(QUEST_NORM_0.key, new SlicedTexture(TX_QUEST, new GuiRectangle(0, 0, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.SLICED_STRETCH)); - reg.setDefaultTexture(QUEST_NORM_1.key, new SlicedTexture(TX_QUEST, new GuiRectangle(0, 24, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.SLICED_STRETCH)); - reg.setDefaultTexture(QUEST_NORM_2.key, new SlicedTexture(TX_QUEST, new GuiRectangle(0, 48, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.SLICED_STRETCH)); - reg.setDefaultTexture(QUEST_NORM_3.key, new SlicedTexture(TX_QUEST, new GuiRectangle(0, 72, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.SLICED_STRETCH)); - reg.setDefaultTexture(QUEST_NORM_4.key, new SlicedTexture(TX_QUEST, new GuiRectangle(0, 72, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.SLICED_STRETCH)); - - reg.setDefaultTexture(QUEST_MAIN_0.key, new SlicedTexture(TX_QUEST, new GuiRectangle(24, 0, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.STRETCH)); - reg.setDefaultTexture(QUEST_MAIN_1.key, new SlicedTexture(TX_QUEST, new GuiRectangle(24, 24, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.STRETCH)); - reg.setDefaultTexture(QUEST_MAIN_2.key, new SlicedTexture(TX_QUEST, new GuiRectangle(24, 48, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.STRETCH)); - reg.setDefaultTexture(QUEST_MAIN_3.key, new SlicedTexture(TX_QUEST, new GuiRectangle(24, 72, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.STRETCH)); - reg.setDefaultTexture(QUEST_MAIN_4.key, new SlicedTexture(TX_QUEST, new GuiRectangle(24, 72, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.STRETCH)); - - reg.setDefaultTexture(QUEST_AUX_0.key, new SlicedTexture(TX_QUEST, new GuiRectangle(48, 0, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.SLICED_STRETCH)); - reg.setDefaultTexture(QUEST_AUX_1.key, new SlicedTexture(TX_QUEST, new GuiRectangle(48, 24, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.SLICED_STRETCH)); - reg.setDefaultTexture(QUEST_AUX_2.key, new SlicedTexture(TX_QUEST, new GuiRectangle(48, 48, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.SLICED_STRETCH)); - reg.setDefaultTexture(QUEST_AUX_3.key, new SlicedTexture(TX_QUEST, new GuiRectangle(48, 72, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.SLICED_STRETCH)); - reg.setDefaultTexture(QUEST_AUX_4.key, new SlicedTexture(TX_QUEST, new GuiRectangle(48, 72, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.SLICED_STRETCH)); - - reg.setDefaultTexture(TEXT_BOX_0.key, new SlicedTexture(TX_SIMPLE, new GuiRectangle(0, 28, 8, 8), new GuiPadding(1, 1, 1, 1)).setSliceMode(SliceMode.SLICED_STRETCH)); - reg.setDefaultTexture(TEXT_BOX_1.key, new SlicedTexture(TX_SIMPLE, new GuiRectangle(8, 28, 8, 8), new GuiPadding(1, 1, 1, 1)).setSliceMode(SliceMode.SLICED_STRETCH)); - reg.setDefaultTexture(TEXT_BOX_2.key, new SlicedTexture(TX_SIMPLE, new GuiRectangle(16, 28, 8, 8), new GuiPadding(1, 1, 1, 1)).setSliceMode(SliceMode.SLICED_STRETCH)); - - reg.setDefaultTexture(TOOLTIP_BG.key, new SlicedTexture(TX_SIMPLE, new GuiRectangle(204, 0, 12, 12), new GuiPadding(2, 2, 2, 2)).setSliceMode(SliceMode.SLICED_STRETCH)); + reg.setDefaultTexture(QUEST_NORM_0.key, + new SlicedTexture(TX_QUEST, new GuiRectangle(0, 0, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.SLICED_STRETCH)); + reg.setDefaultTexture(QUEST_NORM_1.key, + new SlicedTexture(TX_QUEST, new GuiRectangle(0, 24, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.SLICED_STRETCH)); + reg.setDefaultTexture(QUEST_NORM_2.key, + new SlicedTexture(TX_QUEST, new GuiRectangle(0, 48, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.SLICED_STRETCH)); + reg.setDefaultTexture(QUEST_NORM_3.key, + new SlicedTexture(TX_QUEST, new GuiRectangle(0, 72, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.SLICED_STRETCH)); + reg.setDefaultTexture(QUEST_NORM_4.key, + new SlicedTexture(TX_QUEST, new GuiRectangle(0, 72, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.SLICED_STRETCH)); + + reg.setDefaultTexture(QUEST_MAIN_0.key, + new SlicedTexture(TX_QUEST, new GuiRectangle(24, 0, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.STRETCH)); + reg.setDefaultTexture(QUEST_MAIN_1.key, + new SlicedTexture(TX_QUEST, new GuiRectangle(24, 24, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.STRETCH)); + reg.setDefaultTexture(QUEST_MAIN_2.key, + new SlicedTexture(TX_QUEST, new GuiRectangle(24, 48, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.STRETCH)); + reg.setDefaultTexture(QUEST_MAIN_3.key, + new SlicedTexture(TX_QUEST, new GuiRectangle(24, 72, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.STRETCH)); + reg.setDefaultTexture(QUEST_MAIN_4.key, + new SlicedTexture(TX_QUEST, new GuiRectangle(24, 72, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode(SliceMode.STRETCH)); + + { + int idx = 0; + for (EnumFrameType frameType : EnumFrameType.values()) { + if (frameType == EnumFrameType.DEFAULT) + continue; + for (EnumQuestState questState : EnumQuestState.values()) { + ResourceLocation id = getExtraQuestFrameTextureId(frameType, questState); + ResourceLocation fileLocation = new ResourceLocation(ModReference.MODID, "textures/gui/ex_frames.png"); + int x = (idx % 10) * 24; + int y = (idx / 10) * 24; + reg.setDefaultTexture(id, + new SlicedTexture(fileLocation, new GuiRectangle(x, y, 24, 24), new GuiPadding(8, 8, 8, 8)).setSliceMode( + SliceMode.STRETCH)); + } + idx++; + } + } + + reg.setDefaultTexture(TEXT_BOX_0.key, + new SlicedTexture(TX_SIMPLE, new GuiRectangle(0, 28, 8, 8), new GuiPadding(1, 1, 1, 1)).setSliceMode(SliceMode.SLICED_STRETCH)); + reg.setDefaultTexture(TEXT_BOX_1.key, + new SlicedTexture(TX_SIMPLE, new GuiRectangle(8, 28, 8, 8), new GuiPadding(1, 1, 1, 1)).setSliceMode(SliceMode.SLICED_STRETCH)); + reg.setDefaultTexture(TEXT_BOX_2.key, + new SlicedTexture(TX_SIMPLE, new GuiRectangle(16, 28, 8, 8), new GuiPadding(1, 1, 1, 1)).setSliceMode(SliceMode.SLICED_STRETCH)); + + reg.setDefaultTexture(TOOLTIP_BG.key, + new SlicedTexture(TX_SIMPLE, new GuiRectangle(204, 0, 12, 12), new GuiPadding(2, 2, 2, 2)).setSliceMode( + SliceMode.SLICED_STRETCH)); + } + + public static ResourceLocation getExtraQuestFrameTextureId(EnumFrameType frameType, EnumQuestState questState) { + return new ResourceLocation(ModReference.MODID, + "quest_ex_" + frameType.name().toLowerCase(Locale.ROOT) + "_" + questState.name().toLowerCase(Locale.ROOT)); + } + + public static IGuiTexture getExtraQuestFrameTexture(EnumFrameType frameType, EnumQuestState questState) { + return ThemeRegistry.INSTANCE.getTexture(getExtraQuestFrameTextureId(frameType, questState)); } + + public static IGuiTexture getNormalQuestFrameTexture(EnumQuestState questState, boolean isMain) { + switch (questState) { + case LOCKED -> { + return isMain ? PresetTexture.QUEST_MAIN_0.getTexture() : PresetTexture.QUEST_NORM_0.getTexture(); + } + case UNLOCKED -> { + return isMain ? PresetTexture.QUEST_MAIN_1.getTexture() : PresetTexture.QUEST_NORM_1.getTexture(); + } + case UNCLAIMED -> { + return isMain ? PresetTexture.QUEST_MAIN_2.getTexture() : PresetTexture.QUEST_NORM_2.getTexture(); + } + case COMPLETED -> { + return isMain ? PresetTexture.QUEST_MAIN_3.getTexture() : PresetTexture.QUEST_NORM_3.getTexture(); + } + case REPEATABLE -> { + return isMain ? PresetTexture.QUEST_MAIN_4.getTexture() : PresetTexture.QUEST_NORM_4.getTexture(); + } + default -> throw new IllegalStateException("Unexpected value: " + questState); + } + } + } diff --git a/src/main/java/betterquesting/client/gui2/GuiThemes.java b/src/main/java/betterquesting/client/gui2/GuiThemes.java index db3821eed..ff23208f7 100644 --- a/src/main/java/betterquesting/client/gui2/GuiThemes.java +++ b/src/main/java/betterquesting/client/gui2/GuiThemes.java @@ -1,10 +1,18 @@ package betterquesting.client.gui2; +import java.util.List; + +import org.lwjgl.util.vector.Vector4f; + import betterquesting.api.utils.BigItemStack; import betterquesting.api2.client.gui.GuiScreenCanvas; import betterquesting.api2.client.gui.controls.PanelButton; import betterquesting.api2.client.gui.controls.PanelButtonStorage; -import betterquesting.api2.client.gui.misc.*; +import betterquesting.api2.client.gui.misc.GuiAlign; +import betterquesting.api2.client.gui.misc.GuiPadding; +import betterquesting.api2.client.gui.misc.GuiRectangle; +import betterquesting.api2.client.gui.misc.GuiTransform; +import betterquesting.api2.client.gui.misc.IGuiRect; import betterquesting.api2.client.gui.panels.CanvasEmpty; import betterquesting.api2.client.gui.panels.CanvasTextured; import betterquesting.api2.client.gui.panels.bars.PanelVScrollBar; @@ -31,11 +39,9 @@ import betterquesting.core.BetterQuesting; import net.minecraft.client.gui.GuiScreen; import net.minecraft.util.ResourceLocation; -import org.lwjgl.util.vector.Vector4f; - -import java.util.List; public class GuiThemes extends GuiScreenCanvas { + // Last value of the scrollbar before loading new theme private PanelVScrollBar scrollPanel; @@ -55,11 +61,14 @@ public void initPanel() { CanvasEmpty inCan = new CanvasEmpty(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(16, 16, 16, 16), 0)); bgCan.addPanel(inCan); - PanelTextBox panTxt = new PanelTextBox(new GuiTransform(GuiAlign.TOP_EDGE, new GuiPadding(0, 0, 0, -16), 0), QuestTranslation.translate("betterquesting.title.select_theme")).setAlignment(1); + PanelTextBox panTxt = new PanelTextBox(new GuiTransform(GuiAlign.TOP_EDGE, new GuiPadding(0, 0, 0, -16), 0), + QuestTranslation.translate("betterquesting.title.select_theme")).setAlignment(1); panTxt.setColor(PresetColor.TEXT_HEADER.getColor()); inCan.addPanel(panTxt); - PanelButton btnExit = new PanelButton(new GuiTransform(GuiAlign.BOTTOM_CENTER, new GuiPadding(-100, -16, -100, 0), 0), 0, QuestTranslation.translate("gui.done")); + PanelButton btnExit = new PanelButton(new GuiTransform(GuiAlign.BOTTOM_CENTER, new GuiPadding(-100, -16, -100, 0), 0), + 0, + QuestTranslation.translate("gui.done")); btnExit.setClickAction((b) -> mc.displayGuiScreen(ThemeRegistry.INSTANCE.getGui(PresetGUIs.HOME, GArgsNone.NONE))); bgCan.addPanel(btnExit); @@ -98,48 +107,61 @@ public void initPanel() { CanvasEmpty preCan = new CanvasEmpty(new GuiTransform(GuiAlign.HALF_RIGHT, new GuiPadding(8, 16, 0, 16), 0)); inCan.addPanel(preCan); - CanvasTextured preCanIn0 = new CanvasTextured(new GuiTransform(new Vector4f(0F, 0F, 0.5F, 0.5F), new GuiPadding(0, 0, 0, 0), 0), PresetTexture.PANEL_MAIN.getTexture()); + CanvasTextured preCanIn0 = new CanvasTextured(new GuiTransform(new Vector4f(0F, 0F, 0.5F, 0.5F), new GuiPadding(0, 0, 0, 0), 0), + PresetTexture.PANEL_MAIN.getTexture()); preCan.addPanel(preCanIn0); - preCanIn0.addPanel(new PanelTextBox(new GuiTransform(GuiAlign.MID_CENTER, -32, -8, 64, 16, 0), "EXAMPLE").setAlignment(1).setColor(PresetColor.TEXT_MAIN.getColor())); + preCanIn0.addPanel(new PanelTextBox(new GuiTransform(GuiAlign.MID_CENTER, -32, -8, 64, 16, 0), "EXAMPLE").setAlignment(1) + .setColor(PresetColor.TEXT_MAIN.getColor())); - CanvasTextured preCanIn1 = new CanvasTextured(new GuiTransform(new Vector4f(0.5F, 0F, 1F, 0.5F), new GuiPadding(0, 0, 0, 0), 0), PresetTexture.PANEL_INNER.getTexture()); + CanvasTextured preCanIn1 = new CanvasTextured(new GuiTransform(new Vector4f(0.5F, 0F, 1F, 0.5F), new GuiPadding(0, 0, 0, 0), 0), + PresetTexture.PANEL_INNER.getTexture()); preCan.addPanel(preCanIn1); - preCanIn1.addPanel(new PanelTextBox(new GuiTransform(GuiAlign.MID_CENTER, -32, -8, 64, 16, 0), "EXAMPLE").setAlignment(1).setColor(PresetColor.TEXT_AUX_0.getColor())); + preCanIn1.addPanel(new PanelTextBox(new GuiTransform(GuiAlign.MID_CENTER, -32, -8, 64, 16, 0), "EXAMPLE").setAlignment(1) + .setColor(PresetColor.TEXT_AUX_0.getColor())); - CanvasTextured preCanIn2 = new CanvasTextured(new GuiTransform(GuiAlign.HALF_BOTTOM, new GuiPadding(0, 0, 0, 0), 0), PresetTexture.AUX_FRAME_0.getTexture()); + CanvasTextured preCanIn2 = new CanvasTextured(new GuiTransform(GuiAlign.HALF_BOTTOM, new GuiPadding(0, 0, 0, 0), 0), + PresetTexture.AUX_FRAME_0.getTexture()); preCan.addPanel(preCanIn2); IGuiTexture icoSlides = new SlideShowTexture(1F, - new GuiTextureColored(PresetTexture.QUEST_NORM_0.getTexture(), PresetColor.QUEST_ICON_LOCKED.getColor()), - new GuiTextureColored(PresetTexture.QUEST_NORM_1.getTexture(), PresetColor.QUEST_ICON_UNLOCKED.getColor()), - new GuiTextureColored(PresetTexture.QUEST_NORM_2.getTexture(), PresetColor.QUEST_ICON_PENDING.getColor()), - new GuiTextureColored(PresetTexture.QUEST_NORM_3.getTexture(), PresetColor.QUEST_ICON_COMPLETE.getColor()), - new GuiTextureColored(PresetTexture.QUEST_NORM_4.getTexture(), PresetColor.QUEST_ICON_REPEATABLE.getColor()), - new GuiTextureColored(PresetTexture.QUEST_MAIN_0.getTexture(), PresetColor.QUEST_ICON_LOCKED.getColor()), - new GuiTextureColored(PresetTexture.QUEST_MAIN_1.getTexture(), PresetColor.QUEST_ICON_UNLOCKED.getColor()), - new GuiTextureColored(PresetTexture.QUEST_MAIN_2.getTexture(), PresetColor.QUEST_ICON_PENDING.getColor()), - new GuiTextureColored(PresetTexture.QUEST_MAIN_3.getTexture(), PresetColor.QUEST_ICON_COMPLETE.getColor()), - new GuiTextureColored(PresetTexture.QUEST_MAIN_4.getTexture(), PresetColor.QUEST_ICON_REPEATABLE.getColor()), - new GuiTextureColored(PresetTexture.QUEST_AUX_0.getTexture(), PresetColor.QUEST_ICON_LOCKED.getColor()), - new GuiTextureColored(PresetTexture.QUEST_AUX_1.getTexture(), PresetColor.QUEST_ICON_UNLOCKED.getColor()), - new GuiTextureColored(PresetTexture.QUEST_AUX_2.getTexture(), PresetColor.QUEST_ICON_PENDING.getColor()), - new GuiTextureColored(PresetTexture.QUEST_AUX_3.getTexture(), PresetColor.QUEST_ICON_COMPLETE.getColor()), - new GuiTextureColored(PresetTexture.QUEST_AUX_4.getTexture(), PresetColor.QUEST_ICON_REPEATABLE.getColor())); + new GuiTextureColored(PresetTexture.QUEST_NORM_0.getTexture(), PresetColor.QUEST_ICON_LOCKED.getColor()), + new GuiTextureColored(PresetTexture.QUEST_NORM_1.getTexture(), PresetColor.QUEST_ICON_UNLOCKED.getColor()), + new GuiTextureColored(PresetTexture.QUEST_NORM_2.getTexture(), PresetColor.QUEST_ICON_PENDING.getColor()), + new GuiTextureColored(PresetTexture.QUEST_NORM_3.getTexture(), PresetColor.QUEST_ICON_COMPLETE.getColor()), + new GuiTextureColored(PresetTexture.QUEST_NORM_4.getTexture(), + PresetColor.QUEST_ICON_REPEATABLE.getColor()), + new GuiTextureColored(PresetTexture.QUEST_MAIN_0.getTexture(), PresetColor.QUEST_ICON_LOCKED.getColor()), + new GuiTextureColored(PresetTexture.QUEST_MAIN_1.getTexture(), PresetColor.QUEST_ICON_UNLOCKED.getColor()), + new GuiTextureColored(PresetTexture.QUEST_MAIN_2.getTexture(), PresetColor.QUEST_ICON_PENDING.getColor()), + new GuiTextureColored(PresetTexture.QUEST_MAIN_3.getTexture(), PresetColor.QUEST_ICON_COMPLETE.getColor()), + new GuiTextureColored(PresetTexture.QUEST_MAIN_4.getTexture(), + PresetColor.QUEST_ICON_REPEATABLE.getColor())); PanelGeneric pqp = new PanelGeneric(new GuiTransform(new Vector4f(0.25F, 0.5F, 0.25F, 0.5F), -12, -12, 24, 24, 0), icoSlides); preCanIn2.addPanel(pqp); - CanvasTextured itemFrame = new CanvasTextured(new GuiTransform(new Vector4f(0.75F, 0.5F, 0.75F, 0.5F), -12, -12, 24, 24, 0), PresetTexture.ITEM_FRAME.getTexture()); + CanvasTextured itemFrame = new CanvasTextured(new GuiTransform(new Vector4f(0.75F, 0.5F, 0.75F, 0.5F), -12, -12, 24, 24, 0), + PresetTexture.ITEM_FRAME.getTexture()); preCanIn2.addPanel(itemFrame); - itemFrame.addPanel(new PanelGeneric(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(1, 1, 1, 1), 0), new ItemTexture(new BigItemStack(BetterQuesting.guideBook, 9999, 0), true, true))); - - IGuiLine linSeq = new GuiLineSequence(1F, PresetLine.QUEST_LOCKED.getLine(), PresetLine.QUEST_UNLOCKED.getLine(), PresetLine.QUEST_PENDING.getLine(), PresetLine.QUEST_COMPLETE.getLine()); - IGuiColor colSeq = new GuiColorSequence(1F, PresetColor.QUEST_LINE_LOCKED.getColor(), PresetColor.QUEST_LINE_UNLOCKED.getColor(), PresetColor.QUEST_LINE_PENDING.getColor(), PresetColor.QUEST_LINE_COMPLETE.getColor()); + itemFrame.addPanel(new PanelGeneric(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(1, 1, 1, 1), 0), + new ItemTexture(new BigItemStack(BetterQuesting.guideBook, 9999, 0), true, true))); + + IGuiLine linSeq = new GuiLineSequence(1F, + PresetLine.QUEST_LOCKED.getLine(), + PresetLine.QUEST_UNLOCKED.getLine(), + PresetLine.QUEST_PENDING.getLine(), + PresetLine.QUEST_COMPLETE.getLine()); + IGuiColor colSeq = new GuiColorSequence(1F, + PresetColor.QUEST_LINE_LOCKED.getColor(), + PresetColor.QUEST_LINE_UNLOCKED.getColor(), + PresetColor.QUEST_LINE_PENDING.getColor(), + PresetColor.QUEST_LINE_COMPLETE.getColor()); preCanIn2.addPanel(new PanelLine(pqp.getTransform(), itemFrame.getTransform(), linSeq, 4, colSeq, 1)); - preCanIn2.addPanel(new PanelTextBox(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(8, 8, 8, 8), 0), "EXAMPLE").setAlignment(1).setColor(PresetColor.TEXT_AUX_1.getColor())); + preCanIn2.addPanel(new PanelTextBox(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(8, 8, 8, 8), 0), "EXAMPLE").setAlignment(1) + .setColor(PresetColor.TEXT_AUX_1.getColor())); IGuiRect ls0 = new GuiTransform(GuiAlign.TOP_CENTER, 0, 16, 0, 0, 0); ls0.setParent(inCan.getTransform()); @@ -148,4 +170,5 @@ public void initPanel() { PanelLine paLine0 = new PanelLine(ls0, le0, PresetLine.GUI_DIVIDER.getLine(), 1, PresetColor.GUI_DIVIDER.getColor(), 1); inCan.addPanel(paLine0); } + } diff --git a/src/main/java/betterquesting/client/gui2/editors/nbt/GuiQuestFrameSelection.java b/src/main/java/betterquesting/client/gui2/editors/nbt/GuiQuestFrameSelection.java new file mode 100644 index 000000000..dd7dce4ec --- /dev/null +++ b/src/main/java/betterquesting/client/gui2/editors/nbt/GuiQuestFrameSelection.java @@ -0,0 +1,195 @@ +package betterquesting.client.gui2.editors.nbt; + +import org.lwjgl.input.Keyboard; +import org.lwjgl.util.vector.Vector4f; + +import betterquesting.api.client.gui.misc.IVolatileScreen; +import betterquesting.api.enums.EnumFrameType; +import betterquesting.api.enums.EnumQuestState; +import betterquesting.api.misc.ICallback; +import betterquesting.api.utils.BigItemStack; +import betterquesting.api2.client.gui.GuiScreenCanvas; +import betterquesting.api2.client.gui.controls.IPanelButton; +import betterquesting.api2.client.gui.controls.PanelButton; +import betterquesting.api2.client.gui.controls.PanelButtonStorage; +import betterquesting.api2.client.gui.events.IPEventListener; +import betterquesting.api2.client.gui.events.PEventBroadcaster; +import betterquesting.api2.client.gui.events.PanelEvent; +import betterquesting.api2.client.gui.events.types.PEventButton; +import betterquesting.api2.client.gui.misc.GuiAlign; +import betterquesting.api2.client.gui.misc.GuiPadding; +import betterquesting.api2.client.gui.misc.GuiTransform; +import betterquesting.api2.client.gui.misc.IGuiRect; +import betterquesting.api2.client.gui.panels.CanvasEmpty; +import betterquesting.api2.client.gui.panels.CanvasTextured; +import betterquesting.api2.client.gui.panels.bars.PanelVScrollBar; +import betterquesting.api2.client.gui.panels.content.PanelTextBox; +import betterquesting.api2.client.gui.panels.lists.CanvasQuestFrame; +import betterquesting.api2.client.gui.resources.textures.GuiTextureColored; +import betterquesting.api2.client.gui.resources.textures.IGuiTexture; +import betterquesting.api2.client.gui.resources.textures.ItemTexture; +import betterquesting.api2.client.gui.themes.presets.PresetColor; +import betterquesting.api2.client.gui.themes.presets.PresetTexture; +import betterquesting.api2.utils.QuestTranslation; +import net.minecraft.client.gui.GuiScreen; + +@SuppressWarnings("WeakerAccess") +public class GuiQuestFrameSelection extends GuiScreenCanvas implements IPEventListener, IVolatileScreen { + + private final ICallback callback; + private final BigItemStack itemStack; + private final boolean isMain; + private final PanelButtonStorage[] questStateButtons = new PanelButtonStorage[EnumQuestState.values().length]; + private EnumFrameType frameType; + private EnumQuestState questState = EnumQuestState.LOCKED; + + private PanelQuest itemPreview; + private CanvasQuestFrame cvQuestFrame; + + public GuiQuestFrameSelection(GuiScreen parent, EnumFrameType frameType, BigItemStack itemStack, ICallback callback, boolean isMain) { + super(parent); + this.frameType = frameType; + this.itemStack = itemStack; + this.callback = callback; + this.isMain = isMain; + } + + public void initPanel() { + super.initPanel(); + + PEventBroadcaster.INSTANCE.register(this, PEventButton.class); + Keyboard.enableRepeatEvents(true); + + // Background panel + CanvasTextured cvBackground = new CanvasTextured(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(0, 0, 0, 0), 0), + PresetTexture.PANEL_MAIN.getTexture()); + this.addPanel(cvBackground); + + cvBackground.addPanel(new PanelButton(new GuiTransform(GuiAlign.BOTTOM_CENTER, -100, -16, 200, 16, 0), 0, QuestTranslation.translate("gui.done"))); + + PanelTextBox txTitle = new PanelTextBox(new GuiTransform(GuiAlign.TOP_EDGE, new GuiPadding(0, 16, 0, -32), 0), + QuestTranslation.translate("betterquesting.title.select_item")).setAlignment(1); + txTitle.setColor(PresetColor.TEXT_HEADER.getColor()); + cvBackground.addPanel(txTitle); + + // === LEFT PANEL === + + CanvasEmpty cvLeft = new CanvasEmpty(new GuiTransform(new Vector4f(0F, 0F, 0.2F, 1F), new GuiPadding(16, 32, 8, 8), 0)); + cvBackground.addPanel(cvLeft); + + PanelTextBox txSelection = new PanelTextBox(new GuiTransform(GuiAlign.TOP_EDGE, new GuiPadding(0, 0, 0, -16), 0), + QuestTranslation.translate("betterquesting.gui.selection")); + txSelection.setColor(PresetColor.TEXT_MAIN.getColor()); + cvLeft.addPanel(txSelection); + + itemPreview = new PanelQuest(new GuiTransform(GuiAlign.TOP_LEFT, 0, 16, 36, 36, 0), 99, itemStack, frameType, questState, isMain); + cvLeft.addPanel(itemPreview); + + EnumQuestState[] values = EnumQuestState.values(); + for (int i = 0; i < values.length; i++) { + EnumQuestState value = values[i]; + PanelButtonStorage btn = new PanelButtonStorage<>(new GuiTransform(GuiAlign.TOP_LEFT, 10, 64 + i * 16, 80, 16, 0), + 2, + value.toString(), + value); + cvLeft.addPanel(btn); + questStateButtons[i] = btn; + } + updateButtonState(); + + // === RIGHT PANEL === + + CanvasEmpty cvRight = new CanvasEmpty(new GuiTransform(new Vector4f(0.3F, 0F, 1F, 1F), new GuiPadding(8, 32, 16, 32), 0)); + cvBackground.addPanel(cvRight); + + cvQuestFrame = new CanvasQuestFrame(new GuiTransform(GuiAlign.FULL_BOX, new GuiPadding(0, 16, 8, 0), 0), 1); + cvRight.addPanel(cvQuestFrame); + + PanelVScrollBar scEdit = new PanelVScrollBar(new GuiTransform(GuiAlign.RIGHT_EDGE, new GuiPadding(-8, 16, 0, 0), 0)); + cvQuestFrame.setScrollDriverY(scEdit); + cvRight.addPanel(scEdit); + + } + + @Override + public void onPanelEvent(PanelEvent event) { + if (event instanceof PEventButton) { + onButtonPress((PEventButton) event); + } + } + + @SuppressWarnings("unchecked") + private void onButtonPress(PEventButton event) { + IPanelButton btn = event.getButton(); + + if (btn.getButtonID() == 0) // Exit + { + if (callback != null) { + callback.setValue(frameType); + } + + mc.displayGuiScreen(this.parent); + } else if (btn.getButtonID() == 1 && btn instanceof PanelButtonStorage) { + EnumFrameType tmp = ((PanelButtonStorage) btn).getStoredValue(); + + if (tmp != null) { + frameType = tmp; + itemPreview.setFrameType(frameType); + } + } else if (btn.getButtonID() == 2 && btn instanceof PanelButtonStorage) { + EnumQuestState tmp = ((PanelButtonStorage) btn).getStoredValue(); + + if (tmp != null) { + questState = tmp; + itemPreview.setQuestState(questState); + cvQuestFrame.setQuestState(questState); + updateButtonState(); + } + } + } + + private void updateButtonState() { + for (PanelButtonStorage btn : questStateButtons) { + btn.setActive(btn.getStoredValue() != questState); + } + } + + private static class PanelQuest extends PanelButton { + + private final boolean isMain; + private EnumFrameType frameType; + private EnumQuestState questState; + + public PanelQuest(IGuiRect rect, int id, BigItemStack itemStack, EnumFrameType frameType, EnumQuestState questState, boolean isMain) { + super(rect, id, ""); + this.frameType = frameType; + this.questState = questState; + this.isMain = isMain; + + updateTexture(); + setIcon(new ItemTexture(itemStack, false, true), 6); + setActive(true); + } + + public void setFrameType(EnumFrameType frameType) { + this.frameType = frameType; + updateTexture(); + } + + public void setQuestState(EnumQuestState questState) { + this.questState = questState; + updateTexture(); + } + + private void updateTexture() { + IGuiTexture texture; + if (frameType == EnumFrameType.DEFAULT) + texture = new GuiTextureColored(PresetTexture.getNormalQuestFrameTexture(questState, isMain), questState.getColor()); + else + texture = new GuiTextureColored(PresetTexture.getExtraQuestFrameTexture(frameType, questState), questState.getColor()); + setTextures(texture, texture, texture); + } + + } + +} diff --git a/src/main/java/betterquesting/client/toolbox/PanelTabMain.java b/src/main/java/betterquesting/client/toolbox/PanelTabMain.java index 80b82971f..999a3a169 100644 --- a/src/main/java/betterquesting/client/toolbox/PanelTabMain.java +++ b/src/main/java/betterquesting/client/toolbox/PanelTabMain.java @@ -1,5 +1,8 @@ package betterquesting.client.toolbox; +import java.util.ArrayList; +import java.util.List; + import betterquesting.api.client.toolbox.IToolboxTool; import betterquesting.api2.client.gui.controls.PanelButton; import betterquesting.api2.client.gui.controls.PanelButtonStorage; @@ -14,7 +17,19 @@ import betterquesting.api2.utils.QuestTranslation; import betterquesting.client.gui2.editors.designer.PanelToolController; import betterquesting.client.gui2.editors.nbt.GuiNbtEditor; -import betterquesting.client.toolbox.tools.*; +import betterquesting.client.toolbox.tools.ToolboxToolComplete; +import betterquesting.client.toolbox.tools.ToolboxToolCopy; +import betterquesting.client.toolbox.tools.ToolboxToolDelete; +import betterquesting.client.toolbox.tools.ToolboxToolFrame; +import betterquesting.client.toolbox.tools.ToolboxToolGrab; +import betterquesting.client.toolbox.tools.ToolboxToolIcon; +import betterquesting.client.toolbox.tools.ToolboxToolLink; +import betterquesting.client.toolbox.tools.ToolboxToolNew; +import betterquesting.client.toolbox.tools.ToolboxToolOpen; +import betterquesting.client.toolbox.tools.ToolboxToolRemove; +import betterquesting.client.toolbox.tools.ToolboxToolReset; +import betterquesting.client.toolbox.tools.ToolboxToolScale; +import betterquesting.client.toolbox.tools.ToolboxToolSetMain; import betterquesting.network.handlers.NetChapterEdit; import betterquesting.questing.QuestLineDatabase; import net.minecraft.client.Minecraft; @@ -22,10 +37,8 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.util.text.TextFormatting; -import java.util.ArrayList; -import java.util.List; - public class PanelTabMain extends CanvasEmpty { + private final CanvasQuestLine cvQuestLine; private final PanelToolController toolController; @@ -45,14 +58,21 @@ public void initPanel() { IGuiColor tCol = new GuiColorStatic(0xFF000000); this.addPanel(new PanelButton(new GuiRectangle(0, 0, w / 2, 16, 0), -1, "" + ToolboxTabMain.INSTANCE.getSnapValue()) { + @Override public void onButtonClick() { ToolboxTabMain.INSTANCE.toggleSnap(); this.setText("" + ToolboxTabMain.INSTANCE.getSnapValue()); } - }.setIcon(PresetIcon.ICON_GRID.getTexture()).setTextShadow(false).setTextHighlight(tCol, tCol, tCol).setTooltip(makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.snap.name"), QuestTranslation.translate("betterquesting.toolbox.tool.snap.desc")))); + + }.setIcon(PresetIcon.ICON_GRID.getTexture()) + .setTextShadow(false) + .setTextHighlight(tCol, tCol, tCol) + .setTooltip(makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.snap.name"), + QuestTranslation.translate("betterquesting.toolbox.tool.snap.desc")))); this.addPanel(new PanelButton(new GuiRectangle(w / 2, 0, w / 2, 16, 0), -1, "") { + @Override public void onButtonClick() { Minecraft mc = Minecraft.getMinecraft(); @@ -68,7 +88,10 @@ public void onButtonClick() { NetChapterEdit.sendEdit(payload); })); } - }.setIcon(PresetIcon.ICON_PROPS.getTexture()).setTooltip(makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.raw.name"), QuestTranslation.translate("betterquesting.toolbox.tool.raw.desc")))); + + }.setIcon(PresetIcon.ICON_PROPS.getTexture()) + .setTooltip(makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.raw.name"), + QuestTranslation.translate("betterquesting.toolbox.tool.raw.desc")))); final List> toolBtns = new ArrayList<>(); @@ -94,11 +117,15 @@ public void onButtonClick() { } this.addPanel(new PanelButton(new GuiRectangle(0, (toolEntries.size() / 2 + 1) * 16 + 24, w / 2, 16, 0), -1, "") { + @Override public void onButtonClick() { cvQuestLine.fitToWindow(); } - }.setIcon(PresetIcon.ICON_BOX_FIT.getTexture()).setTextShadow(false).setTextHighlight(tCol, tCol, tCol) + + }.setIcon(PresetIcon.ICON_BOX_FIT.getTexture()) + .setTextShadow(false) + .setTextHighlight(tCol, tCol, tCol) .setTooltip(makeToolTip(QuestTranslation.translate("betterquesting.btn.zoom_fit"), QuestTranslation.translate("betterquesting.btn.zoom_fit")))); } @@ -110,6 +137,7 @@ private static List makeToolTip(String title, String desc) { } private static class ToolEntry { + private final IToolboxTool tool; private final IGuiTexture tex; private final List tt; @@ -119,20 +147,62 @@ private ToolEntry(IToolboxTool tool, IGuiTexture tex, List tt) { this.tex = tex; this.tt = tt; } + } static { - toolEntries.add(new ToolEntry(new ToolboxToolOpen(), PresetIcon.ICON_CURSOR.getTexture(), makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.open.name"), QuestTranslation.translate("betterquesting.toolbox.tool.open.desc")))); - toolEntries.add(new ToolEntry(new ToolboxToolNew(), PresetIcon.ICON_NEW.getTexture(), makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.new.name"), QuestTranslation.translate("betterquesting.toolbox.tool.new.desc")))); - toolEntries.add(new ToolEntry(new ToolboxToolGrab(), PresetIcon.ICON_GRAB.getTexture(), makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.grab.name"), QuestTranslation.translate("betterquesting.toolbox.tool.grab.desc")))); - toolEntries.add(new ToolEntry(new ToolboxToolLink(), PresetIcon.ICON_LINK.getTexture(), makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.link.name"), QuestTranslation.translate("betterquesting.toolbox.tool.link.desc")))); - toolEntries.add(new ToolEntry(new ToolboxToolCopy(), PresetIcon.ICON_COPY.getTexture(), makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.copy.name"), QuestTranslation.translate("betterquesting.toolbox.tool.copy.desc")))); - toolEntries.add(new ToolEntry(new ToolboxToolScale(), PresetIcon.ICON_SCALE.getTexture(), makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.scale.name"), QuestTranslation.translate("betterquesting.toolbox.tool.scale.desc")))); - toolEntries.add(new ToolEntry(new ToolboxToolDelete(), PresetIcon.ICON_TRASH.getTexture(), makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.delete.name"), QuestTranslation.translate("betterquesting.toolbox.tool.delete.desc")))); - toolEntries.add(new ToolEntry(new ToolboxToolRemove(), PresetIcon.ICON_NEGATIVE.getTexture(), makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.remove.name"), QuestTranslation.translate("betterquesting.toolbox.tool.remove.desc")))); - toolEntries.add(new ToolEntry(new ToolboxToolComplete(), PresetIcon.ICON_TICK.getTexture(), makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.complete.name"), QuestTranslation.translate("betterquesting.toolbox.tool.complete.desc")))); - toolEntries.add(new ToolEntry(new ToolboxToolReset(), PresetIcon.ICON_REFRESH.getTexture(), makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.reset.name"), QuestTranslation.translate("betterquesting.toolbox.tool.reset.desc")))); - toolEntries.add(new ToolEntry(new ToolboxToolIcon(), PresetIcon.ICON_ITEM.getTexture(), makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.icon.name"), QuestTranslation.translate("betterquesting.toolbox.tool.icon.desc")))); - toolEntries.add(new ToolEntry(new ToolboxToolFrame(), PresetIcon.ICON_NOTICE.getTexture(), makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.frame.name"), QuestTranslation.translate("betterquesting.toolbox.tool.frame.desc")))); + toolEntries.add(new ToolEntry(new ToolboxToolOpen(), + PresetIcon.ICON_CURSOR.getTexture(), + makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.open.name"), + QuestTranslation.translate("betterquesting.toolbox.tool.open.desc")))); + toolEntries.add(new ToolEntry(new ToolboxToolNew(), + PresetIcon.ICON_NEW.getTexture(), + makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.new.name"), + QuestTranslation.translate("betterquesting.toolbox.tool.new.desc")))); + toolEntries.add(new ToolEntry(new ToolboxToolGrab(), + PresetIcon.ICON_GRAB.getTexture(), + makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.grab.name"), + QuestTranslation.translate("betterquesting.toolbox.tool.grab.desc")))); + toolEntries.add(new ToolEntry(new ToolboxToolLink(), + PresetIcon.ICON_LINK.getTexture(), + makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.link.name"), + QuestTranslation.translate("betterquesting.toolbox.tool.link.desc")))); + toolEntries.add(new ToolEntry(new ToolboxToolCopy(), + PresetIcon.ICON_COPY.getTexture(), + makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.copy.name"), + QuestTranslation.translate("betterquesting.toolbox.tool.copy.desc")))); + toolEntries.add(new ToolEntry(new ToolboxToolScale(), + PresetIcon.ICON_SCALE.getTexture(), + makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.scale.name"), + QuestTranslation.translate("betterquesting.toolbox.tool.scale.desc")))); + toolEntries.add(new ToolEntry(new ToolboxToolDelete(), + PresetIcon.ICON_TRASH.getTexture(), + makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.delete.name"), + QuestTranslation.translate("betterquesting.toolbox.tool.delete.desc")))); + toolEntries.add(new ToolEntry(new ToolboxToolRemove(), + PresetIcon.ICON_NEGATIVE.getTexture(), + makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.remove.name"), + QuestTranslation.translate("betterquesting.toolbox.tool.remove.desc")))); + toolEntries.add(new ToolEntry(new ToolboxToolComplete(), + PresetIcon.ICON_TICK.getTexture(), + makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.complete.name"), + QuestTranslation.translate("betterquesting.toolbox.tool.complete.desc")))); + toolEntries.add(new ToolEntry(new ToolboxToolReset(), + PresetIcon.ICON_REFRESH.getTexture(), + makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.reset.name"), + QuestTranslation.translate("betterquesting.toolbox.tool.reset.desc")))); + toolEntries.add(new ToolEntry(new ToolboxToolIcon(), + PresetIcon.ICON_ITEM.getTexture(), + makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.icon.name"), + QuestTranslation.translate("betterquesting.toolbox.tool.icon.desc")))); + toolEntries.add(new ToolEntry(new ToolboxToolSetMain(), + PresetIcon.ICON_NOTICE.getTexture(), + makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.set_main.name"), + QuestTranslation.translate("betterquesting.toolbox.tool.set_main.desc")))); + toolEntries.add(new ToolEntry(new ToolboxToolFrame(), + PresetIcon.ICON_CHANGE_FRAME.getTexture(), + makeToolTip(QuestTranslation.translate("betterquesting.toolbox.tool.frame.name"), + QuestTranslation.translate("betterquesting.toolbox.tool.frame.desc")))); } + } diff --git a/src/main/java/betterquesting/client/toolbox/tools/ToolboxToolFrame.java b/src/main/java/betterquesting/client/toolbox/tools/ToolboxToolFrame.java index 95f5e800e..56e678272 100644 --- a/src/main/java/betterquesting/client/toolbox/tools/ToolboxToolFrame.java +++ b/src/main/java/betterquesting/client/toolbox/tools/ToolboxToolFrame.java @@ -1,11 +1,15 @@ package betterquesting.client.toolbox.tools; import betterquesting.api.client.toolbox.IToolboxTool; +import betterquesting.api.enums.EnumFrameType; import betterquesting.api.properties.NativeProps; +import betterquesting.api.questing.IQuest; import betterquesting.api2.client.gui.controls.PanelButtonQuest; import betterquesting.api2.client.gui.panels.lists.CanvasQuestLine; import betterquesting.client.gui2.editors.designer.PanelToolController; +import betterquesting.client.gui2.editors.nbt.GuiQuestFrameSelection; import betterquesting.network.handlers.NetQuestEdit; +import net.minecraft.client.Minecraft; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.NonNullList; @@ -61,22 +65,26 @@ public boolean onMouseClick(int mx, int my, int click) { } private void changeFrame(List btnList) { - boolean state = !btnList.get(0).getStoredValue().getValue().getProperty(NativeProps.MAIN); - - NBTTagList dataList = new NBTTagList(); - for (PanelButtonQuest btn : btnList) { - btn.getStoredValue().getValue().setProperty(NativeProps.MAIN, state); - - NBTTagCompound entry = new NBTTagCompound(); - entry.setInteger("questID", btn.getStoredValue().getID()); - entry.setTag("config", btn.getStoredValue().getValue().writeToNBT(new NBTTagCompound())); - dataList.appendTag(entry); - } - - NBTTagCompound payload = new NBTTagCompound(); - payload.setTag("data", dataList); - payload.setInteger("action", 0); - NetQuestEdit.sendEdit(payload); + Minecraft mc = Minecraft.getMinecraft(); + IQuest quest = btnList.get(0).getStoredValue().getValue(); + EnumFrameType current = quest.getProperty(NativeProps.FRAME); + mc.displayGuiScreen(new GuiQuestFrameSelection(mc.currentScreen, current, quest.getProperty(NativeProps.ICON), value -> { + NBTTagList dataList = new NBTTagList(); + for (PanelButtonQuest btn : btnList) { + btn.getStoredValue().getValue().setProperty(NativeProps.FRAME, value); + + NBTTagCompound entry = new NBTTagCompound(); + entry.setInteger("questID", btn.getStoredValue().getID()); + entry.setTag("config", btn.getStoredValue().getValue().writeToNBT(new NBTTagCompound())); + dataList.appendTag(entry); + } + + NBTTagCompound payload = new NBTTagCompound(); + payload.setTag("data", dataList); + payload.setInteger("action", 0); + NetQuestEdit.sendEdit(payload); + }, quest.getProperty(NativeProps.MAIN))); + } @Override diff --git a/src/main/java/betterquesting/client/toolbox/tools/ToolboxToolSetMain.java b/src/main/java/betterquesting/client/toolbox/tools/ToolboxToolSetMain.java new file mode 100644 index 000000000..83345e6f6 --- /dev/null +++ b/src/main/java/betterquesting/client/toolbox/tools/ToolboxToolSetMain.java @@ -0,0 +1,121 @@ +package betterquesting.client.toolbox.tools; + +import java.util.Collections; +import java.util.List; + +import org.lwjgl.input.Keyboard; + +import betterquesting.api.client.toolbox.IToolboxTool; +import betterquesting.api.properties.NativeProps; +import betterquesting.api2.client.gui.controls.PanelButtonQuest; +import betterquesting.api2.client.gui.panels.lists.CanvasQuestLine; +import betterquesting.client.gui2.editors.designer.PanelToolController; +import betterquesting.network.handlers.NetQuestEdit; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.NonNullList; + +public class ToolboxToolSetMain implements IToolboxTool { + + private CanvasQuestLine gui; + + @Override + public void initTool(CanvasQuestLine gui) { + this.gui = gui; + } + + @Override + public void refresh(CanvasQuestLine gui) { + + } + + @Override + public void disableTool() { + + } + + @Override + public void drawCanvas(int mx, int my, float partialTick) { + + } + + @Override + public void drawOverlay(int mx, int my, float partialTick) { + + } + + @Override + public void onSelection(NonNullList buttons) { + } + + @Override + public boolean onMouseClick(int mx, int my, int click) { + if (click != 0 || !gui.getTransform().contains(mx, my)) + return false; + + PanelButtonQuest btn = gui.getButtonAt(mx, my); + + if (btn == null) + return false; + if (PanelToolController.selected.size() > 0 && !PanelToolController.selected.contains(btn)) + return false; + + List btnList = PanelToolController.selected.size() > 0 ? PanelToolController.selected : Collections.singletonList(btn); + changeIsMain(btnList); + return true; + } + + private void changeIsMain(List btnList) { + boolean state = !btnList.get(0).getStoredValue().getValue().getProperty(NativeProps.MAIN); + + NBTTagList dataList = new NBTTagList(); + for (PanelButtonQuest btn : btnList) { + btn.getStoredValue().getValue().setProperty(NativeProps.MAIN, state); + + NBTTagCompound entry = new NBTTagCompound(); + entry.setInteger("questID", btn.getStoredValue().getID()); + entry.setTag("config", btn.getStoredValue().getValue().writeToNBT(new NBTTagCompound())); + dataList.appendTag(entry); + } + + NBTTagCompound payload = new NBTTagCompound(); + payload.setTag("data", dataList); + payload.setInteger("action", 0); + NetQuestEdit.sendEdit(payload); + } + + @Override + public boolean onMouseRelease(int mx, int my, int click) { + return false; + } + + @Override + public boolean onMouseScroll(int mx, int my, int scroll) { + return false; + } + + @Override + public boolean onKeyPressed(char c, int key) { + if (PanelToolController.selected.size() <= 0 || key != Keyboard.KEY_RETURN) + return false; + + changeIsMain(PanelToolController.selected); + return true; + } + + @Override + public List getTooltip(int mx, int my) { + return null; + } + + @Override + public boolean clampScrolling() { + return true; + } + + @Override + public boolean useSelection() { + return true; + } + +} diff --git a/src/main/java/betterquesting/legacy/v0/LegacyLoader_v0.java b/src/main/java/betterquesting/legacy/v0/LegacyLoader_v0.java index efd650175..932d56142 100644 --- a/src/main/java/betterquesting/legacy/v0/LegacyLoader_v0.java +++ b/src/main/java/betterquesting/legacy/v0/LegacyLoader_v0.java @@ -1,5 +1,13 @@ package betterquesting.legacy.v0; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; + +import betterquesting.api.enums.EnumFrameType; import betterquesting.api.enums.EnumLogic; import betterquesting.api.placeholders.rewards.RewardPlaceholder; import betterquesting.api.placeholders.tasks.TaskPlaceholder; @@ -13,21 +21,20 @@ import betterquesting.api.utils.NBTConverter; import betterquesting.api2.storage.IDatabaseNBT; import betterquesting.legacy.ILegacyLoader; -import betterquesting.questing.*; +import betterquesting.questing.QuestDatabase; +import betterquesting.questing.QuestInstance; +import betterquesting.questing.QuestLine; +import betterquesting.questing.QuestLineDatabase; +import betterquesting.questing.QuestLineEntry; import betterquesting.questing.rewards.RewardRegistry; import betterquesting.questing.tasks.TaskRegistry; import betterquesting.storage.QuestSettings; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.ResourceLocation; -import java.util.ArrayList; -import java.util.List; - public final class LegacyLoader_v0 implements ILegacyLoader { + public static final LegacyLoader_v0 INSTANCE = new LegacyLoader_v0(); private LegacyLoader_v0() { @@ -78,8 +85,10 @@ public void readQuestDatabase(JsonArray jAry) { @Override public void readProgressFromJson(JsonElement json) { - if (!json.isJsonObject()) return; - QuestDatabase.INSTANCE.readProgressFromNBT(NBTConverter.JSONtoNBT_Object(json.getAsJsonObject(), new NBTTagCompound(), true).getTagList("questProgress", 10), false); + if (!json.isJsonObject()) + return; + QuestDatabase.INSTANCE.readProgressFromNBT(NBTConverter.JSONtoNBT_Object(json.getAsJsonObject(), new NBTTagCompound(), true) + .getTagList("questProgress", 10), false); } public void readLineDatabase(JsonArray jAry) { @@ -110,7 +119,9 @@ public void readQuest(IQuest quest, JsonObject json) { quest.setProperty(NativeProps.REPEAT_TIME, JsonHelper.GetNumber(json, "repeatTime", 2000).intValue()); quest.setProperty(NativeProps.LOGIC_QUEST, EnumLogic.valueOf(JsonHelper.GetString(json, "logic", "AND"))); quest.setProperty(NativeProps.LOGIC_TASK, EnumLogic.valueOf(JsonHelper.GetString(json, "taskLogic", "AND"))); - quest.setProperty(NativeProps.ICON, JsonHelper.JsonToItemStack(NBTConverter.JSONtoNBT_Object(JsonHelper.GetObject(json, "icon"), new NBTTagCompound(), true))); + quest.setProperty(NativeProps.ICON, + JsonHelper.JsonToItemStack(NBTConverter.JSONtoNBT_Object(JsonHelper.GetObject(json, "icon"), new NBTTagCompound(), true))); + quest.setProperty(NativeProps.FRAME, EnumFrameType.valueOf(JsonHelper.GetString(json, "frame", "default"))); JsonArray reqAry = JsonHelper.GetArray(json, "preRequisites"); int[] req = new int[reqAry.size()]; @@ -245,4 +256,5 @@ public void readLine(IQuestLine qLine, JsonObject json) { } } } + } diff --git a/src/main/java/betterquesting/questing/QuestInstance.java b/src/main/java/betterquesting/questing/QuestInstance.java index d337bc6db..b6a7ee7cc 100644 --- a/src/main/java/betterquesting/questing/QuestInstance.java +++ b/src/main/java/betterquesting/questing/QuestInstance.java @@ -1,6 +1,7 @@ package betterquesting.questing; import betterquesting.api.api.QuestingAPI; +import betterquesting.api.enums.EnumFrameType; import betterquesting.api.enums.EnumLogic; import betterquesting.api.enums.EnumQuestState; import betterquesting.api.properties.IPropertyType; @@ -53,6 +54,8 @@ private void setupProps() { setupValue(NativeProps.ICON, new BigItemStack(Items.NETHER_STAR)); + setupValue(NativeProps.FRAME, EnumFrameType.DEFAULT); + setupValue(NativeProps.SOUND_COMPLETE); setupValue(NativeProps.SOUND_UPDATE); //setupValue(NativeProps.SOUND_UNLOCK); diff --git a/src/main/resources/assets/betterquesting/lang/en_us.lang b/src/main/resources/assets/betterquesting/lang/en_us.lang index 1983a1f89..a6e99d953 100644 --- a/src/main/resources/assets/betterquesting/lang/en_us.lang +++ b/src/main/resources/assets/betterquesting/lang/en_us.lang @@ -186,8 +186,10 @@ betterquesting.toolbox.tool.scale.name=Scale Icon betterquesting.toolbox.tool.scale.desc=Scales the quest icons up or down betterquesting.toolbox.tool.raw.name=Edit Raw betterquesting.toolbox.tool.raw.desc=Opens up the raw quest line JSON for editing. Includes additional hidden settings such as changing the background -betterquesting.toolbox.tool.frame.name=Edit Icon Frame +betterquesting.toolbox.tool.frame.name=Change Icon Frame betterquesting.toolbox.tool.frame.desc=Changes the quest icons frame style +betterquesting.toolbox.tool.set_main.name=Set as Main +betterquesting.toolbox.tool.set_main.desc=Set or unset the quest as main betterquesting.cmd.complete=Completed quest %s for %s betterquesting.cmd.default.save=Quest database saved as default diff --git a/src/main/resources/assets/betterquesting/textures/gui/editor_icons.png b/src/main/resources/assets/betterquesting/textures/gui/editor_icons.png index f50ca9c1f..025f248ae 100644 Binary files a/src/main/resources/assets/betterquesting/textures/gui/editor_icons.png and b/src/main/resources/assets/betterquesting/textures/gui/editor_icons.png differ diff --git a/src/main/resources/assets/betterquesting/textures/gui/ex_frames.png b/src/main/resources/assets/betterquesting/textures/gui/ex_frames.png new file mode 100644 index 000000000..ff5cc7dda Binary files /dev/null and b/src/main/resources/assets/betterquesting/textures/gui/ex_frames.png differ