Implemented the final dialog for Generate Class which shows the class that was chosen by the game based on the players chosen questions. The class is currently hardcoded to Acrobat.

This commit is contained in:
Jan Borsodi 2010-10-10 01:52:08 +02:00
parent b364d47b0b
commit 232164bfb0
6 changed files with 169 additions and 9 deletions

View file

@ -12,6 +12,60 @@
using namespace MWGui;
/* GenerateClassResultDialog */
GenerateClassResultDialog::GenerateClassResultDialog(MWWorld::Environment& environment)
: Layout("openmw_chargen_generate_class_result_layout.xml")
, environment(environment)
{
// Centre dialog
MyGUI::IntSize gameWindowSize = environment.mWindowManager->getGui()->getViewSize();
MyGUI::IntCoord coord = mMainWidget->getCoord();
coord.left = (gameWindowSize.width - coord.width)/2;
coord.top = (gameWindowSize.height - coord.height)/2;
mMainWidget->setCoord(coord);
WindowManager *wm = environment.mWindowManager;
setText("ReflectT", wm->getGameSettingString("sMessageQuestionAnswer1", ""));
getWidget(classImage, "ClassImage");
getWidget(className, "ClassName");
// TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr backButton;
getWidget(backButton, "BackButton");
backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &GenerateClassResultDialog::onBackClicked);
MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &GenerateClassResultDialog::onOkClicked);
}
std::string GenerateClassResultDialog::getClassId() const
{
return className->getCaption();
}
void GenerateClassResultDialog::setClassId(const std::string &classId)
{
currentClassId = classId;
classImage->setImageTexture(std::string("textures\\levelup\\") + currentClassId + ".dds");
ESMS::ESMStore &store = environment.mWorld->getStore();
className->setCaption(store.classes.find(currentClassId)->name);
}
// widget controls
void GenerateClassResultDialog::onOkClicked(MyGUI::Widget* _sender)
{
eventDone();
}
void GenerateClassResultDialog::onBackClicked(MyGUI::Widget* _sender)
{
eventBack();
}
/* PickClassDialog */
PickClassDialog::PickClassDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize)

View file

@ -75,6 +75,40 @@ namespace MWGui
ClassChoiceDialog(MWWorld::Environment& environment);
};
class GenerateClassResultDialog : public OEngine::GUI::Layout
{
public:
GenerateClassResultDialog(MWWorld::Environment& environment);
std::string getClassId() const;
void setClassId(const std::string &classId);
// Events
typedef delegates::CDelegate0 EventHandle_Void;
/** Event : Back button clicked.\n
signature : void method()\n
*/
EventHandle_Void eventBack;
/** Event : Dialog finished, OK button clicked.\n
signature : void method()\n
*/
EventHandle_Void eventDone;
protected:
void onOkClicked(MyGUI::Widget* _sender);
void onBackClicked(MyGUI::Widget* _sender);
private:
MWWorld::Environment& environment;
MyGUI::StaticImagePtr classImage;
MyGUI::StaticTextPtr className;
std::string currentClassId;
};
class PickClassDialog : public OEngine::GUI::Layout
{
public:

View file

@ -23,6 +23,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
, raceDialog(nullptr)
, classChoiceDialog(nullptr)
, generateClassQuestionDialog(nullptr)
, generateClassResultDialog(nullptr)
, pickClassDialog(nullptr)
, birthSignDialog(nullptr)
, nameChosen(false)
@ -71,6 +72,7 @@ WindowManager::~WindowManager()
delete raceDialog;
delete classChoiceDialog;
delete generateClassQuestionDialog;
delete generateClassResultDialog;
delete pickClassDialog;
delete birthSignDialog;
}
@ -369,9 +371,6 @@ void WindowManager::onClassChoice(MyGUI::WidgetPtr, int _index)
void WindowManager::showClassQuestionDialog()
{
if (!generateClassQuestionDialog)
generateClassQuestionDialog = new InfoBoxDialog(environment);
struct Step
{
const char* text;
@ -390,17 +389,29 @@ void WindowManager::showClassQuestionDialog()
},
} };
if (generateClassStep == steps.size())
{
// TODO: Calculate this in mechanics manager
generateClass = "acrobat";
if (generateClassResultDialog)
delete generateClassResultDialog;
generateClassResultDialog = new GenerateClassResultDialog(environment);
generateClassResultDialog->setClassId(generateClass);
generateClassResultDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onGenerateClassBack);
generateClassResultDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onGenerateClassDone);
generateClassResultDialog->setVisible(true);
return;
}
if (generateClassStep > steps.size())
{
environment.mInputManager->setGuiMode(GM_Class);
return;
}
if (generateClassStep == steps.size())
{
// TODO: Show selected class
environment.mInputManager->setGuiMode(GM_Review);
return;
}
if (!generateClassQuestionDialog)
generateClassQuestionDialog = new InfoBoxDialog(environment);
InfoBoxDialog::ButtonList buttons;
generateClassQuestionDialog->setText(steps[generateClassStep].text);
@ -426,6 +437,33 @@ void WindowManager::onClassQuestionChosen(MyGUI::Widget* _sender, int _index)
showClassQuestionDialog();
}
void WindowManager::onGenerateClassBack()
{
if (generateClassResultDialog)
{
generateClassResultDialog->setVisible(false);
}
environment.mMechanicsManager->setPlayerClass(generateClass);
updateCharacterGeneration();
environment.mInputManager->setGuiMode(GM_Class);
}
void WindowManager::onGenerateClassDone()
{
if (generateClassResultDialog)
{
generateClassResultDialog->setVisible(false);
}
environment.mMechanicsManager->setPlayerClass(generateClass);
updateCharacterGeneration();
environment.mInputManager->setGuiMode(GM_Review);
}
void WindowManager::onPickClassDialogDone()
{
pickClassDialog->eventDone = MWGui::PickClassDialog::EventHandle_Void();

View file

@ -46,6 +46,7 @@ namespace MWGui
class InfoBoxDialog;
class RaceDialog;
class ClassChoiceDialog;
class GenerateClassResultDialog;
class PickClassDialog;
class BirthDialog;
@ -66,6 +67,7 @@ namespace MWGui
RaceDialog *raceDialog;
ClassChoiceDialog *classChoiceDialog;
InfoBoxDialog *generateClassQuestionDialog;
GenerateClassResultDialog *generateClassResultDialog;
PickClassDialog *pickClassDialog;
BirthDialog *birthSignDialog;
@ -79,6 +81,7 @@ namespace MWGui
// Keeps track of current step in Generate Class dialogs
unsigned generateClassStep;
std::string generateClass;
MyGUI::Gui *gui;
@ -203,6 +206,8 @@ namespace MWGui
// Character generation: Generate Class
void showClassQuestionDialog();
void onClassQuestionChosen(MyGUI::Widget* _sender, int _index);
void onGenerateClassBack();
void onGenerateClassDone();
// Character generation: Pick Class dialog
void onPickClassDialogDone();

View file

@ -45,6 +45,7 @@ configure_file("${SDIR}/openmw_text_input_layout.xml" "${DDIR}/openmw_text_input
configure_file("${SDIR}/openmw_infobox_layout.xml" "${DDIR}/openmw_infobox_layout.xml" COPYONLY)
configure_file("${SDIR}/openmw_chargen_race_layout.xml" "${DDIR}/openmw_chargen_race_layout.xml" COPYONLY)
configure_file("${SDIR}/openmw_chargen_class_layout.xml" "${DDIR}/openmw_chargen_class_layout.xml" COPYONLY)
configure_file("${SDIR}/openmw_chargen_generate_class_result_layout.xml" "${DDIR}/openmw_chargen_generate_class_result_layout.xml" COPYONLY)
configure_file("${SDIR}/openmw_chargen_create_class_layout.xml" "${DDIR}/openmw_chargen_create_class_layout.xml" COPYONLY)
configure_file("${SDIR}/openmw_chargen_select_specialization_layout.xml" "${DDIR}/openmw_chargen_select_specialization_layout.xml" COPYONLY)
configure_file("${SDIR}/openmw_chargen_select_attribute_layout.xml" "${DDIR}/openmw_chargen_select_attribute_layout.xml" COPYONLY)

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 330 217" name="_Main">
<!-- Class image -->
<Widget type="Widget" skin="MW_Box" position="32 10 265 138" align="ALIGN_LEFT ALIGN_TOP">
<Widget type="StaticImage" skin="StaticImage" position="2 2 261 134" name="ClassImage" align="ALIGN_LEFT ALIGN_TOP" />
</Widget>
<!-- Class text -->
<Widget type="StaticText" skin="SandText" position="32 152 265 18" name="ReflectT" align="ALIGN_LEFT ALIGN_TOP">
<Property key="Widget_Caption" value="Your personality and past reflect a:"/>
<Property key="Widget_AlignText" value="ALIGN_TOP ALIGN_HCENTER"/>
</Widget>
<Widget type="StaticText" skin="SandText" position="32 170 265 18" name="ClassName" align="ALIGN_LEFT ALIGN_TOP">
<Property key="Widget_Caption" value="[Class]"/>
<Property key="Widget_AlignText" value="ALIGN_TOP ALIGN_HCENTER"/>
</Widget>
<!-- Dialog buttons -->
<Widget type="Button" skin="MW_Button" position="220 184 53 23" name="BackButton">
<Property key="Widget_Caption" value="Back"/>
</Widget>
<Widget type="Button" skin="MW_Button" position="277 184 42 23" name="OKButton">
<Property key="Widget_Caption" value="OK"/>
</Widget>
</Widget>
</MyGUI>