YouDunIt/modules/you_done_it/clue_data.cpp

56 lines
1.3 KiB
C++

#include "clue_data.h"
#include "you_done_it/macros.h"
#include "you_done_it/ydi_client.h"
void ClueData::_bind_methods() {
BIND_HPROPERTY(Variant::STRING, popup_text, PROPERTY_HINT_MULTILINE_TEXT);
BIND_HPROPERTY(Variant::INT, id, PROPERTY_HINT_ENUM, NetworkData::ClueID_hint());
BIND_HPROPERTY(Variant::OBJECT, image, PROPERTY_HINT_RESOURCE_TYPE, "Texture2D");
}
void ClueData::set_revealed(bool value) {
this->revealed = value;
}
void ClueData::set_id(NetworkData::ClueID id) {
this->id = id;
}
NetworkData::ClueID ClueData::get_id() const {
return this->id;
}
void ClueData::reveal() {
if (this->id == NetworkData::CLUE_MAX) {
print_error("Attempt to reveal CLUE_MAX, invalid state, aborting");
abort();
}
if (this->revealed) {
print_error("Attempt to reveal clue that's already revealed, returning without action");
return;
}
this->revealed = true;
if (ydi::client::status() == NetworkData::CONNECTION_AUTHENTICATED) {
ydi::client::send::reveal_clue(this->id);
}
}
bool ClueData::get_revealed() const {
return this->revealed;
}
void ClueData::set_image(Ref<Texture2D> image) {
this->image = image;
}
Ref<Texture2D> ClueData::get_image() const {
return this->image;
}
void ClueData::set_popup_text(String value) {
this->popup_text = value;
}
String ClueData::get_popup_text() const {
return this->popup_text;
}