Skip to content

Commit

Permalink
update: Sun 07 Apr 2024 08:54:52 CEST
Browse files Browse the repository at this point in the history
  • Loading branch information
cophilot committed Apr 7, 2024
1 parent 0f3397f commit 2f476bb
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/app/coordinate-system/coordinate-system.component.sass
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
p
text-align: center
margin-left: -10px
cursor: default

.measure-band-y
opacity: 0.6 !important
Expand All @@ -98,3 +99,4 @@
p
text-align: center
margin-left: 10px
cursor: default
2 changes: 0 additions & 2 deletions src/app/service/move.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { ObjectService } from './object.service';
providedIn: 'root',
})
export class MoveService {
static G = 6.6743e-11;

private interval: any | null = null;

isPlaying: boolean = false;
Expand Down
20 changes: 20 additions & 0 deletions src/app/service/settings.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { Injectable } from '@angular/core';
import { LocalStorageService } from './local-storage.service';
import { CoordinateSystemComponent } from '../coordinate-system/coordinate-system.component';
import {
CollisionMode,
collisionModeToString,
rotateCollisionMode,
} from '../../types/CollisionMode';

@Injectable({
providedIn: 'root',
Expand All @@ -14,6 +19,8 @@ export class SettingsService {
private static showLogo = true;
private static showSettings = true;

private static collisionMode: CollisionMode = CollisionMode.IGNORE;

static init() {
if (this.isInit) {
return;
Expand All @@ -25,6 +32,7 @@ export class SettingsService {
this.showVelocityArrow = settings.showVelocityArrow;
this.showLogo = settings.showLogo;
this.showSettings = settings.showSettings;
this.collisionMode = settings.collisionMode;
}
this.isInit = true;
}
Expand All @@ -37,6 +45,7 @@ export class SettingsService {
showVelocityArrow: this.showVelocityArrow,
showLogo: this.showLogo,
showSettings: this.showSettings,
collisionMode: this.collisionMode,
});
}

Expand Down Expand Up @@ -89,6 +98,17 @@ export class SettingsService {
this.saveSettings();
}

static getCollisionMode(): string {
this.init();
return collisionModeToString(this.collisionMode);
}

static toggleCollisionMode(): void {
this.init();
this.collisionMode = rotateCollisionMode(this.collisionMode);
this.saveSettings();
}

static toggleGridSize(): void {
this.init();

Expand Down
7 changes: 2 additions & 5 deletions src/app/settings/settings/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,8 @@ <h2>View</h2>
<h2>Behavior</h2>
<div class="row">
<p class="label">Collision Mode</p>
<button
class="actionButton"
(click)="getSettings().toggleSettingsVisibility()"
>
{{ getSettings().isSettingsVisible() ? "ON" : "OFF" }}
<button class="actionButton" (click)="getSettings().toggleCollisionMode()">
{{ getSettings().getCollisionMode() }}
</button>
</div>
<h2>Examples</h2>
Expand Down
1 change: 0 additions & 1 deletion src/app/settings/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
getPlutoCharonExample,
getThreeBody,
} from '../../../data/examples';
import { CoordinateSystemComponent } from 'src/app/coordinate-system/coordinate-system.component';
import { ObjectService } from 'src/app/service/object.service';

@Component({
Expand Down
27 changes: 27 additions & 0 deletions src/types/CollisionMode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export enum CollisionMode {
IGNORE = 'Ignore',
END = 'End',
JOIN = 'Join',
}

export function rotateCollisionMode(mode: CollisionMode): CollisionMode {
switch (mode) {
case CollisionMode.IGNORE:
return CollisionMode.END;
case CollisionMode.END:
return CollisionMode.JOIN;
case CollisionMode.JOIN:
return CollisionMode.IGNORE;
}
}

export function collisionModeToString(mode: CollisionMode): string {
switch (mode) {
case CollisionMode.IGNORE:
return 'Ignore';
case CollisionMode.END:
return 'End';
case CollisionMode.JOIN:
return 'Join';
}
}

0 comments on commit 2f476bb

Please sign in to comment.