diff options
author | Chris West <therealchriswest@hotmail.com> | 2012-12-29 16:17:48 +0000 |
---|---|---|
committer | Chris West <therealchriswest@hotmail.com> | 2013-01-05 16:25:23 +0000 |
commit | 10e7a704c28f35be409b468c5881b81ed1c452a8 (patch) | |
tree | 0bba7a6daaee7fe3a23ed741bdc8e575c5e34962 /crawl-ref/source/tilereg-title.cc | |
parent | d11e3248a35dcfb6ad16f5dc28db7a0b8ad0c8d5 (diff) | |
download | crawl-ref-10e7a704c28f35be409b468c5881b81ed1c452a8.tar.gz crawl-ref-10e7a704c28f35be409b468c5881b81ed1c452a8.zip |
merge of small-screen changes from old build env
Diffstat (limited to 'crawl-ref/source/tilereg-title.cc')
-rw-r--r-- | crawl-ref/source/tilereg-title.cc | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/crawl-ref/source/tilereg-title.cc b/crawl-ref/source/tilereg-title.cc index 5479eb1293..d1c8318b4b 100644 --- a/crawl-ref/source/tilereg-title.cc +++ b/crawl-ref/source/tilereg-title.cc @@ -27,15 +27,42 @@ TitleRegion::TitleRegion(int width, int height, FontWrapper* font) : if (!m_img.load_texture(_get_title_image().c_str(), MIPMAP_NONE)) return; - // Center - wx = width; - wy = height; - ox = (wx - m_img.orig_width()) / 2; - oy = (wy - m_img.orig_height()) / 2; + if (m_img.orig_width() < width && m_img.orig_height() < height) + { + // Center + wx = width; + wy = height; + ox = (wx - m_img.orig_width()) / 2; + oy = (wy - m_img.orig_height()) / 2; - GLWPrim rect(0, 0, m_img.width(), m_img.height()); - rect.set_tex(0, 0, 1, 1); - m_buf.add_primitive(rect); + GLWPrim rect(0, 0, m_img.width(), m_img.height()); + rect.set_tex(0, 0, 1, 1); + m_buf.add_primitive(rect); + } + else + { + // scale to fit + if (width < height) + { + // taller than wide (scale to fit width; leave top/bottom borders) + ox = 0; + oy = (height - m_img.orig_height()*width/m_img.orig_width())/2; + wx = m_img.width()*width/m_img.orig_width(); + wy = m_img.height()*width/m_img.orig_width(); + } + else + { + // wider than tall (so scale to fit height; leave left/right borders) + oy = 0; + ox = (width - m_img.orig_width()*height/m_img.orig_height())/2; + wx = m_img.width()*height/m_img.orig_height(); + wy = m_img.height()*height/m_img.orig_height(); + } + + GLWPrim rect(0, 0, wx, wy); + rect.set_tex(0, 0, 1, 1); + m_buf.add_primitive(rect); + } } void TitleRegion::render() |