diff --git a/app/src/main/java/bot/Main.java b/app/src/main/java/bot/Main.java index dfadb8fa..f31d59f6 100644 --- a/app/src/main/java/bot/Main.java +++ b/app/src/main/java/bot/Main.java @@ -451,6 +451,7 @@ public static void main(String[] args) isRunning = true; startStopButton.setText("Stop"); } + syncMainMenuButtonsEnabledStatusToBackingState(); } if (config.getScreenRefresh()) { @@ -706,6 +707,7 @@ private static void initializeBotFrame(JComponent botFrame) { botFrame.setLayout(new BoxLayout(botFrame, BoxLayout.Y_AXIS)); startStopButton = new JButton(isRunning ? "Stop" : "Start"); + startStopButton.setEnabled(currentRunningScript != null); autoLoginCheckbox = new JCheckBox("Auto-Login"); debugCheckbox = new JCheckBox("Debug Messages"); @@ -723,12 +725,18 @@ private static void initializeBotFrame(JComponent botFrame) { startStopButton.addActionListener( e -> { + if (currentRunningScript == null) { + return; + } + isRunning = !isRunning; if (isRunning) { startStopButton.setText("Stop"); } else { startStopButton.setText("Start"); } + + syncMainMenuButtonsEnabledStatusToBackingState(); }); loadScriptButton.addActionListener(e -> showLoadScript()); @@ -743,6 +751,7 @@ private static void initializeBotFrame(JComponent botFrame) { } else { JOptionPane.showMessageDialog(null, "Stop the current script first."); } + syncMainMenuButtonsEnabledStatusToBackingState(); }); openDebuggerButton.addActionListener( @@ -1036,6 +1045,7 @@ public void filter() { startStopButton.setText("Stop"); scriptFrame.setVisible(false); } + syncMainMenuButtonsEnabledStatusToBackingState(); } }); @@ -1265,6 +1275,12 @@ private static void createCache() { } } + private static void syncMainMenuButtonsEnabledStatusToBackingState() { + loadScriptButton.setEnabled(!isRunning); + pathwalkerButton.setEnabled(!isRunning); + startStopButton.setEnabled(currentRunningScript != null); + } + private static void setIconStyle(boolean newIcons) { // Create Cache directory File dir = new File("." + File.separator + "Cache"); @@ -1486,6 +1502,7 @@ public static void setRunning(boolean _isRunning) { } else { startStopButton.setText("Start"); } + syncMainMenuButtonsEnabledStatusToBackingState(); } /**