gui implementation of #145, last test for #141

This commit is contained in:
doitux
2012-11-30 01:15:21 +01:00
parent 10f94f2749
commit cebbc667e1
3 changed files with 82 additions and 67 deletions
+16 -3
View File
@@ -40,8 +40,10 @@ ui(new Ui::LogFileDialog)
connect( ui->pushButton_exportLogHtml, SIGNAL(clicked()), this, SLOT (exportLogToHtml())); connect( ui->pushButton_exportLogHtml, SIGNAL(clicked()), this, SLOT (exportLogToHtml()));
connect( ui->pushButton_exportLogTxt, SIGNAL(clicked()), this, SLOT (exportLogToTxt())); connect( ui->pushButton_exportLogTxt, SIGNAL(clicked()), this, SLOT (exportLogToTxt()));
connect( ui->pushButton_saveLogAs, SIGNAL(clicked()), this, SLOT (saveLogFileAs())); connect( ui->pushButton_saveLogAs, SIGNAL(clicked()), this, SLOT (saveLogFileAs()));
connect( ui->treeWidget_logFiles, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(showLogFilePreview())); connect( ui->treeWidget_logFiles, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(showLogFilePreviewInit()));
connect( ui->pushButton_analyseLogfile, SIGNAL(clicked()), this, SLOT (uploadFile())); connect( ui->pushButton_analyseLogfile, SIGNAL(clicked()), this, SLOT (uploadFile()));
connect( ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(showLogFilePreviewSelected()));
} }
LogFileDialog::~LogFileDialog() LogFileDialog::~LogFileDialog()
@@ -154,12 +156,23 @@ void LogFileDialog::saveLogFileAs()
} }
} }
void LogFileDialog::showLogFilePreview() void LogFileDialog::showLogFilePreview(ShowLogMode mode)
{ {
QTreeWidgetItem* selectedItem = ui->treeWidget_logFiles->currentItem(); QTreeWidgetItem* selectedItem = ui->treeWidget_logFiles->currentItem();
if(mode == INIT_VIEW) {
ui->comboBox->blockSignals(TRUE);
ui->comboBox->clear();
QList<int> gameIds = myGuiLog->getGameList(selectedItem->data(0, Qt::UserRole).toString());
QList<int>::const_iterator it;
for (it = gameIds.constBegin(); it != gameIds.constEnd(); ++it) {
ui->comboBox->addItem(QString::number(*it));
}
ui->comboBox->blockSignals(FALSE);
}
if(selectedItem) { if(selectedItem) {
myGuiLog->showLog(selectedItem->data(0, Qt::UserRole).toString(), ui->textBrowser_logPreview); myGuiLog->showLog(selectedItem->data(0, Qt::UserRole).toString(), ui->textBrowser_logPreview, ui->comboBox->itemText(ui->comboBox->currentIndex()).toInt());
} }
QTextCursor cursor(ui->textBrowser_logPreview->textCursor()); QTextCursor cursor(ui->textBrowser_logPreview->textCursor());
+4 -1
View File
@@ -26,6 +26,7 @@ namespace Ui {
class LogFileDialog; class LogFileDialog;
} }
enum ShowLogMode { INIT_VIEW, SELECTED_GAME };
class guiLog; class guiLog;
class ConfigFile; class ConfigFile;
@@ -48,7 +49,9 @@ public slots:
void exportLogToHtml(); void exportLogToHtml();
void exportLogToTxt(); void exportLogToTxt();
void saveLogFileAs(); void saveLogFileAs();
void showLogFilePreview(); void showLogFilePreviewInit() {showLogFilePreview(INIT_VIEW); }
void showLogFilePreviewSelected() {showLogFilePreview(SELECTED_GAME); }
void showLogFilePreview(ShowLogMode);
void keyPressEvent ( QKeyEvent * event ); void keyPressEvent ( QKeyEvent * event );
void uploadFile(); void uploadFile();
+62 -63
View File
@@ -61,7 +61,6 @@ void SDLPlayer::initAudio()
if( Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) == 0) { if( Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) == 0) {
Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels); Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
audioEnabled = 1; audioEnabled = 1;
qDebug() << "Mix_OpenAudio()";
} }
else { else {
qDebug() << "Mix_OpenAudio() was not successfull, no sound possible :("; qDebug() << "Mix_OpenAudio() was not successfull, no sound possible :(";
@@ -73,76 +72,76 @@ void SDLPlayer::initAudio()
void SDLPlayer::playSound(string audioString, int playerID) void SDLPlayer::playSound(string audioString, int playerID)
{ {
#ifndef ANDROID #ifndef ANDROID
if(audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) { // if(audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) {
QFile myFile(myAppDataPath + "sounds/default/" + QString::fromStdString(audioString)+".wav"); // QFile myFile(myAppDataPath + "sounds/default/" + QString::fromStdString(audioString)+".wav");
if(myFile.open(QIODevice::ReadOnly)) { // if(myFile.open(QIODevice::ReadOnly)) {
//set 3d position for player // //set 3d position for player
int position = 0; // int position = 0;
int distance = 0; // int distance = 0;
switch (playerID) { // switch (playerID) {
case 0: { // case 0: {
position = 180; // position = 180;
distance = 10; // distance = 10;
} // }
break; // break;
case 1: { // case 1: {
position = 281; // position = 281;
distance = 50; // distance = 50;
} // }
break; // break;
case 2: { // case 2: {
position = 315; // position = 315;
distance = 120; // distance = 120;
} // }
break; // break;
case 3: { // case 3: {
position = 338; // position = 338;
distance = 160; // distance = 160;
} // }
break; // break;
case 4: { // case 4: {
position = 23; // position = 23;
distance = 160; // distance = 160;
} // }
break; // break;
case 5: { // case 5: {
position = 45; // position = 45;
distance = 120; // distance = 120;
} // }
break; // break;
case 6: { // case 6: {
position = 79; // position = 79;
distance = 50; // distance = 50;
} // }
break; // break;
default: { // default: {
position = 0; // position = 0;
distance = 0; // distance = 0;
} // }
break; // break;
} // }
QDataStream in(&myFile); // QDataStream in(&myFile);
soundData = new Uint8[(int)myFile.size()]; // soundData = new Uint8[(int)myFile.size()];
in.readRawData( (char*)soundData, (int)myFile.size() ); // in.readRawData( (char*)soundData, (int)myFile.size() );
sound = Mix_QuickLoad_WAV(soundData); // sound = Mix_QuickLoad_WAV(soundData);
// set channel 0 to settings volume // // set channel 0 to settings volume
Mix_Volume(-1,myConfig->readConfigInt("SoundVolume")*10); // Mix_Volume(-1,myConfig->readConfigInt("SoundVolume")*10);
// set 3d effect // // set 3d effect
if(!Mix_SetPosition(0, position, distance)) { // if(!Mix_SetPosition(0, position, distance)) {
printf("Mix_SetPosition: %s\n", Mix_GetError()); // printf("Mix_SetPosition: %s\n", Mix_GetError());
// no position effect, is it ok? // // no position effect, is it ok?
} // }
currentChannel = Mix_PlayChannel(-1, sound,0); // currentChannel = Mix_PlayChannel(-1, sound,0);
} // }
} // }
#endif #endif
} }