Skip to content

Commit

Permalink
refactor: reset settings structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanimodori committed Feb 22, 2024
1 parent 5a7dedd commit a35e5cd
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/renderer/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
const recordStore = useRecordStore();
onMounted(() => {
if (settingsStore.autoConnect) {
if (settingsStore.connection.startup) {
recordStore.connect();
}
});
Expand Down
5 changes: 3 additions & 2 deletions packages/renderer/src/store/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ export const useRecordStore = defineStore('record', () => {
ws.close();
}
const settingsStore = useSettingsStore();
const port = settingsStore.port;
ws = new WebSocket(`ws://localhost:${port}`);
const host = settingsStore.connection.host;
const port = settingsStore.connection.port;
ws = new WebSocket(`ws://${host}:${port}`);

ws.onmessage = (event: MessageEvent<string>) => {
if (event.type === 'message') {
Expand Down
64 changes: 44 additions & 20 deletions packages/renderer/src/store/settings.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
import { defineStore } from 'pinia';
import { ref } from 'vue';

export const useSettingsStore = defineStore('settings', {
state: () => {
return {
bgAlpha: 100,
bgColor: 'FFFFFF',
bgCornerSize: 0,
fontAlpha: 100,
fontColor: '000000',
fontSize: 16,
align: 'topleft',
paddingtop: 0,
paddingbottom: 0,
paddingleft: 0,
paddingright: 0,
cols: [],
shortcut: 'Ctrl+Shift+Num0',
port: 24399,
autoConnect: true,
};
},
export const useSettingsStore = defineStore('settings', () => {
const connection = ref({
host: 'localhost',
port: 24399,
startup: true,
retry: true,
});

const damageStyle = ref({
bgAlpha: 100,
bgColor: 'FFFFFF',
bgCornerSize: 0,
fontAlpha: 100,
fontColor: '000000',
fontSize: 16,
});

const damageCols = ref({
order: [],
});

const windowStyle = ref({
align: 'topleft',
paddingtop: 0,
paddingbottom: 0,
paddingleft: 0,
paddingright: 0,
width: 700,
height: 500,
});

const shortcut = ref({
enabled: true,
key: 'Ctrl+Shift+Num0',
});

return {
connection,
damageStyle,
damageCols,
windowStyle,
shortcut,
};
});
1 change: 0 additions & 1 deletion packages/renderer/src/views/damage/DamagePane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
}>();
const validPlayers = computed(() => {
console.log(props.record.players);
return props.record.players.filter(player => player);
});
</script>
Expand Down

0 comments on commit a35e5cd

Please sign in to comment.