#include "x2_inc_craft" #include "mk_inc_modmodes" #include "mk_inc_craft" #include "mk_inc_ccoh_db" #include "mk_inc_generic" #include "mk_inc_debug" #include "mk_inc_states" #include "mk_inc_delimiter" #include "mk_inc_itm_disp" #include "mk_inc_2da_disp" #include "mk_inc_cheats" /* int MK_ITEMPROP_GetIsModified() { int bResult = FALSE; object oPC = GetPCSpeaker(); object oItem = CIGetCurrentModItem(oPC); object oBackup = CIGetCurrentModBackup(oPC); if (GetIsObjectValid(oItem) && GetIsObjectValid(oBackup)) { string sIASStrBackup = MK_CCOH_DB_ItemPropertiesToIASStr(oBackup); string sIASStrCurrent = MK_CCOH_DB_ItemPropertiesToIASStr(oItem); bResult = (sIASStrBackup != sIASStrCurrent); } return bResult; } */ /* int MK_ITEMPROP_GetRequiredGold(int nCurrentValue=-1) { object oPC = GetPCSpeaker(); int nRequiredGold = 0; object oBackup = CIGetCurrentModBackup(oPC); if (GetIsObjectValid(oBackup)) { if (nCurrentValue==-1) { nCurrentValue = MK_CHEATS_CalculateCurrentGoldPieceValue(); } int nBackupValue = MK_IPRP_GetGoldPieceValue(oBackup); nRequiredGold = nCurrentValue - nBackupValue; float fFactor = 1.0f; if (nRequiredGold > 0) { fFactor = GetLocalFloat(oPC, "MK_CHEATS_ITEM_BUY"); } else if (nRequiredGold < 0) { fFactor = GetLocalFloat(oPC, "MK_CHEATS_ITEM_SELL"); } nRequiredGold = FloatToInt(fFactor * nRequiredGold); MK_DEBUG_TRACE("MK_ITEMPROP_GetRequiredGold: nCurrentValue="+IntToString(nCurrentValue) +", nBackupValue="+IntToString(nBackupValue) +", fFactor="+FloatToString(fFactor) +", nRequiredGold="+IntToString(nRequiredGold)); } return nRequiredGold; } */ void MK_ITEMPROP_SetCustomToken(int nState) { MK_CHEATS_SetCustomToken(); // string sItemName; // string sItemValue = "-"; string sItemPropertyName; // string sRequiredGold = "-"; // int nRequiredGold = 0; // int nGold = GetGold(); // object oItem = MK_CHEATS_GetCurrentItem(); // if (GetIsObjectValid(oItem)) // { // int nCurrentValue = MK_CHEATS_CalculateCurrentGoldPieceValue(); // int nGoldPieceValue = MK_CHEATS_GetCurrentGoldPieceValue(); // sItemValue = IntToString(nCurrentValue) + " / " + IntToString(nGoldPieceValue); // nRequiredGold = MK_CHEATS_GetRequiredGold(nCurrentValue); // sRequiredGold = IntToString(nRequiredGold); // } // sRequiredGold += (" ("+IntToString(nGold)+")"); // sItemName=MK_CHEATS_GetCurrentItemName("-"); sItemPropertyName = MK_CHEATS_GetCurrentItemPropertyName("-"); // SetCustomToken(14422, sItemName); // SetCustomToken(14423, sItemValue); SetCustomToken(14424, sItemPropertyName); // SetCustomToken(14426, sRequiredGold); // if (nRequiredGold>nGold) // { // string sDisabledOptionsColor = GetLocalString(OBJECT_SELF, "MK_DISABLED_OPTIONS_COLOR"); // string sCloseColor = (sDisabledOptionsColor!="" ? "" : ""); // SetCustomToken(14460, sDisabledOptionsColor); // SetCustomToken(14470, " "+MK_TLK_GetStringByStrRef(-474)+""); // } int nStrRef = 0; switch (nState) { case MK_STATE_CHEATS_ITEMPROPS_PARAM1: nStrRef = MK_CHEATS_GetCurrentParam1TableStrRef(); break; case MK_STATE_CHEATS_ITEMPROPS_COSTTABLE: nStrRef = -471; break; case MK_STATE_CHEATS_ITEMPROPS_SUBTYPE: nStrRef = -470; break; case MK_STATE_CHEATS_ITEMPROPS_PROPERTY: nStrRef = -469; break; case MK_STATE_CHEATS_ITEMPROPS_ITEM: nStrRef = -468; break; } SetCustomToken(14425, MK_TLK_GetStringByStrRef(nStrRef)); } int MK_ITEMPROP_Finish() { int nState = MK_GenericDialog_GetState(); if (MK_CHEATS_FinishModifyItem()) { object oPC = GetPCSpeaker(); MK_GenericDialog_SetCurrentPage(nState, 1); MK_2DA_DISPLAY_Cleanup(); MK_GenericDialog_SetState(nState = MK_STATE_CHEATS_ITEMPROPS_ITEM_INIT); } return nState; } int MK_ITEMPROP_Cancel() { MK_DEBUG_TRACE("MK_ITEMPROP_Cancel() *start*"); object oPC = GetPCSpeaker(); int nState = MK_GenericDialog_GetState(); MK_GenericDialog_SetCurrentPage(nState, 1); MK_2DA_DISPLAY_Cleanup(); MK_CHEATS_CancelModifyItem(); MK_GenericDialog_SetState(nState = MK_STATE_CHEATS_ITEMPROPS_ITEM_INIT); MK_DEBUG_TRACE("MK_ITEMPROP_Cancel(): *terminate*"); return nState; } /* void DisplayDebugOutputQ(string sMsg, object oItem) { string sIASStr = ""; int nCalculatedValue = -1; int nGoldPieceValue = -1; if (GetIsObjectValid(oItem)) { sIASStr = MK_CCOH_DB_ItemPropertiesToIASStr(oItem); nCalculatedValue = MK_IPRP_CalculateGoldPieceValue(oItem, 0); nGoldPieceValue = MK_IPRP_GetGoldPieceValue(oItem); } MK_DEBUG_TRACE(sMsg+": oItem='"+GetName(oItem) +"', sIASStr='"+sIASStr +"', nCalculatedValue="+IntToString(nCalculatedValue) +"', nGoldPieceValue="+IntToString(nGoldPieceValue)); } void DisplayDebugOutput(object oPC) { object oItem = CIGetCurrentModItem(oPC); object oBackup = CIGetCurrentModBackup(oPC); DisplayDebugOutputQ("Current item", oItem); DisplayDebugOutputQ("Backup item ", oBackup); object oContainer = IPGetIPWorkContainer(); if (GetIsObjectValid(oContainer)) { int iItem=0; object oItemQ = GetFirstItemInInventory(oContainer); while (GetIsObjectValid(oItemQ)) { DisplayDebugOutputQ("Item "+IntToString(++iItem), oItemQ); oItemQ = GetNextItemInInventory(oContainer); } } } */ int StartingConditional() { object oPC = GetPCSpeaker(); int nState = MK_GenericDialog_GetState(); int nAction = MK_GenericDialog_GetAction(); MK_DEBUG_TRACE("mk_pre_itemprop: nState="+IntToString(nState)+", nAction="+IntToString(nAction)); // DisplayDebugOutput(oPC); switch (nState) { case MK_STATE_CHEATS: MK_CHEATS_SetCurrentItem(OBJECT_INVALID); MK_CHEATS_SetCurrentItemPropertyID(-1); MK_CHEATS_SetCurrentItemPropertySubType(-1); MK_CHEATS_SetCurrentItemPropertyCostTableValue(-1); MK_CHEATS_SetCurrentItemPropertyParam1Value(-1); MK_GenericDialog_SetCurrentPage(MK_STATE_CHEATS_ITEMPROPS_ITEM, 1); MK_GenericDialog_SetCurrentPage(MK_STATE_CHEATS_ITEMPROPS_PROPERTY, 1); MK_GenericDialog_SetCurrentPage(MK_STATE_CHEATS_ITEMPROPS_SUBTYPE, 1); MK_GenericDialog_SetCurrentPage(MK_STATE_CHEATS_ITEMPROPS_COSTTABLE, 1); MK_GenericDialog_SetState(nState = MK_STATE_CHEATS_ITEMPROPS_ITEM_INIT); break; case MK_STATE_CHEATS_ITEMPROPS_ITEM: switch (nAction) { case 250: // First page case 251: // previous page case 252: // next page case 253: // last page MK_ITM_DISPLAY_UpdatePage(nAction); break; case 31: // filter items MK_ITM_DISPLAY_Cleanup(); MK_GenericDialog_SetState(nState = MK_STATE_CHEATS_ITEMPROPS_FILTERITEMS_INIT); SetLocalInt(oPC, "MK_CHEATS_ITEMPROPS_FILTERITEMS_SHOWALL", MK_CHEATS_GetAreAllItemTypesSelected(oPC)); break; default: if ((nAction>=0) && (nAction=0) && (nAction=0) && (nAction=0) && (nAction=0) && (nAction=0) && (nAction0); MK_GenericDialog_SetConditionRange(31, 32, FALSE); MK_GenericDialog_SetCondition(33, TRUE); MK_GenericDialog_SetCondition(127, FALSE); SetCustomToken(14427, MK_TLK_GetStringByStrRef( GetLocalInt(oPC, "MK_CHEATS_ITEMPROPS_SHOWCURRENTONLY") ? -39 : -40 )); break; case MK_STATE_CHEATS_ITEMPROPS_SUBTYPE: MK_2DA_DISPLAY_DisplayPage(MK_2DA_DISPLAY_GetCurrentPage(), -1, "mk_cb_iprp_stlbl", FALSE); MK_GenericDialog_SetCondition(100, FALSE); MK_GenericDialog_SetCondition(101, TRUE); MK_GenericDialog_SetCondition(30, MK_CHEATS_GetCurrentItemPropertyCount(MK_CHEATS_GetCurrentItemPropertyID())>0); MK_GenericDialog_SetConditionRange(31, 32, FALSE); MK_GenericDialog_SetCondition(33, TRUE); MK_GenericDialog_SetCondition(127, FALSE); SetCustomToken(14427, MK_TLK_GetStringByStrRef( GetLocalInt(oPC, "MK_CHEATS_ITEMPROPS_SHOWCURRENTONLY") ? -39 : -40 )); break; case MK_STATE_CHEATS_ITEMPROPS_COSTTABLE: MK_2DA_DISPLAY_DisplayPage(MK_2DA_DISPLAY_GetCurrentPage(), -1, "mk_cb_iprp_ctlbl", FALSE); MK_GenericDialog_SetCondition(100, FALSE); MK_GenericDialog_SetCondition(101, TRUE); MK_GenericDialog_SetCondition(30, MK_CHEATS_GetCurrentItemPropertyCount( MK_CHEATS_GetCurrentItemPropertyID(), MK_CHEATS_GetCurrentItemPropertySubType())>0); MK_GenericDialog_SetConditionRange(31, 32, FALSE); MK_GenericDialog_SetCondition(33, TRUE); MK_GenericDialog_SetCondition(127, FALSE); SetCustomToken(14427, MK_TLK_GetStringByStrRef( GetLocalInt(oPC, "MK_CHEATS_ITEMPROPS_SHOWCURRENTONLY") ? -39 : -40 )); break; case MK_STATE_CHEATS_ITEMPROPS_PARAM1: MK_2DA_DISPLAY_DisplayPage(MK_2DA_DISPLAY_GetCurrentPage(), -1, "mk_cb_iprp_p1lbl", FALSE); MK_GenericDialog_SetCondition(100, FALSE); MK_GenericDialog_SetCondition(101, TRUE); MK_GenericDialog_SetCondition(30, MK_CHEATS_GetCurrentItemPropertyCount( MK_CHEATS_GetCurrentItemPropertyID(), MK_CHEATS_GetCurrentItemPropertySubType(), MK_CHEATS_GetCurrentItemPropertyCostTableValue())>0); MK_GenericDialog_SetConditionRange(31, 32, FALSE); MK_GenericDialog_SetCondition(33, TRUE); MK_GenericDialog_SetCondition(127, FALSE); SetCustomToken(14427, MK_TLK_GetStringByStrRef( GetLocalInt(oPC, "MK_CHEATS_ITEMPROPS_SHOWCURRENTONLY") ? -39 : -40 )); break; } MK_GenericDialog_SetCondition(254, bIsModified); MK_GenericDialog_SetCondition(257, bIsModified); MK_DELIMITER_Initialize(); MK_ITEMPROP_SetCustomToken(nState); // DisplayDebugOutput(oPC); return TRUE; }