Skip to content

Commit

Permalink
First cut of the messages editor
Browse files Browse the repository at this point in the history
Top view shows the character set graphics and the matching ascii character
Left window is the messages text editor
Right window shows the messages rendered in the character set graphics
  • Loading branch information
tonyt73 committed Mar 13, 2023
1 parent 212a950 commit a684052
Show file tree
Hide file tree
Showing 11 changed files with 245 additions and 116 deletions.
6 changes: 3 additions & 3 deletions AGD Studio.cbproj
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,11 @@
<DependentOn>Frames\MapEditor\TileEditor.h</DependentOn>
<BuildOrder>56</BuildOrder>
</CppCompile>
<CppCompile Include="Frames\MessageEditor\fEditorMessages.cpp">
<CppCompile Include="Frames\MessagesEditor\fEditorMessages.cpp">
<Form>frmEditorMessage</Form>
<FormType>dfm</FormType>
<DesignClass>TFrame</DesignClass>
<DependentOn>Frames\MessageEditor\fEditorMessages.h</DependentOn>
<DependentOn>Frames\MessagesEditor\fEditorMessages.h</DependentOn>
<BuildOrder>62</BuildOrder>
</CppCompile>
<CppCompile Include="Frames\MouseState.cpp">
Expand Down Expand Up @@ -684,7 +684,7 @@
<FormResources Include="Frames\MapEditor\LabelledImage.dfm"/>
<FormResources Include="Frames\MusicEditor\fEditorMusic.dfm"/>
<FormResources Include="Frames\WelcomeDialog\fSelectionPanel.dfm"/>
<FormResources Include="Frames\MessageEditor\fEditorMessages.dfm"/>
<FormResources Include="Frames\MessagesEditor\fEditorMessages.dfm"/>
<FormResources Include="Forms\fAbout.dfm"/>
<FormResources Include="Frames\ImageEditor\fEditorImage.dfm"/>
<FormResources Include="Frames\ImageEditor\fMultiImageView.dfm"/>
Expand Down
28 changes: 14 additions & 14 deletions AGD Studio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@
//---------------------------------------------------------------------------
USEFORM("Forms\fAbout.cpp", frmAbout);
USEFORM("Forms\fAdvancedSettings.cpp", frmAdvancedSettings);
USEFORM("Forms\fSettings.cpp", frmSettings);
USEFORM("Forms\fMain.cpp", frmMain);
USEFORM("Forms\fNewImage.cpp", frmNewImage);
USEFORM("Frames\WelcomeDialog\fWelcomeDialog.cpp", frmWelcomeDialog); /* TFrame: File Type */
USEFORM("Frames\WindowEditor\fEditorWindow.cpp", frmEditorWindow); /* TFrame: File Type */
USEFORM("Frames\MapEditor\AssetSelection.cpp", frmAssetSelection); /* TFrame: File Type */
USEFORM("Frames\MapEditor\fEditorMap.cpp", frmEditorMap); /* TFrame: File Type */
USEFORM("Frames\MapEditor\LabelledImage.cpp", frmLabelledImage); /* TFrame: File Type */
USEFORM("Frames\MusicEditor\fEditorMusic.cpp", frmEditorMusic); /* TFrame: File Type */
USEFORM("Frames\WelcomeDialog\fSelectionPanel.cpp", SelectionPanelFrame); /* TFrame: File Type */
USEFORM("Frames\MessageEditor\fEditorMessages.cpp", frmEditorMessage); /* TFrame: File Type */
USEFORM("Forms\fSettings.cpp", frmSettings);
USEFORM("Frames\CodeEditor\fEditorCode.cpp", frmEditorCode); /* TFrame: File Type */
USEFORM("Frames\ControlsEditor\fEditorControls.cpp", frmEditorControls); /* TFrame: File Type */
USEFORM("Frames\ControlsEditor\fKeyCapture.cpp", frmKeyCode); /* TFrame: File Type */
USEFORM("Frames\IDE\fIDE.cpp", frmIDE); /* TFrame: File Type */
USEFORM("Frames\ImageEditor\fEditorImage.cpp", frmEditorImage); /* TFrame: File Type */
USEFORM("Frames\ImageEditor\fMultiImageView.cpp", MultiImageViewFrame); /* TFrame: File Type */
USEFORM("Frames\ImageEditor\fPaletteAttribute.cpp", frmPaletteAttribute); /* TFrame: File Type */
USEFORM("Frames\ImageEditor\fBlockTypes.cpp", frmBlockTypes); /* TFrame: File Type */
USEFORM("Frames\ImageEditor\fPaletteBitmap.cpp", frmPaletteBitmap); /* TFrame: File Type */
USEFORM("Frames\ImageEditor\fToolbarShape.cpp", frmToolbarShape); /* TFrame: File Type */
USEFORM("Frames\ImageEditor\fULAplusBitmap.cpp", frmULAplusBitmap); /* TFrame: File Type */
USEFORM("Frames\JumpEditor\fEditorJumpTable.cpp", frmEditorJump); /* TFrame: File Type */
USEFORM("Frames\ImageEditor\fPaletteMonoAttribute.cpp", frmPaletteMonoAttribute); /* TFrame: File Type */
USEFORM("Frames\ImageEditor\fSelectionImage.cpp", SelectionImageFrame); /* TFrame: File Type */
USEFORM("Frames\ImageEditor\fToolbar.cpp", frmToolbar); /* TFrame: File Type */
USEFORM("Frames\CodeEditor\fEditorCode.cpp", frmEditorCode); /* TFrame: File Type */
USEFORM("Frames\ControlsEditor\fEditorControls.cpp", frmEditorControls); /* TFrame: File Type */
USEFORM("Frames\ControlsEditor\fKeyCapture.cpp", frmKeyCode); /* TFrame: File Type */
USEFORM("Frames\IDE\fIDE.cpp", frmIDE); /* TFrame: File Type */
USEFORM("Frames\JumpEditor\fEditorJumpTable.cpp", frmEditorJump); /* TFrame: File Type */
USEFORM("Frames\MapEditor\AssetSelection.cpp", frmAssetSelection); /* TFrame: File Type */
USEFORM("Frames\MapEditor\fEditorMap.cpp", frmEditorMap); /* TFrame: File Type */
USEFORM("Frames\MapEditor\LabelledImage.cpp", frmLabelledImage); /* TFrame: File Type */
USEFORM("Frames\MessagesEditor\fEditorMessages.cpp", frmEditorsMessage); /* TFrame: File Type */
USEFORM("Frames\MusicEditor\fEditorMusic.cpp", frmEditorMusic); /* TFrame: File Type */
USEFORM("Frames\WelcomeDialog\fWelcomeDialog.cpp", frmWelcomeDialog); /* TFrame: File Type */
USEFORM("Frames\WelcomeDialog\fSelectionPanel.cpp", SelectionPanelFrame); /* TFrame: File Type */
USEFORM("Frames\WindowEditor\fEditorWindow.cpp", frmEditorWindow); /* TFrame: File Type */
//---------------------------------------------------------------------------
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR, int)
{
Expand Down
26 changes: 13 additions & 13 deletions Frames/CodeEditor/fEditorCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ void __fastcall TfrmEditorCode::UpdateStatus()
Breaks.set_length(0);
Books.set_length(0);

actReplace->Enabled = (evEditor->Document!=nullptr) && (! evEditor->Document->ReadOnly);
actSearch->Enabled = evEditor->Document!=nullptr;
actReplace->Enabled = (evEditor->Document != nullptr) && (! evEditor->Document->ReadOnly);
actSearch->Enabled = evEditor->Document != nullptr;
actSearchNext->Enabled = (evEditor->Document==nullptr) ? false : (! evEditor->Document->ReadOnly) || (evEditor->SearchState!=stInReplace);

actCopy->Enabled = evEditor->CanCopy;
Expand All @@ -345,18 +345,18 @@ void __fastcall TfrmEditorCode::UpdateStatus()
actToggleShowRuler->Enabled = true;
actToggleCursorBound->Enabled = true;

actGoToLine->Enabled = evEditor->Document!=nullptr;
actGoToLine->Enabled = evEditor->Document != nullptr;

actFoldAll->Enabled = evEditor->Document!=nullptr;
actFoldAllInCurrent->Enabled = evEditor->Document!=nullptr;
actFoldCurrentTop->Enabled = evEditor->Document!=nullptr;
actFoldTops->Enabled = evEditor->Document!=nullptr;
actFoldTopsInCurrent->Enabled = evEditor->Document!=nullptr;

actUnfoldAll->Enabled = evEditor->Document!=nullptr;
actUnfoldAllInCurrent->Enabled = evEditor->Document!=nullptr;
actUnfoldTops->Enabled = evEditor->Document!=nullptr;
actUnfoldTopsInCurrent->Enabled = evEditor->Document!=nullptr;
actFoldAll->Enabled = evEditor->Document != nullptr;
actFoldAllInCurrent->Enabled = evEditor->Document != nullptr;
actFoldCurrentTop->Enabled = evEditor->Document != nullptr;
actFoldTops->Enabled = evEditor->Document != nullptr;
actFoldTopsInCurrent->Enabled = evEditor->Document != nullptr;

actUnfoldAll->Enabled = evEditor->Document != nullptr;
actUnfoldAllInCurrent->Enabled = evEditor->Document != nullptr;
actUnfoldTops->Enabled = evEditor->Document != nullptr;
actUnfoldTopsInCurrent->Enabled = evEditor->Document != nullptr;

actUndo->Enabled = evEditor->CanUndo && (! lmdDocument->ReadOnly);
actRedo->Enabled = evEditor->CanRedo && (! lmdDocument->ReadOnly);
Expand Down
1 change: 1 addition & 0 deletions Frames/CodeEditor/fEditorCode.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ object frmEditorCode: TfrmEditorCode
Gutter.LinesBarBg = clMaroon
Gutter.FoldsBarBg = clGray
CustomKeyBindings = <>
CompletionSettings.ItemHeight = 15
OnStatusChanged = evEditorStatusChanged
OnEnter = evEditorEnter
GutterBarsEmpty = False
Expand Down
6 changes: 3 additions & 3 deletions Frames/CodeEditor/fEditorCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ class TfrmEditorCode : public TFrame
TLMDEditView *evEditor;
TStatusBar *sbStatus;
TLMDEditDocument *lmdDocument;
TEditUndo *actUndo;
TEditUndo *actRedo;
TActionList *Actions;
TAction *actBmkSet_0;
TAction *actBmkSet_9;
TAction *actBmkSet_8;
TAction *actBmkSet_7;
TAction *actBmkSet_6;
TAction *actBmkSet_5;
TEditUndo *actUndo;
TEditUndo *actRedo;
TAction *actBmkSet_4;
TAction *actToggleShowLineEnds;
TAction *actToggleShowTabs;
Expand Down Expand Up @@ -83,11 +83,11 @@ class TfrmEditorCode : public TFrame
TAction *actToggleCursorBound;
TAction *actToggleShowRuler;
TAction *actFont;
TFontDialog *FontDialog;
TAction *actSearchPrevious;
TAction *actZoomIn;
TAction *actZoomOut;
TAction *actZoomReset;
TFontDialog *FontDialog;
void __fastcall actUndoExecute(TObject *Sender);
void __fastcall actRedoExecute(TObject *Sender);
void __fastcall actGoToLineExecute(TObject *Sender);
Expand Down
2 changes: 1 addition & 1 deletion Frames/IDE/fIDE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "Frames/WindowEditor/fEditorWindow.h"
#include "Frames/JumpEditor/fEditorJumpTable.h"
#include "Frames/ControlsEditor/fEditorControls.h"
#include "Frames/MessageEditor/fEditorMessages.h"
#include "Frames/MessagesEditor/fEditorMessages.h"
#include "Project/ProjectManager.h"
#include "Settings/ThemeManager.h"
#include "Messaging/Messaging.h"
Expand Down
63 changes: 0 additions & 63 deletions Frames/MessageEditor/fEditorMessages.cpp

This file was deleted.

156 changes: 156 additions & 0 deletions Frames/MessagesEditor/fEditorMessages.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
//---------------------------------------------------------------------------
#include "AgdStudio.pch.h"
#include "fEditorMessages.h"
#include "Frames/EditorManager.h"
#include "Project/DocumentManager.h"
#include "Settings/ThemeManager.h"
#include "Messaging/Messaging.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "fEditorCode"
#pragma link "fMultiImageView"
#pragma resource "*.dfm"
TfrmEditorMessages *frmEditorMessages;
//---------------------------------------------------------------------------
__fastcall TfrmEditorMessages::TfrmEditorMessages(TComponent* Owner)
: TFrame(Owner)
, m_GraphicsMode(*(theDocumentManager.ProjectConfig()->MachineConfiguration().GraphicsMode()))
{
m_Tile = std::make_unique<TImage>(nullptr);
m_Tile->Width = 8;
m_Tile->Height = 8;
m_Tile->Picture->Bitmap->Width = 8;
m_Tile->Picture->Bitmap->Height = 8;
}
//---------------------------------------------------------------------------
void __fastcall TfrmEditorMessages::SetDocument(Document* document)
{
fFramesView->Timer1->Enabled = false;
Color = ThemeManager::Background;
m_Document = document;
ecMessageEditor->SetDocument(document);

DocumentList images;
// TODO: Should take a subtype as well
theDocumentManager.GetAllOfType("Image", images);
// find the character set document
for (auto image : images)
{
auto charset = dynamic_cast<CharacterSetDocument*>(image);
if (charset)
{
m_CharacterSet = charset;
break;
}
}
RefreshCharacterSet();
RefreshView();
fFramesView->Select(-1);
// set the image font to the scroll box font
imgView->Canvas->Font = sbxView->Font;
imgView->Canvas->Font->Size = 6;
imgView->Canvas->Font->Color = ThemeManager::Highlight;
imgView->Canvas->Brush->Color = clBlack;
}
//---------------------------------------------------------------------------
bool __fastcall TfrmEditorMessages::IsActive() const
{
return theEditorManager.IsActive(this);
}
//---------------------------------------------------------------------------
void __fastcall TfrmEditorMessages::FrameMouseActivate(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y, int HitTest, TMouseActivate &MouseActivate)
{
theEditorManager.SetActive(this);
}
//---------------------------------------------------------------------------
void __fastcall TfrmEditorMessages::FrameResize(TObject *Sender)
{
Color = ThemeManager::Background;
}
//---------------------------------------------------------------------------
void __fastcall TfrmEditorMessages::OnStatusChanged(TLMDCustomEditView *AView, TLMDViewStatusChanges AChanges)
{
// refresh the view
m_RefreshView = true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmEditorMessages::tmrRefreshViewTimer(TObject *Sender)
{
// redraw the image view
RefreshView();
m_RefreshView = false;
}
//---------------------------------------------------------------------------
void __fastcall TfrmEditorMessages::RefreshView()
{
auto scale = 2;
// work out the size of the view
auto doc = ecMessageEditor->evEditor->Document;
auto height = (doc->LinesCount * m_CharacterSet->Height) + (m_CharacterSet->Height * 2);
auto width = m_GraphicsMode.Width + (m_CharacterSet->Width * 3);
imgView->Picture->Bitmap->Width = width;
imgView->Picture->Bitmap->Height = height;
imgView->Width = width * scale;
imgView->Height = height * scale;

// render the view
PatBlt(imgView->Canvas->Handle, 0, 0, imgView->Width, imgView->Height, BLACKNESS);

auto xs = m_CharacterSet->Width * 2;
auto x = xs;
auto y = m_CharacterSet->Height;
auto idx = 0;
auto quote = true;
for (auto line = 0; line < doc->LinesCount; line++)
{
for (auto col = 0; col < doc->LineSegments[line].Count; col++)
{
auto seg = doc->LineSegments[line];
auto chr = seg.Source->Chars[seg.Start + col];
if (chr == L'\"')
{
if (quote)
{
// draw the message index
idx++;
imgView->Canvas->TextOut(0, y - 2, IntToStr(idx));
}
quote = !quote;
}
else if (chr >= 32 && chr < 128)
{
m_Frames[chr - 32]->Canvas().Assign(m_Tile->Picture->Bitmap);
imgView->Canvas->Draw(x, y, m_Tile->Picture->Bitmap);
x += m_CharacterSet->Width;
}
}
y += m_CharacterSet->Height;
x = xs;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmEditorMessages::RefreshCharacterSet()
{
fFramesView->Clear();
const auto& gm = m_GraphicsMode;
for (auto i = 0; i < m_CharacterSet->Frames; i++)
{
if (m_Frames.size() < m_CharacterSet->Frames) {
// make an image canvas
auto image = std::make_unique<Agdx::Image>(m_CharacterSet->Width, m_CharacterSet->Height, gm);
// save the image
m_Frames.push_back(std::move(image));
}
// set the graphic of the canvas from the image documents frame
m_Frames[i]->Canvas().Set(m_CharacterSet->Frame[i]);
// add the new canvas to the frame view; along with a hint (character set only)
fFramesView->Add(m_Frames[i]->Canvas(), m_CharacterSet->Hint[i]);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmEditorMessages::OnScroll(TObject *Sender, TScrollCode ScrollCode, int &ScrollPos)
{
//
}
//---------------------------------------------------------------------------

Loading

0 comments on commit a684052

Please sign in to comment.