QTfrontend/game.cpp
changeset 84 0f6669da2fcb
parent 80 3c3dc6a148ca
child 85 44d9045b26ff
equal deleted inserted replaced
83:207c85fbef51 84:0f6669da2fcb
    38 #include <QByteArray>
    38 #include <QByteArray>
    39 #include <QTextStream>
    39 #include <QTextStream>
    40 #include <QFile>
    40 #include <QFile>
    41 #include "game.h"
    41 #include "game.h"
    42 #include "hwconsts.h"
    42 #include "hwconsts.h"
    43 
    43 #include "gameconfig.h"
    44 HWGame::HWGame(int Resolution, bool Fullscreen)
    44 
    45 {
    45 HWGame::HWGame(GameConfig * config)
    46 	vid_Resolution = Resolution;
    46 {
    47 	vid_Fullscreen = Fullscreen;
    47 	this->config = config;
    48 	TeamCount = 0;
    48 	TeamCount = 0;
    49 	seed = "";
    49 	seed = "";
    50 	cfgdir.setPath(cfgdir.homePath());
       
    51 	cfgdir.cd(".hedgewars");
       
    52 }
    50 }
    53 
    51 
    54 void HWGame::NewConnection()
    52 void HWGame::NewConnection()
    55 {
    53 {
    56 	QTcpSocket * client = IPCServer->nextPendingConnection();
    54 	QTcpSocket * client = IPCServer->nextPendingConnection();
    90 	SENDIPC("TL");
    88 	SENDIPC("TL");
    91 	SENDIPC("e$gmflags 0");
    89 	SENDIPC("e$gmflags 0");
    92 	SENDIPC("eaddteam");
    90 	SENDIPC("eaddteam");
    93 	SendTeamConfig(0);
    91 	SendTeamConfig(0);
    94 	SENDIPC("ecolor 65535");
    92 	SENDIPC("ecolor 65535");
    95 	SENDIPC("eadd hh0 0");
    93 	SENDIPC("eadd hh0 1");
    96 	SENDIPC("eadd hh1 0");
    94 	SENDIPC("eadd hh1 1");
    97 	SENDIPC("eadd hh2 0");
    95 	SENDIPC("eadd hh2 1");
    98 	SENDIPC("eadd hh3 0");
    96 	SENDIPC("eadd hh3 1");
    99 	SENDIPC("eadd hh4 0");
    97 	SENDIPC("eadd hh4 1");
       
    98 	SENDIPC("eadd hh5 1");
       
    99 	SENDIPC("eadd hh6 1");
       
   100 	SENDIPC("eadd hh7 1");
   100 	SENDIPC("eaddteam");
   101 	SENDIPC("eaddteam");
   101 	SendTeamConfig(1);
   102 	SendTeamConfig(1);
   102 	SENDIPC("ecolor 16776960");
   103 	SENDIPC("ecolor 16776960");
   103 	SENDIPC("eadd hh0 1");
   104 	SENDIPC("eadd hh0 1");
   104 	SENDIPC("eadd hh1 1");
   105 	SENDIPC("eadd hh1 1");
   105 	SENDIPC("eadd hh2 1");
   106 	SENDIPC("eadd hh2 1");
   106 	SENDIPC("eadd hh3 1");
   107 	SENDIPC("eadd hh3 1");
   107 	SENDIPC("eadd hh4 1");
   108 	SENDIPC("eadd hh4 1");
       
   109 	SENDIPC("eadd hh5 1");
       
   110 	SENDIPC("eadd hh6 1");
       
   111 	SENDIPC("eadd hh7 1");
       
   112 	SENDIPC("eaddteam");
       
   113 	SendTeamConfig(1);
       
   114 	SENDIPC("ecolor 255");
       
   115 	SENDIPC("eadd hh0 1");
       
   116 	SENDIPC("eadd hh1 1");
       
   117 	SENDIPC("eadd hh2 1");
       
   118 	SENDIPC("eadd hh3 1");
       
   119 	SENDIPC("eadd hh4 1");
       
   120 	SENDIPC("eadd hh5 1");
       
   121 	SENDIPC("eadd hh6 1");
       
   122 	SENDIPC("eadd hh7 1");
   108 }
   123 }
   109 
   124 
   110 void HWGame::ParseMessage(const QByteArray & msg)
   125 void HWGame::ParseMessage(const QByteArray & msg)
   111 {
   126 {
   112 	switch(msg.data()[1])
   127 	switch(msg.data()[1])
   231 
   246 
   232 	demo = new QByteArray;
   247 	demo = new QByteArray;
   233 	QProcess * process;
   248 	QProcess * process;
   234 	QStringList arguments;
   249 	QStringList arguments;
   235 	process = new QProcess;
   250 	process = new QProcess;
   236 	arguments << resolutions[0][vid_Resolution];
   251 	arguments << resolutions[0][config->vid_Resolution()];
   237 	arguments << resolutions[1][vid_Resolution];
   252 	arguments << resolutions[1][config->vid_Resolution()];
   238 	arguments << "16";
   253 	arguments << "16";
   239 	arguments << "46631";
   254 	arguments << "46631";
   240 	arguments << (vid_Fullscreen ? "1" : "0");
   255 	arguments << (config->vid_Fullscreen() ? "1" : "0");
   241 	arguments << "1";
   256 	arguments << (config->isSoundEnabled() ? "1" : "0");
   242 	arguments << tr("en.txt");
   257 	arguments << tr("en.txt");
   243 	process->start("./hwengine", arguments);
   258 	process->start("./hwengine", arguments);
   244 }
   259 }
   245 
   260 
   246 void HWGame::AddTeam(const QString & teamname)
   261 void HWGame::AddTeam(const QString & teamname)
   345 	Start();
   360 	Start();
   346 }
   361 }
   347 
   362 
   348 void HWGame::LocalCFG(const QString & teamname)
   363 void HWGame::LocalCFG(const QString & teamname)
   349 {
   364 {
   350 	QFile teamcfg(cfgdir.absolutePath() + "/" + teamname + ".cfg");
   365 	QFile teamcfg(config->cfgdir.absolutePath() + "/" + teamname + ".cfg");
   351 	if (!teamcfg.open(QIODevice::ReadOnly))
   366 	if (!teamcfg.open(QIODevice::ReadOnly))
   352 	{
   367 	{
   353 		return ;
   368 		return ;
   354 	}
   369 	}
   355 	QTextStream stream(&teamcfg);
   370 	QTextStream stream(&teamcfg);