added DialogeFragment for WinScreen

This commit is contained in:
Gongxter 2015-12-11 14:48:27 +01:00
parent 97becd93e5
commit f205532ed4
12 changed files with 146 additions and 9 deletions

View file

@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View file

@ -6,6 +6,7 @@ import android.graphics.Point;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.NavigationView;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
@ -23,10 +24,10 @@ import tu_darmstadt.sudoku.controller.GameController;
import tu_darmstadt.sudoku.controller.SaveLoadStatistics;
import tu_darmstadt.sudoku.controller.helper.GameInfoContainer;
import tu_darmstadt.sudoku.game.GameDifficulty;
import tu_darmstadt.sudoku.game.GameStatus;
import tu_darmstadt.sudoku.game.GameType;
import tu_darmstadt.sudoku.game.listener.IGameSolvedListener;
import tu_darmstadt.sudoku.game.listener.ITimerListener;
import tu_darmstadt.sudoku.ui.view.DialogWinScreen;
import tu_darmstadt.sudoku.ui.view.R;
import tu_darmstadt.sudoku.ui.view.SudokuFieldLayout;
import tu_darmstadt.sudoku.ui.view.SudokuKeyboardLayout;
@ -231,7 +232,13 @@ public class GameActivity extends AppCompatActivity implements NavigationView.On
t.show();
SaveLoadStatistics s = new SaveLoadStatistics(this);
s.saveGameStats(gameController);
DialogWinScreen win = new DialogWinScreen();
win.setProps(gameController);
FragmentManager fr = getSupportFragmentManager();
win.show(fr, "win_screen_layout");
// TODO: WE WON.. do something awesome :)
gameController.pauseTimer();
}
@Override

View file

@ -34,6 +34,7 @@ import tu_darmstadt.sudoku.controller.NewLevelManager;
import tu_darmstadt.sudoku.controller.helper.GameInfoContainer;
import tu_darmstadt.sudoku.game.GameDifficulty;
import tu_darmstadt.sudoku.game.GameType;
import tu_darmstadt.sudoku.ui.view.DialogWinScreen;
import tu_darmstadt.sudoku.ui.view.R;
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener{
@ -122,6 +123,11 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
navigationView.setNavigationItemSelectedListener(this);
}
public void callFragment(View view){
FragmentManager fm = getSupportFragmentManager();
DialogWinScreen winScreen = new DialogWinScreen();
winScreen.show(fm,"win_screen_layout");
}
public void onClick(View view) {
@ -133,9 +139,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
/**case R.id.aboutButton:
i = new Intent(this, AboutActivity.class);
break;
case R.id.continueButton:
i = new Intent(this, LoadGameActivity.class);
break;
case R.id.highscoreButton:
i = new Intent(this,StatsActivity.class);
break;
@ -145,6 +148,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
case R.id.helpButton:
// TODO: create help page.. what is supposed to be in there?!
break;*/
case R.id.continueButton:
i = new Intent(this, LoadGameActivity.class);
break;
case R.id.playButton:
GameType gameType = GameType.getValidGameTypes().get(mViewPager.getCurrentItem());
int index = difficultyBar.getProgress()-1;

View file

@ -0,0 +1,50 @@
package tu_darmstadt.sudoku.ui.view;
import android.app.DialogFragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import tu_darmstadt.sudoku.controller.GameController;
/**
* Created by TMZ_LToP on 11.12.2015.
*/
public class DialogWinScreen extends android.support.v4.app.DialogFragment {
ImageView upperView, lowerView;
public DialogWinScreen(){
}
public void setProps(GameController gc){
//no second Conjstrutor with argument allowed
//save everything that should be sown in winscreeen and set in the text etc
}
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.win_screen_layout,container);
getDialog().getWindow().setBackgroundDrawableResource(R.drawable.ic_trophy_black_48dp);
//getDialog().getWindow().setLayout(200,250);
//Maybe creat real animation
//Animation ani = AnimationUtils.loadAnimation(this,R.anim...);
/*RotateAnimation anim = new RotateAnimation(0.0f,350.0f,60f,60f);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(700);
*/
return view;
}
}

View file

@ -155,7 +155,6 @@ public class SudokuCellView extends View {
p.setAntiAlias(true);
p.setTextSize(Math.min(mHeight * 3 / 4, mHeight * 3 / 4));
p.setTextAlign(Paint.Align.CENTER);
// TODO settings: get SymbolEnum from settings
canvas.drawText(Symbol.getSymbol(symbolsToUse, mGameCell.getValue()-1), mHeight / 2, mHeight / 2 + mHeight / 4, p);
}

View file

@ -81,7 +81,6 @@ public class SudokuKeyboardLayout extends GridLayout {
buttons[number].setLayoutParams(p);
//buttons[number].setGravity(Gravity.CENTER);
buttons[number].setType(SudokuButtonType.Value);
// TODO settings: get SymbolEnum from settings
buttons[number].setBackgroundResource(R.drawable.mnenomic_numpad_button);
buttons[number].setText(Symbol.getSymbol(symbolsToUse, number));
buttons[number].setValue(number + 1);

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -132,6 +132,11 @@
android:capitalize="none"
android:clickable="false"
android:background="@drawable/mnenomic_numpad_button"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="testforwinshitz"
android:onClick="callFragment"/>
<!--
<LinearLayout
android:layout_width="match_parent"

View file

@ -6,6 +6,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:id="@+id/game_coordinate_layout"
tools:context="tu_darmstadt.sudoku.activity.GameActivity">
<android.support.design.widget.AppBarLayout

View file

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="200dp" android:layout_height="250dp"
android:background="@drawable/ic_trophy_black_48dp"
android:weightSum="5"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@color/transparent"
android:gravity="center">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="bottom"
android:background="@color/transparent"
android:src="@drawable/ic_trophy_award_black_48dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="3"
android:gravity="center"
android:background="@color/transparent"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/win_text"
android:textAlignment="center"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:textColor="@color/lightblue"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test2"
android:layout_gravity="center"
android:textColor="@color/lightblue"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test1"
android:textColor="@color/lightblue"
android:layout_gravity="center"/>
<View
android:layout_width="fill_parent"
android:layout_height="10dp"
android:background="@color/middleblue"
android:layout_gravity="bottom" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@color/transparent"
android:gravity="center">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="bottom"
android:src="@drawable/ic_trophy_award_black_48dp"
android:background="@color/transparent" />
</LinearLayout>
</LinearLayout>

View file

@ -80,6 +80,7 @@
<string name="reset_stats">reset stats</string>
<!--### Win Strings -->
<string name="win_text">Congratz du depp du hast gewonnen oder so was</string>
</resources>