Merge branch 'main' into update-file-subsystem
This commit is contained in:
commit
dceb5f6ee4
@ -278,7 +278,7 @@ void ALSpeaker::play() {
|
|||||||
AL_CHECK(alSourcef(
|
AL_CHECK(alSourcef(
|
||||||
source,
|
source,
|
||||||
AL_GAIN,
|
AL_GAIN,
|
||||||
volume * p_channel->getVolume() * get_channel(0)->getVolume()
|
volume * p_channel->getVolume()
|
||||||
));
|
));
|
||||||
AL_CHECK(alSourcePlay(source));
|
AL_CHECK(alSourcePlay(source));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ InputBindBox::InputBindBox(Binding& binding, glm::vec4 padding)
|
|||||||
label(std::make_shared<Label>(L"")) {
|
label(std::make_shared<Label>(L"")) {
|
||||||
add(label);
|
add(label);
|
||||||
setScrollable(false);
|
setScrollable(false);
|
||||||
|
hoverColor = glm::vec4(0.05f, 0.1f, 0.2f, 0.75f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputBindBox::drawBackground(const DrawContext& pctx, const Assets&) {
|
void InputBindBox::drawBackground(const DrawContext& pctx, const Assets&) {
|
||||||
@ -25,8 +26,10 @@ void InputBindBox::drawBackground(const DrawContext& pctx, const Assets&) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InputBindBox::clicked(GUI*, mousecode button) {
|
void InputBindBox::clicked(GUI*, mousecode button) {
|
||||||
binding.reset(button);
|
if (isFocused()) {
|
||||||
defocus();
|
binding.reset(button);
|
||||||
|
defocus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputBindBox::keyPressed(keycode key) {
|
void InputBindBox::keyPressed(keycode key) {
|
||||||
|
|||||||
@ -7,8 +7,7 @@ namespace gui {
|
|||||||
|
|
||||||
class InputBindBox : public Panel {
|
class InputBindBox : public Panel {
|
||||||
protected:
|
protected:
|
||||||
glm::vec4 hoverColor {0.05f, 0.1f, 0.2f, 0.75f};
|
glm::vec4 focusedColor {0.1f, 0.15f, 0.35f, 0.75f};
|
||||||
glm::vec4 focusedColor {0.0f, 0.0f, 0.0f, 1.0f};
|
|
||||||
std::shared_ptr<Label> label;
|
std::shared_ptr<Label> label;
|
||||||
Binding& binding;
|
Binding& binding;
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -93,22 +93,24 @@ glm::vec3 CameraControl::updateCameraShaking(
|
|||||||
const float ov = CAM_SHAKE_OFFSET_Y;
|
const float ov = CAM_SHAKE_OFFSET_Y;
|
||||||
const glm::vec3& vel = hitbox.velocity;
|
const glm::vec3& vel = hitbox.velocity;
|
||||||
|
|
||||||
interpVel = interpVel * (1.0f - delta * 5) + vel * delta * 0.1f;
|
if (settings.shaking.get()) {
|
||||||
if (hitbox.grounded && interpVel.y < 0.0f) {
|
shake = shake * (1.0f - delta * k);
|
||||||
interpVel.y *= -30.0f;
|
float oh = CAM_SHAKE_OFFSET;
|
||||||
}
|
if (hitbox.grounded) {
|
||||||
shake = shake * (1.0f - delta * k);
|
float f = glm::length(glm::vec2(vel.x, vel.z));
|
||||||
float oh = CAM_SHAKE_OFFSET;
|
shakeTimer += delta * f * CAM_SHAKE_SPEED;
|
||||||
if (hitbox.grounded) {
|
shake += f * delta * k;
|
||||||
float f = glm::length(glm::vec2(vel.x, vel.z));
|
oh *= glm::sqrt(f);
|
||||||
shakeTimer += delta * f * CAM_SHAKE_SPEED;
|
}
|
||||||
shake += f * delta * k;
|
|
||||||
oh *= glm::sqrt(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
offset += camera->right * glm::sin(shakeTimer) * oh * shake;
|
offset += camera->right * glm::sin(shakeTimer) * oh * shake;
|
||||||
offset += camera->up * glm::abs(glm::cos(shakeTimer)) * ov * shake;
|
offset += camera->up * glm::abs(glm::cos(shakeTimer)) * ov * shake;
|
||||||
|
}
|
||||||
if (settings.inertia.get()) {
|
if (settings.inertia.get()) {
|
||||||
|
interpVel = interpVel * (1.0f - delta * 5) + vel * delta * 0.1f;
|
||||||
|
if (hitbox.grounded && interpVel.y < 0.0f) {
|
||||||
|
interpVel.y *= -30.0f;
|
||||||
|
}
|
||||||
offset -= glm::min(interpVel * 0.05f, 1.0f);
|
offset -= glm::min(interpVel * 0.05f, 1.0f);
|
||||||
}
|
}
|
||||||
return offset;
|
return offset;
|
||||||
@ -124,7 +126,7 @@ void CameraControl::updateFovEffects(
|
|||||||
if (crouch) {
|
if (crouch) {
|
||||||
offset += glm::vec3(0.f, CROUCH_SHIFT_Y, 0.f);
|
offset += glm::vec3(0.f, CROUCH_SHIFT_Y, 0.f);
|
||||||
zoomValue = CROUCH_ZOOM;
|
zoomValue = CROUCH_ZOOM;
|
||||||
} else if (input.sprint) {
|
} else if (input.sprint && (input.moveForward || input.moveBack || input.moveLeft || input.moveRight)) {
|
||||||
zoomValue = RUN_ZOOM;
|
zoomValue = RUN_ZOOM;
|
||||||
}
|
}
|
||||||
if (input.zoom) zoomValue *= C_ZOOM;
|
if (input.zoom) zoomValue *= C_ZOOM;
|
||||||
@ -161,7 +163,7 @@ void CameraControl::update(
|
|||||||
|
|
||||||
if (auto hitbox = player.getHitbox()) {
|
if (auto hitbox = player.getHitbox()) {
|
||||||
offset.y += hitbox->halfsize.y * (0.7f / 0.9f);
|
offset.y += hitbox->halfsize.y * (0.7f / 0.9f);
|
||||||
if (settings.shaking.get() && !input.cheat) {
|
if (!input.cheat) {
|
||||||
offset += updateCameraShaking(*hitbox, delta);
|
offset += updateCameraShaking(*hitbox, delta);
|
||||||
}
|
}
|
||||||
if (settings.fovEffects.get()) {
|
if (settings.fovEffects.get()) {
|
||||||
|
|||||||
@ -40,21 +40,22 @@ static std::unordered_map<std::string, int> mousecodes {
|
|||||||
{"left", GLFW_MOUSE_BUTTON_1},
|
{"left", GLFW_MOUSE_BUTTON_1},
|
||||||
{"right", GLFW_MOUSE_BUTTON_2},
|
{"right", GLFW_MOUSE_BUTTON_2},
|
||||||
{"middle", GLFW_MOUSE_BUTTON_3},
|
{"middle", GLFW_MOUSE_BUTTON_3},
|
||||||
|
{"side1", GLFW_MOUSE_BUTTON_4},
|
||||||
|
{"side2", GLFW_MOUSE_BUTTON_5},
|
||||||
|
{"side3", GLFW_MOUSE_BUTTON_6},
|
||||||
|
{"side4", GLFW_MOUSE_BUTTON_7},
|
||||||
|
{"side5", GLFW_MOUSE_BUTTON_8},
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::unordered_map<int, std::string> keynames {};
|
static std::unordered_map<int, std::string> keynames {};
|
||||||
|
static std::unordered_map<int, std::string> buttonsnames{};
|
||||||
|
|
||||||
std::string input_util::get_name(mousecode code) {
|
std::string input_util::get_name(mousecode code) {
|
||||||
switch (code) {
|
auto found = buttonsnames.find(static_cast<int>(code));
|
||||||
case mousecode::BUTTON_1:
|
if (found == buttonsnames.end()) {
|
||||||
return "left";
|
return "unknown";
|
||||||
case mousecode::BUTTON_2:
|
|
||||||
return "right";
|
|
||||||
case mousecode::BUTTON_3:
|
|
||||||
return "middle";
|
|
||||||
default:
|
|
||||||
return "unknown";
|
|
||||||
}
|
}
|
||||||
|
return found->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string input_util::get_name(keycode code) {
|
std::string input_util::get_name(keycode code) {
|
||||||
@ -91,6 +92,9 @@ void input_util::initialize() {
|
|||||||
for (const auto& entry : keycodes) {
|
for (const auto& entry : keycodes) {
|
||||||
keynames[entry.second] = entry.first;
|
keynames[entry.second] = entry.first;
|
||||||
}
|
}
|
||||||
|
for (const auto& entry : mousecodes) {
|
||||||
|
buttonsnames[entry.second] = entry.first;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
keycode input_util::keycode_from(const std::string& name) {
|
keycode input_util::keycode_from(const std::string& name) {
|
||||||
@ -210,6 +214,13 @@ std::string input_util::to_string(mousecode code) {
|
|||||||
return "RMB";
|
return "RMB";
|
||||||
case mousecode::BUTTON_3:
|
case mousecode::BUTTON_3:
|
||||||
return "MMB";
|
return "MMB";
|
||||||
|
case mousecode::BUTTON_4:
|
||||||
|
case mousecode::BUTTON_5:
|
||||||
|
case mousecode::BUTTON_6:
|
||||||
|
case mousecode::BUTTON_7:
|
||||||
|
case mousecode::BUTTON_8:
|
||||||
|
return "XButton " + std::to_string(static_cast<int>(code) -
|
||||||
|
static_cast<int>(mousecode::BUTTON_3));
|
||||||
default:
|
default:
|
||||||
return "unknown button";
|
return "unknown button";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,11 +102,17 @@ enum class mousecode : int {
|
|||||||
BUTTON_1 = 0, // Left mouse button
|
BUTTON_1 = 0, // Left mouse button
|
||||||
BUTTON_2 = 1, // Right mouse button
|
BUTTON_2 = 1, // Right mouse button
|
||||||
BUTTON_3 = 2, // Middle mouse button
|
BUTTON_3 = 2, // Middle mouse button
|
||||||
|
BUTTON_4 = 3, // Side mouse button 1
|
||||||
|
BUTTON_5 = 4, // Side mouse button 2
|
||||||
|
BUTTON_6 = 5, // Side mouse button 3
|
||||||
|
BUTTON_7 = 6, // Side mouse button 4
|
||||||
|
BUTTON_8 = 7, // Side mouse button 5
|
||||||
UNKNOWN = -1,
|
UNKNOWN = -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline mousecode MOUSECODES_ALL[] {
|
inline mousecode MOUSECODES_ALL[] {
|
||||||
mousecode::BUTTON_1, mousecode::BUTTON_2, mousecode::BUTTON_3};
|
mousecode::BUTTON_1, mousecode::BUTTON_2, mousecode::BUTTON_3, mousecode::BUTTON_4,
|
||||||
|
mousecode::BUTTON_5, mousecode::BUTTON_6, mousecode::BUTTON_7, mousecode::BUTTON_8 };
|
||||||
|
|
||||||
namespace input_util {
|
namespace input_util {
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user