Moved the whole logic to a new file (TooltipManager.cpp), and rewrote most of the logic to profit from object oriented programming. The side-effect is that the changes are scattered across entities, tiles and items because moving everything to OOP requires to add the tooltip to every .cpp file for every tile/item/entities (or their class, on plants for example which all use the tooltip IDS_TOOLTIPS_PLANT)
The issue with the default tooltips loop written by 4J is that:
Its running in the main Minecraft::tick loop and is more than a thousand lines long, polluting the function.
Not using C++'s full potential with object oriented programming, 4J decided to use a big switch case (probably because it could run better on hardware without branch prediction like the WiiU or Xbox 360 ?)
And seems to be better off in its own file than in the main Minecraft.cpp file
34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "Item.h"
|
|
|
|
class Player;
|
|
class Level;
|
|
|
|
class BowItem : public Item
|
|
{
|
|
public:
|
|
static const wstring TEXTURE_PULL[];
|
|
static const int MAX_DRAW_DURATION = 20 * 1;
|
|
|
|
private:
|
|
static const int BOW_ICONS_COUNT = 3;
|
|
Icon **icons;
|
|
|
|
public:
|
|
BowItem(int id);
|
|
|
|
virtual void releaseUsing(shared_ptr<ItemInstance> itemInstance, Level *level, shared_ptr<Player> player, int durationLeft);
|
|
virtual shared_ptr<ItemInstance> useTimeDepleted(shared_ptr<ItemInstance> instance, Level *level, shared_ptr<Player> player);
|
|
virtual int getUseDuration(shared_ptr<ItemInstance> itemInstance);
|
|
virtual UseAnim getUseAnimation(shared_ptr<ItemInstance> itemInstance);
|
|
virtual shared_ptr<ItemInstance> use(shared_ptr<ItemInstance> instance, Level *level, shared_ptr<Player> player);
|
|
virtual int getEnchantmentValue();
|
|
|
|
//@Override
|
|
void registerIcons(IconRegister *iconRegister);
|
|
Icon *getDrawnIcon(int amount);
|
|
|
|
virtual int getUseTooltipId(std::shared_ptr<ItemInstance> itemInstance, std::shared_ptr<Player> player, Level* level, int x, int y, int z, bool bUseItem) const;
|
|
};
|