Changeset 51


Ignore:
Timestamp:
Nov 3, 2019, 6:20:02 PM (5 years ago)
Author:
chronos
Message:
  • Added: New tile skip alpha for alpha letters.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Languages/Game2048.cs.po

    r50 r51  
    191191#: ucore.swinmessage
    192192msgctxt "ucore.swinmessage"
    193 msgid "You reached %d and won! You can continue to play to get higher score."
    194 msgstr "Dosáhl jsi %d a vyhrál! Můžeš pokračovat ve hře k dosažení vyššího skóre."
     193msgid "You reached %s and won! You can continue to play to get higher score."
     194msgstr "Dosáhl jsi %s a vyhrál! Můžeš pokračovat ve hře k dosažení vyššího skóre."
    195195
    196196#: uformabout.slicense
     
    238238msgstr "Skóre"
    239239
     240#: ugame.sskinalpha
     241msgid "Alpha"
     242msgstr "Písmena"
     243
    240244#: ugame.sskinlinear
    241245msgid "Linear"
  • trunk/Languages/Game2048.po

    r50 r51  
    181181#: ucore.swinmessage
    182182msgctxt "ucore.swinmessage"
    183 msgid "You reached %d and won! You can continue to play to get higher score."
     183msgid "You reached %s and won! You can continue to play to get higher score."
    184184msgstr ""
    185185
     
    228228msgstr ""
    229229
     230#: ugame.sskinalpha
     231msgid "Alpha"
     232msgstr ""
     233
    230234#: ugame.sskinlinear
    231235msgid "Linear"
  • trunk/UCore.lfm

    r50 r51  
    44  OldCreateOrder = False
    55  Height = 534
    6   HorizontalOffset = 1092
    7   VerticalOffset = 494
     6  HorizontalOffset = 773
     7  VerticalOffset = 525
    88  Width = 635
    99  PPI = 144
     
    3737  object Translator1: TTranslator
    3838    POFilesFolder = 'Languages'
     39    OnTranslate = Translator1Translate
    3940    left = 336
    4041    top = 295
     
    8182    end
    8283  end
     84  object ThemeManager2: TThemeManager
     85    left = 163
     86    top = 405
     87  end
    8388end
  • trunk/UCore.pas

    r50 r51  
    6464  SGameOverMessage = 'Game over!';
    6565  SWinCaption = 'Win';
    66   SWinMessage = 'You reached %d and won! You can continue to play to get higher score.';
     66  SWinMessage = 'You reached %s and won! You can continue to play to get higher score.';
    6767
    6868{ TCore }
  • trunk/UGame.pas

    r50 r51  
    9494  end;
    9595
    96   TTileSkin = (tsLinear, tsPowerOfTwo);
     96  TTileSkin = (tsLinear, tsPowerOfTwo, tsAlpha);
    9797
    9898  { TGame }
     
    145145    procedure SaveToRegistry(RegContext: TRegistryContext);
    146146    procedure LoadFromRegistry(RegContext: TRegistryContext);
    147     function GetTileSkinValue(Value: Integer): Integer;
     147    function GetTileSkinValue(Value: Integer): string;
     148    function GetTileSkinScore(Value: Integer): Integer;
    148149    constructor Create;
    149150    destructor Destroy; override;
     
    176177  SSkinLinear = 'Linear';
    177178  SSkinPowerOfTwo = 'Power of two';
     179  SSkinAlpha = 'Alpha';
    178180  STileShouldBeEmpty = 'Tile should be empty';
     181
    179182
    180183procedure Translate;
     
    190193  SkinText[tsLinear] := SSkinLinear;
    191194  SkinText[tsPowerOfTwo] := SSkinPowerOfTwo;
     195  SkinText[tsAlpha] := SSkinAlpha;
    192196end;
    193197
     
    694698              Board.Tiles[P.Y, P.X].Value := 0;
    695699              Board.Tiles[P.Y, P.X].Merged := False;
    696               Score := Score + GetTileSkinValue(Board.Tiles[PNew.Y, PNew.X].Value);
     700              Score := Score + GetTileSkinScore(Board.Tiles[PNew.Y, PNew.X].Value);
    697701            end;
    698702          end;
     
    715719  Canvas.RoundRect(TileRect, ScaleX(TileRect.Width div 20, 96), ScaleY(TileRect.Height div 20, 96));
    716720  if WithText and (Tile.Value <> 0) then begin
    717     ValueStr := IntToStr(GetTileSkinValue(Tile.Value));
     721    ValueStr := GetTileSkinValue(Tile.Value);
    718722    Canvas.Brush.Style := bsClear;
    719723    Canvas.Font.Height := Trunc(TileRect.Height * 0.7);
     
    859863              Board.Tiles[P.Y, P.X].NewValue := 0;
    860864              Board.Tiles[P.Y, P.X].Merged := False;
    861               Score := Score + GetTileSkinValue(Board.Tiles[PNew.Y, PNew.X].NewValue);
     865              Score := Score + GetTileSkinScore(Board.Tiles[PNew.Y, PNew.X].NewValue);
    862866              TileMoved := True;
    863867            end;
     
    918922end;
    919923
    920 function TGame.GetTileSkinValue(Value: Integer): Integer;
    921 begin
    922   if FSkin = tsPowerOfTwo then Result := 1 shl Value
    923   else Result := Value;
     924function TGame.GetTileSkinValue(Value: Integer): string;
     925begin
     926  case FSkin of
     927    tsLinear: Result := IntToStr(Value);
     928    tsPowerOfTwo: Result := IntToStr(1 shl Value);
     929    tsAlpha: Result := Chr(Ord('A') + Value - 1);
     930    else Result := IntToStr(Value);
     931  end;
     932end;
     933
     934function TGame.GetTileSkinScore(Value: Integer): Integer;
     935begin
     936  case FSkin of
     937    tsLinear: Result := Value;
     938    tsPowerOfTwo: Result := 1 shl Value;
     939    tsAlpha: Result := Value;
     940    else Result := Value;
     941  end;
    924942end;
    925943
     
    10831101end;
    10841102
     1103initialization
     1104  Translate;
     1105
    10851106end.
    10861107
Note: See TracChangeset for help on using the changeset viewer.