add very rudimentary right-alignment text option

This commit is contained in:
2024-11-10 13:00:14 -06:00
parent af2253e5ce
commit a551da6299
4 changed files with 30 additions and 14 deletions

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