Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

40
LINES

< > BotCompany Repo | #1019132 // Voice Matrix [enable/disable voice output from modules, OK]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (15449L/108K).

!7

module VoiceMatrix extends DynObjectTable<Map> {
  new TreeMap<S> map; // module lib ID => "+" or "-"
  bool defaultOn = true; // for new modules
  
  start {
    ownResource(vmBus_onMessages(rstUpdate(), 'moduleDeleted, 'moduleLoaded));
  }
  
  void update {
    for (O m : dm_listModules())
      syncPutIfNotThere(map, dm_moduleLibID(m), "?");
      
    setData(syncMap(map, func(S moduleID, S value) {
      litorderedmap(
        "Module ID" := moduleID,
        "Speech Output Enabled" :=
          eq(value, "+") ? "Yes" :
          eq(value, "-") ? "No" :
          "Default (" + (defaultOn ? "Yes" : "No") + ")")
    }));
  }
  
  visualize {
    ret withUpdate(withCenteredLine(super.visualize(),
      tableDependButton(table, "Enable", r { setValue((S) firstValue(selected()), "+") }),
      tableDependButton(table, "Disable", r { setValue((S) firstValue(selected()), "-") })));
  }
  
  void setValue(S moduleID, S value) {
    if (syncPut_trueIfChanged(map, moduleID, value))
      persistMe();
  }
  
  bool isModuleEnabled(O m) {
    S value = syncGet(map, dm_moduleLibID(m));
    ret eq(value, "+" ) ? true : eq(value, "-") ? false : defaultOn;
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1019132
Snippet name: Voice Matrix [enable/disable voice output from modules, OK]
Eternal ID of this version: #1019132/19
Text MD5: e365adccd3325d974820d0b6163a47a0
Transpilation MD5: 089bbc691881d7bef839e950f73667a2
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-25 13:08:39
Source code size: 1213 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 346 / 1793
Version history: 18 change(s)
Referenced in: [show references]