Skip to content

Commit

Permalink
Add a 'filled' option to dialogxml pict and use it in get-items
Browse files Browse the repository at this point in the history
Fix #629
  • Loading branch information
CelticMinstrel committed Mar 2, 2025
1 parent 34725b0 commit 014f562
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 33 deletions.
16 changes: 8 additions & 8 deletions rsrc/dialogs/get-items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,35 @@
<text name='title' size='large' top='6' left='64' width='199' height='18'>You Find:</text>
<text framed='true' top='31' left='73' width='327' height='309'/>
<text name='item1-key' top='37' left='74' width='311' height='36'/>
<pict name='item1-g' type='item' num='0' top='37' left='80'/>
<pict name='item1-g' framed='false' filled='false' type='item' num='0' top='37' left='80'/>
<text name='item1-name' top='37' left='107' width='212' height='18'/>
<text name='item1-detail' top='55' left='116' width='275' height='17'/>
<text name='item2-key' top='74' left='74' width='311' height='36'/>
<pict name='item2-g' type='item' num='0' top='74' left='80'/>
<pict name='item2-g' framed='false' filled='false' type='item' num='0' top='74' left='80'/>
<text name='item2-name' top='74' left='107' width='212' height='18'/>
<text name='item2-detail' top='92' left='116' width='275' height='17'/>
<text name='item3-key' top='111' left='74' width='311' height='36'/>
<pict name='item3-g' type='item' num='0' top='111' left='80'/>
<pict name='item3-g' framed='false' filled='false' type='item' num='0' top='111' left='80'/>
<text name='item3-name' top='111' left='107' width='212' height='18'/>
<text name='item3-detail' top='129' left='116' width='275' height='17'/>
<text name='item4-key' top='148' left='74' width='311' height='36'/>
<pict name='item4-g' type='item' num='0' top='148' left='80'/>
<pict name='item4-g' framed='false' filled='false' type='item' num='0' top='148' left='80'/>
<text name='item4-name' top='148' left='107' width='212' height='18'/>
<text name='item4-detail' top='166' left='116' width='275' height='17'/>
<text name='item5-key' top='185' left='74' width='311' height='36'/>
<pict name='item5-g' type='item' num='0' top='185' left='80'/>
<pict name='item5-g' framed='false' filled='false' type='item' num='0' top='185' left='80'/>
<text name='item5-name' top='185' left='107' width='212' height='18'/>
<text name='item5-detail' top='203' left='116' width='275' height='17'/>
<text name='item6-key' top='222' left='74' width='311' height='36'/>
<pict name='item6-g' type='item' num='0' top='222' left='80'/>
<pict name='item6-g' framed='false' filled='false' type='item' num='0' top='222' left='80'/>
<text name='item6-name' top='222' left='107' width='212' height='18'/>
<text name='item6-detail' top='240' left='116' width='275' height='17'/>
<text name='item7-key' top='259' left='74' width='311' height='36'/>
<pict name='item7-g' type='item' num='0' top='259' left='80'/>
<pict name='item7-g' framed='false' filled='false' type='item' num='0' top='259' left='80'/>
<text name='item7-name' top='259' left='107' width='212' height='18'/>
<text name='item7-detail' top='277' left='116' width='275' height='17'/>
<text name='item8-key' top='297' left='74' width='311' height='36'/>
<pict name='item8-g' type='item' num='0' top='297' left='80'/>
<pict name='item8-g' framed='false' filled='false' type='item' num='0' top='297' left='80'/>
<text name='item8-name' top='297' left='107' width='212' height='18'/>
<text name='item8-detail' top='315' left='116' width='275' height='17'/>
<!-- End of item entries -->
Expand Down
1 change: 1 addition & 0 deletions rsrc/schemas/dialog.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
<xs:attribute name="custom" default="false" type="bool"/>
<xs:attribute name="scaled" default="false" type="bool"/>
<xs:attribute name="framed" default="true" type="bool"/>
<xs:attribute name="filled" default="true" type="bool"/>
<xs:attribute name="outline" default="inset" type="frameStyle"/>
<xs:attribute name="size">
<xs:simpleType>
Expand Down
54 changes: 30 additions & 24 deletions src/dialogxml/widgets/pict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,12 @@ bool cPict::parseAttribute(ticpp::Attribute& attr, std::string tagName, std::str
else if(val == "false") setFormat(TXT_WRAP, true);
else throw xBadVal(tagName, name, val, attr.Row(), attr.Column(), fname);
return true;
} else if(name == "filled") {
std::string val = attr.Value();
if(val == "true") filled = true;
else if(val == "false") filled = false;
else throw xBadVal(tagName, name, val, attr.Row(), attr.Column(), fname);
return true;
} else if(name == "def-key") {
try {
attachKey(parseKey(attr.Value()));
Expand Down Expand Up @@ -759,14 +765,14 @@ void cPict::drawPresetMonstSm(short num, rectangle to_rect){
rectangle from_rect = calcDefMonstRect(m_start_pic, animFrame);
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
}

void cPict::drawPresetMonstWide(short num, rectangle to_rect){
rectangle small_monst_rect = {0,0,18,14};
to_rect.right = to_rect.left + 28; to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);

short m_start_pic = m_pic_index[num].i;
auto from_gw = getSheet(SHEET_MONST, m_start_pic / 20);
Expand All @@ -787,7 +793,7 @@ void cPict::drawPresetMonstTall(short num, rectangle to_rect){
rectangle small_monst_rect = {0,0,18,14};
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);

short m_start_pic = m_pic_index[num].i;
auto from_gw = getSheet(SHEET_MONST, m_start_pic / 20);
Expand All @@ -808,7 +814,7 @@ void cPict::drawPresetMonstLg(short num, rectangle to_rect){
rectangle small_monst_rect = {0,0,18,14};
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);

short m_start_pic = m_pic_index[num].i;
auto from_gw = getSheet(SHEET_MONST, m_start_pic / 20);
Expand Down Expand Up @@ -887,7 +893,7 @@ void cPict::drawPresetScenLg(short num, rectangle to_rect){
void cPict::drawPresetItem(short num, 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);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);
std::shared_ptr<const sf::Texture> from_gw;
rectangle from_rect = {0,0,18,18};
if(num < 55) {
Expand All @@ -904,7 +910,7 @@ void cPict::drawPresetItem(short num, rectangle to_rect){
void cPict::drawPresetTinyItem(short num, 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);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);
rectangle from_rect = {0,0,18,18};
auto from_gw = getSheet(SHEET_TINY_ITEM);
from_rect.offset(18 * (num % 10), 18 * (num / 10));
Expand All @@ -916,7 +922,7 @@ void cPict::drawPresetPc(short num, rectangle to_rect){
rectangle from_rect = calc_rect(2 * (num / 8), num % 8);
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
}

Expand All @@ -925,7 +931,7 @@ void cPict::drawPresetField(short num, rectangle to_rect){
rectangle from_rect = calc_rect(num % 8, num / 8);
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
}

Expand All @@ -937,7 +943,7 @@ void cPict::drawPresetBoom(short num, rectangle to_rect){
// TODO: Be smarter about this - we know the first row is static booms and subsequent rows are animated booms.
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
}

Expand All @@ -957,7 +963,7 @@ void cPict::drawPresetMissile(short num, rectangle to_rect){
auto from_gw = getSheet(SHEET_MISSILE);
to_rect.right = to_rect.left + 18;
to_rect.bottom = to_rect.top + 18;
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);
short i = animFrame % 8;
from_rect.offset(18 * i, 18 * num);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
Expand Down Expand Up @@ -1013,7 +1019,7 @@ void cPict::drawCustomMonstSm(short num, rectangle to_rect){
num += adj[animFrame % 4];
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);

rectangle from_rect;
std::shared_ptr<const sf::Texture> from_gw;
Expand All @@ -1027,7 +1033,7 @@ void cPict::drawCustomMonstWide(short num, rectangle to_rect){
rectangle small_monst_rect = {0,0,18,14};
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);

rectangle from_rect;
std::shared_ptr<const sf::Texture> from_gw;
Expand All @@ -1046,7 +1052,7 @@ void cPict::drawCustomMonstTall(short num, rectangle to_rect){
rectangle small_monst_rect = {0,0,18,14};
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);

rectangle from_rect;
std::shared_ptr<const sf::Texture> from_gw;
Expand All @@ -1065,7 +1071,7 @@ void cPict::drawCustomMonstLg(short num, rectangle to_rect){
rectangle small_monst_rect = {0,0,18,14};
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);

rectangle from_rect;
std::shared_ptr<const sf::Texture> from_gw;
Expand Down Expand Up @@ -1147,7 +1153,7 @@ void cPict::drawCustomItem(short num, rectangle to_rect){
rectangle from_rect;
std::shared_ptr<const sf::Texture> from_gw;
graf_pos_ref(from_gw, from_rect) = spec_scen_g.find_graphic(num);
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
}

Expand All @@ -1157,7 +1163,7 @@ void cPict::drawCustomTinyItem(short num, rectangle to_rect){
rectangle from_rect;
std::shared_ptr<const sf::Texture> from_gw;
graf_pos_ref(from_gw, from_rect) = spec_scen_g.find_graphic(num);
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
}

Expand All @@ -1167,7 +1173,7 @@ void cPict::drawCustomBoom(short num, rectangle to_rect){
rectangle from_rect;
std::shared_ptr<const sf::Texture> from_gw;
graf_pos_ref(from_gw, from_rect) = spec_scen_g.find_graphic(num + animFrame % 8);
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
}

Expand All @@ -1179,7 +1185,7 @@ void cPict::drawCustomMissile(short num, rectangle to_rect){
from_rect.right = from_rect.left + 18;
from_rect.bottom = from_rect.top + 18;
if(animFrame >= 4) from_rect.offset(0, 18);
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) 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);
}
Expand All @@ -1204,15 +1210,15 @@ void cPict::drawPartyMonstSm(short num, rectangle to_rect){
rectangle from_rect;

graf_pos_ref(from_gw, from_rect) = spec_scen_g.find_graphic(num, true);
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
}

void cPict::drawPartyMonstWide(short num, rectangle to_rect){
rectangle small_monst_rect = {0,0,18,14};
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);
std::shared_ptr<const sf::Texture> from_gw;
rectangle from_rect;

Expand All @@ -1229,7 +1235,7 @@ void cPict::drawPartyMonstTall(short num, rectangle to_rect){
rectangle small_monst_rect = {0,0,18,14};
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);
std::shared_ptr<const sf::Texture> from_gw;
rectangle from_rect;

Expand All @@ -1246,7 +1252,7 @@ void cPict::drawPartyMonstLg(short num, rectangle to_rect){
rectangle small_monst_rect = {0,0,18,14};
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);
std::shared_ptr<const sf::Texture> from_gw;
rectangle from_rect;

Expand Down Expand Up @@ -1283,7 +1289,7 @@ void cPict::drawPartyItem(short num, rectangle to_rect){
rectangle from_rect;

graf_pos_ref(from_gw, from_rect) = spec_scen_g.find_graphic(num, true);
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
}

Expand All @@ -1294,7 +1300,7 @@ void cPict::drawPartyPc(short num, rectangle to_rect){
rectangle from_rect;

graf_pos_ref(from_gw, from_rect) = spec_scen_g.find_graphic(num, true);
fill_rect(*inWindow, to_rect, sf::Color::Black);
if(filled) fill_rect(*inWindow, to_rect, sf::Color::Black);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect, sf::BlendAlpha);
}

Expand Down
2 changes: 1 addition & 1 deletion src/dialogxml/widgets/pict.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class cPict : public cControl {
ePicType picType;
bool drawScaled;
// Transient parse flags
bool wide = false, tall = false, tiny = false, custom = false, blank = false;
bool wide = false, tall = false, tiny = false, custom = false, blank = false, filled = true;
void drawPresetTer(short num, rectangle to_rect);
void drawPresetTerAnim(short num, rectangle to_rect);
void drawPresetMonstSm(short num, rectangle to_rect);
Expand Down
2 changes: 2 additions & 0 deletions src/doxy/mainpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ whether it should be scaled to fit within the provided bounds. It only
has an effect for types `full`, `dlog`, and `scen`, and the latter two
only if `size` is `large`. Can be either `true` or `false`, defaults to
`false`.
* `filled` - For transparent graphics, specifies whether to draw a solid
black fill behind the icon
* `def-key` - See **Common Attributes** above.

The possible values for the `type` attribute are:
Expand Down

0 comments on commit 014f562

Please sign in to comment.