protected override void OnCreate(Bundle savedInstanceState) { try { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.UserInput); saveBtn = FindViewById <Button>(Resource.Id.saveBtn); menuBtn = FindViewById <Button>(Resource.Id.menuBtn); enterNameTxt = FindViewById <EditText>(Resource.Id.enterNameETxt); scoreTxtView = FindViewById <TextView>(Resource.Id.scoreTxtView); timeTxtView = FindViewById <TextView>(Resource.Id.timeTxtView); highScoreTxtView = FindViewById <TextView>(Resource.Id.highScoreTxtView); congratTxtView = FindViewById <TextView>(Resource.Id.congratulationsTxtView); chkBoxName = FindViewById <CheckBox>(Resource.Id.chkBoxPreviousName); // Event handlers: enterNameTxt.Click += EditTextClick; menuBtn.Click += MenuButtonClick; chkBoxName.Click += CheckBoxClick; saveBtn.Click += SaveButtonClick; // Initializing data for the User input. enterNameTxt.Text = DEFAULTENTERNAMEHERE; string content = Intent.GetStringExtra(GlobalApp.getPlayersScoreVariable()); // Why starting at index 1? Because the Name will come before the score data. string score = GlobalApp.splitString(content, 1, '-'); string dif = GlobalApp.splitString(content, 2, '-'); string time = GlobalApp.splitString(content, 3, '-'); scoreTxtView.Text += " " + score; timeTxtView.Text += " " + time; chkBoxName.Enabled = !GlobalApp.isNewPlayer(); // We don't want the checkbox to be auto checked. if (chkBoxName.Enabled) { chkBoxName.Checked = false; } checkForNewPositionToLocalAndOnline(score, time, dif); } catch { GlobalApp.Alert(this, 0); } }
// ---------------------------------------------------------------------------------------------------------------- // Add the players score, and saves it into the current storage. protected void SaveButtonClick(Object sender, EventArgs args) { try { string content = Intent.GetStringExtra(GlobalApp.getPlayersScoreVariable()); if (GlobalApp.isNewPlayer()) { if (String.Compare(enterNameTxt.Text, DEFAULTENTERNAMEHERE) == 0) { GlobalApp.setName(DEFAULTNAME); content = DEFAULTNAME + content; } else { GlobalApp.setName(enterNameTxt.Text); content = enterNameTxt.Text + content; } } else { if (String.Compare(enterNameTxt.Text, DEFAULTENTERNAMEHERE) == 0) { GlobalApp.setName(DEFAULTNAME); content = DEFAULTNAME + content; } else { GlobalApp.setName(enterNameTxt.Text); content = enterNameTxt.Text + content; } } // Now we can add the new score into the local leaderboard. // Method: addNewScore will also determine if the score can be added into the Online leaderboard. LeaderBoardInterface.addNewScore(content); } catch { GlobalApp.Alert(this, 0); } finally { GlobalApp.BeginActivity(this, typeof(GameMenuActivity), GlobalApp.getVariableChoiceName(), Intent.GetIntExtra(GlobalApp.getVariableChoiceName(), 0)); } }