23#include "dev_mapedit.h"
24#include "dev_uniedit.h"
49#include "tk/toolkit_priv.h"
55#define MENU_HEIGHT 250
57#define DEATH_WIDTH 200
58#define DEATH_HEIGHT 200
60#define BUTTON_WIDTH 160
61#define BUTTON_HEIGHT 30
63#define EDITORS_EXTRA_WIDTH 60
65#define menu_Open(f) (menu_open |= (f))
66#define menu_Close(f) (menu_open &= ~(f))
68int bg_needs_reset = 1;
71static int menu_small_allowsave = 1;
77static void menu_exit(
unsigned int wid,
const char *str );
79static int menu_main_bkg_system (
void);
80static void main_menu_promptClose(
unsigned int wid,
const char *unused );
81static void menu_main_load(
unsigned int wid,
const char *str );
82static void menu_main_new(
unsigned int wid,
const char *str );
83static void menu_main_credits(
unsigned int wid,
const char *str );
84static void menu_main_cleanBG(
unsigned int wid,
const char *str );
86static void menu_small_load(
unsigned int wid,
const char *str );
87static void menu_small_resume(
unsigned int wid,
const char *str );
88static void menu_small_info(
unsigned int wid,
const char *str );
89static void menu_small_exit(
unsigned int wid,
const char *str );
90static void exit_game (
void);
92static void menu_death_continue(
unsigned int wid,
const char *str );
93static void menu_death_restart(
unsigned int wid,
const char *str );
94static void menu_death_main(
unsigned int wid,
const char *str );
95static void menu_death_close(
unsigned int wid,
const char *str );
99static void menu_editors_open(
unsigned int wid_unused,
const char *unused );
100static void menu_editors_close(
unsigned int wid,
const char *str );
102static void menu_options_button(
unsigned int wid,
const char *str );
107static int menu_main_bkg_system (
void)
109 if (!bg_needs_reset) {
174 int offset_logo, offset_wdw, freespace;
175 unsigned int bwid, wid;
180 WARN( _(
"Menu main is already open.") );
195 render_postprocessCleanup();
204 menu_main_bkg_system();
215 freespace = SCREEN_H - tex->
sh - h;
217 offset_logo = SCREEN_W - tex->
sh;
222 offset_logo = -freespace/4;
223 offset_wdw = freespace/2;
230 window_addImage( bwid, (SCREEN_W-tex->
sw)/2., offset_logo, 0, 0,
"imgLogo", tex, 0 );
231 window_addText( bwid, 0, 10, SCREEN_W, 30., 1,
"txtBG", NULL,
235 wid =
window_create(
"wdwMainMenu", _(
"Main Menu"), -1, offset_wdw, MAIN_WIDTH, h );
240 "btnLoad", _(
"Load Game"), menu_main_load, SDLK_l );
243 "btnNew", _(
"New Game"), menu_main_new, SDLK_n );
247 "btnEditor", _(
"Editors"), menu_editors_open, SDLK_e );
251 "btnOptions", _(
"Options"), menu_options_button, SDLK_o );
254 "btnCredits", p_(
"Menu|",
"Credits"), menu_main_credits, SDLK_c );
257 "btnExit", _(
"Exit Game"), menu_exit, SDLK_x );
261 window_disableButton( wid,
"btnLoad" );
280void menu_main_resize (
void)
282 int w, h, bgw, bgh, tw, th;
283 int offset_logo, offset_wdw, freespace;
295 freespace = SCREEN_H - main_naevLogo->
sh - h;
297 offset_logo = SCREEN_H - main_naevLogo->
sh;
301 offset_logo = -freespace/4;
302 offset_wdw = freespace/2;
306 (bgw - main_naevLogo->
sw)/2., offset_logo );
315 wgt->x = (SCREEN_W - tw) / 2;
326static void main_menu_promptClose(
unsigned int wid,
const char *unused )
336void menu_main_close (
void)
343 WARN( _(
"Main menu does not exist.") );
352static void menu_main_load(
unsigned int wid,
const char *str )
362static void menu_main_new(
unsigned int wid,
const char *str )
379static void menu_main_credits(
unsigned int wid,
const char *str )
395static void menu_exit(
unsigned int wid,
const char *str )
407static void menu_main_cleanBG(
unsigned int wid,
const char *str )
413 main_naevLogo = NULL;
424void menu_small(
int docheck,
int info,
int options,
int allowsave )
431 if (docheck && (player_isFlag(PLAYER_DESTROYED) ||
439 can_save = allowsave &&
landed && !player_isFlag(PLAYER_NOSAVE);
440 menu_small_allowsave = allowsave;
448 window_addButtonKey( wid, 20, y,
450 "btnResume", _(
"Resume"), menu_small_resume, SDLK_r );
453 window_addButtonKey( wid, 20, y,
455 "btnInfo", _(
"Info"), menu_small_info, SDLK_i );
458 window_addButtonKey( wid, 20, y,
460 "btnSave", can_save ? _(
"Load / Save") : _(
"Load"), menu_small_load, SDLK_l );
463 window_addButtonKey( wid, 20, y,
465 "btnOptions", _(
"Options"), menu_options_button, SDLK_o );
469 "btnExit", _(
"Exit to Title"), menu_small_exit, SDLK_x );
479static void menu_small_load(
unsigned int wid,
const char *str )
492static void menu_small_resume(
unsigned int wid,
const char *str )
502void menu_small_close (
void)
507 WARN( _(
"Small menu does not exist.") );
517static void menu_small_info(
unsigned int wid,
const char *str )
525static int menu_small_exit_hook(
void* unused )
544 unsigned int info_wid =
window_get(
"wdwInfo");
565static void menu_small_exit(
unsigned int wid,
const char *str )
571 if (!
dialogue_YesNoRaw(_(
"Exit to Menu?"),_(
"Are you sure you wish to exit to menu right now? The game #rwill not be saved#0 since last time you landed!") ))
577 SDL_memset( &event, 0,
sizeof(event) );
579 SDL_PushEvent( &event );
587static void exit_game (
void)
595 quit.type = SDL_QUIT;
596 SDL_PushEvent(&
quit);
602static void menu_death_continue(
unsigned int wid,
const char *str )
617static void menu_death_restart(
unsigned int wid,
const char *str )
630void menu_death (
void)
634 wid =
window_create(
"wdwRIP", _(
"Death"), -1, -1, DEATH_WIDTH, DEATH_HEIGHT );
641 "btnContinue", _(
"Continue"), menu_death_continue, SDLK_c );
644 "btnRestart", _(
"Restart"), menu_death_restart, SDLK_r );
648 "btnMain", _(
"Main Menu"), menu_death_main, SDLK_m );
650 "btnExit", _(
"Exit Game"), menu_exit, SDLK_x );
661static void menu_death_main(
unsigned int wid,
const char *str )
674static void menu_death_close(
unsigned int wid,
const char *str )
684static void menu_options_button(
unsigned int wid,
const char *str )
694int menu_askQuit (
void)
704 if (
dialogue_YesNoRaw( _(
"Quit Naev"), _(
"Are you sure you want to quit Naev?") )) {
716static void menu_editors_open(
unsigned int wid,
const char *unused )
737 wid =
window_create(
"wdwEditors", _(
"Editors"), -1, -1, MENU_WIDTH + EDITORS_EXTRA_WIDTH, h );
741 window_addButtonKey( wid, 20, y, BUTTON_WIDTH + EDITORS_EXTRA_WIDTH, BUTTON_HEIGHT,
742 "btnUniverse", _(
"Universe Map"),
uniedit_open, SDLK_u );
744 window_addButtonKey( wid, 20, y, BUTTON_WIDTH + EDITORS_EXTRA_WIDTH, BUTTON_HEIGHT,
747 window_addButtonKey( wid, 20, y, BUTTON_WIDTH + EDITORS_EXTRA_WIDTH, BUTTON_HEIGHT,
748 "btnMain", _(
"Exit to Main Menu"), menu_editors_close, SDLK_x );
760static 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.
const char * spob_getSystem(const char *spobname)
Get the name of a system from a spobname.
void space_clearKnown(void)
Clears all system knowledge.
void start_position(double *x, double *y)
Gets the starting position of the player.
const char * start_system(void)
Gets the starting system name.
unsigned int death_counter
unsigned int death_counter
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
Abstraction for rendering sprite sheets.