- make the game be run from ${PREFIX}/bin with data in ${PREFIX}/share/hedgewars/Data
- fix build
--- a/QTfrontend/game.cpp Sun Aug 06 15:47:20 2006 +0000
+++ b/QTfrontend/game.cpp Sun Aug 06 15:48:48 2006 +0000
@@ -97,7 +97,7 @@
SENDIPC("eadd hh2 0");
SENDIPC("eadd hh3 0");
SENDIPC("eaddteam");
- LocalCFG(1);
+ LocalCFG(2);
SENDIPC("ecolor 16776960");
SENDIPC("eadd hh0 1");
SENDIPC("eadd hh1 1");
@@ -238,7 +238,7 @@
arguments << (config->vid_Fullscreen() ? "1" : "0");
arguments << (config->isSoundEnabled() ? "1" : "0");
arguments << tr("en.txt");
- process->start("./hwengine", arguments);
+ process->start(bindir->absolutePath() + "/hwengine", arguments);
}
void HWGame::AddTeam(const QString & teamname)
@@ -250,7 +250,7 @@
QString HWGame::GetThemeBySeed()
{
- QFile themesfile(QString(DATA_PATH) + "/Themes/themes.cfg");
+ QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg");
QStringList themes;
if (themesfile.open(QIODevice::ReadOnly))
{
@@ -327,10 +327,9 @@
Start();
}
-void HWGame::StartNet(const QString & netseed)
+void HWGame::StartNet()
{
gameType = gtNet;
- seed = netseed;
demo = new QByteArray;
Start();
}
--- a/QTfrontend/game.h Sun Aug 06 15:47:20 2006 +0000
+++ b/QTfrontend/game.h Sun Aug 06 15:48:48 2006 +0000
@@ -59,7 +59,7 @@
void PlayDemo(const QString & demofilename);
void StartLocal();
void StartQuick();
- void StartNet(const QString & netseed);
+ void StartNet();
signals:
void SendNet(const QByteArray & msg);
--- a/QTfrontend/gameuiconfig.cpp Sun Aug 06 15:47:20 2006 +0000
+++ b/QTfrontend/gameuiconfig.cpp Sun Aug 06 15:48:48 2006 +0000
@@ -36,27 +36,14 @@
#include "gameuiconfig.h"
#include "hwform.h"
#include "pages.h"
+#include "hwconsts.h"
GameUIConfig::GameUIConfig(HWForm * FormWidgets)
: QObject()
{
Form = FormWidgets;
- cfgdir.setPath(cfgdir.homePath());
- if (!cfgdir.exists(".hedgewars"))
- {
- if (!cfgdir.mkdir(".hedgewars"))
- {
- QMessageBox::critical(0,
- tr("Error"),
- tr("Cannot create directory %1").arg("/.hedgewars"),
- tr("Quit"));
- return ;
- }
- }
- cfgdir.cd(".hedgewars");
-
- QFile settings(cfgdir.absolutePath() + "/options");
+ QFile settings(cfgdir->absolutePath() + "/options");
if (settings.open(QIODevice::ReadOnly))
{
QTextStream stream(&settings);
@@ -90,12 +77,12 @@
QStringList GameUIConfig::GetTeamsList()
{
- return cfgdir.entryList(QStringList("*.cfg"));
+ return cfgdir->entryList(QStringList("*.cfg"));
}
void GameUIConfig::SaveOptions()
{
- QFile settings(cfgdir.absolutePath() + "/options");
+ QFile settings(cfgdir->absolutePath() + "/options");
if (!settings.open(QIODevice::WriteOnly))
{
QMessageBox::critical(0,
--- a/QTfrontend/gameuiconfig.h Sun Aug 06 15:47:20 2006 +0000
+++ b/QTfrontend/gameuiconfig.h Sun Aug 06 15:48:48 2006 +0000
@@ -47,7 +47,6 @@
public:
GameUIConfig(HWForm * FormWidgets);
QStringList GetTeamsList();
- QDir cfgdir;
int vid_Resolution();
bool vid_Fullscreen();
bool isSoundEnabled();
--- a/QTfrontend/hedgewars.pro Sun Aug 06 15:47:20 2006 +0000
+++ b/QTfrontend/hedgewars.pro Sun Aug 06 15:48:48 2006 +0000
@@ -2,7 +2,7 @@
TARGET = hedgewars
DEPENDPATH += .
INCLUDEPATH += .
-DESTDIR = ../hedgewars
+DESTDIR = ../bin
win32 {
RC_FILE = ./res/hedgewars.rc
--- a/QTfrontend/hwconsts.h Sun Aug 06 15:47:20 2006 +0000
+++ b/QTfrontend/hwconsts.h Sun Aug 06 15:48:48 2006 +0000
@@ -31,10 +31,14 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-const char resolutions[2][4][5] =
+#include <QDir>
+
+const char resolutions[2][4][5] =
{
{"640", "800", "1024", "1280"},
{"480", "600", "768", "1024"}
};
-#define DATA_PATH "Data"
+extern QDir * cfgdir;
+extern QDir * datadir;
+extern QDir * bindir;
--- a/QTfrontend/hwform.cpp Sun Aug 06 15:47:20 2006 +0000
+++ b/QTfrontend/hwform.cpp Sun Aug 06 15:48:48 2006 +0000
@@ -132,7 +132,7 @@
void HWForm::GoToDemos()
{
QDir tmpdir;
- tmpdir.cd(DATA_PATH);
+ tmpdir.cd(datadir->absolutePath());
tmpdir.cd("Demos");
tmpdir.setFilter(QDir::Files);
ui.pagePlayDemo->DemosList->clear();
@@ -196,7 +196,7 @@
return ;
}
game = new HWGame(config, 0);
- game->PlayDemo(QString(DATA_PATH) + "/Demos/" + curritem->text() + ".hwd_1");
+ game->PlayDemo(datadir->absolutePath() + "/Demos/" + curritem->text() + ".hwd_1");
}
void HWForm::NetConnect()
--- a/QTfrontend/main.cpp Sun Aug 06 15:47:20 2006 +0000
+++ b/QTfrontend/main.cpp Sun Aug 06 15:48:48 2006 +0000
@@ -34,19 +34,46 @@
#include <QApplication>
#include <QTranslator>
#include <QLocale>
+#include <QMessageBox>
+#include <QFileInfo>
#include "hwform.h"
+#include "hwconsts.h"
+
+QDir * bindir;
+QDir * cfgdir;
+QDir * datadir;
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
+ QDir mydir = QFileInfo(argv[0]).dir();
+ bindir = new QDir(mydir);
+ cfgdir = new QDir();
+
+ cfgdir->setPath(cfgdir->homePath());
+ if (!cfgdir->exists(".hedgewars"))
+ {
+ if (!cfgdir->mkdir(".hedgewars"))
+ {
+ QMessageBox::critical(0,
+ QObject::tr("Error"),
+ QObject::tr("Cannot create directory %1").arg("/.hedgewars"),
+ QObject::tr("Quit"));
+ }
+ }
+ cfgdir->cd(".hedgewars");
+
+ datadir = new QDir(mydir);
+ datadir->cd("../share/hedgewars/Data");
+
Q_INIT_RESOURCE(hedgewars);
QTranslator Translator;
Translator.load(":/translations/hedgewars_" + QLocale::system().name());
app.installTranslator(&Translator);
- HWForm *Form = new HWForm;
+ HWForm *Form = new HWForm();
Form->show();
return app.exec();
}
--- a/QTfrontend/netclient.cpp Sun Aug 06 15:47:20 2006 +0000
+++ b/QTfrontend/netclient.cpp Sun Aug 06 15:48:48 2006 +0000
@@ -140,7 +140,7 @@
void HWNet::RawSendNet(const QString & str)
{
- RawSendNet(str.toLatin1());
+ RawSendNet(str.toUtf8());
}
void HWNet::RawSendNet(const QByteArray & buf)
@@ -262,6 +262,7 @@
case 432 : // ERR_ERRONEUSNICKNAME
case 433 : // ERR_NICKNAMEINUSE
{
+ QMessageBox::information(0, "Your net nickname is in use or cannot be used", msg);
// ask for another nick
}
}
@@ -352,6 +353,22 @@
if (configasks == playerscnt)
{
quint32 color = 65535;
+ #define ADD(a) { \
+ QByteArray strmsg; \
+ strmsg.append(a); \
+ quint8 sz = strmsg.size(); \
+ cache.append(QByteArray((char *)&sz, 1)); \
+ cache.append(strmsg); \
+ }
+ {
+ QByteArray cache;
+ ADD("eseed " + seed);
+ ADD("e$gmflags 0");
+ ADD("etheme steel");
+ QString _msg = MAGIC_CHAR MAGIC_CHAR + QString(cache.toBase64());
+ RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, _msg));
+ hwp_chanmsg(mynick, _msg);
+ }
for (int i = 0; i < teamsCount; i++)
{
QString msg;
@@ -359,13 +376,6 @@
RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, msg));
hwp_chanmsg(mynick, msg);
QByteArray cache;
- #define ADD(a) { \
- QByteArray strmsg; \
- strmsg.append(a); \
- quint8 sz = strmsg.size(); \
- cache.append(QByteArray((char *)&sz, 1)); \
- cache.append(strmsg); \
- }
ADD(QString("ecolor %1").arg(color));
ADD("eadd hh0 0");
ADD("eadd hh1 0");
@@ -374,8 +384,8 @@
ADD("eadd hh4 0");
#undef ADD
QString _msg = MAGIC_CHAR MAGIC_CHAR + QString(cache.toBase64());
+ RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, _msg));
hwp_chanmsg(mynick, _msg);
- RawSendNet(QString("PRIVMSG %1 :").arg(channel) + _msg);
color <<= 8;
}
SENDCFGSTRNET("!");
@@ -390,10 +400,10 @@
}
if (state == nsJoined)
{
- if (msg.startsWith(MAGIC_CHAR"Start!"MAGIC_CHAR) && (who == opnick))
+ if (msg.startsWith(MAGIC_CHAR"Start!") && (who == opnick))
{
state = nsStarting;
- RunGame(msg.mid(8));
+ RunGame();
return ;
}
if (msg.startsWith(MAGIC_CHAR"="MAGIC_CHAR) && (who == opnick))
@@ -426,7 +436,7 @@
}
if (msg.startsWith(MAGIC_CHAR MAGIC_CHAR)) // HWP message
{
- QByteArray em = QByteArray::fromBase64(msg.mid(2).toLocal8Bit());
+ QByteArray em = QByteArray::fromBase64(msg.mid(2).toAscii());
emit FromNet(em);
} else // smth other
{
@@ -483,18 +493,17 @@
playerscnt = players.size();
configasks = 0;
- QString seed;
seedgen.GenRNDStr(seed, 10);
- QString msg = QString(MAGIC_CHAR"Start!"MAGIC_CHAR"%1").arg(seed);
+ QString msg = QString(MAGIC_CHAR"Start!");
RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, msg));
hwp_chanmsg(mynick, msg);
}
-void HWNet::RunGame(const QString & seed)
+void HWNet::RunGame()
{
HWGame * game = new HWGame(config, 0);
connect(game, SIGNAL(SendNet(const QByteArray &)), this, SLOT(SendNet(const QByteArray &)));
connect(this, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &)));
connect(this, SIGNAL(LocalCFG(const QString &)), game, SLOT(LocalCFG(const QString &)));
- game->StartNet(seed);
+ game->StartNet();
}
--- a/QTfrontend/netclient.h Sun Aug 06 15:47:20 2006 +0000
+++ b/QTfrontend/netclient.h Sun Aug 06 15:48:48 2006 +0000
@@ -42,7 +42,7 @@
#include "team.h"
#include "rndstr.h"
-#define MAGIC_CHAR "\x02"
+#define MAGIC_CHAR "\x2f"
struct netTeam
{
@@ -97,6 +97,7 @@
QString mynick;
QString opnick;
QString channel;
+ QString seed;
bool isOp;
quint32 opCount;
netTeam teams[5];
@@ -123,7 +124,7 @@
void ConfigAsked();
void NetTeamAdded(const QString & msg);
- void RunGame(const QString & seed);
+ void RunGame();
private slots:
--- a/QTfrontend/pages.cpp Sun Aug 06 15:47:20 2006 +0000
+++ b/QTfrontend/pages.cpp Sun Aug 06 15:48:48 2006 +0000
@@ -221,7 +221,7 @@
QDir tmpdir;
- tmpdir.cd(DATA_PATH);
+ tmpdir.cd(datadir->absolutePath());
tmpdir.cd("Forts");
tmpdir.setFilter(QDir::Files);
@@ -239,13 +239,13 @@
void PageEditTeam::CBGrave_activated(const QString & gravename)
{
- QPixmap pix(QString(DATA_PATH) + "/Graphics/Graves/" + gravename + ".png");
+ QPixmap pix(datadir->absolutePath() + "/Graphics/Graves/" + gravename + ".png");
GravePreview->setPixmap(pix.copy(0, 0, 32, 32));
}
void PageEditTeam::CBFort_activated(const QString & fortname)
{
- QPixmap pix(QString(DATA_PATH) + "/Forts/" + fortname + "L.png");
+ QPixmap pix(datadir->absolutePath() + "/Forts/" + fortname + "L.png");
FortPreview->setPixmap(pix);
}
--- a/QTfrontend/predefteams.h Sun Aug 06 15:47:20 2006 +0000
+++ b/QTfrontend/predefteams.h Sun Aug 06 15:48:48 2006 +0000
@@ -36,19 +36,19 @@
#include <QtGlobal>
-#define PREDEFTEAMS_COUNT 2
+#define PREDEFTEAMS_COUNT 3
struct PredefinedTeam
{
const char * TeamName;
const char * hh0name;
const char * hh1name;
- const char * hh2name;
- const char * hh3name;
- const char * hh4name;
- const char * hh5name;
- const char * hh6name;
- const char * hh7name;
+ const char * hh2name;
+ const char * hh3name;
+ const char * hh4name;
+ const char * hh5name;
+ const char * hh6name;
+ const char * hh7name;
QString Grave;
QString Fort;
};
@@ -79,6 +79,18 @@
QT_TRANSLATE_NOOP("teams", "Kali"),
QT_TRANSLATE_NOOP("teams", "Inanna"),
"Bone", "Island"
+ },
+ {
+ QT_TRANSLATE_NOOP("teams", "Fruits"),
+ QT_TRANSLATE_NOOP("teams", "Banana"),
+ QT_TRANSLATE_NOOP("teams", "Apple"),
+ QT_TRANSLATE_NOOP("teams", "Orange"),
+ QT_TRANSLATE_NOOP("teams", "Lemon"),
+ QT_TRANSLATE_NOOP("teams", "Pineapple"),
+ QT_TRANSLATE_NOOP("teams", "Mango"),
+ QT_TRANSLATE_NOOP("teams", "Peach"),
+ QT_TRANSLATE_NOOP("teams", "Plum"),
+ "coffin", "Barrelhouse"
}
};
--- a/QTfrontend/team.cpp Sun Aug 06 15:47:20 2006 +0000
+++ b/QTfrontend/team.cpp Sun Aug 06 15:48:48 2006 +0000
@@ -39,6 +39,7 @@
#include "gameuiconfig.h"
#include "predefteams.h"
#include "pages.h"
+#include "hwconsts.h"
HWTeam::HWTeam(const QString & teamname, GameUIConfig * config)
{
@@ -79,7 +80,7 @@
bool HWTeam::LoadFromFile()
{
- QFile cfgfile(config->cfgdir.absolutePath() + "/" + TeamName + ".cfg");
+ QFile cfgfile(cfgdir->absolutePath() + "/" + TeamName + ".cfg");
if (!cfgfile.open(QIODevice::ReadOnly)) return false;
QTextStream stream(&cfgfile);
stream.setCodec("UTF-8");
@@ -133,7 +134,7 @@
bool HWTeam::SaveToFile()
{
- QFile cfgfile(config->cfgdir.absolutePath() + "/" + TeamName + ".cfg");
+ QFile cfgfile(cfgdir->absolutePath() + "/" + TeamName + ".cfg");
if (!cfgfile.open(QIODevice::WriteOnly)) return false;
QTextStream stream(&cfgfile);
stream.setCodec("UTF-8");
Binary file QTfrontend/translations/hedgewars_ru.qm has changed
--- a/QTfrontend/translations/hedgewars_ru.ts Sun Aug 06 15:47:20 2006 +0000
+++ b/QTfrontend/translations/hedgewars_ru.ts Sun Aug 06 15:48:48 2006 +0000
@@ -112,6 +112,14 @@
<source>Teams</source>
<translation>Команды</translation>
</message>
+ <message>
+ <source>Audio/Graphic options</source>
+ <translation>Настройки звука и графики</translation>
+ </message>
+ <message>
+ <source>Net nick</source>
+ <translation>Имя игрока</translation>
+ </message>
</context>
<context>
<name>QLabel</name>
@@ -401,5 +409,41 @@
<source>Inanna</source>
<translation>Инанна</translation>
</message>
+ <message>
+ <source>Fruits</source>
+ <translation>Фрукты</translation>
+ </message>
+ <message>
+ <source>Banana</source>
+ <translation>Банан</translation>
+ </message>
+ <message>
+ <source>Apple</source>
+ <translation>Яблоко</translation>
+ </message>
+ <message>
+ <source>Orange</source>
+ <translation>Апельсин</translation>
+ </message>
+ <message>
+ <source>Lemon</source>
+ <translation>Лимон</translation>
+ </message>
+ <message>
+ <source>Pineapple</source>
+ <translation>Ананас</translation>
+ </message>
+ <message>
+ <source>Mango</source>
+ <translation>Манго</translation>
+ </message>
+ <message>
+ <source>Peach</source>
+ <translation>Персик</translation>
+ </message>
+ <message>
+ <source>Plum</source>
+ <translation>Слива</translation>
+ </message>
</context>
</TS>
--- a/hedgewars/hwengine.dpr Sun Aug 06 15:47:20 2006 +0000
+++ b/hedgewars/hwengine.dpr Sun Aug 06 15:48:48 2006 +0000
@@ -163,9 +163,24 @@
////////////////////
procedure GetParams;
var c: integer;
+ i: integer;
+ p: TPathType;
+begin
+PathPrefix:= ParamStr(0);
+for i:= 1 to Length(PathPrefix) do
+ if PathPrefix[i] = '\' then PathPrefix[i]:= '/';
+i:= Length(PathPrefix);
+while (i > 0) and not (PathPrefix[i] = '/') do dec(i);
+Delete(PathPrefix, i, Length(PathPrefix) - i + 1);
+dec(i);
+while (i > 0) and not (PathPrefix[i] = '/') do dec(i);
+Delete(PathPrefix, i, Length(PathPrefix) - i + 1);
+PathPrefix:= PathPrefix + '/share/hedgewars/';
+for p:= Low(TPathType) to High(TPathType) do
+ if p <> ptMapCurrent then Pathz[p]:= PathPrefix + Pathz[p];
+
{$IFDEF DEBUGFILE}
- i: integer;
-begin
+AddFileLog('Prefix: "' + PathPrefix +'"');
for i:= 0 to ParamCount do
AddFileLog(inttostr(i) + ': ' + ParamStr(i));
{$ELSE}
@@ -181,7 +196,7 @@
cFullScreen:= ParamStr(5) = '1';
isSoundEnabled:= ParamStr(6) = '1';
cLocaleFName:= ParamStr(7);
- end else OutError(errmsgShouldntRun, true);
+ end else OutError(errmsgShouldntRun, true)
end;
procedure ShowMainWindow;
--- a/hedgewars/uConsts.pas Sun Aug 06 15:47:20 2006 +0000
+++ b/hedgewars/uConsts.pas Sun Aug 06 15:48:48 2006 +0000
@@ -119,6 +119,8 @@
cKeyMaxIndex = 322;
+ cMaxCaptions = 4;
+
cInactDelay = 1500;
gfForts = $00000001;
@@ -179,6 +181,7 @@
Name: 'DejaVuSans.ttf')
);
+ PathPrefix: shortstring = './';
Pathz: array[TPathType] of string[ 64] = (
'', // ptNone
'Data', // ptData
--- a/hedgewars/uSound.pas Sun Aug 06 15:47:20 2006 +0000
+++ b/hedgewars/uSound.pas Sun Aug 06 15:48:48 2006 +0000
@@ -84,7 +84,7 @@
WriteLnToConsole(msgOK);
end;
-s:= 'Data/Music/kahvi140a_alexander_chereshnev-illusion.ogg';
+s:= PathPrefix + 'Data/Music/kahvi140a_alexander_chereshnev-illusion.ogg';
WriteToConsole(msgLoading + s + ' ');
Mus:= Mix_LoadMUS(PChar(s));
TryDo(Mus <> nil, msgFailed, false);
--- a/hedgewars/uStore.pas Sun Aug 06 15:47:20 2006 +0000
+++ b/hedgewars/uStore.pas Sun Aug 06 15:48:48 2006 +0000
@@ -468,10 +468,8 @@
begin
if Step = 0 then
begin
- WriteToConsole(msgLoading + 'progress sprite... ');
- ProgrSurf:= IMG_Load(PChar(string('Data/Graphics/BigDigits.png')));
- SDLTry(ProgrSurf <> nil, true);
- WriteLnToConsole(msgOK)
+ WriteToConsole(msgLoading + 'progress sprite: ');
+ ProgrSurf:= LoadImage(Pathz[ptGraphics] + '/BigDigits', false);
end;
SDL_FillRect(SDLPrimSurface, nil, 0);
r.x:= 0;
--- a/hedgewars/uWorld.pas Sun Aug 06 15:47:20 2006 +0000
+++ b/hedgewars/uWorld.pas Sun Aug 06 15:48:48 2006 +0000
@@ -60,11 +60,12 @@
type TCaptionStr = record
Surf: PSDL_Surface;
StorePos: Longword;
+ Group: TCapGroup;
EndTime: LongWord;
end;
var cWaterSprCount: integer;
- Captions: array[TCapGroup] of TCaptionStr;
+ Captions: array[0..Pred(cMaxCaptions)] of TCaptionStr;
procedure InitWorld;
begin