show match pane when a match is selected

This commit is contained in:
Ilion Beyst 2022-02-23 23:29:14 +01:00
parent 816b3bfc27
commit bfc2263c7c
3 changed files with 15 additions and 6 deletions

View file

@ -1,7 +1,11 @@
<script lang="ts"> <script lang="ts">
export let matchLog: string; export let matchLog: string;
function getStdErr(log: string, botId: number): string { function getStdErr(botId: number, log?: string): string {
if (!log) {
return "";
}
let output = []; let output = [];
log log
.split("\n") .split("\n")
@ -15,7 +19,7 @@
return output.join("\n"); return output.join("\n");
} }
$: botStdErr = getStdErr(matchLog, 1); $: botStdErr = getStdErr(1, matchLog);
</script> </script>
<div class="output"> <div class="output">

View file

@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { onMount } from "svelte"; import { onDestroy, onMount } from "svelte";
import * as visualizer from "pw-visualizer"; import * as visualizer from "pw-visualizer";
import init_wasm_module from "planetwars-rs"; import init_wasm_module from "planetwars-rs";
@ -15,6 +15,11 @@
visualizer.set_loading(false); visualizer.set_loading(false);
}); });
onDestroy(() => {
// TODO: do a more thorough cleanup
visualizer.stop();
});
$: if (initialized) { $: if (initialized) {
if (matchLog === null) { if (matchLog === null) {
visualizer.set_loading(true); visualizer.set_loading(true);

View file

@ -59,7 +59,7 @@
matches.unshift(matchData); matches.unshift(matchData);
matches = matches; matches = matches;
selectMatch(matchData["id"]); await selectMatch(matchData["id"]);
} }
async function selectMatch(matchId: string) { async function selectMatch(matchId: string) {
@ -158,14 +158,14 @@
</ul> </ul>
</div> </div>
<div class="editor-container"> <div class="editor-container">
{#if selectedMatchLog} {#if selectedMatchId}
<Visualizer matchLog={selectedMatchLog} /> <Visualizer matchLog={selectedMatchLog} />
{:else} {:else}
<EditorView {editSession} /> <EditorView {editSession} />
{/if} {/if}
</div> </div>
<div class="sidebar-right"> <div class="sidebar-right">
{#if selectedMatchLog} {#if selectedMatchId}
<OutputPane matchLog={selectedMatchLog} /> <OutputPane matchLog={selectedMatchLog} />
{:else} {:else}
<SubmitPane on:submit={submitCode} /> <SubmitPane on:submit={submitCode} />