Make DoConfig use the Config.dat in its directory
This is accurate to how the original DoConfig does it.
This commit is contained in:
parent
657b586cd1
commit
00d0161832
1 changed files with 23 additions and 2 deletions
|
@ -4,7 +4,9 @@
|
||||||
* To Public License, Version 2, as published by Sam Hocevar. See
|
* To Public License, Version 2, as published by Sam Hocevar. See
|
||||||
* http://sam.zoy.org/wtfpl/COPYING for more details. */
|
* http://sam.zoy.org/wtfpl/COPYING for more details. */
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "FL/Fl.H"
|
#include "FL/Fl.H"
|
||||||
#include "FL/Fl_Window.H"
|
#include "FL/Fl_Window.H"
|
||||||
|
@ -42,6 +44,8 @@ class RadioRow{
|
||||||
Fl_Group *label;
|
Fl_Group *label;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char config_path[FILENAME_MAX];
|
||||||
|
|
||||||
static data config = {MAGIC, FONT};
|
static data config = {MAGIC, FONT};
|
||||||
|
|
||||||
static unsigned long CharsToLong(unsigned char *chars)
|
static unsigned long CharsToLong(unsigned char *chars)
|
||||||
|
@ -113,7 +117,7 @@ void activatejoy(Fl_Widget*, void*){
|
||||||
|
|
||||||
void read_Config(){
|
void read_Config(){
|
||||||
std::fstream fd;
|
std::fstream fd;
|
||||||
fd.open("Config.dat", std::ios::in | std::ios::binary);
|
fd.open(config_path, std::ios::in | std::ios::binary);
|
||||||
fd.read((char*)&config, sizeof(config));
|
fd.read((char*)&config, sizeof(config));
|
||||||
fd.close();
|
fd.close();
|
||||||
if (CharsToLong(config.move) == 0){
|
if (CharsToLong(config.move) == 0){
|
||||||
|
@ -157,12 +161,29 @@ void write_Config(Fl_Widget*, void*){
|
||||||
LongToChars(button_lookup[joyRows[i]->value()]+1, config.buttons[i]);
|
LongToChars(button_lookup[joyRows[i]->value()]+1, config.buttons[i]);
|
||||||
}
|
}
|
||||||
std::fstream fd;
|
std::fstream fd;
|
||||||
fd.open("Config.dat", std::ios::out | std::ios::binary);
|
fd.open(config_path, std::ios::out | std::ios::binary);
|
||||||
fd.write((char*)&config, sizeof(config));
|
fd.write((char*)&config, sizeof(config));
|
||||||
fd.close();
|
fd.close();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
int main(int argc, char* argv[]){
|
int main(int argc, char* argv[]){
|
||||||
|
strcpy(config_path, argv[0]);
|
||||||
|
|
||||||
|
for (size_t i = strlen(config_path); ; --i)
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
strcpy(config_path, "Config.dat");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (config_path[i] == '\\' || config_path[i] == '/')
|
||||||
|
{
|
||||||
|
config_path[i] = '\0';
|
||||||
|
strcat(config_path, "/Config.dat");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Fl_Window *mainw = new Fl_Window(400, 380, "DoConfig - Doukutsu Monogatari Settings");
|
Fl_Window *mainw = new Fl_Window(400, 380, "DoConfig - Doukutsu Monogatari Settings");
|
||||||
|
|
||||||
Fl_Group *movegroup = new Fl_Group(10, 10, 185, 50);
|
Fl_Group *movegroup = new Fl_Group(10, 10, 185, 50);
|
||||||
|
|
Loading…
Add table
Reference in a new issue