Ejemplo n.º 1
0
void decrementCursor() {
	if (getCursorX() < 1) {
		if (getCursorY() < 1) {
			setCursorY(0);
			setCursorX(current_video_mode->width);
		} else {
			setCursorY(getCursorY() - 1);
			setCursorX(current_video_mode->width);
		}
		return;
	}
	setCursorX(getCursorX() - 1);
}
Ejemplo n.º 2
0
void incrementCursor() {
	if (getCursorX() >= current_video_mode->width) {
		setCursorX(0);
		if (getCursorY() >= current_video_mode->height - 1)
		{
			newLine();
			setCursorY(current_video_mode->height - 1);
		}
		else
			setCursorY(getCursorY() + 1);
		return;
	} else {
		setCursorX(getCursorX() + 1);
	}

}
Ejemplo n.º 3
0
void video_reload() { 
	int x, y;
	int old_x = getCursorX();
	int old_y = getCursorY();
	setCursor(FALSE);
	for(x = 0; x < current_video_mode->width; ++x)
	{
		for(y = 0; y < current_video_mode->height; ++y)
		{
			setCursorX(x);
			setCursorY(y);
			putC(current_video_mode->screen[x][y]);
		}
	}
	setCursor(TRUE);
	setCursorX(old_x);
	setCursorY(old_y);
}
Ejemplo n.º 4
0
char *screen::input()
{
  activate();
  
  static char ac[1024];

  int i = 0;
  while (nInput2 != Qt::Key_Enter && nInput2 != Qt::Key_Return){
    if (nInput2 != 0xffff){ // no key pressed = 0xffff

 // QMessageBox::information(this, "", QString("%1").arg(nInput2));

      if (nInput2 == Qt::Key_Backspace){
        if (i > 0){ // backspace
         i--;

         decCursorX();
         static QString ss = QString(QChar(' '));
         print(ss);
         decCursorX();
        }

        nInput2 = 0xffff; // no key pressed
        bInputted = false;
      } else if (nInput2 >= 32){

       QChar *c = sInput.data();
       ac[i] = c->toAscii();       

       print(sInput);
       nInput2 = 0xffff; // no key pressed
       bInputted = false;
       i++;
       if (i > 1023) break;
      
      } else { // ignore special keys
       nInput2 = 0xffff; // no key pressed
       bInputted = false;
      }
    }
    update();
    qApp->processEvents(QEventLoop::AllEvents, 100);
  };  

  setCursorX(1);
  incCursorY();

  nInput2 = 0xffff; // no key pressed
  bInputted = false;

	ac[i] = '\0';  

  return ac;  
}
Ejemplo n.º 5
0
// Clears the screen from the given cursor to the end of the page.
// And rolls the cursor back.
void clear_screen_topdown() {
	int i = 0;
	int x = getCursorX();
	int y = getCursorY();
	setCursor(FALSE);
	while (i++ < (current_video_mode->width * (current_video_mode->height
			- y)) - x) {
		putchar(' ');
	}
	setCursor(TRUE);
	setCursorX(x);
	setCursorY(y);
}
Ejemplo n.º 6
0
void Screen::setCursorYX(int y, int x)
{
    setCursorY(y); setCursorX(x);
}
Ejemplo n.º 7
0
// Starts default video.
void initVideo() {
	clear_screen();
	setCursorX(0);
	setCursorY(0);
}
Ejemplo n.º 8
0
void moveCursorToStart() {
	setCursorX(0);
	setCursorY(0);
}
Ejemplo n.º 9
0
void Mouse::think()
{
    if (_animation) _animation->think();
    SDL_GetMouseState(&_cursorX, &_cursorY);

    auto game = &Game::getInstance();
    auto location = game->location();

    if (location && game->states()->back()->scrollable())
    {
        //check if cursor in the scrolling area
        if (cursorX() < 5) // LEFT
        {
            if (cursorY() < 5) //  LEFT-UP
            {
                auto moved = location->scroll(true, false, true, false);
                setType( moved ? Mouse::SCROLL_NW : Mouse::SCROLL_NW_X);
            }
            else if (cursorY() > 475) //LEFT-DOWN
            {
                auto moved = location->scroll(false, true, true, false);
                setType(moved ? Mouse::SCROLL_SW : Mouse::SCROLL_SW_X);
            }
            else
            {
                auto moved = location->scroll(false, false, true, false);
                setType(moved ? Mouse::SCROLL_W : Mouse::SCROLL_W_X);
            }
        }
        else if (cursorX() > 635) // RIGHT
        {
            if (cursorY() < 5) //  RIGHT-UP
            {
                auto moved = location->scroll(true, false, false, true);
                setType(moved ? Mouse::SCROLL_NE : Mouse::SCROLL_NE_X);
            }
            else if (cursorY() > 475) //RIGHT-DOWN
            {
                auto moved = location->scroll(false, true, false, true);
                setType(moved ? Mouse::SCROLL_SE : Mouse::SCROLL_SE_X);
            }
            else
            {
                auto moved = location->scroll(false, false, false, true);
                setType(moved ? Mouse::SCROLL_E : Mouse::SCROLL_E_X);
            }
        }
        else if (cursorY() < 5) // UP
        {
            auto moved = location->scroll(true, false, false, false);
            setType(moved ? Mouse::SCROLL_N : Mouse::SCROLL_N_X);
        }
        else if (cursorY() > 475) // DOWN
        {
            auto moved = location->scroll(false, true, false, false);
            setType(moved ? Mouse::SCROLL_S : Mouse::SCROLL_S_X);
        }
        else if (_type != _lastType)
        {
            setType(_lastType);
        }

        switch (type())
        {
            case HEXAGON_RED:
                auto location = Game::getInstance().location();
                int x = location->camera()->x() + this->cursorX();
                int y = location->camera()->y() + this->cursorY();
                unsigned int hexagon = location->positionToHexagon(x, y);
                setCursorX(location->hexagonToX(hexagon) - location->camera()->x());
                setCursorY(location->hexagonToY(hexagon) - location->camera()->y());
                break;
        }
    }
}