Advertisement
Guest User

ZeldaROTH US texte.cpp corrigé

a guest
Oct 19th, 2013
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 36.88 KB | None | 0 0
  1. /*
  2.  
  3.     Zelda Return of the Hylian
  4.  
  5.     Copyright (C) 2005-2008  Vincent Jouillat
  6.  
  7.     Please send bugreports with examples or suggestions to www.zeldaroth.fr
  8.  
  9. */
  10.  
  11. #include <SDL/SDL.h>
  12. #include <SDL/SDL_image.h>
  13.  
  14. #include "Texte.h"
  15. #include "Menu.h"
  16. #include "Joueur.h"
  17. #include "Monde.h"
  18. #include "Projectile.h"
  19. #include "Jeu.h"
  20.  
  21. Texte::Texte(Jeu* jeu) : gpJeu(jeu), vitesse(40), av(0), x(0), y(0), w(0), h(0),
  22. id(0), idsuiv(0), def(false), cadre(false), texte(""), buffer("") {
  23.     lastAnimTime = SDL_GetTicks();
  24.     imageFont = IMG_Load("data/images/texte/font.png");
  25.     SDL_SetColorKey(imageFont,SDL_SRCCOLORKEY,SDL_MapRGB(imageFont->format,0,0,255));
  26.     imageCoeur = IMG_Load("data/images/menu/coeur.png");
  27.     SDL_SetColorKey(imageCoeur,SDL_SRCCOLORKEY,SDL_MapRGB(imageCoeur->format,0,0,255));
  28. }
  29.  
  30. Texte::~Texte() {
  31.     SDL_FreeSurface(imageFont);
  32.     SDL_FreeSurface(imageCoeur);
  33. }
  34.  
  35. void Texte::chercheText() {
  36.     ostringstream os;
  37.     int tmp;
  38.     switch (id) {
  39.         case 1  : texte = "You find a shield!!!**Your defense rises by one point!"; break;
  40.         case 2  : texte = "You find a sword!!!**You can now fight monsters with the Z key (or W)!!!*Hold Z to charge a spin attack!!!"; break;
  41.         case 3  :
  42.             tmp = 4-(gpJeu->getJoueur()->nbQuarts()%4);
  43.             os << tmp;
  44.             texte = "You find a piece of heart!!!";
  45.             if (tmp<4) buffer = os.str()+" left for a new heart container!!!";
  46.             else buffer = "Your heart count just increased!!!";
  47.             break;
  48.         case 11 : texte = "N: Link's Home*W: Hyrule Field*E: Forest Temple"; break;
  49.         case 12 : texte = "Mountain Temple**Not for cardiacs, scaredy-cats, and the generally faint of heart."; break;
  50.         case 13 : texte = "W: Desert entrance*N: Mountain Temple"; break;
  51.         case 14 : texte = "N: Mountain Temple*S: Hyrule Field"; break;
  52.         case 15 : texte = "N: Death Mountain"; break;
  53.         case 16 : texte = "E: Forest Entrance"; break;
  54.         case 17 : texte = "S: Lake Hylia*E: Haunted Graveyard"; break;
  55.         case 18 : texte = "S: To Kakariko Village"; break;
  56.         case 19 : texte = "N: Kakariko Village"; break;
  57.         case 20 : texte = "N: Hyrule Field"; break;
  58.         case 21 : texte = "W: Fire Land"; break;
  59.         case 22 : texte = "E: Shadow Village*- Not for the living -"; break;
  60.         case 23 : texte = "Dark Temple**If you are a ghost, seeking a job, you'd better come here to hang out with us."; break;
  61.         case 24 : texte = "N: Shadow Village*W: Lake Hylia"; break;
  62.         case 25 : texte = "N: Haunted Graveyard**No entry"; break;
  63.         case 26 : texte = "Shadow Village"; break;
  64.         case 27 : texte = "I am selling a bottle for 100 rupees, are you interested?*              YES ?            no  ";
  65.             if ((gpJeu->getJoueur()->hasBouteille(0) && gpJeu->getZone()==8)
  66.             || (gpJeu->getJoueur()->hasBouteille(1) && gpJeu->getZone()==5)
  67.             || (gpJeu->getJoueur()->hasBouteille(2) && gpJeu->getZone()==6)) {id=32; chercheText();break;}
  68.             if (gpJeu->getJoueur()->getRubis() + gpJeu->getJoueur()->getBoostRubis()<100) idsuiv=29;
  69.             else idsuiv=30;
  70.             break;
  71.         case 28 : texte = "I am selling a bottle for 100 rupees, are you interested?*              yes             NO ?"; idsuiv=31; break;
  72.         case 29 : texte = "Sorry, you don't have enough rupees"; break;
  73.         case 30 : texte = "Thank you, here is your bottle."; break;
  74.         case 31 : texte = "Come again if you change your mind."; break;
  75.         case 32 : texte = "Sorry, that was my only bottle."; break;
  76.         case 33 : texte = "You find an empty bottle!!!**It will help you to stock potions!!!"; break;
  77.         case 35 : texte = "The inhabitants of that village have a dialect out of the ordinary, I don't understand anything..."; break;
  78.         case 36 : texte = "@+@+@+@+@+@+@@@+*@=++=@=+@=+@=+=@*+@+@+@+=+="; break;
  79.         case 37 : texte = "Wangle chief's permit if you really want to pass!!!"; break;
  80.         case 38 : texte = "The chief allowed you to pass??? Grrrr... So move along!!!"; break;
  81.         case 39 : texte = "Get out of my way!!!"; break;
  82.         case 40 : texte = "It's not common to have visitors around here."; break;
  83.         case 41 : texte = "Local monsters don't fear a lot of things, fortunately they only attack humans."; break;
  84.         case 42 : texte = "Really?*You understand what I say?"; break;
  85.         case 43 : texte = "N: Desert and Gerudo Village"; break;
  86.         case 44 : texte = "S: Lake Hylia*W: Hyrule Castle"; break;
  87.         case 45 : texte = "Kakariko Village"; break;
  88.         case 46 : texte = "W: Hyrule Castle"; break;
  89.         case 47 : texte = "What a good day!!!"; break;
  90.         case 48 : texte = "But why did I accept to take care of that rubbish???*I loathe hens!!!"; break;
  91.         case 49 : texte = "You can find a lot of things in the shop of this village."; break;
  92.         case 50 : texte = "S: Kakariko Village*W: Desert*E: Death Mountain"; break;
  93.         case 51 : texte = "Gerudo Village"; break;
  94.         case 52 : texte = "Lost in the desert?*You are here:*                        X"; break;
  95.         case 54 : texte = "S: To Hyrule Castle"; break;
  96.         case 55 : texte = "Desert Temple**Come to try our bath.*(water is not for drinking)"; break;
  97.         case 56 : texte = "Forest Temple**Save the trees, eat beaver!!!"; break;
  98.         case 57 : texte = "Lake Temple**Compulsory bathing cap."; break;
  99.         case 58 : texte = "Ice Temple**The staff wishes to remind you that a dungeon is not a ice rink."; break;
  100.         case 59 : texte = "Did you see the blacksmith of that village?*He is said to be very gifted to improve adventurers' equipment, a lot of people visit him."; break;
  101.         case 60 : texte = "The Temple is in the deepest desert, in an ancient oasis."; break;
  102.         case 61 : texte = "S: Fire Land*E: Kakariko Village"; break;
  103.         case 62 : texte = "Hyrule Castle"; break;
  104.         case 63 : texte = "E: Kakariko Village"; break;
  105.         case 64 : texte = "W: Turtle Rock*E: Lake Hylia"; break;
  106.         case 65 : texte = "Hidden Temple**Here rests the Sword of Evil's Bane, the Master Sword."; break;
  107.         case 66 : texte = "N: To the Haunted Graveyard"; break;
  108.         case 67 : texte = "You find the Dungeon Map!!!*Press P to see the map."; break;
  109.         case 68 : texte = "You find the Compass!!!*You can locate the boss and chests on the plan."; break;
  110.         case 69 : texte = "You find the Boss Key!!!"; break;
  111.         case 70 : texte = "You find a small key!!!*Go near a door to open it."; break;
  112.         case 71 : texte = "You find the Gloves!!!*Use them to lift some object setting them up or pressing C."; break;
  113.         case 72 :
  114.             texte = "You find a Magic Crystal!!!";
  115.             tmp = 7-gpJeu->getJoueur()->nbCristaux();
  116.             os << tmp;
  117.             if (tmp==6 && !gpJeu->getJoueur()->getAvancement()) buffer = "What may it be used for...?";
  118.             else if (tmp>2) buffer = "There are "+os.str()+" left to find!!!";
  119.             else if (tmp==2) buffer = "Only 2 left to find!!!";
  120.             else if (tmp==1) buffer = "You lack only one!!!";
  121.             else if (tmp==0) buffer = "You have all the crystals, run to the castle and save Zelda!!!";
  122.             break;
  123.         case 80 : texte = "You find the Hookshot!!!*Use it to overcome obstacles."; break;
  124.         case 81 : texte = "You find the Lantern!!!*Use it to bring out flames."; break;
  125.         case 82 : texte = "You find the Flippers!!!*Wear them to swim in the water."; break;
  126.         case 83 : texte = "You find the Magic Hammer!!!*Use it to squash obstacles."; break;
  127.         case 84 : texte = "You find the Fire Rod!!!*From now on you are able to shoot out powerful flames."; break;
  128.         case 85 : texte = "You find the Ice Rod!!!*Use it to freeze anything from a distance."; break;
  129.         case 86 : texte = "You find the Master Sword!!!*Even Ganon could not stand up to its power!!! (in theory)"; break;
  130.         case 87 : texte = "Congratulations, Link! You have succeeded in saving me!!!***Let's quickly find Ganon, we have to reclaim the Triforce!"; break;
  131.         case 89 : texte = "The secret passage behind the throne room leads to Ganon. Hurry up!"; break;
  132.         case 90 : texte = "We are very near, follow me!"; break;
  133.         case 91 : texte = "I'm afraid you are not able to defeat Ganon with your present weapons...*Go and speak to the chief of the Kakariko village, I am sure he will find a solution."; break;
  134.         case 92 : texte = "Ganon is just behind that door, I will cure your wounds."; break;
  135.         case 93 : texte = "Ganon is still somewhere in the castle."; break;
  136.         case 94 : texte = "You should wait for princess Zelda!!!"; break;
  137.         case 95 : texte = "Don't you have the spooky feeling that you are forgetting someone by any chance???"; break;
  138.         case 96 : texte = "Zelda is waiting for you!!!"; break;
  139.         case 97 : texte = "You find the Triforce!!!"; break;
  140.         case 98 : texte = "You find the book of Mudora!!!**From now on, you understand the ancient Hylian!!!"; break;
  141.         case 99 : texte = "Congratulations for finding me, Link. As a reward, I give you the Din Pendant; it raises your defense by one point."; break;
  142.         case 100 : texte = "Congratulations for finding me, Link. As a reward, I give you the Nayru Pendant; it raises your defense by two points!!!"; break;
  143.         case 101 : texte = "..."; break;
  144.         case 102 : texte = "You obtain a magic pendant!!!**Your defense just went up!!!"; break;
  145.         case 103 : texte = "Congratulations for finding me, Link. As a reward, I will double the capacity of your magic meter."; break;
  146.         case 104 : texte = "Your magic meter has been doubled!!!"; break;
  147.         case 105 : texte = "Come back when you have an empty bottle and I will sell you a red potion which restores energy."; break;
  148.         case 106 : texte = "A red potion for 60 rupees, are you interested?*              YES ?            no  ";
  149.             if (gpJeu->getJoueur()->hasBouteille(0)!=1
  150.             && gpJeu->getJoueur()->hasBouteille(1)!=1
  151.             && gpJeu->getJoueur()->hasBouteille(2)!=1) {id=105; chercheText();break;}
  152.             if (gpJeu->getJoueur()->getRubis() + gpJeu->getJoueur()->getBoostRubis()<60) idsuiv=29;
  153.             else idsuiv=108; break;
  154.         case 107 : texte = "A red potion for 60 rupees, are you interested?*              yes              NO ?"; break;
  155.         case 108 : texte = "Thank you, here is your potion.";break;
  156.         case 109 : texte = "You get a red potion!!!*Drink it to restore your energy."; break;
  157.         case 110 : texte = "You get a green potion!!!*Drink it to restore your magic."; break;
  158.         case 111 : texte = "You get a blue potion!!!*Drink it to restore your energy and your magic."; break;
  159.         case 112 : texte = "Hello, what would you like to drink?"; break;
  160.         case 113 : texte = "-Hiccup!- A fairy is said to give enchanted objects... -Hiccup!- ...to the adventurers who would find her... -Hiccup!!!-"; break;
  161.         case 114 : texte = "One heart for 10 rupees, ok?**              YES ?            no  ";
  162.             if (gpJeu->getJoueur()->getVie()+gpJeu->getJoueur()->getBoostVie()
  163.             == gpJeu->getJoueur()->getVieMax()) {id=128; chercheText();break;}
  164.             if (gpJeu->getJoueur()->getRubis() + gpJeu->getJoueur()->getBoostRubis()<10) idsuiv=29;
  165.             else idsuiv=129; break;
  166.         case 115 : texte = "One heart for 10 rupees, ok?**              yes              NO ?"; break;
  167.         case 116 : texte = "A little bit of magic for 20 rupees, ok?**              YES ?            no  ";
  168.             if (gpJeu->getJoueur()->getMagie()+gpJeu->getJoueur()->getBoostMagie()
  169.             == gpJeu->getJoueur()->getMagieMax() || !gpJeu->getJoueur()->hasObjet(O_LANTERNE)) {
  170.                 id=128; chercheText();break;}
  171.             if (gpJeu->getJoueur()->getRubis() + gpJeu->getJoueur()->getBoostRubis()<20) idsuiv=29;
  172.             else idsuiv=129; break;
  173.         case 117 : texte = "A little bit of magic for 20 rupees, ok?**              yes              NO ?"; break;
  174.         case 118 : texte = "Some magic for 30 rupees, ok?**              YES ?            no  ";
  175.             if (gpJeu->getJoueur()->getMagie()+gpJeu->getJoueur()->getBoostMagie()
  176.             == gpJeu->getJoueur()->getMagieMax() || !gpJeu->getJoueur()->hasObjet(O_LANTERNE)) {
  177.                 id=128; chercheText();break;}
  178.             if (gpJeu->getJoueur()->getRubis() + gpJeu->getJoueur()->getBoostRubis()<30) idsuiv=29;
  179.             else idsuiv=129; break;
  180.         case 119 : texte = "Some magic for 30 rupees, ok?**              yes              NO ?"; break;
  181.         case 120 : texte = "5 arrows for 30 rupees, ok?**              YES ?            no  ";
  182.             if (gpJeu->getJoueur()->getFleche() == gpJeu->getJoueur()->getFlecheMax()
  183.             || !gpJeu->getJoueur()->hasObjet(O_ARC)) {id=128; chercheText();break;}
  184.             if (gpJeu->getJoueur()->getRubis() + gpJeu->getJoueur()->getBoostRubis()<30) idsuiv=29;
  185.             else idsuiv=129; break;
  186.         case 121 : texte = "5 arrows for 30 rupees, ok?**              yes              NO ?"; break;
  187.         case 122 : texte = "One bomb for 30 rupees, ok?**              YES ?            no  ";
  188.             if (gpJeu->getJoueur()->getBombe() == gpJeu->getJoueur()->getBombeMax()
  189.             || !gpJeu->getJoueur()->hasObjet(O_SAC_BOMBES)) {id=128; chercheText();break;}
  190.             if (gpJeu->getJoueur()->getRubis() + gpJeu->getJoueur()->getBoostRubis()<30) idsuiv=29;
  191.             else idsuiv=129; break;
  192.         case 123 : texte = "One bomb for 30 rupees, ok?**              yes              NO ?"; break;
  193.         case 124 : texte = "A bow for 1000 rupees, ok?**              YES ?            no  ";
  194.             idsuiv=29; break;
  195.         case 125 : texte = "A bow for 1000 rupees, ok?**              yes              NO ?"; break;
  196.         case 126 : texte = "A bow for 50 rupees, ok?**              YES ?            no  ";
  197.             if (gpJeu->getJoueur()->getRubis() + gpJeu->getJoueur()->getBoostRubis()<50) idsuiv=29;
  198.             else idsuiv=129; break;
  199.         case 127 : texte = "A bow for 50 rupees, ok?**              yes              NO ?"; break;
  200.         case 128 : texte = "You don't need this right now."; break;
  201.         case 129 : texte = "Thank you."; break;
  202.         case 130 : texte = "You get the bow!!!*Use it to hit a distant target."; break;
  203.         case 131 : texte = "Choose whatever you want."; break;
  204.         case 132 : texte = "What???*You are fulfilling a mission for the chief???*Okay, so I will give you a discount on the bow."; break;
  205.         case 133 : texte = "Hello Link, I am the chief of that village, I suspected you were coming."; idsuiv=134; break;
  206.         case 134 : texte = "Ever since this morning, monsters stride along Hyrule. I tried to talk about that with Zelda, but as you perhaps already have seen, a powerful spell blocks the access to the castle..."; idsuiv=136; break;
  207.         case 136 : texte = "You say Ganon is responsible for all of that? He stole the Triforce and he holds the princess Zelda captive?"; idsuiv=137; break;
  208.         case 137 : texte = "Hmmm... The situation is more serious than I thought..."; idsuiv=138; break;
  209.         case 138 : texte = "We have to act very quickly, you must face Ganon again!"; idsuiv=139; break;
  210.         case 139 : texte = "How to enter the castle? I may have an idea..."; idsuiv=140; break;
  211.         case 140 : texte = "As you know, the power of the 7 wise men was locked in 7 crystals by wizard Aghanim when he was trying to open up the path to the Dark World, where Ganon was."; idsuiv=141; break;
  212.         case 141 : texte = "Yet, even if you raised the descendants of the 7 wise men from death after you defeated Ganon and found the Triforce, these crystals have kept their power."; idsuiv=142; break;
  213.         case 142 : texte = "They have been hidden deep in the 7 temples. Gather them all and you'll be able to get over Ganon's spell."; idsuiv=143; break;
  214.         case 143 : texte = "However that won't be easy. Ganon will surely send his best units to protect these crystals..."; idsuiv=144; break;
  215.         case 144 : texte = "A last thing, you won't go far with your present equipment. Go and see the arms dealer and tell him that you're coming on my behalf. He will probably make a gesture for you."; break;
  216.         case 145 : texte = "Go and see the arms dealer and tell him that you're coming on my behalf. He will probably make a gesture for you."; break;
  217.         case 146 : texte = "You have to gather the 7 crystals to have a chance to save Zelda and Hyrule..."; break;
  218.         case 147 : texte = "You found the 7 crystals? So go right now to the castle! First you have to rescue the princess, she will know better than I how to save Hyrule."; break;
  219.         case 148 : texte = "Your weapons are null and void against Ganon? In that case, you have to find the Master Sword. It is said to have been concealed in a hidden temple.*Besides, the way leading to the Sword of Evil's Bane is said to cross over a village populated by monsters...*I wonder if such a village exists..."; break;
  220.         case 150 : texte = "However, I'm afraid that your present equipment is inadequate to reach this temple. You may go to see the blacksmith of Gerudo village..."; break;
  221.         case 151 : texte = "It's about time to brave Ganon and take the Triforce back!"; break;
  222.         case 152 : texte = "Hey! You must pay in order to open one of my chests!!!"; break;
  223.         case 153 : texte = "One of these chests contains a piece of heart, do you want to try for 10 rupees?*You will only be allowed to open one chest, ok?               YES ?            no  ";
  224.             if (gpJeu->getJoueur()->getRubis() + gpJeu->getJoueur()->getBoostRubis()<10) idsuiv=29; break;
  225.         case 154 : texte = "One of these chests contains a piece of heart, do you want to try for 10 rupees?*You will only be allowed to open one chest, ok?               yes              NO ?"; break;
  226.         case 155 : texte = "Choose a chest."; break;
  227.         case 156 : texte = "I don't have anymore prizes to bring into play, sorry."; break;
  228.         case 157 : texte = "You lose! This chest is empty. Try again!"; break;
  229.         case 158 : texte = "Hello! If you are looking for the blacksmith, he lives a little farther."; break;
  230.         case 159 : texte = "Hello Link, I am the chief of this village.*You should go to see the blacksmith and show him what you want him to temper in your equipment.";
  231.             buffer = "I have been informed of your quest, so I have arranged it with him.*All will be free for you."; break;
  232.         case 160 : texte = "You don't need to drink this potion now."; break;
  233.         case 161 : texte = "A green potion for 40 rupees, are you interested?*              YES ?            no  ";
  234.             if (gpJeu->getJoueur()->hasBouteille(0)!=1
  235.             && gpJeu->getJoueur()->hasBouteille(1)!=1
  236.             && gpJeu->getJoueur()->hasBouteille(2)!=1) {id=163; chercheText();break;}
  237.             if (gpJeu->getJoueur()->getRubis() + gpJeu->getJoueur()->getBoostRubis()<40) idsuiv=29;
  238.             else idsuiv=108; break;
  239.         case 162 : texte = "A green potion for 40 rupees, are you interested?*              yes              NO ?"; break;
  240.         case 163 : texte = "Come back when you have an empty bottle and I will sell you a green potion which restores magic."; break;
  241.         case 164 : texte = "Come back later, I am overbooked!"; break;
  242.         case 165 : texte = "May I do something for you?";
  243.             if (gpJeu->getJoueur()->getEpee()==1) {id=166; chercheText();break;}
  244.             if (gpJeu->getJoueur()->hasObjet(O_GANTS)==1 && gpJeu->getJoueur()->getObjet()==8) {
  245.                 id=169; chercheText();break;}
  246.             if (gpJeu->getJoueur()->hasObjet(O_ARC)==2 && gpJeu->getJoueur()->getObjet()==0
  247.             && gpJeu->getJoueur()->nbCristaux()==7) {
  248.                 id=172; chercheText();break;}
  249.             break;
  250.         case 166 : texte = "Do you want me to temper your sword?**              YES ?            no  "; break;
  251.         case 167 : texte = "Do you want me to temper your sword?**              yes              NO ?"; break;
  252.         case 168 : texte = "Your sword triples in power and you can now throw some magic attack, so good!!!*"; break;
  253.         case 169 : texte = "Do you want me to upgrade your gloves?**              YES ?            no  "; break;
  254.         case 170 : texte = "Do you want me to upgrade your gloves?**              yes              NO ?"; break;
  255.         case 171 : texte = "The power of your gloves helps you to lift heavy rocks."; break;
  256.         case 172 : texte = "Do you want me to upgrade your bow?**              YES ?            no  "; break;
  257.         case 173 : texte = "Do you want me to upgrade your bow?**              yes              NO ?"; break;
  258.         case 174 : texte = "Your bow now shoots silver arrows with a cataclysmic power!!!"; break;
  259.         case 175 : texte = "Come back when you have an empty bottle and I will sell you a blue potion which restores energy and magic."; break;
  260.         case 176 : texte = "A blue potion for 160 rupees, are you interested?*              YES ?            no  ";
  261.             if (gpJeu->getJoueur()->hasBouteille(0)!=1
  262.             && gpJeu->getJoueur()->hasBouteille(1)!=1
  263.             && gpJeu->getJoueur()->hasBouteille(2)!=1) {id=175; chercheText();break;}
  264.             if (gpJeu->getJoueur()->getRubis() + gpJeu->getJoueur()->getBoostRubis()<160) idsuiv=29;
  265.             else idsuiv=108; break;
  266.         case 177 : texte = "A blue potion for 160 rupees, are you interested?*              yes              NO ?"; break;
  267.         case 178 : texte = "Our village has been founded in order to stop careless adventurers from reaching the temple. I won't allow just anyone to pass!"; break;
  268.         case 179 : texte = "Mmmm... You already found 4 crystals?*I have to admit you impress me...";
  269.             buffer = "All right, you are allowed to cross over the graveyard, at your own risk."; break;
  270.         case 181 : texte = "Talk to the guard at the north of the village, he will let you pass."; break;
  271.         case 182 : texte = "I see you're still alive...*Surprising."; break;
  272.         case 183 : texte = "The dark temple is the starting point of the way leading to a legendary object. This village just exists to dissuade adventurers from approaching."; break;
  273.         case 184 : texte = "So you found the Sword?*But don't believe it is yours for all that.";
  274.             buffer = "The Master Sword is among the most treasured heritage of Hyrule with the Triforce, you will have to bring it back in his sanctuary when your mission is completed."; break;
  275.         case 186 : texte = "All the inhabitants of this village are spirits who responded to princess Zelda's call."; break;
  276.         case 187 : texte = "When you returned peace to Hyrule and reunified the Light World with the Golden Land, Zelda secretly asked volunteer spirits to create this village to block";
  277.             buffer = "the access to a very high valued object."; break;
  278.        
  279.         case 189 : texte = "Welcome Link!*Let me explain what I am doing here."; idsuiv=190; break;
  280.         case 190 : texte = "As you certainly have noticed, monsters have appeared in Hyrule. It's the first time I have seen monsters since your victory on Ganon."; idsuiv=191; break;
  281.         case 191 : texte = "Well, I have decided to list all of them."; idsuiv=192; break;
  282.         case 192 : texte = "Unfortunately, I'm really too fearful to meet them, so I need your help."; idsuiv=193; break;
  283.         case 193 : texte = "You have to fight each kind of monster and come back to give me your report."; idsuiv=194; break;
  284.         case 194 : texte = "Each time you have defeated 7 new kinds of enemies, I will give you one piece of heart."; idsuiv=195; break;
  285.         case 195 : texte = "If you want to see what enemies you've already defeated, press M."; break;
  286.        
  287.        
  288.         case 196 :
  289.             if (gpJeu->getJoueur()->getCoeur(43)) {
  290.                 if (gpJeu->getJoueur()->nbEnnemis() >= 46) {id=205; chercheText();return;}
  291.                 else {id=204; chercheText();return;}
  292.             }
  293.             for (int i = 38; i < 44; i++)
  294.                 if (!gpJeu->getJoueur()->getCoeur(i)
  295.                 && (gpJeu->getJoueur()->nbEnnemis()/7)+37>=i) {
  296.                     id=203; chercheText();return;
  297.                 }
  298.             tmp = 7-(gpJeu->getJoueur()->nbEnnemis()%7);
  299.             os << tmp;
  300.             if (tmp>1) texte = os.str()+" different enemies left before your next reward.";
  301.             else texte = "You need only one more enemy before the next reward!!!";
  302.             break;
  303.         case 203 : texte = "Take this gift for your contribution on my project:"; break;
  304.         case 204 : texte = "I'm sorry, but I don't have a gift for you anymore..."; break;
  305.         case 205 : texte = "I can't take it in, you succeeded in defeating all kinds of enemies!!!*Congratulation Link!!!"; break;
  306.        
  307.         case 206 : texte = "                    Level 1:**                  Forest Temple"; break;
  308.         case 207 : texte = "                    Level 2:**                  Water Temple"; break;
  309.         case 208 : texte = "                    Level 3:**                 Mountain Temple"; break;
  310.         case 209 : texte = "                    Level 4:**                  Desert Temple"; break;
  311.         case 210 : texte = "                    Level 5:**                   Dark Temple"; break;
  312.         case 211 : texte = "                    Level 6:**                   Fire Temple"; break;
  313.         case 212 : texte = "                    Level 7:**                   Ice Temple"; break;
  314.         case 213 : texte = "                    Level ?:**                  Hidden Temple"; break;
  315.         case 214 : texte = "                  Last Level:**                 Hyrule Castle"; break;
  316.        
  317.         case 215 :texte = "                 Already tired?                  ?                 CONTINUE                 ?                   Save and quit                               Quit without saving            "; break;
  318.         case 216 :texte = "                 Already tired?                                    Continue                     ?               SAVE AND QUIT              ?                Quit without saving            "; break;
  319.         case 217 :texte = "                 Already tired?                                    Continue                                     Save and quit                  ?            QUIT WITHOUT SAVING           ?"; break;
  320.        
  321.         case 223 : texte = "At the right time, when Link touched the Triforce, monsters disappeared and peace returned.**Princess Zelda then made a great decision: she touched in turn the Triforce and made her wish.**Triforce had always been the origin of troubles in the Kingdom; sooner or later, another evil creature would find it.**Just when the princess touched the relic, it disappeared from Hyrule forever.";
  322.             buffer = "Since this day, Hyrule's people have lived in peace, without fear of new disasters.**Thus the legend of Zelda, of the Triforce and of the Golden Land is achieved.**Master Sword is said to rest safely somewhere and to be the last heirloom of Link's quest..."; break;
  323.         case 224 : texte = "Congratulation Link, for finding me. As a reward, I give you the Farore Pendant; it raises your defense by one point..."; break;
  324.         case 225 : texte = "Do you want to save your game?**                    ? YES ?*                      no  "; break;
  325.         case 226 : texte = "Do you want to save your game?**                      yes  *                    ? NO ?"; break;
  326.         case 227 : texte = "Game saved."; break;
  327.        
  328.         case 228 : texte = "The Kingdom of Hyrule has been in peace since Link, the last knight of Hyrule, had defeated the malicious Ganon and reclaimed the precious Triforce."; idsuiv = 229; break;
  329.         case 229 : texte = "Nobody knows what Link's wish to the Triforce was, but it had the effect of reunifying the Light and Dark World, and bringig back the 7 wise men's descendants to life."; idsuiv = 230; break;
  330.         case 230 : texte = "Next, Link handed the Triforce and the Master Sword over to Princess Zelda, and people started to believe that peace would last.*But the people were wrong..."; idsuiv=231; break;
  331.         case 231 : texte = "Unfortunately, Link's wish also had negative effects. Ganon and his henchmen were resurrected and got ready to attack."; idsuiv=232; break;
  332.         case 232 : texte = "Somewhere in Hyrule Forest, Link is sleeping without suspecting that Ganon has already moved into the attack, until a";
  333.             buffer="well-known voice talked to him during his sleep..."; break;
  334.         case 233 : texte = "Help me!*Help me!*That's me! Zelda!*I'm talking to you by telepathy."; idsuiv = 234; break;
  335.         case 234 : texte = "I am a prisoner in the dungeon of the castle!*I need your help!*Ganon is back, and he surely has already found the Triforce..."; idsuiv=235; break;
  336.         case 235 : texte = "Come quickly to the castle Link, you are my only hope..."; break;
  337.         case 236 : texte = "HELP: Press F1 to consult help."; break;
  338.     }
  339.    
  340.    
  341. }
  342.  
  343. void Texte::affiche(SDL_Surface* gpScreen, std::string s, int a, int b) {
  344.     for (int i = 0; i < (int)s.length(); i++) {
  345.         afficheLettre(gpScreen, s.at(i),a,b);
  346.         a+=6;
  347.     }
  348. }
  349.  
  350. void Texte::draw(SDL_Surface* gpScreen) {
  351.    
  352.     if (cadre) drawCadre(gpScreen);
  353.    
  354.     if (id==3 && texte == "You foundd a piece of heart!!!") {
  355.         SDL_Rect src; SDL_Rect dst;
  356.         src.x=16*(gpJeu->getJoueur()->nbQuarts()%4);
  357.         if(src.x==0)src.x=16*4;
  358.         src.y=0; src.w=16; src.h=16; dst.x=160-8; dst.y=120-8+16*5;
  359.         SDL_BlitSurface(imageCoeur, &src, gpScreen, &dst);
  360.     }
  361.    
  362.     int a = x+8; int b = y+8;
  363.     for (int i = 0; i < av; i++) {
  364.         afficheLettre(gpScreen, texte.at(i),a,b);
  365.         a+=6;
  366.         if (a > x+w-16) {a=x+8; b+=16;}
  367.     }
  368.    
  369.     if(SDL_GetTicks() > lastAnimTime + vitesse && def && av < (int)texte.length()) {
  370.         lastAnimTime = SDL_GetTicks();
  371.         do av++;
  372.         while (av < (int)texte.length() && texte.at(av-1) == ' ');
  373.         if (texte.at(av-1) != ' ') gpJeu->getAudio()->playSound(0,1);
  374.     }
  375. }
  376.  
  377. bool Texte::isFinished() {return (av==(int)texte.length());}
  378.  
  379. int Texte::getId() {return id;}
  380.  
  381. void Texte::changeId(int i) {
  382.     id=i; idsuiv=0; buffer="";
  383.     chercheText();
  384.     decoupeText();
  385.     if (av>(int)texte.length()) av=(int)texte.length();
  386. }
  387.  
  388. void Texte::drawCadre(SDL_Surface* gpScreen) {
  389.     SDL_Rect src;
  390.     SDL_Rect dst;
  391.    
  392.     src.w=8; src.h=8; src.x = 103; src.y = 100; dst.x = x; dst.y = y;
  393.     SDL_BlitSurface(imageFont, &src, gpScreen, &dst);
  394.    
  395.     src.x = 112;
  396.     for (int i = 8; i < w-8; i+=16) {
  397.         dst.x = x+i; src.w=16;
  398.         while (dst.x + src.w > x+w && src.w>0) src.w--;
  399.         if (src.w>0) SDL_BlitSurface(imageFont, &src, gpScreen, &dst);
  400.     }
  401.    
  402.     src.w=8; src.x = 129; dst.x = x+w-8;
  403.     SDL_BlitSurface(imageFont, &src, gpScreen, &dst);
  404.    
  405.     src.y = 109; src.w=8;
  406.     for (int j = 8; j < h-8; j+=16) {
  407.         dst.y = y + j;
  408.         src.x = 103; dst.x = x; src.h=16;
  409.         while (dst.y + src.h > y+h && src.h>0) src.h--;
  410.         if (src.h>0) SDL_BlitSurface(imageFont, &src, gpScreen, &dst);
  411.    
  412.         src.x = 129; dst.x = x+w-8;
  413.         if (src.h>0)SDL_BlitSurface(imageFont, &src, gpScreen, &dst);
  414.     }
  415.    
  416.     src.h=8; src.x = 103; src.y = 126; dst.x = x; dst.y = y+h-8;
  417.     SDL_BlitSurface(imageFont, &src, gpScreen, &dst);
  418.    
  419.     src.x = 112;
  420.     for (int i = 8; i < w-8; i+=16) {
  421.         dst.x = x+i; src.w=16;
  422.         while (dst.x + src.w > x+w && src.w>0) src.w--;
  423.         if (src.w>0) SDL_BlitSurface(imageFont, &src, gpScreen, &dst);
  424.     }
  425.    
  426.     src.w=8; src.x = 129; dst.x = x+w-8;
  427.     SDL_BlitSurface(imageFont, &src, gpScreen, &dst);
  428. }
  429.  
  430. void Texte::setTexte(int idTxt, int vx, int vy, int vw, int vh, bool cadr, bool defil, int vit) {
  431.     if (idTxt == 0) return;
  432.     id = idTxt;
  433.     idsuiv = 0;
  434.     buffer = "";
  435.     chercheText();
  436.    
  437.     x = vx; y = vy; w = vw; h = vh;
  438.     decoupeText();
  439.        
  440.     def=defil;
  441.     if (def) av = 0;
  442.     else av = texte.length();
  443.    
  444.     cadre = cadr;
  445.    
  446.     vitesse = vit;
  447. }
  448.  
  449. void Texte::decoupeText() {
  450.     //compte le nombre de caractères possibles et largeur et en hauteur
  451.     int nbcol = (w-16)/6 -1;
  452.     int nblig = (h-16)/16;
  453.     int tailleMax = nbcol * nblig;
  454.     int taille;
  455.    
  456.     //parcours du texte à afficher; à chaque début de mot,
  457.     //vérifie que le mot peut tenir sur la ligne
  458.     for (int i = 0; i < (int)texte.length(); i++) {
  459.        
  460.         //supprime les espaces isolés en début de ligne
  461.         if (texte.at(i)==' ' && texte.at(i+1)!=' ' && i%nbcol == 0) texte.erase(i,1);
  462.         //recherche du début du prochain mot
  463.         while(texte.at(i)==' ' && i < (int)texte.length()-1) i++;
  464.        
  465.         //saute une ligne si trouve une étoile
  466.         if (texte.at(i)=='*') {
  467.             texte.erase(i,1);//replace(i, 1, " ");
  468.             int nb = (nbcol)-(i%(nbcol));
  469.             for (int j = 0; j < nb; j++) texte.insert(i," ");
  470.             continue;
  471.         }
  472.        
  473.         //si le mot dépasse
  474.         taille = tailleMot(i);
  475.         if ((i%nbcol)+taille>nbcol) {
  476.             if  (i < tailleMax) {
  477.                 //si le mot ne tient pas sur une ligne, on le coupe avec des tirets
  478.                 if (taille>nbcol) {
  479.                     texte.insert(((i/nbcol)+1)*nbcol-1,"--");
  480.                     i = 1+((i/nbcol)+1)*nbcol;
  481.                 }
  482.                 //sinon, on ajoute des espaces pour faire commencer le mot à la ligne
  483.                 else while((i%nbcol) != 0) {texte.insert(i," "); i++;}
  484.             }
  485.         }
  486.        
  487.     }
  488.    
  489.     // si le texte est trop grand, on le coupe en deux
  490.     if ((int)texte.length() > tailleMax) {
  491.         buffer = texte.substr(tailleMax);
  492.         texte = texte.substr(0, tailleMax);
  493.     }
  494. }
  495.  
  496. int Texte::tailleMot(int deb) {
  497.     int i = deb;
  498.     int total = 0;
  499.     while (texte.at(i)!=' ') {total++; i++; if (i >= (int)texte.length()) return total;}
  500.     return total;
  501. }
  502.  
  503. void Texte::afficheLettre(SDL_Surface* gpScreen, char c, int vx, int vy) {
  504.     SDL_Rect src;
  505.     SDL_Rect dst;
  506.    
  507.     int val = (int)c;
  508.    
  509.     dst.x=vx; dst.y=vy;
  510.     src.h=16;src.w=8;
  511.    
  512.     if(val==32) return;
  513.    
  514.     // /
  515.     if(val==47) {src.x=52;src.y=151;}
  516.    
  517.     // @ hylien
  518.     if(val==64) {src.x=4;src.y=151;}
  519.            
  520.     // + hylien
  521.     if(val==43) {src.x=20;src.y=151;}
  522.            
  523.     // = hylien
  524.     if(val==61) {src.x=36;src.y=151;}
  525.            
  526.     //minuscules a-z
  527.     if(val>=97 && val<=122) {src.x=4+16*((val-97)%10); src.y=52+16*((val-97)/10);}
  528.            
  529.     //majuscules A-Z
  530.     if(val>=65 && val<=90) {src.x=6+16*((val-65)%10); src.y=2+16*((val-65)/10);}  
  531.     // ç
  532.     if(val==-25) {src.x=148;src.y=34;}
  533.     // é
  534.     if(val==-23) {src.x=100;src.y=84;}
  535.     // ê
  536.     if(val==-22) {src.x=116;src.y=84;}
  537.     // è
  538.     if(val==-24) {src.x=132;src.y=84;}
  539.     // ë
  540.     if(val==-21) {src.x=132;src.y=151;}
  541.     // à
  542.     if(val==-32) {src.x=148;src.y=84;}
  543.     // â
  544.     if(val==-30) {src.x=148;src.y=103;}
  545.     // ä
  546.     if(val==-28) {src.x=148;src.y=135;}
  547.     // î
  548.     if(val==-18) {src.x=84;src.y=119;}
  549.     // ï
  550.     if(val==-17) {src.x=116;src.y=151;}
  551.     // û
  552.     if(val==-5) {src.x=84;src.y=103;}
  553.     // ù
  554.     if(val==-7) {src.x=148;src.y=151;}
  555.     // ü
  556.     if(val==-4) {src.x=116;src.y=135;}
  557.     // ö
  558.     if(val==-10) {src.x=132;src.y=135;}
  559.     // ô
  560.     if(val==-12) {src.x=148;src.y=119;}
  561.            
  562.     //ponctuation
  563.     // -
  564.     if(val==45) {src.x=102;src.y=34;}
  565.     // .
  566.     if(val==46) {src.x=118;src.y=34;}
  567.     // ,
  568.     if(val==44) {src.x=134;src.y=34;}
  569.     // !
  570.     if(val==33) {src.x=3;src.y=135;}
  571.     // ?
  572.     if(val==63) {src.x=19;src.y=135;}
  573.     // (
  574.     if(val==40) {src.x=35;src.y=135;}
  575.     // )
  576.     if(val==41) {src.x=51;src.y=135;}            
  577.     // ' ( avec @ )
  578.     if(val==39) {src.x=67;src.y=135;}
  579.     // :
  580.     if(val==58) {src.x=83;src.y=135;}
  581.     // ... ( avec % )
  582.     if(val==37) {src.x=101;src.y=135;}
  583.     // >
  584.     if(val==62) {src.x=100;src.y=151;}
  585.     // <
  586.     if(val==60) {src.x=84;src.y=151;}
  587.            
  588.     //chiffres            
  589.     if(val>=48 && val<=57) {src.x=3+16*((val-48)%5); src.y=103+16*((val-48)/5);}
  590.    
  591.     SDL_BlitSurface(imageFont, &src, gpScreen, &dst);
  592. }
  593.  
  594. bool Texte::hasNext() {
  595.     return (buffer != "" || idsuiv > 0);
  596. }
  597.  
  598. bool Texte::suite() {
  599.     if (av < (int)texte.length()) {
  600.         av = texte.length();
  601.         return true;
  602.     }
  603.     if (!hasNext()) {
  604.         gpJeu->getAudio()->playSound(18);
  605.         return gpJeu->finTexte(id);
  606.     }
  607.     if (buffer != "") {
  608.         texte = buffer;
  609.         buffer = "";
  610.     }
  611.     else {
  612.         id = idsuiv;
  613.         idsuiv = 0;
  614.         chercheText();
  615.     }
  616.     decoupeText();
  617.     if (def) av = 0;
  618.     else av = texte.length();
  619.     gpJeu->getAudio()->playSound(17);
  620.     return true;
  621. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement