implement vehicle pictype (presets only, for now)

This commit is contained in:
2025-09-04 17:03:10 -05:00
parent c7c10f5381
commit 370a106def
6 changed files with 49 additions and 6 deletions

View File

@@ -69,6 +69,10 @@ void cPict::init(){
drawPict()[PIC_PARTY_MONST_TALL] = &cPict::drawPartyMonstTall;
drawPict()[PIC_PARTY_MONST_LG] = &cPict::drawPartyMonstLg;
drawPict()[PIC_BTN] = &cPict::drawInvenBtn;
drawPict()[PIC_VEHICLE] = &cPict::drawPresetVehicle;
drawPict()[PIC_VEHICLE_OCCUPIED] = &cPict::drawPresetVehicleOccupied;
drawPict()[PIC_CUSTOM_VEHICLE] = &cPict::drawPresetVehicle; // TODO
drawPict()[PIC_CUSTOM_VEHICLE_OCCUPIED] = &cPict::drawPresetVehicleOccupied;
}
std::map<ePicType,void(cPict::*)(short,rectangle,sf::RenderTarget&)>& cPict::drawPict(){
@@ -562,6 +566,7 @@ void cPict::recalcRect() {
case PIC_PC: case PIC_PARTY_PC:
case PIC_FIELD:
case PIC_BOOM: case PIC_CUSTOM_BOOM:
case PIC_VEHICLE: case PIC_VEHICLE_OCCUPIED: case PIC_CUSTOM_VEHICLE: case PIC_CUSTOM_VEHICLE_OCCUPIED:
bounds.width() = 28;
bounds.height() = 36;
break;
@@ -716,7 +721,12 @@ std::shared_ptr<const sf::Texture> cPict::getSheetInternal(eSheetType type, size
// TODO: The scenario should be allowed to define a sheet1400.png without it being ignored in favour of outhelp.png
purgeable = false;
sout << "sheet" << n;
break;
}
break;
case SHEET_VEHICLE:
sout << "vehicle";
break;
}
auto name = sout.str();
try {
@@ -1388,8 +1398,30 @@ void cPict::drawInvenBtn(short num, rectangle to_rect, sf::RenderTarget& targ){
if(num >= n_pics) return;
auto from_gw = getSheet(SHEET_INVENBTN);
if(!from_gw) return;
if(filled) fill_rect(getWindow(), to_rect, fillClr);
rect_draw_some_item(*from_gw, from_rect[num], getWindow(), to_rect, sf::BlendAlpha);
if(filled) fill_rect(targ, to_rect, fillClr);
rect_draw_some_item(*from_gw, from_rect[num], targ, to_rect, sf::BlendAlpha);
}
void cPict::drawPresetVehicle(short num, rectangle to_rect, sf::RenderTarget& targ){
if(num >= 3) return;
rectangle from_rect = {0, 0, 36, 28};
auto from_gw = getSheet(SHEET_VEHICLE);
if(!from_gw) return;
if(filled) fill_rect(targ, to_rect, fillClr);
from_rect.offset(0, num * 36);
rect_draw_some_item(*from_gw, from_rect, targ, to_rect, sf::BlendAlpha);
}
void cPict::drawPresetVehicleOccupied(short num, rectangle to_rect, sf::RenderTarget& targ){
LOG("occupied draw");
if(num >= 3) return;
rectangle from_rect = {0, 0, 36, 28};
auto from_gw = getSheet(SHEET_VEHICLE);
if(!from_gw) return;
if(filled) fill_rect(targ, to_rect, fillClr);
from_rect.offset(56, num * 36);
rect_draw_some_item(*from_gw, from_rect, targ, to_rect, sf::BlendAlpha);
LOG("occupied draw done");
}
cPict::~cPict() {}

View File

@@ -146,6 +146,8 @@ private:
void drawPartyItem(short num, rectangle to_rect, sf::RenderTarget& targ);
void drawPartyPc(short num, rectangle to_rect, sf::RenderTarget& targ);
void drawInvenBtn(short num, rectangle to_rect, sf::RenderTarget& targ);
void drawPresetVehicle(short num, rectangle to_rect, sf::RenderTarget& targ);
void drawPresetVehicleOccupied(short num, rectangle to_rect, sf::RenderTarget& targ);
static std::map<ePicType,void(cPict::*)(short,rectangle,sf::RenderTarget&)>& drawPict();
};

View File

@@ -34,6 +34,8 @@ enum ePicType {
PIC_STATUS = 16, ///< 12x12 status icon
PIC_TINY_ITEM = 17, ///< 18x18 item graphic from the small item sheet
PIC_BTN = 18, ///< Button graphic from the inventory buttons sheet (various sizes)
PIC_VEHICLE = 19, ///< 28x36 vehicle graphic from the preset vehicles sheet
PIC_VEHICLE_OCCUPIED = 20, ///< 28x36 vehicle graphic from the preset vehicles sheet, occupied
PIC_MONST_WIDE = 23, ///< 56x36 monster graphic from the preset sheets, resized to fit and centred in a 28x36 space
PIC_MONST_TALL = 43, ///< 28x72 monster graphic from the preset sheets, resized to fit and centred in a 28x36 space
PIC_MONST_LG = 63, ///< 56x72 monster graphic from the preset sheets, resized to fit in a 28x36 space
@@ -50,6 +52,8 @@ enum ePicType {
PIC_CUSTOM_DLOG_LG = 113, ///< 72x72 dialog graphic from the custom sheet, taken from 8 successive slots
PIC_CUSTOM_TER_MAP = 115, ///< 12x12 map graphic taken from the custom sheet and expanded to 24x24
PIC_CUSTOM_TINY_ITEM = 117, ///< 28x36 custom item graphic shrunk down into an 18x18 space
PIC_CUSTOM_VEHICLE = 119, ///< 28x36 custom vehicle graphic (TODO not implemented)
PIC_CUSTOM_VEHICLE_OCCUPIED = 120,///< 28x36 custom vehicle graphic, occupied (TODO not implemented)
PIC_CUSTOM_MONST_WIDE = 123,///< 56x36 monster graphic from the custom sheets, resized to fit and centred in a 28x36 space
PIC_CUSTOM_MONST_TALL = 143,///< 28x72 monster graphic from the custom sheets, resized to fit and centred in a 28x36 space
PIC_CUSTOM_MONST_LG = 163, ///< 56x72 monster graphic from the custom sheets, resized to fit in a 28x36 space
@@ -96,7 +100,7 @@ enum eSheetType {
SHEET_STATUS, ///< The status icons sheet, staticons.png
SHEET_INVENBTN, ///< Inventory buttons sheet, invenbtns.png
SHEET_CUSTOM, ///< Any custom graphics sheet
// TODO: Vehicle sheet is missing.
SHEET_VEHICLE, ///< Preset vehicle graphics in vehicles.png
// TODO: Documentation of full, custom, header, and exported sheets is still lacking.
NUM_SHEET_TYPES
};