1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 06:04:49 +01:00

add option to change the language of the config program

This commit is contained in:
FunkyFr3sh 2021-07-24 07:27:55 +02:00
parent ec2ee6714d
commit 397f139151
4 changed files with 271 additions and 186 deletions

View File

@ -13,6 +13,7 @@
#pragma resource "*.dfm"
TConfigForm *ConfigForm;
bool Initialized;
bool IsEnglish;
/* Save previous settings so we don't override custom settings */
int Maxfps;
@ -24,7 +25,40 @@ int Minfps;
__fastcall TConfigForm::TConfigForm(TComponent* Owner)
: TForm(Owner)
{
if (SysLocale.PriLangID == LANG_CHINESE) {
}
void __fastcall TConfigForm::LanguageLblClick(TObject *Sender)
{
auto *ini = new TIniFile(".\\ddraw.ini");
if (IsEnglish) {
ini->WriteString("ddraw", "configlang", "auto");
}
else {
ini->WriteString("ddraw", "configlang", "english");
}
delete ini;
ShellExecute(
NULL,
L"open",
Application->ExeName.w_str(),
NULL,
NULL,
SW_SHOWNORMAL);
Application->Terminate();
}
void TConfigForm::ApplyTranslation(TIniFile *ini)
{
auto lang = LowerCase(ini->ReadString("ddraw", "configlang", "auto"));
int priID = SysLocale.PriLangID;
if (lang == "chinese" || (lang == "auto" && priID == LANG_CHINESE)) {
LanguageLbl->Visible = true;
/* -Chinese Simplified- made by universal963 @ github */
ConfigForm->Caption = L"cnc-ddraw 配置";
@ -72,7 +106,9 @@ __fastcall TConfigForm::TConfigForm(TComponent* Owner)
MaxgameticksCbx->AddItem(L"25tick每秒", NULL);
MaxgameticksCbx->AddItem(L"15tick每秒", NULL);
}
else if (SysLocale.PriLangID == LANG_SPANISH) {
else if (lang == "spanish" || (lang == "auto" && priID == LANG_SPANISH)) {
LanguageLbl->Visible = true;
/* -Spanish- made by c-sanchez @ github */
ConfigForm->Caption = L"Ajustes de cnc-ddraw";
@ -120,7 +156,9 @@ __fastcall TConfigForm::TConfigForm(TComponent* Owner)
MaxgameticksCbx->AddItem(L"25 tics por segundo", NULL);
MaxgameticksCbx->AddItem(L"15 tics por segundo", NULL);
}
else if (SysLocale.PriLangID == LANG_GERMAN) {
else if (lang == "german" || (lang == "auto" && priID == LANG_GERMAN)) {
LanguageLbl->Visible = true;
/* -German- made by helgo1506 @ github */
ConfigForm->Caption = L"cnc-ddraw Konfiguration";
@ -169,6 +207,28 @@ __fastcall TConfigForm::TConfigForm(TComponent* Owner)
MaxgameticksCbx->AddItem(L"15 Ticks pro Sekunde", NULL);
}
else {
IsEnglish = true;
UnicodeString name = "";
try {
int lcid = Languages()->IndexOf(SysLocale.DefaultLCID);
name = SplitString(Languages()->Name[lcid].w_str(), L" (")[0];
} catch (...) {
}
if (priID == LANG_CHINESE) {
LanguageLbl->Visible = true;
LanguageLbl->Caption = name == "" ? "Chinese" : name;
}
else if (priID == LANG_SPANISH) {
LanguageLbl->Visible = true;
LanguageLbl->Caption = name == "" ? "Spanish" : name;
}
else if (priID == LANG_GERMAN) {
LanguageLbl->Visible = true;
LanguageLbl->Caption = name == "" ? "German" : name;
}
/*
ConfigForm->Caption = L"cnc-ddraw config";
DisplayBtn->Caption = L"Display Settings";
@ -243,6 +303,8 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender)
{
auto *ini = new TIniFile(".\\ddraw.ini");
ApplyTranslation(ini);
/* Display Settings */
bool windowed = GetBool(ini, "windowed", false);

View File

@ -2682,6 +2682,189 @@ object ConfigForm: TConfigForm
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object CompatibilityPnl: TPanel
Left = 201
Top = 8
Width = 499
Height = 465
BevelOuter = bvNone
Color = clWhite
ParentBackground = False
ShowCaption = False
TabOrder = 3
Visible = False
StyleElements = [seFont, seBorder]
object MaxgameticksLbl: TLabel
Left = 40
Top = 28
Width = 123
Height = 21
Caption = 'Limit game speed'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object NoactivateappLbl: TLabel
Left = 40
Top = 105
Width = 129
Height = 21
Margins.Top = 18
Caption = 'Fix broken Alt+Tab'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object HookLbl: TLabel
Left = 40
Top = 173
Width = 281
Height = 21
Margins.Top = 18
Caption = 'Fix broken windowed mode or upscaling'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object MinfpsLbl: TLabel
Left = 40
Top = 241
Width = 350
Height = 21
Margins.Top = 18
Caption = 'Force high FPS / Fix stuttering on Freesync/G-Sync'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object FixpitchLbl: TLabel
Left = 40
Top = 309
Width = 272
Height = 21
Margins.Top = 18
Caption = 'Fix diagonally displayed drawing issues'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object NonexclusiveLbl: TLabel
Left = 40
Top = 377
Width = 225
Height = 21
Margins.Top = 18
Caption = 'Fix invisible videos / UI elements'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object MaxgameticksPbox: TPaintBox
Left = 40
Top = 54
Width = 342
Height = 31
OnPaint = PboxPaint
end
object MaxgameticksCbx: TComboBox
Left = 41
Top = 55
Width = 340
Height = 29
BevelEdges = []
BevelInner = bvNone
BevelOuter = bvSpace
Style = csDropDownList
DropDownCount = 10
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
TabOrder = 0
OnChange = MaxgameticksCbxChange
Items.Strings = (
'No limit'
'Sync with monitor refresh rate'
'Emulate 60hz refresh rate monitor'
'1000 ticks per second'
'500 ticks per second'
'60 ticks per second'
'30 ticks per second'
'25 ticks per second'
'15 ticks per second')
end
object NoactivateappChk: TToggleSwitch
Left = 40
Top = 132
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 1
OnClick = NoactivateappChkClick
end
object HookChk: TToggleSwitch
Left = 40
Top = 200
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 2
OnClick = HookChkClick
end
object MinfpsChk: TToggleSwitch
Left = 40
Top = 268
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 3
OnClick = MinfpsChkClick
end
object FixpitchChk: TToggleSwitch
Left = 40
Top = 336
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 4
OnClick = FixpitchChkClick
end
object NonexclusiveChk: TToggleSwitch
Left = 40
Top = 404
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 5
OnClick = NonexclusiveChkClick
end
end
object AdvancedPnl: TPanel
Left = 201
Top = 8
@ -2968,6 +3151,23 @@ object ConfigForm: TConfigForm
Height = 31
OnPaint = PboxPaint
end
object LanguageLbl: TLabel
Left = 453
Top = 8
Width = 38
Height = 13
Alignment = taRightJustify
Caption = 'English'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
Visible = False
StyleElements = [seClient, seBorder]
OnClick = LanguageLblClick
end
object PresentationCbx: TComboBox
Left = 41
Top = 55
@ -3028,189 +3228,6 @@ object ConfigForm: TConfigForm
OnClick = DevmodeChkClick
end
end
object CompatibilityPnl: TPanel
Left = 201
Top = 8
Width = 499
Height = 465
BevelOuter = bvNone
Color = clWhite
ParentBackground = False
ShowCaption = False
TabOrder = 3
Visible = False
StyleElements = [seFont, seBorder]
object MaxgameticksLbl: TLabel
Left = 40
Top = 28
Width = 123
Height = 21
Caption = 'Limit game speed'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object NoactivateappLbl: TLabel
Left = 40
Top = 105
Width = 129
Height = 21
Margins.Top = 18
Caption = 'Fix broken Alt+Tab'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object HookLbl: TLabel
Left = 40
Top = 173
Width = 281
Height = 21
Margins.Top = 18
Caption = 'Fix broken windowed mode or upscaling'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object MinfpsLbl: TLabel
Left = 40
Top = 241
Width = 350
Height = 21
Margins.Top = 18
Caption = 'Force high FPS / Fix stuttering on Freesync/G-Sync'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object FixpitchLbl: TLabel
Left = 40
Top = 309
Width = 272
Height = 21
Margins.Top = 18
Caption = 'Fix diagonally displayed drawing issues'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object NonexclusiveLbl: TLabel
Left = 40
Top = 377
Width = 225
Height = 21
Margins.Top = 18
Caption = 'Fix invisible videos / UI elements'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
StyleElements = [seClient, seBorder]
end
object MaxgameticksPbox: TPaintBox
Left = 40
Top = 54
Width = 342
Height = 31
OnPaint = PboxPaint
end
object MaxgameticksCbx: TComboBox
Left = 41
Top = 55
Width = 340
Height = 29
BevelEdges = []
BevelInner = bvNone
BevelOuter = bvSpace
Style = csDropDownList
DropDownCount = 10
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
ParentFont = False
TabOrder = 0
OnChange = MaxgameticksCbxChange
Items.Strings = (
'No limit'
'Sync with monitor refresh rate'
'Emulate 60hz refresh rate monitor'
'1000 ticks per second'
'500 ticks per second'
'60 ticks per second'
'30 ticks per second'
'25 ticks per second'
'15 ticks per second')
end
object NoactivateappChk: TToggleSwitch
Left = 40
Top = 132
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 1
OnClick = NoactivateappChkClick
end
object HookChk: TToggleSwitch
Left = 40
Top = 200
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 2
OnClick = HookChkClick
end
object MinfpsChk: TToggleSwitch
Left = 40
Top = 268
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 3
OnClick = MinfpsChkClick
end
object FixpitchChk: TToggleSwitch
Left = 40
Top = 336
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 4
OnClick = FixpitchChkClick
end
object NonexclusiveChk: TToggleSwitch
Left = 40
Top = 404
Width = 50
Height = 20
ShowStateCaption = False
TabOrder = 5
OnClick = NonexclusiveChkClick
end
end
object MenuPnl: TPanel
Left = 0
Top = 8

View File

@ -60,6 +60,7 @@ __published: // Von der IDE verwaltete Komponenten
TPaintBox *RendererPbox;
TPaintBox *ShaderPbox;
TPaintBox *MaxgameticksPbox;
TLabel *LanguageLbl;
void __fastcall DisplayBtnClick(TObject *Sender);
void __fastcall AdvancedBtnClick(TObject *Sender);
void __fastcall CompatibilityBtnClick(TObject *Sender);
@ -82,9 +83,11 @@ __published: // Von der IDE verwaltete Komponenten
void __fastcall FixpitchChkClick(TObject *Sender);
void __fastcall NonexclusiveChkClick(TObject *Sender);
void __fastcall PboxPaint(TObject *Sender);
void __fastcall LanguageLblClick(TObject *Sender);
private: // Benutzer-Deklarationen
void SaveSettings();
bool GetBool(TIniFile *ini, System::UnicodeString key, bool defValue);
void ApplyTranslation(TIniFile *ini);
public: // Benutzer-Deklarationen
__fastcall TConfigForm(TComponent* Owner);
};

View File

@ -323,6 +323,9 @@ static void cfg_create_ini()
"; Force CPU0 affinity, avoids crashes/freezing, *might* have a performance impact\n"
"singlecpu=true\n"
"\n"
"; cnc-ddraw config program language, possible values: auto, english, chinese, german, spanish\n"
"configlang=auto\n"
"\n"
"\n"
"\n"
"; ### Game specific settings ###\n"