Skip to content

Commit

Permalink
CLIENT-MENU: Now users can choose parallax
Browse files Browse the repository at this point in the history
MINOR
  • Loading branch information
KitetsuK committed Nov 5, 2023
2 parents 0bd3618 + fd94088 commit bccdb28
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 7 deletions.
Binary file added assets/Audio/Musics/home.mp3
Binary file not shown.
4 changes: 4 additions & 0 deletions assets/Json/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -338,5 +338,9 @@
"imgPath": "assets/Menu/loading.gif",
"width": 100,
"height": 100
},
"mainTheme": {
"path": "assets/Audio/Musics/home.mp3",
"volume": 0.65
}
}
10 changes: 8 additions & 2 deletions src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,14 @@ namespace Menu {
}
for (auto id : ids) {
if (arrText[id]->getCurrentText().find("PARALLAX") != std::string::npos) {
Logger::info("parallax name" + std::to_string(Systems::Parallax::ActualParallax::getInstance()._actualParallaxNbr));
std::string paraName = "PARALLAX_" + std::to_string(Systems::Parallax::ActualParallax::getInstance()._actualParallaxNbr);
Logger::info(
"parallax name"
+ std::to_string(
Systems::Parallax::ActualParallax::getInstance()._actualParallaxNbr));
std::string paraName =
"PARALLAX_"
+ std::to_string(
Systems::Parallax::ActualParallax::getInstance()._actualParallaxNbr);

arrText[id]->setCurrentText(paraName);
}
Expand Down
30 changes: 27 additions & 3 deletions src/Client/Systems/Menus/Menu/MenuSystems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,31 @@ namespace Systems {
}
}

static void initMainTheme()
{
Json &json = Json::getInstance();

nlohmann::json jsonData = json.getDataByJsonType<nlohmann::json>(
ResourcesManager::getPathByJsonType(JsonType::MENU),
"mainTheme");
if (json.isDataExist(jsonData, "path") && json.isDataExist(jsonData, "volume")) {
std::string musicPath = json.getDataFromJson<std::string>(jsonData, "path");
float volume = json.getDataFromJson<float>(jsonData, "volume");
Raylib::MusicShared music = Raylib::Music::fromFile(musicPath, volume);
music->setNeedToPlay(true);
Registry::getInstance().addEntity();
Registry::getInstance().getComponents<Raylib::MusicShared>().insertBack(music);
}
}

void initMenu(std::size_t managerId, std::size_t systemId)
{
if (Scene::SceneManager::getInstance().getCurrentScene() != MENU) {
SystemManagersDirector::getInstance().getSystemManager(managerId).removeSystem(systemId);
return;
}
try {
initMainTheme();
Parallax::initParalax();
Logger::info("Init Parallax");
nlohmann::json jsonData = Json::getInstance().getDataByJsonType<nlohmann::json>(
Expand Down Expand Up @@ -299,13 +317,19 @@ namespace Systems {

void resetParallaxTextForParallax(std::size_t /*unused*/, std::size_t /*unused*/)
{
auto ids = Registry::getInstance().getEntitiesByComponents({typeid(Raylib::TextShared)});
auto ids = Registry::getInstance().getEntitiesByComponents({typeid(Raylib::TextShared)});
auto arrText = Registry::getInstance().getComponents<Raylib::TextShared>();

for (auto id : ids) {
if (arrText[id]->getCurrentText().find("PARALLAX") != std::string::npos) {
Logger::info("parallax name" + std::to_string(Systems::Parallax::ActualParallax::getInstance()._actualParallaxNbr));
std::string paraName = "PARALLAX_" + std::to_string(Systems::Parallax::ActualParallax::getInstance()._actualParallaxNbr);
Logger::info(
"parallax name"
+ std::to_string(
Systems::Parallax::ActualParallax::getInstance()._actualParallaxNbr));
std::string paraName =
"PARALLAX_"
+ std::to_string(
Systems::Parallax::ActualParallax::getInstance()._actualParallaxNbr);

arrText[id]->setCurrentText(paraName);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Systems/Parallax/Parallax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace Systems::Parallax {
ResourcesManager::getPathByJsonType(
Parallax::ActualParallax::getInstance().getActualParallaxType()),
"parallax");

for (auto &elem : parallaxData) {
initParallaxEntity(elem);
if (Json::getInstance().isDataExist(elem, "copy")
Expand Down
1 change: 0 additions & 1 deletion src/Nitwork/NitworkMainServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ namespace Nitwork {
<< _T(maxNbPlayer) << _T(" ") << _T(gameType) << _T(" ") << _T(winName.c_str()) << _T(" ")
<< _T(ownerIp.c_str()) << _T(" ") << _T(ownerPort);

Logger::fatal("cmdline: " + cmdline.str());
STARTUPINFO si = {sizeof(si)};
PROCESS_INFORMATION pi;
#ifdef UNICODE
Expand Down

0 comments on commit bccdb28

Please sign in to comment.