mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-04 20:49:44 +00:00
Merge remote branch 'scrawl/cursor_replace'
This commit is contained in:
commit
477237d60a
11 changed files with 148 additions and 19 deletions
|
@ -97,6 +97,7 @@ set(OENGINE_OGRE
|
||||||
${LIBDIR}/openengine/ogre/renderer.cpp
|
${LIBDIR}/openengine/ogre/renderer.cpp
|
||||||
${LIBDIR}/openengine/ogre/mouselook.cpp
|
${LIBDIR}/openengine/ogre/mouselook.cpp
|
||||||
${LIBDIR}/openengine/ogre/fader.cpp
|
${LIBDIR}/openengine/ogre/fader.cpp
|
||||||
|
${LIBDIR}/openengine/ogre/imagerotate.cpp
|
||||||
)
|
)
|
||||||
set(OENGINE_GUI
|
set(OENGINE_GUI
|
||||||
${LIBDIR}/openengine/gui/events.cpp
|
${LIBDIR}/openengine/gui/events.cpp
|
||||||
|
|
|
@ -25,7 +25,7 @@ add_openmw_dir (mwinput
|
||||||
add_openmw_dir (mwgui
|
add_openmw_dir (mwgui
|
||||||
layouts text_input widgets race class birth review window_manager console dialogue
|
layouts text_input widgets race class birth review window_manager console dialogue
|
||||||
dialogue_history window_base stats_window messagebox journalwindow charactercreation
|
dialogue_history window_base stats_window messagebox journalwindow charactercreation
|
||||||
map_window window_pinnable_base
|
map_window window_pinnable_base cursorreplace
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwdialogue
|
add_openmw_dir (mwdialogue
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "mwinput/inputmanager.hpp"
|
#include "mwinput/inputmanager.hpp"
|
||||||
|
|
||||||
#include "mwgui/window_manager.hpp"
|
#include "mwgui/window_manager.hpp"
|
||||||
|
#include "mwgui/cursorreplace.hpp"
|
||||||
|
|
||||||
#include "mwscript/scriptmanager.hpp"
|
#include "mwscript/scriptmanager.hpp"
|
||||||
#include "mwscript/compilercontext.hpp"
|
#include "mwscript/compilercontext.hpp"
|
||||||
|
@ -368,6 +369,9 @@ void OMW::Engine::go()
|
||||||
|
|
||||||
loadBSA();
|
loadBSA();
|
||||||
|
|
||||||
|
// cursor replacer (converts the cursor from the bsa so they can be used by mygui)
|
||||||
|
MWGui::CursorReplace replacer;
|
||||||
|
|
||||||
// Create the world
|
// Create the world
|
||||||
mEnvironment.mWorld = new MWWorld::World (*mOgre, mFileCollections, mMaster,
|
mEnvironment.mWorld = new MWWorld::World (*mOgre, mFileCollections, mMaster,
|
||||||
mResDir, mNewGame, mEnvironment, mEncoding, mFallbackMap);
|
mResDir, mNewGame, mEnvironment, mEncoding, mFallbackMap);
|
||||||
|
|
16
apps/openmw/mwgui/cursorreplace.cpp
Normal file
16
apps/openmw/mwgui/cursorreplace.cpp
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#include "cursorreplace.hpp"
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
#include <openengine/ogre/imagerotate.hpp>
|
||||||
|
|
||||||
|
#include <OgreResourceGroupManager.h>
|
||||||
|
#include <OgreRoot.h>
|
||||||
|
|
||||||
|
using namespace MWGui;
|
||||||
|
|
||||||
|
CursorReplace::CursorReplace()
|
||||||
|
{
|
||||||
|
OEngine::Render::ImageRotate::rotate("textures\\tx_cursormove.dds", "mwpointer_vresize.png", 90);
|
||||||
|
OEngine::Render::ImageRotate::rotate("textures\\tx_cursormove.dds", "mwpointer_dresize1.png", -45);
|
||||||
|
OEngine::Render::ImageRotate::rotate("textures\\tx_cursormove.dds", "mwpointer_dresize2.png", 45);
|
||||||
|
}
|
16
apps/openmw/mwgui/cursorreplace.hpp
Normal file
16
apps/openmw/mwgui/cursorreplace.hpp
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef GAME_CURSORREPLACE_H
|
||||||
|
#define GAME_CURSORREPLACE_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace MWGui
|
||||||
|
{
|
||||||
|
/// \brief MyGUI does not support rotating cursors, so we have to do it manually
|
||||||
|
class CursorReplace
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CursorReplace();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -8,7 +8,6 @@ configure_file("${SDIR}/bigbars.png" "${DDIR}/bigbars.png" COPYONLY)
|
||||||
configure_file("${SDIR}/black.png" "${DDIR}/black.png" COPYONLY)
|
configure_file("${SDIR}/black.png" "${DDIR}/black.png" COPYONLY)
|
||||||
configure_file("${SDIR}/core.skin" "${DDIR}/core.skin" COPYONLY)
|
configure_file("${SDIR}/core.skin" "${DDIR}/core.skin" COPYONLY)
|
||||||
configure_file("${SDIR}/core.xml" "${DDIR}/core.xml" COPYONLY)
|
configure_file("${SDIR}/core.xml" "${DDIR}/core.xml" COPYONLY)
|
||||||
configure_file("${SDIR}/mwpointer.png" "${DDIR}/mwpointer.png" COPYONLY)
|
|
||||||
configure_file("${SDIR}/mwgui.png" "${DDIR}/mwgui.png" COPYONLY)
|
configure_file("${SDIR}/mwgui.png" "${DDIR}/mwgui.png" COPYONLY)
|
||||||
configure_file("${SDIR}/openmw_images.xml" "${DDIR}/openmw_images.xml" COPYONLY)
|
configure_file("${SDIR}/openmw_images.xml" "${DDIR}/openmw_images.xml" COPYONLY)
|
||||||
configure_file("${SDIR}/openmw_settings.xml" "${DDIR}/openmw_settings.xml" COPYONLY)
|
configure_file("${SDIR}/openmw_settings.xml" "${DDIR}/openmw_settings.xml" COPYONLY)
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.7 KiB |
|
@ -2,37 +2,37 @@
|
||||||
|
|
||||||
<MyGUI type="Resource">
|
<MyGUI type="Resource">
|
||||||
<Resource type="ResourceImageSet" name="ArrowPointerImage">
|
<Resource type="ResourceImageSet" name="ArrowPointerImage">
|
||||||
<Group name="Pointer" texture="mwpointer.png" size="32 32">
|
<Group name="Pointer" texture="textures\tx_cursor.dds" size="32 32">
|
||||||
<Index name="Pointer" >
|
<Index name="Pointer" >
|
||||||
<Frame point="0 0"/>
|
<Frame point="0 0"/>
|
||||||
</Index>
|
</Index>
|
||||||
</Group>
|
</Group>
|
||||||
</Resource>
|
</Resource>
|
||||||
<Resource type="ResourceImageSet" name="HResizePointerImage">
|
<Resource type="ResourceImageSet" name="HResizePointerImage">
|
||||||
<Group name="Pointer" texture="mwpointer.png" size="32 32">
|
<Group name="Pointer" texture="textures\tx_cursormove.dds" size="32 32">
|
||||||
<Index name="Pointer" >
|
<Index name="Pointer" >
|
||||||
<Frame point="32 0"/>
|
<Frame point="0 0"/>
|
||||||
</Index>
|
</Index>
|
||||||
</Group>
|
</Group>
|
||||||
</Resource>
|
</Resource>
|
||||||
<Resource type="ResourceImageSet" name="VResizePointerImage">
|
<Resource type="ResourceImageSet" name="VResizePointerImage">
|
||||||
<Group name="Pointer" texture="mwpointer.png" size="32 32">
|
<Group name="Pointer" texture="mwpointer_vresize.png" size="32 32">
|
||||||
<Index name="Pointer" >
|
<Index name="Pointer" >
|
||||||
<Frame point="0 32"/>
|
<Frame point="0 0"/>
|
||||||
</Index>
|
</Index>
|
||||||
</Group>
|
</Group>
|
||||||
</Resource>
|
</Resource>
|
||||||
<Resource type="ResourceImageSet" name="DResizePointerImage">
|
<Resource type="ResourceImageSet" name="DResizePointerImage">
|
||||||
<Group name="Pointer" texture="mwpointer.png" size="32 32">
|
<Group name="Pointer" texture="mwpointer_dresize1.png" size="32 32">
|
||||||
<Index name="Pointer" >
|
<Index name="Pointer" >
|
||||||
<Frame point="32 32"/>
|
<Frame point="o o"/>
|
||||||
</Index>
|
</Index>
|
||||||
</Group>
|
</Group>
|
||||||
</Resource>
|
</Resource>
|
||||||
<Resource type="ResourceImageSet" name="DResize2PointerImage">
|
<Resource type="ResourceImageSet" name="DResize2PointerImage">
|
||||||
<Group name="Pointer" texture="mwpointer.png" size="32 32">
|
<Group name="Pointer" texture="mwpointer_dresize2.png" size="32 32">
|
||||||
<Index name="Pointer" >
|
<Index name="Pointer" >
|
||||||
<Frame point="64 32"/>
|
<Frame point="0 0"/>
|
||||||
</Index>
|
</Index>
|
||||||
</Group>
|
</Group>
|
||||||
</Resource>
|
</Resource>
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<MyGUI type="Resource" version="1.1">
|
|
||||||
<Resource type="ResourceSkin" name="Skin name 0" size="32 32" texture="">
|
|
||||||
<BasisSkin type="SubSkin" offset="0 0 32 32" align="Stretch">
|
|
||||||
<State name="normal" offset="0 0 32 32"/>
|
|
||||||
</BasisSkin>
|
|
||||||
</Resource>
|
|
||||||
</MyGUI>
|
|
74
libs/openengine/ogre/imagerotate.cpp
Normal file
74
libs/openengine/ogre/imagerotate.cpp
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
#include "imagerotate.hpp"
|
||||||
|
|
||||||
|
#include <OgreRoot.h>
|
||||||
|
#include <OgreSceneManager.h>
|
||||||
|
#include <OgreImage.h>
|
||||||
|
#include <OgreTexture.h>
|
||||||
|
#include <OgreRenderTarget.h>
|
||||||
|
#include <OgreCamera.h>
|
||||||
|
#include <OgreTextureUnitState.h>
|
||||||
|
#include <OgreHardwarePixelBuffer.h>
|
||||||
|
|
||||||
|
using namespace Ogre;
|
||||||
|
using namespace OEngine::Render;
|
||||||
|
|
||||||
|
void ImageRotate::rotate(const std::string& sourceImage, const std::string& destImage, const float angle)
|
||||||
|
{
|
||||||
|
Root* root = Ogre::Root::getSingletonPtr();
|
||||||
|
|
||||||
|
SceneManager* sceneMgr = root->createSceneManager(ST_GENERIC);
|
||||||
|
Camera* camera = sceneMgr->createCamera("ImageRotateCamera");
|
||||||
|
|
||||||
|
MaterialPtr material = MaterialManager::getSingleton().create("ImageRotateMaterial", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
|
||||||
|
material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
|
||||||
|
material->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
|
||||||
|
TextureUnitState* tus = material->getTechnique(0)->getPass(0)->createTextureUnitState(sourceImage);
|
||||||
|
Degree deg(angle);
|
||||||
|
tus->setTextureRotate(Radian(deg.valueRadians()));
|
||||||
|
tus->setTextureAddressingMode(TextureUnitState::TAM_BORDER);
|
||||||
|
tus->setTextureBorderColour(ColourValue(0, 0, 0, 0));
|
||||||
|
|
||||||
|
Rectangle2D* rect = new Rectangle2D(true);
|
||||||
|
rect->setCorners(-1.0, 1.0, 1.0, -1.0);
|
||||||
|
rect->setMaterial("ImageRotateMaterial");
|
||||||
|
// Render the background before everything else
|
||||||
|
rect->setRenderQueueGroup(RENDER_QUEUE_BACKGROUND);
|
||||||
|
|
||||||
|
// Use infinite AAB to always stay visible
|
||||||
|
AxisAlignedBox aabInf;
|
||||||
|
aabInf.setInfinite();
|
||||||
|
rect->setBoundingBox(aabInf);
|
||||||
|
|
||||||
|
// Attach background to the scene
|
||||||
|
SceneNode* node = sceneMgr->getRootSceneNode()->createChildSceneNode();
|
||||||
|
node->attachObject(rect);
|
||||||
|
|
||||||
|
// retrieve image width and height
|
||||||
|
TexturePtr sourceTexture = TextureManager::getSingleton().getByName(sourceImage);
|
||||||
|
unsigned int width = sourceTexture->getWidth();
|
||||||
|
unsigned int height = sourceTexture->getHeight();
|
||||||
|
|
||||||
|
TexturePtr destTexture = TextureManager::getSingleton().createManual(
|
||||||
|
destImage,
|
||||||
|
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
||||||
|
TEX_TYPE_2D,
|
||||||
|
width, height,
|
||||||
|
0,
|
||||||
|
PF_A8R8G8B8,
|
||||||
|
TU_RENDERTARGET);
|
||||||
|
|
||||||
|
RenderTarget* rtt = destTexture->getBuffer()->getRenderTarget();
|
||||||
|
rtt->setAutoUpdated(false);
|
||||||
|
Viewport* vp = rtt->addViewport(camera);
|
||||||
|
vp->setOverlaysEnabled(false);
|
||||||
|
vp->setShadowsEnabled(false);
|
||||||
|
vp->setBackgroundColour(ColourValue(0,0,0,0));
|
||||||
|
vp->setClearEveryFrame(true, FBT_DEPTH);
|
||||||
|
|
||||||
|
rtt->update();
|
||||||
|
|
||||||
|
// remove all the junk we've created
|
||||||
|
MaterialManager::getSingleton().remove("ImageRotateMaterial");
|
||||||
|
root->destroySceneManager(sceneMgr);
|
||||||
|
delete rect;
|
||||||
|
}
|
27
libs/openengine/ogre/imagerotate.hpp
Normal file
27
libs/openengine/ogre/imagerotate.hpp
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef OENGINE_OGRE_IMAGEROTATE_HPP
|
||||||
|
#define OENGINE_OGRE_IMAGEROTATE_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace OEngine
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
|
||||||
|
/// Rotate an image by certain degrees and save as file, uses the GPU
|
||||||
|
/// Make sure Ogre Root is initialised before calling
|
||||||
|
class ImageRotate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @param source image (file name - has to exist in an resource group)
|
||||||
|
* @param name of the destination texture to save to (in memory)
|
||||||
|
* @param angle in degrees to turn
|
||||||
|
*/
|
||||||
|
static void rotate(const std::string& sourceImage, const std::string& destImage, const float angle);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue