- 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:
parent
b109b26664
commit
21a12a6c72
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -31,11 +31,7 @@ AllocRegistry::~AllocRegistry() {
|
|||
}
|
||||
|
||||
void AllocRegistry::dump(const char *path) {
|
||||
#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;
|
||||
|
||||
|
@ -44,10 +40,17 @@ void AllocRegistry::dump(const char *path) {
|
|||
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
|
||||
|
||||
if(f) {
|
||||
fprintf(f, "Memory leak dump at: %s\n\n",szBuf2);
|
||||
|
||||
for(int i=0; i<maxAllocs; ++i){
|
||||
AllocInfo &info = allocs[i];
|
||||
for(int index = 0; index < maxAllocs; ++index) {
|
||||
AllocInfo &info = allocs[index];
|
||||
if(info.freetouse == false && info.inuse == true) {
|
||||
|
||||
if(info.line > 0) {
|
||||
|
@ -63,7 +66,8 @@ void AllocRegistry::dump(const char *path) {
|
|||
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);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
printf("Memory leak dump summary at: %s\n",szBuf2);
|
||||
printf("Total leaks: %d, " MG_SIZE_T_SPECIFIER " bytes\n", leakCount, leakBytes);
|
||||
|
|
Loading…
Reference in New Issue