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

fix(UI): update visualisation files | fix build #45

Merged
merged 6 commits into from
Aug 13, 2024
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
Binary file removed assets/fonts/Jost-Regular.woff
Binary file not shown.
Binary file removed assets/fonts/Jost-Regular.woff2
Binary file not shown.
1 change: 0 additions & 1 deletion assets/index-DFDuEtdz.css

This file was deleted.

3,355 changes: 0 additions & 3,355 deletions assets/index-DNOwXiCN.js

This file was deleted.

13 changes: 0 additions & 13 deletions assets/js/dat.gui.min.js

This file was deleted.

Binary file removed assets/textures/clay.exr
Binary file not shown.
Binary file removed assets/textures/clay3.exr
Binary file not shown.
16 changes: 10 additions & 6 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import pluginJs from '@eslint/js'
import tseslint from 'typescript-eslint'
import react from 'eslint-plugin-react'
import eslintConfigPrettier from 'eslint-config-prettier'
import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';
import react from 'eslint-plugin-react';
import prettierConfig from 'eslint-config-prettier';
import globals from 'globals';

export default [
react.configs.flat.recommended,
react.configs.flat['jsx-runtime'],
pluginJs.configs.recommended,
...tseslint.configs.recommended,
eslintConfigPrettier,
{
languageOptions: {
globals: { ...globals.browser },
},
files: ['src/**/*.{js,ts,jsx,tsx}'],
ignores: ['./**/*.config.{js,ts}'],
plugins: { react },
Expand All @@ -19,4 +22,5 @@ export default [
'@typescript-eslint/no-explicit-any': 'warn',
},
},
]
prettierConfig,
];
8 changes: 3 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<title>Tari Universe</title>
<script type="module" crossorigin src="/assets/index-DNOwXiCN.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-DFDuEtdz.css">
<style>
canvas {
canvas {
visibility: visible;
padding: 0 0 0 200px;
position: absolute;
Expand All @@ -25,7 +23,7 @@
</head>
<body>
<div id="root"></div>
<script src="assets/js/dat.gui.min.js"></script>
<script type="module" crossorigin src="/assets/index-CcNHoC10.js"></script>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@emotion/styled": "^11.13.0",
"@mui/material": "^5.16.6",
"@tauri-apps/api": "^1",
"globals": "^15.9.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^5.2.1",
Expand Down
3,535 changes: 3,535 additions & 0 deletions public/assets/index-CcNHoC10.js

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
Binary file added public/assets/textures/LDR_RGB1_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/textures/matcap.exr
Binary file not shown.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import { TauriEvent } from './types.ts';
import useAppStateStore from './store/appStateStore.ts';
import { useMining } from './hooks/useMining.ts';

import { preload } from './visuals.js';
import { useGetApplicatonsVersions } from './hooks/useGetApplicatonsVersions.ts';
import { preload } from './visuals';

function App() {
const background = useUIStore((s) => s.background);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useAppStatusStore } from '../../../../store/useAppStatusStore.ts';
import { useMining } from '../../../../hooks/useMining.ts';
import { styled } from '@mui/material/styles';
import { keyframes } from '@emotion/react';
import { useUIStore } from '../../../../store/useUIStore.ts';

const StartStyle = {
background: '#06C983',
Expand Down Expand Up @@ -44,9 +45,12 @@ const StyledIcon = styled(AiOutlineLoading)(() => ({

function MiningButton() {
const mining = useAppStatusStore((s) => s.cpu?.is_mining);
const { startMining, stopMining, isLoading } = useMining();
const isLoading = useUIStore((s) => s.isMiningLoading);

const { startMining, stopMining } = useMining();

const handleMining = () => {
if (isLoading) return;
if (mining) {
stopMining();
} else {
Expand Down
21 changes: 13 additions & 8 deletions src/hooks/useMining.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,46 @@
import { useCallback } from 'react';
import { useCallback, useRef } from 'react';
import { invoke } from '@tauri-apps/api/tauri';
import { useUIStore } from '../store/useUIStore';
import { setStart, setPause } from '../visuals';
import { setStart, setStop, setRestart } from '../visuals';

export function useMining() {
const isLoading = useUIStore((s) => s.isMiningLoading);
const setIsLoading = useUIStore((s) => s.setIsMiningLoading);
const setBackground = useUIStore((s) => s.setBackground);
const hasStarted = useRef(false);

const startMining = useCallback(async () => {
setIsLoading(true);
try {
await invoke('start_mining', {});
setStart();
} catch (e) {
console.error('Could not start mining', e);
} finally {
setIsLoading(false);
setBackground('mining');
if (!hasStarted.current) {
hasStarted.current = true;
setStart();
} else {
setRestart();
}
}
}, []);
}, [setIsLoading, setIsLoading]);

const stopMining = useCallback(async () => {
setIsLoading(true);
try {
await invoke('stop_mining', {});
setPause();
setStop();
} catch (e) {
console.error('Could not stop mining', e);
} finally {
setIsLoading(false);
setBackground('idle');
}
}, []);
}, [setIsLoading, setIsLoading]);

return {
startMining,
stopMining,
isLoading,
};
}
44 changes: 7 additions & 37 deletions src/visuals.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-undef */
let time;

export const preload = () => {
const el = document.getElementById('canvas');
if (el) {
Expand Down Expand Up @@ -43,43 +43,13 @@ function update(dt) {
glApp.render(dt);
}

export const setStart = () => {
properties.stateSignal.dispatch(STATUS.STARTED);
};

function setSuccess() {
properties.resultSignal.dispatch(RESULT.COMPLETED);
}

function setFailure() {
properties.resultSignal.dispatch(RESULT.FAILED);
}

export const setPause = () => {
properties.resultSignal.dispatch(RESULT.PAUSE);
export function setStop() {
properties.stateSignal.dispatch(STATUS.NOT_STARTED);
};

function onNewSpawn(callback) {
if (callback && typeof callback === 'function') {
properties.spawnSignal.add(callback);
}
}

function onGameEnd(callback) {
if (callback && typeof callback === 'function') {
properties.gameEndedSignal.add(callback);
}
}

function onCycleEnd(callback) {
if (callback && typeof callback === 'function') {
properties.endCycleSignal.add(callback);
}
export function setRestart() {
properties.stateSignal.dispatch(STATUS.FREE);
}

function onStateChange(callback) {
if (callback && typeof callback === 'function') {
properties.stateSignal.add((newState) => callback(newState));
}
}
export const setStart = () => {
properties.stateSignal.dispatch(STATUS.STARTED);
};
Loading