yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::editor::ProjectFileEditor Class Reference

Editor for .yaze project files with syntax highlighting and validation. More...

#include <project_file_editor.h>

Collaboration diagram for yaze::editor::ProjectFileEditor:

Public Types

using SaveGuardCallback
 
using SaveCompleteCallback
 

Public Member Functions

 ProjectFileEditor ()
 
void Draw ()
 
absl::Status LoadFile (const std::string &filepath)
 Load a project file into the editor.
 
absl::Status SaveFile ()
 Save the current editor contents to disk.
 
absl::Status SaveFileAs (const std::string &filepath)
 Save to a new file path.
 
bool IsModified () const
 Get whether the file has unsaved changes.
 
const std::string & filepath () const
 Get the current filepath.
 
bool IsInitialized () const
 
ProjectFileEditorState CaptureState () const
 
void RestoreState (const ProjectFileEditorState &state, project::YazeProject *project)
 
void ResetForProject (project::YazeProject *project)
 
void set_active (bool active)
 Set whether the editor window is active.
 
bool * active ()
 Get pointer to active state for ImGui.
 
bool is_active () const
 
void SetToastManager (ToastManager *toast_manager)
 Set toast manager for notifications.
 
void SetSaveGuardCallback (SaveGuardCallback callback)
 
void SetSaveCompleteCallback (SaveCompleteCallback callback)
 
absl::Status CanReplaceDocument () const
 
absl::Status NewFile ()
 Create a new empty project file.
 
void SetProject (project::YazeProject *project)
 Set the project pointer for label import operations.
 

Private Member Functions

absl::Status ImportLabelsFromZScream ()
 Import labels from a ZScream DefaultNames.txt file.
 
void ApplySyntaxHighlighting ()
 
void ValidateContent ()
 
void ShowValidationErrors ()
 
std::string GetDocumentText () const
 

Private Attributes

TextEditor text_editor_
 
std::string filepath_
 
bool initialized_ = false
 
bool active_ = false
 
bool modified_ = false
 
bool show_validation_ = true
 
std::vector< std::string > validation_errors_
 
ToastManagertoast_manager_ = nullptr
 
project::YazeProjectproject_ = nullptr
 
SaveGuardCallback save_guard_callback_
 
SaveCompleteCallback save_complete_callback_
 

Detailed Description

Editor for .yaze project files with syntax highlighting and validation.

Provides a rich text editing experience for yaze project files with:

  • Syntax highlighting for INI-style format
  • Real-time validation
  • Auto-save capability
  • Integration with project::YazeProject

Definition at line 37 of file project_file_editor.h.

Member Typedef Documentation

◆ SaveGuardCallback

Initial value:
std::function<absl::Status(
const std::string& filepath, const std::string& contents)>
const std::string & filepath() const
Get the current filepath.

Definition at line 39 of file project_file_editor.h.

◆ SaveCompleteCallback

Initial value:
std::function<absl::Status(
const std::string& filepath, const std::string& contents)>

Definition at line 41 of file project_file_editor.h.

Constructor & Destructor Documentation

◆ ProjectFileEditor()

yaze::editor::ProjectFileEditor::ProjectFileEditor ( )

Member Function Documentation

◆ Draw()

◆ LoadFile()

absl::Status yaze::editor::ProjectFileEditor::LoadFile ( const std::string & filepath)

◆ SaveFile()

absl::Status yaze::editor::ProjectFileEditor::SaveFile ( )

Save the current editor contents to disk.

Definition at line 276 of file project_file_editor.cc.

References filepath_, and SaveFileAs().

Referenced by Draw(), and yaze::editor::EditorManager::SaveActiveProjectEditingWork().

Here is the call graph for this function:

◆ SaveFileAs()

absl::Status yaze::editor::ProjectFileEditor::SaveFileAs ( const std::string & filepath)

◆ IsModified()

bool yaze::editor::ProjectFileEditor::IsModified ( ) const
inline

Get whether the file has unsaved changes.

Definition at line 66 of file project_file_editor.h.

References modified_.

Referenced by Draw().

◆ filepath()

const std::string & yaze::editor::ProjectFileEditor::filepath ( ) const
inline

◆ IsInitialized()

bool yaze::editor::ProjectFileEditor::IsInitialized ( ) const
inline

Definition at line 72 of file project_file_editor.h.

References initialized_.

◆ CaptureState()

◆ RestoreState()

◆ ResetForProject()

◆ set_active()

void yaze::editor::ProjectFileEditor::set_active ( bool active)
inline

Set whether the editor window is active.

Definition at line 82 of file project_file_editor.h.

References active(), and active_.

Referenced by yaze::editor::EditorManager::RebaseCleanProjectFileDraft(), and yaze::editor::EditorManager::ShowProjectFileEditor().

Here is the call graph for this function:

◆ active()

bool * yaze::editor::ProjectFileEditor::active ( )
inline

Get pointer to active state for ImGui.

Definition at line 87 of file project_file_editor.h.

References active_.

Referenced by set_active().

◆ is_active()

bool yaze::editor::ProjectFileEditor::is_active ( ) const
inline

Definition at line 88 of file project_file_editor.h.

References active_.

Referenced by yaze::editor::EditorManager::RebaseCleanProjectFileDraft().

◆ SetToastManager()

void yaze::editor::ProjectFileEditor::SetToastManager ( ToastManager * toast_manager)
inline

Set toast manager for notifications.

Definition at line 93 of file project_file_editor.h.

References toast_manager_.

Referenced by yaze::editor::EditorManager::InitializeServices().

◆ SetSaveGuardCallback()

void yaze::editor::ProjectFileEditor::SetSaveGuardCallback ( SaveGuardCallback callback)
inline

◆ SetSaveCompleteCallback()

void yaze::editor::ProjectFileEditor::SetSaveCompleteCallback ( SaveCompleteCallback callback)
inline

◆ CanReplaceDocument()

absl::Status yaze::editor::ProjectFileEditor::CanReplaceDocument ( ) const

Definition at line 338 of file project_file_editor.cc.

References initialized_, and modified_.

Referenced by LoadFile(), and NewFile().

◆ NewFile()

absl::Status yaze::editor::ProjectFileEditor::NewFile ( )

Create a new empty project file.

Definition at line 346 of file project_file_editor.cc.

References CanReplaceDocument(), and RETURN_IF_ERROR.

Referenced by Draw().

Here is the call graph for this function:

◆ SetProject()

void yaze::editor::ProjectFileEditor::SetProject ( project::YazeProject * project)
inline

Set the project pointer for label import operations.

Definition at line 114 of file project_file_editor.h.

References project_.

Referenced by yaze::editor::EditorManager::RebaseCleanProjectFileDraft(), and yaze::editor::EditorManager::ShowProjectFileEditor().

◆ ImportLabelsFromZScream()

absl::Status yaze::editor::ProjectFileEditor::ImportLabelsFromZScream ( )
private

Import labels from a ZScream DefaultNames.txt file.

Definition at line 438 of file project_file_editor.cc.

Referenced by Draw().

◆ ApplySyntaxHighlighting()

void yaze::editor::ProjectFileEditor::ApplySyntaxHighlighting ( )
private
Todo
Implement custom syntax highlighting for INI format

Definition at line 361 of file project_file_editor.cc.

◆ ValidateContent()

void yaze::editor::ProjectFileEditor::ValidateContent ( )
private

Definition at line 366 of file project_file_editor.cc.

Referenced by Draw(), and LoadFile().

◆ ShowValidationErrors()

void yaze::editor::ProjectFileEditor::ShowValidationErrors ( )
private

Definition at line 428 of file project_file_editor.cc.

◆ GetDocumentText()

std::string yaze::editor::ProjectFileEditor::GetDocumentText ( ) const
private

Definition at line 418 of file project_file_editor.cc.

Referenced by CaptureState(), and SaveFileAs().

Member Data Documentation

◆ text_editor_

TextEditor yaze::editor::ProjectFileEditor::text_editor_
private

◆ filepath_

std::string yaze::editor::ProjectFileEditor::filepath_
private

◆ initialized_

bool yaze::editor::ProjectFileEditor::initialized_ = false
private

◆ active_

bool yaze::editor::ProjectFileEditor::active_ = false
private

◆ modified_

bool yaze::editor::ProjectFileEditor::modified_ = false
private

◆ show_validation_

bool yaze::editor::ProjectFileEditor::show_validation_ = true
private

Definition at line 132 of file project_file_editor.h.

Referenced by CaptureState(), Draw(), ResetForProject(), and RestoreState().

◆ validation_errors_

std::vector<std::string> yaze::editor::ProjectFileEditor::validation_errors_
private

Definition at line 133 of file project_file_editor.h.

Referenced by CaptureState(), Draw(), ResetForProject(), and RestoreState().

◆ toast_manager_

ToastManager* yaze::editor::ProjectFileEditor::toast_manager_ = nullptr
private

Definition at line 134 of file project_file_editor.h.

Referenced by Draw(), and SetToastManager().

◆ project_

project::YazeProject* yaze::editor::ProjectFileEditor::project_ = nullptr
private

◆ save_guard_callback_

SaveGuardCallback yaze::editor::ProjectFileEditor::save_guard_callback_
private

Definition at line 136 of file project_file_editor.h.

Referenced by SaveFileAs(), and SetSaveGuardCallback().

◆ save_complete_callback_

SaveCompleteCallback yaze::editor::ProjectFileEditor::save_complete_callback_
private

Definition at line 137 of file project_file_editor.h.

Referenced by SaveFileAs(), and SetSaveCompleteCallback().


The documentation for this class was generated from the following files: