mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
- minor fixes to JSON
- music will resume correctly after battles
This commit is contained in:
parent
8fa540b4da
commit
7eb82278d9
@ -1450,7 +1450,8 @@ void CAdvMapInt::select(const CArmedInstance *sel, bool centerView /*= true*/)
|
|||||||
assert(sel);
|
assert(sel);
|
||||||
LOCPLINT->cb->setSelection(sel);
|
LOCPLINT->cb->setSelection(sel);
|
||||||
selection = sel;
|
selection = sel;
|
||||||
CCS->musich->playMusic(CCS->musich->terrainMusics[LOCPLINT->cb->getTile(sel->visitablePos())->tertype]);
|
if (LOCPLINT->battleInt == NULL)
|
||||||
|
CCS->musich->playMusic(CCS->musich->terrainMusics[LOCPLINT->cb->getTile(sel->visitablePos())->tertype]);
|
||||||
if(centerView)
|
if(centerView)
|
||||||
centerOn(sel);
|
centerOn(sel);
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "CCreatureWindow.h"
|
#include "CCreatureWindow.h"
|
||||||
#include "CVideoHandler.h"
|
#include "CVideoHandler.h"
|
||||||
#include "../lib/CTownHandler.h"
|
#include "../lib/CTownHandler.h"
|
||||||
|
#include "../lib/map.h"
|
||||||
#include <boost/assign/list_of.hpp>
|
#include <boost/assign/list_of.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
@ -1431,6 +1432,12 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
|
|||||||
bTacticNextStack();
|
bTacticNextStack();
|
||||||
active = 0;
|
active = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CCS->musich->stopMusic();
|
||||||
|
|
||||||
|
int channel = CCS->soundh->playSoundFromSet(CCS->soundh->battleIntroSounds);
|
||||||
|
CCS->soundh->setCallback(channel, boost::bind(&CMusicHandler::playMusicFromSet, CCS->musich, CCS->musich->battleMusics, -1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CBattleInterface::~CBattleInterface()
|
CBattleInterface::~CBattleInterface()
|
||||||
@ -1478,7 +1485,15 @@ CBattleInterface::~CBattleInterface()
|
|||||||
delete siegeH;
|
delete siegeH;
|
||||||
curInt->battleInt = NULL;
|
curInt->battleInt = NULL;
|
||||||
|
|
||||||
//TODO:restart music (can be AI or terrain). May be easier to backup and restore it instead of re-selecting
|
//TODO: play AI tracks if battle was during AI turn
|
||||||
|
//if (!curInt->makingTurn)
|
||||||
|
//CCS->musich->playMusicFromSet(CCS->musich->aiMusics, -1);
|
||||||
|
|
||||||
|
if(adventureInt && adventureInt->selection)
|
||||||
|
{
|
||||||
|
int terrain = LOCPLINT->cb->getTile(adventureInt->selection->visitablePos())->tertype;
|
||||||
|
CCS->musich->playMusic(CCS->musich->terrainMusics[terrain], -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBattleInterface::setPrintCellBorders(bool set)
|
void CBattleInterface::setPrintCellBorders(bool set)
|
||||||
|
@ -331,6 +331,8 @@ CMusicHandler::CMusicHandler()
|
|||||||
#undef VCMI_MUSIC_FILE
|
#undef VCMI_MUSIC_FILE
|
||||||
|
|
||||||
// Vectors for helper
|
// Vectors for helper
|
||||||
|
aiMusics += musicBase::AITheme0, musicBase::AITheme1, musicBase::AITheme2;
|
||||||
|
|
||||||
battleMusics += musicBase::combat1, musicBase::combat2,
|
battleMusics += musicBase::combat1, musicBase::combat2,
|
||||||
musicBase::combat3, musicBase::combat4;
|
musicBase::combat3, musicBase::combat4;
|
||||||
|
|
||||||
|
@ -157,6 +157,7 @@ public:
|
|||||||
|
|
||||||
// Musics
|
// Musics
|
||||||
std::map<musicBase::musicID, std::string> musics;
|
std::map<musicBase::musicID, std::string> musics;
|
||||||
|
std::vector<musicBase::musicID> aiMusics;
|
||||||
std::vector<musicBase::musicID> battleMusics;
|
std::vector<musicBase::musicID> battleMusics;
|
||||||
std::vector<musicBase::musicID> townMusics;
|
std::vector<musicBase::musicID> townMusics;
|
||||||
std::vector<musicBase::musicID> terrainMusics;
|
std::vector<musicBase::musicID> terrainMusics;
|
||||||
|
@ -571,10 +571,6 @@ void CPlayerInterface::battleStart(const CCreatureSet *army1, const CCreatureSet
|
|||||||
SDL_Delay(20);
|
SDL_Delay(20);
|
||||||
|
|
||||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||||
CCS->musich->stopMusic();
|
|
||||||
|
|
||||||
int channel = CCS->soundh->playSoundFromSet(CCS->soundh->battleIntroSounds);
|
|
||||||
CCS->soundh->setCallback(channel, boost::bind(&CMusicHandler::playMusicFromSet, CCS->musich, CCS->musich->battleMusics, -1));
|
|
||||||
|
|
||||||
GH.pushInt(battleInt);
|
GH.pushInt(battleInt);
|
||||||
}
|
}
|
||||||
|
@ -2,28 +2,28 @@
|
|||||||
{
|
{
|
||||||
"difficulty":
|
"difficulty":
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"human": { "wood" : 30, "mercury": 15, "ore": 30, "sulfur": 15, "crystal": 15, "gems": 15, "gold": 30000, "mithril": 0 },
|
"human": { "wood" : 30, "mercury": 15, "ore": 30, "sulfur": 15, "crystal": 15, "gems": 15, "gold": 30000, "mithril": 0 },
|
||||||
"ai": { "wood" : 5, "mercury": 2, "ore": 5, "sulfur": 2, "crystal": 2, "gems": 2, "gold": 5000, "mithril": 0 }
|
"ai": { "wood" : 5, "mercury": 2, "ore": 5, "sulfur": 2, "crystal": 2, "gems": 2, "gold": 5000, "mithril": 0 }
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"human": { "wood" : 20, "mercury": 10, "ore": 20, "sulfur": 10, "crystal": 10, "gems": 10, "gold": 20000, "mithril": 0 },
|
"human": { "wood" : 20, "mercury": 10, "ore": 20, "sulfur": 10, "crystal": 10, "gems": 10, "gold": 20000, "mithril": 0 },
|
||||||
"ai": { "wood" : 10, "mercury": 4, "ore": 10, "sulfur": 4, "crystal": 4, "gems": 4, "gold": 7500, "mithril": 0 }
|
"ai": { "wood" : 10, "mercury": 4, "ore": 10, "sulfur": 4, "crystal": 4, "gems": 4, "gold": 7500, "mithril": 0 }
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"human": { "wood" : 15, "mercury": 7, "ore": 15, "sulfur": 7, "crystal": 7, "gems": 7, "gold": 15000, "mithril": 0 },
|
"human": { "wood" : 15, "mercury": 7, "ore": 15, "sulfur": 7, "crystal": 7, "gems": 7, "gold": 15000, "mithril": 0 },
|
||||||
"ai": { "wood" : 15, "mercury": 7, "ore": 15, "sulfur": 7, "crystal": 7, "gems": 7, "gold": 10000, "mithril": 0 }
|
"ai": { "wood" : 15, "mercury": 7, "ore": 15, "sulfur": 7, "crystal": 7, "gems": 7, "gold": 10000, "mithril": 0 }
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"human": { "wood" : 10, "mercury": 4, "ore": 10, "sulfur": 4, "crystal": 4, "gems": 4, "gold": 10000, "mithril": 0 },
|
"human": { "wood" : 10, "mercury": 4, "ore": 10, "sulfur": 4, "crystal": 4, "gems": 4, "gold": 10000, "mithril": 0 },
|
||||||
"ai": { "wood" : 15, "mercury": 7, "ore": 15, "sulfur": 7, "crystal": 7, "gems": 7, "gold": 10000, "mithril": 0 }
|
"ai": { "wood" : 15, "mercury": 7, "ore": 15, "sulfur": 7, "crystal": 7, "gems": 7, "gold": 10000, "mithril": 0 }
|
||||||
}
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"human": { "wood" : 0, "mercury": 0, "ore": 0 , "sulfur": 0, "crystal": 0, "gems": 0, "gold": 0, "mithril": 0 },
|
"human": { "wood" : 0, "mercury": 0, "ore": 0 , "sulfur": 0, "crystal": 0, "gems": 0, "gold": 0, "mithril": 0 },
|
||||||
"ai": { "wood" : 15, "mercury": 7, "ore": 15, "sulfur": 7, "crystal": 7, "gems": 7, "gold": 10000, "mithril": 0 }
|
"ai": { "wood" : 15, "mercury": 7, "ore": 15, "sulfur": 7, "crystal": 7, "gems": 7, "gold": 10000, "mithril": 0 }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -20,7 +20,8 @@ JsonNode::JsonNode(std::string input):
|
|||||||
JsonParser parser(input, *this);
|
JsonParser parser(input, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonNode::JsonNode(const char *filename)
|
JsonNode::JsonNode(const char *filename):
|
||||||
|
type(DATA_NULL)
|
||||||
{
|
{
|
||||||
std::ifstream file(filename);
|
std::ifstream file(filename);
|
||||||
std::string str((std::istreambuf_iterator<char>(file)),
|
std::string str((std::istreambuf_iterator<char>(file)),
|
||||||
@ -246,12 +247,13 @@ JsonParser::JsonParser(const std::string inputString, JsonNode &root):
|
|||||||
pos(0)
|
pos(0)
|
||||||
{
|
{
|
||||||
extractValue(root);
|
extractValue(root);
|
||||||
|
extractWhitespace(false);
|
||||||
|
|
||||||
//Warn if there are any non-whitespace symbols left
|
//Warn if there are any non-whitespace symbols left
|
||||||
if (input.find_first_not_of(" \r\t\n", pos) != std::string::npos)
|
if (pos < input.size())
|
||||||
error("Not all file was parsed!", true);
|
error("Not all file was parsed!", true);
|
||||||
|
|
||||||
//TODO: better way to show errors
|
//TODO: better way to show errors (like printing file name as well)
|
||||||
tlog2<<errors;
|
tlog2<<errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +292,7 @@ bool JsonParser::extractValue(JsonNode &node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JsonParser::extractWhitespace()
|
bool JsonParser::extractWhitespace(bool verbose)
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
@ -317,7 +319,7 @@ bool JsonParser::extractWhitespace()
|
|||||||
pos = input.find('\n', pos);
|
pos = input.find('\n', pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos >= input.size())
|
if (pos >= input.size() && verbose)
|
||||||
return error("Unexpected end of file!");
|
return error("Unexpected end of file!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
//Create tree from Json-formatted input
|
//Create tree from Json-formatted input
|
||||||
explicit JsonNode(std::string input);
|
explicit JsonNode(std::string input);
|
||||||
//Create tree from JSON file
|
//Create tree from JSON file
|
||||||
JsonNode(const char *filename);
|
explicit JsonNode(const char *filename);
|
||||||
//Copy c-tor
|
//Copy c-tor
|
||||||
JsonNode(const JsonNode ©);
|
JsonNode(const JsonNode ©);
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ class JsonParser
|
|||||||
bool extractEscaping(std::string &str);
|
bool extractEscaping(std::string &str);
|
||||||
bool extractLiteral(const std::string &literal);
|
bool extractLiteral(const std::string &literal);
|
||||||
bool extractString(std::string &string);
|
bool extractString(std::string &string);
|
||||||
bool extractWhitespace();
|
bool extractWhitespace(bool verbose = true);
|
||||||
bool extractSeparator();
|
bool extractSeparator();
|
||||||
|
|
||||||
//Methods for extracting JSON data
|
//Methods for extracting JSON data
|
||||||
|
Loading…
Reference in New Issue
Block a user