Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
love_飞影
Neos
Commits
f8b686d1
Commit
f8b686d1
authored
Aug 07, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finsh enter room logic
parent
ab0be43d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
30 additions
and
70 deletions
+30
-70
src/service/room/hsPlayerEnter.ts
src/service/room/hsPlayerEnter.ts
+6
-1
src/service/room/typeChange.ts
src/service/room/typeChange.ts
+7
-2
src/ui/Layout/index.tsx
src/ui/Layout/index.tsx
+0
-1
src/ui/NeosRouter.tsx
src/ui/NeosRouter.tsx
+1
-49
src/ui/NewMatch/Modal.tsx
src/ui/NewMatch/Modal.tsx
+12
-4
src/ui/NewMatch/util.ts
src/ui/NewMatch/util.ts
+1
-1
src/ui/NewWaitRoom/index.module.scss
src/ui/NewWaitRoom/index.module.scss
+1
-1
src/ui/NewWaitRoom/index.tsx
src/ui/NewWaitRoom/index.tsx
+2
-11
No files found.
src/service/room/hsPlayerEnter.ts
View file @
f8b686d1
...
@@ -7,7 +7,12 @@ export default function handleHsPlayerEnter(pb: ygopro.YgoStocMsg) {
...
@@ -7,7 +7,12 @@ export default function handleHsPlayerEnter(pb: ygopro.YgoStocMsg) {
if
(
pos
>
1
)
{
if
(
pos
>
1
)
{
console
.
log
(
"
Currently only supported 2v2 mode.
"
);
console
.
log
(
"
Currently only supported 2v2 mode.
"
);
}
else
{
}
else
if
(
pos
<
roomStore
.
players
.
length
)
{
roomStore
.
players
[
pos
].
name
=
name
;
roomStore
.
players
[
pos
].
name
=
name
;
}
else
{
roomStore
.
players
.
push
({
name
,
state
:
ygopro
.
StocHsPlayerChange
.
State
.
NO_READY
,
});
}
}
}
}
src/service/room/typeChange.ts
View file @
f8b686d1
...
@@ -17,8 +17,13 @@ export default function handleTypeChange(pb: ygopro.YgoStocMsg) {
...
@@ -17,8 +17,13 @@ export default function handleTypeChange(pb: ygopro.YgoStocMsg) {
break
;
break
;
}
}
default
:
{
default
:
{
roomStore
.
players
[
selfType
-
1
].
state
=
const
player
=
roomStore
.
players
[
selfType
-
1
];
ygopro
.
StocHsPlayerChange
.
State
.
NO_READY
;
const
state
=
ygopro
.
StocHsPlayerChange
.
State
.
NO_READY
;
if
(
player
)
{
player
.
state
=
state
;
}
else
{
roomStore
.
players
.
push
({
name
:
"
?
"
,
state
});
}
break
;
break
;
}
}
}
}
...
...
src/ui/Layout/index.tsx
View file @
f8b686d1
...
@@ -37,7 +37,6 @@ export const Component = () => {
...
@@ -37,7 +37,6 @@ export const Component = () => {
<
NavLink
to=
"/"
>
主页
</
NavLink
>
<
NavLink
to=
"/"
>
主页
</
NavLink
>
<
NavLink
to=
"/match"
>
匹配
</
NavLink
>
<
NavLink
to=
"/match"
>
匹配
</
NavLink
>
<
NavLink
to=
"/build"
>
组卡
</
NavLink
>
<
NavLink
to=
"/build"
>
组卡
</
NavLink
>
<
NavLink
to=
"/waitroom"
>
waitroom(temp)
</
NavLink
>
<
span
style=
{
{
flexGrow
:
1
}
}
/>
<
span
style=
{
{
flexGrow
:
1
}
}
/>
<
span
className=
{
styles
.
profile
}
>
<
span
className=
{
styles
.
profile
}
>
<
NeosAvatar
/>
<
NeosAvatar
/>
...
...
src/ui/NeosRouter.tsx
View file @
f8b686d1
import
{
createBrowserRouter
,
RouterProvider
}
from
"
react-router-dom
"
;
import
{
createBrowserRouter
,
RouterProvider
}
from
"
react-router-dom
"
;
// import LazyLoad, { Loading } from "./LazyLoad";
// const Match = React.lazy(() => import("./Match"));
// const WaitRoom = React.lazy(() => import("./WaitRoom"));
// const Mora = React.lazy(() => import("./Mora"));
// const NeosDuel = React.lazy(() => import("./Duel/Main"));
// const Replay = React.lazy(() => import("./Replay"));
// const SSO = React.lazy(() => import("./SSO"));
// const Profile = React.lazy(() => import("./Profile"));
// const Build = React.lazy(() => import("./Build"));
// TODO: finish this
// TODO: finish this
const
_router
=
createBrowserRouter
([
const
_router
=
createBrowserRouter
([
{
{
...
@@ -34,7 +23,7 @@ const _router = createBrowserRouter([
...
@@ -34,7 +23,7 @@ const _router = createBrowserRouter([
lazy
:
()
=>
import
(
"
./NewProfile
"
),
lazy
:
()
=>
import
(
"
./NewProfile
"
),
},
},
{
{
path
:
"
/waitroom
/:ip?/:player?/:passWd?
"
,
path
:
"
/waitroom
"
,
lazy
:
()
=>
import
(
"
./NewWaitRoom
"
),
lazy
:
()
=>
import
(
"
./NewWaitRoom
"
),
},
},
{
{
...
@@ -44,41 +33,4 @@ const _router = createBrowserRouter([
...
@@ -44,41 +33,4 @@ const _router = createBrowserRouter([
},
},
]);
]);
// 暂且先这么写,为后重构为createBrowserRouter打基础
// const router = createBrowserRouter(
// createRoutesFromElements(
// <Route path="/" element={<NeosLayout />}>
// <Route path="/" element={<LazyLoad lazy={<Start />} />} />
// <Route path="/profile" element={<LazyLoad lazy={<Profile />} />} />
// <Route path="/match" element={<LazyLoad lazy={<Match />} />} />
// <Route
// path="/room/:player/:passWd/:ip"
// element={
// <Suspense fallback={<Loading />}>
// <WaitRoom />
// </Suspense>
// }
// />
// <Route
// path="/mora/:player/:passWd/:ip"
// element={
// <Suspense fallback={<Loading />}>
// <Mora />
// </Suspense>
// }
// />
// <Route path="/replay" element={<LazyLoad lazy={<Replay />} />} />
// <Route
// path="/duel/:player/:passWd/:ip"
// element={
// <Suspense fallback={<Loading />}>
// <NeosDuel />
// </Suspense>
// }
// />
// <Route path="/sso/*" element={<LazyLoad lazy={<SSO />} />} />
// </Route>
// )
// );
export
const
NeosRouter
=
()
=>
<
RouterProvider
router=
{
_router
}
/>;
export
const
NeosRouter
=
()
=>
<
RouterProvider
router=
{
_router
}
/>;
src/ui/NewMatch/Modal.tsx
View file @
f8b686d1
...
@@ -4,9 +4,10 @@ import { useNavigate } from "react-router-dom";
...
@@ -4,9 +4,10 @@ import { useNavigate } from "react-router-dom";
import
{
proxy
,
useSnapshot
}
from
"
valtio
"
;
import
{
proxy
,
useSnapshot
}
from
"
valtio
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
accountStore
}
from
"
@/stores
"
;
import
{
accountStore
,
roomStore
}
from
"
@/stores
"
;
import
styles
from
"
./Modal.module.scss
"
;
import
styles
from
"
./Modal.module.scss
"
;
import
{
init
}
from
"
./util
"
;
const
NeosConfig
=
useConfig
();
const
NeosConfig
=
useConfig
();
const
serverConfig
=
NeosConfig
.
servers
;
const
serverConfig
=
NeosConfig
.
servers
;
...
@@ -28,6 +29,7 @@ export const localStore = proxy<Props>(defaultProps);
...
@@ -28,6 +29,7 @@ export const localStore = proxy<Props>(defaultProps);
export
const
MatchModal
:
React
.
FC
=
({})
=>
{
export
const
MatchModal
:
React
.
FC
=
({})
=>
{
const
{
open
}
=
useSnapshot
(
localStore
);
const
{
open
}
=
useSnapshot
(
localStore
);
const
{
user
}
=
useSnapshot
(
accountStore
);
const
{
user
}
=
useSnapshot
(
accountStore
);
const
{
joined
}
=
useSnapshot
(
roomStore
);
const
[
player
,
setPlayer
]
=
useState
(
user
?.
name
??
defaultPlayer
);
const
[
player
,
setPlayer
]
=
useState
(
user
?.
name
??
defaultPlayer
);
const
[
passwd
,
setPasswd
]
=
useState
(
defaultPassword
);
const
[
passwd
,
setPasswd
]
=
useState
(
defaultPassword
);
const
[
server
,
setServer
]
=
useState
(
const
[
server
,
setServer
]
=
useState
(
...
@@ -47,10 +49,9 @@ export const MatchModal: React.FC = ({}) => {
...
@@ -47,10 +49,9 @@ export const MatchModal: React.FC = ({}) => {
};
};
// 因为萌卡服务器的房间密码会有`#`等特殊字符,因此这里用`encodeURIComponent`做下转义
// 因为萌卡服务器的房间密码会有`#`等特殊字符,因此这里用`encodeURIComponent`做下转义
const
handleSubmit
=
()
=>
{
const
handleSubmit
=
async
()
=>
{
setConfirmLoading
(
true
);
setConfirmLoading
(
true
);
// TODO: 这里应该进行WASM,websocket等的初始化,成功加入房间后才跳转
await
init
({
player
,
ip
:
server
,
passWd
:
passwd
});
// navigate(`/room/${player}/${encodeURIComponent(passwd)}/${server}`);
};
};
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -60,6 +61,13 @@ export const MatchModal: React.FC = ({}) => {
...
@@ -60,6 +61,13 @@ export const MatchModal: React.FC = ({}) => {
}
}
},
[]);
},
[]);
useEffect
(()
=>
{
// 如果一切顺利的话,后端传来已加入房间的信号,这时候跳转到房间页面
if
(
joined
)
{
navigate
(
`/waitroom`
);
}
},
[
joined
]);
return
(
return
(
<
Modal
<
Modal
open=
{
open
}
open=
{
open
}
...
...
src/ui/New
WaitRoom
/util.ts
→
src/ui/New
Match
/util.ts
View file @
f8b686d1
...
@@ -7,7 +7,7 @@ import sqliteMiddleWare, { sqliteCmd } from "@/middleware/sqlite";
...
@@ -7,7 +7,7 @@ import sqliteMiddleWare, { sqliteCmd } from "@/middleware/sqlite";
const
NeosConfig
=
useConfig
();
const
NeosConfig
=
useConfig
();
// 进行进入房间
后
的一些初始化操作
// 进行进入房间
前
的一些初始化操作
export
const
init
=
async
(
params
:
{
export
const
init
=
async
(
params
:
{
ip
:
string
;
ip
:
string
;
player
:
string
;
player
:
string
;
...
...
src/ui/NewWaitRoom/index.module.scss
View file @
f8b686d1
...
@@ -65,7 +65,7 @@
...
@@ -65,7 +65,7 @@
}
}
}
}
.name
{
.name
{
font-size
:
1
4
px
;
font-size
:
1
8
px
;
color
:
white
;
color
:
white
;
z-index
:
1
;
z-index
:
1
;
}
}
...
...
src/ui/NewWaitRoom/index.tsx
View file @
f8b686d1
...
@@ -5,11 +5,10 @@ import PlayerState = ygopro.StocHsPlayerChange.State;
...
@@ -5,11 +5,10 @@ import PlayerState = ygopro.StocHsPlayerChange.State;
import
{
Avatar
,
Button
,
ConfigProvider
,
Popover
,
Skeleton
,
Space
}
from
"
antd
"
;
import
{
Avatar
,
Button
,
ConfigProvider
,
Popover
,
Skeleton
,
Space
}
from
"
antd
"
;
import
classNames
from
"
classnames
"
;
import
classNames
from
"
classnames
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
type
LoaderFunction
,
useLoaderData
}
from
"
react-router-dom
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
accountStore
,
Player
,
roomStore
,
type
User
}
from
"
@/stores
"
;
import
{
accountStore
,
Player
,
roomStore
}
from
"
@/stores
"
;
import
{
Background
,
IconFont
,
Select
}
from
"
@/ui/Shared
"
;
import
{
Background
,
IconFont
,
Select
}
from
"
@/ui/Shared
"
;
import
{
Chat
}
from
"
./Chat
"
;
import
{
Chat
}
from
"
./Chat
"
;
...
@@ -17,14 +16,6 @@ import styles from "./index.module.scss";
...
@@ -17,14 +16,6 @@ import styles from "./index.module.scss";
const
NeosConfig
=
useConfig
();
const
NeosConfig
=
useConfig
();
interface
Params
{
player
?:
string
;
passWd
?:
string
;
ip
?:
string
;
}
export
const
loader
:
LoaderFunction
=
async
({
params
})
=>
params
;
const
theme
=
{
const
theme
=
{
components
:
{
components
:
{
Button
:
{
Button
:
{
...
@@ -42,10 +33,10 @@ const theme = {
...
@@ -42,10 +33,10 @@ const theme = {
};
};
export
const
Component
:
React
.
FC
=
()
=>
{
export
const
Component
:
React
.
FC
=
()
=>
{
const
_params
=
useLoaderData
<
Params
>
();
const
{
user
}
=
useSnapshot
(
accountStore
);
const
{
user
}
=
useSnapshot
(
accountStore
);
const
[
collapsed
,
setCollapsed
]
=
useState
(
false
);
const
[
collapsed
,
setCollapsed
]
=
useState
(
false
);
const
room
=
useSnapshot
(
roomStore
);
const
room
=
useSnapshot
(
roomStore
);
return
(
return
(
<
ConfigProvider
theme=
{
theme
}
>
<
ConfigProvider
theme=
{
theme
}
>
<
div
<
div
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment