Skip to content

Commit

Permalink
Merge branch 'dev' into fix-remove-un-needed-console-log
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinJMann committed Jan 28, 2025
2 parents 99ecccb + 97595a7 commit c3d5dae
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/app/ui/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,20 @@ import { SettingsManager } from '../../client/core/SettingsManager.ts';
<select [(ngModel)]="settings.crosshairType" (change)="saveSettings()">
<option [ngValue]="1">dot</option>
<option [ngValue]="0">cross</option>
<option [ngValue]="2">can't decide</option>
<option [ngValue]="3">none</option>
</select>
</div>
<div class="setting-item">
<label class="mr-2">crosshair opacity</label>
<div class="flex items-center min-w-[160px]">
<input type="range" min="0" max="1" step="0.05"
[(ngModel)]="settings.crosshairOpacity" (change)="saveSettings()">
<span class="w-8 text-left ml-2">{{ settings.crosshairOpacity | number:'1.1-1' }}</span>
</div>
</div>
<div class="setting-item">
<label class="mr-2">bobbing strength</label>
<div class="flex items-center min-w-[160px]">
Expand Down
2 changes: 2 additions & 0 deletions src/client/core/SettingsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class SettingsManager {
name: null,
crosshairColor: '#00ffff',
crosshairType: 1,
crosshairOpacity: 1,
viewBobbingStrength: 1,
doPrettyText: false,
developerMode: false,
Expand All @@ -35,6 +36,7 @@ interface Settings {
name: null | string;
crosshairColor: string;
crosshairType: number;
crosshairOpacity: number;
viewBobbingStrength: number;
doPrettyText: boolean;
developerMode: boolean;
Expand Down
33 changes: 32 additions & 1 deletion src/client/ui/ChatOverlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -956,20 +956,51 @@ export class ChatOverlay {
private renderCrosshair() {
const ctx = this.chatCtx;
ctx.fillStyle = SettingsManager.settings.crosshairColor;
if (ChatOverlay.isHexColor(SettingsManager.settings.crosshairColor)) {
ctx.fillStyle = SettingsManager.settings.crosshairColor +
ChatOverlay.toTwoDigitHex(SettingsManager.settings.crosshairOpacity);
}

if (this.renderer.crosshairIsFlashing) {
ctx.fillStyle = '#FF0000';
}
switch (SettingsManager.settings.crosshairType) {
case 0:
ctx.fillRect(Math.floor(this.screenWidth / 2), 100 - 3, 1, 7);
ctx.fillRect(Math.floor(this.screenWidth / 2 - 3), 100, 7, 1);
//ctx.fillRect(Math.floor(this.screenWidth / 2 - 3), 100, 7, 1);
ctx.fillRect(Math.floor(this.screenWidth / 2 - 3), 100, 3, 1);
ctx.fillRect(Math.floor(this.screenWidth / 2 + 1), 100, 3, 1);

break;
case 1:
ctx.fillRect(Math.floor(this.screenWidth / 2), 100, 1, 1);
break;
case 2:
ctx.fillRect(Math.floor(this.screenWidth / 2), 100, 1, 1);
ctx.fillRect(Math.floor(this.screenWidth / 2), 95, 1, 3);
ctx.fillRect(Math.floor(this.screenWidth / 2), 103, 1, 3);
ctx.fillRect(Math.floor(this.screenWidth / 2 + 3), 100, 3, 1);
ctx.fillRect(Math.floor(this.screenWidth / 2 - 5), 100, 3, 1);

break;
case 3:
break;
}
}

public static isHexColor(str: string) {
const hexColorRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
return hexColorRegex.test(str);
}

public static toTwoDigitHex(value: number) {
if (value < 0) value = 0;
if (value > 1) value = 1;

const scaledValue = Math.round(value * 255);
return scaledValue.toString(16).padStart(2, '0');
}

private onKeyDown(e: KeyboardEvent) {
if (e.key === 'Backspace' && (this.localPlayer.chatActive || this.nameSettingActive)) {
this.localPlayer.chatMsg = this.localPlayer.chatMsg.slice(0, -1);
Expand Down

0 comments on commit c3d5dae

Please sign in to comment.