Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add two new buttons to Soundsets Importer window #106

Merged
merged 2 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion public/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"elements": "Soundset Elements",
"createdMacro": "Created macro \"{macroName}\"",
"createdFolder": "Created macro folder \"{folderName}\"",
"idCopiedToClipboard": "Mood Id copied to clipboard : \"{id}\"",
"collapse": "Collapse: ",
"expand": "Expand: ",
"removeSelection": "Remove selection: ",
Expand All @@ -60,7 +61,8 @@
"stopMood": "Stop Mood",
"playElement": "Play: {elementName}",
"createMacro": "Create Macro",
"createPlaylist": "Create Playlist"
"createPlaylist": "Create Playlist",
"copyIdToClipboard": "Copy ID to Clipboard"
},
"elements": {
"zeroFound": "No elements found"
Expand Down
3 changes: 2 additions & 1 deletion public/languages/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"playElement": "Graj: {elementName}",
"stopMood": "Zatrzymaj nastrój",
"createMacro": "Utwórz makro",
"createPlaylist": "Utwórz playlistę"
"createPlaylist": "Utwórz playlistę",
"copyIdToClipboard": "Copy ID to Clipboard"
frondeus marked this conversation as resolved.
Show resolved Hide resolved
},
"elements": {
"zeroFound": "Brak elementów"
Expand Down
21 changes: 21 additions & 0 deletions src/components/SimpleButton.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script lang="ts">
export let icon: string;
export let title: string;
</script>

<span role="button" class="syrin-control" {title} on:click on:keypress>
<i class="fas fa-{icon}" />
</span>

<style>
.syrin-control {
display: inline;
margin: 2px;
vertical-align: middle;
}

.syrin-control i {
display: inline;
vertical-align: middle;
}
</style>
22 changes: 22 additions & 0 deletions src/components/importer/Mood.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type { CurrentlyPlaying, Mood, Soundset } from '@/models';
import Context from '@/services/context';
import Toggable from '@/components/Toggable.svelte';
import SimpleButton from '@/components/SimpleButton.svelte';

// Context
const ctx = Context();
Expand Down Expand Up @@ -40,6 +41,17 @@
ctx.syrin.setMood(mood.id);
}
}

async function createMoodMacro() {
let macro = await ctx.game.createMoodMacro(mood, '');
ctx.utils.trace('Element | Macro = ', { macro });
ctx.game.notifyInfo('importer.createdMacro', { macroName: mood.name });
}

function copyMoodIdToClipboard() {
navigator.clipboard.writeText(mood.id.toString());
ctx.game.notifyInfo('importer.idCopiedToClipboard', { id: mood.id });
}
</script>

<tr class="mood" data-test="syrin-mood-row">
Expand All @@ -56,6 +68,16 @@
</span>
</td>
<td class="actions-cell">
<SimpleButton
on:click={copyMoodIdToClipboard}
title={ctx.game.localize('commands.copyIdToClipboard')}
icon="copy"
/>
<SimpleButton
on:click={createMoodMacro}
title={ctx.game.localize('commands.createMacro')}
icon="terminal"
/>
<Toggable
on:click={onPlayMood}
toggled={isPlaying}
Expand Down