Changeset 105 for oup/rewrite/Tools
- Timestamp:
- Feb 21, 2007, 1:29:27 AM (18 years ago)
- Location:
- oup/rewrite/Tools
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
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.