working menu transparency slider

actorid
scrawl 13 years ago
parent 972c035e97
commit 656a8f1be9

@ -1,5 +1,13 @@
#include "settingswindow.hpp"
#include <OgreRoot.h>
#include <OgreRenderSystem.h>
#include <components/settings/settings.hpp>
#include "../mwbase/environment.hpp"
#include "../mwworld/world.hpp"
#include "window_manager.hpp"
namespace MWGui
@ -8,18 +16,48 @@ namespace MWGui
WindowBase("openmw_settings_window_layout.xml", parWindowManager)
{
getWidget(mOkButton, "OkButton");
getWidget(mResolutionList, "ResolutionList");
getWidget(mMenuTransparencySlider, "MenuTransparencySlider");
getWidget(mViewDistanceSlider, "ViewDistanceSlider");
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked);
mMenuTransparencySlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
mViewDistanceSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
center();
int okSize = mOkButton->getTextSize().width + 24;
mOkButton->setCoord(mMainWidget->getWidth()-16-okSize, mOkButton->getTop(),
okSize, mOkButton->getHeight());
// fill resolution list
Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem();
const Ogre::StringVector& videoModes = rs->getConfigOptions()["Video Mode"].possibleValues;
for (Ogre::StringVector::const_iterator it=videoModes.begin();
it!=videoModes.end(); ++it)
{
mResolutionList->addItem(*it);
}
// read settings
int menu_transparency = (mMenuTransparencySlider->getScrollRange()-1) * Settings::Manager::getFloat("menu transparency", "GUI");
mMenuTransparencySlider->setScrollPosition(menu_transparency);
onSliderChangePosition(mMenuTransparencySlider, menu_transparency);
}
void SettingsWindow::onOkButtonClicked(MyGUI::Widget* _sender)
{
mWindowManager.setGuiMode(GM_Game);
}
void SettingsWindow::onSliderChangePosition(MyGUI::ScrollBar* scroller, size_t pos)
{
float val = pos / float(scroller->getScrollRange()-1);
if (scroller == mMenuTransparencySlider)
{
Settings::Manager::setFloat("menu transparency", "GUI", val);
}
MWBase::Environment::get().getWorld()->processChangedSettings(Settings::Manager::apply());
}
}

@ -17,8 +17,12 @@ namespace MWGui
protected:
MyGUI::Button* mOkButton;
MyGUI::ListBox* mResolutionList;
MyGUI::ScrollBar* mMenuTransparencySlider;
MyGUI::ScrollBar* mViewDistanceSlider;
void onOkButtonClicked(MyGUI::Widget* _sender);
void onSliderChangePosition(MyGUI::ScrollBar* scroller, size_t pos);
};
}

@ -114,6 +114,8 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
mDebugging = new Debugging(mMwRoot, engine);
mLocalMap = new MWRender::LocalMap(&mRendering, this);
setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI"));
}
RenderingManager::~RenderingManager ()
@ -563,4 +565,26 @@ Compositors* RenderingManager::getCompositors()
return mCompositors;
}
void RenderingManager::processChangedSettings(const Settings::CategorySettingVector& settings)
{
for (Settings::CategorySettingVector::const_iterator it=settings.begin();
it != settings.end(); ++it)
{
if (it->second == "menu transparency" && it->first == "GUI")
{
setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI"));
}
}
}
void RenderingManager::setMenuTransparency(float val)
{
Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().getByName("transparent.png");
std::vector<Ogre::uint32> buffer;
buffer.resize(1);
buffer[0] = (int(255*val) << 24);
memcpy(tex->getBuffer()->lock(Ogre::HardwareBuffer::HBL_DISCARD), &buffer[0], 1*4);
tex->getBuffer()->unlock();
}
} // namespace

@ -13,6 +13,8 @@
#include <openengine/ogre/fader.hpp>
#include <openengine/bullet/physic.hpp>
#include <components/settings/settings.hpp>
#include <vector>
#include <string>
@ -157,10 +159,14 @@ class RenderingManager: private RenderingInterface {
///< transform the specified bounding box (in world coordinates) into screen coordinates.
/// @return packed vector4 (min_x, min_y, max_x, max_y)
void processChangedSettings(const Settings::CategorySettingVector& settings);
private:
void setAmbientMode();
void setMenuTransparency(float val);
bool mSunEnabled;
SkyManager* mSkyManager;

@ -1024,4 +1024,9 @@ namespace MWWorld
mWorldScene->insertObject(object, cell);
}
void World::processChangedSettings(const Settings::CategorySettingVector& settings)
{
mRendering->processChangedSettings(settings);
}
}

@ -7,6 +7,7 @@
#include <boost/filesystem.hpp>
#include <components/esm_store/cell_store.hpp>
#include <components/settings/settings.hpp>
#include "../mwrender/debugging.hpp"
#include "../mwrender/renderingmanager.hpp"
@ -279,6 +280,8 @@ namespace MWWorld
bool canPlaceObject(float cursorX, float cursorY);
///< @return true if it is possible to place on object at specified cursor location
void processChangedSettings(const Settings::CategorySettingVector& settings);
};
}

@ -60,7 +60,6 @@ configure_file("${SDIR}/openmw_trade_window_layout.xml" "${DDIR}/openmw_trade_wi
configure_file("${SDIR}/openmw_settings_window_layout.xml" "${DDIR}/openmw_settings_window_layout.xml" COPYONLY)
configure_file("${SDIR}/atlas1.cfg" "${DDIR}/atlas1.cfg" COPYONLY)
configure_file("${SDIR}/smallbars.png" "${DDIR}/smallbars.png" COPYONLY)
configure_file("${SDIR}/transparent.png" "${DDIR}/transparent.png" COPYONLY)
configure_file("${SDIR}/EBGaramond-Regular.ttf" "${DDIR}/EBGaramond-Regular.ttf" COPYONLY)
configure_file("${SDIR}/Obliviontt.zip" "${DDIR}/Obliviontt.zip" COPYONLY)
configure_file("${SDIR}/VeraMono.ttf" "${DDIR}/VeraMono.ttf" COPYONLY)

@ -151,6 +151,28 @@
<Property key="TrackRangeMargins" value = "14 14" />
<Property key="MinTrackSize" value = "14" />
<Property key="VerticalAlignment" value="false"/>
<Property key="MoveToClick" value="true"/>
<!-- Background widget trick that must go first to be placed behind Track and FirstPart/SecondPart widgets, provides the bar texture -->
<Child type="Button" skin="MW_HScrollBackground" offset = "14 0 62 14" align = "ALIGN_STRETCH" name = "Background"/>
<Child type="Button" skin="MW_ScrollLeft" offset = "0 0 14 14" align = "ALIGN_LEFT ALIGN_VSTRETCH" name = "Start"/>
<Child type="Button" skin="MW_ScrollRight" offset = "76 0 14 14" align = "ALIGN_RIGHT ALIGN_VSTRETCH" name = "End"/>
<!-- These are only provided to get mouse input, they should have no skin and be transparent -->
<Child type="Button" skin="MW_ScrollEmptyPart" offset = "14 0 24 14" align = "ALIGN_TOP ALIGN_HSTRETCH" name = "FirstPart"/>
<Child type="Button" skin="MW_ScrollEmptyPart" offset = "52 0 24 14" align = "ALIGN_TOP ALIGN_HSTRETCH" name = "SecondPart"/>
<!-- Tracker must be last to be on top and receive mouse events -->
<Child type="Button" skin="MW_ScrollTrackH" offset = "38 0 14 14" align = "ALIGN_LEFT ALIGN_VSTRETCH" name = "Track"/>
</Skin>
<!-- Morrowind has a 1 pixel gap between the left arrow and the inner bar, this skin does not replicate that -->
<Skin name = "MW_HSlider" size = "90 14">
<Property key="TrackRangeMargins" value = "14 14" />
<Property key="MinTrackSize" value = "14" />
<Property key="VerticalAlignment" value="false"/>
<Property key="MoveToClick" value="true"/>
<!-- Background widget trick that must go first to be placed behind Track and FirstPart/SecondPart widgets, provides the bar texture -->
<Child type="Button" skin="MW_HScrollBackground" offset = "14 0 62 14" align = "ALIGN_STRETCH" name = "Background"/>
@ -170,6 +192,7 @@
<Skin name = "MW_VScroll" size = "14 90">
<Property key="TrackRangeMargins" value = "14 14" />
<Property key="MinTrackSize" value = "14" />
<Property key="MoveToClick" value="true"/>
<!-- Background widget trick that must go first to be placed behind Track and FirstPart/SecondPart widgets, provides the bar texture -->
<Child type="Button" skin="MW_VScrollBackground" offset = "0 14 14 62" align = "ALIGN_STRETCH" name = "Background"/>

@ -130,7 +130,7 @@
<Widget type="Widget" skin="" position="5 5 89 60" name="Root">
<UserString key="ButtonSkin" value="MW_Button"/>
<Widget type="Widget" skin="MW_Box" position="0 24 89 36" align="Left Top Stretch">
<Widget type="Widget" skin="PanelEmpty" position="4 4 81 28" align="Left Top Stretch" name="TabItem"/>
<Widget type="Widget" skin="" position="4 4 81 28" align="Left Top Stretch" name="TabItem"/>
</Widget>
<Widget type="Widget" skin="" position="0 0 89 23" align="HStretch Top" name="HeaderPlace">
<Widget type="Widget" skin="" position="52 0 37 23" name="Controls">

@ -6,17 +6,52 @@
<Widget type="TabControl" skin="TabControl" position="8 8 368 340" align="Left Top" name="SettingsTab">
<Property key="ButtonAutoWidth" value="true"/>
<Widget type="TabItem" skin="" position="2 24 300 300">
<Widget type="TabItem" skin="" position="4 28 360 312">
<Property key="Caption" value=" #{sPrefs} "/>
<Widget type="TextBox" skin="NormalText" position="4 10 352 18" align="Left Top">
<Property key="Caption" value="#{sTransparency_Menu}"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HSlider" position="4 34 352 18" align="Left Top" name="MenuTransparencySlider">
<Property key="Range" value="1000000"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="4 58 352 18" align="Left Top">
<Property key="Caption" value="#{sFull}"/>
<Property key="TextAlign" value="Left"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="4 58 352 18" align="Left Top">
<Property key="Caption" value="#{sNone}"/>
<Property key="TextAlign" value="Right"/>
</Widget>
</Widget>
<Widget type="TabItem" skin="" position="2 24 300 300">
<Widget type="TabItem" skin="" position="4 28 360 312">
<Property key="Caption" value=" #{sAudio} "/>
</Widget>
<Widget type="TabItem" skin="" position="2 24 300 300">
<Widget type="TabItem" skin="" position="4 28 360 312">
<Property key="Caption" value=" #{sControls} "/>
</Widget>
<Widget type="TabItem" skin="" position="2 24 300 300">
<Widget type="TabItem" skin="" position="4 28 360 312">
<Property key="Caption" value=" #{sVideo} "/>
<Widget type="ListBox" skin="MW_List" position="4 4 200 110" align="Left Top" name="ResolutionList"/>
<Widget type="Button" skin="MW_Button" position="212 4 120 24" align="Left Top" name="ApplyResolutionButton">
<Property key="Caption" value="Apply"/>
</Widget>
<Widget type="TextBox" skin="NormalText" position="4 130 352 18" align="Left Top">
<Property key="Caption" value="#{sRender_Distance}"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HSlider" position="4 154 352 18" align="Left Top" name="ViewDistanceSlider">
<Property key="Range" value="1000000"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="4 178 352 18" align="Left Top">
<Property key="Caption" value="#{sNear}"/>
<Property key="TextAlign" value="Left"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="4 178 352 18" align="Left Top">
<Property key="Caption" value="#{sFar}"/>
<Property key="TextAlign" value="Right"/>
</Widget>
</Widget>
</Widget>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 B

@ -24,6 +24,10 @@ antialiasing = none
vsync = false
[GUI]
# 1 is fully opaque
menu transparency = 0.84
[General]
# Camera field of view
field of view = 55

@ -5,6 +5,9 @@
#include "OgreRenderWindow.h"
#include "OgreLogManager.h"
#include "OgreLog.h"
#include "OgreTextureManager.h"
#include "OgreTexture.h"
#include "OgreHardwarePixelBuffer.h"
#include <assert.h>
@ -107,6 +110,18 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings&
params.insert(std::make_pair("vsync", settings.vsync ? "true" : "false"));
mWindow = mRoot->createRenderWindow(title, settings.window_x, settings.window_y, settings.fullscreen, &params);
// create the semi-transparent black background texture used by the GUI.
// has to be created in code with TU_DYNAMIC_WRITE_ONLY_DISCARDABLE param
// so that it can be modified at runtime.
mTransparentBGTexture = Ogre::TextureManager::getSingleton().createManual(
"transparent.png",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D,
1, 1,
0,
Ogre::PF_A8R8G8B8,
Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
}
void OgreRenderer::createScene(const std::string camName, float fov, float nearClip)

@ -24,6 +24,8 @@
# include "OgreD3D9Plugin.h"
#endif
#include "OgreTexture.h"
namespace Ogre
{
class Root;
@ -71,6 +73,8 @@ namespace OEngine
Fader* mFader;
bool logging;
Ogre::TexturePtr mTransparentBGTexture;
public:
OgreRenderer()
: mRoot(NULL)

Loading…
Cancel
Save