10#include "SDL_events.h"
20#include "dev_mapedit.h"
21#include "dev_uniedit.h"
43#include "tk/toolkit_priv.h"
49#define MENU_HEIGHT 250
51#define DEATH_WIDTH 200
52#define DEATH_HEIGHT 200
54#define BUTTON_WIDTH 160
55#define BUTTON_HEIGHT 30
57#define EDITORS_EXTRA_WIDTH 60
59#define menu_Open( f ) ( menu_open |= ( f ) )
60#define menu_Close( f ) \
61 ( menu_open &= ~( f ) )
64int bg_needs_reset = 1;
67static int menu_small_allowsave = 1;
73static void menu_exit(
unsigned int wid,
const char *str );
75static int menu_main_bkg_system(
void );
76static void main_menu_promptClose(
unsigned int wid,
const char *unused );
77static void menu_main_load(
unsigned int wid,
const char *str );
78static void menu_main_new(
unsigned int wid,
const char *str );
79static void menu_main_credits(
unsigned int wid,
const char *str );
80static void menu_main_cleanBG(
unsigned int wid,
const char *str );
82static void menu_small_load(
unsigned int wid,
const char *str );
83static void menu_small_resume(
unsigned int wid,
const char *str );
84static void menu_small_info(
unsigned int wid,
const char *str );
85static void menu_small_exit(
unsigned int wid,
const char *str );
86static void exit_game(
void );
88static void menu_death_continue(
unsigned int wid,
const char *str );
89static void menu_death_restart(
unsigned int wid,
const char *str );
90static void menu_death_main(
unsigned int wid,
const char *str );
91static void menu_death_close(
unsigned int wid,
const char *str );
95static void menu_editors_open(
unsigned int wid_unused,
const char *unused );
96static void menu_editors_close(
unsigned int wid,
const char *str );
98static void menu_options_button(
unsigned int wid,
const char *str );
105static int menu_main_bkg_system(
void )
107 if ( !bg_needs_reset ) {
154 cx += SCREEN_W / 4. / conf.zoom_far;
155 cy += SCREEN_H / 8. / conf.zoom_far;
172 int offset_logo, offset_wdw, freespace;
173 unsigned int bwid, wid;
178 WARN( _(
"Menu main is already open." ) );
193 render_postprocessCleanup();
202 menu_main_bkg_system();
207 if ( conf.devmode ) {
213 freespace = SCREEN_H - tex->
sh - h;
214 if ( freespace < 0 ) {
215 offset_logo = SCREEN_W - tex->
sh;
220 offset_logo = -freespace / 4;
221 offset_wdw = freespace / 2;
228 window_addImage( bwid, ( SCREEN_W - tex->
sw ) / 2., offset_logo, 0, 0,
230 window_addText( bwid, 0, 10, SCREEN_W, 30., 1,
"txtBG", NULL, &cWhite,
234 wid =
window_create(
"wdwMainMenu", _(
"Main Menu" ), -1, offset_wdw,
240 _(
"Load Game" ), menu_main_load, SDLK_l );
243 _(
"New Game" ), menu_main_new, SDLK_n );
245 if ( conf.devmode ) {
247 _(
"Editors" ), menu_editors_open, SDLK_e );
251 _(
"Options" ), menu_options_button, SDLK_o );
254 p_(
"Menu|",
"Credits" ), menu_main_credits, SDLK_c );
257 _(
"Exit Game" ), menu_exit, SDLK_x );
261 window_disableButton( wid,
"btnLoad" );
281 int w, h, bgw, bgh, tw, th;
282 int offset_logo, offset_wdw, freespace;
294 freespace = SCREEN_H - main_naevLogo->sh - h;
295 if ( freespace < 0 ) {
296 offset_logo = SCREEN_H - main_naevLogo->sh;
299 offset_logo = -freespace / 4;
300 offset_wdw = freespace / 2;
308 if ( tw > SCREEN_W ) {
313 wgt->x = ( SCREEN_W - tw ) / 2;
323static void main_menu_promptClose(
unsigned int wid,
const char *unused )
336 unsigned int wid =
window_get(
"wdwMainMenu" );
339 WARN( _(
"Main menu does not exist." ) );
348static void menu_main_load(
unsigned int wid,
const char *str )
358static void menu_main_new(
unsigned int wid,
const char *str )
375static void menu_main_credits(
unsigned int wid,
const char *str )
391static void menu_exit(
unsigned int wid,
const char *str )
403static void menu_main_cleanBG(
unsigned int wid,
const char *str )
409 main_naevLogo = NULL;
420void menu_small(
int docheck,
int info,
int options,
int allowsave )
428 ( player_isFlag( PLAYER_DESTROYED ) ||
436 can_save = allowsave &&
landed && !player_isFlag( PLAYER_NOSAVE );
437 menu_small_allowsave = allowsave;
439 h = MENU_HEIGHT - (
BUTTON_HEIGHT + 20 ) * ( !info + !options );
440 y = 20 + (
BUTTON_HEIGHT + 20 ) * ( 2 + !!info + !!options );
441 wid =
window_create(
"wdwMenuSmall", _(
"Menu" ), -1, -1, MENU_WIDTH,
447 _(
"Resume" ), menu_small_resume, SDLK_r );
451 _(
"Info" ), menu_small_info, SDLK_i );
455 can_save ? _(
"Load / Save" ) : _(
"Load" ),
456 menu_small_load, SDLK_l );
460 "btnOptions", _(
"Options" ), menu_options_button,
465 _(
"Exit to Title" ), menu_small_exit, SDLK_x );
475static void menu_small_load(
unsigned int wid,
const char *str )
489static void menu_small_resume(
unsigned int wid,
const char *str )
504 WARN( _(
"Small menu does not exist." ) );
514static void menu_small_info(
unsigned int wid,
const char *str )
522static int menu_small_exit_hook(
void *unused )
541 unsigned int info_wid =
window_get(
"wdwInfo" );
549 NTracingMessageL(
"Exited to main menu" );
563static void menu_small_exit(
unsigned int wid,
const char *str )
570 _(
"Exit to Menu?" ),
571 _(
"Are you sure you wish to exit to menu right now? The game "
572 "#rwill not be saved#0 since last time you landed!" ) ) )
578 SDL_memset( &event, 0,
sizeof( event ) );
580 SDL_PushEvent( &event );
588static void exit_game(
void )
596 quit.type = SDL_QUIT;
597 SDL_PushEvent( &
quit );
604static void menu_death_continue(
unsigned int wid,
const char *str )
613 player.ps.death_counter++;
620static void menu_death_restart(
unsigned int wid,
const char *str )
637 wid =
window_create(
"wdwRIP", _(
"Death" ), -1, -1, DEATH_WIDTH,
645 window_addButtonKey( wid, 20, 20 +
BUTTON_HEIGHT * 2 + 20 * 2,
647 _(
"Continue" ), menu_death_continue, SDLK_c );
649 window_addButtonKey( wid, 20, 20 +
BUTTON_HEIGHT * 2 + 20 * 2,
651 _(
"Restart" ), menu_death_restart, SDLK_r );
655 menu_death_main, SDLK_m );
657 _(
"Exit Game" ), menu_exit, SDLK_x );
668static void menu_death_main(
unsigned int wid,
const char *str )
681static void menu_death_close(
unsigned int wid,
const char *str )
691static void menu_options_button(
unsigned int wid,
const char *str )
712 _(
"Are you sure you want to quit Naev?" ) ) ) {
724static void menu_editors_open(
unsigned int wid,
const char *unused )
746 MENU_WIDTH + EDITORS_EXTRA_WIDTH, h );
750 window_addButtonKey( wid, 20, y,
BUTTON_WIDTH + EDITORS_EXTRA_WIDTH,
754 window_addButtonKey( wid, 20, y,
BUTTON_WIDTH + EDITORS_EXTRA_WIDTH,
758 window_addButtonKey( wid, 20, y,
BUTTON_WIDTH + EDITORS_EXTRA_WIDTH,
760 menu_editors_close, SDLK_x );
770static void menu_editors_close(
unsigned int wid,
const char *str )
Provides macros to work with dynamic arrays.
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
void cam_setZoom(double zoom)
Sets the camera zoom.
void cam_setTargetPos(double x, double y, int soft_over)
Sets the camera target to a position.
void mapedit_open(unsigned int wid_unused, const char *unused)
Opens the system editor interface.
void uniedit_open(unsigned int wid_unused, const char *unused)
Opens the system editor interface.
int dialogue_YesNoRaw(const char *caption, const char *msg)
Runs a dialogue with both yes and no options.
int dialogue_isOpen(void)
Checks to see if a dialogue is open.
void gui_cleanup(void)
Cleans up the GUI.
unsigned int hook_addFunc(int(*func)(void *), void *data, const char *stack)
Adds a function hook to be run.
int intro_display(const char *text, const char *mus)
Displays the introduction sequence.
void land_cleanup(void)
Cleans up some land-related variables.
int land_canSave(void)
Whether or not the player can save.
void load_loadSnapshotMenu(const char *name, int disablesave)
Opens the load snapshot menu.
int load_refresh(void)
Loads or refreshes saved games for the player.
void load_loadGameMenu(void)
Opens the load game menu.
const nsave_t * load_getList(const char *name)
Gets the array (array.h) of loaded saves.
int load_gameDiff(const char *file)
Loads the diffs from game file.
int music_choose(const char *situation)
Actually runs the music stuff, based on situation.
void naev_quit(void)
Flags naev to quit.
Header file with generic functions and naev-specifics.
const char * naev_version(int long_version)
Returns the version in a human readable string.
glTexture * gl_newImage(const char *path, const unsigned int flags)
Loads an image as a texture.
void gl_freeTexture(glTexture *texture)
Frees a texture.
void opt_menu(void)
Creates the options menu thingy.
void pause_game(void)
Pauses the game.
void pause_setSpeed(double mod)
Adjusts the game's dt modifier.
void unpause_game(void)
Unpauses the game.
void pilots_cleanAll(void)
Even cleans up the player.
void player_new(void)
Creates a new player.
void player_resetSpeed(void)
Resets the player speed stuff.
void player_soundStop(void)
Stops playing player sounds.
void player_restoreControl(int reason, const char *str)
Aborts autonav and other states that take control of the ship.
int safelanes_calculated(void)
Whether or not the safe lanes have been calculated at least once.
void safelanes_recalculate(void)
Update the safe lane locations in response to the universe changing (e.g., diff applied).
void save_reload(void)
Reload the current saved game.
int save_all(void)
Saves the current game.
void sound_setSpeed(double s)
Sets the speed to play the sound at.
void space_init(const char *sysname, int do_simulate)
Initializes the system.
int spob_exists(const char *spobname)
Check to see if a spob exists.
Spob * spob_get(const char *spobname)
Gets a spob based on its name.
void space_clearKnown(void)
Clears all system knowledge.
const char * spob_getSystemName(const char *spobname)
Get the name of a system from a spobname.
void start_position(double *x, double *y)
Gets the starting position of the player.
const char * start_system(void)
Gets the starting system name.
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
Abstraction for rendering sprite sheets.