Skip to content

Commit

Permalink
feat: persistence of search options and editor level
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahkittyy committed Oct 31, 2022
1 parent 773a8e7 commit 585196b
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 62 deletions.
27 changes: 27 additions & 0 deletions game/context.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "context.hpp"

context::context()
: m_editor_level(32, 32),
m_query({ .cursor = -1, .query = "", .matchTitle = true, .matchDescription = true, .sortBy = "id", .order = "desc" }) {
}

level& context::editor_level() {
return m_editor_level;
}

const level& context::editor_level() const {
return m_editor_level;
}

api::search_query& context::search_query() {
return m_query;
}

const api::search_query& context::search_query() const {
return m_query;
}

context& context::get() {
static context instance;
return instance;
}
26 changes: 26 additions & 0 deletions game/context.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include "api.hpp"
#include "level.hpp"
#include "tilemap.hpp"

/* manages app context / global state */
class context {
public:
static context& get();

// level currently in the editor
level& editor_level();
const level& editor_level() const;

api::search_query& search_query();
const api::search_query& search_query() const;

private:
context();
context(const context&) = delete;
context(context&&) = delete;

level m_editor_level;
api::search_query m_query;
};
Loading

0 comments on commit 585196b

Please sign in to comment.