Hacky resize to update the title bar on game launch. (fixes #1)
I don't believe there is a better way to do this.
This commit is contained in:
parent
a5e20da017
commit
fa2b490aec
|
@ -49,8 +49,10 @@ public class DarkTitleBar {
|
|||
);
|
||||
mem.close();
|
||||
|
||||
// we have to "refresh" the window for the titlebar to appear without resizing.
|
||||
// this seems to work.
|
||||
w.applyVideoMode();
|
||||
// this is a very hacky way to invalidate the title bar, so it appears as dark correctly
|
||||
// without having the user resize the window
|
||||
int oldWidth = w.getWidth();
|
||||
w.setWindowedSize(oldWidth + 2, w.getHeight());
|
||||
w.setWindowedSize(oldWidth, w.getHeight());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
package tech.williamist.darktitlebar.mixin;
|
||||
|
||||
import net.minecraft.client.WindowSettings;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.RunArgs;
|
||||
import net.minecraft.client.util.Window;
|
||||
import net.minecraft.client.util.WindowProvider;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import tech.williamist.darktitlebar.DarkTitleBar;
|
||||
|
||||
@Mixin(WindowProvider.class)
|
||||
@Mixin(MinecraftClient.class)
|
||||
public class WindowCreateMixin {
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "createWindow")
|
||||
public void createWindow(WindowSettings settings, String videoMode, String title, CallbackInfoReturnable<Window> cir) {
|
||||
DarkTitleBar.setDarkTitlebar(cir.getReturnValue());
|
||||
@Shadow @Final private Window window;
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "<init>")
|
||||
public void createWindow(RunArgs args, CallbackInfo ci) {
|
||||
DarkTitleBar.setDarkTitlebar(window);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue