From e72e336e2464295bb389c276b3de4334f12f22af Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Jan 2011 01:38:35 -0800 Subject: [PATCH 01/59] testing --- apps/openmw/mwclass/npc.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index c277832ab..a64db189b 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -53,9 +53,6 @@ namespace MWClass MWRender::Rendering rendering (cellRender, ref->ref); - - //TODO: define consts for each bodypart e.g. chest, foot, wrist... and put the parts in the - // right place const ESM::BodyPart *bodyPart = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); @@ -241,7 +238,6 @@ namespace MWClass cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers); } - //neck will reset chest counter if(neck) { cellRender.insertMesh ("meshes\\" + neck->model, Ogre::Vector3( 0, 0, 120), axis, Ogre::Radian(3.14), npcName + "neck", neckandup, neckNumbers); @@ -250,8 +246,9 @@ namespace MWClass cellRender.insertMesh (headModel, Ogre::Vector3( 0, 0, 5), axis, Ogre::Radian(0), npcName + "head", neckandup, neckNumbers); neckandup[neckNumbers++] = npcName + "head"; cellRender.insertMesh (hairModel, Ogre::Vector3( 0, -1, 0), axis, Ogre::Radian(0), npcName + "hair", neckandup, neckNumbers); + cellRender.insertMesh("meshes\\base_anim.nif"); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); - + // } void Npc::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const From ca9beb610d33124b4db0333889716fb4790906a9 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Jan 2011 01:59:57 -0800 Subject: [PATCH 02/59] Brainstorming --- apps/openmw/engine.cpp | 132 +++++++++---------------- apps/openmw/mwgui/layouts.cpp | 2 +- apps/openmw/mwgui/review.cpp | 2 +- components/nifogre/ogre_nif_loader.cpp | 58 +++++------ components/nifogre/ogre_nif_loader.hpp | 3 +- 5 files changed, 76 insertions(+), 121 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 9e14c119b..d0f09c214 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -42,6 +42,8 @@ #include "mwgui/class.hpp" + + //using namespace ESM; void OMW::Engine::executeLocalScripts() @@ -75,8 +77,8 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) std::string effect; - - + + MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayerPos().getPlayer().getCell(); //If the region has changed if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){ @@ -86,7 +88,7 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) total = 0; test = (ESM::Region) *(mEnvironment.mWorld->getStore().regions.find(current->cell->region)); } - + if(test.soundList.size() > 0) { std::vector::iterator soundIter = test.soundList.begin(); @@ -118,14 +120,14 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) //play sound std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n"; mEnvironment.mSoundManager->playSound(effect, 20.0, 1.0); - + break; } pos += chance; } } - + //mEnvironment.mSoundManager->playSound(effect, 1.0, 1.0); //printf("REGION: %s\n", test.name); @@ -194,7 +196,6 @@ OMW::Engine::Engine() , mVerboseScripts (false) , mNewGame (false) , mUseSound (true) - , mCompileAll (false) , mScriptManager (0) , mScriptContext (0) , mGuiManager (0) @@ -297,7 +298,7 @@ void OMW::Engine::go() test.name = ""; total = 0; - + std::cout << "Data directory: " << mDataDir << "\n"; @@ -307,6 +308,16 @@ void OMW::Engine::go() addResourcesDirectory (mDataDir / "Meshes"); addResourcesDirectory (mDataDir / "Textures"); + //boost::filesystem::copy_file("meshes\\b\\B_N_Argonian_F_Skins.nif",mDataDir / "b2\\B_N_Argonian_F_Skins.nif",boost::filesystem::copy_option::overwrite_if_exists); + /*CFileOperation fo; // create object + + fo.SetOverwriteMode(false); // reset OverwriteMode flag (optional) + + if (!fo.Copy("c:\\source", "c:\\dest")) // do Copy + { + fo.ShowError(); // if copy fails show error message + }*/ + // This has to be added BEFORE MyGUI is initialized, as it needs // to find core.xml here. @@ -327,7 +338,6 @@ void OMW::Engine::go() MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); // Create window manager - this manages all the MW-specific GUI windows MWScript::registerExtensions (mExtensions); @@ -361,20 +371,9 @@ void OMW::Engine::go() // load cell ESM::Position pos; + pos.pos[0] = pos.pos[1] = pos.pos[2] = 0; pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; - pos.pos[2] = 0; - - if (const ESM::Cell *exterior = mEnvironment.mWorld->getExterior (mCellName)) - { - mEnvironment.mWorld->indexToPosition (exterior->data.gridX, exterior->data.gridY, - pos.pos[0], pos.pos[1], true); - mEnvironment.mWorld->changeToExteriorCell (pos); - } - else - { - pos.pos[0] = pos.pos[1] = 0; - mEnvironment.mWorld->changeCell (mCellName, pos); - } + mEnvironment.mWorld->changeCell (mCellName, pos); // Sets up the input system MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayerPos(), @@ -390,29 +389,6 @@ void OMW::Engine::go() // Play some good 'ol tunes mEnvironment.mSoundManager->startRandomTitle(); - // scripts - if (mCompileAll) - { - typedef ESMS::ScriptListT::MapType Container; - - Container scripts = mEnvironment.mWorld->getStore().scripts.list; - - int count = 0; - int success = 0; - - for (Container::const_iterator iter (scripts.begin()); iter!=scripts.end(); ++iter, ++count) - if (mScriptManager->compile (iter->first)) - ++success; - - if (count) - std::cout - << "compiled " << success << " of " << count << " scripts (" - << 100*static_cast (success)/count - << "%)" - << std::endl; - - } - // Start the main rendering loop mOgre.start(); @@ -421,49 +397,35 @@ void OMW::Engine::go() void OMW::Engine::activate() { - // TODO: This is only a workaround. The input dispatcher should catch any exceptions thrown inside - // the input handling functions. Looks like this will require an OpenEngine modification. - try + std::string handle = mEnvironment.mWorld->getFacedHandle(); + + if (handle.empty()) + return; + + MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle); + + if (ptr.isEmpty()) + return; + + MWScript::InterpreterContext interpreterContext (mEnvironment, + &ptr.getRefData().getLocals(), ptr); + + boost::shared_ptr action = + MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayerPos().getPlayer(), + mEnvironment); + + interpreterContext.activate (ptr, action); + + std::string script = MWWorld::Class::get (ptr).getScript (ptr); + + if (!script.empty()) { - std::string handle = mEnvironment.mWorld->getFacedHandle(); - - if (handle.empty()) - return; - - MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle); - - if (ptr.isEmpty()) - return; - - MWScript::InterpreterContext interpreterContext (mEnvironment, - &ptr.getRefData().getLocals(), ptr); - - boost::shared_ptr action = - MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayerPos().getPlayer(), - mEnvironment); - - interpreterContext.activate (ptr, action); - - std::string script = MWWorld::Class::get (ptr).getScript (ptr); - - if (!script.empty()) - { - mIgnoreLocalPtr = ptr; - mScriptManager->run (script, interpreterContext); - } - - if (!interpreterContext.hasActivationBeenHandled()) - { - interpreterContext.executeActivation(); - } + mIgnoreLocalPtr = ptr; + mScriptManager->run (script, interpreterContext); } - catch (const std::exception& e) + + if (!interpreterContext.hasActivationBeenHandled()) { - std::cerr << "Activation failed: " << e.what() << std::endl; + interpreterContext.executeActivation(); } } - -void OMW::Engine::setCompileAll (bool all) -{ - mCompileAll = all; -} diff --git a/apps/openmw/mwgui/layouts.cpp b/apps/openmw/mwgui/layouts.cpp index 501b234d1..e03805e65 100644 --- a/apps/openmw/mwgui/layouts.cpp +++ b/apps/openmw/mwgui/layouts.cpp @@ -55,7 +55,7 @@ StatsWindow::StatsWindow (MWWorld::Environment& environment) 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, (MyGUI::StaticTextPtr) nullptr)); } MyGUI::WindowPtr t = static_cast(mMainWidget); diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index 9eb6092ce..6caba6238 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -80,7 +80,7 @@ ReviewDialog::ReviewDialog(MWWorld::Environment& environment) 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, (MyGUI::StaticTextPtr)nullptr)); } static_cast(mMainWidget)->eventWindowChangeCoord = MyGUI::newDelegate(this, &ReviewDialog::onWindowResize); diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index fc205d387..7d4731b82 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -728,8 +728,6 @@ void NIFLoader::handleNode(Nif::Node *node, int flags, const Transformation *trafo, BoundsFinder &bounds, Bone *parentBone) { stack++; - //if( MWClass::isChest) - // cout << "u:" << node << "\n"; // Accumulate the flags from all the child nodes. This works for all // the flags we currently use, at least. flags |= node->flags; @@ -740,6 +738,10 @@ void NIFLoader::handleNode(Nif::Node *node, int flags, { // Get the next extra data in the list e = e->extra.getPtr(); + if(anim){ + cout << "RECNAME:" << e->recName.toString() << "RECTYPE:" << e->recType << "\n"; + cout << "THE:" << e; + } assert(e != NULL); if (e->recType == RC_NiStringExtraData) @@ -761,9 +763,21 @@ void NIFLoader::handleNode(Nif::Node *node, int flags, Bone *bone = 0; + //Contains the actual rotation, scale, and translation coordinate data + if(node->recType == RC_NiKeyframeData && anim) + { + + } + //Indicates the node that the data applies to + if(node->recType == RC_NiKeyframeController && anim) + { + + } + // create skeleton or add bones if (node->recType == RC_NiNode) { + //TODO: Store this variable, then read the KeyFrames //FIXME: "Bip01" isn't every time the root bone if (node->name == "Bip01" || node->name == "Root Bone") //root node, create a skeleton { @@ -779,6 +793,8 @@ void NIFLoader::handleNode(Nif::Node *node, int flags, if (!skel.isNull()) //if there is a skeleton { std::string name = node->name.toString(); + if (anim) + std::cout << "BONE:" << name << "\n"; //if (isBeast && isChest) // std::cout << "NAME: " << name << "\n"; // Quick-n-dirty workaround for the fact that several @@ -928,6 +944,13 @@ void NIFLoader::loadResource(Resource *resource) const std::string test22 ="meshes\\b\\B_N_Breton_M_Skins.nif"; const std::string test23 ="meshes\\b\\B_N_High Elf_F_Skins.nif"; const std::string test24 ="meshes\\b\\B_N_High Elf_M_Skins.nif"; + const std::string animfile = "meshes\\base_anim.nif"; + if (name == animfile){ + std::cout << "We have animation\n"; + anim = true; + } + else + anim = false; //std::cout <<"LEN1:" << test.length() << "TEST: " << test << "\n"; @@ -1087,47 +1110,16 @@ MeshPtr NIFLoader::load(const std::string &name, // Check if the resource already exists ResourcePtr ptr = m->getByName(name, group); MeshPtr resize; - - const std::string beast1 ="meshes\\b\\B_N_Khajiit_F_Skins.nif"; - const std::string beast2 ="meshes\\b\\B_N_Khajiit_M_Skins.nif"; - const std::string beast3 ="meshes\\b\\B_N_Argonian_F_Skins.nif"; - const std::string beast4 ="meshes\\b\\B_N_Argonian_M_Skins.nif"; - - const std::string beasttail1 ="tail\\b\\B_N_Khajiit_F_Skins.nif"; - const std::string beasttail2 ="tail\\b\\B_N_Khajiit_M_Skins.nif"; - const std::string beasttail3 ="tail\\b\\B_N_Argonian_F_Skins.nif"; - const std::string beasttail4 ="tail\\b\\B_N_Argonian_M_Skins.nif"; if (!ptr.isNull()){ - //if(pieces > 1) - //cout << "It exists\n"; resize = MeshPtr(ptr); - //resize->load(); - //resize->reload(); } else // Nope, create a new one. { resize = MeshManager::getSingleton().createManual(name, group, NIFLoader::getSingletonPtr()); - //cout <<"EXISTING" << name << "\n"; - - //if(pieces > 1) - //cout << "Creating it\n"; - - - //resize->load(); - //resize->reload(); - //return 0; ResourcePtr ptr = m->getByName(name, group); resize = MeshPtr(ptr); - - //NIFLoader::getSingletonPtr()-> - /*ResourcePtr ptr = m->getByName(name, group); - if (!ptr.isNull()){ - if(pieces > 1) - cout << "It exists\n"; - resize = MeshPtr(ptr);*/ - //return resize; } return resize; } diff --git a/components/nifogre/ogre_nif_loader.hpp b/components/nifogre/ogre_nif_loader.hpp index b2a6b50fd..8f88c0fdb 100644 --- a/components/nifogre/ogre_nif_loader.hpp +++ b/components/nifogre/ogre_nif_loader.hpp @@ -82,7 +82,7 @@ class NIFLoader : Ogre::ManualResourceLoader Ogre::Quaternion convertRotation(const Nif::Matrix& rot); private: - NIFLoader() : resourceGroup("General") { skincounter = 0; resourceName = "";} + NIFLoader() : resourceGroup("General") { skincounter = 0; resourceName = ""; anim = false;} NIFLoader(NIFLoader& n) {} void warn(std::string msg); @@ -128,6 +128,7 @@ class NIFLoader : Ogre::ManualResourceLoader bool isBeast; bool isHands; bool isFeet; + bool anim; int counter; int numbers; int stack; From d035441876e9678093f89e4f46bcfa820333549b Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Mon, 11 Apr 2011 20:56:06 -0400 Subject: [PATCH 03/59] Reintroducing animation --- components/nif/data.hpp | 238 +++++++++++++++++++++++-- components/nifogre/ogre_nif_loader.cpp | 165 +++++++++++++++++ components/nifogre/ogre_nif_loader.hpp | 4 + 3 files changed, 388 insertions(+), 19 deletions(-) diff --git a/components/nif/data.hpp b/components/nif/data.hpp index 6fc2c4b82..bc23c45ab 100644 --- a/components/nif/data.hpp +++ b/components/nif/data.hpp @@ -25,6 +25,8 @@ #define _NIF_DATA_H_ #include "controlled.hpp" +#include +#include namespace Nif { @@ -433,20 +435,91 @@ public: class NiKeyframeData : public Record { + + //Rotations + std::vector quats; + std::vector tbc; + std::vector rottime; + int rtype; + + //Translations + std::vector translist1; + std::vector translist2; + std::vector translist3; + std::vector transtbc; + std::vector transtime; + int ttype; + + //Scalings + + std::vector scalefactor; + std::vector scaletime; + std::vector forwards; + std::vector backwards; + std::vector tbcscale; + int stype; + public: + void read(NIFFile *nif) { // Rotations first int count = nif->getInt(); + //std::vector quat(count); + //std::vector rottime(count); + std::cout << "r"; if(count) { - int type = nif->getInt(); - if(type == 1) - nif->skip(count*4*5); // time + quaternion - else if(type == 3) - nif->skip(count*4*8); // rot1 + tension+bias+continuity - else if(type == 4) + //TYPE1 LINEAR_KEY + //TYPE2 QUADRATIC_KEY + //TYPE3 TBC_KEY + //TYPE4 XYZ_ROTATION_KEY + //TYPE5 UNKNOWN_KEY + rtype = nif->getInt(); + //std::cout << "Count: " << count << "Type: " << type << "\n"; + + if(rtype == 1) + { + //We need to actually read in these values instead of skipping them + //nif->skip(count*4*5); // time + quaternion + for (int i = 0; i < count; i++) { + float time = nif->getFloat(); + float w = nif->getFloat(); + float x = nif->getFloat(); + float y = nif->getFloat(); + float z = nif->getFloat(); + Ogre::Quaternion quat = Ogre::Quaternion(Ogre::Real(w), Ogre::Real(x), Ogre::Real(y), Ogre::Real(z)); + quats.push_back(quat); + rottime.push_back(time); + //if(time == 0.0 || time > 355.5) + // std::cout <<"Time:" << time << "W:" << w <<"X:" << x << "Y:" << y << "Z:" << z << "\n"; + } + } + else if(rtype == 3) + { //Example - node 116 in base_anim.nif + for (int i = 0; i < count; i++) { + float time = nif->getFloat(); + float w = nif->getFloat(); + float x = nif->getFloat(); + float y = nif->getFloat(); + float z = nif->getFloat(); + + float tbcx = nif->getFloat(); + float tbcy = nif->getFloat(); + float tbcz = nif->getFloat(); + Ogre::Quaternion quat = Ogre::Quaternion(Ogre::Real(w), Ogre::Real(x), Ogre::Real(y), Ogre::Real(z)); + Ogre::Vector3 vec = Ogre::Vector3(tbcx, tbcy, tbcz); + quats.push_back(quat); + rottime.push_back(time); + tbc.push_back(vec); + //if(time == 0.0 || time > 355.5) + // std::cout <<"Time:" << time << "W:" << w <<"X:" << x << "Y:" << y << "Z:" << z << "\n"; + } + + //nif->skip(count*4*8); // rot1 + tension+bias+continuity + } + else if(rtype == 4) { for(int j=0;jfail("Unknown rotation type in NiKeyframeData"); } + //first = false; // Then translation count = nif->getInt(); + if(count) { - int type = nif->getInt(); + ttype = nif->getInt(); - if(type == 1) nif->getFloatLen(count*4); // time + translation - else if(type == 2) - nif->getFloatLen(count*10); // trans1 + forward + backward - else if(type == 3) - nif->getFloatLen(count*7); // trans1 + tension,bias,continuity + //std::cout << "TransCount:" << count << " Type: " << type << "\n"; + if(ttype == 1) { + for (int i = 0; i < count; i++) { + float time = nif->getFloat(); + float x = nif->getFloat(); + float y = nif->getFloat(); + float z = nif->getFloat(); + Ogre::Vector3 trans = Ogre::Vector3(x, y, z); + translist1.push_back(trans); + transtime.push_back(time); + } + //nif->getFloatLen(count*4); // time + translation + } + else if(ttype == 2) + { //Example - node 116 in base_anim.nif + for (int i = 0; i < count; i++) { + float time = nif->getFloat(); + float x = nif->getFloat(); + float y = nif->getFloat(); + float z = nif->getFloat(); + float x2 = nif->getFloat(); + float y2 = nif->getFloat(); + float z2 = nif->getFloat(); + float x3 = nif->getFloat(); + float y3 = nif->getFloat(); + float z3 = nif->getFloat(); + Ogre::Vector3 trans = Ogre::Vector3(x, y, z); + Ogre::Vector3 trans2 = Ogre::Vector3(x2, y2, z2); + Ogre::Vector3 trans3 = Ogre::Vector3(x3, y3, z3); + transtime.push_back(time); + translist1.push_back(trans); + translist2.push_back(trans2); + translist3.push_back(trans3); + } + + //nif->getFloatLen(count*10); // trans1 + forward + backward + } + else if(ttype == 3){ + for (int i = 0; i < count; i++) { + float time = nif->getFloat(); + float x = nif->getFloat(); + float y = nif->getFloat(); + float z = nif->getFloat(); + float t = nif->getFloat(); + float b = nif->getFloat(); + float c = nif->getFloat(); + Ogre::Vector3 trans = Ogre::Vector3(x, y, z); + Ogre::Vector3 tbc = Ogre::Vector3(t, b, c); + translist1.push_back(trans); + transtbc.push_back(tbc); + transtime.push_back(time); + } + //nif->getFloatLen(count*7); // trans1 + tension,bias,continuity + } else nif->fail("Unknown translation type"); } @@ -484,17 +608,93 @@ public: count = nif->getInt(); if(count) { - int type = nif->getInt(); + stype = nif->getInt(); - int size = 0; - if(type == 1) size = 2; // time+scale - else if(type == 2) size = 4; // 1 + forward + backward (floats) - else if(type == 3) size = 5; // 1 + tbc - else nif->fail("Unknown scaling type"); - nif->getFloatLen(count*size); + + for(int i = 0; i < count; i++){ + + + //int size = 0; + if(stype >= 1 && stype < 4) + { + float time = nif->getFloat(); + float scale = nif->getFloat(); + scaletime.push_back(time); + scalefactor.push_back(scale); + //size = 2; // time+scale + } + else nif->fail("Unknown scaling type"); + if(stype == 2){ + //size = 4; // 1 + forward + backward (floats) + float forward = nif->getFloat(); + float backward = nif->getFloat(); + forwards.push_back(forward); + backwards.push_back(backward); + } + else if(stype == 3){ + float tbcx = nif->getFloat(); + float tbcy = nif->getFloat(); + float tbcz = nif->getFloat(); + Ogre::Vector3 vec = Ogre::Vector3(tbcx, tbcy, tbcz); + tbcscale.push_back(vec); + + //size = 5; // 1 + tbc + } + + } } + else + stype = 0; } + int getRtype(){ + return rtype; + } + int getStype(){ + return stype; + } + int getTtype(){ + return ttype; + } + std::vector getQuat(){ + return quats; + } + std::vector getrTbc(){ + return tbc; + } + std::vector getrTime(){ + return rottime; + } + + std::vector getTranslist1(){ + return translist1; + } + std::vector getTranslist2(){ + return translist2; + } + std::vector getTranslist3(){ + return translist3; + } + std::vector gettTime(){ + return transtime; + } + std::vector getScalefactor(){ + return scalefactor; + } + std::vector getForwards(){ + return forwards; + } + std::vector getBackwards(){ + return backwards; + } + std::vector getScaleTbc(){ + return tbcscale; + } + + std::vector getsTime(){ + return scaletime; + } }; + } // Namespace #endif diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index a33fde55a..3d63a9f98 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -1068,6 +1068,11 @@ void NIFLoader::loadResource(Resource *resource) // Handle the node handleNode(node, 0, NULL, bounds, 0); + + short handle = 0; + //skel->setBlendMode(Ogre::SkeletonAnimationBlendMode::ANIMBLEND_CUMULATIVE); + bool first = true; + // set the bounding value. if (bounds.isValid()) { @@ -1075,6 +1080,166 @@ void NIFLoader::loadResource(Resource *resource) bounds.maxX(), bounds.maxY(), bounds.maxZ())); mesh->_setBoundingSphereRadius(bounds.getRadius()); } + for(int i = 0; i < nif.numRecords(); i++) + { + + Nif::NiKeyframeController *f = dynamic_cast(nif.getRecord(i)); + Nif::Node *n = dynamic_cast(nif.getRecord(i)); + + + if(f != NULL) + { + Nif::NiKeyframeDataPtr data = f->data; + std::cout << "Controller's Rtype:" << data->getRtype() << "Stype: " << data->getStype() << "Ttype:" << data->getTtype() << "\n"; + + if(first){ + + float end = f->timeStop; + //std::cout <<"Creating WholeThing" << end << "\n"; + + //TRANSLATION + if(!mSkel.isNull()){ + std::cout <<"Creating WholeThing" << end << "\n"; + animcore = mSkel->createAnimation("WholeThing", end); + //animcore->setInterpolationMode(Ogre::Animation::IM_SPLINE); + //animcore->setRotationInterpolationMode(Ogre::Animation::RIM_SPHERICAL); + //animcore2->setRotationInterpolationMode(Ogre::Animation::RIM_LINEAR); + + //ROTATION + animcore2 = mSkel->createAnimation("WholeThing2", end); + //animcore2->setInterpolationMode(Ogre::Animation::IM_SPLINE); + //animcore2->setRotationInterpolationMode(Ogre::Animation::RIM_SPHERICAL); + } + std::cout <<"AFTER"; + first = false; + } + if(animcore && animcore2){ + Nif::Named *node = dynamic_cast ( f->target.getPtr()); + std::cout << "The target rec: " << node->name.toString() << "\n"; + Ogre::NodeAnimationTrack* mTrack = animcore->createNodeTrack(handle, mSkel->getBone(node->name.toString())); + Ogre::NodeAnimationTrack* mTrack2 = animcore2->createNodeTrack(handle++, mSkel->getBone(node->name.toString())); + /* if (node->recType == RC_NiNode) + { + NodeList &list = ((NiNode*)node)->children; + int n = list.length(); + + for (int i = n; i<=n; i++) + { + if(skel->hasBone((list[i]).name.toString())) + mTrack3 = animcore2->createNodeTrack(handle++, skel->getBone((list[i]).name.toString())); + + } + }*/ + + std::vector quats = data->getQuat(); + std::vector::iterator quatIter = quats.begin(); + std::vector rtime = data->getrTime(); + std::vector::iterator rtimeiter = rtime.begin(); + + std::vector ttime = data->gettTime(); + std::vector::iterator ttimeiter = ttime.begin(); + std::vector translist1 = data->getTranslist1(); + std::vector::iterator transiter = translist1.begin(); + std::vector translist2 = data->getTranslist2(); + std::vector::iterator transiter2 = translist2.begin(); + std::vector translist3 = data->getTranslist3(); + std::vector::iterator transiter3 = translist3.begin(); + + + float tleft = 0; + float rleft = 0.0; + float ttotal = 0.0; + float rtotal = 0; + Ogre::TransformKeyFrame* mKey; + Ogre::TransformKeyFrame* mKey2; + float tused = 0.0; + float rused = 0.0; + Ogre::Quaternion lastquat; + Ogre::Vector3 lasttrans; + bool rend = false; + bool tend = false; + Ogre::Quaternion test;// = (skel->getBone(node->name.toString()))->getOrientation(); + for (int j = 0 ; j < ttime.size(); j++) + { + if(data->getTtype() >= 1 && data->getTtype() <= 5) + { + + Ogre::TransformKeyFrame* mKey = mTrack->createNodeKeyFrame(*ttimeiter); + Ogre::Vector3 standard = *transiter; + if(data->getTtype() == 2) + standard = *transiter * *transiter2 * *transiter3; + + mKey->setTranslate(standard);/* + if(mTrack3) + { + Ogre::TransformKeyFrame* mKey3 = mTrack->createNodeKeyFrame(*ttimeiter); + mKey3->setTranslate(standard); + }*/ + //mKey->setRotation(Quaternion::ZERO); + //mKey->setScale(Ogre::Vector3(1,1,1)); + transiter++; //START + transiter2++; + transiter3++; + ttimeiter++; + } + } + for (int j = 0 ; j < rtime.size(); j++) + { + if(data->getRtype() >= 1 && data->getRtype() <= 5) + { + Ogre::TransformKeyFrame* mKey2 = mTrack2->createNodeKeyFrame(*rtimeiter); + test = *quatIter; + + mKey2->setRotation(test); + //mKey2->setTranslate(Ogre::Vector3(0,0,0)); + //mKey2->setScale(Ogre::Vector3(1,1,1)); + quatIter++; + rtimeiter++; + } + } + } + + + + + /* + //mTrack = animcore->createNodeTrack(handle++, skel->getBone(node->name.toString())); + + std::vector stime = data->getsTime(); + std::vector::iterator stimeiter = stime.begin(); + + std::vector sfactor = data->getScalefactor(); + std::vector::iterator sfactoriter = sfactor.begin(); + for (int i = 0 ; i < stime.size(); i++) + { + if(data->getStype() >= 1 && data->getStype() <= 5) + { + Ogre::TransformKeyFrame* mKey = mTrack->createNodeKeyFrame(*stimeiter); + mKey->setScale(Ogre::Vector3(*sfactoriter, *sfactoriter, *sfactoriter)); + + sfactoriter++; + stimeiter++; + } + } + */ + + + } + /* + else if (n != NULL) + { + std::cout << "handle" << handle << "\n"; + //handle++; + }*/ + } + + + + // set skeleton + if (!mSkel.isNull()) + { + mesh->_notifySkeleton(mSkel); + } // set skeleton // if (!skel.isNull()) diff --git a/components/nifogre/ogre_nif_loader.hpp b/components/nifogre/ogre_nif_loader.hpp index 6ab22aa2f..a619d3a3b 100644 --- a/components/nifogre/ogre_nif_loader.hpp +++ b/components/nifogre/ogre_nif_loader.hpp @@ -131,6 +131,10 @@ class NIFLoader : Ogre::ManualResourceLoader int counter; int numbers; int stack; + bool anim; + int handle2; + Ogre::Animation* animcore; + Ogre::Animation* animcore2; // pointer to the ogre mesh which is currently build From 2ac1cc8aee28cf6d8975c36a49648e0a7e149676 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Wed, 13 Apr 2011 20:16:46 -0400 Subject: [PATCH 04/59] Trying to animate creatures --- apps/openmw/engine.cpp | 48 ++++++++++++++++++++++++++ components/esm_store/cell_store.hpp | 3 ++ components/nifogre/ogre_nif_loader.cpp | 13 +++---- 3 files changed, 55 insertions(+), 9 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 78ddffbe8..a6cdd2838 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -7,6 +7,7 @@ #include #include +#include #include "components/esm/records.hpp" #include @@ -90,6 +91,53 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) std::string effect; MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayer().getPlayer().getCell(); + /* + ESMS::CellRefList::List creatureData = (current->creatures).list; + ESMS::CellRefList::List::iterator creaturedataiter = creatureData.begin(); + + for(int i = 0; i < creatureData.size(); i++) + { + //std::cout << "Testing" << i < "\n"; + ESMS::LiveCellRef item = *creaturedataiter; + Ogre::Entity* creaturemodel = item.model; + + if(evt.timeSinceLastFrame == 0) + creaturemodel->getSkeleton()->setBindingPose(); + creaturemodel->getSkeleton()->setBlendMode(Ogre::SkeletonAnimationBlendMode::ANIMBLEND_AVERAGE); //ANIMBLEND_AVERAGE + Ogre::AnimationState *mAnimationState = creaturemodel->getAnimationState("WholeThing"); + mAnimationState->setWeight(.5); + mAnimationState->setLoop(true); + //npcmodel->getSkeleton()-> + + mAnimationState->setEnabled(true); + + + + + Ogre::AnimationState *mAnimationState2 = creaturemodel->getAnimationState("WholeThing2"); + mAnimationState2->setLoop(true); + mAnimationState2->setWeight(.5); + mAnimationState2->setEnabled(true); + + mAnimationState2->createBlendMask(creaturemodel->getSkeleton()->getNumBones(),1); + mAnimationState->createBlendMask(creaturemodel->getSkeleton()->getNumBones(),1); + for(int j = 2; j < creaturemodel->getSkeleton()->getNumBones(); j++) + { + mAnimationState->setBlendMaskEntry(j,1); + mAnimationState2->setBlendMaskEntry(j,1); + } + // set skeleton + std::cout << "TimePosition:" << mAnimationState->getTimePosition() << "\n"; + + mAnimationState->addTime(evt.timeSinceLastFrame); + mAnimationState2->addTime(evt.timeSinceLastFrame); + //npcmodel->_updateAnimation(); + //mAnimationState2->setEnabled(true); + creaturedataiter++; + }*/ + + + //If the region has changed if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){ timer.restart(); diff --git a/components/esm_store/cell_store.hpp b/components/esm_store/cell_store.hpp index 43860dff3..a55bb3d0e 100644 --- a/components/esm_store/cell_store.hpp +++ b/components/esm_store/cell_store.hpp @@ -14,6 +14,7 @@ #include "components/esm/records.hpp" #include "components/esm/loadcell.hpp" #include +#include #include #include @@ -29,6 +30,8 @@ namespace ESMS // The object that this instance is based on. const X* base; + Ogre::Entity *model; + /* Information about this instance, such as 3D location and rotation and individual type-dependent data. */ diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index 3d63a9f98..a1254ed7f 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -1225,20 +1225,15 @@ void NIFLoader::loadResource(Resource *resource) } - /* - else if (n != NULL) - { - std::cout << "handle" << handle << "\n"; - //handle++; - }*/ + + //std::cout <"BE\n"; } - - // set skeleton - if (!mSkel.isNull()) + if (!mSkel.isNull() && mesh->isLoaded()) { mesh->_notifySkeleton(mSkel); + std::cout << "Skeleton notified\n"; } // set skeleton From 92509d3b70dd4f686caf8d9d9d449f86b258b125 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Wed, 13 Apr 2011 20:35:44 -0400 Subject: [PATCH 05/59] Trying to animate creatures --- apps/openmw/mwclass/creature.cpp | 2 +- apps/openmw/mwrender/cellimp.hpp | 2 ++ apps/openmw/mwrender/exterior.cpp | 15 +++++++++++++++ apps/openmw/mwrender/exterior.hpp | 2 ++ apps/openmw/mwrender/interior.cpp | 17 +++++++++++++++++ apps/openmw/mwrender/interior.hpp | 2 ++ 6 files changed, 39 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 8cde67671..5316c8267 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -34,7 +34,7 @@ namespace MWClass if (!model.empty()) { MWRender::Rendering rendering (cellRender, ref->ref); - cellRender.insertMesh ("meshes\\" + model); + cellRender.insertMesh("meshes\\" + model); cellRender.insertActorPhysics(); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); } diff --git a/apps/openmw/mwrender/cellimp.hpp b/apps/openmw/mwrender/cellimp.hpp index 272bfeeab..727c9d317 100644 --- a/apps/openmw/mwrender/cellimp.hpp +++ b/apps/openmw/mwrender/cellimp.hpp @@ -7,6 +7,7 @@ #include "../mwworld/refdata.hpp" #include +#include namespace Ogre { @@ -42,6 +43,7 @@ namespace MWRender virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst) = 0; virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements) = 0; virtual void insertMesh(const std::string &mesh) = 0; + //virtual Ogre::Entity* insertAndDeliverMesh(const std::string &mesh) = 0; virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements) = 0; diff --git a/apps/openmw/mwrender/exterior.cpp b/apps/openmw/mwrender/exterior.cpp index fe54af84a..aa712dede 100644 --- a/apps/openmw/mwrender/exterior.cpp +++ b/apps/openmw/mwrender/exterior.cpp @@ -273,6 +273,21 @@ std::string ExteriorCellRender::insertEnd (bool enable) return handle; } +/* +Ogre::Entity* ExteriorCellRender::insertAndDeliverMesh(const std::string &mesh) +{ + assert (insert); + + NIFLoader::load(mesh); + Entity *ent = mScene.getMgr()->createEntity(mesh); + ent->setDisplaySkeleton(true); + + + mInsert->attachObject(ent); + return ent; + +}*/ + // configure lighting according to cell void ExteriorCellRender::configureAmbient() diff --git a/apps/openmw/mwrender/exterior.hpp b/apps/openmw/mwrender/exterior.hpp index 93491f263..87659a213 100644 --- a/apps/openmw/mwrender/exterior.hpp +++ b/apps/openmw/mwrender/exterior.hpp @@ -6,6 +6,7 @@ #include "OgreColourValue.h" #include +#include namespace Ogre { @@ -70,6 +71,7 @@ namespace MWRender virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst); virtual void insertMesh(const std::string &mesh); + //virtual Ogre::Entity* insertAndDeliverMesh(const std::string &mesh); virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements); virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements); diff --git a/apps/openmw/mwrender/interior.cpp b/apps/openmw/mwrender/interior.cpp index dbacaacf9..d3ec9b442 100644 --- a/apps/openmw/mwrender/interior.cpp +++ b/apps/openmw/mwrender/interior.cpp @@ -180,6 +180,23 @@ void InteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, } } +/* +Ogre::Entity* InteriorCellRender::insertAndDeliverMesh(const std::string &mesh) +{ + + assert (insert); + + NIFLoader::load(mesh); + Entity *ent = scene.getMgr()->createEntity(mesh); + ent->setDisplaySkeleton(true); + + + insert->attachObject(ent); + return ent; + +}*/ + + void InteriorCellRender::insertMesh(const std::string &mesh) { assert (insert); diff --git a/apps/openmw/mwrender/interior.hpp b/apps/openmw/mwrender/interior.hpp index 7c4b2aaf1..f77d3358d 100644 --- a/apps/openmw/mwrender/interior.hpp +++ b/apps/openmw/mwrender/interior.hpp @@ -6,6 +6,7 @@ #include "OgreColourValue.h" #include +#include namespace Ogre { @@ -67,6 +68,7 @@ namespace MWRender virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements); virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements); /// insert a mesh related to the most recent insertBegin call. + //virtual Ogre::Entity* insertAndDeliverMesh(const std::string &mesh); virtual void insertMesh(const std::string &mesh); virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements); virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst); From 51b74c2f053b87fedadf71136648e63831a73382 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Mon, 23 May 2011 19:01:36 -0400 Subject: [PATCH 06/59] starting --- apps/openmw/engine.cpp | 1 + apps/openmw/mwclass/npc.cpp | 2 ++ apps/openmw/mwrender/interior.cpp | 6 ++++-- components/bsa/bsa_archive.cpp | 6 ++++++ components/bsa/bsa_archive.hpp | 1 + components/files/multidircollection.hpp | 6 ++++-- 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 244c63e51..6725497c1 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -296,6 +296,7 @@ void OMW::Engine::loadBSA() std::cout << "Adding " << iter->second.string() << std::endl; addBSA (iter->second.string()); } + } // add resources directory diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index bb5578f6d..2b5bbbc4d 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -118,6 +118,8 @@ namespace MWClass Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75); if (groin){ + cellRender.insertMesh("bald_MJ_hat.NIF"); //w/W_6th_Hammer.NIF + //bald_MJ_hat.NIF cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, kOgrePi, npcName + "groin", addresses, numbers); addresses2[numbers] = npcName + "groin"; addresses[numbers++] = npcName + "groin"; diff --git a/apps/openmw/mwrender/interior.cpp b/apps/openmw/mwrender/interior.cpp index d3ec9b442..09cce2f6d 100644 --- a/apps/openmw/mwrender/interior.cpp +++ b/apps/openmw/mwrender/interior.cpp @@ -200,8 +200,10 @@ Ogre::Entity* InteriorCellRender::insertAndDeliverMesh(const std::string &mesh) void InteriorCellRender::insertMesh(const std::string &mesh) { assert (insert); - - NIFLoader::load(mesh); + //if(mesh == "\\Meshes\\bald_MJ_hat.NIF") + // NIFLoader::load(mesh, ""); + //else + NIFLoader::load(mesh); MovableObject *ent = scene.getMgr()->createEntity(mesh); insert->attachObject(ent); diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index 4691eb546..643845e25 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -145,6 +145,7 @@ public: void destroyInstance( Archive* arch) { delete arch; } }; + static bool init = false; static void insertBSAFactory() { @@ -163,3 +164,8 @@ void addBSA(const std::string& name, const std::string& group) ResourceGroupManager::getSingleton(). addResourceLocation(name, "BSA", group); } +void addDir(const std::string& name, const std::string& group) +{ + ResourceGroupManager::getSingleton(). + addResourceLocation(name, "FileSystem", group); +} diff --git a/components/bsa/bsa_archive.hpp b/components/bsa/bsa_archive.hpp index bde6d9c3b..91fd2fe98 100644 --- a/components/bsa/bsa_archive.hpp +++ b/components/bsa/bsa_archive.hpp @@ -29,5 +29,6 @@ /// Add the given BSA file as an input archive in the Ogre resource /// system. void addBSA(const std::string& file, const std::string& group="General"); +void addDir(const std::string& file, const std::string& group="General"); #endif diff --git a/components/files/multidircollection.hpp b/components/files/multidircollection.hpp index bd0304e40..3f9ddad84 100644 --- a/components/files/multidircollection.hpp +++ b/components/files/multidircollection.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -21,11 +22,12 @@ namespace Files return left Date: Fri, 3 Jun 2011 20:28:47 -0400 Subject: [PATCH 07/59] Introducing Dir Archive --- apps/openmw/engine.cpp | 24 ++++++++------- apps/openmw/mwclass/npc.cpp | 2 +- components/bsa/bsa_archive.cpp | 54 +++++++++++++++++++++++++++++++++- 3 files changed, 68 insertions(+), 12 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 6725497c1..5c51ab513 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -111,16 +111,16 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) mAnimationState->setLoop(true); //npcmodel->getSkeleton()-> - mAnimationState->setEnabled(true); - + mAnimationState->setEnabled(true); + + + - - Ogre::AnimationState *mAnimationState2 = creaturemodel->getAnimationState("WholeThing2"); mAnimationState2->setLoop(true); mAnimationState2->setWeight(.5); - mAnimationState2->setEnabled(true); - + mAnimationState2->setEnabled(true); + mAnimationState2->createBlendMask(creaturemodel->getSkeleton()->getNumBones(),1); mAnimationState->createBlendMask(creaturemodel->getSkeleton()->getNumBones(),1); for(int j = 2; j < creaturemodel->getSkeleton()->getNumBones(); j++) @@ -130,11 +130,11 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) } // set skeleton std::cout << "TimePosition:" << mAnimationState->getTimePosition() << "\n"; - + mAnimationState->addTime(evt.timeSinceLastFrame); mAnimationState2->addTime(evt.timeSinceLastFrame); //npcmodel->_updateAnimation(); - //mAnimationState2->setEnabled(true); + //mAnimationState2->setEnabled(true); creaturedataiter++; }*/ @@ -297,6 +297,10 @@ void OMW::Engine::loadBSA() addBSA (iter->second.string()); } + std::string m = mDataDir.string(); + std::cout << "Data dir" << m << "\n"; + addDir(m); + } // add resources directory @@ -394,8 +398,8 @@ void OMW::Engine::go() mOgre.configure(!isFile(ogreCfg.c_str()), cfgUserDir, plugCfg, false); - addResourcesDirectory (mDataDir / "Meshes"); - addResourcesDirectory (mDataDir / "Textures"); + //addResourcesDirectory (mDataDir / "Meshes"); + //addResourcesDirectory (mDataDir / "Textures"); // This has to be added BEFORE MyGUI is initialized, as it needs // to find core.xml here. diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 2b5bbbc4d..6fab8841a 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -118,7 +118,7 @@ namespace MWClass Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75); if (groin){ - cellRender.insertMesh("bald_MJ_hat.NIF"); //w/W_6th_Hammer.NIF + //cellRender.insertMesh("Meshes/bald_MJ_hat.NIF"); //w/W_6th_Hammer.NIF //bald_MJ_hat.NIF cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, kOgrePi, npcName + "groin", addresses, numbers); addresses2[numbers] = npcName + "groin"; diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index 643845e25..552084c41 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -23,6 +23,7 @@ #include "bsa_archive.hpp" +#include #include #include #include @@ -33,6 +34,29 @@ using namespace Ogre; using namespace Mangle::Stream; /// An OGRE Archive wrapping a BSAFile archive +class DirArchive: public Ogre::FileSystemArchive +{ + //FileSystemArchive* arc; + public: + + DirArchive(const String& name) + : FileSystemArchive(name, "Dir") + { mType = "Dir";} + + bool isCaseSensitive() const { return false; } + + // The archive is loaded in the constructor, and never unloaded. + void load() {} + void unload() {} + + DataStreamPtr open(const String& filename, bool readonly = true) const + { + std::string copy = filename; + return FileSystemArchive::open(copy, readonly); + } + +}; + class BSAArchive : public Archive { BSAFile arc; @@ -145,8 +169,26 @@ public: void destroyInstance( Archive* arch) { delete arch; } }; +class DirArchiveFactory : public FileSystemArchiveFactory +{ +public: + const String& getType() const + { + static String name = "Dir"; + return name; + } + + Archive *createInstance( const String& name ) + { + return new DirArchive(name); + } + + void destroyInstance( Archive* arch) { delete arch; } +}; + static bool init = false; +static bool init2 = false; static void insertBSAFactory() { if(!init) @@ -156,6 +198,15 @@ static void insertBSAFactory() } } +static void insertDirFactory() +{ + if(!init2) + { + ArchiveManager::getSingleton().addArchiveFactory( new DirArchiveFactory ); + init = true; + } +} + // The function below is the only publicly exposed part of this file void addBSA(const std::string& name, const std::string& group) @@ -166,6 +217,7 @@ void addBSA(const std::string& name, const std::string& group) } void addDir(const std::string& name, const std::string& group) { + insertDirFactory(); ResourceGroupManager::getSingleton(). - addResourceLocation(name, "FileSystem", group); + addResourceLocation(name, "Dir", group); } From 2aaa0f4578976fb09c05a2cfa1a70a777ad33806 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 4 Jun 2011 01:29:57 -0400 Subject: [PATCH 08/59] Backslash working in linux --- apps/openmw/engine.cpp | 2 ++ apps/openmw/mwclass/npc.cpp | 2 +- components/bsa/bsa_archive.cpp | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 5c51ab513..a899a5aea 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -300,6 +300,8 @@ void OMW::Engine::loadBSA() std::string m = mDataDir.string(); std::cout << "Data dir" << m << "\n"; addDir(m); + //std::string s = "f\n"; + //std::cout <<"S: " << s.size() << "\n"; } diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 6fab8841a..c6d092253 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -118,7 +118,7 @@ namespace MWClass Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75); if (groin){ - //cellRender.insertMesh("Meshes/bald_MJ_hat.NIF"); //w/W_6th_Hammer.NIF + cellRender.insertMesh("Meshes\\bald_MJ_hat.NIF"); //w/W_6th_Hammer.NIF //bald_MJ_hat.NIF cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, kOgrePi, npcName + "groin", addresses, numbers); addresses2[numbers] = npcName + "groin"; diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index 552084c41..93bde48e3 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -49,9 +49,33 @@ class DirArchive: public Ogre::FileSystemArchive void load() {} void unload() {} + bool exists(const String& filename) { + std::string copy = filename; + if(OGRE_PLATFORM != OGRE_PLATFORM_WIN32) + { + + for (int i = 0; i < filename.size(); i++) + { + if(copy.at(i) == '\\' ){ + copy.replace(i, 1, "/"); + } + } + } + return FileSystemArchive::exists(copy); + } + DataStreamPtr open(const String& filename, bool readonly = true) const { std::string copy = filename; + if(OGRE_PLATFORM != OGRE_PLATFORM_WIN32){ + //std::cout << "In Open\n"; + for (int i = 0; i < filename.size(); i++) + { + if(copy.at(i) == '\\' ){ + copy.replace(i, 1, "/"); + } + } + } return FileSystemArchive::open(copy, readonly); } From f2a0fa8af2f08e21fe7abf988660ededa8d6524e Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sun, 5 Jun 2011 23:46:18 -0400 Subject: [PATCH 09/59] Adding files to directory map --- apps/openmw/mwclass/npc.cpp | 2 +- components/bsa/bsa_archive.cpp | 58 ++++++++++++++++++++++++++++++++-- components/bsa/bsa_archive.hpp | 1 + 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index c6d092253..6a186b92e 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -118,7 +118,7 @@ namespace MWClass Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75); if (groin){ - cellRender.insertMesh("Meshes\\bald_MJ_hat.NIF"); //w/W_6th_Hammer.NIF + cellRender.insertMesh("Meshes\\joker\\bald_MJ_hat.nif"); //w/W_6th_Hammer.NIF //bald_MJ_hat.NIF cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, kOgrePi, npcName + "groin", addresses, numbers); addresses2[numbers] = npcName + "groin"; diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index 93bde48e3..5b5ff6511 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -36,12 +36,42 @@ using namespace Mangle::Stream; /// An OGRE Archive wrapping a BSAFile archive class DirArchive: public Ogre::FileSystemArchive { - //FileSystemArchive* arc; + + boost::filesystem::path currentdir; + std::map > m; + public: DirArchive(const String& name) : FileSystemArchive(name, "Dir") - { mType = "Dir";} + { mType = "Dir"; + currentdir = name; + + populateMap(currentdir); + + } + void populateMap(boost::filesystem::path d){ + //need to cut off first + boost::filesystem::directory_iterator dir_iter(d), dir_end; + std::vector filesind; + boost::filesystem::path f; + for(;dir_iter != dir_end; dir_iter++) + { + if(boost::filesystem::is_directory(*dir_iter)) + populateMap(*dir_iter); + else + { + + f = *dir_iter; + std::string s = f.string(); + filesind.push_back(s); + //std::cout << "File: " << s << "\n"; + } + } + m[d.string()] = filesind; + std::cout << "Directory: " << d.string() << filesind.size() << "\n"; + + } bool isCaseSensitive() const { return false; } @@ -50,6 +80,11 @@ class DirArchive: public Ogre::FileSystemArchive void unload() {} bool exists(const String& filename) { + //String s = filename; + //FileSystemArchive::findFiles(s, true, false, filenames.getPointer(), f.getPointer()); + // std::cout << "Filenames" << filenames.useCount() << "\n"; + + std::string copy = filename; if(OGRE_PLATFORM != OGRE_PLATFORM_WIN32) { @@ -61,6 +96,23 @@ class DirArchive: public Ogre::FileSystemArchive } } } + boost::filesystem::path p = copy; + + int last = copy.size() - 1; + int i = last; + + for (;last >= 0; i--) + { + if(copy.at(i) == '/' || copy.at(i) == '\\') + break; + } + std::string folder; + + folder = copy.substr(0, i); + + boost::filesystem::path folderpath = folder; + std::cout << "\nFull:" << p.string() << "\n"<< "Part:" << folderpath.string(); + return FileSystemArchive::exists(copy); } @@ -227,7 +279,7 @@ static void insertDirFactory() if(!init2) { ArchiveManager::getSingleton().addArchiveFactory( new DirArchiveFactory ); - init = true; + init2 = true; } } diff --git a/components/bsa/bsa_archive.hpp b/components/bsa/bsa_archive.hpp index 91fd2fe98..405856e8c 100644 --- a/components/bsa/bsa_archive.hpp +++ b/components/bsa/bsa_archive.hpp @@ -22,6 +22,7 @@ */ #include +#include #ifndef _BSA_ARCHIVE_H_ #define _BSA_ARCHIVE_H_ From 45453fd7a95276c69479484f8a74d2d4541b1538 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Mon, 6 Jun 2011 20:11:23 -0400 Subject: [PATCH 10/59] Case insensitive external loader working --- apps/openmw/mwclass/npc.cpp | 2 +- components/bsa/bsa_archive.cpp | 101 +++++++++++++++++++++++++++++---- components/bsa/bsa_archive.hpp | 2 + 3 files changed, 93 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 6a186b92e..8eaa9d614 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -118,7 +118,7 @@ namespace MWClass Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75); if (groin){ - cellRender.insertMesh("Meshes\\joker\\bald_MJ_hat.nif"); //w/W_6th_Hammer.NIF + cellRender.insertMesh("MeSHes\\1\\red_MJ_hat_org.NIF"); //w/W_6th_Hammer.NIF //bald_MJ_hat.NIF cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, kOgrePi, npcName + "groin", addresses, numbers); addresses2[numbers] = npcName + "groin"; diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index 5b5ff6511..13858d405 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -33,12 +33,21 @@ using namespace Ogre; using namespace Mangle::Stream; +struct ciLessBoost : std::binary_function +{ + bool operator() (const std::string & s1, const std::string & s2) const { + //case insensitive version of is_less + return lexicographical_compare(s1, s2, boost::algorithm::is_iless()); + } +}; + /// An OGRE Archive wrapping a BSAFile archive class DirArchive: public Ogre::FileSystemArchive { boost::filesystem::path currentdir; - std::map > m; + std::map, ciLessBoost> m; + int cutoff; public: @@ -46,6 +55,9 @@ class DirArchive: public Ogre::FileSystemArchive : FileSystemArchive(name, "Dir") { mType = "Dir"; currentdir = name; + std::string s = name; + cutoff = s.size() + 1; + //std::cout << "Cut off:" << cutoff; populateMap(currentdir); @@ -64,12 +76,26 @@ class DirArchive: public Ogre::FileSystemArchive f = *dir_iter; std::string s = f.string(); - filesind.push_back(s); - //std::cout << "File: " << s << "\n"; + + std::string small; + if(cutoff < s.size()) + small = s.substr(cutoff, s.size() - cutoff); + else + small = s.substr(cutoff - 1, s.size() - cutoff); + + filesind.push_back(small); + //std::cout << "File: " << small << "f\n"; } } - m[d.string()] = filesind; - std::cout << "Directory: " << d.string() << filesind.size() << "\n"; + std::string small; + std::string original = d.string(); + if(cutoff < original.size()) + small = original.substr(cutoff, original.size() - cutoff); + else + small = original.substr(cutoff - 1, original.size() - cutoff); + boost::filesystem::path smallp = small; + m[smallp.string()] = filesind; + //std::cout << "Directory: " << smallp.string() << " " << filesind.size() << "\n"; } @@ -80,6 +106,7 @@ class DirArchive: public Ogre::FileSystemArchive void unload() {} bool exists(const String& filename) { + //std::cout << "exists\n"; //String s = filename; //FileSystemArchive::findFiles(s, true, false, filenames.getPointer(), f.getPointer()); // std::cout << "Filenames" << filenames.useCount() << "\n"; @@ -106,21 +133,40 @@ class DirArchive: public Ogre::FileSystemArchive if(copy.at(i) == '/' || copy.at(i) == '\\') break; } - std::string folder; - folder = copy.substr(0, i); + std::string file = copy.substr(i + 1, copy.size() - i); //filename with no slash + std::string folder = copy.substr(0, i); //folder with no slash + std::transform(file.begin(), file.end(), file.begin(), tolower); boost::filesystem::path folderpath = folder; - std::cout << "\nFull:" << p.string() << "\n"<< "Part:" << folderpath.string(); + std::vector current = m[folderpath.string()]; + + for(std::vector::iterator iter = current.begin(); iter != current.end(); iter++) + { + std::string loopfile = iter->substr(i + 1, copy.size() - i); //filename with no slash + std::transform(loopfile.begin(), loopfile.end(), loopfile.begin(), tolower); + if(file.compare(loopfile) == 0){ + std::cout << "Loopfile:" << loopfile << "\n"; + return FileSystemArchive::exists(*iter); + } + } + + //std::cout << "Filename:" << file << "\n"; + //std::cout << "Full:" << p.string() << "\n"; + //std::cout << "Current:" << folder << "size: " << current.size() << "\n"; + //std::cout << "\nFull:" << p.string() << "\n"<< "Part:" << folderpath.string(); return FileSystemArchive::exists(copy); } DataStreamPtr open(const String& filename, bool readonly = true) const { - std::string copy = filename; - if(OGRE_PLATFORM != OGRE_PLATFORM_WIN32){ - //std::cout << "In Open\n"; + std::map, ciLessBoost> mlocal = m; + //std::cout << "Open\n"; + std::string copy = filename; + if(OGRE_PLATFORM != OGRE_PLATFORM_WIN32) + { + for (int i = 0; i < filename.size(); i++) { if(copy.at(i) == '\\' ){ @@ -128,6 +174,39 @@ class DirArchive: public Ogre::FileSystemArchive } } } + boost::filesystem::path p = copy; + + int last = copy.size() - 1; + int i = last; + + for (;last >= 0; i--) + { + if(copy.at(i) == '/' || copy.at(i) == '\\') + break; + } + + std::string file = copy.substr(i + 1, copy.size() - i); //filename with no slash + std::string folder = copy.substr(0, i); //folder with no slash + + std::transform(file.begin(), file.end(), file.begin(), tolower); + boost::filesystem::path folderpath = folder; + std::vector current = mlocal[folderpath.string()]; + + for(std::vector::iterator iter = current.begin(); iter != current.end(); iter++) + { + std::string loopfile = iter->substr(i + 1, copy.size() - i); //filename with no slash + std::transform(loopfile.begin(), loopfile.end(), loopfile.begin(), tolower); + if(file.compare(loopfile) == 0){ + std::cout << "Loopfile:" << loopfile << "\n"; + return FileSystemArchive::open(*iter, readonly); + } + } + + //std::cout << "Filename:" << file << "\n"; + //std::cout << "Full:" << p.string() << "\n"; + //std::cout << "Current:" << folder << "size: " << current.size() << "\n"; + //std::cout << "\nFull:" << p.string() << "\n"<< "Part:" << folderpath.string(); + return FileSystemArchive::open(copy, readonly); } diff --git a/components/bsa/bsa_archive.hpp b/components/bsa/bsa_archive.hpp index 405856e8c..a72f638e3 100644 --- a/components/bsa/bsa_archive.hpp +++ b/components/bsa/bsa_archive.hpp @@ -23,6 +23,8 @@ #include #include +#include +#include #ifndef _BSA_ARCHIVE_H_ #define _BSA_ARCHIVE_H_ From 4d31ca2c865f84883692077951b539bec7ecc99f Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Tue, 7 Jun 2011 17:17:25 -0400 Subject: [PATCH 11/59] Leading slashes now work, efficiency changes --- apps/openmw/mwclass/npc.cpp | 2 +- components/bsa/bsa_archive.cpp | 80 ++++++++++++++++++++++++---------- 2 files changed, 57 insertions(+), 25 deletions(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 8eaa9d614..285da5c5a 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -118,7 +118,7 @@ namespace MWClass Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75); if (groin){ - cellRender.insertMesh("MeSHes\\1\\red_MJ_hat_org.NIF"); //w/W_6th_Hammer.NIF + cellRender.insertMesh("MeSHes\\1\\red_MJ_hat_org.NIf"); //w/W_6th_Hammer.NIF //bald_MJ_hat.NIF cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, kOgrePi, npcName + "groin", addresses, numbers); addresses2[numbers] = npcName + "groin"; diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index 13858d405..ba7be5bfd 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -49,6 +49,18 @@ class DirArchive: public Ogre::FileSystemArchive std::map, ciLessBoost> m; int cutoff; + bool comparePortion(std::string file1, std::string file2, int start, int size) const + { + for(int i = start; i < start+size; i++) + { + char one = file1.at(i); + char two = file2.at(i); + if(tolower(one) != tolower(two) ) + return false; + } + return true; + } + public: DirArchive(const String& name) @@ -93,8 +105,8 @@ class DirArchive: public Ogre::FileSystemArchive small = original.substr(cutoff, original.size() - cutoff); else small = original.substr(cutoff - 1, original.size() - cutoff); - boost::filesystem::path smallp = small; - m[smallp.string()] = filesind; + //boost::filesystem::path smallp = small; + m[small] = filesind; //std::cout << "Directory: " << smallp.string() << " " << filesind.size() << "\n"; } @@ -113,6 +125,7 @@ class DirArchive: public Ogre::FileSystemArchive std::string copy = filename; + if(OGRE_PLATFORM != OGRE_PLATFORM_WIN32) { @@ -123,7 +136,17 @@ class DirArchive: public Ogre::FileSystemArchive } } } - boost::filesystem::path p = copy; + + if(copy.at(0) == '\\' || copy.at(0) == '/') + { + //std::cout << "Before:" << copy.size() << "\n"; + copy.erase(0, 1); + //std::cout << "The copy" << copy << "\n"; + //std::cout << "After:" << copy.size(); + } + + + //boost::filesystem::path p = copy; int last = copy.size() - 1; int i = last; @@ -134,19 +157,20 @@ class DirArchive: public Ogre::FileSystemArchive break; } - std::string file = copy.substr(i + 1, copy.size() - i); //filename with no slash + //std::string file = copy.substr(i + 1, copy.size() - i); //filename with no slash std::string folder = copy.substr(0, i); //folder with no slash - std::transform(file.begin(), file.end(), file.begin(), tolower); - boost::filesystem::path folderpath = folder; - std::vector current = m[folderpath.string()]; + //std::transform(file.begin(), file.end(), file.begin(), tolower); + //boost::filesystem::path folderpath = folder; + std::vector current = m[folder]; for(std::vector::iterator iter = current.begin(); iter != current.end(); iter++) { - std::string loopfile = iter->substr(i + 1, copy.size() - i); //filename with no slash - std::transform(loopfile.begin(), loopfile.end(), loopfile.begin(), tolower); - if(file.compare(loopfile) == 0){ - std::cout << "Loopfile:" << loopfile << "\n"; + //std::string loopfile = iter->substr(i + 1, copy.size() - i); //filename with no slash + //std::transform(loopfile.begin(), loopfile.end(), loopfile.begin(), tolower); + //std::string now = *iter; + if(comparePortion(*iter, copy, i + 1, copy.size() - i -1) == true){ + //std::cout << "Loopfile:" << copy << "\n"; return FileSystemArchive::exists(*iter); } } @@ -156,7 +180,7 @@ class DirArchive: public Ogre::FileSystemArchive //std::cout << "Current:" << folder << "size: " << current.size() << "\n"; //std::cout << "\nFull:" << p.string() << "\n"<< "Part:" << folderpath.string(); - return FileSystemArchive::exists(copy); + return false;//FileSystemArchive::exists(copy); } DataStreamPtr open(const String& filename, bool readonly = true) const @@ -164,6 +188,7 @@ class DirArchive: public Ogre::FileSystemArchive std::map, ciLessBoost> mlocal = m; //std::cout << "Open\n"; std::string copy = filename; + if(OGRE_PLATFORM != OGRE_PLATFORM_WIN32) { @@ -174,7 +199,15 @@ class DirArchive: public Ogre::FileSystemArchive } } } - boost::filesystem::path p = copy; + + if(copy.at(0) == '\\' || copy.at(0) == '/') + { + //std::cout << "Before:" << copy.size() << "\n"; + copy.erase(0, 1); + //std::cout << "The copy" << copy << "\n"; + //std::cout << "After:" << copy.size(); + } + //boost::filesystem::path p = copy; int last = copy.size() - 1; int i = last; @@ -185,19 +218,18 @@ class DirArchive: public Ogre::FileSystemArchive break; } - std::string file = copy.substr(i + 1, copy.size() - i); //filename with no slash - std::string folder = copy.substr(0, i); //folder with no slash + std::string folder = copy.substr(0, i); //folder with no slash //folder with no slash - std::transform(file.begin(), file.end(), file.begin(), tolower); - boost::filesystem::path folderpath = folder; - std::vector current = mlocal[folderpath.string()]; + //std::transform(file.begin(), file.end(), file.begin(), tolower); + //boost::filesystem::path folderpath = folder; + std::vector current = mlocal[folder]; for(std::vector::iterator iter = current.begin(); iter != current.end(); iter++) { - std::string loopfile = iter->substr(i + 1, copy.size() - i); //filename with no slash - std::transform(loopfile.begin(), loopfile.end(), loopfile.begin(), tolower); - if(file.compare(loopfile) == 0){ - std::cout << "Loopfile:" << loopfile << "\n"; + //std::string loopfile = iter->substr(i + 1, copy.size() - i); //filename with no slash + //std::transform(loopfile.begin(), loopfile.end(), loopfile.begin(), tolower); + if(comparePortion(*iter, copy, i + 1, copy.size() - i -1) == true){ + //std::cout << "Loopfile:" << copy << "\n"; return FileSystemArchive::open(*iter, readonly); } } @@ -206,8 +238,8 @@ class DirArchive: public Ogre::FileSystemArchive //std::cout << "Full:" << p.string() << "\n"; //std::cout << "Current:" << folder << "size: " << current.size() << "\n"; //std::cout << "\nFull:" << p.string() << "\n"<< "Part:" << folderpath.string(); - - return FileSystemArchive::open(copy, readonly); + DataStreamPtr p; + return p;//FileSystemArchive::open(copy, readonly); } }; From d59856af5c98d993e56a5c1dbb75b9f08cd177d4 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 8 Jun 2011 00:52:25 +0200 Subject: [PATCH 12/59] minor performance improvement --- components/bsa/bsa_archive.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index ba7be5bfd..68c47a0ed 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -162,7 +162,7 @@ class DirArchive: public Ogre::FileSystemArchive //std::transform(file.begin(), file.end(), file.begin(), tolower); //boost::filesystem::path folderpath = folder; - std::vector current = m[folder]; + std::vector& current = m[folder]; for(std::vector::iterator iter = current.begin(); iter != current.end(); iter++) { From a719a6b46824d2d5e91c15a79ab1bf42b3b23194 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Tue, 7 Jun 2011 18:57:24 -0400 Subject: [PATCH 13/59] Getting rid of animation code in nif loader --- components/nifogre/ogre_nif_loader.cpp | 199 ++++--------------------- 1 file changed, 27 insertions(+), 172 deletions(-) diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index a1254ed7f..8219a224c 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -81,11 +81,11 @@ Vector3 NIFLoader::convertVector3(const Nif::Vector& vec) Quaternion NIFLoader::convertRotation(const Nif::Matrix& rot) { Real matrix[3][3]; - + for (int i=0; i<3; i++) for (int j=0; j<3; j++) matrix[i][j] = rot.v[i].array[j]; - + return Quaternion(Matrix3(matrix)); } @@ -265,7 +265,7 @@ void NIFLoader::createMaterial(const String &name, } else pass->setDepthWriteEnabled(true); */ - + // Add transparency if NiAlphaProperty was present if (alphaFlags != -1) @@ -346,16 +346,16 @@ void NIFLoader::createOgreSubMesh(NiTriShape *shape, const String &material, std sub->vertexData = new VertexData(); sub->vertexData->vertexCount = numVerts; sub->useSharedVertices = false; - + VertexDeclaration *decl = sub->vertexData->vertexDeclaration; decl->addElement(nextBuf, 0, VET_FLOAT3, VES_POSITION); - + HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager::getSingleton().createVertexBuffer( VertexElement::getTypeSize(VET_FLOAT3), numVerts, HardwareBuffer::HBU_STATIC_WRITE_ONLY); vbuf->writeData(0, vbuf->getSizeInBytes(), data->vertices.ptr, true); - + VertexBufferBinding* bind = sub->vertexData->vertexBufferBinding; bind->setBinding(nextBuf++, vbuf); @@ -673,7 +673,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou if (verIndex < data->normals.length) { Vector3 absNormalsPos = vecRot * Vector3(ptrNormals + verIndex *3); - + for (int j=0; j<3; j++) (ptrNormals + verIndex*3)[j] = absNormalsPos[j]; } @@ -833,7 +833,7 @@ void NIFLoader::handleNode(Nif::Node *node, int flags, } for (; itrafo, bounds, bone); } @@ -848,7 +848,7 @@ void NIFLoader::handleNode(Nif::Node *node, int flags, Tri Chest */ if((isChest && stack < 10 ) || (isHands && counter < 3) || !(isChest || isHands)){ //(isBeast && isChest && stack < 10 && counter == skincounter ) - + std::string name = node->name.toString(); //if (isChest) //std::cout << "NAME: " << name << "\n"; @@ -875,15 +875,15 @@ void NIFLoader::handleNode(Nif::Node *node, int flags, //if(isBeast && isChest) //cout << "Handling Shape, Stack " << stack <<"\n"; - - + + counter++; } /*if(isHands){ //cout << "Handling Shape, Stack " << stack <<"\n"; counter++; }*/ - + } stack--; @@ -904,7 +904,7 @@ void NIFLoader::loadResource(Resource *resource) //std::cout <<"NAME:" << name; //if(name.length() >= 20) // {std::string split = name.substr(name.length() - 20, 20); - //if(name == + //if(name == //std::cout <<"NAME:" << name << "LEN: " << name.length() << "\n"; const std::string test ="meshes\\b\\B_N_Dark Elf_M_Skins.NIF"; const std::string test2 ="meshes\\b\\B_N_Dark Elf_M_Skins.nif"; @@ -932,15 +932,15 @@ void NIFLoader::loadResource(Resource *resource) const std::string test24 ="meshes\\b\\B_N_High Elf_M_Skins.nif"; //std::cout <<"LEN1:" << test.length() << "TEST: " << test << "\n"; - - + + if(name.compare(test) == 0 || name.compare(test2) == 0 || name.compare(test3) == 0 || name.compare(test4) == 0 || name.compare(test5) == 0 || name.compare(test6) == 0 || name.compare(test7) == 0 || name.compare(test8) == 0 || name.compare(test9) == 0 || name.compare(test10) == 0 || name.compare(test11) == 0 || name.compare(test12) == 0 || name.compare(test13) == 0 || name.compare(test14) == 0 || name.compare(test15) == 0 || name.compare(test16) == 0 || name.compare(test17) == 0 || name.compare(test18) == 0 || name.compare(test19) == 0 || name.compare(test20) == 0 || name.compare(test21) == 0 || name.compare(test22) == 0 || name.compare(test23) == 0 || name.compare(test24) == 0 - + ){ //std::cout << "Welcome Chest\n"; isChest = true; @@ -1009,7 +1009,7 @@ void NIFLoader::loadResource(Resource *resource) std::cout << "\n\n\nWelcome FRedguard Chest\n\n\n"; isChest = true; }*/ - + //if(split== "Skins.NIF") // std::cout << "\nSPECIAL PROPS\n"; resourceName = ""; @@ -1072,7 +1072,7 @@ void NIFLoader::loadResource(Resource *resource) short handle = 0; //skel->setBlendMode(Ogre::SkeletonAnimationBlendMode::ANIMBLEND_CUMULATIVE); bool first = true; - + // set the bounding value. if (bounds.isValid()) { @@ -1080,155 +1080,10 @@ void NIFLoader::loadResource(Resource *resource) bounds.maxX(), bounds.maxY(), bounds.maxZ())); mesh->_setBoundingSphereRadius(bounds.getRadius()); } - for(int i = 0; i < nif.numRecords(); i++) - { - - Nif::NiKeyframeController *f = dynamic_cast(nif.getRecord(i)); - Nif::Node *n = dynamic_cast(nif.getRecord(i)); - - if(f != NULL) - { - Nif::NiKeyframeDataPtr data = f->data; - std::cout << "Controller's Rtype:" << data->getRtype() << "Stype: " << data->getStype() << "Ttype:" << data->getTtype() << "\n"; - - if(first){ - float end = f->timeStop; - //std::cout <<"Creating WholeThing" << end << "\n"; - - //TRANSLATION - if(!mSkel.isNull()){ - std::cout <<"Creating WholeThing" << end << "\n"; - animcore = mSkel->createAnimation("WholeThing", end); - //animcore->setInterpolationMode(Ogre::Animation::IM_SPLINE); - //animcore->setRotationInterpolationMode(Ogre::Animation::RIM_SPHERICAL); - //animcore2->setRotationInterpolationMode(Ogre::Animation::RIM_LINEAR); - //ROTATION - animcore2 = mSkel->createAnimation("WholeThing2", end); - //animcore2->setInterpolationMode(Ogre::Animation::IM_SPLINE); - //animcore2->setRotationInterpolationMode(Ogre::Animation::RIM_SPHERICAL); - } - std::cout <<"AFTER"; - first = false; - } - if(animcore && animcore2){ - Nif::Named *node = dynamic_cast ( f->target.getPtr()); - std::cout << "The target rec: " << node->name.toString() << "\n"; - Ogre::NodeAnimationTrack* mTrack = animcore->createNodeTrack(handle, mSkel->getBone(node->name.toString())); - Ogre::NodeAnimationTrack* mTrack2 = animcore2->createNodeTrack(handle++, mSkel->getBone(node->name.toString())); - /* if (node->recType == RC_NiNode) - { - NodeList &list = ((NiNode*)node)->children; - int n = list.length(); - - for (int i = n; i<=n; i++) - { - if(skel->hasBone((list[i]).name.toString())) - mTrack3 = animcore2->createNodeTrack(handle++, skel->getBone((list[i]).name.toString())); - - } - }*/ - - std::vector quats = data->getQuat(); - std::vector::iterator quatIter = quats.begin(); - std::vector rtime = data->getrTime(); - std::vector::iterator rtimeiter = rtime.begin(); - std::vector ttime = data->gettTime(); - std::vector::iterator ttimeiter = ttime.begin(); - std::vector translist1 = data->getTranslist1(); - std::vector::iterator transiter = translist1.begin(); - std::vector translist2 = data->getTranslist2(); - std::vector::iterator transiter2 = translist2.begin(); - std::vector translist3 = data->getTranslist3(); - std::vector::iterator transiter3 = translist3.begin(); - - - float tleft = 0; - float rleft = 0.0; - float ttotal = 0.0; - float rtotal = 0; - Ogre::TransformKeyFrame* mKey; - Ogre::TransformKeyFrame* mKey2; - float tused = 0.0; - float rused = 0.0; - Ogre::Quaternion lastquat; - Ogre::Vector3 lasttrans; - bool rend = false; - bool tend = false; - Ogre::Quaternion test;// = (skel->getBone(node->name.toString()))->getOrientation(); - for (int j = 0 ; j < ttime.size(); j++) - { - if(data->getTtype() >= 1 && data->getTtype() <= 5) - { - - Ogre::TransformKeyFrame* mKey = mTrack->createNodeKeyFrame(*ttimeiter); - Ogre::Vector3 standard = *transiter; - if(data->getTtype() == 2) - standard = *transiter * *transiter2 * *transiter3; - - mKey->setTranslate(standard);/* - if(mTrack3) - { - Ogre::TransformKeyFrame* mKey3 = mTrack->createNodeKeyFrame(*ttimeiter); - mKey3->setTranslate(standard); - }*/ - //mKey->setRotation(Quaternion::ZERO); - //mKey->setScale(Ogre::Vector3(1,1,1)); - transiter++; //START - transiter2++; - transiter3++; - ttimeiter++; - } - } - for (int j = 0 ; j < rtime.size(); j++) - { - if(data->getRtype() >= 1 && data->getRtype() <= 5) - { - Ogre::TransformKeyFrame* mKey2 = mTrack2->createNodeKeyFrame(*rtimeiter); - test = *quatIter; - - mKey2->setRotation(test); - //mKey2->setTranslate(Ogre::Vector3(0,0,0)); - //mKey2->setScale(Ogre::Vector3(1,1,1)); - quatIter++; - rtimeiter++; - } - } - } - - - - - /* - //mTrack = animcore->createNodeTrack(handle++, skel->getBone(node->name.toString())); - - std::vector stime = data->getsTime(); - std::vector::iterator stimeiter = stime.begin(); - - std::vector sfactor = data->getScalefactor(); - std::vector::iterator sfactoriter = sfactor.begin(); - for (int i = 0 ; i < stime.size(); i++) - { - if(data->getStype() >= 1 && data->getStype() <= 5) - { - Ogre::TransformKeyFrame* mKey = mTrack->createNodeKeyFrame(*stimeiter); - mKey->setScale(Ogre::Vector3(*sfactoriter, *sfactoriter, *sfactoriter)); - - sfactoriter++; - stimeiter++; - } - } - */ - - - } - - //std::cout <"BE\n"; - } - // set skeleton if (!mSkel.isNull() && mesh->isLoaded()) { @@ -1241,14 +1096,14 @@ void NIFLoader::loadResource(Resource *resource) // mesh->setSkeletonName(getSkeletonName()); } -MeshPtr NIFLoader::load(const std::string &name, +MeshPtr NIFLoader::load(const std::string &name, const std::string &group) { MeshManager *m = MeshManager::getSingletonPtr(); // Check if the resource already exists ResourcePtr ptr = m->getByName(name, group); MeshPtr resize; - + const std::string beast1 ="meshes\\b\\B_N_Khajiit_F_Skins.nif"; const std::string beast2 ="meshes\\b\\B_N_Khajiit_M_Skins.nif"; const std::string beast3 ="meshes\\b\\B_N_Argonian_F_Skins.nif"; @@ -1259,8 +1114,8 @@ MeshPtr NIFLoader::load(const std::string &name, const std::string beasttail3 ="tail\\b\\B_N_Argonian_F_Skins.nif"; const std::string beasttail4 ="tail\\b\\B_N_Argonian_M_Skins.nif"; - if (!ptr.isNull()){ - + if (!ptr.isNull()){ + //if(pieces > 1) //cout << "It exists\n"; resize = MeshPtr(ptr); @@ -1271,17 +1126,17 @@ MeshPtr NIFLoader::load(const std::string &name, { resize = MeshManager::getSingleton().createManual(name, group, NIFLoader::getSingletonPtr()); //cout <<"EXISTING" << name << "\n"; - + //if(pieces > 1) //cout << "Creating it\n"; - - + + //resize->load(); //resize->reload(); //return 0; ResourcePtr ptr = m->getByName(name, group); resize = MeshPtr(ptr); - + //NIFLoader::getSingletonPtr()-> /*ResourcePtr ptr = m->getByName(name, group); if (!ptr.isNull()){ @@ -1292,7 +1147,7 @@ MeshPtr NIFLoader::load(const std::string &name, } return resize; } - + /* More code currently not in use, from the old D source. This was used in the first attempt at loading NIF meshes, where each submesh From 3a9007849d033610343ba3e3d05636e43a2169ba Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Wed, 8 Jun 2011 00:35:30 -0400 Subject: [PATCH 14/59] Windows fix --- apps/openmw/mwclass/npc.cpp | 2 +- components/bsa/bsa_archive.cpp | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 285da5c5a..5afc26480 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -118,7 +118,7 @@ namespace MWClass Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75); if (groin){ - cellRender.insertMesh("MeSHes\\1\\red_MJ_hat_org.NIf"); //w/W_6th_Hammer.NIF + cellRender.insertMesh("Meshes\\2\\red_MJ_hat_org.nif"); //w/W_6th_Hammer.NIF //bald_MJ_hat.NIF cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, kOgrePi, npcName + "groin", addresses, numbers); addresses2[numbers] = npcName + "groin"; diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index ba7be5bfd..99848649a 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -107,7 +107,7 @@ class DirArchive: public Ogre::FileSystemArchive small = original.substr(cutoff - 1, original.size() - cutoff); //boost::filesystem::path smallp = small; m[small] = filesind; - //std::cout << "Directory: " << smallp.string() << " " << filesind.size() << "\n"; + //std::cout << "Directory: " << small << " " << filesind.size() << "\n"; } @@ -126,8 +126,7 @@ class DirArchive: public Ogre::FileSystemArchive std::string copy = filename; - if(OGRE_PLATFORM != OGRE_PLATFORM_WIN32) - { + for (int i = 0; i < filename.size(); i++) { @@ -135,7 +134,7 @@ class DirArchive: public Ogre::FileSystemArchive copy.replace(i, 1, "/"); } } - } + if(copy.at(0) == '\\' || copy.at(0) == '/') { @@ -189,8 +188,7 @@ class DirArchive: public Ogre::FileSystemArchive //std::cout << "Open\n"; std::string copy = filename; - if(OGRE_PLATFORM != OGRE_PLATFORM_WIN32) - { + for (int i = 0; i < filename.size(); i++) { @@ -198,7 +196,7 @@ class DirArchive: public Ogre::FileSystemArchive copy.replace(i, 1, "/"); } } - } + if(copy.at(0) == '\\' || copy.at(0) == '/') { From 65cc0e83179ae71a9c32291ebf4495972133729c Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Wed, 8 Jun 2011 17:15:13 -0400 Subject: [PATCH 15/59] trying strict --- apps/openmw/engine.cpp | 49 +--------------------------------- apps/openmw/mwclass/npc.cpp | 2 +- components/bsa/bsa_archive.cpp | 31 ++++++++++++++++----- components/bsa/bsa_archive.hpp | 2 +- 4 files changed, 27 insertions(+), 57 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index a899a5aea..a160e0993 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -93,51 +93,6 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) std::string effect; MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayer().getPlayer().getCell(); - /* - ESMS::CellRefList::List creatureData = (current->creatures).list; - ESMS::CellRefList::List::iterator creaturedataiter = creatureData.begin(); - - for(int i = 0; i < creatureData.size(); i++) - { - //std::cout << "Testing" << i < "\n"; - ESMS::LiveCellRef item = *creaturedataiter; - Ogre::Entity* creaturemodel = item.model; - - if(evt.timeSinceLastFrame == 0) - creaturemodel->getSkeleton()->setBindingPose(); - creaturemodel->getSkeleton()->setBlendMode(Ogre::SkeletonAnimationBlendMode::ANIMBLEND_AVERAGE); //ANIMBLEND_AVERAGE - Ogre::AnimationState *mAnimationState = creaturemodel->getAnimationState("WholeThing"); - mAnimationState->setWeight(.5); - mAnimationState->setLoop(true); - //npcmodel->getSkeleton()-> - - mAnimationState->setEnabled(true); - - - - - Ogre::AnimationState *mAnimationState2 = creaturemodel->getAnimationState("WholeThing2"); - mAnimationState2->setLoop(true); - mAnimationState2->setWeight(.5); - mAnimationState2->setEnabled(true); - - mAnimationState2->createBlendMask(creaturemodel->getSkeleton()->getNumBones(),1); - mAnimationState->createBlendMask(creaturemodel->getSkeleton()->getNumBones(),1); - for(int j = 2; j < creaturemodel->getSkeleton()->getNumBones(); j++) - { - mAnimationState->setBlendMaskEntry(j,1); - mAnimationState2->setBlendMaskEntry(j,1); - } - // set skeleton - std::cout << "TimePosition:" << mAnimationState->getTimePosition() << "\n"; - - mAnimationState->addTime(evt.timeSinceLastFrame); - mAnimationState2->addTime(evt.timeSinceLastFrame); - //npcmodel->_updateAnimation(); - //mAnimationState2->setEnabled(true); - creaturedataiter++; - }*/ - //If the region has changed @@ -299,9 +254,7 @@ void OMW::Engine::loadBSA() std::string m = mDataDir.string(); std::cout << "Data dir" << m << "\n"; - addDir(m); - //std::string s = "f\n"; - //std::cout <<"S: " << s.size() << "\n"; + addDir(m, mFSStrict); } diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 5afc26480..88d3ee136 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -118,7 +118,7 @@ namespace MWClass Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75); if (groin){ - cellRender.insertMesh("Meshes\\2\\red_MJ_hat_org.nif"); //w/W_6th_Hammer.NIF + cellRender.insertMesh("meshes\\2\\red_MJ_hat_ORg.nif"); //w/W_6th_Hammer.NIF //bald_MJ_hat.NIF cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, kOgrePi, npcName + "groin", addresses, numbers); addresses2[numbers] = npcName + "groin"; diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index 99848649a..8e3da70e0 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -41,6 +41,8 @@ struct ciLessBoost : std::binary_function } }; +static bool fsstrict = false; + /// An OGRE Archive wrapping a BSAFile archive class DirArchive: public Ogre::FileSystemArchive { @@ -70,8 +72,8 @@ class DirArchive: public Ogre::FileSystemArchive std::string s = name; cutoff = s.size() + 1; //std::cout << "Cut off:" << cutoff; - - populateMap(currentdir); + if(fsstrict == false) + populateMap(currentdir); } void populateMap(boost::filesystem::path d){ @@ -111,7 +113,7 @@ class DirArchive: public Ogre::FileSystemArchive } - bool isCaseSensitive() const { return false; } + bool isCaseSensitive() const { return fsstrict; } // The archive is loaded in the constructor, and never unloaded. void load() {} @@ -134,7 +136,13 @@ class DirArchive: public Ogre::FileSystemArchive copy.replace(i, 1, "/"); } } + if(fsstrict == true) + { + std::cout << "fsstrict " << copy << "\n"; + return FileSystemArchive::exists(copy); + } + std::cout << "afterstrict\n"; if(copy.at(0) == '\\' || copy.at(0) == '/') { @@ -144,8 +152,7 @@ class DirArchive: public Ogre::FileSystemArchive //std::cout << "After:" << copy.size(); } - - //boost::filesystem::path p = copy; + int last = copy.size() - 1; int i = last; @@ -196,7 +203,11 @@ class DirArchive: public Ogre::FileSystemArchive copy.replace(i, 1, "/"); } } - + if(fsstrict == true){ + std::cout << "fsstrict " << copy << "\n"; + return FileSystemArchive::open(copy, readonly); + } + std::cout << "afterstrict\n"; if(copy.at(0) == '\\' || copy.at(0) == '/') { @@ -205,6 +216,9 @@ class DirArchive: public Ogre::FileSystemArchive //std::cout << "The copy" << copy << "\n"; //std::cout << "After:" << copy.size(); } + + + //boost::filesystem::path p = copy; int last = copy.size() - 1; @@ -374,6 +388,7 @@ public: static bool init = false; static bool init2 = false; + static void insertBSAFactory() { if(!init) @@ -400,9 +415,11 @@ void addBSA(const std::string& name, const std::string& group) ResourceGroupManager::getSingleton(). addResourceLocation(name, "BSA", group); } -void addDir(const std::string& name, const std::string& group) +void addDir(const std::string& name, const bool& fs, const std::string& group) { + fsstrict = fs; insertDirFactory(); + ResourceGroupManager::getSingleton(). addResourceLocation(name, "Dir", group); } diff --git a/components/bsa/bsa_archive.hpp b/components/bsa/bsa_archive.hpp index a72f638e3..bf7e7ee51 100644 --- a/components/bsa/bsa_archive.hpp +++ b/components/bsa/bsa_archive.hpp @@ -32,6 +32,6 @@ /// Add the given BSA file as an input archive in the Ogre resource /// system. void addBSA(const std::string& file, const std::string& group="General"); -void addDir(const std::string& file, const std::string& group="General"); +void addDir(const std::string& file, const bool& fs, const std::string& group="General"); #endif From 93f41e25a44fea0fe2ae2f9e6a2e7bf19a0c19ff Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Wed, 8 Jun 2011 17:29:28 -0400 Subject: [PATCH 16/59] fs-strict --- apps/openmw/mwclass/npc.cpp | 2 +- components/bsa/bsa_archive.cpp | 35 ++++++++++++++++------------------ 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 88d3ee136..5afc26480 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -118,7 +118,7 @@ namespace MWClass Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75); if (groin){ - cellRender.insertMesh("meshes\\2\\red_MJ_hat_ORg.nif"); //w/W_6th_Hammer.NIF + cellRender.insertMesh("Meshes\\2\\red_MJ_hat_org.nif"); //w/W_6th_Hammer.NIF //bald_MJ_hat.NIF cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, kOgrePi, npcName + "groin", addresses, numbers); addresses2[numbers] = npcName + "groin"; diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index 8e3da70e0..09662474f 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -49,7 +49,7 @@ class DirArchive: public Ogre::FileSystemArchive boost::filesystem::path currentdir; std::map, ciLessBoost> m; - int cutoff; + unsigned int cutoff; bool comparePortion(std::string file1, std::string file2, int start, int size) const { @@ -128,21 +128,15 @@ class DirArchive: public Ogre::FileSystemArchive std::string copy = filename; - - for (int i = 0; i < filename.size(); i++) + + for (unsigned int i = 0; i < filename.size(); i++) { if(copy.at(i) == '\\' ){ copy.replace(i, 1, "/"); } } - if(fsstrict == true) - { - std::cout << "fsstrict " << copy << "\n"; - return FileSystemArchive::exists(copy); - } - std::cout << "afterstrict\n"; if(copy.at(0) == '\\' || copy.at(0) == '/') { @@ -151,8 +145,13 @@ class DirArchive: public Ogre::FileSystemArchive //std::cout << "The copy" << copy << "\n"; //std::cout << "After:" << copy.size(); } + if(fsstrict == true) + { + //std::cout << "fsstrict " << copy << "\n"; + return FileSystemArchive::exists(copy); + + } - int last = copy.size() - 1; int i = last; @@ -195,19 +194,15 @@ class DirArchive: public Ogre::FileSystemArchive //std::cout << "Open\n"; std::string copy = filename; - - for (int i = 0; i < filename.size(); i++) + + for (unsigned int i = 0; i < filename.size(); i++) { if(copy.at(i) == '\\' ){ copy.replace(i, 1, "/"); } } - if(fsstrict == true){ - std::cout << "fsstrict " << copy << "\n"; - return FileSystemArchive::open(copy, readonly); - } - std::cout << "afterstrict\n"; + if(copy.at(0) == '\\' || copy.at(0) == '/') { @@ -217,7 +212,9 @@ class DirArchive: public Ogre::FileSystemArchive //std::cout << "After:" << copy.size(); } - + if(fsstrict == true){ + return FileSystemArchive::open(copy, readonly); + } //boost::filesystem::path p = copy; @@ -419,7 +416,7 @@ void addDir(const std::string& name, const bool& fs, const std::string& group) { fsstrict = fs; insertDirFactory(); - + ResourceGroupManager::getSingleton(). addResourceLocation(name, "Dir", group); } From 9eefee7168ca3a6fe6b5b75e4e39918309a39f6a Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 11 Jun 2011 20:01:21 -0400 Subject: [PATCH 17/59] Say strict --- apps/openmw/engine.cpp | 2 +- apps/openmw/mwsound/soundmanager.cpp | 35 ++++++++++++++++++++---- apps/openmw/mwsound/soundmanager.hpp | 7 +++-- components/file_finder/file_finder.hpp | 7 +++-- components/file_finder/filename_less.hpp | 35 ++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 12 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index a160e0993..97596301c 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -392,7 +392,7 @@ void OMW::Engine::go() mOgre.getCamera(), mEnvironment.mWorld->getStore(), (mDataDir), - mUseSound); + mUseSound, mFSStrict); // Create script system mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full, diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index 564ebe941..72e62421f 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -63,7 +63,7 @@ namespace MWSound */ OEManagerPtr mgr; SoundPtr music; - + /* This class calls update() on the sound manager each frame using and Ogre::FrameListener */ @@ -84,20 +84,22 @@ namespace MWSound // finding. It takes DOS paths (any case, \\ slashes or / slashes) // relative to the sound dir, and translates them into full paths // of existing files in the filesystem, if they exist. + bool FSstrict; FileFinder::FileFinder files; + FileFinder::FileFinderStrict strict; SoundImpl(Ogre::Root *root, Ogre::Camera *camera, const ESMS::ESMStore &str, - const std::string &soundDir) + const std::string &soundDir, bool fsstrict) : mgr(new OEManager(SoundFactoryPtr(new SOUND_FACTORY))) , updater(mgr) , cameraTracker(mgr) , store(str) - , files(soundDir) + , files(soundDir), strict(soundDir) { + FSstrict = fsstrict; cout << "Sound output: " << SOUND_OUT << endl; cout << "Sound decoder: " << SOUND_IN << endl; - // Attach the camera to the camera tracker cameraTracker.followCamera(camera); @@ -124,15 +126,23 @@ namespace MWSound bool hasFile(const std::string &str) { + if(FSstrict == false){ if(files.has(str)) return true; // Not found? Try with .mp3 + return files.has(toMp3(str)); + } + else{ + if(strict.has(str)) return true; + // Not found? Try with .mp3 return files.has(toMp3(str)); } + } // Convert a Morrowind sound path (eg. Fx\funny.wav) to full path // with proper slash conversion (eg. datadir/Sound/Fx/funny.wav) std::string convertPath(const std::string &str) { + if(FSstrict == false){ // Search and return if(files.has(str)) return files.lookup(str); @@ -141,6 +151,18 @@ namespace MWSound std::string mp3 = toMp3(str); if(files.has(mp3)) return files.lookup(mp3); + } + + else + { + if(files.has(str)) + return files.lookup(str); + + // Try mp3 if the wav wasn't found + std::string mp3 = toMp3(str); + if(files.has(mp3)) + return files.lookup(mp3); + } // Give up return ""; @@ -307,12 +329,13 @@ namespace MWSound SoundManager::SoundManager(Ogre::Root *root, Ogre::Camera *camera, const ESMS::ESMStore &store, boost::filesystem::path dataDir, - bool useSound) + bool useSound, bool fsstrict) : mData(NULL) { + fsStrict = fsstrict; MP3Lookup(dataDir / "Music/Explore/"); if(useSound) - mData = new SoundImpl(root, camera, store, (dataDir / "Sound").string()); + mData = new SoundImpl(root, camera, store, (dataDir / "Sound").string(), fsstrict); } SoundManager::~SoundManager() diff --git a/apps/openmw/mwsound/soundmanager.hpp b/apps/openmw/mwsound/soundmanager.hpp index 8c48986db..b76e71e39 100644 --- a/apps/openmw/mwsound/soundmanager.hpp +++ b/apps/openmw/mwsound/soundmanager.hpp @@ -30,13 +30,16 @@ namespace MWSound SoundImpl *mData; std::vector files; + bool fsStrict; - public: + + SoundManager(Ogre::Root*, Ogre::Camera*, const ESMS::ESMStore &store, - boost::filesystem::path dataDir, bool useSound); + boost::filesystem::path dataDir, bool useSound, bool fsstrict); ~SoundManager(); + void startRandomTitle(); void MP3Lookup(boost::filesystem::path dir); //struct SoundImpl; diff --git a/components/file_finder/file_finder.hpp b/components/file_finder/file_finder.hpp index cfa07dce9..358563afa 100644 --- a/components/file_finder/file_finder.hpp +++ b/components/file_finder/file_finder.hpp @@ -22,7 +22,7 @@ class FileFinderT { std::string file = pth.string(); std::string key = file.substr(cut); - owner->table[key] = file; + owner->table[key] = file; } }; @@ -50,17 +50,18 @@ public: bool has(const std::string& file) const { - return table.find(file) != table.end(); + return table.find(file) != table.end(); } // Find the full path from a relative path. const std::string &lookup(const std::string& file) const { - return table.find(file)->second; + return table.find(file)->second; } }; // The default is to use path_less for equality checks typedef FileFinderT FileFinder; +typedef FileFinderT FileFinderStrict; } #endif diff --git a/components/file_finder/filename_less.hpp b/components/file_finder/filename_less.hpp index 9f251b1c8..bc3186ce9 100644 --- a/components/file_finder/filename_less.hpp +++ b/components/file_finder/filename_less.hpp @@ -44,6 +44,41 @@ struct path_less return compareString(a.c_str(), b.c_str()) < 0; } }; + +struct path_slash +{ + int compareChar(char a, char b) const + { + if(a>b) return 1; + else if(a Date: Sun, 12 Jun 2011 16:36:18 -0400 Subject: [PATCH 18/59] streammusic strict --- apps/openmw/mwsound/soundmanager.cpp | 119 ++++++++++++++++++--------- apps/openmw/mwsound/soundmanager.hpp | 9 +- 2 files changed, 85 insertions(+), 43 deletions(-) diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index 72e62421f..abff70664 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -87,15 +87,18 @@ namespace MWSound bool FSstrict; FileFinder::FileFinder files; FileFinder::FileFinderStrict strict; + FileFinder::FileFinder musicpath; + FileFinder::FileFinderStrict musicpathStrict; SoundImpl(Ogre::Root *root, Ogre::Camera *camera, const ESMS::ESMStore &str, - const std::string &soundDir, bool fsstrict) + const std::string &soundDir, const std::string &musicDir, bool fsstrict) : mgr(new OEManager(SoundFactoryPtr(new SOUND_FACTORY))) , updater(mgr) , cameraTracker(mgr) , store(str) , files(soundDir), strict(soundDir) + ,musicpath(musicDir), musicpathStrict(musicDir) { FSstrict = fsstrict; cout << "Sound output: " << SOUND_OUT << endl; @@ -113,6 +116,8 @@ namespace MWSound cameraTracker.unfollowCamera(); } + + static std::string toMp3(std::string str) { std::string::size_type i = str.rfind('.'); @@ -124,44 +129,70 @@ namespace MWSound return str; } - bool hasFile(const std::string &str) + bool hasFile(const std::string &str, bool music = false) { if(FSstrict == false){ - if(files.has(str)) return true; - // Not found? Try with .mp3 - return files.has(toMp3(str)); + if(music){ + if(musicpath.has(str)) return true; + // Not found? Try with .mp3 + return musicpath.has(toMp3(str)); + } + else + { + if(files.has(str)) return true; + return files.has(toMp3(str)); + } + } + else + { + if(music){ + if(musicpathStrict.has(str)) return true; + // Not found? Try with .mp3 + return musicpathStrict.has(toMp3(str)); + } + else + { + if(strict.has(str)) return true; + return strict.has(toMp3(str)); + } + } - else{ - if(strict.has(str)) return true; - // Not found? Try with .mp3 - return files.has(toMp3(str)); - } } // Convert a Morrowind sound path (eg. Fx\funny.wav) to full path // with proper slash conversion (eg. datadir/Sound/Fx/funny.wav) - std::string convertPath(const std::string &str) + std::string convertPath(const std::string &str, bool music = false) { if(FSstrict == false){ // Search and return - if(files.has(str)) - return files.lookup(str); + if(music && musicpath.has(str)) + return musicpath.lookup(str); + else if(files.has(str)) + return files.lookup(str); + // Try mp3 if the wav wasn't found std::string mp3 = toMp3(str); - if(files.has(mp3)) - return files.lookup(mp3); + if(music && musicpath.has(mp3)) + return musicpath.lookup(mp3); + else if(files.has(mp3)) + return files.lookup(mp3); } else { - if(files.has(str)) - return files.lookup(str); + if(music && musicpathStrict.has(str)) + return musicpathStrict.lookup(str); + else if(strict.has(str)) + return strict.lookup(str); - // Try mp3 if the wav wasn't found - std::string mp3 = toMp3(str); - if(files.has(mp3)) - return files.lookup(mp3); + + // Try mp3 if the wav wasn't found + std::string mp3 = toMp3(str); + if(music && musicpathStrict.has(mp3)) + return musicpathStrict.lookup(mp3); + else if(strict.has(str)) + return strict.lookup(mp3); } // Give up @@ -326,6 +357,22 @@ namespace MWSound } }; + void SoundManager::streamMusicFull (const std::string& filename) + { + if(!mData) return; + + // Play the sound and tell it to stream, if possible. TODO: + // Store the reference, the jukebox will need to check status, + // control volume etc. + if (mData->music) + mData->music->stop(); + mData->music = mData->mgr->load(filename); + mData->music->setStreaming(true); + mData->music->setVolume(0.4); + mData->music->play(); + + } + SoundManager::SoundManager(Ogre::Root *root, Ogre::Camera *camera, const ESMS::ESMStore &store, boost::filesystem::path dataDir, @@ -335,7 +382,7 @@ namespace MWSound fsStrict = fsstrict; MP3Lookup(dataDir / "Music/Explore/"); if(useSound) - mData = new SoundImpl(root, camera, store, (dataDir / "Sound").string(), fsstrict); + mData = new SoundImpl(root, camera, store, (dataDir / "Sound").string(), (dataDir / "Music").string(), fsstrict); } SoundManager::~SoundManager() @@ -344,6 +391,15 @@ namespace MWSound delete mData; } + void SoundManager::streamMusic(const std::string& filename){ + if(mData->hasFile(filename, true)) + { + std::string fullpath = mData->convertPath(filename, true); + streamMusicFull(fullpath); + } + } + + void SoundManager::MP3Lookup(boost::filesystem::path dir) { boost::filesystem::directory_iterator dir_iter(dir), dir_end; @@ -376,7 +432,7 @@ namespace MWSound try { std::cout << "Playing " << music << "\n"; - streamMusic(music); + streamMusicFull(music); } catch(std::exception &e) { @@ -420,22 +476,7 @@ namespace MWSound return !mData->isPlaying(ptr, "_say_sound"); } - void SoundManager::streamMusic (const std::string& filename) - { - if(!mData) return; - - // Play the sound and tell it to stream, if possible. TODO: - // Store the reference, the jukebox will need to check status, - // control volume etc. - if (mData->music) - mData->music->stop(); - mData->music = mData->mgr->load(filename); - mData->music->setStreaming(true); - mData->music->setVolume(0.4); - mData->music->play(); - - } - + void SoundManager::playSound (const std::string& soundId, float volume, float pitch) { if(!mData) return; diff --git a/apps/openmw/mwsound/soundmanager.hpp b/apps/openmw/mwsound/soundmanager.hpp index b76e71e39..70e6babf9 100644 --- a/apps/openmw/mwsound/soundmanager.hpp +++ b/apps/openmw/mwsound/soundmanager.hpp @@ -31,6 +31,9 @@ namespace MWSound SoundImpl *mData; std::vector files; bool fsStrict; + void streamMusicFull (const std::string& filename); + ///< Play a soundifle + /// \param filename name of a sound file in "Music/" in the data directory. public: @@ -39,7 +42,7 @@ namespace MWSound boost::filesystem::path dataDir, bool useSound, bool fsstrict); ~SoundManager(); - + void streamMusic(const std::string& filename); void startRandomTitle(); void MP3Lookup(boost::filesystem::path dir); //struct SoundImpl; @@ -54,9 +57,7 @@ namespace MWSound bool sayDone (MWWorld::Ptr reference) const; ///< Is actor not speaking? - void streamMusic (const std::string& filename); - ///< Play a soundifle - /// \param filename name of a sound file in "Music/" in the data directory. + void playSound (const std::string& soundId, float volume, float pitch); ///< Play a sound, independently of 3D-position From 5bf5bde946a0cf5fca1c3ffd54edd61a9a50b2d7 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 14 Jun 2011 16:41:30 +0200 Subject: [PATCH 19/59] created new files, conncted MessageBoxManger with WindowManager --- apps/openmw/mwgui/messagebox.cpp | 15 +++++++++++++++ apps/openmw/mwgui/messagebox.hpp | 25 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 apps/openmw/mwgui/messagebox.cpp create mode 100644 apps/openmw/mwgui/messagebox.hpp diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp new file mode 100644 index 000000000..9c32ed47d --- /dev/null +++ b/apps/openmw/mwgui/messagebox.cpp @@ -0,0 +1,15 @@ +#include "messagebox.hpp" +//#include "window_manager.hpp" + +using namespace MWGui; + +void MessageBoxManager::createMessageBox (const std::string& message) +{ + std::cout << "create non-interactive message box" << std::endl; +} + +void MessageBoxManager::createInteractiveMessageBox (const std::string& message, const std::vector& buttons) +{ + std::cout << "create interactive message box" << std::endl; + std::copy (buttons.begin(), buttons.end(), std::ostream_iterator (std::cout, ", ")); +} diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp new file mode 100644 index 000000000..0e6f0e45f --- /dev/null +++ b/apps/openmw/mwgui/messagebox.hpp @@ -0,0 +1,25 @@ +#ifndef MWGUI_MESSAGE_BOX_H +#define MWGUI_MESSAGE_BOX_H + +#include "window_base.hpp" + +namespace MWGui +{ + class WindowManager; +} + +namespace MWGui +{ + using namespace MyGUI; + + class WindowManager; + + class MessageBoxManager + { + public: + void createMessageBox (const std::string& message); + void createInteractiveMessageBox (const std::string& message, const std::vector& buttons); + }; +} + +#endif From 2d93705baa05dfbbd59447c6261f139e8f7b778a Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 14 Jun 2011 18:25:07 +0200 Subject: [PATCH 20/59] created xml file for the layout; MessageBox class --- .../openmw_resources/openmw_messagebox_layout.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml new file mode 100644 index 000000000..9debd1096 --- /dev/null +++ b/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml @@ -0,0 +1,10 @@ + + + + + + + + + + From 84c19a90ade136ee9dea42ab7b484834cdb57705 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 14 Jun 2011 18:29:20 +0200 Subject: [PATCH 21/59] deleted needless code --- apps/openmw/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index b20693417..bb62c0044 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -65,6 +65,7 @@ set(GAMEGUI mwgui/dialogue_history.cpp mwgui/window_base.cpp mwgui/stats_window.cpp + mwgui/messagebox.cpp ) source_group(apps\\openmw\\mwgui FILES ${GAMEGUI_HEADER} ${GAMEGUI}) From 56dc9ffcf3650e6d9692a4405043ac4eaa6bb027 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 14 Jun 2011 18:29:55 +0200 Subject: [PATCH 22/59] now, realy deleted needless code. --- apps/openmw/mwgui/messagebox.cpp | 10 +++++++++- apps/openmw/mwgui/messagebox.hpp | 24 +++++++++++++++++------- apps/openmw/mwgui/window_manager.cpp | 13 ++++++++++++- apps/openmw/mwgui/window_manager.hpp | 4 +++- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 9c32ed47d..78235fa8c 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -1,11 +1,12 @@ #include "messagebox.hpp" -//#include "window_manager.hpp" using namespace MWGui; void MessageBoxManager::createMessageBox (const std::string& message) { std::cout << "create non-interactive message box" << std::endl; + MessageBox *box = new MessageBox(*this, message); + mMessageBoxes.push_back(box); } void MessageBoxManager::createInteractiveMessageBox (const std::string& message, const std::vector& buttons) @@ -13,3 +14,10 @@ void MessageBoxManager::createInteractiveMessageBox (const std::string& message, std::cout << "create interactive message box" << std::endl; std::copy (buttons.begin(), buttons.end(), std::ostream_iterator (std::cout, ", ")); } + +MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message) + : Layout("openmw_messagebox_layout.xml") + , mMessageBoxManager(parMessageBoxManager) +{ + setText("message", message); +} diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index 0e6f0e45f..31286dacd 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -1,25 +1,35 @@ #ifndef MWGUI_MESSAGE_BOX_H #define MWGUI_MESSAGE_BOX_H +#include +#include + #include "window_base.hpp" namespace MWGui { - class WindowManager; -} -namespace MWGui -{ - using namespace MyGUI; - - class WindowManager; + class MessageBoxManager; + class MessageBox; class MessageBoxManager { + private: + std::vector mMessageBoxes; public: void createMessageBox (const std::string& message); void createInteractiveMessageBox (const std::string& message, const std::vector& buttons); }; + + class MessageBox : public OEngine::GUI::Layout + { + public: + MessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message); + void setMessage(const std::string& message); + protected: + MessageBoxManager& mMessageBoxManager; + }; + } #endif diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 2d7f70ef8..1c9cda677 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -8,6 +8,7 @@ #include "dialogue.hpp" #include "dialogue_history.hpp" #include "stats_window.hpp" +#include "messagebox.hpp" #include "../mwmechanics/mechanicsmanager.hpp" #include "../mwinput/inputmanager.hpp" @@ -60,6 +61,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment inventory = new InventoryWindow (); #endif console = new Console(w,h, environment, extensions); + mMessageBoxManager = new MessageBoxManager(); // The HUD is always on hud->setVisible(true); @@ -82,6 +84,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment WindowManager::~WindowManager() { delete console; + delete mMessageBoxManager; delete hud; delete map; delete menu; @@ -446,13 +449,21 @@ void WindowManager::removeDialog(OEngine::GUI::Layout*dialog) void WindowManager::messageBox (const std::string& message, const std::vector& buttons) { - std::cout << "message box: " << message << std::endl; + /*std::cout << "message box: " << message << std::endl; if (!buttons.empty()) { std::cout << "buttons: "; std::copy (buttons.begin(), buttons.end(), std::ostream_iterator (std::cout, ", ")); std::cout << std::endl; + }*/ + if (buttons.empty()) + { + mMessageBoxManager->createMessageBox(message); + } + else + { + mMessageBoxManager->createInteractiveMessageBox(message, buttons); } } diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index d3fbf3ea3..92f19cdc3 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -62,6 +62,7 @@ namespace MWGui class CreateClassDialog; class BirthDialog; class ReviewDialog; + class MessageBoxManager; struct ClassPoint { @@ -84,6 +85,7 @@ namespace MWGui MapWindow *map; MainMenu *menu; StatsWindow *stats; + MessageBoxManager *mMessageBoxManager; #if 0 InventoryWindow *inventory; #endif @@ -245,7 +247,7 @@ namespace MWGui void removeDialog(OEngine::GUI::Layout* dialog); ///< Hides dialog and schedules dialog to be deleted. - + void messageBox (const std::string& message, const std::vector& buttons); /** From aab07f379e89f90351b971539c7f6fb4a771cea0 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 14 Jun 2011 18:55:07 +0200 Subject: [PATCH 23/59] added openmw_messagebox_layout.xml to CMakeLists.txt --- extern/mygui_3.0.1/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/extern/mygui_3.0.1/CMakeLists.txt b/extern/mygui_3.0.1/CMakeLists.txt index 8101ad91a..36467733d 100644 --- a/extern/mygui_3.0.1/CMakeLists.txt +++ b/extern/mygui_3.0.1/CMakeLists.txt @@ -68,6 +68,7 @@ configure_file("${SDIR}/openmw_progress.skin.xml" "${DDIR}/openmw_progress.skin. configure_file("${SDIR}/openmw_stats_window_layout.xml" "${DDIR}/openmw_stats_window_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_text.skin.xml" "${DDIR}/openmw_text.skin.xml" COPYONLY) configure_file("${SDIR}/openmw_windows.skin.xml" "${DDIR}/openmw_windows.skin.xml" COPYONLY) +configure_file("${SDIR}/openmw_messagebox_layout.xml" "${DDIR}/openmw_messagebox_layout.xml" COPYONLY) configure_file("${SDIR}/smallbars.png" "${DDIR}/smallbars.png" COPYONLY) configure_file("${SDIR}/transparent.png" "${DDIR}/transparent.png" COPYONLY) configure_file("${SDIR}/VeraMono.ttf" "${DDIR}/VeraMono.ttf" COPYONLY) From fc25ccef4e102d12a458a7796a1844ceffa1306b Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 14 Jun 2011 22:11:36 +0200 Subject: [PATCH 24/59] MW_Dialog set ro right propertys --- apps/openmw/mwgui/messagebox.cpp | 25 +++++++++++++++++++ apps/openmw/mwgui/messagebox.hpp | 14 ++++++++--- apps/openmw/mwgui/window_manager.cpp | 2 +- .../openmw_messagebox_layout.xml | 5 +--- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 78235fa8c..1a8c3c169 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -2,6 +2,11 @@ using namespace MWGui; +MessageBoxManager::MessageBoxManager (WindowManager *windowManager) +{ + mWindowManager = windowManager; +} + void MessageBoxManager::createMessageBox (const std::string& message) { std::cout << "create non-interactive message box" << std::endl; @@ -20,4 +25,24 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin , mMessageBoxManager(parMessageBoxManager) { setText("message", message); + + MyGUI::WidgetPtr messageWidget; + getWidget(messageWidget, "message"); + + MyGUI::IntSize size = messageWidget->_getTextSize(); + size.width += 20; + size.height += 20; + + MyGUI::IntSize gameWindowSize = mMessageBoxManager.mWindowManager->getGui()->getViewSize(); + MyGUI::IntCoord coord; + coord.left = (gameWindowSize.width - size.width)/2; + coord.top = (gameWindowSize.height - size.height); + + + std::cout << "Setting MainWidget to position (" << coord.left << "|" << coord.top + << ") and size to (" << size.width << "|" << size.height << ")" << std::endl; + + mMainWidget->setCoord(coord); + mMainWidget->setSize(size); + } diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index 31286dacd..86e9cb28e 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -5,6 +5,7 @@ #include #include "window_base.hpp" +#include "window_manager.hpp" namespace MWGui { @@ -14,18 +15,23 @@ namespace MWGui class MessageBoxManager { - private: - std::vector mMessageBoxes; public: + MessageBoxManager (WindowManager* windowManager); void createMessageBox (const std::string& message); void createInteractiveMessageBox (const std::string& message, const std::vector& buttons); + + WindowManager *mWindowManager; + + private: + std::vector mMessageBoxes; }; class MessageBox : public OEngine::GUI::Layout { public: - MessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message); - void setMessage(const std::string& message); + MessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message); + void setMessage (const std::string& message); + protected: MessageBoxManager& mMessageBoxManager; }; diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 1c9cda677..1c9217a92 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -61,7 +61,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment inventory = new InventoryWindow (); #endif console = new Console(w,h, environment, extensions); - mMessageBoxManager = new MessageBoxManager(); + mMessageBoxManager = new MessageBoxManager(this); // The HUD is always on hud->setVisible(true); diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml index 9debd1096..e2caf1e31 100644 --- a/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml +++ b/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml @@ -2,9 +2,6 @@ - - - - + From 9c56031ee2ec8f80b24dbdc34ca5f1ff6c0e7f4c Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 15 Jun 2011 13:58:57 +0200 Subject: [PATCH 25/59] rudimental implementation of non-interactive MessageBox --- apps/openmw/mwgui/messagebox.cpp | 48 ++++++++++++++++++++++++++++---- apps/openmw/mwgui/messagebox.hpp | 4 +++ 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 1a8c3c169..148a7f98c 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -11,7 +11,23 @@ void MessageBoxManager::createMessageBox (const std::string& message) { std::cout << "create non-interactive message box" << std::endl; MessageBox *box = new MessageBox(*this, message); - mMessageBoxes.push_back(box); + + mMessageBoxes.insert(mMessageBoxes.begin(), box); + int height = box->getHeight(); + std::vector::const_iterator it; + + int i = 0; + for(it = mMessageBoxes.begin(); it != mMessageBoxes.end(); ++it) { + if(i == 3) { + (*it)->del(); + break; + } + else { + (*it)->update(height); + height += (*it)->getHeight(); + i++; + } + } } void MessageBoxManager::createInteractiveMessageBox (const std::string& message, const std::vector& buttons) @@ -25,24 +41,44 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin , mMessageBoxManager(parMessageBoxManager) { setText("message", message); - + update(0); +} + +void MessageBox::update (int height) +{ MyGUI::WidgetPtr messageWidget; getWidget(messageWidget, "message"); MyGUI::IntSize size = messageWidget->_getTextSize(); - size.width += 20; - size.height += 20; + messageWidget->setSize(size); + size.width += 20; // padding between text and border of the box + size.height += 20; // same here MyGUI::IntSize gameWindowSize = mMessageBoxManager.mWindowManager->getGui()->getViewSize(); MyGUI::IntCoord coord; coord.left = (gameWindowSize.width - size.width)/2; - coord.top = (gameWindowSize.height - size.height); + coord.top = (gameWindowSize.height - size.height - height); std::cout << "Setting MainWidget to position (" << coord.left << "|" << coord.top - << ") and size to (" << size.width << "|" << size.height << ")" << std::endl; + << ") and size to (" << size.width << "|" << size.height << ")" + << " while height is " << height << std::endl; mMainWidget->setCoord(coord); mMainWidget->setSize(size); + mHeight = size.height; +} + +void MessageBox::del () +{ + // i dont know how to destroy, but therefor i will just set height and width to zero + MyGUI::IntSize size; + size.width = size.height = 0; + mMainWidget->setSize(size); +} + +int MessageBox::getHeight () +{ + return mHeight+20; // 20 is the padding between this and the next MessageBox } diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index 86e9cb28e..717ec5ab3 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -31,9 +31,13 @@ namespace MWGui public: MessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message); void setMessage (const std::string& message); + int getHeight (); + void update (int height); + void del (); protected: MessageBoxManager& mMessageBoxManager; + int mHeight; }; } From 56affd018ab8d2f0f50ed37ecb91961b11147c01 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Wed, 15 Jun 2011 13:09:47 -0400 Subject: [PATCH 26/59] Some cleanup --- apps/openmw/mwclass/npc.cpp | 15 ++------- apps/openmw/mwsound/soundmanager.hpp | 4 ++- components/bsa/bsa_archive.cpp | 50 +++------------------------- 3 files changed, 10 insertions(+), 59 deletions(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 5afc26480..9ef5e6f40 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -95,8 +95,7 @@ namespace MWClass upperright[uppernumbers++] = npcName + "chest"; neckandup[neckNumbers++] = npcName + "chest"; } - //std::cout << "GETTING NPC PART"; - //Orgre::SceneNode test = cellRender.getNpcPart(); + const ESM::BodyPart *upperleg = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg"); const ESM::BodyPart *groin = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin"); @@ -113,23 +112,18 @@ namespace MWClass const ESM::BodyPart *hands = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands.1st"); - //std::cout << "RACE" << bodyRaceID << "\n"; - Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75); if (groin){ - cellRender.insertMesh("Meshes\\2\\red_MJ_hat_org.nif"); //w/W_6th_Hammer.NIF - //bald_MJ_hat.NIF cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, kOgrePi, npcName + "groin", addresses, numbers); addresses2[numbers] = npcName + "groin"; addresses[numbers++] = npcName + "groin"; } if (tail) { cellRender.insertMesh("tail\\" + tail->model, Ogre::Vector3(0 , 0, -76), axis, kOgrePi, npcName + "tail", addresses, numbers, "tail"); - //std::cout << "TAIL\n"; } - //addresses[1] = npcName + "groin"; + if(upperleg){ cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( 6, 0, -16), axis, kOgrePi, npcName + "upper leg", addresses, numbers); //-18 cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( -6, 0, -16), axis, Ogre::Radian(0), npcName + "upper leg2", addresses2, numbers); @@ -220,9 +214,6 @@ namespace MWClass if(hand) { - //std::cout << "WE FOUND A HAND\n"; - //-50, 0, -120 - //std::cout << "WE FOUND HANDS\n"; std::string pass; if(hand->model.compare("b\\B_N_Dark Elf_F_Hands.1st.NIF")==0 && bodyRaceID.compare("b_n_dark elf_m_") == 0) pass = "b\\B_N_Dark Elf_M_Hands.1st.NIF"; @@ -232,7 +223,6 @@ namespace MWClass cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0,0), kOgrePi, npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120 upperleft[uppernumbers] = npcName + "hand"; upperright[uppernumbers++] = npcName + "hand2"; - //cellRender.rotateMesh(Ogre::Vector3(0, 0,0), kOgrePi, upperleft, uppernumbers); cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers); cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers); } @@ -246,7 +236,6 @@ namespace MWClass else pass =hands->model; //-50, 0, -120 cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1,-110), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "hand", upperleft, uppernumbers, false); //0, 100, -100 42, 0, -110 - //cellRender.insertMesh("meshes\\" + hands->model, Ogre::Vector3(42, 0,110), Ogre::Vector3(1, 0, 0), kOgrePi, npcName + "hand", upperleft, uppernumbers, false); //0, 100, -100 42, 0, -110 cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120 upperleft[uppernumbers] = npcName + "hand"; upperright[uppernumbers++] = npcName + "hand2"; diff --git a/apps/openmw/mwsound/soundmanager.hpp b/apps/openmw/mwsound/soundmanager.hpp index 70e6babf9..ec33f57a2 100644 --- a/apps/openmw/mwsound/soundmanager.hpp +++ b/apps/openmw/mwsound/soundmanager.hpp @@ -33,7 +33,7 @@ namespace MWSound bool fsStrict; void streamMusicFull (const std::string& filename); ///< Play a soundifle - /// \param filename name of a sound file in "Music/" in the data directory. + /// \param absolute filename public: @@ -43,6 +43,8 @@ namespace MWSound ~SoundManager(); void streamMusic(const std::string& filename); + ///< Play a soundifle + /// \param filename name of a sound file in "Music/" in the data directory. void startRandomTitle(); void MP3Lookup(boost::filesystem::path dir); //struct SoundImpl; diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index 09662474f..4b3fbf6c0 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -67,11 +67,11 @@ class DirArchive: public Ogre::FileSystemArchive DirArchive(const String& name) : FileSystemArchive(name, "Dir") - { mType = "Dir"; + { + mType = "Dir"; currentdir = name; std::string s = name; cutoff = s.size() + 1; - //std::cout << "Cut off:" << cutoff; if(fsstrict == false) populateMap(currentdir); @@ -98,7 +98,6 @@ class DirArchive: public Ogre::FileSystemArchive small = s.substr(cutoff - 1, s.size() - cutoff); filesind.push_back(small); - //std::cout << "File: " << small << "f\n"; } } std::string small; @@ -107,9 +106,7 @@ class DirArchive: public Ogre::FileSystemArchive small = original.substr(cutoff, original.size() - cutoff); else small = original.substr(cutoff - 1, original.size() - cutoff); - //boost::filesystem::path smallp = small; m[small] = filesind; - //std::cout << "Directory: " << small << " " << filesind.size() << "\n"; } @@ -120,12 +117,6 @@ class DirArchive: public Ogre::FileSystemArchive void unload() {} bool exists(const String& filename) { - //std::cout << "exists\n"; - //String s = filename; - //FileSystemArchive::findFiles(s, true, false, filenames.getPointer(), f.getPointer()); - // std::cout << "Filenames" << filenames.useCount() << "\n"; - - std::string copy = filename; @@ -140,10 +131,7 @@ class DirArchive: public Ogre::FileSystemArchive if(copy.at(0) == '\\' || copy.at(0) == '/') { - //std::cout << "Before:" << copy.size() << "\n"; copy.erase(0, 1); - //std::cout << "The copy" << copy << "\n"; - //std::cout << "After:" << copy.size(); } if(fsstrict == true) { @@ -162,36 +150,23 @@ class DirArchive: public Ogre::FileSystemArchive break; } - //std::string file = copy.substr(i + 1, copy.size() - i); //filename with no slash std::string folder = copy.substr(0, i); //folder with no slash - - //std::transform(file.begin(), file.end(), file.begin(), tolower); - //boost::filesystem::path folderpath = folder; std::vector current = m[folder]; for(std::vector::iterator iter = current.begin(); iter != current.end(); iter++) { - //std::string loopfile = iter->substr(i + 1, copy.size() - i); //filename with no slash - //std::transform(loopfile.begin(), loopfile.end(), loopfile.begin(), tolower); - //std::string now = *iter; if(comparePortion(*iter, copy, i + 1, copy.size() - i -1) == true){ - //std::cout << "Loopfile:" << copy << "\n"; return FileSystemArchive::exists(*iter); } } - //std::cout << "Filename:" << file << "\n"; - //std::cout << "Full:" << p.string() << "\n"; - //std::cout << "Current:" << folder << "size: " << current.size() << "\n"; - //std::cout << "\nFull:" << p.string() << "\n"<< "Part:" << folderpath.string(); - return false;//FileSystemArchive::exists(copy); + return false; } DataStreamPtr open(const String& filename, bool readonly = true) const { std::map, ciLessBoost> mlocal = m; - //std::cout << "Open\n"; std::string copy = filename; @@ -206,17 +181,13 @@ class DirArchive: public Ogre::FileSystemArchive if(copy.at(0) == '\\' || copy.at(0) == '/') { - //std::cout << "Before:" << copy.size() << "\n"; copy.erase(0, 1); - //std::cout << "The copy" << copy << "\n"; - //std::cout << "After:" << copy.size(); } if(fsstrict == true){ return FileSystemArchive::open(copy, readonly); } - //boost::filesystem::path p = copy; int last = copy.size() - 1; int i = last; @@ -227,28 +198,17 @@ class DirArchive: public Ogre::FileSystemArchive break; } - std::string folder = copy.substr(0, i); //folder with no slash //folder with no slash - - //std::transform(file.begin(), file.end(), file.begin(), tolower); - //boost::filesystem::path folderpath = folder; + std::string folder = copy.substr(0, i); //folder with no slash std::vector current = mlocal[folder]; for(std::vector::iterator iter = current.begin(); iter != current.end(); iter++) { - //std::string loopfile = iter->substr(i + 1, copy.size() - i); //filename with no slash - //std::transform(loopfile.begin(), loopfile.end(), loopfile.begin(), tolower); if(comparePortion(*iter, copy, i + 1, copy.size() - i -1) == true){ - //std::cout << "Loopfile:" << copy << "\n"; return FileSystemArchive::open(*iter, readonly); } } - - //std::cout << "Filename:" << file << "\n"; - //std::cout << "Full:" << p.string() << "\n"; - //std::cout << "Current:" << folder << "size: " << current.size() << "\n"; - //std::cout << "\nFull:" << p.string() << "\n"<< "Part:" << folderpath.string(); DataStreamPtr p; - return p;//FileSystemArchive::open(copy, readonly); + return p; } }; From 6dc35247dac7c501d1527d6a211871e755e80bfa Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 15 Jun 2011 19:42:20 +0200 Subject: [PATCH 27/59] Word wrap for MessageBox --- apps/openmw/mwgui/messagebox.cpp | 53 ++++++++++++------- apps/openmw/mwgui/messagebox.hpp | 4 ++ .../openmw_messagebox_layout.xml | 14 ++++- 3 files changed, 50 insertions(+), 21 deletions(-) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 148a7f98c..a96906d25 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -17,8 +17,8 @@ void MessageBoxManager::createMessageBox (const std::string& message) std::vector::const_iterator it; int i = 0; - for(it = mMessageBoxes.begin(); it != mMessageBoxes.end(); ++it) { - if(i == 3) { + for(it = mMessageBoxes.begin()+1; it != mMessageBoxes.end(); ++it) { + if(i == 2) { (*it)->del(); break; } @@ -39,35 +39,50 @@ void MessageBoxManager::createInteractiveMessageBox (const std::string& message, MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message) : Layout("openmw_messagebox_layout.xml") , mMessageBoxManager(parMessageBoxManager) + , cMessage(message) { - setText("message", message); + mFixedWidth = 300; + mBottomPadding = 20; + + getWidget(mMessageWidget, "message"); + + mMessageWidget->setOverflowToTheLeft(true); + mMessageWidget->addText(cMessage); + + MyGUI::IntSize size; + size.width = mFixedWidth; // fiexd width + size.height = 100; // dummy + + MyGUI::IntCoord coord; + coord.left = 10; // dummy + coord.top = 10; // dummy + + mMessageWidget->setSize(size); + + 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 -= 5; // this is to center the text (see messagebox_layout.xml, Widget type="Edit" position="-2 -3 0 0") + mMessageWidget->setSize(size); + update(0); } void MessageBox::update (int height) { - MyGUI::WidgetPtr messageWidget; - getWidget(messageWidget, "message"); - - MyGUI::IntSize size = messageWidget->_getTextSize(); - messageWidget->setSize(size); - size.width += 20; // padding between text and border of the box - size.height += 20; // same here - MyGUI::IntSize gameWindowSize = mMessageBoxManager.mWindowManager->getGui()->getViewSize(); MyGUI::IntCoord coord; - coord.left = (gameWindowSize.width - size.width)/2; - coord.top = (gameWindowSize.height - size.height - height); + coord.left = (gameWindowSize.width - mFixedWidth)/2; + coord.top = (gameWindowSize.height - mHeight - height - mBottomPadding); - - std::cout << "Setting MainWidget to position (" << coord.left << "|" << coord.top - << ") and size to (" << size.width << "|" << size.height << ")" - << " while height is " << height << std::endl; + MyGUI::IntSize size; + size.width = mFixedWidth; + size.height = mHeight; mMainWidget->setCoord(coord); mMainWidget->setSize(size); - - mHeight = size.height; + mMainWidget->setVisible(true); } void MessageBox::del () diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index 717ec5ab3..e5593473a 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -38,6 +38,10 @@ namespace MWGui protected: MessageBoxManager& mMessageBoxManager; int mHeight; + const std::string& cMessage; + MyGUI::EditPtr mMessageWidget; + int mFixedWidth; + int mBottomPadding; }; } diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml index e2caf1e31..aa1e00258 100644 --- a/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml +++ b/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml @@ -1,7 +1,17 @@ - - + + + + + + + + + + From 94e010b79002ac82c5bfc55329af37c96cdafe44 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 15 Jun 2011 19:53:32 +0200 Subject: [PATCH 28/59] delete all non-interactive MessageBox'es when creating an interactive MessageBox --- apps/openmw/mwgui/messagebox.cpp | 24 +++++++++++++----------- apps/openmw/mwgui/messagebox.hpp | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index a96906d25..92d79d05f 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -12,6 +12,8 @@ void MessageBoxManager::createMessageBox (const std::string& message) std::cout << "create non-interactive message box" << std::endl; MessageBox *box = new MessageBox(*this, message); + // create a timer and delete when ready. + mMessageBoxes.insert(mMessageBoxes.begin(), box); int height = box->getHeight(); std::vector::const_iterator it; @@ -19,7 +21,7 @@ void MessageBoxManager::createMessageBox (const std::string& message) int i = 0; for(it = mMessageBoxes.begin()+1; it != mMessageBoxes.end(); ++it) { if(i == 2) { - (*it)->del(); + delete (*it); break; } else { @@ -34,6 +36,13 @@ void MessageBoxManager::createInteractiveMessageBox (const std::string& message, { std::cout << "create interactive message box" << std::endl; std::copy (buttons.begin(), buttons.end(), std::ostream_iterator (std::cout, ", ")); + + // delete all MessageBox'es + std::vector::const_iterator it; + for(it = mMessageBoxes.begin(); it != mMessageBoxes.end(); it++) { + delete (*it); + } + mMessageBoxes.clear(); } MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message) @@ -43,6 +52,7 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin { mFixedWidth = 300; mBottomPadding = 20; + mNextBoxPadding = 20; getWidget(mMessageWidget, "message"); @@ -50,7 +60,7 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin mMessageWidget->addText(cMessage); MyGUI::IntSize size; - size.width = mFixedWidth; // fiexd width + size.width = mFixedWidth; size.height = 100; // dummy MyGUI::IntCoord coord; @@ -85,15 +95,7 @@ void MessageBox::update (int height) mMainWidget->setVisible(true); } -void MessageBox::del () -{ - // i dont know how to destroy, but therefor i will just set height and width to zero - MyGUI::IntSize size; - size.width = size.height = 0; - mMainWidget->setSize(size); -} - int MessageBox::getHeight () { - return mHeight+20; // 20 is the padding between this and the next MessageBox + return mHeight+mNextBoxPadding; // 20 is the padding between this and the next MessageBox } diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index e5593473a..30e869a72 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -33,7 +33,6 @@ namespace MWGui void setMessage (const std::string& message); int getHeight (); void update (int height); - void del (); protected: MessageBoxManager& mMessageBoxManager; @@ -42,6 +41,7 @@ namespace MWGui MyGUI::EditPtr mMessageWidget; int mFixedWidth; int mBottomPadding; + int mNextBoxPadding; }; } From 0f2df4e2b8c0fcce0dc88405df970ccf272d0601 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Wed, 15 Jun 2011 22:33:31 +0200 Subject: [PATCH 29/59] more cleanup --- apps/openmw/engine.cpp | 3 - apps/openmw/mwclass/creature.cpp | 2 +- apps/openmw/mwrender/cellimp.hpp | 2 - apps/openmw/mwrender/exterior.cpp | 15 -- apps/openmw/mwrender/exterior.hpp | 2 +- apps/openmw/mwrender/interior.cpp | 29 +-- apps/openmw/mwrender/interior.hpp | 2 - apps/openmw/mwsound/soundmanager.cpp | 150 ++++++------ apps/openmw/mwsound/soundmanager.hpp | 19 +- components/bsa/bsa_archive.cpp | 33 ++- components/esm_store/cell_store.hpp | 3 - components/file_finder/file_finder.hpp | 10 +- components/files/multidircollection.hpp | 2 +- components/nif/data.hpp | 310 +++++------------------- components/nifogre/ogre_nif_loader.cpp | 15 -- components/nifogre/ogre_nif_loader.hpp | 12 +- 16 files changed, 176 insertions(+), 433 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 97596301c..483a74eef 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -353,9 +353,6 @@ void OMW::Engine::go() mOgre.configure(!isFile(ogreCfg.c_str()), cfgUserDir, plugCfg, false); - //addResourcesDirectory (mDataDir / "Meshes"); - //addResourcesDirectory (mDataDir / "Textures"); - // This has to be added BEFORE MyGUI is initialized, as it needs // to find core.xml here. addResourcesDirectory(mResDir / "mygui"); diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 5316c8267..0bd133f21 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -34,7 +34,7 @@ namespace MWClass if (!model.empty()) { MWRender::Rendering rendering (cellRender, ref->ref); - cellRender.insertMesh("meshes\\" + model); + cellRender.insertMesh("meshes\\" + model); cellRender.insertActorPhysics(); ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); } diff --git a/apps/openmw/mwrender/cellimp.hpp b/apps/openmw/mwrender/cellimp.hpp index 727c9d317..272bfeeab 100644 --- a/apps/openmw/mwrender/cellimp.hpp +++ b/apps/openmw/mwrender/cellimp.hpp @@ -7,7 +7,6 @@ #include "../mwworld/refdata.hpp" #include -#include namespace Ogre { @@ -43,7 +42,6 @@ namespace MWRender virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst) = 0; virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements) = 0; virtual void insertMesh(const std::string &mesh) = 0; - //virtual Ogre::Entity* insertAndDeliverMesh(const std::string &mesh) = 0; virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements) = 0; diff --git a/apps/openmw/mwrender/exterior.cpp b/apps/openmw/mwrender/exterior.cpp index aa712dede..fe54af84a 100644 --- a/apps/openmw/mwrender/exterior.cpp +++ b/apps/openmw/mwrender/exterior.cpp @@ -273,21 +273,6 @@ std::string ExteriorCellRender::insertEnd (bool enable) return handle; } -/* -Ogre::Entity* ExteriorCellRender::insertAndDeliverMesh(const std::string &mesh) -{ - assert (insert); - - NIFLoader::load(mesh); - Entity *ent = mScene.getMgr()->createEntity(mesh); - ent->setDisplaySkeleton(true); - - - mInsert->attachObject(ent); - return ent; - -}*/ - // configure lighting according to cell void ExteriorCellRender::configureAmbient() diff --git a/apps/openmw/mwrender/exterior.hpp b/apps/openmw/mwrender/exterior.hpp index 87659a213..8458e4dd8 100644 --- a/apps/openmw/mwrender/exterior.hpp +++ b/apps/openmw/mwrender/exterior.hpp @@ -71,7 +71,7 @@ namespace MWRender virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst); virtual void insertMesh(const std::string &mesh); - //virtual Ogre::Entity* insertAndDeliverMesh(const std::string &mesh); + virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements); virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements); diff --git a/apps/openmw/mwrender/interior.cpp b/apps/openmw/mwrender/interior.cpp index 09cce2f6d..201eaf542 100644 --- a/apps/openmw/mwrender/interior.cpp +++ b/apps/openmw/mwrender/interior.cpp @@ -180,32 +180,13 @@ void InteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, } } -/* -Ogre::Entity* InteriorCellRender::insertAndDeliverMesh(const std::string &mesh) -{ - - assert (insert); - - NIFLoader::load(mesh); - Entity *ent = scene.getMgr()->createEntity(mesh); - ent->setDisplaySkeleton(true); - - - insert->attachObject(ent); - return ent; - -}*/ - - void InteriorCellRender::insertMesh(const std::string &mesh) { - assert (insert); - //if(mesh == "\\Meshes\\bald_MJ_hat.NIF") - // NIFLoader::load(mesh, ""); - //else - NIFLoader::load(mesh); - MovableObject *ent = scene.getMgr()->createEntity(mesh); - insert->attachObject(ent); + assert (insert); + + NIFLoader::load(mesh); + MovableObject *ent = scene.getMgr()->createEntity(mesh); + insert->attachObject(ent); if (mInsertMesh.empty()) mInsertMesh = mesh; diff --git a/apps/openmw/mwrender/interior.hpp b/apps/openmw/mwrender/interior.hpp index f77d3358d..7c4b2aaf1 100644 --- a/apps/openmw/mwrender/interior.hpp +++ b/apps/openmw/mwrender/interior.hpp @@ -6,7 +6,6 @@ #include "OgreColourValue.h" #include -#include namespace Ogre { @@ -68,7 +67,6 @@ namespace MWRender virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements); virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements); /// insert a mesh related to the most recent insertBegin call. - //virtual Ogre::Entity* insertAndDeliverMesh(const std::string &mesh); virtual void insertMesh(const std::string &mesh); virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements); virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst); diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index abff70664..970118a13 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -63,7 +63,7 @@ namespace MWSound */ OEManagerPtr mgr; SoundPtr music; - + /* This class calls update() on the sound manager each frame using and Ogre::FrameListener */ @@ -84,11 +84,11 @@ namespace MWSound // finding. It takes DOS paths (any case, \\ slashes or / slashes) // relative to the sound dir, and translates them into full paths // of existing files in the filesystem, if they exist. - bool FSstrict; + bool FSstrict; FileFinder::FileFinder files; - FileFinder::FileFinderStrict strict; - FileFinder::FileFinder musicpath; - FileFinder::FileFinderStrict musicpathStrict; + FileFinder::FileFinderStrict strict; + FileFinder::FileFinder musicpath; + FileFinder::FileFinderStrict musicpathStrict; SoundImpl(Ogre::Root *root, Ogre::Camera *camera, const ESMS::ESMStore &str, @@ -98,9 +98,9 @@ namespace MWSound , cameraTracker(mgr) , store(str) , files(soundDir), strict(soundDir) - ,musicpath(musicDir), musicpathStrict(musicDir) + ,musicpath(musicDir), musicpathStrict(musicDir) { - FSstrict = fsstrict; + FSstrict = fsstrict; cout << "Sound output: " << SOUND_OUT << endl; cout << "Sound decoder: " << SOUND_IN << endl; // Attach the camera to the camera tracker @@ -131,72 +131,74 @@ namespace MWSound bool hasFile(const std::string &str, bool music = false) { - if(FSstrict == false){ - if(music){ - if(musicpath.has(str)) return true; - // Not found? Try with .mp3 - return musicpath.has(toMp3(str)); - } - else - { - if(files.has(str)) return true; - return files.has(toMp3(str)); - } - } - else - { - if(music){ - if(musicpathStrict.has(str)) return true; - // Not found? Try with .mp3 - return musicpathStrict.has(toMp3(str)); - } - else - { - if(strict.has(str)) return true; - return strict.has(toMp3(str)); - } + if(FSstrict == false) + { + if(music) + { + if(musicpath.has(str)) return true; - } - } + // Not found? Try with .mp3 + return musicpath.has(toMp3(str)); + } + else + { + if(files.has(str)) return true; + return files.has(toMp3(str)); + } + } + else + { + if(music) + { + if(musicpathStrict.has(str)) return true; + + // Not found? Try with .mp3 + return musicpathStrict.has(toMp3(str)); + } + else + { + if(strict.has(str)) return true; + return strict.has(toMp3(str)); + } + } + } // Convert a Morrowind sound path (eg. Fx\funny.wav) to full path // with proper slash conversion (eg. datadir/Sound/Fx/funny.wav) std::string convertPath(const std::string &str, bool music = false) { - if(FSstrict == false){ - // Search and return - if(music && musicpath.has(str)) - return musicpath.lookup(str); - else if(files.has(str)) - return files.lookup(str); + if(FSstrict == false) + { + // Search and return + if(music && musicpath.has(str)) + return musicpath.lookup(str); + else if(files.has(str)) + return files.lookup(str); + // Try mp3 if the wav wasn't found + std::string mp3 = toMp3(str); + if(music && musicpath.has(mp3)) + return musicpath.lookup(mp3); + else if(files.has(mp3)) + return files.lookup(mp3); + } + else + { + if(music && musicpathStrict.has(str)) + return musicpathStrict.lookup(str); + else if(strict.has(str)) + return strict.lookup(str); - // Try mp3 if the wav wasn't found - std::string mp3 = toMp3(str); - if(music && musicpath.has(mp3)) - return musicpath.lookup(mp3); - else if(files.has(mp3)) - return files.lookup(mp3); - } + // Try mp3 if the wav wasn't found + std::string mp3 = toMp3(str); + if(music && musicpathStrict.has(mp3)) + return musicpathStrict.lookup(mp3); + else if(strict.has(str)) + return strict.lookup(mp3); + } - else - { - if(music && musicpathStrict.has(str)) - return musicpathStrict.lookup(str); - else if(strict.has(str)) - return strict.lookup(str); - - - // Try mp3 if the wav wasn't found - std::string mp3 = toMp3(str); - if(music && musicpathStrict.has(mp3)) - return musicpathStrict.lookup(mp3); - else if(strict.has(str)) - return strict.lookup(mp3); - } - - // Give up - return ""; + // Give up + return ""; } // Convert a soundId to file name, and modify the volume @@ -377,9 +379,8 @@ namespace MWSound const ESMS::ESMStore &store, boost::filesystem::path dataDir, bool useSound, bool fsstrict) - : mData(NULL) + : mData(NULL), fsStrict (fsstrict) { - fsStrict = fsstrict; MP3Lookup(dataDir / "Music/Explore/"); if(useSound) mData = new SoundImpl(root, camera, store, (dataDir / "Sound").string(), (dataDir / "Music").string(), fsstrict); @@ -391,13 +392,14 @@ namespace MWSound delete mData; } - void SoundManager::streamMusic(const std::string& filename){ - if(mData->hasFile(filename, true)) - { - std::string fullpath = mData->convertPath(filename, true); - streamMusicFull(fullpath); - } - } + void SoundManager::streamMusic(const std::string& filename) + { + if(mData->hasFile(filename, true)) + { + std::string fullpath = mData->convertPath(filename, true); + streamMusicFull(fullpath); + } + } void SoundManager::MP3Lookup(boost::filesystem::path dir) @@ -476,7 +478,7 @@ namespace MWSound return !mData->isPlaying(ptr, "_say_sound"); } - + void SoundManager::playSound (const std::string& soundId, float volume, float pitch) { if(!mData) return; diff --git a/apps/openmw/mwsound/soundmanager.hpp b/apps/openmw/mwsound/soundmanager.hpp index ec33f57a2..ab9559176 100644 --- a/apps/openmw/mwsound/soundmanager.hpp +++ b/apps/openmw/mwsound/soundmanager.hpp @@ -27,27 +27,28 @@ namespace MWSound // Hide implementation details - engine.cpp is compiling // enough as it is. struct SoundImpl; - + SoundImpl *mData; std::vector files; - bool fsStrict; - void streamMusicFull (const std::string& filename); + bool fsStrict; + + void streamMusicFull (const std::string& filename); ///< Play a soundifle /// \param absolute filename - + public: - SoundManager(Ogre::Root*, Ogre::Camera*, const ESMS::ESMStore &store, boost::filesystem::path dataDir, bool useSound, bool fsstrict); ~SoundManager(); - void streamMusic(const std::string& filename); - ///< Play a soundifle + void streamMusic(const std::string& filename); + ///< Play a soundifle /// \param filename name of a sound file in "Music/" in the data directory. + void startRandomTitle(); void MP3Lookup(boost::filesystem::path dir); - //struct SoundImpl; + bool isMusicPlaying(); SoundImpl getMData(); @@ -59,7 +60,7 @@ namespace MWSound bool sayDone (MWWorld::Ptr reference) const; ///< Is actor not speaking? - + void playSound (const std::string& soundId, float volume, float pitch); ///< Play a sound, independently of 3D-position diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index f1cf21710..f29b8b237 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -66,14 +66,13 @@ class DirArchive: public Ogre::FileSystemArchive public: DirArchive(const String& name) - : FileSystemArchive(name, "Dir") - { - mType = "Dir"; - currentdir = name; - std::string s = name; - cutoff = s.size() + 1; - if(fsstrict == false) - populateMap(currentdir); + : FileSystemArchive(name, "Dir"), currentdir (name) + { + mType = "Dir"; + std::string s = name; + cutoff = s.size() + 1; + if(fsstrict == false) + populateMap(currentdir); } void populateMap(boost::filesystem::path d){ @@ -134,11 +133,10 @@ class DirArchive: public Ogre::FileSystemArchive copy.erase(0, 1); } if(fsstrict == true) - { - //std::cout << "fsstrict " << copy << "\n"; - return FileSystemArchive::exists(copy); - - } + { + //std::cout << "fsstrict " << copy << "\n"; + return FileSystemArchive::exists(copy); + } int last = copy.size() - 1; @@ -185,9 +183,10 @@ class DirArchive: public Ogre::FileSystemArchive copy.erase(0, 1); } - if(fsstrict == true){ - return FileSystemArchive::open(copy, readonly); - } + if(fsstrict == true) + { + return FileSystemArchive::open(copy, readonly); + } int last = copy.size() - 1; @@ -199,7 +198,7 @@ class DirArchive: public Ogre::FileSystemArchive break; } - std::string folder = copy.substr(0, i); //folder with no slash + std::string folder = copy.substr(0, i); //folder with no slash std::vector current = mlocal[folder]; for(std::vector::iterator iter = current.begin(); iter != current.end(); iter++) diff --git a/components/esm_store/cell_store.hpp b/components/esm_store/cell_store.hpp index a55bb3d0e..43860dff3 100644 --- a/components/esm_store/cell_store.hpp +++ b/components/esm_store/cell_store.hpp @@ -14,7 +14,6 @@ #include "components/esm/records.hpp" #include "components/esm/loadcell.hpp" #include -#include #include #include @@ -30,8 +29,6 @@ namespace ESMS // The object that this instance is based on. const X* base; - Ogre::Entity *model; - /* Information about this instance, such as 3D location and rotation and individual type-dependent data. */ diff --git a/components/file_finder/file_finder.hpp b/components/file_finder/file_finder.hpp index 358563afa..0e1e07226 100644 --- a/components/file_finder/file_finder.hpp +++ b/components/file_finder/file_finder.hpp @@ -20,9 +20,9 @@ class FileFinderT void add(const boost::filesystem::path &pth) { - std::string file = pth.string(); - std::string key = file.substr(cut); - owner->table[key] = file; + std::string file = pth.string(); + std::string key = file.substr(cut); + owner->table[key] = file; } }; @@ -50,13 +50,13 @@ public: bool has(const std::string& file) const { - return table.find(file) != table.end(); + return table.find(file) != table.end(); } // Find the full path from a relative path. const std::string &lookup(const std::string& file) const { - return table.find(file)->second; + return table.find(file)->second; } }; diff --git a/components/files/multidircollection.hpp b/components/files/multidircollection.hpp index a4345fb82..898700c06 100644 --- a/components/files/multidircollection.hpp +++ b/components/files/multidircollection.hpp @@ -23,7 +23,7 @@ namespace Files return left -#include namespace Nif { @@ -435,266 +434,71 @@ public: class NiKeyframeData : public Record { - - //Rotations - std::vector quats; - std::vector tbc; - std::vector rottime; - int rtype; + public: - //Translations - std::vector translist1; - std::vector translist2; - std::vector translist3; - std::vector transtbc; - std::vector transtime; - int ttype; + void read(NIFFile *nif) + { + // Rotations first + int count = nif->getInt(); + if(count) + { + int type = nif->getInt(); - //Scalings + if(type == 1) + nif->skip(count*4*5); // time + quaternion + else if(type == 3) + nif->skip(count*4*8); // rot1 + tension+bias+continuity + else if(type == 4) + { + for(int j=0;jgetFloat(); // time + for(int i=0; i<3; i++) + { + int cnt = nif->getInt(); + int type = nif->getInt(); + if(type == 1) + nif->skip(cnt*4*2); // time + unknown + else if(type == 2) + nif->skip(cnt*4*4); // time + unknown vector + else nif->fail("Unknown sub-rotation type"); + } + } + } + else nif->fail("Unknown rotation type in NiKeyframeData"); + } - std::vector scalefactor; - std::vector scaletime; - std::vector forwards; - std::vector backwards; - std::vector tbcscale; - int stype; + // Then translation + count = nif->getInt(); -public: + if(count) + { + int type = nif->getInt(); - void read(NIFFile *nif) - { - // Rotations first - int count = nif->getInt(); - //std::vector quat(count); - //std::vector rottime(count); - std::cout << "r"; - if(count) - { + if(type == 1) + nif->getFloatLen(count*4); // time + translation + else if(type == 2) + nif->getFloatLen(count*10); // trans1 + forward + backward + else if(type == 3) + nif->getFloatLen(count*7); // trans1 + tension,bias,continuity + else nif->fail("Unknown translation type"); + } - //TYPE1 LINEAR_KEY - //TYPE2 QUADRATIC_KEY - //TYPE3 TBC_KEY - //TYPE4 XYZ_ROTATION_KEY - //TYPE5 UNKNOWN_KEY - rtype = nif->getInt(); - //std::cout << "Count: " << count << "Type: " << type << "\n"; + // Finally, scalings + count = nif->getInt(); + if(count) + { + int type = nif->getInt(); - if(rtype == 1) - { - //We need to actually read in these values instead of skipping them - //nif->skip(count*4*5); // time + quaternion - for (int i = 0; i < count; i++) { - float time = nif->getFloat(); - float w = nif->getFloat(); - float x = nif->getFloat(); - float y = nif->getFloat(); - float z = nif->getFloat(); - Ogre::Quaternion quat = Ogre::Quaternion(Ogre::Real(w), Ogre::Real(x), Ogre::Real(y), Ogre::Real(z)); - quats.push_back(quat); - rottime.push_back(time); - //if(time == 0.0 || time > 355.5) - // std::cout <<"Time:" << time << "W:" << w <<"X:" << x << "Y:" << y << "Z:" << z << "\n"; - } - } - else if(rtype == 3) - { //Example - node 116 in base_anim.nif - for (int i = 0; i < count; i++) { - float time = nif->getFloat(); - float w = nif->getFloat(); - float x = nif->getFloat(); - float y = nif->getFloat(); - float z = nif->getFloat(); - - float tbcx = nif->getFloat(); - float tbcy = nif->getFloat(); - float tbcz = nif->getFloat(); - Ogre::Quaternion quat = Ogre::Quaternion(Ogre::Real(w), Ogre::Real(x), Ogre::Real(y), Ogre::Real(z)); - Ogre::Vector3 vec = Ogre::Vector3(tbcx, tbcy, tbcz); - quats.push_back(quat); - rottime.push_back(time); - tbc.push_back(vec); - //if(time == 0.0 || time > 355.5) - // std::cout <<"Time:" << time << "W:" << w <<"X:" << x << "Y:" << y << "Z:" << z << "\n"; - } - - //nif->skip(count*4*8); // rot1 + tension+bias+continuity - } - else if(rtype == 4) - { - for(int j=0;jgetFloat(); // time - for(int i=0; i<3; i++) - { - int cnt = nif->getInt(); - int type = nif->getInt(); - if(type == 1) - nif->skip(cnt*4*2); // time + unknown - else if(type == 2) - nif->skip(cnt*4*4); // time + unknown vector - else nif->fail("Unknown sub-rotation type"); - } - } - } - else nif->fail("Unknown rotation type in NiKeyframeData"); - } - //first = false; - - // Then translation - count = nif->getInt(); - - if(count) - { - ttype = nif->getInt(); - - //std::cout << "TransCount:" << count << " Type: " << type << "\n"; - if(ttype == 1) { - for (int i = 0; i < count; i++) { - float time = nif->getFloat(); - float x = nif->getFloat(); - float y = nif->getFloat(); - float z = nif->getFloat(); - Ogre::Vector3 trans = Ogre::Vector3(x, y, z); - translist1.push_back(trans); - transtime.push_back(time); - } - //nif->getFloatLen(count*4); // time + translation - } - else if(ttype == 2) - { //Example - node 116 in base_anim.nif - for (int i = 0; i < count; i++) { - float time = nif->getFloat(); - float x = nif->getFloat(); - float y = nif->getFloat(); - float z = nif->getFloat(); - float x2 = nif->getFloat(); - float y2 = nif->getFloat(); - float z2 = nif->getFloat(); - float x3 = nif->getFloat(); - float y3 = nif->getFloat(); - float z3 = nif->getFloat(); - Ogre::Vector3 trans = Ogre::Vector3(x, y, z); - Ogre::Vector3 trans2 = Ogre::Vector3(x2, y2, z2); - Ogre::Vector3 trans3 = Ogre::Vector3(x3, y3, z3); - transtime.push_back(time); - translist1.push_back(trans); - translist2.push_back(trans2); - translist3.push_back(trans3); - } - - //nif->getFloatLen(count*10); // trans1 + forward + backward - } - else if(ttype == 3){ - for (int i = 0; i < count; i++) { - float time = nif->getFloat(); - float x = nif->getFloat(); - float y = nif->getFloat(); - float z = nif->getFloat(); - float t = nif->getFloat(); - float b = nif->getFloat(); - float c = nif->getFloat(); - Ogre::Vector3 trans = Ogre::Vector3(x, y, z); - Ogre::Vector3 tbc = Ogre::Vector3(t, b, c); - translist1.push_back(trans); - transtbc.push_back(tbc); - transtime.push_back(time); - } - //nif->getFloatLen(count*7); // trans1 + tension,bias,continuity - } - else nif->fail("Unknown translation type"); - } - - // Finally, scalings - count = nif->getInt(); - if(count) - { - stype = nif->getInt(); - - - for(int i = 0; i < count; i++){ - - - //int size = 0; - if(stype >= 1 && stype < 4) - { - float time = nif->getFloat(); - float scale = nif->getFloat(); - scaletime.push_back(time); - scalefactor.push_back(scale); - //size = 2; // time+scale - } - else nif->fail("Unknown scaling type"); - if(stype == 2){ - //size = 4; // 1 + forward + backward (floats) - float forward = nif->getFloat(); - float backward = nif->getFloat(); - forwards.push_back(forward); - backwards.push_back(backward); - } - else if(stype == 3){ - float tbcx = nif->getFloat(); - float tbcy = nif->getFloat(); - float tbcz = nif->getFloat(); - Ogre::Vector3 vec = Ogre::Vector3(tbcx, tbcy, tbcz); - tbcscale.push_back(vec); - - //size = 5; // 1 + tbc - } - - } - } - else - stype = 0; - } - int getRtype(){ - return rtype; - } - int getStype(){ - return stype; - } - int getTtype(){ - return ttype; - } - std::vector getQuat(){ - return quats; - } - std::vector getrTbc(){ - return tbc; - } - std::vector getrTime(){ - return rottime; - } - - std::vector getTranslist1(){ - return translist1; - } - std::vector getTranslist2(){ - return translist2; - } - std::vector getTranslist3(){ - return translist3; - } - std::vector gettTime(){ - return transtime; - } - std::vector getScalefactor(){ - return scalefactor; - } - std::vector getForwards(){ - return forwards; - } - std::vector getBackwards(){ - return backwards; - } - std::vector getScaleTbc(){ - return tbcscale; - } - - std::vector getsTime(){ - return scaletime; - } + int size = 0; + if(type == 1) size = 2; // time+scale + else if(type == 2) size = 4; // 1 + forward + backward (floats) + else if(type == 3) size = 5; // 1 + tbc + else nif->fail("Unknown scaling type"); + nif->getFloatLen(count*size); + } + } }; - } // Namespace #endif diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index 8219a224c..bdd9417a6 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -1068,11 +1068,6 @@ void NIFLoader::loadResource(Resource *resource) // Handle the node handleNode(node, 0, NULL, bounds, 0); - - short handle = 0; - //skel->setBlendMode(Ogre::SkeletonAnimationBlendMode::ANIMBLEND_CUMULATIVE); - bool first = true; - // set the bounding value. if (bounds.isValid()) { @@ -1081,16 +1076,6 @@ void NIFLoader::loadResource(Resource *resource) mesh->_setBoundingSphereRadius(bounds.getRadius()); } - - - - // set skeleton - if (!mSkel.isNull() && mesh->isLoaded()) - { - mesh->_notifySkeleton(mSkel); - std::cout << "Skeleton notified\n"; - } - // set skeleton // if (!skel.isNull()) // mesh->setSkeletonName(getSkeletonName()); diff --git a/components/nifogre/ogre_nif_loader.hpp b/components/nifogre/ogre_nif_loader.hpp index a619d3a3b..736d1ab1e 100644 --- a/components/nifogre/ogre_nif_loader.hpp +++ b/components/nifogre/ogre_nif_loader.hpp @@ -73,11 +73,11 @@ class NIFLoader : Ogre::ManualResourceLoader virtual void loadResource(Ogre::Resource *resource); - static Ogre::MeshPtr load(const std::string &name, + static Ogre::MeshPtr load(const std::string &name, const std::string &group="General"); - + Ogre::Vector3 convertVector3(const Nif::Vector& vec); Ogre::Quaternion convertRotation(const Nif::Matrix& rot); @@ -113,7 +113,7 @@ class NIFLoader : Ogre::ManualResourceLoader { return resourceName + ".skel"; } - + // This is the interface to the Ogre resource system. It allows us to // load NIFs from BSAs, in the file system and in any other place we // tell Ogre to look (eg. in zip or rar files.) It's also used to @@ -131,11 +131,7 @@ class NIFLoader : Ogre::ManualResourceLoader int counter; int numbers; int stack; - bool anim; - int handle2; - Ogre::Animation* animcore; - Ogre::Animation* animcore2; - + // pointer to the ogre mesh which is currently build Ogre::Mesh *mesh; From a4217f8fb809f6f9c7efc11534a29ebd62f3934c Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 15 Jun 2011 22:53:05 +0200 Subject: [PATCH 30/59] Everything should work fine but deleting the existing MessageBox'es. --- apps/openmw/engine.cpp | 3 ++ apps/openmw/mwgui/messagebox.cpp | 47 +++++++++++++++++++++++++--- apps/openmw/mwgui/messagebox.hpp | 16 +++++++++- apps/openmw/mwgui/window_manager.cpp | 5 +++ apps/openmw/mwgui/window_manager.hpp | 2 ++ 5 files changed, 68 insertions(+), 5 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index b2ed0a767..1aa442c15 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -152,6 +152,9 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) try { mEnvironment.mFrameDuration = evt.timeSinceLastFrame; + + // + mEnvironment.mWindowManager->onFrame(mEnvironment.mFrameDuration); // global scripts mEnvironment.mGlobalScripts->run (mEnvironment); diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 92d79d05f..43de3ff0d 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -5,6 +5,22 @@ using namespace MWGui; MessageBoxManager::MessageBoxManager (WindowManager *windowManager) { mWindowManager = windowManager; + // defines + mMessageBoxSpeed = 0.1; +} + +void MessageBoxManager::onFrame (float frameDuration) +{ + std::vector::const_iterator it; + for(it = mTimers.begin(); it != mTimers.end(); it++) + { + (*it)->current += frameDuration; + if((*it)->current >= (*it)->max) + { + // FIXME: delete the messagebox and erase it from the vector + std::cout << "delete MessageBox" << std::endl; + } + } } void MessageBoxManager::createMessageBox (const std::string& message) @@ -12,16 +28,18 @@ void MessageBoxManager::createMessageBox (const std::string& message) std::cout << "create non-interactive message box" << std::endl; MessageBox *box = new MessageBox(*this, message); - // create a timer and delete when ready. + removeMessageBox(message.length()*mMessageBoxSpeed, box); mMessageBoxes.insert(mMessageBoxes.begin(), box); int height = box->getHeight(); std::vector::const_iterator it; int i = 0; - for(it = mMessageBoxes.begin()+1; it != mMessageBoxes.end(); ++it) { + for(it = mMessageBoxes.begin()+1; it != mMessageBoxes.end(); ++it) + { if(i == 2) { delete (*it); + // FIXME: erase it from the vector without segfault :/ break; } else { @@ -30,6 +48,7 @@ void MessageBoxManager::createMessageBox (const std::string& message) i++; } } + std::cout << "mMessageBoxes.size() is " << mMessageBoxes.size() << std::endl; } void MessageBoxManager::createInteractiveMessageBox (const std::string& message, const std::vector& buttons) @@ -37,19 +56,39 @@ void MessageBoxManager::createInteractiveMessageBox (const std::string& message, std::cout << "create interactive message box" << std::endl; std::copy (buttons.begin(), buttons.end(), std::ostream_iterator (std::cout, ", ")); - // delete all MessageBox'es + // FIXME: erase it from the vector without segfault :/ std::vector::const_iterator it; - for(it = mMessageBoxes.begin(); it != mMessageBoxes.end(); it++) { + for(it = mMessageBoxes.begin(); it != mMessageBoxes.end(); it++) + { delete (*it); } mMessageBoxes.clear(); } +void MessageBoxManager::removeMessageBox (float time, MessageBox *msgbox) +{ + MessageBoxManagerTimer *timer; + timer->current = 0; + timer->max = time; + timer->messageBox = msgbox; + + mTimers.insert(mTimers.end(), timer); +} + +void MessageBoxManager::setMessageBoxSpeed (int speed) +{ + mMessageBoxSpeed = speed; +} + + + + MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message) : Layout("openmw_messagebox_layout.xml") , mMessageBoxManager(parMessageBoxManager) , cMessage(message) { + // defines mFixedWidth = 300; mBottomPadding = 20; mNextBoxPadding = 20; diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index 30e869a72..166a87011 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -3,27 +3,41 @@ #include #include +#include #include "window_base.hpp" #include "window_manager.hpp" + namespace MWGui { - + class MessageBoxManager; class MessageBox; + struct MessageBoxManagerTimer { + float current; + float max; + MessageBox *messageBox; + }; + class MessageBoxManager { public: MessageBoxManager (WindowManager* windowManager); + void onFrame (float frameDuration); void createMessageBox (const std::string& message); void createInteractiveMessageBox (const std::string& message, const std::vector& buttons); + void removeMessageBox (float time, MessageBox *msgbox); + void setMessageBoxSpeed (int speed); + WindowManager *mWindowManager; private: std::vector mMessageBoxes; + std::vector mTimers; + float mMessageBoxSpeed; }; class MessageBox : public OEngine::GUI::Layout diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 1c9217a92..8e9a14837 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -566,6 +566,11 @@ void WindowManager::onClassChoice(int _index) }; } +void WindowManager::onFrame (float frameDuration) +{ + mMessageBoxManager->onFrame(frameDuration); +} + namespace MWGui { diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 92f19cdc3..ebe115d30 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -249,6 +249,8 @@ namespace MWGui ///< Hides dialog and schedules dialog to be deleted. void messageBox (const std::string& message, const std::vector& buttons); + + void onFrame (float frameDuration); /** * Fetches a GMST string from the store, if there is no setting with the given From 4d1db13c8f76a24a509a69baea177bbba68a674d Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Thu, 16 Jun 2011 12:12:50 +0200 Subject: [PATCH 31/59] MessageBoxmangerTimer is now working properly --- apps/openmw/mwgui/messagebox.cpp | 15 +++++++-------- apps/openmw/mwgui/messagebox.hpp | 3 +-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 43de3ff0d..6baf496a4 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -11,14 +11,13 @@ MessageBoxManager::MessageBoxManager (WindowManager *windowManager) void MessageBoxManager::onFrame (float frameDuration) { - std::vector::const_iterator it; + std::vector::iterator it; for(it = mTimers.begin(); it != mTimers.end(); it++) { - (*it)->current += frameDuration; - if((*it)->current >= (*it)->max) + it->current += frameDuration; + if(it->current >= it->max) { // FIXME: delete the messagebox and erase it from the vector - std::cout << "delete MessageBox" << std::endl; } } } @@ -67,10 +66,10 @@ void MessageBoxManager::createInteractiveMessageBox (const std::string& message, void MessageBoxManager::removeMessageBox (float time, MessageBox *msgbox) { - MessageBoxManagerTimer *timer; - timer->current = 0; - timer->max = time; - timer->messageBox = msgbox; + MessageBoxManagerTimer timer; + timer.current = 0; + timer.max = time; + timer.messageBox = msgbox; mTimers.insert(mTimers.end(), timer); } diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index 166a87011..94a4407be 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -3,7 +3,6 @@ #include #include -#include #include "window_base.hpp" #include "window_manager.hpp" @@ -36,7 +35,7 @@ namespace MWGui private: std::vector mMessageBoxes; - std::vector mTimers; + std::vector mTimers; float mMessageBoxSpeed; }; From b72e9d3b2bac35a73ecb6d8c5684114d9ebd2733 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Thu, 16 Jun 2011 13:02:49 +0200 Subject: [PATCH 32/59] non-interactive MessageBox is finished. Didn't find any bugs. --- apps/openmw/mwgui/messagebox.cpp | 41 ++++++++++++++++++++++++-------- apps/openmw/mwgui/messagebox.hpp | 1 + 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 6baf496a4..76b35eab3 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -12,33 +12,39 @@ MessageBoxManager::MessageBoxManager (WindowManager *windowManager) void MessageBoxManager::onFrame (float frameDuration) { std::vector::iterator it; - for(it = mTimers.begin(); it != mTimers.end(); it++) + for(it = mTimers.begin(); it != mTimers.end();) { it->current += frameDuration; if(it->current >= it->max) { - // FIXME: delete the messagebox and erase it from the vector + removeMessageBox(it->messageBox); + it = mTimers.erase(it); + } + else + { + it++; } } } void MessageBoxManager::createMessageBox (const std::string& message) { - std::cout << "create non-interactive message box" << std::endl; + std::cout << "MessageBox: " << message << std::endl; + MessageBox *box = new MessageBox(*this, message); removeMessageBox(message.length()*mMessageBoxSpeed, box); mMessageBoxes.insert(mMessageBoxes.begin(), box); int height = box->getHeight(); - std::vector::const_iterator it; + std::vector::iterator it; int i = 0; for(it = mMessageBoxes.begin()+1; it != mMessageBoxes.end(); ++it) { if(i == 2) { delete (*it); - // FIXME: erase it from the vector without segfault :/ + mMessageBoxes.erase(it); break; } else { @@ -47,19 +53,19 @@ void MessageBoxManager::createMessageBox (const std::string& message) i++; } } - std::cout << "mMessageBoxes.size() is " << mMessageBoxes.size() << std::endl; } void MessageBoxManager::createInteractiveMessageBox (const std::string& message, const std::vector& buttons) { - std::cout << "create interactive message box" << std::endl; + std::cout << "interactive MessageBox: " << message << " - "; std::copy (buttons.begin(), buttons.end(), std::ostream_iterator (std::cout, ", ")); + std::cout << std::endl; - // FIXME: erase it from the vector without segfault :/ - std::vector::const_iterator it; - for(it = mMessageBoxes.begin(); it != mMessageBoxes.end(); it++) + std::vector::iterator it = mMessageBoxes.begin(); + while(it != mMessageBoxes.end()) { delete (*it); + it = mMessageBoxes.erase(it); } mMessageBoxes.clear(); } @@ -74,6 +80,21 @@ void MessageBoxManager::removeMessageBox (float time, MessageBox *msgbox) mTimers.insert(mTimers.end(), timer); } +bool MessageBoxManager::removeMessageBox (MessageBox *msgbox) +{ + std::vector::iterator it; + for(it = mMessageBoxes.begin(); it != mMessageBoxes.end(); ++it) + { + if((*it) == msgbox) + { + delete (*it); + mMessageBoxes.erase(it); + return true; + } + } + return false; +} + void MessageBoxManager::setMessageBoxSpeed (int speed) { mMessageBoxSpeed = speed; diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index 94a4407be..37c4db77a 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -29,6 +29,7 @@ namespace MWGui void createInteractiveMessageBox (const std::string& message, const std::vector& buttons); void removeMessageBox (float time, MessageBox *msgbox); + bool removeMessageBox (MessageBox *msgbox); void setMessageBoxSpeed (int speed); WindowManager *mWindowManager; From 5198de53b86b83bcaf4a288d9cab6d9980992dbc Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Thu, 16 Jun 2011 15:16:35 +0200 Subject: [PATCH 33/59] add the new header to the cmake script --- apps/openmw/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index bb62c0044..492c3869b 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -50,6 +50,7 @@ set(GAMEGUI_HEADER mwgui/dialogue_history.hpp mwgui/window_base.hpp mwgui/stats_window.hpp + mwgui/messagebox.hpp ) set(GAMEGUI mwgui/window_manager.cpp From 315f4078c625b506bb118a882f22d9872fab19ec Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Thu, 16 Jun 2011 17:11:50 +0200 Subject: [PATCH 34/59] make them behave like the MessageBox in the original game --- apps/openmw/mwgui/messagebox.cpp | 48 +++++++++++++++++++++++--------- apps/openmw/mwgui/messagebox.hpp | 2 ++ 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 76b35eab3..d9117a896 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -17,7 +17,28 @@ void MessageBoxManager::onFrame (float frameDuration) it->current += frameDuration; if(it->current >= it->max) { - removeMessageBox(it->messageBox); + it->messageBox->mMarkedToDelete = true; + + if(*mMessageBoxes.begin() == it->messageBox) // if this box is the last one + { + // collect all with mMarkedToDelete and delete them. + // and place the other messageboxes on the right position + int height = 0; + std::vector::iterator it2 = mMessageBoxes.begin(); + while(it2 != mMessageBoxes.end()) + { + if((*it2)->mMarkedToDelete) + { + delete (*it2); + it2 = mMessageBoxes.erase(it2); + } + else { + (*it2)->update(height); + height += (*it2)->getHeight(); + it2++; + } + } + } it = mTimers.erase(it); } else @@ -35,22 +56,24 @@ void MessageBoxManager::createMessageBox (const std::string& message) removeMessageBox(message.length()*mMessageBoxSpeed, box); - mMessageBoxes.insert(mMessageBoxes.begin(), box); - int height = box->getHeight(); + mMessageBoxes.push_back(box); std::vector::iterator it; - int i = 0; - for(it = mMessageBoxes.begin()+1; it != mMessageBoxes.end(); ++it) + if(mMessageBoxes.size() > 3) { + delete *mMessageBoxes.begin(); + mMessageBoxes.erase(mMessageBoxes.begin()); + } + + int height = 0; + for(it = mMessageBoxes.begin(); it != mMessageBoxes.end(); ++it) { - if(i == 2) { - delete (*it); - mMessageBoxes.erase(it); - break; + if((*it) == box) + { + std::cout << "update(" << height << ")" << std::endl; + box->update(height); } else { - (*it)->update(height); height += (*it)->getHeight(); - i++; } } } @@ -112,6 +135,7 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin mFixedWidth = 300; mBottomPadding = 20; mNextBoxPadding = 20; + mMarkedToDelete = false; getWidget(mMessageWidget, "message"); @@ -134,8 +158,6 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin mMainWidget->setSize(size); size.width -= 5; // this is to center the text (see messagebox_layout.xml, Widget type="Edit" position="-2 -3 0 0") mMessageWidget->setSize(size); - - update(0); } void MessageBox::update (int height) diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index 37c4db77a..fe58a31c8 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -48,6 +48,8 @@ namespace MWGui int getHeight (); void update (int height); + bool mMarkedToDelete; + protected: MessageBoxManager& mMessageBoxManager; int mHeight; From d74f834735ab44319fd1e51c53b8c11540ce2d1e Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Thu, 16 Jun 2011 18:12:50 +0200 Subject: [PATCH 35/59] make to boxes apear on the correct place even if the oldest is erased --- apps/openmw/mwgui/messagebox.cpp | 12 +++--------- .../openmw_resources/openmw_messagebox_layout.xml | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index d9117a896..28aae874f 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -67,14 +67,8 @@ void MessageBoxManager::createMessageBox (const std::string& message) int height = 0; for(it = mMessageBoxes.begin(); it != mMessageBoxes.end(); ++it) { - if((*it) == box) - { - std::cout << "update(" << height << ")" << std::endl; - box->update(height); - } - else { - height += (*it)->getHeight(); - } + (*it)->update(height); + height += (*it)->getHeight(); } } @@ -156,7 +150,7 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin size.height = mHeight = textSize.height + 20; // this is the padding between the text and the box mMainWidget->setSize(size); - size.width -= 5; // this is to center the text (see messagebox_layout.xml, Widget type="Edit" position="-2 -3 0 0") + size.width -= 15; // this is to center the text (see messagebox_layout.xml, Widget type="Edit" position="-2 -3 0 0") mMessageWidget->setSize(size); } diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml index aa1e00258..fb4235ff1 100644 --- a/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml +++ b/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml @@ -5,7 +5,7 @@ - + From e77240dceb116438b9875cf9ac533960f8b444b0 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Sat, 18 Jun 2011 15:50:41 +0200 Subject: [PATCH 36/59] basics for InteractiveMessageBox --- apps/openmw/mwgui/messagebox.cpp | 19 +++++++++++++++++++ apps/openmw/mwgui/messagebox.hpp | 13 +++++++++++++ extern/mygui_3.0.1/CMakeLists.txt | 1 + .../openmw_interactive_messagebox_layout.xml | 19 +++++++++++++++++++ .../openmw_messagebox_layout.xml | 2 ++ 5 files changed, 54 insertions(+) create mode 100644 extern/mygui_3.0.1/openmw_resources/openmw_interactive_messagebox_layout.xml diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 28aae874f..1527bde4c 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -78,6 +78,10 @@ void MessageBoxManager::createInteractiveMessageBox (const std::string& message, std::copy (buttons.begin(), buttons.end(), std::ostream_iterator (std::cout, ", ")); std::cout << std::endl; + InteractiveMessageBox *box = new InteractiveMessageBox(*this, message, buttons); + mInterMessageBoxes.push_back(box); + + // delete all non-interactive MessageBox'es std::vector::iterator it = mMessageBoxes.begin(); while(it != mMessageBoxes.end()) { @@ -174,3 +178,18 @@ int MessageBox::getHeight () { return mHeight+mNextBoxPadding; // 20 is the padding between this and the next MessageBox } + + + +InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector& buttons) + : Layout("openmw_interactive_messagebox_layout.xml") + , mMessageBoxManager(parMessageBoxManager) +{ + getWidget(mMessageWidget, "message"); + getWidget(mButtonsWidget, "buttons"); + + mMessageWidget->setOverflowToTheLeft(true); + mMessageWidget->addText(message); +} + + diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index fe58a31c8..e394b4c26 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -11,6 +11,7 @@ namespace MWGui { + class InteractiveMessageBox; class MessageBoxManager; class MessageBox; @@ -36,6 +37,7 @@ namespace MWGui private: std::vector mMessageBoxes; + std::vector mInterMessageBoxes; std::vector mTimers; float mMessageBoxSpeed; }; @@ -59,6 +61,17 @@ namespace MWGui int mBottomPadding; int mNextBoxPadding; }; + + class InteractiveMessageBox : public OEngine::GUI::Layout + { + public: + InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector& buttons); + + protected: + MessageBoxManager& mMessageBoxManager; + MyGUI::EditPtr mMessageWidget; + MyGUI::WidgetPtr mButtonsWidget; + }; } diff --git a/extern/mygui_3.0.1/CMakeLists.txt b/extern/mygui_3.0.1/CMakeLists.txt index 36467733d..566fea773 100644 --- a/extern/mygui_3.0.1/CMakeLists.txt +++ b/extern/mygui_3.0.1/CMakeLists.txt @@ -69,6 +69,7 @@ configure_file("${SDIR}/openmw_stats_window_layout.xml" "${DDIR}/openmw_stats_wi configure_file("${SDIR}/openmw_text.skin.xml" "${DDIR}/openmw_text.skin.xml" COPYONLY) configure_file("${SDIR}/openmw_windows.skin.xml" "${DDIR}/openmw_windows.skin.xml" COPYONLY) configure_file("${SDIR}/openmw_messagebox_layout.xml" "${DDIR}/openmw_messagebox_layout.xml" COPYONLY) +configure_file("${SDIR}/openmw_interactive_messagebox_layout.xml" "${DDIR}/openmw_interactive_messagebox_layout.xml" COPYONLY) configure_file("${SDIR}/smallbars.png" "${DDIR}/smallbars.png" COPYONLY) configure_file("${SDIR}/transparent.png" "${DDIR}/transparent.png" COPYONLY) configure_file("${SDIR}/VeraMono.ttf" "${DDIR}/VeraMono.ttf" COPYONLY) diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_interactive_messagebox_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_interactive_messagebox_layout.xml new file mode 100644 index 000000000..4db91341e --- /dev/null +++ b/extern/mygui_3.0.1/openmw_resources/openmw_interactive_messagebox_layout.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml index fb4235ff1..890752db3 100644 --- a/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml +++ b/extern/mygui_3.0.1/openmw_resources/openmw_messagebox_layout.xml @@ -12,6 +12,8 @@ + + From 5db8e8c449428371b5097a271daadccac5310835 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Sun, 19 Jun 2011 19:10:44 +0200 Subject: [PATCH 37/59] InterMessageBox game mode --- apps/openmw/mwgui/messagebox.cpp | 55 ++++++++++++++----- apps/openmw/mwgui/messagebox.hpp | 12 ++-- apps/openmw/mwgui/mode.hpp | 5 +- apps/openmw/mwgui/window_manager.cpp | 19 ++++--- .../openmw_interactive_messagebox_layout.xml | 8 +-- 5 files changed, 68 insertions(+), 31 deletions(-) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 1527bde4c..c4334250d 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -2,11 +2,13 @@ using namespace MWGui; -MessageBoxManager::MessageBoxManager (WindowManager *windowManager) +MessageBoxManager::MessageBoxManager (WindowManager *windowManager, MyGUI::Gui *_gui) { mWindowManager = windowManager; + gui = _gui; // defines mMessageBoxSpeed = 0.1; + mInterMessageBoxe = NULL; } void MessageBoxManager::onFrame (float frameDuration) @@ -72,23 +74,24 @@ void MessageBoxManager::createMessageBox (const std::string& message) } } -void MessageBoxManager::createInteractiveMessageBox (const std::string& message, const std::vector& buttons) +bool MessageBoxManager::createInteractiveMessageBox (const std::string& message, const std::vector& buttons) { + if(mInterMessageBoxe != NULL) { + std::cout << "there is a MessageBox already" << std::endl; + return false; + } std::cout << "interactive MessageBox: " << message << " - "; std::copy (buttons.begin(), buttons.end(), std::ostream_iterator (std::cout, ", ")); std::cout << std::endl; - InteractiveMessageBox *box = new InteractiveMessageBox(*this, message, buttons); - mInterMessageBoxes.push_back(box); + mInterMessageBoxe = new InteractiveMessageBox(*this, gui, message, buttons); - // delete all non-interactive MessageBox'es - std::vector::iterator it = mMessageBoxes.begin(); - while(it != mMessageBoxes.end()) - { - delete (*it); - it = mMessageBoxes.erase(it); - } - mMessageBoxes.clear(); + return true; +} + +bool MessageBoxManager::isInteractiveMessageBox () +{ + return mInterMessageBoxe != NULL; } void MessageBoxManager::removeMessageBox (float time, MessageBox *msgbox) @@ -181,15 +184,41 @@ int MessageBox::getHeight () -InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector& buttons) +InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, MyGUI::Gui *_gui, const std::string& message, const std::vector& buttons) : Layout("openmw_interactive_messagebox_layout.xml") , mMessageBoxManager(parMessageBoxManager) + , mGUI(_gui) { getWidget(mMessageWidget, "message"); getWidget(mButtonsWidget, "buttons"); mMessageWidget->setOverflowToTheLeft(true); mMessageWidget->addText(message); + + MyGUI::IntSize textSize = mMessageWidget->_getTextSize(); + std::cout << "textSize.width " << textSize.width << " textSize.height " << textSize.height << std::endl; + + MyGUI::IntSize size; + size.width = 500; // 500 is fixed width + size.height = textSize.height + 100; // 100 is mButtonWidget high + + mMainWidget->setSize(size); + size.width = 480; // fixed width (500) - 2*padding (10) + size.height = textSize.height; + mMessageWidget->setSize(size); + + std::vector::const_iterator it; + for(it = buttons.begin(); it != buttons.end(); ++it) + { + std::cout << "add button " << *it << std::endl; + MyGUI::ButtonPtr button = mGUI->createWidget("button1", 10, textSize.height, 480, 100, MyGUI::Align::Default, "buttons"); + button->setCaption(*it); + //mButtons.push_back(button); + } + } + + + diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index e394b4c26..5e31cb346 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -24,10 +24,11 @@ namespace MWGui class MessageBoxManager { public: - MessageBoxManager (WindowManager* windowManager); + MessageBoxManager (WindowManager* windowManager, MyGUI::Gui *_gui); void onFrame (float frameDuration); void createMessageBox (const std::string& message); - void createInteractiveMessageBox (const std::string& message, const std::vector& buttons); + bool createInteractiveMessageBox (const std::string& message, const std::vector& buttons); + bool isInteractiveMessageBox (); void removeMessageBox (float time, MessageBox *msgbox); bool removeMessageBox (MessageBox *msgbox); @@ -37,8 +38,9 @@ namespace MWGui private: std::vector mMessageBoxes; - std::vector mInterMessageBoxes; + InteractiveMessageBox* mInterMessageBoxe; std::vector mTimers; + MyGUI::Gui *gui; float mMessageBoxSpeed; }; @@ -65,12 +67,14 @@ namespace MWGui class InteractiveMessageBox : public OEngine::GUI::Layout { public: - InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector& buttons); + InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, MyGUI::Gui *_gui, const std::string& message, const std::vector& buttons); protected: MessageBoxManager& mMessageBoxManager; MyGUI::EditPtr mMessageWidget; MyGUI::WidgetPtr mButtonsWidget; + MyGUI::Gui *mGUI; + //std::vector mButtons; }; } diff --git a/apps/openmw/mwgui/mode.hpp b/apps/openmw/mwgui/mode.hpp index 313b097cf..b0dc14029 100644 --- a/apps/openmw/mwgui/mode.hpp +++ b/apps/openmw/mwgui/mode.hpp @@ -26,7 +26,10 @@ namespace MWGui GM_ClassGenerate, GM_ClassPick, GM_ClassCreate, - GM_Review + GM_Review, + + // interactive MessageBox + GM_InterMessageBox }; // Windows shown in inventory mode diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 8e9a14837..55d0c93cf 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -61,7 +61,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment inventory = new InventoryWindow (); #endif console = new Console(w,h, environment, extensions); - mMessageBoxManager = new MessageBoxManager(this); + mMessageBoxManager = new MessageBoxManager(this, (MyGUI::Gui*)gui); // The HUD is always on hud->setVisible(true); @@ -329,6 +329,14 @@ void WindowManager::updateVisible() dialogueWindow->open(); return; } + + if(mode == GM_InterMessageBox) + { + if(!mMessageBoxManager->isInteractiveMessageBox()) { + setGuiMode(GM_Game); + } + return; + } // Unsupported mode, switch back to game @@ -449,14 +457,6 @@ void WindowManager::removeDialog(OEngine::GUI::Layout*dialog) void WindowManager::messageBox (const std::string& message, const std::vector& buttons) { - /*std::cout << "message box: " << message << std::endl; - - if (!buttons.empty()) - { - std::cout << "buttons: "; - std::copy (buttons.begin(), buttons.end(), std::ostream_iterator (std::cout, ", ")); - std::cout << std::endl; - }*/ if (buttons.empty()) { mMessageBoxManager->createMessageBox(message); @@ -464,6 +464,7 @@ void WindowManager::messageBox (const std::string& message, const std::vectorcreateInteractiveMessageBox(message, buttons); + setGuiMode(GM_InterMessageBox); } } diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_interactive_messagebox_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_interactive_messagebox_layout.xml index 4db91341e..bba5d631c 100644 --- a/extern/mygui_3.0.1/openmw_resources/openmw_interactive_messagebox_layout.xml +++ b/extern/mygui_3.0.1/openmw_resources/openmw_interactive_messagebox_layout.xml @@ -1,8 +1,8 @@ - - + + @@ -12,8 +12,8 @@ - - + + From 23194a932f1eca63f080e6ef3bf663f961fa5cc2 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Sun, 19 Jun 2011 19:41:42 +0200 Subject: [PATCH 38/59] creating the buttons on the fly --- apps/openmw/mwgui/messagebox.cpp | 20 ++++++++++++------- apps/openmw/mwgui/messagebox.hpp | 12 +++++------ apps/openmw/mwgui/window_manager.cpp | 2 +- .../openmw_interactive_messagebox_layout.xml | 2 +- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index c4334250d..17de1f504 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -2,10 +2,9 @@ using namespace MWGui; -MessageBoxManager::MessageBoxManager (WindowManager *windowManager, MyGUI::Gui *_gui) +MessageBoxManager::MessageBoxManager (WindowManager *windowManager) { mWindowManager = windowManager; - gui = _gui; // defines mMessageBoxSpeed = 0.1; mInterMessageBoxe = NULL; @@ -84,7 +83,7 @@ bool MessageBoxManager::createInteractiveMessageBox (const std::string& message, std::copy (buttons.begin(), buttons.end(), std::ostream_iterator (std::cout, ", ")); std::cout << std::endl; - mInterMessageBoxe = new InteractiveMessageBox(*this, gui, message, buttons); + mInterMessageBoxe = new InteractiveMessageBox(*this, message, buttons); return true; } @@ -184,11 +183,12 @@ int MessageBox::getHeight () -InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, MyGUI::Gui *_gui, const std::string& message, const std::vector& buttons) +InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector& buttons) : Layout("openmw_interactive_messagebox_layout.xml") , mMessageBoxManager(parMessageBoxManager) - , mGUI(_gui) { + mTextButtonPadding = 10; + getWidget(mMessageWidget, "message"); getWidget(mButtonsWidget, "buttons"); @@ -207,13 +207,19 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan size.height = textSize.height; mMessageWidget->setSize(size); + MyGUI::IntCoord coord(10, textSize.height+mTextButtonPadding, 100, 50); + std::vector::const_iterator it; for(it = buttons.begin(); it != buttons.end(); ++it) { std::cout << "add button " << *it << std::endl; - MyGUI::ButtonPtr button = mGUI->createWidget("button1", 10, textSize.height, 480, 100, MyGUI::Align::Default, "buttons"); + MyGUI::ButtonPtr button = mButtonsWidget->createWidget( + MyGUI::WidgetStyle::Child, + std::string("MW_Button"), + coord, + MyGUI::Align::Default); button->setCaption(*it); - //mButtons.push_back(button); + mButtons.push_back(button); } } diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index 5e31cb346..f7c7197fa 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -24,7 +24,7 @@ namespace MWGui class MessageBoxManager { public: - MessageBoxManager (WindowManager* windowManager, MyGUI::Gui *_gui); + MessageBoxManager (WindowManager* windowManager); void onFrame (float frameDuration); void createMessageBox (const std::string& message); bool createInteractiveMessageBox (const std::string& message, const std::vector& buttons); @@ -40,7 +40,6 @@ namespace MWGui std::vector mMessageBoxes; InteractiveMessageBox* mInterMessageBoxe; std::vector mTimers; - MyGUI::Gui *gui; float mMessageBoxSpeed; }; @@ -67,14 +66,15 @@ namespace MWGui class InteractiveMessageBox : public OEngine::GUI::Layout { public: - InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, MyGUI::Gui *_gui, const std::string& message, const std::vector& buttons); + InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector& buttons); - protected: + private: MessageBoxManager& mMessageBoxManager; MyGUI::EditPtr mMessageWidget; MyGUI::WidgetPtr mButtonsWidget; - MyGUI::Gui *mGUI; - //std::vector mButtons; + std::vector mButtons; + + int mTextButtonPadding; }; } diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 55d0c93cf..b5a6e36a6 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -61,7 +61,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment inventory = new InventoryWindow (); #endif console = new Console(w,h, environment, extensions); - mMessageBoxManager = new MessageBoxManager(this, (MyGUI::Gui*)gui); + mMessageBoxManager = new MessageBoxManager(this); // The HUD is always on hud->setVisible(true); diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_interactive_messagebox_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_interactive_messagebox_layout.xml index bba5d631c..40c0787b8 100644 --- a/extern/mygui_3.0.1/openmw_resources/openmw_interactive_messagebox_layout.xml +++ b/extern/mygui_3.0.1/openmw_resources/openmw_interactive_messagebox_layout.xml @@ -13,7 +13,7 @@ - + From 9c2bb76869c01d60566d55e67594683b654262ef Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Sun, 19 Jun 2011 22:56:51 +0200 Subject: [PATCH 39/59] disigned the interactive messagebox. Have to center it and add button events --- apps/openmw/mwgui/messagebox.cpp | 98 +++++++++++++++++++++++++++----- apps/openmw/mwgui/messagebox.hpp | 2 - 2 files changed, 85 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 17de1f504..61a359e7e 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -187,7 +187,13 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan : Layout("openmw_interactive_messagebox_layout.xml") , mMessageBoxManager(parMessageBoxManager) { - mTextButtonPadding = 10; + int fixedWidth = 500; + int textPadding = 10; // padding between text-widget and main-widget + int textButtonPadding = 20; // padding between the text-widget und the button-widget + int buttonLeftPadding = 10; // padding between the buttons if horizontal + int buttonTopPadding = 5; // ^-- if vertical + int buttonPadding = 5; // padding between button label and button itself + getWidget(mMessageWidget, "message"); getWidget(mButtonsWidget, "buttons"); @@ -196,32 +202,98 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan mMessageWidget->addText(message); MyGUI::IntSize textSize = mMessageWidget->_getTextSize(); - std::cout << "textSize.width " << textSize.width << " textSize.height " << textSize.height << std::endl; - - MyGUI::IntSize size; - size.width = 500; // 500 is fixed width - size.height = textSize.height + 100; // 100 is mButtonWidget high - mMainWidget->setSize(size); - size.width = 480; // fixed width (500) - 2*padding (10) - size.height = textSize.height; - mMessageWidget->setSize(size); - MyGUI::IntCoord coord(10, textSize.height+mTextButtonPadding, 100, 50); + 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) { - std::cout << "add button " << *it << std::endl; MyGUI::ButtonPtr button = mButtonsWidget->createWidget( MyGUI::WidgetStyle::Child, std::string("MW_Button"), - coord, + dummyCoord, MyGUI::Align::Default); button->setCaption(*it); + mButtons.push_back(button); + + buttonsWidth += button->_getTextSize().width + 2*buttonPadding + 2*buttonLeftPadding; + buttonHeight = button->_getTextSize().height + 2*buttonPadding + 2*buttonTopPadding; } + MyGUI::IntSize mainWidgetSize; + if(buttonsWidth < fixedWidth) + { + // on one line + + int left; + if(textSize.width + 2*textPadding < buttonsWidth) + { + mainWidgetSize.width = buttonsWidth; + left = buttonLeftPadding; + } + else + { + mainWidgetSize.width = textSize.width + 2*textPadding; + left = (textSize.width - buttonsWidth)/2; + } + mainWidgetSize.height = textSize.height + textButtonPadding + buttonHeight; + mMainWidget->setSize(mainWidgetSize); + + mMessageWidget->setSize(textSize); + + MyGUI::IntCoord buttonCord; + MyGUI::IntSize buttonSize(0, buttonHeight); + + 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 + buttonPadding*2; + buttonSize.height = (*button)->_getTextSize().height + buttonPadding*2; + + (*button)->setCoord(buttonCord); + (*button)->setSize(buttonSize); + + left += buttonSize.width + 2*buttonLeftPadding; + } + } + else + { + // among each other + + mainWidgetSize.width = textSize.width + 2*textPadding; + mainWidgetSize.height = textSize.height + 2*textPadding + textButtonPadding + buttonHeight * buttons.size(); + mMainWidget->setSize(mainWidgetSize); + + 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) + { + buttonCord.top = top; + buttonCord.left = (textSize.width - (*button)->_getTextSize().width)/2; + + buttonSize.width = (*button)->_getTextSize().width + buttonPadding*2; + buttonSize.height = (*button)->_getTextSize().height + buttonPadding*2; + + (*button)->setCoord(buttonCord); + (*button)->setSize(buttonSize); + + top += buttonSize.height + 2*buttonTopPadding; + } + + } } diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index f7c7197fa..b8c205823 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -73,8 +73,6 @@ namespace MWGui MyGUI::EditPtr mMessageWidget; MyGUI::WidgetPtr mButtonsWidget; std::vector mButtons; - - int mTextButtonPadding; }; } From 2b5dc0042b04ff88270257d04dc3dc4e153f83df Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 4 Jul 2011 23:36:22 +0200 Subject: [PATCH 40/59] fix for issue 138 (record loading failed for some NPCs) --- components/esm_store/store.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/esm_store/store.cpp b/components/esm_store/store.cpp index 9f301d163..2b5b977aa 100644 --- a/components/esm_store/store.cpp +++ b/components/esm_store/store.cpp @@ -85,7 +85,13 @@ void ESMStore::load(ESMReader &esm) dialogue = 0; // Insert the reference into the global lookup - if(!id.empty()) + if(!id.empty() && + (n.val==REC_ACTI || n.val==REC_ALCH || n.val==REC_APPA || n.val==REC_ARMO || + n.val==REC_BOOK || n.val==REC_CLOT || n.val==REC_CONT || n.val==REC_CREA || + n.val==REC_DOOR || n.val==REC_INGR || n.val==REC_LEVC || n.val==REC_LEVI || + n.val==REC_LIGH || n.val==REC_LOCK || n.val==REC_MISC || n.val==REC_NPC_ || + n.val==REC_PROB || n.val==REC_REPA || n.val==REC_STAT || n.val==REC_WEAP) + ) all[id] = n.val; } } From f07f363a212205ae717bb5717d298a8e8c2bf176 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 8 Jul 2011 14:24:09 +0200 Subject: [PATCH 41/59] declare OpenMW version in CMakeLists.txt --- CMakeLists.txt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e0c0c463..c3a51d715 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,14 @@ IF (APPLE) set(APP_BUNDLE_DIR "${OpenMW_BINARY_DIR}/OpenMW.app") ENDIF (APPLE) +# Version + +set (OPENMW_VERSION_MAJOR 0) +set (OPENMW_VERSION_MINOR 12) +set (OPENMW_VERSION_PATCH 0) + +set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_PATCH}") + # Sound source selection option(USE_AUDIERE "use Audiere for sound" OFF) option(USE_FFMPEG "use ffmpeg for sound" OFF) @@ -56,7 +64,7 @@ IF(EXISTS "${CMAKE_SOURCE_DIR}/prebuilt/vc100-mt-gd/ogre_1_7_1") set(AUDIERE_LIBRARY "${PREBUILT_DIR}/audiere-1.9.4/lib/audiere.lib") set(ENV{OPENALDIR} "${PREBUILT_DIR}/OpenAL 1.1 SDK") - + set(BULLET_ROOT "${PREBUILT_DIR}/bullet") ELSE() message (STATUS "OpenMW pre-built binaries not found. Using standard locations.") @@ -436,8 +444,7 @@ if(DPKG_PROGRAM) exec_program("git" ARGS "config --get user.email" OUTPUT_VARIABLE GIT_EMAIL) set(PACKAGE_MAINTAINER "${GIT_NAME} <${GIT_EMAIL}>") else() - #FIXME this should probably be read from some file like ${CMAKE_CURRENT_SOURCE_DIR}/VERSION or something that gets updated when changing version - set(VERSION_STRING "0.10.0") + set(VERSION_STRING "${OPENMW_VERSION}") set(PACKAGE_MAINTAINER "unknown") endif() From 27cba6c6244bd21bb286d918aff6e65856257aba Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 8 Jul 2011 14:39:23 +0200 Subject: [PATCH 42/59] created config.hpp file for appps/openmw --- .gitignore | 3 ++- apps/openmw/CMakeLists.txt | 7 ++++++- apps/openmw/config.hpp.cmake | 9 +++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 apps/openmw/config.hpp.cmake diff --git a/.gitignore b/.gitignore index 774478e2b..a58044556 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ build *~ Doxygen -prebuilt \ No newline at end of file +prebuilt +apps/openmw/config.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 492c3869b..f8b4d7a59 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -1,5 +1,9 @@ project(OpenMW) +# config file + +configure_file ("${OpenMW_SOURCE_DIR}/config.hpp.cmake" "${OpenMW_SOURCE_DIR}/config.hpp") + # local files set(GAME @@ -7,7 +11,8 @@ set(GAME engine.cpp ) set(GAME_HEADER - engine.hpp) + engine.hpp + config.hpp) source_group(game FILES ${GAME} ${GAME_HEADER}) set(GAMEREND diff --git a/apps/openmw/config.hpp.cmake b/apps/openmw/config.hpp.cmake new file mode 100644 index 000000000..f74734d9e --- /dev/null +++ b/apps/openmw/config.hpp.cmake @@ -0,0 +1,9 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#define OPENMW_VERSION_MAJOR @OPENMW_VERSION_MAJOR@ +#define OPENMW_VERSION_MINOR @OPENMW_VERSION_MINOR@ +#define OPENMW_VERSION_PATCH @OPENMW_VERSION_PATCH@ +#define OPENMW_VERSION @OPENMW_VERSION@ + +#endif From d5e463519847e6bd90c1ceb346fd740ab020d8a3 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 8 Jul 2011 14:52:34 +0200 Subject: [PATCH 43/59] state OpenMW version on doxygen main page --- .gitignore | 1 + CMakeLists.txt | 4 ++++ Docs/Doxyfile | 1 + Docs/DoxyfilePages | 1 + Docs/mainpage.hpp.cmake | 5 +++++ 5 files changed, 12 insertions(+) create mode 100644 Docs/mainpage.hpp.cmake diff --git a/.gitignore b/.gitignore index a58044556..b17b5a584 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ build Doxygen prebuilt apps/openmw/config.hpp +Docs/mainpage.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index c3a51d715..235d920e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,10 @@ set (OPENMW_VERSION_PATCH 0) set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_PATCH}") +# doxygen main page + +configure_file ("${OpenMW_SOURCE_DIR}/Docs/mainpage.hpp.cmake" "${OpenMW_SOURCE_DIR}/Docs/mainpage.hpp") + # Sound source selection option(USE_AUDIERE "use Audiere for sound" OFF) option(USE_FFMPEG "use ffmpeg for sound" OFF) diff --git a/Docs/Doxyfile b/Docs/Doxyfile index 0a1e0eae8..43c3312ad 100644 --- a/Docs/Doxyfile +++ b/Docs/Doxyfile @@ -576,6 +576,7 @@ WARN_LOGFILE = INPUT = apps \ components \ libs \ + Docs # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is diff --git a/Docs/DoxyfilePages b/Docs/DoxyfilePages index 943e2eef0..5ce82a7c2 100644 --- a/Docs/DoxyfilePages +++ b/Docs/DoxyfilePages @@ -576,6 +576,7 @@ WARN_LOGFILE = INPUT = apps \ components \ libs \ + Docs # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is diff --git a/Docs/mainpage.hpp.cmake b/Docs/mainpage.hpp.cmake new file mode 100644 index 000000000..f8cdf8a82 --- /dev/null +++ b/Docs/mainpage.hpp.cmake @@ -0,0 +1,5 @@ +/// \mainpage +/// +/// This is the source documentation for: +/// +/// OpenMW @OPENMW_VERSION@ From 6ddf9e4cc56d4ef11a17d775d5307999eb4bd10c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 8 Jul 2011 14:53:01 +0200 Subject: [PATCH 44/59] minor correction --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 235d920e2..2ee5ac653 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,9 +8,9 @@ ENDIF (APPLE) set (OPENMW_VERSION_MAJOR 0) set (OPENMW_VERSION_MINOR 12) -set (OPENMW_VERSION_PATCH 0) +set (OPENMW_VERSION_RELEASE 0) -set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_PATCH}") +set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") # doxygen main page From a7b266c4d2998161894ea6eb6606292617c2954a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 8 Jul 2011 16:16:06 +0200 Subject: [PATCH 45/59] another minor correction (fixing the previous one) --- apps/openmw/config.hpp.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/config.hpp.cmake b/apps/openmw/config.hpp.cmake index f74734d9e..848fbe0eb 100644 --- a/apps/openmw/config.hpp.cmake +++ b/apps/openmw/config.hpp.cmake @@ -3,7 +3,7 @@ #define OPENMW_VERSION_MAJOR @OPENMW_VERSION_MAJOR@ #define OPENMW_VERSION_MINOR @OPENMW_VERSION_MINOR@ -#define OPENMW_VERSION_PATCH @OPENMW_VERSION_PATCH@ -#define OPENMW_VERSION @OPENMW_VERSION@ +#define OPENMW_VERSION_RELEASE @OPENMW_VERSION_RELEASE@ +#define OPENMW_VERSION "@OPENMW_VERSION@" #endif From d9a25427c5c9d9d2b747e8014e9b99bcad7a291b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 8 Jul 2011 16:16:20 +0200 Subject: [PATCH 46/59] added --version command line option --- apps/openmw/main.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 56f78afe3..c3d0cc821 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -26,6 +26,8 @@ #endif +#include "config.hpp" + using namespace std; /// Parse command line options and openmw.cfg file (if one exists). Results are directly @@ -41,7 +43,8 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) "Syntax: openmw \nAllowed options"); desc.add_options() - ("help", "print help message") + ("help", "print help message and quit") + ("version", "print version information and quit") ("data", bpo::value >() ->default_value (std::vector(), "data") ->multitoken(), @@ -105,12 +108,23 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) if (globalConfigFile.is_open()) bpo::store ( bpo::parse_config_file (globalConfigFile, desc), variables); + bool run = true; + if (variables.count ("help")) { std::cout << desc << std::endl; - return false; + run = false; } + if (variables.count ("version")) + { + std::cout << "OpenMW version " << OPENMW_VERSION << std::endl; + run = false; + } + + if (!run) + return false; + // directory settings if (variables["fs-strict"].as()==true) engine.enableFSStrict(); From 537b2bf9636a3c8581701f85c7538bdda46722f7 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 12 Jul 2011 17:57:16 +0200 Subject: [PATCH 47/59] set position on interactive MessageBox'es --- apps/openmw/mwgui/messagebox.cpp | 36 +++++++++++++++++++++----------- apps/openmw/mwgui/messagebox.hpp | 2 ++ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 61a359e7e..9c0196147 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -193,6 +193,7 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan int buttonLeftPadding = 10; // padding between the buttons if horizontal 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 getWidget(mMessageWidget, "message"); @@ -203,6 +204,7 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan MyGUI::IntSize textSize = mMessageWidget->_getTextSize(); + MyGUI::IntSize gameWindowSize = mMessageBoxManager.mWindowManager->getGui()->getViewSize(); int buttonsWidth = 0; int buttonHeight = 0; @@ -220,33 +222,43 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan mButtons.push_back(button); - buttonsWidth += button->_getTextSize().width + 2*buttonPadding + 2*buttonLeftPadding; - buttonHeight = button->_getTextSize().height + 2*buttonPadding + 2*buttonTopPadding; + buttonsWidth += button->_getTextSize().width + 2*buttonPadding + buttonLeftPadding; + buttonHeight = button->_getTextSize().height + 2*buttonPadding + buttonTopPadding; } + buttonsWidth += buttonLeftPadding; MyGUI::IntSize mainWidgetSize; if(buttonsWidth < fixedWidth) { // on one line - - int left; + std::cout << "on one line" << std::endl; + if(textSize.width + 2*textPadding < buttonsWidth) { + std::cout << "width = buttonsWidth" << std::endl; mainWidgetSize.width = buttonsWidth; - left = buttonLeftPadding; } else { - mainWidgetSize.width = textSize.width + 2*textPadding; - left = (textSize.width - buttonsWidth)/2; + mainWidgetSize.width = textSize.width + 3*textPadding; } - mainWidgetSize.height = textSize.height + textButtonPadding + buttonHeight; + 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); - + 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) @@ -254,13 +266,13 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan buttonCord.left = left; buttonCord.top = textSize.height + textButtonPadding; - buttonSize.width = (*button)->_getTextSize().width + buttonPadding*2; - buttonSize.height = (*button)->_getTextSize().height + buttonPadding*2; + buttonSize.width = (*button)->_getTextSize().width + 2*buttonPadding; + buttonSize.height = (*button)->_getTextSize().height + 2*buttonPadding; (*button)->setCoord(buttonCord); (*button)->setSize(buttonSize); - left += buttonSize.width + 2*buttonLeftPadding; + left += buttonSize.width + buttonLeftPadding; } } else diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index b8c205823..f7c7197fa 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -73,6 +73,8 @@ namespace MWGui MyGUI::EditPtr mMessageWidget; MyGUI::WidgetPtr mButtonsWidget; std::vector mButtons; + + int mTextButtonPadding; }; } From 0fc77dc1c3eb1b18e5c6a1ac869b77778bed2bd7 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 12 Jul 2011 18:05:46 +0200 Subject: [PATCH 48/59] everything looks good if buttons are on one line --- apps/openmw/mwgui/messagebox.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 9c0196147..62e079657 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -254,6 +254,12 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan 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; From 16ed02baebfcae30b8e4fbbbd926bc4f4826db3a Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 12 Jul 2011 19:17:07 +0200 Subject: [PATCH 49/59] all MessageBoxes look good; next: make them do something ;) --- apps/openmw/mwgui/messagebox.cpp | 41 +++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 62e079657..2a1cb6a21 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -206,6 +206,8 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan MyGUI::IntSize gameWindowSize = mMessageBoxManager.mWindowManager->getGui()->getViewSize(); + int biggestButtonWidth = 0; + int buttonWidth = 0; int buttonsWidth = 0; int buttonHeight = 0; MyGUI::IntCoord dummyCoord(0, 0, 0, 0); @@ -222,8 +224,14 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan mButtons.push_back(button); - buttonsWidth += button->_getTextSize().width + 2*buttonPadding + buttonLeftPadding; + buttonWidth = button->_getTextSize().width + 2*buttonPadding + buttonLeftPadding; + buttonsWidth += buttonWidth; buttonHeight = button->_getTextSize().height + 2*buttonPadding + buttonTopPadding; + + if(buttonWidth > biggestButtonWidth) + { + biggestButtonWidth = buttonWidth; + } } buttonsWidth += buttonLeftPadding; @@ -285,10 +293,31 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan { // among each other - mainWidgetSize.width = textSize.width + 2*textPadding; - mainWidgetSize.height = textSize.height + 2*textPadding + textButtonPadding + buttonHeight * buttons.size(); + if(biggestButtonWidth > textSize.width) { + mainWidgetSize.width = biggestButtonWidth + buttonTopPadding; + } + else { + 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; @@ -299,12 +328,12 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan std::vector::const_iterator button; for(button = mButtons.begin(); button != mButtons.end(); ++button) { - buttonCord.top = top; - buttonCord.left = (textSize.width - (*button)->_getTextSize().width)/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); From 317c920e03eb9609196069cd0afffd827eedb750 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 12 Jul 2011 20:05:04 +0200 Subject: [PATCH 50/59] everything works, also the readPressedButton function should do the job --- apps/openmw/mwgui/messagebox.cpp | 45 ++++++++++++++++++++++++++++ apps/openmw/mwgui/messagebox.hpp | 7 +++++ apps/openmw/mwgui/window_manager.cpp | 5 ++++ apps/openmw/mwgui/window_manager.hpp | 3 ++ 4 files changed, 60 insertions(+) diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index 2a1cb6a21..f0745bbbe 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -47,6 +47,12 @@ void MessageBoxManager::onFrame (float frameDuration) it++; } } + + if(mInterMessageBoxe != NULL && mInterMessageBoxe->mMarkedToDelete) { + delete mInterMessageBoxe; + mInterMessageBoxe = NULL; + mWindowManager->setNextMode(GM_Game); + } } void MessageBoxManager::createMessageBox (const std::string& message) @@ -124,6 +130,16 @@ void MessageBoxManager::setMessageBoxSpeed (int speed) } +int MessageBoxManager::readPressedButton () +{ + if(mInterMessageBoxe != NULL) + { + return mInterMessageBoxe->readPressedButton(); + } + return -1; +} + + MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message) @@ -186,6 +202,7 @@ int MessageBox::getHeight () InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector& buttons) : Layout("openmw_interactive_messagebox_layout.xml") , mMessageBoxManager(parMessageBoxManager) + , mButtonPressed(-1) { int fixedWidth = 500; int textPadding = 10; // padding between text-widget and main-widget @@ -195,6 +212,8 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan 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"); @@ -222,6 +241,8 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan MyGUI::Align::Default); button->setCaption(*it); + button->eventMouseButtonClick = MyGUI::newDelegate(this, &InteractiveMessageBox::mousePressed); + mButtons.push_back(button); buttonWidth = button->_getTextSize().width + 2*buttonPadding + buttonLeftPadding; @@ -343,6 +364,30 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan } } +void InteractiveMessageBox::mousePressed (MyGUI::Widget* pressed) +{ + mMarkedToDelete = true; + int index = 0; + std::vector::const_iterator button; + for(button = mButtons.begin(); button != mButtons.end(); ++button) + { + if(*button == pressed) + { + mButtonPressed = index; + return; + } + index++; + } + std::cout << "Cant be possible :/" << std::endl; +} + +int InteractiveMessageBox::readPressedButton () +{ + int pressed = mButtonPressed; + mButtonPressed = -1; + return pressed; +} + diff --git a/apps/openmw/mwgui/messagebox.hpp b/apps/openmw/mwgui/messagebox.hpp index f7c7197fa..bf3307acc 100644 --- a/apps/openmw/mwgui/messagebox.hpp +++ b/apps/openmw/mwgui/messagebox.hpp @@ -34,6 +34,8 @@ namespace MWGui bool removeMessageBox (MessageBox *msgbox); void setMessageBoxSpeed (int speed); + int readPressedButton (); + WindowManager *mWindowManager; private: @@ -67,6 +69,10 @@ namespace MWGui { public: InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector& buttons); + void mousePressed (MyGUI::Widget* _widget); + int readPressedButton (); + + bool mMarkedToDelete; private: MessageBoxManager& mMessageBoxManager; @@ -75,6 +81,7 @@ namespace MWGui std::vector mButtons; int mTextButtonPadding; + int mButtonPressed; }; } diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index b5a6e36a6..84e45859f 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -468,6 +468,11 @@ void WindowManager::messageBox (const std::string& message, const std::vectorreadPressedButton(); +} + const std::string &WindowManager::getGameSettingString(const std::string &id, const std::string &default_) { const ESM::GameSetting *setting = environment.mWorld->getStore().gameSettings.search(id); diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index ebe115d30..293bac601 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -250,6 +250,9 @@ namespace MWGui void messageBox (const std::string& message, const std::vector& buttons); + int readPressedButton (); + ///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox) + void onFrame (float frameDuration); /** From aded4608c0cd6a9d4ee07a3dde323cae6f11f40a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 12 Jul 2011 21:26:58 +0200 Subject: [PATCH 51/59] added GetButtonPressed function --- apps/openmw/mwscript/docs/vmformat.txt | 3 +- apps/openmw/mwscript/guiextensions.cpp | 54 ++++++++++++++++++-------- 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index fcebaae2b..33ce38cdd 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -108,4 +108,5 @@ op 0x2000133: Journal op 0x2000134: SetJournalIndex op 0x2000135: GetJournalIndex op 0x2000136: GetPCCell -opcodes 0x2000137-0x3ffffff unused +op 0x2000137: GetButtonPressed +opcodes 0x2000138-0x3ffffff unused diff --git a/apps/openmw/mwscript/guiextensions.cpp b/apps/openmw/mwscript/guiextensions.cpp index 0339a11f5..484c0d3ab 100644 --- a/apps/openmw/mwscript/guiextensions.cpp +++ b/apps/openmw/mwscript/guiextensions.cpp @@ -15,42 +15,57 @@ namespace MWScript { namespace Gui - { + { class OpEnableWindow : public Interpreter::Opcode0 { MWGui::GuiWindow mWindow; - + public: - + OpEnableWindow (MWGui::GuiWindow window) : mWindow (window) {} - + virtual void execute (Interpreter::Runtime& runtime) { InterpreterContext& context = static_cast (runtime.getContext()); - + context.getWindowManager().allow (mWindow); - } - }; - + } + }; + class OpShowDialogue : public Interpreter::Opcode0 { MWGui::GuiMode mDialogue; - + public: - + OpShowDialogue (MWGui::GuiMode dialogue) : mDialogue (dialogue) {} - + virtual void execute (Interpreter::Runtime& runtime) { InterpreterContext& context = static_cast (runtime.getContext()); - + context.getInputManager().setGuiMode(mDialogue); - } - }; + } + }; + + class OpGetButtonPressed : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + InterpreterContext& context = + static_cast (runtime.getContext()); + + MWWorld::Ptr ptr = context.getReference(); + + runtime.push (context.getWindowManager().readPressedButton()); + } + }; const int opcodeEnableBirthMenu = 0x200000e; const int opcodeEnableClassMenu = 0x200000f; @@ -63,7 +78,8 @@ namespace MWScript const int opcodeEnableStatsMenu = 0x2000016; const int opcodeEnableRest = 0x2000017; const int opcodeShowRestMenu = 0x2000018; - + const int opcodeGetButtonPressed = 0x2000137; + void registerExtensions (Compiler::Extensions& extensions) { extensions.registerInstruction ("enablebirthmenu", "", opcodeEnableBirthMenu); @@ -80,10 +96,12 @@ namespace MWScript extensions.registerInstruction ("enablerestmenu", "", opcodeEnableRest); extensions.registerInstruction ("enablelevelupmenu", "", opcodeEnableRest); - + extensions.registerInstruction ("showrestmenu", "", opcodeShowRestMenu); + + extensions.registerFunction ("getbuttonpressed", 'l', "", opcodeGetButtonPressed); } - + void installOpcodes (Interpreter::Interpreter& interpreter) { interpreter.installSegment5 (opcodeEnableBirthMenu, @@ -115,6 +133,8 @@ namespace MWScript interpreter.installSegment5 (opcodeShowRestMenu, new OpShowDialogue (MWGui::GM_Rest)); + + interpreter.installSegment5 (opcodeGetButtonPressed, new OpGetButtonPressed); } } } From ac9b1715d5ff6a58e0b8e13c4b1e7482033acb4d Mon Sep 17 00:00:00 2001 From: Lukasz Gromanowski Date: Sun, 17 Jul 2011 22:16:50 +0200 Subject: [PATCH 52/59] Added new command line option: "encoding" Added new command line option: "encoding" which allow to change font encoding used in game messages. Currently there are three evailable encodings: win1250 - Central and Eastern European (languages that use Latin script, such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, Serbian (Latin script), Romanian and Albanian) win1251 - languages that use the Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and others win1252 - Western European (Latin) - default Signed-off-by: Lukasz Gromanowski --- apps/openmw/engine.cpp | 7 +- apps/openmw/engine.hpp | 4 + apps/openmw/main.cpp | 25 + apps/openmw/mwworld/world.cpp | 3 +- apps/openmw/mwworld/world.hpp | 2 +- components/esm/esm_reader.cpp | 19 +- components/esm/esm_reader.hpp | 4 + components/to_utf8/gen_iconv.cpp | 16 + components/to_utf8/tables_gen.hpp | 527 ++++++++++++++++++ components/to_utf8/to_utf8.cpp | 26 +- components/to_utf8/to_utf8.hpp | 6 +- .../openmw_resources/openmw.font.xml | 10 +- 12 files changed, 635 insertions(+), 14 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index c344b55aa..264cf5347 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -370,7 +370,7 @@ void OMW::Engine::go() // Create the world mEnvironment.mWorld = new MWWorld::World (mOgre, mPhysicEngine, mFileCollections, mMaster, - mResDir, mNewGame, mEnvironment); + mResDir, mNewGame, mEnvironment, mEncoding); // Set up the GUI system mGuiManager = new OEngine::GUI::MyGUIManager(mOgre.getWindow(), mOgre.getScene(), false, cfgDir); @@ -519,3 +519,8 @@ void OMW::Engine::setCompileAll (bool all) { mCompileAll = all; } + +void OMW::Engine::setEncoding(const std::string& encoding) +{ + mEncoding = encoding; +} \ No newline at end of file diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 4c70d7f35..9d1466655 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -56,6 +56,7 @@ namespace OMW class Engine : private Ogre::FrameListener { + std::string mEncoding; boost::filesystem::path mDataDir; boost::filesystem::path mResDir; OEngine::Render::OgreRenderer mOgre; @@ -157,6 +158,9 @@ namespace OMW /// Compile all scripts (excludign dialogue scripts) at startup? void setCompileAll (bool all); + + /// Font encoding + void setEncoding(const std::string& encoding); }; } diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index c3d0cc821..d0efb401c 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -80,6 +80,13 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) ( "fs-strict", boost::program_options::value()-> implicit_value (true)->default_value (false), "strict file system handling (no case folding)") + + ( "encoding", boost::program_options::value()-> + default_value("win1252"), + "Font encoding used in OpenMW game messages:\n" + "\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, Serbian (Latin script), Romanian and Albanian languages\n" + "\n\twin1251 - Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages\n" + "\n\twin1252 - Western European (Latin) alphabet, used by default") ; bpo::variables_map variables; @@ -125,6 +132,24 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) if (!run) return false; + // Font encoding settings + std::string encoding(variables["encoding"].as()); + if (encoding == "win1250") + { + std::cout << "Using Central and Eastern European font encoding." << std::endl; + engine.setEncoding(encoding); + } + else if (encoding == "win1251") + { + std::cout << "Using Cyrillic font encoding." << std::endl; + engine.setEncoding(encoding); + } + else + { + std::cout << "Using default (English) font encoding." << std::endl; + engine.setEncoding("win1252"); + } + // directory settings if (variables["fs-strict"].as()==true) engine.enableFSStrict(); diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 3a4151e3a..0b750b1c3 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -409,7 +409,7 @@ namespace MWWorld World::World (OEngine::Render::OgreRenderer& renderer, OEngine::Physic::PhysicEngine* physEng, const Files::Collections& fileCollections, const std::string& master, const boost::filesystem::path& resDir, - bool newGame, Environment& environment) + bool newGame, Environment& environment, const std::string& encoding) : mSkyManager (0), mScene (renderer,physEng), mPlayer (0), mCurrentCell (0), mGlobalVariables (0), mSky (false), mCellChanged (false), mEnvironment (environment) { @@ -420,6 +420,7 @@ namespace MWWorld std::cout << "Loading ESM " << masterPath.string() << "\n"; // This parses the ESM file and loads a sample cell + mEsm.setEncoding(encoding); mEsm.open (masterPath.string()); mStore.load (mEsm); diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 160c20314..188e5dec5 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -115,7 +115,7 @@ namespace MWWorld World (OEngine::Render::OgreRenderer& renderer, OEngine::Physic::PhysicEngine* physEng, const Files::Collections& fileCollections, const std::string& master, const boost::filesystem::path& resDir, bool newGame, - Environment& environment); + Environment& environment, const std::string& encoding); ~World(); diff --git a/components/esm/esm_reader.cpp b/components/esm/esm_reader.cpp index 2c342178b..e9bfcf5ee 100644 --- a/components/esm/esm_reader.cpp +++ b/components/esm/esm_reader.cpp @@ -326,7 +326,7 @@ std::string ESMReader::getString(int size) mEsm->read(ptr, size); // Convert to UTF8 and return - return ToUTF8::getUtf8(ToUTF8::WINDOWS_1252); + return ToUTF8::getUtf8(mEncoding); } void ESMReader::fail(const std::string &msg) @@ -344,4 +344,21 @@ void ESMReader::fail(const std::string &msg) throw std::runtime_error(ss.str()); } +void ESMReader::setEncoding(const std::string& encoding) +{ + if (encoding == "win1250") + { + mEncoding = ToUTF8::WINDOWS_1250; + } + else if (encoding == "win1251") + { + mEncoding = ToUTF8::WINDOWS_1251; + } + else + { + // Default Latin encoding + mEncoding = ToUTF8::WINDOWS_1252; + } +} + } diff --git a/components/esm/esm_reader.hpp b/components/esm/esm_reader.hpp index dea1980e2..e5b230748 100644 --- a/components/esm/esm_reader.hpp +++ b/components/esm/esm_reader.hpp @@ -350,6 +350,9 @@ public: /// Used for error handling void fail(const std::string &msg); + /// Sets font encoding for ESM strings + void setEncoding(const std::string& encoding); + private: Mangle::Stream::StreamPtr mEsm; @@ -360,6 +363,7 @@ private: SaveData mSaveData; MasterList mMasters; + ToUTF8::FromType mEncoding; }; } #endif diff --git a/components/to_utf8/gen_iconv.cpp b/components/to_utf8/gen_iconv.cpp index cf4d9ac3f..620205245 100644 --- a/components/to_utf8/gen_iconv.cpp +++ b/components/to_utf8/gen_iconv.cpp @@ -88,7 +88,23 @@ int main() // Write namespace cout << "namespace ToUTF8\n{\n\n"; + // Central European and Eastern European languages that use Latin script, such as + // Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, Serbian (Latin script), Romanian and Albanian. + cout << "\n/// Central European and Eastern European languages that use Latin script," + "\n/// such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian," + "\n/// Serbian (Latin script), Romanian and Albanian." + "\n"; + write_table("WINDOWS-1250", "windows_1250"); + + // Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages + cout << "\n/// Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic" + "\n/// and other languages" + "\n"; + write_table("WINDOWS-1251", "windows_1251"); + // English + cout << "\n/// Latin alphabet used by English and some other Western languages" + "\n"; write_table("WINDOWS-1252", "windows_1252"); // Close namespace diff --git a/components/to_utf8/tables_gen.hpp b/components/to_utf8/tables_gen.hpp index a45d5d181..79945bddc 100644 --- a/components/to_utf8/tables_gen.hpp +++ b/components/to_utf8/tables_gen.hpp @@ -4,6 +4,533 @@ namespace ToUTF8 { + +/// Central European and Eastern European languages that use Latin script, +/// such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, +/// Serbian (Latin script), Romanian and Albanian. +static char windows_1250[] = +{ + 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x1, 0x1, 0x0, 0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not part of this charset + 0x3, 0xe2, 0x80, 0x9e, 0x0, 0x0, + 0x3, 0xe2, 0x80, 0xa6, 0x0, 0x0, + 0x3, 0xe2, 0x80, 0xa0, 0x0, 0x0, + 0x3, 0xe2, 0x80, 0xa1, 0x0, 0x0, + 0x1, 0x20, 0x0, 0x0, 0x0, 0x0, // not part of this charset + 0x3, 0xe2, 0x80, 0xb0, 0x0, 0x0, + 0x2, 0xc5, 0xa0, 0x0, 0x0, 0x0, + 0x3, 0xe2, 0x80, 0xb9, 0x0, 0x0, + 0x2, 0xc5, 0x9a, 0x0, 0x0, 0x0, + 0x2, 0xc5, 0xa4, 0x0, 0x0, 0x0, + 0x2, 0xc5, 0xbd, 0x0, 0x0, 0x0, + 0x2, 0xc5, 0xb9, 0x0, 0x0, 0x0, + 0x1, 0x20, 0x0, 0x0, 0x0, 0x0, // not part of this charset + 0x3, 0xe2, 0x80, 0x98, 0x0, 0x0, + 0x3, 0xe2, 0x80, 0x99, 0x0, 0x0, + 0x3, 0xe2, 0x80, 0x9c, 0x0, 0x0, + 0x3, 0xe2, 0x80, 0x9d, 0x0, 0x0, + 0x3, 0xe2, 0x80, 0xa2, 0x0, 0x0, + 0x3, 0xe2, 0x80, 0x93, 0x0, 0x0, + 0x3, 0xe2, 0x80, 0x94, 0x0, 0x0, + 0x1, 0x20, 0x0, 0x0, 0x0, 0x0, // not part of this charset + 0x3, 0xe2, 0x84, 0xa2, 0x0, 0x0, + 0x2, 0xc5, 0xa1, 0x0, 0x0, 0x0, + 0x3, 0xe2, 0x80, 0xba, 0x0, 0x0, + 0x2, 0xc5, 0x9b, 0x0, 0x0, 0x0, + 0x2, 0xc5, 0xa5, 0x0, 0x0, 0x0, + 0x2, 0xc5, 0xbe, 0x0, 0x0, 0x0, + 0x2, 0xc5, 0xba, 0x0, 0x0, 0x0, + 0x2, 0xc2, 0xa0, 0x0, 0x0, 0x0, + 0x2, 0xcb, 0x87, 0x0, 0x0, 0x0, + 0x2, 0xcb, 0x98, 0x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x8f, 0x0, 0x0, 0x0 +}; + +/// Latin alphabet used by English and some other Western languages static char windows_1252[] = { 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, diff --git a/components/to_utf8/to_utf8.cpp b/components/to_utf8/to_utf8.cpp index 5f38313aa..3fbbeb733 100644 --- a/components/to_utf8/to_utf8.cpp +++ b/components/to_utf8/to_utf8.cpp @@ -130,10 +130,28 @@ std::string ToUTF8::getUtf8(ToUTF8::FromType from) { // Pick translation array const char *arr; - if(from == ToUTF8::WINDOWS_1252) - arr = ToUTF8::windows_1252; - else - assert(0); + switch (from) + { + case ToUTF8::WINDOWS_1252: + { + arr = ToUTF8::windows_1252; + break; + } + case ToUTF8::WINDOWS_1250: + { + arr = ToUTF8::windows_1250; + break; + } + case ToUTF8::WINDOWS_1251: + { + arr = ToUTF8::windows_1251; + break; + } + default: + { + assert(0); + } + } // Double check that the input string stops at some point (it might // contain zero terminators before this, inside its own data, which diff --git a/components/to_utf8/to_utf8.hpp b/components/to_utf8/to_utf8.hpp index ec2231be7..4cbee1019 100644 --- a/components/to_utf8/to_utf8.hpp +++ b/components/to_utf8/to_utf8.hpp @@ -8,8 +8,10 @@ namespace ToUTF8 // These are all the currently supported code pages enum FromType { - WINDOWS_1252 // Used by English version of Morrowind (and - // probably others) + WINDOWS_1250, // Central ane Eastern European languages + WINDOWS_1251, // Cyrillic languages + WINDOWS_1252 // Used by English version of Morrowind (and + // probably others) }; // Return a writable buffer of at least 'size' bytes. The buffer diff --git a/extern/mygui_3.0.1/openmw_resources/openmw.font.xml b/extern/mygui_3.0.1/openmw_resources/openmw.font.xml index 5e283c549..76f164bcb 100644 --- a/extern/mygui_3.0.1/openmw_resources/openmw.font.xml +++ b/extern/mygui_3.0.1/openmw_resources/openmw.font.xml @@ -2,8 +2,9 @@ - + + @@ -11,15 +12,16 @@ - - + + - + + From 0bf2a2df41550e4830266a1057cde4b713f5fb85 Mon Sep 17 00:00:00 2001 From: Lukasz Gromanowski Date: Sun, 17 Jul 2011 22:53:20 +0200 Subject: [PATCH 53/59] Mantis: #3 - Fixed spelling error "Font" -> "Character" Signed-off-by: Lukasz Gromanowski --- apps/openmw/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index d0efb401c..08015b865 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -83,7 +83,7 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine) ( "encoding", boost::program_options::value()-> default_value("win1252"), - "Font encoding used in OpenMW game messages:\n" + "Character encoding used in OpenMW game messages:\n" "\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, Serbian (Latin script), Romanian and Albanian languages\n" "\n\twin1251 - Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages\n" "\n\twin1252 - Western European (Latin) alphabet, used by default") From ac43d482c5c23ecbe7d81836b844a2e5d1c3022d Mon Sep 17 00:00:00 2001 From: k1ll Date: Mon, 18 Jul 2011 18:49:38 +0200 Subject: [PATCH 54/59] Basic tab-completition seems to be finished. It's working like requested in the old thread. --- apps/openmw/mwgui/console.cpp | 92 +++++++++++++++++++++++++++++++++++ apps/openmw/mwgui/console.hpp | 2 + 2 files changed, 94 insertions(+) diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index baa1309af..31b1b8fb6 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -171,6 +171,22 @@ namespace MWGui MyGUI::KeyCode key, MyGUI::Char _char) { + if( key == MyGUI::KeyCode::Tab) + { + std::vector matches; + listNames(); + command->setCaption(complete( command->getCaption(), matches )); +#if 0 + int i = 0; + for(std::vector::iterator it=matches.begin(); it < matches.end(); it++,i++ ) + { + printOK( *it ); + if( i == 50 ) + break; + } +#endif + } + if(command_history.empty()) return; // Traverse history with up and down arrows @@ -237,4 +253,80 @@ namespace MWGui command->setCaption(""); } + + std::string Console::complete( std::string input, std::vector &matches ) + { + using namespace std; + string output=input; + string tmp=input; + + /* Does the input string contain things that don't have to be completed? If yes erase them. */ + for(string::reverse_iterator rit=tmp.rbegin(); rit < tmp.rend(); rit++) { + if( *rit == ' ' ) { + if( rit == tmp.rbegin() ) + { + tmp.clear(); + break; + } + tmp.erase(tmp.begin(), (rit).base()); + break; + } + } + /* Erase the input from the output string so we can easily append the completed form later. */ + output.erase(output.end()-tmp.length(), output.end()); + + /* Is there still something in the input string? If not just display all commands and return the unchanged input. */ + if( tmp.length() == 0 ) { + matches=mNames; + return input; + } + + /* Iterate through the vector. */ + for(vector::iterator it=mNames.begin(); it < mNames.end();it++) { + bool string_different=false; + + /* Is the string shorter than the input string? If yes skip it. */ + if( (*it).length() < tmp.length() ) + continue; + + /* Is the beginning of the string different from the input string? If yes skip it. */ + for( string::iterator iter=tmp.begin(), iter2=(*it).begin(); iter < tmp.end();iter++, iter2++) { + if( *iter != *iter2 ) { + string_different=true; + break; + } + } + + if( string_different ) + continue; + + /* The beginning of the string matches the input string, save it for the next test. */ + matches.push_back(*it); + } + + /* There are no matches. Return the unchanged input. */ + if( matches.empty() ) + { + return input; + } + + /* Only one match. We're done. */ + if( matches.size() == 1 ) { + return output.append(matches.front() + string(" ")); + } + + /* Check if all matching strings match further than input. If yes complete to this match. */ + int i = tmp.length(); + + for(string::iterator iter=matches.front().begin()+tmp.length(); iter < matches.front().end(); iter++, i++) { + for(vector::iterator it=matches.begin(); it < matches.end();it++) { + if( (*it)[i] != *iter ) { + /* Append the longest match to the end of the output string*/ + return output.append(matches.front().substr( 0, i)); + } + } + } + /* All keywords match with the shortest. Append it to the output string and return it. */ + return output.append(matches.front()); + } } diff --git a/apps/openmw/mwgui/console.hpp b/apps/openmw/mwgui/console.hpp index d08ac5887..eaf4299be 100644 --- a/apps/openmw/mwgui/console.hpp +++ b/apps/openmw/mwgui/console.hpp @@ -80,6 +80,8 @@ namespace MWGui MyGUI::Char _char); void acceptCommand(MyGUI::EditPtr _sender); + + std::string complete( std::string input, std::vector &matches ); }; } #endif From 0ece722ff3c28bd1b5e20b1b6b36b8f208cbdb01 Mon Sep 17 00:00:00 2001 From: k1ll Date: Tue, 19 Jul 2011 18:42:34 +0200 Subject: [PATCH 55/59] Added handling of quotation marks and search for matches now ignores the case of input and keywords. When completing and there are matching or partly matching uppercase keywords the output will be upercase too. If this is a problem i'll change it. --- apps/openmw/mwgui/console.cpp | 63 ++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 31b1b8fb6..0e2e692d3 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -259,17 +259,43 @@ namespace MWGui using namespace std; string output=input; string tmp=input; + bool has_front_quote = false; /* Does the input string contain things that don't have to be completed? If yes erase them. */ - for(string::reverse_iterator rit=tmp.rbegin(); rit < tmp.rend(); rit++) { - if( *rit == ' ' ) { - if( rit == tmp.rbegin() ) - { - tmp.clear(); - break; + /* Are there quotation marks? */ + if( tmp.find('"') != string::npos ) { + int numquotes=0; + for(string::iterator it=tmp.begin(); it < tmp.end(); it++) { + if( *it == '"' ) + numquotes++; + } + + /* Is it terminated?*/ + if( numquotes % 2 ) { + tmp.erase( 0, tmp.rfind('"')+1 ); + has_front_quote = true; + } + else { + size_t pos; + if( ( ((pos = tmp.rfind(' ')) != string::npos ) ) && ( pos > tmp.rfind('"') ) ) { + tmp.erase( 0, tmp.rfind(' ')+1); + } + else { + tmp.clear(); + } + has_front_quote = false; + } + } + /* No quotation marks. Are there spaces?*/ + else { + size_t rpos; + if( (rpos=tmp.rfind(' ')) != string::npos ) { + if( rpos == 0 ) { + tmp.clear(); + } + else { + tmp.erase(0, rpos+1); } - tmp.erase(tmp.begin(), (rit).base()); - break; } } /* Erase the input from the output string so we can easily append the completed form later. */ @@ -291,7 +317,7 @@ namespace MWGui /* Is the beginning of the string different from the input string? If yes skip it. */ for( string::iterator iter=tmp.begin(), iter2=(*it).begin(); iter < tmp.end();iter++, iter2++) { - if( *iter != *iter2 ) { + if( tolower(*iter) != tolower(*iter2) ) { string_different=true; break; } @@ -312,7 +338,18 @@ namespace MWGui /* Only one match. We're done. */ if( matches.size() == 1 ) { - return output.append(matches.front() + string(" ")); + /* Adding quotation marks when the input string started with a quotation mark or has spaces in it*/ + if( ( matches.front().find(' ') != string::npos ) ) { + if( !has_front_quote ) + output.append(string("\"")); + return output.append(matches.front() + string("\" ")); + } + else if( has_front_quote ) { + return output.append(matches.front() + string("\" ")); + } + else { + return output.append(matches.front() + string(" ")); + } } /* Check if all matching strings match further than input. If yes complete to this match. */ @@ -320,12 +357,14 @@ namespace MWGui for(string::iterator iter=matches.front().begin()+tmp.length(); iter < matches.front().end(); iter++, i++) { for(vector::iterator it=matches.begin(); it < matches.end();it++) { - if( (*it)[i] != *iter ) { + if( tolower((*it)[i]) != tolower(*iter) ) { /* Append the longest match to the end of the output string*/ - return output.append(matches.front().substr( 0, i)); + output.append(matches.front().substr( 0, i)); + return output; } } } + /* All keywords match with the shortest. Append it to the output string and return it. */ return output.append(matches.front()); } From 7bc1adde9fa576f2324af39a9a18eb0b55d9f274 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 22 Jul 2011 15:56:54 +0200 Subject: [PATCH 56/59] allow adding records at runtime (only potions and classes) --- apps/openmw/mwworld/world.cpp | 34 +++++++++++++++++++++++++++++++++- apps/openmw/mwworld/world.hpp | 9 +++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 0b750b1c3..30596a209 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -411,7 +411,7 @@ namespace MWWorld const std::string& master, const boost::filesystem::path& resDir, bool newGame, Environment& environment, const std::string& encoding) : mSkyManager (0), mScene (renderer,physEng), mPlayer (0), mCurrentCell (0), mGlobalVariables (0), - mSky (false), mCellChanged (false), mEnvironment (environment) + mSky (false), mCellChanged (false), mEnvironment (environment), mNextDynamicRecord (0) { mPhysEngine = physEng; @@ -871,4 +871,36 @@ namespace MWWorld { return mScene.toggleRenderMode (mode); } + + std::pair World::createRecord (const ESM::Potion& record) + { + /// \todo Rewrite the ESMStore so that a dynamic 2nd ESMStore can be attached to it. + /// This function should then insert the record into the 2nd store (the code for this + /// should also be moved to the ESMStore class). It might be a good idea to review + /// the STL-container usage of the ESMStore before the rewrite. + + std::ostringstream stream; + stream << "$dyamic" << mNextDynamicRecord++; + + const ESM::Potion *created = + &mStore.potions.list.insert (std::make_pair (stream.str(), record)).first->second; + + mStore.all.insert (std::make_pair (stream.str(), ESM::REC_ALCH)); + + return std::make_pair (stream.str(), created); + } + + std::pair World::createRecord (const ESM::Class& record) + { + /// \todo See function above. + std::ostringstream stream; + stream << "$dyamic" << mNextDynamicRecord++; + + const ESM::Class *created = + &mStore.classes.list.insert (std::make_pair (stream.str(), record)).first->second; + + mStore.all.insert (std::make_pair (stream.str(), ESM::REC_CLAS)); + + return std::make_pair (stream.str(), created); + } } diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 188e5dec5..cccd8816d 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -79,6 +79,7 @@ namespace MWWorld bool mSky; bool mCellChanged; Environment& mEnvironment; + int mNextDynamicRecord; OEngine::Physic::PhysicEngine* mPhysEngine; @@ -202,6 +203,14 @@ namespace MWWorld bool toggleRenderMode (RenderMode mode); ///< Toggle a render mode. ///< \return Resulting mode + + std::pair createRecord (const ESM::Potion& record); + ///< Create a new recrod (of type potion) in the ESM store. + /// \return ID, pointer to created record + + std::pair createRecord (const ESM::Class& record); + ///< Create a new recrod (of type class) in the ESM store. + /// \return ID, pointer to created record }; } From 4367b93e646b244c636fbf7293b1c58b76438a5b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 23 Jul 2011 11:56:01 +0200 Subject: [PATCH 57/59] typo --- apps/openmw/mwworld/world.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 30596a209..063f54d6f 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -880,7 +880,7 @@ namespace MWWorld /// the STL-container usage of the ESMStore before the rewrite. std::ostringstream stream; - stream << "$dyamic" << mNextDynamicRecord++; + stream << "$dynamic" << mNextDynamicRecord++; const ESM::Potion *created = &mStore.potions.list.insert (std::make_pair (stream.str(), record)).first->second; @@ -894,7 +894,7 @@ namespace MWWorld { /// \todo See function above. std::ostringstream stream; - stream << "$dyamic" << mNextDynamicRecord++; + stream << "$dynamic" << mNextDynamicRecord++; const ESM::Class *created = &mStore.classes.list.insert (std::make_pair (stream.str(), record)).first->second; From 9921e86790230c01e5ff5bab3ee6f73d75fd9c5f Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Wed, 27 Jul 2011 14:15:28 +0400 Subject: [PATCH 58/59] Forcing to build with 10.6 sdk on OS X. --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 58c4ebae0..5e2d00e1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,9 @@ project(OpenMW) IF (APPLE) set(APP_BUNDLE_DIR "${OpenMW_BINARY_DIR}/OpenMW.app") + + # using 10.6 sdk + set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk") ENDIF (APPLE) # Sound source selection From 7c023a9973ca988c03d2536f7ade4c2033c6e19f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 31 Jul 2011 20:20:52 +0200 Subject: [PATCH 59/59] fixed version number --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cbfb24837..91d3f7dd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ project(OpenMW) IF (APPLE) set(APP_BUNDLE_DIR "${OpenMW_BINARY_DIR}/OpenMW.app") - + # using 10.6 sdk set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk") ENDIF (APPLE) @@ -10,7 +10,7 @@ ENDIF (APPLE) # Version set (OPENMW_VERSION_MAJOR 0) -set (OPENMW_VERSION_MINOR 12) +set (OPENMW_VERSION_MINOR 11) set (OPENMW_VERSION_RELEASE 0) set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}")