From: Jaka K. <lyn...@us...> - 2010-09-26 11:05:36
|
gemrb: Infinity Engine emulator The branch master has been updated via b0a1b5a64ce4a1e1af130173e8ae408565d62515 (commit) via 05ccf4f2d452ccd047e4cbb7c21e3c12bf352353 (commit) Summary of changes: gemrb/GUIScripts/GUISTORE.py | 239 +++++++++++++++++++----------------------- gemrb/core/Interface.cpp | 4 +- 2 files changed, 110 insertions(+), 133 deletions(-) from 1e2dea8ab3c4d227704f2cb829936a0c4f01c81e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=b0a1b5a64ce4a1e1af130173e8ae408565d62515 commit b0a1b5a64ce4a1e1af130173e8ae408565d62515 Author: Jaka Kranjc <lyn...@us...> Date: Sun Sep 26 13:07:12 2010 +0200 GUISTORE: do all the important price calculation at the same spot; implemented the charisma discount diff --git a/gemrb/GUIScripts/GUISTORE.py b/gemrb/GUIScripts/GUISTORE.py index 50d54da..7fd18e1 100644 --- a/gemrb/GUIScripts/GUISTORE.py +++ b/gemrb/GUIScripts/GUISTORE.py @@ -654,7 +654,7 @@ def BuyPressed (): if Flags: Slot = GemRB.GetStoreItem (i-1) Item = GemRB.GetItem (Slot['ItemResRef']) - Price = Item['Price'] * Store['SellMarkup'] / 100 + Price = GetRealPrice (pc, "sell", Item) if Price <= 0: Price = 1 @@ -722,7 +722,7 @@ def RedrawStoreShoppingWindow (): if Inventory: Price = 1 else: - Price = Item['Price'] * Store['SellMarkup'] / 100 + Price = GetRealPrice (pc, "sell", Item) if Price <= 0: Price = 1 BuySum = BuySum + Price @@ -737,7 +737,7 @@ def RedrawStoreShoppingWindow (): if Inventory: Price = 1 else: - Price = Item['Price'] * Store['BuyMarkup'] / 100 + Price = GetRealPrice (pc, "buy", Item) if Flags & SHOP_ID: Price = 1 SellSum = SellSum + Price @@ -1045,7 +1045,7 @@ def SetupItems (pc, Slot, Button, Label, i, type, idx, steal=0): Button.SetFlags (IE_GUI_BUTTON_PICTURE, OP_OR) if type == ITEM_STORE: - Price = Item['Price'] * Store['BuyMarkup'] / 100 + Price = GetRealPrice (pc, "buy", Item) Flags = GemRB.IsValidStoreItem (pc, i+LeftTopIndex, type) if steal: Button.SetState (IE_GUI_BUTTON_ENABLED) @@ -1060,7 +1060,7 @@ def SetupItems (pc, Slot, Button, Label, i, type, idx, steal=0): Button.SetState (IE_GUI_BUTTON_DISABLED) if not Inventory: - Price = Item['Price'] * Store['SellMarkup'] / 100 + Price = GetRealPrice (pc, "sell", Item) if Price <= 0: Price = 1 else: @@ -1079,7 +1079,7 @@ def SetupItems (pc, Slot, Button, Label, i, type, idx, steal=0): if Inventory: Price = 1 else: - Price = Item['Price'] * Store['BuyMarkup'] / 100 + Price = GetRealPrice (pc, "buy", Item) if (Price>0) and (Flags & SHOP_SELL): if Flags & SHOP_SELECT: @@ -1109,6 +1109,26 @@ def SetupItems (pc, Slot, Button, Label, i, type, idx, steal=0): GemRB.SetToken ("ITEMCOST", str(Price) ) Label.SetText (10162) +def GetRealPrice (pc, mode, Item): + # get the base from the item + price = Item['Price'] + + # modifier from store properties (in percent) + if mode == "buy": + mod = Store['BuyMarkup'] + else: + mod = Store['SellMarkup'] + + # charisma modifier (in percent) + mod += GemRB.GetAbilityBonus (IE_CHR, GemRB.GetPlayerStat (pc, IE_CHR) - 1, 0) + + # TODO: reputation modifier (in percent, but multiplied) + mod = mod * 100 / 100 + + # TODO: depreciation + + return price * mod / 100 + def UpdateStoreDonateWindow (): Window = StoreDonateWindow diff --git a/gemrb/core/Interface.cpp b/gemrb/core/Interface.cpp index 38d3dfd..3f7d5e3 100644 --- a/gemrb/core/Interface.cpp +++ b/gemrb/core/Interface.cpp @@ -5064,13 +5064,13 @@ int Interface::GetConstitutionBonus(int column, int value) const return conmod[column*(MaximumAbility+1)+value]; } -int Interface::GetCharismaBonus(int column, int value) const +int Interface::GetCharismaBonus(int column, int /*value*/) const { // store price reduction if (column<0 || column>(MaximumAbility-1)) return -9999; - return chrmod[value]; + return chrmod[column]; } int Interface::GetLoreBonus(int column, int value) const http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=05ccf4f2d452ccd047e4cbb7c21e3c12bf352353 commit 05ccf4f2d452ccd047e4cbb7c21e3c12bf352353 Author: Jaka Kranjc <lyn...@us...> Date: Sun Sep 26 12:32:15 2010 +0200 GUISTORE: a bit more code share diff --git a/gemrb/GUIScripts/GUISTORE.py b/gemrb/GUIScripts/GUISTORE.py index a86cfa0..50d54da 100644 --- a/gemrb/GUIScripts/GUISTORE.py +++ b/gemrb/GUIScripts/GUISTORE.py @@ -712,6 +712,7 @@ def RedrawStoreShoppingWindow (): LeftIndex = GemRB.GetVar ("LeftIndex") RightTopIndex = GemRB.GetVar ("RightTopIndex") RightIndex = GemRB.GetVar ("RightIndex") + idx = [ LeftTopIndex, RightTopIndex, LeftIndex, RightIndex ] LeftCount = Store['StoreItemCount'] BuySum = 0 for i in range (LeftCount): @@ -769,45 +770,7 @@ def RedrawStoreShoppingWindow (): Button = Window.GetControl (i+5) Label = Window.GetControl (0x10000012+i) Button.SetVarAssoc ("LeftIndex", LeftTopIndex+i) - if Slot != None: - Flags = GemRB.IsValidStoreItem (pc, i+LeftTopIndex, ITEM_STORE) - Item = GemRB.GetItem (Slot['ItemResRef']) - Button.SetItemIcon (Slot['ItemResRef'], 0) - Button.SetFlags (IE_GUI_BUTTON_NO_IMAGE, OP_NAND) - Button.SetFlags (IE_GUI_BUTTON_PICTURE, OP_OR) - if Flags & SHOP_BUY: - if Flags & SHOP_SELECT: - Button.SetState (IE_GUI_BUTTON_SELECTED) - else: - Button.SetState (IE_GUI_BUTTON_ENABLED) - else: - Button.SetState (IE_GUI_BUTTON_DISABLED) - - if Flags & SHOP_ID: - GemRB.SetToken ("ITEMNAME", GemRB.GetString (Item['ItemName'])) - Button.EnableBorder (0, 1) - else: - GemRB.SetToken ("ITEMNAME", GemRB.GetString (Item['ItemNameIdentified'])) - Button.EnableBorder (0, 0) - - if Inventory: - if GUICommon.GameIsIWD1() or GUICommon.GameIsIWD2(): - Label.SetText (24890) - elif GUICommon.GameIsBG2(): - Label.SetText (28337) - else: - Label.SetText ("") - else: - Price = Item['Price'] * Store['SellMarkup'] / 100 - if Price <= 0: - Price = 1 - GemRB.SetToken ("ITEMCOST", str(Price) ) - Label.SetText (10162) - else: - Button.SetState (IE_GUI_BUTTON_DISABLED) - Button.SetFlags (IE_GUI_BUTTON_NO_IMAGE, OP_OR) - Button.SetFlags (IE_GUI_BUTTON_PICTURE, OP_NAND) - Label.SetText ("") + SetupItems (pc, Slot, Button, Label, i, ITEM_STORE, idx) if i+RightTopIndex<RightCount: Slot = GemRB.GetSlotItem (pc, inventory_slots[i+RightTopIndex]) @@ -816,49 +779,8 @@ def RedrawStoreShoppingWindow (): Button = Window.GetControl (i+13) Label = Window.GetControl (0x1000001e+i) Button.SetVarAssoc ("RightIndex", RightTopIndex+i) - if Slot != None: - Flags = GemRB.IsValidStoreItem (pc, inventory_slots[i+RightTopIndex], ITEM_PC) - Item = GemRB.GetItem (Slot['ItemResRef']) - Button.SetItemIcon (Slot['ItemResRef'], 0) - Button.SetFlags (IE_GUI_BUTTON_NO_IMAGE, OP_NAND) - Button.SetFlags (IE_GUI_BUTTON_PICTURE, OP_OR) - if Inventory: - Price = 1 - else: - Price = Item['Price'] * Store['BuyMarkup'] / 100 - - if (Price>0) and (Flags & SHOP_SELL): - if Flags & SHOP_SELECT: - print "SELECTING", GemRB.GetString(Item['ItemNameIdentified']) - Button.SetState (IE_GUI_BUTTON_SELECTED) - else: - Button.SetState (IE_GUI_BUTTON_ENABLED) - else: - Button.SetState (IE_GUI_BUTTON_DISABLED) - - if Flags & SHOP_ID: - GemRB.SetToken ("ITEMNAME", GemRB.GetString (Item['ItemName'])) - Price = 1 - Button.EnableBorder (0, 1) - else: - GemRB.SetToken ("ITEMNAME", GemRB.GetString (Item['ItemNameIdentified'])) - Button.EnableBorder (0, 0) + SetupItems (pc, Slot, Button, Label, i, ITEM_PC, idx) - if Inventory: - if GUICommon.GameIsIWD1() or GUICommon.GameIsIWD2(): - Label.SetText (24890) - elif GUICommon.GameIsBG2(): - Label.SetText (28337) - else: - Label.SetText ("") - else: - GemRB.SetToken ("ITEMCOST", str(Price) ) - Label.SetText (10162) - else: - Button.SetState (IE_GUI_BUTTON_DISABLED) - Button.SetFlags (IE_GUI_BUTTON_NO_IMAGE, OP_OR) - Button.SetFlags (IE_GUI_BUTTON_PICTURE, OP_NAND) - Label.SetText ("") return def UpdateStoreIdentifyWindow (): @@ -1080,6 +1002,7 @@ def RedrawStoreStealWindow (): LeftIndex = GemRB.GetVar ("LeftIndex") RightTopIndex = GemRB.GetVar ("RightTopIndex") RightIndex = GemRB.GetVar ("RightIndex") + idx = [ LeftTopIndex, RightTopIndex, LeftIndex, RightIndex ] LeftCount = Store['StoreItemCount'] pc = GemRB.GameGetSelectedPCSingle () RightCount = len(inventory_slots) @@ -1088,12 +1011,60 @@ def RedrawStoreStealWindow (): Button = Window.GetControl (i+4) Label = Window.GetControl (0x1000000f+i) Button.SetVarAssoc ("LeftIndex", LeftTopIndex+i) - if Slot != None: - Flags = GemRB.IsValidStoreItem (pc, i+LeftTopIndex, ITEM_STORE) - Item = GemRB.GetItem (Slot['ItemResRef']) - Button.SetItemIcon (Slot['ItemResRef'], 0) - Button.SetFlags (IE_GUI_BUTTON_NO_IMAGE, OP_NAND) - Button.SetFlags (IE_GUI_BUTTON_PICTURE, OP_OR) + SetupItems (pc, Slot, Button, Label, i, ITEM_STORE, idx, 1) + + if i+RightTopIndex<RightCount: + Slot = GemRB.GetSlotItem (pc, inventory_slots[i+RightTopIndex]) + else: + Slot = None + Button = Window.GetControl (i+11) + Label = Window.GetControl (0x10000019+i) + Button.SetVarAssoc ("RightIndex", RightTopIndex+i) + SetupItems (pc, Slot, Button, Label, i, ITEM_PC, idx, 1) + + if LeftIndex>=0: + LeftButton.SetState (IE_GUI_BUTTON_ENABLED) + else: + LeftButton.SetState (IE_GUI_BUTTON_DISABLED) + return + +def SetupItems (pc, Slot, Button, Label, i, type, idx, steal=0): + if Slot == None: + Button.SetState (IE_GUI_BUTTON_DISABLED) + Button.SetFlags (IE_GUI_BUTTON_NO_IMAGE, OP_OR) + Button.SetFlags (IE_GUI_BUTTON_PICTURE, OP_NAND) + Label.SetText ("") + else: + LeftTopIndex = idx[0] + RightTopIndex = idx[1] + LeftIndex = idx[2] + + Item = GemRB.GetItem (Slot['ItemResRef']) + Button.SetItemIcon (Slot['ItemResRef'], 0) + Button.SetFlags (IE_GUI_BUTTON_NO_IMAGE, OP_NAND) + Button.SetFlags (IE_GUI_BUTTON_PICTURE, OP_OR) + + if type == ITEM_STORE: + Price = Item['Price'] * Store['BuyMarkup'] / 100 + Flags = GemRB.IsValidStoreItem (pc, i+LeftTopIndex, type) + if steal: + Button.SetState (IE_GUI_BUTTON_ENABLED) + else: + if Flags & SHOP_BUY: + if Flags & SHOP_SELECT: + Button.SetState (IE_GUI_BUTTON_SELECTED) + print "Selecting", i+LeftTopIndex, Slot['ItemResRef'], Item['Price'], Price + else: + Button.SetState (IE_GUI_BUTTON_ENABLED) + else: + Button.SetState (IE_GUI_BUTTON_DISABLED) + + if not Inventory: + Price = Item['Price'] * Store['SellMarkup'] / 100 + if Price <= 0: + Price = 1 + else: + Flags = GemRB.IsValidStoreItem (pc, inventory_slots[i+RightTopIndex], type) if Flags & SHOP_STEAL: if LeftIndex == LeftTopIndex + i: Button.SetState (IE_GUI_BUTTON_SELECTED) @@ -1102,55 +1073,41 @@ def RedrawStoreStealWindow (): else: Button.SetState (IE_GUI_BUTTON_DISABLED) - if Flags & SHOP_ID: - GemRB.SetToken ("ITEMNAME", GemRB.GetString (Item['ItemName'])) - Button.EnableBorder (0, 1) + if steal: + Price = Slot['Price'] else: - GemRB.SetToken ("ITEMNAME", GemRB.GetString (Item['ItemNameIdentified'])) - Button.EnableBorder (0, 0) + if Inventory: + Price = 1 + else: + Price = Item['Price'] * Store['BuyMarkup'] / 100 - GemRB.SetToken ("ITEMCOST", str(Slot['Price']) ) - Label.SetText (10162) - else: - Button.SetState (IE_GUI_BUTTON_DISABLED) - Button.SetFlags (IE_GUI_BUTTON_NO_IMAGE, OP_OR) - Button.SetFlags (IE_GUI_BUTTON_PICTURE, OP_NAND) - Label.SetText ("") + if (Price>0) and (Flags & SHOP_SELL): + if Flags & SHOP_SELECT: + Button.SetState (IE_GUI_BUTTON_SELECTED) + else: + Button.SetState (IE_GUI_BUTTON_ENABLED) + else: + Button.SetState (IE_GUI_BUTTON_DISABLED) - if i+RightTopIndex<RightCount: - Slot = GemRB.GetSlotItem (pc, inventory_slots[i+RightTopIndex]) + if Flags & SHOP_ID: + GemRB.SetToken ("ITEMNAME", GemRB.GetString (Item['ItemName'])) + Button.EnableBorder (0, 1) + if not steal and type == ITEM_PC: + Price = 1 else: - Slot = None - Button = Window.GetControl (i+11) - Label = Window.GetControl (0x10000019+i) - Button.SetVarAssoc ("RightIndex", RightTopIndex+i) - if Slot != None: - Flags = GemRB.IsValidStoreItem (pc, inventory_slots[i+RightTopIndex], ITEM_PC) - Item = GemRB.GetItem (Slot['ItemResRef']) - Button.SetItemIcon (Slot['ItemResRef'], 0) - Button.SetFlags (IE_GUI_BUTTON_NO_IMAGE, OP_NAND) - Button.SetFlags (IE_GUI_BUTTON_PICTURE, OP_OR) - Price = Item['Price'] * Store['BuyMarkup'] / 100 - Button.SetState (IE_GUI_BUTTON_ENABLED) - if Flags & SHOP_ID: - GemRB.SetToken ("ITEMNAME", GemRB.GetString (Item['ItemName'])) - Button.EnableBorder (0, 1) - else: - GemRB.SetToken ("ITEMNAME", GemRB.GetString (Item['ItemNameIdentified'])) - Button.EnableBorder (0, 0) + GemRB.SetToken ("ITEMNAME", GemRB.GetString (Item['ItemNameIdentified'])) + Button.EnableBorder (0, 0) + if Inventory: + if GUICommon.GameIsIWD1() or GUICommon.GameIsIWD2(): + Label.SetText (24890) + elif GUICommon.GameIsBG2(): + Label.SetText (28337) + else: + Label.SetText ("") + else: GemRB.SetToken ("ITEMCOST", str(Price) ) Label.SetText (10162) - else: - Button.SetState (IE_GUI_BUTTON_DISABLED) - Button.SetFlags (IE_GUI_BUTTON_NO_IMAGE, OP_OR) - Button.SetFlags (IE_GUI_BUTTON_PICTURE, OP_NAND) - Label.SetText ("") - if LeftIndex>=0: - LeftButton.SetState (IE_GUI_BUTTON_ENABLED) - else: - LeftButton.SetState (IE_GUI_BUTTON_DISABLED) - return def UpdateStoreDonateWindow (): Window = StoreDonateWindow ----------------------------------------------------------------------- This is an automated email from the git hooks/post-receive script. -- gemrb: Infinity Engine emulator |