[Gcblue-commits] gcb_wx/src/sim Game.cpp,1.111,1.112
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-12-28 00:40:29
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10434/src/sim Modified Files: Game.cpp Log Message: Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.111 retrieving revision 1.112 diff -C2 -d -r1.111 -r1.112 *** Game.cpp 11 Dec 2004 01:09:07 -0000 1.111 --- Game.cpp 28 Dec 2004 00:40:16 -0000 1.112 *************** *** 59,62 **** --- 59,63 ---- #include "tcPopupMessage.h" #include "tcLauncherPopup.h" + #include "tcUserSelectedGroups.h" #if defined(_MSC_VER) *************** *** 1955,1958 **** --- 1956,1984 ---- void tcGame::OnKeyDown(wxKeyEvent& event) { + int nChar = event.GetKeyCode(); + bool controlDown = event.ControlDown(); + bool altDown = event.AltDown(); + + + if (meGameMode == GM_START) + { + return; + } + + /* If control is down and character is a number, set user selected group + */ + if (controlDown) + { + wxString s = wxString::Format("%c", nChar); + int val = (int)strtol(s.c_str(), NULL, 10); + if ((val >= 1) && (val <= 9)) + { + tcUserSelectedGroups* groupCtrl = tcUserSelectedGroups::Get(); + + groupCtrl->SetGroup(val, hookedUnits); + } + + } + } *************** *** 1967,2000 **** long hookCount = event.m_extraLong; ! if (hookCount <= 0) { ! NewHook(-1); ! return; } ! long* groupList = reinterpret_cast<long*>(event.m_clientData); - // first object id is used for single unit displays - long primaryHook = groupList[0]; if (hookCount == 1) { NewHook(primaryHook); - delete event.m_clientData; return; } ! //tacticalMap->SetHookID(primaryHook); hookInfo->SetHookID(primaryHook); oobView->SetHookID(primaryHook); objectControl->SetHookID(primaryHook); viewer->SetHookID(primaryHook); ! ! std::vector<long> groupUnits; ! for (int n = 0; n< hookCount; n++) ! { ! groupUnits.push_back(groupList[n]); ! } pythonInterface->SetMenuGroup(groupUnits); ! delete event.m_clientData; // is this necessary? tcSound::Get()->PlayEffect(SEFFECT_SHORTBEEP); --- 1993,2041 ---- long hookCount = event.m_extraLong; ! long* groupList = reinterpret_cast<long*>(event.m_clientData); ! ! std::vector<long> groupUnits; ! for (int n = 0; n < hookCount; n++) { ! groupUnits.push_back(groupList[n]); } ! NewGroupHook(groupUnits); ! ! delete event.m_clientData; // is this necessary? ! } ! ! /** ! * ! */ ! void tcGame::NewGroupHook(std::vector<long>& groupUnits) ! { ! size_t hookCount = groupUnits.size(); ! ! if (hookCount == 0) ! { ! groupUnits.push_back(-1); // clear hook with -1 ! hookCount = 1; ! } ! ! long primaryHook = groupUnits[0]; if (hookCount == 1) { NewHook(primaryHook); return; } + ! //tacticalMap->SetHookID(primaryHook); // why commented? hookInfo->SetHookID(primaryHook); oobView->SetHookID(primaryHook); objectControl->SetHookID(primaryHook); viewer->SetHookID(primaryHook); ! tcGameObject::SetHookedId(primaryHook); ! pythonInterface->SetMenuGroup(groupUnits); ! ! hookedUnits = groupUnits; tcSound::Get()->PlayEffect(SEFFECT_SHORTBEEP); *************** *** 2032,2035 **** --- 2073,2079 ---- } tcGameObject::SetHookedId(hookID); + + hookedUnits.clear(); + hookedUnits.push_back(hookID); } *************** *** 2037,2040 **** --- 2081,2087 ---- { int nChar = event.GetKeyCode(); + bool controlDown = event.ControlDown(); + bool altDown = event.AltDown(); + if (meGameMode == GM_START) *************** *** 2050,2053 **** --- 2097,2126 ---- } + /* If control is down and character is a number, set user selected group + ** If Alt is down, set group hook to user selected group (if group is empty + ** clear the current hook) + */ + if (altDown) + { + wxString s = wxString::Format("%c", nChar); + int val = (int)strtol(s.c_str(), NULL, 10); + if ((val >= 1) && (val <= 9)) + { + tcUserSelectedGroups* groupCtrl = tcUserSelectedGroups::Get(); + if (controlDown) + { + groupCtrl->SetGroup(val, hookedUnits); + } + else + { + std::vector<long> assignedGroup = groupCtrl->GetGroup(val); + NewGroupHook(assignedGroup); + } + return; + } + + } + + // first check for control key or priority game command key switch(nChar) |