Skip to content

Commit

Permalink
1. The work of the editors has been rewritten, which allows you to ed…
Browse files Browse the repository at this point in the history
…it the text more flexibly and use additional unused characters.

2. Search has been added.
3. Small work has been done to optimize the program.
  • Loading branch information
RED1cat committed Mar 5, 2024
1 parent 986b8c4 commit d24868d
Show file tree
Hide file tree
Showing 14 changed files with 684 additions and 387 deletions.
Binary file modified ujlptr_subedit/Content/BG.xnb
Binary file not shown.
109 changes: 109 additions & 0 deletions ujlptr_subedit/EditorExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace ujlptr_subedit
{
static class EditorExtensions
{
public static string ConvertTextToHex(this string text, Encoding codePage, Dictionary<string, string> hexConverter = null)
{
string hex = BitConverter.ToString(codePage.GetBytes(text)).Replace("-", "");
string outHex = "";

for (int i = 0; i < hex.Length / 2; i++)
{
if (hexConverter != null)
{
if (hexConverter.ContainsKey(hex.Substring(i * 2, 2)))
{
outHex += hexConverter[hex.Substring(i * 2, 2)];
}
else
{
outHex += hex.Substring(i * 2, 2);
}
}
else
{
outHex += hex.Substring(i * 2, 2);
}
}
return outHex;
}

public static string ConvertHexToText(this string text, Encoding codePage)
{
byte[] raw = new byte[text.Length / 2];
for (int i = 0; i < raw.Length; i++)
{
raw[i] = Convert.ToByte(text.Substring(i * 2, 2), 16);
}
return codePage.GetString(raw);
}

public static string ConvertTextFromPattern(this string text, Encoding codePage, Dictionary<string, string> hexConverter)
{
if (hexConverter != null)
{
return text.ConvertTextToHex(codePage, hexConverter).ConvertHexToText(codePage);
}
return text;
}

public static string GetTextFromAddress(this int address, byte[] file, Encoding codePage)
{
int count = 0;
bool StopFlag = false;
while (true)
{
if (address + count == file.Length)
{
break;
}
if (file[address + count] == 0x00)
{
StopFlag = true;
}
else if (StopFlag)
{
break;
}
count++;
}
if (count > 0)
{
count--;
}

return codePage.GetString(file, address, count);
}
public static int GetTextLegthFromAddress(this int address, byte[] file)
{
int count = 0;
bool StopFlag = false;
while (true)
{
if (address + count == file.Length)
{
break;
}
if (file[address + count] == 0x00)
{
StopFlag = true;
}
else if (StopFlag)
{
break;
}
count++;
}
if (count > 0)
{
count--;
}

return count;
}
}
}
39 changes: 39 additions & 0 deletions ujlptr_subedit/Group.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System.Collections.Generic;
using System.ComponentModel;

namespace ujlptr_subedit
{
public class Group
{
public List<Line> Lines = new List<Line>();
public int MaxChars = 0;
public int CurChars = 0;
public int TextLocation;
public bool Edit = false;

public int UpdateCurChars()
{
CurChars = 0;
foreach (Line line in Lines)
{
CurChars += line.Text.Replace("\0", "").Length;
}
return CurChars;
}

public Group(List<int> pointersLocation, List<byte[]> pointers, List<string> texts, int FirstCharAddress, int MaxChars)
{
TextLocation = FirstCharAddress;
this.MaxChars = MaxChars;
foreach (string text in texts)
{
CurChars += text.Replace("\0", "").Length;
}

for (int i = 0; i < pointersLocation.Count; i++)
{
Lines.Add(new Line(pointersLocation[i], pointers[i], texts[i].Replace("\0", "")));
}
}
}
}
24 changes: 24 additions & 0 deletions ujlptr_subedit/Line.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;

namespace ujlptr_subedit
{
public class Line
{
public int PointerLocation;
public string Text;
public string Time;
public string SwitchingTime;

public Line(int pointerLocation, byte[] pointer, string text)
{

PointerLocation = pointerLocation;
Text = text;
if (pointer.Length == 6)
{
Time = BitConverter.ToString(pointer, 3, 1).Replace("-", "");
SwitchingTime = BitConverter.ToString(pointer, 4, 2).Replace("-", "");
}
}
}
}
25 changes: 13 additions & 12 deletions ujlptr_subedit/MainForm.Designer.cs

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

42 changes: 24 additions & 18 deletions ujlptr_subedit/MainForm.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using SharpDX.Direct3D9;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Windows.Input;
using ujlptr_subedit;

namespace ujlptr_subedit
{
Expand All @@ -22,14 +19,14 @@ public MainForm()
public class FileDecodeOffset
{
public string Name { get; set; }
public string Redion { get; set; }
public string Region { get; set; }
public int FirstOffset { get; set; }
public int LastOffset { get; set; }

public FileDecodeOffset(string Name,string region, int FirstOffset, int LastOffset)
{
this.Name = Name;
this.Redion = region;
this.Region = region;
this.FirstOffset = FirstOffset;
this.LastOffset = LastOffset;
}
Expand Down Expand Up @@ -190,9 +187,9 @@ private void OpenFile(string file)
catch(Exception e)
{
MessageBox.Show(e.Message,
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
editor.MdiParent = this;
Expand Down Expand Up @@ -491,15 +488,6 @@ private void TextPreviewToolStripMenuItem_Click(object sender, EventArgs e)
editor.TextPreview.Show();
editor.TextPreview.WindowState = FormWindowState.Normal;


//Editor editor = ((Editor)this.ActiveMdiChild);
//string[] text = new string[1] { "54-65-73-74" };
//text = editor.GetAllHexText();

//UjlTextPreview textPreview = new UjlTextPreview(text);
//textPreview.MdiParent = this;
//textPreview.Show();
//textPreview.WindowState = FormWindowState.Normal;
}
}
}
Expand Down Expand Up @@ -542,5 +530,23 @@ private void AdvancedModeToolStripMenuItem_CheckStateChanged(object sender, Even
}

}

private void SearchToolStripMenuItem_Click(object sender, EventArgs e)
{
if (this.MdiChildren.Length > 0 & this.ActiveMdiChild != null)
{
if (this.ActiveMdiChild.Name == "Editor")
{
Editor editor = ((Editor)this.ActiveMdiChild);

TextSearch textSearch = new TextSearch(editor);
textSearch.Text = editor.FileName;
textSearch.MdiParent = this;
textSearch.Show();
textSearch.WindowState = FormWindowState.Normal;

}
}
}
}
}
2 changes: 1 addition & 1 deletion ujlptr_subedit/Properties/BuildInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ internal class BuildInfo
public const string Description = "Um Jammer Lammy & Parappa The Rapper Subtitle Editor";
public const string Author = "REDcat";
public const string Company = "https://github.com/RED1cat/UjlSubEdit";
public const string Version = "3.0.0";
public const string Version = "3.1.0";
}
}
Loading

0 comments on commit d24868d

Please sign in to comment.