mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 16:24:23 +01:00
Fixed file select sppearing behind the window when experimental skin drop is disabled
This commit is contained in:
parent
0597d2b02c
commit
2b1ef25f96
3 changed files with 47 additions and 11 deletions
|
@ -269,7 +269,7 @@ public class GuiSkins extends GuiScreen implements FutureCallback<SkinUploadResp
|
|||
this.selectedSkin = null;
|
||||
this.localPlayer.releaseTextures();
|
||||
this.openFileThread = new ThreadOpenFilePNG(this.mc, I18n.format("hdskins.open.title"), this::onFileOpenDialogClosed);
|
||||
this.openFileThread.setParent(GLWindow.current().getFrame()).start();
|
||||
this.openFileThread.start();
|
||||
guiButton.enabled = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package com.voxelmodpack.hdskins.upload.awt;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.voxelmodpack.hdskins.gui.GLWindow;
|
||||
|
||||
final class InternalDialog {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static JFrame hiddenFrame;
|
||||
|
||||
public static JFrame getAWTContext() {
|
||||
JFrame context = GLWindow.current().getFrame();
|
||||
|
||||
if (context != null) {
|
||||
return context;
|
||||
}
|
||||
|
||||
if (hiddenFrame == null) {
|
||||
hiddenFrame = new JFrame("InternalDialogue");
|
||||
hiddenFrame.setVisible(false);
|
||||
hiddenFrame.requestFocusInWindow();
|
||||
hiddenFrame.requestFocus();
|
||||
|
||||
try {
|
||||
if (hiddenFrame.isAlwaysOnTopSupported()) {
|
||||
hiddenFrame.setAlwaysOnTop(true);
|
||||
}
|
||||
} catch (SecurityException e) {
|
||||
LOGGER.fatal("Could not set window on top state. This is probably Forge's fault.", e);
|
||||
}
|
||||
}
|
||||
|
||||
return hiddenFrame;
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@ import net.minecraft.client.Minecraft;
|
|||
import java.io.File;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
/**
|
||||
|
@ -24,8 +23,6 @@ public abstract class ThreadOpenFile extends Thread {
|
|||
|
||||
private JFileChooser fileDialog;
|
||||
|
||||
private JFrame parent = null;
|
||||
|
||||
private static String lastChosenFile = null;
|
||||
|
||||
protected ThreadOpenFile(Minecraft minecraft, String dialogTitle, IOpenFileCallback callback)
|
||||
|
@ -38,11 +35,6 @@ public abstract class ThreadOpenFile extends Thread {
|
|||
this.dialogTitle = dialogTitle;
|
||||
}
|
||||
|
||||
public ThreadOpenFile setParent(JFrame parent) {
|
||||
this.parent = parent;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
fileDialog = new JFileChooser();
|
||||
|
@ -53,9 +45,13 @@ public abstract class ThreadOpenFile extends Thread {
|
|||
}
|
||||
fileDialog.setFileFilter(this.getFileFilter());
|
||||
|
||||
int dialogResult = fileDialog.showOpenDialog(parent);
|
||||
int dialogResult = fileDialog.showOpenDialog(InternalDialog.getAWTContext());
|
||||
|
||||
lastChosenFile = fileDialog.getSelectedFile().getAbsolutePath();
|
||||
File f = fileDialog.getSelectedFile();
|
||||
|
||||
if (f != null) {
|
||||
lastChosenFile = f.getAbsolutePath();
|
||||
}
|
||||
|
||||
this.parentScreen.onFileOpenDialogClosed(fileDialog, dialogResult);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue