/** * Start a competition. * This code needs to track the order of the field starting to ensure that everything happens * in the right order. Repeatedly run the correct method, either Autonomous or OperatorControl * when the robot is enabled. After running the correct method, wait for some state to change, * either the other mode starts or the robot is disabled. Then go back and wait for the robot * to be enabled again. */ void SimpleRobot::StartCompetition() { RobotMain(); if (!m_robotMainOverridden) { while (1) { if (IsDisabled()) { Disabled(); while (IsDisabled()) Wait(.01); } else if (IsAutonomous()) { Autonomous(); while (IsAutonomous() && IsEnabled()) Wait(.01); } else { OperatorControl(); while (IsOperatorControl() && IsEnabled()) Wait(.01); } } } }
void MAS::HyperText::Draw(Bitmap &canvas) { // get the button state int state = Disabled() ? 2 : ((Selected() || (Flags() & D_PRESSED)) ? 1 : (HasFocus() ? 3 : 0)); // get the button colors and font Color fg = GetFontColor(state); Color bg = GetShadowColor(state); Font f = GetFont(state); Color textMode = GetTextMode(); canvas.Clear(textMode); switch (state) { case 0: case 2: f.GUITextoutEx(canvas, text, 1, 1, fg, bg, textMode, 0); canvas.Hline(1, h()-3, w()-2, fg); break; case 1: f.GUITextoutEx(canvas, text, 2, 2, fg, bg, textMode, 0); canvas.DrawDottedRect(1, 1, w()-1, h()-1, skin->c_font); canvas.Hline(1, h()-2, w()-2, fg); break; case 3: f.GUITextoutEx(canvas, text, 1, 1, fg, bg, textMode, 0); canvas.DrawDottedRect(0, 0, w()-2, h()-2, skin->c_font); canvas.Hline(1, h()-3, w()-2, fg); break; }; }
/** * Start a competition. * This code needs to track the order of the field starting to ensure that everything happens * in the right order. Repeatedly run the correct method, either Autonomous or OperatorControl * when the robot is enabled. After running the correct method, wait for some state to change, * either the other mode starts or the robot is disabled. Then go back and wait for the robot * to be enabled again. */ void SimpleRobot::StartCompetition() { RobotMain(); if (!m_robotMainOverridden) { // first and one-time initialization RobotInit(); while (true) { if (IsDisabled()) { m_ds->InDisabled(true); Disabled(); m_ds->InDisabled(false); while (IsDisabled()) m_ds->WaitForData(); } else if (IsAutonomous()) { m_ds->InAutonomous(true); Autonomous(); m_ds->InAutonomous(false); while (IsAutonomous() && IsEnabled()) m_ds->WaitForData(); } else { m_ds->InOperatorControl(true); OperatorControl(); m_ds->InOperatorControl(false); while (IsOperatorControl() && IsEnabled()) m_ds->WaitForData(); } } } }
void FleetButton::MouseHere(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys) { MapWnd* map_wnd = ClientUI::GetClientUI()->GetMapWnd(); if (!Disabled() && (!map_wnd || !map_wnd->InProductionViewMode())) { if (State() != BN_ROLLOVER) PlayFleetButtonRolloverSound(); SetState(BN_ROLLOVER); } }
void ServoTitleInfo::on_buttonBox_accepted() { auto CheckPower = []() -> bool { test::servo::Parameters& params = test::servo::Parameters::Instance(); const int pomp_max_power = 55; const int pomp_count = 2; double power = pomp_count * pomp_max_power; bool combo1 = params.DefaultExpenditure()*params.PressureNominal()/540 > power; bool combo2 = params.DefaultExpenditure()*params.PressureTesting()/540 > power; bool combo3 = params.MaxExpenditureA()*params.PressureNominal()/540 > power; bool combo4 = params.MaxExpenditureB()*params.PressureNominal()/540 > power; QString err_msg; if ( combo1 ) err_msg += "Необходимо скорректировать расход по умолчанию и номинальное давление\n"; if ( combo2 ) err_msg += "Необходимо скорректировать расход по умолчанию и пробное давление\n"; if ( combo3 ) err_msg += "Необходимо скорректировать максимальный расход в канале А и номинальное давление\n"; if ( combo4 ) err_msg += "Необходимо скорректировать максимальный расход в канале Б и номинальное давление\n"; if ( !err_msg.isEmpty() ) { QMessageBox msg; msg.setWindowTitle( "Превышена допустимая мощьность насосов" ); msg.setText( err_msg ); msg.setStandardButtons( QMessageBox::Ok ); msg.setModal( true ); msg.exec(); } return !combo1 && !combo2 && !combo3 && !combo4; }; if ( SaveInputParams() ) { if (!CheckPower()) return; if ( test::servo::Parameters::Instance().PosCount() == 2 ) { foreach (auto test_ptr, test::servo::Parameters::Instance().TestCollection().Tests()) { if ( test_ptr->ID() == 14 || test_ptr->ID() == 15 ) test_ptr->Disabled( true ); } } hide(); if ( mChildWindow.get() ) QObject::disconnect( mChildWindow.get(), SIGNAL(closed()), this, SLOT(close()) ); mChildWindow.reset( new TestForm( mNewMode ) ); QObject::connect( mChildWindow.get(), SIGNAL(closed()), this, SLOT(close()) ); mChildWindow->show(); }
void ProgressWidget::Draw( void ) { surface->DrawBack( *this ); surface->DrawBox( *this, BOX_RECESSED ); if ( !Disabled() && (level > 0) ) { unsigned short levsize = level * (Width() - 2) / (max_level - min_level); surface->FillRectAlpha( x + 1, y + 1, levsize, h - 2, col ); } PrintTitle( title_x, title_y, col ); }
static void InformUnlockableStatusChanges(int* statusChanges, int count) { char text[MAX_STRING_CHARS]; char* textptr = text; int unlockableNum; bool firstPass = true, unlocked = true; unlockable_t* unlockable; for (unlockableNum = 0; unlockableNum < NUM_UNLOCKABLES; unlockableNum++) { unlockable = &unlockables[unlockableNum]; if (!statusChanges[unlockableNum] || Disabled(unlockable)) { continue; } if (firstPass) { if (statusChanges[unlockableNum] > 0) { Com_sprintf(text, sizeof(text), S_COLOR_GREEN "ITEM%s UNLOCKED: " S_COLOR_WHITE, (count > 1) ? "S" : ""); } else { unlocked = false; Com_sprintf(text, sizeof(text), S_COLOR_RED "ITEM%s LOCKED: " S_COLOR_WHITE, (count > 1) ? "S" : ""); } textptr = text + strlen(text); firstPass = false; } else { Com_sprintf(textptr, sizeof(text) - (textptr - text), ", "); textptr += 2; } Com_sprintf(textptr, sizeof(text) - (textptr - text), "%s", UnlockableHumanName(unlockable)); textptr += strlen(textptr); } // TODO: Add sound for items being locked for each team switch (cg.snap->ps.persistant[PERS_TEAM]) { case TEAM_ALIENS: if (unlocked) { trap_S_StartLocalSound(cgs.media.weHaveEvolved, CHAN_ANNOUNCER); } break; case TEAM_HUMANS: default: if (unlocked) { trap_S_StartLocalSound(cgs.media.reinforcement, CHAN_ANNOUNCER); } break; } CG_CenterPrint(text, SCREEN_HEIGHT * 0.3, GIANTCHAR_WIDTH * 2); }
/** * Start a competition. * This code needs to track the order of the field starting to ensure that everything happens * in the right order. Repeatedly run the correct method, either Autonomous or OperatorControl * or Test when the robot is enabled. After running the correct method, wait for some state to * change, either the other mode starts or the robot is disabled. Then go back and wait for the * robot to be enabled again. */ void SampleRobot::StartCompetition() { LiveWindow *lw = LiveWindow::GetInstance(); SmartDashboard::init(); NetworkTable::GetTable("LiveWindow")->GetSubTable("~STATUS~")->PutBoolean("LW Enabled", false); RobotMain(); if (!m_robotMainOverridden) { // first and one-time initialization lw->SetEnabled(false); RobotInit(); while (true) { if (IsDisabled()) { m_ds.InDisabled(true); Disabled(); m_ds.InDisabled(false); while (IsDisabled()) sleep(1); //m_ds.WaitForData(); } else if (IsAutonomous()) { m_ds.InAutonomous(true); Autonomous(); m_ds.InAutonomous(false); while (IsAutonomous() && IsEnabled()) sleep(1); //m_ds.WaitForData(); } else if (IsTest()) { lw->SetEnabled(true); m_ds.InTest(true); Test(); m_ds.InTest(false); while (IsTest() && IsEnabled()) sleep(1); //m_ds.WaitForData(); lw->SetEnabled(false); } else { m_ds.InOperatorControl(true); OperatorControl(); m_ds.InOperatorControl(false); while (IsOperatorControl() && IsEnabled()) sleep(1); //m_ds.WaitForData(); } } } }
void QueueListBox::KeyPress(GG::Key key, boost::uint32_t key_code_point, GG::Flags<GG::ModKey> mod_keys) { if (Disabled()) { CUIListBox::KeyPress(key, key_code_point, mod_keys); return; } if (key == GG::GGK_DELETE) { QueueListBox::iterator it = Caret(); if (it == end()) return; QueueItemDeletedSignal(it); } else { CUIListBox::KeyPress(key, key_code_point, mod_keys); } }
static void InformUnlockableStatusChanges( int *statusChanges, int count ) { char text[ MAX_STRING_CHARS ]; char *textptr = text; int unlockableNum; qboolean firstPass = qtrue; unlockable_t *unlockable; for ( unlockableNum = 0; unlockableNum < NUM_UNLOCKABLES; unlockableNum++ ) { unlockable = &unlockables[ unlockableNum ]; if ( !statusChanges[ unlockableNum ] || Disabled( unlockable ) ) { continue; } if ( firstPass ) { if ( statusChanges[ unlockableNum ] > 0 ) { Com_sprintf( text, sizeof( text ), S_COLOR_GREEN "ITEM%s UNLOCKED: " S_COLOR_WHITE, ( count > 1 ) ? "S" : "" ); } else { Com_sprintf( text, sizeof( text ), S_COLOR_RED "ITEM%s LOCKED: " S_COLOR_WHITE, ( count > 1 ) ? "S" : "" ); } textptr = text + strlen( text ); firstPass = qfalse; } else { Com_sprintf( textptr, sizeof( text ) - ( textptr - text ), ", " ); textptr += 2; } Com_sprintf( textptr, sizeof( text ) - ( textptr - text ), "%s", UnlockableHumanName( unlockable ) ); textptr += strlen( textptr ); } Com_Printf( "%s\n", text ); }
void CDestination::SetDisabled( bool disabled) { bool changed = false; if (disabled) changed = _addFlag(DISABLED); else changed = _removeFlag(DISABLED); if (changed) { Disabled(disabled); CUpdateHint hint; hint.AddInt32("DestID", m_id); hint.AddInt32("DestAttrs",Update_Flags); PostUpdate(&hint); } }
void FieldIcon::RClick(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys) { if (!Disabled()) RightClickedSignal(m_field_id); GG::MenuItem menu_contents; TemporaryPtr<const Field> field = GetField(m_field_id); if (!field) return; const std::string& field_type_name = field->FieldTypeName(); if (field_type_name.empty()) return; std::string popup_label = boost::io::str(FlexibleFormat(UserString("ENC_LOOKUP")) % UserString(field_type_name)); menu_contents.next_level.push_back(GG::MenuItem(popup_label, 1, false, false)); GG::PopupMenu popup(pt.x, pt.y, ClientUI::GetFont(), menu_contents, ClientUI::TextColor(), ClientUI::WndOuterBorderColor(), ClientUI::WndColor(), ClientUI::EditHiliteColor()); if (!popup.Run() || popup.MenuID() != 1) return; ClientUI::GetClientUI()->ZoomToFieldType(field_type_name); }
/** * Start a competition. * This code needs to track the order of the field starting to ensure that everything happens * in the right order. Repeatedly run the correct method, either Autonomous or OperatorControl * when the robot is enabled. After running the correct method, wait for some state to change, * either the other mode starts or the robot is disabled. Then go back and wait for the robot * to be enabled again. */ void SimpleRobot::StartCompetition() { nUsageReporting::report(nUsageReporting::kResourceType_Framework, nUsageReporting::kFramework_Simple); RobotMain(); if (!m_robotMainOverridden) { // first and one-time initialization RobotInit(); while (true) { if (IsDisabled()) { m_ds->InDisabled(true); Disabled(); m_ds->InDisabled(false); while (IsDisabled()) m_ds->WaitForData(); } else if (IsAutonomous()) { m_ds->InAutonomous(true); Autonomous(); m_ds->InAutonomous(false); while (IsAutonomous() && IsEnabled()) m_ds->WaitForData(); } else { m_ds->InOperatorControl(true); OperatorControl(); m_ds->InOperatorControl(false); while (IsOperatorControl() && IsEnabled()) m_ds->WaitForData(); } } } }
void FieldIcon::RDoubleClick(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys) { if (!Disabled()) RightDoubleClickedSignal(m_field_id); }
void MAS::SpinButton::Draw(Bitmap &canvas) { Bitmap bmp = GetBitmap(); int state = Disabled() ? 2 : (Selected() ? 1 : (HasFocus() ? 3 : 0)); bmp.StretchBlit(canvas, 0, state*bmp.h()/4, bmp.w(), bmp.h()/4, 0, 0, w(), h()); }
NS_IMETHODIMP StyleSheet::GetDisabled(bool* aDisabled) { *aDisabled = Disabled(); return NS_OK; }
void FieldIcon::LClick(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys) { if (!Disabled()) LeftClickedSignal(m_field_id); ForwardEventToParent(); }