summaryrefslogtreecommitdiffstats
path: root/src/UI
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-06-01 10:43:37 +0200
committerMattes D <github@xoft.cz>2014-06-01 10:43:37 +0200
commit2059944d1e39e952c164b8a87c0c3f216b3b731e (patch)
treefd210c1cf1bfcda2f7ed1292df01a26f9555c057 /src/UI
parentInitial commit of the Generator article. (diff)
parentUpdated AlchemistVillage prefabs. (diff)
downloadcuberite-2059944d1e39e952c164b8a87c0c3f216b3b731e.tar
cuberite-2059944d1e39e952c164b8a87c0c3f216b3b731e.tar.gz
cuberite-2059944d1e39e952c164b8a87c0c3f216b3b731e.tar.bz2
cuberite-2059944d1e39e952c164b8a87c0c3f216b3b731e.tar.lz
cuberite-2059944d1e39e952c164b8a87c0c3f216b3b731e.tar.xz
cuberite-2059944d1e39e952c164b8a87c0c3f216b3b731e.tar.zst
cuberite-2059944d1e39e952c164b8a87c0c3f216b3b731e.zip
Diffstat (limited to 'src/UI')
-rw-r--r--src/UI/SlotArea.cpp44
-rw-r--r--src/UI/SlotArea.h6
2 files changed, 48 insertions, 2 deletions
diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp
index 788974f9c..507b45833 100644
--- a/src/UI/SlotArea.cpp
+++ b/src/UI/SlotArea.cpp
@@ -496,6 +496,8 @@ void cSlotAreaCrafting::ClickedResult(cPlayer & a_Player)
DraggingItem = Result;
Recipe.ConsumeIngredients(Grid);
Grid.CopyToItems(PlayerSlots);
+
+ HandleCraftItem(Result, a_Player);
}
else if (DraggingItem.IsEqual(Result))
{
@@ -505,6 +507,8 @@ void cSlotAreaCrafting::ClickedResult(cPlayer & a_Player)
DraggingItem.m_ItemCount += Result.m_ItemCount;
Recipe.ConsumeIngredients(Grid);
Grid.CopyToItems(PlayerSlots);
+
+ HandleCraftItem(Result, a_Player);
}
}
@@ -594,6 +598,27 @@ cCraftingRecipe & cSlotAreaCrafting::GetRecipeForPlayer(cPlayer & a_Player)
+void cSlotAreaCrafting::HandleCraftItem(const cItem & a_Result, cPlayer & a_Player)
+{
+ switch (a_Result.m_ItemType)
+ {
+ case E_BLOCK_WORKBENCH: a_Player.AwardAchievement(achCraftWorkbench); break;
+ case E_BLOCK_FURNACE: a_Player.AwardAchievement(achCraftFurnace); break;
+ case E_BLOCK_CAKE: a_Player.AwardAchievement(achBakeCake); break;
+ case E_BLOCK_ENCHANTMENT_TABLE: a_Player.AwardAchievement(achCraftEnchantTable); break;
+ case E_BLOCK_BOOKCASE: a_Player.AwardAchievement(achBookshelf); break;
+ case E_ITEM_WOODEN_PICKAXE: a_Player.AwardAchievement(achCraftPickaxe); break;
+ case E_ITEM_WOODEN_SWORD: a_Player.AwardAchievement(achCraftSword); break;
+ case E_ITEM_STONE_PICKAXE: a_Player.AwardAchievement(achCraftBetterPick); break;
+ case E_ITEM_WOODEN_HOE: a_Player.AwardAchievement(achCraftHoe); break;
+ case E_ITEM_BREAD: a_Player.AwardAchievement(achMakeBread); break;
+ default: break;
+ }
+}
+
+
+
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cSlotAreaAnvil:
@@ -760,7 +785,7 @@ void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player)
{
if (!a_Player.IsGameModeCreative())
{
- a_Player.DeltaExperience(cPlayer::XpForLevel(m_MaximumCost));
+ a_Player.DeltaExperience(-cPlayer::XpForLevel(m_MaximumCost));
}
SetSlot(0, a_Player, cItem());
@@ -1393,7 +1418,7 @@ void cSlotAreaFurnace::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
{
// Something has changed in the window, broadcast the entire window to all clients
ASSERT(a_ItemGrid == &(m_Furnace->GetContents()));
-
+
m_ParentWindow.BroadcastWholeWindow();
}
@@ -1401,6 +1426,21 @@ void cSlotAreaFurnace::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum)
+void cSlotAreaFurnace::HandleSmeltItem(const cItem & a_Result, cPlayer & a_Player)
+{
+ /** TODO 2014-05-12 xdot: Figure out when to call this method. */
+ switch (a_Result.m_ItemType)
+ {
+ case E_ITEM_IRON: a_Player.AwardAchievement(achAcquireIron); break;
+ case E_ITEM_COOKED_FISH: a_Player.AwardAchievement(achCookFish); break;
+ default: break;
+ }
+}
+
+
+
+
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cSlotAreaInventoryBase:
diff --git a/src/UI/SlotArea.h b/src/UI/SlotArea.h
index 4da6a672f..e297bcff7 100644
--- a/src/UI/SlotArea.h
+++ b/src/UI/SlotArea.h
@@ -254,6 +254,9 @@ protected:
/// Retrieves the recipe for the specified player from the map, or creates one if not found
cCraftingRecipe & GetRecipeForPlayer(cPlayer & a_Player);
+
+ /// Called after an item has been crafted to handle statistics e.t.c.
+ void HandleCraftItem(const cItem & a_Result, cPlayer & a_Player);
} ;
@@ -397,6 +400,9 @@ protected:
// cItemGrid::cListener overrides:
virtual void OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) override;
+
+ /// Called after an item has been smelted to handle statistics e.t.c.
+ void HandleSmeltItem(const cItem & a_Result, cPlayer & a_Player);
} ;