Skip to content

Commit

Permalink
Merge pull request #714 from FTBTeam/1.20.1/dev
Browse files Browse the repository at this point in the history
1.20.1/dev
  • Loading branch information
desht authored Mar 12, 2024
2 parents 697d1da + bd52665 commit 0d27e2e
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 27 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2001.3.4]

### Added
* The color of dependency lines for uncompleted quests is now themable
* Use the "dependency_line_uncompleted_color" setting in ftb_quests_theme.txt (a resource pack file)
* Default is #B4CCA3A3, which is the same as the previous color (a washed-out red tint)
* Added "Icon Scaling" property for quests (default: 1.0)
* Allows the quest icon to be scaled separately from the overall quest button size, which can be useful for a good appearance with some button shapes

### Fixed
* Fixed client-side config (from "User Preferences" button) not getting properly persisted
* User Preferences screen SSP pause behaviour now follows main screen's pause behaviour

## [2001.3.3]

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import dev.ftb.mods.ftbquests.item.FTBQuestsItems;
import dev.ftb.mods.ftbquests.net.SetCustomImageMessage;
import dev.ftb.mods.ftbquests.quest.BaseQuestFile;
import dev.ftb.mods.ftbquests.quest.Quest;
import dev.ftb.mods.ftbquests.quest.QuestObjectBase;
import dev.ftb.mods.ftbquests.quest.TeamData;
import dev.ftb.mods.ftbquests.quest.reward.ItemReward;
Expand Down Expand Up @@ -62,10 +61,13 @@ public class FTBQuestsClient {
public static KeyMapping KEY_QUESTS;

public static void init() {
FTBQuestsClientConfig.init();

ClientLifecycleEvent.CLIENT_SETUP.register(FTBQuestsClient::onClientSetup);
ReloadListenerRegistry.register(PackType.CLIENT_RESOURCES, new QuestFileCacheReloader());
ReloadListenerRegistry.register(PackType.CLIENT_RESOURCES, new ThemeLoader());
KeyMappingRegistry.register(KEY_QUESTS = new KeyMapping("key.ftbquests.quests", InputConstants.Type.KEYSYM, -1, "key.categories.ftbquests"));

new FTBQuestsClientEventHandler().init();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.ftb.mods.ftbquests.client;

import dev.architectury.platform.Platform;
import dev.ftb.mods.ftblibrary.config.ConfigGroup;
import dev.ftb.mods.ftblibrary.config.ui.EditConfigScreen;
import dev.ftb.mods.ftblibrary.snbt.config.BooleanValue;
Expand All @@ -9,8 +8,12 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;

import static dev.ftb.mods.ftblibrary.snbt.config.ConfigUtil.LOCAL_DIR;
import static dev.ftb.mods.ftblibrary.snbt.config.ConfigUtil.loadDefaulted;

public interface FTBQuestsClientConfig {
SNBTConfig CONFIG = SNBTConfig.create(FTBQuestsAPI.MOD_ID + "-client");
String CLIENT_CONFIG = "client-config.snbt";

SNBTConfig UI = CONFIG.addGroup("ui", 0);
BooleanValue OLD_SCROLL_WHEEL = UI.addBoolean("old_scroll_wheel", false);
Expand All @@ -25,12 +28,21 @@ static void openSettings(Screen screen) {
Minecraft.getInstance().setScreen(screen);
});
CONFIG.createClientConfig(group);
EditConfigScreen gui = new EditConfigScreen(group);
EditConfigScreen gui = new EditConfigScreen(group) {
@Override
public boolean doesGuiPauseGame() {
return screen.isPauseScreen();
}
};

gui.openGui();
}

static void init() {
loadDefaulted(CONFIG, LOCAL_DIR.resolve(FTBQuestsAPI.MOD_ID), FTBQuestsAPI.MOD_ID, CLIENT_CONFIG);
}

static void saveConfig() {
CONFIG.save(Platform.getGameFolder().resolve("local/ftbquests/client-config.snbt"));
CONFIG.save(LOCAL_DIR.resolve(FTBQuestsAPI.MOD_ID).resolve(CLIENT_CONFIG));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,6 @@ public void addMouseOverText(TooltipList list) {
chapterImage.addHoverText(list);
}

@Override
public boolean shouldDraw() {
return false;
}

@Override
public void draw(GuiGraphics graphics, Theme theme, int x, int y, int w, int h) {
Icon image = chapterImage.getImage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public void draw(GuiGraphics graphics, Theme theme, int x, int y, int w, int h)
PoseStack poseStack = graphics.pose();

if (!icon.isEmpty()) {
float s = w * 2F / 3F;
float s = w * (2F / 3F) * (float) quest.getIconScale();
poseStack.pushPose();
poseStack.translate(x + (w - s) / 2D, y + (h - s) / 2D, 0);
poseStack.scale(s, s, 1F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,24 +199,15 @@ public void drawOffsetBackground(GuiGraphics graphics, Theme theme, int x, int y
if (widget.shouldDraw() && widget instanceof QuestButton qb && !qb.quest.shouldHideDependencyLines()) {
boolean unavailable = !questScreen.file.selfTeamData.canStartTasks(qb.quest);
boolean complete = !unavailable && questScreen.file.selfTeamData.isCompleted(qb.quest);
Color4I c = complete ?
ThemeProperties.DEPENDENCY_LINE_COMPLETED_COLOR.get(questScreen.selectedChapter) :
ThemeProperties.DEPENDENCY_LINE_UNCOMPLETED_COLOR.get(questScreen.selectedChapter);

for (QuestButton button : qb.getDependencies()) {
if (button.shouldDraw() && button.quest != selectedQuest && qb.quest != selectedQuest && !button.quest.shouldHideDependentLines()) {
int r, g, b, a;
if (complete) {
Color4I c = ThemeProperties.DEPENDENCY_LINE_COMPLETED_COLOR.get(questScreen.selectedChapter);
r = c.redi();
g = c.greeni();
b = c.bluei();
a = c.alphai();
} else {
Color4I c = Color4I.hsb(button.quest.id / 1000F, 0.2F, unavailable ? 0.3F : 0.8F);
r = c.redi();
g = c.greeni();
b = c.bluei();
a = 180;
}
renderConnection(widget, button, graphics.pose(), buffer, lineWidth, r, g, b, a, a, mu, tesselator);
renderConnection(widget, button, graphics.pose(), buffer, lineWidth,
c.redi(), c.greeni(), c.bluei(), c.alphai(), c.alphai(),
mu, tesselator);
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions common/src/main/java/dev/ftb/mods/ftbquests/quest/Quest.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public final class Quest extends QuestObject implements Movable {
private boolean invisible; // invisible to players (not the same as hidden!)
private int invisibleUntilTasks; // invisible until at least X number of tasks have been completed
private Tristate requireSequentialTasks;
private double iconScale;

private Component cachedSubtitle = null;
private List<Component> cachedDescription = null;
Expand Down Expand Up @@ -107,6 +108,7 @@ public Quest(long id, Chapter chapter) {
progressionMode = ProgressionMode.DEFAULT;
dependantIDs = new HashSet<>();
requireSequentialTasks = Tristate.DEFAULT;
iconScale = 1d;
}

@Override
Expand Down Expand Up @@ -201,6 +203,10 @@ public List<String> getRawDescription() {
return rawDescription;
}

public double getIconScale() {
return iconScale;
}

@Override
public boolean isOptionalForProgression() {
return isOptional();
Expand Down Expand Up @@ -270,6 +276,10 @@ public void writeData(CompoundTag nbt) {
nbt.putDouble("size", size);
}

if (iconScale != 1d) {
nbt.putDouble("icon_scale", iconScale);
}

if (optional) {
nbt.putBoolean("optional", true);
}
Expand Down Expand Up @@ -350,6 +360,7 @@ public void readData(CompoundTag nbt) {
dependencyRequirement = DependencyRequirement.NAME_MAP.get(nbt.getString("dependency_requirement"));
hideTextUntilComplete = Tristate.read(nbt, "hide_text_until_complete");
size = nbt.getDouble("size");
iconScale = nbt.contains("icon_scale", Tag.TAG_DOUBLE) ? nbt.getDouble("icon_scale") : 1f;
optional = nbt.getBoolean("optional");
minWidth = nbt.getInt("min_width");
canRepeat = Tristate.read(nbt, "can_repeat");
Expand Down Expand Up @@ -383,6 +394,7 @@ public void writeNetData(FriendlyByteBuf buffer) {
flags = Bits.setFlag(flags, 0x4000, canRepeat == Tristate.TRUE);
flags = Bits.setFlag(flags, 0x8000, requireSequentialTasks != Tristate.DEFAULT);
flags = Bits.setFlag(flags, 0x10000, requireSequentialTasks == Tristate.TRUE);
flags = Bits.setFlag(flags, 0x20000, iconScale != 1f);
buffer.writeVarInt(flags);

hideUntilDepsVisible.write(buffer);
Expand Down Expand Up @@ -417,6 +429,10 @@ public void writeNetData(FriendlyByteBuf buffer) {
buffer.writeDouble(size);
}

if (iconScale != 1D) {
buffer.writeDouble(iconScale);
}

if (minWidth > 0) {
buffer.writeVarInt(minWidth);
}
Expand Down Expand Up @@ -463,6 +479,7 @@ public void readNetData(FriendlyByteBuf buffer) {
}

size = Bits.getFlag(flags, 0x04) ? buffer.readDouble() : 0D;
iconScale = Bits.getFlag(flags, 0x20000) ? buffer.readDouble() : 1D;
minWidth = Bits.getFlag(flags, 0x200) ? buffer.readVarInt() : 0;
ignoreRewardBlocking = Bits.getFlag(flags, 0x10);
hideDependentLines = Bits.getFlag(flags, 0x20);
Expand Down Expand Up @@ -647,6 +664,7 @@ public void onClicked(MouseButton button, ConfigCallback callback) {
appearance.addDouble("x", x, v -> x = v, 0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
appearance.addDouble("y", y, v -> y = v, 0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
appearance.addInt("min_width", minWidth, v -> minWidth = v, 0, 0, 3000);
appearance.addDouble("icon_scale", iconScale, v -> iconScale = v, 1f, 0.1, 2.0);

ConfigGroup visibility = config.getOrCreateSubgroup("visibility");
visibility.addTristate("hide", hideUntilDepsVisible, v -> hideUntilDepsVisible = v);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public boolean equals(Object o) {
ColorProperty QUEST_LOCKED_COLOR = new ColorProperty("quest_locked_color");
IconProperty DEPENDENCY_LINE_TEXTURE = new IconProperty("dependency_line_texture");
ColorProperty DEPENDENCY_LINE_COMPLETED_COLOR = new ColorProperty("dependency_line_completed_color");
ColorProperty DEPENDENCY_LINE_UNCOMPLETED_COLOR = new ColorProperty("dependency_line_uncompleted_color");
ColorProperty DEPENDENCY_LINE_REQUIRES_COLOR = new ColorProperty("dependency_line_requires_color");
ColorProperty DEPENDENCY_LINE_REQUIRED_FOR_COLOR = new ColorProperty("dependency_line_required_for_color");
DoubleProperty DEPENDENCY_LINE_SELECTED_SPEED = new DoubleProperty("dependency_line_selected_speed", 0D, 1000D);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ quest_not_started_color: #96FFFFFF
quest_locked_color: #FF999999
dependency_line_texture: ftbquests:textures/gui/dependency.png
dependency_line_completed_color: #64DC64
dependency_line_uncompleted_color: #B4CCA3A3
dependency_line_requires_color: #00C8C8
dependency_line_required_for_color: #C8C800
dependency_line_selected_speed: 1.0
Expand Down
2 changes: 2 additions & 0 deletions common/src/main/resources/assets/ftbquests/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@
"ftbquests.quest.appearance.y": "Y",
"ftbquests.quest.appearance.size": "Size",
"ftbquests.quest.appearance.size.tooltip": "0 means to use chapter default",
"ftbquests.quest.appearance.icon_scale": "Icon Scaling",
"ftbquests.quest.appearance.icon_scale.tooltip": "Independent of the overall button size",
"ftbquests.quest.visibility.hide": "Hide Quest Until Dependencies are Visible",
"ftbquests.quest.appearance.shape": "Shape",
"ftbquests.quest_link.shape": "Shape",
Expand Down
1 change: 1 addition & 0 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
"ftbteams": ">=2001.1.4-build.1"
},
"breaks": {
"ftblibrary": ">=2001.2.0"
}
}
2 changes: 1 addition & 1 deletion forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ side = "BOTH"
[[dependencies.ftbquests]]
modId = "ftblibrary"
mandatory = true
versionRange = "[2001.1.4,)"
versionRange = "[2001.1.4,2001.2.0)"
ordering = "AFTER"
side = "BOTH"

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod_id=ftbquests
archives_base_name=ftb-quests
minecraft_version=1.20.1
# Build time
mod_version=2001.3.3
mod_version=2001.3.4
maven_group=dev.ftb.mods
mod_author=FTB Team
# Curse release
Expand Down

0 comments on commit 0d27e2e

Please sign in to comment.