Fixed 128 type conversion warnings from VS.

git-svn-id: https://svn.code.sf.net/p/extremetuxracer/code/trunk@600 0420edf4-82e4-42fc-9478-35b55e6d67a3
master
pkeus 2016-01-19 13:07:10 +00:00
parent 2506c7300f
commit 7420115fbe
27 changed files with 165 additions and 166 deletions

View File

@ -231,10 +231,10 @@ std::size_t CMusic::GetThemeIdx(const std::string& theme) const {
}
void CMusic::SetVolume(int volume) {
int vol = clamp(0, volume, MIX_MAX_VOLUME);
volume = clamp(0, volume, MIX_MAX_VOLUME);
if (curr_music)
curr_music->setVolume(volume);
curr_volume = vol;
curr_volume = volume;
}
bool CMusic::Play(sf::Music* music, bool loop, int volume) {
@ -277,7 +277,7 @@ bool CMusic::PlayTheme(std::size_t theme, ESituation situation) {
if (theme >= themes.size()) return false;
if (situation >= SITUATION_COUNT) return false;
sf::Music* music = themes[theme].situation[situation];
return Play(music, -1, curr_volume);
return Play(music, true, curr_volume);
}
void CMusic::Halt() {

View File

@ -30,7 +30,7 @@ GNU General Public License for more details.
// color utils
// --------------------------------------------------------------------
#define TColor(r, g, b, a) sf::Color(r*255, g*255, b*255, a*255)
#define TColor(r, g, b, a) sf::Color(static_cast<sf::Uint8>(r*255), static_cast<sf::Uint8>(g*255), static_cast<sf::Uint8>(b*255), static_cast<sf::Uint8>(a*255))
const sf::Color colDYell = TColor(1.0, 0.8, 0.0, 1.0);
const sf::Color colDDYell = TColor(0.8, 0.6, 0.0, 1.0);
const sf::Color colLYell = TColor(1.0, 1.0, 0.4, 1.0);

View File

@ -152,7 +152,7 @@ void CGameConfig::Enter() {
int rightpos = area.right -48;
ResetGUI();
int siz = FT.AutoSizeN(5);
unsigned int siz = FT.AutoSizeN(5);
fullscreen = AddCheckbox(area.left, area.top, framewidth-16, Trans.Text(31));
fullscreen->checked = param.fullscreen;

View File

@ -251,9 +251,9 @@ void CCourse::FillGlArrays() {
for (unsigned int y = 0; y < ny; y++) {
int idx = STRIDE_GL_ARRAY * (y * nx + x);
FLOATVAL(0) = (GLfloat)x / (nx-1.0) * curr_course->size.x;
FLOATVAL(0) = (GLfloat)x / (nx-1.f) * curr_course->size.x;
FLOATVAL(1) = Fields[x + nx*y].elevation;
FLOATVAL(2) = -(GLfloat)y / (ny-1.0) * curr_course->size.y;
FLOATVAL(2) = -(GLfloat)y / (ny-1.f) * curr_course->size.y;
const TVector3d& nml = Fields[ x + y * nx ].nml;
FLOATVAL(4) = nml.x;
@ -548,7 +548,7 @@ bool CCourse::LoadObjectTypes() {
if (ObjTypes[i].drawable) {
ObjTypes[i].textureFile = SPStrN(*line, "texture");
}
ObjTypes[i].collectable = SPBoolN(*line, "snap", -1) != 0;
ObjTypes[i].collectable = SPBoolN(*line, "snap", true) != 0;
if (ObjTypes[i].collectable == 0) {
ObjTypes[i].collectable = -1;
}

View File

@ -33,8 +33,8 @@ GNU General Public License for more details.
static const bool clip_course = true;
void setup_course_tex_gen() {
static const GLfloat xplane[4] = {1.0 / TEX_SCALE, 0.0, 0.0, 0.0 };
static const GLfloat zplane[4] = {0.0, 0.0, 1.0 / TEX_SCALE, 0.0 };
static const GLfloat xplane[4] = {1.f / TEX_SCALE, 0.f, 0.f, 0.f };
static const GLfloat zplane[4] = {0.f, 0.f, 1.f / TEX_SCALE, 0.f };
glTexGenfv(GL_S, GL_OBJECT_PLANE, xplane);
glTexGenfv(GL_T, GL_OBJECT_PLANE, zplane);
}
@ -50,7 +50,7 @@ void RenderCourse() {
}
void DrawTrees() {
std::size_t tree_type = -1;
std::size_t tree_type = -1;
const CControl* ctrl = g_game.player->ctrl;
ScopedRenderMode rm(TREES);
@ -154,8 +154,8 @@ void DrawTrees() {
};
const GLfloat vtx[] = {
-itemRadius*normal.z, 0.0, itemRadius*normal.x,
itemRadius*normal.z, 0.0, -itemRadius*normal.x,
-itemRadius*normal.z, 0.f, itemRadius*normal.x,
itemRadius*normal.z, 0.f, -itemRadius*normal.x,
itemRadius*normal.z, itemHeight, -itemRadius*normal.x,
-itemRadius*normal.z, itemHeight, itemRadius*normal.x
};

View File

@ -57,8 +57,8 @@ void CCredits::LoadCreditList() {
TCredits& credit = *last;
credit.text = SPStrN(*line, "text");
float offset = SPFloatN(*line, "offs", 0) * OFFS_SCALE_FACTOR * Winsys.scale;
if (line != list.cbegin()) credit.offs = old_offs + (int)offset;
int offset = SPFloatN(*line, "offs", 0) * OFFS_SCALE_FACTOR * Winsys.scale;
if (line != list.cbegin()) credit.offs = old_offs + offset;
else credit.offs = offset;
credit.col = SPIntN(*line, "col", 0);
@ -126,8 +126,8 @@ void CCredits::Enter() {
RT = new sf::RenderTexture();
RT->create(Winsys.resolution.width, Winsys.resolution.height - TOP_Y - BOTT_Y + 2 * FADE);
int w = Winsys.resolution.width;
int h = Winsys.resolution.height;
float w = Winsys.resolution.width;
float h = Winsys.resolution.height;
arr[0] = sf::Vertex(sf::Vector2f(0, TOP_Y - FADE), colTBackr, sf::Vector2f(0, 0));
arr[1] = sf::Vertex(sf::Vector2f(0, TOP_Y), colWhite, sf::Vector2f(0, FADE));
arr[2] = sf::Vertex(sf::Vector2f(w, TOP_Y), colWhite, sf::Vector2f(w, FADE));

View File

@ -35,7 +35,7 @@ static const float def_diff[] = {1.f, 0.9f, 1.f, 1.f};
static const float def_spec[] = {0.6f, 0.6f, 0.6f, 1.f};
static const float def_pos[] = {1.f, 2.f, 2.f, 0.f};
static const float def_fogcol[] = {0.9f, 0.9f, 1.f, 0.f};
static const sf::Color def_partcol(0.8*255, 0.8*255, 0.9*255, 0);
static const sf::Color def_partcol(204, 204, 230, 0);
void TLight::Enable(GLenum num) const {
glLightfv(num, GL_POSITION, position);
@ -210,7 +210,7 @@ void CEnvironment::DrawSkybox(const TVector3d& pos) {
static const float bb = 0.995f;
#endif
glColor4f(1.0, 1.0, 1.0, 1.0);
glColor4ub(255, 255, 255, 255);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glPushMatrix();
glTranslate(pos);
@ -322,7 +322,7 @@ void CEnvironment::DrawFog() {
// TPlane right_edge_plane = MakePlane (-1.0, 0.0, 0.0, Course.width);
bottom_plane.nml = TVector3d(0.0, 1, -slope);
float height = Course.GetBaseHeight(0);
double height = Course.GetBaseHeight(0);
bottom_plane.d = -height * bottom_plane.nml.y;
top_plane.nml = bottom_plane.nml;
@ -346,29 +346,29 @@ void CEnvironment::DrawFog() {
glEnable(GL_FOG);
// only the alpha channel is used
static const GLfloat bottom_dens[4] = { 0, 0, 0, 1.0 };
static const GLfloat top_dens[4] = { 0, 0, 0, 0.9 };
static const GLfloat leftright_dens[4] = { 0, 0, 0, 0.3 };
static const GLfloat top_bottom_dens[4] = { 0, 0, 0, 0.0 };
static const GLubyte bottom_dens[4] = { 0, 0, 0, 255 };
static const GLubyte top_dens[4] = { 0, 0, 0, 230 };
static const GLubyte leftright_dens[4] = { 0, 0, 0, 77 };
static const GLubyte top_bottom_dens[4] = { 0, 0, 0, 0 };
glBegin(GL_QUAD_STRIP);
glColor4fv(bottom_dens);
glColor4ubv(bottom_dens);
glVertex3(bottomleft);
glVertex3(bottomright);
glVertex3(left);
glVertex3(right);
glColor4fv(top_dens);
glColor4ubv(top_dens);
glVertex3(topleft);
glVertex3(topright);
glColor4fv(leftright_dens);
glColor4ubv(leftright_dens);
vpoint = topleft + leftvec;
glVertex3(vpoint);
vpoint = topright + rightvec;
glVertex3(vpoint);
glColor4fv(top_bottom_dens);
glColor4ubv(top_bottom_dens);
vpoint = topleft + 3.0 * leftvec;
glVertex3(vpoint);
vpoint = topright + 3.0 * rightvec;

View File

@ -145,9 +145,9 @@ void CEvent::Enter() {
int framebottom = frametop + (int) ecup->races.size() * dist + 10;
ResetGUI();
int siz = FT.AutoSizeN(5);
unsigned int siz = FT.AutoSizeN(5);
textbuttons[1] = AddTextButton(Trans.Text(8), area.left + 100, AutoYPosN(80), siz);
float len = FT.GetTextWidth(Trans.Text(13));
int len = FT.GetTextWidth(Trans.Text(13));
textbuttons[0] = AddTextButton(Trans.Text(13), area.right -len - 100, AutoYPosN(80), siz);
textbuttons[2] = AddTextButton(Trans.Text(15), CENTER, AutoYPosN(80), siz);
SetFocus((ready == 2) ? textbuttons[2] : textbuttons[0]);

View File

@ -100,7 +100,7 @@ void CEventSelect::Enter() {
event = AddUpDown(area.right+8, frametop1, 0, (int)Events.EventList.size() - 1, 0);
cup = AddUpDown(area.right + 8, frametop2, 0, (int)Events.EventList[0].cups.size() - 1, 0);
int siz = FT.AutoSizeN(5);
unsigned int siz = FT.AutoSizeN(5);
float len = FT.GetTextWidth(Trans.Text(9));
textbuttons[0] = AddTextButton(Trans.Text(9), area.right-len-50, AutoYPosN(70), siz);

View File

@ -84,13 +84,13 @@ CFont FT;
CFont::CFont() {
// setting default values
curr_col.r = 0.0; // default color: black
curr_col.g = 0.0;
curr_col.b = 0.0;
curr_col.a = 1.0; // default: no transparency
curr_size = 20; // default size: 20 px
curr_fact = 0;
curr_font = 0;
curr_col.r = 0; // default color: black
curr_col.g = 0;
curr_col.b = 0;
curr_col.a = 255; // default: no transparency
curr_size = 20; // default size: 20 px
curr_fact = 0;
curr_font = 0;
}
CFont::~CFont() {
@ -149,12 +149,12 @@ std::size_t CFont::GetFontIdx(const std::string &name) const {
return fontindex.at(name);
}
void CFont::SetProps(const std::string &fontname, float size, const sf::Color& col) {
void CFont::SetProps(const std::string &fontname, unsigned int size, const sf::Color& col) {
SetProps(fontname, size);
curr_col = col;
}
void CFont::SetProps(const std::string &fontname, float size) {
void CFont::SetProps(const std::string &fontname, unsigned int size) {
curr_font = (int)GetFontIdx(fontname);
curr_size = size;
}
@ -179,23 +179,22 @@ void CFont::SetFontFromSettings() {
// -------------------- auto ------------------------------------------
int CFont::AutoSizeN(int rel_val) {
float size = (rel_val + 2) * 4;
size *= curr_fact;
size *= Winsys.scale;
unsigned int CFont::AutoSizeN(int rel_val) {
unsigned int size = (rel_val + 2) * 4;
size *= curr_fact * Winsys.scale;
SetSize(size);
return (int)size;
return size;
}
int CFont::AutoDistanceN(int rel_val) {
float fact = (rel_val + 5) * 0.2;
float fact = (rel_val + 5) * 0.2f;
float dist = curr_size * fact;
return (int) dist;
}
// -------------------- draw (x, y, text) -----------------------------
void CFont::DrawText(float x, float y, const sf::String& text, std::size_t font, float size) const {
void CFont::DrawText(float x, float y, const sf::String& text, std::size_t font, unsigned int size) const {
if (font >= fonts.size()) return;
sf::Text temp(text, *fonts[font], size);
@ -210,14 +209,14 @@ void CFont::DrawString(float x, float y, const sf::String &s) const {
DrawText(x, y, s, curr_font, curr_size);
}
void CFont::DrawString(float x, float y, const sf::String& s, const std::string &fontname, float size) const {
void CFont::DrawString(float x, float y, const sf::String& s, const std::string &fontname, unsigned int size) const {
DrawText(x, y, s, GetFontIdx(fontname), size);
}
// --------------------- metrics --------------------------------------
void CFont::GetTextSize(const sf::String& text, float &x, float &y, std::size_t font, float size) const {
void CFont::GetTextSize(const sf::String& text, float &x, float &y, std::size_t font, unsigned int size) const {
if (font >= fonts.size()) { x = 0; y = 0; return; }
sf::Text temp(text, *fonts[font], size);
@ -225,7 +224,7 @@ void CFont::GetTextSize(const sf::String& text, float &x, float &y, std::size_t
y = temp.getGlobalBounds().height;
}
void CFont::GetTextSize(const sf::String& text, float &x, float &y, const std::string &fontname, float size) const {
void CFont::GetTextSize(const sf::String& text, float &x, float &y, const std::string &fontname, unsigned int size) const {
GetTextSize(text, x, y, GetFontIdx(fontname), size);
}
@ -239,7 +238,7 @@ float CFont::GetTextWidth(const sf::String& text) const {
return x;
}
float CFont::GetTextWidth(const sf::String& text, const std::string &fontname, float size) const {
float CFont::GetTextWidth(const sf::String& text, const std::string &fontname, unsigned int size) const {
std::size_t temp_font = GetFontIdx(fontname);
float x, y;
GetTextSize(text, x, y, temp_font, size);

View File

@ -33,13 +33,13 @@ private:
std::vector<sf::Font*> fonts;
std::map<std::string, std::size_t> fontindex;
int curr_font;
int curr_font;
sf::Color curr_col;
float curr_size;
float curr_fact; // the length factor
unsigned int curr_size;
float curr_fact; // the length factor
void DrawText(float x, float y, const sf::String& text, std::size_t font, float size) const;
void GetTextSize(const sf::String& text, float &x, float &y, std::size_t font, float size) const;
void DrawText(float x, float y, const sf::String& text, std::size_t font, unsigned int size) const;
void GetTextSize(const sf::String& text, float &x, float &y, std::size_t font, unsigned int size) const;
public:
CFont();
~CFont();
@ -50,29 +50,29 @@ public:
bool LoadFontlist();
std::size_t GetFontIdx(const std::string &name) const;
const sf::Font& getCurrentFont() const { return *fonts[curr_font]; }
float GetSize() const { return curr_size; }
unsigned int GetSize() const { return curr_size; }
// properties
void SetProps(const std::string &fontname, float size, const sf::Color& col);
void SetProps(const std::string &fontname, float size);
void SetProps(const std::string &fontname, unsigned int size, const sf::Color& col);
void SetProps(const std::string &fontname, unsigned int size);
void SetColor(const sf::Color& col) { curr_col = col; }
void SetSize(float size) { curr_size = size; }
void SetSize(unsigned int size) { curr_size = size; }
void SetFont(const std::string& fontname);
void SetFontFromSettings();
// auto
int AutoSizeN(int rel_val); // rel_val = relative size, return: autosize
int AutoDistanceN(int rel_val); // rel_val = relative dist
unsigned int AutoSizeN(int rel_val); // rel_val = relative size, return: autosize
int AutoDistanceN(int rel_val); // rel_val = relative dist
// draw
void DrawString(float x, float y, const sf::String &s) const; // sf::String class
void DrawString(float x, float y, const sf::String &s, const std::string &fontname, float size) const;
void DrawString(float x, float y, const sf::String &s, const std::string &fontname, unsigned int size) const;
// metrics
void GetTextSize(const sf::String& text, float &x, float &y) const;
void GetTextSize(const sf::String& text, float &x, float &y, const std::string &fontname, float size) const;
void GetTextSize(const sf::String& text, float &x, float &y, const std::string &fontname, unsigned int size) const;
float GetTextWidth(const sf::String& text) const;
float GetTextWidth(const sf::String& text, const std::string &fontname, float size) const;
float GetTextWidth(const sf::String& text, const std::string &fontname, unsigned int size) const;
std::vector<std::string> MakeLineList(const char *source, float width);
};

View File

@ -70,18 +70,18 @@ void GameOverMessage(const CControl *ctrl) {
int topframe = 80;
const sf::Color& backcol = colWhite;
static const sf::Color framecol(0.7*255, 0.7*255, 1*255);
static const sf::Color framecol(178, 178, 255);
if (param.use_papercut_font > 0) FT.SetSize(28);
else FT.SetSize(22);
if (g_game.raceaborted) {
DrawFrameX(leftframe, topframe, fwidth, 100, 4, backcol, framecol, 0.5);
DrawFrameX(leftframe, topframe, fwidth, 100, 4, backcol, framecol, 0.5f);
FT.SetColor(colDBlue);
FT.DrawString(CENTER, topframe+30, Trans.Text(25));
} else {
int firstMarker = leftframe + 60;
int secondMarker = leftframe + 310;
DrawFrameX(leftframe, topframe, fwidth, 210, 4, backcol, framecol, 0.5);
DrawFrameX(leftframe, topframe, fwidth, 210, 4, backcol, framecol, 0.5f);
if (param.use_papercut_font > 0) FT.SetSize(20);
else FT.SetSize(14);

View File

@ -104,7 +104,7 @@ void CGameTypeSelect::Enter() {
ResetGUI();
int top = AutoYPosN(40);
int siz = FT.AutoSizeN(6);
unsigned int siz = FT.AutoSizeN(6);
int dist = FT.AutoDistanceN(2);
textbuttons[0] = AddTextButton(Trans.Text(1), CENTER, top, siz);
textbuttons[1] = AddTextButton(Trans.Text(2), CENTER, top + dist, siz);

View File

@ -108,7 +108,7 @@ TLabel* AddLabel(const sf::String& string, int x, int y, const sf::Color& color)
}
TFramedText::TFramedText(int x, int y, int width, int height, int line, const sf::Color& backcol, const sf::String& string, float ftsize, bool borderFocus_)
TFramedText::TFramedText(int x, int y, int width, int height, int line, const sf::Color& backcol, const sf::String& string, unsigned int ftsize, bool borderFocus_)
: TWidget(x, y, width, height, false)
, frame(sf::Vector2f(width - line * 2, height - line * 2))
, text(string, FT.getCurrentFont(), ftsize)
@ -151,19 +151,19 @@ void TFramedText::Draw() const {
Winsys.draw(text);
}
TFramedText* AddFramedText(int x, int y, int width, int height, int line, const sf::Color& backcol, const sf::String& text, float ftsize, bool borderFocus) {
TFramedText* AddFramedText(int x, int y, int width, int height, int line, const sf::Color& backcol, const sf::String& text, unsigned int ftsize, bool borderFocus) {
return static_cast<TFramedText*>(AddWidget(new TFramedText(x, y, width, height, line, backcol, text, ftsize, borderFocus)));
}
TTextButton::TTextButton(int x, int y, const sf::String& text_, float ftsize)
TTextButton::TTextButton(int x, int y, const sf::String& text_, int ftsize)
: TWidget(x, y, 0, 0)
, text(text_, FT.getCurrentFont(), ftsize) {
if (ftsize < 0) text.setCharacterSize(FT.AutoSizeN(4));
float len = text.getLocalBounds().width;
if (x == CENTER) position.x = (int)((Winsys.resolution.width - len) / 2);
int len = text.getLocalBounds().width;
if (x == CENTER) position.x = (Winsys.resolution.width - len) / 2;
text.setPosition(position.x, position.y);
int offs = (int)(ftsize / 5);
int offs = ftsize / 5;
mouseRect.left = position.x-20;
mouseRect.top = position.y+offs;
mouseRect.width = len+40;
@ -181,12 +181,12 @@ void TTextButton::Draw() const {
Winsys.draw(text);
}
TTextButton* AddTextButton(const sf::String& text, int x, int y, float ftsize) {
TTextButton* AddTextButton(const sf::String& text, int x, int y, int ftsize) {
return static_cast<TTextButton*>(AddWidget(new TTextButton(x, y, text, ftsize)));
}
TTextButton* AddTextButtonN(const sf::String& text, int x, int y, int rel_ftsize) {
double siz = FT.AutoSizeN(rel_ftsize);
unsigned int siz = FT.AutoSizeN(rel_ftsize);
return AddTextButton(text, x, y, siz);
}
@ -227,7 +227,7 @@ void TTextField::TextEnter(char key) {
void TTextField::SetCursorPos(std::size_t new_pos) {
cursorPos = new_pos;
int x = mouseRect.left + 20 - 2;
float x = mouseRect.left + 20 - 2;
if (cursorPos != 0) {
// substring() is very new addition to SFML2 string class, so
// for compatibility with older version we use std::string to do it.
@ -344,14 +344,14 @@ TCheckbox* AddCheckbox(int x, int y, int width, const sf::String& tag) {
return static_cast<TCheckbox*>(AddWidget(new TCheckbox(x, y, width, tag)));
}
TIconButton::TIconButton(int x, int y, const sf::Texture& texture, double size_, int max_, int value_)
TIconButton::TIconButton(int x, int y, const sf::Texture& texture, float size_, int max_, int value_)
: TWidget(x, y, 32, 32)
, sprite(texture)
, frame(sf::Vector2f(size_, size_))
, size(size_)
, maximum(max_)
, value(value_) {
sprite.setScale(size / (texture.getSize().x / 2.0), size / (texture.getSize().y / 2.0));
sprite.setScale(size / (texture.getSize().x / 2.f), size / (texture.getSize().y / 2.f));
sprite.setPosition(x, y);
frame.setPosition(x, y);
frame.setOutlineColor(colWhite);
@ -369,16 +369,16 @@ void TIconButton::SetValue(int _value) {
sf::Vector2u texSize = sprite.getTexture()->getSize();
switch (value) {
case 0:
sprite.setTextureRect(sf::IntRect(0, 0, texSize.x / 2.0, texSize.y / 2.0));
sprite.setTextureRect(sf::IntRect(0, 0, texSize.x / 2, texSize.y / 2));
break;
case 1:
sprite.setTextureRect(sf::IntRect(texSize.x / 2.0, 0, texSize.x / 2.0, texSize.y / 2.0));
sprite.setTextureRect(sf::IntRect(texSize.x / 2, 0, texSize.x / 2, texSize.y / 2));
break;
case 2:
sprite.setTextureRect(sf::IntRect(0, texSize.y / 2.0, texSize.x / 2.0, texSize.y / 2.0));
sprite.setTextureRect(sf::IntRect(0, texSize.y / 2, texSize.x / 2, texSize.y / 2));
break;
case 3:
sprite.setTextureRect(sf::IntRect(texSize.x / 2.0, texSize.y / 2.0, texSize.x / 2.0, texSize.y / 2.0));
sprite.setTextureRect(sf::IntRect(texSize.x / 2, texSize.y / 2, texSize.x / 2, texSize.y / 2));
break;
}
}
@ -413,7 +413,7 @@ void TIconButton::Key(sf::Keyboard::Key key, bool released) {
}
}
TIconButton* AddIconButton(int x, int y, const sf::Texture& texture, double size, int maximum, int value) {
TIconButton* AddIconButton(int x, int y, const sf::Texture& texture, float size, int maximum, int value) {
locked_UD = true;
return static_cast<TIconButton*>(AddWidget(new TIconButton(x, y, texture, size, maximum, value)));
}
@ -437,8 +437,8 @@ void TArrow::Activated() {
}
void TArrow::SetTexture() {
static const float textl[6] = { 0.5, 0.0, 0.5, 0.5, 0.0, 0.5 };
static const float texbr[6] = { 0.50, 0.50, 0.00, 0.75, 0.75, 0.25 };
static const float textl[6] = { 0.5f, 0.f, 0.5f, 0.5f, 0.f, 0.5f };
static const float texbr[6] = { 0.5f, 0.5f, 0.f, 0.75f, 0.75f, 0.25f };
int type = 0;
if (active)
@ -449,7 +449,7 @@ void TArrow::SetTexture() {
type += 3;
sf::Vector2u texSize = sprite.getTexture()->getSize();
sprite.setTextureRect(sf::IntRect(textl[type] * texSize.x, texbr[type] * texSize.y, 0.5 * texSize.x, 0.25 * texSize.y));
sprite.setTextureRect(sf::IntRect(textl[type] * texSize.x, texbr[type] * texSize.y, texSize.x / 2, texSize.y / 4));
}
void TArrow::Draw() const {
@ -549,7 +549,7 @@ TUpDown* AddUpDown(int x, int y, int minimum, int maximum, int value, int distan
// ------------------ Elementary drawing ---------------------------------------------
void DrawFrameX(int x, int y, int w, int h, int line, const sf::Color& backcol, const sf::Color& framecol, double transp) {
void DrawFrameX(int x, int y, int w, int h, int line, const sf::Color& backcol, const sf::Color& framecol, float transp) {
x += line;
y += line;
w -= line * 2;
@ -583,7 +583,7 @@ void DrawBonusExt(int y, std::size_t numraces, std::size_t num) {
static sf::Sprite tuxbonus(Tex.GetSFTexture(TUXBONUS));
sf::Vector2u size = tuxbonus.getTexture()->getSize();
tuxbonus.setTextureRect(sf::IntRect(0, 0, size.x, 0.5*size.y));
tuxbonus.setTextureRect(sf::IntRect(0, 0, size.x, size.y/2));
for (std::size_t i=0; i<maxtux; i++) {
std::size_t majr = (i/numraces);

View File

@ -84,22 +84,22 @@ class TFramedText : public TWidget {
sf::Text text;
bool borderFocus;
public:
TFramedText(int x, int y, int width, int height, int line, const sf::Color& backcol, const sf::String& string, float ftsize, bool borderFocus_ = false);
TFramedText(int x, int y, int width, int height, int line, const sf::Color& backcol, const sf::String& string, unsigned int ftsize, bool borderFocus_ = false);
void Focussed(bool masterFocus);
void Activated();
void Draw() const;
void SetString(const sf::String& string) { text.setString(string); }
};
TFramedText* AddFramedText(int x, int y, int width, int height, int line, const sf::Color& backcol, const sf::String& text, float ftsize, bool borderFocus = false);
TFramedText* AddFramedText(int x, int y, int width, int height, int line, const sf::Color& backcol, const sf::String& text, unsigned int ftsize, bool borderFocus = false);
class TTextButton : public TWidget {
sf::Text text;
public:
TTextButton(int x, int y, const sf::String& text_, float ftsize);
TTextButton(int x, int y, const sf::String& text_, int ftsize);
void Focussed();
void Draw() const;
};
TTextButton* AddTextButton(const sf::String& text, int x, int y, float ftsize);
TTextButton* AddTextButton(const sf::String& text, int x, int y, int ftsize);
TTextButton* AddTextButtonN(const sf::String& text, int x, int y, int rel_ftsize);
class TTextField : public TWidget {
@ -142,11 +142,11 @@ TCheckbox* AddCheckbox(int x, int y, int width, const sf::String& tag);
class TIconButton : public TWidget {
sf::Sprite sprite;
sf::RectangleShape frame;
double size;
float size;
int maximum;
int value;
public:
TIconButton(int x, int y, const sf::Texture& texture, double size_, int max_, int value_);
TIconButton(int x, int y, const sf::Texture& texture, float size_, int max_, int value_);
int GetValue() const { return value; }
void SetValue(int _value);
void Draw() const;
@ -154,7 +154,7 @@ public:
bool Click(int x, int y);
void Key(sf::Keyboard::Key key, bool released);
};
TIconButton* AddIconButton(int x, int y, const sf::Texture& texture, double size, int maximum, int value);
TIconButton* AddIconButton(int x, int y, const sf::Texture& texture, float size, int maximum, int value);
class TArrow : public TWidget {
sf::Sprite sprite;
@ -202,7 +202,7 @@ void ResetGUI();
// --------------------------------------------------------------------
void DrawFrameX(int x, int y, int w, int h, int line,
const sf::Color& backcol, const sf::Color& framecol, double transp);
const sf::Color& backcol, const sf::Color& framecol, float transp);
void DrawBonusExt(int y, std::size_t numraces, std::size_t num);
void DrawGUIBackground(float scale);
void DrawGUIFrame();

View File

@ -47,10 +47,10 @@ GNU General Public License for more details.
#define SPEEDBAR_RED_FRACTION 0.25
#define CIRCLE_DIVISIONS 10
static const GLfloat energy_background_color[] = { 0.2, 0.2, 0.2, 0.0 };
static const GLfloat energy_foreground_color[] = { 0.54, 0.59, 1.00, 0.5 };
static const GLfloat speedbar_background_color[] = { 0.2, 0.2, 0.2, 0.0 };
static const GLfloat hud_white[] = { 1.0, 1.0, 1.0, 1.0 };
static const GLubyte energy_background_color[] = { 51, 51, 51, 0 };
static const GLubyte energy_foreground_color[] = { 138, 150, 255, 128 };
static const GLubyte speedbar_background_color[] = { 51, 51, 51, 0 };
static const GLubyte hud_white[] = { 255, 255, 255, 255 };
static void draw_time() {
Tex.Draw(T_TIME, 10, 10, 1);
@ -66,7 +66,7 @@ static void draw_time() {
if (param.use_papercut_font < 2) {
Tex.DrawNumStr(timestr, 50, 12, 1, colWhite);
Tex.DrawNumStr(hundrstr, 170, 12, 0.7, colWhite);
Tex.DrawNumStr(hundrstr, 170, 12, 0.7f, colWhite);
} else {
Winsys.beginSFML();
FT.SetColor(colDYell);
@ -126,8 +126,8 @@ void draw_partial_tri_fan(double fraction) {
}
void draw_gauge(double speed, double energy) {
static const GLfloat xplane[4] = {1.0 / GAUGE_IMG_SIZE, 0.0, 0.0, 0.0 };
static const GLfloat yplane[4] = {0.0, 1.0 / GAUGE_IMG_SIZE, 0.0, 0.0 };
static const GLfloat xplane[4] = {1.f / GAUGE_IMG_SIZE, 0.f, 0.f, 0.f };
static const GLfloat yplane[4] = {0.f, 1.f / GAUGE_IMG_SIZE, 0.f, 0.f };
ScopedRenderMode rm(GAUGE_BARS);
@ -142,27 +142,27 @@ void draw_gauge(double speed, double energy) {
glPushMatrix();
glTranslatef(Winsys.resolution.width - GAUGE_WIDTH, 0, 0);
Tex.BindTex(GAUGE_ENERGY);
double y = ENERGY_GAUGE_BOTTOM + energy * ENERGY_GAUGE_HEIGHT;
float y = ENERGY_GAUGE_BOTTOM + energy * ENERGY_GAUGE_HEIGHT;
const GLfloat vtx1 [] = {
0.0, y,
0.f, y,
GAUGE_IMG_SIZE, y,
GAUGE_IMG_SIZE, GAUGE_IMG_SIZE,
0.0, GAUGE_IMG_SIZE
0.f, GAUGE_IMG_SIZE
};
const GLfloat vtx2 [] = {
0.0, 0.0,
GAUGE_IMG_SIZE, 0.0,
0.f, 0.f,
GAUGE_IMG_SIZE, 0.f,
GAUGE_IMG_SIZE, y,
0.0, y
0.f, y
};
glEnableClientState(GL_VERTEX_ARRAY);
glColor4fv(energy_background_color);
glColor4ubv(energy_background_color);
glVertexPointer(2, GL_FLOAT, 0, vtx1);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glColor4fv(energy_foreground_color);
glColor4ubv(energy_foreground_color);
glVertexPointer(2, GL_FLOAT, 0, vtx2);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
@ -189,13 +189,13 @@ void draw_gauge(double speed, double energy) {
speedbar_frac += speed/SPEEDBAR_GREEN_MAX_SPEED * SPEEDBAR_GREEN_FRACTION;
}
glColor4fv(speedbar_background_color);
glColor4ubv(speedbar_background_color);
Tex.BindTex(GAUGE_SPEED);
draw_partial_tri_fan(1.0);
glColor4fv(hud_white);
glColor4ubv(hud_white);
draw_partial_tri_fan(min(1.0, speedbar_frac));
glColor4fv(hud_white);
glColor4ubv(hud_white);
Tex.BindTex(GAUGE_OUTLINE);
static const GLshort vtx3 [] = {
0, 0,
@ -240,10 +240,10 @@ void DrawWind(float dir, float speed, const CControl *ctrl) {
alpha = speed / 50;
red = 0;
} else {
alpha = 1.0;
alpha = 1.f;
red = (speed - 50) / 50;
}
blue = 1.0 - red;
blue = 1.f - red;
glPushMatrix();
glColor4f(red, 0, blue, alpha);

View File

@ -50,8 +50,8 @@ void CLoading::Loop(float time_step) {
}
sf::Sprite logo(Tex.GetSFTexture(TEXLOGO));
logo.setScale(0.35, 0.35);
logo.setPosition((Winsys.resolution.width - logo.getTextureRect().width*0.35) / 2, 40);
logo.setScale(0.35f, 0.35f);
logo.setPosition((Winsys.resolution.width - logo.getTextureRect().width*0.35f) / 2, 40);
Winsys.draw(logo);
DrawGUIFrame();

View File

@ -70,7 +70,7 @@ TGuiParticle::TGuiParticle(float x, float y) {
const sf::Texture& texture = Tex.GetSFTexture(SNOW_PART);
sprite.setTexture(texture);
sprite.setPosition(x*static_cast<float>(Winsys.resolution.width), y*static_cast<float>(Winsys.resolution.height));
sprite.setColor(sf::Color(255, 255, 255, 0.3 * 255));
sprite.setColor(sf::Color(255, 255, 255, 76));
double p_dist = FRandom();
size = PARTICLE_MIN_SIZE + (1.0 - p_dist) * PARTICLE_SIZE_RANGE;
@ -942,15 +942,15 @@ void CWind::SetParams(int grade) {
max_base_speed = 35;
min_speed_var = 20;
max_speed_var = 20;
params.minChange = 0.1;
params.maxChange = 0.3;
params.minChange = 0.1f;
params.maxChange = 0.3f;
min_base_angle = 70;
max_base_angle = 110;
min_angle_var = 0;
max_angle_var = 90;
params.minAngleChange = 0.1;
params.maxAngleChange = 1.0;
params.minAngleChange = 0.1f;
params.maxAngleChange = 1.0f;
params.topSpeed = 100;
params.topProbability = 0;
@ -961,15 +961,15 @@ void CWind::SetParams(int grade) {
max_base_speed = 60;
min_speed_var = 40;
max_speed_var = 40;
params.minChange = 0.1;
params.maxChange = 0.5;
params.minChange = 0.1f;
params.maxChange = 0.5f;
min_base_angle = 70;
max_base_angle = 110;
min_angle_var = 0;
max_angle_var = 90;
params.minAngleChange = 0.1;
params.maxAngleChange = 1.0;
params.minAngleChange = 0.1f;
params.maxAngleChange = 1.0f;
params.topSpeed = 100;
params.topProbability = 0;
@ -980,15 +980,15 @@ void CWind::SetParams(int grade) {
max_base_speed = 80;
min_speed_var = 30;
max_speed_var = 60;
params.minChange = 0.1;
params.maxChange = 1.0;
params.minChange = 0.1f;
params.maxChange = 1.0f;
min_base_angle = 0;
max_base_angle = 180;
min_angle_var = 180;
max_angle_var = 360;
params.minAngleChange = 0.1;
params.maxAngleChange = 1.0;
params.minAngleChange = 0.1f;
params.maxAngleChange = 1.0f;
params.topSpeed = 100;
params.topProbability = 10;

View File

@ -208,9 +208,9 @@ float quadsquare::RecomputeError(const quadcornerdata& cd) {
std::size_t numTerr = Course.TerrList.size();
if (cd.ChildIndex & 1) {
e = fabs(Vertex[0].Y - (cd.Verts[1].Y + cd.Verts[3].Y) * 0.5);
e = fabs(Vertex[0].Y - (cd.Verts[1].Y + cd.Verts[3].Y) * 0.5f);
} else {
e = fabs(Vertex[0].Y - (cd.Verts[0].Y + cd.Verts[2].Y) * 0.5);
e = fabs(Vertex[0].Y - (cd.Verts[0].Y + cd.Verts[2].Y) * 0.5f);
}
if (e > maxerror) maxerror = e;
@ -224,11 +224,11 @@ float quadsquare::RecomputeError(const quadcornerdata& cd) {
}
e = fabs(Vertex[1].Y - (cd.Verts[0].Y + cd.Verts[3].Y) * 0.5);
e = fabs(Vertex[1].Y - (cd.Verts[0].Y + cd.Verts[3].Y) * 0.5f);
if (e > maxerror) maxerror = e;
Error[0] = e;
e = fabs(Vertex[4].Y - (cd.Verts[2].Y + cd.Verts[3].Y) * 0.5);
e = fabs(Vertex[4].Y - (cd.Verts[2].Y + cd.Verts[3].Y) * 0.5f);
if (e > maxerror) maxerror = e;
Error[1] = e;
@ -322,7 +322,7 @@ float quadsquare::RecomputeError(const quadcornerdata& cd) {
if (Child[i]->MaxY > MaxY) MaxY = Child[i]->MaxY;
} else {
Error[i+2] = fabs((Vertex[0].Y + cd.Verts[i].Y)
- (Vertex[i+1].Y + Vertex[((i+1)&3) + 1].Y)) * 0.25;
- (Vertex[i+1].Y + Vertex[((i+1)&3) + 1].Y)) * 0.25f;
}
if (Error[i+2] > maxerror) maxerror = Error[i+2];
}
@ -414,7 +414,7 @@ void quadsquare::StaticCullAux(const quadcornerdata& cd, float ThresholdDetail,
}
return;
}
float size = 2 << cd.Level; // Edge length.
float size = 2 << cd.Level; // Edge length.
if (Child[0] == nullptr && Child[3] == nullptr && Error[0] * ThresholdDetail < size) {
quadsquare* s = GetNeighbor(0, cd);
if (s == nullptr || (s->Child[1] == nullptr && s->Child[2] == nullptr)) {
@ -587,9 +587,9 @@ bool quadsquare::VertexTest(int x, float y, int z, float error,
}
bool quadsquare::BoxTest(int x, int z, float size, float miny, float maxy, float error, const float Viewer[3]) {
float half = size * 0.5;
float half = size * 0.5f;
float dx = (fabs(x + half - Viewer[0]) - half) * fabs(ScaleX);
float dy = fabs((miny + maxy) * 0.5 - Viewer[1]) - (maxy - miny) * 0.5;
float dy = fabs((miny + maxy) * 0.5f - Viewer[1]) - (maxy - miny) * 0.5f;
float dz = (fabs(z + half - Viewer[2]) - half) * fabs(ScaleZ);
float d = max(dx, max(dy , dz));

View File

@ -210,7 +210,7 @@ void CRaceSelect::Loop(float timestep) {
if ((*Course.currentCourseList)[course->GetValue()].preview)
(*Course.currentCourseList)[course->GetValue()].preview->DrawFrame(area.left + 3, prevtop, prevwidth, prevheight, 3, colWhite);
DrawFrameX(area.right-boxwidth, prevtop-3, boxwidth, prevheight+6, 3, colBackgr, colWhite, 1.0);
DrawFrameX(area.right-boxwidth, prevtop-3, boxwidth, prevheight+6, 3, colBackgr, colWhite, 1.f);
FT.AutoSizeN(2);
FT.SetColor(colWhite);
int dist = FT.AutoDistanceN(0);

View File

@ -185,12 +185,12 @@ static int CalcSoundVol(float fact) {
}
static void SetSoundVolumes() {
Sound.SetVolume("pickup1", CalcSoundVol(1.0));
Sound.SetVolume("pickup2", CalcSoundVol(0.8));
Sound.SetVolume("pickup3", CalcSoundVol(0.8));
Sound.SetVolume("snow_sound", CalcSoundVol(1.5));
Sound.SetVolume("ice_sound", CalcSoundVol(0.6));
Sound.SetVolume("rock_sound", CalcSoundVol(1.1));
Sound.SetVolume("pickup1", CalcSoundVol(1.0f));
Sound.SetVolume("pickup2", CalcSoundVol(0.8f));
Sound.SetVolume("pickup3", CalcSoundVol(0.8f));
Sound.SetVolume("snow_sound", CalcSoundVol(1.5f));
Sound.SetVolume("ice_sound", CalcSoundVol(0.6f));
Sound.SetVolume("rock_sound", CalcSoundVol(1.1f));
}
// ---------------------------- init ----------------------------------
@ -255,7 +255,7 @@ static void PlayTerrainSound(CControl *ctrl, bool airborne) {
} else newsound = -1;
} else newsound = -1;
if ((newsound != lastsound) && (lastsound >= 0)) Sound.Halt(lastsound);
if (newsound >= 0) Sound.Play(newsound, -1);
if (newsound >= 0) Sound.Play(newsound, true);
lastsound = newsound;
}

View File

@ -30,7 +30,7 @@ struct TScore {
int herrings;
float time;
TScore(const std::string& player_ = emptyString, int points_ = 0, int herrings_ = 0, double time_ = 0)
TScore(const std::string& player_ = emptyString, int points_ = 0, int herrings_ = 0, float time_ = 0)
: player(player_), points(points_), herrings(herrings_), time(time_)
{}
};

View File

@ -155,7 +155,7 @@ void TTexture::DrawFrame(int x, int y, int w, int h, int frame, const sf::Color&
if (h < 1) h = texture.getSize().y;
if (frame > 0)
DrawFrameX(x - frame, y - frame, w + 2 * frame, h + 2 * frame, frame, colTransp, col, 1.0);
DrawFrameX(x - frame, y - frame, w + 2 * frame, h + 2 * frame, frame, colTransp, col, 1.f);
sf::Sprite temp(texture);
temp.setPosition(x, y);

View File

@ -173,12 +173,12 @@ void CharKeys(sf::Keyboard::Key key, bool release, int x, int y) {
break;
case sf::Keyboard::Add:
case sf::Keyboard::Equal: // zoom in
zposition += 0.1;
xposition -= 0.03;
zposition += 0.1f;
xposition -= 0.03f;
break;
case sf::Keyboard::Dash: // zoom out
zposition -= 0.1;
xposition += 0.03;
zposition -= 0.1f;
xposition += 0.03f;
break;
// set rotations for view
@ -262,11 +262,11 @@ void CharMouse(int button, int state, int x, int y) {
startposy = yposition;
moveactive = true;
} else if (button == 4) {
zposition -= 0.1;
xposition += 0.03;
zposition -= 0.1f;
xposition += 0.03f;
} else if (button == 5) {
zposition += 0.1;
xposition -= 0.03;
zposition += 0.1f;
xposition -= 0.03f;
}
}

View File

@ -48,8 +48,8 @@ static const sf::Color shad_col(0, 0, 0, 76);
static const sf::Color shad_col(0, 0, 0, 25);
#endif
static const TCharMaterial TuxDefMat = { sf::Color(0.5 * 255, 0.5 * 255, 0.5 * 255), colBlack, 0.0 };
static const TCharMaterial Highlight = { sf::Color(0.8 * 255, 0.15 * 255, 0.15 * 255), colBlack, 0.0 };
static const TCharMaterial TuxDefMat = { sf::Color(128, 128, 128), colBlack, 0.0 };
static const TCharMaterial Highlight = { sf::Color(204, 38, 38), colBlack, 0.0 };
CCharShape TestChar;
CCharShape::CCharShape() {

View File

@ -34,7 +34,7 @@ GNU General Public License for more details.
#define BEHIND_ORIENT_TIME_CONSTANT 0.06
#define FOLLOW_ORBIT_TIME_CONSTANT 0.06
#define FOLLOW_ORIENT_TIME_CONSTANT 0.06
#define MAX_INTERPOLATION_VALUE 0.3
#define MAX_INTERPOLATION_VALUE 0.3f
#define BASELINE_INTERPOLATION_SPEED 4.5
#define NO_INTERPOLATION_SPEED 2.0
#define CAMERA_DISTANCE_INCREMENT 2
@ -65,7 +65,7 @@ void set_view_mode(CControl *ctrl, TViewMode mode) {ctrl->viewmode = mode;}
TVector3d interpolate_view_pos(const TVector3d& ctrl_pos1, const TVector3d& ctrl_pos2,
double max_vec_angle,
const TVector3d& pos1, const TVector3d& pos2,
double dist, double dt,
double dist, float dt,
float time_constant) {
static TVector3d y_vec(0.0, 1.0, 0.0);
@ -77,7 +77,7 @@ TVector3d interpolate_view_pos(const TVector3d& ctrl_pos1, const TVector3d& ctrl
TQuaternion q1 = MakeRotationQuaternion(y_vec, vec1);
TQuaternion q2 = MakeRotationQuaternion(y_vec, vec2);
double alpha = min(MAX_INTERPOLATION_VALUE, 1.0 - exp(-dt / time_constant));
double alpha = min(MAX_INTERPOLATION_VALUE, 1.f - exp(-dt / time_constant));
q2 = InterpolateQuaternions(q1, q2, alpha);
vec2 = RotateVector(q2, y_vec);
@ -164,7 +164,7 @@ TVector3d MakeViewVector() {
return TVector3d(0, camera_distance * sin(rad), camera_distance * cos(rad));
}
void update_view(CControl *ctrl, double dt) {
void update_view(CControl *ctrl, float dt) {
if (is_stationary) {
glLoadMatrix(stationary_matrix);
return;

View File

@ -22,7 +22,7 @@ GNU General Public License for more details.
#include "mathlib.h"
void set_view_mode(CControl *ctrl, TViewMode mode);
void update_view(CControl *ctrl, double dt);
void update_view(CControl *ctrl, float dt);
void SetStationaryCamera(bool stat); // 0 follow, 1 stationary
void IncCameraDistance(float timestep);