From b490643b24b51e5f6d0c3f4358b8e19c81afc54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=28=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BD=80=29?= Date: Sat, 28 Aug 2021 21:27:16 +0900 Subject: [PATCH] ADD: Show the name of depot above own depots in the main game window --- boden/grund.cc | 18 ++++++++++++++++++ dataobj/environment.cc | 3 +++ dataobj/environment.h | 3 +++ dataobj/settings.cc | 1 + display/simgraph.h | 1 + display/simgraph0.cc | 4 ++++ display/simgraph16.cc | 21 +++++++++++++++++++++ gui/display_settings.cc | 11 +++++++++++ simmenu.cc | 1 + simmenu.h | 1 + simtool.h | 15 +++++++++++++++ simutrans/config/simuconf.tab | 3 +++ 12 files changed, 82 insertions(+) diff --git a/boden/grund.cc b/boden/grund.cc index 8a7e9fb97f..74e171b0d6 100644 --- a/boden/grund.cc +++ b/boden/grund.cc @@ -1702,6 +1702,24 @@ void grund_t::display_overlay(const sint16 xpos, const sint16 ypos) } } } + + if( env_t::show_depot_names ) { + if( depot_t *dep = get_depot() ) { + const player_t* owner = dep->get_owner(); + if( owner==welt->get_active_player() ) { + const char *text = dep->get_name(); + + const sint16 raster_tile_width = get_tile_raster_width(); + const int width = proportional_string_width(text)+7; + int new_xpos = xpos - (width-raster_tile_width)/2; + + const scr_coord_val depot_sym_width = max(12,(LINESPACE*3)>>2); + + display_depot_symbol(new_xpos, ypos-LINESPACE/4, depot_sym_width, owner->get_player_color1()); + display_outline_proportional_rgb(new_xpos+depot_sym_width+4, ypos-LINESPACE/4, color_idx_to_rgb(owner->get_player_color1()+4), color_idx_to_rgb(COL_BLACK), text, dirty); + } + } + } if( schiene_t::show_reservations && hat_wege() ) { if( weg_t* w = get_weg_nr( 0 ) ) { if( w->has_signal() ) { diff --git a/dataobj/environment.cc b/dataobj/environment.cc index f3dd42b015..85054c1e45 100644 --- a/dataobj/environment.cc +++ b/dataobj/environment.cc @@ -108,6 +108,7 @@ uint16 env_t::cursor_hide_range; bool env_t::use_transparency_station_coverage; uint8 env_t::station_coverage_show; sint32 env_t::show_names; +bool env_t::show_depot_names; sint32 env_t::message_flags[4]; uint32 env_t::water_animation; uint32 env_t::ground_object_probability; @@ -201,6 +202,7 @@ void env_t::init() station_coverage_show = 0; show_names = 3; + show_depot_names = false; player_finance_display_account = true; water_animation = 250; // 250ms per wave stage @@ -550,6 +552,7 @@ void env_t::rdwr(loadsave_t *file) file->rdwr_bool( reselect_closes_tool ); file->rdwr_bool( single_line_gui ); + file->rdwr_bool( env_t::show_depot_names ); } // server settings are not saved, since they are server specific diff --git a/dataobj/environment.h b/dataobj/environment.h index c63750f91e..c54017bbab 100644 --- a/dataobj/environment.h +++ b/dataobj/environment.h @@ -326,6 +326,9 @@ class env_t */ static sint32 show_names; + /// Show own depot name label + static bool show_depot_names; + /// if a schedule is open, show tiles which are used by it static bool visualize_schedule; diff --git a/dataobj/settings.cc b/dataobj/settings.cc index 7ff66e0282..959b4f2263 100644 --- a/dataobj/settings.cc +++ b/dataobj/settings.cc @@ -996,6 +996,7 @@ void settings_t::parse_simuconf( tabfile_t& simuconf, sint16& disp_width, sint16 // display stuff env_t::show_names = contents.get_int_clamped( "show_names", env_t::show_names, 0, 7 ); + env_t::show_depot_names = contents.get_int( "show_depot_names", env_t::show_depot_names ) != 0; env_t::show_month = contents.get_int_clamped( "show_month", env_t::show_month, 0, 7 ); env_t::show_vehicle_states = contents.get_int_clamped( "show_vehicle_states", env_t::show_vehicle_states, 0, 3 ); env_t::follow_convoi_underground = contents.get_int_clamped( "follow_convoi_underground", env_t::follow_convoi_underground, 0, 2 ); diff --git a/display/simgraph.h b/display/simgraph.h index 1cc2af7569..fd9d0d48ce 100644 --- a/display/simgraph.h +++ b/display/simgraph.h @@ -349,6 +349,7 @@ void draw_bezier_rgb(scr_coord_val Ax, scr_coord_val Ay, scr_coord_val Bx, scr_c void display_right_triangle_rgb(scr_coord_val x, scr_coord_val y, scr_coord_val height, const PIXVAL colval, const bool dirty); void display_signal_direction_rgb(scr_coord_val x, scr_coord_val y, uint8 way_dir, uint8 sig_dir, PIXVAL col1, PIXVAL col1_dark, bool is_diagonal=false ); +void display_depot_symbol(scr_coord_val x, scr_coord_val y, scr_coord_val width=12, const uint8 darkest_pcol_idx=88/*brown*/, const bool dirty=true); void display_set_clip_wh(scr_coord_val x, scr_coord_val y, scr_coord_val w, scr_coord_val h CLIP_NUM_DEF CLIP_NUM_DEFAULT_ZERO, bool fit = false); clip_dimension display_get_clip_wh(CLIP_NUM_DEF0 CLIP_NUM_DEFAULT_ZERO); diff --git a/display/simgraph0.cc b/display/simgraph0.cc index 58beec36a4..9e0dcddc41 100644 --- a/display/simgraph0.cc +++ b/display/simgraph0.cc @@ -396,6 +396,10 @@ void display_signal_direction_rgb( scr_coord_val, scr_coord_val, uint8, uint8, P { } +void display_depot_symbol(scr_coord_val, scr_coord_val, scr_coord_val, const uint8, const bool) +{ +} + void display_set_progress_text(const char *) { } diff --git a/display/simgraph16.cc b/display/simgraph16.cc index ccb363d9d1..0aef92d902 100644 --- a/display/simgraph16.cc +++ b/display/simgraph16.cc @@ -5078,6 +5078,27 @@ void display_signal_direction_rgb(scr_coord_val x, scr_coord_val y, uint8 way_di } + +void display_depot_symbol(scr_coord_val x, scr_coord_val y, scr_coord_val width, const uint8 darkest_pcol_idx, const bool dirty) +{ + if (width < 6) { return; } // too small to draw! + // first, draw the roof (upper triangle) + for (uint8 i = 0; i < width/4; i++) { + const scr_coord_val w = i*4 + 2; + display_fillbox_wh_clip_rgb(x + (width-w) / 2, y+i, w, 1, color_idx_to_rgb(darkest_pcol_idx+3), dirty); + } + display_fillbox_wh_clip_rgb(x, y+width/4, width, width-width/3-1, color_idx_to_rgb(darkest_pcol_idx+3), dirty); + // draw the door + const scr_coord_val y_start = width/4+1; + display_vline_wh_rgb(x+1, y+y_start, width-width/3-2, color_idx_to_rgb(darkest_pcol_idx+6), dirty); + display_vline_wh_rgb(x+(width/2)*2-2, y+y_start, width-width/3-2, color_idx_to_rgb(darkest_pcol_idx+6), dirty); + if (width < 8) { return; } // too small to draw! + for (uint8 i=y_start; i < width-3; i+=2) { + const scr_coord_val w = i==y_start ? (width/2)*2-4 : (width/2)*2-6; + display_fillbox_wh_clip_rgb(x+3-(i==y_start), y+i, w, 1, color_idx_to_rgb(darkest_pcol_idx+6), dirty); + } +} + /** * Print a bezier curve between points A and B * @Ax,Ay=start coordinate of Bezier curve diff --git a/gui/display_settings.cc b/gui/display_settings.cc index 9bdd5c4e60..d69d8fcf40 100644 --- a/gui/display_settings.cc +++ b/gui/display_settings.cc @@ -47,6 +47,7 @@ enum { IDBTN_SHOW_THEMEMANAGER, IDBTN_SIMPLE_DRAWING, IDBTN_CHANGE_FONT, + IDBTN_SHOW_DEPOT_NAME, COLORS_MAX_BUTTONS }; @@ -341,6 +342,12 @@ station_settings_t::station_settings_t() buttons[ IDBTN_SHOW_WAITING_BARS ].pressed = env_t::show_names & 2; add_component( buttons + IDBTN_SHOW_WAITING_BARS, 2 ); + // Show own depot name + buttons[ IDBTN_SHOW_DEPOT_NAME ].init( button_t::square_state, "Show own depot names" ); + buttons[ IDBTN_SHOW_DEPOT_NAME ].pressed = env_t::show_depot_names; + add_component( buttons + IDBTN_SHOW_DEPOT_NAME ); + + end_table(); } @@ -538,6 +545,9 @@ bool color_gui_t::action_triggered( gui_action_creator_t *comp, value_t ) case IDBTN_SHOW_STATION_COVERAGE: env_t::station_coverage_show = env_t::station_coverage_show == 0 ? 0xFF : 0; break; + case IDBTN_SHOW_DEPOT_NAME: + env_t::show_depot_names = !env_t::show_depot_names; + break; case IDBTN_UNDERGROUND_VIEW: // see simtool.cc::tool_show_underground_t::init grund_t::set_underground_mode( buttons[ IDBTN_UNDERGROUND_VIEW ].pressed ? grund_t::ugm_none : grund_t::ugm_all, map_settings.inp_underground_level.get_value() ); @@ -618,6 +628,7 @@ void color_gui_t::draw(scr_coord pos, scr_size size) buttons[IDBTN_UNDERGROUND_VIEW].pressed = grund_t::underground_mode == grund_t::ugm_all; buttons[IDBTN_SHOW_GRID].pressed = grund_t::show_grid; buttons[IDBTN_SHOW_WAITING_BARS].pressed = (env_t::show_names&2)!=0; + buttons[IDBTN_SHOW_DEPOT_NAME].pressed = env_t::show_depot_names; buttons[IDBTN_SHOW_SLICE_MAP_VIEW].pressed = grund_t::underground_mode == grund_t::ugm_level; buttons[IDBTN_SHOW_SCHEDULES_STOP].pressed = env_t::visualize_schedule; buttons[IDBTN_SIMPLE_DRAWING].pressed = env_t::simple_drawing; diff --git a/simmenu.cc b/simmenu.cc index 8990a44034..93455e1ee6 100644 --- a/simmenu.cc +++ b/simmenu.cc @@ -295,6 +295,7 @@ tool_t *create_simple_tool(int toolnr) case TOOL_ZOOM_OUT: tool = new tool_zoom_out_t(); break; case TOOL_SHOW_COVERAGE: tool = new tool_show_coverage_t(); break; case TOOL_SHOW_NAME: tool = new tool_show_name_t(); break; + case TOOL_SHOW_DEPOT_NAME: tool = new tool_show_depot_name_t(); break; case TOOL_SHOW_GRID: tool = new tool_show_grid_t(); break; case TOOL_SHOW_TREES: tool = new tool_show_trees_t(); break; case TOOL_SHOW_HOUSES: tool = new tool_show_houses_t(); break; diff --git a/simmenu.h b/simmenu.h index 111d8964f6..0e45d10731 100644 --- a/simmenu.h +++ b/simmenu.h @@ -123,6 +123,7 @@ enum { TOOL_MOVE_MAP, TOOL_ROLLUP_ALL_WIN, TOOL_RECOLOUR_TOOL, + TOOL_SHOW_DEPOT_NAME, SIMPLE_TOOL_COUNT, SIMPLE_TOOL = 0x2000 }; diff --git a/simtool.h b/simtool.h index c5b6c0e4f1..561814b0db 100644 --- a/simtool.h +++ b/simtool.h @@ -841,6 +841,21 @@ class tool_show_name_t : public tool_t { bool is_work_network_safe() const OVERRIDE { return true; } }; +class tool_show_depot_name_t : public tool_t { +public: + tool_show_depot_name_t() : tool_t(TOOL_SHOW_DEPOT_NAME | SIMPLE_TOOL) {} + char const* get_tooltip(player_t const*) const OVERRIDE { return translator::translate("Show depot names"); } + bool is_selected() const OVERRIDE { return env_t::show_depot_names; } + bool init( player_t * ) OVERRIDE { + env_t::show_depot_names = !env_t::show_depot_names; + welt->set_dirty(); + return false; + } + bool exit(player_t *s ) OVERRIDE { return init(s); } + bool is_init_network_safe() const OVERRIDE { return true; } + bool is_work_network_safe() const OVERRIDE { return true; } +}; + class tool_show_grid_t : public tool_t { public: tool_show_grid_t() : tool_t(TOOL_SHOW_GRID | SIMPLE_TOOL) {} diff --git a/simutrans/config/simuconf.tab b/simutrans/config/simuconf.tab index 22336882e4..f763cf1743 100644 --- a/simutrans/config/simuconf.tab +++ b/simutrans/config/simuconf.tab @@ -345,6 +345,9 @@ show_delete_buttons = 0 # 8 = box left of name in yellow outline show_names = 3 +# Show the name of depot above own depots +#show_depot_names = 0 + # Draw the earth slope to mark the border (default 1 on) draw_earth_border = 1