diff --git a/apps/openmw/mwgui/mw_layouts.hpp b/apps/openmw/mwgui/mw_layouts.hpp index 22e7b58fa..54e3bf733 100644 --- a/apps/openmw/mwgui/mw_layouts.hpp +++ b/apps/openmw/mwgui/mw_layouts.hpp @@ -5,6 +5,8 @@ #include +#include + /* This file contains classes corresponding to all the window layouts defined in resources/mygui/ *.xml. @@ -268,5 +270,124 @@ namespace MWGui } } }; + + class InventoryWindow : public OEngine::GUI::Layout + { + public: + enum CategoryMode + { + CM_All = 0, // All items + CM_Weapon = 1, // Only weapons + CM_Apparel = 2, // Apparel + CM_Magic = 3, // Magic + CM_Misc = 4 // Misc + }; + + InventoryWindow () + : Layout("openmw_inventory_window_layout.xml") + , categoryMode(CM_All) + + // color should be fetched from skin + , activeColor(0, 0, 1) + , inactiveColor(0.7, 0.7, 0.7) + { + setCoord(0, 200, 600, 400); + + // These are just demo values, you should replace these with + // real calls from outside the class later. + + mMainWidget->setCaption("Glass Frostsword"); + setText("EncumbranceBarT", "176/210"); + + MyGUI::ProgressPtr pt; + getWidget(pt, "EncumbranceBar"); + pt->setProgressRange(210); + pt->setProgressPosition(176); + + MyGUI::WidgetPtr avatar; + getWidget(avatar, "Avatar"); + + // Adjust armor rating text to bottom of avatar widget + MyGUI::StaticTextPtr armor_rating; + getWidget(armor_rating, "ArmorRating"); + armor_rating->setCaption("Armor: 11"); + MyGUI::IntCoord coord = armor_rating->getCoord(); + coord.top = avatar->getCoord().height - 4 - coord.height; + armor_rating->setCoord(coord); + + names[0] = "All"; + names[1] = "Weapon"; + names[2] = "Apparel"; + names[3] = "Magic"; + names[4] = "Misc"; + + boost::array categories = { { + CM_All, CM_Weapon, CM_Apparel, CM_Magic, CM_Misc + } }; + + // Initialize buttons with text and adjust sizes, also mark All as active button + int margin = 2; + int last_x = 0; + for (int i = 0; i < categories.size(); ++i) + { + CategoryMode mode = categories[i]; + std::string name = names[mode]; + name += "Button"; + setText(name, names[mode]); + getWidget(buttons[mode], name); + + MyGUI::ButtonPtr &button_pt = buttons[mode]; + if (mode == CM_All) + button_pt->setTextColour(activeColor); + else + button_pt->setTextColour(inactiveColor); + MyGUI::IntCoord coord = button_pt->getCoord(); + coord.left = last_x; + last_x += coord.width + margin; + button_pt->setCoord(coord); + + button_pt->eventMouseButtonClick = MyGUI::newDelegate(this, &InventoryWindow::onCategorySelected); + } + } + + void setCategory(CategoryMode mode) + { + MyGUI::ButtonPtr pt = getCategoryButton(categoryMode); + pt->setTextColour(inactiveColor); + + pt = getCategoryButton(mode); + pt->setTextColour(activeColor); + categoryMode = mode; + } + + MyGUI::ButtonPtr getCategoryButton(CategoryMode mode) + { + return buttons[mode]; + } + + void onCategorySelected(MyGUI::Widget *widget) + { + boost::array categories = { { + CM_All, CM_Weapon, CM_Apparel, CM_Magic, CM_Misc + } }; + + for (int i = 0; i < categories.size(); ++i) + { + CategoryMode mode = categories[i]; + if (widget == buttons[mode]) + { + setCategory(mode); + return; + } + } + } + + CategoryMode categoryMode; // Current category filter + MyGUI::ButtonPtr buttons[5]; // Button pointers + std::string names[5]; // Names of category buttons + + MyGUI::Colour activeColor; + MyGUI::Colour inactiveColor; + }; } #endif diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 995b39e88..207a5bb8c 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -22,6 +22,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment menu = new MainMenu(w,h); map = new MapWindow(); stats = new StatsWindow (environment.mWorld->getStore()); + inventory = new InventoryWindow (); console = new Console(w,h, environment, extensions); // The HUD is always on @@ -38,6 +39,7 @@ WindowManager::~WindowManager() delete map; delete menu; delete stats; + delete inventory; } void WindowManager::updateVisible() @@ -46,6 +48,7 @@ void WindowManager::updateVisible() map->setVisible(false); menu->setVisible(false); stats->setVisible(false); + inventory->setVisible(false); console->disable(); // Mouse is visible whenever we're not in game mode @@ -81,6 +84,7 @@ void WindowManager::updateVisible() // Show the windows we want map -> setVisible( eff & GW_Map ); stats -> setVisible( eff & GW_Stats ); + inventory -> setVisible( eff & GW_Inventory ); return; } diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index ea2d87bc9..32f0d4944 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -36,6 +36,7 @@ namespace MWGui class MapWindow; class MainMenu; class StatsWindow; + class InventoryWindow; class Console; enum GuiMode @@ -80,6 +81,7 @@ namespace MWGui MapWindow *map; MainMenu *menu; StatsWindow *stats; + InventoryWindow *inventory; Console *console; MyGUI::Gui *gui; diff --git a/extern/mygui_3.0.1/CMakeLists.txt b/extern/mygui_3.0.1/CMakeLists.txt index dbebf890a..6aa1f165b 100644 --- a/extern/mygui_3.0.1/CMakeLists.txt +++ b/extern/mygui_3.0.1/CMakeLists.txt @@ -38,6 +38,7 @@ configure_file("${SDIR}/openmw.font.xml" "${DDIR}/openmw.font.xml" COPYONLY) configure_file("${SDIR}/openmw_hud_box.skin.xml" "${DDIR}/openmw_hud_box.skin.xml" COPYONLY) configure_file("${SDIR}/openmw_hud_energybar.skin.xml" "${DDIR}/openmw_hud_energybar.skin.xml" COPYONLY) configure_file("${SDIR}/openmw_hud_layout.xml" "${DDIR}/openmw_hud_layout.xml" COPYONLY) +configure_file("${SDIR}/openmw_inventory_window_layout.xml" "${DDIR}/openmw_inventory_window_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_layers.xml" "${DDIR}/openmw_layers.xml" COPYONLY) configure_file("${SDIR}/openmw_mainmenu_layout.xml" "${DDIR}/openmw_mainmenu_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_mainmenu_skin.xml" "${DDIR}/openmw_mainmenu_skin.xml" COPYONLY) diff --git a/extern/mygui_3.0.1/openmw_resources/openmw_inventory_window_layout.xml b/extern/mygui_3.0.1/openmw_resources/openmw_inventory_window_layout.xml new file mode 100644 index 000000000..e5c32a9f7 --- /dev/null +++ b/extern/mygui_3.0.1/openmw_resources/openmw_inventory_window_layout.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +