Skip to content

Commit

Permalink
add smarthome addon to readme, disable all modules when opening the c…
Browse files Browse the repository at this point in the history
…onfig
  • Loading branch information
LabyStudio committed Feb 23, 2021
1 parent f6f605c commit dad381e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -6,6 +6,7 @@ The modules are displayed over all your programs and games and are freely movabl

## Available Addons
- [Spotify](https://github.com/LabyStudio/spotify-addon)
- [SmartHome](https://github.com/LabyStudio/smarthome-addon) (FritzBox client list and IP-Camera feed)

*Feel free to add your addons!*

Expand Down
Expand Up @@ -31,18 +31,20 @@ public class ModuleWidget extends JPanel {
public ModuleWidget(Module<? extends Addon> module) {
this.module = module;

Addon addon = module.getAddon();

// Create switch widget
SwitchWidget switchWidget = new SwitchWidget(module.isEnabled());
switchWidget.setActionListener(enabled -> {
// Update module visibility
this.module.getAddon().setModuleVisibility(this.module, enabled);
addon.setModuleVisibility(this.module, enabled);
});

// Create advanced gear widget
TextureLoader textureLoader = module.getAddon().getDesktopModules().getTextureLoader();
AdvancedWidget advancedWidget = new AdvancedWidget(textureLoader);
advancedWidget.setActionListener(unused -> {
File file = this.module.getAddon().getConfigFile();
File file = addon.getConfigFile();

// Open config file in editor
try {
Expand All @@ -51,9 +53,11 @@ public ModuleWidget(Module<? extends Addon> module) {
exception.printStackTrace();
}

// Turn off module to avoid conflicts while editing the config
if (this.module.isEnabled()) {
this.module.getAddon().setModuleVisibility(this.module, false);
// Turn off modules to avoid conflicts while editing the config
for (Module<? extends Addon> moduleEntry : addon.getModules()) {
if (moduleEntry.isEnabled()) {
addon.setModuleVisibility(moduleEntry, false);
}
}
});

Expand Down

0 comments on commit dad381e

Please sign in to comment.