Currency type names from (typFind '$) are listed in a custompicker screen.
The screen description shows the current player balance for every available currency and updates in OnPaneInit.
Actions are used to change the value of the currency the cursor is on.
But the number of currencies varies; 2 in SOTP, 4 in EP, etc, so the number of lines in the screen description can also vary.
This <OnPaneInit> code works:
Code: Select all
(block Nil
(scrSetData gScreen 'currency (scrGetListEntry gScreen))
(setq currList (typFind '$))
(setq listLength (count currList))
(scrSetDesc gScreen
(cat "Enter amount of " (scrGetData gScreen 'currency) " to add or subtract.\n"
(if (@ currList 0)
(cat (typGetProperty (@ currList 0) 'name) ": " (fmtNumber 'integer (plyGetCredits gPlayer (@ currList 0))) "\n")
)
(if (@ currList 1)
(cat (typGetProperty (@ currList 1) 'name) ": " (fmtNumber 'integer (plyGetCredits gPlayer (@ currList 1))) "\n")
)
(if (@ currList 2)
(cat (typGetProperty (@ currList 2) 'name) ": " (fmtNumber 'integer (plyGetCredits gPlayer (@ currList 2))) "\n")
)
(if (@ currList 3)
(cat (typGetProperty (@ currList 3) 'name) ": " (fmtNumber 'integer (plyGetCredits gPlayer (@ currList 3))) "\n")
)
(if (@ currList 4)
(cat (typGetProperty (@ currList 4) 'name) ": " (fmtNumber 'integer (plyGetCredits gPlayer (@ currList 4))) "\n")
)
)
)
)
Possibly 'enumWhile' until the number of display list entries (listLength) is reached? Or 'for' doing the same thing? Another possibility might be 'loop'?
Anyone know the easy way to do this? The number of currencies displayed in the screen description needs to match the number of currencies displayed in the list which is set by typFind '$.
Whole dockscreen code:
Code: Select all
<Dockscreen UNID="&dsD789GodCurrencyDockscreen;"
name= "Currency"
type= "customPicker"
nestedScreen= "true"
>
<List
rowHeight="44"
>
(map (typFind '$) theCurrency (typGetProperty theCurrency 'name))
</List>
<Panes>
<Default
showCounter="true"
>
<OnPaneInit>
(block Nil
(scrSetData gScreen 'currency (scrGetListEntry gScreen))
(setq currList (typFind '$))
(setq listLength (count currList))
(scrSetDesc gScreen
(cat "Enter amount of " (scrGetData gScreen 'currency) " to add or subtract.\n"
(if (@ currList 0)
(cat (typGetProperty (@ currList 0) 'name) ": " (fmtNumber 'integer (plyGetCredits gPlayer (@ currList 0))) "\n")
)
(if (@ currList 1)
(cat (typGetProperty (@ currList 1) 'name) ": " (fmtNumber 'integer (plyGetCredits gPlayer (@ currList 1))) "\n")
)
(if (@ currList 2)
(cat (typGetProperty (@ currList 2) 'name) ": " (fmtNumber 'integer (plyGetCredits gPlayer (@ currList 2))) "\n")
)
(if (@ currList 3)
(cat (typGetProperty (@ currList 3) 'name) ": " (fmtNumber 'integer (plyGetCredits gPlayer (@ currList 3))) "\n")
)
(if (@ currList 4)
(cat (typGetProperty (@ currList 4) 'name) ": " (fmtNumber 'integer (plyGetCredits gPlayer (@ currList 4))) "\n")
)
)
)
)
</OnPaneInit>
<Actions>
<Action id="actionMillionCurrency">
(block Nil
(plyCredit gPlayer (scrGetData gScreen 'currency) 1000000)
(scrShowPane gScreen "Default")
)
</Action>
<Action id="actionZeroCurrency">
(block Nil
(plyCharge gPlayer (scrGetData gScreen 'currency) (plyGetCredits gPlayer (scrGetData gScreen 'currency)))
(scrShowPane gScreen "Default")
)
</Action>
<Action id="actionAddCurrency">
(block Nil
(plyCredit gPlayer (scrGetData gScreen 'currency) (scrGetCounter gScreen))
(scrShowPane gScreen "Default")
)
</Action>
<Action id="actionSubtractCurrency">
(block Nil
(plyCharge gPlayer (scrGetData gScreen 'currency) (scrGetCounter gScreen))
(scrShowPane gScreen "Default")
)
</Action>
<Action id="actionBack" cancel="1">
(scrExitScreen gScreen)
</Action>
</Actions>
</Default>
</Panes>
<Language>
<Text id="descDefault">
</Text>
<Text id="actionMillionCurrency">Add 1 [M]illion</Text>
<Text id="actionZeroCurrency">Set To [Z]ero</Text>
<Text id="actionAddCurrency">[A]dd Currency Amount</Text>
<Text id="actionSubtractCurrency">[S]ubtract Currency Amount</Text>
<Text id="actionBack">[B]ack</Text>
</Language>
</Dockscreen>