1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Fix regressions

This commit is contained in:
Ivan Savenko 2023-09-04 14:29:02 +03:00
parent 0f88b8969b
commit 9cfcf5ea19
13 changed files with 45 additions and 38 deletions

View File

@ -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());
}

View File

@ -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());

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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)

View File

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

View File

@ -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
}

View File

@ -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;

View File

@ -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;

View File

@ -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();
}

View File

@ -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))
{

View File

@ -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;

View File

@ -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>