diff options
Diffstat (limited to 'plugins/Actman/i_options.inc')
-rw-r--r-- | plugins/Actman/i_options.inc | 716 |
1 files changed, 366 insertions, 350 deletions
diff --git a/plugins/Actman/i_options.inc b/plugins/Actman/i_options.inc index 26dd8e1f08..fbbf6c558c 100644 --- a/plugins/Actman/i_options.inc +++ b/plugins/Actman/i_options.inc @@ -1,459 +1,475 @@ {Save/load options}
const
- opt_group = 'Group';
- opt_actions = 'Action';
- opt_numacts = 'numactions';
- opt_numhk = 'numgroups';
- opt_firstAction = 'firstaction';
-
- opt_cproto = 'cproto';
- opt_cuid = 'cuid';
- opt_ischat = 'ischat';
+ opt_group = 'Group';
+ opt_actions = 'Action';
+ opt_numacts = 'numactions';
+ opt_nummacro = 'numgroups';
opt_descr = 'descr';
opt_id = 'id';
+ opt_uid = 'uid';
opt_flags = 'flags';
- opt_flags2 = 'flags2';
- opt_time = 'time';
- opt_show = 'show';
- opt_action = 'action';
- opt_value = 'value';
- opt_file = 'file';
-
- opt_next = 'next';
- opt_type = 'type';
- opt_contact = 'contact';
- opt_text = 'text';
- opt_prg = 'program';
- opt_args = 'arguments';
- opt_service = 'service';
- opt_wparam = 'wparam';
- opt_wlparam = 'wparamlen';
- opt_llparam = 'lparamlen';
- opt_lparam = 'lparam';
- opt_chain = 'chain';
- opt_cond = 'condition';
- opt_count = 'count';
- opt_module = 'module';
- opt_setting = 'setting';
- opt_oper = 'operation';
- opt_mathval = 'mathval';
- opt_operval = 'operval';
- opt_varval = 'varval';
- opt_msgtitle = 'msgtitle';
- opt_msgtext = 'msgtext';
- opt_boxopts = 'boxopts';
-
//----- Save settings -----
-procedure SaveNumValue(setting:pAnsiChar;value:uint_ptr;isvar:boolean);
-begin
- if isvar then
- DBWriteUnicode(0,DBBranch,setting,pWideChar(value))
- else
- DBWriteDWord (0,DBBranch,setting,value);
-end;
-
-function SaveActions(section:pAnsiChar;first:integer):integer;
+procedure SaveActions(Macro:pMacroRecord;section:pAnsiChar);
var
p,p1:PAnsiChar;
- act:pHKAction;
i:integer;
begin
- result:=0;
+ p:=StrEnd(section);
+ StrCopy(p,opt_numacts); DBWriteWord(0,DBBranch,section,Macro^.ActionCount);
+
// in: section = "Group#/"
- p1:=StrCopyE(StrEnd(section),opt_actions); // "Group#/Action"
+ p1:=StrCopyE(p,opt_actions); // "Group#/Action"
DBDeleteGroup(0,DBBranch,section);
- i:=1;
- while first<>0 do
+
+ for i:=0 to Macro^.ActionCount-1 do
begin
- act:=@ActionList[first];
- p:=StrEnd(IntToStr(p1,i)); //!!!
+ p:=StrEnd(IntToStr(p1,i));
p^:='/'; inc(p); // "Group#/Action#/"
- StrCopy(p,opt_flags ); DBWriteDWord(0,DBBranch,section,act^.flags);
- StrCopy(p,opt_flags2); DBWriteDWord(0,DBBranch,section,act^.flags2);
- StrCopy(p,opt_type ); DBWriteByte (0,DBBranch,section,act^.actionType);
- if act^.descr<>nil then
- begin
- StrCopy(p,opt_descr); DBWriteUnicode(0,DBBranch,section,act^.descr);
- end;
-
- case act^.actionType of
- ACT_CONTACT: begin
- p^:=#0;
- SaveContact(act^.contact,DBBranch,section);
- end;
-
- ACT_SERVICE: begin
- StrCopy(p,opt_service); DBWriteString(0,DBBranch,section,act^.service);
-
- if (act^.flags and (ACF_WCURRENT or ACF_WRESULT or ACF_WPARAM))=0 then
- begin
- StrCopy(p,opt_wparam);
- if (act^.flags and ACF_WPARNUM)<>0 then
- SaveNumValue(section,act^.wparam,(act^.flags2 and ACF2_SRV_WPAR)<>0)
-// DBWriteDWord(0,DBBranch,section,act^.wparam)
- else if act^.wparam<>0 then
- begin
- if (act^.flags and ACF_WSTRUCT)<>0 then
- DBWriteUTF8(0,DBBranch,section,pAnsiChar(act^.wparam))
- else if (act^.flags and ACF_WUNICODE)<>0 then
- DBWriteUnicode(0,DBBranch,section,pWideChar(act^.wparam))
- else
- DBWriteString(0,DBBranch,section,PAnsiChar(act^.wparam));
- end;
- end;
-
- if (act^.flags and (ACF_LCURRENT or ACF_LRESULT or ACF_LPARAM))=0 then
- begin
- StrCopy(p,opt_lparam);
- if (act^.flags and ACF_LPARNUM)<>0 then
- SaveNumValue(section,act^.lparam,(act^.flags2 and ACF2_SRV_LPAR)<>0)
-// DBWriteDWord(0,DBBranch,section,act^.lparam)
- else if act^.lparam<>0 then
- begin
- if (act^.flags and ACF_LSTRUCT)<>0 then
- DBWriteUTF8(0,DBBranch,section,pAnsiChar(act^.lparam))
- else if (act^.flags and ACF_LUNICODE)<>0 then
- DBWriteUnicode(0,DBBranch,section,pWideChar(act^.lparam))
- else
- DBWriteString(0,DBBranch,section,PAnsiChar(act^.lparam));
- end;
- end;
-
- end;
-
- ACT_PROGRAM: begin
- StrCopy(p,opt_prg ); DBWriteUnicode(0,DBBranch,section,act^.prgname);
- StrCopy(p,opt_args); DBWriteUnicode(0,DBBranch,section,act^.args);
- StrCopy(p,opt_time); DBWriteDWord (0,DBBranch,section,act^.time);
- StrCopy(p,opt_show); DBWriteDWord (0,DBBranch,section,act^.show);
- end;
-
- ACT_TEXT: begin
- if (act^.flags and ACF_CLIPBRD)=0 then
- begin
- StrCopy(p,opt_text); DBWriteUnicode(0,DBBranch,section,act^.text);
- if (act^.flags and ACF_FILE)<>0 then
- begin
- StrCopy(p,opt_file); DBWriteUnicode(0,DBBranch,section,act^.tfile);
- end;
- end;
- end;
-
- ACT_ADVANCE: begin
- StrCopy(p,opt_cond ); DBWriteByte (0,DBBranch,section,act^.condition);
- StrCopy(p,opt_value ); DBWriteDWord (0,DBBranch,section,act^.value);
- StrCopy(p,opt_action ); DBWriteByte (0,DBBranch,section,act^.action);
- StrCopy(p,opt_operval); DBWriteUnicode(0,DBBranch,section,act^.operval);
- StrCopy(p,opt_oper ); DBWriteByte (0,DBBranch,section,act^.oper);
- StrCopy(p,opt_mathval); DBWriteDWord (0,DBBranch,section,act^.mathval);
- StrCopy(p,opt_varval ); DBWriteUnicode(0,DBBranch,section,act^.varval);
- end;
-
- ACT_CHAIN: begin
- StrCopy(p,opt_text); DBWriteDWord(0,DBBranch,section,act^.id);
- end;
-
- ACT_RW: begin
- if (act^.flags and ACF_NOCNTCT)=0 then
- begin
- p^:=#0;
- SaveContact(act^.dbcontact,DBBranch,section);
- end;
- StrCopy(p,opt_module ); DBWriteString(0,DBBranch,section,act^.dbmodule);
- StrCopy(p,opt_setting); DBWriteString(0,DBBranch,section,act^.dbsetting);
- StrCopy(p,opt_value );
- if (act^.flags and ACF_DBUTEXT)=0 then
- begin
- SaveNumValue(section,act^.dbvalue,(act^.flags2 and ACF2_RW_TVAR)<>0);
-// DBWriteDWord(0,DBBranch,section,act^.dbvalue)
- end
- else
- DBWriteUnicode(0,DBBranch,section,pWideChar(act^.dbvalue));
- end;
-
- ACT_MESSAGE: begin
- StrCopy(p,opt_msgtitle); DBWriteUnicode(0,DBBranch,section,act^.msgtitle);
- StrCopy(p,opt_msgtext ); DBWriteUnicode(0,DBBranch,section,act^.msgtext);
- StrCopy(p,opt_boxopts ); DBWriteByte (0,DBBranch,section,act^.boxopts); //!!
- end;
-
- end;
- inc(result);
- inc(i);
- first:=ActionList^[first].next;
+//?? StrCopy(p,opt_uid); DBWriteDWord(0,DBBranch,section,Macro^.ActionList[i].uid);
+ p^:=#0;
+ Macro^.ActionList[i].Save(section,0);
end;
+
end;
-procedure SaveGroups;
+procedure SaveMacros;
var
- HK:pHKRecord;
- NumHK:integer;
- i,num:integer;
+ Macro:pMacroRecord;
+ OldNumMacros,NumMacros:integer;
+ i:integer;
section:array [0..127] of AnsiChar;
p,p1:PAnsiChar;
- Actions:integer;
begin
// even if crap in settings, skip on read
-// DBDeleteGroup(0,DBBranch,opt_group);
- HK:=@GroupList^;
- i:=MaxGroups;
- NumHK:=0;
- Actions:=1;
- DBWriteUnicode(0,DBBranch,'CLformat',fCLformat);
- DBWriteByte (0,DBBranch,'CLfilter',ord(fCLfilter));
+ DBWriteByte(0,DBBranch,'version' ,3);
+
+ OldNumMacros:=DBReadWord(0,DBBranch,opt_nummacro,0);
+
+ Macro:=MacroList[0];
+ i:=MacroList.Count;
+ NumMacros:=0;
p1:=StrCopyE(section,opt_group);
while i>0 do
begin
- with HK^ do
+ with Macro^ do
begin
if (flags and (ACF_ASSIGNED or ACF_VOLATILE))=ACF_ASSIGNED then
begin
- p:=StrEnd(IntToStr(p1,NumHK));
+ p:=StrEnd(IntToStr(p1,NumMacros));
p^:='/'; inc(p);
StrCopy(p,opt_id ); DBWriteDWord(0,DBBranch,section,id);
StrCopy(p,opt_flags); DBWriteDWord(0,DBBranch,section,flags);
- StrCopy(p,opt_descr);
- if descr<>nil then
- DBWriteUnicode (0,DBBranch,section,descr)
- else
- DBDeleteSetting(0,DBBranch,section);
+ StrCopy(p,opt_descr); DBWriteUnicode (0,DBBranch,section,descr);
p^:=#0;
- //??
- num:=SaveActions(section,firstAction);
- StrCopy(p,opt_numacts); DBWriteWord(0,DBBranch,section,num);
- inc(Actions,num);
- inc(NumHK);
+ SaveActions(Macro,section);
+
+ inc(NumMacros);
end;
end;
- inc(HK);
+ inc(Macro);
dec(i);
end;
- DBWriteWord(0,DBBranch,opt_numhk ,NumHK);
- DBWriteWord(0,DBBranch,opt_numacts,Actions-1);
+ DBWriteWord(0,DBBranch,opt_nummacro,NumMacros);
+
+ // deleting old unused macro settings
+ while OldNumMacros>NumMacros do
+ begin
+ dec(OldNumMacros);
+ IntToStr(p1,OldNumMacros);
+ DBDeleteGroup(0,DBBranch,section);
+ end;
end;
-//----- Load settings -----
+//===== Load settings =====
+
+//----- V2 settings processing -----
+
+const
+ ACT_CONTACT = 1;
+ ACT_SERVICE = 2;
+ ACT_PROGRAM = 3;
+ ACT_TEXT = 4;
+ ACT_ADVANCE = 5;
+ ACT_CHAIN = 6;
+ ACT_RW = 7;
+ ACT_MESSAGE = 8;
+
+// action flags
+const
+ ACF_MASK = $00FFFFFF;
-function LoadNumValue(setting:pAnsiChar;isvar:boolean):uint_ptr;
+ ACF_OLD_CLIPBRD = $00000002; // Clipboard operations, not window
+ ACF_OLD_FILE = $00000010; // File operations
+ ACF_OLD_FWRITE = $00000020; // read/write file
+ ACF_OLD_FAPPEND = $00000040; // append file
+
+const
+ OldVersion = 'Your Actman settings are for old version. If you are ready to upgrade settings, ' +
+ 'press OK. Else press Cancel and change manually Actman plugin back to old version ' +
+ 'or make settings backup. To keep previously exported macros please import them back ' +
+ 'before conversion.';
+ Notes = 'Please, don''t use macro test for non-saved macros. If you had ''Advanced'' or file ' +
+ 'writing actions previously, check them - their logic was changed.';
+ ConvResult = 'Actman settings converted to new version';
+
+procedure CheckActionList(Macro:pMacroRecord;num:integer);
+var
+ tmplist:pActionList;
begin
- if isvar then
- result:=uint_ptr(DBReadUnicode(0,DBBranch,setting,nil))
- else
- result:=DBReadDWord(0,DBBranch,setting);
+ if num=Macro^.ActionCount then
+ begin
+ GetMem(tmplist,SizeOf(tBaseAction)*(num+1));
+ move(Macro^.ActionList^,tmplist^,Macro^.ActionCount*SizeOf(tBaseAction));
+ FreeMem(Macro^.ActionList);
+ Macro^.ActionList:=tmplist;
+ Inc(Macro^.ActionCount);
+ end;
end;
-function LoadActions(section:pAnsiChar;count:integer):integer;
+function LoadActionsV2(Macro:pMacroRecord;section:pAnsiChar):boolean; stdcall;
var
- p,p1:PAnsiChar;
- act:tHKAction;
- i,num,oldnum:integer;
+ buf:array [0..31] of WideChar;
+ p,p1,pc:PAnsiChar;
+ action:tBaseAction;
+ actm:pActModule;
+ flags2,actionType:dword;
+ code,i,num,count:integer;
+ cond,act:byte;
begin
- result:=0;
- p1:=StrCopyE(StrEnd(section),opt_actions); // "Group#/Action"
+ result:=false;
+ p:=StrEnd(section);
+ StrCopy(p,opt_numacts); Macro^.ActionCount:=DBReadWord(0,DBBranch,section);
- oldnum:=0;
- for i:=1 to count do
+ if Macro^.ActionCount>0 then
begin
- p:=StrEnd(IntToStr(p1,i));
- p^:='/'; inc(p); // "Group#/Action#/"
- FillChar(act,SizeOf(act),0);
+ GetMem(Macro^.ActionList,SizeOf(tBaseAction)*Macro^.ActionCount);
+ p1:=StrCopyE(p,opt_actions); // "Group#/Action"
- StrCopy(p,opt_flags ); act.flags :=DBReadDWord (0,DBBranch,section,0);
- if (act.flags and ACF_ASSIGNED)<>0 then
+ num:=0;
+ count:=Macro^.ActionCount;
+ for i:=1 to count do
begin
- StrCopy(p,opt_flags2); act.flags2 :=DBReadDWord (0,DBBranch,section,0);
- StrCopy(p,opt_descr ); act.descr :=DBReadUnicode(0,DBBranch,section,nil);
- StrCopy(p,opt_type ); act.actionType:=DBReadByte (0,DBBranch,section,ACT_CONTACT);
+ p:=StrEnd(IntToStr(p1,i));
+ p^:='/'; inc(p); // "Group#/Action#/"
+
+ StrCopy(p,'type' ); actionType:=DBReadByte (0,DBBranch,section,ACT_CONTACT);
+ case actionType of
+ ACT_CONTACT: pc:='Contact';
+ ACT_SERVICE: pc:='Service';
+ ACT_PROGRAM: pc:='Program';
+ ACT_TEXT: pc:=nil;
+ ACT_ADVANCE: pc:=nil;
+ ACT_CHAIN: pc:='Chain';
+ ACT_RW: pc:='Database';
+ ACT_MESSAGE: pc:='MessageBox';
+ else
+ pc:=nil;
+ end;
+ if pc<>nil then
+ begin
+ actm :=GetLinkByName(pc);
+ action:=actm.Create;
+ end
+ else
+ begin
+ action:=nil;
+ end;
- case act.actionType of
+ p^:=#0;
+ case actionType of
ACT_CONTACT: begin
- p^:=#0;
- act.contact:=LoadContact(DBBranch,section);
+ action.Load(section,0);
end;
ACT_SERVICE: begin
- StrCopy(p,opt_service);
- act.service:=DBReadString(0,DBBranch,section,nil);
-
- if (act.flags and (ACF_WCURRENT or ACF_WRESULT or ACF_WPARAM))=0 then
- begin
- StrCopy(p,opt_wparam);
- if (act.flags and ACF_WPARNUM)<>0 then
- act.wparam:=LoadNumValue(section,(act.flags2 and ACF2_SRV_WPAR)<>0)
- else if (act.flags and ACF_WSTRUCT)<>0 then
- act.wparam:=wparam(DBReadUTF8(0,DBBranch,section,nil))
- else if (act.flags and ACF_WUNICODE)<>0 then
- act.wparam:=wparam(DBReadUnicode(0,DBBranch,section,nil))
- else
- act.wparam:=wparam(DBReadString (0,DBBranch,section,nil));
- end;
-
- if (act.flags and (ACF_LCURRENT or ACF_LRESULT or ACF_LPARAM))=0 then
- begin
- StrCopy(p,opt_lparam);
- if (act.flags and ACF_LPARNUM)<>0 then
- act.lparam:=LoadNumValue(section,(act.flags2 and ACF2_SRV_LPAR)<>0)
- // act.lparam:=DBReadDWord(0,DBBranch,section,0)
- else if (act.flags and ACF_LSTRUCT)<>0 then
- act.lparam:=lparam(DBReadUTF8(0,DBBranch,section,nil))
- else if (act.flags and ACF_LUNICODE)<>0 then
- act.lparam:=lparam(DBReadUnicode(0,DBBranch,section,nil))
- else
- act.lparam:=lparam(DBReadString(0,DBBranch,section,nil));
- end;
-
+ action.Load(section,100);
end;
ACT_PROGRAM: begin
- StrCopy(p,opt_prg ); act.prgname:=DBReadUnicode(0,DBBranch,section,nil);
- StrCopy(p,opt_args); act.args :=DBReadUnicode(0,DBBranch,section,nil);
- StrCopy(p,opt_time); act.time :=DBReadDWord (0,DBBranch,section,0);
- StrCopy(p,opt_show); act.show :=DBReadDWord (0,DBBranch,section,SW_SHOW);
+ action.Load(section,100);
end;
ACT_TEXT: begin
- if (act.flags and ACF_CLIPBRD)=0 then
+ StrCopy(p,opt_flags); flags2:=DBReadDWord(0,DBBranch,section,0);
+ p^:=#0;
+ if ((flags2 and ACF_OLD_CLIPBRD)=0) then
begin
- StrCopy(p,opt_text); act.text:=DBReadUnicode(0,DBBranch,section,nil);
- if (act.flags and ACF_FILE)<>0 then
+ if ((flags2 and ACF_OLD_FILE)=0) or ((flags2 and (ACF_OLD_FWRITE or ACF_OLD_FAPPEND)<>0)) then
begin
- StrCopy(p,opt_file); act.tfile:=DBReadUnicode(0,DBBranch,section,nil);
+ actm :=GetLinkByName('Text');
+ action:=actm.Create;
+
+ action.Load(section,100);
+
+ CheckActionList(Macro,num);
+ Macro^.ActionList^[num]:=action;
+ inc(num);
end;
end;
+
+ actm :=GetLinkByName('In/Out');
+ action:=actm.Create;
+
+ action.Load(section,100);
end;
ACT_ADVANCE: begin
- StrCopy(p,opt_cond ); act.condition:=DBReadByte (0,DBBranch,section);
- StrCopy(p,opt_value ); act.value :=DBReadDWord (0,DBBranch,section);
- StrCopy(p,opt_action ); act.action :=DBReadByte (0,DBBranch,section);
- StrCopy(p,opt_oper ); act.oper :=DBReadByte (0,DBBranch,section);
- StrCopy(p,opt_mathval); act.mathval :=DBReadDWord (0,DBBranch,section);
- StrCopy(p,opt_operval); act.operval :=DBReadUnicode(0,DBBranch,section);
- StrCopy(p,opt_varval ); act.varval :=DBReadUnicode(0,DBBranch,section);
+ StrCopy(p,'condition' ); cond:=DBReadByte(0,DBBranch,section);
+ StrCopy(p,'action'); act :=DBReadByte(0,DBBranch,section);
+ p^:=#0;
+ // get code of my list
+ code:=0;
+ if (cond and $0F)=0 then
+ begin
+ if act<>0 then code:=4; // action and jump
+ if (act and $F0)=0 then code:=6; // no action
+ if (act and $0F)=0 then code:=5; // no jump
+ end
+ else // with condition
+ begin
+ if act<>0 then code:=1; // action and jump
+ if (act and $F0)=0 then code:=2; // no action
+ if (act and $0F)=0 then code:=3; // no jump
+ end;
+ case code of
+ 1: begin // conditional action and jump
+ actm :=GetLinkByName('Jump'); // reversed condition jump to tmplabel
+ action:=actm.Create;
+ action.Load(section,102+i);
+ CheckActionList(Macro,num);
+ Macro^.ActionList^[num]:=action;
+ inc(num);
+
+ actm :=GetLinkByName('Text'); // action
+ action:=actm.Create;
+ action.Load(section,101);
+ CheckActionList(Macro,num);
+ Macro^.ActionList^[num]:=action;
+ inc(num);
+
+ actm :=GetLinkByName('Jump'); // jump to label (no condition)
+ action:=actm.Create;
+ action.Load(section,101);
+ CheckActionList(Macro,num);
+ Macro^.ActionList^[num]:=action;
+ inc(num);
+
+ actm :=GetLinkByName('Notes'); // tmplabel
+ action:=actm.Create;
+ mFreeMem(action.ActionDescr); // created by constructor
+ buf[0]:='$'; buf[1]:='$';
+ IntToStr(PWideChar(@buf[2]),i);
+ StrDupW(action.ActionDescr,buf);
+ end;
+ 2,6: begin // conditional and unconditional jump
+ actm :=GetLinkByName('Jump');
+ action:=actm.Create;
+
+ action.Load(section,100);
+ end;
+ 3: begin // conditional action
+ actm :=GetLinkByName('Jump');
+ action:=actm.Create;
+ action.Load(section,101+num);
+ CheckActionList(Macro,num);
+ Macro^.ActionList^[num]:=action;
+ inc(num);
+
+ actm :=GetLinkByName('Text');
+ action:=actm.Create;
+ action.Load(section,101);
+ CheckActionList(Macro,num);
+ Macro^.ActionList^[num]:=action;
+ inc(num);
+
+ actm :=GetLinkByName('Notes');
+ action:=actm.Create;
+ mFreeMem(action.ActionDescr); // created by constructor
+ buf[0]:='$'; buf[1]:='$';
+ StrDupW(action.ActionDescr,IntToStr(PWideChar(@buf[2]),num));
+ end;
+ 4: begin // action + unconditional jump
+ actm :=GetLinkByName('Text');
+ action:=actm.Create;
+ action.Load(section,101);
+ CheckActionList(Macro,num);
+ Macro^.ActionList^[num]:=action;
+ inc(num);
+
+ actm :=GetLinkByName('Jump');
+ action:=actm.Create;
+
+ action.Load(section,100);
+ end;
+ 5: begin // direct text action
+ actm :=GetLinkByName('Text');
+ action:=actm.Create;
+
+ action.Load(section,101);
+ end;
+ end;
end;
ACT_CHAIN: begin
- StrCopy(p,opt_text); act.id:=DBReadDWord(0,DBBranch,section);
+ action.Load(section,100);
end;
ACT_RW: begin
- if (act.flags and ACF_NOCNTCT)=0 then
- begin
- p^:=#0;
- act.dbcontact:=LoadContact(DBBranch,section);
- end;
- StrCopy(p,opt_module ); act.dbmodule :=DBReadString(0,DBBranch,section);
- StrCopy(p,opt_setting); act.dbsetting:=DBReadString(0,DBBranch,section);
- StrCopy(p,opt_value );
-
- if (act.flags and ACF_DBUTEXT)=0 then
- act.dbvalue:=LoadNumValue(section,(act.flags2 and ACF2_RW_TVAR)<>0)
- else
- act.dbvalue:=uint_ptr(DBReadUnicode(0,DBBranch,section));
+ action.Load(section,100);
end;
ACT_MESSAGE: begin
- StrCopy(p,opt_msgtitle); act.msgtitle:=DBReadUnicode(0,DBBranch,section);
- StrCopy(p,opt_msgtext ); act.msgtext :=DBReadUnicode(0,DBBranch,section);
- StrCopy(p,opt_boxopts ); act.boxopts :=DBReadByte (0,DBBranch,section);
+ action.Load(section,0);
+
+ StrCopy(p,'flags2'); flags2:=DBReadDWord(0,DBBranch,section,0);
+ action.flags:=(action.flags and not ACF_MASK) or flags2;
end;
end;
- num:=NewAction(ActionList,MaxActions);
- move(act,ActionList^[num],SizeOf(tHKAction));
- if i=1 then
- result:=num
- else
- ActionList^[oldnum].next:=num;
- oldnum:=num;
+
+ if action<>nil then
+ begin
+ CheckActionList(Macro,num);
+ Macro^.ActionList^[num]:=action;
+ inc(num);
+ end;
end;
end;
end;
-procedure LoadGroups;
+//----- V3 settings processing -----
+
+function LoadActions(Macro:pMacroRecord;section:pAnsiChar):integer; stdcall;
var
- HK:pHKRecord;
- i,num:cardinal;
p,p1:PAnsiChar;
- section:array [0..127] of AnsiChar;
- NumGroups,NumActions:cardinal;
+ actm:pActModule;
+ action:tBaseAction;
+ tmp:pActionList;
+ uid:dword;
+ i,num:integer;
begin
-{ remove doubling - no need? (called just once)
- if MaxGroups>0 then
+ result:=0;
+ p:=StrEnd(section);
+ StrCopy(p,opt_numacts); Macro^.ActionCount:=DBReadWord(0,DBBranch,section);
+ if Macro^.ActionCount>0 then
begin
- while MaxGroups>0 do
+ GetMem(Macro^.ActionList,SizeOf(tBaseAction)*Macro^.ActionCount);
+ p1:=StrCopyE(p,opt_actions); // "Group#/Action"
+
+ num:=0;
+ for i:=0 to Macro^.ActionCount-1 do
begin
- FreeGroup(MaxGroups);
- dec(MaxGroups);
+ p:=StrEnd(IntToStr(p1,i));
+ p^:='/'; inc(p); // "Group#/Action#/"
+
+ // get uid
+ StrCopy(p,opt_uid); uid:=DBReadDWord(0,DBBranch,section,0);
+ if uid<>0 then
+ begin
+ p^:=#0;
+ // call proper constructor
+ actm:=GetLink(uid);
+ if actm=nil then
+ continue;
+
+ action:=actm.Create;
+ // call proper loader
+ action.Load(section,0);
+
+ Macro^.ActionList^[num]:=action;
+ inc(num);
+ end;
end;
- FreeMem(GroupList);
- end;
-}
- NumGroups:=DBReadWord(0,DBBranch,opt_numhk,HKListPage);
- if NumGroups<HKListPage then
- MaxGroups:=HKListPage
- else
- MaxGroups:=NumGroups;
- GetMem (GroupList ,MaxGroups*SizeOf(tHKRecord));
- FillChar(GroupList^,MaxGroups*SizeOf(tHKRecord),0);
-
-{ remove doubling - no need? (called just once)
- if MaxActions<>0 then
- begin
- act:=@ActionList[1];
- while MaxActions>0 do
+ if Macro^.ActionCount<>num then
begin
- FreeAction(act);
- inc(act);
- dec(MaxActions);
+ GetMem(tmp,SizeOf(tBaseAction)*num);
+ move(Macro^.ActionList^,tmp^,SizeOf(tBaseAction)*num);
+ Macro^.ActionCount:=num;
+ FreeMem(Macro^.ActionList);
+ Macro^.ActionList:=tmp;
end;
- FreeMem(ActionList);
end;
-}
- NumActions:=DBReadWord(0,DBBranch,opt_numacts,ActListPage);
- if NumActions<ActListPage then
- MaxActions:=ActListPage
- else
- MaxActions:=NumActions+1;
- GetMem (ActionList ,MaxActions*SizeOf(tHKAction));
- FillChar(ActionList^,MaxActions*SizeOf(tHKAction),0);
-
- HK:=@GroupList^; //??
- i:=0;
- p1:=StrCopyE(section,opt_group);
- while i<NumGroups do
+end;
+
+procedure LoadMacros;
+var
+ Macro:pMacroRecord;
+ p,p1:PAnsiChar;
+ section:array [0..127] of AnsiChar;
+ tmp:pWideChar;
+ i:cardinal;
+ NumMacros:cardinal;
+ v2:bool;
+begin
+ NumMacros:=DBReadWord(0,DBBranch,opt_nummacro,0);
+ v2:=false;
+
+ // Check if old actman version used
+ if NumMacros>0 then
begin
- p:=StrEnd(IntToStr(p1,i));
- p^:='/'; inc(p);
+ // V2 counts actions from 1, not 0
+ v2:=DBReadDWord(0,DBBranch,'Group0/Action0/flags',$FFFFFFFF)=$FFFFFFFF;
- StrCopy(p,opt_flags);
- with HK^ do
+ if v2 then
begin
- flags:=DBReadDWord(0,DBBranch,section,0{integer(ACF_ASSIGNED or ACF_DISABLED)});
- if (flags and ACF_ASSIGNED)<>0 then // not needed in normal cases
+ if MessageBoxW(0,TranslateW(OldVersion),'Actman',MB_OKCANCEL or MB_ICONWARNING)<>IDOK then
begin
- StrCopy(p,opt_id ); id :=DBReadDWord (0,DBBranch,section);
- StrCopy(p,opt_descr); descr:=DBReadUnicode(0,DBBranch,section,nil);
- if descr=nil then
- StrDupW(descr,TranslateW('No description'));
+ MacroList:=tMacroList.Create(0);
+ exit;
+ end;
+ end;
+ end;
- StrCopy(p,opt_numacts); num:=DBReadWord(0,DBBranch,section);
- p^:=#0;
- firstAction:=LoadActions(section,num);
+ // Allocate macro list
+ MacroList:=tMacroList.Create(NumMacros);
+
+ // read macro list settings
+ if NumMacros>0 then //?? really, not so necessary
+ begin
+ Macro:=MacroList[0];
+ i:=0;
+ p1:=StrCopyE(section,opt_group);
+ while i<NumMacros do
+ begin
+ p:=StrEnd(IntToStr(p1,i));
+ p^:='/'; inc(p);
+
+ StrCopy(p,opt_flags);
+ with Macro^ do
+ begin
+ flags:=DBReadDWord(0,DBBranch,section,0) and ACF_TOSAVE;
+ if (flags and ACF_ASSIGNED)<>0 then //?? not needed in normal cases
+ begin
+ StrCopy(p,opt_id ); id :=DBReadDWord (0,DBBranch,section);
+ StrCopy(p,opt_descr); tmp:=DBReadUnicode(0,DBBranch,section,NoDescription);
+ StrCopyW(descr,tmp,MacroNameLen-1);
+ mFreeMem(tmp);
+ p^:=#0;
+ if v2 then
+ LoadActionsV2(Macro,section)
+ else
+ LoadActions(Macro,section);
+ end;
end;
+ inc(Macro);
+ inc(i);
+ end;
+
+ if v2 then
+ begin
+ DBDeleteSetting(0,DBBranch,opt_numacts);
+ SaveMacros;
+ MessageBoxW(0,TranslateW(Notes),TranslateW(ConvResult),MB_ICONINFORMATION);
end;
- inc(HK);
- inc(i);
end;
- fCLfilter:=DBReadByte (0,DBBranch,'CLfilter',0)<>0;
- fCLformat:=DBReadUnicode(0,DBBranch,'CLformat');
+
end;
|