Scenario: use cPictNum to retrieve the ter_map pictures...
This commit is contained in:
@@ -428,6 +428,20 @@ cPictNum cTerrain::get_picture_num_for_terrain(pic_num_t bigPicture)
|
|||||||
return cPictNum(bigPicture-960,PIC_TER_ANIM);
|
return cPictNum(bigPicture-960,PIC_TER_ANIM);
|
||||||
if(bigPicture < 2000)
|
if(bigPicture < 2000)
|
||||||
return cPictNum(bigPicture-1000,PIC_CUSTOM_TER);
|
return cPictNum(bigPicture-1000,PIC_CUSTOM_TER);
|
||||||
|
if (bigPicture>=10000) // force to use PIC_TER
|
||||||
|
return cPictNum(bigPicture-10000,PIC_TER);
|
||||||
|
else
|
||||||
return cPictNum(bigPicture-2000,PIC_CUSTOM_TER_ANIM);
|
return cPictNum(bigPicture-2000,PIC_CUSTOM_TER_ANIM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 < 2000)
|
||||||
|
return cPictNum(map_pic-1000,PIC_CUSTOM_TER);
|
||||||
|
return cPictNum(map_pic-2000,PIC_CUSTOM_TER_ANIM);
|
||||||
|
// checkme add force PIC_TER_MAP?
|
||||||
|
}
|
||||||
|
@@ -50,6 +50,7 @@ public:
|
|||||||
cPictNum get_picture_num() const {
|
cPictNum get_picture_num() const {
|
||||||
return get_picture_num_for_terrain(picture);
|
return get_picture_num_for_terrain(picture);
|
||||||
}
|
}
|
||||||
|
cPictNum get_map_picture_num() const;
|
||||||
static cPictNum get_picture_num_for_terrain(pic_num_t bigPicture);
|
static cPictNum get_picture_num_for_terrain(pic_num_t bigPicture);
|
||||||
void import_legacy(legacy::terrain_type_type const &old);
|
void import_legacy(legacy::terrain_type_type const &old);
|
||||||
void writeTo(std::ostream& file) const;
|
void writeTo(std::ostream& file) const;
|
||||||
|
@@ -320,7 +320,10 @@ static std::vector<short> get_small_icons(location at, ter_num_t t_to_draw) {
|
|||||||
static bool get_terrain_picture(cPictNum pict, Texture &source, rectangle &from_rect)
|
static bool get_terrain_picture(cPictNum pict, Texture &source, rectangle &from_rect)
|
||||||
{
|
{
|
||||||
source=Texture();
|
source=Texture();
|
||||||
switch (pict.type) {
|
ePicType type=pict.type;
|
||||||
|
if (pict.num<0)
|
||||||
|
type=ePicType::PIC_NONE;
|
||||||
|
switch (type) {
|
||||||
case ePicType::PIC_TER: {
|
case ePicType::PIC_TER: {
|
||||||
source = *ResMgr::textures.get("ter" + std::to_string(1 + pict.num / 50));
|
source = *ResMgr::textures.get("ter" + std::to_string(1 + pict.num / 50));
|
||||||
int picture_wanted = pict.num%50;
|
int picture_wanted = pict.num%50;
|
||||||
@@ -331,6 +334,13 @@ static bool get_terrain_picture(cPictNum pict, Texture &source, rectangle &from_
|
|||||||
source = *ResMgr::textures.get("teranim");
|
source = *ResMgr::textures.get("teranim");
|
||||||
from_rect = calc_rect(4 * (pict.num / 5),pict.num % 5);
|
from_rect = calc_rect(4 * (pict.num / 5),pict.num % 5);
|
||||||
break;
|
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);
|
||||||
|
from_rect.right = from_rect.left+12;
|
||||||
|
from_rect.bottom = from_rect.top+12;
|
||||||
|
break;
|
||||||
case ePicType::PIC_CUSTOM_TER:
|
case ePicType::PIC_CUSTOM_TER:
|
||||||
case ePicType::PIC_CUSTOM_TER_ANIM: // checkme
|
case ePicType::PIC_CUSTOM_TER_ANIM: // checkme
|
||||||
if (!spec_scen_g)
|
if (!spec_scen_g)
|
||||||
@@ -1140,37 +1150,12 @@ void draw_one_terrain_spot (short i,short j,ter_num_t terrain_to_draw) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void draw_one_tiny_terrain_spot (short i,short j,ter_num_t terrain_to_draw,short size,bool road) {
|
void draw_one_tiny_terrain_spot (short i,short j,ter_num_t terrain_to_draw,short size,bool road) {
|
||||||
rectangle dest_rect = {0,0,size,size},from_rect = {0,0,12,12};
|
rectangle from_rect;
|
||||||
short picture_wanted;
|
|
||||||
Texture source_gworld;
|
Texture source_gworld;
|
||||||
|
rectangle dest_rect = {0,0,size,size};
|
||||||
picture_wanted = scenario.ter_types[terrain_to_draw].map_pic;
|
|
||||||
|
|
||||||
dest_rect.offset(8 + TER_RECT_UL_X + size * i, 8 + TER_RECT_UL_Y + size * j);
|
dest_rect.offset(8 + TER_RECT_UL_X + size * i, 8 + TER_RECT_UL_Y + size * j);
|
||||||
if(picture_wanted == NO_PIC) {
|
if (get_terrain_picture(scenario.ter_types[terrain_to_draw].get_map_picture_num(), source_gworld, from_rect))
|
||||||
if (get_terrain_picture(scenario.ter_types[terrain_to_draw].get_picture_num(), source_gworld, from_rect))
|
|
||||||
rect_draw_some_item(source_gworld, from_rect, mainPtr, dest_rect);
|
rect_draw_some_item(source_gworld, from_rect, mainPtr, dest_rect);
|
||||||
} else {
|
|
||||||
if(picture_wanted >= 1000) {
|
|
||||||
Texture from_gw;
|
|
||||||
std::tie(from_gw,from_rect) = spec_scen_g.find_graphic(picture_wanted % 1000);
|
|
||||||
from_rect.right = from_rect.left + 12;
|
|
||||||
from_rect.bottom = from_rect.top + 12;
|
|
||||||
picture_wanted /= 1000; picture_wanted--;
|
|
||||||
from_rect.offset((picture_wanted / 3) * 12, (picture_wanted % 3) * 12);
|
|
||||||
rect_draw_some_item(from_gw, from_rect, mainPtr, dest_rect);
|
|
||||||
} else {
|
|
||||||
auto const & small_ter_gworld = *ResMgr::textures.get("termap");
|
|
||||||
if(picture_wanted >= 960) {
|
|
||||||
picture_wanted -= 960;
|
|
||||||
from_rect.offset(12 * 20, (picture_wanted - 960) * 12);
|
|
||||||
rect_draw_some_item(small_ter_gworld, from_rect, mainPtr, dest_rect);
|
|
||||||
} else {
|
|
||||||
from_rect.offset((picture_wanted % 20) * 12,(picture_wanted / 20) * 12);
|
|
||||||
rect_draw_some_item(small_ter_gworld, from_rect, mainPtr, dest_rect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(road) {
|
if(road) {
|
||||||
rectangle road_rect = dest_rect;
|
rectangle road_rect = dest_rect;
|
||||||
int border = (size - 4) / 2;
|
int border = (size - 4) / 2;
|
||||||
|
Reference in New Issue
Block a user