int nCurScrollNum; int nCurFourNum; void InitInterface(string iniName) { GameInterface.title = "titleCannons"; FillFourImage(); FillScroll(); GameInterface.FourImage.current = 0; nCurFourNum = -1; GameInterface.scrollcannons.current = 0; nCurScrollNum = -1; SendMessage(&GameInterface,"ls",MSG_INTERFACE_INIT,iniName); CreateString(TRUE,"Money",MakeMoneyShow(sti(Characters[GetMainCharacterIndex()].Money),"","."),FONT_NORMAL,COLOR_MONEY,320,392,SCRIPT_ALIGN_CENTER,1.0); CreateString(TRUE,"ShipName","",FONT_NORMAL,COLOR_NORMAL,320,198,SCRIPT_ALIGN_CENTER,1.0); CreateString(TRUE,"FireRange","",FONT_NORMAL,COLOR_NORMAL,400,245,SCRIPT_ALIGN_RIGHT,1.0); CreateString(TRUE,"ReloadTime","",FONT_NORMAL,COLOR_NORMAL,400,275,SCRIPT_ALIGN_RIGHT,1.0); CreateString(TRUE,"Cost","",FONT_NORMAL,COLOR_NORMAL,400,305,SCRIPT_ALIGN_RIGHT,1.0); ProcessFrame(); SetEventHandler("InterfaceBreak","ProcessCancelExit",0); SetEventHandler("frame","ProcessFrame",1); SetEventHandler("exitCancel","ProcessCancelExit",0); SetEventHandler("InstallPress","ProcessInstall",0); SetEventHandler("installSelect","ProcessInstallSelect",0); } void ProcessFrame() { if(sti(GameInterface.scrollcannons.current)!=nCurScrollNum) { nCurScrollNum = sti(GameInterface.scrollcannons.current); ref rcann = GetCannonByType(GetChoosedCannonType()); GameInterface.strings.FireRange = sti(rcann.FireRange); GameInterface.strings.ReloadTime = sti(rcann.ReloadTime); nCurFourNum = -1; } if(sti(GameInterface.FourImage.current)!=nCurFourNum) { nCurFourNum = sti(GameInterface.FourImage.current); ref rcn = GetCannonByType(GetChoosedCannonType()); ref refMyCh = GetMainCharacter(); int cn = GetCompanionIndex(refMyCh,nCurFourNum); if(cn==-1) { SetSelectable("INSTALL_BUTTON",false); GameInterface.strings.ShipName = ""; GameInterface.strings.Cost = "0"; } else { GameInterface.strings.ShipName = GetCharShipName(GetCharacter(cn)); GameInterface.strings.Cost = GetCannonDeltaPrice(GetCharacter(cn),GetChoosedCannonType()); } SetSelectable("INSTALL_BUTTON",CheckInstallEnable()); } } void FillScroll() { int i, idx; string attributeName; aref pRef; GameInterface.scrollcannons.ImagesGroup.t1 = "ICONS"; GameInterface.scrollcannons.ImagesGroup.t2 = "CANNONS"; idx=0; for(i=0; i GetCharacterMoney(GetMainCharacter()) ) { ShowHelpString("chelp_cannons#12"); return false; } if( GetCaracterShipCannonsType(GetCharacter(cn)) == GetChoosedCannonType() ) { ShowHelpString("chelp_cannons#11"); return false; } if( GetMaximumCaliber(GetCharacter(cn)) < GetCannonCaliber(GetChoosedCannonType()) ) { ShowHelpString("chelp_cannons#10"); return false; } ShowHelpString("chelp_cannons#2"); return true; } void ProcessInstallSelect() { if( GetSelectable("INSTALL_BUTTON") ) SetCurrentNode("INSTALL_BUTTON"); } int GetChoosedCannonType() { string attributeName = "pic" + (nCurScrollNum+1); if( !CheckAttribute(&GameInterface,"scrollcannons."+attributeName) ) return 0; return sti(GameInterface.scrollcannons.(attributeName).cannon); } int GetCharacterMoney(ref rChr) { ref mc = GetMainCharacter(); if( CheckAttribute(mc,"money") ) return sti(mc.money); return 0; }