mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Remove unused code and no longer needed caching
This commit is contained in:
		| @@ -934,9 +934,6 @@ StackQueue::StackQueue(bool Embedded, BattleInterface & owner) | |||||||
| 		pos.h = 49; | 		pos.h = 49; | ||||||
| 		pos.x += parent->pos.w/2 - pos.w/2; | 		pos.x += parent->pos.w/2 - pos.w/2; | ||||||
| 		pos.y += queueSmallOutside ? -queueSmallOutsideYOffset : 10; | 		pos.y += queueSmallOutside ? -queueSmallOutsideYOffset : 10; | ||||||
|  |  | ||||||
| 		icons = GH.renderHandler().loadAnimation(AnimationPath::builtin("CPRSMALL")); |  | ||||||
| 		stateIcons = GH.renderHandler().loadAnimation(AnimationPath::builtin("VCMI/BATTLEQUEUE/STATESSMALL")); |  | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| @@ -946,13 +943,7 @@ StackQueue::StackQueue(bool Embedded, BattleInterface & owner) | |||||||
| 		pos.y -= pos.h; | 		pos.y -= pos.h; | ||||||
|  |  | ||||||
| 		background = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), Rect(0, 0, pos.w, pos.h)); | 		background = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), Rect(0, 0, pos.w, pos.h)); | ||||||
|  |  | ||||||
| 		icons = GH.renderHandler().loadAnimation(AnimationPath::builtin("TWCRPORT")); |  | ||||||
| 		stateIcons = GH.renderHandler().loadAnimation(AnimationPath::builtin("VCMI/BATTLEQUEUE/STATESSMALL")); |  | ||||||
| 		//TODO: where use big icons? |  | ||||||
| 		//stateIcons = GH.renderHandler().loadAnimation("VCMI/BATTLEQUEUE/STATESBIG"); |  | ||||||
| 	} | 	} | ||||||
| 	stateIcons->preload(); |  | ||||||
|  |  | ||||||
| 	stackBoxes.resize(queueSize); | 	stackBoxes.resize(queueSize); | ||||||
| 	for (int i = 0; i < stackBoxes.size(); i++) | 	for (int i = 0; i < stackBoxes.size(); i++) | ||||||
| @@ -1021,13 +1012,13 @@ StackQueue::StackBox::StackBox(StackQueue * owner): | |||||||
|  |  | ||||||
| 	if(owner->embedded) | 	if(owner->embedded) | ||||||
| 	{ | 	{ | ||||||
| 		icon = std::make_shared<CAnimImage>(owner->icons, 0, 0, 5, 2); | 		icon = std::make_shared<CAnimImage>(AnimationPath::builtin("CPRSMALL"), 0, 0, 5, 2); | ||||||
| 		amount = std::make_shared<CLabel>(pos.w/2, pos.h - 7, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE); | 		amount = std::make_shared<CLabel>(pos.w/2, pos.h - 7, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE); | ||||||
| 		roundRect = std::make_shared<TransparentFilledRectangle>(Rect(0, 0, 2, 48), ColorRGBA(0, 0, 0, 255), ColorRGBA(0, 255, 0, 255)); | 		roundRect = std::make_shared<TransparentFilledRectangle>(Rect(0, 0, 2, 48), ColorRGBA(0, 0, 0, 255), ColorRGBA(0, 255, 0, 255)); | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		icon = std::make_shared<CAnimImage>(owner->icons, 0, 0, 9, 1); | 		icon = std::make_shared<CAnimImage>(AnimationPath::builtin("TWCRPORT"), 0, 0, 9, 1); | ||||||
| 		amount = std::make_shared<CLabel>(pos.w/2, pos.h - 8, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE); | 		amount = std::make_shared<CLabel>(pos.w/2, pos.h - 8, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE); | ||||||
| 		roundRect = std::make_shared<TransparentFilledRectangle>(Rect(0, 0, 15, 18), ColorRGBA(0, 0, 0, 255), ColorRGBA(241, 216, 120, 255)); | 		roundRect = std::make_shared<TransparentFilledRectangle>(Rect(0, 0, 15, 18), ColorRGBA(0, 0, 0, 255), ColorRGBA(241, 216, 120, 255)); | ||||||
| 		round = std::make_shared<CLabel>(4, 2, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE); | 		round = std::make_shared<CLabel>(4, 2, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE); | ||||||
| @@ -1035,7 +1026,7 @@ StackQueue::StackBox::StackBox(StackQueue * owner): | |||||||
| 		int icon_x = pos.w - 17; | 		int icon_x = pos.w - 17; | ||||||
| 		int icon_y = pos.h - 18; | 		int icon_y = pos.h - 18; | ||||||
|  |  | ||||||
| 		stateIcon = std::make_shared<CAnimImage>(owner->stateIcons, 0, 0, icon_x, icon_y); | 		stateIcon = std::make_shared<CAnimImage>(AnimationPath::builtin("VCMI/BATTLEQUEUE/STATESSMALL"), 0, 0, icon_x, icon_y); | ||||||
| 		stateIcon->visible = false; | 		stateIcon->visible = false; | ||||||
| 	} | 	} | ||||||
| 	roundRect->disable(); | 	roundRect->disable(); | ||||||
|   | |||||||
| @@ -274,9 +274,6 @@ class StackQueue : public CIntObject | |||||||
| 	std::vector<std::shared_ptr<StackBox>> stackBoxes; | 	std::vector<std::shared_ptr<StackBox>> stackBoxes; | ||||||
| 	BattleInterface & owner; | 	BattleInterface & owner; | ||||||
|  |  | ||||||
| 	std::shared_ptr<CAnimation> icons; |  | ||||||
| 	std::shared_ptr<CAnimation> stateIcons; |  | ||||||
|  |  | ||||||
| 	int32_t getSiegeShooterIconID(); | 	int32_t getSiegeShooterIconID(); | ||||||
| public: | public: | ||||||
| 	const bool embedded; | 	const bool embedded; | ||||||
|   | |||||||
| @@ -227,11 +227,8 @@ SelectionTab::SelectionTab(ESelectionScreen Type) | |||||||
| 		buttonsSortBy.push_back(sortByDate); | 		buttonsSortBy.push_back(sortByDate); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	iconsMapFormats = GH.renderHandler().loadAnimation(AnimationPath::builtin("SCSELC.DEF")); |  | ||||||
| 	iconsVictoryCondition = GH.renderHandler().loadAnimation(AnimationPath::builtin("SCNRVICT.DEF")); |  | ||||||
| 	iconsLossCondition = GH.renderHandler().loadAnimation(AnimationPath::builtin("SCNRLOSS.DEF")); |  | ||||||
| 	for(int i = 0; i < positionsToShow; i++) | 	for(int i = 0; i < positionsToShow; i++) | ||||||
| 		listItems.push_back(std::make_shared<ListItem>(Point(30, 129 + i * 25), iconsMapFormats, iconsVictoryCondition, iconsLossCondition)); | 		listItems.push_back(std::make_shared<ListItem>(Point(30, 129 + i * 25))); | ||||||
|  |  | ||||||
| 	labelTabTitle = std::make_shared<CLabel>(205, 28, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, tabTitle); | 	labelTabTitle = std::make_shared<CLabel>(205, 28, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, tabTitle); | ||||||
| 	slider = std::make_shared<CSlider>(Point(372, 86 + (enableUiEnhancements ? 30 : 0)), (tabType != ESelectionScreen::saveGame ? 480 : 430) - (enableUiEnhancements ? 30 : 0), std::bind(&SelectionTab::sliderMove, this, _1), positionsToShow, (int)curItems.size(), 0, Orientation::VERTICAL, CSlider::BLUE); | 	slider = std::make_shared<CSlider>(Point(372, 86 + (enableUiEnhancements ? 30 : 0)), (tabType != ESelectionScreen::saveGame ? 480 : 430) - (enableUiEnhancements ? 30 : 0), std::bind(&SelectionTab::sliderMove, this, _1), positionsToShow, (int)curItems.size(), 0, Orientation::VERTICAL, CSlider::BLUE); | ||||||
| @@ -883,7 +880,7 @@ std::unordered_set<ResourcePath> SelectionTab::getFiles(std::string dirURI, ERes | |||||||
| 	return ret; | 	return ret; | ||||||
| } | } | ||||||
|  |  | ||||||
| SelectionTab::ListItem::ListItem(Point position, std::shared_ptr<CAnimation> iconsFormats, std::shared_ptr<CAnimation> iconsVictory, std::shared_ptr<CAnimation> iconsLoss) | SelectionTab::ListItem::ListItem(Point position) | ||||||
| 	: CIntObject(LCLICK, position) | 	: CIntObject(LCLICK, position) | ||||||
| { | { | ||||||
| 	OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; | 	OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; | ||||||
| @@ -898,9 +895,9 @@ SelectionTab::ListItem::ListItem(Point position, std::shared_ptr<CAnimation> ico | |||||||
| 	labelMapSizeLetter->setAutoRedraw(false); | 	labelMapSizeLetter->setAutoRedraw(false); | ||||||
| 	// FIXME: This -12 should not be needed, but for some reason CAnimImage displaced otherwise | 	// FIXME: This -12 should not be needed, but for some reason CAnimImage displaced otherwise | ||||||
| 	iconFolder = std::make_shared<CPicture>(ImagePath::builtin("lobby/iconFolder.png"), -8, -12); | 	iconFolder = std::make_shared<CPicture>(ImagePath::builtin("lobby/iconFolder.png"), -8, -12); | ||||||
| 	iconFormat = std::make_shared<CAnimImage>(iconsFormats, 0, 0, 59, -12); | 	iconFormat = std::make_shared<CAnimImage>(AnimationPath::builtin("SCSELC.DEF"), 0, 0, 59, -12); | ||||||
| 	iconVictoryCondition = std::make_shared<CAnimImage>(iconsVictory, 0, 0, 277, -12); | 	iconVictoryCondition = std::make_shared<CAnimImage>(AnimationPath::builtin("SCNRVICT.DEF"), 0, 0, 277, -12); | ||||||
| 	iconLossCondition = std::make_shared<CAnimImage>(iconsLoss, 0, 0, 310, -12); | 	iconLossCondition = std::make_shared<CAnimImage>(AnimationPath::builtin("SCNRLOSS.DEF"), 0, 0, 310, -12); | ||||||
| } | } | ||||||
|  |  | ||||||
| void SelectionTab::ListItem::updateItem(std::shared_ptr<ElementInfo> info, bool selected) | void SelectionTab::ListItem::updateItem(std::shared_ptr<ElementInfo> info, bool selected) | ||||||
|   | |||||||
| @@ -59,7 +59,7 @@ class SelectionTab : public CIntObject | |||||||
| 		std::shared_ptr<CPicture> pictureEmptyLine; | 		std::shared_ptr<CPicture> pictureEmptyLine; | ||||||
| 		std::shared_ptr<CLabel> labelName; | 		std::shared_ptr<CLabel> labelName; | ||||||
|  |  | ||||||
| 		ListItem(Point position, std::shared_ptr<CAnimation> iconsFormats, std::shared_ptr<CAnimation> iconsVictory, std::shared_ptr<CAnimation> iconsLoss); | 		ListItem(Point position); | ||||||
| 		void updateItem(std::shared_ptr<ElementInfo> info = {}, bool selected = false); | 		void updateItem(std::shared_ptr<ElementInfo> info = {}, bool selected = false); | ||||||
| 	}; | 	}; | ||||||
| 	std::vector<std::shared_ptr<ListItem>> listItems; | 	std::vector<std::shared_ptr<ListItem>> listItems; | ||||||
|   | |||||||
| @@ -25,7 +25,6 @@ bool CAnimation::loadFrame(size_t frame, size_t group) | |||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
| 	if(auto image = getImage(frame, group, false)) | 	if(auto image = getImage(frame, group, false)) | ||||||
| 	{ | 	{ | ||||||
| 		return true; | 		return true; | ||||||
|   | |||||||
| @@ -47,7 +47,6 @@ public: | |||||||
|  |  | ||||||
| 	//draws image on surface "where" at position | 	//draws image on surface "where" at position | ||||||
| 	virtual void draw(SDL_Surface * where, const Point & pos, const Rect * src = nullptr) const = 0; | 	virtual void draw(SDL_Surface * where, const Point & pos, const Rect * src = nullptr) const = 0; | ||||||
| 	//virtual void draw(SDL_Surface * where, const Rect * dest, const Rect * src) const = 0; |  | ||||||
|  |  | ||||||
| 	virtual void scaleFast(const Point & size) = 0; | 	virtual void scaleFast(const Point & size) = 0; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -115,19 +115,6 @@ const RenderHandler::AnimationLayoutMap & RenderHandler::getAnimationLayout(cons | |||||||
| 	return animationLayouts[path]; | 	return animationLayouts[path]; | ||||||
| } | } | ||||||
|  |  | ||||||
| //std::shared_ptr<JsonNode> RenderHandler::getJsonFile(const JsonPath & path) |  | ||||||
| //{ |  | ||||||
| //	auto it = jsonFiles.find(path); |  | ||||||
| // |  | ||||||
| //	if (it != jsonFiles.end()) |  | ||||||
| //		return it->second; |  | ||||||
| // |  | ||||||
| //	auto result = std::make_shared<JsonNode>(path); |  | ||||||
| // |  | ||||||
| //	jsonFiles[path] = result; |  | ||||||
| //	return result; |  | ||||||
| //} |  | ||||||
|  |  | ||||||
| std::shared_ptr<IImage> RenderHandler::loadImage(const AnimationPath & path, int frame, int group) | std::shared_ptr<IImage> RenderHandler::loadImage(const AnimationPath & path, int frame, int group) | ||||||
| { | { | ||||||
| 	AnimationLocator locator{path, frame, group}; | 	AnimationLocator locator{path, frame, group}; | ||||||
| @@ -143,19 +130,6 @@ std::shared_ptr<IImage> RenderHandler::loadImage(const AnimationPath & path, int | |||||||
| 	return result->createImageReference(); | 	return result->createImageReference(); | ||||||
| } | } | ||||||
|  |  | ||||||
| //std::vector<std::shared_ptr<IImage>> RenderHandler::loadImageGroup(const AnimationPath & path, int group) |  | ||||||
| //{ |  | ||||||
| //	const auto defFile = getAnimationFile(path); |  | ||||||
| // |  | ||||||
| //	size_t groupSize = defFile->getEntries().at(group); |  | ||||||
| // |  | ||||||
| //	std::vector<std::shared_ptr<IImage>> result; |  | ||||||
| //	for (size_t i = 0; i < groupSize; ++i) |  | ||||||
| //		loadImage(path, i, group); |  | ||||||
| // |  | ||||||
| //	return result; |  | ||||||
| //} |  | ||||||
|  |  | ||||||
| std::shared_ptr<IImage> RenderHandler::loadImage(const ImagePath & path) | std::shared_ptr<IImage> RenderHandler::loadImage(const ImagePath & path) | ||||||
| { | { | ||||||
| 	return loadImage(path, EImageBlitMode::ALPHA); | 	return loadImage(path, EImageBlitMode::ALPHA); | ||||||
|   | |||||||
| @@ -234,9 +234,9 @@ void SDLImageConst::savePalette() | |||||||
| 		return; | 		return; | ||||||
|  |  | ||||||
| 	if(originalPalette == nullptr) | 	if(originalPalette == nullptr) | ||||||
| 		originalPalette = SDL_AllocPalette(DEFAULT_PALETTE_COLORS); | 		originalPalette = SDL_AllocPalette(surf->format->palette->ncolors); | ||||||
|  |  | ||||||
| 	SDL_SetPaletteColors(originalPalette, surf->format->palette->colors, 0, DEFAULT_PALETTE_COLORS); | 	SDL_SetPaletteColors(originalPalette, surf->format->palette->colors, 0, surf->format->palette->ncolors); | ||||||
| } | } | ||||||
|  |  | ||||||
| void SDLImageIndexed::shiftPalette(uint32_t firstColorID, uint32_t colorsToMove, uint32_t distanceToMove) | void SDLImageIndexed::shiftPalette(uint32_t firstColorID, uint32_t colorsToMove, uint32_t distanceToMove) | ||||||
|   | |||||||
| @@ -26,8 +26,6 @@ struct SDL_Palette; | |||||||
|  */ |  */ | ||||||
| class SDLImageConst final : public IConstImage, public std::enable_shared_from_this<SDLImageConst>, boost::noncopyable | class SDLImageConst final : public IConstImage, public std::enable_shared_from_this<SDLImageConst>, boost::noncopyable | ||||||
| { | { | ||||||
| 	static constexpr int DEFAULT_PALETTE_COLORS = 256; |  | ||||||
| 	 |  | ||||||
| 	//Surface without empty borders | 	//Surface without empty borders | ||||||
| 	SDL_Surface * surf; | 	SDL_Surface * surf; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -32,8 +32,8 @@ void SDLImageLoader::init(Point SpriteSize, Point Margins, Point FullSize, SDL_C | |||||||
| 	image->fullSize = FullSize; | 	image->fullSize = FullSize; | ||||||
|  |  | ||||||
| 	//Prepare surface | 	//Prepare surface | ||||||
| 	SDL_Palette * p = SDL_AllocPalette(SDLImageConst::DEFAULT_PALETTE_COLORS); | 	SDL_Palette * p = SDL_AllocPalette(DEFAULT_PALETTE_COLORS); | ||||||
| 	SDL_SetPaletteColors(p, pal, 0, SDLImageConst::DEFAULT_PALETTE_COLORS); | 	SDL_SetPaletteColors(p, pal, 0, DEFAULT_PALETTE_COLORS); | ||||||
| 	SDL_SetSurfacePalette(image->surf, p); | 	SDL_SetSurfacePalette(image->surf, p); | ||||||
| 	SDL_FreePalette(p); | 	SDL_FreePalette(p); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -15,6 +15,8 @@ class SDLImageConst; | |||||||
|  |  | ||||||
| class SDLImageLoader : public IImageLoader | class SDLImageLoader : public IImageLoader | ||||||
| { | { | ||||||
|  | 	static constexpr int DEFAULT_PALETTE_COLORS = 256; | ||||||
|  |  | ||||||
| 	SDLImageConst * image; | 	SDLImageConst * image; | ||||||
| 	ui8 * lineStart; | 	ui8 * lineStart; | ||||||
| 	ui8 * position; | 	ui8 * position; | ||||||
|   | |||||||
| @@ -180,16 +180,16 @@ CAnimImage::CAnimImage(const AnimationPath & name, size_t Frame, size_t Group, i | |||||||
| 	init(); | 	init(); | ||||||
| } | } | ||||||
|  |  | ||||||
| CAnimImage::CAnimImage(std::shared_ptr<CAnimation> Anim, size_t Frame, size_t Group, int x, int y, ui8 Flags): | //CAnimImage::CAnimImage(std::shared_ptr<CAnimation> Anim, size_t Frame, size_t Group, int x, int y, ui8 Flags): | ||||||
| 	anim(Anim), | //	anim(Anim), | ||||||
| 	frame(Frame), | //	frame(Frame), | ||||||
| 	group(Group), | //	group(Group), | ||||||
| 	flags(Flags) | //	flags(Flags) | ||||||
| { | //{ | ||||||
| 	pos.x += x; | //	pos.x += x; | ||||||
| 	pos.y += y; | //	pos.y += y; | ||||||
| 	init(); | //	init(); | ||||||
| } | //} | ||||||
|  |  | ||||||
| CAnimImage::CAnimImage(const AnimationPath & name, size_t Frame, Rect targetPos, size_t Group, ui8 Flags): | CAnimImage::CAnimImage(const AnimationPath & name, size_t Frame, Rect targetPos, size_t Group, ui8 Flags): | ||||||
| 	anim(GH.renderHandler().loadAnimation(name)), | 	anim(GH.renderHandler().loadAnimation(name)), | ||||||
|   | |||||||
| @@ -103,7 +103,7 @@ public: | |||||||
| 	bool visible; | 	bool visible; | ||||||
|  |  | ||||||
| 	CAnimImage(const AnimationPath & name, size_t Frame, size_t Group=0, int x=0, int y=0, ui8 Flags=0); | 	CAnimImage(const AnimationPath & name, size_t Frame, size_t Group=0, int x=0, int y=0, ui8 Flags=0); | ||||||
| 	CAnimImage(std::shared_ptr<CAnimation> Anim, size_t Frame, size_t Group=0, int x=0, int y=0, ui8 Flags=0); | //	CAnimImage(std::shared_ptr<CAnimation> Anim, size_t Frame, size_t Group=0, int x=0, int y=0, ui8 Flags=0); | ||||||
| 	CAnimImage(const AnimationPath & name, size_t Frame, Rect targetPos, size_t Group=0, ui8 Flags=0); | 	CAnimImage(const AnimationPath & name, size_t Frame, Rect targetPos, size_t Group=0, ui8 Flags=0); | ||||||
| 	~CAnimImage(); | 	~CAnimImage(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -149,12 +149,11 @@ CHeroWindow::CHeroWindow(const CGHeroInstance * hero) | |||||||
| 	expValue = std::make_shared<CLabel>(68, 252); | 	expValue = std::make_shared<CLabel>(68, 252); | ||||||
| 	manaValue = std::make_shared<CLabel>(211, 252); | 	manaValue = std::make_shared<CLabel>(211, 252); | ||||||
|  |  | ||||||
| 	auto secSkills = GH.renderHandler().loadAnimation(AnimationPath::builtin("SECSKILL")); |  | ||||||
| 	for(int i = 0; i < std::min<size_t>(hero->secSkills.size(), 8u); ++i) | 	for(int i = 0; i < std::min<size_t>(hero->secSkills.size(), 8u); ++i) | ||||||
| 	{ | 	{ | ||||||
| 		Rect r = Rect(i%2 == 0  ?  18  :  162,  276 + 48 * (i/2),  136,  42); | 		Rect r = Rect(i%2 == 0  ?  18  :  162,  276 + 48 * (i/2),  136,  42); | ||||||
| 		secSkillAreas.push_back(std::make_shared<LRClickableAreaWTextComp>(r, ComponentType::SEC_SKILL)); | 		secSkillAreas.push_back(std::make_shared<LRClickableAreaWTextComp>(r, ComponentType::SEC_SKILL)); | ||||||
| 		secSkillImages.push_back(std::make_shared<CAnimImage>(secSkills, 0, 0, r.x, r.y)); | 		secSkillImages.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("SECSKILL"), 0, 0, r.x, r.y)); | ||||||
|  |  | ||||||
| 		int x = (i % 2) ? 212 : 68; | 		int x = (i % 2) ? 212 : 68; | ||||||
| 		int y = 280 + 48 * (i/2); | 		int y = 280 + 48 * (i/2); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user