Skip to content

Commit

Permalink
language combo now on start screen
Browse files Browse the repository at this point in the history
  • Loading branch information
digao-dalpiaz committed Sep 28, 2020
1 parent 1f014be commit 82beb11
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 124 deletions.
2 changes: 1 addition & 1 deletion Languages/English.lang
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ CONN_REJECT_ALREADY_RUNNING=You cannot join the game because it is already runni
CONN_REJECT_ALREADY_PLAYER_NAME=This player name already exists!

SETTINGS_CAPTION=Settings
SETTINGS_LANGUAGE=Language:
SETTINGS_SOUNDS=Enable Sounds
SETTINGS_ZOOM=Grid zoom:
SETTINGS_LOG_FONT_SIZE=Log font size:
Expand All @@ -34,6 +33,7 @@ START_OPERATION=Operation mode
START_RECONNECT=Reconnect
START_SERVER_ADDR=Server address:
START_CONN_PASSWORD=Connection password:
START_LANGUAGE=Language:

START_MSG_BLANK_NAME=Please, type your name.
START_MSG_BLANK_HASH=Please, type the hash code for reconnection.
Expand Down
2 changes: 1 addition & 1 deletion Languages/PortugueseBrazil.lang
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ CONN_REJECT_ALREADY_RUNNING=Você não pode ser juntar a este jogo pois ele já
CONN_REJECT_ALREADY_PLAYER_NAME=Este nome de jogador já existe!

SETTINGS_CAPTION=Configurações
SETTINGS_LANGUAGE=Linguagem:
SETTINGS_SOUNDS=Habilitar Sons
SETTINGS_ZOOM=Zoom da tabela:
SETTINGS_LOG_FONT_SIZE=Tamanho da fonte do log:
Expand All @@ -34,6 +33,7 @@ START_OPERATION=Modo de operação
START_RECONNECT=Reconectar
START_SERVER_ADDR=Endereço do servidor:
START_CONN_PASSWORD=Senha de conexão:
START_LANGUAGE=Linguagem:

START_MSG_BLANK_NAME=Por favor, digite seu nome.
START_MSG_BLANK_HASH=Por favor, digite o código para reconexão.
Expand Down
35 changes: 17 additions & 18 deletions UDMClient.pas
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ implementation

{$R *.dfm}

uses UVars, UFrmGame, UFrmLog, UFrmStart, UFrmMain, System.SysUtils, UDMServer,
ULanguage;
uses UVars, ULanguage, UDMServer,
UFrmMain, UFrmStart, UFrmGame, UFrmLog,
System.SysUtils, System.StrUtils;

procedure TDMClient.DataModuleCreate(Sender: TObject);
begin
Expand Down Expand Up @@ -100,8 +101,9 @@ procedure TDMClient.CLoginResponse(Sender: TObject; Socket: TDzSocket;
pubPlayerName := D[0];
FrmStart.EdHash.Text := D[1]; //auto-set for use when disconnect

FrmMain.ClientRules.Received := False;
FrmMain.UpdateConnectionBox;
FrmMain.LbMode.Caption := Lang.Get(IfThen(pubModeServer, 'MODE_SERVER', 'MODE_CLIENT'));
FrmMain.LbPlayer.Caption := pubPlayerName;
FrmMain.LbRules.Caption := string.Empty;
FrmMain.BoxConInfo.Visible := True;

FrmGame.Initialize(FrmStart.BoxReconnect.Visible);
Expand Down Expand Up @@ -152,26 +154,23 @@ procedure TDMClient.CRead(Sender: TObject; Socket: TDzSocket; const Cmd: Char;
procedure TDMClient.RulesReceived(const A: string; ToOne: Boolean);
var
D: TMsgArray;
Dictionary: string;
SizeW, SizeH, InitialLetters, RebuyLetters: Integer;
begin
D := DataToArray(A);

with FrmMain.ClientRules do
begin
Dictionary := D[0];
SizeW := D[1];
SizeH := D[2];
InitialLetters := D[3];
RebuyLetters := D[4];

Received := True;
end;
Dictionary := D[0];
SizeW := D[1];
SizeH := D[2];
InitialLetters := D[3];
RebuyLetters := D[4];

FrmMain.UpdateConnectionBox;
FrmMain.LbRules.Caption :=
Format(Lang.Get('TITLE_RULES_DEFINITION'), [
Dictionary, SizeW, SizeH, InitialLetters, RebuyLetters]);

FrmGame.LbPosition.Caption := string.Empty;
FrmGame.PB.SetMatrixSize(
FrmMain.ClientRules.SizeH,
FrmMain.ClientRules.SizeW);
FrmGame.PB.SetMatrixSize(SizeH, SizeW);

if not ToOne then
Log(Lang.Get('LOG_RULES_CHANGED'));
Expand Down
6 changes: 0 additions & 6 deletions UFrmGame.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ object FrmGame: TFrmGame
Align = alClient
BevelOuter = bvNone
TabOrder = 2
ExplicitHeight = 108
object LbChat: TLabel
Left = 0
Top = 0
Expand Down Expand Up @@ -84,7 +83,6 @@ object FrmGame: TFrmGame
TabOrder = 0
StyleElements = [seClient, seBorder]
Zoom = 100
ExplicitHeight = 25
end
object EdChatMsg: TEdit
Left = 0
Expand All @@ -100,7 +98,6 @@ object FrmGame: TFrmGame
ParentFont = False
TabOrder = 1
OnKeyPress = EdChatMsgKeyPress
ExplicitTop = 87
end
end
object LPlayers: TListBox
Expand Down Expand Up @@ -375,7 +372,6 @@ object FrmGame: TFrmGame
BevelOuter = bvNone
TabOrder = 4
StyleElements = [seFont, seBorder]
ExplicitTop = 430
end
end
object BoxGrid: TPanel
Expand Down Expand Up @@ -407,8 +403,6 @@ object FrmGame: TFrmGame
Align = alClient
BorderStyle = bsNone
TabOrder = 0
ExplicitTop = 17
ExplicitHeight = 425
end
end
object IL: TImageList
Expand Down
2 changes: 1 addition & 1 deletion UFrmGame.pas
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ TFrmGame = class(TForm)
Status: TGameStatus;
PB: TMatrixImage;

procedure InitTranslation;
procedure Initialize(Reconnected: Boolean);
procedure MatrixReceived(const A: string);
procedure ChatLog(const Player, Text: string);
Expand All @@ -67,6 +66,7 @@ TFrmGame = class(TForm)
procedure GameOverReceived;
procedure ReceivedPreparingNewGame;
private
procedure InitTranslation;
procedure SetStatus(NewStatus: TGameStatus);
end;

Expand Down
49 changes: 20 additions & 29 deletions UFrmMain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,8 @@ TFrmMain = class(TForm)
procedure InitStartPage;
procedure InitGamePage;
public
ClientRules: record
Received: Boolean;

Dictionary: string;
SizeW, SizeH, InitialLetters, RebuyLetters: Integer;
end;

procedure ConfigLanguage(Save: Boolean);
procedure InitTranslation;
procedure UpdateConnectionBox;
end;

var
Expand All @@ -56,17 +49,18 @@ implementation

uses UVars, UDams, ULanguage,
UFrmStart, UFrmGame, UFrmLog, UFrmSettings, UDMClient,
System.StrUtils, System.SysUtils, Winapi.ShellAPI;
System.SysUtils, System.IniFiles, Winapi.ShellAPI;

procedure TFrmMain.FormCreate(Sender: TObject);
begin
ReportMemoryLeaksOnShutdown := True;

TSettings.Load;

ConfigLanguage(False); //load config language
Lang.LoadLanguage;
InitTranslation;

TSettings.Load;

Randomize;

InitLogArea;
Expand All @@ -76,6 +70,21 @@ procedure TFrmMain.FormCreate(Sender: TObject);
FrmStart.Show;
end;

procedure TFrmMain.ConfigLanguage(Save: Boolean);
var
Ini: TIniFile;
begin
Ini := TIniFile.Create(GetIniFilePath);
try
if Save then
Ini.WriteString('Language', 'ID', pubLanguageID)
else
pubLanguageID := Ini.ReadString('Language', 'ID', 'EN');
finally
Ini.Free;
end;
end;

procedure TFrmMain.InitTranslation;
begin
LbVersion.Caption := Format(Lang.Get('TITLE_VERSION'), [STR_VERSION]);
Expand All @@ -85,8 +94,6 @@ procedure TFrmMain.InitTranslation;

_QuestionCloseApp.Message := Lang.Get('MSG_CLOSE_APP');
_QuestionKillPlayer.Message := Lang.Get('MSG_KILL_PLAYER');

UpdateConnectionBox;
end;

procedure TFrmMain.InitStartPage;
Expand All @@ -112,22 +119,6 @@ procedure TFrmMain.LbLinkClick(Sender: TObject);
ShellExecute(0, '', 'http://digaodalpiaz.com/', '', '', 0);
end;

procedure TFrmMain.UpdateConnectionBox;
begin
LbMode.Caption := Lang.Get(IfThen(pubModeServer, 'MODE_SERVER', 'MODE_CLIENT'));
LbPlayer.Caption := pubPlayerName;

with ClientRules do
begin
if Received then
LbRules.Caption :=
Format(Lang.Get('TITLE_RULES_DEFINITION'), [
Dictionary, SizeW, SizeH, InitialLetters, RebuyLetters])
else
LbRules.Caption := string.Empty;
end;
end;

procedure TFrmMain.BtnSettingsClick(Sender: TObject);
begin
ShowSettings;
Expand Down
51 changes: 18 additions & 33 deletions UFrmSettings.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ object FrmSettings: TFrmSettings
Top = 0
BorderStyle = bsDialog
Caption = 'Settings'
ClientHeight = 219
ClientHeight = 162
ClientWidth = 457
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Expand All @@ -18,23 +18,16 @@ object FrmSettings: TFrmSettings
TextHeight = 13
object LbGridZoom: TLabel
Left = 16
Top = 107
Top = 51
Width = 153
Height = 13
Alignment = taRightJustify
AutoSize = False
Caption = 'Grid zoom:'
end
object LbLanguage: TLabel
Left = 16
Top = 16
Width = 51
Height = 13
Caption = 'Language:'
end
object LbLogFontSize: TLabel
Left = 16
Top = 139
Top = 83
Width = 153
Height = 13
Alignment = taRightJustify
Expand All @@ -43,87 +36,79 @@ object FrmSettings: TFrmSettings
end
object Bevel1: TBevel
Left = 16
Top = 176
Top = 120
Width = 425
Height = 9
Shape = bsTopLine
end
object CkSounds: TCheckBox
Left = 16
Top = 72
Top = 16
Width = 97
Height = 17
Caption = 'Enable Sounds'
TabOrder = 1
TabOrder = 0
end
object BtnOK: TButton
Left = 144
Top = 184
Top = 128
Width = 81
Height = 25
Caption = 'OK'
Default = True
TabOrder = 6
TabOrder = 5
OnClick = BtnOKClick
end
object BtnCancel: TButton
Left = 232
Top = 184
Top = 128
Width = 81
Height = 25
Cancel = True
Caption = 'Cancel'
ModalResult = 2
TabOrder = 7
TabOrder = 6
end
object EdGridZoom: TEdit
Left = 176
Top = 104
Top = 48
Width = 49
Height = 21
Alignment = taRightJustify
NumbersOnly = True
TabOrder = 2
TabOrder = 1
Text = '100'
end
object BtnZoom: TUpDown
Left = 225
Top = 104
Top = 48
Width = 16
Height = 21
Associate = EdGridZoom
Min = 50
Max = 200
Position = 100
TabOrder = 3
end
object EdLanguage: TComboBox
Left = 16
Top = 32
Width = 249
Height = 21
Style = csDropDownList
TabOrder = 0
TabOrder = 2
end
object EdLogFontSize: TEdit
Left = 176
Top = 136
Top = 80
Width = 49
Height = 21
Alignment = taRightJustify
NumbersOnly = True
TabOrder = 4
TabOrder = 3
Text = '10'
end
object BtnLogFontSize: TUpDown
Left = 225
Top = 136
Top = 80
Width = 16
Height = 21
Associate = EdLogFontSize
Min = 7
Max = 20
Position = 10
TabOrder = 5
TabOrder = 4
end
end
Loading

0 comments on commit 82beb11

Please sign in to comment.