-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmenu_external.cpp
More file actions
68 lines (61 loc) · 1.83 KB
/
menu_external.cpp
File metadata and controls
68 lines (61 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "menu_external.h"
#include "menu_nav.h"
#include "fs_utils.h"
#include "LEJATSZO.H"
#include "level_load.h"
#include "main.h"
#include "menu_nav.h"
#include "menu_pic.h"
#include "menu_play.h"
#include "platform_impl.h"
#include "state.h"
#include "directinput/scancodes.h"
#include <cstring>
#include <string>
static void play_external(const std::string& filename, bool map_viewer) {
if (filename.length() > MAX_FILENAME_LEN + 4) {
internal_error("menu_external_levels() entry too long!");
}
const char* filename_str = filename.c_str();
strcpy(State->external_filename, filename_str);
while (true) {
loading_screen();
if (!load_level_play(filename_str)) {
return;
}
Rec1->erase(filename_str);
Rec2->erase(filename_str);
int time = lejatszo(filename_str, map_viewer ? CameraMode::MapViewer : CameraMode::Normal);
MenuPalette->set();
char finish_msg[100] = "";
update_top_ten(time, finish_msg, 0, filename_str);
if (menu_level(0, 0, finish_msg, filename_str) == MenuLevel::Esc) {
Rec1->erase(filename_str);
Rec2->erase(filename_str);
return;
}
map_viewer = is_key_down(DIK_F1);
}
}
void menu_external_levels() {
menu_nav nav("Select External File!");
nav.search_pattern = SearchPattern::Sorted;
finame filename;
bool done = find_first("lev/*.lev", filename);
while (!done) {
nav.add_row(filename, NAV_FUNC() { play_external(left, is_key_down(DIK_F1)); });
done = find_next(filename);
}
find_close();
if (nav.row_count() <= 0) {
return;
}
nav.sort_rows();
nav.select_row(State->external_filename);
while (true) {
int choice = nav.navigate();
if (choice < 0) {
return;
}
}
}