- added ability to render map preview full screen when user clicks on the map preview. Click anywhere on the fullscreen map to restore.

This commit is contained in:
SoftCoder 2013-12-30 23:32:06 -08:00
parent b109b26664
commit 21a12a6c72
5 changed files with 149 additions and 26 deletions

View File

@ -47,6 +47,11 @@ static const double REPROMPT_DOWNLOAD_SECONDS = 7;
const int HEADLESSSERVER_BROADCAST_SETTINGS_SECONDS = 4;
static const char *HEADLESS_SAVED_GAME_FILENAME = "lastHeadlessGameSettings.mgg";
const int mapPreviewTexture_X = 5;
const int mapPreviewTexture_Y = 185;
const int mapPreviewTexture_W = 150;
const int mapPreviewTexture_H = 150;
struct FormatString {
void operator()(string &s) {
s = formatString(s);
@ -67,6 +72,11 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
updateDataSynchDetailText = false;
launchingNewGame = false;
this->render_mapPreviewTexture_X = mapPreviewTexture_X;
this->render_mapPreviewTexture_Y = mapPreviewTexture_Y;
this->render_mapPreviewTexture_W = mapPreviewTexture_W;
this->render_mapPreviewTexture_H = mapPreviewTexture_H;
needToBroadcastServerSettings=false;
broadcastServerSettingsDelayTimer=0;
lastGameSettingsReceivedCount=0;
@ -1131,6 +1141,40 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
}
}
if(mapPreviewTexture != NULL) {
// printf("X: %d Y: %d [%d, %d, %d, %d]\n",
// x, y,
// this->render_mapPreviewTexture_X, this->render_mapPreviewTexture_X + this->render_mapPreviewTexture_W,
// this->render_mapPreviewTexture_Y, this->render_mapPreviewTexture_Y + this->render_mapPreviewTexture_H);
if( x >= this->render_mapPreviewTexture_X && x <= this->render_mapPreviewTexture_X + this->render_mapPreviewTexture_W &&
y >= this->render_mapPreviewTexture_Y && y <= this->render_mapPreviewTexture_Y + this->render_mapPreviewTexture_H) {
if( this->render_mapPreviewTexture_X == mapPreviewTexture_X &&
this->render_mapPreviewTexture_Y == mapPreviewTexture_Y &&
this->render_mapPreviewTexture_W == mapPreviewTexture_W &&
this->render_mapPreviewTexture_H == mapPreviewTexture_H) {
const Metrics &metrics= Metrics::getInstance();
this->render_mapPreviewTexture_X = 0;
this->render_mapPreviewTexture_Y = 0;
this->render_mapPreviewTexture_W = metrics.getVirtualW();
this->render_mapPreviewTexture_H = metrics.getVirtualH();
cleanupMapPreviewTexture();
}
else {
this->render_mapPreviewTexture_X = mapPreviewTexture_X;
this->render_mapPreviewTexture_Y = mapPreviewTexture_Y;
this->render_mapPreviewTexture_W = mapPreviewTexture_W;
this->render_mapPreviewTexture_H = mapPreviewTexture_H;
cleanupMapPreviewTexture();
}
}
}
if(mainMessageBox.getEnabled()) {
int button= 0;
if(mainMessageBox.mouseClick(x, y, button)) {
@ -2386,7 +2430,13 @@ void MenuStateConnectedGame::render() {
}
if(mapPreviewTexture != NULL) {
renderer.renderTextureQuad(5,185,150,150,mapPreviewTexture,1.0f);
//renderer.renderTextureQuad(5,185,150,150,mapPreviewTexture,1.0f);
renderer.renderTextureQuad( this->render_mapPreviewTexture_X,
this->render_mapPreviewTexture_Y,
this->render_mapPreviewTexture_W,
this->render_mapPreviewTexture_H,
mapPreviewTexture,1.0f);
//printf("=================> Rendering map preview texture\n");
}
@ -2633,8 +2683,13 @@ void MenuStateConnectedGame::render() {
if(mapPreviewTexture == NULL) {
renderer.renderMouse2d(mouseX, mouseY, mouse2dAnim);
bool renderAll = (listBoxFogOfWar.getSelectedItemIndex() == 2);
renderer.renderMapPreview(&mapPreview, renderAll, 10, 350, &mapPreviewTexture);
//renderer.renderMapPreview(&mapPreview, renderAll, 10, 350, &mapPreviewTexture);
renderer.renderMapPreview(&mapPreview, renderAll,
this->render_mapPreviewTexture_X,
this->render_mapPreviewTexture_Y,
&mapPreviewTexture);
}
}
renderer.renderChatManager(&chatManager);

View File

@ -104,6 +104,10 @@ private:
MapInfo mapInfo;
Texture2D *mapPreviewTexture;
int render_mapPreviewTexture_X;
int render_mapPreviewTexture_Y;
int render_mapPreviewTexture_W;
int render_mapPreviewTexture_H;
bool needToSetChangedGameSettings;
time_t lastSetChangedGameSettings;

View File

@ -47,6 +47,11 @@ static const char *SAVED_GAME_FILENAME = "lastCustomGameSettings.mgg";
static const char *DEFAULT_GAME_FILENAME = "data/defaultGameSetup.mgg";
static const char *DEFAULT_NETWORKGAME_FILENAME = "data/defaultNetworkGameSetup.mgg";
const int mapPreviewTexture_X = 5;
const int mapPreviewTexture_Y = 185;
const int mapPreviewTexture_W = 150;
const int mapPreviewTexture_H = 150;
struct FormatString {
void operator()(string &s) {
s = formatString(s);
@ -75,6 +80,11 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
this->gameUUID = getUUIDAsString();
this->render_mapPreviewTexture_X = mapPreviewTexture_X;
this->render_mapPreviewTexture_Y = mapPreviewTexture_Y;
this->render_mapPreviewTexture_W = mapPreviewTexture_W;
this->render_mapPreviewTexture_H = mapPreviewTexture_H;
this->lastMasterServerSettingsUpdateCount = 0;
this->masterserverModeMinimalResources = true;
this->parentMenuState=parentMenuState;
@ -1043,6 +1053,40 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
advanceToItemStartingWith = lastKey;
}
if(mapPreviewTexture != NULL) {
// printf("X: %d Y: %d [%d, %d, %d, %d]\n",
// x, y,
// this->render_mapPreviewTexture_X, this->render_mapPreviewTexture_X + this->render_mapPreviewTexture_W,
// this->render_mapPreviewTexture_Y, this->render_mapPreviewTexture_Y + this->render_mapPreviewTexture_H);
if( x >= this->render_mapPreviewTexture_X && x <= this->render_mapPreviewTexture_X + this->render_mapPreviewTexture_W &&
y >= this->render_mapPreviewTexture_Y && y <= this->render_mapPreviewTexture_Y + this->render_mapPreviewTexture_H) {
if( this->render_mapPreviewTexture_X == mapPreviewTexture_X &&
this->render_mapPreviewTexture_Y == mapPreviewTexture_Y &&
this->render_mapPreviewTexture_W == mapPreviewTexture_W &&
this->render_mapPreviewTexture_H == mapPreviewTexture_H) {
const Metrics &metrics= Metrics::getInstance();
this->render_mapPreviewTexture_X = 0;
this->render_mapPreviewTexture_Y = 0;
this->render_mapPreviewTexture_W = metrics.getVirtualW();
this->render_mapPreviewTexture_H = metrics.getVirtualH();
cleanupMapPreviewTexture();
}
else {
this->render_mapPreviewTexture_X = mapPreviewTexture_X;
this->render_mapPreviewTexture_Y = mapPreviewTexture_Y;
this->render_mapPreviewTexture_W = mapPreviewTexture_W;
this->render_mapPreviewTexture_H = mapPreviewTexture_H;
cleanupMapPreviewTexture();
}
}
}
if(activeInputLabel!=NULL && !(activeInputLabel->mouseClick(x,y))){
setActiveInputLabel(NULL);
}
@ -1482,7 +1526,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
}
}
}
}
}
}
if(hasNetworkGameSettings() == true && listBoxPlayerStatus.mouseClick(x,y)) {
@ -1981,7 +2025,13 @@ void MenuStateCustomGame::render() {
}
else {
if(mapPreviewTexture != NULL) {
renderer.renderTextureQuad(5,185,150,150,mapPreviewTexture,1.0f);
//renderer.renderTextureQuad(5,185,150,150,mapPreviewTexture,1.0f);
renderer.renderTextureQuad( this->render_mapPreviewTexture_X,
this->render_mapPreviewTexture_Y,
this->render_mapPreviewTexture_W,
this->render_mapPreviewTexture_H,
mapPreviewTexture,1.0f);
//printf("=================> Rendering map preview texture\n");
}
@ -2174,7 +2224,13 @@ void MenuStateCustomGame::render() {
if(mapPreviewTexture == NULL) {
bool renderAll = (listBoxFogOfWar.getSelectedItemIndex() == 2);
//printf("=================> Rendering map preview into a texture BEFORE (%p)\n", mapPreviewTexture);
renderer.renderMapPreview(&mapPreview, renderAll, 10, 350,&mapPreviewTexture);
//renderer.renderMapPreview(&mapPreview, renderAll, 10, 350,&mapPreviewTexture);
renderer.renderMapPreview(&mapPreview, renderAll,
this->render_mapPreviewTexture_X,
this->render_mapPreviewTexture_Y,
&mapPreviewTexture);
//printf("=================> Rendering map preview into a texture AFTER (%p)\n", mapPreviewTexture);
}
}

View File

@ -192,6 +192,10 @@ private:
MapPreview mapPreview;
Texture2D *mapPreviewTexture;
int render_mapPreviewTexture_X;
int render_mapPreviewTexture_Y;
int render_mapPreviewTexture_W;
int render_mapPreviewTexture_H;
bool autostart;
GameSettings *autoStartSettings;

View File

@ -31,40 +31,44 @@ AllocRegistry::~AllocRegistry() {
}
void AllocRegistry::dump(const char *path) {
int leakCount=0;
size_t leakBytes=0;
time_t debugTime = time(NULL);
struct tm *loctime = localtime (&debugTime);
char szBuf2[100]="";
strftime(szBuf2,100,"%Y-%m-%d %H:%M:%S",loctime);
#ifdef WIN32
FILE* f= _wfopen(utf8_decode(path).c_str(), L"wt");
#else
FILE *f= fopen(path, "wt");
#endif
int leakCount=0;
size_t leakBytes=0;
time_t debugTime = time(NULL);
struct tm *loctime = localtime (&debugTime);
char szBuf2[100]="";
strftime(szBuf2,100,"%Y-%m-%d %H:%M:%S",loctime);
if(f) {
fprintf(f, "Memory leak dump at: %s\n\n",szBuf2);
fprintf(f, "Memory leak dump at: %s\n\n",szBuf2);
for(int index = 0; index < maxAllocs; ++index) {
AllocInfo &info = allocs[index];
if(info.freetouse == false && info.inuse == true) {
for(int i=0; i<maxAllocs; ++i){
AllocInfo &info = allocs[i];
if(info.freetouse == false && info.inuse == true) {
if(info.line > 0) {
leakBytes += info.bytes;
if(info.line > 0) {
leakBytes += info.bytes;
//allocs[i].stack = AllocInfo::getStackTrace();
fprintf(f, "Leak #%d.\tfile: %s, line: %d, ptr [%p], bytes: " MG_SIZE_T_SPECIFIER ", array: %d, inuse: %d\n%s\n", ++leakCount, info.file, info.line, info.ptr, info.bytes, info.array,info.inuse,info.stack.c_str());
//allocs[i].stack = AllocInfo::getStackTrace();
fprintf(f, "Leak #%d.\tfile: %s, line: %d, ptr [%p], bytes: " MG_SIZE_T_SPECIFIER ", array: %d, inuse: %d\n%s\n", ++leakCount, info.file, info.line, info.ptr, info.bytes, info.array,info.inuse,info.stack.c_str());
}
}
}
fprintf(f, "\nTotal leaks: %d, " MG_SIZE_T_SPECIFIER " bytes\n", leakCount, leakBytes);
fprintf(f, "Total allocations: %d, " MG_SIZE_T_SPECIFIER " bytes\n", allocCount, allocBytes);
fprintf(f, "Not monitored allocations: %d, " MG_SIZE_T_SPECIFIER " bytes\n", nonMonitoredCount, nonMonitoredBytes);
fclose(f);
}
fprintf(f, "\nTotal leaks: %d, " MG_SIZE_T_SPECIFIER " bytes\n", leakCount, leakBytes);
fprintf(f, "Total allocations: %d, " MG_SIZE_T_SPECIFIER " bytes\n", allocCount, allocBytes);
fprintf(f, "Not monitored allocations: %d, " MG_SIZE_T_SPECIFIER " bytes\n", nonMonitoredCount, nonMonitoredBytes);
if(f) fclose(f);
printf("Memory leak dump summary at: %s\n",szBuf2);
printf("Total leaks: %d, " MG_SIZE_T_SPECIFIER " bytes\n", leakCount, leakBytes);
printf("Total allocations: %d, " MG_SIZE_T_SPECIFIER " bytes\n", allocCount, allocBytes);