From bc51ba5a38a3c032a96ac84e16497b7271f5b97b Mon Sep 17 00:00:00 2001 From: gugus Date: Mon, 28 Nov 2011 16:51:11 +0100 Subject: [PATCH] Add the journal window (J key). It's still not in the right position. --- apps/openmw/mwgui/journal_window.cpp | 52 +++++++++++++++++++ apps/openmw/mwgui/journal_window.hpp | 45 ++++++++++++++++ apps/openmw/mwgui/mode.hpp | 1 + apps/openmw/mwgui/window_manager.cpp | 10 ++++ apps/openmw/mwgui/window_manager.hpp | 2 + apps/openmw/mwinput/inputmanager.cpp | 18 +++++++ .../openmw_journal_layout.xml | 13 +++++ 7 files changed, 141 insertions(+) create mode 100644 apps/openmw/mwgui/journal_window.cpp create mode 100644 apps/openmw/mwgui/journal_window.hpp create mode 100644 extern/mygui_3.0.1/openmw_resources/openmw_journal_layout.xml diff --git a/apps/openmw/mwgui/journal_window.cpp b/apps/openmw/mwgui/journal_window.cpp new file mode 100644 index 000000000..f52b3dc22 --- /dev/null +++ b/apps/openmw/mwgui/journal_window.cpp @@ -0,0 +1,52 @@ +#include "journal_window.hpp" +#include "window_manager.hpp" + + +void formatText() +{ + //std::string +} + + +MWGui::JournalWindow::JournalWindow (WindowManager& parWindowManager) + : WindowBase("openmw_journal_layout.xml", parWindowManager) + , lastPos(0) +{ + setCoord(0,0,498, 342); + + getWidget(mLeftTextWidget, "LeftText"); + getWidget(mRightTextWidget, "RightText"); + //MyGUI::ItemBox* list = new MyGUI::ItemBox(); + //list->addItem("qaq","aqzazaz"); + //mScrollerWidget->addChildItem(list); + //mScrollerWidget->addItem("dserzt",MyGUI::UString("fedgdfg")); + //mEditWidget->addText("ljblsxdvdsfvgedfvdfvdkjfghldfjgn sdv,nhsxl;vvn lklksbvlksb lbsdflkbdSLKJGBLskdhbvlshow(); + //mEditWidget->setEditStatic(true); + mLeftTextWidget->addText("left texxxt "); + mLeftTextWidget->setEditReadOnly(true); + mRightTextWidget->setEditReadOnly(true); + mRightTextWidget->setEditStatic(true); + mLeftTextWidget->setEditStatic(true); + mRightTextWidget->addText("Right texxt "); + + displayLeftText("sdfsdfsdfvf"); + + MyGUI::WindowPtr t = static_cast(mMainWidget); + t->eventWindowChangeCoord = MyGUI::newDelegate(this, &JournalWindow::onWindowResize); +} + +void MWGui::JournalWindow::onWindowResize(MyGUI::Window* window) +{ +} + +void MWGui::JournalWindow::displayLeftText(std::string text) +{ + mLeftTextWidget->removeAllRenderItems(); + mLeftTextWidget->addText(text); +} + +void MWGui::JournalWindow::displayRightText(std::string text) +{ + mRightTextWidget->addText(text); +} \ No newline at end of file diff --git a/apps/openmw/mwgui/journal_window.hpp b/apps/openmw/mwgui/journal_window.hpp new file mode 100644 index 000000000..9b4698398 --- /dev/null +++ b/apps/openmw/mwgui/journal_window.hpp @@ -0,0 +1,45 @@ +#ifndef MWGUI_JOURNAL_H +#define MWGUI_JOURNAL_H + +#include +#include +#include +#include +#include "../mwdialogue/journal.hpp" + +#include "window_base.hpp" + +namespace MWGui +{ + class WindowManager; + + class JournalWindow : public WindowBase + { + public: + JournalWindow(WindowManager& parWindowManager); + + private: + enum ColorStyle + { + CS_Sub, + CS_Normal, + CS_Super + }; + + void onWindowResize(MyGUI::Window* window); + + void displayLeftText(std::string text); + void displayRightText(std::string text); + + static const int lineHeight; + + MyGUI::WidgetPtr skillAreaWidget, skillClientWidget; + MyGUI::VScrollPtr skillScrollerWidget; + int lastPos, clientHeight; + MyGUI::EditPtr mLeftTextWidget; + MyGUI::EditPtr mRightTextWidget; + }; + +} + +#endif \ No newline at end of file diff --git a/apps/openmw/mwgui/mode.hpp b/apps/openmw/mwgui/mode.hpp index b0dc14029..55f0952ce 100644 --- a/apps/openmw/mwgui/mode.hpp +++ b/apps/openmw/mwgui/mode.hpp @@ -10,6 +10,7 @@ namespace MWGui GM_MainMenu, // Main menu mode GM_Console, // Console mode + GM_Journal, // Journal mode // None of the following are implemented yet diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 84e45859f..ff98df7af 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -14,6 +14,7 @@ #include "../mwinput/inputmanager.hpp" #include "console.hpp" +#include "journal_window.hpp" #include #include @@ -61,6 +62,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment inventory = new InventoryWindow (); #endif console = new Console(w,h, environment, extensions); + mJournal = new JournalWindow(*this); mMessageBoxManager = new MessageBoxManager(this); // The HUD is always on @@ -89,6 +91,7 @@ WindowManager::~WindowManager() delete map; delete menu; delete stats; + delete mJournal; #if 0 delete inventory; #endif @@ -156,6 +159,7 @@ void WindowManager::updateVisible() inventory->setVisible(false); #endif console->disable(); + mJournal->setVisible(false); // Mouse is visible whenever we're not in game mode gui->setVisiblePointer(isGuiMode()); @@ -338,6 +342,12 @@ void WindowManager::updateVisible() return; } + if(mode == GM_Journal) + { + mJournal->setVisible(true); + return; + } + // Unsupported mode, switch back to game // Note: The call will eventually end up this method again but diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 293bac601..9db3f8c60 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -51,6 +51,7 @@ namespace MWGui class StatsWindow; class InventoryWindow; class Console; + class JournalWindow; class TextInputDialog; class InfoBoxDialog; @@ -90,6 +91,7 @@ namespace MWGui InventoryWindow *inventory; #endif Console *console; + JournalWindow* mJournal; // Character creation TextInputDialog *nameDialog; diff --git a/apps/openmw/mwinput/inputmanager.cpp b/apps/openmw/mwinput/inputmanager.cpp index eb6c59963..e0c819a71 100644 --- a/apps/openmw/mwinput/inputmanager.cpp +++ b/apps/openmw/mwinput/inputmanager.cpp @@ -134,6 +134,21 @@ namespace MWInput else setGuiMode(GM_Console); } + void toggleJournal() + { + using namespace MWGui; + + GuiMode mode = windows.getMode(); + + // Toggle between game mode and journal mode + if(mode == GM_Game) + setGuiMode(GM_Journal); + else if(mode == GM_Journal) + setGuiMode(GM_Game); + + // .. but don't touch any other mode. + } + void activate() { mEngine.activate(); @@ -188,6 +203,8 @@ namespace MWInput "Toggle inventory screen"); disp->funcs.bind(A_Console, boost::bind(&InputImpl::toggleConsole, this), "Toggle console"); + disp->funcs.bind(A_Journal, boost::bind(&InputImpl::toggleJournal, this), + "Toggle journal"); disp->funcs.bind(A_Activate, boost::bind(&InputImpl::activate, this), "Activate"); disp->funcs.bind(A_AutoMove, boost::bind(&InputImpl::toggleAutoMove, this), @@ -236,6 +253,7 @@ namespace MWInput disp->bind(A_Screenshot, KC_SYSRQ); disp->bind(A_Inventory, KC_I); disp->bind(A_Console, KC_F1); + disp->bind(A_Journal, KC_J); disp->bind(A_Activate, KC_SPACE); disp->bind(A_AutoMove, KC_Z); disp->bind(A_ToggleSneak, KC_X); diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_journal_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_journal_layout.xml new file mode 100644 index 000000000..a9cf42fdd --- /dev/null +++ b/extern/mygui_3.0.1/openmw_resources/openmw_journal_layout.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + +