Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.ldtteam.structurize.client.gui;

import com.google.gson.internal.LazilyParsedNumber;
import com.ldtteam.blockui.Alignment;
import com.ldtteam.blockui.Color;
import com.ldtteam.blockui.Pane;
import com.ldtteam.blockui.PaneBuilders;
import com.ldtteam.blockui.controls.*;
import com.ldtteam.blockui.controls.ButtonImage;
import com.ldtteam.blockui.controls.Image;
import com.ldtteam.blockui.controls.Text;
import com.ldtteam.blockui.controls.TextFieldVanilla;
import com.ldtteam.blockui.views.ScrollingList;
import com.ldtteam.blockui.views.View;
import com.ldtteam.structurize.Structurize;
import com.ldtteam.structurize.api.util.Utils;
import com.ldtteam.structurize.api.util.constant.TranslationConstants;
Expand All @@ -31,7 +31,6 @@
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
import net.minecraftforge.common.ForgeConfigSpec.DoubleValue;
import net.minecraftforge.common.ForgeConfigSpec.ValueSpec;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -374,11 +373,21 @@ protected void initSettings()
inputField.off();
buttonImage.on();
buttonImage.setText(Component.translatable(value ? "options.on" : "options.off"));
if (setting == Structurize.getConfig().getClient().renderPlaceholdersNice)
{
buttonImage.setText(Component.translatable(!value ? "options.on" : "options.off"));
}
buttonImage.setHandler((button) -> {
final Boolean newValue = !typedSetting.get();

Structurize.getConfig().set(typedSetting, newValue);
buttonImage.setText(Component.translatable(newValue ? "options.on" : "options.off"));
if (setting == Structurize.getConfig().getClient().renderPlaceholdersNice)
{
final BlueprintPreviewData previewData = RenderingCache.getOrCreateBlueprintPreviewData("blueprint");
previewData.setRenderBlocksNice(!previewData.getRenderBlocksNice());
buttonImage.setText(Component.translatable(!newValue ? "options.on" : "options.off"));
}
});
}
else if (setting.get() instanceof final Number value)
Expand Down Expand Up @@ -411,74 +420,6 @@ else if (setting.get() instanceof final Number value)
{
inputField.setTextColor(0xffe0e0e0); // vanilla defualt

final DoubleValue rendererTransparency = Structurize.getConfig().getClient().rendererTransparency;
if (setting == rendererTransparency && rendererTransparency.get() < 0)
{
// TODO: move to standalone ui
final View confirmDialog = new View();
confirmDialog.setPosition(70, 0);
confirmDialog.setSize(177, 150);
confirmDialog.setAlignment(Alignment.MIDDLE);

final Gradient hidingLayer = new Gradient();
hidingLayer.setGradientStart(0x10, 0x10, 0x10, 0xC0);
hidingLayer.setGradientEnd(0x10, 0x10, 0x10, 0xD0);
hidingLayer.setSize(getWindow().getWidth(), getWindow().getHeight());

getWindow().addChild(hidingLayer);
getWindow().addChild(confirmDialog);
View.setFocus(null);

final ImageRepeatable background = new ImageRepeatable();
background.setSize(177, 150);
background.setImageLoc(new ResourceLocation(MOD_ID, "textures/gui/builderhut/builder_papper.png"));
background.setImageSize(6, 7, 177, 231, 20, 20, 100, 100);
confirmDialog.addChild(background);

final Text text = new Text();
text.setPosition(10, 8);
text.setSize(157, 105);
text.setColors(Color.getByName("black"));
text.setTextAlignment(Alignment.TOP_MIDDLE);
text.setText(Component.translatable("structurize.config.transparency.warning"));
confirmDialog.addChild(text);

final ButtonImage confirm = new ButtonImage();
confirm.setPosition(10, 123);
confirm.setSize(64, 17);
confirm.setImage(new ResourceLocation(MOD_ID, "textures/gui/builderhut/builder_button_small.png"), false);
confirm.setColors(Color.getByName("black"));
confirm.setTextAlignment(Alignment.MIDDLE);
confirm.setTextRenderBox(64, 17);
confirm.setText(Component.translatable("gui.yes"));
confirm.setHandler(b -> {
final double newVal = newValue.doubleValue();
Structurize.getConfig().set(rendererTransparency, newVal < 0 ? 1 : newVal);
if (newVal < 0)
{
inputField.setText("1.0");
}
getWindow().removeChild(hidingLayer);
getWindow().removeChild(confirmDialog);
});
confirmDialog.addChild(confirm);

final ButtonImage cancel = new ButtonImage();
cancel.setPosition(103, 123);
cancel.setSize(64, 17);
cancel.setImage(new ResourceLocation(MOD_ID, "textures/gui/builderhut/builder_button_small.png"), false);
cancel.setColors(Color.getByName("black"));
cancel.setTextAlignment(Alignment.MIDDLE);
cancel.setTextRenderBox(64, 17);
cancel.setText(Component.translatable("gui.cancel"));
cancel.setHandler(b -> {
inputField.setText(Double.toString(rendererTransparency.get()));
getWindow().removeChild(hidingLayer);
getWindow().removeChild(confirmDialog);
});
confirmDialog.addChild(cancel);
}
else
{
// need properly typed thing now, but it's validated so parsing should never crash
// TODO: switch instanceof
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ protected ClientConfiguration(final ForgeConfigSpec.Builder builder)
{
createCategory(builder, "blueprint.renderer");
// if you add anything to this category, also add it #collectPreviewRendererSettings()
renderPlaceholdersNice = defineBoolean(builder, "render_placeholders_nice", false);

renderPlaceholdersNice = defineBoolean(builder, "render_placeholders_nice", true);
sharePreviews = defineBoolean(builder, "share_previews", false);
displayShared = defineBoolean(builder, "see_shared_previews", false);
rendererLightLevel = defineInteger(builder, "light_level", 15, -1, 15);
rendererTransparency = defineDouble(builder, "transparency", -1, -1, 1);
rendererTransparency = defineDouble(builder, "transparency", 1, 0.1, 1);

addWatcher(BlueprintHandler.getInstance()::clearCache, renderPlaceholdersNice, rendererLightLevel);
addWatcher(displayShared, (oldValue, isSharingEnabled) -> {
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/assets/structurize/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@
"structurize.config.maxcachedschematics.comment": "Max amount of schematics to be cached on the server.",
"structurize.config.maxoperationspertick": "Max Operations per Tick",
"structurize.config.maxoperationspertick.comment": "Max world operations per tick (max blocks to place, remove, or replace).",
"structurize.config.render_placeholders_nice": "Render placeholders as target blocks",
"structurize.config.render_placeholders_nice.comment": "If disabled show placeholders as normal blocks, if enabled render: any (light) -> nothing, fluid (blue) -> dimension default fluid, solid (brown) -> worldgen block, tag (transparent) -> content block. Fluid and solid only work in singleplayer/for LAN owner, else it's just best guess. Currently without auto-updating",
"structurize.config.render_placeholders_nice": "Show placeholders",
"structurize.config.render_placeholders_nice.comment": "Shows placeholder blocks, if enabled. Light placeholders(small ones) are positions which are not touched, solid placeholders(dark, full block) are only replaced if there is no full block already.",
"structurize.config.scan_tool_scrolling": "Scan Tool Scrolling",
"structurize.config.scan_tool_scrolling.comment": "Sneak+scroll on the hotbar switches scan tool slots",
"structurize.config.see_shared_previews": "See previews from others",
Expand All @@ -155,7 +155,7 @@
"structurize.config.teleportsafety": "Safety Check",
"structurize.config.teleportsafety.comment": "Allow teleporting a little distance away if the landing area is blocked; disable to teleport exactly to target.",
"structurize.config.transparency": "Transparency of non-transparent things",
"structurize.config.transparency.comment": "From 0 (transparent) to 1 (opaque). ALPHA FEATURE, reported bugs may not receive fix. (Minus values also mean disabled)",
"structurize.config.transparency.comment": "From 0.1 (transparent) to 1.0 (opaque), transparency may have problems with shaders or rendering optimization mods",
"structurize.config.transparency.warning": "Transparent rendering will in most situations look somewhat correctly. But you might face situations under which looking through transparent preview will make the rendered result weird, wrong or even may enable you to see through other things. Are you sure you want to change the transparency config?",
"structurize.gui.buildtool.creative_only": "Structurize does not support using the build tool when in survival. Switch to creative or install MineColonies and use the MineColonies Builder.",
"structurize.gui.tagtool.creative_only": "This tool is meant to be used in creative mode only",
Expand Down
Loading