File: ingame_options_manager.h

package info (click to toggle)
freespace2 24.2.0%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 43,716 kB
  • sloc: cpp: 595,001; ansic: 21,741; python: 1,174; sh: 457; makefile: 248; xml: 181
file content (49 lines) | stat: -rw-r--r-- 1,404 bytes parent folder | download
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
#pragma once

#include "options/Ingame_Options.h"
#include "options/dialogs/ingame_options_ui.h"

#include "gamesequence/gamesequence.h"

class OptConfigurator {
  public:
	OptConfigurator();

	// Do rendering and handle keyboard/mouse events
	void onFrame();

	void close() {
		gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
	}

	// Call this function from outside OptConfigurator::onFrame to signal that the SCP Options should close.
	void notify_close() {
		CloseThis = true;
	}

	void offer_restart_popup();
	void offer_save_options_popup();

	void maybe_persist_changes();
	void discard_changes();

	int get_binary_option_index(const SCP_string& title);
	int get_float_range_option_index(const SCP_string& title);
	int get_int_range_option_index(const SCP_string& title);

	bool show_save_options_popup = false;
	bool show_persist_popup = false;
	SCP_string persist_options = "";
	bool options_changed = false;

	// These are used to store options values for imgui since we can't get to the
	// actual globals through the Options Manager. Imgui does not need a value to
	// store multi select options, so that can be done directly instead of through
	// a vector here.
	SCP_vector<std::pair<SCP_string, bool>> binary_options;
	SCP_vector<std::pair<SCP_string, float>> range_float_options;
	SCP_vector<std::pair<SCP_string, int>> range_int_options;
  private:
	bool CloseThis = false;
	OptUi optUi;
};