Compare commits
No commits in common. "2ee6d61231d7fe4f8f8bc75737a21977fcb9ad7a" and "4b2446a5f46e541e0c5c061b38c96cfe92425865" have entirely different histories.
2ee6d61231
...
4b2446a5f4
@ -12,7 +12,12 @@ App::App() :
|
|||||||
{
|
{
|
||||||
std::cout << "Initializing App..." << std::endl;
|
std::cout << "Initializing App..." << std::endl;
|
||||||
|
|
||||||
ApplySettings();
|
#ifndef EMSCRIPTEN
|
||||||
|
audiomaster_.SetMasterVolume(1.0f);
|
||||||
|
#else
|
||||||
|
audiomaster_.SetMasterVolume(2.0f);
|
||||||
|
#endif
|
||||||
|
|
||||||
AddChatMessage("Test!");
|
AddChatMessage("Test!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,11 +141,7 @@ void App::Input(game::PlayerInputType in, bool pressed, bool repeated)
|
|||||||
{
|
{
|
||||||
if (in == game::IN_MENU && pressed)
|
if (in == game::IN_MENU && pressed)
|
||||||
{
|
{
|
||||||
if (!menu_)
|
OpenSettings();
|
||||||
OpenSettings();
|
|
||||||
else
|
|
||||||
menu_.reset();
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,8 +159,10 @@ void App::Input(game::PlayerInputType in, bool pressed, bool repeated)
|
|||||||
|
|
||||||
void App::MouseMove(const glm::vec2& delta)
|
void App::MouseMove(const glm::vec2& delta)
|
||||||
{
|
{
|
||||||
float delta_yaw = -delta.x * sensitivity_;
|
float sensitivity = 0.002f; // Sensitivity factor for mouse movement
|
||||||
float delta_pitch = -delta.y * sensitivity_;
|
|
||||||
|
float delta_yaw = -delta.x * sensitivity;
|
||||||
|
float delta_pitch = -delta.y * sensitivity;
|
||||||
|
|
||||||
if (session_)
|
if (session_)
|
||||||
session_->ProcessMouseMove(delta_yaw, delta_pitch);
|
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& 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;
|
value += v;
|
||||||
|
|
||||||
// clamp
|
// clamp
|
||||||
@ -220,7 +223,6 @@ static void AddSlider(gui::Menu& menu, std::string text, int& value, int min, in
|
|||||||
value = max;
|
value = max;
|
||||||
|
|
||||||
slider.SetSelectionText(std::to_string(value));
|
slider.SetSelectionText(std::to_string(value));
|
||||||
changed();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
slider.SetSwitchCallback(on_switch);
|
slider.SetSwitchCallback(on_switch);
|
||||||
@ -231,41 +233,12 @@ void App::OpenSettings()
|
|||||||
{
|
{
|
||||||
menu_ = std::make_unique<gui::Menu>();
|
menu_ = std::make_unique<gui::Menu>();
|
||||||
|
|
||||||
AddSlider(*menu_, "jak moc to řve", volume_, 0, 100, [this]{
|
AddSlider(*menu_, "jak moc to řve", volume_, 0, 100);
|
||||||
ApplyVolume();
|
|
||||||
});
|
|
||||||
|
|
||||||
AddSlider(*menu_, "agresivita krysy", sens_, 0, 100, [this]{
|
|
||||||
ApplySensitivity();
|
|
||||||
});
|
|
||||||
|
|
||||||
auto& ok = menu_->Add<gui::ButtonMenuItem>("0k");
|
auto& ok = menu_->Add<gui::ButtonMenuItem>("0k");
|
||||||
ok.SetClickCallback([this] { menu_.reset(); });
|
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_LABEL "^ccc"
|
||||||
#define COL_VALUE "^5ff"
|
#define COL_VALUE "^5ff"
|
||||||
|
|
||||||
|
|||||||
@ -57,9 +57,6 @@ private:
|
|||||||
void DrawChat();
|
void DrawChat();
|
||||||
|
|
||||||
void OpenSettings();
|
void OpenSettings();
|
||||||
void ApplySettings();
|
|
||||||
void ApplyVolume();
|
|
||||||
void ApplySensitivity();
|
|
||||||
|
|
||||||
void UpdateStats();
|
void UpdateStats();
|
||||||
void DrawStats();
|
void DrawStats();
|
||||||
@ -86,8 +83,6 @@ private:
|
|||||||
|
|
||||||
// settings
|
// settings
|
||||||
int volume_ = 50;
|
int volume_ = 50;
|
||||||
int sens_ = 50;
|
|
||||||
float sensitivity_ = 0.0f;
|
|
||||||
|
|
||||||
// stats
|
// stats
|
||||||
float stats_time_ = 0.0f;
|
float stats_time_ = 0.0f;
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
#include "game.hpp"
|
#include "game.hpp"
|
||||||
|
|
||||||
#include <format>
|
|
||||||
|
|
||||||
#include "player.hpp"
|
#include "player.hpp"
|
||||||
#include "openworld.hpp"
|
#include "openworld.hpp"
|
||||||
|
|
||||||
@ -24,26 +22,13 @@ void game::Game::FinishFrame()
|
|||||||
void game::Game::PlayerJoined(Player& player)
|
void game::Game::PlayerJoined(Player& player)
|
||||||
{
|
{
|
||||||
player.SetWorld(default_world_);
|
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)
|
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)
|
bool game::Game::PlayerInput(Player& player, PlayerInputType type, bool enabled)
|
||||||
{
|
{
|
||||||
return false; // not handled here
|
return false; // not handled here
|
||||||
}
|
}
|
||||||
|
|
||||||
void game::Game::BroadcastChat(const std::string& text)
|
|
||||||
{
|
|
||||||
for (auto player : players_)
|
|
||||||
{
|
|
||||||
player->SendChat(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
|
||||||
|
|
||||||
#include "world.hpp"
|
#include "world.hpp"
|
||||||
|
|
||||||
@ -22,12 +21,9 @@ public:
|
|||||||
void PlayerLeft(Player& player);
|
void PlayerLeft(Player& player);
|
||||||
bool PlayerInput(Player& player, PlayerInputType type, bool enabled);
|
bool PlayerInput(Player& player, PlayerInputType type, bool enabled);
|
||||||
|
|
||||||
private:
|
|
||||||
void BroadcastChat(const std::string& text);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<World> default_world_;
|
std::shared_ptr<World> default_world_;
|
||||||
std::set<Player*> players_;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -119,7 +119,7 @@ void game::OpenWorld::DestructibleDestroyed(net::ObjNum num, std::unique_ptr<Map
|
|||||||
{
|
{
|
||||||
auto& destroyed_obj = Spawn<DestroyedObject>(std::move(col));
|
auto& destroyed_obj = Spawn<DestroyedObject>(std::move(col));
|
||||||
|
|
||||||
Schedule(120000, [this, num] {
|
Schedule(10000, [this, num] {
|
||||||
RespawnObj(num);
|
RespawnObj(num);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,7 +85,7 @@ bool sv::Client::ProcessLoginMsg(net::InMessage& msg)
|
|||||||
// check ver
|
// check ver
|
||||||
if (ver != FEKAL_VERSION)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user