Skip to content

Commit

Permalink
ADD: goods waiting bar with now configurable: gui_waitingbar_width
Browse files Browse the repository at this point in the history
git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@8923 8aca7d54-2c30-db11-9de9-000461428c89
  • Loading branch information
prissi committed Feb 16, 2020
1 parent 499863c commit 3290d8f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
5 changes: 5 additions & 0 deletions gui/gui_theme.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ scr_size gui_theme_t::gui_label_size;
scr_size gui_theme_t::gui_edit_size;
scr_size gui_theme_t::gui_gadget_size;
scr_size gui_theme_t::gui_indicator_size;
KOORD_VAL gui_theme_t::gui_waitingbar_width;

scr_coord gui_theme_t::gui_focus_offset;
scr_coord gui_theme_t::gui_button_text_offset_right;
scr_coord gui_theme_t::gui_color_button_text_offset_right;
Expand Down Expand Up @@ -195,6 +197,7 @@ void gui_theme_t::init_gui_defaults()
gui_frame_bottom = 10;
gui_hspace = 4;
gui_vspace = 4;
gui_waitingbar_width = 4;
gui_divider_size.h = D_V_SPACE*2;

gui_drop_shadows = false;
Expand Down Expand Up @@ -500,6 +503,8 @@ bool gui_theme_t::themes_init(const char *file_name, bool init_fonts )
gui_theme_t::gui_highlight_color = (PIXVAL)contents.get_color("gui_highlight_color", SYSCOL_HIGHLIGHT);
gui_theme_t::gui_shadow_color = (PIXVAL)contents.get_color("gui_shadow_color", SYSCOL_SHADOW);

gui_theme_t::gui_waitingbar_width = (uint32)contents.get_int("gui_waitingbar_width", gui_theme_t::gui_waitingbar_width);

// those two may be rather an own control later on?
gui_theme_t::gui_indicator_size = contents.get_scr_size("gui_indicator_size", gui_theme_t::gui_indicator_size );

Expand Down
4 changes: 4 additions & 0 deletions gui/gui_theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ class image_t;
#define D_H_SPACE (gui_theme_t::gui_hspace)
#define D_V_SPACE (gui_theme_t::gui_vspace)

// bars of goods waiting in stations
#define D_WAITINGBAR_WIDTH (gui_theme_t::gui_waitingbar_width)

// Button grid helpers
#define BUTTON1_X (D_MARGIN_LEFT)
#define BUTTON2_X (D_MARGIN_LEFT+1*(D_BUTTON_WIDTH+D_H_SPACE))
Expand Down Expand Up @@ -269,6 +272,7 @@ class gui_theme_t {
static KOORD_VAL gui_frame_bottom;
static KOORD_VAL gui_hspace;
static KOORD_VAL gui_vspace;
static KOORD_VAL gui_waitingbar_width;
/// @}

// those are the 3x3 images which are used for stretching
Expand Down
5 changes: 3 additions & 2 deletions gui/map_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ class legend_entry_t : public gui_component_t
void draw(scr_coord offset) OVERRIDE
{
scr_coord pos = get_pos() + offset;
display_fillbox_wh_clip_rgb(pos.x, pos.y + D_GET_CENTER_ALIGN_OFFSET(D_INDICATOR_BOX_HEIGHT,LINESPACE), D_INDICATOR_BOX_WIDTH, D_INDICATOR_BOX_HEIGHT, color, false);
label.draw(pos + scr_size(D_INDICATOR_BOX_WIDTH + D_H_SPACE, 0));
display_ddd_box_clip_rgb( pos.x, pos.y+D_GET_CENTER_ALIGN_OFFSET(D_INDICATOR_BOX_HEIGHT,LINESPACE), D_INDICATOR_BOX_WIDTH, D_INDICATOR_HEIGHT, color_idx_to_rgb(MN_GREY0), color_idx_to_rgb(MN_GREY4) );
display_fillbox_wh_clip_rgb( pos.x, pos.y+D_GET_CENTER_ALIGN_OFFSET(D_INDICATOR_BOX_HEIGHT,LINESPACE), D_INDICATOR_BOX_WIDTH, D_INDICATOR_BOX_HEIGHT, color, false );
label.draw( pos+scr_size(D_INDICATOR_BOX_WIDTH+D_H_SPACE,0) );
}
};

Expand Down
26 changes: 13 additions & 13 deletions simhalt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3053,8 +3053,8 @@ void haltestelle_t::display_status(KOORD_VAL xpos, KOORD_VAL ypos)
max_bar_height = last_bar_height[i];
}
}
const KOORD_VAL x = xpos - (last_bar_count * 4 - get_tile_raster_width()) / 2;
mark_rect_dirty_wc( x - 1 - 4, ypos - 11 - max_bar_height - 6, x + last_bar_count * 4 + 12 - 2, ypos - 11 );
const KOORD_VAL x = xpos - (last_bar_count * D_WAITINGBAR_WIDTH - get_tile_raster_width()) / 2;
mark_rect_dirty_wc( x - 1 - D_WAITINGBAR_WIDTH, ypos - 11 - max_bar_height - 6, x + last_bar_count * D_WAITINGBAR_WIDTH + 12 - 2, ypos - 11 );

// reset bar heights for new count
last_bar_height.clear();
Expand All @@ -3065,8 +3065,8 @@ void haltestelle_t::display_status(KOORD_VAL xpos, KOORD_VAL ypos)
last_bar_count = count;
}

ypos -= 11;
xpos -= (count * 4 - get_tile_raster_width()) / 2;
ypos -= D_LABEL_HEIGHT/2 +D_WAITINGBAR_WIDTH;
xpos -= (count * D_WAITINGBAR_WIDTH - get_tile_raster_width()) / 2;
const KOORD_VAL x = xpos;

sint16 bar_height_index = 0;
Expand All @@ -3092,31 +3092,31 @@ void haltestelle_t::display_status(KOORD_VAL xpos, KOORD_VAL ypos)
v = (v / 4) + 2;
}

display_fillbox_wh_clip_rgb( xpos, ypos - v - 1, 1, v, color_idx_to_rgb(COL_GREY4), false);
display_fillbox_wh_clip_rgb( xpos + 1, ypos - v - 1, 2, v, wtyp->get_color(), false);
display_fillbox_wh_clip_rgb( xpos + 3, ypos - v - 1, 1, v, color_idx_to_rgb(COL_GREY1), false);
display_fillbox_wh_clip_rgb( xpos, ypos - v - 1, 1, v, color_idx_to_rgb( COL_GREY4 ), false );
display_fillbox_wh_clip_rgb( xpos + 1, ypos - v - 1, D_WAITINGBAR_WIDTH - 2, v, wtyp->get_color(), false );
display_fillbox_wh_clip_rgb( xpos + D_WAITINGBAR_WIDTH - 1, ypos - v - 1, 1, v, color_idx_to_rgb( COL_GREY1 ), false );

// Hajo: show up arrow for capped values
if( sum > max_capacity ) {
display_fillbox_wh_clip_rgb( xpos + 1, ypos - v - 6, 2, 4, color_idx_to_rgb(COL_WHITE), false);
display_fillbox_wh_clip_rgb( xpos, ypos - v - 5, 4, 1, color_idx_to_rgb(COL_WHITE), false);
display_fillbox_wh_clip_rgb( xpos + (D_WAITINGBAR_WIDTH / 2) - 1, ypos - v - 6, 2, 4, color_idx_to_rgb( COL_WHITE ), false );
display_fillbox_wh_clip_rgb( xpos + (D_WAITINGBAR_WIDTH / 2) - 2, ypos - v - 5, 4, 1, color_idx_to_rgb( COL_WHITE ), false );
v += 5; // for marking dirty
}

if( last_bar_height[bar_height_index] != (KOORD_VAL)v ) {
if( (KOORD_VAL)v > last_bar_height[bar_height_index] ) {
// bar will be longer, mark new height dirty
mark_rect_dirty_wc( xpos, ypos - v - 1, xpos + 3, ypos - 1);
mark_rect_dirty_wc( xpos, ypos - v - 1, xpos + D_WAITINGBAR_WIDTH, ypos - 1 );
}
else {
// bar will be shorter, mark old height dirty
mark_rect_dirty_wc( xpos, ypos - last_bar_height[bar_height_index] - 1, xpos + 3, ypos - 1);
mark_rect_dirty_wc( xpos, ypos - last_bar_height[ bar_height_index ] - 1, xpos + D_WAITINGBAR_WIDTH, ypos - 1 );
}
last_bar_height[bar_height_index] = v;
}

bar_height_index++;
xpos += 4;
xpos += D_WAITINGBAR_WIDTH;
}
}

Expand All @@ -3126,7 +3126,7 @@ void haltestelle_t::display_status(KOORD_VAL xpos, KOORD_VAL ypos)
last_status_color = get_status_farbe();
dirty = true;
}
display_fillbox_wh_clip_rgb( x - 1 - 4, ypos, count * 4 + 12 - 2, 4, get_status_farbe(), dirty );
display_fillbox_wh_clip_rgb( x - 1 - 4, ypos, count * D_WAITINGBAR_WIDTH + 12 - 2, D_WAITINGBAR_WIDTH, get_status_farbe(), dirty );
}


Expand Down
1 change: 1 addition & 0 deletions simutrans/history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
ADD: Depot list as dialog tool 32
FIX: city more strongly attempt to build double height bridges over navigable rivers
ADD: Vehicle list as dialog tool 33 (to see also upcoming vehicles)
ADD: goods waiting bar with now configurable: gui_waitingbar_width

Release of 121.0 (r8870 on 1-Dec-2019):
ADD: Map number is shown in the enlarge map window.
Expand Down

0 comments on commit 3290d8f

Please sign in to comment.