/** * Same as setPower, but ranges from 0-800 for PID controller */ void setPower800(uint8_t motor, uint16_t power800) { if (power800 > MAXPOW800) power800 = MAXPOW800; if (motor) { OCR1B = MAXTIMER - power800 * (MAXTIMER/800); // opposite phase moving1 = power800 ? 1 : 0; } else { OCR1A = power800 * (MAXTIMER/800); moving0 = power800 ? 1 : 0; } updateArrows(); }
/** * Sets the power of the motor. To use with timer1. * - 0 for pin PB1 / OC1A * - 1 for pin PB2 / OC1B * Ranges from 0 to MAXPOWER */ void setPower(uint8_t motor, uint16_t power) { if (power > MAXPOWER) power = MAXPOWER; if (motor) { OCR1B = MAXTIMER - power; // opposite phase moving1 = power ? 1 : 0; } else { OCR1A = power; moving0 = power ? 1 : 0; } updateArrows(); }
/** * Sorts the saves by date. * @param action Pointer to an action. */ void SavedGameState::sortDateClick(Action *) { if (Options::saveOrder == SORT_DATE_ASC) { Options::saveOrder = SORT_DATE_DESC; } else { Options::saveOrder = SORT_DATE_ASC; } updateArrows(); _lstSaves->clearList(); sortList(Options::saveOrder); }
Private(const KoColor &fgColor, const KoColor &bgColor, QWidget *_dialogParent, const KoColorDisplayRendererInterface *_displayRenderer) : dialogParent(_dialogParent) , dragFlag( false ) , miniCtlFlag( false ) , foregroundColor(fgColor) , backgroundColor(bgColor) , displayRenderer(_displayRenderer) { updateArrows(); resetPixmap = QPixmap( (const char **)dcolorreset_xpm ); popDialog = true; }
/** * Sorts the saves by name. * @param action Pointer to an action. */ void ListGamesState::sortNameClick(Action *) { if (_sortable) { if (Options::saveOrder == SORT_NAME_ASC) { Options::saveOrder = SORT_NAME_DESC; } else { Options::saveOrder = SORT_NAME_ASC; } updateArrows(); _lstSaves->clearList(); sortList(Options::saveOrder); } }
/** * Initializes all the elements in the Saved Game screen. * @param game Pointer to the core game. * @param origin Game section that originated this state. */ SavedGameState::SavedGameState(Game *game, OptionsOrigin origin, int firstValidRow) : State(game), _origin(origin), _showMsg(true), _noUI(false), _firstValidRow(firstValidRow) { _screen = false; // Create objects _window = new Window(this, 320, 200, 0, 0, POPUP_BOTH); _btnCancel = new TextButton(80, 16, 120, 172); _txtTitle = new Text(310, 17, 5, 8); _txtDelete = new Text(310, 9, 5, 24); _txtName = new Text(150, 9, 16, 32); _txtDate = new Text(110, 9, 204, 32); _txtStatus = new Text(320, 17, 0, 92); _lstSaves = new TextList(288, 112, 8, 40); _txtDetails = new Text(288, 9, 16, 160); _sortName = new ArrowButton(ARROW_NONE, 11, 8, 16, 32); _sortDate = new ArrowButton(ARROW_NONE, 11, 8, 204, 32); // Set palette if (_origin != OPT_BATTLESCAPE) { _game->setPalette(_game->getResourcePack()->getPalette("BACKPALS.DAT")->getColors(Palette::blockOffset(6)), Palette::backPos, 16); } add(_window); add(_btnCancel); add(_txtTitle); add(_txtDelete); add(_txtName); add(_txtDate); add(_lstSaves); add(_txtStatus); add(_txtDetails); add(_sortName); add(_sortDate); // Set up objects _window->setColor(Palette::blockOffset(8)+5); _window->setBackground(game->getResourcePack()->getSurface("BACK01.SCR")); _btnCancel->setColor(Palette::blockOffset(8)+5); _btnCancel->setText(tr("STR_CANCEL_UC")); _btnCancel->onMouseClick((ActionHandler)&SavedGameState::btnCancelClick); _btnCancel->onKeyboardPress((ActionHandler)&SavedGameState::btnCancelClick, Options::keyCancel); _txtTitle->setColor(Palette::blockOffset(15)-1); _txtTitle->setBig(); _txtTitle->setAlign(ALIGN_CENTER); _txtDelete->setColor(Palette::blockOffset(15)-1); _txtDelete->setAlign(ALIGN_CENTER); _txtDelete->setText(tr("STR_RIGHT_CLICK_TO_DELETE")); _txtName->setColor(Palette::blockOffset(15)-1); _txtName->setText(tr("STR_NAME")); _txtDate->setColor(Palette::blockOffset(15)-1); _txtDate->setText(tr("STR_DATE")); _txtStatus->setColor(Palette::blockOffset(8)+5); _txtStatus->setBig(); _txtStatus->setAlign(ALIGN_CENTER); _lstSaves->setColor(Palette::blockOffset(8)+10); _lstSaves->setArrowColor(Palette::blockOffset(8)+5); _lstSaves->setColumns(3, 188, 60, 40); _lstSaves->setSelectable(true); _lstSaves->setBackground(_window); _lstSaves->setMargin(8); _lstSaves->onMouseOver((ActionHandler)&SavedGameState::lstSavesMouseOver); _lstSaves->onMouseOut((ActionHandler)&SavedGameState::lstSavesMouseOut); _txtDetails->setColor(Palette::blockOffset(15)-1); _txtDetails->setSecondaryColor(Palette::blockOffset(8)+10); _txtDetails->setText(tr("STR_DETAILS").arg(L"")); _sortName->setX(_sortName->getX() + _txtName->getTextWidth() + 5); _sortName->setColor(Palette::blockOffset(15)-1); _sortName->onMouseClick((ActionHandler)&SavedGameState::sortNameClick); _sortDate->setX(_sortDate->getX() + _txtDate->getTextWidth() + 5); _sortDate->setColor(Palette::blockOffset(15)-1); _sortDate->onMouseClick((ActionHandler)&SavedGameState::sortDateClick); updateArrows(); }
/** * Initializes all the elements in the Saved Game screen. * @param game Pointer to the core game. * @param origin Game section that originated this state. * @param firstValidRow First row containing saves. * @param autoquick Show auto/quick saved games? */ ListGamesState::ListGamesState(OptionsOrigin origin, int firstValidRow, bool autoquick) : _origin(origin), _firstValidRow(firstValidRow), _autoquick(autoquick), _sortable(true) { _screen = false; // Create objects _window = new Window(this, 320, 200, 0, 0, POPUP_BOTH); _btnCancel = new TextButton(80, 16, 120, 172); _txtTitle = new Text(310, 17, 5, 7); _txtDelete = new Text(310, 9, 5, 23); _txtName = new Text(150, 9, 16, 32); _txtDate = new Text(110, 9, 204, 32); _lstSaves = new TextList(288, 112, 8, 42); _txtDetails = new Text(288, 16, 16, 156); _sortName = new ArrowButton(ARROW_NONE, 11, 8, 16, 32); _sortDate = new ArrowButton(ARROW_NONE, 11, 8, 204, 32); // Set palette setInterface("geoscape", true, _game->getSavedGame() ? _game->getSavedGame()->getSavedBattle() : 0); add(_window, "window", "saveMenus"); add(_btnCancel, "button", "saveMenus"); add(_txtTitle, "text", "saveMenus"); add(_txtDelete, "text", "saveMenus"); add(_txtName, "text", "saveMenus"); add(_txtDate, "text", "saveMenus"); add(_lstSaves, "list", "saveMenus"); add(_txtDetails, "text", "saveMenus"); add(_sortName, "text", "saveMenus"); add(_sortDate, "text", "saveMenus"); // Set up objects _window->setBackground(_game->getMod()->getSurface("BACK01.SCR")); _btnCancel->setText(tr("STR_CANCEL_UC")); _btnCancel->onMouseClick((ActionHandler)&ListGamesState::btnCancelClick); _btnCancel->onKeyboardPress((ActionHandler)&ListGamesState::btnCancelClick, Options::keyCancel); _txtTitle->setBig(); _txtTitle->setAlign(ALIGN_CENTER); _txtDelete->setAlign(ALIGN_CENTER); _txtDelete->setText(tr("STR_RIGHT_CLICK_TO_DELETE")); _txtName->setText(tr("STR_NAME")); _txtDate->setText(tr("STR_DATE")); _lstSaves->setColumns(3, 188, 60, 40); _lstSaves->setSelectable(true); _lstSaves->setBackground(_window); _lstSaves->setMargin(8); _lstSaves->onMouseOver((ActionHandler)&ListGamesState::lstSavesMouseOver); _lstSaves->onMouseOut((ActionHandler)&ListGamesState::lstSavesMouseOut); _lstSaves->onMousePress((ActionHandler)&ListGamesState::lstSavesPress); _txtDetails->setWordWrap(true); _txtDetails->setText(tr("STR_DETAILS").arg(L"")); _sortName->setX(_sortName->getX() + _txtName->getTextWidth() + 5); _sortName->onMouseClick((ActionHandler)&ListGamesState::sortNameClick); _sortDate->setX(_sortDate->getX() + _txtDate->getTextWidth() + 5); _sortDate->onMouseClick((ActionHandler)&ListGamesState::sortDateClick); updateArrows(); }