Skip to content

Commit

Permalink
Fix #90
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanPB committed Feb 22, 2022
1 parent 5b246e4 commit 83ee129
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,28 +168,28 @@ class DeepLearnerScreenHandler (
if (currentDataModel == null) {
dataAmount.text = LiteralText("")
dataTier.text = LiteralText("")
} else {
} else if (FabricLoader.getInstance().environmentType == EnvType.CLIENT) {
dataAmount.text =
RenderUtils.getTextWithDefaultTextColor(TranslatableText("tooltip.${MOD_ID}.data_amount.1"), world)
?.append(TranslatableText("tooltip.${MOD_ID}.data_amount.2", currentDataModel.dataAmount, currentDataModel.tier().nextTierOrCurrent().dataAmount).formatted(Formatting.WHITE))
.append(TranslatableText("tooltip.${MOD_ID}.data_amount.2", currentDataModel.dataAmount, currentDataModel.tier().nextTierOrCurrent().dataAmount).formatted(Formatting.WHITE))

dataTier.text =
RenderUtils.getTextWithDefaultTextColor(TranslatableText("tooltip.${MOD_ID}.tier.1"), world)
?.append(TranslatableText("tooltip.${MOD_ID}.tier.2", currentDataModel.tier().text))
.append(TranslatableText("tooltip.${MOD_ID}.tier.2", currentDataModel.tier().text))
}
}

fun updateEntityInformation() {
if(showcase.entityType != null) {
if(showcase.entityType != null && FabricLoader.getInstance().environmentType == EnvType.CLIENT) {
entityName.text =
RenderUtils.getTextWithDefaultTextColor(TranslatableText("tooltip.${MOD_ID}.deep_learner.entityName.1"), world)
?.append(TranslatableText("tooltip.${MOD_ID}.deep_learner.entityName.2",
.append(TranslatableText("tooltip.${MOD_ID}.deep_learner.entityName.2",
showcase.entityType!!.name).formatted(Formatting.WHITE))

entityHealth.text =
RenderUtils.getTextWithDefaultTextColor(TranslatableText("tooltip.${MOD_ID}.deep_learner.entityHealth.1"), world)
?.append(LiteralText("").formatted(Formatting.RED))
?.append(TranslatableText("tooltip.${MOD_ID}.deep_learner.entityHealth.2",
.append(LiteralText("").formatted(Formatting.RED))
.append(TranslatableText("tooltip.${MOD_ID}.deep_learner.entityHealth.2",
(EntityTypeMixin.invokeNewInstance(world, showcase.entityType) as LivingEntity).maxHealth).formatted(Formatting.WHITE))
}
}
Expand Down Expand Up @@ -252,4 +252,4 @@ class DeepLearnerScreenHandler (
return RenderUtils.getDefaultTextColor(world)
}

}
}
8 changes: 5 additions & 3 deletions base/src/main/kotlin/dev/nathanpb/dml/utils/RenderUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class RenderUtils {

companion object {
private const val TITLE_COLOR: Int = 0x04FCC4
val DEFAULT_BACKGROUND_PAINTER: BackgroundPainter = BackgroundPainter.createNinePatch(identifier("textures/gui/dml_background_painter.png"))
val DEFAULT_BACKGROUND_PAINTER by lazy {
BackgroundPainter.createNinePatch(identifier("textures/gui/dml_background_painter.png"))
}
val DML_WIDGETS: Identifier = identifier("textures/gui/dml_widgets.png")
val PROGRESS_BAR: Identifier = identifier("textures/gui/progress_bar.png")
val PROGRESS_BAR_BACKGROUND: Identifier = identifier("textures/gui/progress_bar_background.png")
Expand All @@ -47,8 +49,8 @@ class RenderUtils {
return if(world.isClient()) TITLE_COLOR else WLabel.DEFAULT_TEXT_COLOR
}

fun getTextWithDefaultTextColor(text: MutableText?, world: World): MutableText? {
return text!!.setStyle(Style.EMPTY.withColor(getDefaultTextColor(world)))
fun getTextWithDefaultTextColor(text: MutableText, world: World): MutableText {
return text.setStyle(Style.EMPTY.withColor(getDefaultTextColor(world)))
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class WModularEffectToggle(
world: World
) : WToggleButton() {
var effect by Delegates.observable<ModularEffect<*>?>(null) { _, _, value ->
setLabel(RenderUtils.getTextWithDefaultTextColor(value?.name?.append(""), world) ?: LiteralText(""))
setLabel(
value?.name?.let {
RenderUtils.getTextWithDefaultTextColor(it, world)
} ?: LiteralText("")
)
}
}

0 comments on commit 83ee129

Please sign in to comment.