Skip to content

Commit

Permalink
Add mouse sensitivity back.
Browse files Browse the repository at this point in the history
Update credits.
  • Loading branch information
mooflu committed Oct 26, 2023
1 parent 2e60799 commit 059a335
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 26 deletions.
39 changes: 28 additions & 11 deletions data/system/Menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,31 +103,48 @@
Text="-=<[ Critical Mass (aka Critter) ]>=-"
Info="Have you used your bike lately? Why not?"
Size="1.2"
Position="500.0 440.0"/>
Position="500.0 460.0"/>
<TextItem
Text="Copyright (C) 2004-2023 Frank Becker"
Info="Visit https://github.com/mooflu"
Size="0.85"
Position="500.0 400.0" />
<TextItem
Text="Visit https://github.com/mooflu/critter"
Info="Older versions on http://criticalmass.sourceforge.net"
Position="500.0 320.0" />
Position="500.0 420.0" />
<TextItem
Text="Special thanks to:"
Info="Danke schoen. Muchas gracias. Merci."
Position="500.0 220.0" />
Position="500.0 370.0" />
<TextItem
Text="-- SDL folks --"
Info="Goto libsdl.org for details."
Position="500.0 190.0" />
Position="500.0 330.0" />
<TextItem
Text="-- Lee Thomason (TinyXml) --"
Info="Goto https://github.com/leethomason for details."
Position="500.0 160.0" />
Position="500.0 300.0" />
<TextItem
Text="-- Lunar Gravity & Burkey (Soundtrack) --"
Info="Critical: Lunar Gravity's Millennium Remake"
Position="500.0 130.0" />
Position="500.0 270.0" />
<TextItem
Text="-- PhysicsFS --"
Info="Goto https://github.com/icculus/physfs for details."
Position="500.0 240.0" />
<TextItem
Text="-- mini-yaml --"
Info="Goto https://github.com/jimmiebergmann/mini-yaml for details."
Position="500.0 210.0" />
<TextItem
Text="-- vmmlib --"
Info="Goto https://github.com/VMML/vmmlib for details."
Position="500.0 180.0" />
<TextItem
Text="-- glew --"
Info="Goto https://github.com/nigels-com/glew for details."
Position="500.0 150.0" />
<TextItem
Text="-- glm --"
Info="Goto https://github.com/g-truc/glm for details."
Position="500.0 120.0" />
</Menu>

<Menu
Expand Down Expand Up @@ -213,7 +230,7 @@
Info="Change mouse speed."
Position="220.0 220.0"
Variable="mouseSensitivity"
Range="0.1 0.5"
Range="0.1 3.0"
SliderOffset="100"/>
</Menu>

Expand Down
1 change: 1 addition & 0 deletions data/system/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ config:
developer: false
debug: false
autofireOn: 1
mouseSensitivity: 1

binds:
CritterBoard: TAB
Expand Down
10 changes: 7 additions & 3 deletions game/Input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Input::Input(void) :
_callbackManager(),
_mousePos(0, 0),
_mouseDelta(0, 0),
_mouseSensitivity(1.0f),
_interceptor(0) {
XTRACE();
}
Expand Down Expand Up @@ -109,7 +110,10 @@ bool Input::init(void) {
return true;
}

void Input::updateMouseSettings(void) {}
void Input::updateMouseSettings(void) {
ConfigS::instance()->getFloat( "mouseSensitivity", _mouseSensitivity);
Clampf(_mouseSensitivity, 0.1f, 3.0f);
}


// Returns false, if there are no more events available.
Expand Down Expand Up @@ -175,8 +179,8 @@ bool Input::tryGetTrigger(Trigger& trigger, bool& isDown) {

case SDL_MOUSEMOTION:
trigger.type = eMotionTrigger;
trigger.fData1 = (float)event.motion.xrel;
trigger.fData2 = (float)-event.motion.yrel;
trigger.fData1 = (float)event.motion.xrel * _mouseSensitivity;
trigger.fData2 = (float)-event.motion.yrel * _mouseSensitivity;
break;

case SDL_MOUSEWHEEL:
Expand Down
1 change: 1 addition & 0 deletions game/Input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class Input : public ConfigHandler {
//mouse position [0..1]
vec2f _mousePos;
vec2f _mouseDelta;
float _mouseSensitivity;

//intercept raw input
InterceptorI* _interceptor;
Expand Down
26 changes: 14 additions & 12 deletions game/Selectable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,12 @@ void FloatSelectable::draw(const Point2Di& offset) {
1.6f, 0.4f);
_icons->DrawC(_doubleArrow, _boundingBox.min.x + offset.x + 112 + _sliderOffset + _xPos,
_boundingBox.min.y + offset.y + 15, 0.8f, 0.8f);

float curVal = _min + _xPos * (_max - _min) / 140.0f;
char valStr[10];
sprintf(valStr, "%2.2f", curVal);
_fontWhite->DrawString(valStr, _boundingBox.max.x + offset.x,
_boundingBox.min.y + offset.y + 5, 0.5f, 0.5f);
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -461,12 +467,10 @@ void EnumSelectable::input(const Trigger& trigger, const bool& isDown, const Poi
break;

case eButtonTrigger: {
if (trigger.data1 == SDL_MOUSEWHEEL) {
if (trigger.data3 > 0) {
nextEnum();
} else {
prevEnum();
}
if ((trigger.data1 != SDL_MOUSEWHEEL) || trigger.data3 > 0) {
nextEnum();
} else {
prevEnum();
}
} break;

Expand Down Expand Up @@ -872,12 +876,10 @@ void ResolutionSelectable::input(const Trigger& trigger, const bool& isDown, con
(mouseY >= (_bRect.min.y + offset.y)) && (mouseY <= (_bRect.max.y + offset.y))) {
applyResolution();
} else {
if (trigger.data1 == SDL_MOUSEWHEEL) {
if (trigger.data3 > 0) {
nextResolution();
} else {
prevResolution();
}
if ((trigger.data1 != SDL_MOUSEWHEEL) || trigger.data3 > 0) {
nextResolution();
} else {
prevResolution();
}
}
}
Expand Down

0 comments on commit 059a335

Please sign in to comment.