mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-02 08:42:45 +03:00
feat(ui): implement CSimpleCheckbox_SetChecked
This commit is contained in:
parent
1cd1bb5672
commit
5e00730587
@ -1,5 +1,6 @@
|
|||||||
#include "ui/CSimpleCheckbox.hpp"
|
#include "ui/CSimpleCheckbox.hpp"
|
||||||
#include "ui/CSimpleCheckboxScript.hpp"
|
#include "ui/CSimpleCheckboxScript.hpp"
|
||||||
|
#include "ui/CSimpleTexture.hpp"
|
||||||
|
|
||||||
int32_t CSimpleCheckbox::s_metatable;
|
int32_t CSimpleCheckbox::s_metatable;
|
||||||
int32_t CSimpleCheckbox::s_objectType;
|
int32_t CSimpleCheckbox::s_objectType;
|
||||||
@ -38,3 +39,27 @@ bool CSimpleCheckbox::IsA(int32_t type) {
|
|||||||
int32_t CSimpleCheckbox::GetChecked() {
|
int32_t CSimpleCheckbox::GetChecked() {
|
||||||
return this->m_checked;
|
return this->m_checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSimpleCheckbox::SetChecked(int32_t checked, int32_t force) {
|
||||||
|
if (checked == this->m_checked && !force) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->m_checked = checked;
|
||||||
|
|
||||||
|
if (this->m_checkedTexture) {
|
||||||
|
this->m_checkedTexture->Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->m_disabledTexture) {
|
||||||
|
this->m_disabledTexture->Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->m_checked) {
|
||||||
|
if (this->m_disabledTexture && this->m_state == BUTTONSTATE_DISABLED) {
|
||||||
|
this->m_disabledTexture->Show();
|
||||||
|
} else if (this->m_checkedTexture) {
|
||||||
|
this->m_checkedTexture->Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -27,6 +27,7 @@ class CSimpleCheckbox : public CSimpleButton {
|
|||||||
CSimpleCheckbox(CSimpleFrame* parent)
|
CSimpleCheckbox(CSimpleFrame* parent)
|
||||||
: CSimpleButton(parent) {};
|
: CSimpleButton(parent) {};
|
||||||
int32_t GetChecked();
|
int32_t GetChecked();
|
||||||
|
void SetChecked(int32_t checked, int32_t force);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -1,11 +1,18 @@
|
|||||||
#include "ui/CSimpleCheckboxScript.hpp"
|
#include "ui/CSimpleCheckboxScript.hpp"
|
||||||
#include "ui/CSimpleCheckbox.hpp"
|
#include "ui/CSimpleCheckbox.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
|
#include "util/StringTo.hpp"
|
||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
int32_t CSimpleCheckbox_SetChecked(lua_State* L) {
|
int32_t CSimpleCheckbox_SetChecked(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
auto type = CSimpleCheckbox::GetObjectType();
|
||||||
|
auto checkbox = static_cast<CSimpleCheckbox*>(FrameScript_GetObjectThis(L, type));
|
||||||
|
|
||||||
|
auto checked = StringToBOOL(L, 2, 1);
|
||||||
|
checkbox->SetChecked(checked, 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleCheckbox_GetChecked(lua_State* L) {
|
int32_t CSimpleCheckbox_GetChecked(lua_State* L) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user