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");
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)
102 return MENU_NO_ENGINE
;
104 engine
->setError((char *)"Error: No se asigno imagen");
107 if(this->engine
->show(this->Simage
, this->x
, this->y
, this->Simage
->w
, this->Simage
->h
) == ENGINE_ERROR
)
109 // this->engine->update(this->x, this->y, this->Simage->w, this->Simage->h);
110 return MENU_NO_ERROR
;
114 int Option::update(void)
117 return MENU_NO_ENGINE
;
118 this->engine
->update(this->x
, this->y
, this->Simage
->w
, this->Simage
->h
);
119 return MENU_NO_ERROR
;
122 void Option::setXY(int x
, int y
)
128 int Option::getX(void)
133 int Option::getY(void)
138 int Option::getH(void)
140 return this->Simage
? this->Simage
->h
: 0;
143 int Option::getW(void)
145 return this->Simage
? this->Simage
->w
: 0;
148 void Option::setEngine(Engine
*e
)
157 for(i
= 0; i
< MAX_OPTIONS
; i
++)
158 this->options
[i
] = WITHOUT_OPTION
;
159 this->wallpaper
[0] = 0;
162 Menu::Menu(Engine
*e
)
166 for(i
= 0; i
< MAX_OPTIONS
; i
++)
167 this->options
[i
] = WITHOUT_OPTION
;
168 this->wallpaper
[0] = 0;
171 Menu::Menu(char *w
, Engine
*e
)
175 for(i
= 0; i
< MAX_OPTIONS
; i
++)
176 this->options
[i
] = WITHOUT_OPTION
;
177 this->setWallpaper(w
);
180 Menu::Menu(char *w
, Option
**o
, int im
, Engine
*e
)
184 for(i
= 0; i
< im
&& i
< MAX_OPTIONS
; i
++){
185 this->options
[i
] = o
[i
];
187 for(;i
< MAX_OPTIONS
; i
++)
188 this->options
[i
] = WITHOUT_OPTION
;
189 this->setWallpaper(w
);
192 int Menu::setWallpaper(char *w
)
195 strcpy(this->wallpaper
, w
);
196 this->Swallpaper
= SDL_LoadBMP(w
);
197 if(!this->Swallpaper
){
198 strcpy(err
, "Error: SDL_LoadBMP(w): ");
199 strcat(err
, SDL_GetError());
200 this->engine
->setError(err
);
203 this->engine
->setError((char *)"No hay errores");
204 return MENU_NO_ERROR
;
207 int Menu::addOption(Option
*o
)
210 for(i
= 0; i
< MAX_OPTIONS
; i
++){
211 if(this->options
[i
] == WITHOUT_OPTION
){
212 this->options
[i
] = o
;
213 return MENU_NO_ERROR
;
219 Option
*Menu::getOptionById(int oid
)
222 for(i
= 0; i
< MAX_OPTIONS
; i
++){
223 if(options
[i
] != WITHOUT_OPTION
&& options
[i
]->getId() == oid
){
230 Option
*Menu::getOption(int i
)
233 return WITHOUT_OPTION
;
234 return this->options
[i
];
237 int Menu::removeOption(int oid
)
240 for(i
= 0; i
< MAX_OPTIONS
; i
++){
241 if(options
[i
] != WITHOUT_OPTION
&& options
[i
]->getId() == oid
){
242 options
[i
] = WITHOUT_OPTION
;
243 return MENU_NO_ERROR
;
253 return MENU_NO_ENGINE
;
254 if(this->engine
->show(this->Swallpaper
, 0, 0, this->Swallpaper
->w
, this->Swallpaper
->h
) == ENGINE_ERROR
)
256 // this->engine->update(0, 0, 0, 0);
257 for(i
= 0; i
< MAX_OPTIONS
; ++i
){
258 if(this->options
[i
] != WITHOUT_OPTION
)
259 this->options
[i
]->show();
261 return MENU_NO_ERROR
;
264 int Menu::update(void)
267 return MENU_NO_ENGINE
;
268 this->engine
->update(0, 0, 0, 0);
269 return MENU_NO_ERROR
;
272 void Menu::setEngine(Engine
*e
)