Fix compilation under MSVC
Use template for std::min and std::max
This commit is contained in:
parent
b61f509755
commit
ca2fe9cf45
|
@ -128,7 +128,7 @@ void Creature::internalDrawOutfit(Point dest, float scaleFactor, bool animateWal
|
|||
dest -= datType->getDisplacement() * scaleFactor;
|
||||
datType->draw(dest, scaleFactor, 0, xPattern, 0, 0, animationPhase, lightView);
|
||||
dest += getDisplacement() * scaleFactor;
|
||||
zPattern = std::min(1, getNumPatternZ() - 1);
|
||||
zPattern = std::min<int>(1, getNumPatternZ() - 1);
|
||||
}
|
||||
|
||||
PointF jumpOffset = m_jumpOffset * scaleFactor;
|
||||
|
@ -183,7 +183,7 @@ void Creature::internalDrawOutfit(Point dest, float scaleFactor, bool animateWal
|
|||
}
|
||||
|
||||
if(m_outfit.getCategory() == ThingCategoryEffect)
|
||||
animationPhase = std::min(animationPhase+1, animationPhases);
|
||||
animationPhase = std::min<int>(animationPhase+1, animationPhases);
|
||||
|
||||
type->draw(dest - (getDisplacement() * scaleFactor), scaleFactor, 0, 0, 0, 0, animationPhase, lightView);
|
||||
}
|
||||
|
@ -480,7 +480,7 @@ void Creature::updateWalkAnimation(int totalPixelsWalked)
|
|||
if(!self->m_walking || self->m_walkTimer.ticksElapsed() >= self->getStepDuration(true))
|
||||
self->m_walkAnimationPhase = 0;
|
||||
self->m_walkFinishAnimEvent = nullptr;
|
||||
}, std::min(footDelay, 200));
|
||||
}, std::min<int>(footDelay, 200));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -553,7 +553,7 @@ void Creature::nextWalkUpdate()
|
|||
void Creature::updateWalk()
|
||||
{
|
||||
float walkTicksPerPixel = getStepDuration(true) / 32;
|
||||
int totalPixelsWalked = std::min(m_walkTimer.ticksElapsed() / walkTicksPerPixel, 32.0f);
|
||||
int totalPixelsWalked = std::min<int>(m_walkTimer.ticksElapsed() / walkTicksPerPixel, 32.0f);
|
||||
|
||||
// needed for paralyze effect
|
||||
m_walkedPixels = std::max<int>(m_walkedPixels, totalPixelsWalked);
|
||||
|
|
|
@ -170,7 +170,7 @@ bool Texture::setupSize(const Size& size, bool forcePowerOfTwo)
|
|||
glSize = size;
|
||||
|
||||
// checks texture max size
|
||||
if(std::max(glSize.width(), glSize.height()) > g_graphics.getMaxTextureSize()) {
|
||||
if(std::max<int>(glSize.width(), glSize.height()) > g_graphics.getMaxTextureSize()) {
|
||||
g_logger.error(stdext::format("loading texture with size %dx%d failed, "
|
||||
"the maximum size allowed by the graphics card is %dx%d,"
|
||||
"to prevent crashes the texture will be displayed as a blank texture",
|
||||
|
|
|
@ -66,10 +66,10 @@ bool UIHorizontalLayout::internalUpdate()
|
|||
pos.y = paddingRect.top() + widget->getMarginTop();
|
||||
} else if(widget->getTextAlign() & Fw::AlignBottom) {
|
||||
pos.y = paddingRect.bottom() - widget->getHeight() - widget->getMarginBottom();
|
||||
pos.y = std::max(pos.y, paddingRect.top());
|
||||
pos.y = std::max<int>(pos.y, paddingRect.top());
|
||||
} else { // center it
|
||||
pos.y = paddingRect.top() + (paddingRect.height() - (widget->getMarginTop() + widget->getHeight() + widget->getMarginBottom()))/2;
|
||||
pos.y = std::max(pos.y, paddingRect.top());
|
||||
pos.y = std::max<int>(pos.y, paddingRect.top());
|
||||
}
|
||||
} else {
|
||||
// expand height
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
virtual void addWidget(const UIWidgetPtr& widget) { }
|
||||
virtual void removeWidget(const UIWidgetPtr& widget) { }
|
||||
void disableUpdates() { m_updateDisabled++; }
|
||||
void enableUpdates() { m_updateDisabled = std::max(m_updateDisabled-1,0); }
|
||||
void enableUpdates() { m_updateDisabled = std::max<int>(m_updateDisabled-1,0); }
|
||||
|
||||
void setParent(UIWidgetPtr parentWidget) { m_parentWidget = parentWidget; }
|
||||
UIWidgetPtr getParentWidget() { return m_parentWidget; }
|
||||
|
|
|
@ -181,15 +181,15 @@ void UITextEdit::update(bool focusCursor)
|
|||
if(!virtualRect.contains(glyphRect.topLeft()) || !virtualRect.contains(glyphRect.bottomRight())) {
|
||||
// calculate where is the first glyph visible
|
||||
Point startGlyphPos;
|
||||
startGlyphPos.y = std::max(glyphRect.bottom() - virtualRect.height(), 0);
|
||||
startGlyphPos.x = std::max(glyphRect.right() - virtualRect.width(), 0);
|
||||
startGlyphPos.y = std::max<int>(glyphRect.bottom() - virtualRect.height(), 0);
|
||||
startGlyphPos.x = std::max<int>(glyphRect.right() - virtualRect.width(), 0);
|
||||
|
||||
// find that glyph
|
||||
for(pos = 0; pos < textLength; ++pos) {
|
||||
glyph = (uchar)text[pos];
|
||||
glyphRect = Rect(glyphsPositions[pos], glyphsSize[glyph]);
|
||||
glyphRect.setTop(std::max(glyphRect.top() - m_font->getYOffset() - m_font->getGlyphSpacing().height(), 0));
|
||||
glyphRect.setLeft(std::max(glyphRect.left() - m_font->getGlyphSpacing().width(), 0));
|
||||
glyphRect.setTop(std::max<int>(glyphRect.top() - m_font->getYOffset() - m_font->getGlyphSpacing().height(), 0));
|
||||
glyphRect.setLeft(std::max<int>(glyphRect.left() - m_font->getGlyphSpacing().width(), 0));
|
||||
|
||||
// first glyph entirely visible found
|
||||
if(glyphRect.topLeft() >= startGlyphPos) {
|
||||
|
@ -358,8 +358,8 @@ void UITextEdit::setSelection(int start, int end)
|
|||
if(end == -1)
|
||||
end = m_text.length();
|
||||
|
||||
m_selectionStart = std::min(std::max(start, 0), (int)m_text.length());
|
||||
m_selectionEnd = std::min(std::max(end, 0), (int)m_text.length());
|
||||
m_selectionStart = std::min<int>(std::max<int>(start, 0), (int)m_text.length());
|
||||
m_selectionEnd = std::min<int>(std::max<int>(end, 0), (int)m_text.length());
|
||||
}
|
||||
|
||||
void UITextEdit::setTextHidden(bool hidden)
|
||||
|
|
|
@ -68,10 +68,10 @@ bool UIVerticalLayout::internalUpdate()
|
|||
pos.x = paddingRect.left() + widget->getMarginLeft();
|
||||
} else if(widget->getTextAlign() & Fw::AlignLeft) {
|
||||
pos.x = paddingRect.bottom() - widget->getHeight() - widget->getMarginBottom();
|
||||
pos.x = std::max(pos.x, paddingRect.left());
|
||||
pos.x = std::max<int>(pos.x, paddingRect.left());
|
||||
} else {
|
||||
pos.x = paddingRect.left() + (paddingRect.width() - (widget->getMarginLeft() + widget->getWidth() + widget->getMarginRight()))/2;
|
||||
pos.x = std::max(pos.x, paddingRect.left());
|
||||
pos.x = std::max<int>(pos.x, paddingRect.left());
|
||||
}
|
||||
} else {
|
||||
// expand width
|
||||
|
|
|
@ -192,7 +192,7 @@ void UIWidget::insertChild(int index, const UIWidgetPtr& child)
|
|||
|
||||
if(!(index >= 0 && (uint)index <= m_children.size())) {
|
||||
//g_logger.traceWarning("attempt to insert a child UIWidget into an invalid index, using nearest index...");
|
||||
index = std::min(std::max(index, 0), (int)m_children.size());
|
||||
index = std::min<int>(std::max<int>(index, 0), (int)m_children.size());
|
||||
}
|
||||
|
||||
// retrieve child by index
|
||||
|
|
|
@ -346,7 +346,7 @@ public:
|
|||
void setPaddingRight(int padding) { m_padding.right = padding; updateLayout(); }
|
||||
void setPaddingBottom(int padding) { m_padding.bottom = padding; updateLayout(); }
|
||||
void setPaddingLeft(int padding) { m_padding.left = padding; updateLayout(); }
|
||||
void setOpacity(float opacity) { m_opacity = std::min(std::max(opacity, 0.0f), 1.0f); }
|
||||
void setOpacity(float opacity) { m_opacity = std::min<float>(std::max<float>(opacity, 0.0f), 1.0f); }
|
||||
void setRotation(float degrees) { m_rotation = degrees; }
|
||||
|
||||
int getX() { return m_rect.x(); }
|
||||
|
|
|
@ -221,10 +221,10 @@ public:
|
|||
|
||||
TRect<T> united(const TRect<T> &r) const {
|
||||
TRect<T> tmp;
|
||||
tmp.x1 = std::min(x1, r.x1);
|
||||
tmp.x2 = std::max(x2, r.x2);
|
||||
tmp.y1 = std::min(y1, r.y1);
|
||||
tmp.y2 = std::max(y2, r.y2);
|
||||
tmp.x1 = std::min<T>(x1, r.x1);
|
||||
tmp.x2 = std::max<T>(x2, r.x2);
|
||||
tmp.y1 = std::min<T>(y1, r.y1);
|
||||
tmp.y2 = std::max<T>(y2, r.y2);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
@ -263,10 +263,10 @@ public:
|
|||
b2 = r.y2;
|
||||
|
||||
TRect<T> tmp;
|
||||
tmp.x1 = std::max(l1, l2);
|
||||
tmp.x2 = std::min(r1, r2);
|
||||
tmp.y1 = std::max(t1, t2);
|
||||
tmp.y2 = std::min(b1, b2);
|
||||
tmp.x1 = std::max<int>(l1, l2);
|
||||
tmp.x2 = std::min<int>(r1, r2);
|
||||
tmp.y1 = std::max<int>(t1, t2);
|
||||
tmp.y2 = std::min<int>(b1, b2);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,8 +70,8 @@ public:
|
|||
bool operator==(const TSize<T>& other) const { return other.wd==wd && other.ht==ht; }
|
||||
bool operator!=(const TSize<T>& other) const { return other.wd!=wd || other.ht!=ht; }
|
||||
|
||||
TSize<T> expandedTo(const TSize<T>& other) const { return TSize<T>(std::max(wd,other.wd), std::max(ht,other.ht)); }
|
||||
TSize<T> boundedTo(const TSize<T>& other) const { return TSize<T>(std::min(wd,other.wd), std::min(ht,other.ht)); }
|
||||
TSize<T> expandedTo(const TSize<T>& other) const { return TSize<T>(std::max<T>(wd, other.wd), std::max<T>(ht, other.ht)); }
|
||||
TSize<T> boundedTo(const TSize<T>& other) const { return TSize<T>(std::min<T>(wd, other.wd), std::min<T>(ht, other.ht)); }
|
||||
|
||||
void scale(const TSize<T>& s, Fw::AspectRatioMode mode) {
|
||||
if(mode == Fw::IgnoreAspectRatio || wd == 0 || ht == 0) {
|
||||
|
|
Loading…
Reference in New Issue