--- oup/rewrite/Tools/Template.pas 2007/01/22 23:05:45 97 +++ oup/rewrite/Tools/Template.pas 2007/02/21 00:29:27 105 @@ -53,7 +53,6 @@ type procedure listMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); - procedure FormResize(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure popup_importClick(Sender: TObject); procedure popup_exportClick(Sender: TObject); @@ -117,7 +116,7 @@ begin datatype := 'OUP-DB: ' else datatype := 'Unknown: '; - boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ')'; + boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ') [' + IntToStr(ConManager.ConnectionByIndex[i].ConnectionID) + ']'; combo_connection.Items.Add(boxstring); if ConManager.ConnectionByIndex[i].ConnectionID = FConnectionID then combo_connection.ItemIndex := combo_connection.Items.Count - 1; @@ -219,24 +218,42 @@ var finfo: TFileInfo; fs: TFileStream; begin - id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]); - finfo := ConManager.Connection[FConnectionID].GetFileInfo(id); + if CR_EditDat in ConManager.Connection[FConnectionID].ChangeRights then + begin + id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]); + finfo := ConManager.Connection[FConnectionID].GetFileInfo(id); - importd.Filter := 'Files of matching extension (*.' + finfo.Extension + ')|*.' + - finfo.Extension + '|All files|*.*'; - if importd.Execute then - begin - fs := TFileStream.Create(importd.FileName, fmOpenRead); - if fs.Size <> finfo.Size then - ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) + - ', file has to have same size as file in .dat.' + CrLf + - 'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf + - 'Size of chosen file: ' + FormatFileSize(fs.Size)) - else begin + importd.Filter := 'Files of matching extension (*.' + finfo.Extension + ')|*.' + + finfo.Extension + '|All files|*.*'; + if importd.Execute then + begin + fs := TFileStream.Create(importd.FileName, fmOpenRead); + if fs.Size <> finfo.Size then + begin + if not (CR_ResizeDat in ConManager.Connection[FConnectionID].ChangeRights) then + begin + ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) + + ', file has to have same size as file in .dat with this backend.' + CrLf + + 'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf + + 'Size of chosen file: ' + FormatFileSize(fs.Size)); + Exit; + end else begin + if MessageBox(Self.Handle, + PChar('File has different size from the file in the .dat.' + CrLf + + 'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf + + 'Size of chosen file: ' + FormatFileSize(fs.Size) + CrLf + + 'Replace anyway?'), PChar('Different size'), MB_YESNO + MB_ICONWARNING) = ID_NO then + begin + Exit; + end; + end; + end; ConManager.Connection[FConnectionID].UpdateDatFile(id, fs); Self.listClick(Self); + fs.Free; end; - fs.Free; + end else begin + ShowMessage('Editing .dat-contents not allowed with this backend.'); end; end; @@ -258,7 +275,10 @@ var i: Integer; begin if combo_connection.ItemIndex >= 0 then - FConnectionID := combo_connection.ItemIndex + begin + name := combo_connection.Items.Strings[combo_connection.ItemIndex]; + FConnectionID := StrToInt(MidStr(name, Pos('[', name) + 1, Pos(']', name) - Pos('[', name) - 1)); + end else FConnectionID := -1; RecreateExtList; @@ -448,16 +468,6 @@ begin end; -procedure TForm_ToolTemplate.FormResize(Sender: TObject); -begin - if Self.Width < 300 then - Self.Width := 300; - if Self.Height < 200 then - Self.Height := 200; -end; - - - function TForm_ToolTemplate.GetToolCloseable: Boolean; begin if Assigned(FOnCheckCloseable) then