diff options
author | Vittorio Romeo <vittorio.romeo@outlook.com> | 2020-06-16 22:21:58 +0100 |
---|---|---|
committer | Vittorio Romeo <vittorio.romeo@outlook.com> | 2020-06-16 22:21:58 +0100 |
commit | bc1687d31195318af75015890fd4113dfdbfb5df (patch) | |
tree | 9a58a7b16416903e33b6411546d8066b21310d8f | |
parent | 5292aceff5e485bad9ea3da6624e0e723c85ca3e (diff) |
Add global and per-level option to disable darkening of uneven background side chunksdarken_uneven_bg_option
-rw-r--r-- | _RELEASE/config.json | 1 | ||||
-rw-r--r-- | include/SSVOpenHexagon/Data/LevelData.hpp | 2 | ||||
-rw-r--r-- | include/SSVOpenHexagon/Data/StyleData.hpp | 3 | ||||
-rw-r--r-- | include/SSVOpenHexagon/Global/Config.hpp | 2 | ||||
-rw-r--r-- | src/SSVOpenHexagon/Core/HGGraphics.cpp | 2 | ||||
-rw-r--r-- | src/SSVOpenHexagon/Core/HGScripting.cpp | 4 | ||||
-rw-r--r-- | src/SSVOpenHexagon/Core/MenuGame.cpp | 10 | ||||
-rw-r--r-- | src/SSVOpenHexagon/Data/StyleData.cpp | 17 | ||||
-rw-r--r-- | src/SSVOpenHexagon/Global/Config.cpp | 10 |
9 files changed, 40 insertions, 11 deletions
diff --git a/_RELEASE/config.json b/_RELEASE/config.json index d908cad5..37ed9371 100644 --- a/_RELEASE/config.json +++ b/_RELEASE/config.json @@ -8,6 +8,7 @@ "auto_zoom_factor" : true,
"beatpulse_enabled" : true,
"black_and_white" : false,
+ "darken_uneven_background_chunk" : true,
"debug" : false,
"draw_text_outlines" : false,
"flash_enabled" : true,
diff --git a/include/SSVOpenHexagon/Data/LevelData.hpp b/include/SSVOpenHexagon/Data/LevelData.hpp index bb481e53..447bed39 100644 --- a/include/SSVOpenHexagon/Data/LevelData.hpp +++ b/include/SSVOpenHexagon/Data/LevelData.hpp @@ -64,7 +64,7 @@ namespace hg int cameraShake{0}; unsigned int sides{6}, sidesMax{6}, sidesMin{6}; bool swapEnabled{false}, tutorialMode{false}, incEnabled{true}, - rndSideChangesEnabled{true}; + rndSideChangesEnabled{true}, darkenUnevenBackgroundChunk{true}; SizeT currentIncrements{0u}, maxIncrements{ssvu::NumLimits<SizeT>::max()}; diff --git a/include/SSVOpenHexagon/Data/StyleData.hpp b/include/SSVOpenHexagon/Data/StyleData.hpp index a02a0ca6..048c45a7 100644 --- a/include/SSVOpenHexagon/Data/StyleData.hpp +++ b/include/SSVOpenHexagon/Data/StyleData.hpp @@ -9,6 +9,7 @@ namespace hg { + class LevelStatus; class StyleData { private: @@ -98,7 +99,7 @@ namespace hg void update(FT mFT, float mMult = 1.f); void computeColors(); void drawBackground(sf::RenderTarget& mRenderTarget, - const Vec2f& mCenterPos, unsigned int mSides); + const Vec2f& mCenterPos, const LevelStatus& levelStatus); void setRootPath(const Path& mPath) { rootPath = mPath; } diff --git a/include/SSVOpenHexagon/Global/Config.hpp b/include/SSVOpenHexagon/Global/Config.hpp index 4dde1e9c..1285d7d4 100644 --- a/include/SSVOpenHexagon/Global/Config.hpp +++ b/include/SSVOpenHexagon/Global/Config.hpp @@ -52,6 +52,7 @@ namespace hg void setMouseVisible(bool mValue); void setMusicSpeedMult(float mValue); void setDrawTextOutlines(bool mX); + void setDarkenUnevenBackgroundChunk(bool mX); void setRotateToStart(bool mX); bool getOnline(); @@ -108,6 +109,7 @@ namespace hg bool getMouseVisible(); float getMusicSpeedMult(); bool getDrawTextOutlines(); + bool getDarkenUnevenBackgroundChunk(); ssvs::Input::Trigger getTriggerRotateCCW(); ssvs::Input::Trigger getTriggerRotateCW(); diff --git a/src/SSVOpenHexagon/Core/HGGraphics.cpp b/src/SSVOpenHexagon/Core/HGGraphics.cpp index 4ec0af9f..7f1fbbe3 100644 --- a/src/SSVOpenHexagon/Core/HGGraphics.cpp +++ b/src/SSVOpenHexagon/Core/HGGraphics.cpp @@ -44,7 +44,7 @@ namespace hg if(!Config::getNoBackground()) { backgroundCamera.apply(); - styleData.drawBackground(window, ssvs::zeroVec2f, getSides()); + styleData.drawBackground(window, ssvs::zeroVec2f, levelStatus); } backgroundCamera.apply(); diff --git a/src/SSVOpenHexagon/Core/HGScripting.cpp b/src/SSVOpenHexagon/Core/HGScripting.cpp index 4459c190..38e88509 100644 --- a/src/SSVOpenHexagon/Core/HGScripting.cpp +++ b/src/SSVOpenHexagon/Core/HGScripting.cpp @@ -278,6 +278,10 @@ namespace hg { levelStatus.rndSideChangesEnabled = mValue; }); + lua.writeVariable("l_darkenUnevenBackgroundChunk", [=](bool mValue) + { + levelStatus.darkenUnevenBackgroundChunk = mValue; + }); lua.writeVariable("l_getRotationSpeed", [=] { return levelStatus.rotationSpeed; diff --git a/src/SSVOpenHexagon/Core/MenuGame.cpp b/src/SSVOpenHexagon/Core/MenuGame.cpp index fe8c5e4c..bac53c8a 100644 --- a/src/SSVOpenHexagon/Core/MenuGame.cpp +++ b/src/SSVOpenHexagon/Core/MenuGame.cpp @@ -294,6 +294,9 @@ namespace hg "show fps", &Config::getShowFPS, &Config::setShowFPS); gfx.create<i::Toggle>("text outlines", &Config::getDrawTextOutlines, &Config::setDrawTextOutlines); + gfx.create<i::Toggle>("darken uneven background chunk", + &Config::getDarkenUnevenBackgroundChunk, + &Config::setDarkenUnevenBackgroundChunk); gfx.create<i::GoBack>("back"); sfx.create<i::Toggle>( @@ -319,7 +322,7 @@ namespace hg sfx.create<i::Toggle>("sync music with difficulty", &Config::getMusicSpeedDMSync, &Config::setMusicSpeedDMSync) | whenMusicEnabled; - sfx.create<i::Slider>("music speed multipler", + sfx.create<i::Slider>("music speed multiplier", &Config::getMusicSpeedMult, [this](float mValue) { @@ -699,7 +702,8 @@ namespace hg "l_setWallSkewRight", "l_setWallAngleLeft", "l_setWallAngleRight", "l_setRadiusMin", "l_setSwapEnabled", "l_setTutorialMode", "l_setIncEnabled", - "l_enableRndSideChanges", "l_getSpeedMult", "l_getDelayMult", + "l_enableRndSideChanges", "l_darkenUnevenBackgroundChunk", + "l_getSpeedMult", "l_getDelayMult", "l_addTracked", "u_playSound", "u_isKeyPressed", "u_isFastSpinning", "u_forceIncrement", "u_kill", "u_eventKill", "m_messageAdd", "m_messageAddImportant", "t_wait", "t_waitS", @@ -1008,7 +1012,7 @@ namespace hg backgroundCamera.apply(); if(state == s::SMain) styleData.drawBackground( - window, ssvs::zeroVec2f, levelStatus.sides); + window, ssvs::zeroVec2f, levelStatus); overlayCamera.apply(); if(state == s::SMain) diff --git a/src/SSVOpenHexagon/Data/StyleData.cpp b/src/SSVOpenHexagon/Data/StyleData.cpp index 9d7b3562..1d48587f 100644 --- a/src/SSVOpenHexagon/Data/StyleData.cpp +++ b/src/SSVOpenHexagon/Data/StyleData.cpp @@ -114,23 +114,30 @@ namespace hg } void StyleData::drawBackground(RenderTarget& mRenderTarget, - const Vec2f& mCenterPos, unsigned int mSides) + const Vec2f& mCenterPos, const LevelStatus& levelStatus) { - float div{ssvu::tau / mSides * 1.0001f}, distance{4500}; + const auto sides = levelStatus.sides; + + float div{ssvu::tau / sides * 1.0001f}, distance{4500}; ssvs::VertexVector<sf::PrimitiveType::Triangles> vertices; - vertices.reserve(mSides * 3); + vertices.reserve(sides * 3); const auto& colors(getColors()); - for(auto i(0u); i < mSides; ++i) + for(auto i(0u); i < sides; ++i) { const float angle{div * i}; Color currentColor{ssvu::getByModIdx(colors, i)}; + const bool darkenUnevenBackgroundChunk = + (i % 2 == 0 && i == sides - 1) && + Config::getDarkenUnevenBackgroundChunk() && + levelStatus.darkenUnevenBackgroundChunk; + if(Config::getBlackAndWhite()) currentColor = Color::Black; - else if(i % 2 == 0 && i == mSides - 1) + else if(darkenUnevenBackgroundChunk) currentColor = getColorDarkened(currentColor, 1.4f); vertices.emplace_back(mCenterPos, currentColor); diff --git a/src/SSVOpenHexagon/Global/Config.cpp b/src/SSVOpenHexagon/Global/Config.cpp index b808d3e4..613786c1 100644 --- a/src/SSVOpenHexagon/Global/Config.cpp +++ b/src/SSVOpenHexagon/Global/Config.cpp @@ -72,6 +72,8 @@ namespace hg auto& mouseVisible(lvm.create<bool>("mouse_visible")); auto& musicSpeedMult(lvm.create<float>("music_speed_mult")); auto& drawTextOutlines(lvm.create<bool>("draw_text_outlines")); + auto& darkenUnevenBackgroundChunk( + lvm.create<bool>("darken_uneven_background_chunk")); auto& rotateToStart(lvm.create<bool>("rotate_to_start")); auto& triggerRotateCCW(lvm.create<Trigger>("t_rotate_ccw")); auto& triggerRotateCW(lvm.create<Trigger>("t_rotate_cw")); @@ -314,6 +316,10 @@ namespace hg void setMouseVisible(bool mValue) { mouseVisible = mValue; } void setMusicSpeedMult(float mValue) { musicSpeedMult = mValue; } void setDrawTextOutlines(bool mX) { drawTextOutlines = mX; } + void setDarkenUnevenBackgroundChunk(bool mX) + { + darkenUnevenBackgroundChunk = mX; + } void setRotateToStart(bool mX) { rotateToStart = mX; } bool SSVU_ATTRIBUTE(pure) getOnline() { return online; } @@ -446,6 +452,10 @@ namespace hg { return drawTextOutlines; } + bool SSVU_ATTRIBUTE(pure) getDarkenUnevenBackgroundChunk() + { + return darkenUnevenBackgroundChunk; + } bool SSVU_ATTRIBUTE(pure) getRotateToStart() { return rotateToStart; } Trigger getTriggerRotateCCW() { return triggerRotateCCW; } |