Ejemplo n.º 1
0
 public void SetSelectionSprite(StringDrawable sel)
 {
     selection = sel;
     sel.Layer = -1;
     AllTogether.Add(sel);
 }
Ejemplo n.º 2
0
 public void UpdateChoices(float camx, float camy)
 {
     if (ShowingChoices)
     {
         if (!AllTogether.Contains(choices))
         {
             AllTogether.Add(choices);
             AllTogether.Add(choicesBG);
             AllTogether.Add(choicesSel);
         }
         if (SelectedChoice >= Choices.Count)
         {
             SelectedChoice = Choices.Count - 1;
         }
         else if (SelectedChoice == -1)
         {
             SelectedChoice = 0;
             choiceScroll   = 0;
         }
         if (SelectedChoice >= choiceScroll + 7)
         {
             choiceScroll = SelectedChoice - 6;
         }
         else if (SelectedChoice < choiceScroll)
         {
             choiceScroll = SelectedChoice;
         }
         if (selection.SelectionStart < start || selection.SelectionStart > end)
         {
             Choices = new List <string>();
         }
         choicesBG.X = selection.SelectionX + 16 + (start - selection.SelectionStart) * 8;
         choicesBG.Y = selection.SelectionY + 16;
         StringBuilder sb = new StringBuilder();
         for (int i = choiceScroll; i < choiceScroll + 7; i++)
         {
             if (Choices.Count() > i)
             {
                 sb.Append(Choices.ElementAtOrDefault(i));
                 sb.Append('\n');
             }
         }
         if (sb.Length > 1)
         {
             sb.Remove(sb.Length - 1, 1);
         }
         choices.Text = sb.ToString();
         choicesBG.SetSize(Math.Max(choices.Width + 2, 64), choices.Height + 2);
         if (choicesBG.Right > Game.RESOLUTION_WIDTH + camx)
         {
             choicesBG.Right = Game.RESOLUTION_WIDTH + camx;
         }
         if (choicesBG.Bottom > Game.RESOLUTION_HEIGHT + camy)
         {
             choicesBG.Bottom = selection.SelectionY;
         }
         choices.X = choicesBG.X + 1;
         choices.Y = choicesBG.Y + 1;
         choicesSel.SetSize(choicesBG.Width - 2, 8 * choices.Size);
         bool iv = Choices.Count() > 0;
         choicesBG.Visible = choicesSel.Visible = choices.Visible = iv;
         choicesSel.X      = choicesBG.X + 1;
         choicesSel.Y      = choicesBG.Y + 1 + (8 * choices.Size * (SelectedChoice - choiceScroll));
         ChoicesVisible    = iv;
     }
 }