spellMenus.back().Add("Stronger : 8", 0);
spellMenus.back().Add("Champion :16", 0);
spellMenus.back().Add("Rally :10", 0);
+ spellMenus.back().Add("Escape : 8", 0, false);
spellMenus.back().Add("Valor :30", 0);
spellMenus.back().Add("Poison : 2", 0);
+ spellMenus.back().Add("Warp : 8", 0, false);
spellMenus.back().Add("Release : 2", 0);
spellMenus.back().Add("Waken : 4", 0);
+ spellMenus.back().Add("Light : 0", 0, false);
spellMenus.back().Add("Fake : 4", 0);
spellMenus.back().Add("Trick : 5", 0);
+ spellMenus.back().Add("Flash : 5", 0);
+ spellMenus.back().Add("Fireball : 6", 0);
+ spellMenus.back().Add("Vortex : 7", 0);
+ spellMenus.back().Add("Blizzard : 8", 0);
+ spellMenus.back().Add("Spark : 3", 0);
heroTags.push_back(HeroTag(&heroes[i], &attackChoices[i], res, HeroTag::Alignment((i + 1) % 2)));
}
}
#include "../../geometry/Point.h"
#include "../../graphics/Frame.h"
-#include <iostream>
-
using app::Application;
using app::Input;
using geometry::Point;
ctrl->PopState(); // return control to parent
}
if (input.JustPressed(Input::PAD_UP)) {
- std::cout << "pressed up" << std::endl;
battle->GetSpellMenu().PreviousRow();
- std::cout << "selected index: " << battle->GetSpellMenu().SelectedIndex() << std::endl;
}
if (input.JustPressed(Input::PAD_RIGHT)) {
- std::cout << "pressed right" << std::endl;
battle->GetSpellMenu().NextItem();
- std::cout << "selected index: " << battle->GetSpellMenu().SelectedIndex() << std::endl;
}
if (input.JustPressed(Input::PAD_DOWN)) {
- std::cout << "pressed down" << std::endl;
battle->GetSpellMenu().NextRow();
- std::cout << "selected index: " << battle->GetSpellMenu().SelectedIndex() << std::endl;
}
if (input.JustPressed(Input::PAD_LEFT)) {
- std::cout << "pressed left" << std::endl;
battle->GetSpellMenu().PreviousItem();
- std::cout << "selected index: " << battle->GetSpellMenu().SelectedIndex() << std::endl;
}
}
#include "../geometry/Point.h"
#include "../geometry/Vector.h"
-#include <iostream>
#include <vector>
#include <SDL.h>
public:
Menu();
Menu(const Font *font, const Font *disabledFont, const Sprite *cursor, int charsPerEntry, int rows, int rowGap = 0, int cols = 1, int colGap = 0);
- Menu(const Menu &);
public:
int Width() const;
}
-template<class T>
-Menu<T>::Menu(const Menu &other)
-: font(other.font)
-, disabledFont(other.disabledFont)
-, cursor(other.cursor)
-, entries(other.entries)
-, charsPerEntry(other.charsPerEntry)
-, rows(other.rows)
-, rowGap(other.rowGap)
-, cols(other.cols)
-, colGap(other.colGap)
-, selected(other.selected)
-, topRow(other.topRow) {
- std::cout << "copied Menu" << std::endl;
-}
-
template<class T>
int Menu<T>::Width() const {
template<class T>
void Menu<T>::SelectIndex(int index) {
- if (index < 0 || int(entries.size()) < index) return;
- std::cout << "selecting index " << index << std::endl;
+ if (index < 0 || int(entries.size()) <= index) return;
selected = index;
- if (GetRow(selected) - rows > topRow) {
- topRow = GetRow(selected) - rows;
+ if (topRow <= GetRow(selected) - rows) {
+ topRow = GetRow(selected) - rows + 1;
} else if (GetRow(selected) < topRow) {
topRow = GetRow(selected);
}
template<class T>
void Menu<T>::Draw(SDL_Surface *dest, geometry::Point<int> position) const {
int start(topRow * cols);
- int slots((topRow + rows) * cols);
+ int slots(rows * cols);
int items(entries.size() - start);
- int end(items < slots ? items : slots);
+ int end(start + (items < slots ? items : slots));
for (int i(0), count(end - start); i < count; ++i) {
geometry::Vector<int> offset(
(i % cols) * (ColWidth() + colGap),
}
geometry::Vector<int> cursorOffset(
(selected % cols) * (ColWidth() + colGap) - cursor->Width(),
- (selected / cols) * RowHeight());
+ ((selected - start) / cols) * RowHeight());
cursor->Draw(dest, position + cursorOffset);
}