diff --git a/CMakeLists.txt b/CMakeLists.txt index 67fc2dbfe..74a43ede1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,7 +177,6 @@ include_directories(${UUID_INCLUDE_DIR}) endif (WIN32) if (MSVC10) set(PLATFORM_INCLUDE_DIR "") - add_definitions(-DMYGUI_DONT_REPLACE_NULLPTR) endif() if (APPLE) @@ -186,7 +185,13 @@ endif (APPLE) # Dependencies +# Fix for not visible pthreads functions for linker with glibc 2.15 +if (UNIX AND NOT APPLE) +find_package (Threads) +endif() + find_package(OGRE REQUIRED) +find_package(MyGUI REQUIRED) find_package(Boost REQUIRED COMPONENTS system filesystem program_options thread) find_package(OIS REQUIRED) find_package(OpenAL REQUIRED) @@ -203,14 +208,14 @@ include_directories("." ${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre ${OGRE_INCLUDE_DIR}/OGRE ${OGRE_PLUGIN_INCLUDE_DIRS} ${OIS_INCLUDE_DIRS} ${Boost_INCLUDE_DIR} ${PLATFORM_INCLUDE_DIR} - ${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/MyGUIEngine/include - ${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/OgrePlatform/include + ${MYGUI_INCLUDE_DIRS} + ${MYGUI_PLATFORM_INCLUDE_DIRS} ${OPENAL_INCLUDE_DIR} ${UUID_INCLUDE_DIR} ${LIBDIR} ) -link_directories(${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR}) +link_directories(${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR} ${MYGUI_LIB_DIR}) if(APPLE) # List used Ogre plugins @@ -220,15 +225,8 @@ if(APPLE) "Plugin_ParticleFX") endif(APPLE) -add_subdirectory( extern/mygui_3.0.1 ) add_subdirectory( files/) - -# Make sure that certain libraries are used as static libraries -# This is in effect turns off __declspec (dllexport) for windows -# Each library will also need to be configured to build as a static lib - -# MyGUI: extern/mygui_3.0.0/ -add_definitions(-DMYGUI_STATIC) +add_subdirectory( files/mygui ) # Specify build paths @@ -323,7 +321,7 @@ if(DPKG_PROGRAM) SET(CPACK_DEBIAN_PACKAGE_NAME "openmw") SET(CPACK_DEBIAN_PACKAGE_VERSION "${VERSION_STRING}") SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW esmtool;Esmtool omwlauncher;OMWLauncher") - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libogre-1.7.3 (>= 1.7.3), libbullet0 (>= 2.77), libboost-filesystem1.46.1 (>= 1.46.1), libboost-program-options1.46.1 (>= 1.46.1), libboost-system1.46.1 (>= 1.46.1), libboost-thread1.46.1 (>= 1.46.1), libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libois-1.3.0 (>= 1.3.0), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2), libqtgui4 (>= 4.7.0)") + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "nvidia-cg-toolkit (>= 2.1), libboost-filesystem1.46.1 (>= 1.46.1), libboost-program-options1.46.1 (>= 1.46.1), libboost-system1.46.1 (>= 1.46.1), libboost-thread1.46.1 (>= 1.46.1), libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libois-1.3.0 (>= 1.3.0), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2), libqtgui4 (>= 4.7.0)") SET(CPACK_DEBIAN_PACKAGE_SECTION "Games") @@ -459,7 +457,9 @@ if (WIN32) endforeach(d) set_target_properties(components PROPERTIES COMPILE_FLAGS ${WARNINGS}) - set_target_properties(omwlauncher PROPERTIES COMPILE_FLAGS ${WARNINGS}) + if (BUILD_LAUNCHER) + set_target_properties(omwlauncher PROPERTIES COMPILE_FLAGS ${WARNINGS}) + endif (BUILD_LAUNCHER) set_target_properties(openmw PROPERTIES COMPILE_FLAGS ${WARNINGS}) endif(MSVC) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 054cbf141..c96fc2c7b 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -222,7 +222,7 @@ void DataFilesPage::setupDataFiles() QMessageBox msgBox; msgBox.setWindowTitle("Error detecting Morrowind installation"); - msgBox.setIcon(QMessageBox::Critical); + msgBox.setIcon(QMessageBox::Warning); msgBox.setStandardButtons(QMessageBox::Cancel); msgBox.setText(tr("
Could not find the Data Files location

\ The directory containing the Data Files was not found.

\ @@ -279,72 +279,79 @@ void DataFilesPage::setupDataFiles() const Files::MultiDirCollection &esp = fileCollections.getCollection(".esp"); for (Files::MultiDirCollection::TIter iter(esp.begin()); iter!=esp.end(); ++iter) { - ESMReader fileReader; - QStringList availableMasters; // Will contain all found masters - fileReader.setEncoding(variables["encoding"].as()); - fileReader.open(iter->second.string()); + try { + ESMReader fileReader; + QStringList availableMasters; // Will contain all found masters + + fileReader.setEncoding(variables["encoding"].as()); + fileReader.open(iter->second.string()); - // First we fill the availableMasters and the mMastersWidget - ESMReader::MasterList mlist = fileReader.getMasters(); + // First we fill the availableMasters and the mMastersWidget + ESMReader::MasterList mlist = fileReader.getMasters(); - for (unsigned int i = 0; i < mlist.size(); ++i) { - const QString currentMaster = QString::fromStdString(mlist[i].name); - availableMasters.append(currentMaster); + for (unsigned int i = 0; i < mlist.size(); ++i) { + const QString currentMaster = QString::fromStdString(mlist[i].name); + availableMasters.append(currentMaster); - const QList itemList = mMastersWidget->findItems(currentMaster, Qt::MatchExactly); + const QList itemList = mMastersWidget->findItems(currentMaster, Qt::MatchExactly); - if (itemList.isEmpty()) { // Master is not yet in the widget - mMastersWidget->insertRow(i); + if (itemList.isEmpty()) { // Master is not yet in the widget + mMastersWidget->insertRow(i); - QTableWidgetItem *item = new QTableWidgetItem(currentMaster); - item->setForeground(Qt::red); - item->setFlags(item->flags() & ~(Qt::ItemIsSelectable)); + QTableWidgetItem *item = new QTableWidgetItem(currentMaster); + item->setForeground(Qt::red); + item->setFlags(item->flags() & ~(Qt::ItemIsSelectable)); - mMastersWidget->setItem(i, 0, item); + mMastersWidget->setItem(i, 0, item); + } } - } - availableMasters.sort(); // Sort the masters alphabetically + availableMasters.sort(); // Sort the masters alphabetically - // Now we put the current plugin in the mDataFilesModel under its masters - QStandardItem *parent = new QStandardItem(availableMasters.join(",")); + // Now we put the current plugin in the mDataFilesModel under its masters + QStandardItem *parent = new QStandardItem(availableMasters.join(",")); - QString fileName = QString::fromStdString(boost::filesystem::path (iter->second.filename()).string()); - QStandardItem *child = new QStandardItem(fileName); + QString fileName = QString::fromStdString(boost::filesystem::path (iter->second.filename()).string()); + QStandardItem *child = new QStandardItem(fileName); - // Tooltip information - QString author = QString::fromStdString(fileReader.getAuthor()); - float version = fileReader.getFVer(); - QString description = QString::fromStdString(fileReader.getDesc()); + // Tooltip information + QString author = QString::fromStdString(fileReader.getAuthor()); + float version = fileReader.getFVer(); + QString description = QString::fromStdString(fileReader.getDesc()); - // For the date created/modified - QFileInfo fi(QString::fromStdString(iter->second.string())); + // For the date created/modified + QFileInfo fi(QString::fromStdString(iter->second.string())); - QString toolTip= QString("Author: %1
\ - Version: %2

\ - Description:
\ - %3

\ - Created on: %4
\ - Last modified: %5") - .arg(author) - .arg(version) - .arg(description) - .arg(fi.created().toString(Qt::TextDate)) - .arg(fi.lastModified().toString(Qt::TextDate)); + QString toolTip= QString("Author: %1
\ + Version: %2

\ + Description:
\ + %3

\ + Created on: %4
\ + Last modified: %5") + .arg(author) + .arg(version) + .arg(description) + .arg(fi.created().toString(Qt::TextDate)) + .arg(fi.lastModified().toString(Qt::TextDate)); - child->setToolTip(toolTip); + child->setToolTip(toolTip); - const QList masterList = mDataFilesModel->findItems(availableMasters.join(",")); + const QList masterList = mDataFilesModel->findItems(availableMasters.join(",")); - if (masterList.isEmpty()) { // Masters node not yet in the mDataFilesModel - parent->appendRow(child); - mDataFilesModel->appendRow(parent); - } else { - // Masters node exists, append current plugin - foreach (QStandardItem *currentItem, masterList) { - currentItem->appendRow(child); + if (masterList.isEmpty()) { // Masters node not yet in the mDataFilesModel + parent->appendRow(child); + mDataFilesModel->appendRow(parent); + } else { + // Masters node exists, append current plugin + foreach (QStandardItem *currentItem, masterList) { + currentItem->appendRow(child); + } } + + } catch(std::runtime_error &e) { + // An error occurred while reading the .esp + continue; } } diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index f416b996d..365600061 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -48,7 +48,7 @@ add_openmw_dir (mwsound add_openmw_dir (mwworld refdata world physicssystem scene environment globals class action nullaction actionteleport containerstore actiontalk actiontake manualref player cellfunctors - cells localscripts customdata weather inventorystore + cells localscripts customdata weather inventorystore ptr ) add_openmw_dir (mwclass @@ -85,17 +85,22 @@ add_definitions(${SOUND_DEFINE}) target_link_libraries(openmw ${OGRE_LIBRARIES} - ${OGRE_STATIC_PLUGINS} + ${OGRE_STATIC_PLUGINS} ${OIS_LIBRARIES} ${Boost_LIBRARIES} ${OPENAL_LIBRARY} ${SOUND_INPUT_LIBRARY} ${BULLET_LIBRARIES} + ${MYGUI_LIBRARIES} + MyGUI.OgrePlatform #TODO MyGUI ogre platform is not added by the find script components - MyGUIEngine - MyGUIOgrePlatform ) +# Fix for not visible pthreads functions for linker with glibc 2.15 +if (UNIX AND NOT APPLE) +target_link_libraries(openmw ${CMAKE_THREAD_LIBS_INIT}) +endif() + if(APPLE) find_library(CARBON_FRAMEWORK Carbon) target_link_libraries(openmw ${CARBON_FRAMEWORK}) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 7f6dccf1f..433cc0c11 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -60,7 +60,7 @@ void OMW::Engine::executeLocalScripts() MWScript::InterpreterContext interpreterContext (mEnvironment, &script.second.getRefData().getLocals(), script.second); - mScriptManager->run (script.first, interpreterContext); + mEnvironment.mScriptManager->run (script.first, interpreterContext); if (mEnvironment.mWorld->hasCellChanged()) break; @@ -182,7 +182,6 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) , mCompileAll (false) , mReportFocus (false) , mFocusTDiff (0) - , mScriptManager (0) , mScriptContext (0) , mFSStrict (false) , mCfgMgr(configurationManager) @@ -199,7 +198,7 @@ OMW::Engine::~Engine() delete mEnvironment.mMechanicsManager; delete mEnvironment.mDialogueManager; delete mEnvironment.mJournal; - delete mScriptManager; + delete mEnvironment.mScriptManager; delete mScriptContext; delete mOgre; } @@ -352,18 +351,18 @@ void OMW::Engine::go() mEnvironment); mScriptContext->setExtensions (&mExtensions); - mScriptManager = new MWScript::ScriptManager (mEnvironment.mWorld->getStore(), mVerboseScripts, - *mScriptContext); + mEnvironment.mScriptManager = new MWScript::ScriptManager (mEnvironment.mWorld->getStore(), + mVerboseScripts, *mScriptContext); mEnvironment.mGlobalScripts = new MWScript::GlobalScripts (mEnvironment.mWorld->getStore(), - *mScriptManager); + *mEnvironment.mScriptManager); // Create game mechanics system mEnvironment.mMechanicsManager = new MWMechanics::MechanicsManager (mEnvironment); // Create dialog system mEnvironment.mJournal = new MWDialogue::Journal (mEnvironment); - mEnvironment.mDialogueManager = new MWDialogue::DialogueManager (mEnvironment); + mEnvironment.mDialogueManager = new MWDialogue::DialogueManager (mEnvironment,mExtensions); // load cell ESM::Position pos; @@ -397,7 +396,7 @@ void OMW::Engine::go() // scripts if (mCompileAll) { - std::pair result = mScriptManager->compileAll(); + std::pair result = mEnvironment.mScriptManager->compileAll(); if (result.first) std::cout @@ -442,7 +441,7 @@ void OMW::Engine::activate() if (!script.empty()) { mEnvironment.mWorld->getLocalScripts().setIgnore (ptr); - mScriptManager->run (script, interpreterContext); + mEnvironment.mScriptManager->run (script, interpreterContext); } if (!interpreterContext.hasActivationBeenHandled()) diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 5c5cdc018..690430784 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -78,10 +78,9 @@ namespace OMW std::string mFocusName; MWWorld::Environment mEnvironment; - MWScript::ScriptManager *mScriptManager; Compiler::Extensions mExtensions; Compiler::Context *mScriptContext; - + Files::Collections mFileCollections; bool mFSStrict; diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index f78160cd7..50549f4a5 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -9,16 +9,36 @@ #include + #include "../mwworld/class.hpp" #include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" #include "../mwworld/refdata.hpp" #include "../mwworld/player.hpp" +#include "../mwworld/containerstore.hpp" #include "../mwinput/inputmanager.hpp" +#include "../mwgui/dialogue.hpp" +#include "../mwgui/window_manager.hpp" + +#include "journal.hpp" #include +#include "../mwscript/extensions.hpp" +#include "../mwscript/scriptmanager.hpp" + +#include +#include +#include +#include +#include +#include + +#include "../mwscript/compilercontext.hpp" +#include "../mwscript/interpretercontext.hpp" +#include + namespace { std::string toLower (const std::string& name) @@ -31,17 +51,18 @@ namespace return lowerCase; } + template bool selectCompare (char comp, T1 value1, T2 value2) { switch (comp) { - case '0': return value1==value2; - case '1': return value1!=value2; - case '2': return value1>value2; - case '3': return value1>=value2; - case '4': return value1value2; + case '3': return value1>=value2; + case '4': return value1::const_iterator iter (info.selects.begin()); + iter != info.selects.end(); ++iter) + { + ESM::DialInfo::SelectStruct select = *iter; + char type = select.selectRule[1]; + if(type == '1') + { + char comp = select.selectRule[4]; + std::string name = select.selectRule.substr (5); + std::string function = select.selectRule.substr(2,2); + + int ifunction; + std::istringstream iss(function); + iss >> ifunction; + switch(ifunction) + { + case 39://PC Expelled + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 40://PC Common Disease + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 41://PC Blight Disease + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 43://PC Crime level + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 46://Same faction + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 48://Detected + if(!selectCompare(comp,1,select.i)) return false; + break; + + case 49://Alarmed + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 50://choice + + if(choice) + { + if(!selectCompare(comp,mChoice,select.i)) return false; + } + break; + + case 60://PC Vampire + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 61://Level + if(!selectCompare(comp,1,select.i)) return false; + break; + + case 62://Attacked + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 63://Talked to PC + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 64://PC Health + if(!selectCompare(comp,50,select.i)) return false; + break; + + case 65://Creature target + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 66://Friend hit + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 67://Fight + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 68://Hello???? + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 69://Alarm + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 70://Flee + if(!selectCompare(comp,0,select.i)) return false; + break; + + case 71://Should Attack + if(!selectCompare(comp,0,select.i)) return false; + break; + + default: + break; + + } + } + } + + return true; + } + bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo::SelectStruct& select) const { @@ -124,58 +264,173 @@ namespace MWDialogue { char comp = select.selectRule[4]; std::string name = select.selectRule.substr (5); - - // TODO types 4, 5, 6, 7, 8, 9, A, B, C + std::string function = select.selectRule.substr(1,2); switch (type) { - case '1': // function + case '1': // function - return false; // TODO implement functions + return true; // TODO implement functions - case '2': // global + case '2': // global - if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || - select.type==ESM::VT_Long) - { - if (!checkGlobal (comp, toLower (name), select.i, *mEnvironment.mWorld)) - return false; - } - else if (select.type==ESM::VT_Float) - { - if (!checkGlobal (comp, toLower (name), select.f, *mEnvironment.mWorld)) - return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); + if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || + select.type==ESM::VT_Long) + { + if (!checkGlobal (comp, toLower (name), select.i, *mEnvironment.mWorld)) + return false; + } + else if (select.type==ESM::VT_Float) + { + if (!checkGlobal (comp, toLower (name), select.f, *mEnvironment.mWorld)) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); - return true; + return true; - case '3': // local + case '3': // local - if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || - select.type==ESM::VT_Long) - { - if (!checkLocal (comp, toLower (name), select.i, actor, - mEnvironment.mWorld->getStore())) - return false; - } - else if (select.type==ESM::VT_Float) - { - if (!checkLocal (comp, toLower (name), select.f, actor, - mEnvironment.mWorld->getStore())) - return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); + if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || + select.type==ESM::VT_Long) + { + if (!checkLocal (comp, toLower (name), select.i, actor, + mEnvironment.mWorld->getStore())) + return false; + } + else if (select.type==ESM::VT_Float) + { + if (!checkLocal (comp, toLower (name), select.f, actor, + mEnvironment.mWorld->getStore())) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); - return true; + return true; - default: + case '4'://journal + if(select.type==ESM::VT_Int) + { + if(!selectCompare(comp,mEnvironment.mJournal->getJournalIndex(toLower(name)),select.i)) return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + + return true; + + case '5'://item + { + MWWorld::Ptr player = mEnvironment.mWorld->getPlayer().getPlayer(); + MWWorld::ContainerStore& store = MWWorld::Class::get (player).getContainerStore (player); + + int sum = 0; + + for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter) + if (iter->getCellRef().refID==name) + sum += iter->getRefData().getCount(); + if(!selectCompare(comp,sum,select.i)) return false; + } + + return true; + + + case '6'://dead + if(!selectCompare(comp,0,select.i)) return false; + + case '7':// not ID + if(select.type==ESM::VT_String ||select.type==ESM::VT_Int)//bug in morrowind here? it's not a short, it's a string + { + int isID = int(toLower(name)==toLower(MWWorld::Class::get (actor).getId (actor))); + if (selectCompare(comp,!isID,select.i)) return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + + return true; + + case '8':// not faction + if(select.type==ESM::VT_Int) + { + ESMS::LiveCellRef* npc = actor.get(); + int isFaction = int(toLower(npc->base->faction) == toLower(name)); + if(selectCompare(comp,!isFaction,select.i)) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + + return true; + + case '9':// not class + if(select.type==ESM::VT_Int) + { + ESMS::LiveCellRef* npc = actor.get(); + int isClass = int(toLower(npc->base->cls) == toLower(name)); + if(selectCompare(comp,!isClass,select.i)) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + + return true; + + case 'A'://not Race + if(select.type==ESM::VT_Int) + { + ESMS::LiveCellRef* npc = actor.get(); + int isRace = int(toLower(npc->base->race) == toLower(name)); + if(selectCompare(comp,!isRace,select.i)) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + + return true; - std::cout << "unchecked select: " << type << " " << comp << " " << name << std::endl; + case 'B'://not Cell + if(select.type==ESM::VT_Int) + { + int isCell = int(toLower(actor.getCell()->cell->name) == toLower(name)); + if(selectCompare(comp,!isCell,select.i)) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + return true; + + case 'C'://not local + if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || + select.type==ESM::VT_Long) + { + if (checkLocal (comp, toLower (name), select.i, actor, + mEnvironment.mWorld->getStore())) + return false; + } + else if (select.type==ESM::VT_Float) + { + if (checkLocal (comp, toLower (name), select.f, actor, + mEnvironment.mWorld->getStore())) + return false; + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + return true; + + + default: + + std::cout << "unchecked select: " << type << " " << comp << " " << name << std::endl; } } @@ -189,6 +444,10 @@ namespace MWDialogue if (toLower (info.actor)!=MWWorld::Class::get (actor).getId (actor)) return false; + //PC Faction + if(!info.pcFaction.empty()) return false; + + //NPC race if (!info.race.empty()) { ESMS::LiveCellRef *cellRef = actor.get(); @@ -200,6 +459,7 @@ namespace MWDialogue return false; } + //NPC class if (!info.clas.empty()) { ESMS::LiveCellRef *cellRef = actor.get(); @@ -211,6 +471,7 @@ namespace MWDialogue return false; } + //NPC faction if (!info.npcFaction.empty()) { ESMS::LiveCellRef *cellRef = actor.get(); @@ -220,66 +481,320 @@ namespace MWDialogue if (toLower (info.npcFaction)!=toLower (cellRef->base->faction)) return false; + + //check NPC rank + if(cellRef->base->npdt52.gold != -10) + { + if(cellRef->base->npdt52.rank < info.data.rank) return false; + } + else + { + if(cellRef->base->npdt12.rank < info.data.rank) return false; + } } // TODO check player faction + //check gender + ESMS::LiveCellRef* npc = actor.get(); + if(npc->base->flags&npc->base->Female) + { + if(static_cast (info.data.gender)==0) return false; + } + else + { + if(static_cast (info.data.gender)==1) return false; + } + + // check cell if (!info.cell.empty()) if (mEnvironment.mWorld->getPlayer().getPlayer().getCell()->cell->name != info.cell) return false; // TODO check DATAstruct - for (std::vector::const_iterator iter (info.selects.begin()); iter != info.selects.end(); ++iter) if (!isMatching (actor, *iter)) return false; - std::cout - << "unchecked entries:" << std::endl - << " player faction: " << info.pcFaction << std::endl - << " disposition: " << info.data.disposition << std::endl - << " NPC rank: " << static_cast (info.data.rank) << std::endl - << " gender: " << static_cast (info.data.gender) << std::endl - << " PC rank: " << static_cast (info.data.PCrank) << std::endl; - return true; } - DialogueManager::DialogueManager (MWWorld::Environment& environment) : mEnvironment (environment) {} + DialogueManager::DialogueManager (MWWorld::Environment& environment,const Compiler::Extensions& extensions) : + mEnvironment (environment),mCompilerContext (MWScript::CompilerContext::Type_Dialgoue, environment), + mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream) + { + mChoice = -1; + mIsInChoice = false; + mCompilerContext.setExtensions (&extensions); + } + + void DialogueManager::addTopic(std::string topic) + { + knownTopics[toLower(topic)] = true; + } + + void DialogueManager::parseText(std::string text) + { + std::list::iterator it; + for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++) + { + size_t pos = find_str_ci(text,*it,0); + if(pos !=std::string::npos) + { + if(pos==0) + { + knownTopics[*it] = true; + } + else if(text.substr(pos -1,1) == " ") + { + knownTopics[*it] = true; + } + } + } + updateTopics(); + } void DialogueManager::startDialogue (const MWWorld::Ptr& actor) { - std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl; + mChoice = -1; + mIsInChoice = false; - const ESM::Dialogue *dialogue = mEnvironment.mWorld->getStore().dialogs.find ("hello"); + mActor = actor; - for (std::vector::const_iterator iter (dialogue->mInfo.begin()); - iter!=dialogue->mInfo.end(); ++iter) + mDialogueMap.clear(); + actorKnownTopics.clear(); + ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { - if (isMatching (actor, *iter)) + mDialogueMap[it->first] = it->second; + } + + //initialise the GUI + mEnvironment.mInputManager->setGuiMode(MWGui::GM_Dialogue); + MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + win->startDialogue(MWWorld::Class::get (actor).getName (actor)); + + //setup the list of topics known by the actor. Topics who are also on the knownTopics list will be added to the GUI + updateTopics(); + + //greeting + bool greetingFound = false; + //ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + { + ESM::Dialogue ndialogue = it->second; + if(ndialogue.type == ESM::Dialogue::Greeting) { - // start dialogue - std::cout << "found matching info record" << std::endl; + if (greetingFound) break; + for (std::vector::const_iterator iter (it->second.mInfo.begin()); + iter!=it->second.mInfo.end(); ++iter) + { + if (isMatching (actor, *iter) && functionFilter(mActor,*iter,true)) + { + if (!iter->sound.empty()) + { + // TODO play sound + } + + std::string text = iter->response; + parseText(text); + win->addText(iter->response); + executeScript(iter->resultScript); + greetingFound = true; + mLastTopic = it->first; + mLastDialogue = *iter; + break; + } + } + } + } + } + + bool DialogueManager::compile (const std::string& cmd,std::vector& code) + { + try + { + mErrorHandler.reset(); + + std::istringstream input (cmd + "\n"); + + Compiler::Scanner scanner (mErrorHandler, input, mCompilerContext.getExtensions()); + + Compiler::Locals locals; + + std::string actorScript = MWWorld::Class::get (mActor).getScript (mActor); + + if (!actorScript.empty()) + { + // grab local variables from actor's script, if available. + locals = mEnvironment.mScriptManager->getLocals (actorScript); + } + + Compiler::ScriptParser parser(mErrorHandler,mCompilerContext, locals, false); + + scanner.scan (parser); + if(mErrorHandler.isGood()) + { + parser.getCode(code); + return true; + } + return false; + } + catch (const Compiler::SourceException& error) + { + // error has already been reported via error handler + } + catch (const std::exception& error) + { + printError (std::string ("An exception has been thrown: ") + error.what()); + } - std::cout << "response: " << iter->response << std::endl; + return false; + } - if (!iter->sound.empty()) + void DialogueManager::executeScript(std::string script) + { + std::vector code; + if(compile(script,code)) + { + try + { + MWScript::InterpreterContext interpreterContext(mEnvironment,&mActor.getRefData().getLocals(),mActor); + Interpreter::Interpreter interpreter; + MWScript::installOpcodes (interpreter); + interpreter.run (&code[0], code.size(), interpreterContext); + } + catch (const std::exception& error) + { + printError (std::string ("An exception has been thrown: ") + error.what()); + } + } + } + + void DialogueManager::updateTopics() + { + std::list keywordList; + int choice = mChoice; + mChoice = -1; + actorKnownTopics.clear(); + MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + { + ESM::Dialogue ndialogue = it->second; + if(ndialogue.type == ESM::Dialogue::Topic) + { + for (std::vector::const_iterator iter (it->second.mInfo.begin()); + iter!=it->second.mInfo.end(); ++iter) { - // TODO play sound + if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) + { + actorKnownTopics.push_back(it->first); + //does the player know the topic? + if(knownTopics.find(toLower(it->first)) != knownTopics.end()) + { + keywordList.push_back(it->first); + break; + } + } } + } + } + win->setKeywords(keywordList); + mChoice = choice; + } - if (!iter->resultScript.empty()) + void DialogueManager::keywordSelected(std::string keyword) + { + if(!mIsInChoice) + { + if(mDialogueMap.find(keyword) != mDialogueMap.end()) + { + ESM::Dialogue ndialogue = mDialogueMap[keyword]; + if(ndialogue.type == ESM::Dialogue::Topic) { - std::cout << "script: " << iter->resultScript << std::endl; - // TODO execute script + for (std::vector::const_iterator iter = ndialogue.mInfo.begin(); + iter!=ndialogue.mInfo.end(); ++iter) + { + if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) + { + std::string text = iter->response; + std::string script = iter->resultScript; + + parseText(text); + + MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + win->addTitle(keyword); + win->addText(iter->response); + + executeScript(script); + + mLastTopic = keyword; + mLastDialogue = *iter; + break; + } + } } + } + } - mEnvironment.mInputManager->setGuiMode(MWGui::GM_Dialogue); - break; + updateTopics(); + } + + void DialogueManager::goodbyeSelected() + { + mEnvironment.mInputManager->setGuiMode(MWGui::GM_Game); + } + + void DialogueManager::questionAnswered(std::string answere) + { + if(mChoiceMap.find(answere) != mChoiceMap.end()) + { + mChoice = mChoiceMap[answere]; + + std::vector::const_iterator iter; + if(mDialogueMap.find(mLastTopic) != mDialogueMap.end()) + { + ESM::Dialogue ndialogue = mDialogueMap[mLastTopic]; + if(ndialogue.type == ESM::Dialogue::Topic) + { + for (std::vector::const_iterator iter = ndialogue.mInfo.begin(); + iter!=ndialogue.mInfo.end(); ++iter) + { + if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) + { + mChoiceMap.clear(); + mChoice = -1; + mIsInChoice = false; + MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + std::string text = iter->response; + parseText(text); + win->addText(text); + executeScript(iter->resultScript); + mLastTopic = mLastTopic; + mLastDialogue = *iter; + break; + } + } + } } + updateTopics(); } } + void DialogueManager::printError(std::string error) + { + MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + win->addText(error); + } + + void DialogueManager::askQuestion(std::string question, int choice) + { + MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + win->askQuestion(question); + mChoiceMap[question] = choice; + mIsInChoice = true; + } } diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index 5b6b26240..260d8e339 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -3,7 +3,13 @@ #include +#include +#include "../mwscript/compilercontext.hpp" +#include "../mwscript/interpretercontext.hpp" +#include + #include "../mwworld/ptr.hpp" +#include namespace MWWorld { @@ -20,12 +26,48 @@ namespace MWDialogue bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const; + bool functionFilter(const MWWorld::Ptr& actor, const ESM::DialInfo& info,bool choice); + + void parseText(std::string text); + + void updateTopics(); + + std::map mDialogueMap; + std::map knownTopics;// Those are the topics the player knows. + std::list actorKnownTopics; + + MWScript::CompilerContext mCompilerContext; + std::ostream mErrorStream; + Compiler::StreamErrorHandler mErrorHandler; + + + bool compile (const std::string& cmd,std::vector& code); + void executeScript(std::string script); + MWWorld::Ptr mActor; + + void printError(std::string error); + + int mChoice; + std::map mChoiceMap; + std::string mLastTopic; + ESM::DialInfo mLastDialogue; + bool mIsInChoice; + public: - DialogueManager (MWWorld::Environment& environment); + DialogueManager (MWWorld::Environment& environment,const Compiler::Extensions& extensions); void startDialogue (const MWWorld::Ptr& actor); + void addTopic(std::string topic); + + void askQuestion(std::string question,int choice); + + //calbacks for the GUI + void keywordSelected(std::string keyword); + void goodbyeSelected(); + void questionAnswered(std::string answere); + }; } diff --git a/apps/openmw/mwdialogue/journal.cpp b/apps/openmw/mwdialogue/journal.cpp index 42cce5cf5..0715214eb 100644 --- a/apps/openmw/mwdialogue/journal.cpp +++ b/apps/openmw/mwdialogue/journal.cpp @@ -3,6 +3,9 @@ #include "../mwworld/environment.hpp" +#include "../mwgui/window_manager.hpp" +#include "../mwgui/messagebox.hpp" + namespace MWDialogue { Quest& Journal::getQuest (const std::string& id) @@ -34,6 +37,10 @@ namespace MWDialogue Quest& quest = getQuest (id); quest.addEntry (entry, *mEnvironment.mWorld); // we are doing slicing on purpose here + + std::vector empty; + std::string notification = "Your Journal has been updated."; + mEnvironment.mWindowManager->messageBox (notification, empty); } void Journal::setJournalIndex (const std::string& id, int index) @@ -60,7 +67,12 @@ namespace MWDialogue int Journal::getJournalIndex (const std::string& id) const { - return 0; + TQuestContainer::const_iterator iter = mQuests.find (id); + + if (iter==mQuests.end()) + return 0; + + return iter->second.getIndex(); } Journal::TEntryIter Journal::begin() const diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 93dde9f1b..e9c15fab4 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -21,18 +21,18 @@ BirthDialog::BirthDialog(WindowManager& parWindowManager) getWidget(birthList, "BirthsignList"); birthList->setScrollVisible(true); - birthList->eventListSelectAccept = MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); - birthList->eventListMouseItemActivate = MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); - birthList->eventListChangePosition = MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); + birthList->eventListSelectAccept += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); + birthList->eventListMouseItemActivate += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); + birthList->eventListChangePosition += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); - backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &BirthDialog::onBackClicked); + backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onBackClicked); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &BirthDialog::onOkClicked); + okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onOkClicked); updateBirths(); updateSpells(); @@ -100,7 +100,7 @@ void BirthDialog::onBackClicked(MyGUI::Widget* _sender) eventBack(); } -void BirthDialog::onSelectBirth(MyGUI::List* _sender, size_t _index) +void BirthDialog::onSelectBirth(MyGUI::ListBox* _sender, size_t _index) { if (_index == MyGUI::ITEM_NONE) return; @@ -188,7 +188,7 @@ void BirthDialog::updateSpells() { if (!categories[category].spells.empty()) { - MyGUI::StaticTextPtr label = spellArea->createWidget("SandBrightText", coord, MyGUI::Align::Default, std::string("Label")); + MyGUI::TextBox* label = spellArea->createWidget("SandBrightText", coord, MyGUI::Align::Default, std::string("Label")); label->setCaption(mWindowManager.getGameSettingString(categories[category].label, "")); spellItems.push_back(label); coord.top += lineHeight; diff --git a/apps/openmw/mwgui/birth.hpp b/apps/openmw/mwgui/birth.hpp index a55a774a5..b5f7db774 100644 --- a/apps/openmw/mwgui/birth.hpp +++ b/apps/openmw/mwgui/birth.hpp @@ -32,7 +32,7 @@ namespace MWGui void open(); // Events - typedef delegates::CDelegate0 EventHandle_Void; + typedef delegates::CMultiDelegate0 EventHandle_Void; /** Event : Back button clicked.\n signature : void method()\n @@ -40,7 +40,7 @@ namespace MWGui EventHandle_Void eventBack; protected: - void onSelectBirth(MyGUI::List* _sender, size_t _index); + void onSelectBirth(MyGUI::ListBox* _sender, size_t _index); void onOkClicked(MyGUI::Widget* _sender); void onBackClicked(MyGUI::Widget* _sender); @@ -49,9 +49,9 @@ namespace MWGui void updateBirths(); void updateSpells(); - MyGUI::ListPtr birthList; + MyGUI::ListBox* birthList; MyGUI::WidgetPtr spellArea; - MyGUI::StaticImagePtr birthImage; + MyGUI::ImageBox* birthImage; std::vector spellItems; std::string currentBirthId; diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index 1cb0593e7..ce5e744cc 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -121,7 +121,7 @@ void CharacterCreation::spawnDialog(const char id) mNameDialog->setTextLabel(mWM->getGameSettingString("sName", "Name")); mNameDialog->setTextInput(mPlayerName); mNameDialog->setNextButtonShow(mCreationStage >= CSE_NameChosen); - mNameDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onNameDialogDone); + mNameDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onNameDialogDone); mNameDialog->open(); break; @@ -131,8 +131,8 @@ void CharacterCreation::spawnDialog(const char id) mRaceDialog = new RaceDialog(*mWM); mRaceDialog->setNextButtonShow(mCreationStage >= CSE_RaceChosen); mRaceDialog->setRaceId(mPlayerRaceId); - mRaceDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogDone); - mRaceDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogBack); + mRaceDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogDone); + mRaceDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogBack); mRaceDialog->open(); break; @@ -140,7 +140,7 @@ void CharacterCreation::spawnDialog(const char id) if (mClassChoiceDialog) mWM->removeDialog(mClassChoiceDialog); mClassChoiceDialog = new ClassChoiceDialog(*mWM); - mClassChoiceDialog->eventButtonSelected = MyGUI::newDelegate(this, &CharacterCreation::onClassChoice); + mClassChoiceDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassChoice); mClassChoiceDialog->open(); break; @@ -150,8 +150,8 @@ void CharacterCreation::spawnDialog(const char id) mPickClassDialog = new PickClassDialog(*mWM); mPickClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen); mPickClassDialog->setClassId(mPlayerClass.name); - mPickClassDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogDone); - mPickClassDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogBack); + mPickClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogDone); + mPickClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogBack); mPickClassDialog->open(); break; @@ -161,8 +161,8 @@ void CharacterCreation::spawnDialog(const char id) mBirthSignDialog = new BirthDialog(*mWM); mBirthSignDialog->setNextButtonShow(mCreationStage >= CSE_BirthSignChosen); mBirthSignDialog->setBirthId(mPlayerBirthSignId); - mBirthSignDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone); - mBirthSignDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogBack); + mBirthSignDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone); + mBirthSignDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogBack); mBirthSignDialog->open(); break; @@ -170,8 +170,8 @@ void CharacterCreation::spawnDialog(const char id) if (mCreateClassDialog) mWM->removeDialog(mCreateClassDialog); mCreateClassDialog = new CreateClassDialog(*mWM); - mCreateClassDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogDone); - mCreateClassDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogBack); + mCreateClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogDone); + mCreateClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogBack); mCreateClassDialog->open(); break; case GM_ClassGenerate: @@ -212,9 +212,9 @@ void CharacterCreation::spawnDialog(const char id) mReviewDialog->configureSkills(mPlayerMajorSkills, mPlayerMinorSkills); } - mReviewDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogDone); - mReviewDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogBack); - mReviewDialog->eventActivateDialog = MyGUI::newDelegate(this, &CharacterCreation::onReviewActivateDialog); + mReviewDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogDone); + mReviewDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogBack); + mReviewDialog->eventActivateDialog += MyGUI::newDelegate(this, &CharacterCreation::onReviewActivateDialog); mReviewDialog->open(); break; } @@ -559,8 +559,8 @@ void CharacterCreation::showClassQuestionDialog() mWM->removeDialog(mGenerateClassResultDialog); mGenerateClassResultDialog = new GenerateClassResultDialog(*mWM); mGenerateClassResultDialog->setClassId(mGenerateClass); - mGenerateClassResultDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassBack); - mGenerateClassResultDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassDone); + mGenerateClassResultDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassBack); + mGenerateClassResultDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassDone); mGenerateClassResultDialog->open(); return; } @@ -581,7 +581,7 @@ void CharacterCreation::showClassQuestionDialog() buttons.push_back(sGenerateClassSteps[mGenerateClassStep].mButtons[1]); buttons.push_back(sGenerateClassSteps[mGenerateClassStep].mButtons[2]); mGenerateClassQuestionDialog->setButtons(buttons); - mGenerateClassQuestionDialog->eventButtonSelected = MyGUI::newDelegate(this, &CharacterCreation::onClassQuestionChosen); + mGenerateClassQuestionDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassQuestionChosen); mGenerateClassQuestionDialog->open(); } diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index ad94f30b1..75e534b42 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -29,11 +29,11 @@ GenerateClassResultDialog::GenerateClassResultDialog(WindowManager& parWindowMan // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); - backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &GenerateClassResultDialog::onBackClicked); + backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &GenerateClassResultDialog::onBackClicked); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &GenerateClassResultDialog::onOkClicked); + okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &GenerateClassResultDialog::onOkClicked); } void GenerateClassResultDialog::open() @@ -96,20 +96,20 @@ PickClassDialog::PickClassDialog(WindowManager& parWindowManager) getWidget(classList, "ClassList"); classList->setScrollVisible(true); - classList->eventListSelectAccept = MyGUI::newDelegate(this, &PickClassDialog::onSelectClass); - classList->eventListMouseItemActivate = MyGUI::newDelegate(this, &PickClassDialog::onSelectClass); - classList->eventListChangePosition = MyGUI::newDelegate(this, &PickClassDialog::onSelectClass); + classList->eventListSelectAccept += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass); + classList->eventListMouseItemActivate += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass); + classList->eventListChangePosition += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass); getWidget(classImage, "ClassImage"); // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); - backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &PickClassDialog::onBackClicked); + backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PickClassDialog::onBackClicked); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &PickClassDialog::onOkClicked); + okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PickClassDialog::onOkClicked); updateClasses(); updateStats(); @@ -177,7 +177,7 @@ void PickClassDialog::onBackClicked(MyGUI::Widget* _sender) eventBack(); } -void PickClassDialog::onSelectClass(MyGUI::List* _sender, size_t _index) +void PickClassDialog::onSelectClass(MyGUI::ListBox* _sender, size_t _index) { if (_index == MyGUI::ITEM_NONE) return; @@ -248,7 +248,7 @@ void PickClassDialog::updateStats() /* InfoBoxDialog */ -void InfoBoxDialog::fitToText(MyGUI::StaticTextPtr widget) +void InfoBoxDialog::fitToText(MyGUI::TextBox* widget) { MyGUI::IntCoord inner = widget->getTextRegion(); MyGUI::IntCoord outer = widget->getCoord(); @@ -267,7 +267,7 @@ void InfoBoxDialog::layoutVertically(MyGUI::WidgetPtr widget, int margin) for (unsigned i = 0; i < count; ++i) { MyGUI::WidgetPtr child = widget->getChildAt(i); - if (!child->isVisible()) + if (!child->getVisible()) continue; child->setPosition(child->getLeft(), pos); @@ -322,7 +322,7 @@ void InfoBoxDialog::setButtons(ButtonList &buttons) button->getSubWidgetText()->setWordWrap(true); button->setCaption(text); fitToText(button); - button->eventMouseButtonClick = MyGUI::newDelegate(this, &InfoBoxDialog::onButtonClicked); + button->eventMouseButtonClick += MyGUI::newDelegate(this, &InfoBoxDialog::onButtonClicked); coord.top += button->getHeight(); this->buttons.push_back(button); } @@ -389,15 +389,15 @@ CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager) setText("SpecializationT", mWindowManager.getGameSettingString("sChooseClassMenu1", "Specialization")); getWidget(specializationName, "SpecializationName"); specializationName->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], "")); - specializationName->eventMouseButtonClick = MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationClicked); + specializationName->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationClicked); setText("FavoriteAttributesT", mWindowManager.getGameSettingString("sChooseClassMenu2", "Favorite Attributes:")); getWidget(favoriteAttribute0, "FavoriteAttribute0"); getWidget(favoriteAttribute1, "FavoriteAttribute1"); favoriteAttribute0->setWindowManager(&mWindowManager); favoriteAttribute1->setWindowManager(&mWindowManager); - favoriteAttribute0->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked); - favoriteAttribute1->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked); + favoriteAttribute0->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked); + favoriteAttribute1->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked); setText("MajorSkillT", mWindowManager.getGameSettingString("sSkillClassMajor", "")); setText("MinorSkillT", mWindowManager.getGameSettingString("sSkillClassMinor", "")); @@ -414,7 +414,7 @@ CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager) for (std::vector::const_iterator it = skills.begin(); it != end; ++it) { (*it)->setWindowManager(&mWindowManager); - (*it)->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked); + (*it)->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked); } setText("LabelT", mWindowManager.getGameSettingString("sName", "")); @@ -426,15 +426,15 @@ CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager) // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr descriptionButton; getWidget(descriptionButton, "DescriptionButton"); - descriptionButton->eventMouseButtonClick = MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionClicked); + descriptionButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionClicked); MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); - backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &CreateClassDialog::onBackClicked); + backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onBackClicked); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &CreateClassDialog::onOkClicked); + okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onOkClicked); // Set default skills, attributes @@ -560,8 +560,8 @@ void CreateClassDialog::onSpecializationClicked(MyGUI::WidgetPtr _sender) if (specDialog) delete specDialog; specDialog = new SelectSpecializationDialog(mWindowManager); - specDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); - specDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationSelected); + specDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); + specDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationSelected); specDialog->setVisible(true); } @@ -578,8 +578,8 @@ void CreateClassDialog::onAttributeClicked(Widgets::MWAttributePtr _sender) delete attribDialog; attribDialog = new SelectAttributeDialog(mWindowManager); attribDialog->setAffectedWidget(_sender); - attribDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); - attribDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeSelected); + attribDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); + attribDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeSelected); attribDialog->setVisible(true); } @@ -607,8 +607,8 @@ void CreateClassDialog::onSkillClicked(Widgets::MWSkillPtr _sender) delete skillDialog; skillDialog = new SelectSkillDialog(mWindowManager); skillDialog->setAffectedWidget(_sender); - skillDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); - skillDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onSkillSelected); + skillDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); + skillDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onSkillSelected); skillDialog->setVisible(true); } @@ -638,7 +638,7 @@ void CreateClassDialog::onDescriptionClicked(MyGUI::Widget* _sender) { descDialog = new DescriptionDialog(mWindowManager); descDialog->setTextInput(description); - descDialog->eventDone = MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionEntered); + descDialog->eventDone += MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionEntered); descDialog->setVisible(true); } @@ -672,18 +672,18 @@ SelectSpecializationDialog::SelectSpecializationDialog(WindowManager& parWindowM getWidget(specialization1, "Specialization1"); getWidget(specialization2, "Specialization2"); specialization0->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], "")); - specialization0->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); + specialization0->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); specialization1->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Magic], "")); - specialization1->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); + specialization1->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); specialization2->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Stealth], "")); - specialization2->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); + specialization2->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); specializationId = ESM::Class::Combat; // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr cancelButton; getWidget(cancelButton, "CancelButton"); cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", "")); - cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked); + cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked); } // widget controls @@ -725,14 +725,14 @@ SelectAttributeDialog::SelectAttributeDialog(WindowManager& parWindowManager) getWidget(attribute, std::string("Attribute").append(1, theIndex)); attribute->setWindowManager(&parWindowManager); attribute->setAttributeId(ESM::Attribute::attributeIds[i]); - attribute->eventClicked = MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked); + attribute->eventClicked += MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked); } // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr cancelButton; getWidget(cancelButton, "CancelButton"); cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", "")); - cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked); + cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked); } // widget controls @@ -813,7 +813,7 @@ SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager) { skills[spec][i].widget->setWindowManager(&mWindowManager); skills[spec][i].widget->setSkillId(skills[spec][i].skillId); - skills[spec][i].widget->eventClicked = MyGUI::newDelegate(this, &SelectSkillDialog::onSkillClicked); + skills[spec][i].widget->eventClicked += MyGUI::newDelegate(this, &SelectSkillDialog::onSkillClicked); } } @@ -821,7 +821,7 @@ SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager) MyGUI::ButtonPtr cancelButton; getWidget(cancelButton, "CancelButton"); cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", "")); - cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSkillDialog::onCancelClicked); + cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSkillDialog::onCancelClicked); } // widget controls @@ -850,7 +850,7 @@ DescriptionDialog::DescriptionDialog(WindowManager& parWindowManager) // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &DescriptionDialog::onOkClicked); + okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DescriptionDialog::onOkClicked); okButton->setCaption(mWindowManager.getGameSettingString("sInputMenu1", "")); // Make sure the edit box has focus diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index 5f1734b19..0e3348086 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -31,7 +31,7 @@ namespace MWGui int getChosenButton() const; // Events - typedef delegates::CDelegate1 EventHandle_Int; + typedef delegates::CMultiDelegate1 EventHandle_Int; /** Event : Button was clicked.\n signature : void method(MyGUI::WidgetPtr widget, int index)\n @@ -43,11 +43,11 @@ namespace MWGui private: - void fitToText(MyGUI::StaticTextPtr widget); + void fitToText(MyGUI::TextBox* widget); void layoutVertically(MyGUI::WidgetPtr widget, int margin); int currentButton; MyGUI::WidgetPtr textBox; - MyGUI::StaticTextPtr text; + MyGUI::TextBox* text; MyGUI::WidgetPtr buttonBar; std::vector buttons; }; @@ -78,7 +78,7 @@ namespace MWGui void open(); // Events - typedef delegates::CDelegate0 EventHandle_Void; + typedef delegates::CMultiDelegate0 EventHandle_Void; /** Event : Back button clicked.\n signature : void method()\n @@ -90,8 +90,8 @@ namespace MWGui void onBackClicked(MyGUI::Widget* _sender); private: - MyGUI::StaticImagePtr classImage; - MyGUI::StaticTextPtr className; + MyGUI::ImageBox* classImage; + MyGUI::TextBox* className; std::string currentClassId; }; @@ -108,7 +108,7 @@ namespace MWGui void open(); // Events - typedef delegates::CDelegate0 EventHandle_Void; + typedef delegates::CMultiDelegate0 EventHandle_Void; /** Event : Back button clicked.\n signature : void method()\n @@ -116,7 +116,7 @@ namespace MWGui EventHandle_Void eventBack; protected: - void onSelectClass(MyGUI::List* _sender, size_t _index); + void onSelectClass(MyGUI::ListBox* _sender, size_t _index); void onOkClicked(MyGUI::Widget* _sender); void onBackClicked(MyGUI::Widget* _sender); @@ -125,9 +125,9 @@ namespace MWGui void updateClasses(); void updateStats(); - MyGUI::StaticImagePtr classImage; - MyGUI::ListPtr classList; - MyGUI::StaticTextPtr specializationName; + MyGUI::ImageBox* classImage; + MyGUI::ListBox* classList; + MyGUI::TextBox* specializationName; Widgets::MWAttributePtr favoriteAttribute[2]; Widgets::MWSkillPtr majorSkill[5]; Widgets::MWSkillPtr minorSkill[5]; @@ -143,7 +143,7 @@ namespace MWGui ESM::Class::Specialization getSpecializationId() const { return specializationId; } // Events - typedef delegates::CDelegate0 EventHandle_Void; + typedef delegates::CMultiDelegate0 EventHandle_Void; /** Event : Cancel button clicked.\n signature : void method()\n @@ -160,7 +160,7 @@ namespace MWGui void onCancelClicked(MyGUI::Widget* _sender); private: - MyGUI::WidgetPtr specialization0, specialization1, specialization2; + MyGUI::TextBox *specialization0, *specialization1, *specialization2; ESM::Class::Specialization specializationId; }; @@ -175,7 +175,7 @@ namespace MWGui void setAffectedWidget(Widgets::MWAttributePtr widget) { affectedWidget = widget; } // Events - typedef delegates::CDelegate0 EventHandle_Void; + typedef delegates::CMultiDelegate0 EventHandle_Void; /** Event : Cancel button clicked.\n signature : void method()\n @@ -207,7 +207,7 @@ namespace MWGui void setAffectedWidget(Widgets::MWSkillPtr widget) { affectedWidget = widget; } // Events - typedef delegates::CDelegate0 EventHandle_Void; + typedef delegates::CMultiDelegate0 EventHandle_Void; /** Event : Cancel button clicked.\n signature : void method()\n @@ -264,7 +264,7 @@ namespace MWGui void open(); // Events - typedef delegates::CDelegate0 EventHandle_Void; + typedef delegates::CMultiDelegate0 EventHandle_Void; /** Event : Back button clicked.\n signature : void method()\n @@ -287,7 +287,7 @@ namespace MWGui private: MyGUI::EditPtr editName; - MyGUI::WidgetPtr specializationName; + MyGUI::TextBox* specializationName; Widgets::MWAttributePtr favoriteAttribute0, favoriteAttribute1; Widgets::MWSkillPtr majorSkill[5]; Widgets::MWSkillPtr minorSkill[5]; diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 3fd6e7892..ac4f4a82a 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -113,9 +113,9 @@ namespace MWGui getWidget(history, "list_History"); // Set up the command line box - command->eventEditSelectAccept = + command->eventEditSelectAccept += newDelegate(this, &Console::acceptCommand); - command->eventKeyButtonPressed = + command->eventKeyButtonPressed += newDelegate(this, &Console::keyPress); // Set up the log window @@ -139,6 +139,9 @@ namespace MWGui void Console::disable() { setVisible(false); + // Remove keyboard focus from the console input whenever the + // console is turned off + MyGUI::InputManager::getInstance().setKeyFocusWidget(NULL); } void Console::setFont(const std::string &fntName) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index e48c142aa..d6c4ce4e5 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -3,6 +3,8 @@ #include "window_manager.hpp" #include "widgets.hpp" #include "components/esm_store/store.hpp" +#include "../mwworld/environment.hpp" +#include "../mwdialogue/dialoguemanager.hpp" #include #include @@ -14,107 +16,192 @@ using namespace MWGui; using namespace Widgets; -DialogueWindow::DialogueWindow(WindowManager& parWindowManager) - : WindowBase("openmw_dialogue_window_layout.xml", parWindowManager) +/** +*Copied from the internet. +*/ + +std::string lower_string(const std::string& str) +{ + std::string lowerCase; + + std::transform (str.begin(), str.end(), std::back_inserter (lowerCase), + (int(*)(int)) std::tolower); + + return lowerCase; +} + +std::string::size_type find_str_ci(const std::string& str, const std::string& substr,size_t pos) +{ + return lower_string(str).find(lower_string(substr),pos); +} + + +DialogueWindow::DialogueWindow(WindowManager& parWindowManager,MWWorld::Environment& environment) + : WindowBase("openmw_dialogue_window_layout.xml", parWindowManager), + mEnvironment(environment) { // Centre dialog center(); //WindowManager *wm = environment.mWindowManager; setText("NpcName", "Name of character"); - + //History view getWidget(history, "History"); history->setOverflowToTheLeft(true); - history->getClient()->eventMouseButtonClick = MyGUI::newDelegate(this, &DialogueWindow::onHistoryClicked); - - //Topics list + history->setMaxTextLength(1000000); + Widget* eventbox; + + //An EditBox cannot receive mouse click events, so we use an + //invisible widget on top of the editbox to receive them + /// \todo scrolling the dialogue history with the mouse wheel doesn't work using this solution + getWidget(eventbox, "EventBox"); + eventbox->eventMouseButtonClick += MyGUI::newDelegate(this, &DialogueWindow::onHistoryClicked); + + //Topics list getWidget(topicsList, "TopicsList"); topicsList->setScrollVisible(true); - topicsList->eventListSelectAccept = MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); - topicsList->eventListMouseItemActivate = MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); - topicsList->eventListChangePosition = MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); + //topicsList->eventListSelectAccept += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); + topicsList->eventListMouseItemActivate += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); + //topicsList->eventListChangePosition += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); MyGUI::ButtonPtr byeButton; getWidget(byeButton, "ByeButton"); - byeButton->eventMouseButtonClick = MyGUI::newDelegate(this, &DialogueWindow::onByeClicked); + byeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DialogueWindow::onByeClicked); - updateOptions(); + getWidget(pDispositionBar, "Disposition"); + getWidget(pDispositionText,"DispositionText"); } void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) { - ISubWidgetText* t = history->getSubWidgetText(); + ISubWidgetText* t = history->getClient()->getSubWidgetText(); if(t == nullptr) return; - const IntPoint& lastPressed = InputManager::getInstance().getLastLeftPressed(); + const IntPoint& lastPressed = InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left); size_t cursorPosition = t->getCursorPosition(lastPressed); - if(history->getColorAtPos(cursorPosition) != "#FFFFFF") + MyGUI::UString color = history->getColorAtPos(cursorPosition); + if(color != "#B29154") { UString key = history->getColorTextAt(cursorPosition); - std::cout << "Clicked on key: " << key << std::endl; - //eventTopicSelected(key); + if(color == "#686EBA") mEnvironment.mDialogueManager->keywordSelected(lower_string(key)); + + if(color == "#572D21") mEnvironment.mDialogueManager->questionAnswered(key); } } void DialogueWindow::open() { + topicsList->removeAllItems(); + pTopicsText.clear(); + history->eraseText(0,history->getTextLength()); updateOptions(); setVisible(true); } void DialogueWindow::onByeClicked(MyGUI::Widget* _sender) { - eventBye(); + mEnvironment.mDialogueManager->goodbyeSelected(); } -void DialogueWindow::onSelectTopic(MyGUI::List* _sender, size_t _index) +void DialogueWindow::onSelectTopic(MyGUI::ListBox* _sender, size_t _index) { if (_index == MyGUI::ITEM_NONE) return; + std::string topic = _sender->getItemNameAt(_index); + mEnvironment.mDialogueManager->keywordSelected(lower_string(topic)); +} - //const std::string* theTopic = topicsList->getItemDataAt(_index); - //std::cout << "Selected: "<< theTopic << std::endl; - //eventTopicSelected(key); +void DialogueWindow::startDialogue(std::string npcName) +{ + setText("NpcName", npcName); } +void DialogueWindow::setKeywords(std::list keyWords) +{ + topicsList->removeAllItems(); + for(std::list::iterator it = keyWords.begin(); it != keyWords.end(); it++) + { + topicsList->addItem(*it); + } +} -void DialogueWindow::updateOptions() +void DialogueWindow::removeKeyword(std::string keyWord) +{ + if(topicsList->findItemIndexWith(keyWord) != MyGUI::ITEM_NONE) + { + topicsList->removeItemAt(topicsList->findItemIndexWith(keyWord)); + pTopicsText.erase(keyWord); + } +} + +void addColorInString(std::string& str, const std::string& keyword,std::string color1, std::string color2) +{ + size_t pos = 0; + while((pos = find_str_ci(str,keyword, pos)) != std::string::npos) + { + if(pos==0) + { + str.insert(pos,color1); + pos += color1.length(); + pos += keyword.length(); + str.insert(pos,color2); + pos+= color2.length(); + } + else + { + if(str.substr(pos -1,1) == " ") + { + str.insert(pos,color1); + pos += color1.length(); + pos += keyword.length(); + str.insert(pos,color2); + pos+= color2.length(); + } + else + { + pos += keyword.length(); + } + } + } +} + +std::string DialogueWindow::parseText(std::string text) { - //FIXME Add this properly - history->addDialogText("Through the translucent surface of the orb, you see shifting images of distant locations..."); - for(int z = 0; z < 10; z++) + for(unsigned int i = 0;igetItemCount();i++) { - history->addDialogHeading("Fort Frostmoth"); - history->addDialogText("The image in the orb flickers, and you see.... The cold courtyard of #FF0000Fort Frostmoth#FFFFFF, battered bu werewolf attack, but still standing, still projecting Imperial might even to this distant and cold corner of the world."); + std::string keyWord = topicsList->getItemNameAt(i); + addColorInString(text,keyWord,"#686EBA","#B29154"); } + return text; +} +void DialogueWindow::addText(std::string text) +{ + history->addDialogText("#B29154"+parseText(text)+"#B29154"); +} + +void DialogueWindow::addTitle(std::string text) +{ + history->addDialogHeading(text); +} + +void DialogueWindow::askQuestion(std::string question) +{ + history->addDialogText("#572D21"+question+"#B29154"+" "); +} + +void DialogueWindow::updateOptions() +{ //Clear the list of topics topicsList->removeAllItems(); - int i = 0; - topicsList->addItem("Ald'ruhn", i++); - topicsList->addItem("Balmora", i++); - topicsList->addItem("Sadrith Mora", i++); - topicsList->addItem("Vivec", i++); - topicsList->addItem("Ald Velothi", i++); - topicsList->addItem("Caldera", i++); - topicsList->addItem("Dagon Fel ", i++); - topicsList->addItem("Gnaar Mok", i++); - topicsList->addItem("Gnisis", i++); - topicsList->addItem("Hla Oad", i++); - topicsList->addItem("Khuul", i++); - topicsList->addItem("Maar Gan", i++); - topicsList->addItem("Molag Mar", i++); - topicsList->addItem("Pelagiad", i++); - topicsList->addItem("Seyda Neen", i++); - topicsList->addItem("Suran", i++); - topicsList->addItem("Tel Aruhn", i++); - topicsList->addItem("Tel Branora", i++); - topicsList->addItem("Tel Fyr", i++); - topicsList->addItem("Tel Mora", i++); - topicsList->addItem("Tel Vos", i++); - topicsList->addItem("Vos", i++); -} + pTopicsText.clear(); + history->eraseText(0,history->getTextLength()); + pDispositionBar->setProgressRange(100); + pDispositionBar->setProgressPosition(40); + pDispositionText->eraseText(0,pDispositionText->getTextLength()); + pDispositionText->addText("#B29154"+std::string("40/100")+"#B29154"); +} diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index ddb6f8a4c..b80a016cb 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -9,6 +9,11 @@ namespace MWGui class WindowManager; } +namespace MWWorld +{ + class Environment; +} + /* This file contains the dialouge window Layout is defined by resources/mygui/openmw_dialogue_window_layout.xml. @@ -16,35 +21,52 @@ namespace MWGui namespace MWGui { - class DialogeHistory; + class DialogueHistory; using namespace MyGUI; class DialogueWindow: public WindowBase { public: - DialogueWindow(WindowManager& parWindowManager); + DialogueWindow(WindowManager& parWindowManager,MWWorld::Environment& environment); void open(); // Events - typedef delegates::CDelegate0 EventHandle_Void; + typedef delegates::CMultiDelegate0 EventHandle_Void; /** Event : Dialog finished, OK button clicked.\n signature : void method()\n */ EventHandle_Void eventBye; + void startDialogue(std::string npcName); + void stopDialogue(); + void setKeywords(std::list keyWord); + void removeKeyword(std::string keyWord); + void addText(std::string text); + void addTitle(std::string text); + void askQuestion(std::string question); + protected: - void onSelectTopic(MyGUI::List* _sender, size_t _index); + void onSelectTopic(MyGUI::ListBox* _sender, size_t _index); void onByeClicked(MyGUI::Widget* _sender); void onHistoryClicked(MyGUI::Widget* _sender); private: void updateOptions(); + /** + *Helper function that add topic keyword in blue in a text. + */ + std::string parseText(std::string text); + + DialogueHistory* history; + MyGUI::ListBox* topicsList; + MyGUI::ProgressPtr pDispositionBar; + MyGUI::EditPtr pDispositionText; + std::map pTopicsText;// this map links keyword and "real" text. - DialogeHistory* history; - MyGUI::ListPtr topicsList; + MWWorld::Environment& mEnvironment; }; } #endif diff --git a/apps/openmw/mwgui/dialogue_history.cpp b/apps/openmw/mwgui/dialogue_history.cpp index aaa559d24..cd34ee119 100644 --- a/apps/openmw/mwgui/dialogue_history.cpp +++ b/apps/openmw/mwgui/dialogue_history.cpp @@ -13,10 +13,10 @@ using namespace MWGui; using namespace Widgets; -UString DialogeHistory::getColorAtPos(size_t _pos) +UString DialogueHistory::getColorAtPos(size_t _pos) { - UString colour = TextIterator::convertTagColour(mText->getTextColour()); - TextIterator iterator(mText->getCaption()); + UString colour = TextIterator::convertTagColour(getTextColour()); + TextIterator iterator(getCaption()); while(iterator.moveNext()) { size_t pos = iterator.getPosition(); @@ -29,12 +29,12 @@ UString DialogeHistory::getColorAtPos(size_t _pos) return colour; } -UString DialogeHistory::getColorTextAt(size_t _pos) +UString DialogueHistory::getColorTextAt(size_t _pos) { bool breakOnNext = false; - UString colour = TextIterator::convertTagColour(mText->getTextColour()); + UString colour = TextIterator::convertTagColour(getTextColour()); UString colour2 = colour; - TextIterator iterator(mText->getCaption()); + TextIterator iterator(getCaption()); TextIterator col_start = iterator; while(iterator.moveNext()) { @@ -59,15 +59,15 @@ UString DialogeHistory::getColorTextAt(size_t _pos) return ""; } -void DialogeHistory::addDialogHeading(const UString& parText) +void DialogueHistory::addDialogHeading(const UString& parText) { - UString head("\n#00FF00"); + UString head("\n#D8C09A"); head.append(parText); - head.append("#FFFFFF\n"); + head.append("#B29154\n"); addText(head); } -void DialogeHistory::addDialogText(const UString& parText) +void DialogueHistory::addDialogText(const UString& parText) { addText(parText); addText("\n"); diff --git a/apps/openmw/mwgui/dialogue_history.hpp b/apps/openmw/mwgui/dialogue_history.hpp index ec41678e6..12a9c53e7 100644 --- a/apps/openmw/mwgui/dialogue_history.hpp +++ b/apps/openmw/mwgui/dialogue_history.hpp @@ -5,9 +5,9 @@ namespace MWGui { using namespace MyGUI; - class DialogeHistory : public MyGUI::Edit + class DialogueHistory : public MyGUI::EditBox { - MYGUI_RTTI_DERIVED( DialogeHistory ) + MYGUI_RTTI_DERIVED( DialogueHistory ) public: Widget* getClient() { return mClient; } UString getColorAtPos(size_t _pos); diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index 5c9ef1f9b..644bcbc04 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -89,9 +89,9 @@ MWGui::JournalWindow::JournalWindow (WindowManager& parWindowManager) getWidget(mLeftTextWidget, "LeftText"); getWidget(mRightTextWidget, "RightText"); getWidget(mPrevBtn, "PrevPageBTN"); - mPrevBtn->eventMouseButtonClick = MyGUI::newDelegate(this,&MWGui::JournalWindow::notifyPrevPage); + mPrevBtn->eventMouseButtonClick += MyGUI::newDelegate(this,&MWGui::JournalWindow::notifyPrevPage); getWidget(mNextBtn, "NextPageBTN"); - mNextBtn->eventMouseButtonClick = MyGUI::newDelegate(this,&MWGui::JournalWindow::notifyNextPage); + mNextBtn->eventMouseButtonClick += MyGUI::newDelegate(this,&MWGui::JournalWindow::notifyNextPage); //MyGUI::ItemBox* list = new MyGUI::ItemBox(); //list->addItem("qaq","aqzazaz"); //mScrollerWidget->addChildItem(list); @@ -111,7 +111,7 @@ MWGui::JournalWindow::JournalWindow (WindowManager& parWindowManager) //displayLeftText(list.front()); MyGUI::WindowPtr t = static_cast(mMainWidget); - t->eventWindowChangeCoord = MyGUI::newDelegate(this, &JournalWindow::onWindowResize); + t->eventWindowChangeCoord += MyGUI::newDelegate(this, &JournalWindow::onWindowResize); } void MWGui::JournalWindow::open() diff --git a/apps/openmw/mwgui/journalwindow.hpp b/apps/openmw/mwgui/journalwindow.hpp index e66448763..4656c7a48 100644 --- a/apps/openmw/mwgui/journalwindow.hpp +++ b/apps/openmw/mwgui/journalwindow.hpp @@ -41,7 +41,7 @@ namespace MWGui static const int lineHeight; MyGUI::WidgetPtr skillAreaWidget, skillClientWidget; - MyGUI::VScrollPtr skillScrollerWidget; + MyGUI::ScrollBar* skillScrollerWidget; int lastPos, clientHeight; MyGUI::EditPtr mLeftTextWidget; MyGUI::EditPtr mRightTextWidget; @@ -54,4 +54,4 @@ namespace MWGui } -#endif \ No newline at end of file +#endif diff --git a/apps/openmw/mwgui/layouts.hpp b/apps/openmw/mwgui/layouts.hpp index 9917dcdcc..71181e48d 100644 --- a/apps/openmw/mwgui/layouts.hpp +++ b/apps/openmw/mwgui/layouts.hpp @@ -45,18 +45,18 @@ namespace MWGui void setBatchCount(size_t count); MyGUI::ProgressPtr health, magicka, stamina; - MyGUI::StaticImagePtr weapImage, spellImage; + MyGUI::ImageBox *weapImage, *spellImage; MyGUI::ProgressPtr weapStatus, spellStatus; MyGUI::WidgetPtr effectBox; - MyGUI::StaticImagePtr effect1; - MyGUI::StaticImagePtr minimap; - MyGUI::StaticImagePtr compass; - MyGUI::StaticImagePtr crosshair; + MyGUI::ImageBox* effect1; + MyGUI::ImageBox* minimap; + MyGUI::ImageBox* compass; + MyGUI::ImageBox* crosshair; MyGUI::WidgetPtr fpsbox; - MyGUI::StaticTextPtr fpscounter; - MyGUI::StaticTextPtr trianglecounter; - MyGUI::StaticTextPtr batchcounter; + MyGUI::TextBox* fpscounter; + MyGUI::TextBox* trianglecounter; + MyGUI::TextBox* batchcounter; }; class MapWindow : public OEngine::GUI::Layout @@ -75,7 +75,7 @@ namespace MWGui void setCellName(const std::string& cellName) { - mMainWidget->setCaption(cellName); + static_cast(mMainWidget)->setCaption(cellName); } }; @@ -127,7 +127,7 @@ namespace MWGui getWidget(avatar, "Avatar"); // Adjust armor rating text to bottom of avatar widget - MyGUI::StaticTextPtr armor_rating; + MyGUI::TextBox* armor_rating; getWidget(armor_rating, "ArmorRating"); armor_rating->setCaption("Armor: 11"); MyGUI::IntCoord coord = armor_rating->getCoord(); @@ -165,7 +165,7 @@ namespace MWGui last_x += coord.width + margin; button_pt->setCoord(coord); - button_pt->eventMouseButtonClick = MyGUI::newDelegate(this, &InventoryWindow::onCategorySelected); + button_pt->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onCategorySelected); } } diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index f0745bbbe..c103bcb8b 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -19,7 +19,7 @@ void MessageBoxManager::onFrame (float frameDuration) if(it->current >= it->max) { it->messageBox->mMarkedToDelete = true; - + if(*mMessageBoxes.begin() == it->messageBox) // if this box is the last one { // collect all with mMarkedToDelete and delete them. @@ -47,7 +47,7 @@ void MessageBoxManager::onFrame (float frameDuration) it++; } } - + if(mInterMessageBoxe != NULL && mInterMessageBoxe->mMarkedToDelete) { delete mInterMessageBoxe; mInterMessageBoxe = NULL; @@ -57,20 +57,18 @@ void MessageBoxManager::onFrame (float frameDuration) void MessageBoxManager::createMessageBox (const std::string& message) { - std::cout << "MessageBox: " << message << std::endl; - MessageBox *box = new MessageBox(*this, message); - + removeMessageBox(message.length()*mMessageBoxSpeed, box); - + mMessageBoxes.push_back(box); std::vector::iterator it; - + if(mMessageBoxes.size() > 3) { delete *mMessageBoxes.begin(); mMessageBoxes.erase(mMessageBoxes.begin()); } - + int height = 0; for(it = mMessageBoxes.begin(); it != mMessageBoxes.end(); ++it) { @@ -88,9 +86,9 @@ bool MessageBoxManager::createInteractiveMessageBox (const std::string& message, std::cout << "interactive MessageBox: " << message << " - "; std::copy (buttons.begin(), buttons.end(), std::ostream_iterator (std::cout, ", ")); std::cout << std::endl; - + mInterMessageBoxe = new InteractiveMessageBox(*this, message, buttons); - + return true; } @@ -105,7 +103,7 @@ void MessageBoxManager::removeMessageBox (float time, MessageBox *msgbox) timer.current = 0; timer.max = time; timer.messageBox = msgbox; - + mTimers.insert(mTimers.end(), timer); } @@ -152,25 +150,26 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin mBottomPadding = 20; mNextBoxPadding = 20; mMarkedToDelete = false; - + getWidget(mMessageWidget, "message"); - + mMessageWidget->setOverflowToTheLeft(true); mMessageWidget->addText(cMessage); - + MyGUI::IntSize size; size.width = mFixedWidth; size.height = 100; // dummy - + MyGUI::IntCoord coord; coord.left = 10; // dummy coord.top = 10; // dummy mMessageWidget->setSize(size); - - MyGUI::IntSize textSize = mMessageWidget->_getTextSize(); + + MyGUI::IntSize textSize = mMessageWidget->getTextSize(); + size.height = mHeight = textSize.height + 20; // this is the padding between the text and the box - + mMainWidget->setSize(size); size.width -= 15; // this is to center the text (see messagebox_layout.xml, Widget type="Edit" position="-2 -3 0 0") mMessageWidget->setSize(size); @@ -178,15 +177,15 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin void MessageBox::update (int height) { - MyGUI::IntSize gameWindowSize = mMessageBoxManager.mWindowManager->getGui()->getViewSize(); + MyGUI::IntSize gameWindowSize = MyGUI::RenderManager::getInstance().getViewSize(); MyGUI::IntCoord coord; coord.left = (gameWindowSize.width - mFixedWidth)/2; coord.top = (gameWindowSize.height - mHeight - height - mBottomPadding); - + MyGUI::IntSize size; size.width = mFixedWidth; size.height = mHeight; - + mMainWidget->setCoord(coord); mMainWidget->setSize(size); mMainWidget->setVisible(true); @@ -211,26 +210,26 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan int buttonTopPadding = 5; // ^-- if vertical int buttonPadding = 5; // padding between button label and button itself int buttonMainPadding = 10; // padding between buttons and bottom of the main widget - + mMarkedToDelete = false; - - + + getWidget(mMessageWidget, "message"); getWidget(mButtonsWidget, "buttons"); - + mMessageWidget->setOverflowToTheLeft(true); mMessageWidget->addText(message); - - MyGUI::IntSize textSize = mMessageWidget->_getTextSize(); - - MyGUI::IntSize gameWindowSize = mMessageBoxManager.mWindowManager->getGui()->getViewSize(); - + + MyGUI::IntSize textSize = mMessageWidget->getTextSize(); + + MyGUI::IntSize gameWindowSize = MyGUI::RenderManager::getInstance().getViewSize(); + int biggestButtonWidth = 0; int buttonWidth = 0; int buttonsWidth = 0; int buttonHeight = 0; MyGUI::IntCoord dummyCoord(0, 0, 0, 0); - + std::vector::const_iterator it; for(it = buttons.begin(); it != buttons.end(); ++it) { @@ -240,28 +239,28 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan dummyCoord, MyGUI::Align::Default); button->setCaption(*it); - - button->eventMouseButtonClick = MyGUI::newDelegate(this, &InteractiveMessageBox::mousePressed); - + + button->eventMouseButtonClick += MyGUI::newDelegate(this, &InteractiveMessageBox::mousePressed); + mButtons.push_back(button); - - buttonWidth = button->_getTextSize().width + 2*buttonPadding + buttonLeftPadding; + + buttonWidth = button->getTextSize().width + 2*buttonPadding + buttonLeftPadding; buttonsWidth += buttonWidth; - buttonHeight = button->_getTextSize().height + 2*buttonPadding + buttonTopPadding; - + buttonHeight = button->getTextSize().height + 2*buttonPadding + buttonTopPadding; + if(buttonWidth > biggestButtonWidth) { biggestButtonWidth = buttonWidth; } } buttonsWidth += buttonLeftPadding; - + MyGUI::IntSize mainWidgetSize; if(buttonsWidth < fixedWidth) { // on one line std::cout << "on one line" << std::endl; - + if(textSize.width + 2*textPadding < buttonsWidth) { std::cout << "width = buttonsWidth" << std::endl; @@ -272,48 +271,48 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan mainWidgetSize.width = textSize.width + 3*textPadding; } mainWidgetSize.height = textSize.height + textButtonPadding + buttonHeight + buttonMainPadding; - + MyGUI::IntCoord absCoord; absCoord.left = (gameWindowSize.width - mainWidgetSize.width)/2; absCoord.top = (gameWindowSize.height - mainWidgetSize.height)/2; - + std::cout << "width " << mainWidgetSize.width << " height " << mainWidgetSize.height << std::endl; std::cout << "left " << absCoord.left << " top " << absCoord.top << std::endl; - + mMainWidget->setCoord(absCoord); mMainWidget->setSize(mainWidgetSize); - - + + MyGUI::IntCoord messageWidgetCoord; messageWidgetCoord.left = (mainWidgetSize.width - textSize.width)/2; messageWidgetCoord.top = textPadding; mMessageWidget->setCoord(messageWidgetCoord); - + mMessageWidget->setSize(textSize); - + MyGUI::IntCoord buttonCord; MyGUI::IntSize buttonSize(0, buttonHeight); int left = (mainWidgetSize.width - buttonsWidth)/2 + buttonPadding; - + std::vector::const_iterator button; for(button = mButtons.begin(); button != mButtons.end(); ++button) { buttonCord.left = left; buttonCord.top = textSize.height + textButtonPadding; - - buttonSize.width = (*button)->_getTextSize().width + 2*buttonPadding; - buttonSize.height = (*button)->_getTextSize().height + 2*buttonPadding; - + + buttonSize.width = (*button)->getTextSize().width + 2*buttonPadding; + buttonSize.height = (*button)->getTextSize().height + 2*buttonPadding; + (*button)->setCoord(buttonCord); (*button)->setSize(buttonSize); - + left += buttonSize.width + buttonLeftPadding; } } else { // among each other - + if(biggestButtonWidth > textSize.width) { mainWidgetSize.width = biggestButtonWidth + buttonTopPadding; } @@ -321,46 +320,46 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan mainWidgetSize.width = textSize.width + 3*textPadding; } mainWidgetSize.height = textSize.height + 2*textPadding + textButtonPadding + buttonHeight * buttons.size() + buttonMainPadding; - + std::cout << "biggestButtonWidth " << biggestButtonWidth << " textSize.width " << textSize.width << std::endl; std::cout << "width " << mainWidgetSize.width << " height " << mainWidgetSize.height << std::endl; mMainWidget->setSize(mainWidgetSize); - + MyGUI::IntCoord absCoord; absCoord.left = (gameWindowSize.width - mainWidgetSize.width)/2; absCoord.top = (gameWindowSize.height - mainWidgetSize.height)/2; - + mMainWidget->setCoord(absCoord); mMainWidget->setSize(mainWidgetSize); - - + + MyGUI::IntCoord messageWidgetCoord; messageWidgetCoord.left = (mainWidgetSize.width - textSize.width)/2; messageWidgetCoord.top = textPadding; mMessageWidget->setCoord(messageWidgetCoord); - + mMessageWidget->setSize(textSize); - + MyGUI::IntCoord buttonCord; MyGUI::IntSize buttonSize(0, buttonHeight); - + int top = textButtonPadding + buttonTopPadding + textSize.height; - + std::vector::const_iterator button; for(button = mButtons.begin(); button != mButtons.end(); ++button) { - buttonSize.width = (*button)->_getTextSize().width + buttonPadding*2; - buttonSize.height = (*button)->_getTextSize().height + buttonPadding*2; - + buttonSize.width = (*button)->getTextSize().width + buttonPadding*2; + buttonSize.height = (*button)->getTextSize().height + buttonPadding*2; + buttonCord.top = top; buttonCord.left = (mainWidgetSize.width - buttonSize.width)/2 - 5; // FIXME: -5 is not so nice :/ - + (*button)->setCoord(buttonCord); (*button)->setSize(buttonSize); - + top += buttonSize.height + 2*buttonTopPadding; } - + } } @@ -387,8 +386,3 @@ int InteractiveMessageBox::readPressedButton () mButtonPressed = -1; return pressed; } - - - - - diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 037f97fc3..880c0bc52 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -34,7 +34,7 @@ RaceDialog::RaceDialog(WindowManager& parWindowManager) headRotate->setScrollRange(50); headRotate->setScrollPosition(20); headRotate->setScrollViewPage(10); - headRotate->eventScrollChangePosition = MyGUI::newDelegate(this, &RaceDialog::onHeadRotate); + headRotate->eventScrollChangePosition += MyGUI::newDelegate(this, &RaceDialog::onHeadRotate); // Set up next/previous buttons MyGUI::ButtonPtr prevButton, nextButton; @@ -42,27 +42,27 @@ RaceDialog::RaceDialog(WindowManager& parWindowManager) setText("GenderChoiceT", mWindowManager.getGameSettingString("sRaceMenu2", "Change Sex")); getWidget(prevButton, "PrevGenderButton"); getWidget(nextButton, "NextGenderButton"); - prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousGender); - nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextGender); + prevButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousGender); + nextButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectNextGender); setText("FaceChoiceT", mWindowManager.getGameSettingString("sRaceMenu3", "Change Face")); getWidget(prevButton, "PrevFaceButton"); getWidget(nextButton, "NextFaceButton"); - prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousFace); - nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextFace); + prevButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousFace); + nextButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectNextFace); setText("HairChoiceT", mWindowManager.getGameSettingString("sRaceMenu3", "Change Hair")); getWidget(prevButton, "PrevHairButton"); getWidget(nextButton, "NextHairButton"); - prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousHair); - nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextHair); + prevButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousHair); + nextButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectNextHair); setText("RaceT", mWindowManager.getGameSettingString("sRaceMenu4", "Race")); getWidget(raceList, "RaceList"); raceList->setScrollVisible(true); - raceList->eventListSelectAccept = MyGUI::newDelegate(this, &RaceDialog::onSelectRace); - raceList->eventListMouseItemActivate = MyGUI::newDelegate(this, &RaceDialog::onSelectRace); - raceList->eventListChangePosition = MyGUI::newDelegate(this, &RaceDialog::onSelectRace); + raceList->eventListSelectAccept += MyGUI::newDelegate(this, &RaceDialog::onSelectRace); + raceList->eventListMouseItemActivate += MyGUI::newDelegate(this, &RaceDialog::onSelectRace); + raceList->eventListChangePosition += MyGUI::newDelegate(this, &RaceDialog::onSelectRace); setText("SkillsT", mWindowManager.getGameSettingString("sBonusSkillTitle", "Skill Bonus")); getWidget(skillList, "SkillList"); @@ -72,11 +72,11 @@ RaceDialog::RaceDialog(WindowManager& parWindowManager) // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); - backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onBackClicked); + backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onBackClicked); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onOkClicked); + okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onOkClicked); updateRaces(); updateSkills(); @@ -157,7 +157,7 @@ void RaceDialog::onBackClicked(MyGUI::Widget* _sender) eventBack(); } -void RaceDialog::onHeadRotate(MyGUI::VScroll*, size_t _position) +void RaceDialog::onHeadRotate(MyGUI::ScrollBar*, size_t _position) { // TODO: Rotate head } @@ -192,7 +192,7 @@ void RaceDialog::onSelectNextHair(MyGUI::Widget*) hairIndex = wrap(hairIndex - 1, hairCount); } -void RaceDialog::onSelectRace(MyGUI::List* _sender, size_t _index) +void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index) { if (_index == MyGUI::ITEM_NONE) return; diff --git a/apps/openmw/mwgui/race.hpp b/apps/openmw/mwgui/race.hpp index f2aac3a18..bcd3b5185 100644 --- a/apps/openmw/mwgui/race.hpp +++ b/apps/openmw/mwgui/race.hpp @@ -46,7 +46,7 @@ namespace MWGui void open(); // Events - typedef delegates::CDelegate0 EventHandle_Void; + typedef delegates::CMultiDelegate0 EventHandle_Void; /** Event : Back button clicked.\n signature : void method()\n @@ -54,7 +54,7 @@ namespace MWGui EventHandle_Void eventBack; protected: - void onHeadRotate(MyGUI::VScroll* _sender, size_t _position); + void onHeadRotate(MyGUI::ScrollBar* _sender, size_t _position); void onSelectPreviousGender(MyGUI::Widget* _sender); void onSelectNextGender(MyGUI::Widget* _sender); @@ -65,7 +65,7 @@ namespace MWGui void onSelectPreviousHair(MyGUI::Widget* _sender); void onSelectNextHair(MyGUI::Widget* _sender); - void onSelectRace(MyGUI::List* _sender, size_t _index); + void onSelectRace(MyGUI::ListBox* _sender, size_t _index); void onOkClicked(MyGUI::Widget* _sender); void onBackClicked(MyGUI::Widget* _sender); @@ -76,8 +76,8 @@ namespace MWGui void updateSpellPowers(); MyGUI::CanvasPtr appearanceBox; - MyGUI::ListPtr raceList; - MyGUI::HScrollPtr headRotate; + MyGUI::ListBox* raceList; + MyGUI::ScrollBar* headRotate; MyGUI::WidgetPtr skillList; std::vector skillItems; diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index e770ec235..cb0d9969c 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -28,22 +28,22 @@ ReviewDialog::ReviewDialog(WindowManager& parWindowManager) getWidget(nameWidget, "NameText"); getWidget(button, "NameButton"); button->setCaption(mWindowManager.getGameSettingString("sName", "")); - button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onNameClicked);; + button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onNameClicked);; getWidget(raceWidget, "RaceText"); getWidget(button, "RaceButton"); button->setCaption(mWindowManager.getGameSettingString("sRace", "")); - button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onRaceClicked);; + button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onRaceClicked);; getWidget(classWidget, "ClassText"); getWidget(button, "ClassButton"); button->setCaption(mWindowManager.getGameSettingString("sClass", "")); - button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onClassClicked);; + button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onClassClicked);; getWidget(birthSignWidget, "SignText"); getWidget(button, "SignButton"); button->setCaption(mWindowManager.getGameSettingString("sBirthSign", "")); - button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onBirthSignClicked);; + button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBirthSignClicked);; // Setup dynamic stats getWidget(health, "Health"); @@ -75,25 +75,25 @@ ReviewDialog::ReviewDialog(WindowManager& parWindowManager) getWidget(skillClientWidget, "SkillClient"); getWidget(skillScrollerWidget, "SkillScroller"); - skillScrollerWidget->eventScrollChangePosition = MyGUI::newDelegate(this, &ReviewDialog::onScrollChangePosition); + skillScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &ReviewDialog::onScrollChangePosition); updateScroller(); for (int i = 0; i < ESM::Skill::Length; ++i) { skillValues.insert(std::make_pair(i, MWMechanics::Stat())); - skillWidgetMap.insert(std::make_pair(i, static_cast (0))); + skillWidgetMap.insert(std::make_pair(i, static_cast (0))); } - static_cast(mMainWidget)->eventWindowChangeCoord = MyGUI::newDelegate(this, &ReviewDialog::onWindowResize); + static_cast(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &ReviewDialog::onWindowResize); // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); - backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onBackClicked); + backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBackClicked); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onOkClicked); + okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onOkClicked); } void ReviewDialog::open() @@ -102,7 +102,7 @@ void ReviewDialog::open() setVisible(true); } -void ReviewDialog::onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos) +void ReviewDialog::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos) { int diff = lastPos - pos; // Adjust position of all widget according to difference @@ -176,7 +176,7 @@ void ReviewDialog::setAttribute(ESM::Attribute::AttributeID attributeId, const M void ReviewDialog::setSkillValue(ESM::Skill::SkillEnum skillId, const MWMechanics::Stat& value) { skillValues[skillId] = value; - MyGUI::StaticTextPtr widget = skillWidgetMap[skillId]; + MyGUI::TextBox* widget = skillWidgetMap[skillId]; if (widget) { float modified = value.getModified(), base = value.getBase(); @@ -210,7 +210,7 @@ void ReviewDialog::configureSkills(const std::vector& major, const std::vec } } -void ReviewDialog::setStyledText(MyGUI::StaticTextPtr widget, ColorStyle style, const std::string &value) +void ReviewDialog::setStyledText(MyGUI::TextBox* widget, ColorStyle style, const std::string &value) { widget->setCaption(value); if (style == CS_Super) @@ -223,7 +223,7 @@ void ReviewDialog::setStyledText(MyGUI::StaticTextPtr widget, ColorStyle style, void ReviewDialog::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { - MyGUI::StaticImagePtr separator = skillClientWidget->createWidget("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Default); + MyGUI::ImageBox* separator = skillClientWidget->createWidget("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Default); skillWidgets.push_back(separator); coord1.top += separator->getHeight(); @@ -232,7 +232,7 @@ void ReviewDialog::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2 void ReviewDialog::addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { - MyGUI::StaticTextPtr groupWidget = skillClientWidget->createWidget("SandBrightText", MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Default); + MyGUI::TextBox* groupWidget = skillClientWidget->createWidget("SandBrightText", MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Default); groupWidget->setCaption(label); skillWidgets.push_back(groupWidget); @@ -240,14 +240,15 @@ void ReviewDialog::addGroup(const std::string &label, MyGUI::IntCoord &coord1, M coord2.top += lineHeight; } -MyGUI::StaticTextPtr ReviewDialog::addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) +MyGUI::TextBox* ReviewDialog::addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { - MyGUI::StaticTextPtr skillNameWidget, skillValueWidget; + MyGUI::TextBox* skillNameWidget; + MyGUI::TextBox* skillValueWidget; - skillNameWidget = skillClientWidget->createWidget("SandText", coord1, MyGUI::Align::Default); + skillNameWidget = skillClientWidget->createWidget("SandText", coord1, MyGUI::Align::Default); skillNameWidget->setCaption(text); - skillValueWidget = skillClientWidget->createWidget("SandTextRight", coord2, MyGUI::Align::Default); + skillValueWidget = skillClientWidget->createWidget("SandTextRight", coord2, MyGUI::Align::Default); setStyledText(skillValueWidget, style, value); skillWidgets.push_back(skillNameWidget); @@ -261,9 +262,9 @@ MyGUI::StaticTextPtr ReviewDialog::addValueItem(const std::string text, const st void ReviewDialog::addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { - MyGUI::StaticTextPtr skillNameWidget; + MyGUI::TextBox* skillNameWidget; - skillNameWidget = skillClientWidget->createWidget("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default); + skillNameWidget = skillClientWidget->createWidget("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default); skillNameWidget->setCaption(text); skillWidgets.push_back(skillNameWidget); @@ -299,7 +300,7 @@ void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId style = CS_Super; else if (modified < base) style = CS_Sub; - MyGUI::StaticTextPtr widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast(static_cast(modified)), style, coord1, coord2); + MyGUI::TextBox* widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast(static_cast(modified)), style, coord1, coord2); skillWidgetMap[skillId] = widget; } } diff --git a/apps/openmw/mwgui/review.hpp b/apps/openmw/mwgui/review.hpp index 5846804f7..588c1b6b5 100644 --- a/apps/openmw/mwgui/review.hpp +++ b/apps/openmw/mwgui/review.hpp @@ -49,8 +49,8 @@ namespace MWGui void open(); // Events - typedef delegates::CDelegate0 EventHandle_Void; - typedef delegates::CDelegate1 EventHandle_Int; + typedef delegates::CMultiDelegate0 EventHandle_Void; + typedef delegates::CMultiDelegate1 EventHandle_Int; /** Event : Back button clicked.\n signature : void method()\n @@ -75,23 +75,23 @@ namespace MWGui CS_Normal, CS_Super }; - void setStyledText(MyGUI::StaticTextPtr widget, ColorStyle style, const std::string &value); + void setStyledText(MyGUI::TextBox* widget, ColorStyle style, const std::string &value); void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); - MyGUI::StaticTextPtr addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); + MyGUI::TextBox* addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void updateScroller(); void updateSkillArea(); - void onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos); + void onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos); void onWindowResize(MyGUI::Window* window); static const int lineHeight; - MyGUI::StaticTextPtr nameWidget, raceWidget, classWidget, birthSignWidget; + MyGUI::TextBox *nameWidget, *raceWidget, *classWidget, *birthSignWidget; MyGUI::WidgetPtr skillAreaWidget, skillClientWidget; - MyGUI::VScrollPtr skillScrollerWidget; + MyGUI::ScrollBar* skillScrollerWidget; int lastPos, clientHeight; Widgets::MWDynamicStatPtr health, magicka, fatigue; @@ -100,7 +100,7 @@ namespace MWGui SkillList majorSkills, minorSkills, miscSkills; std::map > skillValues; - std::map skillWidgetMap; + std::map skillWidgetMap; std::string name, raceId, birthSignId; ESM::Class klass; std::vector skillWidgets; //< Skills and other information diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 30a4015e3..243b6272a 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -48,20 +48,20 @@ StatsWindow::StatsWindow (WindowManager& parWindowManager) getWidget(skillClientWidget, "SkillClient"); getWidget(skillScrollerWidget, "SkillScroller"); - skillScrollerWidget->eventScrollChangePosition = MyGUI::newDelegate(this, &StatsWindow::onScrollChangePosition); + skillScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &StatsWindow::onScrollChangePosition); updateScroller(); for (int i = 0; i < ESM::Skill::Length; ++i) { skillValues.insert(std::pair >(i, MWMechanics::Stat())); - skillWidgetMap.insert(std::pair(i, nullptr)); + skillWidgetMap.insert(std::pair(i, nullptr)); } MyGUI::WindowPtr t = static_cast(mMainWidget); - t->eventWindowChangeCoord = MyGUI::newDelegate(this, &StatsWindow::onWindowResize); + t->eventWindowChangeCoord += MyGUI::newDelegate(this, &StatsWindow::onWindowResize); } -void StatsWindow::onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos) +void StatsWindow::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos) { int diff = lastPos - pos; // Adjust position of all widget according to difference @@ -95,10 +95,10 @@ void StatsWindow::setBar(const std::string& name, const std::string& tname, int void StatsWindow::setPlayerName(const std::string& playerName) { - mMainWidget->setCaption(playerName); + static_cast(mMainWidget)->setCaption(playerName); } -void StatsWindow::setStyledText(MyGUI::StaticTextPtr widget, ColorStyle style, const std::string &value) +void StatsWindow::setStyledText(MyGUI::TextBox* widget, ColorStyle style, const std::string &value) { widget->setCaption(value); if (style == CS_Super) @@ -175,7 +175,7 @@ void StatsWindow::setValue (const std::string& id, int value) void StatsWindow::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat& value) { skillValues[parSkill] = value; - MyGUI::StaticTextPtr widget = skillWidgetMap[(int)parSkill]; + MyGUI::TextBox* widget = skillWidgetMap[(int)parSkill]; if (widget) { float modified = value.getModified(), base = value.getBase(); @@ -221,7 +221,7 @@ void StatsWindow::setBirthSign (const std::string& signId) void StatsWindow::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { - MyGUI::StaticImagePtr separator = skillClientWidget->createWidget("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Default); + MyGUI::ImageBox* separator = skillClientWidget->createWidget("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Default); skillWidgets.push_back(separator); coord1.top += separator->getHeight(); @@ -230,7 +230,7 @@ void StatsWindow::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { - MyGUI::StaticTextPtr groupWidget = skillClientWidget->createWidget("SandBrightText", MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Default); + MyGUI::TextBox* groupWidget = skillClientWidget->createWidget("SandBrightText", MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Default); groupWidget->setCaption(label); skillWidgets.push_back(groupWidget); @@ -238,14 +238,14 @@ void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, My coord2.top += lineHeight; } -MyGUI::StaticTextPtr StatsWindow::addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) +MyGUI::TextBox* StatsWindow::addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { - MyGUI::StaticTextPtr skillNameWidget, skillValueWidget; + MyGUI::TextBox *skillNameWidget, *skillValueWidget; - skillNameWidget = skillClientWidget->createWidget("SandText", coord1, MyGUI::Align::Default); + skillNameWidget = skillClientWidget->createWidget("SandText", coord1, MyGUI::Align::Default); skillNameWidget->setCaption(text); - skillValueWidget = skillClientWidget->createWidget("SandTextRight", coord2, MyGUI::Align::Default); + skillValueWidget = skillClientWidget->createWidget("SandTextRight", coord2, MyGUI::Align::Default); setStyledText(skillValueWidget, style, value); skillWidgets.push_back(skillNameWidget); @@ -259,9 +259,9 @@ MyGUI::StaticTextPtr StatsWindow::addValueItem(const std::string text, const std void StatsWindow::addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { - MyGUI::StaticTextPtr skillNameWidget; + MyGUI::TextBox* skillNameWidget; - skillNameWidget = skillClientWidget->createWidget("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default); + skillNameWidget = skillClientWidget->createWidget("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default); skillNameWidget->setCaption(text); skillWidgets.push_back(skillNameWidget); @@ -297,7 +297,7 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, style = CS_Super; else if (modified < base) style = CS_Sub; - MyGUI::StaticTextPtr widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast(static_cast(modified)), style, coord1, coord2); + MyGUI::TextBox* widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast(static_cast(modified)), style, coord1, coord2); skillWidgetMap[skillId] = widget; } } diff --git a/apps/openmw/mwgui/stats_window.hpp b/apps/openmw/mwgui/stats_window.hpp index 9db5c240b..2ff170f57 100644 --- a/apps/openmw/mwgui/stats_window.hpp +++ b/apps/openmw/mwgui/stats_window.hpp @@ -49,26 +49,26 @@ namespace MWGui CS_Normal, CS_Super }; - void setStyledText(MyGUI::StaticTextPtr widget, ColorStyle style, const std::string &value); + void setStyledText(MyGUI::TextBox* widget, ColorStyle style, const std::string &value); void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); - MyGUI::StaticTextPtr addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); + MyGUI::TextBox* addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void updateScroller(); - void onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos); + void onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos); void onWindowResize(MyGUI::Window* window); static const int lineHeight; MyGUI::WidgetPtr skillAreaWidget, skillClientWidget; - MyGUI::VScrollPtr skillScrollerWidget; + MyGUI::ScrollBar* skillScrollerWidget; int lastPos, clientHeight; SkillList majorSkills, minorSkills, miscSkills; std::map > skillValues; - std::map skillWidgetMap; + std::map skillWidgetMap; std::map factionWidgetMap; FactionList factions; ///< Stores a list of factions and the current rank std::string birthSignId; diff --git a/apps/openmw/mwgui/text_input.cpp b/apps/openmw/mwgui/text_input.cpp index 83ebef657..8ac07e766 100644 --- a/apps/openmw/mwgui/text_input.cpp +++ b/apps/openmw/mwgui/text_input.cpp @@ -10,12 +10,12 @@ TextInputDialog::TextInputDialog(WindowManager& parWindowManager) center(); getWidget(textEdit, "TextEdit"); - textEdit->eventEditSelectAccept = newDelegate(this, &TextInputDialog::onTextAccepted); + textEdit->eventEditSelectAccept += newDelegate(this, &TextInputDialog::onTextAccepted); // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &TextInputDialog::onOkClicked); + okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TextInputDialog::onOkClicked); // Make sure the edit box has focus MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit); diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index f62da2bab..74603aaf1 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -62,24 +62,24 @@ void MWSkill::updateWidgets() { if (skillId == ESM::Skill::Length) { - skillNameWidget->setCaption(""); + static_cast(skillNameWidget)->setCaption(""); } else { const std::string &name = manager->getGameSettingString(ESM::Skill::sSkillNameIds[skillId], ""); - skillNameWidget->setCaption(name); + static_cast(skillNameWidget)->setCaption(name); } } if (skillValueWidget) { SkillValue::Type modified = value.getModified(), base = value.getBase(); - skillValueWidget->setCaption(boost::lexical_cast(modified)); + static_cast(skillValueWidget)->setCaption(boost::lexical_cast(modified)); if (modified > base) - skillValueWidget->setState("increased"); + skillValueWidget->_setWidgetState("increased"); else if (modified < base) - skillValueWidget->setState("decreased"); + skillValueWidget->_setWidgetState("decreased"); else - skillValueWidget->setState("normal"); + skillValueWidget->_setWidgetState("normal"); } } @@ -88,59 +88,32 @@ void MWSkill::onClicked(MyGUI::Widget* _sender) eventClicked(this); } -void MWSkill::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name) -{ - Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name); - - initialiseWidgetSkin(_info); -} - MWSkill::~MWSkill() { - shutdownWidgetSkin(); } -void MWSkill::baseChangeWidgetSkin(ResourceSkin* _info) +void MWSkill::initialiseOverride() { - shutdownWidgetSkin(); - Base::baseChangeWidgetSkin(_info); - initialiseWidgetSkin(_info); -} + Base::initialiseOverride(); -void MWSkill::initialiseWidgetSkin(ResourceSkin* _info) -{ - for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter) + assignWidget(skillNameWidget, "StatName"); + assignWidget(skillValueWidget, "StatValue"); + + MyGUI::ButtonPtr button; + assignWidget(button, "StatNameButton"); + if (button) { - const std::string &name = *(*iter)->_getInternalData(); - if (name == "StatName") - { - MYGUI_DEBUG_ASSERT( ! skillNameWidget, "widget already assigned"); - skillNameWidget = (*iter)->castType(); - } - else if (name == "StatValue") - { - MYGUI_DEBUG_ASSERT( ! skillValueWidget, "widget already assigned"); - skillValueWidget = (*iter)->castType(); - } - else if (name == "StatNameButton") - { - MYGUI_DEBUG_ASSERT( ! skillNameWidget, "widget already assigned"); - MyGUI::ButtonPtr button = (*iter)->castType