internal static void UpdateSelection() { int Count = (StrList.Items.Count / 8) + (StrList.Items.Count % 8); byte[] Booleans = new byte[Count]; for (int i = 0, b = 0; i < Booleans.Length; i++, b += 8) { byte Byt = 0; /*1, 2, 4, 8, 16, 32, 64, 128*/ for (int loop = 0, multiple = 1; loop < 8; loop++) { if (b + loop < StrList.Items.Count && StrList.GetItemChecked(b + loop)) { Byt |= (byte)multiple; } multiple *= 2; } Booleans[i] = Byt; } File.WriteAllBytes(TableName, Booleans); }
internal static void UpdateInfo(int value, ref Label InfoLbl, int BackupFreq, ref int Changes, bool TestIndex, out int DialogueIndex) { DialogueIndex = -1; if (StrList.Items.Count == 0) { InfoLbl.Text = string.Empty; return; } if (value < 0) { InfoLbl.Text = LoadTranslation(TLID.NoChangeDialogueNow); return; } bool CanJump = true; if (value == StrList.Items.Count) { Changes = 0; InfoLbl.Text = LoadTranslation(TLID.Congratulation) + ": " + LoadTranslation(TLID.ScriptComplete); MessageBox.Show(LoadTranslation(TLID.ScriptComplete), LoadTranslation(TLID.Congratulation), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } while (CanJump && !StrList.GetItemChecked(value) && TestIndex) { if (StrList.SelectedIndex < value) { value++; } else { value--; } CanJump = value < StrList.Items.Count && value > 0; } if (!CanJump) { if (value == StrList.Items.Count) { Changes = 0; InfoLbl.Text = LoadTranslation(TLID.Congratulation) + ": " + LoadTranslation(TLID.ScriptComplete); MessageBox.Show(LoadTranslation(TLID.ScriptComplete), LoadTranslation(TLID.Congratulation), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { return; } } bool Changing = StrList.SelectedIndex != value; StrList.SelectedIndex = value; //Prevent Spellcheck reset without changes if (Changing) { string OriDialogue = StrList.Items[value].ToString(); if (CanReload(OriDialogue)) { string NewDialogue = ReloadString(OriDialogue); if (NewDialogue != OriDialogue) { TextBox.Text = NewDialogue; TextBox.ResetCache(); } } else if (TextBox.Text != OriDialogue) { TextBox.Text = OriDialogue; DialogueIndex = value; } } int Pos = TestIndex ? GetPos(StrList, value) : value; int Total = TestIndex ? StrList.CheckedItems.Count : StrList.Items.Count; int Progress = (Pos * 100) / Total; string Freq = BackupFreq < 0 || string.IsNullOrEmpty(UserAccount.Name) || UserAccount.Name == "Anon" ? "Off" : (BackupFreq - Changes).ToString(); if (BackupFreq > 0 && Changes == BackupFreq) { Changes = 0; string[] Strs = new string[StrList.Items.Count]; for (int i = 0; i < Strs.Length; i++) { Strs[i] = StrList.Items[i].ToString(); } //Multi-Thread Backup (new System.Threading.Thread((arg) => { Backup((string[])arg); })).Start(Strs); } InfoLbl.Text = string.Format(LoadTranslation(TLID.InfoMask), Pos, Total, Progress, Freq); }
internal static bool SearchNext(string Content, bool WithContains, bool Up, bool CaseSensentive, bool Loop, bool CheckNonDialog, bool NoMsg, bool NoRerty = false) { int Len = CheckNonDialog ? StrList.Items.Count : StrList.CheckedItems.Count; string[] Strings = new string[Len]; int[] Indexs = new int[Len]; for (int ind = 0, count = 0, diff = StrList.Items.Count; ind < StrList.Items.Count; ind++) { if (CheckNonDialog || StrList.GetItemChecked(ind)) { Strings[count] = StrList.Items[ind].ToString(); Indexs[count++] = ind; } } int i = StrList.SelectedIndex + (Up ? 1 : -1); if (i < 0) { i = 0; } if (i >= StrList.Items.Count) { i = StrList.Items.Count - 1; } for (int ind = i; ind < StrList.Items.Count && ind > 0; ind += Up ? 1 : -1) { if (CheckNonDialog || StrList.GetItemChecked(ind)) { for (int j = 0; j < Indexs.Length; j++) { if (Indexs[j] == ind) { i = j; break; } } break; } } i = Search(Content, Strings, i, WithContains, Up, CaseSensentive, Loop); bool Found = i > -1; if (!Found) { if (!NoMsg) { MessageBox.Show(LoadTranslation(TLID.NoMatchFound), "VNXTLP", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { i = Indexs[i]; StrList.SetItemChecked(i, true); Index = i; string Text = CaseSensentive ? TextBox.Text : TextBox.Text.ToLower(); int IO = Text.IndexOf(CaseSensentive ? Content : Content.ToLower()); if (IO < 0 && !NoRerty) { System.Threading.Thread.Sleep(500); return(SearchNext(Content, WithContains, Up, CaseSensentive, Loop, CheckNonDialog, NoMsg, true)); } TextBox.Select(IO, Content.Length); TextBox.Focus(); } return(Found); }