mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-07 03:54:40 +00:00
opening, closing and taking books/scrolls works
This commit is contained in:
parent
0e6b82284f
commit
9fc1138a87
@ -46,7 +46,7 @@ add_openmw_dir (mwsound
|
||||
add_openmw_dir (mwworld
|
||||
refdata world physicssystem scene globals class action nullaction actionteleport
|
||||
containerstore actiontalk actiontake manualref player cellfunctors
|
||||
cells localscripts customdata weather inventorystore ptr
|
||||
cells localscripts customdata weather inventorystore ptr actionread
|
||||
)
|
||||
|
||||
add_openmw_dir (mwclass
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
#include "../mwworld/actionread.hpp"
|
||||
#include "../mwworld/world.hpp"
|
||||
|
||||
#include "../mwrender/objects.hpp"
|
||||
@ -60,12 +60,8 @@ namespace MWClass
|
||||
boost::shared_ptr<MWWorld::Action> Book::activate (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Ptr& actor) const
|
||||
{
|
||||
// TODO implement reading
|
||||
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
new MWWorld::ActionRead (ptr));
|
||||
}
|
||||
|
||||
std::string Book::getScript (const MWWorld::Ptr& ptr) const
|
||||
|
@ -1,15 +1,58 @@
|
||||
#include "bookwindow.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwinput/inputmanager.hpp"
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
|
||||
using namespace MWGui;
|
||||
|
||||
BookWindow::BookWindow(WindowManager& parWindowManager) :
|
||||
BookWindow::BookWindow (WindowManager& parWindowManager) :
|
||||
WindowBase("openmw_book_layout.xml", parWindowManager)
|
||||
{
|
||||
//setVisible(false);
|
||||
getWidget(mCloseButton, "CloseButton");
|
||||
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onCloseButtonClicked);
|
||||
|
||||
getWidget(mTakeButton, "TakeButton");
|
||||
mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onTakeButtonClicked);
|
||||
|
||||
getWidget(mNextPageButton, "NextPageBTN");
|
||||
mNextPageButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onNextPageButtonClicked);
|
||||
|
||||
getWidget(mPrevPageButton, "PrevPageBTN");
|
||||
mPrevPageButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onPrevPageButtonClicked);
|
||||
|
||||
center();
|
||||
}
|
||||
|
||||
void BookWindow::open(MWWorld::Ptr book)
|
||||
void BookWindow::open (MWWorld::Ptr book)
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (book, "book open", 1.0, 1.0);
|
||||
|
||||
mBook = book;
|
||||
}
|
||||
|
||||
void BookWindow::onCloseButtonClicked (MyGUI::Widget* _sender)
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (mBook, "book close", 1.0, 1.0);
|
||||
|
||||
MWBase::Environment::get().getInputManager()->setGuiMode(MWGui::GM_Game);
|
||||
}
|
||||
|
||||
void BookWindow::onTakeButtonClicked (MyGUI::Widget* _sender)
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (mBook, "Item Book Up", 1.0, 1.0, MWSound::Play_NoTrack);
|
||||
|
||||
MWWorld::ActionTake take(mBook);
|
||||
take.execute();
|
||||
|
||||
MWBase::Environment::get().getInputManager()->setGuiMode (GM_Game);
|
||||
}
|
||||
|
||||
void BookWindow::onNextPageButtonClicked (MyGUI::Widget* _sender)
|
||||
{
|
||||
}
|
||||
|
||||
void BookWindow::onPrevPageButtonClicked (MyGUI::Widget* _sender)
|
||||
{
|
||||
}
|
||||
|
@ -12,6 +12,20 @@ namespace MWGui
|
||||
public:
|
||||
BookWindow(WindowManager& parWindowManager);
|
||||
void open(MWWorld::Ptr book);
|
||||
|
||||
protected:
|
||||
void onNextPageButtonClicked (MyGUI::Widget* _sender);
|
||||
void onPrevPageButtonClicked (MyGUI::Widget* _sender);
|
||||
void onCloseButtonClicked (MyGUI::Widget* _sender);
|
||||
void onTakeButtonClicked (MyGUI::Widget* _sender);
|
||||
|
||||
private:
|
||||
MyGUI::Button* mCloseButton;
|
||||
MyGUI::Button* mTakeButton;
|
||||
MyGUI::Button* mNextPageButton;
|
||||
MyGUI::Button* mPrevPageButton;
|
||||
|
||||
MWWorld::Ptr mBook;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -12,12 +12,12 @@ namespace MWGui
|
||||
GM_Console, // Console mode
|
||||
GM_Journal, // Journal mode
|
||||
|
||||
// None of the following are implemented yet
|
||||
GM_Scroll, // Read scroll
|
||||
GM_Book, // Read book
|
||||
|
||||
GM_Dialogue, // NPC interaction
|
||||
GM_Barter,
|
||||
GM_Rest,
|
||||
// .. more here ..
|
||||
|
||||
// Startup character creation dialogs
|
||||
GM_Name,
|
||||
|
@ -1,14 +1,44 @@
|
||||
#include "scrollwindow.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwinput/inputmanager.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
|
||||
using namespace MWGui;
|
||||
|
||||
ScrollWindow::ScrollWindow(WindowManager& parWindowManager) :
|
||||
ScrollWindow::ScrollWindow (WindowManager& parWindowManager) :
|
||||
WindowBase("openmw_scroll_layout.xml", parWindowManager)
|
||||
{
|
||||
setVisible(false);
|
||||
getWidget(mCloseButton, "CloseButton");
|
||||
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ScrollWindow::onCloseButtonClicked);
|
||||
|
||||
getWidget(mTakeButton, "TakeButton");
|
||||
mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ScrollWindow::onTakeButtonClicked);
|
||||
|
||||
center();
|
||||
}
|
||||
|
||||
void ScrollWindow::open(MWWorld::Ptr scroll)
|
||||
void ScrollWindow::open (MWWorld::Ptr scroll)
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (scroll, "scroll", 1.0, 1.0);
|
||||
|
||||
mScroll = scroll;
|
||||
}
|
||||
|
||||
void ScrollWindow::onCloseButtonClicked (MyGUI::Widget* _sender)
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (mScroll, "scroll", 1.0, 1.0);
|
||||
|
||||
MWBase::Environment::get().getInputManager()->setGuiMode (GM_Game);
|
||||
}
|
||||
|
||||
void ScrollWindow::onTakeButtonClicked (MyGUI::Widget* _sender)
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D (mScroll, "Item Book Up", 1.0, 1.0, MWSound::Play_NoTrack);
|
||||
|
||||
MWWorld::ActionTake take(mScroll);
|
||||
take.execute();
|
||||
|
||||
MWBase::Environment::get().getInputManager()->setGuiMode (GM_Game);
|
||||
}
|
||||
|
@ -10,8 +10,18 @@ namespace MWGui
|
||||
class ScrollWindow : public WindowBase
|
||||
{
|
||||
public:
|
||||
ScrollWindow(WindowManager& parWindowManager);
|
||||
void open(MWWorld::Ptr scroll);
|
||||
ScrollWindow (WindowManager& parWindowManager);
|
||||
void open (MWWorld::Ptr scroll);
|
||||
|
||||
protected:
|
||||
void onCloseButtonClicked (MyGUI::Widget* _sender);
|
||||
void onTakeButtonClicked (MyGUI::Widget* _sender);
|
||||
|
||||
private:
|
||||
MyGUI::Button* mCloseButton;
|
||||
MyGUI::Button* mTakeButton;
|
||||
|
||||
MWWorld::Ptr mScroll;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -185,6 +185,8 @@ void WindowManager::updateVisible()
|
||||
stats->setVisible(false);
|
||||
console->disable();
|
||||
mJournal->setVisible(false);
|
||||
mScrollWindow->setVisible(false);
|
||||
mBookWindow->setVisible(false);
|
||||
dialogueWindow->setVisible(false);
|
||||
|
||||
// Mouse is visible whenever we're not in game mode
|
||||
@ -205,6 +207,12 @@ void WindowManager::updateVisible()
|
||||
case GM_Console:
|
||||
console->enable();
|
||||
break;
|
||||
case GM_Scroll:
|
||||
mScrollWindow->setVisible(true);
|
||||
break;
|
||||
case GM_Book:
|
||||
mBookWindow->setVisible(true);
|
||||
break;
|
||||
case GM_Name:
|
||||
case GM_Race:
|
||||
case GM_Class:
|
||||
|
@ -127,6 +127,9 @@ namespace MWGui
|
||||
|
||||
MWGui::DialogueWindow* getDialogueWindow() {return dialogueWindow;}
|
||||
|
||||
MWGui::BookWindow* getBookWindow() {return mBookWindow;}
|
||||
MWGui::ScrollWindow* getScrollWindow() {return mScrollWindow;}
|
||||
|
||||
MyGUI::Gui* getGui() const { return gui; }
|
||||
|
||||
void wmUpdateFps(float fps, size_t triangleCount, size_t batchCount)
|
||||
|
31
apps/openmw/mwworld/actionread.cpp
Normal file
31
apps/openmw/mwworld/actionread.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include "actionread.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwgui/window_manager.hpp"
|
||||
#include "../mwgui/bookwindow.hpp"
|
||||
#include "../mwgui/scrollwindow.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
ActionRead::ActionRead (const MWWorld::Ptr& object) : mObject (object)
|
||||
{
|
||||
}
|
||||
|
||||
void ActionRead::execute ()
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
|
||||
mObject.get<ESM::Book>();
|
||||
|
||||
if (ref->base->data.isScroll)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->setGuiMode(MWGui::GM_Scroll);
|
||||
MWBase::Environment::get().getWindowManager()->getScrollWindow()->open(mObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->setGuiMode(MWGui::GM_Book);
|
||||
MWBase::Environment::get().getWindowManager()->getBookWindow()->open(mObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
21
apps/openmw/mwworld/actionread.hpp
Normal file
21
apps/openmw/mwworld/actionread.hpp
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef GAME_MWWORLD_ACTIONREAD_H
|
||||
#define GAME_MWWORLD_ACTIONREAD_H
|
||||
|
||||
#include "action.hpp"
|
||||
#include "ptr.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class ActionRead : public Action
|
||||
{
|
||||
Ptr mObject; // book or scroll to read
|
||||
|
||||
public:
|
||||
/// @param book or scroll to read
|
||||
ActionRead (const Ptr& object);
|
||||
|
||||
virtual void execute ();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // ACTIONOPEN_H
|
Loading…
Reference in New Issue
Block a user