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).

1  
!7
2  
3  
module VoiceMatrix extends DynObjectTable<Map> {
4  
  new TreeMap<S> map; // module lib ID => "+" or "-"
5  
  bool defaultOn = true; // for new modules
6  
  
7  
  start {
8  
    ownResource(vmBus_onMessages(rstUpdate(), 'moduleDeleted, 'moduleLoaded));
9  
  }
10  
  
11  
  void update {
12  
    for (O m : dm_listModules())
13  
      syncPutIfNotThere(map, dm_moduleLibID(m), "?");
14  
      
15  
    setData(syncMap(map, func(S moduleID, S value) {
16  
      litorderedmap(
17  
        "Module ID" := moduleID,
18  
        "Speech Output Enabled" :=
19  
          eq(value, "+") ? "Yes" :
20  
          eq(value, "-") ? "No" :
21  
          "Default (" + (defaultOn ? "Yes" : "No") + ")")
22  
    }));
23  
  }
24  
  
25  
  visualize {
26  
    ret withUpdate(withCenteredLine(super.visualize(),
27  
      tableDependButton(table, "Enable", r { setValue((S) firstValue(selected()), "+") }),
28  
      tableDependButton(table, "Disable", r { setValue((S) firstValue(selected()), "-") })));
29  
  }
30  
  
31  
  void setValue(S moduleID, S value) {
32  
    if (syncPut_trueIfChanged(map, moduleID, value))
33  
      persistMe();
34  
  }
35  
  
36  
  bool isModuleEnabled(O m) {
37  
    S value = syncGet(map, dm_moduleLibID(m));
38  
    ret eq(value, "+" ) ? true : eq(value, "-") ? false : defaultOn;
39  
  }
40  
}

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: 434 / 1903
Version history: 18 change(s)
Referenced in: [show references]