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_exportLogTxt, SIGNAL(clicked()), this, SLOT (exportLogToTxt()));
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->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(showLogFilePreviewSelected()));
}
LogFileDialog::~LogFileDialog()
@@ -154,12 +156,23 @@ void LogFileDialog::saveLogFileAs()
}
}
void LogFileDialog::showLogFilePreview()
void LogFileDialog::showLogFilePreview(ShowLogMode mode)
{
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) {
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());
+4 -1
View File
@@ -26,6 +26,7 @@ namespace Ui {
class LogFileDialog;
}
enum ShowLogMode { INIT_VIEW, SELECTED_GAME };
class guiLog;
class ConfigFile;
@@ -48,7 +49,9 @@ public slots:
void exportLogToHtml();
void exportLogToTxt();
void saveLogFileAs();
void showLogFilePreview();
void showLogFilePreviewInit() {showLogFilePreview(INIT_VIEW); }
void showLogFilePreviewSelected() {showLogFilePreview(SELECTED_GAME); }
void showLogFilePreview(ShowLogMode);
void keyPressEvent ( QKeyEvent * event );
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) {
Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
audioEnabled = 1;
qDebug() << "Mix_OpenAudio()";
}
else {
qDebug() << "Mix_OpenAudio() was not successfull, no sound possible :(";
@@ -73,76 +72,76 @@ void SDLPlayer::initAudio()
void SDLPlayer::playSound(string audioString, int playerID)
{
#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
int position = 0;
int distance = 0;
// //set 3d position for player
// int position = 0;
// int distance = 0;
switch (playerID) {
// switch (playerID) {
case 0: {
position = 180;
distance = 10;
}
break;
case 1: {
position = 281;
distance = 50;
}
break;
case 2: {
position = 315;
distance = 120;
}
break;
case 3: {
position = 338;
distance = 160;
}
break;
case 4: {
position = 23;
distance = 160;
}
break;
case 5: {
position = 45;
distance = 120;
}
break;
case 6: {
position = 79;
distance = 50;
}
break;
default: {
position = 0;
distance = 0;
}
break;
}
// case 0: {
// position = 180;
// distance = 10;
// }
// break;
// case 1: {
// position = 281;
// distance = 50;
// }
// break;
// case 2: {
// position = 315;
// distance = 120;
// }
// break;
// case 3: {
// position = 338;
// distance = 160;
// }
// break;
// case 4: {
// position = 23;
// distance = 160;
// }
// break;
// case 5: {
// position = 45;
// distance = 120;
// }
// break;
// case 6: {
// position = 79;
// distance = 50;
// }
// break;
// default: {
// position = 0;
// distance = 0;
// }
// break;
// }
QDataStream in(&myFile);
soundData = new Uint8[(int)myFile.size()];
in.readRawData( (char*)soundData, (int)myFile.size() );
sound = Mix_QuickLoad_WAV(soundData);
// QDataStream in(&myFile);
// soundData = new Uint8[(int)myFile.size()];
// in.readRawData( (char*)soundData, (int)myFile.size() );
// sound = Mix_QuickLoad_WAV(soundData);
// set channel 0 to settings volume
Mix_Volume(-1,myConfig->readConfigInt("SoundVolume")*10);
// // set channel 0 to settings volume
// Mix_Volume(-1,myConfig->readConfigInt("SoundVolume")*10);
// set 3d effect
if(!Mix_SetPosition(0, position, distance)) {
printf("Mix_SetPosition: %s\n", Mix_GetError());
// no position effect, is it ok?
}
currentChannel = Mix_PlayChannel(-1, sound,0);
}
}
// // set 3d effect
// if(!Mix_SetPosition(0, position, distance)) {
// printf("Mix_SetPosition: %s\n", Mix_GetError());
// // no position effect, is it ok?
// }
// currentChannel = Mix_PlayChannel(-1, sound,0);
// }
// }
#endif
}