Don't attempt to create quest log buttons if textures are unavailable (Fixes #3063)

openmw-38
scrawl 9 years ago
parent 5981e1cbb3
commit 9d4af59860

@ -96,7 +96,7 @@ namespace
return getWidget <MWGui::BookPage> (name); return getWidget <MWGui::BookPage> (name);
} }
JournalWindowImpl (MWGui::JournalViewModel::Ptr Model) JournalWindowImpl (MWGui::JournalViewModel::Ptr Model, bool questList)
: WindowBase("openmw_journal.layout"), JournalBooks (Model) : WindowBase("openmw_journal.layout"), JournalBooks (Model)
{ {
mMainWidget->setVisible(false); mMainWidget->setVisible(false);
@ -142,17 +142,17 @@ namespace
getPage (RightTopicIndex)->adviseLinkClicked (callback); getPage (RightTopicIndex)->adviseLinkClicked (callback);
} }
adjustButton(OptionsBTN, true);
adjustButton(PrevPageBTN); adjustButton(PrevPageBTN);
adjustButton(NextPageBTN); adjustButton(NextPageBTN);
adjustButton(CloseBTN); adjustButton(CloseBTN);
adjustButton(CancelBTN); adjustButton(CancelBTN);
adjustButton(ShowAllBTN, true);
adjustButton(ShowActiveBTN, true);
adjustButton(JournalBTN); adjustButton(JournalBTN);
Gui::ImageButton* optionsButton = getWidget<Gui::ImageButton>(OptionsBTN); Gui::ImageButton* optionsButton = getWidget<Gui::ImageButton>(OptionsBTN);
if (optionsButton->getWidth() == 0) Gui::ImageButton* showActiveButton = getWidget<Gui::ImageButton>(ShowActiveBTN);
Gui::ImageButton* showAllButton = getWidget<Gui::ImageButton>(ShowAllBTN);
Gui::ImageButton* questsButton = getWidget<Gui::ImageButton>(QuestsBTN);
if (!questList)
{ {
// If tribunal is not installed (-> no options button), we still want the Topics button available, // If tribunal is not installed (-> no options button), we still want the Topics button available,
// so place it where the options button would have been // so place it where the options button would have been
@ -162,6 +162,23 @@ namespace
topicsButton->setPosition(optionsButton->getPosition()); topicsButton->setPosition(optionsButton->getPosition());
topicsButton->eventMouseButtonClick.clear(); topicsButton->eventMouseButtonClick.clear();
topicsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &JournalWindowImpl::notifyOptions); topicsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &JournalWindowImpl::notifyOptions);
optionsButton->setVisible(false);
showActiveButton->setVisible(false);
showAllButton->setVisible(false);
questsButton->setVisible(false);
}
else
{
optionsButton->setImage("textures/tx_menubook_options.dds");
showActiveButton->setImage("textures/tx_menubook_quests_active.dds");
showAllButton->setImage("textures/tx_menubook_quests_all.dds");
questsButton->setImage("textures/tx_menubook_quests.dds");
adjustButton(ShowAllBTN);
adjustButton(ShowActiveBTN);
adjustButton(OptionsBTN);
adjustButton(QuestsBTN);
} }
Gui::ImageButton* nextButton = getWidget<Gui::ImageButton>(NextPageBTN); Gui::ImageButton* nextButton = getWidget<Gui::ImageButton>(NextPageBTN);
@ -173,7 +190,6 @@ namespace
} }
adjustButton(TopicsBTN); adjustButton(TopicsBTN);
adjustButton(QuestsBTN, true);
int width = getWidget<MyGUI::Widget>(TopicsBTN)->getSize().width + getWidget<MyGUI::Widget>(QuestsBTN)->getSize().width; int width = getWidget<MyGUI::Widget>(TopicsBTN)->getSize().width + getWidget<MyGUI::Widget>(QuestsBTN)->getSize().width;
int topicsWidth = getWidget<MyGUI::Widget>(TopicsBTN)->getSize().width; int topicsWidth = getWidget<MyGUI::Widget>(TopicsBTN)->getSize().width;
int pageWidth = getWidget<MyGUI::Widget>(RightBookPage)->getSize().width; int pageWidth = getWidget<MyGUI::Widget>(RightBookPage)->getSize().width;
@ -186,12 +202,12 @@ namespace
mOptionsMode = false; mOptionsMode = false;
} }
void adjustButton (char const * name, bool optional = false) void adjustButton (char const * name)
{ {
Gui::ImageButton* button = getWidget<Gui::ImageButton>(name); Gui::ImageButton* button = getWidget<Gui::ImageButton>(name);
MyGUI::IntSize diff = button->getSize() - button->getRequestedSize(!optional); MyGUI::IntSize diff = button->getSize() - button->getRequestedSize();
button->setSize(button->getRequestedSize(!optional)); button->setSize(button->getRequestedSize());
if (button->getAlign().isRight()) if (button->getAlign().isRight())
button->setPosition(button->getPosition() + MyGUI::IntPoint(diff.width,0)); button->setPosition(button->getPosition() + MyGUI::IntPoint(diff.width,0));
@ -551,7 +567,7 @@ namespace
} }
// glue the implementation to the interface // glue the implementation to the interface
MWGui::JournalWindow * MWGui::JournalWindow::create (JournalViewModel::Ptr Model) MWGui::JournalWindow * MWGui::JournalWindow::create (JournalViewModel::Ptr Model, bool questList)
{ {
return new JournalWindowImpl (Model); return new JournalWindowImpl (Model, questList);
} }

@ -12,7 +12,7 @@ namespace MWGui
struct JournalWindow struct JournalWindow
{ {
/// construct a new instance of the one JournalWindow implementation /// construct a new instance of the one JournalWindow implementation
static JournalWindow * create (boost::shared_ptr <JournalViewModel> Model); static JournalWindow * create (boost::shared_ptr <JournalViewModel> Model, bool questList);
/// destroy this instance of the JournalWindow implementation /// destroy this instance of the JournalWindow implementation
virtual ~JournalWindow () {}; virtual ~JournalWindow () {};

@ -288,7 +288,9 @@ namespace MWGui
trackWindow(mStatsWindow, "stats"); trackWindow(mStatsWindow, "stats");
mConsole = new Console(w,h, mConsoleOnlyScripts); mConsole = new Console(w,h, mConsoleOnlyScripts);
trackWindow(mConsole, "console"); trackWindow(mConsole, "console");
mJournal = JournalWindow::create(JournalViewModel::create ());
bool questList = mResourceSystem->getVFS()->exists("textures/tx_menubook_options_over.dds");
mJournal = JournalWindow::create(JournalViewModel::create (), questList);
mMessageBoxManager = new MessageBoxManager( mMessageBoxManager = new MessageBoxManager(
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fMessageTimePerChar")->getFloat()); MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fMessageTimePerChar")->getFloat());
mInventoryWindow = new InventoryWindow(mDragAndDrop, mViewer, mResourceSystem); mInventoryWindow = new InventoryWindow(mDragAndDrop, mViewer, mResourceSystem);

@ -31,6 +31,7 @@ namespace Resource
void setUnRefImageDataAfterApply(bool unref); void setUnRefImageDataAfterApply(bool unref);
/// Create or retrieve a Texture2D using the specified image filename, and wrap parameters. /// Create or retrieve a Texture2D using the specified image filename, and wrap parameters.
/// Returns the dummy texture if the given texture is not found.
osg::ref_ptr<osg::Texture2D> getTexture2D(const std::string& filename, osg::Texture::WrapMode wrapS, osg::Texture::WrapMode wrapT); osg::ref_ptr<osg::Texture2D> getTexture2D(const std::string& filename, osg::Texture::WrapMode wrapS, osg::Texture::WrapMode wrapT);
/// Create or retrieve an Image /// Create or retrieve an Image

@ -42,18 +42,31 @@ namespace Gui
ImageBox::onMouseButtonPressed(_left, _top, _id); ImageBox::onMouseButtonPressed(_left, _top, _id);
} }
MyGUI::IntSize ImageButton::getRequestedSize(bool logError) MyGUI::IntSize ImageButton::getRequestedSize()
{ {
MyGUI::ITexture* texture = MyGUI::RenderManager::getInstance().getTexture(mImageNormal); MyGUI::ITexture* texture = MyGUI::RenderManager::getInstance().getTexture(mImageNormal);
if (!texture) if (!texture)
{ {
if (logError) std::cerr << "ImageButton: can't find " << mImageNormal << std::endl;
std::cerr << "ImageButton: can't find " << mImageNormal << std::endl;
return MyGUI::IntSize(0,0); return MyGUI::IntSize(0,0);
} }
return MyGUI::IntSize (texture->getWidth(), texture->getHeight()); return MyGUI::IntSize (texture->getWidth(), texture->getHeight());
} }
void ImageButton::setImage(const std::string &image)
{
size_t extpos = image.find_last_of(".");
std::string imageNoExt = image.substr(0, extpos);
std::string ext = image.substr(extpos);
mImageNormal = imageNoExt + "_idle" + ext;
mImageHighlighted = imageNoExt + "_over" + ext;
mImagePushed = imageNoExt + "_pressed" + ext;
setImageTexture(mImageNormal);
}
void ImageButton::onMouseButtonReleased(int _left, int _top, MyGUI::MouseButton _id) void ImageButton::onMouseButtonReleased(int _left, int _top, MyGUI::MouseButton _id)
{ {
if (_id == MyGUI::MouseButton::Left) if (_id == MyGUI::MouseButton::Left)

@ -14,7 +14,10 @@ namespace Gui
MYGUI_RTTI_DERIVED(ImageButton) MYGUI_RTTI_DERIVED(ImageButton)
public: public:
MyGUI::IntSize getRequestedSize(bool logError = true); MyGUI::IntSize getRequestedSize();
/// Set mImageNormal, mImageHighlighted and mImagePushed based on file convention (image_idle.ext, image_over.ext and image_pressed.ext)
void setImage(const std::string& image);
protected: protected:
virtual void setPropertyOverride(const std::string& _key, const std::string& _value); virtual void setPropertyOverride(const std::string& _key, const std::string& _value);

@ -26,9 +26,7 @@
<!-- buttons --> <!-- buttons -->
<Widget type="ImageButton" skin="ImageBox" position="40 350 64 32" name="OptionsBTN"> <Widget type="ImageButton" skin="ImageBox" position="40 350 64 32" name="OptionsBTN">
<Property key="ImageHighlighted" value="textures\tx_menubook_options_over.dds"/> <!-- Image set at runtime since it may not be available in all versions of the game -->
<Property key="ImageNormal" value="textures\tx_menubook_options_idle.dds"/>
<Property key="ImagePushed" value="textures\tx_menubook_options_pressed.dds"/>
</Widget> </Widget>
<Widget type="TextBox" skin="NormalText" position="150 350 32 16" name="PageOneNum"> <Widget type="TextBox" skin="NormalText" position="150 350 32 16" name="PageOneNum">
<Property key="TextColour" value="0 0 0"/> <Property key="TextColour" value="0 0 0"/>
@ -66,15 +64,11 @@
<Widget type="BookPage" skin="MW_BookPage" position="112 15 92 250" name="RightTopicIndex"/> <Widget type="BookPage" skin="MW_BookPage" position="112 15 92 250" name="RightTopicIndex"/>
<Widget type="ImageButton" skin="ImageBox" position="62 15 100 20" Align="Top|Left" name="ShowActiveBTN"> <Widget type="ImageButton" skin="ImageBox" position="62 15 100 20" Align="Top|Left" name="ShowActiveBTN">
<Property key="ImageHighlighted" value="textures\tx_menubook_quests_active_over.dds"/> <!-- Image set at runtime since it may not be available in all versions of the game -->
<Property key="ImageNormal" value="textures\tx_menubook_quests_active_idle.dds"/>
<Property key="ImagePushed" value="textures\tx_menubook_quests_active_pressed.dds"/>
</Widget> </Widget>
<Widget type="ImageButton" skin="ImageBox" position="76 15 72 20" Align="Top|Left" name="ShowAllBTN"> <Widget type="ImageButton" skin="ImageBox" position="76 15 72 20" Align="Top|Left" name="ShowAllBTN">
<Property key="ImageHighlighted" value="textures\tx_menubook_quests_all_over.dds"/> <!-- Image set at runtime since it may not be available in all versions of the game -->
<Property key="ImageNormal" value="textures\tx_menubook_quests_all_idle.dds"/>
<Property key="ImagePushed" value="textures\tx_menubook_quests_all_pressed.dds"/>
</Widget> </Widget>
<Widget type="MWList" skin="MW_QuestList" position="8 35 208 225" name="TopicsList" align="Right VStretch"> <Widget type="MWList" skin="MW_QuestList" position="8 35 208 225" name="TopicsList" align="Right VStretch">
@ -90,9 +84,7 @@
</Widget> </Widget>
<Widget type="ImageButton" skin="ImageBox" position="130 265 56 32" Align="Top|Left" name="QuestsBTN"> <Widget type="ImageButton" skin="ImageBox" position="130 265 56 32" Align="Top|Left" name="QuestsBTN">
<Property key="ImageHighlighted" value="textures\tx_menubook_quests_over.dds"/> <!-- Image set at runtime since it may not be available in all versions of the game -->
<Property key="ImageNormal" value="textures\tx_menubook_quests_idle.dds"/>
<Property key="ImagePushed" value="textures\tx_menubook_quests_pressed.dds"/>
</Widget> </Widget>
<Widget type="ImageButton" skin="ImageBox" position="85 290 56 32" Align="Top|Left" name="CancelBTN"> <Widget type="ImageButton" skin="ImageBox" position="85 290 56 32" Align="Top|Left" name="CancelBTN">

Loading…
Cancel
Save