aboutsummaryrefslogtreecommitdiff
path: root/archive/hgehelp/parser.h
blob: c33ff110e1e9542dbc1bb1cb969f2485ed89c904 (plain) (blame)
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
/*
** Haaf's Game Engine 1.7
** Copyright (C) 2003-2007, Relish Games
** hge.relishgames.com
**
** Resource script parser header
*/

#ifndef HGEPARSER_H
#define HGEPARSER_H


#include "hge.h"
#include <string.h>
#include <stdlib.h>


enum
{
 TTNONE, TTEND, TTNUMBER, TTSTRING,

 TTBOOL, TTEQUALS, TTBASED, TTSEPARATOR, TTOPENBLOCK, TTCLOSEBLOCK,

 TTRES__FIRST,
 TTRES_INCLUDE, TTRES_RESOURCE, TTRES_TEXTURE, TTRES_SOUND, TTRES_MUSIC,
 TTRES_STREAM, TTRES_TARGET, TTRES_SPRITE, TTRES_ANIMATION, TTRES_FONT,
 TTRES_PARTICLE, TTRES_DISTORT, TTRES_STRTABLE,
 TTRES__LAST,

 TTPAR__FIRST,
 TTPAR_FILENAME, TTPAR_RESGROUP, TTPAR_MIPMAP, TTPAR_AMPLIFY, TTPAR_SIZE, TTPAR_ZBUFFER,
 TTPAR_TEXTURE, TTPAR_RECT, TTPAR_HOTSPOT, TTPAR_BLENDMODE, TTPAR_COLOR,
 TTPAR_ZORDER, TTPAR_FLIP, TTPAR_SCALE, TTPAR_PROPORTION, TTPAR_ROTATION, TTPAR_FRAMES,
 TTPAR_FPS, TTPAR_MODE, TTPAR_TRACKING, TTPAR_SPACING, TTPAR_SPRITE, TTPAR_MESH,
 TTPAR__LAST,

 TTCON__FIRST,
 TTCON_COLORMUL, TTCON_COLORADD, TTCON_ALPHABLND, TTCON_ALPHAADD, TTCON_ZWRITE,
 TTCON_NOZWRITE, TTCON_FORWARD, TTCON_REVERSE, TTCON_PINGPONG, TTCON_NOPINGPONG,
 TTCON_LOOP, TTCON_NOLOOP, TTCON_CIRCLE, TTCON_RECT, TTCON_ALPHA,
 TTCON__LAST
};


class RScriptParser
{
public:
	RScriptParser(char *name, char *scr);
	~RScriptParser() { hge->Release(); }

	int		get_token();
	void	put_back()	 { script-=strlen(tokenvalue); }
	int		get_line()	 { return line;}
	char*	get_name()	 { return scriptname;}

	char*	tkn_string() { return tokenvalue; }
	int		tkn_int()    { return atoi(tokenvalue); }
	float	tkn_float()  { return (float)atof(tokenvalue); }
	bool	tkn_bool()   { return (tokenvalue[0]=='t' || tokenvalue[0]=='T') ? true : false; }
	DWORD	tkn_hex();

	void	ScriptPostError(const char *msg1, const char *msg2);

	int		tokentype;
	char	tokenvalue[128];
	char*	script;
	char*	scriptname;
	int		line;

private:
	bool	strtkcmp(const char *str, const char *mem);

	static HGE *hge;
};


#endif