コード例 #1
0
ファイル: CComponent.cpp プロジェクト: argarak/vcmi
CSelectableComponent::CSelectableComponent(Etype Type, int Sub, int Val, ESize imageSize, std::function<void()> OnSelect):
	CComponent(Type,Sub,Val, imageSize),onSelect(OnSelect)
{
	type |= REDRAW_PARENT;
	addUsedEvents(LCLICK | KEYBOARD);
	init();
}
コード例 #2
0
ファイル: Buttons.cpp プロジェクト: COJIDAT/vcmi-ios
CButton::CButton(Point position, const std::string &defName, const std::pair<std::string, std::string> &help, CFunctionList<void()> Callback, int key, bool playerColoredButton):
    CKeyShortcut(key),
    callback(Callback)
{
	addUsedEvents(LCLICK | RCLICK | HOVER | KEYBOARD);

	stateToIndex[0] = 0;
	stateToIndex[1] = 1;
	stateToIndex[2] = 2;
	stateToIndex[3] = 3;

	state=NORMAL;
	image = nullptr;
	overlay = nullptr;

	currentImage = -1;
	hoverable = actOnDown = soundDisabled = false;
	hoverTexts[0] = help.first;
	helpBox=help.second;

	pos.x += position.x;
	pos.y += position.y;

	if (!defName.empty())
	{
		imageNames.push_back(defName);
		setIndex(0, playerColoredButton);
	}
}
コード例 #3
0
ファイル: CComponent.cpp プロジェクト: argarak/vcmi
CComponent::CComponent(Etype Type, int Subtype, int Val, ESize imageSize):
	image(nullptr),
	perDay(false)
{
	addUsedEvents(RCLICK);
	init(Type, Subtype, Val, imageSize);
}
コード例 #4
0
ファイル: CComponent.cpp プロジェクト: argarak/vcmi
CSelectableComponent::CSelectableComponent(const Component &c, std::function<void()> OnSelect):
	CComponent(c),onSelect(OnSelect)
{
	type |= REDRAW_PARENT;
	addUsedEvents(LCLICK | KEYBOARD);
	init();
}
コード例 #5
0
ファイル: CComponent.cpp プロジェクト: argarak/vcmi
CComponent::CComponent(const Component &c, ESize imageSize):
	image(nullptr),
	perDay(false)
{
	addUsedEvents(RCLICK);

	if(c.id == Component::RESOURCE && c.when==-1)
		perDay = true;

	init((Etype)c.id,c.subtype,c.val, imageSize);
}
コード例 #6
0
CTextInput::CTextInput( const Rect &Pos, const Point &bgOffset, const std::string &bgName, const CFunctionList<void(const std::string &)> &CB )
:cb(CB)
{
	focus = false;
	pos += Pos;
	captureAllKeys = true;
	OBJ_CONSTRUCTION;
	bg = new CPicture(bgName, bgOffset.x, bgOffset.y);
	addUsedEvents(LCLICK | KEYBOARD);
	giveFocus();
}
コード例 #7
0
CHeroArea::CHeroArea(int x, int y, const CGHeroInstance * _hero):hero(_hero)
{
	OBJ_CONSTRUCTION_CAPTURING_ALL;

	addUsedEvents(LCLICK | RCLICK | HOVER);
	pos.x += x;	pos.w = 58;
	pos.y += y;	pos.h = 64;

	if (hero)
		new CAnimImage("PortraitsLarge", hero->portrait);
}
コード例 #8
0
CTextInput::CTextInput(const Rect &Pos, EFonts font, const CFunctionList<void(const std::string &)> &CB):
    CLabel(Pos.x, Pos.y, font, CENTER),
    cb(CB)
{
	type |= REDRAW_PARENT;
	focus = false;
	pos.h = Pos.h;
	pos.w = Pos.w;
	textOffset = Point(pos.w/2, pos.h/2);
	captureAllKeys = true;
	bg = nullptr;
	addUsedEvents(LCLICK | KEYBOARD);
	giveFocus();
}
コード例 #9
0
CTextInput::CTextInput(const Rect &Pos, SDL_Surface *srf)
{
	focus = false;
	pos += Pos;
	captureAllKeys = true;
	OBJ_CONSTRUCTION;
	bg = new CPicture(Pos, 0, true);
	Rect hlp = Pos;
	if(srf)
		CSDL_Ext::blitSurface(srf, &hlp, *bg, NULL);
	else
		SDL_FillRect(*bg, NULL, 0);
	pos.w = bg->pos.w;
	pos.h = bg->pos.h;
	bg->pos = pos;
	addUsedEvents(LCLICK | KEYBOARD);
	giveFocus();
}
コード例 #10
0
void CAdventureMapButton::init(const CFunctionList<void()> &Callback, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, int key)
{
	currentImage = -1;
	addUsedEvents(LCLICK | RCLICK | HOVER | KEYBOARD);
	callback = Callback;
	hoverable = actOnDown = borderEnabled = soundDisabled = false;
	borderColor.unused = 1; // represents a transparent color, used for HighlightableButton
	hoverTexts = Name;
	helpBox=HelpBox;

	if (key != SDLK_UNKNOWN)
		assignedKeys.insert(key);

	pos.x += x;
	pos.y += y;

	if (!defName.empty())
		imageNames.push_back(defName);
	if (add)
		for (size_t i=0; i<add->size();i++ )
			imageNames.push_back(add->at(i));
	setIndex(0, playerColoredButton);
}
コード例 #11
0
CBattleHero::CBattleHero(const std::string & defName, bool flipG, PlayerColor player, const CGHeroInstance * hero, const CBattleInterface * owner):
    flip(flipG),
    myHero(hero),
    myOwner(owner),
    phase(1),
    nextPhase(0),
    flagAnim(0),
    animCount(0)
{
	dh = CDefHandler::giveDef( defName );
	for(size_t i = 0; i < dh->ourImages.size(); ++i) //transforming images
	{
		if(flip)
		{
			SDL_Surface * hlp = CSDL_Ext::rotate01(dh->ourImages[i].bitmap);
			SDL_FreeSurface(dh->ourImages[i].bitmap);
			dh->ourImages[i].bitmap = hlp;
		}
		CSDL_Ext::alphaTransform(dh->ourImages[i].bitmap);
	}

	if(flip)
		flag = CDefHandler::giveDef("CMFLAGR.DEF");
	else
		flag = CDefHandler::giveDef("CMFLAGL.DEF");

	//coloring flag and adding transparency
	for(size_t i = 0; i < flag->ourImages.size(); ++i)
	{
		CSDL_Ext::alphaTransform(flag->ourImages[i].bitmap);
		graphics->blueToPlayersAdv(flag->ourImages[i].bitmap, player);
	}
	addUsedEvents(LCLICK);

	switchToNextPhase();
}
コード例 #12
0
CClickableHex::CClickableHex() : setAlterText(false), myNumber(-1), accessible(true), hovered(false), strictHovered(false), myInterface(NULL)
{
	addUsedEvents(LCLICK | RCLICK | HOVER | MOVE);
}
コード例 #13
0
ファイル: Buttons.cpp プロジェクト: COJIDAT/vcmi-ios
CSlider::CSlider(Point position, int totalw, std::function<void(int)> Moved, int Capacity, int Amount, int Value, bool Horizontal, CSlider::EStyle style):
    capacity(Capacity),
    horizontal(Horizontal),
    amount(Amount),
    value(Value),
    scrollStep(1),
    moved(Moved)
{
	OBJ_CONSTRUCTION_CAPTURING_ALL;
	setAmount(amount);
	vstd::amax(value, 0);
	vstd::amin(value, positions);

	addUsedEvents(LCLICK | KEYBOARD | WHEEL);
	strongInterest = true;

	pos.x += position.x;
	pos.y += position.y;

	if(style == BROWN)
	{
		std::string name = horizontal?"IGPCRDIV.DEF":"OVBUTN2.DEF";
		//NOTE: this images do not have "blocked" frames. They should be implemented somehow (e.g. palette transform or something...)

		left =   new CButton(Point(), name, CButton::tooltip());
		right =  new CButton(Point(), name, CButton::tooltip());
		slider = new CButton(Point(), name, CButton::tooltip());

		left->setImageOrder(0, 1, 1, 1);
		right->setImageOrder(2, 3, 3, 3);
		slider->setImageOrder(4, 4, 4, 4);
	}
	else
	{
		left = new CButton(Point(), horizontal ? "SCNRBLF.DEF" : "SCNRBUP.DEF", CButton::tooltip());
		right = new CButton(Point(), horizontal ? "SCNRBRT.DEF" : "SCNRBDN.DEF", CButton::tooltip());
		slider = new CButton(Point(), "SCNRBSL.DEF", CButton::tooltip());
	}
	slider->actOnDown = true;
	slider->soundDisabled = true;
	left->soundDisabled = true;
	right->soundDisabled = true;

	if (horizontal)
		right->moveBy(Point(totalw - right->pos.w, 0));
	else
		right->moveBy(Point(0, totalw - right->pos.h));

	left->addCallback(std::bind(&CSlider::moveLeft,this));
	right->addCallback(std::bind(&CSlider::moveRight,this));
	slider->addCallback(std::bind(&CSlider::sliderClicked,this));

	if(horizontal)
	{
		pos.h = slider->pos.h;
		pos.w = totalw;
	}
	else
	{
		pos.w = slider->pos.w;
		pos.h = totalw;
	}

	updateSliderPos();
}
コード例 #14
0
ファイル: Buttons.cpp プロジェクト: COJIDAT/vcmi-ios
void CSlider::sliderClicked()
{
	if(!(active & MOVE))
		addUsedEvents(MOVE);
}
コード例 #15
0
ファイル: InfoWindows.cpp プロジェクト: COJIDAT/vcmi-ios
CRClickPopup::CRClickPopup()
{
	addUsedEvents(RCLICK);
}
コード例 #16
0
ファイル: CQuestLog.cpp プロジェクト: andrew889/vcmi
CQuestIcon::CQuestIcon (const std::string &defname, int index, int x, int y) :
	CAnimImage(defname, index, 0, x, y)
{
	addUsedEvents(LCLICK);
}
コード例 #17
0
CHoverableArea::CHoverableArea()
{
	addUsedEvents(HOVER);
}
コード例 #18
0
CAdventureMapButton::CAdventureMapButton ()
{
	hoverable = actOnDown = borderEnabled = soundDisabled = false;
	borderColor.unused = 1; // represents a transparent color, used for HighlightableButton
	addUsedEvents(LCLICK | RCLICK | HOVER | KEYBOARD);
}
コード例 #19
0
void LRClickableAreaWText::init()
{
	addUsedEvents(LCLICK | RCLICK | HOVER);
}
コード例 #20
0
CSlider::CSlider(int x, int y, int totalw, boost::function<void(int)> Moved, int Capacity, int Amount, int Value, bool Horizontal, int style)
:capacity(Capacity),amount(Amount),horizontal(Horizontal), moved(Moved)
{
	OBJ_CONSTRUCTION_CAPTURING_ALL;
	setAmount(amount);

	addUsedEvents(LCLICK | KEYBOARD | WHEEL);
	strongInterest = true;


	left = new CAdventureMapButton();
	right = new CAdventureMapButton();
	slider = new CAdventureMapButton();

	pos.x += x;
	pos.y += y;

	if(horizontal)
	{
		left->pos.y = slider->pos.y = right->pos.y = pos.y;
		left->pos.x = pos.x;
		right->pos.x = pos.x + totalw - 16;
	}
	else
	{
		left->pos.x = slider->pos.x = right->pos.x = pos.x;
		left->pos.y = pos.y;
		right->pos.y = pos.y + totalw - 16;
	}

	left->callback = boost::bind(&CSlider::moveLeft,this);
	right->callback = boost::bind(&CSlider::moveRight,this);
	slider->callback = boost::bind(&CSlider::sliderClicked,this);
	left->pos.w = left->pos.h = right->pos.w = right->pos.h = slider->pos.w = slider->pos.h = 16;
	if(horizontal)
	{
		pos.h = 16;
		pos.w = totalw;
	}
	else
	{
		pos.w = 16;
		pos.h = totalw;
	}

	if(style == 0)
	{
		std::string name = horizontal?"IGPCRDIV.DEF":"OVBUTN2.DEF";
		//NOTE: this images do not have "blocked" frames. They should be implemented somehow (e.g. palette transform or something...)

		//use source def to create custom animations. Format "name.def:123" will load this frame from def file
		CAnimation *animLeft = new CAnimation();
		animLeft->setCustom(name + ":0", 0);
		animLeft->setCustom(name + ":1", 1);
		left->setImage(animLeft);

		CAnimation *animRight = new CAnimation();
		animRight->setCustom(name + ":2", 0);
		animRight->setCustom(name + ":3", 1);
		right->setImage(animRight);

		CAnimation *animSlider = new CAnimation();
		animSlider->setCustom(name + ":4", 0);
		slider->setImage(animSlider);
	}
	else
	{
		left->setImage(new CAnimation(horizontal ? "SCNRBLF.DEF" : "SCNRBUP.DEF"));
		right->setImage(new CAnimation(horizontal ? "SCNRBRT.DEF" : "SCNRBDN.DEF"));
		slider->setImage(new CAnimation("SCNRBSL.DEF"));
	}
	slider->actOnDown = true;
	slider->soundDisabled = true;
	left->soundDisabled = true;
	right->soundDisabled = true;

	value = -1;
	moveTo(Value);
}