]> git.localhorst.tv Git - l2e.git/blobdiff - src/main.cpp
added Spell and TargetingMode interpretation
[l2e.git] / src / main.cpp
index 90f08d53bed888b629406ef15b248de497511e64..2f1c12ab655f4c2e92208bff89b37825f90780a2 100644 (file)
@@ -103,63 +103,17 @@ int main(int argc, char **argv) {
 
                battle::Resources battleRes;
 
-               SDL_Surface *swapCursorImg(IMG_Load("test-data/swap-cursor.png"));
-               Sprite swapCursorSprite(swapCursorImg, 32, 32);
-               battleRes.swapCursor = &swapCursorSprite;
-               SDL_Surface *attackIconsImg(IMG_Load("test-data/attack-type-icons.png"));
-               Sprite attackIconsSprite(attackIconsImg, 32, 32);
-               battleRes.attackIcons = &attackIconsSprite;
-               SDL_Surface *attackChoiceIconsImg(IMG_Load("test-data/attack-choice-icons.png"));
-               Sprite attackChoiceIconsSprite(attackChoiceIconsImg, 16, 16);
-               battleRes.attackChoiceIcons = &attackChoiceIconsSprite;
-               SDL_Surface *moveIconsImg(IMG_Load("test-data/move-icons.png"));
-               Sprite moveIconsSprite(moveIconsImg, 32, 32);
-               battleRes.moveIcons = &moveIconsSprite;
-
-               SDL_Surface *titleFrameImg(IMG_Load("test-data/title-frame.png"));
-               Frame titleFrame(titleFrameImg, 16, 16);
-               battleRes.titleFrame = &titleFrame;
-
-               SDL_Surface *largeFontImg(IMG_Load("test-data/large-font.png"));
-               Sprite largeFontSprite(largeFontImg, 16, 32);
-               Font largeFont(&largeFontSprite, 0, -2);
-               battleRes.titleFont = &largeFont;
-
-               ComplexAnimation numberAnimationPrototype(0, framerate);
-               numberAnimationPrototype.AddFrame(0, 0);
-               numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -26));
-               numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -42));
-               numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -48));
-               numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -42));
-               numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -26));
-               numberAnimationPrototype.AddFrame(0, 0);
-               numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
-               numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -20));
-               numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -24));
-               numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -20));
-               numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
-               numberAnimationPrototype.AddFrame(0, 0);
-               numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -6));
-               numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -10));
-               numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
-               numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -10));
-               numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -6));
-               numberAnimationPrototype.AddFrames(0, 0, Vector<int>(), 14);
-               numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -36));
-               numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -32));
-               numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -18));
-               battleRes.numberAnimationPrototype = &numberAnimationPrototype;
-
-               SDL_Surface *bigNumbersImg(IMG_Load("test-data/big-numbers.png"));
-               Sprite bigNumbersSprite(bigNumbersImg, 16, 32);
-               battleRes.bigNumberSprite = &bigNumbersSprite;
-               SDL_Surface *bigGreenNumbersImg(IMG_Load("test-data/big-green-numbers.png"));
-               Sprite bigGreenNumbersSprite(bigGreenNumbersImg, 16, 32);
-               battleRes.greenNumberSprite = &bigGreenNumbersSprite;
-
-               SDL_Surface *heroTagImg(IMG_Load("test-data/hero-tag-sprites.png"));
-               Sprite heroTagSprite(heroTagImg, 32, 16);
-               battleRes.heroTagLabels = &heroTagSprite;
+               battleRes.swapCursor = intp.GetSprite("swapCursor");
+               battleRes.attackIcons = intp.GetSprite("attackIcons");
+               battleRes.attackChoiceIcons = intp.GetSprite("attackChoiceIcons");
+               battleRes.moveIcons = intp.GetSprite("moveIcons");
+               battleRes.titleFrame = intp.GetFrame("titleFrame");
+               battleRes.titleFont = intp.GetFont("largeFont");
+               battleRes.numberAnimationPrototype = intp.GetAnimation("numberAnimationPrototype");
+               battleRes.bigNumberSprite = intp.GetSprite("bigNumbers");
+               battleRes.greenNumberSprite = intp.GetSprite("bigGreenNumbers");
+
+               battleRes.heroTagLabels = intp.GetSprite("heroTagLabels");
                battleRes.levelLabelCol = 0;
                battleRes.levelLabelRow = 0;
                battleRes.healthLabelCol = 0;
@@ -171,101 +125,46 @@ int main(int argc, char **argv) {
                battleRes.ikariLabelCol = 0;
                battleRes.ikariLabelRow = 4;
 
-               SDL_Surface *numbersImg(IMG_Load("test-data/numbers.png"));
-               Sprite numbersSprite(numbersImg, 16, 16);
-               Font heroTagFont(&numbersSprite, 0, -3);
-               battleRes.heroTagFont = &heroTagFont;
-               SDL_Surface *tagFramesImg(IMG_Load("test-data/tag-frames.png"));
-               Frame heroTagFrame(tagFramesImg, 16, 16, 1, 1, 0, 33);
-               battleRes.heroTagFrame = &heroTagFrame;
-               Frame activeHeroTagFrame(tagFramesImg, 16, 16);
-               battleRes.activeHeroTagFrame = &activeHeroTagFrame;
-               SDL_Surface *smallTagFrameImg(IMG_Load("test-data/small-tag-frame.png"));
-               Frame smallTagFrame(smallTagFrameImg, 8, 16);
-               battleRes.smallHeroTagFrame = &smallTagFrame;
-               Frame lastSmallTagFrame(smallTagFrameImg, 8, 16, 1, 1, 0, 33);
-               battleRes.lastSmallHeroTagFrame = &lastSmallTagFrame;
+               battleRes.heroTagFont = intp.GetFont("heroTagFont");
+               battleRes.heroTagFrame = intp.GetFrame("heroTagFrame");
+               battleRes.activeHeroTagFrame = intp.GetFrame("activeHeroTagFrame");
+               battleRes.smallHeroTagFrame = intp.GetFrame("smallHeroTagFrame");
+               battleRes.lastSmallHeroTagFrame = intp.GetFrame("lastSmallHeroTagFrame");
                battleRes.heroesBgColor = SDL_MapRGB(screen.Screen()->format, 0x18, 0x28, 0x31);
 
-               SDL_Surface *gauges(IMG_Load("test-data/gauges.png"));
-               Gauge healthGauge(gauges, 0, 16, 0, 0, 16, 6, 1, 6);
-               battleRes.healthGauge = &healthGauge;
-               Gauge manaGauge(gauges, 0, 32, 0, 0, 16, 6, 1, 6);
-               battleRes.manaGauge = &manaGauge;
-               Gauge ikariGauge(gauges, 0, 48, 0, 0, 16, 6, 1, 6);
-               battleRes.ikariGauge = &ikariGauge;
-
-               SDL_Surface *selectFrameImg(IMG_Load("test-data/select-frame.png"));
-               Frame selectFrame(selectFrameImg, 16, 16);
-               battleRes.selectFrame = &selectFrame;
-
-               SDL_Surface *normalFontImg(IMG_Load("test-data/normal-font.png"));
-               Sprite normalFontSprite(normalFontImg, 16, 16);
-               Font normalFont(&normalFontSprite, 0, -2);
-               battleRes.normalFont = &normalFont;
-
-               SDL_Surface *disabledFontImg(IMG_Load("test-data/disabled-font.png"));
-               Sprite disabledFontSprite(disabledFontImg, 16, 16);
-               Font disabledFont(&disabledFontSprite, 0, -2);
-               battleRes.disabledFont = &disabledFont;
-
-               SDL_Surface *handCursorImg(IMG_Load("test-data/cursor-hand.png"));
-               Sprite handCursorSprite(handCursorImg, 32, 32);
-               battleRes.menuCursor = &handCursorSprite;
-
-               SDL_Surface *targetingIconsImg(IMG_Load("test-data/targeting-icons.png"));
-               Sprite weaponTargetCursor(targetingIconsImg, 32, 32);
-               Sprite magicTargetCursor(targetingIconsImg, 32, 32, 0, 32);
-               Sprite itemTargetCursor(targetingIconsImg, 32, 32, 0, 64);
-               battleRes.weaponTargetCursor = &weaponTargetCursor;
-               battleRes.magicTargetCursor = &magicTargetCursor;
-               battleRes.itemTargetCursor = &itemTargetCursor;
-
-               Spell resetSpell;
-               resetSpell.SetName("Reset");
-               maxim.AddSpell(&resetSpell);
-               Spell strongSpell;
-               strongSpell.SetName("Strong");
-               strongSpell.SetCost(3);
-               strongSpell.SetUsableInBattle();
-               strongSpell.GetTargetingMode().TargetMultipleAllies();
-               maxim.AddSpell(&strongSpell);
-               selan.AddSpell(&strongSpell);
-               Spell strongerSpell;
-               strongerSpell.SetName("Stronger");
-               strongerSpell.SetCost(8);
-               strongerSpell.SetUsableInBattle();
-               strongerSpell.GetTargetingMode().TargetMultipleAllies();
-               maxim.AddSpell(&strongerSpell);
-               selan.AddSpell(&strongerSpell);
-               Spell championSpell;
-               championSpell.SetName("Champion");
-               championSpell.SetCost(16);
-               championSpell.SetUsableInBattle();
-               championSpell.GetTargetingMode().TargetMultipleAllies();
-               maxim.AddSpell(&championSpell);
-               selan.AddSpell(&championSpell);
-               Spell rallySpell;
-               rallySpell.SetName("Rally");
-               rallySpell.SetCost(10);
-               rallySpell.SetUsableInBattle();
-               rallySpell.GetTargetingMode().TargetMultipleAllies();
-               maxim.AddSpell(&rallySpell);
-               selan.AddSpell(&rallySpell);
-               Spell escapeSpell;
-               escapeSpell.SetName("Escape");
-               escapeSpell.SetCost(8);
-               selan.AddSpell(&escapeSpell);
-               Spell valorSpell;
-               valorSpell.SetName("Valor");
-               valorSpell.SetCost(30);
-               valorSpell.SetUsableInBattle();
-               valorSpell.GetTargetingMode().TargetMultipleAllies();
-               maxim.AddSpell(&valorSpell);
-               selan.AddSpell(&valorSpell);
+               battleRes.healthGauge = intp.GetGauge("healthGauge");
+               battleRes.manaGauge = intp.GetGauge("manaGauge");
+               battleRes.ikariGauge = intp.GetGauge("ikariGauge");
+
+               battleRes.selectFrame = intp.GetFrame("selectFrame");
+               battleRes.normalFont = intp.GetFont("normalFont");
+               battleRes.disabledFont = intp.GetFont("disabledFont");
+               battleRes.menuCursor = intp.GetSprite("handCursor");
+
+               battleRes.weaponTargetCursor = intp.GetSprite("weaponTargetCursor");
+               battleRes.magicTargetCursor = intp.GetSprite("magicTargetCursor");
+               battleRes.itemTargetCursor = intp.GetSprite("itemTargetCursor");
+
+               maxim.AddSpell(intp.GetSpell("resetSpell"));
+               Spell *strongSpell(intp.GetSpell("strongSpell"));
+               maxim.AddSpell(strongSpell);
+               selan.AddSpell(strongSpell);
+               Spell *strongerSpell(intp.GetSpell("strongerSpell"));
+               maxim.AddSpell(strongerSpell);
+               selan.AddSpell(strongerSpell);
+               Spell *championSpell(intp.GetSpell("championSpell"));
+               maxim.AddSpell(championSpell);
+               selan.AddSpell(championSpell);
+               Spell *rallySpell(intp.GetSpell("rallySpell"));
+               maxim.AddSpell(rallySpell);
+               selan.AddSpell(rallySpell);
+               selan.AddSpell(intp.GetSpell("escapeSpell"));
+               Spell *valorSpell(intp.GetSpell("valorSpell"));
+               maxim.AddSpell(valorSpell);
+               selan.AddSpell(valorSpell);
 
                battleRes.spellMenuHeadline = "Please choose a spell.";
-               battleRes.spellMenuPrototype = Menu<const Spell *>(&normalFont, &disabledFont, &handCursorSprite, 9, 6, 8, 0, 2, 32, 2, ':');
+               battleRes.spellMenuPrototype = Menu<const Spell *>(intp.GetFont("normalFont"), intp.GetFont("disabledFont"), intp.GetSprite("handCursor"), 9, 6, 8, 0, 2, 32, 2, ':');
 
                SDL_Surface *itemIcons(IMG_Load("test-data/item-icons.png"));
                Sprite potionIcon(itemIcons, 16, 16);
@@ -334,7 +233,7 @@ int main(int argc, char **argv) {
                battleRes.inventory = &inventory;
 
                battleRes.itemMenuHeadline = "Please choose an item.";
-               battleRes.itemMenuPrototype = Menu<const common::Item *>(&normalFont, &disabledFont, &handCursorSprite, 15, 6, 8, 16, 1, 32, 2, ':');
+               battleRes.itemMenuPrototype = Menu<const common::Item *>(intp.GetFont("normalFont"), intp.GetFont("disabledFont"), intp.GetSprite("handCursor"), 15, 6, 8, 16, 1, 32, 2, ':');
 
                SDL_Surface *swordAttackImg(IMG_Load("test-data/attack-sword.png"));
                Sprite swordAttackSprite(swordAttackImg, 96, 96);
@@ -556,7 +455,7 @@ int main(int argc, char **argv) {
 
                battleRes.ikariMenuHeadline = "Please choose equipment.";
                battleRes.noEquipmentText = "No equip";
-               battleRes.ikariMenuPrototype = Menu<const Item *>(&normalFont, &disabledFont, &handCursorSprite, 12, 6, normalFont.CharHeight() / 2, normalFont.CharWidth(), 1, normalFont.CharWidth() * 2, 0, ':', 12, normalFont.CharWidth());
+               battleRes.ikariMenuPrototype = Menu<const Item *>(intp.GetFont("normalFont"), intp.GetFont("disabledFont"), intp.GetSprite("handCursor"), 12, 6, intp.GetFont("normalFont")->CharHeight() / 2, intp.GetFont("normalFont")->CharWidth(), 1, intp.GetFont("normalFont")->CharWidth() * 2, 0, ':', 12, intp.GetFont("normalFont")->CharWidth());
 
                battleRes.escapeText = "Escapes.";