--- a/QTfrontend/gameuiconfig.cpp Tue Dec 18 20:48:37 2012 +0400
+++ b/QTfrontend/gameuiconfig.cpp Fri Jan 04 21:44:40 2013 +0400
@@ -24,6 +24,7 @@
#include <QStandardItemModel>
#include <QNetworkProxy>
#include <QNetworkProxyFactory>
+#include <utility>
#include "gameuiconfig.h"
#include "hwform.h"
@@ -34,6 +35,7 @@
#include "fpsedit.h"
#include "HWApplication.h"
#include "DataManager.h"
+#include "SDL.h"
const QNetworkProxy::ProxyType proxyTypesMap[] = {
@@ -52,6 +54,13 @@
connect(Form->ui.pageOptions->CBFrontendMusic, SIGNAL(toggled(bool)), Form, SLOT(Music(bool)));
+ for(int i = 0; i < BINDS_NUMBER; i++)
+ {
+ m_binds.append(BindAction());
+ m_binds[i].action = cbinds[i].action;
+ m_binds[i].strbind = cbinds[i].strbind;
+ }
+
//Form->resize(value("frontend/width", 640).toUInt(), value("frontend/height", 450).toUInt());
resizeToConfigValues();
@@ -65,7 +74,7 @@
{
Form->ui.pageOptions->WeaponTooltip->setChecked(value("misc/weaponTooltips", true).toBool());
- int t = Form->ui.pageOptions->CBResolution->findText(value("video/resolution").toString());
+ int t = Form->ui.pageOptions->CBResolution->findText(value("video/fullscreenResolution").toString());
if (t < 0)
{
if (Form->ui.pageOptions->CBResolution->count() > 1)
@@ -74,6 +83,20 @@
Form->ui.pageOptions->CBResolution->setCurrentIndex(0);
}
else Form->ui.pageOptions->CBResolution->setCurrentIndex(t);
+
+ // Default the windowed resolution to 5/6 of the screen size
+ int screenWidth = SDL_GetVideoInfo()->current_w * 5 / 6;
+ int screenHeight = SDL_GetVideoInfo()->current_h * 5 / 6;
+ QString widthStr; widthStr.setNum(screenWidth);
+ QString heightStr; heightStr.setNum(screenHeight);
+ QString wWidth = value("video/windowedWidth", widthStr).toString();
+ QString wHeight = value("video/windowedHeight", heightStr).toString();
+ // If left blank reset the resolution to the default
+ wWidth = (wWidth == "" ? widthStr : wWidth);
+ wHeight = (wHeight == "" ? heightStr : wHeight);
+ Form->ui.pageOptions->windowWidthEdit->setText(wWidth);
+ Form->ui.pageOptions->windowHeightEdit->setText(wHeight);
+
Form->ui.pageOptions->CBResolution->setCurrentIndex((t < 0) ? 1 : t);
Form->ui.pageOptions->CBFullscreen->setChecked(value("video/fullscreen", false).toBool());
bool ffscr=value("frontend/fullscreen", false).toBool();
@@ -130,15 +153,20 @@
Form->ui.pageOptions->leProxyLogin->setText(value("proxy/login", "").toString());
Form->ui.pageOptions->leProxyPassword->setText(value("proxy/password", "").toString());
- depth = HWApplication::desktop()->depth();
- if (depth < 16) depth = 16;
- else if (depth > 16) depth = 32;
-
{ // load colors
QStandardItemModel * model = DataManager::instance().colorsModel();
for(int i = model->rowCount() - 1; i >= 0; --i)
model->item(i)->setData(QColor(value(QString("colors/color%1").arg(i), model->item(i)->data().value<QColor>()).value<QColor>()));
}
+
+ { // load binds
+ QStandardItemModel * binds = DataManager::instance().bindsModel();
+ for(int i = 0; i < BINDS_NUMBER; i++)
+ {
+ m_binds[i].strbind = value(QString("Binds/%1").arg(m_binds[i].action), cbinds[i].strbind).toString();
+ if (m_binds[i].strbind.isEmpty() || m_binds[i].strbind == "default") m_binds[i].strbind = cbinds[i].strbind;
+ }
+ }
}
void GameUIConfig::reloadVideosValues(void)
@@ -203,7 +231,9 @@
void GameUIConfig::SaveOptions()
{
- setValue("video/resolution", Form->ui.pageOptions->CBResolution->currentText());
+ setValue("video/fullscreenResolution", Form->ui.pageOptions->CBResolution->currentText());
+ setValue("video/windowedWidth", Form->ui.pageOptions->windowWidthEdit->text());
+ setValue("video/windowedHeight", Form->ui.pageOptions->windowHeightEdit->text());
setValue("video/fullscreen", vid_Fullscreen());
setValue("video/quality", Form->ui.pageOptions->SLQuality->value());
@@ -323,16 +353,28 @@
return Form->ui.pageOptions->CBLanguage->itemData(Form->ui.pageOptions->CBLanguage->currentIndex()).toString();
}
-QRect GameUIConfig::vid_Resolution()
-{
- QRect result(0, 0, 640, 480);
+std::pair<QRect, QRect> GameUIConfig::vid_ResolutionPair() {
+ // returns a pair of both the fullscreen and the windowed resolution
+ QRect full(0, 0, 640, 480);
+ QRect windowed(0, 0, 640, 480);
QStringList wh = Form->ui.pageOptions->CBResolution->currentText().split('x');
if (wh.size() == 2)
{
- result.setWidth(wh[0].toInt());
- result.setHeight(wh[1].toInt());
+ full.setWidth(wh[0].toInt());
+ full.setHeight(wh[1].toInt());
}
- return result;
+ windowed.setWidth(Form->ui.pageOptions->windowWidthEdit->text().toInt());
+ windowed.setHeight(Form->ui.pageOptions->windowHeightEdit->text().toInt());
+ return std::make_pair(full, windowed);
+}
+
+QRect GameUIConfig::vid_Resolution()
+{
+ std::pair<QRect, QRect> result = vid_ResolutionPair();
+ if(Form->ui.pageOptions->CBFullscreen->isChecked())
+ return result.first;
+ else
+ return result.second;
}
bool GameUIConfig::vid_Fullscreen()
@@ -449,11 +491,6 @@
return 35 - Form->ui.pageOptions->fpsedit->value();
}
-quint8 GameUIConfig::bitDepth()
-{
- return depth;
-}
-
QString GameUIConfig::netNick()
{
return Form->ui.pageOptions->editNetNick->text();
@@ -590,3 +627,16 @@
{
return Form->ui.pageOptions->checkRecordAudio->isChecked();
}
+
+// Gets a bind for a bindID
+QString GameUIConfig::bind(int bindID)
+{
+ return m_binds[bindID].strbind;
+}
+
+// Sets a bind for a bindID and saves it
+void GameUIConfig::setBind(int bindID, QString & strbind)
+{
+ m_binds[bindID].strbind = strbind;
+ setValue(QString("Binds/%1").arg(m_binds[bindID].action), strbind);
+}