Add censoring to input box and add user ID request box when a user ID has not been established in the emscripten port.
This commit is contained in:
@@ -44,9 +44,10 @@ protected:
|
||||
std::string enteredText;
|
||||
float blinkTimer=0;
|
||||
uint8_t charLimit=16;
|
||||
bool censored=false;
|
||||
public:
|
||||
inline TextEntryLabel(geom2d::rect<float>rect,std::string label,const uint8_t charLimit=16,float scale=1,ComponentAttr attributes=ComponentAttr::NONE)
|
||||
:MenuLabel(rect,label,scale,attributes),charLimit(charLimit){}
|
||||
inline TextEntryLabel(geom2d::rect<float>rect,const bool censored=false,const uint8_t charLimit=16,float scale=1,ComponentAttr attributes=ComponentAttr::NONE)
|
||||
:MenuLabel(rect,"",scale,attributes),censored(censored),charLimit(charLimit){}
|
||||
|
||||
|
||||
inline virtual void Update(Crawler*game)override{
|
||||
@@ -55,11 +56,17 @@ public:
|
||||
|
||||
game->TextEntrySetCharLimit(charLimit);
|
||||
|
||||
std::string censoredTextEntry;
|
||||
std::string_view textEntry=game->TextEntryGetString();
|
||||
censoredTextEntry=std::accumulate(textEntry.begin(),textEntry.end(),""s,[](std::string currentStr,const char&c){return std::move(currentStr)+'*';});
|
||||
|
||||
std::string_view finalLabel=censored?censoredTextEntry:textEntry;
|
||||
|
||||
if(game->IsTextEntryEnabled()){
|
||||
if(blinkTimer<0.5f){
|
||||
SetLabel(game->TextEntryGetString().substr(0,game->TextEntryGetCursor())+" "+game->TextEntryGetString().substr(game->TextEntryGetCursor()));
|
||||
SetLabel(std::string(finalLabel.substr(0,game->TextEntryGetCursor()))+" "+std::string(finalLabel.substr(game->TextEntryGetCursor())));
|
||||
}else{
|
||||
SetLabel(game->TextEntryGetString().substr(0,game->TextEntryGetCursor())+"|"+game->TextEntryGetString().substr(game->TextEntryGetCursor()));
|
||||
SetLabel(std::string(finalLabel.substr(0,game->TextEntryGetCursor()))+"|"+std::string(finalLabel.substr(game->TextEntryGetCursor())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user