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
ff2ce6e0
Commit
ff2ce6e0
authored
Oct 22, 2019
by
kenan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
opt code
parent
dfd048b6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
148 additions
and
108 deletions
+148
-108
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
.../src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
+5
-5
libcore/src/main/java/cn/garymb/ygomobile/core/YGOCore.java
libcore/src/main/java/cn/garymb/ygomobile/core/YGOCore.java
+22
-0
mobile/src/main/java/cn/garymb/ygomobile/App.java
mobile/src/main/java/cn/garymb/ygomobile/App.java
+0
-95
mobile/src/main/java/cn/garymb/ygomobile/LocalGameHost.java
mobile/src/main/java/cn/garymb/ygomobile/LocalGameHost.java
+111
-0
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
+2
-8
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/LogoActivity.java
.../java/cn/garymb/ygomobile/ui/activities/LogoActivity.java
+8
-0
No files found.
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
View file @
ff2ce6e0
...
...
@@ -128,12 +128,12 @@ public class YGOMobileActivity extends NativeActivity implements
mCore
=
YGOCore
.
getInstance
();
mHost
=
app
().
getGameHost
();
fullscreen
();
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
P
)
{
WindowManager
.
LayoutParams
lp
=
getWindow
().
getAttributes
();
lp
.
layoutInDisplayCutoutMode
=
LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
;
getWindow
().
setAttributes
(
lp
);
}
if
(
mGameConfig
!=
null
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
P
)
{
WindowManager
.
LayoutParams
lp
=
getWindow
().
getAttributes
();
lp
.
layoutInDisplayCutoutMode
=
LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
;
getWindow
().
setAttributes
(
lp
);
}
mGameSoundPlayer
=
new
GameSoundPlayer
(
mHost
.
getGameAsset
());
if
(
mGameConfig
.
isEnableSoundEffect
())
{
mGameSoundPlayer
.
initSoundEffectPool
();
...
...
libcore/src/main/java/cn/garymb/ygomobile/core/YGOCore.java
View file @
ff2ce6e0
package
cn.garymb.ygomobile.core
;
import
android.app.Activity
;
import
android.content.ComponentName
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Handler
;
import
android.os.HandlerThread
;
import
android.util.Log
;
import
android.view.MotionEvent
;
import
android.widget.Toast
;
import
androidx.annotation.Keep
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
java.nio.ByteBuffer
;
import
cn.garymb.ygodata.YGOGameOptions
;
import
cn.garymb.ygomobile.YGOMobileActivity
;
import
cn.garymb.ygomobile.interfaces.GameConfig
;
public
class
YGOCore
{
public
static
final
float
GAME_WIDTH
=
1024.0f
;
public
static
final
float
GAME_HEIGHT
=
640.0f
;
...
...
@@ -168,6 +179,17 @@ public class YGOCore {
}
}
public
static
void
startGame
(
Context
activity
,
@Nullable
YGOGameOptions
options
,
@NonNull
GameConfig
gameConfig
)
{
Intent
intent
=
new
Intent
(
activity
,
YGOMobileActivity
.
class
);
if
(
options
!=
null
)
{
intent
.
putExtra
(
YGOGameOptions
.
YGO_GAME_OPTIONS_BUNDLE_KEY
,
options
);
intent
.
putExtra
(
YGOGameOptions
.
YGO_GAME_OPTIONS_BUNDLE_TIME
,
System
.
currentTimeMillis
());
}
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
intent
.
putExtra
(
GameConfig
.
EXTRA_CONFIG
,
gameConfig
);
activity
.
startActivity
(
intent
);
}
//插入文本(大概是发送消息)
private
native
void
nativeInsertText
(
int
device
,
String
text
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/App.java
View file @
ff2ce6e0
package
cn.garymb.ygomobile
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.app.ActivityManager
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.res.AssetManager
;
import
android.graphics.Point
;
import
android.os.Build
;
import
android.os.Process
;
import
android.util.Log
;
import
android.widget.ImageView
;
import
androidx.appcompat.app.AppCompatDelegate
;
...
...
@@ -19,15 +10,9 @@ import com.bumptech.glide.Glide;
import
com.yuyh.library.imgsel.ISNav
;
import
com.yuyh.library.imgsel.common.ImageLoader
;
import
java.lang.reflect.Method
;
import
cn.garymb.ygomobile.core.YGOCore
;
import
cn.garymb.ygomobile.interfaces.GameConfig
;
import
cn.garymb.ygomobile.interfaces.GameHost
;
import
cn.garymb.ygomobile.interfaces.GameSize
;
import
cn.garymb.ygomobile.lite.BuildConfig
;
import
cn.garymb.ygomobile.utils.CrashHandler
;
import
cn.garymb.ygomobile.utils.ScreenUtil
;
import
jonathanfinerty.once.Once
;
public
class
App
extends
GameApplication
{
...
...
@@ -66,86 +51,6 @@ public class App extends GameApplication {
return
gameHost
;
}
private
class
LocalGameHost
extends
GameHost
{
LocalGameHost
(
Context
context
)
{
super
(
context
);
}
@Override
public
String
getSetting
(
String
key
)
{
return
AppsSettings
.
get
().
getSettings
(
key
);
}
@Override
public
int
getIntSetting
(
String
key
,
int
def
)
{
return
AppsSettings
.
get
().
getIntSettings
(
key
,
def
);
}
@Override
public
void
saveIntSetting
(
String
key
,
int
value
)
{
AppsSettings
.
get
().
saveIntSettings
(
key
,
value
);
}
@Override
public
void
saveSetting
(
String
key
,
String
value
)
{
AppsSettings
.
get
().
saveSettings
(
key
,
value
);
}
@Override
public
void
runWindbot
(
String
cmd
)
{
Intent
intent
=
new
Intent
();
intent
.
putExtra
(
"args"
,
cmd
);
intent
.
setAction
(
"RUN_WINDBOT"
);
sendBroadcast
(
intent
);
}
@Override
public
AssetManager
getGameAsset
()
{
return
getAssets
();
}
@Override
public
GameSize
getGameSize
(
Activity
activity
)
{
int
maxW
,
maxH
;
int
w1
=
activity
.
getWindowManager
().
getDefaultDisplay
().
getWidth
();
int
h1
=
activity
.
getWindowManager
().
getDefaultDisplay
().
getHeight
();
maxW
=
Math
.
max
(
w1
,
h1
);
maxH
=
Math
.
min
(
w1
,
h1
);
if
(
AppsSettings
.
get
().
isImmerSiveMode
())
{
maxH
+=
ScreenUtil
.
getCurrentNavigationBarHeight
(
activity
);
}
float
sx
,
sy
,
scale
;
int
gw
,
gh
;
if
(
AppsSettings
.
get
().
isKeepScale
())
{
sx
=
(
float
)
maxW
/
YGOCore
.
GAME_WIDTH
;
sy
=
(
float
)
maxH
/
YGOCore
.
GAME_HEIGHT
;
scale
=
Math
.
min
(
sx
,
sy
);
gw
=
(
int
)
(
YGOCore
.
GAME_WIDTH
*
scale
);
gh
=
(
int
)
(
YGOCore
.
GAME_HEIGHT
*
scale
);
}
else
{
gw
=
maxW
;
gh
=
maxH
;
}
//fix touch point
int
left
=
(
maxW
-
gw
)
/
2
;
int
top
=
(
maxH
-
gh
)
/
2
;
//if(huawei and liuhai){
// left-=liuhai
// }
return
new
GameSize
(
gw
,
gh
,
left
,
top
);
}
@Override
public
boolean
isDebugMode
()
{
return
BuildConfig
.
DEBUG
;
}
@Override
public
boolean
isAutoKeepGame
()
{
return
false
;
}
}
public
static
GameConfig
genConfig
()
{
GameConfig
config
=
new
GameConfig
();
config
.
setNativeInitOptions
(
AppsSettings
.
get
().
getNativeInitOptions
());
...
...
mobile/src/main/java/cn/garymb/ygomobile/LocalGameHost.java
0 → 100644
View file @
ff2ce6e0
package
cn.garymb.ygomobile
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.res.AssetManager
;
import
android.graphics.Point
;
import
android.util.Log
;
import
cn.garymb.ygomobile.core.YGOCore
;
import
cn.garymb.ygomobile.interfaces.GameHost
;
import
cn.garymb.ygomobile.interfaces.GameSize
;
import
cn.garymb.ygomobile.lite.BuildConfig
;
import
cn.garymb.ygomobile.utils.ScreenUtil
;
class
LocalGameHost
extends
GameHost
{
private
Context
context
;
LocalGameHost
(
Context
context
)
{
super
(
context
);
this
.
context
=
context
;
}
@Override
public
String
getSetting
(
String
key
)
{
return
AppsSettings
.
get
().
getSettings
(
key
);
}
@Override
public
int
getIntSetting
(
String
key
,
int
def
)
{
return
AppsSettings
.
get
().
getIntSettings
(
key
,
def
);
}
@Override
public
void
saveIntSetting
(
String
key
,
int
value
)
{
AppsSettings
.
get
().
saveIntSettings
(
key
,
value
);
}
@Override
public
void
saveSetting
(
String
key
,
String
value
)
{
AppsSettings
.
get
().
saveSettings
(
key
,
value
);
}
@Override
public
void
runWindbot
(
String
cmd
)
{
Intent
intent
=
new
Intent
();
intent
.
putExtra
(
"args"
,
cmd
);
intent
.
setAction
(
"RUN_WINDBOT"
);
context
.
sendBroadcast
(
intent
);
}
@Override
public
AssetManager
getGameAsset
()
{
return
context
.
getAssets
();
}
@Override
public
GameSize
getGameSize
(
Activity
activity
)
{
boolean
immerSiveMode
=
AppsSettings
.
get
().
isImmerSiveMode
();
boolean
keepScale
=
AppsSettings
.
get
().
isKeepScale
();
int
maxW
,
maxH
;
int
fullW
,
fullH
,
actW
,
actH
;
Point
size
=
new
Point
();
activity
.
getWindowManager
().
getDefaultDisplay
().
getRealSize
(
size
);
fullW
=
size
.
x
;
fullH
=
size
.
y
;
actW
=
activity
.
getWindowManager
().
getDefaultDisplay
().
getWidth
();
actH
=
activity
.
getWindowManager
().
getDefaultDisplay
().
getHeight
();
int
w1
,
h1
;
if
(
immerSiveMode
)
{
w1
=
fullW
;
h1
=
fullH
;
}
else
{
w1
=
actW
;
h1
=
actH
;
}
maxW
=
Math
.
max
(
w1
,
h1
);
maxH
=
Math
.
min
(
w1
,
h1
);
Log
.
i
(
"kk"
,
"maxW="
+
maxW
+
",maxH="
+
maxH
);
float
sx
,
sy
,
scale
;
int
gw
,
gh
;
if
(
keepScale
)
{
sx
=
(
float
)
maxW
/
YGOCore
.
GAME_WIDTH
;
sy
=
(
float
)
maxH
/
YGOCore
.
GAME_HEIGHT
;
scale
=
Math
.
min
(
sx
,
sy
);
gw
=
(
int
)
(
YGOCore
.
GAME_WIDTH
*
scale
);
gh
=
(
int
)
(
YGOCore
.
GAME_HEIGHT
*
scale
);
}
else
{
gw
=
maxW
;
gh
=
maxH
;
}
Log
.
i
(
"kk"
,
"game="
+
gw
+
"x"
+
gh
);
//fix touch point
int
left
=
(
maxW
-
gw
)
/
2
;
int
top
=
(
maxH
-
gh
)
/
2
;
Log
.
i
(
"kk"
,
"touch fix="
+
left
+
"x"
+
top
);
//if(huawei and liuhai){
// left-=liuhai
// }
return
new
GameSize
(
gw
,
gh
,
left
,
top
);
}
@Override
public
boolean
isDebugMode
()
{
return
BuildConfig
.
DEBUG
;
}
@Override
public
boolean
isAutoKeepGame
()
{
return
false
;
}
}
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
View file @
ff2ce6e0
...
...
@@ -25,6 +25,7 @@ import java.io.File;
import
java.util.HashMap
;
import
cn.garymb.ygodata.YGOGameOptions
;
import
cn.garymb.ygomobile.core.YGOCore
;
import
cn.garymb.ygomobile.interfaces.GameConfig
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.plus.ViewTargetPlus
;
...
...
@@ -171,15 +172,8 @@ public class YGOStarter {
// } else {
// options = null;
}
Intent
intent
=
new
Intent
(
activity
,
YGOMobileActivity
.
class
);
if
(
options
!=
null
)
{
intent
.
putExtra
(
YGOGameOptions
.
YGO_GAME_OPTIONS_BUNDLE_KEY
,
options
);
intent
.
putExtra
(
YGOGameOptions
.
YGO_GAME_OPTIONS_BUNDLE_TIME
,
System
.
currentTimeMillis
());
}
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
intent
.
putExtra
(
GameConfig
.
EXTRA_CONFIG
,
App
.
genConfig
());
Log
.
e
(
"YGOStarter"
,
"跳转前"
+
System
.
currentTimeMillis
());
activity
.
startActivity
(
intent
);
YGOCore
.
startGame
(
activity
,
options
,
App
.
genConfig
()
);
Log
.
e
(
"YGOStarter"
,
"跳转后"
+
System
.
currentTimeMillis
());
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/LogoActivity.java
View file @
ff2ce6e0
...
...
@@ -3,6 +3,7 @@ package cn.garymb.ygomobile.ui.activities;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.view.View
;
import
android.widget.Toast
;
import
cn.garymb.ygomobile.AppsSettings
;
...
...
@@ -18,6 +19,13 @@ public class LogoActivity extends BaseActivity {
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_logo
);
int
windowsFlags
=
View
.
SYSTEM_UI_FLAG_LAYOUT_STABLE
/* 系统UI变化不触发relayout */
|
View
.
SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
/* 导航栏悬浮在布局上面 */
|
View
.
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
/* 状态栏悬浮在布局上面 */
|
View
.
SYSTEM_UI_FLAG_HIDE_NAVIGATION
/* 隐藏导航栏 */
|
View
.
SYSTEM_UI_FLAG_FULLSCREEN
/* 隐藏状态栏 */
|
View
.
SYSTEM_UI_FLAG_IMMERSIVE_STICKY
/* 沉浸模式 */
;
getWindow
().
getDecorView
().
setSystemUiVisibility
(
windowsFlags
);
if
(
AppsSettings
.
get
().
isOnlyGame
())
{
YGOStarter
.
startGame
(
this
,
null
);
finish
();
...
...
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