implemented ooc chat and cleaned up some old headers
This commit is contained in:
		
							parent
							
								
									5e2ea2b24c
								
							
						
					
					
						commit
						9682087667
					
				@ -32,8 +32,6 @@ SOURCES += main.cpp\
 | 
				
			|||||||
    hardware_functions.cpp
 | 
					    hardware_functions.cpp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HEADERS  += lobby.h \
 | 
					HEADERS  += lobby.h \
 | 
				
			||||||
    text_file_functions.h \
 | 
					 | 
				
			||||||
    path_functions.h \
 | 
					 | 
				
			||||||
    aoimage.h \
 | 
					    aoimage.h \
 | 
				
			||||||
    file_functions.h \
 | 
					    file_functions.h \
 | 
				
			||||||
    aobutton.h \
 | 
					    aobutton.h \
 | 
				
			||||||
 | 
				
			|||||||
@ -1,11 +1,12 @@
 | 
				
			|||||||
#include <QDebug>
 | 
					#include "aoapplication.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "lobby.h"
 | 
					#include "lobby.h"
 | 
				
			||||||
#include "courtroom.h"
 | 
					#include "courtroom.h"
 | 
				
			||||||
#include "networkmanager.h"
 | 
					#include "networkmanager.h"
 | 
				
			||||||
#include "text_file_functions.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "aoapplication.h"
 | 
					#include <QDebug>
 | 
				
			||||||
 | 
					#include <QRect>
 | 
				
			||||||
 | 
					#include <QDesktopWidget>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AOApplication::AOApplication(int &argc, char **argv) : QApplication(argc, argv)
 | 
					AOApplication::AOApplication(int &argc, char **argv) : QApplication(argc, argv)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -29,6 +30,11 @@ void AOApplication::construct_lobby()
 | 
				
			|||||||
  w_lobby = new Lobby(this);
 | 
					  w_lobby = new Lobby(this);
 | 
				
			||||||
  lobby_constructed = true;
 | 
					  lobby_constructed = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  QRect screenGeometry = QApplication::desktop()->screenGeometry();
 | 
				
			||||||
 | 
					  int x = (screenGeometry.width()-w_lobby->width()) / 2;
 | 
				
			||||||
 | 
					  int y = (screenGeometry.height()-w_lobby->height()) / 2;
 | 
				
			||||||
 | 
					  w_lobby->move(x, y);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  w_lobby->show();
 | 
					  w_lobby->show();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -54,6 +60,11 @@ void AOApplication::construct_courtroom()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  w_courtroom = new Courtroom(this);
 | 
					  w_courtroom = new Courtroom(this);
 | 
				
			||||||
  courtroom_constructed = true;
 | 
					  courtroom_constructed = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  QRect screenGeometry = QApplication::desktop()->screenGeometry();
 | 
				
			||||||
 | 
					  int x = (screenGeometry.width()-w_courtroom->width()) / 2;
 | 
				
			||||||
 | 
					  int y = (screenGeometry.height()-w_courtroom->height()) / 2;
 | 
				
			||||||
 | 
					  w_courtroom->move(x, y);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void AOApplication::destruct_courtroom()
 | 
					void AOApplication::destruct_courtroom()
 | 
				
			||||||
 | 
				
			|||||||
@ -86,6 +86,7 @@ public:
 | 
				
			|||||||
  void write_to_serverlist_txt(QString p_line);
 | 
					  void write_to_serverlist_txt(QString p_line);
 | 
				
			||||||
  QVector<server_type> read_serverlist_txt();
 | 
					  QVector<server_type> read_serverlist_txt();
 | 
				
			||||||
  pos_size_type get_pos_and_size(QString p_identifier, QString p_design_path);
 | 
					  pos_size_type get_pos_and_size(QString p_identifier, QString p_design_path);
 | 
				
			||||||
 | 
					  QString get_char_side(QString p_char);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
  const int RELEASE = 2;
 | 
					  const int RELEASE = 2;
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,6 @@
 | 
				
			|||||||
#include "aobutton.h"
 | 
					#include "aobutton.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "debug_functions.h"
 | 
					#include "debug_functions.h"
 | 
				
			||||||
#include "path_functions.h"
 | 
					 | 
				
			||||||
#include "file_functions.h"
 | 
					#include "file_functions.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,5 @@
 | 
				
			|||||||
#include "aocharbutton.h"
 | 
					#include "aocharbutton.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "path_functions.h"
 | 
					 | 
				
			||||||
#include "file_functions.h"
 | 
					#include "file_functions.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QFile>
 | 
					#include <QFile>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,4 @@
 | 
				
			|||||||
#include "file_functions.h"
 | 
					#include "file_functions.h"
 | 
				
			||||||
#include "path_functions.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "aoimage.h"
 | 
					#include "aoimage.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										110
									
								
								courtroom.cpp
									
									
									
									
									
								
							
							
						
						
									
										110
									
								
								courtroom.cpp
									
									
									
									
									
								
							@ -2,8 +2,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "aoapplication.h"
 | 
					#include "aoapplication.h"
 | 
				
			||||||
#include "lobby.h"
 | 
					#include "lobby.h"
 | 
				
			||||||
#include "text_file_functions.h"
 | 
					#include "hardware_functions.h"
 | 
				
			||||||
#include "path_functions.h"
 | 
					#include "file_functions.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -18,22 +18,33 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
 | 
				
			|||||||
  //viewport elements like background, desk, etc.
 | 
					  //viewport elements like background, desk, etc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ui_ic_chatlog = new QPlainTextEdit(this);
 | 
					  ui_ic_chatlog = new QPlainTextEdit(this);
 | 
				
			||||||
 | 
					  ui_ic_chatlog->setReadOnly(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ui_ms_chatlog = new QPlainTextEdit(this);
 | 
					  ui_ms_chatlog = new QPlainTextEdit(this);
 | 
				
			||||||
  ui_server_chatlog = new QPlainTextEdit(this);
 | 
					  ui_ms_chatlog->setReadOnly(true);
 | 
				
			||||||
 | 
					  ui_ms_chatlog->hide();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ui_server_chatlog = new QPlainTextEdit(this);
 | 
				
			||||||
 | 
					  ui_server_chatlog->setReadOnly(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ui_mute_list = new QListWidget(this);
 | 
					  ui_mute_list = new QListWidget(this);
 | 
				
			||||||
  ui_area_list = new QListWidget(this);
 | 
					  ui_area_list = new QListWidget(this);
 | 
				
			||||||
  ui_music_list = new QListWidget(this);
 | 
					  ui_music_list = new QListWidget(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ui_ic_chat_message = new QLineEdit(this);
 | 
					  ui_ic_chat_message = new QLineEdit(this);
 | 
				
			||||||
 | 
					  ui_ic_chat_message->setFrame(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ui_ooc_chat_message = new QLineEdit(this);
 | 
					  ui_ooc_chat_message = new QLineEdit(this);
 | 
				
			||||||
 | 
					  ui_ooc_chat_message->setFrame(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ui_ooc_chat_name = new QLineEdit(this);
 | 
					  ui_ooc_chat_name = new QLineEdit(this);
 | 
				
			||||||
 | 
					  ui_ooc_chat_name->setFrame(false);
 | 
				
			||||||
 | 
					  ui_ooc_chat_name->setPlaceholderText("Name");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ui_area_password = new QLineEdit(this);
 | 
					  ui_area_password = new QLineEdit(this);
 | 
				
			||||||
 | 
					  ui_area_password->setFrame(false);
 | 
				
			||||||
  ui_music_search = new QLineEdit(this);
 | 
					  ui_music_search = new QLineEdit(this);
 | 
				
			||||||
 | 
					  ui_music_search->setFrame(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //emote buttons
 | 
					  //emote buttons
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -138,6 +149,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  ui_spectator = new AOButton(ui_char_select_background, ao_app);
 | 
					  ui_spectator = new AOButton(ui_char_select_background, ao_app);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  connect(ui_ooc_chat_message, SIGNAL(returnPressed()), this, SLOT(on_ooc_return_pressed()));
 | 
				
			||||||
 | 
					  connect(ui_ooc_toggle, SIGNAL(clicked()), this, SLOT(on_ooc_toggle_clicked()));
 | 
				
			||||||
  connect(ui_change_character, SIGNAL(clicked()), this, SLOT(on_change_character_clicked()));
 | 
					  connect(ui_change_character, SIGNAL(clicked()), this, SLOT(on_change_character_clicked()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  connect(ui_reload_theme, SIGNAL(clicked()), this, SLOT(on_reload_theme_clicked()));
 | 
					  connect(ui_reload_theme, SIGNAL(clicked()), this, SLOT(on_reload_theme_clicked()));
 | 
				
			||||||
@ -390,6 +403,86 @@ void Courtroom::set_char_select_page()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Courtroom::enter_courtroom(int p_cid)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  m_cid = p_cid;
 | 
				
			||||||
 | 
					  QString f_char = char_list.at(m_cid).name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //T0D0: set emote buttons
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  QString side = ao_app->get_char_side(f_char);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (side == "jud")
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    ui_witness_testimony->show();
 | 
				
			||||||
 | 
					    ui_cross_examination->show();
 | 
				
			||||||
 | 
					    ui_defense_minus->show();
 | 
				
			||||||
 | 
					    ui_defense_plus->show();
 | 
				
			||||||
 | 
					    ui_prosecution_minus->show();
 | 
				
			||||||
 | 
					    ui_prosecution_plus->show();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    ui_witness_testimony->hide();
 | 
				
			||||||
 | 
					    ui_cross_examination->hide();
 | 
				
			||||||
 | 
					    ui_defense_minus->hide();
 | 
				
			||||||
 | 
					    ui_defense_plus->hide();
 | 
				
			||||||
 | 
					    ui_prosecution_minus->hide();
 | 
				
			||||||
 | 
					    ui_prosecution_plus->hide();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ui_char_select_background->hide();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Courtroom::append_ms_chatmessage(QString f_message)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  ui_ms_chatlog->appendPlainText(f_message);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Courtroom::append_server_chatmessage(QString f_message)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  ui_server_chatlog->appendPlainText(f_message);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Courtroom::on_ooc_return_pressed()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  if (ui_ooc_chat_message->text() == "" || ui_ooc_chat_name->text() == "")
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  QStringList packet_contents;
 | 
				
			||||||
 | 
					  packet_contents.append(ui_ooc_chat_name->text());
 | 
				
			||||||
 | 
					  packet_contents.append(ui_ooc_chat_message->text());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  AOPacket *f_packet = new AOPacket("CT", packet_contents);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (server_ooc)
 | 
				
			||||||
 | 
					    ao_app->send_server_packet(f_packet);
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    ao_app->send_ms_packet(f_packet);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ui_ooc_chat_message->clear();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Courtroom::on_ooc_toggle_clicked()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  if (server_ooc)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    ui_ms_chatlog->show();
 | 
				
			||||||
 | 
					    ui_server_chatlog->hide();
 | 
				
			||||||
 | 
					    ui_ooc_toggle->setText("Master");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    server_ooc = false;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    ui_ms_chatlog->hide();
 | 
				
			||||||
 | 
					    ui_server_chatlog->show();
 | 
				
			||||||
 | 
					    ui_ooc_toggle->setText("Server");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    server_ooc = true;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Courtroom::on_change_character_clicked()
 | 
					void Courtroom::on_change_character_clicked()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  ui_char_select_background->show();
 | 
					  ui_char_select_background->show();
 | 
				
			||||||
@ -428,7 +521,18 @@ void Courtroom::on_spectator_clicked()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void Courtroom::char_clicked(int n_char)
 | 
					void Courtroom::char_clicked(int n_char)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  int n_real_char = n_char + current_char_page * 90;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  QString char_ini_path = ao_app->get_character_path(char_list.at(n_real_char).name) + "char.ini";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (!file_exists(char_ini_path))
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    qDebug() << "did not find " << char_ini_path;
 | 
				
			||||||
 | 
					    //T0D0: call error
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_real_char) + "#" + get_hdid() + "#%"));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Courtroom::~Courtroom()
 | 
					Courtroom::~Courtroom()
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										18
									
								
								courtroom.h
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								courtroom.h
									
									
									
									
									
								
							@ -35,6 +35,11 @@ public:
 | 
				
			|||||||
  void set_taken(int n_char, bool p_taken);
 | 
					  void set_taken(int n_char, bool p_taken);
 | 
				
			||||||
  void set_char_select_page();
 | 
					  void set_char_select_page();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void enter_courtroom(int p_cid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void append_ms_chatmessage(QString f_message);
 | 
				
			||||||
 | 
					  void append_server_chatmessage(QString f_message);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ~Courtroom();
 | 
					  ~Courtroom();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
@ -59,6 +64,12 @@ private:
 | 
				
			|||||||
  //makes char arithmetic easier
 | 
					  //makes char arithmetic easier
 | 
				
			||||||
  int current_char_page = 0;
 | 
					  int current_char_page = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //character id, which index of the char_list the player is
 | 
				
			||||||
 | 
					  int m_cid = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //wether the ooc chat is server or master chat, true is server
 | 
				
			||||||
 | 
					  bool server_ooc = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  AOImage *ui_background;
 | 
					  AOImage *ui_background;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //T0D0: add viewport elements like background, desk, etc.
 | 
					  //T0D0: add viewport elements like background, desk, etc.
 | 
				
			||||||
@ -143,16 +154,19 @@ private:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  AOButton *ui_spectator;
 | 
					  AOButton *ui_spectator;
 | 
				
			||||||
private slots:
 | 
					private slots:
 | 
				
			||||||
 | 
					  void on_ooc_return_pressed();
 | 
				
			||||||
 | 
					  void on_ooc_toggle_clicked();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void on_change_character_clicked();
 | 
					  void on_change_character_clicked();
 | 
				
			||||||
  void on_reload_theme_clicked();
 | 
					  void on_reload_theme_clicked();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void on_back_to_lobby_clicked();
 | 
					  void on_back_to_lobby_clicked();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void on_spectator_clicked();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  void on_char_select_left_clicked();
 | 
					  void on_char_select_left_clicked();
 | 
				
			||||||
  void on_char_select_right_clicked();
 | 
					  void on_char_select_right_clicked();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void on_spectator_clicked();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void char_clicked(int n_char);
 | 
					  void char_clicked(int n_char);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										15
									
								
								lobby.cpp
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								lobby.cpp
									
									
									
									
									
								
							@ -1,7 +1,5 @@
 | 
				
			|||||||
#include "lobby.h"
 | 
					#include "lobby.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "path_functions.h"
 | 
					 | 
				
			||||||
#include "text_file_functions.h"
 | 
					 | 
				
			||||||
#include "debug_functions.h"
 | 
					#include "debug_functions.h"
 | 
				
			||||||
#include "aoapplication.h"
 | 
					#include "aoapplication.h"
 | 
				
			||||||
#include "networkmanager.h"
 | 
					#include "networkmanager.h"
 | 
				
			||||||
@ -27,6 +25,7 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow()
 | 
				
			|||||||
  ui_description = new QPlainTextEdit(this);
 | 
					  ui_description = new QPlainTextEdit(this);
 | 
				
			||||||
  ui_chatbox = new QPlainTextEdit(this);
 | 
					  ui_chatbox = new QPlainTextEdit(this);
 | 
				
			||||||
  ui_chatname = new QLineEdit(this);
 | 
					  ui_chatname = new QLineEdit(this);
 | 
				
			||||||
 | 
					  ui_chatname->setPlaceholderText("Name");
 | 
				
			||||||
  ui_chatmessage = new QLineEdit(this);
 | 
					  ui_chatmessage = new QLineEdit(this);
 | 
				
			||||||
  ui_loading_background = new AOImage(this, ao_app);
 | 
					  ui_loading_background = new AOImage(this, ao_app);
 | 
				
			||||||
  ui_loading_text = new QTextEdit(ui_loading_background);
 | 
					  ui_loading_text = new QTextEdit(ui_loading_background);
 | 
				
			||||||
@ -152,6 +151,13 @@ void Lobby::set_loading_text(QString p_text)
 | 
				
			|||||||
  ui_loading_text->append(p_text);
 | 
					  ui_loading_text->append(p_text);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString Lobby::get_chatlog()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  QString return_value = ui_chatbox->toPlainText();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return return_value;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Lobby::on_public_servers_clicked()
 | 
					void Lobby::on_public_servers_clicked()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  ui_public_servers->set_image("publicservers_selected.png");
 | 
					  ui_public_servers->set_image("publicservers_selected.png");
 | 
				
			||||||
@ -260,6 +266,11 @@ void Lobby::on_server_list_clicked(QModelIndex p_model)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void Lobby::on_chatfield_return_pressed()
 | 
					void Lobby::on_chatfield_return_pressed()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  //no you can't send empty messages
 | 
				
			||||||
 | 
					  if (ui_chatname->text() == "" || ui_chatmessage->text() == "")
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  QString f_header = "CT";
 | 
					  QString f_header = "CT";
 | 
				
			||||||
  QStringList f_contents{ui_chatname->text(), ui_chatmessage->text()};
 | 
					  QStringList f_contents{ui_chatname->text(), ui_chatmessage->text()};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1
									
								
								lobby.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								lobby.h
									
									
									
									
									
								
							@ -29,6 +29,7 @@ public:
 | 
				
			|||||||
  void set_loading_text(QString p_text);
 | 
					  void set_loading_text(QString p_text);
 | 
				
			||||||
  void show_loading_overlay(){ui_loading_background->show();}
 | 
					  void show_loading_overlay(){ui_loading_background->show();}
 | 
				
			||||||
  void hide_loading_overlay(){ui_loading_background->hide();}
 | 
					  void hide_loading_overlay(){ui_loading_background->hide();}
 | 
				
			||||||
 | 
					  QString get_chatlog();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ~Lobby();
 | 
					  ~Lobby();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -63,8 +63,7 @@ void AOApplication::ms_packet_received(AOPacket *p_packet)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    if (courtroom_constructed)
 | 
					    if (courtroom_constructed)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      //T0D0: uncomment this when it's implemented
 | 
					      w_courtroom->append_ms_chatmessage(message_line);
 | 
				
			||||||
      //w_courtroom->append_ms_chat_message(message_line);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -77,7 +76,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
 | 
				
			|||||||
  QStringList f_contents = p_packet->get_contents();
 | 
					  QStringList f_contents = p_packet->get_contents();
 | 
				
			||||||
  QString f_packet = p_packet->to_string();
 | 
					  QString f_packet = p_packet->to_string();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  qDebug() << "R: " << f_packet;
 | 
					  if (header != "checkconnection")
 | 
				
			||||||
 | 
					    qDebug() << "R: " << f_packet;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (header == "decryptor")
 | 
					  if (header == "decryptor")
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
@ -113,10 +113,9 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
 | 
				
			|||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //QString message_line = f_contents.at(0) + ": " + f_contents.at(1);
 | 
					    QString message_line = f_contents.at(0) + ": " + f_contents.at(1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //T0D0, uncomment when implemented
 | 
					    w_courtroom->append_server_chatmessage(message_line);
 | 
				
			||||||
    //w_courtroom->append_ooc_chatmessage(message_line)
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else if (header == "PN")
 | 
					  else if (header == "PN")
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
@ -176,7 +175,6 @@ 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);
 | 
				
			||||||
      //qDebug() << "appended " << f_char.name << " to char_list";
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (loaded_chars < char_list_size)
 | 
					    if (loaded_chars < char_list_size)
 | 
				
			||||||
@ -281,10 +279,20 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    w_courtroom->set_char_select_page();
 | 
					    w_courtroom->set_char_select_page();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    w_courtroom->append_ms_chatmessage(w_lobby->get_chatlog());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    w_courtroom->show();
 | 
					    w_courtroom->show();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    destruct_lobby();
 | 
					    destruct_lobby();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  //server accepting char request(CC) packet
 | 
				
			||||||
 | 
					  if (header == "PV")
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    if (f_contents.size() < 3)
 | 
				
			||||||
 | 
					      return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    w_courtroom->enter_courtroom(f_contents.at(2).toInt());
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void AOApplication::send_ms_packet(AOPacket *p_packet)
 | 
					void AOApplication::send_ms_packet(AOPacket *p_packet)
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,5 @@
 | 
				
			|||||||
#include "aoapplication.h"
 | 
					#include "aoapplication.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "text_file_functions.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <QDir>
 | 
					#include <QDir>
 | 
				
			||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,8 +0,0 @@
 | 
				
			|||||||
#ifndef PATH_FUNCTIONS_H
 | 
					 | 
				
			||||||
#define PATH_FUNCTIONS_H
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <QString>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif // PATH_FUNCTIONS_H
 | 
					 | 
				
			||||||
@ -1,6 +1,5 @@
 | 
				
			|||||||
#include "aoapplication.h"
 | 
					#include "aoapplication.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "path_functions.h"
 | 
					 | 
				
			||||||
#include "file_functions.h"
 | 
					#include "file_functions.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <QTextStream>
 | 
					#include <QTextStream>
 | 
				
			||||||
@ -140,3 +139,38 @@ pos_size_type AOApplication::get_pos_and_size(QString p_identifier, QString p_de
 | 
				
			|||||||
  return return_value;
 | 
					  return return_value;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString AOApplication::get_char_side(QString p_char)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  QString char_ini_path = get_character_path(p_char) + "char.ini";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  QFile char_ini;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  char_ini.setFileName(char_ini_path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (!char_ini.open(QIODevice::ReadOnly))
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    //default to wit and don't make a big deal about it
 | 
				
			||||||
 | 
					    return "wit";
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  QTextStream in(&char_ini);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  while(!in.atEnd())
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    QString line = in.readLine();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!line.startsWith("side"))
 | 
				
			||||||
 | 
					      continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    QStringList line_elements = line.split("=");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (line_elements.size() < 2)
 | 
				
			||||||
 | 
					      continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //note that we do not validate if this is a valid side or not. that's up to the caller
 | 
				
			||||||
 | 
					    return line_elements.at(1).trimmed().toLower();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return "wit";
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,11 +0,0 @@
 | 
				
			|||||||
#ifndef TEXT_FILE_FUNCTIONS_H
 | 
					 | 
				
			||||||
#define TEXT_FILE_FUNCTIONS_H
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "datatypes.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <QString>
 | 
					 | 
				
			||||||
#include <QFile>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif // TEXT_FILE_FUNCTIONS_H
 | 
					 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user