Exemplo n.º 1
0
void save_hotkeys(config& cfg)
{
	cfg.clear_children(hotkey_tag_name);

	for(std::map<int, hotkey_item>::iterator it = hotkeys.begin(); it != hotkeys.end(); ++ it) {
		hotkey_item& key = it->second;
		if (key.hidden() || key.get_type() == hotkey_item::UNBOUND)
			continue;

		config& item = cfg.add_child(hotkey_tag_name);
		item["command"] = key.get_command();
		if (key.get_type() == hotkey_item::CLEARED)
		{
			item["key"] = CLEARED_TEXT;
			continue;
		}

		if (key.get_type() == hotkey_item::BY_KEYCODE) {
			item["key"] = SDL_GetKeyName(SDLKey(key.get_keycode()));
			item["shift"] = key.get_shift();
		} else if (key.get_type() == hotkey_item::BY_CHARACTER) {
			item["key"] = utils::wchar_to_string(key.get_character());
		}
		item["alt"] = key.get_alt();
		item["ctrl"] = key.get_ctrl();
		item["cmd"] = key.get_cmd();
	}
}
Exemplo n.º 2
0
void save_hotkeys(config& cfg)
{
	cfg.clear_children(hotkey_tag_name);

	for(std::vector<hotkey_item>::iterator i = hotkeys_.begin(); i != hotkeys_.end(); ++i) {
		if (i->hidden() || i->get_type() == hotkey_item::UNBOUND || !i->is_in_active_scope())
			continue;

		config& item = cfg.add_child(hotkey_tag_name);
		item["command"] = i->get_command();
		if (i->get_type() == hotkey_item::CLEARED)
		{
			item["key"] = CLEARED_TEXT;
			continue;
		}

		if (i->get_type() == hotkey_item::BY_KEYCODE) {
			item["key"] = SDL_GetKeyName(SDLKey(i->get_keycode()));
			item["shift"] = i->get_shift() ? "yes" : "no";
		} else if (i->get_type() == hotkey_item::BY_CHARACTER) {
			item["key"] = std::string(1, static_cast<char>(i->get_character()));
		}
		item["alt"] = i->get_alt() ? "yes" : "no";
		item["ctrl"] = i->get_ctrl() ? "yes" : "no";
		item["cmd"] = i->get_cmd() ? "yes" : "no";
	}
}
Exemplo n.º 3
0
void save_hotkeys(config& cfg)
{
	cfg.clear_children("hotkey");

	for (hotkey_ptr item : hotkeys_) {
		if ((!item->is_default() && item->active()) ||
			(item->is_default() && item->is_disabled())) {
			item->save(cfg.add_child("hotkey"));
		}
	}
}
Exemplo n.º 4
0
void save_hotkeys(config& cfg)
{
	cfg.clear_children(hotkey_tag_name);

	for(std::vector<hotkey_item>::iterator i = hotkeys_.begin(); i != hotkeys_.end(); ++i) {
		if (i->hidden() || i->get_type() == hotkey_item::UNBOUND || !i->is_in_active_scope())
			continue;

		config& item = cfg.add_child(hotkey_tag_name);
		item["command"] = i->get_command();
		if (i->get_type() == hotkey_item::CLEARED)
		{
			item["key"] = CLEARED_TEXT;
			continue;
		}

		if (i->get_type() == hotkey_item::BUTTON)
		{
			item["joystick"] = i->get_joystick();
			item["button"] = i->get_button();
		}

		if (i->get_type() == hotkey_item::HAT)
		{
			item["joystick"] = i->get_joystick();
			item["hat"] = i->get_hat();
			item["value"] = i->get_value();
		}

		if (i->get_type() == hotkey_item::BY_KEYCODE) {
			item["key"] = SDL_GetKeyName(SDLKey(i->get_keycode()));
			item["shift"] = i->get_shift();
		} else if (i->get_type() == hotkey_item::BY_CHARACTER) {
			item["key"] = utils::wchar_to_string(i->get_character());
		}
		item["alt"] = i->get_alt();
		item["ctrl"] = i->get_ctrl();
		item["cmd"] = i->get_cmd();
	}
}