time tracking: fix birdhouse notification buttons not doing anything
This commit is contained in:
@@ -42,6 +42,7 @@ public interface TimeTrackingConfig extends Config
|
|||||||
String STOPWATCHES = "stopwatches";
|
String STOPWATCHES = "stopwatches";
|
||||||
String PREFER_SOONEST = "preferSoonest";
|
String PREFER_SOONEST = "preferSoonest";
|
||||||
String NOTIFY = "notify";
|
String NOTIFY = "notify";
|
||||||
|
String BIRDHOUSE_NOTIFY = "birdHouseNotification";
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "timeFormatMode",
|
keyName = "timeFormatMode",
|
||||||
@@ -65,17 +66,6 @@ public interface TimeTrackingConfig extends Config
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
|
||||||
keyName = "birdHouseNotification",
|
|
||||||
name = "Bird house notification",
|
|
||||||
description = "Notify you when all bird houses are full",
|
|
||||||
position = 3
|
|
||||||
)
|
|
||||||
default boolean birdHouseNotification()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "farmingContractInfoBox",
|
keyName = "farmingContractInfoBox",
|
||||||
name = "Show farming contract infobox",
|
name = "Show farming contract infobox",
|
||||||
|
|||||||
@@ -31,24 +31,29 @@ import java.time.Instant;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.runelite.api.ItemID;
|
import net.runelite.api.ItemID;
|
||||||
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.game.ItemManager;
|
import net.runelite.client.game.ItemManager;
|
||||||
import net.runelite.client.plugins.timetracking.TabContentPanel;
|
import net.runelite.client.plugins.timetracking.TabContentPanel;
|
||||||
import net.runelite.client.plugins.timetracking.TimeTrackingConfig;
|
import net.runelite.client.plugins.timetracking.TimeTrackingConfig;
|
||||||
import net.runelite.client.plugins.timetracking.TimeablePanel;
|
import net.runelite.client.plugins.timetracking.TimeablePanel;
|
||||||
import net.runelite.client.ui.ColorScheme;
|
import net.runelite.client.ui.ColorScheme;
|
||||||
import net.runelite.client.ui.DynamicGridLayout;
|
import net.runelite.client.ui.DynamicGridLayout;
|
||||||
|
import javax.swing.JToggleButton;
|
||||||
|
|
||||||
public class BirdHouseTabPanel extends TabContentPanel
|
public class BirdHouseTabPanel extends TabContentPanel
|
||||||
{
|
{
|
||||||
private static final Color COMPLETED_COLOR = ColorScheme.PROGRESS_COMPLETE_COLOR.darker();
|
private static final Color COMPLETED_COLOR = ColorScheme.PROGRESS_COMPLETE_COLOR.darker();
|
||||||
|
|
||||||
|
private final ConfigManager configManager;
|
||||||
private final ItemManager itemManager;
|
private final ItemManager itemManager;
|
||||||
private final BirdHouseTracker birdHouseTracker;
|
private final BirdHouseTracker birdHouseTracker;
|
||||||
private final TimeTrackingConfig config;
|
private final TimeTrackingConfig config;
|
||||||
private final List<TimeablePanel<BirdHouseSpace>> spacePanels;
|
private final List<TimeablePanel<BirdHouseSpace>> spacePanels;
|
||||||
|
|
||||||
BirdHouseTabPanel(ItemManager itemManager, BirdHouseTracker birdHouseTracker, TimeTrackingConfig config)
|
BirdHouseTabPanel(ConfigManager configManager, ItemManager itemManager, BirdHouseTracker birdHouseTracker,
|
||||||
|
TimeTrackingConfig config)
|
||||||
{
|
{
|
||||||
|
this.configManager = configManager;
|
||||||
this.itemManager = itemManager;
|
this.itemManager = itemManager;
|
||||||
this.birdHouseTracker = birdHouseTracker;
|
this.birdHouseTracker = birdHouseTracker;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
@@ -71,6 +76,17 @@ public class BirdHouseTabPanel extends TabContentPanel
|
|||||||
first = false;
|
first = false;
|
||||||
panel.setBorder(null);
|
panel.setBorder(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JToggleButton toggleNotify = panel.getNotifyButton();
|
||||||
|
|
||||||
|
toggleNotify.addActionListener(e ->
|
||||||
|
{
|
||||||
|
if (configManager.getRSProfileKey() != null)
|
||||||
|
{
|
||||||
|
configManager.setRSProfileConfiguration(TimeTrackingConfig.CONFIG_GROUP, TimeTrackingConfig.BIRDHOUSE_NOTIFY, toggleNotify.isSelected());
|
||||||
|
}
|
||||||
|
spacePanels.forEach(p -> p.getNotifyButton().setSelected(toggleNotify.isSelected()));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,6 +101,9 @@ public class BirdHouseTabPanel extends TabContentPanel
|
|||||||
{
|
{
|
||||||
long unixNow = Instant.now().getEpochSecond();
|
long unixNow = Instant.now().getEpochSecond();
|
||||||
|
|
||||||
|
boolean notifications = Boolean.TRUE
|
||||||
|
.equals(configManager.getRSProfileConfiguration(TimeTrackingConfig.CONFIG_GROUP, TimeTrackingConfig.BIRDHOUSE_NOTIFY, boolean.class));
|
||||||
|
|
||||||
for (TimeablePanel<BirdHouseSpace> panel : spacePanels)
|
for (TimeablePanel<BirdHouseSpace> panel : spacePanels)
|
||||||
{
|
{
|
||||||
BirdHouseSpace space = panel.getTimeable();
|
BirdHouseSpace space = panel.getTimeable();
|
||||||
@@ -113,6 +132,8 @@ public class BirdHouseTabPanel extends TabContentPanel
|
|||||||
panel.getProgress().setVisible(true);
|
panel.getProgress().setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
panel.getNotifyButton().setSelected(notifications);
|
||||||
|
|
||||||
panel.getProgress().setForeground(state.getColor().darker());
|
panel.getProgress().setForeground(state.getColor().darker());
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class BirdHouseTracker
|
|||||||
|
|
||||||
public BirdHouseTabPanel createBirdHouseTabPanel()
|
public BirdHouseTabPanel createBirdHouseTabPanel()
|
||||||
{
|
{
|
||||||
return new BirdHouseTabPanel(itemManager, this, config);
|
return new BirdHouseTabPanel(configManager, itemManager, this, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadFromConfig()
|
public void loadFromConfig()
|
||||||
@@ -180,7 +180,7 @@ public class BirdHouseTracker
|
|||||||
summary = SummaryState.COMPLETED;
|
summary = SummaryState.COMPLETED;
|
||||||
completionTime = 0;
|
completionTime = 0;
|
||||||
|
|
||||||
if (config.birdHouseNotification())
|
if (Boolean.TRUE.equals(configManager.getRSProfileConfiguration(TimeTrackingConfig.CONFIG_GROUP, TimeTrackingConfig.BIRDHOUSE_NOTIFY, boolean.class)))
|
||||||
{
|
{
|
||||||
notifier.notify("Your bird houses are ready to be dismantled.");
|
notifier.notify("Your bird houses are ready to be dismantled.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user