fixed swiping back and forth causing issues sometimes
This commit is contained in:
parent
4b6e22dcb7
commit
c1438464cd
1 changed files with 12 additions and 13 deletions
|
@ -338,14 +338,18 @@ namespace TouchyTickets {
|
|||
} else if (!this.finishingSwipe && this.swipeProgress != 0 && !MlemGame.Input.TouchState.Any()) {
|
||||
// if we're not dragging or holding, we need to move back to our current ui
|
||||
this.swipeProgress -= Math.Sign(this.swipeProgress) * 0.03F;
|
||||
if (this.swipeProgress.Equals(0, 0.03F))
|
||||
this.ResetSwipe();
|
||||
if (this.swipeProgress.Equals(0, 0.03F)) {
|
||||
this.currentUi.Root.Transform = Matrix.Identity;
|
||||
this.finishingSwipe = false;
|
||||
this.swipeProgress = 0;
|
||||
}
|
||||
}
|
||||
|
||||
var next = -1;
|
||||
if (this.swipeProgress != 0) {
|
||||
// actual swipe reaction logic
|
||||
var curr = Array.IndexOf(this.swipeRelations, this.currentUi);
|
||||
var next = curr + Math.Sign(this.swipeProgress);
|
||||
next = curr + Math.Sign(this.swipeProgress);
|
||||
if (next >= 0 && next < this.swipeRelations.Length) {
|
||||
this.swipeRelations[next].IsHidden = false;
|
||||
// if we've swiped a bit, we count this as a success and move to the next ui
|
||||
|
@ -357,7 +361,9 @@ namespace TouchyTickets {
|
|||
// we're done with the swipe, so switch the active ui
|
||||
if (this.swipeProgress.Equals(Math.Sign(this.swipeProgress), 0.05F)) {
|
||||
this.currentUi = this.swipeRelations[next];
|
||||
this.ResetSwipe();
|
||||
this.currentUi.Root.Transform = Matrix.Identity;
|
||||
this.finishingSwipe = false;
|
||||
this.swipeProgress = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -370,6 +376,8 @@ namespace TouchyTickets {
|
|||
if (next >= 0 && next < this.swipeRelations.Length)
|
||||
this.swipeRelations[next].Root.Transform = Matrix.CreateTranslation((Math.Sign(this.swipeProgress) - this.swipeProgress) * this.swipeRelations[next].DisplayArea.Width, 0, 0);
|
||||
}
|
||||
for (var i = 0; i < this.swipeRelations.Length; i++)
|
||||
this.swipeRelations[i].IsHidden = i != next && this.swipeRelations[i] != this.currentUi;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,15 +418,6 @@ namespace TouchyTickets {
|
|||
this.uiSystem.Remove(splash.Root.Name);
|
||||
}
|
||||
|
||||
private void ResetSwipe() {
|
||||
this.finishingSwipe = false;
|
||||
this.swipeProgress = 0;
|
||||
foreach (var element in this.swipeRelations) {
|
||||
element.IsHidden = element != this.currentUi;
|
||||
element.Root.Transform = Matrix.Identity;
|
||||
}
|
||||
}
|
||||
|
||||
private void FadeUi(bool fadeOut, Action after = null) {
|
||||
IEnumerator<IWait> Impl() {
|
||||
// disable input handling during fade
|
||||
|
|
Loading…
Reference in a new issue