2010-09-12 14:06:10 +02:00
|
|
|
#include "mw_chargen.hpp"
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <iostream>
|
|
|
|
#include <iterator>
|
|
|
|
|
|
|
|
using namespace MWGui;
|
|
|
|
|
|
|
|
RaceDialog::RaceDialog()
|
|
|
|
: Layout("openmw_chargen_race_layout.xml")
|
2010-09-12 14:14:54 +02:00
|
|
|
, genderIndex(0)
|
2010-09-12 14:06:10 +02:00
|
|
|
, faceIndex(0)
|
|
|
|
, hairIndex(0)
|
|
|
|
, faceCount(10)
|
|
|
|
, hairCount(14)
|
|
|
|
{
|
|
|
|
mMainWidget->setCoord(mMainWidget->getCoord() + MyGUI::IntPoint(0, 100));
|
|
|
|
|
|
|
|
// These are just demo values, you should replace these with
|
|
|
|
// real calls from outside the class later.
|
|
|
|
|
|
|
|
setText("AppearanceT", "Appearance");
|
|
|
|
getWidget(appearanceBox, "AppearanceBox");
|
|
|
|
|
|
|
|
getWidget(headRotate, "HeadRotate");
|
|
|
|
headRotate->setScrollRange(50);
|
|
|
|
headRotate->setScrollPosition(20);
|
|
|
|
headRotate->setScrollViewPage(10);
|
|
|
|
headRotate->eventScrollChangePosition = MyGUI::newDelegate(this, &RaceDialog::onHeadRotate);
|
|
|
|
|
|
|
|
// Set up next/previous buttons
|
|
|
|
MyGUI::ButtonPtr prevButton, nextButton;
|
|
|
|
|
2010-09-12 14:14:54 +02:00
|
|
|
getWidget(prevButton, "PrevGenderButton");
|
|
|
|
getWidget(nextButton, "NextGenderButton");
|
|
|
|
prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousGender);
|
|
|
|
nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextGender);
|
2010-09-12 14:06:10 +02:00
|
|
|
|
|
|
|
getWidget(prevButton, "PrevFaceButton");
|
|
|
|
getWidget(nextButton, "NextFaceButton");
|
|
|
|
prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousFace);
|
|
|
|
nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextFace);
|
|
|
|
|
|
|
|
getWidget(prevButton, "PrevHairButton");
|
|
|
|
getWidget(nextButton, "NextHairButton");
|
|
|
|
prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousHair);
|
|
|
|
nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextHair);
|
|
|
|
|
|
|
|
setText("RaceT", "Race");
|
|
|
|
getWidget(raceList, "RaceList");
|
|
|
|
raceList->setScrollVisible(true);
|
|
|
|
raceList->eventListSelectAccept = MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
|
|
|
|
raceList->eventListMouseItemActivate = MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
|
|
|
|
|
|
|
|
getWidget(skillList, "SkillList");
|
2010-09-12 14:14:54 +02:00
|
|
|
getWidget(spellPowerList, "SpellPowerList");
|
2010-09-12 14:06:10 +02:00
|
|
|
|
|
|
|
updateRaces();
|
|
|
|
updateSkills();
|
2010-09-12 14:14:54 +02:00
|
|
|
updateSpellPowers();
|
2010-09-12 14:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int wrap(int index, int max)
|
|
|
|
{
|
|
|
|
if (index < 0)
|
|
|
|
return max - 1;
|
|
|
|
else if (index >= max)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
// widget controls
|
|
|
|
|
|
|
|
void RaceDialog::onHeadRotate(MyGUI::VScroll*, size_t _position)
|
|
|
|
{
|
|
|
|
// TODO: Rotate head
|
|
|
|
}
|
|
|
|
|
2010-09-12 14:14:54 +02:00
|
|
|
void RaceDialog::onSelectPreviousGender(MyGUI::Widget*)
|
2010-09-12 14:06:10 +02:00
|
|
|
{
|
2010-09-13 21:21:21 +02:00
|
|
|
genderIndex = wrap(genderIndex - 1, 2);
|
2010-09-12 14:06:10 +02:00
|
|
|
}
|
|
|
|
|
2010-09-12 14:14:54 +02:00
|
|
|
void RaceDialog::onSelectNextGender(MyGUI::Widget*)
|
2010-09-12 14:06:10 +02:00
|
|
|
{
|
2010-09-13 21:21:21 +02:00
|
|
|
genderIndex = wrap(genderIndex + 1, 2);
|
2010-09-12 14:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void RaceDialog::onSelectPreviousFace(MyGUI::Widget*)
|
|
|
|
{
|
2010-09-13 21:21:21 +02:00
|
|
|
faceIndex = wrap(faceIndex - 1, faceCount);
|
2010-09-12 14:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void RaceDialog::onSelectNextFace(MyGUI::Widget*)
|
|
|
|
{
|
2010-09-13 21:21:21 +02:00
|
|
|
faceIndex = wrap(faceIndex + 1, faceCount);
|
2010-09-12 14:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void RaceDialog::onSelectPreviousHair(MyGUI::Widget*)
|
|
|
|
{
|
2010-09-13 21:21:21 +02:00
|
|
|
hairIndex = wrap(hairIndex - 1, hairCount);
|
2010-09-12 14:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void RaceDialog::onSelectNextHair(MyGUI::Widget*)
|
|
|
|
{
|
2010-09-13 21:21:21 +02:00
|
|
|
hairIndex = wrap(hairIndex - 1, hairCount);
|
2010-09-12 14:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void RaceDialog::onSelectRace(MyGUI::List* _sender, size_t _index)
|
|
|
|
{
|
|
|
|
// TODO: Select actual race
|
|
|
|
updateSkills();
|
2010-09-12 14:14:54 +02:00
|
|
|
updateSpellPowers();
|
2010-09-12 14:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// update widget content
|
|
|
|
|
|
|
|
void RaceDialog::updateRaces()
|
|
|
|
{
|
|
|
|
raceList->removeAllItems();
|
|
|
|
raceList->addItem("Argonian");
|
|
|
|
raceList->addItem("Breton");
|
|
|
|
raceList->addItem("Dark Elf");
|
|
|
|
raceList->addItem("High Elf");
|
|
|
|
raceList->addItem("Imperial");
|
|
|
|
raceList->addItem("Khajiit");
|
|
|
|
raceList->addItem("Nord");
|
|
|
|
raceList->addItem("Orc");
|
|
|
|
}
|
|
|
|
|
|
|
|
void RaceDialog::updateSkills()
|
|
|
|
{
|
|
|
|
for (std::vector<MyGUI::WidgetPtr>::iterator it = skillItems.begin(); it != skillItems.end(); ++it)
|
|
|
|
{
|
|
|
|
MyGUI::Gui::getInstance().destroyWidget(*it);
|
|
|
|
}
|
|
|
|
skillItems.clear();
|
|
|
|
|
2010-09-12 14:14:54 +02:00
|
|
|
MyGUI::StaticTextPtr skillName, skillBonus;
|
2010-09-12 14:06:10 +02:00
|
|
|
const int lineHeight = 18;
|
|
|
|
MyGUI::IntCoord coord1(0, 0, skillList->getWidth() - (40 + 4), 18);
|
|
|
|
MyGUI::IntCoord coord2(coord1.left + coord1.width, 0, 40, 18);
|
|
|
|
|
|
|
|
const char *inputList[][2] = {
|
|
|
|
{"Athletics", "5"},
|
|
|
|
{"Destruction", "10"},
|
|
|
|
{"Light Armor", "5"},
|
|
|
|
{"Long Blade", "5"},
|
|
|
|
{"Marksman", "5"},
|
|
|
|
{"Mysticism", "5"},
|
|
|
|
{"Short Blade", "10"},
|
|
|
|
{0,0}
|
|
|
|
};
|
|
|
|
|
|
|
|
for (int i = 0; inputList[i][0]; ++i)
|
|
|
|
{
|
2010-09-12 14:28:17 +02:00
|
|
|
std::ostringstream name;
|
|
|
|
name << std::string("SkillName") << i;
|
|
|
|
skillName = skillList->createWidget<MyGUI::StaticText>("SandText", coord1, MyGUI::Align::Default, name.str());
|
2010-09-12 14:06:10 +02:00
|
|
|
skillName->setCaption(inputList[i][0]);
|
2010-09-12 14:28:17 +02:00
|
|
|
std::ostringstream bonus;
|
|
|
|
bonus << std::string("SkillBonus") << i;
|
|
|
|
skillBonus = skillList->createWidget<MyGUI::StaticText>("SandTextRight", coord2, MyGUI::Align::Default, bonus.str());
|
2010-09-12 14:14:54 +02:00
|
|
|
skillBonus->setCaption(inputList[i][1]);
|
2010-09-12 14:06:10 +02:00
|
|
|
|
|
|
|
skillItems.push_back(skillName);
|
2010-09-12 14:14:54 +02:00
|
|
|
skillItems.push_back(skillBonus);
|
2010-09-12 14:06:10 +02:00
|
|
|
|
|
|
|
coord1.top += lineHeight;
|
|
|
|
coord2.top += lineHeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-12 14:14:54 +02:00
|
|
|
void RaceDialog::updateSpellPowers()
|
2010-09-12 14:06:10 +02:00
|
|
|
{
|
2010-09-12 14:14:54 +02:00
|
|
|
for (std::vector<MyGUI::WidgetPtr>::iterator it = spellPowerItems.begin(); it != spellPowerItems.end(); ++it)
|
2010-09-12 14:06:10 +02:00
|
|
|
{
|
|
|
|
MyGUI::Gui::getInstance().destroyWidget(*it);
|
|
|
|
}
|
2010-09-12 14:14:54 +02:00
|
|
|
spellPowerItems.clear();
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2010-09-12 14:14:54 +02:00
|
|
|
MyGUI::StaticTextPtr spellPowerName;
|
2010-09-12 14:06:10 +02:00
|
|
|
const int lineHeight = 18;
|
2010-09-12 14:14:54 +02:00
|
|
|
MyGUI::IntCoord coord(0, 0, spellPowerList->getWidth(), 18);
|
2010-09-12 14:06:10 +02:00
|
|
|
|
|
|
|
const char *inputList[] = {
|
|
|
|
"Depth Perception",
|
|
|
|
"Resist Fire",
|
|
|
|
"Ancestor Guardian",
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
for (int i = 0; inputList[i]; ++i)
|
|
|
|
{
|
2010-09-12 14:28:17 +02:00
|
|
|
std::ostringstream name;
|
|
|
|
name << std::string("SpellPowerName") << i;
|
|
|
|
spellPowerName = spellPowerList->createWidget<MyGUI::StaticText>("SandText", coord, MyGUI::Align::Default, name.str());
|
2010-09-12 14:14:54 +02:00
|
|
|
spellPowerName->setCaption(inputList[i]);
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2010-09-12 14:14:54 +02:00
|
|
|
spellPowerItems.push_back(spellPowerName);
|
2010-09-12 14:06:10 +02:00
|
|
|
|
|
|
|
coord.top += lineHeight;
|
|
|
|
}
|
|
|
|
}
|