CharSelect::CharSelect(QWidget* parent) : ScrPaletteBase(parent, "CharSelect"), m_doc(0), m_enhanced(0), m_Item(0) { setupUi(this); paletteFileMask = tr("Scribus Char Palette (*.ucp);;All Files (*)"); hideButton->setIcon(loadIcon("22/insert-table.png")); unicodeButton->setIcon(loadIcon("find.png")); uniLoadButton->setIcon(loadIcon("22/document-open.png")); uniSaveButton->setIcon(loadIcon("22/document-save.png")); uniClearButton->setIcon(loadIcon("22/document-new.png")); m_userTableModel = new CharTableModel(this, 6, m_doc, PrefsManager::instance()->appPrefs.itemToolPrefs.textFont); loadUserContent(ScPaths::getApplicationDataDir() + "charpalette.ucp"); m_userTable->setModel(m_userTableModel); m_userTable->setAcceptDrops(true); // signals and slots connections connect(m_userTable, SIGNAL(selectChar(uint, QString)), this, SLOT(userNewChar(uint, QString))); connect(m_userTableModel, SIGNAL(selectionChanged(QItemSelectionModel*)), m_userTable, SLOT(modelSelectionChanged(QItemSelectionModel*))); connect(m_userTableModel, SIGNAL(rowAppended()), m_userTable, SLOT(resizeLastRow())); connect(unicodeButton, SIGNAL(chosenUnicode(const QString &)), m_userTableModel, SLOT(appendUnicode(const QString &))); connect(hideButton, SIGNAL(toggled(bool)), this, SLOT(hideButton_toggled(bool))); connect(this, SIGNAL(insertUserSpecialChar(QChar, QString)), this, SLOT(slot_insertUserSpecialChar(QChar, QString))); connect(uniLoadButton, SIGNAL(clicked()), this, SLOT(uniLoadButton_clicked())); connect(uniSaveButton, SIGNAL(clicked()), this, SLOT(uniSaveButton_clicked())); connect(uniClearButton, SIGNAL(clicked()), this, SLOT(uniClearButton_clicked())); }
CharSelectEnhanced::CharSelectEnhanced(QWidget* parent) : ScrPaletteBase(parent, "CharSelectEnhanced"), m_doc(0), m_characterClass(0) { setupUi(this); m_charTableModel = new CharTableModel(this, 26, m_doc);//, // PrefsManager::instance()->appPrefs.toolSettings.defFont); m_charTable->setModel(m_charTableModel); m_charTable->setDragEnabled(true); // insert hex codes directly QValidator* insValidator = new QRegExpValidator(QRegExp("[A-F,a-f,0-9]{4}"), this); hexLineEdit->setValidator(insValidator); // signals and slots connections connect(deleteButton, SIGNAL(clicked()), this, SLOT(delEdit())); connect(insertButton, SIGNAL(clicked()), this, SLOT(insChar())); connect(m_charTable, SIGNAL(selectChar(uint, QString)), this, SLOT(newChar(uint, QString))); connect(fontSelector, SIGNAL(activated(int)), this, SLOT(newFont(int))); connect(rangeSelector, SIGNAL(activated(int)), this, SLOT(newCharClass(int))); connect(hexLineEdit, SIGNAL(returnPressed()), this, SLOT(hexLineEdit_returnPressed())); }
void CharTableView::viewDoubleClicked(const QModelIndex & /*index*/) { int charIndex = currentCharactersIndex(); if (model()->characters().count() > charIndex) emit selectChar(model()->characters()[charIndex], model()->fonts()[charIndex]); }
TCPMessagePtr GameClient::processClient() { TCPMessagePtr msg(new TCPMessage); if (SDLNet_SocketReady(_socket)){ msg = TCPMessage::receiveFromSocket(_socket); std::cout << "Got message[" << static_cast<int>( msg->type ) << "]: "<< msg->data << "\n"; if ( msg->type == TCPMessage::MSG_LOGIN ){ size_t tmpPos = msg->data.find_first_of(';'); if (tmpPos == std::string::npos){ std::cout << "Invalid LOGIN message!!!\n"; return TCPMessagePtr(new TCPMessage(TCPMessage::MSG_DISCONNECT, "")); } // check login std::string username(msg->data.substr(0, tmpPos)); std::string password(msg->data.substr(tmpPos + 1)); msg->type = login( username, password ); } else if ( msg->type == TCPMessage::MSG_LIST_CHARS ) { std::string chars; sqlite3_stmt* query = Database::getInstance()->prepare( QUERY_CHARACTER_LIST_BY_ACCID ); sqlite3_bind_int( query, 1, _id ); while(sqlite3_step( query ) == SQLITE_ROW) { chars += reinterpret_cast<const char*>( sqlite3_column_text( query, 0 ) ); if (chars.empty() == false) chars += ';'; } TCPMessage charsMsg( TCPMessage::MSG_LIST_CHARS, chars ); charsMsg.sendToSocket(_socket); } else if ( msg->type == TCPMessage::MSG_SELECT_CHAR ) { selectChar(msg->data); } else if ( msg->type == TCPMessage::MSG_MOVE_REQ ) { const int* x = reinterpret_cast<const int*>(msg->data.c_str()); const int* y = reinterpret_cast<const int*>(msg->data.c_str() + INT_SIZE); std::cout << "move request: " << *x << " " << *y << "\n"; int coords[] = { *x, *y }; if ( _world->canMoveTo( *x, *y, *this, true ) == false ){ // reset to current coords coords[0] = getCurrentCharacter()->position().x; coords[1] = getCurrentCharacter()->position().y; // send correction message TCPMessagePtr msg = TCPMessage::createMessage( TCPMessage::MSG_MOVE_COORD, coords, 2 ); msg->sendToSocket(_socket); } else { // save the coords getCurrentCharacter()->position().x = coords[0]; getCurrentCharacter()->position().y = coords[1]; TCPMessagePtr playerMsg = TCPMessage::createMessage( TCPMessage::MSG_PLAYER_MOVE, coords, 2, getCurrentCharacter()->getName()); _world->broadcastMessage( playerMsg, this ); } } } return msg; }
/* * This rasterises the line using Bresenham's * line algorithm */ void drawLineToGlobalScreen(lineVector* line) { /* * TODO doesn't draw correctly when coordinate outside X * range */ int_u x1 = (int_u)(line->x1 - 0.5); int_u y1 = (int_u)(line->y1 - 0.5); int_u x2 = (int_u)(line->x2 - 0.5); int_u y2 = (int_u)(line->y2 - 0.5); int_u tmp; int deltax = (int)(x2) - (int)(x1); int deltay = (int)(y2) - (int)(y1); float gradient = (float) deltay / (float) deltax; float error = 0; /* * Changes coordinates around so they are printed correctly */ if((x1 > x2 && gradient > 0) || (x1 < x2 && gradient < 0)) { tmp = x1; x1 = x2; x2 = tmp; tmp = y1; y1 = y2; y2 = tmp; deltax = -deltax; deltay = -deltay; } int i,j; if(deltax == 0) { /* * vertical line */ for(i = 0;i < abs(deltay);i++) { if(deltay < 0 && y2 + i < SSIZEY && x2 < SSIZEX) globalScreen[x2][y2 + i] = '|'; else if(y2 - i < SSIZEY) globalScreen[x2][y2 - i] = '|'; } } if(deltay == 0) { for(i = 0;i < abs(deltax);i++) { if(deltax < 0 && x2 + i < SSIZEX && y2 < SSIZEY) globalScreen[x2 + i][y2] = '-'; else if(x2 - i < SSIZEX) globalScreen[x2 - i][y2] = '-'; } } else { int y = 0; int x = 0; for(x = 0;x < abs(deltax);x++) { error += gradient; if(gradient > 0) { while(error >= 0.5) { if(x1 + x < SSIZEX && y1 + y < SSIZEY) globalScreen[x1 + x][y1 + y] = selectChar(gradient,error); if(deltay < 0) y--; else y++; error--; } if(x1 + x < SSIZEX && y1 + y < SSIZEY) globalScreen[x1 + x][y1 + y] = selectChar(gradient,error); } else { while(error <= 0.5) { if(x1 - x < SSIZEX && y1 + y < SSIZEY) globalScreen[x1 - x][y1 + y] = selectChar(gradient,error); if(deltay < 0) y--; else y++; error++; } if(x1 - x < SSIZEX && y1 + y < SSIZEY) globalScreen[x1 - x][y1 + y] = selectChar(gradient,error); } } } }