From af3561616b4f22b15f1d283540ec41e5ac0a14a6 Mon Sep 17 00:00:00 2001 From: 4nonch Date: Sun, 21 Jul 2024 16:47:56 +0300 Subject: [PATCH] astyle formatting --- src/cata_tiles.cpp | 33 ++++++++++++++++------------ src/cata_tiles.h | 8 +++---- src/newcharacter.cpp | 52 ++++++++++++++++++++++++-------------------- src/newcharacter.h | 15 ++++++------- src/output.cpp | 6 +++-- 5 files changed, 63 insertions(+), 51 deletions(-) diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index c4a6fb263341..0dbb4f69c83f 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -644,10 +644,11 @@ void cata_tiles::set_draw_scale( int scale ) tile_ratioy = ( static_cast( tile_height ) / static_cast( fontheight ) ); } -std::optional> cata_tiles::tile_type_search( - const std::string &id, TILE_CATEGORY category, - const std::string &subcategory, int subtile, int rota - ) { +std::optional> cata_tiles::tile_type_search( + const std::string &id, TILE_CATEGORY category, + const std::string &subcategory, int subtile, int rota + ) +{ std::optional res = find_tile_looks_like( id, category ); const tile_type *tt = nullptr; if( res ) { @@ -1946,7 +1947,7 @@ bool cata_tiles::terrain_requires_animation() const void cata_tiles::display_character( const Character &ch, const point &p ) { int height_3d = 0; - draw_entity_with_overlays(ch, tripoint(p.x, p.y, 0), lit_level::BRIGHT, height_3d, true); + draw_entity_with_overlays( ch, tripoint( p.x, p.y, 0 ), lit_level::BRIGHT, height_3d, true ); } void cata_tiles::draw_minimap( point dest, const tripoint ¢er, int width, int height ) @@ -2160,15 +2161,15 @@ bool cata_tiles::draw_from_id_string( const std::string &id, TILE_CATEGORY categ } // Trying to search for tile type - std::optional> optional_tt; - optional_tt = tile_type_search(id, category, subcategory, subtile, rota); - if (optional_tt == std::nullopt) { + std::optional> optional_tt; + optional_tt = tile_type_search( id, category, subcategory, subtile, rota ); + if( optional_tt == std::nullopt ) { return false; } - const tile_type* tt; + const tile_type *tt; std::string found_id; - std::tie(tt, found_id) = optional_tt.value(); + std::tie( tt, found_id ) = optional_tt.value(); const tile_type &display_tile = *tt; // check to see if the display_tile is multitile, and if so if it has the key related to subtile @@ -3232,9 +3233,11 @@ void cata_tiles::draw_entity_with_overlays( const Character &ch, const tripoint // depending on the toggle flip sprite left or right if( ch.facing == FD_RIGHT ) { - draw_from_id_string( ent_name, C_NONE, "", p, corner, 0, ll, false, height_3d, 0, as_independent_entity ); + draw_from_id_string( ent_name, C_NONE, "", p, corner, 0, ll, false, height_3d, 0, + as_independent_entity ); } else if( ch.facing == FD_LEFT ) { - draw_from_id_string( ent_name, C_NONE, "", p, corner, 4, ll, false, height_3d, 0, as_independent_entity ); + draw_from_id_string( ent_name, C_NONE, "", p, corner, 4, ll, false, height_3d, 0, + as_independent_entity ); } // next up, draw all the overlays @@ -3244,9 +3247,11 @@ void cata_tiles::draw_entity_with_overlays( const Character &ch, const tripoint if( find_overlay_looks_like( ch.male, overlay, draw_id ) ) { int overlay_height_3d = prev_height_3d; if( ch.facing == FD_RIGHT ) { - draw_from_id_string( draw_id, C_NONE, "", p, corner, /*rota:*/ 0, ll, false, overlay_height_3d, 0, as_independent_entity ); + draw_from_id_string( draw_id, C_NONE, "", p, corner, /*rota:*/ 0, ll, false, overlay_height_3d, 0, + as_independent_entity ); } else if( ch.facing == FD_LEFT ) { - draw_from_id_string( draw_id, C_NONE, "", p, corner, /*rota:*/ 4, ll, false, overlay_height_3d, 0, as_independent_entity ); + draw_from_id_string( draw_id, C_NONE, "", p, corner, /*rota:*/ 4, ll, false, overlay_height_3d, 0, + as_independent_entity ); } // the tallest height-having overlay is the one that counts height_3d = std::max( height_3d, overlay_height_3d ); diff --git a/src/cata_tiles.h b/src/cata_tiles.h index 30c84afbfe57..d467d6eb3018 100644 --- a/src/cata_tiles.h +++ b/src/cata_tiles.h @@ -357,10 +357,10 @@ class cata_tiles void set_draw_scale( int scale ); /** Tries to find tile with specified parameters and return it if exists **/ - std::optional> tile_type_search( - const std::string &id, TILE_CATEGORY category, const std::string &subcategory, - int subtile, int rota - ); + std::optional> tile_type_search( + const std::string &id, TILE_CATEGORY category, const std::string &subcategory, + int subtile, int rota + ); void on_options_changed(); diff --git a/src/newcharacter.cpp b/src/newcharacter.cpp index a56ba2456177..8d2430c53386 100644 --- a/src/newcharacter.cpp +++ b/src/newcharacter.cpp @@ -1111,14 +1111,14 @@ tab_direction set_traits( avatar &u, points_left &points ) const auto init_windows = [&]( ui_adaptor & ui ) { page_width = std::min( ( TERMX - 4 ) / used_pages, 38 ); - const int int_page_width = static_cast(page_width); + const int int_page_width = static_cast( page_width ); w = catacurses::newwin( TERMY, TERMX, point_zero ); w_description = catacurses::newwin( 3, TERMX - 2, point( 1, TERMY - 4 ) ); character_preview.init( &u, TERMY - 9, TERMX - int_page_width * 3 - 3, - point(int_page_width * 3, 5) + point( int_page_width * 3, 5 ) ); ui.position_from_window( w ); @@ -1259,10 +1259,10 @@ tab_direction set_traits( avatar &u, points_left &points ) ui_manager::redraw(); const std::string action = ctxt.handle_input(); #if defined(TILES) - if ( action == "zoom_in" ) { + if( action == "zoom_in" ) { character_preview.zoom_in(); } - if ( action == "zoom_out" ) { + if( action == "zoom_out" ) { character_preview.zoom_out(); } #endif @@ -3215,10 +3215,12 @@ std::string points_left::to_string() } } -void character_preview_window::init(avatar* player, const int nlines, const int ncols, const point begin) { +void character_preview_window::init( avatar *player, const int nlines, const int ncols, + const point begin ) +{ #if defined(TILES) - tilecontext->set_draw_scale(zoom); - w_preview = catacurses::newwin(nlines, ncols, begin); + tilecontext->set_draw_scale( zoom ); + w_preview = catacurses::newwin( nlines, ncols, begin ); win_preview = w_preview.get(); termx_pixels = termx_to_pixel_value(); termy_pixels = termy_to_pixel_value(); @@ -3226,47 +3228,51 @@ void character_preview_window::init(avatar* player, const int nlines, const int #endif } -point character_preview_window::calc_character_pos() const { +point character_preview_window::calc_character_pos() const +{ #if defined(TILES) const int t_width = tilecontext->get_tile_width(); const int t_height = tilecontext->get_tile_height(); return point( - win_preview->pos.x * termx_pixels + win_preview->width * termx_pixels / 2 - t_width / 2, - win_preview->pos.y * termy_pixels + win_preview->height * termy_pixels / 2 - t_height / 2 - ); + win_preview->pos.x * termx_pixels + win_preview->width * termx_pixels / 2 - t_width / 2, + win_preview->pos.y * termy_pixels + win_preview->height * termy_pixels / 2 - t_height / 2 + ); #endif } -void character_preview_window::zoom_in() { +void character_preview_window::zoom_in() +{ #if defined(TILES) - zoom = zoom * 2 % (MAX_ZOOM * 2); - if (zoom == 0) { + zoom = zoom * 2 % ( MAX_ZOOM * 2 ); + if( zoom == 0 ) { zoom = MIN_ZOOM; } - tilecontext->set_draw_scale(zoom); + tilecontext->set_draw_scale( zoom ); #endif } -void character_preview_window::zoom_out() { +void character_preview_window::zoom_out() +{ #if defined(TILES) zoom = zoom / 2; - if (zoom < MIN_ZOOM) { + if( zoom < MIN_ZOOM ) { zoom = MAX_ZOOM; } - tilecontext->set_draw_scale(zoom); + tilecontext->set_draw_scale( zoom ); #endif } -void character_preview_window::display() const { +void character_preview_window::display() const +{ #if defined(TILES) // Drawing UI across character tile - werase(w_preview); - draw_border(w_preview, BORDER_COLOR, "CHARACTER PREVIEW", BORDER_COLOR); - wnoutrefresh(w_preview); + werase( w_preview ); + draw_border( w_preview, BORDER_COLOR, "CHARACTER PREVIEW", BORDER_COLOR ); + wnoutrefresh( w_preview ); // Drawing character itself const point pos = calc_character_pos(); - tilecontext->display_character(*u, pos); + tilecontext->display_character( *u, pos ); #endif } diff --git a/src/newcharacter.h b/src/newcharacter.h index 2d8a7a20e504..1011edc9ff2f 100644 --- a/src/newcharacter.h +++ b/src/newcharacter.h @@ -34,14 +34,13 @@ struct points_left { std::string to_string(); }; -struct character_preview_window -{ - catacurses::window w_preview; +struct character_preview_window { + catacurses::window w_preview; - void init(avatar* player, int nlines, int ncols, point begin); - void zoom_in(); - void zoom_out(); - void display() const; + void init( avatar *player, int nlines, int ncols, point begin ); + void zoom_in(); + void zoom_out(); + void display() const; private: cata_cursesport::WINDOW *win_preview = nullptr; @@ -51,7 +50,7 @@ struct character_preview_window const int MIN_ZOOM = 32; const int MAX_ZOOM = 256; int zoom = 128; - avatar* u = nullptr; + avatar *u = nullptr; point calc_character_pos() const; }; diff --git a/src/output.cpp b/src/output.cpp index e81bf8f47726..64e98255e960 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -64,11 +64,13 @@ int OVERMAP_LEGEND_WIDTH; scrollingcombattext SCT; -int termx_to_pixel_value() { +int termx_to_pixel_value() +{ return projected_window_width() / TERMX; } -int termy_to_pixel_value() { +int termy_to_pixel_value() +{ return projected_window_height() / TERMY; }