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
8664e10a
Commit
8664e10a
authored
Oct 04, 2019
by
kenan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
坐标校准
parent
bd22e195
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
136 additions
and
102 deletions
+136
-102
Classes/gframe/event_handler.cpp
Classes/gframe/event_handler.cpp
+2
-2
Classes/gframe/game.cpp
Classes/gframe/game.cpp
+17
-2
Classes/gframe/game.h
Classes/gframe/game.h
+24
-3
irrlicht/include/IEventReceiver.h
irrlicht/include/IEventReceiver.h
+9
-0
irrlicht/include/IrrlichtDevice.h
irrlicht/include/IrrlichtDevice.h
+2
-0
irrlicht/source/Irrlicht/CIrrDeviceStub.cpp
irrlicht/source/Irrlicht/CIrrDeviceStub.cpp
+6
-1
irrlicht/source/Irrlicht/CIrrDeviceStub.h
irrlicht/source/Irrlicht/CIrrDeviceStub.h
+4
-0
libcore/android/android_tools.cpp
libcore/android/android_tools.cpp
+13
-4
libcore/android/android_tools.h
libcore/android/android_tools.h
+5
-1
libcore/jni/cn_garymb_ygomobile_core_IrrlichtBridge.cpp
libcore/jni/cn_garymb_ygomobile_core_IrrlichtBridge.cpp
+9
-0
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
.../src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
+34
-88
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
...rc/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
+11
-1
No files found.
Classes/gframe/event_handler.cpp
View file @
8664e10a
...
...
@@ -1654,7 +1654,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case
irr
:
:
EMIE_LMOUSE_PRESSED_DOWN
:
{
if
(
!
mainGame
->
dInfo
.
isStarted
)
break
;
if
(
mainGame
->
gameConf
.
control_mode
==
1
&&
event
.
MouseInput
.
X
>
300
)
{
if
(
mainGame
->
gameConf
.
control_mode
==
1
&&
event
.
MouseInput
.
X
>
300
*
mainGame
->
xScale
)
{
mainGame
->
always_chain
=
event
.
MouseInput
.
isLeftPressed
();
mainGame
->
ignore_chain
=
false
;
mainGame
->
chain_when_avail
=
false
;
...
...
@@ -1665,7 +1665,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case
irr
:
:
EMIE_RMOUSE_PRESSED_DOWN
:
{
if
(
!
mainGame
->
dInfo
.
isStarted
)
break
;
if
(
mainGame
->
gameConf
.
control_mode
==
1
&&
event
.
MouseInput
.
X
>
300
)
{
if
(
mainGame
->
gameConf
.
control_mode
==
1
&&
event
.
MouseInput
.
X
>
300
*
mainGame
->
xScale
)
{
mainGame
->
ignore_chain
=
event
.
MouseInput
.
isRightPressed
();
mainGame
->
always_chain
=
false
;
mainGame
->
chain_when_avail
=
false
;
...
...
Classes/gframe/game.cpp
View file @
8664e10a
...
...
@@ -15,6 +15,7 @@
#include <android/CAndroidGUIEditBox.h>
#include <android/CAndroidGUIComboBox.h>
#include <android/CAndroidGUISkin.h>
#include <Android/CIrrDeviceAndroid.h>
#include <COGLES2ExtensionHandler.h>
#include <COGLESExtensionHandler.h>
#include <COGLES2Driver.h>
...
...
@@ -25,7 +26,18 @@ const unsigned short PRO_VERSION = 0x134B;
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
);
// __android_log_print(ANDROID_LOG_DEBUG, "ygo", "Android comman process %d,%d -> %d,%d", x, y,
// event.MouseInput.X, event.MouseInput.Y);
}
}
#ifdef _IRR_ANDROID_PLATFORM_
bool
Game
::
Initialize
(
ANDROID_APP
app
)
{
...
...
@@ -80,10 +92,13 @@ bool Game::Initialize() {
if
(
!
device
)
return
false
;
#ifdef _IRR_ANDROID_PLATFORM_
device
->
setProcessReceiver
(
this
);
if
(
!
android
::
perfromTrick
(
app
))
{
return
false
;
}
android
::
initJavaBridge
(
app
,
device
);
core
::
position2di
appPosition
=
android
::
initJavaBridge
(
app
,
device
);
setPositionFix
(
appPosition
);
soundEffectPlayer
=
new
AndroidSoundEffectPlayer
(
app
);
soundEffectPlayer
->
setSEEnabled
(
options
->
isSoundEffectEnabled
());
app
->
onInputEvent
=
android
::
handleInput
;
...
...
Classes/gframe/game.h
View file @
8664e10a
...
...
@@ -107,7 +107,7 @@ struct FadingUnit {
irr
::
core
::
vector2di
fadingDiff
;
};
class
Game
{
class
Game
:
IProcessEventReceiver
{
public:
#ifdef _IRR_ANDROID_PLATFORM_
...
...
@@ -543,10 +543,31 @@ public:
irr
::
android
::
CustomShaderConstantSetCallBack
customShadersCallback
;
Signal
externalSignal
;
#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
;
}
...
...
irrlicht/include/IEventReceiver.h
View file @
8664e10a
...
...
@@ -539,6 +539,15 @@ public:
virtual
bool
OnEvent
(
const
SEvent
&
event
)
=
0
;
};
class
IProcessEventReceiver
{
public:
//! Destructor
virtual
~
IProcessEventReceiver
()
{}
virtual
void
process
(
SEvent
&
event
)
=
0
;
};
//! Information on a joystick, returned from @ref irr::IrrlichtDevice::activateJoysticks()
struct
SJoystickInfo
...
...
irrlicht/include/IrrlichtDevice.h
View file @
8664e10a
...
...
@@ -307,6 +307,8 @@ namespace irr
//! Get context manager
virtual
video
::
IContextManager
*
getContextManager
()
=
0
;
virtual
void
setProcessReceiver
(
IProcessEventReceiver
*
receiver
)
=
0
;
//! Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behavior.
/** When set to 0 no double- and tripleclicks will be generated.
\param timeMs maximal time in milliseconds for two consecutive clicks to be recognized as double click
...
...
irrlicht/source/Irrlicht/CIrrDeviceStub.cpp
View file @
8664e10a
...
...
@@ -224,10 +224,15 @@ u32 CIrrDeviceStub::checkSuccessiveClicks(s32 mouseX, s32 mouseY, EMOUSE_INPUT_E
//! send the event to the right receiver
bool
CIrrDeviceStub
::
postEventFromUser
(
const
SEvent
&
event
)
bool
CIrrDeviceStub
::
postEventFromUser
(
const
SEvent
&
_
event
)
{
SEvent
event
=
_event
;
bool
absorbed
=
false
;
if
(
ProcessReceiver
){
ProcessReceiver
->
process
(
event
);
}
if
(
UserReceiver
)
absorbed
=
UserReceiver
->
OnEvent
(
event
);
...
...
irrlicht/source/Irrlicht/CIrrDeviceStub.h
View file @
8664e10a
...
...
@@ -178,6 +178,9 @@ namespace irr
//! Resize the render window.
virtual
void
setWindowSize
(
const
irr
::
core
::
dimension2d
<
u32
>&
size
)
_IRR_OVERRIDE_
{}
virtual
void
setProcessReceiver
(
IProcessEventReceiver
*
receiver
)
_IRR_OVERRIDE_
{
ProcessReceiver
=
receiver
;
}
protected:
void
createGUIAndScene
();
...
...
@@ -200,6 +203,7 @@ namespace irr
ITimer
*
Timer
;
gui
::
ICursorControl
*
CursorControl
;
IEventReceiver
*
UserReceiver
;
IProcessEventReceiver
*
ProcessReceiver
;
CLogger
*
Logger
;
IOSOperator
*
Operator
;
IRandomizer
*
Randomizer
;
...
...
libcore/android/android_tools.cpp
View file @
8664e10a
...
...
@@ -703,20 +703,29 @@ void toggleGlobalIME(ANDROID_APP app, bool pShow) {
app
->
activity
->
vm
->
DetachCurrentThread
();
}
void
initJavaBridge
(
ANDROID_APP
app
,
void
*
handle
)
{
core
::
position2di
initJavaBridge
(
ANDROID_APP
app
,
void
*
handle
)
{
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
return
;
return
core
::
position2di
(
0
,
0
)
;
JNIEnv
*
jni
=
0
;
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
NULL
);
jobject
lNativeActivity
=
app
->
activity
->
clazz
;
jclass
ClassNativeActivity
=
jni
->
GetObjectClass
(
lNativeActivity
);
jmethodID
MethodSetHandle
=
jni
->
GetMethodID
(
ClassNativeActivity
,
"setNativeHandle"
,
"(I)V"
);
"setNativeHandle"
,
"(I)V"
);
jint
code
=
(
int
)
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
();
return
;
__android_log_print
(
ANDROID_LOG_INFO
,
"ygo"
,
"Android command initJavaBridge posX=%d, posY=%d"
,
posX
,
posY
);
return
core
::
position2di
((
int
)
posX
,
(
int
)
posY
);
}
InitOptions
*
getInitOptions
(
ANDROID_APP
app
)
{
...
...
libcore/android/android_tools.h
View file @
8664e10a
...
...
@@ -84,6 +84,10 @@ struct SDisplayMetrics {
irr
::
f32
xdpi
;
irr
::
f32
ydpi
;
};
typedef
struct
{
float
posX
;
float
posY
;
}
AppPosition
;
/* jni utils*/
// Access SDisplayMetrics
extern
float
getScreenWidth
(
ANDROID_APP
app
);
...
...
@@ -115,7 +119,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
void
initJavaBridge
(
ANDROID_APP
app
,
void
*
handle
);
extern
core
::
position2di
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 @
8664e10a
...
...
@@ -7,6 +7,7 @@
#include <Android/CIrrDeviceAndroid.h>
#include "../android/YGOGameOptions.h"
#include "../Classes/gframe/game.h"
#include <android/log.h>
using
namespace
irr
;
using
namespace
gui
;
...
...
@@ -293,6 +294,14 @@ static void* join_game_thread(void* param) {
}
}
JNIEXPORT
void
JNICALL
Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetInputFix
(
JNIEnv
*
env
,
jclass
clazz
,
jint
handle
,
jint
x
,
jint
y
)
{
if
(
ygo
::
mainGame
)
{
__android_log_print
(
ANDROID_LOG_INFO
,
"ygo"
,
"setInputFix posX=%d, posY=%d"
,
x
,
y
);
ygo
::
mainGame
->
setPositionFix
(
core
::
position2di
(
x
,
y
));
}
}
//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
)
{
...
...
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
View file @
8664e10a
...
...
@@ -14,14 +14,11 @@ import android.content.res.Resources;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.HandlerThread
;
import
android.os.PowerManager
;
import
android.util.Log
;
import
android.view.Gravity
;
import
android.view.HapticFeedbackConstants
;
import
android.view.InputQueue
;
import
android.view.KeyEvent
;
import
android.view.MotionEvent
;
import
android.view.SurfaceView
;
import
android.view.View
;
import
android.widget.FrameLayout
;
...
...
@@ -85,9 +82,6 @@ public class YGOMobileActivity extends NativeActivity implements
private
volatile
int
mPositionX
,
mPositionY
;
private
boolean
mPaused
;
private
SurfaceView
mSurfaceView
;
private
HandlerThread
mThread
;
private
Handler
mWorker
;
// public static int notchHeight;
...
...
@@ -111,9 +105,8 @@ public class YGOMobileActivity extends NativeActivity implements
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
mSurfaceView
=
new
SurfaceView
(
this
);
mSurfaceView
.
getHolder
().
addCallback
(
this
);
mThread
=
new
HandlerThread
(
"ygo_work_"
+
hashCode
());
mThread
.
start
();
mWorker
=
new
Handler
(
mThread
.
getLooper
());
app
().
attachGame
(
this
);
getGameSize
();
super
.
onCreate
(
savedInstanceState
);
Log
.
e
(
"YGOStarter"
,
"跳转完成"
+
System
.
currentTimeMillis
());
mFullScreenUtils
=
new
FullScreenUtils
(
this
,
app
().
isImmerSiveMode
());
...
...
@@ -239,12 +232,40 @@ public class YGOMobileActivity extends NativeActivity implements
yScale
=
sW
;
}
int
w
=
(
int
)(
1024.0
*
xScale
);
int
h
=
(
int
)(
640.0
*
yScale
);
mPositionX
=
(
int
)((
sH
-
w
)/
2.0f
);
mPositionY
=
(
int
)((
sW
-
h
)/
2.0f
);
int
h
=
(
int
)
(
640.0
*
yScale
);
int
spX
=
(
int
)
((
screenH
-
w
)
/
2.0f
);
int
spY
=
(
int
)
((
screenW
-
h
)
/
2.0f
);
Log
.
i
(
"ygo"
,
"Android command setInputFix1:posX="
+
spX
+
",posY="
+
spY
);
boolean
update
=
false
;
synchronized
(
this
)
{
if
(
spX
!=
mPositionX
||
spY
!=
mPositionY
)
{
mPositionX
=
spX
;
mPositionY
=
spY
;
update
=
true
;
}
}
if
(
update
)
{
Log
.
i
(
"ygo"
,
"Android command setInputFix2:posX="
+
spX
+
",posY="
+
spY
);
IrrlichtBridge
.
setInputFix
(
mPositionX
,
mPositionY
);
}
return
new
int
[]{
w
,
h
};
}
@Override
public
int
getPositionX
()
{
synchronized
(
this
)
{
return
mPositionX
;
}
}
@Override
public
int
getPositionY
()
{
synchronized
(
this
)
{
return
mPositionY
;
}
}
private
void
fullscreen
()
{
//如果是沉浸模式
...
...
@@ -252,7 +273,7 @@ public class YGOMobileActivity extends NativeActivity implements
mFullScreenUtils
.
fullscreen
();
app
().
attachGame
(
this
);
//游戏大小
//
int[] size = getGameSize();
int
[]
size
=
getGameSize
();
// getWindow().setLayout(size[0], size[1]);
}
}
...
...
@@ -263,43 +284,10 @@ public class YGOMobileActivity extends NativeActivity implements
int
[]
size
=
getGameSize
();
int
w
=
size
[
0
];
int
h
=
size
[
1
];
getWindow
().
takeInputQueue
(
null
);
FrameLayout
.
LayoutParams
lp
=
new
FrameLayout
.
LayoutParams
(
w
,
h
);
lp
.
gravity
=
Gravity
.
CENTER
;
layout
.
addView
(
mSurfaceView
,
lp
);
layout
.
addView
(
view
,
lp
);
view
.
setLongClickable
(
true
);
view
.
setOnTouchListener
(
new
View
.
OnTouchListener
()
{
@Override
public
boolean
onTouch
(
View
v
,
final
MotionEvent
event
)
{
if
(
mPaused
){
return
false
;
}
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
;
}
final
int
action
=
event
.
getAction
();
final
float
x
=
event
.
getX
();
final
float
y
=
event
.
getY
();
doWork
(
new
Runnable
()
{
@Override
public
void
run
()
{
IrrlichtBridge
.
sendTouch
(
action
,
x
,
y
,
0
);
}
});
return
true
;
}
});
// getWindow().setLayout(w, h);
// getWindow().setGravity(Gravity.CENTER);
super
.
setContentView
(
layout
);
...
...
@@ -307,48 +295,6 @@ public class YGOMobileActivity extends NativeActivity implements
mSurfaceView
.
requestFocus
();
}
@Override
public
void
onInputQueueCreated
(
InputQueue
queue
)
{
// super.onInputQueueCreated(queue);
}
@Override
public
void
onInputQueueDestroyed
(
InputQueue
queue
)
{
// super.onInputQueueDestroyed(queue);
}
@Override
public
boolean
onKeyDown
(
final
int
keyCode
,
KeyEvent
event
)
{
if
(
keyCode
!=
KeyEvent
.
KEYCODE_BACK
){
doWork
(
new
Runnable
()
{
@Override
public
void
run
()
{
IrrlichtBridge
.
sendKey
(
keyCode
,
true
);
}
});
return
true
;
}
return
super
.
onKeyDown
(
keyCode
,
event
);
}
@Override
public
boolean
onKeyUp
(
final
int
keyCode
,
KeyEvent
event
)
{
if
(
keyCode
!=
KeyEvent
.
KEYCODE_BACK
){
doWork
(
new
Runnable
()
{
@Override
public
void
run
()
{
IrrlichtBridge
.
sendKey
(
keyCode
,
false
);
}
});
return
true
;
}
return
super
.
onKeyUp
(
keyCode
,
event
);
}
private
void
doWork
(
Runnable
runnable
){
mWorker
.
post
(
runnable
);
}
@Override
public
void
onBackPressed
()
{
Toast
.
makeText
(
this
,
"请在游戏里面退出"
,
Toast
.
LENGTH_SHORT
).
show
();
...
...
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
View file @
8664e10a
...
...
@@ -63,6 +63,8 @@ public final class IrrlichtBridge {
private
static
native
void
nativeSendTouch
(
int
handle
,
int
action
,
int
id
,
float
x
,
float
y
);
private
static
native
void
nativeSetInputFix
(
int
handle
,
int
x
,
int
y
);
private
static
final
boolean
DEBUG
=
false
;
private
static
final
String
TAG
=
IrrlichtBridge
.
class
.
getSimpleName
();
...
...
@@ -133,6 +135,10 @@ public final class IrrlichtBridge {
}
}
public
static
void
setInputFix
(
int
x
,
int
y
){
nativeSetInputFix
(
sNativeHandle
,
x
,
y
);
}
public
static
void
cancelChain
()
{
nativeCancelChain
(
getHandle
());
}
...
...
@@ -193,7 +199,7 @@ public final class IrrlichtBridge {
void
playSoundEffect
(
String
path
);
void
runWindbot
(
String
args
);
// float getSmallerSize();
// float getXScale();
// float getYScale();
...
...
@@ -221,5 +227,9 @@ public final class IrrlichtBridge {
int
getLocalAddress
();
void
setNativeHandle
(
int
nativeHandle
);
int
getPositionX
();
int
getPositionY
();
}
}
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