Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust view offsets + show sidebar in alternate main screen states #29478

Merged
merged 2 commits into from
Apr 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6658,14 +6658,15 @@ void game::zones_manager()
mvwprintz( w_zones_info, 3, 2, c_white, _( "Select first point." ) );
wrefresh( w_zones_info );

tripoint center = u.pos() + u.view_offset + sidebar_offset;
tripoint center = u.pos() + u.view_offset;

const look_around_result first = look_around( w_zones_info, center, center, false, true, false );
if( first.position )
{
mvwprintz( w_zones_info, 3, 2, c_white, _( "Select second point." ) );
wrefresh( w_zones_info );

center = center - sidebar_offset;
const look_around_result second = look_around( w_zones_info, center, *first.position, true, true,
false );
if( second.position ) {
Expand Down Expand Up @@ -7046,10 +7047,15 @@ look_around_result game::look_around( catacurses::window w_info, tripoint &cente

temp_exit_fullscreen();

center = center + sidebar_offset;

const int offset_x = ( u.posx() + u.view_offset.x ) - getmaxx( w_terrain ) / 2;
const int offset_y = ( u.posy() + u.view_offset.y ) - getmaxy( w_terrain ) / 2;

tripoint lp = start_point; // cursor
if( !has_first_point ) {
lp = start_point - sidebar_offset;
}
int &lx = lp.x;
int &ly = lp.y;
int &lz = lp.z;
Expand All @@ -7063,10 +7069,22 @@ look_around_result game::look_around( catacurses::window w_info, tripoint &cente

bool bNewWindow = false;
if( !w_info ) {
int panel_width = panel_manager::get_manager().get_current_layout().begin()->get_width();

// Set the examine window to a bit smaller than the current minimap size, with a bit less to show some above it.
// Hopefully the player has the minimap at or close to the bottom.
int height = TERMY - ( catacurses::getmaxy( w_pixel_minimap ) + 11 );

// If particularly small, base height on panel width irrespective of other elements.
// Value here is attempting to get a square-ish result assuming 1x2 proportioned font.
if( height < panel_width / 2 ) {
height = panel_width / 2;
}

int la_y = 0;
int la_x = TERMX - 32;
int la_h = 16;
int la_w = 32;
int la_x = TERMX - panel_width;
int la_h = height;
int la_w = panel_width;
w_info = catacurses::newwin( la_h, la_w, la_y, la_x );
bNewWindow = true;
}
Expand Down Expand Up @@ -7161,6 +7179,7 @@ look_around_result game::look_around( catacurses::window w_info, tripoint &cente

// redraw order: terrain, panels, look_around panel
wrefresh( w_terrain );
draw_panels();
wrefresh( w_info );

}
Expand Down Expand Up @@ -7410,13 +7429,13 @@ void centerlistview( const tripoint &active_item_position )
if( xpos < 0 ) {
u.view_offset.x = xpos - xOffset;
} else {
u.view_offset.x = xpos - ( TERRAIN_WINDOW_WIDTH - 1 ) + xOffset;
u.view_offset.x = xpos - ( TERRAIN_WINDOW_WIDTH ) + xOffset;
}

if( ypos < 0 ) {
u.view_offset.y = ypos - yOffset;
} else {
u.view_offset.y = ypos - ( TERRAIN_WINDOW_HEIGHT - 1 ) + yOffset;
u.view_offset.y = ypos - ( TERRAIN_WINDOW_HEIGHT ) + yOffset;
}
} else {
if( xpos < 0 ) {
Expand Down
3 changes: 2 additions & 1 deletion src/ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ std::vector<tripoint> target_handler::target_ui( player &pc, target_mode mode,
mvwputch( w_target, i, j, c_white, ' ' );
}
}
g->draw_ter( center, true );
g->draw_ter( center + g->sidebar_offset, true );
int line_number = 1;
Creature *critter = g->critter_at( dst, true );
const int relative_elevation = dst.z - pc.pos().z;
Expand Down Expand Up @@ -1338,6 +1338,7 @@ std::vector<tripoint> target_handler::target_ui( player &pc, target_mode mode,
}

wrefresh( g->w_terrain );
g->draw_panels();
draw_targeting_window( w_target, relevant->tname(),
mode, ctxt, aim_types,
static_cast<bool>( on_mode_change ),
Expand Down