Fix some rough edges when handling large pictures or full sheets

- Choose Picture dialog now scales these pictures down to fit in the available space, thus avoiding the ugly overlap issue.
- Choose Picture dialog now supports full sheets, scaling them down in a similar manner
- Due to the above, the Display Picture node now offers a Choose button
- The possibility of large (72x72) dialog pictures is now properly documented
This commit is contained in:
2015-06-28 20:13:33 -04:00
parent f6d9ac7633
commit 860cf9d5dd
6 changed files with 72 additions and 23 deletions

View File

@@ -22,8 +22,6 @@
// TODO: This should probably be a source file instead of a header
#include "dlogutil.buttons.hpp" // must be included here and only here
const size_t cPictChoice::per_page = 36;
cPictChoice::cPictChoice(const std::vector<pic_num_t>& pics,ePicType t,cDialog* parent) : cPictChoice(pics.begin(), pics.end(), t, parent) {}
cPictChoice::cPictChoice(const std::vector<std::pair<pic_num_t,ePicType>>& pics,cDialog* parent) : dlg("choose-pict",parent) {
@@ -100,7 +98,19 @@ void cPictChoice::fillPage(){
cPict& pic = dynamic_cast<cPict&>(dlg[sout.str()]);
if(page * per_page + i < picts.size()){
pic.show();
pic.setPict(picts[per_page * page + i].first, picts[per_page * page + i].second);
ePicType tp = picts[per_page * page + i].second;
pic.setPict(picts[per_page * page + i].first, tp);
rectangle b = pic.getBounds();
if(tp == PIC_DLOG_LG || tp == PIC_CUSTOM_DLOG_LG || tp == PIC_SCEN_LG) {
pic.setFormat(TXT_WRAP, false);
b.width() /= 2;
b.height() /= 2;
} else if(tp == PIC_FULL) {
pic.setFormat(TXT_WRAP, false);
b.width() = 40;
b.height() = 40;
} else pic.setFormat(TXT_WRAP, true);
pic.setBounds(b);
}else pic.hide();
}
}
@@ -153,8 +163,6 @@ size_t cPictChoice::getSelected() {
return cur;
}
const size_t cStringChoice::per_page = 40;
cStringChoice::cStringChoice(
std::vector<std::string>& strs,
std::string title,

View File

@@ -156,7 +156,7 @@ public:
/// A dialog that presents a list of strings with LEDs and allows you to choose one.
/// The list may span several pages.
class cStringChoice {
static const size_t per_page;
static const size_t per_page = 40;
cDialog dlg;
bool onLeft();
bool onRight();
@@ -197,7 +197,7 @@ public:
/// Like cStringChoice, but presents a list of icons rather than strings.
class cPictChoice {
static const size_t per_page;
static const size_t per_page = 36;
bool didAccept;
cDialog dlg;
void attachHandlers();

View File

@@ -734,8 +734,8 @@ void cPict::drawPresetDlog(short num, rectangle to_rect){
}
void cPict::drawPresetDlogLg(short num, rectangle to_rect){
to_rect.right = to_rect.left + 72;
to_rect.bottom = to_rect.top + 72;
to_rect.right = to_rect.left + (drawScaled ? getBounds().width() : 72);
to_rect.bottom = to_rect.top + (drawScaled ? getBounds().height() : 72);
std::shared_ptr<sf::Texture> from_gw = getSheet(SHEET_DLOG);
rectangle from_rect = {0,0,72,72};
from_rect.offset(36 * (num % 4),36 * (num / 4));
@@ -762,8 +762,8 @@ void cPict::drawPresetScen(short num, rectangle to_rect){
void cPict::drawPresetScenLg(short num, rectangle to_rect){
std::shared_ptr<sf::Texture> from_gw = getSheet(SHEET_SCEN_LG);
to_rect.right = to_rect.left + 64;
to_rect.bottom = to_rect.top + 64;
to_rect.right = to_rect.left + (drawScaled ? getBounds().width() : 64);
to_rect.bottom = to_rect.top + (drawScaled ? getBounds().height() : 64);
rectangle from_rect = {0,0,64,64};
from_rect.offset(num * 64, 0);
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect);
@@ -967,31 +967,42 @@ void cPict::drawCustomMonstLg(short num, rectangle to_rect){
rect_draw_some_item(*from_gw, from_rect, *inWindow, small_monst_rect, sf::BlendAlpha);
}
// This is a super-hacky way to wedge in scaled form, but at least it should work.
static int dlog_to_w = 18, dlog_to_h = 36;
void cPict::drawCustomDlog(short num, rectangle to_rect){
rectangle from_rect;
sf::Texture* from_gw;
graf_pos_ref(from_gw, from_rect) = spec_scen_g.find_graphic(num);
to_rect.right = to_rect.left + 18;
to_rect.bottom = to_rect.top + 36;
to_rect.right = to_rect.left + dlog_to_w;
to_rect.bottom = to_rect.top + dlog_to_h;
from_rect.right = from_rect.left + 18;
from_rect.bottom = from_rect.top + 36;
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect);
graf_pos_ref(from_gw, from_rect) = spec_scen_g.find_graphic(num+1);
to_rect.offset(18,0);
to_rect.offset(dlog_to_w,0);
from_rect.right = from_rect.left + 18;
from_rect.bottom = from_rect.top + 36;
rect_draw_some_item(*from_gw, from_rect, *inWindow, to_rect);
}
void cPict::drawCustomDlogLg(short num, rectangle to_rect){
if(drawScaled) {
dlog_to_w = 9;
dlog_to_h = 18;
}
drawCustomDlog(num,to_rect);
to_rect.offset(36,0);
to_rect.offset(dlog_to_h,0);
drawCustomDlog(num + 2,to_rect);
to_rect.offset(-36,36);
to_rect.offset(-dlog_to_h,dlog_to_h);
drawCustomDlog(num + 4,to_rect);
to_rect.offset(36,0);
to_rect.offset(dlog_to_h,0);
drawCustomDlog(num + 6,to_rect);
if(drawScaled) {
dlog_to_w = 18;
dlog_to_h = 26;
}
}
void cPict::drawCustomTalk(short num, rectangle to_rect){