Skip to content

Commit

Permalink
Merge branch '2403-schedule-gui-update' of https://github.com/Ranran-…
Browse files Browse the repository at this point in the history
…the-JuicyPork/simutrans-extended into 2403-schedule-gui-update
  • Loading branch information
jamespetts committed Mar 3, 2024
2 parents 6b9e888 + 748e4ef commit 2c27bdc
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 40 deletions.
2 changes: 1 addition & 1 deletion dataobj/schedule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ void schedule_t::gimme_stop_name(cbuffer_t & buf, karte_t* welt, const player_t
sprintf(modified_name, "%s", halt->get_name());
}

if(entry.wait_for_time)
if(entry.wait_for_time && !skinverwaltung_t::waiting_time)
{
buf.printf("[*] ");
}
Expand Down
24 changes: 24 additions & 0 deletions gui/components/gui_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ scr_size button_t::get_min_size() const
return scr_size( max( D_BUTTON_HEIGHT, (gui_theme_t::gui_color_button_text_offset.w+4)*2 + 6/*arrow width(5)+margin(1)*/+block_height + (bars_height-2)/2 ), max(D_BUTTON_HEIGHT, LINESPACE) );
}

case swap_vertical:
return scr_size(D_BUTTON_PADDINGS_X + 18/*arrow width(5*2)+center margin(3)+padding*/ ,D_LABEL_HEIGHT);

case depot:
{
return scr_size( max(18, D_BUTTON_HEIGHT), max(D_BUTTON_HEIGHT, LINESPACE));
Expand Down Expand Up @@ -494,6 +497,26 @@ void button_t::draw(scr_coord offset)
}
break;

case swap_vertical:
{
display_img_stretch(gui_theme_t::round_button_tiles[get_state_offset()], area);

scr_coord_val xoff = area.x + gui_theme_t::gui_button_text_offset.w + 5;
const scr_coord_val yoff = area.y + 2 + (pressed&&gui_theme_t::pressed_button_sinks);
// up arrow
display_fillbox_wh_clip_rgb(xoff, yoff, 1, D_LABEL_HEIGHT-4, SYSCOL_BUTTON_TEXT, false);
display_fillbox_wh_clip_rgb(xoff-1, yoff+1, 3, 1, SYSCOL_BUTTON_TEXT, false);
display_fillbox_wh_clip_rgb(xoff-2, yoff+2, 5, 1, SYSCOL_BUTTON_TEXT, false);

// down arrow
xoff = area.x + size.w - gui_theme_t::gui_button_text_offset.w - 6;
display_fillbox_wh_clip_rgb(xoff, yoff, 1, D_LABEL_HEIGHT-4, SYSCOL_BUTTON_TEXT, false);
display_fillbox_wh_clip_rgb(xoff-1, yoff+D_LABEL_HEIGHT-6, 3, 1, SYSCOL_BUTTON_TEXT, false);
display_fillbox_wh_clip_rgb(xoff-2, yoff+D_LABEL_HEIGHT-7, 5, 1, SYSCOL_BUTTON_TEXT, false);

}
break;

case depot:
{
display_img_stretch(gui_theme_t::round_button_tiles[get_state_offset()], area);
Expand Down Expand Up @@ -573,6 +596,7 @@ void button_t::update_focusability()
// those cannot receive focus ...
case imagebox:
case sortarrow:
case swap_vertical:
case arrowleft:
case repeatarrowleft:
case arrowright:
Expand Down
1 change: 1 addition & 0 deletions gui/components/gui_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class button_t :
posbutton,
repeatarrowleft,
repeatarrowright,
swap_vertical,
TYPE_MASK = (1 << 6) - 1,

state = 1 << 6,
Expand Down
6 changes: 3 additions & 3 deletions gui/components/gui_schedule_item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void gui_waypoint_box_t::draw(scr_coord offset)
// draw waypoint symbol on the color bar
offset += pos;
scr_coord_val radius = L_ROUTEBAR_WIDTH >> 1;
display_framed_circle_rgb(offset.x + size.w/2 - radius, offset.y + size.h/2 - radius, radius, color_idx_to_rgb(world()->get_player(player_nr)->get_player_color1() + env_t::gui_player_color_dark), color_idx_to_rgb(COL_WHITE));
display_framed_circle_rgb(offset.x + size.w/2 - radius, offset.y + size.h/2 - radius, radius, color_idx_to_rgb(world()->get_player(player_nr)->get_player_color1() + env_t::gui_player_color_dark), highlight ? color_idx_to_rgb(COL_YELLOW) : color_idx_to_rgb(COL_WHITE));
}

bool gui_waypoint_box_t::infowin_event(const event_t *ev)
Expand Down Expand Up @@ -190,7 +190,7 @@ void gui_schedule_entry_number_t::draw(scr_coord offset)
break;
case number_style::interchange:
display_filled_roundbox_clip(pos.x+offset.x, pos.y+offset.y, size.w, size.h, base_colval, false);
display_filled_roundbox_clip(pos.x+offset.x+2, pos.y+offset.y+2, size.w-4, size.h-4, color_idx_to_rgb(COL_WHITE), false);
display_filled_roundbox_clip(pos.x+offset.x+2, pos.y+offset.y+2, size.w-4, size.h-4, highlight ? color_idx_to_rgb(COL_YELLOW) : color_idx_to_rgb(COL_WHITE), false);
break;
case number_style::depot:
for (uint8 i = 0; i < 3; i++) {
Expand All @@ -208,7 +208,7 @@ void gui_schedule_entry_number_t::draw(scr_coord offset)
const scr_coord_val bar_width = (D_ENTRY_NO_WIDTH-4)/2;
const scr_coord_val radius = min(bar_width, size.h)/2;
display_fillbox_wh_clip_rgb(pos.x+offset.x + size.w/2 - D_ENTRY_NO_WIDTH/4+1, pos.y+offset.y, bar_width, size.h, base_colval, true);
display_framed_circle_rgb( pos.x+offset.x + size.w/2 - radius, pos.y+offset.y+ size.h/2-radius, radius, base_colval, color_idx_to_rgb(COL_WHITE));
display_framed_circle_rgb( pos.x+offset.x + size.w/2 - radius, pos.y+offset.y+ size.h/2-radius, radius, base_colval, highlight ? color_idx_to_rgb(COL_YELLOW) : color_idx_to_rgb(COL_WHITE));
break;
}
default:
Expand Down
6 changes: 6 additions & 0 deletions gui/components/gui_schedule_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ class gui_waypoint_box_t : public gui_colored_route_bar_t
{
koord3d entry_pos;
uint8 player_nr = PUBLIC_PLAYER_NR;
bool highlight = false;

public:
gui_waypoint_box_t(PIXVAL line_color, uint8 line_style, koord3d pos3d, waytype_t wt = ignore_wt);

void set_highlight(bool yesno) { highlight = yesno; }

void draw(scr_coord offset) OVERRIDE;

bool infowin_event(event_t const*) OVERRIDE;
Expand All @@ -79,6 +82,8 @@ class gui_schedule_entry_number_t : public gui_container_t, public gui_action_cr
uint8 style;
gui_label_buf_t lb_number;
koord3d entry_pos;
bool highlight=false;

public:
enum number_style {
halt = 0,
Expand All @@ -104,6 +109,7 @@ class gui_schedule_entry_number_t : public gui_container_t, public gui_action_cr

void set_number_style(uint8 style_) { style = style_; }
void set_color(uint8 color_idx) { p_color_idx = color_idx; }
void set_highlight(bool yesno) { highlight = yesno; }

scr_size get_min_size() const OVERRIDE { return size; }
scr_size get_max_size() const OVERRIDE { return get_min_size(); }
Expand Down
7 changes: 7 additions & 0 deletions gui/gui_theme.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ PIXVAL gui_theme_t::gui_color_traction_type;
PIXVAL gui_theme_t::gui_color_upgradeable;
PIXVAL gui_theme_t::gui_color_chat_window_network_transparency;
PIXVAL gui_theme_t::gui_color_empty;
//PIXVAL gui_theme_t::gui_color_image_transparency;
PIXVAL gui_theme_t::gui_color_object_highlight;
PIXVAL gui_theme_t::gui_color_up_pointing_triangle;
PIXVAL gui_theme_t::gui_color_down_pointing_triangle;

Expand Down Expand Up @@ -225,6 +227,9 @@ void gui_theme_t::init_gui_defaults()
gui_color_upgradeable = color_idx_to_rgb(COL_PURPLE);
gui_color_traction_type = color_idx_to_rgb(149);
gui_color_empty = color_idx_to_rgb(COL_WHITE);
// gui_color_image_transparency = color_idx_to_rgb(COL_BLACK);

gui_color_object_highlight = color_idx_to_rgb(COL_RED);

gui_color_up_pointing_triangle = color_idx_to_rgb(COL_LIGHT_TURQUOISE-1);
gui_color_down_pointing_triangle = color_idx_to_rgb(COL_LIGHT_ORANGE-2);
Expand Down Expand Up @@ -643,6 +648,8 @@ bool gui_theme_t::themes_init(const char *file_name, bool init_fonts, bool init_
gui_theme_t::gui_color_upgradeable = (PIXVAL)contents.get_color("gui_color_upgradeable", SYSCOL_UPGRADEABLE);
gui_theme_t::gui_color_empty = (PIXVAL)contents.get_color("gui_color_empty", SYSCOL_EMPTY);
gui_theme_t::gui_color_chat_window_network_transparency = (PIXVAL)contents.get_color("gui_color_chat_window_network_transparency", gui_color_chat_window_network_transparency);
// gui_theme_t::gui_color_image_transparency = (PIXVAL)contents.get_color("gui_color_image_transparency", SYSCOL_IMAGE_TRANSPARENCY);
gui_theme_t::gui_color_object_highlight = (PIXVAL)contents.get_color("gui_color_object_highlight", SYSCOL_OBJECT_HIGHLIGHT);
gui_theme_t::gui_color_up_pointing_triangle = (PIXVAL)contents.get_color("gui_color_up_pointing_triangle", SYSCOL_UP_TRIANGLE);
gui_theme_t::gui_color_down_pointing_triangle = (PIXVAL)contents.get_color("gui_color_down_pointing_triangle", SYSCOL_DOWN_TRIANGLE);
gui_theme_t::gui_color_table_frame = (PIXVAL)contents.get_color("gui_color_table_frame", SYSCOL_TABLE_FRAME);
Expand Down
4 changes: 4 additions & 0 deletions gui/gui_theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class image_t;
#define D_H_SPACE (gui_theme_t::gui_hspace)
#define D_V_SPACE (gui_theme_t::gui_vspace)

#define NO_SPACING (scr_size(0,0))

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

Expand Down Expand Up @@ -265,6 +267,8 @@ class gui_theme_t {
static PIXVAL gui_color_upgradeable; //@< Color for vehicles with available upgrades
static PIXVAL gui_color_empty; //@< Color for empty entries
static PIXVAL gui_color_chat_window_network_transparency; //@< Color if chat window is transparent in network mode
// static PIXVAL gui_color_image_transparency; //@< Transparency color for some icons/images **NOT USED IN EXTENDED**
static PIXVAL gui_color_object_highlight; //@< Color (Red) to mark objects on the map
static PIXVAL gui_color_up_pointing_triangle; //@< (EX unique) Color to draw an upward triangle indicating an increase in the number
static PIXVAL gui_color_down_pointing_triangle; //@< (EX unique) Color to draw an downward triangle indicating an decrease in the number
/// @}
Expand Down
88 changes: 59 additions & 29 deletions gui/schedule_gui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ gui_schedule_entry_t::gui_schedule_entry_t(player_t* pl, schedule_entry_t e, uin
number = n;
is_current = false;
is_air_wt = air_wt;
set_table_layout(7,0);
set_table_layout(9,0);
set_spacing(scr_size(1,0));
bt_del.init(button_t::imagebox, NULL);
Expand Down Expand Up @@ -170,18 +170,31 @@ gui_schedule_entry_t::gui_schedule_entry_t(player_t* pl, schedule_entry_t e, uin
new_component<gui_margin_t>(1); //5-5
lb_pos.buf().printf("(%s)", entry.pos.get_str());
lb_pos.update();
add_component(&lb_pos); // 5-6
lb_reverse.set_visible(true);
lb_reverse.buf().append("[<<]");
lb_reverse.set_color(SYSCOL_TEXT_STRONG);
lb_reverse.update();
add_component(&lb_reverse); // 5-7
add_component(&lb_reverse); // 5-6
new_component<gui_empty_t>(); // 5-7
}
end_table();
new_component<gui_fill_t>(); // 6

new_component<gui_fill_t>(); // 7
add_table(2,1)->set_spacing(NO_SPACING); //8
{
// pos button and label
bt_pos.set_typ(button_t::posbutton_automatic);
bt_pos.set_targetpos3d(entry.pos);
add_component(&bt_pos); // 8-1
lb_pos.buf().printf("(%s) ", entry.pos.get_str());
lb_pos.set_tooltip(translator::translate("can_also_jump_to_the_coordinate_by_right-clicking_on_the_entry"));
lb_pos.update();
lb_pos.set_fixed_width(lb_pos.get_min_size().w);
add_component(&lb_pos); // 8-2
}
end_table();
new_component<gui_empty_t>(); // 9

// 2nd row
lb_distance.set_fixed_width(proportional_string_width("(0000km) "));
Expand All @@ -207,8 +220,15 @@ gui_schedule_entry_t::gui_schedule_entry_t(player_t* pl, schedule_entry_t e, uin
wpbox.set_color(base_color);
route_bar->set_visible(true);

new_component<gui_empty_t>(); //7
new_component<gui_fill_t>(); //8
new_component<gui_empty_t>(); // 6
new_component<gui_fill_t>(); // 7

new_component<gui_empty_t>(); // 8
bt_swap.init(button_t::swap_vertical| button_t::automatic, NULL);
bt_swap.set_tooltip("helptxt_swap_schedule_entries");
bt_swap.add_listener(this);
add_component(&bt_swap); // 9

update_label();
}

Expand Down Expand Up @@ -277,6 +297,8 @@ void gui_schedule_entry_t::set_active(bool yesno)
is_current = yesno;
stop.set_color(yesno ? SYSCOL_TEXT_HIGHLIGHT : SYSCOL_TEXT);
lb_pos.set_color(yesno ? SYSCOL_TEXT_HIGHLIGHT : SYSCOL_TEXT);
entry_no.set_highlight(yesno);
wpbox.set_highlight(yesno);
}

void gui_schedule_entry_t::draw(scr_coord offset)
Expand Down Expand Up @@ -309,6 +331,11 @@ bool gui_schedule_entry_t::action_triggered(gui_action_creator_t *c, value_t )
call_listeners( DELETE_FLAG | number);
return true;
}
else if ( c == &bt_swap ) {
call_listeners( DOWN_FLAG | number);
return true;
}

return false;
}

Expand Down Expand Up @@ -478,6 +505,11 @@ bool schedule_gui_stats_t::action_triggered(gui_action_creator_t *, value_t v)
highlight_schedule( schedule, true );
call_listeners( schedule->get_current_stop() );
}
else if( v.i & DOWN_FLAG ) {
uint8 down_stop = v.i & 0x00FF;
schedule->move_entry_backward( down_stop );
call_listeners( schedule->get_current_stop() );
}
else {
call_listeners(v);
}
Expand Down Expand Up @@ -598,17 +630,17 @@ void schedule_gui_t::init_components()
img_electric.set_tooltip(translator::translate("This line/convoy needs electrification"));
img_electric.set_rigid(false);

bt_add.init(button_t::roundbox_state | button_t::flexible, "Add Stop", scr_coord(0, 0), D_BUTTON_SIZE);
bt_add.init(button_t::roundbox_state, "Add Stop", scr_coord(0, 0), D_BUTTON_SIZE);
bt_add.set_tooltip("Appends stops at the end of the schedule");
bt_add.add_listener(this);

bt_insert.init(button_t::roundbox_state | button_t::flexible, "Ins Stop", scr_coord(0, 0), D_BUTTON_SIZE);
bt_insert.init(button_t::roundbox_state, "Ins Stop", scr_coord(0, 0), D_BUTTON_SIZE);
bt_insert.set_tooltip("Insert stop before the current stop");
bt_insert.add_listener(this);

bt_remove.init(button_t::roundbox_state | button_t::flexible, "Del Stop", scr_coord(0, 0), D_BUTTON_SIZE);
bt_remove.set_tooltip("Delete the current stop");
bt_remove.add_listener(this);
//bt_revert.init(button_t::roundbox, "Revert schedule");
//bt_revert.set_tooltip("Revert to original schedule");
//bt_revert.add_listener(this);

lb_min_range.set_fixed_width(proportional_string_width("8888km "));
lb_min_range.set_rigid(false);
Expand Down Expand Up @@ -684,14 +716,18 @@ void schedule_gui_t::build_table()
add_component(&img_electric);

add_table(3,1)->set_spacing(scr_size(0,0));
bt_add.pressed = true;
add_component(&bt_add);
{
bt_add.pressed = true;
add_component(&bt_add);

bt_insert.pressed = false;
add_component(&bt_insert);
bt_insert.pressed = false;
add_component(&bt_insert);

bt_remove.pressed = false;
add_component(&bt_remove);
//bt_revert.pressed = false;
//bt_revert.enable(false); // schedule was not changed yet
//add_component(&bt_revert);
new_component<gui_margin_t>(D_BUTTON_WIDTH);
}
end_table();
}
end_table();
Expand Down Expand Up @@ -1142,23 +1178,17 @@ DBG_MESSAGE("schedule_gui_t::action_triggered()","comp=%p combo=%p",comp,&line_s
mode = adding;
bt_add.pressed = true;
bt_insert.pressed = false;
bt_remove.pressed = false;
update_tool( true );
}
else if(comp == &bt_insert) {
mode = inserting;
bt_add.pressed = false;
bt_insert.pressed = true;
bt_remove.pressed = false;
update_tool( true );
}
else if(comp == &bt_remove) {
mode = removing;
bt_add.pressed = false;
bt_insert.pressed = false;
bt_remove.pressed = true;
update_tool( false );
}
/*else if(comp == &bt_revert) {
// revert changes and tell listener
}*/
else if (comp == &bt_mirror) {
schedule->set_mirrored(bt_mirror.pressed);
}
Expand Down
7 changes: 4 additions & 3 deletions gui/schedule_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class loadsave_t;
class gui_schedule_entry_t;

#define DELETE_FLAG (0x8000)
#define UP_FLAG (0x4000)
//#define UP_FLAG (0x4000)
#define DOWN_FLAG (0x2000)

class gui_wait_loading_schedule_t : public gui_component_t
Expand Down Expand Up @@ -87,7 +87,8 @@ class gui_schedule_entry_t : public gui_aligned_container_t, public gui_action_c
gui_waypoint_box_t wpbox;
gui_colored_route_bar_t *route_bar;
gui_wait_loading_schedule_t *wait_loading;
button_t bt_del;
button_t bt_del, bt_swap;
button_t bt_pos;

public:
gui_schedule_entry_t(player_t* pl, schedule_entry_t e, uint n, bool air_wt = false, uint8 line_color_index = 254);
Expand Down Expand Up @@ -188,7 +189,7 @@ class schedule_gui_t : public gui_frame_t, public action_listener_t

// UI TODO: Make the below features work with the new UI (ignore choose, layover, range stop, consist order)
// always needed
button_t bt_add, bt_insert, bt_remove; // stop management
button_t bt_add, bt_insert/*, bt_revert*/; // stop management
button_t bt_bidirectional, bt_mirror, bt_same_spacing_shift;
button_t bt_wait_for_time;
button_t filter_btn_all_pas, filter_btn_all_mails, filter_btn_all_freights;
Expand Down
8 changes: 4 additions & 4 deletions obj/simobj.cc
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ void obj_t::display(int xpos, int ypos CLIP_NUM_DEF) const
}
else if( obj_t::get_flag( highlight ) ) {
// highlight this tile
display_blend( get_image(), xpos, start_ypos, owner_n, color_idx_to_rgb(COL_RED) | OUTLINE_FLAG | TRANSPARENT75_FLAG, 0, is_dirty CLIP_NUM_PAR);
display_blend( get_image(), xpos, start_ypos, owner_n, SYSCOL_OBJECT_HIGHLIGHT | OUTLINE_FLAG | TRANSPARENT75_FLAG, 0, is_dirty CLIP_NUM_PAR);
}
}
else if( obj_t::get_flag( highlight ) ) {
// highlight this tile
display_blend( get_image(), xpos, start_ypos, owner_n, color_idx_to_rgb(COL_RED) | OUTLINE_FLAG | TRANSPARENT75_FLAG, 0, is_dirty CLIP_NUM_PAR);
display_blend( get_image(), xpos, start_ypos, owner_n, SYSCOL_OBJECT_HIGHLIGHT | OUTLINE_FLAG | TRANSPARENT75_FLAG, 0, is_dirty CLIP_NUM_PAR);
}
else if( get_outline_colour() ) {
// highlight this tile
Expand Down Expand Up @@ -296,15 +296,15 @@ void obj_t::display_after(int xpos, int ypos, bool) const
}
else if( obj_t::get_flag( highlight ) ) {
// highlight this tile
display_blend( image, xpos, ypos, owner_n, color_idx_to_rgb(COL_RED) | OUTLINE_FLAG | TRANSPARENT75_FLAG, 0, is_dirty CLIP_NUM_PAR);
display_blend( image, xpos, ypos, owner_n, SYSCOL_OBJECT_HIGHLIGHT | OUTLINE_FLAG | TRANSPARENT75_FLAG, 0, is_dirty CLIP_NUM_PAR);
}
else {
display_color( image, xpos, ypos, owner_n, true, is_dirty CLIP_NUM_PAR);
}
}
else if( obj_t::get_flag( highlight ) ) {
// highlight this tile
display_blend( image, xpos, ypos, owner_n, color_idx_to_rgb(COL_RED) | OUTLINE_FLAG | TRANSPARENT75_FLAG, 0, is_dirty CLIP_NUM_PAR);
display_blend( image, xpos, ypos, owner_n, SYSCOL_OBJECT_HIGHLIGHT | OUTLINE_FLAG | TRANSPARENT75_FLAG, 0, is_dirty CLIP_NUM_PAR);
}
else {
display_normal( image, xpos, ypos, 0, true, is_dirty CLIP_NUM_PAR);
Expand Down
Loading

0 comments on commit 2c27bdc

Please sign in to comment.