- Timestamp:
- Feb 21, 2007, 1:29:27 AM (18 years ago)
- Location:
- oup/rewrite
- Files:
-
- 22 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
oup/rewrite/DataAccess/Access_OUP_ADB.pas
r101 r105 103 103 FBackend := DB_ADB; 104 104 105 FConnectionID := ConnectionID; 105 106 FChangeRights := [CR_EditDat, CR_EditRaw, CR_ResizeDat, CR_ResizeRaw]; 106 107 -
oup/rewrite/DataAccess/Access_OniArchive.pas
r101 r105 43 43 procedure UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: TStream); overload; override; 44 44 45 function AppendRawFile(LocSep: Boolean; S ize: Integer; Src: TStream): Integer; overload; override;45 function AppendRawFile(LocSep: Boolean; Src: TStream): Integer; overload; override; 46 46 published 47 47 end; … … 184 184 Msg := SM_OK; 185 185 FBackend := DB_ONI; 186 FConnectionID := ConnectionID; 186 187 FChangeRights := [CR_EditDat, CR_EditRaw, CR_AppendRaw]; 187 188 end; … … 616 617 end; 617 618 618 function TAccess_OniArchive.AppendRawFile(LocSep: Boolean; S ize: Integer; Src: TStream): Integer;619 function TAccess_OniArchive.AppendRawFile(LocSep: Boolean; Src: TStream): Integer; 619 620 begin 620 621 if not LocSep then … … 625 626 Result := Fraw_file.Size; 626 627 Fraw_file.Seek(0, soFromEnd); 627 Fraw_file.CopyFrom(Src, S ize);628 Fraw_file.CopyFrom(Src, Src.Size); 628 629 if UnloadWhenUnused then 629 630 begin … … 641 642 Result := Fsep_file.Size; 642 643 Fsep_file.Seek(0, soFromEnd); 643 Fsep_file.CopyFrom(Src, S ize);644 Fsep_file.CopyFrom(Src, Src.Size); 644 645 if UnloadWhenUnused then 645 646 begin -
oup/rewrite/DataAccess/DataAccess.pas
r101 r105 42 42 procedure LoadDatFilePart(FileID, Offset, Size: Integer; Target: Pointer); overload; 43 43 procedure UpdateDatFilePart(FileID, Offset, Size: Integer; Src: TStream); overload; virtual; abstract; 44 procedure UpdateDatFilePart(FileID, Offset, Size: Integer; Src: TByteData); overload;45 44 procedure UpdateDatFilePart(FileID, Offset, Size: Integer; Src: Pointer); overload; 46 45 … … 56 55 procedure LoadRawFilePart(FileID, DatOffset, Offset, Size: Integer; Target: Pointer); overload; 57 56 procedure UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: TStream); overload; virtual; abstract; 58 procedure UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: TByteData); overload;59 57 procedure UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: Pointer); overload; 60 58 61 function AppendRawFile(LocSep: Boolean; S ize: Integer; Src: TStream): Integer; overload; virtual;62 function AppendRawFile(LocSep: Boolean; S ize: Integer; Src: TByteData): Integer; overload;59 function AppendRawFile(LocSep: Boolean; Src: TStream): Integer; overload; virtual; 60 function AppendRawFile(LocSep: Boolean; Src: TByteData): Integer; overload; 63 61 function AppendRawFile(LocSep: Boolean; Size: Integer; Src: Pointer): Integer; overload; 64 62 published … … 173 171 end; 174 172 175 procedure TDataAccess.UpdateDatFilePart(FileID, Offset, Size: Integer; Src: TByteData);176 var177 data: TStream;178 begin179 if fileid < GetFileCount then180 begin181 data := TMemoryStream.Create;182 data.Write(Src[0], Size);183 data.Seek(0, soFromBeginning);184 UpdateDatFilePart(FileID, offset, size, data);185 data.Free;186 end;187 end;188 189 173 procedure TDataAccess.UpdateDatFilePart(FileID, Offset, Size: Integer; Src: Pointer); 190 174 var … … 260 244 end; 261 245 262 procedure TDataAccess.UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: TByteData);263 var 264 data: TStream; 265 begin 266 if fileid < GetFileCount then 267 begin 268 data := TMemoryStream.Create; 269 data.Write(Src [0], Size);246 procedure TDataAccess.UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: Pointer); 247 var 248 data: TStream; 249 begin 250 if fileid < GetFileCount then 251 begin 252 data := TMemoryStream.Create; 253 data.Write(Src^, Size); 270 254 data.Seek(0, soFromBeginning); 271 255 UpdateRawFilePart(FileID, DatOffset, Offset, Size, data); … … 274 258 end; 275 259 276 procedure TDataAccess.UpdateRawFilePart(FileID, DatOffset, Offset, Size: Integer; Src: Pointer); 277 var 278 data: TStream; 279 begin 280 if fileid < GetFileCount then 281 begin 282 data := TMemoryStream.Create; 283 data.Write(Src^, Size); 284 data.Seek(0, soFromBeginning); 285 UpdateRawFilePart(FileID, DatOffset, Offset, Size, data); 286 data.Free; 287 end; 288 end; 289 290 291 function TDataAccess.AppendRawFile(LocSep: Boolean; Size: Integer; Src: TStream): Integer; 260 261 function TDataAccess.AppendRawFile(LocSep: Boolean; Src: TStream): Integer; 292 262 begin 293 263 raise ENotImplemented.Create('ERROR: AppendRawFile not implemented here!!!'); … … 295 265 296 266 297 function TDataAccess.AppendRawFile(LocSep: Boolean; S ize: Integer; Src: TByteData): Integer;267 function TDataAccess.AppendRawFile(LocSep: Boolean; Src: TByteData): Integer; 298 268 var 299 269 data: TStream; 300 270 begin 301 271 data := TMemoryStream.Create; 302 data.Write(Src[0], Size); 303 AppendRawFile(LocSep, Size, data); 272 data.Write(Src[0], Length(Src)); 273 data.Seek(0, soFromBeginning); 274 AppendRawFile(LocSep, data); 304 275 data.Free; 305 276 end; … … 311 282 data := TMemoryStream.Create; 312 283 data.Write(Src^, Size); 313 AppendRawFile(LocSep, Size, data); 284 data.Seek(0, soFromBeginning); 285 AppendRawFile(LocSep, data); 314 286 data.Free; 315 287 end; -
oup/rewrite/Global/Functions.pas
r97 r105 11 11 function Decode_Float(buffer: TByteData): Single; 12 12 function Encode_Float(input: Single): TByteData; 13 function IntToBin(Value: Byte): String; 13 14 function DataToBin(Data: TByteData): String; 14 15 function BinToInt(bin: String): Byte; … … 39 40 40 41 41 42 42 function BoolToStr(bool: Boolean): String; 43 43 begin … … 49 49 50 50 51 52 53 51 function HexToLong(hex: String): LongWord; 54 52 … … 76 74 begin 77 75 if NormalizeHexString(hex) then 78 begin 79 Result := StrToInt(hex); 80 { 81 hex := UpperCase(hex); 76 Result := StrToInt(hex) 77 else 82 78 Result := 0; 83 for i := 1 to Length(hex) do 84 begin 85 Result := Result shl 4; 86 case hex[i] of 87 '0'..'9': 88 Result := Result + Ord(hex[i]) - 48; 89 'A'..'F': 90 Result := Result + Ord(hex[i]) - 55; 91 else 92 Result := 0; 93 Exit; 94 end; 95 end; 96 } 97 end 98 else 99 begin 100 Result := 0; 101 end; 102 end; 103 104 79 end; 105 80 106 81 … … 109 84 Result := buffer[0] + buffer[1] * 256 + buffer[2] * 256 * 256 + buffer[3] * 256 * 256 * 256; 110 85 end; 111 112 113 86 114 87 … … 126 99 127 100 128 129 130 101 function Decode_Float(buffer: TByteData): Single; 131 102 var … … 139 110 140 111 141 142 143 112 function Encode_Float(input: Single): TByteData; 144 113 var … … 150 119 151 120 121 function IntToBin(Value: Byte): String; 122 var 123 i: Byte; 124 begin 125 Result := ''; 126 for i := 7 downto 0 do 127 Result := Result + IntToStr((Value shr i) and $01); 128 end; 152 129 153 130 … … 171 148 end; 172 149 end; 173 174 175 150 176 151 … … 193 168 end; 194 169 end; 195 196 170 197 171 -
oup/rewrite/Global/OniImgClass.pas
r101 r105 39 39 function GetImageDataSize(fading: Boolean): Integer; 40 40 41 function GetAsData: TByteData; 42 function GetAs32bit: TByteData; 41 procedure GetAsData(var Target: TStream); overload; 42 procedure GetAsData(var Target: TByteData); overload; 43 procedure GetAs32bit(var Target: TStream); overload; 44 procedure GetAs32bit(var Target: TByteData); overload; 45 procedure GetAsBMP(var Target: TStream); overload; 43 46 procedure GetAsBMP(var Target: TByteData); overload; 44 procedure GetAsBMP(var Target: TStream); overload;45 47 function LoadFromBMP(filename: String): Boolean; 46 48 function WriteToBMP(filename: String): Boolean; 47 function GetMipMappedImage(var faded: TByteData): Boolean; 49 function GetMipMappedImage(var Target: TStream): Boolean; overload; 50 function GetMipMappedImage(var Target: TByteData): Boolean; overload; 48 51 published 49 52 end; … … 369 372 txmpimg.DecodeImage; 370 373 // txmpimg.WriteToBMP('C:\file.bmp'); 371 txmp data := txmpimg.GetAs32bit;374 txmpimg.GetAs32bit(txmpdata); 372 375 { ShowMessage(IntToStr(txmpimg.Width)+'x'+IntToStr(txmpimg.Height)); 373 376 for i:=0 to High(txmpdata) do … … 615 618 616 619 617 function TOniImage.GetAsData: TByteData;620 procedure TOniImage.GetAsData(var Target: TStream); 618 621 var 619 622 i: Integer; … … 629 632 else 630 633 revert := False; 631 SetLength(Result, Length(Self.FData)); 632 for i := 0 to High(Result) do 633 Result[i] := Self.FData[i]; 634 if not Assigned(Target) then 635 Target := TMemoryStream.Create; 636 Target.Write(FData[0], Length(FData)); 637 Target.Seek(0, soFromBeginning); 634 638 if revert then 635 639 Self.RevertImage; 636 640 end; 637 641 638 639 640 641 function TOniImage.GetAs32bit: TByteData; 642 var 643 i: Integer; 642 procedure TOniImage.GetAsData(var Target: TByteData); 643 var 644 mem: TStream; 645 begin 646 mem := TMemoryStream.Create; 647 GetAsData(mem); 648 SetLength(Target, mem.Size); 649 mem.Read(Target[0], mem.Size); 650 mem.Free; 651 end; 652 653 654 procedure TOniImage.GetAs32bit(var Target: TStream); 644 655 begin 645 656 if not (DT_Decoded32 in Self.FDataType) then 646 657 Self.DecodeImage; 647 SetLength(Result, Length(Self.FData)); 648 for i := 0 to High(Result) do 649 Result[i] := Self.FData[i]; 650 end; 651 652 658 if not Assigned(Target) then 659 Target := TMemoryStream.Create; 660 Target.Write(FData[0], Length(FData)); 661 Target.Seek(0, soFromBeginning); 662 end; 663 664 procedure TOniImage.GetAs32bit(var Target: TByteData); 665 var 666 mem: TStream; 667 begin 668 mem := TMemoryStream.Create; 669 GetAs32bit(mem); 670 SetLength(Target, mem.Size); 671 mem.Read(Target[0], mem.Size); 672 mem.Free; 673 end; 653 674 654 675 … … 786 807 787 808 788 789 function TOniImage.GetMipMappedImage(var faded: TByteData): Boolean; 809 function TOniImage.GetMipMappedImage(var Target: TByteData): Boolean; 790 810 var 791 811 i: Integer; … … 810 830 x := Self.FWidth; 811 831 y := Self.FHeight; 812 SetLength( faded, x * y * Self.FDepth div 8);832 SetLength(Target, x * y * Self.FDepth div 8); 813 833 SetLength(fadelvldata, x * y * Self.FDepth div 8); 814 for i := 0 to Length( faded) - 1 do815 begin 816 faded[i] := Self.FData[i];834 for i := 0 to Length(Target) - 1 do 835 begin 836 Target[i] := Self.FData[i]; 817 837 fadelvldata[i] := Self.FData[i]; 818 838 end; … … 821 841 x := x div 2; 822 842 y := y div 2; 823 SetLength( faded, Length(faded) + x * y * Self.FDepth div 8);843 SetLength(Target, Length(Target) + x * y * Self.FDepth div 8); 824 844 for i := 0 to Length(fadelvldata) - 1 do 825 faded[Length(faded) - x * y * Self.FDepth div 8 + i] := fadelvldata[i];845 Target[Length(Target) - x * y * Self.FDepth div 8 + i] := fadelvldata[i]; 826 846 until (x = 1) or (y = 1) or ((x mod 2) = 1) or ((y mod 2) = 1); 827 847 if (x > 1) and (y > 1) then … … 834 854 835 855 856 function TOniImage.GetMipMappedImage(var Target: TStream): Boolean; 857 var 858 data: TByteData; 859 streampos: Integer; 860 begin 861 Result := GetMipMappedImage(data); 862 if not Assigned(Target) then 863 Target := TMemoryStream.Create; 864 streampos := Target.Position; 865 Target.Write(data[0], Length(data)); 866 Target.Seek(streampos, soFromBeginning); 867 end; 868 869 836 870 end. -
oup/rewrite/Global/RawList.pas
r101 r105 18 18 FRawListHandlers: TRawListHandlers; 19 19 public 20 property RawListHandlers: TRawListHandlers read FRawListHandlers; 20 21 procedure InsertRawListHandler(ext: String; needed: Boolean; handler: THandler); 21 22 function GetRawList(ConnectionID, FileID: Integer): TRawDataList; -
oup/rewrite/Helper/ValueEdit.pas
r104 r105 33 33 implementation 34 34 35 uses BinEdit, {RawEdit, }DatStructureLoader, Main;35 uses BinEdit, RawEdit, DatStructureLoader, Main; 36 36 37 37 {$R *.dfm} -
oup/rewrite/Main.dfm
r97 r105 370 370 'Compatible level files|*.dat;*.oldb|Oni level (*.dat)|*.dat|OUP ' + 371 371 'level database (*.oldb)|*.oldb|Any (*.*)|*' 372 Options = [of PathMustExist, ofFileMustExist, ofEnableSizing]372 Options = [ofAllowMultiSelect, ofPathMustExist, ofFileMustExist, ofEnableSizing] 373 373 Left = 32 374 374 Top = 64 -
oup/rewrite/Main.pas
r97 r105 11 11 Settings, {Helper_LevelDB, } 12 12 Template, 13 Preview; 14 // BinEdit, Extractor, RawEdit, TxmpReplace; 13 RawEdit, BinEdit, Extractor, Preview, TxmpReplace; 15 14 16 15 type … … 162 161 begin 163 162 UpdateStatBar; 163 UpdateConLists; 164 164 end; 165 165 end; … … 497 497 procedure TForm_Main.LoadFile(typedb: Boolean); 498 498 var 499 ext: String;499 i: Integer; 500 500 begin 501 501 opend.InitialDir := AppSettings.DatPath; … … 507 507 if opend.Execute then 508 508 begin 509 ext := ExtractFileExt(opend.FileName); 510 if ext = '.dat' then 511 begin 512 CreateConnection(opend.FileName); 513 end else if ext = '.oldb' then 514 begin 515 CreateConnection(opend.FileName); 516 end else 517 ShowMessage('Incompatible file'); 509 if opend.Files.Count > 0 then 510 for i := 0 to opend.Files.Count - 1 do 511 CreateConnection(opend.Files.Strings[i]); 518 512 AppSettings.DatPath := ExtractFilepath(opend.FileName); 519 513 end; … … 693 687 CheckConnectionCloseable(index); 694 688 ConManager.CloseConnectionByIndex(index, RepMsg); 689 ShowOpenMsg(RepMsg); 690 UpdateConLists; 695 691 end; 696 692 UpdateStatBar; … … 751 747 if window_context = 'binedit' then 752 748 begin 753 //toolform := TForm_BinEdit.Create(Self);749 toolform := TForm_BinEdit.Create(Self); 754 750 toolform.Caption := 'Binary .dat-Editor ' + caption_end; 755 751 iconindex := 5; … … 757 753 if window_context = 'extractor' then 758 754 begin 759 //toolform := TForm_Extractor.Create(Self);755 toolform := TForm_Extractor.Create(Self); 760 756 toolform.Caption := 'Extractor ' + caption_end; 761 757 iconindex := 8; … … 769 765 if window_context = 'rawedit' then 770 766 begin 771 //toolform := TForm_RawEdit.Create(Self);767 toolform := TForm_RawEdit.Create(Self); 772 768 toolform.Caption := 'Binary .raw-Editor ' + caption_end; 773 769 iconindex := 6; … … 775 771 if window_context = 'txmpreplace' then 776 772 begin 777 // toolform := TForm_TxmpReplace.Create(Application);773 toolform := TForm_TxmpReplace.Create(Self); 778 774 toolform.Caption := 'TXMP Replacer ' + caption_end; 779 775 iconindex := 7; -
oup/rewrite/OniUnPacker.bdsproj
r104 r105 178 178 </Language> 179 179 180 181 180 <Excluded_Packages> 182 181 <Excluded_Packages Name="d:\programme\borland\bds\3.0\Bin\dbwebxprt.bpl">Borland Web Wizard Package</Excluded_Packages> -
oup/rewrite/OniUnPacker.dpr
r104 r105 23 23 ValueEdit in 'Helper\ValueEdit.pas' {Form_ValueEdit}, 24 24 BinEdit in 'Tools\BinEdit.pas' {Form_BinEdit}, 25 RawEdit in 'Tools\RawEdit.pas' {Form_RawEdit}; 25 RawEdit in 'Tools\RawEdit.pas' {Form_RawEdit}, 26 Extractor in 'Tools\Extractor.pas' {Form_Extractor}, 27 TxmpReplace in 'Tools\TxmpReplace.pas' {Form_TxmpReplace}; 26 28 27 29 {$R *.res} … … 34 36 Application.CreateForm(TForm_Settings, Form_Settings); 35 37 Application.CreateForm(TForm_ValueEdit, Form_ValueEdit); 36 Application.CreateForm(TForm_RawEdit, Form_RawEdit);37 38 Application.Run; 38 39 end. -
oup/rewrite/Tools/BinEdit.dfm
r104 r105 3 3 KeyPreview = True 4 4 OnCloseQuery = FormCloseQuery 5 OnCreate = FormCreate 5 6 OnKeyUp = FormKeyUp 6 7 ExplicitWidth = 500 -
oup/rewrite/Tools/BinEdit.pas
r104 r105 176 176 end; 177 177 end; 178 179 180 181 182 function IntToBin(Value: Byte): String;183 var184 i: Byte;185 begin186 Result := '';187 for i := 7 downto 0 do188 Result := Result + IntToStr((Value shr i) and $01);189 end;190 191 178 192 179 -
oup/rewrite/Tools/Extractor.dfm
r93 r105 22 22 Width = 333 23 23 Height = 338 24 MultiSelect = True 24 25 ExplicitWidth = 333 25 26 ExplicitHeight = 338 -
oup/rewrite/Tools/Extractor.pas
r93 r105 36 36 implementation 37 37 {$R *.dfm} 38 uses Main, Functions, Data, OniDataClass, FolderBrowser, Exporters;38 uses Main, Functions, Data, ConnectionManager, FolderBrowser, Exporters; 39 39 40 40 … … 105 105 if (selonly and filelist.Selected[i]) or not selonly then 106 106 begin 107 fileid := Con nection.ExtractFileID(filelist.Items.Strings[i]);107 fileid := ConManager.Connection[ConnectionID].ExtractFileIDOfName(filelist.Items.Strings[i]); 108 108 filename := GetWinFilename(filelist.Items.Strings[i]); 109 109 if check_dat.Checked then 110 ExportDatFile(Connection , fileid, path + filename);110 ExportDatFile(ConnectionID, fileid, path + filename); 111 111 if check_raw.Checked then 112 ExportRawFiles(Connection , fileid, path + filename);112 ExportRawFiles(ConnectionID, fileid, path + filename); 113 113 if check_convert.Checked then 114 ExportConverted(Connection , fileid, path + filename);114 ExportConverted(ConnectionID, fileid, path + filename); 115 115 Inc(done); 116 116 end; -
oup/rewrite/Tools/RawEdit.dfm
r104 r105 3 3 KeyPreview = True 4 4 OnCloseQuery = FormCloseQuery 5 OnCreate = FormCreate 5 6 OnKeyUp = FormKeyUp 6 7 ExplicitWidth = 500 -
oup/rewrite/Tools/RawEdit.pas
r104 r105 63 63 implementation 64 64 {$R *.dfm} 65 uses Main, ValueEdit ;65 uses Main, ValueEdit, RawList; 66 66 67 67 procedure TForm_RawEdit.NewFile(fileinfo: TFileInfo); … … 115 115 for i := 0 to filelist.Count - 1 do 116 116 begin 117 if ConManager.Connection[ConID].ExtractFileIDOfName(filelist.Items.Strings[i]) = Raw Info.SrcID then117 if ConManager.Connection[ConID].ExtractFileIDOfName(filelist.Items.Strings[i]) = Raw_Info.SrcID then 118 118 begin 119 119 filelist.ItemIndex := i; … … 132 132 end; 133 133 mem := nil; 134 ConManager.Connection[ConID].LoadRawFile(raw_info.SrcID, raw_info.SrcOffset, mem);134 ConManager.Connection[ConID].LoadRawFile(raw_info.SrcID, raw_info.SrcOffset, TStream(mem)); 135 135 hex.LoadFromStream(mem); 136 136 ClearValues; … … 146 146 begin 147 147 ClearValues; 148 dat _offset := StrToInt('$' + MidStr(148 datoffset := StrToInt('$' + MidStr( 149 149 list_offset.Items.Strings[list_offset.ItemIndex], 3, 8)); 150 LoadRaw(Connection.GetRawInfo(fileid, dat_offset)); 151 end; 152 153 154 155 156 function IntToBin(Value: Byte): String; 157 var 158 i: Byte; 159 begin 160 Result := ''; 161 for i := 7 downto 0 do 162 begin 163 Result := Result + IntToStr((Value shr i) and $01); 164 end; 150 LoadRaw(ConManager.Connection[ConID].GetRawInfo(fileid, datoffset)); 165 151 end; 166 152 … … 170 156 function TForm_RawEdit.GetValue(datatype: Word; offset: LongWord): String; 171 157 var 172 Data: T data;158 Data: TByteData; 173 159 i: Word; 174 160 floatformat: TFormatSettings; … … 231 217 begin 232 218 for i := 1 to value_viewer.RowCount - 1 do 233 begin234 219 value_viewer.Cells[1, i] := ''; 235 end;236 220 end; 237 221 … … 242 226 var 243 227 i, j: Integer; 244 Data: T data;228 Data: TByteData; 245 229 str: String; 246 230 Value: LongWord; … … 363 347 364 348 exts := ''; 365 if Length(RawList Handlers) > 0 then366 begin 367 for i := 0 to High(RawList Handlers) do349 if Length(RawLists.RawListHandlers) > 0 then 350 begin 351 for i := 0 to High(RawLists.RawListHandlers) do 368 352 if Length(exts) > 0 then 369 exts := exts + ',' + RawList Handlers[i].Ext353 exts := exts + ',' + RawLists.RawListHandlers[i].Ext 370 354 else 371 exts := RawList Handlers[i].Ext;355 exts := RawLists.RawListHandlers[i].Ext; 372 356 end; 373 357 Self.AllowedExts := exts; … … 404 388 var 405 389 mem: TMemoryStream; 406 Data: Tdata;407 390 i: LongWord; 408 391 begin 409 392 case MessageBox(Self.Handle, PChar('Save changes to .raw-part of file ' + 410 Con nection.GetFileInfo(fileid).FileName + '?'), PChar('Data changed...'),393 ConManager.Connection[ConID].GetFileInfo(fileid).Name + '?'), PChar('Data changed...'), 411 394 MB_YESNOCANCEL) of 412 395 idYes: … … 415 398 hex.SaveToStream(mem); 416 399 mem.Seek(0, soFromBeginning); 417 SetLength(Data, mem.Size); 418 mem.Read(Data[0], mem.Size); 400 ConManager.Connection[ConID].UpdateRawFile(fileid, datoffset, mem); 419 401 mem.Free; 420 Connection.UpdateRawFile(fileid_opened, dat_offset_opened,421 Length(Data), @Data[0]);422 402 hex.Modified := False; 423 403 for i := 0 to hex.Datasize - 1 do … … 428 408 Result := True; 429 409 idCancel: 430 begin431 410 Result := False; 432 end;433 411 end; 434 412 end; … … 440 418 begin 441 419 if hex.Modified then 442 begin443 420 if not Save then 444 421 CanClose := False; 445 end;446 422 end; 447 423 … … 529 505 fs: TFileStream; 530 506 begin 531 saved.Filter := 'Files of matching extension (*.' + Connection.GetFileInfo( 532 fileid).Extension + ')|*.' + Connection.GetFileInfo(fileid).Extension + 507 saved.Filter := 'Files of matching extension (*.' + 508 ConManager.Connection[ConID].GetFileInfo(fileid).Extension + ')|*.' + 509 ConManager.Connection[ConID].GetFileInfo(fileid).Extension + 533 510 '|All files|*.*'; 534 saved.DefaultExt := Con nection.GetFileInfo(fileid).Extension;511 saved.DefaultExt := ConManager.Connection[ConID].GetFileInfo(fileid).Extension; 535 512 if saved.Execute then 536 513 begin … … 548 525 // Data: Tdata; 549 526 fs: TFileStream; 550 begin 551 opend.Filter := 'Files of matching extension (*.' + Connection.GetFileInfo( 552 fileid).Extension + ')|*.' + Connection.GetFileInfo(fileid).Extension + 527 data: TByteData; 528 i: Integer; 529 rawinfo: TRawDataInfo; 530 begin 531 opend.Filter := 'Files of matching extension (*.' + 532 ConManager.Connection[ConID].GetFileInfo(fileid).Extension + ')|*.' + 533 ConManager.Connection[ConID].GetFileInfo(fileid).Extension + 553 534 '|All files|*.*'; 554 535 if opend.Execute then … … 557 538 if fs.Size <> hex.DataSize then 558 539 begin 559 ShowMessage('Can''t import ' + ExtractFilename(opend.FileName) + 560 ', file has to have same size as file in .dat.' + CrLf + 561 'Size of file in .dat: ' + FormatFileSize(hex.datasize) + CrLf + 562 'Size of chosen file: ' + FormatFileSize(fs.Size)); 563 end 564 else 565 begin 566 hex.LoadFromStream(fs); 567 hex.Modified := True; 568 end; 540 if (not (CR_ResizeRaw in ConManager.Connection[ConID].ChangeRights)) and (not (CR_AppendRaw in ConManager.Connection[ConnectionID].ChangeRights)) then 541 begin 542 ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) + 543 ', file has to have same size as file in .raw with this backend.' + CrLf + 544 'Size of file in .raw: ' + FormatFileSize(hex.DataSize) + CrLf + 545 'Size of chosen file: ' + FormatFileSize(fs.Size)); 546 Exit; 547 end else begin 548 if MessageBox(Self.Handle, 549 PChar('File has different size from the file in the .raw.' + CrLf + 550 'Size of file in .dat: ' + FormatFileSize(hex.DataSize) + CrLf + 551 'Size of chosen file: ' + FormatFileSize(fs.Size) + CrLf + 552 'Replace anyway?' + CrLf + 553 'WARNING: This only replaces the raw-data. It doesn''t' + CrLf + 554 'do the according changes in the .dat. Oni probably' + CrLf + 555 'won''t be able to use the data correctly!'), PChar('Different size'), MB_YESNO + MB_ICONWARNING) = ID_NO then 556 begin 557 Exit; 558 end; 559 end; 560 rawinfo := ConManager.Connection[ConID].GetRawInfo(fileid, datoffset); 561 if CR_ResizeRaw in ConManager.Connection[ConID].ChangeRights then 562 ConManager.Connection[ConID].UpdateRawFile(fileid, datoffset, fs) 563 else if CR_AppendRaw in ConManager.Connection[ConID].ChangeRights then 564 i := ConManager.Connection[ConID].AppendRawFile(rawinfo.LocSep, fs); 565 ConManager.Connection[ConID].UpdateDatFilePart(fileid, datoffset, 4, @i); 566 end else begin 567 ConManager.Connection[ConID].UpdateRawFile(fileid, datoffset, fs); 568 end; 569 fs.Seek(0, soFromBeginning); 570 hex.LoadFromStream(fs); 571 hex.Modified := False; 572 for i := 0 to hex.Datasize - 1 do 573 hex.ByteChanged[i] := False; 569 574 fs.Free; 570 575 end; … … 691 696 procedure TForm_RawEdit.SetNewValue(datatype: Word; offset: LongWord; Value: String); 692 697 var 693 Data: T data;698 Data: TByteData; 694 699 value_int: LongWord; 695 700 value_float: Single; -
oup/rewrite/Tools/Template.dfm
r101 r105 242 242 Style = csDropDownList 243 243 Anchors = [akLeft, akTop, akRight] 244 DropDownCount = 12244 DropDownCount = 20 245 245 Font.Charset = DEFAULT_CHARSET 246 246 Font.Color = clWindowText … … 288 288 Style = csDropDownList 289 289 Anchors = [akLeft, akTop, akRight] 290 DropDownCount = 12 290 291 ItemHeight = 13 291 292 TabOrder = 4 -
oup/rewrite/Tools/Template.pas
r101 r105 117 117 else 118 118 datatype := 'Unknown: '; 119 boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ') ';119 boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ') [' + IntToStr(ConManager.ConnectionByIndex[i].ConnectionID) + ']'; 120 120 combo_connection.Items.Add(boxstring); 121 121 if ConManager.ConnectionByIndex[i].ConnectionID = FConnectionID then … … 276 276 begin 277 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 279 282 else 280 283 FConnectionID := -1; -
oup/rewrite/Tools/TxmpReplace.dfm
r93 r105 1 1 inherited Form_TxmpReplace: TForm_TxmpReplace 2 2 Caption = 'TxmpReplace' 3 OnCreate = FormCreate 3 4 PixelsPerInch = 96 4 5 TextHeight = 13 -
oup/rewrite/Tools/TxmpReplace.pas
r97 r105 47 47 procedure TForm_TxmpReplace.SelectFile(fileinfo: TFileInfo); 48 48 var 49 Data: TByteData;50 49 mem: TMemoryStream; 51 50 fadingbyte, depthbyte, storebyte: Byte; 52 51 begin 53 52 fileid := fileinfo.ID; 54 Con nection.LoadDatFilePart(fileid, $88, SizeOf(fadingbyte), @fadingbyte);55 Con nection.LoadDatFilePart(fileid, $89, SizeOf(depthbyte), @depthbyte);56 Con nection.LoadDatFilePart(fileid, $90, SizeOf(storebyte), @storebyte);53 ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $88, SizeOf(fadingbyte), @fadingbyte); 54 ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $89, SizeOf(depthbyte), @depthbyte); 55 ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $90, SizeOf(storebyte), @storebyte); 57 56 check_fading.Checked := (fadingbyte and $01) > 0; 58 57 check_transparency.Checked := (depthbyte and $04) > 0; 59 58 60 OniImage_Old.LoadFromTXMP( connection, fileid);59 OniImage_Old.LoadFromTXMP(ConnectionID, fileid); 61 60 old_size := OniImage_Old.GetImageDataSize((fadingbyte and $01) > 0); 62 Data := OniImage_Old.GetAsBMP;63 61 mem := TMemoryStream.Create; 64 mem.Write(Data[0], Length(Data));62 OniImage_Old.GetAsBMP(TStream(mem)); 65 63 mem.Seek(0, soFromBeginning); 66 64 image_txmppreview.Picture.Bitmap.LoadFromStream(mem); … … 74 72 var 75 73 mem: TMemoryStream; 76 tempd: Tdata;77 74 begin 78 75 if opend.Execute then 79 76 begin 80 77 OniImage_New.LoadFromBMP(opend.FileName); 81 tempd := OniImage_New.GetAsBMP;82 78 mem := TMemoryStream.Create; 83 mem.Write(tempd[0], Length(tempd));79 OniImage_New.GetAsBMP(TStream(mem)); 84 80 mem.Seek(0, soFromBeginning); 85 81 image_bmppreview.Picture.Bitmap.LoadFromStream(mem); … … 97 93 old_rawaddr, new_rawaddr: LongWord; 98 94 oldfading: Byte; 99 tempd: Tdata;100 101 95 datbyte: Word; 96 mem: TMemoryStream; 102 97 begin 103 98 if filelist.ItemIndex >= 0 then 104 99 begin 105 Con nection.LoadDatFilePart(fileid, $88, 1, @oldfading);106 if Connection.OSisMacthen107 Con nection.UpdateDatFilePart(fileid, $A0, 4, @old_rawaddr)100 ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $88, 1, @oldfading); 101 if not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN) then 102 ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $A0, 4, @old_rawaddr) 108 103 else 109 Con nection.LoadDatFilePart(fileid, $9C, 4, @old_rawaddr);104 ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $9C, 4, @old_rawaddr); 110 105 111 106 if (OniImage_Old.Width <> OniImage_New.Width) or 112 107 (OniImage_Old.Height <> OniImage_New.Height) then 113 108 begin 114 if MessageBox(Self.Handle, PChar(115 'Current image and new image have different size' + CrLf +116 '(Current: ' + IntToStr(OniImage_Old.Width)+117 'x' + IntToStr(OniImage_Old.Height) + ' - New:' +118 IntToStr(OniImage_New.Width) + 'x' + IntToStr(OniImage_New.Height) + ')' + CrLf+119 'Replace anyways?'),120 PChar(filelist.Items.Strings[filelist.ItemIndex]),121 MB_YESNO) = idNo then109 if MessageBox(Self.Handle, 110 PChar( 111 'Current image and new image have different size' + CrLf + 112 '(Current: ' + IntToStr(OniImage_Old.Width) + 'x' + 113 IntToStr(OniImage_Old.Height) + ' - New: ' + 114 IntToStr(OniImage_New.Width) + 'x' + IntToStr(OniImage_New.Height) + 115 ')' + CrLf + 'Replace anyway?'), 116 PChar(filelist.Items.Strings[filelist.ItemIndex]), MB_YESNO) = idNo then 122 117 Exit; 123 118 end; 124 119 120 mem := TMemoryStream.Create; 121 125 122 if check_fading.Checked then 126 if not OniImage_New.GetMipMappedImage( tempd) then123 if not OniImage_New.GetMipMappedImage(TStream(mem)) then 127 124 if MessageBox(Self.Handle, 128 PChar('Can not create a MipMapped-image (probably because of a wrong dimension).' +129 #13 + #10 + 'Do you want to continue without MipMapping?'), PChar('Warning'),130 MB_YESNO) = ID_YES then125 PChar('Can not create a MipMapped-image (probably because of a wrong dimension).' + 126 #13 + #10 + 'Do you want to continue without MipMapping?'), PChar('Warning'), 127 MB_YESNO) = ID_YES then 131 128 check_fading.Checked := False 132 129 else … … 134 131 135 132 if not check_fading.Checked then 136 tempd := OniImage_New.GetAsData; 133 begin 134 mem.Clear; 135 OniImage_New.GetAsData(TStream(mem)); 136 end; 137 137 138 138 newsize := OniImage_New.GetImageDataSize(check_fading.Checked); 139 139 140 if (newsize > old_size) and (Con nection.Backend = ODB_Dat) then141 new_rawaddr := Con nection.AppendRawFile(142 Connection.OSisMac, Length(tempd), tempd)140 if (newsize > old_size) and (ConManager.Connection[ConnectionID].Backend = DB_ONI) then 141 new_rawaddr := ConManager.Connection[ConnectionID].AppendRawFile( 142 not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN), mem.Size, mem) 143 143 else 144 144 begin 145 145 new_rawaddr := old_rawaddr; 146 Con nection.UpdateRawFile(fileid, $9C, Length(tempd), tempd);146 ConManager.Connection[ConnectionID].UpdateRawFile(fileid, $9C, mem); 147 147 end; 148 148 … … 150 150 if check_fading.Checked then 151 151 datbyte := datbyte or $01; 152 Con nection.UpdateDatFilePart(fileid, $88, 1, @datbyte);152 ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $88, 1, @datbyte); 153 153 datbyte := $10; 154 154 if check_transparency.Checked then 155 155 datbyte := datbyte or $04; 156 Con nection.UpdateDatFilePart(fileid, $89, 1, @datbyte);157 Con nection.UpdateDatFilePart(fileid, $8C, 2, @OniImage_New.Width);158 Con nection.UpdateDatFilePart(fileid, $8E, 2, @OniImage_New.Height);156 ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $89, 1, @datbyte); 157 ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $8C, 2, @OniImage_New.Width); 158 ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $8E, 2, @OniImage_New.Height); 159 159 datbyte := $08; 160 Con nection.UpdateDatFilePart(fileid, $90, 1, @datbyte);161 if Connection.OSisMacthen162 Con nection.UpdateDatFilePart(fileid, $A0, 4, @new_rawaddr)160 ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $90, 1, @datbyte); 161 if not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN) then 162 ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $A0, 4, @new_rawaddr) 163 163 else 164 Con nection.UpdateDatFilePart(fileid, $9C, 4, @new_rawaddr);164 ConManager.Connection[ConnectionID].UpdateDatFilePart(fileid, $9C, 4, @new_rawaddr); 165 165 166 166 ShowMessage('TXMP-image replaced');
Note:
See TracChangeset
for help on using the changeset viewer.