Merge remote-tracking branch 'scrawl/master'

deque
Marc Zinnschlag 11 years ago
commit be88168e91

@ -137,6 +137,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
} }
// update GUI // update GUI
MWBase::Environment::get().getWindowManager()->onFrame(frametime);
if (MWBase::Environment::get().getStateManager()->getState()!= if (MWBase::Environment::get().getStateManager()->getState()!=
MWBase::StateManager::State_NoGame) MWBase::StateManager::State_NoGame)
{ {
@ -145,7 +146,6 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
MWBase::Environment::get().getWorld()->getTriangleBatchCount(tri, batch); MWBase::Environment::get().getWorld()->getTriangleBatchCount(tri, batch);
MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), tri, batch); MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), tri, batch);
MWBase::Environment::get().getWindowManager()->onFrame(frametime);
MWBase::Environment::get().getWindowManager()->update(); MWBase::Environment::get().getWindowManager()->update();
} }
} }

@ -50,10 +50,10 @@ namespace MWClass
void Light::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Light::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
{ {
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if(!model.empty()) {
// Insert even if model is empty, so that the light is added
renderingInterface.getObjects().insertModel(ptr, model); renderingInterface.getObjects().insertModel(ptr, model);
} }
}
void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
{ {

@ -61,7 +61,7 @@ namespace MWGui
} }
catch (const std::exception& error) catch (const std::exception& error)
{ {
printError (std::string ("An exception has been thrown: ") + error.what()); printError (std::string ("Error: ") + error.what());
} }
return false; return false;
@ -195,7 +195,7 @@ namespace MWGui
} }
catch (const std::exception& error) catch (const std::exception& error)
{ {
printError (std::string ("An exception has been thrown: ") + error.what()); printError (std::string ("Error: ") + error.what());
} }
} }
} }

@ -1,5 +1,7 @@
#include "mainmenu.hpp" #include "mainmenu.hpp"
#include <OgreResourceGroupManager.h>
#include <components/version/version.hpp> #include <components/version/version.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
@ -16,6 +18,7 @@
#include "confirmationdialog.hpp" #include "confirmationdialog.hpp"
#include "imagebutton.hpp" #include "imagebutton.hpp"
#include "backgroundimage.hpp" #include "backgroundimage.hpp"
#include "videowidget.hpp"
namespace MWGui namespace MWGui
{ {
@ -25,6 +28,7 @@ namespace MWGui
, mButtonBox(0), mWidth (w), mHeight (h) , mButtonBox(0), mWidth (w), mHeight (h)
, mSaveGameDialog(NULL) , mSaveGameDialog(NULL)
, mBackground(NULL) , mBackground(NULL)
, mVideo(NULL)
{ {
getWidget(mVersionText, "VersionText"); getWidget(mVersionText, "VersionText");
std::stringstream sstream; std::stringstream sstream;
@ -42,6 +46,8 @@ namespace MWGui
std::string output = sstream.str(); std::string output = sstream.str();
mVersionText->setCaption(output); mVersionText->setCaption(output);
mHasAnimatedMenu = (Ogre::ResourceGroupManager::getSingleton().resourceExistsInAnyGroup("video\\menu_background.bik"));
updateMenu(); updateMenu();
} }
@ -134,14 +140,66 @@ namespace MWGui
void MainMenu::showBackground(bool show) void MainMenu::showBackground(bool show)
{ {
if (show && !mBackground) if (mVideo && !show)
{
MyGUI::Gui::getInstance().destroyWidget(mVideo);
mVideo = NULL;
}
if (mBackground && !show)
{
MyGUI::Gui::getInstance().destroyWidget(mBackground);
mBackground = NULL;
}
if (!show)
return;
if (mHasAnimatedMenu)
{
if (!mVideo)
{
// Use black background to correct aspect ratio
mVideoBackground = MyGUI::Gui::getInstance().createWidgetReal<MyGUI::ImageBox>("ImageBox", 0,0,1,1,
MyGUI::Align::Default, "Menu");
mVideoBackground->setImageTexture("black.png");
mVideo = mVideoBackground->createWidget<VideoWidget>("ImageBox", 0,0,1,1,
MyGUI::Align::Stretch, "Menu");
mVideo->playVideo("video\\menu_background.bik", false);
}
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
int screenWidth = viewSize.width;
int screenHeight = viewSize.height;
mVideoBackground->setSize(screenWidth, screenHeight);
double imageaspect = static_cast<double>(mVideo->getVideoWidth())/mVideo->getVideoHeight();
int leftPadding = std::max(0.0, (screenWidth - screenHeight * imageaspect) / 2);
int topPadding = std::max(0.0, (screenHeight - screenWidth / imageaspect) / 2);
mVideo->setCoord(leftPadding, topPadding,
screenWidth - leftPadding*2, screenHeight - topPadding*2);
mVideo->setVisible(true);
}
else
{
if (!mBackground)
{ {
mBackground = MyGUI::Gui::getInstance().createWidgetReal<BackgroundImage>("ImageBox", 0,0,1,1, mBackground = MyGUI::Gui::getInstance().createWidgetReal<BackgroundImage>("ImageBox", 0,0,1,1,
MyGUI::Align::Stretch, "Menu"); MyGUI::Align::Stretch, "Menu");
mBackground->setBackgroundImage("textures\\menu_morrowind.dds"); mBackground->setBackgroundImage("textures\\menu_morrowind.dds");
} }
if (mBackground) mBackground->setVisible(true);
mBackground->setVisible(show); }
}
void MainMenu::update(float dt)
{
if (mVideo)
mVideo->update();
} }
void MainMenu::updateMenu() void MainMenu::updateMenu()
@ -229,7 +287,7 @@ namespace MWGui
if (state == MWBase::StateManager::State_NoGame) if (state == MWBase::StateManager::State_NoGame)
{ {
// Align with the background image // Align with the background image
int bottomPadding=48; int bottomPadding=24;
mButtonBox->setCoord (mWidth/2 - maxwidth/2, mHeight - curH - bottomPadding, maxwidth, curH); mButtonBox->setCoord (mWidth/2 - maxwidth/2, mHeight - curH - bottomPadding, maxwidth, curH);
} }
else else

@ -9,12 +9,15 @@ namespace MWGui
class ImageButton; class ImageButton;
class BackgroundImage; class BackgroundImage;
class SaveGameDialog; class SaveGameDialog;
class VideoWidget;
class MainMenu : public OEngine::GUI::Layout class MainMenu : public OEngine::GUI::Layout
{ {
int mWidth; int mWidth;
int mHeight; int mHeight;
bool mHasAnimatedMenu;
public: public:
MainMenu(int w, int h); MainMenu(int w, int h);
@ -24,6 +27,8 @@ namespace MWGui
virtual void setVisible (bool visible); virtual void setVisible (bool visible);
void update(float dt);
private: private:
MyGUI::Widget* mButtonBox; MyGUI::Widget* mButtonBox;
@ -31,6 +36,9 @@ namespace MWGui
BackgroundImage* mBackground; BackgroundImage* mBackground;
MyGUI::ImageBox* mVideoBackground;
VideoWidget* mVideo; // For animated main menus
std::map<std::string, MWGui::ImageButton*> mButtons; std::map<std::string, MWGui::ImageButton*> mButtons;
void onButtonClicked (MyGUI::Widget* sender); void onButtonClicked (MyGUI::Widget* sender);

@ -134,9 +134,12 @@ namespace MWGui
else else
{ {
// Find the localised name for this class from the store // Find the localised name for this class from the store
const ESM::Class* class_ = MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find( const ESM::Class* class_ = MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().search(
it->getSignature().mPlayerClassId); it->getSignature().mPlayerClassId);
if (class_)
className = class_->mName; className = class_->mName;
else
className = "?"; // From an older savegame format that did not support custom classes properly.
} }
title << " (Level " << it->getSignature().mPlayerLevel << " " << className << ")"; title << " (Level " << it->getSignature().mPlayerLevel << " " << className << ")";

@ -73,17 +73,6 @@ namespace
return (Ogre::Root::getSingleton ().getRenderSystem ()->getName ().find("OpenGL") != std::string::npos) ? "glsl" : "hlsl"; return (Ogre::Root::getSingleton ().getRenderSystem ()->getName ().find("OpenGL") != std::string::npos) ? "glsl" : "hlsl";
} }
bool cgAvailable ()
{
Ogre::Root::PluginInstanceList list = Ogre::Root::getSingleton ().getInstalledPlugins ();
for (Ogre::Root::PluginInstanceList::const_iterator it = list.begin(); it != list.end(); ++it)
{
if ((*it)->getName() == "Cg Program Manager")
return true;
}
return false;
}
const char* checkButtonType = "CheckButton"; const char* checkButtonType = "CheckButton";
const char* sliderType = "Slider"; const char* sliderType = "Slider";
@ -366,12 +355,7 @@ namespace MWGui
void SettingsWindow::onShaderModeToggled(MyGUI::Widget* _sender) void SettingsWindow::onShaderModeToggled(MyGUI::Widget* _sender)
{ {
std::string val = static_cast<MyGUI::Button*>(_sender)->getCaption(); std::string val = static_cast<MyGUI::Button*>(_sender)->getCaption();
if (val == "cg")
{
val = hlslGlsl(); val = hlslGlsl();
}
else if (cgAvailable ())
val = "cg";
static_cast<MyGUI::Button*>(_sender)->setCaption(val); static_cast<MyGUI::Button*>(_sender)->setCaption(val);

@ -454,20 +454,30 @@ namespace MWGui
if (!mFactions.empty()) if (!mFactions.empty())
{ {
// Add a line separator if there are items above
if (!mSkillWidgets.empty())
addSeparator(coord1, coord2);
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
const MWMechanics::NpcStats &PCstats = player.getClass().getNpcStats(player); const MWMechanics::NpcStats &PCstats = player.getClass().getNpcStats(player);
const std::set<std::string> &expelled = PCstats.getExpelled(); const std::set<std::string> &expelled = PCstats.getExpelled();
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sFaction", "Faction"), coord1, coord2); bool firstFaction=true;
FactionList::const_iterator end = mFactions.end(); FactionList::const_iterator end = mFactions.end();
for (FactionList::const_iterator it = mFactions.begin(); it != end; ++it) for (FactionList::const_iterator it = mFactions.begin(); it != end; ++it)
{ {
const ESM::Faction *faction = const ESM::Faction *faction =
store.get<ESM::Faction>().find(it->first); store.get<ESM::Faction>().find(it->first);
if (faction->mData.mIsHidden == 1)
continue;
if (firstFaction)
{
// Add a line separator if there are items above
if (!mSkillWidgets.empty())
addSeparator(coord1, coord2);
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sFaction", "Faction"), coord1, coord2);
firstFaction = false;
}
MyGUI::Widget* w = addItem(faction->mName, coord1, coord2); MyGUI::Widget* w = addItem(faction->mName, coord1, coord2);
std::string text; std::string text;

@ -803,6 +803,8 @@ namespace MWGui
mToolTips->onFrame(frameDuration); mToolTips->onFrame(frameDuration);
mMenu->update(frameDuration);
if (MWBase::Environment::get().getStateManager()->getState()== if (MWBase::Environment::get().getStateManager()->getState()==
MWBase::StateManager::State_NoGame) MWBase::StateManager::State_NoGame)
return; return;

@ -1257,6 +1257,8 @@ Ogre::Vector3 Animation::getEnchantmentColor(MWWorld::Ptr item)
ObjectAnimation::ObjectAnimation(const MWWorld::Ptr& ptr, const std::string &model) ObjectAnimation::ObjectAnimation(const MWWorld::Ptr& ptr, const std::string &model)
: Animation(ptr, ptr.getRefData().getBaseNode()) : Animation(ptr, ptr.getRefData().getBaseNode())
{ {
if (!model.empty())
{
setObjectRoot(model, false); setObjectRoot(model, false);
Ogre::Vector3 extents = getWorldBounds().getSize(); Ogre::Vector3 extents = getWorldBounds().getSize();
@ -1273,6 +1275,12 @@ ObjectAnimation::ObjectAnimation(const MWWorld::Ptr& ptr, const std::string &mod
setRenderProperties(mObjectRoot, (mPtr.getTypeName() == typeid(ESM::Static).name()) ? setRenderProperties(mObjectRoot, (mPtr.getTypeName() == typeid(ESM::Static).name()) ?
(small ? RV_StaticsSmall : RV_Statics) : RV_Misc, (small ? RV_StaticsSmall : RV_Statics) : RV_Misc,
RQG_Main, RQG_Alpha, dist, !ptr.getClass().getEnchantment(ptr).empty(), &col); RQG_Main, RQG_Alpha, dist, !ptr.getClass().getEnchantment(ptr).empty(), &col);
}
else
{
// No model given. Create an object root anyway, so that lights can be added to it if needed.
mObjectRoot = NifOgre::ObjectScenePtr (new NifOgre::ObjectScene(mInsert->getCreator()));
}
} }
void ObjectAnimation::addLight(const ESM::Light *light) void ObjectAnimation::addLight(const ESM::Light *light)

@ -79,6 +79,11 @@ void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh)
std::auto_ptr<ObjectAnimation> anim(new ObjectAnimation(ptr, mesh)); std::auto_ptr<ObjectAnimation> anim(new ObjectAnimation(ptr, mesh));
if(ptr.getTypeName() == typeid(ESM::Light).name())
anim->addLight(ptr.get<ESM::Light>()->mBase);
if (!mesh.empty())
{
Ogre::AxisAlignedBox bounds = anim->getWorldBounds(); Ogre::AxisAlignedBox bounds = anim->getWorldBounds();
Ogre::Vector3 extents = bounds.getSize(); Ogre::Vector3 extents = bounds.getSize();
extents *= ptr.getRefData().getBaseNode()->getScale(); extents *= ptr.getRefData().getBaseNode()->getScale();
@ -94,9 +99,6 @@ void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh)
mBounds[ptr.getCell()] = Ogre::AxisAlignedBox::BOX_NULL; mBounds[ptr.getCell()] = Ogre::AxisAlignedBox::BOX_NULL;
mBounds[ptr.getCell()].merge(bounds); mBounds[ptr.getCell()].merge(bounds);
if(ptr.getTypeName() == typeid(ESM::Light).name())
anim->addLight(ptr.get<ESM::Light>()->mBase);
if(ptr.getTypeName() == typeid(ESM::Static).name() && if(ptr.getTypeName() == typeid(ESM::Static).name() &&
Settings::Manager::getBool("use static geometry", "Objects") && Settings::Manager::getBool("use static geometry", "Objects") &&
anim->canBatch()) anim->canBatch())
@ -153,6 +155,7 @@ void Objects::insertModel(const MWWorld::Ptr &ptr, const std::string &mesh)
* it. Would require associating the Ptr with the StaticGeometry. */ * it. Would require associating the Ptr with the StaticGeometry. */
anim.reset(); anim.reset();
} }
}
if(anim.get() != NULL) if(anim.get() != NULL)
mObjects.insert(std::make_pair(ptr, anim.release())); mObjects.insert(std::make_pair(ptr, anim.release()));

@ -41,8 +41,9 @@ namespace MWWorld
unsigned int j=0; unsigned int j=0;
for(unsigned int i=0;i<sum.length();++i){ for(unsigned int i=0;i<sum.length();++i){
if(sum[i]==',') j++; if(sum[i]==',') j++;
else ret[j]+=sum[i]; else if (sum[i] != ' ') ret[j]+=sum[i];
} }
return Ogre::ColourValue(boost::lexical_cast<int>(ret[0])/255.f,boost::lexical_cast<int>(ret[1])/255.f,boost::lexical_cast<int>(ret[2])/255.f); return Ogre::ColourValue(boost::lexical_cast<int>(ret[0])/255.f,boost::lexical_cast<int>(ret[1])/255.f,boost::lexical_cast<int>(ret[2])/255.f);
} }
} }

@ -685,12 +685,14 @@ namespace MWWorld
typedef std::map<std::string, ESM::Cell>::iterator IntIterator; typedef std::map<std::string, ESM::Cell>::iterator IntIterator;
//std::sort(mInt.begin(), mInt.end(), RecordCmp()); //std::sort(mInt.begin(), mInt.end(), RecordCmp());
mSharedInt.clear();
mSharedInt.reserve(mInt.size()); mSharedInt.reserve(mInt.size());
for (IntIterator it = mInt.begin(); it != mInt.end(); ++it) { for (IntIterator it = mInt.begin(); it != mInt.end(); ++it) {
mSharedInt.push_back(&(it->second)); mSharedInt.push_back(&(it->second));
} }
//std::sort(mExt.begin(), mExt.end(), ExtCmp()); //std::sort(mExt.begin(), mExt.end(), ExtCmp());
mSharedExt.clear();
mSharedExt.reserve(mExt.size()); mSharedExt.reserve(mExt.size());
for (ExtIterator it = mExt.begin(); it != mExt.end(); ++it) { for (ExtIterator it = mExt.begin(); it != mExt.end(); ++it) {
mSharedExt.push_back(&(it->second)); mSharedExt.push_back(&(it->second));

@ -82,7 +82,7 @@ struct NPC
char mSkills[Skill::Length]; char mSkills[Skill::Length];
char mReputation; char mReputation;
short mHealth, mMana, mFatigue; unsigned short mHealth, mMana, mFatigue;
char mDisposition, mFactionID, mRank; char mDisposition, mFactionID, mRank;
char mUnknown; char mUnknown;
int mGold; int mGold;

@ -333,17 +333,14 @@ namespace ICS
} }
} }
} }
else if(mDetectingBindingListener)
{
mDetectingBindingListener->mouseButtonBindingDetected(this,
mDetectingBindingControl, btn, mDetectingBindingDirection);
}
} }
} }
void InputControlSystem::mouseReleased(const SDL_MouseButtonEvent &evt, Uint8 btn) void InputControlSystem::mouseReleased(const SDL_MouseButtonEvent &evt, Uint8 btn)
{ {
if(mActive) if(mActive)
{
if (!mDetectingBindingControl)
{ {
ControlsButtonBinderMapType::const_iterator it = mControlsMouseButtonBinderMap.find((int)btn); ControlsButtonBinderMapType::const_iterator it = mControlsMouseButtonBinderMap.find((int)btn);
if(it != mControlsMouseButtonBinderMap.end()) if(it != mControlsMouseButtonBinderMap.end())
@ -351,6 +348,12 @@ namespace ICS
it->second.control->setChangingDirection(Control::STOP); it->second.control->setChangingDirection(Control::STOP);
} }
} }
else if(mDetectingBindingListener)
{
mDetectingBindingListener->mouseButtonBindingDetected(this,
mDetectingBindingControl, btn, mDetectingBindingDirection);
}
}
} }
// mouse auto bindings // mouse auto bindings

Loading…
Cancel
Save