diff --git a/tim2view.lpi b/tim2view.lpi index 1b3013d..de0a553 100644 --- a/tim2view.lpi +++ b/tim2view.lpi @@ -24,7 +24,7 @@ - + @@ -365,6 +365,7 @@ + diff --git a/tim2view.lps b/tim2view.lps index ab06667..e88720b 100644 --- a/tim2view.lps +++ b/tim2view.lps @@ -23,8 +23,8 @@ - - + + @@ -48,9 +48,10 @@ + - + @@ -83,8 +84,8 @@ - - + + @@ -94,7 +95,7 @@ - + @@ -105,8 +106,8 @@ - - + + @@ -144,11 +145,10 @@ - - + @@ -160,7 +160,7 @@ - + @@ -169,7 +169,7 @@ - + @@ -184,13 +184,6 @@ - - - - - - - diff --git a/tim2view.res b/tim2view.res index e5974d3..38d297e 100644 Binary files a/tim2view.res and b/tim2view.res differ diff --git a/todos.inc b/todos.inc index 8231534..2bb9cb2 100644 --- a/todos.inc +++ b/todos.inc @@ -1,3 +1 @@ -{ TODO : Zooming? } -{ TODO : Add file to filelist } -{ TODO : StartScan - remove refs to umain } \ No newline at end of file +{ TODO : Zooming? } \ No newline at end of file diff --git a/umain.lfm b/umain.lfm index 9f1bb67..b146469 100644 --- a/umain.lfm +++ b/umain.lfm @@ -1,7 +1,7 @@ object frmMain: TfrmMain - Left = 919 - Height = 647 - Top = 209 + Left = 1092 + Height = 668 + Top = 213 Width = 790 HorzScrollBar.Page = 780 HorzScrollBar.Range = 489 @@ -9,7 +9,7 @@ object frmMain: TfrmMain VertScrollBar.Range = 344 ActiveControl = pnlList AllowDropFiles = True - ClientHeight = 622 + ClientHeight = 643 ClientWidth = 790 Color = clBtnFace Font.Color = clWindowText @@ -498,7 +498,7 @@ object frmMain: TfrmMain object pnlStatus: TPanel Left = 0 Height = 30 - Top = 571 + Top = 613 Width = 790 Align = alBottom BevelOuter = bvLowered @@ -552,33 +552,33 @@ object frmMain: TfrmMain end object pnlMain: TPanel Left = 0 - Height = 543 + Height = 585 Top = 28 Width = 790 Align = alClient BevelOuter = bvNone - ClientHeight = 543 + ClientHeight = 585 ClientWidth = 790 TabOrder = 1 object splMain: TSplitter Left = 253 - Height = 543 + Height = 585 Top = 0 Width = 5 end object pnlList: TPanel Left = 0 - Height = 543 + Height = 585 Top = 0 Width = 253 Align = alLeft BevelOuter = bvNone - ClientHeight = 543 + ClientHeight = 585 ClientWidth = 253 TabOrder = 0 object lvList: TListView Left = 0 - Height = 515 + Height = 372 Top = 28 Width = 253 Align = alClient @@ -648,15 +648,72 @@ object frmMain: TfrmMain TabOrder = 1 end end + object tblTimInfo: TStringGrid + Left = 0 + Height = 185 + Top = 400 + Width = 253 + Align = alBottom + AutoEdit = False + AutoFillColumns = True + ColCount = 2 + DefaultRowHeight = 20 + Enabled = False + Flat = True + Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goSmoothScroll] + RowCount = 9 + TabOrder = 2 + TitleFont.Color = clWindowText + TitleFont.Height = -11 + TitleFont.Name = 'Tahoma' + Visible = False + ColWidths = ( + 102 + 150 + ) + Cells = ( + 10 + 0 + 0 + 'Field' + 0 + 1 + 'Position' + 0 + 2 + 'Version' + 0 + 3 + 'Good' + 0 + 5 + 'VRAM (X/Y)' + 0 + 6 + 'Colors Count' + 0 + 8 + 'VRAM (X/Y)' + 1 + 0 + 'Value' + 1 + 4 + 'CLUT' + 1 + 7 + 'IMAGE' + ) + end end object pnlImage: TPanel Left = 258 - Height = 543 + Height = 585 Top = 0 Width = 532 Align = alClient BevelOuter = bvLowered - ClientHeight = 543 + ClientHeight = 585 ClientWidth = 532 Color = clBtnFace ParentColor = False @@ -664,7 +721,7 @@ object frmMain: TfrmMain object pnlImageOptions: TPanel Left = 1 Height = 32 - Top = 510 + Top = 552 Width = 530 Align = alBottom AutoSize = True @@ -746,12 +803,12 @@ object frmMain: TfrmMain end object pnlClut: TPanel Left = 1 - Height = 165 - Top = 345 + Height = 192 + Top = 360 Width = 530 Align = alBottom BevelOuter = bvLowered - ClientHeight = 165 + ClientHeight = 192 ClientWidth = 530 Color = clBtnFace ParentColor = False @@ -759,7 +816,7 @@ object frmMain: TfrmMain Visible = False object grdClut: TDrawGrid Left = 1 - Height = 115 + Height = 125 Top = 1 Width = 528 Align = alClient @@ -784,12 +841,12 @@ object frmMain: TfrmMain end object lblClutHint: TLabel Left = 1 - Height = 48 - Top = 116 + Height = 65 + Top = 126 Width = 528 Align = alBottom Alignment = taCenter - Caption = 'Press "Space" key to invert Transparence bit.'#13#10'H-splitted color = black transparent.'#13#10'V-splitted color = non-black transparent.' + Caption = 'Double-click to change color.'#10'Press "Space" key to invert Transparence bit.'#13#10'H-splitted color = black transparent.'#13#10'V-splitted color = non-black transparent.' Layout = tlCenter ParentColor = False WordWrap = True @@ -797,7 +854,7 @@ object frmMain: TfrmMain end object imgTim: TImage Left = 1 - Height = 344 + Height = 359 Top = 1 Width = 530 AntialiasingMode = amOff @@ -808,39 +865,6 @@ object frmMain: TfrmMain end end end - object sbMain: TStatusBar - Left = 0 - Height = 21 - Top = 601 - Width = 790 - Panels = < - item - Width = 50 - end - item - Width = 50 - end - item - Width = 50 - end - item - Width = 50 - end - item - Width = 50 - end - item - Width = 50 - end - item - Width = 50 - end - item - Width = 50 - end> - SimplePanel = False - SizeGrip = False - end object dlgOpenFile: TOpenDialog Title = 'Please, select File...' DefaultExt = '.bin' @@ -899,6 +923,11 @@ object frmMain: TfrmMain object N8: TMenuItem Caption = '-' end + object mnShowTimInfo: TMenuItem + Action = actShowTimInfo + AutoCheck = True + ShowAlwaysCheckable = True + end object mnStretchImage: TMenuItem Action = actStretch AutoCheck = True @@ -1063,6 +1092,11 @@ object frmMain: TfrmMain Caption = '&Background Color' OnExecute = actChangeBackColorExecute end + object actShowTimInfo: TAction + AutoCheck = True + Caption = '&Show Tim Info' + OnExecute = actShowTimInfoExecute + end end object pmList: TPopupMenu left = 432 diff --git a/umain.pas b/umain.pas index 4ad1b6b..d75c300 100644 --- a/umain.pas +++ b/umain.pas @@ -28,6 +28,7 @@ type actExtractTIMs: TAction; actChangeFile: TAction; actChangeBackColor: TAction; + actShowTimInfo: TAction; actPngImport: TAction; actStopScan: TAction; actOpenLab: TAction; @@ -58,6 +59,7 @@ type lblStatus: TLabel; lvList: TListView; MenuItem1: TMenuItem; + mnShowTimInfo: TMenuItem; mnImportPng: TMenuItem; mnChangeBackColor2: TMenuItem; N8: TMenuItem; @@ -104,7 +106,7 @@ type SaveasPNG1: TMenuItem; dlgSelectDir: TSelectDirectoryDialog; splMain: TSplitter; - sbMain: TStatusBar; + tblTimInfo: TStringGrid; procedure actAboutExecute(Sender: TObject); procedure actAssocTimsExecute(Sender: TObject); procedure actChangeBackColorExecute(Sender: TObject); @@ -123,6 +125,7 @@ type procedure actReturnFocusExecute(Sender: TObject); procedure actScanDirExecute(Sender: TObject); procedure actScanFileExecute(Sender: TObject); + procedure actShowTimInfoExecute(Sender: TObject); procedure actStopScanExecute(Sender: TObject); procedure actStretchExecute(Sender: TObject); procedure actPngExportExecute(Sender: TObject); @@ -164,6 +167,7 @@ type procedure ScanDirectory(const Directory: string); procedure CheckButtonsAndMainMenu; procedure ScanFinished(Sender: TObject); + procedure BeforeScan(MaxProgress: Integer); procedure SetTimsListCount(Count: Integer); procedure UpdateCLUTInfo; procedure DrawSelTim; @@ -212,6 +216,12 @@ begin ScanPath(dlgOpenFile.Files.Strings[I - 1]); end; +procedure TfrmMain.actShowTimInfoExecute(Sender: TObject); +begin + Settings.InfoVisible := (Sender as TAction).Checked; + tblTimInfo.Visible := (Sender as TAction).Checked; +end; + procedure TfrmMain.actStopScanExecute(Sender: TObject); var I: Integer; @@ -232,7 +242,7 @@ end; procedure TfrmMain.actStretchExecute(Sender: TObject); begin - Settings.StretchMode := actStretch.Checked; + Settings.StretchMode := (Sender as TAction).Checked; UpdateTim(True, False, False); end; @@ -579,6 +589,7 @@ begin LastDir := Settings.LastDir; cbbBitMode.ItemIndex := Settings.BitMode; pnlImage.Color := Settings.BackColor; + actShowTimInfo.Checked := Settings.InfoVisible; ScanThreads := TScanThreadList.Create(False); //False - to able scan thread remove itself from this list ScanResults := TScanResultList.Create(False); @@ -810,6 +821,7 @@ begin if StartedScans < GetLogicalCpuCount then begin + BeforeScan(ScanThreads.Last.FileLength); ScanThreads.Last.Start; Inc(StartedScans); end; @@ -848,6 +860,10 @@ begin pnlList.Enabled := cbbFiles.Enabled; actCloseFile.Enabled := cbbFiles.Enabled; actCloseFiles.Enabled := cbbFiles.Enabled; + + actScanFile.Enabled := ScanThreads.Count = 0; + actScanDir.Enabled := ScanThreads.Count = 0; + actReplaceTim.Enabled := (lvList.Selected <> nil) and (lvList.Selected.Index <> -1); actPngExport.Enabled := (Surf^ <> nil) and actReplaceTim.Enabled; @@ -862,7 +878,6 @@ var I: Integer; begin ScanThreads.Remove(Sender as TScanThread); - Dec(StartedScans); if ScanThreads.Count <> 0 then @@ -870,6 +885,7 @@ begin for I := 1 to ScanThreads.Count do if ScanThreads[I - 1].Suspended and (not ScanThreads[I - 1].StopScan) then begin + BeforeScan(ScanThreads[I - 1].FileLength); ScanThreads[I - 1].Start; Inc(StartedScans); Exit; @@ -877,7 +893,7 @@ begin Exit; end; - if ScanResults.Count <> 0 then SetTimsListCount(ScanResults.Last.Count); + if ScanThreads.Count <> 0 then SetTimsListCount(ScanResults.Last.Count); CheckButtonsAndMainMenu; @@ -891,6 +907,18 @@ begin actStopScan.Tag := NativeInt(True); end; +procedure TfrmMain.BeforeScan(MaxProgress: Integer); +begin + cbbFiles.Enabled := False; + pnlList.Enabled := False; + + actScanFile.Enabled := False; + actScanDir.Enabled := False; + + pbProgress.Max := MaxProgress; + pbProgress.Position := 0; +end; + procedure TfrmMain.SetTimsListCount(Count: Integer); begin lvList.Items.BeginUpdate; @@ -1004,43 +1032,33 @@ end; procedure TfrmMain.ShowTimInfo(ShowInfo: Boolean); var - I: Integer; TIM: PTIM; TimInfo: TTimInfo; begin - for I := 1 to sbMain.Panels.Count do - sbMain.Panels[I - 1].Text := ''; + tblTimInfo.Cells[1, 1] := ''; + tblTimInfo.Cells[1, 2] := ''; + tblTimInfo.Cells[1, 3] := ''; + tblTimInfo.Cells[1, 5] := ''; + tblTimInfo.Cells[1, 6] := ''; + tblTimInfo.Cells[1, 8] := ''; if not ShowInfo then Exit; TimInfo := SelectedTimInfo; TIM := SelectedTimInMode; - I := 0; + tblTimInfo.Cells[1, 1] := Format('0x%x', [TimInfo.Position]); - sbMain.Panels[I].Text := Format('Pos: 0x%x', [TimInfo.Position]); - sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I); - sbMain.Panels[I].Text := Format('Ver: %d', [GetTimVersion(TIM)]); - sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I); - sbMain.Panels[I].Text := Format('Good: %s', [TIMIsGoodStr(TIM)]); - sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I); + tblTimInfo.Cells[1, 2] := Format('%d', [GetTimVersion(TIM)]); + tblTimInfo.Cells[1, 3] := Format('%s', [TIMIsGoodStr(TIM)]); if TIMHasCLUT(TIM) then begin - sbMain.Panels[I].Alignment := taRightJustify; - sbMain.Panels[I].Text := 'CLUT:'; - sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 20; Inc(I); - sbMain.Panels[I].Text := Format('X/Y: %dx%d', [GetTimClutVRAMX(TIM), GetTimClutVRAMY(TIM)]); - sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I); - sbMain.Panels[I].Text := Format('Colors: %d', [GetTimColorsCount(TIM)]); - sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I); + tblTimInfo.Cells[1, 5] := Format('%dx%d', [GetTimClutVRAMX(TIM), GetTimClutVRAMY(TIM)]); + tblTimInfo.Cells[1, 6] := Format('%d', [GetTimColorsCount(TIM)]); end; - sbMain.Panels[I].Alignment := taRightJustify; - sbMain.Panels[I].Text := 'IMAGE:'; - sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 20; Inc(I); - sbMain.Panels[I].Text := Format('X/Y: %dx%d', [GetTimImageVRAMX(TIM), GetTimImageVRAMY(TIM)]); - sbMain.Panels[I].Width := Canvas.GetTextWidth(sbMain.Panels[I].Text) + 8; Inc(I); + tblTimInfo.Cells[1, 8] := Format('%dx%d', [GetTimImageVRAMX(TIM), GetTimImageVRAMY(TIM)]); FreeTIM(TIM); end; diff --git a/uscanthread.pas b/uscanthread.pas index d346b3c..71e83fc 100644 --- a/uscanthread.pas +++ b/uscanthread.pas @@ -20,7 +20,6 @@ type pSrcFileStream: TFileStream; pStopScan: boolean; procedure SetStatusText; - procedure StartScan; procedure FinishScan; procedure UpdateProgressBar; procedure AddResult(TIM: PTIM); @@ -31,6 +30,7 @@ type constructor Create(const FileToScan: string; ImageScan: boolean; Results: PScanResultList); //property Started: boolean read pStarted write pStarted; property StopScan: boolean read pStopScan write pStopScan; + property FileLength: Integer read pFileSize; end; TScanThreadList = specialize TFPGObjectList; @@ -89,8 +89,6 @@ var pScanFinished: boolean; pRealBufSize, pTimPosition, pTIMNumber: Integer; begin - Synchronize(@StartScan); - if pScanResult.IsImage then pSectorBufferSize := cSectorBufferSize else @@ -187,7 +185,10 @@ begin end; if not CheckForFileOpened(pResults, pScanResult.ScanFile) then - pResults^.Add(pScanResult) + begin + pResults^.Add(pScanResult); + frmMain.cbbFiles.Items.Add(pScanResult.ScanFile); + end else pScanResult.Free; end; @@ -197,15 +198,6 @@ begin frmMain.lblStatus.Caption := pStatusText; end; -procedure TScanThread.StartScan; -begin - frmMain.cbbFiles.Enabled := False; - frmMain.pnlList.Enabled := False; - - frmMain.pbProgress.Max := FileSize(pScanResult.ScanFile); - frmMain.pbProgress.Position := 0; -end; - procedure TScanThread.UpdateProgressBar; begin frmMain.pbProgress.Position := pFilePos; diff --git a/usettings.pas b/usettings.pas index b63dcb7..dcf2f95 100644 --- a/usettings.pas +++ b/usettings.pas @@ -24,6 +24,8 @@ type function FBackColorRead(): TColor; procedure FBitModeWrite(Mode: Integer); function FBitModeRead(): Integer; + procedure FInfoVisibleWrite(Value: Boolean); + function FInfoVisibleRead(): Boolean; public constructor Create(const DirPath: string); destructor Destroy; override; @@ -32,6 +34,7 @@ type property LastDir: string read FLastDirRead write FLastDirWrite; property BackColor: TColor read FBackColorRead write FBackColorWrite; property BitMode: Integer read FBitModeRead write FBitModeWrite; + property InfoVisible: Boolean read FInfoVisibleRead write FInfoVisibleWrite; end; implementation @@ -92,6 +95,16 @@ begin Result := FIniFile.ReadInteger(sMain, 'BitMode', 0); end; +procedure TSettings.FInfoVisibleWrite(Value: Boolean); +begin + FIniFile.WriteBool(sMain, 'InfoVisible', Value); +end; + +function TSettings.FInfoVisibleRead: Boolean; +begin + Result := FIniFile.ReadBool(sMain, 'InfoVisible', False); +end; + constructor TSettings.Create(const DirPath: string); begin inherited Create; @@ -107,4 +120,4 @@ begin end; end. - + \ No newline at end of file