00001 /* 00002 * Extended support for activating emotes 00003 * Copyright (C) 2009 Aethyra Development Team 00004 * 00005 * This file is part of The Mana World. 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 */ 00021 00022 #include "emoteshortcut.h" 00023 00024 #include "configuration.h" 00025 #include "localplayer.h" 00026 00027 #include "utils/stringutils.h" 00028 00029 EmoteShortcut::EmoteShortcut *emoteShortcut; 00030 00031 EmoteShortcut::EmoteShortcut(): 00032 mEmoteSelected(0) 00033 { 00034 for (int i = 0; i < SHORTCUT_EMOTES; i++) 00035 { 00036 mEmotes[i] = i + 1; 00037 } 00038 load(); 00039 } 00040 00041 EmoteShortcut::~EmoteShortcut() 00042 { 00043 save(); 00044 } 00045 00046 void EmoteShortcut::load() 00047 { 00048 for (int i = 0; i < SHORTCUT_EMOTES; i++) 00049 { 00050 int emoteId = (int) config.getValue("emoteshortcut" + toString(i), i + 1); 00051 00052 if (emoteId) 00053 { 00054 mEmotes[i] = emoteId; 00055 } 00056 } 00057 } 00058 00059 void EmoteShortcut::save() 00060 { 00061 for (int i = 0; i < SHORTCUT_EMOTES; i++) 00062 { 00063 const int emoteId = mEmotes[i] ? mEmotes[i] : 0; 00064 config.setValue("emoteshortcut" + toString(i), emoteId); 00065 } 00066 } 00067 00068 void EmoteShortcut::useEmote(int index) 00069 { 00070 if ((index > 0) && (index <= SHORTCUT_EMOTES)) 00071 { 00072 if (mEmotes[index - 1] > 0) 00073 { 00074 player_node->emote(mEmotes[index - 1]); 00075 } 00076 } 00077 }