Skip to content

Commit

Permalink
Merge pull request #111 from fallahn/golf-1.16
Browse files Browse the repository at this point in the history
Golf 1.16.3
  • Loading branch information
fallahn authored Apr 27, 2024
2 parents aeb53ef + 6fd65c3 commit 9ce5a4a
Show file tree
Hide file tree
Showing 27 changed files with 503 additions and 279 deletions.
7 changes: 4 additions & 3 deletions crogine/src/ecs/systems/RenderSystem2D.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*-----------------------------------------------------------------------
Matt Marchant 2017 - 2023
Matt Marchant 2017 - 2024
http://trederia.blogspot.com
crogine - Zlib license.
Expand Down Expand Up @@ -178,18 +178,19 @@ void RenderSystem2D::process(float)

const auto& tx = entity.getComponent<Transform>();
auto pos = tx.getWorldPosition();
auto origin = tx.getOrigin();

//set sort criteria based on position
//faster to do a sort on int than float
if (m_sortOrder == DepthAxis::Y)
{
//multiplying by 100 preserves two places of precision
//which is enough to sort on
drawable.m_sortCriteria = static_cast<std::int32_t>(-pos.y * 100.f);
drawable.m_sortCriteria = static_cast<std::int32_t>(-(pos.y - origin.y) * 100.f);
}
else
{
drawable.m_sortCriteria = static_cast<std::int32_t>(pos.z * 100.f);
drawable.m_sortCriteria = static_cast<std::int32_t>((pos.z - origin.z) * 100.f);
}

//check if the cropping area is smaller than
Expand Down
7 changes: 4 additions & 3 deletions libsocial/include/Social.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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; }
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 5414
#define BUILDNUMBER_STR "5414"
#define BUILDNUMBER 5455
#define BUILDNUMBER_STR "5455"

#endif /* BUILD_NUMBER_H_ */
Binary file modified samples/golf/golf.aps
Binary file not shown.
8 changes: 4 additions & 4 deletions samples/golf/golf.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
17 changes: 16 additions & 1 deletion samples/golf/src/golf/GameConsts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<cro::AudioEmitter>().getState();

if (e.getComponent<cro::AudioEmitter>().getState() == cro::AudioEmitter::State::Stopped)
if (state == cro::AudioEmitter::State::Playing
&& currVol < MinMusicVolume)
{
e.getComponent<cro::AudioEmitter>().pause();
}
else if (state == cro::AudioEmitter::State::Paused
&& currVol > MinMusicVolume)
{
e.getComponent<cro::AudioEmitter>().play();
}
else if (state == cro::AudioEmitter::State::Stopped)
{
e.getComponent<cro::Callback>().active = false;
scene.destroyEntity(e);
Expand Down
17 changes: 15 additions & 2 deletions samples/golf/src/golf/GolfState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,7 @@ void GolfState::handleMessage(const cro::Message& msg)
e.getComponent<cro::Model>().setHidden(true);
};
m_gameScene.getSystem<cro::CommandSystem>()->sendCommand(cmd);
setUIHidden(true);
}
else if (data.data == CameraID::Player
&& m_currentCamera == CameraID::Drone)
Expand All @@ -1168,6 +1169,7 @@ void GolfState::handleMessage(const cro::Message& msg)
e.getComponent<cro::Model>().setHidden(!(localPlayer && !m_sharedData.localConnectionData.playerData[m_currentPlayer.player].isCPU));
};
m_gameScene.getSystem<cro::CommandSystem>()->sendCommand(cmd);
setUIHidden(false);
}

setActiveCamera(data.data);
Expand Down Expand Up @@ -3610,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)
{
Expand Down Expand Up @@ -5204,6 +5209,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<MiniBallSystem>()->setActivePlayer(player.client, player.player);
m_gameScene.getDirector<GolfSoundDirector>()->setActivePlayer(player.client, player.player, isCPU && m_sharedData.fastCPU);
m_avatars[player.client][player.player].ballModel.getComponent<cro::Transform>().setScale(glm::vec3(1.f));

Expand Down Expand Up @@ -6248,7 +6254,9 @@ 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
&& cro::AudioMixer::getVolume(MixerChannel::Music) != 0)
{
m_cameras[CameraID::Player].getComponent<cro::AudioEmitter>().play();
}
Expand All @@ -6271,7 +6279,12 @@ void GolfState::startFlyBy()
{
showScoreboard(true);
m_newHole = true;
m_cameras[CameraID::Player].getComponent<cro::AudioEmitter>().play();

if (cro::AudioMixer::getVolume(MixerChannel::UserMusic) < 0.01f
&& cro::AudioMixer::getVolume(MixerChannel::Music) != 0)
{
m_cameras[CameraID::Player].getComponent<cro::AudioEmitter>().play();
}

//delayed ent just to show the score board for a while
auto de = m_gameScene.createEntity();
Expand Down
4 changes: 3 additions & 1 deletion samples/golf/src/golf/GolfState.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*-----------------------------------------------------------------------
Matt Marchant 2021 - 2023
Matt Marchant 2021 - 2024
http://trederia.blogspot.com
Super Video Golf - zlib licence.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -594,6 +595,7 @@ class GolfState final : public cro::State, public cro::GuiClient, public cro::Co
std::vector<StatBoardEntry> m_statBoardScores;

void updateLeague();
void setUIHidden(bool hidden);

struct GamepadNotify final
{
Expand Down
9 changes: 2 additions & 7 deletions samples/golf/src/golf/GolfStateCameras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<cro::Transform>().getOrigin();
origin.z = -3.f;
m_courseEnt.getComponent<cro::Transform>().setOrigin(origin);
setUIHidden(true);
}
else
{
Expand All @@ -769,9 +766,7 @@ void GolfState::toggleFreeCam()
m_resolutionUpdate.targetFade = m_currentPlayer.terrain == TerrainID::Green ? GreenFadeDistance : CourseFadeDistance;

//unhide UI
auto origin = m_courseEnt.getComponent<cro::Transform>().getOrigin();
origin.z = 0.5f;
m_courseEnt.getComponent<cro::Transform>().setOrigin(origin);
setUIHidden(false);


//and stroke indicator
Expand Down
16 changes: 16 additions & 0 deletions samples/golf/src/golf/GolfStateDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 11 additions & 5 deletions samples/golf/src/golf/GolfStateScoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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);
//}
}
Loading

0 comments on commit 9ce5a4a

Please sign in to comment.