Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
dustdustinthewind committed Jan 27, 2020
2 parents a57b56c + dfeeabc commit bdf6f8d
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 36 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.3.2-alpha] - 2020-01-27

### Changed
- Backspace gets rid of the last character instead of clearing the searchbox.
- Pressing escape clears the searchbox if there is text in it. When there's no text, pressing escape quits to the main menu.

### Fixed
- Searchbox entering the names of keys instead of proper typing (i.e. "space", "leftalt")
- Positioning of the elements on ScoreCards and the Grade on the result screen.
- Leaderboards only showing at max the same amount of ranks as there were beatmap cards on the screen.

## [1.3.1-alpha] - 2020-01-26

### Fixed
Expand Down Expand Up @@ -88,7 +99,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Leaderboard for past scores


[unreleased]: https://github.com/PulsarcGame/Pulsarc/compare/v1.3.1-alpha...HEAD
[unreleased]: https://github.com/PulsarcGame/Pulsarc/compare/v1.3.2-alpha...HEAD
[1.3.2-alpha]: https://github.com/PulsarcGame/Pulsarc/compare/v1.3.1-alpha...v1.3.2-alpha
[1.3.1-alpha]: https://github.com/PulsarcGame/Pulsarc/compare/v1.3.0-alpha...v1.3.1-alpha
[1.3.0-alpha]: https://github.com/PulsarcGame/Pulsarc/compare/v1.2.0-alpha...v1.3.0-alpha
[1.2.0-alpha]: https://github.com/PulsarcGame/Pulsarc/compare/v1.1.1-alpha...v1.2.0-alpha
Expand Down
4 changes: 2 additions & 2 deletions Pulsarc/Skins/DefaultSkin/UI/ResultScreen/result_screen.ini
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ ComboY = 390
GradeAnchor = Center
GradeStartPos = Center
GradeScale = 0.7
GradeX = 25
GradeX = 40
GradeY = 130

;HitError
HitErrorAnchor = TopLeft
HitErrorStartPos = TopLeft
Expand Down
10 changes: 5 additions & 5 deletions Pulsarc/Skins/DefaultSkin/UI/SongSelect/song_select.ini
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ GradeAnchor = Center
GradeStartPos = CenterLeft
GradeScale = .3
GradeX = 180
GradeY = 25
GradeY = 30

;Rank
RankAnchor = CenterLeft
Expand All @@ -96,31 +96,31 @@ ScoreAnchor = TopLeft
ScoreStartPos = TopLeft
ScoreFontSize = 30
ScoreColor = 255,255,255
ScoreX = 260
ScoreX = 300
ScoreY = 50

;Accuracy
AccAnchor = CenterRight
AccStartPos = CenterRight
AccFontSize = 30
AccColor = 255,255,255
AccX = -75
AccX = -100
AccY = 0

;Combo
ComboAnchor = TopLeft
ComboStartPos = TopLeft
ComboFontSize = 20
ComboColor = 255,255,255
ComboX = 260
ComboX = 300
ComboY = 90

;Rate
RateAnchor = TopLeft
RateStartPos = TopLeft
RateFontSize = 30
RateColor = 255,255,255
RateX = 160
RateX = 200
RateY = 50

;Username
Expand Down
16 changes: 11 additions & 5 deletions Pulsarc/UI/Screens/Gameplay/UI/TextDisplayElementFixedSize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ public class TextDisplayElementFixedSize : TextDisplayElement
/// <param name="append">String to be appended to the displayed value</param>
/// <param name="fontSize">The size to be used for drawing the font</param>
/// <param name="anchor">The anchor</param>
public TextDisplayElementFixedSize(string name, Vector2 position, string append, int fontSize = 18, Anchor anchor = Anchor.Center, Color? color = null)
: base (name, position, fontSize, anchor, color)
{
this.append = append;
}
public TextDisplayElementFixedSize
(
string name,
Vector2 position,
string append,
int fontSize = 18,
Anchor anchor = Anchor.Center,
Color? color = null
)
: base (name, position, fontSize, anchor, color)
=> this.append = append;

/// <summary>
/// Update text to the provided string.
Expand Down
2 changes: 1 addition & 1 deletion Pulsarc/UI/Screens/Settings/UI/Slider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void SetSelector(int value)
/// </summary>
public void Update()
{
Title.Update(" : " + Math.Round(Value / (float)DisplayDivider, DisplayPrecision).ToString());
Title.RestartThenAppend(" : " + Math.Round(Value / (float)DisplayDivider, DisplayPrecision).ToString());
}

public void SetSelectorPercent(float percent)
Expand Down
54 changes: 41 additions & 13 deletions Pulsarc/UI/Screens/SongSelect/SongSelection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class SongSelection : PulsarcScreen
public float SelectedFocus = 0;
public BeatmapCard FocusedCard { get; set; }

// The time when the last key was pressed
private double lastKeyPressTime;

// Returns true once a second has passed since the last RestartKeyPressTimer = true call
Expand Down Expand Up @@ -68,14 +69,20 @@ public override void Init()
/// </summary>
public void RefreshBeatmaps(string keyword = "")
{
keyword = keyword.ToLower();

List<Beatmap> beatmaps = new List<Beatmap>();
Cards = new List<BeatmapCard>();

List<BeatmapData> data = DataManager.BeatmapDB.GetBeatmaps();

for (int i = 0; i < data.Count; i++)
{
if (keyword == "" || data[i].Match(keyword))
{
beatmaps.Add(BeatmapHelper.LoadLight(data[i]));
}
}

// TODO: Allow user to choose sorting method.
beatmaps = SortBeatmaps(beatmaps, "difficulty");
Expand Down Expand Up @@ -167,10 +174,6 @@ private void HandleKeyboardPresses()

switch (press.Value)
{
// If Escape has been pressed, go back one screen.
case Keys.Escape:
ScreenManager.RemoveScreen(true);
break;
// If F5 has been pressed, refresh beatmaps
case Keys.F5:
RescanBeatmaps();
Expand All @@ -179,9 +182,18 @@ private void HandleKeyboardPresses()
case Keys.Enter:
FocusedCard.OnClick();
break;
// If Delete or Backspace is pressed, clear the search bar
// If Escape has been pressed with no text in the searchbox, go back one screen.
case Keys.Escape:
if (GetSongSelectionView().SearchBox.GetText().Length <= 0)
{
ScreenManager.RemoveScreen(true);
break;
}
// If there was text in the searchbox, fall through to Keys.Delete, which
// clears the box
goto case Keys.Delete;
// If Delete is pressed, clear the search bar
case Keys.Delete:
case Keys.Back:
// If there's nothing in the box, don't refresh.
if (GetSongSelectionView().SearchBox.GetText().Length <= 0)
{
Expand All @@ -191,31 +203,47 @@ private void HandleKeyboardPresses()
GetSongSelectionView().SearchBox.Clear();
RefreshBeatmaps();
break;
// If the backspace is pressed, delete the last character
case Keys.Back:
// Reset the timer
RestartKeyPressTimer = true;

GetSongSelectionView().SearchBox.DeleteLastCharacter();
break;
// If none of the above, type into the search bar
// TODO: Ignore keypressses like CTRL, SHIFT, ALT, etc
// TODO? Ignore keypresses unless clicked on
default:
if (!KeyboardManager.IsUniqueKeyPress(press.Value))
// If the press is not an acceptable typing character, or the key hasn't been
// released yet, break.
if (!XnaKeyHelper.IsTypingCharacter(press.Value)
|| !KeyboardManager.IsUniqueKeyPress(press.Value))
{
break;
}

// Reset the timer
RestartKeyPressTimer = true;

GetSongSelectionView().SearchBox.AddText(InputManager.Caps
? Enum.GetName(typeof(Keys), press.Value)
: Enum.GetName(typeof(Keys), press.Value).ToLower());
string key = XnaKeyHelper.GetStringFromKey(press.Value);

// If caps/shift isn't on, lowercase the text
if (!InputManager.Caps)
{
key = key.ToLower();
}

GetSongSelectionView().SearchBox.AddText(key);
break;
}
}

// If one second has passed since the last search box key press, refresh the maps.
if (OneSecondSinceLastKeyPress && RestartKeyPressTimer)
if (RestartKeyPressTimer && OneSecondSinceLastKeyPress)
{
// Don't call this block every frame
RestartKeyPressTimer = false;

RefreshBeatmaps(GetSongSelectionView().SearchBox.GetText().ToLower());
RefreshBeatmaps(GetSongSelectionView().SearchBox.GetText());
}
}

Expand Down
11 changes: 7 additions & 4 deletions Pulsarc/UI/Screens/SongSelect/SongSelectionView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,15 @@ public override void Draw(GameTime gameTime)
{
DrawBackgrounds();

for (int i = 0; i < cards.Count; i++)
// Keep things in one for-loop for optimization
for (int i = 0; i < Math.Max(cards.Count, scores.Count); i++)
{
cards[i].AdjustClickDistance();
cards[i].Draw();
if (i < cards.Count)
{
cards[i].AdjustClickDistance();
cards[i].Draw();
}

// Might as well through this here instead of having a second for loop taking up time.
if (i < scores.Count)
{
scores[i].Draw();
Expand Down
8 changes: 7 additions & 1 deletion Pulsarc/UI/Screens/SongSelect/UI/SearchBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ public SearchBox(string search, Vector2 position, Anchor anchor = Anchor.TopLeft

public void Clear() => textDisplay.Text.Clear();

public string GetText() => textDisplay.Text.ToString();
public string GetText() => textDisplay.CurrentText;

public void SetText(string text) => textDisplay.Update(text);

public void DeleteLastCharacter()
=> textDisplay.Update(
textDisplay.CurrentText.Substring(0, textDisplay.CurrentText.Length - 1));

public override void Draw()
{
Expand Down
28 changes: 25 additions & 3 deletions Pulsarc/UI/TextDisplayElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ namespace Pulsarc.UI
{
public class TextDisplayElement : Drawable
{
// The "name" of this TDE. This will be the starting text for the TDE, but it can be changed.
public string Name { get; set; }

// Gets the current text displayed by this TDE
public string CurrentText => Text.ToString();

// Text data
private SpriteFont font => AssetsManager.Fonts["DefaultFont"];
Expand Down Expand Up @@ -42,22 +46,40 @@ public TextDisplayElement(string name, Vector2 position, int fontSize = 18, Anch
// base.ChangePosition() avoids this crash.
base.ChangePosition(position);
processedPosition = TruePosition;
Update("");
Update(Name);
}

/// <summary>
/// Update the text with new text added to name.
/// Update the text to display the provided value.
/// </summary>
/// <param name="value">The text to change to</param>
public void Update(string value)
{
Text.Clear();
Text.Append(Name).Append(value);
Text.Append(value);
ReprocessPosition();

caught = false;
}

/// <summary>
/// Adds the provided value to the end of this TDE
/// </summary>
/// <param name="value"></param>
public void Append(string value) => Update(CurrentText + value);

/// <summary>
/// Restarts this TDE and changes the text to Name.
/// </summary>
public void RestartToName() => Update(Name);

/// <summary>
/// Clears the text, changes it to "Name + value";
/// The Old Update() method did something similar to this.
/// </summary>
/// <param name="value"></param>
public void RestartThenAppend(string value) => Update(Name + value);

/// <summary>
/// Reprocess the position of this TDE.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Pulsarc/UI/VersionCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Pulsarc.UI
{
public class VersionCounter : TextDisplayElement
{
private const string VERSION_NAME = "v1.3.1-alpha";
private const string VERSION_NAME = "v1.3.2-alpha";

// Temporary until we fix font shit.
private const int X_OFFSET = -22;
Expand Down

0 comments on commit bdf6f8d

Please sign in to comment.