More init/splash streamlining, now including the scenario editor
This commit is contained in:
@@ -12,7 +12,6 @@ void move_sound(ter_num_t ter,short step);
|
||||
void incidental_noises(bool on_surface);
|
||||
void pause(short length);
|
||||
bool handle_startup_press(location the_point);
|
||||
void draw_splash(const sf::Texture& splash, rectangle dest_rect);
|
||||
void handle_splash_events();
|
||||
void show_logo();
|
||||
void plop_fancy_startup();
|
||||
|
@@ -134,13 +134,6 @@ bool handle_startup_press(location the_point) {
|
||||
extern int display_mode;
|
||||
extern bool show_startup_splash;
|
||||
|
||||
void draw_splash(const sf::Texture& splash, rectangle dest_rect) {
|
||||
rectangle from_rect = rectangle(splash);
|
||||
mainPtr.clear(sf::Color::Black);
|
||||
rect_draw_some_item(splash, from_rect, mainPtr, dest_rect);
|
||||
mainPtr.display();
|
||||
}
|
||||
|
||||
void handle_splash_events() {
|
||||
extern sf::Event event;
|
||||
if(!mainPtr.pollEvent(event)) return;
|
||||
@@ -165,13 +158,13 @@ void show_logo() {
|
||||
play_sound(-95);
|
||||
// TODO: Looping 10 times here is a bit of a hack; fix it
|
||||
while(sound_going(95)) {
|
||||
draw_splash(pict_to_draw, logo_from);
|
||||
draw_splash(pict_to_draw, mainPtr, logo_from);
|
||||
handle_splash_events();
|
||||
}
|
||||
if(!show_startup_splash) {
|
||||
int delay = time_in_ticks(60).asMilliseconds();
|
||||
sf::Time delay = time_in_ticks(60);
|
||||
sf::Clock timer;
|
||||
while(timer.getElapsedTime().asMilliseconds() < delay)
|
||||
while(timer.getElapsedTime() < delay)
|
||||
handle_splash_events();
|
||||
}
|
||||
}
|
||||
@@ -181,15 +174,15 @@ void plop_fancy_startup() {
|
||||
rectangle whole_window,from_rect;
|
||||
rectangle intro_from = {0,0,480,640};
|
||||
whole_window = rectangle(mainPtr);
|
||||
int delay = time_in_ticks(220).asMilliseconds();
|
||||
sf::Time delay = time_in_ticks(220);
|
||||
intro_from.offset((whole_window.right - intro_from.right) / 2,(whole_window.bottom - intro_from.bottom) / 2);
|
||||
pict_to_draw.loadFromImage(*ResMgr::get<ImageRsrc>("startsplash"));
|
||||
|
||||
play_sound(-22);
|
||||
sf::Clock timer;
|
||||
|
||||
while(timer.getElapsedTime().asMilliseconds() < delay) {
|
||||
draw_splash(pict_to_draw, intro_from);
|
||||
while(timer.getElapsedTime() < delay) {
|
||||
draw_splash(pict_to_draw, mainPtr, intro_from);
|
||||
handle_splash_events();
|
||||
}
|
||||
}
|
||||
|
@@ -2391,7 +2391,6 @@ static std::string version() {
|
||||
// is slot >= 0, force that slot
|
||||
// if -1, use 1st free slot
|
||||
void set_up_start_screen() {
|
||||
reset_lb();
|
||||
reset_rb();
|
||||
set_lb(0,LB_TITLE,LB_NO_ACTION,"Blades of Exile");
|
||||
set_lb(1,LB_TITLE,LB_NO_ACTION,"Scenario Editor");
|
||||
@@ -2412,7 +2411,6 @@ void set_up_start_screen() {
|
||||
void set_up_main_screen() {
|
||||
std::ostringstream strb;
|
||||
|
||||
reset_lb();
|
||||
reset_rb();
|
||||
set_lb(-1,LB_TITLE,LB_NO_ACTION,"Blades of Exile");
|
||||
set_lb(-1,LB_TEXT,LB_NO_ACTION,"Scenario Options");
|
||||
|
@@ -375,26 +375,18 @@ void Set_up_win () {
|
||||
|
||||
void run_startup_g() {
|
||||
sf::Event event;
|
||||
rectangle pict_rect = {0,0,480,640}, dest_rect;
|
||||
sf::Texture pict_to_draw;
|
||||
dest_rect = pict_rect;
|
||||
|
||||
set_cursor(watch_curs);
|
||||
dest_rect.offset(-25,-25);
|
||||
pict_to_draw.loadFromImage(*ResMgr::get<ImageRsrc>("edsplash"));
|
||||
for(int i = 0; i < 10; i++) {
|
||||
mainPtr.clear(sf::Color::Black);
|
||||
rect_draw_some_item(pict_to_draw, pict_rect, mainPtr, dest_rect, sf::BlendAlpha);
|
||||
mainPtr.display();
|
||||
mainPtr.pollEvent(event);
|
||||
rectangle dest_rect = rectangle(pict_to_draw);
|
||||
|
||||
play_sound(-95);
|
||||
sf::Time delay = time_in_ticks(120);
|
||||
sf::Clock timer;
|
||||
while(sound_going(95) || timer.getElapsedTime() < delay) {
|
||||
draw_splash(pict_to_draw, mainPtr, dest_rect);
|
||||
if(!mainPtr.pollEvent(event)) continue;
|
||||
if(event.type == sf::Event::GainedFocus || event.type == sf::Event::MouseMoved)
|
||||
set_cursor(watch_curs);
|
||||
}
|
||||
play_sound(-95);
|
||||
sf::Clock timer;
|
||||
set_cursor(wand_curs);
|
||||
while(timer.getElapsedTime() < time_in_ticks(120)) {
|
||||
mainPtr.pollEvent(event);
|
||||
if(event.type == sf::Event::KeyPressed || event.type == sf::Event::MouseButtonPressed)
|
||||
break;
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@ short cur_town;
|
||||
location cur_out;
|
||||
|
||||
/* Prototypes */
|
||||
void Initialize(void);
|
||||
static void init_scened(int, char*[]);
|
||||
void Handle_One_Event();
|
||||
void Handle_Activate();
|
||||
void Handle_Update();
|
||||
@@ -64,34 +64,7 @@ extern void set_up_apple_events(int argc, char* argv[]);
|
||||
int main(int argc, char* argv[]) {
|
||||
try {
|
||||
|
||||
init_directories(argv[0]);
|
||||
init_menubar();
|
||||
|
||||
init_current_terrain();
|
||||
Initialize();
|
||||
init_fileio();
|
||||
init_snd_tool();
|
||||
load_graphics();
|
||||
|
||||
cDialog::init();
|
||||
cDialog::defaultBackground = cDialog::BG_LIGHT;
|
||||
cDialog::doAnimations = true;
|
||||
init_graph_tool();
|
||||
|
||||
check_for_intel();
|
||||
set_up_apple_events(argc, argv);
|
||||
|
||||
cen_x = 18;
|
||||
cen_y = 18;
|
||||
|
||||
run_startup_g();
|
||||
init_lb();
|
||||
init_rb();
|
||||
|
||||
make_cursor_sword();
|
||||
|
||||
Set_up_win();
|
||||
init_screen_locs();
|
||||
init_scened(argc, argv);
|
||||
|
||||
if(ae_loading)
|
||||
set_up_main_screen();
|
||||
@@ -100,8 +73,6 @@ int main(int argc, char* argv[]) {
|
||||
set_up_start_screen();
|
||||
}
|
||||
|
||||
redraw_screen();
|
||||
|
||||
while(!All_Done)
|
||||
Handle_One_Event();
|
||||
|
||||
@@ -119,16 +90,20 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
void Initialize(void) {
|
||||
// To make the Random sequences truly random, we need to make the seed start
|
||||
// at a different number. An easy way to do this is to put the current time
|
||||
// and date into the seed. Since it is always incrementing the starting seed
|
||||
// will always be different. Don’t for each call of Random, or the sequence
|
||||
// will no longer be random. Only needed once, here in the init.
|
||||
srand(time(nullptr));
|
||||
static void init_sbar(std::shared_ptr<cScrollbar>& sbar, rectangle rect, int pgSz) {
|
||||
sbar.reset(new cScrollbar(mainPtr));
|
||||
sbar->setBounds(rect);
|
||||
sbar->setPageSize(pgSz);
|
||||
sbar->hide();
|
||||
}
|
||||
|
||||
void init_scened(int argc, char* argv[]) {
|
||||
init_directories(argv[0]);
|
||||
init_menubar();
|
||||
// TODO: Sync and load prefs
|
||||
init_graph_tool();
|
||||
init_snd_tool();
|
||||
|
||||
// Make a new window for drawing in, and it must be a color window.
|
||||
// The window is full screen size, made smaller to make it more visible.
|
||||
sf::VideoMode mode = sf::VideoMode::getDesktopMode();
|
||||
rectangle windRect;
|
||||
windRect.width() = mode.width;
|
||||
@@ -143,23 +118,45 @@ void Initialize(void) {
|
||||
ImageRsrc& icon = *ResMgr::get<ImageRsrc>("icon");
|
||||
mainPtr.setIcon(icon.getSize().x, icon.getSize().y, icon.getPixelsPtr());
|
||||
#endif
|
||||
init_menubar();
|
||||
mainPtr.clear(sf::Color::Black);
|
||||
mainPtr.display();
|
||||
|
||||
set_cursor(watch_curs);
|
||||
boost::thread init_thread([]() {
|
||||
init_current_terrain();
|
||||
check_for_intel();
|
||||
srand(time(nullptr));
|
||||
|
||||
cen_x = 18;
|
||||
cen_y = 18;
|
||||
|
||||
right_sbar_rect.top = RIGHT_AREA_UL_Y - 1;
|
||||
right_sbar_rect.left = RIGHT_AREA_UL_X + RIGHT_AREA_WIDTH - 1 - 16;
|
||||
right_sbar_rect.bottom = RIGHT_AREA_UL_Y + RIGHT_AREA_HEIGHT + 1;
|
||||
right_sbar_rect.right = RIGHT_AREA_UL_X + RIGHT_AREA_WIDTH - 1;
|
||||
right_sbar.reset(new cScrollbar(mainPtr));
|
||||
right_sbar->setBounds(right_sbar_rect);
|
||||
right_sbar->setPageSize(NRSONPAGE - 1);
|
||||
right_sbar->hide();
|
||||
rectangle pal_sbar_rect = terrain_buttons_rect;
|
||||
pal_sbar_rect.offset(RIGHT_AREA_UL_X,RIGHT_AREA_UL_Y);
|
||||
pal_sbar_rect.left = pal_sbar_rect.right - 16;
|
||||
pal_sbar_rect.height() = 17 * 16;
|
||||
pal_sbar.reset(new cScrollbar(mainPtr));
|
||||
pal_sbar->setBounds(pal_sbar_rect);
|
||||
pal_sbar->setPageSize(16);
|
||||
pal_sbar->hide();
|
||||
|
||||
init_sbar(right_sbar, right_sbar_rect, NRSONPAGE - 1);
|
||||
init_sbar(pal_sbar, pal_sbar_rect, 16);
|
||||
init_lb();
|
||||
init_rb();
|
||||
|
||||
Set_up_win();
|
||||
init_screen_locs();
|
||||
load_graphics();
|
||||
cDialog::init();
|
||||
});
|
||||
run_startup_g();
|
||||
init_thread.join();
|
||||
|
||||
cDialog::defaultBackground = cDialog::BG_LIGHT;
|
||||
cDialog::doAnimations = true;
|
||||
set_up_apple_events(argc, argv);
|
||||
init_fileio();
|
||||
redraw_screen();
|
||||
}
|
||||
|
||||
void Handle_One_Event() {
|
||||
|
@@ -113,6 +113,13 @@ void init_graph_tool(){
|
||||
register_main_patterns();
|
||||
}
|
||||
|
||||
void draw_splash(const sf::Texture& splash, sf::RenderWindow& targ, rectangle dest_rect) {
|
||||
rectangle from_rect = rectangle(splash);
|
||||
targ.clear(sf::Color::Black);
|
||||
rect_draw_some_item(splash, from_rect, targ, dest_rect);
|
||||
targ.display();
|
||||
}
|
||||
|
||||
static void rect_draw_some_item(const sf::Texture& src_gworld,rectangle src_rect,sf::RenderTarget& targ_gworld,rectangle targ_rect,sf::RenderStates mode);
|
||||
|
||||
void rect_draw_some_item(sf::RenderTarget& targ_gworld,rectangle targ_rect) {
|
||||
|
@@ -110,6 +110,7 @@ void rect_draw_some_item(sf::RenderTarget& targ_gworld,rectangle targ_rect);
|
||||
void rect_draw_some_item(const sf::Texture& src_gworld,rectangle src_rect,sf::RenderTarget& targ_gworld,rectangle targ_rect,sf::BlendMode mode = sf::BlendNone);
|
||||
void rect_draw_some_item(const sf::Texture& src_gworld,rectangle src_rect,rectangle targ_rect,location offset,sf::BlendMode mode = sf::BlendNone);
|
||||
void rect_draw_some_item(const sf::Texture& src_gworld,rectangle src_rect,const sf::Texture& mask_gworld,sf::RenderTarget& targ_gworld,rectangle targ_rect);
|
||||
void draw_splash(const sf::Texture& splash, sf::RenderWindow& targ, rectangle dest_rect);
|
||||
|
||||
std::vector<rectangle> draw_string_hilite(sf::RenderTarget& dest_window,rectangle dest_rect,std::string str,TextStyle style,std::vector<hilite_t> hilites,sf::Color hiliteClr);
|
||||
std::vector<snippet_t> draw_string_sel(sf::RenderTarget& dest_window,rectangle dest_rect,std::string str,TextStyle style,std::vector<hilite_t> hilites,sf::Color hiliteClr);
|
||||
|
Reference in New Issue
Block a user