Fixed dragging mod files to UI
This commit is contained in:
@@ -91,6 +91,8 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
|||||||
|
|
||||||
void initGui() {
|
void initGui() {
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
|
dropTarget = new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, this);
|
||||||
setBackground(GraphicsUtils.getWebColorWithAlpha("FFFFFF7F"));
|
setBackground(GraphicsUtils.getWebColorWithAlpha("FFFFFF7F"));
|
||||||
setOpaque(true);
|
setOpaque(true);
|
||||||
|
|
||||||
@@ -110,8 +112,6 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
|||||||
|
|
||||||
Settings.profileLoadingEvent.register(onLoadingProfiles);
|
Settings.profileLoadingEvent.register(onLoadingProfiles);
|
||||||
Settings.profileChangedEvent.register(onSelectedProfilesChanged);
|
Settings.profileChangedEvent.register(onSelectedProfilesChanged);
|
||||||
|
|
||||||
dropTarget = new DropTarget(lstExternalMods, DnDConstants.ACTION_COPY_OR_MOVE, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initExplorationMenu() {
|
void initExplorationMenu() {
|
||||||
@@ -1222,23 +1222,13 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
// <editor-fold defaultstate="collapsed" desc="Installer">
|
// <editor-fold defaultstate="collapsed" desc="Mod">
|
||||||
String getMinecraftVersionFormatted() {
|
String getMinecraftVersionFormatted() {
|
||||||
return minecraftVersion == null ? "" : (StrUtils.formatVersion(minecraftVersion.version) == null) ? mcVersion : minecraftVersion.version;
|
return minecraftVersion == null ? "" : (StrUtils.formatVersion(minecraftVersion.version) == null) ? mcVersion : minecraftVersion.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dragEnter(DropTargetDragEvent dtde) {
|
public void dragEnter(DropTargetDragEvent dtde) {
|
||||||
DataFlavor[] f = dtde.getCurrentDataFlavors();
|
|
||||||
if (f[0].match(DataFlavor.javaFileListFlavor))
|
|
||||||
try {
|
|
||||||
Transferable tr = dtde.getTransferable();
|
|
||||||
List<File> files = (List<File>) tr.getTransferData(DataFlavor.javaFileListFlavor);
|
|
||||||
for (File file : files)
|
|
||||||
Settings.getLastProfile().service().mod().addMod(Settings.getLastProfile().getSelectedVersion(), file);
|
|
||||||
} catch (UnsupportedFlavorException | IOException ex) {
|
|
||||||
HMCLog.warn("Failed to drop file.", ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1255,6 +1245,18 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drop(DropTargetDropEvent dtde) {
|
public void drop(DropTargetDropEvent dtde) {
|
||||||
|
DataFlavor[] f = dtde.getCurrentDataFlavors();
|
||||||
|
if (f[0].match(DataFlavor.javaFileListFlavor))
|
||||||
|
try {
|
||||||
|
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
|
||||||
|
Transferable tr = dtde.getTransferable();
|
||||||
|
List<File> files = (List<File>) tr.getTransferData(DataFlavor.javaFileListFlavor);
|
||||||
|
for (File file : files)
|
||||||
|
Settings.getLastProfile().service().mod().addMod(Settings.getLastProfile().getSelectedVersion(), file);
|
||||||
|
reloadMods();
|
||||||
|
} catch (UnsupportedFlavorException | IOException ex) {
|
||||||
|
HMCLog.warn("Failed to drop file.", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void refreshVersions() {
|
void refreshVersions() {
|
||||||
|
|||||||
Reference in New Issue
Block a user