Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.88 KB | None | 0 0
  1.  public void OdzyskajStan(View view)
  2.         {
  3.             for (int i = 0; i < 8; i++)
  4.             {
  5.                 rows[i].RemoveAllViews();
  6.                 for (int j = 0; j < 8; j++)
  7.                 {
  8.  
  9.                     plansza[i,j] = new Obiekt(Application.Context, i, j);
  10.                     plansza[i,j].SetImageResource(Resource.Drawable.qwe);
  11.  
  12.                     rows[i].AddView(plansza[i,j]);
  13.                     plansza[i,j].Click += Clicker;
  14.  
  15.                 }
  16.  
  17.             }
  18.             ISharedPreferences ustawienia = GetSharedPreferences("Warcaby", 0);
  19.             String a = ustawienia.GetString("piony", "tutaj");
  20.             Log.Info("AAAAAAA", a);
  21.             String[] b = a.Split(":");
  22.             Log.Info("Bleng", b[0]);
  23.             for (int i = 0; i < b.Length; i++)
  24.             {
  25.                 Log.Info("AAA", b[i]);
  26.                 String[] pion = b[i].Split(";");
  27.                 bool p = bool.Parse(pion[0]);
  28.                 bool kolor = bool.Parse(pion[1]);
  29.                 int x = int.Parse(pion[2]);
  30.                 int y = int.Parse(pion[3]);
  31.                 plansza[x,y] = new Pion(Application.Context, kolor, x, y, p);
  32.                 plansza[x,y].SetOnClickListener(this);
  33.             }
  34.             biale = ustawienia.GetInt("biale", 0);
  35.             czarne = ustawienia.GetInt("czarne", 0);
  36.             tura = ustawienia.GetBoolean("tura", false);
  37.             dotylu = ustawienia.GetBoolean("dotylu", false);
  38.             TextView qwe = (TextView)FindViewById(Resource.Id.qwe);
  39.             if (tura)
  40.                 qwe.Text= "Tura => Niebieskie";
  41.             else qwe.Text="Tura => Czerwone";
  42.             // swicz.setVisibility(View.INVISIBLE);
  43.             Toast toast = Toast.MakeText(Application.Context, "Poprawnie wczytano.", ToastLength.Long);
  44.             toast.Show();
  45.             Odswiez();
  46.  
  47.         }
  48.  
  49. public void Zapis(View v)
  50.         {
  51.             ISharedPreferences Ustawienia = GetSharedPreferences("Warcaby", 0);
  52.             ISharedPreferencesEditor edytor = Ustawienia.Edit();
  53.             StringBuilder a = new StringBuilder();
  54.             for (int i = 0; i < 8; i++)
  55.             {
  56.                 for (int j = 0; j < 8; j++)
  57.                 {
  58.                     if (plansza[i,j].DajKolor() != 0)
  59.                     {
  60.                         a.Append(plansza[i,j].Opisz());
  61.                         a.Append(":");
  62.                     }
  63.  
  64.                 }
  65.             }
  66.             Toast toast = Toast.MakeText(Application.Context, "Poprawnie zapisano stan gry", ToastLength.Long);
  67.             toast.Show();
  68.             Log.Info("AAA", a.ToString());
  69.             edytor.PutString("piony", a.ToString());
  70.             edytor.PutInt("biale", biale);
  71.             edytor.PutInt("czarne", czarne);
  72.             edytor.PutBoolean("tura", tura);
  73.             edytor.PutBoolean("dotylu", dotylu);
  74.             edytor.Commit();
  75.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement