yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
hack_workflow_backend_factory.cc
Go to the documentation of this file.
2
3#include <algorithm>
4#include <cctype>
5#include <memory>
6#include <string>
7
10#include "core/project.h"
11
12namespace yaze::editor::workflow {
13namespace {
14
15bool ContainsIgnoreCase(const std::string& haystack,
16 const std::string& needle) {
17 if (needle.empty()) {
18 return true;
19 }
20 auto it = std::search(haystack.begin(), haystack.end(), needle.begin(),
21 needle.end(), [](unsigned char a, unsigned char b) {
22 return std::tolower(a) == std::tolower(b);
23 });
24 return it != haystack.end();
25}
26
28 if (project == nullptr || !project->hack_manifest.loaded()) {
29 return false;
30 }
31
32 // Capability-based first: any project carrying Oracle progression data is
33 // by definition Oracle-compatible, regardless of what it's named. This
34 // covers forks / renames that would previously silently drop to the
35 // manifest-only backend.
36 if (project->hack_manifest.oracle_progression_state().has_value()) {
37 return true;
38 }
39
40 // Name-based fallback for projects that don't yet have progression state
41 // populated (fresh manifest, early-stage scaffolding). Kept as a local
42 // helper instead of absl::StrContainsIgnoreCase so older Abseil versions
43 // on Linux CI can still compile this translation unit.
44 return ContainsIgnoreCase(project->hack_manifest.hack_name(), "oracle");
45}
46
47} // namespace
48
49std::unique_ptr<HackWorkflowBackend> CreateHackWorkflowBackendForProject(
50 const project::YazeProject* project) {
51 if (LooksLikeOracleProject(project)) {
52 return std::make_unique<OracleHackWorkflowBackend>();
53 }
54 return std::make_unique<ManifestOnlyHackWorkflowBackend>();
55}
56
57} // namespace yaze::editor::workflow
const std::string & hack_name() const
std::optional< OracleProgressionState > oracle_progression_state() const
bool loaded() const
Check if the manifest has been loaded.
bool ContainsIgnoreCase(const std::string &haystack, const std::string &needle)
std::unique_ptr< HackWorkflowBackend > CreateHackWorkflowBackendForProject(const project::YazeProject *project)
Modern project structure with comprehensive settings consolidation.
Definition project.h:164
core::HackManifest hack_manifest
Definition project.h:204