int main(int argc, char const *argv[]) { compliment(); compliment(); compliment(); last_say(); return 0; }
char * reverseComp(char *read) { char *strReverse = strdup(read); int i = 0, end = strlen(read)-1; while (strReverse[i] != '\n' && strReverse[i] != '\0' && strReverse[i] != '\t') { strReverse[i] = compliment(read[end]); i++; end--; } return strReverse; }
void UberDelegate::paint_pref(const QRect &adjusted, QPainter *p, const QStyleOptionViewItem &opt, const QModelIndex &proxy_idx) const { QModelIndex idx = m_proxy->mapToSource(proxy_idx); Dwarf *d = m_model->get_dwarf_by_id(idx.data(DwarfModel::DR_ID).toInt()); if (!d) { return QStyledItemDelegate::paint(p, opt, idx); } int labor_id = idx.data(DwarfModel::DR_LABOR_ID).toInt(); short val = d->pref_value(labor_id); QString symbol = GameDataReader::ptr()->get_military_preference(labor_id)->value_symbol(val); bool dirty = d->is_labor_state_dirty(labor_id); QColor bg = paint_bg(adjusted, false, p, opt, proxy_idx); p->save(); if (auto_contrast) p->setPen(QPen(compliment(bg))); p->drawText(opt.rect, Qt::AlignCenter, symbol); p->restore(); paint_grid(adjusted, dirty, p, opt, proxy_idx); }
void multi(int valA, int valB, int& runningScore) { runningScore = 0; int count = 0; int product, userAns; for(int i = 0; i < 6; i++) { randNum(valA, valB); product = valA * valB; cout << "What is " << valA << " * " << valB << " equal to: "; cin >> userAns; if(product == userAns) { compliment(); count++; runningScore++; } else { encouragement(); } } cout << "You got " << count << " problems correct."; }
void UberDelegate::paint_cell(QPainter *p, const QStyleOptionViewItem &opt, const QModelIndex &idx, const bool drawing_aggregate) const { QModelIndex model_idx = idx; if (m_proxy) model_idx = m_proxy->mapToSource(idx); COLUMN_TYPE type = static_cast<COLUMN_TYPE>(model_idx.data(DwarfModel::DR_COL_TYPE).toInt()); QRect adjusted = opt.rect.adjusted(cell_padding, cell_padding, -cell_padding, -cell_padding); float rating = model_idx.data(DwarfModel::DR_RATING).toFloat(); QString text_rating = model_idx.data(DwarfModel::DR_DISPLAY_RATING).toString(); float limit = 100.0; switch (type) { case CT_SKILL: { QColor bg = paint_bg(adjusted, p, opt, idx); limit = 15.0; if(rating >= 0) paint_values(adjusted, rating, text_rating, bg, p, opt, idx, 0, 0, limit, 0, 0); paint_mood_cell(adjusted,p,opt,idx,model_idx.data(DwarfModel::DR_SKILL_ID).toInt(),false); } break; case CT_LABOR: { if (!drawing_aggregate) { Dwarf *d = m_model->get_dwarf_by_id(idx.data(DwarfModel::DR_ID).toInt()); if (!d) { return QStyledItemDelegate::paint(p, opt, idx); } int labor_id = idx.data(DwarfModel::DR_LABOR_ID).toInt(); bool enabled = d->labor_enabled(labor_id); bool dirty = d->is_labor_state_dirty(labor_id); QColor bg = paint_bg_active(adjusted, enabled, p, opt, idx); limit = 15.0; if(rating >= 0) paint_values(adjusted, rating, text_rating, bg, p, opt, idx, 0, 0, limit, 0, 0); paint_mood_cell(adjusted,p,opt,idx,GameDataReader::ptr()->get_labor(labor_id)->skill_id, dirty); }else { paint_labor_aggregate(adjusted, p, opt, idx); } } break; case CT_HAPPINESS: { paint_bg(adjusted, p, opt, idx, true, model_idx.data(Qt::BackgroundColorRole).value<QColor>()); if(draw_happiness_icons){ paint_icon(adjusted,p,opt,idx); }else{ p->save(); paint_grid(adjusted, false, p, opt, idx); p->restore(); } } break; case CT_EQUIPMENT: { int wear_level = idx.data(DwarfModel::DR_SPECIAL_FLAG).toInt(); paint_bg(adjusted, p, opt, idx, true, model_idx.data(Qt::BackgroundColorRole).value<QColor>()); paint_wear_cell(adjusted,p,opt,idx,wear_level); } break; case CT_ITEMTYPE: { QColor bg = paint_bg(adjusted, p, opt, idx, true, model_idx.data(Qt::BackgroundColorRole).value<QColor>()); //if we're drawing numbers, we only want to draw counts for squads //this is a special case because we're drawing different information if it's text mode if(m_skill_drawing_method == SDM_NUMERIC && rating == 100) rating = -1; paint_values(adjusted, rating, text_rating, bg, p, opt, idx,90.0f,5.0f,95.0f,99.99f,102.0f,false); int wear_level = idx.data(DwarfModel::DR_SPECIAL_FLAG).toInt(); paint_wear_cell(adjusted,p,opt,idx,wear_level); } break; case CT_ROLE: { bool active_labors = false; int dirty_alpha = 255; int active_alpha = 255; bool dirty = false; Dwarf *d = m_model->get_dwarf_by_id(idx.data(DwarfModel::DR_ID).toInt()); if(d){ if(idx.data(DwarfModel::DR_SPECIAL_FLAG).canConvert<QVariantList>()){ QVariantList labors = idx.data(DwarfModel::DR_SPECIAL_FLAG).toList(); int active_count = 0; int dirty_count = 0; foreach(QVariant id, labors){ if(d->labor_enabled(id.toInt())){ active_labors = true; active_count++; } if(d->is_labor_state_dirty(id.toInt())){ dirty = true; dirty_count++; } } if(active_labors) active_alpha = (255 * ((float)active_count / labors.count())); if(dirty) dirty_alpha = (255 * ((float)dirty_count / labors.count())); } } QColor bg; QColor color_active_adjusted = color_active_labor; if(active_labors){ color_active_adjusted.setAlpha(active_alpha); bg = paint_bg_active(adjusted, active_labors, p, opt, idx, color_active_adjusted); }else{ bg = paint_bg(adjusted, p, opt, idx); } double limit_range = (DwarfStats::get_role_max() - DwarfStats::get_role_min()) * 0.05; paint_values(adjusted, rating, text_rating, bg, p, opt, idx,50.0f, DwarfStats::get_role_min() + limit_range,DwarfStats::get_role_max() - limit_range,45.0f,55.0f); if(dirty){ QColor color_dirty_adjusted = color_dirty_border; color_dirty_adjusted.setAlpha(dirty_alpha); paint_border(adjusted,p,color_dirty_adjusted); paint_grid(adjusted,false,p,opt,idx,false); }else{ paint_grid(adjusted, dirty, p, opt, idx); } } break; case CT_IDLE: { paint_bg(adjusted, p, opt, idx, true, model_idx.data(Qt::BackgroundColorRole).value<QColor>()); paint_icon(adjusted,p,opt,idx); } break; case CT_PROFESSION: { paint_bg(adjusted, p, opt, idx, true, model_idx.data(Qt::BackgroundColorRole).value<QColor>()); paint_icon(adjusted,p,opt,idx); } break; case CT_HIGHEST_MOOD: { paint_bg(adjusted, p, opt, idx, true, model_idx.data(Qt::BackgroundColorRole).value<QColor>()); paint_icon(adjusted,p,opt,idx); bool had_mood = idx.data(DwarfModel::DR_SPECIAL_FLAG).toBool(); if(had_mood){ p->save(); QRect moodr = adjusted; moodr.adjust(2,2,-2,-2); p->setPen(QPen(Qt::darkRed,2)); p->drawLine(moodr.bottomLeft(), moodr.topRight()); p->restore(); } } break; case CT_TRAIT: { QColor bg = paint_bg(adjusted, p, opt, idx); paint_values(adjusted, rating, text_rating, bg, p, opt, idx, 50, 10, 90); paint_grid(adjusted, false, p, opt, idx); } break; case CT_ATTRIBUTE: { QColor bg = paint_bg(adjusted, p, opt, idx); paint_values(adjusted, rating, text_rating, bg, p, opt, idx, 50.0f, 2.0f, 98.0f); if(color_attribute_syns && idx.data(DwarfModel::DR_SPECIAL_FLAG).toInt() > 0){ paint_border(adjusted,p,Attribute::color_affected_by_syns()); paint_grid(adjusted, false, p, opt, idx, false); }else{ paint_grid(adjusted, false, p, opt, idx); } } break; case CT_WEAPON: { QColor bg = paint_bg(adjusted, p, opt, idx); paint_values(adjusted, rating, text_rating, bg, p, opt, idx, 50.0f, 1, 99, 49, 51, true); paint_grid(adjusted, false, p, opt, idx); } break; case CT_FLAGS: { paint_flags(adjusted, p, opt, idx); } break; case CT_TRAINED: { QColor bg = paint_bg(adjusted, p, opt, idx, false, model_idx.data(Qt::BackgroundColorRole).value<QColor>()); //arbitrary ignore range is used just to hide tame animals paint_values(adjusted, rating, text_rating, bg, p, opt, idx, 50.0f, 1.0f, 95.0f, 49.9f, 50.1f, true); paint_grid(adjusted, false, p, opt, idx); } break; case CT_HEALTH: { QColor bg = paint_bg(adjusted, p, opt, idx, false, model_idx.data(Qt::BackgroundColorRole).value<QColor>()); //draw the symbol text in bold p->save(); if (rating != 0) { if(color_health_cells){ p->setPen(model_idx.data(Qt::TextColorRole).value<QColor>()); }else{ if(auto_contrast){ p->setPen(compliment(bg)); }else{ p->setPen(Qt::black); } } QFont tmp = m_fnt; tmp.setBold(true); p->setFont(tmp); p->drawText(opt.rect, Qt::AlignCenter, text_rating); } p->restore(); paint_grid(adjusted, false, p, opt, idx); } break; case CT_SPACER: case CT_DEFAULT: default: { if(adjusted.width() > 0) paint_bg(adjusted, p, opt, idx, true, model_idx.data(Qt::BackgroundColorRole).value<QColor>()); break; } }
void UberDelegate::paint_skill(const QRect &adjusted, int rating, QColor bg, QPainter *p, const QStyleOptionViewItem &opt, const QModelIndex &) const { QColor c = color_skill; if (auto_contrast) c = compliment(bg); p->save(); switch(m_skill_drawing_method) { default: case SDM_GROWING_CENTRAL_BOX: if (rating >= 15) { // draw diamond p->setRenderHint(QPainter::Antialiasing); p->setPen(Qt::gray); p->setBrush(QBrush(c)); p->translate(opt.rect.x() + 2, opt.rect.y() + 2); p->scale(opt.rect.width()-4, opt.rect.height()-4); p->drawPolygon(m_diamond_shape); } else if (rating > -1 && rating < 15) { float size = 0.75f * ((rating + 1) / 15.0f); // even dabbling (0) should be drawn float inset = (1.0f - size) / 2.0f; p->translate(adjusted.x(), adjusted.y()); p->scale(adjusted.width(), adjusted.height()); p->fillRect(QRectF(inset, inset, size, size), QBrush(c)); } break; case SDM_GROWING_FILL: if (rating >= 15) { // draw diamond p->setRenderHint(QPainter::Antialiasing); p->setPen(Qt::gray); p->setBrush(QBrush(c)); p->translate(opt.rect.x() + 2, opt.rect.y() + 2); p->scale(opt.rect.width() - 4, opt.rect.height() - 4); p->drawPolygon(m_diamond_shape); } else if (rating > -1 && rating < 15) { float size = (rating + 2) / 16.0f; p->translate(adjusted.x(), adjusted.y()); p->scale(adjusted.width(), adjusted.height()); p->fillRect(QRectF(0, 0, size, 1), QBrush(c)); } break; case SDM_GLYPH_LINES: { p->setBrush(QBrush(c)); p->setPen(c); p->translate(adjusted.x(), adjusted.y()); p->scale(adjusted.width(), adjusted.height()); QVector<QLineF> lines; switch (rating) { case 20: case 19: case 18: case 17: case 16: case 15: { p->resetTransform(); p->translate(adjusted.x() + adjusted.width()/2.0, adjusted.y() + adjusted.height()/2.0); p->scale(adjusted.width(), adjusted.height()); p->rotate(-18); p->setRenderHint(QPainter::Antialiasing); p->drawPolygon(m_star_shape, Qt::WindingFill); } break; case 14: { QPolygonF poly; poly << QPointF(0.5, 0.1) << QPointF(0.5, 0.5) << QPointF(0.9, 0.5); p->drawPolygon(poly); } case 13: { QPolygonF poly; poly << QPointF(0.1, 0.5) << QPointF(0.5, 0.5) << QPointF(0.5, 0.9); p->drawPolygon(poly); } case 12: { QPolygonF poly; poly << QPointF(0.9, 0.5) << QPointF(0.5, 0.5) << QPointF(0.5, 0.9); p->drawPolygon(poly); } case 11: { QPolygonF poly; poly << QPointF(0.1, 0.5) << QPointF(0.5, 0.5) << QPointF(0.5, 0.1); p->drawPolygon(poly); } case 10: // accomplished lines << QLineF(QPointF(0.5, 0.1), QPointF(0.9, 0.5)); case 9: //professional lines << QLineF(QPointF(0.1, 0.5), QPointF(0.5, 0.1)); case 8: //expert lines << QLineF(QPointF(0.5, 0.9), QPointF(0.1, 0.5)); case 7: //adept lines << QLineF(QPointF(0.5, 0.9), QPointF(0.9, 0.5)); case 6: //talented lines << QLineF(QPointF(0.5, 0.5), QPointF(0.5, 0.9)); case 5: //proficient lines << QLineF(QPointF(0.5, 0.5), QPointF(0.9, 0.5)); case 4: //skilled lines << QLineF(QPointF(0.5, 0.1), QPointF(0.5, 0.5)); case 3: //competent lines << QLineF(QPointF(0.1, 0.5), QPointF(0.5, 0.5)); case 2: //untitled lines << QLineF(QPointF(0.7, 0.3), QPointF(0.3, 0.7)); case 1: //novice lines << QLineF(QPointF(0.3, 0.3), QPointF(0.7, 0.7)); case 0: //dabbling lines << QLineF(QPointF(0.5, 0.5), QPointF(0.5, 0.5)); break; } p->drawLines(lines); } break; case SDM_NUMERIC: if (rating > -1) { // don't draw 0s everywhere p->setPen(c); p->drawText(opt.rect, Qt::AlignCenter, QString::number(rating)); } break; } p->restore(); }