- weapon_size.x = max_panel_size.x / columns;
- weapon_size.y = max_panel_size.y / rows;
- rows = ceil(weapon_count / columns);
- }
+ // reduce rows and columns as needed
+ columns = ceil(weapon_count / rows);
+ rows = ceil(weapon_count / columns);
+
+ // NOTE: although weapons should aways look the same even if onlyowned is disabled,
+ // we enlarge them a bit when possible to better match the desired aspect ratio
+ // as they look much better
+ weapon_size.x = min(old_panel_size.x / columns, aspect * weapon_size.y);
+ weapon_size.y = min(old_panel_size.y / rows, weapon_size.x / aspect);