2 # GemRB - Infinity Engine Emulator
3 # Copyright (C) 2003-2005 The GemRB Project
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 # GUISTORE.py - script to open store/inn/temple windows from GUISTORE winpack
23 ###################################################
26 import GUICommonWindows
27 from GUIDefines
import *
28 from GUICommonWindows
import *
29 from ie_stats
import *
30 from ie_slots
import *
31 from GUICommon
import CheckStat100
32 from GUICommon
import GameWindow
38 StoreShoppingWindow
= None
39 StoreIdentifyWindow
= None
40 StoreStealWindow
= None
41 StoreDonateWindow
= None
42 StoreHealWindow
= None
43 StoreRumourWindow
= None
44 StoreRentWindow
= None
45 OldPortraitWindow
= None
46 RentConfirmWindow
= None
56 Buttons
= [-1,-1,-1,-1]
76 storebams
= ("STORSTOR","STORTVRN","STORINN","STORTMPL","STORSTOR","STORSTOR")
77 storetips
= (14288,14292,14291,12138,15013,14289,14287)
78 roomtypes
= (17389,17517,17521,17519)
79 store_funcs
= ( "OpenStoreShoppingWindow", "OpenStoreIdentifyWindow",
80 "OpenStoreStealWindow", "OpenStoreHealWindow", "OpenStoreDonateWindow",
81 "OpenStoreRumourWindow", "OpenStoreRentWindow" )
82 store_update_funcs
= None
85 CloseStoreShoppingWindow ()
86 CloseStoreIdentifyWindow ()
87 CloseStoreStealWindow ()
88 CloseStoreHealWindow ()
89 CloseStoreDonateWindow ()
90 CloseStoreRumourWindow ()
91 CloseStoreRentWindow ()
94 def CloseStoreWindow ():
95 global StoreWindow
, ActionWindow
, PortraitWindow
96 global OldPortraitWindow
98 GemRB
.SetVar ("Inventory", 0)
101 StoreWindow
.Unload ()
103 ActionWindow
.Unload ()
105 PortraitWindow
.Unload ()
108 GUICommonWindows
.PortraitWindow
= OldPortraitWindow
110 GemRB
.RunEventHandler("OpenInventoryWindow")
112 GameWindow
.SetVisible(WINDOW_VISIBLE
) #enabling the game control screen
113 GemRB
.UnhideGUI () #enabling the other windows
114 SetSelectionChangeHandler( None )
117 def OpenStoreWindow ():
119 global StoreWindow
, ActionWindow
, PortraitWindow
120 global OldPortraitWindow
121 global store_update_funcs
124 #these are function pointers, not strings
125 #can't put this in global init, doh!
126 store_update_funcs
= (OpenStoreShoppingWindow
,
127 OpenStoreIdentifyWindow
,OpenStoreStealWindow
,
128 OpenStoreHealWindow
, OpenStoreDonateWindow
,
129 OpenStoreRumourWindow
,OpenStoreRentWindow
)
132 GameWindow
.SetVisible(WINDOW_INVISIBLE
) #removing the game control screen
134 if GemRB
.GetVar ("Inventory"):
139 GemRB
.SetVar ("Action", 0)
140 GemRB
.LoadWindowPack ("GUISTORE", 640, 480)
141 StoreWindow
= Window
= GemRB
.LoadWindow (3)
142 #saving the original portrait window
143 OldPortraitWindow
= GUICommonWindows
.PortraitWindow
144 PortraitWindow
= OpenPortraitWindow (0)
145 ActionWindow
= GemRB
.LoadWindow (0)
146 #this window is static and grey, but good to stick the frame onto
147 ActionWindow
.SetFrame ()
149 Store
= GemRB
.GetStore ()
152 Button
= Window
.GetControl (0)
153 Button
.SetText (11973)
154 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "CloseStoreWindow")
157 Button
= Window
.GetControl (5)
158 Button
.SetSprites (storebams
[Store
['StoreType']],0,0,0,0,0)
160 #based on shop type, these buttons will change
161 store_type
= Store
['StoreType']
162 store_buttons
= Store
['StoreButtons']
164 Buttons
[i
] = Button
= Window
.GetControl (i
+1)
165 Action
= store_buttons
[i
]
166 Button
.SetVarAssoc ("Action", i
)
168 Button
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON
, OP_OR
)
169 #this is different from BG???
170 Button
.SetSprites ("GUISTBBC", Action
, 1,2,0,0)
171 Button
.SetTooltip (storetips
[Action
])
172 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, store_funcs
[Action
])
173 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
175 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_OR
)
176 Button
.SetTooltip ("")
177 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, None)
178 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
180 ActionWindow
.SetVisible (WINDOW_VISIBLE
)
181 Window
.SetVisible (WINDOW_VISIBLE
)
182 store_update_funcs
[store_buttons
[0]] ()
183 PortraitWindow
.SetVisible (WINDOW_VISIBLE
)
186 def OpenStoreShoppingWindow ():
187 global StoreShoppingWindow
188 global LeftButton
, RightButton
192 StoreShoppingWindow
= Window
= GemRB
.LoadWindow (2)
196 Label
= Window
.GetControl (0xfffffff)
197 Label
.SetText (26291)
199 Label
= Window
.GetControl (0x1000002b)
202 Label
= Window
.GetControl (0x1000002c)
205 Label
= Window
.GetControl (0x1000002f)
208 Label
= Window
.GetControl (0x10000030)
212 Label
= Window
.GetControl (0x1000002b)
216 Label
= Window
.GetControl (0x1000002c)
220 Button
= Window
.GetControl (i
+5)
221 Button
.SetBorder (0,0,0,0,0,32,32,192,128,0,1)
222 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "SelectBuy")
223 Button
.SetEventByName (IE_GUI_BUTTON_ON_RIGHT_PRESS
, "InfoLeftWindow")
225 Button
= Window
.GetControl (i
+13)
226 Button
.SetBorder (0,0,0,0,0,32,32,192,128,0,1)
227 if Store
['StoreType'] != 3: # can't sell to temples
228 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "SelectSell")
229 Button
.SetEventByName (IE_GUI_BUTTON_ON_RIGHT_PRESS
, "InfoRightWindow")
232 LeftButton
= Button
= Window
.GetControl (2)
234 Button
.SetText (26287)
235 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "ToBackpackPressed")
237 Button
.SetText (13703)
238 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "BuyPressed")
241 RightButton
= Button
= Window
.GetControl (3)
243 Button
.SetText (26288)
244 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "ToBagPressed")
246 Button
.SetText (13704)
247 if Store
['StoreType'] != 3: # can't sell to temples
248 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "SellPressed")
251 #Button = Window.GetControl (50)
252 #Button.SetState (IE_GUI_BUTTON_LOCKED)
253 #Button.SetFlags (IE_GUI_BUTTON_NO_IMAGE, OP_SET)
256 Button
= Window
.GetControl (44)
257 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
260 Label
= Window
.CreateLabel (0x10000043, 15,325,60,15,"NUMBER","0:",IE_FONT_ALIGN_LEFT|IE_FONT_ALIGN_TOP
)
261 Label
= Window
.CreateLabel (0x10000044, 15,365,80,15,"NUMBER","0:",IE_FONT_ALIGN_RIGHT|IE_FONT_ALIGN_TOP
)
264 ScrollBar
= Window
.GetControl (11)
265 ScrollBar
.SetEventByName (IE_GUI_SCROLLBAR_ON_CHANGE
, "RedrawStoreShoppingWindow")
268 ScrollBar
= Window
.GetControl (12)
269 ScrollBar
.SetEventByName (IE_GUI_SCROLLBAR_ON_CHANGE
, "RedrawStoreShoppingWindow")
271 SetSelectionChangeHandler( UpdateStoreShoppingWindow
)
272 UpdateStoreShoppingWindow ()
273 Window
.SetVisible (WINDOW_VISIBLE
)
276 def OpenStoreIdentifyWindow ():
277 global StoreIdentifyWindow
279 GemRB
.SetVar ("Index", -1)
280 GemRB
.SetVar ("TopIndex", 0)
283 StoreIdentifyWindow
= Window
= GemRB
.LoadWindow (4)
286 Button
= Window
.GetControl (5)
287 Button
.SetText (14133)
288 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "IdentifyPressed")
289 Button
.SetEventByName (IE_GUI_BUTTON_ON_RIGHT_PRESS
, "InfoIdentifyWindow")
292 Label
= Window
.GetControl (0x10000003)
295 # 8-11 item slots, 0x1000000c-f labels
297 Button
= Window
.GetControl (i
+8)
298 Button
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON
, OP_OR
)
299 Button
.SetSprites ("GUISTMSC", 0, 1,2,0,3)
300 Button
.SetBorder (0,0,0,0,0,32,32,192,128,0,1)
301 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "RedrawStoreIdentifyWindow")
302 Button
.SetEventByName (IE_GUI_BUTTON_ON_RIGHT_PRESS
, "InfoIdentifyWindow")
304 ScrollBar
= Window
.GetControl (7)
305 ScrollBar
.SetEventByName (IE_GUI_SCROLLBAR_ON_CHANGE
, "RedrawStoreIdentifyWindow")
307 SetSelectionChangeHandler( UpdateStoreIdentifyWindow
)
308 UpdateStoreIdentifyWindow ()
309 Window
.SetVisible (WINDOW_VISIBLE
)
312 def OpenStoreStealWindow ():
313 global StoreStealWindow
316 GemRB
.SetVar ("RightIndex", 0)
317 GemRB
.SetVar ("LeftIndex", 0)
320 StoreStealWindow
= Window
= GemRB
.LoadWindow (6)
323 Button
= Window
.GetControl (i
+4)
324 Button
.SetBorder (0,0,0,0,0,32,32,192,128,0,1)
325 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "RedrawStoreStealWindow")
327 Button
= Window
.GetControl (i
+11)
328 Button
.SetBorder (0,0,0,0,0,32,32,192,128,0,1)
329 Button
.SetEventByName (IE_GUI_BUTTON_ON_RIGHT_PRESS
, "InfoRightWindow")
332 LeftButton
= Button
= Window
.GetControl (1)
333 Button
.SetText (14179)
334 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "StealPressed")
336 Button
= Window
.GetControl (37)
337 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
340 Label
= Window
.CreateLabel (0x10000043, 15,325,60,15,"NUMBER","0:",IE_FONT_ALIGN_LEFT|IE_FONT_ALIGN_TOP
)
341 Label
= Window
.CreateLabel (0x10000044, 15,365,80,15,"NUMBER","0:",IE_FONT_ALIGN_RIGHT|IE_FONT_ALIGN_TOP
)
344 ScrollBar
= Window
.GetControl (9)
345 ScrollBar
.SetEventByName (IE_GUI_SCROLLBAR_ON_CHANGE
, "RedrawStoreStealWindow")
348 ScrollBar
= Window
.GetControl (10)
349 ScrollBar
.SetEventByName (IE_GUI_SCROLLBAR_ON_CHANGE
, "RedrawStoreStealWindow")
351 SetSelectionChangeHandler( UpdateStoreStealWindow
)
352 UpdateStoreStealWindow ()
353 Window
.SetVisible (WINDOW_VISIBLE
)
356 def OpenStoreDonateWindow ():
357 global StoreDonateWindow
361 StoreDonateWindow
= Window
= GemRB
.LoadWindow (9)
364 Button
= Window
.GetControl (10)
365 Button
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_ANIMATED|IE_GUI_BUTTON_PLAYONCE
, OP_OR
)
366 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
369 Button
= Window
.GetControl (3)
370 Button
.SetText (15101)
371 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "DonateGold")
372 Button
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
375 Field
= Window
.GetControl (5)
377 Field
.SetEventByName (IE_GUI_EDIT_ON_CHANGE
, "UpdateStoreDonateWindow")
378 Field
.SetStatus (IE_GUI_EDIT_NUMBER
)
381 Button
= Window
.GetControl (6)
382 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "IncrementDonation")
384 Button
= Window
.GetControl (7)
385 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "DecrementDonation")
387 SetSelectionChangeHandler( UpdateStoreDonateWindow
)
388 UpdateStoreDonateWindow ()
389 Window
.SetVisible (WINDOW_VISIBLE
)
392 def OpenStoreHealWindow ():
393 global StoreHealWindow
395 GemRB
.SetVar ("Index", -1)
396 GemRB
.SetVar ("TopIndex", 0)
399 StoreHealWindow
= Window
= GemRB
.LoadWindow (5)
403 Button
= Window
.GetControl (i
+8)
404 Button
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON
, OP_OR
)
405 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "UpdateStoreHealWindow")
406 Button
.SetEventByName (IE_GUI_BUTTON_ON_RIGHT_PRESS
, "InfoHealWindow")
409 Label
= Window
.GetControl (0x10000003)
413 Button
= Window
.GetControl (5)
414 Button
.SetText (13703)
415 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "BuyHeal")
416 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
418 ScrollBar
= Window
.GetControl (7)
419 ScrollBar
.SetEventByName (IE_GUI_SCROLLBAR_ON_CHANGE
, "UpdateStoreHealWindow")
420 Count
= Store
['StoreCureCount']
425 ScrollBar
.SetVarAssoc ("TopIndex", Count
+1)
427 UpdateStoreHealWindow ()
428 Window
.SetVisible (WINDOW_VISIBLE
)
431 def OpenStoreRumourWindow ():
432 global StoreRumourWindow
434 GemRB
.SetVar ("TopIndex", 0)
437 StoreRumourWindow
= Window
= GemRB
.LoadWindow (8)
439 #removing those pesky labels
441 Window
.DeleteControl (0x10000005+i
)
443 TextArea
= Window
.GetControl (11)
444 TextArea
.SetText (14144)
446 #the quality isn't displayed in iwd
447 #BAM = "TVRNQUL%d"% ((Store['StoreFlags']>>9)&3)
448 #Button = Window.GetControl (12)
449 #Button.SetSprites (BAM, 0, 0, 0, 0, 0)
450 #Button.SetState (IE_GUI_BUTTON_LOCKED)
452 ScrollBar
= Window
.GetControl (5)
453 ScrollBar
.SetEventByName (IE_GUI_SCROLLBAR_ON_CHANGE
, "UpdateStoreRumourWindow")
454 Count
= Store
['StoreDrinkCount']
459 ScrollBar
.SetVarAssoc ("TopIndex", Count
+1)
461 UpdateStoreRumourWindow ()
462 Window
.SetVisible (WINDOW_VISIBLE
)
465 def OpenStoreRentWindow ():
466 global StoreRentWindow
, RentIndex
470 StoreRentWindow
= Window
= GemRB
.LoadWindow (7)
475 ok
= Store
['StoreRoomPrices'][i
]
476 Button
= Window
.GetControl (i
)
477 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "UpdateStoreRentWindow")
479 Button
.SetState (IE_GUI_BUTTON_DISABLED
) #disabled room icons are selected, not disabled
481 Button
.SetVarAssoc ("RentIndex", i
)
485 Button
= Window
.GetControl (i
+4)
486 Button
.SetText (14294+i
)
487 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "UpdateStoreRentWindow")
488 Button
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON
, OP_OR
)
489 Button
.SetVarAssoc ("RentIndex", i
)
491 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
494 Button
= Window
.GetControl (11)
495 Button
.SetText (14293)
496 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "RentRoom")
498 GemRB
.SetVar ("RentIndex", RentIndex
)
500 UpdateStoreRentWindow ()
501 Window
.SetVisible (WINDOW_VISIBLE
)
504 def UpdateStoreCommon (Window
, title
, name
, gold
):
506 Label
= Window
.GetControl (title
)
507 Label
.SetText (Store
['StoreName'])
510 pc
= GemRB
.GameGetSelectedPCSingle ()
511 Label
= Window
.GetControl (name
)
512 Label
.SetText (GemRB
.GetPlayerName (pc
, 0) )
514 Label
= Window
.GetControl (gold
)
515 Label
.SetText (str(GemRB
.GameGetPartyGold ()))
518 def UpdateStoreShoppingWindow ():
519 global Store
, inventory_slots
521 Window
= StoreShoppingWindow
522 #reget store in case of a change
523 Store
= GemRB
.GetStore ()
524 LeftCount
= Store
['StoreItemCount']-3
527 ScrollBar
= Window
.GetControl (11)
528 ScrollBar
.SetVarAssoc ("LeftTopIndex", LeftCount
)
529 LeftTopIndex
= GemRB
.GetVar ("LeftTopIndex")
530 if LeftTopIndex
>LeftCount
:
531 GemRB
.SetVar ("LeftTopIndex", LeftCount
)
533 pc
= GemRB
.GameGetSelectedPCSingle ()
534 inventory_slots
= GemRB
.GetSlots (pc
, SLOT_INVENTORY
)
535 RightCount
= len(inventory_slots
)-3
538 ScrollBar
= Window
.GetControl (12)
539 ScrollBar
.SetVarAssoc ("RightTopIndex", RightCount
)
540 RightTopIndex
= GemRB
.GetVar ("RightTopIndex")
541 if RightTopIndex
>RightCount
:
542 GemRB
.SetVar ("RightTopIndex", RightCount
)
544 RedrawStoreShoppingWindow ()
548 Window
= StoreShoppingWindow
550 pc
= GemRB
.GameGetSelectedPCSingle ()
551 LeftIndex
= GemRB
.GetVar ("LeftIndex")
552 GemRB
.ChangeStoreItem (pc
, LeftIndex
, SHOP_BUY|SHOP_SELECT
)
553 RedrawStoreShoppingWindow ()
556 def ToBackpackPressed ():
557 Window
= StoreShoppingWindow
559 pc
= GemRB
.GameGetSelectedPCSingle ()
560 LeftCount
= Store
['StoreItemCount']
561 #going backwards because removed items shift the slots
562 for i
in range (LeftCount
, 0, -1):
563 Flags
= GemRB
.IsValidStoreItem (pc
, i
-1, ITEM_STORE
)&SHOP_SELECT
565 GemRB
.ChangeStoreItem (pc
, i
-1, SHOP_BUY
)
567 UpdateStoreShoppingWindow ()
571 Window
= StoreShoppingWindow
573 if (BuySum
>GemRB
.GameGetPartyGold ()):
577 pc
= GemRB
.GameGetSelectedPCSingle ()
578 LeftCount
= Store
['StoreItemCount']
579 #going backwards because removed items shift the slots
580 for i
in range (LeftCount
, 0, -1):
581 Flags
= GemRB
.IsValidStoreItem (pc
, i
-1, ITEM_STORE
)&SHOP_SELECT
583 Slot
= GemRB
.GetStoreItem (i
-1)
584 Item
= GemRB
.GetItem (Slot
['ItemResRef'])
585 Price
= Item
['Price'] * Store
['SellMarkup'] / 100
589 if GemRB
.ChangeStoreItem (pc
, i
-1, SHOP_BUY
):
590 GemRB
.GameSetPartyGold (GemRB
.GameGetPartyGold ()-Price
)
591 UpdateStoreShoppingWindow ()
595 Window
= StoreShoppingWindow
597 pc
= GemRB
.GameGetSelectedPCSingle ()
598 RightIndex
= GemRB
.GetVar ("RightIndex")
599 GemRB
.ChangeStoreItem (pc
, inventory_slots
[RightIndex
], SHOP_SELL|SHOP_SELECT
)
600 RedrawStoreShoppingWindow ()
604 Window
= StoreShoppingWindow
606 pc
= GemRB
.GameGetSelectedPCSingle ()
607 RightCount
= len (inventory_slots
)
608 #no need to go reverse
609 for Slot
in range (RightCount
):
610 Flags
= GemRB
.IsValidStoreItem (pc
, inventory_slots
[Slot
], ITEM_PC
)
611 if Flags
& SHOP_SELECT
:
612 GemRB
.ChangeStoreItem (pc
, inventory_slots
[Slot
], SHOP_SELL
)
613 UpdateStoreShoppingWindow ()
617 Window
= StoreShoppingWindow
619 pc
= GemRB
.GameGetSelectedPCSingle ()
620 RightCount
= len (inventory_slots
)
621 #no need to go reverse
622 for Slot
in range (RightCount
):
623 Flags
= GemRB
.IsValidStoreItem (pc
, inventory_slots
[Slot
], ITEM_PC
) & SHOP_SELECT
625 GemRB
.ChangeStoreItem (pc
, inventory_slots
[Slot
], SHOP_SELL
)
627 GemRB
.GameSetPartyGold (GemRB
.GameGetPartyGold ()+SellSum
)
628 UpdateStoreShoppingWindow ()
631 def RedrawStoreShoppingWindow ():
632 global BuySum
, SellSum
634 Window
= StoreShoppingWindow
636 UpdateStoreCommon (Window
, 0x10000003, 0x1000002e, 0x1000002a)
637 pc
= GemRB
.GameGetSelectedPCSingle ()
639 LeftTopIndex
= GemRB
.GetVar ("LeftTopIndex")
640 LeftIndex
= GemRB
.GetVar ("LeftIndex")
641 RightTopIndex
= GemRB
.GetVar ("RightTopIndex")
642 RightIndex
= GemRB
.GetVar ("RightIndex")
643 LeftCount
= Store
['StoreItemCount']
645 for i
in range (LeftCount
):
646 if GemRB
.IsValidStoreItem (pc
, i
, ITEM_STORE
) & SHOP_SELECT
:
647 Slot
= GemRB
.GetStoreItem (i
)
648 Item
= GemRB
.GetItem (Slot
['ItemResRef'])
652 Price
= Item
['Price'] * Store
['SellMarkup'] / 100
655 BuySum
= BuySum
+ Price
657 RightCount
= len(inventory_slots
)
659 for i
in range (RightCount
):
660 Flags
= GemRB
.IsValidStoreItem (pc
, inventory_slots
[i
], ITEM_PC
)
661 if Flags
& SHOP_SELECT
:
662 Slot
= GemRB
.GetSlotItem (pc
, inventory_slots
[i
])
663 Item
= GemRB
.GetItem (Slot
['ItemResRef'])
667 Price
= Item
['Price'] * Store
['BuyMarkup'] / 100
670 SellSum
= SellSum
+ Price
672 Label
= Window
.GetControl (0x1000002b)
676 Label
.SetText (str(BuySum
) )
678 LeftButton
.SetState (IE_GUI_BUTTON_ENABLED
)
680 LeftButton
.SetState (IE_GUI_BUTTON_DISABLED
)
682 Label
= Window
.GetControl (0x1000002c)
686 Label
.SetText (str(SellSum
) )
688 RightButton
.SetState (IE_GUI_BUTTON_ENABLED
)
690 RightButton
.SetState (IE_GUI_BUTTON_DISABLED
)
693 if i
+LeftTopIndex
<LeftCount
:
694 Slot
= GemRB
.GetStoreItem (i
+LeftTopIndex
)
697 Button
= Window
.GetControl (i
+5)
698 Label
= Window
.GetControl (0x10000012+i
)
699 Button
.SetVarAssoc ("LeftIndex", LeftTopIndex
+i
)
701 Flags
= GemRB
.IsValidStoreItem (pc
, i
+LeftTopIndex
, ITEM_STORE
)
702 Item
= GemRB
.GetItem (Slot
['ItemResRef'])
703 Button
.SetItemIcon (Slot
['ItemResRef'], 0)
704 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_NAND
)
705 Button
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_OR
)
707 if Flags
& SHOP_SELECT
:
708 Button
.SetState (IE_GUI_BUTTON_SELECTED
)
710 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
712 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
715 GemRB
.SetToken ("ITEMNAME", GemRB
.GetString (Item
['ItemName']))
716 Button
.EnableBorder (0, 1)
718 GemRB
.SetToken ("ITEMNAME", GemRB
.GetString (Item
['ItemNameIdentified']))
719 Button
.EnableBorder (0, 0)
722 Label
.SetText (24890) #different from BG
724 Price
= Item
['Price'] * Store
['SellMarkup'] / 100
727 GemRB
.SetToken ("ITEMCOST", str(Price
) )
728 Label
.SetText (10162)
730 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
731 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_OR
)
732 Button
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_NAND
)
735 if i
+RightTopIndex
<RightCount
:
736 Slot
= GemRB
.GetSlotItem (pc
, inventory_slots
[i
+RightTopIndex
])
739 Button
= Window
.GetControl (i
+13)
740 Label
= Window
.GetControl (0x1000001e+i
)
741 Button
.SetVarAssoc ("RightIndex", RightTopIndex
+i
)
743 Flags
= GemRB
.IsValidStoreItem (pc
, inventory_slots
[i
+RightTopIndex
], ITEM_PC
)
744 Item
= GemRB
.GetItem (Slot
['ItemResRef'])
745 Button
.SetItemIcon (Slot
['ItemResRef'], 0)
746 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_NAND
)
747 Button
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_OR
)
751 Price
= Item
['Price'] * Store
['BuyMarkup'] / 100
753 if (Price
>0) and (Flags
& SHOP_SELL
):
754 if Flags
& SHOP_SELECT
:
755 Button
.SetState (IE_GUI_BUTTON_SELECTED
)
757 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
759 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
762 GemRB
.SetToken ("ITEMNAME", GemRB
.GetString (Item
['ItemName']))
764 Button
.EnableBorder (0, 1)
766 GemRB
.SetToken ("ITEMNAME", GemRB
.GetString (Item
['ItemNameIdentified']))
767 Button
.EnableBorder (0, 0)
770 Label
.SetText (24890) #different from BG
772 GemRB
.SetToken ("ITEMCOST", str(Price
) )
773 Label
.SetText (10162)
775 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
776 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_OR
)
777 Button
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_NAND
)
781 def UpdateStoreIdentifyWindow ():
782 global inventory_slots
784 Window
= StoreIdentifyWindow
786 pc
= GemRB
.GameGetSelectedPCSingle ()
787 inventory_slots
= GemRB
.GetSlots (pc
, SLOT_INVENTORY
)
788 Count
= len(inventory_slots
)
789 ScrollBar
= Window
.GetControl (7)
790 ScrollBar
.SetVarAssoc ("TopIndex", Count
-3)
791 GemRB
.SetVar ("Index", -1)
792 RedrawStoreIdentifyWindow ()
795 def RedrawStoreIdentifyWindow ():
796 Window
= StoreIdentifyWindow
798 UpdateStoreCommon (Window
, 0x10000000, 0x10000005, 0x10000001)
799 TopIndex
= GemRB
.GetVar ("TopIndex")
800 Index
= GemRB
.GetVar ("Index")
801 pc
= GemRB
.GameGetSelectedPCSingle ()
802 Count
= len(inventory_slots
)
803 IDPrice
= Store
['IDPrice']
805 TextArea
= Window
.GetControl (23)
806 TextArea
.SetText ("")
810 Slot
= GemRB
.GetSlotItem (pc
, inventory_slots
[TopIndex
+i
])
813 Button
= Window
.GetControl (i
+8)
814 Label
= Window
.GetControl (0x1000000c+i
)
815 Button
.SetVarAssoc ("Index", TopIndex
+i
)
817 Flags
= GemRB
.IsValidStoreItem (pc
, inventory_slots
[TopIndex
+i
], ITEM_PC
)
818 Item
= GemRB
.GetItem (Slot
['ItemResRef'])
819 Button
.SetItemIcon (Slot
['ItemResRef'], 0)
820 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_NAND
)
821 Button
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_OR
)
823 if Index
== TopIndex
+i
:
824 Button
.SetState (IE_GUI_BUTTON_SELECTED
)
825 Text
= Item
['ItemDesc']
826 TextArea
.SetText (Text
)
829 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
831 GemRB
.SetToken ("ITEMNAME", GemRB
.GetString (Item
['ItemName']))
832 GemRB
.SetToken ("ITEMCOST", str(IDPrice
) )
833 Button
.EnableBorder (0, 1)
835 if Index
== TopIndex
+i
:
836 Text
= Item
['ItemDescIdentified']
837 TextArea
.SetText (Text
)
838 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
839 GemRB
.SetToken ("ITEMNAME", GemRB
.GetString (Item
['ItemNameIdentified']))
840 GemRB
.SetToken ("ITEMCOST", str(0) )
841 Button
.EnableBorder (0, 0)
843 Label
.SetText (10162)
845 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
846 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_OR
)
847 Button
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_NAND
)
850 Button
= Window
.GetControl (5)
851 Label
= Window
.GetControl (0x10000003)
853 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
854 Label
.SetText (str(IDPrice
) )
856 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
857 Label
.SetText (str(0) )
860 def IdentifyPressed ():
861 IDPrice
= Store
['IDPrice']
862 if (GemRB
.GameGetPartyGold ()<IDPrice
):
865 Index
= GemRB
.GetVar ("Index")
869 pc
= GemRB
.GameGetSelectedPCSingle ()
870 Count
= len(inventory_slots
)
874 GemRB
.ChangeStoreItem (pc
, inventory_slots
[Index
], SHOP_ID
)
875 GemRB
.GameSetPartyGold (GemRB
.GameGetPartyGold ()-IDPrice
)
876 UpdateStoreIdentifyWindow ()
879 def InfoIdentifyWindow ():
880 Index
= GemRB
.GetVar ("Index")
881 pc
= GemRB
.GameGetSelectedPCSingle ()
882 Count
= len(inventory_slots
)
885 Slot
= GemRB
.GetSlotItem (pc
, inventory_slots
[Index
])
886 Item
= GemRB
.GetItem (Slot
['ItemResRef'])
887 InfoWindow (Slot
, Item
)
890 def InfoLeftWindow ():
891 Index
= GemRB
.GetVar ("LeftIndex")
892 Slot
= GemRB
.GetStoreItem (Index
)
893 Item
= GemRB
.GetItem (Slot
['ItemResRef'])
894 InfoWindow (Slot
, Item
)
897 def InfoRightWindow ():
898 Index
= GemRB
.GetVar ("RightIndex")
899 pc
= GemRB
.GameGetSelectedPCSingle ()
900 Count
= len(inventory_slots
)
903 Slot
= GemRB
.GetSlotItem (pc
, inventory_slots
[Index
])
904 Item
= GemRB
.GetItem (Slot
['ItemResRef'])
905 InfoWindow (Slot
, Item
)
908 def InfoWindow (Slot
, Item
):
911 Identify
= Slot
['Flags'] & IE_INV_ITEM_IDENTIFIED
913 MessageWindow
= Window
= GemRB
.LoadWindow (12)
916 Label
= Window
.GetControl (0x10000000)
919 #description bam, only in bg2
920 #Button = Window.GetControl (7)
921 #Button.SetItemIcon (Slot['ItemResRef'], 2)
924 Button
= Window
.GetControl (2)
925 Button
.SetItemIcon (Slot
['ItemResRef'], 0)
927 Label
= Window
.GetControl (0x10000007)
928 TextArea
= Window
.GetControl (5)
930 Label
.SetText (Item
['ItemNameIdentified'])
931 TextArea
.SetText (Item
['ItemDescIdentified'])
933 Label
.SetText (Item
['ItemName'])
934 TextArea
.SetText (Item
['ItemDesc'])
937 Button
= Window
.GetControl (4)
938 Button
.SetText (11973)
939 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "ErrorDone")
941 Window
.ShowModal (MODAL_SHADOW_GRAY
)
944 def UpdateStoreStealWindow ():
945 global Store
, inventory_slots
947 Window
= StoreStealWindow
949 #reget store in case of a change
950 Store
= GemRB
.GetStore ()
951 LeftCount
= Store
['StoreItemCount']
952 ScrollBar
= Window
.GetControl (9)
953 ScrollBar
.SetVarAssoc ("LeftTopIndex", LeftCount
-3)
955 pc
= GemRB
.GameGetSelectedPCSingle ()
956 inventory_slots
= GemRB
.GetSlots (pc
, SLOT_INVENTORY
)
957 RightCount
= len(inventory_slots
)
958 ScrollBar
= Window
.GetControl (10)
959 ScrollBar
.SetVarAssoc ("RightTopIndex", RightCount
-3)
960 GemRB
.SetVar ("LeftIndex", -1)
961 LeftButton
.SetState (IE_GUI_BUTTON_DISABLED
)
962 RedrawStoreStealWindow ()
966 Window
= StoreShoppingWindow
968 LeftIndex
= GemRB
.GetVar ("LeftIndex")
969 pc
= GemRB
.GameGetSelectedPCSingle ()
970 #percentage skill check, if fails, trigger StealFailed
971 if CheckStat100 (pc
, IE_PICKPOCKET
, Store
['StealFailure']):
972 GemRB
.ChangeStoreItem (pc
, LeftIndex
, SHOP_STEAL
)
973 UpdateStoreStealWindow ()
979 def RedrawStoreStealWindow ():
980 Window
= StoreStealWindow
982 UpdateStoreCommon (Window
, 0x10000002, 0x10000027, 0x10000023)
983 LeftTopIndex
= GemRB
.GetVar ("LeftTopIndex")
984 LeftIndex
= GemRB
.GetVar ("LeftIndex")
985 RightTopIndex
= GemRB
.GetVar ("RightTopIndex")
986 RightIndex
= GemRB
.GetVar ("RightIndex")
987 LeftCount
= Store
['StoreItemCount']
988 pc
= GemRB
.GameGetSelectedPCSingle ()
989 RightCount
= len(inventory_slots
)
991 Slot
= GemRB
.GetStoreItem (i
+LeftTopIndex
)
992 Button
= Window
.GetControl (i
+4)
993 Label
= Window
.GetControl (0x1000000f+i
)
994 Button
.SetVarAssoc ("LeftIndex", LeftTopIndex
+i
)
996 Flags
= GemRB
.IsValidStoreItem (pc
, i
+LeftTopIndex
, ITEM_STORE
)
997 Item
= GemRB
.GetItem (Slot
['ItemResRef'])
998 Button
.SetItemIcon (Slot
['ItemResRef'], 0)
999 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_NAND
)
1000 Button
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_OR
)
1001 if Flags
& SHOP_STEAL
:
1002 if LeftIndex
== LeftTopIndex
+ i
:
1003 Button
.SetState (IE_GUI_BUTTON_SELECTED
)
1005 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
1007 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
1010 GemRB
.SetToken ("ITEMNAME", GemRB
.GetString (Item
['ItemName']))
1011 Button
.EnableBorder (0, 1)
1013 GemRB
.SetToken ("ITEMNAME", GemRB
.GetString (Item
['ItemNameIdentified']))
1014 Button
.EnableBorder (0, 0)
1016 GemRB
.SetToken ("ITEMCOST", str(Slot
['Price']) )
1017 Label
.SetText (10162)
1019 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
1020 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_OR
)
1021 Button
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_NAND
)
1024 if i
+RightTopIndex
<RightCount
:
1025 Slot
= GemRB
.GetSlotItem (pc
, inventory_slots
[i
+RightTopIndex
])
1028 Button
= Window
.GetControl (i
+11)
1029 Label
= Window
.GetControl (0x10000019+i
)
1030 Button
.SetVarAssoc ("RightIndex", RightTopIndex
+i
)
1032 Flags
= GemRB
.IsValidStoreItem (pc
, inventory_slots
[i
+RightTopIndex
], ITEM_PC
)
1033 Item
= GemRB
.GetItem (Slot
['ItemResRef'])
1034 Button
.SetItemIcon (Slot
['ItemResRef'], 0)
1035 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_NAND
)
1036 Button
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_OR
)
1037 Price
= Item
['Price'] * Store
['BuyMarkup'] / 100
1038 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
1040 GemRB
.SetToken ("ITEMNAME", GemRB
.GetString (Item
['ItemName']))
1041 Button
.EnableBorder (0, 1)
1043 GemRB
.SetToken ("ITEMNAME", GemRB
.GetString (Item
['ItemNameIdentified']))
1044 Button
.EnableBorder (0, 0)
1046 GemRB
.SetToken ("ITEMCOST", str(Price
) )
1047 Label
.SetText (10162)
1049 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
1050 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_OR
)
1051 Button
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_NAND
)
1054 LeftButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1056 LeftButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1059 def UpdateStoreDonateWindow ():
1060 Window
= StoreDonateWindow
1062 UpdateStoreCommon (Window
, 0x10000007, 0, 0x10000008)
1063 Field
= Window
.GetControl (5)
1064 donation
= int("0"+Field
.QueryText ())
1065 gold
= GemRB
.GameGetPartyGold ()
1068 Field
.SetText (str(gold
) )
1070 Button
= Window
.GetControl (3)
1072 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
1074 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
1077 def IncrementDonation ():
1078 Window
= StoreDonateWindow
1080 Field
= Window
.GetControl (5)
1081 donation
= int("0"+Field
.QueryText ())
1082 if donation
<GemRB
.GameGetPartyGold ():
1083 Field
.SetText (str(donation
+1) )
1085 Field
.SetText (str(GemRB
.GameGetPartyGold ()) )
1086 UpdateStoreDonateWindow ()
1089 def DecrementDonation ():
1090 Window
= StoreDonateWindow
1092 Field
= Window
.GetControl (5)
1093 donation
= int("0"+Field
.QueryText ())
1095 Field
.SetText (str(donation
-1) )
1097 Field
.SetText (str(0) )
1098 UpdateStoreDonateWindow ()
1102 Window
= StoreDonateWindow
1104 TextArea
= Window
.GetControl (0)
1105 TextArea
.SetFlags (IE_GUI_TEXTAREA_AUTOSCROLL
)
1107 Button
= Window
.GetControl (10)
1108 Button
.SetAnimation ("DONATE")
1110 Field
= Window
.GetControl (5)
1111 donation
= int("0"+Field
.QueryText ())
1112 GemRB
.GameSetPartyGold (GemRB
.GameGetPartyGold ()-donation
)
1113 if GemRB
.IncreaseReputation (donation
):
1114 TextArea
.Append (10468, -1)
1115 GemRB
.PlaySound ("act_03")
1116 UpdateStoreDonateWindow ()
1119 TextArea
.Append (10469, -1)
1120 GemRB
.PlaySound ("act_03e")
1121 UpdateStoreDonateWindow ()
1124 def UpdateStoreHealWindow ():
1125 Window
= StoreHealWindow
1127 UpdateStoreCommon (Window
, 0x10000000, 0, 0x10000001)
1128 TopIndex
= GemRB
.GetVar ("TopIndex")
1129 Index
= GemRB
.GetVar ("Index")
1131 Cure
= GemRB
.GetStoreCure (TopIndex
+i
)
1133 Button
= Window
.GetControl (i
+8)
1134 Label
= Window
.GetControl (0x1000000c+i
)
1135 Button
.SetVarAssoc ("Index", TopIndex
+i
)
1137 Spell
= GemRB
.GetSpell (Cure
['CureResRef'])
1138 Button
.SetSpellIcon (Cure
['CureResRef'], 1)
1139 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_NAND
)
1140 Button
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_OR
)
1142 GemRB
.SetToken ("ITEMNAME", GemRB
.GetString (Spell
['SpellName']))
1143 GemRB
.SetToken ("ITEMCOST", str(Cure
['Price']) )
1144 Label
.SetText (10162)
1147 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
1148 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_OR
)
1149 Button
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_NAND
)
1151 if TopIndex
+i
==Index
:
1152 TextArea
= Window
.GetControl (23)
1153 TextArea
.SetText (Cure
['Description'])
1154 Label
= Window
.GetControl (0x10000003)
1155 Label
.SetText (str(Cure
['Price']) )
1156 Button
= Window
.GetControl (5)
1157 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
1160 def InfoHealWindow ():
1161 global MessageWindow
1163 UpdateStoreHealWindow ()
1164 Index
= GemRB
.GetVar ("Index")
1165 Cure
= GemRB
.GetStoreCure (Index
)
1166 Spell
= GemRB
.GetSpell (Cure
['CureResRef'])
1168 MessageWindow
= Window
= GemRB
.LoadWindow (14)
1170 Label
= Window
.GetControl (0x10000000)
1171 Label
.SetText (Spell
['SpellName'])
1173 Button
= Window
.GetControl (2)
1174 Button
.SetSpellIcon (Cure
['CureResRef'], 1)
1176 TextArea
= Window
.GetControl (3)
1177 TextArea
.SetText (Spell
['SpellDesc'])
1180 Button
= Window
.GetControl (5)
1181 Button
.SetText (11973)
1182 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "ErrorDone")
1184 Window
.ShowModal (MODAL_SHADOW_GRAY
)
1188 Index
= GemRB
.GetVar ("Index")
1189 Cure
= GemRB
.GetStoreCure (Index
)
1190 gold
= GemRB
.GameGetPartyGold ()
1191 if gold
< Cure
['Price']:
1195 GemRB
.GameSetPartyGold (gold
-Cure
['Price'])
1196 pc
= GemRB
.GameGetSelectedPCSingle ()
1197 GemRB
.ApplySpell (pc
, Cure
['CureResRef'])
1198 UpdateStoreHealWindow ()
1201 def UpdateStoreRumourWindow ():
1202 Window
= StoreRumourWindow
1204 UpdateStoreCommon (Window
, 0x10000011, 0, 0x10000012)
1205 TopIndex
= GemRB
.GetVar ("TopIndex")
1207 Drink
= GemRB
.GetStoreDrink (TopIndex
+i
)
1208 Button
= Window
.GetControl (i
)
1209 Button
.SetVarAssoc ("Index", i
)
1211 GemRB
.SetToken ("ITEMNAME", GemRB
.GetString (Drink
['DrinkName']))
1212 GemRB
.SetToken ("ITEMCOST", str(Drink
['Price']) )
1213 Button
.SetText (10162)
1214 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
1215 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "GulpDrink")
1218 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
1222 Window
= StoreRumourWindow
1224 TextArea
= Window
.GetControl (13)
1225 TextArea
.SetFlags (IE_GUI_TEXTAREA_AUTOSCROLL
)
1226 pc
= GemRB
.GameGetSelectedPCSingle ()
1227 intox
= GemRB
.GetPlayerStat (pc
, IE_INTOXICATION
)
1230 TextArea
.Append (10832, -1)
1233 gold
= GemRB
.GameGetPartyGold ()
1234 Index
= GemRB
.GetVar ("TopIndex")+GemRB
.GetVar ("Index")
1235 Drink
= GemRB
.GetStoreDrink (Index
)
1236 if gold
< Drink
['Price']:
1240 GemRB
.GameSetPartyGold (gold
-Drink
['Price'])
1241 GemRB
.SetPlayerStat (pc
, IE_INTOXICATION
, intox
+Drink
['Strength'])
1242 text
= GemRB
.GetRumour (Drink
['Strength'], Store
['TavernRumour'])
1243 TextArea
.Append (text
, -1)
1244 GemRB
.PlaySound ("gam_07")
1245 UpdateStoreRumourWindow ()
1248 def UpdateStoreRentWindow ():
1251 Window
= StoreRentWindow
1252 UpdateStoreCommon (Window
, 0x10000008, 0, 0x10000009)
1253 RentIndex
= GemRB
.GetVar ("RentIndex")
1254 Button
= Window
.GetControl (11)
1255 Label
= Window
.GetControl (0x1000000d)
1257 TextArea
= Window
.GetControl (12)
1258 TextArea
.SetText (roomtypes
[RentIndex
] )
1259 price
= Store
['StoreRoomPrices'][RentIndex
]
1260 Label
.SetText (str(price
) )
1261 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
1263 Label
.SetText ("0" )
1264 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
1268 RentIndex
= GemRB
.GetVar ("RentIndex")
1269 price
= Store
['StoreRoomPrices'][RentIndex
]
1270 Gold
= GemRB
.GameGetPartyGold ()
1271 GemRB
.GameSetPartyGold (Gold
-price
)
1272 GemRB
.RestParty (13, 1, RentIndex
+1)
1273 if RentConfirmWindow
:
1274 RentConfirmWindow
.Unload ()
1275 Window
= StoreRentWindow
1276 TextArea
= Window
.GetControl (12)
1277 #is there any way to change this???
1278 GemRB
.SetToken ("HOUR", "8")
1279 GemRB
.SetToken ("HP", "%d"%(RentIndex
+1))
1280 TextArea
.SetText (16476)
1281 GemRB
.SetVar ("RentIndex", -1)
1282 Button
= Window
.GetControl (RentIndex
+4)
1283 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
1284 UpdateStoreRentWindow ()
1288 if RentConfirmWindow
:
1289 RentConfirmWindow
.Unload ()
1290 UpdateStoreRentWindow ()
1294 global RentIndex
, RentConfirmWindow
1296 RentIndex
= GemRB
.GetVar ("RentIndex")
1297 price
= Store
['StoreRoomPrices'][RentIndex
]
1298 Gold
= GemRB
.GameGetPartyGold ()
1303 RentConfirmWindow
= Window
= GemRB
.LoadWindow (11)
1305 Button
= Window
.GetControl (0)
1306 Button
.SetText (17199)
1307 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "RentConfirm")
1308 Button
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1311 Button
= Window
.GetControl (1)
1312 Button
.SetText (13727)
1313 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "RentDeny")
1314 Button
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
1317 TextArea
= Window
.GetControl (3)
1318 TextArea
.SetText (15358)
1320 Window
.ShowModal (MODAL_SHADOW_GRAY
)
1323 def CloseStoreShoppingWindow ():
1324 global StoreShoppingWindow
1326 if StoreShoppingWindow
!= None:
1327 if StoreShoppingWindow
:
1328 StoreShoppingWindow
.Unload ()
1329 StoreShoppingWindow
= None
1332 def CloseStoreIdentifyWindow ():
1333 global StoreIdentifyWindow
1335 if StoreIdentifyWindow
!= None:
1336 if StoreIdentifyWindow
:
1337 StoreIdentifyWindow
.Unload ()
1338 StoreIdentifyWindow
= None
1341 def CloseStoreStealWindow ():
1342 global StoreStealWindow
1344 if StoreStealWindow
!= None:
1345 if StoreStealWindow
:
1346 StoreStealWindow
.Unload ()
1347 StoreStealWindow
= None
1350 def CloseStoreDonateWindow ():
1351 global StoreDonateWindow
1353 if StoreDonateWindow
!= None:
1354 if StoreDonateWindow
:
1355 StoreDonateWindow
.Unload ()
1356 StoreDonateWindow
= None
1359 def CloseStoreHealWindow ():
1360 global StoreHealWindow
1362 if StoreHealWindow
!= None:
1364 StoreHealWindow
.Unload ()
1365 StoreHealWindow
= None
1368 def CloseStoreRumourWindow ():
1369 global StoreRumourWindow
1371 if StoreRumourWindow
!= None:
1372 if StoreRumourWindow
:
1373 StoreRumourWindow
.Unload ()
1374 StoreRumourWindow
= None
1377 def CloseStoreRentWindow ():
1378 global StoreRentWindow
1380 if StoreRentWindow
!= None:
1382 StoreRentWindow
.Unload ()
1383 StoreRentWindow
= None
1386 def ErrorWindow (strref
):
1387 global MessageWindow
1389 MessageWindow
= Window
= GemRB
.LoadWindow (10)
1391 TextArea
= Window
.GetControl (3)
1392 TextArea
.SetText (strref
)
1395 Button
= Window
.GetControl (0)
1396 Button
.SetText (11973)
1397 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "ErrorDone")
1399 Window
.ShowModal (MODAL_SHADOW_GRAY
)
1404 MessageWindow
.Unload ()
1407 ###################################################
1408 # End of file GUISTORE.py