diff --git a/rsrc/graphics/CREDITS.md b/rsrc/graphics/CREDITS.md index 5575c7e4..38110992 100644 --- a/rsrc/graphics/CREDITS.md +++ b/rsrc/graphics/CREDITS.md @@ -20,6 +20,7 @@ though in some cases rearranged a little: - dlogbtnsm.png - dlogbtntall.png - dlogpics.png +- errors.png ( "Under Construction Grunge Sign" by Free Grunge Textures - www.freestock.ca is licensed under CC BY 2.0 ) - edsplash.png (by James Ernest) - fighthelp.png - invenbtns.png (the coin was cropped from an item graphic) diff --git a/rsrc/graphics/errors.png b/rsrc/graphics/errors.png new file mode 100644 index 00000000..fa5d2faf Binary files /dev/null and b/rsrc/graphics/errors.png differ diff --git a/src/gfx/gfxsheets.cpp b/src/gfx/gfxsheets.cpp index 46ceb14e..c80be3a2 100644 --- a/src/gfx/gfxsheets.cpp +++ b/src/gfx/gfxsheets.cpp @@ -29,8 +29,8 @@ Texture_pos cCustomGraphics::find_graphic(pic_num_t which_rect, bool party) { else if(numSheets == 0) valid = false; if(!valid) { INVALID: - auto const &blank = *ResMgr::textures.get("blank", true); - return std::make_pair(blank, rectangle(0,0,36,28)); + auto const &error = *ResMgr::textures.get("errors", true); + return std::make_pair(error, rectangle(0,0,40,40)); } short sheet = which_rect / 100; if(is_old || party) sheet = 0; diff --git a/src/gfx/texture.hpp b/src/gfx/texture.hpp index 4b8d91f3..d9a845fe 100644 --- a/src/gfx/texture.hpp +++ b/src/gfx/texture.hpp @@ -78,6 +78,7 @@ struct Texture { { "dlogscrollwh", {64,64} }, { "edbuttons", {251,164} }, { "edsplash", {640,480} }, + { "errors", {40,40} }, { "fields", {224,144} }, { "fighthelp", {320,125} }, { "icon", {38,38} }, diff --git a/src/scenario/terrain.cpp b/src/scenario/terrain.cpp index d1996b9a..e8a81f64 100644 --- a/src/scenario/terrain.cpp +++ b/src/scenario/terrain.cpp @@ -438,10 +438,10 @@ cPictNum cTerrain::get_map_picture_num() const { if (map_pic<0) return get_picture_num(); - if (map_pic<1000) - return cPictNum(map_pic+(map_pic<960 ? 0 : 400-960),PIC_TER_MAP); + if (map_pic < 1000) + return cPictNum(map_pic,PIC_TER_MAP); if(map_pic < 2000) - return cPictNum(map_pic-1000,PIC_CUSTOM_TER); - return cPictNum(map_pic-2000,PIC_CUSTOM_TER_ANIM); + return cPictNum(map_pic-1000,PIC_CUSTOM_TER_MAP); + return cPictNum(map_pic-2000,PIC_CUSTOM_TER_MAP); // checkme add force PIC_TER_MAP? } diff --git a/src/scenedit/scen.core.cpp b/src/scenedit/scen.core.cpp index 07e10c6c..f63a6b18 100644 --- a/src/scenedit/scen.core.cpp +++ b/src/scenedit/scen.core.cpp @@ -353,15 +353,38 @@ static void fill_ter_info(cDialog& me, short ter){ cTerrain& ter_type = scenario.ter_types[ter]; { cPict& pic_ctrl = dynamic_cast(me["graphic"]); - pic_ctrl.setPict(ter_type.get_picture_num()); + bool bad=false; + if (ter_type.get_picture_num().type==ePicType::PIC_TER) { + // REMOVEME when setPict will not do fatal error + try { + *ResMgr::textures.get("ter" + std::to_string(1 + ter_type.get_picture_num().num / 50)); + } + catch(...) { + bad=true; + } + } + if (!bad) + pic_ctrl.setPict(ter_type.get_picture_num()); + else + pic_ctrl.setPict(cPictNum(1999,ePicType::PIC_CUSTOM_TER)); me["pict"].setTextToNum(ter_type.picture); }{ cPict& pic_ctrl = dynamic_cast(me["seemap"]); - pic_num_t pic = ter_type.map_pic; - if(pic < 1000) - pic_ctrl.setPict(pic, PIC_TER_MAP); - else pic_ctrl.setPict(pic, PIC_CUSTOM_TER_MAP); - me["map"].setTextToNum(pic); + bool bad=false; + if (ter_type.get_map_picture_num().type==ePicType::PIC_TER) { + // REMOVEME when setPict will not do fatal error + try { + *ResMgr::textures.get("ter" + std::to_string(1 + ter_type.get_map_picture_num().num / 50)); + } + catch(...) { + bad=true; + } + } + if (!bad) // FIXME the picture size is bad if we revert to the main picture + pic_ctrl.setPict(ter_type.get_map_picture_num()); + else + pic_ctrl.setPict(cPictNum(1999,ePicType::PIC_CUSTOM_TER)); + me["map"].setTextToNum(ter_type.map_pic); } me["number"].setTextToNum(ter); me["name"].setText(ter_type.name); diff --git a/src/scenedit/scen.graphics.cpp b/src/scenedit/scen.graphics.cpp index b4a4abc8..c82fc2d0 100644 --- a/src/scenedit/scen.graphics.cpp +++ b/src/scenedit/scen.graphics.cpp @@ -318,7 +318,7 @@ static std::vector get_small_icons(location at, ter_num_t t_to_draw) { } static bool get_terrain_picture(cPictNum pict, Texture &source, rectangle &from_rect) -{ +try { source=Texture(); ePicType type=pict.type; if (pict.num<0) @@ -336,8 +336,14 @@ static bool get_terrain_picture(cPictNum pict, Texture &source, rectangle &from_ break; case ePicType::PIC_TER_MAP: source=*ResMgr::textures.get("termap"); - from_rect.left = 12*(pict.num%20); - from_rect.top = 12*(pict.num/20); + if (pict.num<960) { + from_rect.left = 12*(pict.num%20); + from_rect.top = 12*(pict.num/20); + } + else { + from_rect.left = 12*20; + from_rect.top = 12*(pict.num-960); + } from_rect.right = from_rect.left+12; from_rect.bottom = from_rect.top+12; break; @@ -350,10 +356,17 @@ static bool get_terrain_picture(cPictNum pict, Texture &source, rectangle &from_ default: break; } - if (bool(source)) - return true; + if (!source) + throw "can not find image"; + return true; +} +catch (...) { + if (pict.num==-1) // ok no picture + return false; std::cerr << "Error[get_terrain_picture]: can not find picture id=" << pict.num << "type=" << int(pict.type)<< "\n"; - return false; + source = *ResMgr::textures.get("errors"); + from_rect={0,0,40,40}; + return true; } void Set_up_win() {