Skip to content

Commit

Permalink
Add centering back into edit/practice mode playback.
Browse files Browse the repository at this point in the history
  • Loading branch information
bwaggone committed Sep 29, 2024
1 parent 25f1beb commit 886ca65
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/EditModePlayerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ void EditModePlayerManager::AddPlayers(const NoteData& note_data) {
player->SetY(SCREEN_CENTER_Y);
player->SetZoom(SCREEN_HEIGHT / 480);
StyleType style_type = GAMESTATE->GetCurrentStyle(pn)->m_StyleType;
if (center_) {
// Use the doubles style positioning for centering.
style_type = StyleType_OnePlayerTwoSides;
}
player->SetX(THEME->GetMetricF("ScreenGameplay", ssprintf("PlayerP%d%sX", pn + 1, StyleTypeToString(style_type).c_str())));
}

Expand Down
5 changes: 4 additions & 1 deletion src/EditModePlayerManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
class EditModePlayerManager
{
public:

// Adds players based on the current gamestate.
void AddPlayers(const NoteData& note_data);

Expand All @@ -43,7 +42,11 @@ class EditModePlayerManager
// Play assist ticks.
void PlayTicks(GameplayAssist& gameplay_assist);

// Sets the "center" boolean, for centering the notefield.
void SetCenter(bool center) { center_ = center; }

private:
// All players that the manager is looking at. Indexable by PlayerNumber.
std::unordered_map<PlayerNumber, std::shared_ptr<PlayerPlus>> players_;
bool center_;
};
21 changes: 21 additions & 0 deletions src/ScreenEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,27 @@ void ScreenEdit::Init()
SetDirty(true);
}


// There are two conditions for centering the notefield.
// 1. We're in EditMode
// 2. We're in PracticeMode, the preference is enabled,
// sylte is OnePlayerOneSide, and the theme allows it.
//
// If the "center_enabled" check is modified, also modify
// ScreenGameplay::Center1Player().
ThemeMetric<bool> allow_center;
allow_center.Load("ScreenGameplay", "AllowCenter1Player");
bool center_enabled = (Preference<bool>::GetPreferenceByName("Center1Player")->Get()
&& GAMESTATE->GetCurrentStyle(PLAYER_INVALID)->m_StyleType
== StyleType_OnePlayerOneSide)
&& GAMESTATE->m_PlayMode != PLAY_MODE_BATTLE
&& GAMESTATE->m_PlayMode != PLAY_MODE_RAVE
&& allow_center;

bool edit_mode_screen = (m_sName == "ScreenEdit");

player_manager_.SetCenter(edit_mode_screen || center_enabled);

player_manager_.AddPlayers(m_NoteDataEdit);
player_manager_.AddPlayersToActorFrame(*this);

Expand Down
6 changes: 5 additions & 1 deletion src/ScreenGameplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,11 @@ bool ScreenGameplay::Center1Player() const
/* Perhaps this should be handled better by defining a new
* StyleType for ONE_PLAYER_ONE_CREDIT_AND_ONE_COMPUTER,
* but for now just ignore Center1Player when it's Battle or Rave
* Mode. This doesn't begin to address two-player solo (6 arrows) */
* Mode. This doesn't begin to address two-player solo (6 arrows)
*
* If this check is modified, also modify the center check in
* ScreenEdit::Init().
*/
return g_bCenter1Player &&
(bool)ALLOW_CENTER_1_PLAYER &&
GAMESTATE->m_PlayMode != PLAY_MODE_BATTLE &&
Expand Down

0 comments on commit 886ca65

Please sign in to comment.