Merge remote-tracking branch 'origin/master' into refactor_networking
This commit is contained in:
commit
4aea491ed0
@ -16,7 +16,6 @@ if (NOT CMAKE_BUILD_TYPE)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(USE_WIIUSE "Support for wiimote input devices" ON)
|
option(USE_WIIUSE "Support for wiimote input devices" ON)
|
||||||
option(USE_FREETYPE "Use Freetype to render text" ON)
|
|
||||||
option(USE_FRIBIDI "Support for right-to-left languages" ON)
|
option(USE_FRIBIDI "Support for right-to-left languages" ON)
|
||||||
option(CHECK_ASSETS "Check if assets are installed in ../stk-assets" ON)
|
option(CHECK_ASSETS "Check if assets are installed in ../stk-assets" ON)
|
||||||
option(USE_SYSTEM_ANGELSCRIPT "Use system angelscript instead of built-in angelscript. If you enable this option, make sure to use a compatible version." OFF)
|
option(USE_SYSTEM_ANGELSCRIPT "Use system angelscript instead of built-in angelscript. If you enable this option, make sure to use a compatible version." OFF)
|
||||||
@ -166,14 +165,12 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Freetype
|
# Freetype
|
||||||
if(USE_FREETYPE)
|
|
||||||
find_package(Freetype)
|
find_package(Freetype)
|
||||||
if(FREETYPE_FOUND)
|
if(FREETYPE_FOUND)
|
||||||
include_directories(${FREETYPE_INCLUDE_DIRS})
|
include_directories(${FREETYPE_INCLUDE_DIRS})
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Freetype not found. "
|
message(FATAL_ERROR "Freetype not found. "
|
||||||
"Either install freetype or disable freetype rendering support with -DUSE_FREETYPE=0 ")
|
"Freetype is required to display characters in SuperTuxKart. ")
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Fribidi
|
# Fribidi
|
||||||
@ -351,7 +348,7 @@ target_link_libraries(supertuxkart
|
|||||||
${OGGVORBIS_LIBRARIES}
|
${OGGVORBIS_LIBRARIES}
|
||||||
${OPENAL_LIBRARY}
|
${OPENAL_LIBRARY}
|
||||||
${OPENGL_LIBRARIES}
|
${OPENGL_LIBRARIES}
|
||||||
${FREETPYE_LIBRARIES}
|
${FREETYPE_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
@ -381,11 +378,6 @@ if(USE_FRIBIDI)
|
|||||||
add_definitions(-DENABLE_BIDI)
|
add_definitions(-DENABLE_BIDI)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_FREETYPE)
|
|
||||||
target_link_libraries(supertuxkart ${FREETYPE_LIBRARIES})
|
|
||||||
add_definitions(-DENABLE_FREETYPE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Wiiuse
|
# Wiiuse
|
||||||
# ------
|
# ------
|
||||||
if(USE_WIIUSE)
|
if(USE_WIIUSE)
|
||||||
|
@ -11,15 +11,15 @@
|
|||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
find_path(FREETYPE_INCLUDE_DIRS NAMES freetype/freetype.h PATHS "${PROJECT_SOURCE_DIR}/dependencies/include")
|
find_path(FREETYPE_INCLUDE_DIRS NAMES freetype/freetype.h PATHS "${PROJECT_SOURCE_DIR}/dependencies/include")
|
||||||
find_library(FREETPYE_LIBRARY NAMES freetype PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib")
|
find_library(FREETYPE_LIBRARY NAMES freetype PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib")
|
||||||
set(FREETYPE_FOUND 1)
|
set(FREETYPE_FOUND 1)
|
||||||
set(FREETPYE_LIBRARIES ${FREETPYE_LIBRARY})
|
set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY})
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
find_path(FREETYPE_INCLUDE_DIRS NAMES freetype/freetype.h PATHS "/Library/Frameworks/FreeType.Framework/Versions/2.4/unix/include")
|
find_path(FREETYPE_INCLUDE_DIRS NAMES freetype/freetype.h PATHS "/Library/Frameworks/FreeType.Framework/Versions/2.4/unix/include")
|
||||||
find_library(FREETPYE_LIBRARY NAMES freetype PATHS "/Library/Frameworks/FreeType.Framework/Versions/2.4/")
|
find_library(FREETYPE_LIBRARY NAMES freetype PATHS "/Library/Frameworks/FreeType.Framework/Versions/2.4/")
|
||||||
include_directories(/Library/Frameworks/FreeType.Framework/Versions/2.4/unix/include)
|
include_directories(/Library/Frameworks/FreeType.Framework/Versions/2.4/unix/include)
|
||||||
set(FREETYPE_FOUND 1)
|
set(FREETYPE_FOUND 1)
|
||||||
set(FREETPYE_LIBRARIES ${FREETPYE_LIBRARY})
|
set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY})
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
include(FindPkgConfig)
|
include(FindPkgConfig)
|
||||||
pkg_check_modules(FREETYPE freetype2)
|
pkg_check_modules(FREETYPE freetype2)
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<stkgui>
|
|
||||||
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
|
|
||||||
|
|
||||||
<div x="5%" y="2%" width="90%" height="96%" layout="vertical-row" >
|
|
||||||
|
|
||||||
<header I18N="Title for challenges screen" text="Challenges - Trophy Room" text_align="center" align="center" width="80%" />
|
|
||||||
|
|
||||||
<spacer height="5" width="100%"/>
|
|
||||||
|
|
||||||
<box width="100%" proportion="5" layout="vertical-row">
|
|
||||||
|
|
||||||
<ribbon_grid id="challenges" proportion="8" width="100%"
|
|
||||||
label_location="bottom" align="center" child_width="128" child_height="128" />
|
|
||||||
|
|
||||||
|
|
||||||
<spacer proportion="1" width="100%"/>
|
|
||||||
</box>
|
|
||||||
</div>
|
|
||||||
</stkgui>
|
|
@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<stkgui>
|
|
||||||
<div x="2%" y="10%" width="96%" height="80%" layout="vertical-row" >
|
|
||||||
|
|
||||||
<label id="title" width="100%" text_align="center" word_wrap="true"
|
|
||||||
I18N="In the 'add new player' dialog" text="Enter the new player's name" proportion="1" />
|
|
||||||
|
|
||||||
<spacer height="25" width="10" />
|
|
||||||
|
|
||||||
<textbox id="textfield" width="75%" I18N="In the 'add new player' dialog" align="center"/>
|
|
||||||
|
|
||||||
<spacer height="20" width="20" />
|
|
||||||
|
|
||||||
<buttonbar proportion="1" id="options" width="100%" height="100%">
|
|
||||||
<button id="ok" I18N="In the 'add new player' dialog" text="OK" align="center"/>
|
|
||||||
<button id="cancel" I18N="In the 'add new player' dialog" text="Cancel" align="center"/>
|
|
||||||
</buttonbar>
|
|
||||||
<spacer height="15" width="20" />
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</stkgui>
|
|
7
data/shaders/lightning.frag
Normal file
7
data/shaders/lightning.frag
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
uniform vec3 intensity;
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
FragColor = vec4(intensity, 1.0f);
|
||||||
|
}
|
@ -818,6 +818,24 @@ public:
|
|||||||
} // render
|
} // render
|
||||||
}; // SunLightShader
|
}; // SunLightShader
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
class LightningShader : public TextureShader<LightningShader, 1,
|
||||||
|
core::vector3df>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LightningShader()
|
||||||
|
{
|
||||||
|
loadProgram(OBJECT, GL_VERTEX_SHADER, "screenquad.vert",
|
||||||
|
GL_FRAGMENT_SHADER, "lightning.frag");
|
||||||
|
assignUniforms("intensity");
|
||||||
|
} // LightningShader
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
void render(core::vector3df intensity)
|
||||||
|
{
|
||||||
|
drawFullScreenEffect(intensity);
|
||||||
|
} // render
|
||||||
|
}; // LightningShader
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
PostProcessing::PostProcessing(IVideoDriver* video_driver)
|
PostProcessing::PostProcessing(IVideoDriver* video_driver)
|
||||||
@ -1408,6 +1426,18 @@ void PostProcessing::applyMLAA()
|
|||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
} // applyMLAA
|
} // applyMLAA
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void PostProcessing::renderLightning(core::vector3df intensity)
|
||||||
|
{
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_ONE, GL_ONE);
|
||||||
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
|
|
||||||
|
LightningShader::getInstance()->render(intensity);
|
||||||
|
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Render the post-processed scene */
|
/** Render the post-processed scene */
|
||||||
FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode,
|
FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode,
|
||||||
|
@ -105,6 +105,7 @@ public:
|
|||||||
void renderMotionBlur(unsigned cam, const FrameBuffer &in_fbo,
|
void renderMotionBlur(unsigned cam, const FrameBuffer &in_fbo,
|
||||||
FrameBuffer &out_fbo);
|
FrameBuffer &out_fbo);
|
||||||
void renderGlow(unsigned tex);
|
void renderGlow(unsigned tex);
|
||||||
|
void renderLightning(core::vector3df intensity);
|
||||||
|
|
||||||
/** Render the post-processed scene */
|
/** Render the post-processed scene */
|
||||||
FrameBuffer *render(scene::ICameraSceneNode * const camnode, bool isRace);
|
FrameBuffer *render(scene::ICameraSceneNode * const camnode, bool isRace);
|
||||||
|
@ -67,11 +67,7 @@ scene::IMesh* STKTextBillboard::getTextMesh(core::stringw text, gui::ScalableFon
|
|||||||
font->doDraw(text, core::rect<s32>(0, 0, size.Width, size.Height), video::SColor(255,255,255,255),
|
font->doDraw(text, core::rect<s32>(0, 0, size.Width, size.Height), video::SColor(255,255,255,255),
|
||||||
false, false, NULL, this);
|
false, false, NULL, this);
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
const float scale = 0.03f;
|
||||||
const float scale = 0.03f; //Larger for ttf font as they are less bold
|
|
||||||
#else
|
|
||||||
const float scale = 0.018f;
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
//scene::SMesh* mesh = new scene::SMesh();
|
//scene::SMesh* mesh = new scene::SMesh();
|
||||||
std::map<video::ITexture*, scene::SMeshBuffer*> buffers;
|
std::map<video::ITexture*, scene::SMeshBuffer*> buffers;
|
||||||
|
@ -688,10 +688,8 @@ namespace GUIEngine
|
|||||||
{
|
{
|
||||||
IGUIEnvironment* g_env;
|
IGUIEnvironment* g_env;
|
||||||
Skin* g_skin = NULL;
|
Skin* g_skin = NULL;
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
FTEnvironment* g_ft_env = NULL;
|
FTEnvironment* g_ft_env = NULL;
|
||||||
GlyphPageCreator* g_gp_creator = NULL;
|
GlyphPageCreator* g_gp_creator = NULL;
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
ScalableFont *g_font;
|
ScalableFont *g_font;
|
||||||
ScalableFont *g_outline_font;
|
ScalableFont *g_outline_font;
|
||||||
ScalableFont *g_large_font;
|
ScalableFont *g_large_font;
|
||||||
@ -956,12 +954,10 @@ namespace GUIEngine
|
|||||||
//if (g_skin != NULL) delete g_skin;
|
//if (g_skin != NULL) delete g_skin;
|
||||||
g_skin = NULL;
|
g_skin = NULL;
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
g_ft_env->~FTEnvironment();
|
g_ft_env->~FTEnvironment();
|
||||||
g_ft_env = NULL;
|
g_ft_env = NULL;
|
||||||
g_gp_creator->~GlyphPageCreator();
|
g_gp_creator->~GlyphPageCreator();
|
||||||
g_gp_creator = NULL;
|
g_gp_creator = NULL;
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
for (unsigned int i=0; i<g_loaded_screens.size(); i++)
|
for (unsigned int i=0; i<g_loaded_screens.size(); i++)
|
||||||
{
|
{
|
||||||
@ -1031,10 +1027,8 @@ namespace GUIEngine
|
|||||||
g_focus_for_player[n] = NULL;
|
g_focus_for_player[n] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
g_ft_env = new FTEnvironment();
|
g_ft_env = new FTEnvironment();
|
||||||
g_gp_creator = new GlyphPageCreator();
|
g_gp_creator = new GlyphPageCreator();
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
To make the g_font a little bit nicer, we load an external g_font
|
To make the g_font a little bit nicer, we load an external g_font
|
||||||
@ -1069,10 +1063,6 @@ namespace GUIEngine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
float normal_text_scale = 1;
|
|
||||||
float title_text_scale = 1;
|
|
||||||
|
|
||||||
ScalableFont* digit_font =new ScalableFont(g_env,T_DIGIT);
|
ScalableFont* digit_font =new ScalableFont(g_env,T_DIGIT);
|
||||||
digit_font->setMonospaceDigits(true);
|
digit_font->setMonospaceDigits(true);
|
||||||
g_digit_font = digit_font;
|
g_digit_font = digit_font;
|
||||||
@ -1081,16 +1071,16 @@ namespace GUIEngine
|
|||||||
sfont2->setKerningWidth(0);
|
sfont2->setKerningWidth(0);
|
||||||
// Because the fallback font is much smaller than the title font:
|
// Because the fallback font is much smaller than the title font:
|
||||||
sfont2->m_fallback_font_scale = 2.0f;
|
sfont2->m_fallback_font_scale = 2.0f;
|
||||||
sfont2->m_fallback_kerning_width = 5;
|
sfont2->m_fallback_kerning_width = 0;
|
||||||
|
|
||||||
ScalableFont* sfont =new ScalableFont(g_env,T_NORMAL);
|
ScalableFont* sfont =new ScalableFont(g_env,T_NORMAL);
|
||||||
sfont->setKerningHeight(0);
|
sfont->setKerningHeight(0);
|
||||||
sfont->setScale(normal_text_scale);
|
sfont->setScale(1);
|
||||||
g_font = sfont;
|
g_font = sfont;
|
||||||
Private::font_height = g_font->getDimension( L"X" ).Height;
|
Private::font_height = g_font->getDimension( L"X" ).Height;
|
||||||
|
|
||||||
ScalableFont* sfont_larger = sfont->getHollowCopy();
|
ScalableFont* sfont_larger = sfont->getHollowCopy();
|
||||||
sfont_larger->setScale(normal_text_scale*1.4f);
|
sfont_larger->setScale(1.4f);
|
||||||
sfont_larger->setKerningHeight(0);
|
sfont_larger->setKerningHeight(0);
|
||||||
g_large_font = sfont_larger;
|
g_large_font = sfont_larger;
|
||||||
|
|
||||||
@ -1100,7 +1090,7 @@ namespace GUIEngine
|
|||||||
Private::large_font_height = g_large_font->getDimension( L"X" ).Height;
|
Private::large_font_height = g_large_font->getDimension( L"X" ).Height;
|
||||||
|
|
||||||
ScalableFont* sfont_smaller = sfont->getHollowCopy();
|
ScalableFont* sfont_smaller = sfont->getHollowCopy();
|
||||||
sfont_smaller->setScale(normal_text_scale*0.8f);
|
sfont_smaller->setScale(0.8f);
|
||||||
sfont_smaller->setKerningHeight(0);
|
sfont_smaller->setKerningHeight(0);
|
||||||
g_small_font = sfont_smaller;
|
g_small_font = sfont_smaller;
|
||||||
|
|
||||||
@ -1108,83 +1098,11 @@ namespace GUIEngine
|
|||||||
g_small_font->getDimension( L"X" ).Height;
|
g_small_font->getDimension( L"X" ).Height;
|
||||||
|
|
||||||
sfont2->m_fallback_font = sfont;
|
sfont2->m_fallback_font = sfont;
|
||||||
sfont2->setScale(title_text_scale);
|
sfont2->setScale(1);
|
||||||
sfont2->m_black_border = true;
|
sfont2->m_black_border = true;
|
||||||
g_title_font = sfont2;
|
g_title_font = sfont2;
|
||||||
Private::title_font_height =
|
Private::title_font_height =
|
||||||
g_title_font->getDimension( L"X" ).Height;
|
g_title_font->getDimension( L"X" ).Height;
|
||||||
#else
|
|
||||||
// font size is resolution-dependent.
|
|
||||||
// normal text will range from 0.8, in 640x* resolutions (won't scale
|
|
||||||
// below that) to 1.0, in 1024x* resolutions, and linearly up
|
|
||||||
// normal text will range from 0.2, in 640x* resolutions (won't scale
|
|
||||||
// below that) to 0.4, in 1024x* resolutions, and linearly up
|
|
||||||
const int screen_width = irr_driver->getFrameSize().Width;
|
|
||||||
const int screen_height = irr_driver->getFrameSize().Height;
|
|
||||||
float scale = std::max(0, screen_width - 640)/564.0f;
|
|
||||||
|
|
||||||
// attempt to compensate for small screens
|
|
||||||
if (screen_width < 1200) scale = std::max(0, screen_width - 640) / 750.0f;
|
|
||||||
if (screen_width < 900 || screen_height < 700) scale = std::min(scale, 0.05f);
|
|
||||||
|
|
||||||
Log::info("GUIEngine", "scale: %f", scale);
|
|
||||||
|
|
||||||
float normal_text_scale = 0.7f + 0.2f*scale;
|
|
||||||
float title_text_scale = 0.2f + 0.2f*scale;
|
|
||||||
|
|
||||||
ScalableFont* sfont =
|
|
||||||
new ScalableFont(g_env,
|
|
||||||
file_manager->getAssetChecked(FileManager::FONT,
|
|
||||||
"StkFont.xml",true) );
|
|
||||||
sfont->setScale(normal_text_scale);
|
|
||||||
sfont->setKerningHeight(-5);
|
|
||||||
g_font = sfont;
|
|
||||||
|
|
||||||
ScalableFont* digit_font =
|
|
||||||
new ScalableFont(g_env,
|
|
||||||
file_manager->getAssetChecked(FileManager::FONT,
|
|
||||||
"BigDigitFont.xml",true));
|
|
||||||
digit_font->lazyLoadTexture(0); // make sure the texture is loaded for this one
|
|
||||||
digit_font->setMonospaceDigits(true);
|
|
||||||
g_digit_font = digit_font;
|
|
||||||
|
|
||||||
Private::font_height = g_font->getDimension( L"X" ).Height;
|
|
||||||
|
|
||||||
ScalableFont* sfont_larger = sfont->getHollowCopy();
|
|
||||||
sfont_larger->setScale(normal_text_scale*1.4f);
|
|
||||||
sfont_larger->setKerningHeight(-5);
|
|
||||||
g_large_font = sfont_larger;
|
|
||||||
|
|
||||||
g_outline_font = sfont->getHollowCopy();
|
|
||||||
g_outline_font->m_black_border = true;
|
|
||||||
|
|
||||||
Private::large_font_height = g_large_font->getDimension( L"X" ).Height;
|
|
||||||
|
|
||||||
ScalableFont* sfont_smaller = sfont->getHollowCopy();
|
|
||||||
sfont_smaller->setScale(normal_text_scale*0.8f);
|
|
||||||
sfont_smaller->setKerningHeight(-5);
|
|
||||||
g_small_font = sfont_smaller;
|
|
||||||
|
|
||||||
Private::small_font_height =
|
|
||||||
g_small_font->getDimension( L"X" ).Height;
|
|
||||||
|
|
||||||
|
|
||||||
ScalableFont* sfont2 =
|
|
||||||
new ScalableFont(g_env,
|
|
||||||
file_manager->getAssetChecked(FileManager::FONT,
|
|
||||||
"title_font.xml",
|
|
||||||
true) );
|
|
||||||
sfont2->m_fallback_font = sfont;
|
|
||||||
// Because the fallback font is much smaller than the title font:
|
|
||||||
sfont2->m_fallback_font_scale = 4.0f;
|
|
||||||
sfont2->m_fallback_kerning_width = 15;
|
|
||||||
sfont2->setScale(title_text_scale);
|
|
||||||
sfont2->setKerningWidth(-18);
|
|
||||||
sfont2->m_black_border = true;
|
|
||||||
g_title_font = sfont2;
|
|
||||||
Private::title_font_height =
|
|
||||||
g_title_font->getDimension( L"X" ).Height;
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
|
|
||||||
if (g_font != NULL) g_skin->setFont(g_font);
|
if (g_font != NULL) g_skin->setFont(g_font);
|
||||||
@ -1202,15 +1120,13 @@ namespace GUIEngine
|
|||||||
void reloadHollowCopyFont(irr::gui::ScalableFont* sfont)
|
void reloadHollowCopyFont(irr::gui::ScalableFont* sfont)
|
||||||
{
|
{
|
||||||
//Base on the init function above
|
//Base on the init function above
|
||||||
float normal_text_scale = 1;
|
sfont->setScale(1);
|
||||||
|
sfont->setKerningHeight(0);
|
||||||
sfont->setScale(normal_text_scale);
|
|
||||||
sfont->setKerningHeight(-5);
|
|
||||||
Private::font_height = sfont->getDimension( L"X" ).Height;
|
Private::font_height = sfont->getDimension( L"X" ).Height;
|
||||||
|
|
||||||
ScalableFont* sfont_larger = sfont->getHollowCopy();
|
ScalableFont* sfont_larger = sfont->getHollowCopy();
|
||||||
sfont_larger->setScale(normal_text_scale*1.4f);
|
sfont_larger->setScale(1.4f);
|
||||||
sfont_larger->setKerningHeight(-5);
|
sfont_larger->setKerningHeight(0);
|
||||||
g_large_font = sfont_larger;
|
g_large_font = sfont_larger;
|
||||||
|
|
||||||
g_outline_font = sfont->getHollowCopy();
|
g_outline_font = sfont->getHollowCopy();
|
||||||
@ -1219,8 +1135,8 @@ namespace GUIEngine
|
|||||||
Private::large_font_height = g_large_font->getDimension( L"X" ).Height;
|
Private::large_font_height = g_large_font->getDimension( L"X" ).Height;
|
||||||
|
|
||||||
ScalableFont* sfont_smaller = sfont->getHollowCopy();
|
ScalableFont* sfont_smaller = sfont->getHollowCopy();
|
||||||
sfont_smaller->setScale(normal_text_scale*0.8f);
|
sfont_smaller->setScale(0.8f);
|
||||||
sfont_smaller->setKerningHeight(-5);
|
sfont_smaller->setKerningHeight(0);
|
||||||
g_small_font = sfont_smaller;
|
g_small_font = sfont_smaller;
|
||||||
|
|
||||||
Private::small_font_height = g_small_font->getDimension( L"X" ).Height;
|
Private::small_font_height = g_small_font->getDimension( L"X" ).Height;
|
||||||
|
@ -39,10 +39,8 @@ namespace irr
|
|||||||
#include "utils/constants.hpp"
|
#include "utils/constants.hpp"
|
||||||
#include "utils/ptr_vector.hpp"
|
#include "utils/ptr_vector.hpp"
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
#include "guiengine/ft_environment.hpp"
|
#include "guiengine/ft_environment.hpp"
|
||||||
#include "guiengine/glyph_page_creator.hpp"
|
#include "guiengine/glyph_page_creator.hpp"
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \ingroup guiengine
|
* \ingroup guiengine
|
||||||
@ -86,10 +84,8 @@ namespace GUIEngine
|
|||||||
{
|
{
|
||||||
extern irr::gui::IGUIEnvironment* g_env;
|
extern irr::gui::IGUIEnvironment* g_env;
|
||||||
extern Skin* g_skin;
|
extern Skin* g_skin;
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
extern FTEnvironment* g_ft_env;
|
extern FTEnvironment* g_ft_env;
|
||||||
extern GlyphPageCreator* g_gp_creator;
|
extern GlyphPageCreator* g_gp_creator;
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
extern irr::gui::ScalableFont* g_small_font;
|
extern irr::gui::ScalableFont* g_small_font;
|
||||||
extern irr::gui::ScalableFont* g_font;
|
extern irr::gui::ScalableFont* g_font;
|
||||||
extern irr::gui::ScalableFont* g_outline_font;
|
extern irr::gui::ScalableFont* g_outline_font;
|
||||||
@ -181,7 +177,6 @@ namespace GUIEngine
|
|||||||
*/
|
*/
|
||||||
inline Skin* getSkin() { return Private::g_skin; }
|
inline Skin* getSkin() { return Private::g_skin; }
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
/**
|
/**
|
||||||
* \pre GUIEngine::init must have been called first
|
* \pre GUIEngine::init must have been called first
|
||||||
* \return the freetype and library with face
|
* \return the freetype and library with face
|
||||||
@ -193,7 +188,6 @@ namespace GUIEngine
|
|||||||
* \return the glyph page creator, useful to create a glyph page from individual char
|
* \return the glyph page creator, useful to create a glyph page from individual char
|
||||||
*/
|
*/
|
||||||
inline GlyphPageCreator* getGlyphPageCreator() { return Private::g_gp_creator; }
|
inline GlyphPageCreator* getGlyphPageCreator() { return Private::g_gp_creator; }
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
Screen* getScreenNamed(const char* name);
|
Screen* getScreenNamed(const char* name);
|
||||||
|
|
||||||
@ -271,13 +265,11 @@ namespace GUIEngine
|
|||||||
*/
|
*/
|
||||||
void reloadSkin();
|
void reloadSkin();
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
/**
|
/**
|
||||||
* \brief call when translation in user config was updated for freetype rendering STK
|
* \brief call when translation in user config was updated for freetype rendering STK
|
||||||
*/
|
*/
|
||||||
void cleanHollowCopyFont();
|
void cleanHollowCopyFont();
|
||||||
void reloadHollowCopyFont(irr::gui::ScalableFont*);
|
void reloadHollowCopyFont(irr::gui::ScalableFont*);
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
#include "guiengine/ft_environment.hpp"
|
#include "guiengine/ft_environment.hpp"
|
||||||
#include "guiengine/get_font_properties.hpp"
|
#include "guiengine/get_font_properties.hpp"
|
||||||
#include "io/file_manager.hpp"
|
#include "io/file_manager.hpp"
|
||||||
@ -98,4 +97,3 @@ FT_Library FTEnvironment::ft_lib = NULL;
|
|||||||
FT_Error FTEnvironment::ft_err = 0;
|
FT_Error FTEnvironment::ft_err = 0;
|
||||||
|
|
||||||
} // guiengine
|
} // guiengine
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include "guiengine/get_font_properties.hpp"
|
#include "guiengine/get_font_properties.hpp"
|
||||||
#include FT_FREETYPE_H
|
#include FT_FREETYPE_H
|
||||||
|
|
||||||
|
#include "utils/leak_check.hpp"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \ingroup guiengine
|
* \ingroup guiengine
|
||||||
*/
|
*/
|
||||||
@ -30,6 +32,9 @@ namespace GUIEngine
|
|||||||
class FTEnvironment
|
class FTEnvironment
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
LEAK_CHECK()
|
||||||
|
|
||||||
FTEnvironment();
|
FTEnvironment();
|
||||||
~FTEnvironment();
|
~FTEnvironment();
|
||||||
FT_Face ft_face[irr::gui::F_COUNT];
|
FT_Face ft_face[irr::gui::F_COUNT];
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
//
|
//
|
||||||
// http://irrlicht.suckerfreegames.com/
|
// http://irrlicht.suckerfreegames.com/
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
#include <irrlicht.h>
|
#include <irrlicht.h>
|
||||||
#include "guiengine/engine.hpp"
|
#include "guiengine/engine.hpp"
|
||||||
|
|
||||||
@ -151,9 +150,4 @@ bool GlyphPageCreator::insertGlyph(FT_Bitmap bits, core::rect<s32>& rect)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GlyphPageCreator::used_width = 0;
|
|
||||||
u32 GlyphPageCreator::used_height = 0;
|
|
||||||
u32 GlyphPageCreator::temp_height = 0;
|
|
||||||
|
|
||||||
} // guiengine
|
} // guiengine
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include FT_FREETYPE_H
|
#include FT_FREETYPE_H
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
#include "utils/leak_check.hpp"
|
||||||
|
|
||||||
using namespace irr;
|
using namespace irr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,6 +36,9 @@ namespace GUIEngine
|
|||||||
class GlyphPageCreator
|
class GlyphPageCreator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
LEAK_CHECK()
|
||||||
|
|
||||||
GlyphPageCreator();
|
GlyphPageCreator();
|
||||||
~GlyphPageCreator();
|
~GlyphPageCreator();
|
||||||
|
|
||||||
@ -51,7 +56,7 @@ namespace GUIEngine
|
|||||||
|
|
||||||
/** Reset position of glyph on the current glyph page.
|
/** Reset position of glyph on the current glyph page.
|
||||||
*/
|
*/
|
||||||
static void clearGlyphPage();
|
void clearGlyphPage();
|
||||||
|
|
||||||
/** Clear (fill it with transparent content) the current glyph page.
|
/** Clear (fill it with transparent content) the current glyph page.
|
||||||
*/
|
*/
|
||||||
@ -87,9 +92,9 @@ namespace GUIEngine
|
|||||||
*/
|
*/
|
||||||
video::IImage* page;
|
video::IImage* page;
|
||||||
|
|
||||||
static u32 temp_height;
|
u32 temp_height;
|
||||||
static u32 used_width;
|
u32 used_width;
|
||||||
static u32 used_height;
|
u32 used_height;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // guiengine
|
} // guiengine
|
||||||
|
@ -26,7 +26,6 @@ namespace gui
|
|||||||
{
|
{
|
||||||
|
|
||||||
//! constructor
|
//! constructor
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
ScalableFont::ScalableFont(IGUIEnvironment *env, TTFLoadingType type)
|
ScalableFont::ScalableFont(IGUIEnvironment *env, TTFLoadingType type)
|
||||||
: Driver(0), SpriteBank(0), Environment(env), WrongCharacter(0),
|
: Driver(0), SpriteBank(0), Environment(env), WrongCharacter(0),
|
||||||
MaxHeight(0), GlobalKerningWidth(0), GlobalKerningHeight(0)
|
MaxHeight(0), GlobalKerningWidth(0), GlobalKerningHeight(0)
|
||||||
@ -90,51 +89,6 @@ void ScalableFont::recreateFromLanguage()
|
|||||||
Log::fatal("ScalableFont", "Recreation of TTF font failed");
|
Log::fatal("ScalableFont", "Recreation of TTF font failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
ScalableFont::ScalableFont(IGUIEnvironment *env, const std::string &filename)
|
|
||||||
: Driver(0), SpriteBank(0), Environment(env), WrongCharacter(0),
|
|
||||||
MaxHeight(0), GlobalKerningWidth(0), GlobalKerningHeight(0)
|
|
||||||
{
|
|
||||||
#ifdef _DEBUG
|
|
||||||
setDebugName("ScalableFont");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_fallback_font = NULL;
|
|
||||||
m_fallback_kerning_width = 0;
|
|
||||||
m_fallback_font_scale = 1.0f;
|
|
||||||
m_scale = 1.0f;
|
|
||||||
m_is_hollow_copy = false;
|
|
||||||
m_black_border = false;
|
|
||||||
m_shadow = false;
|
|
||||||
m_mono_space_digits = false;
|
|
||||||
m_rtl = translations->isRTLLanguage();
|
|
||||||
|
|
||||||
if (Environment)
|
|
||||||
{
|
|
||||||
// don't grab environment, to avoid circular references
|
|
||||||
Driver = Environment->getVideoDriver();
|
|
||||||
|
|
||||||
SpriteBank = Environment->addEmptySpriteBank(io::path(filename.c_str()));
|
|
||||||
if (SpriteBank)
|
|
||||||
SpriteBank->grab();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Driver)
|
|
||||||
Driver->grab();
|
|
||||||
|
|
||||||
setInvisibleCharacters ( L" " );
|
|
||||||
|
|
||||||
io::IXMLReader* reader = file_manager->createXMLReader(filename.c_str());
|
|
||||||
if (!load( reader ))
|
|
||||||
{
|
|
||||||
Log::fatal("ScalableFont", "Loading font failed");
|
|
||||||
}
|
|
||||||
reader->drop();
|
|
||||||
|
|
||||||
assert(Areas.size() > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
//! destructor
|
//! destructor
|
||||||
ScalableFont::~ScalableFont()
|
ScalableFont::~ScalableFont()
|
||||||
@ -157,204 +111,6 @@ void ScalableFont::setShadow(const irr::video::SColor &col)
|
|||||||
m_shadow_color = col;
|
m_shadow_color = col;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef ENABLE_FREETYPE
|
|
||||||
void ScalableFont::doReadXmlFile(io::IXMLReader* xml)
|
|
||||||
{
|
|
||||||
int trim_top = 0;
|
|
||||||
int trim_bottom = 0;
|
|
||||||
|
|
||||||
while (xml->read())
|
|
||||||
{
|
|
||||||
if (io::EXN_ELEMENT == xml->getNodeType())
|
|
||||||
{
|
|
||||||
if (core::stringw(L"include") == xml->getNodeName())
|
|
||||||
{
|
|
||||||
core::stringc filename = xml->getAttributeValue(L"file");
|
|
||||||
/*
|
|
||||||
const wchar_t* iflangis = xml->getAttributeValue(L"iflanguage");
|
|
||||||
|
|
||||||
Log::info("ScalableFont", "langcode = %s", translations->getCurrentLanguageCode().c_str());
|
|
||||||
|
|
||||||
if (iflangis != NULL &&
|
|
||||||
core::stringc(iflangis) != translations->getCurrentLanguageCode().c_str())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
io::IXMLReader* included = file_manager->createXMLReader(
|
|
||||||
file_manager->getAsset(FileManager::FONT, filename.c_str()));
|
|
||||||
if (included != NULL)
|
|
||||||
{
|
|
||||||
doReadXmlFile(included);
|
|
||||||
included->drop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (core::stringw(L"Texture") == xml->getNodeName())
|
|
||||||
{
|
|
||||||
// add a texture
|
|
||||||
core::stringc filename = xml->getAttributeValue(L"filename");
|
|
||||||
core::stringc fn = file_manager->getAsset(FileManager::FONT,
|
|
||||||
filename.c_str()).c_str();
|
|
||||||
u32 i = (u32)xml->getAttributeValueAsInt(L"index");
|
|
||||||
|
|
||||||
float scale=1.0f;
|
|
||||||
if(xml->getAttributeValue(L"scale"))
|
|
||||||
{
|
|
||||||
scale = xml->getAttributeValueAsFloat(L"scale");
|
|
||||||
//Log::info("ScalableFont", "scale = %f", scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool excludeFromMaxHeightCalculation = false;
|
|
||||||
if (xml->getAttributeValue(L"excludeFromMaxHeightCalculation"))
|
|
||||||
excludeFromMaxHeightCalculation = (core::stringc(xml->getAttributeValue(L"excludeFromMaxHeightCalculation")) == "true");
|
|
||||||
|
|
||||||
core::stringw alpha = xml->getAttributeValue(L"hasAlpha");
|
|
||||||
|
|
||||||
//Log::info("ScalableFont", "Adding font texture %s; alpha = %s", fn.c_str(), alpha.c_str());
|
|
||||||
|
|
||||||
|
|
||||||
// make sure the sprite bank has enough textures in it
|
|
||||||
while (i+1 > SpriteBank->getTextureCount())
|
|
||||||
{
|
|
||||||
SpriteBank->addTexture(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
TextureInfo info;
|
|
||||||
info.m_file_name = fn;
|
|
||||||
info.m_has_alpha = (alpha == core::stringw("true"));
|
|
||||||
info.m_scale = scale;
|
|
||||||
info.m_exclude_from_max_height_calculation = excludeFromMaxHeightCalculation;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
if (m_texture_files.find(i) != m_texture_files.end())
|
|
||||||
{
|
|
||||||
Log::warn("ScalableFont", "Font conflict, two images have texture %i.", i);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_texture_files[i] = info;
|
|
||||||
}
|
|
||||||
else if (core::stringw(L"font") == xml->getNodeName())
|
|
||||||
{
|
|
||||||
trim_top = (u32)xml->getAttributeValueAsInt(L"trim_top"); // returns 0 if no such attribute
|
|
||||||
trim_bottom = (u32)xml->getAttributeValueAsInt(L"trim_bottom");
|
|
||||||
}
|
|
||||||
else if (core::stringw(L"c") == xml->getNodeName())
|
|
||||||
{
|
|
||||||
// adding a character to this font
|
|
||||||
SFontArea a;
|
|
||||||
SGUISpriteFrame f;
|
|
||||||
SGUISprite s;
|
|
||||||
core::rect<s32> rectangle;
|
|
||||||
|
|
||||||
a.underhang = xml->getAttributeValueAsInt(L"u");
|
|
||||||
a.overhang = xml->getAttributeValueAsInt(L"o");
|
|
||||||
a.spriteno = SpriteBank->getSprites().size();
|
|
||||||
s32 texno = xml->getAttributeValueAsInt(L"i");
|
|
||||||
|
|
||||||
// parse rectangle
|
|
||||||
core::stringc rectstr = xml->getAttributeValue(L"r");
|
|
||||||
wchar_t ch = xml->getAttributeValue(L"c")[0];
|
|
||||||
|
|
||||||
const c8 *c = rectstr.c_str();
|
|
||||||
s32 val;
|
|
||||||
val = 0;
|
|
||||||
while (*c >= '0' && *c <= '9')
|
|
||||||
{
|
|
||||||
val *= 10;
|
|
||||||
val += *c - '0';
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
rectangle.UpperLeftCorner.X = val;
|
|
||||||
while (*c == L' ' || *c == L',') c++;
|
|
||||||
|
|
||||||
val = 0;
|
|
||||||
while (*c >= '0' && *c <= '9')
|
|
||||||
{
|
|
||||||
val *= 10;
|
|
||||||
val += *c - '0';
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
rectangle.UpperLeftCorner.Y = val + trim_top;
|
|
||||||
while (*c == L' ' || *c == L',') c++;
|
|
||||||
|
|
||||||
val = 0;
|
|
||||||
while (*c >= '0' && *c <= '9')
|
|
||||||
{
|
|
||||||
val *= 10;
|
|
||||||
val += *c - '0';
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
rectangle.LowerRightCorner.X = val;
|
|
||||||
while (*c == L' ' || *c == L',') c++;
|
|
||||||
|
|
||||||
val = 0;
|
|
||||||
while (*c >= '0' && *c <= '9')
|
|
||||||
{
|
|
||||||
val *= 10;
|
|
||||||
val += *c - '0';
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
rectangle.LowerRightCorner.Y = val - trim_bottom;
|
|
||||||
|
|
||||||
CharacterMap[ch] = Areas.size();
|
|
||||||
|
|
||||||
//Log::info("ScalableFont", "Inserting character '%d' with area %d", (int)ch, Areas.size());
|
|
||||||
|
|
||||||
// make frame
|
|
||||||
f.rectNumber = SpriteBank->getPositions().size();
|
|
||||||
f.textureNumber = texno;
|
|
||||||
|
|
||||||
// add frame to sprite
|
|
||||||
s.Frames.push_back(f);
|
|
||||||
s.frameTime = 0;
|
|
||||||
|
|
||||||
// add rectangle to sprite bank
|
|
||||||
SpriteBank->getPositions().push_back(rectangle);
|
|
||||||
a.width = rectangle.getWidth();
|
|
||||||
|
|
||||||
// add sprite to sprite bank
|
|
||||||
SpriteBank->getSprites().push_back(s);
|
|
||||||
|
|
||||||
// add character to font
|
|
||||||
Areas.push_back(a);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//! loads a font file from xml
|
|
||||||
bool ScalableFont::load(io::IXMLReader* xml)
|
|
||||||
{
|
|
||||||
if (!SpriteBank)
|
|
||||||
{
|
|
||||||
Log::error("ScalableFont::load", "SpriteBank is NULL!!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
doReadXmlFile(xml);
|
|
||||||
|
|
||||||
// set bad character
|
|
||||||
WrongCharacter = getAreaIDFromCharacter(L' ', NULL);
|
|
||||||
|
|
||||||
setMaxHeight();
|
|
||||||
|
|
||||||
for(wchar_t c='0'; c<='9'; c++)
|
|
||||||
{
|
|
||||||
SFontArea a = getAreaFromCharacter(c, NULL);
|
|
||||||
if(a.overhang > m_max_digit_area.overhang ) m_max_digit_area.overhang = a.overhang;
|
|
||||||
if(a.underhang > m_max_digit_area.underhang) m_max_digit_area.underhang = a.underhang;
|
|
||||||
if(a.width > m_max_digit_area.width ) m_max_digit_area.width = a.width;
|
|
||||||
}
|
|
||||||
m_max_digit_area.overhang = 0;m_max_digit_area.underhang=0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
//! loads a font from a TTF file
|
//! loads a font from a TTF file
|
||||||
bool ScalableFont::loadTTF()
|
bool ScalableFont::loadTTF()
|
||||||
{
|
{
|
||||||
@ -376,12 +132,12 @@ bool ScalableFont::loadTTF()
|
|||||||
m_dpi = cur_prop.size;
|
m_dpi = cur_prop.size;
|
||||||
|
|
||||||
std::vector <s32> offset;
|
std::vector <s32> offset;
|
||||||
std::vector <s32> bx;
|
std::vector <s32> bearingx;
|
||||||
std::vector <s32> advance;
|
std::vector <s32> advance;
|
||||||
std::vector <s32> height;
|
std::vector <s32> height;
|
||||||
|
|
||||||
std::set<wchar_t>::iterator it;
|
std::set<wchar_t>::iterator it;
|
||||||
s32 current_maxheight = 0;
|
s32 curr_maxheight = 0;
|
||||||
s32 t;
|
s32 t;
|
||||||
u32 texno = 0;
|
u32 texno = 0;
|
||||||
SpriteBank->addTexture(NULL);
|
SpriteBank->addTexture(NULL);
|
||||||
@ -437,22 +193,22 @@ bool ScalableFont::loadTTF()
|
|||||||
Log::error("ScalableFont::loadTTF", "Can't load a single glyph.");
|
Log::error("ScalableFont::loadTTF", "Can't load a single glyph.");
|
||||||
|
|
||||||
// Store vertical offset on line.
|
// Store vertical offset on line.
|
||||||
s32 offset_on_line = (curr_face->glyph->metrics.height >> 6) - curr_face->glyph->bitmap_top;
|
s32 curr_offset = (curr_face->glyph->metrics.height >> 6) - curr_face->glyph->bitmap_top;
|
||||||
offset.push_back(offset_on_line);
|
offset.push_back(curr_offset);
|
||||||
|
|
||||||
// This is to be used later.
|
// This is to be used later.
|
||||||
t = curr_face->glyph->metrics.height >> 6;
|
t = curr_face->glyph->metrics.height >> 6;
|
||||||
height.push_back(t);
|
height.push_back(t);
|
||||||
if (t > current_maxheight)
|
if (t > curr_maxheight)
|
||||||
current_maxheight = t;
|
curr_maxheight = t;
|
||||||
|
|
||||||
// Store horizontal padding (bearingX).
|
// Store horizontal padding (bearingX).
|
||||||
s32 bX = curr_face->glyph->bitmap_left;
|
s32 curr_bearingx = curr_face->glyph->bitmap_left;
|
||||||
bx.push_back(bX);
|
bearingx.push_back(curr_bearingx);
|
||||||
|
|
||||||
// Store total width on horizontal line.
|
// Store total width on horizontal line.
|
||||||
s32 width = curr_face->glyph->advance.x >> 6;
|
s32 curr_advance = curr_face->glyph->advance.x >> 6;
|
||||||
advance.push_back(width);
|
advance.push_back(curr_advance);
|
||||||
|
|
||||||
// Convert to an anti-aliased bitmap
|
// Convert to an anti-aliased bitmap
|
||||||
FT_Bitmap bits = slot->bitmap;
|
FT_Bitmap bits = slot->bitmap;
|
||||||
@ -538,7 +294,7 @@ bool ScalableFont::loadTTF()
|
|||||||
//Storing now
|
//Storing now
|
||||||
SFontArea a;
|
SFontArea a;
|
||||||
a.spriteno = n;
|
a.spriteno = n;
|
||||||
a.offsety = current_maxheight - height.at(n)
|
a.offsety = curr_maxheight - height.at(n)
|
||||||
+ offset.at(n); //Compute the correct offset as ttf texture image is cropped against the glyph fully.
|
+ offset.at(n); //Compute the correct offset as ttf texture image is cropped against the glyph fully.
|
||||||
|
|
||||||
a.offsety_bt = -offset.at(n); //FIXME
|
a.offsety_bt = -offset.at(n); //FIXME
|
||||||
@ -550,7 +306,7 @@ bool ScalableFont::loadTTF()
|
|||||||
if (!n) //Skip width-less characters
|
if (!n) //Skip width-less characters
|
||||||
a.bearingx = 0;
|
a.bearingx = 0;
|
||||||
else
|
else
|
||||||
a.bearingx = bx.at(n);
|
a.bearingx = bearingx.at(n);
|
||||||
if (!n) //Skip width-less characters
|
if (!n) //Skip width-less characters
|
||||||
a.width = 0;
|
a.width = 0;
|
||||||
else
|
else
|
||||||
@ -563,10 +319,10 @@ bool ScalableFont::loadTTF()
|
|||||||
|
|
||||||
//Reserve 10 for normal font new characters added, 40 for digit font to display separately
|
//Reserve 10 for normal font new characters added, 40 for digit font to display separately
|
||||||
//Consider fallback font (bold) too
|
//Consider fallback font (bold) too
|
||||||
MaxHeight = (int)((current_maxheight + (m_type == T_DIGIT ? 40 : 10) +
|
MaxHeight = (int)((curr_maxheight + (m_type == T_DIGIT ? 40 : 10) +
|
||||||
(m_type == T_BOLD ? 20 : 0))*m_scale);
|
(m_type == T_BOLD ? 20 : 0))*m_scale);
|
||||||
|
|
||||||
GlyphMaxHeight = current_maxheight;
|
GlyphMaxHeight = curr_maxheight;
|
||||||
|
|
||||||
for(wchar_t c='0'; c<='9'; c++)
|
for(wchar_t c='0'; c<='9'; c++)
|
||||||
{
|
{
|
||||||
@ -611,8 +367,8 @@ bool ScalableFont::lazyLoadChar()
|
|||||||
GUIEngine::GlyphPageCreator* gp_creator = GUIEngine::getGlyphPageCreator();
|
GUIEngine::GlyphPageCreator* gp_creator = GUIEngine::getGlyphPageCreator();
|
||||||
|
|
||||||
s32 height;
|
s32 height;
|
||||||
s32 bX;
|
s32 bearingx;
|
||||||
s32 offset_on_line;
|
s32 curr_offset;
|
||||||
s32 width;
|
s32 width;
|
||||||
u32 texno = SpriteBank->getTextureCount() - 1;
|
u32 texno = SpriteBank->getTextureCount() - 1;
|
||||||
std::set<wchar_t>::iterator it;
|
std::set<wchar_t>::iterator it;
|
||||||
@ -653,9 +409,9 @@ bool ScalableFont::lazyLoadChar()
|
|||||||
if (err)
|
if (err)
|
||||||
Log::error("ScalableFont::loadTTF", "Can't load a single glyph.");
|
Log::error("ScalableFont::loadTTF", "Can't load a single glyph.");
|
||||||
|
|
||||||
offset_on_line = (curr_face->glyph->metrics.height >> 6) - curr_face->glyph->bitmap_top;
|
curr_offset = (curr_face->glyph->metrics.height >> 6) - curr_face->glyph->bitmap_top;
|
||||||
height = curr_face->glyph->metrics.height >> 6;
|
height = curr_face->glyph->metrics.height >> 6;
|
||||||
bX = curr_face->glyph->bitmap_left;
|
bearingx = curr_face->glyph->bitmap_left;
|
||||||
width = curr_face->glyph->advance.x >> 6;
|
width = curr_face->glyph->advance.x >> 6;
|
||||||
FT_Bitmap bits = slot->bitmap;
|
FT_Bitmap bits = slot->bitmap;
|
||||||
CharacterMap[*it] = SpriteBank->getSprites().size();
|
CharacterMap[*it] = SpriteBank->getSprites().size();
|
||||||
@ -686,9 +442,9 @@ bool ScalableFont::lazyLoadChar()
|
|||||||
|
|
||||||
SFontArea a;
|
SFontArea a;
|
||||||
a.spriteno = SpriteBank->getSprites().size() - 1;
|
a.spriteno = SpriteBank->getSprites().size() - 1;
|
||||||
a.offsety = GlyphMaxHeight - height + offset_on_line;
|
a.offsety = GlyphMaxHeight - height + curr_offset;
|
||||||
a.offsety_bt = -offset_on_line;
|
a.offsety_bt = -curr_offset;
|
||||||
a.bearingx = bX;
|
a.bearingx = bearingx;
|
||||||
a.width = width;
|
a.width = width;
|
||||||
Areas.push_back(a);
|
Areas.push_back(a);
|
||||||
}
|
}
|
||||||
@ -729,42 +485,12 @@ void ScalableFont::forceNewPage()
|
|||||||
gp_creator->createNewGlyphPage();
|
gp_creator->createNewGlyphPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
void ScalableFont::setScale(const float scale)
|
void ScalableFont::setScale(const float scale)
|
||||||
{
|
{
|
||||||
m_scale = scale;
|
m_scale = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef ENABLE_FREETYPE
|
|
||||||
void ScalableFont::setMaxHeight()
|
|
||||||
{
|
|
||||||
MaxHeight = 0;
|
|
||||||
s32 t;
|
|
||||||
|
|
||||||
core::array< core::rect<s32> >& p = SpriteBank->getPositions();
|
|
||||||
core::array< SGUISprite >& sprites = SpriteBank->getSprites();
|
|
||||||
|
|
||||||
for (u32 i=0; i<p.size(); ++i)
|
|
||||||
{
|
|
||||||
t = p[i].getHeight();
|
|
||||||
|
|
||||||
// FIXME: consider fallback fonts
|
|
||||||
int texID = sprites[i].Frames[0].textureNumber;
|
|
||||||
|
|
||||||
const TextureInfo& info = (*(m_texture_files.find(texID))).second;
|
|
||||||
if (info.m_exclude_from_max_height_calculation) continue;
|
|
||||||
|
|
||||||
float char_scale = info.m_scale;
|
|
||||||
t = (int)(t*char_scale);
|
|
||||||
|
|
||||||
if (t>MaxHeight)
|
|
||||||
MaxHeight = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
MaxHeight = (int)(MaxHeight*m_scale);
|
|
||||||
}
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -780,18 +506,6 @@ s32 ScalableFont::getKerningWidth(const wchar_t* thisLetter, const wchar_t* prev
|
|||||||
{
|
{
|
||||||
s32 ret = GlobalKerningWidth;
|
s32 ret = GlobalKerningWidth;
|
||||||
|
|
||||||
#ifndef ENABLE_FREETYPE
|
|
||||||
if (thisLetter)
|
|
||||||
{
|
|
||||||
ret += Areas[getAreaIDFromCharacter(*thisLetter, NULL)].overhang;
|
|
||||||
|
|
||||||
if (previousLetter)
|
|
||||||
{
|
|
||||||
ret += Areas[getAreaIDFromCharacter(*previousLetter, NULL)].underhang;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -880,7 +594,6 @@ void ScalableFont::setInvisibleCharacters( const wchar_t *s )
|
|||||||
//! returns the dimension of text
|
//! returns the dimension of text
|
||||||
core::dimension2d<u32> ScalableFont::getDimension(const wchar_t* text) const
|
core::dimension2d<u32> ScalableFont::getDimension(const wchar_t* text) const
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
GUIEngine::GlyphPageCreator* gp_creator = GUIEngine::getGlyphPageCreator();
|
GUIEngine::GlyphPageCreator* gp_creator = GUIEngine::getGlyphPageCreator();
|
||||||
|
|
||||||
if (m_type == T_NORMAL || T_BOLD) //lazy load char
|
if (m_type == T_NORMAL || T_BOLD) //lazy load char
|
||||||
@ -901,7 +614,6 @@ core::dimension2d<u32> ScalableFont::getDimension(const wchar_t* text) const
|
|||||||
Log::error("ScalableFont::lazyLoadChar", "Can't insert new char into glyph pages.");
|
Log::error("ScalableFont::lazyLoadChar", "Can't insert new char into glyph pages.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
assert(Areas.size() > 0);
|
assert(Areas.size() > 0);
|
||||||
|
|
||||||
@ -925,10 +637,6 @@ core::dimension2d<u32> ScalableFont::getDimension(const wchar_t* text) const
|
|||||||
bool fallback = false;
|
bool fallback = false;
|
||||||
const SFontArea &area = getAreaFromCharacter(*p, &fallback);
|
const SFontArea &area = getAreaFromCharacter(*p, &fallback);
|
||||||
|
|
||||||
#ifndef ENABLE_FREETYPE
|
|
||||||
thisLine.Width += area.underhang;
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
thisLine.Width += getCharWidth(area, fallback);
|
thisLine.Width += getCharWidth(area, fallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1015,7 +723,6 @@ void ScalableFont::doDraw(const core::stringw& text,
|
|||||||
core::array<core::position2di> offsets(text_size);
|
core::array<core::position2di> offsets(text_size);
|
||||||
std::vector<bool> fallback(text_size);
|
std::vector<bool> fallback(text_size);
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
if (m_type == T_NORMAL || T_BOLD) //lazy load char, have to do this again
|
if (m_type == T_NORMAL || T_BOLD) //lazy load char, have to do this again
|
||||||
{ //because some text isn't drawn with getDimension
|
{ //because some text isn't drawn with getDimension
|
||||||
for (u32 i = 0; i<text_size; i++)
|
for (u32 i = 0; i<text_size; i++)
|
||||||
@ -1044,7 +751,6 @@ void ScalableFont::doDraw(const core::stringw& text,
|
|||||||
Log::error("ScalableFont::lazyLoadChar", "Can't insert new char into glyph pages.");
|
Log::error("ScalableFont::lazyLoadChar", "Can't insert new char into glyph pages.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
for (u32 i = 0; i<text_size; i++)
|
for (u32 i = 0; i<text_size; i++)
|
||||||
{
|
{
|
||||||
@ -1064,7 +770,6 @@ void ScalableFont::doDraw(const core::stringw& text,
|
|||||||
bool use_fallback_font = false;
|
bool use_fallback_font = false;
|
||||||
const SFontArea &area = getAreaFromCharacter(c, &use_fallback_font);
|
const SFontArea &area = getAreaFromCharacter(c, &use_fallback_font);
|
||||||
fallback[i] = use_fallback_font;
|
fallback[i] = use_fallback_font;
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
if (charCollector == NULL)
|
if (charCollector == NULL)
|
||||||
{
|
{
|
||||||
//floor is used to prevent negligible movement when m_scale changes with resolution
|
//floor is used to prevent negligible movement when m_scale changes with resolution
|
||||||
@ -1090,10 +795,6 @@ void ScalableFont::doDraw(const core::stringw& text,
|
|||||||
offset.X -= Hpadding;
|
offset.X -= Hpadding;
|
||||||
offset.Y -= Vpadding + floor(m_type == T_DIGIT ? 20*m_scale : 0);
|
offset.Y -= Vpadding + floor(m_type == T_DIGIT ? 20*m_scale : 0);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
offset.X += area.underhang;
|
|
||||||
offsets.push_back(offset);
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
// Invisible character. add something to the array anyway so that
|
// Invisible character. add something to the array anyway so that
|
||||||
// indices from the various arrays remain in sync
|
// indices from the various arrays remain in sync
|
||||||
indices.push_back( Invisible.findFirst(c) < 0 ? area.spriteno
|
indices.push_back( Invisible.findFirst(c) < 0 ? area.spriteno
|
||||||
@ -1119,6 +820,52 @@ void ScalableFont::doDraw(const core::stringw& text,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const int spriteAmount = sprites.size();
|
const int spriteAmount = sprites.size();
|
||||||
|
|
||||||
|
if (m_black_border && charCollector == NULL)
|
||||||
|
{ //Draw black border first, to make it behind the real character
|
||||||
|
//which make script language display better
|
||||||
|
video::SColor black(color.getAlpha(),0,0,0);
|
||||||
|
for (int n=0; n<indiceAmount; n++)
|
||||||
|
{
|
||||||
|
const int spriteID = indices[n];
|
||||||
|
if (!fallback[n] && (spriteID < 0 || spriteID >= spriteAmount)) continue;
|
||||||
|
if (indices[n] == -1) continue;
|
||||||
|
|
||||||
|
const int texID = (fallback[n] ?
|
||||||
|
(*fallback_sprites)[spriteID].Frames[0].textureNumber :
|
||||||
|
sprites[spriteID].Frames[0].textureNumber);
|
||||||
|
|
||||||
|
core::rect<s32> source = (fallback[n] ?
|
||||||
|
(*fallback_positions)[(*fallback_sprites)[spriteID].Frames[0].rectNumber] :
|
||||||
|
positions[sprites[spriteID].Frames[0].rectNumber]);
|
||||||
|
|
||||||
|
core::dimension2d<s32> size = source.getSize();
|
||||||
|
|
||||||
|
float scale = (fallback[n] ? m_scale*m_fallback_font_scale : m_scale);
|
||||||
|
size.Width = (int)(size.Width * scale);
|
||||||
|
size.Height = (int)(size.Height * scale);
|
||||||
|
|
||||||
|
core::rect<s32> dest(offsets[n], size);
|
||||||
|
|
||||||
|
video::ITexture* texture = (fallback[n] ?
|
||||||
|
m_fallback_font->SpriteBank->getTexture(texID) :
|
||||||
|
SpriteBank->getTexture(texID) );
|
||||||
|
|
||||||
|
for (int x_delta=-2; x_delta<=2; x_delta++)
|
||||||
|
{
|
||||||
|
for (int y_delta=-2; y_delta<=2; y_delta++)
|
||||||
|
{
|
||||||
|
if (x_delta == 0 || y_delta == 0) continue;
|
||||||
|
draw2DImage(texture,
|
||||||
|
dest + core::position2d<s32>(x_delta, y_delta),
|
||||||
|
source,
|
||||||
|
clip,
|
||||||
|
black, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int n=0; n<indiceAmount; n++)
|
for (int n=0; n<indiceAmount; n++)
|
||||||
{
|
{
|
||||||
const int spriteID = indices[n];
|
const int spriteID = indices[n];
|
||||||
@ -1135,30 +882,13 @@ void ScalableFont::doDraw(const core::stringw& text,
|
|||||||
(*fallback_positions)[(*fallback_sprites)[spriteID].Frames[0].rectNumber] :
|
(*fallback_positions)[(*fallback_sprites)[spriteID].Frames[0].rectNumber] :
|
||||||
positions[sprites[spriteID].Frames[0].rectNumber]);
|
positions[sprites[spriteID].Frames[0].rectNumber]);
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
float char_scale = 1.0f;
|
|
||||||
#else
|
|
||||||
const TextureInfo& info = (fallback[n] ?
|
|
||||||
(*(m_fallback_font->m_texture_files.find(texID))).second :
|
|
||||||
(*(m_texture_files.find(texID))).second
|
|
||||||
);
|
|
||||||
float char_scale = info.m_scale;
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
core::dimension2d<s32> size = source.getSize();
|
core::dimension2d<s32> size = source.getSize();
|
||||||
|
|
||||||
float scale = (fallback[n] ? m_scale*m_fallback_font_scale : m_scale);
|
float scale = (fallback[n] ? m_scale*m_fallback_font_scale : m_scale);
|
||||||
size.Width = (int)(size.Width * scale * char_scale);
|
size.Width = (int)(size.Width * scale);
|
||||||
size.Height = (int)(size.Height * scale * char_scale);
|
size.Height = (int)(size.Height * scale);
|
||||||
|
|
||||||
// align vertically if character is smaller
|
|
||||||
#ifndef ENABLE_FREETYPE
|
|
||||||
int y_shift = (size.Height < MaxHeight*m_scale ? (int)((MaxHeight*m_scale - size.Height)/2.0f) : 0);
|
|
||||||
|
|
||||||
core::rect<s32> dest(offsets[n] + core::position2di(0, y_shift), size);
|
|
||||||
#else
|
|
||||||
core::rect<s32> dest(offsets[n], size);
|
core::rect<s32> dest(offsets[n], size);
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
video::ITexture* texture = (fallback[n] ?
|
video::ITexture* texture = (fallback[n] ?
|
||||||
m_fallback_font->SpriteBank->getTexture(texID) :
|
m_fallback_font->SpriteBank->getTexture(texID) :
|
||||||
@ -1176,54 +906,7 @@ void ScalableFont::doDraw(const core::stringw& text,
|
|||||||
GL32_draw2DRectangle(video::SColor(255, 255,0,0), dest,clip);
|
GL32_draw2DRectangle(video::SColor(255, 255,0,0), dest,clip);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ENABLE_FREETYPE
|
|
||||||
if (texture == NULL)
|
|
||||||
{
|
|
||||||
// perform lazy loading
|
|
||||||
|
|
||||||
if (fallback[n])
|
|
||||||
{
|
|
||||||
m_fallback_font->lazyLoadTexture(texID);
|
|
||||||
texture = m_fallback_font->SpriteBank->getTexture(texID);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lazyLoadTexture(texID);
|
|
||||||
texture = SpriteBank->getTexture(texID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (texture == NULL)
|
|
||||||
{
|
|
||||||
Log::warn("ScalableFont", "Character not found in current font");
|
|
||||||
continue; // no such character
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
if (m_black_border && charCollector == NULL)
|
|
||||||
{
|
|
||||||
// draw black border
|
|
||||||
video::SColor black(color.getAlpha(),0,0,0);
|
|
||||||
|
|
||||||
for (int x_delta=-2; x_delta<=2; x_delta++)
|
|
||||||
{
|
|
||||||
for (int y_delta=-2; y_delta<=2; y_delta++)
|
|
||||||
{
|
|
||||||
if (x_delta == 0 || y_delta == 0) continue;
|
|
||||||
draw2DImage(texture,
|
|
||||||
dest + core::position2d<s32>(x_delta, y_delta),
|
|
||||||
source,
|
|
||||||
clip,
|
|
||||||
black, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
if (fallback[n] || m_type == T_BOLD)
|
if (fallback[n] || m_type == T_BOLD)
|
||||||
#else
|
|
||||||
if (fallback[n])
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
{
|
{
|
||||||
// TODO: don't hardcode colors?
|
// TODO: don't hardcode colors?
|
||||||
video::SColor orange(color.getAlpha(), 255, 100, 0);
|
video::SColor orange(color.getAlpha(), 255, 100, 0);
|
||||||
@ -1269,78 +952,10 @@ void ScalableFont::doDraw(const core::stringw& text,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef ENABLE_FREETYPE
|
|
||||||
void ScalableFont::lazyLoadTexture(int texID)
|
|
||||||
{
|
|
||||||
Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
|
|
||||||
|
|
||||||
// load texture
|
|
||||||
assert(m_texture_files[texID].m_file_name.size() > 0);
|
|
||||||
|
|
||||||
// Font textures can not be resized (besides the impact on quality in
|
|
||||||
// this case, the indices in the xml files would become wrong).
|
|
||||||
core::dimension2du old_max_size = Driver->getDriverAttributes()
|
|
||||||
.getAttributeAsDimension2d("MAX_TEXTURE_SIZE");
|
|
||||||
Driver->getNonConstDriverAttributes().setAttribute("MAX_TEXTURE_SIZE",
|
|
||||||
core::dimension2du(0, 0));
|
|
||||||
|
|
||||||
SpriteBank->setTexture(texID, Driver->getTexture( m_texture_files[texID].m_file_name ));
|
|
||||||
Driver->getNonConstDriverAttributes().setAttribute("MAX_TEXTURE_SIZE", old_max_size);
|
|
||||||
|
|
||||||
// set previous mip-map+filter state
|
|
||||||
//Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, mipmap);
|
|
||||||
|
|
||||||
// couldn't load texture, abort.
|
|
||||||
if (!SpriteBank->getTexture(texID))
|
|
||||||
{
|
|
||||||
Log::error("ScalableFont::lazyLoadTexture", "Unable to load all textures in the font");
|
|
||||||
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
assert(m_texture_files[texID].m_file_name.size() > 0);
|
|
||||||
|
|
||||||
// colorkey texture rather than alpha channel?
|
|
||||||
if (! m_texture_files[texID].m_has_alpha)
|
|
||||||
{
|
|
||||||
Driver->makeColorKeyTexture(SpriteBank->getTexture(texID), core::position2di(0,0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
int ScalableFont::getCharWidth(const SFontArea& area, const bool fallback) const
|
int ScalableFont::getCharWidth(const SFontArea& area, const bool fallback) const
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_FREETYPE
|
if (fallback) return (int)((area.width*m_fallback_font_scale + m_fallback_kerning_width) * m_scale);
|
||||||
const float char_scale = 1.0f;
|
else return (int)((area.width + GlobalKerningWidth) * m_scale);
|
||||||
#else
|
|
||||||
core::array< SGUISprite >& sprites = SpriteBank->getSprites();
|
|
||||||
core::array< SGUISprite >* fallback_sprites = (m_fallback_font != NULL ?
|
|
||||||
&m_fallback_font->SpriteBank->getSprites() :
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
const int texID = (fallback ?
|
|
||||||
(*fallback_sprites)[area.spriteno].Frames[0].textureNumber :
|
|
||||||
sprites[area.spriteno].Frames[0].textureNumber);
|
|
||||||
|
|
||||||
const TextureInfo& info = (fallback ?
|
|
||||||
(*(m_fallback_font->m_texture_files.find(texID))).second :
|
|
||||||
(*(m_texture_files.find(texID))).second
|
|
||||||
);
|
|
||||||
assert(info.m_file_name.size() > 0);
|
|
||||||
const float char_scale = info.m_scale;
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
//Log::info("ScalableFont", "area.spriteno = %d, char_scale = %f", area.spriteno, char_scale);
|
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
if (fallback) return (int)((area.width*m_fallback_font_scale + m_fallback_kerning_width) * m_scale * char_scale);
|
|
||||||
else return (int)((area.width + GlobalKerningWidth) * m_scale * char_scale);
|
|
||||||
#else
|
|
||||||
if (fallback) return (int)(((area.width + area.overhang)*m_fallback_font_scale + m_fallback_kerning_width) * m_scale * char_scale);
|
|
||||||
else return (int)((area.width + area.overhang + GlobalKerningWidth) * m_scale * char_scale);
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1355,11 +970,7 @@ s32 ScalableFont::getCharacterFromPos(const wchar_t* text, s32 pixel_x) const
|
|||||||
bool use_fallback_font = false;
|
bool use_fallback_font = false;
|
||||||
const SFontArea &a = getAreaFromCharacter(text[idx], &use_fallback_font);
|
const SFontArea &a = getAreaFromCharacter(text[idx], &use_fallback_font);
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
x += getCharWidth(a, use_fallback_font) + GlobalKerningWidth;
|
x += getCharWidth(a, use_fallback_font) + GlobalKerningWidth;
|
||||||
#else
|
|
||||||
x += getCharWidth(a, use_fallback_font) + a.overhang + a.underhang + GlobalKerningWidth;
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
if (x >= pixel_x)
|
if (x >= pixel_x)
|
||||||
return idx;
|
return idx;
|
||||||
|
@ -7,9 +7,7 @@
|
|||||||
|
|
||||||
#include "utils/leak_check.hpp"
|
#include "utils/leak_check.hpp"
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
#include "guiengine/get_font_properties.hpp"
|
#include "guiengine/get_font_properties.hpp"
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
#include "IrrCompileConfig.h"
|
#include "IrrCompileConfig.h"
|
||||||
#include "IGUIFontBitmap.h"
|
#include "IGUIFontBitmap.h"
|
||||||
@ -55,26 +53,6 @@ class ScalableFont : public IGUIFontBitmap
|
|||||||
bool m_mono_space_digits;
|
bool m_mono_space_digits;
|
||||||
irr::video::SColor m_shadow_color;
|
irr::video::SColor m_shadow_color;
|
||||||
|
|
||||||
#ifndef ENABLE_FREETYPE
|
|
||||||
struct TextureInfo
|
|
||||||
{
|
|
||||||
irr::core::stringc m_file_name;
|
|
||||||
bool m_has_alpha;
|
|
||||||
float m_scale;
|
|
||||||
bool m_exclude_from_max_height_calculation;
|
|
||||||
|
|
||||||
TextureInfo()
|
|
||||||
{
|
|
||||||
m_has_alpha = false;
|
|
||||||
m_scale = 1.0f;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
std::map<int /* texture file ID */, TextureInfo> m_texture_files;
|
|
||||||
|
|
||||||
void doReadXmlFile(io::IXMLReader* xml);
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
bool m_is_hollow_copy;
|
bool m_is_hollow_copy;
|
||||||
bool m_rtl;
|
bool m_rtl;
|
||||||
|
|
||||||
@ -84,22 +62,16 @@ public:
|
|||||||
|
|
||||||
bool m_black_border;
|
bool m_black_border;
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
TTFLoadingType m_type;
|
TTFLoadingType m_type;
|
||||||
FontUse m_font_use;
|
FontUse m_font_use;
|
||||||
u32 m_dpi;
|
u32 m_dpi;
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
ScalableFont* m_fallback_font;
|
ScalableFont* m_fallback_font;
|
||||||
float m_fallback_font_scale;
|
float m_fallback_font_scale;
|
||||||
int m_fallback_kerning_width;
|
int m_fallback_kerning_width;
|
||||||
|
|
||||||
//! constructor
|
//! constructor
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
ScalableFont(IGUIEnvironment* env, TTFLoadingType type);
|
ScalableFont(IGUIEnvironment* env, TTFLoadingType type);
|
||||||
#else
|
|
||||||
ScalableFont(IGUIEnvironment* env, const std::string &filename);
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
/** Creates a hollow copy of this font; i.e. the underlying font data is the *same* for
|
/** Creates a hollow copy of this font; i.e. the underlying font data is the *same* for
|
||||||
* both fonts. The advantage of doing this is that you can change "view" parameters
|
* both fonts. The advantage of doing this is that you can change "view" parameters
|
||||||
@ -120,15 +92,8 @@ public:
|
|||||||
//! destructor
|
//! destructor
|
||||||
virtual ~ScalableFont();
|
virtual ~ScalableFont();
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
//! loads a font from a TTF file
|
//! loads a font from a TTF file
|
||||||
bool loadTTF();
|
bool loadTTF();
|
||||||
#else
|
|
||||||
//! loads a font from an XML file
|
|
||||||
bool load(io::IXMLReader* xml);
|
|
||||||
|
|
||||||
void lazyLoadTexture(int texID);
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
//! draws an text and clips it to the specified rectangle if wanted
|
//! draws an text and clips it to the specified rectangle if wanted
|
||||||
virtual void draw(const core::stringw& text, const core::rect<s32>& position,
|
virtual void draw(const core::stringw& text, const core::rect<s32>& position,
|
||||||
@ -180,7 +145,6 @@ public:
|
|||||||
|
|
||||||
void updateRTL();
|
void updateRTL();
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
//! re-create fonts when language is changed
|
//! re-create fonts when language is changed
|
||||||
void recreateFromLanguage();
|
void recreateFromLanguage();
|
||||||
|
|
||||||
@ -189,11 +153,9 @@ public:
|
|||||||
|
|
||||||
//! force create a new texture (glyph) page in a font
|
//! force create a new texture (glyph) page in a font
|
||||||
void forceNewPage();
|
void forceNewPage();
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
struct SFontArea
|
struct SFontArea
|
||||||
{
|
{
|
||||||
SFontArea() : width(0), spriteno(0), offsety(0), offsety_bt(0), bearingx(0) {}
|
SFontArea() : width(0), spriteno(0), offsety(0), offsety_bt(0), bearingx(0) {}
|
||||||
@ -203,16 +165,6 @@ private:
|
|||||||
s32 offsety_bt;
|
s32 offsety_bt;
|
||||||
s32 bearingx;
|
s32 bearingx;
|
||||||
};
|
};
|
||||||
#else
|
|
||||||
struct SFontArea
|
|
||||||
{
|
|
||||||
SFontArea() : underhang(0), overhang(0), width(0), spriteno(0) {}
|
|
||||||
s32 underhang;
|
|
||||||
s32 overhang;
|
|
||||||
s32 width;
|
|
||||||
u32 spriteno;
|
|
||||||
};
|
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
int getCharWidth(const SFontArea& area, const bool fallback) const;
|
int getCharWidth(const SFontArea& area, const bool fallback) const;
|
||||||
s32 getAreaIDFromCharacter(const wchar_t c, bool* fallback_font) const;
|
s32 getAreaIDFromCharacter(const wchar_t c, bool* fallback_font) const;
|
||||||
@ -229,10 +181,8 @@ private:
|
|||||||
u32 WrongCharacter;
|
u32 WrongCharacter;
|
||||||
s32 MaxHeight;
|
s32 MaxHeight;
|
||||||
s32 GlobalKerningWidth, GlobalKerningHeight;
|
s32 GlobalKerningWidth, GlobalKerningHeight;
|
||||||
#ifdef ENABLE_FREETYPE
|
|
||||||
s32 GlyphMaxHeight;
|
s32 GlyphMaxHeight;
|
||||||
video::ITexture* LastNormalPage;
|
video::ITexture* LastNormalPage;
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
core::stringw Invisible;
|
core::stringw Invisible;
|
||||||
};
|
};
|
||||||
|
@ -1252,6 +1252,8 @@ void Kart::update(float dt)
|
|||||||
{
|
{
|
||||||
m_body->getBroadphaseHandle()->m_collisionFilterGroup = old_group;
|
m_body->getBroadphaseHandle()->m_collisionFilterGroup = old_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PROFILER_PUSH_CPU_MARKER("Kart::Update (material)", 0x60, 0x34, 0x7F);
|
||||||
handleMaterialGFX();
|
handleMaterialGFX();
|
||||||
const Material* material=m_terrain_info->getMaterial();
|
const Material* material=m_terrain_info->getMaterial();
|
||||||
if (!material) // kart falling off the track
|
if (!material) // kart falling off the track
|
||||||
@ -1309,6 +1311,7 @@ void Kart::update(float dt)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} // if there is material
|
} // if there is material
|
||||||
|
PROFILER_POP_CPU_MARKER();
|
||||||
|
|
||||||
// Check if any item was hit.
|
// Check if any item was hit.
|
||||||
// check it if we're not in a network world, or if we're on the server (when network mode is on)
|
// check it if we're not in a network world, or if we're on the server (when network mode is on)
|
||||||
@ -1447,7 +1450,11 @@ void Kart::handleMaterialSFX(const Material *material)
|
|||||||
// In case that three sfx needed to be played (i.e. a previous is
|
// In case that three sfx needed to be played (i.e. a previous is
|
||||||
// playing, a current is playing, and a new terrain with sfx is
|
// playing, a current is playing, and a new terrain with sfx is
|
||||||
// entered), the oldest (previous) sfx is stopped and deleted.
|
// entered), the oldest (previous) sfx is stopped and deleted.
|
||||||
if(getLastMaterial()!=material)
|
|
||||||
|
// FIXME: if there are already two sfx playing, don't add another
|
||||||
|
// one. This should reduce the performance impact when driving
|
||||||
|
// on the bridge in Cocoa.
|
||||||
|
if(getLastMaterial()!=material && !m_previous_terrain_sound)
|
||||||
{
|
{
|
||||||
// First stop any previously playing terrain sound
|
// First stop any previously playing terrain sound
|
||||||
// and remove it, so that m_previous_terrain_sound
|
// and remove it, so that m_previous_terrain_sound
|
||||||
|
@ -954,7 +954,7 @@ void World::update(float dt)
|
|||||||
m_physics->update(dt);
|
m_physics->update(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
PROFILER_PUSH_CPU_MARKER("World::update (AI)", 0x40, 0x7F, 0x00);
|
PROFILER_PUSH_CPU_MARKER("World::update (Kart::upate)", 0x40, 0x7F, 0x00);
|
||||||
const int kart_amount = (int)m_karts.size();
|
const int kart_amount = (int)m_karts.size();
|
||||||
for (int i = 0 ; i < kart_amount; ++i)
|
for (int i = 0 ; i < kart_amount; ++i)
|
||||||
{
|
{
|
||||||
|
@ -213,6 +213,30 @@ namespace Scripting
|
|||||||
/** @} */
|
/** @} */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------- Light Object methods -----------
|
||||||
|
|
||||||
|
namespace Light
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @addtogroup Scripting_Light Light (script binding)
|
||||||
|
* Type returned by trackObject.getLight()
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
void setEnergy(float energy, /** \cond DOXYGEN_IGNORE */void *memory /** \endcond */)
|
||||||
|
{
|
||||||
|
((TrackObjectPresentationLight*)memory)->setEnergy(energy);
|
||||||
|
}
|
||||||
|
|
||||||
|
void animateEnergy(float energy, float duration, /** \cond DOXYGEN_IGNORE */void *memory /** \endcond */)
|
||||||
|
{
|
||||||
|
((TrackObjectPresentationLight*)memory)->setEnergy(energy, duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------- Sound Object methods -----------
|
// ----------- Sound Object methods -----------
|
||||||
|
|
||||||
namespace SoundEmitter
|
namespace SoundEmitter
|
||||||
@ -289,6 +313,7 @@ namespace Scripting
|
|||||||
r = engine->RegisterObjectType("ParticleEmitter", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
r = engine->RegisterObjectType("ParticleEmitter", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
||||||
r = engine->RegisterObjectType("SoundEmitter", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
r = engine->RegisterObjectType("SoundEmitter", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
||||||
r = engine->RegisterObjectType("Animator", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
r = engine->RegisterObjectType("Animator", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectType("Light", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
||||||
|
|
||||||
//r = engine->RegisterGlobalFunction("void disableTrackObject(const string &in)", asFUNCTION(disableTrackObject), asCALL_CDECL); assert(r >= 0);
|
//r = engine->RegisterGlobalFunction("void disableTrackObject(const string &in)", asFUNCTION(disableTrackObject), asCALL_CDECL); assert(r >= 0);
|
||||||
//r = engine->RegisterGlobalFunction("void enableTrackObject(const string &in)", asFUNCTION(enableTrackObject), asCALL_CDECL); assert(r >= 0);
|
//r = engine->RegisterGlobalFunction("void enableTrackObject(const string &in)", asFUNCTION(enableTrackObject), asCALL_CDECL); assert(r >= 0);
|
||||||
@ -305,6 +330,7 @@ namespace Scripting
|
|||||||
// TrackObject
|
// TrackObject
|
||||||
r = engine->RegisterObjectMethod("TrackObject", "void setEnabled(bool status)", asMETHOD(::TrackObject, setEnabled), asCALL_THISCALL); assert(r >= 0);
|
r = engine->RegisterObjectMethod("TrackObject", "void setEnabled(bool status)", asMETHOD(::TrackObject, setEnabled), asCALL_THISCALL); assert(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("TrackObject", "SoundEmitter@ getSoundEmitter()", asMETHOD(::TrackObject, getSoundEmitter), asCALL_THISCALL); assert(r >= 0);
|
r = engine->RegisterObjectMethod("TrackObject", "SoundEmitter@ getSoundEmitter()", asMETHOD(::TrackObject, getSoundEmitter), asCALL_THISCALL); assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("TrackObject", "Light@ getLight()", asMETHOD(::TrackObject, getLight), asCALL_THISCALL); assert(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("TrackObject", "PhysicalObject@ getPhysics()", asMETHOD(::TrackObject, getPhysics), asCALL_THISCALL); assert(r >= 0);
|
r = engine->RegisterObjectMethod("TrackObject", "PhysicalObject@ getPhysics()", asMETHOD(::TrackObject, getPhysics), asCALL_THISCALL); assert(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("TrackObject", "Mesh@ getMesh()", asMETHOD(::TrackObject, getMesh), asCALL_THISCALL); assert(r >= 0);
|
r = engine->RegisterObjectMethod("TrackObject", "Mesh@ getMesh()", asMETHOD(::TrackObject, getMesh), asCALL_THISCALL); assert(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("TrackObject", "ParticleEmitter@ getParticleEmitter()", asMETHOD(::TrackObject, getParticleEmitter), asCALL_THISCALL); assert(r >= 0);
|
r = engine->RegisterObjectMethod("TrackObject", "ParticleEmitter@ getParticleEmitter()", asMETHOD(::TrackObject, getParticleEmitter), asCALL_THISCALL); assert(r >= 0);
|
||||||
@ -335,6 +361,9 @@ namespace Scripting
|
|||||||
r = engine->RegisterObjectMethod("SoundEmitter", "void playOnce()", asFUNCTION(SoundEmitter::playOnce), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
r = engine->RegisterObjectMethod("SoundEmitter", "void playOnce()", asFUNCTION(SoundEmitter::playOnce), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("SoundEmitter", "void playLoop()", asFUNCTION(SoundEmitter::playLoop), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
r = engine->RegisterObjectMethod("SoundEmitter", "void playLoop()", asFUNCTION(SoundEmitter::playLoop), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||||
|
|
||||||
|
// Light
|
||||||
|
r = engine->RegisterObjectMethod("Light", "void setEnergy(float)", asFUNCTION(Light::setEnergy), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("Light", "void animateEnergy(float, float)", asFUNCTION(Light::animateEnergy), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||||
|
|
||||||
// Curve based Animation
|
// Curve based Animation
|
||||||
//fails due to insufficient visibility to scripts TODO : Decide whether to fix visibility or introduce wrappers
|
//fails due to insufficient visibility to scripts TODO : Decide whether to fix visibility or introduce wrappers
|
||||||
|
@ -330,13 +330,11 @@ void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, con
|
|||||||
|
|
||||||
translations = new Translations();
|
translations = new Translations();
|
||||||
|
|
||||||
#ifdef ENABLE_FREETYPE
|
//Reload fonts for new translation
|
||||||
//Reload fonts for new translation when using freetype
|
|
||||||
GUIEngine::cleanHollowCopyFont();
|
GUIEngine::cleanHollowCopyFont();
|
||||||
GUIEngine::getTitleFont()->recreateFromLanguage();
|
GUIEngine::getTitleFont()->recreateFromLanguage();
|
||||||
GUIEngine::getFont()->recreateFromLanguage();
|
GUIEngine::getFont()->recreateFromLanguage();
|
||||||
GUIEngine::reloadHollowCopyFont(GUIEngine::getFont());
|
GUIEngine::reloadHollowCopyFont(GUIEngine::getFont());
|
||||||
#endif // ENABLE_FREETYPE
|
|
||||||
|
|
||||||
GUIEngine::getStateManager()->hardResetAndGoToScreen<MainMenuScreen>();
|
GUIEngine::getStateManager()->hardResetAndGoToScreen<MainMenuScreen>();
|
||||||
|
|
||||||
|
@ -22,11 +22,13 @@
|
|||||||
|
|
||||||
#include "audio/music_manager.hpp"
|
#include "audio/music_manager.hpp"
|
||||||
#include "config/user_config.hpp"
|
#include "config/user_config.hpp"
|
||||||
#include "graphics/camera.hpp"
|
|
||||||
#include "graphics/2dutils.hpp"
|
#include "graphics/2dutils.hpp"
|
||||||
|
#include "graphics/camera.hpp"
|
||||||
|
#include "graphics/central_settings.hpp"
|
||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "graphics/material.hpp"
|
#include "graphics/material.hpp"
|
||||||
#include "graphics/material_manager.hpp"
|
#include "graphics/material_manager.hpp"
|
||||||
|
#include "graphics/post_processing.hpp"
|
||||||
#include "graphics/referee.hpp"
|
#include "graphics/referee.hpp"
|
||||||
#include "guiengine/scalable_font.hpp"
|
#include "guiengine/scalable_font.hpp"
|
||||||
#include "io/file_manager.hpp"
|
#include "io/file_manager.hpp"
|
||||||
@ -410,6 +412,17 @@ void RaceGUIBase::preRenderCallback(const Camera *camera)
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void RaceGUIBase::renderPlayerView(const Camera *camera, float dt)
|
void RaceGUIBase::renderPlayerView(const Camera *camera, float dt)
|
||||||
{
|
{
|
||||||
|
if (CVS->isGLSL())
|
||||||
|
{
|
||||||
|
if (m_lightning > 0.0f)
|
||||||
|
{
|
||||||
|
core::vector3df intensity = {0.7f * m_lightning,
|
||||||
|
0.7f * m_lightning,
|
||||||
|
0.7f * std::min(1.0f, m_lightning * 1.5f)};
|
||||||
|
irr_driver->getPostProcessing()->renderLightning(intensity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
const core::recti &viewport = camera->getViewport();
|
const core::recti &viewport = camera->getViewport();
|
||||||
|
|
||||||
|
@ -197,6 +197,10 @@ public:
|
|||||||
* On the script side, the returned object is of type : @ref Scripting_SoundEmitter
|
* On the script side, the returned object is of type : @ref Scripting_SoundEmitter
|
||||||
*/
|
*/
|
||||||
TrackObjectPresentationSound* getSoundEmitter(){ return getPresentation<TrackObjectPresentationSound>(); }
|
TrackObjectPresentationSound* getSoundEmitter(){ return getPresentation<TrackObjectPresentationSound>(); }
|
||||||
|
/** Should only be used on sound emitter track objects.
|
||||||
|
* On the script side, the returned object is of type : @ref Scripting_Light
|
||||||
|
*/
|
||||||
|
TrackObjectPresentationLight* getLight() { return getPresentation<TrackObjectPresentationLight>(); }
|
||||||
// For angelscript. Needs to be named something different than getAnimator since it's overloaded.
|
// For angelscript. Needs to be named something different than getAnimator since it's overloaded.
|
||||||
/** Should only be used on TrackObjects that use curve-based animation.
|
/** Should only be used on TrackObjects that use curve-based animation.
|
||||||
* On the script side, the returned object is of type : @ref Scripting_Animator
|
* On the script side, the returned object is of type : @ref Scripting_Animator
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "graphics/camera.hpp"
|
#include "graphics/camera.hpp"
|
||||||
#include "graphics/central_settings.hpp"
|
#include "graphics/central_settings.hpp"
|
||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
|
#include "graphics/light.hpp"
|
||||||
#include "graphics/material_manager.hpp"
|
#include "graphics/material_manager.hpp"
|
||||||
#include "graphics/mesh_tools.hpp"
|
#include "graphics/mesh_tools.hpp"
|
||||||
#include "graphics/particle_emitter.hpp"
|
#include "graphics/particle_emitter.hpp"
|
||||||
@ -966,13 +967,50 @@ TrackObjectPresentationLight::TrackObjectPresentationLight(
|
|||||||
{
|
{
|
||||||
m_node = NULL; // lights require shaders to work
|
m_node = NULL; // lights require shaders to work
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_energy_animation_from = 0.0f;
|
||||||
|
m_energy_animation_to = 0.0f;
|
||||||
|
m_energy_animation_total_duration = 0.0f;
|
||||||
|
m_energy_animation_remaining_duration = 0.0f;
|
||||||
} // TrackObjectPresentationLight
|
} // TrackObjectPresentationLight
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
TrackObjectPresentationLight::~TrackObjectPresentationLight()
|
TrackObjectPresentationLight::~TrackObjectPresentationLight()
|
||||||
{
|
{
|
||||||
} // ~TrackObjectPresentationLight
|
} // ~TrackObjectPresentationLight
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void TrackObjectPresentationLight::setEnergy(float energy)
|
||||||
|
{
|
||||||
|
m_energy = energy;
|
||||||
|
LightNode* lnode = dynamic_cast<LightNode*>(m_node);
|
||||||
|
if (lnode != NULL)
|
||||||
|
{
|
||||||
|
lnode->setEnergy(energy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void TrackObjectPresentationLight::setEnergy(float energy, float duration)
|
||||||
|
{
|
||||||
|
m_energy_animation_from = m_energy;
|
||||||
|
m_energy_animation_to = energy;
|
||||||
|
m_energy_animation_total_duration = duration;
|
||||||
|
m_energy_animation_remaining_duration = duration;
|
||||||
|
}
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void TrackObjectPresentationLight::update(float dt)
|
||||||
|
{
|
||||||
|
if (m_energy_animation_remaining_duration > 0.0f)
|
||||||
|
{
|
||||||
|
m_energy_animation_remaining_duration -= dt;
|
||||||
|
if (m_energy_animation_remaining_duration < 0.0f)
|
||||||
|
m_energy_animation_remaining_duration = 0.0f;
|
||||||
|
|
||||||
|
float ratio = m_energy_animation_remaining_duration / m_energy_animation_total_duration;
|
||||||
|
|
||||||
|
setEnergy(m_energy_animation_from +
|
||||||
|
(m_energy_animation_to - m_energy_animation_from)*(1.0f - ratio));
|
||||||
|
}
|
||||||
|
}
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
TrackObjectPresentationActionTrigger::TrackObjectPresentationActionTrigger(
|
TrackObjectPresentationActionTrigger::TrackObjectPresentationActionTrigger(
|
||||||
const XMLNode& xml_node)
|
const XMLNode& xml_node)
|
||||||
|
@ -355,10 +355,18 @@ private:
|
|||||||
float m_distance;
|
float m_distance;
|
||||||
float m_energy;
|
float m_energy;
|
||||||
|
|
||||||
|
float m_energy_animation_from;
|
||||||
|
float m_energy_animation_to;
|
||||||
|
float m_energy_animation_total_duration;
|
||||||
|
float m_energy_animation_remaining_duration;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TrackObjectPresentationLight(const XMLNode& xml_node,
|
TrackObjectPresentationLight(const XMLNode& xml_node,
|
||||||
scene::ISceneNode* parent);
|
scene::ISceneNode* parent);
|
||||||
virtual ~TrackObjectPresentationLight();
|
virtual ~TrackObjectPresentationLight();
|
||||||
|
void setEnergy(float energy);
|
||||||
|
void setEnergy(float energy, float duration);
|
||||||
|
virtual void update(float dt) OVERRIDE;
|
||||||
}; // TrackObjectPresentationLight
|
}; // TrackObjectPresentationLight
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
Loading…
Reference in New Issue
Block a user