Skip to content

Commit

Permalink
Add limit onto various textboxes, now that textbox width no longer ar…
Browse files Browse the repository at this point in the history
…tificially limits it

Save Name is limited to 50 characters by the db column, so stop it there
Ambient Air Temp glitches out when it's too long, so limit to 9
Limit profile location to 40 to prevent spam / abuse
Limit tags to 16 because that's the max the server accepts
  • Loading branch information
jacob1 committed Mar 17, 2024
1 parent aa8ee76 commit 16f50b8
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/gui/options/OptionsView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ OptionsView::OptionsView() : ui::Window(ui::Point(-1, -1), ui::Point(320, 340))
ambientAirTemp->SetDefocusCallback({ [this] {
UpdateAirTemp(ambientAirTemp->GetText(), true);
}});
ambientAirTemp->SetLimit(9);
scrollPanel->AddChild(ambientAirTemp);
ambientAirTempPreview = new ui::Button(ui::Point(Size.X-31, currentY), ui::Point(16, 16), "", "Preview");
scrollPanel->AddChild(ambientAirTempPreview);
Expand Down
1 change: 1 addition & 0 deletions src/gui/preview/PreviewView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ void PreviewView::NotifyCommentBoxEnabledChanged(PreviewModel * sender)
} });
addCommentBox->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
addCommentBox->SetMultiline(true);
addCommentBox->SetLimit(1000);
AddComponent(addCommentBox);
submitCommentButton = new ui::Button(ui::Point(Size.X-40, Size.Y-19), ui::Point(40, 19), "Submit");
submitCommentButton->SetActionCallback({ [this] { submitComment(); } });
Expand Down
5 changes: 5 additions & 0 deletions src/gui/profile/ProfileActivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,14 @@ void ProfileActivity::setUserInfo(UserInfo newInfo)
scrollPanel->AddChild(locationTitle);

if (editable)
{
location = new ui::Textbox(ui::Point(8+locationTitle->Size.X, currentY), ui::Point(Size.X-locationTitle->Size.X-16, 17), info.location);
((ui::Textbox*)location)->SetLimit(40);
}
else
{
location = new ui::Label(ui::Point(4+locationTitle->Size.X, currentY), ui::Point(Size.X-locationTitle->Size.X-14, 17), info.location);
}
location->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
scrollPanel->AddChild(location);
currentY += 2+location->Size.Y;
Expand Down
1 change: 1 addition & 0 deletions src/gui/save/ServerSaveActivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ ServerSaveActivity::ServerSaveActivity(std::unique_ptr<SaveInfo> newSave, OnUplo
nameField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
nameField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
nameField->SetActionCallback({ [this] { CheckName(nameField->GetText()); } });
nameField->SetLimit(50);
AddComponent(nameField);
FocusComponent(nameField);

Expand Down
1 change: 1 addition & 0 deletions src/gui/search/SearchView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ SearchView::SearchView():
searchField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
searchField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
searchField->SetActionCallback({ [this] { doSearch(); } });
searchField->SetLimit(100);
FocusComponent(searchField);

sortButton = new ui::Button(ui::Point(WINDOWW-140, 10), ui::Point(61, 17), "Sort");
Expand Down
1 change: 1 addition & 0 deletions src/gui/tags/TagsView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ TagsView::TagsView():
tagInput->Appearance.icon = IconTag;
tagInput->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tagInput->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
tagInput->SetLimit(16);
AddComponent(tagInput);
FocusComponent(tagInput);

Expand Down

0 comments on commit 16f50b8

Please sign in to comment.