MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / PurchaseState

Method PurchaseState

src/Basescape/PurchaseState.cpp:57–209  ·  view source on GitHub ↗

* Initializes all the elements in the Purchase/Hire screen. * @param game Pointer to the core game. * @param base Pointer to the base to get info from. */

Source from the content-addressed store, hash-verified

55 * @param base Pointer to the base to get info from.
56 */
57PurchaseState::PurchaseState(Game *game, Base *base) : State(game), _base(base), _crafts(), _items(), _qtys(), _sel(0), _itemOffset(0), _total(0), _pQty(0), _cQty(0), _iQty(0.0)
58{
59 // Create objects
60 _window = new Window(this, 320, 200, 0, 0);
61 _btnOk = new TextButton(148, 16, 8, 176);
62 _btnCancel = new TextButton(148, 16, 164, 176);
63 _txtTitle = new Text(310, 17, 5, 8);
64 _txtFunds = new Text(150, 9, 10, 24);
65 _txtPurchases = new Text(150, 9, 160, 24);
66 _txtSpaceUsed = new Text(150, 9, 160, 34);
67 _txtItem = new Text(140, 9, 10, Options::storageLimitsEnforced? 44:33);
68 _txtCost = new Text(102, 9, 152, Options::storageLimitsEnforced? 44:33);
69 _txtQuantity = new Text(60, 9, 256, Options::storageLimitsEnforced? 44:33);
70 _lstItems = new TextList(287, Options::storageLimitsEnforced? 112:120, 8, Options::storageLimitsEnforced? 55:44);
71
72 // Set palette
73 setPalette("PAL_BASESCAPE", 0);
74
75 add(_window);
76 add(_btnOk);
77 add(_btnCancel);
78 add(_txtTitle);
79 add(_txtFunds);
80 add(_txtPurchases);
81 add(_txtSpaceUsed);
82 add(_txtItem);
83 add(_txtCost);
84 add(_txtQuantity);
85 add(_lstItems);
86
87 centerAllSurfaces();
88
89 // Set up objects
90 _window->setColor(Palette::blockOffset(13)+10);
91 _window->setBackground(_game->getResourcePack()->getSurface("BACK13.SCR"));
92
93 _btnOk->setColor(Palette::blockOffset(13)+10);
94 _btnOk->setText(tr("STR_OK"));
95 _btnOk->onMouseClick((ActionHandler)&PurchaseState::btnOkClick);
96 _btnOk->onKeyboardPress((ActionHandler)&PurchaseState::btnOkClick, Options::keyOk);
97
98 _btnCancel->setColor(Palette::blockOffset(13)+10);
99 _btnCancel->setText(tr("STR_CANCEL"));
100 _btnCancel->onMouseClick((ActionHandler)&PurchaseState::btnCancelClick);
101 _btnCancel->onKeyboardPress((ActionHandler)&PurchaseState::btnCancelClick, Options::keyCancel);
102
103 _txtTitle->setColor(Palette::blockOffset(13)+10);
104 _txtTitle->setBig();
105 _txtTitle->setAlign(ALIGN_CENTER);
106 _txtTitle->setText(tr("STR_PURCHASE_HIRE_PERSONNEL"));
107
108 _txtFunds->setColor(Palette::blockOffset(13)+10);
109 _txtFunds->setSecondaryColor(Palette::blockOffset(13));
110 _txtFunds->setText(tr("STR_CURRENT_FUNDS").arg(Text::formatFunding(_game->getSavedGame()->getFunds())));
111
112 _txtPurchases->setColor(Palette::blockOffset(13)+10);
113 _txtPurchases->setSecondaryColor(Palette::blockOffset(13));
114 _txtPurchases->setText(tr("STR_COST_OF_PURCHASES").arg(Text::formatFunding(_total)));

Callers

nothing calls this directly

Calls 15

onMouseClickMethod · 0.80
onKeyboardPressMethod · 0.80
getFundsMethod · 0.80
getSavedGameMethod · 0.80
getUsedStoresMethod · 0.80
getAvailableStoresMethod · 0.80
setArrowColumnMethod · 0.80
setColumnsMethod · 0.80
setMarginMethod · 0.80
onLeftArrowPressMethod · 0.80
onLeftArrowReleaseMethod · 0.80
onLeftArrowClickMethod · 0.80

Tested by

no test coverage detected