QTfrontend/gameuiconfig.cpp
changeset 297 279e10ec31b4
parent 184 f97a7a3dc8f6
child 301 29bf9c1a3ad3
equal deleted inserted replaced
296:607912ccc5af 297:279e10ec31b4
    20 #include <QTextStream>
    20 #include <QTextStream>
    21 #include "gameuiconfig.h"
    21 #include "gameuiconfig.h"
    22 #include "hwform.h"
    22 #include "hwform.h"
    23 #include "pages.h"
    23 #include "pages.h"
    24 #include "hwconsts.h"
    24 #include "hwconsts.h"
       
    25 #include "fpsedit.h"
    25 
    26 
    26 GameUIConfig::GameUIConfig(HWForm * FormWidgets)
    27 GameUIConfig::GameUIConfig(HWForm * FormWidgets)
    27 	: QObject()
    28 	: QObject()
    28 {
    29 {
    29 	Form = FormWidgets;
    30 	Form = FormWidgets;
    56 				Form->ui.pageNet->editNetNick->setText(str.mid(5));
    57 				Form->ui.pageNet->editNetNick->setText(str.mid(5));
    57 			} else
    58 			} else
    58 			if (str.startsWith("ip "))
    59 			if (str.startsWith("ip "))
    59 			{
    60 			{
    60 				Form->ui.pageNet->editIP->setText(str.mid(3));
    61 				Form->ui.pageNet->editIP->setText(str.mid(3));
       
    62 			} else
       
    63 			if (str.startsWith("showfps "))
       
    64 			{
       
    65 				Form->ui.pageOptions->CBShowFPS->setChecked(str.mid(8).toLong());
       
    66 			} else
       
    67 			if (str.startsWith("interval "))
       
    68 			{
       
    69 				Form->ui.pageOptions->fpsedit->setValue(str.mid(9).toUInt());
    61 			}
    70 			}
    62 		}
    71 		}
    63 		settings.close();
    72 		settings.close();
    64 	}
    73 	}
    65 
    74 
   100 		return ;
   109 		return ;
   101 	}
   110 	}
   102 	QTextStream stream(&settings);
   111 	QTextStream stream(&settings);
   103 	stream.setCodec("UTF-8");
   112 	stream.setCodec("UTF-8");
   104 	stream << "; Generated by Hedgewars, do not modify" << endl;
   113 	stream << "; Generated by Hedgewars, do not modify" << endl;
   105 	stream << "resolution " << Form->ui.pageOptions->CBResolution->currentIndex() << endl;
   114 	stream << "resolution " << vid_Resolution() << endl;
   106 	stream << "fullscreen " << Form->ui.pageOptions->CBFullscreen->isChecked() << endl;
   115 	stream << "fullscreen " << vid_Fullscreen() << endl;
   107 	stream << "sound " << Form->ui.pageOptions->CBEnableSound->isChecked() << endl;
   116 	stream << "sound " << isSoundEnabled() << endl;
   108 	stream << "nick " << Form->ui.pageNet->editNetNick->text() << endl;
   117 	stream << "nick " << Form->ui.pageNet->editNetNick->text() << endl;
   109 	stream << "ip " << Form->ui.pageNet->editIP->text() << endl;
   118 	stream << "ip " << Form->ui.pageNet->editIP->text() << endl;
       
   119 	stream << "showfps " << isShowFPSEnabled() << endl;
       
   120 	stream << "interval " << Form->ui.pageOptions->fpsedit->value() << endl;
   110 	settings.close();
   121 	settings.close();
   111 }
   122 }
   112 
   123 
   113 int GameUIConfig::vid_Resolution()
   124 int GameUIConfig::vid_Resolution()
   114 {
   125 {
   123 bool GameUIConfig::isSoundEnabled()
   134 bool GameUIConfig::isSoundEnabled()
   124 {
   135 {
   125 	return Form->ui.pageOptions->CBEnableSound->isChecked();
   136 	return Form->ui.pageOptions->CBEnableSound->isChecked();
   126 }
   137 }
   127 
   138 
       
   139 bool GameUIConfig::isShowFPSEnabled()
       
   140 {
       
   141 	return Form->ui.pageOptions->CBShowFPS->isChecked();
       
   142 }
       
   143 
       
   144 quint8 GameUIConfig::timerInterval()
       
   145 {
       
   146 	return 35 - Form->ui.pageOptions->fpsedit->value();
       
   147 }
       
   148 
   128 QString GameUIConfig::GetRandomTheme()
   149 QString GameUIConfig::GetRandomTheme()
   129 {
   150 {
   130 	return (Themes.size() > 0) ? Themes[rand() % Themes.size()] : QString("steel");
   151 	return (Themes.size() > 0) ? Themes[rand() % Themes.size()] : QString("steel");
   131 }
   152 }