Something went wrong. Try again.
the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
Something went wrong. Try again.
42 kB · 1424 lines
C++
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425#include "stdafx.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.item.crafting.h"#include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.h"#include "..\..\..\Minecraft.World\net.minecraft.stats.h"#include "..\..\LocalPlayer.h"#include "IUIScene_CraftingMenu.h"
Recipy::_eGroupType IUIScene_CraftingMenu::m_GroupTypeMapping4GridA[IUIScene_CraftingMenu::m_iMaxGroup2x2]={ Recipy::eGroupType_Structure, Recipy::eGroupType_Tool, Recipy::eGroupType_Food, Recipy::eGroupType_Mechanism, Recipy::eGroupType_Transport, Recipy::eGroupType_Decoration,};
Recipy::_eGroupType IUIScene_CraftingMenu::m_GroupTypeMapping9GridA[IUIScene_CraftingMenu::m_iMaxGroup3x3]={ Recipy::eGroupType_Structure, Recipy::eGroupType_Tool, Recipy::eGroupType_Food, Recipy::eGroupType_Armour, Recipy::eGroupType_Mechanism, Recipy::eGroupType_Transport, Recipy::eGroupType_Decoration,};
LPCWSTR IUIScene_CraftingMenu::m_GroupIconNameA[m_iMaxGroup3x3]={ L"Structures",//Recipy::eGroupType_Structure, L"Tools",//Recipy::eGroupType_Tool, L"Food",//Recipy::eGroupType_Food, L"Armour",//Recipy::eGroupType_Armour, L"Mechanisms",//Recipy::eGroupType_Mechanism, L"Transport",//Recipy::eGroupType_Transport, L"Decoration",//Recipy::eGroupType_Decoration,};
IUIScene_CraftingMenu::_eGroupTab IUIScene_CraftingMenu::m_GroupTabBkgMapping2x2A[m_iMaxGroup2x2]={ eGroupTab_Left, eGroupTab_Middle, eGroupTab_Middle, eGroupTab_Middle, eGroupTab_Middle, eGroupTab_Right,};
IUIScene_CraftingMenu::_eGroupTab IUIScene_CraftingMenu::m_GroupTabBkgMapping3x3A[m_iMaxGroup3x3]={ eGroupTab_Left, eGroupTab_Middle, eGroupTab_Middle, eGroupTab_Middle, eGroupTab_Middle, eGroupTab_Middle, eGroupTab_Right,};
// mapping array to map the base objects to their description string// This should map the enums// enum// {// eBaseItemType_undefined=0,// eBaseItemType_sword,// eBaseItemType_shovel,// eBaseItemType_pickaxe,// eBaseItemType_hatchet,// eBaseItemType_hoe,// eBaseItemType_door,// eBaseItemType_helmet,// eBaseItemType_chestplate,// eBaseItemType_leggings,// eBaseItemType_boots,// eBaseItemType_ingot,// eBaseItemType_rail,// eBaseItemType_block,// eBaseItemType_pressureplate,// eBaseItemType_stairs,// eBaseItemType_cloth,// eBaseItemType_dyepowder,// eBaseItemType_structplanks// eBaseItemType_structblock,// eBaseItemType_slab,// eBaseItemType_halfslab,// eBaseItemType_torch,// eBaseItemType_bow,// eBaseItemType_pockettool,// eBaseItemType_utensil,// // }// eBaseItemType;
IUIScene_CraftingMenu::IUIScene_CraftingMenu(){ m_iCurrentSlotHIndex=0; m_iCurrentSlotVIndex=1;
for(int i=0;i<m_iMaxHSlotC;i++) { CanBeMadeA[i].iCount=0; CanBeMadeA[i].iItemBaseType=0; } memset(CanBeMadeA,0,sizeof(CANBEMADE)*m_iMaxHSlotC); m_iRecipeC=0; m_iGroupIndex=0;
for(int i=0;i<m_iMaxDisplayedVSlotC;i++) { iVSlotIndexA[i]=i; // start with 0,1,2 }
m_iDisplayDescription=DISPLAY_INVENTORY; m_iIngredientsC=0;}
LPCWSTR IUIScene_CraftingMenu::GetGroupNameText(int iGroupType){ switch(iGroupType) { case ShapedRecipy::eGroupType_Tool: return app.GetString( IDS_GROUPNAME_TOOLS ); case ShapedRecipy::eGroupType_Food: return app.GetString( IDS_GROUPNAME_FOOD); case ShapedRecipy::eGroupType_Structure: return app.GetString( IDS_GROUPNAME_STRUCTURES ); case ShapedRecipy::eGroupType_Armour: return app.GetString( IDS_GROUPNAME_ARMOUR ); case ShapedRecipy::eGroupType_Mechanism: return app.GetString( IDS_GROUPNAME_MECHANISMS ); case ShapedRecipy::eGroupType_Transport: return app.GetString( IDS_GROUPNAME_TRANSPORT ); case ShapedRecipy::eGroupType_Decoration: default: return app.GetString( IDS_GROUPNAME_DECORATIONS ); }}
bool IUIScene_CraftingMenu::handleKeyDown(int iPad, int iAction, bool bRepeat){ bool bHandled = false;
if(m_bIgnoreKeyPresses) return bHandled;
// ignore key repeats of the X key - because it's X to open this menu, it can come through as a repeat on opening if(bRepeat &&(iAction==ACTION_MENU_X)) { return S_OK; }
Minecraft *pMinecraft = Minecraft::GetInstance();
if( pMinecraft->localgameModes[getPad()] != NULL ) { Tutorial *tutorial = pMinecraft->localgameModes[getPad()]->getTutorial(); if(tutorial != NULL) { tutorial->handleUIInput(iAction); if(ui.IsTutorialVisible(getPad()) && !tutorial->isInputAllowed(iAction)) { return S_OK; } } }
switch(iAction) { case ACTION_MENU_X:
// change the display m_iDisplayDescription++; if(m_iDisplayDescription==DISPLAY_MAX) m_iDisplayDescription=DISPLAY_INVENTORY; ui.PlayUISFX(eSFX_Focus); UpdateMultiPanel(); UpdateTooltips(); break; case ACTION_MENU_PAUSEMENU: case ACTION_MENU_B: ui.ShowTooltip( iPad, eToolTipButtonX, false ); ui.ShowTooltip( iPad, eToolTipButtonB, false ); ui.ShowTooltip( iPad, eToolTipButtonA, false ); ui.ShowTooltip( iPad, eToolTipButtonRB, false ); // kill the crafting xui //ui.PlayUISFX(eSFX_Back); ui.CloseUIScenes(iPad);
bHandled = true; break; case ACTION_MENU_A:#ifdef __ORBIS__ case ACTION_MENU_TOUCHPAD_PRESS:#endif // Do some crafting! if(m_pPlayer && m_pPlayer->inventory) { //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); // Force a make if the debug is on if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<<eDebugSetting_CraftAnything)) { if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) { int iSlot=iVSlotIndexA[m_iCurrentSlotVIndex];
int iRecipe= CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; shared_ptr<ItemInstance> pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); //int iIcon=pTempItemInst->getItem()->getIcon(pTempItemInst->getAuxValue());
if( pMinecraft->localgameModes[iPad] != NULL) { Tutorial *tutorial = pMinecraft->localgameModes[iPad]->getTutorial(); if(tutorial != NULL) { tutorial->onCrafted(pTempItemInst); } }
pMinecraft->localgameModes[iPad]->handleCraftItem(iRecipe,m_pPlayer);
if(m_pPlayer->inventory->add(pTempItemInst)==false) { // no room in inventory, so throw it down m_pPlayer->drop(pTempItemInst); } // play a sound //pMinecraft->soundEngine->playUI( L"random.pop", 1.0f, 1.0f); ui.PlayUISFX(eSFX_Craft); } } else if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) { int iSlot; if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) { iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; } else { iSlot=0; } int iRecipe= CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; shared_ptr<ItemInstance> pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); //int iIcon=pTempItemInst->getItem()->getIcon(pTempItemInst->getAuxValue());
if( pMinecraft->localgameModes[iPad] != NULL ) { Tutorial *tutorial = pMinecraft->localgameModes[iPad]->getTutorial(); if(tutorial != NULL) { tutorial->createItemSelected(pTempItemInst, pRecipeIngredientsRequired[iRecipe].bCanMake[iPad]); } }
if(pRecipeIngredientsRequired[iRecipe].bCanMake[iPad]) { pTempItemInst->onCraftedBy(m_pPlayer->level, dynamic_pointer_cast<Player>( m_pPlayer->shared_from_this() ), pTempItemInst->count ); // TODO 4J Stu - handleCraftItem should do a lot more than what it does, loads of the "can we craft" code should also probably be // shifted to the GameMode pMinecraft->localgameModes[iPad]->handleCraftItem(iRecipe,m_pPlayer);
// play a sound //pMinecraft->soundEngine->playUI( L"random.pop", 1.0f, 1.0f); ui.PlayUISFX(eSFX_Craft);
if(pTempItemInst->id != Item::fireworksCharge_Id && pTempItemInst->id != Item::fireworks_Id) { // and remove those resources from your inventory for(int i=0;i<pRecipeIngredientsRequired[iRecipe].iIngC;i++) { for(int j=0;j<pRecipeIngredientsRequired[iRecipe].iIngValA[i];j++) { shared_ptr<ItemInstance> ingItemInst = nullptr; // do we need to remove a specific aux value? if(pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i]!=Recipes::ANY_AUX_VALUE) { ingItemInst = m_pPlayer->inventory->getResourceItem( pRecipeIngredientsRequired[iRecipe].iIngIDA[i],pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i] ); m_pPlayer->inventory->removeResource(pRecipeIngredientsRequired[iRecipe].iIngIDA[i],pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i]); } else { ingItemInst = m_pPlayer->inventory->getResourceItem( pRecipeIngredientsRequired[iRecipe].iIngIDA[i] ); m_pPlayer->inventory->removeResource(pRecipeIngredientsRequired[iRecipe].iIngIDA[i]); }
// 4J Stu - Fix for #13097 - Bug: Milk Buckets are removed when crafting Cake if (ingItemInst != NULL) { if (ingItemInst->getItem()->hasCraftingRemainingItem()) { // replace item with remaining result m_pPlayer->inventory->add( shared_ptr<ItemInstance>( new ItemInstance(ingItemInst->getItem()->getCraftingRemainingItem()) ) ); }
} } }
// 4J Stu - Fix for #13119 - We should add the item after we remove the ingredients if(m_pPlayer->inventory->add(pTempItemInst)==false ) { // no room in inventory, so throw it down m_pPlayer->drop(pTempItemInst); }
//4J Gordon: Achievements switch(pTempItemInst->id ) { case Tile::workBench_Id: m_pPlayer->awardStat(GenericStats::buildWorkbench(), GenericStats::param_buildWorkbench()); break; case Item::pickAxe_wood_Id: m_pPlayer->awardStat(GenericStats::buildPickaxe(), GenericStats::param_buildPickaxe()); break; case Tile::furnace_Id: m_pPlayer->awardStat(GenericStats::buildFurnace(), GenericStats::param_buildFurnace()); break; case Item::hoe_wood_Id: m_pPlayer->awardStat(GenericStats::buildHoe(), GenericStats::param_buildHoe()); break; case Item::bread_Id: m_pPlayer->awardStat(GenericStats::makeBread(), GenericStats::param_makeBread()); break; case Item::cake_Id: m_pPlayer->awardStat(GenericStats::bakeCake(), GenericStats::param_bakeCake()); break; case Item::pickAxe_stone_Id: m_pPlayer->awardStat(GenericStats::buildBetterPickaxe(), GenericStats::param_buildBetterPickaxe()); break; case Item::sword_wood_Id: m_pPlayer->awardStat(GenericStats::buildSword(), GenericStats::param_buildSword()); break; case Tile::dispenser_Id: m_pPlayer->awardStat(GenericStats::dispenseWithThis(), GenericStats::param_dispenseWithThis()); break; case Tile::enchantTable_Id: m_pPlayer->awardStat(GenericStats::enchantments(), GenericStats::param_enchantments()); break; case Tile::bookshelf_Id: m_pPlayer->awardStat(GenericStats::bookcase(), GenericStats::param_bookcase()); break; }
// We've used some ingredients from our inventory, so update the recipes we can make CheckRecipesAvailable(); // don't reset the vertical slots - we want to stay where we are UpdateVerticalSlots(); UpdateHighlight(); } } else { //pMinecraft->soundEngine->playUI( L"btn.back", 1.0f, 1.0f); ui.PlayUISFX(eSFX_CraftFail); } } } break;
case ACTION_MENU_LEFT_SCROLL: // turn off the old group tab showTabHighlight(m_iGroupIndex,false);
if(m_iGroupIndex==0) { if(m_iContainerType==RECIPE_TYPE_3x3) { m_iGroupIndex=m_iMaxGroup3x3-1; } else { m_iGroupIndex=m_iMaxGroup2x2-1; } } else { m_iGroupIndex--; } // turn on the new group showTabHighlight(m_iGroupIndex,true);
m_iCurrentSlotHIndex=0; m_iCurrentSlotVIndex=1;
CheckRecipesAvailable(); // reset the vertical slots iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; iVSlotIndexA[1]=0; iVSlotIndexA[2]=1; ui.PlayUISFX(eSFX_Focus); UpdateVerticalSlots(); UpdateHighlight(); setGroupText(GetGroupNameText(m_pGroupA[m_iGroupIndex]));
break; case ACTION_MENU_RIGHT_SCROLL: // turn off the old group tab showTabHighlight(m_iGroupIndex,false);
m_iGroupIndex++; if(m_iContainerType==RECIPE_TYPE_3x3) { if(m_iGroupIndex==m_iMaxGroup3x3) m_iGroupIndex=0; } else { if(m_iGroupIndex==m_iMaxGroup2x2) m_iGroupIndex=0; } // turn on the new group showTabHighlight(m_iGroupIndex,true);
m_iCurrentSlotHIndex=0; m_iCurrentSlotVIndex=1; CheckRecipesAvailable(); // reset the vertical slots iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; iVSlotIndexA[1]=0; iVSlotIndexA[2]=1; ui.PlayUISFX(eSFX_Focus); UpdateVerticalSlots(); UpdateHighlight(); setGroupText(GetGroupNameText(m_pGroupA[m_iGroupIndex])); break; }
// 4J-Tomk - check if we've only got one vertical scroll slot (480, splits & Vita) bool bNoScrollSlots = false; if(m_bSplitscreen ||(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())) { bNoScrollSlots = true; }#ifdef __PSVITA__ bNoScrollSlots = true;#endif
// 4J Stu - We did used to swap the thumsticks based on Southpaw in this scene, but ONLY in this scene switch(iAction) { case ACTION_MENU_OTHER_STICK_UP: scrollDescriptionUp(); break; case ACTION_MENU_OTHER_STICK_DOWN: scrollDescriptionDown(); break; case ACTION_MENU_RIGHT: { int iOldHSlot=m_iCurrentSlotHIndex;
m_iCurrentSlotHIndex++; if(m_iCurrentSlotHIndex>=m_iCraftablesMaxHSlotC) m_iCurrentSlotHIndex=0; m_iCurrentSlotVIndex=1; // clear the indices iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; iVSlotIndexA[1]=0; iVSlotIndexA[2]=1;
UpdateVerticalSlots(); UpdateHighlight(); // re-enable the old hslot if(CanBeMadeA[iOldHSlot].iCount>0) { setShowCraftHSlot(iOldHSlot,true); } ui.PlayUISFX(eSFX_Focus); bHandled = true; } break; case ACTION_MENU_LEFT: { if(m_iCraftablesMaxHSlotC!=0) { int iOldHSlot=m_iCurrentSlotHIndex; if(m_iCurrentSlotHIndex==0) m_iCurrentSlotHIndex=m_iCraftablesMaxHSlotC-1; else m_iCurrentSlotHIndex--; m_iCurrentSlotVIndex=1; // clear the indices iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; iVSlotIndexA[1]=0; iVSlotIndexA[2]=1;
UpdateVerticalSlots(); UpdateHighlight(); // re-enable the old hslot if(CanBeMadeA[iOldHSlot].iCount>0) { setShowCraftHSlot(iOldHSlot,true); } ui.PlayUISFX(eSFX_Focus); } bHandled = true; } break; case ACTION_MENU_UP: { if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) { if(bNoScrollSlots) { if(iVSlotIndexA[1]==0) { iVSlotIndexA[1]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; } else { iVSlotIndexA[1]--; } ui.PlayUISFX(eSFX_Focus); } else if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>2) { { if(m_iCurrentSlotVIndex!=0) { // just move the highlight m_iCurrentSlotVIndex--; ui.PlayUISFX(eSFX_Focus); } else { //move the slots iVSlotIndexA[2]=iVSlotIndexA[1]; iVSlotIndexA[1]=iVSlotIndexA[0]; // on 0 and went up, so cycle the values if(iVSlotIndexA[0]==0) { iVSlotIndexA[0]=CanBeMadeA[m_iCurrentSlotHIndex].iCount-1; } else { iVSlotIndexA[0]--; } ui.PlayUISFX(eSFX_Focus); } } } else { if(m_iCurrentSlotVIndex!=1) { // just move the highlight m_iCurrentSlotVIndex--; ui.PlayUISFX(eSFX_Focus); } } UpdateVerticalSlots(); UpdateHighlight(); }
} break; case ACTION_MENU_DOWN: { if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) { if(bNoScrollSlots) { if(iVSlotIndexA[1]==(CanBeMadeA[m_iCurrentSlotHIndex].iCount-1)) { iVSlotIndexA[1]=0; } else { iVSlotIndexA[1]++; } ui.PlayUISFX(eSFX_Focus);
} else if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>2) { if(m_iCurrentSlotVIndex!=2) { m_iCurrentSlotVIndex++; ui.PlayUISFX(eSFX_Focus); } else { iVSlotIndexA[0]=iVSlotIndexA[1]; iVSlotIndexA[1]=iVSlotIndexA[2]; if(iVSlotIndexA[m_iCurrentSlotVIndex]==(CanBeMadeA[m_iCurrentSlotHIndex].iCount-1)) { iVSlotIndexA[2]=0; } else { iVSlotIndexA[2]++; } ui.PlayUISFX(eSFX_Focus); } } else { if(m_iCurrentSlotVIndex!=(CanBeMadeA[m_iCurrentSlotHIndex].iCount)) { m_iCurrentSlotVIndex++; ui.PlayUISFX(eSFX_Focus); } } UpdateVerticalSlots(); UpdateHighlight(); } } break; }
return bHandled;}
////////////////////////////////////////////////////////////////////////////// CheckRecipesAvailable////////////////////////////////////////////////////////////////////////////void IUIScene_CraftingMenu::CheckRecipesAvailable(){ int iHSlotBrushControl=0;
// clear the current list memset(CanBeMadeA,0,sizeof(CANBEMADE)*m_iCraftablesMaxHSlotC);
hideAllHSlots();
if(m_pPlayer && m_pPlayer->inventory) { // dump out the inventory /* for (unsigned int k = 0; k < m_pPlayer->inventory->items.length; k++) { if (m_pPlayer->inventory->items[k] != NULL) { wstring itemstring=m_pPlayer->inventory->items[k]->toString();
//printf("--- Player has "); OutputDebugStringW(itemstring.c_str()); //printf(" with Aux val = %d, base type = %d, Material = %d\n",m_pPlayer->inventory->items[k]->getAuxValue(),m_pPlayer->inventory->items[k]->getItem()->getBaseItemType(),m_pPlayer->inventory->items[k]->getItem()->getMaterial()); } } */ RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); int iRecipeC=(int)recipes->size(); AUTO_VAR(itRecipe, recipes->begin());
// dump out the recipe products
// for (int i = 0; i < iRecipeC; i++) // { // shared_ptr<ItemInstance> pTempItemInst=pRecipeIngredientsRequired[i].pRecipy->assemble(NULL); // if (pTempItemInst != NULL) // { // wstring itemstring=pTempItemInst->toString(); // // printf("Recipe [%d] = ",i); // OutputDebugStringW(itemstring.c_str()); // if(pTempItemInst->id!=0) // { // if(pTempItemInst->id<256) // { // Tile *pTile=Tile::tiles[pTempItemInst->id]; // printf("[TILE] ID\t%d\tAux val\t%d\tBase type\t%d\tMaterial\t%d\t Count=%d\n",pTempItemInst->id, pTempItemInst->getAuxValue(),pTile->getBaseItemType(),pTile->getMaterial(),pTempItemInst->GetCount()); // } // else // { // printf("ID\t%d\tAux val\t%d\tBase type\t%d\tMaterial\t%d Count=%d\n",pTempItemInst->id, pTempItemInst->getAuxValue(),pTempItemInst->getItem()->getBaseItemType(),pTempItemInst->getItem()->getMaterial(),pTempItemInst->GetCount()); // } // // } // } // }
for(int i=0;i<iRecipeC;i++) {
Recipy *r = *itRecipe;
// If this recipe isn't in the current grouptype, skip it if(r->getGroup()!=m_pGroupA[m_iGroupIndex]) { itRecipe++; pRecipeIngredientsRequired[i].bCanMake[getPad()]=false; continue; } // if we are in the inventory menu, then we have 2x2 crafting available only if((m_iContainerType==RECIPE_TYPE_2x2) && (pRecipeIngredientsRequired[i].iType==RECIPE_TYPE_3x3)) { // need a crafting table for this recipe itRecipe++; pRecipeIngredientsRequired[i].bCanMake[getPad()]=false; continue; } // clear the mask showing which ingredients are missing pRecipeIngredientsRequired[i].usBitmaskMissingGridIngredients[getPad()]=0;
//bool bCanMakeRecipe=true; bool *bFoundA= new bool [pRecipeIngredientsRequired[i].iIngC]; for(int j=0;j<pRecipeIngredientsRequired[i].iIngC;j++) { bFoundA[j]=false; int iTotalCount=0;
// Does the player have this ingredient? for (unsigned int k = 0; k < m_pPlayer->inventory->items.length; k++) { if (m_pPlayer->inventory->items[k] != NULL) { // do they have the ingredient, and the aux value matches, and enough off it? if((m_pPlayer->inventory->items[k]->id == pRecipeIngredientsRequired[i].iIngIDA[j]) && // check if the ingredient required doesn't care about the aux value, or if it does, does the inventory item aux match it ((pRecipeIngredientsRequired[i].iIngAuxValA[j]==Recipes::ANY_AUX_VALUE) || (pRecipeIngredientsRequired[i].iIngAuxValA[j]==m_pPlayer->inventory->items[k]->getAuxValue())) ) { // do they have enough? We need to check the whole inventory, since they may have enough in different slots (milk isn't milkx3, but milk,milk,milk) if(m_pPlayer->inventory->items[k]->GetCount()>=pRecipeIngredientsRequired[i].iIngValA[j]) { // they have enough with one slot bFoundA[j]=true; } else { // look at the combined value from the whole inventory
for(unsigned int l=0;l<m_pPlayer->inventory->items.length;l++) { if (m_pPlayer->inventory->items[l] != NULL) { if( (m_pPlayer->inventory->items[l]->id == pRecipeIngredientsRequired[i].iIngIDA[j]) && ( (pRecipeIngredientsRequired[i].iIngAuxValA[j]==Recipes::ANY_AUX_VALUE) || (pRecipeIngredientsRequired[i].iIngAuxValA[j]==m_pPlayer->inventory->items[l]->getAuxValue() )) ) { iTotalCount+=m_pPlayer->inventory->items[l]->GetCount(); } } }
if(iTotalCount>=pRecipeIngredientsRequired[i].iIngValA[j]) { bFoundA[j]=true; } }
// 4J Stu - TU-1 hotfix // Fix for #13143 - Players are able to craft items they do not have enough ingredients for if they store the ingredients in multiple, smaller stacks break; } } } // if bFoundA[j] is false, then we didn't have enough of the ingredient required by the recipe, so mark the grid items we're short of if(bFoundA[j]==false) { int iMissing = pRecipeIngredientsRequired[i].iIngValA[j]-iTotalCount; int iGridIndex=0; while(iMissing!=0) { // need to check if there is an aux val and match that if(((pRecipeIngredientsRequired[i].uiGridA[iGridIndex]&0x00FFFFFF)==pRecipeIngredientsRequired[i].iIngIDA[j]) && ((pRecipeIngredientsRequired[i].iIngAuxValA[j]==Recipes::ANY_AUX_VALUE) ||(pRecipeIngredientsRequired[i].iIngAuxValA[j]== ((pRecipeIngredientsRequired[i].uiGridA[iGridIndex]&0xFF000000)>>24))) ) { // this grid entry is the ingredient we don't have enough of pRecipeIngredientsRequired[i].usBitmaskMissingGridIngredients[getPad()]|=1<<iGridIndex; iMissing--; } iGridIndex++; } } }
// so can we make it? bool bCanMake=true; for(int j=0;j<pRecipeIngredientsRequired[i].iIngC;j++) { if(bFoundA[j]==false) { bCanMake=false; break; } }
pRecipeIngredientsRequired[i].bCanMake[getPad()]=bCanMake;
// Add the recipe to the CanBeMade list of lists if(iHSlotBrushControl<=m_iCraftablesMaxHSlotC) { bool bFound=false; shared_ptr<ItemInstance> pTempItemInst=pRecipeIngredientsRequired[i].pRecipy->assemble(nullptr); //int iIcon=pTempItemInst->getItem()->getIcon(pTempItemInst->getAuxValue()); int iID=pTempItemInst->getItem()->id; int iBaseType;
if(iID<256) // is it a tile? { iBaseType=Tile::tiles[iID]->getBaseItemType(); } else { iBaseType=pTempItemInst->getItem()->getBaseItemType(); }
// ignore for the misc base type - these have not been placed in a base type group if(iBaseType!=Item::eBaseItemType_undefined) { for(int k=0;k<iHSlotBrushControl;k++) { // if the item base type is the same as one already in, then add it to that list if(CanBeMadeA[k].iItemBaseType==iBaseType) { // base item type already in our list bFound=true; if(CanBeMadeA[k].iCount<m_iMaxVSlotC) { CanBeMadeA[k].iRecipeA[CanBeMadeA[k].iCount++]=i; } else { app.DebugPrintf("Need more V slots\n"); } break; } } }
if(!bFound) { if(iHSlotBrushControl<m_iCraftablesMaxHSlotC) { // add to the list CanBeMadeA[iHSlotBrushControl].iItemBaseType=iBaseType; CanBeMadeA[iHSlotBrushControl].iRecipeA[CanBeMadeA[iHSlotBrushControl].iCount++]=i; iHSlotBrushControl++; } else { app.DebugPrintf("Need more H slots - ");#ifndef _CONTENT_PACKAGE OutputDebugStringW(app.GetString(pTempItemInst->getDescriptionId()));#endif app.DebugPrintf("\n");
} } } else { app.DebugPrintf("Need more HSlots\n"); }
delete [] bFoundA; itRecipe++; } }
// run through the canbemade list and update the icons displayed int iIndex=0; //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray();
while((iIndex<m_iCraftablesMaxHSlotC) && CanBeMadeA[iIndex].iCount!=0) { shared_ptr<ItemInstance> pTempItemInst=pRecipeIngredientsRequired[CanBeMadeA[iIndex].iRecipeA[0]].pRecipy->assemble(nullptr); assert(pTempItemInst->id!=0); unsigned int uiAlpha;
if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<<eDebugSetting_CraftAnything)) { uiAlpha = 31; } else { if(pRecipeIngredientsRequired[CanBeMadeA[iIndex].iRecipeA[0]].bCanMake[getPad()]) { uiAlpha = 31; } else { uiAlpha= 16; } }
// 4J Stu - For clocks and compasses we set the aux value to a special one that signals we should use a default texture // rather than the dynamic one for the player if( pTempItemInst->id == Item::clock_Id || pTempItemInst->id == Item::compass_Id ) { pTempItemInst->setAuxValue( 255 ); } setCraftHSlotItem(getPad(),iIndex,pTempItemInst,uiAlpha);
iIndex++; }
// 4J-PB - Removed - UpdateTooltips will do this // Update tooltips /*if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) { ui.ShowTooltip( getPad(), eToolTipButtonA, true ); // 4J-PB - not implemented ! //ui.EnableTooltip( getPad(), eToolTipButtonA, true ); } else { ui.ShowTooltip( getPad(), eToolTipButtonA, false ); }*/}
////////////////////////////////////////////////////////////////////////////// UpdateHighlight////////////////////////////////////////////////////////////////////////////void IUIScene_CraftingMenu::UpdateHighlight(){ updateHighlightAndScrollPositions();
bool bCanBeMade=CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0; if(bCanBeMade) { //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); int iSlot; if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) { iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; } else { iSlot=0; } shared_ptr<ItemInstance> pTempItemInstAdditional=pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].pRecipy->assemble(nullptr);
// special case for the torch coal/charcoal int id=pTempItemInstAdditional->getDescriptionId(); LPCWSTR itemstring;
switch(id) { case IDS_TILE_TORCH: { if(pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].iIngAuxValA[0]==1) { itemstring=app.GetString( IDS_TILE_TORCHCHARCOAL ); } else { itemstring=app.GetString( IDS_TILE_TORCHCOAL ); } } break; case IDS_ITEM_FIREBALL: { if(pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].iIngAuxValA[2]==1) { itemstring=app.GetString( IDS_ITEM_FIREBALLCHARCOAL ); } else { itemstring=app.GetString( IDS_ITEM_FIREBALLCOAL ); } } break; default: itemstring=app.GetString(id ); break; }
setItemText(itemstring); } else { setItemText(L""); } UpdateDescriptionText(bCanBeMade); DisplayIngredients();
UpdateMultiPanel();
UpdateTooltips();}
////////////////////////////////////////////////////////////////////////////// UpdateVerticalSlots////////////////////////////////////////////////////////////////////////////void IUIScene_CraftingMenu::UpdateVerticalSlots(){ //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray();
// update the vertical items for the current horizontal slot hideAllVSlots();
// could have either 1 or 2 vertical slots, above and below the horizontal slot if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) { // turn off the horizontal one since we could be cycling through others setShowCraftHSlot(m_iCurrentSlotHIndex,false); int iSlots=(CanBeMadeA[m_iCurrentSlotHIndex].iCount>2)?3:2;
// 4J-Tomk - check if we've only got one vertical scroll slot (480, splits & Vita) bool bNoScrollSlots = false; if(m_bSplitscreen ||(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())) { bNoScrollSlots = true; }#ifdef __PSVITA__ bNoScrollSlots = true;#endif
for(int i=0;i<iSlots;i++) { // 4J this check determines if the crafting scene has only one vertical scroll slot if(bNoScrollSlots) { if(i!=1) continue; } shared_ptr<ItemInstance> pTempItemInstAdditional=pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iVSlotIndexA[i]]].pRecipy->assemble(nullptr);
assert(pTempItemInstAdditional->id!=0); unsigned int uiAlpha;
if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<<eDebugSetting_CraftAnything)) { uiAlpha = 31; } else { if(pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iVSlotIndexA[i]]].bCanMake[getPad()]) { uiAlpha = 31; } else { uiAlpha= 16; } }
// 4J Stu - For clocks and compasses we set the aux value to a special one that signals we should use a default texture // rather than the dynamic one for the player if( pTempItemInstAdditional->id == Item::clock_Id || pTempItemInstAdditional->id == Item::compass_Id ) { pTempItemInstAdditional->setAuxValue( 255 ); }
setCraftVSlotItem(getPad(),i,pTempItemInstAdditional,uiAlpha);
updateVSlotPositions(iSlots, i); } }}
////////////////////////////////////////////////////////////////////////////// DisplayIngredients////////////////////////////////////////////////////////////////////////////void IUIScene_CraftingMenu::DisplayIngredients(){ //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray();
// hide the previous ingredients hideAllIngredientsSlots();
if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) { int iSlot,iRecipy; if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) { iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; iRecipy=CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; } else { iSlot=0; iRecipy=CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[0]; }
// show the 2x2 or 3x3 to make the current item int iBoxWidth=(m_iContainerType==RECIPE_TYPE_2x2)?2:3; int iRecipe=CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; bool bCanMakeRecipe = pRecipeIngredientsRequired[iRecipe].bCanMake[getPad()]; shared_ptr<ItemInstance> pTempItemInst=pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr);
m_iIngredientsC=pRecipeIngredientsRequired[iRecipe].iIngC;
// update the ingredients required - these will all be hidden until cycled by the user for(int i=0;i<pRecipeIngredientsRequired[iRecipe].iIngC;i++) { int id=pRecipeIngredientsRequired[iRecipe].iIngIDA[i]; int iAuxVal=pRecipeIngredientsRequired[iRecipe].iIngAuxValA[i]; Item *item = Item::items[id];
shared_ptr<ItemInstance> itemInst= shared_ptr<ItemInstance>(new ItemInstance(item,pRecipeIngredientsRequired[iRecipe].iIngValA[i],iAuxVal));
// 4J-PB - a very special case - the bed can use any kind of wool, so we can't use the item description // and the same goes for the painting int idescID;
if( ((pTempItemInst->id==Item::bed_Id) &&(id==Tile::wool_Id)) || ((pTempItemInst->id==Item::painting_Id) &&(id==Tile::wool_Id)) ) { idescID=IDS_ANY_WOOL; } else if((pTempItemInst->id==Item::fireworksCharge_Id) && (id==Item::dye_powder_Id)) { idescID=IDS_ITEM_DYE_POWDER; iAuxVal = 1; } else { idescID=itemInst->getDescriptionId(); } setIngredientDescriptionText(i,app.GetString(idescID));
if( (iAuxVal & 0xFF) == 0xFF) // 4J Stu - If the aux value is set to match any iAuxVal = 0;
// 4J Stu - For clocks and compasses we set the aux value to a special one that signals we should use a default texture // rather than the dynamic one for the player if( id == Item::clock_Id || id == Item::compass_Id ) { iAuxVal = 0xFF; } itemInst->setAuxValue(iAuxVal);
setIngredientDescriptionItem(getPad(),i,itemInst); setIngredientDescriptionRedBox(i,false); }
// 4J Stu - For clocks and compasses we set the aux value to a special one that signals we should use a default texture // rather than the dynamic one for the player if( pTempItemInst->id == Item::clock_Id || pTempItemInst->id == Item::compass_Id ) { pTempItemInst->setAuxValue( 255 ); }
// don't grey out the output icon setCraftingOutputSlotItem(getPad(), pTempItemInst);
if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<<eDebugSetting_CraftAnything)) { setCraftingOutputSlotRedBox(false); } else { if(bCanMakeRecipe==false) { setCraftingOutputSlotRedBox(true); } else { setCraftingOutputSlotRedBox(false); }
} for (int x = 0; x < iBoxWidth; x++) { for (int y = 0; y < iBoxWidth; y++) { int index = x+y*iBoxWidth; if(pRecipeIngredientsRequired[iRecipy].uiGridA[x+y*3]!=0) { int id=pRecipeIngredientsRequired[iRecipy].uiGridA[x+y*3]&0x00FFFFFF; assert(id!=0); int iAuxVal=(pRecipeIngredientsRequired[iRecipy].uiGridA[x+y*3]&0xFF000000)>>24;
// 4J Stu - For clocks and compasses we set the aux value to a special one that signals we should use a default texture // rather than the dynamic one for the player if( id == Item::clock_Id || id == Item::compass_Id ) { iAuxVal = 0xFF; } else if( pTempItemInst->id==Item::fireworksCharge_Id && id == Item::dye_powder_Id) { iAuxVal = 1; } shared_ptr<ItemInstance> itemInst= shared_ptr<ItemInstance>(new ItemInstance(id,1,iAuxVal)); setIngredientSlotItem(getPad(),index,itemInst); // show the ingredients we don't have if we can't make the recipe if(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<<eDebugSetting_CraftAnything)) { setIngredientSlotRedBox(index, false); } else { if((pRecipeIngredientsRequired[iRecipy].usBitmaskMissingGridIngredients[getPad()]&(1<<(x+y*3)))!=0) { setIngredientSlotRedBox(index, true); } else { setIngredientSlotRedBox(index, false); } } } else { setIngredientSlotRedBox(index, false); setIngredientSlotItem(getPad(),index,nullptr); } } } } else { setCraftingOutputSlotItem(getPad(), nullptr); setCraftingOutputSlotRedBox(false); m_iIngredientsC=0; int iIngredientsSlots; // if it's a 2x2 , only clear the 4 m_pCraftingIngredientA slots if(m_iContainerType==RECIPE_TYPE_2x2) { iIngredientsSlots=4; } else { iIngredientsSlots=m_iIngredients3x3SlotC; }
for(int i=0;i<iIngredientsSlots;i++) { setIngredientSlotRedBox(i, false); setIngredientSlotItem(getPad(),i,nullptr); } }}
////////////////////////////////////////////////////////////////////////////// UpdateDescriptionText////////////////////////////////////////////////////////////////////////////void IUIScene_CraftingMenu::UpdateDescriptionText(bool bCanBeMade){ int iIDSString=0; //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray();
if(bCanBeMade) { int iSlot;//,iRecipy; if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) { iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; //iRecipy=CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; } else { iSlot=0; //iRecipy=CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[0]; }
shared_ptr<ItemInstance> pTempItemInst=pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].pRecipy->assemble(nullptr); int iID=pTempItemInst->getItem()->id; int iAuxVal=pTempItemInst->getAuxValue(); int iBaseType;
if(iID<256) // is it a tile? { iBaseType=Tile::tiles[iID]->getBaseItemType();
iIDSString = Tile::tiles[iID]->getUseDescriptionId(); } else { iBaseType=pTempItemInst->getItem()->getBaseItemType();
iIDSString = pTempItemInst->getUseDescriptionId(); }
// A few special cases where the description required is specific to crafting, rather than the normal description if(iBaseType!=Item::eBaseItemType_undefined) { switch(iBaseType) { case Item::eBaseItemType_cloth: switch(iAuxVal) { case 0: iIDSString=IDS_DESC_WOOLSTRING; break; } break; } }
// set the string mapped to by the base object mapping array
if(iIDSString>=0) { // this is an html control now, so set the font size and colour //wstring wsText=app.GetString(iIDSString); wstring wsText=app.FormatHTMLString(getPad(),app.GetString(iIDSString));
// 12 for splitscreen, 14 for normal EHTMLFontSize size = eHTMLSize_Normal; if(m_bSplitscreen ||(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen())) { size = eHTMLSize_Splitscreen; } wchar_t startTags[64]; swprintf(startTags,64,L"<font color=\"#%08x\"><P ALIGN=LEFT>",app.GetHTMLColour(eHTMLColor_Black)); wsText= startTags + wsText + L"</P>";
setDescriptionText(wsText.c_str()); } else { /// Missing string!#ifdef _DEBUG setDescriptionText(L"This is some placeholder description text about the craftable item.");#else setDescriptionText(L""); #endif } } else { setDescriptionText(L""); }}
////////////////////////////////////////////////////////////////////////////// UpdateTooltips////////////////////////////////////////////////////////////////////////////void IUIScene_CraftingMenu::UpdateTooltips(){ //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray(); // Update tooltips
bool bDisplayCreate;
if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) { int iSlot; if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) { iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; } else { iSlot=0; }
if(pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].bCanMake[getPad()]) { bDisplayCreate=true; } else { bDisplayCreate=false; } } else { bDisplayCreate=false; }
switch(m_iDisplayDescription) { case DISPLAY_INVENTORY: ui.SetTooltips( getPad(), bDisplayCreate?IDS_TOOLTIPS_CREATE:-1,IDS_TOOLTIPS_EXIT, IDS_TOOLTIPS_SHOW_DESCRIPTION,-1,-1,-1,-2, IDS_TOOLTIPS_CHANGE_GROUP); break; case DISPLAY_DESCRIPTION: ui.SetTooltips( getPad(), bDisplayCreate?IDS_TOOLTIPS_CREATE:-1,IDS_TOOLTIPS_EXIT, IDS_TOOLTIPS_SHOW_INGREDIENTS,-1,-1,-1,-2, IDS_TOOLTIPS_CHANGE_GROUP); break; case DISPLAY_INGREDIENTS: ui.SetTooltips( getPad(), bDisplayCreate?IDS_TOOLTIPS_CREATE:-1,IDS_TOOLTIPS_EXIT, IDS_TOOLTIPS_SHOW_INVENTORY,-1,-1,-1,-2, IDS_TOOLTIPS_CHANGE_GROUP); break; }
/*if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) { int iSlot; if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) { iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; } else { iSlot=0; }
if(pRecipeIngredientsRequired[CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]].bCanMake[getPad()]) { ui.EnableTooltip( getPad(), eToolTipButtonA, true ); } else { ui.EnableTooltip( getPad(), eToolTipButtonA, false ); } } else { ui.ShowTooltip( getPad(), eToolTipButtonA, false ); }*/}
void IUIScene_CraftingMenu::HandleInventoryUpdated(){ // Check which recipes are available with the resources we have CheckRecipesAvailable(); UpdateVerticalSlots(); UpdateHighlight(); UpdateTooltips();}
bool IUIScene_CraftingMenu::isItemSelected(int itemId){ bool isSelected = false; if(m_pPlayer && m_pPlayer->inventory) { //RecipyList *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED *pRecipeIngredientsRequired=Recipes::getInstance()->getRecipeIngredientsArray();
if(CanBeMadeA[m_iCurrentSlotHIndex].iCount!=0) { int iSlot; if(CanBeMadeA[m_iCurrentSlotHIndex].iCount>1) { iSlot=iVSlotIndexA[m_iCurrentSlotVIndex]; } else { iSlot=0; } int iRecipe= CanBeMadeA[m_iCurrentSlotHIndex].iRecipeA[iSlot]; ItemInstance *pTempItemInst = (ItemInstance *)pRecipeIngredientsRequired[iRecipe].pRecipy->getResultItem();
if(pTempItemInst->id == itemId) { isSelected = true; } } } return isSelected;}