/************************************************** Module Bot0 Editor part Version: 3.1 Author: Sylvain Huet & Sebastien DENEUX Last update: 21/05/2001 Bot Module add "nameBot" by iri, 10/2004 **************************************************/ typeof BotEditor = Editor;; typeof eventsList = ObjText;; typeof ll = ObjList;; typeof addll = ObjButton;; typeof delll = ObjButton;; typeof links = [S r1];; typeof editWin = ObjWin;; typeof nameBot = ObjText;; /******************************************************************************* *******************************************************************************/ fun Updatel2(s,b)= _ADDlist ll 1000 s ;; /******************************************************************************* *******************************************************************************/ fun Updatel()= _RSTlist ll; apply_on_list links @Updatel2 0 ;; /******************************************************************************* *******************************************************************************/ fun cbAdr(s)= if s==nil then nil else ( set links=listcat links s::nil; Updatel ) ;; /******************************************************************************* *******************************************************************************/ fun cbAdd(a,b)= iniEnterBox _channel editWin nil nil (_locEditor "NEW_EVENT" nil) @cbAdr (_locEditor "ENTER_NEW" nil) ;; /******************************************************************************* *******************************************************************************/ fun cbRemove(x,b)= let _GETlist ll ->[i _] in let nth_list links i -> a in if a==nil then nil else ( set links=remove_from_list links a; Updatel ) ;; /******************************************************************************* *******************************************************************************/ fun Fdlink(a,b)= if strcmp hd a "botevent" then 0 else ( set links=listcat links (hd tl a)::nil; 0 ) ;; /******************************************************************************* load the parameters for a module instance p -> [[S r1] r1] : the dmi contents editor -> Editor : editor <- I : nothing special *******************************************************************************/ fun cbLoad (p) = set links=nil; apply_on_list p @Fdlink 0; Updatel; _SETtext nameBot getInfo p "nameBot"; 0 ;; /******************************************************************************* *******************************************************************************/ fun Suppevent(l)= if l==nil then nil else let l->[a n] in ("botevent"::a::nil)::("event"::a::nil)::Suppevent n ;; /******************************************************************************* save modifications a -> S : not used b -> S : not used editor -> Editor : editor <- [[S r1] r1] : the dmi contents *******************************************************************************/ fun cbSave (a,b)= ("action"::"register"::nil):: ("action"::"unregister"::nil):: ("action"::"!hear"::nil):: ("event"::"broadMsg"::nil):: ("event"::"privateMsg"::nil):: ("nameBot"::(_GETtext nameBot)::nil):: Suppevent links ;; /******************************************************************************* *******************************************************************************/ fun rflSizeEditWin (wn, param, w, h)= _SIZEtext eventsList w-10 20 5 5; _SIZElist ll w-10 h-50 5 25; _SIZEbutton addll 45 20 5 h-25; _SIZEbutton delll 45 20 70 h-25 ;; /******************************************************************************* main function called when the editor is starting. The openDMI function must be called at the end in order to load the data if the module has already been edited. s -> S : obsolete (unused) <- I : nothing special *******************************************************************************/ fun IniEditor(s)= let [315 230] -> [w h] in ( set BotEditor = startEditor _channel nil nil nil w h WN_NORMAL EDITOR_NORMAL s nil nil nil @cbLoad @cbSave nil; let getEditWin BotEditor -> editorWin in ( _CBwinSize editorWin @rflSizeEditWin 0; set eventsList = _CRtext _channel editorWin 5 5 w-10 20 ET_ALIGN_CENTER (_locEditor "NEW_EVENTS" nil); set ll = _CRlist _channel editorWin 5 25 w-10 h-75 LB_DOWN+LB_VSCROLL; set addll = _CBbutton _CRbutton _channel editorWin 5 h-50 45 20 0 (_locEditor "ADD" nil) @cbAdd 0; set delll = _CBbutton _CRbutton _channel editorWin 70 h-50 45 20 0 (_locEditor "REMOVE" nil) @cbRemove 0; _CRtext _channel editorWin 5 h-25 50 20 0 (_locEditor "NAME" nil); set nameBot = _CReditLine _channel editorWin 55 h-25 w-60 20 ET_DOWN|ET_AHSCROLL ""; openDMI BotEditor ) ) ;;