~ubuntu-branches/ubuntu/raring/simutrans/raring-proposed

« back to all changes in this revision

Viewing changes to gui/message_stats_t.cc

  • Committer: Package Import Robot
  • Author(s): Ansgar Burchardt
  • Date: 2011-11-03 19:59:02 UTC
  • mfrom: (1.2.7)
  • Revision ID: package-import@ubuntu.com-20111103195902-uopgwf488mfctb75
Tags: 111.0-1
* New upstream release.
* debian/rules: Update get-orig-source target for new upstream release.
* Use xz compression for source and binary packages.
* Use override_* targets to simplify debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
                if(  msg_type==-1  ) {
46
46
                        // case : no message filtering
47
47
                        message_list = &(msg->get_list());
48
 
                        set_groesse( koord(600, min(2000, last_count) * BUTTON_HEIGHT + 1) );
 
48
                        recalc_size();
49
49
                }
50
50
                else {
51
51
                        // case : filter messages belonging to the specified type
56
56
                                        filtered_messages.append( *iter );
57
57
                                }
58
58
                        }
59
 
                        set_groesse( koord(600, min(2000, filtered_messages.get_count()) * BUTTON_HEIGHT + 1) );
 
59
                        recalc_size();
60
60
                }
61
61
                return true;
62
62
        }
72
72
{
73
73
        message_selected = -1;
74
74
        if(  ev->button_state>0  &&  ev->cx>=2  &&  ev->cx<=12  ) {
75
 
                message_selected = ev->cy/BUTTON_HEIGHT;
 
75
                message_selected = ev->cy/(LINESPACE+1);
76
76
        }
77
77
 
78
78
        if(  IS_LEFTRELEASE(ev)  ) {
79
 
                sint32 line = ev->cy/BUTTON_HEIGHT;
 
79
                sint32 line = ev->cy/(LINESPACE+1);
80
80
                if(  (uint32)line<message_list->get_count()  ) {
81
81
                        message_t::node &n = *(message_list->at(line));
82
82
                        if(  ev->cx>=2  &&  ev->cx<=12  &&  welt->ist_in_kartengrenzen(n.pos)  ) {
97
97
        }
98
98
        else if(  IS_RIGHTRELEASE(ev)  ) {
99
99
                // just reposition
100
 
                sint32 line = ev->cy/BUTTON_HEIGHT;
 
100
                sint32 line = ev->cy/(LINESPACE+1);
101
101
                if(  (uint32)line<message_list->get_count()  ) {
102
102
                        message_t::node &n = *(message_list->at(line));
103
103
                        if(  welt->ist_in_kartengrenzen(n.pos)  ) {
109
109
}
110
110
 
111
111
 
 
112
void message_stats_t::recalc_size()
 
113
{
 
114
        sint16 x_size = 0;
 
115
        sint16 y_size = 0;
 
116
 
 
117
        // loop copied from ::zeichnen(), trimmed to minimum for x_size calculation
 
118
 
 
119
        for(  slist_tpl<message_t::node *>::const_iterator iter=message_list->begin(), end=message_list->end();  iter!=end;  ++iter, y_size+=(LINESPACE+1)  ) {
 
120
                const message_t::node &n = *(*iter);
 
121
 
 
122
                // add time
 
123
                char time[64];
 
124
                switch (umgebung_t::show_month) {
 
125
                        case umgebung_t::DATE_FMT_GERMAN:
 
126
                        case umgebung_t::DATE_FMT_GERMAN_NO_SEASON:
 
127
                                sprintf(time, "(%d.%d)", (n.time%12)+1, n.time/12 );
 
128
                                break;
 
129
 
 
130
                        case umgebung_t::DATE_FMT_MONTH:
 
131
                        case umgebung_t::DATE_FMT_US:
 
132
                        case umgebung_t::DATE_FMT_US_NO_SEASON:
 
133
                                sprintf(time, "(%d/%d)", (n.time%12)+1, n.time/12 );
 
134
                                break;
 
135
 
 
136
                        case umgebung_t::DATE_FMT_JAPANESE:
 
137
                        case umgebung_t::DATE_FMT_JAPANESE_NO_SEASON:
 
138
                                sprintf(time, "(%d/%d)", n.time/12, (n.time%12)+1 );
 
139
                                break;
 
140
 
 
141
                        default:
 
142
                                time[0] = 0;
 
143
                }
 
144
                KOORD_VAL left = 14;
 
145
                if(  time[0]  ) {
 
146
                        left += proportional_string_width(time)+8;
 
147
                }
 
148
 
 
149
                char buf[256];
 
150
                for(  int j=0;  j<256;  ++j  ) {
 
151
                        buf[j] = (n.msg[j]=='\n')?' ':n.msg[j];
 
152
                        if(  buf[j]==0  ) {
 
153
                                break;
 
154
                        }
 
155
                }
 
156
 
 
157
                left += proportional_string_width(buf);
 
158
                if(  left>x_size  ) {
 
159
                        x_size = left;
 
160
                }
 
161
        }
 
162
 
 
163
        set_groesse(koord(x_size+4,y_size));
 
164
}
 
165
 
 
166
 
112
167
/**
113
168
 * Now draw the list
114
169
 * @author prissi
121
176
                if(  message_type==-1  ) {
122
177
                        // no message filtering -> only update last count and component size
123
178
                        last_count = new_count;
124
 
                        set_groesse( koord(600, min(2000, last_count) * BUTTON_HEIGHT + 1) );
 
179
                        recalc_size();
125
180
                }
126
181
                else {
127
182
                        // incrementally add new entries to filtered message list before recalculating component size, and update last count
134
189
                                }
135
190
                        }
136
191
                        // insert new messages to old messages
137
 
                        while(  temp_list.get_count()>0  ) {
 
192
                        while (!temp_list.empty()) {
138
193
                                filtered_messages.insert( temp_list.remove_first() );
139
194
                        }
140
195
                        last_count = new_count;
141
 
                        set_groesse( koord(600, min(2000, filtered_messages.get_count()) * BUTTON_HEIGHT + 1) );
 
196
                        recalc_size();
142
197
                }
143
198
        }
144
199
 
145
200
        struct clip_dimension cd = display_get_clip_wh();
146
 
        sint16 y = offset.y+1;
 
201
        sint16 y = offset.y+2;
147
202
 
148
 
        for(  slist_tpl<message_t::node *>::const_iterator iter=message_list->begin(), end=message_list->end();  iter!=end;  ++iter, y+=BUTTON_HEIGHT  ) {
 
203
        // changes to loop affecting x_size must be copied to ::recalc_size()
 
204
        for(  slist_tpl<message_t::node *>::const_iterator iter=message_list->begin(), end=message_list->end();  iter!=end;  ++iter, y+=(LINESPACE+1)  ) {
149
205
 
150
206
                if(  y<cd.y  ) {
151
207
                        // below the top
159
215
                // goto information
160
216
                if(  n.pos!=koord::invalid  ) {
161
217
                        // goto button
162
 
                        display_color_img( message_selected!=((y-offset.y)/BUTTON_HEIGHT) ? button_t::arrow_right_normal : button_t::arrow_right_pushed, offset.x + 4, y, 0, false, true);
 
218
                        display_color_img( message_selected!=((y-offset.y)/(LINESPACE+1)) ? button_t::arrow_right_normal : button_t::arrow_right_pushed, offset.x + 2, y, 0, false, true);
163
219
                }
164
220
 
165
221
                // correct for player color