Deprecation on final keyvalues pt4

This commit is contained in:
Rebekah 2022-04-11 13:49:49 -04:00
parent 0f3b06cb9f
commit 20e710bf86
Signed by: oneechanhax
GPG Key ID: 183EB7902964DAE5
8 changed files with 48 additions and 16 deletions

View File

@ -39,11 +39,11 @@ public:
[[deprecated]] void SetInt(const std::string& s, int v) { this->stored_ints[s] = v; }
[[deprecated]] float GetFloat(const std::string& s) { return this->stored_floats.at(s); }
[[deprecated]] void SetFloat(const std::string& s, float v) { this->stored_floats[s] = v; }
std::string GetString(const std::string& s) { return this->stored_strings.at(s); }
void SetString(const std::string& s, const std::string& v) { this->stored_strings[s] = v; }
glez::rgba GetColor(const std::string& s) { return this->stored_colors.at(s); }
void SetColor(const std::string& s, glez::rgba v) { this->stored_colors[s] = v; }
bool FindKey(const std::string& s) {
[[deprecated]] std::string GetString(const std::string& s) { return this->stored_strings.at(s); }
[[deprecated]] void SetString(const std::string& s, const std::string& v) { this->stored_strings[s] = v; }
[[deprecated]] glez::rgba GetColor(const std::string& s) { return this->stored_colors.at(s); }
[[deprecated]] void SetColor(const std::string& s, glez::rgba v) { this->stored_colors[s] = v; }
[[deprecated]] bool FindKey(const std::string& s) {
{
auto find = stored_bools.find(s);
if (find != stored_bools.end())
@ -71,7 +71,34 @@ public:
}
return false;
}
bool IsEmpty(const std::string& s) {
return !this->FindKey(s);
[[deprecated]] bool IsEmpty(const std::string& s) {
return ![this](const std::string& s) {
{
auto find = stored_bools.find(s);
if (find != stored_bools.end())
return true;
}
{
auto find = stored_ints.find(s);
if (find != stored_ints.end())
return true;
}
{
auto find = stored_floats.find(s);
if (find != stored_floats.end())
return true;
}
{
auto find = stored_strings.find(s);
if (find != stored_strings.end())
return true;
}
{
auto find = stored_colors.find(s);
if (find != stored_colors.end())
return true;
}
return false;
}(s);
}
};

View File

@ -41,4 +41,5 @@ public:
void SetValue(std::string value);
TextInputCallbackFn_t m_pCallback;
std::string value;
};

View File

@ -37,4 +37,5 @@ private:
bool autosize;
bool centered;
std::pair<int, int> padding;
std::string text;
};

View File

@ -31,9 +31,9 @@ CMenuList::CMenuList(std::string name, CMenuWindow* parent)
void CMenuList::AddEntry(std::string id, std::string name) {
CMenuListEntry* entry = new CMenuListEntry("entry_" + id, this, id);
entry->SetText(name);
entry->SetCallback([this](CBaseButton* thisptr) {
entry->SetCallback([entry](CBaseButton* thisptr) {
CMenuWindow* window = dynamic_cast<CMenuWindow*>(thisptr->GetParent()->GetParent());
window->SelectTab(thisptr->Props()->GetString("entry"));
window->SelectTab(entry->entry);
});
AddChild(entry);
}

View File

@ -26,7 +26,7 @@
CMenuListEntry::CMenuListEntry(std::string name, CMenuList* parent, std::string entry)
: CBaseButton(name, parent, entry) {
Props()->SetString("entry", entry.c_str());
this->entry = entry;
}
void CMenuListEntry::SetMaxSize(int x, int y) {

View File

@ -31,4 +31,7 @@ public:
virtual void SetMaxSize(int x, int y) override;
virtual void Draw(int x, int y) override;
public:
std::string entry;
};

View File

@ -26,7 +26,7 @@
CTextInput::CTextInput(std::string name, IWidget* parent)
: CBaseWidget(name, parent) {
this->Props()->SetString("value", "");
this->value = "";
this->focus = false;
this->SetMaxWidth(8);
}
@ -42,14 +42,14 @@ void CTextInput::SetMaxWidth(int width) {
}
std::string CTextInput::Value() {
return std::string(Props()->GetString("value"));
return this->value;
}
void CTextInput::SetValue(std::string value) {
std::string oldv = Value();
if (m_pCallback)
m_pCallback(this, oldv, value);
Props()->SetString("value", value.c_str());
this->value = value;
}
void CTextInput::Draw(int x, int y) {

View File

@ -88,7 +88,7 @@ void CTextLabel::SetPadding(int x, int y) {
void CTextLabel::SetText(std::string text) {
// unsigned long font_handle = Props()->GetInt("font", fonts::MENU);
Props()->SetString("text", text.c_str());
this->text = text;
std::pair<float, float> size;
g_pGUI->GetRootWindow()->GetFont().stringSize(text, &size.first, &size.second);
if (this->autosize) {
@ -102,14 +102,14 @@ void CTextLabel::SetText(std::string text) {
std::pair<float, float> size2;
g_pGUI->GetRootWindow()->GetFont().stringSize(txt, &size2.first, &size2.second);
SetSize(size2.first + padding.first * 2, size2.second + padding.second * 2);
Props()->SetString("text", txt);
this->text = txt;
}
}
}
std::string CTextLabel::GetText() {
// return std::string(Props()->GetString("text", ""));
return std::string(Props()->GetString("text"));
return this->text;
}
void CTextLabel::Draw(int x, int y) {