naev 0.11.5
dev_mapedit.c File Reference

Handles the star system editor. More...

#include "dev_mapedit.h"
#include "conf.h"
#include "array.h"
#include "commodity.h"
#include "dev_spob.h"
#include "dev_uniedit.h"
#include "dev_sysedit.h"
#include "dev_system.h"
#include "dialogue.h"
#include "load.h"
#include "map.h"
#include "mapData.h"
#include "ndata.h"
#include "nfile.h"
#include "nstring.h"
#include "opengl.h"
#include "outfit.h"
#include "pause.h"
#include "space.h"
#include "tk/toolkit_priv.h"
#include "toolkit.h"
#include "unidiff.h"

Go to the source code of this file.

Data Structures

struct  mapOutfitsList_t
 

Macros

#define BUTTON_WIDTH   80
 
#define BUTTON_HEIGHT   30
 
#define MAPEDIT_EDIT_WIDTH   400
 
#define MAPEDIT_EDIT_HEIGHT   450
 
#define MAPEDIT_DRAG_THRESHOLD   300
 
#define MAPEDIT_MOVE_THRESHOLD   10
 
#define MAPEDIT_ZOOM_STEP   1.2
 
#define MAPEDIT_ZOOM_MAX   5
 
#define MAPEDIT_ZOOM_MIN   -5
 
#define MAPEDIT_OPEN_WIDTH   800
 
#define MAPEDIT_OPEN_HEIGHT   500
 
#define MAPEDIT_OPEN_TXT_WIDTH   300
 
#define MAPEDIT_SAVE_WIDTH   800
 
#define MAPEDIT_SAVE_HEIGHT   500
 
#define MAPEDIT_SAVE_TXT_WIDTH   300
 

Functions

static void mapedit_deselect (void)
 Deselects selected targets.
 
static void mapedit_selectAdd (StarSystem *sys)
 Adds a system to the selection.
 
static void mapedit_selectRm (StarSystem *sys)
 Removes a system from the selection.
 
static void mapedit_buttonZoom (unsigned int wid, const char *str)
 Handles the button zoom clicks.
 
static void mapedit_render (double bx, double by, double w, double h, void *data)
 System editor custom widget rendering.
 
static void mapedit_focusLose (unsigned int wid, const char *wgtname)
 Called when it's de-focused.
 
static int mapedit_mouse (unsigned int wid, const SDL_Event *event, double mx, double my, double w, double h, double xr, double yr, void *data)
 System editor custom widget mouse handling.
 
static void mapedit_close (unsigned int wid, const char *wgt)
 Closes the system editor widget.
 
static void mapedit_btnOpen (unsigned int wid_unused, const char *unused)
 Opens up a map file.
 
static void mapedit_btnSaveMapAs (unsigned int wdw, const char *unused)
 Save the current Map to selected file.
 
static void mapedit_clear (unsigned int wid, const char *unused)
 Closes the system editor widget.
 
static void mapedit_chkSpob (unsigned int wid, const char *wgtname)
 
static void mapedit_chkHidden (unsigned int wid, const char *wgtname)
 
static int mapedit_keys (unsigned int wid, SDL_Keycode key, SDL_Keymod mod, int isrepeat)
 Handles keybindings.
 
static void mapedit_loadMapMenu_open (void)
 Opens the load map outfit menu.
 
static void mapedit_loadMapMenu_close (unsigned int wdw, const char *str)
 Closes the load map outfit menu.
 
static void mapedit_loadMapMenu_update (unsigned int wdw, const char *str)
 Updates the load menu.
 
static void mapedit_loadMapMenu_load (unsigned int wdw, const char *str)
 Load the selected Map.
 
static int mapedit_saveMap (StarSystem **uniedit_sys, mapOutfitsList_t *ns)
 Saves selected systems as a map outfit file.
 
void mapedit_setGlobalLoadedInfos (mapOutfitsList_t *ns)
 Set and display the global variables describing last loaded/saved file.
 
static int mapedit_mapsList_refresh (void)
 Gets the list of all the maps names. from outfit_mapParse()
 
static void mapsList_free (void)
 Frees the loaded map.
 
void mapedit_open (unsigned int wid_unused, const char *unused)
 Opens the system editor interface.
 
void mapedit_selectText (void)
 Sets the selected system text.
 

Variables

StarSystem * systems_stack
 
static mapOutfitsList_tmapList = NULL
 
static unsigned int mapedit_wid = 0
 
static double mapedit_xpos = 0.
 
static double mapedit_ypos = 0.
 
static double mapedit_zoom = 1.
 
static int mapedit_moved = 0
 
static unsigned int mapedit_dragTime = 0
 
static int mapedit_drag = 0
 
static StarSystem ** mapedit_sys = NULL
 
static int mapedit_iLastClickedSystem = 0
 
static int mapedit_tadd = 0
 
static int mapedit_nsys = 0
 
static int mapedit_msys = 0
 
static double mapedit_mx = 0.
 
static double mapedit_my = 0.
 
static unsigned int mapedit_widLoad = 0
 
static char * mapedit_sLoadMapName = NULL
 
static int mapedit_nospob = 0
 
static int mapedit_hidden = 0
 

Detailed Description

Handles the star system editor.

Definition in file dev_mapedit.c.

Macro Definition Documentation

◆ BUTTON_HEIGHT

#define BUTTON_HEIGHT   30

Map button height.

Definition at line 43 of file dev_mapedit.c.

◆ BUTTON_WIDTH

#define BUTTON_WIDTH   80

Map button width.

Definition at line 42 of file dev_mapedit.c.

◆ MAPEDIT_DRAG_THRESHOLD

#define MAPEDIT_DRAG_THRESHOLD   300

Drag threshold.

Definition at line 48 of file dev_mapedit.c.

◆ MAPEDIT_EDIT_HEIGHT

#define MAPEDIT_EDIT_HEIGHT   450

System editor height.

Definition at line 46 of file dev_mapedit.c.

◆ MAPEDIT_EDIT_WIDTH

#define MAPEDIT_EDIT_WIDTH   400

System editor width.

Definition at line 45 of file dev_mapedit.c.

◆ MAPEDIT_MOVE_THRESHOLD

#define MAPEDIT_MOVE_THRESHOLD   10

Movement threshold.

Definition at line 49 of file dev_mapedit.c.

◆ MAPEDIT_OPEN_HEIGHT

#define MAPEDIT_OPEN_HEIGHT   500

Open window height.

Definition at line 56 of file dev_mapedit.c.

◆ MAPEDIT_OPEN_TXT_WIDTH

#define MAPEDIT_OPEN_TXT_WIDTH   300

Text width.

Definition at line 57 of file dev_mapedit.c.

◆ MAPEDIT_OPEN_WIDTH

#define MAPEDIT_OPEN_WIDTH   800

Open window width.

Definition at line 55 of file dev_mapedit.c.

◆ MAPEDIT_SAVE_HEIGHT

#define MAPEDIT_SAVE_HEIGHT   500

Open window height.

Definition at line 60 of file dev_mapedit.c.

◆ MAPEDIT_SAVE_TXT_WIDTH

#define MAPEDIT_SAVE_TXT_WIDTH   300

Text width.

Definition at line 61 of file dev_mapedit.c.

◆ MAPEDIT_SAVE_WIDTH

#define MAPEDIT_SAVE_WIDTH   800

Open window width.

Definition at line 59 of file dev_mapedit.c.

◆ MAPEDIT_ZOOM_MAX

#define MAPEDIT_ZOOM_MAX   5

Maximum mapedit zoom level (close).

Definition at line 52 of file dev_mapedit.c.

◆ MAPEDIT_ZOOM_MIN

#define MAPEDIT_ZOOM_MIN   -5

Minimum mapedit zoom level (far).

Definition at line 53 of file dev_mapedit.c.

◆ MAPEDIT_ZOOM_STEP

#define MAPEDIT_ZOOM_STEP   1.2

Factor to zoom by for each zoom level.

Definition at line 51 of file dev_mapedit.c.

Function Documentation

◆ mapedit_btnOpen()

static void mapedit_btnOpen ( unsigned int wid_unused,
const char * unused )
static

Opens up a map file.

Definition at line 352 of file dev_mapedit.c.

◆ mapedit_btnSaveMapAs()

static void mapedit_btnSaveMapAs ( unsigned int wid_unused,
const char * unused )
static

Save the current Map to selected file.

Definition at line 853 of file dev_mapedit.c.

◆ mapedit_buttonZoom()

static void mapedit_buttonZoom ( unsigned int wid,
const char * str )
static

Handles the button zoom clicks.

Parameters
widUnused.
strName of the button creating the event.

Definition at line 612 of file dev_mapedit.c.

◆ mapedit_chkHidden()

static void mapedit_chkHidden ( unsigned int wid,
const char * wgtname )
static

Definition at line 344 of file dev_mapedit.c.

◆ mapedit_chkSpob()

static void mapedit_chkSpob ( unsigned int wid,
const char * wgtname )
static

Definition at line 339 of file dev_mapedit.c.

◆ mapedit_clear()

static void mapedit_clear ( unsigned int wid_unused,
const char * unused )
static

Closes the system editor widget.

Definition at line 330 of file dev_mapedit.c.

◆ mapedit_close()

static void mapedit_close ( unsigned int wid,
const char * wgt )
static

Closes the system editor widget.

Definition at line 311 of file dev_mapedit.c.

◆ mapedit_deselect()

static void mapedit_deselect ( void )
static

Deselects selected targets.

Definition at line 514 of file dev_mapedit.c.

◆ mapedit_focusLose()

static void mapedit_focusLose ( unsigned int wid,
const char * wgtname )
static

Called when it's de-focused.

Definition at line 398 of file dev_mapedit.c.

◆ mapedit_keys()

static int mapedit_keys ( unsigned int wid,
SDL_Keycode key,
SDL_Keymod mod,
int isrepeat )
static

Handles keybindings.

Definition at line 292 of file dev_mapedit.c.

◆ mapedit_loadMapMenu_close()

static void mapedit_loadMapMenu_close ( unsigned int wdw,
const char * str )
static

Closes the load map outfit menu.

Parameters
wdwWindow triggering function.
strUnused.

Definition at line 731 of file dev_mapedit.c.

◆ mapedit_loadMapMenu_load()

static void mapedit_loadMapMenu_load ( unsigned int wdw,
const char * str )
static

Load the selected Map.

Definition at line 740 of file dev_mapedit.c.

◆ mapedit_loadMapMenu_open()

void mapedit_loadMapMenu_open ( void )
static

Opens the load map outfit menu.

Definition at line 637 of file dev_mapedit.c.

◆ mapedit_loadMapMenu_update()

static void mapedit_loadMapMenu_update ( unsigned int wdw,
const char * str )
static

Updates the load menu.

Parameters
wdwWindow triggering function.
strUnused.

Definition at line 693 of file dev_mapedit.c.

◆ mapedit_mapsList_refresh()

static int mapedit_mapsList_refresh ( void )
static

Gets the list of all the maps names. from outfit_mapParse()

Definition at line 903 of file dev_mapedit.c.

◆ mapedit_mouse()

static int mapedit_mouse ( unsigned int wid,
const SDL_Event * event,
double mx,
double my,
double w,
double h,
double xr,
double yr,
void * data )
static

System editor custom widget mouse handling.

Definition at line 408 of file dev_mapedit.c.

◆ mapedit_open()

void mapedit_open ( unsigned int wid_unused,
const char * unused )

Opens the system editor interface.

Definition at line 132 of file dev_mapedit.c.

◆ mapedit_render()

static void mapedit_render ( double bx,
double by,
double w,
double h,
void * data )
static

System editor custom widget rendering.

Definition at line 364 of file dev_mapedit.c.

◆ mapedit_saveMap()

static int mapedit_saveMap ( StarSystem ** uniedit_sys,
mapOutfitsList_t * ns )
static

Saves selected systems as a map outfit file.

Returns
0 on success.

Definition at line 1046 of file dev_mapedit.c.

◆ mapedit_selectAdd()

static void mapedit_selectAdd ( StarSystem * sys)
static

Adds a system to the selection.

Definition at line 530 of file dev_mapedit.c.

◆ mapedit_selectRm()

static void mapedit_selectRm ( StarSystem * sys)
static

Removes a system from the selection.

Definition at line 555 of file dev_mapedit.c.

◆ mapedit_selectText()

void mapedit_selectText ( void )

Sets the selected system text.

Definition at line 570 of file dev_mapedit.c.

◆ mapedit_setGlobalLoadedInfos()

void mapedit_setGlobalLoadedInfos ( mapOutfitsList_t * ns)

Set and display the global variables describing last loaded/saved file.

Definition at line 877 of file dev_mapedit.c.

◆ mapsList_free()

static void mapsList_free ( void )
static

Frees the loaded map.

Definition at line 1025 of file dev_mapedit.c.

Variable Documentation

◆ mapedit_drag

int mapedit_drag = 0
static

Dragging viewport around.

Definition at line 81 of file dev_mapedit.c.

◆ mapedit_dragTime

unsigned int mapedit_dragTime = 0
static

Tick last started to drag.

Definition at line 80 of file dev_mapedit.c.

◆ mapedit_hidden

int mapedit_hidden = 0
static

Mark hidden jump lanes too.

Definition at line 92 of file dev_mapedit.c.

◆ mapedit_iLastClickedSystem

int mapedit_iLastClickedSystem = 0
static

Last clicked system (use with system_getIndex).

Definition at line 83 of file dev_mapedit.c.

◆ mapedit_moved

int mapedit_moved = 0
static

Space moved since mouse down.

Definition at line 79 of file dev_mapedit.c.

◆ mapedit_msys

int mapedit_msys = 0
static

Memory allocated for selected systems.

Definition at line 86 of file dev_mapedit.c.

◆ mapedit_mx

double mapedit_mx = 0.
static

X mouse position.

Definition at line 87 of file dev_mapedit.c.

◆ mapedit_my

double mapedit_my = 0.
static

Y mouse position.

Definition at line 88 of file dev_mapedit.c.

◆ mapedit_nospob

int mapedit_nospob = 0
static

Don't save spobs.

Definition at line 91 of file dev_mapedit.c.

◆ mapedit_nsys

int mapedit_nsys = 0
static

Number of selected systems.

Definition at line 85 of file dev_mapedit.c.

◆ mapedit_sLoadMapName

char* mapedit_sLoadMapName = NULL
static

Loaded Map Outfit.

Definition at line 90 of file dev_mapedit.c.

◆ mapedit_sys

StarSystem** mapedit_sys = NULL
static

Selected systems.

Definition at line 82 of file dev_mapedit.c.

◆ mapedit_tadd

int mapedit_tadd = 0
static

Temporarily clicked system should be added.

Definition at line 84 of file dev_mapedit.c.

◆ mapedit_wid

unsigned int mapedit_wid = 0
static

Sysedit wid.

Definition at line 75 of file dev_mapedit.c.

◆ mapedit_widLoad

unsigned int mapedit_widLoad = 0
static

Load Map Outfit wid.

Definition at line 89 of file dev_mapedit.c.

◆ mapedit_xpos

double mapedit_xpos = 0.
static

Viewport X position.

Definition at line 76 of file dev_mapedit.c.

◆ mapedit_ypos

double mapedit_ypos = 0.
static

Viewport Y position.

Definition at line 77 of file dev_mapedit.c.

◆ mapedit_zoom

double mapedit_zoom = 1.
static

Viewport zoom level.

Definition at line 78 of file dev_mapedit.c.

◆ mapList

mapOutfitsList_t* mapList = NULL
static

Definition at line 73 of file dev_mapedit.c.

◆ systems_stack

StarSystem* systems_stack
extern

Star system stack.

Definition at line 92 of file space.c.