Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
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
fallenstardust
YGOMobile
Commits
d69823b9
Commit
d69823b9
authored
Jul 16, 2021
by
柯南
Committed by
Gitee
Jul 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持argv参数
parent
1b8bb888
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
112 additions
and
43 deletions
+112
-43
Classes/gframe/game.cpp
Classes/gframe/game.cpp
+3
-3
Classes/gframe/game.h
Classes/gframe/game.h
+1
-1
Classes/gframe/gframe.cpp
Classes/gframe/gframe.cpp
+57
-39
libcore/android/android_tools.cpp
libcore/android/android_tools.cpp
+8
-0
libcore/android/android_tools.h
libcore/android/android_tools.h
+12
-0
libcore/src/main/java/cn/garymb/ygomobile/NativeInitOptions.java
.../src/main/java/cn/garymb/ygomobile/NativeInitOptions.java
+9
-0
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
.../src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
+17
-0
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
...rc/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
+5
-0
No files found.
Classes/gframe/game.cpp
View file @
d69823b9
...
...
@@ -39,14 +39,14 @@ void Game::process(irr::SEvent &event) {
}
#ifdef _IRR_ANDROID_PLATFORM_
bool
Game
::
Initialize
(
ANDROID_APP
app
)
{
bool
Game
::
Initialize
(
ANDROID_APP
app
,
android
::
InitOptions
*
options
)
{
this
->
appMain
=
app
;
#endif
srand
(
time
(
0
));
irr
::
SIrrlichtCreationParameters
params
=
irr
::
SIrrlichtCreationParameters
();
#ifdef _IRR_ANDROID_PLATFORM_
android
::
InitOptions
*
options
=
android
::
getInitOptions
(
app
);
glversion
=
options
->
getOpenglVersion
();
if
(
glversion
==
0
)
{
params
.
DriverType
=
irr
::
video
::
EDT_OGLES1
;
...
...
@@ -1186,7 +1186,7 @@ IGUIStaticText *text = env->addStaticText(L"",
#endif
hideChat
=
false
;
hideChatTimer
=
0
;
delete
options
;
return
true
;
}
//bool Game::Initialize
void
Game
::
MainLoop
()
{
...
...
Classes/gframe/game.h
View file @
d69823b9
...
...
@@ -121,7 +121,7 @@ class Game :IProcessEventReceiver{
public:
#ifdef _IRR_ANDROID_PLATFORM_
bool
Initialize
(
ANDROID_APP
app
);
bool
Initialize
(
ANDROID_APP
app
,
android
::
InitOptions
*
options
);
#else
bool
Initialize
();
#endif
...
...
Classes/gframe/gframe.cpp
View file @
d69823b9
...
...
@@ -19,58 +19,76 @@ int main(int argc, char* argv[]) {
ygo
::
Game
_game
;
ygo
::
mainGame
=
&
_game
;
#ifdef _IRR_ANDROID_PLATFORM_
if
(
!
ygo
::
mainGame
->
Initialize
(
app
))
android
::
InitOptions
*
options
=
android
::
getInitOptions
(
app
);
if
(
!
ygo
::
mainGame
->
Initialize
(
app
,
options
)){
delete
options
;
return
;
}
int
argc
=
options
->
getArgc
();
irr
::
io
::
path
*
argv
=
options
->
getArgv
();
#endif
#ifndef _IRR_ANDROID_PLATFORM_
for
(
int
i
=
1
;
i
<
argc
;
++
i
)
{
/*command line args:
/*command line args:
* -j: join host (host info from system.conf)
* -d: deck edit
* -r: replay */
if
(
argv
[
i
][
0
]
==
'-'
&&
argv
[
i
][
1
]
==
'e'
)
{
* -r: replay
*/
#ifdef _IRR_ANDROID_PLATFORM_
wchar_t
fname
[
260
];
MultiByteToWideChar
(
CP_ACP
,
0
,
&
argv
[
i
][
2
],
-
1
,
fname
,
260
);
char
fname2
[
260
];
BufferIO
::
EncodeUTF8
(
fname
,
fname2
);
if
(
ygo
::
dataManager
.
LoadDB
(
fname2
)){
os
::
Printer
::
log
(
"add cdb ok "
,
fname2
);
}
else
{
os
::
Printer
::
log
(
"add cdb fail "
,
fname2
);
}
//android
for
(
int
i
=
0
;
i
<
argc
;
++
i
)
{
char
*
arg
=
argv
[
i
].
c_str
();
#else
ygo
::
dataManager
.
LoadDB
(
&
argv
[
i
][
2
]);
//pc的第一个是exe的路径
for
(
int
i
=
1
;
i
<
argc
;
++
i
)
{
char
*
arg
=
argv
[
i
];
#endif
}
else
if
(
!
strcmp
(
argv
[
i
],
"-j"
)
||
!
strcmp
(
argv
[
i
],
"-d"
)
||
!
strcmp
(
argv
[
i
],
"-r"
)
||
!
strcmp
(
argv
[
i
],
"-s"
))
{
if
(
arg
[
0
]
==
'-'
&&
arg
[
1
]
==
'e'
)
{
ygo
::
dataManager
.
LoadDB
(
&
arg
[
2
]);
}
else
if
(
!
strcmp
(
arg
,
"-j"
)
||
!
strcmp
(
arg
,
"-d"
)
||
!
strcmp
(
arg
,
"-r"
)
||
!
strcmp
(
arg
,
"-s"
))
{
exit_on_return
=
true
;
irr
::
SEvent
event
;
event
.
EventType
=
irr
::
EET_GUI_EVENT
;
event
.
GUIEvent
.
EventType
=
irr
::
gui
::
EGET_BUTTON_CLICKED
;
}
else
if
(
!
strcmp
(
arg
v
[
i
]
,
"-c"
))
{
// Create host
}
else
if
(
!
strcmp
(
arg
,
"-c"
))
{
// Create host
ygo
::
mainGame
->
HideElement
(
ygo
::
mainGame
->
wMainMenu
);
event
.
GUIEvent
.
Caller
=
ygo
::
mainGame
->
btnJoinHost
;
ygo
::
mainGame
->
device
->
postEventFromUser
(
event
);
}
else
if
(
!
strcmp
(
argv
[
i
],
"-j"
))
{
// Join host
break
;
}
else
if
(
!
strcmp
(
arg
,
"-j"
))
{
// Join host
event
.
GUIEvent
.
Caller
=
ygo
::
mainGame
->
btnJoinHost
;
ygo
::
mainGame
->
HideElement
(
ygo
::
mainGame
->
wMainMenu
);
ygo
::
mainGame
->
device
->
postEventFromUser
(
event
);
}
else
if
(
!
strcmp
(
argv
[
i
],
"-r"
))
{
// Replay
break
;
}
else
if
(
!
strcmp
(
arg
,
"-r"
))
{
// Replay
char
*
name
=
NULL
;
if
((
i
+
1
)
<
argc
){
//下一个参数是录像名
#ifdef _IRR_ANDROID_PLATFORM_
name
=
argv
[
i
+
1
].
c_str
();
#else
name
=
argv
[
i
+
1
];
#endif
}
event
.
GUIEvent
.
Caller
=
ygo
::
mainGame
->
btnReplayMode
;
ygo
::
mainGame
->
device
->
postEventFromUser
(
event
);
if
(
name
!=
NULL
){
//TODO may be error?
ygo
::
mainGame
->
lstReplayList
->
setSelected
(
name
);
}
else
{
ygo
::
mainGame
->
lstReplayList
->
setSelected
(
0
);
}
event
.
GUIEvent
.
Caller
=
ygo
::
mainGame
->
btnLoadReplay
;
ygo
::
mainGame
->
device
->
postEventFromUser
(
event
);
}
else
if
(
!
strcmp
(
argv
[
i
],
"-s"
))
{
// Single
break
;
//只播放一个
}
else
if
(
!
strcmp
(
arg
,
"-s"
))
{
// Single
event
.
GUIEvent
.
Caller
=
ygo
::
mainGame
->
btnSingleMode
;
ygo
::
mainGame
->
device
->
postEventFromUser
(
event
);
ygo
::
mainGame
->
lstSinglePlayList
->
setSelected
(
0
);
event
.
GUIEvent
.
Caller
=
ygo
::
mainGame
->
btnLoadSinglePlay
;
ygo
::
mainGame
->
device
->
postEventFromUser
(
event
);
}
break
;
}
}
#ifdef _IRR_ANDROID_PLATFORM_
delete
options
;
#endif
ygo
::
mainGame
->
externalSignal
.
Set
();
ygo
::
mainGame
->
externalSignal
.
SetNoWait
(
true
);
...
...
libcore/android/android_tools.cpp
View file @
d69823b9
...
...
@@ -47,6 +47,14 @@ InitOptions::InitOptions(void*data) :
ReadString
(
tmp_path
,
rawdata
);
m_archive_files
[
i
]
=
tmp_path
;
}
//argv
m_argc
=
BufferIO
::
ReadInt32
(
rawdata
);
m_argv
=
new
io
::
path
[
m_argc
];
for
(
int
i
=
0
;
i
<
m_argc
;
i
++
){
io
::
path
tmp_path
;
ReadString
(
tmp_path
,
rawdata
);
m_argv
[
i
]
=
tmp_path
;
}
}
}
...
...
libcore/android/android_tools.h
View file @
d69823b9
...
...
@@ -27,6 +27,12 @@ public:
inline
irr
::
io
::
path
*
getArchiveFiles
()
{
return
m_archive_files
;
}
inline
int
getArgc
()
{
return
m_argc
;
}
inline
irr
::
io
::
path
*
getArgv
()
{
return
m_argv
;
}
inline
int
getDbCount
()
{
return
cdb_count
;
}
...
...
@@ -55,11 +61,17 @@ public:
delete
[]
m_archive_files
;
}
m_archive_files
=
NULL
;
if
(
m_argv
!=
NULL
){
delete
[]
m_argv
;
}
m_argv
=
NULL
;
}
private:
irr
::
io
::
path
m_work_dir
;
irr
::
io
::
path
*
m_db_files
;
irr
::
io
::
path
*
m_archive_files
;
irr
::
io
::
path
*
m_argv
;
int
m_argc
;
int
m_opengles_version
;
int
m_card_quality
;
int
cdb_count
;
...
...
libcore/src/main/java/cn/garymb/ygomobile/NativeInitOptions.java
View file @
d69823b9
...
...
@@ -21,6 +21,9 @@ public final class NativeInitOptions {
//pics.zip;scripts.zip;a.zip;b.zip
public
final
List
<
String
>
mArchiveList
;
//int main(int argc, char*[] argv)
public
final
List
<
String
>
mArgvList
;
public
int
mCardQuality
;
public
boolean
mIsFontAntiAliasEnabled
;
...
...
@@ -30,6 +33,7 @@ public final class NativeInitOptions {
public
NativeInitOptions
()
{
mDbList
=
new
ArrayList
<>();
mArchiveList
=
new
ArrayList
<>();
mArgvList
=
new
ArrayList
<>();
}
public
ByteBuffer
toNativeBuffer
()
{
...
...
@@ -48,6 +52,10 @@ public final class NativeInitOptions {
for
(
String
str
:
mArchiveList
)
{
putString
(
buffer
,
str
);
}
putInt
(
buffer
,
mArgvList
.
size
());
for
(
String
str
:
mArgvList
)
{
putString
(
buffer
,
str
);
}
return
buffer
;
}
...
...
@@ -59,6 +67,7 @@ public final class NativeInitOptions {
", mDbList='"
+
mDbList
+
'\''
+
", mArchiveList='"
+
mArchiveList
+
'\''
+
", mCardQuality="
+
mCardQuality
+
", mArgvList='"
+
mArgvList
+
'\''
+
", mIsFontAntiAliasEnabled="
+
mIsFontAntiAliasEnabled
+
", mIsPendulumScaleEnabled="
+
mIsPendulumScaleEnabled
+
'}'
;
...
...
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
View file @
d69823b9
...
...
@@ -85,6 +85,7 @@ public class YGOMobileActivity extends NativeActivity implements
private
SurfaceView
mSurfaceView
;
private
boolean
replaced
=
false
;
private
static
boolean
USE_SURFACE
=
true
;
private
String
[]
mArgV
;
// public static int notchHeight;
...
...
@@ -196,6 +197,9 @@ public class YGOMobileActivity extends NativeActivity implements
}
private
void
handleExternalCommand
(
Intent
intent
)
{
//argv
mArgV
=
intent
.
getStringArrayExtra
(
IrrlichtBridge
.
EXTRA_ARGV
);
//
YGOGameOptions
options
=
intent
.
getParcelableExtra
(
YGOGameOptions
.
YGO_GAME_OPTIONS_BUNDLE_KEY
);
long
time
=
intent
.
getLongExtra
(
YGOGameOptions
.
YGO_GAME_OPTIONS_BUNDLE_TIME
,
0
);
...
...
@@ -513,4 +517,17 @@ public class YGOMobileActivity extends NativeActivity implements
}
super
.
surfaceRedrawNeeded
(
holder
);
}
@Override
public
int
getArgc
(){
return
mArgV
==
null
?
0
:
mArgV
.
length
;
}
@Override
public
String
getArgv
(
int
index
){
if
(
index
>=
0
&&
mArgV
!=
null
&&
index
<
mArgV
.
length
){
return
mArgV
[
index
];
}
return
null
;
}
}
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
View file @
d69823b9
...
...
@@ -26,6 +26,7 @@ public final class IrrlichtBridge {
public
static
final
String
ACTION_START
=
"cn.garymb.ygomobile.game.start"
;
public
static
final
String
ACTION_STOP
=
"cn.garymb.ygomobile.game.stop"
;
public
static
final
String
EXTRA_PID
=
"extras.mypid"
;
public
static
final
String
EXTRA_ARGV
=
"extras.argv"
;
public
static
int
gPid
;
static
{
try
{
...
...
@@ -210,5 +211,9 @@ public final class IrrlichtBridge {
int
getPositionX
();
int
getPositionY
();
int
getArgc
();
String
getArgv
(
int
index
);
}
}
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