#define SHOWMOD_CONTROLSVIEW 1 #define SHOWMOD_CONTROL_SET 2 #define SHOWMOD_CONTROL_CHANGE 3 int nShowMode = 1; object objArrayControls; int qntGroup; int curGroup; int curCntrlIdx; int nLastTextGroupNum; int nLastTextStringNum; int glob_retVal; bool g_bThatIsPC; string gsKeyWindowName; int nFadeStr_AlUsed = 0; int nFadeStr_NoStick = 0; void InitInterface(string iniName) { GameInterface.title = "titleControls"; SendMessage(&GameInterface,"ls",MSG_INTERFACE_INIT,iniName); if(GetTargetPlatform()=="PC") { g_bThatIsPC = true; gsKeyWindowName = "KEYSWINDOW_PC"; } else { g_bThatIsPC = false; gsKeyWindowName = "KEYSWINDOW_XBOX"; } SetNodeUsing("CONTROLSWINDOW",false); SetNodeUsing(gsKeyWindowName,false); SetNodeUsing("CONTROLGROUP",false); SetNodeUsing("SCROLL",false); SetNodeUsing("KEY_CHOOSER",false); SetNodeUsing("KEYCHOOSE_RECT",false); SetNodeUsing("KEYCHOOSE_STRINGS",false); SetNodeUsing("SET_BUTTON",false); SetNodeUsing("DELETE_BUTTON",false); SetNodeUsing("INVERSE_BUTTON",false); SetFormatedText("RESTORE_STRINGS",XI_ConvertString("Confirm default restore keys")); SetNodeUsing("RESTORE_RECT",false); SetNodeUsing("RESTORE_STRINGS",false); SetNodeUsing("RESTORE_OK",false); SetNodeUsing("RESTORE_CANCEL",false); SetEventHandler("InterfaceBreak","ProcessCancelExit",0); SetEventHandler("exitCancel","ProcessCancelExit",0); SetEventHandler("ievnt_command","ProcessCommandExecute",0); SetEventHandler("FormatedTextActivate","procFTActivate",0); SetEventHandler("evntUpdateFormtText","procFTUpdate",0); SetEventHandler("SetScrollerPos","procFTSetScrollPos",0); SetEventHandler("evntKeyChoose","procKeyChoose",0); SetEventHandler("ScrollPosChange","ProcScrollPosChange",0); SetStartData(); aref ar; makearef(ar,objControlsState.key_codes); SendMessage(&GameInterface,"lsla",MSG_INTERFACE_MSG_TO_NODE,"KEY_CHOOSER", 0,ar); SetEventHandler("evntFadeStrings","FadeStringsUpdate",0); PostEvent("evntFadeStrings",100); } void SetStartData() { aref arGroupRoot; makearef(arGroupRoot,objControlsState.grouplist); curGroup = -1; qntGroup = GetAttributesNum(arGroupRoot); } int GetRealGroupIndex(int grNum) { aref arGroupRoot; makearef(arGroupRoot,objControlsState.grouplist); if(grNum<0 || grNum>=GetAttributesNum(arGroupRoot)) return -1; aref arCur = GetAttributeN(arGroupRoot,grNum); string groupName = GetAttributeName(arCur); makearef(arGroupRoot,objControlsState.keygroups); int q = GetAttributesNum(arGroupRoot); for(int n=0; nshowWidth) { CreateString(true,"KeyGroupName",tmpStr,FONT_NORMAL,COLOR_NORMAL,320,62,SCRIPT_ALIGN_CENTER,makefloat(showWidth)/makefloat(strWidth)); } else { CreateString(true,"KeyGroupName",tmpStr,FONT_NORMAL,COLOR_NORMAL,320,62,SCRIPT_ALIGN_CENTER,1.0); } // Прописать контроли в список DeleteAttribute(&objArrayControls,""); int i, idx, tmpcolor; aref arControl; bool bTmpBool; int qn = GetAttributesNum(arGroup); idx = 0; string cntrlText; for(i=0; i=qntGroup) newGrNum = 0; SetShowGroup(newGrNum); } void procFTActivate() { string nodName = GetEventData(); if(nodName!="CONTROLSWINDOW") return; curCntrlIdx = GetEventData(); // номер текста if( !IsEnableRemapping(curCntrlIdx) ) return; SetShowMode(SHOWMOD_CONTROL_CHANGE); } ref procKeyChoose() { int keyIdx = GetEventData(); int stickUp = GetEventData(); glob_retVal = false; if( DoMapToOtherKey(keyIdx,stickUp) ) { SetShowMode(SHOWMOD_CONTROLSVIEW); Event("evntUpdateFormtText","sll","CONTROLSWINDOW", nLastTextGroupNum, nLastTextStringNum); glob_retVal = true; } return &glob_retVal; } void procFTUpdate() { string nodName = GetEventData(); if(nodName!="CONTROLSWINDOW") return; int grNum = GetEventData(); // первая группа в изменениях int strNum = GetEventData(); // первая строка в изменениях object objPos,obj; DeleteAttribute(&objPos,""); SendMessage(&GameInterface,"lsla",MSG_INTERFACE_MSG_TO_NODE,"CONTROLSWINDOW", 3,&objPos); SetFormatedText(gsKeyWindowName,""); int i,qn,posnum; qn = GetAttributesNum(&objPos); int idx=0; for(i=0; i=0) { idx = SetKeysStrings(grNum+i,posnum,idx); } } nLastTextGroupNum = grNum; nLastTextStringNum = strNum; } void procFTSetScrollPos() { string nodName = GetEventData(); float fpos = GetEventData(); if(nodName=="CONTROLSWINDOW") { SendMessage(&GameInterface,"lsf",MSG_INTERFACE_SET_SCROLLER,"SCROLL",fpos); } } int SetKeysStrings(int grNum, int newpos, int oldpos) { int i; string tmpStr; string keyStr = " "; for(i=oldpos; i0 ) { nFadeStr_AlUsed--; if(nFadeStr_AlUsed==0) { GameInterface.strings.AlreadyUsed = ""; } else { color = argb(GetAlphaFromFade(nFadeStr_AlUsed),255,255,255); CreateString(true,"AlreadyUsed",XI_ConvertString("Button Already Used"),FONT_NORMAL,color,320,258,SCRIPT_ALIGN_CENTER,1.0); } } if( nFadeStr_NoStick>0 ) { nFadeStr_NoStick--; if(nFadeStr_NoStick==0) { GameInterface.strings.AlreadyUsed = ""; } else { color = argb(GetAlphaFromFade(nFadeStr_NoStick),255,255,255); CreateString(true,"AlreadyUsed",XI_ConvertString("thumbstick cannot be used"),FONT_NORMAL,color,320,258,SCRIPT_ALIGN_CENTER,1.0); } } PostEvent("evntFadeStrings",100); } int GetAlphaFromFade(int n) { int alpha = n*20; if(alpha>255) alpha = 255; if(alpha<0) alpha = 0; return alpha; }