void CRmtView::ReadRMTConfig()
{
#define NAME(a) (strcmp(a,name)==0)
CString s;
char line[1024];
char *tmp, *name, *value;
s.Format("%s%s", g_prgpath, CONFIG_FILENAME);
ifstream in(s);
if (!in)
{
MessageBox("Could not find: '" + s + "'\n\nRMT will use the default configuration.\n", "RMT", MB_ICONEXCLAMATION);
ResetRMTConfig(); // In order to save the default configuration file
return;
}
// Parse individual lines until the end of the file is reached
while (!in.eof())
{
in.getline(line, 1023); // Seek for the next character in memory
tmp = strchr(line, '='); // The tmp pointer will be set at the position of '='
if (!tmp) continue; // Seek for the character until a match is found
tmp[-1] = 0; // Offset by 1 to compensate the Space
name = line; // Name set to the current line, terminated by tmp
value = tmp + 2; // Offset by 1 to compensate the Space
// GENERAL
if (NAME("SCALEPERCENTAGE")) { g_scaling_percentage = atoi(value); continue; }
if (NAME("TRACKLINEPRIMARYHIGHLIGHT")) { g_trackLinePrimaryHighlight = atoi(value); continue; }
if (NAME("TRACKLINESECONDARYHIGHLIGHT")) { g_trackLineSecondaryHighlight = atoi(value); continue; }
if (NAME("TRACKLINEALTNUMBERING")) { g_tracklinealtnumbering = atoi(value); continue; }
if (NAME("DISPLAYFLATNOTES")) { g_displayflatnotes = atoi(value); continue; }
if (NAME("USEGERMANNOTATION")) { g_usegermannotation = atoi(value); continue; }
if (NAME("NTSC_SYSTEM")) { g_ntsc = atoi(value); continue; }
if (NAME("SMOOTH_SCROLL")) { g_viewDoSmoothScrolling = atoi(value); continue; }
if (NAME("NOHWSOUNDBUFFER")) { g_nohwsoundbuffer = atoi(value); continue; }
// KEYBOARD
if (NAME("KEYBOARD_LAYOUT")) { g_keyboard_layout = atoi(value); continue; }
if (NAME("KEYBOARD_UPDOWNCONTINUE")) { g_keyboard_updowncontinue = atoi(value); continue; }
if (NAME("KEYBOARD_REMEMBEROCTAVESANDVOLUMES")) { g_keyboard_RememberOctavesAndVolumes = atoi(value); continue; }
if (NAME("KEYBOARD_ESCRESETATARISOUND")) { g_keyboard_escresetatarisound = atoi(value); continue; }
if (NAME("KEYBOARD_ASKWHENCONTROL_S")) { g_keyboard_askwhencontrol_s = atoi(value); continue; }
// MIDI
if (NAME("MIDI_IN")) { g_Midi.SetDevice(value); continue; }
if (NAME("MIDI_TR")) { g_Midi.m_TouchResponse = atoi(value); continue; }
if (NAME("MIDI_VOLUMEOFFSET")) { g_Midi.m_VolumeOffset = atoi(value); continue; }
if (NAME("MIDI_NOTEOFF")) { g_Midi.m_NoteOff = atoi(value); continue; }
// PATHS
if (NAME("PATH_DEFAULTSONGS")) { g_defaultSongsPath = value; continue; }
if (NAME("PATH_DEFAULTINSTRUMENTS")) { g_defaultInstrumentsPath = value; continue; }
if (NAME("PATH_DEFAULTTRACKS")) { g_defaultTracksPath = value; continue; }
if (NAME("PATH_LASTSONGS")) { g_lastLoadPath_Songs = value; continue; }
if (NAME("PATH_LASTINSTRUMENTS")) { g_lastLoadPath_Instruments = value; continue; }
if (NAME("PATH_LASTTRACKS")) { g_lastLoadPath_Tracks = value; continue; }
// VIEW
if (NAME("VIEW_MAINTOOLBAR")) { g_viewMainToolbar = atoi(value); continue; }
if (NAME("VIEW_BLOCKTOOLBAR")) { g_viewBlockToolbar = atoi(value); continue; }
if (NAME("VIEW_STATUSBAR")) { g_viewStatusBar = atoi(value); continue; }
if (NAME("VIEW_PLAYTIMECOUNTER")) { g_viewPlayTimeCounter = atoi(value); continue; }
if (NAME("VIEW_VOLUMEANALYZER")) { g_viewVolumeAnalyzer = atoi(value); continue; }
if (NAME("VIEW_POKEYCHIPREGISTERS")) { g_viewPokeyRegisters = atoi(value); continue; }
if (NAME("VIEW_INSTRUMENTACTIVEHELP")) { g_viewInstrumentEditHelp = atoi(value); continue; }
}
in.close();
}