/* Copyright Alexander 'm8f' Kromm (mmaulwurff@gmail.com) 2019
 *
 * This file is a part of Tips.pk3.
 *
 * Tips.pk3 is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * Tips.pk3 is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * Tips.pk3.  If not, see <https://www.gnu.org/licenses/>.
 */

/**
 * This class draws a note at the bottom of the screen.
 *
 * It respects tp_show_notes CVar.
 */
class Angel_ListMenuNote : ListMenuItem
{

// public: /////////////////////////////////////////////////////////////////////

  Angel_ListMenuNote init()
  {
		
	add("\"----------Cherub ----------\"\n"
        "\"At melee range, Cherubs do a single point of damage.\"\n"
        " - Enemy #1");
		
	add("\"---------- Knife Doll ----------\"\n"
		"\"Knife dolls only have 15 HP.\"\n"
        "\"Don't waste ammo on them. They're just not worth it.\"\n"
        " - Enemy #2");
		
	add("\"---------- Revolver Doll ----------\"\n"
		"\"Very weak, very smol.\"\n"
        "\"These shouldn't be too hard to kill. \"\n"
        " - Enemy #3");
		
	add("\"---------- Shotgun Duo ----------\"\n"
        "\"When the 1st doll is killed, the second will attack with a knife.\"\n"
        "\"Gibbing the Shotgun duo will prevent the second doll from spawning.\"\n"
        " - Enemy #4");
		
	add("\"---------- Cardinal ----------\"\n"
        "\"Cardinals have poor stamina and become tired after attacking or flying.\"\n"
        "\"She is vulnerable while catching her breath\"\n"
        " - Enemy #5");
		
	add("\"---------- Blackbird ----------\"\n"
        "\"The blackbird is completely invisible… except for her halo.\"\n"
        " - Enemy #6");
		
	add("\"---------- Snowball ----------\"\n"
        "\"Snowballs take double damage from fire and half damage from ice.\"\n"
        "\"Plus, she is not a hitscanner.\"\n"
        " - Enemy #7");
		
	add("\"---------- Putto ----------\"\n"
        "\"Putto cannot attack the player in any way.\"\n"
		"\"Instead, she can sacrifice themselves to resurrect any doll, inner or outer sphere angel.\"\n"
        "\"Eliminating Putto should always be a high priority on the battlefield.\"\n"
        " - Enemy #8");
		
	add("\"---------- Aspect of Iris ----------\"\n"
        "\"Iris butterflies are ripper projectiles and can be tricky to shake off.\"\n"
		"\"Green butterflies move faster than pink butterflies.\"\n"
        "\"The butterflies have a limited lifespan and will collapse from exhaustion after 15 seconds\"\n"
        " - Enemy #9");
		
	add("\"---------- Authority ----------\"\n"
        "\"The Authority is a quick opponent who sacrifices health for speed. \"\n"
        "\"She can be killed with two well placed super shotgun blasts.\"\n"
        " - Enemy #10");

	add("\"---------- Principality ----------\"\n"
        "\"The Principality can mix up her lightning attacks on a whim.\"\n"
        "\"She will laugh when shooting a stream of small lightning blasts.\"\n"
        " - Enemy #11");
		
	add("\"---------- Ophanim ----------\"\n"
        "\"The Ophanim becomes more powerful as she opens more eyes.\"\n"
        "\"She will go back to sleep if the player leaves her line of sight for a few seconds.\"\n"
		"\"She is completely vulnerable when going back to sleep\"\n"
        " - Enemy #12");
		
	add("\"---------- Joy Elemental ----------\"\n"
        "\"Joy elementals have one job; resurrecting their fallen comrades.\"\n"
        "\"Not only can she summon Putto, but she also can resurrect dead angels.\"\n"
		"\"At melee range, Joy Elementals are helpless.\"\n"
        " - Enemy #13");
		
	add("\"---------- Virtue Virgin ----------\"\n"
        "\"Virtue Virgins become quicker and stronger when injured.\"\n"
        "\"At 75% health, she shoots three projectiles and gains the ability to fly.\"\n"
		"\"At 5% health, she gains the fast monster ability.\"\n"
        " - Enemy #14");
		
	add("\"---------- Dollmaykr ----------\"\n"
        "\"Dollmaykrs have tricky movement.\"\n"
        "\"She comes to a complete stop when summoning dolls or attacking\"\n"
		" - Enemy #15");
		
	add("\"---------- Seraph ----------\"\n"
        "\"When the Seraph dies, her ashes form into a red egg.\"\n"
        "\"Break the egg before it hatches, or she will come back stronger than ever.\"\n"
        " - Enemy #16");
		
	add("\"---------- Great Seraph ----------\"\n"
        "\"If the red egg hatches into the Great Seraph, kiss your ass goodbye.\"\n"
        " - Enemy #17");
		
	add("\"---------- Crusader Queen 1st phase ----------\"\n"
        "\"If faltered, the Crusader Queens will hard counter the player with orbiter bullets.\"\n"
        "\"She will not counter right before charging or while charging at the player.\"\n"
		"\"Being hit by a direct charge is almost always fatal.\"\n"
        " - Enemy #18");
		
	add("\"---------- Crusader Queen 2nd phase ----------\"\n"
        "\"In her second phase, the Crusader Queen can fly and moves in an unpredictable pattern.\"\n"
        "\"She is limited to only using her arm cannon.\"\n"
        " - Enemy #19");
		
	add("\"---------- Rare bird - Puckish Prankster ----------\"\n"
        "\"Puckish Prankster spawns bubbles when attacking and will create a wall of bubbles when dodging.\"\n"
        "\"Bubbles do not deal damage but obstruct the player’s view.\"\n"
        " - Enemy #20");
		
	add("\"---------- Rare bird - Rusalka ----------\"\n"
        "\"On death, Rusalka will shatter into dozens of ice shards that bounce off walls.\"\n"
        "\"If gibbed, she will instantly shatter into more powerful ice shards.\"\n"
        " - Enemy #21");
	
	add("\"---------- Rare bird - Jay ----------\"\n"
        "\"Unlike Cardinals, Jays do not get tired between attacks and are twice as tough to kill.\"\n"
        "\"When flying, Jays can quickly charge at player.\"\n"
        " - Enemy #22");	
		
	add("\"---------- Rare bird - Aphrodite's Kiss ----------\"\n"
        "\"On death, the Aphrodite’s Kiss will turn to stone.\"\n"
        "\"If her statue is shattered, she will come back to life with full health\"\n"
		"\"Be careful when using rockets or the BFG around her.\"\n"
        " - Enemy #23");	
		
	add("\"---------- Rare bird - Forgotten Maiden ----------\"\n"
        "\"Forgotten Maidens are Aphrodite’s Kisses on steroids.\"\n"
        "\"Their arrows are quicker, more accurate, deal more damage, and have a huge explosion radius.\"\n"
		"\"These angels are completely optional but drop a powerful artifact on death.\"\n"
        " - Enemy #24");	
		
	add("\"---------- Rare bird - Queen of Queens ----------\"\n"
        "\"The extra boss of Angelic Aviary.\"\n"
        "\"There is nothing fair about this angel, but she can be defeated with determination and hard work.\"\n"
        " - Enemy #25");
		
	add("\"---------- Collectables ----------\"\n"
        "\"Dollmaykrs imprison the souls of their enemies into dolls and toys.\"\n"
        "\"Ever wonder where all those Doomguy collectables came from?\"\n"
        " - Lore #1");
		
	add("\"---------- Angelic Candy ----------\"\n"
        "\"Angels live on a diet of pink rock candy only found in heaven.\"\n"
        "\"Angelic candy is so sweet that it is toxic to all other creatures.\"\n"
		"\"The UAC has been mining this candy in secret and using it as an energy source.\"\n"
		"\"This rock candy is also used as ammo for one of the most powerful guns in existance.\"\n"
        " - Lore #2");
		
	add("\"---------- Sleeping Ophanim ----------\"\n"
        "\"Ophanim spend their entire lives asleep, even when they open their eyes, they are still sleeping.\"\n"
        "\"These angels are easier to slay than to wake up.\"\n"
		"\"On the rare chance she wakes, the Ophanim will have a panic attack until she faints back to sleep.\"\n"
        " - Lore #3");
		
	add("\"---------- Angel tiers ----------\"\n"
        "\"They are three tiers of angel; outer sphere, inner sphere and sacrificial.\"\n"
        "\"Outer sphere angels exist to play and have fun.\"\n"
		"\"Inner sphere angels run the day-to-day operations of heaven.\"\n"
		"\"Sacrificial angels suffer for the sake of the inner and outer sphere angels.\"\n"
        " - Lore #4");
		
	add("\"---------- Outer sphere angels ----------\"\n"
        "\"Outer sphere angels consist of the Cherub, Putto, Cardinal, Blackbird and Snowball.\"\n"
        "\"The most numerous angel type, Outer sphere angels spend their days having fun and enjoying the paradise that is Heaven.\"\n"
		"\"The weakest in raw strength, inner and sacrificial angels are completely subservient to the outer sphere angels whims and wishes.\"\n"
        " - Lore #5");
		
	add("\"---------- Inner sphere angels ----------\"\n"
        "\"Inner sphere angels consist of the Kiss, Aspect of Iris, Authority, Principality, Ophanim and Joy Elemental.\"\n"
        "\"Always working, never resting, These angels have no free will.\"\n"
		"\"Inner Sphere angels derive great joy from their work and in many ways are more content than the outer sphere angels.\"\n"
        " - Lore #6");
		
	add("\"---------- Sacrificial angels ----------\"\n"
        "\"Sacrificial angels consist of the Virtue Virgin, Dollmaykr, Seraph and Crusader Queen.\"\n"
        "\"Fulfilling the most vital roles in heaven, these powerful angels live in perpetual agony for the sake of all other angels.\"\n"
		"\"Each Sacrificial angel has free will and is brilliant enough to stop her suffering and overthrow the forces of heaven to become a goddess in her own right.\"\n"
		"\"To do so would mean the destruction of all heaven so Sacrificial angels always choose to suffer in silence.\"\n"
        " - Lore #7");
		
	add("\"---------- Little Goddess ----------\"\n"
        "\"The mysterious creator of all the angels known only as the Little Goddess.\"\n"
        "\"Eons ago, the forces of hell assassinated the little goddess, neutralizing heaven as a threat.\"\n"
		"\"Seven archangels currently guide the angels in her place.\"\n"
        " - Lore #8");
		
	add("\"---------- Corrupted Angels ----------\"\n"
        "\"A corrupted Angel is a Sacrificial angel who abandoned her post.\"\n"
        "\"Her feathers are forever stained a black so dark that light cannot penetrate them.\"\n"
		"\"The destroying Angel is the only known corrupted angel in existence.\"\n"
        " - Lore #9");

	add("\"---------- Angel flesh ----------\"\n"
        "\"Demons prey on smol angels, but seldom eat them.\"\n"
        "\"They're just too SWEET.\"\n"
        " - Lore #10");	
		
	add("\"---------- Dolls ----------\"\n"
        "\"Demons and wicked souls captured by the angels are given the choice to serve heaven by having their souls placed into angelic dolls.\"\n"
		"\"The doll acts as a prison where the demon can do nothing but observe and bid its time.\"\n"
        "\"These dolls are then given to lonely children who show them love and compassion, something most demons never feel.\"\n"
		"\"Over time, the demon's soul learns empathy and love which purifies their soul.\"\n"
        " - Lore #11");	
		
	add("\"---------- Sin ----------\"\n"
        "\"Angels are only born of souls untainted by sin.\"\n"
        "\"As all souls contain some degree of sin, the sin must be purged away to create new angels.\"\n"
		"\"Seraphs exist to absorb, process, and destroy this Sin at the cost of their own lives.\"\n"
        " - Lore #12");	
		
	add("\"---------- Loopholes ----------\"\n"
        "\"The souls of angels have been purified of sin which prevents them from using mortal objects, including firearms.\"\n"
        "\"Angelic Dolls contains souls with sin so they can technically use human weapons.\"\n"
        " - Lore #13");	
		
	add("\"---------- Gender ----------\"\n"
        "\"All angels are female.\"\n"
        " - Lore #14");	

	add("\"---------- Flightless angels ----------\"\n"
        "\"Much like birds on isolated islands, Angels who rarely leave heaven have lost the ability to fly.\"\n"
		"\"Some angels have lost their wings entirely.\"\n"
		" - Lore #15");	
	
	add("\"---------- Lifespan ----------\"\n"
        "\"Unlike demons, angels are not immortal. Angelic lifespans vary from angel to angel.\"\n"
		"\"Seraphs have the shortest lifespan at 15 years while Dollmaykrs can live for nearly 1,500,000 years.\"\n"
		"\"While mortal, Angels do not physically age or become weaker with time.\"\n"
		" - Lore #16");	
		
	add("\"---------- Heaven ----------\"\n"
        "\"Beautiful, pure, cold.\"\n"
		"\"Heaven is a dreamlike paradise created by the Little Goddess to be the perfect world for the Cherubs.\"\n"
		"\"Unfortunately, the temperature is so low that nothing besides angels can reside there.\"\n"
		" - Lore #17");	
		
	add("\"---------- Summer Gardens ----------\"\n"
        "\"The outer sphere of heaven.\"\n"
		"\"A world of floating islands, white clouds, marble ruins and gardens of colorful flowers and trees.\"\n"
		"\"A tropical paradise in appearance, the temperature is an average of -20 Celsius where anything besides native plants and Angels will freeze to death in hours.\"\n"
		"\"During the summer, temperatures rise slightly above freezing and all Angels must migrate to the winter gardens.\"\n"
		" - Lore #18");
		
	add("\"---------- Winter Gardens ----------\"\n"
        "\"The inner sphere of heaven. An abyss of snow, glass, and pink crystals.\"\n"
		"\"Empty most of the year, angels migrate to the winter gardens only during the warmer months of the year.\"\n"
		"\"While beautiful, angels find the winter gardens less enticing and are eager to return to the summer gardens.\"\n"
		"\"The winter gardens do have some year-round residents, primarily the Snowballs and Cardinals.\"\n"
		" - Lore #19");	
		
	add("\"---------- Outer Endless palace  ----------\"\n"
        "\"At the center of heaven is the Endless palace; a white bricked, M.C Escher like labyrinth where gravity doesn’t seem to exist.\"\n"
		"\"As the palace is endless, Cherubs never get tired of exploring its halls, but often become hopelessly lost.\"\n"
		"\"Dollmaykrs and Ophanim are the only angels that permanently reside in the palace as its infinite rooms provide ample room to hide.\"\n"
		"\"Only one angel can truly navigate the endless palace. The little goddess.\"\n"
		" - Lore #20");	
		
	add("\"---------- Inner Endless palace  ----------\"\n"
        "\"The outer endless palace serves primarily to obscure the location of the inner palace.\"\n"
		"\"The inner palace served as the throne room for the little goddess and her Crusader Queens.\"\n"
		"\"Ten-thousand years ago, hell assassins managed to infiltrate the endless palace’s defenses, and assassinate the Little Goddess.\"\n"
		"\"Since her death, the inner palace has fallen into ruin, becoming forgotten to time.\"\n"
		" - Lore #21");	
		
	add("\"---------- Migration ----------\"\n"
        "\"Cherubs reside in the summer gardens most of the year.\"\n"
		"\"During warmer months, millions of Cherubs annually migrate to the winter gardens due to the heat.\"\n"
		"\"During these mass migrations, a few angels become lost, winding up on earth.\"\n"
		"\"...or hell\"\n"
		" - Lore #22");	
		
	add("\"---------- Humiliation ----------\"\n"
        "\"When embarrassed, modest angels freeze in embarrassment.\"\n"
		"\"Literally.\"\n"
		" - Lore #23");
		
	add("\"---------- Appearance ----------\"\n"
        "\"Angels are both kyoot and smol.\"\n"
		" - Lore #24");
		
		
	add("\"---------- Halo ----------\"\n"
        "\"As an angel takes damage, her halo begins to fade .\"\n"
		"\"The more transparent the halo, the closer she is to death.\"\n"
		" - Hint #1");	
		
	add("\"---------- Damage types ----------\"\n"
        "\"As an angel takes damage, her halo begins to fade .\"\n"
		"\"The more transparent the halo, the closer she is to death.\"\n"
		" - Hint #2");	
	


    Super.Init();
    return self;
  }

  override
  bool, String GetString(int i)
  {
    // unused: i
    return true, "ListMenuNote";
  }

// public: // ListMenuItem /////////////////////////////////////////////////////

  override
  void OnMenuCreated()
  {
    _iString = random(0, _strings.size() - 1);
  }

  override
  void Drawer(bool selected)
  {
    // unused: selected

    if (!Angel_show_notes)
    {
      return;
    }

    int    width  = (Screen.GetWidth() / CleanXFac_1) * 3 / 4;
    let    lines  = NewSmallFont.BreakLines(_strings[_iString], width);
    int    nLines = lines.Count();
    double height = NewSmallFont.GetHeight();
    double y      = Screen.GetHeight() - MARGIN - height * nLines * CleanYFac_1;

    for (int i = 0; i < nLines; ++i)
    {
      double x = Screen.GetWidth() - MARGIN - lines.StringWidth(i) * CleanXFac_1;
      Screen.DrawText( NewSmallFont, Font.CR_WHITE, x, y, lines.StringAt(i)
                     , DTA_CleanNoMove_1, true
                     );
      y += height * CleanYFac_1;
    }
  }

// private: ////////////////////////////////////////////////////////////////////

  private ui
  void add(String s)
  {
    _strings.push(s);
  }

// private: ////////////////////////////////////////////////////////////////////

  const MARGIN = 10;

// private: ////////////////////////////////////////////////////////////////////

  /// Must contain at least 1 string.
  private ui Array<String> _strings;
  private ui uint          _iString;

} // class Angel_ListMenuNote

class OptionMenuItemAngel_MenuInjector : OptionMenuItem
{

// public: /////////////////////////////////////////////////////////////////////

  void Init()
  {
    injectNote("MainMenu");
    injectNote("MainMenuTextOnly");
  }

// private /////////////////////////////////////////////////////////////////////

  /**
   * This function assumes that menu with name @a menuName exists and is a ListMenu.
   */
  void injectNote(String menuName)
  {
    let descriptor = ListMenuDescriptor(MenuDescriptor.GetDescriptor(menuName));

    bool   hasString;
    String string;
    [hasString, string] = descriptor.mItems[descriptor.mItems.size() - 1].GetString(0);

    if (hasString && string == "ListMenuNote")
    {
      return;
    }

    descriptor.mItems.Push(new("Angel_ListMenuNote").init());
  }

} // class OptionMenuItemtp_MenuInjector
