This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
-
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 #9 from jojobii-arks/jojobii-arks/0-svelte-rewrite
Jojobii arks/0 svelte rewrite
- Loading branch information
Showing
17 changed files
with
351 additions
and
203 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
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 |
---|---|---|
@@ -1,2 +1,6 @@ | ||
/** API generated from [api.ts] */ | ||
declare const api: typeof import('./api').default; | ||
|
||
declare interface Window { | ||
api: typeof api; | ||
} |
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,123 @@ | ||
<script lang="ts"> | ||
import { onMount } from 'svelte'; | ||
import type { ActionLogItem } from '../../lib/types'; | ||
const api = window.api; | ||
let log: ActionLogItem[] = []; | ||
let gameDirectory: string; | ||
let sessionMesetaTotal: number; | ||
$: sessionMesetaTotal = [...log] | ||
.filter( | ||
(e) => | ||
['[Pickup]', '[DiscradExchange]'].includes(e.action_type) && | ||
e.item_num?.includes('N-Meseta') | ||
) | ||
.reduce( | ||
(total: number, action) => | ||
total + Number(/\d+(?=\))(?!\()/.exec(action.item_num ?? '')), | ||
0 | ||
); | ||
let showMeseta = true; | ||
let isAlwaysOnTop = false; | ||
$: api.setIsAlwaysOnTop(isAlwaysOnTop); | ||
onMount(() => { | ||
api.onAlert((_, value) => { | ||
alert(value); | ||
}); | ||
api.onNewAction((_, value) => { | ||
log = [...log, ...value]; | ||
}); | ||
api.getGameDirectory().then((value) => { | ||
gameDirectory = value.split('\\').at(-1); | ||
}); | ||
return () => { | ||
api.clear(); | ||
}; | ||
}); | ||
</script> | ||
|
||
<main class="flex h-[100vh] flex-col overflow-y-clip"> | ||
<header class="draggable select-none bg-base-300 p-4"> | ||
<div> | ||
<h1 class="mb-1 text-2xl font-black">NGS Log Observer</h1> | ||
<p class="mb-2 text-sm"> | ||
Using logs from{' '} | ||
<button | ||
class="link-hover link" | ||
on:click={() => { | ||
api.openGameDirectory(); | ||
}} | ||
> | ||
{gameDirectory} | ||
</button> | ||
</p> | ||
</div> | ||
<div class="flex flex-wrap justify-between"> | ||
<div class="stats"> | ||
<div class="no-drag stat"> | ||
<div class="stat-title text-sm">Session 💰</div> | ||
<div class="stat-value select-text text-xl"> | ||
{sessionMesetaTotal.toLocaleString()} | ||
</div> | ||
</div> | ||
</div> | ||
<div class="flex flex-col"> | ||
<div class="form-control"> | ||
<label class="no-drag label cursor-pointer"> | ||
<span class="label-text mr-4">Show Meseta</span> | ||
<input type="checkbox" class="toggle" bind:checked={showMeseta} /> | ||
</label> | ||
</div> | ||
<div class="form-control"> | ||
<label class="no-drag label cursor-pointer"> | ||
<span class="label-text mr-4">Always On Top</span> | ||
<input | ||
type="checkbox" | ||
class="toggle" | ||
bind:checked={isAlwaysOnTop} | ||
/> | ||
</label> | ||
</div> | ||
</div> | ||
</div> | ||
</header> | ||
<div class="flex-auto overflow-y-scroll"> | ||
<table class="table-compact relative table w-full"> | ||
<thead class="sticky top-0"> | ||
<tr> | ||
<th class="rounded-none">Type</th> | ||
<th>Data</th> | ||
<th class="rounded-none">Time</th> | ||
</tr> | ||
</thead> | ||
<tbody class="min-h-full"> | ||
{#each [...log].reverse().filter((e) => { | ||
/** check if `showMeseta` is on, then filter accordingly */ | ||
if (!showMeseta) { | ||
if (e.item_num?.includes('N-Meseta')) return false; | ||
} | ||
/** only show pickups and sells */ | ||
return ['[Pickup]', '[DiscradExchange]'].includes(e.action_type); | ||
}) as action} | ||
<tr> | ||
<td>{action.item_num?.includes('N-Meseta') ? `💰` : `📥`}</td> | ||
<td> | ||
{action.item_name | ||
? action.item_name + | ||
' - x' + | ||
/\d+(?=\))(?!\()/.exec(action.item_num ?? '') | ||
: 'N-Meseta - x' + | ||
/\d+(?=\))(?!\()/.exec(action.item_num ?? '')}</td | ||
> | ||
<td>{new Date(action.log_time).toLocaleString()}</td> | ||
</tr> | ||
{/each} | ||
</tbody> | ||
</table> | ||
</div> | ||
</main> |
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
import '../index.css'; | ||
import App from './App.svelte'; | ||
|
||
const app = new App({ | ||
target: document.getElementById('app'), | ||
}); | ||
|
||
export default app; |
This file was deleted.
Oops, something went wrong.
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 +1,3 @@ | ||
/// <reference types="svelte" /> | ||
/// <reference types="vite/client" /> | ||
|
Oops, something went wrong.