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

35
LINES

< > BotCompany Repo | #1016704 // dm_placeModuleUnderAIBar (old, use v2 instead)

JavaX fragment (include)

static int dm_placeModuleUnderAIBar_expiry = 4000;

// return true if we are first
sbool dm_placeModuleUnderAIBar(O moduleOrID, fS query) {
  fO module = dm_getModule(moduleOrID);
  fS moduleID = dm_moduleID(moduleOrID);
  dm_showModule_noFocus(module);
  ret swing(func -> bool {
    JTextComponent aiBar = cast getCreatorOpt('tfTopInput);
    Rect mr = dm_getBounds(module);
    if (aiBar == null || mr == null) false;
    
    Rectangle r = getBounds(aiBar);
    
    // height / query / timestamp
    T3<Int, S, Long> p = optCast(T3, quickImport(dm_generalMap_get('modulesUnderAIBar_y)));
    bool first = !(p != null && eq(p.b, query)
      && sysNow() <= p.c+dm_placeModuleUnderAIBar_expiry
      /*&& p.a != mr.y2()*/);
    int y = first ? 0 : p.a;
    
    // place on top if there is space (doesn't work like this)
    //if (y >= mr.h) y = 0;
      
    if (first) dm_generalMap_put('modulesUnderAIBar_firstModule, moduleID);
    //print("dm_place: " + p + " / " + y);
    dm_setBounds(module, r.x, y, r.width, mr.h);
    int yOut = y+mr.h;
    if (!first && p != null) yOut = max(yOut, p.a);
    dm_generalMap_put('modulesUnderAIBar_y, t3(yOut, query, y == 0 ? sysNow() : p.c));
    if (first)
      vmBus_send('placedModuleUnderAIBar, module);
    ret first;
  });
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1016704
Snippet name: dm_placeModuleUnderAIBar (old, use v2 instead)
Eternal ID of this version: #1016704/31
Text MD5: 8fc3591f876a3f5a77c597beca7c2669
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-18 00:41:58
Source code size: 1311 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 436 / 506
Version history: 30 change(s)
Referenced in: [show references]