Skip to content

Commit

Permalink
Merge pull request #91 from jonadem/master
Browse files Browse the repository at this point in the history
Write correct speed even when returning to the OnePlayerScreen
  • Loading branch information
allan-simon authored Jan 21, 2020
2 parents e18bb4f + 360a428 commit afc90a1
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/screens/one_player_screen/one_player_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ void OnePlayerScreen::initSpeedLabel(const sf::RenderWindow &app) {
}
speedLabel.setFont(font);
speedLabel.setColor(sf::Color(200, 165, 0));
speedLabel.setString("speed: 1");
updateSpeedLabel();

float yPosition = app.getSize().y - SPACE_BUTTONS / 2;

Expand Down
3 changes: 2 additions & 1 deletion src/screens/select_track_screen/select_track_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ ScreenIndex SelectTrackScreen::run(
app.clear(BACKGROUND_COLOR);
app.draw(backButton);
app.draw(startGameButton);
for (const auto &trackBox : allTrackBoxes) {
for (auto &trackBox : allTrackBoxes) {
app.draw(trackBox);
trackBox.updatePlayChoiceLabel(context.tracksOptions);
}
app.display();

Expand Down
12 changes: 8 additions & 4 deletions src/screens/select_track_screen/track_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ TrackBox::TrackBox(

const std::string instrument("Instrument:");
const std::string notes("Notes:");
const std::string playChoice("Played automatically");
const unsigned BUTTON_PADDING = 15;
const unsigned CHARACTER_SIZE = 15;
const unsigned INTER_LINE_SPACE = 10;
Expand Down Expand Up @@ -141,18 +140,23 @@ TrackBox::TrackBox(




// init the part displaying the midi output used
playChoiceLabel.setFont(font);
playChoiceLabel.setCharacterSize(CHARACTER_SIZE);
playChoiceLabel.setString(playChoice);
// "playChoiceLabel.setString()" will be called when the track will have been chosen
playChoiceLabel.setPosition(
BUTTON_PADDING + ICON_WIDTH,
// we center text in the middle of the icon
CHOICE_LINE_Y + (ICON_WIDTH - CHARACTER_SIZE) / 2.0f
);
}

void TrackBox::updatePlayChoiceLabel(
linthesia::TrackOptions &trackOptions
) {
const std::string style = trackOptions.getStrStyle(trackId);
playChoiceLabel.setString(style);
}

/**
*
*/
Expand Down
4 changes: 4 additions & 0 deletions src/screens/select_track_screen/track_box.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class TrackBox : public sf::Drawable , public sf::Transformable {
linthesia::TrackOptions &TrackOptions
);

void updatePlayChoiceLabel(
linthesia::TrackOptions &TrackOptions)
;

private:
/**
*
Expand Down
4 changes: 4 additions & 0 deletions src/track_options/track_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ PlayStyle TrackOptions::getStyle(unsigned trackId) {
return trackidStyle[trackId];
}

const std::string TrackOptions::getStrStyle(unsigned trackId) {
return style2name[trackidStyle[trackId]];
}

/**
*
*/
Expand Down
2 changes: 2 additions & 0 deletions src/track_options/track_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class TrackOptions {
*/
PlayStyle getStyle(unsigned trackId);

const std::string getStrStyle(unsigned trackId);

private:
/**
* store the track style by trackId
Expand Down

0 comments on commit afc90a1

Please sign in to comment.