ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/oup/current/Tools/Template.pas
(Generate patch)

Comparing oup/rewrite/Tools/Template.pas (file contents):
Revision 97 by alloc, Mon Jan 22 23:05:45 2007 UTC vs.
Revision 105 by alloc, Wed Feb 21 00:29:27 2007 UTC

# Line 53 | Line 53 | type
53      procedure listMouseDown(Sender: TObject; Button: TMouseButton;
54        Shift: TShiftState; X, Y: Integer);
55  
56    procedure FormResize(Sender: TObject);
56      procedure FormClose(Sender: TObject; var Action: TCloseAction);
57      procedure popup_importClick(Sender: TObject);
58      procedure popup_exportClick(Sender: TObject);
# Line 117 | Line 116 | begin
116          datatype := 'OUP-DB: '
117        else
118          datatype := 'Unknown: ';
119 <      boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ')';
119 >      boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ') [' + IntToStr(ConManager.ConnectionByIndex[i].ConnectionID) + ']';
120        combo_connection.Items.Add(boxstring);
121        if ConManager.ConnectionByIndex[i].ConnectionID = FConnectionID then
122          combo_connection.ItemIndex := combo_connection.Items.Count - 1;
# Line 219 | Line 218 | var
218    finfo: TFileInfo;
219    fs: TFileStream;
220   begin
221 <  id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]);
222 <  finfo := ConManager.Connection[FConnectionID].GetFileInfo(id);
221 >  if CR_EditDat in ConManager.Connection[FConnectionID].ChangeRights then
222 >  begin
223 >    id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]);
224 >    finfo := ConManager.Connection[FConnectionID].GetFileInfo(id);
225  
226 <  importd.Filter := 'Files of matching extension (*.' + finfo.Extension + ')|*.' +
227 <        finfo.Extension + '|All files|*.*';
228 <  if importd.Execute then
229 <  begin
230 <    fs := TFileStream.Create(importd.FileName, fmOpenRead);
231 <    if fs.Size <> finfo.Size then
232 <      ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) +
233 <        ', file has to have same size as file in .dat.' + CrLf +
234 <        'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf +
235 <        'Size of chosen file: ' + FormatFileSize(fs.Size))
236 <    else begin
226 >    importd.Filter := 'Files of matching extension (*.' + finfo.Extension + ')|*.' +
227 >          finfo.Extension + '|All files|*.*';
228 >    if importd.Execute then
229 >    begin
230 >      fs := TFileStream.Create(importd.FileName, fmOpenRead);
231 >      if fs.Size <> finfo.Size then
232 >      begin
233 >        if not (CR_ResizeDat in ConManager.Connection[FConnectionID].ChangeRights) then
234 >        begin
235 >          ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) +
236 >            ', file has to have same size as file in .dat with this backend.' + CrLf +
237 >            'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf +
238 >            'Size of chosen file: ' + FormatFileSize(fs.Size));
239 >          Exit;
240 >        end else begin
241 >          if MessageBox(Self.Handle,
242 >              PChar('File has different size from the file in the .dat.' + CrLf +
243 >                    'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf +
244 >                    'Size of chosen file: ' + FormatFileSize(fs.Size) + CrLf +
245 >                    'Replace anyway?'), PChar('Different size'), MB_YESNO + MB_ICONWARNING) = ID_NO then
246 >          begin
247 >            Exit;
248 >          end;
249 >        end;
250 >      end;
251        ConManager.Connection[FConnectionID].UpdateDatFile(id, fs);
252        Self.listClick(Self);
253 +      fs.Free;
254      end;
255 <    fs.Free;
255 >  end else begin
256 >    ShowMessage('Editing .dat-contents not allowed with this backend.');
257    end;
258   end;
259  
# Line 258 | Line 275 | var
275    i: Integer;
276   begin
277    if combo_connection.ItemIndex >= 0 then
278 <    FConnectionID := combo_connection.ItemIndex
278 >  begin
279 >    name := combo_connection.Items.Strings[combo_connection.ItemIndex];
280 >    FConnectionID := StrToInt(MidStr(name, Pos('[', name) + 1, Pos(']', name) - Pos('[', name)  - 1));
281 >  end
282    else
283      FConnectionID := -1;
284    RecreateExtList;
# Line 448 | Line 468 | begin
468   end;
469  
470  
451 procedure TForm_ToolTemplate.FormResize(Sender: TObject);
452 begin
453  if Self.Width < 300 then
454    Self.Width := 300;
455  if Self.Height < 200 then
456    Self.Height := 200;
457 end;
458
459
460
471   function TForm_ToolTemplate.GetToolCloseable: Boolean;
472   begin
473    if Assigned(FOnCheckCloseable) then

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)