|
20 | 20 | import gregtech.api.pattern.PatternMatchContext; |
21 | 21 | import gregtech.api.unification.material.Materials; |
22 | 22 | import gregtech.api.util.GTUtility; |
| 23 | +import gregtech.api.util.KeyUtil; |
23 | 24 | import gregtech.api.util.RelativeDirection; |
24 | 25 | import gregtech.api.util.TextComponentUtil; |
25 | 26 | import gregtech.api.util.TextFormattingUtil; |
|
55 | 56 | import codechicken.lib.render.pipeline.IVertexOperation; |
56 | 57 | import codechicken.lib.vec.Matrix4; |
57 | 58 | import com.cleanroommc.modularui.api.drawable.IKey; |
| 59 | +import com.cleanroommc.modularui.api.drawable.IRichTextBuilder; |
| 60 | +import com.cleanroommc.modularui.value.sync.BooleanSyncValue; |
58 | 61 | import com.cleanroommc.modularui.value.sync.DoubleSyncValue; |
59 | 62 | import com.cleanroommc.modularui.value.sync.IntSyncValue; |
60 | 63 | import com.cleanroommc.modularui.value.sync.PanelSyncManager; |
@@ -453,6 +456,79 @@ protected void addErrorText(List<ITextComponent> textList) { |
453 | 456 | } |
454 | 457 | } |
455 | 458 |
|
| 459 | + @Override |
| 460 | + protected MultiblockUIFactory createUIFactory() { |
| 461 | + IntSyncValue curCWUt = new IntSyncValue(() -> hpcaHandler.cachedCWUt, null); |
| 462 | + IntSyncValue maxCWUt = new IntSyncValue(hpcaHandler::getMaxCWUt, null); |
| 463 | + BooleanSyncValue hasNoEnergy = new BooleanSyncValue(() -> hasNotEnoughEnergy, null); |
| 464 | + DoubleSyncValue temp = new DoubleSyncValue(() -> temperature, null); |
| 465 | + |
| 466 | + return new MultiblockUIFactory(this) |
| 467 | + .syncValue("cur_cwut", curCWUt) |
| 468 | + .syncValue("max_cwut", maxCWUt) |
| 469 | + .syncValue("no_energy", hasNoEnergy) |
| 470 | + .syncValue("temp", temp) |
| 471 | + .configureDisplayText(builder -> builder |
| 472 | + .setWorkingStatus(() -> true, () -> hpcaHandler.getAllocatedCWUt() > 0) |
| 473 | + .setWorkingStatusKeys( |
| 474 | + "gregtech.multiblock.idling", |
| 475 | + "gregtech.multiblock.idling", |
| 476 | + "gregtech.multiblock.data_bank.providing") |
| 477 | + .addCustom(richText -> { |
| 478 | + if (!isStructureFormed()) return; |
| 479 | + |
| 480 | + // Energy Usage |
| 481 | + String voltageName = GTValues.VNF[GTUtility.getTierByVoltage(hpcaHandler.getMaxEUt())]; |
| 482 | + richText.addLine(KeyUtil.lang(TextFormatting.GRAY, |
| 483 | + "gregtech.multiblock.hpca.energy", |
| 484 | + TextFormattingUtil.formatNumbers(curCWUt.getIntValue()), |
| 485 | + TextFormattingUtil.formatNumbers(maxCWUt.getIntValue()), |
| 486 | + voltageName)); |
| 487 | + |
| 488 | + // Provided Computation |
| 489 | + IKey cwutInfo = KeyUtil.string(TextFormatting.AQUA, |
| 490 | + curCWUt.getIntValue() + " / " + maxCWUt.getIntValue() + " CWU/t"); |
| 491 | + |
| 492 | + richText.addLine(KeyUtil.lang(TextFormatting.GRAY, |
| 493 | + "gregtech.multiblock.hpca.computation", |
| 494 | + cwutInfo)); |
| 495 | + }) |
| 496 | + .addWorkingStatusLine()) |
| 497 | + .configureWarningText(builder -> builder |
| 498 | + .addLowPowerLine(hasNoEnergy.getBoolValue()) |
| 499 | + .addCustom(richText -> { |
| 500 | + if (!isStructureFormed()) return; |
| 501 | + |
| 502 | + if (temp.getDoubleValue() > 500) { |
| 503 | + // Temperature warning |
| 504 | + richText.add(KeyUtil.lang( |
| 505 | + TextFormatting.YELLOW, |
| 506 | + "gregtech.multiblock.hpca.warning_temperature")); |
| 507 | + |
| 508 | + // Active cooler overdrive warning |
| 509 | + richText.add(KeyUtil.lang( |
| 510 | + TextFormatting.GRAY, |
| 511 | + "gregtech.multiblock.hpca.warning_temperature_active_cool")); |
| 512 | + } |
| 513 | + |
| 514 | + // Structure warnings |
| 515 | + // hpcaHandler.addWarnings(richText); |
| 516 | + hpcaHandler.addWarnings2(richText); |
| 517 | + }) |
| 518 | + .addMaintenanceProblemLines(getMaintenanceProblems())) |
| 519 | + .configureErrorText(builder -> builder |
| 520 | + .addCustom(richText -> { |
| 521 | + if (!isStructureFormed()) return; |
| 522 | + |
| 523 | + if (temp.getDoubleValue() > 1000) { |
| 524 | + richText.addLine(KeyUtil.lang(TextFormatting.RED, |
| 525 | + "gregtech.multiblock.hpca.error_temperature")); |
| 526 | + } |
| 527 | + // hpcaHandler.addErrors(textList); |
| 528 | + hpcaHandler.addErrors2(richText); |
| 529 | + })); |
| 530 | + } |
| 531 | + |
456 | 532 | @Override |
457 | 533 | public void addInformation(ItemStack stack, @Nullable World world, @NotNull List<String> tooltip, |
458 | 534 | boolean advanced) { |
@@ -923,6 +999,37 @@ public void addErrors(List<ITextComponent> textList) { |
923 | 999 | } |
924 | 1000 | } |
925 | 1001 |
|
| 1002 | + public void addWarnings2(IRichTextBuilder<?> richText) { |
| 1003 | + List<IKey> warnings = new ArrayList<>(); |
| 1004 | + if (numBridges > 1) { |
| 1005 | + warnings.add(KeyUtil.lang(TextFormatting.GRAY, |
| 1006 | + "gregtech.multiblock.hpca.warning_multiple_bridges")); |
| 1007 | + } |
| 1008 | + if (computationProviders.isEmpty()) { |
| 1009 | + warnings.add(KeyUtil.lang(TextFormatting.GRAY, |
| 1010 | + "gregtech.multiblock.hpca.warning_no_computation")); |
| 1011 | + } |
| 1012 | + if (getMaxCoolingDemand() > getMaxCoolingAmount()) { |
| 1013 | + warnings.add(KeyUtil.lang(TextFormatting.GRAY, |
| 1014 | + "gregtech.multiblock.hpca.warning_low_cooling")); |
| 1015 | + } |
| 1016 | + if (!warnings.isEmpty()) { |
| 1017 | + richText.addLine(KeyUtil.lang(TextFormatting.YELLOW, |
| 1018 | + "gregtech.multiblock.hpca.warning_structure_header")); |
| 1019 | + warnings.forEach(richText::addLine); |
| 1020 | + } |
| 1021 | + } |
| 1022 | + |
| 1023 | + public void addErrors2(IRichTextBuilder<?> richText) { |
| 1024 | + for (IHPCAComponentHatch component : components) { |
| 1025 | + if (component.isDamaged()) { |
| 1026 | + richText.addLine(KeyUtil.lang(TextFormatting.RED, |
| 1027 | + "gregtech.multiblock.hpca.error_damaged")); |
| 1028 | + return; |
| 1029 | + } |
| 1030 | + } |
| 1031 | + } |
| 1032 | + |
926 | 1033 | public TextureArea getComponentTexture(int index) { |
927 | 1034 | if (components.size() <= index) { |
928 | 1035 | return GuiTextures.BLANK_TRANSPARENT; |
|
0 commit comments