Skip to content

Commit

Permalink
Clang format updates for background darkening option
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutzzz committed Oct 13, 2022
1 parent 86928f6 commit 564a266
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 35 deletions.
6 changes: 3 additions & 3 deletions src/engine/map_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void MapRenderer::renderBackground(
{
if (backColorMod < 1.0f)
{
//const auto saved = renderer::saveState(mpRenderer);
// const auto saved = renderer::saveState(mpRenderer);
mpRenderer->setColorModulation(base::Color{
base::roundTo<uint8_t, float>(255 * backColorMod),
base::roundTo<uint8_t, float>(255 * backColorMod),
Expand All @@ -311,7 +311,7 @@ void MapRenderer::renderForeground(
{
if (foreColorMod < 1.0f)
{
//const auto saved = renderer::saveState(mpRenderer);
// const auto saved = renderer::saveState(mpRenderer);
mpRenderer->setColorModulation(base::Color{
base::roundTo<uint8_t, float>(255 * foreColorMod),
base::roundTo<uint8_t, float>(255 * foreColorMod),
Expand Down Expand Up @@ -424,7 +424,7 @@ void MapRenderer::renderBackdrop(
{
if (dropColorMod < 1.0f)
{
//const auto saved = renderer::saveState(mpRenderer);
// const auto saved = renderer::saveState(mpRenderer);
mpRenderer->setColorModulation(base::Color{
base::roundTo<uint8_t, float>(255 * dropColorMod),
base::roundTo<uint8_t, float>(255 * dropColorMod),
Expand Down
12 changes: 4 additions & 8 deletions src/engine/sprite_rendering_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ void collectVisibleSprites(
engine::interpolatedPixelPosition(
previousTopLeft, topLeft, interpolationFactor),
data::tilesToPixels(frame.mDimensions)};
const auto drawSpec =
SpriteDrawSpec{destRect, frame.mImageId, flashingWhite, useCloakEffect, background};
const auto drawSpec = SpriteDrawSpec{
destRect, frame.mImageId, flashingWhite, useCloakEffect, background};

output.push_back({drawSpec, drawOrder, drawTopmost});
};
Expand Down Expand Up @@ -216,11 +216,7 @@ void collectVisibleSprites(

const auto useCloakEffect = sprite.mUseCloakEffect;
const auto drawSpec = SpriteDrawSpec{
destRect,
frame.mImageId,
false,
useCloakEffect,
background};
destRect, frame.mImageId, false, useCloakEffect, background};
output.push_back({drawSpec, drawOrder, drawTopmost});
}
});
Expand Down Expand Up @@ -420,7 +416,7 @@ void SpriteRenderingSystem::renderSprite(
{
if (colorMod < 1.0f)
{
//const auto saved = renderer::saveState(mpRenderer);
// const auto saved = renderer::saveState(mpRenderer);
mpRenderer->setColorModulation(base::Color{
base::roundTo<uint8_t, float>(255 * colorMod),
base::roundTo<uint8_t, float>(255 * colorMod),
Expand Down
12 changes: 9 additions & 3 deletions src/engine/sprite_rendering_system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,15 @@ class SpriteRenderingSystem

bool cloakEffectSpritesVisible() const { return mCloakEffectSpritesVisible; }

void renderBackgroundSprites(const SpecialEffectsRenderer& fx, const float backColorMod) const;
void renderRegularSprites(const SpecialEffectsRenderer& fx, const float regColorMod) const;
void renderForegroundSprites(const SpecialEffectsRenderer& fx, const float foreColorMod) const;
void renderBackgroundSprites(
const SpecialEffectsRenderer& fx,
const float backColorMod) const;
void renderRegularSprites(
const SpecialEffectsRenderer& fx,
const float regColorMod) const;
void renderForegroundSprites(
const SpecialEffectsRenderer& fx,
const float foreColorMod) const;

private:
void renderSprite(
Expand Down
21 changes: 14 additions & 7 deletions src/frontend/user_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,13 +668,20 @@ data::GameOptions deserialize<data::GameOptions>(const nlohmann::json& json)
extractValueIfExists("quickSavingEnabled", result.mQuickSavingEnabled, json);
extractValueIfExists("skipIntro", result.mSkipIntro, json);
extractValueIfExists("motionSmoothing", result.mMotionSmoothing, json);
extractValueIfExists("foregroundSpriteBrightness", result.mForeSpriteBrightness, json);
extractValueIfExists("regularSpriteBrightness", result.mRegSpriteBrightness, json);
extractValueIfExists("backgroundSpriteBrightness", result.mBackSpriteBrightness, json);
extractValueIfExists("prisonerIsBackground", result.mPrisonerIsBackground, json);
extractValueIfExists("foregroundTileBrightness", result.mForeTileBrightness, json);
extractValueIfExists("backgroundTileBrightness", result.mBackTileBrightness, json);
extractValueIfExists("parallaxTileBrightness", result.mDropTileBrightness, json);
extractValueIfExists(
"foregroundSpriteBrightness", result.mForeSpriteBrightness, json);
extractValueIfExists(
"regularSpriteBrightness", result.mRegSpriteBrightness, json);
extractValueIfExists(
"backgroundSpriteBrightness", result.mBackSpriteBrightness, json);
extractValueIfExists(
"prisonerIsBackground", result.mPrisonerIsBackground, json);
extractValueIfExists(
"foregroundTileBrightness", result.mForeTileBrightness, json);
extractValueIfExists(
"backgroundTileBrightness", result.mBackTileBrightness, json);
extractValueIfExists(
"parallaxTileBrightness", result.mDropTileBrightness, json);

removeInvalidKeybindings(result);

Expand Down
8 changes: 2 additions & 6 deletions src/game_logic/game_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,9 +1015,7 @@ void GameWorld::drawMapAndSprites(
params.mViewportSize,
mpOptions->mBackTileBrightness);
state.mDynamicGeometrySystem.renderDynamicBackgroundSections(
params.mRenderStartPosition,
params.mViewportSize,
interpolationFactor);
params.mRenderStartPosition, params.mViewportSize, interpolationFactor);
state.mSpriteRenderingSystem.renderBackgroundSprites(
mSpecialEffects, mpOptions->mBackSpriteBrightness);
state.mSpriteRenderingSystem.renderRegularSprites(
Expand All @@ -1030,9 +1028,7 @@ void GameWorld::drawMapAndSprites(
params.mViewportSize,
mpOptions->mForeTileBrightness);
state.mDynamicGeometrySystem.renderDynamicForegroundSections(
params.mRenderStartPosition,
params.mViewportSize,
interpolationFactor);
params.mRenderStartPosition, params.mViewportSize, interpolationFactor);
state.mSpriteRenderingSystem.renderForegroundSprites(
mSpecialEffects, mpOptions->mForeSpriteBrightness);
renderTileDebris();
Expand Down
16 changes: 8 additions & 8 deletions src/ui/options_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,13 @@ void OptionsMenu::updateAndRender(engine::TimeDelta dt)
ImGui::NewLine();
}
ImGui::Checkbox(
"Prisoner monster is background sprite", &mpOptions->mPrisonerIsBackground);
if ((!mpOptions->mPrisonerIsBackground &&
mpOptions->mRegSpriteBrightness != mpOptions->mBackTileBrightness) ||
"Prisoner monster is background sprite",
&mpOptions->mPrisonerIsBackground);
if (
(!mpOptions->mPrisonerIsBackground &&
mpOptions->mRegSpriteBrightness != mpOptions->mBackTileBrightness) ||
(mpOptions->mPrisonerIsBackground &&
mpOptions->mBackSpriteBrightness != mpOptions->mBackTileBrightness))
mpOptions->mBackSpriteBrightness != mpOptions->mBackTileBrightness))
{
ImGui::Spacing();
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.0f, 0.0f, 1.0f));
Expand Down Expand Up @@ -909,10 +911,8 @@ void OptionsMenu::updateAndRender(engine::TimeDelta dt)
ImGui::EndDisabled();
}

ImGui::Checkbox(
"Quick saving", &mpOptions->mQuickSavingEnabled);
ImGui::Checkbox(
"Skip intro sequence", &mpOptions->mSkipIntro);
ImGui::Checkbox("Quick saving", &mpOptions->mQuickSavingEnabled);
ImGui::Checkbox("Skip intro sequence", &mpOptions->mSkipIntro);
ImGui::Checkbox(
"Smooth scrolling & movement", &mpOptions->mMotionSmoothing);
ImGui::EndTabItem();
Expand Down

0 comments on commit 564a266

Please sign in to comment.