commit 6b0307111971a1b5357189eccce9c4cab3c8a0d5 Author: dm1sh Date: Thu Mar 24 10:44:33 2022 +0300 Initial app structure, added menu, dialogs, background drawing diff --git a/.clang-uml b/.clang-uml new file mode 100644 index 0000000..9f3270e --- /dev/null +++ b/.clang-uml @@ -0,0 +1,8 @@ +compilation_database_dir: build +output_directory: diagrams +generate_method_arguments: none +diagrams: + config_class: + type: class + glob: + - ./*.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7ebfe7e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build/ +class_diagram/ +diagrams/ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..864b595 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "C_Cpp.default.includePath": [ + "${default}", + "/usr/local/include/wx-3.1/", + "/usr/local/lib/wx/include/gtk3-unicode-3.1" + ] +} diff --git a/AboutDlg.cpp b/AboutDlg.cpp new file mode 100644 index 0000000..a7edf0a --- /dev/null +++ b/AboutDlg.cpp @@ -0,0 +1,5 @@ +#include "./AboutDlg.h" + +AboutDlg::AboutDlg(wxWindow *parent, wxWindowID id) : wxDialog::wxDialog(parent, id, _("О программе")) +{ +} diff --git a/AboutDlg.h b/AboutDlg.h new file mode 100644 index 0000000..5cfd4f3 --- /dev/null +++ b/AboutDlg.h @@ -0,0 +1,13 @@ +#ifndef ABOUTDLG_H +#define ABOUTDLG_H + +#include "./wxw.h" + +class AboutDlg : public wxDialog +{ +public: + AboutDlg(wxWindow *parent, wxWindowID id); + ~AboutDlg() {}; +}; + +#endif diff --git a/App.cpp b/App.cpp new file mode 100644 index 0000000..12c8577 --- /dev/null +++ b/App.cpp @@ -0,0 +1,12 @@ +#include "./App.h" +#include "./GameFrame.h" + +wxIMPLEMENT_APP(MyApp); + +bool MyApp::OnInit() +{ + GameFrame *frame = new GameFrame(); + frame->Show(true); + SetTopWindow(frame); + return true; +} diff --git a/App.h b/App.h new file mode 100644 index 0000000..04bab87 --- /dev/null +++ b/App.h @@ -0,0 +1,12 @@ +#ifndef APP_H_ +#define APP_H_ + +#include "./wxw.h" + +class MyApp : public wxApp +{ + public: + virtual bool OnInit(); +}; + +#endif diff --git a/CREDITS b/CREDITS new file mode 100644 index 0000000..6ae56ae --- /dev/null +++ b/CREDITS @@ -0,0 +1,2 @@ +This game uses the following assets: +mahjong tiles by FluffyStuff ( https://github.com/FluffyStuff/riichi-mahjong-tiles ) licensed under CC BY 4.0 diff --git a/GameFrame.cpp b/GameFrame.cpp new file mode 100644 index 0000000..767dbcd --- /dev/null +++ b/GameFrame.cpp @@ -0,0 +1,65 @@ +#include "./GameFrame.h" + +#include "./HelpDlg.h" +#include "./RulesDlg.h" +#include "./AboutDlg.h" + +BEGIN_EVENT_TABLE(GameFrame, wxFrame) + EVT_MENU(IDM_Exit, GameFrame::OnExit) + EVT_MENU(IDM_Help, GameFrame::OnHelp) + EVT_MENU(IDM_Rules, GameFrame::OnRules) + EVT_MENU(IDM_About, GameFrame::OnHelp) + EVT_PAINT(GameFrame::OnPaint) +END_EVENT_TABLE() + +GameFrame::GameFrame() + : wxFrame(nullptr, wxID_ANY, _("Маджонг (пасьянс)")) +{ + InitMenu(); +} + +void GameFrame::InitMenu() { + wxMenu *menuGame = new wxMenu; + menuGame->Append(IDM_New_Game, _("Начать сначала")); + menuGame->AppendSeparator(); + menuGame->Append(IDM_Exit, _("Выход")); + + wxMenu *menuHelp = new wxMenu; + menuHelp->Append(IDM_Help, _("Инструкция")); + menuHelp->Append(IDM_Rules, _("Правила игры")); + menuHelp->Append(IDM_About, _("О программе")); + + wxMenuBar *menuBar = new wxMenuBar; + menuBar->Append(menuGame, _("Игра")); + menuBar->Append(menuHelp, _("Помощь")); + + SetMenuBar(menuBar); +} + +void GameFrame::OnExit(wxCommandEvent &event) { + Close(); +} + +void GameFrame::OnHelp(wxCommandEvent &event) { + HelpDlg *dlg = new HelpDlg(this, -1); + + dlg->Show(); +} + +void GameFrame::OnRules(wxCommandEvent &event) { + RulesDlg *dlg = new RulesDlg(this, -1); + + dlg->Show(); +} + +void GameFrame::OnAbout(wxCommandEvent &event) { + AboutDlg *dlg = new AboutDlg(this, -1); + + dlg->Show(); +} + +void GameFrame::OnPaint(wxPaintEvent& event) { + wxPaintDC dc(this); + + paint.drawTable(dc, GetSize()); +} diff --git a/GameFrame.h b/GameFrame.h new file mode 100644 index 0000000..ab26234 --- /dev/null +++ b/GameFrame.h @@ -0,0 +1,38 @@ +#ifndef GAMEFRAME_H_ +#define GAMEFRAME_H_ + +#include "./wxw.h" + +#include "./Graphics.h" + +/// @uml{style[#line.dotted:blue]} +class GameFrame : public wxFrame +{ +public: + GameFrame(); + +private: + Graphics paint; + + void InitMenu(); + + void OnExit(wxCommandEvent &event); + void OnHelp(wxCommandEvent &event); + void OnRules(wxCommandEvent &event); + void OnAbout(wxCommandEvent &event); + + void OnPaint(wxPaintEvent& event); + + DECLARE_EVENT_TABLE() +}; + +enum +{ + IDM_Exit = wxID_EXIT, + IDM_Help = wxID_HELP, + IDM_About = wxID_ABOUT, + IDM_New_Game = 1, + IDM_Rules +}; + +#endif diff --git a/Graphics.cpp b/Graphics.cpp new file mode 100644 index 0000000..b6f843e --- /dev/null +++ b/Graphics.cpp @@ -0,0 +1,9 @@ +#include "./Graphics.h" + +void Graphics::drawTable(wxDC& dc, wxSize wndSize) { + drawBG(dc, wndSize); +} + +void Graphics::drawBG(wxDC& dc, wxSize wndSize) { + dc.GradientFillConcentric(wxRect(wxPoint(0, 0), wndSize), wxColor(7, 85, 45), wxColor(1, 45, 22)); +} diff --git a/Graphics.h b/Graphics.h new file mode 100644 index 0000000..c30aad0 --- /dev/null +++ b/Graphics.h @@ -0,0 +1,15 @@ +#ifndef GRAPHICS_H +#define GRAPHICS_H + +#include "./wxw.h" + +class Graphics { +public: + Graphics() {}; + ~Graphics() {}; + + void drawTable(wxDC& dc, wxSize wndSize); + void drawBG(wxDC& dc, wxSize wndSize); +}; + +#endif diff --git a/HelpDlg.cpp b/HelpDlg.cpp new file mode 100644 index 0000000..569b08d --- /dev/null +++ b/HelpDlg.cpp @@ -0,0 +1,5 @@ +#include "./HelpDlg.h" + +HelpDlg::HelpDlg(wxWindow *parent, wxWindowID id) : wxDialog::wxDialog(parent, id, _("Инструкция по использованию программы")) +{ +} diff --git a/HelpDlg.h b/HelpDlg.h new file mode 100644 index 0000000..398f47a --- /dev/null +++ b/HelpDlg.h @@ -0,0 +1,13 @@ +#ifndef HELPDLG_H +#define HELPDLG_H + +#include "./wxw.h" + +class HelpDlg : public wxDialog +{ +public: + HelpDlg(wxWindow *parent, wxWindowID id); + ~HelpDlg() {}; +}; + +#endif diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ef2982b --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright 2022 dm1sh + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..53a6f60 --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +# CXX = $(shell wx-config --cxx) +CXX = clang++ + +PROGRAM = wxMahjong +BDIR = build + +OBJECTS := $(addprefix $(BDIR)/,$(patsubst %.cpp,%.o,$(wildcard *.cpp))) + +$(BDIR)/%.o: %.cpp + $(CXX) -c `wx-config --cxxflags` -o $@ $< + +all: $(PROGRAM) + +$(PROGRAM): $(OBJECTS) + $(CXX) -o $(BDIR)/$(PROGRAM) $(OBJECTS) `wx-config --libs` + +clean: + rm -f $(BDIR)/*.o $(PROGRAM) diff --git a/RulesDlg.cpp b/RulesDlg.cpp new file mode 100644 index 0000000..29c1bde --- /dev/null +++ b/RulesDlg.cpp @@ -0,0 +1,5 @@ +#include "./RulesDlg.h" + +RulesDlg::RulesDlg(wxWindow *parent, wxWindowID id) : wxDialog::wxDialog(parent, id, _("Правила игры")) +{ +} diff --git a/RulesDlg.h b/RulesDlg.h new file mode 100644 index 0000000..cc1f718 --- /dev/null +++ b/RulesDlg.h @@ -0,0 +1,13 @@ +#ifndef RULESDLG_H +#define RULESDLG_H + +#include "./wxw.h" + +class RulesDlg : public wxDialog +{ +public: + RulesDlg(wxWindow *parent, wxWindowID id); + ~RulesDlg() {}; +}; + +#endif diff --git a/resources/tiles/Back.png b/resources/tiles/Back.png new file mode 100644 index 0000000..b7a1e2e Binary files /dev/null and b/resources/tiles/Back.png differ diff --git a/resources/tiles/Blank.png b/resources/tiles/Blank.png new file mode 100644 index 0000000..1f9160f Binary files /dev/null and b/resources/tiles/Blank.png differ diff --git a/resources/tiles/Chun.png b/resources/tiles/Chun.png new file mode 100644 index 0000000..b79b4c3 Binary files /dev/null and b/resources/tiles/Chun.png differ diff --git a/resources/tiles/Front.png b/resources/tiles/Front.png new file mode 100644 index 0000000..1734865 Binary files /dev/null and b/resources/tiles/Front.png differ diff --git a/resources/tiles/Haku.png b/resources/tiles/Haku.png new file mode 100644 index 0000000..14fc45b Binary files /dev/null and b/resources/tiles/Haku.png differ diff --git a/resources/tiles/Hatsu.png b/resources/tiles/Hatsu.png new file mode 100644 index 0000000..e9e2032 Binary files /dev/null and b/resources/tiles/Hatsu.png differ diff --git a/resources/tiles/Man1.png b/resources/tiles/Man1.png new file mode 100644 index 0000000..3b4c323 Binary files /dev/null and b/resources/tiles/Man1.png differ diff --git a/resources/tiles/Man2.png b/resources/tiles/Man2.png new file mode 100644 index 0000000..b589670 Binary files /dev/null and b/resources/tiles/Man2.png differ diff --git a/resources/tiles/Man3.png b/resources/tiles/Man3.png new file mode 100644 index 0000000..777d4bf Binary files /dev/null and b/resources/tiles/Man3.png differ diff --git a/resources/tiles/Man4.png b/resources/tiles/Man4.png new file mode 100644 index 0000000..ba194d7 Binary files /dev/null and b/resources/tiles/Man4.png differ diff --git a/resources/tiles/Man5-Dora.png b/resources/tiles/Man5-Dora.png new file mode 100644 index 0000000..ae1f296 Binary files /dev/null and b/resources/tiles/Man5-Dora.png differ diff --git a/resources/tiles/Man5.png b/resources/tiles/Man5.png new file mode 100644 index 0000000..db0e1e8 Binary files /dev/null and b/resources/tiles/Man5.png differ diff --git a/resources/tiles/Man6.png b/resources/tiles/Man6.png new file mode 100644 index 0000000..8209f7d Binary files /dev/null and b/resources/tiles/Man6.png differ diff --git a/resources/tiles/Man7.png b/resources/tiles/Man7.png new file mode 100644 index 0000000..740b352 Binary files /dev/null and b/resources/tiles/Man7.png differ diff --git a/resources/tiles/Man8.png b/resources/tiles/Man8.png new file mode 100644 index 0000000..52747e8 Binary files /dev/null and b/resources/tiles/Man8.png differ diff --git a/resources/tiles/Man9.png b/resources/tiles/Man9.png new file mode 100644 index 0000000..76f3260 Binary files /dev/null and b/resources/tiles/Man9.png differ diff --git a/resources/tiles/Nan.png b/resources/tiles/Nan.png new file mode 100644 index 0000000..c95a0a4 Binary files /dev/null and b/resources/tiles/Nan.png differ diff --git a/resources/tiles/Pei.png b/resources/tiles/Pei.png new file mode 100644 index 0000000..0423a1a Binary files /dev/null and b/resources/tiles/Pei.png differ diff --git a/resources/tiles/Pin1.png b/resources/tiles/Pin1.png new file mode 100644 index 0000000..788b122 Binary files /dev/null and b/resources/tiles/Pin1.png differ diff --git a/resources/tiles/Pin2.png b/resources/tiles/Pin2.png new file mode 100644 index 0000000..24db919 Binary files /dev/null and b/resources/tiles/Pin2.png differ diff --git a/resources/tiles/Pin3.png b/resources/tiles/Pin3.png new file mode 100644 index 0000000..c9cb1db Binary files /dev/null and b/resources/tiles/Pin3.png differ diff --git a/resources/tiles/Pin4.png b/resources/tiles/Pin4.png new file mode 100644 index 0000000..8a62119 Binary files /dev/null and b/resources/tiles/Pin4.png differ diff --git a/resources/tiles/Pin5-Dora.png b/resources/tiles/Pin5-Dora.png new file mode 100644 index 0000000..af8a48e Binary files /dev/null and b/resources/tiles/Pin5-Dora.png differ diff --git a/resources/tiles/Pin5.png b/resources/tiles/Pin5.png new file mode 100644 index 0000000..e1262f8 Binary files /dev/null and b/resources/tiles/Pin5.png differ diff --git a/resources/tiles/Pin6.png b/resources/tiles/Pin6.png new file mode 100644 index 0000000..6bdd1a5 Binary files /dev/null and b/resources/tiles/Pin6.png differ diff --git a/resources/tiles/Pin7.png b/resources/tiles/Pin7.png new file mode 100644 index 0000000..8d25212 Binary files /dev/null and b/resources/tiles/Pin7.png differ diff --git a/resources/tiles/Pin8.png b/resources/tiles/Pin8.png new file mode 100644 index 0000000..2f7e912 Binary files /dev/null and b/resources/tiles/Pin8.png differ diff --git a/resources/tiles/Pin9.png b/resources/tiles/Pin9.png new file mode 100644 index 0000000..c615133 Binary files /dev/null and b/resources/tiles/Pin9.png differ diff --git a/resources/tiles/Shaa.png b/resources/tiles/Shaa.png new file mode 100644 index 0000000..424bac9 Binary files /dev/null and b/resources/tiles/Shaa.png differ diff --git a/resources/tiles/Sou1.png b/resources/tiles/Sou1.png new file mode 100644 index 0000000..76c0cfe Binary files /dev/null and b/resources/tiles/Sou1.png differ diff --git a/resources/tiles/Sou2.png b/resources/tiles/Sou2.png new file mode 100644 index 0000000..ecdf96d Binary files /dev/null and b/resources/tiles/Sou2.png differ diff --git a/resources/tiles/Sou3.png b/resources/tiles/Sou3.png new file mode 100644 index 0000000..b6ab4de Binary files /dev/null and b/resources/tiles/Sou3.png differ diff --git a/resources/tiles/Sou4.png b/resources/tiles/Sou4.png new file mode 100644 index 0000000..0cb592e Binary files /dev/null and b/resources/tiles/Sou4.png differ diff --git a/resources/tiles/Sou5-Dora.png b/resources/tiles/Sou5-Dora.png new file mode 100644 index 0000000..84951f4 Binary files /dev/null and b/resources/tiles/Sou5-Dora.png differ diff --git a/resources/tiles/Sou5.png b/resources/tiles/Sou5.png new file mode 100644 index 0000000..e0f4c31 Binary files /dev/null and b/resources/tiles/Sou5.png differ diff --git a/resources/tiles/Sou6.png b/resources/tiles/Sou6.png new file mode 100644 index 0000000..7230b84 Binary files /dev/null and b/resources/tiles/Sou6.png differ diff --git a/resources/tiles/Sou7.png b/resources/tiles/Sou7.png new file mode 100644 index 0000000..529065f Binary files /dev/null and b/resources/tiles/Sou7.png differ diff --git a/resources/tiles/Sou8.png b/resources/tiles/Sou8.png new file mode 100644 index 0000000..b8f09eb Binary files /dev/null and b/resources/tiles/Sou8.png differ diff --git a/resources/tiles/Sou9.png b/resources/tiles/Sou9.png new file mode 100644 index 0000000..45a542d Binary files /dev/null and b/resources/tiles/Sou9.png differ diff --git a/resources/tiles/Ton.png b/resources/tiles/Ton.png new file mode 100644 index 0000000..1f8fc63 Binary files /dev/null and b/resources/tiles/Ton.png differ diff --git a/wxw.h b/wxw.h new file mode 100644 index 0000000..549eb97 --- /dev/null +++ b/wxw.h @@ -0,0 +1,31 @@ +#ifndef WXW_H_ +#define WXW_H_ + +#include + +#ifndef WX_PRECOMP +#include +#endif + +#ifdef _ +#undef _ +#endif +#define _(s) wxString::FromUTF8(s) + +// class wxTrackable {}; +// class wxObject {}; +// class wxEventHandler : wxObject, wxTrackable {}; +// class wxEventFilter {}; +// class wxAppConsole : wxEventHandler, wxEventFilter {}; +// class wxApp : wxAppConsole {}; + +// class wxWindow : wxEventHandler {}; +// class wxNotOwnedWindow : wxWindow {}; +// class wxTopLevelWindow : wxNotOwnedWindow {}; +// class wxFrame : wxTopLevelWindow {}; + +// class wxCommandEvent {}; + +// #define DECLARE_EVENT_TABLE() void none(); + +#endif