Skip to content

Commit

Permalink
fix releasing mouse on mouse move in Scrub
Browse files Browse the repository at this point in the history
fix crash deleting intro entities in Scrub
don't add default openal device when multiple devices found
  • Loading branch information
fallahn committed Nov 3, 2024
1 parent b8477fe commit 6b233f5
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 17 deletions.
8 changes: 4 additions & 4 deletions crogine.sln
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,8 @@ Global
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Debug|Any CPU.ActiveCfg = Debug|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Debug|ARM.ActiveCfg = Debug|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Debug|ARM64.ActiveCfg = Debug|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Debug|x64.ActiveCfg = Debug|x64
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Debug|x64.Build.0 = Debug|x64
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Debug|x64.ActiveCfg = DebugGNS|x64
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Debug|x64.Build.0 = DebugGNS|x64
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Debug|x86.ActiveCfg = Debug|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Debug|x86.Build.0 = Debug|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.DebugASan|Any CPU.ActiveCfg = DebugASan|Win32
Expand Down Expand Up @@ -703,8 +703,8 @@ Global
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|Any CPU.ActiveCfg = Release|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|ARM.ActiveCfg = Release|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|ARM64.ActiveCfg = Release|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x64.ActiveCfg = Release|x64
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x64.Build.0 = Release|x64
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x64.ActiveCfg = ReleaseGNS|x64
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x64.Build.0 = ReleaseGNS|x64
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x86.ActiveCfg = Release|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x86.Build.0 = Release|Win32
{B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release-asan|Any CPU.ActiveCfg = Release-asan|Win32
Expand Down
6 changes: 5 additions & 1 deletion crogine/src/audio/OpenALImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,11 @@ void OpenALImpl::refreshDeviceList()
next += (len + 2);
}
}
m_devices.push_back("Default");

if (m_devices.empty())
{
m_devices.push_back("Default");
}
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions samples/golf/buildnumber.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef BUILD_NUMBER_H_
#define BUILD_NUMBER_H_

#define BUILDNUMBER 7176
#define BUILDNUMBER_STR "7176"
#define BUILDNUMBER 7181
#define BUILDNUMBER_STR "7181"

#endif /* BUILD_NUMBER_H_ */
8 changes: 8 additions & 0 deletions samples/golf/src/GolfGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,13 @@ bool GolfGame::initialise()
}
});

registerCommand("scrub",
[&](const std::string&)
{
m_stateStack.clearStates();
m_stateStack.pushState(StateID::ScrubBackground);
});

getWindow().setLoadingScreen<LoadingScreen>(m_sharedData);
getWindow().setTitle("Super Video Golf - " + StringVer);
getWindow().setIcon(icon);
Expand Down Expand Up @@ -973,6 +980,7 @@ bool GolfGame::initialise()
//m_stateStack.pushState(StateID::Workshop);
#else
m_stateStack.pushState(StateID::SplashScreen);
//m_stateStack.pushState(StateID::ScrubBackground);
#endif

applyImGuiStyle(m_sharedData);
Expand Down
9 changes: 8 additions & 1 deletion samples/golf/src/scrub/ScrubAttractState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,13 @@ bool ScrubAttractState::handleEvent(const cro::Event& evt)
|| evt.caxis.value > cro::GameController::LeftThumbDeadZone)
{
m_controllerIndex = cro::GameController::controllerID(evt.caxis.which);
cro::App::getWindow().setMouseCaptured(true);
}
}

else if (evt.type == SDL_MOUSEMOTION)
{
cro::App::getWindow().setMouseCaptured(false);
}

m_gameScene.forwardEvent(evt);
m_uiScene.forwardEvent(evt);
Expand Down Expand Up @@ -398,6 +402,7 @@ void ScrubAttractState::buildScene()

//title background - remember sprites are added to the spriteNode of the current tab for correct scaling...
auto& bgTex = m_resources.textures.get("assets/arcade/scrub/images/attract_bg.png");
bgTex.setSmooth(true);
entity = m_uiScene.createEntity();
entity.addComponent<cro::AudioEmitter>() = as.getEmitter("menu_show");
entity.addComponent<cro::Transform>().setPosition(glm::vec3(size / 2.f, sc::UIBackgroundDepth));
Expand Down Expand Up @@ -506,6 +511,7 @@ void ScrubAttractState::buildScene()

//help background
auto& helpTex = m_resources.textures.get("assets/arcade/scrub/images/rules_bg.png");
helpTex.setSmooth(true);
entity = m_uiScene.createEntity();
entity.addComponent<cro::Transform>().setPosition(glm::vec3(size / 2.f, sc::UIBackgroundDepth));
entity.addComponent<cro::Drawable2D>();
Expand Down Expand Up @@ -597,6 +603,7 @@ void ScrubAttractState::buildScene()

//score background
auto& scoreTex = m_resources.textures.get("assets/arcade/scrub/images/highscore_bg.png");
scoreTex.setSmooth(true);
entity = m_uiScene.createEntity();
entity.addComponent<cro::Transform>().setPosition(glm::vec3(size / 2.f, sc::UIBackgroundDepth));
entity.addComponent<cro::Drawable2D>();
Expand Down
23 changes: 14 additions & 9 deletions samples/golf/src/scrub/ScrubGameState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ ScrubGameState::ScrubGameState(cro::StateStack& stack, cro::State::Context conte
m_sharedData (sd),
m_sharedScrubData (sc),
m_soundDirector (nullptr),
m_gameScene (context.appInstance.getMessageBus()),
m_gameScene (context.appInstance.getMessageBus(), 854),
m_uiScene (context.appInstance.getMessageBus(), 512),
m_pitchStage (0),
m_soapAnimationActive (false),
Expand Down Expand Up @@ -358,6 +358,7 @@ bool ScrubGameState::handleEvent(const cro::Event& evt)
|| evt.caxis.value > cro::GameController::LeftThumbDeadZone)
{
m_controllerIndex = cro::GameController::controllerID(evt.caxis.which);
cro::App::getWindow().setMouseCaptured(true);
}
}
else if (evt.type == SDL_CONTROLLERDEVICEREMOVED)
Expand All @@ -371,6 +372,10 @@ bool ScrubGameState::handleEvent(const cro::Event& evt)
cro::GameController::applyDSTriggerEffect(i, cro::GameController::DSTriggerBoth, cro::GameController::DSEffect::createWeapon(0, 1, 2));
}
}
else if (evt.type == SDL_MOUSEMOTION)
{
cro::App::getWindow().setMouseCaptured(false);
}

else if (evt.type == SDL_KEYUP
|| evt.type == SDL_CONTROLLERBUTTONUP)
Expand Down Expand Up @@ -446,8 +451,8 @@ bool ScrubGameState::simulate(float dt)
auto oldTime = m_score.remainingTime;

m_score.totalRunTime += dt;
#ifndef CRO_DEBUG_
m_score.remainingTime = std::max(m_score.remainingTime - dt, 0.f);
#ifndef CRO_DEBUG_
#endif
switch (m_pitchStage)
{
Expand Down Expand Up @@ -1583,7 +1588,7 @@ void ScrubGameState::createCountIn()
if (ct == 1)
{
g.getComponent<cro::Callback>().active = false;
m_uiScene.destroyEntity(e);
m_uiScene.destroyEntity(g);
}
};

Expand All @@ -1596,12 +1601,6 @@ void ScrubGameState::createCountIn()
else
{
//go
if (t < 0)
{
e.getComponent<cro::Callback>().active = false;
m_uiScene.destroyEntity(e);
}

const glm::vec2 winSize(cro::App::getWindow().getSize());

const auto progress = 1.f - std::max(0.f, std::min(1.f, t / (GoTime / 2.f)));
Expand All @@ -1613,6 +1612,12 @@ void ScrubGameState::createCountIn()

static constexpr float Stretch = 1.52f;
e.getComponent<cro::Transform>().setScale({ 1.f + (progress * Stretch), 1.f - (progress * Stretch) });

if (t < 0)
{
e.getComponent<cro::Callback>().active = false;
m_uiScene.destroyEntity(e);
}
}
};

Expand Down
5 changes: 5 additions & 0 deletions samples/golf/src/scrub/ScrubPauseState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,13 @@ bool ScrubPauseState::handleEvent(const cro::Event& evt)
|| evt.caxis.value > cro::GameController::LeftThumbDeadZone)
{
m_controllerIndex = cro::GameController::controllerID(evt.caxis.which);
cro::App::getWindow().setMouseCaptured(true);
}
}
else if (evt.type == SDL_MOUSEMOTION)
{
cro::App::getWindow().setMouseCaptured(false);
}

m_uiScene.forwardEvent(evt);
return false;
Expand Down

0 comments on commit 6b233f5

Please sign in to comment.