pict: continue to simplify this code, to be continued...

+ add a tint color to the cPictNum structure.
This commit is contained in:
ALONSO Laurent
2022-01-30 13:53:36 +01:00
committed by Celtic Minstrel
parent c57f2fd13a
commit 49a70570a5
7 changed files with 134 additions and 243 deletions

View File

@@ -27,46 +27,47 @@ const pic_num_t cPict::BLANK = -1;
void cPict::init(){
using namespace std::placeholders;
drawPict()[PIC_TER] = &cPict::drawPresetTer;
drawPict()[PIC_TER_ANIM] = &cPict::drawPresetTerAnim;
// item
for (auto type : { PIC_ITEM, PIC_TINY_ITEM, PIC_CUSTOM_ITEM, PIC_PARTY_ITEM, PIC_CUSTOM_TINY_ITEM})
drawPict()[type] = std::bind(&cPict::drawItem,_1,_2,type, type==PIC_TINY_ITEM || type==PIC_CUSTOM_TINY_ITEM);
// monster
for (auto type : { PIC_MONST, PIC_MONST_WIDE, PIC_MONST_TALL, PIC_MONST_LG,
PIC_CUSTOM_MONST, PIC_CUSTOM_MONST_WIDE, PIC_CUSTOM_MONST_TALL, PIC_CUSTOM_MONST_LG,
PIC_PARTY_MONST, PIC_PARTY_MONST_WIDE, PIC_PARTY_MONST_TALL, PIC_PARTY_MONST_LG,
})
drawPict()[type] = std::bind(&cPict::drawMonster,_1,_2,type);
drawPict()[PIC_CUSTOM_PC] = std::bind(&cPict::drawMonster,_1,_2,PIC_CUSTOM_MONST); // checkme, I am not sure that this can happen
// pc
for (auto type : { PIC_PC, PIC_CUSTOM_PC, PIC_PARTY_PC})
drawPict()[type] = std::bind(&cPict::drawPc,_1,_2,type);
// scenario
for (auto type : { PIC_SCEN, PIC_SCEN_LG})
drawPict()[type] = std::bind(&cPict::drawScenario,_1,_2,type);
drawPict()[PIC_CUSTOM_SCEN] = &cPict::drawCustomTalk;
drawPict()[PIC_PARTY_SCEN] = &cPict::drawPartyScen; // checkme, I am not sure that this can happen
// terrain
for (auto type : { PIC_TER, PIC_TER_ANIM, PIC_TER_MAP, PIC_CUSTOM_TER, PIC_CUSTOM_TER_ANIM, PIC_CUSTOM_TER_MAP})
drawPict()[type] = std::bind(&cPict::drawTerrain,_1,_2,type);
drawPict()[PIC_DLOG] = &cPict::drawPresetDlog;
drawPict()[PIC_TALK] = &cPict::drawPresetTalk;
drawPict()[PIC_SCEN] = &cPict::drawPresetScen;
drawPict()[PIC_ITEM] = &cPict::drawPresetItem;
drawPict()[PIC_TINY_ITEM] = &cPict::drawPresetTinyItem;
drawPict()[PIC_PC] = &cPict::drawPresetPc;
drawPict()[PIC_FIELD] = &cPict::drawPresetField;
drawPict()[PIC_BOOM] = &cPict::drawPresetBoom;
drawPict()[PIC_FULL] = &cPict::drawFullSheet;
drawPict()[PIC_MISSILE] = &cPict::drawPresetMissile;
drawPict()[PIC_DLOG_LG] = &cPict::drawPresetDlogLg;
drawPict()[PIC_SCEN_LG] = &cPict::drawPresetScenLg;
drawPict()[PIC_TER_MAP] = &cPict::drawPresetTerMap;
drawPict()[PIC_STATUS] = &cPict::drawStatusIcon;
drawPict()[PIC_CUSTOM_TER] = &cPict::drawCustomTer;
drawPict()[PIC_CUSTOM_TER_ANIM] = &cPict::drawCustomTerAnim;
drawPict()[PIC_CUSTOM_DLOG] = &cPict::drawCustomDlog;
drawPict()[PIC_CUSTOM_TALK] = &cPict::drawCustomTalk;
drawPict()[PIC_CUSTOM_SCEN] = &cPict::drawCustomTalk;
drawPict()[PIC_CUSTOM_ITEM] = &cPict::drawCustomItem;
drawPict()[PIC_CUSTOM_TINY_ITEM] = &cPict::drawCustomTinyItem;
drawPict()[PIC_CUSTOM_FULL] = &cPict::drawFullSheet;
drawPict()[PIC_CUSTOM_BOOM] = &cPict::drawCustomBoom;
drawPict()[PIC_CUSTOM_MISSILE] = &cPict::drawCustomMissile;
drawPict()[PIC_CUSTOM_DLOG_LG] = &cPict::drawCustomDlogLg;
drawPict()[PIC_CUSTOM_TER_MAP] = &cPict::drawCustomTerMap;
drawPict()[PIC_PARTY_SCEN] = &cPict::drawPartyScen;
drawPict()[PIC_PARTY_ITEM] = &cPict::drawPartyItem;
drawPict()[PIC_PARTY_PC] = &cPict::drawPartyPc;
}
std::map<ePicType,std::function<void(cPict *, rectangle)>>& cPict::drawPict(){
@@ -761,7 +762,12 @@ try {
break;
std::tie(source,from_rect) = spec_scen_g.find_graphic(pict.num);
break;
case ePicType::PIC_PARTY_ITEM:
if (!spec_scen_g)
break;
std::tie(source,from_rect) = spec_scen_g.find_graphic(pict.num, true);
break;
// TODO finish monster code
case ePicType::PIC_MONST:
case ePicType::PIC_MONST_LG:
@@ -865,29 +871,25 @@ catch (...) {
return true;
}
void cPict::drawPresetTer(rectangle to_rect){
Texture source;
rectangle source_rect;
if (!get_picture(getSourcePicture(ePicType::PIC_TER), source, source_rect, animFrame))
return;
if(to_rect.right - to_rect.left > 28)
to_rect.inset(4,0);
rect_draw_some_item(source, source_rect, *inWindow, to_rect);
}
void cPict::drawPresetTerAnim(rectangle to_rect){
Texture source;
rectangle source_rect;
if (!get_picture(getSourcePicture(ePicType::PIC_TER_ANIM), source, source_rect, animFrame))
return;
if(to_rect.right - to_rect.left > 28) {
to_rect.inset(4,0);
to_rect.right = to_rect.left + 28;
void cPict::drawTerrain(rectangle to_rect, ePicType defType)
{
if (defType==PIC_TER_MAP || defType==PIC_CUSTOM_TER_MAP) {
to_rect.right = to_rect.left + 24;
to_rect.bottom = to_rect.top + 24;
}
rect_draw_some_item(source, source_rect, *inWindow, to_rect);
else if(to_rect.right - to_rect.left > 28)
to_rect.inset(4,0);
Texture source;
rectangle source_rect;
cPictNum pict=getSourcePicture(defType);
if (!get_picture(pict, source, source_rect, animFrame)) {
fill_rect(*inWindow, to_rect, sf::Color::Black);
return;
}
rect_draw_some_item(source, source_rect, *inWindow, to_rect, RenderState(sf::BlendNone,pict.tint));
}
void cPict::draw_monster(sf::RenderTarget &window, cPictNum const &pict, rectangle to_rect, int anim)
void cPict::draw_monster(sf::RenderTarget &target, rectangle to_rect, cPictNum const &pict, int anim)
{
Texture source;
rectangle source_rect;
@@ -916,7 +918,7 @@ void cPict::draw_monster(sf::RenderTarget &window, cPictNum const &pict, rectang
continue;
small_monst_rect.left=to_rect.left+w*decal.w;
small_monst_rect.right=small_monst_rect.left+decal.w;
rect_draw_some_item(source, source_rect, window, small_monst_rect, sf::BlendAlpha);
rect_draw_some_item(source, source_rect, target, small_monst_rect, RenderState(sf::BlendAlpha, pict.tint));
}
}
}
@@ -927,7 +929,7 @@ void cPict::drawMonster(rectangle to_rect, ePicType defType)
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
draw_monster(*inWindow, getSourcePicture(defType), to_rect, animFrame);
draw_monster(*inWindow, to_rect, getSourcePicture(defType), animFrame);
}
void cPict::drawPresetDlog(rectangle to_rect){
@@ -936,9 +938,10 @@ void cPict::drawPresetDlog(rectangle to_rect){
Texture source;
rectangle source_rect;
if (!get_picture(getSourcePicture(ePicType::PIC_DLOG), source, source_rect, animFrame))
cPictNum pict=getSourcePicture(ePicType::PIC_DLOG);
if (!get_picture(pict, source, source_rect, animFrame))
return;
rect_draw_some_item(source, source_rect, *inWindow, to_rect);
rect_draw_some_item(source, source_rect, *inWindow, to_rect, RenderState(sf::BlendNone,pict.tint));
}
void cPict::drawPresetDlogLg(rectangle to_rect){
@@ -947,9 +950,10 @@ void cPict::drawPresetDlogLg(rectangle to_rect){
Texture source;
rectangle source_rect;
if (!get_picture(getSourcePicture(ePicType::PIC_DLOG_LG), source, source_rect, animFrame))
cPictNum pict=getSourcePicture(ePicType::PIC_DLOG_LG);
if (!get_picture(pict, source, source_rect, animFrame))
return;
rect_draw_some_item(source, source_rect, *inWindow, to_rect);
rect_draw_some_item(source, source_rect, *inWindow, to_rect, RenderState(sf::BlendNone,pict.tint));
}
void cPict::drawPresetTalk(rectangle to_rect){
@@ -958,68 +962,71 @@ void cPict::drawPresetTalk(rectangle to_rect){
Texture source;
rectangle source_rect;
if (!get_picture(getSourcePicture(ePicType::PIC_TALK), source, source_rect, animFrame))
return;
rect_draw_some_item(source, source_rect, *inWindow, to_rect);
}
void cPict::drawPresetScen(rectangle to_rect){
to_rect.right = to_rect.left + 32;
to_rect.bottom = to_rect.top + 32;
Texture source;
rectangle source_rect;
if (!get_picture(getSourcePicture(ePicType::PIC_SCEN), source, source_rect, animFrame))
return;
rect_draw_some_item(source, source_rect, *inWindow, to_rect);
}
void cPict::drawPresetScenLg(rectangle to_rect){
to_rect.right = to_rect.left + (drawScaled ? getBounds().width() : 64);
to_rect.bottom = to_rect.top + (drawScaled ? getBounds().height() : 64);
Texture source;
rectangle source_rect;
if (!get_picture(getSourcePicture(ePicType::PIC_SCEN_LG), source, source_rect, animFrame))
return;
rect_draw_some_item(source, source_rect, *inWindow, to_rect);
}
void cPict::drawPresetItem(rectangle to_rect){
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
Texture source;
rectangle source_rect;
auto pict=getSourcePicture(ePicType::PIC_ITEM);
cPictNum pict=getSourcePicture(ePicType::PIC_TALK);
if (!get_picture(pict, source, source_rect, animFrame))
return;
if (pict.type==ePicType::PIC_TINY_ITEM || (pict.type==ePicType::PIC_ITEM && pict.num>=55))
to_rect.inset(5,9);
rect_draw_some_item(source, source_rect, *inWindow, to_rect, sf::BlendAlpha);
rect_draw_some_item(source, source_rect, *inWindow, to_rect, RenderState(sf::BlendNone,pict.tint));
}
void cPict::drawPresetTinyItem(rectangle to_rect){
to_rect.right = to_rect.left + 18;
to_rect.bottom = to_rect.top + 18;
void cPict::drawScenario(rectangle to_rect, ePicType defType)
{
int const w=(drawScaled && defType==ePicType::PIC_SCEN_LG) ? 64 : 32;
to_rect.right = to_rect.left + w;
to_rect.bottom = to_rect.top + w;
Texture source;
rectangle source_rect;
cPictNum pict=getSourcePicture(defType);
if (!get_picture(pict, source, source_rect, animFrame))
return;
rect_draw_some_item(source, source_rect, *inWindow, to_rect, RenderState(sf::BlendNone,pict.tint));
}
void cPict::drawPartyScen(rectangle to_rect){
auto from_gw = getSheet(SHEET_HEADER);
rectangle from_rect = {0,0,32,32};
from_rect.offset(32 * (picture.num % 5),32 * (picture.num / 5));
to_rect.right = to_rect.left + 32;
to_rect.bottom = to_rect.top + 32;
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, RenderState(sf::BlendNone,picture.tint));
}
void cPict::drawItem(rectangle to_rect, ePicType defType, bool inTinyRect)
{
if (inTinyRect) {
to_rect.right = to_rect.left + 18;
to_rect.bottom = to_rect.top + 18;
}
else {
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
}
fill_rect(*inWindow, to_rect, sf::Color::Black);
Texture source;
rectangle source_rect;
if (!get_picture(getSourcePicture(ePicType::PIC_TINY_ITEM), source, source_rect, animFrame))
rectangle source_rect; auto pict=getSourcePicture(defType);
if (!get_picture(pict, source, source_rect, animFrame))
return;
rect_draw_some_item(source, source_rect, *inWindow, to_rect, sf::BlendAlpha);
if (!inTinyRect) {
if (pict.type==ePicType::PIC_TINY_ITEM || pict.type==ePicType::PIC_CUSTOM_TINY_ITEM || (pict.type==ePicType::PIC_ITEM && pict.num>=55))
to_rect.inset(5,9);
}
rect_draw_some_item(source, source_rect, *inWindow, to_rect, RenderState(sf::BlendAlpha,pict.tint));
}
void cPict::drawPresetPc(rectangle to_rect){
Texture source;
rectangle source_rect;
if (!get_picture(getSourcePicture(ePicType::PIC_PC), source, source_rect, animFrame))
return;
void cPict::drawPc(rectangle to_rect, ePicType defType)
{
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
rect_draw_some_item(source, source_rect, *inWindow, to_rect, sf::BlendAlpha);
Texture source;
rectangle source_rect;
cPictNum pict=getSourcePicture(defType);
if (!get_picture(pict, source, source_rect, animFrame))
return;
rect_draw_some_item(source, source_rect, *inWindow, to_rect, RenderState(sf::BlendAlpha,pict.tint));
}
void cPict::drawPresetField(rectangle to_rect){
@@ -1028,7 +1035,7 @@ void cPict::drawPresetField(rectangle to_rect){
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, RenderState(sf::BlendAlpha,picture.tint));
}
void cPict::drawPresetBoom(rectangle to_rect){
@@ -1041,7 +1048,7 @@ void cPict::drawPresetBoom(rectangle to_rect){
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, RenderState(sf::BlendAlpha,picture.tint));
}
void cPict::drawFullSheet(rectangle to_rect){
@@ -1052,7 +1059,7 @@ void cPict::drawFullSheet(rectangle to_rect){
to_rect.right = to_rect.left + (from_rect.right - from_rect.left);
to_rect.bottom = to_rect.top + (from_rect.bottom - from_rect.top);
}
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, RenderState(sf::BlendNone,picture.tint));
}
void cPict::drawPresetMissile(rectangle to_rect){
@@ -1063,18 +1070,7 @@ void cPict::drawPresetMissile(rectangle to_rect){
fill_rect(*inWindow, to_rect, sf::Color::Black);
short i = animFrame % 8;
from_rect.offset(18 * i, 18 * picture.num);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
}
void cPict::drawPresetTerMap(rectangle to_rect){
Texture source;
rectangle source_rect;
if (!get_picture(getSourcePicture(ePicType::PIC_TER_MAP), source, source_rect, animFrame))
return;
// TODO: Should probably fill black somewhere in here...?
to_rect.right = to_rect.left + 24;
to_rect.bottom = to_rect.top + 24;
rect_draw_some_item(source, source_rect, *inWindow, to_rect);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, RenderState(sf::BlendAlpha,picture.tint));
}
void cPict::drawStatusIcon(rectangle to_rect){
@@ -1088,27 +1084,7 @@ void cPict::drawStatusIcon(rectangle to_rect){
pat_rect.inset(-1,-1);
tileImage(*inWindow, pat_rect, bg[6]);
}
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
}
void cPict::drawCustomTer(rectangle to_rect){
Texture source;
rectangle source_rect;
if (!get_picture(getSourcePicture(ePicType::PIC_CUSTOM_TER), source, source_rect, animFrame))
return;
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
rect_draw_some_item(source, source_rect, *inWindow, to_rect);
}
void cPict::drawCustomTerAnim(rectangle to_rect){
Texture source;
rectangle source_rect;
if (!get_picture(getSourcePicture(ePicType::PIC_CUSTOM_TER), source, source_rect, animFrame))
return;
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
rect_draw_some_item(source, source_rect, *inWindow, to_rect);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, RenderState(sf::BlendAlpha,picture.tint));
}
// This is a super-hacky way to wedge in scaled form, but at least it should work.
@@ -1123,18 +1099,18 @@ void cPict::drawCustomNumDlog(int num, rectangle to_rect){
to_rect.right = to_rect.left + dlog_to_w;
to_rect.bottom = to_rect.top + dlog_to_h;
if (get_picture(pict, source, source_rect, animFrame))
rect_draw_some_item(source, source_rect, *inWindow, to_rect);
rect_draw_some_item(source, source_rect, *inWindow, to_rect, RenderState(sf::BlendNone,pict.tint));
to_rect.offset(dlog_to_w,0);
++pict.num;
if (get_picture(pict, source, source_rect, animFrame))
rect_draw_some_item(source, source_rect, *inWindow, to_rect);
rect_draw_some_item(source, source_rect, *inWindow, to_rect, RenderState(sf::BlendNone,pict.tint));
}
else {
to_rect.right = to_rect.left + 36;
to_rect.bottom = to_rect.top + 36;
if (get_picture(pict, source, source_rect, animFrame))
rect_draw_some_item(source, source_rect, *inWindow, to_rect);
rect_draw_some_item(source, source_rect, *inWindow, to_rect, RenderState(sf::BlendNone,pict.tint));
}
}
@@ -1169,37 +1145,13 @@ void cPict::drawCustomTalk(rectangle to_rect){
to_rect.bottom = to_rect.top + 32;
from_rect.right = from_rect.left + 16;
from_rect.bottom = from_rect.top + 32;
rect_draw_some_item(from_gw, from_rect, *inWindow, to_rect);
rect_draw_some_item(from_gw, from_rect, *inWindow, to_rect, RenderState(sf::BlendNone,picture.tint));
std::tie(from_gw,from_rect) = spec_scen_g.find_graphic(picture.num+1);
to_rect.offset(16,0);
from_rect.right = from_rect.left + 16;
from_rect.bottom = from_rect.top + 32;
rect_draw_some_item(from_gw, from_rect, *inWindow, to_rect);
}
void cPict::drawCustomItem(rectangle to_rect){
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
Texture source;
rectangle source_rect;
if (!get_picture(getSourcePicture(ePicType::PIC_CUSTOM_ITEM), source, source_rect, animFrame))
return;
rect_draw_some_item(source, source_rect, *inWindow, to_rect, sf::BlendAlpha);
}
void cPict::drawCustomTinyItem(rectangle to_rect){
to_rect.right = to_rect.left + 18;
to_rect.bottom = to_rect.top + 18;
fill_rect(*inWindow, to_rect, sf::Color::Black);
Texture source;
rectangle source_rect;
if (!get_picture(getSourcePicture(ePicType::PIC_CUSTOM_TINY_ITEM), source, source_rect, animFrame))
return;
rect_draw_some_item(source, source_rect, *inWindow, to_rect, sf::BlendAlpha);
rect_draw_some_item(from_gw, from_rect, *inWindow, to_rect, RenderState(sf::BlendNone,picture.tint));
}
void cPict::drawCustomBoom(rectangle to_rect){
@@ -1209,7 +1161,7 @@ void cPict::drawCustomBoom(rectangle to_rect){
rectangle from_rect;
std::tie(from_gw,from_rect) = spec_scen_g.find_graphic(picture.num + animFrame % 8);
fill_rect(*inWindow, to_rect, sf::Color::Black);
rect_draw_some_item(from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
rect_draw_some_item(from_gw, from_rect, *inWindow, to_rect, RenderState(sf::BlendAlpha,picture.tint));
}
void cPict::drawCustomMissile(rectangle to_rect){
@@ -1221,44 +1173,7 @@ void cPict::drawCustomMissile(rectangle to_rect){
if(animFrame >= 4) from_rect.offset(0, 18);
fill_rect(*inWindow, to_rect, sf::Color::Black);
to_rect.inset(5,9);
rect_draw_some_item(from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
}
void cPict::drawCustomTerMap(rectangle to_rect){
Texture source;
rectangle source_rect;
if (!get_picture(getSourcePicture(ePicType::PIC_CUSTOM_TER_MAP), source, source_rect, animFrame))
return;
rect_draw_some_item(source, source_rect, *inWindow, to_rect);
}
void cPict::drawPartyScen(rectangle to_rect){
auto from_gw = getSheet(SHEET_HEADER);
rectangle from_rect = {0,0,32,32};
from_rect.offset(32 * (picture.num % 5),32 * (picture.num / 5));
to_rect.right = to_rect.left + 32;
to_rect.bottom = to_rect.top + 32;
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect);
}
void cPict::drawPartyItem(rectangle to_rect){
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
Texture from_gw;
rectangle from_rect;
std::tie(from_gw,from_rect) = spec_scen_g.find_graphic(picture.num, true);
fill_rect(*inWindow, to_rect, sf::Color::Black);
rect_draw_some_item(from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
}
void cPict::drawPartyPc(rectangle to_rect){
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
Texture from_gw;
rectangle from_rect;
std::tie(from_gw,from_rect) = spec_scen_g.find_graphic(picture.num, true);
fill_rect(*inWindow, to_rect, sf::Color::Black);
rect_draw_some_item(from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
rect_draw_some_item(from_gw, from_rect, *inWindow, to_rect, RenderState(sf::BlendAlpha,picture.tint));
}
cPict::~cPict() {}
@@ -1273,7 +1188,7 @@ void cPict::drawAt(sf::RenderWindow& win, rectangle dest, pic_num_t which_g, ePi
cControl::storage_t cPict::store() {
storage_t storage = cControl::store();
storage["pic-num"] = picture.num;
storage["pic-num"] = picture;
storage["pic-type"] = resultType;
return storage;
}
@@ -1281,7 +1196,7 @@ cControl::storage_t cPict::store() {
void cPict::restore(storage_t to) {
cControl::restore(to);
if(to.find("pic-num") != to.end())
picture.num = boost::any_cast<pic_num_t>(to["pic-num"]);
picture = boost::any_cast<cPictNum>(to["pic-num"]);
if(to.find("pic-type") != to.end())
resultType = boost::any_cast<ePicType>(to["pic-type"]);
}

View File

@@ -25,15 +25,17 @@
class cPictNum {
public:
cPictNum(pic_num_t nNum=-1, ePicType nType=ePicType::PIC_NONE)
cPictNum(pic_num_t nNum=-1, ePicType nType=ePicType::PIC_NONE, unsigned long tintMod=0)
: num(nNum)
, type(nType)
, tint(tintMod)
{
}
bool operator==(const cPictNum&pict) const { return num==pict.num && type == pict.type; }
bool operator==(const cPictNum&pict) const { return num==pict.num && type == pict.type && tint == pict.tint; }
bool operator!=(const cPictNum&pict) const { return !operator==(pict);}
pic_num_t num;
ePicType type;
unsigned long tint;
};
std::ostream& operator<< (std::ostream& out, cPictNum pic);
@@ -97,7 +99,7 @@ public:
void draw() override;
// only implemented for major type
static bool get_picture(cPictNum const &pict, Texture &source, rectangle &from_rect, int anim=0, int which_part=0);
static void draw_monster(sf::RenderTarget &window, cPictNum const &pict, rectangle to_rect, int anim=0);
static void draw_monster(sf::RenderTarget &target, rectangle to_rect, cPictNum const &pict, int anim=0);
/// A utility function to draw an icon into an arbitrary window.
/// @param win The window to draw in.
@@ -126,37 +128,26 @@ private:
// Transient parse flags
bool wide = false, tall = false, tiny = false, custom = false, blank = false;
void updateResultType(ePicType type);
void drawItem(rectangle to_rect, ePicType defType, bool inTinyRect);
void drawMonster(rectangle to_rect, ePicType defType);
void drawPresetTer(rectangle to_rect);
void drawPresetTerAnim(rectangle to_rect);
void drawPc(rectangle to_rect, ePicType defType);
void drawScenario(rectangle to_rect, ePicType defType);
void drawTerrain(rectangle to_rect, ePicType defType);
void drawPresetDlog(rectangle to_rect);
void drawPresetDlogLg(rectangle to_rect);
void drawPresetTalk(rectangle to_rect);
void drawPresetScen(rectangle to_rect);
void drawPresetScenLg(rectangle to_rect);
void drawPresetItem(rectangle to_rect);
void drawPresetTinyItem(rectangle to_rect);
void drawPresetPc(rectangle to_rect);
void drawPresetField(rectangle to_rect);
void drawPresetBoom(rectangle to_rect);
void drawPresetMissile(rectangle to_rect);
void drawPresetTerMap(rectangle to_rect);
void drawStatusIcon(rectangle to_rect);
void drawFullSheet(rectangle to_rect);
void drawCustomTer(rectangle to_rect);
void drawCustomTerAnim(rectangle to_rect);
void drawCustomNumDlog(int num, rectangle to_rect);
void drawCustomDlog(rectangle to_rect);
void drawCustomDlogLg(rectangle to_rect);
void drawCustomTalk(rectangle to_rect);
void drawCustomItem(rectangle to_rect);
void drawCustomTinyItem(rectangle to_rect);
void drawCustomBoom(rectangle to_rect);
void drawCustomMissile(rectangle to_rect);
void drawCustomTerMap(rectangle to_rect);
void drawPartyScen(rectangle to_rect);
void drawPartyItem(rectangle to_rect);
void drawPartyPc(rectangle to_rect);
cPictNum getSourcePicture(ePicType defaultType) const {
cPictNum res=picture;
if (res.type==ePicType::PIC_NONE) res.type=defaultType;

View File

@@ -108,7 +108,7 @@ void draw_monsters() {
if(picture.type!=ePicType::PIC_NONE) {
to_rect={0,0,36,28};
to_rect.offset(13 + 28 * where_draw.x,13 + 36 * where_draw.y);
cPict::draw_monster(terrain_screen_gworld, picture, to_rect, (enc.direction < 4 ? 0 : 2));
cPict::draw_monster(terrain_screen_gworld, to_rect, picture, (enc.direction < 4 ? 0 : 2));
} else enc.exists = false;
}
}

View File

@@ -132,8 +132,8 @@ cPictNum get_monst_picture_num(mon_num_t monst) {
}
short get_monst_picnum(mon_num_t monst) {
if(monst >= 10000) return univ.party.get_summon(monst - 10000).picture_num;
return univ.scenario.get_monster(monst).picture_num;
if(monst >= 10000) return univ.party.get_summon(monst - 10000).get_num_for_picture();
return univ.scenario.get_monster(monst).get_num_for_picture();
}
std::pair<short,short> get_monst_dims(mon_num_t monst) {

View File

@@ -76,6 +76,9 @@ public:
cPictNum get_picture_num() const {
return get_picture_num(picture_num);
}
pic_num_t get_num_for_picture() const {
return picture_num;
}
static cPictNum get_picture_num(pic_num_t pic);
static pic_num_t get_num_for_picture(cPictNum const &pic);

View File

@@ -412,7 +412,7 @@ void set_up_terrain_buttons(bool reset) {
}
case DRAW_MONST:
frame_rect(mainPtr, draw_rect, sf::Color::Black);
cPict::draw_monster(mainPtr, scenario.get_monster(i).get_picture_num(), draw_rect);
cPict::draw_monster(mainPtr, draw_rect, scenario.get_monster(i).get_picture_num());
break;
case DRAW_ITEM:
Texture source_gworld;
@@ -1030,7 +1030,7 @@ void place_location() {
extern short mode_count;
bool draw_field = false;
if(overall_mode == MODE_PLACE_CREATURE || overall_mode == MODE_PLACE_SAME_CREATURE)
cPict::draw_monster(mainPtr, scenario.get_monster(mode_count).get_picture_num(), draw_rect);
cPict::draw_monster(mainPtr, draw_rect, scenario.get_monster(mode_count).get_picture_num());
else if(overall_mode == MODE_PLACE_ITEM || overall_mode == MODE_PLACE_SAME_ITEM) {
cPictNum pic=scenario.get_item(mode_count).get_picture_num(false);
Texture source_gworld;

View File

@@ -124,26 +124,8 @@ void put_monst_info(cDialog& me, const cMonster& store_m, const cScenario& scen)
cPict& pic = dynamic_cast<cPict&>(me["pic"]);
if(store_m.invisible)
pic.setPict(-1,PIC_MONST);
else if(store_m.picture_num < 1000)
pic.setPict(store_m.picture_num,PIC_MONST);
else {
ePicType type_g = PIC_CUSTOM_MONST;
short size_g = store_m.picture_num / 1000;
switch(size_g){
case 2:
type_g += PIC_WIDE;
break;
case 3:
type_g += PIC_TALL;
break;
case 4:
type_g += PIC_WIDE;
type_g += PIC_TALL;
break;
}
pic.setPict(store_m.picture_num % 1000, type_g);
}
else
pic.setPict(store_m.get_picture_num(), true);
me["name"].setText(store_m.m_name);
i = 1;