Pārlūkot izejas kodu

Fix regressions

Ivan Savenko 2 gadi atpakaļ
vecāks
revīzija
9cfcf5ea19

+ 8 - 4
client/CMusicHandler.cpp

@@ -566,19 +566,23 @@ void MusicEntry::load(const AudioPath & musicURI)
 		music = nullptr;
 	}
 
-	currentName = musicURI;
+	if (CResourceHandler::get()->existsResource(musicURI))
+		currentName = musicURI;
+	else
+		currentName = musicURI.addPrefix("MUSIC/");
+
 	music = nullptr;
 
-	logGlobal->trace("Loading music file %s", musicURI.getOriginalName());
+	logGlobal->trace("Loading music file %s", currentName.getOriginalName());
 
 	try
 	{
-		auto musicFile = MakeSDLRWops(CResourceHandler::get()->load(musicURI));
+		auto musicFile = MakeSDLRWops(CResourceHandler::get()->load(currentName));
 		music = Mix_LoadMUS_RW(musicFile, SDL_TRUE);
 	}
 	catch(std::exception &e)
 	{
-		logGlobal->error("Failed to load music. setName=%s\tmusicURI=%s", setName, musicURI.getOriginalName());
+		logGlobal->error("Failed to load music. setName=%s\tmusicURI=%s", setName, currentName.getOriginalName());
 		logGlobal->error("Exception: %s", e.what());
 	}
 

+ 6 - 2
client/CVideoHandler.cpp

@@ -77,14 +77,18 @@ bool CVideoPlayer::open(const VideoPath & fname, bool scale)
 
 // loop = to loop through the video
 // useOverlay = directly write to the screen.
-bool CVideoPlayer::open(const VideoPath & fname, bool loop, bool useOverlay, bool scale)
+bool CVideoPlayer::open(const VideoPath & videoToOpen, bool loop, bool useOverlay, bool scale)
 {
 	close();
 
-	this->fname = fname.addPrefix("VIDEO/");
 	doLoop = loop;
 	frameTime = 0;
 
+	if (CResourceHandler::get()->existsResource(videoToOpen))
+		fname = videoToOpen;
+	else
+		fname = videoToOpen.addPrefix("VIDEO/");
+
 	if (!CResourceHandler::get()->existsResource(fname))
 	{
 		logGlobal->error("Error: video %s was not found", fname.getName());

+ 5 - 5
client/adventureMap/CInfoBar.cpp

@@ -94,18 +94,18 @@ AnimationPath CInfoBar::VisibleDateInfo::getNewDayName()
 		return AnimationPath::builtin("NEWDAY");
 
 	if(LOCPLINT->cb->getDate(Date::DAY_OF_WEEK) != 1)
-		return AnimationPath("NEWDAY");
+		return AnimationPath::builtin("NEWDAY");
 
 	switch(LOCPLINT->cb->getDate(Date::WEEK))
 	{
 	case 1:
-		return AnimationPath("NEWWEEK1");
+		return AnimationPath::builtin("NEWWEEK1");
 	case 2:
-		return AnimationPath("NEWWEEK2");
+		return AnimationPath::builtin("NEWWEEK2");
 	case 3:
-		return AnimationPath("NEWWEEK3");
+		return AnimationPath::builtin("NEWWEEK3");
 	case 4:
-		return AnimationPath("NEWWEEK4");
+		return AnimationPath::builtin("NEWWEEK4");
 	default:
 		return AnimationPath();
 	}

+ 1 - 1
client/adventureMap/MapAudioPlayer.cpp

@@ -140,7 +140,7 @@ std::vector<AudioPath> MapAudioPlayer::getAmbientSounds(const int3 & tile)
 	}
 
 	if(CGI->mh->getMap()->isCoastalTile(tile))
-		result.emplace_back("LOOPOCEA");
+		result.emplace_back(AudioPath::builtin("LOOPOCEA"));
 
 	return result;
 }

+ 5 - 10
client/mainmenu/CCampaignScreen.cpp

@@ -128,17 +128,7 @@ void CCampaignScreen::CCampaignButton::show(Canvas & to)
 
 	// Play the campaign button video when the mouse cursor is placed over the button
 	if(isHovered())
-	{
-		if(CCS->videoh->fname != video.addPrefix("VIDEO/"))
-			CCS->videoh->open(video);
-
 		CCS->videoh->update(pos.x, pos.y, to.getInternalSurface(), true, false); // plays sequentially frame by frame, starts at the beginning when the video is over
-	}
-	else if(CCS->videoh->fname == video.addPrefix("VIDEO/")) // When you got out of the bounds of the button then close the video
-	{
-		CCS->videoh->close();
-		redraw();
-	}
 }
 
 void CCampaignScreen::CCampaignButton::clickReleased(const Point & cursorPosition)
@@ -149,6 +139,11 @@ void CCampaignScreen::CCampaignButton::clickReleased(const Point & cursorPositio
 
 void CCampaignScreen::CCampaignButton::hover(bool on)
 {
+	if (on)
+		CCS->videoh->open(video);
+	else
+		CCS->videoh->close();
+
 	if(hoverLabel)
 	{
 		if(on)

+ 1 - 3
client/render/CAnimation.cpp

@@ -217,9 +217,7 @@ CAnimation::CAnimation(const AnimationPath & Name):
 }
 
 CAnimation::CAnimation():
-	name(""),
-	preloaded(false),
-	defFile()
+	preloaded(false)
 {
 	init();
 }

+ 3 - 3
client/windows/CKingdomInterface.cpp

@@ -417,7 +417,7 @@ si64 InfoBoxCustomHeroData::getValue()
 	return value;
 }
 
-InfoBoxCustom::InfoBoxCustom(std::string ValueText, std::string NameText, std::string ImageName, size_t ImageIndex, std::string HoverText):
+InfoBoxCustom::InfoBoxCustom(std::string ValueText, std::string NameText, const AnimationPath & ImageName, size_t ImageIndex, std::string HoverText):
 	IInfoBoxData(CUSTOM),
 	valueText(ValueText),
 	nameText(NameText),
@@ -531,7 +531,7 @@ std::shared_ptr<CIntObject> CKingdomInterface::createOwnedObject(size_t index)
 	{
 		OwnedObjectInfo & obj = objects[index];
 		std::string value = std::to_string(obj.count);
-		auto data = std::make_shared<InfoBoxCustom>(value, "", "FLAGPORT", obj.imageID, obj.hoverText);
+		auto data = std::make_shared<InfoBoxCustom>(value, "", AnimationPath::builtin("FLAGPORT"), obj.imageID, obj.hoverText);
 		return std::make_shared<InfoBox>(Point(), InfoBox::POS_CORNER, InfoBox::SIZE_SMALL, data);
 	}
 	return std::shared_ptr<CIntObject>();
@@ -587,7 +587,7 @@ void CKingdomInterface::generateMinesList(const std::vector<const CGObjectInstan
 	for(int i=0; i<7; i++)
 	{
 		std::string value = std::to_string(minesCount[i]);
-		auto data = std::make_shared<InfoBoxCustom>(value, "", "OVMINES", i, CGI->generaltexth->translate("core.minename", i));
+		auto data = std::make_shared<InfoBoxCustom>(value, "", AnimationPath::builtin("OVMINES"), i, CGI->generaltexth->translate("core.minename", i));
 		minesBox[i] = std::make_shared<InfoBox>(Point(20+i*80, 31+footerPos), InfoBox::POS_INSIDE, InfoBox::SIZE_SMALL, data);
 		minesBox[i]->removeUsedEvents(LCLICK|SHOW_POPUP); //fixes #890 - mines boxes ignore clicks
 	}

+ 1 - 1
client/windows/CKingdomInterface.h

@@ -170,7 +170,7 @@ public:
 	std::string hoverText;
 	size_t imageIndex;
 
-	InfoBoxCustom(std::string ValueText, std::string NameText, std::string ImageName, size_t ImageIndex, std::string HoverText="");
+	InfoBoxCustom(std::string ValueText, std::string NameText, const AnimationPath & ImageName, size_t ImageIndex, std::string HoverText="");
 
 	std::string getValueText() override;
 	std::string getNameText() override;

+ 1 - 1
client/windows/CPuzzleWindow.cpp

@@ -43,7 +43,7 @@ CPuzzleWindow::CPuzzleWindow(const int3 & GrailPos, double discoveredRatio)
 
 	logo = std::make_shared<CPicture>(ImagePath::builtin("PUZZLOGO"), 607, 3);
 	title = std::make_shared<CLabel>(700, 95, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->allTexts[463]);
-	resDataBar = std::make_shared<CResDataBar>(ImagePath("ARESBAR.bmp"), 3, 575, 32, 2, 85, 85);
+	resDataBar = std::make_shared<CResDataBar>(ImagePath::builtin("ARESBAR.bmp"), 3, 575, 32, 2, 85, 85);
 
 	int faction = LOCPLINT->cb->getStartInfo()->playerInfos.find(LOCPLINT->playerID)->second.castle;
 

+ 1 - 1
lib/CConfigHandler.cpp

@@ -76,7 +76,7 @@ void SettingsStorage::invalidateNode(const std::vector<std::string> &changedPath
 	savedConf.Struct().erase("session");
 	JsonUtils::minimize(savedConf, "vcmi:settings");
 
-	std::fstream file(CResourceHandler::get()->getResourceName(ResourcePath("config/settings.json"))->c_str(), std::ofstream::out | std::ofstream::trunc);
+	std::fstream file(CResourceHandler::get()->getResourceName(JsonPath::builtin("config/settings.json"))->c_str(), std::ofstream::out | std::ofstream::trunc);
 	file << savedConf.toJson();
 }
 

+ 1 - 1
lib/JsonNode.cpp

@@ -1448,7 +1448,7 @@ JsonNode JsonUtils::assembleFromFiles(const std::vector<std::string> & files, bo
 JsonNode JsonUtils::assembleFromFiles(const std::string & filename)
 {
 	JsonNode result;
-	JsonPath resID(filename);
+	JsonPath resID = JsonPath::builtinTODO(filename);
 
 	for(auto & loader : CResourceHandler::get()->getResourcesWithName(resID))
 	{

+ 1 - 1
lib/filesystem/CFilesystemLoader.cpp

@@ -70,7 +70,7 @@ std::unordered_set<ResourcePath> CFilesystemLoader::getFilteredFiles(std::functi
 
 bool CFilesystemLoader::createResource(const ResourcePath & resID, bool update)
 {
-	std::string filename = resID.getOriginalName();
+	std::string filename = resID.getOriginalName() + '.' + boost::to_lower_copy(EResTypeHelper::getEResTypeAsString(resID.getType()));
 
 	if (fileList.find(resID) != fileList.end())
 		return true;

+ 11 - 5
lib/filesystem/ResourcePath.h

@@ -133,9 +133,15 @@ class DLL_LINKAGE ResourcePathTempl : public ResourcePath
 		type = Type;
 	}
 
-public:
-	using ResourcePath::ResourcePath;
+	ResourcePathTempl(const std::string & path)
+		:ResourcePath(path, Type)
+	{}
 
+	ResourcePathTempl(const JsonNode & name)
+		:ResourcePath(name, Type)
+	{}
+
+public:
 	ResourcePathTempl()
 		:ResourcePath("", Type)
 	{}
@@ -148,17 +154,17 @@ public:
 
 	static ResourcePathTempl builtin(const std::string & filename)
 	{
-		return ResourcePathTempl(filename, Type);
+		return ResourcePathTempl(filename);
 	}
 
 	static ResourcePathTempl builtinTODO(const std::string & filename)
 	{
-		return ResourcePathTempl(filename, Type);
+		return ResourcePathTempl(filename);
 	}
 
 	static ResourcePathTempl fromJson(const JsonNode & path)
 	{
-		return ResourcePathTempl(path, Type);
+		return ResourcePathTempl(path);
 	}
 
 	template<EResType Type2>