#include "StdAfx.h" #include "ShortcutManager.h" #include "KeyboardAgent.h" #include "Application.h" #include "RenderSystem.h" #include "UIManager.h" #include "GameUIManager.h" #include "ShortcutWindow.h" #include "RowQuickSlot.h" #include "ColumnQuickSlot.h" #include "Parser.h" #include "StageManager.h" #include "GameResourceManager.h" cShortcutManager* cShortcutManager::mpShortcutManager = NULL; const char* const SCRIPT_PATH_FILE = "./script/interface/path_shortcut.txt"; cShortcutLexer::cShortcutLexer(const char *buffer, unsigned int size) : cLexer( buffer, size ) { BindKeyword( "shortcut", eTOKEN_SHORTCUT ); BindKeyword( "keyboard", eTOKEN_KEYBORAD ); } cShortcutManager::cShortcutManager() { mpShortcutManager = this; } cShortcutManager::~cShortcutManager() { mpShortcutManager = 0; sKeyboardMap::cIterator pos = mKeyboardKey.Begin(); sKeyboardMap::cIterator end = mKeyboardKey.End(); for( ; pos != end; ++pos ) { sKeyboardInfo* pKeyInfo = (sKeyboardInfo*)(*pos).mSecond; SAFE_DELETE( pKeyInfo ); } sKeyMap::cIterator pos2 = mKeyboardScriptMap.Begin(); sKeyMap::cIterator end2 = mKeyboardScriptMap.End(); for( ; pos2 != end2; ++pos2 ) { sKeyboardScript* pKeyboardInfo = (sKeyboardScript*)(*pos2).mSecond; SAFE_DELETE( pKeyboardInfo ); } sKeyMap::cIterator pos3 = mShortcutScriptMap.Begin(); sKeyMap::cIterator end3 = mShortcutScriptMap.End(); for( ; pos3 != end3; ++pos3 ) { sShortcutScript* pShorcutInfo = (sShortcutScript*)(*pos3).mSecond; SAFE_DELETE( pShorcutInfo ); } } bool cShortcutManager::ProcessKeyPressed( cKeyboardAgent* /*keyInfo*/ ) { /// stage¿¡ »ó°ü ¾ø´Â °øÅë 󸮺κÐÀ» ³Ö¾î¶ó.. return false; } bool cShortcutManager::ProcessKeyUpDown( cKeyboardAgent* keyInfo ) { /// stage¿¡ »ó°ü ¾ø´Â °øÅë 󸮺κÐÀ» ³Ö¾î¶ó.. /// ½Ã½ºÅÛ°ü·Ã Ű ÀÔ·ÂÀº À̰÷¿¡ ³ÖÀ»°Í.. if( keyInfo->GetKeyPressed(KEY_CONTROL) ) { #if (defined(_DEVSYS) || defined(_DEBUG)) /// ÇÁ·Î±×·¥À» Á¾·áÇÏÁö ¾Ê°í ½ºÅ²¸¸ ÀçÀû¿ë °¡´ÉÇÏ´Ù. if( keyInfo->GetKeyDown( KEY_F5 ) ) { /// ½ºÅ² ÆÄÀÏ ·Îµù ÈÄ ÀçÀû¿ë UIMAN->ChangeSkin( "./Script/Interface/List_SkinImage.txt" ); return true; } #endif return false; } if( keyInfo->GetKeyDown( KEY_SCREENSHOT ) ) { /// ½ºÅ©¸°¼¦.. THEAPP->SetSaveScreenShot( true ); return true; } else if( keyInfo->GetKeyDown( KEY_SCROLL ) ) { /// °ÔÀÓ ½ºÅ×ÀÌÁö³ª ij¸¯ÅÍ ¼±ÅÃ, »ý¼º Áß¿¡¸¸ »ç¿ë°¡´É if( RENDERSYS ) { switch( STAGEMAN->GetCurrentStage() ) { case eStage_Login : case eStage_Select: case eStage_Make : case eStage_Game : if( RENDERSYS->IsVideoCapturing() ) RENDERSYS->ToggleVideoCapture(); else { /// Msgbox Ãâ·Â UIMAN->CreateMsgBox( eStage_Make, eMSGBOX_MODAL, eMBEVENT_VIDEO_CAPTURE, eSKIN_YESNO, GAMERESOURCEMAN->GetGameText( 10003 ), GAMERESOURCEMAN->GetGameText( 2 ) // ¾Ë¸² ); } break; default : ///¸ðµç ¸ðµå¿¡¼­ ²ô±â Áö¿ø if( RENDERSYS->IsVideoCapturing() == true ) RENDERSYS->ToggleVideoCapture(); break; } } return true; } return false; } bool cShortcutManager::InitShortcut() { sKeyMap::cIterator pos = mShortcutScriptMap.Begin(); sKeyMap::cIterator end = mShortcutScriptMap.End(); for( ; pos != end; ++pos ) { int index = (*pos).mFirst; sShortcutScript* pShorcutInfo = (sShortcutScript*)(*pos).mSecond; if( pShorcutInfo ) mShortCutKey.Insert( index, pShorcutInfo->mKeyboardIndex ); else { assert(0); return false; } } if( mShortcutScriptMap.GetSize() > 0 ) return true; else return false; } bool cShortcutManager::InitKeyboard() { sKeyMap::cIterator pos = mKeyboardScriptMap.Begin(); sKeyMap::cIterator end = mKeyboardScriptMap.End(); for( ; pos != end; ++pos ) { int index = (*pos).mFirst; sKeyboardScript* pKeyboardInfo = (sKeyboardScript*)(*pos).mSecond; if( pKeyboardInfo ) { sKeyboardInfo* pKeyInfo = new sKeyboardInfo; pKeyInfo->mKey = pKeyboardInfo->mKey; pKeyInfo->mMixKey = pKeyboardInfo->mMixKey; mKeyboardKey.Insert( index, pKeyInfo ); } else { assert(0); return false; } } if( mKeyboardScriptMap.GetSize() > 0 ) return true; else return false; } void cShortcutManager::ResetShortcut() { /// ´ÜÃàŰ Á¤º¸ ÃʱâÈ­ sShortCutMap::cIterator pos = mShortCutKey.Begin(); sShortCutMap::cIterator end = mShortCutKey.End(); for( ; pos!=end; ++pos ) { int index = (*pos).mFirst; sShortcutScript* pShorcutInfo = (sShortcutScript*)mShortcutScriptMap.GetAt( index ); if( pShorcutInfo ) { (*pos).mSecond = pShorcutInfo->mKeyboardIndex; } else (*pos).mSecond = -1; } } void cShortcutManager::ResetKeyboard() { sKeyMap::cIterator pos = mShortcutScriptMap.Begin(); sKeyMap::cIterator end = mShortcutScriptMap.End(); for( ; pos != end; ++pos ) { int index = (*pos).mFirst; sShortcutScript* pShorcutInfo = (sShortcutScript*)(*pos).mSecond; if( pShorcutInfo ) { sKeyboardInfo* pKeyInfo = (sKeyboardInfo*)mKeyboardKey.GetAt( pShorcutInfo->mKeyboardIndex ); if( pKeyInfo ) { pKeyInfo->mShortcutIndex = index; } } else assert(0); } } void cShortcutManager::UpdateAllIconByKeyboard() { cShortcutWindow* pShortcutWindow = GAMEUI->GetShortcutWindow(); if( !pShortcutWindow ) return; cFSRowQuickSlot* fsRowQuickSlotWindow = GAMEUI->GetFSRowQuickSlot(); cFSColumnQuickSlot* fsColumnQuickSlotWindow = GAMEUI->GetFSColumnQuickSlot(); if( !fsRowQuickSlotWindow || !fsColumnQuickSlotWindow ) { assert(0); return; } cRowQuickSlot* rowQuickSlotWindow = GAMEUI->GetRowQuickSlot( QUICKTYPE_COMMON ); cRowQuickSlot* rowQuickExtra1Window = GAMEUI->GetRowQuickSlot( QUICKTYPE_COMMON_EXTRA1 ); cRowQuickSlot* rowQuickExtra2Window = GAMEUI->GetRowQuickSlot( QUICKTYPE_COMMON_EXTRA2 ); cColumnQuickSlot* columnQuickSlotWindow = GAMEUI->GetColumnQuickSlot( QUICKTYPE_COMMON ); cColumnQuickSlot* columnQuickExtra1Window = GAMEUI->GetColumnQuickSlot( QUICKTYPE_COMMON_EXTRA1 ); cColumnQuickSlot* columnQuickExtra2Window = GAMEUI->GetColumnQuickSlot( QUICKTYPE_COMMON_EXTRA2 ); if( !rowQuickSlotWindow || !rowQuickExtra1Window || !rowQuickExtra2Window || !columnQuickSlotWindow || !columnQuickExtra1Window || !columnQuickExtra2Window ) { assert(0); return; } /// ´ÜÃàŰ Á¤º¸ ÃʱâÈ­ sShortCutMap::cIterator pos = mShortCutKey.Begin(); sShortCutMap::cIterator end = mShortCutKey.End(); for( ; pos!=end; ++pos ) { (*pos).mSecond = -1; } /// Űº¸µå¿¡ ÀÖ´Â ´ÜÃàŰ Á¤º¸´ë·Î ´ÜÃà ¾ÆÀÌÄÜ Á¤º¸¸¦ ¼ÂÆÃÇÑ´Ù. sKeyboardMap::cIterator pos2 = mKeyboardKey.Begin(); sKeyboardMap::cIterator end2 = mKeyboardKey.End(); for( ; pos2 != end2; ++pos2 ) { // Űº¸µå¿¡ ÀÖ´Â ´ÜÃàŰ Á¤º¸´ë·Î ´ÜÃà ¾ÆÀÌÄÜ Á¤º¸¸¦ ¼ÂÆÃÇÑ´Ù. int index = (*pos2).mFirst; sKeyboardInfo* pKeyInfo = (sKeyboardInfo*)(*pos2).mSecond; if( pKeyInfo && pKeyInfo->mShortcutIndex != -1 ) { mShortCutKey[pKeyInfo->mShortcutIndex] = index; } } /// Űº¸µå¿¡ ±×·ÁÁø ¾ÆÀÌÄÜÀ» ±×¸®°í ´ÜÃà¾ÆÀÌÄܵéÀ» ±âº» À§Ä¡¿¡ ¼ÂÆÃÇÑ´Ù. pShortcutWindow->ClearAllKeyboardIcon(); pShortcutWindow->ClearAllShortcutIcon(); sShortCutMap::cIterator pos3 = mShortCutKey.Begin(); sShortCutMap::cIterator end3 = mShortCutKey.End(); for( ; pos3!=end3; ++pos3 ) { int index = (*pos3).mFirst; /// Äü½½·Ô »ó¿¡ À̹ÌÁö °»½Å if( eKEY_COMMON_QUICK1 <= index && index <= eKEY_COMMON_QUICK0 ) { rowQuickSlotWindow->ChangeShortcut( index - eKEY_COMMON_QUICK1, mShortCutKey[index] ); columnQuickSlotWindow->ChangeShortcut( index - eKEY_COMMON_QUICK1, mShortCutKey[index] ); } if( eKEY_QUICK1 <= index && index <= eKEY_QUICK0 ) { fsRowQuickSlotWindow->ChangeShortcut( index - eKEY_QUICK1, mShortCutKey[index] ); fsColumnQuickSlotWindow->ChangeShortcut( index - eKEY_QUICK1, mShortCutKey[index] ); } if( eKEY_EXTRA1_QUICK1 <= index && index <= eKEY_EXTRA1_QUICK0 ) { rowQuickExtra1Window->ChangeShortcut( index - eKEY_EXTRA1_QUICK1, mShortCutKey[index] ); columnQuickExtra1Window->ChangeShortcut( index - eKEY_EXTRA1_QUICK1, mShortCutKey[index] ); } if( eKEY_EXTRA2_QUICK1 <= index && index <= eKEY_EXTRA2_QUICK0 ) { rowQuickExtra2Window->ChangeShortcut( index - eKEY_EXTRA2_QUICK1, mShortCutKey[index] ); columnQuickExtra2Window->ChangeShortcut( index - eKEY_EXTRA2_QUICK1, mShortCutKey[index] ); } /// ۸¦ ¼ÂÆÃÇÏÁö ¾ÊÀº ¾ÆÀÌÄÜÀº ±âº» ´ÜÃàŰ ¼ÂÆÃ À§Ä¡¿¡ Ç¥½ÃÇÑ´Ù. if( mShortCutKey[index] < 0 ) { pShortcutWindow->SetShortcutIcon( index ); continue; } pShortcutWindow->UpdateKeyboardIcon( mShortCutKey[index], index ); } } void cShortcutManager::UpdateAllIconByShortcut() { cShortcutWindow* pShortcutWindow = GAMEUI->GetShortcutWindow(); if( !pShortcutWindow ) { assert(0); return; } cFSRowQuickSlot* fsRowQuickSlotWindow = GAMEUI->GetFSRowQuickSlot(); cFSColumnQuickSlot* fsColumnQuickSlotWindow = GAMEUI->GetFSColumnQuickSlot(); if( !fsRowQuickSlotWindow || !fsColumnQuickSlotWindow ) { assert(0); return; } cRowQuickSlot* rowQuickSlotWindow = GAMEUI->GetRowQuickSlot( QUICKTYPE_COMMON ); cRowQuickSlot* rowQuickExtra1Window = GAMEUI->GetRowQuickSlot( QUICKTYPE_COMMON_EXTRA1 ); cRowQuickSlot* rowQuickExtra2Window = GAMEUI->GetRowQuickSlot( QUICKTYPE_COMMON_EXTRA2 ); cColumnQuickSlot* columnQuickSlotWindow = GAMEUI->GetColumnQuickSlot( QUICKTYPE_COMMON ); cColumnQuickSlot* columnQuickExtra1Window = GAMEUI->GetColumnQuickSlot( QUICKTYPE_COMMON_EXTRA1 ); cColumnQuickSlot* columnQuickExtra2Window = GAMEUI->GetColumnQuickSlot( QUICKTYPE_COMMON_EXTRA2 ); if( !rowQuickSlotWindow || !rowQuickExtra1Window || !rowQuickExtra2Window || !columnQuickSlotWindow || !columnQuickExtra1Window || !columnQuickExtra2Window ) { assert(0); return; } /// Űº¸µå¿¡ ÀÖ´Â ´ÜÃàŰ Á¤º¸ ÃʱâÈ­. sKeyboardMap::cIterator pos= mKeyboardKey.Begin(); sKeyboardMap::cIterator end = mKeyboardKey.End(); for( ; pos != end; ++pos ) { // Űº¸µå¿¡ ÀÖ´Â ´ÜÃàŰ Á¤º¸´ë·Î ´ÜÃà ¾ÆÀÌÄÜ Á¤º¸¸¦ ¼ÂÆÃÇÑ´Ù. sKeyboardInfo* pKeyInfo = (sKeyboardInfo*)(*pos).mSecond; if( pKeyInfo ) { pKeyInfo->mShortcutIndex = -1; } else { assert(0); } } /// ´ÜÃàŰ¿¡ ÀÖ´Â Á¤º¸´ë·Î Űº¸µå¿¡ ´ÜÃà ¾ÆÀÌÄÜ ¼ÂÆÃ sShortCutMap::cIterator pos2 = mShortCutKey.Begin(); sShortCutMap::cIterator end2 = mShortCutKey.End(); for( ; pos2!=end2; ++pos2 ) { int index = (*pos2).mFirst; int shortcutKey = (*pos2).mSecond; if( shortcutKey != -1 ) { sKeyboardInfo* pKeyInfo = (sKeyboardInfo*)mKeyboardKey.GetAt( shortcutKey ); if( pKeyInfo ) { pKeyInfo->mShortcutIndex = index; } } } /// Űº¸µå¿¡ ±×·ÁÁø ¾ÆÀÌÄÜÀ» ±×¸®°í ´ÜÃà¾ÆÀÌÄܵéÀ» ±âº» À§Ä¡¿¡ ¼ÂÆÃÇÑ´Ù. pShortcutWindow->ClearAllKeyboardIcon(); pShortcutWindow->ClearAllShortcutIcon(); sShortCutMap::cIterator pos3 = mShortCutKey.Begin(); sShortCutMap::cIterator end3 = mShortCutKey.End(); for( ; pos3!=end3; ++pos3 ) { int index = (*pos3).mFirst; /// Äü½½·Ô »ó¿¡ À̹ÌÁö °»½Å if( eKEY_COMMON_QUICK1 <= index && index <= eKEY_COMMON_QUICK0 ) { rowQuickSlotWindow->ChangeShortcut( index - eKEY_COMMON_QUICK1, mShortCutKey[index] ); columnQuickSlotWindow->ChangeShortcut( index - eKEY_COMMON_QUICK1, mShortCutKey[index] ); } if( eKEY_QUICK1 <= index && index <= eKEY_QUICK0 ) { fsRowQuickSlotWindow->ChangeShortcut( index - eKEY_QUICK1, mShortCutKey[index] ); fsColumnQuickSlotWindow->ChangeShortcut( index - eKEY_QUICK1, mShortCutKey[index] ); } if( eKEY_EXTRA1_QUICK1 <= index && index <= eKEY_EXTRA1_QUICK0 ) { rowQuickExtra1Window->ChangeShortcut( index - eKEY_EXTRA1_QUICK1, mShortCutKey[index] ); columnQuickExtra1Window->ChangeShortcut( index - eKEY_EXTRA1_QUICK1, mShortCutKey[index] ); } if( eKEY_EXTRA2_QUICK1 <= index && index <= eKEY_EXTRA2_QUICK0 ) { rowQuickExtra2Window->ChangeShortcut( index - eKEY_EXTRA2_QUICK1, mShortCutKey[index] ); columnQuickExtra2Window->ChangeShortcut( index - eKEY_EXTRA2_QUICK1, mShortCutKey[index] ); } /// ۸¦ ¼ÂÆÃÇÏÁö ¾ÊÀº ¾ÆÀÌÄÜÀº ±âº» ´ÜÃàŰ ¼ÂÆÃ À§Ä¡¿¡ Ç¥½ÃÇÑ´Ù. if( mShortCutKey[index] < 0 ) { pShortcutWindow->SetShortcutIcon( index ); continue; } pShortcutWindow->UpdateKeyboardIcon( mShortCutKey[index], index ); } } void cShortcutManager::UpdateKeyboardIcon() { cShortcutWindow* pShortcutWindow = GAMEUI->GetShortcutWindow(); if( !pShortcutWindow ) { assert(0); return; } sKeyboardMap::cIterator pos= mKeyboardKey.Begin(); sKeyboardMap::cIterator end = mKeyboardKey.End(); for( ; pos != end; ++pos ) { int index = (*pos).mFirst; sKeyboardInfo* pKeyInfo = (sKeyboardInfo*)(*pos).mSecond; if( pKeyInfo && pKeyInfo->mShortcutIndex >= 0 ) { pShortcutWindow->UpdateKeyboardIcon( index, pKeyInfo->mShortcutIndex ); } } } void cShortcutManager::SetShortcut( int fromShortcutIndex, int toKeyboardIndex ) { sKeyboardInfo* pKeyInfo = (sKeyboardInfo*)mKeyboardKey.GetAt( toKeyboardIndex ); if( pKeyInfo == 0 ) { assert( 0 && "Wrong Keyboard Index" ); return; } if( mShortCutKey.Find( fromShortcutIndex ) == mShortCutKey.End() ) { assert( 0 && "Wrong Shortcut Index" ); return; } cShortcutWindow* pShortcutWindow = GAMEUI->GetShortcutWindow(); if( !pShortcutWindow ) { assert( 0 ); return; } /// ±âÁ¸¿¡ µé¾îÀÖ´Â Á¤º¸°¡ ÀÖ´Ù¸é ÃʱâÈ­ ½ÃŰ°í µ¥ÀÌÅÍ »ðÀÔ. int toShortcutIdx = pKeyInfo->mShortcutIndex; if( mShortCutKey.Find( toShortcutIdx ) != mShortCutKey.End() ) { pShortcutWindow->SetShortcutIcon( toShortcutIdx ); pKeyInfo->mShortcutIndex = fromShortcutIndex; } else { pKeyInfo->mShortcutIndex = fromShortcutIndex; } pShortcutWindow->UpdateKeyboardIcon( toKeyboardIndex, fromShortcutIndex ); pShortcutWindow->UpdateSelect( toKeyboardIndex ); } void cShortcutManager::MoveShortcut( int fromKeyboardIndex, int toKeyboardIndex ) { sKeyboardInfo* pFromKeyInfo = (sKeyboardInfo*)mKeyboardKey.GetAt( fromKeyboardIndex ); if( pFromKeyInfo == 0 ) { assert( 0 && "Wrong Keyboard Index" ); return; } sKeyboardInfo* pToKeyInfo = (sKeyboardInfo*)mKeyboardKey.GetAt( toKeyboardIndex ); if( pToKeyInfo == 0 ) { assert( 0 && "Wrong Keyboard Index" ); return; } int fromShortcutIdx; int toShortcutIdx; fromShortcutIdx = pFromKeyInfo->mShortcutIndex; toShortcutIdx = pToKeyInfo->mShortcutIndex; /// »õ·Î À̵¿ÇÒ °÷¿¡ ÀÌ¹Ì ´ÜÃà۰¡ ¼³Á¤µÇ¾î À־ swap ÇØ¾ß Çϴ°æ¿ì if( mShortCutKey.Find( toShortcutIdx ) != mShortCutKey.End() ) { /// Űº¸µåÀÇ ´ÜÃàŰ À妽º °»½Å pFromKeyInfo->mShortcutIndex = toShortcutIdx; pToKeyInfo->mShortcutIndex = fromShortcutIdx; } else if( mShortCutKey.Find( fromShortcutIdx ) != mShortCutKey.End() && pFromKeyInfo ) { /// »õ·Î À̵¿ÇÒ °÷¿¡ ¾Æ¹«·± ´ÜÃà۰¡ ¼³Á¤ µÇ¾î ÀÖÁö ¾Ê´Â °æ¿ì. pToKeyInfo->mShortcutIndex = fromShortcutIdx; pFromKeyInfo->mShortcutIndex = -1; } cShortcutWindow* pShortcutWindow = GAMEUI->GetShortcutWindow(); if( pShortcutWindow ) { pShortcutWindow->UpdateKeyboardIcon( fromKeyboardIndex, toShortcutIdx ); pShortcutWindow->UpdateKeyboardIcon( toKeyboardIndex, fromShortcutIdx ); pShortcutWindow->UpdateSelect( toKeyboardIndex ); } } void cShortcutManager::EraseShortcut(int keyboardIndex ) { sKeyboardInfo* pKeyInfo = (sKeyboardInfo*)mKeyboardKey.GetAt( keyboardIndex ); if( pKeyInfo == 0 ) { assert( 0 && "Wrong Keyboard Index" ); return; } int shortcutIdx = pKeyInfo->mShortcutIndex; /// Űº¸µå¿¡¼­ ´ÜÃàŰ Á¤º¸ »èÁ¦ pKeyInfo->mShortcutIndex = -1; /// Űº¸µå â¿¡ ¾ÆÀÌÄÜÀ» »èÁ¦ÇÏ°í ´ÜÃàŰ â¿¡¼­ ¾ÆÀÌÄÜÀ» Ç¥½ÃÇÑ´Ù cShortcutWindow* pShortcutWindow = GAMEUI->GetShortcutWindow(); if( pShortcutWindow ) { pShortcutWindow->ClearKeyboardIcon( keyboardIndex ); pShortcutWindow->SetShortcutIcon( shortcutIdx ); pShortcutWindow->HideSelectImage(); } } bool cShortcutManager::IsSettingChanged() { /// Űº¸µåÀÇ ´ÜÃàŰ À妽º °Ë»ç sKeyboardMap::cIterator pos= mKeyboardKey.Begin(); sKeyboardMap::cIterator end = mKeyboardKey.End(); for( ; pos != end; ++pos ) { int index = (*pos).mFirst; sKeyboardInfo* pKeyInfo = (sKeyboardInfo*)(*pos).mSecond; if( pKeyInfo && pKeyInfo->mShortcutIndex >= 0 ) { sShortCutMap::cIterator pos; pos = mShortCutKey.Find( pKeyInfo->mShortcutIndex ); if( pos != mShortCutKey.End() ) { int findKeyboardIndex = pos->mSecond; if( index != findKeyboardIndex ) return true; } } } /// ´ÜÃàŰ À妽º °Ë»ç. sShortCutMap::cIterator pos2 = mShortCutKey.Begin(); sShortCutMap::cIterator end2 = mShortCutKey.End(); for( ; pos2!=end2; ++pos2 ) { int index = (*pos2).mFirst; int shortcutKey = (*pos2).mSecond; sKeyboardInfo* pKeyInfo = (sKeyboardInfo*)mKeyboardKey.GetAt( shortcutKey ); if( pKeyInfo ) { if( index != pKeyInfo->mShortcutIndex ) return true; } } return false; } void cShortcutManager::ClearKeyboard() { sKeyboardMap::cIterator pos= mKeyboardKey.Begin(); sKeyboardMap::cIterator end = mKeyboardKey.End(); for( ; pos != end; ++pos ) { sKeyboardInfo* pKeyInfo = (sKeyboardInfo*)(*pos).mSecond; if( pKeyInfo ) pKeyInfo->mShortcutIndex = -1; else assert(0); } } unsigned char cShortcutManager::GetShortcutKey( int index ) { sShortCutMap::cIterator pos; pos = mShortCutKey.Find( index ); if( pos != mShortCutKey.End() ) { int findKeyboardIndex = pos->mSecond; sKeyboardInfo* pKeyInfo = (sKeyboardInfo*)mKeyboardKey.GetAt( findKeyboardIndex ); if( pKeyInfo ) return pKeyInfo->mKey; } return 0; } sKeyboardInfo* cShortcutManager::GetShortcutKeyInfo( int index ) { sShortCutMap::cIterator pos; pos = mShortCutKey.Find( index ); if( pos != mShortCutKey.End() ) { int findKeyboardIndex = pos->mSecond; sKeyboardInfo* pKeyInfo = (sKeyboardInfo*)mKeyboardKey.GetAt( findKeyboardIndex ); if( pKeyInfo ) return pKeyInfo; } return 0; } void cShortcutManager::SetShortCutValue( int index, int value ) { sShortCutMap::cIterator pos; pos = mShortCutKey.Find( index ); if( pos == mShortCutKey.End() ) { //assert(0); ///±âÁ¸ ´ÜÃà۸¦ »èÁ¦ÇÒ °æ¿ì µé¾î¿É´Ï´Ù. return; } sKeyboardInfo* pKeyInfo = (sKeyboardInfo*)mKeyboardKey.GetAt( value ); if( pKeyInfo ) { mShortCutKey[index] = value; } else { mShortCutKey[index] = -1; //assert(0); /// ±âÁ¸ Űº¸µå¿¡¼­ »ç¿ë¸øÇϴ Ű¸¦ Ãß°¡ÇßÀ» °æ¿ì µé¾î¿É´Ï´Ù. } } int cShortcutManager::GetShortCutValue( int index ) { sShortCutMap::cIterator pos; pos = mShortCutKey.Find( index ); if( pos != mShortCutKey.End() ) { return pos->mSecond; } else { assert(0); return -1; } } bool cShortcutManager::Init() { /// scirpt load if ( LoadShortcutPath( SCRIPT_PATH_FILE ) ) { if( InitShortcut() == true && InitKeyboard() == true ) return true; } return false; } bool cShortcutManager::LoadShortcutPath( const cString& pathName ) { cFileLoader loader; if( loader.Open( pathName, true ) == false ) { assert( 0 && "failed to load path shortcut" ); return false; } /// ·º¼­¿¡ ¹äÁÖ°í ÆÄ½Ì cToken token; cShortcutLexer lexer( loader.GetBufferPtr(), loader.GetSize() ); cParser parser( &lexer, pathName ); while( lexer.IsEnd() == false ) { lexer.GetNextToken( &token ); switch( token.mType ) { case eTOKEN_ERROR: return false; case eTOKEN_NULL: continue; case cShortcutLexer::eTOKEN_SHORTCUT: { if( parser.ExpectTokenString( "{" ) == false ) { assert( 0 && "wrong script" ); return false; } cToken token; cLexer* lexer = parser.GetLexer(); while( lexer->GetNextToken( &token ) ) { if( token == "}" ) { break; } int index = token.ToInt(); sShortcutScript *pShortcutInfo = new sShortcutScript; if( pShortcutInfo ) { pShortcutInfo->mPathIconIndex = parser.ParseInt(); pShortcutInfo->mKeyboardIndex = parser.ParseInt(); pShortcutInfo->mIconPosX = parser.ParseInt(); pShortcutInfo->mIconPosY = parser.ParseInt(); if( mShortcutScriptMap.Insert( index, pShortcutInfo ) == false ) { assert(0); SAFE_DELETE( pShortcutInfo ); return false; } } } } break; case cShortcutLexer::eTOKEN_KEYBORAD: { if( parser.ExpectTokenString( "{" ) == false ) { assert( 0 && "wrong script" ); return false; } cToken token; cLexer* lexer = parser.GetLexer(); while( lexer->GetNextToken( &token ) ) { if( token == "}" ) { break; } int index = token.ToInt(); sKeyboardScript *pKeyboardInfo = new sKeyboardScript; if( pKeyboardInfo ) { pKeyboardInfo->mKey = (unsigned char)parser.ParseInt(); pKeyboardInfo->mMixKey = (unsigned char)parser.ParseInt(); pKeyboardInfo->mIconPosX = parser.ParseInt(); pKeyboardInfo->mIconPosY = parser.ParseInt(); if( mKeyboardScriptMap.Insert( index, pKeyboardInfo ) == false ) { assert(0); SAFE_DELETE( pKeyboardInfo ); return false; } } } } break; default: assert( 0 && "invalid token" ); return false; } } return true; }