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))
70static int menu_small_allowsave = 1;
76static void menu_exit(
unsigned int wid,
const char *str );
78static int menu_main_bkg_system (
void);
79static void main_menu_promptClose(
unsigned int wid,
const char *unused );
80static void menu_main_load(
unsigned int wid,
const char *str );
81static void menu_main_new(
unsigned int wid,
const char *str );
82static void menu_main_credits(
unsigned int wid,
const char *str );
83static void menu_main_cleanBG(
unsigned int wid,
const char *str );
85static void menu_small_load(
unsigned int wid,
const char *str );
86static void menu_small_resume(
unsigned int wid,
const char *str );
87static void menu_small_info(
unsigned int wid,
const char *str );
88static void menu_small_exit(
unsigned int wid,
const char *str );
89static void exit_game (
void);
91static void menu_death_continue(
unsigned int wid,
const char *str );
92static void menu_death_restart(
unsigned int wid,
const char *str );
93static void menu_death_main(
unsigned int wid,
const char *str );
94static void menu_death_close(
unsigned int wid,
const char *str );
98static void menu_editors_open(
unsigned int wid_unused,
const char *unused );
99static void menu_editors_close(
unsigned int wid,
const char *str );
101static void menu_options_button(
unsigned int wid,
const char *str );
106static int menu_main_bkg_system (
void)
167 int offset_logo, offset_wdw, freespace;
168 unsigned int bwid, wid;
173 WARN( _(
"Menu main is already open.") );
184 render_postprocessCleanup();
193 menu_main_bkg_system();
204 freespace = SCREEN_H - tex->
sh - h;
206 offset_logo = SCREEN_W - tex->
sh;
211 offset_logo = -freespace/4;
212 offset_wdw = freespace/2;
219 window_addImage( bwid, (SCREEN_W-tex->
sw)/2., offset_logo, 0, 0,
"imgLogo", tex, 0 );
220 window_addText( bwid, 0, 10, SCREEN_W, 30., 1,
"txtBG", NULL,
224 wid =
window_create(
"wdwMainMenu", _(
"Main Menu"), -1, offset_wdw, MAIN_WIDTH, h );
233 "btnLoad", _(
"Load Game"), menu_main_load, SDLK_l );
236 "btnNew", _(
"New Game"), menu_main_new, SDLK_n );
240 "btnEditor", _(
"Editors"), menu_editors_open, SDLK_e );
244 "btnOptions", _(
"Options"), menu_options_button, SDLK_o );
247 "btnCredits", p_(
"Menu|",
"Credits"), menu_main_credits, SDLK_c );
250 "btnExit", _(
"Exit Game"), menu_exit, SDLK_x );
254 window_disableButton( wid,
"btnLoad" );
275 int w, h, bgw, bgh, tw, th;
276 int offset_logo, offset_wdw, freespace;
289 freespace = SCREEN_H - main_naevLogo->
sh - h;
291 offset_logo = SCREEN_H - main_naevLogo->
sh;
295 offset_logo = -freespace/4;
296 offset_wdw = freespace/2;
300 (bgw - main_naevLogo->
sw)/2., offset_logo );
309 wgt->x = (SCREEN_W - tw) / 2;
320static void main_menu_promptClose(
unsigned int wid,
const char *unused )
337 WARN( _(
"Main menu does not exist.") );
346static void menu_main_load(
unsigned int wid,
const char *str )
356static void menu_main_new(
unsigned int wid,
const char *str )
373static void menu_main_credits(
unsigned int wid,
const char *str )
387static void menu_exit(
unsigned int wid,
const char *str )
399static void menu_main_cleanBG(
unsigned int wid,
const char *str )
405 main_naevLogo = NULL;
416void menu_small(
int docheck,
int info,
int options,
int allowsave )
423 if (docheck && (player_isFlag(PLAYER_DESTROYED) ||
431 can_save = allowsave &&
landed && !player_isFlag(PLAYER_NOSAVE);
432 menu_small_allowsave = allowsave;
440 window_addButtonKey( wid, 20, y,
442 "btnResume", _(
"Resume"), menu_small_resume, SDLK_r );
445 window_addButtonKey( wid, 20, y,
447 "btnInfo", _(
"Info"), menu_small_info, SDLK_i );
450 window_addButtonKey( wid, 20, y,
452 "btnSave", can_save ? _(
"Load / Save") : _(
"Load"), menu_small_load, SDLK_l );
455 window_addButtonKey( wid, 20, y,
457 "btnOptions", _(
"Options"), menu_options_button, SDLK_o );
461 "btnExit", _(
"Exit to Title"), menu_small_exit, SDLK_x );
471static void menu_small_load(
unsigned int wid,
const char *str )
484static void menu_small_resume(
unsigned int wid,
const char *str )
499 WARN( _(
"Small menu does not exist.") );
509static void menu_small_info(
unsigned int wid,
const char *str )
517static int menu_small_exit_hook(
void* unused )
536 unsigned int info_wid =
window_get(
"wdwInfo");
557static void menu_small_exit(
unsigned int wid,
const char *str )
563 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!") ))
569 SDL_memset( &event, 0,
sizeof(event) );
571 SDL_PushEvent( &event );
579static void exit_game (
void)
587 quit.type = SDL_QUIT;
588 SDL_PushEvent(&
quit);
594static void menu_death_continue(
unsigned int wid,
const char *str )
609static void menu_death_restart(
unsigned int wid,
const char *str )
626 wid =
window_create(
"wdwRIP", _(
"Death"), -1, -1, DEATH_WIDTH, DEATH_HEIGHT );
633 "btnContinue", _(
"Continue"), menu_death_continue, SDLK_c );
636 "btnRestart", _(
"Restart"), menu_death_restart, SDLK_r );
640 "btnMain", _(
"Main Menu"), menu_death_main, SDLK_m );
642 "btnExit", _(
"Exit Game"), menu_exit, SDLK_x );
652static void menu_death_main(
unsigned int wid,
const char *str )
665static void menu_death_close(
unsigned int wid,
const char *str )
675static void menu_options_button(
unsigned int wid,
const char *str )
695 if (
dialogue_YesNoRaw( _(
"Quit Naev"), _(
"Are you sure you want to quit Naev?") )) {
707static void menu_editors_open(
unsigned int wid,
const char *unused )
728 wid =
window_create(
"wdwEditors", _(
"Editors"), -1, -1, MENU_WIDTH + EDITORS_EXTRA_WIDTH, h );
733 "btnUniverse", _(
"Universe Map"),
uniedit_open, SDLK_u );
739 "btnMain", _(
"Exit to Main Menu"), menu_editors_close, SDLK_x );
751static 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.
void menu_info(int window)
Opens the information menu.
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.
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.