New launcher visibility mode: hide and reopen later
This commit is contained in:
@@ -117,7 +117,7 @@ public class GameDownloadPanel extends Page {
|
||||
lstDownloads.requestFocus();
|
||||
if (model.getRowCount() > 0)
|
||||
model.removeRow(0);
|
||||
})).execute();
|
||||
})).runAsync();
|
||||
}
|
||||
|
||||
void downloadMinecraft() {
|
||||
|
||||
@@ -297,7 +297,7 @@
|
||||
<Component class="javax.swing.JComboBox" name="cboLauncherVisibility">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="new javax.swing.DefaultComboBoxModel(new String[] { C.i18n("advancedsettings.launcher_visibility.close"), C.i18n("advancedsettings.launcher_visibility.hide"), C.i18n("advancedsettings.launcher_visibility.keep") })" type="code"/>
|
||||
<Connection code="new javax.swing.DefaultComboBoxModel(new String[] { C.i18n("advancedsettings.launcher_visibility.close"), C.i18n("advancedsettings.launcher_visibility.hide"), C.i18n("advancedsettings.launcher_visibility.keep"),C.i18n("advancedsettings.launcher_visibility.hide_reopen") })" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
|
||||
@@ -405,7 +405,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
}
|
||||
});
|
||||
|
||||
cboLauncherVisibility.setModel(new javax.swing.DefaultComboBoxModel(new String[] { C.i18n("advancedsettings.launcher_visibility.close"), C.i18n("advancedsettings.launcher_visibility.hide"), C.i18n("advancedsettings.launcher_visibility.keep") }));
|
||||
cboLauncherVisibility.setModel(new javax.swing.DefaultComboBoxModel(new String[] { C.i18n("advancedsettings.launcher_visibility.close"), C.i18n("advancedsettings.launcher_visibility.hide"), C.i18n("advancedsettings.launcher_visibility.keep"),C.i18n("advancedsettings.launcher_visibility.hide_reopen") }));
|
||||
cboLauncherVisibility.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent evt) {
|
||||
cboLauncherVisibilityItemStateChanged(evt);
|
||||
@@ -950,7 +950,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(tabVersionEdit, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 766, Short.MAX_VALUE)
|
||||
.addComponent(tabVersionEdit, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(btnMakeLaunchScript)
|
||||
|
||||
@@ -140,9 +140,12 @@
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkDecorated" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="btnCheckUpdate" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
<Component id="btnMCBBS" alignment="3" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="btnCheckUpdate" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="btnMCBBS" pref="26" max="32767" attributes="0"/>
|
||||
<EmptySpace min="1" pref="1" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblRestart" min="-2" max="-2" attributes="0"/>
|
||||
|
||||
@@ -308,12 +308,12 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
.addComponent(chkEnableBlur)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkEnableAnimation))
|
||||
.addComponent(lblAbout)
|
||||
.addComponent(lblAbout, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(btnCheckUpdate)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnMCBBS))
|
||||
.addComponent(lblModpack)
|
||||
.addComponent(lblModpack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblRestart))
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
@@ -382,15 +382,17 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkDecorated)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(btnCheckUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(btnMCBBS, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(btnMCBBS, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)
|
||||
.addGap(1, 1, 1)))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblRestart)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblModpack)
|
||||
.addComponent(lblModpack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblAbout)
|
||||
.addComponent(lblAbout, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
@@ -38,6 +38,8 @@ import org.jackhuang.hmcl.util.C;
|
||||
import org.jackhuang.hmcl.util.MessageBox;
|
||||
import org.jackhuang.hmcl.api.func.Consumer;
|
||||
import org.jackhuang.hmcl.api.HMCLog;
|
||||
import org.jackhuang.hmcl.api.event.SimpleEvent;
|
||||
import org.jackhuang.hmcl.api.event.launch.LaunchingState;
|
||||
import org.jackhuang.hmcl.util.DefaultPlugin;
|
||||
import org.jackhuang.hmcl.util.sys.FileUtils;
|
||||
import org.jackhuang.hmcl.util.sys.ProcessMonitor;
|
||||
@@ -61,11 +63,12 @@ public class LaunchingUIDaemon {
|
||||
else {
|
||||
if (LogWindow.INSTANCE.isVisible())
|
||||
LogWindow.INSTANCE.setExit(() -> true);
|
||||
MainFrame.INSTANCE.dispose();
|
||||
HMCLApi.EVENT_BUS.fireChannel(new LaunchingStateChangedEvent(obj, LaunchingState.WaitingForGameLaunching));
|
||||
}
|
||||
// We promise that JavaProcessMonitor.tag is LauncherVisibility
|
||||
// See events below.
|
||||
ProcessMonitor monitor = new ProcessMonitor(p.getValue());
|
||||
monitor.registerPrintlnEvent(PRINTLN);
|
||||
monitor.setTag(tag.launcherVisibility);
|
||||
monitor.start();
|
||||
});
|
||||
@@ -103,7 +106,7 @@ public class LaunchingUIDaemon {
|
||||
noExitThisTime = true;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
boolean noExitThisTime = false;
|
||||
|
||||
void runGame(Profile profile) {
|
||||
@@ -131,6 +134,15 @@ public class LaunchingUIDaemon {
|
||||
}, MainFrame.INSTANCE::failed, Settings.getInstance().getAuthenticator().getPassword());
|
||||
}
|
||||
|
||||
private static final Consumer<SimpleEvent<String>> PRINTLN = t -> {
|
||||
LauncherVisibility l = ((LauncherVisibility) ((ProcessMonitor) t.getSource()).getTag());
|
||||
if (t.getValue().contains("LWJGL Version: ") && l != LauncherVisibility.KEEP)
|
||||
if (l != LauncherVisibility.HIDE_AND_REOPEN)
|
||||
MainFrame.INSTANCE.dispose();
|
||||
else
|
||||
MainFrame.INSTANCE.setVisible(false);
|
||||
};
|
||||
|
||||
private static final Consumer<LaunchingStateChangedEvent> LAUNCHING_STATE_CHANGED = t -> {
|
||||
String message = null;
|
||||
switch (t.getValue()) {
|
||||
@@ -146,6 +158,9 @@ public class LaunchingUIDaemon {
|
||||
case DecompressingNatives:
|
||||
message = "launch.state.decompressing_natives";
|
||||
break;
|
||||
case WaitingForGameLaunching:
|
||||
message = "launch.state.waiting_launching";
|
||||
break;
|
||||
case Done:
|
||||
return;
|
||||
}
|
||||
@@ -162,7 +177,10 @@ public class LaunchingUIDaemon {
|
||||
};
|
||||
|
||||
private void checkExit(LauncherVisibility v) {
|
||||
if (v != LauncherVisibility.KEEP && !LogWindow.INSTANCE.isVisible() && !noExitThisTime) {
|
||||
if (v == LauncherVisibility.HIDE_AND_REOPEN) {
|
||||
HMCLog.log("Launcher will not exit now.");
|
||||
MainFrame.INSTANCE.setVisible(true);
|
||||
} else if (v != LauncherVisibility.KEEP && !LogWindow.INSTANCE.isVisible() && !noExitThisTime) {
|
||||
HMCLog.log("Launcher will exit now.");
|
||||
System.exit(0);
|
||||
} else {
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package org.jackhuang.hmcl.ui;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import javax.swing.JScrollBar;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.text.Document;
|
||||
import javax.swing.text.SimpleAttributeSet;
|
||||
|
||||
@@ -36,5 +36,9 @@ public enum LauncherVisibility {
|
||||
/**
|
||||
* Keep the launcher visible even if the game launched successfully.
|
||||
*/
|
||||
KEEP;
|
||||
KEEP,
|
||||
/**
|
||||
* Hide the launcher and reopen it when game closes.
|
||||
*/
|
||||
HIDE_AND_REOPEN
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user