Because actually , we have no way to return to the MAIN MENU .
The way i want to make it will use a new variable of type Gamestate
That Gamestate will be added and stored in the game_data_t struct :enum Gamestate{QUIT,MENU,LOAD,RUNNING};//ADD BY EZEE
Also needed , a new entry in the CommandMap/* All global data is stored in a variable of this type */
typedef struct
{
char use_textures;
char use_animations;
char use_videos;
char use_sprites;
char use_logos;
char use_ship_textures;
char use_planet_textures;
int audio_frequency_mode; //0==11025/8 1==22050/8 2==44100/8 3==11025/16 4==22050/16 5==44100/16
int sound_enabled;
int music_enabled;
int sound_volume;
int music_volume;
int max_sound_sources;
int warning_level;
int capture_mouse;
float MouseSensitivityX;
float MouseSensitivityY;
float detaillevel; /*how much the LOD calculation gets multiplied by...higher="bigger" */
int y_resolution;
int x_resolution;
float znear;
float zfar;
float fov;
float aspect;
float difficulty;
char vsdebug;
Gamestate state;//Added by ezee
} game_data_t; //we could add a gamestate here so i did it
I created a new CockpitKeys fonction to change the state of the game engine :commandMap["BackToMenu"] =CockpitKeys::Menu;// New menu by ezee
I have also made a binding in the vegastrike.config file for the Menu ://NEW MENU SYSTEM BY EZEE
void Menu(const KBData&, KBSTATE newState)
{
if (newState == PRESS)
{
g_game.state=MENU;
printf( "********** MENU BY EZEE ****************\n" );
QuitNow(g_game.state);//we should go to the menu now
}
Note that the key i used is just because it's easy for test .<bind key="space" modifier="none" command="BackToMenu" />
You will assign the key you want . ( it could also work with the actual ESC , i will try
that also )
I just tried it , and i've seen the Menu that is harcoded in the c++ !
But it freezed ... I think i must stop the render before , i don't know .
Oh yeah , i forgot to say that i have modified also the CockpitKeys's namespace
by tweaking the QuitNow() fonction :
//could be reused with a state like enum{quit,menu)
//okay , done
//OLD WAS void QuitNow()
//ezee
void QuitNow(Gamestate state)
{
//menu stuff
if(g_game.state==MENU)
{
UniverseUtil::startMenuInterface(true);
return;
}
// old code
if (!cleanexit)
{
cleanexit = true;
if (Network == NULL && game_options.write_savegame_on_exit)
_Universe->WriteSaveGame( true ); //gotta do important stuff first
for (unsigned int i = 0; i < active_missions.size(); i++)
if (active_missions)
active_missions->DirectorEnd();
if (forcefeedback)
{
delete forcefeedback;
forcefeedback = NULL;
}
VSExit(g_game.state);//this way we have exit to menu enabled
}
}
The freeze is caused by :
i set
startMenuInterface(false);
this time and that WORKS !
Well , mouse moove = ok , i just pressed quit , and have a clean exit .
the stdout :
In path d:\program\experimental\Data
Windows version 5 1
Vega Strike
See http://www.gnu.org/copyleft/gpl.html for license details.
Using .vegastrike as the home directory
['d:\\program\\experimental\\Data\\python27.zip', 'D:\\program files\\Lib', 'D:\\program files\\DLLs', 'D:\\program files\\Lib\\lib-tk', '', 'd:\\program\\experimental\\Data']
['d:\\program\\experimental\\Data\\modules\\builtin', 'd:\\program\\experimental\\Data\\modules\\quests', 'd:\\program\\experimental\\Data\\modules\\missions', 'd:\\program\\experimental\\Data\\modules\\ai', 'd:\\program\\experimental\\Data\\modules', 'd:\\program\\experimental\\Data\\bases', 'd:\\program\\experimental\\Data\\python27.zip', 'D:\\program files\\Lib', 'D:\\program files\\DLLs', 'D:\\program files\\Lib\\lib-tk', '', 'd:\\program\\experimental\\Data']
1 joysticks were found.
The names of the joysticks are:
SideWinder Joystick
axes: 3 buttons: 8 hats: 0
using NV_CUBE_MAP
Compiling python module modules/dj.py
Initializing optimizer
Compilation of technique fixed successful
Compilation of technique default successful
Compilation of technique default_simple successful
MASK is introduced by ezee !
pox 119990000000.000000 -9000000.000000 -109990000000.000000
INFO: Missing video stream preintro.ogv
INFO: Missing video stream intro.ogv
Force feedback support disabled when compiled
Loading active missions True
IS NOW AT Special/Empty
Launching bases for Special/Empty
Adding news
conditioning
nonzeroing
New selection: 0
Error: Cannot Open Unit Llama.begin from save file Autosave.
Compilation of technique earth successful
Compilation of technique fireglass successful
using NV_CUBE_MAP
MASK is introduced by ezee !
Loading active missions True
Special/Empty IS NOW AT Crucible/Cephid_17
Special
Showing splash screen!
Launching bases for Crucible/Cephid_17
Adding news
conditioning
nonzeroing
conditioning
nonzeroing
finding nonloaded quest
quest_tutorial
finding quest
quest_tutorial
nonpfact
********** MENU BY EZEE ****************
Thank you for playing!
Writing Save Game Autosave
THAT WORRRRRRRRRRKSSSSSSSSSSS !!
thank you jymmy -> https://www.youtube.com/watch?v=jvXKOreEK84
I now make a video to show you .