Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
Changes for v2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
amrshaheen61 committed Jan 25, 2024
1 parent a076332 commit 169f317
Show file tree
Hide file tree
Showing 20 changed files with 655 additions and 292 deletions.
3 changes: 3 additions & 0 deletions UE4localizationsTool/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<setting name="CheckForUpdates" serializeAs="String">
<value>True</value>
</setting>
<setting name="GoodByeMessage" serializeAs="String">
<value>False</value>
</setting>
</UE4localizationsTool.Properties.Settings>
</userSettings>
</configuration>
37 changes: 31 additions & 6 deletions UE4localizationsTool/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ public Commands(string Options, string SourcePath, Args args)
GetFilterValues();
}

if (Flags.HasFlag(Args.CSV)){
if (Flags.HasFlag(Args.CSV))
{

TextFileExtension = ".csv";
}
string[] Paths;
string ConsoleText;
string[] rows;
switch (Options.ToLower())
{
case "export"://Single File
Expand Down Expand Up @@ -87,7 +89,18 @@ public Commands(string Options, string SourcePath, Args args)
throw new Exception("Invalid text file type: " + Path.GetFileName(SourcePath));
}

Import(Path.ChangeExtension(SourcePath, null), File.ReadAllLines(SourcePath), Options.ToLower());


if (Flags.HasFlag(Args.CSV))
{
rows = CSVFile.Instance.Load(SourcePath, Flags.HasFlag(Args.noname));
}
else
{
rows = File.ReadAllLines(SourcePath);
}

Import(Path.ChangeExtension(SourcePath, null), rows, Options.ToLower());
Console.ForegroundColor = ConsoleColor.Green;
Console.Write("Done\n");
Console.ForegroundColor = ConsoleColor.White;
Expand All @@ -104,7 +117,19 @@ public Commands(string Options, string SourcePath, Args args)
throw new Exception("Invalid text file type: " + Path.GetFileName(SourcePath));
}

ImportFolder(Paths[0], File.ReadAllLines(Paths[1]), Options.ToLower());


if (Flags.HasFlag(Args.CSV))
{
rows = CSVFile.Instance.Load(Paths[1], Flags.HasFlag(Args.noname));
}
else
{
rows = File.ReadAllLines(Paths[1]);
}


ImportFolder(Paths[0], rows, Options.ToLower());
break;
default:
throw new Exception("Invalid number of arguments.\n" + Program.commandlines);
Expand All @@ -123,7 +148,7 @@ private void SaveTextFile(string FilePath)

if (Flags.HasFlag(Args.CSV))
{
CSVFile.Instance.Save(Strings, FilePath);
CSVFile.Instance.Save(Strings, FilePath, Flags.HasFlag(Args.noname));

goto End;
}
Expand Down Expand Up @@ -151,7 +176,7 @@ private void SaveTextFile(string FilePath)
i++;
}
File.WriteAllLines(FilePath, stringsArray);
End:
End:
Console.ForegroundColor = ConsoleColor.Green;
Console.Write("Done\n");
Console.ForegroundColor = ConsoleColor.White;
Expand Down Expand Up @@ -301,7 +326,7 @@ private void Import(string FilePath, string[] Values, string Option)
{
var locres = new LocresFile(FilePath);
var strings = locres.ExtractTexts();
EditList(locres.ExtractTexts(), Values);
EditList(strings, Values);
locres.ImportTexts(strings);

if (Option == "-import")
Expand Down
26 changes: 3 additions & 23 deletions UE4localizationsTool/Controls/NDataGridView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct DataRow
[Browsable(true)]
public event EventHandler RowCountChanged;


private bool _isFiltering = false;

[Browsable(false)]
Expand Down Expand Up @@ -124,28 +125,7 @@ protected void ClearUndoRedoStacks()
}


//protected override void OnCellBeginEdit(DataGridViewCellCancelEventArgs e)
//{
// // BackupDataUndo.Push(new DataRow() { cell = Rows[e.RowIndex].Cells[e.ColumnIndex], StringValue = Rows[e.RowIndex].Cells[e.ColumnIndex].Value, style = Rows[e.RowIndex].Cells[e.ColumnIndex].Style.Clone() });
// base.OnCellBeginEdit(e);
//}

//protected override void OnCellEndEdit(DataGridViewCellEventArgs e)
//{
// base.OnCellEndEdit(e);
// if (BackupDataUndo.Count > 0)
// {
// if (!object.Equals(BackupDataUndo.Peek().StringValue, Rows[e.RowIndex].Cells[e.ColumnIndex].Value))
// {
// BackupDataRedo.Clear();
// UpdateBackColor(Rows[e.RowIndex].Cells[e.ColumnIndex]);
// }
// else
// {
// BackupDataUndo.Pop();
// }
// }
//}


protected override void OnCellValidating(DataGridViewCellValidatingEventArgs e)
{
Expand All @@ -160,7 +140,7 @@ protected override void OnCellValidating(DataGridViewCellValidatingEventArgs e)
}


public void SetValue(DataGridViewCell cell,object Value)
public void SetValue(DataGridViewCell cell, object Value)
{
if (!object.Equals(Value, cell.Value))
{
Expand Down
83 changes: 82 additions & 1 deletion UE4localizationsTool/Controls/NForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,88 @@ protected override void CreateHandle()
DarkMode(this);
}

#if DEBUG

protected override void OnLoad(System.EventArgs e)
{
GetAllControlNames(this, Name);
}

private void GetAllControlNames(Control control, string parentName)
{
string controlName = parentName;

if (control is TextBox || control is Label || control is Button || control is ComboBox
|| control is ListBox || control is DataGridView || control is CheckBox)
{
controlName += $".{control.Name}";
//control.GetType().GetProperty("Text", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SetValue(column, "amr");
Console.WriteLine(controlName);

if (control is DataGridView)
{
foreach (DataGridViewColumn column in ((DataGridView)control).Columns)
{
Console.WriteLine(controlName + "." + column.Name);
//column.HeaderText = "amr";
// column.GetType().GetProperty("HeaderText", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SetValue(column, "amr");
}
}

}
else if (control is ToolStripMenuItem)
{
controlName += $".{control.Name}";
//control.GetType().GetProperty("Text", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SetValue(column, "amr");
Console.WriteLine(controlName);
}

foreach (Control childControl in control.Controls)
{
GetAllControlNames(childControl, controlName);
}

if (control.ContextMenuStrip != null)
{
foreach (ToolStripMenuItem toolStripItem in control.ContextMenuStrip.Items)
{
GetAllContextMenuNames(toolStripItem, controlName);
}
}

if (control is MenuStrip)
{
foreach (var toolStripItem in ((MenuStrip)control).Items)
{
if (toolStripItem is ToolStripMenuItem)
GetAllContextMenuNames((ToolStripMenuItem)toolStripItem, controlName);
}
}
}

private void GetAllContextMenuNames(ToolStripMenuItem control, string parentName)
{
string controlName = parentName;

if (control is ToolStripMenuItem)
{
controlName += $".{(control as ToolStripMenuItem).Name}";
//control.GetType().GetProperty("Text", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SetValue(column, "amr");
Console.WriteLine(controlName);
}

// Recursively call the method for child controls
foreach (ToolStripItem childControl in control.DropDownItems)
{
if (childControl is ToolStripMenuItem)
{
GetAllContextMenuNames(childControl as ToolStripMenuItem, controlName);
}
}
}

#endif

public void DarkMode(Control control)
{
if (control == null) return;
Expand Down Expand Up @@ -77,7 +159,6 @@ public void DarkMode(Control control)
button.BackColor = Color.FromArgb(40, 40, 40);
button.ForeColor = Color.White;
button.FlatStyle = FlatStyle.Flat;
button.FlatAppearance.BorderSize = 1;
button.FlatAppearance.BorderColor = Color.FromArgb(60, 60, 60);
button.FlatAppearance.MouseOverBackColor = Color.FromArgb(60, 60, 60);
}
Expand Down
4 changes: 2 additions & 2 deletions UE4localizationsTool/Controls/NTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ private void UpdatePlaceholderText()

protected override void OnKeyPress(KeyPressEventArgs e)
{
if (Multiline&&StopEnterKey && e.KeyChar == '\r'|| StopEnterKey && e.KeyChar == '\n')
if (Multiline && StopEnterKey && e.KeyChar == '\r' || StopEnterKey && e.KeyChar == '\n')
{
e.Handled = true;
}


base.OnKeyPress(e);
}
Expand Down
Loading

0 comments on commit 169f317

Please sign in to comment.