Skip to content

Commit

Permalink
Partial text display minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirKhil committed Mar 18, 2024
1 parent bd75e4b commit 910e453
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/SICore/SICore/Clients/Game/GameLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2800,7 +2800,7 @@ private void PrintPartial()
var printingLength = newTextLength - _data.TextLength;

// Align to next space position
while (_data.TextLength + printingLength + 1 < text.Length && !char.IsWhiteSpace(text[_data.TextLength + printingLength]))
while (_data.TextLength + printingLength < text.Length && !char.IsWhiteSpace(text[_data.TextLength + printingLength]))
{
printingLength++;
}
Expand Down
16 changes: 12 additions & 4 deletions src/SIQuester/SIQuester/Controls/TextList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ private void OnItemsRemoved(NotifyCollectionChangedEventArgs e)

Select(start, end - start);
_infos.RemoveRange(e.OldStartingIndex, e.OldItems.Count);

if (_infos.Count != ItemsSource.Count)
{
throw new Exception($"_infos.Count != ItemsSource.Count (_infos.Count: {_infos.Count}, ItemsSource.Count: {ItemsSource.Count}, e.OldItems.Count: {e.OldItems.Count}");
}
}
finally
{
Expand Down Expand Up @@ -244,7 +249,7 @@ private void Check()
{
if (Text != ItemsSource[0].ToString())
{
MessageBox.Show("Ошибка редактирования! Обратитесь к разработчику.");
MessageBox.Show("Editing error. Send message to author");
SetText();
}
}
Expand Down Expand Up @@ -273,6 +278,11 @@ private void OnItemsAdded(NotifyCollectionChangedEventArgs e)
_infos.Insert(index++, new ItemInfo(toAdd.Length, isLink ? toAdd.Length : -1, canBeSpecified));
}

if (_infos.Count != ItemsSource.Count)
{
throw new Exception($"_infos.Count != ItemsSource.Count (_infos.Count: {_infos.Count}, ItemsSource.Count: {ItemsSource.Count}, e.NewItems.Count: {e.NewItems.Count}");
}

if (e.NewStartingIndex == 0 && index < _infos.Count)
{
text.Append(ItemsSeparator);
Expand Down Expand Up @@ -411,11 +421,9 @@ protected override void OnTextChanged(TextChangedEventArgs e)
return;
}

int index = 0;

foreach (var change in e.Changes)
{
var offset = ConvertGlobalOffsetToLocalOffset(change.Offset, out index);
var offset = ConvertGlobalOffsetToLocalOffset(change.Offset, out var index);

var origin = ItemsSource[index].ToString();
_blockNotificationsFlag = true;
Expand Down
2 changes: 1 addition & 1 deletion test/SIGame/SIGame.Tests/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"GameServerClient": {
"ServiceUri": "https://vladimirkhil.com/siserver/0/"
"ServiceUri": "https://vladimirkhil.com/sigameserver-0/api/v1/"
},
"SIStorageServiceClient": {
"ServiceUri": "https://vladimirkhil.com/sistorage/"
Expand Down

0 comments on commit 910e453

Please sign in to comment.