Merge pull request #803 from c64kernal/dev_hud

Fixed two issues with HUD sliders.
This commit is contained in:
David G Yu 2016-06-23 09:54:33 -07:00 committed by GitHub
commit 15a40ecc68
2 changed files with 4 additions and 3 deletions

View File

@ -528,7 +528,7 @@ Hud::Rebuild(int width, int height, int framebufferWidth, int framebufferHeight)
x = drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_SLIDER_MIDDLE);
}
drawChar(_staticVboSource, x, y, 1, 1, 1, FONT_SLIDER_RIGHT);
int pos = (int)((it->value/float(it->max-it->min))*it->w);
int pos = int(((it->value-it->min)/(it->max-it->min))*float(it->w));
drawChar(_staticVboSource, sx+pos, y, 1, 1, 0, FONT_SLIDER_CURSOR);
}
// draw pulldowns

View File

@ -127,11 +127,12 @@ protected:
bool intStep;
void SetValue(float v) {
value = std::max(std::min(v, max), min);
v = std::max(std::min(v, max), min);
if (intStep) {
// MSVC 2010 does not have std::round() or roundf()
value = v>0.0f ? floor(v+0.5f) : ceil(v-0.5f);
v = v>0.0f ? floor(v+0.5f) : ceil(v-0.5f);
}
value = v;
}
};