Skip to content

Commit

Permalink
tweak scrub ui layout
Browse files Browse the repository at this point in the history
  • Loading branch information
fallahn committed Nov 2, 2024
1 parent 31a9c38 commit b8477fe
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 32 deletions.
4 changes: 3 additions & 1 deletion crogine/src/audio/OpenALImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions samples/golf/src/scrub/ScrubAttractState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,7 @@ void ScrubAttractState::buildScene()
m_tabs[TabID::Scores].getComponent<cro::Transform>().addChild(entity.getComponent<cro::Transform>());

// std::string temp =
//R"(
//Buns 123248974
//R"(Buns 123248974
//Buns 123248974
//Buns 123248974
//Buns 123248974
Expand All @@ -656,7 +655,7 @@ void ScrubAttractState::buildScene()
entity.getComponent<cro::Text>().setShadowOffset(sc::SmallTextOffset);
entity.addComponent<cro::CommandTarget>().ID = CommandID::UI::UIElement;
entity.addComponent<UIElement>().relativePosition = glm::vec2(0.5f);
entity.getComponent<UIElement>().absolutePosition = { 0.f, 120.f };
entity.getComponent<UIElement>().absolutePosition = { 0.f, 100.f };
entity.getComponent<UIElement>().characterSize = sc::SmallTextSize;
entity.getComponent<UIElement>().depth = sc::TextDepth;
m_highScoreText = entity;
Expand Down Expand Up @@ -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";


Expand Down
2 changes: 1 addition & 1 deletion samples/golf/src/scrub/ScrubConsts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 17 additions & 25 deletions samples/golf/src/scrub/ScrubGameState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -556,28 +556,6 @@ void ScrubGameState::onCachedPush()

m_soundDirector->playSound(AudioID::FXTextIntro, MixerChannel::Effects, 0.8f).getComponent<cro::AudioEmitter>().setPitch(0.5f);

////reset the music volume
//auto entity = m_uiScene.createEntity();
//entity.addComponent<cro::Callback>().active = true;
//entity.getComponent<cro::Callback>().setUserData<float>(0.f);
//entity.getComponent<cro::Callback>().function =
// [&](cro::Entity e, float dt)
// {
// auto& ct = e.getComponent<cro::Callback>().getUserData<float>();
// ct = std::min(1.f, ct + dt);

// cro::AudioMixer::setPrefadeVolume(ct, MixerChannel::Music);

// if (ct == 1)
// {
// e.getComponent<cro::Callback>().active = false;
// m_uiScene.destroyEntity(e);
// }
// };

//cro::AudioMixer::setPrefadeVolume(0.f, MixerChannel::Music);
//m_music.getComponent<cro::AudioEmitter>().play();


//choose a model at random
if (cro::Util::Random::value(0, 1) == 0)
Expand Down Expand Up @@ -1322,6 +1300,20 @@ void ScrubGameState::createUI()
m_spriteRoot.getComponent<cro::Transform>().addChild(entity.getComponent<cro::Transform>());



//level bar background
entity = m_uiScene.createEntity();
entity.addComponent<cro::Transform>();
entity.addComponent<cro::Drawable2D>();
entity.addComponent<cro::Sprite>(m_resources.textures.get("assets/arcade/scrub/images/ui_tubes.png"));
entity.addComponent<cro::CommandTarget>().ID = CommandID::UI::UIElement;
entity.addComponent<UIElement>().relativePosition = { 1.f, 0.f };
entity.getComponent<UIElement>().absolutePosition = { -340.f, 12.f };
entity.getComponent<UIElement>().depth = sc::UIBackgroundDepth;
m_spriteRoot.getComponent<cro::Transform>().addChild(entity.getComponent<cro::Transform>());



const auto createLevelMeter =
[&](cro::Colour c)
{
Expand Down Expand Up @@ -1349,7 +1341,7 @@ void ScrubGameState::createUI()
//soap level
entity = createLevelMeter(SoapMeterColour);
entity.getComponent<UIElement>().relativePosition = glm::vec2(1.f, 0.f);
entity.getComponent<UIElement>().absolutePosition = { -(BarWidth + 42.f), 12.f };
entity.getComponent<UIElement>().absolutePosition = { -(BarWidth + 49.f), 38.f };
entity.addComponent<cro::Callback>().active = true;
entity.getComponent<cro::Callback>().setUserData<float>(1.f);
entity.getComponent<cro::Callback>().function =
Expand Down Expand Up @@ -1390,7 +1382,7 @@ void ScrubGameState::createUI()
//current ball cleanliness
entity = createLevelMeter(cro::Colour::Blue);
entity.getComponent<UIElement>().relativePosition = glm::vec2(1.f, 0.f);
entity.getComponent<UIElement>().absolutePosition = { -((BarWidth + 42.f) * 2.f), 12.f };
entity.getComponent<UIElement>().absolutePosition = { -((BarWidth + 46.f) * 2.f), 38.f };
entity.addComponent<cro::Callback>().active = true;
entity.getComponent<cro::Callback>().function =
[&](cro::Entity e, float dt)
Expand Down
9 changes: 8 additions & 1 deletion samples/golf/src/scrub/Shaders.inl
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit b8477fe

Please sign in to comment.