Compare commits

..

No commits in common. "2ee6d61231d7fe4f8f8bc75737a21977fcb9ad7a" and "4b2446a5f46e541e0c5c061b38c96cfe92425865" have entirely different histories.

6 changed files with 16 additions and 67 deletions

View File

@ -12,7 +12,12 @@ App::App() :
{
std::cout << "Initializing App..." << std::endl;
ApplySettings();
#ifndef EMSCRIPTEN
audiomaster_.SetMasterVolume(1.0f);
#else
audiomaster_.SetMasterVolume(2.0f);
#endif
AddChatMessage("Test!");
}
@ -136,11 +141,7 @@ void App::Input(game::PlayerInputType in, bool pressed, bool repeated)
{
if (in == game::IN_MENU && pressed)
{
if (!menu_)
OpenSettings();
else
menu_.reset();
return;
}
@ -158,8 +159,10 @@ void App::Input(game::PlayerInputType in, bool pressed, bool repeated)
void App::MouseMove(const glm::vec2& delta)
{
float delta_yaw = -delta.x * sensitivity_;
float delta_pitch = -delta.y * sensitivity_;
float sensitivity = 0.002f; // Sensitivity factor for mouse movement
float delta_yaw = -delta.x * sensitivity;
float delta_pitch = -delta.y * sensitivity;
if (session_)
session_->ProcessMouseMove(delta_yaw, delta_pitch);
@ -207,10 +210,10 @@ void App::DrawChat()
}
}
static void AddSlider(gui::Menu& menu, std::string text, int& value, int min, int max, std::function<void()> changed)
static void AddSlider(gui::Menu& menu, std::string text, int& value, int min, int max)
{
auto& slider = menu.Add<gui::SelectMenuItem>(std::move(text));
auto on_switch = [&slider, &value, min, max, changed] (int v) {
auto on_switch = [&slider, &value, min, max] (int v) {
value += v;
// clamp
@ -220,7 +223,6 @@ static void AddSlider(gui::Menu& menu, std::string text, int& value, int min, in
value = max;
slider.SetSelectionText(std::to_string(value));
changed();
};
slider.SetSwitchCallback(on_switch);
@ -231,41 +233,12 @@ void App::OpenSettings()
{
menu_ = std::make_unique<gui::Menu>();
AddSlider(*menu_, "jak moc to řve", volume_, 0, 100, [this]{
ApplyVolume();
});
AddSlider(*menu_, "agresivita krysy", sens_, 0, 100, [this]{
ApplySensitivity();
});
AddSlider(*menu_, "jak moc to řve", volume_, 0, 100);
auto& ok = menu_->Add<gui::ButtonMenuItem>("0k");
ok.SetClickCallback([this] { menu_.reset(); });
}
void App::ApplySettings()
{
ApplyVolume();
ApplySensitivity();
}
void App::ApplyVolume()
{
float vol_f = static_cast<float>(volume_) / 50.0f;
#ifndef EMSCRIPTEN
audiomaster_.SetMasterVolume(vol_f);
#else
audiomaster_.SetMasterVolume(2.0f * vol_f);
#endif
}
void App::ApplySensitivity()
{
float f = static_cast<float>(sens_) / 100.0f;
sensitivity_ = glm::mix(0.0005f, 0.0035f, f);
}
#define COL_LABEL "^ccc"
#define COL_VALUE "^5ff"

View File

@ -57,9 +57,6 @@ private:
void DrawChat();
void OpenSettings();
void ApplySettings();
void ApplyVolume();
void ApplySensitivity();
void UpdateStats();
void DrawStats();
@ -86,8 +83,6 @@ private:
// settings
int volume_ = 50;
int sens_ = 50;
float sensitivity_ = 0.0f;
// stats
float stats_time_ = 0.0f;

View File

@ -1,7 +1,5 @@
#include "game.hpp"
#include <format>
#include "player.hpp"
#include "openworld.hpp"
@ -24,26 +22,13 @@ void game::Game::FinishFrame()
void game::Game::PlayerJoined(Player& player)
{
player.SetWorld(default_world_);
players_.insert(&player);
BroadcastChat(std::format("{}^r se připoojil jupí jupí jupííí", player.GetName()));
}
void game::Game::PlayerLeft(Player& player)
{
players_.erase(&player);
BroadcastChat(std::format("{}^r se vodpojil zmrd", player.GetName()));
}
bool game::Game::PlayerInput(Player& player, PlayerInputType type, bool enabled)
{
return false; // not handled here
}
void game::Game::BroadcastChat(const std::string& text)
{
for (auto player : players_)
{
player->SendChat(text);
}
}

View File

@ -1,7 +1,6 @@
#pragma once
#include <map>
#include <set>
#include "world.hpp"
@ -22,12 +21,9 @@ public:
void PlayerLeft(Player& player);
bool PlayerInput(Player& player, PlayerInputType type, bool enabled);
private:
void BroadcastChat(const std::string& text);
private:
std::shared_ptr<World> default_world_;
std::set<Player*> players_;
};

View File

@ -119,7 +119,7 @@ void game::OpenWorld::DestructibleDestroyed(net::ObjNum num, std::unique_ptr<Map
{
auto& destroyed_obj = Spawn<DestroyedObject>(std::move(col));
Schedule(120000, [this, num] {
Schedule(10000, [this, num] {
RespawnObj(num);
});
}

View File

@ -85,7 +85,7 @@ bool sv::Client::ProcessLoginMsg(net::InMessage& msg)
// check ver
if (ver != FEKAL_VERSION)
{
SendChat(std::format("^f55máš nahovno verzi {}, server je na {}", ver, FEKAL_VERSION));
SendChat(std::format("^f55špatná verze {}, server je na verzi {}", ver, FEKAL_VERSION));
return false;
}