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.
oup/current/Tools/Template.pas (file contents), Revision 109 by alloc, Wed Feb 21 03:12:33 2007 UTC

# Line 40 | Line 40 | type
40      Label3: TLabel;
41      combo_connection: TComboBox;
42      Bevel1: TBevel;
43 +    popup_linkshere: TMenuItem;
44 +    popup_separator2: TMenuItem;
45      procedure RecreateExtList;
46      procedure UpdateConList;
47      procedure LoadFileNames;
# Line 53 | Line 55 | type
55      procedure listMouseDown(Sender: TObject; Button: TMouseButton;
56        Shift: TShiftState; X, Y: Integer);
57  
56    procedure FormResize(Sender: TObject);
58      procedure FormClose(Sender: TObject; var Action: TCloseAction);
59      procedure popup_importClick(Sender: TObject);
60      procedure popup_exportClick(Sender: TObject);
# Line 62 | Line 63 | type
63      procedure btn_sortClick(Sender: TObject);
64      procedure FormActivate(Sender: TObject);
65      procedure combo_connectionChange(Sender: TObject);
66 +    procedure popup_linkshereClick(Sender: TObject);
67    private
68      FSortBy: TSortType;
69      FOnNewFileSelected: TNewFileSelectedEvent;
# Line 94 | Line 96 | procedure AddToolListEntry(context, name
96  
97   implementation
98   {$R *.dfm}
99 < uses Main, ConnectionManager, Exporters, Functions;
99 > uses Main, ConnectionManager, Exporters, Functions, WhatLinksHere;
100  
101  
102   procedure TForm_ToolTemplate.UpdateConList;
# Line 117 | Line 119 | begin
119          datatype := 'OUP-DB: '
120        else
121          datatype := 'Unknown: ';
122 <      boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ')';
122 >      boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ') [' + IntToStr(ConManager.ConnectionByIndex[i].ConnectionID) + ']';
123        combo_connection.Items.Add(boxstring);
124        if ConManager.ConnectionByIndex[i].ConnectionID = FConnectionID then
125          combo_connection.ItemIndex := combo_connection.Items.Count - 1;
# Line 219 | Line 221 | var
221    finfo: TFileInfo;
222    fs: TFileStream;
223   begin
224 <  id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]);
225 <  finfo := ConManager.Connection[FConnectionID].GetFileInfo(id);
224 >  if CR_EditDat in ConManager.Connection[FConnectionID].ChangeRights then
225 >  begin
226 >    id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]);
227 >    finfo := ConManager.Connection[FConnectionID].GetFileInfo(id);
228  
229 <  importd.Filter := 'Files of matching extension (*.' + finfo.Extension + ')|*.' +
230 <        finfo.Extension + '|All files|*.*';
231 <  if importd.Execute then
232 <  begin
233 <    fs := TFileStream.Create(importd.FileName, fmOpenRead);
234 <    if fs.Size <> finfo.Size then
235 <      ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) +
236 <        ', file has to have same size as file in .dat.' + CrLf +
237 <        'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf +
238 <        'Size of chosen file: ' + FormatFileSize(fs.Size))
239 <    else begin
229 >    importd.Filter := 'Files of matching extension (*.' + finfo.Extension + ')|*.' +
230 >          finfo.Extension + '|All files|*.*';
231 >    if importd.Execute then
232 >    begin
233 >      fs := TFileStream.Create(importd.FileName, fmOpenRead);
234 >      if fs.Size <> finfo.Size then
235 >      begin
236 >        if not (CR_ResizeDat in ConManager.Connection[FConnectionID].ChangeRights) then
237 >        begin
238 >          ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) +
239 >            ', file has to have same size as file in .dat with this backend.' + CrLf +
240 >            'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf +
241 >            'Size of chosen file: ' + FormatFileSize(fs.Size));
242 >          Exit;
243 >        end else begin
244 >          if MessageBox(Self.Handle,
245 >              PChar('File has different size from the file in the .dat.' + CrLf +
246 >                    'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf +
247 >                    'Size of chosen file: ' + FormatFileSize(fs.Size) + CrLf +
248 >                    'Replace anyway?'), PChar('Different size'), MB_YESNO + MB_ICONWARNING) = ID_NO then
249 >          begin
250 >            Exit;
251 >          end;
252 >        end;
253 >      end;
254        ConManager.Connection[FConnectionID].UpdateDatFile(id, fs);
255        Self.listClick(Self);
256 +      fs.Free;
257      end;
258 <    fs.Free;
258 >  end else begin
259 >    ShowMessage('Editing .dat-contents not allowed with this backend.');
260    end;
261   end;
262  
263 + procedure TForm_ToolTemplate.popup_linkshereClick(Sender: TObject);
264 + begin
265 +  Form_WhatLinksHere.ConID := FConnectionID;
266 +  Form_WhatLinksHere.FileID := FSelectedFile.ID;
267 +  Form_WhatLinksHere.SenderForm := Self;
268 +  Form_WhatLinksHere.Show;
269 + end;
270 +
271   procedure TForm_ToolTemplate.popup_opentool(Sender: TObject);
272   var
273    sender_name, context: String;
# Line 258 | Line 286 | var
286    i: Integer;
287   begin
288    if combo_connection.ItemIndex >= 0 then
289 <    FConnectionID := combo_connection.ItemIndex
289 >  begin
290 >    name := combo_connection.Items.Strings[combo_connection.ItemIndex];
291 >    FConnectionID := StrToInt(MidStr(name, Pos('[', name) + 1, Pos(']', name) - Pos('[', name)  - 1));
292 >  end
293    else
294      FConnectionID := -1;
295    RecreateExtList;
# Line 314 | Line 345 | begin
345        if Pos(ext, ToolList[i].exts) = 0 then
346          filepopup.Items.Items[i].Enabled := False;
347    end;
348 +  filepopup.Items.Find('What links here?').Enabled :=
349 +      ConManager.Connection[FConnectionID].Backend = DB_ADB;
350   end;
351  
352   procedure TForm_ToolTemplate.check_zerobyteClick(Sender: TObject);
# Line 365 | Line 398 | var
398   begin
399    pt.X := x;
400    pt.Y := y;
401 < //  filelist.ItemIndex := filelist.ItemAtPos(pt, true);
402 < //  Self.listClick(Self);
401 >  if Shift = [ssRight] then
402 >  begin
403 >    filelist.ItemIndex := filelist.ItemAtPos(pt, true);
404 >    Self.listClick(Self);
405 >  end;
406   end;
407  
408  
# Line 448 | Line 484 | begin
484   end;
485  
486  
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
487   function TForm_ToolTemplate.GetToolCloseable: Boolean;
488   begin
489    if Assigned(FOnCheckCloseable) then

Diff Legend

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