Skip to content

Commit

Permalink
#renderSearchAndContextMenuStuff sync
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbuilder1961 committed Nov 25, 2024
1 parent 5f6497e commit fe416e7
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions src/main/java/obro1961/chatpatches/mixin/gui/ChatScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.client.gui.hud.ChatHud;
import net.minecraft.client.gui.hud.ChatHudLine;
import net.minecraft.client.gui.hud.MessageIndicator;
import net.minecraft.client.gui.screen.ChatInputSuggestor;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.tooltip.Tooltip;
Expand Down Expand Up @@ -149,14 +150,35 @@ protected void initSearchStuff(CallbackInfo ci) {
}

/**
* Renders everything needed for the revamped ChatScreen,
* including the search bar, button, error, settings
* menu, and the context menu.
* */
* @implNote In order, renders:
* <ol>
* <li>(Everything shifted backwards on the Z-axis in
* order to render under the {@link ChatInputSuggestor}
* and suggestion text)</li>
* <li>The {@link #searchButton}</li>
* <li>If the search bar should show:</li>
* <ol>
* <li>The {@link #searchField} background</li>
* <li>The {@link #searchField} itself</li>
* <li>If it isn't null, the {@link #searchError}</li>
* </ol>
* <li>If the settings menu should show:</li>
* <ol>
* <li>The settings menu background</li>
* <li>The setting buttons themselves</li>
* </ol>
* <li>If the copy menu has been loaded and should show:</li>
* <ol>
* <li>The outline around the selected chat message</li>
* <li>The copy menu buttons (the menu itself)</li>
* </ol>
* </ol>
*/
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(Lnet/minecraft/client/gui/DrawContext;IIF)V"))
private void renderSearchAndContextMenuStuff(DrawContext context, int mX, int mY, float delta, CallbackInfo ci) {
context.getMatrices().push();
context.getMatrices().translate(0, 0, -1); // easiest fix to render everything effectively under the ChatInputSuggestor (#186)

searchButton.render(context, mX, mY, delta);
if(showSearch && !config.hideSearchButton) {
context.fill(SEARCH_X - 2, height + SEARCH_Y_OFFSET - 2, (int) (width * (SEARCH_W_MULT + 0.06)), height + SEARCH_Y_OFFSET + SEARCH_H - 2, client.options.getTextBackgroundColor(Integer.MIN_VALUE));
Expand All @@ -183,9 +205,9 @@ private void renderSearchAndContextMenuStuff(DrawContext context, int mX, int mY

//todo does this make sense? what about !showSettingsMenu? experiment.
// renders the context menu if the settings menu is not open
if(!isMouseOverSettingsMenu(mX, mY)) {
if(!isMouseOverSettingsMenu(mX, mY))
contextMenu.render(context, mX, mY, delta);
}

context.getMatrices().pop();
}

Expand Down

0 comments on commit fe416e7

Please sign in to comment.