void Button::Deactivate() { Component::Deactivate(); if (m_isToggle) { // Reset texture to right one depending on if we are selected or not. if (IsSelected()) ChangeTexture(Button::Selected); else ChangeTexture(Button::Normal); } }
CDialogEditEffects::CDialogEditEffects(CModelViewer* modelViewer, CObject3D* obj3D, QWidget *parent) : QDialog(parent), m_modelViewer(modelViewer), m_obj3D(obj3D), m_oldBlocks(null), m_editing(null), m_editingObj(null), m_editingGroup(null) { ui.setupUi(this); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); ui.spinOpacity->setEnabled(false); connect(ui.check2Sides, SIGNAL(toggled(bool)), this, SLOT(Set2Sides(bool))); connect(ui.checkHighlight, SIGNAL(toggled(bool)), this, SLOT(SetHighlight(bool))); connect(ui.checkOpacity, SIGNAL(toggled(bool)), this, SLOT(SetOpacity(bool))); connect(ui.checkReflect, SIGNAL(toggled(bool)), this, SLOT(SetReflect(bool))); connect(ui.checkSelfIlluminate, SIGNAL(toggled(bool)), this, SLOT(SetSelfIlluminate(bool))); connect(ui.spinOpacity, SIGNAL(valueChanged(int)), this, SLOT(SetAmount(int))); connect(ui.changeTexture, SIGNAL(clicked()), this, SLOT(ChangeTexture())); connect(ui.CWOrCCW, SIGNAL(clicked()), this, SLOT(ChangeCW())); int materialBlockCount = 0; for (int i = 0; i < (m_obj3D->m_LOD ? MAX_GROUP : 1); i++) for (int j = 0; j < m_obj3D->m_groups[i].objectCount; j++) for (int k = 0; k < m_obj3D->m_groups[i].objects[j].materialBlockCount; k++) materialBlockCount++; m_oldBlocks = new MaterialBlock[materialBlockCount]; _setTree(); connect(ui.tree, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(CurrentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*))); }
void Button::Select() { Component::Select(); ChangeTexture(Button::Selected); m_sounds.Play(SoundEffect::Button); }
Button::Button(State::Context_t context) : m_callback() , m_sprite(context.textures->Get(Textures::Buttons)) , m_text("", context.fonts->Get(Fonts::Main), 16) , m_isToggle(false) , m_sounds(*context.sound) { ChangeTexture(Button::Normal); sf::FloatRect bounds = m_sprite.getLocalBounds(); m_text.setPosition(bounds.width / 2.f, bounds.height / 2.f); }
void Button::Activate() { Component::Activate(); // If we are toggle then we should show that the button is pressed and thus "toggled". if (m_isToggle) ChangeTexture(Button::Pressed); if (m_callback) m_callback(); // If we are not a toggle then deactivate the button since we are just momentarily activated. if (!m_isToggle) Deactivate(); m_sounds.Play(SoundEffect::Button); }
bool Sprite::ChangeTexture(SpritePack *pack, uint32_t index) { auto old_pack = pack_; pack_ = pack; if (!ChangeTexture(index)) { pack_ = old_pack; return false; } if (auto gp = dynamic_cast<GifPack *>(pack_)) { gif_ = GifState{ 0, gp->CacheNextThreaded(0) }; } else { gif_ = std::nullopt; } return true; }
// Move /////////////////////////////////////////////////////////////////////// // Parametr: // - _dir: Direction - kierunek, w którym ma się poruszyć postać gracza. // Opis: // Funkcja sprawdza dzięki wskaźnikowi na mapę, czy ruch może się odbyć. // Jeśli tak - przesuwa gracza. void Player::Move(Direction _dir) { if (map->IsMovePossible(x, y, _dir)) { switch (_dir) { case Down: y++; break; case Up: y--; break; case Left: x--; break; case Right: x++; break; } ChangeTexture(_dir); } }
bool Sprite::ChangeTexture(const String &name) { if (auto idx = pack_->FindSprite(name)) return ChangeTexture(*idx); return false; }
void Button::Deselect() { Component::Deselect(); ChangeTexture(Button::Normal); }
void AvatarEditor::RebuildEditView() { if (!avatar_widget_) return; // Activate/deactivate export button based on whether export currently supported QPushButton *button = avatar_widget_->findChild<QPushButton *>("but_export"); if (button) button->setEnabled(rexlogicmodule_->GetAvatarHandler()->AvatarExportSupported()); QWidget* mat_panel = avatar_widget_->findChild<QWidget *>("panel_materials"); QWidget* attachment_panel = avatar_widget_->findChild<QWidget *>("panel_attachments"); if (!mat_panel || !attachment_panel) return; Scene::EntityPtr entity = rexlogicmodule_->GetAvatarHandler()->GetUserAvatar(); if (!entity) return; EC_AvatarAppearance* appearance = entity->GetComponent<EC_AvatarAppearance>().get(); if (!appearance) return; int width = 308-10; int tab_width = 302-10; int itemheight = 20; // Materials ClearPanel(mat_panel); const AvatarMaterialVector& materials = appearance->GetMaterials(); mat_panel->resize(width, itemheight * (materials.size() + 1)); for (uint y = 0; y < materials.size(); ++y) { QPushButton* button = new QPushButton("Change", mat_panel); button->setObjectName(QString::fromStdString(ToString<int>(y))); // Material index button->resize(50, 20); button->move(width - 50, y*itemheight); button->show(); QObject::connect(button, SIGNAL(clicked()), this, SLOT(ChangeTexture())); // If there's a texture name, use it, because it is probably more understandable than material name std::string texname = materials[y].asset_.name_; if (materials[y].textures_.size()) texname = materials[y].textures_[0].name_; QLabel* label = new QLabel(QString::fromStdString(texname), mat_panel); label->resize(200,20); label->move(0, y*itemheight); label->show(); } // Attachments ClearPanel(attachment_panel); const AvatarAttachmentVector& attachments = appearance->GetAttachments(); attachment_panel->resize(width, itemheight * (attachments.size() + 1)); for (uint y = 0; y < attachments.size(); ++y) { QPushButton* button = new QPushButton("Remove", attachment_panel); button->setObjectName(QString::fromStdString(ToString<int>(y))); // Attachment index button->resize(50, 20); button->move(width - 50, y*itemheight); button->show(); QObject::connect(button, SIGNAL(clicked()), this, SLOT(RemoveAttachment())); std::string attachment_name = attachments[y].name_; // Strip away .xml from the attachment name for slightly nicer display std::size_t pos = attachment_name.find(".xml"); if (pos != std::string::npos) attachment_name = attachment_name.substr(0, pos); QLabel* label = new QLabel(QString::fromStdString(attachment_name), attachment_panel); label->resize(200,20); label->move(0, y*itemheight); label->show(); } // Modifiers QTabWidget* tabs = avatar_widget_->findChild<QTabWidget *>("tab_appearance"); if (!tabs) return; for (;;) { QWidget* tab = tabs->widget(0); if (!tab) break; tabs->removeTab(0); delete tab; } const MasterModifierVector& master_modifiers = appearance->GetMasterModifiers(); // If no master modifiers, show the individual morph/bone controls if (!master_modifiers.size()) { QWidget* morph_panel = GetOrCreateTabScrollArea(tabs, "Morphs"); QWidget* bone_panel = GetOrCreateTabScrollArea(tabs, "Bones"); if (!morph_panel || !bone_panel) return; const BoneModifierSetVector& bone_modifiers = appearance->GetBoneModifiers(); const MorphModifierVector& morph_modifiers = appearance->GetMorphModifiers(); morph_panel->resize(tab_width, itemheight * (morph_modifiers.size() + 1)); bone_panel->resize(tab_width, itemheight * (bone_modifiers.size() + 1)); for (uint i = 0; i < bone_modifiers.size(); ++i) { QScrollBar* slider = new QScrollBar(Qt::Horizontal, bone_panel); slider->setObjectName(QString::fromStdString(bone_modifiers[i].name_)); slider->setMinimum(0); slider->setMaximum(100); slider->setPageStep(10); slider->setValue(bone_modifiers[i].value_ * 100.0f); slider->resize(150, 20); slider->move(tab_width - 150, i * itemheight); slider->show(); QObject::connect(slider, SIGNAL(valueChanged(int)), this, SLOT(BoneModifierValueChanged(int))); QLabel* label = new QLabel(QString::fromStdString(bone_modifiers[i].name_), bone_panel); label->resize(100,20); label->move(0, i * itemheight); label->show(); } for (uint i = 0; i < morph_modifiers.size(); ++i) { QScrollBar* slider = new QScrollBar(Qt::Horizontal, morph_panel); slider->setObjectName(QString::fromStdString(morph_modifiers[i].name_)); slider->setMinimum(0); slider->setMaximum(100); slider->setPageStep(10); slider->setValue(morph_modifiers[i].value_ * 100.0f); slider->resize(150, 20); slider->move(tab_width - 150, i * itemheight); slider->show(); QObject::connect(slider, SIGNAL(valueChanged(int)), this, SLOT(MorphModifierValueChanged(int))); QLabel* label = new QLabel(QString::fromStdString(morph_modifiers[i].name_), morph_panel); label->resize(100,20); label->move(0, i * itemheight); label->show(); } }