-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
297 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
forge/origin/src/main/java/io/github/kituin/chatimage/gui/ConfigRawScreen.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,57 @@ | ||
package io.github.kituin.chatimage.gui; | ||
|
||
import io.github.kituin.chatimage.widget.SettingSliderWidget; | ||
|
||
import java.util.function.Consumer; | ||
|
||
|
||
public abstract class ConfigRawScreen extends #Screen# { | ||
protected #Screen# parent; | ||
|
||
protected ConfigRawScreen(#Component# title, #Screen# screen) { | ||
super(title); | ||
this.parent = screen; | ||
} | ||
public void render(#GuiGraphics# matrixStack, int mouseX, int mouseY, float partialTicks) { | ||
super.render(matrixStack, mouseX, mouseY, partialTicks); | ||
// IF <= forge-1.19 | ||
// renderBackground(matrixStack); | ||
// drawCenteredString(matrixStack, this.font, | ||
// title, this.width / 2, this.height / 4 - 16, 16764108); | ||
// ELSE | ||
// renderBackground(matrixStack, mouseX, mouseY, partialTicks); | ||
// matrixStack.drawCenteredString(this.font, | ||
// title, this.width / 2, this.height / 4 - 16, 16764108); | ||
// END IF | ||
|
||
} | ||
protected SettingSliderWidget.OnTooltip createSliderTooltip(#Component# text) { | ||
return new SettingSliderWidget.OnTooltip() { | ||
public void onTooltip(SettingSliderWidget p_93753_, #GuiGraphics# p_283427_, int p_281447_, int p_282852_) { | ||
if (text != null) { | ||
// IF <= forge-1.19 | ||
// ConfigRawScreen.this.renderTooltip(p_283427_, ConfigRawScreen.this.font.split(text, Math.max(ConfigRawScreen.this.width / 2 - 43, 170)), p_281447_, p_282852_); | ||
// ELSE | ||
// p_283427_.renderTooltip(ConfigRawScreen.this.font, ConfigRawScreen.this.font.split(text, Math.max(ConfigRawScreen.this.width / 2 - 43, 170)), p_281447_, p_282852_); | ||
// END IF | ||
} | ||
} | ||
|
||
public void narrateTooltip(Consumer<#Component#> p_168842_) { | ||
p_168842_.accept(text); | ||
} | ||
}; | ||
} | ||
// IF <= forge-1.19 | ||
// protected #Button.OnTooltip# createButtonTooltip(#Component# text) { | ||
// return new #Button.OnTooltip#() { | ||
// public void onTooltip(#Button# p_93753_, #GuiGraphics# p_93754_, int p_93755_, int p_93756_) { | ||
// if (text != null) { | ||
// ConfigRawScreen.this.renderTooltip(p_93754_, ConfigRawScreen.this.font.split(text, Math.max(ConfigRawScreen.this.width / 2 - 43, 170)), p_93755_, p_93756_); | ||
// } | ||
// } | ||
// | ||
// }; | ||
// } | ||
// END IF | ||
} |
77 changes: 77 additions & 0 deletions
77
forge/origin/src/main/java/io/github/kituin/chatimage/gui/ConfigScreen.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,77 @@ | ||
package io.github.kituin.chatimage.gui; | ||
|
||
import io.github.kituin.ChatImageCode.ChatImageConfig; | ||
import io.github.kituin.chatimage.widget.GifSlider; | ||
import io.github.kituin.chatimage.widget.TimeOutSlider; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.api.distmarker.OnlyIn; | ||
|
||
import static io.github.kituin.chatimage.ChatImage.CONFIG; | ||
import static io.github.kituin.chatimage.tool.SimpleUtil.createTranslatableComponent; | ||
import static io.github.kituin.chatimage.tool.SimpleUtil.composeGenericOptionComponent; | ||
import static io.github.kituin.chatimage.tool.SimpleUtil.createButton; | ||
@OnlyIn(Dist.CLIENT) | ||
public class ConfigScreen extends ConfigRawScreen { | ||
public ConfigScreen(#Screen# screen) { | ||
super(createTranslatableComponent("config.chatimage.category"), screen); | ||
} | ||
|
||
protected void init() { | ||
super.init(); | ||
this.#kituin$addRenderableWidget#(createButton(this.width / 2 - 154, this.height / 4 + 24 - 16, 150, 20, getNsfw(CONFIG.nsfw), (p_96270_) -> { | ||
CONFIG.nsfw = !CONFIG.nsfw; | ||
p_96270_.setMessage(getNsfw(CONFIG.nsfw)); | ||
ChatImageConfig.saveConfig(CONFIG); | ||
}, #kituin$createButtonTooltip#(createTranslatableComponent("nsfw.chatimage.tooltip")))); | ||
this.#kituin$addRenderableWidget#(new GifSlider(this.width / 2 + 4, this.height / 4 + 24 - 16, 150, 20, createSliderTooltip(GifSlider.tooltip()))); | ||
this.#kituin$addRenderableWidget#(new TimeOutSlider(this.width / 2 - 154, this.height / 4 + 48 - 16, 150, 20, createSliderTooltip(TimeOutSlider.tooltip()))); | ||
this.#kituin$addRenderableWidget#(createButton(this.width / 2 + 4, this.height / 4 + 48 - 16, 150, 20, | ||
createTranslatableComponent("padding.chatimage.gui"), | ||
(button) -> { | ||
if (this.minecraft != null) { | ||
this.minecraft.setScreen(new LimitPaddingScreen(this)); | ||
} | ||
}, | ||
#kituin$createButtonTooltip#(createTranslatableComponent("padding.chatimage.tooltip")))); | ||
this.#kituin$addRenderableWidget#(createButton(this.width / 2 - 154, this.height / 4 + 72 - 16, 150, 20, getCq(CONFIG.cqCode), (button) -> { | ||
CONFIG.cqCode = !CONFIG.cqCode; | ||
button.setMessage(getCq(CONFIG.cqCode)); | ||
ChatImageConfig.saveConfig(CONFIG); | ||
}, #kituin$createButtonTooltip#(createTranslatableComponent("cq.chatimage.tooltip")))); | ||
this.#kituin$addRenderableWidget#(createButton(this.width / 2 + 4, this.height / 4 + 72 - 16, 150, 20,getDrag(CONFIG.dragUseCicode), (button) -> { | ||
CONFIG.dragUseCicode = !CONFIG.dragUseCicode; | ||
button.setMessage(getDrag(CONFIG.dragUseCicode)); | ||
ChatImageConfig.saveConfig(CONFIG); | ||
},#kituin$createButtonTooltip#(createTranslatableComponent("drag.chatimage.tooltip")))); | ||
this.#kituin$addRenderableWidget#(createButton(this.width / 2 - 154, this.height / 4 + 96 - 16, 150, 20,getUri(CONFIG.checkImageUri), (button) -> { | ||
CONFIG.checkImageUri = !CONFIG.checkImageUri; | ||
button.setMessage(getUri(CONFIG.checkImageUri)); | ||
ChatImageConfig.saveConfig(CONFIG); | ||
})); | ||
this.#kituin$addRenderableWidget#(createButton(this.width / 2 - 77, this.height / 4 + 120 - 16, 150, 20, | ||
createTranslatableComponent("gui.back"), | ||
(button) -> { | ||
if (this.minecraft != null) { | ||
this.minecraft.setScreen(this.parent); | ||
} | ||
})); | ||
} | ||
|
||
private #MutableComponent# getCq(boolean enable) { | ||
return getEnable( "cq.chatimage.gui", enable); | ||
} | ||
private #MutableComponent# getNsfw(boolean enable) { | ||
return getEnable( "nsfw.chatimage.gui", !enable); | ||
} | ||
private #MutableComponent# getDrag(boolean enable) { | ||
return getEnable("drag.chatimage.gui", enable); | ||
} | ||
private #MutableComponent# getUri(boolean enable) { | ||
return getEnable("uri.chatimage.gui", enable); | ||
} | ||
public static #MutableComponent# getEnable(String key, boolean enable) | ||
{ | ||
return composeGenericOptionComponent(createTranslatableComponent(key), createTranslatableComponent((enable ? "open" : "close") + ".chatimage.common")); | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
forge/origin/src/main/java/io/github/kituin/chatimage/gui/ConfirmNsfwScreen.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,45 @@ | ||
package io.github.kituin.chatimage.gui; | ||
|
||
import it.unimi.dsi.fastutil.booleans.BooleanConsumer; | ||
import net.minecraft.client.gui.screens.ConfirmScreen; | ||
import net.minecraft.network.chat.CommonComponents; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.api.distmarker.OnlyIn; | ||
|
||
import static io.github.kituin.chatimage.tool.SimpleUtil.*; | ||
|
||
@OnlyIn(Dist.CLIENT) | ||
public class ConfirmNsfwScreen extends ConfirmScreen { | ||
|
||
public ConfirmNsfwScreen(BooleanConsumer callback, String link) { | ||
this(callback, createTranslatableComponent("nsfw.chatimage.open"), createLiteralComponent(link)); | ||
} | ||
|
||
public ConfirmNsfwScreen(BooleanConsumer callback, #Component# title, #Component# message) { | ||
super(callback, title, message); | ||
this.yesButton = CommonComponents.GUI_YES; | ||
this.noButton = CommonComponents.GUI_NO; | ||
} | ||
|
||
@Override | ||
protected void addButtons(int y) { | ||
this.#kituin$addRenderableWidget#(createButton(this.width / 2 - 50 - 52, y, 100, 20, this.yesButton, | ||
(button) -> this.callback.accept(true))); | ||
this.#kituin$addRenderableWidget#(createButton(this.width / 2 - 50 + 52, y, 100, 20, this.noButton, | ||
(button) -> this.callback.accept(false))); | ||
} | ||
|
||
@Override | ||
public void render(#GuiGraphics# matrixStack, int mouseX, int mouseY, float partialTicks) { | ||
super.render(matrixStack, mouseX, mouseY, partialTicks); | ||
// IF <= forge-1.19 | ||
// renderBackground(matrixStack); | ||
// drawCenteredString(matrixStack, this.font, | ||
// title, this.width / 2, this.height / 4 - 16, 16764108); | ||
// ELSE | ||
// renderBackground(matrixStack, mouseX, mouseY, partialTicks); | ||
// matrixStack.drawCenteredString(this.font, | ||
// createTranslatableComponent("nsfw.chatimage.warning"), this.width / 2, 110, 16764108); | ||
// END IF | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
forge/origin/src/main/java/io/github/kituin/chatimage/gui/LimitPaddingScreen.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,43 @@ | ||
package io.github.kituin.chatimage.gui; | ||
|
||
import io.github.kituin.chatimage.widget.LimitSlider; | ||
import io.github.kituin.chatimage.widget.PaddingSlider; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.api.distmarker.OnlyIn; | ||
|
||
import static io.github.kituin.chatimage.ChatImage.CONFIG; | ||
import static io.github.kituin.chatimage.tool.SimpleUtil.createTranslatableComponent; | ||
import static io.github.kituin.chatimage.tool.SimpleUtil.createButton; | ||
|
||
@OnlyIn(Dist.CLIENT) | ||
public class LimitPaddingScreen extends ConfigRawScreen { | ||
|
||
|
||
public LimitPaddingScreen(#Screen# screen) { | ||
super(createTranslatableComponent("padding.chatimage.gui"), screen); | ||
} | ||
|
||
protected void init() { | ||
super.init(); | ||
|
||
#kituin$addRenderableWidget#(new PaddingSlider(this.width / 2 - 154, this.height / 4 + 24 + -16, 150, 20, createTranslatableComponent("left.padding.chatimage.gui"), | ||
CONFIG.paddingLeft, (float) this.width / 2, PaddingSlider.PaddingType.LEFT, createSliderTooltip(PaddingSlider.tooltip(PaddingSlider.PaddingType.LEFT)))); | ||
#kituin$addRenderableWidget#(new PaddingSlider(this.width / 2 + 4, this.height / 4 + 24 + -16, 150, 20, createTranslatableComponent("right.padding.chatimage.gui"), | ||
CONFIG.paddingRight, (float) this.width / 2, PaddingSlider.PaddingType.RIGHT, createSliderTooltip(PaddingSlider.tooltip(PaddingSlider.PaddingType.RIGHT)))); | ||
#kituin$addRenderableWidget#(new PaddingSlider(this.width / 2 - 154, this.height / 4 + 48 + -16, 150, 20, createTranslatableComponent("top.padding.chatimage.gui"), | ||
CONFIG.paddingTop, (float) this.height / 2, PaddingSlider.PaddingType.TOP, createSliderTooltip(PaddingSlider.tooltip(PaddingSlider.PaddingType.TOP)))); | ||
#kituin$addRenderableWidget#(new PaddingSlider(this.width / 2 + 4, this.height / 4 + 48 + -16, 150, 20, createTranslatableComponent("bottom.padding.chatimage.gui"), | ||
CONFIG.paddingBottom, (float) this.height / 2, PaddingSlider.PaddingType.BOTTOM, createSliderTooltip(PaddingSlider.tooltip(PaddingSlider.PaddingType.BOTTOM)))); | ||
#kituin$addRenderableWidget#(new LimitSlider(this.width / 2 - 154, this.height / 4 + 72 + -16, 150, 20, createTranslatableComponent("width.limit.chatimage.gui"), | ||
CONFIG.limitWidth, this.width, LimitSlider.LimitType.WIDTH, createSliderTooltip(LimitSlider.tooltip(LimitSlider.LimitType.WIDTH)))); | ||
#kituin$addRenderableWidget#(new LimitSlider(this.width / 2 + 4, this.height / 4 + 72 + -16, 150, 20, createTranslatableComponent("height.limit.chatimage.gui"), | ||
CONFIG.limitHeight, this.height, LimitSlider.LimitType.HEIGHT, createSliderTooltip(LimitSlider.tooltip(LimitSlider.LimitType.HEIGHT)))); | ||
#kituin$addRenderableWidget#(createButton(this.width / 2 - 77, this.height / 4 + 96 - 16, 150, 20, | ||
createTranslatableComponent("gui.back"), | ||
(button) -> { | ||
if (this.minecraft != null) { | ||
this.minecraft.setScreen(this.parent); | ||
} | ||
})); | ||
} | ||
} |
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.