Root/src/dialog.cpp

Source at commit 00d3c3b57008bddf8770c51271db9d766acaf854 created 7 years 5 months ago.
By Maarten ter Huurne, Gave Layer class a protected constructor
1#include <string>
2
3#include "dialog.h"
4#include "gmenu2x.h"
5#include "font.h"
6
7Dialog::Dialog(GMenu2X& gmenu2x) : gmenu2x(gmenu2x)
8{
9}
10
11void Dialog::drawTitleIcon(Surface& s, const std::string &icon, bool skinRes)
12{
13    Surface *i = NULL;
14    if (!icon.empty()) {
15        if (skinRes)
16            i = gmenu2x.sc.skinRes(icon);
17        else
18            i = gmenu2x.sc[icon];
19    }
20
21    if (i==NULL)
22        i = gmenu2x.sc.skinRes("icons/generic.png");
23
24    i->blit(s, 4, (gmenu2x.skinConfInt["topBarHeight"] - 32) / 2);
25}
26
27void Dialog::writeTitle(Surface& s, const std::string &title)
28{
29    gmenu2x.font->write(s, title, 40, 0, Font::HAlignLeft, Font::VAlignTop);
30}
31
32void Dialog::writeSubTitle(Surface& s, const std::string &subtitle)
33{
34    std::string wrapped = gmenu2x.font->wordWrap(subtitle, gmenu2x.resX - 48);
35    gmenu2x.font->write(s, wrapped, 40,
36            gmenu2x.skinConfInt["topBarHeight"]
37                - gmenu2x.font->getTextHeight(wrapped),
38            Font::HAlignLeft, Font::VAlignTop);
39}
40

Archive Download this file



interactive