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
e948dac0
Commit
e948dac0
authored
Jul 11, 2020
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add random carddetail layout
test 3dlayout
parent
abc66ec9
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
726 additions
and
8 deletions
+726
-8
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
+99
-8
mobile/src/main/java/cn/garymb/ygomobile/utils/ThreeDLayoutUtil.java
...main/java/cn/garymb/ygomobile/utils/ThreeDLayoutUtil.java
+355
-0
mobile/src/main/res/layout/dialog_cardinfo_small.xml
mobile/src/main/res/layout/dialog_cardinfo_small.xml
+272
-0
No files found.
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
View file @
e948dac0
package
cn.garymb.ygomobile
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.content.ComponentName
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.ActivityInfo
;
import
android.graphics.Bitmap
;
import
android.graphics.drawable.Drawable
;
import
android.os.Build
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.appcompat.app.ActionBar
;
...
...
@@ -26,12 +31,100 @@ import java.util.HashMap;
import
cn.garymb.ygodata.YGOGameOptions
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.loader.ImageLoader
;
import
cn.garymb.ygomobile.ui.activities.BaseActivity
;
import
cn.garymb.ygomobile.ui.plus.ViewTargetPlus
;
import
cn.garymb.ygomobile.utils.CardUtils
;
import
cn.garymb.ygomobile.utils.ComponentUtils
;
import
cn.garymb.ygomobile.utils.ThreeDLayoutUtil
;
import
ocgcore.CardManager
;
import
ocgcore.StringManager
;
import
ocgcore.data.Card
;
import
ocgcore.enums.CardType
;
import
static
android
.
view
.
View
.
inflate
;
public
class
YGOStarter
{
private
static
Bitmap
mLogo
;
private
ImageView
cardImage
;
private
TextView
name
;
private
TextView
desc
;
private
TextView
level
;
private
TextView
type
;
private
TextView
race
;
private
TextView
cardAtk
;
private
TextView
cardDef
;
private
TextView
otView
;
private
TextView
attrView
;
private
View
linkArrow
;
private
View
monsterlayout
;
private
View
layout_detail_p_scale
;
private
View
atkdefView
;
private
TextView
detail_cardscale
;
public
void
RandomCardDetail
(
Context
context
,
ImageLoader
imageLoader
,
Card
cardInfo
,
StringManager
stringManager
,
View
view
)
{
ThreeDLayoutUtil
cardDetail
=
(
ThreeDLayoutUtil
)
inflate
(
context
,
R
.
layout
.
dialog_cardinfo_small
,
null
);
cardImage
=
cardDetail
.
findViewById
(
R
.
id
.
card_image
);
name
=
cardDetail
.
findViewById
(
R
.
id
.
text_name
);
level
=
cardDetail
.
findViewById
(
R
.
id
.
card_level
);
linkArrow
=
cardDetail
.
findViewById
(
R
.
id
.
detail_link_arrows
);
race
=
cardDetail
.
findViewById
(
R
.
id
.
card_race
);
attrView
=
cardDetail
.
findViewById
(
R
.
id
.
card_attribute
);
type
=
cardDetail
.
findViewById
(
R
.
id
.
card_type
);
cardAtk
=
cardDetail
.
findViewById
(
R
.
id
.
card_atk
);
cardDef
=
cardDetail
.
findViewById
(
R
.
id
.
card_def
);
atkdefView
=
cardDetail
.
findViewById
(
R
.
id
.
layout_atkdef2
);
desc
=
cardDetail
.
findViewById
(
R
.
id
.
text_desc
);
monsterlayout
=
cardDetail
.
findViewById
(
R
.
id
.
layout_monster
);
layout_detail_p_scale
=
cardDetail
.
findViewById
(
R
.
id
.
detail_p_scale
);
detail_cardscale
=
cardDetail
.
findViewById
(
R
.
id
.
detail_cardscale
);
if
(
cardInfo
==
null
)
return
;
imageLoader
.
bindImage
(
cardImage
,
cardInfo
.
Code
,
null
,
true
);
name
.
setText
(
cardInfo
.
Name
);
type
.
setText
(
CardUtils
.
getAllTypeString
(
cardInfo
,
stringManager
).
replace
(
"/"
,
"|"
));
attrView
.
setText
(
stringManager
.
getAttributeString
(
cardInfo
.
Attribute
));
desc
.
setText
(
cardInfo
.
Desc
);
if
(
cardInfo
.
isType
(
CardType
.
Monster
))
{
atkdefView
.
setVisibility
(
View
.
VISIBLE
);
monsterlayout
.
setVisibility
(
View
.
VISIBLE
);
race
.
setVisibility
(
View
.
VISIBLE
);
String
star
=
"★"
+
cardInfo
.
getStar
();
level
.
setText
(
star
);
if
(
cardInfo
.
isType
(
CardType
.
Xyz
))
{
level
.
setTextColor
(
context
.
getResources
().
getColor
(
R
.
color
.
star_rank
));
}
else
{
level
.
setTextColor
(
context
.
getResources
().
getColor
(
R
.
color
.
star
));
}
if
(
cardInfo
.
isType
(
CardType
.
Pendulum
))
{
layout_detail_p_scale
.
setVisibility
(
View
.
VISIBLE
);
detail_cardscale
.
setText
(
String
.
valueOf
(
cardInfo
.
LScale
));
}
else
{
layout_detail_p_scale
.
setVisibility
(
View
.
GONE
);
}
cardAtk
.
setText
((
cardInfo
.
Attack
<
0
?
"?"
:
String
.
valueOf
(
cardInfo
.
Attack
)));
//连接怪兽设置
if
(
cardInfo
.
isType
(
CardType
.
Link
))
{
level
.
setVisibility
(
View
.
GONE
);
linkArrow
.
setVisibility
(
View
.
VISIBLE
);
cardDef
.
setText
((
cardInfo
.
getStar
()
<
0
?
"?"
:
"LINK-"
+
String
.
valueOf
(
cardInfo
.
getStar
())));
BaseActivity
.
showLinkArrows
(
cardInfo
,
view
);
}
else
{
level
.
setVisibility
(
View
.
VISIBLE
);
linkArrow
.
setVisibility
(
View
.
GONE
);
cardDef
.
setText
((
cardInfo
.
Defense
<
0
?
"?"
:
String
.
valueOf
(
cardInfo
.
Defense
)));
}
race
.
setText
(
stringManager
.
getRaceString
(
cardInfo
.
Race
));
}
else
{
atkdefView
.
setVisibility
(
View
.
GONE
);
race
.
setVisibility
(
View
.
GONE
);
monsterlayout
.
setVisibility
(
View
.
GONE
);
level
.
setVisibility
(
View
.
GONE
);
linkArrow
.
setVisibility
(
View
.
GONE
);
}
}
private
static
void
setFullScreen
(
Activity
activity
,
ActivityShowInfo
activityShowInfo
)
{
activity
.
getWindow
().
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_FULLSCREEN
,
...
...
@@ -73,8 +166,6 @@ public class YGOStarter {
return
;
}
activityShowInfo
.
isRunning
=
true
;
// Log.i("checker", "show:" + activity);
// activityShowInfo.oldRequestedOrientation = activity.getRequestedOrientation();
activityShowInfo
.
rootOld
=
activityShowInfo
.
mRoot
.
getBackground
();
activityShowInfo
.
mContentView
.
setVisibility
(
View
.
INVISIBLE
);
//读取当前的背景图,如果卡的话,可以考虑缓存bitmap
...
...
@@ -157,18 +248,18 @@ public class YGOStarter {
//如果距离上次加入游戏的时间大于1秒才处理
if
(
System
.
currentTimeMillis
()
-
lasttime
>=
1000
)
{
lasttime
=
System
.
currentTimeMillis
();
Log
.
e
(
"YGOStarter"
,
"设置背景前"
+
System
.
currentTimeMillis
());
Log
.
e
(
"YGOStarter"
,
"设置背景前"
+
System
.
currentTimeMillis
());
//显示加载背景
showLoadingBg
(
activity
);
Log
.
e
(
"YGOStarter"
,
"设置背景后"
+
System
.
currentTimeMillis
());
Log
.
e
(
"YGOStarter"
,
"设置背景后"
+
System
.
currentTimeMillis
());
if
(!
ComponentUtils
.
isActivityRunning
(
activity
,
new
ComponentName
(
activity
,
YGOMobileActivity
.
class
)))
{
//random tips
String
[]
tipsList
=
activity
.
getResources
().
getStringArray
(
R
.
array
.
tips
);
int
x
=
(
int
)
(
Math
.
random
()
*
tipsList
.
length
);
String
tips
=
tipsList
[
x
];
Toast
.
makeText
(
activity
,
tips
,
Toast
.
LENGTH_LONG
).
show
();
// } else {
// options = null;
//random carddetail
}
Intent
intent
=
new
Intent
(
activity
,
YGOMobileActivity
.
class
);
if
(
options
!=
null
)
{
...
...
@@ -176,9 +267,9 @@ public class YGOStarter {
intent
.
putExtra
(
YGOGameOptions
.
YGO_GAME_OPTIONS_BUNDLE_TIME
,
System
.
currentTimeMillis
());
}
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
Log
.
e
(
"YGOStarter"
,
"跳转前"
+
System
.
currentTimeMillis
());
Log
.
e
(
"YGOStarter"
,
"跳转前"
+
System
.
currentTimeMillis
());
activity
.
startActivity
(
intent
);
Log
.
e
(
"YGOStarter"
,
"跳转后"
+
System
.
currentTimeMillis
());
Log
.
e
(
"YGOStarter"
,
"跳转后"
+
System
.
currentTimeMillis
());
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/ThreeDLayoutUtil.java
0 → 100644
View file @
e948dac0
package
cn.garymb.ygomobile.utils
;
import
android.animation.Animator
;
import
android.animation.ValueAnimator
;
import
android.content.Context
;
import
android.graphics.Camera
;
import
android.graphics.Canvas
;
import
android.graphics.Color
;
import
android.graphics.Matrix
;
import
android.util.AttributeSet
;
import
android.util.DisplayMetrics
;
import
android.util.Log
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.ViewGroup
;
/*
* Created by wing on 10/14/16.
*/
public
class
ThreeDLayoutUtil
extends
ViewGroup
{
private
Camera
mCamera
;
private
Matrix
mMatrix
;
//this viewgroup's center
private
int
mCenterX
;
private
int
mCenterY
;
//rotateDegree
private
float
mCanvasRotateY
;
private
float
mCanvasRotateX
;
private
float
mCanvasMaxRotateDegree
=
50
;
//the touch mode
public
static
int
MODE_X
=
0
;
public
static
int
MODE_Y
=
1
;
public
static
int
MODE_BOTH_X_Y
=
2
;
private
int
mMode
=
MODE_BOTH_X_Y
;
private
float
mDensity
;
private
float
[]
mValues
=
new
float
[
9
];
//the flag of touch
private
boolean
isCanTouch
=
false
;
//the degree of animation
private
float
mDegreeY
=
0
;
private
float
mDegreeX
=
0
;
//the flag of animate
private
boolean
isPlaying
=
false
;
//the degree of longer animate
private
int
mLoopAnimateY
=
0
;
public
ThreeDLayoutUtil
(
Context
context
)
{
this
(
context
,
null
);
}
public
ThreeDLayoutUtil
(
Context
context
,
AttributeSet
attrs
)
{
this
(
context
,
attrs
,
0
);
}
public
ThreeDLayoutUtil
(
Context
context
,
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
//set a default background to make sure onDraw() dispatch
if
(
getBackground
()
==
null
)
{
setBackgroundColor
(
Color
.
parseColor
(
"#00ffffff"
));
}
DisplayMetrics
dm
=
new
DisplayMetrics
();
dm
=
getResources
().
getDisplayMetrics
();
mDensity
=
dm
.
density
;
mCamera
=
new
Camera
();
mMatrix
=
new
Matrix
();
}
@Override
protected
void
onMeasure
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
if
(
getChildCount
()
!=
1
)
{
throw
new
IllegalStateException
(
"ThreeDLayout can only have one child"
);
}
View
child
=
getChildAt
(
0
);
measureChild
(
child
,
widthMeasureSpec
,
heightMeasureSpec
);
//only one child view,so give the same size
setMeasuredDimension
(
child
.
getMeasuredWidth
(),
child
.
getMeasuredHeight
());
}
@Override
protected
void
onLayout
(
boolean
changed
,
int
l
,
int
t
,
int
r
,
int
b
)
{
View
child
=
getChildAt
(
0
);
child
.
layout
(
0
,
0
,
child
.
getMeasuredWidth
(),
child
.
getMeasuredHeight
());
}
@Override
protected
void
onSizeChanged
(
int
w
,
int
h
,
int
oldw
,
int
oldh
)
{
super
.
onSizeChanged
(
w
,
h
,
oldw
,
oldh
);
mCenterX
=
w
/
2
;
mCenterY
=
h
/
2
;
}
@Override
protected
void
onDraw
(
Canvas
canvas
)
{
mMatrix
.
reset
();
mCamera
.
save
();
if
(
mMode
==
MODE_Y
||
mMode
==
MODE_BOTH_X_Y
)
{
mCamera
.
rotateX
(
mCanvasRotateX
);
}
if
(
mMode
==
MODE_X
||
mMode
==
MODE_BOTH_X_Y
)
{
mCamera
.
rotateY
(
mCanvasRotateY
);
}
mCamera
.
rotateY
(
mDegreeY
);
mCamera
.
rotateX
(
mDegreeX
);
if
(
isPlaying
)
{
mCamera
.
rotateY
(
mLoopAnimateY
++);
Log
.
e
(
"wing"
,
mLoopAnimateY
+
""
);
if
(
mLoopAnimateY
==
360
)
{
mLoopAnimateY
=
0
;
}
invalidate
();
}
mCamera
.
getMatrix
(
mMatrix
);
// fix the Camera bug,
mMatrix
.
getValues
(
mValues
);
mValues
[
6
]
=
mValues
[
6
]
/
mDensity
;
mValues
[
7
]
=
mValues
[
7
]
/
mDensity
;
mMatrix
.
setValues
(
mValues
);
mCamera
.
restore
();
mMatrix
.
preTranslate
(-
mCenterX
,
-
mCenterY
);
mMatrix
.
postTranslate
(
mCenterX
,
mCenterY
);
canvas
.
concat
(
mMatrix
);
super
.
onDraw
(
canvas
);
}
@Override
public
boolean
onInterceptTouchEvent
(
MotionEvent
ev
)
{
if
(
isCanTouch
)
{
return
true
;
}
else
{
return
super
.
onInterceptTouchEvent
(
ev
);
}
}
@Override
public
boolean
onTouchEvent
(
MotionEvent
event
)
{
if
(
isCanTouch
)
{
float
x
=
event
.
getX
();
float
y
=
event
.
getY
();
int
action
=
event
.
getAction
();
switch
(
action
)
{
case
MotionEvent
.
ACTION_MOVE
:
{
rotateCanvasWhenMove
(
x
,
y
);
invalidate
();
return
true
;
}
case
MotionEvent
.
ACTION_UP
:
{
mDegreeY
=
0
;
rotateCanvasWhenMove
(
mCenterX
,
mCenterY
);
invalidate
();
return
true
;
}
}
return
true
;
}
else
{
return
super
.
onTouchEvent
(
event
);
}
}
/**
* get the value to rotate
*/
private
void
rotateCanvasWhenMove
(
float
x
,
float
y
)
{
float
dx
=
x
-
mCenterX
;
float
dy
=
y
-
mCenterY
;
float
percentX
=
dx
/
mCenterX
;
float
percentY
=
dy
/
mCenterY
;
if
(
percentX
>
1
f
)
{
percentX
=
1
f
;
}
else
if
(
percentX
<
-
1
f
)
{
percentX
=
-
1
f
;
}
if
(
percentY
>
1
f
)
{
percentY
=
1
f
;
}
else
if
(
percentY
<
-
1
f
)
{
percentY
=
-
1
f
;
}
mCanvasRotateY
=
mCanvasMaxRotateDegree
*
percentX
;
mCanvasRotateX
=
-(
mCanvasMaxRotateDegree
*
percentY
);
}
public
void
setTouchable
(
boolean
canTouch
)
{
isCanTouch
=
canTouch
;
}
public
void
setTouchMode
(
int
mode
)
{
mMode
=
mode
;
isCanTouch
=
true
;
}
/**
* set the max rotate degree
*/
public
void
setMaxRotateDegree
(
int
degree
)
{
mCanvasMaxRotateDegree
=
degree
;
}
/**
* start horizontal turn animate
*/
public
void
startHorizontalAnimate
(
long
duration
)
{
final
ValueAnimator
animator
=
ValueAnimator
.
ofFloat
(-
180
f
,
0
f
);
animator
.
addUpdateListener
(
new
ValueAnimator
.
AnimatorUpdateListener
()
{
@Override
public
void
onAnimationUpdate
(
ValueAnimator
animation
)
{
mDegreeY
=
(
float
)
animation
.
getAnimatedValue
();
invalidate
();
}
});
animator
.
addListener
(
new
Animator
.
AnimatorListener
()
{
@Override
public
void
onAnimationStart
(
Animator
animation
)
{
}
@Override
public
void
onAnimationEnd
(
Animator
animation
)
{
mDegreeY
=
0
;
animator
.
removeAllUpdateListeners
();
}
@Override
public
void
onAnimationCancel
(
Animator
animation
)
{
}
@Override
public
void
onAnimationRepeat
(
Animator
animation
)
{
}
});
animator
.
setDuration
(
duration
);
animator
.
start
();
}
/**
* start horizontal turn animate delayed
*/
public
void
startHorizontalAnimateDelayed
(
final
long
delayed
,
final
long
duration
)
{
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
Thread
.
sleep
(
delayed
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
startHorizontalAnimate
(
duration
);
}
});
}
}).
start
();
}
/**
* start vertical turn animate
*/
public
void
startVerticalAnimate
(
long
duration
)
{
final
ValueAnimator
animator
=
ValueAnimator
.
ofFloat
(-
180
f
,
0
f
);
animator
.
addUpdateListener
(
new
ValueAnimator
.
AnimatorUpdateListener
()
{
@Override
public
void
onAnimationUpdate
(
ValueAnimator
animation
)
{
mDegreeX
=
(
float
)
animation
.
getAnimatedValue
();
invalidate
();
}
});
animator
.
addListener
(
new
Animator
.
AnimatorListener
()
{
@Override
public
void
onAnimationStart
(
Animator
animation
)
{
}
@Override
public
void
onAnimationEnd
(
Animator
animation
)
{
mDegreeX
=
0
;
animator
.
removeAllUpdateListeners
();
}
@Override
public
void
onAnimationCancel
(
Animator
animation
)
{
}
@Override
public
void
onAnimationRepeat
(
Animator
animation
)
{
}
});
animator
.
setDuration
(
duration
);
animator
.
start
();
}
/**
* start vertical turn animate delayed
*/
public
void
startVerticalAnimateDelayed
(
final
long
delayed
,
final
long
duration
)
{
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
Thread
.
sleep
(
delayed
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
startVerticalAnimate
(
duration
);
}
});
}
}).
start
();
}
/**
* start loop animate
*/
public
void
startHorizontalAnimate
()
{
isPlaying
=
true
;
invalidate
();
}
/**
* stop the loop animate
*/
public
void
stopAnimate
()
{
isPlaying
=
false
;
mLoopAnimateY
=
0
;
invalidate
();
}
}
mobile/src/main/res/layout/dialog_cardinfo_small.xml
0 → 100644
View file @
e948dac0
This diff is collapsed.
Click to expand it.
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