Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build-macos/CalChart.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@
E803363417EE27C500A58457 /* math_utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = math_utils.cpp; sourceTree = "<group>"; };
E803363517EE27C500A58457 /* math_utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = math_utils.h; sourceTree = "<group>"; };
E803364117EE2E5400A58457 /* parse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parse.h; sourceTree = "<group>"; };
E803A0C7193BA54900C5F2D5 /* draw_utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = draw_utils.h; sourceTree = "<group>"; };
E807BD5C17ED71F50052A53F /* calchart_cmd */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = calchart_cmd; sourceTree = BUILT_PRODUCTS_DIR; };
E807BD5E17ED71F60052A53F /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
E807BD6017ED71F60052A53F /* calchart_cmd.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = calchart_cmd.1; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1192,6 +1193,7 @@
C7AFA97A117A6DBA00CC53E2 /* contscan.l */,
C7AFA97B117A6DBA00CC53E2 /* draw.cpp */,
E884F3A217A631BB00831301 /* draw.h */,
E803A0C7193BA54900C5F2D5 /* draw_utils.h */,
C7E047CA155F7B8900D8C71B /* field_canvas.cpp */,
C7E047CB155F7B8A00D8C71B /* field_canvas.h */,
C7E047CD155F892400D8C71B /* field_frame.cpp */,
Expand Down
7 changes: 4 additions & 3 deletions src/animation_canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,22 @@ void
AnimationCanvas::OnPaint(wxPaintEvent& event)
{
wxBufferedPaintDC dc(this);
auto& config = CalChartConfiguration::GetGlobalConfig();

dc.SetBackground(GetCalChartBrush(COLOR_FIELD));
dc.SetBackground(config.Get_CalChartBrushAndPen(COLOR_FIELD).first);
dc.Clear();
dc.SetUserScale(mUserScale, mUserScale);
dc.SetDeviceOrigin(mUserOriginX, 0);
if (mMouseDown)
{
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.SetPen(GetCalChartPen(COLOR_SHAPES));
dc.SetPen(config.Get_CalChartBrushAndPen(COLOR_SHAPES).second);
dc.DrawRectangle(mMouseXStart, mMouseYStart,
mMouseXEnd - mMouseXStart, mMouseYEnd - mMouseYStart);
}
if (mAnimationView)
{
mAnimationView->OnDraw(&dc);
mAnimationView->OnDraw(&dc, config);
}
}

Expand Down
31 changes: 16 additions & 15 deletions src/animation_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ EVT_SIZE(AnimationFrame::OnSize)
END_EVENT_TABLE()


AnimationFrame::AnimationFrame(std::function<void ()> onClose, wxDocument *doc, wxView *view, wxFrame *parent, const wxSize& size) :
AnimationFrame::AnimationFrame(std::function<void ()> onClose, wxDocument *doc, CalChartConfiguration& config_, wxView *view, wxFrame *parent, const wxSize& size) :
#if defined(BUILD_FOR_VIEWER) && (BUILD_FOR_VIEWER != 0)
wxDocChildFrame(doc, view, parent, wxID_ANY, wxT("CalChart Viewer"), wxDefaultPosition, size),
#else
wxFrame(parent, wxID_ANY, wxT("CalChart Viewer"), wxDefaultPosition, size),
#endif
mAnimationView(),
config(config_),
mCanvas(NULL),
mOmniViewCanvas(NULL),
mTimer(new wxTimer(this, CALCHART__anim_next_beat_timer)),
Expand Down Expand Up @@ -131,19 +132,19 @@ mWhenClosed(onClose)
mSplitter->SetWindowStyleFlag(mSplitter->GetWindowStyleFlag() | wxSP_LIVE_UPDATE);
mSplitter->SetMinSize(wxSize(300, 400));

mOmniViewCanvas = new CCOmniView_Canvas(&mAnimationView, mSplitter);
mOmniViewCanvas = new CCOmniView_Canvas(&mAnimationView, mSplitter, config);
mCanvas = new AnimationCanvas(&mAnimationView, mSplitter);

mSplitA = mOmniViewCanvas;
mSplitB = mCanvas;
if (!GetConfiguration_AnimationFrameOmniAnimation())
if (!config.Get_AnimationFrameOmniAnimation())
{
std::swap(mSplitA, mSplitB);
}
mSplitter->Initialize(mSplitA);
if (GetConfiguration_AnimationFrameSplitScreen())
if (config.Get_AnimationFrameSplitScreen())
{
if (GetConfiguration_AnimationFrameSplitVertical())
if (config.Get_AnimationFrameSplitVertical())
{
mSplitter->SplitVertically(mSplitA, mSplitB);
}
Expand All @@ -152,7 +153,7 @@ mWhenClosed(onClose)
mSplitter->SplitHorizontally(mSplitA, mSplitB);
}
}
mSplitter->SetSashPosition(GetConfiguration_AnimationFrameSashPosition());
mSplitter->SetSashPosition(config.Get_AnimationFrameSashPosition());


AddCoolToolBar(GetAnimationToolBar(), *this);
Expand Down Expand Up @@ -251,8 +252,8 @@ AnimationFrame::OnSize(wxSizeEvent& event)
// HACK: Prevent width and height from growing out of control
int w = event.GetSize().GetWidth();
int h = event.GetSize().GetHeight();
SetConfiguration_AnimationFrameWidth((w > 1200) ? 1200 : w);
SetConfiguration_AnimationFrameHeight((h > 700) ? 700 : h);
config.Set_AnimationFrameWidth((w > 1200) ? 1200 : w);
config.Set_AnimationFrameHeight((h > 700) ? 700 : h);
super::OnSize(event);
}

Expand All @@ -278,7 +279,7 @@ AnimationFrame::OnCmdClose(wxCloseEvent& event)
{
if (mSplitter)
{
SetConfiguration_AnimationFrameSashPosition(mSplitter->GetSashPosition());
config.Set_AnimationFrameSashPosition(mSplitter->GetSashPosition());
}
// we should inform the parent frame we are closing
if (mWhenClosed)
Expand Down Expand Up @@ -620,8 +621,8 @@ AnimationFrame::OnCmd_SplitViewHorizontal(wxCommandEvent& event)
mSplitA->Show(true);
mSplitB->Show(true);
mSplitter->SplitHorizontally(mSplitA, mSplitB);
SetConfiguration_AnimationFrameSplitScreen(true);
SetConfiguration_AnimationFrameSplitVertical(false);
config.Set_AnimationFrameSplitScreen(true);
config.Set_AnimationFrameSplitVertical(false);
}

void
Expand All @@ -634,8 +635,8 @@ AnimationFrame::OnCmd_SplitViewVertical(wxCommandEvent& event)
mSplitA->Show(true);
mSplitB->Show(true);
mSplitter->SplitVertically(mSplitA, mSplitB);
SetConfiguration_AnimationFrameSplitScreen(true);
SetConfiguration_AnimationFrameSplitVertical(true);
config.Set_AnimationFrameSplitScreen(true);
config.Set_AnimationFrameSplitVertical(true);
}

void
Expand All @@ -645,7 +646,7 @@ AnimationFrame::OnCmd_SplitViewUnsplit(wxCommandEvent& event)
{
mSplitter->Unsplit();
}
SetConfiguration_AnimationFrameSplitScreen(false);
config.Set_AnimationFrameSplitScreen(false);
}

void
Expand All @@ -658,7 +659,7 @@ AnimationFrame::OnCmd_SwapAnimateAndOmni(wxCommandEvent& event)
mSplitter->Unsplit();
}
std::swap(mSplitA, mSplitB);
SetConfiguration_AnimationFrameOmniAnimation(!GetConfiguration_AnimationFrameOmniAnimation());
config.Set_AnimationFrameOmniAnimation(!config.Get_AnimationFrameOmniAnimation());
if (mode == wxSPLIT_HORIZONTAL)
{
mSplitter->SplitHorizontally(mSplitA, mSplitB);
Expand Down
6 changes: 4 additions & 2 deletions src/animation_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class AnimationCanvas;
class CCOmniView_Canvas;
class FancyTextWin;
class wxSplitterWindow;
class CalChartConfiguration;

#if defined(BUILD_FOR_VIEWER) && (BUILD_FOR_VIEWER != 0)
typedef wxDocChildFrame AnimationFrameParent;
Expand All @@ -48,7 +49,7 @@ class AnimationFrame : public AnimationFrameParent
public:
typedef AnimationFrameParent super;

AnimationFrame(std::function<void ()> onClose, wxDocument *doc, wxView *view, wxFrame *parent, const wxSize& size);
AnimationFrame(std::function<void ()> onClose, wxDocument *doc, CalChartConfiguration& config, wxView *view, wxFrame *parent, const wxSize& size);
~AnimationFrame();

void OnSize(wxSizeEvent& event);
Expand Down Expand Up @@ -107,7 +108,8 @@ class AnimationFrame : public AnimationFrameParent
void TransitionToNextSheet();

AnimationView mAnimationView;
// we really do need one of each. We can't do inheritance because they have different base classes
CalChartConfiguration& config;
// we really do need one of each. We can't do inheritance because they have different base classes
AnimationCanvas *mCanvas;
CCOmniView_Canvas *mOmniViewCanvas;
wxSlider *mSheetSlider;
Expand Down
63 changes: 45 additions & 18 deletions src/animation_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ AnimationView::~AnimationView()
void
AnimationView::OnDraw(wxDC *dc)
{
GetShow()->GetMode().DrawMode(*dc, ShowMode::kAnimation);
auto& config = CalChartConfiguration::GetGlobalConfig();
OnDraw(dc, config);
}

void
AnimationView::OnDraw(wxDC *dc, const CalChartConfiguration& config)
{
dc->SetPen(config.Get_CalChartBrushAndPen(COLOR_FIELD_DETAIL).second);
GetShow()->GetMode().DrawMode(*dc, config, ShowMode::kAnimation);
const bool checkForCollision = mCollisionWarningType != COLLISION_RESPONSE_NONE;
if (mAnimation)
{
Expand All @@ -65,13 +73,14 @@ AnimationView::OnDraw(wxDC *dc)
if (checkForCollision && info.mCollision)
{
if (info.mCollision == COLLISION_WARNING) {
dc->SetPen(GetCalChartPen(COLOR_POINT_ANIM_COLLISION_WARNING));
dc->SetBrush(GetCalChartBrush(COLOR_POINT_ANIM_COLLISION_WARNING));
auto brushAndPen = config.Get_CalChartBrushAndPen(COLOR_POINT_ANIM_COLLISION_WARNING);
dc->SetBrush(brushAndPen.first);
dc->SetPen(brushAndPen.second);
} else if (info.mCollision == COLLISION_INTERSECT) {
dc->SetPen(GetCalChartPen(COLOR_POINT_ANIM_COLLISION));
dc->SetBrush(GetCalChartBrush(COLOR_POINT_ANIM_COLLISION));
auto brushAndPen = config.Get_CalChartBrushAndPen(COLOR_POINT_ANIM_COLLISION);
dc->SetBrush(brushAndPen.first);
dc->SetPen(brushAndPen.second);
}

}
else if (GetShow()->IsSelected(i))
{
Expand All @@ -80,18 +89,27 @@ AnimationView::OnDraw(wxDC *dc)
case ANIMDIR_SW:
case ANIMDIR_W:
case ANIMDIR_NW:
dc->SetPen(GetCalChartPen(COLOR_POINT_ANIM_HILIT_BACK));
dc->SetBrush(GetCalChartBrush(COLOR_POINT_ANIM_HILIT_BACK));
{
auto brushAndPen = config.Get_CalChartBrushAndPen(COLOR_POINT_ANIM_HILIT_BACK);
dc->SetBrush(brushAndPen.first);
dc->SetPen(brushAndPen.second);
}
break;
case ANIMDIR_SE:
case ANIMDIR_E:
case ANIMDIR_NE:
dc->SetPen(GetCalChartPen(COLOR_POINT_ANIM_HILIT_FRONT));
dc->SetBrush(GetCalChartBrush(COLOR_POINT_ANIM_HILIT_FRONT));
{
auto brushAndPen = config.Get_CalChartBrushAndPen(COLOR_POINT_ANIM_HILIT_FRONT);
dc->SetBrush(brushAndPen.first);
dc->SetPen(brushAndPen.second);
}
break;
default:
dc->SetPen(GetCalChartPen(COLOR_POINT_ANIM_HILIT_SIDE));
dc->SetBrush(GetCalChartBrush(COLOR_POINT_ANIM_HILIT_SIDE));
{
auto brushAndPen = config.Get_CalChartBrushAndPen(COLOR_POINT_ANIM_HILIT_SIDE);
dc->SetBrush(brushAndPen.first);
dc->SetPen(brushAndPen.second);
}
}
}
else
Expand All @@ -101,18 +119,27 @@ AnimationView::OnDraw(wxDC *dc)
case ANIMDIR_SW:
case ANIMDIR_W:
case ANIMDIR_NW:
dc->SetPen(GetCalChartPen(COLOR_POINT_ANIM_BACK));
dc->SetBrush(GetCalChartBrush(COLOR_POINT_ANIM_BACK));
{
auto brushAndPen = config.Get_CalChartBrushAndPen(COLOR_POINT_ANIM_BACK);
dc->SetBrush(brushAndPen.first);
dc->SetPen(brushAndPen.second);
}
break;
case ANIMDIR_SE:
case ANIMDIR_E:
case ANIMDIR_NE:
dc->SetPen(GetCalChartPen(COLOR_POINT_ANIM_FRONT));
dc->SetBrush(GetCalChartBrush(COLOR_POINT_ANIM_FRONT));
{
auto brushAndPen = config.Get_CalChartBrushAndPen(COLOR_POINT_ANIM_FRONT);
dc->SetBrush(brushAndPen.first);
dc->SetPen(brushAndPen.second);
}
break;
default:
dc->SetPen(GetCalChartPen(COLOR_POINT_ANIM_SIDE));
dc->SetBrush(GetCalChartBrush(COLOR_POINT_ANIM_SIDE));
{
auto brushAndPen = config.Get_CalChartBrushAndPen(COLOR_POINT_ANIM_SIDE);
dc->SetBrush(brushAndPen.first);
dc->SetPen(brushAndPen.second);
}
}
}
CC_coord position = info.mPosition;
Expand Down
2 changes: 2 additions & 0 deletions src/animation_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

class AnimationFrame;
class FieldView;
class CalChartConfiguration;

class AnimationView : public wxView
{
Expand All @@ -41,6 +42,7 @@ class AnimationView : public wxView
// virtual bool OnCreate(wxDocument *doc, long flags);
// virtual bool OnClose(bool deleteWindow = true);
virtual void OnDraw(wxDC *dc);
void OnDraw(wxDC *dc, const CalChartConfiguration& config);
virtual void OnUpdate(wxView *sender, wxObject *hint = (wxObject *) NULL);

void RefreshFrame();
Expand Down
14 changes: 10 additions & 4 deletions src/calchartapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ void CalChartApp::InitAppAsServer() {
gPrintDialogData = new wxPrintDialogData();
mHelpController = std::unique_ptr<wxHtmlHelpController>(new wxHtmlHelpController());

// setup the configuration.
ReadConfig();

//// Create the main frame window
wxFrame *frame = new TopFrame(mDocManager, (wxFrame *)NULL, _T("CalChart"));

Expand Down Expand Up @@ -158,6 +155,8 @@ void CalChartApp::ProcessArguments() {


void CalChartApp::ExitAppAsServer() {
// Flush out the other commands
CalChartConfiguration::GetGlobalConfig().FlushWriteQueue();
// Get the file history
wxConfigBase *config = wxConfigBase::Get();
config->SetPath(wxT("/FileHistory"));
Expand All @@ -172,5 +171,12 @@ void CalChartApp::ExitAppAsServer() {
mHelpController.reset();
}

std::unique_ptr<ShowMode>
CalChartApp::GetMode(const wxString& which)
{
return ShowMode::GetMode(which);
}

void CalChartApp::ExitAppAsClient() {
}
}

4 changes: 1 addition & 3 deletions src/calchartapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CalChartApp : public wxApp
virtual void MacOpenFiles(const wxArrayString &fileNames);
int OnExit();

ShowModeList& GetModeList() { return mModeList; }
std::unique_ptr<ShowMode> GetMode(const wxString& which);

// the global help system:
wxHtmlHelpController& GetGlobalHelpController();
Expand All @@ -60,8 +60,6 @@ class CalChartApp : public wxApp
void ExitAppAsServer();
void ExitAppAsClient();

ShowModeList mModeList;

wxDocManager* mDocManager;
std::unique_ptr<wxHtmlHelpController> mHelpController;

Expand Down
8 changes: 4 additions & 4 deletions src/calchartdoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ IMPLEMENT_DYNAMIC_CLASS(CalChartDoc, wxDocument);
// Create a new show
CalChartDoc::CalChartDoc() :
mShow(CC_show::Create_CC_show()),
mMode(wxGetApp().GetModeList().front().get()),
mMode(wxGetApp().GetMode(kShowModeStrings[0])),
mTimer(*this)
{
mTimer.Start(GetConfiguration_AutosaveInterval()*1000);
mTimer.Start(CalChartConfiguration::GetGlobalConfig().Get_AutosaveInterval()*1000);
}

// When a file is opened, we first check to see if there is a temporary
Expand Down Expand Up @@ -511,13 +511,13 @@ CalChartDoc::GetMode() const
}

void
CalChartDoc::SetMode(const ShowMode* m)
CalChartDoc::SetMode(std::unique_ptr<const ShowMode> m)
{
if (!m)
{
throw std::runtime_error("Cannot use NULL ShowMode");
}
mMode = m;
std::swap(mMode, m);
UpdateAllViews();
}

Expand Down
4 changes: 2 additions & 2 deletions src/calchartdoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class CalChartDoc : public wxDocument
const SelectionList& GetSelectionList() const;

const ShowMode& GetMode() const;
void SetMode(const ShowMode* m);
void SetMode(std::unique_ptr<const ShowMode> m);

bool AlreadyHasPrintContinuity() const;

Expand Down Expand Up @@ -193,7 +193,7 @@ class CalChartDoc : public wxDocument
void RestoreSnapShot(const CC_show& snapshot);

std::unique_ptr<CC_show> mShow;
const ShowMode* mMode;
std::unique_ptr<const ShowMode> mMode;
AutoSaveTimer mTimer;
};

Expand Down
Loading