This is HProductionState.m in view mode; [Download] [Up]
// // $Id: HProductionState.m,v 1.2 1997/10/31 03:38:21 nygard Exp $ // // // This file is a part of Empire, a game of exploration and conquest. // Copyright (C) 1996 Steve Nygard // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // // You may contact the author by: // e-mail: nygard@telusplanet.net // #import "Empire.h" RCSID ("$Id: HProductionState.m,v 1.2 1997/10/31 03:38:21 nygard Exp $"); #import "HProductionState.h" #import "City.h" #import "Human.h" #import "Map.h" #import "MapView.h" #import "Unit.h" //====================================================================== // Show a map with all the units removed, and replace cities by the // type of unit they are producing. Cities may still be selected and // their production changed. //====================================================================== @implementation HProductionState //====================================================================== // Subclass responsibilities //====================================================================== - (NSString *) stateName { return @"Production"; } //---------------------------------------------------------------------- - (NSString *) stateKey { return HS_PRODUCTION; } //---------------------------------------------------------------------- - (void) stateEntered:(Human *)context { MapView *mapView = [context mapView]; Map *productionMap = [[context map] copyWithZone:[self zone]]; // Do we need to autorelease this? NSEnumerator *cityEnumerator; City *city; // Set cursor [mapView useDefaultCursor]; [mapView setFastCursor:NO]; [mapView setCursorEnabled:YES]; [context setStatusLine:@""]; [productionMap stripIcons]; cityEnumerator = [[context cityList] objectEnumerator]; while (city = [cityEnumerator nextObject]) { [productionMap setToken:EMCreateMapToken (t_city, [[city owner] playerNumber], EMConvertUnitTypeToBaseIcon ([city productionType]), YES) atLocation:[city cityLocation]]; } [mapView setMap:productionMap]; [context enableContinueButton:YES]; [context enableEndTurnButton:NO]; } //---------------------------------------------------------------------- - (void) continue:(Human *)context { MapView *mapView = [context mapView]; Map *productionMap = [mapView map]; [mapView setMap:[context map]]; SNRelease (productionMap); [context restoreState]; } //---------------------------------------------------------------------- - (void) mouseDown:(Human *)context:(unsigned int)modifierFlags atLocation:(EMMapLocation)target { [self selectThing:context atLocation:target andInspect:YES]; } //---------------------------------------------------------------------- - (void) selectThing:(Human *)context atLocation:(EMMapLocation)target andInspect:(BOOL)inspectFlag { id anObject = nil; Map *map = [context map]; MapToken mapToken = [map tokenAtLocation:target]; [[context mapView] positionCursorAtLocation:target]; [context selectUnit:nil]; [context setStatusLine:@""]; if (EMTerrainComponent (mapToken) == t_city && EMExploredComponent (mapToken) == YES) { anObject = [context cityAtLocation:target]; } else if (EMPlayerComponent (mapToken) == [context playerNumber] && EMIconComponent (mapToken) != i_none && EMExploredComponent (mapToken) == YES) { Unit *unit = [context primaryUnitAtLocation:target]; anObject = unit; [context selectUnit:unit]; [context setStatusLine:[unit statusLine]]; } if (inspectFlag == YES) [context selectThing:anObject]; } //====================================================================== // Commands //====================================================================== - (void) centerScreen:(Human *)context mapView:(MapView *)mapView { [mapView centerScreenAroundCursor]; } //====================================================================== // Interface Management //====================================================================== - (void) cityProductionChanged:(Human *)context city:(City *)theCity { MapView *mapView = [context mapView]; Map *productionMap = [mapView map]; [productionMap setToken:EMCreateMapToken (t_city, [[theCity owner] playerNumber], EMConvertUnitTypeToBaseIcon ([theCity productionType]), YES) atLocation:[theCity cityLocation]]; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.