graphics: begin to rewrite code to be more simple: - add

a struct Texture to store a sf::Texture and the application's texture sizes,
 - add a texture resources manager and retrieve codes to allow - if needed,
 rescaling startsplash and spidlogo at startup - loading some graphics with
 different resolutions:     buttons, inventory, pcedbuttons, statarea,
 startanim,     startbut, startup, terscreen, textbar, transcript   can be
 used to load high resolution pictures.

Note: currently, render_image and res_image are a mess as Texture and sf:Texture classes
  cohabit :-~
This commit is contained in:
Laurent alonso
2020-10-15 19:37:38 +02:00
committed by Celtic Minstrel
parent 44c063abd2
commit e625927a29
15 changed files with 226 additions and 39 deletions

View File

@@ -65,6 +65,7 @@ extern location center;
extern cCustomGraphics spec_scen_g;
extern sf::RenderTexture pc_stats_gworld, item_stats_gworld, text_area_gworld;
extern sf::RenderTexture terrain_screen_gworld;
extern rectangle text_area_rect;
// game globals
extern enum_map(eItemButton, rectangle) item_buttons[8];
@@ -96,8 +97,9 @@ void put_pc_screen() {
pc_stats_gworld.setActive();
// First clean up gworld with pretty patterns
sf::Texture& orig = *ResMgr::graphics.get("statarea");
rect_draw_some_item(orig, rectangle(orig), pc_stats_gworld, rectangle(pc_stats_gworld));
auto const &orig = *ResMgr::textures.get("statarea");
rectangle const stats_rect(orig);
rect_draw_some_item(orig, stats_rect, pc_stats_gworld, stats_rect);
tileImage(pc_stats_gworld, erase_rect,bg[6]);
TextStyle style;
@@ -217,8 +219,9 @@ void put_item_screen(eItemWinMode screen_num) {
item_stats_gworld.setActive(false);
// First clean up gworld with pretty patterns
sf::Texture& orig = *ResMgr::graphics.get("inventory");
rect_draw_some_item(orig, rectangle(orig), item_stats_gworld, rectangle(item_stats_gworld));
auto const & orig = *ResMgr::textures.get("inventory");
rectangle const item_stats_rect(orig);
rect_draw_some_item(orig, item_stats_rect, item_stats_gworld, item_stats_rect);
tileImage(item_stats_gworld, erase_rect,bg[6]);
// Draw buttons at bottom
@@ -943,7 +946,7 @@ void add_string_to_buf(std::string str, unsigned short indent) {
inited = true;
buf_style.font = FONT_PLAIN;
buf_style.pointSize = 12;
width = text_area_gworld.getSize().x - 5;
width = text_area_rect.width() - 5;
}
if(overall_mode == MODE_STARTUP)
return;