1 /*SENI, Search for Extra Nibiru Intelligence*/
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 Copyright SSW Team 2010
35 Option::Option(Engine
*e
)
44 Option::Option(char *f
, Engine
*e
)
52 Option::Option(char *f
, int i
, Engine
*e
)
60 int Option::getId(void)
65 void Option::setId(int i
)
70 int Option::setImage(char *f
)
74 return MENU_NO_ENGINE
;
75 strcpy(this->image
, f
);
76 this->Simage
= SDL_LoadBMP(f
);
78 strcpy(err
, "Error: SDL_LoadBMP(f): ");
79 strcat(err
, SDL_GetError());
80 this->engine
->setError(err
);
83 this->engine
->setError((char *)"No hay errores", ERROR_NO_PRINT
);
87 void Option::setEvent(option_event oe
)
92 int Option::execEvent(SDL_Event
*se
, Engine
*e
, Menu
*m
, Option
*o
)
96 return this->event(se
, e
, m
, o
);
99 int Option::show(void)
103 return MENU_NO_ENGINE
;
105 engine
->setError((char *)"Error: No se asigno imagen");
108 if(this->engine
->show(this->Simage
, this->x
, this->y
, this->Simage
->w
, this->Simage
->h
) == ENGINE_ERROR
){
109 strcpy(err
, "Error: Option->show()->engine->show(): ");
110 strcat(err
, SDL_GetError());
111 this->engine
->setError(err
);
114 // this->engine->update(this->x, this->y, this->Simage->w, this->Simage->h);
115 engine
->setError((char *)"No hay errores", ERROR_NO_PRINT
);
116 return MENU_NO_ERROR
;
120 int Option::update(void)
123 return MENU_NO_ENGINE
;
124 this->engine
->update(this->x
, this->y
, this->Simage
->w
, this->Simage
->h
);
125 return MENU_NO_ERROR
;
128 void Option::setXY(int x
, int y
)
134 int Option::getX(void)
139 int Option::getY(void)
144 int Option::getH(void)
146 return this->Simage
? this->Simage
->h
: 0;
149 int Option::getW(void)
151 return this->Simage
? this->Simage
->w
: 0;
154 void Option::setEngine(Engine
*e
)
163 for(i
= 0; i
< MAX_OPTIONS
; i
++)
164 this->options
[i
] = WITHOUT_OPTION
;
165 this->wallpaper
[0] = 0;
168 Menu::Menu(Engine
*e
)
172 for(i
= 0; i
< MAX_OPTIONS
; i
++)
173 this->options
[i
] = WITHOUT_OPTION
;
174 this->wallpaper
[0] = 0;
177 Menu::Menu(char *w
, Engine
*e
)
181 for(i
= 0; i
< MAX_OPTIONS
; i
++)
182 this->options
[i
] = WITHOUT_OPTION
;
183 this->setWallpaper(w
);
186 Menu::Menu(char *w
, Option
**o
, int im
, Engine
*e
)
190 for(i
= 0; i
< im
&& i
< MAX_OPTIONS
; i
++){
191 this->options
[i
] = o
[i
];
193 for(;i
< MAX_OPTIONS
; i
++)
194 this->options
[i
] = WITHOUT_OPTION
;
195 this->setWallpaper(w
);
198 int Menu::setWallpaper(char *w
)
201 strcpy(this->wallpaper
, w
);
202 this->Swallpaper
= SDL_LoadBMP(w
);
203 if(!this->Swallpaper
){
204 strcpy(err
, "Error: SDL_LoadBMP(w): ");
205 strcat(err
, SDL_GetError());
206 this->engine
->setError(err
);
209 this->engine
->setError((char *)"No hay errores", ERROR_NO_PRINT
);
210 return MENU_NO_ERROR
;
213 int Menu::addOption(Option
*o
)
216 for(i
= 0; i
< MAX_OPTIONS
; i
++){
217 if(this->options
[i
] == WITHOUT_OPTION
){
218 this->options
[i
] = o
;
219 return MENU_NO_ERROR
;
225 Option
*Menu::getOptionById(int oid
)
228 for(i
= 0; i
< MAX_OPTIONS
; i
++){
229 if(options
[i
] != WITHOUT_OPTION
&& options
[i
]->getId() == oid
){
236 Option
*Menu::getOption(int i
)
239 return WITHOUT_OPTION
;
240 return this->options
[i
];
243 int Menu::removeOption(int oid
)
246 for(i
= 0; i
< MAX_OPTIONS
; i
++){
247 if(options
[i
] != WITHOUT_OPTION
&& options
[i
]->getId() == oid
){
248 options
[i
] = WITHOUT_OPTION
;
249 return MENU_NO_ERROR
;
260 return MENU_NO_ENGINE
;
261 if(this->engine
->show(this->Swallpaper
, 0, 0, this->Swallpaper
->w
, this->Swallpaper
->h
) == ENGINE_ERROR
){
262 strcpy(err
, "Error: Menu->show()->engine->show(): ");
263 strcat(err
, SDL_GetError());
264 this->engine
->setError(err
);
267 // this->engine->update(0, 0, 0, 0);
268 for(i
= 0; i
< MAX_OPTIONS
; ++i
){
269 if(this->options
[i
] != WITHOUT_OPTION
){
270 int r
= this->options
[i
]->show();
271 if(r
!= MENU_NO_ERROR
)
275 return MENU_NO_ERROR
;
278 int Menu::update(void)
281 return MENU_NO_ENGINE
;
282 this->engine
->update(0, 0, 0, 0);
283 return MENU_NO_ERROR
;
286 void Menu::setEngine(Engine
*e
)