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
a0f08346
Commit
a0f08346
authored
Oct 05, 2019
by
kenan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步master
parent
66a1d319
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
210 additions
and
144 deletions
+210
-144
Classes/gframe/drawing.cpp
Classes/gframe/drawing.cpp
+1
-1
Classes/gframe/event_handler.cpp
Classes/gframe/event_handler.cpp
+3
-3
Classes/gframe/game.cpp
Classes/gframe/game.cpp
+6
-24
Classes/gframe/game.h
Classes/gframe/game.h
+9
-0
libcore/android/android_tools.cpp
libcore/android/android_tools.cpp
+46
-0
libcore/android/android_tools.h
libcore/android/android_tools.h
+4
-0
libcore/src/main/java/cn/garymb/ygomobile/GameApplication.java
...re/src/main/java/cn/garymb/ygomobile/GameApplication.java
+10
-4
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
.../src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
+50
-36
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
...rc/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
+4
-0
mobile/src/main/java/cn/garymb/ygomobile/App.java
mobile/src/main/java/cn/garymb/ygomobile/App.java
+6
-3
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
+57
-73
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
+3
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/fragments/SettingFragment.java
...mb/ygomobile/ui/preference/fragments/SettingFragment.java
+2
-0
mobile/src/main/res/values-ko/strings.xml
mobile/src/main/res/values-ko/strings.xml
+1
-0
mobile/src/main/res/values-zh/strings.xml
mobile/src/main/res/values-zh/strings.xml
+1
-0
mobile/src/main/res/values/strings.xml
mobile/src/main/res/values/strings.xml
+1
-0
mobile/src/main/res/xml/preference_game.xml
mobile/src/main/res/xml/preference_game.xml
+6
-0
No files found.
Classes/gframe/drawing.cpp
View file @
a0f08346
...
...
@@ -1065,7 +1065,7 @@ void Game::DrawSpec() {
void
Game
::
DrawBackImage
(
irr
::
video
::
ITexture
*
texture
)
{
if
(
!
texture
)
return
;
driver
->
draw2DImage
(
texture
,
recti
(
0
,
0
,
1024
*
mainGame
->
xScale
,
640
*
mainGame
->
yScale
),
recti
(
0
,
0
,
texture
->
getOriginalSize
().
Width
,
texture
->
getOriginalSize
().
Height
));
driver
->
draw2DImage
(
texture
,
recti
(
0
,
0
,
GAME_WIDTH
*
mainGame
->
xScale
,
GAME_HEIGHT
*
mainGame
->
yScale
),
recti
(
0
,
0
,
texture
->
getOriginalSize
().
Width
,
texture
->
getOriginalSize
().
Height
));
}
void
Game
::
ShowElement
(
irr
::
gui
::
IGUIElement
*
win
,
int
autoframe
)
{
FadingUnit
fu
;
...
...
Classes/gframe/event_handler.cpp
View file @
a0f08346
...
...
@@ -2010,8 +2010,8 @@ void ClientField::GetHoverField(int x, int y) {
hovered_sequence
=
hc
-
1
-
(
x
-
ofRect
.
UpperLeftCorner
.
X
)
*
(
hc
-
1
)
/
((
cardSize
+
cardSpace
)
*
5
*
mainGame
->
xScale
);
}
}
else
{
double
screenx
=
x
/
(
1024.0
*
mainGame
->
xScale
)
*
1.35
-
0.90
;
double
screeny
=
y
/
(
640.0
*
mainGame
->
yScale
)
*
0.84
-
0.42
;
double
screenx
=
x
/
(
GAME_WIDTH
*
mainGame
->
xScale
)
*
1.35
-
0.90
;
double
screeny
=
y
/
(
GAME_HEIGHT
*
mainGame
->
yScale
)
*
0.84
-
0.42
;
double
angle
=
0.798056
-
atan
(
screeny
);
//0.798056 = arctan(8.0/7.8)
double
vlen
=
sqrt
(
1.0
+
screeny
*
screeny
);
double
boardx
=
4.2
+
7.8
*
screenx
/
vlen
/
cos
(
angle
);
...
...
@@ -2308,7 +2308,7 @@ void ClientField::ShowCardInfoInList(ClientCard* pcard, irr::gui::IGUIElement* e
x
=
w
+
10
*
mainGame
->
xScale
;
if
(
x
+
w
>
670
*
mainGame
->
xScale
)
x
=
670
*
mainGame
->
xScale
-
w
;
mainGame
->
stCardListTip
->
setRelativePosition
(
recti
(
x
-
dTip
.
Width
/
2
,
y
-
10
,
x
+
dTip
.
Width
/
2
,
y
-
10
+
dTip
.
Height
));
mainGame
->
stCardListTip
->
setRelativePosition
(
recti
(
x
-
dTip
.
Width
/
2
,
y
-
10
*
mainGame
->
yScale
,
x
+
dTip
.
Width
/
2
,
y
-
10
*
mainGame
->
yScale
+
dTip
.
Height
));
mainGame
->
stCardListTip
->
setVisible
(
true
);
}
}
...
...
Classes/gframe/game.cpp
View file @
a0f08346
...
...
@@ -47,19 +47,6 @@ bool Game::Initialize() {
#endif
srand
(
time
(
0
));
irr
::
SIrrlichtCreationParameters
params
=
irr
::
SIrrlichtCreationParameters
();
int
screenH
=
static_cast
<
int
>
(
android
::
getScreenHeight
(
app
));
int
screenW
=
static_cast
<
int
>
(
android
::
getScreenWidth
(
app
));
float
sH
=
static_cast
<
float
>
(
screenH
/
1024.0
);
float
sW
=
static_cast
<
float
>
(
screenW
/
640.0
);
//取最小值
if
(
sH
<
sW
){
xScale
=
sH
;
yScale
=
sH
;
}
else
{
xScale
=
sW
;
yScale
=
sW
;
}
#ifdef _IRR_ANDROID_PLATFORM_
android
::
InitOptions
*
options
=
android
::
getInitOptions
(
app
);
...
...
@@ -73,13 +60,7 @@ bool Game::Initialize() {
params
.
Bits
=
24
;
params
.
ZBufferBits
=
16
;
params
.
AntiAlias
=
0
;
//int w = (int)(1024.0*xScale);
//int h = (int)(640.0*yScale);
params
.
WindowSize
=
irr
::
core
::
dimension2d
<
u32
>
(
0
,
0
);
//每一个元素得left和top都需要改
//xStart = (float)((screenH - w)/2.0);
//yStart = (float)((screenW - h)/2.0);
//params.WindowPosition = core::position2di((s32)xStart, (s32)yStart);
#else
if
(
gameConf
.
use_d3d
)
params
.
DriverType
=
irr
::
video
::
EDT_DIRECT3D9
;
...
...
@@ -92,12 +73,13 @@ bool Game::Initialize() {
if
(
!
device
)
return
false
;
#ifdef _IRR_ANDROID_PLATFORM_
device
->
setProcessReceiver
(
this
);
if
(
!
android
::
perfromTrick
(
app
))
{
return
false
;
}
core
::
position2di
appPosition
=
android
::
initJavaBridge
(
app
,
device
);
setPositionFix
(
appPosition
);
device
->
setProcessReceiver
(
this
);
soundEffectPlayer
=
new
AndroidSoundEffectPlayer
(
app
);
soundEffectPlayer
->
setSEEnabled
(
options
->
isSoundEffectEnabled
());
...
...
@@ -107,10 +89,10 @@ bool Game::Initialize() {
isPSEnabled
=
options
->
isPendulumScaleEnabled
();
dataManager
.
FileSystem
=
device
->
getFileSystem
();
/* if (xScale < yScale) {
* xScale = android::getScreenWidth(app) / 1024.0
;
* yScale = android::getScreenHeight(app) / 640.0;
* }//start ygocore when mobile is in landscape mode, or using Android tablets or TV.*/
xScale
=
android
::
getXScale
(
app
);
yScale
=
android
::
getYScale
(
app
)
;
//start ygocore when mobile is in landscape mode, or using Android tablets or TV.
char
log_scale
[
256
]
=
{
0
};
sprintf
(
log_scale
,
"xScale = %f, yScale = %f"
,
xScale
,
yScale
);
Printer
::
log
(
log_scale
);
...
...
Classes/gframe/game.h
View file @
a0f08346
...
...
@@ -529,6 +529,7 @@ public:
irr
::
gui
::
IGUIButton
*
btnCancelOrFinish
;
float
xScale
;
float
yScale
;
IYGOSoundEffectPlayer
*
soundEffectPlayer
;
#ifdef _IRR_ANDROID_PLATFORM_
ANDROID_APP
appMain
;
...
...
@@ -755,6 +756,14 @@ private:
#define CARD_ARTWORK_VERSIONS_OFFSET 10
#ifdef _IRR_ANDROID_PLATFORM_
#define GAME_WIDTH 1024
#define GAME_HEIGHT 640
#else
#define GAME_WIDTH 1280
#define GAME_HEIGHT 720
#endif
#ifdef _IRR_ANDROID_PLATFORM_
#define GUI_INFO_FPS 1000
#endif
...
...
libcore/android/android_tools.cpp
View file @
a0f08346
...
...
@@ -356,7 +356,53 @@ irr::io::path getResourcePath(ANDROID_APP app) {
return
ret
;
}
float
getXScale
(
ANDROID_APP
app
){
float
ret
=
1
;
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
return
ret
;
JNIEnv
*
jni
=
0
;
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
NULL
);
if
(
!
jni
)
return
ret
;
// Retrieves NativeActivity.
jobject
lNativeActivity
=
app
->
activity
->
clazz
;
jclass
ClassNativeActivity
=
jni
->
GetObjectClass
(
lNativeActivity
);
jmethodID
MethodGetApp
=
jni
->
GetMethodID
(
ClassNativeActivity
,
"getApplication"
,
"()Landroid/app/Application;"
);
jobject
application
=
jni
->
CallObjectMethod
(
lNativeActivity
,
MethodGetApp
);
jclass
classApp
=
jni
->
GetObjectClass
(
application
);
jmethodID
glversionMethod
=
jni
->
GetMethodID
(
classApp
,
"getXScale"
,
"()F"
);
ret
=
jni
->
CallFloatMethod
(
application
,
glversionMethod
);
jni
->
DeleteLocalRef
(
classApp
);
jni
->
DeleteLocalRef
(
ClassNativeActivity
);
app
->
activity
->
vm
->
DetachCurrentThread
();
return
ret
;
}
float
getYScale
(
ANDROID_APP
app
){
float
ret
=
1
;
if
(
!
app
||
!
app
->
activity
||
!
app
->
activity
->
vm
)
return
ret
;
JNIEnv
*
jni
=
0
;
app
->
activity
->
vm
->
AttachCurrentThread
(
&
jni
,
NULL
);
if
(
!
jni
)
return
ret
;
// Retrieves NativeActivity.
jobject
lNativeActivity
=
app
->
activity
->
clazz
;
jclass
ClassNativeActivity
=
jni
->
GetObjectClass
(
lNativeActivity
);
jmethodID
MethodGetApp
=
jni
->
GetMethodID
(
ClassNativeActivity
,
"getApplication"
,
"()Landroid/app/Application;"
);
jobject
application
=
jni
->
CallObjectMethod
(
lNativeActivity
,
MethodGetApp
);
jclass
classApp
=
jni
->
GetObjectClass
(
application
);
jmethodID
glversionMethod
=
jni
->
GetMethodID
(
classApp
,
"getYScale"
,
"()F"
);
ret
=
jni
->
CallFloatMethod
(
application
,
glversionMethod
);
jni
->
DeleteLocalRef
(
classApp
);
jni
->
DeleteLocalRef
(
ClassNativeActivity
);
app
->
activity
->
vm
->
DetachCurrentThread
();
return
ret
;
}
//Retrive last deck name.
irr
::
io
::
path
getLastDeck
(
ANDROID_APP
app
)
{
...
...
libcore/android/android_tools.h
View file @
a0f08346
...
...
@@ -141,6 +141,10 @@ extern int getCardQuality(ANDROID_APP app);
//Retrive local ip address(mostly for wifi only);
extern
int
getLocalAddr
(
ANDROID_APP
app
);
extern
float
getXScale
(
ANDROID_APP
app
);
extern
float
getYScale
(
ANDROID_APP
app
);
//Retrive font path.
extern
irr
::
io
::
path
getFontPath
(
ANDROID_APP
app
);
...
...
libcore/src/main/java/cn/garymb/ygomobile/GameApplication.java
View file @
a0f08346
...
...
@@ -53,6 +53,16 @@ public abstract class GameApplication extends Application implements IrrlichtBri
isInitSoundEffectPool
=
initSoundEffectPool
;
}
public
int
getGameWidth
(){
return
1024
;
}
public
int
getGameHeight
(){
return
640
;
}
public
abstract
boolean
isKeepScale
();
@SuppressWarnings
(
"deprecation"
)
public
void
initSoundEffectPool
()
{
mSoundEffectPool
=
new
SoundPool
(
2
,
AudioManager
.
STREAM_MUSIC
,
0
);
...
...
@@ -75,10 +85,6 @@ public abstract class GameApplication extends Application implements IrrlichtBri
public
abstract
float
getSmallerSize
();
public
abstract
float
getXScale
();
public
abstract
float
getYScale
();
public
abstract
boolean
isLockSreenOrientation
();
public
abstract
boolean
isSensorRefresh
();
...
...
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
View file @
a0f08346
...
...
@@ -84,6 +84,7 @@ public class YGOMobileActivity extends NativeActivity implements
private
FrameLayout
mLayout
;
private
SurfaceView
mSurfaceView
;
private
boolean
replaced
=
false
;
private
static
boolean
USE_SURFACE
=
true
;
// public static int notchHeight;
...
...
@@ -105,7 +106,9 @@ public class YGOMobileActivity extends NativeActivity implements
@SuppressWarnings
(
"WrongConstant"
)
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
mSurfaceView
=
new
SurfaceView
(
this
);
if
(
USE_SURFACE
)
{
mSurfaceView
=
new
SurfaceView
(
this
);
}
super
.
onCreate
(
savedInstanceState
);
Log
.
e
(
"YGOStarter"
,
"跳转完成"
+
System
.
currentTimeMillis
());
mFullScreenUtils
=
new
FullScreenUtils
(
this
,
app
().
isImmerSiveMode
());
...
...
@@ -218,28 +221,24 @@ public class YGOMobileActivity extends NativeActivity implements
if
(
app
().
isImmerSiveMode
())
{
mFullScreenUtils
.
fullscreen
();
app
().
attachGame
(
this
);
changeGameSize
();
if
(
USE_SURFACE
)
{
changeGameSize
();
}
else
{
int
[]
size
=
getGameSize
();
if
(
app
().
isKeepScale
())
{
getWindow
().
setLayout
(
size
[
0
],
size
[
1
]);
}
}
}
}
private
int
[]
getGameSize
(){
//调整padding
float
screenW
=
app
().
getScreenWidth
();
float
screenH
=
app
().
getScreenHeight
();
float
sH
=
screenH
/
1024.0f
;
float
sW
=
screenW
/
640.0f
;
float
xScale
,
yScale
;
//取最小值
if
(
sH
<
sW
){
xScale
=
sH
;
yScale
=
sH
;
}
else
{
xScale
=
sW
;
yScale
=
sW
;
}
int
w
=
(
int
)(
1024.0
*
xScale
);
int
h
=
(
int
)
(
640.0
*
yScale
);
float
xScale
=
app
().
getXScale
();
float
yScale
=
app
().
getYScale
();
int
w
=
(
int
)
(
app
().
getGameWidth
()
*
xScale
);
int
h
=
(
int
)
(
app
().
getGameHeight
()
*
yScale
);
Log
.
i
(
"kk"
,
"w1="
+
app
().
getGameWidth
()
+
",h1="
+
app
().
getGameHeight
()
+
",w2="
+
w
+
",h2="
+
h
+
",xScale="
+
xScale
+
",yScale="
+
yScale
);
return
new
int
[]{
w
,
h
};
}
...
...
@@ -259,21 +258,28 @@ public class YGOMobileActivity extends NativeActivity implements
@Override
public
void
setContentView
(
View
view
)
{
mLayout
=
new
FrameLayout
(
this
);
int
[]
size
=
getGameSize
();
int
w
=
size
[
0
];
int
h
=
size
[
1
];
mLayout
=
new
FrameLayout
(
this
);
FrameLayout
.
LayoutParams
lp
=
new
FrameLayout
.
LayoutParams
(
w
,
h
);
lp
.
gravity
=
Gravity
.
CENTER
;
mLayout
.
addView
(
mSurfaceView
,
lp
);
mLayout
.
addView
(
view
,
lp
);
super
.
setContentView
(
mLayout
);
app
().
attachGame
(
this
);
changeGameSize
();
getWindow
().
takeSurface
(
null
);
replaced
=
true
;
mSurfaceView
.
getHolder
().
addCallback
(
this
);
mSurfaceView
.
requestFocus
();
if
(
USE_SURFACE
)
{
mLayout
.
addView
(
mSurfaceView
,
lp
);
mLayout
.
addView
(
view
,
lp
);
super
.
setContentView
(
mLayout
);
app
().
attachGame
(
this
);
changeGameSize
();
getWindow
().
takeSurface
(
null
);
replaced
=
true
;
mSurfaceView
.
getHolder
().
addCallback
(
this
);
mSurfaceView
.
requestFocus
();
}
else
{
mLayout
.
addView
(
view
,
lp
);
getWindow
().
setLayout
(
w
,
h
);
getWindow
().
setGravity
(
Gravity
.
CENTER
);
super
.
setContentView
(
mLayout
);
}
}
private
void
changeGameSize
(){
...
...
@@ -479,32 +485,40 @@ public class YGOMobileActivity extends NativeActivity implements
@Override
public
void
surfaceCreated
(
SurfaceHolder
holder
)
{
if
(!
replaced
){
return
;
if
(
USE_SURFACE
)
{
if
(!
replaced
)
{
return
;
}
}
super
.
surfaceCreated
(
holder
);
}
@Override
public
void
surfaceChanged
(
SurfaceHolder
holder
,
int
format
,
int
width
,
int
height
)
{
if
(!
replaced
){
return
;
if
(
USE_SURFACE
)
{
if
(!
replaced
)
{
return
;
}
}
super
.
surfaceChanged
(
holder
,
format
,
width
,
height
);
}
@Override
public
void
surfaceDestroyed
(
SurfaceHolder
holder
)
{
if
(!
replaced
){
return
;
if
(
USE_SURFACE
)
{
if
(!
replaced
)
{
return
;
}
}
super
.
surfaceDestroyed
(
holder
);
}
@Override
public
void
surfaceRedrawNeeded
(
SurfaceHolder
holder
)
{
if
(!
replaced
){
return
;
if
(
USE_SURFACE
)
{
if
(!
replaced
)
{
return
;
}
}
super
.
surfaceRedrawNeeded
(
holder
);
}
...
...
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
View file @
a0f08346
...
...
@@ -177,6 +177,10 @@ public final class IrrlichtBridge {
void
runWindbot
(
String
args
);
float
getXScale
();
float
getYScale
();
// float getSmallerSize();
// float getXScale();
// float getYScale();
...
...
mobile/src/main/java/cn/garymb/ygomobile/App.java
View file @
a0f08346
...
...
@@ -4,7 +4,6 @@ package cn.garymb.ygomobile;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.util.Log
;
import
android.widget.ImageView
;
import
androidx.appcompat.app.AppCompatDelegate
;
...
...
@@ -54,12 +53,12 @@ public class App extends GameApplication {
@Override
public
float
getXScale
()
{
return
AppsSettings
.
get
().
getXScale
();
return
AppsSettings
.
get
().
getXScale
(
getGameWidth
(),
getGameHeight
()
);
}
@Override
public
float
getYScale
()
{
return
AppsSettings
.
get
().
getYScale
();
return
AppsSettings
.
get
().
getYScale
(
getGameWidth
(),
getGameHeight
()
);
}
@Override
...
...
@@ -72,6 +71,10 @@ public class App extends GameApplication {
return
AppsSettings
.
get
().
getFontPath
();
}
@Override
public
boolean
isKeepScale
()
{
return
AppsSettings
.
get
().
isKeepScale
();
}
@Override
public
void
saveSetting
(
String
key
,
String
value
)
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
View file @
a0f08346
package
cn.garymb.ygomobile
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.graphics.Point
;
import
android.os.Environment
;
import
android.text.TextUtils
;
import
android.util.DisplayMetrics
;
import
android.util.Log
;
import
android.view.WindowManager
;
...
...
@@ -14,7 +12,6 @@ import org.json.JSONArray;
import
java.io.File
;
import
java.io.FileFilter
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
...
...
@@ -23,15 +20,14 @@ import java.util.Locale;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.preference.PreferenceFragmentPlus
;
import
cn.garymb.ygomobile.utils.DeckUtil
;
import
cn.garymb.ygomobile.utils.FileLogUtil
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.SystemUtils
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_DECK_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_EXPANSIONS
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_PACK_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_SYSTEM_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
DEF_PREF_FONT_SIZE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
DEF_PREF_KEEP_SCALE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
DEF_PREF_NOTCH_HEIGHT
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
DEF_PREF_ONLY_GAME
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
DEF_PREF_READ_EX
;
...
...
@@ -39,6 +35,7 @@ import static cn.garymb.ygomobile.Constants.PREF_DEF_IMMERSIVE_MODE;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_DEF_SENSOR_REFRESH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_FONT_SIZE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_IMMERSIVE_MODE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_KEEP_SCALE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_LOCK_SCREEN
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_NOTCH_HEIGHT
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_ONLY_GAME
;
...
...
@@ -53,8 +50,9 @@ public class AppsSettings {
private
static
AppsSettings
sAppsSettings
;
private
Context
context
;
private
PreferenceFragmentPlus
.
SharedPreferencesPlus
mSharedPreferences
;
private
float
mScreenHeight
,
mScreenWidth
,
mDensity
;
private
float
mDensity
;
private
final
Point
mScreenSize
=
new
Point
();
private
final
Point
mRealScreenSize
=
new
Point
();
private
AppsSettings
(
Context
context
)
{
this
.
context
=
context
;
...
...
@@ -78,64 +76,13 @@ public class AppsSettings {
return
new
File
(
getResourcePath
(),
CORE_SYSTEM_PATH
);
}
private
static
float
getScale
(
float
srcWidth
,
float
srcHeight
,
float
destWidth
,
float
destHeight
)
{
float
sx
=
srcWidth
/
destWidth
;
float
sy
=
srcHeight
==
0
?
(
sx
+
1.0f
)
:
(
srcHeight
/
destHeight
);
return
Math
.
min
(
sx
,
sy
);
}
public
void
update
(
Context
context
)
{
WindowManager
wm
=
(
WindowManager
)
context
.
getSystemService
(
Context
.
WINDOW_SERVICE
);
Point
size
=
new
Point
();
//真实宽高
wm
.
getDefaultDisplay
().
getRealSize
(
size
);
//应用尺寸
wm
.
getDefaultDisplay
().
getSize
(
mScreenSize
);
//屏幕尺寸
wm
.
getDefaultDisplay
().
getRealSize
(
mRealScreenSize
);
mDensity
=
context
.
getResources
().
getDisplayMetrics
().
density
;
mScreenHeight
=
size
.
y
;
mScreenWidth
=
size
.
x
;
if
(
isImmerSiveMode
()
&&
context
instanceof
Activity
)
{
DisplayMetrics
dm
=
SystemUtils
.
getHasVirtualDisplayMetrics
((
Activity
)
context
);
if
(
dm
!=
null
)
{
int
height
=
Math
.
max
(
dm
.
widthPixels
,
dm
.
heightPixels
);
Log
.
e
(
"YGOMobileLog"
,
"类地址"
+
System
.
identityHashCode
(
this
));
int
notchHeight
=
getNotchHeight
();
try
{
FileLogUtil
.
writeAndTime
(
"是否沉浸: "
+
isImmerSiveMode
());
FileLogUtil
.
writeAndTime
(
"原始长: "
+
mScreenHeight
);
FileLogUtil
.
writeAndTime
(
"原始宽: "
+
mScreenWidth
);
FileLogUtil
.
writeAndTime
(
"界面长: "
+
dm
.
heightPixels
);
FileLogUtil
.
writeAndTime
(
"界面宽: "
+
dm
.
widthPixels
);
FileLogUtil
.
writeAndTime
(
"刘海长: "
+
notchHeight
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
height
-=
notchHeight
;
try
{
FileLogUtil
.
writeAndTime
(
"处理后height值: "
+
height
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
if
(
mScreenHeight
>
mScreenWidth
)
{
mScreenHeight
=
height
;
}
else
{
mScreenWidth
=
height
;
}
try
{
FileLogUtil
.
writeAndTime
(
"转换后长: "
+
mScreenHeight
);
FileLogUtil
.
writeAndTime
(
"转换后宽: "
+
mScreenWidth
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
public
int
getAppVersion
()
{
...
...
@@ -146,17 +93,14 @@ public class AppsSettings {
mSharedPreferences
.
putInt
(
PREF_VERSION
,
ver
);
}
public
PreferenceFragmentPlus
.
SharedPreferencesPlus
getSharedPreferences
()
{
return
mSharedPreferences
;
}
public
float
getSmallerSize
()
{
return
mScreenHeight
<
mScreenWidth
?
mScreenHeight
:
mScreenWidth
;
}
public
float
getScreenWidth
()
{
return
Math
.
min
(
mScreenWidth
,
mScreenHeight
);
float
w
=
getScreenWidth
();
float
h
=
getScreenHeight
();
return
h
<
w
?
h
:
w
;
}
public
boolean
isDialogDelete
()
{
...
...
@@ -190,16 +134,56 @@ public class AppsSettings {
return
false
;
//mSharedPreferences.getBoolean(PREF_DECK_MANAGER_V2, DEF_PREF_DECK_MANAGER_V2);
}
public
float
getXScale
()
{
return
getScreenHeight
()
/
(
float
)
Constants
.
CORE_SKIN_BG_SIZE
[
0
];
public
float
getXScale
(
int
w
,
int
h
)
{
if
(
isKeepScale
()){
float
sx
=
getScreenHeight
()
/
w
;
float
sy
=
getScreenWidth
()
/
h
;
return
Math
.
min
(
sx
,
sy
);
}
return
getScreenHeight
()
/
w
;
}
public
float
getYScale
(
int
w
,
int
h
)
{
if
(
isKeepScale
()){
//固定比例,取最小值
float
sx
=
getScreenHeight
()
/
w
;
float
sy
=
getScreenWidth
()
/
h
;
return
Math
.
min
(
sx
,
sy
);
}
return
getScreenWidth
()
/
h
;
}
public
float
getYScale
()
{
return
getScreenWidth
()
/
(
float
)
Constants
.
CORE_SKIN_BG_SIZE
[
1
];
public
boolean
isKeepScale
(){
return
mSharedPreferences
.
getBoolean
(
PREF_KEEP_SCALE
,
DEF_PREF_KEEP_SCALE
);
}
public
float
getScreenWidth
()
{
int
w
,
h
;
if
(
isImmerSiveMode
())
{
w
=
mRealScreenSize
.
x
;
h
=
mRealScreenSize
.
y
;
}
else
{
w
=
mScreenSize
.
x
;
h
=
mScreenSize
.
y
;
}
return
Math
.
min
(
w
,
h
);
}
public
float
getScreenHeight
()
{
return
Math
.
max
(
mScreenWidth
,
mScreenHeight
);
int
w
,
h
;
if
(
isImmerSiveMode
())
{
w
=
mRealScreenSize
.
x
;
h
=
mRealScreenSize
.
y
;
}
else
{
w
=
mScreenSize
.
x
;
h
=
mScreenSize
.
y
;
}
int
ret
=
Math
.
max
(
w
,
h
);
if
(
isImmerSiveMode
()){
//刘海高度
ret
-=
getNotchHeight
();
}
return
ret
;
}
/**
...
...
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
View file @
a0f08346
...
...
@@ -116,6 +116,9 @@ public interface Constants {
String
PREF_DECK_MANAGER_V2
=
"pref_settings_deck_manager_v2"
;
boolean
DEF_PREF_DECK_MANAGER_V2
=
false
;
String
PREF_KEEP_SCALE
=
"pref_settings_keep_scale"
;
boolean
DEF_PREF_KEEP_SCALE
=
false
;
int
REQUEST_CUT_IMG
=
0x1000
+
0x10
;
int
REQUEST_CHOOSE_FILE
=
0x1000
+
0x20
;
int
REQUEST_CHOOSE_IMG
=
0x1000
+
0x21
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/fragments/SettingFragment.java
View file @
a0f08346
...
...
@@ -61,6 +61,7 @@ import static cn.garymb.ygomobile.Constants.PREF_GAME_FONT;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_GAME_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_IMAGE_QUALITY
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_IMMERSIVE_MODE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_KEEP_SCALE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_LOCK_SCREEN
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_ONLY_GAME
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
PREF_OPENGL_VERSION
;
...
...
@@ -146,6 +147,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
bind
(
SETTINGS_CARD_BG
,
new
File
(
mSettings
.
getCoreSkinPath
(),
Constants
.
CORE_SKIN_BG
).
getAbsolutePath
());
bind
(
PREF_FONT_SIZE
,
mSettings
.
getFontSize
());
bind
(
PREF_ONLY_GAME
,
mSettings
.
isOnlyGame
());
bind
(
PREF_KEEP_SCALE
,
mSettings
.
isKeepScale
());
isInit
=
false
;
}
...
...
mobile/src/main/res/values-ko/strings.xml
View file @
a0f08346
...
...
@@ -270,4 +270,5 @@
<string
name=
"donot_editor_bot_Deck"
>
덱을 변경하지 말아 주세요. 그러면 프로그램이 제대로 작동하지 않을 수 있습니다.
</string>
<string
name=
"unable_to_edit_empty_deck"
>
사용할 수 없는 빈 구역
</string>
<string
name=
"create_new_failed"
>
생성실패
</string>
<string
name=
"about_pref_settings_keep_scale"
>
Keep Display Scale
</string>
</resources>
mobile/src/main/res/values-zh/strings.xml
View file @
a0f08346
...
...
@@ -269,4 +269,5 @@
<string
name=
"donot_editor_bot_Deck"
>
请不要更改/删除AI卡组否则会导致人机模式无法正常使用
</string>
<string
name=
"unable_to_edit_empty_deck"
>
不可操作空卡组
</string>
<string
name=
"create_new_failed"
>
创建失败
</string>
<string
name=
"about_pref_settings_keep_scale"
>
游戏画面比例固定
</string>
</resources>
mobile/src/main/res/values/strings.xml
View file @
a0f08346
...
...
@@ -272,4 +272,5 @@
<string
name=
"screenshoot"
>
Screenshoot
</string>
<string
name=
"unable_to_edit_empty_deck"
>
unable to edit empty deck
</string>
<string
name=
"create_new_failed"
>
Create Failed
</string>
<string
name=
"about_pref_settings_keep_scale"
>
Keep Display Scale
</string>
</resources>
mobile/src/main/res/xml/preference_game.xml
View file @
a0f08346
...
...
@@ -13,6 +13,12 @@
<Preference
android:key=
"pref_key_change_log"
android:title=
"@string/settings_about_change_log"
/>
<CheckBoxPreference
android:key=
"pref_settings_keep_scale"
android:persistent=
"false"
android:title=
"@string/about_pref_settings_keep_scale"
/>
<ListPreference
android:entries=
"@array/opengl_version"
android:entryValues=
"@array/opengl_version_value"
...
...
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