Win32 - UpdateHotkeyAssignments() - code cleanup

This commit is contained in:
adelikat 2009-05-09 19:36:03 +00:00
parent a8a53aa82e
commit b0669283e7
1 changed files with 15 additions and 19 deletions

View File

@ -4001,40 +4001,36 @@ void UpdateHotkeyAssignments()
{ {
extern void TranslateKey(WORD keyz,char *out); //adelikat: Yeah hackey extern void TranslateKey(WORD keyz,char *out); //adelikat: Yeah hackey
//Update all menu items that can be called from a hotkey to include the current hotkey assignment //Update all menu items that can be called from a hotkey to include the current hotkey assignment
char itemText[255]; //To get the current text from a mnue item char str[255]; //Temp string
string text; //Used to manipulate menu item text string text; //Used to manipulate menu item text
string keyname; //Used to hold the name of the hotkey string keyname; //Used to hold the name of the hotkey
int truncate; //Used to truncate the hotkey config from the menu item int truncate; //Used to truncate the hotkey config from the menu item
char tempKey[100]; //Used to poss to TranslateKey
//-------------------------------FILE--------------------------------------- //-------------------------------FILE---------------------------------------
//Open ROM //Open ROM
GetMenuString(mainMenu,IDM_OPEN, itemText, 255, IDM_OPEN); //Get menu item text GetMenuString(mainMenu,IDM_OPEN, str, 255, IDM_OPEN); //Get menu item text
text = itemText; //Store in string object text = str; //Store in string object
truncate = text.find("\t"); //Find the tab truncate = text.find("\t"); //Find the tab
if (truncate >= 1) //Truncate if it exists if (truncate >= 1) //Truncate if it exists
text = text.substr(0,truncate); text = text.substr(0,truncate);
TranslateKey(CustomKeys.OpenROM.key, tempKey); TranslateKey(CustomKeys.OpenROM.key, str);
keyname = tempKey; keyname = str;
keyname.insert(0,GetModifierString(CustomKeys.OpenROM.modifiers)); keyname.insert(0,GetModifierString(CustomKeys.OpenROM.modifiers));
text.append("\t"); text.append("\t" + keyname);
text.append(keyname);
ChangeMenuItemText(IDM_OPEN, text); ChangeMenuItemText(IDM_OPEN, text);
//Save Screenshot As... //Save Screenshot As...
GetMenuString(mainMenu,IDM_PRINTSCREEN, itemText, 255, IDM_PRINTSCREEN); //Get menu item text GetMenuString(mainMenu,IDM_PRINTSCREEN, str, 255, IDM_PRINTSCREEN);
text = itemText; //Store in string object text = str;
truncate = text.find("\t"); //Find the tab truncate = text.find("\t");
if (truncate >= 1) //Truncate if it exists if (truncate >= 1)
text = text.substr(0,truncate); text = text.substr(0,truncate);
TranslateKey(CustomKeys.PrintScreen.key, tempKey); TranslateKey(CustomKeys.PrintScreen.key, str);
keyname = tempKey; //Get key & modifiers keyname = str;
keyname.insert(0,GetModifierString(CustomKeys.PrintScreen.modifiers)); keyname.insert(0,GetModifierString(CustomKeys.PrintScreen.modifiers));
text.append("\t"); text.append("\t" + keyname);
text.append(keyname);
ChangeMenuItemText(IDM_PRINTSCREEN, text); ChangeMenuItemText(IDM_PRINTSCREEN, text);
} }