File: image.c

package info (click to toggle)
ale-clone 1.15pre16.3-1
  • links: PTS
  • area: contrib
  • in suites: potato
  • size: 2,432 kB
  • ctags: 3,217
  • sloc: ansic: 37,483; sh: 1,105; makefile: 343
file content (116 lines) | stat: -rw-r--r-- 2,683 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
**	A clone of a famous game.
*/
/**@name image.c	-	The standard images. */
/*
**	(c) Copyright 1998,1999 by Lutz Sammer
**
**	$Id: image.c,v 1.13 1999/11/21 21:59:58 root Exp $
*/

//@{

/*----------------------------------------------------------------------------
--	Includes
----------------------------------------------------------------------------*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "clone.h"
#include "video.h"
#include "sound_id.h"
#include "unitsound.h"
#include "unittype.h"
#include "player.h"
#include "image.h"

/*----------------------------------------------------------------------------
--	Variables
----------------------------------------------------------------------------*/

/**
**	Constant graphics
**
**	FIXME: most should be moved into user interface.
*/
struct _images_ {
    char*	File[PlayerMaxRaces];	/// one file for each race
    unsigned	Width;			/// graphic size width
    unsigned	Height;			/// graphic size height

// --- FILLED UP ---
    OldGraphic	Image;			/// graphic image (filled)
} Images[] = {
    { { "Map border (Top,Humans).png"
	,"Map border (Top,Orcs).png" }
		,448,16 },
    { { "Map border (Bottom,Humans).png"
	,"Map border (Bottom,Orcs).png" }
		,448,16 },
    { { "Map border (Right,Humans).png"
	,"Map border (Right,Orcs).png" }
		,16,480 },
    { { "Minimap border (Top,Humans).png"
	,"Minimap border (Top,Orcs).png" }
		,176,24 },
    { { "Minimap (Humans).png"
	,"Minimap (Orcs).png" }
		,176,136 },
    { { "human panel.png"
	,"orcish panel.png" }
		,176,176 },
    { { "Panel (Bottom,Humans).png"
	,"Panel (Bottom,Orcs).png" }
		,176,144 },
    { { "gold,wood,oil,mana.png"
	,NULL }
		, 14, 14 },
    { { "bloodlust,haste,slow,invis.,shield.png"
	,NULL }
		, 16, 16 },
};

/**
**	Draw image on screen.
**
**	@param image	Image number (=index).
**	@param row	Image row
**	@param frame	Image frame
**	@param X	X position.
**	@param Y	Y position.
*/
global void DrawImage(int image,int row,int frame,int x,int y)
{
    DrawOldGraphic(&Images[image].Image
	,frame*Images[image].Width,row*Images[image].Height
	,Images[image].Width,Images[image].Height,x,y);
}

/**
**	Load all images.
*/
global void LoadImages(void)
{
    int i;
    const char* file;
    char* buf;

    //
    //	Load all images, depends on the race of the player on this computer.
    //
    for( i=0; i<sizeof(Images)/sizeof(*Images); ++i ) {
	file=Images[i].File[ThisPlayer->Race];
	if( !file ) {			// default one
	    file=Images[i].File[0];
	}

	buf=alloca(strlen(file)+9+1);
	file=strcat(strcpy(buf,"graphic/"),file);
	ShowLoadProgress("\tImage %s\n",file);
	LoadOldGraphic(file,&Images[i].Image);
    }
}

//@}