This commit is contained in:
@clasher113
2025-02-04 13:31:40 +02:00
parent 2105d56b3b
commit aeb5312ed2
4 changed files with 25 additions and 21 deletions
+1 -1
View File
@@ -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) {
if (isFocused()) {
binding.reset(button); binding.reset(button);
defocus(); defocus();
}
} }
void InputBindBox::keyPressed(keycode key) { void InputBindBox::keyPressed(keycode key) {
+1 -2
View File
@@ -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:
+8 -6
View File
@@ -93,10 +93,7 @@ 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) {
interpVel.y *= -30.0f;
}
shake = shake * (1.0f - delta * k); shake = shake * (1.0f - delta * k);
float oh = CAM_SHAKE_OFFSET; float oh = CAM_SHAKE_OFFSET;
if (hitbox.grounded) { if (hitbox.grounded) {
@@ -108,7 +105,12 @@ glm::vec3 CameraControl::updateCameraShaking(
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()) {