Logo Search packages:      
Sourcecode: vdr-plugin-sudoku version File versions  Download package

eOSState Menu::ProcessKey ( eKeys  key  )  [virtual]

Process user events.

Definition at line 81 of file menu.cpp.

References SudokuPlugin::SetupData::clear_marks, Sudoku::Puzzle::generate(), SudokuPlugin::SetupData::givens_count, Sudoku::Pos::next_col(), Sudoku::Puzzle::next_free(), Sudoku::Puzzle::next_number(), Sudoku::Pos::next_row(), paint(), Sudoku::Pos::prev_col(), Sudoku::Pos::prev_row(), Sudoku::Puzzle::reset(), Sudoku::Puzzle::set(), Sudoku::Puzzle::solved(), SudokuPlugin::SetupData::symmetric, Sudoku::Puzzle::toggle_mark(), and Sudoku::Puzzle::untouched().

{
  eOSState state = cOsdObject::ProcessKey(key);
  if (state == osUnknown)
  {
    if (key == kBack)
      return osEnd;
    if (new_puzzle_request)
    {
      if (key == kOk)
      {
        new_puzzle_request = false;
        puzzle.generate(setup.givens_count, setup.symmetric);
      }
    }
    else
    {
      switch (key)
      {
        case kLeft:
        case kLeft|k_Repeat:
          curr = curr.prev_col();
          break;
        case kRight:
        case kRight|k_Repeat:
          curr = curr.next_col();
          break;
        case kUp:
        case kUp|k_Repeat:
          curr = curr.prev_row();
          break;
        case kDown:
        case kDown|k_Repeat:
          curr = curr.next_row();
          break;
        case k0:
        case k1:
        case k2:
        case k3:
        case k4:
        case k5:
        case k6:
        case k7:
        case k8:
        case k9:
          puzzle.set(curr, key - k0);
          break;
        case kRed:
          puzzle.set(curr, puzzle.next_number(curr));
          break;
        case kGreen:
          puzzle.toggle_mark(curr);
          break;
        case kYellow:
          if (puzzle.next_free(curr) <= Pos::last())
            curr = puzzle.next_free(curr);
          break;
        case kBlue:
          if (puzzle.untouched())
            puzzle.generate(setup.givens_count, setup.symmetric);
          else
            puzzle.reset(setup.clear_marks);
          break;
        default:
          return osContinue;
      }
    }
    if (puzzle.solved())
    {
      new_puzzle_request = true;
      infoText = tr("Congratulations!\nPress OK to start a new puzzle");
    }
    paint();
    state = osContinue;
  }
  return state;
}


Generated by  Doxygen 1.6.0   Back to index