Merge branch 'discord-toggle'
This commit is contained in:
		
						commit
						064cde6759
					
				@ -36,6 +36,7 @@ void AOApplication::construct_lobby()
 | 
				
			|||||||
  int y = (screenGeometry.height()-w_lobby->height()) / 2;
 | 
					  int y = (screenGeometry.height()-w_lobby->height()) / 2;
 | 
				
			||||||
  w_lobby->move(x, y);
 | 
					  w_lobby->move(x, y);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if(is_discord_enabled())
 | 
				
			||||||
    discord->state_lobby();
 | 
					    discord->state_lobby();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  w_lobby->show();
 | 
					  w_lobby->show();
 | 
				
			||||||
 | 
				
			|||||||
@ -117,6 +117,9 @@ public:
 | 
				
			|||||||
  //Reads the theme from config.ini and loads it into the current_theme variable
 | 
					  //Reads the theme from config.ini and loads it into the current_theme variable
 | 
				
			||||||
  QString read_theme();
 | 
					  QString read_theme();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //Returns the value of ooc_name in config.ini
 | 
				
			||||||
 | 
					  QString get_ooc_name();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //Returns the blip rate from config.ini
 | 
					  //Returns the blip rate from config.ini
 | 
				
			||||||
  int read_blip_rate();
 | 
					  int read_blip_rate();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -132,6 +135,9 @@ public:
 | 
				
			|||||||
  //Returns the value of default_blip in config.ini
 | 
					  //Returns the value of default_blip in config.ini
 | 
				
			||||||
  int get_default_blip();
 | 
					  int get_default_blip();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //Returns true if discord is enabled in config.ini and false otherwise
 | 
				
			||||||
 | 
					  bool is_discord_enabled();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //Returns the list of words in callwords.ini
 | 
					  //Returns the list of words in callwords.ini
 | 
				
			||||||
  QStringList get_call_words();
 | 
					  QStringList get_call_words();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -10,7 +10,7 @@ void AOBlipPlayer::set_blips(QString p_sfx)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  QString f_path = ao_app->get_sounds_path() + p_sfx.toLower();
 | 
					  QString f_path = ao_app->get_sounds_path() + p_sfx.toLower();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
 | 
					  for (int n_stream = 0 ; n_stream < BLIP_COUNT ; ++n_stream)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    BASS_StreamFree(m_stream_list[n_stream]);
 | 
					    BASS_StreamFree(m_stream_list[n_stream]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -24,7 +24,7 @@ void AOBlipPlayer::blip_tick()
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  int f_cycle = m_cycle++;
 | 
					  int f_cycle = m_cycle++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (m_cycle == 5)
 | 
					  if (m_cycle == BLIP_COUNT)
 | 
				
			||||||
    m_cycle = 0;
 | 
					    m_cycle = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  HSTREAM f_stream = m_stream_list[f_cycle];
 | 
					  HSTREAM f_stream = m_stream_list[f_cycle];
 | 
				
			||||||
@ -38,7 +38,7 @@ void AOBlipPlayer::set_volume(int p_value)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  float volume = p_value / 100.0f;
 | 
					  float volume = p_value / 100.0f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
 | 
					  for (int n_stream = 0 ; n_stream < BLIP_COUNT ; ++n_stream)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume);
 | 
					    BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
@ -8,6 +8,8 @@
 | 
				
			|||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <QDebug>
 | 
					#include <QDebug>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const int BLIP_COUNT = 5;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class AOBlipPlayer
 | 
					class AOBlipPlayer
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
@ -24,7 +26,7 @@ private:
 | 
				
			|||||||
  AOApplication *ao_app;
 | 
					  AOApplication *ao_app;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  int m_volume;
 | 
					  int m_volume;
 | 
				
			||||||
  HSTREAM m_stream_list[5];
 | 
					  HSTREAM m_stream_list[BLIP_COUNT];
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // AOBLIPPLAYER_H
 | 
					#endif // AOBLIPPLAYER_H
 | 
				
			||||||
 | 
				
			|||||||
@ -95,6 +95,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
 | 
				
			|||||||
  ui_ooc_chat_name = new QLineEdit(this);
 | 
					  ui_ooc_chat_name = new QLineEdit(this);
 | 
				
			||||||
  ui_ooc_chat_name->setFrame(false);
 | 
					  ui_ooc_chat_name->setFrame(false);
 | 
				
			||||||
  ui_ooc_chat_name->setPlaceholderText("Name");
 | 
					  ui_ooc_chat_name->setPlaceholderText("Name");
 | 
				
			||||||
 | 
					  ui_ooc_chat_name->setText(ao_app->get_ooc_name());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //ui_area_password = new QLineEdit(this);
 | 
					  //ui_area_password = new QLineEdit(this);
 | 
				
			||||||
  //ui_area_password->setFrame(false);
 | 
					  //ui_area_password->setFrame(false);
 | 
				
			||||||
@ -649,12 +650,14 @@ void Courtroom::enter_courtroom(int p_cid)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  if (m_cid == -1)
 | 
					  if (m_cid == -1)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
 | 
					    if(ao_app->is_discord_enabled())
 | 
				
			||||||
      ao_app->discord->state_spectate();
 | 
					      ao_app->discord->state_spectate();
 | 
				
			||||||
    f_char = "";
 | 
					    f_char = "";
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    f_char = ao_app->get_char_name(char_list.at(m_cid).name);
 | 
					    f_char = ao_app->get_char_name(char_list.at(m_cid).name);
 | 
				
			||||||
 | 
					    if(ao_app->is_discord_enabled())
 | 
				
			||||||
      ao_app->discord->state_character(f_char.toStdString());
 | 
					      ao_app->discord->state_character(f_char.toStdString());
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -262,7 +262,7 @@ private:
 | 
				
			|||||||
  //whether the ooc chat is server or master chat, true is server
 | 
					  //whether the ooc chat is server or master chat, true is server
 | 
				
			||||||
  bool server_ooc = true;
 | 
					  bool server_ooc = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  QString current_background = "gs4";
 | 
					  QString current_background = "default";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  AOMusicPlayer *music_player;
 | 
					  AOMusicPlayer *music_player;
 | 
				
			||||||
  AOSfxPlayer *sfx_player;
 | 
					  AOSfxPlayer *sfx_player;
 | 
				
			||||||
 | 
				
			|||||||
@ -4,6 +4,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace omni
 | 
					namespace omni
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  // This might be unused but I don't care to search the entire source code
 | 
				
			||||||
 | 
					  // So it will remain here (lol)
 | 
				
			||||||
 | 
					  // The actual int to hex conversion is now done properly
 | 
				
			||||||
  char halfword_to_hex_char(unsigned int input)
 | 
					  char halfword_to_hex_char(unsigned int input)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    if (input > 127)
 | 
					    if (input > 127)
 | 
				
			||||||
@ -53,31 +56,12 @@ namespace omni
 | 
				
			|||||||
    if (input > 255)
 | 
					    if (input > 255)
 | 
				
			||||||
      return "FF";
 | 
					      return "FF";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::bitset<8> whole_byte(input);
 | 
					    std::stringstream stream;
 | 
				
			||||||
    //240 represents 11110000, our needed bitmask
 | 
					    stream << std::setfill('0') << std::setw(sizeof(char)*2)
 | 
				
			||||||
    uint8_t left_mask_int = 240;
 | 
					       << std::hex << input;
 | 
				
			||||||
    std::bitset<8> left_mask(left_mask_int);
 | 
					    std::string result(stream.str());
 | 
				
			||||||
    std::bitset<8> left_halfword((whole_byte & left_mask) >> 4);
 | 
					    std::transform(result.begin(), result.end(), result.begin(), ::toupper);
 | 
				
			||||||
    //likewise, 15 represents 00001111
 | 
					 | 
				
			||||||
    uint8_t right_mask_int = 15;
 | 
					 | 
				
			||||||
    std::bitset<8> right_mask(right_mask_int);
 | 
					 | 
				
			||||||
    std::bitset<8> right_halfword((whole_byte & right_mask));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    unsigned int left = left_halfword.to_ulong();
 | 
					    return result;
 | 
				
			||||||
    unsigned int right = right_halfword.to_ulong();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    //std::cout << "now have have " << left << " and " << right << '\n';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    char a = halfword_to_hex_char(left);
 | 
					 | 
				
			||||||
    char b = halfword_to_hex_char(right);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    std::string left_string(1, a);
 | 
					 | 
				
			||||||
    std::string right_string(1, b);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    std::string final_byte = left_string + right_string;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    //std::string final_byte = halfword_to_hex_char(left) + "" + halfword_to_hex_char(right);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return final_byte;
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
} //namespace omni
 | 
					} //namespace omni
 | 
				
			||||||
 | 
				
			|||||||
@ -4,6 +4,10 @@
 | 
				
			|||||||
#include <bitset>
 | 
					#include <bitset>
 | 
				
			||||||
#include <cstdint>
 | 
					#include <cstdint>
 | 
				
			||||||
#include <iostream>
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					#include <algorithm>
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					#include <iomanip>
 | 
				
			||||||
 | 
					#include <sstream>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace omni
 | 
					namespace omni
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
				
			|||||||
@ -29,6 +29,7 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow()
 | 
				
			|||||||
  ui_chatbox->setOpenExternalLinks(true);
 | 
					  ui_chatbox->setOpenExternalLinks(true);
 | 
				
			||||||
  ui_chatname = new QLineEdit(this);
 | 
					  ui_chatname = new QLineEdit(this);
 | 
				
			||||||
  ui_chatname->setPlaceholderText("Name");
 | 
					  ui_chatname->setPlaceholderText("Name");
 | 
				
			||||||
 | 
					  ui_chatname->setText(ao_app->get_ooc_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);
 | 
				
			||||||
 | 
				
			|||||||
@ -264,6 +264,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    QCryptographicHash hash(QCryptographicHash::Algorithm::Sha256);
 | 
					    QCryptographicHash hash(QCryptographicHash::Algorithm::Sha256);
 | 
				
			||||||
    hash.addData(server_address.toUtf8());
 | 
					    hash.addData(server_address.toUtf8());
 | 
				
			||||||
 | 
					    if(is_discord_enabled())
 | 
				
			||||||
      discord->state_server(server_name.toStdString(), hash.result().toBase64().toStdString());
 | 
					      discord->state_server(server_name.toStdString(), hash.result().toBase64().toStdString());
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else if (header == "CI")
 | 
					  else if (header == "CI")
 | 
				
			||||||
 | 
				
			|||||||
@ -29,21 +29,6 @@ QString AOApplication::get_base_path()
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
    return base_path;
 | 
					    return base_path;
 | 
				
			||||||
  /*
 | 
					 | 
				
			||||||
#ifdef OMNI_DEBUG
 | 
					 | 
				
			||||||
  return "/media/omnitroid/Data/winshare/AO/client/base/";
 | 
					 | 
				
			||||||
#elif OMNI_DEBUG2
 | 
					 | 
				
			||||||
  return "/home/omnitroid/winshare/AO/client/base/";
 | 
					 | 
				
			||||||
#elif defined(OMNI_WIN_DEBUG)
 | 
					 | 
				
			||||||
  return "E:/AO/client/base/";
 | 
					 | 
				
			||||||
#elif defined(OMNI_WIN_DEBUG2)
 | 
					 | 
				
			||||||
  return "F:/winshare/AO/client/base/";
 | 
					 | 
				
			||||||
#elif defined(ANDROID)
 | 
					 | 
				
			||||||
  return "/storage/extSdCard/AO2/";
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
  return QDir::currentPath() + "/base/";
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString AOApplication::get_data_path()
 | 
					QString AOApplication::get_data_path()
 | 
				
			||||||
@ -96,7 +81,7 @@ QString AOApplication::get_background_path()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
QString AOApplication::get_default_background_path()
 | 
					QString AOApplication::get_default_background_path()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  return get_base_path() + "background/gs4/";
 | 
					  return get_base_path() + "background/default/";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString AOApplication::get_evidence_path()
 | 
					QString AOApplication::get_evidence_path()
 | 
				
			||||||
@ -118,5 +103,5 @@ QString Courtroom::get_background_path()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
QString Courtroom::get_default_background_path()
 | 
					QString Courtroom::get_default_background_path()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  return ao_app->get_base_path() + "background/gs4/";
 | 
					  return ao_app->get_base_path() + "background/default/";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -52,6 +52,11 @@ QString AOApplication::read_theme()
 | 
				
			|||||||
    return result;
 | 
					    return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString AOApplication::get_ooc_name()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return read_config("ooc_name");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int AOApplication::read_blip_rate()
 | 
					int AOApplication::read_blip_rate()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  QString result = read_config("blip_rate");
 | 
					  QString result = read_config("blip_rate");
 | 
				
			||||||
@ -571,8 +576,8 @@ bool AOApplication::get_blank_blip()
 | 
				
			|||||||
  return f_result.startsWith("true");
 | 
					  return f_result.startsWith("true");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool AOApplication::is_discord_enabled()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  QString f_result = read_config("discord");
 | 
				
			||||||
 | 
					  return !f_result.startsWith("false");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user