Merge branch 'discord-toggle'

This commit is contained in:
oldmud0 2018-07-05 21:33:27 -05:00
commit 064cde6759
12 changed files with 48 additions and 56 deletions

View File

@ -36,7 +36,8 @@ void AOApplication::construct_lobby()
int y = (screenGeometry.height()-w_lobby->height()) / 2;
w_lobby->move(x, y);
discord->state_lobby();
if(is_discord_enabled())
discord->state_lobby();
w_lobby->show();
}

View File

@ -117,6 +117,9 @@ public:
//Reads the theme from config.ini and loads it into the current_theme variable
QString read_theme();
//Returns the value of ooc_name in config.ini
QString get_ooc_name();
//Returns the blip rate from config.ini
int read_blip_rate();
@ -132,6 +135,9 @@ public:
//Returns the value of default_blip in config.ini
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
QStringList get_call_words();

View File

@ -10,7 +10,7 @@ void AOBlipPlayer::set_blips(QString p_sfx)
{
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]);
@ -24,7 +24,7 @@ void AOBlipPlayer::blip_tick()
{
int f_cycle = m_cycle++;
if (m_cycle == 5)
if (m_cycle == BLIP_COUNT)
m_cycle = 0;
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;
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);
}

View File

@ -8,6 +8,8 @@
#include <string.h>
#include <QDebug>
const int BLIP_COUNT = 5;
class AOBlipPlayer
{
public:
@ -24,7 +26,7 @@ private:
AOApplication *ao_app;
int m_volume;
HSTREAM m_stream_list[5];
HSTREAM m_stream_list[BLIP_COUNT];
};
#endif // AOBLIPPLAYER_H

View File

@ -95,6 +95,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_ooc_chat_name = new QLineEdit(this);
ui_ooc_chat_name->setFrame(false);
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->setFrame(false);
@ -649,13 +650,15 @@ void Courtroom::enter_courtroom(int p_cid)
if (m_cid == -1)
{
ao_app->discord->state_spectate();
if(ao_app->is_discord_enabled())
ao_app->discord->state_spectate();
f_char = "";
}
else
{
f_char = ao_app->get_char_name(char_list.at(m_cid).name);
ao_app->discord->state_character(f_char.toStdString());
if(ao_app->is_discord_enabled())
ao_app->discord->state_character(f_char.toStdString());
}
current_char = f_char;

View File

@ -262,7 +262,7 @@ private:
//whether the ooc chat is server or master chat, true is server
bool server_ooc = true;
QString current_background = "gs4";
QString current_background = "default";
AOMusicPlayer *music_player;
AOSfxPlayer *sfx_player;

View File

@ -4,6 +4,9 @@
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)
{
if (input > 127)
@ -53,31 +56,12 @@ namespace omni
if (input > 255)
return "FF";
std::bitset<8> whole_byte(input);
//240 represents 11110000, our needed bitmask
uint8_t left_mask_int = 240;
std::bitset<8> left_mask(left_mask_int);
std::bitset<8> left_halfword((whole_byte & left_mask) >> 4);
//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));
std::stringstream stream;
stream << std::setfill('0') << std::setw(sizeof(char)*2)
<< std::hex << input;
std::string result(stream.str());
std::transform(result.begin(), result.end(), result.begin(), ::toupper);
unsigned int left = left_halfword.to_ulong();
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;
return result;
}
} //namespace omni

View File

@ -4,6 +4,10 @@
#include <bitset>
#include <cstdint>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <sstream>
namespace omni
{

View File

@ -29,6 +29,7 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow()
ui_chatbox->setOpenExternalLinks(true);
ui_chatname = new QLineEdit(this);
ui_chatname->setPlaceholderText("Name");
ui_chatname->setText(ao_app->get_ooc_name());
ui_chatmessage = new QLineEdit(this);
ui_loading_background = new AOImage(this, ao_app);
ui_loading_text = new QTextEdit(ui_loading_background);

View File

@ -264,7 +264,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
QCryptographicHash hash(QCryptographicHash::Algorithm::Sha256);
hash.addData(server_address.toUtf8());
discord->state_server(server_name.toStdString(), hash.result().toBase64().toStdString());
if(is_discord_enabled())
discord->state_server(server_name.toStdString(), hash.result().toBase64().toStdString());
}
else if (header == "CI")
{

View File

@ -29,21 +29,6 @@ QString AOApplication::get_base_path()
#endif
}
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()
@ -96,7 +81,7 @@ QString AOApplication::get_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()
@ -118,5 +103,5 @@ QString Courtroom::get_background_path()
QString Courtroom::get_default_background_path()
{
return ao_app->get_base_path() + "background/gs4/";
return ao_app->get_base_path() + "background/default/";
}

View File

@ -52,6 +52,11 @@ QString AOApplication::read_theme()
return result;
}
QString AOApplication::get_ooc_name()
{
return read_config("ooc_name");
}
int AOApplication::read_blip_rate()
{
QString result = read_config("blip_rate");
@ -571,8 +576,8 @@ bool AOApplication::get_blank_blip()
return f_result.startsWith("true");
}
bool AOApplication::is_discord_enabled()
{
QString f_result = read_config("discord");
return !f_result.startsWith("false");
}