| 62 |
|
|
| 63 |
|
implementation |
| 64 |
|
{$R *.dfm} |
| 65 |
< |
uses Main, ValueEdit; |
| 65 |
> |
uses Main, ValueEdit, RawList; |
| 66 |
|
|
| 67 |
|
procedure TForm_RawEdit.NewFile(fileinfo: TFileInfo); |
| 68 |
|
var |
| 114 |
|
begin |
| 115 |
|
for i := 0 to filelist.Count - 1 do |
| 116 |
|
begin |
| 117 |
< |
if ConManager.Connection[ConID].ExtractFileIDOfName(filelist.Items.Strings[i]) = RawInfo.SrcID then |
| 117 |
> |
if ConManager.Connection[ConID].ExtractFileIDOfName(filelist.Items.Strings[i]) = Raw_Info.SrcID then |
| 118 |
|
begin |
| 119 |
|
filelist.ItemIndex := i; |
| 120 |
|
listClick(Self); |
| 131 |
|
end; |
| 132 |
|
end; |
| 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 |
|
hex.LoadFromStream(mem); |
| 136 |
|
ClearValues; |
| 137 |
|
hexSelectionChanged(Self); |
| 145 |
|
procedure TForm_RawEdit.list_offsetClick(Sender: TObject); |
| 146 |
|
begin |
| 147 |
|
ClearValues; |
| 148 |
< |
dat_offset := StrToInt('$' + MidStr( |
| 148 |
> |
datoffset := StrToInt('$' + MidStr( |
| 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)); |
| 151 |
|
end; |
| 152 |
|
|
| 153 |
|
|
| 155 |
|
|
| 156 |
|
function TForm_RawEdit.GetValue(datatype: Word; offset: LongWord): String; |
| 157 |
|
var |
| 158 |
< |
Data: Tdata; |
| 158 |
> |
Data: TByteData; |
| 159 |
|
i: Word; |
| 160 |
|
floatformat: TFormatSettings; |
| 161 |
|
begin |
| 216 |
|
i: Byte; |
| 217 |
|
begin |
| 218 |
|
for i := 1 to value_viewer.RowCount - 1 do |
| 233 |
– |
begin |
| 219 |
|
value_viewer.Cells[1, i] := ''; |
| 235 |
– |
end; |
| 220 |
|
end; |
| 221 |
|
|
| 222 |
|
|
| 225 |
|
procedure TForm_RawEdit.WriteValues; |
| 226 |
|
var |
| 227 |
|
i, j: Integer; |
| 228 |
< |
Data: Tdata; |
| 228 |
> |
Data: TByteData; |
| 229 |
|
str: String; |
| 230 |
|
Value: LongWord; |
| 231 |
|
floatformat: TFormatSettings; |
| 346 |
|
Self.OnNewFileSelected := Self.NewFile; |
| 347 |
|
|
| 348 |
|
exts := ''; |
| 349 |
< |
if Length(RawListHandlers) > 0 then |
| 349 |
> |
if Length(RawLists.RawListHandlers) > 0 then |
| 350 |
|
begin |
| 351 |
< |
for i := 0 to High(RawListHandlers) do |
| 351 |
> |
for i := 0 to High(RawLists.RawListHandlers) do |
| 352 |
|
if Length(exts) > 0 then |
| 353 |
< |
exts := exts + ',' + RawListHandlers[i].Ext |
| 353 |
> |
exts := exts + ',' + RawLists.RawListHandlers[i].Ext |
| 354 |
|
else |
| 355 |
< |
exts := RawListHandlers[i].Ext; |
| 355 |
> |
exts := RawLists.RawListHandlers[i].Ext; |
| 356 |
|
end; |
| 357 |
|
Self.AllowedExts := exts; |
| 358 |
|
|
| 387 |
|
function TForm_RawEdit.Save: Boolean; |
| 388 |
|
var |
| 389 |
|
mem: TMemoryStream; |
| 406 |
– |
Data: Tdata; |
| 390 |
|
i: LongWord; |
| 391 |
|
begin |
| 392 |
|
case MessageBox(Self.Handle, PChar('Save changes to .raw-part of file ' + |
| 393 |
< |
Connection.GetFileInfo(fileid).FileName + '?'), PChar('Data changed...'), |
| 393 |
> |
ConManager.Connection[ConID].GetFileInfo(fileid).Name + '?'), PChar('Data changed...'), |
| 394 |
|
MB_YESNOCANCEL) of |
| 395 |
|
idYes: |
| 396 |
|
begin |
| 397 |
|
mem := TMemoryStream.Create; |
| 398 |
|
hex.SaveToStream(mem); |
| 399 |
|
mem.Seek(0, soFromBeginning); |
| 400 |
< |
SetLength(Data, mem.Size); |
| 418 |
< |
mem.Read(Data[0], mem.Size); |
| 400 |
> |
ConManager.Connection[ConID].UpdateRawFile(fileid, datoffset, mem); |
| 401 |
|
mem.Free; |
| 420 |
– |
Connection.UpdateRawFile(fileid_opened, dat_offset_opened, |
| 421 |
– |
Length(Data), @Data[0]); |
| 402 |
|
hex.Modified := False; |
| 403 |
|
for i := 0 to hex.Datasize - 1 do |
| 404 |
|
hex.ByteChanged[i] := False; |
| 407 |
|
idNo: |
| 408 |
|
Result := True; |
| 409 |
|
idCancel: |
| 430 |
– |
begin |
| 410 |
|
Result := False; |
| 432 |
– |
end; |
| 411 |
|
end; |
| 412 |
|
end; |
| 413 |
|
|
| 417 |
|
procedure TForm_RawEdit.FormCloseQuery(Sender: TObject; var CanClose: Boolean); |
| 418 |
|
begin |
| 419 |
|
if hex.Modified then |
| 442 |
– |
begin |
| 420 |
|
if not Save then |
| 421 |
|
CanClose := False; |
| 445 |
– |
end; |
| 422 |
|
end; |
| 423 |
|
|
| 424 |
|
|
| 504 |
|
var |
| 505 |
|
fs: TFileStream; |
| 506 |
|
begin |
| 507 |
< |
saved.Filter := 'Files of matching extension (*.' + Connection.GetFileInfo( |
| 508 |
< |
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 + |
| 510 |
|
'|All files|*.*'; |
| 511 |
< |
saved.DefaultExt := Connection.GetFileInfo(fileid).Extension; |
| 511 |
> |
saved.DefaultExt := ConManager.Connection[ConID].GetFileInfo(fileid).Extension; |
| 512 |
|
if saved.Execute then |
| 513 |
|
begin |
| 514 |
|
fs := TFileStream.Create(saved.FileName, fmCreate); |
| 524 |
|
var |
| 525 |
|
// Data: Tdata; |
| 526 |
|
fs: TFileStream; |
| 527 |
+ |
data: TByteData; |
| 528 |
+ |
i: Integer; |
| 529 |
+ |
rawinfo: TRawDataInfo; |
| 530 |
|
begin |
| 531 |
< |
opend.Filter := 'Files of matching extension (*.' + Connection.GetFileInfo( |
| 532 |
< |
fileid).Extension + ')|*.' + Connection.GetFileInfo(fileid).Extension + |
| 531 |
> |
opend.Filter := 'Files of matching extension (*.' + |
| 532 |
> |
ConManager.Connection[ConID].GetFileInfo(fileid).Extension + ')|*.' + |
| 533 |
> |
ConManager.Connection[ConID].GetFileInfo(fileid).Extension + |
| 534 |
|
'|All files|*.*'; |
| 535 |
|
if opend.Execute then |
| 536 |
|
begin |
| 537 |
|
fs := TFileStream.Create(opend.FileName, fmOpenRead); |
| 538 |
|
if fs.Size <> hex.DataSize then |
| 539 |
|
begin |
| 540 |
< |
ShowMessage('Can''t import ' + ExtractFilename(opend.FileName) + |
| 541 |
< |
', file has to have same size as file in .dat.' + CrLf + |
| 542 |
< |
'Size of file in .dat: ' + FormatFileSize(hex.datasize) + CrLf + |
| 543 |
< |
'Size of chosen file: ' + FormatFileSize(fs.Size)); |
| 544 |
< |
end |
| 545 |
< |
else |
| 546 |
< |
begin |
| 547 |
< |
hex.LoadFromStream(fs); |
| 548 |
< |
hex.Modified := True; |
| 549 |
< |
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; |
| 574 |
|
fs.Free; |
| 575 |
|
end; |
| 576 |
|
end; |
| 695 |
|
|
| 696 |
|
procedure TForm_RawEdit.SetNewValue(datatype: Word; offset: LongWord; Value: String); |
| 697 |
|
var |
| 698 |
< |
Data: Tdata; |
| 698 |
> |
Data: TByteData; |
| 699 |
|
value_int: LongWord; |
| 700 |
|
value_float: Single; |
| 701 |
|
i: Word; |