- added new lua functions:
triggeredCellEventUnitId() showMarker(int flashCount, int factionIndex, string note, string textureFile,Vec2i pos) 1. The first one can be called in a cell trigger event and tell you which unit triggered the event 2. The second flashes a position in the minimap
This commit is contained in:
parent
87c3a11876
commit
0180aa6bba
|
@ -1844,7 +1844,7 @@ void Game::updateNetworkHighligtedCells() {
|
|||
for(int idx = highlightedCells.size()-1; idx >= 0; idx--) {
|
||||
MarkedCell *mc = &highlightedCells[idx];
|
||||
mc->decrementAliveCount();
|
||||
if(mc->getAliveCount()<0){
|
||||
if(mc->getAliveCount() < 0) {
|
||||
highlightedCells.erase(highlightedCells.begin()+idx);
|
||||
}
|
||||
}
|
||||
|
@ -1869,17 +1869,21 @@ void Game::updateNetworkHighligtedCells() {
|
|||
}
|
||||
|
||||
void Game::addOrReplaceInHighlightedCells(MarkedCell mc){
|
||||
for(int i = highlightedCells.size()-1; i >= 0; i--) {
|
||||
MarkedCell *currentMc = &highlightedCells[i];
|
||||
if(currentMc->getFactionIndex()==mc.getFactionIndex()){
|
||||
highlightedCells.erase(highlightedCells.begin()+i);
|
||||
if(mc.getFactionIndex() >= 0) {
|
||||
for(int i = highlightedCells.size()-1; i >= 0; i--) {
|
||||
MarkedCell *currentMc = &highlightedCells[i];
|
||||
if(currentMc->getFactionIndex() == mc.getFactionIndex()) {
|
||||
highlightedCells.erase(highlightedCells.begin()+i);
|
||||
}
|
||||
}
|
||||
}
|
||||
mc.setAliveCount(200);
|
||||
if(mc.getAliveCount() <= 0) {
|
||||
mc.setAliveCount(200);
|
||||
}
|
||||
highlightedCells.push_back(mc);
|
||||
CoreData &coreData= CoreData::getInstance();
|
||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||
if(mc.getFaction() != NULL && mc.getFaction()->getTeam() == getWorld()->getThisFaction()->getTeam()) {
|
||||
if(mc.getFaction() == NULL || (mc.getFaction()->getTeam() == getWorld()->getThisFaction()->getTeam())) {
|
||||
soundRenderer.playFx(coreData.getMarkerSound());
|
||||
}
|
||||
}
|
||||
|
@ -2324,6 +2328,22 @@ void Game::removeCellMarker(Vec2i surfaceCellPos, const Faction *faction) {
|
|||
//renderer.updateMarkedCellScreenPosQuadCache(surfaceCellPos);
|
||||
renderer.forceQuadCacheUpdate();
|
||||
}
|
||||
void Game::showMarker(Vec2i cellPos, MarkedCell cellData) {
|
||||
//setMarker = true;
|
||||
//if(setMarker) {
|
||||
//Vec2i targetPos = cellData.targetPos;
|
||||
//Vec2i screenPos(x,y-60);
|
||||
//Renderer &renderer= Renderer::getInstance();
|
||||
//renderer.computePosition(screenPos, targetPos);
|
||||
//Vec2i surfaceCellPos = map->toSurfCoords(targetPos);
|
||||
|
||||
//MarkedCell mc(targetPos,world.getThisFaction(),"none",world.getThisFaction()->getStartLocationIndex());
|
||||
addOrReplaceInHighlightedCells(cellData);
|
||||
|
||||
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
|
||||
gameNetworkInterface->sendHighlightCellMessage(cellData.getTargetPos(),cellData.getFactionIndex());
|
||||
//}
|
||||
}
|
||||
|
||||
void Game::mouseDownLeft(int x, int y) {
|
||||
if(this->masterserverMode == true) {
|
||||
|
|
|
@ -302,6 +302,7 @@ public:
|
|||
|
||||
void addCellMarker(Vec2i cellPos, MarkedCell cellData);
|
||||
void removeCellMarker(Vec2i surfaceCellPos, const Faction *faction);
|
||||
void showMarker(Vec2i cellPos, MarkedCell cellData);
|
||||
|
||||
private:
|
||||
//render
|
||||
|
|
|
@ -208,6 +208,7 @@ ScriptManager::ScriptManager() {
|
|||
gameWon = false;
|
||||
currentTimerTriggeredEventId = 0;
|
||||
currentCellTriggeredEventId = 0;
|
||||
currentCellTriggeredEventUnitId = 0;
|
||||
currentEventId = 0;
|
||||
inCellTriggerEvent = false;
|
||||
rootNode = NULL;
|
||||
|
@ -315,6 +316,8 @@ void ScriptManager::init(World* world, GameCamera *gameCamera, const XmlNode *ro
|
|||
luaScript.registerFunction(getCellTriggeredEventAreaEntryUnitId, "triggeredEventAreaEntryUnitId");
|
||||
luaScript.registerFunction(getCellTriggeredEventAreaExitUnitId, "triggeredEventAreaExitUnitId");
|
||||
|
||||
luaScript.registerFunction(getCellTriggeredEventUnitId, "triggeredCellEventUnitId");
|
||||
|
||||
luaScript.registerFunction(setRandomGenInit, "setRandomGenInit");
|
||||
luaScript.registerFunction(getRandomGen, "getRandomGen");
|
||||
luaScript.registerFunction(getWorldFrameCount, "getWorldFrameCount");
|
||||
|
@ -326,6 +329,7 @@ void ScriptManager::init(World* world, GameCamera *gameCamera, const XmlNode *ro
|
|||
|
||||
luaScript.registerFunction(addCellMarker, "addCellMarker");
|
||||
luaScript.registerFunction(removeCellMarker, "removeCellMarker");
|
||||
luaScript.registerFunction(showMarker, "showMarker");
|
||||
|
||||
luaScript.registerFunction(getUnitFaction, "unitFaction");
|
||||
luaScript.registerFunction(getUnitName, "unitName");
|
||||
|
@ -365,6 +369,8 @@ void ScriptManager::init(World* world, GameCamera *gameCamera, const XmlNode *ro
|
|||
luaScript.registerFunction(isFreeCellsOrHasUnit, "isFreeCellsOrHasUnit");
|
||||
luaScript.registerFunction(isFreeCells, "isFreeCells");
|
||||
|
||||
luaScript.registerFunction(getHumanFactionId, "humanFaction");
|
||||
|
||||
//load code
|
||||
for(int i= 0; i<scenario->getScriptCount(); ++i){
|
||||
const Script* script= scenario->getScript(i);
|
||||
|
@ -626,6 +632,7 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
|||
bool triggerEvent = false;
|
||||
currentCellTriggeredEventAreaEntryUnitId = 0;
|
||||
currentCellTriggeredEventAreaExitUnitId = 0;
|
||||
currentCellTriggeredEventUnitId = 0;
|
||||
|
||||
switch(event.type) {
|
||||
case ctet_Unit:
|
||||
|
@ -646,6 +653,9 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
|||
__FILE__,__FUNCTION__,__LINE__,movingUnit->getId(), event.type,movingUnit->getPos().getString().c_str(),event.sourceId,event.destId, event.destPos.getString().c_str(), destUnit->getPos().getString().c_str(),srcInDst);
|
||||
}
|
||||
triggerEvent = srcInDst;
|
||||
if(triggerEvent == true) {
|
||||
currentCellTriggeredEventUnitId = movingUnit->getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -661,6 +671,10 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
triggerEvent = srcInDst;
|
||||
|
||||
if(triggerEvent == true) {
|
||||
currentCellTriggeredEventUnitId = movingUnit->getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -681,6 +695,9 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
triggerEvent = srcInDst;
|
||||
if(triggerEvent == true) {
|
||||
currentCellTriggeredEventUnitId = movingUnit->getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -703,6 +720,9 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
|||
__FILE__,__FUNCTION__,__LINE__,movingUnit->getId(),event.type,movingUnit->getPos().getString().c_str(),event.sourceId,event.destId,event.destPos.getString().c_str(),destUnit->getPos().getString().c_str(),srcInDst);
|
||||
}
|
||||
triggerEvent = srcInDst;
|
||||
if(triggerEvent == true) {
|
||||
currentCellTriggeredEventUnitId = movingUnit->getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -717,6 +737,9 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
triggerEvent = srcInDst;
|
||||
if(triggerEvent == true) {
|
||||
currentCellTriggeredEventUnitId = movingUnit->getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -724,7 +747,7 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
|||
case ctet_FactionAreaPos:
|
||||
{
|
||||
if(movingUnit->getFactionIndex() == event.sourceId) {
|
||||
//printf("ctet_FactionPos event.destPos = [%s], movingUnit->getPos() [%s]\n",event.destPos.getString().c_str(),movingUnit->getPos().getString().c_str());
|
||||
//if(event.sourceId == 1) printf("ctet_FactionPos event.destPos = [%s], movingUnit->getPos() [%s] Unit id = %d\n",event.destPos.getString().c_str(),movingUnit->getPos().getString().c_str(),movingUnit->getId());
|
||||
|
||||
bool srcInDst = false;
|
||||
for(int x = event.destPos.x; srcInDst == false && x <= event.destPosEnd.x; ++x) {
|
||||
|
@ -737,6 +760,10 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
|||
}
|
||||
}
|
||||
triggerEvent = srcInDst;
|
||||
if(triggerEvent == true) {
|
||||
//printf("!!!UNIT IN AREA!!! Faction area pos, moving unit faction= %d, trigger faction = %d, unit id = %d\n",movingUnit->getFactionIndex(),event.sourceId,movingUnit->getId());
|
||||
currentCellTriggeredEventUnitId = movingUnit->getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -761,6 +788,9 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
|||
}
|
||||
}
|
||||
triggerEvent = srcInDst;
|
||||
if(triggerEvent == true) {
|
||||
currentCellTriggeredEventUnitId = movingUnit->getId();
|
||||
}
|
||||
}
|
||||
// If unit is already in cell range check if they are leaving?
|
||||
else {
|
||||
|
@ -777,6 +807,10 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
|||
}
|
||||
}
|
||||
triggerEvent = (srcInDst == false);
|
||||
if(triggerEvent == true) {
|
||||
currentCellTriggeredEventUnitId = movingUnit->getId();
|
||||
}
|
||||
|
||||
if(triggerEvent == true) {
|
||||
currentCellTriggeredEventAreaExitUnitId = movingUnit->getId();
|
||||
|
||||
|
@ -1427,6 +1461,12 @@ void ScriptManager::removeCellMarker(Vec2i pos, int factionIndex) {
|
|||
return world->removeCellMarker(pos,factionIndex);
|
||||
}
|
||||
|
||||
void ScriptManager::showMarker(Vec2i pos, int factionIndex, const string ¬e, const string &textureFile, int flashCount) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||
return world->showMarker(pos,factionIndex, note, textureFile, flashCount);
|
||||
}
|
||||
|
||||
int ScriptManager::getIsUnitAlive(int unitId) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||
|
@ -1476,6 +1516,10 @@ int ScriptManager::getCellTriggeredEventAreaExitUnitId() {
|
|||
return currentCellTriggeredEventAreaExitUnitId;
|
||||
}
|
||||
|
||||
int ScriptManager::getCellTriggeredEventUnitId() {
|
||||
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||
return currentCellTriggeredEventUnitId;
|
||||
}
|
||||
|
||||
void ScriptManager::setRandomGenInit(int seed) {
|
||||
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||
|
@ -1630,6 +1674,12 @@ int ScriptManager::isFreeCells(int unitSize, int field, Vec2i pos) {
|
|||
return result;
|
||||
}
|
||||
|
||||
int ScriptManager::getHumanFactionId() {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||
return this->world->getThisFactionIndex();
|
||||
}
|
||||
|
||||
// ========================== lua callbacks ===============================================
|
||||
|
||||
int ScriptManager::showMessage(LuaHandle* luaHandle){
|
||||
|
@ -2081,6 +2131,32 @@ int ScriptManager::removeCellMarker(LuaHandle* luaHandle){
|
|||
return luaArguments.getReturnCount();
|
||||
}
|
||||
|
||||
int ScriptManager::showMarker(LuaHandle* luaHandle){
|
||||
LuaArguments luaArguments(luaHandle);
|
||||
|
||||
int flashCount = luaArguments.getInt(-5);
|
||||
//printf("LUA addCellMarker --> START\n");
|
||||
|
||||
int factionIndex = luaArguments.getInt(-4);
|
||||
|
||||
//printf("LUA addCellMarker --> START 1\n");
|
||||
|
||||
Vec2i pos = luaArguments.getVec2i(-1);
|
||||
|
||||
//printf("LUA addCellMarker --> START 2\n");
|
||||
|
||||
string note = luaArguments.getString(-3);
|
||||
|
||||
//printf("LUA addCellMarker --> START 3\n");
|
||||
|
||||
string texture = luaArguments.getString(-2);
|
||||
|
||||
//printf("LUA addCellMarker --> faction [%d] pos [%s] note [%s] texture [%s]\n",factionIndex,pos.getString().c_str(),note.c_str(),texture.c_str());
|
||||
|
||||
thisScriptManager->showMarker(pos,factionIndex,note,texture,flashCount);
|
||||
return luaArguments.getReturnCount();
|
||||
}
|
||||
|
||||
int ScriptManager::getUnitFaction(LuaHandle* luaHandle){
|
||||
LuaArguments luaArguments(luaHandle);
|
||||
int factionIndex= thisScriptManager->getUnitFaction(luaArguments.getInt(-1));
|
||||
|
@ -2136,6 +2212,12 @@ int ScriptManager::getCellTriggeredEventAreaExitUnitId(LuaHandle* luaHandle){
|
|||
return luaArguments.getReturnCount();
|
||||
}
|
||||
|
||||
int ScriptManager::getCellTriggeredEventUnitId(LuaHandle* luaHandle){
|
||||
LuaArguments luaArguments(luaHandle);
|
||||
luaArguments.returnInt(thisScriptManager->getCellTriggeredEventUnitId());
|
||||
return luaArguments.getReturnCount();
|
||||
}
|
||||
|
||||
int ScriptManager::setRandomGenInit(LuaHandle* luaHandle){
|
||||
LuaArguments luaArguments(luaHandle);
|
||||
thisScriptManager->setRandomGenInit(luaArguments.getInt(-1));
|
||||
|
@ -2570,6 +2652,13 @@ int ScriptManager::isFreeCells(LuaHandle* luaHandle) {
|
|||
return luaArguments.getReturnCount();
|
||||
}
|
||||
|
||||
int ScriptManager::getHumanFactionId(LuaHandle* luaHandle) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
LuaArguments luaArguments(luaHandle);
|
||||
luaArguments.returnInt(thisScriptManager->getHumanFactionId());
|
||||
return luaArguments.getReturnCount();
|
||||
}
|
||||
|
||||
void ScriptManager::saveGame(XmlNode *rootNode) {
|
||||
std::map<string,string> mapTagReplacements;
|
||||
XmlNode *scriptManagerNode = rootNode->addChild("ScriptManager");
|
||||
|
|
|
@ -185,6 +185,7 @@ private:
|
|||
|
||||
int currentTimerTriggeredEventId;
|
||||
int currentCellTriggeredEventId;
|
||||
int currentCellTriggeredEventUnitId;
|
||||
|
||||
int currentCellTriggeredEventAreaEntryUnitId;
|
||||
int currentCellTriggeredEventAreaExitUnitId;
|
||||
|
@ -306,6 +307,8 @@ private:
|
|||
int getCellTriggeredEventAreaEntryUnitId();
|
||||
int getCellTriggeredEventAreaExitUnitId();
|
||||
|
||||
int getCellTriggeredEventUnitId();
|
||||
|
||||
void setRandomGenInit(int seed);
|
||||
int getRandomGen(int minVal, int maxVal);
|
||||
int getWorldFrameCount();
|
||||
|
@ -335,6 +338,8 @@ private:
|
|||
void addCellMarker(Vec2i pos, int factionIndex, const string ¬e, const string &textureFile);
|
||||
void removeCellMarker(Vec2i pos, int factionIndex);
|
||||
|
||||
void showMarker(Vec2i pos, int factionIndex, const string ¬e, const string &textureFile, int flashCount);
|
||||
|
||||
const string &getLastDeadUnitName();
|
||||
int getLastDeadUnitId();
|
||||
int getLastDeadUnitCauseOfDeath();
|
||||
|
@ -361,6 +366,7 @@ private:
|
|||
int isFreeCellsOrHasUnit(int field, int unitId,Vec2i pos);
|
||||
int isFreeCells(int unitSize, int field,Vec2i pos);
|
||||
|
||||
int getHumanFactionId();
|
||||
|
||||
//callbacks, commands
|
||||
static int networkShowMessageForFaction(LuaHandle* luaHandle);
|
||||
|
@ -435,6 +441,8 @@ private:
|
|||
static int getCellTriggeredEventAreaEntryUnitId(LuaHandle* luaHandle);
|
||||
static int getCellTriggeredEventAreaExitUnitId(LuaHandle* luaHandle);
|
||||
|
||||
static int getCellTriggeredEventUnitId(LuaHandle* luaHandle);
|
||||
|
||||
static int setRandomGenInit(LuaHandle* luaHandle);
|
||||
static int getRandomGen(LuaHandle* luaHandle);
|
||||
static int getWorldFrameCount(LuaHandle* luaHandle);
|
||||
|
@ -461,6 +469,8 @@ private:
|
|||
static int addCellMarker(LuaHandle* luaHandle);
|
||||
static int removeCellMarker(LuaHandle* luaHandle);
|
||||
|
||||
static int showMarker(LuaHandle* luaHandle);
|
||||
|
||||
static int getLastDeadUnitName(LuaHandle* luaHandle);
|
||||
static int getLastDeadUnitId(LuaHandle* luaHandle);
|
||||
static int getLastDeadUnitCauseOfDeath(LuaHandle* luaHandle);
|
||||
|
@ -491,6 +501,8 @@ private:
|
|||
static int isFreeCellsOrHasUnit(LuaHandle* luaHandle);
|
||||
static int isFreeCells(LuaHandle* luaHandle);
|
||||
|
||||
static int getHumanFactionId(LuaHandle* luaHandle);
|
||||
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -5926,11 +5926,14 @@ void Renderer::renderHighlightedCellsOnMinimap() {
|
|||
static_cast<float>(mw)/ pixmap->getW()/2,
|
||||
static_cast<float>(mh)/ pixmap->getH()/2);
|
||||
|
||||
for(int i=0;i<highlightedCells->size();i++) {
|
||||
for(int i = 0;i < highlightedCells->size(); i++) {
|
||||
const MarkedCell *mc=&highlightedCells->at(i);
|
||||
if(mc->getFaction() != NULL && mc->getFaction()->getTeam() == game->getWorld()->getThisFaction()->getTeam()) {
|
||||
if(mc->getFaction() == NULL || (mc->getFaction()->getTeam() == game->getWorld()->getThisFaction()->getTeam())) {
|
||||
const Texture2D *texture= game->getHighlightCellTexture();
|
||||
Vec3f color= mc->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0, 0);
|
||||
Vec3f color(MarkedCell::static_system_marker_color);
|
||||
if(mc->getFaction() != NULL) {
|
||||
color= mc->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0, 0);
|
||||
}
|
||||
float alpha = 0.49f+0.5f/(mc->getAliveCount()%15);
|
||||
Vec2i pos=mc->getTargetPos();
|
||||
if(texture!=NULL){
|
||||
|
|
|
@ -3213,18 +3213,28 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
|
|||
listBoxTeams[i].setSelectedItem(intToStr(GameConstants::maxPlayers + fpt_Observer));
|
||||
}
|
||||
else if(listBoxTeams[i].getSelectedItem() == intToStr(GameConstants::maxPlayers + fpt_Observer)) {
|
||||
if(lastSelectedTeamIndex[i] >= 0 && lastSelectedTeamIndex[i] + 1 != (GameConstants::maxPlayers + fpt_Observer)) {
|
||||
if(lastSelectedTeamIndex[i] == 0) {
|
||||
lastSelectedTeamIndex[i] = GameConstants::maxPlayers-1;
|
||||
}
|
||||
else if(lastSelectedTeamIndex[i] == GameConstants::maxPlayers-1) {
|
||||
lastSelectedTeamIndex[i] = 0;
|
||||
}
|
||||
|
||||
listBoxTeams[i].setSelectedItemIndex(lastSelectedTeamIndex[i]);
|
||||
//printf("Line: %d lastSelectedTeamIndex[i] = %d \n",__LINE__,lastSelectedTeamIndex[i]);
|
||||
|
||||
if((listBoxControls[i].getSelectedItemIndex() == ctCpuEasy || listBoxControls[i].getSelectedItemIndex() == ctCpu ||
|
||||
listBoxControls[i].getSelectedItemIndex() == ctCpuUltra || listBoxControls[i].getSelectedItemIndex() == ctCpuMega) &&
|
||||
checkBoxScenario.getValue() == true) {
|
||||
|
||||
}
|
||||
else {
|
||||
listBoxTeams[i].setSelectedItem(intToStr(1));
|
||||
if(lastSelectedTeamIndex[i] >= 0 && lastSelectedTeamIndex[i] + 1 != (GameConstants::maxPlayers + fpt_Observer)) {
|
||||
if(lastSelectedTeamIndex[i] == 0) {
|
||||
lastSelectedTeamIndex[i] = GameConstants::maxPlayers-1;
|
||||
}
|
||||
else if(lastSelectedTeamIndex[i] == GameConstants::maxPlayers-1) {
|
||||
lastSelectedTeamIndex[i] = 0;
|
||||
}
|
||||
|
||||
listBoxTeams[i].setSelectedItemIndex(lastSelectedTeamIndex[i]);
|
||||
}
|
||||
else {
|
||||
listBoxTeams[i].setSelectedItem(intToStr(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4317,6 +4327,11 @@ void MenuStateCustomGame::processScenario() {
|
|||
if(listBoxTeams[i].getSelectedItemIndex() + 1 != (GameConstants::maxPlayers + fpt_Observer)) {
|
||||
lastSelectedTeamIndex[i] = listBoxTeams[i].getSelectedItemIndex();
|
||||
}
|
||||
// Alow Neutral cpu players
|
||||
else if(listBoxControls[i].getSelectedItemIndex() == ctCpuEasy || listBoxControls[i].getSelectedItemIndex() == ctCpu ||
|
||||
listBoxControls[i].getSelectedItemIndex() == ctCpuUltra || listBoxControls[i].getSelectedItemIndex() == ctCpuMega) {
|
||||
lastSelectedTeamIndex[i] = listBoxTeams[i].getSelectedItemIndex();
|
||||
}
|
||||
}
|
||||
else {
|
||||
lastSelectedTeamIndex[i] = -1;
|
||||
|
|
|
@ -1342,6 +1342,31 @@ void World::removeCellMarker(Vec2i pos, int factionIndex) {
|
|||
game->removeCellMarker(surfaceCellPos, faction);
|
||||
}
|
||||
|
||||
void World::showMarker(Vec2i pos, int factionIndex, const string ¬e, const string textureFile, int flashCount) {
|
||||
//Vec2i surfaceCellPos = map.toSurfCoords(pos);
|
||||
//Vec2i surfaceCellPos = pos;
|
||||
const Faction *faction = NULL;
|
||||
if(factionIndex >= 0) {
|
||||
faction = this->getFaction(factionIndex);
|
||||
}
|
||||
|
||||
Vec2i surfaceCellPos = map.toSurfCoords(pos);
|
||||
SurfaceCell *sc = map.getSurfaceCell(surfaceCellPos);
|
||||
if(sc == NULL) {
|
||||
throw megaglest_runtime_error("sc == NULL");
|
||||
}
|
||||
Vec3f vertex = sc->getVertex();
|
||||
Vec2i targetPos(vertex.x,vertex.z);
|
||||
|
||||
//printf("pos [%s] scPos [%s][%p] targetPos [%s]\n",pos.getString().c_str(),surfaceCellPos.getString().c_str(),sc,targetPos.getString().c_str());
|
||||
|
||||
MarkedCell mc(targetPos,faction,note,(faction != NULL ? faction->getStartLocationIndex() : -1));
|
||||
if(flashCount > 0) {
|
||||
mc.setAliveCount(flashCount);
|
||||
}
|
||||
game->showMarker(surfaceCellPos, mc);
|
||||
}
|
||||
|
||||
int World::getUnitFactionIndex(int unitId) {
|
||||
Unit* unit= findUnitById(unitId);
|
||||
if(unit == NULL) {
|
||||
|
|
|
@ -248,6 +248,7 @@ public:
|
|||
|
||||
void addCellMarker(Vec2i pos, int factionIndex, const string ¬e, const string textureFile);
|
||||
void removeCellMarker(Vec2i pos, int factionIndex);
|
||||
void showMarker(Vec2i pos, int factionIndex, const string ¬e, const string textureFile,int flashCount);
|
||||
|
||||
int getUnitFactionIndex(int unitId);
|
||||
const string getUnitName(int unitId);
|
||||
|
|
Loading…
Reference in New Issue