From b8477feaaf4960cb4df7acbf1558894b4cd3e62b Mon Sep 17 00:00:00 2001 From: fallahn Date: Sat, 2 Nov 2024 13:43:29 +0000 Subject: [PATCH] tweak scrub ui layout --- crogine/src/audio/OpenALImpl.cpp | 4 +- samples/golf/src/scrub/ScrubAttractState.cpp | 7 ++-- samples/golf/src/scrub/ScrubConsts.hpp | 2 +- samples/golf/src/scrub/ScrubGameState.cpp | 42 ++++++++------------ samples/golf/src/scrub/Shaders.inl | 9 ++++- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/crogine/src/audio/OpenALImpl.cpp b/crogine/src/audio/OpenALImpl.cpp index b99a64772..7f887954e 100644 --- a/crogine/src/audio/OpenALImpl.cpp +++ b/crogine/src/audio/OpenALImpl.cpp @@ -889,7 +889,9 @@ void OpenALImpl::refreshDeviceList() auto enumAvailable = alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT"); if (enumAvailable) { - const auto* deviceList = alcGetString(nullptr, ALC_DEVICE_SPECIFIER); + //ALC_DEVICE_SPECIFIER only returns basic device list (this is no good on steam deck) + //const auto* deviceList = alcGetString(nullptr, ALC_DEVICE_SPECIFIER); + const auto* deviceList = alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER); if (deviceList) { auto* next = deviceList + 1; diff --git a/samples/golf/src/scrub/ScrubAttractState.cpp b/samples/golf/src/scrub/ScrubAttractState.cpp index 4f9bc5eeb..a6c713f58 100644 --- a/samples/golf/src/scrub/ScrubAttractState.cpp +++ b/samples/golf/src/scrub/ScrubAttractState.cpp @@ -628,8 +628,7 @@ void ScrubAttractState::buildScene() m_tabs[TabID::Scores].getComponent().addChild(entity.getComponent()); // std::string temp = -//R"( -//Buns 123248974 +//R"(Buns 123248974 //Buns 123248974 //Buns 123248974 //Buns 123248974 @@ -656,7 +655,7 @@ void ScrubAttractState::buildScene() entity.getComponent().setShadowOffset(sc::SmallTextOffset); entity.addComponent().ID = CommandID::UI::UIElement; entity.addComponent().relativePosition = glm::vec2(0.5f); - entity.getComponent().absolutePosition = { 0.f, 120.f }; + entity.getComponent().absolutePosition = { 0.f, 100.f }; entity.getComponent().characterSize = sc::SmallTextSize; entity.getComponent().depth = sc::TextDepth; m_highScoreText = entity; @@ -921,7 +920,7 @@ void ScrubAttractState::onCachedPush() + " to insert and " + cro::Keyboard::keyString(m_sharedData.inputBinding.keys[InputBinding::NextClub]) + " to remove a ball\nUse " + cro::Keyboard::keyString(m_sharedData.inputBinding.keys[InputBinding::Left]) + "/" + cro::Keyboard::keyString(m_sharedData.inputBinding.keys[InputBinding::Right]) - + "to scrub the ball\nPress " + cro::Keyboard::keyString(m_sharedData.inputBinding.keys[InputBinding::Action]) + + " to scrub the ball\nPress " + cro::Keyboard::keyString(m_sharedData.inputBinding.keys[InputBinding::Action]) + " to add more soap\n\n\nPress ESCAPE to Pause the game"; diff --git a/samples/golf/src/scrub/ScrubConsts.hpp b/samples/golf/src/scrub/ScrubConsts.hpp index dce9b8b35..441821d36 100644 --- a/samples/golf/src/scrub/ScrubConsts.hpp +++ b/samples/golf/src/scrub/ScrubConsts.hpp @@ -73,7 +73,7 @@ static constexpr inline glm::uvec2 BucketTextureSize = glm::uvec2(468, 1280); static constexpr inline glm::uvec2 SoapTextureSize = glm::uvec2(80, 1440); //size of the level meters/bars -static constexpr inline float BarHeight = 400.f; +static constexpr inline float BarHeight = 406.f; static constexpr inline float BarWidth = 80.f; //how much to shift the pitch by when time is low diff --git a/samples/golf/src/scrub/ScrubGameState.cpp b/samples/golf/src/scrub/ScrubGameState.cpp index 9bf7c4245..6265c2a6b 100644 --- a/samples/golf/src/scrub/ScrubGameState.cpp +++ b/samples/golf/src/scrub/ScrubGameState.cpp @@ -446,8 +446,8 @@ bool ScrubGameState::simulate(float dt) auto oldTime = m_score.remainingTime; m_score.totalRunTime += dt; - m_score.remainingTime = std::max(m_score.remainingTime - dt, 0.f); #ifndef CRO_DEBUG_ + m_score.remainingTime = std::max(m_score.remainingTime - dt, 0.f); #endif switch (m_pitchStage) { @@ -556,28 +556,6 @@ void ScrubGameState::onCachedPush() m_soundDirector->playSound(AudioID::FXTextIntro, MixerChannel::Effects, 0.8f).getComponent().setPitch(0.5f); - ////reset the music volume - //auto entity = m_uiScene.createEntity(); - //entity.addComponent().active = true; - //entity.getComponent().setUserData(0.f); - //entity.getComponent().function = - // [&](cro::Entity e, float dt) - // { - // auto& ct = e.getComponent().getUserData(); - // ct = std::min(1.f, ct + dt); - - // cro::AudioMixer::setPrefadeVolume(ct, MixerChannel::Music); - - // if (ct == 1) - // { - // e.getComponent().active = false; - // m_uiScene.destroyEntity(e); - // } - // }; - - //cro::AudioMixer::setPrefadeVolume(0.f, MixerChannel::Music); - //m_music.getComponent().play(); - //choose a model at random if (cro::Util::Random::value(0, 1) == 0) @@ -1322,6 +1300,20 @@ void ScrubGameState::createUI() m_spriteRoot.getComponent().addChild(entity.getComponent()); + + //level bar background + entity = m_uiScene.createEntity(); + entity.addComponent(); + entity.addComponent(); + entity.addComponent(m_resources.textures.get("assets/arcade/scrub/images/ui_tubes.png")); + entity.addComponent().ID = CommandID::UI::UIElement; + entity.addComponent().relativePosition = { 1.f, 0.f }; + entity.getComponent().absolutePosition = { -340.f, 12.f }; + entity.getComponent().depth = sc::UIBackgroundDepth; + m_spriteRoot.getComponent().addChild(entity.getComponent()); + + + const auto createLevelMeter = [&](cro::Colour c) { @@ -1349,7 +1341,7 @@ void ScrubGameState::createUI() //soap level entity = createLevelMeter(SoapMeterColour); entity.getComponent().relativePosition = glm::vec2(1.f, 0.f); - entity.getComponent().absolutePosition = { -(BarWidth + 42.f), 12.f }; + entity.getComponent().absolutePosition = { -(BarWidth + 49.f), 38.f }; entity.addComponent().active = true; entity.getComponent().setUserData(1.f); entity.getComponent().function = @@ -1390,7 +1382,7 @@ void ScrubGameState::createUI() //current ball cleanliness entity = createLevelMeter(cro::Colour::Blue); entity.getComponent().relativePosition = glm::vec2(1.f, 0.f); - entity.getComponent().absolutePosition = { -((BarWidth + 42.f) * 2.f), 12.f }; + entity.getComponent().absolutePosition = { -((BarWidth + 46.f) * 2.f), 38.f }; entity.addComponent().active = true; entity.getComponent().function = [&](cro::Entity e, float dt) diff --git a/samples/golf/src/scrub/Shaders.inl b/samples/golf/src/scrub/Shaders.inl index f21b40d6a..60627eaf3 100644 --- a/samples/golf/src/scrub/Shaders.inl +++ b/samples/golf/src/scrub/Shaders.inl @@ -51,14 +51,21 @@ void main() //add distortion offset - using the colour accessors here because I can't find //a definitive answer whether the order is wxyz or xyzw float u = ((coord.x - u_uvRect.r) / u_uvRect.b); + float v = ((coord.y - u_uvRect.g) / u_uvRect.a); float highlight = smoothstep(0.55, 0.75, u); highlight *= 1.0 - smoothstep(0.78, 0.80, u); + float curve = sin(u * 3.141) * 0.01; + float shadow = mix(1.0, 0.75, smoothstep(0.948 + curve, 0.958 + curve, v)); + + u = pow(((u * 2.0) - 1.0), 3.0); coord.x += u * DistortionAmount; - FRAG_OUT = mix(TEXTURE(u_texture, coord), v_colour, 0.25 + (abs(u) * 0.3)) + vec4(highlight * HighlightAmount); + + FRAG_OUT = (mix(TEXTURE(u_texture, coord), v_colour, 0.25 + (abs(u) * 0.3)) * shadow) + vec4(highlight * HighlightAmount); + FRAG_OUT.a = 1.0; })"; static const inline std::string SoapFragment =