import java.util.List; /** * In-game Canvas UI for Tab 7 and the 3D Viewport Interactive Modal. * Styled authentically after native RuneScape 2006 (Revision 377) stone interfaces, * with beveled stone borders, dark parchment/stone background (0x2a251e), gold headers, * authentic red stone close button, seamless segmented button groups, and native RS scrollbar. * Works identically across Desktop (Fixed & Modern) and Android (Fixed & Modern). */ public class PluginPanelUI { private static boolean modalOpen = false; private static int currentModalTab = 0; // 0: Plugins, 1: Scripts, 2: Online Repo, 3: Config Page private static int currentRepoSubTab = 0; // 0: Plugins, 1: Scripts private static int configReturnTab = 0; private static Object configTarget = null; // ClientPlugin or ClientScript currently being configured private static int scrollOffset = 0; private static String searchQuery = ""; private static boolean searchFocused = false; private static String openDropdownKey = null; private static int dropdownScrollOffset = 0; private static boolean isDraggingDropdown = false; private static final int DROPDOWN_WIDTH = 172; private static final int DROPDOWN_ROW_H = 22; private static final int DROPDOWN_MAX_VISIBLE = 6; private static boolean isDragging = false; private static boolean isDraggingScrollBar = false; private static int lastDragY = -1; private static int dragStartY = -1; private static boolean wasDrag = false; // Modal Dimensions - fits cleanly within standard 512x334 interface rectangle like the Bank interface public static final int MODAL_WIDTH = 488; public static final int MODAL_HEIGHT = 308; public static boolean isModalOpen() { return modalOpen; } public static boolean isSearchFocused() { return modalOpen && searchFocused && (currentModalTab == 0 || currentModalTab == 1 || currentModalTab == 2); } public static void handleKeyChar(int ch) { if (!isSearchFocused()) { return; } if (ch == 8) { if (!searchQuery.isEmpty()) { searchQuery = searchQuery.substring(0, searchQuery.length() - 1); scrollOffset = 0; } } else if (ch == 10 || ch == 13 || ch == 27) { searchFocused = false; } else if (ch >= 32 && ch <= 126 && searchQuery.length() < 40) { searchQuery += (char) ch; scrollOffset = 0; } } public static void openModal(int tab) { modalOpen = true; searchFocused = false; currentModalTab = (!PluginManager.isScriptsAvailable() && tab == 1) ? 0 : tab; if (currentModalTab == 2) { PluginRepoClient.ensureLoaded(); } scrollOffset = 0; isDragging = false; isDraggingScrollBar = false; lastDragY = -1; dragStartY = -1; wasDrag = false; PluginManager pm = PluginManager.get(); if (pm != null && pm.getContext() != null) { Game game = pm.getContext().getGame(); if (game != null && game.openInterfaceID != -1) { game.closeOpenInterfaces(); } } } public static void closeModal() { modalOpen = false; searchFocused = false; configTarget = null; scrollOffset = 0; openDropdownKey = null; dropdownScrollOffset = 0; isDragging = false; isDraggingScrollBar = false; isDraggingDropdown = false; lastDragY = -1; dragStartY = -1; wasDrag = false; } public static int getScrollOffset() { return scrollOffset; } public static void setScrollOffset(int offset) { scrollOffset = offset; } public static int getCurrentModalTab() { return currentModalTab; } public static void setCurrentModalTab(int tab) { currentModalTab = tab; } public static Object getConfigTarget() { return configTarget; } public static void setConfigTarget(Object target) { configTarget = target; } public static int getModalAreaWidth() { if (ClientSettings.ANDROID || !ClientSettings.isDesktopModern()) { return 512; } return DrawingArea.width > 0 ? DrawingArea.width : ClientSettings.VIEWPORT_WIDTH; } public static int getModalAreaHeight() { if (ClientSettings.ANDROID || !ClientSettings.isDesktopModern()) { return 334; } return DrawingArea.height > 0 ? DrawingArea.height : ClientSettings.VIEWPORT_HEIGHT; } public static int toLocalX(int x) { if (ClientSettings.ANDROID || !ClientSettings.isDesktopModern()) { return x - 4; } return x; } public static int toLocalY(int y) { if (ClientSettings.ANDROID || !ClientSettings.isDesktopModern()) { return y - 4; } return y; } public static int getContentAreaY() { int vh = getModalAreaHeight(); int my = Math.max(0, (vh - MODAL_HEIGHT) / 2); return my + 28 + 26; } public static int getContentAreaHeight() { int vh = getModalAreaHeight(); int my = Math.max(0, (vh - MODAL_HEIGHT) / 2); int contentY = getContentAreaY(); int footerY = my + MODAL_HEIGHT - 32; return footerY - contentY - 4; } public static void handleMouseWheel(int notches) { if (!modalOpen) return; PluginManager pm = PluginManager.get(); if (pm == null) return; if (currentModalTab == 3 && openDropdownKey != null) { int maxDropScroll = getOpenDropdownMaxScroll(pm); if (maxDropScroll > 0) { dropdownScrollOffset += notches * DROPDOWN_ROW_H; if (dropdownScrollOffset < 0) dropdownScrollOffset = 0; if (dropdownScrollOffset > maxDropScroll) dropdownScrollOffset = maxDropScroll; return; } } scrollOffset += notches * 30; clampScroll(pm); } private static int[] getOpenDropdownBounds(PluginManager pm) { if (openDropdownKey == null || configTarget == null || currentModalTab != 3) return null; List items = getVisibleConfigItems(pm, configTarget); if (items == null) return null; int vw = getModalAreaWidth(); int vh = getModalAreaHeight(); int mx = Math.max(0, (vw - MODAL_WIDTH) / 2); int my = Math.max(0, (vh - MODAL_HEIGHT) / 2); int wellX = mx + 12; int wellW = MODAL_WIDTH - 24; int contentY = getContentAreaY(); int contentH = getContentAreaHeight(); int headerH = getConfigHeaderHeight(); int wellInnerX = wellX + 2; int wellInnerW = wellW - 4 - 16; int rowY = contentY + headerH + 2 - scrollOffset; for (int i = 0; i < items.size(); i++) { PluginConfigItem item = items.get(i); if (openDropdownKey.equals(item.getKey())) { String[] choices = item.getChoices(); if (choices == null || choices.length == 0) return null; int visibleCount = Math.min(DROPDOWN_MAX_VISIBLE, choices.length); int dropH = visibleCount * DROPDOWN_ROW_H + 2; int dropX = wellInnerX + wellInnerW - DROPDOWN_WIDTH; int dropY = rowY + 31; if (dropY + dropH > contentY + contentH) { dropY = Math.max(contentY + 2, rowY + 1 - dropH); } return new int[]{dropX, dropY, DROPDOWN_WIDTH, dropH, i, choices.length}; } rowY += 32; } return null; } private static int getOpenDropdownMaxScroll(PluginManager pm) { int[] b = getOpenDropdownBounds(pm); if (b == null) return 0; int totalH = b[5] * DROPDOWN_ROW_H + 2; return Math.max(0, totalH - b[3]); } private static boolean matchesSearch(String name, String desc, String author) { if (searchQuery == null || searchQuery.isEmpty()) { return true; } String q = searchQuery.toLowerCase(java.util.Locale.ROOT); if (name != null && name.toLowerCase(java.util.Locale.ROOT).contains(q)) { return true; } if (desc != null && desc.toLowerCase(java.util.Locale.ROOT).contains(q)) { return true; } return author != null && author.toLowerCase(java.util.Locale.ROOT).contains(q); } private static List getFilteredPlugins(PluginManager pm) { List filtered = new java.util.ArrayList<>(); if (pm == null || pm.getPlugins() == null) return filtered; for (ClientPlugin p : pm.getPlugins()) { if (matchesSearch(p.getName(), p.getDescription(), null)) { filtered.add(p); } } return filtered; } private static List getFilteredScripts(PluginManager pm) { List filtered = new java.util.ArrayList<>(); if (pm == null || pm.getScripts() == null) return filtered; for (ClientScript s : pm.getScripts()) { if (matchesSearch(s.getName(), s.getDescription(), null)) { filtered.add(s); } } return filtered; } public static int getContentHeight(PluginManager pm) { int contentH = getContentAreaHeight(); if (pm == null) return contentH; if (currentModalTab == 0) { return getFilteredPlugins(pm).size() * 38 + 34; } else if (currentModalTab == 1) { if (!PluginManager.isScriptsAvailable()) return contentH; return getFilteredScripts(pm).size() * 38 + 34; } else if (currentModalTab == 2) { List entries = getFilteredRepoEntries(); return entries.size() * 38 + 34; } else if (currentModalTab == 3) { if (configTarget == null) { return contentH; } List items = getVisibleConfigItems(pm, configTarget); if (items == null || items.isEmpty()) return contentH; return (items.size() * 32) + getConfigHeaderHeight() + 4; } return contentH; } public static List getVisibleConfigItems(PluginManager pm, Object target) { List rawItems = (target instanceof ClientPlugin) ? ((ClientPlugin) target).getConfigItems() : (target instanceof ClientScript) ? ((ClientScript) target).getConfigItems() : null; if (rawItems == null || rawItems.isEmpty()) return rawItems; List visible = new java.util.ArrayList<>(); for (PluginConfigItem item : rawItems) { String depKey = item.getVisibleWhen(); if (depKey == null || depKey.isEmpty() || pm == null) { visible.add(item); continue; } PluginConfigItem dep = null; for (PluginConfigItem candidate : rawItems) { if (depKey.equals(candidate.getKey())) { dep = candidate; break; } } if (dep == null || pm.getConfigBoolean(target, dep)) { visible.add(item); } } return visible; } public static int getConfigHeaderHeight() { if (configTarget != null) { String desc = (configTarget instanceof ClientPlugin) ? ((ClientPlugin) configTarget).getDescription() : (configTarget instanceof ClientScript) ? ((ClientScript) configTarget).getDescription() : null; if (desc != null && !desc.isEmpty()) { return 40; } } return 24; } public static int getMaxScroll(PluginManager pm) { int contentH = getContentAreaHeight(); if (currentModalTab == 2) { int availH = contentH - 26; int totalH = getContentHeight(pm); return Math.max(0, totalH - availH); } else if (currentModalTab == 3) { int headerH = (configTarget != null) ? getConfigHeaderHeight() : 24; int availH = contentH - headerH; int totalH = getContentHeight(pm); return Math.max(0, totalH - availH); } else { int totalH = getContentHeight(pm); return Math.max(0, totalH - contentH); } } public static void clampScroll(PluginManager pm) { int max = getMaxScroll(pm); if (scrollOffset > max) { scrollOffset = max; } if (scrollOffset < 0) { scrollOffset = 0; } } public static boolean isModalAt(int x, int y) { if (!modalOpen) return false; int lx = toLocalX(x); int ly = toLocalY(y); int vw = getModalAreaWidth(); int vh = getModalAreaHeight(); int mx = Math.max(0, (vw - MODAL_WIDTH) / 2); int my = Math.max(0, (vh - MODAL_HEIGHT) / 2); return lx >= mx && lx <= mx + MODAL_WIDTH && ly >= my && ly <= my + MODAL_HEIGHT; } public static boolean isScrollBarAt(int x, int y) { if (!modalOpen) return false; PluginManager pm = PluginManager.get(); if (pm == null) return false; if (getMaxScroll(pm) <= 0) return false; int lx = toLocalX(x); int ly = toLocalY(y); int vw = getModalAreaWidth(); int mx = Math.max(0, (vw - MODAL_WIDTH) / 2); int contentY = getContentAreaY(); int contentH = getContentAreaHeight(); int sbX = mx + MODAL_WIDTH - 28; int sbY = contentY + 2; int sbH = contentH - 4; return lx >= sbX - 6 && lx <= sbX + 22 && ly >= sbY - 2 && ly <= sbY + sbH + 2; } public static boolean isContentAreaAt(int x, int y) { if (!modalOpen) return false; int lx = toLocalX(x); int ly = toLocalY(y); int vw = getModalAreaWidth(); int mx = Math.max(0, (vw - MODAL_WIDTH) / 2); int contentY = getContentAreaY(); int contentH = getContentAreaHeight(); return lx >= mx + 10 && lx <= mx + MODAL_WIDTH - 10 && ly >= contentY && ly <= contentY + contentH; } public static void processInput(Game game) { if (!modalOpen || game == null) { isDragging = false; isDraggingScrollBar = false; lastDragY = -1; return; } PluginManager pm = PluginManager.get(); int maxScroll = pm != null ? getMaxScroll(pm) : 0; if (game.clickMode2 == 1) { int mx = toLocalX(game.mouseX); int my = toLocalY(game.mouseY); if (!isDragging) { if (isScrollBarAt(game.mouseX, game.mouseY)) { isDragging = true; int contentY = getContentAreaY(); int contentH = getContentAreaHeight(); int sbY = contentY + 2; int sbH = contentH - 4; if (my < sbY + 16) { scrollOffset -= 24; clampScroll(pm); isDraggingScrollBar = false; } else if (my > sbY + sbH - 16) { scrollOffset += 24; clampScroll(pm); isDraggingScrollBar = false; } else { isDraggingScrollBar = true; handleScrollBarJump(pm, my, maxScroll); } lastDragY = my; dragStartY = my; wasDrag = false; } else if (isContentAreaAt(game.mouseX, game.mouseY)) { int[] dropBounds = getOpenDropdownBounds(pm); isDragging = true; isDraggingScrollBar = false; isDraggingDropdown = (dropBounds != null && mx >= dropBounds[0] && mx <= dropBounds[0] + dropBounds[2] && my >= dropBounds[1] && my <= dropBounds[1] + dropBounds[3]); lastDragY = my; dragStartY = my; wasDrag = false; } } else { if (Math.abs(my - dragStartY) > 5) { wasDrag = true; } if (isDraggingDropdown) { int maxDropScroll = getOpenDropdownMaxScroll(pm); if (maxDropScroll > 0) { int deltaY = my - lastDragY; if (deltaY != 0) { dropdownScrollOffset -= deltaY; if (dropdownScrollOffset < 0) dropdownScrollOffset = 0; if (dropdownScrollOffset > maxDropScroll) dropdownScrollOffset = maxDropScroll; } } } else if (maxScroll > 0) { if (isDraggingScrollBar) { handleScrollBarJump(pm, my, maxScroll); } else { int deltaY = my - lastDragY; if (deltaY != 0) { scrollOffset -= deltaY; clampScroll(pm); } } } lastDragY = my; } } else { isDragging = false; isDraggingScrollBar = false; isDraggingDropdown = false; lastDragY = -1; } } private static void handleScrollBarJump(PluginManager pm, int clickY, int maxScroll) { if (pm == null || maxScroll <= 0) return; int contentY = getContentAreaY(); int contentH = getContentAreaHeight(); int sbY = contentY + 2; int sbH = contentH - 4; int trackH = sbH - 32; int thumbH = Math.max(8, (trackH * sbH) / (sbH + maxScroll)); if (thumbH > trackH) thumbH = trackH; int trackAvail = trackH - thumbH; if (isDraggingScrollBar) { if (trackAvail > 0) { int relY = clickY - (sbY + 16) - (thumbH / 2); relY = Math.max(0, Math.min(relY, trackAvail)); scrollOffset = (relY * maxScroll) / trackAvail; clampScroll(pm); } return; } // Discrete tap: Up arrow click (16px) if (clickY < sbY + 16) { scrollOffset -= 24; clampScroll(pm); return; } // Down arrow click (16px) if (clickY > sbY + sbH - 16) { scrollOffset += 24; clampScroll(pm); return; } // Track and thumb tap jump if (trackAvail > 0) { int relY = clickY - (sbY + 16) - (thumbH / 2); relY = Math.max(0, Math.min(relY, trackAvail)); scrollOffset = (relY * maxScroll) / trackAvail; clampScroll(pm); } } // ========================================================================= // Tab 7 (QoL & Plugins) Rendering and Click Handling // ========================================================================= public static void drawTab7(Game game) { PluginManager pm = PluginManager.get(); if (pm == null) return; try { int centerX = 95; int currentY = 6; int stepY = 36; int textTop = 13; int textBottom = 27; int textMiddle = 20; // 1. "PLUGIN HUB" (Opens Viewport Modal) game.drawButton(modalOpen, centerX - 73, currentY, 146); game.aTextDrawingArea_1271.textCenterShadow(0x00ffff, centerX, "PLUGIN HUB", currentY + textTop, true); game.aTextDrawingArea_1271.textCenterShadow(RSColors.YELLOW, centerX, "[Open Modal]", currentY + textBottom, true); // Hide remaining QoL buttons when QoL client settings are disabled if (!ClientSettings.ENABLE_QOL) { return; } currentY += stepY; // 2. Always Visible Player Names game.drawButton(game.customSettingVisiblePlayerNames, centerX - 73, currentY, 146); game.aTextDrawingArea_1271.textCenterShadow(RSColors.YELLOW, centerX, "player names", currentY + textMiddle, true); currentY += stepY; // 3. Item Drops Visible game.drawButton(true, centerX - 73, currentY, 146); game.aTextDrawingArea_1271.textCenterShadow(RSColors.YELLOW, centerX, "item drops visible", currentY + textTop, true); game.aTextDrawingArea_1271.textCenterShadow(RSColors.WHITE, centerX, game.intToKOrMil(game.customSettingMinItemValue) + " gp", currentY + textBottom, true); currentY += stepY; // 4. Draw Distance game.drawButton(true, centerX - 73, currentY, 146); game.aTextDrawingArea_1271.textCenterShadow(RSColors.YELLOW, centerX, "draw distance", currentY + textTop, true); game.aTextDrawingArea_1271.textCenterShadow(RSColors.WHITE, centerX, WorldController.drawDistance + " tiles", currentY + textBottom, true); currentY += stepY; // 5. Experience Tracker Info game.drawButton(game.customSettingShowExperiencePerHour, centerX - 73, currentY, 146); game.aTextDrawingArea_1271.textCenterShadow(RSColors.YELLOW, centerX, "show exp info", currentY + textMiddle, true); currentY += stepY; // 6. Debug Info game.drawButton(game.showInfo, centerX - 73, currentY, 146); game.aTextDrawingArea_1271.textCenterShadow(RSColors.YELLOW, centerX, "show debug info", currentY + textMiddle, true); currentY += stepY; // 7. Visual Fixes game.drawButton(game.customSettingVisualFixes, centerX - 73, currentY, 146); game.aTextDrawingArea_1271.textCenterShadow(RSColors.YELLOW, centerX, "visual fixes", currentY + textMiddle, true); } catch (Throwable ignored) { } } public static boolean handleTab7Click(Game game, int clickX, int clickY) { PluginManager pm = PluginManager.get(); if (pm == null) return false; // In fixed layout, tab body X is 575..720, Y is 210..465 int startY = 210 + 6; int stepY = 36; // 1. Plugin Hub Open Modal if (clickY >= startY && clickY <= startY + 30) { modalOpen = !modalOpen; if (modalOpen) currentModalTab = 0; return true; } // Ignore remaining QoL clicks when QoL client settings are disabled if (!ClientSettings.ENABLE_QOL) { return false; } startY += stepY; // 2. Player Names if (clickY >= startY && clickY <= startY + 30) { game.customSettingVisiblePlayerNames = !game.customSettingVisiblePlayerNames; return true; } startY += stepY; // 3. Item Drops Visible Prompt if (clickY >= startY && clickY <= startY + 30) { game.inputTaken = true; game.inputDialogState = 0; game.messagePromptRaised = true; game.promptInput = ""; game.aString1121 = "Enter minimum item value"; game.customTabAction = 1; return true; } startY += stepY; // 4. Draw Distance Prompt if (clickY >= startY && clickY <= startY + 30) { game.inputTaken = true; game.inputDialogState = 0; game.messagePromptRaised = true; game.promptInput = ""; game.aString1121 = "Enter new draw distance"; game.customTabAction = 2; return true; } startY += stepY; // 5. Exp Tracker if (clickY >= startY && clickY <= startY + 30) { game.customSettingShowExperiencePerHour = !game.customSettingShowExperiencePerHour; game.customSettingShowExperiencePerHourStart = System.currentTimeMillis(); game.customSettingShowExperiencePerHourStartExp = game.calculateTotalExp(); game.customSettingShowExperiencePerHourStartLevels = game.calculateTotalLevels(); return true; } startY += stepY; // 6. Debug Info if (clickY >= startY && clickY <= startY + 30) { game.showInfo = !game.showInfo; return true; } startY += stepY; // 7. Visual Fixes if (clickY >= startY && clickY <= startY + 30) { game.customSettingVisualFixes = !game.customSettingVisualFixes; ClientSettings.BILINEAR_MINIMAP_FILTERING = !ClientSettings.BILINEAR_MINIMAP_FILTERING; ClientSettings.FIX_TRANSPARENCY_OVERFLOW = !ClientSettings.FIX_TRANSPARENCY_OVERFLOW; ClientSettings.FULL_512PX_VIEWPORT = !ClientSettings.FULL_512PX_VIEWPORT; return true; } return false; } // ========================================================================= // Viewport Modal Rendering & Clicks (Authentic RuneScape 2006 Stone Theme) // ========================================================================= public static void drawViewportModal(Game game) { if (!modalOpen) return; PluginManager pm = PluginManager.get(); if (pm == null) return; PluginGraphics g = pm.getGraphics(); int vw = getModalAreaWidth(); int vh = getModalAreaHeight(); int mx = Math.max(0, (vw - MODAL_WIDTH) / 2); int my = Math.max(0, (vh - MODAL_HEIGHT) / 2); // 1. Modal Authentic Stone Outer Frame & Background boolean scriptsAvailable = PluginManager.isScriptsAvailable(); if (!scriptsAvailable && currentModalTab == 1) { currentModalTab = 0; } drawStoneBox(g, mx, my, MODAL_WIDTH, MODAL_HEIGHT); // 2. Centered Header in Authentic RuneScape Gold with drop shadow String title = scriptsAvailable ? "RUNELITE PLUGIN & SCRIPT HUB" : "RUNELITE PLUGIN HUB"; if (game != null && game.aTextDrawingArea_1271 != null) { game.aTextDrawingArea_1271.textCenterShadow(0xff981f, mx + (MODAL_WIDTH / 2), title, my + 19, true); } else { g.drawCenteredString(title, mx + (MODAL_WIDTH / 2), my + 19, 0xff981f); } // 3. Authentic Carved/Etched Stone Divider Line drawEtchedLine(g, mx + 8, my + 27, MODAL_WIDTH - 16); // 4. Authentic Red Stone Circular Close Button int closeX = mx + MODAL_WIDTH - 25; int closeY = my + 5; drawCloseButton(g, closeX, closeY, 18); // 5. Authentic RuneScape Full-Width Continuous Subtabs (100% width, 0 gaps) int tabY = my + 28; int tabH = 26; int contentX = mx + 10; int contentW = MODAL_WIDTH - 20; int updateCount = PluginRepoClient.countUpdatesAvailable(pm); String onlineLabel = updateCount > 0 ? "Online Repo (" + updateCount + ")" : "Online Repo"; int numTabs = scriptsAvailable ? 3 : 2; int tabW = contentW / numTabs; drawSubTab(g, contentX, tabY, tabW, tabH, "Plugins", currentModalTab == 0); if (scriptsAvailable) { drawSubTab(g, contentX + tabW, tabY, tabW, tabH, "Scripts", currentModalTab == 1); drawSubTab(g, contentX + (tabW * 2), tabY, contentW - (tabW * 2), tabH, onlineLabel, currentModalTab == 2); } else { drawSubTab(g, contentX + tabW, tabY, contentW - tabW, tabH, onlineLabel, currentModalTab == 2); } // 6. Authentic Sunken Stone Content Well int contentY = getContentAreaY(); int contentH = getContentAreaHeight(); drawStoneWell(g, contentX, contentY, contentW, contentH); int maxScroll = getMaxScroll(pm); clampScroll(pm); int sbWidth = 16; int sbX = mx + MODAL_WIDTH - 28; int sbY = contentY + 2; int sbH = contentH - 4; int wellInnerX = contentX + 1; int wellInnerW = (maxScroll > 0) ? (sbX - wellInnerX) : (contentW - 2); if (currentModalTab == 0) { drawSearchBar(g, wellInnerX + 4, contentY + 2, wellInnerW - 8, 20); drawEtchedLine(g, wellInnerX, contentY + 25, wellInnerW); try { DrawingArea.setDrawingArea(contentY + contentH - 1, wellInnerX, wellInnerX + wellInnerW, contentY + 26); drawPluginsList(g, pm, wellInnerX, contentY + 28 - scrollOffset, wellInnerW); } finally { DrawingArea.defaultDrawingAreaSize(); } } else if (currentModalTab == 1) { drawSearchBar(g, wellInnerX + 4, contentY + 2, wellInnerW - 8, 20); drawEtchedLine(g, wellInnerX, contentY + 25, wellInnerW); try { DrawingArea.setDrawingArea(contentY + contentH - 1, wellInnerX, wellInnerX + wellInnerW, contentY + 26); drawScriptsList(g, pm, wellInnerX, contentY + 28 - scrollOffset, wellInnerW); } finally { DrawingArea.defaultDrawingAreaSize(); } } else if (currentModalTab == 2) { drawSubTab(g, wellInnerX + 4, contentY + 2, 72, 22, "Plugins", currentRepoSubTab == 0); drawSubTab(g, wellInnerX + 79, contentY + 2, 72, 22, "Scripts", currentRepoSubTab == 1); int searchX = wellInnerX + 155; int searchRight = (updateCount > 0) ? (wellInnerX + wellInnerW - 148) : (wellInnerX + wellInnerW - 68); if (searchRight - searchX >= 60) { drawSearchBar(g, searchX, contentY + 3, searchRight - searchX, 20); } if (updateCount > 0) { String updAllLabel = PluginRepoClient.getBusyEntryId() != null ? "Updating..." : "Update All"; drawStoneButton(g, wellInnerX + wellInnerW - 144, contentY + 2, 76, 22, updAllLabel, 0x55d0ff, false); } String refreshLabel = PluginRepoClient.isLoading() ? "Loading..." : "Refresh"; drawStoneButton(g, wellInnerX + wellInnerW - 64, contentY + 2, 62, 22, refreshLabel, 0xffd700, false); drawEtchedLine(g, wellInnerX, contentY + 25, wellInnerW); try { DrawingArea.setDrawingArea(contentY + contentH - 1, wellInnerX, wellInnerX + wellInnerW, contentY + 26); drawRepoList(g, pm, wellInnerX, contentY + 28 - scrollOffset, wellInnerW); } finally { DrawingArea.defaultDrawingAreaSize(); } } else if (currentModalTab == 3) { if (configTarget instanceof ClientScript && !scriptsAvailable) { configTarget = null; } if (configTarget != null) { String name = (configTarget instanceof ClientPlugin) ? ((ClientPlugin) configTarget).getName() : (configTarget instanceof ClientScript) ? ((ClientScript) configTarget).getName() : "Config"; String desc = (configTarget instanceof ClientPlugin) ? ((ClientPlugin) configTarget).getDescription() : (configTarget instanceof ClientScript) ? ((ClientScript) configTarget).getDescription() : null; int headerH = getConfigHeaderHeight(); g.drawStringBoldTruncated("Settings: " + name, wellInnerX + 8, contentY + 16, wellInnerW - 72, 0xff981f, true); drawStoneButton(g, wellInnerX + wellInnerW - 58, contentY + 2, 56, 20, "< Back", 0xffd700, false); if (desc != null && !desc.isEmpty()) { g.drawStringTruncated(desc, wellInnerX + 8, contentY + 30, wellInnerW - 16, 0xa09484, false); drawEtchedLine(g, wellInnerX, contentY + 36, wellInnerW); } else { drawEtchedLine(g, wellInnerX, contentY + 22, wellInnerW); } try { DrawingArea.setDrawingArea(contentY + contentH - 1, wellInnerX, wellInnerX + wellInnerW, contentY + headerH); drawConfigEditor(g, pm, wellInnerX, contentY + headerH + 2 - scrollOffset, wellInnerW); } finally { DrawingArea.defaultDrawingAreaSize(); } drawConfigDropdownOverlay(g, pm, wellInnerX, wellInnerW, contentY, contentH, headerH); } else { currentModalTab = 0; } } // 7. Authentic 2006Scape Scrollbar with Cache Sprites if (maxScroll > 0) { int totalHeight = sbH + maxScroll; if (game != null && game.scrollBar1 != null && game.scrollBar2 != null) { game.drawScrollThumb(sbH, scrollOffset, sbY, sbX, totalHeight); } else { // Fallback for tests or before cache sprite load g.fillRect(sbX, sbY, sbWidth, sbH, 0x23201b, 255); g.drawRect(sbX, sbY, sbWidth, sbH, 0x332d25); int trackH = sbH - 32; int thumbH = Math.max(8, (trackH * sbH) / totalHeight); if (thumbH > trackH) thumbH = trackH; int trackAvail = trackH - thumbH; int thumbY = sbY + 16 + (trackAvail > 0 ? (scrollOffset * trackAvail) / maxScroll : 0); if (thumbY < sbY + 16) thumbY = sbY + 16; if (thumbY + thumbH > sbY + sbH - 16) thumbY = sbY + sbH - 16 - thumbH; g.fillRect(sbX + 1, thumbY, sbWidth - 2, thumbH, 0x4d4233, 255); g.drawVerticalLine(sbX + 1, thumbY, thumbH, 0x766654); g.drawHorizontalLine(sbX + 1, thumbY, sbWidth - 2, 0x766654); g.drawVerticalLine(sbX + sbWidth - 2, thumbY, thumbH, 0x332d25); g.drawHorizontalLine(sbX + 1, thumbY + thumbH - 1, sbWidth - 2, 0x332d25); } } // 8. Authentic Bank-Style Bottom Action Footer (Zero Gaps) int footerY = my + MODAL_HEIGHT - 32; int footerH = 26; drawEtchedLine(g, contentX, footerY - 2, contentW); int w1 = contentW / 2; int w2 = contentW - w1; drawSegmentedFooter(g, contentX, footerY, w1, w2, footerH); // 9. Seal any 0x000000 (transparent) pixels inside modal bounds to prevent // RSImageProducer from punching see-through holes through outlines and text drop shadows. sealTransparency(mx, my, MODAL_WIDTH, MODAL_HEIGHT); } private static void sealTransparency(int mx, int my, int w, int h) { int[] px = DrawingArea.pixels; if (px == null) return; int x0 = Math.max(0, mx); int y0 = Math.max(0, my); int x1 = Math.min(DrawingArea.width, mx + w); int y1 = Math.min(DrawingArea.height, my + h); for (int y = y0; y < y1; y++) { int row = y * DrawingArea.width; for (int x = x0; x < x1; x++) { if (px[row + x] == 0) { px[row + x] = 0x010101; } } } } // ========================================================================= // Authentic RS Stone UI Primitive Renderers // ========================================================================= private static void drawStoneBox(PluginGraphics g, int x, int y, int w, int h) { // Outer black border (use 0x010101 so it is non-zero in drawing buffer) g.drawRect(x, y, w, h, 0x010101); // Bevel layer 1 (outer stone edge) g.drawHorizontalLine(x + 1, y + 1, w - 2, 0x5c5040); g.drawVerticalLine(x + 1, y + 1, h - 2, 0x5c5040); g.drawHorizontalLine(x + 1, y + h - 2, w - 2, 0x1f1a14); g.drawVerticalLine(x + w - 2, y + 1, h - 2, 0x1f1a14); // Bevel layer 2 (inner stone frame) g.drawHorizontalLine(x + 2, y + 2, w - 4, 0x483e32); g.drawVerticalLine(x + 2, y + 2, h - 4, 0x483e32); g.drawHorizontalLine(x + 2, y + h - 3, w - 4, 0x252019); g.drawVerticalLine(x + w - 3, y + 2, h - 4, 0x252019); // Authentic RS interface dark parchment/stone background g.fillRect(x + 3, y + 3, w - 6, h - 6, 0x2a251e, 255); } private static void drawStoneWell(PluginGraphics g, int x, int y, int w, int h) { // Outer dark stone border g.drawRect(x, y, w, h, 0x383025); // Recessed well fill g.fillRect(x + 1, y + 1, w - 2, h - 2, 0x1f1b16, 255); // Inner shadow on top and left g.drawHorizontalLine(x + 1, y + 1, w - 2, 0x14110e); g.drawVerticalLine(x + 1, y + 1, h - 2, 0x14110e); // Inner subtle highlight on bottom and right g.drawHorizontalLine(x + 1, y + h - 2, w - 2, 0x2e271f); g.drawVerticalLine(x + w - 2, y + 1, h - 2, 0x2e271f); } private static void drawEtchedLine(PluginGraphics g, int x, int y, int w) { // Carved stone groove: dark shadow line above, light highlight line below g.drawHorizontalLine(x, y, w, 0x1a1510); g.drawHorizontalLine(x, y + 1, w, 0x5c5040); } private static void drawCloseButton(PluginGraphics g, int x, int y, int size) { // Authentic circular / beveled red stone close button g.drawRect(x, y, size, size, 0x010101); // Bevel highlight (top & left) g.drawHorizontalLine(x + 1, y + 1, size - 2, 0xb82828); g.drawVerticalLine(x + 1, y + 1, size - 2, 0xb82828); // Bevel shadow (bottom & right) g.drawHorizontalLine(x + 1, y + size - 2, size - 2, 0x480808); g.drawVerticalLine(x + size - 2, y + 1, size - 2, 0x480808); // Red stone fill g.fillRect(x + 2, y + 2, size - 4, size - 4, 0x801414, 255); // Crisp white 'X' g.drawCenteredString("X", x + (size / 2), y + 13, 0xffffff); } private static void drawSubTab(PluginGraphics g, int x, int y, int w, int h, String label, boolean selected) { g.drawRect(x, y, w, h, 0x010101); if (selected) { // Selected tab: lighter stone, connects seamlessly into content well below g.fillRect(x + 1, y + 1, w - 2, h, 0x2a251e, 255); g.drawHorizontalLine(x + 1, y + 1, w - 2, 0x6e604d); g.drawVerticalLine(x + 1, y + 1, h - 1, 0x6e604d); g.drawVerticalLine(x + w - 2, y + 1, h - 1, 0x1f1a14); // Open seam at bottom g.drawHorizontalLine(x + 1, y + h, w - 2, 0x2a251e); g.drawStringBold(label, x + (w - g.getTextWidth(label)) / 2, y + (h / 2) + 4, 0xff981f, true); } else { // Unselected tab: recessed dark stone, closed bottom g.fillRect(x + 1, y + 1, w - 2, h - 2, 0x1f1b16, 255); g.drawHorizontalLine(x + 1, y + 1, w - 2, 0x3e3529); g.drawVerticalLine(x + 1, y + 1, h - 2, 0x3e3529); g.drawHorizontalLine(x + 1, y + h - 1, w - 2, 0x383025); g.drawVerticalLine(x + w - 2, y + 1, h - 2, 0x16130f); g.drawString(label, x + (w - g.getTextWidth(label)) / 2, y + (h / 2) + 4, 0x9c907e, false); } } private static void drawSegmentedFooter(PluginGraphics g, int x, int y, int w1, int w2, int h) { int totalW = w1 + w2; g.drawRect(x, y, totalW, h, 0x010101); // Segment 1 (Open Files) g.fillRect(x + 1, y + 1, w1 - 1, h - 2, 0x3e3529, 255); g.drawHorizontalLine(x + 1, y + 1, w1 - 1, 0x655542); g.drawVerticalLine(x + 1, y + 1, h - 2, 0x655542); g.drawHorizontalLine(x + 1, y + h - 2, w1 - 1, 0x1f1a14); g.drawStringBold("Open Files", x + (w1 - g.getTextWidth("Open Files")) / 2, y + (h / 2) + 4, 0xff981f, true); // Center divider line g.drawVerticalLine(x + w1, y, h, 0x010101); // Segment 2 (Reload Extensions) g.fillRect(x + w1 + 1, y + 1, w2 - 2, h - 2, 0x3e3529, 255); g.drawHorizontalLine(x + w1 + 1, y + 1, w2 - 2, 0x655542); g.drawHorizontalLine(x + w1 + 1, y + h - 2, w2 - 2, 0x1f1a14); g.drawVerticalLine(x + totalW - 2, y + 1, h - 2, 0x1f1a14); g.drawStringBold("Reload Extensions", x + w1 + (w2 - g.getTextWidth("Reload Extensions")) / 2, y + (h / 2) + 4, 0xff981f, true); } private static void drawSegmentedToggleGroup(PluginGraphics g, int x, int y, int toggleW, int gearW, int h, boolean enabled, String toggleText) { int totalW = toggleW + gearW; g.drawRect(x, y, totalW, h, 0x010101); // Toggle segment (left) int fill = enabled ? 0x1b461f : 0x332c23; int hl = enabled ? 0x347c3c : 0x52473a; int sh = enabled ? 0x0f2611 : 0x181410; int txtColor = enabled ? 0x76ff76 : 0x9c907e; g.fillRect(x + 1, y + 1, toggleW - 1, h - 2, fill, 255); g.drawHorizontalLine(x + 1, y + 1, toggleW - 1, hl); g.drawVerticalLine(x + 1, y + 1, h - 2, hl); g.drawHorizontalLine(x + 1, y + h - 2, toggleW - 1, sh); g.drawStringBold(toggleText, x + (toggleW - g.getTextWidth(toggleText)) / 2, y + (h / 2) + 4, txtColor, true); // Center divider line g.drawVerticalLine(x + toggleW, y, h, 0x010101); // CFG segment (right) g.fillRect(x + toggleW + 1, y + 1, gearW - 2, h - 2, 0x3e3529, 255); g.drawHorizontalLine(x + toggleW + 1, y + 1, gearW - 2, 0x655542); g.drawHorizontalLine(x + toggleW + 1, y + h - 2, gearW - 2, 0x1f1a14); g.drawVerticalLine(x + totalW - 2, y + 1, h - 2, 0x1f1a14); g.drawStringBold("CFG", x + toggleW + (gearW - g.getTextWidth("CFG")) / 2, y + (h / 2) + 4, 0xffd700, true); } private static void drawSegmentedScriptGroup(PluginGraphics g, int x, int y, int stopW, int pauseW, int gearW, int h, boolean paused) { int totalW = stopW + pauseW + gearW; g.drawRect(x, y, totalW, h, 0x010101); // Stop segment g.fillRect(x + 1, y + 1, stopW - 1, h - 2, 0x5a1818, 255); g.drawHorizontalLine(x + 1, y + 1, stopW - 1, 0x8a2626); g.drawVerticalLine(x + 1, y + 1, h - 2, 0x8a2626); g.drawHorizontalLine(x + 1, y + h - 2, stopW - 1, 0x300c0c); g.drawStringBold("STOP", x + (stopW - g.getTextWidth("STOP")) / 2, y + (h / 2) + 4, 0xff7676, true); // Divider 1 g.drawVerticalLine(x + stopW, y, h, 0x010101); // Pause segment g.fillRect(x + stopW + 1, y + 1, pauseW - 1, h - 2, 0x544014, 255); g.drawHorizontalLine(x + stopW + 1, y + 1, pauseW - 1, 0x866620); g.drawHorizontalLine(x + stopW + 1, y + h - 2, pauseW - 1, 0x2c220a); String pauseTxt = paused ? "RES" : "PAUS"; g.drawStringBold(pauseTxt, x + stopW + (pauseW - g.getTextWidth(pauseTxt)) / 2, y + (h / 2) + 4, 0xffd700, true); // Divider 2 g.drawVerticalLine(x + stopW + pauseW, y, h, 0x010101); // CFG segment g.fillRect(x + stopW + pauseW + 1, y + 1, gearW - 2, h - 2, 0x3e3529, 255); g.drawHorizontalLine(x + stopW + pauseW + 1, y + 1, gearW - 2, 0x655542); g.drawHorizontalLine(x + stopW + pauseW + 1, y + h - 2, gearW - 2, 0x1f1a14); g.drawVerticalLine(x + totalW - 2, y + 1, h - 2, 0x1f1a14); g.drawStringBold("CFG", x + stopW + pauseW + (gearW - g.getTextWidth("CFG")) / 2, y + (h / 2) + 4, 0xffd700, true); } private static void drawStoneButton(PluginGraphics g, int x, int y, int w, int h, String label, int textRgb, boolean pressed) { g.drawRect(x, y, w, h, 0x010101); int fill = pressed ? 0x2f2820 : 0x3e3529; int hl = pressed ? 0x1f1a14 : 0x655542; int sh = pressed ? 0x655542 : 0x1f1a14; g.fillRect(x + 1, y + 1, w - 2, h - 2, fill, 255); g.drawHorizontalLine(x + 1, y + 1, w - 2, hl); g.drawVerticalLine(x + 1, y + 1, h - 2, hl); g.drawHorizontalLine(x + 1, y + h - 2, w - 2, sh); g.drawVerticalLine(x + w - 2, y + 1, h - 2, sh); g.drawStringBold(label, x + (w - g.getTextWidth(label)) / 2, y + (h / 2) + 4, textRgb, true); } private static void drawColoredButton(PluginGraphics g, int x, int y, int w, int h, String label, int fillRgb, int borderRgb, int shadowRgb, int textRgb) { g.drawRect(x, y, w, h, 0x010101); g.fillRect(x + 1, y + 1, w - 2, h - 2, fillRgb, 255); g.drawHorizontalLine(x + 1, y + 1, w - 2, borderRgb); g.drawVerticalLine(x + 1, y + 1, h - 2, borderRgb); g.drawHorizontalLine(x + 1, y + h - 2, w - 2, shadowRgb); g.drawVerticalLine(x + w - 2, y + 1, h - 2, shadowRgb); g.drawStringBold(label, x + (w - g.getTextWidth(label)) / 2, y + (h / 2) + 4, textRgb, true); } // ========================================================================= // Content Lists (Plugins, Scripts, Config) // ========================================================================= private static void drawSearchBar(PluginGraphics g, int x, int y, int w, int h) { int bg = searchFocused ? 0x1a1510 : 0x16120d; int border = searchFocused ? 0xffd700 : 0x453b2e; g.fillRect(x, y, w, h, bg, 255); g.drawRect(x, y, w, h, border); boolean hasQuery = searchQuery != null && !searchQuery.isEmpty(); int textMaxW = hasQuery ? (w - 28) : (w - 12); if (hasQuery) { String display = searchFocused ? (searchQuery + "_") : searchQuery; g.drawStringTruncated(display, x + 6, y + 14, textMaxW, 0xffffff, false); int clearX = x + w - 20; g.fillRect(clearX, y + 1, 19, h - 2, 0x352c22, 255); g.drawString("X", clearX + 6, y + 14, 0xff9090, false); } else { String placeholder = searchFocused ? "_" : "Search..."; int col = searchFocused ? 0xffffff : 0x807464; g.drawStringTruncated(placeholder, x + 6, y + 14, textMaxW, col, false); } } private static void drawPluginsList(PluginGraphics g, PluginManager pm, int x, int y, int w) { List list = getFilteredPlugins(pm); int rowY = y; int i = 0; if (list != null && !list.isEmpty()) { for (; i < list.size(); i++) { if (rowY + 36 >= DrawingArea.topY && rowY <= DrawingArea.bottomY) { ClientPlugin p = list.get(i); int rowFill = (i % 2 == 0) ? 0x26211b : 0x201b15; g.fillRect(x, rowY, w, 38, rowFill, 255); g.drawHorizontalLine(x, rowY, w, 0x16130f); g.drawHorizontalLine(x, rowY + 37, w, 0x322b22); // Seamless Segmented Toggle + CFG Control (docked flush against row borders and right edge) int groupW = 84; int groupX = x + w - groupW; int btnY = rowY + 1; int maxTextW = groupX - (x + 10) - 8; // Plugin Name and Description (bounded with RuneLite-style ellipsis truncation) g.drawStringBoldTruncated(p.getName() + " v" + p.getVersion(), x + 10, rowY + 16, maxTextW, 0xffffff, true); g.drawStringTruncated(p.getDescription(), x + 10, rowY + 30, maxTextW, 0xa09484, false); drawSegmentedToggleGroup(g, groupX, btnY, 50, 34, 36, p.isEnabled(), p.isEnabled() ? "ON" : "OFF"); } rowY += 38; } } else if (searchQuery != null && !searchQuery.isEmpty()) { g.drawString("No matching plugins.", x + 10, y + 20, 0xa09484, false); return; } // Fill remaining well area with alternating empty rows while (rowY <= DrawingArea.bottomY) { int rowFill = (i % 2 == 0) ? 0x26211b : 0x201b15; g.fillRect(x, rowY, w, 38, rowFill, 255); g.drawHorizontalLine(x, rowY, w, 0x16130f); g.drawHorizontalLine(x, rowY + 37, w, 0x322b22); rowY += 38; i++; } } private static void drawScriptsList(PluginGraphics g, PluginManager pm, int x, int y, int w) { List list = getFilteredScripts(pm); int rowY = y; int i = 0; if (list != null && !list.isEmpty()) { for (; i < list.size(); i++) { if (rowY + 36 >= DrawingArea.topY && rowY <= DrawingArea.bottomY) { ClientScript s = list.get(i); int rowFill = (i % 2 == 0) ? 0x26211b : 0x201b15; g.fillRect(x, rowY, w, 38, rowFill, 255); g.drawHorizontalLine(x, rowY, w, 0x16130f); g.drawHorizontalLine(x, rowY + 37, w, 0x322b22); // Seamless Segmented Controls (docked flush against row borders and right edge) int btnY = rowY + 1; int groupW = s.isRunning() ? (44 + 44 + 34) : (50 + 34); int groupX = x + w - groupW; int maxTextW = groupX - (x + 10) - 8; // Script Name and status (bounded with RuneLite-style ellipsis truncation) g.drawStringBoldTruncated(s.getName() + " v" + s.getVersion(), x + 10, rowY + 16, maxTextW, 0xffffff, true); g.drawStringTruncated(s.getDescription() + " [" + s.getStatus() + "]", x + 10, rowY + 30, maxTextW, s.isRunning() ? 0x60e080 : 0xa09484, false); if (s.isRunning()) { drawSegmentedScriptGroup(g, groupX, btnY, 44, 44, 34, 36, s.isPaused()); } else { drawSegmentedToggleGroup(g, groupX, btnY, 50, 34, 36, false, "START"); } } rowY += 38; } } else if (searchQuery != null && !searchQuery.isEmpty()) { g.drawString("No matching scripts.", x + 10, y + 20, 0xa09484, false); return; } // Fill remaining well area with alternating empty rows while (rowY <= DrawingArea.bottomY) { int rowFill = (i % 2 == 0) ? 0x26211b : 0x201b15; g.fillRect(x, rowY, w, 38, rowFill, 255); g.drawHorizontalLine(x, rowY, w, 0x16130f); g.drawHorizontalLine(x, rowY + 37, w, 0x322b22); rowY += 38; i++; } } private static List getFilteredRepoEntries() { List all = PluginRepoClient.getEntries(); List filtered = new java.util.ArrayList<>(); if (all == null) return filtered; boolean wantPlugin = (currentRepoSubTab == 0); for (PluginRepoClient.RepoEntry entry : all) { boolean isPlugin = "plugin".equalsIgnoreCase(entry.type); if (isPlugin == wantPlugin && matchesSearch(entry.name, entry.description, entry.author)) { filtered.add(entry); } } return filtered; } private static void drawRepoList(PluginGraphics g, PluginManager pm, int x, int y, int w) { if (PluginRepoClient.isLoading() && PluginRepoClient.getEntries().isEmpty()) { g.drawString("Fetching online repository index...", x + 10, y + 20, 0xa09484, false); return; } String err = PluginRepoClient.getLastError(); List allEntries = PluginRepoClient.getEntries(); if ((allEntries == null || allEntries.isEmpty()) && err != null) { g.drawStringTruncated("Repo error: " + err, x + 10, y + 20, w - 20, 0xff6060, false); return; } List entries = getFilteredRepoEntries(); if (entries.isEmpty()) { String emptyMsg = (searchQuery != null && !searchQuery.isEmpty()) ? "No matching entries." : ((currentRepoSubTab == 0) ? "No plugins found in online repository." : "No scripts found in online repository."); g.drawString(emptyMsg, x + 10, y + 20, 0xa09484, false); return; } int rowY = y; if (err != null && !err.isEmpty()) { g.fillRect(x, rowY, w, 20, 0x3b1818, 255); g.drawStringTruncated(err, x + 8, rowY + 14, w - 16, 0xff7070, false); rowY += 22; } int i = 0; String busyId = PluginRepoClient.getBusyEntryId(); for (; i < entries.size(); i++) { if (rowY + 36 >= DrawingArea.topY && rowY <= DrawingArea.bottomY) { PluginRepoClient.RepoEntry entry = entries.get(i); int rowFill = (i % 2 == 0) ? 0x26211b : 0x201b15; g.fillRect(x, rowY, w, 38, rowFill, 255); g.drawHorizontalLine(x, rowY, w, 0x16130f); g.drawHorizontalLine(x, rowY + 37, w, 0x322b22); int btnW = 74; int btnX = x + w - btnW; int maxTextW = btnX - (x + 10) - 8; String entryKey = entry.id.isEmpty() ? entry.name : entry.id; boolean isBusy = busyId != null && busyId.equals(entryKey); PluginRepoClient.InstallStatus status = PluginRepoClient.getInstallStatus(entry, pm); String verText = "v" + entry.version; if (status == PluginRepoClient.InstallStatus.UPDATE_AVAILABLE) { SemVer installedVer = PluginRepoClient.findInstalledVersion(entry, pm); if (installedVer != null) { verText = "v" + installedVer + " -> v" + entry.version; } } String title = entry.name + " " + verText + " (" + entry.author + ")"; g.drawStringBoldTruncated(title, x + 10, rowY + 16, maxTextW, 0xffffff, true); g.drawStringTruncated(entry.description, x + 10, rowY + 30, maxTextW, 0xa09484, false); String btnLabel; int btnColor; if (isBusy) { btnLabel = "..."; btnColor = 0xa09484; } else if (status == PluginRepoClient.InstallStatus.INCOMPATIBLE) { btnLabel = "API " + entry.minApi; btnColor = 0xff6060; } else if (status == PluginRepoClient.InstallStatus.UPDATE_AVAILABLE) { btnLabel = "Update"; btnColor = 0x55d0ff; } else if (status == PluginRepoClient.InstallStatus.UP_TO_DATE) { btnLabel = "Remove"; btnColor = 0xe06060; } else { btnLabel = "Install"; btnColor = 0x60e080; } drawStoneButton(g, btnX, rowY + 1, btnW, 36, btnLabel, btnColor, false); } rowY += 38; } while (rowY <= DrawingArea.bottomY) { int rowFill = (i % 2 == 0) ? 0x26211b : 0x201b15; g.fillRect(x, rowY, w, 38, rowFill, 255); g.drawHorizontalLine(x, rowY, w, 0x16130f); g.drawHorizontalLine(x, rowY + 37, w, 0x322b22); rowY += 38; i++; } } private static void drawConfigTargetSelector(PluginGraphics g, PluginManager pm, int x, int y, int w) { List list = pm.getPlugins(); int rowY = y; int i = 0; if (list != null) { for (; i < list.size(); i++) { if (rowY + 36 >= DrawingArea.topY && rowY <= DrawingArea.bottomY) { ClientPlugin p = list.get(i); int rowFill = (i % 2 == 0) ? 0x26211b : 0x201b15; g.fillRect(x, rowY, w, 38, rowFill, 255); g.drawHorizontalLine(x, rowY, w, 0x16130f); g.drawHorizontalLine(x, rowY + 37, w, 0x322b22); int btnW = 74; int btnX = x + w - btnW; int maxTextW = btnX - (x + 10) - 8; g.drawStringBoldTruncated(p.getName() + " v" + p.getVersion(), x + 10, rowY + 16, maxTextW, 0xffffff, true); g.drawStringTruncated(p.getDescription(), x + 10, rowY + 30, maxTextW, 0xa09484, false); drawStoneButton(g, btnX, rowY + 1, btnW, 36, "Configure", 0xffd700, false); } rowY += 38; } } // Fill remaining well area with alternating empty rows while (rowY <= DrawingArea.bottomY) { int rowFill = (i % 2 == 0) ? 0x26211b : 0x201b15; g.fillRect(x, rowY, w, 38, rowFill, 255); g.drawHorizontalLine(x, rowY, w, 0x16130f); g.drawHorizontalLine(x, rowY + 37, w, 0x322b22); rowY += 38; i++; } } private static void drawConfigEditor(PluginGraphics g, PluginManager pm, int x, int y, int w) { List items = getVisibleConfigItems(pm, configTarget); if (items == null || items.isEmpty()) { g.drawString("No configurable settings available.", x + 8, y + 16, 0xa09484, false); return; } int rowY = y; for (int i = 0; i < items.size(); i++) { if (rowY + 28 >= DrawingArea.topY && rowY <= DrawingArea.bottomY) { PluginConfigItem item = items.get(i); int rowFill = (i % 2 == 0) ? 0x26211b : 0x201b15; g.fillRect(x, rowY, w, 32, rowFill, 255); g.drawHorizontalLine(x, rowY, w, 0x16130f); g.drawHorizontalLine(x, rowY + 31, w, 0x322b22); int maxLabelW = (item.getType() == PluginConfigItem.Type.BOOLEAN) ? (w - 60 - 20) : (item.getType() == PluginConfigItem.Type.INTEGER) ? (w - 126 - 20) : (item.getType() == PluginConfigItem.Type.CHOICE) ? (w - DROPDOWN_WIDTH - 20) : (w - 180); g.drawStringTruncated(item.getLabel(), x + 10, rowY + 20, maxLabelW, 0xffffff, false); if (item.getType() == PluginConfigItem.Type.BOOLEAN) { boolean currentVal = pm.getConfigBoolean(configTarget, item); int btnW = 60; int btnX = x + w - btnW; int btnY = rowY + 1; if (currentVal) { drawColoredButton(g, btnX, btnY, btnW, 30, "ON", 0x1b461f, 0x347c3c, 0x0f2611, 0x76ff76); } else { drawColoredButton(g, btnX, btnY, btnW, 30, "OFF", 0x332c23, 0x52473a, 0x181410, 0x9c907e); } } else if (item.getType() == PluginConfigItem.Type.INTEGER) { int currentVal = pm.getConfigInt(configTarget, item); int stepperW = 126; int stepX = x + w - stepperW; int btnY = rowY + 1; int btnH = 30; // Segmented Stepper [ - | 1000000 | + ] (flush, zero gaps, 126px width) g.drawRect(stepX, btnY, stepperW, btnH, 0x010101); // Minus [-] g.fillRect(stepX + 1, btnY + 1, 27, btnH - 2, 0x3e3529, 255); g.drawHorizontalLine(stepX + 1, btnY + 1, 27, 0x655542); g.drawVerticalLine(stepX + 1, btnY + 1, btnH - 2, 0x655542); g.drawHorizontalLine(stepX + 1, btnY + btnH - 2, 27, 0x1f1a14); g.drawStringBold("-", stepX + 11, btnY + 19, 0xffffff, true); // Divider 1 g.drawVerticalLine(stepX + 28, btnY, btnH, 0x010101); // Value display (68px wide compartment, comfortably fits up to 10 digits without overlap) g.fillRect(stepX + 29, btnY + 1, 68, btnH - 2, 0x2a251e, 255); g.drawCenteredString(String.valueOf(currentVal), stepX + 63, btnY + 19, 0xffd700); // Divider 2 g.drawVerticalLine(stepX + 97, btnY, btnH, 0x010101); // Plus [+] g.fillRect(stepX + 98, btnY + 1, 27, btnH - 2, 0x3e3529, 255); g.drawHorizontalLine(stepX + 98, btnY + 1, 27, 0x655542); g.drawHorizontalLine(stepX + 98, btnY + btnH - 2, 27, 0x1f1a14); g.drawVerticalLine(stepX + stepperW - 2, btnY + 1, btnH - 2, 0x1f1a14); g.drawStringBold("+", stepX + 107, btnY + 19, 0xffffff, true); } else if (item.getType() == PluginConfigItem.Type.CHOICE) { String currentVal = String.valueOf(pm.getConfigValue(configTarget, item)); int dropX = x + w - DROPDOWN_WIDTH; int btnY = rowY + 1; int btnH = 30; boolean isOpen = item.getKey().equals(openDropdownKey); g.drawRect(dropX, btnY, DROPDOWN_WIDTH, btnH, 0x010101); g.fillRect(dropX + 1, btnY + 1, DROPDOWN_WIDTH - 25, btnH - 2, isOpen ? 0x352e25 : 0x2a251e, 255); g.drawHorizontalLine(dropX + 1, btnY + 1, DROPDOWN_WIDTH - 2, 0x52473a); g.drawVerticalLine(dropX + 1, btnY + 1, btnH - 2, 0x52473a); g.drawStringTruncated(currentVal, dropX + 8, btnY + 19, DROPDOWN_WIDTH - 34, 0xffd700, true); // Arrow compartment [v] / [^] int arrowX = dropX + DROPDOWN_WIDTH - 24; g.drawVerticalLine(arrowX, btnY, btnH, 0x010101); g.fillRect(arrowX + 1, btnY + 1, 22, btnH - 2, 0x3e3529, 255); g.drawHorizontalLine(arrowX + 1, btnY + 1, 22, 0x655542); g.drawStringBold(isOpen ? "^" : "v", arrowX + 8, btnY + 19, 0xffffff, true); } else { g.drawString("(Edit in .properties or chat)", x + w - 170, rowY + 20, 0xa09484, false); } } rowY += 32; } // Fill remaining well area with alternating empty rows int extraIdx = items.size(); while (rowY <= DrawingArea.bottomY) { int rowFill = (extraIdx % 2 == 0) ? 0x26211b : 0x201b15; g.fillRect(x, rowY, w, 32, rowFill, 255); g.drawHorizontalLine(x, rowY, w, 0x16130f); g.drawHorizontalLine(x, rowY + 31, w, 0x322b22); rowY += 32; extraIdx++; } } private static void drawConfigDropdownOverlay(PluginGraphics g, PluginManager pm, int wellInnerX, int wellInnerW, int contentY, int contentH, int headerH) { int[] b = getOpenDropdownBounds(pm); if (b == null) return; List items = getVisibleConfigItems(pm, configTarget); if (items == null || b[4] >= items.size()) return; PluginConfigItem item = items.get(b[4]); String[] choices = item.getChoices(); if (choices == null || choices.length == 0) return; int dropX = b[0]; int dropY = b[1]; int dropW = b[2]; int dropH = b[3]; int maxDropScroll = Math.max(0, choices.length * DROPDOWN_ROW_H + 2 - dropH); if (dropdownScrollOffset > maxDropScroll) dropdownScrollOffset = maxDropScroll; if (dropdownScrollOffset < 0) dropdownScrollOffset = 0; g.fillRect(dropX, dropY, dropW, dropH, 0x1e1914, 248); g.drawRect(dropX, dropY, dropW, dropH, 0x655542); String currentVal = String.valueOf(pm.getConfigValue(configTarget, item)); int listW = (maxDropScroll > 0) ? (dropW - 8) : (dropW - 2); try { DrawingArea.setDrawingArea(dropY + dropH - 1, dropX + 1, dropX + 1 + listW, dropY + 1); int optY = dropY + 1 - dropdownScrollOffset; for (int ci = 0; ci < choices.length; ci++) { if (optY + DROPDOWN_ROW_H >= dropY && optY <= dropY + dropH) { boolean selected = choices[ci].equalsIgnoreCase(currentVal); int bg = selected ? 0x3b3226 : ((ci % 2 == 0) ? 0x241f19 : 0x1e1914); g.fillRect(dropX + 1, optY, listW, DROPDOWN_ROW_H, bg, 255); g.drawHorizontalLine(dropX + 1, optY + DROPDOWN_ROW_H - 1, listW, 0x14100c); g.drawStringTruncated(choices[ci], dropX + 8, optY + 15, listW - 14, selected ? 0xffd700 : 0xffffff, selected); } optY += DROPDOWN_ROW_H; } } finally { DrawingArea.defaultDrawingAreaSize(); } if (maxDropScroll > 0) { int trackX = dropX + dropW - 6; int trackY = dropY + 2; int trackH = dropH - 4; g.fillRect(trackX, trackY, 4, trackH, 0x14100c, 255); int thumbH = Math.max(10, (trackH * dropH) / (choices.length * DROPDOWN_ROW_H + 2)); int avail = Math.max(0, trackH - thumbH); int thumbY = trackY + (avail * dropdownScrollOffset) / maxDropScroll; g.fillRect(trackX, thumbY, 4, thumbH, 0x766654, 255); } } // ========================================================================= // Modal Click Handling // ========================================================================= public static boolean handleModalClick(int clickX, int clickY) { if (!modalOpen) return false; PluginManager pm = PluginManager.get(); if (pm == null) return false; if (wasDrag) { wasDrag = false; return true; } int cx = toLocalX(clickX); int cy = toLocalY(clickY); int vw = getModalAreaWidth(); int vh = getModalAreaHeight(); int mx = Math.max(0, (vw - MODAL_WIDTH) / 2); int my = Math.max(0, (vh - MODAL_HEIGHT) / 2); // Click outside modal closes it if (cx < mx || cx > mx + MODAL_WIDTH || cy < my || cy > my + MODAL_HEIGHT) { closeModal(); return true; } // Close button [X] int closeX = mx + MODAL_WIDTH - 25; int closeY = my + 5; if (cx >= closeX - 4 && cx <= closeX + 22 && cy >= closeY - 4 && cy <= closeY + 22) { closeModal(); return true; } // Top Full-Width Tabs (0 gaps) int tabY = my + 28; int contentX = mx + 10; int contentW = MODAL_WIDTH - 20; boolean scriptsAvailable = PluginManager.isScriptsAvailable(); int numTabs = scriptsAvailable ? 3 : 2; int tabW = contentW / numTabs; if (cy >= tabY && cy <= tabY + 26) { searchFocused = false; if (scriptsAvailable) { // Tab 0: Plugins if (cx >= contentX && cx < contentX + tabW) { currentModalTab = 0; scrollOffset = 0; return true; } // Tab 1: Scripts if (cx >= contentX + tabW && cx < contentX + (tabW * 2)) { currentModalTab = 1; scrollOffset = 0; return true; } // Tab 2: Online Repo if (cx >= contentX + (tabW * 2) && cx <= contentX + contentW) { currentModalTab = 2; configTarget = null; scrollOffset = 0; PluginRepoClient.ensureLoaded(); return true; } } else { // Tab 0: Plugins if (cx >= contentX && cx < contentX + tabW) { currentModalTab = 0; scrollOffset = 0; return true; } // Tab 2: Online Repo if (cx >= contentX + tabW && cx <= contentX + contentW) { currentModalTab = 2; configTarget = null; scrollOffset = 0; PluginRepoClient.ensureLoaded(); return true; } } } // Bottom Footer Action Buttons (Segmented Full-Width, 0 gaps) int footerY = my + MODAL_HEIGHT - 32; int footerH = 26; int w1 = contentW / 2; if (cy >= footerY && cy <= footerY + footerH && cx >= contentX && cx <= contentX + contentW) { // Left Half: Open Files if (cx < contentX + w1) { AndroidHooks.openScriptsFolder(); if (pm.getContext() != null) { pm.getContext().sendClientMessage(scriptsAvailable ? "Opened plugins & scripts directory." : "Opened plugins directory."); } return true; } // Right Half: Reload Extensions else { pm.reloadExternal(); scrollOffset = 0; if (pm.getContext() != null) { pm.getContext().sendClientMessage(scriptsAvailable ? "Reloaded external plugins and scripts." : "Reloaded external plugins."); } return true; } } int contentY = getContentAreaY(); int contentH = getContentAreaHeight(); int maxScroll = getMaxScroll(pm); int sbX = mx + MODAL_WIDTH - 28; int wellInnerX = contentX + 1; int wellInnerW = (maxScroll > 0) ? (sbX - wellInnerX) : (contentW - 2); // Scrollbar click / tap jump if (maxScroll > 0 && isScrollBarAt(clickX, clickY)) { handleScrollBarJump(pm, cy, maxScroll); return true; } if (currentModalTab == 0) { if (handleSearchBarClick(cx, cy, wellInnerX + 4, contentY + 2, wellInnerW - 8, 20)) { return true; } searchFocused = false; if (cy < contentY + 26 || cy > contentY + contentH) { return true; } List list = getFilteredPlugins(pm); int rowY = contentY + 28 - scrollOffset; for (ClientPlugin p : list) { if (rowY + 36 >= contentY + 26 && rowY <= contentY + contentH) { int groupW = 84; int groupX = wellInnerX + wellInnerW - groupW; int btnY = rowY + 1; int btnH = 36; // Toggle segment if (cx >= groupX && cx < groupX + 50 && cy >= btnY && cy <= btnY + btnH) { pm.togglePlugin(p); return true; } // CFG segment if (cx >= groupX + 50 && cx <= groupX + groupW && cy >= btnY && cy <= btnY + btnH) { configTarget = p; configReturnTab = 0; currentModalTab = 3; scrollOffset = 0; return true; } } rowY += 38; } } else if (currentModalTab == 1) { if (handleSearchBarClick(cx, cy, wellInnerX + 4, contentY + 2, wellInnerW - 8, 20)) { return true; } searchFocused = false; if (cy < contentY + 26 || cy > contentY + contentH) { return true; } List list = getFilteredScripts(pm); int rowY = contentY + 28 - scrollOffset; for (ClientScript s : list) { if (rowY + 36 >= contentY + 26 && rowY <= contentY + contentH) { int btnY = rowY + 1; int btnH = 36; if (s.isRunning()) { int groupW = 44 + 44 + 34; // 122px int groupX = wellInnerX + wellInnerW - groupW; // STOP if (cx >= groupX && cx < groupX + 44 && cy >= btnY && cy <= btnY + btnH) { pm.stopScript(s); return true; } // PAUSE / RESUME if (cx >= groupX + 44 && cx < groupX + 88 && cy >= btnY && cy <= btnY + btnH) { pm.pauseResumeScript(s); return true; } // CFG if (cx >= groupX + 88 && cx <= groupX + groupW && cy >= btnY && cy <= btnY + btnH) { configTarget = s; configReturnTab = 1; currentModalTab = 3; scrollOffset = 0; return true; } } else { int groupW = 50 + 34; // 84px int groupX = wellInnerX + wellInnerW - groupW; // START if (cx >= groupX && cx < groupX + 50 && cy >= btnY && cy <= btnY + btnH) { pm.startScript(s); return true; } // CFG if (cx >= groupX + 50 && cx <= groupX + groupW && cy >= btnY && cy <= btnY + btnH) { configTarget = s; configReturnTab = 1; currentModalTab = 3; scrollOffset = 0; return true; } } } rowY += 38; } } else if (currentModalTab == 2) { int searchX = wellInnerX + 155; int searchRight = (PluginRepoClient.countUpdatesAvailable(pm) > 0) ? (wellInnerX + wellInnerW - 148) : (wellInnerX + wellInnerW - 68); if (searchRight - searchX >= 60 && handleSearchBarClick(cx, cy, searchX, contentY + 3, searchRight - searchX, 20)) { return true; } searchFocused = false; if (cx >= wellInnerX + 4 && cx <= wellInnerX + 76 && cy >= contentY + 2 && cy <= contentY + 24) { currentRepoSubTab = 0; scrollOffset = 0; return true; } if (cx >= wellInnerX + 79 && cx <= wellInnerX + 151 && cy >= contentY + 2 && cy <= contentY + 24) { currentRepoSubTab = 1; scrollOffset = 0; return true; } if (cx >= wellInnerX + wellInnerW - 144 && cx <= wellInnerX + wellInnerW - 68 && cy >= contentY + 2 && cy <= contentY + 24 && PluginRepoClient.countUpdatesAvailable(pm) > 0) { PluginRepoClient.updateAllAsync(pm, null); return true; } if (cx >= wellInnerX + wellInnerW - 64 && cx <= wellInnerX + wellInnerW - 2 && cy >= contentY + 2 && cy <= contentY + 24) { PluginRepoClient.fetchIndexAsync(null); return true; } if (cy < contentY + 26 || cy > contentY + contentH) { return true; } List entries = getFilteredRepoEntries(); if (entries == null || PluginRepoClient.getBusyEntryId() != null) { return true; } int rowY = contentY + 28 - scrollOffset; String err = PluginRepoClient.getLastError(); if (err != null && !err.isEmpty()) { rowY += 22; } for (PluginRepoClient.RepoEntry entry : entries) { if (rowY + 36 >= contentY + 26 && rowY <= contentY + contentH) { int btnW = 74; int btnX = wellInnerX + wellInnerW - btnW; int btnY = rowY + 1; int btnH = 36; if (cx >= btnX && cx <= btnX + btnW && cy >= btnY && cy <= btnY + btnH) { PluginRepoClient.InstallStatus status = PluginRepoClient.getInstallStatus(entry, pm); if (status == PluginRepoClient.InstallStatus.NOT_INSTALLED || status == PluginRepoClient.InstallStatus.UPDATE_AVAILABLE) { PluginRepoClient.installOrUpdateAsync(entry, pm, null); } else if (status == PluginRepoClient.InstallStatus.UP_TO_DATE) { PluginRepoClient.uninstall(entry, pm); } return true; } } rowY += 38; } } else if (currentModalTab == 3) { if (configTarget == null) { currentModalTab = configReturnTab; return true; } if (cx >= wellInnerX + wellInnerW - 58 && cx <= wellInnerX + wellInnerW - 2 && cy >= contentY + 2 && cy <= contentY + 22) { currentModalTab = configReturnTab; configTarget = null; scrollOffset = 0; openDropdownKey = null; dropdownScrollOffset = 0; return true; } List items = getVisibleConfigItems(pm, configTarget); if (items == null) return true; int headerH = getConfigHeaderHeight(); if (cy < contentY + headerH || cy > contentY + contentH) { openDropdownKey = null; dropdownScrollOffset = 0; return true; } // Handle open dropdown popup clicks first int[] dropBounds = getOpenDropdownBounds(pm); if (dropBounds != null) { PluginConfigItem openItem = items.get(dropBounds[4]); if (cx >= dropBounds[0] && cx <= dropBounds[0] + dropBounds[2] && cy >= dropBounds[1] && cy <= dropBounds[1] + dropBounds[3]) { String[] choices = openItem.getChoices(); int idx = (cy - (dropBounds[1] + 1) + dropdownScrollOffset) / DROPDOWN_ROW_H; if (idx >= 0 && idx < choices.length) { pm.setConfigValue(configTarget, openItem, choices[idx]); } openDropdownKey = null; dropdownScrollOffset = 0; return true; } int headerDropX = wellInnerX + wellInnerW - DROPDOWN_WIDTH; int headerRowY = contentY + headerH + 2 - scrollOffset + dropBounds[4] * 32; if (cx >= headerDropX && cx <= headerDropX + DROPDOWN_WIDTH && cy >= headerRowY + 1 && cy <= headerRowY + 31) { openDropdownKey = null; dropdownScrollOffset = 0; return true; } openDropdownKey = null; dropdownScrollOffset = 0; } int rowY = contentY + headerH + 2 - scrollOffset; for (PluginConfigItem item : items) { if (rowY + 32 >= contentY + headerH && rowY <= contentY + contentH) { int btnY = rowY + 1; int btnH = 30; if (item.getType() == PluginConfigItem.Type.BOOLEAN) { int btnW = 60; int btnX = wellInnerX + wellInnerW - btnW; if (cx >= btnX && cx <= btnX + btnW && cy >= btnY && cy <= btnY + btnH) { boolean currentVal = pm.getConfigBoolean(configTarget, item); pm.setConfigValue(configTarget, item, !currentVal); return true; } } else if (item.getType() == PluginConfigItem.Type.INTEGER) { int stepperW = 126; int stepX = wellInnerX + wellInnerW - stepperW; int range = item.getMaxValue() - item.getMinValue(); int step = 1; if (range >= 100000000) step = 1000000; else if (range >= 10000000) step = 100000; else if (range >= 1000000) step = 10000; else if (range >= 100000) step = 1000; else if (range >= 10000) step = 100; else if (range >= 1000) step = 10; // Minus segment [-] if (cx >= stepX && cx <= stepX + 28 && cy >= btnY && cy <= btnY + btnH) { int currentVal = pm.getConfigInt(configTarget, item); int nextVal = Math.max(item.getMinValue(), currentVal - step); pm.setConfigValue(configTarget, item, nextVal); return true; } // Plus segment [+] if (cx >= stepX + 97 && cx <= stepX + stepperW && cy >= btnY && cy <= btnY + btnH) { int currentVal = pm.getConfigInt(configTarget, item); int nextVal = Math.min(item.getMaxValue(), currentVal + step); pm.setConfigValue(configTarget, item, nextVal); return true; } } else if (item.getType() == PluginConfigItem.Type.CHOICE && item.getChoices() != null && item.getChoices().length > 0) { int dropX = wellInnerX + wellInnerW - DROPDOWN_WIDTH; if (cx >= dropX && cx <= dropX + DROPDOWN_WIDTH && cy >= btnY && cy <= btnY + btnH) { String[] choices = item.getChoices(); openDropdownKey = item.getKey(); String currentVal = String.valueOf(pm.getConfigValue(configTarget, item)); int curIdx = 0; for (int ci = 0; ci < choices.length; ci++) { if (choices[ci].equalsIgnoreCase(currentVal)) { curIdx = ci; break; } } int visibleH = Math.min(DROPDOWN_MAX_VISIBLE, choices.length) * DROPDOWN_ROW_H + 2; int maxDropScroll = Math.max(0, choices.length * DROPDOWN_ROW_H + 2 - visibleH); dropdownScrollOffset = Math.min(maxDropScroll, Math.max(0, (curIdx - 2) * DROPDOWN_ROW_H)); return true; } } } rowY += 32; } } return true; // Consume any other click inside modal } private static boolean handleSearchBarClick(int cx, int cy, int bx, int by, int bw, int bh) { if (cx >= bx && cx <= bx + bw && cy >= by && cy <= by + bh) { if (searchQuery != null && !searchQuery.isEmpty() && cx >= bx + bw - 20) { searchQuery = ""; scrollOffset = 0; } searchFocused = true; return true; } return false; } }