Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile-Cn-Ko-En
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-Cn-Ko-En
Commits
2fcc88ae
Commit
2fcc88ae
authored
Oct 04, 2019
by
kenan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
surface
parent
2fe782e3
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
231 additions
and
81 deletions
+231
-81
Classes/gframe/game.cpp
Classes/gframe/game.cpp
+17
-12
irrlicht/source/Irrlicht/Android/CIrrDeviceAndroid.h
irrlicht/source/Irrlicht/Android/CIrrDeviceAndroid.h
+2
-1
libcore/android/android_tools.cpp
libcore/android/android_tools.cpp
+8
-2
libcore/android/android_tools.h
libcore/android/android_tools.h
+3
-1
libcore/jni/cn_garymb_ygomobile_core_IrrlichtBridge.cpp
libcore/jni/cn_garymb_ygomobile_core_IrrlichtBridge.cpp
+77
-36
libcore/src/main/java/cn/garymb/ygomobile/GameReceiver.java
libcore/src/main/java/cn/garymb/ygomobile/GameReceiver.java
+5
-4
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
.../src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
+87
-16
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
...rc/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
+32
-9
No files found.
Classes/gframe/game.cpp
View file @
2fcc88ae
...
@@ -1453,34 +1453,39 @@ void Game::LoadConfig() {
...
@@ -1453,34 +1453,39 @@ void Game::LoadConfig() {
}
}
void
Game
::
SaveConfig
()
{
void
Game
::
SaveConfig
()
{
JNIEnv
*
jni
=
0
;
appMain
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
NULL
);
if
(
!
jni
)
return
;
//helper
//helper
gameConf
.
chkMAutoPos
=
chkMAutoPos
->
isChecked
()
?
1
:
0
;
gameConf
.
chkMAutoPos
=
chkMAutoPos
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
"chkMAutoPos"
,
gameConf
.
chkMAutoPos
);
android
::
saveIntSetting
(
appMain
,
jni
,
"chkMAutoPos"
,
gameConf
.
chkMAutoPos
);
gameConf
.
chkSTAutoPos
=
chkSTAutoPos
->
isChecked
()
?
1
:
0
;
gameConf
.
chkSTAutoPos
=
chkSTAutoPos
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
"chkSTAutoPos"
,
gameConf
.
chkSTAutoPos
);
android
::
saveIntSetting
(
appMain
,
jni
,
"chkSTAutoPos"
,
gameConf
.
chkSTAutoPos
);
gameConf
.
chkRandomPos
=
chkRandomPos
->
isChecked
()
?
1
:
0
;
gameConf
.
chkRandomPos
=
chkRandomPos
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
"chkRandomPos"
,
gameConf
.
chkRandomPos
);
android
::
saveIntSetting
(
appMain
,
jni
,
"chkRandomPos"
,
gameConf
.
chkRandomPos
);
gameConf
.
chkAutoChain
=
chkAutoChain
->
isChecked
()
?
1
:
0
;
gameConf
.
chkAutoChain
=
chkAutoChain
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
"chkAutoChain"
,
gameConf
.
chkAutoChain
);
android
::
saveIntSetting
(
appMain
,
jni
,
"chkAutoChain"
,
gameConf
.
chkAutoChain
);
gameConf
.
chkWaitChain
=
chkWaitChain
->
isChecked
()
?
1
:
0
;
gameConf
.
chkWaitChain
=
chkWaitChain
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
"chkWaitChain"
,
gameConf
.
chkWaitChain
);
android
::
saveIntSetting
(
appMain
,
jni
,
"chkWaitChain"
,
gameConf
.
chkWaitChain
);
//system
//system
gameConf
.
chkIgnore1
=
chkIgnore1
->
isChecked
()
?
1
:
0
;
gameConf
.
chkIgnore1
=
chkIgnore1
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
"chkIgnore1"
,
gameConf
.
chkIgnore1
);
android
::
saveIntSetting
(
appMain
,
jni
,
"chkIgnore1"
,
gameConf
.
chkIgnore1
);
gameConf
.
chkIgnore2
=
chkIgnore2
->
isChecked
()
?
1
:
0
;
gameConf
.
chkIgnore2
=
chkIgnore2
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
"chkIgnore2"
,
gameConf
.
chkIgnore2
);
android
::
saveIntSetting
(
appMain
,
jni
,
"chkIgnore2"
,
gameConf
.
chkIgnore2
);
gameConf
.
chkIgnoreDeckChanges
=
chkIgnoreDeckChanges
->
isChecked
()
?
1
:
0
;
gameConf
.
chkIgnoreDeckChanges
=
chkIgnoreDeckChanges
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
"chkIgnoreDeckChanges"
,
gameConf
.
chkIgnoreDeckChanges
);
android
::
saveIntSetting
(
appMain
,
jni
,
"chkIgnoreDeckChanges"
,
gameConf
.
chkIgnoreDeckChanges
);
gameConf
.
auto_save_replay
=
chkAutoSaveReplay
->
isChecked
()
?
1
:
0
;
gameConf
.
auto_save_replay
=
chkAutoSaveReplay
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
"auto_save_replay"
,
gameConf
.
auto_save_replay
);
android
::
saveIntSetting
(
appMain
,
jni
,
"auto_save_replay"
,
gameConf
.
auto_save_replay
);
gameConf
.
draw_field_spell
=
chkDrawFieldSpell
->
isChecked
()
?
1
:
0
;
gameConf
.
draw_field_spell
=
chkDrawFieldSpell
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
"draw_field_spell"
,
gameConf
.
draw_field_spell
);
android
::
saveIntSetting
(
appMain
,
jni
,
"draw_field_spell"
,
gameConf
.
draw_field_spell
);
gameConf
.
quick_animation
=
chkQuickAnimation
->
isChecked
()
?
1
:
0
;
gameConf
.
quick_animation
=
chkQuickAnimation
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
"quick_animation"
,
gameConf
.
quick_animation
);
android
::
saveIntSetting
(
appMain
,
jni
,
"quick_animation"
,
gameConf
.
quick_animation
);
gameConf
.
prefer_expansion_script
=
chkPreferExpansionScript
->
isChecked
()
?
1
:
0
;
gameConf
.
prefer_expansion_script
=
chkPreferExpansionScript
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
"prefer_expansion_script"
,
gameConf
.
prefer_expansion_script
);
android
::
saveIntSetting
(
appMain
,
jni
,
"prefer_expansion_script"
,
gameConf
.
prefer_expansion_script
);
appMain
->
activity
->
vm
->
DetachCurrentThread
();
//gameConf.control_mode = control_mode->isChecked()?1:0;
//gameConf.control_mode = control_mode->isChecked()?1:0;
// android::saveIntSetting(appMain, "control_mode", gameConf.control_mode);
// android::saveIntSetting(appMain, "control_mode", gameConf.control_mode);
}
}
...
...
irrlicht/source/Irrlicht/Android/CIrrDeviceAndroid.h
View file @
2fcc88ae
...
@@ -56,6 +56,8 @@ namespace irr
...
@@ -56,6 +56,8 @@ namespace irr
virtual
E_DEVICE_TYPE
getType
()
const
;
virtual
E_DEVICE_TYPE
getType
()
const
;
core
::
array
<
EKEY_CODE
>
KeyMap
;
private:
private:
static
void
handleAndroidCommand
(
ANDROID_APP
app
,
int32_t
cmd
);
static
void
handleAndroidCommand
(
ANDROID_APP
app
,
int32_t
cmd
);
...
@@ -80,7 +82,6 @@ namespace irr
...
@@ -80,7 +82,6 @@ namespace irr
video
::
SExposedVideoData
ExposedVideoData
;
video
::
SExposedVideoData
ExposedVideoData
;
core
::
array
<
EKEY_CODE
>
KeyMap
;
};
};
}
// end namespace irr
}
// end namespace irr
...
...
libcore/android/android_tools.cpp
View file @
2fcc88ae
...
@@ -441,13 +441,20 @@ int getIntSetting(ANDROID_APP app, const char* key,int defvalue){
...
@@ -441,13 +441,20 @@ int getIntSetting(ANDROID_APP app, const char* key,int defvalue){
return
(
int
)
ret
;
return
(
int
)
ret
;
}
}
void
saveIntSetting
(
ANDROID_APP
app
,
const
char
*
key
,
int
value
)
{
void
saveIntSetting
Auto
(
ANDROID_APP
app
,
const
char
*
key
,
int
value
)
{
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
return
;
return
;
JNIEnv
*
jni
=
0
;
JNIEnv
*
jni
=
0
;
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
NULL
);
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
NULL
);
if
(
!
jni
)
if
(
!
jni
)
return
;
return
;
saveIntSetting
(
app
,
jni
,
key
,
value
);
app
->
activity
->
vm
->
DetachCurrentThread
();
}
void
saveIntSetting
(
ANDROID_APP
app
,
JNIEnv
*
jni
,
const
char
*
key
,
int
value
)
{
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
return
;
// Retrieves NativeActivity.
// Retrieves NativeActivity.
jobject
lNativeActivity
=
app
->
activity
->
clazz
;
jobject
lNativeActivity
=
app
->
activity
->
clazz
;
jclass
ClassNativeActivity
=
jni
->
GetObjectClass
(
lNativeActivity
);
jclass
ClassNativeActivity
=
jni
->
GetObjectClass
(
lNativeActivity
);
...
@@ -464,7 +471,6 @@ void saveIntSetting(ANDROID_APP app, const char* key, int value) {
...
@@ -464,7 +471,6 @@ void saveIntSetting(ANDROID_APP app, const char* key, int value) {
}
}
jni
->
DeleteLocalRef
(
classApp
);
jni
->
DeleteLocalRef
(
classApp
);
jni
->
DeleteLocalRef
(
ClassNativeActivity
);
jni
->
DeleteLocalRef
(
ClassNativeActivity
);
app
->
activity
->
vm
->
DetachCurrentThread
();
}
}
void
saveSetting
(
ANDROID_APP
app
,
const
char
*
key
,
const
char
*
value
)
{
void
saveSetting
(
ANDROID_APP
app
,
const
char
*
key
,
const
char
*
value
)
{
...
...
libcore/android/android_tools.h
View file @
2fcc88ae
...
@@ -160,7 +160,9 @@ extern void setLastDeck(ANDROID_APP app, const char* deckname);
...
@@ -160,7 +160,9 @@ extern void setLastDeck(ANDROID_APP app, const char* deckname);
//save last category name.
//save last category name.
extern
void
setLastCategory
(
ANDROID_APP
app
,
const
char
*
catename
);
extern
void
setLastCategory
(
ANDROID_APP
app
,
const
char
*
catename
);
extern
void
saveIntSetting
(
ANDROID_APP
app
,
const
char
*
key
,
int
value
);
extern
void
saveIntSetting
(
ANDROID_APP
app
,
JNIEnv
*
jni
,
const
char
*
key
,
int
value
);
extern
void
saveIntSettingAuto
(
ANDROID_APP
app
,
const
char
*
key
,
int
value
);
extern
void
saveSetting
(
ANDROID_APP
app
,
const
char
*
key
,
const
char
*
value
);
extern
void
saveSetting
(
ANDROID_APP
app
,
const
char
*
key
,
const
char
*
value
);
...
...
libcore/jni/cn_garymb_ygomobile_core_IrrlichtBridge.cpp
View file @
2fcc88ae
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include "../Classes/gframe/os.h"
#include "../Classes/gframe/os.h"
#include <unistd.h>
#include <unistd.h>
#include <pthread.h>
#include <pthread.h>
#include <Android/CIrrDeviceAndroid.h>
#include "../android/YGOGameOptions.h"
#include "../android/YGOGameOptions.h"
#include "../Classes/gframe/game.h"
#include "../Classes/gframe/game.h"
...
@@ -225,27 +226,38 @@ static void* join_game_thread(void* param) {
...
@@ -225,27 +226,38 @@ static void* join_game_thread(void* param) {
return
NULL
;
return
NULL
;
}
}
/*
bool
sendKey
(
int
handle
,
int
keycode
,
bool
begin
){
* Class: cn_garymb_ygomobile_core_IrrlichtBridge
if
(
handle
)
{
* Method: nativeRefreshTexture
CIrrDeviceAndroid
*
device
=
(
CIrrDeviceAndroid
*
)
handle
;
* Signature: (I)V
*/
JNIEXPORT
void
JNICALL
Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeRefreshTexture
(
JNIEnv
*
env
,
jclass
clazz
,
jint
handle
)
{
if
(
handle
)
{
IrrlichtDevice
*
device
=
(
IrrlichtDevice
*
)
handle
;
if
(
device
->
isWindowFocused
())
{
if
(
device
->
isWindowFocused
())
{
irr
::
os
::
Printer
::
log
(
"before send refresh event"
);
SEvent
event
;
SEvent
event
;
event
.
EventType
=
EET_KEY_INPUT_EVENT
;
event
.
EventType
=
EET_KEY_INPUT_EVENT
;
//just cause a right up event to refresh texture
event
.
KeyInput
.
PressedDown
=
true
;
int
keyCode
=
keycode
;
if
(
keyCode
>=
0
&&
(
u32
)
keyCode
<
device
->
KeyMap
.
size
())
event
.
KeyInput
.
Key
=
device
->
KeyMap
[
keyCode
];
else
event
.
KeyInput
.
Key
=
KEY_UNKNOWN
;
event
.
KeyInput
.
PressedDown
=
begin
;
event
.
KeyInput
.
Shift
=
false
;
event
.
KeyInput
.
Shift
=
false
;
event
.
KeyInput
.
Control
=
false
;
event
.
KeyInput
.
Control
=
false
;
event
.
KeyInput
.
Key
=
KEY_KEY_R
;
device
->
postEventFromUser
(
event
);
device
->
postEventFromUser
(
event
);
return
true
;
}
}
}
}
return
false
;
}
/*
* Class: cn_garymb_ygomobile_core_IrrlichtBridge
* Method: nativeRefreshTexture
* Signature: (I)V
*/
JNIEXPORT
void
JNICALL
Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeRefreshTexture
(
JNIEnv
*
env
,
jclass
clazz
,
jint
handle
)
{
if
(
sendKey
(
handle
,
KEY_KEY_R
,
true
)){
irr
::
os
::
Printer
::
log
(
"before send refresh event"
);
}
}
}
/*
/*
...
@@ -254,19 +266,8 @@ static void* join_game_thread(void* param) {
...
@@ -254,19 +266,8 @@ static void* join_game_thread(void* param) {
* Signature: (IZ)V
* Signature: (IZ)V
*/
JNIEXPORT
void
JNICALL
Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeIgnoreChain
(
*/
JNIEXPORT
void
JNICALL
Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeIgnoreChain
(
JNIEnv
*
env
,
jclass
clazz
,
jint
handle
,
jboolean
begin
)
{
JNIEnv
*
env
,
jclass
clazz
,
jint
handle
,
jboolean
begin
)
{
if
(
handle
)
{
if
(
sendKey
(
handle
,
KEY_KEY_S
,
true
)){
IrrlichtDevice
*
device
=
(
IrrlichtDevice
*
)
handle
;
irr
::
os
::
Printer
::
log
(
"before send ignore chain"
);
if
(
device
->
isWindowFocused
())
{
irr
::
os
::
Printer
::
log
(
"before send ignore chain"
);
SEvent
event
;
event
.
EventType
=
EET_KEY_INPUT_EVENT
;
//just cause a right up event to refresh texture
event
.
KeyInput
.
PressedDown
=
begin
;
event
.
KeyInput
.
Shift
=
false
;
event
.
KeyInput
.
Control
=
false
;
event
.
KeyInput
.
Key
=
KEY_KEY_S
;
device
->
postEventFromUser
(
event
);
}
}
}
}
}
...
@@ -276,18 +277,58 @@ static void* join_game_thread(void* param) {
...
@@ -276,18 +277,58 @@ static void* join_game_thread(void* param) {
* Signature: (IZ)V
* Signature: (IZ)V
*/
JNIEXPORT
void
JNICALL
Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeReactChain
(
*/
JNIEXPORT
void
JNICALL
Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeReactChain
(
JNIEnv
*
env
,
jclass
clazz
,
jint
handle
,
jboolean
begin
)
{
JNIEnv
*
env
,
jclass
clazz
,
jint
handle
,
jboolean
begin
)
{
if
(
handle
)
{
if
(
sendKey
(
handle
,
KEY_KEY_A
,
true
)){
IrrlichtDevice
*
device
=
(
IrrlichtDevice
*
)
handle
;
irr
::
os
::
Printer
::
log
(
"before send react chain"
);
}
}
//key事件
JNIEXPORT
void
JNICALL
Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSendKey
(
JNIEnv
*
env
,
jclass
clazz
,
jint
handle
,
jint
keycode
,
jboolean
begin
)
{
if
(
sendKey
(
handle
,
keycode
,
begin
)){
irr
::
os
::
Printer
::
log
(
"before send nativeSendKey"
);
}
}
//touch事件
JNIEXPORT
void
JNICALL
Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSendTouch
(
JNIEnv
*
env
,
jclass
clazz
,
jint
handle
,
jint
action
,
jint
id
,
jfloat
x
,
jfloat
y
)
{
if
(
handle
)
{
irr
::
os
::
Printer
::
log
(
"before send touch"
);
CIrrDeviceAndroid
*
device
=
(
CIrrDeviceAndroid
*
)
handle
;
if
(
device
->
isWindowFocused
())
{
if
(
device
->
isWindowFocused
())
{
irr
::
os
::
Printer
::
log
(
"before send react chain"
);
SEvent
event
;
SEvent
event
;
event
.
EventType
=
EET_KEY_INPUT_EVENT
;
event
.
EventType
=
EET_TOUCH_INPUT_EVENT
;
//just cause a right up event to refresh texture
s32
eventAction
=
action
;
event
.
KeyInput
.
PressedDown
=
begin
;
s32
eventType
=
eventAction
&
AMOTION_EVENT_ACTION_MASK
;
event
.
KeyInput
.
Shift
=
false
;
event
.
KeyInput
.
Control
=
false
;
bool
touchReceived
=
true
;
event
.
KeyInput
.
Key
=
KEY_KEY_A
;
device
->
postEventFromUser
(
event
);
switch
(
eventType
)
{
case
AMOTION_EVENT_ACTION_DOWN
:
case
AMOTION_EVENT_ACTION_POINTER_DOWN
:
event
.
TouchInput
.
Event
=
ETIE_PRESSED_DOWN
;
break
;
case
AMOTION_EVENT_ACTION_MOVE
:
event
.
TouchInput
.
Event
=
ETIE_MOVED
;
break
;
case
AMOTION_EVENT_ACTION_UP
:
case
AMOTION_EVENT_ACTION_POINTER_UP
:
case
AMOTION_EVENT_ACTION_CANCEL
:
event
.
TouchInput
.
Event
=
ETIE_LEFT_UP
;
break
;
default:
touchReceived
=
false
;
break
;
}
if
(
touchReceived
)
{
// Process all touches for move action.
event
.
TouchInput
.
ID
=
static_cast
<
size_t
>
(
id
);
event
.
TouchInput
.
X
=
static_cast
<
s32
>
(
x
);
event
.
TouchInput
.
Y
=
static_cast
<
s32
>
(
y
);
device
->
postEventFromUser
(
event
);
}
}
}
}
}
}
}
...
...
libcore/src/main/java/cn/garymb/ygomobile/GameReceiver.java
View file @
2fcc88ae
...
@@ -3,6 +3,7 @@ package cn.garymb.ygomobile;
...
@@ -3,6 +3,7 @@ package cn.garymb.ygomobile;
import
android.content.BroadcastReceiver
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.util.Log
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
...
@@ -16,19 +17,19 @@ public class GameReceiver extends BroadcastReceiver {
...
@@ -16,19 +17,19 @@ public class GameReceiver extends BroadcastReceiver {
if
(
ACTION_START
.
equals
(
action
))
{
if
(
ACTION_START
.
equals
(
action
))
{
//
//
IrrlichtBridge
.
gPid
=
intent
.
getIntExtra
(
IrrlichtBridge
.
EXTRA_PID
,
0
);
IrrlichtBridge
.
gPid
=
intent
.
getIntExtra
(
IrrlichtBridge
.
EXTRA_PID
,
0
);
//
Log.w("ygo", "pid=" + IrrlichtBridge.gPid);
Log
.
w
(
"ygo"
,
"pid="
+
IrrlichtBridge
.
gPid
);
}
else
if
(
ACTION_STOP
.
equals
(
action
))
{
}
else
if
(
ACTION_STOP
.
equals
(
action
))
{
int
pid
=
intent
.
getIntExtra
(
IrrlichtBridge
.
EXTRA_PID
,
0
);
int
pid
=
intent
.
getIntExtra
(
IrrlichtBridge
.
EXTRA_PID
,
0
);
if
(
pid
==
0
&&
IrrlichtBridge
.
gPid
!=
0
)
{
if
(
pid
==
0
&&
IrrlichtBridge
.
gPid
!=
0
)
{
pid
=
IrrlichtBridge
.
gPid
;
pid
=
IrrlichtBridge
.
gPid
;
//
Log.w("ygo", "will kill last pid=" + pid);
Log
.
w
(
"ygo"
,
"will kill last pid="
+
pid
);
}
}
if
(
pid
==
0
)
{
if
(
pid
==
0
)
{
pid
=
android
.
os
.
Process
.
myPid
();
pid
=
android
.
os
.
Process
.
myPid
();
//
Log.w("ygo", "will kill now pid=" + pid);
Log
.
w
(
"ygo"
,
"will kill now pid="
+
pid
);
}
}
try
{
try
{
// Log.w
("ygo", "kill pid=" + pid);
Log
.
e
(
"ygo"
,
"kill pid="
+
pid
);
android
.
os
.
Process
.
killProcess
(
pid
);
android
.
os
.
Process
.
killProcess
(
pid
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
//ignore
//ignore
...
...
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
View file @
2fcc88ae
...
@@ -18,7 +18,10 @@ import android.os.PowerManager;
...
@@ -18,7 +18,10 @@ import android.os.PowerManager;
import
android.util.Log
;
import
android.util.Log
;
import
android.view.Gravity
;
import
android.view.Gravity
;
import
android.view.HapticFeedbackConstants
;
import
android.view.HapticFeedbackConstants
;
import
android.view.InputQueue
;
import
android.view.KeyEvent
;
import
android.view.KeyEvent
;
import
android.view.MotionEvent
;
import
android.view.SurfaceView
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.FrameLayout
;
import
android.widget.FrameLayout
;
import
android.widget.PopupWindow
;
import
android.widget.PopupWindow
;
...
@@ -78,6 +81,9 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -78,6 +81,9 @@ public class YGOMobileActivity extends NativeActivity implements
private
GameApplication
mApp
;
private
GameApplication
mApp
;
private
Handler
handler
=
new
Handler
();
private
Handler
handler
=
new
Handler
();
private
FullScreenUtils
mFullScreenUtils
;
private
FullScreenUtils
mFullScreenUtils
;
private
volatile
int
mPositionX
,
mPositionY
;
private
boolean
mPaused
;
private
SurfaceView
mSurfaceView
;
// public static int notchHeight;
// public static int notchHeight;
...
@@ -100,6 +106,8 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -100,6 +106,8 @@ public class YGOMobileActivity extends NativeActivity implements
@SuppressWarnings
(
"WrongConstant"
)
@SuppressWarnings
(
"WrongConstant"
)
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
mSurfaceView
=
new
SurfaceView
(
this
);
mSurfaceView
.
getHolder
().
addCallback
(
this
);
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
Log
.
e
(
"YGOStarter"
,
"跳转完成"
+
System
.
currentTimeMillis
());
Log
.
e
(
"YGOStarter"
,
"跳转完成"
+
System
.
currentTimeMillis
());
mFullScreenUtils
=
new
FullScreenUtils
(
this
,
app
().
isImmerSiveMode
());
mFullScreenUtils
=
new
FullScreenUtils
(
this
,
app
().
isImmerSiveMode
());
...
@@ -126,6 +134,7 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -126,6 +134,7 @@ public class YGOMobileActivity extends NativeActivity implements
@Override
@Override
protected
void
onResume
()
{
protected
void
onResume
()
{
mPaused
=
false
;
super
.
onResume
();
super
.
onResume
();
Log
.
e
(
"YGOStarter"
,
"ygo显示"
+
System
.
currentTimeMillis
());
Log
.
e
(
"YGOStarter"
,
"ygo显示"
+
System
.
currentTimeMillis
());
if
(
mLock
==
null
)
{
if
(
mLock
==
null
)
{
...
@@ -140,6 +149,7 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -140,6 +149,7 @@ public class YGOMobileActivity extends NativeActivity implements
@Override
@Override
protected
void
onPause
()
{
protected
void
onPause
()
{
mPaused
=
true
;
super
.
onPause
();
super
.
onPause
();
if
(
mLock
!=
null
)
{
if
(
mLock
!=
null
)
{
if
(
mLock
.
isHeld
())
{
if
(
mLock
.
isHeld
())
{
...
@@ -206,18 +216,6 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -206,18 +216,6 @@ public class YGOMobileActivity extends NativeActivity implements
}
}
}
}
private
void
fullscreen
()
{
//如果是沉浸模式
if
(
app
().
isImmerSiveMode
())
{
mFullScreenUtils
.
fullscreen
();
app
().
attachGame
(
this
);
//游戏大小
int
[]
size
=
getGameSize
();
getWindow
().
setLayout
(
size
[
0
],
size
[
1
]);
}
}
private
int
[]
getGameSize
(){
private
int
[]
getGameSize
(){
//调整padding
//调整padding
float
screenW
=
app
().
getScreenWidth
();
float
screenW
=
app
().
getScreenWidth
();
...
@@ -236,21 +234,94 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -236,21 +234,94 @@ public class YGOMobileActivity extends NativeActivity implements
}
}
int
w
=
(
int
)(
1024.0
*
xScale
);
int
w
=
(
int
)(
1024.0
*
xScale
);
int
h
=
(
int
)(
640.0
*
yScale
);
int
h
=
(
int
)(
640.0
*
yScale
);
mPositionX
=
(
int
)((
sH
-
w
)/
2.0f
);
mPositionY
=
(
int
)((
sW
-
h
)/
2.0f
);
return
new
int
[]{
w
,
h
};
return
new
int
[]{
w
,
h
};
}
}
private
void
fullscreen
()
{
//如果是沉浸模式
if
(
app
().
isImmerSiveMode
())
{
mFullScreenUtils
.
fullscreen
();
app
().
attachGame
(
this
);
//游戏大小
// int[] size = getGameSize();
// getWindow().setLayout(size[0], size[1]);
}
}
@Override
@Override
public
void
setContentView
(
View
view
)
{
public
void
setContentView
(
View
view
)
{
FrameLayout
layout
=
new
FrameLayout
(
this
);
int
[]
size
=
getGameSize
();
int
[]
size
=
getGameSize
();
int
w
=
size
[
0
];
int
w
=
size
[
0
];
int
h
=
size
[
1
];
int
h
=
size
[
1
];
FrameLayout
.
LayoutParams
lp
=
new
FrameLayout
.
LayoutParams
(
w
,
h
);
FrameLayout
.
LayoutParams
lp
=
new
FrameLayout
.
LayoutParams
(
w
,
h
);
FrameLayout
layout
=
new
FrameLayout
(
this
);
lp
.
gravity
=
Gravity
.
CENTER
;
lp
.
gravity
=
Gravity
.
CENTER
;
layout
.
addView
(
mSurfaceView
,
lp
);
layout
.
addView
(
view
,
lp
);
layout
.
addView
(
view
,
lp
);
getWindow
().
setLayout
(
w
,
h
);
view
.
setLongClickable
(
true
);
getWindow
().
setGravity
(
Gravity
.
CENTER
);
view
.
setOnTouchListener
(
new
View
.
OnTouchListener
()
{
@Override
public
boolean
onTouch
(
View
v
,
final
MotionEvent
event
)
{
int
eventType
=
event
.
getAction
()
&
MotionEvent
.
ACTION_MASK
;
switch
(
eventType
)
{
case
MotionEvent
.
ACTION_DOWN
:
case
MotionEvent
.
ACTION_POINTER_DOWN
:
case
MotionEvent
.
ACTION_MOVE
:
case
MotionEvent
.
ACTION_UP
:
case
MotionEvent
.
ACTION_POINTER_UP
:
case
MotionEvent
.
ACTION_CANCEL
:
break
;
default
:
return
false
;
}
IrrlichtBridge
.
sendTouch
(
event
.
getAction
(),
event
.
getX
(),
event
.
getY
(),
0
);
return
true
;
}
});
// getWindow().setLayout(w, h);
// getWindow().setGravity(Gravity.CENTER);
super
.
setContentView
(
layout
);
super
.
setContentView
(
layout
);
getWindow
().
takeSurface
(
null
);
getWindow
().
takeInputQueue
(
null
);
}
@Override
public
void
onInputQueueCreated
(
InputQueue
queue
)
{
// super.onInputQueueCreated(queue);
}
@Override
public
void
onInputQueueDestroyed
(
InputQueue
queue
)
{
// super.onInputQueueDestroyed(queue);
}
@Override
public
boolean
onKeyDown
(
int
keyCode
,
KeyEvent
event
)
{
if
(
keyCode
!=
KeyEvent
.
KEYCODE_BACK
){
IrrlichtBridge
.
sendKey
(
keyCode
,
true
);
return
true
;
}
return
super
.
onKeyDown
(
keyCode
,
event
);
}
@Override
public
boolean
onKeyUp
(
int
keyCode
,
KeyEvent
event
)
{
if
(
keyCode
!=
KeyEvent
.
KEYCODE_BACK
){
IrrlichtBridge
.
sendKey
(
keyCode
,
false
);
return
true
;
}
return
super
.
onKeyUp
(
keyCode
,
event
);
}
@Override
public
void
onBackPressed
()
{
// Toast.makeText(this, "请在游戏里面退出", Toast.LENGTH_SHORT).show();
// super.onBackPressed();
}
}
private
void
initExtraView
()
{
private
void
initExtraView
()
{
...
@@ -425,6 +496,6 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -425,6 +496,6 @@ public class YGOMobileActivity extends NativeActivity implements
@Override
@Override
public
void
setNativeHandle
(
int
nativeHandle
)
{
public
void
setNativeHandle
(
int
nativeHandle
)
{
IrrlichtBridge
.
s
NativeHandle
=
nativeHandle
;
IrrlichtBridge
.
s
etHandle
(
nativeHandle
)
;
}
}
}
}
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
View file @
2fcc88ae
...
@@ -39,7 +39,7 @@ public final class IrrlichtBridge {
...
@@ -39,7 +39,7 @@ public final class IrrlichtBridge {
}
}
p
ublic
static
int
sNativeHandle
;
p
rivate
static
int
sNativeHandle
;
//显示卡图
//显示卡图
public
static
native
byte
[]
nativeBpgImage
(
byte
[]
data
);
public
static
native
byte
[]
nativeBpgImage
(
byte
[]
data
);
//插入文本(大概是发送消息)
//插入文本(大概是发送消息)
...
@@ -59,6 +59,10 @@ public final class IrrlichtBridge {
...
@@ -59,6 +59,10 @@ public final class IrrlichtBridge {
private
static
native
void
nativeJoinGame
(
int
handle
,
ByteBuffer
buffer
,
int
length
);
private
static
native
void
nativeJoinGame
(
int
handle
,
ByteBuffer
buffer
,
int
length
);
private
static
native
void
nativeSendKey
(
int
handle
,
int
keycode
,
boolean
begin
);
private
static
native
void
nativeSendTouch
(
int
handle
,
int
action
,
int
id
,
float
x
,
float
y
);
private
static
final
boolean
DEBUG
=
false
;
private
static
final
boolean
DEBUG
=
false
;
private
static
final
String
TAG
=
IrrlichtBridge
.
class
.
getSimpleName
();
private
static
final
String
TAG
=
IrrlichtBridge
.
class
.
getSimpleName
();
...
@@ -117,37 +121,56 @@ public final class IrrlichtBridge {
...
@@ -117,37 +121,56 @@ public final class IrrlichtBridge {
return
null
;
return
null
;
}
}
}
}
public
static
void
setHandle
(
int
handle
){
synchronized
(
IrrlichtBridge
.
class
){
sNativeHandle
=
handle
;
}
}
public
static
int
getHandle
()
{
synchronized
(
IrrlichtBridge
.
class
){
return
sNativeHandle
;
}
}
public
static
void
cancelChain
()
{
public
static
void
cancelChain
()
{
nativeCancelChain
(
sNativeHandle
);
nativeCancelChain
(
getHandle
()
);
}
}
public
static
void
ignoreChain
(
boolean
begin
)
{
public
static
void
ignoreChain
(
boolean
begin
)
{
nativeIgnoreChain
(
sNativeHandle
,
begin
);
nativeIgnoreChain
(
getHandle
()
,
begin
);
}
}
public
static
void
reactChain
(
boolean
begin
)
{
public
static
void
reactChain
(
boolean
begin
)
{
nativeReactChain
(
sNativeHandle
,
begin
);
nativeReactChain
(
getHandle
(),
begin
);
}
public
static
void
sendKey
(
int
keycode
,
boolean
begin
)
{
nativeSendKey
(
getHandle
(),
keycode
,
begin
);
}
public
static
void
sendTouch
(
int
action
,
float
x
,
float
y
,
int
id
)
{
nativeSendTouch
(
getHandle
(),
action
,
id
,
x
,
y
);
}
}
public
static
void
insertText
(
String
text
)
{
public
static
void
insertText
(
String
text
)
{
nativeInsertText
(
sNativeHandle
,
text
);
nativeInsertText
(
getHandle
()
,
text
);
}
}
public
static
void
setComboBoxSelection
(
int
idx
)
{
public
static
void
setComboBoxSelection
(
int
idx
)
{
nativeSetComboBoxSelection
(
sNativeHandle
,
idx
);
nativeSetComboBoxSelection
(
getHandle
()
,
idx
);
}
}
public
static
void
refreshTexture
()
{
public
static
void
refreshTexture
()
{
nativeRefreshTexture
(
sNativeHandle
);
nativeRefreshTexture
(
getHandle
()
);
}
}
public
static
void
setCheckBoxesSelection
(
int
idx
)
{
public
static
void
setCheckBoxesSelection
(
int
idx
)
{
nativeSetCheckBoxesSelection
(
sNativeHandle
,
idx
);
nativeSetCheckBoxesSelection
(
getHandle
()
,
idx
);
}
}
public
static
void
joinGame
(
ByteBuffer
options
,
int
length
)
{
public
static
void
joinGame
(
ByteBuffer
options
,
int
length
)
{
nativeJoinGame
(
sNativeHandle
,
options
,
length
);
nativeJoinGame
(
getHandle
()
,
options
,
length
);
}
}
public
interface
IrrlichtApplication
{
public
interface
IrrlichtApplication
{
...
...
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