Example #1
0
/**
 * Initializes all the elements in the Prime Grenade window.
 * @param game Pointer to the core game.
 * @param action Pointer to the action.
 * @param inInventoryView Called from inventory?
 * @param grenadeInInventory Pointer to associated grenade.
 */
PrimeGrenadeState::PrimeGrenadeState(BattleAction *action, bool inInventoryView, BattleItem *grenadeInInventory) : _action(action), _inInventoryView(inInventoryView), _grenadeInInventory(grenadeInInventory)
{
	_screen = false;

	// Create objects
	_title = new Text(192, 24, 65, 44);
	_frame = new Frame(192, 27, 65, 37);
	_bg = new Surface(192, 93, 65, 45);

	int x = 67;
	int y = 68;
	for (int i = 0; i < 24; ++i)
	{
		_button[i] = new InteractiveSurface(22, 22, x-1+((i%8)*24), y-4+((i/8)*25));
		_number[i] = new Text(20, 20, x+((i%8)*24), y-1+((i/8)*25));
	}

	// Set palette
	if (inInventoryView)
	{
		setPalette("PAL_BATTLESCAPE");
	}
	else
	{
		_game->getSavedGame()->getSavedBattle()->setPaletteByDepth(this);
	}

	Element *grenadeBackground = _game->getMod()->getInterface("battlescape")->getElement("grenadeBackground");

	// Set up objects
	add(_bg);
	_bg->drawRect(0, 0, _bg->getWidth(), _bg->getHeight(), grenadeBackground->color);

	add(_frame, "grenadeMenu", "battlescape");
	_frame->setThickness(3);
	_frame->setHighContrast(true);

	add(_title, "grenadeMenu", "battlescape");
	_title->setAlign(ALIGN_CENTER);
	_title->setBig();
	_title->setText(tr("STR_SET_TIMER"));
	_title->setHighContrast(true);

	for (int i = 0; i < 24; ++i)
	{
		SDL_Rect square;
		add(_button[i]);
		_button[i]->onMouseClick((ActionHandler)&PrimeGrenadeState::btnClick);
		square.x = 0;
		square.y = 0;
		square.w = _button[i]->getWidth();
		square.h = _button[i]->getHeight();
		_button[i]->drawRect(&square, grenadeBackground->border);
		square.x++;
		square.y++;
		square.w -= 2;
		square.h -= 2;
		_button[i]->drawRect(&square, grenadeBackground->color2);

		std::wostringstream ss;
		ss << i;
		add(_number[i], "grenadeMenu", "battlescape");
		_number[i]->setBig();
		_number[i]->setText(ss.str());
		_number[i]->setHighContrast(true);
		_number[i]->setAlign(ALIGN_CENTER);
		_number[i]->setVerticalAlign(ALIGN_MIDDLE);
	}

	centerAllSurfaces();
	lowerAllSurfaces();
}
Example #2
0
/**
 * Initializes all the elements in the Prime Grenade window.
 * @param game Pointer to the core game.
 * @param action Pointer to the action.
 * @param inInventoryView Called from inventory?
 * @param grenadeInInventory Pointer to associated grenade.
 */
PrimeGrenadeState::PrimeGrenadeState(Game *game, BattleAction *action, bool inInventoryView, BattleItem *grenadeInInventory) : State(game), _action(action), _inInventoryView(inInventoryView), _grenadeInInventory(grenadeInInventory)
{
	_screen = false;

	// Create objects
	_title = new Text(192, 24, 65, 44);
	_frame = new Frame(192, 27, 65, 37);
	_bg = new Surface(192, 93, 65, 45);

	int x = 67;
	int y = 68;
	for (int i = 0; i < 24; ++i)
	{
		_button[i] = new InteractiveSurface(22, 22, x-1+((i%8)*24), y-4+((i/8)*25));
		_number[i] = new Text(20, 20, x+((i%8)*24), y-1+((i/8)*25));
	}

	// Set palette
	setPalette("PAL_BATTLESCAPE");

	// Set up objects
	SDL_Rect square;
	square.x = 0;
	square.y = 0;
	square.w = _bg->getWidth();
	square.h = _bg->getHeight();
	add(_bg);
	_bg->drawRect(&square, Palette::blockOffset(6)+9);

	add(_frame);
	_frame->setColor(Palette::blockOffset(6)+3);
	_frame->setBackground(Palette::blockOffset(6)+12);
	_frame->setThickness(3);
	_frame->setHighContrast(true);

	add(_title);
	_title->setAlign(ALIGN_CENTER);
	_title->setBig();
	_title->setText(tr("STR_SET_TIMER"));
	_title->setColor(Palette::blockOffset(1)-1);
	_title->setHighContrast(true);

	for (int i = 0; i < 24; ++i)
	{
		add(_button[i]);
		_button[i]->onMouseClick((ActionHandler)&PrimeGrenadeState::btnClick);
		square.x = 0;
		square.y = 0;
		square.w = _button[i]->getWidth();
		square.h = _button[i]->getHeight();
		_button[i]->drawRect(&square, Palette::blockOffset(0)+15);
		square.x = 1;
		square.y = 1;
		square.w = _button[i]->getWidth()-2;
		square.h = _button[i]->getHeight()-2;
		_button[i]->drawRect(&square, Palette::blockOffset(6)+12);

		std::wostringstream ss;
		ss << i;
		add(_number[i]);
		_number[i]->setBig();
		_number[i]->setText(ss.str());
		_number[i]->setColor(Palette::blockOffset(1)-1);
		_number[i]->setHighContrast(true);
		_number[i]->setAlign(ALIGN_CENTER);
		_number[i]->setVerticalAlign(ALIGN_MIDDLE);
	}

	centerAllSurfaces();
	lowerAllSurfaces();
}