Skip to content

Commit

Permalink
Updated translation system
Browse files Browse the repository at this point in the history
  • Loading branch information
LIPtoH committed Dec 18, 2019
1 parent b143b12 commit 012b78e
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 101 deletions.
4 changes: 4 additions & 0 deletions TS SE Tool/DataManipulation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3444,6 +3444,10 @@ private void LoadCachedExternalCargoData(string _dbname)
{
SqlCeConnection tDBconnection;
string _fileName = Directory.GetCurrentDirectory() + @"\gameref\cache\" + GameType + "\\" + _dbname + ".sdf";

if (!File.Exists(_fileName))
return;

tDBconnection = new SqlCeConnection("Data Source = " + _fileName + ";");

if (tDBconnection.State == ConnectionState.Closed)
Expand Down
2 changes: 1 addition & 1 deletion TS SE Tool/FormGaragesSoldContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private void FillTreeView()

if (_resultvalue != null && _resultvalue != "")
{
DriverName = _resultvalue;
DriverName = _resultvalue.TrimStart(new char[] { '+'});
}
}

Expand Down
21 changes: 0 additions & 21 deletions TS SE Tool/FormMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion TS SE Tool/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ limitations under the License.
using System.Runtime.InteropServices;
using System.Globalization;
using System.Deployment.Application;
using System.Threading;


namespace TS_SE_Tool
Expand Down Expand Up @@ -257,7 +258,18 @@ private void FormMain_FormClosing(object sender, FormClosingEventArgs e)

private void makeToolStripMenuItem_Click(object sender, EventArgs e)
{
ExportFormControlstoLanguageFile();
//Set default culture
string sysCI = CultureInfo.InstalledUICulture.Name;

string folderPath = Directory.GetCurrentDirectory() + @"\lang\" + sysCI;

if(!Directory.Exists(folderPath))
Directory.CreateDirectory(folderPath);

Process.Start(folderPath);

//Copy default files

}
}

Expand Down
150 changes: 100 additions & 50 deletions TS SE Tool/FormMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -922,10 +922,18 @@ private void comboBoxProfiles_SelectedIndexChanged(object sender, EventArgs e)
{
string AvatarPath = Globals.ProfilesHex[comboBoxProfiles.SelectedIndex] + @"\avatar.png";

Bitmap Source = new Bitmap(AvatarPath);
Rectangle SourceRect = new Rectangle(0, 0, 95, 95);
Bitmap Cropped = Source.Clone(SourceRect, Source.PixelFormat);
pictureBoxProfileAvatar.Image = Cropped;
if(File.Exists(AvatarPath))
{
Bitmap Source = new Bitmap(AvatarPath);
Rectangle SourceRect = new Rectangle(0, 0, 95, 95);
Bitmap Cropped = Source.Clone(SourceRect, Source.PixelFormat);
pictureBoxProfileAvatar.Image = Cropped;
}
else
{
string[] imgpaths = new string[] { @"img\unknown.dds" };
pictureBoxProfileAvatar.Image = ExtImgLoader(imgpaths, 95, 95, 0, 0)[0];
}
}
catch
{
Expand Down Expand Up @@ -3294,12 +3302,12 @@ public void FillcomboBoxCountries()
}

combDT.DefaultView.Sort = "CountryName ASC";

//All item
DataTable dt2 = combDT.DefaultView.ToTable();
DataRow row1 = dt2.NewRow();
row1[0] = "All";
row1[0] = "+all";

CountriesLngDict.TryGetValue("All", out value);
CountriesLngDict.TryGetValue("+all", out value);

if (value != null && value != "")
{
Expand All @@ -3311,11 +3319,28 @@ public void FillcomboBoxCountries()
}

dt2.Rows.InsertAt(row1, 0);
//Unsorted item
row1 = dt2.NewRow();
row1[0] = "+unsorted";

CountriesLngDict.TryGetValue("+unsorted", out value);

if (value != null && value != "")
{
row1[1] = value;
}
else
{
row1[1] = "Unsorted";
}

dt2.Rows.InsertAt(row1, 1);

//Finish
comboBoxFreightMarketCountries.ValueMember = "Country";
comboBoxFreightMarketCountries.DisplayMember = "CountryName";
comboBoxFreightMarketCountries.DataSource = dt2;
comboBoxFreightMarketCountries.SelectedValue = "All";
comboBoxFreightMarketCountries.SelectedValue = "+all";
}

private void comboBoxCountries_SelectedIndexChanged(object sender, EventArgs e)
Expand Down Expand Up @@ -3361,9 +3386,9 @@ public void FillcomboBoxCompanies()
sortedDT.DefaultView.Sort = "";

DataRow row = sortedDT.NewRow();
string tvalue;
CompaniesLngDict.TryGetValue("All", out tvalue);
row.ItemArray = new object [] { "All", tvalue };
string tvalue = "All";
CompaniesLngDict.TryGetValue("+all", out tvalue);
row.ItemArray = new object [] { "+all", tvalue };

sortedDT.Rows.InsertAt(row, 0);
//
Expand Down Expand Up @@ -4035,7 +4060,7 @@ private void comboBoxDestinationCity_SelectedIndexChanged(object sender, EventAr
private void triggerDestinationCitiesUpdate()
{
if (comboBoxFreightMarketCompanies.SelectedIndex != -1)
SetupDestinationCities(!(comboBoxFreightMarketCountries.SelectedValue.ToString() == "All"), !(comboBoxFreightMarketCompanies.SelectedValue.ToString() == "All"));
SetupDestinationCities(!(comboBoxFreightMarketCountries.SelectedValue.ToString() == "+all"), !(comboBoxFreightMarketCompanies.SelectedValue.ToString() == "+all"));
}

private void SetupDestinationCities(bool _country_selected, bool _company_selected)
Expand All @@ -4052,46 +4077,63 @@ private void SetupDestinationCities(bool _country_selected, bool _company_select

if (_country_selected && !checkBoxFreightMarketFilterDestination.Checked)
{
cities = cities.FindAll(x => x.Country == comboBoxFreightMarketCountries.SelectedValue.ToString());
if(comboBoxFreightMarketCountries.SelectedValue.ToString() == "+unsorted")
{
cities = cities.FindAll(x => x.Country == "");
}
else
cities = cities.FindAll(x => x.Country == comboBoxFreightMarketCountries.SelectedValue.ToString());
}
else
if (!(_country_selected || checkBoxFreightMarketFilterDestination.Checked))
{
}

foreach (City city in cities)
if (cities.Count > 0)
{
List<Company> companyList = city.ReturnCompanies();

if (!_company_selected)
foreach (City city in cities)
{
}
else
if (_company_selected && checkBoxFreightMarketFilterDestination.Checked)
{
companyList = companyList.FindAll(x => (x.CompanyName == comboBoxFreightMarketCompanies.SelectedValue.ToString()) && !x.Excluded);
}
else
if (!(_company_selected || !checkBoxFreightMarketFilterDestination.Checked))
{
companyList = companyList.FindAll(x => !x.Excluded);
}
else
if (_company_selected && !checkBoxFreightMarketFilterDestination.Checked)
{
companyList = companyList.FindAll(x => x.CompanyName == comboBoxFreightMarketCompanies.SelectedValue.ToString());
}
List<Company> companyList = city.ReturnCompanies();

if (companyList.Count > 0)
{
combDT.Rows.Add(city.CityName, city.CityNameTranslated);
comboBoxFreightMarketDestinationCity.Enabled = true;
}
else
{
comboBoxFreightMarketDestinationCity.Enabled = false;
if (!_company_selected)
{
}
else
if (_company_selected && checkBoxFreightMarketFilterDestination.Checked)
{
companyList = companyList.FindAll(x => (x.CompanyName == comboBoxFreightMarketCompanies.SelectedValue.ToString()) && !x.Excluded);
}
else
if (!(_company_selected || !checkBoxFreightMarketFilterDestination.Checked))
{
companyList = companyList.FindAll(x => !x.Excluded);
}
else
if (_company_selected && !checkBoxFreightMarketFilterDestination.Checked)
{
companyList = companyList.FindAll(x => x.CompanyName == comboBoxFreightMarketCompanies.SelectedValue.ToString());
}

if (companyList.Count > 0)
{
combDT.Rows.Add(city.CityName, city.CityNameTranslated);
comboBoxFreightMarketDestinationCity.Enabled = true;
comboBoxFreightMarketDestinationCompany.Enabled = true;
}
else
{
comboBoxFreightMarketDestinationCity.Enabled = false;
}
}
//comboBoxFreightMarketDestinationCity.Enabled = true;
}
else
{
comboBoxFreightMarketDestinationCity.Text = "";
comboBoxFreightMarketDestinationCity.Enabled = false;
comboBoxFreightMarketDestinationCompany.Text = "";
comboBoxFreightMarketDestinationCompany.Enabled = false;
}

combDT.DefaultView.Sort = "CityName ASC";

Expand All @@ -4113,7 +4155,7 @@ private void SetupDestinationCities(bool _country_selected, bool _company_select
//Destination companies
private void triggerDestinationCompaniesUpdate()
{
SetupDestinationCompanies(!(comboBoxFreightMarketCompanies.SelectedValue.ToString() == "All"));
SetupDestinationCompanies(!(comboBoxFreightMarketCompanies.SelectedValue.ToString() == "+all"));
}

private void SetupDestinationCompanies(bool _company_selected)
Expand Down Expand Up @@ -4302,8 +4344,8 @@ private void FM_JobList_Edit()
buttonFreightMarketCancelJobEdit.Visible = true;
buttonFreightMarketCancelJobEdit.Enabled = true;

comboBoxFreightMarketCountries.SelectedValue = "All";
comboBoxFreightMarketCompanies.SelectedValue = "All";
comboBoxFreightMarketCountries.SelectedValue = "+all";
comboBoxFreightMarketCompanies.SelectedValue = "+all";

FreightMarketJob = (JobAdded)listBoxFreightMarketAddedJobs.SelectedItem;

Expand Down Expand Up @@ -5002,7 +5044,6 @@ internal void HelpTranslateFormMethod (Control parent, PlainTXTResourceManager _
{
try
{

string translatedString = _rm.GetString(c.Name.TrimEnd(charsToTrim), _ci);
if (translatedString != null)
c.Text = translatedString;
Expand Down Expand Up @@ -5107,23 +5148,32 @@ private void RefreshComboboxes()
dv.Sort = "CountryName ASC";
sortedDT = dv.ToTable();
sortedDT.DefaultView.Sort = "";

DataRow sourceRow = sortedDT.Select("Country = 'All'")[0];
//Shift All
DataRow sourceRow = sortedDT.Select("Country = '+all'")[0];
int rowi = sortedDT.Rows.IndexOf(sourceRow);

DataRow row = sortedDT.NewRow();
row.ItemArray = sourceRow.ItemArray;

sortedDT.Rows.RemoveAt(rowi);
sortedDT.Rows.InsertAt(row, 0);
//Shift Unsorted
sourceRow = sortedDT.Select("Country = '+unsorted'")[0];
rowi = sortedDT.Rows.IndexOf(sourceRow);

row = sortedDT.NewRow();
row.ItemArray = sourceRow.ItemArray;

sortedDT.Rows.RemoveAt(rowi);
sortedDT.Rows.InsertAt(row, 1);


comboBoxFreightMarketCountries.DataSource = sortedDT;

if (savedindex != -1)
comboBoxFreightMarketCountries.SelectedValue = savedvalue;
else
comboBoxFreightMarketCountries.SelectedValue = "All";
comboBoxFreightMarketCountries.SelectedValue = "+all";

comboBoxFreightMarketCountries.SelectedIndexChanged += comboBoxCountries_SelectedIndexChanged;
}
Expand Down Expand Up @@ -5163,7 +5213,7 @@ private void RefreshComboboxes()
sortedDT = dv.ToTable();
sortedDT.DefaultView.Sort = "";

DataRow sourceRow = sortedDT.Select("Company = 'All'")[0];
DataRow sourceRow = sortedDT.Select("Company = '+all'")[0];
int rowi = sortedDT.Rows.IndexOf(sourceRow);

DataRow row = sortedDT.NewRow();
Expand All @@ -5178,7 +5228,7 @@ private void RefreshComboboxes()
if (savedindex != -1)
comboBoxFreightMarketCompanies.SelectedValue = savedvalue;
else
comboBoxFreightMarketCompanies.SelectedValue = "All";
comboBoxFreightMarketCompanies.SelectedValue = "+all";

comboBoxFreightMarketCompanies.SelectedIndexChanged += comboBoxCompanies_SelectedIndexChanged;
}
Expand Down
Loading

0 comments on commit 012b78e

Please sign in to comment.