mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-03 17:54:06 +00:00
Add FontLoader and transparent BG texture to the MyGUI plugin
This commit is contained in:
parent
ecfc2ff5d0
commit
ee3b1e800c
@ -39,7 +39,7 @@ add_openmw_dir (mwgui
|
|||||||
enchantingdialog trainingwindow travelwindow imagebutton exposedwindow cursor spellicons
|
enchantingdialog trainingwindow travelwindow imagebutton exposedwindow cursor spellicons
|
||||||
merchantrepair repair soulgemdialog companionwindow bookpage journalviewmodel journalbooks
|
merchantrepair repair soulgemdialog companionwindow bookpage journalviewmodel journalbooks
|
||||||
keywordsearch itemmodel containeritemmodel inventoryitemmodel sortfilteritemmodel itemview
|
keywordsearch itemmodel containeritemmodel inventoryitemmodel sortfilteritemmodel itemview
|
||||||
tradeitemmodel companionitemmodel pickpocketitemmodel fontloader controllers savegamedialog
|
tradeitemmodel companionitemmodel pickpocketitemmodel controllers savegamedialog
|
||||||
recharge mode videowidget backgroundimage itemwidget screenfader
|
recharge mode videowidget backgroundimage itemwidget screenfader
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include <extern/sdl4ogre/sdlcursormanager.hpp>
|
#include <extern/sdl4ogre/sdlcursormanager.hpp>
|
||||||
|
|
||||||
|
#include <components/fontloader/fontloader.hpp>
|
||||||
|
|
||||||
#include "../mwbase/inputmanager.hpp"
|
#include "../mwbase/inputmanager.hpp"
|
||||||
#include "../mwbase/statemanager.hpp"
|
#include "../mwbase/statemanager.hpp"
|
||||||
|
|
||||||
@ -63,7 +65,6 @@
|
|||||||
#include "inventorywindow.hpp"
|
#include "inventorywindow.hpp"
|
||||||
#include "bookpage.hpp"
|
#include "bookpage.hpp"
|
||||||
#include "itemview.hpp"
|
#include "itemview.hpp"
|
||||||
#include "fontloader.hpp"
|
|
||||||
#include "videowidget.hpp"
|
#include "videowidget.hpp"
|
||||||
#include "backgroundimage.hpp"
|
#include "backgroundimage.hpp"
|
||||||
#include "itemwidget.hpp"
|
#include "itemwidget.hpp"
|
||||||
@ -149,7 +150,7 @@ namespace MWGui
|
|||||||
mGui = mGuiManager->getGui();
|
mGui = mGuiManager->getGui();
|
||||||
|
|
||||||
// Load fonts
|
// Load fonts
|
||||||
FontLoader fontLoader (encoding);
|
Gui::FontLoader fontLoader (encoding);
|
||||||
fontLoader.loadAllFonts(exportFonts);
|
fontLoader.loadAllFonts(exportFonts);
|
||||||
|
|
||||||
//Register own widgets with MyGUI
|
//Register own widgets with MyGUI
|
||||||
|
@ -91,6 +91,14 @@ add_component_dir (ogreinit
|
|||||||
ogreinit ogreplugin
|
ogreinit ogreplugin
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_component_dir (widgets
|
||||||
|
box
|
||||||
|
)
|
||||||
|
|
||||||
|
add_component_dir (fontloader
|
||||||
|
fontloader
|
||||||
|
)
|
||||||
|
|
||||||
add_component_dir (version
|
add_component_dir (version
|
||||||
version
|
version
|
||||||
)
|
)
|
||||||
|
@ -123,7 +123,7 @@ namespace
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWGui
|
namespace Gui
|
||||||
{
|
{
|
||||||
|
|
||||||
FontLoader::FontLoader(ToUTF8::FromType encoding)
|
FontLoader::FontLoader(ToUTF8::FromType encoding)
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <components/to_utf8/to_utf8.hpp>
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
|
|
||||||
namespace MWGui
|
namespace Gui
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -1,13 +1,53 @@
|
|||||||
#include "plugin.hpp"
|
#include "plugin.hpp"
|
||||||
|
|
||||||
#include <MyGUI_LogManager.h>
|
#include <MyGUI_LogManager.h>
|
||||||
|
#include <MyGUI_FactoryManager.h>
|
||||||
|
#include <MyGUI_ScrollBar.h>
|
||||||
|
#include <MyGUI_Gui.h>
|
||||||
|
|
||||||
#include <components/bsa/resources.hpp>
|
#include <components/bsa/resources.hpp>
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
|
#include <components/fontloader/fontloader.hpp>
|
||||||
|
|
||||||
namespace MyGUI
|
#include <OgreTextureManager.h>
|
||||||
|
#include <OgreHardwarePixelBuffer.h>
|
||||||
|
|
||||||
|
namespace MyGUIPlugin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Dummy - obsolete when using MyGUI git, because the ScrollBar there has autorepeat support added.
|
||||||
|
class MWScrollBar : public MyGUI::ScrollBar
|
||||||
|
{
|
||||||
|
MYGUI_RTTI_DERIVED(MWScrollBar)
|
||||||
|
};
|
||||||
|
|
||||||
|
// Dummy - not properly supportable without bringing in the whole ESM store
|
||||||
|
class MWSkill : public MyGUI::Widget
|
||||||
|
{
|
||||||
|
MYGUI_RTTI_DERIVED( MWSkill )
|
||||||
|
};
|
||||||
|
class MWAttribute : public MyGUI::Widget
|
||||||
|
{
|
||||||
|
MYGUI_RTTI_DERIVED( MWAttribute )
|
||||||
|
};
|
||||||
|
class MWSpell : public MyGUI::Widget
|
||||||
|
{
|
||||||
|
MYGUI_RTTI_DERIVED( MWSpell )
|
||||||
|
};
|
||||||
|
class MWEffectList : public MyGUI::Widget
|
||||||
|
{
|
||||||
|
MYGUI_RTTI_DERIVED( MWEffectList )
|
||||||
|
};
|
||||||
|
class MWSpellEffect : public MyGUI::Widget
|
||||||
|
{
|
||||||
|
MYGUI_RTTI_DERIVED( MWSpellEffect )
|
||||||
|
};
|
||||||
|
class MWDynamicStat : public MyGUI::Widget
|
||||||
|
{
|
||||||
|
MYGUI_RTTI_DERIVED( MWDynamicStat )
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const std::string& ResourcePlugin::getName() const
|
const std::string& ResourcePlugin::getName() const
|
||||||
{
|
{
|
||||||
static const std::string name = "OpenMW resource plugin";
|
static const std::string name = "OpenMW resource plugin";
|
||||||
@ -23,10 +63,8 @@ namespace MyGUI
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourcePlugin::initialize()
|
void ResourcePlugin::registerResources()
|
||||||
{
|
{
|
||||||
MYGUI_LOGGING("OpenMW_Resource_Plugin", Info, "initialize");
|
|
||||||
|
|
||||||
boost::program_options::variables_map variables;
|
boost::program_options::variables_map variables;
|
||||||
|
|
||||||
boost::program_options::options_description desc("Allowed options");
|
boost::program_options::options_description desc("Allowed options");
|
||||||
@ -35,7 +73,8 @@ namespace MyGUI
|
|||||||
("data-local", boost::program_options::value<std::string>()->default_value(""))
|
("data-local", boost::program_options::value<std::string>()->default_value(""))
|
||||||
("fs-strict", boost::program_options::value<bool>()->implicit_value(true)->default_value(false))
|
("fs-strict", boost::program_options::value<bool>()->implicit_value(true)->default_value(false))
|
||||||
("fallback-archive", boost::program_options::value<std::vector<std::string> >()->
|
("fallback-archive", boost::program_options::value<std::vector<std::string> >()->
|
||||||
default_value(std::vector<std::string>(), "fallback-archive")->multitoken());
|
default_value(std::vector<std::string>(), "fallback-archive")->multitoken())
|
||||||
|
("encoding", boost::program_options::value<std::string>()->default_value("win1252"));
|
||||||
|
|
||||||
boost::program_options::notify(variables);
|
boost::program_options::notify(variables);
|
||||||
|
|
||||||
@ -64,11 +103,51 @@ namespace MyGUI
|
|||||||
Files::Collections collections (dataDirs, !fsStrict);
|
Files::Collections collections (dataDirs, !fsStrict);
|
||||||
|
|
||||||
Bsa::registerResources(collections, archives, true, fsStrict);
|
Bsa::registerResources(collections, archives, true, fsStrict);
|
||||||
|
|
||||||
|
std::string encoding(variables["encoding"].as<std::string>());
|
||||||
|
std::cout << ToUTF8::encodingUsingMessage(encoding) << std::endl;
|
||||||
|
|
||||||
|
Gui::FontLoader loader(ToUTF8::calculateEncoding(encoding));
|
||||||
|
loader.loadAllFonts(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResourcePlugin::registerWidgets()
|
||||||
|
{
|
||||||
|
MyGUI::FactoryManager::getInstance().registerFactory<MWScrollBar>("Widget");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResourcePlugin::createTransparentBGTexture()
|
||||||
|
{
|
||||||
|
// This texture is manually created in OpenMW to be able to change its opacity at runtime in the options menu
|
||||||
|
Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().createManual(
|
||||||
|
"transparent.png",
|
||||||
|
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
||||||
|
Ogre::TEX_TYPE_2D,
|
||||||
|
1, 1,
|
||||||
|
0,
|
||||||
|
Ogre::PF_A8R8G8B8,
|
||||||
|
Ogre::TU_WRITE_ONLY);
|
||||||
|
std::vector<Ogre::uint32> buffer;
|
||||||
|
buffer.resize(1);
|
||||||
|
const float val = 0.7;
|
||||||
|
buffer[0] = (int(255*val) << 24);
|
||||||
|
memcpy(tex->getBuffer()->lock(Ogre::HardwareBuffer::HBL_DISCARD), &buffer[0], 1*4);
|
||||||
|
tex->getBuffer()->unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResourcePlugin::initialize()
|
||||||
|
{
|
||||||
|
MYGUI_LOGGING("OpenMW_Resource_Plugin", Info, "initialize");
|
||||||
|
|
||||||
|
registerResources();
|
||||||
|
registerWidgets();
|
||||||
|
createTransparentBGTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourcePlugin::shutdown()
|
void ResourcePlugin::shutdown()
|
||||||
{
|
{
|
||||||
/// \todo remove resource groups
|
/// \todo cleanup
|
||||||
|
|
||||||
MYGUI_LOGGING("OpenMW_Resource_Plugin", Info, "shutdown");
|
MYGUI_LOGGING("OpenMW_Resource_Plugin", Info, "shutdown");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,9 +3,14 @@
|
|||||||
|
|
||||||
#include <MyGUI_Plugin.h>
|
#include <MyGUI_Plugin.h>
|
||||||
|
|
||||||
namespace MyGUI
|
namespace MyGUIPlugin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MyGUI plugin used to register Morrowind resources, custom widgets used in OpenMW, and load Morrowind fonts.
|
||||||
|
* @paragraph The plugin isn't used in OpenMW itself, but it is useful with the standalone MyGUI tools. To use it,
|
||||||
|
* change EditorPlugin.xml in Media/Tools/LayoutEditor/EditorPlugin.xml and add an entry for this plugin.
|
||||||
|
*/
|
||||||
class ResourcePlugin : public MyGUI::IPlugin
|
class ResourcePlugin : public MyGUI::IPlugin
|
||||||
{
|
{
|
||||||
/*! Get the name of the plugin.
|
/*! Get the name of the plugin.
|
||||||
@ -30,6 +35,11 @@ namespace MyGUI
|
|||||||
/*! Perform the final plugin uninstallation sequence
|
/*! Perform the final plugin uninstallation sequence
|
||||||
*/
|
*/
|
||||||
virtual void uninstall();
|
virtual void uninstall();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void registerResources();
|
||||||
|
void registerWidgets();
|
||||||
|
void createTransparentBGTexture();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#include "plugin.hpp"
|
#include "plugin.hpp"
|
||||||
#include "MyGUI_PluginManager.h"
|
#include "MyGUI_PluginManager.h"
|
||||||
|
|
||||||
MyGUI::ResourcePlugin* plugin_item = nullptr;
|
MyGUIPlugin::ResourcePlugin* plugin_item = nullptr;
|
||||||
|
|
||||||
extern "C" MYGUI_EXPORT_DLL void dllStartPlugin(void)
|
extern "C" MYGUI_EXPORT_DLL void dllStartPlugin(void)
|
||||||
{
|
{
|
||||||
plugin_item = new MyGUI::ResourcePlugin();
|
plugin_item = new MyGUIPlugin::ResourcePlugin();
|
||||||
MyGUI::PluginManager::getInstance().installPlugin(plugin_item);
|
MyGUI::PluginManager::getInstance().installPlugin(plugin_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user