Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/df hud settings #92

Merged
merged 4 commits into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions layout/pages/settings/gameplay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,10 @@
<RadioButton group="accelmirrorenable" text="#Common_On" value="1" />
</ChaosSettingsEnum>

<ConVarEnabler convar="mom_df_hud_accel_mirror_enable" class="flow-down">
<ChaosSettingsSlider text="#Settings_Defrag_CGAZ_MirrorBorder" min="0" max="10" convar="mom_df_hud_accel_mirror_border" displayprecision="0" infomessage="#Settings_Defrag_CGAZ_MirrorBorder_Info" tags="cgaz" />
</ConVarEnabler>

<ChaosSettingsEnum text="#Settings_Defrag_CGAZ_True" convar="mom_df_hud_accel_scale_enable" infomessage="#Settings_Defrag_CGAZ_True_Info" tags="cgaz">
<RadioButton group="accelscaleenable" text="#Common_Off" value="0" />
<RadioButton group="accelscaleenable" text="#Common_On" value="1" />
Expand Down Expand Up @@ -629,6 +633,11 @@
</ConVarEnabler>

<!-- Trueness Mode -->

<ChaosSettingsEnum text="#Settings_Defrag_PrimeSight_OneLineEnable" convar="mom_df_hud_prime_one_line_enable" infomessage="#Settings_Defrag_PrimeSight_OneLineEnable_Info" tags="prime,sight">
<RadioButton group="primeonelineenable" text="#Common_Off" value="0" />
<RadioButton group="primeonelineenable" text="#Common_On" value="1" />
</ChaosSettingsEnum>
</ConVarEnabler>

</Panel>
Expand Down Expand Up @@ -664,9 +673,12 @@
</ChaosSettingsEnumDropDown>

<ConVarEnabler convar="mom_df_hud_compass_mode" class="flow-down">
<ChaosSettingsSlider text="#Settings_Defrag_CompassSize" min="0" max="25" convar="mom_df_hud_compass_size" displayprecision="0" infomessage="#Settings_Defrag_CompassSize_Info" tags="compass" />
<ChaosSettingsSlider text="#Settings_Defrag_CompassArrowSize" min="0" max="25" convar="mom_df_hud_compass_arrow_size" displayprecision="0" infomessage="#Settings_Defrag_CompassArrowSize_Info" tags="compass" />

<ChaosSettingsSlider text="#Settings_Defrag_CompassTickSize" min="0" max="50" convar="mom_df_hud_compass_tick_size" displayprecision="0" infomessage="#Settings_Defrag_CompassTickSize_Info" tags="compass" />

<ChaosSettingsSlider text="#Settings_Defrag_CompassOffset" min="-200" max="200" convar="mom_df_hud_compass_offset" displayprecision="0" infomessage="#Settings_Defrag_CompassOffset_Info" tags="compass" />

<!-- Stats Enable -->
</ConVarEnabler>

<ChaosSettingsEnum text="#Settings_Defrag_Pitch" convar="mom_df_hud_pitch_enable" infomessage="#Settings_Defrag_Pitch_Info" tags="pitch">
Expand All @@ -677,7 +689,9 @@
<ConVarEnabler convar="mom_df_hud_pitch_enable" class="flow-down">
<ChaosSettingsSlider text="#Settings_Defrag_PitchTarget" min="-90" max="90" convar="mom_df_hud_pitch_target" displayprecision="1" infomessage="#Settings_Defrag_PitchTarget_Info" tags="compass,pitch" />

<!-- Stats Enable -->
<ChaosSettingsSlider text="#Settings_Defrag_PitchWidth" min="10" max="200" convar="mom_df_hud_pitch_width" displayprecision="1" infomessage="#Settings_Defrag_PitchWidth_Info" tags="compass,pitch" />

<ChaosSettingsSlider text="#Settings_Defrag_PitchOffset" min="-200" max="200" convar="mom_df_hud_pitch_offset" displayprecision="1" infomessage="#Settings_Defrag_PitchOffset_Info" tags="compass,pitch" />
</ConVarEnabler>

<ChaosSettingsEnumDropDown text="#Settings_Defrag_Compass_Stat_Mode" convar="mom_df_hud_compass_stat_mode" infomessage="#Settings_Defrag_Compass_Stat_Mode_Info" tags="compass">
Expand All @@ -701,9 +715,15 @@
</ChaosSettingsEnum>

<ConVarEnabler convar="mom_df_hud_windicator_enable" class="flow-down">
<ChaosSettingsSlider text="#Settings_Defrag_WIndicatorZoneHeight" min="0" max="50" convar="mom_df_hud_windicator_height" displayprecision="0" infomessage="#Settings_Defrag_WIndicatorZoneHeight_Info" />

<ChaosSettingsSlider text="#Settings_Defrag_WIndicatorZoneOffset" min="-200" max="200" convar="mom_df_hud_windicator_offset" displayprecision="0" infomessage="#Settings_Defrag_WIndicatorZoneOffset_Info" />

<ChaosSettingsSlider text="#Settings_Defrag_WIndicatorArrowSize" min="0" max="25" convar="mom_df_hud_windicator_size" displayprecision="0" infomessage="#Settings_Defrag_WIndicatorArrowSize_Info" />

<ConVarColorDisplay text="#Settings_Defrag_WIndicatorArrowColor" convar="mom_df_hud_windicator_color" infomessage="#Settings_Defrag_WIndicatorArrowColor_Info" />

<ChaosSettingsSlider text="#Settings_Defrag_WIndicatorBorder" min="0" max="10" convar="mom_df_hud_windicator_border" displayprecision="0" infomessage="#Settings_Defrag_WIndicatorBorder_Info" />
</ConVarEnabler>

</Panel>
Expand Down
88 changes: 44 additions & 44 deletions scripts/hud/cgaz.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class Cgaz {
this.accelDzColor = accelConfig.dzColor;
this.accelScaleEnable = accelConfig.scaleEnable;
this.accelMirrorEnable = accelConfig.mirrorEnable;
this.accelMirrorBorder = Math.round(accelConfig.mirrorBorder);

NEUTRAL_CLASS = new StyleObject(this.accelHeight, this.accelOffset, this.accelDzColor);
SLOW_CLASS = new StyleObject(this.accelHeight, this.accelOffset, this.accelSlowColor);
Expand All @@ -176,19 +177,9 @@ class Cgaz {
this.applyClass(this.rightFastZone, FAST_CLASS);
this.applyClass(this.rightTurnZone, TURN_CLASS);
this.applyClass(this.accelSplitZone, NEUTRAL_CLASS);
this.applyClassBorder(this.leftMirrorZone, 2, MIRROR_CLASS);
this.applyClassBorder(this.rightMirrorZone, 2, MIRROR_CLASS);
this.applyClassBorder(this.mirrorSplitZone, 2, MIRROR_CLASS);

if (this.snapEnable) {
this.onSnapConfigChange();
}
if (this.windicatorEnable) {
this.onWindicatorConfigChange();
}
if (this.compassPitchEnable || this.compassMode) {
this.onCompassConfigChange();
}
this.applyClassBorder(this.leftMirrorZone, this.accelMirrorBorder, MIRROR_CLASS);
this.applyClassBorder(this.rightMirrorZone, this.accelMirrorBorder, MIRROR_CLASS);
this.applyClassBorder(this.mirrorSplitZone, this.accelMirrorBorder, MIRROR_CLASS);
}

static onSnapConfigChange() {
Expand All @@ -207,14 +198,12 @@ class Cgaz {
this.snapColorMode = snapConfig.colorMode;
this.snapHeightgainEnable = snapConfig.enableHeightGain;

const accelConfig = DefragAPI.GetHUDAccelCFG(); // needed for aligning snaps to top of cgaz bar by default
const offset = this.snapOffset + (accelConfig.enable ? 0.5 * accelConfig.height + accelConfig.offset : 0);
COLORED_SNAP_CLASS = new StyleObject(this.snapHeight, offset, this.snapColor);
UNCOLORED_SNAP_CLASS = new StyleObject(this.snapHeight, offset, this.snapAltColor);
HIGHLIGHTED_SNAP_CLASS = new StyleObject(this.snapHeight, offset, this.snapHlColor);
HIGHLIGHTED_ALT_SNAP_CLASS = new StyleObject(this.snapHeight, offset, this.snapHlAltColor);
COLORED_SNAP_CLASS = new StyleObject(this.snapHeight, this.snapOffset, this.snapColor);
UNCOLORED_SNAP_CLASS = new StyleObject(this.snapHeight, this.snapOffset, this.snapAltColor);
HIGHLIGHTED_SNAP_CLASS = new StyleObject(this.snapHeight, this.snapOffset, this.snapHlColor);
HIGHLIGHTED_ALT_SNAP_CLASS = new StyleObject(this.snapHeight, this.snapOffset, this.snapHlAltColor);

this.setupContainer(this.snapContainer, offset);
this.setupContainer(this.snapContainer, this.snapOffset);
for (let i = 0; i < this.snapZones?.length; ++i) {
this.applyClass(this.snapZones[i], i % 2 ? UNCOLORED_SNAP_CLASS : COLORED_SNAP_CLASS);
}
Expand All @@ -225,6 +214,7 @@ class Cgaz {
this.primeEnable = primeConfig.enable;
this.primeTruenessMode = primeConfig.truenessMode;
this.primeShowInactive = primeConfig.inactiveEnable;
this.primeLockOneLine = primeConfig.oneLineEnable;
this.primeMinSpeed = primeConfig.minSpeed;
this.primeHeight = primeConfig.height;
this.primeOffset = primeConfig.offset;
Expand Down Expand Up @@ -276,39 +266,48 @@ class Cgaz {
}

static onWindicatorConfigChange() {
const windicatorArrowConfig = DefragAPI.GetHUDWIndicatorCFG();
this.windicatorEnable = windicatorArrowConfig.enable;
this.windicatorSize = windicatorArrowConfig.size;
this.windicatorColor = windicatorArrowConfig.color;

const accelConfig = DefragAPI.GetHUDAccelCFG();
const width = 2 * this.windicatorSize;
const height = accelConfig.height + 2 * width;
const offset = accelConfig.enable ? accelConfig.offset : 0;
const windicatorConfig = DefragAPI.GetHUDWIndicatorCFG();
this.windicatorEnable = windicatorConfig.enable;
this.windicatorHeight = windicatorConfig.height;
this.windicatorOffset = windicatorConfig.offset;
this.windicatorSize = windicatorConfig.size;
this.windicatorOffset = windicatorConfig.offset;
this.windicatorColor = windicatorConfig.color;
this.windicatorBorder = Math.round(windicatorConfig.border);

const arrowWidth = 2 * this.windicatorSize;
const arrowHeight = 2 * arrowWidth;
this.setupArrow(
this.windicatorArrow,
this.windicatorArrowIcon,
height,
width,
offset,
arrowHeight,
arrowWidth,
this.windicatorOffset,
'top',
this.windicatorColor
);

WIN_ZONE_CLASS = new StyleObject(accelConfig.height, accelConfig.offset, this.windicatorColor);
this.applyClassBorder(this.windicatorZone, 2, WIN_ZONE_CLASS);
WIN_ZONE_CLASS = new StyleObject(this.windicatorHeight, this.windicatorOffset, this.windicatorColor);
this.applyClassBorder(this.windicatorZone, this.windicatorBorder, WIN_ZONE_CLASS);
}

static onCompassConfigChange() {
const compassConfig = DefragAPI.GetHUDCompassCFG();
this.compassMode = compassConfig.compassMode;
this.compassSize = compassConfig.compassSize;
this.compassArrowSize = compassConfig.compassArrowSize;
this.compassTickSize = compassConfig.compassTickSize;
this.compassOffset = compassConfig.compassOffset;
this.compassPitchEnable = compassConfig.pitchEnable;
this.compassPitchTarget = String(compassConfig.pitchTarget).split(' ');
this.compassPitchWidth = compassConfig.pitchWidth;
this.compassPitchOffset = compassConfig.pitchOffset;
this.compassStatMode = compassConfig.statMode;
this.compassColor = compassConfig.color;
this.compassHlColor = compassConfig.highlightColor;

this.pitchLineContainer.style.width = this.compassPitchWidth + 'px';
this.pitchLineContainer.style.transform = `translatex( ${this.compassPitchOffset}px )`;

const pitchLines = this.pitchLineContainer?.Children();
if (this.compassPitchTarget.length > pitchLines?.length) {
for (let i = pitchLines?.length; i < this.compassPitchTarget.length; ++i) {
Expand All @@ -323,21 +322,20 @@ class Cgaz {
}
}

const accelConfig = DefragAPI.GetHUDAccelCFG();
const offset = accelConfig.offset - 0.5 * (accelConfig.height + this.compassSize);
const size = this.NaNCheck(this.compassSize, 0);
const size = this.NaNCheck(this.compassTickSize, 0);
const offset = this.compassOffset - 0.5 * this.compassTickSize;
this.setupContainer(this.tickContainer, offset);
this.compassTickFull.style.height = size + 'px';
this.compassTickHalf.style.height = size * 0.5 + 'px';

const width = 2 * this.compassSize;
const height = accelConfig.height + 2 * width;
const width = 2 * this.compassArrowSize;
const height = 2 * width;
this.setupArrow(
this.compassArrow,
this.compassArrowIcon,
height,
width,
accelConfig.offset,
this.compassOffset,
'bottom',
this.compassColor
);
Expand Down Expand Up @@ -688,7 +686,7 @@ class Cgaz {
this.compassArrowIcon.AddClass('arrow__down');
velocityAngle = this.remapAngle(velocityAngle - Math.PI);
}
const leftEdge = this.mapToScreenWidth(velocityAngle) - this.compassSize;
const leftEdge = this.mapToScreenWidth(velocityAngle) - this.compassArrowSize;
this.compassArrow.style.marginLeft = this.NaNCheck(leftEdge, 0) + 'px';
this.compassArrowIcon.style.washColor = this.getRgbFromRgba(color);
}
Expand Down Expand Up @@ -1035,11 +1033,13 @@ class Cgaz {
const scale = 1 / (gainMax > 0 ? gainMax : this.primeAccel);
for (const [zone, gain] of gainZonesMap.entries()) {
const gainFactor = Math.min(Math.abs(gain * scale), 1);
const secondLine = gain < 0 && !this.primeLockOneLine;
const height = this.NaNCheck(this.primeHeight * (this.primeHeightgainEnable ? gainFactor : 1), 0);
const margin = gain < 0 ? this.primeHeight : this.primeHeight - height;
const margin = secondLine ? this.primeHeight : this.primeHeight - height;
zone.style.height = Number(height).toFixed(0) + 'px';
zone.style.marginTop = Number(margin).toFixed(0) + 'px';
zone.style.marginBottom = Number(gain < 0 ? this.primeHeight - height : this.primeHeight).toFixed(0) + 'px';
zone.style.marginBottom =
Number(secondLine ? this.primeHeight - height : this.primeHeight).toFixed(0) + 'px';

if (zone.isInactive) continue;

Expand Down
4 changes: 2 additions & 2 deletions styles/hud/cgaz.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
}

.cgaz-line {
width: 100px;
width: 100%;
height: 2px;
align: center top;
transform: translatey(-1px);

&__container {
width: 100%;
//width set in js
height: 100%;
horizontal-align: center;
}
Expand Down
Loading