|
44 | 44 | import javax.swing.text.html.HTMLDocument; |
45 | 45 | import javax.swing.text.html.HTMLEditorKit; |
46 | 46 |
|
| 47 | +import com.gradwahl.rs254.ClientConfig; |
47 | 48 | import com.gradwahl.rs254.discord.DiscordRichPresence; |
48 | | -import com.gradwahl.rs254.update.ClientUpdater; |
49 | 49 |
|
50 | 50 | import static org.lwjgl.glfw.Callbacks.glfwFreeCallbacks; |
51 | 51 | import static org.lwjgl.glfw.GLFW.*; |
@@ -507,16 +507,7 @@ void main() { |
507 | 507 | private boolean settingsFullscreen = false; |
508 | 508 | private boolean settingsAfkDropdownOpen; |
509 | 509 | private int settingsAfkIndex = SETTINGS_PREFS.getInt("afkIndex", 0); |
510 | | - private enum UpdateButtonState { OUTDATED, CHECKING, READY, UPDATED, APPLYING } |
511 | | - private volatile UpdateButtonState updateButtonState = UpdateButtonState.OUTDATED; |
512 | | - private volatile String updateStatusText = "Current: " + ClientUpdater.currentVersionLabel(); |
513 | | - private volatile ClientUpdater.UpdateInfo updateInfo; |
514 | | - private final java.util.concurrent.ExecutorService updateExecutor = |
515 | | - java.util.concurrent.Executors.newSingleThreadExecutor(r -> { |
516 | | - Thread t = new Thread(r, "client-updater"); |
517 | | - t.setDaemon(true); |
518 | | - return t; |
519 | | - }); |
| 510 | + private final String clientVersionText = "Version: " + ClientConfig.currentVersionLabel(); |
520 | 511 |
|
521 | 512 | // XP session tracking — updated by Client when XP packets arrive |
522 | 513 | public static final long[] xpSessionGains = new long[25]; |
@@ -896,7 +887,6 @@ public void destroy() { |
896 | 887 | if (sidebarNativeDirect != null) MemoryUtil.memFree(sidebarNativeDirect); |
897 | 888 | hiscoresFetcher.shutdownNow(); |
898 | 889 | DISCORD_RPC.disconnect(); |
899 | | - updateExecutor.shutdownNow(); |
900 | 890 | glfwFreeCallbacks(window); |
901 | 891 | glfwDestroyWindow(window); |
902 | 892 | glfwTerminate(); |
@@ -2805,7 +2795,7 @@ private void drawSettingsPanel(int x) { |
2805 | 2795 | y = drawSettingsToggleRow(x, y, "60 Fps Mode", sidebarFpsEnabled); |
2806 | 2796 | y = drawSettingsToggleRow(x, y, "Fullscreen Mode", settingsFullscreen); |
2807 | 2797 | y += 4; |
2808 | | - drawUpdateButton(x, y); |
| 2798 | + drawClientVersionText(x, y); |
2809 | 2799 | } |
2810 | 2800 |
|
2811 | 2801 | private void loadSettings() { |
@@ -2838,36 +2828,9 @@ private int drawSettingsToggleRow(int x, int y, String text, boolean enabled) { |
2838 | 2828 | return y + 20; |
2839 | 2829 | } |
2840 | 2830 |
|
2841 | | - private void drawUpdateButton(int x, int y) { |
| 2831 | + private void drawClientVersionText(int x, int y) { |
2842 | 2832 | int panelW = sidebarPanelW(); |
2843 | | - int buttonX = x + 16; |
2844 | | - int buttonW = panelW - 32; |
2845 | | - int color = updateButtonColor(); |
2846 | | - fillUiRect(buttonX, y, buttonW, 18, 0xFF202020); |
2847 | | - fillUiRect(buttonX, y, buttonW, 1, color); |
2848 | | - fillUiRect(buttonX, y + 17, buttonW, 1, 0xFF111111); |
2849 | | - fillUiRect(buttonX, y, 1, 18, 0xFF4A4A4A); |
2850 | | - fillUiRect(buttonX + buttonW - 1, y, 1, 18, 0xFF111111); |
2851 | | - drawUiTextCentered(updateButtonText(), buttonX, y, buttonW, 18, 0, color); |
2852 | | - drawUiTextFittedFull(updateStatusText, buttonX, y + 23, buttonW, 0, 0xFF999999); |
2853 | | - } |
2854 | | - |
2855 | | - private int updateButtonColor() { |
2856 | | - return switch (updateButtonState) { |
2857 | | - case READY, CHECKING, APPLYING -> 0xFF4AA3FF; |
2858 | | - case UPDATED -> 0xFF43D36B; |
2859 | | - case OUTDATED -> 0xFFE05252; |
2860 | | - }; |
2861 | | - } |
2862 | | - |
2863 | | - private String updateButtonText() { |
2864 | | - return switch (updateButtonState) { |
2865 | | - case CHECKING -> "CHECKING..."; |
2866 | | - case READY -> "READY TO UPDATE"; |
2867 | | - case UPDATED -> "UPDATED TO LATEST"; |
2868 | | - case APPLYING -> "APPLYING UPDATE..."; |
2869 | | - case OUTDATED -> "CHECK FOR UPDATES"; |
2870 | | - }; |
| 2833 | + drawUiTextFittedFull(clientVersionText, x + 16, y + 5, panelW - 32, 0, 0xFF999999); |
2871 | 2834 | } |
2872 | 2835 |
|
2873 | 2836 | private void drawSelectBox(int x, int y, int w, String text, boolean open) { |
@@ -3768,73 +3731,13 @@ private void clickSettingsPanel(int x, int y) { |
3768 | 3731 | if (toggleHit(px, rowY, x, y)) { setFps60(!sidebarFpsEnabled); return; } |
3769 | 3732 | rowY += 20; |
3770 | 3733 | if (toggleHit(px, rowY, x, y)) { toggleFullscreen(); return; } |
3771 | | - rowY += 24; |
3772 | | - if (updateButtonHit(px, rowY, x, y)) clickUpdateButton(); |
3773 | 3734 | } |
3774 | 3735 |
|
3775 | 3736 | private boolean toggleHit(int px, int rowY, int mouseX, int mouseY) { |
3776 | 3737 | return mouseX >= px + 8 && mouseX < px + sidebarPanelW() - 8 |
3777 | 3738 | && mouseY >= rowY && mouseY < rowY + 20; |
3778 | 3739 | } |
3779 | 3740 |
|
3780 | | - private boolean updateButtonHit(int px, int rowY, int mouseX, int mouseY) { |
3781 | | - return mouseX >= px + 16 && mouseX < px + sidebarPanelW() - 16 |
3782 | | - && mouseY >= rowY && mouseY < rowY + 18; |
3783 | | - } |
3784 | | - |
3785 | | - private void clickUpdateButton() { |
3786 | | - if (updateButtonState == UpdateButtonState.CHECKING |
3787 | | - || updateButtonState == UpdateButtonState.APPLYING) { |
3788 | | - return; |
3789 | | - } |
3790 | | - if (updateButtonState == UpdateButtonState.READY && updateInfo != null) { |
3791 | | - applyUpdate(); |
3792 | | - } else { |
3793 | | - checkForUpdates(); |
3794 | | - } |
3795 | | - } |
3796 | | - |
3797 | | - private void checkForUpdates() { |
3798 | | - updateButtonState = UpdateButtonState.CHECKING; |
3799 | | - updateStatusText = "Contacting GitHub releases..."; |
3800 | | - updateExecutor.execute(() -> { |
3801 | | - try { |
3802 | | - ClientUpdater.UpdateInfo latest = ClientUpdater.checkLatest(); |
3803 | | - updateInfo = latest; |
3804 | | - if (latest.updateAvailable()) { |
3805 | | - updateButtonState = UpdateButtonState.READY; |
3806 | | - updateStatusText = "Latest: " + latest.tagName() + " (" + latest.assetName() + ")"; |
3807 | | - } else { |
3808 | | - updateButtonState = UpdateButtonState.UPDATED; |
3809 | | - updateStatusText = "Latest: " + latest.tagName(); |
3810 | | - } |
3811 | | - } catch (Exception e) { |
3812 | | - updateInfo = null; |
3813 | | - updateButtonState = UpdateButtonState.OUTDATED; |
3814 | | - updateStatusText = "Update check failed"; |
3815 | | - System.err.println("[Updater] Check failed: " + e); |
3816 | | - e.printStackTrace(System.err); |
3817 | | - } |
3818 | | - }); |
3819 | | - } |
3820 | | - |
3821 | | - private void applyUpdate() { |
3822 | | - ClientUpdater.UpdateInfo info = updateInfo; |
3823 | | - if (info == null) return; |
3824 | | - updateButtonState = UpdateButtonState.APPLYING; |
3825 | | - updateStatusText = "Downloading " + info.assetName(); |
3826 | | - updateExecutor.execute(() -> { |
3827 | | - try { |
3828 | | - ClientUpdater.apply(info); |
3829 | | - } catch (Exception e) { |
3830 | | - updateButtonState = UpdateButtonState.READY; |
3831 | | - updateStatusText = "Update failed"; |
3832 | | - System.err.println("[Updater] Apply failed: " + e); |
3833 | | - e.printStackTrace(System.err); |
3834 | | - } |
3835 | | - }); |
3836 | | - } |
3837 | | - |
3838 | 3741 | private void setAfkIndex(int index) { |
3839 | 3742 | settingsAfkIndex = Math.max(0, Math.min(AFK_LABELS.length - 1, index)); |
3840 | 3743 | afkTimeoutCycles = AFK_CYCLES[settingsAfkIndex]; |
|
0 commit comments