[Gcblue-commits] gcb_wx/scripts AirManagement.py, NONE, 1.1 GameMenuCommands.py, NONE, 1.1 AI.py, 1
Status: Alpha
Brought to you by:
ddcforge
From: Dewitt C. <ddc...@us...> - 2006-08-17 01:29:14
|
Update of /cvsroot/gcblue/gcb_wx/scripts In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv22611/scripts Modified Files: AI.py Menu.py Added Files: AirManagement.py GameMenuCommands.py Log Message: Update for server name change --- NEW FILE: GameMenuCommands.py --- from random import * deg_to_rad = 0.01745329252 rad_to_deg = 57.2957795131 # workaround that passes UI object when nothing is hooked to # do a command pass-through def YellowBlueMap(UI): UI.SendCommand("YellowBlueMap") def CopperMap(UI): UI.SendCommand("CopperMap") def BlackBlueMap(UI): UI.SendCommand("BlackBlueMap") --- NEW FILE: AirManagement.py --- def RefuelAllAircraft(TI): UI = TI.GetPlatformInterface() FP = UI.GetFlightPortInfo() if (not FP.IsValid()): UI.DisplayMessage('No flightport') TI.EndTask() TI.SetUpdateInterval(20) nUnits = FP.GetUnitCount() for n in range(0, nUnits): unitStatus = FP.GetUnitStatus(n) unitName = unitStatus.name unitLoc = unitStatus.current_loc UI_n = FP.GetUnitPlatformInterface(n) if (UI_n.GetFuel() < 1.0) and (not UI_n.IsRefueling()): UI_n.DisplayMessage('Refueling %s' % unitName) UI_n.LoadOther('Fuel') def MaintainCAP(TI): UI = TI.GetPlatformInterface() FP = UI.GetFlightPortInfo() if (not FP.IsValid()): UI.DisplayMessage('No flightport') TI.EndTask() ######## FlightPort scripts ##### ##def BuildFlightPortPanel(UserPanel, FlightPortInfo, UnitInfo): ## # UnitInfo.DisplayMessage('BuildFlightPortPanelCalled') ## UserPanel.Clear() ## UserPanel.SetTitle('Flight Deck Control') ## ## # draw buttons for heading row ## UserPanel.AddItem('Unit Type','',10,10,80,12) ## UserPanel.BoldLastItem() ## UserPanel.AddItem('Location','',90,10,50,12) ## UserPanel.BoldLastItem() ## UserPanel.AddItem('Dest','',140,10,50,12) ## UserPanel.BoldLastItem() ## UserPanel.AddItem('Move','',190,10,60,12) ## UserPanel.BoldLastItem() ## UserPanel.AddItem('','',250,10,40,12) ## UserPanel.AddItem('','',290,10,40,12) ## nUnits = FlightPortInfo.GetUnitCount() ## rowy = 22 ## startx = 10 ## for n in range(0, nUnits): ## rowx = startx ## # two buttons for unit info ## unitStatus = FlightPortInfo.GetUnitStatus(n) ## unitName = unitStatus.name ## unitLoc = unitStatus.current_loc ## if (unitStatus.atDestination): ## unitGoalLoc = '---' ## else: ## unitGoalLoc = unitStatus.goal_loc ## ## bwidth = 80 ## UserPanel.AddItem(unitName,'',rowx,rowy,bwidth,12) ## rowx = rowx + bwidth ## bwidth = 50 ## UserPanel.AddItem(unitLoc,'',rowx,rowy,bwidth,12) ## rowx = rowx + bwidth ## UserPanel.AddItem(unitGoalLoc,'',rowx,rowy,bwidth,12) ## rowx = rowx + bwidth ## # buttons to move units to different positions on flight deck ## # hangar ## bwidth = 20 ## UserPanel.AddItemWithParam('H','MoveToHangar',n,rowx,rowy,bwidth,12) ## rowx = rowx + bwidth ## # Ready (on deck) ## UserPanel.AddItemWithParam('D','MoveToReady',n,rowx,rowy,bwidth,12) ## rowx = rowx + bwidth ## # Runway ## UserPanel.AddItemWithParam('R','MoveToRunway',n,rowx,rowy,bwidth,12) ## rowx = rowx + bwidth ## # Op time ## bwidth = 40 ## if (unitStatus.isIdle == 0): ## current_time = FlightPortInfo.GetCurrentTime() ## op_time = unitStatus.ready_time ## delta = op_time - current_time ## str = '%04.0f' % delta ## else: ## str = '' ## UserPanel.AddItem(str,'',rowx,rowy,bwidth,12) ## rowx = rowx + bwidth ## # Launch ## bwidth = 40 ## if (unitStatus.runway != -1): ## cmdstr = 'LaunchRunway%d' % unitStatus.runway ## UserPanel.AddItem('Launch',cmdstr,rowx,rowy,bwidth,12) ## else: ## UserPanel.AddItem('','',rowx,rowy,bwidth,12) ## rowx = rowx + bwidth ## ## rowy = rowy + 12 ## ##def LaunchRunway0(FlightPort): ## LaunchRunway(FlightPort, 0) ## ##def LaunchRunway1(FlightPort): ## LaunchRunway(FlightPort, 1) ## ##def LaunchRunway2(FlightPort): ## LaunchRunway(FlightPort, 2) ## ##def LaunchRunway(FlightPort, n): ## FlightPort.Launch(n) ## ##def MoveToHangar(FlightPort, n): ## FlightPort.SetDestination(n, 0) # 0 = Hangar ## ##def MoveToReady(FlightPort, n): ## FlightPort.SetDestination(n, 1) # 1 = Ready ## ##def MoveToRunway(FlightPort, n): ## FlightPort.SetDestination(n, 3) # 2 = Runway Index: AI.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/AI.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** AI.py 18 Jun 2006 00:47:42 -0000 1.26 --- AI.py 17 Aug 2006 01:29:11 -0000 1.27 *************** *** 2,5 **** --- 2,6 ---- from SubTactics import * from Landing import * + from AirManagement import * import math Index: Menu.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/Menu.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Menu.py 18 Jun 2006 00:47:42 -0000 1.23 --- Menu.py 17 Aug 2006 01:29:11 -0000 1.24 *************** *** 1,4 **** --- 1,5 ---- from UnitCommands import * from MissionEditCommands import * + from GameMenuCommands import * from HotKey import * from FlightPort import * *************** *** 360,363 **** --- 361,365 ---- # top-level edit menu def BuildEditMenu(UnitMenu, SM): + page_count = 25 UnitMenu.Clear() *************** *** 371,427 **** ### Create surface ship submenu ### UnitMenu.AddItem('Surface','') ! ! UnitMenu.BeginSubMenu() ! platforms = SM.GetPlatformListByClass('Surface') ! nPlatforms = platforms.Size() ! for n in range(0, nPlatforms): ! className = platforms.GetString(n) ! UnitMenu.AddItemUIWithTextParam('%s' % className, 'AddNewPlatform', 'Datum', className) ! UnitMenu.EndSubMenu() ! ### Create submarine submenu ### UnitMenu.AddItem('Submarine','') ! ! UnitMenu.BeginSubMenu() ! platforms = SM.GetPlatformListByClass('Sub') ! nPlatforms = platforms.Size() ! for n in range(0, nPlatforms): ! className = platforms.GetString(n) ! UnitMenu.AddItemUIWithTextParam('%s' % className, 'AddNewPlatform', 'Datum', className) ! UnitMenu.EndSubMenu() ! ### Create fixed wing air submenu ### UnitMenu.AddItem('Air fixed wing','') ! ! UnitMenu.BeginSubMenu() ! platforms = SM.GetPlatformListByClass('AirFW') ! nPlatforms = platforms.Size() ! for n in range(0, nPlatforms): ! className = platforms.GetString(n) ! UnitMenu.AddItemUIWithTextParam('%s' % className, 'AddNewPlatform', 'Datum', className) ! UnitMenu.EndSubMenu() ### Create helo submenu ### UnitMenu.AddItem('Helo','') ! ! UnitMenu.BeginSubMenu() ! platforms = SM.GetPlatformListByClass('Helo') ! nPlatforms = platforms.Size() ! for n in range(0, nPlatforms): ! className = platforms.GetString(n) ! UnitMenu.AddItemUIWithTextParam('%s' % className, 'AddNewPlatform', 'Datum', className) ! UnitMenu.EndSubMenu() ### Create land submenu ### UnitMenu.AddItem('Land','') ! ! UnitMenu.BeginSubMenu() ! platforms = SM.GetPlatformListByClass('Land') ! nPlatforms = platforms.Size() ! for n in range(0, nPlatforms): ! className = platforms.GetString(n) ! UnitMenu.AddItemUIWithTextParam('%s' % className, 'AddNewPlatform', 'Datum', className) ! UnitMenu.EndSubMenu() UnitMenu.EndSubMenu() --- 373,397 ---- ### Create surface ship submenu ### UnitMenu.AddItem('Surface','') ! BuildPagedCreateMenu(SM, UnitMenu, 'Surface', page_count) ! ### Create submarine submenu ### UnitMenu.AddItem('Submarine','') ! BuildPagedCreateMenu(SM, UnitMenu, 'Sub', page_count) ! ### Create fixed wing air submenu ### UnitMenu.AddItem('Air fixed wing','') ! BuildPagedCreateMenu(SM, UnitMenu, 'AirFW', page_count) ! ### Create helo submenu ### UnitMenu.AddItem('Helo','') ! BuildPagedCreateMenu(SM, UnitMenu, 'Helo', page_count) ! ### Create land submenu ### UnitMenu.AddItem('Land','') ! BuildPagedCreateMenu(SM, UnitMenu, 'Land', page_count) ! UnitMenu.EndSubMenu() *************** *** 432,453 **** ### Create fixed wing air on carrier or airstrip ### UnitMenu.AddItem('Air fixed wing','') ! UnitMenu.BeginSubMenu() ! platforms = SM.GetPlatformListByClass('AirFW') ! nPlatforms = platforms.Size() ! for n in range(0, nPlatforms): ! className = platforms.GetString(n) ! UnitMenu.AddItemUIWithTextParam('%s' % className, 'AddNewPlatformToFlightDeck', 'Target', className) ! UnitMenu.EndSubMenu() ! ### Create helo on carrier or airstrip ### UnitMenu.AddItem('Helo','') ! UnitMenu.BeginSubMenu() ! platforms = SM.GetPlatformListByClass('Helo') ! nPlatforms = platforms.Size() ! for n in range(0, nPlatforms): ! className = platforms.GetString(n) ! UnitMenu.AddItemUIWithTextParam('%s' % className, 'AddNewPlatformToFlightDeck', 'Target', className) ! UnitMenu.EndSubMenu() --- 402,411 ---- ### Create fixed wing air on carrier or airstrip ### UnitMenu.AddItem('Air fixed wing','') ! BuildPagedCreateChildMenu(SM, UnitMenu, 'AirFW', page_count) ! ### Create helo on carrier or airstrip ### UnitMenu.AddItem('Helo','') ! BuildPagedCreateChildMenu(SM, UnitMenu, 'Helo', page_count) *************** *** 455,457 **** --- 413,459 ---- + def BuildPagedCreateMenu(SM, Menu, create_class, page_count): + Menu.BeginSubMenu() + platforms = SM.GetPlatformListByClass(create_class) + nPlatforms = platforms.Size() + if (nPlatforms > page_count): + nSubmenus = nPlatforms/page_count + 1 + for sm in range(0, nSubmenus): + Menu.AddItem('Page %d' % (sm+1),'') + Menu.BeginSubMenu() + nPlatformsPage = min(page_count, nPlatforms - sm*page_count) + for n in range(0, nPlatformsPage): + className = platforms.GetString(n+sm*page_count) + Menu.AddItemUIWithTextParam('%s' % className, 'AddNewPlatform', 'Datum', className) + Menu.EndSubMenu() + else: + for n in range(0, nPlatforms): + className = platforms.GetString(n) + Menu.AddItemUIWithTextParam('%s' % className, 'AddNewPlatform', 'Datum', className) + Menu.EndSubMenu() + + + def BuildPagedCreateChildMenu(SM, Menu, create_class, page_count): + Menu.BeginSubMenu() + platforms = SM.GetPlatformListByClass(create_class) + nPlatforms = platforms.Size() + if (nPlatforms > page_count): + nSubmenus = nPlatforms/page_count + 1 + for sm in range(0, nSubmenus): + Menu.AddItem('Page %d' % (sm+1),'') + Menu.BeginSubMenu() + nPlatformsPage = min(page_count, nPlatforms - sm*page_count) + for n in range(0, nPlatformsPage): + className = platforms.GetString(n+sm*page_count) + Menu.AddItemUIWithTextParam('%s' % className, 'AddNewPlatformToFlightDeck', 'Target', className) + Menu.EndSubMenu() + else: + for n in range(0, nPlatforms): + className = platforms.GetString(n) + Menu.AddItemUIWithTextParam('%s' % className, 'AddNewPlatformToFlightDeck', 'Target', className) + Menu.EndSubMenu() + + + + |