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
d69b698e
Commit
d69b698e
authored
Jul 21, 2021
by
kenan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
游戏结束杀死自己进程
parent
fe5870f0
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
81 additions
and
54 deletions
+81
-54
Classes/gframe/deck_con.cpp
Classes/gframe/deck_con.cpp
+1
-1
Classes/gframe/duelclient.cpp
Classes/gframe/duelclient.cpp
+2
-2
Classes/gframe/event_handler.cpp
Classes/gframe/event_handler.cpp
+1
-1
Classes/gframe/game.cpp
Classes/gframe/game.cpp
+4
-11
Classes/gframe/game.h
Classes/gframe/game.h
+2
-1
Classes/gframe/gframe.cpp
Classes/gframe/gframe.cpp
+1
-1
Classes/gframe/menu_handler.cpp
Classes/gframe/menu_handler.cpp
+3
-3
Classes/gframe/replay_mode.cpp
Classes/gframe/replay_mode.cpp
+1
-1
Classes/gframe/single_mode.cpp
Classes/gframe/single_mode.cpp
+1
-1
irrlicht/source/Irrlicht/Android/CIrrDeviceAndroid.cpp
irrlicht/source/Irrlicht/Android/CIrrDeviceAndroid.cpp
+0
-15
irrlicht/source/Irrlicht/Android/CIrrDeviceAndroid.h
irrlicht/source/Irrlicht/Android/CIrrDeviceAndroid.h
+0
-8
libcore/android/android_tools.cpp
libcore/android/android_tools.cpp
+14
-0
libcore/android/android_tools.h
libcore/android/android_tools.h
+2
-0
libcore/src/main/AndroidManifest.xml
libcore/src/main/AndroidManifest.xml
+1
-1
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
.../src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
+7
-0
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
...rc/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
+2
-0
mobile/build.gradle
mobile/build.gradle
+4
-1
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
+9
-3
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
+9
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
+3
-3
mobile/src/main/java/cn/garymb/ygomobile/ui/home/MainActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/MainActivity.java
+1
-1
mobile/src/main/java/cn/garymb/ygomobile/utils/ComponentUtils.java
...c/main/java/cn/garymb/ygomobile/utils/ComponentUtils.java
+13
-0
No files found.
Classes/gframe/deck_con.cpp
View file @
d69b698e
...
@@ -132,7 +132,7 @@ void DeckBuilder::Terminate() {
...
@@ -132,7 +132,7 @@ void DeckBuilder::Terminate() {
//os::Printer::log("setLastDeck", linebuf);
//os::Printer::log("setLastDeck", linebuf);
mainGame
->
SaveConfig
();
mainGame
->
SaveConfig
();
if
(
exit_on_return
)
if
(
exit_on_return
)
mainGame
->
device
->
closeDevic
e
();
mainGame
->
OnGameClos
e
();
}
}
bool
DeckBuilder
::
OnEvent
(
const
irr
::
SEvent
&
event
)
{
bool
DeckBuilder
::
OnEvent
(
const
irr
::
SEvent
&
event
)
{
#ifdef _IRR_ANDROID_PLATFORM_
#ifdef _IRR_ANDROID_PLATFORM_
...
...
Classes/gframe/duelclient.cpp
View file @
d69b698e
...
@@ -679,7 +679,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
...
@@ -679,7 +679,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame
->
SaveConfig
();
mainGame
->
SaveConfig
();
event_base_loopbreak
(
client_base
);
event_base_loopbreak
(
client_base
);
if
(
exit_on_return
)
if
(
exit_on_return
)
mainGame
->
device
->
closeDevic
e
();
mainGame
->
OnGameClos
e
();
break
;
break
;
}
}
case
STOC_REPLAY
:
{
case
STOC_REPLAY
:
{
...
@@ -980,7 +980,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
...
@@ -980,7 +980,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame
->
gMutex
.
unlock
();
mainGame
->
gMutex
.
unlock
();
event_base_loopbreak
(
client_base
);
event_base_loopbreak
(
client_base
);
if
(
exit_on_return
)
if
(
exit_on_return
)
mainGame
->
device
->
closeDevic
e
();
mainGame
->
OnGameClos
e
();
}
}
return
false
;
return
false
;
}
}
...
...
Classes/gframe/event_handler.cpp
View file @
d69b698e
...
@@ -145,7 +145,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
...
@@ -145,7 +145,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
else
else
mainGame
->
ShowElement
(
mainGame
->
wLanWindow
);
mainGame
->
ShowElement
(
mainGame
->
wLanWindow
);
if
(
exit_on_return
)
if
(
exit_on_return
)
mainGame
->
device
->
closeDevic
e
();
mainGame
->
OnGameClos
e
();
}
else
{
}
else
{
mainGame
->
PopupElement
(
mainGame
->
wSurrender
);
mainGame
->
PopupElement
(
mainGame
->
wSurrender
);
}
}
...
...
Classes/gframe/game.cpp
View file @
d69b698e
...
@@ -39,15 +39,6 @@ void Game::process(irr::SEvent &event) {
...
@@ -39,15 +39,6 @@ void Game::process(irr::SEvent &event) {
}
}
#ifdef _IRR_ANDROID_PLATFORM_
#ifdef _IRR_ANDROID_PLATFORM_
void
onActivityLifeChanged
(
struct
android_app
*
app
,
int32_t
status
){
//status ==
//ANDROID_ACTIVITY_RESUME 1
//ANDROID_ACTIVITY_STOP 2
// ANDROID_ACTIVITY_PAUSE 5
//ANDROID_ACTIVITY_DESTROY 3
//ANDROID_ACTIVITY_FOCUS 4
}
bool
Game
::
Initialize
(
ANDROID_APP
app
,
android
::
InitOptions
*
options
)
{
bool
Game
::
Initialize
(
ANDROID_APP
app
,
android
::
InitOptions
*
options
)
{
this
->
appMain
=
app
;
this
->
appMain
=
app
;
#endif
#endif
...
@@ -81,8 +72,6 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
...
@@ -81,8 +72,6 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
device
->
setProcessReceiver
(
this
);
device
->
setProcessReceiver
(
this
);
app
->
onInputEvent
=
android
::
handleInput
;
app
->
onInputEvent
=
android
::
handleInput
;
((
CIrrDeviceAndroid
*
)
device
)
->
onActivityLifeChanged
=
onActivityLifeChanged
;
ILogger
*
logger
=
device
->
getLogger
();
ILogger
*
logger
=
device
->
getLogger
();
// logger->setLogLevel(ELL_WARNING);
// logger->setLogLevel(ELL_WARNING);
isPSEnabled
=
options
->
isPendulumScaleEnabled
();
isPSEnabled
=
options
->
isPendulumScaleEnabled
();
...
@@ -2028,4 +2017,8 @@ void Game::ChangeToIGUIImageButton(irr::gui::IGUIButton* button, irr::video::ITe
...
@@ -2028,4 +2017,8 @@ void Game::ChangeToIGUIImageButton(irr::gui::IGUIButton* button, irr::video::ITe
button
->
setOverrideFont
(
font
);
button
->
setOverrideFont
(
font
);
}
}
void
Game
::
OnGameClose
()
{
android
::
onGameExit
(
appMain
);
this
->
device
->
closeDevice
();
}
}
}
\ No newline at end of file
Classes/gframe/game.h
View file @
d69b698e
...
@@ -167,11 +167,12 @@ public:
...
@@ -167,11 +167,12 @@ public:
void
AddDebugMsg
(
const
char
*
msgbuf
);
void
AddDebugMsg
(
const
char
*
msgbuf
);
void
ErrorLog
(
const
char
*
msgbuf
);
void
ErrorLog
(
const
char
*
msgbuf
);
void
addMessageBox
(
const
wchar_t
*
caption
,
const
wchar_t
*
text
);
void
addMessageBox
(
const
wchar_t
*
caption
,
const
wchar_t
*
text
);
void
initUtils
()
;
void
initUtils
()
{}
void
ClearTextures
();
void
ClearTextures
();
void
CloseGameButtons
();
void
CloseGameButtons
();
void
CloseGameWindow
();
void
CloseGameWindow
();
void
CloseDuelWindow
();
void
CloseDuelWindow
();
void
OnGameClose
();
void
ChangeToIGUIImageWindow
(
irr
::
gui
::
IGUIWindow
*
window
,
irr
::
gui
::
IGUIImage
*
bgwindow
,
irr
::
video
::
ITexture
*
image
);
void
ChangeToIGUIImageWindow
(
irr
::
gui
::
IGUIWindow
*
window
,
irr
::
gui
::
IGUIImage
*
bgwindow
,
irr
::
video
::
ITexture
*
image
);
void
ChangeToIGUIImageButton
(
irr
::
gui
::
IGUIButton
*
button
,
irr
::
video
::
ITexture
*
image
,
irr
::
video
::
ITexture
*
pressedImage
,
irr
::
gui
::
CGUITTFont
*
font
=
0
);
void
ChangeToIGUIImageButton
(
irr
::
gui
::
IGUIButton
*
button
,
irr
::
video
::
ITexture
*
image
,
irr
::
video
::
ITexture
*
pressedImage
,
irr
::
gui
::
CGUITTFont
*
font
=
0
);
...
...
Classes/gframe/gframe.cpp
View file @
d69b698e
...
@@ -65,6 +65,7 @@ int main(int argc, char* argv[]) {
...
@@ -65,6 +65,7 @@ int main(int argc, char* argv[]) {
bool
keep_on_return
=
false
;
bool
keep_on_return
=
false
;
bool
open_file
=
false
;
bool
open_file
=
false
;
#ifdef _IRR_ANDROID_PLATFORM_
#ifdef _IRR_ANDROID_PLATFORM_
__android_log_print
(
ANDROID_LOG_WARN
,
"ygo"
,
"handle args %d"
,
argc
);
//android
//android
for
(
int
i
=
0
;
i
<
argc
;
++
i
)
{
for
(
int
i
=
0
;
i
<
argc
;
++
i
)
{
const
char
*
arg
=
argv
[
i
].
c_str
();
const
char
*
arg
=
argv
[
i
].
c_str
();
...
@@ -77,7 +78,6 @@ int main(int argc, char* argv[]) {
...
@@ -77,7 +78,6 @@ int main(int argc, char* argv[]) {
wchar_t
fname
[
1024
];
wchar_t
fname
[
1024
];
char
*
tmp
=
sub_string
(
arg
,
2
);
char
*
tmp
=
sub_string
(
arg
,
2
);
BufferIO
::
DecodeUTF8
(
tmp
,
fname
);
BufferIO
::
DecodeUTF8
(
tmp
,
fname
);
__android_log_print
(
ANDROID_LOG_DEBUG
,
"ygo"
,
"load cdb=%s"
,
tmp
);
ygo
::
dataManager
.
LoadDB
(
fname
);
ygo
::
dataManager
.
LoadDB
(
fname
);
delete
tmp
;
delete
tmp
;
}
else
if
(
!
strcmp
(
arg
,
"-k"
))
{
// Keep on return
}
else
if
(
!
strcmp
(
arg
,
"-k"
))
{
// Keep on return
...
...
Classes/gframe/menu_handler.cpp
View file @
d69b698e
...
@@ -63,7 +63,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -63,7 +63,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
case
BUTTON_MODE_EXIT
:
{
case
BUTTON_MODE_EXIT
:
{
mainGame
->
soundManager
->
StopBGM
();
mainGame
->
soundManager
->
StopBGM
();
mainGame
->
SaveConfig
();
mainGame
->
SaveConfig
();
mainGame
->
device
->
closeDevic
e
();
mainGame
->
OnGameClos
e
();
break
;
break
;
}
}
case
BUTTON_LAN_MODE
:
{
case
BUTTON_LAN_MODE
:
{
...
@@ -121,7 +121,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -121,7 +121,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame
->
HideElement
(
mainGame
->
wLanWindow
);
mainGame
->
HideElement
(
mainGame
->
wLanWindow
);
mainGame
->
ShowElement
(
mainGame
->
wMainMenu
);
mainGame
->
ShowElement
(
mainGame
->
wMainMenu
);
if
(
exit_on_return
)
if
(
exit_on_return
)
mainGame
->
device
->
closeDevic
e
();
mainGame
->
OnGameClos
e
();
break
;
break
;
}
}
case
BUTTON_LAN_REFRESH
:
{
case
BUTTON_LAN_REFRESH
:
{
...
@@ -214,7 +214,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -214,7 +214,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame
->
wChat
->
setVisible
(
false
);
mainGame
->
wChat
->
setVisible
(
false
);
mainGame
->
SaveConfig
();
mainGame
->
SaveConfig
();
if
(
exit_on_return
)
if
(
exit_on_return
)
mainGame
->
device
->
closeDevic
e
();
mainGame
->
OnGameClos
e
();
break
;
break
;
}
}
case
BUTTON_REPLAY_MODE
:
{
case
BUTTON_REPLAY_MODE
:
{
...
...
Classes/gframe/replay_mode.cpp
View file @
d69b698e
...
@@ -249,7 +249,7 @@ void ReplayMode::EndDuel() {
...
@@ -249,7 +249,7 @@ void ReplayMode::EndDuel() {
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
menuHandler
);
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
menuHandler
);
mainGame
->
gMutex
.
unlock
();
mainGame
->
gMutex
.
unlock
();
if
(
exit_on_return
)
if
(
exit_on_return
)
mainGame
->
device
->
closeDevic
e
();
mainGame
->
OnGameClos
e
();
}
}
}
}
void
ReplayMode
::
Restart
(
bool
refresh
)
{
void
ReplayMode
::
Restart
(
bool
refresh
)
{
...
...
Classes/gframe/single_mode.cpp
View file @
d69b698e
...
@@ -154,7 +154,7 @@ int SingleMode::SinglePlayThread() {
...
@@ -154,7 +154,7 @@ int SingleMode::SinglePlayThread() {
mainGame
->
gMutex
.
unlock
();
mainGame
->
gMutex
.
unlock
();
mainGame
->
SaveConfig
();
mainGame
->
SaveConfig
();
if
(
exit_on_return
)
if
(
exit_on_return
)
mainGame
->
device
->
closeDevic
e
();
mainGame
->
OnGameClos
e
();
}
}
return
0
;
return
0
;
}
}
...
...
irrlicht/source/Irrlicht/Android/CIrrDeviceAndroid.cpp
View file @
d69b698e
...
@@ -279,36 +279,21 @@ void CIrrDeviceAndroid::handleAndroidCommand(ANDROID_APP app, int32_t cmd)
...
@@ -279,36 +279,21 @@ void CIrrDeviceAndroid::handleAndroidCommand(ANDROID_APP app, int32_t cmd)
case
APP_CMD_LOST_FOCUS
:
case
APP_CMD_LOST_FOCUS
:
os
::
Printer
::
log
(
"Android command APP_CMD_LOST_FOCUS"
,
ELL_DEBUG
);
os
::
Printer
::
log
(
"Android command APP_CMD_LOST_FOCUS"
,
ELL_DEBUG
);
device
->
Focused
=
false
;
device
->
Focused
=
false
;
if
(
device
->
onActivityLifeChanged
!=
nullptr
){
device
->
onActivityLifeChanged
(
app
,
ANDROID_ACTIVITY_FOCUS
);
}
break
;
break
;
case
APP_CMD_DESTROY
:
case
APP_CMD_DESTROY
:
os
::
Printer
::
log
(
"Android command APP_CMD_DESTROY"
,
ELL_DEBUG
);
os
::
Printer
::
log
(
"Android command APP_CMD_DESTROY"
,
ELL_DEBUG
);
device
->
Initialized
=
false
;
device
->
Initialized
=
false
;
if
(
device
->
onActivityLifeChanged
!=
nullptr
){
device
->
onActivityLifeChanged
(
app
,
ANDROID_ACTIVITY_DESTROY
);
}
break
;
break
;
case
APP_CMD_PAUSE
:
case
APP_CMD_PAUSE
:
os
::
Printer
::
log
(
"Android command APP_CMD_PAUSE"
,
ELL_DEBUG
);
os
::
Printer
::
log
(
"Android command APP_CMD_PAUSE"
,
ELL_DEBUG
);
device
->
Paused
=
true
;
device
->
Paused
=
true
;
if
(
device
->
onActivityLifeChanged
!=
nullptr
){
device
->
onActivityLifeChanged
(
app
,
ANDROID_ACTIVITY_PAUSE
);
}
break
;
break
;
case
APP_CMD_STOP
:
case
APP_CMD_STOP
:
os
::
Printer
::
log
(
"Android command APP_CMD_STOP"
,
ELL_DEBUG
);
os
::
Printer
::
log
(
"Android command APP_CMD_STOP"
,
ELL_DEBUG
);
if
(
device
->
onActivityLifeChanged
!=
nullptr
){
device
->
onActivityLifeChanged
(
app
,
ANDROID_ACTIVITY_STOP
);
}
break
;
break
;
case
APP_CMD_RESUME
:
case
APP_CMD_RESUME
:
os
::
Printer
::
log
(
"Android command APP_CMD_RESUME"
,
ELL_DEBUG
);
os
::
Printer
::
log
(
"Android command APP_CMD_RESUME"
,
ELL_DEBUG
);
device
->
Paused
=
false
;
device
->
Paused
=
false
;
if
(
device
->
onActivityLifeChanged
!=
nullptr
){
device
->
onActivityLifeChanged
(
app
,
ANDROID_ACTIVITY_RESUME
);
}
break
;
break
;
case
APP_CMD_WINDOW_RESIZED
:
case
APP_CMD_WINDOW_RESIZED
:
os
::
Printer
::
log
(
"Android command APP_CMD_WINDOW_RESIZED"
,
ELL_DEBUG
);
os
::
Printer
::
log
(
"Android command APP_CMD_WINDOW_RESIZED"
,
ELL_DEBUG
);
...
...
irrlicht/source/Irrlicht/Android/CIrrDeviceAndroid.h
View file @
d69b698e
...
@@ -17,12 +17,6 @@
...
@@ -17,12 +17,6 @@
#include <android/sensor.h>
#include <android/sensor.h>
#include <android_native_app_glue.h>
#include <android_native_app_glue.h>
#define ANDROID_ACTIVITY_RESUME 1
#define ANDROID_ACTIVITY_STOP 2
#define ANDROID_ACTIVITY_PAUSE 5
#define ANDROID_ACTIVITY_DESTROY 3
#define ANDROID_ACTIVITY_FOCUS 4
namespace
irr
namespace
irr
{
{
class
CIrrDeviceAndroid
:
public
CIrrDeviceStub
,
video
::
IImagePresenter
class
CIrrDeviceAndroid
:
public
CIrrDeviceStub
,
video
::
IImagePresenter
...
@@ -58,8 +52,6 @@ namespace irr
...
@@ -58,8 +52,6 @@ namespace irr
virtual
void
restoreWindow
();
virtual
void
restoreWindow
();
void
(
*
onActivityLifeChanged
)(
struct
android_app
*
app
,
int32_t
status
);
virtual
core
::
position2di
getWindowPosition
();
virtual
core
::
position2di
getWindowPosition
();
virtual
E_DEVICE_TYPE
getType
()
const
;
virtual
E_DEVICE_TYPE
getType
()
const
;
...
...
libcore/android/android_tools.cpp
View file @
d69b698e
...
@@ -887,6 +887,20 @@ void process_input(ANDROID_APP app,
...
@@ -887,6 +887,20 @@ void process_input(ANDROID_APP app,
}
}
}
}
void
onGameExit
(
ANDROID_APP
app
){
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
return
;
JNIEnv
*
jni
=
nullptr
;
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
NULL
);
jobject
lNativeActivity
=
app
->
activity
->
clazz
;
jclass
ClassNativeActivity
=
jni
->
GetObjectClass
(
lNativeActivity
);
jmethodID
methodId
=
jni
->
GetMethodID
(
ClassNativeActivity
,
"onGameExit"
,
"()V"
);
jni
->
CallVoidMethod
(
lNativeActivity
,
methodId
);
jni
->
DeleteLocalRef
(
ClassNativeActivity
);
app
->
activity
->
vm
->
DetachCurrentThread
();
}
s32
handleInput
(
ANDROID_APP
app
,
AInputEvent
*
androidEvent
)
{
s32
handleInput
(
ANDROID_APP
app
,
AInputEvent
*
androidEvent
)
{
IrrlichtDevice
*
device
=
(
IrrlichtDevice
*
)
app
->
userData
;
IrrlichtDevice
*
device
=
(
IrrlichtDevice
*
)
app
->
userData
;
s32
Status
=
0
;
s32
Status
=
0
;
...
...
libcore/android/android_tools.h
View file @
d69b698e
...
@@ -193,6 +193,8 @@ extern s32 handleInput(ANDROID_APP app, AInputEvent* androidEvent);
...
@@ -193,6 +193,8 @@ extern s32 handleInput(ANDROID_APP app, AInputEvent* androidEvent);
extern
bool
android_deck_delete
(
const
char
*
deck_name
);
extern
bool
android_deck_delete
(
const
char
*
deck_name
);
extern
void
onGameExit
(
ANDROID_APP
app
);
extern
void
runWindbot
(
ANDROID_APP
app
,
const
char
*
args
);
extern
void
runWindbot
(
ANDROID_APP
app
,
const
char
*
args
);
}
}
...
...
libcore/src/main/AndroidManifest.xml
View file @
d69b698e
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
android:value=
"YGOMobile"
/>
android:value=
"YGOMobile"
/>
</activity>
</activity>
<receiver
android:name=
"cn.garymb.ygomobile.GameReceiver"
<receiver
android:name=
"cn.garymb.ygomobile.GameReceiver"
android:process=
":game"
>
android:process=
":game
helper
"
>
<intent-filter>
<intent-filter>
<action
android:name=
"cn.garymb.ygomobile.game.start"
/>
<action
android:name=
"cn.garymb.ygomobile.game.start"
/>
<action
android:name=
"cn.garymb.ygomobile.game.stop"
/>
<action
android:name=
"cn.garymb.ygomobile.game.stop"
/>
...
...
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
View file @
d69b698e
...
@@ -17,6 +17,7 @@ import android.os.Build;
...
@@ -17,6 +17,7 @@ import android.os.Build;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.os.PowerManager
;
import
android.os.PowerManager
;
import
android.os.Process
;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.Gravity
;
import
android.view.Gravity
;
import
android.view.HapticFeedbackConstants
;
import
android.view.HapticFeedbackConstants
;
...
@@ -544,4 +545,10 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -544,4 +545,10 @@ public class YGOMobileActivity extends NativeActivity implements
}
}
});
});
}
}
@Override
public
void
onGameExit
()
{
Log
.
e
(
"ygomobile"
,
"game exit"
);
Process
.
killProcess
(
Process
.
myPid
());
}
}
}
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
View file @
d69b698e
...
@@ -213,5 +213,7 @@ public final class IrrlichtBridge {
...
@@ -213,5 +213,7 @@ public final class IrrlichtBridge {
int
getPositionX
();
int
getPositionX
();
int
getPositionY
();
int
getPositionY
();
void
onGameExit
();
}
}
}
}
mobile/build.gradle
View file @
d69b698e
...
@@ -13,7 +13,7 @@ android {
...
@@ -13,7 +13,7 @@ android {
flavorDimensions
"versionCode"
flavorDimensions
"versionCode"
vectorDrawables
.
useSupportLibrary
=
true
vectorDrawables
.
useSupportLibrary
=
true
ndk
{
ndk
{
abiFilters
"arm64-v8a"
,
"armeabi-v7a"
,
"x86"
abiFilters
"arm
eabi-v7a"
//"arm
64-v8a", "armeabi-v7a", "x86"
}
}
}
}
compileOptions
{
compileOptions
{
...
@@ -34,6 +34,9 @@ android {
...
@@ -34,6 +34,9 @@ android {
}
}
}
}
buildTypes
{
buildTypes
{
debug
{
debuggable
false
}
release
{
release
{
shrinkResources
false
shrinkResources
false
minifyEnabled
false
minifyEnabled
false
...
...
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
View file @
d69b698e
...
@@ -37,6 +37,7 @@ public class GameUriManager {
...
@@ -37,6 +37,7 @@ public class GameUriManager {
}
}
public
boolean
doIntent
(
Intent
intent
)
{
public
boolean
doIntent
(
Intent
intent
)
{
Log
.
i
(
"ygo"
,
"doIntent"
);
if
(
ACTION_OPEN_DECK
.
equals
(
intent
.
getAction
()))
{
if
(
ACTION_OPEN_DECK
.
equals
(
intent
.
getAction
()))
{
if
(
intent
.
getData
()
!=
null
)
{
if
(
intent
.
getData
()
!=
null
)
{
doUri
(
intent
.
getData
());
doUri
(
intent
.
getData
());
...
@@ -119,6 +120,7 @@ public class GameUriManager {
...
@@ -119,6 +120,7 @@ public class GameUriManager {
private
void
doUri
(
Uri
uri
)
{
private
void
doUri
(
Uri
uri
)
{
Intent
startSeting
=
new
Intent
(
activity
,
SettingsActivity
.
class
);
Intent
startSeting
=
new
Intent
(
activity
,
SettingsActivity
.
class
);
Log
.
i
(
"ygo"
,
"doUri:"
+
uri
);
if
(
"file"
.
equals
(
uri
.
getScheme
()))
{
if
(
"file"
.
equals
(
uri
.
getScheme
()))
{
File
file
=
new
File
(
uri
.
getPath
());
File
file
=
new
File
(
uri
.
getPath
());
if
(
file
.
getName
().
toLowerCase
(
Locale
.
US
).
endsWith
(
".ydk"
))
{
if
(
file
.
getName
().
toLowerCase
(
Locale
.
US
).
endsWith
(
".ydk"
))
{
...
@@ -162,9 +164,11 @@ public class GameUriManager {
...
@@ -162,9 +164,11 @@ public class GameUriManager {
Toast
.
makeText
(
activity
,
activity
.
getString
(
R
.
string
.
install_failed_bcos
)
+
e
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
activity
,
activity
.
getString
(
R
.
string
.
install_failed_bcos
)
+
e
,
Toast
.
LENGTH_LONG
).
show
();
}
}
}
}
if
(!
ComponentUtils
.
isActivityRunning
(
getActivity
(),
new
ComponentName
(
getActivity
(),
YGOMobileActivity
.
class
)))
{
if
(!
YGOStarter
.
isGameRunning
(
getActivity
(
)))
{
YGOStarter
.
startGame
(
getActivity
(),
null
,
"-r"
,
yrp
.
getName
());
YGOStarter
.
startGame
(
getActivity
(),
null
,
"-r"
,
yrp
.
getName
());
Toast
.
makeText
(
activity
,
""
+
yrp
.
getName
(),
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
activity
,
""
+
yrp
.
getName
(),
Toast
.
LENGTH_LONG
).
show
();
}
else
{
Log
.
w
(
"ygo"
,
"game is running"
);
}
}
}
}
}
else
if
(
"content"
.
equals
(
uri
.
getScheme
()))
{
}
else
if
(
"content"
.
equals
(
uri
.
getScheme
()))
{
...
@@ -242,9 +246,11 @@ public class GameUriManager {
...
@@ -242,9 +246,11 @@ public class GameUriManager {
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
if
(!
ComponentUtils
.
isActivityRunning
(
activity
,
new
ComponentName
(
activity
,
YGOMobileActivity
.
class
)))
{
if
(!
YGOStarter
.
isGameRunning
(
getActivity
(
)))
{
YGOStarter
.
startGame
(
getActivity
(),
null
,
"-r
"
,
yrp
.
getName
());
YGOStarter
.
startGame
(
getActivity
(),
null
,
"-r"
,
yrp
.
getName
());
Toast
.
makeText
(
activity
,
activity
.
getString
(
R
.
string
.
yrp_installed
),
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
activity
,
activity
.
getString
(
R
.
string
.
yrp_installed
),
Toast
.
LENGTH_LONG
).
show
();
}
else
{
Log
.
w
(
"ygo"
,
"game is running"
);
}
}
}
}
}
else
{
}
else
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
View file @
d69b698e
...
@@ -3,6 +3,8 @@ package cn.garymb.ygomobile;
...
@@ -3,6 +3,8 @@ package cn.garymb.ygomobile;
import
android.annotation.SuppressLint
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.content.ComponentName
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.pm.ActivityInfo
;
import
android.content.pm.ActivityInfo
;
import
android.graphics.Bitmap
;
import
android.graphics.Bitmap
;
...
@@ -19,6 +21,7 @@ import com.bumptech.glide.Glide;
...
@@ -19,6 +21,7 @@ import com.bumptech.glide.Glide;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
import
com.bumptech.glide.request.target.ViewTarget
;
import
com.bumptech.glide.request.target.ViewTarget
;
import
com.bumptech.glide.signature.StringSignature
;
import
com.bumptech.glide.signature.StringSignature
;
import
com.tencent.bugly.proguard.C
;
import
java.io.File
;
import
java.io.File
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -27,6 +30,7 @@ import cn.garymb.ygodata.YGOGameOptions;
...
@@ -27,6 +30,7 @@ import cn.garymb.ygodata.YGOGameOptions;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.plus.ViewTargetPlus
;
import
cn.garymb.ygomobile.ui.plus.ViewTargetPlus
;
import
cn.garymb.ygomobile.utils.ComponentUtils
;
public
class
YGOStarter
{
public
class
YGOStarter
{
...
@@ -207,4 +211,9 @@ public class YGOStarter {
...
@@ -207,4 +211,9 @@ public class YGOStarter {
int
oldRequestedOrientation
;
int
oldRequestedOrientation
;
boolean
isRunning
=
false
;
boolean
isRunning
=
false
;
}
}
public
static
boolean
isGameRunning
(
Context
context
)
{
return
ComponentUtils
.
isProcessRunning
(
context
,
context
.
getPackageName
()
+
":game"
)
&&
ComponentUtils
.
isActivityRunning
(
context
,
new
ComponentName
(
context
,
YGOMobileActivity
.
class
));
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
View file @
d69b698e
...
@@ -435,7 +435,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
...
@@ -435,7 +435,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
builder
.
setLeftButtonText
(
R
.
string
.
join_game
);
builder
.
setLeftButtonText
(
R
.
string
.
join_game
);
builder
.
setLeftButtonListener
((
dlg
,
i
)
->
{
builder
.
setLeftButtonListener
((
dlg
,
i
)
->
{
dlg
.
dismiss
();
dlg
.
dismiss
();
if
(
Build
.
VERSION
.
SDK_INT
>=
23
&&
ComponentUtils
.
isActivityRunning
(
this
,
new
ComponentName
(
this
,
YGOMobileActivity
.
class
)))
{
if
(
Build
.
VERSION
.
SDK_INT
>=
23
&&
YGOStarter
.
isGameRunning
(
getActivity
(
)))
{
Toast
toast
=
Toast
.
makeText
(
getApplicationContext
(),
R
.
string
.
tip_return_to_duel
,
Toast
.
LENGTH_SHORT
);
Toast
toast
=
Toast
.
makeText
(
getApplicationContext
(),
R
.
string
.
tip_return_to_duel
,
Toast
.
LENGTH_SHORT
);
toast
.
setGravity
(
Gravity
.
CENTER
,
0
,
0
);
toast
.
setGravity
(
Gravity
.
CENTER
,
0
,
0
);
toast
.
show
();
toast
.
show
();
...
@@ -558,7 +558,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
...
@@ -558,7 +558,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
tv
.
setOnClickListener
((
v
)
->
{
tv
.
setOnClickListener
((
v
)
->
{
openGame
();
openGame
();
});
});
if
(
ComponentUtils
.
isActivityRunning
(
this
,
new
ComponentName
(
this
,
YGOMobileActivity
.
class
)))
{
if
(
YGOStarter
.
isGameRunning
(
getActivity
(
)))
{
tv
.
setVisibility
(
View
.
VISIBLE
);
tv
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
}
else
{
tv
.
setVisibility
(
View
.
GONE
);
tv
.
setVisibility
(
View
.
GONE
);
...
@@ -664,7 +664,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
...
@@ -664,7 +664,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
}
}
public
void
showTipsToast
()
{
public
void
showTipsToast
()
{
if
(!
ComponentUtils
.
isActivityRunning
(
this
,
new
ComponentName
(
this
,
YGOMobileActivity
.
class
)))
{
if
(!
YGOStarter
.
isGameRunning
(
getActivity
(
)))
{
String
[]
tipsList
=
this
.
getResources
().
getStringArray
(
R
.
array
.
tips
);
String
[]
tipsList
=
this
.
getResources
().
getStringArray
(
R
.
array
.
tips
);
int
x
=
(
int
)
(
Math
.
random
()
*
tipsList
.
length
);
int
x
=
(
int
)
(
Math
.
random
()
*
tipsList
.
length
);
String
tips
=
tipsList
[
x
];
String
tips
=
tipsList
[
x
];
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/MainActivity.java
View file @
d69b698e
...
@@ -196,7 +196,7 @@ public class MainActivity extends HomeActivity {
...
@@ -196,7 +196,7 @@ public class MainActivity extends HomeActivity {
super
.
onResume
();
super
.
onResume
();
YGOStarter
.
onResumed
(
this
);
YGOStarter
.
onResumed
(
this
);
//如果游戏Activity已经不存在了,则
//如果游戏Activity已经不存在了,则
if
(!
ComponentUtils
.
isActivityRunning
(
this
,
new
ComponentName
(
this
,
YGOMobileActivity
.
class
)))
{
if
(!
YGOStarter
.
isGameRunning
(
getActivity
(
)))
{
sendBroadcast
(
new
Intent
(
IrrlichtBridge
.
ACTION_STOP
).
setPackage
(
getPackageName
()));
sendBroadcast
(
new
Intent
(
IrrlichtBridge
.
ACTION_STOP
).
setPackage
(
getPackageName
()));
}
}
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/ComponentUtils.java
View file @
d69b698e
...
@@ -4,12 +4,25 @@ import android.app.ActivityManager;
...
@@ -4,12 +4,25 @@ import android.app.ActivityManager;
import
android.content.ComponentName
;
import
android.content.ComponentName
;
import
android.content.Context
;
import
android.content.Context
;
import
android.os.Build
;
import
android.os.Build
;
import
android.text.TextUtils
;
import
androidx.annotation.RequiresApi
;
import
androidx.annotation.RequiresApi
;
import
java.util.List
;
import
java.util.List
;
public
class
ComponentUtils
{
public
class
ComponentUtils
{
public
static
boolean
isProcessRunning
(
Context
context
,
String
processName
)
{
ActivityManager
am
=
(
ActivityManager
)
context
.
getSystemService
(
Context
.
ACTIVITY_SERVICE
);
List
<
ActivityManager
.
RunningAppProcessInfo
>
tasks
=
am
.
getRunningAppProcesses
();
if
(
tasks
!=
null
)
{
for
(
ActivityManager
.
RunningAppProcessInfo
taskInfo
:
tasks
)
{
if
(
context
.
getApplicationInfo
().
uid
==
taskInfo
.
uid
&&
TextUtils
.
equals
(
processName
,
taskInfo
.
processName
))
{
return
true
;
}
}
}
return
false
;
}
public
static
boolean
isActivityRunning
(
Context
context
,
ComponentName
componentName
)
{
public
static
boolean
isActivityRunning
(
Context
context
,
ComponentName
componentName
)
{
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
>=
android
.
os
.
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
>=
android
.
os
.
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
return
isActivityRunningV21
(
context
,
componentName
);
return
isActivityRunningV21
(
context
,
componentName
);
...
...
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