Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void OdzyskajStan(View view)
- {
- for (int i = 0; i < 8; i++)
- {
- rows[i].RemoveAllViews();
- for (int j = 0; j < 8; j++)
- {
- plansza[i,j] = new Obiekt(Application.Context, i, j);
- plansza[i,j].SetImageResource(Resource.Drawable.qwe);
- rows[i].AddView(plansza[i,j]);
- plansza[i,j].Click += Clicker;
- }
- }
- ISharedPreferences ustawienia = GetSharedPreferences("Warcaby", 0);
- String a = ustawienia.GetString("piony", "tutaj");
- Log.Info("AAAAAAA", a);
- String[] b = a.Split(":");
- Log.Info("Bleng", b[0]);
- for (int i = 0; i < b.Length; i++)
- {
- Log.Info("AAA", b[i]);
- String[] pion = b[i].Split(";");
- bool p = bool.Parse(pion[0]);
- bool kolor = bool.Parse(pion[1]);
- int x = int.Parse(pion[2]);
- int y = int.Parse(pion[3]);
- plansza[x,y] = new Pion(Application.Context, kolor, x, y, p);
- plansza[x,y].SetOnClickListener(this);
- }
- biale = ustawienia.GetInt("biale", 0);
- czarne = ustawienia.GetInt("czarne", 0);
- tura = ustawienia.GetBoolean("tura", false);
- dotylu = ustawienia.GetBoolean("dotylu", false);
- TextView qwe = (TextView)FindViewById(Resource.Id.qwe);
- if (tura)
- qwe.Text= "Tura => Niebieskie";
- else qwe.Text="Tura => Czerwone";
- // swicz.setVisibility(View.INVISIBLE);
- Toast toast = Toast.MakeText(Application.Context, "Poprawnie wczytano.", ToastLength.Long);
- toast.Show();
- Odswiez();
- }
- public void Zapis(View v)
- {
- ISharedPreferences Ustawienia = GetSharedPreferences("Warcaby", 0);
- ISharedPreferencesEditor edytor = Ustawienia.Edit();
- StringBuilder a = new StringBuilder();
- for (int i = 0; i < 8; i++)
- {
- for (int j = 0; j < 8; j++)
- {
- if (plansza[i,j].DajKolor() != 0)
- {
- a.Append(plansza[i,j].Opisz());
- a.Append(":");
- }
- }
- }
- Toast toast = Toast.MakeText(Application.Context, "Poprawnie zapisano stan gry", ToastLength.Long);
- toast.Show();
- Log.Info("AAA", a.ToString());
- edytor.PutString("piony", a.ToString());
- edytor.PutInt("biale", biale);
- edytor.PutInt("czarne", czarne);
- edytor.PutBoolean("tura", tura);
- edytor.PutBoolean("dotylu", dotylu);
- edytor.Commit();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement