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
c99935ed
Commit
c99935ed
authored
Oct 04, 2019
by
kenan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
固定比例开关
parent
2fe782e3
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
127 additions
and
54 deletions
+127
-54
Classes/gframe/game.cpp
Classes/gframe/game.cpp
+4
-23
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
+6
-4
libcore/src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
.../src/main/java/cn/garymb/ygomobile/YGOMobileActivity.java
+7
-17
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
+14
-1
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
+27
-9
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
+4
-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/game.cpp
View file @
c99935ed
...
...
@@ -35,19 +35,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
);
...
...
@@ -61,13 +48,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,10 +73,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, xStart=%f, yStart=%f"
,
xScale
,
yScale
,
xStart
,
yStart
);
Printer
::
log
(
log_scale
);
...
...
libcore/android/android_tools.cpp
View file @
c99935ed
...
...
@@ -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 @
c99935ed
...
...
@@ -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 @
c99935ed
...
...
@@ -53,6 +53,12 @@ public abstract class GameApplication extends Application implements IrrlichtBri
isInitSoundEffectPool
=
initSoundEffectPool
;
}
public
abstract
int
getGameWidth
();
public
abstract
int
getGameHeight
();
public
abstract
boolean
isKeepScale
();
@SuppressWarnings
(
"deprecation"
)
public
void
initSoundEffectPool
()
{
mSoundEffectPool
=
new
SoundPool
(
2
,
AudioManager
.
STREAM_MUSIC
,
0
);
...
...
@@ -75,10 +81,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 @
c99935ed
...
...
@@ -212,30 +212,20 @@ public class YGOMobileActivity extends NativeActivity implements
if
(
app
().
isImmerSiveMode
())
{
mFullScreenUtils
.
fullscreen
();
app
().
attachGame
(
this
);
//游戏大小
int
[]
size
=
getGameSize
();
getWindow
().
setLayout
(
size
[
0
],
size
[
1
]);
}
}
private
int
[]
getGameSize
(){
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"
,
"w="
+
w
+
",h="
+
h
+
",xScale="
+
xScale
+
",yScale="
+
yScale
);
return
new
int
[]{
w
,
h
};
}
...
...
libcore/src/main/java/cn/garymb/ygomobile/core/IrrlichtBridge.java
View file @
c99935ed
...
...
@@ -170,6 +170,10 @@ public final class IrrlichtBridge {
void
playSoundEffect
(
String
path
);
void
runWindbot
(
String
args
);
float
getXScale
();
float
getYScale
();
// float getSmallerSize();
// float getXScale();
...
...
mobile/src/main/java/cn/garymb/ygomobile/App.java
View file @
c99935ed
...
...
@@ -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
;
...
...
@@ -72,6 +71,20 @@ public class App extends GameApplication {
return
AppsSettings
.
get
().
getFontPath
();
}
@Override
public
boolean
isKeepScale
()
{
return
AppsSettings
.
get
().
isKeepScale
();
}
@Override
public
int
getGameHeight
()
{
return
Constants
.
CORE_GAME_SIZE
[
1
];
}
@Override
public
int
getGameWidth
()
{
return
Constants
.
CORE_GAME_SIZE
[
0
];
}
@Override
public
void
saveSetting
(
String
key
,
String
value
)
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
View file @
c99935ed
...
...
@@ -32,6 +32,7 @@ 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 +40,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
;
...
...
@@ -78,13 +80,6 @@ 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
();
...
...
@@ -190,12 +185,35 @@ public class AppsSettings {
return
false
;
//mSharedPreferences.getBoolean(PREF_DECK_MANAGER_V2, DEF_PREF_DECK_MANAGER_V2);
}
public
float
getGameHeight
()
{
return
(
float
)
Constants
.
CORE_GAME_SIZE
[
1
];
}
public
float
getGameWidth
()
{
return
(
float
)
Constants
.
CORE_GAME_SIZE
[
0
];
}
public
float
getXScale
()
{
return
getScreenHeight
()
/
(
float
)
Constants
.
CORE_SKIN_BG_SIZE
[
0
];
if
(
isKeepScale
()){
float
sx
=
getScreenHeight
()
/
getGameWidth
();
float
sy
=
getScreenWidth
()
/
getGameHeight
();
return
Math
.
min
(
sx
,
sy
);
}
return
getScreenHeight
()
/
getGameWidth
();
}
public
float
getYScale
()
{
return
getScreenWidth
()
/
(
float
)
Constants
.
CORE_SKIN_BG_SIZE
[
1
];
if
(
isKeepScale
()){
//固定比例,取最小值
float
sx
=
getScreenHeight
()
/
getGameWidth
();
float
sy
=
getScreenWidth
()
/
getGameHeight
();
return
Math
.
min
(
sx
,
sy
);
}
return
getScreenWidth
()
/
getGameHeight
();
}
public
boolean
isKeepScale
(){
return
mSharedPreferences
.
getBoolean
(
PREF_KEEP_SCALE
,
DEF_PREF_KEEP_SCALE
);
}
public
float
getScreenHeight
()
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
View file @
c99935ed
...
...
@@ -90,6 +90,7 @@ public interface Constants {
String
CORE_SKIN_AVATAR_OPPONENT
=
"opponent.jpg"
;
String
UNKNOWN_IMAGE
=
"unknown.jpg"
;
String
YDK_FILE_EX
=
".ydk"
;
int
[]
CORE_GAME_SIZE
=
new
int
[]{
1024
,
640
};
int
[]
CORE_SKIN_BG_SIZE
=
new
int
[]{
1280
,
720
};
int
[]
CORE_SKIN_CARD_COVER_SIZE
=
new
int
[]{
177
,
254
};
int
[]
CORE_SKIN_AVATAR_SIZE
=
new
int
[]{
128
,
128
};
...
...
@@ -116,6 +117,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 @
c99935ed
...
...
@@ -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 @
c99935ed
...
...
@@ -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 @
c99935ed
...
...
@@ -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 @
c99935ed
...
...
@@ -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 @
c99935ed
...
...
@@ -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