mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-21 04:42:17 +00:00
The Mergening (#13)
* ThreadedTessellator -> RenderBlocks instance Tessellator * Plus a CME workaround until I can figure out why it's happening * One inject with multiple methods instead of two injects * Add AF's Tessellator#reset mixin Fixes screen flashing when chunks are being built * Thread Saftey * Make each tesselator use its own ByteBuffer * Don't make RecyclingList a static variable 🤦 * Add some additions via ITessellatorInstance * Stop using builtin updateRenderers * Remove a few unused things in MixinTessellator * Remove useless casting due to implementing the interface * Overwrite some more rendering methods to ensure they're not used * Implement IBlockAccess on WorldSlice * Currently just proxies to the World... need to get it to use the local cache * Make WorldSlice use its copied values instead of using the world * block, meta, and light. Still need TODO biome * Finish making WorldSlice thread safe * Remove last unsafe this.world accesses * Copy biomeData * Implement getTileEntity(), and getBiomeGenForCoords() * Remove unused 1.16+ classes - Biome, Colorizer, and ColorBlender related * Cache worldHeight instead of asking the provider every time * Debug Screen updates * Disable Culling for now (until it works) * Tessellator Updates * Use one instance on the main thread, and individual instances on every other thread * Prevent draw() and buffer.reset() on non singleton instance * Misc cleanup, maybe better growBuffer? * Fixing splash screen and GUI issues by excluding SplashProgress from GLStateManager transformer * Update docs * Fixing a one line in SodiumWorldRenderer that allows the game setting for the distance at which entities will render. Hope it's not too bad mitch :) * TileEntites now render * Less silly transparency * Removing clamp implementation because I missed the one in mathhelper * Initial sodium entity smooth lighting * Fix entity smooth lighting * Fix lerp uses and use render layers properly (#17) * Remove some uses of blockstate + patch FluidState * Fix lerp * Enable Sodium fluid rendering * Update FluidRenderer.java * Rewind buffers when copying * Fix multidraw * Force cutout on all non-translucent blocks * Let vanilla handle render pass state * Rewrite render layer check to use Forge 1.7 hook * Fix skylight handling * Fix flickering * Clone TEs correctly * Fixing entityDistMulti (I think) * Fix TEs rendering on the wrong pass * Buff max render distance to 32 Pretty useless since the integrated server stalls instantly, but our renderer supports it * Fix fog * Fix render distance changes being ignored * Implement entity culling * Block face culling * Re-enable occlusion culling * Fix x/z coordinate mixup when indexing biome arrays Partially fixes wrong biome colors, but at chunk edges it's still wrong because neighboring chunks aren't accessed * Make a copy of biome data The old code seemed to work fine but this should be safer * Make CompatMemoryUtil#memReallocDirect preserve buffer position LWJGL3's MemoryUtil#memRealloc does this, see its javadoc. Fixes screen flashing and this error getting printed when indirect buffer grows: GL_INVALID_OPERATION error generated. Bound draw indirect buffer is not large enough. * Use biome data of neighboring chunk sections Fixes wrong colors at chunk edges * Re-enable fog culling * Tile entity culling * Remove some unneeded Sodium code * Massive code cleanup * Avoids errors when usin lwjglxdebug * Bump hodgepodge dep * Add AngelicaConfig * Add Mixin to disable MC's builtin checkGLError * Add configs for iris/sodium * Iris work * Move some StateNotifiers to GLStateManager * Remove some redundant mixins based on sodium/angelica work and rendering state captures * Add Iris DebugScreenHandler * rm archaicfix's occlusion renderer and threaded updates * Implemented Sodium's GUI and a couple of setting fixes (#20) * Ported Sodium's GUI * Correct AO * Fixed Vignette * Re-enable DirectMemoryAccess * Adds some code from lwjgl3 in CompatMemoryUtil.java * Re-add *Unsafe classes * Remove MixinWorldRenderer * Add NEID (mixin pr) support * Only shadow runtime module of antlr4 Reduces jar size by 11 mb * Update NotFine * Make LongHashMap actually perform like a hash map * Options GUI Fixes and some option implementations (#22) * Correct useNoErrorGLContext option * Added translucency sorting option * Implemented Particle Culling gives real fps boost, however, it's not as big as i thought * Begin implementing animateOnlyVisibleTextures * Correct Donation page opening * Fixed Shift + P Now it uses NotFine's GUI, but it think that NotFine's GUI should be rewrited for using other config options * Correct URL's for Linux * second code cleanup in particle culling * Fix incorrect TE map population * Add optional assertMainThread behind `-Dangelica.assertMainThread=true` * Add back air optimization, but only apply to vanilla air * Implement more options (#23) * Combine free regions in GlBufferArena * Clear global block entity list when initializing renderer * AF, CompileStubs, and SplashProgress Remove most of ArchaicFix * Move a few mixins over to angelica * Disable if org.lwjgl.util.Debug is set * Only enable Iris/lwjgl debug callbacks if org.lwjgl.util.Debug is set * Rewrite Tessellator hacks - now using a ThreadLocal instead of only patching RenderBlocks * Reenable AF mixins, switch to cached debug var, disable incompatible mixins * Remove AF deps and a late mixin that was missed * Add Iris Sodium Compat impl * Fix Sodium GLProgram to use ResourceLocation instead of Identifier * Start applying Iris -> Sodium Mixins * Make NotFine menu open if holding shift * Fixed Tessellators in production env * Finish Sodium Fluid Renderer (#24) * Init and pass Sodium LightPipelines * Remove registry lookup and refactor WorldUtil * Hook up lighting pipeline * Patch fluid velocity * It's alive! Sodium Fluid Renderer is alive! * Fix face culling not taking third person camera offset into account * rewrite ACTEntityRenderer to stop transforming ALL the classes * use ClassConstantPoolParser in TessellatorTransformer to speed up search for Tessellator references * use ClassConstantPoolParser in GLStateManagerTransformer to speed up search for class references * rewrite GLStateManagerTransformer and TessellatorTransformer * merge GLStateManagerTransfor and TessellatorTransformer into one Transformer * Fixed smooth lighting rendering * Iris block_id Mixins & BlockStateIdMap initial impl for 1.7.10 * Fix running with lwjgl debug flag & Cleanup old ShadersMod transformers * Initialize GLStateManager via Mixins instead of all in the static block * Clean up chunk load/unload tracking, fix chunks rendering without neighbors sometimes * Fix occlusion culler not re-running after important uploads Backport of https://github.com/CaffeineMC/sodium-fabric/pull/755 * Add chunks to queues without going through occlusion culler Partially reverts the previous chunk tracking commit, because that logic will reintroduce https://github.com/CaffeineMC/sodium-fabric/issues/605 As long as we only rebuild with neighbors present, we shouldn't see the visual seams * Extremely primitive synchronization approach for ISBRH * Use factory for Spdium menu createElement outputs This will allow NotFine to use Sodium menu elements and vice versa in a future commit. * Splash Screen Compat * Separate remaining NamedState enums * NotFine but it loads Sodium pages * Hook up NotFine optimizations * Hook up some NotFine features * copy over hud caching code from hodgepodge * backport glstatemanager mixin * Track thread that currently owns the GL Context in addition to the main thread. * First pass over FontRenderer, 1300->1400 FPS on my GPU when showing F3 Done: - A batching vertex buffer builder for font output - Reduction in drawcalls from 1-3 per character to 1 per font atlas switch - Mixin to draw the entire F3 screen in one batch, instead of separate batches per line TODO: - Switch drawing to a VBO - Cache string meshes across frames - Cache string width calculations used for layouts - Multidraw to reduce draw calls even further * Add JVM flag to bypass GL state caching * Push/Pop Attrib Hacks -- to be evolved later * Fix FontRenderer+SplashScreen combo * HUDCaching tweaks * Add license * Jabba Compat, and reset tesselator state even if the chunk render thread blows up * Initial Xaero's World Map + Minimap Support * Disable Fastcraft & Optifine if present * Iris Progress * Wire up more Iris mixins, informing pipeline stages. Still not rendering anything visible. * Don't try to transform the server * Avoid running biome generator on client in singleplayer * Call world biome retrieval methods instead of copying array directly (#25) * Shaders now do something! * Shadow Pass work * First shadow pass renders; however it moves all around when moving the camera... * Second shadow pass not running because it makes everything very very dark instead of just rendering translucents * Actually use the ShadowRenderer Model View when running the shadow pass... * Enable Sodium SmoothLightPipeline & Iris useSeparateAo * Avoid repeatedly copying biome data on each Y level (#27) * Celestial Rotation fixes * Water progress * Uniforms audit * Lightmap workaround * PBR compiling, stuck on Normal and Specular textures being added in * Shaderpack selection "works"; ShaderOptions TODO * Hud caching angelica (#28) * Potential hud-caching fix * Shader Options almost working ** Clicking on everything doesn't yet work, and the visuals are slightly off * Entity shadows seem to be working * Move glint fix to Mixin * Rework mouse handling for ShaderPackConfig * Stop centering shader options vertically * Angelica pbr (#31) * Only use Sodium light pipeline if useSeparateAo is on Sodium pipeline is still very buggy, so isolate it to Iris-only for now * Fix region sorting for translucency * Open Shaderpack now works on Linux * RM Shadersmod * Initial iris scrollbar clicking * Punt unsupported ISBRHs to the main thread * Delete the ISBRH lock, shouldn't be needed anymore * Render GT blocks on main thread * Require CCC 1.2.0+ * Depend on CCC 1.2 * Fix TESRs not being tracked for blocks rendered on main thread * Cut down number of runtime dependencies, enable CoreTweaks in dev by default * Add modern F3 background * Pull over some hodgepodge mixins --------- Co-authored-by: makamys <[email protected]> Co-authored-by: embeddedt <[email protected]> Co-authored-by: rjnasers <[email protected]> Co-authored-by: ah-OOG-ah <[email protected]> Co-authored-by: Ryan Nasers <[email protected]> Co-authored-by: Rad <[email protected]> Co-authored-by: Bogdan <[email protected]> Co-authored-by: Caedis <[email protected]> Co-authored-by: jss2a98aj <[email protected]> Co-authored-by: Alexdoru <[email protected]> Co-authored-by: Raven Szewczyk <[email protected]> Co-authored-by: mist475 <[email protected]> Co-authored-by: Ryan Nasers <[email protected]>
This commit is contained in:
942 files changed
+65828
-8640
No files matched your search
@@ -0,0 +1,512 @@
|
||||
package net.coderbot.iris.gui.screen;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.gui.GuiUtil;
|
||||
import net.coderbot.iris.gui.NavigationController;
|
||||
import net.coderbot.iris.gui.element.ShaderPackOptionList;
|
||||
import net.coderbot.iris.gui.element.ShaderPackSelectionList;
|
||||
import net.coderbot.iris.gui.element.shaderselection.ShaderPackEntry;
|
||||
import net.coderbot.iris.gui.element.widget.AbstractElementWidget;
|
||||
import net.coderbot.iris.gui.element.widget.CommentedElementWidget;
|
||||
import net.coderbot.iris.gui.element.widget.IrisButton;
|
||||
import net.coderbot.iris.gui.element.widget.IrisImageButton;
|
||||
import net.coderbot.iris.shaderpack.ShaderPack;
|
||||
import net.irisshaders.iris.api.v0.IrisApi;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ShaderPackScreen extends GuiScreen implements HudHideable {
|
||||
/**
|
||||
* Queue rendering to happen on top of all elements. Useful for tooltips or dialogs.
|
||||
*/
|
||||
public static final Set<Runnable> TOP_LAYER_RENDER_QUEUE = new HashSet<>();
|
||||
|
||||
private static final String SELECT_TITLE = I18n.format("pack.iris.select.title");
|
||||
private static final String CONFIGURE_TITLE = I18n.format("pack.iris.configure.title");
|
||||
private static final int COMMENT_PANEL_WIDTH = 314;
|
||||
|
||||
private final GuiScreen parent;
|
||||
private final String title;
|
||||
|
||||
private final String irisTextComponent;
|
||||
|
||||
private ShaderPackSelectionList shaderPackList;
|
||||
|
||||
private @Nullable ShaderPackOptionList shaderOptionList = null;
|
||||
private @Nullable NavigationController navigation = null;
|
||||
private GuiButton screenSwitchButton;
|
||||
|
||||
private String notificationDialog = null;
|
||||
private int notificationDialogTimer = 0;
|
||||
|
||||
private @Nullable AbstractElementWidget<?> hoveredElement = null;
|
||||
private Optional<String> hoveredElementCommentTitle = Optional.empty();
|
||||
private List<String> hoveredElementCommentBody = new ArrayList<>();
|
||||
private int hoveredElementCommentTimer = 0;
|
||||
|
||||
private boolean optionMenuOpen = false;
|
||||
|
||||
private boolean dropChanges = false;
|
||||
private static final String development = "Development Environment";
|
||||
private String developmentComponent;
|
||||
private String updateComponent;
|
||||
|
||||
private boolean guiHidden = false;
|
||||
private boolean dirty = false;
|
||||
private float guiButtonHoverTimer = 0.0f;
|
||||
|
||||
public ShaderPackScreen(GuiScreen parent) {
|
||||
this.title = I18n.format("options.iris.shaderPackSelection.title");
|
||||
|
||||
this.parent = parent;
|
||||
|
||||
String irisName = Iris.MODNAME; // + " " + Iris.getVersion(); // TEMP
|
||||
|
||||
if (Iris.INSTANCE.isDevelopmentEnvironment) {
|
||||
this.developmentComponent = "Development Environment";
|
||||
irisName = irisName.replace("-development-environment", "");
|
||||
}
|
||||
|
||||
this.irisTextComponent = irisName;
|
||||
|
||||
refreshForChangedPack();
|
||||
}
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float delta) {
|
||||
if(dirty) {
|
||||
dirty = false;
|
||||
this.initGui();
|
||||
}
|
||||
|
||||
if (this.mc.theWorld == null) {
|
||||
super.drawDefaultBackground();
|
||||
} else if (!this.guiHidden) {
|
||||
this.drawGradientRect(0, 0, width, height, 0x4F232323, 0x4F232323);
|
||||
}
|
||||
|
||||
if (!this.guiHidden) {
|
||||
if (optionMenuOpen && this.shaderOptionList != null) {
|
||||
this.shaderOptionList.drawScreen(mouseX, mouseY, delta);
|
||||
} else {
|
||||
this.shaderPackList.drawScreen(mouseX, mouseY, delta);
|
||||
}
|
||||
}
|
||||
|
||||
final float previousHoverTimer = this.guiButtonHoverTimer;
|
||||
super.drawScreen(mouseX, mouseY, delta);
|
||||
if (previousHoverTimer == this.guiButtonHoverTimer) {
|
||||
this.guiButtonHoverTimer = 0.0f;
|
||||
}
|
||||
|
||||
if (!this.guiHidden) {
|
||||
drawCenteredString(this.fontRendererObj, this.title, (int) (this.width * 0.5), 8, 0xFFFFFF);
|
||||
|
||||
if (notificationDialog != null && notificationDialogTimer > 0) {
|
||||
drawCenteredString(this.fontRendererObj, notificationDialog, (int) (this.width * 0.5), 21, 0xFFFFFF);
|
||||
} else {
|
||||
if (optionMenuOpen) {
|
||||
drawCenteredString(this.fontRendererObj, CONFIGURE_TITLE, (int) (this.width * 0.5), 21, 0xFFFFFF);
|
||||
} else {
|
||||
drawCenteredString(this.fontRendererObj, SELECT_TITLE, (int) (this.width * 0.5), 21, 0xFFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the comment panel
|
||||
if (this.isDisplayingComment()) {
|
||||
// Determine panel height and position
|
||||
final int panelHeight = Math.max(50, 18 + (this.hoveredElementCommentBody.size() * 10));
|
||||
final int x = (int) (0.5 * this.width) - 157;
|
||||
final int y = this.height - (panelHeight + 4);
|
||||
// Draw panel
|
||||
GuiUtil.drawPanel(x, y, COMMENT_PANEL_WIDTH, panelHeight);
|
||||
// Draw text
|
||||
this.fontRendererObj.drawStringWithShadow(this.hoveredElementCommentTitle.orElse(""), x + 4, y + 4, 0xFFFFFF);
|
||||
for (int i = 0; i < this.hoveredElementCommentBody.size(); i++) {
|
||||
this.fontRendererObj.drawStringWithShadow(this.hoveredElementCommentBody.get(i), x + 4, (y + 16) + (i * 10), 0xFFFFFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Render everything queued to drawScreen last
|
||||
for (Runnable render : TOP_LAYER_RENDER_QUEUE) {
|
||||
render.run();
|
||||
}
|
||||
TOP_LAYER_RENDER_QUEUE.clear();
|
||||
|
||||
if (this.developmentComponent != null) {
|
||||
this.fontRendererObj.drawStringWithShadow(developmentComponent, 2, this.height - 10, 0xFFFFFF);
|
||||
this.fontRendererObj.drawStringWithShadow(irisTextComponent, 2, this.height - 20, 0xFFFFFF);
|
||||
} else if (this.updateComponent != null) {
|
||||
this.fontRendererObj.drawStringWithShadow(updateComponent, 2, this.height - 10, 0xFFFFFF);
|
||||
this.fontRendererObj.drawStringWithShadow(irisTextComponent, 2, this.height - 20, 0xFFFFFF);
|
||||
} else {
|
||||
this.fontRendererObj.drawStringWithShadow(irisTextComponent, 2, this.height - 10, 0xFFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
final int bottomCenter = this.width / 2 - 50;
|
||||
final int topCenter = this.width / 2 - 76;
|
||||
final boolean inWorld = this.mc.theWorld != null;
|
||||
|
||||
this.shaderPackList = new ShaderPackSelectionList(this, this.mc, this.width, this.height, 32, this.height - 58, 0, this.width);
|
||||
|
||||
if (Iris.getCurrentPack().isPresent() && this.navigation != null) {
|
||||
final ShaderPack currentPack = Iris.getCurrentPack().get();
|
||||
|
||||
this.shaderOptionList = new ShaderPackOptionList(this, this.navigation, currentPack, this.mc, this.width, this.height, 32, this.height - 58, 0, this.width);
|
||||
this.navigation.setActiveOptionList(this.shaderOptionList);
|
||||
|
||||
this.shaderOptionList.rebuild();
|
||||
} else {
|
||||
optionMenuOpen = false;
|
||||
this.shaderOptionList = null;
|
||||
}
|
||||
|
||||
if (inWorld) {
|
||||
this.shaderPackList.setRenderBackground(false);
|
||||
if (shaderOptionList != null) {
|
||||
this.shaderOptionList.setRenderBackground(false);
|
||||
}
|
||||
}
|
||||
|
||||
this.buttonList.clear();
|
||||
|
||||
if (!this.guiHidden) {
|
||||
|
||||
this.buttonList.add(new IrisButton(bottomCenter + 104, this.height - 27, 100, 20,
|
||||
I18n.format("gui.done"), button -> this.onClose()));
|
||||
|
||||
this.buttonList.add(new IrisButton(bottomCenter, this.height - 27, 100, 20,
|
||||
I18n.format("options.iris.apply"), button -> this.applyChanges()));
|
||||
|
||||
this.buttonList.add(new IrisButton(bottomCenter - 104, this.height - 27, 100, 20,
|
||||
I18n.format("gui.cancel"), button -> this.dropChangesAndClose()));
|
||||
|
||||
this.buttonList.add(new IrisButton(topCenter - 78, this.height - 51, 152, 20,
|
||||
I18n.format("options.iris.openShaderPackFolder"), button -> this.openShaderPackFolder()));
|
||||
|
||||
this.screenSwitchButton = new IrisButton(topCenter + 78, this.height - 51, 152, 20,
|
||||
I18n.format("options.iris.shaderPackList"), button -> {
|
||||
this.optionMenuOpen = !this.optionMenuOpen;
|
||||
|
||||
// UX: Apply changes before switching screens to avoid unintuitive behavior
|
||||
//
|
||||
// Not doing this leads to unintuitive behavior, since selecting a pack in the
|
||||
// list (but not applying) would open the settings for the previous pack, rather
|
||||
// than opening the settings for the selected (but not applied) pack.
|
||||
this.applyChanges();
|
||||
|
||||
initGui();
|
||||
}
|
||||
);
|
||||
this.buttonList.add(this.screenSwitchButton);
|
||||
|
||||
refreshScreenSwitchButton();
|
||||
}
|
||||
|
||||
if (inWorld) {
|
||||
final String showOrHide = this.guiHidden
|
||||
? I18n.format("options.iris.gui.show")
|
||||
: I18n.format("options.iris.gui.hide");
|
||||
|
||||
final float endOfLastButton = this.width / 2.0f + 154.0f;
|
||||
final float freeSpace = this.width - endOfLastButton;
|
||||
final int x;
|
||||
if (freeSpace > 100.0f) {
|
||||
x = this.width - 50;
|
||||
} else if (freeSpace < 20.0f) {
|
||||
x = this.width - 20;
|
||||
} else {
|
||||
x = (int) (endOfLastButton + (freeSpace / 2.0f)) - 10;
|
||||
}
|
||||
|
||||
this.buttonList.add(new IrisImageButton(
|
||||
x, this.height - 39,
|
||||
20, 20,
|
||||
this.guiHidden ? 20 : 0, 146, 20,
|
||||
GuiUtil.IRIS_WIDGETS_TEX,
|
||||
button -> {
|
||||
this.guiHidden = !this.guiHidden;
|
||||
this.dirty = true;
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
// NB: Don't let comment remain when exiting options screen
|
||||
// https://github.com/IrisShaders/Iris/issues/1494
|
||||
this.hoveredElement = null;
|
||||
this.hoveredElementCommentTimer = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the mouse is clicked.
|
||||
*/
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
boolean handled = false;
|
||||
if (!this.guiHidden) {
|
||||
if (optionMenuOpen && this.shaderOptionList != null ) {
|
||||
handled = this.shaderOptionList.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
} else {
|
||||
handled = this.shaderPackList.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
if(!handled) {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the mouse is moved or a mouse button is released. Signature: (mouseX, mouseY, which) which==-1 is
|
||||
* mouseMove, which==0 or which==1 is mouseUp
|
||||
*/
|
||||
@Override
|
||||
protected void mouseMovedOrUp(int mouseX, int mouseY, int state) {
|
||||
boolean handled = false;
|
||||
if (!this.guiHidden && state != -1) {
|
||||
if (optionMenuOpen && this.shaderOptionList != null) {
|
||||
handled = this.shaderOptionList.mouseReleased(mouseX, mouseY, Mouse.getEventButton());
|
||||
} else {
|
||||
handled = this.shaderPackList.mouseReleased(mouseX, mouseY, Mouse.getEventButton());
|
||||
}
|
||||
}
|
||||
if(!handled) {
|
||||
super.mouseMovedOrUp(mouseX, mouseY, state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guiButton) {
|
||||
if(guiButton.enabled) {
|
||||
if(guiButton instanceof IrisButton irisButton) {
|
||||
irisButton.onPress();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshForChangedPack() {
|
||||
if (Iris.getCurrentPack().isPresent()) {
|
||||
final ShaderPack currentPack = Iris.getCurrentPack().get();
|
||||
|
||||
this.navigation = new NavigationController(currentPack.getMenuContainer());
|
||||
|
||||
if (this.shaderOptionList != null) {
|
||||
this.shaderOptionList.applyShaderPack(currentPack);
|
||||
this.shaderOptionList.rebuild();
|
||||
}
|
||||
} else {
|
||||
this.navigation = null;
|
||||
}
|
||||
|
||||
refreshScreenSwitchButton();
|
||||
}
|
||||
|
||||
public void refreshScreenSwitchButton() {
|
||||
if (this.screenSwitchButton != null) {
|
||||
this.screenSwitchButton.displayString = optionMenuOpen ? I18n.format("options.iris.shaderPackList") : I18n.format("options.iris.shaderPackSettings");
|
||||
this.screenSwitchButton.enabled = optionMenuOpen || shaderPackList.getTopButtonRow().shadersEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) {
|
||||
if (keyCode == Keyboard.KEY_ESCAPE) {
|
||||
if (this.guiHidden) {
|
||||
this.guiHidden = false;
|
||||
this.initGui();
|
||||
return;
|
||||
} else if (this.navigation != null && this.navigation.hasHistory()) {
|
||||
this.navigation.back();
|
||||
return;
|
||||
} else if (this.optionMenuOpen) {
|
||||
this.optionMenuOpen = false;
|
||||
this.initGui();
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
}
|
||||
|
||||
public void displayNotification(String String) {
|
||||
this.notificationDialog = String;
|
||||
this.notificationDialogTimer = 100;
|
||||
}
|
||||
|
||||
public void onClose() {
|
||||
if (!dropChanges) {
|
||||
applyChanges();
|
||||
} else {
|
||||
discardChanges();
|
||||
}
|
||||
|
||||
this.mc.displayGuiScreen(parent);
|
||||
}
|
||||
|
||||
private void dropChangesAndClose() {
|
||||
dropChanges = true;
|
||||
onClose();
|
||||
}
|
||||
|
||||
public void applyChanges() {
|
||||
final ShaderPackEntry entry = this.shaderPackList.getSelected();
|
||||
|
||||
this.shaderPackList.setApplied(entry);
|
||||
|
||||
final String name = entry.getPackName();
|
||||
|
||||
// If the pack is being changed, clear pending options from the previous pack to
|
||||
// avoid possible undefined behavior from applying one pack's options to another pack
|
||||
if (!name.equals(Iris.getCurrentPackName())) {
|
||||
Iris.clearShaderPackOptionQueue();
|
||||
}
|
||||
|
||||
final boolean enabled = this.shaderPackList.getTopButtonRow().shadersEnabled;
|
||||
|
||||
final String previousPackName = Iris.getIrisConfig().getShaderPackName().orElse(null);
|
||||
final boolean previousShadersEnabled = Iris.getIrisConfig().areShadersEnabled();
|
||||
|
||||
// Only reload if the pack would be different from before, or shaders were toggled, or options were changed, or if we're about to reset options.
|
||||
if (!name.equals(previousPackName) || enabled != previousShadersEnabled || !Iris.getShaderPackOptionQueue().isEmpty() || Iris.shouldResetShaderPackOptionsOnNextReload()) {
|
||||
Iris.getIrisConfig().setShaderPackName(name);
|
||||
IrisApi.getInstance().getConfig().setShadersEnabledAndApply(enabled);
|
||||
}
|
||||
|
||||
refreshForChangedPack();
|
||||
}
|
||||
|
||||
private void discardChanges() {
|
||||
Iris.clearShaderPackOptionQueue();
|
||||
}
|
||||
|
||||
private void openShaderPackFolder() {
|
||||
CompletableFuture.runAsync(() -> openUri(Iris.getShaderpacksDirectoryManager().getDirectoryUri()));
|
||||
}
|
||||
|
||||
private void openUri(URI uri) {
|
||||
switch (net.minecraft.util.Util.getOSType()) {
|
||||
case OSX -> {
|
||||
try {
|
||||
Runtime.getRuntime().exec(new String[] { "/usr/bin/open", uri.toString() });
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
case WINDOWS -> {
|
||||
try {
|
||||
Runtime.getRuntime().exec(new String[] { "rundll32", "url.dll,FileProtocolHandler", uri.toString() });
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
case LINUX -> {
|
||||
try {
|
||||
Runtime.getRuntime().exec(new String[] { "xdg-open", uri.toString() });
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
boolean openViaSystemClass = false;
|
||||
|
||||
try {
|
||||
final Class<?> aClass = Class.forName("java.awt.Desktop");
|
||||
final Object getDesktop = aClass.getMethod("getDesktop").invoke((Object) null);
|
||||
aClass.getMethod("browse", URI.class).invoke(getDesktop, uri);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
openViaSystemClass = true;
|
||||
}
|
||||
|
||||
if (openViaSystemClass) {
|
||||
AngelicaTweaker.LOGGER.debug("Opening via system class!");
|
||||
Sys.openURL("file://" + uri);
|
||||
}
|
||||
}
|
||||
|
||||
// Let the screen know if an element is hovered or not, allowing for accurately updating which element is hovered
|
||||
public void setElementHoveredStatus(AbstractElementWidget<?> widget, boolean hovered) {
|
||||
// TODO: Unused, but might be useful for shader options
|
||||
if (hovered && widget != this.hoveredElement) {
|
||||
this.hoveredElement = widget;
|
||||
|
||||
if (widget instanceof CommentedElementWidget) {
|
||||
this.hoveredElementCommentTitle = ((CommentedElementWidget<?>) widget).getCommentTitle();
|
||||
|
||||
Optional<String> commentBody = ((CommentedElementWidget<?>) widget).getCommentBody();
|
||||
if (!commentBody.isPresent()) {
|
||||
this.hoveredElementCommentBody.clear();
|
||||
} else {
|
||||
String rawCommentBody = commentBody.get();
|
||||
|
||||
// Strip any trailing "."s
|
||||
if (rawCommentBody.endsWith(".")) {
|
||||
rawCommentBody = rawCommentBody.substring(0, rawCommentBody.length() - 1);
|
||||
}
|
||||
// Split comment body into lines by separator ". "
|
||||
List<String> splitByPeriods = Arrays.stream(rawCommentBody.split("\\. [ ]*")).map(String::new).collect(Collectors.toList());
|
||||
// Line wrap
|
||||
this.hoveredElementCommentBody = new ArrayList<>();
|
||||
for (String text : splitByPeriods) {
|
||||
this.hoveredElementCommentBody.addAll(this.fontRendererObj.listFormattedStringToWidth(text, COMMENT_PANEL_WIDTH - 8));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.hoveredElementCommentTitle = Optional.empty();
|
||||
this.hoveredElementCommentBody.clear();
|
||||
}
|
||||
|
||||
this.hoveredElementCommentTimer = 0;
|
||||
} else if (!hovered && widget == this.hoveredElement) {
|
||||
this.hoveredElement = null;
|
||||
this.hoveredElementCommentTitle = Optional.empty();
|
||||
this.hoveredElementCommentBody.clear();
|
||||
this.hoveredElementCommentTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDisplayingComment() {
|
||||
return this.hoveredElementCommentTimer > 20 &&
|
||||
this.hoveredElementCommentTitle.isPresent() &&
|
||||
!this.hoveredElementCommentBody.isEmpty();
|
||||
}
|
||||
public void drawCenteredString(String text, int x, int y, int color) {
|
||||
this.drawCenteredString(this.fontRendererObj, text, x, y, color);
|
||||
}
|
||||
public void drawString(String text, int x, int y, int color) {
|
||||
this.drawString(this.fontRendererObj, text, x, y, color);
|
||||
}
|
||||
|
||||
|
||||
public FontRenderer getFontRenderer() {
|
||||
return this.fontRendererObj;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user