1 /* Copyright (C) 1995-2002  FSGames. Ported by Sean Ford and Yan Shosh
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16  */
17 #ifndef __BUTTON_H
18 #define __BUTTON_H
19 
20 #include "base.h"
21 #include "obmap.h"
22 #include "loader.h"
23 #include "pixien.h"
24 #include "text.h"
25 #include "screen.h"
26 #include <math.h>
27 //buffers: we are putting the int32 stuff into a new file (input.cpp/h)
28 //#include "int32.h"
29 #include "input.h"
30 
31 #define MEM_TIME (long) 2000
32 class vbutton;
33 
34 // Definition of a button
35 
36 #define BUT_STR 0
37 #define BUT_DEX 1
38 #define BUT_CON 2
39 #define BUT_INT 3
40 #define BUT_ARMOR 4
41 #define BUT_LEVEL 5
42 
43 // Button edge-colors
44 #define BUTTON_FACING (char) 13 //12
45 #define BUTTON_TOP    (char) 15 //14
46 #define BUTTON_BOTTOM (char) 11 //10
47 #define BUTTON_LEFT   (char) 14 //13
48 #define BUTTON_RIGHT  (char) 12 //11
49 
50 //extern screen *myscreen;
51 extern screen *myscreen;
52 extern text *mytext;
53 extern long *mymouse;
54 extern unsigned long money[4];
55 
56 typedef struct
57 {
58 	char label[30];
59 	unsigned char hotkey;
60 	long x, y;
61 	long sizex, sizey;
62 	//long (*fun)(long arg1);
63 	long myfun;
64 	long arg1;     // argurment to function fun
65 }
66 button;
67 
68 class vbutton
69 {
70 	public:
71 		vbutton();//this should only be used for pointers!!
72 		vbutton(long xpos, long ypos, long wide, long high, long func(long),
73 		        long pass, char *msg, unsigned char hot );
74 		vbutton(long xpos, long ypos, long wide, long high, long func_code,
75 		        long pass, char *msg, unsigned char hot );
76 		vbutton(long xpos, long ypos, long wide, long high, long func_code,
77 		        long pass, char *msg, char family, unsigned char hot );
78 		~vbutton();
79 		void set_graphic(char family);
80 		long leftclick(); //is called when the button is left clicked
81 		long leftclick(long whichone);
82 		long rightclick(); //is called when the button is right clicked
83 		long rightclick(long whichone);
84 		long mouse_on(); //determins if mouse is on this button, returns 1 if true
85 		void vdisplay();
86 		void vdisplay(long status); // display depressed
87 		long do_call(long whatfunc, long arg);
88 		long do_call_right(long whatfunc, long arg);  // for right-button
89 
90 		long xloc; //the xposition in screen-coords
91 		long yloc; //the yposition in screen-coords
92 		char label[80]; //the label on the button
93 		long width; // the buttons width in pixels
94 		long height; // the buttons height in pixels
95 		long xend; //xloc+width
96 		long yend; //yloc+height
97 		long (*fun)(long arg1); //the function this button calls when clicked, with one arg
98 		long myfunc;
99 		long arg; //the arg to be passed to the function when called
100 		vbutton * next; //a pointer to the next button
101 		vbutton * prev; //a pointer to the previous button
102 		char had_focus; // did we recently have focus?
103 		char do_outline; // force an outline
104 		char depressed;
105 		pixieN *mypixie;
106 		unsigned char hotkey;
107 };
108 
109 #define MAX_BUTTONS 50  // max buttons per screen
110 extern vbutton *allbuttons[MAX_BUTTONS];
111 
112 short has_mouse_focus(button thisbutton);
113 void clearmenu(button *buttons, short numbuttons);
114 long add_money(long howmuch);
115 
116 long ventermenu(vbutton *vbuttons);
117 long vexitmenu(vbutton *vbuttons);
118 
119 vbutton * buttonmenu(button * buttons, long numbuttons);
120 vbutton * buttonmenu(button * buttons, long numbuttons, long redraw);
121 
122 // These are for picker ..
123 long score_panel(screen *myscreen);
124 long mainmenu(long arg1);
125 long beginmenu(long arg1);
126 long loadmenu(long arg1);
127 long newmenu(long arg1);
128 long quit(long arg1);
129 long nullmenu(long arg1);
130 long load1(long arg1);  // Begin a preset scenario ..
131 long load2(long arg1);
132 long load3(long arg1);
133 long create_team_menu(long arg1); // Create / modify team members
134 long create_detail_menu(guy *arg1); // detailed character information
135 long create_view_menu(long arg1); // View team members
136 long create_buy_menu(long arg1);  // Purchase new team members
137 long create_edit_menu(long arg1); // Edit or sell team members
138 long create_load_menu(long arg1); // Load a team
139 long create_save_menu(long arg1); // Save a team
140 long go_menu(long arg1); // run glad..
141 long increase_stat(long arg1, long howmuch=1); // increase a guy's stats
142 long decrease_stat(long arg1, long howmuch=1); // decrease a guy's stats
143 long calculate_cost();
144 long calculate_cost(guy * oldguy);
145 long cycle_guy(long whichway);
146 long cycle_team_guy(long whichway);
147 long add_guy(long ignoreme);
148 long edit_guy(long arg1); // transfer stats .. hardcoded
149 long do_save(long arg1);  // dummy function for save_team_list
150 long save_team_list(char * filename); // save the team list
151 long do_load(long arg1); // dummy function for load_team_list_one
152 long load_team_list_one(char * filename); // load a team list
153 long delete_all(); // delete entire team
154 long delete_first(); // delete first guy on team list
155 long how_many(long whatfamily);   // how many guys of family X on the team?
156 void statscopy(guy *dest, guy *source); //copy stats from source => dest
157 long set_player_mode(long howmany);
158 long calculate_level(unsigned long temp_exp);
159 unsigned long calculate_exp(long level);
160 void clear_levels();
161 long return_menu(long arg);
162 long name_guy(long arg); // name the current guy
163 long do_set_scen_level(long arg1);
164 long set_difficulty();
165 long change_teamnum(long arg);
166 long change_hire_teamnum(long arg);
167 long change_allied();
168 
169 // Function definitions ..
170 #define BEGINMENU               1
171 #define CREATE_TEAM_MENU        2
172 #define SET_PLAYER_MODE         3
173 #define QUIT_MENU               4
174 #define CREATE_VIEW_MENU        5
175 #define CREATE_EDIT_MENU        6
176 #define CREATE_BUY_MENU         7
177 #define CREATE_LOAD_MENU        8
178 #define CREATE_SAVE_MENU        9
179 #define GO_MENU                 10
180 #define RETURN_MENU             11
181 #define CYCLE_TEAM_GUY          12
182 #define DECREASE_STAT           13
183 #define INCREASE_STAT           14
184 #define EDIT_GUY                15
185 #define CYCLE_GUY               16
186 #define ADD_GUY                 17
187 #define DO_SAVE                 18
188 #define DO_LOAD                 19
189 #define NAME_GUY                20
190 #define CREATE_DETAIL_MENU      21
191 #define NULLMENU                22
192 #define DO_SET_SCEN_LEVEL       23
193 #define SET_DIFFICULTY          24
194 #define CHANGE_TEAM             25
195 #define ALLIED_MODE             26
196 #define CHANGE_HIRE_TEAM        27
197 #endif
198