From f8992b96c3a093e9df65adbb83ea6a959ac7836e Mon Sep 17 00:00:00 2001 From: fallahn Date: Sat, 20 Apr 2024 11:48:04 +0100 Subject: [PATCH 01/12] fix restoring defaults when launching tutorial --- crogine.sln | 4 ++-- samples/golf/buildnumber.h | 4 ++-- samples/golf/src/golf/PracticeState.cpp | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/crogine.sln b/crogine.sln index 36c317be4..2259aee69 100644 --- a/crogine.sln +++ b/crogine.sln @@ -303,8 +303,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 = ReleaseGNS|x64 - {B1559428-CDF8-4797-8766-0EA62BDD6D1B}.Release|x64.Build.0 = ReleaseGNS|x64 + {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|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 diff --git a/samples/golf/buildnumber.h b/samples/golf/buildnumber.h index 8b9f3c78b..3573d5b1f 100644 --- a/samples/golf/buildnumber.h +++ b/samples/golf/buildnumber.h @@ -3,7 +3,7 @@ #ifndef BUILD_NUMBER_H_ #define BUILD_NUMBER_H_ -#define BUILDNUMBER 5414 -#define BUILDNUMBER_STR "5414" +#define BUILDNUMBER 5416 +#define BUILDNUMBER_STR "5416" #endif /* BUILD_NUMBER_H_ */ diff --git a/samples/golf/src/golf/PracticeState.cpp b/samples/golf/src/golf/PracticeState.cpp index 9ca4bc071..8c4f35bca 100644 --- a/samples/golf/src/golf/PracticeState.cpp +++ b/samples/golf/src/golf/PracticeState.cpp @@ -36,6 +36,7 @@ source distribution. #include "PacketIDs.hpp" #include "Utility.hpp" #include "TextAnimCallback.hpp" +#include "League.hpp" #include "../GolfGame.hpp" #include @@ -355,6 +356,10 @@ void PracticeState::buildScene() m_sharedData.gameMode = GameMode::Tutorial; m_sharedData.localConnectionData.playerCount = 1; m_sharedData.localConnectionData.playerData[0].isCPU = false; + m_sharedData.clubSet = 0; + m_sharedData.preferredClubSet = 0; + + m_sharedData.leagueRoundID = LeagueRoundID::Club; //start a local server and connect if (!m_sharedData.clientConnection.connected) From 6628b0ffe4746254cafb85763e07007374704bcf Mon Sep 17 00:00:00 2001 From: fallahn Date: Mon, 22 Apr 2024 12:06:07 +0100 Subject: [PATCH 02/12] add vsync toggle to options menu --- samples/golf/src/golf/OptionsEnum.inl | 1 + samples/golf/src/golf/OptionsState.cpp | 91 ++++++++++++++++++++------ 2 files changed, 73 insertions(+), 19 deletions(-) diff --git a/samples/golf/src/golf/OptionsEnum.inl b/samples/golf/src/golf/OptionsEnum.inl index 2538d960c..741adf14d 100644 --- a/samples/golf/src/golf/OptionsEnum.inl +++ b/samples/golf/src/golf/OptionsEnum.inl @@ -52,6 +52,7 @@ enum OptionsIndex AVPixelScale, AVVertSnap, AVFullScreen, + AVVSync, AVBeacon, AVBeaconL, AVBeaconR, diff --git a/samples/golf/src/golf/OptionsState.cpp b/samples/golf/src/golf/OptionsState.cpp index 6631df947..0b67a3944 100644 --- a/samples/golf/src/golf/OptionsState.cpp +++ b/samples/golf/src/golf/OptionsState.cpp @@ -1367,8 +1367,11 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit //full screen label createLabel(glm::vec2(12.f, 51.f), "Full Screen"); + //vsync label + createLabel(glm::vec2(12.f, 35.f), "Enable VSync"); + //beacon label - auto beaconLabel = createLabel(glm::vec2(12.f, 35.f), "Flag Beacon"); + auto beaconLabel = createLabel(glm::vec2(12.f, 19.f), "Flag Beacon"); beaconLabel.addComponent().active = true; beaconLabel.getComponent().function = [&](cro::Entity e, float) @@ -1574,7 +1577,7 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit }; auto helpEnt = m_scene.createEntity(); - helpEnt.addComponent().setPosition({ bgBounds.width / 2.f, -4.f, 0.1f }); + helpEnt.addComponent().setPosition({ bgBounds.width / 2.f, -9.f, 0.1f }); helpEnt.addComponent(); helpEnt.addComponent(font).setCharacterSize(InfoTextSize); helpEnt.getComponent().setFillColour(TextNormalColour); @@ -1589,7 +1592,19 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit e.getComponent().play(); e.getComponent().active = true; - helpEnt.getComponent().setString(e.getLabel()); + const auto& str = e.getLabel(); + + auto pos = helpEnt.getComponent().getPosition(); + if (str.find('\n') != std::string::npos) + { + pos.y = -9.f; + } + else + { + pos.y = -15.f; + } + helpEnt.getComponent().setPosition(pos); + helpEnt.getComponent().setString(str); m_scene.getActiveCamera().getComponent().active = true; }); auto unselectedID = uiSystem.addCallback([helpEnt](cro::Entity e) mutable @@ -1897,7 +1912,7 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit //full screen check box entity = createHighlight(glm::vec2(81.f, 42.f)); entity.getComponent().setSelectionIndex(AVFullScreen); - entity.getComponent().setNextIndex(AVTreeL, AVBeacon); + entity.getComponent().setNextIndex(AVTreeL, AVVSync); entity.getComponent().setPrevIndex(AVTreeR, AVVertSnap); entity.getComponent().callbacks[cro::UIInput::ButtonDown] = uiSystem.addCallback([&](cro::Entity e, cro::ButtonEvent evt) @@ -1931,9 +1946,47 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit parent.getComponent().addChild(entity.getComponent()); + //vsync checkbox + entity = createHighlight(glm::vec2(81.f, 26.f)); + entity.getComponent().setSelectionIndex(AVVSync); + entity.getComponent().setNextIndex(AVShadowL, AVBeacon); + entity.getComponent().setPrevIndex(AVShadowR, AVFullScreen); + entity.getComponent().callbacks[cro::UIInput::ButtonDown] = + uiSystem.addCallback([&](cro::Entity e, cro::ButtonEvent evt) + { + if (activated(evt)) + { + bool vsync = cro::App::getWindow().getVsyncEnabled(); + cro::App::getWindow().setVsyncEnabled(!vsync); + + m_audioEnts[AudioID::Accept].getComponent().play(); + m_scene.getActiveCamera().getComponent().active = true; + } + }); + + //vsync checkbox centre + entity = m_scene.createEntity(); + entity.addComponent().setPosition(glm::vec3(83.f, 28.f, HighlightOffset)); + entity.addComponent().getVertexData() = + { + cro::Vertex2D(glm::vec2(0.f, 7.f), TextGoldColour), + cro::Vertex2D(glm::vec2(0.f), TextGoldColour), + cro::Vertex2D(glm::vec2(7.f), TextGoldColour), + cro::Vertex2D(glm::vec2(7.f, 0.f), TextGoldColour) + }; + entity.getComponent().updateLocalBounds(); + entity.addComponent().active = true; + entity.getComponent().function = + [&](cro::Entity e, float) + { + float scale = cro::App::getWindow().getVsyncEnabled() ? 1.f : 0.f; + e.getComponent().setScale(glm::vec2(scale)); + }; + parent.getComponent().addChild(entity.getComponent()); + //beacon check box - entity = createHighlight(glm::vec2(81.f, 26.f)); + entity = createHighlight(glm::vec2(81.f, 10.f)); entity.setLabel("Displays a beacon on the course at the pin position."); entity.getComponent().setSelectionIndex(AVBeacon); #ifdef _WIN32 @@ -1946,7 +1999,7 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit { entity.getComponent().setNextIndex(AVBeaconL, WindowCredits); } - entity.getComponent().setPrevIndex(AVShadowR, AVFullScreen); + entity.getComponent().setPrevIndex(AVCrowdR, AVVSync); entity.getComponent().callbacks[cro::UIInput::ButtonDown] = uiSystem.addCallback([&](cro::Entity e, cro::ButtonEvent evt) { @@ -1961,7 +2014,7 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit //beacon checkbox centre entity = m_scene.createEntity(); - entity.addComponent().setPosition(glm::vec3(83.f, 28.f, HighlightOffset)); + entity.addComponent().setPosition(glm::vec3(83.f, 12.f, HighlightOffset)); entity.addComponent().getVertexData() = { cro::Vertex2D(glm::vec2(0.f, 7.f), TextGoldColour), @@ -1982,7 +2035,7 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit //beacon colour preview entity = m_scene.createEntity(); - entity.addComponent().setPosition(glm::vec3(99.f, 28.f, HighlightOffset)); + entity.addComponent().setPosition(glm::vec3(99.f, 12.f, HighlightOffset)); entity.addComponent().setVertexData( { cro::Vertex2D(glm::vec2(0.f, 7.f), cro::Colour::Magenta), @@ -2001,7 +2054,7 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit glUseProgram(shaderID); glUniform1f(uniformID, m_sharedData.beaconColour); - entity = createHighlight(glm::vec2(113.f, 26.f)); + entity = createHighlight(glm::vec2(113.f, 10.f)); entity.getComponent().setSelectionIndex(AVBeaconL); entity.getComponent().setNextIndex(AVBeaconR, WindowCredits); entity.getComponent().setPrevIndex(AVBeacon, AVFullScreen); @@ -2018,9 +2071,9 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit } }); - entity = createHighlight(glm::vec2(182.f, 26.f)); + entity = createHighlight(glm::vec2(182.f, 10.f)); entity.getComponent().setSelectionIndex(AVBeaconR); - entity.getComponent().setNextIndex(AVShadowL, TabController); + entity.getComponent().setNextIndex(AVCrowdL, TabController); entity.getComponent().setPrevIndex(AVBeaconL, AVResolutionR); entity.getComponent().callbacks[cro::UIInput::ButtonDown] = uiSystem.addCallback([&, shaderID, uniformID](cro::Entity e, cro::ButtonEvent evt) @@ -2036,7 +2089,7 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit }); //colour slider - auto colourPos = glm::vec2(131.f, 32.f); + auto colourPos = glm::vec2(131.f, 16.f); auto colourSlider = createSlider(colourPos); auto sliderData = SliderData(colourPos, 44.f); sliderData.onActivate = @@ -2396,12 +2449,12 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit entity = createHighlight(glm::vec2(286.f, 26.f)); entity.getComponent().setSelectionIndex(AVShadowL); entity.getComponent().setNextIndex(AVShadowR, AVCrowdL); - entity.getComponent().setPrevIndex(AVBeaconR, AVTreeL); + entity.getComponent().setPrevIndex(AVVSync, AVTreeL); entity.getComponent().callbacks[cro::UIInput::ButtonDown] = shadowChanged; entity = createHighlight(glm::vec2(355.f, 26.f)); entity.getComponent().setSelectionIndex(AVShadowR); - entity.getComponent().setNextIndex(AVBeacon, AVCrowdR); + entity.getComponent().setNextIndex(AVVSync, AVCrowdR); entity.getComponent().setPrevIndex(AVShadowL, AVTreeR); entity.getComponent().callbacks[cro::UIInput::ButtonDown] = shadowChanged; @@ -2446,11 +2499,11 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit #ifdef _WIN32 if (!Social::isSteamdeck()) { - entity.getComponent().setPrevIndex(AVTextToSpeech, AVShadowL); + entity.getComponent().setPrevIndex(AVBeaconR, AVShadowL); } else #endif - entity.getComponent().setPrevIndex(AVCrowdR, AVShadowL); + entity.getComponent().setPrevIndex(AVBeaconR, AVShadowL); entity.getComponent().callbacks[cro::UIInput::ButtonDown] = crowdChanged; entity = createHighlight(glm::vec2(355.f, 10.f)); @@ -2459,11 +2512,11 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit #ifdef _WIN32 if (!Social::isSteamdeck()) { - entity.getComponent().setNextIndex(AVTextToSpeech, WindowClose); + entity.getComponent().setNextIndex(AVBeacon, WindowClose); } else #endif - entity.getComponent().setNextIndex(AVCrowdL, WindowClose); + entity.getComponent().setNextIndex(AVBeacon, WindowClose); entity.getComponent().setPrevIndex(AVCrowdL, AVShadowR); entity.getComponent().callbacks[cro::UIInput::ButtonDown] = crowdChanged; @@ -2471,7 +2524,7 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit if (!Social::isSteamdeck()) { entity = m_scene.createEntity(); - entity.addComponent().setPosition({ 12.f, 11.f, 0.1f }); + entity.addComponent().setPosition({ 12.f, -5.f, 0.1f }); entity.addComponent(); entity.addComponent() = spriteSheet.getSprite("use_tts"); parent.getComponent().addChild(entity.getComponent()); From e0f9e6f3e99a0e3b3c251e0182905679d9553f5a Mon Sep 17 00:00:00 2001 From: fallahn Date: Mon, 22 Apr 2024 12:13:34 +0100 Subject: [PATCH 03/12] increment version number --- libsocial/include/Social.hpp | 6 +++--- samples/golf/golf.aps | Bin 295000 -> 295000 bytes samples/golf/golf.rc | 8 ++++---- windows/crogine.aps | Bin 2704 -> 2760 bytes windows/crogine.rc | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libsocial/include/Social.hpp b/libsocial/include/Social.hpp index 0596c54d9..5cb39e00c 100644 --- a/libsocial/include/Social.hpp +++ b/libsocial/include/Social.hpp @@ -49,11 +49,11 @@ source distribution. //(ball started sending wind effect 1120 -> 1124) //(added night mode/weather 1141 -> 1150) //(player avatar data format changed 1153->1160) -static constexpr std::uint16_t CURRENT_VER = 1162; +static constexpr std::uint16_t CURRENT_VER = 1163; #ifdef __APPLE__ -static const std::string StringVer("1.16.2 (macOS beta)"); +static const std::string StringVer("1.16.3 (macOS beta)"); #else -static const std::string StringVer("1.16.2"); +static const std::string StringVer("1.16.3"); #endif struct HallEntry final diff --git a/samples/golf/golf.aps b/samples/golf/golf.aps index 525ca8bec67c62c12b594599edfe0715f7ffd0ac..9c7463e400d4ef74418b98f83ecded753362a47c 100644 GIT binary patch delta 49 zcmcc7AatWasG)_ig{g&k3(LGJPG$xH21W)32IlR{t5}#B8I8BEu4V}a(f?~$BAEei Cvkm3| delta 49 zcmcc7AatWasG)_ig{g&k3(LGJP9_Ec21W)32Bz)Ht5}#B8I88Du4V}a(f?~$BAEei CXAR;2 diff --git a/samples/golf/golf.rc b/samples/golf/golf.rc index bb135dd00..aa3e0fae9 100644 --- a/samples/golf/golf.rc +++ b/samples/golf/golf.rc @@ -61,8 +61,8 @@ IDI_ICON1 ICON "icon.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,16,2,0 - PRODUCTVERSION 1,16,2,0 + FILEVERSION 1,16,3,0 + PRODUCTVERSION 1,16,3,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -79,12 +79,12 @@ BEGIN BEGIN VALUE "CompanyName", "Trederia" VALUE "FileDescription", "Super Video Golf" - VALUE "FileVersion", "1.16.2.0" + VALUE "FileVersion", "1.16.3.0" VALUE "InternalName", "golf.exe" VALUE "LegalCopyright", "Copyright (C) 2024 Trederia Games" VALUE "OriginalFilename", "golf.exe" VALUE "ProductName", "Super Video Golf" - VALUE "ProductVersion", "1.16.2.0" + VALUE "ProductVersion", "1.16.3.0" END END BLOCK "VarFileInfo" diff --git a/windows/crogine.aps b/windows/crogine.aps index 304f7975132256b14832769b6427475c24a04a9c..d92e79963f2ee835367c1b33a718d5ce013ef87b 100644 GIT binary patch delta 427 zcma)%&q@MO6vn^fjOA4VH;P2!L}DaVVzrSVY6NSaw3&^_kS?4V=Fdi2^au`j-6HY< z6gMq;fOfq>s~(_L5ERoHG23=7=kVQgzu&#*j&jerkw&d>bE}#afZj0Lp6Pmq-f{d+ z-_mq9u(~~?X?KHxY5AVvnvOjkR*1&(o=iDaa+Uu<;joxFLK#sMXF;wd)-P2oLPrAz z+VEh)E;MUPLLuvrBdu-{@=Ot`Ea*it4QL>+b1;w4X%V^Zaf za!u;&P5C6k>^1pLbU1ri-6d+t@6B!S`QGSR#P3Eea&eIpGgAHvZek{v52l)dc HwYVHVElWg+WsATU=n*1XxNS9E4J7Hpy>Ne=b2x92R-~no(Oz2Fdsl!=+AKI$(=l@;*EKVC z*}JkDu45Lfj#sK{hU-Ki!B+;R$=mqkmbQdPRiNf9JWS=P64JvUWL+q*>^wMs}-@Cec-PqKGLvtICD(C#x$G%G*hhHmw_`J;ezi8PDL!VMmJ(Qv?w0s a8JPpP*Wmk Date: Mon, 22 Apr 2024 12:29:10 +0100 Subject: [PATCH 04/12] automatically pause in-game music when volume is turned down --- crogine.sln | 4 ++-- samples/golf/buildnumber.h | 4 ++-- samples/golf/src/golf/GameConsts.hpp | 17 ++++++++++++++++- samples/golf/src/golf/OptionsEnum.inl | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/crogine.sln b/crogine.sln index 2259aee69..36c317be4 100644 --- a/crogine.sln +++ b/crogine.sln @@ -303,8 +303,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 diff --git a/samples/golf/buildnumber.h b/samples/golf/buildnumber.h index 3573d5b1f..b737bfbe2 100644 --- a/samples/golf/buildnumber.h +++ b/samples/golf/buildnumber.h @@ -3,7 +3,7 @@ #ifndef BUILD_NUMBER_H_ #define BUILD_NUMBER_H_ -#define BUILDNUMBER 5416 -#define BUILDNUMBER_STR "5416" +#define BUILDNUMBER 5417 +#define BUILDNUMBER_STR "5417" #endif /* BUILD_NUMBER_H_ */ diff --git a/samples/golf/src/golf/GameConsts.hpp b/samples/golf/src/golf/GameConsts.hpp index 5a425149e..b19fa31e7 100644 --- a/samples/golf/src/golf/GameConsts.hpp +++ b/samples/golf/src/golf/GameConsts.hpp @@ -148,6 +148,8 @@ static constexpr std::int16_t TriggerDeadZone = cro::GameController::TriggerDead static constexpr glm::vec3 BallHairScale(0.23f); static constexpr glm::vec3 BallHairOffset(0.f, -0.29f, -0.008f); +static constexpr float MinMusicVolume = 0.001f; + class btVector3; glm::vec3 btToGlm(btVector3 v); btVector3 glmToBt(glm::vec3 v); @@ -854,8 +856,21 @@ static inline void createMusicPlayer(cro::Scene& scene, SharedStateData& sharedD cro::AudioMixer::setPrefadeVolume(vol, MixerChannel::UserMusic); } + //if the user turned the volume down, pause the playback (TODO this might be better reading messages?) + const float currVol = cro::AudioMixer::getVolume(MixerChannel::UserMusic); + const auto state = e.getComponent().getState(); - if (e.getComponent().getState() == cro::AudioEmitter::State::Stopped) + if (state == cro::AudioEmitter::State::Playing + && currVol < MinMusicVolume) + { + e.getComponent().pause(); + } + else if (state == cro::AudioEmitter::State::Paused + && currVol > MinMusicVolume) + { + e.getComponent().play(); + } + else if (state == cro::AudioEmitter::State::Stopped) { e.getComponent().active = false; scene.destroyEntity(e); diff --git a/samples/golf/src/golf/OptionsEnum.inl b/samples/golf/src/golf/OptionsEnum.inl index 741adf14d..92484940f 100644 --- a/samples/golf/src/golf/OptionsEnum.inl +++ b/samples/golf/src/golf/OptionsEnum.inl @@ -1,6 +1,6 @@ /*----------------------------------------------------------------------- -Matt Marchant 2021 - 2023 +Matt Marchant 2021 - 2024 http://trederia.blogspot.com Super Video Golf - zlib licence. From 84b07ff3d73b6c4cdf77b071cf6ae6c35248f486 Mon Sep 17 00:00:00 2001 From: fallahn Date: Mon, 22 Apr 2024 13:04:25 +0100 Subject: [PATCH 05/12] drawable origin offset is accounted for when sorting 2D drawables fixed compositing bug causing particles to have dark edges --- crogine/src/ecs/systems/RenderSystem2D.cpp | 7 ++++--- samples/golf/buildnumber.h | 4 ++-- samples/golf/src/golf/GolfStateUI.cpp | 2 +- samples/golf/src/golf/shaders/CompositeShader.inl | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/crogine/src/ecs/systems/RenderSystem2D.cpp b/crogine/src/ecs/systems/RenderSystem2D.cpp index d77af8a62..d2159c320 100644 --- a/crogine/src/ecs/systems/RenderSystem2D.cpp +++ b/crogine/src/ecs/systems/RenderSystem2D.cpp @@ -1,6 +1,6 @@ /*----------------------------------------------------------------------- -Matt Marchant 2017 - 2023 +Matt Marchant 2017 - 2024 http://trederia.blogspot.com crogine - Zlib license. @@ -178,6 +178,7 @@ void RenderSystem2D::process(float) const auto& tx = entity.getComponent(); auto pos = tx.getWorldPosition(); + auto origin = tx.getOrigin(); //set sort criteria based on position //faster to do a sort on int than float @@ -185,11 +186,11 @@ void RenderSystem2D::process(float) { //multiplying by 100 preserves two places of precision //which is enough to sort on - drawable.m_sortCriteria = static_cast(-pos.y * 100.f); + drawable.m_sortCriteria = static_cast(-(pos.y - origin.y) * 100.f); } else { - drawable.m_sortCriteria = static_cast(pos.z * 100.f); + drawable.m_sortCriteria = static_cast((pos.z - origin.z) * 100.f); } //check if the cropping area is smaller than diff --git a/samples/golf/buildnumber.h b/samples/golf/buildnumber.h index b737bfbe2..3f262f1ac 100644 --- a/samples/golf/buildnumber.h +++ b/samples/golf/buildnumber.h @@ -3,7 +3,7 @@ #ifndef BUILD_NUMBER_H_ #define BUILD_NUMBER_H_ -#define BUILDNUMBER 5417 -#define BUILDNUMBER_STR "5417" +#define BUILDNUMBER 5421 +#define BUILDNUMBER_STR "5421" #endif /* BUILD_NUMBER_H_ */ diff --git a/samples/golf/src/golf/GolfStateUI.cpp b/samples/golf/src/golf/GolfStateUI.cpp index bf0c6a6de..0dc6a215e 100644 --- a/samples/golf/src/golf/GolfStateUI.cpp +++ b/samples/golf/src/golf/GolfStateUI.cpp @@ -209,7 +209,7 @@ void GolfState::buildUI() //draws the background using the render texture auto entity = m_uiScene.createEntity(); entity.addComponent(); - entity.addComponent(); + entity.addComponent().setBlendMode(cro::Material::BlendMode::None); auto* shader = &m_resources.shaders.get(ShaderID::Composite); entity.getComponent().setShader(shader); diff --git a/samples/golf/src/golf/shaders/CompositeShader.inl b/samples/golf/src/golf/shaders/CompositeShader.inl index 55cd25d13..242c34887 100644 --- a/samples/golf/src/golf/shaders/CompositeShader.inl +++ b/samples/golf/src/golf/shaders/CompositeShader.inl @@ -162,6 +162,6 @@ void main() colour.rgb = (blurColour * maskAmount * 0.65) + colour.rgb; #endif - FRAG_OUT = colour; + FRAG_OUT = vec4(colour.rgb, 1.0); //FRAG_OUT = mix(colour, vec4(d,d,d,1.0), u_density / 10.0); })"; \ No newline at end of file From 4931483f4eb496377395d9951bd5b1aa7e35c2cc Mon Sep 17 00:00:00 2001 From: fallahn Date: Mon, 22 Apr 2024 14:12:01 +0100 Subject: [PATCH 06/12] reinstate tutorial completion text --- samples/golf/buildnumber.h | 4 ++-- samples/golf/src/golf/GolfStateScoring.cpp | 16 +++++++++++----- samples/golf/src/golf/GolfStateUI.cpp | 6 ++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/samples/golf/buildnumber.h b/samples/golf/buildnumber.h index 3f262f1ac..3e5abd087 100644 --- a/samples/golf/buildnumber.h +++ b/samples/golf/buildnumber.h @@ -3,7 +3,7 @@ #ifndef BUILD_NUMBER_H_ #define BUILD_NUMBER_H_ -#define BUILDNUMBER 5421 -#define BUILDNUMBER_STR "5421" +#define BUILDNUMBER 5423 +#define BUILDNUMBER_STR "5423" #endif /* BUILD_NUMBER_H_ */ diff --git a/samples/golf/src/golf/GolfStateScoring.cpp b/samples/golf/src/golf/GolfStateScoring.cpp index 94d29adae..b5ad37d8a 100644 --- a/samples/golf/src/golf/GolfStateScoring.cpp +++ b/samples/golf/src/golf/GolfStateScoring.cpp @@ -86,7 +86,13 @@ void GolfState::updateHoleScore(std::uint16_t data) void GolfState::updateLeaderboardScore(bool& personalBest, cro::String& bestString) { - if (m_sharedData.scoreType == ScoreType::Stroke + if (m_sharedData.gameMode == GameMode::Tutorial) + { + bestString = "Tutorial Complete"; + return; + } + + else if (m_sharedData.scoreType == ScoreType::Stroke && Social::getLeaderboardsEnabled()) { const auto& connectionData = m_sharedData.connectionData[m_sharedData.clientConnection.connectionID]; @@ -129,8 +135,8 @@ void GolfState::updateLeaderboardScore(bool& personalBest, cro::String& bestStri } } } - else - { - cro::Logger::log("LEADERBOARD did not insert score: Score Type is not Stroke.\n", cro::Logger::Type::Info, cro::Logger::Output::File); - } + //else + //{ + // cro::Logger::log("LEADERBOARD did not insert score: Score Type is not Stroke.\n", cro::Logger::Type::Info, cro::Logger::Output::File); + //} } \ No newline at end of file diff --git a/samples/golf/src/golf/GolfStateUI.cpp b/samples/golf/src/golf/GolfStateUI.cpp index 0dc6a215e..68dcfd71f 100644 --- a/samples/golf/src/golf/GolfStateUI.cpp +++ b/samples/golf/src/golf/GolfStateUI.cpp @@ -1960,7 +1960,8 @@ void GolfState::showCountdown(std::uint8_t seconds) m_uiScene.getSystem()->sendCommand(cmd); - if (personalBest && Social::getLeaderboardsEnabled()) + if ((personalBest && Social::getLeaderboardsEnabled()) + || m_sharedData.gameMode == GameMode::Tutorial) { entity = m_uiScene.createEntity(); entity.addComponent().setPosition({ 200.f + scoreboardExpansion, 10.f, 0.8f }); @@ -1974,8 +1975,6 @@ void GolfState::showCountdown(std::uint8_t seconds) entity.addComponent().ID = CommandID::UI::UIElement; entity.addComponent(font).setCharacterSize(UITextSize * 2); entity.getComponent().setFillColour(TextHighlightColour); - //entity.getComponent().setOutlineColour(LeaderboardTextDark); - //entity.getComponent().setOutlineThickness(1.f); entity.getComponent().setString(bestString); centreText(entity); @@ -1993,7 +1992,6 @@ void GolfState::showCountdown(std::uint8_t seconds) fw.getComponent().active = true; } } - //create status icons for each connected client From ad6cd113f66716b733f449d001a2810de756a759 Mon Sep 17 00:00:00 2001 From: fallahn Date: Mon, 22 Apr 2024 14:31:35 +0100 Subject: [PATCH 07/12] hide UI when switching to drone cam add console command cl_drawhud to toggle UI --- samples/golf/buildnumber.h | 4 ++-- samples/golf/src/golf/GolfState.cpp | 2 ++ samples/golf/src/golf/GolfState.hpp | 1 + samples/golf/src/golf/GolfStateCameras.cpp | 9 ++------- samples/golf/src/golf/GolfStateDebug.cpp | 16 ++++++++++++++++ samples/golf/src/golf/GolfStateUI.cpp | 17 +++++++++++++++++ 6 files changed, 40 insertions(+), 9 deletions(-) diff --git a/samples/golf/buildnumber.h b/samples/golf/buildnumber.h index 3e5abd087..21c4e09ea 100644 --- a/samples/golf/buildnumber.h +++ b/samples/golf/buildnumber.h @@ -3,7 +3,7 @@ #ifndef BUILD_NUMBER_H_ #define BUILD_NUMBER_H_ -#define BUILDNUMBER 5423 -#define BUILDNUMBER_STR "5423" +#define BUILDNUMBER 5426 +#define BUILDNUMBER_STR "5426" #endif /* BUILD_NUMBER_H_ */ diff --git a/samples/golf/src/golf/GolfState.cpp b/samples/golf/src/golf/GolfState.cpp index e979f1f4e..326b3f24e 100644 --- a/samples/golf/src/golf/GolfState.cpp +++ b/samples/golf/src/golf/GolfState.cpp @@ -1157,6 +1157,7 @@ void GolfState::handleMessage(const cro::Message& msg) e.getComponent().setHidden(true); }; m_gameScene.getSystem()->sendCommand(cmd); + setUIHidden(true); } else if (data.data == CameraID::Player && m_currentCamera == CameraID::Drone) @@ -1168,6 +1169,7 @@ void GolfState::handleMessage(const cro::Message& msg) e.getComponent().setHidden(!(localPlayer && !m_sharedData.localConnectionData.playerData[m_currentPlayer.player].isCPU)); }; m_gameScene.getSystem()->sendCommand(cmd); + setUIHidden(false); } setActiveCamera(data.data); diff --git a/samples/golf/src/golf/GolfState.hpp b/samples/golf/src/golf/GolfState.hpp index 2105e7a88..372c0ea65 100644 --- a/samples/golf/src/golf/GolfState.hpp +++ b/samples/golf/src/golf/GolfState.hpp @@ -594,6 +594,7 @@ class GolfState final : public cro::State, public cro::GuiClient, public cro::Co std::vector m_statBoardScores; void updateLeague(); + void setUIHidden(bool hidden); struct GamepadNotify final { diff --git a/samples/golf/src/golf/GolfStateCameras.cpp b/samples/golf/src/golf/GolfStateCameras.cpp index 0b6ef4619..00915e5b2 100644 --- a/samples/golf/src/golf/GolfStateCameras.cpp +++ b/samples/golf/src/golf/GolfStateCameras.cpp @@ -752,10 +752,7 @@ void GolfState::toggleFreeCam() //reduce fade distance m_resolutionUpdate.targetFade = 0.2f; - //hide UI by bringing scene ent to front - auto origin = m_courseEnt.getComponent().getOrigin(); - origin.z = -3.f; - m_courseEnt.getComponent().setOrigin(origin); + setUIHidden(true); } else { @@ -769,9 +766,7 @@ void GolfState::toggleFreeCam() m_resolutionUpdate.targetFade = m_currentPlayer.terrain == TerrainID::Green ? GreenFadeDistance : CourseFadeDistance; //unhide UI - auto origin = m_courseEnt.getComponent().getOrigin(); - origin.z = 0.5f; - m_courseEnt.getComponent().setOrigin(origin); + setUIHidden(false); //and stroke indicator diff --git a/samples/golf/src/golf/GolfStateDebug.cpp b/samples/golf/src/golf/GolfStateDebug.cpp index 89d0ac268..ea27e9bde 100644 --- a/samples/golf/src/golf/GolfStateDebug.cpp +++ b/samples/golf/src/golf/GolfStateDebug.cpp @@ -434,6 +434,22 @@ void GolfState::registerDebugCommands() }); + registerCommand("cl_drawhud", [&](const std::string& param) + { + if (param == "1" || param == "true") + { + setUIHidden(false); + } + else if (param == "0" || param == "false") + { + setUIHidden(true); + } + else + { + cro::Console::print("Usage: cl_drawhud <0|1>"); + } + }); + //nasssssty staticses static bool showKickWindow = false; if (m_sharedData.hosting) diff --git a/samples/golf/src/golf/GolfStateUI.cpp b/samples/golf/src/golf/GolfStateUI.cpp index 68dcfd71f..072b00023 100644 --- a/samples/golf/src/golf/GolfStateUI.cpp +++ b/samples/golf/src/golf/GolfStateUI.cpp @@ -4686,6 +4686,23 @@ void GolfState::updateLeague() } } +void GolfState::setUIHidden(bool hidden) +{ + if (hidden) + { + //hide UI by bringing scene ent to front + auto origin = m_courseEnt.getComponent().getOrigin(); + origin.z = -3.f; + m_courseEnt.getComponent().setOrigin(origin); + } + else + { + auto origin = m_courseEnt.getComponent().getOrigin(); + origin.z = 0.5f; + m_courseEnt.getComponent().setOrigin(origin); + } +} + void MinimapZoom::updateShader() { CRO_ASSERT(glm::length2(textureSize) != 0, ""); From 0c23afdf07be5d297f472087b58eaec2b6bb4113 Mon Sep 17 00:00:00 2001 From: fallahn Date: Tue, 23 Apr 2024 11:02:37 +0100 Subject: [PATCH 08/12] fade balls on minimap when not currently active player --- samples/golf/buildnumber.h | 4 +-- samples/golf/src/golf/GolfState.cpp | 1 + samples/golf/src/golf/MiniBallSystem.cpp | 31 +++++++++++++++++++++--- samples/golf/src/golf/MiniBallSystem.hpp | 3 +++ 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/samples/golf/buildnumber.h b/samples/golf/buildnumber.h index 21c4e09ea..fe9d36265 100644 --- a/samples/golf/buildnumber.h +++ b/samples/golf/buildnumber.h @@ -3,7 +3,7 @@ #ifndef BUILD_NUMBER_H_ #define BUILD_NUMBER_H_ -#define BUILDNUMBER 5426 -#define BUILDNUMBER_STR "5426" +#define BUILDNUMBER 5431 +#define BUILDNUMBER_STR "5431" #endif /* BUILD_NUMBER_H_ */ diff --git a/samples/golf/src/golf/GolfState.cpp b/samples/golf/src/golf/GolfState.cpp index 326b3f24e..a1317ca25 100644 --- a/samples/golf/src/golf/GolfState.cpp +++ b/samples/golf/src/golf/GolfState.cpp @@ -5206,6 +5206,7 @@ void GolfState::setCurrentPlayer(const ActivePlayer& player) auto localPlayer = (player.client == m_sharedData.clientConnection.connectionID); auto isCPU = m_sharedData.connectionData[player.client].playerData[player.player].isCPU; + m_uiScene.getSystem()->setActivePlayer(player.client, player.player); m_gameScene.getDirector()->setActivePlayer(player.client, player.player, isCPU && m_sharedData.fastCPU); m_avatars[player.client][player.player].ballModel.getComponent().setScale(glm::vec3(1.f)); diff --git a/samples/golf/src/golf/MiniBallSystem.cpp b/samples/golf/src/golf/MiniBallSystem.cpp index 3da38656b..9d2db7817 100644 --- a/samples/golf/src/golf/MiniBallSystem.cpp +++ b/samples/golf/src/golf/MiniBallSystem.cpp @@ -29,6 +29,7 @@ source distribution. #include "MiniBallSystem.hpp" #include "MinimapZoom.hpp" +#include "CommonConsts.hpp" #include #include @@ -38,7 +39,8 @@ source distribution. MiniBallSystem::MiniBallSystem(cro::MessageBus& mb, const MinimapZoom& mz) : cro::System(mb, typeid(MiniBallSystem)), - m_minimapZoom(mz) + m_minimapZoom(mz), + m_activePlayer(0) { requireComponent(); requireComponent(); @@ -84,7 +86,7 @@ void MiniBallSystem::process(float dt) if (ball.parent.isValid()) { auto position = ball.parent.getComponent().getPosition(); - entity.getComponent().setPosition(glm::vec3(m_minimapZoom.toMapCoords(position), 0.1f)); + entity.getComponent().setPosition(glm::vec3(m_minimapZoom.toMapCoords(position), 0.1f * ball.playerID)); } } else @@ -92,7 +94,7 @@ void MiniBallSystem::process(float dt) if (ball.parent.isValid()) { auto position = ball.parent.getComponent().getPosition(); - entity.getComponent().setPosition(glm::vec3(m_minimapZoom.toMapCoords(position), 0.1f)); + entity.getComponent().setPosition(glm::vec3(m_minimapZoom.toMapCoords(position), 0.1f * ball.playerID)); //set scale based on height static constexpr float MaxHeight = 40.f; @@ -104,7 +106,30 @@ void MiniBallSystem::process(float dt) auto miniBounds = ball.minimap.getComponent().getWorldTransform() * ball.minimap.getComponent().getLocalBounds(); auto renderBounds = glm::inverse(entity.getComponent().getWorldTransform()) * miniBounds; entity.getComponent().setCroppingArea(renderBounds); + + + //fade out the ball if not the active player to make current player more prominent + auto& verts = entity.getComponent().getVertexData(); + float alpha = verts[0].colour.getAlpha(); + if (ball.playerID == m_activePlayer) + { + alpha = std::min(1.f, alpha + dt); + } + else + { + alpha = std::max(0.4f, alpha - dt); + } + for (auto& v : verts) + { + v.colour.setAlpha(alpha); + } } } } +} + +void MiniBallSystem::setActivePlayer(std::uint8_t client, std::uint8_t player) +{ + //this MUST match how the ball playerID is calculated (and actually should be a single func somewhere) + m_activePlayer = ((client * ConstVal::MaxPlayers) + player) + 1; } \ No newline at end of file diff --git a/samples/golf/src/golf/MiniBallSystem.hpp b/samples/golf/src/golf/MiniBallSystem.hpp index aa3fc35a3..f57a36ecd 100644 --- a/samples/golf/src/golf/MiniBallSystem.hpp +++ b/samples/golf/src/golf/MiniBallSystem.hpp @@ -54,6 +54,9 @@ class MiniBallSystem final : public cro::System void process(float) override; + void setActivePlayer(std::uint8_t client, std::uint8_t player); + private: const MinimapZoom& m_minimapZoom; + std::int32_t m_activePlayer; }; \ No newline at end of file From ff26c28d635618ecb696ffdf0379ee03974c4345 Mon Sep 17 00:00:00 2001 From: fallahn Date: Wed, 24 Apr 2024 12:04:59 +0100 Subject: [PATCH 09/12] favour the humans in league tie-break --- samples/golf/src/golf/League.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/golf/src/golf/League.cpp b/samples/golf/src/golf/League.cpp index a0d33a374..9697736c2 100644 --- a/samples/golf/src/golf/League.cpp +++ b/samples/golf/src/golf/League.cpp @@ -619,7 +619,7 @@ void League::createSortedTable() { return a.handicap > b.handicap; } - return false; + return true; //favour the humans } return a.score > b.score; }); From e1e94cf9f2fbf61e7c02569d2a112caf25bec687 Mon Sep 17 00:00:00 2001 From: fallahn Date: Fri, 26 Apr 2024 13:40:37 +0100 Subject: [PATCH 10/12] implement CAT auth --- libsocial/include/Social.hpp | 1 + samples/golf/buildnumber.h | 4 +- samples/golf/src/golf/GolfState.cpp | 3 ++ samples/golf/src/golf/GolfState.hpp | 3 +- samples/golf/src/golf/GolfStateUI.cpp | 53 +++++++++++++++++++++++++ samples/golf/src/golf/PacketIDs.hpp | 9 +++++ samples/golf/src/golf/TextChat.cpp | 3 +- samples/golf/src/golf/server/Server.cpp | 10 ++++- 8 files changed, 80 insertions(+), 6 deletions(-) diff --git a/libsocial/include/Social.hpp b/libsocial/include/Social.hpp index 5cb39e00c..91407d09a 100644 --- a/libsocial/include/Social.hpp +++ b/libsocial/include/Social.hpp @@ -144,6 +144,7 @@ class Social final static bool isGreyscale() { return false; } static bool isValid(); static bool isValid(const std::string&) { return true; } + static bool isAuth() { return false; } static bool isAvailable() { return false; } static bool isSteamdeck() { return false; } static cro::Image getUserIcon(std::uint64_t) { return userIcon; } diff --git a/samples/golf/buildnumber.h b/samples/golf/buildnumber.h index fe9d36265..6cd2c9d48 100644 --- a/samples/golf/buildnumber.h +++ b/samples/golf/buildnumber.h @@ -3,7 +3,7 @@ #ifndef BUILD_NUMBER_H_ #define BUILD_NUMBER_H_ -#define BUILDNUMBER 5431 -#define BUILDNUMBER_STR "5431" +#define BUILDNUMBER 5438 +#define BUILDNUMBER_STR "5438" #endif /* BUILD_NUMBER_H_ */ diff --git a/samples/golf/src/golf/GolfState.cpp b/samples/golf/src/golf/GolfState.cpp index a1317ca25..d99e4ed20 100644 --- a/samples/golf/src/golf/GolfState.cpp +++ b/samples/golf/src/golf/GolfState.cpp @@ -3612,6 +3612,9 @@ void GolfState::handleNetEvent(const net::NetEvent& evt) switch (evt.packet.getID()) { default: break; + case PacketID::CAT: + catAuth(); + break; case PacketID::DronePosition: if (!m_sharedData.hosting) { diff --git a/samples/golf/src/golf/GolfState.hpp b/samples/golf/src/golf/GolfState.hpp index 372c0ea65..caa235ecd 100644 --- a/samples/golf/src/golf/GolfState.hpp +++ b/samples/golf/src/golf/GolfState.hpp @@ -1,6 +1,6 @@ /*----------------------------------------------------------------------- -Matt Marchant 2021 - 2023 +Matt Marchant 2021 - 2024 http://trederia.blogspot.com Super Video Golf - zlib licence. @@ -485,6 +485,7 @@ class GolfState final : public cro::State, public cro::GuiClient, public cro::Co SkipState m_skipState; void updateSkipMessage(float); void refreshUI(); + void catAuth(); glm::vec3 findTargetPos(glm::vec3 playerPos) const; //decides if we should be using the sub-target (if it exists) //hack to allow the profile update to be const. diff --git a/samples/golf/src/golf/GolfStateUI.cpp b/samples/golf/src/golf/GolfStateUI.cpp index 072b00023..a9341dcc9 100644 --- a/samples/golf/src/golf/GolfStateUI.cpp +++ b/samples/golf/src/golf/GolfStateUI.cpp @@ -4156,6 +4156,59 @@ void GolfState::refreshUI() m_uiScene.getSystem()->sendCommand(cmd); } +void GolfState::catAuth() +{ + cro::SpriteSheet sheet; + if (sheet.loadFromFile("assets/golf/sprites/rockit.spt", m_resources.textures)) + { + auto entity = m_uiScene.createEntity(); + entity.addComponent().setPosition({ -380.f, 120.f, 0.1f }); + entity.getComponent().setScale(m_viewScale); + entity.addComponent(); + entity.addComponent() = sheet.getSprite("rockit"); + entity.addComponent().play(0); + entity.addComponent().active = true; + entity.getComponent().setUserData>(0, 2.f); + entity.getComponent().function = + [&](cro::Entity e, float dt) + { + const glm::vec2 Speed = glm::vec2(420.f * m_viewScale.x, 0.f); + auto& [state, currTime] = e.getComponent().getUserData>(); + switch (state) + { + case 0: + e.getComponent().move(Speed * dt); + if (e.getComponent().getPosition().x > (static_cast(cro::App::getWindow().getSize().x)/* / m_viewScale.x*/) * 2.f) + { + state = 1; + e.getComponent().setScale({ -m_viewScale.x, m_viewScale.y }); + e.getComponent().move({ 0.f, 120.f * m_viewScale.y }); + e.getComponent().setFacing(cro::Drawable2D::Facing::Back); + } + break; + case 1: + currTime -= dt; + if (currTime < 0) + { + state = 2; + } + break; + case 2: + e.getComponent().move(-Speed * dt); + if (e.getComponent().getPosition().x < 0) + { + e.getComponent().active = false; + m_uiScene.destroyEntity(e); + } + break; + default: + m_uiScene.destroyEntity(e); + break; + } + }; + } +} + void GolfState::buildTrophyScene() { auto updateCam = [&](cro::Camera& cam) diff --git a/samples/golf/src/golf/PacketIDs.hpp b/samples/golf/src/golf/PacketIDs.hpp index 794654712..e193a60c5 100644 --- a/samples/golf/src/golf/PacketIDs.hpp +++ b/samples/golf/src/golf/PacketIDs.hpp @@ -31,6 +31,8 @@ source distribution. #include "ScoreType.hpp" +#include + #include #include #include @@ -93,6 +95,12 @@ struct TextMessage final static constexpr std::size_t MaxBytes = 8192; std::array messageData = {}; TextMessage() { std::fill(messageData.begin(), messageData.end(), 0); } + + cro::String getString() const + { + //we have to manually truncate this else we get a lot of white space + return cro::String::fromUtf8(messageData.begin(), std::find(messageData.begin(), messageData.end(), 0)); + } }; namespace PacketID @@ -138,6 +146,7 @@ namespace PacketID WarnTime, //< uint8 warning time for AFK in seconds WeatherChange, //< 0 off 1 on uint8 Poke, //< uint8 0 - only sent to specific client + CAT, //from client RequestGameStart, //uint8 sv::State, ie Golf to start golf, Billiards to start billiards etc diff --git a/samples/golf/src/golf/TextChat.cpp b/samples/golf/src/golf/TextChat.cpp index e185c1a3c..5b0cdfefe 100644 --- a/samples/golf/src/golf/TextChat.cpp +++ b/samples/golf/src/golf/TextChat.cpp @@ -420,8 +420,7 @@ bool TextChat::handlePacket(const net::NetEvent::Packet& pkt) //so we'll always assume it's player 0 auto outStr = m_sharedData.connectionData[msg.client].playerData[0].name; - //we have to manually truncate this else we get a lot of white space - auto msgText = cro::String::fromUtf8(msg.messageData.begin(), std::find(msg.messageData.begin(), msg.messageData.end(), 0)); + auto msgText = msg.getString();// cro::String::fromUtf8(msg.messageData.begin(), std::find(msg.messageData.begin(), msg.messageData.end(), 0)); #ifdef USE_GNS Social::filterString(msgText); diff --git a/samples/golf/src/golf/server/Server.cpp b/samples/golf/src/golf/server/Server.cpp index 87f17befe..2d73084d5 100644 --- a/samples/golf/src/golf/server/Server.cpp +++ b/samples/golf/src/golf/server/Server.cpp @@ -242,7 +242,15 @@ void Server::run() m_sharedData.host.broadcastPacket(PacketID::PlayerXP, evt.packet.as(), net::NetFlag::Reliable); break; case PacketID::ChatMessage: - m_sharedData.host.broadcastPacket(PacketID::ChatMessage, evt.packet.as(), net::NetFlag::Reliable, ConstVal::NetChannelStrings); + { + const auto msg = evt.packet.as(); + if (msg.getString() == "CAT" + && Social::isAuth()) + { + m_sharedData.host.broadcastPacket(PacketID::CAT, std::uint8_t(0), net::NetFlag::Reliable, ConstVal::NetChannelReliable); + } + m_sharedData.host.broadcastPacket(PacketID::ChatMessage, msg, net::NetFlag::Reliable, ConstVal::NetChannelStrings); + } break; } } From 8e17befa5c0fbf355fd99e845c202c24530f39df Mon Sep 17 00:00:00 2001 From: fallahn Date: Fri, 26 Apr 2024 23:04:18 +0100 Subject: [PATCH 11/12] tweakages --- samples/golf/buildnumber.h | 4 ++-- samples/golf/src/golf/GolfState.cpp | 9 +++++++-- samples/golf/src/golf/GolfStateUI.cpp | 6 +++--- samples/golf/src/golf/OptionsState.cpp | 10 +++++----- samples/golf/src/golf/Weather.cpp | 2 +- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/samples/golf/buildnumber.h b/samples/golf/buildnumber.h index 6cd2c9d48..2cc5a6d91 100644 --- a/samples/golf/buildnumber.h +++ b/samples/golf/buildnumber.h @@ -3,7 +3,7 @@ #ifndef BUILD_NUMBER_H_ #define BUILD_NUMBER_H_ -#define BUILDNUMBER 5438 -#define BUILDNUMBER_STR "5438" +#define BUILDNUMBER 5448 +#define BUILDNUMBER_STR "5448" #endif /* BUILD_NUMBER_H_ */ diff --git a/samples/golf/src/golf/GolfState.cpp b/samples/golf/src/golf/GolfState.cpp index d99e4ed20..d0940540f 100644 --- a/samples/golf/src/golf/GolfState.cpp +++ b/samples/golf/src/golf/GolfState.cpp @@ -6254,7 +6254,8 @@ void GolfState::startFlyBy() data.speeds[2] *= 1.f / SpeedMultiplier; //play the transition music - if (m_sharedData.gameMode == GameMode::Tutorial) + if (m_sharedData.gameMode == GameMode::Tutorial + && cro::AudioMixer::getVolume(MixerChannel::UserMusic) < 0.01f) { m_cameras[CameraID::Player].getComponent().play(); } @@ -6277,7 +6278,11 @@ void GolfState::startFlyBy() { showScoreboard(true); m_newHole = true; - m_cameras[CameraID::Player].getComponent().play(); + + if (cro::AudioMixer::getVolume(MixerChannel::UserMusic) < 0.01f) + { + m_cameras[CameraID::Player].getComponent().play(); + } //delayed ent just to show the score board for a while auto de = m_gameScene.createEntity(); diff --git a/samples/golf/src/golf/GolfStateUI.cpp b/samples/golf/src/golf/GolfStateUI.cpp index a9341dcc9..d5716cf6e 100644 --- a/samples/golf/src/golf/GolfStateUI.cpp +++ b/samples/golf/src/golf/GolfStateUI.cpp @@ -835,7 +835,7 @@ void GolfState::buildUI() const auto BarWidth = bounds.width - 8.f; const auto BarHeight = bounds.height; entity = m_uiScene.createEntity(); - entity.addComponent().setPosition(glm::vec3(5.f, 0.f, 0.1f)); //TODO expell the magic number!! + entity.addComponent().setPosition(glm::vec3(5.f, 0.f, 0.3f)); //TODO expell the magic number!! entity.addComponent(); entity.addComponent() = m_sprites[SpriteID::PowerBarInner]; bounds = entity.getComponent().getTextureBounds(); @@ -851,7 +851,7 @@ void GolfState::buildUI() //hook/slice indicator entity = m_uiScene.createEntity(); - entity.addComponent().setPosition(glm::vec3(BarCentre, 8.f, 0.25f)); + entity.addComponent().setPosition(glm::vec3(BarCentre, 8.f, 0.55f)); entity.addComponent(); entity.addComponent() = m_sprites[SpriteID::HookBar]; bounds = entity.getComponent().getTextureBounds(); @@ -860,7 +860,7 @@ void GolfState::buildUI() entity.getComponent().function = [&, BarCentre](cro::Entity e, float) { - glm::vec3 pos(std::round(BarCentre + (BarCentre * m_inputParser.getHook())), 8.f, 0.25f); + glm::vec3 pos(std::round(BarCentre + (BarCentre * m_inputParser.getHook())), 8.f, 0.55f); e.getComponent().setPosition(pos); }; barEnt.getComponent().addChild(entity.getComponent()); diff --git a/samples/golf/src/golf/OptionsState.cpp b/samples/golf/src/golf/OptionsState.cpp index 0b67a3944..22b63a20c 100644 --- a/samples/golf/src/golf/OptionsState.cpp +++ b/samples/golf/src/golf/OptionsState.cpp @@ -116,10 +116,10 @@ namespace const std::array MixerLabels = { "Menu Music", - "Effects Volume", - "Menu Volume", - "Voice Volume", - "Vehicle Volume", + "Effects", + "Menu Sounds", + "Voice", + "Vehicles", "Environment", "Game Music" }; @@ -1313,7 +1313,7 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit }; //audio label - auto audioLabel = createLabel(glm::vec2((bgBounds.width / 2.f) - 101.f, 156.f), "Music Volume"); + auto audioLabel = createLabel(glm::vec2((bgBounds.width / 2.f) - 101.f, 156.f), MixerLabels[mixerChannelIndex]); centreText(audioLabel); audioLabel.addComponent().active = true; audioLabel.getComponent().function = diff --git a/samples/golf/src/golf/Weather.cpp b/samples/golf/src/golf/Weather.cpp index bf15f4202..f06153f99 100644 --- a/samples/golf/src/golf/Weather.cpp +++ b/samples/golf/src/golf/Weather.cpp @@ -220,7 +220,7 @@ void GolfState::createWeather(std::int32_t weatherType) else { m_resources.shaders.loadFromString(ShaderID::Weather, WeatherVertex, RainFragment); - weatherColour = cro::Colour(0.86f, 0.87f, 0.873f); + weatherColour = cro::Colour(0.86f, 0.87f, 0.873f, 0.6f); //blendMode = cro::Material::BlendMode::Custom; //create audio entity From 6fd65c3d2ef54f16d2b472e90085d256f9bcb747 Mon Sep 17 00:00:00 2001 From: fallahn Date: Sat, 27 Apr 2024 10:23:16 +0100 Subject: [PATCH 12/12] update options label for Steam Deck tweak colour opacity --- samples/golf/buildnumber.h | 4 +- samples/golf/src/golf/GolfState.cpp | 6 +- samples/golf/src/golf/OptionsState.cpp | 418 +++++++++--------- samples/golf/src/golf/Weather.cpp | 2 +- .../golf/src/golf/WeatherAnimationSystem.cpp | 2 +- .../golf/src/golf/shaders/TerrainShader.inl | 2 +- 6 files changed, 220 insertions(+), 214 deletions(-) diff --git a/samples/golf/buildnumber.h b/samples/golf/buildnumber.h index 2cc5a6d91..002c77729 100644 --- a/samples/golf/buildnumber.h +++ b/samples/golf/buildnumber.h @@ -3,7 +3,7 @@ #ifndef BUILD_NUMBER_H_ #define BUILD_NUMBER_H_ -#define BUILDNUMBER 5448 -#define BUILDNUMBER_STR "5448" +#define BUILDNUMBER 5455 +#define BUILDNUMBER_STR "5455" #endif /* BUILD_NUMBER_H_ */ diff --git a/samples/golf/src/golf/GolfState.cpp b/samples/golf/src/golf/GolfState.cpp index d0940540f..c0b855c31 100644 --- a/samples/golf/src/golf/GolfState.cpp +++ b/samples/golf/src/golf/GolfState.cpp @@ -6255,7 +6255,8 @@ void GolfState::startFlyBy() //play the transition music if (m_sharedData.gameMode == GameMode::Tutorial - && cro::AudioMixer::getVolume(MixerChannel::UserMusic) < 0.01f) + && cro::AudioMixer::getVolume(MixerChannel::UserMusic) < 0.01f + && cro::AudioMixer::getVolume(MixerChannel::Music) != 0) { m_cameras[CameraID::Player].getComponent().play(); } @@ -6279,7 +6280,8 @@ void GolfState::startFlyBy() showScoreboard(true); m_newHole = true; - if (cro::AudioMixer::getVolume(MixerChannel::UserMusic) < 0.01f) + if (cro::AudioMixer::getVolume(MixerChannel::UserMusic) < 0.01f + && cro::AudioMixer::getVolume(MixerChannel::Music) != 0) { m_cameras[CameraID::Player].getComponent().play(); } diff --git a/samples/golf/src/golf/OptionsState.cpp b/samples/golf/src/golf/OptionsState.cpp index 22b63a20c..6ffb34ec3 100644 --- a/samples/golf/src/golf/OptionsState.cpp +++ b/samples/golf/src/golf/OptionsState.cpp @@ -1300,17 +1300,17 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit parent.getComponent().addChild(titleEnt.getComponent()); auto createLabel = [&](glm::vec2 pos, const std::string& str) - { - auto entity = m_scene.createEntity(); - entity.addComponent().setPosition(glm::vec3(pos, TextOffset)); - entity.addComponent(); - entity.addComponent(font).setCharacterSize(InfoTextSize); - entity.getComponent().setString(str); - entity.getComponent().setFillColour(TextNormalColour); - parent.getComponent().addChild(entity.getComponent()); + { + auto entity = m_scene.createEntity(); + entity.addComponent().setPosition(glm::vec3(pos, TextOffset)); + entity.addComponent(); + entity.addComponent(font).setCharacterSize(InfoTextSize); + entity.getComponent().setString(str); + entity.getComponent().setFillColour(TextNormalColour); + parent.getComponent().addChild(entity.getComponent()); - return entity; - }; + return entity; + }; //audio label auto audioLabel = createLabel(glm::vec2((bgBounds.width / 2.f) - 101.f, 156.f), MixerLabels[mixerChannelIndex]); @@ -1318,18 +1318,18 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit audioLabel.addComponent().active = true; audioLabel.getComponent().function = [&](cro::Entity e, float) - { - updateToolTip(e, ToolTipID::CustomMusic); - }; + { + updateToolTip(e, ToolTipID::CustomMusic); + }; //antialiasing label auto aliasLabel = createLabel(glm::vec2(12.f, 131.f), "Antialiasing"); aliasLabel.addComponent().active = true; aliasLabel.getComponent().function = [&](cro::Entity e, float) - { - updateToolTip(e, ToolTipID::AA); - }; + { + updateToolTip(e, ToolTipID::AA); + }; auto aaLabel = createLabel(glm::vec2(136.f, 131.f), AAStrings[AAIndexMap[m_sharedData.multisamples]]); centreText(aaLabel); @@ -1351,18 +1351,18 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit pixelLabel.addComponent().active = true; pixelLabel.getComponent().function = [&](cro::Entity e, float) - { - updateToolTip(e, ToolTipID::Pixel); - }; + { + updateToolTip(e, ToolTipID::Pixel); + }; //vertex snap label auto vertLabel = createLabel(glm::vec2(12.f, 67.f), "Vertex Snap (requires restart)"); vertLabel.addComponent().active = true; vertLabel.getComponent().function = [&](cro::Entity e, float) - { - updateToolTip(e, ToolTipID::VertSnap); - }; + { + updateToolTip(e, ToolTipID::VertSnap); + }; //full screen label createLabel(glm::vec2(12.f, 51.f), "Full Screen"); @@ -1375,21 +1375,21 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit beaconLabel.addComponent().active = true; beaconLabel.getComponent().function = [&](cro::Entity e, float) - { - updateToolTip(e, ToolTipID::Beacon); - }; + { + updateToolTip(e, ToolTipID::Beacon); + }; //ball trail label createLabel({ 204.f, 131.f }, "Enable Ball Trail"); - + //putting assist auto puttingEnt = createLabel({ 204.f, 115.f }, "Enable Putting Assist"); puttingEnt.addComponent().active = true; puttingEnt.getComponent().function = [&](cro::Entity e, float) - { - updateToolTip(e, ToolTipID::PuttingPower); - }; + { + updateToolTip(e, ToolTipID::PuttingPower); + }; //post process label @@ -1400,9 +1400,9 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit measureLabel.addComponent().active = true; measureLabel.getComponent().function = [&](cro::Entity e, float) - { - updateToolTip(e, ToolTipID::Units); - }; + { + updateToolTip(e, ToolTipID::Units); + }; //grid transparency createLabel({ 204.f, 67.f }, "Grid Amount"); @@ -1410,16 +1410,16 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit //tree quality auto treeLabel = createLabel({ 204.f, 51.f }, "Tree Quality"); treeLabel.addComponent().active = true; - treeLabel.getComponent().function = + treeLabel.getComponent().function = [&](cro::Entity e, float) - { - updateToolTip(e, ToolTipID::NeedsRestart); - }; + { + updateToolTip(e, ToolTipID::NeedsRestart); + }; //shadow quality createLabel({ 204.f, 35.f }, "Shadow Quality"); - + //crowd density /*auto crowdLabel =*/ createLabel({ 204, 19.f }, "Crowd Density"); //crowdLabel.addComponent().active = true; @@ -1431,30 +1431,30 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit auto createSlider = [&](glm::vec2 position) - { - auto entity = m_scene.createEntity(); - entity.addComponent().setPosition(position); - entity.addComponent(); - entity.addComponent() = spriteSheet.getSprite("slider"); - auto bounds = entity.getComponent().getTextureBounds(); - entity.getComponent().setOrigin({ std::floor(bounds.width / 2.f), /*std::floor*/(bounds.height / 2.f), -TextOffset }); + { + auto entity = m_scene.createEntity(); + entity.addComponent().setPosition(position); + entity.addComponent(); + entity.addComponent() = spriteSheet.getSprite("slider"); + auto bounds = entity.getComponent().getTextureBounds(); + entity.getComponent().setOrigin({ std::floor(bounds.width / 2.f), /*std::floor*/(bounds.height / 2.f), -TextOffset }); - auto userData = SliderData(position); - userData.onActivate = [](float distance) - { - float vol = distance; - cro::AudioMixer::setVolume(vol, mixerChannelIndex); - }; - entity.addComponent().active = true; - entity.getComponent().setUserData(userData); - entity.getComponent().function = SliderCallback(); + auto userData = SliderData(position); + userData.onActivate = [](float distance) + { + float vol = distance; + cro::AudioMixer::setVolume(vol, mixerChannelIndex); + }; + entity.addComponent().active = true; + entity.getComponent().setUserData(userData); + entity.getComponent().function = SliderCallback(); - parent.getComponent().addChild(entity.getComponent()); + parent.getComponent().addChild(entity.getComponent()); - m_sliders.push_back(entity); - return entity; - }; + m_sliders.push_back(entity); + return entity; + }; //volume slider auto volSlider = createSlider(glm::vec2(192.f, 153.f)); @@ -1463,33 +1463,33 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit tipEnt.addComponent().active = true; tipEnt.getComponent().function = [&, volSlider](cro::Entity e, float) - { - auto mousePos = m_scene.getActiveCamera().getComponent().pixelToCoords(cro::Mouse::getPosition()); - auto bounds = volSlider.getComponent().getLocalBounds(); - bounds = volSlider.getComponent().getWorldTransform() * bounds; - - if (bounds.contains(mousePos)) { - mousePos.x = std::floor(mousePos.x); - mousePos.y = std::floor(mousePos.y); - mousePos.z = ToolTipDepth / 2.f; - - if (m_tooltips[ToolTipID::Volume].getComponent().getScale().x == 0) + auto mousePos = m_scene.getActiveCamera().getComponent().pixelToCoords(cro::Mouse::getPosition()); + auto bounds = volSlider.getComponent().getLocalBounds(); + bounds = volSlider.getComponent().getWorldTransform() * bounds; + + if (bounds.contains(mousePos)) { - m_scene.getActiveCamera().getComponent().active = true; - } + mousePos.x = std::floor(mousePos.x); + mousePos.y = std::floor(mousePos.y); + mousePos.z = ToolTipDepth / 2.f; + + if (m_tooltips[ToolTipID::Volume].getComponent().getScale().x == 0) + { + m_scene.getActiveCamera().getComponent().active = true; + } - m_tooltips[ToolTipID::Volume].getComponent().setPosition(mousePos + (ToolTipOffset * m_viewScale.x)); - m_tooltips[ToolTipID::Volume].getComponent().setScale(m_viewScale); + m_tooltips[ToolTipID::Volume].getComponent().setPosition(mousePos + (ToolTipOffset * m_viewScale.x)); + m_tooltips[ToolTipID::Volume].getComponent().setScale(m_viewScale); - float vol = cro::AudioMixer::getVolume(mixerChannelIndex); - m_tooltips[ToolTipID::Volume].getComponent().setString("Vol: " + std::to_string(static_cast(vol * 100.f))); - } - else - { - m_tooltips[ToolTipID::Volume].getComponent().setScale(glm::vec2(0.f)); - } - }; + float vol = cro::AudioMixer::getVolume(mixerChannelIndex); + m_tooltips[ToolTipID::Volume].getComponent().setString("Vol: " + std::to_string(static_cast(vol * 100.f))); + } + else + { + m_tooltips[ToolTipID::Volume].getComponent().setScale(glm::vec2(0.f)); + } + }; volSlider.getComponent().addChild(tipEnt.getComponent()); @@ -1498,65 +1498,65 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit auto fovPos = glm::vec2(99.f, 112.f); auto fovSlider = createSlider(fovPos); auto userData = SliderData(fovPos, 76.f); - userData.onActivate = + userData.onActivate = [&, fovLabel](float distance) mutable - { - float fov = MinFOV + ((MaxFOV - MinFOV) * distance); + { + float fov = MinFOV + ((MaxFOV - MinFOV) * distance); - m_sharedData.fov = fov; + m_sharedData.fov = fov; - //raise a window resize message to trigger callbacks - auto size = cro::App::getWindow().getSize(); - auto* msg = cro::App::getInstance().getMessageBus().post(cro::Message::WindowMessage); - msg->data0 = size.x; - msg->data1 = size.y; - msg->event = SDL_WINDOWEVENT_SIZE_CHANGED; + //raise a window resize message to trigger callbacks + auto size = cro::App::getWindow().getSize(); + auto* msg = cro::App::getInstance().getMessageBus().post(cro::Message::WindowMessage); + msg->data0 = size.x; + msg->data1 = size.y; + msg->event = SDL_WINDOWEVENT_SIZE_CHANGED; - fovLabel.getComponent().setString("FOV: " + std::to_string(static_cast(m_sharedData.fov))); - }; + fovLabel.getComponent().setString("FOV: " + std::to_string(static_cast(m_sharedData.fov))); + }; fovSlider.getComponent().setUserData(userData); fovSlider.getComponent().function = [&](cro::Entity e, float) - { - const auto& [pos, width, _] = e.getComponent().getUserData(); - float amount = (m_sharedData.fov - MinFOV) / (MaxFOV - MinFOV); + { + const auto& [pos, width, _] = e.getComponent().getUserData(); + float amount = (m_sharedData.fov - MinFOV) / (MaxFOV - MinFOV); - e.getComponent().setPosition({ pos.x + (width * amount), pos.y }); - }; + e.getComponent().setPosition({ pos.x + (width * amount), pos.y }); + }; tipEnt = m_scene.createEntity(); tipEnt.addComponent(); tipEnt.addComponent().active = true; tipEnt.getComponent().function = [&, fovSlider](cro::Entity, float) - { - auto mousePos = m_scene.getActiveCamera().getComponent().pixelToCoords(cro::Mouse::getPosition()); - auto bounds = fovSlider.getComponent().getLocalBounds(); - bounds = fovSlider.getComponent().getWorldTransform() * bounds; - - if (bounds.contains(mousePos)) { - mousePos.x = std::floor(mousePos.x); - mousePos.y = std::floor(mousePos.y); - mousePos.z = ToolTipDepth; + auto mousePos = m_scene.getActiveCamera().getComponent().pixelToCoords(cro::Mouse::getPosition()); + auto bounds = fovSlider.getComponent().getLocalBounds(); + bounds = fovSlider.getComponent().getWorldTransform() * bounds; - if (m_tooltips[ToolTipID::FOV].getComponent().getScale().x == 0) + if (bounds.contains(mousePos)) { - m_scene.getActiveCamera().getComponent().active = true; - } + mousePos.x = std::floor(mousePos.x); + mousePos.y = std::floor(mousePos.y); + mousePos.z = ToolTipDepth; - m_tooltips[ToolTipID::FOV].getComponent().setPosition(mousePos + (ToolTipOffset * m_viewScale.x)); - m_tooltips[ToolTipID::FOV].getComponent().setScale(m_viewScale); + if (m_tooltips[ToolTipID::FOV].getComponent().getScale().x == 0) + { + m_scene.getActiveCamera().getComponent().active = true; + } - float fov = m_sharedData.fov; - m_tooltips[ToolTipID::FOV].getComponent().setString("FOV: " + std::to_string(static_cast(fov))); - } - else - { - m_tooltips[ToolTipID::FOV].getComponent().setScale(glm::vec2(0.f)); - } - }; + m_tooltips[ToolTipID::FOV].getComponent().setPosition(mousePos + (ToolTipOffset * m_viewScale.x)); + m_tooltips[ToolTipID::FOV].getComponent().setScale(m_viewScale); + + float fov = m_sharedData.fov; + m_tooltips[ToolTipID::FOV].getComponent().setString("FOV: " + std::to_string(static_cast(fov))); + } + else + { + m_tooltips[ToolTipID::FOV].getComponent().setScale(glm::vec2(0.f)); + } + }; fovSlider.getComponent().addChild(tipEnt.getComponent()); //grid transparency @@ -1565,16 +1565,16 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit auto ud = SliderData(transPos, 91.f); ud.onActivate = [&](float distance) - { - m_sharedData.gridTransparency = distance; - }; + { + m_sharedData.gridTransparency = distance; + }; transSlider.getComponent().setUserData(ud); transSlider.getComponent().function = [&](cro::Entity e, float) - { - const auto& [pos, width, _] = e.getComponent().getUserData(); - e.getComponent().setPosition({ pos.x + (width * m_sharedData.gridTransparency), pos.y }); - }; + { + const auto& [pos, width, _] = e.getComponent().getUserData(); + e.getComponent().setPosition({ pos.x + (width * m_sharedData.gridTransparency), pos.y }); + }; auto helpEnt = m_scene.createEntity(); helpEnt.addComponent().setPosition({ bgBounds.width / 2.f, -9.f, 0.1f }); @@ -1586,7 +1586,7 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit auto& uiSystem = *m_scene.getSystem(); - auto selectedID = uiSystem.addCallback([&,helpEnt](cro::Entity e) mutable + auto selectedID = uiSystem.addCallback([&, helpEnt](cro::Entity e) mutable { e.getComponent().setColour(cro::Colour::White); e.getComponent().play(); @@ -1609,33 +1609,33 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit }); auto unselectedID = uiSystem.addCallback([helpEnt](cro::Entity e) mutable { - e.getComponent().setColour(cro::Colour::Transparent); + e.getComponent().setColour(cro::Colour::Transparent); helpEnt.getComponent().setString(" "); }); auto createHighlight = [&](glm::vec2 pos) - { - auto ent = m_scene.createEntity(); - ent.addComponent().setPosition(pos); - ent.addComponent() = m_menuSounds.getEmitter("switch"); - ent.addComponent(); - ent.addComponent() = spriteSheet.getSprite("square_highlight"); - ent.getComponent().setColour(cro::Colour::Transparent); - ent.addComponent().setGroup(MenuID::Video); - auto bounds = ent.getComponent().getTextureBounds(); - ent.getComponent().area = bounds; - ent.getComponent().callbacks[cro::UIInput::Selected] = selectedID; - ent.getComponent().callbacks[cro::UIInput::Unselected] = unselectedID; - - ent.addComponent().function = HighlightAnimationCallback(); - ent.getComponent().setOrigin({ bounds.width / 2.f, bounds.height / 2.f, -HighlightOffset }); - ent.getComponent().move({ bounds.width / 2.f, bounds.height / 2.f }); - - parent.getComponent().addChild(ent.getComponent()); - - return ent; - }; + { + auto ent = m_scene.createEntity(); + ent.addComponent().setPosition(pos); + ent.addComponent() = m_menuSounds.getEmitter("switch"); + ent.addComponent(); + ent.addComponent() = spriteSheet.getSprite("square_highlight"); + ent.getComponent().setColour(cro::Colour::Transparent); + ent.addComponent().setGroup(MenuID::Video); + auto bounds = ent.getComponent().getTextureBounds(); + ent.getComponent().area = bounds; + ent.getComponent().callbacks[cro::UIInput::Selected] = selectedID; + ent.getComponent().callbacks[cro::UIInput::Unselected] = unselectedID; + + ent.addComponent().function = HighlightAnimationCallback(); + ent.getComponent().setOrigin({ bounds.width / 2.f, bounds.height / 2.f, -HighlightOffset }); + ent.getComponent().move({ bounds.width / 2.f, bounds.height / 2.f }); + + parent.getComponent().addChild(ent.getComponent()); + + return ent; + }; //channel select down auto entity = createHighlight(glm::vec2((bgBounds.width / 2.f) - 156.f, 147.f)); @@ -1643,7 +1643,7 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit entity.getComponent().setNextIndex(AVMixerRight, AVAAL); entity.getComponent().setPrevIndex(AVVolumeUp, TabController); entity.getComponent().callbacks[cro::UIInput::ButtonDown] = uiSystem.addCallback( - [&,audioLabel](cro::Entity e, cro::ButtonEvent evt) mutable + [&, audioLabel](cro::Entity e, cro::ButtonEvent evt) mutable { if (activated(evt)) { @@ -1660,7 +1660,7 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit entity.getComponent().setNextIndex(AVVolumeDown, AVAAR); entity.getComponent().setPrevIndex(AVMixerLeft, TabController); entity.getComponent().callbacks[cro::UIInput::ButtonDown] = uiSystem.addCallback( - [&,audioLabel](cro::Entity e, cro::ButtonEvent evt) mutable + [&, audioLabel](cro::Entity e, cro::ButtonEvent evt) mutable { if (activated(evt)) { @@ -1700,7 +1700,7 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit auto currIndex = AAIndexMap[m_sharedData.multisamples]; currIndex = (currIndex + (AASamples.size() - 1)) % AASamples.size(); //m_sharedData.multisamples = AASamples[currIndex]; - + aaLabel.getComponent().setString(AAStrings[currIndex]); centreText(aaLabel); @@ -1723,7 +1723,7 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit { auto currIndex = AAIndexMap[m_sharedData.multisamples]; currIndex = (currIndex + 1) % AASamples.size(); - // m_sharedData.multisamples = AASamples[currIndex]; + // m_sharedData.multisamples = AASamples[currIndex]; aaLabel.getComponent().setString(AAStrings[currIndex]); centreText(aaLabel); @@ -1743,28 +1743,28 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit entity.getComponent().callbacks[cro::UIInput::ButtonDown] = uiSystem.addCallback( [&, fovLabel](cro::Entity e, cro::ButtonEvent evt) mutable - { - if (activated(evt)) { - auto fov = m_sharedData.fov; - fov = std::max(MinFOV, fov - 5.f); - m_audioEnts[AudioID::Accept].getComponent().play(); - - if (fov < m_sharedData.fov) + if (activated(evt)) { - m_sharedData.fov = fov; + auto fov = m_sharedData.fov; + fov = std::max(MinFOV, fov - 5.f); + m_audioEnts[AudioID::Accept].getComponent().play(); + + if (fov < m_sharedData.fov) + { + m_sharedData.fov = fov; - //raise a window resize message to trigger callbacks - auto size = cro::App::getWindow().getSize(); - auto* msg = cro::App::getInstance().getMessageBus().post(cro::Message::WindowMessage); - msg->data0 = size.x; - msg->data1 = size.y; - msg->event = SDL_WINDOWEVENT_SIZE_CHANGED; + //raise a window resize message to trigger callbacks + auto size = cro::App::getWindow().getSize(); + auto* msg = cro::App::getInstance().getMessageBus().post(cro::Message::WindowMessage); + msg->data0 = size.x; + msg->data1 = size.y; + msg->event = SDL_WINDOWEVENT_SIZE_CHANGED; - fovLabel.getComponent().setString("FOV: " + std::to_string(static_cast(m_sharedData.fov))); + fovLabel.getComponent().setString("FOV: " + std::to_string(static_cast(m_sharedData.fov))); + } } - } - }); + }); //FOV up entity = createHighlight(glm::vec2((bgBounds.width / 2.f) - 14.f, 106.f)); @@ -1774,28 +1774,28 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit entity.getComponent().callbacks[cro::UIInput::ButtonDown] = uiSystem.addCallback( [&, fovLabel](cro::Entity e, cro::ButtonEvent evt) mutable - { - if (activated(evt)) { - auto fov = m_sharedData.fov; - fov = std::min(MaxFOV, fov + 5.f); - m_audioEnts[AudioID::Back].getComponent().play(); - - if (fov > m_sharedData.fov) + if (activated(evt)) { - m_sharedData.fov = fov; + auto fov = m_sharedData.fov; + fov = std::min(MaxFOV, fov + 5.f); + m_audioEnts[AudioID::Back].getComponent().play(); - //raise a window resize message to trigger callbacks - auto size = cro::App::getWindow().getSize(); - auto* msg = cro::App::getInstance().getMessageBus().post(cro::Message::WindowMessage); - msg->data0 = size.x; - msg->data1 = size.y; - msg->event = SDL_WINDOWEVENT_SIZE_CHANGED; + if (fov > m_sharedData.fov) + { + m_sharedData.fov = fov; - fovLabel.getComponent().setString("FOV: " + std::to_string(static_cast(m_sharedData.fov))); + //raise a window resize message to trigger callbacks + auto size = cro::App::getWindow().getSize(); + auto* msg = cro::App::getInstance().getMessageBus().post(cro::Message::WindowMessage); + msg->data0 = size.x; + msg->data1 = size.y; + msg->event = SDL_WINDOWEVENT_SIZE_CHANGED; + + fovLabel.getComponent().setString("FOV: " + std::to_string(static_cast(m_sharedData.fov))); + } } - } - }); + }); //res down @@ -1806,15 +1806,15 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit entity.getComponent().callbacks[cro::UIInput::ButtonDown] = uiSystem.addCallback( [&, resLabel](cro::Entity e, cro::ButtonEvent evt) mutable - { - if (activated(evt)) { - m_videoSettings.resolutionIndex = (m_videoSettings.resolutionIndex + (m_sharedData.resolutions.size() - 1)) % m_sharedData.resolutions.size(); - resLabel.getComponent().setString(m_sharedData.resolutionStrings[m_videoSettings.resolutionIndex]); - centreText(resLabel); - m_audioEnts[AudioID::Accept].getComponent().play(); - } - }); + if (activated(evt)) + { + m_videoSettings.resolutionIndex = (m_videoSettings.resolutionIndex + (m_sharedData.resolutions.size() - 1)) % m_sharedData.resolutions.size(); + resLabel.getComponent().setString(m_sharedData.resolutionStrings[m_videoSettings.resolutionIndex]); + centreText(resLabel); + m_audioEnts[AudioID::Accept].getComponent().play(); + } + }); //res up entity = createHighlight(glm::vec2((bgBounds.width / 2.f) - 14.f, 90.f)); @@ -1866,10 +1866,10 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit entity.addComponent().active = true; entity.getComponent().function = [&](cro::Entity e, float) - { - float scale = m_sharedData.pixelScale ? 1.f : 0.f; - e.getComponent().setScale(glm::vec2(scale)); - }; + { + float scale = m_sharedData.pixelScale ? 1.f : 0.f; + e.getComponent().setScale(glm::vec2(scale)); + }; parent.getComponent().addChild(entity.getComponent()); //vertex snap checkbox @@ -1901,10 +1901,10 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit entity.addComponent().active = true; entity.getComponent().function = [&](cro::Entity e, float) - { - float scale = m_sharedData.vertexSnap ? 1.f : 0.f; - e.getComponent().setScale(glm::vec2(scale)); - }; + { + float scale = m_sharedData.vertexSnap ? 1.f : 0.f; + e.getComponent().setScale(glm::vec2(scale)); + }; parent.getComponent().addChild(entity.getComponent()); @@ -1939,15 +1939,19 @@ void OptionsState::buildAVMenu(cro::Entity parent, const cro::SpriteSheet& sprit entity.addComponent().active = true; entity.getComponent().function = [&](cro::Entity e, float) - { - float scale = m_videoSettings.fullScreen ? 1.f : 0.f; - e.getComponent().setScale(glm::vec2(scale)); - }; + { + float scale = m_videoSettings.fullScreen ? 1.f : 0.f; + e.getComponent().setScale(glm::vec2(scale)); + }; parent.getComponent().addChild(entity.getComponent()); //vsync checkbox entity = createHighlight(glm::vec2(81.f, 26.f)); + if (Social::isSteamdeck()) + { + entity.setLabel("Requires Disable Frame Limit set on Steam Deck.\nHigher frame rates may reduce battery life."); + } entity.getComponent().setSelectionIndex(AVVSync); entity.getComponent().setNextIndex(AVShadowL, AVBeacon); entity.getComponent().setPrevIndex(AVShadowR, AVFullScreen); diff --git a/samples/golf/src/golf/Weather.cpp b/samples/golf/src/golf/Weather.cpp index f06153f99..8a2c1a2cb 100644 --- a/samples/golf/src/golf/Weather.cpp +++ b/samples/golf/src/golf/Weather.cpp @@ -220,7 +220,7 @@ void GolfState::createWeather(std::int32_t weatherType) else { m_resources.shaders.loadFromString(ShaderID::Weather, WeatherVertex, RainFragment); - weatherColour = cro::Colour(0.86f, 0.87f, 0.873f, 0.6f); + weatherColour = cro::Colour(0.8f, 0.81f, 0.873f, 0.6f); //blendMode = cro::Material::BlendMode::Custom; //create audio entity diff --git a/samples/golf/src/golf/WeatherAnimationSystem.cpp b/samples/golf/src/golf/WeatherAnimationSystem.cpp index 69e546ff0..67b82b69e 100644 --- a/samples/golf/src/golf/WeatherAnimationSystem.cpp +++ b/samples/golf/src/golf/WeatherAnimationSystem.cpp @@ -118,5 +118,5 @@ void WeatherAnimationSystem::setMaterialData(const cro::Shader& shader, cro::Col void WeatherAnimationSystem::updateShader() { glUseProgram(m_shaderID); - glUniform4f(m_uniformID, m_colour.getRed(), m_colour.getGreen(), m_colour.getBlue(), m_opacity); + glUniform4f(m_uniformID, m_colour.getRed(), m_colour.getGreen(), m_colour.getBlue(), m_colour.getAlpha() * m_opacity); } \ No newline at end of file diff --git a/samples/golf/src/golf/shaders/TerrainShader.inl b/samples/golf/src/golf/shaders/TerrainShader.inl index b47edc264..d90a81b63 100644 --- a/samples/golf/src/golf/shaders/TerrainShader.inl +++ b/samples/golf/src/golf/shaders/TerrainShader.inl @@ -165,7 +165,7 @@ R"( VARYING_IN vec2 v_heightData; const vec3 DotColour = vec3(1.0, 0.85, 0.6); - const vec3 BaseColour = vec3(0.627, 0.699, 0.94); //stored as HSV to save on a conversion + const vec3 BaseColour = vec3(0.627, 0.699, 0.58); //0.94 stored as HSV to save on a conversion #include HSV