Created
November 2, 2019 01:53
-
-
Save Leosky/dd8419319de8fcdf59fd2ffaa7ee6f20 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
This script will create an override of the entries in a new file then change NAME and DESC with last conflict looser. | |
} | |
unit CreateOverrideWithLooserStrings; | |
var | |
ToFile: IInterface; | |
function Process(e: IInterface): integer; | |
var | |
m: IInterface; | |
i: integer; | |
frm: TForm; | |
clb: TCheckListBox; | |
begin | |
if not ElementExists(e, 'FULL') and not ElementExists(e, 'DESC') then | |
Exit; | |
// get master record | |
m := Master(e); | |
// no master - nothing to restore | |
if not Assigned(m) then | |
Exit; | |
if Signature(e) = 'TES4' then | |
Exit; | |
if not Assigned(ToFile) then begin | |
frm := frmFileSelect; | |
try | |
frm.Caption := 'Select a plugin'; | |
clb := TCheckListBox(frm.FindComponent('CheckListBox1')); | |
clb.Items.Add('<new file>'); | |
for i := Pred(FileCount) downto 0 do | |
if GetFileName(e) <> GetFileName(FileByIndex(i)) then | |
clb.Items.InsertObject(1, GetFileName(FileByIndex(i)), FileByIndex(i)) | |
else | |
Break; | |
if frm.ShowModal <> mrOk then begin | |
Result := 1; | |
Exit; | |
end; | |
for i := 0 to Pred(clb.Items.Count) do | |
if clb.Checked[i] then begin | |
if i = 0 then ToFile := AddNewFile else | |
ToFile := ObjectToElement(clb.Items.Objects[i]); | |
Break; | |
end; | |
finally | |
frm.Free; | |
end; | |
if not Assigned(ToFile) then begin | |
Result := 1; | |
Exit; | |
end; | |
end; | |
AddRequiredElementMasters(e, ToFile, False); | |
e := wbCopyElementToFile(e, ToFile, False, True); | |
if not SameText(GetElementEditValues(e, 'FULL'), GetElementEditValues(m, 'FULL')) then | |
SetElementEditValues(e, 'FULL', GetElementEditValues(m, 'FULL')); | |
if not SameText(GetElementEditValues(e, 'DESC'), GetElementEditValues(m, 'DESC')) then | |
SetElementEditValues(e, 'DESC', GetElementEditValues(m, 'DESC')); | |
end; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment