made ao2 desks work on chatmessages and made set_text_color
This commit is contained in:
		
							parent
							
								
									6e7fd9c522
								
							
						
					
					
						commit
						051d9dc4dd
					
				
							
								
								
									
										26
									
								
								aoscene.cpp
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								aoscene.cpp
									
									
									
									
									
								
							@ -4,6 +4,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "file_functions.h"
 | 
					#include "file_functions.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QDebug>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AOScene::AOScene(Courtroom *parent) : QLabel(parent)
 | 
					AOScene::AOScene(Courtroom *parent) : QLabel(parent)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  m_courtroom = parent;
 | 
					  m_courtroom = parent;
 | 
				
			||||||
@ -18,7 +20,9 @@ void AOScene::set_image(QString p_image)
 | 
				
			|||||||
  QPixmap default_bg(default_path);
 | 
					  QPixmap default_bg(default_path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  int w = this->width();
 | 
					  int w = this->width();
 | 
				
			||||||
 | 
					  qDebug() << "AOScene width found to be " << w;
 | 
				
			||||||
  int h = this->height();
 | 
					  int h = this->height();
 | 
				
			||||||
 | 
					  qDebug() << "AOScene height found to be " << h;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (file_exists(background_path))
 | 
					  if (file_exists(background_path))
 | 
				
			||||||
    this->setPixmap(background.scaled(w, h));
 | 
					    this->setPixmap(background.scaled(w, h));
 | 
				
			||||||
@ -28,5 +32,27 @@ void AOScene::set_image(QString p_image)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void AOScene::set_legacy_desk(QString p_image)
 | 
					void AOScene::set_legacy_desk(QString p_image)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  //vanilla desks vary in both width and height. in order to make that work with viewport rescaling,
 | 
				
			||||||
 | 
					  //some INTENSE math is needed.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  QImage f_image(p_image);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int vp_x = m_courtroom->get_vp_x();
 | 
				
			||||||
 | 
					  int vp_y = m_courtroom->get_vp_y();
 | 
				
			||||||
 | 
					  int vp_width = m_courtroom->get_vp_w();
 | 
				
			||||||
 | 
					  int vp_height = m_courtroom->get_vp_h();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  double y_modifier = 147 / 192;
 | 
				
			||||||
 | 
					  double w_modifier = vp_width / 256;
 | 
				
			||||||
 | 
					  double h_modifier = vp_height / 192;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int final_x = vp_x;
 | 
				
			||||||
 | 
					  int final_y = vp_y + y_modifier * vp_height;
 | 
				
			||||||
 | 
					  int final_w = w_modifier * f_image.width();
 | 
				
			||||||
 | 
					  int final_h = h_modifier * f_image.height();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  this->move(final_x, final_y);
 | 
				
			||||||
 | 
					  this->resize(final_w, final_h);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -246,6 +246,7 @@ void Courtroom::set_widgets()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  ui_vp_desk->move(m_viewport_x, m_viewport_y);
 | 
					  ui_vp_desk->move(m_viewport_x, m_viewport_y);
 | 
				
			||||||
  ui_vp_desk->resize(m_viewport_width, m_viewport_height);
 | 
					  ui_vp_desk->resize(m_viewport_width, m_viewport_height);
 | 
				
			||||||
 | 
					  qDebug() << "resized ui_vp_desk to " << m_viewport_width << " and " << m_viewport_height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ui_vp_chatbox->move(m_viewport_x, m_viewport_y);
 | 
					  ui_vp_chatbox->move(m_viewport_x, m_viewport_y);
 | 
				
			||||||
  ui_vp_chatbox->resize(m_viewport_width, m_viewport_height);
 | 
					  ui_vp_chatbox->resize(m_viewport_width, m_viewport_height);
 | 
				
			||||||
@ -294,7 +295,7 @@ void Courtroom::set_widgets()
 | 
				
			|||||||
  ui_area_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
 | 
					  ui_area_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  set_size_and_pos(ui_ic_chat_message, "ic_chat_message");
 | 
					  set_size_and_pos(ui_ic_chat_message, "ic_chat_message");
 | 
				
			||||||
  ui_ic_chat_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
 | 
					  ui_ic_chat_message->setStyleSheet("background-color: rgba(89, 89, 89, 0);");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  set_size_and_pos(ui_ooc_chat_message, "ooc_chat_message");
 | 
					  set_size_and_pos(ui_ooc_chat_message, "ooc_chat_message");
 | 
				
			||||||
  ui_ooc_chat_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
 | 
					  ui_ooc_chat_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
 | 
				
			||||||
@ -518,6 +519,8 @@ void Courtroom::set_background(QString p_background)
 | 
				
			|||||||
  is_ao2_bg = file_exists(bg_path + "defensedesk.png") &&
 | 
					  is_ao2_bg = file_exists(bg_path + "defensedesk.png") &&
 | 
				
			||||||
              file_exists(bg_path + "prosecutiondesk.png") &&
 | 
					              file_exists(bg_path + "prosecutiondesk.png") &&
 | 
				
			||||||
              file_exists(bg_path + "stand.png");
 | 
					              file_exists(bg_path + "stand.png");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //T0D0: find some way to compensate for legacy resolution
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Courtroom::enter_courtroom(int p_cid)
 | 
					void Courtroom::enter_courtroom(int p_cid)
 | 
				
			||||||
@ -603,6 +606,8 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  text_state = 0;
 | 
					  text_state = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  chatmessage_is_empty = m_chatmessage[MESSAGE] == " " || m_chatmessage[MESSAGE] == "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (int n_string = 0 ; n_string < chatmessage_size ; ++n_string)
 | 
					  for (int n_string = 0 ; n_string < chatmessage_size ; ++n_string)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    m_chatmessage[n_string] = p_contents->at(n_string);
 | 
					    m_chatmessage[n_string] = p_contents->at(n_string);
 | 
				
			||||||
@ -671,8 +676,6 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
 | 
				
			|||||||
      break;
 | 
					      break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    handle_chatmessage_2();
 | 
					    handle_chatmessage_2();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -691,19 +694,15 @@ void Courtroom::handle_chatmessage_2()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  //empty string means we couldnt find showname in char ini
 | 
					  //empty string means we couldnt find showname in char ini
 | 
				
			||||||
  if (local_showname == "")
 | 
					  if (local_showname == "")
 | 
				
			||||||
    ui_vp_showname->remote_name;
 | 
					    ui_vp_showname->setText(remote_name);
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    ui_vp_showname->local_showname;
 | 
					    ui_vp_showname->setText(local_showname);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ui_vp_message->clear();
 | 
					  ui_vp_message->clear();
 | 
				
			||||||
  ui_vp_chatbox->hide();
 | 
					  ui_vp_chatbox->hide();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  set_scene();
 | 
					  set_scene();
 | 
				
			||||||
  set_text_color();
 | 
					  set_text_color();
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  //ui_vp_player_char->set(m_chatmessage[CHAR_NAME], m_chatmessage[PRE_EMOTE], m_chatmessage[EMOTE]);
 | 
					 | 
				
			||||||
  //ui_vp_player_char->play_pre();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Courtroom::set_scene()
 | 
					void Courtroom::set_scene()
 | 
				
			||||||
@ -716,7 +715,7 @@ void Courtroom::set_scene()
 | 
				
			|||||||
  if (f_side == "def")
 | 
					  if (f_side == "def")
 | 
				
			||||||
    f_image = "defenseempty.png";
 | 
					    f_image = "defenseempty.png";
 | 
				
			||||||
  else if (f_side == "pro")
 | 
					  else if (f_side == "pro")
 | 
				
			||||||
    f_image = "prosecutionempty.png";
 | 
					    f_image = "prosecutorempty.png";
 | 
				
			||||||
  else if (f_side == "jud")
 | 
					  else if (f_side == "jud")
 | 
				
			||||||
    f_image = "judgestand.png";
 | 
					    f_image = "judgestand.png";
 | 
				
			||||||
  else if (f_side == "hld")
 | 
					  else if (f_side == "hld")
 | 
				
			||||||
@ -727,6 +726,83 @@ void Courtroom::set_scene()
 | 
				
			|||||||
  ui_vp_background->set_image(f_image);
 | 
					  ui_vp_background->set_image(f_image);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //now for the hard part: desks
 | 
					  //now for the hard part: desks
 | 
				
			||||||
 | 
					  int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //desks show on emote modifier 0, 1 and 4, we're done with this function if theyre not any of those
 | 
				
			||||||
 | 
					  //we're also done if one of the non-desk positions is the current one(jud, hlp and hld)
 | 
				
			||||||
 | 
					  if (emote_mod == 2 ||
 | 
				
			||||||
 | 
					      emote_mod == 3 ||
 | 
				
			||||||
 | 
					      emote_mod == 5 ||
 | 
				
			||||||
 | 
					      f_side == "jud" ||
 | 
				
			||||||
 | 
					      f_side == "hlp" ||
 | 
				
			||||||
 | 
					      f_side == "hld")
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    ui_vp_desk->hide();
 | 
				
			||||||
 | 
					    ui_vp_legacy_desk->hide();
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (is_ao2_bg)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    qDebug() << "found is_ao2_bg to be true";
 | 
				
			||||||
 | 
					    QString desk_image = "stand.png";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (f_side == "def")
 | 
				
			||||||
 | 
					      desk_image = "defensedesk.png";
 | 
				
			||||||
 | 
					    else if (f_side == "pro")
 | 
				
			||||||
 | 
					      desk_image = "prosecutiondesk.png";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ui_vp_desk->set_image(desk_image);
 | 
				
			||||||
 | 
					    ui_vp_legacy_desk->hide();
 | 
				
			||||||
 | 
					    ui_vp_desk->show();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  else if (f_side == "def" || f_side == "pro")
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    QString desk_image;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (f_side == "def")
 | 
				
			||||||
 | 
					      desk_image = "bancodefensa.png";
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      desk_image = "bancoacusacion.png";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ui_vp_legacy_desk->set_legacy_desk(desk_image);
 | 
				
			||||||
 | 
					    ui_vp_desk->hide();
 | 
				
			||||||
 | 
					    ui_vp_legacy_desk->show();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  //assume wit or invalid side
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    ui_vp_desk->set_image("estrado.png");
 | 
				
			||||||
 | 
					    ui_vp_legacy_desk->hide();
 | 
				
			||||||
 | 
					    ui_vp_desk->show();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Courtroom::set_text_color()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  switch(m_chatmessage[TEXT_COLOR].toInt())
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					  case 0:
 | 
				
			||||||
 | 
					    ui_vp_message->setStyleSheet("QPlainTextEdit{color: white;}");
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  case 1:
 | 
				
			||||||
 | 
					    ui_vp_message->setStyleSheet("QPlainTextEdit{color: rgb(0, 255, 0);}");
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  case 2:
 | 
				
			||||||
 | 
					    ui_vp_message->setStyleSheet("QPlainTextEdit{color: red;}");
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  case 3:
 | 
				
			||||||
 | 
					    ui_vp_message->setStyleSheet("QPlainTextEdit{color: orange;}");
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  case 4:
 | 
				
			||||||
 | 
					    ui_vp_message->setStyleSheet("QPlainTextEdit{color: rgb(45, 150, 255);}");
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  case 5:
 | 
				
			||||||
 | 
					    ui_vp_message->setStyleSheet("QPlainTextEdit{color: yellow;}");
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  default:
 | 
				
			||||||
 | 
					    ui_vp_message->setStyleSheet("QPlainTextEdit{color: white;}");
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Courtroom::handle_wtce(QString p_wtce)
 | 
					void Courtroom::handle_wtce(QString p_wtce)
 | 
				
			||||||
@ -816,6 +892,8 @@ void Courtroom::on_reload_theme_clicked()
 | 
				
			|||||||
  ao_app->set_user_theme();
 | 
					  ao_app->set_user_theme();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  set_widgets();
 | 
					  set_widgets();
 | 
				
			||||||
 | 
					  //to update status on the background
 | 
				
			||||||
 | 
					  set_background(current_background);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Courtroom::on_back_to_lobby_clicked()
 | 
					void Courtroom::on_back_to_lobby_clicked()
 | 
				
			||||||
 | 
				
			|||||||
@ -52,6 +52,11 @@ public:
 | 
				
			|||||||
  QString get_default_background_path();
 | 
					  QString get_default_background_path();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  int get_cid() {return m_cid;}
 | 
					  int get_cid() {return m_cid;}
 | 
				
			||||||
 | 
					  int get_vp_x(){return m_viewport_x;}
 | 
				
			||||||
 | 
					  int get_vp_y(){return m_viewport_y;}
 | 
				
			||||||
 | 
					  int get_vp_w(){return m_viewport_width;}
 | 
				
			||||||
 | 
					  int get_vp_h(){return m_viewport_height;}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void enter_courtroom(int p_cid);
 | 
					  void enter_courtroom(int p_cid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user