Skip to content

Commit

Permalink
astyle formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
4nonch committed Jul 21, 2024
1 parent f3cee3d commit af35616
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 51 deletions.
33 changes: 19 additions & 14 deletions src/cata_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,10 +644,11 @@ void cata_tiles::set_draw_scale( int scale )
tile_ratioy = ( static_cast<float>( tile_height ) / static_cast<float>( fontheight ) );
}

std::optional<std::tuple<const tile_type*, std::string>> cata_tiles::tile_type_search(
const std::string &id, TILE_CATEGORY category,
const std::string &subcategory, int subtile, int rota
) {
std::optional<std::tuple<const tile_type *, std::string>> cata_tiles::tile_type_search(
const std::string &id, TILE_CATEGORY category,
const std::string &subcategory, int subtile, int rota
)
{
std::optional<tile_lookup_res> res = find_tile_looks_like( id, category );
const tile_type *tt = nullptr;
if( res ) {
Expand Down Expand Up @@ -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 &center, int width, int height )
Expand Down Expand Up @@ -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<std::tuple<const tile_type*, std::string>> optional_tt;
optional_tt = tile_type_search(id, category, subcategory, subtile, rota);
if (optional_tt == std::nullopt) {
std::optional<std::tuple<const tile_type *, std::string>> 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
Expand Down Expand Up @@ -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
Expand All @@ -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 );
Expand Down
8 changes: 4 additions & 4 deletions src/cata_tiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::tuple<const tile_type*, std::string>> tile_type_search(
const std::string &id, TILE_CATEGORY category, const std::string &subcategory,
int subtile, int rota
);
std::optional<std::tuple<const tile_type *, std::string>> tile_type_search(
const std::string &id, TILE_CATEGORY category, const std::string &subcategory,
int subtile, int rota
);

void on_options_changed();

Expand Down
52 changes: 29 additions & 23 deletions src/newcharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(page_width);
const int int_page_width = static_cast<int>( 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 );
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -3215,58 +3215,64 @@ 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<cata_cursesport::WINDOW>();
termx_pixels = termx_to_pixel_value();
termy_pixels = termy_to_pixel_value();
u = player;
#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
}

Expand Down
15 changes: 7 additions & 8 deletions src/newcharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
};
Expand Down
6 changes: 4 additions & 2 deletions src/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit af35616

Please sign in to comment.