- added lua functions to add / remove cell markers:

addCellMarker(0,'test from scenario!','',cellMarker)
param1=factionindex
param2=cell hint
param3=empty string
param4=cellPosition

removeCellMarker(0,{46,13})
param1=factionindex
param2=cellPosition
This commit is contained in:
Mark Vejvoda 2012-09-25 07:05:52 +00:00
parent 75011d84d5
commit 7c0e10684a
18 changed files with 352 additions and 79 deletions

View File

@ -110,7 +110,7 @@ void Logger::loadLoadingScreen(string filepath) {
}
else {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] filepath = [%s]\n",__FILE__,__FUNCTION__,__LINE__,filepath.c_str());
loadingTexture = Renderer::findFactionLogoTexture(filepath);
loadingTexture = Renderer::findTexture(filepath);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
}

View File

@ -112,6 +112,7 @@ Game::Game() : ProgramState(NULL) {
lastRenderLog2d=0;
playerIndexDisconnect=0;
tickCount=0;
currentCameraFollowUnit=NULL;
popupMenu.setEnabled(false);
popupMenu.setVisible(false);
@ -242,6 +243,7 @@ void Game::resetMembers() {
camUpButtonDown=false;
camDownButtonDown=false;
currentCameraFollowUnit=NULL;
currentAmbientSound=NULL;
//printf("In [%s:%s] Line: %d currentAmbientSound = [%p]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,currentAmbientSound);
@ -440,7 +442,7 @@ Texture2D * Game::findFactionLogoTexture(const GameSettings *settings, Logger *l
logoFilename = Game::findFactionLogoFile(settings, logger);
}
result = Renderer::findFactionLogoTexture(logoFilename);
result = Renderer::findTexture(logoFilename);
return result;
}
@ -695,7 +697,7 @@ void Game::loadHudTexture(const GameSettings *settings)
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled)
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] found HUD image [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,hudImageFileName.c_str());
Texture2D* texture= Renderer::findFactionLogoTexture(hudImageFileName);
Texture2D* texture= Renderer::findTexture(hudImageFileName);
gui.setHudTexture(texture);
hudFound = true;
//printf("Hud texture found! \n");
@ -862,11 +864,11 @@ void Game::load(int loadTypes) {
loadHudTexture(&gameSettings);
const string markCellTextureFilename = data_path + "data/core/misc_textures/mark_cell.png";
markCellTexture = Renderer::findFactionLogoTexture(markCellTextureFilename);
markCellTexture = Renderer::findTexture(markCellTextureFilename);
const string unmarkCellTextureFilename = data_path + "data/core/misc_textures/unmark_cell.png";
unmarkCellTexture = Renderer::findFactionLogoTexture(unmarkCellTextureFilename);
unmarkCellTexture = Renderer::findTexture(unmarkCellTextureFilename);
const string highlightCellTextureFilename = data_path + "data/core/misc_textures/pointer.png";
highlightCellTexture = Renderer::findFactionLogoTexture(highlightCellTextureFilename);
highlightCellTexture = Renderer::findTexture(highlightCellTextureFilename);
string scenarioDir = "";
if(gameSettings.getScenarioDir() != "") {
@ -1739,13 +1741,14 @@ void Game::updateNetworkMarkedCells() {
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
if(gameNetworkInterface != NULL &&
gameNetworkInterface->getMarkedCellList(false).empty() == false) {
//Lang &lang= Lang::getInstance();
gameNetworkInterface->getMarkedCellList(false).empty() == false) {
std::vector<MarkedCell> chatList = gameNetworkInterface->getMarkedCellList(true);
for(int idx = 0; idx < chatList.size(); idx++) {
MarkedCell mc = chatList[idx];
mc.setFaction((const Faction *)world.getFaction(mc.getFactionIndex()));
if(mc.getFactionIndex() >= 0) {
mc.setFaction((const Faction *)world.getFaction(mc.getFactionIndex()));
}
Map *map= world.getMap();
Vec2i surfaceCellPos = map->toSurfCoords(mc.getTargetPos());
@ -2173,6 +2176,110 @@ void Game::startMarkCell() {
}
}
void Game::processInputText(string text, bool cancelled) {
isMarkCellTextEnabled = false;
if(cancelled == false) {
//printf("Note [%s]\n",text.c_str());
cellMarkedData.setNote(text);
addCellMarker(cellMarkedPos, cellMarkedData);
// if(text.find("\\n") != text.npos) {
// replaceAll(text, "\\n", "\n");
// }
// if(text.find("\\t") != text.npos) {
// replaceAll(text, "\\t", "\t");
// }
//
// cellMarkedData.setNote(text);
// mapMarkedCellList[cellMarkedPos] = cellMarkedData;
//
// GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
//
// int factionIndex = -1;
// int playerIndex = -1;
// if(cellMarkedData.getFaction() != NULL) {
// factionIndex = cellMarkedData.getFaction()->getIndex();
// playerIndex = cellMarkedData.getFaction()->getStartLocationIndex();
// }
// gameNetworkInterface->sendMarkCellMessage(
// cellMarkedData.getTargetPos(),
// factionIndex,
// cellMarkedData.getNote(),
// playerIndex);
//
// Renderer &renderer= Renderer::getInstance();
// renderer.forceQuadCacheUpdate();
}
}
void Game::addCellMarker(Vec2i cellPos, MarkedCell cellData) {
//printf("Note [%s]\n",text.c_str());
string text = cellData.getNote();
if(text.find("\\n") != text.npos) {
replaceAll(text, "\\n", "\n");
}
if(text.find("\\t") != text.npos) {
replaceAll(text, "\\t", "\t");
}
cellData.setNote(text);
mapMarkedCellList[cellPos] = cellData;
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
int factionIndex = -1;
int playerIndex = -1;
if(cellData.getFaction() != NULL) {
factionIndex = cellData.getFaction()->getIndex();
playerIndex = cellData.getFaction()->getStartLocationIndex();
}
//printf("Adding Cell marker pos [%s] factionIndex [%d] note [%s] playerIndex = %d\n",cellData.getTargetPos().getString().c_str(),factionIndex,cellData.getNote().c_str(),playerIndex);
gameNetworkInterface->sendMarkCellMessage(
cellData.getTargetPos(),
factionIndex,
cellData.getNote(),
playerIndex);
Renderer &renderer= Renderer::getInstance();
renderer.forceQuadCacheUpdate();
}
void Game::removeCellMarker(Vec2i surfaceCellPos, const Faction *faction) {
//Vec2i surfaceCellPos = map->toSurfCoords(Vec2i(xCell,yCell));
Map *map= world.getMap();
SurfaceCell *sc = map->getSurfaceCell(surfaceCellPos);
Vec3f vertex = sc->getVertex();
Vec2i targetPos(vertex.x,vertex.z);
//printf("Remove Cell marker lookup pos [%s] factionIndex [%d]\n",surfaceCellPos.getString().c_str(),(faction != NULL ? faction->getIndex() : -1));
if(mapMarkedCellList.find(surfaceCellPos) != mapMarkedCellList.end()) {
MarkedCell mc = mapMarkedCellList[surfaceCellPos];
if(mc.getFaction() == faction) {
mapMarkedCellList.erase(surfaceCellPos);
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
int factionIndex = (faction != NULL ? faction->getIndex() : -1);
//printf("Remvoing Cell marker pos [%s] factionIndex [%d] note [%s]\n",mc.getTargetPos().getString().c_str(),factionIndex,mc.getNote().c_str());
gameNetworkInterface->sendUnMarkCellMessage(mc.getTargetPos(),factionIndex);
}
}
//printf("#1 ADDED in marked list pos [%s] markedCells.size() = %lu\n",surfaceCellPos.getString().c_str(),mapMarkedCellList.size());
//isUnMarkCellEnabled = false;
Renderer &renderer= Renderer::getInstance();
//renderer.updateMarkedCellScreenPosQuadCache(surfaceCellPos);
renderer.forceQuadCacheUpdate();
}
void Game::mouseDownLeft(int x, int y) {
if(this->masterserverMode == true) {
return;
@ -2541,20 +2648,20 @@ void Game::mouseDownLeft(int x, int y) {
Vec3f vertex = sc->getVertex();
Vec2i targetPos(vertex.x,vertex.z);
//MarkedCell mc(targetPos,world.getThisFaction(),"placeholder for note");
//mapMarkedCellList[surfaceCellPos] = mc;
if(mapMarkedCellList.find(surfaceCellPos) != mapMarkedCellList.end()) {
MarkedCell mc = mapMarkedCellList[surfaceCellPos];
if(mc.getFaction() == world.getThisFaction()) {
mapMarkedCellList.erase(surfaceCellPos);
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
gameNetworkInterface->sendUnMarkCellMessage(mc.getTargetPos(),mc.getFaction()->getIndex());
}
}
//printf("#1 ADDED in marked list pos [%s] markedCells.size() = %lu\n",surfaceCellPos.getString().c_str(),mapMarkedCellList.size());
// if(mapMarkedCellList.find(surfaceCellPos) != mapMarkedCellList.end()) {
// MarkedCell mc = mapMarkedCellList[surfaceCellPos];
// if(mc.getFaction() == world.getThisFaction()) {
// mapMarkedCellList.erase(surfaceCellPos);
// GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
// gameNetworkInterface->sendUnMarkCellMessage(mc.getTargetPos(),mc.getFaction()->getIndex());
// }
// }
isUnMarkCellEnabled = false;
removeCellMarker(surfaceCellPos, world.getThisFaction());
//printf("#1 ADDED in marked list pos [%s] markedCells.size() = %lu\n",surfaceCellPos.getString().c_str(),mapMarkedCellList.size());
Renderer &renderer= Renderer::getInstance();
//renderer.updateMarkedCellScreenPosQuadCache(surfaceCellPos);
renderer.forceQuadCacheUpdate();
@ -2600,10 +2707,6 @@ void Game::mouseDownLeft(int x, int y) {
MarkedCell mc(targetPos,world.getThisFaction(),"placeholder for note",world.getThisFaction()->getStartLocationIndex());
cellMarkedData = mc;
//mapMarkedCellList[surfaceCellPos] = mc;
//GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
//gameNetworkInterface->sendMarkCellMessage(mc.getTargetPos(),mc.getFaction()->getIndex(),mc.getNote());
//printf("#2 ADDED in marked list pos [%s] markedCells.size() = %lu\n",surfaceCellPos.getString().c_str(),mapMarkedCellList.size());
@ -2624,19 +2727,18 @@ void Game::mouseDownLeft(int x, int y) {
renderer.computePosition(screenPos, targetPos);
Vec2i surfaceCellPos = map->toSurfCoords(targetPos);
//MarkedCell mc(targetPos,world.getThisFaction(),"placeholder for note");
//mapMarkedCellList[surfaceCellPos] = mc;
if(mapMarkedCellList.find(surfaceCellPos) != mapMarkedCellList.end()) {
MarkedCell mc = mapMarkedCellList[surfaceCellPos];
if(mc.getFaction() == world.getThisFaction()) {
mapMarkedCellList.erase(surfaceCellPos);
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
gameNetworkInterface->sendUnMarkCellMessage(mc.getTargetPos(),mc.getFaction()->getIndex());
}
}
//printf("#1 ADDED in marked list pos [%s] markedCells.size() = %lu\n",surfaceCellPos.getString().c_str(),mapMarkedCellList.size());
// if(mapMarkedCellList.find(surfaceCellPos) != mapMarkedCellList.end()) {
// MarkedCell mc = mapMarkedCellList[surfaceCellPos];
// if(mc.getFaction() == world.getThisFaction()) {
// mapMarkedCellList.erase(surfaceCellPos);
// GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
// gameNetworkInterface->sendUnMarkCellMessage(mc.getTargetPos(),mc.getFaction()->getIndex());
// }
// }
isUnMarkCellEnabled = false;
removeCellMarker(surfaceCellPos, world.getThisFaction());
//printf("#1 ADDED in marked list pos [%s] markedCells.size() = %lu\n",surfaceCellPos.getString().c_str(),mapMarkedCellList.size());
//Renderer &renderer= Renderer::getInstance();
//renderer.updateMarkedCellScreenPosQuadCache(surfaceCellPos);
@ -3044,32 +3146,6 @@ void Game::eventMouseWheel(int x, int y, int zDelta) {
}
}
void Game::processInputText(string text, bool cancelled) {
isMarkCellTextEnabled = false;
if(cancelled == false) {
//printf("Note [%s]\n",text.c_str());
if(text.find("\\n") != text.npos) {
replaceAll(text, "\\n", "\n");
}
if(text.find("\\t") != text.npos) {
replaceAll(text, "\\t", "\t");
}
cellMarkedData.setNote(text);
//MarkedCell mc(targetPos,world.getThisFaction(),"placeholder for note");
//mapMarkedCellList[surfaceCellPos] = mc;
mapMarkedCellList[cellMarkedPos] = cellMarkedData;
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
gameNetworkInterface->sendMarkCellMessage(cellMarkedData.getTargetPos(),cellMarkedData.getFaction()->getIndex(),cellMarkedData.getNote(),cellMarkedData.getFaction()->getStartLocationIndex());
Renderer &renderer= Renderer::getInstance();
renderer.forceQuadCacheUpdate();
}
}
void Game::startCameraFollowUnit() {
Selection *selection= gui.getSelectionPtr();
if(selection->getCount() == 1) {

View File

@ -298,6 +298,9 @@ public:
bool factionLostGame(int factionIndex);
void addCellMarker(Vec2i cellPos, MarkedCell cellData);
void removeCellMarker(Vec2i surfaceCellPos, const Faction *faction);
private:
//render
void render3d();

View File

@ -315,6 +315,9 @@ void ScriptManager::init(World* world, GameCamera *gameCamera, const XmlNode *ro
luaScript.registerFunction(getUnitPosition, "unitPosition");
luaScript.registerFunction(setUnitPosition, "setUnitPosition");
luaScript.registerFunction(addCellMarker, "addCellMarker");
luaScript.registerFunction(removeCellMarker, "removeCellMarker");
luaScript.registerFunction(getUnitFaction, "unitFaction");
luaScript.registerFunction(getUnitName, "unitName");
luaScript.registerFunction(getResourceAmount, "resourceAmount");
@ -1296,6 +1299,18 @@ void ScriptManager::setUnitPosition(int unitId, Vec2i pos) {
return world->setUnitPosition(unitId,pos);
}
void ScriptManager::addCellMarker(Vec2i pos, int factionIndex, const string &note, const string &textureFile) {
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->addCellMarker(pos,factionIndex, note, textureFile);
}
void ScriptManager::removeCellMarker(Vec2i pos, int factionIndex) {
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->removeCellMarker(pos,factionIndex);
}
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;
@ -1861,6 +1876,41 @@ int ScriptManager::setUnitPosition(LuaHandle* luaHandle){
return luaArguments.getReturnCount();
}
int ScriptManager::addCellMarker(LuaHandle* luaHandle){
LuaArguments luaArguments(luaHandle);
//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->addCellMarker(pos,factionIndex,note,texture);
return luaArguments.getReturnCount();
}
int ScriptManager::removeCellMarker(LuaHandle* luaHandle){
LuaArguments luaArguments(luaHandle);
int factionIndex = luaArguments.getInt(-2);
Vec2i pos = luaArguments.getVec2i(-1);
thisScriptManager->removeCellMarker(pos,factionIndex);
return luaArguments.getReturnCount();
}
int ScriptManager::getUnitFaction(LuaHandle* luaHandle){
LuaArguments luaArguments(luaHandle);
int factionIndex= thisScriptManager->getUnitFaction(luaArguments.getInt(-1));

View File

@ -316,6 +316,8 @@ private:
void setUnitPosition(int unitId, Vec2i pos);
void addCellMarker(Vec2i pos, int factionIndex, const string &note, const string &textureFile);
void removeCellMarker(Vec2i pos, int factionIndex);
const string &getLastDeadUnitName();
int getLastDeadUnitId();
@ -428,6 +430,9 @@ private:
static int setUnitPosition(LuaHandle* luaHandle);
static int addCellMarker(LuaHandle* luaHandle);
static int removeCellMarker(LuaHandle* luaHandle);
static int getLastDeadUnitName(LuaHandle* luaHandle);
static int getLastDeadUnitId(LuaHandle* luaHandle);
static int getLastDeadUnitCauseOfDeath(LuaHandle* luaHandle);

View File

@ -5969,11 +5969,16 @@ void Renderer::renderMarkedCellsOnMinimap() {
for(std::map<Vec2i, MarkedCell>::iterator iterMap =markedCells.begin();
iterMap != markedCells.end(); ++iterMap) {
MarkedCell &bm = iterMap->second;
if(bm.getFaction() != NULL && bm.getFaction()->getTeam() == game->getWorld()->getThisFaction()->getTeam()) {
if(bm.getPlayerIndex() < 0 ||
(bm.getFaction() != NULL &&
bm.getFaction()->getTeam() == game->getWorld()->getThisFaction()->getTeam())) {
Vec2i pos= bm.getTargetPos() / Map::cellScale;
float size= 0.5f;
//Vec3f color= bm.color;
Vec3f color= bm.getFaction()->getTexture()->getPixmapConst()->getPixel3f(0, 0);
Vec3f color(MarkedCell::static_system_marker_color);
if(bm.getFaction() != NULL) {
color= bm.getFaction()->getTexture()->getPixmapConst()->getPixel3f(0, 0);
}
float alpha = 0.65;
unit_colors[unitIdx] = Vec4f(color.x,color.y,color.z,alpha);
@ -6024,7 +6029,9 @@ void Renderer::renderVisibleMarkedCells(bool renderTextHint,int x, int y) {
for(std::map<Vec2i, MarkedCell>::iterator iterMap =markedCells.begin();
iterMap != markedCells.end(); ++iterMap) {
MarkedCell &bm = iterMap->second;
if(bm.getFaction() != NULL && bm.getFaction()->getTeam() == game->getWorld()->getThisFaction()->getTeam()) {
if(bm.getPlayerIndex() < 0 ||
(bm.getFaction() != NULL &&
bm.getFaction()->getTeam() == game->getWorld()->getThisFaction()->getTeam())) {
const Map *map= game->getWorld()->getMap();
std::pair<bool,Vec3f> bmVisible = posInCellQuadCache(
map->toSurfCoords(bm.getTargetPos()));
@ -6105,11 +6112,14 @@ void Renderer::renderVisibleMarkedCells(bool renderTextHint,int x, int y) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Vec3f flagColor(bm.getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0));
Vec3f color(MarkedCell::static_system_marker_color);
if(bm.getFaction() != NULL) {
color = bm.getFaction()->getTexture()->getPixmapConst()->getPixel3f(0,0);
}
renderTextureQuad(
bmVisible.second.x,bmVisible.second.y + yOffset,
texture->getTextureWidth(),texture->getTextureHeight(),texture,0.8f,&flagColor);
texture->getTextureWidth(),texture->getTextureHeight(),texture,0.8f,&color);
/*
glActiveTexture(GL_TEXTURE1);
@ -9259,7 +9269,7 @@ Texture2D * Renderer::preloadTexture(string logoFilename) {
return result;
}
Texture2D * Renderer::findFactionLogoTexture(string logoFilename) {
Texture2D * Renderer::findTexture(string logoFilename) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] logoFilename [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,logoFilename.c_str());
Texture2D *result = preloadTexture(logoFilename);

View File

@ -609,7 +609,7 @@ public:
void renderProgressBar(int size, int x, int y, Font2D *font,int customWidth=-1, string prefixLabel="", bool centeredText=true);
static Texture2D * findFactionLogoTexture(string logoFilename);
static Texture2D * findTexture(string logoFilename);
static Texture2D * preloadTexture(string logoFilename);
inline int getCachedSurfaceDataSize() const { return mapSurfaceData.size(); }

View File

@ -4716,7 +4716,7 @@ int glestMain(int argc, char** argv) {
// Texture2D * factionLogo = textureList[i];
// if(factionLogo != NULL) {
// printf("\n\n\n\n|||||||||||||||||||||||||| Load texture [%s]\n",factionLogo->getPath().c_str());
// //Renderer::findFactionLogoTexture(factionLogo);
// //Renderer::findTexture(factionLogo);
// renderer.initTexture(rsGlobal,factionLogo);
// }
// }

View File

@ -2972,7 +2972,7 @@ void MenuStateConnectedGame::loadFactionTexture(string filepath) {
}
else {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] filepath = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,filepath.c_str());
factionTexture = Renderer::findFactionLogoTexture(filepath);
factionTexture = Renderer::findTexture(filepath);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
}
}

View File

@ -4088,7 +4088,7 @@ void MenuStateCustomGame::loadFactionTexture(string filepath) {
else {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] filepath = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,filepath.c_str());
factionTexture = Renderer::findFactionLogoTexture(filepath);
factionTexture = Renderer::findTexture(filepath);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
}

View File

@ -2152,7 +2152,7 @@ void MenuStateMods::render() {
if(tempImage != "" && fileExists(tempImage) == true) {
cleanupPreviewTexture();
modPreviewImage = Renderer::findFactionLogoTexture(tempImage);
modPreviewImage = Renderer::findTexture(tempImage);
}
}
if(modPreviewImage != NULL) {

View File

@ -328,7 +328,7 @@ void MenuStateScenario::loadScenarioPreviewTexture(){
if(scenarioLogo != "") {
cleanupPreviewTexture();
scenarioLogoTexture = Renderer::findFactionLogoTexture(scenarioLogo);
scenarioLogoTexture = Renderer::findTexture(scenarioLogo);
}
else {
cleanupPreviewTexture();

View File

@ -38,6 +38,8 @@ bool NetworkInterface::allowGameDataSynchCheck = false;
bool NetworkInterface::allowDownloadDataSynch = false;
DisplayMessageFunction NetworkInterface::pCB_DisplayMessage = NULL;
Vec3f MarkedCell::static_system_marker_color(MAGENTA.x,MAGENTA.y,MAGENTA.z);
void NetworkInterface::sendMessage(const NetworkMessage* networkMessage){
Socket* socket= getSocket(false);

View File

@ -92,6 +92,8 @@ protected:
int aliveCount;
public:
static Vec3f static_system_marker_color;
MarkedCell() {
faction = NULL;
factionIndex = -1;

View File

@ -1307,6 +1307,41 @@ void World::setUnitPosition(int unitId, Vec2i pos) {
unit->setPos(pos,true);
}
void World::addCellMarker(Vec2i pos, int factionIndex, const string &note, const string textureFile) {
//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));
game->addCellMarker(surfaceCellPos, mc);
}
void World::removeCellMarker(Vec2i pos, int factionIndex) {
//Vec2i surfaceCellPos = map.toSurfCoords(pos);
//Vec2i surfaceCellPos = pos;
const Faction *faction = NULL;
if(factionIndex >= 0) {
faction = this->getFaction(factionIndex);
}
Vec2i surfaceCellPos = map.toSurfCoords(pos);
game->removeCellMarker(surfaceCellPos, faction);
}
int World::getUnitFactionIndex(int unitId) {
Unit* unit= findUnitById(unitId);
if(unit == NULL) {

View File

@ -246,6 +246,9 @@ public:
Vec2i getUnitPosition(int unitId);
void setUnitPosition(int unitId, Vec2i pos);
void addCellMarker(Vec2i pos, int factionIndex, const string &note, const string textureFile);
void removeCellMarker(Vec2i pos, int factionIndex);
int getUnitFactionIndex(int unitId);
const string getUnitName(int unitId);
int getUnitCount(int factionIndex);

View File

@ -92,7 +92,9 @@ public:
void returnVectorInt(const vector<int> &value);
private:
void throwLuaError(const string &message) const;
string getStackText() const;
};
}}//end namespace

View File

@ -631,14 +631,27 @@ Vec2i LuaArguments::getVec2i(int argumentIndex) const{
throwLuaError("Can not get vec2i from Lua state, array size not 2");
}
//string stackString = getStackText();
//printf("Lua Stack:\n%s\n",stackString.c_str());
lua_rawgeti(luaState, argumentIndex, 1);
v.x= luaL_checkint(luaState, argumentIndex);
//printf("xa = %s argumentIndex = %d\n",lua_tostring(luaState, argumentIndex),argumentIndex);
//v.x= luaL_checkint(luaState, argumentIndex);
v.x= lua_tointeger(luaState, argumentIndex);
lua_pop(luaState, 1);
//printf("X = %d\n",v.x);
lua_rawgeti(luaState, argumentIndex, 2);
v.y= luaL_checkint(luaState, argumentIndex);
//printf("ya = %s\n",lua_tostring(luaState, argumentIndex));
//v.y= luaL_checkint(luaState, argumentIndex);
v.y= lua_tointeger(luaState, argumentIndex);
lua_pop(luaState, 1);
//printf("Y = %d\n",v.y);
return v;
}
@ -740,7 +753,7 @@ void LuaArguments::returnVectorInt(const vector<int> &value) {
}
}
void LuaArguments::throwLuaError(const string &message) const{
string LuaArguments::getStackText() const {
Lua_STREFLOP_Wrapper streflopWrapper;
string stackString;
@ -756,11 +769,77 @@ void LuaArguments::throwLuaError(const string &message) const{
stackString+= "String: " + string(luaL_checkstring(luaState, -i));
}
else if(lua_istable(luaState, -i)){
int tableLen = 0;
#if LUA_VERSION_NUM > 501
stackString+= "Table (" + intToStr(lua_rawlen(luaState, -i)) + ")";
tableLen = lua_rawlen(luaState, -i);
#else
stackString+= "Table (" + intToStr(luaL_getn(luaState, -i)) + ")";
tableLen = luaL_getn(luaState, -i);
#endif
stackString+= "Table (" + intToStr(tableLen) + ")\n";
// for(unsigned int j = 1; j < tableLen; ++j) {
// stackString+= "entry# " + intToStr(j) + ", value = " + lua_tostring(luaState, -i) + "\n";
// }
// int j = 1;
// lua_pushnil(luaState); // The initial key for the traversal.
//
// printf("start loop\n");
//
// while (lua_next(luaState, -2)!=0) {
// printf("in loop j = %d\n",j);
//
// const char* Param=lua_tostring(luaState, -1);
//
// printf("passed in loop j = %d Param [%s]\n",j,(Param != NULL ? Param : "<nil>"));
//
// if (Param!=NULL) {
// stackString+= "entry# " + intToStr(j) + ", value = " + Param + "\n";
// }
//
// // Remove the value, keep the key for the next iteration.
// lua_pop(luaState, 1);
// j++;
// }
// const int len = lua_objlen( luaState, -i );
// printf("Table Len = %d\n",len);
//
// for ( int j = 1; j <= len; ++j ) {
// printf("A Table\n");
//
// lua_pushinteger( luaState, j );
//
// printf("B Table\n");
//
// lua_gettable( luaState, -2 );
//
// printf("C Table\n");
//
// //v.push_back( lua_tointeger( L, -1 ) );
// const char *value = lua_tostring( luaState, -1 );
// printf("D Table value = %s\n",(value != NULL ? value : "<nil>"));
//
// //v.push_back( lua_tointeger( L, -1 ) );
// const char *value2 = lua_tostring( luaState, -2 );
// printf("E Table value2 = %s\n",(value2 != NULL ? value2 : "<nil>"));
//
// value2 = lua_tostring( luaState, -3 );
// printf("F Table value2 = %s\n",(value2 != NULL ? value2 : "<nil>"));
//
// value2 = lua_tostring( luaState, 0 );
// printf("G Table value2 = %s\n",(value2 != NULL ? value2 : "<nil>"));
//
// value2 = lua_tostring( luaState, 1 );
// printf("H Table value2 = %s\n",(value2 != NULL ? value2 : "<nil>"));
//
// stackString+= "entry# " + intToStr(j) + ", value = " + (value != NULL ? value : "<nil>") + "\n";
//
// printf("E Table\n");
//
// lua_pop( luaState, 1 );
// }
}
else
{
@ -769,6 +848,12 @@ void LuaArguments::throwLuaError(const string &message) const{
stackString+= "\n";
}
return stackString;
}
void LuaArguments::throwLuaError(const string &message) const{
Lua_STREFLOP_Wrapper streflopWrapper;
string stackString = getStackText();
throw megaglest_runtime_error("Lua error: " + message + "\n\nLua Stack:\n" + stackString);
}