1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-15 11:46:56 +02:00

generate assets only when necessary

This commit is contained in:
Laserlicht 2024-08-29 00:37:39 +02:00
parent f327224d45
commit c6f0f8de03
8 changed files with 29 additions and 14 deletions

View File

@ -18,6 +18,7 @@
#include "gui/CGuiHandler.h" #include "gui/CGuiHandler.h"
#include "gui/WindowHandler.h" #include "gui/WindowHandler.h"
#include "render/IRenderHandler.h" #include "render/IRenderHandler.h"
#include "render/AssetGenerator.h"
#include "ClientNetPackVisitors.h" #include "ClientNetPackVisitors.h"
#include "../lib/CConfigHandler.h" #include "../lib/CConfigHandler.h"
#include "../lib/gameState/CGameState.h" #include "../lib/gameState/CGameState.h"
@ -502,6 +503,12 @@ void ClientCommandManager::handleVsLog(std::istringstream & singleWordBuffer)
logVisual->setKey(key); logVisual->setKey(key);
} }
void ClientCommandManager::handleGenerateAssets()
{
AssetGenerator::generateAll();
printCommandMessage("All assets generated");
}
void ClientCommandManager::printCommandMessage(const std::string &commandMessage, ELogLevel::ELogLevel messageType) void ClientCommandManager::printCommandMessage(const std::string &commandMessage, ELogLevel::ELogLevel messageType)
{ {
switch(messageType) switch(messageType)
@ -624,6 +631,9 @@ void ClientCommandManager::processCommand(const std::string & message, bool call
else if(commandName == "vslog") else if(commandName == "vslog")
handleVsLog(singleWordBuffer); handleVsLog(singleWordBuffer);
else if(message=="generate assets")
handleGenerateAssets();
else else
{ {
if (!commandName.empty() && !vstd::iswithin(commandName[0], 0, ' ')) // filter-out debugger/IDE noise if (!commandName.empty() && !vstd::iswithin(commandName[0], 0, ' ')) // filter-out debugger/IDE noise

View File

@ -84,6 +84,9 @@ class ClientCommandManager //take mantis #2292 issue about account if thinking a
// shows object graph // shows object graph
void handleVsLog(std::istringstream & singleWordBuffer); void handleVsLog(std::istringstream & singleWordBuffer);
// generate all assets
void handleGenerateAssets();
// Prints in Chat the given message // Prints in Chat the given message
void printCommandMessage(const std::string &commandMessage, ELogLevel::ELogLevel messageType = ELogLevel::NOT_SET); void printCommandMessage(const std::string &commandMessage, ELogLevel::ELogLevel messageType = ELogLevel::NOT_SET);
void giveTurn(const PlayerColor &color); void giveTurn(const PlayerColor &color);

View File

@ -24,7 +24,6 @@
#include "../render/Graphics.h" #include "../render/Graphics.h"
#include "../render/IFont.h" #include "../render/IFont.h"
#include "../render/EFont.h" #include "../render/EFont.h"
#include "../render/AssetGenerator.h"
#include "../renderSDL/ScreenHandler.h" #include "../renderSDL/ScreenHandler.h"
#include "../renderSDL/RenderHandler.h" #include "../renderSDL/RenderHandler.h"
#include "../CMT.h" #include "../CMT.h"
@ -64,8 +63,6 @@ void CGuiHandler::init()
shortcutsHandlerInstance = std::make_unique<ShortcutHandler>(); shortcutsHandlerInstance = std::make_unique<ShortcutHandler>();
inputHandlerInstance = std::make_unique<InputHandler>(); // Must be after windowHandlerInstance and shortcutsHandlerInstance inputHandlerInstance = std::make_unique<InputHandler>(); // Must be after windowHandlerInstance and shortcutsHandlerInstance
framerateManagerInstance = std::make_unique<FramerateManager>(settings["video"]["targetfps"].Integer()); framerateManagerInstance = std::make_unique<FramerateManager>(settings["video"]["targetfps"].Integer());
AssetGenerator::generate();
} }
void CGuiHandler::handleEvents() void CGuiHandler::handleEvents()

View File

@ -18,6 +18,7 @@
#include "../widgets/TextControls.h" #include "../widgets/TextControls.h"
#include "../CServerHandler.h" #include "../CServerHandler.h"
#include "../CGameInfo.h" #include "../CGameInfo.h"
#include "../render/AssetGenerator.h"
#include "../../lib/StartInfo.h" #include "../../lib/StartInfo.h"
#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/texts/CGeneralTextHandler.h"
@ -68,6 +69,8 @@ std::vector<SimturnsInfo> OptionsTabBase::getSimturnsPresets() const
OptionsTabBase::OptionsTabBase(const JsonPath & configPath) OptionsTabBase::OptionsTabBase(const JsonPath & configPath)
{ {
AssetGenerator::createAdventureOptionsCleanBackground();
recActions = 0; recActions = 0;
auto setTimerPresetCallback = [this](int index){ auto setTimerPresetCallback = [this](int index){

View File

@ -18,7 +18,7 @@
#include "../lib/filesystem/Filesystem.h" #include "../lib/filesystem/Filesystem.h"
void AssetGenerator::generate() void AssetGenerator::generateAll()
{ {
createBigSpellBook(); createBigSpellBook();
createAdventureOptionsCleanBackground(); createAdventureOptionsCleanBackground();

View File

@ -11,9 +11,8 @@
class AssetGenerator class AssetGenerator
{ {
public:
static void generateAll();
static void createAdventureOptionsCleanBackground(); static void createAdventureOptionsCleanBackground();
static void createBigSpellBook(); static void createBigSpellBook();
public:
static void generate();
}; };

View File

@ -31,6 +31,7 @@
#include "../widgets/TextControls.h" #include "../widgets/TextControls.h"
#include "../widgets/Buttons.h" #include "../widgets/Buttons.h"
#include "../adventureMap/AdventureMapInterface.h" #include "../adventureMap/AdventureMapInterface.h"
#include "../render/AssetGenerator.h"
#include "../../CCallback.h" #include "../../CCallback.h"
@ -115,6 +116,7 @@ CSpellWindow::CSpellWindow(const CGHeroInstance * _myHero, CPlayerInterface * _m
if(isBigSpellbook) if(isBigSpellbook)
{ {
AssetGenerator::createBigSpellBook();
background = std::make_shared<CPicture>(ImagePath::builtin("SpellBookLarge"), 0, 0); background = std::make_shared<CPicture>(ImagePath::builtin("SpellBookLarge"), 0, 0);
updateShadow(); updateShadow();
} }

View File

@ -127,6 +127,7 @@ Below a list of supported commands, with their arguments wrapped in `<>`
`get txt` - save game texts into .txt files matching original heroes 3 files `get txt` - save game texts into .txt files matching original heroes 3 files
`def2bmp <.def file name>` - extract .def animation as BMP files `def2bmp <.def file name>` - extract .def animation as BMP files
`extract <relative file path>` - export file into directory used by other extraction commands `extract <relative file path>` - export file into directory used by other extraction commands
`generate assets` - generate all assets at once
#### AI commands #### AI commands
`setBattleAI <ai name>` - change battle AI used by neutral creatures to the one specified, persists through game quit `setBattleAI <ai name>` - change battle AI used by neutral creatures to the one specified, persists through game quit