Skip to content

Commit

Permalink
fix: Avoid assist level panel being overriden by list on search change
Browse files Browse the repository at this point in the history
When you had a search for a quest, you would have the assist panel shown it an assist level wasn't selected, but then the search text being set to empty would then cause the quest list panel to be made active, hiding it again.

This ensures that the active state of the assist panel is considered for trying to show the quest list.
  • Loading branch information
Zoinkwiz committed Dec 9, 2024
1 parent 0fb01f9 commit 58aafc1
Showing 1 changed file with 15 additions and 49 deletions.
64 changes: 15 additions & 49 deletions src/main/java/com/questhelper/panel/QuestHelperPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public class QuestHelperPanel extends PluginPanel
private final FixedWidthPanel questListWrapper = new FixedWidthPanel();
private final JScrollPane scrollableContainer;
public static final int DROPDOWN_HEIGHT = 26;
private boolean settingsPanelActive = false;
public boolean questActive = false;

private final ArrayList<QuestSelectPanel> questSelectPanels = new ArrayList<>();
Expand Down Expand Up @@ -144,7 +143,8 @@ public QuestHelperPanel(QuestHelperPlugin questHelperPlugin, QuestManager questM
settingsBtn.setUI(new BasicButtonUI());
settingsBtn.addActionListener((ev) -> {
assistLevelPanel.rebuild(null, configManager, this);
if (settingsPanelActive)

if (settingsPanelActive())
{
settingsBtn.setBackground(ColorScheme.LIGHT_GRAY_COLOR);
deactivateSettings();
Expand All @@ -154,6 +154,8 @@ public QuestHelperPanel(QuestHelperPlugin questHelperPlugin, QuestManager questM
settingsBtn.setBackground(ColorScheme.DARK_GRAY_COLOR);
activateSettings();
}

onSearchBarChanged();
});
settingsBtn.addMouseListener(new java.awt.event.MouseAdapter()
{
Expand All @@ -164,7 +166,7 @@ public void mouseEntered(java.awt.event.MouseEvent evt)

public void mouseExited(java.awt.event.MouseEvent evt)
{
if (settingsPanelActive)
if (settingsPanelActive())
{
settingsBtn.setBackground(ColorScheme.LIGHT_GRAY_COLOR);
}
Expand Down Expand Up @@ -304,9 +306,6 @@ public void changedUpdate(DocumentEvent e)
JPanel orderPanel = makeDropdownPanel(orderDropdown, "Ordering");
orderPanel.setPreferredSize(new Dimension(PANEL_WIDTH, DROPDOWN_HEIGHT));

JPanel assistanceToggles = new JPanel();


// Skill filtering
SkillFilterPanel skillFilterPanel = new SkillFilterPanel(questHelperPlugin.skillIconManager, questHelperPlugin.getConfigManager());
skillFilterPanel.setVisible(false);
Expand Down Expand Up @@ -402,6 +401,11 @@ private void onSearchBarChanged()
{
final String text = searchBar.getText();

if (settingsPanelActive())
{
return;
}

if ((questOverviewPanel.currentQuest == null || !text.isEmpty()))
{
activateQuestList();
Expand Down Expand Up @@ -469,46 +473,6 @@ private void showMatchingQuests(String text)
});
}

JButton activeDifficulty = null;

private JButton makeButton(String text)
{
JButton minimalAssist = new JButton();
SwingUtil.removeButtonDecorations(minimalAssist);
minimalAssist.setText(text.substring(0, 3));
// minimalAssist.setIcon(PATREON_ICON);
minimalAssist.setToolTipText(text);
minimalAssist.setBackground(ColorScheme.DARK_GRAY_COLOR);
minimalAssist.setUI(new BasicButtonUI());
minimalAssist.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseEntered(java.awt.event.MouseEvent evt)
{
if (activeDifficulty != minimalAssist)
{
minimalAssist.setBackground(ColorScheme.DARK_GRAY_HOVER_COLOR);
}
}

public void mouseClicked(java.awt.event.MouseEvent evt)
{
minimalAssist.setBackground(ColorScheme.BRAND_ORANGE);
if (activeDifficulty != null) activeDifficulty.setBackground(ColorScheme.DARK_GRAY_COLOR);
activeDifficulty = minimalAssist;
}

public void mouseExited(java.awt.event.MouseEvent evt)
{
if (activeDifficulty != minimalAssist)
{
minimalAssist.setBackground(ColorScheme.DARK_GRAY_COLOR);
}
}
});

return minimalAssist;
}

public void refresh(List<QuestHelper> questHelpers, boolean loggedOut,
Map<QuestHelperQuest, QuestState> completedQuests, QuestHelperConfig.QuestFilter... questFilters)
{
Expand Down Expand Up @@ -613,10 +577,13 @@ public void removeQuest()
revalidate();
}

private void activateSettings()
private boolean settingsPanelActive()
{
settingsPanelActive = true;
return scrollableContainer.getViewport().getView() == assistLevelPanel;
}

private void activateSettings()
{
scrollableContainer.setViewportView(assistLevelPanel);
searchQuestsPanel.setVisible(false);

Expand All @@ -626,7 +593,6 @@ private void activateSettings()

private void deactivateSettings()
{
settingsPanelActive = false;
if (questActive && searchBar.getText().isEmpty())
{
scrollableContainer.setViewportView(questOverviewWrapper);
Expand Down

0 comments on commit 58aafc1

Please sign in to comment.