Bind functions for minimum ambient light
This commit is contained in:
parent
f851bb7777
commit
5fed08b17e
|
@ -521,6 +521,7 @@ void OTClient::registerLuaFunctions()
|
|||
g_lua.bindClassMemberFunction<UIMap>("setAnimated", &UIMap::setAnimated);
|
||||
g_lua.bindClassMemberFunction<UIMap>("setKeepAspectRatio", &UIMap::setKeepAspectRatio);
|
||||
g_lua.bindClassMemberFunction<UIMap>("setMapShader", &UIMap::setMapShader);
|
||||
g_lua.bindClassMemberFunction<UIMap>("setMinimumAmbientLight", &UIMap::setMinimumAmbientLight);
|
||||
g_lua.bindClassMemberFunction<UIMap>("isMultifloor", &UIMap::isMultifloor);
|
||||
g_lua.bindClassMemberFunction<UIMap>("isAutoViewModeEnabled", &UIMap::isAutoViewModeEnabled);
|
||||
g_lua.bindClassMemberFunction<UIMap>("isDrawingTexts", &UIMap::isDrawingTexts);
|
||||
|
@ -539,6 +540,7 @@ void OTClient::registerLuaFunctions()
|
|||
g_lua.bindClassMemberFunction<UIMap>("getMaxZoomOut", &UIMap::getMaxZoomOut);
|
||||
g_lua.bindClassMemberFunction<UIMap>("getZoom", &UIMap::getZoom);
|
||||
g_lua.bindClassMemberFunction<UIMap>("getMapShader", &UIMap::getMapShader);
|
||||
g_lua.bindClassMemberFunction<UIMap>("getMinimumAmbientLight", &UIMap::getMinimumAmbientLight);
|
||||
|
||||
g_lua.registerClass<UIProgressRect, UIWidget>();
|
||||
g_lua.bindClassStaticFunction<UIProgressRect>("create", []{ return UIProgressRectPtr(new UIProgressRect); } );
|
||||
|
|
|
@ -57,6 +57,7 @@ MapView::MapView()
|
|||
m_cachedFirstVisibleFloor = 7;
|
||||
m_cachedLastVisibleFloor = 7;
|
||||
m_updateTilesPos = 0;
|
||||
m_minimumAmbientLight = 0;
|
||||
m_optimizedSize = Size(Otc::AWARE_X_TILES, Otc::AWARE_Y_TILES) * Otc::TILE_PIXELS;
|
||||
|
||||
m_framebuffer = g_framebuffers.createFrameBuffer();
|
||||
|
@ -102,14 +103,15 @@ void MapView::draw(const Rect& rect)
|
|||
m_lightView->reset();
|
||||
m_lightView->resize(m_framebuffer->getSize());
|
||||
|
||||
if(cameraPosition.z <= 7)
|
||||
m_lightView->setGlobalLight(g_map.getLight());
|
||||
else {
|
||||
Light undergroundLight;
|
||||
undergroundLight.color = 215;
|
||||
undergroundLight.intensity = 16;
|
||||
m_lightView->setGlobalLight(undergroundLight);
|
||||
Light ambientLight;
|
||||
if(cameraPosition.z <= 7) {
|
||||
ambientLight = g_map.getLight();
|
||||
} else {
|
||||
ambientLight.color = 215;
|
||||
ambientLight.intensity = 0;
|
||||
}
|
||||
ambientLight.intensity = std::max<int>(m_minimumAmbientLight*255, ambientLight.intensity);
|
||||
m_lightView->setGlobalLight(ambientLight);
|
||||
}
|
||||
}
|
||||
g_painter->setColor(Color::white);
|
||||
|
|
|
@ -88,6 +88,9 @@ public:
|
|||
void setCameraPosition(const Position& pos);
|
||||
Position getCameraPosition();
|
||||
|
||||
void setMinimumAmbientLight(float intensity) { m_minimumAmbientLight = intensity; }
|
||||
float getMinimumAmbientLight() { return m_minimumAmbientLight; }
|
||||
|
||||
// drawing related
|
||||
void setDrawFlags(Otc::DrawFlags drawFlags) { m_drawFlags = drawFlags; requestVisibleTilesCacheUpdate(); }
|
||||
Otc::DrawFlags getDrawFlags() { return m_drawFlags; }
|
||||
|
@ -149,6 +152,7 @@ private:
|
|||
Otc::DrawFlags m_drawFlags;
|
||||
std::vector<Point> m_spiral;
|
||||
LightViewPtr m_lightView;
|
||||
float m_minimumAmbientLight;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
void setAnimated(bool enable) { m_mapView->setAnimated(enable); }
|
||||
void setKeepAspectRatio(bool enable);
|
||||
void setMapShader(const PainterShaderProgramPtr& shader) { m_mapView->setShader(shader); }
|
||||
void setMinimumAmbientLight(float intensity) { m_mapView->setMinimumAmbientLight(intensity); }
|
||||
|
||||
bool isMultifloor() { return m_mapView->isMultifloor(); }
|
||||
bool isAutoViewModeEnabled() { return m_mapView->isAutoViewModeEnabled(); }
|
||||
|
@ -76,6 +77,7 @@ public:
|
|||
int getMaxZoomOut() { return m_maxZoomOut; }
|
||||
int getZoom() { return m_zoom; }
|
||||
PainterShaderProgramPtr getMapShader() { return m_mapView->getShader(); }
|
||||
float getMinimumAmbientLight() { return m_mapView->getMinimumAmbientLight(); }
|
||||
|
||||
protected:
|
||||
virtual void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode);
|
||||
|
|
Loading…
Reference in New Issue