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
0afb2d5b
Commit
0afb2d5b
authored
Oct 05, 2019
by
kenan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
opt code
parent
8664e10a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
137 deletions
+50
-137
Classes/gframe/game.cpp
Classes/gframe/game.cpp
+19
-24
Classes/gframe/game.h
Classes/gframe/game.h
+15
-18
libcore/android/android_tools.cpp
libcore/android/android_tools.cpp
+2
-8
libcore/android/android_tools.h
libcore/android/android_tools.h
+1
-7
libcore/jni/cn_garymb_ygomobile_core_IrrlichtBridge.cpp
libcore/jni/cn_garymb_ygomobile_core_IrrlichtBridge.cpp
+0
-43
libcore/src/main/java/cn/garymb/ygomobile/GameReceiver.java
libcore/src/main/java/cn/garymb/ygomobile/GameReceiver.java
+4
-5
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
...rc/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
+9
-32
No files found.
Classes/gframe/game.cpp
View file @
0afb2d5b
...
...
@@ -28,16 +28,16 @@ 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
);
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
)
{
...
...
@@ -1468,39 +1468,34 @@ void Game::LoadConfig() {
}
void
Game
::
SaveConfig
()
{
JNIEnv
*
jni
=
0
;
appMain
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
NULL
);
if
(
!
jni
)
return
;
//helper
gameConf
.
chkMAutoPos
=
chkMAutoPos
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
jni
,
"chkMAutoPos"
,
gameConf
.
chkMAutoPos
);
android
::
saveIntSetting
(
appMain
,
"chkMAutoPos"
,
gameConf
.
chkMAutoPos
);
gameConf
.
chkSTAutoPos
=
chkSTAutoPos
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
jni
,
"chkSTAutoPos"
,
gameConf
.
chkSTAutoPos
);
android
::
saveIntSetting
(
appMain
,
"chkSTAutoPos"
,
gameConf
.
chkSTAutoPos
);
gameConf
.
chkRandomPos
=
chkRandomPos
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
jni
,
"chkRandomPos"
,
gameConf
.
chkRandomPos
);
android
::
saveIntSetting
(
appMain
,
"chkRandomPos"
,
gameConf
.
chkRandomPos
);
gameConf
.
chkAutoChain
=
chkAutoChain
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
jni
,
"chkAutoChain"
,
gameConf
.
chkAutoChain
);
android
::
saveIntSetting
(
appMain
,
"chkAutoChain"
,
gameConf
.
chkAutoChain
);
gameConf
.
chkWaitChain
=
chkWaitChain
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
jni
,
"chkWaitChain"
,
gameConf
.
chkWaitChain
);
android
::
saveIntSetting
(
appMain
,
"chkWaitChain"
,
gameConf
.
chkWaitChain
);
//system
gameConf
.
chkIgnore1
=
chkIgnore1
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
jni
,
"chkIgnore1"
,
gameConf
.
chkIgnore1
);
android
::
saveIntSetting
(
appMain
,
"chkIgnore1"
,
gameConf
.
chkIgnore1
);
gameConf
.
chkIgnore2
=
chkIgnore2
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
jni
,
"chkIgnore2"
,
gameConf
.
chkIgnore2
);
android
::
saveIntSetting
(
appMain
,
"chkIgnore2"
,
gameConf
.
chkIgnore2
);
gameConf
.
chkIgnoreDeckChanges
=
chkIgnoreDeckChanges
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
jni
,
"chkIgnoreDeckChanges"
,
gameConf
.
chkIgnoreDeckChanges
);
android
::
saveIntSetting
(
appMain
,
"chkIgnoreDeckChanges"
,
gameConf
.
chkIgnoreDeckChanges
);
gameConf
.
auto_save_replay
=
chkAutoSaveReplay
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
jni
,
"auto_save_replay"
,
gameConf
.
auto_save_replay
);
android
::
saveIntSetting
(
appMain
,
"auto_save_replay"
,
gameConf
.
auto_save_replay
);
gameConf
.
draw_field_spell
=
chkDrawFieldSpell
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
jni
,
"draw_field_spell"
,
gameConf
.
draw_field_spell
);
android
::
saveIntSetting
(
appMain
,
"draw_field_spell"
,
gameConf
.
draw_field_spell
);
gameConf
.
quick_animation
=
chkQuickAnimation
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
jni
,
"quick_animation"
,
gameConf
.
quick_animation
);
android
::
saveIntSetting
(
appMain
,
"quick_animation"
,
gameConf
.
quick_animation
);
gameConf
.
prefer_expansion_script
=
chkPreferExpansionScript
->
isChecked
()
?
1
:
0
;
android
::
saveIntSetting
(
appMain
,
jni
,
"prefer_expansion_script"
,
gameConf
.
prefer_expansion_script
);
android
::
saveIntSetting
(
appMain
,
"prefer_expansion_script"
,
gameConf
.
prefer_expansion_script
);
appMain
->
activity
->
vm
->
DetachCurrentThread
();
//gameConf.control_mode = control_mode->isChecked()?1:0;
// android::saveIntSetting(appMain, "control_mode", gameConf.control_mode);
}
...
...
Classes/gframe/game.h
View file @
0afb2d5b
...
...
@@ -529,8 +529,6 @@ public:
irr
::
gui
::
IGUIButton
*
btnCancelOrFinish
;
float
xScale
;
float
yScale
;
float
xStart
;
float
yStart
;
IYGOSoundEffectPlayer
*
soundEffectPlayer
;
#ifdef _IRR_ANDROID_PLATFORM_
ANDROID_APP
appMain
;
...
...
@@ -546,29 +544,28 @@ public:
void
setPositionFix
(
core
::
position2di
fix
){
InputFix
=
fix
;
}
float
optX
(
float
x
)
{
float
x2
=
x
-
InputFix
.
X
;
if
(
x2
<
0
)
{
return
0
;
}
return
x2
;
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
;
float
optY
(
float
y
)
{
float
y2
=
y
-
InputFix
.
Y
;
if
(
y2
<
0
)
{
return
0
;
}
void
process
(
irr
::
SEvent
&
event
);
private:
core
::
position2di
InputFix
;
return
y2
;
}
void
process
(
irr
::
SEvent
&
event
);
private:
core
::
position2di
InputFix
;
};
extern
Game
*
mainGame
;
}
#define CARD_IMG_WIDTH 177
...
...
libcore/android/android_tools.cpp
View file @
0afb2d5b
...
...
@@ -441,20 +441,13 @@ int getIntSetting(ANDROID_APP app, const char* key,int defvalue){
return
(
int
)
ret
;
}
void
saveIntSetting
Auto
(
ANDROID_APP
app
,
const
char
*
key
,
int
value
)
{
void
saveIntSetting
(
ANDROID_APP
app
,
const
char
*
key
,
int
value
)
{
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
return
;
JNIEnv
*
jni
=
0
;
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
NULL
);
if
(
!
jni
)
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.
jobject
lNativeActivity
=
app
->
activity
->
clazz
;
jclass
ClassNativeActivity
=
jni
->
GetObjectClass
(
lNativeActivity
);
...
...
@@ -471,6 +464,7 @@ void saveIntSetting(ANDROID_APP app, JNIEnv* jni, const char* key, int value) {
}
jni
->
DeleteLocalRef
(
classApp
);
jni
->
DeleteLocalRef
(
ClassNativeActivity
);
app
->
activity
->
vm
->
DetachCurrentThread
();
}
void
saveSetting
(
ANDROID_APP
app
,
const
char
*
key
,
const
char
*
value
)
{
...
...
libcore/android/android_tools.h
View file @
0afb2d5b
...
...
@@ -84,10 +84,6 @@ 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
);
...
...
@@ -164,9 +160,7 @@ extern void setLastDeck(ANDROID_APP app, const char* deckname);
//save last category name.
extern
void
setLastCategory
(
ANDROID_APP
app
,
const
char
*
catename
);
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
saveIntSetting
(
ANDROID_APP
app
,
const
char
*
key
,
int
value
);
extern
void
saveSetting
(
ANDROID_APP
app
,
const
char
*
key
,
const
char
*
value
);
...
...
libcore/jni/cn_garymb_ygomobile_core_IrrlichtBridge.cpp
View file @
0afb2d5b
...
...
@@ -302,49 +302,6 @@ JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetInp
}
}
//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
())
{
SEvent
event
;
event
.
EventType
=
EET_TOUCH_INPUT_EVENT
;
s32
eventAction
=
action
;
s32
eventType
=
eventAction
&
AMOTION_EVENT_ACTION_MASK
;
bool
touchReceived
=
true
;
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
);
}
}
}
}
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/GameReceiver.java
View file @
0afb2d5b
...
...
@@ -3,7 +3,6 @@ package cn.garymb.ygomobile;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.util.Log
;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
...
...
@@ -17,19 +16,19 @@ public class GameReceiver extends BroadcastReceiver {
if
(
ACTION_START
.
equals
(
action
))
{
//
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
))
{
int
pid
=
intent
.
getIntExtra
(
IrrlichtBridge
.
EXTRA_PID
,
0
);
if
(
pid
==
0
&&
IrrlichtBridge
.
gPid
!=
0
)
{
pid
=
IrrlichtBridge
.
gPid
;
Log
.
w
(
"ygo"
,
"will kill last pid="
+
pid
);
//
Log.w("ygo", "will kill last pid=" + pid);
}
if
(
pid
==
0
)
{
pid
=
android
.
os
.
Process
.
myPid
();
Log
.
w
(
"ygo"
,
"will kill now pid="
+
pid
);
//
Log.w("ygo", "will kill now pid=" + pid);
}
try
{
Log
.
e
(
"ygo"
,
"kill pid="
+
pid
);
// Log.w
("ygo", "kill pid=" + pid);
android
.
os
.
Process
.
killProcess
(
pid
);
}
catch
(
Exception
e
)
{
//ignore
...
...
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
View file @
0afb2d5b
...
...
@@ -39,7 +39,7 @@ public final class IrrlichtBridge {
}
p
rivate
static
int
sNativeHandle
;
p
ublic
static
int
sNativeHandle
;
//显示卡图
public
static
native
byte
[]
nativeBpgImage
(
byte
[]
data
);
//插入文本(大概是发送消息)
...
...
@@ -59,10 +59,6 @@ public final class IrrlichtBridge {
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
native
void
nativeSetInputFix
(
int
handle
,
int
x
,
int
y
);
private
static
final
boolean
DEBUG
=
false
;
...
...
@@ -123,60 +119,41 @@ public final class IrrlichtBridge {
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
setInputFix
(
int
x
,
int
y
){
nativeSetInputFix
(
sNativeHandle
,
x
,
y
);
}
public
static
void
cancelChain
()
{
nativeCancelChain
(
getHandle
()
);
nativeCancelChain
(
sNativeHandle
);
}
public
static
void
ignoreChain
(
boolean
begin
)
{
nativeIgnoreChain
(
getHandle
()
,
begin
);
nativeIgnoreChain
(
sNativeHandle
,
begin
);
}
public
static
void
reactChain
(
boolean
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
);
nativeReactChain
(
sNativeHandle
,
begin
);
}
public
static
void
insertText
(
String
text
)
{
nativeInsertText
(
getHandle
()
,
text
);
nativeInsertText
(
sNativeHandle
,
text
);
}
public
static
void
setComboBoxSelection
(
int
idx
)
{
nativeSetComboBoxSelection
(
getHandle
()
,
idx
);
nativeSetComboBoxSelection
(
sNativeHandle
,
idx
);
}
public
static
void
refreshTexture
()
{
nativeRefreshTexture
(
getHandle
()
);
nativeRefreshTexture
(
sNativeHandle
);
}
public
static
void
setCheckBoxesSelection
(
int
idx
)
{
nativeSetCheckBoxesSelection
(
getHandle
()
,
idx
);
nativeSetCheckBoxesSelection
(
sNativeHandle
,
idx
);
}
public
static
void
joinGame
(
ByteBuffer
options
,
int
length
)
{
nativeJoinGame
(
getHandle
()
,
options
,
length
);
nativeJoinGame
(
sNativeHandle
,
options
,
length
);
}
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