ftp.nice.ch/Attic/openStep/games/Empire.0.6.m.NIS.bs.tgz#/Empire.0.6/src/WorldMapController.m

This is WorldMapController.m in view mode; [Download] [Up]

//
// $Id: WorldMapController.m,v 1.9 1997/10/31 04:52:15 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: WorldMapController.m,v 1.9 1997/10/31 04:52:15 nygard Exp $");

#import "WorldMapController.h"

#import "EmpireImageVendor.h"
#import "EmPlayer.h"
#import "GameManager.h"
#import "Unit.h"
#import "WorldMapView.h"

static int panelCount = 0;

//======================================================================
// The WorldMapController loads the World Map window, and passes
// messages from the world map view along to the delegate.
//
// That may be a little redundant, and the setDelegate could just
// set the delegate of the WorldMapView...
//======================================================================

#define WorldMapController_VERSION 1

@implementation WorldMapController

+ (void) initialize
{
    if (self == [WorldMapController class])
    {
        [self setVersion:WorldMapController_VERSION];
    }
}

//----------------------------------------------------------------------

- (void) awakeFromNib
{
    NSString *imagePath;
    NSImage *image;

    imagePath = [[NSBundle mainBundle] pathForImageResource:@"mwi_world_map.tiff"];
    NSAssert (imagePath != nil, @"Couldn't find mwi_world_map.tiff");

    image = [[[NSImage alloc] initWithContentsOfFile:imagePath] autorelease];
    NSAssert (image != nil, @"Couldn't load mwi_world_map.tiff");

    [worldMapWindow setMiniwindowImage:image];
}

//----------------------------------------------------------------------

- init
{
    NSString *nibFile;
    BOOL loaded;
    NSRect frameRect;

    [super init];

    worldMapView = nil;

    nibFile = @"WorldMap.nib";
    loaded = [NSBundle loadNibNamed:nibFile owner:self];
    if (loaded == NO)
    {
        NSLog (@"Could not load %@.", nibFile);
        [super dealloc];
        return nil;
    }

    frameRect = [worldMapWindow frame];
    frameRect.origin.x += panelCount * 24;
    frameRect.origin.y -= panelCount * 24;
    [worldMapWindow setFrameOrigin:frameRect.origin];

    panelCount = (panelCount + 1) % 5;

    return self;
}

//----------------------------------------------------------------------

- (void) dealloc
{
    SNRelease (worldMapWindow);

    [super dealloc];
}

//----------------------------------------------------------------------

- (void) setMap:(Map *)aMap
{
    [worldMapView setMap:aMap];
}

//----------------------------------------------------------------------

- (void) setDelegate:newDelegate
{
    delegate = newDelegate;

    if (delegate == nil)
        [worldMapWindow setDelegate:self];
    else
        [worldMapWindow setDelegate:delegate];
}

//----------------------------------------------------------------------

- (void) setTitle:(NSString *)newTitle autosaveFrame:(BOOL)autosaveFlag
{
    BOOL okay;

    [worldMapWindow setTitle:newTitle];
    if (autosaveFlag == YES)
    {
        okay = [worldMapWindow setFrameAutosaveName:newTitle];
        if (okay == NO)
            NSLog (@"Could not set frame autosave name of World Map panel.");
    }
}

//----------------------------------------------------------------------

- (void) showPanel
{
    [worldMapWindow makeKeyAndOrderFront:self];
}

//======================================================================
// MapView Delegate
//======================================================================

- (void) mouseDown:(unsigned int)modifierFlags atLocation:(EMMapLocation)target
{
    if (delegate != nil)
        [delegate mouseDown:modifierFlags atLocation:target];
}

//----------------------------------------------------------------------

- (void) mouseUp:(unsigned int)modifierFlags atLocation:(EMMapLocation)target
{
    if (delegate != nil)
        [delegate mouseUp:modifierFlags atLocation:target];
}

//----------------------------------------------------------------------

- (void) rightMouseDown:(unsigned int)modifierFlags atLocation:(EMMapLocation)target
{
}

//----------------------------------------------------------------------

- (void) rightMouseUp:(unsigned int)modifierFlags atLocation:(EMMapLocation)target
{
}

//----------------------------------------------------------------------

- (void) keyDown:(NSEvent *)theEvent 
{
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.