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);
}
JournalWindowImpl (MWGui::JournalViewModel::Ptr Model)
JournalWindowImpl (MWGui::JournalViewModel::Ptr Model, bool questList)
: WindowBase("openmw_journal.layout"), JournalBooks (Model)
{
mMainWidget->setVisible(false);
@ -142,17 +142,17 @@ namespace
getPage (RightTopicIndex)->adviseLinkClicked (callback);
}
adjustButton(OptionsBTN, true);
adjustButton(PrevPageBTN);
adjustButton(NextPageBTN);
adjustButton(CloseBTN);
adjustButton(CancelBTN);
adjustButton(ShowAllBTN, true);
adjustButton(ShowActiveBTN, true);
adjustButton(JournalBTN);
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,
// so place it where the options button would have been
@ -162,6 +162,23 @@ namespace
topicsButton->setPosition(optionsButton->getPosition());
topicsButton->eventMouseButtonClick.clear();
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);
@ -173,7 +190,6 @@ namespace
}
adjustButton(TopicsBTN);
adjustButton(QuestsBTN, true);
int width = getWidget<MyGUI::Widget>(TopicsBTN)->getSize().width + getWidget<MyGUI::Widget>(QuestsBTN)->getSize().width;
int topicsWidth = getWidget<MyGUI::Widget>(TopicsBTN)->getSize().width;
int pageWidth = getWidget<MyGUI::Widget>(RightBookPage)->getSize().width;
@ -186,12 +202,12 @@ namespace
mOptionsMode = false;
}
void adjustButton (char const * name, bool optional = false)
void adjustButton (char const * name)
{
Gui::ImageButton* button = getWidget<Gui::ImageButton>(name);
MyGUI::IntSize diff = button->getSize() - button->getRequestedSize(!optional);
button->setSize(button->getRequestedSize(!optional));
MyGUI::IntSize diff = button->getSize() - button->getRequestedSize();
button->setSize(button->getRequestedSize());
if (button->getAlign().isRight())
button->setPosition(button->getPosition() + MyGUI::IntPoint(diff.width,0));
@ -551,7 +567,7 @@ namespace
}
// 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
{
/// 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
virtual ~JournalWindow () {};

@ -288,7 +288,9 @@ namespace MWGui
trackWindow(mStatsWindow, "stats");
mConsole = new Console(w,h, mConsoleOnlyScripts);
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(
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fMessageTimePerChar")->getFloat());
mInventoryWindow = new InventoryWindow(mDragAndDrop, mViewer, mResourceSystem);

@ -31,6 +31,7 @@ namespace Resource
void setUnRefImageDataAfterApply(bool unref);
/// 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);
/// Create or retrieve an Image

@ -42,18 +42,31 @@ namespace Gui
ImageBox::onMouseButtonPressed(_left, _top, _id);
}
MyGUI::IntSize ImageButton::getRequestedSize(bool logError)
MyGUI::IntSize ImageButton::getRequestedSize()
{
MyGUI::ITexture* texture = MyGUI::RenderManager::getInstance().getTexture(mImageNormal);
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 (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)
{
if (_id == MyGUI::MouseButton::Left)

@ -14,7 +14,10 @@ namespace Gui
MYGUI_RTTI_DERIVED(ImageButton)
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:
virtual void setPropertyOverride(const std::string& _key, const std::string& _value);

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

Loading…
Cancel
Save