Changeset 97 for oup/rewrite/Tools
- Timestamp:
- Jan 23, 2007, 12:05:45 AM (18 years ago)
- Location:
- oup/rewrite/Tools
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/rewrite/Tools/BinEdit.pas
r93 r97 140 140 var 141 141 mem: TMemoryStream; 142 Data: T data;142 Data: TByteData; 143 143 begin 144 144 if con <> nil then … … 397 397 procedure TForm_BinEdit.WriteValues; 398 398 var 399 i, j: Byte;399 i, j: Integer; 400 400 Data: Tdata; 401 401 str: String; -
oup/rewrite/Tools/Preview.pas
r94 r97 4 4 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 5 5 Dialogs, StdCtrls, Template, ExtCtrls, Math, StrUtils, 6 ConnectionManager, {OniImgClass,}Data, TypeDefs, Menus, Buttons;6 ConnectionManager, OniImgClass, Data, TypeDefs, Menus, Buttons; 7 7 8 8 type … … 84 84 procedure TForm_Preview.LoadImage(fileid, index: Integer); 85 85 var 86 Data: TByte Array;86 Data: TByteData; 87 87 memstream: TMemoryStream; 88 88 OniImage: TOniImage; … … 90 90 begin 91 91 OniImage := TOniImage.Create; 92 OniImage.Load(Connection , fileid);93 Data := OniImage.GetAsBMP;92 OniImage.Load(ConnectionID, fileid); 93 OniImage.GetAsBMP(Data); 94 94 OniImage.Free; 95 95 … … 147 147 i: Byte; 148 148 begin 149 Con nection.LoadDatFilePart(_fileid, $14, SizeOf(loop_speed), @loop_speed);150 Con nection.LoadDatFilePart(_fileid, $1C, SizeOf(linkcount), @linkcount);149 ConManager.Connection[ConnectionID].LoadDatFilePart(_fileid, $14, SizeOf(loop_speed), @loop_speed); 150 ConManager.Connection[ConnectionID].LoadDatFilePart(_fileid, $1C, SizeOf(linkcount), @linkcount); 151 151 SetBitmapCount(linkcount); 152 152 for i := 0 to linkcount - 1 do 153 153 begin 154 Con nection.LoadDatFilePart(_fileid, $20 + i * 4, SizeOf(link), @link);154 ConManager.Connection[ConnectionID].LoadDatFilePart(_fileid, $20 + i * 4, SizeOf(link), @link); 155 155 link := link div 256; 156 156 if link = 0 then … … 190 190 else 191 191 actualimg := High(bitmaps); 192 Self.Caption := 'Preview ' + Con nection.GetFileInfo(_fileid).FileName +192 Self.Caption := 'Preview ' + ConManager.Connection[ConnectionID].GetFileInfo(_fileid).Name + 193 193 ' (' + IntToStr(actualimg + 1) + '/' + IntToStr(Length(bitmaps)) + ')'; 194 194 DrawImage(actualimg); … … 202 202 else 203 203 actualimg := 0; 204 Self.Caption := 'Preview ' + Con nection.GetFileInfo(_fileid).FileName +204 Self.Caption := 'Preview ' + ConManager.Connection[ConnectionID].GetFileInfo(_fileid).Name + 205 205 ' (' + IntToStr(actualimg + 1) + '/' + IntToStr(Length(bitmaps)) + ')'; 206 206 DrawImage(actualimg); -
oup/rewrite/Tools/RawEdit.pas
r93 r97 4 4 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 5 5 Dialogs, Template, StdCtrls, ExtCtrls, Menus, Grids, Wrapgrid, 6 MPHexEditor, Clipbrd, StrUtils, 7 Data, Functions, Dat aStructures, Exporters, OniDataClass, Buttons;6 MPHexEditor, Clipbrd, StrUtils, TypeDefs, 7 Data, Functions, DatStructureLoader, ConnectionManager, Buttons; 8 8 9 9 type … … 29 29 procedure list_offsetClick(Sender: TObject); 30 30 procedure NewFile(fileinfo: TFileInfo); 31 procedure LoadRaw(raw_info: TRaw Info);31 procedure LoadRaw(raw_info: TRawDataInfo); 32 32 function Save: Boolean; 33 33 … … 259 259 procedure TForm_RawEdit.WriteValues; 260 260 var 261 i, j: Byte;261 i, j: Integer; 262 262 Data: Tdata; 263 263 str: String; -
oup/rewrite/Tools/Template.dfm
r93 r97 19 19 OnActivate = FormActivate 20 20 OnClose = FormClose 21 OnCreate = FormCreate22 21 OnResize = FormResize 23 22 PixelsPerInch = 96 -
oup/rewrite/Tools/Template.pas
r93 r97 6 6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 7 7 Dialogs, ExtCtrls, StdCtrls, StrUtils, 8 ConnectionManager, {Functions,}Data, TypeDefs, Menus, Buttons;8 Data, TypeDefs, Menus, Buttons; 9 9 10 10 type 11 11 TNewFileSelectedEvent = procedure(FileInfo: TFileInfo) of object; 12 12 TNewConnectionEvent = procedure(Connection: Integer) of object; 13 TCheckCloseableEvent = function: Boolean of object; 13 14 14 15 TForm_ToolTemplate = class(TForm) … … 40 41 combo_connection: TComboBox; 41 42 Bevel1: TBevel; 42 procedure RecreateList;43 procedure UpdateList;44 43 procedure RecreateExtList; 44 procedure UpdateConList; 45 45 procedure LoadFileNames; 46 procedure SelectFileName(connection: Integer; FileName: String); 47 procedure SelectFileID(connection: Integer; FileID: Integer); 46 procedure SelectFileName(ConnectionID: Integer; FileName: String); 47 procedure SelectFileID(ConnectionID, FileID: Integer); 48 procedure SelectConnection(ConnectionID: Integer); 48 49 procedure check_filternameClick(Sender: TObject); 49 50 procedure check_zerobyteClick(Sender: TObject); … … 54 55 55 56 procedure FormResize(Sender: TObject); 56 procedure FormCreate(Sender: TObject);57 57 procedure FormClose(Sender: TObject; var Action: TCloseAction); 58 58 procedure popup_importClick(Sender: TObject); … … 67 67 FOnNewFileSelected: TNewFileSelectedEvent; 68 68 FOnNewConnection: TNewConnectionEvent; 69 FOnCheckCloseable: TCheckCloseableEvent; 69 70 FAllowedExts: String; 70 71 FAllowMultiSelect: Boolean; 71 72 FSelectedFile: TFileInfo; 72 FConnection : Integer;73 FConnectionID: Integer; 73 74 procedure SetAllowedExts(exts: String); 74 75 procedure SetMultiSelect(allow: Boolean); 76 function GetToolCloseable: Boolean; 75 77 public 76 78 constructor Create(AOwner: TComponent); override; … … 79 81 property OnNewFileSelected: TNewFileSelectedEvent read FOnNewFileSelected write FOnNewFileSelected; 80 82 property OnNewConnection: TNewConnectionEvent read FOnNewConnection write FOnNewConnection; 83 property OnCheckCloseable: TCheckCloseableEvent read FOnCheckCloseable write FOnCheckCloseable; 81 84 property AllowedExts: String read FAllowedExts write SetAllowedExts; 82 85 property AllowMultiSelect: Boolean read FAllowMultiSelect write SetMultiSelect; 83 86 property SelectedFile: TFileInfo read FSelectedFile; 84 property Connection: Integer read FConnection; 87 property ConnectionID: Integer read FConnectionID; 88 property Closeable: Boolean read GetToolCloseable; 85 89 end; 86 90 … … 91 95 implementation 92 96 {$R *.dfm} 93 uses Main, Exporters;94 95 96 procedure TForm_ToolTemplate.Update List;97 uses Main, ConnectionManager, Exporters, Functions; 98 99 100 procedure TForm_ToolTemplate.UpdateConList; 97 101 var 98 102 i: Integer; 99 103 fn, datatype, boxstring: String; 100 104 level: Integer; 101 oldcon: String; 102 begin 103 oldcon := combo_connection.Items.Strings[combo_connection.ItemIndex]; 105 begin 104 106 combo_connection.ItemIndex := -1; 105 107 combo_connection.Items.Clear; 106 if Length(DataConnections)> 0 then107 begin 108 for i := 0 to High(DataConnections)do108 if ConManager.Count > 0 then 109 begin 110 for i := 0 to ConManager.Count - 1 do 109 111 begin 110 level := DataConnections[i].LevelInfo.LevelNumber;111 fn := ExtractFileName( DataConnections[i].FileName);112 if DataConnections[i].Backend = ODB_Datthen112 level := ConManager.ConnectionByIndex[i].LevelNumber; 113 fn := ExtractFileName(ConManager.ConnectionByIndex[i].FileName); 114 if ConManager.ConnectionByIndex[i].Backend = DB_ONI then 113 115 datatype := 'ONI-.dat: ' 114 else if DataConnections[i].Backend = ODB_ADB then116 else if ConManager.ConnectionByIndex[i].Backend = DB_ADB then 115 117 datatype := 'OUP-DB: ' 116 118 else … … 118 120 boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ')'; 119 121 combo_connection.Items.Add(boxstring); 120 if oldcon = boxstringthen122 if ConManager.ConnectionByIndex[i].ConnectionID = FConnectionID then 121 123 combo_connection.ItemIndex := combo_connection.Items.Count - 1; 122 124 end; … … 129 131 else 130 132 begin 131 FConnection := nil;133 FConnectionID := 0; 132 134 filelist.Items.Clear; 133 135 combo_extension.Items.Clear; 134 136 combo_connectionChange(Self); 135 FSelectedFile := GetEmptyFileInfo;137 FSelectedFile.ID := -1; 136 138 if Assigned(FOnNewFileSelected) then 137 139 FOnNewFileSelected(FSelectedFile); … … 139 141 end; 140 142 141 procedure TForm_ToolTemplate.RecreateList;142 var143 i: Integer;144 fn, datatype: String;145 level: Integer;146 begin147 combo_connection.Items.Clear;148 if Length(DataConnections) > 0 then149 begin150 for i := 0 to High(DataConnections) do151 begin152 level := DataConnections[i].LevelInfo.LevelNumber;153 fn := ExtractFileName(DataConnections[i].FileName);154 if DataConnections[i].Backend = ODB_Dat then155 datatype := 'ONI-.dat: '156 else if DataConnections[i].Backend = ODB_ADB then157 datatype := 'OUP-DB: '158 else159 datatype := 'Unknown: ';160 combo_connection.Items.Add(datatype + fn + ' (Level: ' + IntToStr(level) + ')');161 end;162 FConnection := DataConnections[0];163 combo_connection.ItemIndex := 0;164 combo_connectionChange(Self);165 end166 else167 begin168 FConnection := nil;169 filelist.Items.Clear;170 combo_extension.Items.Clear;171 combo_connectionChange(Self);172 end;173 end;174 175 143 procedure TForm_ToolTemplate.RecreateExtList; 176 144 var 177 i: LongWord;178 exts: TString Array;145 i: Integer; 146 exts: TStrings; 179 147 begin 180 148 combo_extension.Items.Clear; 181 if FConnection <> nilthen149 if FConnectionID > -1 then 182 150 begin 183 151 combo_extension.Items.Add('_All files_ (' + 184 IntToStr( FConnection.GetFilesCount) + ')');185 exts := FConnection.GetExtensionsList;186 for i := 0 to High(exts)do152 IntToStr(ConManager.Connection[FConnectionID].GetFileCount) + ')'); 153 exts := ConManager.Connection[FConnectionID].GetExtensionsList(EF_ExtCount); 154 for i := 0 to exts.Count - 1 do 187 155 if Length(FAllowedExts) > 0 then 188 156 begin 189 if Pos(MidStr(exts[i],1,4), FAllowedExts) > 0 then 190 begin 191 combo_extension.Items.Add(exts[i]); 192 end; 193 end else 194 combo_extension.Items.Add(exts[i]); 157 if Pos(MidStr(exts.Strings[i],1,4), FAllowedExts) > 0 then 158 combo_extension.Items.Add(exts.Strings[i]); 159 end 160 else 161 combo_extension.Items.Add(exts.Strings[i]); 195 162 combo_extension.ItemIndex := 0; 196 163 combo_extensionClick(Self); 164 exts.Free; 197 165 end; 198 166 end; … … 206 174 no_zero_bytes: Boolean; 207 175 pattern: String; 208 files: TString Array;209 i: LongWord;210 begin 211 if FConnection <> nilthen176 files: TStrings; 177 i: Integer; 178 begin 179 if FConnectionID > -1 then 212 180 begin 213 181 Extension := MidStr(combo_extension.Items.Strings[combo_extension.ItemIndex], 1, 4); … … 222 190 Extension := ''; 223 191 224 files := FConnection.GetFilesList(extension, pattern, no_zero_bytes, FSortBy);192 files := ConManager.Connection[FConnectionID].GetFilesList(extension, pattern, no_zero_bytes, FSortBy); 225 193 226 194 filelist.Visible := False; 227 195 filelist.Items.Clear; 228 if Length(files) > 0 then 229 for i := 0 to High(files) do 230 filelist.Items.Add(files[i]); 196 if files.Count > 0 then 197 filelist.Items.AddStrings(files); 231 198 filelist.Visible := True; 232 199 end; … … 239 206 ext: String; 240 207 begin 241 id := FConnection.ExtractFileID(filelist.Items.Strings[filelist.ItemIndex]);208 id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]); 242 209 ext := RightStr(filelist.Items.Strings[filelist.ItemIndex], 4); 243 210 exportd.Filter := 'Files of matching extension (*.' + ext + ')|*.' + ext + '|All files|*.*'; 244 211 exportd.DefaultExt := ext; 245 212 if exportd.Execute then 246 ExportDatFile(FConnection , id, exportd.FileName);213 ExportDatFile(FConnectionID, id, exportd.FileName); 247 214 end; 248 215 … … 252 219 finfo: TFileInfo; 253 220 fs: TFileStream; 254 data: TData; 255 begin 256 id := FConnection.ExtractFileID(filelist.Items.Strings[filelist.ItemIndex]); 257 finfo := FConnection.GetFileInfo(id); 221 begin 222 id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]); 223 finfo := ConManager.Connection[FConnectionID].GetFileInfo(id); 258 224 259 225 importd.Filter := 'Files of matching extension (*.' + finfo.Extension + ')|*.' + … … 268 234 'Size of chosen file: ' + FormatFileSize(fs.Size)) 269 235 else begin 270 SetLength(data, fs.Size); 271 fs.Read(data[0], fs.Size); 272 FConnection.UpdateDatFile(id, data); 236 ConManager.Connection[FConnectionID].UpdateDatFile(id, fs); 273 237 Self.listClick(Self); 274 238 end; … … 283 247 begin 284 248 sender_name := TComponent(Sender).Name; 285 id := FConnection.ExtractFileID(filelist.Items.Strings[filelist.ItemIndex]);249 id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]); 286 250 context := MidStr(sender_name, Pos('_', sender_name) + 1, Length(sender_name) - Pos('_', sender_name)); 287 Form_Main.open_child(context, FConnection , id);251 Form_Main.open_child(context, FConnectionID, id); 288 252 end; 289 253 … … 295 259 begin 296 260 if combo_connection.ItemIndex >= 0 then 297 begin 298 name := combo_connection.Items.Strings[combo_connection.ItemIndex]; 299 nstart := Pos(' ', name) + 1; 300 nend := Pos('(', name) - 1; 301 name := MidStr(name, nstart, nend - nstart); 302 303 for i := 0 to High(DataConnections) do 304 begin 305 if ExtractFileName(DataConnections[i].FileName) = name then 306 begin 307 FConnection := DataConnections[i]; 308 Break; 309 end; 310 end; 311 if i = Length(DataConnections) then 312 FConnection := nil; 313 314 RecreateExtList; 315 if Assigned(FOnNewConnection) then 316 FOnNewConnection(FConnection); 317 end; 261 FConnectionID := combo_connection.ItemIndex 262 else 263 FConnectionID := -1; 264 RecreateExtList; 265 if Assigned(FOnNewConnection) then 266 FOnNewConnection(FConnectionID); 318 267 end; 319 268 … … 330 279 begin 331 280 inherited; 332 RecreateList; 333 FSelectedFile := GetEmptyFileInfo; 281 Self.Width := 260; 282 Self.Height := 300; 283 FAllowedExts := ''; 284 FAllowMultiSelect := False; 285 FOnNewFileSelected := nil; 286 FOnNewConnection := nil; 287 FOnCheckCloseable := nil; 288 FConnectionID := -1; 289 FSelectedFile.ID := -1; 290 UpdateConList; 334 291 if Length(ToolList) > 0 then 335 292 begin … … 368 325 begin 369 326 if btn_sort_id_asc.Down then 370 FSortBy := stIDAsc327 FSortBy := ST_IDAsc 371 328 else if btn_sort_id_desc.Down then 372 FSortBy := stIDDesc329 FSortBy := ST_IDDesc 373 330 else if btn_sort_name_asc.Down then 374 FSortBy := stNameAsc331 FSortBy := ST_NameAsc 375 332 else if btn_sort_name_desc.Down then 376 FSortBy := stNameDesc333 FSortBy := ST_NameDesc 377 334 else if btn_sort_ext_asc.Down then 378 FSortBy := stExtAsc335 FSortBy := ST_ExtAsc 379 336 else if btn_sort_ext_desc.Down then 380 FSortBy := stExtDesc;337 FSortBy := ST_ExtDesc; 381 338 LoadFileNames; 382 339 end; … … 394 351 if filelist.ItemIndex > -1 then 395 352 begin 396 fileid := FConnection.ExtractFileID(353 fileid := ConManager.Connection[FConnectionID].ExtractFileIDOfName( 397 354 filelist.Items.Strings[filelist.ItemIndex]); 398 FSelectedFile := FConnection.GetFileInfo(fileid);355 FSelectedFile := ConManager.Connection[FConnectionID].GetFileInfo(fileid); 399 356 if Assigned(FOnNewFileSelected) then 400 357 FOnNewFileSelected(FSelectedFile); … … 415 372 416 373 417 procedure TForm_ToolTemplate.SelectFileID(connection: TOniData; id: Integer); 418 var 419 i: Integer; 420 name: String; 421 nstart, nend: Integer; 422 begin 423 for i := 0 to combo_connection.Items.Count - 1 do 424 begin 425 name := combo_connection.Items.Strings[i]; 426 nstart := Pos(' ', name) + 1; 427 nend := Pos('(', name) - 1; 428 name := MidStr(name, nstart, nend - nstart); 429 430 if ExtractFileName(connection.FileName) = name then 431 begin 432 combo_connection.ItemIndex := i; 433 combo_connectionChange(Self); 434 end; 435 end; 374 procedure TForm_ToolTemplate.SelectConnection(ConnectionID: Integer); 375 begin 376 if FConnectionID <> ConnectionID then 377 begin 378 combo_connection.ItemIndex := ConManager.ConnectionIndexByID[ConnectionID]; 379 combo_connectionChange(Self); 380 end; 381 end; 382 383 procedure TForm_ToolTemplate.SelectFileID(ConnectionID, FileID: Integer); 384 var 385 i: Integer; 386 begin 387 if FConnectionID <> ConnectionID then 388 SelectConnection(ConnectionID); 436 389 437 390 filelist.ItemIndex := -1; 438 391 if filelist.Items.Count > 0 then 439 392 for i := 0 to filelist.Items.Count - 1 do 440 if FConnection.ExtractFileID(filelist.Items.Strings[i]) = idthen393 if ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[i]) = FileID then 441 394 begin 442 395 filelist.ItemIndex := i; … … 446 399 end; 447 400 448 procedure TForm_ToolTemplate.SelectFileName(connection: TOniData; filename: String); 449 var 450 i: Integer; 451 name: String; 452 nstart, nend: Integer; 453 begin 454 for i := 0 to combo_connection.Items.Count - 1 do 455 begin 456 name := combo_connection.Items.Strings[i]; 457 nstart := Pos(' ', name) + 1; 458 nend := Pos('(', name) - 1; 459 name := MidStr(name, nstart, nend - nstart); 460 461 if ExtractFileName(connection.FileName) = name then 462 begin 463 combo_connection.ItemIndex := i; 464 combo_connectionChange(Self); 465 end; 466 end; 401 procedure TForm_ToolTemplate.SelectFileName(ConnectionID: Integer; filename: String); 402 var 403 i: Integer; 404 begin 405 if FConnectionID <> ConnectionID then 406 SelectConnection(ConnectionID); 467 407 468 408 filelist.ItemIndex := -1; … … 519 459 520 460 521 procedure TForm_ToolTemplate.FormCreate(Sender: TObject); 522 begin 523 Self.Width := 260; 524 Self.Height := 300; 525 FOnNewFileSelected := nil; 526 FOnNewConnection := nil; 527 FAllowedExts := ''; 528 FAllowMultiSelect := False; 461 function TForm_ToolTemplate.GetToolCloseable: Boolean; 462 begin 463 if Assigned(FOnCheckCloseable) then 464 Result := FOnCheckCloseable 465 else 466 Result := True; 529 467 end; 530 468 -
oup/rewrite/Tools/TxmpReplace.pas
r93 r97 4 4 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 5 5 Dialogs, Template, StdCtrls, ExtCtrls, 6 Functions, Data, OniImgClass, Menus, Buttons ;6 Functions, Data, OniImgClass, Menus, Buttons, TypeDefs; 7 7 8 8 type … … 41 41 implementation 42 42 {$R *.dfm} 43 uses Main, OniDataClass;43 uses Main, ConnectionManager; 44 44 45 45 … … 47 47 procedure TForm_TxmpReplace.SelectFile(fileinfo: TFileInfo); 48 48 var 49 Data: T data;49 Data: TByteData; 50 50 mem: TMemoryStream; 51 51 fadingbyte, depthbyte, storebyte: Byte;
Note:
See TracChangeset
for help on using the changeset viewer.