Skip to content

Commit 3677d5e

Browse files
committed
#41 Fixed bug with overlaped player's bar plane; added "Copy link" button
1 parent ac89f89 commit 3677d5e

File tree

5 files changed

+31
-15
lines changed

5 files changed

+31
-15
lines changed

frontend/src/App.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component } from 'solid-js'
22
import { useNavigate, useRoutes } from '@solidjs/router'
3-
import { Button, Card, CardActions, IconButton } from '@suid/material'
4-
import { House } from '@suid/icons-material'
3+
import { Card, CardActions, IconButton } from '@suid/material'
4+
import { Home } from '@suid/icons-material'
55

66
import styles from './App.module.css'
77
import routes, { fullLocation } from './router'
@@ -28,7 +28,7 @@ const App: Component = () => {
2828
color="primary"
2929
onClick={() => navigate(fullLocation('/'))}
3030
>
31-
<House fontSize="large" />
31+
<Home fontSize="large" />
3232
</IconButton>
3333
</CardActions>
3434
</Card>

frontend/src/gui/player_bar.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default class PlayerBarGUI {
2626
stack.isHitTestVisible = false
2727

2828
const plane = BABYLON.MeshBuilder.CreatePlane('stack-plane', {
29-
size: 1,
29+
size: 0.5,
3030
})
3131
// plane.parent = this.camera
3232
plane.position.z = -0.1
@@ -43,7 +43,13 @@ export default class PlayerBarGUI {
4343
createScoreComponent(color: string): GUIComponent<TextComponent> {
4444
const background = color
4545
color = color === 'black' ? 'white' : 'black'
46-
const scoreBlock = new TextComponent('80px', '360px', color, background, 46)
46+
const scoreBlock = new TextComponent(
47+
'200px',
48+
'760px',
49+
color,
50+
background,
51+
120
52+
)
4753
scoreBlock.container.isVisible = false
4854

4955
this.stack.component.addControl(scoreBlock.container)
@@ -54,9 +60,9 @@ export default class PlayerBarGUI {
5460
createUndoButton(onUndo: Function): GUIComponent<GUI.Button> {
5561
const button = GUI.Button.CreateSimpleButton('undo-button', 'Undo move')
5662
button.background = 'white'
57-
button.height = '60px'
58-
button.width = '160px'
59-
button.fontSize = 24
63+
button.height = '160px'
64+
button.width = '450px'
65+
button.fontSize = 60
6066
button.isVisible = false
6167

6268
button.onPointerClickObservable.add(() => {

frontend/src/logic/game_manager.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ export default class GameManager {
8686

8787
this._GUI.onStart()
8888

89+
// Setting initial score
90+
this.setBlackScore(game.blackScore)
91+
this.setWhiteScore(game.whiteScore)
92+
8993
// if it's multiplayer and it's not player's turn
9094
if (
9195
this.isMultiplayer &&
@@ -101,10 +105,6 @@ export default class GameManager {
101105

102106
this.field.canMove = true
103107
}
104-
105-
// Setting initial score
106-
this.setBlackScore(game.blackScore)
107-
this.setWhiteScore(game.whiteScore)
108108
}
109109

110110
undo() {

frontend/src/logic/games/multiplayer_game.ts

-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ export default class MultiplayerGame implements Game {
146146
// Setting right moveNumber
147147
this._moveNumber += game.history.records.length
148148

149-
console.log(this._blackScore)
150-
151149
// put stones and scores
152150
this.onRecreateGame(blackStones, whiteStones)
153151
}

frontend/src/pages/rooms/[id].tsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Box from '@suid/material/Box'
33
import Container from '@suid/material/Container'
44
import { createTheme, ThemeProvider } from '@suid/material/styles'
55
import { Component, createSignal, onMount, Show } from 'solid-js'
6-
import { useNavigate, useParams } from '@solidjs/router'
6+
import { useLocation, useNavigate, useParams } from '@solidjs/router'
77
import { Button, Card, CardContent, Stack, Typography } from '@suid/material'
88
import { grey } from '@suid/material/colors'
99

@@ -19,6 +19,7 @@ export default function RoomPage() {
1919
const [store, setStore] = createLocalStore()
2020
const params = useParams()
2121
const navigate = useNavigate()
22+
const location = useLocation()
2223
const [anotherPlayer, setAnotherPlayer] = createSignal<FetchedUser | null>(
2324
null
2425
)
@@ -54,6 +55,9 @@ export default function RoomPage() {
5455
const isUserPlayer1 = () => store.room?.player1_id === store.user?.id
5556
const isWaitingForGameToStart = () => !isUserPlayer1() && !store.room?.game_id
5657

58+
const copyLinkToClipboard = async () =>
59+
navigator.clipboard.writeText(window.location.href)
60+
5761
async function enterRoom() {
5862
const room = await api.enterRoom(store.room.id)
5963
setStore('room', room)
@@ -81,6 +85,14 @@ export default function RoomPage() {
8185
: anotherPlayer()?.username
8286
}
8387
></PlayerCard>
88+
<Show when={isUserPlayer1() && store.room?.player2_id === null}>
89+
<Button
90+
color="secondary"
91+
onClick={async () => await copyLinkToClipboard()}
92+
>
93+
<Typography>Copy This Link</Typography>
94+
</Button>
95+
</Show>
8496

8597
<Show when={!isUserPlayer1() && store.room?.player2_id === null}>
8698
<Button variant="contained" onClick={() => enterRoom()}>

0 commit comments

Comments
 (0)