QTfrontend/ui/page/pagegamestats.cpp
changeset 14842 5443e5e0faa3
parent 14742 123aaa2bf4b5
child 14955 ef3352839616
equal deleted inserted replaced
14841:b9437746bffb 14842:5443e5e0faa3
    56 
    56 
    57     // details
    57     // details
    58     labelGameStats = new QLabel(this);
    58     labelGameStats = new QLabel(this);
    59     QLabel * l = new QLabel(this);
    59     QLabel * l = new QLabel(this);
    60     l->setTextFormat(Qt::RichText);
    60     l->setTextFormat(Qt::RichText);
    61     l->setText("<h1><img src=\":/res/StatsD.png\"> " + PageGameStats::tr("Details") + "</h1>");
    61     l->setText("<h1><img src=\":/res/StatsD.png\"> " + PageGameStats::tr("Details").toHtmlEscaped() + "</h1>");
    62     l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    62     l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    63     labelGameStats->setTextFormat(Qt::RichText);
    63     labelGameStats->setTextFormat(Qt::RichText);
    64     labelGameStats->setAlignment(Qt::AlignTop);
    64     labelGameStats->setAlignment(Qt::AlignTop);
    65     labelGameStats->setWordWrap(true);
    65     labelGameStats->setWordWrap(true);
    66     gbl->addWidget(l);
    66     gbl->addWidget(l);
    71     // graph
    71     // graph
    72     graphic = new FitGraphicsView(gb);
    72     graphic = new FitGraphicsView(gb);
    73     graphic->setObjectName("gameStatsView");
    73     graphic->setObjectName("gameStatsView");
    74     labelGraphTitle = new QLabel(this);
    74     labelGraphTitle = new QLabel(this);
    75     labelGraphTitle->setTextFormat(Qt::RichText);
    75     labelGraphTitle->setTextFormat(Qt::RichText);
    76     labelGraphTitle->setText("<br><h1><img src=\":/res/StatsH.png\"> " + PageGameStats::tr("Health graph") + "</h1>");
    76     labelGraphTitle->setText("<br><h1><img src=\":/res/StatsH.png\"> " + PageGameStats::tr("Health graph").toHtmlEscaped() + "</h1>");
    77     labelGraphTitle->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    77     labelGraphTitle->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    78     gbl->addWidget(labelGraphTitle);
    78     gbl->addWidget(labelGraphTitle);
    79     gbl->addWidget(graphic);
    79     gbl->addWidget(graphic);
    80     graphic->scale(1.0, -1.0);
    80     graphic->scale(1.0, -1.0);
    81     graphic->setBackgroundBrush(QBrush(Qt::black));
    81     graphic->setBackgroundBrush(QBrush(Qt::black));
    89     gb = new QGroupBox(this);
    89     gb = new QGroupBox(this);
    90     gbl = new QVBoxLayout;
    90     gbl = new QVBoxLayout;
    91     labelGameRank = new QLabel(gb);
    91     labelGameRank = new QLabel(gb);
    92     l = new QLabel(this);
    92     l = new QLabel(this);
    93     l->setTextFormat(Qt::RichText);
    93     l->setTextFormat(Qt::RichText);
    94     l->setText("<h1><img src=\":/res/StatsR.png\"> " + PageGameStats::tr("Ranking") + "</h1>");
    94     l->setText("<h1><img src=\":/res/StatsR.png\"> " + PageGameStats::tr("Ranking").toHtmlEscaped() + "</h1>");
    95     l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    95     l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    96     gbl->addWidget(l);
    96     gbl->addWidget(l);
    97     gbl->addWidget(labelGameRank);
    97     gbl->addWidget(labelGameRank);
    98     gb->setLayout(gbl);
    98     gb->setLayout(gbl);
    99 
    99 
   162 }
   162 }
   163 
   163 
   164 void PageGameStats::renderStats()
   164 void PageGameStats::renderStats()
   165 {
   165 {
   166     if(defaultGraphTitle) {
   166     if(defaultGraphTitle) {
   167         labelGraphTitle->setText("<br><h1><img src=\":/res/StatsH.png\"> " + PageGameStats::tr("Health graph") + "</h1>");
   167         labelGraphTitle->setText("<br><h1><img src=\":/res/StatsH.png\"> " + PageGameStats::tr("Health graph").toHtmlEscaped() + "</h1>");
   168     } else {
   168     } else {
   169         defaultGraphTitle = true;
   169         defaultGraphTitle = true;
   170     }
   170     }
   171     // if not health data sent
   171     // if not health data sent
   172     if(healthPoints.size() == 0) {
   172     if(healthPoints.size() == 0) {
   269 {
   269 {
   270     switch(type)
   270     switch(type)
   271     {
   271     {
   272         case 'r' :
   272         case 'r' :
   273         {
   273         {
   274             labelGameWin->setText(QString("<h1 align=\"center\">%1</h1>").arg(info));
   274             labelGameWin->setText(QString("<h1 align=\"center\">%1</h1>").arg(info.toHtmlEscaped()));
   275             break;
   275             break;
   276         }
   276         }
   277         case 'D' :
   277         case 'D' :
   278         {
   278         {
   279             int i = info.indexOf(' ');
   279             int i = info.indexOf(' ');
   280             int num = info.left(i).toInt();
   280             int num = info.left(i).toInt();
   281             QString message = "<p><img src=\":/res/StatsBestShot.png\"> " + PageGameStats::tr("The best shot award was won by <b>%1</b> with <b>%2</b> pts.", "", num).arg(info.mid(i + 1), info.left(i)) + "</p>";
   281             QString message = "<p><img src=\":/res/StatsBestShot.png\"> " + PageGameStats::tr("The best shot award was won by <b>%1</b> with <b>%2</b> pts.", "", num).arg(info.mid(i + 1).toHtmlEscaped(), info.left(i)) + "</p>";
   282             AddStatText(message);
   282             AddStatText(message);
   283             break;
   283             break;
   284         }
   284         }
   285         case 'k' :
   285         case 'k' :
   286         {
   286         {
   287             int i = info.indexOf(' ');
   287             int i = info.indexOf(' ');
   288             int num = info.left(i).toInt();
   288             int num = info.left(i).toInt();
   289             QString message = "<p><img src=\":/res/StatsBestKiller.png\"> " + PageGameStats::tr("The best killer is <b>%1</b> with <b>%2</b> kills in a turn.", "", num).arg(info.mid(i + 1), info.left(i)) + "</p>";
   289             QString message = "<p><img src=\":/res/StatsBestKiller.png\"> " + PageGameStats::tr("The best killer is <b>%1</b> with <b>%2</b> kills in a turn.", "", num).arg(info.mid(i + 1).toHtmlEscaped(), info.left(i)) + "</p>";
   290             AddStatText(message);
   290             AddStatText(message);
   291             break;
   291             break;
   292         }
   292         }
   293         case 'K' :
   293         case 'K' :
   294         {
   294         {
   307         }
   307         }
   308         case 'g' :
   308         case 'g' :
   309         {
   309         {
   310             // TODO: change default picture or add change pic capability
   310             // TODO: change default picture or add change pic capability
   311             defaultGraphTitle = false;
   311             defaultGraphTitle = false;
   312             labelGraphTitle->setText("<br><h1><img src=\":/res/StatsR.png\"> " + info + "</h1>");
   312             labelGraphTitle->setText("<br><h1><img src=\":/res/StatsR.png\"> " + info.toHtmlEscaped() + "</h1>");
   313             break;
   313             break;
   314         }
   314         }
   315         case 'T':   // local team stats
   315         case 'T':   // local team stats
   316         {
   316         {
   317             // unused
   317             // unused
   389                 //: For custom number of points in the stats screen, written after the team name. %1 is the number, %2 is the word. Example: “4 points”
   389                 //: For custom number of points in the stats screen, written after the team name. %1 is the number, %2 is the word. Example: “4 points”
   390                 killstring = PageGameStats::tr("(%1 %2)", "", kills).arg(kills).arg(kindOfPoints);
   390                 killstring = PageGameStats::tr("(%1 %2)", "", kills).arg(kills).arg(kindOfPoints);
   391             }
   391             }
   392             kindOfPoints = QString("");
   392             kindOfPoints = QString("");
   393 
   393 
   394             message = QString("<p><h2>%1 %2. <font color=\"%4\">%3</font> ").arg(image, QString::number(realPlayerPosition), playername, clanColor.name()) + killstring + "</h2></p>";
   394             message = QString("<p><h2>%1 %2. <font color=\"%4\">%3</font> ").arg(image, QString::number(realPlayerPosition), playername.toHtmlEscaped(), clanColor.name().toHtmlEscaped()) + killstring.toHtmlEscaped() + "</h2></p>";
   395 
   395 
   396             labelGameRank->setText(labelGameRank->text() + message);
   396             labelGameRank->setText(labelGameRank->text() + message);
   397             scriptPlayerPosition = 0;
   397             scriptPlayerPosition = 0;
   398             break;
   398             break;
   399         }
   399         }
   400         case 's' :
   400         case 's' :
   401         {
   401         {
   402             int i = info.indexOf(' ');
   402             int i = info.indexOf(' ');
   403             int num = info.left(i).toInt();
   403             int num = info.left(i).toInt();
   404             QString message = "<p><img src=\":/res/StatsMostSelfDamage.png\"> " + PageGameStats::tr("<b>%1</b> thought it's good to shoot their own hedgehogs for <b>%2</b> pts.", "", num).arg(info.mid(i + 1)).arg(num) + "</p>";
   404             QString message = "<p><img src=\":/res/StatsMostSelfDamage.png\"> " + PageGameStats::tr("<b>%1</b> thought it's good to shoot their own hedgehogs for <b>%2</b> pts.", "", num).arg(info.mid(i + 1).toHtmlEscaped()).arg(num) + "</p>";
   405             AddStatText(message);
   405             AddStatText(message);
   406             break;
   406             break;
   407         }
   407         }
   408         case 'S' :
   408         case 'S' :
   409         {
   409         {
   410             int i = info.indexOf(' ');
   410             int i = info.indexOf(' ');
   411             int num = info.left(i).toInt();
   411             int num = info.left(i).toInt();
   412             QString message = "<p><img src=\":/res/StatsSelfKilled.png\"> " + PageGameStats::tr("<b>%1</b> killed <b>%2</b> of their own hedgehogs.", "", num).arg(info.mid(i + 1)).arg(num) + "</p>";
   412             QString message = "<p><img src=\":/res/StatsSelfKilled.png\"> " + PageGameStats::tr("<b>%1</b> killed <b>%2</b> of their own hedgehogs.", "", num).arg(info.mid(i + 1).toHtmlEscaped()).arg(num) + "</p>";
   413             AddStatText(message);
   413             AddStatText(message);
   414             break;
   414             break;
   415         }
   415         }
   416         case 'B' :
   416         case 'B' :
   417         {
   417         {
   418             int i = info.indexOf(' ');
   418             int i = info.indexOf(' ');
   419             int num = info.left(i).toInt();
   419             int num = info.left(i).toInt();
   420             QString message = "<p><img src=\":/res/StatsSkipped.png\"> " + PageGameStats::tr("<b>%1</b> was scared and skipped turn <b>%2</b> times.", "", num).arg(info.mid(i + 1)).arg(num) + "</p>";
   420             QString message = "<p><img src=\":/res/StatsSkipped.png\"> " + PageGameStats::tr("<b>%1</b> was scared and skipped turn <b>%2</b> times.", "", num).arg(info.mid(i + 1).toHtmlEscaped()).arg(num) + "</p>";
   421             AddStatText(message);
   421             AddStatText(message);
   422             break;
   422             break;
   423         }
   423         }
   424         case 'c' :
   424         case 'c' :
   425         {
   425         {
   426             QString message = "<p><img src=\":/res/StatsCustomAchievement.png\"> "+info+" </p>";
   426             QString message = "<p><img src=\":/res/StatsCustomAchievement.png\"> "+info.toHtmlEscaped()+" </p>";
   427             AddStatText(message);
   427             AddStatText(message);
   428             break;
   428             break;
   429         }
   429         }
   430         case 'R' :
   430         case 'R' :
   431         {
   431         {
   432             scriptPlayerPosition = info.toInt();
   432             scriptPlayerPosition = info.toInt();
   433             break;
   433             break;
   434         }
   434         }
   435         case 'h' :
   435         case 'h' :
   436         {
   436         {
   437             QString message = "<p><img src=\":/res/StatsEverAfter.png\"> " + PageGameStats::tr("With everyone having the same clan color, there was no reason to fight. And so the hedgehogs happily lived in peace ever after.") + "</p>";
   437             QString message = "<p><img src=\":/res/StatsEverAfter.png\"> " + PageGameStats::tr("With everyone having the same clan color, there was no reason to fight. And so the hedgehogs happily lived in peace ever after.").toHtmlEscaped() + "</p>";
   438             AddStatText(message);
   438             AddStatText(message);
   439             break;
   439             break;
   440         }
   440         }
   441     }
   441     }
   442 }
   442 }