Merge remote-tracking branch 'scrawl/master'

actorid
Marc Zinnschlag 11 years ago
commit 4ee1069baa

@ -33,7 +33,7 @@ add_openmw_dir (mwgui
merchantrepair repair soulgemdialog companionwindow bookpage journalviewmodel journalbooks merchantrepair repair soulgemdialog companionwindow bookpage journalviewmodel journalbooks
keywordsearch itemmodel containeritemmodel inventoryitemmodel sortfilteritemmodel itemview keywordsearch itemmodel containeritemmodel inventoryitemmodel sortfilteritemmodel itemview
tradeitemmodel companionitemmodel pickpocketitemmodel fontloader controllers savegamedialog tradeitemmodel companionitemmodel pickpocketitemmodel fontloader controllers savegamedialog
recharge mode videowidget recharge mode videowidget backgroundimage
) )
add_openmw_dir (mwdialogue add_openmw_dir (mwdialogue

@ -500,7 +500,24 @@ namespace MWDialogue
mTemporaryDispositionChange = 100 - curDisp; mTemporaryDispositionChange = 100 - curDisp;
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWWorld::Class::get(player).skillUsageSucceeded(player, ESM::Skill::Speechcraft, success ? 0 : 1); player.getClass().skillUsageSucceeded(player, ESM::Skill::Speechcraft, success ? 0 : 1);
if (success)
{
int gold=0;
if (type == MWBase::MechanicsManager::PT_Bribe10)
gold = 10;
else if (type == MWBase::MechanicsManager::PT_Bribe100)
gold = 100;
else if (type == MWBase::MechanicsManager::PT_Bribe1000)
gold = 1000;
if (gold)
{
player.getClass().getContainerStore(player).remove(MWWorld::ContainerStore::sGoldId, gold, player);
mActor.getClass().getContainerStore(mActor).add(MWWorld::ContainerStore::sGoldId, gold, mActor);
}
}
std::string text; std::string text;

@ -0,0 +1,63 @@
#include "backgroundimage.hpp"
#include <MyGUI_Gui.h>
namespace MWGui
{
void BackgroundImage::setBackgroundImage (const std::string& image, bool fixedRatio, bool correct)
{
if (mChild)
{
MyGUI::Gui::getInstance().destroyWidget(mChild);
mChild = NULL;
}
if (correct)
{
setImageTexture("black.png");
if (fixedRatio)
mAspect = 4.0/3.0;
else
mAspect = 0; // TODO
mChild = createWidgetReal<MyGUI::ImageBox>("ImageBox",
MyGUI::FloatCoord(0,0,1,1), MyGUI::Align::Default);
mChild->setImageTexture(image);
adjustSize();
}
else
{
mAspect = 0;
setImageTexture(image);
}
}
void BackgroundImage::adjustSize()
{
if (mAspect == 0)
return;
MyGUI::IntSize screenSize = getSize();
int leftPadding = std::max(0.0, (screenSize.width - screenSize.height * mAspect) / 2);
int topPadding = std::max(0.0, (screenSize.height - screenSize.width / mAspect) / 2);
mChild->setCoord(leftPadding, topPadding, screenSize.width - leftPadding*2, screenSize.height - topPadding*2);
}
void BackgroundImage::setSize (const MyGUI::IntSize& _value)
{
MyGUI::Widget::setSize (_value);
adjustSize();
}
void BackgroundImage::setCoord (const MyGUI::IntCoord& _value)
{
MyGUI::Widget::setCoord (_value);
adjustSize();
}
}

@ -0,0 +1,37 @@
#ifndef OPENMW_MWGUI_BACKGROUNDIMAGE_H
#define OPENMW_MWGUI_BACKGROUNDIMAGE_H
#include <MyGUI_ImageBox.h>
namespace MWGui
{
/**
* @brief A variant of MyGUI::ImageBox with aspect ratio correction using black bars
*/
class BackgroundImage : public MyGUI::ImageBox
{
MYGUI_RTTI_DERIVED(BackgroundImage)
public:
BackgroundImage() : mChild(NULL), mAspect(0) {}
/**
* @param fixedRatio Use a fixed ratio of 4:3, regardless of the image dimensions
* @param correct Add black bars?
*/
void setBackgroundImage (const std::string& image, bool fixedRatio=true, bool correct=true);
virtual void setSize (const MyGUI::IntSize &_value);
virtual void setCoord (const MyGUI::IntCoord &_value);
private:
MyGUI::ImageBox* mChild;
double mAspect;
void adjustSize();
};
}
#endif

@ -56,29 +56,16 @@ namespace MWGui
void PersuasionDialog::onPersuade(MyGUI::Widget *sender) void PersuasionDialog::onPersuade(MyGUI::Widget *sender)
{ {
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWBase::MechanicsManager::PersuasionType type; MWBase::MechanicsManager::PersuasionType type;
if (sender == mAdmireButton) type = MWBase::MechanicsManager::PT_Admire; if (sender == mAdmireButton) type = MWBase::MechanicsManager::PT_Admire;
else if (sender == mIntimidateButton) type = MWBase::MechanicsManager::PT_Intimidate; else if (sender == mIntimidateButton) type = MWBase::MechanicsManager::PT_Intimidate;
else if (sender == mTauntButton) type = MWBase::MechanicsManager::PT_Taunt; else if (sender == mTauntButton) type = MWBase::MechanicsManager::PT_Taunt;
else if (sender == mBribe10Button) else if (sender == mBribe10Button)
{
player.getClass().getContainerStore(player).remove(MWWorld::ContainerStore::sGoldId, 10, player);
mReceiver.getClass().getContainerStore(mReceiver).add(MWWorld::ContainerStore::sGoldId, 10, mReceiver);
type = MWBase::MechanicsManager::PT_Bribe10; type = MWBase::MechanicsManager::PT_Bribe10;
}
else if (sender == mBribe100Button) else if (sender == mBribe100Button)
{
player.getClass().getContainerStore(player).remove(MWWorld::ContainerStore::sGoldId, 100, player);
mReceiver.getClass().getContainerStore(mReceiver).add(MWWorld::ContainerStore::sGoldId, 100, mReceiver);
type = MWBase::MechanicsManager::PT_Bribe100; type = MWBase::MechanicsManager::PT_Bribe100;
}
else /*if (sender == mBribe1000Button)*/ else /*if (sender == mBribe1000Button)*/
{
player.getClass().getContainerStore(player).remove(MWWorld::ContainerStore::sGoldId, 1000, player);
mReceiver.getClass().getContainerStore(mReceiver).add(MWWorld::ContainerStore::sGoldId, 1000, mReceiver);
type = MWBase::MechanicsManager::PT_Bribe1000; type = MWBase::MechanicsManager::PT_Bribe1000;
}
MWBase::Environment::get().getDialogueManager()->persuade(type); MWBase::Environment::get().getDialogueManager()->persuade(type);
@ -100,12 +87,6 @@ namespace MWGui
mGoldLabel->setCaptionWithReplacing("#{sGold}: " + boost::lexical_cast<std::string>(playerGold)); mGoldLabel->setCaptionWithReplacing("#{sGold}: " + boost::lexical_cast<std::string>(playerGold));
} }
// The receiver of the bribe
void PersuasionDialog::setReceiver(MWWorld::Ptr receiver)
{
mReceiver = receiver;
}
// -------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
Response::Response(const std::string &text, const std::string &title) Response::Response(const std::string &text, const std::string &title)
@ -380,7 +361,6 @@ namespace MWGui
mPtr = actor; mPtr = actor;
mTopicsList->setEnabled(true); mTopicsList->setEnabled(true);
setTitle(npcName); setTitle(npcName);
mPersuasionDialog.setReceiver(mPtr);
mTopicsList->clear(); mTopicsList->clear();

@ -35,9 +35,6 @@ namespace MWGui
virtual void open(); virtual void open();
// The receiver of the bribe
void setReceiver(MWWorld::Ptr receiver);
private: private:
MyGUI::Button* mCancelButton; MyGUI::Button* mCancelButton;
MyGUI::Button* mAdmireButton; MyGUI::Button* mAdmireButton;
@ -50,9 +47,6 @@ namespace MWGui
void onCancel (MyGUI::Widget* sender); void onCancel (MyGUI::Widget* sender);
void onPersuade (MyGUI::Widget* sender); void onPersuade (MyGUI::Widget* sender);
// The receiver of the bribe
MWWorld::Ptr mReceiver;
}; };

@ -9,14 +9,14 @@
#include <OgreViewport.h> #include <OgreViewport.h>
#include <OgreHardwarePixelBuffer.h> #include <OgreHardwarePixelBuffer.h>
#include <openengine/ogre/fader.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/inputmanager.hpp" #include "../mwbase/inputmanager.hpp"
#include "backgroundimage.hpp"
namespace MWGui namespace MWGui
{ {
@ -32,28 +32,13 @@ namespace MWGui
{ {
getWidget(mLoadingText, "LoadingText"); getWidget(mLoadingText, "LoadingText");
getWidget(mProgressBar, "ProgressBar"); getWidget(mProgressBar, "ProgressBar");
getWidget(mBackgroundImage, "BackgroundImage");
mProgressBar->setScrollViewPage(1); mProgressBar->setScrollViewPage(1);
mBackgroundMaterial = Ogre::MaterialManager::getSingleton().create("BackgroundMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); mBackgroundImage = MyGUI::Gui::getInstance().createWidgetReal<BackgroundImage>("ImageBox", 0,0,1,1,
mBackgroundMaterial->getTechnique(0)->getPass(0)->setLightingEnabled(false); MyGUI::Align::Stretch, "Menu");
mBackgroundMaterial->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
mBackgroundMaterial->getTechnique(0)->getPass(0)->createTextureUnitState(""); setVisible(false);
mRectangle = new Ogre::Rectangle2D(true);
mRectangle->setCorners(-1.0, 1.0, 1.0, -1.0);
mRectangle->setMaterial("BackgroundMaterial");
// Render the background before everything else
mRectangle->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY-1);
// Use infinite AAB to always stay visible
Ogre::AxisAlignedBox aabInf;
aabInf.setInfinite();
mRectangle->setBoundingBox(aabInf);
// Attach background to the scene
Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
node->attachObject(mRectangle);
mRectangle->setVisible(false);
} }
void LoadingScreen::setLabel(const std::string &label) void LoadingScreen::setLabel(const std::string &label)
@ -63,18 +48,25 @@ namespace MWGui
LoadingScreen::~LoadingScreen() LoadingScreen::~LoadingScreen()
{ {
delete mRectangle; }
void LoadingScreen::setVisible(bool visible)
{
WindowBase::setVisible(visible);
mBackgroundImage->setVisible(visible);
} }
void LoadingScreen::onResChange(int w, int h) void LoadingScreen::onResChange(int w, int h)
{ {
setCoord(0,0,w,h); setCoord(0,0,w,h);
mBackgroundImage->setCoord(MyGUI::IntCoord(0,0,w,h));
} }
void LoadingScreen::loadingOn() void LoadingScreen::loadingOn()
{ {
// Early-out if already on // Early-out if already on
if (mRectangle->getVisible()) if (mMainWidget->getVisible())
return; return;
// Temporarily turn off VSync, we want to do actual loading rather than waiting for the screen to sync. // Temporarily turn off VSync, we want to do actual loading rather than waiting for the screen to sync.
@ -106,7 +98,7 @@ namespace MWGui
texture->createInternalResources(); texture->createInternalResources();
mWindow->copyContentsToMemory(texture->getBuffer()->lock(Ogre::Image::Box(0,0,width,height), Ogre::HardwareBuffer::HBL_DISCARD)); mWindow->copyContentsToMemory(texture->getBuffer()->lock(Ogre::Image::Box(0,0,width,height), Ogre::HardwareBuffer::HBL_DISCARD));
texture->getBuffer()->unlock(); texture->getBuffer()->unlock();
mBackgroundImage->setImageTexture(texture->getName()); mBackgroundImage->setBackgroundImage(texture->getName(), false, false);
} }
setVisible(true); setVisible(true);
@ -149,9 +141,10 @@ namespace MWGui
{ {
std::string const & randomSplash = mResources.at (rand() % mResources.size()); std::string const & randomSplash = mResources.at (rand() % mResources.size());
Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton ().load (randomSplash, Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME); Ogre::TextureManager::getSingleton ().load (randomSplash, Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
mBackgroundImage->setImageTexture (randomSplash); // TODO: add option (filename pattern?) to use image aspect ratio instead of 4:3
mBackgroundImage->setBackgroundImage(randomSplash, true, true);
} }
else else
std::cerr << "No loading screens found!" << std::endl; std::cerr << "No loading screens found!" << std::endl;
@ -237,8 +230,6 @@ namespace MWGui
mWindow->update(false); mWindow->update(false);
mRectangle->setVisible(false);
// resume 3d rendering // resume 3d rendering
mSceneMgr->clearSpecialCaseRenderQueues(); mSceneMgr->clearSpecialCaseRenderQueues();
mSceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE); mSceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE);

@ -10,6 +10,8 @@
namespace MWGui namespace MWGui
{ {
class BackgroundImage;
class LoadingScreen : public WindowBase, public Loading::Listener class LoadingScreen : public WindowBase, public Loading::Listener
{ {
public: public:
@ -25,6 +27,8 @@ namespace MWGui
virtual void setProgress (size_t value); virtual void setProgress (size_t value);
virtual void increaseProgress (size_t increase); virtual void increaseProgress (size_t increase);
virtual void setVisible(bool visible);
virtual void removeWallpaper(); virtual void removeWallpaper();
LoadingScreen(Ogre::SceneManager* sceneMgr, Ogre::RenderWindow* rw); LoadingScreen(Ogre::SceneManager* sceneMgr, Ogre::RenderWindow* rw);
@ -51,10 +55,7 @@ namespace MWGui
MyGUI::TextBox* mLoadingText; MyGUI::TextBox* mLoadingText;
MyGUI::ScrollBar* mProgressBar; MyGUI::ScrollBar* mProgressBar;
MyGUI::ImageBox* mBackgroundImage; BackgroundImage* mBackgroundImage;
Ogre::Rectangle2D* mRectangle;
Ogre::MaterialPtr mBackgroundMaterial;
Ogre::StringVector mResources; Ogre::StringVector mResources;

@ -14,6 +14,8 @@
#include "savegamedialog.hpp" #include "savegamedialog.hpp"
#include "confirmationdialog.hpp" #include "confirmationdialog.hpp"
#include "imagebutton.hpp"
#include "backgroundimage.hpp"
namespace MWGui namespace MWGui
{ {
@ -132,34 +134,14 @@ namespace MWGui
void MainMenu::showBackground(bool show) void MainMenu::showBackground(bool show)
{ {
if (mBackground) if (show && !mBackground)
{
MyGUI::Gui::getInstance().destroyWidget(mBackground);
mBackground = NULL;
}
if (show)
{ {
if (!mBackground) mBackground = MyGUI::Gui::getInstance().createWidgetReal<BackgroundImage>("ImageBox", 0,0,1,1,
{ MyGUI::Align::Stretch, "Menu");
mBackground = MyGUI::Gui::getInstance().createWidgetReal<MyGUI::ImageBox>("ImageBox", 0,0,1,1, mBackground->setBackgroundImage("textures\\menu_morrowind.dds");
MyGUI::Align::Stretch, "Menu");
mBackground->setImageTexture("black.png");
// Use black bars to correct aspect ratio. The video player also does it, so we need to do it
// for mw_logo.bik to align correctly with menu_morrowind.dds.
MyGUI::IntSize screenSize = MyGUI::RenderManager::getInstance().getViewSize();
// No way to un-hardcode this right now, menu_morrowind.dds is 1024x512 but was designed for 4:3
double imageaspect = 4.0/3.0;
int leftPadding = std::max(0.0, (screenSize.width - screenSize.height * imageaspect) / 2);
int topPadding = std::max(0.0, (screenSize.height - screenSize.width / imageaspect) / 2);
MyGUI::ImageBox* image = mBackground->createWidget<MyGUI::ImageBox>("ImageBox",
leftPadding, topPadding, screenSize.width - leftPadding*2, screenSize.height - topPadding*2, MyGUI::Align::Default);
image->setImageTexture("textures\\menu_morrowind.dds");
}
} }
if (mBackground)
mBackground->setVisible(show);
} }
void MainMenu::updateMenu() void MainMenu::updateMenu()
@ -174,6 +156,7 @@ namespace MWGui
MWBase::StateManager::State state = MWBase::Environment::get().getStateManager()->getState(); MWBase::StateManager::State state = MWBase::Environment::get().getStateManager()->getState();
showBackground(state == MWBase::StateManager::State_NoGame); showBackground(state == MWBase::StateManager::State_NoGame);
mVersionText->setVisible(state == MWBase::StateManager::State_NoGame);
std::vector<std::string> buttons; std::vector<std::string> buttons;

@ -3,11 +3,11 @@
#include <openengine/gui/layout.hpp> #include <openengine/gui/layout.hpp>
#include "imagebutton.hpp"
namespace MWGui namespace MWGui
{ {
class ImageButton;
class BackgroundImage;
class SaveGameDialog; class SaveGameDialog;
class MainMenu : public OEngine::GUI::Layout class MainMenu : public OEngine::GUI::Layout
@ -29,7 +29,7 @@ namespace MWGui
MyGUI::Widget* mButtonBox; MyGUI::Widget* mButtonBox;
MyGUI::TextBox* mVersionText; MyGUI::TextBox* mVersionText;
MyGUI::ImageBox* mBackground; BackgroundImage* mBackground;
std::map<std::string, MWGui::ImageButton*> mButtons; std::map<std::string, MWGui::ImageButton*> mButtons;

@ -80,6 +80,8 @@ namespace MWGui
mCharacterSelection->removeAllItems(); mCharacterSelection->removeAllItems();
int selectedIndex = MyGUI::ITEM_NONE;
for (MWBase::StateManager::CharacterIterator it = mgr->characterBegin(); it != mgr->characterEnd(); ++it) for (MWBase::StateManager::CharacterIterator it = mgr->characterBegin(); it != mgr->characterEnd(); ++it)
{ {
if (it->begin()!=it->end()) if (it->begin()!=it->end())
@ -109,11 +111,13 @@ namespace MWGui
it->begin()->mPath.parent_path().filename().string()))) it->begin()->mPath.parent_path().filename().string())))
{ {
mCurrentCharacter = &*it; mCurrentCharacter = &*it;
mCharacterSelection->setIndexSelected(mCharacterSelection->getItemCount()-1); selectedIndex = mCharacterSelection->getItemCount()-1;
} }
} }
} }
mCharacterSelection->setIndexSelected(selectedIndex);
fillSaveList(); fillSaveList();
} }

@ -61,6 +61,7 @@
#include "itemview.hpp" #include "itemview.hpp"
#include "fontloader.hpp" #include "fontloader.hpp"
#include "videowidget.hpp" #include "videowidget.hpp"
#include "backgroundimage.hpp"
namespace MWGui namespace MWGui
{ {
@ -160,6 +161,7 @@ namespace MWGui
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWScrollView>("Widget"); MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWScrollView>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWScrollBar>("Widget"); MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWScrollBar>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<VideoWidget>("Widget"); MyGUI::FactoryManager::getInstance().registerFactory<VideoWidget>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<BackgroundImage>("Widget");
BookPage::registerMyGUIComponents (); BookPage::registerMyGUIComponents ();
ItemView::registerComponents(); ItemView::registerComponents();

@ -4,17 +4,13 @@
<!-- The entire screen --> <!-- The entire screen -->
<Widget type="Widget" layer="LoadingScreen" position="0 0 300 300" name="_Main"> <Widget type="Widget" layer="LoadingScreen" position="0 0 300 300" name="_Main">
<Widget type="ImageBox" skin="ImageBox" position="0 0 300 300" align="Stretch" name="BackgroundImage"> <Widget type="Widget" skin="HUD_Box" position="0 200 300 60" align="Bottom HCenter">
<Widget type="Widget" skin="HUD_Box" position="0 200 300 60" align="Bottom HCenter"> <Widget type="TextBox" skin="SandText" position="20 12 260 20" name="LoadingText">
<Property key="TextAlign" value="Center"/>
<Widget type="TextBox" skin="SandText" position="20 12 260 20" name="LoadingText"> </Widget>
<Property key="TextAlign" value="Center"/>
</Widget>
<Widget type="ScrollBar" skin="MW_ProgressScroll_Loading" position="20 36 260 8" name="ProgressBar">
</Widget>
<Widget type="ScrollBar" skin="MW_ProgressScroll_Loading" position="20 36 260 8" name="ProgressBar">
</Widget> </Widget>
</Widget> </Widget>

Loading…
Cancel
Save