1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

* fix for bugs 47 and 89

This commit is contained in:
mateuszb
2009-10-18 14:39:53 +00:00
parent 476443101f
commit ad0848f1d2
5 changed files with 45 additions and 7 deletions

View File

@@ -790,6 +790,10 @@ CBattleAttack::CBattleAttack(CBattleInterface * _owner, int _stackID, int _dest)
{ {
attackedStack = LOCPLINT->cb->battleGetStackByPos(_dest, false); attackedStack = LOCPLINT->cb->battleGetStackByPos(_dest, false);
attackingStack = LOCPLINT->cb->battleGetStackByID(_stackID, false); attackingStack = LOCPLINT->cb->battleGetStackByID(_stackID, false);
assert(attackedStack && "attackedStack is NULL in CBattleAttack::CBattleAttack !\n");
assert(attackingStack && "attackingStack is NULL in CBattleAttack::CBattleAttack !\n");
attackingStackPosBeforeReturn = attackingStack->position; attackingStackPosBeforeReturn = attackingStack->position;
} }
@@ -3336,8 +3340,8 @@ void CBattleHex::mouseMoved(const SDL_MouseMotionEvent &sEvent)
LOCPLINT->cb->battleGetStackByPos(myNumber)->alive()) LOCPLINT->cb->battleGetStackByPos(myNumber)->alive())
{ {
char tabh[160]; char tabh[160];
CStack attackedStack = *LOCPLINT->cb->battleGetStackByPos(myNumber); const CStack * attackedStack = LOCPLINT->cb->battleGetStackByPos(myNumber);
const std::string & attackedName = attackedStack.amount == 1 ? attackedStack.creature->nameSing : attackedStack.creature->namePl; const std::string & attackedName = attackedStack->amount == 1 ? attackedStack->creature->nameSing : attackedStack->creature->namePl;
sprintf(tabh, CGI->generaltexth->allTexts[220].c_str(), attackedName.c_str()); sprintf(tabh, CGI->generaltexth->allTexts[220].c_str(), attackedName.c_str());
myInterface->console->alterTxt = std::string(tabh); myInterface->console->alterTxt = std::string(tabh);
setAlterText = true; setAlterText = true;

View File

@@ -288,6 +288,12 @@ struct SettingsGrammar : public grammar<SettingsGrammar>
| "graphic=" >> fname[AddGemName()] | "graphic=" >> fname[AddGemName()]
) )
) )
| str_p("InGameConsole:") >>
*(
( "maxInputPerLine=" >> uint_p[SetAdventureProp_a(&AdventureMapConfig::inputLineLength)]
| "maxOutputPerLine=" >> uint_p[SetAdventureProp_a(&AdventureMapConfig::outputLineLength)]
)
)
; ;
AdvMapOptionsSequence = *(AdvMapOption >> (';' | eps_p[lerror("Semicolon lacking in advmapopt!")])); AdvMapOptionsSequence = *(AdvMapOption >> (';' | eps_p[lerror("Semicolon lacking in advmapopt!")]));
GUIResolution = (uint_p[assign_a(curRes.first)] >> 'x' >> uint_p[assign_a(curRes.second)]) GUIResolution = (uint_p[assign_a(curRes.first)] >> 'x' >> uint_p[assign_a(curRes.second)])

View File

@@ -59,6 +59,8 @@ namespace config
//gems //gems
int gemX[4], gemY[4]; int gemX[4], gemY[4];
std::vector<std::string> gemG; std::vector<std::string> gemG;
//in-game console
int inputLineLength, outputLineLength;
}; };
struct GUIOptions struct GUIOptions
{ {

View File

@@ -3179,11 +3179,30 @@ void CInGameConsole::show(SDL_Surface * to)
void CInGameConsole::print(const std::string &txt) void CInGameConsole::print(const std::string &txt)
{ {
texts_mx.lock(); texts_mx.lock();
int lineLen = conf.go()->ac.outputLineLength;
texts.push_back(std::make_pair(txt, SDL_GetTicks())); if(txt.size() < lineLen)
if(texts.size() > maxDisplayedTexts)
{ {
texts.pop_front(); texts.push_back(std::make_pair(txt, SDL_GetTicks()));
if(texts.size() > maxDisplayedTexts)
{
texts.pop_front();
}
}
else
{
for(int g=0; g<txt.size() / lineLen + 1; ++g)
{
std::string part = txt.substr(g * lineLen, lineLen);
if(part.size() == 0)
break;
texts.push_back(std::make_pair(part, SDL_GetTicks()));
if(texts.size() > maxDisplayedTexts)
{
texts.pop_front();
}
}
} }
texts_mx.unlock(); texts_mx.unlock();
@@ -3268,7 +3287,7 @@ void CInGameConsole::keyPressed (const SDL_KeyboardEvent & key)
} }
default: default:
{ {
if(enteredText.size() > 0) if(enteredText.size() > 0 && enteredText.size() < conf.go()->ac.inputLineLength)
{ {
if( key.keysym.unicode < 0x80 && key.keysym.unicode > 0 ) if( key.keysym.unicode < 0x80 && key.keysym.unicode > 0 )
{ {

View File

@@ -16,7 +16,8 @@ GUISettings
{ {
AdventureMap AdventureMap
{ {
AdvMap: x=7 y=6 width=593 height=547 smoothMove=1; InGameConsole: maxInputPerLine=60 maxOutputPerLine=40;
AdvMap: x=7 y=6 width=593 height=547 smoothMove=1 puzzleSepia=1;
InfoBox: x=605 y=389; InfoBox: x=605 y=389;
gem0: x=6 y=508 graphic=agemLL.def; gem0: x=6 y=508 graphic=agemLL.def;
gem1: x=556 y=508 graphic=agemLR.def; gem1: x=556 y=508 graphic=agemLR.def;
@@ -44,6 +45,7 @@ GUISettings
{ {
AdventureMap AdventureMap
{ {
InGameConsole: maxInputPerLine=60 maxOutputPerLine=40;
AdvMap: x=7 y=6 width=817 height=547 smoothMove=1 puzzleSepia=1; AdvMap: x=7 y=6 width=817 height=547 smoothMove=1 puzzleSepia=1;
InfoBox: x=829 y=389; InfoBox: x=829 y=389;
gem0: x=6 y=508 graphic=agemLL.def; gem0: x=6 y=508 graphic=agemLL.def;
@@ -73,6 +75,7 @@ GUISettings
{ {
AdventureMap AdventureMap
{ {
InGameConsole: maxInputPerLine=60 maxOutputPerLine=40;
AdvMap: x=7 y=6 width=817 height=715 smoothMove=1 puzzleSepia=1; AdvMap: x=7 y=6 width=817 height=715 smoothMove=1 puzzleSepia=1;
InfoBox: x=829 y=557; InfoBox: x=829 y=557;
gem0: x=6 y=676 graphic=agemLL.def; gem0: x=6 y=676 graphic=agemLL.def;
@@ -101,6 +104,7 @@ GUISettings
{ {
AdventureMap AdventureMap
{ {
InGameConsole: maxInputPerLine=60 maxOutputPerLine=40;
AdvMap: x=7 y=6 width=1073 height=907 smoothMove=1 puzzleSepia=1; AdvMap: x=7 y=6 width=1073 height=907 smoothMove=1 puzzleSepia=1;
InfoBox: x=1085 y=749; InfoBox: x=1085 y=749;
gem0: x=6 y=868 graphic=agemLL.def; gem0: x=6 y=868 graphic=agemLL.def;
@@ -129,6 +133,7 @@ GUISettings
{ {
AdventureMap AdventureMap
{ {
InGameConsole: maxInputPerLine=60 maxOutputPerLine=40;
AdvMap: x=7 y=6 width=1073 height=971 smoothMove=1 puzzleSepia=1; AdvMap: x=7 y=6 width=1073 height=971 smoothMove=1 puzzleSepia=1;
InfoBox: x=1085 y=557; InfoBox: x=1085 y=557;
gem0: x=6 y=932 graphic=agemLL.def; gem0: x=6 y=932 graphic=agemLL.def;
@@ -157,6 +162,7 @@ GUISettings
{ {
AdventureMap AdventureMap
{ {
InGameConsole: maxInputPerLine=60 maxOutputPerLine=40;
AdvMap: x=7 y=7 width=1234 height=846 smoothMove=1 puzzleSepia=1; AdvMap: x=7 y=7 width=1234 height=846 smoothMove=1 puzzleSepia=1;
InfoBox: x=1246 y=690; InfoBox: x=1246 y=690;
gem0: x=6 y=808 graphic=agemLL.def; gem0: x=6 y=808 graphic=agemLL.def;
@@ -185,6 +191,7 @@ GUISettings
{ {
AdventureMap AdventureMap
{ {
InGameConsole: maxInputPerLine=60 maxOutputPerLine=40;
AdvMap: x=7 y=6 width=1395 height=1147 smoothMove=1 puzzleSepia=1; AdvMap: x=7 y=6 width=1395 height=1147 smoothMove=1 puzzleSepia=1;
InfoBox: x=1406 y=989; InfoBox: x=1406 y=989;
gem0: x=6 y=1108 graphic=agemLL.def; gem0: x=6 y=1108 graphic=agemLL.def;