Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra quest frames #102

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/main/java/betterquesting/api/enums/EnumFrameType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package betterquesting.api.enums;

public enum EnumFrameType {
DEFAULT,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe there should be an option to have no frame (EMPTY).

SQUARE,
ROUNDED_SQUARE,
CIRCLE,
HEXAGON,
HEXAGON90,
PENTAGON,
DIAMOND,
STAR4,
CROSS,
DIAGONAL_CROSS,
DIAGONAL_STAR4,
PRICKLE,
GEAR,
GATE,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAIN as a prop should be deprecated, and should be converted into this frame option

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,
}
30 changes: 29 additions & 1 deletion src/main/java/betterquesting/api/enums/EnumQuestState.java
Original file line number Diff line number Diff line change
@@ -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);
}
}

}
33 changes: 24 additions & 9 deletions src/main/java/betterquesting/api/properties/NativeProps.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,6 +21,7 @@
* List of native properties used in BetterQuesting
*/
public class NativeProps {

public static final IPropertyType<String> NAME = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "name"), "untitled.name");
public static final IPropertyType<String> DESC = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "desc"), "untitled.desc");

Expand All @@ -28,19 +35,24 @@ public class NativeProps {
public static final IPropertyType<Boolean> SIMULTANEOUS = new PropertyTypeBoolean(new ResourceLocation(ModReference.MODID, "simultaneous"), false);
public static final IPropertyType<Boolean> IGNORES_VIEW_MODE = new PropertyTypeBoolean(new ResourceLocation(ModReference.MODID, "ignoresView"), false);

public static final IPropertyType<EnumQuestVisibility> VISIBILITY = new PropertyTypeEnum<>(new ResourceLocation(ModReference.MODID, "visibility"), findVisibility());
public static final IPropertyType<EnumQuestVisibility> VISIBILITY = new PropertyTypeEnum<>(new ResourceLocation(ModReference.MODID, "visibility"),
findVisibility());
public static final IPropertyType<EnumLogic> LOGIC_TASK = new PropertyTypeEnum<>(new ResourceLocation(ModReference.MODID, "taskLogic"), EnumLogic.AND);
public static final IPropertyType<EnumLogic> LOGIC_QUEST = new PropertyTypeEnum<>(new ResourceLocation(ModReference.MODID, "questLogic"), EnumLogic.AND);

public static final IPropertyType<Integer> REPEAT_TIME = new PropertyTypeInteger(new ResourceLocation(ModReference.MODID, "repeatTime"), -1);
public static final IPropertyType<Boolean> REPEAT_REL = new PropertyTypeBoolean(new ResourceLocation(ModReference.MODID, "repeat_relative"), true);

public static final IPropertyType<String> SOUND_UNLOCK = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "snd_unlock"), "minecraft:ui.button.click");
public static final IPropertyType<String> SOUND_UPDATE = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "snd_update"), "minecraft:entity.player.levelup");
public static final IPropertyType<String> SOUND_COMPLETE = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "snd_complete"), "minecraft:entity.player.levelup");
public static final IPropertyType<String> SOUND_UNLOCK = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "snd_unlock"),
"minecraft:ui.button.click");
public static final IPropertyType<String> SOUND_UPDATE = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "snd_update"),
"minecraft:entity.player.levelup");
public static final IPropertyType<String> SOUND_COMPLETE = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "snd_complete"),
"minecraft:entity.player.levelup");

public static final IPropertyType<BigItemStack> ICON = new PropertyTypeItemStack(new ResourceLocation(ModReference.MODID, "icon"), new BigItemStack(Items.NETHER_STAR));
//public static final IPropertyType<String> FRAME = new PropertyTypeString(new ResourceLocation(ModReference.MODID,"frame"), "");
public static final IPropertyType<BigItemStack> ICON = new PropertyTypeItemStack(new ResourceLocation(ModReference.MODID, "icon"),
new BigItemStack(Items.NETHER_STAR));
public static final IPropertyType<EnumFrameType> FRAME = new PropertyTypeEnum<>(new ResourceLocation(ModReference.MODID, "frame"), EnumFrameType.DEFAULT);

public static final IPropertyType<String> BG_IMAGE = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "bg_image"), "");
public static final IPropertyType<Integer> BG_SIZE = new PropertyTypeInteger(new ResourceLocation(ModReference.MODID, "bg_size"), 256);
Expand All @@ -53,7 +65,9 @@ public class NativeProps {
public static final IPropertyType<Integer> LIVES_DEF = new PropertyTypeInteger(new ResourceLocation(ModReference.MODID, "livesDef"), 3);
public static final IPropertyType<Integer> LIVES_MAX = new PropertyTypeInteger(new ResourceLocation(ModReference.MODID, "livesMax"), 10);

public static final IPropertyType<String> HOME_IMAGE = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "home_image"), new ResourceLocation(ModReference.MODID, "textures/gui/default_title.png").toString());
public static final IPropertyType<String> HOME_IMAGE = new PropertyTypeString(new ResourceLocation(ModReference.MODID, "home_image"),
new ResourceLocation(ModReference.MODID, "textures/gui/default_title.png")
.toString());
public static final IPropertyType<Float> HOME_ANC_X = new PropertyTypeFloat(new ResourceLocation(ModReference.MODID, "home_anchor_x"), 0.5F);
public static final IPropertyType<Float> HOME_ANC_Y = new PropertyTypeFloat(new ResourceLocation(ModReference.MODID, "home_anchor_y"), 0F);
public static final IPropertyType<Integer> HOME_OFF_X = new PropertyTypeInteger(new ResourceLocation(ModReference.MODID, "home_offset_x"), -128);
Expand All @@ -72,4 +86,5 @@ private static EnumQuestVisibility findVisibility() {

return EnumQuestVisibility.NORMAL;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -43,33 +44,25 @@ public PanelButtonQuest(GuiRectangle rect, int id, String txt, DBEntry<IQuest> 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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<EnumFrameType> {

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

}
Original file line number Diff line number Diff line change
@@ -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));
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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));
Expand Down
Loading
Loading