mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 09:23:53 +00:00
Issue #19: Moved code from Engine to WindowManager and ScriptManager
This commit is contained in:
parent
38c0f36d44
commit
39af941d6f
4 changed files with 32 additions and 22 deletions
|
@ -319,12 +319,6 @@ void OMW::Engine::go()
|
||||||
mGuiManager = new OEngine::GUI::MyGUIManager(mOgre.getWindow(), mOgre.getScene(), false,
|
mGuiManager = new OEngine::GUI::MyGUIManager(mOgre.getWindow(), mOgre.getScene(), false,
|
||||||
mCfgMgr.getLogPath().string() + std::string("/"));
|
mCfgMgr.getLogPath().string() + std::string("/"));
|
||||||
|
|
||||||
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSkill>("Widget");
|
|
||||||
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
|
// Create window manager - this manages all the MW-specific GUI windows
|
||||||
MWScript::registerExtensions (mExtensions);
|
MWScript::registerExtensions (mExtensions);
|
||||||
|
|
||||||
|
@ -383,29 +377,19 @@ void OMW::Engine::go()
|
||||||
mOgre.getRoot()->addFrameListener (this);
|
mOgre.getRoot()->addFrameListener (this);
|
||||||
|
|
||||||
// Play some good 'ol tunes
|
// Play some good 'ol tunes
|
||||||
mEnvironment.mSoundManager->startRandomTitle();
|
mEnvironment.mSoundManager->startRandomTitle();
|
||||||
|
|
||||||
// scripts
|
// scripts
|
||||||
if (mCompileAll)
|
if (mCompileAll)
|
||||||
{
|
{
|
||||||
typedef ESMS::ScriptListT<ESM::Script>::MapType Container;
|
std::pair<int, int> result = mScriptManager->compileAll();
|
||||||
|
|
||||||
Container scripts = mEnvironment.mWorld->getStore().scripts.list;
|
if (result.first)
|
||||||
|
|
||||||
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
|
std::cout
|
||||||
<< "compiled " << success << " of " << count << " scripts ("
|
<< "compiled " << result.second << " of " << result.first << " scripts ("
|
||||||
<< 100*static_cast<double> (success)/count
|
<< 100*static_cast<double> (result.second)/result.first
|
||||||
<< "%)"
|
<< "%)"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the main rendering loop
|
// Start the main rendering loop
|
||||||
|
|
|
@ -77,6 +77,12 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
|
||||||
playerSkillValues.insert(std::make_pair(ESM::Skill::skillIds[i], MWMechanics::Stat<float>()));
|
playerSkillValues.insert(std::make_pair(ESM::Skill::skillIds[i], MWMechanics::Stat<float>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSkill>("Widget");
|
||||||
|
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");
|
||||||
|
|
||||||
// Set up visibility
|
// Set up visibility
|
||||||
updateVisible();
|
updateVisible();
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,4 +116,20 @@ namespace MWScript
|
||||||
iter->second.clear(); // don't execute again.
|
iter->second.clear(); // don't execute again.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::pair<int, int> ScriptManager::compileAll()
|
||||||
|
{
|
||||||
|
typedef ESMS::ScriptListT<ESM::Script>::MapType Container;
|
||||||
|
|
||||||
|
const Container& scripts = mStore.scripts.list;
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
int success = 0;
|
||||||
|
|
||||||
|
for (Container::const_iterator iter (scripts.begin()); iter!=scripts.end(); ++iter, ++count)
|
||||||
|
if (compile (iter->first))
|
||||||
|
++success;
|
||||||
|
|
||||||
|
return std::make_pair (count, success);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,10 @@ namespace MWScript
|
||||||
bool compile (const std::string& name);
|
bool compile (const std::string& name);
|
||||||
///< Compile script with the given namen
|
///< Compile script with the given namen
|
||||||
/// \return Success?
|
/// \return Success?
|
||||||
|
|
||||||
|
std::pair<int, int> compileAll();
|
||||||
|
///< Compile all scripts
|
||||||
|
/// \return count, success
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue