-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fps): adds configurable frame rate (#543)
* feat(fps): adds infrastucture for configuring the target framerate This allows configuration of the target framerate, UI to follow re #404 * feat(dialog): adds Dialog component and UI state with FPS Dialog Creates a reusable Dialog component and adds the FPS dialog fixes #404
- Loading branch information
Showing
8 changed files
with
237 additions
and
5 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
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,31 @@ | ||
const state = { | ||
fps: 60 | ||
}; | ||
|
||
const getters = { | ||
interval: state => 1000 / state.fps | ||
}; | ||
|
||
const actions = { | ||
setFPS({ commit }, { fps }) { | ||
if (!fps) { | ||
throw new Error("No FPS given"); | ||
} | ||
|
||
commit("SET_FPS", { fps }); | ||
} | ||
}; | ||
|
||
const mutations = { | ||
SET_FPS(state, { fps }) { | ||
state.fps = fps; | ||
} | ||
}; | ||
|
||
export default { | ||
namespaced: true, | ||
state, | ||
getters, | ||
mutations, | ||
actions | ||
}; |
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,75 @@ | ||
<template> | ||
<dialog ref="dialog"> | ||
<header> | ||
<button @click="close" class="close">Close</button> | ||
<span>{{ title }}</span> | ||
</header> | ||
|
||
<div class="body"> | ||
<slot></slot> | ||
</div> | ||
</dialog> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
title: { | ||
type: String, | ||
default: "modV" | ||
} | ||
}, | ||
mounted() { | ||
this.$refs.dialog.showModal(); | ||
}, | ||
methods: { | ||
close() { | ||
this.$emit("close"); | ||
this.$refs.dialog.close(); | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<style scoped> | ||
dialog { | ||
/* Dialog Box */ | ||
border: 1px solid #c4c4c4; | ||
background-color: #151515; | ||
color: #ffffff; | ||
padding: 0; | ||
min-width: 310px; | ||
} | ||
header { | ||
font-size: 14px; | ||
line-height: 17px; | ||
background-color: #363636; | ||
text-align: center; | ||
padding: 6px 8px; | ||
} | ||
button.close { | ||
/* Close Button */ | ||
position: absolute; | ||
width: 12px; | ||
height: 12px; | ||
left: 8px; | ||
top: 8px; | ||
background-color: #bc1010; | ||
border: none; | ||
border-radius: 50%; | ||
font-size: 0; | ||
} | ||
div.body { | ||
min-height: 72px; | ||
padding: 8px; | ||
} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
<template> | ||
<div>{{ Math.round($modV.store.state.metrics.fps) }} FPS</div> | ||
<div @dblclick="openFrameRateDialog"> | ||
{{ Math.round($modV.store.state.metrics.fps) }} FPS | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
methods: { | ||
openFrameRateDialog() { | ||
this.$store.commit("dialogs/ADD_OPEN", "frameRate"); | ||
} | ||
} | ||
}; | ||
</script> |
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,46 @@ | ||
<template> | ||
<Dialog | ||
v-if="$store.state.dialogs.open.includes('frameRate')" | ||
@close="dialogClosed" | ||
title="Framerate Options" | ||
> | ||
<grid columns="4"> | ||
<c span="1"> | ||
<label>Target FPS</label> | ||
</c> | ||
<c span="3"> | ||
<Number v-model.number="fps" /> | ||
</c> | ||
</grid> | ||
</Dialog> | ||
</template> | ||
|
||
<script> | ||
import Dialog from "../Dialog"; | ||
import Number from "../inputs/Number"; | ||
export default { | ||
components: { | ||
Dialog, | ||
Number | ||
}, | ||
computed: { | ||
fps: { | ||
get() { | ||
return this.$modV.store.state.fps.fps; | ||
}, | ||
set(fps) { | ||
this.$modV.store.commit("fps/SET_FPS", { fps }); | ||
} | ||
} | ||
}, | ||
methods: { | ||
dialogClosed() { | ||
this.$store.commit("dialogs/REMOVE_OPEN", "frameRate"); | ||
} | ||
} | ||
}; | ||
</script> |
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,27 @@ | ||
const state = { | ||
open: [] | ||
}; | ||
|
||
const mutations = { | ||
ADD_OPEN(state, id) { | ||
if (Array.isArray(id)) { | ||
state.open = state.open.concat(id); | ||
} else { | ||
state.open.push(id); | ||
} | ||
}, | ||
|
||
REMOVE_OPEN(state, id) { | ||
const index = state.open.indexOf(id); | ||
|
||
if (index > -1) { | ||
state.open.splice(index, 1); | ||
} | ||
} | ||
}; | ||
|
||
export default { | ||
namespaced: true, | ||
state, | ||
mutations | ||
}; |