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
99c7ea84
Commit
99c7ea84
authored
Sep 25, 2021
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GameActivity
parent
88049212
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
168 additions
and
25 deletions
+168
-25
libcore/android/android_tools.h
libcore/android/android_tools.h
+2
-6
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/core/GameActivity.java
.../src/main/java/cn/garymb/ygomobile/core/GameActivity.java
+165
-0
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
...rc/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
+1
-11
No files found.
libcore/android/android_tools.h
View file @
99c7ea84
...
@@ -99,7 +99,7 @@ extern float getScreenWidth(ANDROID_APP app);
...
@@ -99,7 +99,7 @@ extern float getScreenWidth(ANDROID_APP app);
extern
float
getScreenHeight
(
ANDROID_APP
app
);
extern
float
getScreenHeight
(
ANDROID_APP
app
);
extern
void
OnShareFile
(
ANDROID_APP
app
,
const
char
*
title
,
const
char
*
ext
);
extern
void
OnShareFile
(
ANDROID_APP
app
,
const
char
*
_type
,
const
char
*
name
);
// Get SDCard path.
// Get SDCard path.
extern
irr
::
io
::
path
getExternalStorageDir
(
ANDROID_APP
app
);
extern
irr
::
io
::
path
getExternalStorageDir
(
ANDROID_APP
app
);
...
@@ -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
);
...
@@ -186,10 +186,6 @@ extern bool getFontAntiAlias(ANDROID_APP app);
...
@@ -186,10 +186,6 @@ extern bool getFontAntiAlias(ANDROID_APP app);
extern
void
showAndroidComboBoxCompat
(
ANDROID_APP
app
,
bool
pShow
,
extern
void
showAndroidComboBoxCompat
(
ANDROID_APP
app
,
bool
pShow
,
char
**
pContents
,
int
count
,
int
mode
=
0
);
char
**
pContents
,
int
count
,
int
mode
=
0
);
/* android event handlers*/
extern
void
process_input
(
ANDROID_APP
app
,
struct
android_poll_source
*
source
);
extern
s32
handleInput
(
ANDROID_APP
app
,
AInputEvent
*
androidEvent
);
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
);
...
...
libcore/jni/cn_garymb_ygomobile_core_IrrlichtBridge.cpp
View file @
99c7ea84
...
@@ -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/core/GameActivity.java
0 → 100644
View file @
99c7ea84
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.MotionEvent
;
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
)
->
{
onSurfaceTouch
(
v
,
event
);
return
true
;
});
}
}
else
{
mLayout
.
addView
(
view
,
lp
);
getWindow
().
setGravity
(
Gravity
.
CENTER
);
super
.
setContentView
(
mLayout
);
}
}
protected
void
onSurfaceTouch
(
View
v
,
MotionEvent
event
){
if
(
inputQueueCompat
!=
null
)
{
inputQueueCompat
.
sendInputEvent
(
event
,
v
,
true
);
}
}
@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 @
99c7ea84
...
@@ -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
);
}
}
...
@@ -231,7 +225,7 @@ public final class IrrlichtBridge {
...
@@ -231,7 +225,7 @@ public final class IrrlichtBridge {
void
showComboBoxCompat
(
String
[]
items
,
boolean
isShow
,
int
mode
);
void
showComboBoxCompat
(
String
[]
items
,
boolean
isShow
,
int
mode
);
void
shareFile
(
String
t
itle
,
String
ext
);
void
shareFile
(
String
t
ype
,
String
name
);
void
performHapticFeedback
();
void
performHapticFeedback
();
...
@@ -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