Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
srvpro2
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
nanahira
srvpro2
Commits
17fa2913
Commit
17fa2913
authored
Feb 16, 2026
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add menu
parent
91dcb148
Pipeline
#43260
failed with stages
in 83 minutes and 56 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
281 additions
and
284 deletions
+281
-284
src/feats/index.ts
src/feats/index.ts
+1
-0
src/feats/menu-manager.ts
src/feats/menu-manager.ts
+220
-0
src/join-handlers/join-blank-pass-menu.ts
src/join-handlers/join-blank-pass-menu.ts
+58
-283
src/join-handlers/join-handler-module.ts
src/join-handlers/join-handler-module.ts
+2
-1
No files found.
src/feats/index.ts
View file @
17fa2913
export
*
from
'
./client-version-check
'
;
export
*
from
'
./client-version-check
'
;
export
*
from
'
./menu-manager
'
;
export
*
from
'
./welcome
'
;
export
*
from
'
./welcome
'
;
export
*
from
'
./random-duel
'
;
export
*
from
'
./random-duel
'
;
export
*
from
'
./reconnect
'
;
export
*
from
'
./reconnect
'
;
...
...
src/feats/menu-manager.ts
0 → 100644
View file @
17fa2913
import
{
GameMode
,
NetPlayerType
,
YGOProCtosBase
,
YGOProCtosHsToDuelist
,
YGOProCtosKick
,
YGOProStocHsPlayerEnter
,
YGOProStocJoinGame
,
YGOProStocTypeChange
,
}
from
'
ygopro-msg-encode
'
;
import
{
Context
}
from
'
../app
'
;
import
{
Chnroute
,
Client
,
I18nService
}
from
'
../client
'
;
import
{
DefaultHostinfo
}
from
'
../room
'
;
import
{
resolvePanelPageLayout
}
from
'
../utility
'
;
export
type
MenuEntry
=
{
title
:
string
;
callback
:
(
client
:
Client
)
=>
Promise
<
unknown
>
|
unknown
;
};
type
MenuAction
=
|
{
type
:
'
entry
'
;
entry
:
MenuEntry
;
}
|
{
type
:
'
next
'
;
title
:
string
;
offset
:
number
;
}
|
{
type
:
'
prev
'
;
title
:
string
;
offset
:
number
;
};
type
MenuView
=
{
actions
:
MenuAction
[];
mode
:
GameMode
;
slotCount
:
number
;
};
export
class
MenuManager
{
private
i18n
=
this
.
ctx
.
get
(()
=>
I18nService
);
private
chnroute
=
this
.
ctx
.
get
(()
=>
Chnroute
);
constructor
(
private
ctx
:
Context
)
{
this
.
ctx
.
middleware
(
YGOProCtosBase
,
async
(
msg
,
client
,
next
)
=>
{
if
(
!
client
.
currentMenu
)
{
return
next
();
}
if
(
msg
instanceof
YGOProCtosHsToDuelist
||
msg
instanceof
YGOProCtosKick
)
{
return
next
();
}
return
undefined
;
},
true
,
);
this
.
ctx
.
middleware
(
YGOProCtosHsToDuelist
,
async
(
msg
,
client
,
next
)
=>
{
if
(
!
client
.
currentMenu
)
{
return
next
();
}
await
this
.
renderMenu
(
client
);
return
msg
;
});
this
.
ctx
.
middleware
(
YGOProCtosKick
,
async
(
msg
,
client
,
next
)
=>
{
if
(
!
client
.
currentMenu
)
{
return
next
();
}
await
this
.
handleKick
(
client
,
Number
(
msg
.
pos
));
return
undefined
;
});
}
async
launchMenu
(
client
:
Client
,
menu
:
MenuEntry
[])
{
client
.
currentMenu
=
menu
;
if
(
client
.
menuOffset
==
null
)
{
client
.
menuOffset
=
0
;
}
await
this
.
renderMenu
(
client
);
}
clearMenu
(
client
:
Client
)
{
client
.
currentMenu
=
undefined
;
client
.
menuOffset
=
undefined
;
}
private
buildMenuView
(
client
:
Client
):
MenuView
{
const
menu
=
client
.
currentMenu
||
[];
if
(
menu
.
length
<=
2
)
{
return
{
actions
:
menu
.
map
((
entry
)
=>
({
type
:
'
entry
'
,
entry
})),
mode
:
GameMode
.
SINGLE
,
slotCount
:
2
,
};
}
if
(
menu
.
length
<=
4
)
{
return
{
actions
:
menu
.
map
((
entry
)
=>
({
type
:
'
entry
'
,
entry
})),
mode
:
GameMode
.
TAG
,
slotCount
:
4
,
};
}
const
layout
=
resolvePanelPageLayout
(
menu
.
length
,
client
.
menuOffset
||
0
);
client
.
menuOffset
=
layout
.
pageStart
;
const
actions
:
MenuAction
[]
=
[];
if
(
layout
.
isFirstPage
)
{
for
(
const
entry
of
menu
.
slice
(
layout
.
pageStart
,
layout
.
pageStart
+
3
))
{
actions
.
push
({
type
:
'
entry
'
,
entry
});
}
actions
.
push
({
type
:
'
next
'
,
title
:
'
#{menu_next_page}
'
,
offset
:
layout
.
pageStarts
[
layout
.
pageIndex
+
1
],
});
}
else
if
(
layout
.
isLastPage
)
{
actions
.
push
({
type
:
'
prev
'
,
title
:
'
#{menu_prev_page}
'
,
offset
:
layout
.
pageStarts
[
layout
.
pageIndex
-
1
],
});
for
(
const
entry
of
menu
.
slice
(
layout
.
pageStart
,
layout
.
pageStart
+
3
))
{
actions
.
push
({
type
:
'
entry
'
,
entry
});
}
}
else
{
actions
.
push
({
type
:
'
prev
'
,
title
:
'
#{menu_prev_page}
'
,
offset
:
layout
.
pageStarts
[
layout
.
pageIndex
-
1
],
});
for
(
const
entry
of
menu
.
slice
(
layout
.
pageStart
,
layout
.
pageStart
+
2
))
{
actions
.
push
({
type
:
'
entry
'
,
entry
});
}
actions
.
push
({
type
:
'
next
'
,
title
:
'
#{menu_next_page}
'
,
offset
:
layout
.
pageStarts
[
layout
.
pageIndex
+
1
],
});
}
return
{
actions
,
mode
:
GameMode
.
TAG
,
slotCount
:
4
,
};
}
private
async
renderMenu
(
client
:
Client
)
{
if
(
!
client
.
currentMenu
)
{
return
;
}
const
view
=
this
.
buildMenuView
(
client
);
await
client
.
send
(
new
YGOProStocJoinGame
().
fromPartial
({
info
:
{
...
DefaultHostinfo
,
mode
:
view
.
mode
,
},
}),
);
await
client
.
send
(
new
YGOProStocTypeChange
().
fromPartial
({
type
:
NetPlayerType
.
OBSERVER
|
0x10
,
}),
);
const
locale
=
this
.
chnroute
.
getLocale
(
client
.
ip
);
for
(
let
i
=
0
;
i
<
view
.
slotCount
;
i
++
)
{
const
action
=
view
.
actions
[
i
];
const
rawTitle
=
action
?.
type
===
'
entry
'
?
action
.
entry
.
title
:
action
?.
title
||
''
;
const
title
=
rawTitle
?
String
(
await
this
.
i18n
.
translate
(
locale
,
rawTitle
)).
slice
(
0
,
20
)
:
''
;
await
client
.
send
(
new
YGOProStocHsPlayerEnter
().
fromPartial
({
name
:
title
,
pos
:
i
,
}),
);
}
}
private
async
handleKick
(
client
:
Client
,
index
:
number
)
{
if
(
!
client
.
currentMenu
)
{
return
;
}
const
view
=
this
.
buildMenuView
(
client
);
const
selected
=
view
.
actions
[
index
];
if
(
!
selected
)
{
await
this
.
renderMenu
(
client
);
return
;
}
if
(
selected
.
type
===
'
next
'
||
selected
.
type
===
'
prev
'
)
{
client
.
menuOffset
=
selected
.
offset
;
await
this
.
renderMenu
(
client
);
return
;
}
const
callback
=
selected
.
entry
.
callback
;
this
.
clearMenu
(
client
);
await
callback
(
client
);
}
}
declare
module
'
../client
'
{
interface
Client
{
currentMenu
?:
MenuEntry
[];
menuOffset
?:
number
;
}
}
src/join-handlers/join-blank-pass-menu.ts
View file @
17fa2913
import
{
import
{
YGOProCtosJoinGame
}
from
'
ygopro-msg-encode
'
;
GameMode
,
NetPlayerType
,
YGOProCtosBase
,
YGOProCtosHsToDuelist
,
YGOProCtosJoinGame
,
YGOProCtosKick
,
YGOProStocHsPlayerEnter
,
YGOProStocJoinGame
,
YGOProStocTypeChange
,
}
from
'
ygopro-msg-encode
'
;
import
{
Context
}
from
'
../app
'
;
import
{
Context
}
from
'
../app
'
;
import
{
Chnroute
,
Client
,
I18nService
}
from
'
../client
'
;
import
{
Client
}
from
'
../client
'
;
import
{
Welcome
}
from
'
../feats
'
;
import
{
MenuEntry
,
MenuManager
,
Welcome
}
from
'
../feats
'
;
import
{
DefaultHostinfo
}
from
'
../room
'
;
import
{
resolvePanelPageLayout
}
from
'
../utility
'
;
interface
Panel
MenuNode
{
interface
MenuNode
{
[
key
:
string
]:
string
|
Panel
MenuNode
;
[
key
:
string
]:
string
|
MenuNode
;
}
}
type
PanelMenuAction
=
|
{
type
:
'
entry
'
;
rawLabel
:
string
;
value
:
string
|
PanelMenuNode
;
}
|
{
type
:
'
next
'
;
rawLabel
:
string
;
offset
:
number
;
}
|
{
type
:
'
prev
'
;
rawLabel
:
string
;
offset
:
number
;
};
type
PanelView
=
{
actions
:
PanelMenuAction
[];
mode
:
GameMode
;
slotCount
:
number
;
};
export
class
JoinBlankPassMenu
{
export
class
JoinBlankPassMenu
{
private
logger
=
this
.
ctx
.
createLogger
(
this
.
constructor
.
name
);
private
logger
=
this
.
ctx
.
createLogger
(
this
.
constructor
.
name
);
private
i18n
=
this
.
ctx
.
get
(()
=>
I18nService
);
private
chnroute
=
this
.
ctx
.
get
(()
=>
Chnroute
);
private
welcome
=
this
.
ctx
.
get
(()
=>
Welcome
);
private
welcome
=
this
.
ctx
.
get
(()
=>
Welcome
);
private
menuManager
=
this
.
ctx
.
get
(()
=>
MenuManager
);
private
enabled
=
this
.
ctx
.
config
.
getBoolean
(
'
ENABLE_MENU
'
);
private
enabled
=
this
.
ctx
.
config
.
getBoolean
(
'
ENABLE_MENU
'
);
private
rootMenu
=
this
.
loadRootMenu
();
private
rootMenu
=
this
.
loadRootMenu
();
...
@@ -59,60 +23,23 @@ export class JoinBlankPassMenu {
...
@@ -59,60 +23,23 @@ export class JoinBlankPassMenu {
return
;
return
;
}
}
this
.
ctx
.
middleware
(
YGOProCtosBase
,
async
(
msg
,
client
,
next
)
=>
{
const
bypassEstablished
=
msg
instanceof
YGOProCtosJoinGame
&&
msg
.
bypassEstablished
;
if
(
!
client
.
isInPanel
)
{
return
next
();
}
if
(
bypassEstablished
)
{
return
next
();
}
if
(
msg
instanceof
YGOProCtosHsToDuelist
||
msg
instanceof
YGOProCtosKick
)
{
return
next
();
}
return
undefined
;
},
true
,
);
this
.
ctx
.
middleware
(
YGOProCtosJoinGame
,
async
(
msg
,
client
,
next
)
=>
{
this
.
ctx
.
middleware
(
YGOProCtosJoinGame
,
async
(
msg
,
client
,
next
)
=>
{
msg
.
pass
=
(
msg
.
pass
||
''
).
trim
();
msg
.
pass
=
(
msg
.
pass
||
''
).
trim
();
if
(
msg
.
pass
)
{
if
(
msg
.
pass
)
{
if
(
client
.
isInPanel
)
{
this
.
clearMenuContext
(
client
);
this
.
exitPanel
(
client
);
}
return
next
();
return
next
();
}
}
if
(
client
.
isInPanel
)
{
if
(
client
.
menuDispatchingJoin
)
{
this
.
exitPanel
(
client
);
this
.
clearMenuContext
(
client
);
return
next
();
return
next
();
}
}
this
.
enter
Panel
(
client
,
msg
);
this
.
enter
MenuContext
(
client
,
msg
);
await
this
.
welcome
.
sendConfigWelcome
(
client
);
await
this
.
welcome
.
sendConfigWelcome
(
client
);
await
this
.
renderPanel
(
client
);
await
this
.
openMenuByPath
(
client
,
client
.
menuPath
||
[]
);
return
msg
;
return
msg
;
});
});
this
.
ctx
.
middleware
(
YGOProCtosHsToDuelist
,
async
(
_msg
,
client
,
next
)
=>
{
if
(
!
client
.
isInPanel
)
{
return
next
();
}
await
this
.
renderPanel
(
client
);
return
_msg
;
});
this
.
ctx
.
middleware
(
YGOProCtosKick
,
async
(
msg
,
client
,
next
)
=>
{
if
(
!
client
.
isInPanel
)
{
return
next
();
}
await
this
.
handlePanelKick
(
client
,
Number
(
msg
.
pos
));
return
undefined
;
});
}
}
private
loadRootMenu
()
{
private
loadRootMenu
()
{
...
@@ -132,11 +59,11 @@ export class JoinBlankPassMenu {
...
@@ -132,11 +59,11 @@ export class JoinBlankPassMenu {
}
}
}
}
private
parseMenuNode
(
value
:
unknown
,
path
:
string
):
Panel
MenuNode
{
private
parseMenuNode
(
value
:
unknown
,
path
:
string
):
MenuNode
{
if
(
!
value
||
typeof
value
!==
'
object
'
||
Array
.
isArray
(
value
))
{
if
(
!
value
||
typeof
value
!==
'
object
'
||
Array
.
isArray
(
value
))
{
throw
new
Error
(
`
${
path
}
must be a JSON object`
);
throw
new
Error
(
`
${
path
}
must be a JSON object`
);
}
}
const
parsed
:
Panel
MenuNode
=
{};
const
parsed
:
MenuNode
=
{};
for
(
const
[
label
,
entryValue
]
of
Object
.
entries
(
for
(
const
[
label
,
entryValue
]
of
Object
.
entries
(
value
as
Record
<
string
,
unknown
>
,
value
as
Record
<
string
,
unknown
>
,
))
{
))
{
...
@@ -157,28 +84,24 @@ export class JoinBlankPassMenu {
...
@@ -157,28 +84,24 @@ export class JoinBlankPassMenu {
return
parsed
;
return
parsed
;
}
}
private
enterPanel
(
client
:
Client
,
msg
:
YGOProCtosJoinGame
)
{
private
enterMenuContext
(
client
:
Client
,
msg
:
YGOProCtosJoinGame
)
{
client
.
isInPanel
=
true
;
client
.
menuPath
=
[];
client
.
panelMenuPath
=
[];
client
.
menuJoinVersion
=
msg
.
version
;
client
.
panelOffset
=
0
;
client
.
menuJoinGameId
=
msg
.
gameid
;
client
.
panelJoinVersion
=
msg
.
version
;
client
.
panelJoinGameId
=
msg
.
gameid
;
}
}
private
exitPanel
(
client
:
Client
)
{
private
clearMenuContext
(
client
:
Client
)
{
client
.
isInPanel
=
false
;
client
.
menuPath
=
undefined
;
client
.
panelMenuPath
=
undefined
;
client
.
menuJoinVersion
=
undefined
;
client
.
panelOffset
=
undefined
;
client
.
menuJoinGameId
=
undefined
;
client
.
panelJoinVersion
=
undefined
;
client
.
menuDispatchingJoin
=
undefined
;
client
.
panelJoinGameId
=
undefined
;
}
}
private
resolve
CurrentMenu
(
client
:
Client
)
{
private
resolve
MenuNode
(
path
:
string
[]
)
{
if
(
!
this
.
rootMenu
)
{
if
(
!
this
.
rootMenu
)
{
return
undefined
;
return
undefined
;
}
}
let
node
=
this
.
rootMenu
;
let
node
:
MenuNode
=
this
.
rootMenu
;
const
path
=
client
.
panelMenuPath
||
[];
for
(
const
key
of
path
)
{
for
(
const
key
of
path
)
{
const
next
=
node
[
key
];
const
next
=
node
[
key
];
if
(
!
next
||
typeof
next
===
'
string
'
)
{
if
(
!
next
||
typeof
next
===
'
string
'
)
{
...
@@ -189,211 +112,63 @@ export class JoinBlankPassMenu {
...
@@ -189,211 +112,63 @@ export class JoinBlankPassMenu {
return
node
;
return
node
;
}
}
private
ensureCurrentMenu
(
client
:
Client
)
{
private
buildMenuEntries
(
path
:
string
[],
node
:
MenuNode
):
MenuEntry
[]
{
let
menu
=
this
.
resolveCurrentMenu
(
client
);
return
Object
.
entries
(
node
).
map
(([
title
,
value
])
=>
({
if
(
menu
)
{
title
,
return
menu
;
callback
:
async
(
client
)
=>
{
}
if
(
typeof
value
===
'
string
'
)
{
client
.
panelMenuPath
=
[];
await
this
.
dispatchJoinGameFromMenu
(
client
,
value
);
client
.
panelOffset
=
0
;
return
;
menu
=
this
.
resolveCurrentMenu
(
client
);
}
return
menu
;
if
(
!
Object
.
keys
(
value
).
length
)
{
}
await
this
.
returnToPreviousMenu
(
client
,
path
);
return
;
private
buildPanelView
(
client
:
Client
):
PanelView
{
}
const
menu
=
this
.
ensureCurrentMenu
(
client
);
client
.
menuPath
=
[...
path
,
title
];
if
(
!
menu
)
{
client
.
menuOffset
=
0
;
return
{
await
this
.
openMenuByPath
(
client
,
client
.
menuPath
);
actions
:
[],
},
mode
:
GameMode
.
SINGLE
,
slotCount
:
2
,
};
}
const
entries
=
Object
.
entries
(
menu
).
map
(([
rawLabel
,
value
])
=>
({
rawLabel
,
value
,
}));
}));
if
(
entries
.
length
<=
2
)
{
return
{
actions
:
entries
.
map
((
entry
)
=>
({
type
:
'
entry
'
,
rawLabel
:
entry
.
rawLabel
,
value
:
entry
.
value
,
})),
mode
:
GameMode
.
SINGLE
,
slotCount
:
2
,
};
}
if
(
entries
.
length
<=
4
)
{
return
{
actions
:
entries
.
map
((
entry
)
=>
({
type
:
'
entry
'
,
rawLabel
:
entry
.
rawLabel
,
value
:
entry
.
value
,
})),
mode
:
GameMode
.
TAG
,
slotCount
:
4
,
};
}
const
layout
=
resolvePanelPageLayout
(
entries
.
length
,
client
.
panelOffset
||
0
);
client
.
panelOffset
=
layout
.
pageStart
;
const
pageActions
:
PanelMenuAction
[]
=
[];
if
(
layout
.
isFirstPage
)
{
for
(
const
entry
of
entries
.
slice
(
layout
.
pageStart
,
layout
.
pageStart
+
3
))
{
pageActions
.
push
({
type
:
'
entry
'
,
rawLabel
:
entry
.
rawLabel
,
value
:
entry
.
value
,
});
}
pageActions
.
push
({
type
:
'
next
'
,
rawLabel
:
'
#{menu_next_page}
'
,
offset
:
layout
.
pageStarts
[
layout
.
pageIndex
+
1
],
});
}
else
if
(
layout
.
isLastPage
)
{
pageActions
.
push
({
type
:
'
prev
'
,
rawLabel
:
'
#{menu_prev_page}
'
,
offset
:
layout
.
pageStarts
[
layout
.
pageIndex
-
1
],
});
for
(
const
entry
of
entries
.
slice
(
layout
.
pageStart
,
layout
.
pageStart
+
3
))
{
pageActions
.
push
({
type
:
'
entry
'
,
rawLabel
:
entry
.
rawLabel
,
value
:
entry
.
value
,
});
}
}
else
{
pageActions
.
push
({
type
:
'
prev
'
,
rawLabel
:
'
#{menu_prev_page}
'
,
offset
:
layout
.
pageStarts
[
layout
.
pageIndex
-
1
],
});
for
(
const
entry
of
entries
.
slice
(
layout
.
pageStart
,
layout
.
pageStart
+
2
))
{
pageActions
.
push
({
type
:
'
entry
'
,
rawLabel
:
entry
.
rawLabel
,
value
:
entry
.
value
,
});
}
pageActions
.
push
({
type
:
'
next
'
,
rawLabel
:
'
#{menu_next_page}
'
,
offset
:
layout
.
pageStarts
[
layout
.
pageIndex
+
1
],
});
}
return
{
actions
:
pageActions
,
mode
:
GameMode
.
TAG
,
slotCount
:
4
,
};
}
}
private
async
translateLabel
(
client
:
Client
,
label
:
string
)
{
private
async
openMenuByPath
(
client
:
Client
,
path
:
string
[])
{
const
locale
=
this
.
chnroute
.
getLocale
(
client
.
ip
);
const
node
=
this
.
resolveMenuNode
(
path
);
return
String
(
await
this
.
i18n
.
translate
(
locale
,
label
));
if
(
!
node
)
{
}
private
async
renderPanel
(
client
:
Client
)
{
const
view
=
this
.
buildPanelView
(
client
);
if
(
!
view
.
actions
.
length
)
{
client
.
disconnect
();
client
.
disconnect
();
return
;
return
;
}
}
client
.
menuPath
=
[...
path
];
await
client
.
send
(
client
.
menuOffset
=
0
;
new
YGOProStocJoinGame
().
fromPartial
({
const
menu
=
this
.
buildMenuEntries
(
path
,
node
);
info
:
{
await
this
.
menuManager
.
launchMenu
(
client
,
menu
);
...
DefaultHostinfo
,
mode
:
view
.
mode
,
},
}),
);
await
client
.
send
(
new
YGOProStocTypeChange
().
fromPartial
({
type
:
NetPlayerType
.
OBSERVER
|
0x10
,
}),
);
for
(
let
i
=
0
;
i
<
view
.
slotCount
;
i
++
)
{
const
action
=
view
.
actions
[
i
];
const
translated
=
action
?
await
this
.
translateLabel
(
client
,
action
.
rawLabel
)
:
''
;
await
client
.
send
(
new
YGOProStocHsPlayerEnter
().
fromPartial
({
name
:
translated
.
slice
(
0
,
20
),
pos
:
i
,
}),
);
}
}
}
private
async
handlePanelKick
(
client
:
Client
,
index
:
number
)
{
private
async
returnToPreviousMenu
(
client
:
Client
,
currentPath
:
string
[])
{
const
view
=
this
.
buildPanelView
(
client
);
const
selected
=
view
.
actions
[
index
];
if
(
!
selected
)
{
await
this
.
renderPanel
(
client
);
return
;
}
if
(
selected
.
type
===
'
next
'
||
selected
.
type
===
'
prev
'
)
{
client
.
panelOffset
=
selected
.
offset
;
await
this
.
renderPanel
(
client
);
return
;
}
if
(
typeof
selected
.
value
===
'
string
'
)
{
await
this
.
dispatchJoinGameFromPanel
(
client
,
selected
.
value
);
return
;
}
const
nextMenuKeys
=
Object
.
keys
(
selected
.
value
);
if
(
!
nextMenuKeys
.
length
)
{
await
this
.
backFromPanel
(
client
);
return
;
}
client
.
panelMenuPath
=
[...(
client
.
panelMenuPath
||
[]),
selected
.
rawLabel
];
client
.
panelOffset
=
0
;
await
this
.
renderPanel
(
client
);
}
private
async
backFromPanel
(
client
:
Client
)
{
const
currentPath
=
[...(
client
.
panelMenuPath
||
[])];
if
(
!
currentPath
.
length
)
{
if
(
!
currentPath
.
length
)
{
client
.
disconnect
();
client
.
disconnect
();
return
;
return
;
}
}
currentPath
.
pop
();
const
parentPath
=
currentPath
.
slice
(
0
,
-
1
);
client
.
panelMenuPath
=
currentPath
;
await
this
.
openMenuByPath
(
client
,
parentPath
);
client
.
panelOffset
=
0
;
await
this
.
renderPanel
(
client
);
}
}
private
async
dispatchJoinGameFrom
Panel
(
client
:
Client
,
pass
:
string
)
{
private
async
dispatchJoinGameFrom
Menu
(
client
:
Client
,
pass
:
string
)
{
const
joinMsg
=
new
YGOProCtosJoinGame
().
fromPartial
({
const
joinMsg
=
new
YGOProCtosJoinGame
().
fromPartial
({
version
:
client
.
panel
JoinVersion
||
this
.
ctx
.
config
.
getInt
(
'
YGOPRO_VERSION
'
),
version
:
client
.
menu
JoinVersion
||
this
.
ctx
.
config
.
getInt
(
'
YGOPRO_VERSION
'
),
gameid
:
client
.
panel
JoinGameId
||
0
,
gameid
:
client
.
menu
JoinGameId
||
0
,
pass
,
pass
,
});
});
joinMsg
.
bypassEstablished
=
true
;
joinMsg
.
bypassEstablished
=
true
;
client
.
menuDispatchingJoin
=
!
pass
;
await
this
.
ctx
.
dispatch
(
joinMsg
,
client
);
await
this
.
ctx
.
dispatch
(
joinMsg
,
client
);
}
}
}
}
declare
module
'
../client
'
{
declare
module
'
../client
'
{
interface
Client
{
interface
Client
{
isInPanel
?:
boolean
;
menuPath
?:
string
[];
panelMenuPath
?:
string
[];
menuJoinVersion
?:
number
;
panelOffset
?:
number
;
menuJoinGameId
?:
number
;
panelJoinVersion
?:
number
;
menuDispatchingJoin
?:
boolean
;
panelJoinGameId
?:
number
;
}
}
}
}
src/join-handlers/join-handler-module.ts
View file @
17fa2913
import
{
createAppContext
}
from
'
nfkit
'
;
import
{
createAppContext
}
from
'
nfkit
'
;
import
{
ContextState
}
from
'
../app
'
;
import
{
ContextState
}
from
'
../app
'
;
import
{
ClientVersionCheck
}
from
'
../feats
'
;
import
{
ClientVersionCheck
,
MenuManager
}
from
'
../feats
'
;
import
{
JoinWindbotAi
,
JoinWindbotToken
}
from
'
../feats/windbot
'
;
import
{
JoinWindbotAi
,
JoinWindbotToken
}
from
'
../feats/windbot
'
;
import
{
JoinRoom
}
from
'
./join-room
'
;
import
{
JoinRoom
}
from
'
./join-room
'
;
import
{
JoinFallback
}
from
'
./fallback
'
;
import
{
JoinFallback
}
from
'
./fallback
'
;
...
@@ -19,6 +19,7 @@ export const JoinHandlerModule = createAppContext<ContextState>()
...
@@ -19,6 +19,7 @@ export const JoinHandlerModule = createAppContext<ContextState>()
.
provide
(
RandomDuelJoinHandler
)
.
provide
(
RandomDuelJoinHandler
)
.
provide
(
JoinWindbotAi
)
.
provide
(
JoinWindbotAi
)
.
provide
(
JoinRoom
)
.
provide
(
JoinRoom
)
.
provide
(
MenuManager
)
.
provide
(
JoinBlankPassMenu
)
.
provide
(
JoinBlankPassMenu
)
.
provide
(
JoinBlankPassRandomDuel
)
.
provide
(
JoinBlankPassRandomDuel
)
.
provide
(
JoinBlankPassWindbotAi
)
.
provide
(
JoinBlankPassWindbotAi
)
...
...
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