Changeset 62 for trunk/Forms


Ignore:
Timestamp:
Nov 25, 2020, 4:25:09 PM (4 years ago)
Author:
chronos
Message:
  • Added: Main game menu.
Location:
trunk/Forms
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.lfm

    r61 r62  
    3535    Top = 21
    3636  end
     37  object Translator1: TTranslator
     38    POFilesFolder = 'Languages'
     39    Left = 496
     40    Top = 358
     41  end
     42  object ApplicationInfo1: TApplicationInfo
     43    Identification = 1
     44    VersionMajor = 1
     45    VersionMinor = 1
     46    VersionBugFix = 0
     47    HomePage = 'https://app.zdechov.net/BigMetro'
     48    AuthorsName = 'Chronosoft'
     49    EmailContact = 'robie@centrum.cz'
     50    AppName = 'Big Metro'
     51    Description = 'Enjoyable real-time metro building game.'
     52    ReleaseDate = 44160
     53    RegistryKey = '\Software\Chronosoft\BigMetro'
     54    RegistryRoot = rrKeyCurrentUser
     55    License = 'CC0'
     56    Left = 484
     57    Top = 460
     58  end
    3759end
  • trunk/Forms/UFormMain.pas

    r51 r62  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
    9   ExtCtrls, UEngine, LCLType, types;
     9  ExtCtrls, UEngine, LCLType, types, UTranslator, UApplicationInfo, URegistry;
    1010
    1111type
     
    1414
    1515  TFormMain = class(TForm)
     16    ApplicationInfo1: TApplicationInfo;
    1617    PaintBox1: TPaintBox;
    1718    Timer1: TTimer;
     19    Translator1: TTranslator;
    1820    procedure FormCreate(Sender: TObject);
    1921    procedure FormDestroy(Sender: TObject);
     
    3335    procedure PaintBox1Resize(Sender: TObject);
    3436    procedure Timer1Timer(Sender: TObject);
     37  private
     38    procedure LoadConfig;
     39    procedure SaveConfig;
    3540  public
    3641    Engine: TEngine;
     
    5257procedure TFormMain.FormCreate(Sender: TObject);
    5358begin
     59  LoadConfig;
    5460  Engine := TEngine.Create;
    5561  //PaintBox1.ControlStyle := [csOpaque];
     62  Randomize;
    5663end;
    5764
     
    5966begin
    6067  Engine.Free;
     68  SaveConfig;
    6169end;
    6270
     
    7684  Engine.Map.Size := Point(PaintBox1.Width, PaintBox1.Height);
    7785  Engine.View.DestRect := Rect(0, 0, PaintBox1.Width, PaintBox1.Height);
    78   Engine.Reset;
     86  Engine.MainMenu;
    7987end;
    8088
     
    132140end;
    133141
     142procedure TFormMain.LoadConfig;
     143var
     144  LangCode: string;
     145begin
     146  with TRegistryEx.Create do
     147  try
     148    CurrentContext := ApplicationInfo1.GetRegistryContext;
     149
     150    if ValueExists('LanguageCode') then begin
     151      LangCode := ReadStringWithDefault('LanguageCode', '');
     152      Translator1.Language := Translator1.Languages.SearchByCode(LangCode);
     153    end else Translator1.Language := Translator1.Languages.SearchByCode('');
     154    //ThemeManager1.Theme := ThemeManager1.Themes.FindByName(ReadStringWithDefault('Theme', 'System'));
     155  finally
     156    Free;
     157  end;
     158end;
     159
     160procedure TFormMain.SaveConfig;
     161begin
     162  with TRegistryEx.Create do
     163  try
     164    CurrentContext := ApplicationInfo1.GetRegistryContext;
     165
     166    if Assigned(Translator1.Language) and (Translator1.Language.Code <> '') then
     167      WriteString('LanguageCode', Translator1.Language.Code)
     168      else DeleteValue('LanguageCode');
     169    //WriteString('Theme', ThemeManager1.Theme.Name);
     170  finally
     171    Free;
     172  end;
     173end;
     174
     175
    134176end.
    135177
Note: See TracChangeset for help on using the changeset viewer.