Screen* ScreenMgr::getScreen(ResourceID id){ uint32_t row = GetRow(id); uint32_t col = GetCol(id); if ( row-1 >=0 && col-1 >=0 && row -1 < getRowCount() && col -1 < getColCount()){ return screens_[GetRow(id)-1][GetCol(id)-1]; }else return 0; }
//--------------------------------------------------------------------- void __fastcall TColorSetDlg::PCClick(TObject *Sender) { int i, x, pos; pos = -1; for( i = 0; (i < 8) && (pos < 0); i++ ){ for(x = 0; x < 4; x++ ){ if( Sender == GetItem(i, x) ){ pos = i; break; } } } TColorDialog *pDialog = Mmsstv->ColorDialog; InitCustomColor(pDialog); TPanel *pPanel[4]; for( i = 0; i < 4; i++ ){ pPanel[i] = GetItem(pos, i); AddCustomColor(pDialog, pPanel[i]->Color); } pDialog->Color = ((TPanel *)Sender)->Color; SetDisPaint(); if( pDialog->Execute() == TRUE ){ ((TPanel *)Sender)->Color = pDialog->Color; if( (pPanel[0]->Color == pPanel[1]->Color) && (pPanel[2]->Color == pPanel[3]->Color) ){ if( YesNoMB( MsgEng ? "Change to two colors gradation?" : "2色のグラデーションに変更しますか?" ) == IDYES ){ pPanel[1]->Color = GetCol(pPanel[0]->Color, pPanel[3]->Color, 2, 4); pPanel[2]->Color = GetCol(pPanel[0]->Color, pPanel[3]->Color, 3, 4); } } } ResDisPaint(); }
void Screen::connInOutRequest(ResourceID inputid, ResourceID wnode){ if ( qbox_){ QboxDataMap value; value["out"] = QString::number(GetOutput(wnode) ).toStdString(); if ( GetCol(inputid) == GetCol(wnode) && GetRow(inputid) == GetRow(wnode)){ value["in"] = QString::number(GetInput(inputid) ).toStdString(); }else{ value["in"] = QString::number(GetInput(wnode) ).toStdString(); } qbox_->addAsyncRequest( PSetSwitchInputReq::uri , std::bind( ignoreCallback, std::placeholders::_1, std::placeholders::_2), value); } }
bool Screen::connInOutRequestCB(ResourceID inputid, ResourceID wnode, QboxCallback callback, uint32_t , QboxDataMap& v){ if ( qbox_){ QboxDataMap value; value["out"] = QString::number(GetOutput(wnode) ).toStdString(); if ( GetCol(inputid) == GetCol(wnode) && GetRow(inputid) == GetRow(wnode)){ value["in"] = QString::number(GetInput(inputid) ).toStdString(); }else{ value["in"] = QString::number(GetInput(wnode) ).toStdString(); } qbox_->addAsyncRequest( PSetSwitchInputReq::uri , callback, value); return true; } return false; }
bool ChessEngine::isValidMove(int sr, int sc, int er, int ec) { vector<int> moves; moveGenerator->GenerateAllMoves(moves); for (int i = 0; i < moves.size(); i++) { int move = moves[i]; int source = GetSourceFromMove(move); int dest = GetDestFromMove(move); if (sr == GetRow(source) && sc == GetCol(source) && er == GetRow(dest) && ec == GetCol(dest)) { return true; } } return false; }
string GetShortAlgebraicString(int move, const Board& board) { ostringstream moveStr; int source = board.GetPiece(GetSourceFromMove(move)); int dest = board.GetPiece(GetDestFromMove(move)); switch (Pieces::GetPieceTypeFromPiece(source)) { case PieceTypes::King: if(abs(GetSourceFromMove(move) - GetDestFromMove(move)) == 2) { if(GetCol(GetDestFromMove(move)) == 2) return "0-0-0"; else return "0-0"; } moveStr << "K"; break; case PieceTypes::Queen: moveStr << "Q"; break; case PieceTypes::Rook: moveStr << "R"; break; case PieceTypes::Bishop: moveStr << "B"; break; case PieceTypes::Knight: moveStr << "N"; break; } if (dest != Pieces::None) { if(Pieces::GetPieceTypeFromPiece(source) == PieceTypes::Pawn) { moveStr << (char)('a' + GetCol(GetSourceFromMove(move))); } moveStr << "x"; } moveStr << (char) ('a' + GetCol(GetDestFromMove(move))); moveStr << (char) ('1' + GetRow(GetDestFromMove(move))); if (GetPromoFromMove(move) != PieceTypes::None) { char promo = 'Q'; switch (GetPromoFromMove(move)) { case PieceTypes::Bishop: promo = 'b'; break; case PieceTypes::Knight: promo = 'n'; break; case PieceTypes::Queen: promo = 'q'; break; case PieceTypes::Rook: promo = 'r'; break; } moveStr << "=" << promo; } return moveStr.str(); }
bool Screen::connInOutRingRequest(ResourceID inputid, ResourceID rnode){ if ( qbox_){ auto found = outPortRing_.find( ToResourceID(0, GetOutput(rnode), row_, col_)); if ( found != outPortRing_.end()){ found->second = rnode; QboxDataMap value; value["out"] = QString::number(GetOutput(rnode) ).toStdString(); if ( GetCol(inputid) == GetCol(rnode) && GetRow(inputid) == GetRow(rnode)){ value["in"] = QString::number(GetInput(inputid) ).toStdString(); }else{ value["in"] = QString::number(GetInput(rnode) ).toStdString(); } qbox_->addAsyncRequest( PSetSwitchInputReq::uri , std::bind( ignoreCallback, std::placeholders::_1, std::placeholders::_2), value); return true; } } return false; }
int NFCRecord::FindObject(const std::string& strColTag, const NFGUID& value, NFIDataList& varResult) { if (strColTag.empty()) { return -1; } int nCol = GetCol(strColTag); return FindObject(nCol, value, varResult); }
int NFCRecord::FindVector3(const std::string& strColTag, const NFVector3& value, NFDataList& varResult) { if (strColTag.empty()) { return -1; } int nCol = GetCol(strColTag); return FindVector3(nCol, value, varResult); }
int NFCRecord::FindFloat(const std::string& strColTag, const double value, NFDataList& varResult) { if (strColTag.empty()) { return -1; } int nCol = GetCol(strColTag); return FindFloat(nCol, value, varResult); }
void CxEdit::OnUpdatePosition(CCmdUI* pCmdUI) { CString str, strFormat; strFormat.LoadString(pCmdUI->m_nID); str.Format(strFormat, GetRow() + 1, GetCol() + 1 ); pCmdUI->SetText(str); }
ResourceID ScreenMgr::occupyScreenOut( ResourceID inputid){ Screen* screen = screens_[GetRow(inputid)-1][GetCol(inputid)-1]; for ( auto it = screen->outPort753_.begin(); it != screen->outPort753_.end(); ++it){ if ( it->second == 0){ ResourceID wnode = ToResourceID( GetInput(inputid), GetOutput(it->first), GetRow(inputid), GetCol(inputid)); it->second = wnode; return wnode; } } return 0; }
bool ScreenMgr::isInputValid( ResourceID inputid){ uint32_t row, col, input; row = GetRow(inputid); col = GetCol(inputid); input = GetInput(inputid); if ( row <=0) return false; else if ( col <=0) return false; else if ( input <=0) return false; else if ( input <=6) return true; else return false; }
bool ScreenMgr::isOutputRingValid( ResourceID outputid){ uint32_t row, col, output; row = GetRow(outputid); col = GetCol(outputid); output = GetOutput(outputid); if ( row <=0) return false; if ( col <=0) return false; if ( output <=0) return false; Screen* s = screens_[row-1][col-1]; if (s == NULL) return false; return s->isOutputRingValid(outputid); }
void ChessEngine::MakeMove(int sr, int sc, int er, int ec) { vector<int> moves; moveGenerator->GenerateAllMoves(moves); int foundMove = NullMove; for (int i = 0; i < moves.size();i++) { int move = moves[i]; int source = GetSourceFromMove(move); int dest = GetDestFromMove(move); if (sr == GetRow(source) && sc == GetCol(source) && er == GetRow(dest) && ec == GetCol(dest)) { foundMove = move; break; } } if (foundMove != NullMove) { board->MakeMove(foundMove, true); } }
std::vector<ResourceID> ScreenMgr::occupyScreensOut( std::vector<ResourceID> &rnodes){ std::vector<ResourceID> outputs ; std::vector<ResourceID> wnodes ; for ( int i = 0; i < rnodes.size(); ++i){ Screen* screen = screens_[GetRow(rnodes[i])-1][GetCol(rnodes[i])-1]; for ( auto it = screen->outPort753_.begin(); it != screen->outPort753_.end(); ++it){ if ( it->second == 0){ outputs.push_back( it->first); break; } } } if (outputs.size() != rnodes.size() ){ return wnodes; } for ( int i = 0; i < outputs.size(); ++i){ Screen* screen = screens_[GetRow(outputs[i])-1][GetCol(outputs[i])-1]; wnodes.push_back(ToResourceID( GetInput(rnodes[i]), GetOutput(outputs[i]), GetRow(rnodes[i]), GetCol(rnodes[i]))); screen->outPort753_[outputs[i]] = wnodes[i]; } return wnodes; }
bool Board::IsSquareValid(Coords coords, int solvedValue) { // Check that the solved value of this square doesn't appear in any of // the rows, columns or areas it belongs to as a solved value too if (ContainsSolvedValue(GetRow(coords), solvedValue, coords.XCoord()) || ContainsSolvedValue(GetCol(coords), solvedValue, coords.YCoord()) || ContainsSolvedValue(GetArea(coords), solvedValue, IndexInAreaMap(coords))) { cout << "Found invalid repeated value of " << solvedValue << endl; return false; } return true; }
static enum v7_err jsBotFontStyle(struct v7* v7, v7_val_t* res) { v7_val_t fontName = v7_arg(v7, 0); v7_val_t fontSize = v7_arg(v7, 1); v7_val_t fontColor = v7_arg(v7, 2); if (!v7_is_string(fontName) || !v7_is_number(fontSize) || !v7_is_string(fontColor)) { return V7_OK; } TString fontColor2 = v7_to_cstring(v7, &fontColor); TString strFontName = (v7_is_null(fontName)) ? "" : (const char*)v7_to_cstring(v7, &fontName); int nFontSize = (!v7_is_number(fontSize)) ? NULL : (int)v7_to_number(fontSize); COLORREF nFontColor = (!v7_is_string(fontColor)) ? NULL : GetCol(fontColor2.GetAsWChar()); _activeBot->setFontStyle(strFontName, nFontSize, nFontColor); return V7_OK; }
void ScreenMgr::freeScreenOut(ResourceID wnode){ Screen* screen = screens_[GetRow(wnode)-1][GetCol(wnode)-1]; for ( auto it = screen->outPort753_.begin(); it != screen->outPort753_.end(); ++it){ if ( it->second == wnode){ if ( screen->qbox_){ QboxDataMap value; value["out"] = QString::number(GetOutput(wnode) ).toStdString(); screen->qbox_->addAsyncRequest( PDelWindowsReq::uri , std::bind( ignoreCallback, std::placeholders::_1, std::placeholders::_2), value); } it->second = 0; break; } } }
bool ChessEngine::isValidMoveStart(int row, int col) { vector<int> moves; moveGenerator->GenerateAllMoves(moves); for (int i = 0; i < moves.size(); i++) { int move = moves[i]; int source = GetSourceFromMove(move); int dest = GetDestFromMove(move); if (row == GetRow(source) && col == GetCol(source)) { return true; } } return false; }
void TText::Draw() { if (!text) return; SDL_Rect rect; rect.x = 0; rect.y = 0; rect.w = text->w; rect.h = text->h; if (bVisible == true) { if ( SDL_BlitSurface(text, NULL, surface, &rect) < 0 ) { fprintf(stderr, "Couldn't blit text to display: %s\n", SDL_GetError()); } } else { SDL_FillRect(surface, &rect, GetCol(surface, forecolor)); } }
void Bot::say(TString& text, TString& font, unsigned char fontSize, TString& color) { if (font.IsEQ(L"")) font = _charset.font; if (fontSize < 10) fontSize = _charset.size; COLORREF coll = _charset.color; if (!color.IsEQ(L"")) coll = GetCol(color.GetAsWChar()); bot_exchange_format p(PLUGIN_EVENT_ROOM_TEXT); p << bot_value(1, text.GetAsChar()); p << bot_value(2, _charset.attributes); p << bot_value(3, fontSize); p << bot_value(4, coll); p << bot_value(5, _charset.effect); p << bot_value(6, _charset.charset); p << bot_value(7, _charset.pitch); p << bot_value(8, font.GetAsChar()); std::string d = p.data(); _mgr->deliver_event(_name.GetAsChar(), d.c_str(), (int)d.size()); }
string GetUCIString(int move) { int source = GetSourceFromMove(move); int dest = GetDestFromMove(move); ostringstream moveStr; moveStr << (char)('a' + GetCol(source)) << (char)('1' + GetRow(source)) << (char)('a' + GetCol(dest)) << (char)('1' + GetRow(dest)); if (GetPromoFromMove(move) != PieceTypes::None) { char promo = 'Q'; switch (GetPromoFromMove(move)) { case PieceTypes::Bishop: promo = 'b'; break; case PieceTypes::Knight: promo = 'n'; break; case PieceTypes::Queen: promo = 'q'; break; case PieceTypes::Rook: promo = 'r'; break; default: throw new exception("Invalid promotion choice."); break; } moveStr << promo; } return moveStr.str(); }
void show_a_filename(char * name) { int i,len; if(l_length < maxlength) { printf("\n"); l_length = GetCol(); } len = strlen(name); len = maxlength - len; printf("%-s", name); //printf("debug ===-=========%d ", maxlength); for(i = 0; i < len; i++) { printf(" "); } printf(" "); l_length -= (maxlength + 2); }
void Constraint::StandardJointDrawing(Matrix3D& A, Vector3D& p, Vector3D& d_dir, Vector3D& d_rot, int flag, double draw_factor) { //double draw_factor = GetDrawSizeScalar(); Vector3D draw_dir; for (int i=1; i<=3; i++) { draw_dir = draw_factor*Vector3D(A.Get0(0,i-1),A.Get0(1,i-1),A.Get0(2,i-1)); if(d_dir(i)!=0) { mbs->SetColor(GetCol()); mbs->DrawCone(p + flag*draw_dir,p,draw_factor*1.1,6,1); } if(d_rot(i)!=0) { //GetMBS()->ChooseColor(0.0f,0.6f,0.0f); mbs->SetColor(GetColExt()); mbs->DrawCone(p + 2*flag*draw_dir,p,draw_factor,6,1); mbs->DrawCone(p + 4*flag*draw_dir,p + 2*flag*draw_dir,draw_factor,6,1); //mbs->SetColor(GetCol()); } } }
ulong Board::GetPinRestrictionMask(int square, int color) { int attackerColor = OtherColor(color); int kingSquare = GetKingSquare(color); int kingRow = GetRow(kingSquare); int kingCol = GetCol(kingSquare); int pieceRow = GetRow(square); int pieceCol = GetCol(square); int dr = pieceRow - kingRow; int dc = pieceCol - kingCol; ulong defenderKing = 1ULL << kingSquare; if(dr == 0) { ulong rankAttacks = MoveGenerator::rankAttacks[square][GetRankStatus(square)]; ulong defenderKing = 1ULL << kingSquare; if((defenderKing & rankAttacks) != 0) { ulong attackers = GetPieceBitBoard(Pieces::GetPiece(PieceTypes::Rook, attackerColor)) | GetPieceBitBoard(Pieces::GetPiece(PieceTypes::Queen, attackerColor)); if((rankAttacks & attackers) != 0) { return rankAttacks; } } } else if(dc == 0) { ulong fileAttacks = MoveGenerator::fileAttacks[square][GetFileStatus(square)]; if((defenderKing & fileAttacks) != 0) { ulong attackers = GetPieceBitBoard(Pieces::GetPiece(PieceTypes::Rook, attackerColor)) | GetPieceBitBoard(Pieces::GetPiece(PieceTypes::Queen, attackerColor)); if((fileAttacks & attackers) != 0) { return fileAttacks; } } } else if(dr == dc || dr == -dc) { ulong diagAttacks = 0; if(dr == dc) { diagAttacks = MoveGenerator::diagA1H8Attacks[square][GetDiagA1H8Status(square)]; } else { diagAttacks = MoveGenerator::diagA8H1Attacks[square][GetDiagA8H1Status(square)]; } if((defenderKing & diagAttacks) != 0) { ulong attackers = GetPieceBitBoard(Pieces::GetPiece(PieceTypes::Bishop, attackerColor)) | GetPieceBitBoard(Pieces::GetPiece(PieceTypes::Queen, attackerColor)); if((diagAttacks & attackers) != 0) { return diagAttacks; } } } return ~(0ULL); }
int NFCRecord::FindRowByColValue(const std::string& strColTag, const NFData& var, NFDataList& varResult) { int nCol = GetCol(strColTag); return FindRowByColValue(nCol, var, varResult); }
const NFVector3& NFCRecord::GetVector3(const int nRow, const std::string& strColTag) const { int nCol = GetCol(strColTag); return GetVector3(nRow, nCol); }
const NFGUID& NFCRecord::GetObject(const int nRow, const std::string& strColTag) const { int nCol = GetCol(strColTag); return GetObject(nRow, nCol); }
const std::string& NFCRecord::GetString(const int nRow, const std::string& strColTag) const { int nCol = GetCol(strColTag); return GetString(nRow, nCol); }