mirror of
https://github.com/eugene-serb/wavelovers.git
synced 2023-09-09 23:41:16 +03:00
- added interface IPatternUnit and his implementation PatternUnit.
- deleted createPatternUnit-function in AppCustom and AppManual, used now class PatternUnit to create. - deleted consoles in AppManual. - updated dependencies.
This commit is contained in:
parent
d340a6e81d
commit
34e3db0d02
24
package-lock.json
generated
24
package-lock.json
generated
@ -2219,9 +2219,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "18.6.5",
|
"version": "18.7.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.6.5.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.1.tgz",
|
||||||
"integrity": "sha512-Xjt5ZGUa5WusGZJ4WJPbOT8QOqp6nDynVFRKcUt32bOgvXEoc6o085WNkYTMO7ifAj2isEfQQ2cseE+wT6jsRw==",
|
"integrity": "sha512-GKX1Qnqxo4S+Z/+Z8KKPLpH282LD7jLHWJcVryOflnsnH+BtSDfieR6ObwBMwpnNws0bUK8GI7z0unQf9bARNQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/normalize-package-data": {
|
"node_modules/@types/normalize-package-data": {
|
||||||
@ -5186,9 +5186,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/electron-to-chromium": {
|
"node_modules/electron-to-chromium": {
|
||||||
"version": "1.4.213",
|
"version": "1.4.215",
|
||||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.213.tgz",
|
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.215.tgz",
|
||||||
"integrity": "sha512-+3DbGHGOCHTVB/Ms63bGqbyC1b8y7Fk86+7ltssB8NQrZtSCvZG6eooSl9U2Q0yw++fL2DpHKOdTU0NVEkFObg==",
|
"integrity": "sha512-vqZxT8C5mlDZ//hQFhneHmOLnj1LhbzxV0+I1yqHV8SB1Oo4Y5Ne9+qQhwHl7O1s9s9cRuo2l5CoLEHdhMTwZg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/emoji-regex": {
|
"node_modules/emoji-regex": {
|
||||||
@ -13592,9 +13592,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "18.6.5",
|
"version": "18.7.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.6.5.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.1.tgz",
|
||||||
"integrity": "sha512-Xjt5ZGUa5WusGZJ4WJPbOT8QOqp6nDynVFRKcUt32bOgvXEoc6o085WNkYTMO7ifAj2isEfQQ2cseE+wT6jsRw==",
|
"integrity": "sha512-GKX1Qnqxo4S+Z/+Z8KKPLpH282LD7jLHWJcVryOflnsnH+BtSDfieR6ObwBMwpnNws0bUK8GI7z0unQf9bARNQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/normalize-package-data": {
|
"@types/normalize-package-data": {
|
||||||
@ -15802,9 +15802,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"electron-to-chromium": {
|
"electron-to-chromium": {
|
||||||
"version": "1.4.213",
|
"version": "1.4.215",
|
||||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.213.tgz",
|
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.215.tgz",
|
||||||
"integrity": "sha512-+3DbGHGOCHTVB/Ms63bGqbyC1b8y7Fk86+7ltssB8NQrZtSCvZG6eooSl9U2Q0yw++fL2DpHKOdTU0NVEkFObg==",
|
"integrity": "sha512-vqZxT8C5mlDZ//hQFhneHmOLnj1LhbzxV0+I1yqHV8SB1Oo4Y5Ne9+qQhwHl7O1s9s9cRuo2l5CoLEHdhMTwZg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"emoji-regex": {
|
"emoji-regex": {
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import store from '@/store/index';
|
import store from '@/store/index';
|
||||||
import TPatternUnit from '@/models/TPatternUnit';
|
import TPatternUnit from '@/models/TPatternUnit';
|
||||||
|
import PatternUnit from '@/models/PatternUnit';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'AppCustom',
|
name: 'AppCustom',
|
||||||
@ -49,17 +50,14 @@
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
createPatternUnit: function (): TPatternUnit[] {
|
|
||||||
const patternUnit: TPatternUnit[] = [{
|
|
||||||
startDelay: this.startDelay,
|
|
||||||
duration: this.duration,
|
|
||||||
weakMagnitude: this.weakMagnitude,
|
|
||||||
strongMagnitude: this.strongMagnitude,
|
|
||||||
}];
|
|
||||||
return patternUnit as TPatternUnit[];
|
|
||||||
},
|
|
||||||
start: function (): void {
|
start: function (): void {
|
||||||
store.dispatch('startCustom', this.createPatternUnit());
|
const patterns: TPatternUnit[] = [new PatternUnit(
|
||||||
|
this.startDelay,
|
||||||
|
this.duration,
|
||||||
|
this.weakMagnitude,
|
||||||
|
this.strongMagnitude,
|
||||||
|
)];
|
||||||
|
store.dispatch('startCustom', patterns);
|
||||||
},
|
},
|
||||||
stop: function (): void {
|
stop: function (): void {
|
||||||
store.dispatch('reset');
|
store.dispatch('reset');
|
||||||
|
@ -42,19 +42,20 @@
|
|||||||
import store from '@/store/index';
|
import store from '@/store/index';
|
||||||
import Vibrator from '@/models/Vibrator';
|
import Vibrator from '@/models/Vibrator';
|
||||||
import TPatternUnit from '@/models/TPatternUnit';
|
import TPatternUnit from '@/models/TPatternUnit';
|
||||||
|
import PatternUnit from '@/models/PatternUnit';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'AppCustom',
|
name: 'AppCustom',
|
||||||
data: () => {
|
data: () => {
|
||||||
return {
|
return {
|
||||||
startDelay: 0 as number,
|
|
||||||
duration: 260 as number,
|
|
||||||
weakMagnitude: 0 as number,
|
|
||||||
strongMagnitude: 0 as number,
|
|
||||||
timestamp: 0 as number,
|
timestamp: 0 as number,
|
||||||
interval: 0 as number,
|
interval: 0 as number,
|
||||||
mode: 0 as number,
|
mode: 0 as number,
|
||||||
lock: false as boolean,
|
lock: false as boolean,
|
||||||
|
startDelay: 0 as number,
|
||||||
|
duration: 260 as number,
|
||||||
|
weakMagnitude: 0 as number,
|
||||||
|
strongMagnitude: 0 as number,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -68,17 +69,14 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
createPatternUnit: function (): TPatternUnit {
|
|
||||||
const patternUnit: TPatternUnit = {
|
|
||||||
startDelay: this.startDelay,
|
|
||||||
duration: this.duration,
|
|
||||||
weakMagnitude: this.weakMagnitude,
|
|
||||||
strongMagnitude: this.strongMagnitude,
|
|
||||||
};
|
|
||||||
return patternUnit as TPatternUnit;
|
|
||||||
},
|
|
||||||
start: function (): void {
|
start: function (): void {
|
||||||
store.dispatch('startCustom', this.createPatternUnit());
|
const pattern: TPatternUnit = new PatternUnit(
|
||||||
|
this.startDelay,
|
||||||
|
this.duration,
|
||||||
|
this.weakMagnitude,
|
||||||
|
this.strongMagnitude,
|
||||||
|
);
|
||||||
|
store.dispatch('vibrate', pattern);
|
||||||
},
|
},
|
||||||
stop: function (): void {
|
stop: function (): void {
|
||||||
store.dispatch('setIsActive', false);
|
store.dispatch('setIsActive', false);
|
||||||
@ -98,20 +96,16 @@
|
|||||||
if (this.gamepads.length > 0) {
|
if (this.gamepads.length > 0) {
|
||||||
if (this.gamepads[0].unit.buttons[1].pressed === true) {
|
if (this.gamepads[0].unit.buttons[1].pressed === true) {
|
||||||
this.lock = !this.lock;
|
this.lock = !this.lock;
|
||||||
console.log('B', this.lock);
|
|
||||||
}
|
}
|
||||||
if (this.lock === false) {
|
if (this.lock === false) {
|
||||||
if (this.gamepads[0].unit.buttons[0].pressed === true) {
|
if (this.gamepads[0].unit.buttons[0].pressed === true) {
|
||||||
this.mode = 0;
|
this.mode = 0;
|
||||||
console.log('A', this.mode);
|
|
||||||
}
|
}
|
||||||
if (this.gamepads[0].unit.buttons[2].pressed === true) {
|
if (this.gamepads[0].unit.buttons[2].pressed === true) {
|
||||||
this.mode = 1;
|
this.mode = 1;
|
||||||
console.log('X', this.mode);
|
|
||||||
}
|
}
|
||||||
if (this.gamepads[0].unit.buttons[3].pressed === true) {
|
if (this.gamepads[0].unit.buttons[3].pressed === true) {
|
||||||
this.mode = 2;
|
this.mode = 2;
|
||||||
console.log('Y', this.mode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,9 +131,8 @@
|
|||||||
handle: function (): void {
|
handle: function (): void {
|
||||||
if (this.gamepads.length > 0) {
|
if (this.gamepads.length > 0) {
|
||||||
this.gamepads.forEach((gamepad) => {
|
this.gamepads.forEach((gamepad) => {
|
||||||
if (gamepad.unit.buttons[7].value > 0
|
if (gamepad.unit.buttons[7].value > 0 || this.lock === true) {
|
||||||
|| this.lock === true) {
|
this.start();
|
||||||
gamepad.unit.vibrationActuator.playEffect('dual-rumble', this.createPatternUnit());
|
|
||||||
} else {
|
} else {
|
||||||
this.stop();
|
this.stop();
|
||||||
}
|
}
|
||||||
|
9
src/models/IPatternUnit.ts
Normal file
9
src/models/IPatternUnit.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
interface IPatternUnit {
|
||||||
|
startDelay: number;
|
||||||
|
duration: number;
|
||||||
|
weakMagnitude: number;
|
||||||
|
strongMagnitude: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default IPatternUnit;
|
||||||
|
|
22
src/models/PatternUnit.ts
Normal file
22
src/models/PatternUnit.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import IPatternUnit from "@/models/IPatternUnit";
|
||||||
|
|
||||||
|
class PatternUnit implements IPatternUnit {
|
||||||
|
|
||||||
|
startDelay: number;
|
||||||
|
duration: number;
|
||||||
|
weakMagnitude: number;
|
||||||
|
strongMagnitude: number;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
startDelay: number, duration: number,
|
||||||
|
weakMagnitude: number, strongMagnitude: number
|
||||||
|
) {
|
||||||
|
this.startDelay = startDelay;
|
||||||
|
this.duration = duration;
|
||||||
|
this.weakMagnitude = weakMagnitude;
|
||||||
|
this.strongMagnitude = strongMagnitude;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PatternUnit;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user