* Initializes all the elements in the Sell/Sack screen. * @param game Pointer to the core game. * @param base Pointer to the base to get info from. * @param origin Game section that originated this state. */
| 56 | * @param origin Game section that originated this state. |
| 57 | */ |
| 58 | SellState::SellState(Game *game, Base *base, OptionsOrigin origin) : State(game), _base(base), _qtys(), _soldiers(), _crafts(), _items(), _sel(0), _itemOffset(0), _total(0), _hasSci(0), _hasEng(0), _spaceChange(0), _origin(origin) |
| 59 | { |
| 60 | bool overfull = Options::storageLimitsEnforced && _base->storesOverfull(); |
| 61 | |
| 62 | // Create objects |
| 63 | _window = new Window(this, 320, 200, 0, 0); |
| 64 | _btnOk = new TextButton(overfull? 288:148, 16, overfull? 16:8, 176); |
| 65 | _btnCancel = new TextButton(148, 16, 164, 176); |
| 66 | _txtTitle = new Text(310, 17, 5, 8); |
| 67 | _txtSales = new Text(150, 9, 10, 24); |
| 68 | _txtFunds = new Text(150, 9, 160, 24); |
| 69 | _txtSpaceUsed = new Text(150, 9, 160, 34); |
| 70 | _txtItem = new Text(130, 9, 10, Options::storageLimitsEnforced? 44:33); |
| 71 | _txtQuantity = new Text(54, 9, 126, Options::storageLimitsEnforced? 44:33); |
| 72 | _txtSell = new Text(96, 9, 180, Options::storageLimitsEnforced? 44:33); |
| 73 | _txtValue = new Text(40, 9, 260, Options::storageLimitsEnforced? 44:33); |
| 74 | _lstItems = new TextList(287, Options::storageLimitsEnforced? 112:120, 8, Options::storageLimitsEnforced? 55:44); |
| 75 | |
| 76 | // Set palette |
| 77 | if (origin == OPT_BATTLESCAPE) |
| 78 | { |
| 79 | setPalette("PAL_GEOSCAPE", 0); |
| 80 | _color = Palette::blockOffset(15)-1; |
| 81 | _color2 = Palette::blockOffset(8)+10; |
| 82 | _color3 = Palette::blockOffset(8)+5; |
| 83 | _colorAmmo = Palette::blockOffset(15)+6; |
| 84 | } |
| 85 | else |
| 86 | { |
| 87 | setPalette("PAL_BASESCAPE", 0); |
| 88 | _color = Palette::blockOffset(13)+10; |
| 89 | _color2 = Palette::blockOffset(13); |
| 90 | _color3 = Palette::blockOffset(13)+5; |
| 91 | _colorAmmo = Palette::blockOffset(15)+6; |
| 92 | } |
| 93 | |
| 94 | add(_window); |
| 95 | add(_btnOk); |
| 96 | add(_btnCancel); |
| 97 | add(_txtTitle); |
| 98 | add(_txtSales); |
| 99 | add(_txtFunds); |
| 100 | add(_txtSpaceUsed); |
| 101 | add(_txtItem); |
| 102 | add(_txtQuantity); |
| 103 | add(_txtSell); |
| 104 | add(_txtValue); |
| 105 | add(_lstItems); |
| 106 | |
| 107 | centerAllSurfaces(); |
| 108 | |
| 109 | // Set up objects |
| 110 | _window->setColor(_color); |
| 111 | _window->setBackground(_game->getResourcePack()->getSurface("BACK13.SCR")); |
| 112 | |
| 113 | _btnOk->setColor(_color); |
| 114 | _btnOk->setText(tr("STR_SELL_SACK")); |
| 115 | _btnOk->onMouseClick((ActionHandler)&SellState::btnOkClick); |
nothing calls this directly
no test coverage detected