Ejemplo n.º 1
0
bool Engine::Initialize(const Engine::Setting *setting /*= NULL*/)
{
    if (mInited)
        return false;
        
    if (NULL != setting)
        mSetting = *setting;

    bool isOk = true;

    if (isOk) 
        isOk = InitializeScreen();

    if (isOk) 
        isOk = InitializeRenderSystem();

    if (!isOk)
    {
        Finalize();
        return false;
    }

    mInited = true;
    return true;
}
Ejemplo n.º 2
0
/****************************************************************************
  Function:
    void ShowScreenGeneric( void )
  Description:
    This function erases the currently displayed screen and replaces it with
    a screen of a generic format.  The screen consists of:
            * the Microchip icon
            * a one line title
            * four buttons
            * one line of instructions
    The information for the screen contents is obtained from the global
    pageInformation structure.
  Precondition:
    None
  Parameters:
    None
  Returns:
    None
  Remarks:
    The global list of graphics objects is destroyed and replaced.  Therefore,
    this function cannot be called during the message processing of
    GOLMsgCallback().  It must be called during GOLDrawCallback() processing.
  ***************************************************************************/
void ShowScreenGeneric( void )
{
    InitializeScreen();

    BtnCreate(      ID_TOP_LEFT,                // ID
                    0,LOCATION_MIN_Y,62,38,2,   // dimension and radius
                    BTN_DRAW|BTN_PRESSED,       // will be displayed after creation
                    pageInformation.buttonBitmapTopLeft, // bitmap
                    pageInformation.buttonTextTopLeft,   // text
                    NULL );                     // Default scheme

    BtnCreate(      ID_BOTTOM_LEFT,             // ID
                    0,40,62,62,2,               // dimension and radius
                    BTN_DRAW,                   // will be displayed after creation
                    pageInformation.buttonBitmapBottomLeft, // bitmap
                    pageInformation.buttonTextBottomLeft,   // text
                    NULL );                     // Default scheme

    BtnCreate(      ID_TOP_RIGHT,               // ID
                    64,LOCATION_MIN_Y,125,38,2, // dimension and radius
                    BTN_DRAW,                   // will be displayed after creation
                    pageInformation.buttonBitmapTopRight, // bitmap
                    pageInformation.buttonTextTopRight,   // text
                    NULL );                     // Default scheme

    BtnCreate(      ID_BOTTOM_RIGHT,            // ID
                    64,40,125,62,2,             // dimension and radius
                    BTN_DRAW,                   // will be displayed after creation
                    pageInformation.buttonBitmapBottomRight,
                    pageInformation.buttonTextBottomRight,
                    NULL );                     // Default scheme

}
Ejemplo n.º 3
0
static VALUE
Game_window_scale_eq(VALUE self, VALUE rbWindowScale)
{
  Game* game;
  Data_Get_Struct(self, Game, game);
  CheckDisposed(game);
  game->windowScale = NUM2INT(rbWindowScale);
  InitializeScreen(game);
  return Qnil;
}
Ejemplo n.º 4
0
static VALUE
Game_fullscreen_eq(VALUE self, VALUE rbFullscreen)
{
  Game* game;
  Data_Get_Struct(self, Game, game);
  CheckDisposed(game);
  game->isFullscreen = RTEST(rbFullscreen);
  InitializeScreen(game);
  return Qnil;
}
Ejemplo n.º 5
0
int main(void)
{
    InitializeScreen();
    /* Redirect all of std::cout to a curses complaint window */
    toolbox::ncurses_stream redirector_cout(std::cout);
    
#ifdef RT_PRIORITY
    SetProcessPriority(RT_PRIORITY);
#endif

    /* Please check RoboticArtm_Config.h for number of joints*/
    RoboArm = new RoboticArm();
    
    /* Register a signal handler to exit gracefully */
    signal(SIGINT, _cleanup);

    RoboArm->Init();

    logger << "I: Press the arrow keys to control the robotic arm!" << std::endl << std::endl;

    for(;;) {

        /* Used for single line message */
        char buffer[80];        
        
        /* First obtain the actual coordinates of the robot, to move it at will */
        RoboArm->GetPosition(coordinates);

        /* Arrows will increase position by 1% increments in a x,y plane, uses curses library */
        WaitKeyPress(coordinates);

        /* Command the robot to a new position once that coordinates was updated */
        RoboArm->SetPosition(coordinates);
        
        sprintf(buffer, " x= %+3.4f | y= %+3.4f | z= %+3.4f", coordinates.x, coordinates.y, coordinates.z);
        logger << "I: Computed - " << buffer << std::endl;

        /* Updated coordinates and print it out */
        RoboArm->GetPosition(coordinates);

        sprintf(buffer, " x= %+3.4f | y= %+3.4f | z= %+3.4f", coordinates.x, coordinates.y, coordinates.z);
        logger << "I: Measured - " << buffer << std::endl;
        
    }

    return EXIT_SUCCESS;
}
Ejemplo n.º 6
0
  Function:
    void ShowScreenGeneric( void )

  Description:
    This function erases the currently displayed screen and replaces it with
    a screen of a generic format.  The screen consists of:
            * the Microchip icon
            * a one line title
            * four buttons
            * one line of instructions

    The information for the screen contents is obtained from the global
    pageInformation structure.

  Precondition:
    None

  Parameters:
    None

  Returns:
    None

  Remarks:
    The global list of graphics objects is destroyed and replaced.  Therefore,
    this function cannot be called during the message processing of
    GOLMsgCallback().  It must be called during GOLDrawCallback() processing.
  ***************************************************************************/

void ShowScreenGeneric( void )
{
    InitializeScreen();

    BtnCreate(      ID_TOP_LEFT,                // ID
                    0,LOCATION_MIN_Y,62,30,2,   // dimension and radius
                    BTN_DRAW|BTN_PRESSED,       // will be displayed after creation
                    pageInformation.buttonBitmapTopLeft, // bitmap
                    pageInformation.buttonTextTopLeft,   // text
                    NULL );                     // Default scheme

    BtnCreate(      ID_BOTTOM_LEFT,             // ID
                    0,32,62,46,2,               // dimension and radius
                    BTN_DRAW,                   // will be displayed after creation
                    pageInformation.buttonBitmapBottomLeft, // bitmap
                    pageInformation.buttonTextBottomLeft,   // text
                    NULL );                     // Default scheme

    BtnCreate(      ID_TOP_RIGHT,               // ID
                    64,LOCATION_MIN_Y,125,30,2, // dimension and radius
                    BTN_DRAW,                   // will be displayed after creation
                    pageInformation.buttonBitmapTopRight, // bitmap
                    pageInformation.buttonTextTopRight,   // text
                    NULL );                     // Default scheme

    BtnCreate(      ID_BOTTOM_RIGHT,            // ID
                    64,32,125,46,2,             // dimension and radius
                    BTN_DRAW,                   // will be displayed after creation
                    pageInformation.buttonBitmapBottomRight,
                    pageInformation.buttonTextBottomRight,
                    NULL );                     // Default scheme

	
	if(!strcmp(pageInformation.buttonTextThirdrow,"Cap Touch"))
	BtnCreate(		ID_THIRDROW,
					0,48,62,62,2,
					BTN_DRAW,
					pageInformation.buttonBitmapThirdrow,
					pageInformation.buttonTextThirdrow,
					NULL );	else 

    StCreate(       ID_INSTRUCTIONS,
                    0, 47, 127, 47+GetTextHeight( (void *)&FONTDEFAULT )-1,
                    ST_DRAW,
                    pageInformation.instructions,
                    NULL );
}
Ejemplo n.º 7
0
void ShowScreenCTMU( void )
{

    strcpy( pageInformation.title, "Calibrate Touchpads" );
    pageInformation.instructions[0] = 0;

    InitializeScreen();

    StCreate(
                ID_INSTRUCTIONS,
                0, 30, 127, 30+GetTextHeight( (void *)&FONTDEFAULT )-1,
                ST_DRAW,
                pageInformation.instructions,
                NULL );

    // Initialize calibration variables.
    calibrationState    = CTMU_INITIALIZE;
    currentTouchpad     = 0;
}
Ejemplo n.º 8
0
e_Window MainScreen::Render()
{
	InitializeScreen();
	e_Window result;
	startIsSelected = false;

	while (window->isOpen())
	{
		while (window->pollEvent(event))
		{
			window->pollEvent(event);
			
			if (event.type == sf::Event::Closed)
			{
				bool _result = RenderClosing();
				if (_result)
					return exitSignal;
			}

			DefaultButtonColors();

			if (startIsSelected)
			{ // Game mode choices will be rendered.
				ShowGameModeChoices();
			}

			switch (event.type)
			{
			case sf::Event::MouseMoved:
				ControlMouseMoved();
				break;
			case sf::Event::MouseButtonPressed:
				result = ControlMousePressed();
				if( result!=noChange )
					return result; 
				break;
			case sf::Event::Closed:
				return exitSignal;
			default:
				break;
			}

			window->clear();
			drawBackground();

			window->draw(recButton_Exit);

			if (!startIsSelected)
			{ // Nothing is selected.
				window->draw(recButton_StartAGame);
				window->draw(text_StartAGame);
				window->draw(text_Exit);
			}
			else
			{ // Start is selected.
				window->draw(recButton_Scenario);
				window->draw(text_SelectAScenario);

				window->draw(recButton_Random);
				window->draw(text_RandomMatch);

				window->draw(recButton_Custom);
				window->draw(text_CustomMatch);

				window->draw(text_Back);
			}
			window->draw(recButton_English);
			window->draw(recButton_Turkish);
			window->draw(text_English);
			window->draw(text_Turkish);

			window->display();
		}

	}
}
void HandleScreen(int _msqid)
{
     int msqid = _msqid;
     int width, height;
     int curx = 0, cury = 0;
     textmsg msg;

     InitCurses();

     pthread_mutex_lock(&count_mutex);
     pthread_cond_signal(&count_threshold_cv);
     pthread_mutex_unlock(&count_mutex);

     getmaxyx(stdscr, height, width);

     class CursesWindow inputWin, tmpWin;

     inputWin.set(InitializeScreen(0, (height/2), width, height/2, false));

     tmpWin.set(InitializeScreen(0, 0, width, height/2, true));
     class CursesListWindow outputWin(tmpWin);


     while(true) {
          if (msgrcv(msqid, &msg, sizeof(msg) - sizeof(long), TYPE_QUIT, IPC_NOWAIT) == -1) {
               if (msgrcv(msqid, &msg, sizeof(msg) - sizeof(long), TYPE_MSG, IPC_NOWAIT) == -1) {
                    continue;
               }

               if (msg.mwindow == WINDOW_INPUT) {
                    if ((msg.mproperties & PROP_CLEAR) == PROP_CLEAR) {
                         inputWin.clear();
                    }

                    if((msg.mproperties & PROP_DEL) == PROP_DEL) {
                         inputWin.deleteChar();
                    } else {

                         if ((msg.mproperties & (PROP_TOP | PROP_BOTTOM)) == (PROP_TOP | PROP_BOTTOM)) {
                              continue;
                         } else if ((msg.mproperties & PROP_TOP) == PROP_TOP) {
                              inputWin.move(0, 1);
                         } else if ((msg.mproperties & PROP_BOTTOM) == PROP_BOTTOM) {
                              inputWin.move(0, inputWin.getHeight() - 1);
                         }

                         inputWin.stdWrite(msg.mtext);
                    }

                    getyx(inputWin.getWindow(), cury, curx);

                    inputWin.setCursorx(curx);
                    inputWin.setCursory(cury);

                    inputWin.refresh();

               } else if (msg.mwindow == WINDOW_OUTPUT) {

                    outputWin.clear();

                    outputWin.move(0, 0);

                    outputWin.stdWrite(msg.mtext);

                    getyx(outputWin.getWindow(), cury, curx);

                    outputWin.setCursorx(curx);
                    outputWin.setCursory(cury);

                    outputWin.drawBottomLine();

                    outputWin.refresh();
               }


          } else {
               break;
          }
     }

     // cleaning up
     endwin();
     pthread_exit(NULL);
}
Ejemplo n.º 10
0
void ShowScreenTime( void )
{
    WORD    textHeight;
    WORD    textWidth;

    strcpy( pageInformation.title, "Set Date/Time" );

    InitializeScreen();

    RTCCProcessEvents();

    // Draw the hidden controls.

    BtnCreate(
                        ID_RTCC_BUTTON_HOME,
                        GetMaxX()-8, 0, GetMaxX()-6, 4, 0,
                        BTN_HIDE,
                        NULL,
                        NULL,
                        NULL );

    BtnCreate(
                        ID_RTCC_BUTTON_NEXT,
                        GetMaxX()-6, 0, GetMaxX()-4, 4, 0,
                        BTN_HIDE,
                        NULL,
                        NULL,
                        NULL );

    BtnCreate(
                        ID_RTCC_BUTTON_PREVIOUS,
                        GetMaxX()-4, 0, GetMaxX()-2, 4, 0,
                        BTN_HIDE,
                        NULL,
                        NULL,
                        NULL );

    // -------------------------------------------------------------------------
    // Create Month, Day and Year Edit Boxes and Buttons

    textWidth  = GetTextWidth( "Mmm", (void *)&FONTDEFAULT );
    textHeight = GetTextHeight( (void *)&FONTDEFAULT ) + 2*GOL_EMBOSS_SIZE;

    // Create the month components

    EbCreate(
                ID_MONTH,
                MONTH_START_X,
                MONTH_START_Y,
                MONTH_END_X,
                MONTH_END_Y,
                EB_DRAW,                    // will be dislayed after creation
                &_date_str[0],              // use the month string value
                3,                          // max characters is 3
                NULL );                     // default GOL scheme

    BtnCreate(
                ID_MONTH_PLUS,
                MONTH_BUTTON_START_X,
                MONTH_START_Y,
                MONTH_BUTTON_END_X,
                MONTH_START_Y + (textHeight >> 1),
                0,                          // draw rectangular button
                BTN_DRAW,                   // will be dislayed after creation
                NULL,                       // no bitmap
                "+",                        // DOWN arrow as text
                NULL );                     // use navigation scheme

    BtnCreate(  ID_MONTH_MINUS,
                MONTH_BUTTON_START_X,
                MONTH_START_Y + (textHeight >> 1),
                MONTH_BUTTON_END_X,
                MONTH_END_Y,
                0,                          // draw rectangular button
                BTN_DRAW,                   // will be dislayed after creation
                NULL,                       // no bitmap
                "-",                        // DOWN arrow as text
                NULL );                     // use navigation scheme

    // Create the day components

    textWidth  = GetTextWidth( "MM", (void *)&FONTDEFAULT );

    EbCreate(
                ID_DAY,
                DAY_START_X,
                DAY_START_Y,
                DAY_END_X,
                DAY_END_Y,
                EB_DRAW,                    // will be dislayed after creation
                &_date_str[4],              // use the day string value
                2,                          // max characters is 3
                NULL );                     // default GOL scheme

    BtnCreate(
                ID_DAY_PLUS,
                DAY_BUTTON_START_X,
                DAY_START_Y,
                DAY_BUTTON_END_X,
                DAY_START_Y + (textHeight >> 1),
                0,                          // draw rectangular button
                BTN_DRAW,                   // will be dislayed after creation
                NULL,                       // no bitmap
                "+",                        // DOWN arrow as text
                NULL );                     // use navigation scheme

    BtnCreate(  ID_DAY_MINUS,
                DAY_BUTTON_START_X,
                DAY_START_Y + (textHeight >> 1),
                DAY_BUTTON_END_X,
                DAY_END_Y,
                0,                          // draw rectangular button
                BTN_DRAW,                   // will be dislayed after creation
                NULL,                       // no bitmap
                "-",                        // DOWN arrow as text
                NULL );                     // use navigation scheme

    // Create the year components

    textWidth  = GetTextWidth( "MM00", (void *)&FONTDEFAULT );

    EbCreate(
                ID_YEAR,
                YEAR_START_X,
                YEAR_START_Y,
                YEAR_END_X,
                YEAR_END_Y,
                EB_DRAW,                // will be dislayed after creation
                &_date_str[8],          // use the year string value
                4,                      // max characters is 4
                NULL );                 // default GOL scheme

    BtnCreate(
                ID_YEAR_PLUS,
                YEAR_BUTTON_START_X,
                YEAR_START_Y,
                YEAR_BUTTON_END_X,
                YEAR_START_Y + (textHeight >> 1),
                0,                          // draw rectangular button
                BTN_DRAW,                   // will be dislayed after creation
                NULL,                       // no bitmap
                "+",                        // DOWN arrow as text
                NULL );                     // use navigation scheme

    BtnCreate(  ID_YEAR_MINUS,
                YEAR_BUTTON_START_X,
                YEAR_START_Y + (textHeight >> 1),
                YEAR_BUTTON_END_X,
                YEAR_END_Y,
                0,                          // draw rectangular button
                BTN_DRAW,                   // will be dislayed after creation
                NULL,                       // no bitmap
                "-",                        // DOWN arrow as text
                NULL );                     // use navigation scheme

    // -------------------------------------------------------------------------
    // Create the Hour and Minute Edit Boxes and Buttons

    textWidth  = GetTextWidth( "MM", (void *)&FONTDEFAULT ) + (GOL_EMBOSS_SIZE<<1);

    // Create the hour components

    EbCreate(
                ID_HOUR,
                HOUR_START_X,
                HOUR_START_Y,
                HOUR_END_X,
                HOUR_END_Y,
                EB_DRAW,
                &_time_str[4],
                2,
                NULL );

    BtnCreate(
                ID_HOUR_PLUS,
                HOUR_BUTTON_START_X,
                HOUR_START_Y,
                HOUR_BUTTON_END_X,
                HOUR_START_Y + (textHeight >> 1),
                0,
                BTN_DRAW,
                NULL,
                "+",
                NULL );

    BtnCreate(  ID_HOUR_MINUS,
                HOUR_BUTTON_START_X,
                HOUR_START_Y + (textHeight >> 1),
                HOUR_BUTTON_END_X,
                HOUR_END_Y,
                0,
                BTN_DRAW,
                NULL,
                "-",
                NULL );

    // Create the minute components

    EbCreate(
                ID_MINUTE,
                MINUTE_START_X,
                MINUTE_START_Y,
                MINUTE_END_X,
                MINUTE_END_Y,
                EB_DRAW,                // will be dislayed after creation
                &_time_str[7],          // use minute string value
                2,                      // max characters is 2
                NULL );                 // default GOL scheme

    BtnCreate(
                ID_MINUTE_PLUS,
                MINUTE_BUTTON_START_X,
                MINUTE_START_Y,
                MINUTE_BUTTON_END_X,
                MINUTE_START_Y + (textHeight >> 1),
                0,                          // draw rectangular button
                BTN_DRAW,                   // will be dislayed after creation
                NULL,                       // no bitmap
                "+",                        // DOWN arrow as text
                NULL );                     // use navigation scheme

    BtnCreate(  ID_MINUTE_MINUS,
                MINUTE_BUTTON_START_X,
                MINUTE_START_Y + (textHeight >> 1),
                MINUTE_BUTTON_END_X,
                MINUTE_END_Y,
                0,                          // draw rectangular button
                BTN_DRAW,                   // will be dislayed after creation
                NULL,                       // no bitmap
                "-",                        // DOWN arrow as text
                NULL );                     // use navigation scheme


    currentControlSet = CONTROL_SET_MONTH;
    IndicateFocus( WHITE );

}
Ejemplo n.º 11
0
static VALUE
Game_initialize(int argc, VALUE* argv, VALUE self)
{
  if (!NIL_P(Game_s_current(rb_cGame))) {
    rb_raise(strb_GetStarRubyErrorClass(), "already run");
  }

  volatile VALUE rbWidth, rbHeight, rbOptions;
  rb_scan_args(argc, argv, "21", &rbWidth, &rbHeight, &rbOptions);
  if (NIL_P(rbOptions)) {
    rbOptions = rb_hash_new();
  } else {
    Check_Type(rbOptions, T_HASH);
  }
  Game* game;
  Data_Get_Struct(self, Game, game);

  if (SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_TIMER)) {
    rb_raise_sdl_error();
  }

  const int width  = NUM2INT(rbWidth);
  const int height = NUM2INT(rbHeight);

  volatile VALUE rbFps = rb_hash_aref(rbOptions, symbol_fps);
  Game_fps_eq(self, !NIL_P(rbFps) ? rbFps : INT2FIX(30));

  volatile VALUE rbTitle = rb_hash_aref(rbOptions, symbol_title);
  Game_title_eq(self, !NIL_P(rbTitle) ? rbTitle : rb_str_new2(""));

  bool cursor = false;

  volatile VALUE val;
  Check_Type(rbOptions, T_HASH);
  if (!NIL_P(val = rb_hash_aref(rbOptions, symbol_cursor))) {
    cursor = RTEST(val);
  }
  if (!NIL_P(val = rb_hash_aref(rbOptions, symbol_fullscreen))) {
    game->isFullscreen = RTEST(val);
  }
  if (!NIL_P(val = rb_hash_aref(rbOptions, symbol_window_scale))) {
    game->windowScale = NUM2INT(val);
    if (game->windowScale < 1) {
      rb_raise(rb_eArgError, "invalid window scale: %d",
               game->windowScale);
    }
  }
  if (!NIL_P(val = rb_hash_aref(rbOptions, symbol_vsync))) {
    game->isVsync = RTEST(val);
  }

  SDL_ShowCursor(cursor ? SDL_ENABLE : SDL_DISABLE);

  volatile VALUE rbScreen =
    rb_class_new_instance(2, (VALUE[]){INT2NUM(width), INT2NUM(height)},
                          strb_GetTextureClass());
  game->screen = rbScreen;

  InitializeScreen(game);

  rb_iv_set(rb_cGame, "current", self);

  return Qnil;
}