Ignore:
Timestamp:
Aug 22, 2019, 9:50:21 AM (5 years ago)
Author:
chronos
Message:
  • Modified: Use TPaintBox for drawing.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/paintbox/Forms/UMainForm.pas

    r47 r49  
    2323    AFullScreen: TAction;
    2424    ActionList1: TActionList;
    25     Image1: TImage;
    2625    MainMenu1: TMainMenu;
    2726    MenuItem1: TMenuItem;
     
    3332    MenuItem7: TMenuItem;
    3433    MenuItem8: TMenuItem;
     34    PaintBox1: TPaintBox;
    3535    StatusBar1: TStatusBar;
    3636    TimerDraw: TTimer;
     
    5050    procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    5151    procedure FormShow(Sender: TObject);
    52     procedure Image1MouseLeave(Sender: TObject);
    53     procedure Image1Resize(Sender: TObject);
     52    procedure PaintBox1Paint(Sender: TObject);
     53    procedure PaintBox1Resize(Sender: TObject);
    5454    procedure TimerDrawTimer(Sender: TObject);
    5555    procedure TimerEngineTickTimer(Sender: TObject);
     
    6262    procedure LoadConfig;
    6363    procedure SaveConfig;
     64    procedure EngineRepaint(Sender: TObject);
    6465  public
    6566    PersistentForm: TPersistentForm;
     
    125126end;
    126127
     128procedure TMainForm.EngineRepaint(Sender: TObject);
     129begin
     130  PaintBox1.Repaint;
     131end;
     132
    127133procedure TMainForm.EraseBackground(DC: HDC);
    128134begin
     
    142148  DoubleBuffered := False;
    143149  Engine := TEngine.Create;
    144   Engine.Bitmap := Image1.Picture.Bitmap;
     150  Engine.OnRepaint := EngineRepaint;
    145151  Core.CoolTranslator1.Language := Core.CoolTranslator1.Languages.SearchByCode('cs');
    146152  LoadConfig;
    147153  Engine.NewGame;
    148154  Engine.Active := True;
    149   Image1Resize(Self);
    150   Image1.ControlStyle := Image1.ControlStyle + [csOpaque];
     155  PaintBox1Resize(Self);
     156  ControlStyle := ControlStyle + [csOpaque];
     157  PaintBox1.ControlStyle := PaintBox1.ControlStyle + [csOpaque];
    151158end;
    152159
     
    205212procedure TMainForm.AShowRawImageDescExecute(Sender: TObject);
    206213begin
    207   ShowMessage(Image1.Picture.Bitmap.RawImage.Description.AsString);
     214  ShowMessage(Engine.Bitmap.RawImage.Description.AsString);
    208215end;
    209216
     
    244251end;
    245252
    246 procedure TMainForm.Image1MouseLeave(Sender: TObject);
    247 begin
    248 
    249 end;
    250 
    251 procedure TMainForm.Image1Resize(Sender: TObject);
     253procedure TMainForm.PaintBox1Paint(Sender: TObject);
     254begin
     255  PaintBox1.Canvas.StretchDraw(Rect(0, 0, PaintBox1.Width, PaintBox1.Height), Engine.Bitmap);
     256end;
     257
     258procedure TMainForm.PaintBox1Resize(Sender: TObject);
    252259begin
    253260  try
    254261    Engine.Lock.Acquire;
    255     Image1.Picture.Bitmap.SetSize(Image1.Width, Image1.Height);
     262    Engine.Bitmap.SetSize(PaintBox1.Width, PaintBox1.Height);
    256263    Engine.ResizePlayerFrames;
    257264  finally
Note: See TracChangeset for help on using the changeset viewer.