1
0
mirror of synced 2024-11-28 09:30:51 +01:00

Removed more static inline variables in headers to avoid duplication

This commit is contained in:
WerWolv 2021-01-13 23:08:41 +01:00
parent cd200b978b
commit 441f4a9fc7
5 changed files with 11 additions and 12 deletions

View File

@ -53,6 +53,8 @@ namespace hex {
static std::vector<View*> views;
static std::vector<ContentRegistry::Tools::Entry> toolsEntries;
static std::vector<ContentRegistry::DataInspector::Entry> dataInspectorEntries;
static u32 patternPaletteOffset;
static std::string errorPopupMessage;
static int mainArgc;
static char **mainArgv;

View File

@ -45,10 +45,10 @@ namespace hex::lang {
if (color != 0)
return;
this->m_color = Palette[PatternData::s_paletteOffset++];
this->m_color = Palette[SharedData::patternPaletteOffset++];
if (PatternData::s_paletteOffset >= (sizeof(Palette) / sizeof(u32)))
PatternData::s_paletteOffset = 0;
if (SharedData::patternPaletteOffset >= (sizeof(Palette) / sizeof(u32)))
SharedData::patternPaletteOffset = 0;
}
virtual ~PatternData() = default;
@ -143,7 +143,7 @@ namespace hex::lang {
return false;
}
static void resetPalette() { PatternData::s_paletteOffset = 0; }
static void resetPalette() { SharedData::patternPaletteOffset = 0; }
protected:
void createDefaultEntry(std::string_view value) const {
@ -179,9 +179,6 @@ namespace hex::lang {
u32 m_color;
std::string m_variableName;
std::string m_typeName;
static inline u8 s_paletteOffset = 0;
};
class PatternDataPadding : public PatternData {

View File

@ -51,8 +51,6 @@ namespace hex {
private:
std::string m_viewName;
bool m_windowOpen = false;
static inline std::string s_errorMessage;
};
}

View File

@ -14,6 +14,8 @@ namespace hex {
std::vector<View*> SharedData::views;
std::vector<ContentRegistry::Tools::Entry> SharedData::toolsEntries;
std::vector<ContentRegistry::DataInspector::Entry> SharedData::dataInspectorEntries;
u32 SharedData::patternPaletteOffset;
std::string SharedData::errorPopupMessage;
int SharedData::mainArgc;
char **SharedData::mainArgv;

View File

@ -28,8 +28,8 @@ namespace hex {
if (ImGui::BeginPopupModal("Error", nullptr, ImGuiWindowFlags_NoResize)) {
ImGui::NewLine();
if (ImGui::BeginChild("##scrolling", ImVec2(300, 100))) {
ImGui::SetCursorPosX((300 - ImGui::CalcTextSize(View::s_errorMessage.c_str(), nullptr, false).x) / 2.0F);
ImGui::TextWrapped("%s", View::s_errorMessage.c_str());
ImGui::SetCursorPosX((300 - ImGui::CalcTextSize(SharedData::errorPopupMessage.c_str(), nullptr, false).x) / 2.0F);
ImGui::TextWrapped("%s", SharedData::errorPopupMessage.c_str());
ImGui::EndChild();
}
ImGui::NewLine();
@ -41,7 +41,7 @@ namespace hex {
}
void View::showErrorPopup(std::string_view errorMessage) {
View::s_errorMessage = errorMessage;
SharedData::errorPopupMessage = errorMessage;
ImGui::OpenPopup("Error");
}