Merge pull request #458 from NQNStudios:credits-overhaul

Auto-generated credits / Update the credits from IndieGOGO
This commit is contained in:
2024-11-23 18:54:51 -05:00
committed by GitHub
27 changed files with 2062 additions and 71 deletions

View File

@@ -21,6 +21,9 @@
#include <boost/lexical_cast.hpp>
#include "winutil.hpp"
// Hyperlink forward declaration
extern void launchURL(std::string url);
void cControl::setText(std::string l){
lbl = l;
}
@@ -435,6 +438,16 @@ std::string cControl::parse(ticpp::Element& who, std::string fname) {
frame.height() = height > 0 ? height : bestSz.y;
setBounds(frame);
validatePostParse(who, fname, foundAttrs, foundNodes);
// Wire links to function:
// TODO links are identified only by having the color 'link', and can only link to their text value.
if(is_link){
attachClickHandler([](cDialog& self, std::string clicked, eKeyMod) {
launchURL(self[clicked].getText());
return false;
});
}
return id;
}
@@ -541,6 +554,8 @@ bool cControl::parseAttribute(ticpp::Attribute& attr, std::string tagName, std::
setColour({0x7f, 0xd7, 0xFF});
if(parent->getBg() == cDialog::BG_LIGHT)
setColour({0x00, 0x00, 0xFF});
is_link = true;
} else try {
sf::Color clr = parseColor(val);
setColour(clr);

View File

@@ -462,6 +462,7 @@ private:
// Transient values only used during parsing
ePosition horz = POS_ABS, vert = POS_ABS;
std::string anchor;
bool is_link = false;
};
#endif

View File

@@ -53,12 +53,18 @@ bool cTextMsg::parseAttribute(ticpp::Attribute& attr, std::string tagName, std::
throw xBadVal(tagName, attr.Name(), val, attr.Row(), attr.Column(), fname);
}
return true;
} else if(attr.Name() == "underline") {
}else if(attr.Name() == "underline"){
std::string val = attr.Value();
if(val == "true") underlined = true;
else if(val == "false") underlined = false;
else throw xBadVal(tagName, attr.Name(), val, attr.Row(), attr.Column(), fname);
return true;
}else if(attr.Name() == "align"){
std::string val = attr.Value();
if(val == "right") right_align = true;
else if(val == "left") right_align = false;
else throw xBadVal(tagName, attr.Name(), val, attr.Row(), attr.Column(), fname);
return true;
}
return cControl::parseAttribute(attr, tagName, fname);
}
@@ -233,7 +239,7 @@ void cTextMsg::draw(){
}
style.colour = draw_color;
if (!calculated) calculate_layout();
win_draw_string(*inWindow,to_rect,msg,text_mode,style,break_info);
win_draw_string(*inWindow,to_rect,msg,text_mode,style,break_info,right_align);
}
}

View File

@@ -63,5 +63,6 @@ private:
std::string msg;
void calculate_layout();
bool calculated = false;
bool right_align = false;
};
#endif