#include <SDL_image.h>
#include "leveleditor.h"
-#include "world.h"
#include "screen.h"
#include "defines.h"
#include "globals.h"
/* definitions to aid development */
#define DONE_LEVELEDITOR 1
#define DONE_QUIT 2
-#define DONE_CHANGELEVEL 3
/* definitions that affect gameplay */
#define KEY_CURSOR_SPEED 32
void update_subset_settings_menu();
void save_subset_settings_menu();
+static Level* le_current_level;
+
+struct LevelEditorWorld
+{
+ std::vector<BadGuy> bad_guys;
+ void arrays_free(void)
+ {
+ bad_guys.clear();
+ }
+
+ void add_bad_guy(float x, float y, BadGuyKind kind)
+ {
+ bad_guys.push_back(BadGuy());
+ BadGuy& new_bad_guy = bad_guys.back();
+
+ new_bad_guy.init(x,y,kind);
+ }
+
+ void activate_bad_guys()
+ {
+ for (std::vector<BadGuyData>::iterator i = le_current_level->badguy_data.begin();
+ i != le_current_level->badguy_data.end();
+ ++i)
+ {
+ add_bad_guy(i->x, i->y, i->kind);
+ }
+ }
+};
+
/* leveleditor internals */
static string_list_type level_subsets;
static bool le_level_changed; /* if changes, ask for saving, when quiting*/
static int pos_x, cursor_x, cursor_y, fire;
static int le_level;
-static Level* le_current_level;
-static World le_world;
+static LevelEditorWorld le_world;
static st_subset le_level_subset;
static int le_show_grid;
static int le_frame;
return 0;
}
- if(done == DONE_QUIT)
- {
- le_quit();
- return 1;
- }
-
++global_frame_counter;
SDL_Delay(25);
le_tilemap_panel->draw();
sprintf(str, "%d/%d", le_level,le_level_subset.levels);
- text_drawf(&white_text, str, -10, 16, A_RIGHT, A_TOP, 0);
+ white_text->drawf(str, -10, 16, A_RIGHT, A_TOP, 0);
- text_draw(&white_small_text, "F1 for Help", 10, 430, 1);
+ white_small_text->draw("F1 for Help", 10, 430, 1);
}
else
{
if(show_menu == false)
- text_draw(&white_small_text, "No Level Subset loaded - Press ESC and choose one in the menu", 10, 430, 1);
+ white_small_text->draw("No Level Subset loaded - Press ESC and choose one in the menu", 10, 430, 1);
else
- text_draw(&white_small_text, "No Level Subset loaded", 10, 430, 1);
+ white_small_text->draw("No Level Subset loaded", 10, 430, 1);
}
}
while(SDL_PollEvent(&event))
{
- if(show_menu)
- current_menu->event(event);
- else
+ current_menu->event(event);
+ if(!show_menu)
mouse_cursor->set_state(MC_NORMAL);
/* testing SDL_KEYDOWN, SDL_KEYUP and SDL_QUIT events*/
{
case SDL_KEYDOWN: // key pressed
key = event.key.keysym.sym;
- if(show_menu)
- {
- if(key == SDLK_ESCAPE)
- {
- show_menu = false;
- Menu::set_current(leveleditor_menu);
- }
- break;
- }
switch(key)
{
- case SDLK_ESCAPE:
- if(!show_menu)
- show_menu = true;
- else
- show_menu = false;
- break;
case SDLK_LEFT:
if(fire == DOWN)
cursor_x -= KEY_CURSOR_SPEED;
char str[1024];
int d = 0;
sprintf(str,"Level %d doesn't exist.",le_level+1);
- text_drawf(&white_text,str,0,-18,A_HMIDDLE,A_VMIDDLE,2);
- text_drawf(&white_text,"Do you want to create it?",0,0,A_HMIDDLE,A_VMIDDLE,2);
- text_drawf(&red_text,"(Y)es/(N)o",0,20,A_HMIDDLE,A_VMIDDLE,2);
+ white_text->drawf(str,0,-18,A_HMIDDLE,A_VMIDDLE,2);
+ white_text->drawf("Do you want to create it?",0,0,A_HMIDDLE,A_VMIDDLE,2);
+ red_text->drawf("(Y)es/(N)o",0,20,A_HMIDDLE,A_VMIDDLE,2);
flipscreen();
while(d == 0)
{
};
- text_drawf(&blue_text, "- Help -", 0, 30, A_HMIDDLE, A_TOP, 2);
+ blue_text->drawf("- Help -", 0, 30, A_HMIDDLE, A_TOP, 2);
for(i = 0; i < sizeof(text)/sizeof(char *); i++)
- text_draw(&white_text, text[i], 5, 80+(i*18), 1);
+ white_text->draw(text[i], 5, 80+(i*18), 1);
- text_drawf(&gold_text, "Press Any Key to Continue", 0, 440, A_HMIDDLE, A_TOP, 1);
+ gold_text->drawf("Press Any Key to Continue", 0, 440, A_HMIDDLE, A_TOP, 1);
flipscreen();