fixed proper types for some calls in IMGUIControls.cc

main
Martin Felis (berta win) 2011-05-04 18:43:36 +02:00
parent c2ca0a1a4d
commit ef942fe580
1 changed files with 70 additions and 71 deletions

View File

@ -33,8 +33,8 @@ bool regionhit (int x, int y, int w, int h) {
} }
void DrawBlock (int x, int y, int w, int h) { void DrawBlock (int x, int y, int w, int h) {
const float shading_dark = 0.5; const float shading_dark = 0.5f;
const float shading_light = 1.3; const float shading_light = 1.3f;
float color[4]; float color[4];
glGetFloatv (GL_CURRENT_COLOR, color); glGetFloatv (GL_CURRENT_COLOR, color);
@ -42,10 +42,10 @@ void DrawBlock (int x, int y, int w, int h) {
glBegin(GL_QUADS); glBegin(GL_QUADS);
// middle part // middle part
glVertex3f (x, y, 0.); glVertex3i (x, y, 0);
glVertex3f (x, y + h, 0.); glVertex3i (x, y + h, 0);
glVertex3f (x + w, y + h, 0.); glVertex3i (x + w, y + h, 0);
glVertex3f (x + w, y, 0.); glVertex3i (x + w, y, 0);
glEnd(); glEnd();
@ -56,38 +56,38 @@ void DrawBlock (int x, int y, int w, int h) {
glColor3f (color[0] * shading_dark, color[1] * shading_dark, color[2] * shading_dark); glColor3f (color[0] * shading_dark, color[1] * shading_dark, color[2] * shading_dark);
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
glVertex3f (x,y + 2, 0.); glVertex3i (x, y + 2, 0);
glVertex3f (x,y +h, 0.); glVertex3i (x, y + h, 0);
glVertex3f (x + w - 2, y + h, 0.); glVertex3i (x + w - 2, y + h, 0);
glEnd(); glEnd();
} }
void DrawRoundedBlock (int x, int y, int w, int h) { void DrawRoundedBlock (int x, int y, int w, int h) {
const int d = 16; const int d = 16;
const float shading_dark = 0.5; const float shading_dark = 0.5f;
const float shading_light = 1.3; const float shading_light = 1.3f;
assert (h > d); assert (h > d);
assert (w > d); assert (w > d);
glBegin(GL_QUADS); glBegin(GL_QUADS);
// lower part // lower part
glVertex3f (x, y, 0.); glVertex3i (x, y, 0);
glVertex3f (x, y + d, 0.); glVertex3i (x, y + d, 0);
glVertex3f (x + w, y + d, 0.); glVertex3i (x + w, y + d, 0);
glVertex3f (x + w - d, y, 0.); glVertex3i (x + w - d, y, 0);
// middle part // middle part
glVertex3f (x, y + d, 0.); glVertex3i (x, y + d, 0);
glVertex3f (x, y + d + h - 2 * d, 0.); glVertex3i (x, y + d + h - 2 * d, 0);
glVertex3f (x + w, y + d + h - 2 * d, 0.); glVertex3i (x + w, y + d + h - 2 * d, 0);
glVertex3f (x + w, y + d, 0.); glVertex3i (x + w, y + d, 0);
// bottom part // bottom part
glVertex3f (x, y + h - d, 0.); glVertex3i (x, y + h - d, 0);
glVertex3f (x + d, y + h, 0.); glVertex3i (x + d, y + h, 0);
glVertex3f (x + w, y + h, 0.); glVertex3i (x + w, y + h, 0);
glVertex3f (x + w, y + h - d, 0.); glVertex3i (x + w, y + h - d, 0);
glEnd(); glEnd();
@ -99,16 +99,16 @@ void DrawRoundedBlock (int x, int y, int w, int h) {
glColor3f (color[0] * shading_dark, color[1] * shading_dark, color[2] * shading_dark); glColor3f (color[0] * shading_dark, color[1] * shading_dark, color[2] * shading_dark);
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
glVertex3f (x,y + 2, 0.); glVertex3i (x,y + 2, 0);
glVertex3f (x,y + h -d, 0.); glVertex3i (x,y + h - d, 0);
glVertex3f (x + d, y + h, 0.); glVertex3i (x + d, y + h, 0);
glVertex3f (x + w - 2, y + h, 0.); glVertex3i (x + w - 2, y + h, 0);
glEnd(); glEnd();
glColor3f (color[0] * shading_light, color[1] * shading_light, color[2] * shading_light); glColor3f (color[0] * shading_light, color[1] * shading_light, color[2] * shading_light);
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
glVertex3f (x + w - d, y, 0.); glVertex3i (x + w - d, y, 0);
glVertex3f (x + w, y + d, 0.); glVertex3i (x + w, y + d, 0);
glEnd(); glEnd();
glColor4fv (color); glColor4fv (color);
@ -137,12 +137,12 @@ void Label (int id, const char* caption, int x, int y) {
// we shift the gray a little left and up depending on the font size // we shift the gray a little left and up depending on the font size
font_spec << "console.ttf size=" << font_size << " color=#808080"; font_spec << "console.ttf size=" << font_size << " color=#808080";
SelectFont(font_spec.str().c_str()); SelectFont(font_spec.str().c_str());
view->DrawGLString(x - font_size / 20.f , y + height * 0.5 + font_size / 20.f, caption); view->DrawGLString(x - font_size / 20.f , y + height * 0.5f + font_size / 20.f, caption);
font_spec.str(""); font_spec.str("");
font_spec << "console.ttf size=" << font_size << " color=#ffffff"; font_spec << "console.ttf size=" << font_size << " color=#ffffff";
SelectFont(font_spec.str().c_str()); SelectFont(font_spec.str().c_str());
view->DrawGLString(x , y + height * 0.5, caption); view->DrawGLString(x , y + height * 0.5f, caption);
} }
} }
@ -171,12 +171,12 @@ void LabelCentered (int id, const char* caption, int x, int y) {
// we shift the gray a little left and up depending on the font size // we shift the gray a little left and up depending on the font size
font_spec << "console.ttf size=" << font_size << " color=#808080"; font_spec << "console.ttf size=" << font_size << " color=#808080";
SelectFont(font_spec.str().c_str()); SelectFont(font_spec.str().c_str());
view->DrawGLString(x - 0.5 * width - font_size / 20.f , y + height * 0.5 + font_size / 20.f, caption); view->DrawGLString(x - 0.5f * width - font_size / 20.f , y + height * 0.5f + font_size / 20.f, caption);
font_spec.str(""); font_spec.str("");
font_spec << "console.ttf size=" << font_size << " color=#ffffff"; font_spec << "console.ttf size=" << font_size << " color=#ffffff";
SelectFont(font_spec.str().c_str()); SelectFont(font_spec.str().c_str());
view->DrawGLString(x - 0.5 * width, y + height * 0.5, caption); view->DrawGLString(x - 0.5f * width, y + height * 0.5f, caption);
} }
} }
@ -213,20 +213,20 @@ bool Button (int id, const char* caption, int x, int y, int w, int h) {
} }
// Render // Render
glColor3f (0.2, 0.2, 0.2); glColor3f (0.2f, 0.2f, 0.2f);
// DrawRoundedBlock (x + 4, y + 4, w, h); // DrawRoundedBlock (x + 4, y + 4, w, h);
if (controller->uistate.hotitem == id if (controller->uistate.hotitem == id
|| controller->uistate.kbditem == id) { || controller->uistate.kbditem == id) {
if (controller->uistate.activeitem == id) { if (controller->uistate.activeitem == id) {
glColor3f (0.8, 0.8, 0.8); glColor3f (0.8f, 0.8f, 0.8f);
DrawRoundedBlock (x, y, w, h); DrawRoundedBlock (x, y, w, h);
} else { } else {
glColor3f (0.7, 0.7, 0.7); glColor3f (0.7f, 0.7f, 0.7f);
DrawRoundedBlock (x, y, w, h); DrawRoundedBlock (x, y, w, h);
} }
} else { } else {
glColor3f (0.4, 0.4, 0.4); glColor3f (0.4f, 0.4f, 0.4f);
DrawRoundedBlock (x, y, w, h); DrawRoundedBlock (x, y, w, h);
} }
@ -240,18 +240,18 @@ bool Button (int id, const char* caption, int x, int y, int w, int h) {
SelectFont("console.ttf size=23"); SelectFont("console.ttf size=23");
view->DrawGLStringMeasure(caption, &width, &height); view->DrawGLStringMeasure(caption, &width, &height);
float xpos = x + w * 0.5 - width * 0.5; float xpos = x + w * 0.5f - width * 0.5f;
float ypos = y + h * 0.5 - height * 0.5; float ypos = y + h * 0.5f - height * 0.5f;
// LogDebug ("measure '%s' width = %f height = %f", caption, width, height); // LogDebug ("measure '%s' width = %f height = %f", caption, width, height);
if (controller->uistate.hotitem == id || controller->uistate.kbditem == id) { if (controller->uistate.hotitem == id || controller->uistate.kbditem == id) {
SelectFont("console.ttf size=23 color=#666666"); SelectFont("console.ttf size=23 color=#666666");
view->DrawGLString( xpos - 2., ypos + 2., caption); view->DrawGLString( xpos - 2.f, ypos + 2.f, caption);
SelectFont("console.ttf size=23 color=#ffffff"); SelectFont("console.ttf size=23 color=#ffffff");
view->DrawGLString( xpos, ypos, caption); view->DrawGLString( xpos, ypos, caption);
} else { } else {
SelectFont("console.ttf size=23 color=#444444"); SelectFont("console.ttf size=23 color=#444444");
view->DrawGLString( xpos - 2., ypos + 2., caption); view->DrawGLString( xpos - 2.f, ypos + 2.f, caption);
SelectFont("console.ttf size=23 color=#b3b3b3"); SelectFont("console.ttf size=23 color=#b3b3b3");
view->DrawGLString( xpos, ypos, caption); view->DrawGLString( xpos, ypos, caption);
} }
@ -331,23 +331,23 @@ bool CheckButton (int id, const char* caption, bool checked, int x, int y, int w
// Render // Render
if (checked) { if (checked) {
glColor3f (0.91, 0.84, 0.); glColor3f (0.91f, 0.84f, 0.);
DrawRoundedBlock (x - 2, y - 2, w + 4, h + 4); DrawRoundedBlock (x - 2, y - 2, w + 4, h + 4);
} }
glColor3f (0.2, 0.2, 0.2); glColor3f (0.2f, 0.2f, 0.2f);
if (controller->uistate.hotitem == id if (controller->uistate.hotitem == id
|| controller->uistate.kbditem == id) { || controller->uistate.kbditem == id) {
if (controller->uistate.activeitem == id) { if (controller->uistate.activeitem == id) {
glColor3f (0.8, 0.8, 0.8); glColor3f (0.8f, 0.8f, 0.8f);
DrawRoundedBlock (x, y, w, h); DrawRoundedBlock (x, y, w, h);
} else { } else {
glColor3f (0.7, 0.7, 0.7); glColor3f (0.7f, 0.7f, 0.7f);
DrawRoundedBlock (x, y, w, h); DrawRoundedBlock (x, y, w, h);
} }
} else { } else {
glColor3f (0.4, 0.4, 0.4); glColor3f (0.4f, 0.4f, 0.4f);
DrawRoundedBlock (x, y, w, h); DrawRoundedBlock (x, y, w, h);
} }
@ -361,18 +361,18 @@ bool CheckButton (int id, const char* caption, bool checked, int x, int y, int w
SelectFont("console.ttf size=23"); SelectFont("console.ttf size=23");
view->DrawGLStringMeasure(caption, &width, &height); view->DrawGLStringMeasure(caption, &width, &height);
float xpos = x + w * 0.5 - width * 0.5; float xpos = x + w * 0.5f - width * 0.5f;
float ypos = y + h * 0.5 - height * 0.5; float ypos = y + h * 0.5f - height * 0.5f;
// LogDebug ("measure '%s' width = %f height = %f", caption, width, height); // LogDebug ("measure '%s' width = %f height = %f", caption, width, height);
if (controller->uistate.hotitem == id || controller->uistate.kbditem == id) { if (controller->uistate.hotitem == id || controller->uistate.kbditem == id) {
SelectFont("console.ttf size=23 color=#666666"); SelectFont("console.ttf size=23 color=#666666");
view->DrawGLString( xpos - 2., ypos + 2., caption); view->DrawGLString( xpos - 2.f, ypos + 2.f, caption);
SelectFont("console.ttf size=23 color=#ffffff"); SelectFont("console.ttf size=23 color=#ffffff");
view->DrawGLString( xpos, ypos, caption); view->DrawGLString( xpos, ypos, caption);
} else { } else {
SelectFont("console.ttf size=23 color=#444444"); SelectFont("console.ttf size=23 color=#444444");
view->DrawGLString( xpos - 2., ypos + 2., caption); view->DrawGLString( xpos - 2.f, ypos + 2.f, caption);
SelectFont("console.ttf size=23 color=#b3b3b3"); SelectFont("console.ttf size=23 color=#b3b3b3");
view->DrawGLString( xpos, ypos, caption); view->DrawGLString( xpos, ypos, caption);
} }
@ -465,14 +465,14 @@ bool LineEdit (int id, int x, int y, std::string &text_value, const int &maxleng
// If we have keyboard focus, we highlight the widget // If we have keyboard focus, we highlight the widget
if ( controller->uistate.kbditem == id) { if ( controller->uistate.kbditem == id) {
if (controller->uistate.activeitem == id) { if (controller->uistate.activeitem == id) {
glColor3f (0.8, 0.8, 0.8); glColor3f (0.8f, 0.8f, 0.8f);
DrawBlock (x, y, w, h); DrawBlock (x, y, w, h);
} else { } else {
glColor3f (0.7, 0.7, 0.7); glColor3f (0.7f, 0.7f, 0.7f);
DrawBlock (x, y, w, h); DrawBlock (x, y, w, h);
} }
} else { } else {
glColor3f (0.4, 0.4, 0.4); glColor3f (0.4f, 0.4f, 0.4f);
DrawBlock (x, y, w, h); DrawBlock (x, y, w, h);
} }
@ -481,7 +481,7 @@ bool LineEdit (int id, int x, int y, std::string &text_value, const int &maxleng
view = EngineGetView (); view = EngineGetView ();
assert (view); assert (view);
glColor3f (1., 1., 1.); glColor3f (1.f, 1.f, 1.f);
std::string text_output = text_value; std::string text_output = text_value;
@ -605,14 +605,14 @@ bool LineEditMasked (int id, int x, int y, std::string &text_value, const int &m
// If we have keyboard focus, we highlight the widget // If we have keyboard focus, we highlight the widget
if ( controller->uistate.kbditem == id) { if ( controller->uistate.kbditem == id) {
if (controller->uistate.activeitem == id) { if (controller->uistate.activeitem == id) {
glColor3f (0.8, 0.8, 0.8); glColor3f (0.8f, 0.8f, 0.8f);
DrawBlock (x, y, w, h); DrawBlock (x, y, w, h);
} else { } else {
glColor3f (0.7, 0.7, 0.7); glColor3f (0.7f, 0.7f, 0.7f);
DrawBlock (x, y, w, h); DrawBlock (x, y, w, h);
} }
} else { } else {
glColor3f (0.4, 0.4, 0.4); glColor3f (0.4f, 0.4f, 0.4f);
DrawBlock (x, y, w, h); DrawBlock (x, y, w, h);
} }
@ -621,7 +621,7 @@ bool LineEditMasked (int id, int x, int y, std::string &text_value, const int &m
view = EngineGetView (); view = EngineGetView ();
assert (view); assert (view);
glColor3f (1., 1., 1.); glColor3f (1.f, 1.f, 1.f);
std::string text_output = text_value; std::string text_output = text_value;
@ -725,7 +725,7 @@ float VerticalSlider (int id, int x, int y, int w, int h, float min_value, float
int slider_pos = (w * value) / max_value - knob_width / 2; int slider_pos = (w * value) / max_value - knob_width / 2;
// Check for hotness // Check for hotness
if (regionhit (x, y + h * 0.5 - knob_height * 0.5, w, knob_height)) { if (regionhit (x, y + h * 0.5f - knob_height * 0.5f, w, knob_height)) {
controller->uistate.hotitem = id; controller->uistate.hotitem = id;
if (controller->uistate.activeitem == 0 if (controller->uistate.activeitem == 0
&& controller->GetButtonState(MouseButtonLeft)) { && controller->GetButtonState(MouseButtonLeft)) {
@ -746,21 +746,21 @@ float VerticalSlider (int id, int x, int y, int w, int h, float min_value, float
// If we have keyboard focus, we highlight the widget // If we have keyboard focus, we highlight the widget
if ( controller->uistate.kbditem == id) { if ( controller->uistate.kbditem == id) {
if (controller->uistate.activeitem == id) { if (controller->uistate.activeitem == id) {
glColor3f (0.6, 0.6, 0.6); glColor3f (0.6f, 0.6f, 0.6f);
DrawBlock (x, y, w, h); DrawBlock (x, y, w, h);
glColor3f (0.8, 0.8, 0.8); glColor3f (0.8f, 0.8f, 0.8f);
DrawBlock (x + slider_pos, y + h * 0.5 - knob_height * 0.5, knob_width, knob_height); DrawBlock (x + slider_pos, y + h * 0.5f - knob_height * 0.5f, knob_width, knob_height);
} else { } else {
glColor3f (0.6, 0.6, 0.6); glColor3f (0.6f, 0.6f, 0.6f);
DrawBlock (x, y, w, h); DrawBlock (x, y, w, h);
glColor3f (0.7, 0.7, 0.7); glColor3f (0.7f, 0.7f, 0.7f);
DrawBlock (x + slider_pos, y + h * 0.5 - knob_height * 0.5, knob_width, knob_height); DrawBlock (x + slider_pos, y + h * 0.5f - knob_height * 0.5f, knob_width, knob_height);
} }
} else { } else {
glColor3f (0.4, 0.4, 0.4); glColor3f (0.4f, 0.4f, 0.4f);
DrawBlock (x, y, w, h); DrawBlock (x, y, w, h);
glColor3f (0.5, 0.5, 0.5); glColor3f (0.5f, 0.5f, 0.5f);
DrawBlock (x + slider_pos, y + h * 0.5 - knob_height * 0.5, knob_width, knob_height); DrawBlock (x + slider_pos, y + h * 0.5f - knob_height * 0.5f, knob_width, knob_height);
} }
if (controller->uistate.kbditem == id) { if (controller->uistate.kbditem == id) {
@ -776,14 +776,14 @@ float VerticalSlider (int id, int x, int y, int w, int h, float min_value, float
controller->uistate.last_keysym = SDLK_CLEAR; controller->uistate.last_keysym = SDLK_CLEAR;
break; break;
case SDLK_LEFT: case SDLK_LEFT:
value -= (max_value - min_value) * 0.1; value -= (max_value - min_value) * 0.1f;
if ( value < min_value) if ( value < min_value)
value = min_value; value = min_value;
controller->uistate.last_keysym = SDLK_CLEAR; controller->uistate.last_keysym = SDLK_CLEAR;
return true; return true;
break; break;
case SDLK_RIGHT: case SDLK_RIGHT:
value += (max_value - min_value) * 0.1; value += (max_value - min_value) * 0.1f;
if ( value > max_value) if ( value > max_value)
value = max_value; value = max_value;
controller->uistate.last_keysym = SDLK_CLEAR; controller->uistate.last_keysym = SDLK_CLEAR;
@ -831,6 +831,5 @@ bool CheckKeyPressed (int keycode) {
return false; return false;
} }
}; };
}; };