Merge branch 'big_digit'
This commit is contained in:
commit
97a23e83cb
@ -687,11 +687,11 @@ namespace GUIEngine
|
||||
{
|
||||
IGUIEnvironment* g_env;
|
||||
Skin* g_skin = NULL;
|
||||
ScalableFont* g_font;
|
||||
ScalableFont* g_large_font;
|
||||
ScalableFont* g_title_font;
|
||||
ScalableFont* g_small_font;
|
||||
ScalableFont* g_digit_font;
|
||||
ScalableFont *g_font;
|
||||
ScalableFont *g_large_font;
|
||||
ScalableFont *g_title_font;
|
||||
ScalableFont *g_small_font;
|
||||
ScalableFont *g_digit_font;
|
||||
|
||||
IrrlichtDevice* g_device;
|
||||
IVideoDriver* g_driver;
|
||||
@ -1062,7 +1062,7 @@ namespace GUIEngine
|
||||
ScalableFont* sfont =
|
||||
new ScalableFont(g_env,
|
||||
file_manager->getAssetChecked(FileManager::FONT,
|
||||
"StkFont.xml",true).c_str() );
|
||||
"StkFont.xml",true) );
|
||||
sfont->setScale(normal_text_scale);
|
||||
sfont->setKerningHeight(-5);
|
||||
g_font = sfont;
|
||||
@ -1070,13 +1070,12 @@ namespace GUIEngine
|
||||
ScalableFont* digit_font =
|
||||
new ScalableFont(g_env,
|
||||
file_manager->getAssetChecked(FileManager::FONT,
|
||||
"BigDigitFont.xml",true).c_str());
|
||||
"BigDigitFont.xml",true));
|
||||
digit_font->lazyLoadTexture(0); // make sure the texture is loaded for this one
|
||||
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);
|
||||
@ -1097,7 +1096,7 @@ namespace GUIEngine
|
||||
new ScalableFont(g_env,
|
||||
file_manager->getAssetChecked(FileManager::FONT,
|
||||
"title_font.xml",
|
||||
true).c_str() );
|
||||
true) );
|
||||
sfont2->m_fallback_font = sfont;
|
||||
// Because the fallback font is much smaller than the title font:
|
||||
sfont2->m_fallback_font_scale = 4.0f;
|
||||
|
@ -21,9 +21,9 @@ namespace gui
|
||||
{
|
||||
|
||||
//! constructor
|
||||
ScalableFont::ScalableFont(IGUIEnvironment *env, const io::path& filename)
|
||||
: Driver(0), SpriteBank(0), Environment(env), WrongCharacter(0),
|
||||
MaxHeight(0), GlobalKerningWidth(0), GlobalKerningHeight(0)
|
||||
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");
|
||||
@ -44,7 +44,7 @@ ScalableFont::ScalableFont(IGUIEnvironment *env, const io::path& filename)
|
||||
// don't grab environment, to avoid circular references
|
||||
Driver = Environment->getVideoDriver();
|
||||
|
||||
SpriteBank = Environment->addEmptySpriteBank(filename);
|
||||
SpriteBank = Environment->addEmptySpriteBank(io::path(filename.c_str()));
|
||||
if (SpriteBank)
|
||||
SpriteBank->grab();
|
||||
}
|
||||
@ -676,7 +676,6 @@ void ScalableFont::draw(const core::stringw& text,
|
||||
source,
|
||||
clip,
|
||||
color, true);
|
||||
|
||||
#ifdef FONT_DEBUG
|
||||
driver->draw2DLine(core::position2d<s32>(dest.UpperLeftCorner.X, dest.UpperLeftCorner.Y),
|
||||
core::position2d<s32>(dest.UpperLeftCorner.X, dest.LowerRightCorner.Y),
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
int m_fallback_kerning_width;
|
||||
|
||||
//! constructor
|
||||
ScalableFont(IGUIEnvironment* env, const io::path& filename);
|
||||
ScalableFont(IGUIEnvironment* env, const std::string &filename);
|
||||
|
||||
/** 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
|
||||
|
@ -308,6 +308,10 @@ void Flyable::getLinearKartItemIntersection (const Vec3 &origin,
|
||||
|
||||
float fire_th = (dx*dist - dz * sqrtf(dx*dx + dz*dz - dist*dist))
|
||||
/ (dx*dx + dz*dz);
|
||||
if(fire_th>1)
|
||||
fire_th = 1.0f;
|
||||
else if (fire_th<-1.0f)
|
||||
fire_th = -1.0f;
|
||||
fire_th = (((dist - dx*fire_th) / dz > 0) ? -acosf(fire_th)
|
||||
: acosf(fire_th));
|
||||
|
||||
@ -326,8 +330,10 @@ void Flyable::getLinearKartItemIntersection (const Vec3 &origin,
|
||||
fire_th += M_PI;
|
||||
|
||||
//createPhysics offset
|
||||
assert(sqrt(a*a+b*b)!=0);
|
||||
time -= forw_offset / sqrt(a*a+b*b);
|
||||
|
||||
assert(time!=0);
|
||||
*fire_angle = fire_th;
|
||||
*up_velocity = (0.5f * time * gravity) + (dy / time)
|
||||
+ (gy * target_kart->getSpeed());
|
||||
|
@ -77,6 +77,6 @@ public:
|
||||
|
||||
|
||||
|
||||
}; // WorldWithRank
|
||||
}; // WorldWithRank
|
||||
|
||||
#endif
|
||||
|
@ -123,6 +123,13 @@ RaceGUI::RaceGUI()
|
||||
w = font->getDimension(m_string_rank.c_str()).Width;
|
||||
if(m_rank_lap_width < w) m_rank_lap_width = w;
|
||||
|
||||
// Technically we only need getNumLocalPlayers, but using the
|
||||
// global kart id to find the data for a specific kart.
|
||||
int n = race_manager->getNumberOfKarts();
|
||||
|
||||
m_animation_states.resize(n);
|
||||
m_rank_animation_start_times.resize(n);
|
||||
m_last_ranks.resize(n);
|
||||
} // RaceGUI
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -130,6 +137,19 @@ RaceGUI::~RaceGUI()
|
||||
{
|
||||
} // ~Racegui
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Reset the gui before a race. It initialised all rank animation related
|
||||
* values back to the default.
|
||||
*/
|
||||
void RaceGUI::reset()
|
||||
{
|
||||
for(unsigned int i=0; i<race_manager->getNumberOfKarts(); i++)
|
||||
{
|
||||
m_animation_states[i] = AS_NONE;
|
||||
m_last_ranks[i] = i+1;
|
||||
}
|
||||
} // reset
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Render all global parts of the race gui, i.e. things that are only
|
||||
* displayed once even in splitscreen.
|
||||
@ -201,7 +221,7 @@ void RaceGUI::renderPlayerView(const Camera *camera, float dt)
|
||||
core::vector2df scaling = camera->getScaling();
|
||||
const AbstractKart *kart = camera->getKart();
|
||||
if(!kart) return;
|
||||
|
||||
|
||||
drawPlungerInFace(camera, dt);
|
||||
|
||||
scaling *= viewport.getWidth()/800.0f; // scale race GUI along screen size
|
||||
@ -219,6 +239,8 @@ void RaceGUI::renderPlayerView(const Camera *camera, float dt)
|
||||
} // renderPlayerView
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Shows the current soccer result.
|
||||
*/
|
||||
void RaceGUI::drawScores()
|
||||
{
|
||||
SoccerWorld* soccerWorld = (SoccerWorld*)World::getWorld();
|
||||
@ -271,7 +293,8 @@ void RaceGUI::drawScores()
|
||||
numLeader++;
|
||||
offsetX += position.LowerRightCorner.X;
|
||||
}
|
||||
}
|
||||
} // drawScores
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Displays the racing time on the screen.s
|
||||
*/
|
||||
@ -388,10 +411,10 @@ void RaceGUI::drawEnergyMeter(int x, int y, const AbstractKart *kart,
|
||||
const core::recti &viewport,
|
||||
const core::vector2df &scaling)
|
||||
{
|
||||
float minRatio = std::min(scaling.X, scaling.Y);
|
||||
float min_ratio = std::min(scaling.X, scaling.Y);
|
||||
const int GAUGEWIDTH = 78;
|
||||
int gauge_width = (int)(GAUGEWIDTH*minRatio);
|
||||
int gauge_height = (int)(GAUGEWIDTH*minRatio);
|
||||
int gauge_width = (int)(GAUGEWIDTH*min_ratio);
|
||||
int gauge_height = (int)(GAUGEWIDTH*min_ratio);
|
||||
|
||||
float state = (float)(kart->getEnergy())
|
||||
/ kart->getKartProperties()->getNitroMax();
|
||||
@ -404,14 +427,13 @@ void RaceGUI::drawEnergyMeter(int x, int y, const AbstractKart *kart,
|
||||
|
||||
|
||||
// Background
|
||||
draw2DImage(m_gauge_empty,
|
||||
core::rect<s32>((int)offset.X,
|
||||
(int) offset.Y-gauge_height,
|
||||
(int) offset.X + gauge_width,
|
||||
(int)offset.Y) /* dest rect */,
|
||||
core::rect<s32>(0, 0, 256, 256) /* source rect */,
|
||||
NULL /* clip rect */, NULL /* colors */,
|
||||
true /* alpha */);
|
||||
draw2DImage(m_gauge_empty, core::rect<s32>((int)offset.X,
|
||||
(int)offset.Y-gauge_height,
|
||||
(int)offset.X + gauge_width,
|
||||
(int)offset.Y) /* dest rect */,
|
||||
core::rect<s32>(0, 0, 256, 256) /* source rect */,
|
||||
NULL /* clip rect */, NULL /* colors */,
|
||||
true /* alpha */);
|
||||
|
||||
// Target
|
||||
|
||||
@ -581,10 +603,8 @@ void RaceGUI::drawEnergyMeter(int x, int y, const AbstractKart *kart,
|
||||
irr_driver->getVideoDriver()->draw2DVertexPrimitiveList(vertices, count,
|
||||
index, count-2, video::EVT_STANDARD, scene::EPT_TRIANGLE_FAN);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // drawEnergyMeter
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -593,10 +613,10 @@ void RaceGUI::drawSpeedAndEnergy(const AbstractKart* kart,
|
||||
const core::recti &viewport,
|
||||
const core::vector2df &scaling)
|
||||
{
|
||||
float minRatio = std::min(scaling.X, scaling.Y);
|
||||
float min_ratio = std::min(scaling.X, scaling.Y);
|
||||
const int SPEEDWIDTH = 128;
|
||||
int meter_width = (int)(SPEEDWIDTH*minRatio);
|
||||
int meter_height = (int)(SPEEDWIDTH*minRatio);
|
||||
int meter_width = (int)(SPEEDWIDTH*min_ratio);
|
||||
int meter_height = (int)(SPEEDWIDTH*min_ratio);
|
||||
|
||||
drawEnergyMeter(viewport.LowerRightCorner.X ,
|
||||
(int)(viewport.LowerRightCorner.Y),
|
||||
@ -604,8 +624,6 @@ void RaceGUI::drawSpeedAndEnergy(const AbstractKart* kart,
|
||||
|
||||
// First draw the meter (i.e. the background )
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
core::vector2df offset;
|
||||
offset.X = (float)(viewport.LowerRightCorner.X-meter_width) - 24.0f*scaling.X;
|
||||
offset.Y = viewport.LowerRightCorner.Y-10.0f*scaling.Y;
|
||||
@ -699,30 +717,79 @@ void RaceGUI::drawSpeedAndEnergy(const AbstractKart* kart,
|
||||
index, count-2, video::EVT_STANDARD, scene::EPT_TRIANGLE_FAN);
|
||||
|
||||
|
||||
// Draw Speed in Numbers
|
||||
// Draw rank
|
||||
WorldWithRank *world = dynamic_cast<WorldWithRank*>(World::getWorld());
|
||||
|
||||
core::recti pos;
|
||||
pos.UpperLeftCorner.X=(int)(offset.X + 0.5f*meter_width);
|
||||
pos.UpperLeftCorner.Y=(int)(offset.Y - 0.62f*meter_height);
|
||||
pos.LowerRightCorner.X=(int)(offset.X + 0.8f*meter_width);
|
||||
pos.LowerRightCorner.Y=(int)(offset.X - 0.5f*meter_height);
|
||||
if (world && world->displayRank())
|
||||
{
|
||||
core::recti pos;
|
||||
pos.UpperLeftCorner.X = (int)(offset.X + 0.5f*meter_width);
|
||||
pos.UpperLeftCorner.Y = (int)(offset.Y - 0.62f*meter_height);
|
||||
pos.LowerRightCorner.X = (int)(offset.X + 0.8f*meter_width);
|
||||
pos.LowerRightCorner.Y = (int)(offset.X - 0.5f*meter_height);
|
||||
|
||||
gui::ScalableFont* font;
|
||||
gui::ScalableFont* font = GUIEngine::getHighresDigitFont();
|
||||
|
||||
if (pos.getWidth() > 55)
|
||||
font = GUIEngine::getLargeFont();
|
||||
else if (pos.getWidth() > 40)
|
||||
font = GUIEngine::getFont();
|
||||
else
|
||||
font = GUIEngine::getSmallFont();
|
||||
int id = kart->getWorldKartId();
|
||||
|
||||
static video::SColor color = video::SColor(255, 255, 255, 255);
|
||||
std::ostringstream oss;
|
||||
oss << (int)(speed*10);
|
||||
if(m_animation_states[id] == AS_NONE)
|
||||
{
|
||||
if(m_last_ranks[id]!=kart->getPosition())
|
||||
{
|
||||
m_rank_animation_start_times[id] = world->getTime();
|
||||
m_animation_states[id] = AS_SMALLER;
|
||||
}
|
||||
}
|
||||
|
||||
font->draw(oss.str().c_str(), pos, color);
|
||||
float scale = 1.0f;
|
||||
int rank = kart->getPosition();
|
||||
const float DURATION = 0.8f;
|
||||
if(m_animation_states[id] == AS_SMALLER)
|
||||
{
|
||||
scale = 1.0f - (world->getTime()-m_rank_animation_start_times[id])
|
||||
/ DURATION;
|
||||
rank = m_last_ranks[id];
|
||||
if(scale<0)
|
||||
{
|
||||
m_animation_states[id] = AS_BIGGER;
|
||||
m_rank_animation_start_times[id] = world->getTime();
|
||||
// Store the new rank
|
||||
m_last_ranks[id] = kart->getPosition();
|
||||
scale = 0.0f;
|
||||
}
|
||||
}
|
||||
else if(m_animation_states[id] == AS_BIGGER)
|
||||
{
|
||||
scale = (world->getTime() - m_rank_animation_start_times[id])
|
||||
/ DURATION;
|
||||
rank = m_last_ranks[id];
|
||||
if(scale>1.0f)
|
||||
{
|
||||
m_animation_states[id] = AS_NONE;
|
||||
scale = 1.0f;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_last_ranks[id] = kart->getPosition();
|
||||
}
|
||||
|
||||
font->setScale(min_ratio * scale * 0.7f);
|
||||
font->setShadow(video::SColor(255, 128, 0, 0));
|
||||
static video::SColor color = video::SColor(255, 255, 255, 255);
|
||||
std::ostringstream oss;
|
||||
oss << rank; // the current font has no . :( << ".";
|
||||
|
||||
pos.LowerRightCorner = core::vector2di(offset.X+int(0.6f*meter_width),
|
||||
int(offset.Y-0.5f*meter_height));
|
||||
pos.UpperLeftCorner = core::vector2di(offset.X+int(0.6f*meter_width),
|
||||
int(offset.Y-0.5f*meter_height));
|
||||
|
||||
font->draw(oss.str().c_str(), pos, color, true, true);
|
||||
}
|
||||
|
||||
} // drawSpeedAndEnergy
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Displays the rank and the lap of the kart.
|
||||
@ -755,21 +822,6 @@ void RaceGUI::drawRankLap(const AbstractKart* kart,
|
||||
static video::SColor color = video::SColor(255, 255, 255, 255);
|
||||
WorldWithRank *world = (WorldWithRank*)(World::getWorld());
|
||||
|
||||
if (world->displayRank())
|
||||
{
|
||||
const int rank = kart->getPosition();
|
||||
|
||||
font->draw(m_string_rank.c_str(), pos, color);
|
||||
pos.UpperLeftCorner.Y += font_height;
|
||||
pos.LowerRightCorner.Y += font_height;
|
||||
|
||||
char str[256];
|
||||
const unsigned int kart_amount = world->getCurrentNumKarts();
|
||||
sprintf(str, "%d/%d", rank, kart_amount);
|
||||
font->draw(core::stringw(str).c_str(), pos, color);
|
||||
pos.UpperLeftCorner.Y += font_height;
|
||||
pos.LowerRightCorner.Y += font_height;
|
||||
}
|
||||
|
||||
// Don't display laps in follow the leader mode
|
||||
if(world->raceHasLaps())
|
||||
|
@ -88,8 +88,18 @@ private:
|
||||
/** Maximum string length for the timer */
|
||||
int m_timer_width;
|
||||
|
||||
/** Animation state: none, getting smaller (old value),
|
||||
* getting bigger (new number). */
|
||||
enum AnimationState {AS_NONE, AS_SMALLER, AS_BIGGER};
|
||||
std::vector<AnimationState> m_animation_states;
|
||||
|
||||
bool m_is_tutorial;
|
||||
/** When the animation state was changed. */
|
||||
std::vector<float> m_rank_animation_start_times;
|
||||
|
||||
/** Stores the previous rank for each kart. Used for the rank animation. */
|
||||
std::vector<int> m_last_ranks;
|
||||
|
||||
bool m_is_tutorial;
|
||||
|
||||
/* Display informat for one player on the screen. */
|
||||
void drawEnergyMeter (int x, int y, const AbstractKart *kart,
|
||||
@ -111,6 +121,7 @@ public:
|
||||
|
||||
RaceGUI();
|
||||
~RaceGUI();
|
||||
virtual void reset();
|
||||
virtual void renderGlobal(float dt);
|
||||
virtual void renderPlayerView(const Camera *camera, float dt);
|
||||
|
||||
|
@ -9,6 +9,10 @@ const int fontsizes[] = {4,6,8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,56,68,72
|
||||
|
||||
char bUsed[0x10000]={0};
|
||||
|
||||
/** True if pot files where given, which indicates that Asian fonts
|
||||
* are to be created, and an offset needs to be used for the index. */
|
||||
bool has_pot_files = false;
|
||||
|
||||
inline u32 getTextureSizeFromSurfaceSize(u32 size)
|
||||
{
|
||||
u32 ts = 0x01;
|
||||
@ -19,6 +23,7 @@ inline u32 getTextureSizeFromSurfaceSize(u32 size)
|
||||
}
|
||||
|
||||
bool LoadPoFiles(const char* sListFileName){
|
||||
has_pot_files = true;
|
||||
char s[1024];
|
||||
std::ifstream fin(sListFileName);
|
||||
if(!fin){
|
||||
@ -762,7 +767,8 @@ bool CFontTool::saveBitmapFont(const c8 *filename, const c8* format)
|
||||
writer->writeLineBreak();
|
||||
|
||||
// write images and link to them
|
||||
u32 offset_for_asian_fonts=100;
|
||||
// Only use the offset if Asian fonts are created.
|
||||
u32 offset_for_asian_fonts=has_pot_files ? 100 : 0;
|
||||
for (u32 i=0; i<currentImages.size(); ++i)
|
||||
{
|
||||
imagename = filename;
|
||||
|
Loading…
Reference in New Issue
Block a user