Sfoglia il codice sorgente

[added] 'display_func_managed' function to 'shop_utils'

f95Lok 2 settimane fa
parent
commit
cb43097084
1 ha cambiato i file con 43 aggiunte e 0 eliminazioni
  1. 43 0
      locations/shop_utils.qsrc

+ 43 - 0
locations/shop_utils.qsrc

@@ -63,6 +63,10 @@ if $ARGS[0] = 'shop':
 		if dyneval('result = <<$shop_display[''variable'']>>_purses[shop_display[''i'']]') = 0:
 			$result = '<a href="exec: gt ''purses'', ''view_purse_item'', ''shop'', ''<<$shop_display[''variable'']>>'', <<shop_display[''i'']>>"><img height="250" src="<<$shop_display[''item_img_path'']>>/<<shop_display[''i'']>>.jpg"></a>'
 		end
+
+	elseif $ARGS[1] = 'func_managed':
+		$result = '<a href="exec: gt ''<<$shop_display[''main_func_name'']>>'', ''view_item'', ''shop'', ''<<$shop_display[''item_type'']>>'', <<shop_display[''i'']>>"><img height="250" src="<<func($shop_display[''main_func_name''], $shop_display[''img_func_name''], shop_display[''i''])>>"></a>'
+	
 	end
 
 	exit
@@ -360,5 +364,44 @@ if $ARGS[0] = 'display_purses':
 	killvar 'shop_display'
 end
 
+! The file managing your item MUST implement the following funcitons
+!	- 'totals' which returns the max number of items of the specified type
+! 	- 'view_item' which takes 3 arguments and handles displaying, buying and any other related fuctionalities 
+!		- 'action_type' (shop, wardrobe, etc)
+! 		- 'type' 
+!		- 'index'
+! 	- individual functons for each type that return an image of the item based on its index
+! 
+! Arguments for this function are:
+! [1] - name of file that manages the item
+! [2] - item type
+! [3] - loop step
+! [4] - image function name
+! [5] - link type
+! [6] - loop index start offset {OPTIONAL}
+! Populate the 'shop_display_exceptions[]' array with the index of the outfits you want excluded from the display.
+if $ARGS[0] = 'display_func_managed':
+	$shop_display['main_func_name'] = $ARGS[1]
+	$shop_display['item_type'] = $ARGS[2]
+	$shop_display['img_func_name'] = $ARGS[4]
+
+
+	total = func($shop_display['main_func_name'], 'totals', $ARGS[2])
+
+	if total <= 0:
+		killvar 'shop_display'
+		exit
+	end
+
+	shop_display['i'] = 1 + ARGS[6]
+	:func_managed_main_loop
+	if shop_display['i'] <= total:
+		if arrpos('shop_display_exception', shop_display['i']) < 0:
+			*p func('shop_utils', $ARGS[5], 'func_managed')
+		end
+		shop_display['i'] += ARGS[3]
+		jump 'func_managed_main_loop'
+	end
+end
 
 --- shop_utils ---------------------------------