- added support for team unit sharing
This commit is contained in:
parent
338f156a95
commit
e63b3d7499
|
@ -10,6 +10,6 @@ CPUS=`lscpu -p | grep -cv '^#'`
|
||||||
if [ "$CPUS" = '' ]; then CPUS=1; fi
|
if [ "$CPUS" = '' ]; then CPUS=1; fi
|
||||||
|
|
||||||
#~/cppcheck-1.62/cppcheck ../../source/ -i ../../source/win32_deps -i ../../source/configurator -i ../../source/shared_lib/sources/libircclient -i ../../source/shared_lib/sources/platform/miniupnpc -j $CPUS --enable=all --force --verbose 2> $OUTFILE
|
#~/cppcheck-1.62/cppcheck ../../source/ -i ../../source/win32_deps -i ../../source/configurator -i ../../source/shared_lib/sources/libircclient -i ../../source/shared_lib/sources/platform/miniupnpc -j $CPUS --enable=all --force --verbose 2> $OUTFILE
|
||||||
cppcheck ../../source/ -i ../../source/win32_deps -i ../../source/configurator -i ../../source/shared_lib/sources/libircclient -i ../../source/shared_lib/sources/platform/miniupnpc -j $CPUS --enable=all --force --verbose 2> $OUTFILE
|
cppcheck ../../source/ -i ../../source/win32_deps -i ../../source/configurator -i ../../source/shared_lib/sources/libircclient -i ../../source/shared_lib/sources/platform/miniupnpc -i ../../source/shared_lib/sources/streflop -j $CPUS --enable=all --force --verbose 2> $OUTFILE
|
||||||
|
|
||||||
echo "Results from cppcheck were written to $OUTFILE"
|
echo "Results from cppcheck were written to $OUTFILE"
|
||||||
|
|
|
@ -620,6 +620,7 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const {
|
||||||
gameNetworkInterface->sendTextMessage(szMsg,-1, localEcho,languageList[i]);
|
gameNetworkInterface->sendTextMessage(szMsg,-1, localEcho,languageList[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
world->getGame()->reInitGUI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -713,6 +714,7 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const {
|
||||||
gameNetworkInterface->sendTextMessage(szMsg,-1, localEcho,languageList[i]);
|
gameNetworkInterface->sendTextMessage(szMsg,-1, localEcho,languageList[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
world->getGame()->reInitGUI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(newTeamTotalMemberCount == (newTeamVotedYes + newTeamVotedNo)) {
|
else if(newTeamTotalMemberCount == (newTeamVotedYes + newTeamVotedNo)) {
|
||||||
|
|
|
@ -1622,6 +1622,10 @@ void Game::init(bool initForPreviewOnly) {
|
||||||
|
|
||||||
// ==================== update ====================
|
// ==================== update ====================
|
||||||
|
|
||||||
|
void Game::reInitGUI() {
|
||||||
|
gui.init(this);
|
||||||
|
}
|
||||||
|
|
||||||
void Game::setupPopupMenus(bool checkClientAdminOverrideOnly) {
|
void Game::setupPopupMenus(bool checkClientAdminOverrideOnly) {
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
|
|
|
@ -223,6 +223,8 @@ public:
|
||||||
Game(Program *program, const GameSettings *gameSettings, bool masterserverMode);
|
Game(Program *program, const GameSettings *gameSettings, bool masterserverMode);
|
||||||
~Game();
|
~Game();
|
||||||
|
|
||||||
|
void reInitGUI();
|
||||||
|
|
||||||
bool isMarkCellMode() const { return isMarkCellEnabled; }
|
bool isMarkCellMode() const { return isMarkCellEnabled; }
|
||||||
const Texture2D * getMarkCellTexture() const { return markCellTexture; }
|
const Texture2D * getMarkCellTexture() const { return markCellTexture; }
|
||||||
bool isUnMarkCellMode() const { return isUnMarkCellEnabled; }
|
bool isUnMarkCellMode() const { return isUnMarkCellEnabled; }
|
||||||
|
|
|
@ -1,14 +1,3 @@
|
||||||
#ifndef _GLEST_GAME_GAMECONSTANTS_H_
|
|
||||||
#define _GLEST_GAME_GAMECONSTANTS_H_
|
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "vec.h"
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
#include "conversion.h"
|
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest (www.glest.org)
|
// This file is part of Glest (www.glest.org)
|
||||||
//
|
//
|
||||||
|
@ -20,6 +9,17 @@
|
||||||
// License, or (at your option) any later version
|
// License, or (at your option) any later version
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
|
|
||||||
|
#ifndef _GLEST_GAME_GAMECONSTANTS_H_
|
||||||
|
#define _GLEST_GAME_GAMECONSTANTS_H_
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "vec.h"
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include "conversion.h"
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
using namespace Shared::Graphics;
|
using namespace Shared::Graphics;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Shared::Util;
|
using namespace Shared::Util;
|
||||||
|
@ -115,30 +115,27 @@ enum FactionPersonalityType {
|
||||||
|
|
||||||
enum MasterServerGameStatusType {
|
enum MasterServerGameStatusType {
|
||||||
game_status_waiting_for_players = 0,
|
game_status_waiting_for_players = 0,
|
||||||
game_status_waiting_for_start = 1,
|
game_status_waiting_for_start = 1,
|
||||||
game_status_in_progress = 2,
|
game_status_in_progress = 2,
|
||||||
game_status_finished = 3
|
game_status_finished = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
class GameConstants {
|
class GameConstants {
|
||||||
public:
|
public:
|
||||||
static const int specialFactions = fpt_EndCount - 1;
|
static const int specialFactions = fpt_EndCount - 1;
|
||||||
static const int maxPlayers= 8;
|
static const int maxPlayers = 8;
|
||||||
static const int serverPort= 61357;
|
static const int serverPort = 61357;
|
||||||
static const int serverAdminPort= 61355;
|
static const int serverAdminPort = 61355;
|
||||||
//static const int updateFps= 40;
|
|
||||||
//static const int cameraFps= 100;
|
|
||||||
static int updateFps;
|
static int updateFps;
|
||||||
static int cameraFps;
|
static int cameraFps;
|
||||||
|
|
||||||
static int networkFramePeriod;
|
static int networkFramePeriod;
|
||||||
static const int networkPingInterval = 5;
|
static const int networkPingInterval = 5;
|
||||||
static const int networkSmoothInterval= 30;
|
static const int networkSmoothInterval = 30;
|
||||||
//static const int networkExtraLatency= 200;
|
static const int maxClientConnectHandshakeSecs = 10;
|
||||||
static const int maxClientConnectHandshakeSecs= 10;
|
|
||||||
|
|
||||||
static const int cellScale = 2;
|
static const int cellScale = 2;
|
||||||
static const int clusterSize = 16;
|
static const int clusterSize = 16;
|
||||||
|
|
||||||
static const char *folder_path_maps;
|
static const char *folder_path_maps;
|
||||||
static const char *folder_path_scenarios;
|
static const char *folder_path_scenarios;
|
||||||
|
@ -212,9 +209,7 @@ public:
|
||||||
|
|
||||||
static void assertDirValid(int v) { assert(v >= 0 && v < 4); }
|
static void assertDirValid(int v) { assert(v >= 0 && v < 4); }
|
||||||
void operator++() {
|
void operator++() {
|
||||||
//printf("In [%s::%s] Line: %d BEFORE +: value = %d\n",__FILE__,__FUNCTION__,__LINE__,asInt());
|
|
||||||
value = static_cast<Enum>((value + 1) % 4);
|
value = static_cast<Enum>((value + 1) % 4);
|
||||||
//printf("In [%s::%s] Line: %d AFTER +: value = %d\n",__FILE__,__FUNCTION__,__LINE__,asInt());
|
|
||||||
}
|
}
|
||||||
void operator--() { // mod with negative numbers is a 'grey area', hence the +3 rather than -1
|
void operator--() { // mod with negative numbers is a 'grey area', hence the +3 rather than -1
|
||||||
value = static_cast<Enum>((value + 3) % 4);
|
value = static_cast<Enum>((value + 3) % 4);
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "xml_parser.h"
|
#include "xml_parser.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
//#include "util.h"
|
|
||||||
#include "platform_common.h"
|
#include "platform_common.h"
|
||||||
#include "conversion.h"
|
#include "conversion.h"
|
||||||
#include "platform_util.h"
|
#include "platform_util.h"
|
||||||
|
@ -66,9 +65,10 @@ enum FlagTypes1 {
|
||||||
ft1_allow_team_switching = 0x02,
|
ft1_allow_team_switching = 0x02,
|
||||||
ft1_allow_in_game_joining = 0x04,
|
ft1_allow_in_game_joining = 0x04,
|
||||||
ft1_network_synch_checks_verbose = 0x08,
|
ft1_network_synch_checks_verbose = 0x08,
|
||||||
ft1_network_synch_checks = 0x10
|
ft1_network_synch_checks = 0x10,
|
||||||
//ft1_xx = 0x20,
|
ft1_allow_shared_team_units = 0x20,
|
||||||
//ft1_xx = 0x40,
|
ft1_allow_shared_team_resources = 0x40
|
||||||
|
//ft1_xxx = 0x80
|
||||||
};
|
};
|
||||||
|
|
||||||
inline static bool isFlagType1BitEnabled(uint32 flagValue,FlagTypes1 type) {
|
inline static bool isFlagType1BitEnabled(uint32 flagValue,FlagTypes1 type) {
|
||||||
|
@ -590,7 +590,7 @@ public:
|
||||||
result += "networkFramePeriod = " + intToStr(networkFramePeriod) + "\n";
|
result += "networkFramePeriod = " + intToStr(networkFramePeriod) + "\n";
|
||||||
result += "networkPauseGameForLaggedClients = " + intToStr(networkPauseGameForLaggedClients) + "\n";
|
result += "networkPauseGameForLaggedClients = " + intToStr(networkPauseGameForLaggedClients) + "\n";
|
||||||
result += "pathFinderType = " + intToStr(pathFinderType) + "\n";
|
result += "pathFinderType = " + intToStr(pathFinderType) + "\n";
|
||||||
result += "flagTypes1 = " + intToStr(flagTypes1) + "\n";
|
result += "flagTypes1 = " + uIntToStr(flagTypes1) + "\n";
|
||||||
result += "mapCRC = " + uIntToStr(mapCRC) + "\n";
|
result += "mapCRC = " + uIntToStr(mapCRC) + "\n";
|
||||||
result += "tilesetCRC = " + uIntToStr(tilesetCRC) + "\n";
|
result += "tilesetCRC = " + uIntToStr(tilesetCRC) + "\n";
|
||||||
result += "techCRC = " + uIntToStr(techCRC) + "\n";
|
result += "techCRC = " + uIntToStr(techCRC) + "\n";
|
||||||
|
@ -718,7 +718,7 @@ public:
|
||||||
// PathFinderType pathFinderType;
|
// PathFinderType pathFinderType;
|
||||||
gameSettingsNode->addAttribute("pathFinderType",intToStr(pathFinderType), mapTagReplacements);
|
gameSettingsNode->addAttribute("pathFinderType",intToStr(pathFinderType), mapTagReplacements);
|
||||||
// uint32 flagTypes1;
|
// uint32 flagTypes1;
|
||||||
gameSettingsNode->addAttribute("flagTypes1",intToStr(flagTypes1), mapTagReplacements);
|
gameSettingsNode->addAttribute("flagTypes1",uIntToStr(flagTypes1), mapTagReplacements);
|
||||||
// int32 mapCRC;
|
// int32 mapCRC;
|
||||||
gameSettingsNode->addAttribute("mapCRC",uIntToStr(mapCRC), mapTagReplacements);
|
gameSettingsNode->addAttribute("mapCRC",uIntToStr(mapCRC), mapTagReplacements);
|
||||||
// int32 tilesetCRC;
|
// int32 tilesetCRC;
|
||||||
|
@ -858,7 +858,7 @@ public:
|
||||||
// PathFinderType pathFinderType;
|
// PathFinderType pathFinderType;
|
||||||
pathFinderType = static_cast<PathFinderType>(gameSettingsNode->getAttribute("pathFinderType")->getIntValue());
|
pathFinderType = static_cast<PathFinderType>(gameSettingsNode->getAttribute("pathFinderType")->getIntValue());
|
||||||
// uint32 flagTypes1;
|
// uint32 flagTypes1;
|
||||||
flagTypes1 = gameSettingsNode->getAttribute("flagTypes1")->getIntValue();
|
flagTypes1 = gameSettingsNode->getAttribute("flagTypes1")->getUIntValue();
|
||||||
// int32 mapCRC;
|
// int32 mapCRC;
|
||||||
mapCRC = gameSettingsNode->getAttribute("mapCRC")->getUIntValue();
|
mapCRC = gameSettingsNode->getAttribute("mapCRC")->getUIntValue();
|
||||||
// int32 tilesetCRC;
|
// int32 tilesetCRC;
|
||||||
|
|
|
@ -124,13 +124,18 @@ Gui::Gui(){
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] END\n",__FILE__,__FUNCTION__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] END\n",__FILE__,__FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::init(Game *game){
|
void Gui::init(Game *game) {
|
||||||
this->commander= game->getCommander();
|
|
||||||
this->gameCamera= game->getGameCameraPtr();
|
this->commander = game->getCommander();
|
||||||
this->console= game->getConsole();
|
this->gameCamera = game->getGameCameraPtr();
|
||||||
this->world= game->getWorld();
|
this->console = game->getConsole();
|
||||||
this->game=game;
|
this->world = game->getWorld();
|
||||||
selection.init(this, world->getThisFactionIndex(), world->getThisTeamIndex());
|
this->game = game;
|
||||||
|
|
||||||
|
selection.init(this,
|
||||||
|
world->getThisFactionIndex(),
|
||||||
|
world->getThisTeamIndex(),
|
||||||
|
isFlagType1BitEnabled(game->getGameSettings()->getFlagTypes1(),ft1_allow_shared_team_units));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::end(){
|
void Gui::end(){
|
||||||
|
@ -217,10 +222,14 @@ bool Gui::mouseValid(int x, int y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::mouseDownLeftDisplay(int x, int y) {
|
void Gui::mouseDownLeftDisplay(int x, int y) {
|
||||||
if(!selectingPos && !selectingMeetingPoint) {
|
if(selectingPos == false &&
|
||||||
int posDisplay= computePosDisplay(x, y);
|
selectingMeetingPoint == false) {
|
||||||
if(posDisplay!= invalidPos) {
|
|
||||||
|
int posDisplay = computePosDisplay(x, y);
|
||||||
|
|
||||||
|
if(posDisplay != invalidPos) {
|
||||||
if(selection.isCommandable()) {
|
if(selection.isCommandable()) {
|
||||||
|
|
||||||
if(selectingBuilding) {
|
if(selectingBuilding) {
|
||||||
mouseDownDisplayUnitBuild(posDisplay);
|
mouseDownDisplayUnitBuild(posDisplay);
|
||||||
}
|
}
|
||||||
|
@ -548,15 +557,15 @@ void Gui::centerCameraOnSelection() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::selectInterestingUnit(InterestingUnitType iut) {
|
void Gui::selectInterestingUnit(InterestingUnitType iut) {
|
||||||
const Faction* thisFaction= world->getThisFaction();
|
const Faction *thisFaction = world->getThisFaction();
|
||||||
const Unit* previousUnit= NULL;
|
const Unit* previousUnit = NULL;
|
||||||
bool previousFound= true;
|
bool previousFound = true;
|
||||||
|
|
||||||
//start at the next harvester
|
//start at the next harvester
|
||||||
if(selection.getCount()==1){
|
if(selection.getCount() == 1) {
|
||||||
const Unit* refUnit= selection.getFrontUnit();
|
const Unit* refUnit= selection.getFrontUnit();
|
||||||
|
|
||||||
if(refUnit->isInteresting(iut)){
|
if(refUnit->isInteresting(iut)) {
|
||||||
previousUnit= refUnit;
|
previousUnit= refUnit;
|
||||||
previousFound= false;
|
previousFound= false;
|
||||||
}
|
}
|
||||||
|
@ -566,28 +575,28 @@ void Gui::selectInterestingUnit(InterestingUnitType iut) {
|
||||||
selection.clear();
|
selection.clear();
|
||||||
|
|
||||||
//search
|
//search
|
||||||
for(int i= 0; i<thisFaction->getUnitCount(); ++i){
|
for(int index = 0; index < thisFaction->getUnitCount(); ++index){
|
||||||
Unit* unit= thisFaction->getUnit(i);
|
Unit* unit = thisFaction->getUnit(index);
|
||||||
|
|
||||||
if(previousFound){
|
if(previousFound == true) {
|
||||||
if(unit->isInteresting(iut)){
|
if(unit->isInteresting(iut)) {
|
||||||
selection.select(unit);
|
selection.select(unit);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(unit==previousUnit){
|
if(unit == previousUnit) {
|
||||||
previousFound= true;
|
previousFound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//search again if we have a previous
|
//search again if we have a previous
|
||||||
if(selection.isEmpty() && previousUnit!=NULL && previousFound==true){
|
if(selection.isEmpty() && previousUnit != NULL && previousFound == true) {
|
||||||
for(int i= 0; i<thisFaction->getUnitCount(); ++i){
|
for(int index = 0; index < thisFaction->getUnitCount(); ++index) {
|
||||||
Unit* unit= thisFaction->getUnit(i);
|
Unit* unit = thisFaction->getUnit(index);
|
||||||
|
|
||||||
if(unit->isInteresting(iut)){
|
if(unit->isInteresting(iut)) {
|
||||||
selection.select(unit);
|
selection.select(unit);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -595,11 +604,14 @@ void Gui::selectInterestingUnit(InterestingUnitType iut) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::clickCommonCommand(CommandClass commandClass){
|
void Gui::clickCommonCommand(CommandClass commandClass) {
|
||||||
for(int i= 0; i<Display::downCellCount; ++i){
|
for(int index = 0; index < Display::downCellCount; ++index) {
|
||||||
const CommandType* ct= display.getCommandType(i);
|
const CommandType *ct = display.getCommandType(index);
|
||||||
if((ct!=NULL && ct->getClass()==commandClass) || display.getCommandClass(i)==commandClass){
|
|
||||||
mouseDownDisplayUnitSkills(i);
|
if((ct != NULL && ct->getClass() == commandClass) ||
|
||||||
|
display.getCommandClass(index) == commandClass) {
|
||||||
|
|
||||||
|
mouseDownDisplayUnitSkills(index);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -607,34 +619,34 @@ void Gui::clickCommonCommand(CommandClass commandClass){
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::mouseDownDisplayUnitSkills(int posDisplay) {
|
void Gui::mouseDownDisplayUnitSkills(int posDisplay) {
|
||||||
if(!selection.isEmpty()) {
|
if(selection.isEmpty() == false) {
|
||||||
if(posDisplay != cancelPos) {
|
if(posDisplay != cancelPos) {
|
||||||
if(posDisplay!=meetingPointPos) {
|
if(posDisplay != meetingPointPos) {
|
||||||
const Unit *unit= selection.getFrontUnit();
|
const Unit *unit= selection.getFrontUnit();
|
||||||
|
|
||||||
//uniform selection
|
//uniform selection
|
||||||
if(selection.isUniform()) {
|
if(selection.isUniform()) {
|
||||||
const CommandType *ct = display.getCommandType(posDisplay);
|
const CommandType *ct = display.getCommandType(posDisplay);
|
||||||
if(activeCommandClass == ccAttack)
|
|
||||||
{// try to switch to next attack type
|
// try to switch to next attack type
|
||||||
int maxI=unit->getType()->getCommandTypeCount();
|
if(activeCommandClass == ccAttack) {
|
||||||
int i=activeCommandType->getId();
|
|
||||||
int k=i+1;
|
int maxI = unit->getType()->getCommandTypeCount();
|
||||||
while(k!=i)
|
int cmdTypeId = activeCommandType->getId();
|
||||||
{
|
int cmdTypeIdNext = cmdTypeId+1;
|
||||||
if(k>=maxI)
|
|
||||||
{
|
while(cmdTypeIdNext != cmdTypeId) {
|
||||||
k=0;
|
if(cmdTypeIdNext >= maxI) {
|
||||||
|
cmdTypeIdNext = 0;
|
||||||
}
|
}
|
||||||
const CommandType *ctype=display.getCommandType(k);
|
const CommandType *ctype = display.getCommandType(cmdTypeIdNext);
|
||||||
if(ctype != NULL && ctype->getClass() == ccAttack)
|
if(ctype != NULL && ctype->getClass() == ccAttack) {
|
||||||
{
|
|
||||||
if(ctype != NULL && unit->getFaction()->reqsOk(ctype)) {
|
if(ctype != NULL && unit->getFaction()->reqsOk(ctype)) {
|
||||||
posDisplay=k;
|
posDisplay=cmdTypeIdNext;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
k++;
|
cmdTypeIdNext++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,22 +696,32 @@ void Gui::mouseDownDisplayUnitSkills(int posDisplay) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::mouseDownDisplayUnitBuild(int posDisplay){
|
void Gui::mouseDownDisplayUnitBuild(int posDisplay) {
|
||||||
int factionIndex= world->getThisFactionIndex();
|
//int factionIndex = world->getThisFactionIndex();
|
||||||
|
|
||||||
if(posDisplay==cancelPos){
|
if(posDisplay == cancelPos) {
|
||||||
resetState();
|
resetState();
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
if(activeCommandType!=NULL && activeCommandType->getClass()==ccBuild){
|
if(activeCommandType != NULL &&
|
||||||
const BuildCommandType *bct= static_cast<const BuildCommandType*>(activeCommandType);
|
activeCommandType->getClass() == ccBuild) {
|
||||||
const UnitType *ut= bct->getBuilding(posDisplay);
|
|
||||||
if(world->getFaction(factionIndex)->reqsOk(ut)){
|
const BuildCommandType *bct = dynamic_cast<const BuildCommandType*>(activeCommandType);
|
||||||
choosenBuildingType= ut;
|
if(bct != NULL) {
|
||||||
assert(choosenBuildingType!=NULL);
|
const UnitType *ut = bct->getBuilding(posDisplay);
|
||||||
selectingPos= true;
|
|
||||||
selectedBuildingFacing = CardinalDir::NORTH;
|
const Unit *unit = selection.getFrontUnit();
|
||||||
activePos= posDisplay;
|
if(unit != NULL && unit->getFaction() != NULL) {
|
||||||
|
|
||||||
|
if(selection.canSelectUnitFactionCheck(unit) == true &&
|
||||||
|
unit->getFaction()->reqsOk(ut)) {
|
||||||
|
|
||||||
|
choosenBuildingType = ut;
|
||||||
|
selectingPos = true;
|
||||||
|
selectedBuildingFacing = CardinalDir::NORTH;
|
||||||
|
activePos = posDisplay;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -707,10 +729,7 @@ void Gui::mouseDownDisplayUnitBuild(int posDisplay){
|
||||||
|
|
||||||
|
|
||||||
string Gui::computeDefaultInfoString() {
|
string Gui::computeDefaultInfoString() {
|
||||||
//Lang &lang= Lang::getInstance();
|
|
||||||
|
|
||||||
string result="";
|
string result="";
|
||||||
//printf("\n\n\n\n********* selection.isCommandable() [%d] selection.isUniform() [%d]\n\n",selection.isCommandable(),selection.isUniform());
|
|
||||||
|
|
||||||
if(selection.isUniform()) {
|
if(selection.isUniform()) {
|
||||||
if(selection.isObserver() || selection.isCommandable()) {
|
if(selection.isObserver() || selection.isCommandable()) {
|
||||||
|
@ -1251,138 +1270,53 @@ void Gui::saveGame(XmlNode *rootNode) const {
|
||||||
std::map<string,string> mapTagReplacements;
|
std::map<string,string> mapTagReplacements;
|
||||||
XmlNode *guiNode = rootNode->addChild("Gui");
|
XmlNode *guiNode = rootNode->addChild("Gui");
|
||||||
|
|
||||||
//External objects
|
|
||||||
// RandomGen random;
|
|
||||||
guiNode->addAttribute("random",intToStr(random.getLastNumber()), mapTagReplacements);
|
guiNode->addAttribute("random",intToStr(random.getLastNumber()), mapTagReplacements);
|
||||||
// const Commander *commander;
|
|
||||||
// const World *world;
|
|
||||||
// const Game *game;
|
|
||||||
// GameCamera *gameCamera;
|
|
||||||
// Console *console;
|
|
||||||
//
|
|
||||||
// //Positions
|
|
||||||
// Vec2i posObjWorld; //world coords
|
|
||||||
guiNode->addAttribute("posObjWorld",posObjWorld.getString(), mapTagReplacements);
|
guiNode->addAttribute("posObjWorld",posObjWorld.getString(), mapTagReplacements);
|
||||||
// bool validPosObjWorld;
|
|
||||||
guiNode->addAttribute("validPosObjWorld",intToStr(validPosObjWorld), mapTagReplacements);
|
guiNode->addAttribute("validPosObjWorld",intToStr(validPosObjWorld), mapTagReplacements);
|
||||||
// //display
|
|
||||||
// const UnitType *choosenBuildingType;
|
|
||||||
if(choosenBuildingType != NULL) {
|
if(choosenBuildingType != NULL) {
|
||||||
const Faction* thisFaction= world->getThisFaction();
|
const Faction* thisFaction= world->getThisFaction();
|
||||||
guiNode->addAttribute("choosenBuildingType",choosenBuildingType->getName(false), mapTagReplacements);
|
guiNode->addAttribute("choosenBuildingType",choosenBuildingType->getName(false), mapTagReplacements);
|
||||||
guiNode->addAttribute("choosenBuildingTypeFactionIndex",intToStr(thisFaction->getIndex()), mapTagReplacements);
|
guiNode->addAttribute("choosenBuildingTypeFactionIndex",intToStr(thisFaction->getIndex()), mapTagReplacements);
|
||||||
}
|
}
|
||||||
// const CommandType *activeCommandType;
|
|
||||||
if(activeCommandType != NULL) {
|
if(activeCommandType != NULL) {
|
||||||
guiNode->addAttribute("activeCommandType",activeCommandType->getName(false), mapTagReplacements);
|
guiNode->addAttribute("activeCommandType",activeCommandType->getName(false), mapTagReplacements);
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommandClass activeCommandClass;
|
|
||||||
guiNode->addAttribute("activeCommandClass",intToStr(activeCommandClass), mapTagReplacements);
|
guiNode->addAttribute("activeCommandClass",intToStr(activeCommandClass), mapTagReplacements);
|
||||||
// int activePos;
|
|
||||||
guiNode->addAttribute("activePos",intToStr(activePos), mapTagReplacements);
|
guiNode->addAttribute("activePos",intToStr(activePos), mapTagReplacements);
|
||||||
// int lastPosDisplay;
|
|
||||||
guiNode->addAttribute("lastPosDisplay",intToStr(lastPosDisplay), mapTagReplacements);
|
guiNode->addAttribute("lastPosDisplay",intToStr(lastPosDisplay), mapTagReplacements);
|
||||||
// //composite
|
|
||||||
// Display display;
|
|
||||||
display.saveGame(guiNode);
|
display.saveGame(guiNode);
|
||||||
// Mouse3d mouse3d;
|
|
||||||
// Selection selection;
|
|
||||||
selection.saveGame(guiNode);
|
selection.saveGame(guiNode);
|
||||||
// SelectionQuad selectionQuad;
|
|
||||||
// int lastQuadCalcFrame;
|
|
||||||
guiNode->addAttribute("lastQuadCalcFrame",intToStr(lastQuadCalcFrame), mapTagReplacements);
|
guiNode->addAttribute("lastQuadCalcFrame",intToStr(lastQuadCalcFrame), mapTagReplacements);
|
||||||
// int selectionCalculationFrameSkip;
|
|
||||||
guiNode->addAttribute("selectionCalculationFrameSkip",intToStr(selectionCalculationFrameSkip), mapTagReplacements);
|
guiNode->addAttribute("selectionCalculationFrameSkip",intToStr(selectionCalculationFrameSkip), mapTagReplacements);
|
||||||
// int minQuadSize;
|
|
||||||
guiNode->addAttribute("minQuadSize",intToStr(minQuadSize), mapTagReplacements);
|
guiNode->addAttribute("minQuadSize",intToStr(minQuadSize), mapTagReplacements);
|
||||||
// Chrono lastGroupRecallTime;
|
|
||||||
//guiNode->addAttribute("lastGroupRecallTime",intToStr(lastGroupRecallTime.getMillis()), mapTagReplacements);
|
|
||||||
// int lastGroupRecall;
|
|
||||||
guiNode->addAttribute("lastGroupRecall",intToStr(lastGroupRecall), mapTagReplacements);
|
guiNode->addAttribute("lastGroupRecall",intToStr(lastGroupRecall), mapTagReplacements);
|
||||||
// //states
|
|
||||||
// bool selectingBuilding;
|
|
||||||
guiNode->addAttribute("selectingBuilding",intToStr(selectingBuilding), mapTagReplacements);
|
guiNode->addAttribute("selectingBuilding",intToStr(selectingBuilding), mapTagReplacements);
|
||||||
// bool selectingPos;
|
|
||||||
guiNode->addAttribute("selectingPos",intToStr(selectingPos), mapTagReplacements);
|
guiNode->addAttribute("selectingPos",intToStr(selectingPos), mapTagReplacements);
|
||||||
// bool selectingMeetingPoint;
|
|
||||||
guiNode->addAttribute("selectingMeetingPoint",intToStr(selectingMeetingPoint), mapTagReplacements);
|
guiNode->addAttribute("selectingMeetingPoint",intToStr(selectingMeetingPoint), mapTagReplacements);
|
||||||
// CardinalDir selectedBuildingFacing;
|
|
||||||
guiNode->addAttribute("selectedBuildingFacing",intToStr(selectedBuildingFacing), mapTagReplacements);
|
guiNode->addAttribute("selectedBuildingFacing",intToStr(selectedBuildingFacing), mapTagReplacements);
|
||||||
// const Object *selectedResourceObject;
|
|
||||||
//
|
|
||||||
// Texture2D* hudTexture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::loadGame(const XmlNode *rootNode, World *world) {
|
void Gui::loadGame(const XmlNode *rootNode, World *world) {
|
||||||
const XmlNode *guiNode = rootNode->getChild("Gui");
|
const XmlNode *guiNode = rootNode->getChild("Gui");
|
||||||
|
|
||||||
//External objects
|
|
||||||
// RandomGen random;
|
|
||||||
random.setLastNumber(guiNode->getAttribute("random")->getIntValue());
|
random.setLastNumber(guiNode->getAttribute("random")->getIntValue());
|
||||||
// const Commander *commander;
|
|
||||||
// const World *world;
|
|
||||||
// const Game *game;
|
|
||||||
// GameCamera *gameCamera;
|
|
||||||
// Console *console;
|
|
||||||
//
|
|
||||||
// //Positions
|
|
||||||
// Vec2i posObjWorld; //world coords
|
|
||||||
//guiNode->addAttribute("posObjWorld",posObjWorld.getString(), mapTagReplacements);
|
|
||||||
posObjWorld = Vec2i::strToVec2(guiNode->getAttribute("posObjWorld")->getValue());
|
posObjWorld = Vec2i::strToVec2(guiNode->getAttribute("posObjWorld")->getValue());
|
||||||
// bool validPosObjWorld;
|
|
||||||
validPosObjWorld = guiNode->getAttribute("validPosObjWorld")->getIntValue() != 0;
|
validPosObjWorld = guiNode->getAttribute("validPosObjWorld")->getIntValue() != 0;
|
||||||
// //display
|
|
||||||
// const UnitType *choosenBuildingType;
|
|
||||||
// if(choosenBuildingType != NULL) {
|
|
||||||
// guiNode->addAttribute("choosenBuildingType",choosenBuildingType->getName(), mapTagReplacements);
|
|
||||||
// }
|
|
||||||
if(guiNode->hasAttribute("choosenBuildingType") == true) {
|
if(guiNode->hasAttribute("choosenBuildingType") == true) {
|
||||||
string unitType = guiNode->getAttribute("choosenBuildingType")->getValue();
|
string unitType = guiNode->getAttribute("choosenBuildingType")->getValue();
|
||||||
int factionIndex = guiNode->getAttribute("choosenBuildingTypeFactionIndex")->getIntValue();
|
int factionIndex = guiNode->getAttribute("choosenBuildingTypeFactionIndex")->getIntValue();
|
||||||
choosenBuildingType = world->getFaction(factionIndex)->getType()->getUnitType(unitType);
|
choosenBuildingType = world->getFaction(factionIndex)->getType()->getUnitType(unitType);
|
||||||
}
|
}
|
||||||
// const CommandType *activeCommandType;
|
|
||||||
//if(activeCommandType != NULL) {
|
|
||||||
// guiNode->addAttribute("activeCommandType",activeCommandType->getName(), mapTagReplacements);
|
|
||||||
//}
|
|
||||||
|
|
||||||
// CommandClass activeCommandClass;
|
|
||||||
//guiNode->addAttribute("activeCommandClass",intToStr(activeCommandClass), mapTagReplacements);
|
|
||||||
// int activePos;
|
|
||||||
activePos = guiNode->getAttribute("activePos")->getIntValue();
|
activePos = guiNode->getAttribute("activePos")->getIntValue();
|
||||||
// int lastPosDisplay;
|
|
||||||
lastPosDisplay = guiNode->getAttribute("lastPosDisplay")->getIntValue();
|
lastPosDisplay = guiNode->getAttribute("lastPosDisplay")->getIntValue();
|
||||||
// //composite
|
|
||||||
// Display display;
|
|
||||||
display.loadGame(guiNode);
|
display.loadGame(guiNode);
|
||||||
// Mouse3d mouse3d;
|
|
||||||
// Selection selection;
|
|
||||||
selection.loadGame(guiNode,world);
|
selection.loadGame(guiNode,world);
|
||||||
// SelectionQuad selectionQuad;
|
|
||||||
// int lastQuadCalcFrame;
|
|
||||||
// don't load this! lastQuadCalcFrame = guiNode->getAttribute("lastQuadCalcFrame")->getIntValue();
|
// don't load this! lastQuadCalcFrame = guiNode->getAttribute("lastQuadCalcFrame")->getIntValue();
|
||||||
lastQuadCalcFrame = game->getTotalRenderFps();
|
lastQuadCalcFrame = game->getTotalRenderFps();
|
||||||
// int selectionCalculationFrameSkip;
|
|
||||||
selectionCalculationFrameSkip = guiNode->getAttribute("selectionCalculationFrameSkip")->getIntValue();
|
selectionCalculationFrameSkip = guiNode->getAttribute("selectionCalculationFrameSkip")->getIntValue();
|
||||||
// int minQuadSize;
|
|
||||||
minQuadSize = guiNode->getAttribute("minQuadSize")->getIntValue();
|
minQuadSize = guiNode->getAttribute("minQuadSize")->getIntValue();
|
||||||
// Chrono lastGroupRecallTime;
|
|
||||||
//guiNode->addAttribute("lastGroupRecallTime",intToStr(lastGroupRecallTime.getMillis()), mapTagReplacements);
|
|
||||||
// int lastGroupRecall;
|
|
||||||
lastGroupRecall = guiNode->getAttribute("lastGroupRecall")->getIntValue();
|
lastGroupRecall = guiNode->getAttribute("lastGroupRecall")->getIntValue();
|
||||||
// //states
|
|
||||||
// bool selectingBuilding;
|
|
||||||
//selectingBuilding = guiNode->getAttribute("selectingBuilding")->getIntValue();
|
|
||||||
// bool selectingPos;
|
|
||||||
//guiNode->addAttribute("selectingPos",intToStr(selectingPos), mapTagReplacements);
|
|
||||||
// bool selectingMeetingPoint;
|
|
||||||
//guiNode->addAttribute("selectingMeetingPoint",intToStr(selectingMeetingPoint), mapTagReplacements);
|
|
||||||
// CardinalDir selectedBuildingFacing;
|
|
||||||
//guiNode->addAttribute("selectedBuildingFacing",intToStr(selectedBuildingFacing), mapTagReplacements);
|
|
||||||
// const Object *selectedResourceObject;
|
|
||||||
//
|
|
||||||
// Texture2D* hudTexture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -27,20 +27,32 @@ namespace Glest{ namespace Game{
|
||||||
// class Selection
|
// class Selection
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
void Selection::init(Gui *gui, int factionIndex, int teamIndex) {
|
void Selection::init(Gui *gui, int factionIndex, int teamIndex, bool allowSharedTeamUnits) {
|
||||||
this->factionIndex= factionIndex;
|
this->factionIndex = factionIndex;
|
||||||
this->teamIndex = teamIndex;
|
this->teamIndex = teamIndex;
|
||||||
this->gui= gui;
|
this->allowSharedTeamUnits = allowSharedTeamUnits;
|
||||||
|
this->gui = gui;
|
||||||
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Selection::~Selection(){
|
Selection::~Selection(){
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Selection::canSelectUnitFactionCheck(const Unit *unit) const {
|
||||||
|
//check if enemy
|
||||||
|
if(unit->getFactionIndex() != factionIndex) {
|
||||||
|
if(this->allowSharedTeamUnits == false ||
|
||||||
|
unit->getFaction()->getTeam() != teamIndex) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Selection::select(Unit *unit) {
|
bool Selection::select(Unit *unit) {
|
||||||
bool result = false;
|
bool result = false;
|
||||||
//check size
|
|
||||||
//if(selectedUnits.size() >= maxUnits){
|
|
||||||
if((int)selectedUnits.size() >= Config::getInstance().getInt("MaxUnitSelectCount",intToStr(maxUnits).c_str())) {
|
if((int)selectedUnits.size() >= Config::getInstance().getInt("MaxUnitSelectCount",intToStr(maxUnits).c_str())) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -48,34 +60,36 @@ bool Selection::select(Unit *unit) {
|
||||||
// Fix Bug reported on sourceforge.net: Glest::Game::Selection::select crash with NULL pointer - ID: 3608835
|
// Fix Bug reported on sourceforge.net: Glest::Game::Selection::select crash with NULL pointer - ID: 3608835
|
||||||
if(unit != NULL) {
|
if(unit != NULL) {
|
||||||
//check if already selected
|
//check if already selected
|
||||||
for(int i=0; i < (int)selectedUnits.size(); ++i) {
|
for(int index = 0; index < (int)selectedUnits.size(); ++index) {
|
||||||
if(selectedUnits[i ]== unit) {
|
if(selectedUnits[index] == unit) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if dead
|
//check if dead
|
||||||
if(unit->isDead()) {
|
if(unit->isDead() == true) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if multisel
|
//check if multisel
|
||||||
if(!unit->getType()->getMultiSelect() && !isEmpty()) {
|
if(unit->getType()->getMultiSelect() == false && isEmpty() == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if enemy
|
//check if enemy
|
||||||
if(unit->getFactionIndex() != factionIndex && !isEmpty()) {
|
if(canSelectUnitFactionCheck(unit) == false && isEmpty() == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//check existing enemy
|
//check existing enemy
|
||||||
if(selectedUnits.size()==1 && selectedUnits.front()->getFactionIndex() != factionIndex) {
|
//if(selectedUnits.size() == 1 && selectedUnits.front()->getFactionIndex() != factionIndex) {
|
||||||
|
if(selectedUnits.size() == 1 && canSelectUnitFactionCheck(selectedUnits.front()) == false) {
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//check existing multisel
|
//check existing multisel
|
||||||
if(selectedUnits.size()==1 && !selectedUnits.front()->getType()->getMultiSelect()){
|
if(selectedUnits.size() == 1 &&
|
||||||
|
selectedUnits.front()->getType()->getMultiSelect() == false) {
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,22 +97,20 @@ bool Selection::select(Unit *unit) {
|
||||||
|
|
||||||
unit->addObserver(this);
|
unit->addObserver(this);
|
||||||
|
|
||||||
int unitTypeId=unit->getType()->getId();
|
int unitTypeId = unit->getType()->getId();
|
||||||
bool inserted=false;
|
bool inserted = false;
|
||||||
for(int i=0; i < (int)selectedUnits.size(); ++i) {
|
for(int index = 0; index < (int)selectedUnits.size(); ++index) {
|
||||||
int currentTypeId=selectedUnits[i]->getType()->getId();
|
|
||||||
|
int currentTypeId = selectedUnits[index]->getType()->getId();
|
||||||
|
if(unitTypeId <= currentTypeId) {
|
||||||
|
|
||||||
if(unitTypeId<=currentTypeId) {
|
|
||||||
//place unit here
|
//place unit here
|
||||||
selectedUnits.insert(selectedUnits.begin()+i,unit);
|
selectedUnits.insert(selectedUnits.begin() + index,unit);
|
||||||
inserted=true;
|
inserted = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if(unitTypeId>currentTypeId) {
|
|
||||||
//do nothing
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if( !inserted ){
|
if(inserted == false) {
|
||||||
selectedUnits.push_back(unit);
|
selectedUnits.push_back(unit);
|
||||||
}
|
}
|
||||||
result = true;
|
result = true;
|
||||||
|
@ -111,15 +123,15 @@ bool Selection::select(Unit *unit) {
|
||||||
void Selection::select(const UnitContainer &units){
|
void Selection::select(const UnitContainer &units){
|
||||||
|
|
||||||
//add units to gui
|
//add units to gui
|
||||||
for(UnitIterator it= units.begin(); it!=units.end(); ++it){
|
for(UnitIterator it = units.begin(); it != units.end(); ++it) {
|
||||||
select(*it);
|
select(*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Selection::unSelect(const UnitContainer &units){
|
void Selection::unSelect(const UnitContainer &units) {
|
||||||
|
|
||||||
//add units to gui
|
//add units to gui
|
||||||
for(UnitIterator it= units.begin(); it!=units.end(); ++it){
|
for(UnitIterator it = units.begin(); it != units.end(); ++it) {
|
||||||
for(int i = 0; i < (int)selectedUnits.size(); ++i) {
|
for(int i = 0; i < (int)selectedUnits.size(); ++i) {
|
||||||
if(selectedUnits[i] == *it) {
|
if(selectedUnits[i] == *it) {
|
||||||
unSelect(i);
|
unSelect(i);
|
||||||
|
@ -128,26 +140,24 @@ void Selection::unSelect(const UnitContainer &units){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Selection::unSelect(int i){
|
void Selection::unSelect(int i) {
|
||||||
//remove unit from list
|
selectedUnits.erase(selectedUnits.begin() + i);
|
||||||
selectedUnits.erase(selectedUnits.begin()+i);
|
|
||||||
gui->onSelectionChanged();
|
gui->onSelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Selection::clear(){
|
void Selection::clear(){
|
||||||
//clear list
|
|
||||||
selectedUnits.clear();
|
selectedUnits.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Selection::isUniform() const{
|
bool Selection::isUniform() const{
|
||||||
if(selectedUnits.empty()){
|
if(selectedUnits.empty() == true) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const UnitType *ut= selectedUnits.front()->getType();
|
const UnitType *ut= selectedUnits.front()->getType();
|
||||||
|
|
||||||
for(int i = 0; i < (int)selectedUnits.size(); ++i) {
|
for(int i = 0; i < (int)selectedUnits.size(); ++i) {
|
||||||
if(selectedUnits[i]->getType()!=ut){
|
if(selectedUnits[i]->getType() != ut) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +166,8 @@ bool Selection::isUniform() const{
|
||||||
|
|
||||||
bool Selection::isEnemy() const {
|
bool Selection::isEnemy() const {
|
||||||
return selectedUnits.size() == 1 &&
|
return selectedUnits.size() == 1 &&
|
||||||
selectedUnits.front()->getFactionIndex() != factionIndex;
|
//selectedUnits.front()->getFactionIndex() != factionIndex;
|
||||||
|
canSelectUnitFactionCheck(selectedUnits.front()) == false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Selection::isObserver() const {
|
bool Selection::isObserver() const {
|
||||||
|
@ -168,12 +179,12 @@ bool Selection::isCommandable() const {
|
||||||
//printf("\n\n\n\n********* selection.isCommandable() ---> isEmpty() [%d] isEnemy() [%d] selectedUnits.size() [%d]\n\n",isEmpty(),isEnemy(),(int)selectedUnits.size());
|
//printf("\n\n\n\n********* selection.isCommandable() ---> isEmpty() [%d] isEnemy() [%d] selectedUnits.size() [%d]\n\n",isEmpty(),isEnemy(),(int)selectedUnits.size());
|
||||||
|
|
||||||
return
|
return
|
||||||
!isEmpty() &&
|
isEmpty() == false &&
|
||||||
!isEnemy() &&
|
isEnemy() == false &&
|
||||||
!(selectedUnits.size()==1 && !selectedUnits.front()->isAlive());
|
(selectedUnits.size() == 1 && selectedUnits.front()->isAlive() == false) == false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Selection::isCancelable() const{
|
bool Selection::isCancelable() const {
|
||||||
return
|
return
|
||||||
selectedUnits.size() > 1 ||
|
selectedUnits.size() > 1 ||
|
||||||
(selectedUnits.size() == 1 && selectedUnits[0]->anyCommand(true));
|
(selectedUnits.size() == 1 && selectedUnits[0]->anyCommand(true));
|
||||||
|
@ -190,8 +201,8 @@ Vec3f Selection::getRefPos() const{
|
||||||
return getFrontUnit()->getCurrVector();
|
return getFrontUnit()->getCurrVector();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Selection::hasUnit(const Unit* unit) const{
|
bool Selection::hasUnit(const Unit* unit) const {
|
||||||
return find(selectedUnits.begin(), selectedUnits.end(), unit)!=selectedUnits.end();
|
return find(selectedUnits.begin(), selectedUnits.end(), unit) != selectedUnits.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Selection::assignGroup(int groupIndex,const UnitContainer *pUnits) {
|
void Selection::assignGroup(int groupIndex,const UnitContainer *pUnits) {
|
||||||
|
@ -256,21 +267,21 @@ void Selection::recallGroup(int groupIndex){
|
||||||
|
|
||||||
void Selection::unitEvent(UnitObserver::Event event, const Unit *unit) {
|
void Selection::unitEvent(UnitObserver::Event event, const Unit *unit) {
|
||||||
|
|
||||||
if(event==UnitObserver::eKill){
|
if(event == UnitObserver::eKill) {
|
||||||
|
|
||||||
//remove from selection
|
//remove from selection
|
||||||
for(int i = 0; i < (int)selectedUnits.size(); ++i) {
|
for(int index = 0; index < (int)selectedUnits.size(); ++index) {
|
||||||
if(selectedUnits[i]==unit){
|
if(selectedUnits[index] == unit){
|
||||||
selectedUnits.erase(selectedUnits.begin()+i);
|
selectedUnits.erase(selectedUnits.begin() + index);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//remove from groups
|
//remove from groups
|
||||||
for(int i=0; i<maxGroups; ++i){
|
for(int index = 0; index < maxGroups; ++index) {
|
||||||
for(int j = 0; j < (int)groups[i].size(); ++j) {
|
for(int index2 = 0; index2 < (int)groups[index].size(); ++index2) {
|
||||||
if(groups[i][j]==unit){
|
if(groups[index][index2] == unit) {
|
||||||
groups[i].erase(groups[i].begin()+j);
|
groups[index].erase(groups[index].begin() + index2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,29 +289,28 @@ void Selection::unitEvent(UnitObserver::Event event, const Unit *unit) {
|
||||||
|
|
||||||
//notify gui only if no more units to execute the command
|
//notify gui only if no more units to execute the command
|
||||||
//of course the selection changed, but this doesn't matter in this case.
|
//of course the selection changed, but this doesn't matter in this case.
|
||||||
if( selectedUnits.empty() == true ){
|
if( selectedUnits.empty() == true) {
|
||||||
gui->onSelectionChanged();
|
gui->onSelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Selection::saveGame(XmlNode *rootNode) const {
|
void Selection::saveGame(XmlNode *rootNode) const {
|
||||||
|
|
||||||
std::map<string,string> mapTagReplacements;
|
std::map<string,string> mapTagReplacements;
|
||||||
XmlNode *selectionNode = rootNode->addChild("Selection");
|
XmlNode *selectionNode = rootNode->addChild("Selection");
|
||||||
|
|
||||||
// int factionIndex;
|
|
||||||
selectionNode->addAttribute("factionIndex",intToStr(factionIndex), mapTagReplacements);
|
selectionNode->addAttribute("factionIndex",intToStr(factionIndex), mapTagReplacements);
|
||||||
// int teamIndex;
|
|
||||||
selectionNode->addAttribute("teamIndex",intToStr(teamIndex), mapTagReplacements);
|
selectionNode->addAttribute("teamIndex",intToStr(teamIndex), mapTagReplacements);
|
||||||
// UnitContainer selectedUnits;
|
selectionNode->addAttribute("allowSharedTeamUnits",intToStr(allowSharedTeamUnits), mapTagReplacements);
|
||||||
|
|
||||||
for(unsigned int i = 0; i < selectedUnits.size(); i++) {
|
for(unsigned int i = 0; i < selectedUnits.size(); i++) {
|
||||||
Unit *unit = selectedUnits[i];
|
Unit *unit = selectedUnits[i];
|
||||||
|
|
||||||
XmlNode *selectedUnitsNode = selectionNode->addChild("selectedUnits");
|
XmlNode *selectedUnitsNode = selectionNode->addChild("selectedUnits");
|
||||||
selectedUnitsNode->addAttribute("unitId",intToStr(unit->getId()), mapTagReplacements);
|
selectedUnitsNode->addAttribute("unitId",intToStr(unit->getId()), mapTagReplacements);
|
||||||
}
|
}
|
||||||
// UnitContainer groups[maxGroups];
|
|
||||||
for(unsigned int x = 0; x < (unsigned int)maxGroups; ++x) {
|
for(unsigned int x = 0; x < (unsigned int)maxGroups; ++x) {
|
||||||
XmlNode *groupsNode = selectionNode->addChild("groups");
|
XmlNode *groupsNode = selectionNode->addChild("groups");
|
||||||
for(unsigned int i = 0; i < (unsigned int)groups[x].size(); ++i) {
|
for(unsigned int i = 0; i < (unsigned int)groups[x].size(); ++i) {
|
||||||
|
@ -310,32 +320,18 @@ void Selection::saveGame(XmlNode *rootNode) const {
|
||||||
selectedUnitsNode->addAttribute("unitId",intToStr(unit->getId()), mapTagReplacements);
|
selectedUnitsNode->addAttribute("unitId",intToStr(unit->getId()), mapTagReplacements);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gui *gui;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Selection::loadGame(const XmlNode *rootNode, World *world) {
|
void Selection::loadGame(const XmlNode *rootNode, World *world) {
|
||||||
|
|
||||||
const XmlNode *selectionNode = rootNode->getChild("Selection");
|
const XmlNode *selectionNode = rootNode->getChild("Selection");
|
||||||
|
|
||||||
// vector<XmlNode *> fowPixmap1NodeList = minimapNode->getChildList("fowPixmap1");
|
|
||||||
// for(unsigned int i = 0; i < fowPixmap1NodeList.size(); ++i) {
|
|
||||||
// XmlNode *fowPixmap1Node = fowPixmap1NodeList[i];
|
|
||||||
//
|
|
||||||
// int pixelIndex = fowPixmap1Node->getAttribute("index")->getIntValue();
|
|
||||||
// fowPixmap1->getPixels()[pixelIndex] = fowPixmap1Node->getAttribute("pixel")->getIntValue();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// int factionIndex;
|
|
||||||
factionIndex = selectionNode->getAttribute("factionIndex")->getIntValue();
|
factionIndex = selectionNode->getAttribute("factionIndex")->getIntValue();
|
||||||
// int teamIndex;
|
|
||||||
teamIndex = selectionNode->getAttribute("teamIndex")->getIntValue();
|
teamIndex = selectionNode->getAttribute("teamIndex")->getIntValue();
|
||||||
// UnitContainer selectedUnits;
|
if(selectionNode->hasAttribute("allowSharedTeamUnits") == true) {
|
||||||
// for(unsigned int i = 0; i < selectedUnits.size(); i++) {
|
allowSharedTeamUnits = selectionNode->getAttribute("allowSharedTeamUnits")->getIntValue();
|
||||||
// Unit *unit = selectedUnits[i];
|
}
|
||||||
//
|
|
||||||
// XmlNode *selectedUnitsNode = selectionNode->addChild("selectedUnits");
|
|
||||||
// selectedUnitsNode->addAttribute("id",intToStr(unit->getId()), mapTagReplacements);
|
|
||||||
// }
|
|
||||||
vector<XmlNode *> selectedUnitsNodeList = selectionNode->getChildList("selectedUnits");
|
vector<XmlNode *> selectedUnitsNodeList = selectionNode->getChildList("selectedUnits");
|
||||||
for(unsigned int i = 0; i < selectedUnitsNodeList.size(); ++i) {
|
for(unsigned int i = 0; i < selectedUnitsNodeList.size(); ++i) {
|
||||||
XmlNode *selectedUnitsNode = selectedUnitsNodeList[i];
|
XmlNode *selectedUnitsNode = selectedUnitsNodeList[i];
|
||||||
|
@ -347,16 +343,6 @@ void Selection::loadGame(const XmlNode *rootNode, World *world) {
|
||||||
selectedUnits.push_back(unit);
|
selectedUnits.push_back(unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnitContainer groups[maxGroups];
|
|
||||||
// for(unsigned int x = 0; x < maxGroups; ++x) {
|
|
||||||
// XmlNode *groupsNode = selectionNode->addChild("groups");
|
|
||||||
// for(unsigned int i = 0; i < groups[x].size(); ++i) {
|
|
||||||
// Unit *unit = groups[x][i];
|
|
||||||
//
|
|
||||||
// XmlNode *selectedUnitsNode = groupsNode->addChild("selectedUnits");
|
|
||||||
// selectedUnitsNode->addAttribute("unitId",intToStr(unit->getId()), mapTagReplacements);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
vector<XmlNode *> groupsNodeList = selectionNode->getChildList("groups");
|
vector<XmlNode *> groupsNodeList = selectionNode->getChildList("groups");
|
||||||
for(unsigned int i = 0; i < groupsNodeList.size(); ++i) {
|
for(unsigned int i = 0; i < groupsNodeList.size(); ++i) {
|
||||||
XmlNode *groupsNode = groupsNodeList[i];
|
XmlNode *groupsNode = groupsNodeList[i];
|
||||||
|
@ -372,9 +358,6 @@ void Selection::loadGame(const XmlNode *rootNode, World *world) {
|
||||||
groups[i].push_back(unit);
|
groups[i].push_back(unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gui *gui;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,23 +47,25 @@ public:
|
||||||
typedef UnitContainer::const_iterator UnitIterator;
|
typedef UnitContainer::const_iterator UnitIterator;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const int maxGroups= 10;
|
static const int maxGroups = 10;
|
||||||
static const int maxUnits= 36;
|
static const int maxUnits = 36;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int factionIndex;
|
int factionIndex;
|
||||||
int teamIndex;
|
int teamIndex;
|
||||||
|
bool allowSharedTeamUnits;
|
||||||
UnitContainer selectedUnits;
|
UnitContainer selectedUnits;
|
||||||
UnitContainer groups[maxGroups];
|
UnitContainer groups[maxGroups];
|
||||||
Gui *gui;
|
Gui *gui;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Selection() : UnitObserver() {
|
Selection() : UnitObserver() {
|
||||||
factionIndex = 0;
|
factionIndex = 0;
|
||||||
teamIndex = 0;
|
teamIndex = 0;
|
||||||
gui = NULL;
|
allowSharedTeamUnits = false;
|
||||||
|
gui = NULL;
|
||||||
}
|
}
|
||||||
void init(Gui *gui, int factionIndex, int teamIndex);
|
void init(Gui *gui, int factionIndex, int teamIndex, bool allowSharedTeamUnits);
|
||||||
virtual ~Selection();
|
virtual ~Selection();
|
||||||
|
|
||||||
bool select(Unit *unit);
|
bool select(Unit *unit);
|
||||||
|
@ -77,7 +79,6 @@ public:
|
||||||
bool isEnemy() const;
|
bool isEnemy() const;
|
||||||
bool isObserver() const;
|
bool isObserver() const;
|
||||||
|
|
||||||
//bool isComandable() const;
|
|
||||||
bool isCommandable() const;
|
bool isCommandable() const;
|
||||||
bool isCancelable() const;
|
bool isCancelable() const;
|
||||||
bool isMeetable() const;
|
bool isMeetable() const;
|
||||||
|
@ -96,9 +97,11 @@ public:
|
||||||
vector<Unit*> getUnitsForGroup(int groupIndex);
|
vector<Unit*> getUnitsForGroup(int groupIndex);
|
||||||
|
|
||||||
virtual void unitEvent(UnitObserver::Event event, const Unit *unit);
|
virtual void unitEvent(UnitObserver::Event event, const Unit *unit);
|
||||||
|
bool canSelectUnitFactionCheck(const Unit *unit) const;
|
||||||
|
|
||||||
virtual void saveGame(XmlNode *rootNode) const;
|
virtual void saveGame(XmlNode *rootNode) const;
|
||||||
void loadGame(const XmlNode *rootNode, World *world);
|
void loadGame(const XmlNode *rootNode, World *world);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -210,6 +210,28 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
||||||
checkBoxAllowObservers.setValue(false);
|
checkBoxAllowObservers.setValue(false);
|
||||||
checkBoxAllowObservers.setEditable(false);
|
checkBoxAllowObservers.setEditable(false);
|
||||||
|
|
||||||
|
labelAllowTeamUnitSharing.registerGraphicComponent(containerName,"labelAllowTeamUnitSharing");
|
||||||
|
labelAllowTeamUnitSharing.init(xoffset+410, 670, 80);
|
||||||
|
labelAllowTeamUnitSharing.setText(lang.getString("AllowTeamUnitSharing"));
|
||||||
|
labelAllowTeamUnitSharing.setVisible(true);
|
||||||
|
|
||||||
|
checkBoxAllowTeamUnitSharing.registerGraphicComponent(containerName,"checkBoxAllowTeamUnitSharing");
|
||||||
|
checkBoxAllowTeamUnitSharing.init(xoffset+600, 670);
|
||||||
|
checkBoxAllowTeamUnitSharing.setValue(false);
|
||||||
|
checkBoxAllowTeamUnitSharing.setVisible(true);
|
||||||
|
checkBoxAllowTeamUnitSharing.setEditable(false);
|
||||||
|
|
||||||
|
labelAllowTeamResourceSharing.registerGraphicComponent(containerName,"labelAllowTeamResourceSharing");
|
||||||
|
labelAllowTeamResourceSharing.init(xoffset+410, 640, 80);
|
||||||
|
labelAllowTeamResourceSharing.setText(lang.getString("AllowTeamResourceSharing"));
|
||||||
|
labelAllowTeamResourceSharing.setVisible(true);
|
||||||
|
|
||||||
|
checkBoxAllowTeamResourceSharing.registerGraphicComponent(containerName,"checkBoxAllowTeamResourceSharing");
|
||||||
|
checkBoxAllowTeamResourceSharing.init(xoffset+600, 640);
|
||||||
|
checkBoxAllowTeamResourceSharing.setValue(false);
|
||||||
|
checkBoxAllowTeamResourceSharing.setVisible(true);
|
||||||
|
checkBoxAllowTeamResourceSharing.setEditable(false);
|
||||||
|
|
||||||
for(int i=0; i<45; ++i){
|
for(int i=0; i<45; ++i){
|
||||||
rMultiplier.push_back(floatToStr(0.5f+0.1f*i,1));
|
rMultiplier.push_back(floatToStr(0.5f+0.1f*i,1));
|
||||||
}
|
}
|
||||||
|
@ -637,6 +659,9 @@ void MenuStateConnectedGame::reloadUI() {
|
||||||
|
|
||||||
labelEnableSwitchTeamMode.setText(lang.getString("EnableSwitchTeamMode"));
|
labelEnableSwitchTeamMode.setText(lang.getString("EnableSwitchTeamMode"));
|
||||||
|
|
||||||
|
labelAllowTeamUnitSharing.setText(lang.getString("AllowTeamUnitSharing"));
|
||||||
|
labelAllowTeamResourceSharing.setText(lang.getString("AllowTeamResourceSharing"));
|
||||||
|
|
||||||
labelAISwitchTeamAcceptPercent.setText(lang.getString("AISwitchTeamAcceptPercent"));
|
labelAISwitchTeamAcceptPercent.setText(lang.getString("AISwitchTeamAcceptPercent"));
|
||||||
|
|
||||||
vector<string> aiswitchteamModeItems;
|
vector<string> aiswitchteamModeItems;
|
||||||
|
@ -1814,6 +1839,15 @@ void MenuStateConnectedGame::mouseClickAdmin(int x, int y, MouseButton mouseButt
|
||||||
needToBroadcastServerSettings=true;
|
needToBroadcastServerSettings=true;
|
||||||
broadcastServerSettingsDelayTimer=time(NULL);
|
broadcastServerSettingsDelayTimer=time(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (checkBoxAllowTeamUnitSharing.mouseClick(x, y)) {
|
||||||
|
needToBroadcastServerSettings=true;
|
||||||
|
broadcastServerSettingsDelayTimer=time(NULL);
|
||||||
|
}
|
||||||
|
else if (checkBoxAllowTeamResourceSharing.mouseClick(x, y)) {
|
||||||
|
needToBroadcastServerSettings=true;
|
||||||
|
broadcastServerSettingsDelayTimer=time(NULL);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
@ -2156,6 +2190,26 @@ void MenuStateConnectedGame::loadGameSettings(GameSettings *gameSettings) {
|
||||||
gameSettings->setAiAcceptSwitchTeamPercentChance(strToInt(listBoxAISwitchTeamAcceptPercent.getSelectedItem()));
|
gameSettings->setAiAcceptSwitchTeamPercentChance(strToInt(listBoxAISwitchTeamAcceptPercent.getSelectedItem()));
|
||||||
gameSettings->setFallbackCpuMultiplier(listBoxFallbackCpuMultiplier.getSelectedItemIndex());
|
gameSettings->setFallbackCpuMultiplier(listBoxFallbackCpuMultiplier.getSelectedItemIndex());
|
||||||
|
|
||||||
|
valueFlags1 = gameSettings->getFlagTypes1();
|
||||||
|
if(checkBoxAllowTeamUnitSharing.getValue() == true) {
|
||||||
|
valueFlags1 |= ft1_allow_shared_team_units;
|
||||||
|
gameSettings->setFlagTypes1(valueFlags1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
valueFlags1 &= ~ft1_allow_shared_team_units;
|
||||||
|
gameSettings->setFlagTypes1(valueFlags1);
|
||||||
|
}
|
||||||
|
|
||||||
|
valueFlags1 = gameSettings->getFlagTypes1();
|
||||||
|
if(checkBoxAllowTeamResourceSharing.getValue() == true) {
|
||||||
|
valueFlags1 |= ft1_allow_shared_team_resources;
|
||||||
|
gameSettings->setFlagTypes1(valueFlags1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
valueFlags1 &= ~ft1_allow_shared_team_resources;
|
||||||
|
gameSettings->setFlagTypes1(valueFlags1);
|
||||||
|
}
|
||||||
|
|
||||||
// First save Used slots
|
// First save Used slots
|
||||||
//for(int i=0; i<mapInfo.players; ++i)
|
//for(int i=0; i<mapInfo.players; ++i)
|
||||||
int AIPlayerCount = 0;
|
int AIPlayerCount = 0;
|
||||||
|
@ -2398,6 +2452,11 @@ void MenuStateConnectedGame::mouseMove(int x, int y, const MouseState *ms) {
|
||||||
checkBoxScenario.mouseMove(x, y);
|
checkBoxScenario.mouseMove(x, y);
|
||||||
listBoxScenario.mouseMove(x, y);
|
listBoxScenario.mouseMove(x, y);
|
||||||
|
|
||||||
|
labelAllowTeamUnitSharing.mouseMove(x,y);
|
||||||
|
checkBoxAllowTeamUnitSharing.mouseMove(x,y);
|
||||||
|
labelAllowTeamResourceSharing.mouseMove(x,y);
|
||||||
|
checkBoxAllowTeamResourceSharing.mouseMove(x,y);
|
||||||
|
|
||||||
checkBoxAllowNativeLanguageTechtree.mouseMove(x, y);
|
checkBoxAllowNativeLanguageTechtree.mouseMove(x, y);
|
||||||
|
|
||||||
buttonPlayNow.mouseMove(x, y);
|
buttonPlayNow.mouseMove(x, y);
|
||||||
|
@ -2642,6 +2701,12 @@ void MenuStateConnectedGame::render() {
|
||||||
renderer.renderListBox(&listBoxAISwitchTeamAcceptPercent);
|
renderer.renderListBox(&listBoxAISwitchTeamAcceptPercent);
|
||||||
renderer.renderListBox(&listBoxFallbackCpuMultiplier);
|
renderer.renderListBox(&listBoxFallbackCpuMultiplier);
|
||||||
|
|
||||||
|
renderer.renderLabel(&labelAllowTeamUnitSharing);
|
||||||
|
renderer.renderCheckBox(&checkBoxAllowTeamUnitSharing);
|
||||||
|
|
||||||
|
renderer.renderLabel(&labelAllowTeamResourceSharing);
|
||||||
|
renderer.renderCheckBox(&checkBoxAllowTeamResourceSharing);
|
||||||
|
|
||||||
renderer.renderButton(&buttonPlayNow);
|
renderer.renderButton(&buttonPlayNow);
|
||||||
renderer.renderButton(&buttonRestoreLastSettings);
|
renderer.renderButton(&buttonRestoreLastSettings);
|
||||||
|
|
||||||
|
@ -2777,6 +2842,9 @@ void MenuStateConnectedGame::update() {
|
||||||
listBoxFogOfWar.setEditable(isHeadlessAdmin());
|
listBoxFogOfWar.setEditable(isHeadlessAdmin());
|
||||||
checkBoxAllowObservers.setEditable(isHeadlessAdmin());
|
checkBoxAllowObservers.setEditable(isHeadlessAdmin());
|
||||||
|
|
||||||
|
checkBoxAllowTeamUnitSharing.setEditable(isHeadlessAdmin());
|
||||||
|
checkBoxAllowTeamResourceSharing.setEditable(isHeadlessAdmin());
|
||||||
|
|
||||||
if(isHeadlessAdmin() == true) {
|
if(isHeadlessAdmin() == true) {
|
||||||
for(unsigned int i = 0; i < (unsigned int)GameConstants::maxPlayers; ++i) {
|
for(unsigned int i = 0; i < (unsigned int)GameConstants::maxPlayers; ++i) {
|
||||||
listBoxControls[i].setEditable(isHeadlessAdmin());
|
listBoxControls[i].setEditable(isHeadlessAdmin());
|
||||||
|
@ -4625,6 +4693,20 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
|
||||||
listBoxAISwitchTeamAcceptPercent.setSelectedItem(intToStr(gameSettings->getAiAcceptSwitchTeamPercentChance()));
|
listBoxAISwitchTeamAcceptPercent.setSelectedItem(intToStr(gameSettings->getAiAcceptSwitchTeamPercentChance()));
|
||||||
listBoxFallbackCpuMultiplier.setSelectedItemIndex(gameSettings->getFallbackCpuMultiplier());
|
listBoxFallbackCpuMultiplier.setSelectedItemIndex(gameSettings->getFallbackCpuMultiplier());
|
||||||
|
|
||||||
|
if((gameSettings->getFlagTypes1() & ft1_allow_shared_team_units) == ft1_allow_shared_team_units) {
|
||||||
|
checkBoxAllowTeamUnitSharing.setValue(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
checkBoxAllowTeamUnitSharing.setValue(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if((gameSettings->getFlagTypes1() & ft1_allow_shared_team_resources) == ft1_allow_shared_team_resources) {
|
||||||
|
checkBoxAllowTeamResourceSharing.setValue(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
checkBoxAllowTeamResourceSharing.setValue(false);
|
||||||
|
}
|
||||||
|
|
||||||
// Control
|
// Control
|
||||||
for(int i=0; i<GameConstants::maxPlayers; ++i) {
|
for(int i=0; i<GameConstants::maxPlayers; ++i) {
|
||||||
listBoxControls[i].setSelectedItemIndex(ctClosed);
|
listBoxControls[i].setSelectedItemIndex(ctClosed);
|
||||||
|
|
|
@ -206,9 +206,14 @@ private:
|
||||||
GraphicButton buttonCancelDownloads;
|
GraphicButton buttonCancelDownloads;
|
||||||
|
|
||||||
GraphicLabel labelEnableSwitchTeamMode;
|
GraphicLabel labelEnableSwitchTeamMode;
|
||||||
//GraphicListBox listBoxEnableSwitchTeamMode;
|
|
||||||
GraphicCheckBox checkBoxEnableSwitchTeamMode;
|
GraphicCheckBox checkBoxEnableSwitchTeamMode;
|
||||||
|
|
||||||
|
GraphicLabel labelAllowTeamUnitSharing;
|
||||||
|
GraphicCheckBox checkBoxAllowTeamUnitSharing;
|
||||||
|
|
||||||
|
GraphicLabel labelAllowTeamResourceSharing;
|
||||||
|
GraphicCheckBox checkBoxAllowTeamResourceSharing;
|
||||||
|
|
||||||
GraphicLabel labelAISwitchTeamAcceptPercent;
|
GraphicLabel labelAISwitchTeamAcceptPercent;
|
||||||
GraphicListBox listBoxAISwitchTeamAcceptPercent;
|
GraphicListBox listBoxAISwitchTeamAcceptPercent;
|
||||||
GraphicLabel labelFallbackCpuMultiplier;
|
GraphicLabel labelFallbackCpuMultiplier;
|
||||||
|
|
|
@ -30,8 +30,6 @@
|
||||||
#include "cache_manager.h"
|
#include "cache_manager.h"
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include "map_preview.h"
|
#include "map_preview.h"
|
||||||
#include "string_utils.h"
|
|
||||||
#include "network_message.h"
|
|
||||||
#include "gen_uuid.h"
|
#include "gen_uuid.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
|
@ -39,10 +37,10 @@ namespace Glest{ namespace Game{
|
||||||
|
|
||||||
using namespace ::Shared::Util;
|
using namespace ::Shared::Util;
|
||||||
|
|
||||||
const int MASTERSERVER_BROADCAST_MAX_WAIT_RESPONSE_SECONDS = 15;
|
const int MASTERSERVER_BROADCAST_MAX_WAIT_RESPONSE_SECONDS = 15;
|
||||||
const int MASTERSERVER_BROADCAST_PUBLISH_SECONDS = 6;
|
const int MASTERSERVER_BROADCAST_PUBLISH_SECONDS = 6;
|
||||||
const int BROADCAST_MAP_DELAY_SECONDS = 5;
|
const int BROADCAST_MAP_DELAY_SECONDS = 5;
|
||||||
const int BROADCAST_SETTINGS_SECONDS = 4;
|
const int BROADCAST_SETTINGS_SECONDS = 4;
|
||||||
static const char *SAVED_GAME_FILENAME = "lastCustomGameSettings.mgg";
|
static const char *SAVED_GAME_FILENAME = "lastCustomGameSettings.mgg";
|
||||||
static const char *DEFAULT_GAME_FILENAME = "data/defaultGameSetup.mgg";
|
static const char *DEFAULT_GAME_FILENAME = "data/defaultGameSetup.mgg";
|
||||||
static const char *DEFAULT_NETWORKGAME_FILENAME = "data/defaultNetworkGameSetup.mgg";
|
static const char *DEFAULT_NETWORKGAME_FILENAME = "data/defaultNetworkGameSetup.mgg";
|
||||||
|
@ -480,6 +478,26 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
||||||
checkBoxAllowInGameJoinPlayer.setVisible(allowInProgressJoin);
|
checkBoxAllowInGameJoinPlayer.setVisible(allowInProgressJoin);
|
||||||
|
|
||||||
|
|
||||||
|
labelAllowTeamUnitSharing.registerGraphicComponent(containerName,"labelAllowTeamUnitSharing");
|
||||||
|
labelAllowTeamUnitSharing.init(xoffset+410, 670, 80);
|
||||||
|
labelAllowTeamUnitSharing.setText(lang.getString("AllowTeamUnitSharing"));
|
||||||
|
labelAllowTeamUnitSharing.setVisible(true);
|
||||||
|
|
||||||
|
checkBoxAllowTeamUnitSharing.registerGraphicComponent(containerName,"checkBoxAllowTeamUnitSharing");
|
||||||
|
checkBoxAllowTeamUnitSharing.init(xoffset+600, 670);
|
||||||
|
checkBoxAllowTeamUnitSharing.setValue(false);
|
||||||
|
checkBoxAllowTeamUnitSharing.setVisible(true);
|
||||||
|
|
||||||
|
labelAllowTeamResourceSharing.registerGraphicComponent(containerName,"labelAllowTeamResourceSharing");
|
||||||
|
labelAllowTeamResourceSharing.init(xoffset+410, 640, 80);
|
||||||
|
labelAllowTeamResourceSharing.setText(lang.getString("AllowTeamResourceSharing"));
|
||||||
|
labelAllowTeamResourceSharing.setVisible(true);
|
||||||
|
|
||||||
|
checkBoxAllowTeamResourceSharing.registerGraphicComponent(containerName,"checkBoxAllowTeamResourceSharing");
|
||||||
|
checkBoxAllowTeamResourceSharing.init(xoffset+600, 640);
|
||||||
|
checkBoxAllowTeamResourceSharing.setValue(false);
|
||||||
|
checkBoxAllowTeamResourceSharing.setVisible(true);
|
||||||
|
|
||||||
|
|
||||||
// Network Pause for lagged clients
|
// Network Pause for lagged clients
|
||||||
labelNetworkPauseGameForLaggedClients.registerGraphicComponent(containerName,"labelNetworkPauseGameForLaggedClients");
|
labelNetworkPauseGameForLaggedClients.registerGraphicComponent(containerName,"labelNetworkPauseGameForLaggedClients");
|
||||||
|
@ -766,6 +784,9 @@ void MenuStateCustomGame::reloadUI() {
|
||||||
|
|
||||||
labelAllowInGameJoinPlayer.setText(lang.getString("AllowInGameJoinPlayer"));
|
labelAllowInGameJoinPlayer.setText(lang.getString("AllowInGameJoinPlayer"));
|
||||||
|
|
||||||
|
labelAllowTeamUnitSharing.setText(lang.getString("AllowTeamUnitSharing"));
|
||||||
|
labelAllowTeamResourceSharing.setText(lang.getString("AllowTeamResourceSharing"));
|
||||||
|
|
||||||
labelAISwitchTeamAcceptPercent.setText(lang.getString("AISwitchTeamAcceptPercent"));
|
labelAISwitchTeamAcceptPercent.setText(lang.getString("AISwitchTeamAcceptPercent"));
|
||||||
|
|
||||||
listBoxData.clear();
|
listBoxData.clear();
|
||||||
|
@ -1147,7 +1168,6 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||||
mapPublishingDelayTimer=time(NULL);
|
mapPublishingDelayTimer=time(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//else if (listBoxAdvanced.getSelectedItemIndex() == 1 && listBoxFogOfWar.mouseClick(x, y)) {
|
|
||||||
else if (checkBoxAdvanced.getValue() == 1 && listBoxFogOfWar.mouseClick(x, y)) {
|
else if (checkBoxAdvanced.getValue() == 1 && listBoxFogOfWar.mouseClick(x, y)) {
|
||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
MutexSafeWrapper safeMutexCLI((publishToClientsThread != NULL ? publishToClientsThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
MutexSafeWrapper safeMutexCLI((publishToClientsThread != NULL ? publishToClientsThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
@ -1185,8 +1205,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||||
needToRepublishToMasterserver = true;
|
needToRepublishToMasterserver = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true)
|
if(hasNetworkGameSettings() == true) {
|
||||||
{
|
|
||||||
needToSetChangedGameSettings = true;
|
needToSetChangedGameSettings = true;
|
||||||
lastSetChangedGameSettings = time(NULL);
|
lastSetChangedGameSettings = time(NULL);
|
||||||
}
|
}
|
||||||
|
@ -1194,6 +1213,34 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
serverInterface->setAllowInGameConnections(checkBoxAllowInGameJoinPlayer.getValue() == true);
|
serverInterface->setAllowInGameConnections(checkBoxAllowInGameJoinPlayer.getValue() == true);
|
||||||
}
|
}
|
||||||
|
else if (checkBoxAdvanced.getValue() == 1 && checkBoxAllowTeamUnitSharing.mouseClick(x, y)) {
|
||||||
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
MutexSafeWrapper safeMutexCLI((publishToClientsThread != NULL ? publishToClientsThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
|
||||||
|
|
||||||
|
if(checkBoxPublishServer.getValue() == true) {
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hasNetworkGameSettings() == true) {
|
||||||
|
needToSetChangedGameSettings = true;
|
||||||
|
lastSetChangedGameSettings = time(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (checkBoxAdvanced.getValue() == 1 && checkBoxAllowTeamResourceSharing.mouseClick(x, y)) {
|
||||||
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
MutexSafeWrapper safeMutexCLI((publishToClientsThread != NULL ? publishToClientsThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
|
||||||
|
|
||||||
|
if(checkBoxPublishServer.getValue() == true) {
|
||||||
|
needToRepublishToMasterserver = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hasNetworkGameSettings() == true) {
|
||||||
|
needToSetChangedGameSettings = true;
|
||||||
|
lastSetChangedGameSettings = time(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (checkBoxAllowNativeLanguageTechtree.mouseClick(x, y)) {
|
else if (checkBoxAllowNativeLanguageTechtree.mouseClick(x, y)) {
|
||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
MutexSafeWrapper safeMutexCLI((publishToClientsThread != NULL ? publishToClientsThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
MutexSafeWrapper safeMutexCLI((publishToClientsThread != NULL ? publishToClientsThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
@ -1949,13 +1996,10 @@ void MenuStateCustomGame::mouseMove(int x, int y, const MouseState *ms) {
|
||||||
}
|
}
|
||||||
|
|
||||||
listBoxMap.mouseMove(x, y);
|
listBoxMap.mouseMove(x, y);
|
||||||
|
|
||||||
if(checkBoxAdvanced.getValue() == 1) {
|
if(checkBoxAdvanced.getValue() == 1) {
|
||||||
listBoxFogOfWar.mouseMove(x, y);
|
listBoxFogOfWar.mouseMove(x, y);
|
||||||
checkBoxAllowObservers.mouseMove(x, y);
|
checkBoxAllowObservers.mouseMove(x, y);
|
||||||
//listBoxEnableObserverMode.mouseMove(x, y);
|
|
||||||
//listBoxEnableServerControlledAI.mouseMove(x, y);
|
|
||||||
//labelNetworkFramePeriod.mouseMove(x, y);
|
|
||||||
//listBoxNetworkFramePeriod.mouseMove(x, y);
|
|
||||||
|
|
||||||
checkBoxEnableSwitchTeamMode.mouseMove(x, y);
|
checkBoxEnableSwitchTeamMode.mouseMove(x, y);
|
||||||
listBoxAISwitchTeamAcceptPercent.mouseMove(x, y);
|
listBoxAISwitchTeamAcceptPercent.mouseMove(x, y);
|
||||||
|
@ -1964,8 +2008,10 @@ void MenuStateCustomGame::mouseMove(int x, int y, const MouseState *ms) {
|
||||||
labelNetworkPauseGameForLaggedClients.mouseMove(x, y);
|
labelNetworkPauseGameForLaggedClients.mouseMove(x, y);
|
||||||
checkBoxNetworkPauseGameForLaggedClients.mouseMove(x, y);
|
checkBoxNetworkPauseGameForLaggedClients.mouseMove(x, y);
|
||||||
|
|
||||||
//labelPathFinderType.mouseMove(x, y);
|
labelAllowTeamUnitSharing.mouseMove(x,y);
|
||||||
//listBoxPathFinderType.mouseMove(x, y);
|
checkBoxAllowTeamUnitSharing.mouseMove(x,y);
|
||||||
|
labelAllowTeamResourceSharing.mouseMove(x,y);
|
||||||
|
checkBoxAllowTeamResourceSharing.mouseMove(x,y);
|
||||||
}
|
}
|
||||||
checkBoxAllowInGameJoinPlayer.mouseMove(x, y);
|
checkBoxAllowInGameJoinPlayer.mouseMove(x, y);
|
||||||
|
|
||||||
|
@ -2060,7 +2106,6 @@ void MenuStateCustomGame::render() {
|
||||||
// START - this code ensure player title and player names don't overlap
|
// START - this code ensure player title and player names don't overlap
|
||||||
int offsetPosition=0;
|
int offsetPosition=0;
|
||||||
for(int i=0; i < GameConstants::maxPlayers; ++i) {
|
for(int i=0; i < GameConstants::maxPlayers; ++i) {
|
||||||
//const Metrics &metrics= Metrics::getInstance();
|
|
||||||
FontMetrics *fontMetrics= NULL;
|
FontMetrics *fontMetrics= NULL;
|
||||||
if(Renderer::renderText3DEnabled == false) {
|
if(Renderer::renderText3DEnabled == false) {
|
||||||
fontMetrics = labelPlayers[i].getFont()->getMetrics();
|
fontMetrics = labelPlayers[i].getFont()->getMetrics();
|
||||||
|
@ -2071,7 +2116,6 @@ void MenuStateCustomGame::render() {
|
||||||
if(fontMetrics == NULL) {
|
if(fontMetrics == NULL) {
|
||||||
throw megaglest_runtime_error("fontMetrics == NULL");
|
throw megaglest_runtime_error("fontMetrics == NULL");
|
||||||
}
|
}
|
||||||
//int curWidth = (metrics.toVirtualX(fontMetrics->getTextWidth(labelPlayers[i].getText())));
|
|
||||||
int curWidth = (fontMetrics->getTextWidth(labelPlayers[i].getText()));
|
int curWidth = (fontMetrics->getTextWidth(labelPlayers[i].getText()));
|
||||||
int newOffsetPosition = labelPlayers[i].getX() + curWidth + 2;
|
int newOffsetPosition = labelPlayers[i].getX() + curWidth + 2;
|
||||||
|
|
||||||
|
@ -2115,13 +2159,6 @@ void MenuStateCustomGame::render() {
|
||||||
// Render the player # label the player's color
|
// Render the player # label the player's color
|
||||||
Vec3f playerColor = crcPlayerTextureCache[i]->getPixmap()->getPixel3f(0, 0);
|
Vec3f playerColor = crcPlayerTextureCache[i]->getPixmap()->getPixel3f(0, 0);
|
||||||
renderer.renderLabel(&labelPlayers[i],&playerColor);
|
renderer.renderLabel(&labelPlayers[i],&playerColor);
|
||||||
|
|
||||||
// Blend the color with white so make it more readable
|
|
||||||
//Vec4f newColor(1.f, 1.f, 1.f, 0.57f);
|
|
||||||
//renderer.renderLabel(&labelPlayers[i],&newColor);
|
|
||||||
|
|
||||||
//int quadWidth = labelPlayerNames[i].getX() - labelPlayers[i].getX() - 5;
|
|
||||||
//renderer.renderTextureQuad(labelPlayers[i].getX(), labelPlayers[i].getY(), quadWidth, labelPlayers[i].getH(), crcPlayerTextureCache[i],1.0f,&playerColor);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
renderer.renderLabel(&labelPlayers[i]);
|
renderer.renderLabel(&labelPlayers[i]);
|
||||||
|
@ -2166,19 +2203,22 @@ void MenuStateCustomGame::render() {
|
||||||
renderer.renderLabel(&labelFogOfWar);
|
renderer.renderLabel(&labelFogOfWar);
|
||||||
renderer.renderLabel(&labelAllowObservers);
|
renderer.renderLabel(&labelAllowObservers);
|
||||||
renderer.renderLabel(&labelFallbackCpuMultiplier);
|
renderer.renderLabel(&labelFallbackCpuMultiplier);
|
||||||
//renderer.renderLabel(&labelPathFinderType);
|
|
||||||
|
|
||||||
renderer.renderLabel(&labelEnableSwitchTeamMode);
|
renderer.renderLabel(&labelEnableSwitchTeamMode);
|
||||||
renderer.renderLabel(&labelAISwitchTeamAcceptPercent);
|
renderer.renderLabel(&labelAISwitchTeamAcceptPercent);
|
||||||
|
|
||||||
renderer.renderListBox(&listBoxFogOfWar);
|
renderer.renderListBox(&listBoxFogOfWar);
|
||||||
renderer.renderCheckBox(&checkBoxAllowObservers);
|
renderer.renderCheckBox(&checkBoxAllowObservers);
|
||||||
//renderer.renderListBox(&listBoxEnableObserverMode);
|
|
||||||
//renderer.renderListBox(&listBoxPathFinderType);
|
|
||||||
|
|
||||||
renderer.renderCheckBox(&checkBoxEnableSwitchTeamMode);
|
renderer.renderCheckBox(&checkBoxEnableSwitchTeamMode);
|
||||||
renderer.renderListBox(&listBoxAISwitchTeamAcceptPercent);
|
renderer.renderListBox(&listBoxAISwitchTeamAcceptPercent);
|
||||||
renderer.renderListBox(&listBoxFallbackCpuMultiplier);
|
renderer.renderListBox(&listBoxFallbackCpuMultiplier);
|
||||||
|
|
||||||
|
renderer.renderLabel(&labelAllowTeamUnitSharing);
|
||||||
|
renderer.renderCheckBox(&checkBoxAllowTeamUnitSharing);
|
||||||
|
|
||||||
|
renderer.renderLabel(&labelAllowTeamResourceSharing);
|
||||||
|
renderer.renderCheckBox(&checkBoxAllowTeamResourceSharing);
|
||||||
}
|
}
|
||||||
renderer.renderLabel(&labelAllowInGameJoinPlayer);
|
renderer.renderLabel(&labelAllowInGameJoinPlayer);
|
||||||
renderer.renderCheckBox(&checkBoxAllowInGameJoinPlayer);
|
renderer.renderCheckBox(&checkBoxAllowInGameJoinPlayer);
|
||||||
|
@ -2187,7 +2227,6 @@ void MenuStateCustomGame::render() {
|
||||||
renderer.renderLabel(&labelMapFilter);
|
renderer.renderLabel(&labelMapFilter);
|
||||||
renderer.renderLabel(&labelTechTree);
|
renderer.renderLabel(&labelTechTree);
|
||||||
renderer.renderLabel(&labelControl);
|
renderer.renderLabel(&labelControl);
|
||||||
//renderer.renderLabel(&labelRMultiplier);
|
|
||||||
renderer.renderLabel(&labelFaction);
|
renderer.renderLabel(&labelFaction);
|
||||||
renderer.renderLabel(&labelTeam);
|
renderer.renderLabel(&labelTeam);
|
||||||
renderer.renderLabel(&labelMapInfo);
|
renderer.renderLabel(&labelMapInfo);
|
||||||
|
@ -2197,7 +2236,6 @@ void MenuStateCustomGame::render() {
|
||||||
renderer.renderListBox(&listBoxTileset);
|
renderer.renderListBox(&listBoxTileset);
|
||||||
renderer.renderListBox(&listBoxMapFilter);
|
renderer.renderListBox(&listBoxMapFilter);
|
||||||
renderer.renderListBox(&listBoxTechTree);
|
renderer.renderListBox(&listBoxTechTree);
|
||||||
//renderer.renderListBox(&listBoxAdvanced);
|
|
||||||
renderer.renderCheckBox(&checkBoxAdvanced);
|
renderer.renderCheckBox(&checkBoxAdvanced);
|
||||||
|
|
||||||
if(checkBoxPublishServer.getEditable())
|
if(checkBoxPublishServer.getEditable())
|
||||||
|
@ -2206,16 +2244,11 @@ void MenuStateCustomGame::render() {
|
||||||
renderer.renderLabel(&labelPublishServer);
|
renderer.renderLabel(&labelPublishServer);
|
||||||
renderer.renderLabel(&labelGameName);
|
renderer.renderLabel(&labelGameName);
|
||||||
if(checkBoxAdvanced.getValue() == 1) {
|
if(checkBoxAdvanced.getValue() == 1) {
|
||||||
//renderer.renderListBox(&listBoxEnableServerControlledAI);
|
|
||||||
//renderer.renderLabel(&labelEnableServerControlledAI);
|
|
||||||
//renderer.renderLabel(&labelNetworkFramePeriod);
|
|
||||||
//renderer.renderListBox(&listBoxNetworkFramePeriod);
|
|
||||||
renderer.renderLabel(&labelNetworkPauseGameForLaggedClients);
|
renderer.renderLabel(&labelNetworkPauseGameForLaggedClients);
|
||||||
renderer.renderCheckBox(&checkBoxNetworkPauseGameForLaggedClients);
|
renderer.renderCheckBox(&checkBoxNetworkPauseGameForLaggedClients);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//renderer.renderLabel(&labelInfo);
|
|
||||||
renderer.renderCheckBox(&checkBoxScenario);
|
renderer.renderCheckBox(&checkBoxScenario);
|
||||||
renderer.renderLabel(&labelScenario);
|
renderer.renderLabel(&labelScenario);
|
||||||
if(checkBoxScenario.getValue() == true) {
|
if(checkBoxScenario.getValue() == true) {
|
||||||
|
@ -2740,7 +2773,6 @@ void MenuStateCustomGame::update() {
|
||||||
}
|
}
|
||||||
listBoxFallbackCpuMultiplier.setEditable(true);
|
listBoxFallbackCpuMultiplier.setEditable(true);
|
||||||
checkBoxPublishServer.setEditable(true);
|
checkBoxPublishServer.setEditable(true);
|
||||||
//listBoxEnableServerControlledAI.setEditable(true);
|
|
||||||
|
|
||||||
// Masterserver always needs one network slot
|
// Masterserver always needs one network slot
|
||||||
if(this->headlessServerMode == true && hasOneNetworkSlotOpen == false) {
|
if(this->headlessServerMode == true && hasOneNetworkSlotOpen == false) {
|
||||||
|
@ -2773,7 +2805,6 @@ void MenuStateCustomGame::update() {
|
||||||
|
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
serverInterface->setPublishEnabled(checkBoxPublishServer.getValue() == true);
|
serverInterface->setPublishEnabled(checkBoxPublishServer.getValue() == true);
|
||||||
//listBoxEnableServerControlledAI.setEditable(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool republishToMaster = (difftime((long int)time(NULL),lastMasterserverPublishing) >= MASTERSERVER_BROADCAST_PUBLISH_SECONDS);
|
bool republishToMaster = (difftime((long int)time(NULL),lastMasterserverPublishing) >= MASTERSERVER_BROADCAST_PUBLISH_SECONDS);
|
||||||
|
@ -3470,6 +3501,24 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
|
||||||
gameSettings->setFlagTypes1(valueFlags1);
|
gameSettings->setFlagTypes1(valueFlags1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(checkBoxAllowTeamUnitSharing.getValue() == true) {
|
||||||
|
valueFlags1 |= ft1_allow_shared_team_units;
|
||||||
|
gameSettings->setFlagTypes1(valueFlags1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
valueFlags1 &= ~ft1_allow_shared_team_units;
|
||||||
|
gameSettings->setFlagTypes1(valueFlags1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(checkBoxAllowTeamResourceSharing.getValue() == true) {
|
||||||
|
valueFlags1 |= ft1_allow_shared_team_resources;
|
||||||
|
gameSettings->setFlagTypes1(valueFlags1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
valueFlags1 &= ~ft1_allow_shared_team_resources;
|
||||||
|
gameSettings->setFlagTypes1(valueFlags1);
|
||||||
|
}
|
||||||
|
|
||||||
if(Config::getInstance().getBool("EnableNetworkGameSynchChecks","false") == true) {
|
if(Config::getInstance().getBool("EnableNetworkGameSynchChecks","false") == true) {
|
||||||
//printf("*WARNING* - EnableNetworkGameSynchChecks is enabled\n");
|
//printf("*WARNING* - EnableNetworkGameSynchChecks is enabled\n");
|
||||||
|
|
||||||
|
@ -3991,6 +4040,10 @@ void MenuStateCustomGame::setupUIFromGameSettings(const GameSettings &gameSettin
|
||||||
listBoxFallbackCpuMultiplier.setSelectedItemIndex(gameSettings.getFallbackCpuMultiplier());
|
listBoxFallbackCpuMultiplier.setSelectedItemIndex(gameSettings.getFallbackCpuMultiplier());
|
||||||
|
|
||||||
checkBoxAllowInGameJoinPlayer.setValue((gameSettings.getFlagTypes1() & ft1_allow_in_game_joining) == ft1_allow_in_game_joining ? true : false);
|
checkBoxAllowInGameJoinPlayer.setValue((gameSettings.getFlagTypes1() & ft1_allow_in_game_joining) == ft1_allow_in_game_joining ? true : false);
|
||||||
|
|
||||||
|
checkBoxAllowTeamUnitSharing.setValue((gameSettings.getFlagTypes1() & ft1_allow_shared_team_units) == ft1_allow_shared_team_units ? true : false);
|
||||||
|
checkBoxAllowTeamResourceSharing.setValue((gameSettings.getFlagTypes1() & ft1_allow_shared_team_resources) == ft1_allow_shared_team_resources ? true : false);
|
||||||
|
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
if(serverInterface != NULL) {
|
if(serverInterface != NULL) {
|
||||||
serverInterface->setAllowInGameConnections(checkBoxAllowInGameJoinPlayer.getValue() == true);
|
serverInterface->setAllowInGameConnections(checkBoxAllowInGameJoinPlayer.getValue() == true);
|
||||||
|
|
|
@ -54,8 +54,6 @@ private:
|
||||||
GraphicLabel labelTechTree;
|
GraphicLabel labelTechTree;
|
||||||
GraphicLabel labelTileset;
|
GraphicLabel labelTileset;
|
||||||
GraphicLabel labelMapInfo;
|
GraphicLabel labelMapInfo;
|
||||||
//GraphicLabel labelEnableObserverMode;
|
|
||||||
//GraphicLabel labelEnableServerControlledAI;
|
|
||||||
GraphicLabel labelLocalGameVersion;
|
GraphicLabel labelLocalGameVersion;
|
||||||
GraphicLabel labelLocalIP;
|
GraphicLabel labelLocalIP;
|
||||||
GraphicLabel labelGameName;
|
GraphicLabel labelGameName;
|
||||||
|
@ -64,8 +62,6 @@ private:
|
||||||
GraphicListBox listBoxFogOfWar;
|
GraphicListBox listBoxFogOfWar;
|
||||||
GraphicListBox listBoxTechTree;
|
GraphicListBox listBoxTechTree;
|
||||||
GraphicListBox listBoxTileset;
|
GraphicListBox listBoxTileset;
|
||||||
//GraphicListBox listBoxEnableObserverMode;
|
|
||||||
//GraphicListBox listBoxEnableServerControlledAI;
|
|
||||||
|
|
||||||
vector<string> mapFiles;
|
vector<string> mapFiles;
|
||||||
vector<string> playerSortedMaps[GameConstants::maxPlayers+1];
|
vector<string> playerSortedMaps[GameConstants::maxPlayers+1];
|
||||||
|
@ -86,31 +82,21 @@ private:
|
||||||
GraphicButton buttonClearBlockedPlayers;
|
GraphicButton buttonClearBlockedPlayers;
|
||||||
|
|
||||||
GraphicLabel labelPublishServer;
|
GraphicLabel labelPublishServer;
|
||||||
//GraphicListBox listBoxPublishServer;
|
|
||||||
GraphicCheckBox checkBoxPublishServer;
|
GraphicCheckBox checkBoxPublishServer;
|
||||||
|
|
||||||
GraphicMessageBox mainMessageBox;
|
GraphicMessageBox mainMessageBox;
|
||||||
int mainMessageBoxState;
|
int mainMessageBoxState;
|
||||||
|
|
||||||
//GraphicListBox listBoxNetworkFramePeriod;
|
|
||||||
//GraphicLabel labelNetworkFramePeriod;
|
|
||||||
|
|
||||||
GraphicLabel labelNetworkPauseGameForLaggedClients;
|
GraphicLabel labelNetworkPauseGameForLaggedClients;
|
||||||
//GraphicListBox listBoxNetworkPauseGameForLaggedClients;
|
|
||||||
GraphicCheckBox checkBoxNetworkPauseGameForLaggedClients;
|
GraphicCheckBox checkBoxNetworkPauseGameForLaggedClients;
|
||||||
|
|
||||||
//GraphicLabel labelPathFinderType;
|
|
||||||
//GraphicListBox listBoxPathFinderType;
|
|
||||||
|
|
||||||
GraphicLabel labelMapFilter;
|
GraphicLabel labelMapFilter;
|
||||||
GraphicListBox listBoxMapFilter;
|
GraphicListBox listBoxMapFilter;
|
||||||
|
|
||||||
GraphicLabel labelAdvanced;
|
GraphicLabel labelAdvanced;
|
||||||
//GraphicListBox listBoxAdvanced;
|
|
||||||
GraphicCheckBox checkBoxAdvanced;
|
GraphicCheckBox checkBoxAdvanced;
|
||||||
|
|
||||||
GraphicLabel labelAllowObservers;
|
GraphicLabel labelAllowObservers;
|
||||||
//GraphicListBox listBoxAllowObservers;
|
|
||||||
GraphicCheckBox checkBoxAllowObservers;
|
GraphicCheckBox checkBoxAllowObservers;
|
||||||
|
|
||||||
GraphicLabel *activeInputLabel;
|
GraphicLabel *activeInputLabel;
|
||||||
|
@ -119,7 +105,6 @@ private:
|
||||||
GraphicListBox listBoxPlayerStatus;
|
GraphicListBox listBoxPlayerStatus;
|
||||||
|
|
||||||
GraphicLabel labelEnableSwitchTeamMode;
|
GraphicLabel labelEnableSwitchTeamMode;
|
||||||
//GraphicListBox listBoxEnableSwitchTeamMode;
|
|
||||||
GraphicCheckBox checkBoxEnableSwitchTeamMode;
|
GraphicCheckBox checkBoxEnableSwitchTeamMode;
|
||||||
|
|
||||||
GraphicLabel labelAISwitchTeamAcceptPercent;
|
GraphicLabel labelAISwitchTeamAcceptPercent;
|
||||||
|
@ -130,12 +115,20 @@ private:
|
||||||
GraphicLabel labelAllowInGameJoinPlayer;
|
GraphicLabel labelAllowInGameJoinPlayer;
|
||||||
GraphicCheckBox checkBoxAllowInGameJoinPlayer;
|
GraphicCheckBox checkBoxAllowInGameJoinPlayer;
|
||||||
|
|
||||||
|
GraphicLabel labelAllowTeamUnitSharing;
|
||||||
|
GraphicCheckBox checkBoxAllowTeamUnitSharing;
|
||||||
|
|
||||||
|
GraphicLabel labelAllowTeamResourceSharing;
|
||||||
|
GraphicCheckBox checkBoxAllowTeamResourceSharing;
|
||||||
|
|
||||||
|
|
||||||
GraphicLabel labelAllowNativeLanguageTechtree;
|
GraphicLabel labelAllowNativeLanguageTechtree;
|
||||||
GraphicCheckBox checkBoxAllowNativeLanguageTechtree;
|
GraphicCheckBox checkBoxAllowNativeLanguageTechtree;
|
||||||
|
|
||||||
GraphicCheckBox checkBoxScenario;
|
GraphicCheckBox checkBoxScenario;
|
||||||
GraphicLabel labelScenario;
|
GraphicLabel labelScenario;
|
||||||
GraphicListBox listBoxScenario;
|
GraphicListBox listBoxScenario;
|
||||||
|
|
||||||
vector<string> scenarioFiles;
|
vector<string> scenarioFiles;
|
||||||
ScenarioInfo scenarioInfo;
|
ScenarioInfo scenarioInfo;
|
||||||
vector<string> dirList;
|
vector<string> dirList;
|
||||||
|
@ -226,6 +219,7 @@ private:
|
||||||
std::auto_ptr<TechTree> techTree;
|
std::auto_ptr<TechTree> techTree;
|
||||||
|
|
||||||
string gameUUID;
|
string gameUUID;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MenuStateCustomGame(Program *program, MainMenu *mainMenu ,
|
MenuStateCustomGame(Program *program, MainMenu *mainMenu ,
|
||||||
bool openNetworkSlots= false, ParentMenuState parentMenuState=pNewGame,
|
bool openNetworkSlots= false, ParentMenuState parentMenuState=pNewGame,
|
||||||
|
|
Loading…
Reference in New Issue