Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Avoid assist level panel being overriden by list on search change #1902

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading