Provide more game experience options
- Fixes #448. (Setting `cg_animations` to `0` disables the ADS animation)
This commit is contained in:
parent
100eb15378
commit
5e3b41b8ed
@ -588,9 +588,7 @@ namespace spades {
|
||||
hotkeyItems.insertLast(field);
|
||||
}
|
||||
|
||||
// FIXME: generalize these (AddToggleField and AddPlusMinusField) fields
|
||||
|
||||
void AddToggleField(string caption, string configName, bool enabled = true) {
|
||||
void AddChoiceField(string caption, string configName, array<string> labels, array<int> values, bool enabled = true) {
|
||||
spades::ui::UIElement@ container = CreateItem();
|
||||
|
||||
spades::ui::Label label(Parent.Manager);
|
||||
@ -599,49 +597,25 @@ namespace spades {
|
||||
label.Bounds = AABB2(10.f, 0.f, 300.f, 32.f);
|
||||
container.AddChild(label);
|
||||
|
||||
{
|
||||
ConfigSimpleToggleButton field(Parent.Manager, _Tr("Preferences", "ON"), configName, 1);
|
||||
field.Bounds = AABB2(FieldX, 1.f, FieldWidth * 0.5f, 30.f);
|
||||
field.Enable = enabled;
|
||||
container.AddChild(field);
|
||||
}
|
||||
{
|
||||
ConfigSimpleToggleButton field(Parent.Manager, _Tr("Preferences", "OFF"), configName, 0);
|
||||
field.Bounds = AABB2(FieldX + FieldWidth * 0.5f, 1.f, FieldWidth * 0.5f, 30.f);
|
||||
for (uint i = 0; i < labels.length; ++i) {
|
||||
ConfigSimpleToggleButton field(Parent.Manager, labels[i], configName, values[i]);
|
||||
field.Bounds = AABB2(FieldX + FieldWidth / labels.length * i,
|
||||
1.f, FieldWidth / labels.length, 30.f);
|
||||
field.Enable = enabled;
|
||||
container.AddChild(field);
|
||||
}
|
||||
}
|
||||
|
||||
void AddToggleField(string caption, string configName, bool enabled = true) {
|
||||
AddChoiceField(caption, configName,
|
||||
array<string> = {_Tr("Preferences", "ON"), _Tr("Preferences", "OFF")},
|
||||
array<int> = {1, 0}, enabled);
|
||||
}
|
||||
|
||||
void AddPlusMinusField(string caption, string configName, bool enabled = true) {
|
||||
spades::ui::UIElement@ container = CreateItem();
|
||||
|
||||
spades::ui::Label label(Parent.Manager);
|
||||
label.Text = caption;
|
||||
label.Alignment = Vector2(0.f, 0.5f);
|
||||
label.Bounds = AABB2(10.f, 0.f, 300.f, 32.f);
|
||||
container.AddChild(label);
|
||||
|
||||
{
|
||||
ConfigSimpleToggleButton field(Parent.Manager, _Tr("Preferences", "ON"), configName, 1);
|
||||
field.Bounds = AABB2(FieldX, 1.f, FieldWidth * 0.33f, 30.f);
|
||||
field.Enable = enabled;
|
||||
container.AddChild(field);
|
||||
}
|
||||
{
|
||||
ConfigSimpleToggleButton field(Parent.Manager, _Tr("Preferences", "REVERSED"), configName, -1);
|
||||
field.Bounds = AABB2(FieldX + FieldWidth * 0.33f, 1.f, FieldWidth * 0.34f, 30.f);
|
||||
field.Enable = enabled;
|
||||
container.AddChild(field);
|
||||
}
|
||||
{
|
||||
ConfigSimpleToggleButton field(Parent.Manager, _Tr("Preferences", "OFF"), configName, 0);
|
||||
field.Bounds = AABB2(FieldX + FieldWidth * 0.67f, 1.f, FieldWidth * 0.33f, 30.f);
|
||||
field.Enable = enabled;
|
||||
container.AddChild(field);
|
||||
}
|
||||
|
||||
AddChoiceField(caption, configName,
|
||||
array<string> = {_Tr("Preferences", "ON"), _Tr("Preferences", "REVERSED"), _Tr("Preferences", "OFF")},
|
||||
array<int> = {1, -1, 0}, enabled);
|
||||
}
|
||||
|
||||
void FinishLayout() {
|
||||
@ -667,6 +641,11 @@ namespace spades {
|
||||
layouter.AddToggleField(_Tr("Preferences", "Blood"), "cg_blood");
|
||||
layouter.AddToggleField(_Tr("Preferences", "Ejecting Brass"), "cg_ejectBrass");
|
||||
layouter.AddToggleField(_Tr("Preferences", "Ragdoll"), "cg_ragdoll");
|
||||
layouter.AddToggleField(_Tr("Preferences", "Animations"), "cg_animations");
|
||||
layouter.AddToggleField(_Tr("Preferences", "Camera Shake"), "cg_shake");
|
||||
layouter.AddChoiceField(_Tr("Preferences", "Particles"), "cg_particles",
|
||||
array<string> = {_Tr("Preferences", "NORMAL"), _Tr("Preferences", "LESS"), _Tr("Preferences", "OFF")},
|
||||
array<int> = {2, 1, 0});
|
||||
|
||||
layouter.AddHeading(_Tr("Preferences", "Feedbacks"));
|
||||
layouter.AddToggleField(_Tr("Preferences", "Chat Notify Sounds"), "cg_chatBeep");
|
||||
@ -683,10 +662,7 @@ namespace spades {
|
||||
layouter.AddSliderField(_Tr("Preferences", "Minimap size"), "cg_minimapSize", 128, 256, 8,
|
||||
ConfigNumberFormatter(0, " px"));
|
||||
layouter.AddToggleField(_Tr("Preferences", "Show Statistics"), "cg_stats");
|
||||
layouter.AddToggleField(_Tr("Preferences", "Debug Hit Detection"), "cg_debugHitTest");
|
||||
layouter.AddToggleField(_Tr("Preferences", "Weapon Spread Guide"), "cg_debugAim");
|
||||
layouter.FinishLayout();
|
||||
// cg_fov, cg_minimapSize
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
|
||||
SPADES_SETTING(cg_ragdoll);
|
||||
SPADES_SETTING(cg_ejectBrass);
|
||||
DEFINE_SPADES_SETTING(cg_animations, "1");
|
||||
|
||||
namespace spades {
|
||||
namespace client {
|
||||
@ -337,13 +338,24 @@ namespace spades {
|
||||
|
||||
if(actualWeapInput.secondary && player->IsToolWeapon() &&
|
||||
player->IsAlive()){
|
||||
aimDownState += dt * 6.f;
|
||||
if(aimDownState > 1.f)
|
||||
aimDownState = 1.f;
|
||||
}else{
|
||||
aimDownState -= dt * 3.f;
|
||||
if(aimDownState < 0.f)
|
||||
aimDownState = 0.f;
|
||||
// This is the only animation that can be turned off
|
||||
// here; others affect the gameplay directly and
|
||||
// turning them off would be considered cheating
|
||||
if (cg_animations) {
|
||||
aimDownState += dt * 8.f;
|
||||
if(aimDownState > 1.f)
|
||||
aimDownState = 1.f;
|
||||
} else {
|
||||
aimDownState = 1.f;
|
||||
}
|
||||
}else{
|
||||
if (cg_animations) {
|
||||
aimDownState -= dt * 3.f;
|
||||
if(aimDownState < 0.f)
|
||||
aimDownState = 0.f;
|
||||
} else {
|
||||
aimDownState = 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
if(currentTool == player->GetTool()) {
|
||||
|
@ -53,7 +53,7 @@
|
||||
#include "NetClient.h"
|
||||
|
||||
DEFINE_SPADES_SETTING(cg_blood, "1");
|
||||
DEFINE_SPADES_SETTING(cg_reduceSmoke, "0");
|
||||
DEFINE_SPADES_SETTING(cg_particles, "2");
|
||||
DEFINE_SPADES_SETTING(cg_waterImpact, "1");
|
||||
SPADES_SETTING(cg_manualFocus);
|
||||
DEFINE_SPADES_SETTING(cg_autoFocusSpeed, "0.4");
|
||||
@ -144,6 +144,9 @@ namespace spades {
|
||||
if((v - lastSceneDef.viewOrigin).GetPoweredLength() >
|
||||
150.f * 150.f)
|
||||
return;
|
||||
|
||||
if ((int)cg_particles < 1)
|
||||
return;
|
||||
|
||||
Handle<IImage> img = renderer->RegisterImage("Gfx/White.tga");
|
||||
Vector4 color = {0.5f, 0.02f, 0.04f, 1.f};
|
||||
@ -159,7 +162,10 @@ namespace spades {
|
||||
ent->SetRadius(0.1f + GetRandom()*GetRandom()*0.2f);
|
||||
ent->SetLifeTime(3.f, 0.f, 1.f);
|
||||
localEntities.emplace_back(ent);
|
||||
}
|
||||
}
|
||||
|
||||
if((int) cg_particles < 2)
|
||||
return;
|
||||
|
||||
color = MakeVector4(.7f, .35f, .37f, .6f);
|
||||
for(int i = 0; i < 2; i++){
|
||||
@ -178,9 +184,7 @@ namespace spades {
|
||||
ent->SetLifeTime(.20f + GetRandom() * .2f, 0.06f, .20f);
|
||||
localEntities.emplace_back(ent);
|
||||
}
|
||||
|
||||
if(cg_reduceSmoke)
|
||||
return;
|
||||
|
||||
color.w *= .1f;
|
||||
for(int i = 0; i < 1; i++){
|
||||
ParticleSpriteEntity *ent =
|
||||
@ -209,7 +213,10 @@ namespace spades {
|
||||
if(distPowered >
|
||||
150.f * 150.f)
|
||||
return;
|
||||
|
||||
|
||||
if ((int)cg_particles < 1)
|
||||
return;
|
||||
|
||||
Handle<IImage> img = renderer->RegisterImage("Gfx/White.tga");
|
||||
Vector4 color = {c.x / 255.f,
|
||||
c.y / 255.f, c.z / 255.f, 1.f};
|
||||
@ -228,7 +235,10 @@ namespace spades {
|
||||
ent->SetBlockHitAction(ParticleSpriteEntity::BounceWeak);
|
||||
localEntities.emplace_back(ent);
|
||||
}
|
||||
|
||||
|
||||
if ((int)cg_particles < 2)
|
||||
return;
|
||||
|
||||
if(distPowered <
|
||||
32.f * 32.f){
|
||||
for(int i = 0; i < 16; i++){
|
||||
@ -278,7 +288,10 @@ namespace spades {
|
||||
if((origin - lastSceneDef.viewOrigin).GetPoweredLength() >
|
||||
150.f * 150.f)
|
||||
return;
|
||||
|
||||
|
||||
if ((int)cg_particles < 1)
|
||||
return;
|
||||
|
||||
Handle<IImage> img = renderer->RegisterImage("Gfx/White.tga");
|
||||
Vector4 color = {c.x / 255.f,
|
||||
c.y / 255.f, c.z / 255.f, 1.f};
|
||||
@ -307,7 +320,10 @@ namespace spades {
|
||||
l.type = DynamicLightTypePoint;
|
||||
l.color = MakeVector3(3.f, 1.6f, 0.5f);
|
||||
flashDlights.push_back(l);
|
||||
|
||||
|
||||
if ((int)cg_particles < 1)
|
||||
return;
|
||||
|
||||
Vector4 color;
|
||||
Vector3 velBias = {0, 0, -0.5f};
|
||||
color = MakeVector4( .8f, .8f, .8f, .3f);
|
||||
@ -346,7 +362,10 @@ namespace spades {
|
||||
l.color = MakeVector3(3.f, 1.6f, 0.5f);
|
||||
l.useLensFlare = true;
|
||||
flashDlights.push_back(l);
|
||||
|
||||
|
||||
if ((int)cg_particles < 1)
|
||||
return;
|
||||
|
||||
Vector3 velBias = {0,0,0};
|
||||
if(!map->ClipBox(origin.x, origin.y, origin.z)){
|
||||
if(map->ClipBox(origin.x + 1.f, origin.y, origin.z)){
|
||||
@ -403,10 +422,18 @@ namespace spades {
|
||||
ent->SetRadius(1.5f + GetRandom()*GetRandom()*0.8f,
|
||||
0.2f);
|
||||
ent->SetBlockHitAction(ParticleSpriteEntity::Ignore);
|
||||
if(cg_reduceSmoke)
|
||||
ent->SetLifeTime(1.f + GetRandom() * 2.f, 0.1f, 8.f);
|
||||
else
|
||||
ent->SetLifeTime(2.f + GetRandom() * 5.f, 0.1f, 8.f);
|
||||
switch ((int) cg_particles) {
|
||||
case 1:
|
||||
ent->SetLifeTime(0.8f + GetRandom() * 1.f, 0.1f, 8.f);
|
||||
break;
|
||||
case 2:
|
||||
ent->SetLifeTime(1.5f + GetRandom() * 2.f, 0.1f, 8.f);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
ent->SetLifeTime(2.f + GetRandom() * 5.f, 0.1f, 8.f);
|
||||
break;
|
||||
}
|
||||
localEntities.emplace_back(ent);
|
||||
}
|
||||
|
||||
@ -459,14 +486,18 @@ namespace spades {
|
||||
grenadeVibration += 1.5f / (dist + 5.f);
|
||||
if(grenadeVibration > 1.f)
|
||||
grenadeVibration = 1.f;
|
||||
|
||||
|
||||
if((int) cg_particles < 1)
|
||||
return;
|
||||
|
||||
Vector3 velBias = {0,0,0};
|
||||
|
||||
Vector4 color;
|
||||
color = MakeVector4( .95f, .95f, .95f, .6f);
|
||||
// water1
|
||||
Handle<IImage> img = renderer->RegisterImage("Textures/WaterExpl.png");
|
||||
if(cg_reduceSmoke) color.w = .3f;
|
||||
Handle<IImage> img = renderer->RegisterImage("Textures/WaterExpl.png");
|
||||
if((int) cg_particles < 2)
|
||||
color.w = .3f;
|
||||
for(int i = 0; i < 7; i++){
|
||||
ParticleSpriteEntity *ent =
|
||||
new ParticleSpriteEntity(this, img, color);
|
||||
@ -486,7 +517,8 @@ namespace spades {
|
||||
// water2
|
||||
img = renderer->RegisterImage("Textures/Fluid.png");
|
||||
color.w = .9f;
|
||||
if(cg_reduceSmoke) color.w = .4f;
|
||||
if((int) cg_particles < 2)
|
||||
color.w = .4f;
|
||||
for(int i = 0; i < 16; i++){
|
||||
ParticleSpriteEntity *ent =
|
||||
new ParticleSpriteEntity(this, img, color);
|
||||
@ -504,8 +536,9 @@ namespace spades {
|
||||
}
|
||||
|
||||
// slow smoke
|
||||
color.w = .4f;
|
||||
if(cg_reduceSmoke) color.w = .2f;
|
||||
color.w = .4f;
|
||||
if((int) cg_particles < 2)
|
||||
color.w = .2f;
|
||||
for(int i = 0; i < 8; i++){
|
||||
ParticleSpriteEntity *ent =
|
||||
new SmokeSpriteEntity(this, color, 20.f);
|
||||
@ -518,7 +551,17 @@ namespace spades {
|
||||
ent->SetRadius(1.4f + GetRandom()*GetRandom()*0.8f,
|
||||
0.2f);
|
||||
ent->SetBlockHitAction(ParticleSpriteEntity::Ignore);
|
||||
ent->SetLifeTime((cg_reduceSmoke ? 3.f : 6.f) + GetRandom() * 5.f, 0.1f, 8.f);
|
||||
switch ((int)cg_particles) {
|
||||
case 1:
|
||||
ent->SetLifeTime(3.f + GetRandom() * 5.f, 0.1f, 8.f);
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
default:
|
||||
ent->SetLifeTime(6.f + GetRandom() * 5.f, 0.1f, 8.f);
|
||||
break;
|
||||
|
||||
}
|
||||
localEntities.emplace_back(ent);
|
||||
}
|
||||
|
||||
@ -555,12 +598,15 @@ namespace spades {
|
||||
return;
|
||||
if(!cg_waterImpact)
|
||||
return;
|
||||
|
||||
|
||||
if((int) cg_particles < 1)
|
||||
return;
|
||||
|
||||
Vector4 color;
|
||||
color = MakeVector4( .95f, .95f, .95f, .3f);
|
||||
// water1
|
||||
Handle<IImage> img = renderer->RegisterImage("Textures/WaterExpl.png");
|
||||
if(cg_reduceSmoke) color.w = .2f;
|
||||
if((int) cg_particles < 2) color.w = .2f;
|
||||
for(int i = 0; i < 2; i++){
|
||||
ParticleSpriteEntity *ent =
|
||||
new ParticleSpriteEntity(this, img, color);
|
||||
@ -580,7 +626,7 @@ namespace spades {
|
||||
// water2
|
||||
img = renderer->RegisterImage("Textures/Fluid.png");
|
||||
color.w = .9f;
|
||||
if(cg_reduceSmoke) color.w = .4f;
|
||||
if((int) cg_particles < 2) color.w = .4f;
|
||||
for(int i = 0; i < 6; i++){
|
||||
ParticleSpriteEntity *ent =
|
||||
new ParticleSpriteEntity(this, img, color);
|
||||
|
@ -45,6 +45,7 @@ DEFINE_SPADES_SETTING(cg_fov, "68");
|
||||
DEFINE_SPADES_SETTING(cg_thirdperson, "0");
|
||||
DEFINE_SPADES_SETTING(cg_manualFocus, "0");
|
||||
DEFINE_SPADES_SETTING(cg_depthOfFieldAmount, "1");
|
||||
DEFINE_SPADES_SETTING(cg_shake, "1");
|
||||
|
||||
static float nextRandom() {
|
||||
return (float)rand() / (float)RAND_MAX;
|
||||
@ -99,6 +100,8 @@ namespace spades {
|
||||
|
||||
SceneDefinition Client::CreateSceneDefinition() {
|
||||
SPADES_MARK_FUNCTION();
|
||||
|
||||
int shakeLevel = cg_shake;
|
||||
|
||||
SceneDefinition def;
|
||||
def.time = (unsigned int)(time * 1000.f);
|
||||
@ -253,33 +256,33 @@ namespace spades {
|
||||
Vector3 front = player->GetFront();
|
||||
Vector3 right = player->GetRight();
|
||||
Vector3 up = player->GetUp();
|
||||
|
||||
if (shakeLevel >= 1) {
|
||||
float localFireVibration = GetLocalFireVibration();
|
||||
localFireVibration *= localFireVibration;
|
||||
|
||||
if(player->GetTool() == Player::ToolSpade) {
|
||||
localFireVibration *= 0.4f;
|
||||
}
|
||||
|
||||
float localFireVibration = GetLocalFireVibration();
|
||||
localFireVibration *= localFireVibration;
|
||||
|
||||
if(player->GetTool() == Player::ToolSpade) {
|
||||
localFireVibration *= 0.4f;
|
||||
}
|
||||
|
||||
roll += (nextRandom() - nextRandom()) * 0.03f * localFireVibration;
|
||||
scale += nextRandom() * 0.04f * localFireVibration;
|
||||
|
||||
vibPitch += localFireVibration * (1.f - localFireVibration) * 0.01f;
|
||||
vibYaw += sinf(localFireVibration * (float)M_PI * 2.f) * 0.001f;
|
||||
|
||||
def.radialBlur += localFireVibration * 0.2f;
|
||||
|
||||
// sprint bob
|
||||
{
|
||||
float sp = SmoothStep(GetSprintState());
|
||||
vibYaw += sinf(player->GetWalkAnimationProgress() * static_cast<float>(M_PI) * 2.f) * 0.01f * sp;
|
||||
roll -= sinf(player->GetWalkAnimationProgress() * static_cast<float>(M_PI) * 2.f) * 0.005f * (sp);
|
||||
float p = cosf(player->GetWalkAnimationProgress() * static_cast<float>(M_PI) * 2.f);
|
||||
p = p * p; p *= p; p *= p; p *= p;
|
||||
vibPitch += p * 0.01f * sp;
|
||||
}
|
||||
|
||||
|
||||
roll += (nextRandom() - nextRandom()) * 0.03f * localFireVibration;
|
||||
scale += nextRandom() * 0.04f * localFireVibration;
|
||||
|
||||
vibPitch += localFireVibration * (1.f - localFireVibration) * 0.01f;
|
||||
vibYaw += sinf(localFireVibration * (float)M_PI * 2.f) * 0.001f;
|
||||
|
||||
def.radialBlur += localFireVibration * 0.2f;
|
||||
|
||||
// sprint bob
|
||||
{
|
||||
float sp = SmoothStep(GetSprintState());
|
||||
vibYaw += sinf(player->GetWalkAnimationProgress() * static_cast<float>(M_PI) * 2.f) * 0.01f * sp;
|
||||
roll -= sinf(player->GetWalkAnimationProgress() * static_cast<float>(M_PI) * 2.f) * 0.005f * (sp);
|
||||
float p = cosf(player->GetWalkAnimationProgress() * static_cast<float>(M_PI) * 2.f);
|
||||
p = p * p; p *= p; p *= p; p *= p;
|
||||
vibPitch += p * 0.01f * sp;
|
||||
}
|
||||
}
|
||||
|
||||
scale /= GetAimDownZoomScale();
|
||||
|
||||
@ -311,7 +314,7 @@ namespace spades {
|
||||
{
|
||||
// add grenade vibration
|
||||
float grenVib = grenadeVibration;
|
||||
if(grenVib > 0.f){
|
||||
if(grenVib > 0.f && shakeLevel >= 1){
|
||||
grenVib *= 10.f;
|
||||
if(grenVib > 1.f)
|
||||
grenVib = 1.f;
|
||||
|
Loading…
x
Reference in New Issue
Block a user