aboutsummaryrefslogtreecommitdiff
path: root/src/aoemotepreview.cpp
blob: 5afeebda86ad556344f3f9ea10e9cbcd6939e828 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "aoemotepreview.h"

AOEmotePreview::AOEmotePreview(QWidget *parent, AOApplication *p_ao_app) : QWidget(parent)
{
  ao_app = p_ao_app;

  ui_viewport = new QWidget(this);
  ui_vp_player_char = new CharLayer(ui_viewport, ao_app);
  ui_vp_player_char->setObjectName("ui_vp_player_char");
  ui_vp_player_char->masked = false;
  ui_size_label = new QLabel(this);
  ui_size_label->setObjectName("ui_size_label");
  setWindowFlag(Qt::WindowMinMaxButtonsHint, false);
  setWindowFlag(Qt::Tool);
  this->resize(256, 192);
}

void AOEmotePreview::set_widgets()
{
  ui_viewport->resize(this->width(), this->height());

  ui_vp_player_char->move_and_center(0, 0);
  ui_vp_player_char->combo_resize(ui_viewport->width(), ui_viewport->height());

  ui_size_label->setText(QString::number(this->width()) + "x" + QString::number(this->height()));
}

void AOEmotePreview::play(QString emote, QString char_name, bool flipped, int self_offset, int self_offset_v)
{
  ui_vp_player_char->stop();
  ui_vp_player_char->set_flipped(flipped);
  ui_vp_player_char->move_and_center(ui_viewport->width() * self_offset / 100, ui_viewport->height() * self_offset_v / 100);
  ui_vp_player_char->load_image(emote, char_name, 0, false);
  ui_vp_player_char->set_play_once(false);
  m_emote = emote;
  m_char = char_name;
  setWindowTitle(char_name + ": " + emote);
}

void AOEmotePreview::resizeEvent(QResizeEvent *)
{
  set_widgets();
  ui_vp_player_char->load_image(m_emote, m_char, 0, false);
}