Skip to content

Commit

Permalink
Fix sidebar panel highlighting on start
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoinkwiz committed Sep 29, 2023
1 parent c31cb15 commit c29e78e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 35 deletions.
15 changes: 8 additions & 7 deletions src/main/java/com/questhelper/QuestHelperPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,10 @@ public void onMenuEntryAdded(MenuEntryAdded event)
@Subscribe
public void onChatMessage(ChatMessage chatMessage)
{
if (config.showFan() && chatMessage.getType() == ChatMessageType.GAMEMESSAGE) {
if (config.showFan() && chatMessage.getType() == ChatMessageType.GAMEMESSAGE)
{
if (chatMessage.getMessage().contains("Congratulations! Quest complete!") ||
chatMessage.getMessage().contains("you've completed a quest"))
chatMessage.getMessage().contains("you've completed a quest"))
{
addCheerer();
}
Expand Down Expand Up @@ -487,11 +488,11 @@ private void instantiate(QuestHelperQuest quest)
{
QuestHelper questHelper = quest.getQuestHelper();

Module questModule = (Binder binder) ->
{
binder.bind(QuestHelper.class).toInstance(questHelper);
binder.install(questHelper);
};
Module questModule = (Binder binder) ->
{
binder.bind(QuestHelper.class).toInstance(questHelper);
binder.install(questHelper);
};
Injector questInjector = RuneLite.getInjector().createChildInjector(questModule);
injector.injectMembers(questHelper);
questHelper.setInjector(questInjector);
Expand Down
33 changes: 7 additions & 26 deletions src/main/java/com/questhelper/panel/QuestOverviewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,12 @@ public void addQuest(QuestHelper quest, boolean isActive)

for (PanelDetails panelDetail : steps)
{
QuestStepPanel newStep = new QuestStepPanel(panelDetail, currentStep);
if (panelDetail.getHideCondition() != null && panelDetail.getHideCondition().check(questHelperPlugin.getClient()))
{
continue;
}

QuestStepPanel newStep = new QuestStepPanel(panelDetail, currentStep, quest, questHelperPlugin.getClient());
if (panelDetail.getLockingQuestSteps() != null &&
(panelDetail.getVars() == null
|| panelDetail.getVars().contains(currentQuest.getVar())))
Expand Down Expand Up @@ -356,31 +361,7 @@ public void updateSteps()
public void updateHighlight(Client client, QuestStep newStep)
{
questStepPanelList.forEach(panel -> {
if (panel.panelDetails.getHideCondition() == null || !panel.panelDetails.getHideCondition().check(client))
{
panel.setVisible(true);
boolean highlighted = false;
panel.setLockable(panel.panelDetails.getLockingQuestSteps() != null &&
(panel.panelDetails.getVars() == null || panel.panelDetails.getVars().contains(currentQuest.getVar())));

for (QuestStep step : panel.getSteps())
{
if (step == newStep || step.getSubsteps().contains(newStep))
{
highlighted = true;
panel.updateHighlight(step);
break;
}
}
if (!highlighted)
{
panel.removeHighlight();
}
}
else
{
panel.setVisible(false);
}
panel.updateHighlightCheck(client, newStep, currentQuest);
});

repaint();
Expand Down
38 changes: 36 additions & 2 deletions src/main/java/com/questhelper/panel/QuestStepPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
*/
package com.questhelper.panel;

import com.questhelper.questhelpers.QuestHelper;
import com.questhelper.questinfo.QuestHelperQuest;
import com.questhelper.requirements.Requirement;
import java.awt.BorderLayout;
import java.awt.Color;
Expand Down Expand Up @@ -62,7 +64,7 @@ public class QuestStepPanel extends JPanel

private final ArrayList<QuestRequirementPanel> requirementPanels = new ArrayList<>();

public QuestStepPanel(PanelDetails panelDetails, QuestStep currentStep)
public QuestStepPanel(PanelDetails panelDetails, QuestStep currentStep, QuestHelper quest, Client client)
{
this.panelDetails = panelDetails;

Expand Down Expand Up @@ -159,6 +161,8 @@ public QuestStepPanel(PanelDetails panelDetails, QuestStep currentStep)
{
collapse();
}

updateHighlightCheck(client, currentStep, quest);
}

public void addRequirements(String text, List<Requirement> reqs, String borderLayout)
Expand Down Expand Up @@ -222,6 +226,37 @@ public void setLockable(boolean canLock)
lockStep.setVisible(canLock);
}

public void updateHighlightCheck(Client client, QuestStep newStep, QuestHelper currentQuest)
{
if (panelDetails.getHideCondition() == null || !panelDetails.getHideCondition().check(client))
{
setVisible(true);
boolean highlighted = false;
setLockable(panelDetails.getLockingQuestSteps() != null &&
(panelDetails.getVars() == null || panelDetails.getVars().contains(currentQuest.getVar())));

for (QuestStep step : getSteps())
{
if (step == newStep || step.getSubsteps().contains(newStep))
{
highlighted = true;
updateHighlight(step);
break;
}
}

if (!highlighted)
{
removeHighlight();
}
}
else
{
setVisible(false);
}
}


public void updateHighlight(QuestStep currentStep)
{
expand();
Expand Down Expand Up @@ -342,7 +377,6 @@ private void applyDimmer(boolean brighten, JPanel panel)
for (Component component : panel.getComponents())
{
Color color = component.getForeground();

component.setForeground(brighten ? color.brighter() : color.darker());
}
}
Expand Down

0 comments on commit c29e78e

Please sign in to comment.