mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- Fixed: Keys bound in a custom key section would unbind the key in the
main game section. SVN r1409 (trunk)
This commit is contained in:
parent
f867f40bab
commit
8d9bc8cc67
5 changed files with 80 additions and 19 deletions
|
@ -1,5 +1,7 @@
|
|||
February 6, 2009
|
||||
- Fixed scrolling of the automap background on a rotating automap.
|
||||
- Fixed: Keys bound in a custom key section would unbind the key in the
|
||||
main game section.
|
||||
- Fixed scrolling of the automap background on a rotated automap.
|
||||
|
||||
February 5, 2009
|
||||
- Changed singleplayer allowrespawn to act like a co-op game when you
|
||||
|
|
|
@ -580,35 +580,61 @@ bool C_DoKey (event_t *ev)
|
|||
return false;
|
||||
}
|
||||
|
||||
const char *C_ConfigKeyName(int keynum)
|
||||
{
|
||||
const char *name = KeyName(keynum);
|
||||
if (name[1] == 0) // Make sure given name is config-safe
|
||||
{
|
||||
if (name[0] == '[')
|
||||
return "LeftBracket";
|
||||
else if (name[0] == ']')
|
||||
return "RightBracket";
|
||||
else if (name[0] == '=')
|
||||
return "Equals";
|
||||
else if (strcmp (name, "kp=") == 0)
|
||||
return "KP-Equals";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
// This function is first called for functions in custom key sections.
|
||||
// In this case, matchcmd is non-NULL, and only keys bound to that command
|
||||
// are stored. If a match is found, its binding is set to "\1".
|
||||
// After all custom key sections are saved, it is called one more for the
|
||||
// normal Bindings and DoubleBindings sections for this game. In this case
|
||||
// matchcmd is NULL and all keys will be stored. The config section was not
|
||||
// previously cleared, so all old bindings are still in place. If the binding
|
||||
// for a key is empty, the corresponding key in the config is removed as well.
|
||||
// If a binding is "\1", then the binding itself is cleared, but nothing
|
||||
// happens to the entry in the config.
|
||||
void C_ArchiveBindings (FConfigFile *f, bool dodouble, const char *matchcmd)
|
||||
{
|
||||
FString *bindings;
|
||||
const char *name;
|
||||
int i;
|
||||
|
||||
bindings = dodouble ? DoubleBindings : Bindings;
|
||||
|
||||
for (i = 0; i < NUM_KEYS; i++)
|
||||
{
|
||||
if (!bindings[i].IsEmpty() && (matchcmd==NULL || stricmp(bindings[i], matchcmd)==0))
|
||||
if (bindings[i].IsEmpty())
|
||||
{
|
||||
name = KeyName (i);
|
||||
if (name[1] == 0) // Make sure given name is config-safe
|
||||
if (matchcmd == NULL)
|
||||
{
|
||||
if (name[0] == '[')
|
||||
name = "LeftBracket";
|
||||
else if (name[0] == ']')
|
||||
name = "RightBracket";
|
||||
else if (name[0] == '=')
|
||||
name = "Equals";
|
||||
else if (strcmp (name, "kp=") == 0)
|
||||
name = "KP-Equals";
|
||||
f->ClearKey(C_ConfigKeyName(i));
|
||||
}
|
||||
f->SetValueForKey (name, bindings[i]);
|
||||
}
|
||||
else if (matchcmd == NULL || stricmp(bindings[i], matchcmd) == 0)
|
||||
{
|
||||
if (bindings[i][0] == '\1')
|
||||
{
|
||||
bindings[i] = "";
|
||||
continue;
|
||||
}
|
||||
f->SetValueForKey(C_ConfigKeyName(i), bindings[i]);
|
||||
if (matchcmd != NULL)
|
||||
{ // If saving a specific command, remove the old binding
|
||||
// so it does not get saved in the general binding list
|
||||
Bindings[i] = "";
|
||||
{ // If saving a specific command, set a marker so that
|
||||
// it does not get saved in the general binding list.
|
||||
bindings[i] = "\1";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -332,6 +332,40 @@ void FConfigFile::ClearCurrentSection ()
|
|||
}
|
||||
}
|
||||
|
||||
//====================================================================
|
||||
//
|
||||
// FConfigFile :: ClearKey
|
||||
//
|
||||
// Removes a key from the current section, if found. If there are
|
||||
// duplicates, only the first is removed.
|
||||
//
|
||||
//====================================================================
|
||||
|
||||
void FConfigFile::ClearKey(const char *key)
|
||||
{
|
||||
if (CurrentSection->RootEntry == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FConfigEntry **prober = &CurrentSection->RootEntry, *probe = *prober;
|
||||
|
||||
while (probe != NULL && stricmp(probe->Key, key) != 0)
|
||||
{
|
||||
prober = &probe->Next;
|
||||
probe = *prober;
|
||||
}
|
||||
if (probe != NULL)
|
||||
{
|
||||
*prober = probe->Next;
|
||||
if (CurrentSection->LastEntryPtr == &probe->Next)
|
||||
{
|
||||
CurrentSection->LastEntryPtr = prober;
|
||||
}
|
||||
delete[] probe->Value;
|
||||
delete[] (char *)probe;
|
||||
}
|
||||
}
|
||||
|
||||
//====================================================================
|
||||
//
|
||||
// FConfigFile :: SectionIsEmpty
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
bool SetNextSection ();
|
||||
const char *GetCurrentSection () const;
|
||||
void ClearCurrentSection ();
|
||||
void ClearKey (const char *key);
|
||||
|
||||
bool SectionIsEmpty ();
|
||||
bool NextInSection (const char *&key, const char *&value);
|
||||
|
|
|
@ -454,12 +454,10 @@ void FGameConfigFile::ArchiveGameData (const char *gamename)
|
|||
|
||||
strcpy (subsection, "Bindings");
|
||||
SetSection (section, true);
|
||||
ClearCurrentSection ();
|
||||
C_ArchiveBindings (this, false);
|
||||
|
||||
strncpy (subsection, "DoubleBindings", sublen);
|
||||
SetSection (section, true);
|
||||
ClearCurrentSection ();
|
||||
C_ArchiveBindings (this, true);
|
||||
|
||||
if (WeaponSection.IsEmpty())
|
||||
|
|
Loading…
Reference in a new issue