src/Graphics/PlayerInfoView.cc
author Tero Marttila <terom@fixme.fi>
Wed, 21 Jan 2009 23:07:22 +0200
branchnew_graphics
changeset 412 721c60072091
parent 411 106aaf6eadfe
child 413 7dddc163489a
permissions -rw-r--r--
new graphics code compiles... no, it doesn't work yet
410
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
411
106aaf6eadfe there's a grain of truth in the new graphics code now...
Tero Marttila <terom@fixme.fi>
parents: 410
diff changeset
     2
#include "PlayerInfoView.hh"
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
     3
#include "Graphics.hh"
410
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
#include <sstream>
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
namespace graphics
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
{
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    10
void PlayerInfoView::draw (Display &display) {
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    11
    CL_GraphicContext *gc = display.get_gc();
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    12
    CL_Font font = graphics->fonts.getSimpleFont();
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    13
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    14
    int bar_length = 3;
410
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    15
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    16
    // draw status info at bottom of display
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    17
    gc->fill_rect(
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    18
        CL_Rect(area.left, area.top, area.right, area.bottom),
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    19
        CL_Gradient(
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    20
            CL_Color(0, 0, 0),
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    21
            CL_Color(50, 50, 50),
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    22
            CL_Color(50, 50, 50, 150),
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    23
            CL_Color(100, 100, 100, 200)
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    24
        )
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    25
    );
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    26
    
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    27
    // Health
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    28
    double health_percent = player->getHealthPercent();
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    29
410
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    30
    gc->draw_rect(
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    31
        CL_Rect(
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    32
            area.left + 9,
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    33
            area.top + 9,
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    34
            area.left + 11 + 100 * bar_length,
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    35
            area.top + 31
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    36
        ),
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    37
        CL_Color(150, 150, 150)
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    38
    );
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    39
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    40
    gc->fill_rect(
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    41
        CL_Rect(
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    42
            area.left + 10,
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    43
            area.top + 10,
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    44
            area.left + 10 + (int) (health_percent * bar_length),
410
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    45
            area.top + 30
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    46
        ),
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    47
        CL_Gradient(
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    48
            CL_Color(200, 0, 0),
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    49
            CL_Color(200 - (int)(health_percent * 2), (int)(health_percent * 2), 0),
410
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    50
            CL_Color(200, 0, 0),
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    51
            CL_Color(200 - (int)(health_percent * 2), (int)(health_percent * 2), 0)
410
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    52
        )
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    53
    );
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    54
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    55
    // stats - kills
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    56
    std::stringstream sskills;
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    57
    sskills << "Kills:  " << player->getKills();
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    58
    font.draw(
410
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    59
        area.left + 20 + 100 * bar_length,
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    60
        area.top + 10,
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    61
        sskills.str(),
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    62
        display.get_gc()
410
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    63
    );
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    64
    
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    65
    // stats - deaths
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    66
    std::stringstream ssdeaths;
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    67
    ssdeaths << "Deaths:  " << player->getDeaths();
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    68
    font.draw(
410
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    69
        area.left + 20 + 100 * bar_length,
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    70
        area.top + 30,
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    71
        ssdeaths.str(),
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    72
        display.get_gc()
410
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    73
    );
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    74
    
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    75
    // stats - ratio
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    76
    std::stringstream ssratio;
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    77
    ssratio << "Ratio:  " << (player->getKills() + 1) / (player->getDeaths() + 1);
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    78
    font.draw(
410
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    79
        area.left + 20 + 100 * bar_length,
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    80
        area.top + 50,
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    81
        ssratio.str(),
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
    82
        display.get_gc()
410
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    83
    );
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    84
    
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    85
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    86
    // Weapon clip / reloading
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    87
    gc->draw_rect(
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    88
        CL_Rect(
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    89
            area.left + 9,
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    90
            area.top + 69,
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    91
            area.left + 11 + 100 * bar_length,
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    92
            area.top + 91
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    93
        ),
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    94
        CL_Color(150, 150, 150)
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    95
    );
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    96
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    97
    gc->fill_rect(
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    98
        CL_Rect(
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    99
            area.left + 10,
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   100
            area.top + 70,
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
   101
            area.left + 10 + (100 - (int) (
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
   102
                    player->getCurrentWeapon()->getReloadTimer() * 100 / player->getCurrentWeapon()->getReloadTime()
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
   103
            )) * bar_length,
410
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   104
            area.top + 90
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   105
        ),
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   106
        CL_Gradient(
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   107
            CL_Color(100, 100, 0),
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   108
            CL_Color(100, 100, 0),
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   109
            CL_Color(100, 100, 0),
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   110
            CL_Color(100, 100, 100)
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   111
        )
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   112
    );
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   113
   
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   114
    // current weapon name
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
   115
    font.draw(
410
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   116
        area.left + 20 + 100 * bar_length,
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   117
        area.top + 70,
412
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
   118
        player->getCurrentWeapon()->getName(),
721c60072091 new graphics code compiles... no, it doesn't work yet
Tero Marttila <terom@fixme.fi>
parents: 411
diff changeset
   119
        display.get_gc()
410
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   120
    );
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   121
}
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   122
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   123
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   124
41fd46cffc52 start working out the Graphics/* code, this is a long way from compiling, let alone working
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   125
}