Exemplo n.º 1
0
/**
 * @brief Displays a window with Yes and No buttons.
 *
 * @usage if tk.yesno( "YesNo popup box", "Click yes to do something." ) then -- Clicked yes
 *
 *    @luaparam title Title of the window.
 *    @luaparam message Message to display in the window.
 *    @luareturn true if yes was clicked, false if no was clicked.
 * @luafunc yesno( title, message )
 */
static int tk_yesno( lua_State *L )
{
   int ret;
   const char *title, *str;
   NLUA_MIN_ARGS(2);

   title = luaL_checkstring(L,1);
   str   = luaL_checkstring(L,2);

   ret = dialogue_YesNoRaw( title, str );
   lua_pushboolean(L,ret);
   return 1;
}
Exemplo n.º 2
0
/**
 * @brief Runs a dialogue with both yes and no options.
 *
 *    @param caption Caption to use for the dialogue.
 *    @param fmt Printf style message.
 *    @return 1 if yes is clicked or 0 if no is clicked.
 */
int dialogue_YesNo( const char* caption, const char *fmt, ... )
{
   char msg[4096];
   va_list ap;

   if (fmt == NULL) return -1;
   else { /* get the message */
      va_start(ap, fmt);
      vsnprintf(msg, 4096, fmt, ap);
      va_end(ap);
   }

   return dialogue_YesNoRaw( caption, msg );
}
Exemplo n.º 3
0
Arquivo: options.c Projeto: s0be/naev
/**
 * @brief Sets the default gameplay options.
 */
static void opt_gameplayDefaults( unsigned int wid, char *str )
{
   (void) str;

   /* Ask user. */
   if (!dialogue_YesNoRaw( "Restore Defaults", "Are you sure you want to restore default gameplay settings?" ))
      return;

   /* Restore. */
   conf_setGameplayDefaults();
   opt_gameplayUpdate( wid, NULL );

   /* Alert user it worked. */
   dialogue_msgRaw( "Defaults Restored", "Gameplay settings restored to defaults.");
}
Exemplo n.º 4
0
Arquivo: options.c Projeto: s0be/naev
/**
 * @brief Restores the key defaults.
 */
static void opt_keyDefaults( unsigned int wid, char *str )
{
   (void) str;

   /* Ask user if he wants to. */
   if (!dialogue_YesNoRaw( "Restore Defaults", "Are you sure you want to restore default keybindings?" ))
      return;

   /* Restore defaults. */
   input_setDefault();

   /* Regenerate list widget. */
   window_destroyWidget( wid, "lstKeybinds" );
   menuKeybinds_genList( wid );

   /* Alert user it worked. */
   dialogue_msgRaw( "Defaults Restored", "Keybindings restored to defaults.");
}
Exemplo n.º 5
0
Arquivo: menu.c Projeto: naev/naev
/**
 * @brief Menu to ask if player really wants to quit.
 */
int menu_askQuit (void)
{
   /* Asked twice, quit. */
   if (menu_isOpen( MENU_ASKQUIT )) {
      exit_game();
      return 1;
   }

   /* Ask if should quit. */
   menu_Open( MENU_ASKQUIT );
   if (dialogue_YesNoRaw( _("Quit Naev"), _("Are you sure you want to quit Naev?") )) {
      exit_game();
      return 1;
   }
   menu_Close( MENU_ASKQUIT );

   return 0;
}
Exemplo n.º 6
0
Arquivo: options.c Projeto: s0be/naev
/**
 * @brief Sets the audio defaults.
 */
static void opt_audioDefaults( unsigned int wid, char *str )
{
   (void) str;

   /* Ask user. */
   if (!dialogue_YesNoRaw( "Restore Defaults", "Are you sure you want to restore default audio settings?" ))
      return;

   /* Set defaults. */
   conf_setAudioDefaults();

   /* Have sound levels affect. */
   sound_volume(conf.sound);
	music_volume(conf.music);

   /* Update widgets. */
   opt_audioUpdate( wid, NULL );

   /* Alert user it worked. */
   dialogue_msgRaw( "Defaults Restored", "Audio settings restored to defaults.");
}
Exemplo n.º 7
0
/**
 * @brief Toggles autoweap for the ship.
 */
static void weapons_autoweap( unsigned int wid, char *str )
{
   int state, sure;

   /* Set state. */
   state = window_checkboxState( wid, str );

   /* Run autoweapons if needed. */
   if (state) {
      sure = dialogue_YesNoRaw( "Enable autoweapons?",
            "Are you sure you want to enable automatic weapon groups for the "
            "ship?\n\nThis will overwrite all manually-tweaked weapons groups." );
      if (!sure) {
         window_checkboxSet( wid, str, 0 );
         return;
      }
      player.p->autoweap = 1;
      pilot_weaponAuto( player.p );
      weapons_genList( wid );
   }
   else
      player.p->autoweap = 0;
}