Skip to content

Commit

Permalink
mouse sensivity + manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Surer committed Sep 14, 2022
1 parent 7008083 commit 654d95d
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 15 deletions.
4 changes: 2 additions & 2 deletions OpenGL/src/controller/MouseController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include <glm/glm.hpp>

#include "entity/character/Character.hpp"
#include "save/ClientConfig.hpp"

MouseController::MouseController() {
lastX = lastY = deltaX = deltaY = 0;
sensivity = 0.005f;
rotation = false;
}

Expand Down Expand Up @@ -48,7 +48,7 @@ void MouseController::triggerAction(MouseController::Action action) {
void MouseController::apply(Character& character) {

if (rotation) {
character.turn(glm::vec2(deltaY, -deltaX) * sensivity);
character.turn(glm::vec2(deltaY, -deltaX) * Config::getClientConfig().sensivity * 0.0001f);
}

lastX += deltaX;
Expand Down
3 changes: 1 addition & 2 deletions OpenGL/src/controller/MouseController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class MouseController {
int deltaY;
bool rotation;

float sensivity; // rotation radians per mouse pixel on screen


std::vector<Action> actions;
};
5 changes: 5 additions & 0 deletions OpenGL/src/interface/parametersMenu/GraphicsMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ GraphicsMenu::GraphicsMenu()
fullscreen = Checkbox::create();
shadows = ComboBox::create({ "None", "Low", "High" }, clientConf.shadows);
fov = RangeSlider::create(10, 170);
sensivity = RangeSlider::create(1, 100);
renderDistH = RangeSlider::create(1, 40);
renderDistV = RangeSlider::create(1, 20);
vsync = Checkbox::create();

sensivity->setValue((int)(clientConf.sensivity));
fov->setValue((int)clientConf.fov);
renderDistH->setValue(serverConf.renderDistH);
renderDistV->setValue(serverConf.renderDistV);
Expand All @@ -40,6 +42,7 @@ GraphicsMenu::GraphicsMenu()

addLine("Plein écran", fullscreen);
addLine("FOV", fov);
addLine("Sensibilité souris", sensivity);
addLine("Ombres", shadows);
addLine("Distance horizontale", renderDistH);
addLine("Distance verticale", renderDistV);
Expand All @@ -50,6 +53,7 @@ GraphicsMenu::GraphicsMenu()
// vsync->onRelease([&]{ clientConf.vsync = this->vsync->getChecked(); });
shadows->onRelease([&]{ clientConf.shadows = (int)this->shadows->getSelected(); });
fov->onRelease([&]{ clientConf.fov = (float)this->fov->getValue(); });
sensivity->onRelease([&]{ clientConf.sensivity = (float)this->sensivity->getValue(); });
renderDistH->onRelease([&]{ serverConf.renderDistH = this->renderDistH->getValue(); });
renderDistV->onRelease([&]{ serverConf.renderDistV = this->renderDistV->getValue(); });

Expand All @@ -60,6 +64,7 @@ GraphicsMenu::~GraphicsMenu() {
auto& serverConf = Config::getServerConfig();

clientConf.fov = (float)fov->getValue();
clientConf.sensivity = (float)sensivity->getValue();
serverConf.renderDistH = renderDistH->getValue();
serverConf.renderDistV = renderDistV->getValue();
clientConf.fullscreen = fullscreen->getChecked();
Expand Down
1 change: 1 addition & 0 deletions OpenGL/src/interface/parametersMenu/GraphicsMenu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class GraphicsMenu : public ParamList {


std::shared_ptr<RangeSlider> fov;
std::shared_ptr<RangeSlider> sensivity;

std::shared_ptr<ComboBox> shadows;
std::shared_ptr<RangeSlider> renderDistH, renderDistV;
Expand Down
10 changes: 2 additions & 8 deletions OpenGL/src/multiplayer/client/RealServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
#include "terrain/ChunkMap.hpp"
#include "terrain/World.hpp"

#if FMT_VERSION >= 90000 // fmt version >= 9 requires explicit formatter definitions.
template<typename T, length_t N>
struct fmt::formatter<rtc::Configuration> : ostream_formatter{};
template<typename T>
struct fmt::formatter<rtc::Candidate> : ostream_formatter{};
#endif

using namespace glm;
using namespace serde;
Expand Down Expand Up @@ -78,11 +72,11 @@ RealServer::RealServer(std::string host, unsigned short port, bool tls)

peer = std::make_unique<rtc::PeerConnection>(config);
peer->onLocalDescription([this](rtc::Description description) {
spdlog::debug("RTC Local description: ", description);
spdlog::debug("RTC Local description: {}", description);
socket.send(description);
});
peer->onLocalCandidate([this](rtc::Candidate candidate) {
spdlog::debug("RTC Local candidate: ", candidate);
spdlog::debug("RTC Local candidate: {}", candidate);
socket.send(candidate);
});

Expand Down
2 changes: 2 additions & 0 deletions OpenGL/src/save/ClientConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Config::ClientConfig::ClientConfig() {
PARAM(fullscreen)
PARAM(vsync)
PARAM(shadows)
PARAM(sensivity)

}

Expand Down Expand Up @@ -98,6 +99,7 @@ Config::ClientConfig::~ClientConfig() {
PARAM(fullscreen)
PARAM(vsync)
PARAM(shadows)
PARAM(sensivity)

#undef KEY_PARAM
#undef PARAM
Expand Down
7 changes: 4 additions & 3 deletions OpenGL/src/save/ClientConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ namespace Config {
unsigned int msaa = 4;
#endif

float fov = 70.0;
float mainVolume = 50.0;
float musicVolume = 50.0;
float fov = 70.0f;
float mainVolume = 50.0f;
float musicVolume = 50.0f;
float sensivity = 50.0f; // rotation radians per mouse pixel on screen
bool fullscreen = false;
bool vsync = true;
int shadows = 2;
Expand Down
20 changes: 20 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "versions-test",
"version": "1.0.0",
"dependencies": [
"spdlog",
"zlib",
"libdatachannel",
"freetype",
"sdl2-image",
"sdl2",
"sfml"
],
"overrides": [
{
"name": "fmt",
"version": "8.1.1"
}
],
"builtin-baseline": "34f072dfcb8b9356e6ed2c74947f87390ddb2706"
}

0 comments on commit 654d95d

Please sign in to comment.