void HandleModChanged(EditText field, SkillValue val) { int value; if (int.TryParse(field.Text, out value)) { EditMonster.ChangeSkill(val.Name, value - val.Mod); } }
private void CreateFeatsList() { LinearLayout featsList = FindViewById <LinearLayout>(Resource.Id.featsLayout); featsList.RemoveAllViews(); foreach (String s in EditMonster.FeatsList) { LinearLayout row = new LinearLayout(this); row.Orientation = Orientation.Horizontal; row.SetBackgroundColor(new Android.Graphics.Color(0xff, 0xff, 0xff)); row.SetPadding(5, 2, 5, 2); var v = SplitFeat(s); TextView t = new TextView(this); t.SetTextSizeDip(18); t.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.MatchParent, 1f); if (v.Item2 == null) { t.Text = v.Item1; } else { t.TextFormatted = Html.FromHtml(v.Item1 + "<i>(" + v.Item2 + ")</i>"); } row.AddView(t); ImageButton b = new ImageButton(this); b.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.redx)); row.AddView(b); String feat = s; b.Click += (object sender, EventArgs e) => { EditMonster.RemoveFeat(feat); CreateFeatsList(); }; featsList.AddView(row); } }
void CreateSkillsList() { LinearLayout l = FindViewById <LinearLayout>(Resource.Id.skillsLinearLayout); l.RemoveAllViews(); foreach (SkillValue v in EditMonster.SkillValueList) { LinearLayout row = new LinearLayout(this); row.Orientation = Orientation.Horizontal; row.SetBackgroundColor(new Android.Graphics.Color(0xff, 0xff, 0xff)); row.SetPadding(1, 2, 1, 2); TextView t = new TextView(this); t.Text = v.Name; t.SetTextSize(Android.Util.ComplexUnitType.Dip, 18); //t.SetBackgroundColor(new Android.Graphics.Color(0xff, 0x33, 0x33)); t.SetMinimumWidth(130); row.AddView(t); if (Monster.SkillsDetails[v.Name].Subtypes != null) { EditText et = new EditText(this); et.Text = v.Subtype; et.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.MatchParent, 1f); row.AddView(et); } else { t.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.MatchParent, 1f); } SkillValue s = v; EditText mod = new EditText(this); mod.MakeNumber(); mod.Text = v.Mod.ToString(); row.AddView(mod); mod.SetMinimumWidth(60); mod.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => { HandleModChanged((EditText)sender, s); }; ImageButton b = new ImageButton(this); b.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.redx)); row.AddView(b); b.Tag = v.FullName; b.Click += (object sender, EventArgs e) => { AlertDialog.Builder bui = new AlertDialog.Builder(this); bui.SetMessage("Remove skill?"); bui.SetPositiveButton("Yes", (a, x) => { EditMonster.SkillValueDictionary.Remove(s.FullName); EditMonster.UpdateSkillValueList(); CreateSkillsList(); }); bui.SetNegativeButton("No", (a, x) => {}); bui.Show(); }; l.AddView(row); } }