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
Expand all
Hide 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 {
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_
void
Game
::
stopBGM
()
{
...
...
@@ -123,9 +114,7 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
if
(
!
android
::
perfromTrick
(
app
))
{
return
false
;
}
core
::
position2di
appPosition
=
android
::
initJavaBridge
(
app
,
device
);
setPositionFix
(
appPosition
);
device
->
setProcessReceiver
(
this
);
android
::
initJavaBridge
(
app
,
device
);
app
->
onInputEvent
=
android
::
handleInput
;
ILogger
*
logger
=
device
->
getLogger
();
...
...
@@ -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
->
getCloseButton
()
->
setVisible
(
false
);
wDMQuery
->
setVisible
(
false
);
wDMQuery
->
setDraggable
(
false
);
ChangeToIGUIImageWindow
(
wDMQuery
,
bgDMQuery
,
imageManager
->
tDialog_L
);
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
);
...
...
Classes/gframe/game.h
View file @
a57e52e0
...
...
@@ -129,7 +129,7 @@ struct FadingUnit {
irr
::
core
::
vector2di
fadingDiff
;
};
class
Game
:
IProcessEventReceiver
{
class
Game
{
public:
#ifdef _IRR_ANDROID_PLATFORM_
...
...
@@ -662,27 +662,6 @@ public:
Signal
externalSignal
;
static
void
onHandleAndroidCommand
(
ANDROID_APP
app
,
int32_t
cmd
);
#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
;
...
...
Classes/gframe/gframe.cpp
View file @
a57e52e0
...
...
@@ -41,7 +41,6 @@ int GetListBoxIndex(IGUIListBox* listbox, const wchar_t * target){
}
void
android_main
(
ANDROID_APP
app
)
{
app
->
inputPollSource
.
process
=
android
::
process_input
;
app_dummy
();
#else
int
main
(
int
argc
,
char
*
argv
[])
{
#endif
...
...
libcore/android/android_tools.cpp
View file @
a57e52e0
...
...
@@ -749,9 +749,9 @@ void toggleGlobalIME(ANDROID_APP app, bool pShow) {
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
)
return
core
::
position2di
(
0
,
0
)
;
return
;
JNIEnv
*
jni
=
nullptr
;
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
NULL
);
jobject
lNativeActivity
=
app
->
activity
->
clazz
;
...
...
@@ -760,18 +760,9 @@ core::position2di initJavaBridge(ANDROID_APP app, void* handle) {
"setNativeHandle"
,
"(J)V"
);
jlong
code
=
(
jlong
)
handle
;
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
);
app
->
activity
->
vm
->
DetachCurrentThread
();
__android_log_print
(
ANDROID_LOG_INFO
,
"ygo"
,
"Android command initJavaBridge posX=%d, posY=%d"
,
posX
,
posY
);
return
core
::
position2di
((
int
)
posX
,
(
int
)
posY
);
__android_log_print
(
ANDROID_LOG_INFO
,
"ygo"
,
"Android command initJavaBridge"
);
}
InitOptions
*
getInitOptions
(
ANDROID_APP
app
)
{
...
...
@@ -868,13 +859,8 @@ void toggleOverlayView(ANDROID_APP app, bool pShow) {
jni
->
DeleteLocalRef
(
ClassNativeActivity
);
app
->
activity
->
vm
->
DetachCurrentThread
();
}
static
bool
test
=
false
;
void
process_input
(
ANDROID_APP
app
,
struct
android_poll_source
*
source
)
{
if
(
test
==
false
)
{
test
=
true
;
ALOGD
(
"inputQueue:%lld"
,
(
jlong
)
app
->
inputQueue
);
}
AInputEvent
*
event
=
NULL
;
if
(
AInputQueue_getEvent
(
app
->
inputQueue
,
&
event
)
>=
0
)
{
int
type
=
AInputEvent_getType
(
event
);
...
...
@@ -912,10 +898,6 @@ void onGameExit(ANDROID_APP app){
}
s32
handleInput
(
ANDROID_APP
app
,
AInputEvent
*
androidEvent
)
{
if
(
test
==
false
)
{
test
=
true
;
ALOGD
(
"inputQueue:%lld"
,
(
jlong
)
app
->
inputQueue
);
}
IrrlichtDevice
*
device
=
(
IrrlichtDevice
*
)
app
->
userData
;
s32
Status
=
0
;
...
...
libcore/android/android_tools.h
View file @
a57e52e0
...
...
@@ -126,7 +126,7 @@ extern void toggleGlobalIME(ANDROID_APP app, bool pShow);
extern
void
toggleIME
(
ANDROID_APP
app
,
bool
pShow
,
const
char
*
hint
);
//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.
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) {
}
}
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
)
{
IrrlichtDevice
*
device
=
(
IrrlichtDevice
*
)
param
;
irr
::
os
::
Printer
::
log
(
"before send cancel chain"
);
...
...
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
View file @
a57e52e0
This diff is collapsed.
Click to expand it.
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 {
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
;
public
static
void
setArgs
(
Intent
intent
,
String
[]
args
)
{
...
...
@@ -155,10 +153,6 @@ public final class IrrlichtBridge {
}
}
public
static
void
setInputFix
(
int
x
,
int
y
)
{
nativeSetInputFix
(
sNativeHandle
,
x
,
y
);
}
public
static
void
cancelChain
()
{
nativeCancelChain
(
sNativeHandle
);
}
...
...
@@ -244,10 +238,6 @@ public final class IrrlichtBridge {
void
setNativeHandle
(
long
nativeHandle
);
int
getPositionX
();
int
getPositionY
();
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