forked from teamnwah/openmw-tes3coop
Added MyGUI to OpenMW, fully working (with events and script hooks)
parent
4d74f85ae0
commit
c84672a560
@ -1,34 +0,0 @@
|
||||
|
||||
#include "guimanager.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "mw_layouts.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
void GuiManager::enableWindow (GuiWindow window)
|
||||
{
|
||||
std::cout << "enable window: " << window << std::endl;
|
||||
}
|
||||
|
||||
void GuiManager::showOneTimeDialogue (GuiOneTimeDialogue dialogue)
|
||||
{
|
||||
std::cout << "show one time dialogue: " << dialogue << std::endl;
|
||||
}
|
||||
|
||||
void GuiManager::enableDialogue (GuiDialogue dialogue)
|
||||
{
|
||||
std::cout << "enable dialogue: " << dialogue << std::endl;
|
||||
}
|
||||
|
||||
void GuiManager::showDialogue (GuiDialogue dialogue)
|
||||
{
|
||||
std::cout << "show dialogue: " << dialogue << std::endl;
|
||||
}
|
||||
|
||||
bool GuiManager::isGuiActive() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
#ifndef GAME_SOUND_GUIMANAGER_H
|
||||
#define GAME_SOUND_GUIMANAGER_H
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
// Predeclarations, these are defined in mw_layouts.hpp
|
||||
class HUD;
|
||||
class MapWindow;
|
||||
class MainMenu;
|
||||
class StatsWindow;
|
||||
|
||||
class GuiManager
|
||||
{
|
||||
HUD *hud;
|
||||
MapWindow *map;
|
||||
MainMenu *menu;
|
||||
StatsWindow *stats;
|
||||
|
||||
public:
|
||||
|
||||
enum GuiWindow
|
||||
{
|
||||
Gui_Inventory, Gui_Magic, Gui_Map, Gui_Status
|
||||
};
|
||||
|
||||
enum GuiOneTimeDialogue // used only once
|
||||
{
|
||||
// character generation
|
||||
Gui_Birth, Gui_Class, Gui_Name, Gui_Race, Gui_Review
|
||||
};
|
||||
|
||||
enum GuiDialogue
|
||||
{
|
||||
Gui_Rest
|
||||
};
|
||||
|
||||
void enableWindow (GuiWindow window);
|
||||
///< diabled by default.
|
||||
|
||||
void showOneTimeDialogue (GuiOneTimeDialogue dialogue);
|
||||
|
||||
void enableDialogue (GuiDialogue dialogue);
|
||||
///< disabled by default.
|
||||
|
||||
void showDialogue (GuiDialogue dialogue);
|
||||
|
||||
bool isGuiActive() const;
|
||||
///< Any non-HUD GUI element active (dialogues and windows)?
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,74 @@
|
||||
#include "window_manager.hpp"
|
||||
#include "mw_layouts.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
using namespace MWGui;
|
||||
|
||||
WindowManager::WindowManager(MyGUI::Gui *_gui)
|
||||
: gui(_gui), mode(GM_Game), shown(GW_ALL), allowed(GW_ALL)
|
||||
{
|
||||
// Get size info from the Gui object
|
||||
assert(gui);
|
||||
int w = gui->getViewWidth();
|
||||
int h = gui->getViewHeight();
|
||||
|
||||
hud = new HUD(w,h);
|
||||
menu = new MainMenu(w,h);
|
||||
map = new MapWindow();
|
||||
stats = new StatsWindow();
|
||||
|
||||
// The HUD is always on
|
||||
hud->setVisible(true);
|
||||
|
||||
// Set up visibility
|
||||
updateVisible();
|
||||
}
|
||||
|
||||
WindowManager::~WindowManager()
|
||||
{
|
||||
delete hud;
|
||||
delete map;
|
||||
delete menu;
|
||||
delete stats;
|
||||
}
|
||||
|
||||
void WindowManager::updateVisible()
|
||||
{
|
||||
// Start out by hiding everything except the HUD
|
||||
map->setVisible(false);
|
||||
menu->setVisible(false);
|
||||
stats->setVisible(false);
|
||||
|
||||
// Mouse is visible whenever we're not in game mode
|
||||
gui->setVisiblePointer(isGuiMode());
|
||||
|
||||
// If in game mode, don't show anything.
|
||||
if(mode == GM_Game)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(mode == GM_MainMenu)
|
||||
{
|
||||
// Enable the main menu
|
||||
menu->setVisible(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if(mode == GM_Inventory)
|
||||
{
|
||||
// Ah, inventory mode. First, compute the effective set of
|
||||
// windows to show. This is controlled both by what windows the
|
||||
// user has opened/closed (the 'shown' variable) and by what
|
||||
// windows we are allowed to show (the 'allowed' var.)
|
||||
int eff = shown & allowed;
|
||||
|
||||
// Show the windows we want
|
||||
map -> setVisible( eff & GW_Map );
|
||||
stats -> setVisible( eff & GW_Stats );
|
||||
return;
|
||||
}
|
||||
|
||||
// All other modes are ignored
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
#ifndef MWGUI_WINDOWMANAGER_H
|
||||
#define MWGUI_WINDOWMANAGER_H
|
||||
|
||||
/**
|
||||
This class owns and controls all the MW specific windows in the
|
||||
GUI. It can enable/disable Gui mode, and is responsible for sending
|
||||
and retrieving information from the Gui.
|
||||
|
||||
MyGUI should be initialized separately before creating instances of
|
||||
this class.
|
||||
*/
|
||||
|
||||
namespace MyGUI
|
||||
{
|
||||
class Gui;
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
class HUD;
|
||||
class MapWindow;
|
||||
class MainMenu;
|
||||
class StatsWindow;
|
||||
|
||||
enum GuiMode
|
||||
{
|
||||
GM_Game, // Game mode, only HUD
|
||||
GM_Inventory, // Inventory mode
|
||||
GM_MainMenu, // Main menu mode
|
||||
|
||||
// None of the following are implemented yet
|
||||
|
||||
GM_Dialogue, // NPC interaction
|
||||
GM_Barter,
|
||||
GM_Rest,
|
||||
// .. more here ..
|
||||
|
||||
// Startup character creation dialogs
|
||||
GM_Name,
|
||||
GM_Race,
|
||||
GM_Birth,
|
||||
GM_Class,
|
||||
GM_Review
|
||||
};
|
||||
|
||||
// Windows shown in inventory mode
|
||||
enum GuiWindow
|
||||
{
|
||||
GW_None = 0,
|
||||
|
||||
GW_Map = 0x01,
|
||||
GW_Inventory = 0x02,
|
||||
GW_Magic = 0x04,
|
||||
GW_Stats = 0x08,
|
||||
|
||||
GW_ALL = 0xFF
|
||||
};
|
||||
|
||||
class WindowManager
|
||||
{
|
||||
HUD *hud;
|
||||
MapWindow *map;
|
||||
MainMenu *menu;
|
||||
StatsWindow *stats;
|
||||
|
||||
MyGUI::Gui *gui;
|
||||
|
||||
// Current gui mode
|
||||
GuiMode mode;
|
||||
|
||||
// Currently shown windows in inventory mode
|
||||
GuiWindow shown;
|
||||
|
||||
/* Currently ALLOWED windows in inventory mode. This is used at
|
||||
the start of the game, when windows are enabled one by one
|
||||
through script commands. You can manipulate this through using
|
||||
allow() and disableAll().
|
||||
|
||||
The setting should also affect visibility of certain HUD
|
||||
elements, but this is not done yet.
|
||||
*/
|
||||
GuiWindow allowed;
|
||||
|
||||
// Update visibility of all windows based on mode, shown and
|
||||
// allowed settings.
|
||||
void updateVisible();
|
||||
|
||||
public:
|
||||
/// The constructor needs the main Gui object
|
||||
WindowManager(MyGUI::Gui *_gui);
|
||||
virtual ~WindowManager();
|
||||
|
||||
void setMode(GuiMode newMode)
|
||||
{
|
||||
mode = newMode;
|
||||
updateVisible();
|
||||
}
|
||||
|
||||
GuiMode getMode() const { return mode; }
|
||||
|
||||
// Everything that is not game mode is considered "gui mode"
|
||||
bool isGuiMode() const { return getMode() != GM_Game; }
|
||||
|
||||
// Disallow all inventory mode windows
|
||||
void disallowAll()
|
||||
{
|
||||
allowed = GW_None;
|
||||
updateVisible();
|
||||
}
|
||||
|
||||
// Allow one or more windows
|
||||
void allow(GuiWindow wnd)
|
||||
{
|
||||
allowed = (GuiWindow)(allowed | wnd);
|
||||
updateVisible();
|
||||
}
|
||||
|
||||
MyGUI::Gui* getGui() const { return gui; }
|
||||
};
|
||||
}
|
||||
#endif
|
@ -1 +1 @@
|
||||
Subproject commit fedb1a80256a093511075aeb88408c7c56a136ce
|
||||
Subproject commit 82a3c071e56f2df451618e1371424c39aa299690
|
@ -1,16 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
function run()
|
||||
{
|
||||
echo
|
||||
echo "$1/tests/:"
|
||||
cd "$1/tests/"
|
||||
./test.sh
|
||||
cd ../../
|
||||
}
|
||||
|
||||
run tools
|
||||
run input
|
||||
run bsa
|
||||
run nif
|
||||
run nifogre
|
Loading…
Reference in New Issue