Changeset 50 for trunk


Ignore:
Timestamp:
Nov 3, 2019, 12:18:14 PM (5 years ago)
Author:
chronos
Message:
  • Added: Support for dark theme.
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormComputer.pas

    r38 r50  
    217217begin
    218218  Core.Translator1.TranslateComponentRecursive(Self);
     219  Core.ThemeManager1.UseTheme(Self);
    219220  GameTries1 := TGameTries.Create;
    220221  GameTries2 := TGameTries.Create;
  • trunk/Forms/UFormHelp.pas

    r29 r50  
    4545begin
    4646  Core.Translator1.TranslateComponentRecursive(Self);
     47  Core.ThemeManager1.UseTheme(Self);
    4748end;
    4849
  • trunk/Forms/UFormHistory.pas

    r36 r50  
    7878begin
    7979  Core.Translator1.TranslateComponentRecursive(Self);
     80  Core.ThemeManager1.UseTheme(Self);
    8081  Game := TGame.Create;
    8182end;
  • trunk/Forms/UFormMain.pas

    r46 r50  
    9898  Core.PersistentForm1.RegistryContext := Core.ApplicationInfo1.GetRegistryContext;
    9999  Core.PersistentForm1.Load(Self);
     100  Core.ThemeManager1.UseTheme(Self);
    100101  UpdateInterface;
    101102  if Core.Game.Board.GetEmptyTilesCount > Core.Game.Board.Size.X * Core.Game.Board.Size.Y -
  • trunk/Forms/UFormNew.pas

    r49 r50  
    4949begin
    5050  Core.Translator1.TranslateComponentRecursive(Self);
     51  Core.ThemeManager1.UseTheme(Self);
    5152  ComboBoxSkin.Items.Clear;
    5253  for I := Low(SkinText) to High(SkinText) do
  • trunk/Forms/UFormSettings.lfm

    r33 r50  
    1111  OnCreate = FormCreate
    1212  OnShow = FormShow
    13   LCLVersion = '2.0.2.0'
     13  LCLVersion = '2.0.4.0'
    1414  object Label1: TLabel
    1515    Left = 19
    16     Height = 26
     16    Height = 25
    1717    Top = 24
    18     Width = 172
     18    Width = 158
    1919    Caption = 'Animation duration:'
    2020    ParentColor = False
     
    5252  object ComboBoxLanguage: TComboBox
    5353    Left = 208
    54     Height = 42
     54    Height = 33
    5555    Top = 86
    5656    Width = 230
    57     ItemHeight = 0
     57    ItemHeight = 25
    5858    Style = csDropDownList
    5959    TabOrder = 3
     
    6161  object Label2: TLabel
    6262    Left = 19
    63     Height = 26
     63    Height = 25
    6464    Top = 94
    65     Width = 88
     65    Width = 81
    6666    Caption = 'Language:'
    6767    ParentColor = False
    6868  end
     69  object ComboBoxTheme: TComboBox
     70    Left = 208
     71    Height = 33
     72    Top = 136
     73    Width = 230
     74    ItemHeight = 25
     75    Style = csDropDownList
     76    TabOrder = 4
     77  end
     78  object Label3: TLabel
     79    Left = 19
     80    Height = 25
     81    Top = 144
     82    Width = 57
     83    Caption = 'Theme:'
     84    ParentColor = False
     85  end
    6986end
  • trunk/Forms/UFormSettings.lrj

    r19 r50  
    44{"hash":1339,"name":"tformsettings.buttonok.caption","sourcebytes":[79,75],"value":"OK"},
    55{"hash":77089212,"name":"tformsettings.buttoncancel.caption","sourcebytes":[67,97,110,99,101,108],"value":"Cancel"},
    6 {"hash":82521866,"name":"tformsettings.label2.caption","sourcebytes":[76,97,110,103,117,97,103,101,58],"value":"Language:"}
     6{"hash":82521866,"name":"tformsettings.label2.caption","sourcebytes":[76,97,110,103,117,97,103,101,58],"value":"Language:"},
     7{"hash":95339402,"name":"tformsettings.label3.caption","sourcebytes":[84,104,101,109,101,58],"value":"Theme:"}
    78]}
  • trunk/Forms/UFormSettings.pas

    r36 r50  
    77uses
    88  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls,
    9   ULanguages;
     9  ULanguages, UTheme;
    1010
    1111type
     
    1717    ButtonCancel: TButton;
    1818    ComboBoxLanguage: TComboBox;
     19    ComboBoxTheme: TComboBox;
    1920    Label1: TLabel;
    2021    Label2: TLabel;
     22    Label3: TLabel;
    2123    TrackBar1: TTrackBar;
    2224    procedure ButtonCancelClick(Sender: TObject);
     
    6264    Core.Translator1.Language := TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex]);
    6365  end;
     66  if ComboBoxTheme.ItemIndex <> -1 then
     67    Core.ThemeManager1.Theme := TTheme(ComboBoxTheme.Items.Objects[ComboBoxTheme.ItemIndex]);
    6468  ModalResult := mrOk;
    6569end;
     
    7579  Core.Translator1.TranslateComponentRecursive(Self);
    7680  Core.Translator1.LanguageListToStrings(ComboBoxLanguage.Items);
     81  Core.ThemeManager1.UseTheme(Self);
     82  Core.ThemeManager1.Themes.LoadToStrings(ComboBoxTheme.Items);
    7783end;
    7884
     
    8389  ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Core.Translator1.Language);
    8490  if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
     91  ComboBoxTheme.ItemIndex := ComboBoxTheme.Items.IndexOfObject(Core.ThemeManager1.Theme);
     92  if ComboBoxTheme.ItemIndex = -1 then ComboBoxTheme.ItemIndex := 0;
    8593end;
    8694
  • trunk/Languages/Game2048.cs.po

    r49 r50  
    170170msgstr "Jazyk:"
    171171
     172#: tformsettings.label3.caption
     173msgid "Theme:"
     174msgstr "Téma:"
     175
    172176#: ucore.sgameovercaption
    173177msgctxt "ucore.sgameovercaption"
  • trunk/Languages/Game2048.po

    r49 r50  
    160160msgstr ""
    161161
     162#: tformsettings.label3.caption
     163msgid "Theme:"
     164msgstr ""
     165
    162166#: ucore.sgameovercaption
    163167msgctxt "ucore.sgameovercaption"
  • trunk/UCore.lfm

    r49 r50  
    3737  object Translator1: TTranslator
    3838    POFilesFolder = 'Languages'
    39     OnTranslate = Translator1Translate
    4039    left = 336
    4140    top = 295
  • trunk/UCore.pas

    r49 r50  
    9090  try
    9191    if FormSettings.ShowModal = mrOk then begin
     92      FormMain.Redraw;
    9293      FormMain.UpdateInterface;
    9394      UpdateInterface;
     
    214215      Translator1.Language := Translator1.Languages.SearchByCode(ReadStringWithDefault('LanguageCode', ''))
    215216      else Translator1.Language := Translator1.Languages.SearchByCode('');
     217    ThemeManager1.Theme := ThemeManager1.Themes.FindByName(ReadStringWithDefault('Theme', 'System'));
    216218  finally
    217219    Free;
     
    229231      WriteString('LanguageCode', Translator1.Language.Code)
    230232      else DeleteValue('LanguageCode');
     233    WriteString('Theme', ThemeManager1.Theme.Name);
    231234  finally
    232235    Free;
  • trunk/UGame.pas

    r49 r50  
    130130    UndoEnabled: Boolean;
    131131    History: THistory;
     132    BackgroundColor: TColor;
    132133    function CanUndo: Boolean;
    133134    procedure Undo;
     
    182183implementation
    183184
     185uses
     186  UCore;
     187
    184188procedure Translate;
    185189begin
     
    593597  TileMargin := Round(CanvasSize.X / Board.Size.X * 0.015);
    594598  Canvas.Brush.Style := bsSolid;
    595   Canvas.Brush.Color := clBlack;
     599  Canvas.Brush.Color := Core.ThemeManager1.Theme.ColorControl;
    596600  Canvas.FillRect(0, 0, Canvas.Width, Canvas.Height);
    597601
    598602  ValueStr := SScore + ': ' + IntToStr(Score);
    599   Canvas.Font.Color := clWhite;
     603  Canvas.Font.Color := Core.ThemeManager1.Theme.ColorControlText;
    600604  Canvas.Font.Height := Trunc(TopBarHeight * 0.7);
    601605  Canvas.TextOut(ScaleY(16, 96), (TopBarHeight - Canvas.TextHeight(ValueStr)) div 2, ValueStr);
    602606
    603607  ValueStr := STopScore + ': ' + IntToStr(TopScore);
    604   Canvas.Font.Color := clWhite;
     608  Canvas.Font.Color := Core.ThemeManager1.Theme.ColorControlText;
    605609  Canvas.Font.Height := Trunc(TopBarHeight * 0.7);
    606610  Canvas.TextOut(ScaleY(136, 96), (TopBarHeight - Canvas.TextHeight(ValueStr)) div 2, ValueStr);
     
    10301034function TGame.GetTileColor(Value: Integer): TColor;
    10311035begin
    1032   case Value of
    1033     0: Result := $f2f6f9;
    1034     1: Result := $dae4ee;
    1035     2: Result := $c8e0ed;
    1036     3: Result := $79b1f2;
    1037     4: Result := $6395f5;
    1038     5: Result := $5f7cf6;
    1039     6: Result := $3b5ef6;
    1040     7: Result := $72cfed;
    1041     8: Result := $61cced;
    1042     9: Result := $50c8ed;
    1043     10: Result := $3fc5ed;
    1044     11: Result := $2ec2ed;
    1045     else Result := $323a3c;
     1036  if Core.ThemeManager1.Theme.Name = 'Dark' then begin
     1037    case Value of
     1038      0: Result := $222629;
     1039      1: Result := $dae4ee;
     1040      2: Result := $c8e0ed;
     1041      3: Result := $79b1f2;
     1042      4: Result := $6395f5;
     1043      5: Result := $5f7cf6;
     1044      6: Result := $3b5ef6;
     1045      7: Result := $72cfed;
     1046      8: Result := $61cced;
     1047      9: Result := $50c8ed;
     1048      10: Result := $3fc5ed;
     1049      11: Result := $2ec2ed;
     1050      else Result := $323a3c;
     1051    end;
     1052  end else begin
     1053    case Value of
     1054      0: Result := $f2f6f9;
     1055      1: Result := $dae4ee;
     1056      2: Result := $c8e0ed;
     1057      3: Result := $79b1f2;
     1058      4: Result := $6395f5;
     1059      5: Result := $5f7cf6;
     1060      6: Result := $3b5ef6;
     1061      7: Result := $72cfed;
     1062      8: Result := $61cced;
     1063      9: Result := $50c8ed;
     1064      10: Result := $3fc5ed;
     1065      11: Result := $2ec2ed;
     1066      else Result := $323a3c;
     1067    end;
    10461068  end;
    10471069end;
Note: See TracChangeset for help on using the changeset viewer.