1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-05 23:45:32 +00:00

Brainstorming

This commit is contained in:
unknown 2011-01-05 01:59:57 -08:00
parent e72e336e24
commit ca9beb610d
5 changed files with 76 additions and 121 deletions

View file

@ -42,6 +42,8 @@
#include "mwgui/class.hpp"
//using namespace ESM;
void OMW::Engine::executeLocalScripts()
@ -194,7 +196,6 @@ OMW::Engine::Engine()
, mVerboseScripts (false)
, mNewGame (false)
, mUseSound (true)
, mCompileAll (false)
, mScriptManager (0)
, mScriptContext (0)
, mGuiManager (0)
@ -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<MWGui::Widgets::MWAttribute>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSpell>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSpellEffect>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWDynamicStat>("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<ESM::Script>::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<double> (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<MWWorld::Action> 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<MWWorld::Action> 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;
}

View file

@ -55,7 +55,7 @@ StatsWindow::StatsWindow (MWWorld::Environment& environment)
for (int i = 0; i < ESM::Skill::Length; ++i)
{
skillValues.insert(std::pair<int, MWMechanics::Stat<float> >(i, MWMechanics::Stat<float>()));
skillWidgetMap.insert(std::pair<int, MyGUI::StaticTextPtr>(i, nullptr));
skillWidgetMap.insert(std::pair<int, MyGUI::StaticTextPtr>(i, (MyGUI::StaticTextPtr) nullptr));
}
MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget);

View file

@ -80,7 +80,7 @@ ReviewDialog::ReviewDialog(MWWorld::Environment& environment)
for (int i = 0; i < ESM::Skill::Length; ++i)
{
skillValues.insert(std::pair<int, MWMechanics::Stat<float> >(i, MWMechanics::Stat<float>()));
skillWidgetMap.insert(std::pair<int, MyGUI::StaticTextPtr>(i, nullptr));
skillWidgetMap.insert(std::pair<int, MyGUI::StaticTextPtr>(i, (MyGUI::StaticTextPtr)nullptr));
}
static_cast<MyGUI::WindowPtr>(mMainWidget)->eventWindowChangeCoord = MyGUI::newDelegate(this, &ReviewDialog::onWindowResize);

View file

@ -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";
@ -1088,46 +1111,15 @@ MeshPtr NIFLoader::load(const std::string &name,
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;
}

View file

@ -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;