mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2026-01-19 10:04:52 +01:00
Progress towards target title screen.
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
/>
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.READ_LOGS"/>
|
||||
|
||||
|
||||
<application
|
||||
android:name=".AndorsTrailApplication"
|
||||
|
||||
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:tileMode="repeat"
|
||||
android:src="@drawable/ts_sky_gradient_x2"
|
||||
android:src="@drawable/ts_sky_gradient_x6"
|
||||
android:antialias="false"
|
||||
android:dither="false"
|
||||
/>
|
||||
|
||||
@@ -1,15 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/title_bg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<include layout="@layout/title_bg_sky_layout"/>
|
||||
|
||||
<ImageView
|
||||
<com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView
|
||||
android:id="@+id/ts_clouds_animator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:elevation="10dp"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="-200sp"
|
||||
android:scaleType="centerCrop"
|
||||
android:elevation="20dp"
|
||||
android:src="@drawable/ts_foreground"/>
|
||||
|
||||
|
||||
@@ -17,7 +26,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
android:orientation="horizontal" >
|
||||
android:orientation="horizontal"
|
||||
android:elevation="30dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title_logo_placeholder_above"
|
||||
@@ -36,7 +46,7 @@
|
||||
android:id="@+id/title_logo_placeholder_left"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.2" >
|
||||
android:layout_weight="0" >
|
||||
</TextView>
|
||||
|
||||
<ImageView
|
||||
@@ -54,7 +64,7 @@
|
||||
android:id="@+id/title_logo_placeholder_right"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.6" >
|
||||
android:layout_weight="0.7" >
|
||||
</TextView>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
39
AndorsTrail/res/layout/clouds_animator.xml
Normal file
39
AndorsTrail/res/layout/clouds_animator.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/ts_clouds_below"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<RelativeLayout
|
||||
android:id="@+id/ts_clouds_below_start"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentLeft="true"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/ts_clouds_center"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<RelativeLayout
|
||||
android:id="@+id/ts_clouds_center_start"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentLeft="true"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/ts_clouds_above"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<RelativeLayout
|
||||
android:id="@+id/ts_clouds_above_start"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentLeft="true"/>
|
||||
</RelativeLayout>
|
||||
|
||||
</merge>
|
||||
@@ -1,24 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/title_bg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
|
||||
|
||||
<include layout="@layout/title_bg_sky_layout"/>
|
||||
|
||||
<com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView
|
||||
android:id="@+id/ts_clouds_animator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:elevation="10dp"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginRight="-100sp"
|
||||
android:scaleType="centerCrop"
|
||||
android:elevation="20dp"
|
||||
android:src="@drawable/ts_foreground"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
android:orientation="vertical" >
|
||||
android:orientation="vertical"
|
||||
android:elevation="30dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title_logo_placeholder_above"
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
android:orientation="vertical" >
|
||||
android:orientation="vertical"
|
||||
android:elevation="0dp" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/title_bg_top"
|
||||
|
||||
@@ -28,6 +28,7 @@ public final class LoadingActivity extends Activity implements OnResourcesLoaded
|
||||
super.onCreate(savedInstanceState);
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
app.setWindowParameters(this);
|
||||
setContentView(R.layout.startscreen);
|
||||
this.setup = app.getWorldSetup();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentManager.OnBackStackChangedListener;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
@@ -19,10 +21,18 @@ import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_NewGame;
|
||||
import com.gpl.rpg.AndorsTrail.activity.fragment.StartScreenActivity_NewGame.GameCreationOverListener;
|
||||
import com.gpl.rpg.AndorsTrail.resource.tiles.TileManager;
|
||||
import com.gpl.rpg.AndorsTrail.util.ThemeHelper;
|
||||
import com.gpl.rpg.AndorsTrail.view.CloudsAnimatorView;
|
||||
|
||||
public final class StartScreenActivity extends FragmentActivity implements OnNewGameRequestedListener, GameCreationOverListener {
|
||||
|
||||
public final class StartScreenActivity extends FragmentActivity implements OnNewGameRequestedListener, GameCreationOverListener, OnBackStackChangedListener {
|
||||
|
||||
private TextView tv;
|
||||
private TextView development_version;
|
||||
private CloudsAnimatorView clouds;
|
||||
private Fragment currentFragment;
|
||||
|
||||
//Means false by default, as a toggle is initiated in onCreate.
|
||||
boolean ui_visible = true;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
initPreferences();
|
||||
@@ -43,15 +53,17 @@ public final class StartScreenActivity extends FragmentActivity implements OnNew
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.startscreen_fragment_container, mainMenu)
|
||||
.commit();
|
||||
currentFragment = mainMenu;
|
||||
|
||||
getSupportFragmentManager().addOnBackStackChangedListener(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TextView tv = (TextView) findViewById(R.id.startscreen_version);
|
||||
tv = (TextView) findViewById(R.id.startscreen_version);
|
||||
tv.setText('v' + AndorsTrailApplication.CURRENT_VERSION_DISPLAY);
|
||||
|
||||
TextView development_version = (TextView) findViewById(R.id.startscreen_dev_version);
|
||||
development_version = (TextView) findViewById(R.id.startscreen_dev_version);
|
||||
if (AndorsTrailApplication.DEVELOPMENT_INCOMPATIBLE_SAVEGAMES) {
|
||||
development_version.setText(R.string.startscreen_incompatible_savegames);
|
||||
development_version.setVisibility(View.VISIBLE);
|
||||
@@ -59,16 +71,51 @@ public final class StartScreenActivity extends FragmentActivity implements OnNew
|
||||
development_version.setText(R.string.startscreen_non_release_version);
|
||||
development_version.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
clouds = (CloudsAnimatorView) findViewById(R.id.ts_clouds_animator);
|
||||
clouds.startAnimation();
|
||||
|
||||
View background = findViewById(R.id.title_bg);
|
||||
if (background != null) {
|
||||
background.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
toggleUiVisibility();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// if (development_version.getVisibility() == View.VISIBLE) {
|
||||
// development_version.setText(development_version.getText() +
|
||||
// "\nMax Heap: " + Runtime.getRuntime().maxMemory() / 1024 +
|
||||
// "\nTile size: " + (int) (32 * res.getDisplayMetrics().density));
|
||||
// }
|
||||
|
||||
toggleUiVisibility();
|
||||
|
||||
app.getWorldSetup().startResourceLoader(res);
|
||||
|
||||
}
|
||||
|
||||
private void toggleUiVisibility() {
|
||||
ui_visible = !ui_visible;
|
||||
int visibility = ui_visible ? View.VISIBLE : View.GONE;
|
||||
if (tv != null) tv.setVisibility(visibility);
|
||||
if (development_version != null) development_version.setVisibility(visibility);
|
||||
if (currentFragment != null) {
|
||||
if (ui_visible) {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.show(currentFragment)
|
||||
.commit();
|
||||
} else {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.hide(currentFragment)
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initPreferences() {
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
AndorsTrailPreferences preferences = app.getPreferences();
|
||||
@@ -86,6 +133,7 @@ public final class StartScreenActivity extends FragmentActivity implements OnNew
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
clouds.startAnimation();
|
||||
|
||||
}
|
||||
|
||||
@@ -110,9 +158,12 @@ public final class StartScreenActivity extends FragmentActivity implements OnNew
|
||||
private void backPressed() {
|
||||
if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
|
||||
getSupportFragmentManager().popBackStack();
|
||||
currentFragment = getSupportFragmentManager().findFragmentById(R.id.startscreen_fragment_container);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void onNewGameRequested() {
|
||||
if (findViewById(R.id.startscreen_fragment_container) != null) {
|
||||
StartScreenActivity_NewGame newGameFragment = new StartScreenActivity_NewGame();
|
||||
@@ -121,6 +172,8 @@ public final class StartScreenActivity extends FragmentActivity implements OnNew
|
||||
.replace(R.id.startscreen_fragment_container, newGameFragment)
|
||||
.addToBackStack(null)
|
||||
.commit();
|
||||
|
||||
currentFragment = newGameFragment;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -129,5 +182,10 @@ public final class StartScreenActivity extends FragmentActivity implements OnNew
|
||||
public void onGameCreationCancelled() {
|
||||
backPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackStackChanged() {
|
||||
currentFragment = getSupportFragmentManager().findFragmentById(R.id.startscreen_fragment_container);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
package com.gpl.rpg.AndorsTrail.view;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
public class CloudsAnimatorView extends FrameLayout {
|
||||
|
||||
private static final int Y_MIN = 0;
|
||||
private static final int Y_MAX = 100;
|
||||
|
||||
private static final int DURATION = 12000;
|
||||
private static final int SPEED_MIN = 10;
|
||||
private static final int SPEED_MAX = 15;
|
||||
|
||||
private static final float BELOW_SPEED_FACTOR = 0.8f;
|
||||
private static final float CENTER_SPEED_FACTOR = 1.0f;
|
||||
private static final float ABOVE_SPEED_FACTOR = 1.2f;
|
||||
|
||||
private static final int BELOW_CLOUD_COUNT = 30;
|
||||
private static final int CENTER_CLOUD_COUNT = 20;
|
||||
private static final int ABOVE_CLOUD_COUNT = 15;
|
||||
|
||||
private static final int[] belowDrawablesId = new int[]{R.drawable.ts_clouds_s_01, R.drawable.ts_clouds_s_02, R.drawable.ts_clouds_s_03};
|
||||
private static final int[] centerDrawablesId = new int[]{R.drawable.ts_clouds_m_01, R.drawable.ts_clouds_m_02};
|
||||
private static final int[] aboveDrawablesId = new int[]{R.drawable.ts_clouds_l_01, R.drawable.ts_clouds_l_02, R.drawable.ts_clouds_l_03, R.drawable.ts_clouds_l_04};
|
||||
|
||||
ViewGroup belowLayer, centerLayer, aboveLayer;
|
||||
View belowStart, centerStart, aboveStart;
|
||||
|
||||
|
||||
|
||||
public CloudsAnimatorView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public CloudsAnimatorView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public CloudsAnimatorView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
L.log("Cloud animator created");
|
||||
setFocusable(false);
|
||||
inflate(getContext(), R.layout.clouds_animator, this);
|
||||
|
||||
belowLayer = (ViewGroup) findViewById(R.id.ts_clouds_below);
|
||||
centerLayer = (ViewGroup) findViewById(R.id.ts_clouds_center);
|
||||
aboveLayer = (ViewGroup) findViewById(R.id.ts_clouds_above);
|
||||
|
||||
belowStart = (ViewGroup) findViewById(R.id.ts_clouds_below_start);
|
||||
centerStart = (ViewGroup) findViewById(R.id.ts_clouds_center_start);
|
||||
aboveStart = (ViewGroup) findViewById(R.id.ts_clouds_above_start);
|
||||
}
|
||||
|
||||
private void addCloudBelow() {
|
||||
if (belowLayer == null) {
|
||||
L.log("Cloud below is null. Deferring.");
|
||||
postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {addCloudBelow();}
|
||||
}, (int)(DURATION * Math.random()));
|
||||
} else {
|
||||
addCloud(belowLayer, R.id.ts_clouds_below_start, belowDrawablesId, BELOW_SPEED_FACTOR);
|
||||
}
|
||||
|
||||
}
|
||||
private void addCloudCenter() {
|
||||
if (centerLayer == null) {
|
||||
L.log("Cloud center is null. Deferring.");
|
||||
postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {addCloudCenter();}
|
||||
}, (int)(DURATION * Math.random()));
|
||||
} else {
|
||||
addCloud(centerLayer, R.id.ts_clouds_center_start, centerDrawablesId, CENTER_SPEED_FACTOR);
|
||||
}
|
||||
}
|
||||
private void addCloudAbove() {
|
||||
if (aboveLayer == null) {
|
||||
L.log("Cloud above is null. Deferring.");
|
||||
postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {addCloudAbove();}
|
||||
}, (int)(DURATION * Math.random()));
|
||||
} else {
|
||||
addCloud(aboveLayer, R.id.ts_clouds_above_start, aboveDrawablesId, ABOVE_SPEED_FACTOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void addCloud(final ViewGroup layer, final int startId, final int[] ids, final float speedFactor) {
|
||||
final ImageView iv = new ImageView(getContext());
|
||||
iv.setImageDrawable(getResources().getDrawable(ids[(int)(ids.length * Math.random())]));
|
||||
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
|
||||
//lp.addRule(RelativeLayout.LEFT_OF, startId);
|
||||
// lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
|
||||
// lp.topMargin = (int) (layer.getHeight() * Math.random());
|
||||
final float y = (float) (layer.getHeight() * Math.random());
|
||||
L.log("Cloud added at y="+y);
|
||||
layer.addView(iv, lp);
|
||||
TranslateAnimation anim = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_PARENT, -1.0f, TranslateAnimation.RELATIVE_TO_PARENT, 2.0f,
|
||||
TranslateAnimation.ABSOLUTE, y, TranslateAnimation.ABSOLUTE, y);
|
||||
anim.setAnimationListener(new Animation.AnimationListener() {
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
L.log("Cloud ended at y="+y);
|
||||
layer.removeView(iv);
|
||||
if (CloudsAnimatorView.this.getVisibility() == View.VISIBLE) {
|
||||
postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {addCloud(layer, startId, ids, speedFactor);}
|
||||
}, (int)(DURATION * Math.random()));
|
||||
}
|
||||
}
|
||||
});
|
||||
anim.setDuration((long)(DURATION / speedFactor));
|
||||
iv.startAnimation(anim);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
protected void onVisibilityChanged(View changedView, int visibility) {
|
||||
super.onVisibilityChanged(changedView, visibility);
|
||||
if (changedView == this && visibility == View.VISIBLE) {
|
||||
startAnimation();
|
||||
} else if (changedView == this) {
|
||||
stopAll();
|
||||
}
|
||||
}*/
|
||||
|
||||
public void startAnimation() {
|
||||
L.log("Cloud animator started");
|
||||
int i = BELOW_CLOUD_COUNT;
|
||||
while (i-- > 0) {
|
||||
postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {addCloudBelow();}
|
||||
}, (int)(DURATION * Math.random()));
|
||||
}
|
||||
i = CENTER_CLOUD_COUNT;
|
||||
while (i-- > 0) {
|
||||
postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {addCloudCenter();}
|
||||
}, (int)(DURATION * Math.random()));
|
||||
}
|
||||
i = ABOVE_CLOUD_COUNT;
|
||||
while (i-- > 0) {
|
||||
postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {addCloudAbove();}
|
||||
}, (int)(DURATION * Math.random()));
|
||||
}
|
||||
}
|
||||
|
||||
// private void stopAll() {}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user