mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Try to better dimension the info windows.
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
#include "GUIClasses.h"
|
#include "GUIClasses.h"
|
||||||
#include "AdventureMapButton.h"
|
#include "AdventureMapButton.h"
|
||||||
|
#include "CConfigHandler.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CMessage.cpp, part of VCMI engine
|
* CMessage.cpp, part of VCMI engine
|
||||||
@@ -36,6 +37,7 @@ using namespace NMessage;
|
|||||||
const int COMPONENT_TO_SUBTITLE = 5;
|
const int COMPONENT_TO_SUBTITLE = 5;
|
||||||
const int BETWEEN_COMPS_ROWS = 10;
|
const int BETWEEN_COMPS_ROWS = 10;
|
||||||
const int BEFORE_COMPONENTS = 30;
|
const int BEFORE_COMPONENTS = 30;
|
||||||
|
const int SIDE_MARGIN = 30;
|
||||||
|
|
||||||
template <typename T, typename U> std::pair<T,U> max(const std::pair<T,U> &x, const std::pair<T,U> &y)
|
template <typename T, typename U> std::pair<T,U> max(const std::pair<T,U> &x, const std::pair<T,U> &y)
|
||||||
{
|
{
|
||||||
@@ -352,6 +354,17 @@ void CMessage::drawIWindow(CInfoWindow * ret, std::string text, int player, int
|
|||||||
{
|
{
|
||||||
SDL_Surface * _or = NULL;
|
SDL_Surface * _or = NULL;
|
||||||
int fontHeight;
|
int fontHeight;
|
||||||
|
|
||||||
|
// Try to compute a resonable number of characters per line
|
||||||
|
if (!charperline) {
|
||||||
|
if (text.size() < 30)
|
||||||
|
charperline = 30;
|
||||||
|
else if (text.size() < 200)
|
||||||
|
charperline = 40;
|
||||||
|
else
|
||||||
|
charperline = 50;
|
||||||
|
}
|
||||||
|
|
||||||
if(dynamic_cast<CSelWindow*>(ret)) //it's selection window, so we'll blit "or" between components
|
if(dynamic_cast<CSelWindow*>(ret)) //it's selection window, so we'll blit "or" between components
|
||||||
_or = TTF_RenderText_Blended(GEOR13,CGI->generaltexth->allTexts[4].c_str(),zwykly);
|
_or = TTF_RenderText_Blended(GEOR13,CGI->generaltexth->allTexts[4].c_str(),zwykly);
|
||||||
|
|
||||||
@@ -361,24 +374,28 @@ void CMessage::drawIWindow(CInfoWindow * ret, std::string text, int player, int
|
|||||||
|
|
||||||
ComponentsToBlit comps(ret->components,500,_or);
|
ComponentsToBlit comps(ret->components,500,_or);
|
||||||
|
|
||||||
|
if (ret->components.size())
|
||||||
|
txts.second += 30 + comps.h; //space to first component
|
||||||
|
|
||||||
if (ret->buttons.size())
|
if (ret->buttons.size())
|
||||||
txts.second += 20 + //before button
|
txts.second += 20 + //before button
|
||||||
ok->ourImages[0].bitmap->h; //button
|
ok->ourImages[0].bitmap->h; //button
|
||||||
|
|
||||||
if (ret->components.size())
|
// Clip window size
|
||||||
{
|
amax(txts.first, 80);
|
||||||
txts.second += 30 + comps.h; //space to first component
|
amax(txts.second, 50);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
amax(txts.first,comps.w);
|
amax(txts.first,comps.w);
|
||||||
|
|
||||||
ret->bitmap = drawBox1(txts.first+70,txts.second+70,0);
|
amin(txts.first, conf.cc.resx - 150);
|
||||||
|
amin(txts.second, conf.cc.resy - 150);
|
||||||
|
|
||||||
|
ret->bitmap = drawBox1(txts.first+2*SIDE_MARGIN,txts.second+2*SIDE_MARGIN,0);
|
||||||
ret->pos.h=ret->bitmap->h;
|
ret->pos.h=ret->bitmap->h;
|
||||||
ret->pos.w=ret->bitmap->w;
|
ret->pos.w=ret->bitmap->w;
|
||||||
ret->pos.x=screen->w/2-(ret->pos.w/2);
|
ret->pos.x=screen->w/2-(ret->pos.w/2);
|
||||||
ret->pos.y=screen->h/2-(ret->pos.h/2);
|
ret->pos.y=screen->h/2-(ret->pos.h/2);
|
||||||
int curh = 30; //gorny margines
|
|
||||||
|
int curh = SIDE_MARGIN;
|
||||||
blitTextOnSur(txtg, fontHeight, curh,ret->bitmap);
|
blitTextOnSur(txtg, fontHeight, curh,ret->bitmap);
|
||||||
|
|
||||||
if (ret->components.size())
|
if (ret->components.size())
|
||||||
@@ -388,11 +405,15 @@ void CMessage::drawIWindow(CInfoWindow * ret, std::string text, int player, int
|
|||||||
}
|
}
|
||||||
if(ret->buttons.size())
|
if(ret->buttons.size())
|
||||||
{
|
{
|
||||||
curh += 20; //to buttton
|
// Position the buttons at the bottom of the window
|
||||||
int bw = 20*(ret->buttons.size()-1); //total width of buttons - start with distance between them
|
curh = ret->bitmap->h - SIDE_MARGIN - ret->buttons[0]->imgs[0][0]->h;
|
||||||
|
|
||||||
|
// Compute total width of buttons
|
||||||
|
int bw = 20*(ret->buttons.size()-1); // space between all buttons
|
||||||
for(size_t i=0; i<ret->buttons.size(); i++) //and add buttons width
|
for(size_t i=0; i<ret->buttons.size(); i++) //and add buttons width
|
||||||
bw+=ret->buttons[i]->imgs[0][0]->w;
|
bw+=ret->buttons[i]->imgs[0][0]->w;
|
||||||
bw = (ret->bitmap->w/2) - (bw/2);
|
bw = (ret->bitmap->w/2) - (bw/2);
|
||||||
|
|
||||||
for(size_t i=0; i<ret->buttons.size(); i++)
|
for(size_t i=0; i<ret->buttons.size(); i++)
|
||||||
{
|
{
|
||||||
ret->buttons[i]->pos.x = bw + ret->pos.x;
|
ret->buttons[i]->pos.x = bw + ret->pos.x;
|
||||||
|
@@ -1418,7 +1418,7 @@ void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector
|
|||||||
|
|
||||||
std::vector<std::pair<std::string,CFunctionList<void()> > > pom;
|
std::vector<std::pair<std::string,CFunctionList<void()> > > pom;
|
||||||
pom.push_back(std::pair<std::string,CFunctionList<void()> >("IOKAY.DEF",0));
|
pom.push_back(std::pair<std::string,CFunctionList<void()> >("IOKAY.DEF",0));
|
||||||
CInfoWindow * temp = new CInfoWindow(text,playerID,36,components,pom,false);
|
CInfoWindow * temp = new CInfoWindow(text,playerID,0,components,pom,false);
|
||||||
|
|
||||||
if(makingTurn && listInt.size())
|
if(makingTurn && listInt.size())
|
||||||
{
|
{
|
||||||
@@ -1439,7 +1439,7 @@ void CPlayerInterface::showYesNoDialog(const std::string &text, const std::vecto
|
|||||||
std::vector<std::pair<std::string,CFunctionList<void()> > > pom;
|
std::vector<std::pair<std::string,CFunctionList<void()> > > pom;
|
||||||
pom.push_back(std::pair<std::string,CFunctionList<void()> >("IOKAY.DEF",0));
|
pom.push_back(std::pair<std::string,CFunctionList<void()> >("IOKAY.DEF",0));
|
||||||
pom.push_back(std::pair<std::string,CFunctionList<void()> >("ICANCEL.DEF",0));
|
pom.push_back(std::pair<std::string,CFunctionList<void()> >("ICANCEL.DEF",0));
|
||||||
CInfoWindow * temp = new CInfoWindow(text,playerID,36,components,pom,DelComps);
|
CInfoWindow * temp = new CInfoWindow(text,playerID,0,components,pom,DelComps);
|
||||||
temp->delComps = DelComps;
|
temp->delComps = DelComps;
|
||||||
for(int i=0;i<onYes.funcs.size();i++)
|
for(int i=0;i<onYes.funcs.size();i++)
|
||||||
temp->buttons[0]->callback += onYes.funcs[i];
|
temp->buttons[0]->callback += onYes.funcs[i];
|
||||||
|
Reference in New Issue
Block a user