-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.h
More file actions
95 lines (80 loc) · 2.73 KB
/
app.h
File metadata and controls
95 lines (80 loc) · 2.73 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#pragma once
#define IMGUI_DEFINE_MATH_OPERATORS
#include <entropy/core.h>
#include <entropy/hex_display_feature_manager.h>
#include <entropy/ui.h>
#include <atomic>
#include <filesystem>
#include <fstream>
#include <functional>
#include <imgui_gradient/imgui_gradient.hpp>
#include <map>
#include <memory>
#include <string>
#include <thread>
#include <vector>
namespace fs = std::filesystem;
namespace entropy {
extern std::atomic<size_t> cacheProgress;
extern size_t cacheTotal;
extern std::atomic<bool> cacheDone;
extern std::atomic<bool> cacheFailed;
struct UiState {
bool showHexView = false;
bool showAboutUs = false;
bool showHelp = false;
bool showSearchWindow = false;
bool showFeatureSettings = false;
bool showGeneralSettings = false;
size_t highlighted_sector = SIZE_MAX;
std::vector<uint8_t> currentSectorData;
size_t currentSectorIndex = 0;
bool promptForSource = false;
// Search window variables
int search_type = 0; // 0=max, 1=min, 2=range
float max_value = 8.0f;
float min_value = 0.0f;
float range_min = 0.0f;
float range_max = 8.0f;
};
struct AppState {
// File handling
std::ifstream file;
size_t file_size = 0;
size_t current_block = 0;
bool redrawBlock = false;
std::vector<uint8_t> block_buffer;
std::vector<uint8_t> all_cache_data;
std::vector<std::string> droppedFiles;
// Configuration
size_t block_width = DEFAULT_BLOCK_WIDTH;
size_t block_height = DEFAULT_BLOCK_HEIGHT;
// Cache
std::string lastCacheFile;
std::string originalFile;
std::thread cacheThread;
bool promptForSource = false;
bool showCacheGen = false;
// UI
float zoom = 2.f;
ImVec2 pan_offset = ImVec2(-50.0f, -50.0f);
size_t block_slider = 0;
// Autoplay
bool autoplay = false;
float autoplay_interval = 0.5f;
double last_autoplay_time = 0.0;
// Hex Display Features
std::unique_ptr<HexDisplayFeatureManager> hexDisplayFeatureManager;
std::map<std::string, bool> featureEnabled;
ImGG::GradientWidget gradient_widget;
void resetHexDisplayGradientColors();
};
int parseCommandLine(int argc, char **argv, AppState &state);
void handleDroppedFiles(AppState &state, UiState &uiState, std::function<void(size_t)> loadHexData);
void handleKeyboardShortcuts(AppState &state, UiState &uiState, IGFD::FileDialogConfig &config, GLFWwindow *window,
std::function<void(size_t)> loadHexData);
void updateAutoplay(AppState &state);
void initializeWindowAndGL(GLFWwindow *&window, GLuint &tex);
void mainLoop(GLFWwindow *window, GLuint tex, AppState &state, UiState &uiState, IGFD::FileDialogConfig &config,
std::function<void(size_t)> loadHexData);
} // namespace entropy