Skip to content

Commit

Permalink
Allow setting notefieldheight (yreverseoffsetpixels) from lua xnode
Browse files Browse the repository at this point in the history
  • Loading branch information
poco0317 committed Jan 26, 2021
1 parent 8063385 commit 9482760
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/Etterna/Actor/Gameplay/NoteFieldPreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Etterna/Singletons/ThemeManager.h"

#include <cmath>
#include <limits>

REGISTER_ACTOR_CLASS(NoteFieldPreview);

Expand All @@ -34,18 +35,29 @@ NoteFieldPreview::LoadFromNode(const XNode* pNode)
m_iDrawDistanceBeforeTargetsPixels =
THEME->GetMetricI("Player", "DrawDistanceBeforeTargetsPixels");
else
m_iDrawDistanceBeforeTargetsPixels = std::clamp(iDrawBefore, 0, INT_MAX);
m_iDrawDistanceBeforeTargetsPixels =
std::clamp(iDrawBefore, 0, std::numeric_limits<int>::max());
if (!afsuccess)
m_iDrawDistanceAfterTargetsPixels =
THEME->GetMetricI("Player", "DrawDistanceAfterTargetsPixels");
else
m_iDrawDistanceAfterTargetsPixels = std::clamp(iDrawAfter, INT_MIN, 0);

// for NoteField height
// 100 is a kind of typical number
const float yReverse = THEME->GetMetricF("Player", "ReceptorArrowsYReverse");
const float yStandard = THEME->GetMetricF("Player", "ReceptorArrowsYStandard");
const float noteFieldHeight = yReverse - yStandard;
m_iDrawDistanceAfterTargetsPixels =
std::clamp(iDrawAfter, std::numeric_limits<int>::min(), 0);

float reversePixels, noteFieldHeight;
const auto reverseSuccess = pNode->GetAttrValue("YReverseOffsetPixels", reversePixels);
if (reverseSuccess)
noteFieldHeight =
std::clamp(reversePixels, 0.F, std::numeric_limits<float>::max());
else {
// for NoteField height
// 100 is a kind of typical number
const float yReverse =
THEME->GetMetricF("Player", "ReceptorArrowsYReverse");
const float yStandard =
THEME->GetMetricF("Player", "ReceptorArrowsYStandard");
noteFieldHeight = yReverse - yStandard;
}

m_pPlayerState = GAMESTATE->m_pPlayerState;
if (m_pPlayerState == nullptr) {
Expand Down

0 comments on commit 9482760

Please sign in to comment.