Esempio n. 1
0
int SkipPastCloseNode( const char *&xml, const char *tag ){
	CharBuf sub_tag;
	int r, r1;
	while( true ){
		r = AcceptText( xml, sub_tag, true );
		r = AcceptOpenTag( xml, sub_tag );
		r1 = SkipPastCloseToken(xml);
		if( sub_tag==tag )
			return r==1 && r1>=0 ? 0 : (r?-11:-20);
		if( r || r1<0 ) return r<0 || r1<0 ? -12 : -21;
		// We have an open tag to be closed. Call recursively
		r = SkipPastCloseNode(xml,sub_tag);
		if( r ) return r;
	}
}
Esempio n. 2
0
// dropping between elements (inserts between)
void XMLBarEditor::dropInsertCb(int parent, int ii, PasteClip& d)
{
	barTree.AdjustAction(parent, d);
	if(AcceptInternal<TreeCtrl>(d, "mytreedrag"))
	{
		barTree.InsertDrop(parent, ii, d);
		barTree.SetFocus();
		return;
	}
	if(AcceptText(d))
	{
		barTree.SetCursor(barTree.Insert(parent, ii, Image(), GetString(d)));
		barTree.SetFocus();
		return;
	}
}
Esempio n. 3
0
void LineEdit::DragAndDrop(Point p, PasteClip& d)
{
	if(IsReadOnly()) return;
	int c = GetMousePos(p);
	if(AcceptText(d)) {
		NextUndo();
		int a = sb.y;
		int sell, selh;
		WString text = GetWString(d);
		if(GetSelection(sell, selh)) {
			if(c >= sell && c < selh) {
				if(!IsReadOnly())
					RemoveSelection();
				if(IsDragAndDropSource())
					d.SetAction(DND_COPY);
				c = sell;
			}
			else
			if(d.GetAction() == DND_MOVE && IsDragAndDropSource()) {
				if(c > sell)
					c -= selh - sell;
				if(!IsReadOnly())
					RemoveSelection();
				d.SetAction(DND_COPY);
			}
		}
		int count = Insert(c, text);
		sb.y = a;
		SetFocus();
		SetSelection(c, c + count);
		Action();
		return;
	}
	if(!d.IsAccepted()) return;
	if(!isdrag) {
		isdrag = true;
		ScrollIntoCursor();
	}
	Point dc = Null;
	if(c >= 0)
		dc = GetColumnLine(c);
	if(dc != dropcaret) {
		RefreshDropCaret();
		dropcaret = dc;
		RefreshDropCaret();
	}
}
Esempio n. 4
0
void DocEdit::DragAndDrop(Point p, PasteClip& d)
{
	if(IsReadOnly()) return;
	int c = GetMousePos(p);
	if(AcceptText(d)) {
		NextUndo();
		int a = sb;
		int sell, selh;
		WString txt = GetWString(d);
		if(GetSelection(sell, selh)) {
			if(c >= sell && c < selh) {
				if(!IsReadOnly())
					RemoveSelection();
				if(IsDragAndDropSource())
					d.SetAction(DND_COPY);
				c = sell;
			}
			else
			if(d.GetAction() == DND_MOVE && IsDragAndDropSource()) {
				if(c > sell)
					c -= selh - sell;
				if(!IsReadOnly())
					RemoveSelection();
				d.SetAction(DND_COPY);
			}
		}
		int count = Insert(c, txt);
		sb = a;
		SetFocus();
		SetSelection(c, c + count);
		Action();
		return;
	}
	if(!d.IsAccepted()) return;
	Point dc = Null;
	if(c >= 0) {
		Point cr = GetCaret(c);
		dc = Point(cr.x + 1, cr.y);
	}
	if(dc != dropcaret) {
		RefreshDropCaret();
		dropcaret = dc;
		RefreshDropCaret();
	}
}
Esempio n. 5
0
bool QuestEncounter::ReadQuestText(QuestGiver &QuestGiver)
{
    sf::Text QuestText(Quests[QuestIterator].Quest.Text, Font);
    QuestText.setPosition(40.0f, 40.0f);
    QuestText.setColor(sf::Color(0, 0, 0));
    QuestText.setStyle(sf::Text::Bold);
    sf::Text ObjectiveText
        (GetEnemyNameFromDatabase("World" + Quests[QuestIterator].Quest.Objective.Map, Quests[QuestIterator].Quest.Objective.ObjectiveID) + " " //TODO PH LOL KOJA INDIREKCIJA
        + IntToString(Quests[QuestIterator].Quest.Objective.CurrentProgress)
        + "/" + IntToString(Quests[QuestIterator].Quest.Objective.ReqProgress), Font),
        AcceptText(Quests[QuestIterator].From ? "Accept" : "Complete", Font),
        Decline(Quests[QuestIterator].From ? "Decline" : "Back", Font);
    AcceptText.setPosition(700.0f, 520.0f);
    ObjectiveText.setColor(sf::Color(0, 0, 0));
    Decline.setPosition(700.0f, 555.0f);
    AcceptText.setColor(sf::Color(0, 0, 0));
    Decline.setColor(sf::Color(0, 0, 0));
    ObjectiveText.setPosition(580.0f, 90.0f);
    ArrowSprite.setPosition(660.0f, 520.0f);

    bool Accept = false;
    while(Window.isOpen()) 
    {
        while(Window.pollEvent(Event))
        {
            if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Up))
            {
                if(Accept)
                {
                    Accept = false;
                    ArrowSprite.setPosition(660.0f, 520.0f);
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Down))
            {
                if(!Accept)
                {
                    Accept = true;
                    ArrowSprite.setPosition(660.0f, 555.0f);
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Return))
            {
                switch(Accept)
                {
                case false:
                    switch(Quests[QuestIterator].From)
                    {
                    case true:
                        player.AddQuest(Quests[QuestIterator].Quest);
                        Quests[QuestIterator].From = false;
                        for(auto itr = QuestGiver.Quests.begin(); itr != QuestGiver.Quests.end(); ++itr)
                        {
                            if(itr->ID == Quests[QuestIterator].Quest.ID)
                            {
                                QuestGiver.Quests.erase(itr);
                                return false;
                            }
                        }
                    case false:
                        if(Quests[QuestIterator].Quest.IsComplete())
                        {
                            player.AddCompletedQuest(Quests[QuestIterator].Quest.ID);
                            player.AddItem(GetItemFromDatabase("SavedGame", Quests[QuestIterator].Quest.ItemReward));
                            player.RemoveQuest(Quests[QuestIterator].Quest.ID);
                            if(Quests[QuestIterator].Quest.ID == 10)
                                Victory();
                            Quests.erase(Quests.begin() + QuestIterator);
                            player.SetWealth(player.GetWealth() + 20 * player.GetLevel());
                        }
                        if(Quests.empty())
                            return true;
                    }
                    break;
                case true:
                    return false;
                }
            }
            else if((Event.type == sf::Event::KeyPressed) && (Event.key.code == sf::Keyboard::Escape))
            {
                return false;
            }
        }
        Window.clear();
        Window.draw(GUISprite);
        Window.draw(ArrowSprite);
        Window.draw(AcceptText);
        Window.draw(Decline);
        Window.draw(ObjectiveText);
        Window.draw(QuestText);
        Window.display();
    }
    return false;
}