diff --git a/app/src/main/java/com/kauron/dungeonmanager/MainActivity.java b/app/src/main/java/com/kauron/dungeonmanager/MainActivity.java index d86a35e..24a2a28 100644 --- a/app/src/main/java/com/kauron/dungeonmanager/MainActivity.java +++ b/app/src/main/java/com/kauron/dungeonmanager/MainActivity.java @@ -100,41 +100,9 @@ public class MainActivity extends ActionBarActivity{ healDialog(); } return true; - } else if (id == R.id.action_edit_basics) { - Intent intent = new Intent(this, Introduction.class); - startActivity(intent.putExtra( - "first_time", - !p.getBoolean("saved", false) - )); - restoreData(); - return true; } else if (id == R.id.action_undo) { undo(); return true; - } else if (id == R.id.action_reset) { - AlertDialog.Builder alert = new AlertDialog.Builder(this); - alert.setTitle(R.string.reset_confirmation_title); - alert.setMessage(R.string.reset_confirmation); - alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int whichButton) { - Toast.makeText( - getApplicationContext(), - R.string.message_reset, - Toast.LENGTH_LONG - ).show(); - p.edit().clear().apply(); - player = null; - restoreData(); - } - }); - alert.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int whichButton) { - // Canceled. - } - }); - - alert.show(); - return true; } else if (id == R.id.action_time_encounter_end) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(R.string.px_awarded_title); @@ -184,14 +152,6 @@ public class MainActivity extends ActionBarActivity{ alert.show(); input.requestFocus(); return true; - } else if (id == R.id.action_download) { - //TODO: create self-updater - Toast.makeText( - getApplicationContext(), - "This function is not ready yet", - Toast.LENGTH_LONG - ).show(); - return true; } else if (id == R.id.action_time_long_rest) { player.rest(true); Toast.makeText( diff --git a/app/src/main/java/com/kauron/dungeonmanager/Welcome.java b/app/src/main/java/com/kauron/dungeonmanager/Welcome.java index bbbd06d..0372b11 100644 --- a/app/src/main/java/com/kauron/dungeonmanager/Welcome.java +++ b/app/src/main/java/com/kauron/dungeonmanager/Welcome.java @@ -1,35 +1,44 @@ package com.kauron.dungeonmanager; import android.content.Intent; +import android.content.SharedPreferences; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; +import android.widget.TextView; public class Welcome extends ActionBarActivity { - private Button load, newChar; + private Button load; + private SharedPreferences p; + private TextView newText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_welcome); - newChar = (Button) findViewById(R.id.newCharacter); + p = getSharedPreferences("basics", MODE_PRIVATE); load = (Button) findViewById(R.id.loadCharacter); - load.setEnabled( - getSharedPreferences("basics", MODE_PRIVATE).getBoolean("basics", false) - ); + newText = (TextView) findViewById(R.id.newText); + if (p.getBoolean("saved", false)) { + load.setEnabled(true); + load.setText(String.format(getString(R.string.load_text), p.getString("playerName", ""))); + newText.setVisibility(View.VISIBLE); + } else { + load.setEnabled(false); + load.setText(R.string.load_character); + newText.setVisibility(View.GONE); + } } - //TODO: putBoolean in the intent correctly public void onNewClick(View view) { startActivity(new Intent(this, Introduction.class).putExtra("first_time", true)); } - //TODO: get correctly the state of the saved game public void onLoadClick(View view) { startActivity(new Intent(this, MainActivity.class)); } @@ -55,4 +64,18 @@ public class Welcome extends ActionBarActivity { return super.onOptionsItemSelected(item); } + + @Override + protected void onResume() { + super.onResume(); + if (p.getBoolean("saved", false)) { + load.setEnabled(true); + load.setText(String.format(getString(R.string.load_text), p.getString("playerName", ""))); + newText.setVisibility(View.VISIBLE); + } else { + load.setEnabled(false); + load.setText(R.string.load_character); + newText.setVisibility(View.GONE); + } + } } diff --git a/app/src/main/res/layout/activity_welcome.xml b/app/src/main/res/layout/activity_welcome.xml index 9f2b9fe..498e3fe 100644 --- a/app/src/main/res/layout/activity_welcome.xml +++ b/app/src/main/res/layout/activity_welcome.xml @@ -7,12 +7,12 @@ tools:context="com.kauron.dungeonmanager.Welcome" android:orientation="vertical"> - + android:textAppearance="?android:attr/textAppearanceMedium" + android:text="@string/new_character_warning" + android:id="@+id/newText" /> + + diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index ce85426..5ea77ce 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -1,6 +1,7 @@
- -