mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Implemnted enemy turn speed selection:
- implemented switch in settings screen - implemented "0 speed", animation-free. *may* also work for player-owned heroes - removed no longer used creature window switch
This commit is contained in:
parent
8838607669
commit
e692f3f520
@ -250,10 +250,6 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details)
|
||||
return;
|
||||
}
|
||||
|
||||
adventureInt->centerOn(hero); //actualizing screen pos
|
||||
adventureInt->minimap.redraw();
|
||||
adventureInt->heroList.redraw();
|
||||
|
||||
bool directlyAttackingCreature =
|
||||
details.attackedFrom
|
||||
&& adventureInt->terrain.currentPath //in case if movement has been canceled in the meantime and path was already erased
|
||||
@ -310,12 +306,30 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details)
|
||||
return;
|
||||
}
|
||||
|
||||
ui32 speed;
|
||||
if (makingTurn) // our turn, our hero moves
|
||||
speed = settings["adventure"]["heroSpeed"].Float();
|
||||
else
|
||||
speed = settings["adventure"]["enemySpeed"].Float();
|
||||
|
||||
if (speed == 0)
|
||||
{
|
||||
//FIXME: is this a proper solution?
|
||||
CGI->mh->hideObject(hero);
|
||||
CGI->mh->printObject(hero);
|
||||
return; // no animation
|
||||
}
|
||||
|
||||
|
||||
adventureInt->centerOn(hero); //actualizing screen pos
|
||||
adventureInt->minimap.redraw();
|
||||
adventureInt->heroList.redraw();
|
||||
|
||||
initMovement(details, hero, hp);
|
||||
|
||||
//first initializing done
|
||||
GH.mainFPSmng->framerateDelay(); // after first move
|
||||
|
||||
ui32 speed = settings["adventure"]["heroSpeed"].Float();
|
||||
//main moving
|
||||
for(int i=1; i<32; i+=2*speed)
|
||||
{
|
||||
@ -324,14 +338,14 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details)
|
||||
adventureInt->show(screen);
|
||||
{
|
||||
//evil returns here ...
|
||||
//todo: get rid of it
|
||||
//todo: get rid of it
|
||||
logGlobal->traceStream() << "before [un]locks in " << __FUNCTION__;
|
||||
auto unlockPim = vstd::makeUnlockGuard(*pim); //let frame to be rendered
|
||||
GH.mainFPSmng->framerateDelay(); //for animation purposes
|
||||
logGlobal->traceStream() << "after [un]locks in " << __FUNCTION__;
|
||||
logGlobal->traceStream() << "after [un]locks in " << __FUNCTION__;
|
||||
}
|
||||
//CSDL_Ext::update(screen);
|
||||
|
||||
|
||||
} //for(int i=1; i<32; i+=4)
|
||||
//main moving done
|
||||
|
||||
|
@ -621,6 +621,8 @@ CSlider::CSlider(Point position, int totalw, std::function<void(int)> Moved, int
|
||||
{
|
||||
OBJ_CONSTRUCTION_CAPTURING_ALL;
|
||||
setAmount(amount);
|
||||
vstd::amax(value, 0);
|
||||
vstd::amin(value, positions);
|
||||
|
||||
addUsedEvents(LCLICK | KEYBOARD | WHEEL);
|
||||
strongInterest = true;
|
||||
|
@ -483,28 +483,16 @@ CLevelWindow::~CLevelWindow()
|
||||
LOCPLINT->showingDialog->setn(false);
|
||||
}
|
||||
|
||||
void CSystemOptionsWindow::setMusicVolume( int newVolume )
|
||||
static void setIntSetting(std::string group, std::string field, int value)
|
||||
{
|
||||
Settings volume = settings.write["general"]["music"];
|
||||
volume->Float() = newVolume;
|
||||
Settings entry = settings.write[group][field];
|
||||
entry->Float() = value;
|
||||
}
|
||||
|
||||
void CSystemOptionsWindow::setSoundVolume( int newVolume )
|
||||
static void setBoolSetting(std::string group, std::string field, bool value)
|
||||
{
|
||||
Settings volume = settings.write["general"]["sound"];
|
||||
volume->Float() = newVolume;
|
||||
}
|
||||
|
||||
void CSystemOptionsWindow::setHeroMoveSpeed( int newSpeed )
|
||||
{
|
||||
Settings speed = settings.write["adventure"]["heroSpeed"];
|
||||
speed->Float() = newSpeed;
|
||||
}
|
||||
|
||||
void CSystemOptionsWindow::setMapScrollingSpeed( int newSpeed )
|
||||
{
|
||||
Settings speed = settings.write["adventure"]["scrollSpeed"];
|
||||
speed->Float() = newSpeed;
|
||||
Settings fullscreen = settings.write[group][field];
|
||||
fullscreen->Bool() = value;
|
||||
}
|
||||
|
||||
CSystemOptionsWindow::CSystemOptionsWindow():
|
||||
@ -560,48 +548,52 @@ CSystemOptionsWindow::CSystemOptionsWindow():
|
||||
heroMoveSpeed->addToggle(4, new CToggleButton(Point(124, 77), "sysopb3.def", CGI->generaltexth->zelp[351]));
|
||||
heroMoveSpeed->addToggle(8, new CToggleButton(Point(172, 77), "sysopb4.def", CGI->generaltexth->zelp[352]));
|
||||
heroMoveSpeed->setSelected(settings["adventure"]["heroSpeed"].Float());
|
||||
heroMoveSpeed->addCallback(std::bind(&CSystemOptionsWindow::setHeroMoveSpeed, this, _1));
|
||||
heroMoveSpeed->addCallback(std::bind(&setIntSetting, "adventure", "heroSpeed", _1));
|
||||
|
||||
enemyMoveSpeed = new CToggleGroup(0);
|
||||
enemyMoveSpeed->addToggle(2, new CToggleButton(Point( 28, 144), "sysopb5.def", CGI->generaltexth->zelp[353]));
|
||||
enemyMoveSpeed->addToggle(4, new CToggleButton(Point( 76, 144), "sysopb6.def", CGI->generaltexth->zelp[354]));
|
||||
enemyMoveSpeed->addToggle(8, new CToggleButton(Point(124, 144), "sysopb7.def", CGI->generaltexth->zelp[355]));
|
||||
enemyMoveSpeed->addToggle(0, new CToggleButton(Point(172, 144), "sysopb8.def", CGI->generaltexth->zelp[356]));
|
||||
enemyMoveSpeed->setSelected(settings["adventure"]["enemySpeed"].Float());
|
||||
enemyMoveSpeed->addCallback(std::bind(&setIntSetting, "adventure", "enemySpeed", _1));
|
||||
|
||||
mapScrollSpeed = new CToggleGroup(0);
|
||||
mapScrollSpeed->addToggle(1, new CToggleButton(Point( 28, 210), "sysopb9.def", CGI->generaltexth->zelp[357]));
|
||||
mapScrollSpeed->addToggle(2, new CToggleButton(Point( 92, 210), "sysob10.def", CGI->generaltexth->zelp[358]));
|
||||
mapScrollSpeed->addToggle(4, new CToggleButton(Point(156, 210), "sysob11.def", CGI->generaltexth->zelp[359]));
|
||||
mapScrollSpeed->setSelected(settings["adventure"]["scrollSpeed"].Float());
|
||||
mapScrollSpeed->addCallback(std::bind(&CSystemOptionsWindow::setMapScrollingSpeed, this, _1));
|
||||
mapScrollSpeed->addCallback(std::bind(&setIntSetting, "adventure", "scrollSpeed", _1));
|
||||
|
||||
musicVolume = new CToggleGroup(0, true);
|
||||
for(int i=0; i<10; ++i)
|
||||
musicVolume->addToggle(i*11, new CToggleButton(Point(29 + 19*i, 359), "syslb.def", CGI->generaltexth->zelp[326+i]));
|
||||
|
||||
musicVolume->setSelected(CCS->musich->getVolume());
|
||||
musicVolume->addCallback(std::bind(&CSystemOptionsWindow::setMusicVolume, this, _1));
|
||||
musicVolume->addCallback(std::bind(&setIntSetting, "general", "music", _1));
|
||||
|
||||
effectsVolume = new CToggleGroup(0, true);
|
||||
for(int i=0; i<10; ++i)
|
||||
effectsVolume->addToggle(i*11, new CToggleButton(Point(29 + 19*i, 425), "syslb.def", CGI->generaltexth->zelp[336+i]));
|
||||
|
||||
effectsVolume->setSelected(CCS->soundh->getVolume());
|
||||
effectsVolume->addCallback(std::bind(&CSystemOptionsWindow::setSoundVolume, this, _1));
|
||||
effectsVolume->addCallback(std::bind(&setIntSetting, "general", "sound", _1));
|
||||
|
||||
showReminder = new CToggleButton(Point(246, 87), "sysopchk.def", CGI->generaltexth->zelp[361],
|
||||
[&] (bool value) { toggleReminder(value);});
|
||||
[&] (bool value) { setBoolSetting("adventure", "heroReminder", value); });
|
||||
|
||||
quickCombat = new CToggleButton(Point(246, 87+32), "sysopchk.def", CGI->generaltexth->zelp[362],
|
||||
[&] (bool value) { toggleQuickCombat(value);});
|
||||
[&] (bool value) { setBoolSetting("adventure", "quickCombat", value); });
|
||||
|
||||
spellbookAnim = new CToggleButton(Point(246, 87+64), "sysopchk.def", CGI->generaltexth->zelp[364],
|
||||
[&] (bool value) { toggleSpellbookAnim(value);});
|
||||
|
||||
newCreatureWin = new CToggleButton(Point(246, 183), "sysopchk.def", CButton::tooltip(texts["creatureWindowButton"]),
|
||||
[&] (bool value) { toggleCreatureWin(value);});
|
||||
[&] (bool value) { setBoolSetting("video", "spellbookAnimation", value); });
|
||||
|
||||
fullscreen = new CToggleButton(Point(246, 215), "sysopchk.def", CButton::tooltip(texts["fullscreenButton"]),
|
||||
[&] (bool value) { toggleFullscreen(value);});
|
||||
[&] (bool value) { setBoolSetting("video", "fullscreen", value); });
|
||||
|
||||
showReminder->setSelected(settings["adventure"]["heroReminder"].Bool());
|
||||
quickCombat->setSelected(settings["adventure"]["quickCombat"].Bool());
|
||||
spellbookAnim->setSelected(settings["video"]["spellbookAnimation"].Bool());
|
||||
newCreatureWin->setSelected(settings["general"]["classicCreatureWindow"].Bool());
|
||||
fullscreen->setSelected(settings["video"]["fullscreen"].Bool());
|
||||
|
||||
onFullscreenChanged([&](const JsonNode &newState){ fullscreen->setSelected(newState.Bool());});
|
||||
@ -652,36 +644,6 @@ void CSystemOptionsWindow::setGameRes(int index)
|
||||
gameResLabel->setText(resText);
|
||||
}
|
||||
|
||||
void CSystemOptionsWindow::toggleReminder(bool on)
|
||||
{
|
||||
Settings heroReminder = settings.write["adventure"]["heroReminder"];
|
||||
heroReminder->Bool() = on;
|
||||
}
|
||||
|
||||
void CSystemOptionsWindow::toggleQuickCombat(bool on)
|
||||
{
|
||||
Settings quickCombat = settings.write["adventure"]["quickCombat"];
|
||||
quickCombat->Bool() = on;
|
||||
}
|
||||
|
||||
void CSystemOptionsWindow::toggleSpellbookAnim(bool on)
|
||||
{
|
||||
Settings quickCombat = settings.write["video"]["spellbookAnimation"];
|
||||
quickCombat->Bool() = on;
|
||||
}
|
||||
|
||||
void CSystemOptionsWindow::toggleCreatureWin(bool on)
|
||||
{
|
||||
Settings classicCreatureWindow = settings.write["general"]["classicCreatureWindow"];
|
||||
classicCreatureWindow->Bool() = on;
|
||||
}
|
||||
|
||||
void CSystemOptionsWindow::toggleFullscreen(bool on)
|
||||
{
|
||||
Settings fullscreen = settings.write["video"]["fullscreen"];
|
||||
fullscreen->Bool() = on;
|
||||
}
|
||||
|
||||
void CSystemOptionsWindow::bquitf()
|
||||
{
|
||||
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[578], [this]{ closeAndPushEvent(SDL_QUIT); }, 0);
|
||||
|
@ -190,6 +190,7 @@ private:
|
||||
CLabelGroup *rightGroup;
|
||||
CButton *load, *save, *restart, *mainMenu, *quitGame, *backToMap; //load and restart are not used yet
|
||||
CToggleGroup * heroMoveSpeed;
|
||||
CToggleGroup * enemyMoveSpeed;
|
||||
CToggleGroup * mapScrollSpeed;
|
||||
CToggleGroup * musicVolume, * effectsVolume;
|
||||
|
||||
@ -197,7 +198,6 @@ private:
|
||||
CToggleButton * showReminder;
|
||||
CToggleButton * quickCombat;
|
||||
CToggleButton * spellbookAnim;
|
||||
CToggleButton * newCreatureWin;
|
||||
CToggleButton * fullscreen;
|
||||
|
||||
CButton *gameResButton;
|
||||
@ -205,11 +205,6 @@ private:
|
||||
|
||||
SettingsListener onFullscreenChanged;
|
||||
|
||||
void setMusicVolume( int newVolume );
|
||||
void setSoundVolume( int newVolume );
|
||||
void setHeroMoveSpeed( int newSpeed );
|
||||
void setMapScrollingSpeed( int newSpeed );
|
||||
|
||||
//functions bound to buttons
|
||||
void bloadf(); //load game
|
||||
void bsavef(); //save game
|
||||
@ -218,13 +213,6 @@ private:
|
||||
void brestartf(); //restart game
|
||||
void bmainmenuf(); //return to main menu
|
||||
|
||||
//functions for checkboxes
|
||||
void toggleReminder(bool on);
|
||||
void toggleQuickCombat(bool on);
|
||||
void toggleSpellbookAnim(bool on);
|
||||
void toggleCreatureWin(bool on);
|
||||
void toggleFullscreen(bool on);
|
||||
|
||||
void selectGameRes();
|
||||
void setGameRes(int index);
|
||||
void closeAndPushEvent(int eventType, int code = 0);
|
||||
|
@ -19,10 +19,6 @@
|
||||
"additionalProperties" : false,
|
||||
"required" : [ "classicCreatureWindow", "playerName", "showfps", "music", "sound", "encoding" ],
|
||||
"properties" : {
|
||||
"classicCreatureWindow" : {
|
||||
"type" : "boolean",
|
||||
"default" : false
|
||||
},
|
||||
"playerName" : {
|
||||
"type":"string",
|
||||
"default" : "Player"
|
||||
|
@ -29,11 +29,6 @@
|
||||
"label" : "Fullscreen",
|
||||
"help" : "{Fullscreen}\n\n If selected, VCMI will run in fullscreen mode, othervice VCMI will run in window",
|
||||
},
|
||||
"creatureWindowButton" :
|
||||
{
|
||||
"label" : "Classic creature window",
|
||||
"help" : "{Classic creature window}\n\n Enable original Heroes 3 creature window instead of new window from VCMI"
|
||||
},
|
||||
"resolutionButton" :
|
||||
{
|
||||
"label" : "Resolution",
|
||||
|
Loading…
Reference in New Issue
Block a user