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
a57e52e0
Commit
a57e52e0
authored
Sep 21, 2021
by
kenan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GameActivity
parent
b334e11d
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
198 additions
and
274 deletions
+198
-274
Classes/gframe/game.cpp
Classes/gframe/game.cpp
+2
-12
Classes/gframe/game.h
Classes/gframe/game.h
+1
-22
Classes/gframe/gframe.cpp
Classes/gframe/gframe.cpp
+0
-1
libcore/android/android_tools.cpp
libcore/android/android_tools.cpp
+3
-21
libcore/android/android_tools.h
libcore/android/android_tools.h
+1
-1
libcore/jni/cn_garymb_ygomobile_core_IrrlichtBridge.cpp
libcore/jni/cn_garymb_ygomobile_core_IrrlichtBridge.cpp
+0
-8
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
.../src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
+31
-199
libcore/src/main/java/cn/garymb/ygomobile/core/GameActivity.java
.../src/main/java/cn/garymb/ygomobile/core/GameActivity.java
+160
-0
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
...rc/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
+0
-10
No files found.
Classes/gframe/game.cpp
View file @
a57e52e0
...
@@ -27,15 +27,6 @@ namespace ygo {
...
@@ -27,15 +27,6 @@ namespace ygo {
Game
*
mainGame
;
Game
*
mainGame
;
void
Game
::
process
(
irr
::
SEvent
&
event
)
{
if
(
event
.
EventType
==
EET_MOUSE_INPUT_EVENT
)
{
s32
x
=
event
.
MouseInput
.
X
;
s32
y
=
event
.
MouseInput
.
Y
;
event
.
MouseInput
.
X
=
optX
(
x
);
event
.
MouseInput
.
Y
=
optY
(
y
);
}
}
#ifdef _IRR_ANDROID_PLATFORM_
#ifdef _IRR_ANDROID_PLATFORM_
void
Game
::
stopBGM
()
{
void
Game
::
stopBGM
()
{
...
@@ -123,9 +114,7 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
...
@@ -123,9 +114,7 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
if
(
!
android
::
perfromTrick
(
app
))
{
if
(
!
android
::
perfromTrick
(
app
))
{
return
false
;
return
false
;
}
}
core
::
position2di
appPosition
=
android
::
initJavaBridge
(
app
,
device
);
android
::
initJavaBridge
(
app
,
device
);
setPositionFix
(
appPosition
);
device
->
setProcessReceiver
(
this
);
app
->
onInputEvent
=
android
::
handleInput
;
app
->
onInputEvent
=
android
::
handleInput
;
ILogger
*
logger
=
device
->
getLogger
();
ILogger
*
logger
=
device
->
getLogger
();
...
@@ -892,6 +881,7 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
...
@@ -892,6 +881,7 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
wDMQuery
=
env
->
addWindow
(
rect
<
s32
>
(
490
*
xScale
,
180
*
yScale
,
840
*
xScale
,
340
*
yScale
),
false
,
dataManager
->
GetSysString
(
1460
));
wDMQuery
=
env
->
addWindow
(
rect
<
s32
>
(
490
*
xScale
,
180
*
yScale
,
840
*
xScale
,
340
*
yScale
),
false
,
dataManager
->
GetSysString
(
1460
));
wDMQuery
->
getCloseButton
()
->
setVisible
(
false
);
wDMQuery
->
getCloseButton
()
->
setVisible
(
false
);
wDMQuery
->
setVisible
(
false
);
wDMQuery
->
setVisible
(
false
);
wDMQuery
->
setDraggable
(
false
);
ChangeToIGUIImageWindow
(
wDMQuery
,
bgDMQuery
,
imageManager
->
tDialog_L
);
ChangeToIGUIImageWindow
(
wDMQuery
,
bgDMQuery
,
imageManager
->
tDialog_L
);
stDMMessage
=
env
->
addStaticText
(
L""
,
rect
<
s32
>
(
20
*
xScale
,
25
*
yScale
,
290
*
xScale
,
45
*
yScale
),
false
,
false
,
wDMQuery
);
stDMMessage
=
env
->
addStaticText
(
L""
,
rect
<
s32
>
(
20
*
xScale
,
25
*
yScale
,
290
*
xScale
,
45
*
yScale
),
false
,
false
,
wDMQuery
);
stDMMessage2
=
env
->
addStaticText
(
L""
,
rect
<
s32
>
(
20
*
xScale
,
50
*
yScale
,
330
*
xScale
,
90
*
yScale
),
false
,
false
,
wDMQuery
,
-
1
,
true
);
stDMMessage2
=
env
->
addStaticText
(
L""
,
rect
<
s32
>
(
20
*
xScale
,
50
*
yScale
,
330
*
xScale
,
90
*
yScale
),
false
,
false
,
wDMQuery
,
-
1
,
true
);
...
...
Classes/gframe/game.h
View file @
a57e52e0
...
@@ -129,7 +129,7 @@ struct FadingUnit {
...
@@ -129,7 +129,7 @@ struct FadingUnit {
irr
::
core
::
vector2di
fadingDiff
;
irr
::
core
::
vector2di
fadingDiff
;
};
};
class
Game
:
IProcessEventReceiver
{
class
Game
{
public:
public:
#ifdef _IRR_ANDROID_PLATFORM_
#ifdef _IRR_ANDROID_PLATFORM_
...
@@ -662,27 +662,6 @@ public:
...
@@ -662,27 +662,6 @@ public:
Signal
externalSignal
;
Signal
externalSignal
;
static
void
onHandleAndroidCommand
(
ANDROID_APP
app
,
int32_t
cmd
);
static
void
onHandleAndroidCommand
(
ANDROID_APP
app
,
int32_t
cmd
);
#endif
#endif
void
setPositionFix
(
core
::
position2di
fix
){
InputFix
=
fix
;
}
float
optX
(
float
x
)
{
float
x2
=
x
-
InputFix
.
X
;
if
(
x2
<
0
)
{
return
0
;
}
return
x2
;
}
float
optY
(
float
y
)
{
float
y2
=
y
-
InputFix
.
Y
;
if
(
y2
<
0
)
{
return
0
;
}
return
y2
;
}
void
process
(
irr
::
SEvent
&
event
);
private:
core
::
position2di
InputFix
;
};
};
extern
Game
*
mainGame
;
extern
Game
*
mainGame
;
...
...
Classes/gframe/gframe.cpp
View file @
a57e52e0
...
@@ -41,7 +41,6 @@ int GetListBoxIndex(IGUIListBox* listbox, const wchar_t * target){
...
@@ -41,7 +41,6 @@ int GetListBoxIndex(IGUIListBox* listbox, const wchar_t * target){
}
}
void
android_main
(
ANDROID_APP
app
)
{
void
android_main
(
ANDROID_APP
app
)
{
app
->
inputPollSource
.
process
=
android
::
process_input
;
app
->
inputPollSource
.
process
=
android
::
process_input
;
app_dummy
();
#else
#else
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
#endif
#endif
...
...
libcore/android/android_tools.cpp
View file @
a57e52e0
...
@@ -749,9 +749,9 @@ void toggleGlobalIME(ANDROID_APP app, bool pShow) {
...
@@ -749,9 +749,9 @@ void toggleGlobalIME(ANDROID_APP app, bool pShow) {
app
->
activity
->
vm
->
DetachCurrentThread
();
app
->
activity
->
vm
->
DetachCurrentThread
();
}
}
core
::
position2di
initJavaBridge
(
ANDROID_APP
app
,
void
*
handle
)
{
void
initJavaBridge
(
ANDROID_APP
app
,
void
*
handle
)
{
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
return
core
::
position2di
(
0
,
0
)
;
return
;
JNIEnv
*
jni
=
nullptr
;
JNIEnv
*
jni
=
nullptr
;
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
NULL
);
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
NULL
);
jobject
lNativeActivity
=
app
->
activity
->
clazz
;
jobject
lNativeActivity
=
app
->
activity
->
clazz
;
...
@@ -760,18 +760,9 @@ core::position2di initJavaBridge(ANDROID_APP app, void* handle) {
...
@@ -760,18 +760,9 @@ core::position2di initJavaBridge(ANDROID_APP app, void* handle) {
"setNativeHandle"
,
"(J)V"
);
"setNativeHandle"
,
"(J)V"
);
jlong
code
=
(
jlong
)
handle
;
jlong
code
=
(
jlong
)
handle
;
jni
->
CallVoidMethod
(
lNativeActivity
,
MethodSetHandle
,
code
);
jni
->
CallVoidMethod
(
lNativeActivity
,
MethodSetHandle
,
code
);
jmethodID
methodX
=
jni
->
GetMethodID
(
ClassNativeActivity
,
"getPositionX"
,
"()I"
);
jint
posX
=
jni
->
CallIntMethod
(
lNativeActivity
,
methodX
);
jmethodID
methodY
=
jni
->
GetMethodID
(
ClassNativeActivity
,
"getPositionY"
,
"()I"
);
jint
posY
=
jni
->
CallIntMethod
(
lNativeActivity
,
methodY
);
jni
->
DeleteLocalRef
(
ClassNativeActivity
);
jni
->
DeleteLocalRef
(
ClassNativeActivity
);
app
->
activity
->
vm
->
DetachCurrentThread
();
app
->
activity
->
vm
->
DetachCurrentThread
();
__android_log_print
(
ANDROID_LOG_INFO
,
"ygo"
,
"Android command initJavaBridge posX=%d, posY=%d"
,
posX
,
posY
);
__android_log_print
(
ANDROID_LOG_INFO
,
"ygo"
,
"Android command initJavaBridge"
);
return
core
::
position2di
((
int
)
posX
,
(
int
)
posY
);
}
}
InitOptions
*
getInitOptions
(
ANDROID_APP
app
)
{
InitOptions
*
getInitOptions
(
ANDROID_APP
app
)
{
...
@@ -868,13 +859,8 @@ void toggleOverlayView(ANDROID_APP app, bool pShow) {
...
@@ -868,13 +859,8 @@ void toggleOverlayView(ANDROID_APP app, bool pShow) {
jni
->
DeleteLocalRef
(
ClassNativeActivity
);
jni
->
DeleteLocalRef
(
ClassNativeActivity
);
app
->
activity
->
vm
->
DetachCurrentThread
();
app
->
activity
->
vm
->
DetachCurrentThread
();
}
}
static
bool
test
=
false
;
void
process_input
(
ANDROID_APP
app
,
void
process_input
(
ANDROID_APP
app
,
struct
android_poll_source
*
source
)
{
struct
android_poll_source
*
source
)
{
if
(
test
==
false
)
{
test
=
true
;
ALOGD
(
"inputQueue:%lld"
,
(
jlong
)
app
->
inputQueue
);
}
AInputEvent
*
event
=
NULL
;
AInputEvent
*
event
=
NULL
;
if
(
AInputQueue_getEvent
(
app
->
inputQueue
,
&
event
)
>=
0
)
{
if
(
AInputQueue_getEvent
(
app
->
inputQueue
,
&
event
)
>=
0
)
{
int
type
=
AInputEvent_getType
(
event
);
int
type
=
AInputEvent_getType
(
event
);
...
@@ -912,10 +898,6 @@ void onGameExit(ANDROID_APP app){
...
@@ -912,10 +898,6 @@ void onGameExit(ANDROID_APP app){
}
}
s32
handleInput
(
ANDROID_APP
app
,
AInputEvent
*
androidEvent
)
{
s32
handleInput
(
ANDROID_APP
app
,
AInputEvent
*
androidEvent
)
{
if
(
test
==
false
)
{
test
=
true
;
ALOGD
(
"inputQueue:%lld"
,
(
jlong
)
app
->
inputQueue
);
}
IrrlichtDevice
*
device
=
(
IrrlichtDevice
*
)
app
->
userData
;
IrrlichtDevice
*
device
=
(
IrrlichtDevice
*
)
app
->
userData
;
s32
Status
=
0
;
s32
Status
=
0
;
...
...
libcore/android/android_tools.h
View file @
a57e52e0
...
@@ -126,7 +126,7 @@ extern void toggleGlobalIME(ANDROID_APP app, bool pShow);
...
@@ -126,7 +126,7 @@ extern void toggleGlobalIME(ANDROID_APP app, bool pShow);
extern
void
toggleIME
(
ANDROID_APP
app
,
bool
pShow
,
const
char
*
hint
);
extern
void
toggleIME
(
ANDROID_APP
app
,
bool
pShow
,
const
char
*
hint
);
//Init Java Irrlicht world.
//Init Java Irrlicht world.
extern
core
::
position2di
initJavaBridge
(
ANDROID_APP
app
,
void
*
handle
);
extern
void
initJavaBridge
(
ANDROID_APP
app
,
void
*
handle
);
//Cause a haptic feedback.
//Cause a haptic feedback.
extern
void
perfromHapticFeedback
(
ANDROID_APP
app
);
extern
void
perfromHapticFeedback
(
ANDROID_APP
app
);
...
...
libcore/jni/cn_garymb_ygomobile_core_IrrlichtBridge.cpp
View file @
a57e52e0
...
@@ -294,14 +294,6 @@ static void* join_game_thread(void* param) {
...
@@ -294,14 +294,6 @@ static void* join_game_thread(void* param) {
}
}
}
}
JNIEXPORT
void
JNICALL
Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetInputFix
(
JNIEnv
*
env
,
jclass
clazz
,
jlong
handle
,
jint
x
,
jint
y
)
{
if
(
ygo
::
mainGame
)
{
ALOGD
(
"setInputFix posX=%d, posY=%d"
,
x
,
y
);
ygo
::
mainGame
->
setPositionFix
(
core
::
position2di
(
x
,
y
));
}
}
static
void
*
cancel_chain_thread
(
void
*
param
)
{
static
void
*
cancel_chain_thread
(
void
*
param
)
{
IrrlichtDevice
*
device
=
(
IrrlichtDevice
*
)
param
;
IrrlichtDevice
*
device
=
(
IrrlichtDevice
*
)
param
;
irr
::
os
::
Printer
::
log
(
"before send cancel chain"
);
irr
::
os
::
Printer
::
log
(
"before send cancel chain"
);
...
...
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
View file @
a57e52e0
...
@@ -19,6 +19,7 @@ import android.os.Handler;
...
@@ -19,6 +19,7 @@ import android.os.Handler;
import
android.os.PowerManager
;
import
android.os.PowerManager
;
import
android.os.Process
;
import
android.os.Process
;
import
android.util.Log
;
import
android.util.Log
;
import
android.util.Size
;
import
android.view.Gravity
;
import
android.view.Gravity
;
import
android.view.HapticFeedbackConstants
;
import
android.view.HapticFeedbackConstants
;
import
android.view.InputQueue
;
import
android.view.InputQueue
;
...
@@ -38,6 +39,7 @@ import java.util.Arrays;
...
@@ -38,6 +39,7 @@ import java.util.Arrays;
import
cn.garymb.ygodata.YGOGameOptions
;
import
cn.garymb.ygodata.YGOGameOptions
;
import
cn.garymb.ygomobile.controller.InputQueueCompat
;
import
cn.garymb.ygomobile.controller.InputQueueCompat
;
import
cn.garymb.ygomobile.controller.NetworkController
;
import
cn.garymb.ygomobile.controller.NetworkController
;
import
cn.garymb.ygomobile.core.GameActivity
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.lib.R
;
import
cn.garymb.ygomobile.lib.R
;
import
cn.garymb.ygomobile.utils.FullScreenUtils
;
import
cn.garymb.ygomobile.utils.FullScreenUtils
;
...
@@ -52,7 +54,7 @@ import static cn.garymb.ygomobile.core.IrrlichtBridge.ACTION_SHARE_FILE;
...
@@ -52,7 +54,7 @@ import static cn.garymb.ygomobile.core.IrrlichtBridge.ACTION_SHARE_FILE;
/**
/**
* @author mabin
* @author mabin
*/
*/
public
class
YGOMobileActivity
extends
Nativ
eActivity
implements
public
class
YGOMobileActivity
extends
Gam
eActivity
implements
IrrlichtBridge
.
IrrlichtHost
,
IrrlichtBridge
.
IrrlichtHost
,
View
.
OnClickListener
,
View
.
OnClickListener
,
PopupWindow
.
OnDismissListener
,
PopupWindow
.
OnDismissListener
,
...
@@ -78,23 +80,14 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -78,23 +80,14 @@ public class YGOMobileActivity extends NativeActivity implements
private
NetworkController
mNetController
;
private
NetworkController
mNetController
;
private
volatile
boolean
mOverlayShowRequest
=
false
;
private
volatile
boolean
mOverlayShowRequest
=
false
;
private
volatile
int
mCompatGUIMode
;
private
volatile
int
mCompatGUIMode
;
private
static
int
sChainControlXPostion
=
-
1
;
//
private static int sChainControlXPostion = -1;
private
static
int
sChainControlYPostion
=
-
1
;
//
private static int sChainControlYPostion = -1;
private
GameApplication
mApp
;
private
GameApplication
mApp
;
private
Handler
handler
=
new
Handler
();
private
FullScreenUtils
mFullScreenUtils
;
private
FullScreenUtils
mFullScreenUtils
;
private
volatile
int
mPositionX
,
mPositionY
;
private
FrameLayout
mLayout
;
private
SurfaceView
mSurfaceView
;
private
boolean
replaced
=
false
;
private
static
boolean
USE_SURFACE
=
true
;
private
String
[]
mArgV
;
private
String
[]
mArgV
;
private
boolean
onGameExiting
;
private
boolean
onGameExiting
;
//尝试调准触摸事件
private
static
final
boolean
USE_MY_INPUT
=
true
;
private
InputQueueCompat
inputQueueCompat
;
// public static int notchHeight;
private
GameApplication
app
()
{
private
GameApplication
app
()
{
if
(
mApp
==
null
)
{
if
(
mApp
==
null
)
{
...
@@ -111,29 +104,22 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -111,29 +104,22 @@ public class YGOMobileActivity extends NativeActivity implements
return
mApp
;
return
mApp
;
}
}
@SuppressWarnings
(
"WrongConstant"
)
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
initBeforeOnCreate
()
{
if
(
USE_SURFACE
)
{
mSurfaceView
=
new
SurfaceView
(
this
);
}
if
(
USE_MY_INPUT
)
{
inputQueueCompat
=
new
InputQueueCompat
();
if
(!
inputQueueCompat
.
isValid
())
{
inputQueueCompat
=
null
;
}
}
mFullScreenUtils
=
new
FullScreenUtils
(
this
,
app
().
isImmerSiveMode
());
mFullScreenUtils
=
new
FullScreenUtils
(
this
,
app
().
isImmerSiveMode
());
mFullScreenUtils
.
fullscreen
();
mFullScreenUtils
.
fullscreen
();
mFullScreenUtils
.
onCreate
();
mFullScreenUtils
.
onCreate
();
//argv
//argv
mArgV
=
IrrlichtBridge
.
getArgs
(
getIntent
());
mArgV
=
IrrlichtBridge
.
getArgs
(
getIntent
());
//
//
super
.
onCreate
(
savedInstanceState
);
Log
.
e
(
"YGOStarter"
,
"跳转完成"
+
System
.
currentTimeMillis
());
if
(
sChainControlXPostion
<
0
)
{
initPostion
();
}
}
@Override
protected
void
initAfterOnCreate
()
{
Log
.
e
(
"YGOStarter"
,
"跳转完成"
+
System
.
currentTimeMillis
());
// if (sChainControlXPostion < 0) {
// initPostion();
// }
if
(
app
().
isLockSreenOrientation
())
{
if
(
app
().
isLockSreenOrientation
())
{
setRequestedOrientation
(
ActivityInfo
.
SCREEN_ORIENTATION_LANDSCAPE
);
setRequestedOrientation
(
ActivityInfo
.
SCREEN_ORIENTATION_LANDSCAPE
);
}
}
...
@@ -180,14 +166,14 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -180,14 +166,14 @@ public class YGOMobileActivity extends NativeActivity implements
}
}
private
void
initPostion
()
{
private
void
initPostion
()
{
final
Resources
res
=
getResources
();
//
final Resources res = getResources();
sChainControlXPostion
=
(
int
)
(
CHAIN_CONTROL_PANEL_X_POSITION_LEFT_EDGE
*
app
()
//
sChainControlXPostion = (int) (CHAIN_CONTROL_PANEL_X_POSITION_LEFT_EDGE * app()
.
getXScale
());
//
.getXScale());
sChainControlYPostion
=
(
int
)
(
app
().
getSmallerSize
()
//
sChainControlYPostion = (int) (app().getSmallerSize()
-
CHAIN_CONTROL_PANEL_Y_REVERT_POSITION
//
- CHAIN_CONTROL_PANEL_Y_REVERT_POSITION
*
app
().
getYScale
()
-
(
res
//
* app().getYScale() - (res
.
getDimensionPixelSize
(
R
.
dimen
.
chain_control_button_height
)
*
2
+
res
//
.getDimensionPixelSize(R.dimen.chain_control_button_height) * 2 + res
.
getDimensionPixelSize
(
R
.
dimen
.
chain_control_margin
)));
//
.getDimensionPixelSize(R.dimen.chain_control_margin)));
}
}
@Override
@Override
...
@@ -196,11 +182,6 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -196,11 +182,6 @@ public class YGOMobileActivity extends NativeActivity implements
handleExternalCommand
(
intent
);
handleExternalCommand
(
intent
);
}
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
}
private
void
handleExternalCommand
(
Intent
intent
)
{
private
void
handleExternalCommand
(
Intent
intent
)
{
YGOGameOptions
options
=
intent
YGOGameOptions
options
=
intent
.
getParcelableExtra
(
YGOGameOptions
.
YGO_GAME_OPTIONS_BUNDLE_KEY
);
.
getParcelableExtra
(
YGOGameOptions
.
YGO_GAME_OPTIONS_BUNDLE_KEY
);
...
@@ -222,18 +203,15 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -222,18 +203,15 @@ public class YGOMobileActivity extends NativeActivity implements
}
}
private
void
fullscreen
()
{
private
void
fullscreen
()
{
//如果是沉浸模式
//如果是沉浸模式
if
(
app
().
isImmerSiveMode
())
{
if
(
app
().
isImmerSiveMode
())
{
mFullScreenUtils
.
fullscreen
();
mFullScreenUtils
.
fullscreen
();
app
().
attachGame
(
this
);
app
().
attachGame
(
this
);
if
(
USE_SURFACE
)
{
changeGameSize
();
}
}
}
}
}
private
int
[]
getGameSize
()
{
@Override
protected
Size
getGameWindowSize
()
{
//调整padding
//调整padding
float
xScale
=
app
().
getXScale
();
float
xScale
=
app
().
getXScale
();
float
yScale
=
app
().
getYScale
();
float
yScale
=
app
().
getYScale
();
...
@@ -245,88 +223,13 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -245,88 +223,13 @@ public class YGOMobileActivity extends NativeActivity implements
+
", surface="
+
w
+
"x"
+
h
+
", surface="
+
w
+
"x"
+
h
+
", screen="
+
sw
+
"x"
+
sh
+
", screen="
+
sw
+
"x"
+
sh
+
", xScale="
+
xScale
+
",yScale="
+
yScale
);
+
", xScale="
+
xScale
+
",yScale="
+
yScale
);
return
new
int
[]{
w
,
h
}
;
return
new
Size
(
w
,
h
)
;
}
}
@Override
public
int
getPositionX
()
{
synchronized
(
this
)
{
return
mPositionX
;
}
}
@Override
public
int
getPositionY
()
{
synchronized
(
this
)
{
return
mPositionY
;
}
}
@SuppressLint
(
"ClickableViewAccessibility"
)
@Override
@Override
public
void
setContentView
(
View
view
)
{
public
void
setContentView
(
View
view
)
{
int
[]
size
=
getGameSize
();
super
.
setContentView
(
view
);
int
w
=
size
[
0
];
int
h
=
size
[
1
];
mLayout
=
new
FrameLayout
(
this
);
FrameLayout
.
LayoutParams
lp
=
new
FrameLayout
.
LayoutParams
(
w
,
h
);
mLayout
.
setBackgroundColor
(
Color
.
BLACK
);
lp
.
gravity
=
Gravity
.
CENTER
;
if
(
USE_SURFACE
)
{
mLayout
.
addView
(
mSurfaceView
,
lp
);
mLayout
.
addView
(
view
,
lp
);
super
.
setContentView
(
mLayout
);
app
().
attachGame
(
this
);
app
().
attachGame
(
this
);
changeGameSize
();
getWindow
().
takeSurface
(
null
);
if
(
USE_MY_INPUT
&&
inputQueueCompat
!=
null
)
{
getWindow
().
takeInputQueue
(
null
);
}
replaced
=
true
;
mSurfaceView
.
getHolder
().
addCallback
(
this
);
mSurfaceView
.
requestFocus
();
getWindow
().
setGravity
(
Gravity
.
CENTER
);
if
(
USE_MY_INPUT
&&
inputQueueCompat
!=
null
)
{
Log
.
e
(
IrrlichtBridge
.
TAG
,
"use java input queue:"
+
inputQueueCompat
.
getNativePtr
());
mSurfaceView
.
setOnTouchListener
((
v
,
event
)
->
{
if
(
inputQueueCompat
!=
null
)
{
inputQueueCompat
.
sendInputEvent
(
event
,
v
,
true
);
}
return
true
;
});
}
}
else
{
mLayout
.
addView
(
view
,
lp
);
getWindow
().
setGravity
(
Gravity
.
CENTER
);
super
.
setContentView
(
mLayout
);
}
}
private
void
changeGameSize
()
{
boolean
update
=
false
;
if
(
USE_MY_INPUT
&&
inputQueueCompat
!=
null
)
{
//Ignore
update
=
true
;
mPositionX
=
0
;
mPositionY
=
0
;
}
else
{
//游戏大小
int
[]
size
=
getGameSize
();
int
w
=
(
int
)
app
().
getScreenHeight
();
int
h
=
(
int
)
app
().
getScreenWidth
();
int
spX
=
(
int
)
((
w
-
size
[
0
])
/
2.0f
);
int
spY
=
(
int
)
((
h
-
size
[
1
])
/
2.0f
);
synchronized
(
this
)
{
if
(
spX
!=
mPositionX
||
spY
!=
mPositionY
)
{
mPositionX
=
spX
;
mPositionY
=
spY
;
update
=
true
;
}
}
}
if
(
update
)
{
IrrlichtBridge
.
setInputFix
(
mPositionX
,
mPositionY
);
}
}
}
private
void
initExtraView
()
{
private
void
initExtraView
()
{
...
@@ -348,15 +251,9 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -348,15 +251,9 @@ public class YGOMobileActivity extends NativeActivity implements
// Log.e("YGOMobileActivity","窗口变化"+hasFocus);
// Log.e("YGOMobileActivity","窗口变化"+hasFocus);
if
(
hasFocus
)
{
if
(
hasFocus
)
{
fullscreen
();
fullscreen
();
if
(
inputQueueCompat
!=
null
)
{
super
.
onInputQueueCreated
(
inputQueueCompat
.
getInputQueue
());
}
mContentView
.
setHapticFeedbackEnabled
(
true
);
mContentView
.
setHapticFeedbackEnabled
(
true
);
}
else
{
}
else
{
mContentView
.
setHapticFeedbackEnabled
(
false
);
mContentView
.
setHapticFeedbackEnabled
(
false
);
if
(
inputQueueCompat
!=
null
)
{
super
.
onInputQueueDestroyed
(
inputQueueCompat
.
getInputQueue
());
}
}
}
super
.
onWindowFocusChanged
(
hasFocus
);
super
.
onWindowFocusChanged
(
hasFocus
);
}
}
...
@@ -426,7 +323,7 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -426,7 +323,7 @@ public class YGOMobileActivity extends NativeActivity implements
@Override
@Override
public
void
toggleOverlayView
(
final
boolean
isShow
)
{
public
void
toggleOverlayView
(
final
boolean
isShow
)
{
if
(
mOverlayShowRequest
!=
isShow
)
{
if
(
mOverlayShowRequest
!=
isShow
)
{
handler
.
post
(
new
Runnable
()
{
runOnUiThread
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
mOverlayShowRequest
=
isShow
;
mOverlayShowRequest
=
isShow
;
...
@@ -453,7 +350,7 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -453,7 +350,7 @@ public class YGOMobileActivity extends NativeActivity implements
@Override
@Override
public
void
toggleIME
(
final
String
hint
,
final
boolean
isShow
)
{
public
void
toggleIME
(
final
String
hint
,
final
boolean
isShow
)
{
handler
.
post
(
new
Runnable
()
{
runOnUiThread
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
if
(
isShow
)
{
if
(
isShow
)
{
...
@@ -473,7 +370,7 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -473,7 +370,7 @@ public class YGOMobileActivity extends NativeActivity implements
@Override
@Override
public
void
showComboBoxCompat
(
final
String
[]
items
,
final
boolean
isShow
,
final
int
mode
)
{
public
void
showComboBoxCompat
(
final
String
[]
items
,
final
boolean
isShow
,
final
int
mode
)
{
handler
.
post
(
new
Runnable
()
{
runOnUiThread
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
mCompatGUIMode
=
mode
;
mCompatGUIMode
=
mode
;
...
@@ -490,7 +387,7 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -490,7 +387,7 @@ public class YGOMobileActivity extends NativeActivity implements
@Override
@Override
public
void
performHapticFeedback
()
{
public
void
performHapticFeedback
()
{
handler
.
post
(
new
Runnable
()
{
runOnUiThread
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
mContentView
.
performHapticFeedback
(
mContentView
.
performHapticFeedback
(
...
@@ -515,48 +412,6 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -515,48 +412,6 @@ public class YGOMobileActivity extends NativeActivity implements
IrrlichtBridge
.
sNativeHandle
=
nativeHandle
;
IrrlichtBridge
.
sNativeHandle
=
nativeHandle
;
}
}
@Override
public
void
surfaceCreated
(
SurfaceHolder
holder
)
{
if
(
USE_SURFACE
)
{
if
(!
replaced
)
{
return
;
}
// int[] size = getGameSize();
// holder.setFixedSize(size[0], size[1]);
}
super
.
surfaceCreated
(
holder
);
}
@Override
public
void
surfaceChanged
(
SurfaceHolder
holder
,
int
format
,
int
width
,
int
height
)
{
if
(
USE_SURFACE
)
{
if
(!
replaced
)
{
return
;
}
}
super
.
surfaceChanged
(
holder
,
format
,
width
,
height
);
}
@Override
public
void
surfaceDestroyed
(
SurfaceHolder
holder
)
{
if
(
USE_SURFACE
)
{
if
(!
replaced
)
{
return
;
}
}
super
.
surfaceDestroyed
(
holder
);
}
@Override
public
void
surfaceRedrawNeeded
(
SurfaceHolder
holder
)
{
if
(
USE_SURFACE
)
{
if
(!
replaced
)
{
return
;
}
}
super
.
surfaceRedrawNeeded
(
holder
);
}
@Override
@Override
public
void
shareFile
(
final
String
type
,
final
String
name
)
{
public
void
shareFile
(
final
String
type
,
final
String
name
)
{
//TODO 分享文件
//TODO 分享文件
...
@@ -577,29 +432,6 @@ public class YGOMobileActivity extends NativeActivity implements
...
@@ -577,29 +432,6 @@ public class YGOMobileActivity extends NativeActivity implements
}
}
});
});
}
}
//
// @Override
// public boolean onKeyDown(int keyCode, KeyEvent event) {
// if(inputQueueCompat != null) {
// if (keyCode == KeyEvent.KEYCODE_BACK) {
// inputQueueCompat.sendInputEvent(event, this, true);
// return true;
// }
// }
// return super.onKeyDown(keyCode, event);
// }
//
// @Override
// public boolean onKeyUp(int keyCode, KeyEvent event) {
// if(inputQueueCompat != null) {
// if (keyCode == KeyEvent.KEYCODE_BACK) {
// inputQueueCompat.sendInputEvent(event, this, true);
// return true;
// }
// }
// return super.onKeyUp(keyCode, event);
// }
@Override
@Override
public
void
onBackPressed
()
{
public
void
onBackPressed
()
{
...
...
libcore/src/main/java/cn/garymb/ygomobile/core/GameActivity.java
0 → 100644
View file @
a57e52e0
package
cn.garymb.ygomobile.core
;
import
android.annotation.SuppressLint
;
import
android.app.NativeActivity
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.util.Size
;
import
android.view.Gravity
;
import
android.view.SurfaceHolder
;
import
android.view.SurfaceView
;
import
android.view.View
;
import
android.widget.FrameLayout
;
import
cn.garymb.ygomobile.controller.InputQueueCompat
;
public
abstract
class
GameActivity
extends
NativeActivity
{
protected
FrameLayout
mLayout
;
protected
SurfaceView
mSurfaceView
;
private
boolean
replaced
=
false
;
//自定义surface,方便控制窗口大小
private
static
final
boolean
USE_SURFACE
=
true
;
//精准触摸事件
private
static
final
boolean
USE_MY_INPUT
=
true
;
protected
InputQueueCompat
inputQueueCompat
;
@Override
protected
final
void
onCreate
(
Bundle
savedInstanceState
)
{
if
(
USE_SURFACE
)
{
mSurfaceView
=
new
SurfaceView
(
this
);
}
if
(
USE_MY_INPUT
)
{
inputQueueCompat
=
new
InputQueueCompat
();
if
(!
inputQueueCompat
.
isValid
())
{
inputQueueCompat
=
null
;
}
}
initBeforeOnCreate
();
super
.
onCreate
(
savedInstanceState
);
initAfterOnCreate
();
}
@Override
public
void
onWindowFocusChanged
(
boolean
hasFocus
)
{
if
(
hasFocus
)
{
if
(
inputQueueCompat
!=
null
)
{
super
.
onInputQueueCreated
(
inputQueueCompat
.
getInputQueue
());
}
}
else
{
if
(
inputQueueCompat
!=
null
)
{
super
.
onInputQueueDestroyed
(
inputQueueCompat
.
getInputQueue
());
}
}
super
.
onWindowFocusChanged
(
hasFocus
);
}
@SuppressLint
(
"ClickableViewAccessibility"
)
@Override
public
void
setContentView
(
View
view
)
{
Size
size
=
getGameWindowSize
();
mLayout
=
new
FrameLayout
(
this
);
FrameLayout
.
LayoutParams
lp
=
new
FrameLayout
.
LayoutParams
(
size
.
getWidth
(),
size
.
getHeight
());
// mLayout.setBackgroundColor(Color.BLACK);
lp
.
gravity
=
Gravity
.
CENTER
;
if
(
USE_SURFACE
)
{
mLayout
.
addView
(
mSurfaceView
,
lp
);
mLayout
.
addView
(
view
,
lp
);
super
.
setContentView
(
mLayout
);
// app().attachGame(this);
// changeGameSize();
getWindow
().
takeSurface
(
null
);
if
(
USE_MY_INPUT
&&
inputQueueCompat
!=
null
)
{
getWindow
().
takeInputQueue
(
null
);
}
replaced
=
true
;
mSurfaceView
.
getHolder
().
addCallback
(
this
);
mSurfaceView
.
requestFocus
();
getWindow
().
setGravity
(
Gravity
.
CENTER
);
if
(
USE_MY_INPUT
&&
inputQueueCompat
!=
null
)
{
Log
.
d
(
IrrlichtBridge
.
TAG
,
"use java input queue:"
+
inputQueueCompat
.
getNativePtr
());
mSurfaceView
.
setOnTouchListener
((
v
,
event
)
->
{
if
(
inputQueueCompat
!=
null
)
{
inputQueueCompat
.
sendInputEvent
(
event
,
v
,
true
);
}
return
true
;
});
}
}
else
{
mLayout
.
addView
(
view
,
lp
);
getWindow
().
setGravity
(
Gravity
.
CENTER
);
super
.
setContentView
(
mLayout
);
}
}
@Override
public
void
surfaceCreated
(
SurfaceHolder
holder
)
{
if
(
USE_SURFACE
)
{
if
(!
replaced
)
{
return
;
}
}
super
.
surfaceCreated
(
holder
);
}
@Override
public
void
surfaceChanged
(
SurfaceHolder
holder
,
int
format
,
int
width
,
int
height
)
{
if
(
USE_SURFACE
)
{
if
(!
replaced
)
{
return
;
}
}
super
.
surfaceChanged
(
holder
,
format
,
width
,
height
);
}
@Override
public
void
surfaceDestroyed
(
SurfaceHolder
holder
)
{
if
(
USE_SURFACE
)
{
if
(!
replaced
)
{
return
;
}
}
super
.
surfaceDestroyed
(
holder
);
}
@Override
public
void
surfaceRedrawNeeded
(
SurfaceHolder
holder
)
{
if
(
USE_SURFACE
)
{
if
(!
replaced
)
{
return
;
}
}
super
.
surfaceRedrawNeeded
(
holder
);
}
//
// @Override
// public boolean onKeyDown(int keyCode, KeyEvent event) {
// if(inputQueueCompat != null) {
// if (keyCode == KeyEvent.KEYCODE_BACK) {
// inputQueueCompat.sendInputEvent(event, this, true);
// return true;
// }
// }
// return super.onKeyDown(keyCode, event);
// }
//
// @Override
// public boolean onKeyUp(int keyCode, KeyEvent event) {
// if(inputQueueCompat != null) {
// if (keyCode == KeyEvent.KEYCODE_BACK) {
// inputQueueCompat.sendInputEvent(event, this, true);
// return true;
// }
// }
// return super.onKeyUp(keyCode, event);
// }
protected
abstract
Size
getGameWindowSize
();
protected
abstract
void
initBeforeOnCreate
();
protected
abstract
void
initAfterOnCreate
();
}
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
View file @
a57e52e0
...
@@ -82,8 +82,6 @@ public final class IrrlichtBridge {
...
@@ -82,8 +82,6 @@ public final class IrrlichtBridge {
private
static
native
void
nativeJoinGame
(
long
handle
,
ByteBuffer
buffer
,
int
length
);
private
static
native
void
nativeJoinGame
(
long
handle
,
ByteBuffer
buffer
,
int
length
);
private
static
native
void
nativeSetInputFix
(
long
handle
,
int
x
,
int
y
);
private
static
final
boolean
DEBUG
=
false
;
private
static
final
boolean
DEBUG
=
false
;
public
static
void
setArgs
(
Intent
intent
,
String
[]
args
)
{
public
static
void
setArgs
(
Intent
intent
,
String
[]
args
)
{
...
@@ -155,10 +153,6 @@ public final class IrrlichtBridge {
...
@@ -155,10 +153,6 @@ public final class IrrlichtBridge {
}
}
}
}
public
static
void
setInputFix
(
int
x
,
int
y
)
{
nativeSetInputFix
(
sNativeHandle
,
x
,
y
);
}
public
static
void
cancelChain
()
{
public
static
void
cancelChain
()
{
nativeCancelChain
(
sNativeHandle
);
nativeCancelChain
(
sNativeHandle
);
}
}
...
@@ -244,10 +238,6 @@ public final class IrrlichtBridge {
...
@@ -244,10 +238,6 @@ public final class IrrlichtBridge {
void
setNativeHandle
(
long
nativeHandle
);
void
setNativeHandle
(
long
nativeHandle
);
int
getPositionX
();
int
getPositionY
();
void
onGameExit
();
void
onGameExit
();
}
}
}
}
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