The game now keeps every character's icon in memory for a fast character sceen.
Additionally, the loading at the beginning is smoother.
This commit is contained in:
		
							parent
							
								
									3712526ff0
								
							
						
					
					
						commit
						b8dc30a822
					
				
							
								
								
									
										105
									
								
								charselect.cpp
									
									
									
									
									
								
							
							
						
						
									
										105
									
								
								charselect.cpp
									
									
									
									
									
								
							@ -26,42 +26,8 @@ void Courtroom::construct_char_select()
 | 
				
			|||||||
  ui_spectator = new AOButton(ui_char_select_background, ao_app);
 | 
					  ui_spectator = new AOButton(ui_char_select_background, ao_app);
 | 
				
			||||||
  ui_spectator->setText("Spectator");
 | 
					  ui_spectator->setText("Spectator");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  QPoint f_spacing = ao_app->get_button_spacing("char_button_spacing", "courtroom_design.ini");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  const int button_width = 60;
 | 
					 | 
				
			||||||
  int x_spacing = f_spacing.x();
 | 
					 | 
				
			||||||
  int x_mod_count = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  const int button_height = 60;
 | 
					 | 
				
			||||||
  int y_spacing = f_spacing.y();
 | 
					 | 
				
			||||||
  int y_mod_count = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  set_size_and_pos(ui_char_buttons, "char_buttons");
 | 
					  set_size_and_pos(ui_char_buttons, "char_buttons");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  char_columns = ((ui_char_buttons->width() - button_width) / (x_spacing + button_width)) + 1;
 | 
					 | 
				
			||||||
  char_rows = ((ui_char_buttons->height() - button_height) / (y_spacing + button_height)) + 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  max_chars_on_page = char_columns * char_rows;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for (int n = 0 ; n < max_chars_on_page ; ++n)
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    int x_pos = (button_width + x_spacing) * x_mod_count;
 | 
					 | 
				
			||||||
    int y_pos = (button_height + y_spacing) * y_mod_count;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ui_char_button_list.append(new AOCharButton(ui_char_buttons, ao_app, x_pos, y_pos));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    connect(ui_char_button_list.at(n), SIGNAL(clicked()), char_button_mapper, SLOT(map())) ;
 | 
					 | 
				
			||||||
    char_button_mapper->setMapping (ui_char_button_list.at(n), n) ;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ++x_mod_count;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (x_mod_count == char_columns)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      ++y_mod_count;
 | 
					 | 
				
			||||||
      x_mod_count = 0;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  connect (char_button_mapper, SIGNAL(mapped(int)), this, SLOT(char_clicked(int)));
 | 
					  connect (char_button_mapper, SIGNAL(mapped(int)), this, SLOT(char_clicked(int)));
 | 
				
			||||||
  connect(ui_back_to_lobby, SIGNAL(clicked()), this, SLOT(on_back_to_lobby_clicked()));
 | 
					  connect(ui_back_to_lobby, SIGNAL(clicked()), this, SLOT(on_back_to_lobby_clicked()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -97,7 +63,10 @@ void Courtroom::set_char_select_page()
 | 
				
			|||||||
  ui_char_select_right->hide();
 | 
					  ui_char_select_right->hide();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (AOCharButton *i_button : ui_char_button_list)
 | 
					  for (AOCharButton *i_button : ui_char_button_list)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
    i_button->hide();
 | 
					    i_button->hide();
 | 
				
			||||||
 | 
					    i_button->move(0,0);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  int total_pages = char_list.size() / max_chars_on_page;
 | 
					  int total_pages = char_list.size() / max_chars_on_page;
 | 
				
			||||||
  int chars_on_page = 0;
 | 
					  int chars_on_page = 0;
 | 
				
			||||||
@ -121,26 +90,24 @@ void Courtroom::set_char_select_page()
 | 
				
			|||||||
  if (current_char_page > 0)
 | 
					  if (current_char_page > 0)
 | 
				
			||||||
    ui_char_select_left->show();
 | 
					    ui_char_select_left->show();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (int n_button = 0 ; n_button < chars_on_page ; ++n_button)
 | 
					  put_button_in_place(current_char_page * max_chars_on_page, chars_on_page);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /*for (int n_button = 0 ; n_button < chars_on_page ; ++n_button)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    int n_real_char = n_button + current_char_page * max_chars_on_page;
 | 
					    int n_real_char = n_button + current_char_page * max_chars_on_page;
 | 
				
			||||||
    AOCharButton *f_button = ui_char_button_list.at(n_button);
 | 
					    AOCharButton *f_button = ui_char_button_list.at(n_button);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    f_button->reset();
 | 
					 | 
				
			||||||
    f_button->set_image(char_list.at(n_real_char).name);
 | 
					 | 
				
			||||||
    f_button->show();
 | 
					    f_button->show();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (char_list.at(n_real_char).taken)
 | 
					    if (char_list.at(n_real_char).taken)
 | 
				
			||||||
      f_button->set_taken();
 | 
					      f_button->set_taken();
 | 
				
			||||||
  }
 | 
					  }*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Courtroom::char_clicked(int n_char)
 | 
					void Courtroom::char_clicked(int n_char)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  int n_real_char = n_char + current_char_page * max_chars_on_page;
 | 
					  QString char_ini_path = ao_app->get_character_path(char_list.at(n_char).name) + "char.ini";
 | 
				
			||||||
 | 
					 | 
				
			||||||
  QString char_ini_path = ao_app->get_character_path(char_list.at(n_real_char).name) + "char.ini";
 | 
					 | 
				
			||||||
  qDebug() << "char_ini_path" << char_ini_path;
 | 
					  qDebug() << "char_ini_path" << char_ini_path;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!file_exists(char_ini_path))
 | 
					  if (!file_exists(char_ini_path))
 | 
				
			||||||
@ -150,15 +117,65 @@ void Courtroom::char_clicked(int n_char)
 | 
				
			|||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (n_real_char == m_cid)
 | 
					  if (n_char == m_cid)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    enter_courtroom(m_cid);
 | 
					    enter_courtroom(m_cid);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_real_char) + "#" + get_hdid() + "#%"));
 | 
					    ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_char) + "#" + get_hdid() + "#%"));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ui_ic_chat_name->setPlaceholderText(char_list.at(n_real_char).name);
 | 
					  ui_ic_chat_name->setPlaceholderText(char_list.at(n_char).name);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Courtroom::put_button_in_place(int starting, int chars_on_this_page)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    QPoint f_spacing = ao_app->get_button_spacing("char_button_spacing", "courtroom_design.ini");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int x_spacing = f_spacing.x();
 | 
				
			||||||
 | 
					    int x_mod_count = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int y_spacing = f_spacing.y();
 | 
				
			||||||
 | 
					    int y_mod_count = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    char_columns = ((ui_char_buttons->width() - button_width) / (x_spacing + button_width)) + 1;
 | 
				
			||||||
 | 
					    char_rows = ((ui_char_buttons->height() - button_height) / (y_spacing + button_height)) + 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int startout = starting;
 | 
				
			||||||
 | 
					    for (int n = starting ; n < startout+chars_on_this_page ; ++n)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      int x_pos = (button_width + x_spacing) * x_mod_count;
 | 
				
			||||||
 | 
					      int y_pos = (button_height + y_spacing) * y_mod_count;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      ui_char_button_list.at(n)->move(x_pos, y_pos);
 | 
				
			||||||
 | 
					      ui_char_button_list.at(n)->show();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      ++x_mod_count;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (x_mod_count == char_columns)
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        ++y_mod_count;
 | 
				
			||||||
 | 
					        x_mod_count = 0;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Courtroom::character_loading_finished()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // We move them out of the reachable area, so they can't be accidentally clicked.
 | 
				
			||||||
 | 
					    // First, we'll make all the character buttons in the very beginning.
 | 
				
			||||||
 | 
					    // We hide them too, just in case.
 | 
				
			||||||
 | 
					    for (int n = 0; n < char_list.size(); n++)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      AOCharButton* character = new AOCharButton(ui_char_buttons, ao_app, 0, 0);
 | 
				
			||||||
 | 
					      character->hide();
 | 
				
			||||||
 | 
					      character->set_image(char_list.at(n).name);
 | 
				
			||||||
 | 
					      ui_char_button_list.append(character);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      connect(character, SIGNAL(clicked()), char_button_mapper, SLOT(map()));
 | 
				
			||||||
 | 
					      char_button_mapper->setMapping(character, ui_char_button_list.size() - 1);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    put_button_in_place(0, max_chars_on_page);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -47,6 +47,8 @@ public:
 | 
				
			|||||||
  void append_evidence(evi_type p_evi){evidence_list.append(p_evi);}
 | 
					  void append_evidence(evi_type p_evi){evidence_list.append(p_evi);}
 | 
				
			||||||
  void append_music(QString f_music){music_list.append(f_music);}
 | 
					  void append_music(QString f_music){music_list.append(f_music);}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void character_loading_finished();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //sets position of widgets based on theme ini files
 | 
					  //sets position of widgets based on theme ini files
 | 
				
			||||||
  void set_widgets();
 | 
					  void set_widgets();
 | 
				
			||||||
  //sets font size based on theme ini files
 | 
					  //sets font size based on theme ini files
 | 
				
			||||||
@ -272,6 +274,9 @@ private:
 | 
				
			|||||||
  int char_rows = 9;
 | 
					  int char_rows = 9;
 | 
				
			||||||
  int max_chars_on_page = 90;
 | 
					  int max_chars_on_page = 90;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const int button_width = 60;
 | 
				
			||||||
 | 
					  const int button_height = 60;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  int current_emote_page = 0;
 | 
					  int current_emote_page = 0;
 | 
				
			||||||
  int current_emote = 0;
 | 
					  int current_emote = 0;
 | 
				
			||||||
  int emote_columns = 5;
 | 
					  int emote_columns = 5;
 | 
				
			||||||
@ -427,6 +432,7 @@ private:
 | 
				
			|||||||
  void construct_char_select();
 | 
					  void construct_char_select();
 | 
				
			||||||
  void set_char_select();
 | 
					  void set_char_select();
 | 
				
			||||||
  void set_char_select_page();
 | 
					  void set_char_select_page();
 | 
				
			||||||
 | 
					  void put_button_in_place(int starting, int chars_on_this_page);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void construct_emotes();
 | 
					  void construct_emotes();
 | 
				
			||||||
  void set_emote_page();
 | 
					  void set_emote_page();
 | 
				
			||||||
 | 
				
			|||||||
@ -296,11 +296,11 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
 | 
				
			|||||||
      w_lobby->set_loading_text("Loading chars:\n" + QString::number(loaded_chars) + "/" + QString::number(char_list_size));
 | 
					      w_lobby->set_loading_text("Loading chars:\n" + QString::number(loaded_chars) + "/" + QString::number(char_list_size));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      w_courtroom->append_char(f_char);
 | 
					      w_courtroom->append_char(f_char);
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int total_loading_size = char_list_size + evidence_list_size + music_list_size;
 | 
					      int total_loading_size = char_list_size + evidence_list_size + music_list_size;
 | 
				
			||||||
    int loading_value = (loaded_chars / static_cast<double>(total_loading_size)) * 100;
 | 
					      int loading_value = int(((loaded_chars + loaded_music + loaded_evidence) / static_cast<double>(total_loading_size)) * 100);
 | 
				
			||||||
    w_lobby->set_loading_value(loading_value);
 | 
					      w_lobby->set_loading_value(loading_value);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (improved_loading_enabled)
 | 
					    if (improved_loading_enabled)
 | 
				
			||||||
      send_server_packet(new AOPacket("RE#%"));
 | 
					      send_server_packet(new AOPacket("RE#%"));
 | 
				
			||||||
@ -342,7 +342,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
 | 
				
			|||||||
    w_courtroom->append_evidence(f_evi);
 | 
					    w_courtroom->append_evidence(f_evi);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int total_loading_size = char_list_size + evidence_list_size + music_list_size;
 | 
					    int total_loading_size = char_list_size + evidence_list_size + music_list_size;
 | 
				
			||||||
    int loading_value = ((loaded_chars + loaded_evidence) / static_cast<double>(total_loading_size)) * 100;
 | 
					    int loading_value = int(((loaded_chars + loaded_music + loaded_evidence) / static_cast<double>(total_loading_size)) * 100);
 | 
				
			||||||
    w_lobby->set_loading_value(loading_value);
 | 
					    w_lobby->set_loading_value(loading_value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QString next_packet_number = QString::number(loaded_evidence);
 | 
					    QString next_packet_number = QString::number(loaded_evidence);
 | 
				
			||||||
@ -369,11 +369,11 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
 | 
				
			|||||||
      w_lobby->set_loading_text("Loading music:\n" + QString::number(loaded_music) + "/" + QString::number(music_list_size));
 | 
					      w_lobby->set_loading_text("Loading music:\n" + QString::number(loaded_music) + "/" + QString::number(music_list_size));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      w_courtroom->append_music(f_music);
 | 
					      w_courtroom->append_music(f_music);
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int total_loading_size = char_list_size + evidence_list_size + music_list_size;
 | 
					      int total_loading_size = char_list_size + evidence_list_size + music_list_size;
 | 
				
			||||||
    int loading_value = ((loaded_chars + loaded_evidence + loaded_music) / static_cast<double>(total_loading_size)) * 100;
 | 
					      int loading_value = int(((loaded_chars + loaded_music + loaded_evidence) / static_cast<double>(total_loading_size)) * 100);
 | 
				
			||||||
    w_lobby->set_loading_value(loading_value);
 | 
					      w_lobby->set_loading_value(loading_value);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QString next_packet_number = QString::number(((loaded_music - 1) / 10) + 1);
 | 
					    QString next_packet_number = QString::number(((loaded_music - 1) / 10) + 1);
 | 
				
			||||||
    send_server_packet(new AOPacket("AM#" + next_packet_number + "#%"));
 | 
					    send_server_packet(new AOPacket("AM#" + next_packet_number + "#%"));
 | 
				
			||||||
@ -414,11 +414,12 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
 | 
				
			|||||||
      w_lobby->set_loading_text("Loading chars:\n" + QString::number(loaded_chars) + "/" + QString::number(char_list_size));
 | 
					      w_lobby->set_loading_text("Loading chars:\n" + QString::number(loaded_chars) + "/" + QString::number(char_list_size));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      w_courtroom->append_char(f_char);
 | 
					      w_courtroom->append_char(f_char);
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int total_loading_size = char_list_size + evidence_list_size + music_list_size;
 | 
					      int total_loading_size = char_list_size + evidence_list_size + music_list_size;
 | 
				
			||||||
    int loading_value = (loaded_chars / static_cast<double>(total_loading_size)) * 100;
 | 
					      int loading_value = int(((loaded_chars + loaded_music + loaded_evidence) / static_cast<double>(total_loading_size)) * 100);
 | 
				
			||||||
    w_lobby->set_loading_value(loading_value);
 | 
					      w_lobby->set_loading_value(loading_value);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    w_courtroom->character_loading_finished();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    send_server_packet(new AOPacket("RM#%"));
 | 
					    send_server_packet(new AOPacket("RM#%"));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -434,11 +435,11 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
 | 
				
			|||||||
      w_lobby->set_loading_text("Loading music:\n" + QString::number(loaded_music) + "/" + QString::number(music_list_size));
 | 
					      w_lobby->set_loading_text("Loading music:\n" + QString::number(loaded_music) + "/" + QString::number(music_list_size));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      w_courtroom->append_music(f_contents.at(n_element));
 | 
					      w_courtroom->append_music(f_contents.at(n_element));
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int total_loading_size = char_list_size + evidence_list_size + music_list_size;
 | 
					      int total_loading_size = char_list_size + evidence_list_size + music_list_size;
 | 
				
			||||||
    int loading_value = (loaded_chars / static_cast<double>(total_loading_size)) * 100;
 | 
					      int loading_value = int(((loaded_chars + loaded_music + loaded_evidence) / static_cast<double>(total_loading_size)) * 100);
 | 
				
			||||||
    w_lobby->set_loading_value(loading_value);
 | 
					      w_lobby->set_loading_value(loading_value);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    send_server_packet(new AOPacket("RD#%"));
 | 
					    send_server_packet(new AOPacket("RD#%"));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -450,6 +451,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
 | 
				
			|||||||
    if (lobby_constructed)
 | 
					    if (lobby_constructed)
 | 
				
			||||||
      w_courtroom->append_ms_chatmessage("", w_lobby->get_chatlog());
 | 
					      w_courtroom->append_ms_chatmessage("", w_lobby->get_chatlog());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    w_courtroom->character_loading_finished();
 | 
				
			||||||
    w_courtroom->done_received();
 | 
					    w_courtroom->done_received();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    courtroom_loaded = true;
 | 
					    courtroom_loaded = true;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user