Implement sticker logic with animated image support (#414)
* Implement sticker logic with animated image support (will probably be remade in a much better way for AOLayers) * port to aolayer Co-authored-by: in1tiate <radwoodward@vikings.grayson.edu>
This commit is contained in:
		
							parent
							
								
									8c60fb2fcd
								
							
						
					
					
						commit
						0926f3c158
					
				@ -211,4 +211,11 @@ public:
 | 
			
		||||
  InterfaceLayer(QWidget *p_parent, AOApplication *p_ao_app);
 | 
			
		||||
  void load_image(QString p_filename, QString p_miscname);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class StickerLayer : public AOLayer {
 | 
			
		||||
  Q_OBJECT
 | 
			
		||||
public:
 | 
			
		||||
  StickerLayer(QWidget *p_parent, AOApplication *p_ao_app);
 | 
			
		||||
  void load_image(QString p_charname);
 | 
			
		||||
};
 | 
			
		||||
#endif // AOLAYER_H
 | 
			
		||||
 | 
			
		||||
@ -617,6 +617,8 @@ private:
 | 
			
		||||
  ScrollText *ui_music_name;
 | 
			
		||||
  InterfaceLayer *ui_music_display;
 | 
			
		||||
 | 
			
		||||
  StickerLayer *ui_vp_sticker;
 | 
			
		||||
 | 
			
		||||
  AOButton *ui_pair_button;
 | 
			
		||||
  QListWidget *ui_pair_list;
 | 
			
		||||
  QSpinBox *ui_pair_offset_spinbox;
 | 
			
		||||
 | 
			
		||||
@ -49,6 +49,11 @@ InterfaceLayer::InterfaceLayer(QWidget *p_parent, AOApplication *p_ao_app)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
StickerLayer::StickerLayer(QWidget *p_parent, AOApplication *p_ao_app)
 | 
			
		||||
    : AOLayer(p_parent, p_ao_app)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString AOLayer::find_image(QList<QString> p_list)
 | 
			
		||||
{
 | 
			
		||||
  QString image_path;
 | 
			
		||||
@ -278,6 +283,25 @@ void InterfaceLayer::load_image(QString p_filename, QString p_miscname)
 | 
			
		||||
  start_playback(find_image(pathlist));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void StickerLayer::load_image(QString p_charname)
 | 
			
		||||
{
 | 
			
		||||
  QString miscname = ao_app->get_char_shouts(p_charname);
 | 
			
		||||
  transform_mode = ao_app->get_misc_scaling(miscname);
 | 
			
		||||
  QList<QString> pathlist = {
 | 
			
		||||
      ao_app->get_image_suffix(ao_app->get_base_path() + "misc/" +
 | 
			
		||||
                                miscname + "/sticker/" + p_charname), // Misc path
 | 
			
		||||
      ao_app->get_image_suffix(ao_app->get_custom_theme_path(miscname, "sticker/" + p_charname)), // Custom theme path
 | 
			
		||||
      ao_app->get_image_suffix(ao_app->get_theme_path("sticker/" + p_charname)), // Theme path
 | 
			
		||||
      ao_app->get_image_suffix(
 | 
			
		||||
          ao_app->get_default_theme_path("sticker/" + p_charname)), // Default theme path
 | 
			
		||||
      ao_app->get_image_suffix(
 | 
			
		||||
          ao_app->get_character_path(p_charname, "sticker")), // Character folder
 | 
			
		||||
      ao_app->get_image_suffix(
 | 
			
		||||
          ao_app->get_character_path(p_charname, "showname")), // Scuffed DRO way
 | 
			
		||||
  };
 | 
			
		||||
  start_playback(find_image(pathlist));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CharLayer::start_playback(QString p_image)
 | 
			
		||||
{
 | 
			
		||||
  movie_effects.clear();
 | 
			
		||||
 | 
			
		||||
@ -134,6 +134,10 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
 | 
			
		||||
  // todo: filter out \n from showing up as that commonly breaks the chatlog and
 | 
			
		||||
  // can be spammed to hell
 | 
			
		||||
 | 
			
		||||
  ui_vp_sticker = new StickerLayer(ui_viewport, ao_app);
 | 
			
		||||
  ui_vp_sticker->set_play_once(false);
 | 
			
		||||
  ui_vp_sticker->setAttribute(Qt::WA_TransparentForMouseEvents);
 | 
			
		||||
 | 
			
		||||
  ui_muted = new AOImage(ui_ic_chat_message, ao_app);
 | 
			
		||||
  ui_muted->hide();
 | 
			
		||||
 | 
			
		||||
@ -534,9 +538,6 @@ void Courtroom::set_widgets()
 | 
			
		||||
  ui_vp_desk->move(0, 0);
 | 
			
		||||
  ui_vp_desk->combo_resize(ui_viewport->width(), ui_viewport->height());
 | 
			
		||||
 | 
			
		||||
  double y_modifier = 147.0 / 192.0;
 | 
			
		||||
  int final_y = static_cast<int>(y_modifier * ui_viewport->height());
 | 
			
		||||
 | 
			
		||||
  ui_vp_evidence_display->move(0, 0);
 | 
			
		||||
  ui_vp_evidence_display->combo_resize(ui_viewport->width(),
 | 
			
		||||
                                       ui_viewport->height());
 | 
			
		||||
@ -651,7 +652,7 @@ void Courtroom::set_widgets()
 | 
			
		||||
      ao_app->get_element_dimensions("music_display", "courtroom_design.ini");
 | 
			
		||||
 | 
			
		||||
  if (design_ini_result.width < 0 || design_ini_result.height < 0) {
 | 
			
		||||
    qDebug() << "W: could not find \"music_name\" in courtroom_design.ini";
 | 
			
		||||
    qDebug() << "W: could not find \"music_display\" in courtroom_design.ini";
 | 
			
		||||
    ui_music_display->hide();
 | 
			
		||||
  }
 | 
			
		||||
  else {
 | 
			
		||||
@ -661,6 +662,7 @@ void Courtroom::set_widgets()
 | 
			
		||||
  }
 | 
			
		||||
  ui_music_display->load_image("music_display", "");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  if (is_ao2_bg) {
 | 
			
		||||
    set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message");
 | 
			
		||||
    //  set_size_and_pos(ui_vp_chatbox, "ao2_chatbox");
 | 
			
		||||
@ -691,6 +693,10 @@ void Courtroom::set_widgets()
 | 
			
		||||
                      ui_vp_message->y() + ui_vp_chatbox->y());
 | 
			
		||||
  ui_vp_message->setTextInteractionFlags(Qt::NoTextInteraction);
 | 
			
		||||
 | 
			
		||||
  ui_vp_sticker->move(0, 0);
 | 
			
		||||
  ui_vp_sticker->combo_resize(ui_viewport->width(),
 | 
			
		||||
                              ui_viewport->height());
 | 
			
		||||
 | 
			
		||||
  ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height());
 | 
			
		||||
  ui_muted->set_image("muted");
 | 
			
		||||
  ui_muted->setToolTip(tr("Oops, you're muted!"));
 | 
			
		||||
@ -2223,6 +2229,8 @@ void Courtroom::display_character()
 | 
			
		||||
  // Hide the message and chatbox and handle the emotes
 | 
			
		||||
  ui_vp_message->hide();
 | 
			
		||||
  ui_vp_chatbox->hide();
 | 
			
		||||
  // Hide the face sticker
 | 
			
		||||
  ui_vp_sticker->stop();
 | 
			
		||||
  // Initialize the correct pos (called SIDE here for some reason) with DESK_MOD to determine if we should hide the desk or not.
 | 
			
		||||
  switch(m_chatmessage[DESK_MOD].toInt()) {
 | 
			
		||||
    case 4:
 | 
			
		||||
@ -3177,6 +3185,8 @@ void Courtroom::start_chat_ticking()
 | 
			
		||||
  ui_vp_chatbox->show();
 | 
			
		||||
  ui_vp_message->show();
 | 
			
		||||
 | 
			
		||||
  ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]);
 | 
			
		||||
 | 
			
		||||
  if (m_chatmessage[ADDITIVE] != "1") {
 | 
			
		||||
    ui_vp_message->clear();
 | 
			
		||||
    real_tick_pos = 0;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user