Add new features to the config command for control of the config file:
- manipulate the autoexec section - display information on sections and values - show the used config files and startup command line parameters - restart capability - save config files either in the config or program directory Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3651
This commit is contained in:
parent
0d7b792d05
commit
143beec6b1
15 changed files with 847 additions and 248 deletions
|
@ -40,7 +40,7 @@
|
|||
|
||||
extern Bit8u int10_font_14[256 * 14];
|
||||
extern Program * first_shell;
|
||||
extern void MSG_Write(const char *);
|
||||
extern bool MSG_Write(const char *);
|
||||
extern void GFX_SetTitle(Bit32s cycles, Bits frameskip, bool paused);
|
||||
|
||||
static int cursor, saved_bpp;
|
||||
|
|
|
@ -1584,6 +1584,9 @@ public:
|
|||
case MK_printscreen:
|
||||
key=SDLK_PRINT;
|
||||
break;
|
||||
case MK_home:
|
||||
key=SDLK_HOME;
|
||||
break;
|
||||
}
|
||||
sprintf(buf,"%s \"key %d%s%s%s\"",
|
||||
entry,
|
||||
|
|
|
@ -989,6 +989,8 @@ static unsigned char logo[32*32*4]= {
|
|||
#include "dosbox_splash.h"
|
||||
|
||||
//extern void UI_Run(bool);
|
||||
void Restart(bool pressed);
|
||||
|
||||
static void GUI_StartUp(Section * sec) {
|
||||
sec->AddDestroyFunction(&GUI_ShutDown);
|
||||
Section_prop * section=static_cast<Section_prop *>(sec);
|
||||
|
@ -1234,6 +1236,7 @@ static void GUI_StartUp(Section * sec) {
|
|||
MAPPER_AddHandler(KillSwitch,MK_f9,MMOD1,"shutdown","ShutDown");
|
||||
MAPPER_AddHandler(CaptureMouse,MK_f10,MMOD1,"capmouse","Cap Mouse");
|
||||
MAPPER_AddHandler(SwitchFullScreen,MK_return,MMOD2,"fullscr","Fullscreen");
|
||||
MAPPER_AddHandler(Restart,MK_home,MMOD1|MMOD2,"restart","Restart");
|
||||
#if C_DEBUG
|
||||
/* Pause binds with activate-debugger */
|
||||
#else
|
||||
|
@ -1586,6 +1589,32 @@ static void launcheditor() {
|
|||
printf("can't find editor(s) specified at the command line.\n");
|
||||
exit(1);
|
||||
}
|
||||
#if C_DEBUG
|
||||
extern void DEBUG_ShutDown(Section * /*sec*/);
|
||||
#endif
|
||||
|
||||
void restart_program(std::vector<std::string> & parameters) {
|
||||
char** newargs = new char* [parameters.size()+1];
|
||||
// parameter 0 is the executable path
|
||||
// contents of the vector follow
|
||||
// last one is NULL
|
||||
for(Bitu i = 0; i < parameters.size(); i++) newargs[i]=(char*)parameters[i].c_str();
|
||||
newargs[parameters.size()] = NULL;
|
||||
SDL_CloseAudio();
|
||||
SDL_Delay(50);
|
||||
SDL_Quit();
|
||||
#if C_DEBUG
|
||||
// shutdown curses
|
||||
DEBUG_ShutDown(NULL);
|
||||
#endif
|
||||
|
||||
execvp(newargs[0], newargs);
|
||||
free(newargs);
|
||||
}
|
||||
void Restart(bool pressed) { // mapper handler
|
||||
restart_program(control->startup_params);
|
||||
}
|
||||
|
||||
static void launchcaptures(std::string const& edit) {
|
||||
std::string path,file;
|
||||
Section* t = control->GetSection("dosbox");
|
||||
|
@ -1790,15 +1819,16 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
/* Parse configuration files */
|
||||
std::string config_file,config_path;
|
||||
bool parsed_anyconfigfile = false;
|
||||
//First Parse -userconf
|
||||
Cross::GetPlatformConfigDir(config_path);
|
||||
|
||||
//First parse -userconf
|
||||
if(control->cmdline->FindExist("-userconf",true)){
|
||||
config_file.clear();
|
||||
Cross::GetPlatformConfigDir(config_path);
|
||||
Cross::GetPlatformConfigName(config_file);
|
||||
config_path += config_file;
|
||||
if(control->ParseConfigFile(config_path.c_str())) parsed_anyconfigfile = true;
|
||||
if(!parsed_anyconfigfile) {
|
||||
control->ParseConfigFile(config_path.c_str());
|
||||
if(!control->configfiles.size()) {
|
||||
//Try to create the userlevel configfile.
|
||||
config_file.clear();
|
||||
Cross::CreatePlatformConfigDir(config_path);
|
||||
|
@ -1807,29 +1837,29 @@ int main(int argc, char* argv[]) {
|
|||
if(control->PrintConfig(config_path.c_str())) {
|
||||
LOG_MSG("CONFIG: Generating default configuration.\nWriting it to %s",config_path.c_str());
|
||||
//Load them as well. Makes relative paths much easier
|
||||
if(control->ParseConfigFile(config_path.c_str())) parsed_anyconfigfile = true;
|
||||
control->ParseConfigFile(config_path.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Second parse -conf entries
|
||||
while(control->cmdline->FindString("-conf",config_file,true))
|
||||
if (control->ParseConfigFile(config_file.c_str())) parsed_anyconfigfile = true;
|
||||
//Second parse -conf switches
|
||||
while(control->cmdline->FindString("-conf",config_file,true)) {
|
||||
if(!control->ParseConfigFile(config_file.c_str())) {
|
||||
// try to load it from the user directory
|
||||
control->ParseConfigFile((config_path + config_file).c_str());
|
||||
}
|
||||
}
|
||||
// if none found => parse localdir conf
|
||||
if(!control->configfiles.size()) control->ParseConfigFile("dosbox.conf");
|
||||
|
||||
//if none found => parse localdir conf
|
||||
config_file = "dosbox.conf";
|
||||
if (!parsed_anyconfigfile && control->ParseConfigFile(config_file.c_str())) parsed_anyconfigfile = true;
|
||||
|
||||
//if none found => parse userlevel conf
|
||||
if(!parsed_anyconfigfile) {
|
||||
// if none found => parse userlevel conf
|
||||
if(!control->configfiles.size()) {
|
||||
config_file.clear();
|
||||
Cross::GetPlatformConfigDir(config_path);
|
||||
Cross::GetPlatformConfigName(config_file);
|
||||
config_path += config_file;
|
||||
if(control->ParseConfigFile(config_path.c_str())) parsed_anyconfigfile = true;
|
||||
control->ParseConfigFile((config_path + config_file).c_str());
|
||||
}
|
||||
|
||||
if(!parsed_anyconfigfile) {
|
||||
if(!control->configfiles.size()) {
|
||||
//Try to create the userlevel configfile.
|
||||
config_file.clear();
|
||||
Cross::CreatePlatformConfigDir(config_path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue