8 players

This commit is contained in:
Titus Tscharntke 2010-02-28 11:21:01 +00:00
parent 59faabfe14
commit 5cb8aca19c
11 changed files with 90 additions and 45 deletions

View File

@ -1,7 +1,7 @@
// ==============================================================
// This file is part of Glest (www.glest.org)
//
// Copyright (C) 2001-2008 Martiño Figueroa
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
@ -30,7 +30,7 @@ enum ControlType{
class GameConstants{
public:
static const int maxPlayers= 4;
static const int maxPlayers= 8;
static const int serverPort= 61357;
static const int updateFps= 40;
static const int cameraFps= 100;

View File

@ -1,7 +1,7 @@
// ==============================================================
// This file is part of Glest (www.glest.org)
//
// Copyright (C) 2001-2008 Martiño Figueroa
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
@ -60,12 +60,12 @@ void BattleEnd::render(){
textRenderer->begin(CoreData::getInstance().getMenuFontBig());
int lm= 80;
int lm= 20;
int bm= 100;
for(int i=0; i<stats.getFactionCount(); ++i){
int textX= lm+300+i*120;
int textX= lm+120+i*110;
int team= stats.getTeam(i) + 1;
int kills= stats.getKills(i);
int deaths= stats.getDeaths(i);
@ -110,15 +110,15 @@ void BattleEnd::render(){
textRenderer->render(intToStr(score).c_str(), textX, bm+20);
}
textRenderer->render(lang.get("Result"), lm+50, bm+360);
textRenderer->render(lang.get("Control"), lm+50, bm+320);
textRenderer->render(lang.get("Faction"), lm+50, bm+280);
textRenderer->render(lang.get("Team"), lm+50, bm+240);
textRenderer->render(lang.get("Kills"), lm+50, bm+200);
textRenderer->render(lang.get("Deaths"), lm+50, bm+160);
textRenderer->render(lang.get("UnitsProduced"), lm+50, bm+120);
textRenderer->render(lang.get("ResourcesHarvested"), lm+50, bm+80);
textRenderer->render(lang.get("Score"), lm+50, bm+20);
textRenderer->render(lang.get("Result"), lm, bm+360);
textRenderer->render(lang.get("Control"), lm, bm+320);
textRenderer->render(lang.get("Faction"), lm, bm+280);
textRenderer->render(lang.get("Team"), lm, bm+240);
textRenderer->render(lang.get("Kills"), lm, bm+200);
textRenderer->render(lang.get("Deaths"), lm, bm+160);
textRenderer->render(lang.get("UnitsProduced"), lm, bm+120);
textRenderer->render(lang.get("ResourcesHarvested"), lm, bm+80);
textRenderer->render(lang.get("Score"), lm, bm+20);
textRenderer->end();

View File

@ -1,7 +1,7 @@
// ==============================================================
// This file is part of Glest (www.glest.org)
//
// Copyright (C) 2001-2005 Martiño Figueroa
// Copyright (C) 2001-2005 Marti<EFBFBD>o Figueroa
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
@ -47,8 +47,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
vector<string> results, teamItems, controlItems;
//create
buttonReturn.init(350, 200, 125);
buttonPlayNow.init(525, 200, 125);
buttonReturn.init(350, 140, 125);
buttonPlayNow.init(525, 140, 125);
//map listBox
findAll("maps/*.gbm", results, true);
@ -59,10 +59,10 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
for(int i= 0; i<results.size(); ++i){
results[i]= formatString(results[i]);
}
listBoxMap.init(200, 320, 150);
listBoxMap.init(200, 260, 150);
listBoxMap.setItems(results);
labelMap.init(200, 350);
labelMapInfo.init(200, 290, 200, 40);
labelMap.init(200, 290);
labelMapInfo.init(200, 230, 200, 40);
//tileset listBox
findAll("tilesets/*.", results);
@ -73,9 +73,9 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
for(int i= 0; i<results.size(); ++i){
results[i]= formatString(results[i]);
}
listBoxTileset.init(400, 320, 150);
listBoxTileset.init(400, 260, 150);
listBoxTileset.setItems(results);
labelTileset.init(400, 350);
labelTileset.init(400, 290);
//tech Tree listBox
findAll("techs/*.", results);
@ -86,22 +86,22 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
for(int i= 0; i<results.size(); ++i){
results[i]= formatString(results[i]);
}
listBoxTechTree.init(600, 320, 150);
listBoxTechTree.init(600, 260, 150);
listBoxTechTree.setItems(results);
labelTechTree.init(600, 350);
labelTechTree.init(600, 290);
//list boxes
for(int i=0; i<GameConstants::maxPlayers; ++i){
labelPlayers[i].init(200, 500-i*30);
listBoxControls[i].init(300, 500-i*30);
listBoxFactions[i].init(500, 500-i*30);
listBoxTeams[i].init(700, 500-i*30, 60);
labelNetStatus[i].init(800, 500-i*30, 60);
labelPlayers[i].init(200, 550-i*30);
listBoxControls[i].init(300, 550-i*30);
listBoxFactions[i].init(500, 550-i*30);
listBoxTeams[i].init(700, 550-i*30, 60);
labelNetStatus[i].init(800, 550-i*30, 60);
}
labelControl.init(300, 550, GraphicListBox::defW, GraphicListBox::defH, true);
labelFaction.init(500, 550, GraphicListBox::defW, GraphicListBox::defH, true);
labelTeam.init(700, 550, 60, GraphicListBox::defH, true);
labelControl.init(300, 600, GraphicListBox::defW, GraphicListBox::defH, true);
labelFaction.init(500, 600, GraphicListBox::defW, GraphicListBox::defH, true);
labelTeam.init(700, 600, 60, GraphicListBox::defH, true);
//texts
buttonReturn.setText(lang.get("Return"));
@ -118,6 +118,10 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
teamItems.push_back("2");
teamItems.push_back("3");
teamItems.push_back("4");
teamItems.push_back("5");
teamItems.push_back("6");
teamItems.push_back("7");
teamItems.push_back("8");
reloadFactions();

View File

@ -132,6 +132,10 @@ MainWindow::MainWindow():
menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+2, wxT("2 - Player 2 "));
menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+3, wxT("3 - Player 3 "));
menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+4, wxT("4 - Player 4 "));
menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+5, wxT("5 - Player 5 "));
menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+6, wxT("6 - Player 6 "));
menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+7, wxT("7 - Player 7 "));
menuBrushStartLocation->AppendCheckItem(miBrushStartLocation+8, wxT("8 - Player 8 "));
menuBrush->Append(miBrushStartLocation, wxT("Player"), menuBrushStartLocation);
menuBar->Append(menuBrush, wxT("Brush"));
@ -145,6 +149,9 @@ MainWindow::MainWindow():
menuBar->Append(menuRadius, wxT("Radius"));
SetMenuBar(menuBar);
timer = new wxTimer(this);
timer->Start(50);
}
void MainWindow::init(){
@ -414,6 +421,11 @@ void MainWindow::onMenuRadius(wxCommandEvent &event){
radius= event.GetId() - miRadius + 1;
}
void MainWindow::onTimer(wxTimerEvent &event) {
wxPaintEvent paintEvent;
onPaint(paintEvent);
}
void MainWindow::change(int x, int y){
switch(enabledGroup){
case 0:
@ -459,6 +471,7 @@ void MainWindow::uncheckRadius(){
}
BEGIN_EVENT_TABLE(MainWindow, wxFrame)
EVT_TIMER(-1, MainWindow::onTimer)
EVT_CLOSE(MainWindow::onClose)
EVT_LEFT_DOWN(MainWindow::onMouseDown)
EVT_MOTION(MainWindow::onMouseMove)

View File

@ -32,7 +32,7 @@ private:
static const int surfaceCount= 5;
static const int objectCount= 11;
static const int resourceCount= 6;
static const int startLocationCount= 4;
static const int startLocationCount= 8;
static const int radiusCount= 9;
private:
@ -71,6 +71,8 @@ private:
Program *program;
int lastX, lastY;
wxTimer *timer;
wxMenuBar *menuBar;
wxMenu *menuFile;
wxMenu *menuEdit;
@ -131,6 +133,8 @@ public:
void onMenuBrushStartLocation(wxCommandEvent &event);
void onMenuRadius(wxCommandEvent &event);
void onTimer(wxTimerEvent &event);
void change(int x, int y);
void uncheckBrush();

View File

@ -320,8 +320,8 @@ void Map::resize(int w, int h, float alt, int surf){
}
void Map::resetPlayers(int maxPlayers){
if (maxPlayers<1 || maxPlayers>4){
throw runtime_error("Max Players must be in the range 1-4");
if (maxPlayers<1 || maxPlayers>8){
throw runtime_error("Max Players must be in the range 1-8");
return;
}

View File

@ -155,6 +155,10 @@ void Renderer::renderMap(Map *map, int x, int y, int clientW, int clientH, int c
case 1: glColor3f(0.f, 0.f, 1.f); break;
case 2: glColor3f(0.f, 1.f, 0.f); break;
case 3: glColor3f(1.f, 1.f, 0.f); break;
case 4: glColor3f(1.f, 1.f, 1.f); break;
case 5: glColor3f(0.f, 1.f, 0.8f); break;
case 6: glColor3f(1.f, 0.8f, 0.f); break;
case 7: glColor3f(1.f, 0.8f, 1.f); break;
}
glBegin(GL_LINES);
glVertex2i((map->getStartLocationX(i)-1)*cellSize, clientH- (map->getStartLocationY(i)-1)*cellSize);

View File

@ -38,7 +38,8 @@ private:
public:
Ip();
Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned char byte3);
Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned char byte3,
unsigned char byte4, unsigned char byte5, unsigned char byte6, unsigned char byte7);
Ip(const string& ipString);
unsigned char getByte(int byteIndex) {return bytes[byteIndex];}

View File

@ -1,7 +1,7 @@
// ==============================================================
// This file is part of Glest Shared Library (www.glest.org)
//
// Copyright (C) 2001-2008 Martiño Figueroa
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
@ -32,7 +32,8 @@ private:
public:
Ip();
Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned char byte3);
Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned char byte3,
unsigned char byte4, unsigned char byte5, unsigned char byte6, unsigned char byte7);
Ip(const string& ipString);
unsigned char getByte(int byteIndex) {return bytes[byteIndex];}

View File

@ -39,13 +39,22 @@ Ip::Ip(){
bytes[1]= 0;
bytes[2]= 0;
bytes[3]= 0;
bytes[4]= 0;
bytes[5]= 0;
bytes[6]= 0;
bytes[7]= 0;
}
Ip::Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned char byte3){
Ip::Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned char byte3,
unsigned char byte4, unsigned char byte5, unsigned char byte6, unsigned char byte7){
bytes[0]= byte0;
bytes[1]= byte1;
bytes[2]= byte2;
bytes[3]= byte3;
bytes[4]= byte4;
bytes[5]= byte5;
bytes[6]= byte6;
bytes[7]= byte7;
}
@ -53,7 +62,7 @@ Ip::Ip(const string& ipString){
int offset= 0;
int byteIndex= 0;
for(byteIndex= 0; byteIndex<4; ++byteIndex){
for(byteIndex= 0; byteIndex<8; ++byteIndex){
int dotPos= ipString.find_first_of('.', offset);
bytes[byteIndex]= atoi(ipString.substr(offset, dotPos-offset).c_str());

View File

@ -1,7 +1,7 @@
// ==============================================================
// This file is part of Glest Shared Library (www.glest.org)
//
// Copyright (C) 2001-2007 Martiño Figueroa
// Copyright (C) 2001-2007 Marti<EFBFBD>o Figueroa
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
@ -165,21 +165,29 @@ Ip::Ip(){
bytes[1]= 0;
bytes[2]= 0;
bytes[3]= 0;
bytes[4]= 4;
bytes[5]= 5;
bytes[6]= 6;
bytes[7]= 7;
}
Ip::Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned char byte3){
Ip::Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned char byte3,
unsigned char byte4, unsigned char byte5, unsigned char byte6, unsigned char byte7){
bytes[0]= byte0;
bytes[1]= byte1;
bytes[2]= byte2;
bytes[3]= byte3;
bytes[4]= byte4;
bytes[5]= byte5;
bytes[6]= byte6;
bytes[7]= byte7;
}
Ip::Ip(const string& ipString){
int offset= 0;
int byteIndex= 0;
for(byteIndex= 0; byteIndex<4; ++byteIndex){
for(byteIndex= 0; byteIndex<8; ++byteIndex){
int dotPos= ipString.find_first_of('.', offset);
bytes[byteIndex]= atoi(ipString.substr(offset, dotPos-offset).c_str());
@ -188,7 +196,8 @@ Ip::Ip(const string& ipString){
}
string Ip::getString() const{
return intToStr(bytes[0]) + "." + intToStr(bytes[1]) + "." + intToStr(bytes[2]) + "." + intToStr(bytes[3]);
return intToStr(bytes[0]) + "." + intToStr(bytes[1]) + "." + intToStr(bytes[2]) + "." + intToStr(bytes[3])
+ "." +intToStr(bytes[4]) + "." + intToStr(bytes[5]) + "." + intToStr(bytes[6]) + "." + intToStr(bytes[7]);
}
// =====================================================