forked from Funwayguy/BetterQuesting
-
Notifications
You must be signed in to change notification settings - Fork 23
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
KatatsumuriPan
wants to merge
3
commits into
CleanroomMC:1.12
from
KatatsumuriPan:1.12-extra-quest-frame
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/java/betterquesting/api2/client/gui/panels/content/PanelQuestFrame.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/betterquesting/api2/client/gui/panels/lists/CanvasQuestFrame.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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).