Ejemplo n.º 1
0
void Map::GetMapSize(std::string str)
{
	std::vector<std::string> parts = GetParts(str, ',');
	if (parts.size() != 2)
		return;

	map_size_x = atoi(parts[0].c_str());
	map_size_y = atoi(parts[1].c_str());
}
Ejemplo n.º 2
0
PartsCounter *MenuWindow::GetPartsCounter( const std::string &partsStr )
{
	MenuParts *pParts = GetParts( partsStr );
	if( pParts ){
		return dynamic_cast<PartsCounter*>(pParts);
	}

	DEBUG_ASSERT( 0, "指定されたMenuパーツは見つかりませんでした\n");
	return NULL;
}
Ejemplo n.º 3
0
int CMuleStatusBarCtrl::GetPaneAtPosition(CPoint& point) const
{
	CRect rect;
	int nParts = GetParts(0, NULL);
	for (int i = 0; i < nParts; i++)
	{
		GetRect(i, rect);
		if (rect.PtInRect(point))
			return i;
	}
	return -1;
}
Ejemplo n.º 4
0
void CMeterBar::OnSize(UINT nType, int cx, int cy)
{
	CStatusBarCtrl::OnSize(nType, cx, cy);

	// TODO: 在此处添加消息处理程序代码
	int nTemp;
	int nCount = GetParts(0, &nTemp);
	if (nCount > 0) {
		CRect r;
		GetRect(nCount - 1, r);
		m_meter.MoveWindow(r);
	}
}
Ejemplo n.º 5
0
int CAht::BuildPartsSub( int id, char *fname )
{
    //		簡易ahtパース
    //
    int i,res,maxline;
    CStrNote note;
    CMemBuf tmp;
    AHTPARTS *p;
    char s1[256];
    
    p = GetParts( id );
    if ( p == NULL ) return -2;
    
    p->classname[0] = 0;
    p->name[0] = 0;
    p->icon = 0;
    
    res = tmp.PutFile( fname );
    if ( res < 0 ) {
        return -1;
    }
    note.Select( tmp.GetBuffer() );
    maxline = note.GetMaxLine();
    getpath( fname, p->name, 1+8+16 );			// 仮にファイル名を入れておく
    
    for(i=0;i<maxline;i++) {
        pickptr = 0;
        note.GetLine( linebuf, i, 255 );
        PickLineBuffer( s1 );
        if ( tstrcmp( s1,"#aht" ) ) {
            PickLineBuffer( s1 );
            if ( tstrcmp( s1,"iconid" ) ) {
                PickLineBuffer( s1 );
                p->icon = atoi( s1 );
            }
            if ( tstrcmp( s1,"name" ) ) {
                PickLineBuffer( s1 );
                strcpy( p->name, s1 );
            }
            if ( tstrcmp( s1,"class" ) ) {
                PickLineBuffer( s1 );
                strcpy( p->classname, s1 );
            }
        }
    }
    
    return 0;
}
Ejemplo n.º 6
0
bool Map::LoadFromFile(std::string fileName)
{
	std::ifstream fs;
	fs.open(fileName.c_str(), std::ifstream::in);

	if (fs.fail())
		return false;

	int i = 0;
	while (!fs.eof())
	{
		std::string curLine;
		getline(fs, curLine);

		if (curLine == "" || curLine.find("//") != std::string::npos)
			continue;

		// Line #1
		if (i == 0) 
		{
			// The first line should be the file size.
			GetMapSize(curLine);
			InitArray(map_size_x, map_size_y);
			if (mapTiles == NULL)
			{
				std::cout << "Could not load map file: Error reading map size." << '\n';
				return false;
			}
			i++;
		}

		std::vector<std::string> parts = GetParts(curLine, ' ');

		if (parts[0] == "define")
		{
			ParseDefine(parts);
		}
		else if (parts[0] == "set")
		{
			ParseSet(parts);
		}
	}

	fs.close();

	return true;
}
Ejemplo n.º 7
0
int CAht::GetPartsIconID( int id )
{
    return GetParts(id)->icon;
}
Ejemplo n.º 8
0
char *CAht::GetPartsClassName( int id )
{
    return GetParts(id)->classname;
}
Ejemplo n.º 9
0
char *CAht::GetPartsName( int id )
{
    return GetParts(id)->name;
}
Ejemplo n.º 10
0
CRangeCollection<TSeqPos> CSpliced_exon::GetRowSeq_insertions(
    CSeq_align::TDim    row,
    const CSpliced_seg& seg,
    const CRangeCollection<TSeqPos> &within_product_ranges) const
{
    vector<ENa_strand> strand(2, eNa_strand_unknown);
    if (IsSetProduct_strand()) {
        strand[0] = GetProduct_strand();
    } else if (seg.IsSetProduct_strand()) {
        strand[0] = seg.GetProduct_strand();
    }
    if (IsSetGenomic_strand()) {
        strand[1] = GetGenomic_strand();
    } else if (seg.IsSetGenomic_strand()) {
        strand[1] = seg.GetGenomic_strand();
    }

    vector<int> direction;
    direction.push_back(strand[0] == eNa_strand_minus ? -1 : 1);
    direction.push_back(strand[1] == eNa_strand_minus ? -1 : 1);

    vector<TSeqPos> pos;
    pos.push_back(strand[0] == eNa_strand_minus
        ? GetRowSeq_range(0,true).GetTo() : GetRowSeq_range(0,true).GetFrom());
    pos.push_back(strand[1] == eNa_strand_minus
        ? GetRowSeq_range(1,true).GetTo() : GetRowSeq_range(1,true).GetFrom());

    CRangeCollection<TSeqPos> insertions;
    if (IsSetParts()) {
        ITERATE (TParts, it, GetParts()) {
            const CSpliced_exon_chunk& chunk = **it;
            switch (chunk.Which()) {
            case CSpliced_exon_chunk::e_Match:
                pos[0] += chunk.GetMatch() * direction[0];
                pos[1] += chunk.GetMatch() * direction[1];
                break;
    
            case CSpliced_exon_chunk::e_Mismatch:
                pos[0] += chunk.GetMismatch() * direction[0];
                pos[1] += chunk.GetMismatch() * direction[1];
                break;
    
            case CSpliced_exon_chunk::e_Diag:
                pos[0] += chunk.GetDiag() * direction[0];
                pos[1] += chunk.GetDiag() * direction[1];
                break;
    
            case CSpliced_exon_chunk::e_Product_ins:
                if (row == 0) {
                    if (strand[0] == eNa_strand_minus) {
                        insertions += TSeqRange(pos[0] - chunk.GetProduct_ins() + 1,
                                          pos[0]);
                    } else {
                        insertions += TSeqRange(pos[0],
                                          pos[0] + chunk.GetProduct_ins() - 1);
                    }
                }
                pos[0] += chunk.GetProduct_ins() * direction[0];
                break;
    
            case CSpliced_exon_chunk::e_Genomic_ins:
                /// Add genomic insertion if the current position on the product is within the range
                if (row == 1 && within_product_ranges.IntersectingWith(
                                    TSeqRange(pos[0], pos[0])))
                {
                    if (strand[1] == eNa_strand_minus) {
                        insertions += TSeqRange(pos[1] - chunk.GetGenomic_ins() + 1,
                                          pos[1]);
                    } else {
                        insertions += TSeqRange(pos[1],
                                          pos[1] + chunk.GetGenomic_ins() - 1);
                    }
                }
                pos[1] += chunk.GetGenomic_ins() * direction[1];
                break;
    
            default:
                break;
            }
        }
    }
    if (row == 0) {
        insertions &= within_product_ranges;
    }
    return insertions;
}
Ejemplo n.º 11
0
AString cCompositeChat::CreateJsonString(bool a_ShouldUseChatPrefixes) const
{
	Json::Value msg;
	msg["text"] = cClientHandle::FormatMessageType(a_ShouldUseChatPrefixes, GetMessageType(), GetAdditionalMessageTypeData());  // The client crashes without this field being present
	const cCompositeChat::cParts & Parts = GetParts();
	for (cCompositeChat::cParts::const_iterator itr = Parts.begin(), end = Parts.end(); itr != end; ++itr)
	{
		Json::Value Part;
		switch ((*itr)->m_PartType)
		{
			case cCompositeChat::ptText:
			{
				Part["text"] = (*itr)->m_Text;
				AddChatPartStyle(Part, (*itr)->m_Style);
				break;
			}

			case cCompositeChat::ptClientTranslated:
			{
				const cCompositeChat::cClientTranslatedPart & p = static_cast<const cCompositeChat::cClientTranslatedPart &>(**itr);
				Part["translate"] = p.m_Text;
				Json::Value With;
				for (AStringVector::const_iterator itrW = p.m_Parameters.begin(), endW = p.m_Parameters.end(); itrW != endW; ++itr)
				{
					With.append(*itrW);
				}
				if (!p.m_Parameters.empty())
				{
					Part["with"] = With;
				}
				AddChatPartStyle(Part, p.m_Style);
				break;
			}

			case cCompositeChat::ptUrl:
			{
				const cCompositeChat::cUrlPart & p = static_cast<const cCompositeChat::cUrlPart &>(**itr);
				Part["text"] = p.m_Text;
				Json::Value Url;
				Url["action"] = "open_url";
				Url["value"] = p.m_Url;
				Part["clickEvent"] = Url;
				AddChatPartStyle(Part, p.m_Style);
				break;
			}

			case cCompositeChat::ptSuggestCommand:
			case cCompositeChat::ptRunCommand:
			{
				const cCompositeChat::cCommandPart & p = static_cast<const cCompositeChat::cCommandPart &>(**itr);
				Part["text"] = p.m_Text;
				Json::Value Cmd;
				Cmd["action"] = (p.m_PartType == cCompositeChat::ptRunCommand) ? "run_command" : "suggest_command";
				Cmd["value"] = p.m_Command;
				Part["clickEvent"] = Cmd;
				AddChatPartStyle(Part, p.m_Style);
				break;
			}

			case cCompositeChat::ptShowAchievement:
			{
				const cCompositeChat::cShowAchievementPart & p = static_cast<const cCompositeChat::cShowAchievementPart &>(**itr);
				Part["translate"] = "chat.type.achievement";

				Json::Value Ach;
				Ach["action"] = "show_achievement";
				Ach["value"] = p.m_Text;

				Json::Value AchColourAndName;
				AchColourAndName["color"] = "green";
				AchColourAndName["translate"] = p.m_Text;
				AchColourAndName["hoverEvent"] = Ach;

				Json::Value Extra;
				Extra.append(AchColourAndName);

				Json::Value Name;
				Name["text"] = p.m_PlayerName;

				Json::Value With;
				With.append(Name);
				With.append(Extra);

				Part["with"] = With;
				AddChatPartStyle(Part, p.m_Style);
				break;
			}
		}
		msg["extra"].append(Part);
	}  // for itr - Parts[]

	return msg.toStyledString();
}