-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from marvin-wtt/viewing-rate
Viewing rate
- Loading branch information
Showing
17 changed files
with
765 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface ViewingRateSettings { | ||
startViewing: boolean; | ||
readyCheck: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export type ViewingRateState = | ||
| ViewingRatePreparingState | ||
| ViewingRateRunningState | ||
| ViewingRateCompletedState | ||
| ViewingRatePausedState; | ||
|
||
interface ViewingRateBase { | ||
game: 'viewing-rates'; | ||
} | ||
|
||
export interface ViewingRatePreparingState extends ViewingRateBase { | ||
name: 'preparing'; | ||
controllersReady: string[]; | ||
} | ||
|
||
export interface ViewingRateRunningState extends ViewingRateBase { | ||
name: 'running'; | ||
time: number; | ||
changeTimes: Record<string, number[]>; | ||
} | ||
|
||
export interface ViewingRatePausedState extends ViewingRateBase { | ||
name: 'paused'; | ||
time: number; | ||
changeTimes: Record<string, number[]>; | ||
} | ||
|
||
export interface ViewingRateCompletedState extends ViewingRateBase { | ||
name: 'completed'; | ||
time: number; | ||
changeTimes: Record<string, number[]>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
<q-btn | ||
v-bind="$attrs" | ||
icon="done" | ||
label="" | ||
@click="onConfirm" | ||
/> | ||
</template> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/components/gameModes/viewingRate/ViewingRateResultItem.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<template> | ||
<q-item class="column q-my-xs"> | ||
<div class="text-subtitle1">{{ props.name }}</div> | ||
|
||
<div class="relative-position full-width row bg-grey rounded-borders"> | ||
<div | ||
v-for="(slot, index) of timeSlots" | ||
:key="index" | ||
:style="{ width: `${slot.length * 100}%` }" | ||
:class="slot.viewing ? 'bg-primary' : ''" | ||
class="rounded-borders" | ||
style="height: 15px" | ||
/> | ||
</div> | ||
</q-item> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { computed } from 'vue'; | ||
const props = defineProps<{ | ||
name: string; | ||
times: number[]; | ||
totalTime: number; | ||
default: boolean; | ||
}>(); | ||
interface TimeSlot { | ||
length: number; | ||
viewing: boolean; | ||
} | ||
const timeSlots = computed<TimeSlot[]>(() => { | ||
const times = [...props.times, props.totalTime]; | ||
const slots: TimeSlot[] = []; | ||
let viewing: boolean = props.default; | ||
let previousTime = 0; | ||
for (const time of times) { | ||
const diff = time - previousTime; | ||
const length = diff / props.totalTime; | ||
slots.push({ | ||
length, | ||
viewing, | ||
}); | ||
previousTime = time; | ||
viewing = !viewing; | ||
} | ||
return slots; | ||
}); | ||
</script> | ||
|
||
<style scoped></style> |
74 changes: 74 additions & 0 deletions
74
src/components/gameModes/viewingRate/ViewingRateSettingsDialog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<template> | ||
<q-dialog | ||
ref="dialogRef" | ||
@hide="onDialogHide" | ||
> | ||
<q-card | ||
class="q-dialog-plugin" | ||
style="max-width: 20rem" | ||
> | ||
<q-card-section> | ||
<a class="text-h5"> | ||
{{ t('gameMode.viewingRate.settings.title') }} | ||
</a> | ||
</q-card-section> | ||
|
||
<q-card-section> | ||
<q-form | ||
ref="form" | ||
class="q-gutter-y-sm" | ||
> | ||
<q-toggle | ||
:label="t('gameMode.viewingRate.settings.field.startViewing')" | ||
v-model="settings.startViewing" | ||
/> | ||
<q-toggle | ||
:label="t('gameMode.viewingRate.settings.field.readyCheck')" | ||
v-model="settings.readyCheck" | ||
/> | ||
</q-form> | ||
</q-card-section> | ||
|
||
<q-card-actions align="center"> | ||
<q-btn | ||
:label="t('gameMode.viewingRate.settings.action.ok')" | ||
color="primary" | ||
@click="onOk" | ||
rounded | ||
/> | ||
</q-card-actions> | ||
</q-card> | ||
</q-dialog> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { QForm, useDialogPluginComponent } from 'quasar'; | ||
import { useGameSettingsStore } from 'stores/game-settings-store'; | ||
import { useI18n } from 'vue-i18n'; | ||
import { ref, toRaw } from 'vue'; | ||
import { ViewingRateSettings } from 'app/common/gameSettings/ViewingRateSettings'; | ||
defineEmits([...useDialogPluginComponent.emits]); | ||
const { dialogRef, onDialogHide, onDialogOK } = useDialogPluginComponent(); | ||
const { t } = useI18n(); | ||
const gameSettingsStore = useGameSettingsStore(); | ||
const form = ref<QForm | null>(null); | ||
const settings = ref<ViewingRateSettings>( | ||
structuredClone(toRaw(gameSettingsStore.viewingRateSettings)), | ||
); | ||
const onOk = async () => { | ||
const valid = await form.value?.validate(); | ||
if (!valid) { | ||
return; | ||
} | ||
gameSettingsStore.viewingRateSettings = settings.value; | ||
onDialogOK(); | ||
}; | ||
</script> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export default { | ||
title: 'Einschaltquote', | ||
|
||
currentlyViewing: 'Aktuell eingeschaltet', | ||
totalWatchRate: 'Totale Einschaltquote', | ||
|
||
action: { | ||
cancel: 'Abbrechen', | ||
complete: 'Fertig', | ||
pause: 'Pause', | ||
resume: 'Vorsetzen', | ||
reset: 'Zurücksetzen', | ||
start: 'Start', | ||
}, | ||
|
||
settings: { | ||
title: 'Einstellungen', | ||
|
||
field: { | ||
startViewing: 'Zuschauend beginnen', | ||
readyCheck: 'Bereitschaftsprüfung', | ||
}, | ||
|
||
action: { | ||
ok: 'Ok', | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export default { | ||
title: 'Viewing Rate', | ||
|
||
currentlyViewing: 'Currently viewing', | ||
totalWatchRate: 'Total viewing rate', | ||
|
||
action: { | ||
cancel: 'Cancel', | ||
complete: 'Complete', | ||
pause: 'Pause', | ||
resume: 'Resume', | ||
reset: 'Reset', | ||
start: 'Start', | ||
}, | ||
|
||
settings: { | ||
title: 'Settings', | ||
|
||
field: { | ||
startViewing: 'Start viewing', | ||
readyCheck: 'Ready check', | ||
}, | ||
|
||
action: { | ||
ok: 'Ok', | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.