penguins  1.0.0
main.cc
Go to the documentation of this file.
1 #include "gui/main.hh"
2 #include "gui/game.hh"
3 #include "resources_appicon_16_png.h"
4 #include "resources_appicon_256_png.h"
5 #include "resources_appicon_64_png.h"
6 #include <wx/app.h>
7 #include <wx/defs.h>
8 #include <wx/gdicmn.h>
9 #include <wx/iconbndl.h>
10 #include <wx/image.h>
11 #include <wx/imagpng.h>
12 #include <wx/mstream.h>
13 #include <wx/stdpaths.h>
14 #include <wx/version.h>
15 
17 
19  if (!wxApp::OnInit()) return false;
20 
21  this->SetAppName("penguins-game-gui");
22 #if wxCHECK_VERSION(3, 1, 1)
23  wxStandardPaths::Get().SetFileLayout(wxStandardPathsBase::FileLayout_XDG);
24 #endif
26  tileset.load();
27 
28  auto add_icon = [](wxIconBundle& bundle, const void* data, size_t size) {
29  wxMemoryInputStream input_stream(data, size);
30  bundle.AddIcon(input_stream, wxBITMAP_TYPE_PNG);
31  };
32  add_icon(this->app_icon, resources_appicon_16_png, resources_appicon_16_png_size);
33  add_icon(this->app_icon, resources_appicon_64_png, resources_appicon_64_png_size);
34  add_icon(this->app_icon, resources_appicon_256_png, resources_appicon_256_png_size);
35 
36  this->game_frame = new GameFrame(nullptr, wxID_ANY);
37  this->game_frame->Centre();
38  this->game_frame->Show();
39 
40  return true;
41 }
wxIconBundle app_icon
Definition: main.hh:16
virtual bool OnInit() override
Definition: main.cc:18
GameFrame * game_frame
Definition: main.hh:18
TilesetHelper tileset
Definition: main.hh:17
void load()
Definition: tileset.cc:12
void SetAppName(const wxString &name)
virtual bool OnInit()
void Centre(int direction=wxBOTH)
void AddIcon(const wxString &file, wxBitmapType type=wxBITMAP_TYPE_ANY)
static void AddHandler(wxImageHandler *handler)
static wxStandardPaths & Get()
void SetFileLayout(FileLayout layout)
virtual bool Show(bool show=true)
wxID_ANY
wxBITMAP_TYPE_PNG
wxIMPLEMENT_APP(PenguinsApp)