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
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
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
MyCard
Neos
Commits
4bb4fe41
Commit
4bb4fe41
authored
Feb 04, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feat/deprecate/neos-rs' into 'main'
Feat/deprecate/neos rs See merge request
mycard/Neos!96
parents
eb9ace2e
40cc2454
Pipeline
#19942
passed with stages
in 5 minutes and 28 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
39 deletions
+76
-39
src/api/strings.ts
src/api/strings.ts
+20
-1
src/reducers/duel/hintSlice.ts
src/reducers/duel/hintSlice.ts
+1
-1
src/reducers/duel/modal/yesNoModalSlice.ts
src/reducers/duel/modal/yesNoModalSlice.ts
+1
-1
src/ui/Duel/main.tsx
src/ui/Duel/main.tsx
+54
-36
No files found.
src/api/strings.ts
View file @
4bb4fe41
import
axios
from
"
axios
"
;
import
axios
from
"
axios
"
;
export
async
function
initStrings
()
{
const
strings
=
(
await
axios
.
get
<
string
>
(
`ygopro-database/locales/zh-CN/strings.conf`
)
).
data
;
const
lineIter
=
strings
.
split
(
"
\n
"
);
for
(
const
line
of
lineIter
)
{
if
(
!
line
.
startsWith
(
"
#
"
)
&&
line
!==
""
)
{
let
[
region
,
code
,
value
]
=
line
.
split
(
"
"
,
3
);
localStorage
.
setItem
(
`
${
region
}
_
${
code
}
`
,
value
);
}
}
}
export
async
function
fetchStrings
(
export
async
function
fetchStrings
(
region
:
string
,
region
:
string
,
id
:
number
id
:
number
,
local
?:
boolean
):
Promise
<
string
>
{
):
Promise
<
string
>
{
if
(
local
)
{
return
localStorage
.
getItem
(
`
${
region
}
_
${
id
}
`
)
||
""
;
}
return
(
return
(
await
axios
.
get
<
string
>
(
`http://localhost:3030/strings/
${
region
}
_
${
id
}
`
)
await
axios
.
get
<
string
>
(
`http://localhost:3030/strings/
${
region
}
_
${
id
}
`
)
).
data
;
).
data
;
...
...
src/reducers/duel/hintSlice.ts
View file @
4bb4fe41
...
@@ -16,7 +16,7 @@ export const fetchCommonHintMeta = createAsyncThunk(
...
@@ -16,7 +16,7 @@ export const fetchCommonHintMeta = createAsyncThunk(
const
player
=
param
[
0
];
const
player
=
param
[
0
];
const
hintData
=
param
[
1
];
const
hintData
=
param
[
1
];
const
hintMeta
=
await
fetchStrings
(
"
!system
"
,
hintData
);
const
hintMeta
=
await
fetchStrings
(
"
!system
"
,
hintData
,
true
);
const
response
:
[
number
,
string
]
=
[
player
,
hintMeta
];
const
response
:
[
number
,
string
]
=
[
player
,
hintMeta
];
return
response
;
return
response
;
...
...
src/reducers/duel/modal/yesNoModalSlice.ts
View file @
4bb4fe41
...
@@ -31,7 +31,7 @@ export const fetchYesNoMeta = createAsyncThunk(
...
@@ -31,7 +31,7 @@ export const fetchYesNoMeta = createAsyncThunk(
cardLocation
:
ygopro
.
CardLocation
cardLocation
:
ygopro
.
CardLocation
)
=>
string
;
)
=>
string
;
})
=>
{
})
=>
{
const
desc
=
await
fetchStrings
(
"
!system
"
,
param
.
descCode
);
const
desc
=
await
fetchStrings
(
"
!system
"
,
param
.
descCode
,
true
);
const
meta
=
await
fetchCard
(
param
.
code
,
true
);
const
meta
=
await
fetchCard
(
param
.
code
,
true
);
// TODO: 国际化文案
// TODO: 国际化文案
...
...
src/ui/Duel/main.tsx
View file @
4bb4fe41
import
React
from
"
react
"
;
import
React
,
{
useEffect
,
useRef
}
from
"
react
"
;
import
{
Engine
,
Scene
}
from
"
react-babylonjs
"
;
import
{
Engine
,
Scene
}
from
"
react-babylonjs
"
;
import
{
ReactReduxContext
,
Provider
}
from
"
react-redux
"
;
import
{
ReactReduxContext
,
Provider
}
from
"
react-redux
"
;
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
import
*
as
BABYLON
from
"
@babylonjs/core
"
;
...
@@ -20,43 +20,61 @@ import OptionModal from "./optionModal";
...
@@ -20,43 +20,61 @@ import OptionModal from "./optionModal";
import
Phase
from
"
./phase
"
;
import
Phase
from
"
./phase
"
;
import
CheckCardModalV2
from
"
./checkCardModalV2
"
;
import
CheckCardModalV2
from
"
./checkCardModalV2
"
;
import
ExtraDeck
from
"
./extraDeck
"
;
import
ExtraDeck
from
"
./extraDeck
"
;
import
{
initStrings
}
from
"
../../api/strings
"
;
// Ref: https://github.com/brianzinn/react-babylonjs/issues/126
// Ref: https://github.com/brianzinn/react-babylonjs/issues/126
const
NeosDuel
=
()
=>
(
const
NeosDuel
=
()
=>
{
<>
// 应该用更优雅的方式处理`useEffect`执行两次的问题
<
ReactReduxContext
.
Consumer
>
const
initialRender
=
useRef
(
true
);
{
({
store
})
=>
(
useEffect
(()
=>
{
<
Engine
antialias
adaptToDeviceRatio
canvasId=
"babylonJS"
>
const
init
=
async
()
=>
{
<
Scene
>
await
initStrings
();
<
Provider
store=
{
store
}
>
};
<
Camera
/>
<
Light
/>
if
(
initialRender
.
current
)
{
<
Hands
/>
initialRender
.
current
=
false
;
<
Monsters
/>
return
;
<
Magics
/>
}
<
Field
/>
<
CommonDeck
/>
init
();
<
ExtraDeck
/>
},
[]);
<
Cemeteries
/>
<
Exclusion
/>
return
(
<
Field
/>
<>
<
Phase
/>
<
ReactReduxContext
.
Consumer
>
<
Ground
/>
{
({
store
})
=>
(
</
Provider
>
<
Engine
antialias
adaptToDeviceRatio
canvasId=
"babylonJS"
>
</
Scene
>
<
Scene
>
</
Engine
>
<
Provider
store=
{
store
}
>
)
}
<
Camera
/>
</
ReactReduxContext
.
Consumer
>
<
Light
/>
<
CardModal
/>
<
Hands
/>
<
CardListModal
/>
<
Monsters
/>
<
HintNotification
/>
<
Magics
/>
<
CheckCardModal
/>
<
Field
/>
<
YesNoModal
/>
<
CommonDeck
/>
<
PositionModal
/>
<
ExtraDeck
/>
<
OptionModal
/>
<
Cemeteries
/>
<
CheckCardModalV2
/>
<
Exclusion
/>
</>
<
Field
/>
);
<
Phase
/>
<
Ground
/>
</
Provider
>
</
Scene
>
</
Engine
>
)
}
</
ReactReduxContext
.
Consumer
>
<
CardModal
/>
<
CardListModal
/>
<
HintNotification
/>
<
CheckCardModal
/>
<
YesNoModal
/>
<
PositionModal
/>
<
OptionModal
/>
<
CheckCardModalV2
/>
</>
);
};
const
Camera
=
()
=>
(
const
Camera
=
()
=>
(
<
freeCamera
<
freeCamera
...
...
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