Changeset 86 for trunk/Core.pas


Ignore:
Timestamp:
Jun 7, 2024, 12:47:11 PM (5 months ago)
Author:
chronos
Message:
  • Modified: Remove U prefix from unit names.
  • Modified: Used TFormEx for all forms for code simplification.
  • Fixed: Fullscreen mode switching error.
File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Core.pas

    r85 r86  
    1 unit UCore;
    2 
    3 {$mode delphi}
     1unit Core;
    42
    53interface
     
    75uses
    86  Classes, SysUtils, Theme, PersistentForm, ApplicationInfo, Translator,
    9   RegistryEx, UGame, ActnList, Forms, Controls, Dialogs;
     7  RegistryEx, ScaleDPI, Game, ActnList, Forms, Controls, Dialogs;
    108
    119type
     
    2523    ApplicationInfo1: TApplicationInfo;
    2624    PersistentForm1: TPersistentForm;
     25    ScaleDPI1: TScaleDPI;
    2726    ThemeManager1: TThemeManager;
    2827    Translator1: TTranslator;
     
    6160
    6261uses
    63   UFormMain, UFormSettings, UFormNew, UFormHelp, UFormComputer, FormAbout,
    64   UFormHistory;
     62  FormMain, FormSettings, FormNew, FormHelp, FormComputer, FormAbout, FormEx,
     63  FormHistory;
    6564
    6665resourcestring
     
    6968  SWinCaption = 'Win';
    7069  SWinMessage = 'You reached %s and won! You can continue to play to get higher score.';
     70
     71procedure Translate;
     72begin
     73  Game.Translate;
     74end;
    7175
    7276{ TCore }
     
    9094  Game.OnGameOver := GameOver;
    9195  LoadConfig;
     96
     97  TFormEx.ScaleDPI := ScaleDPI1;
     98  TFormEx.Translator := Translator1;
     99  TFormEx.ThemeManager := ThemeManager1;
     100  TFormEx.PersistentForm := PersistentForm1;
    92101end;
    93102
    94103procedure TCore.ASettingsExecute(Sender: TObject);
     104var
     105  FormSettings: TFormSettings;
    95106begin
    96107  FormSettings := TFormSettings.Create(nil);
    97108  try
    98109    if FormSettings.ShowModal = mrOk then begin
    99       FormMain.Redraw;
    100       FormMain.UpdateInterface;
     110      FormMain.FormMain.Redraw;
     111      FormMain.FormMain.UpdateInterface;
    101112      UpdateInterface;
    102113    end;
     
    125136
    126137procedure TCore.AComputerExecute(Sender: TObject);
     138var
     139  FormComputer: TFormComputer;
    127140begin
    128141  FormComputer := TFormComputer.Create(nil);
     
    136149procedure TCore.AExitExecute(Sender: TObject);
    137150begin
    138   FormMain.Close;
     151  FormMain.FormMain.Close;
    139152end;
    140153
    141154procedure TCore.AHelpExecute(Sender: TObject);
     155var
     156  FormHelp: TFormHelp;
    142157begin
    143158  FormHelp := TFormHelp.Create(nil);
     
    150165
    151166procedure TCore.AHistoryExecute(Sender: TObject);
     167var
     168  FormHistory: TFormHistory;
    152169begin
    153170  FormHistory := TFormHistory.Create(nil);
     
    160177
    161178procedure TCore.ANewExecute(Sender: TObject);
     179var
     180  FormNew: TFormNew;
    162181begin
    163182  FormNew := TFormNew.Create(nil);
     
    168187      Game.New;
    169188      UpdateInterface;
    170       FormMain.UpdateInterface;
     189      FormMain.FormMain.UpdateInterface;
    171190    end;
    172191  finally
     
    183202procedure TCore.Translator1Translate(Sender: TObject);
    184203begin
    185   UGame.Translate;
     204  Translate;
    186205end;
    187206
     
    193212procedure TCore.GamePaint(Sender: TObject);
    194213begin
    195   if Assigned(FormMain) then FormMain.Redraw;
     214  if Assigned(FormMain.FormMain) then FormMain.FormMain.Redraw;
    196215end;
    197216
    198217procedure TCore.GameWin(Sender: TObject);
    199218begin
    200   TThread.Synchronize(FormMain.MoveThread, GameWinSync);
     219  TThread.Synchronize(FormMain.FormMain.MoveThread, GameWinSync);
    201220end;
    202221
     
    208227procedure TCore.GameOver(Sender: TObject);
    209228begin
    210   TThread.Synchronize(FormMain.MoveThread, GameOverSync);
     229  TThread.Synchronize(FormMain.FormMain.MoveThread, GameOverSync);
    211230end;
    212231
Note: See TracChangeset for help on using the changeset viewer.