void Koushin::Player::fieldClicked(Koushin::Field* field) { switch (m_lastInteraction) { case Koushin::PlayerInteraction::roundedStarted: case Koushin::PlayerInteraction::noInteraction: if(field->getType() == Koushin::plainField) { townClicked(field->getFieldItem()->pos().toPoint()); } if(field->getType() == Koushin::fieldWithBuilding && field->getBuilding()) { setSelectedBuilding(field->getBuilding()); field->getBuilding()->select(); m_lastInteraction = Koushin::PlayerInteraction::buildingClicked; } break; case Koushin::PlayerInteraction::buildingClicked: if(m_fieldsForFieldAction.contains(field)) { fieldForActionChosen(field); field->getTown()->unmarkAllFields(); m_selectedBuilding->select(); emit showFieldInfo(field); } else { setSelectedBuilding(0); field->getTown()->unmarkAllFields(); emit showFieldInfo(field); m_lastInteraction = Koushin::PlayerInteraction::noInteraction; } break; default: kDebug() << "Do not know what to do."; } }
void FieldManagerDlg::fillContent() { // 填充所有的图元及数据类型 m_typeCombo.ResetContent(); m_fieldListBox.ResetContent(); //AcStringArray types; //FieldHelper::GetAllRegTypes( types ); //if( types.isEmpty() ) return; classNameTrans(); if( m_namesEn.IsEmpty() || m_namesZh.IsEmpty() ) return; int len = m_namesEn.GetCount(); //acutPrintf(_T("\n总个数:%d"), len); for( int i = 0; i < len; i++ ) { m_typeCombo.AddString( m_namesZh[i] ); //acutPrintf(_T("\n%d:%s"), i, types[i].kACharPtr()); } // 定位第1个图元 m_typeCombo.SetCurSel( 0 ); // 填充第1个类型所包含的所有字段 fillFieldListBox( m_namesEn[0] ); // 显示第1个字段信息 showFieldInfo(); }
void FieldManagerDlg::OnCbnSelchangeTypeCombo2() { // 不保存之前所做的修改***??? //确实不保存2015/1/1,hd // 清空字段列表 clearFieldListBox(); // 填充字段 fillFieldListBox( getSelType() ); // 更新字段信息对话框的显示 showFieldInfo(); // Invalidate()将整个对话框都失效 // 而InvalidateRect仅将IDC_DRAW_POS所在矩形块失效 // 从而提高了效率 CRect rect; GetDlgItem( IDC_DRAW_POS )->GetWindowRect( &rect ); ScreenToClient( &rect ); InvalidateRect( &rect ); // 更新绘图区的显示 // 不调用UpdateWindow()也能够触发WM_PAINT消息,从而调用OnPaint()方法 //UpdateWindow(); }
void Koushin::Player::startRound() { emit showResourceInfo(m_townList.first()); emit showFieldInfo(0); foreach(Koushin::Town* town, m_townList) town->growBuildings(); m_lastInteraction = Koushin::PlayerInteraction::roundedStarted; }
void Koushin::Player::fieldForActionChosen(Koushin::Field* field) { if(!m_selectedBuilding) return; KConfigGroup* fieldsGroup = new KConfigGroup(m_selectedBuilding->getConfig()->group("fieldTasks")); //create actions QList<Action* > actions = Koushin::ActionParser::createActionsFromConfig(fieldsGroup, field, m_game->getCurrentRound(), m_openFieldConfig); kDebug() << "##### load actions: " << actions.size(); foreach(Koushin::Action* action, actions) m_selectedBuilding->insertAction(action); m_actionManager->addActionObject(m_selectedBuilding); m_fieldsForFieldAction.clear(); m_selectedBuilding->useField(field); m_selectedBuilding->removeOpenFieldAction(m_openFieldConfig); emit showFieldInfo(field); }
bool FieldManagerDlg::updateFieldInfo() { fidlg.UpdateData( TRUE ); bool ret = fidlg.validateFieldInfo(); if( ret ) { if( getLastSelIndex() != LB_ERR ) { fidlg.writeToFieldInfo( *m_infoes[getLastSelIndex()] ); } showFieldInfo(); } else { m_fieldListBox.SetCurSel( getLastSelIndex() ); } return ret; }
void Koushin::Player::setSelectedBuilding(Koushin::Building* building) { m_selectedBuilding = building; if(building) emit showFieldInfo(building->getField()); }