From 531898b0fef9f81e82ad5d5f38d2c627a0c10e56 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 2 May 2023 00:48:03 -0400 Subject: Use Google's style guide --- .clang-format | 2 ++ game_data.cpp | 73 +++++++++++++++++++++++++++++---------------------------- game_data.h | 4 ++-- main.cpp | 2 +- tracker_frame.h | 4 ++-- tracker_panel.h | 4 ++-- 6 files changed, 46 insertions(+), 43 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..8de7fe6 --- /dev/null +++ b/.clang-format @@ -0,0 +1,2 @@ +--- + BasedOnStyle: Google diff --git a/game_data.cpp b/game_data.cpp index db574d3..0ae5468 100644 --- a/game_data.cpp +++ b/game_data.cpp @@ -1,9 +1,10 @@ #include "game_data.h" #include -#include #include +#include + LingoColor GetColorForString(const std::string &str) { if (str == "black") { return LingoColor::kBlack; @@ -33,7 +34,7 @@ GameData::GameData() { YAML::Node lingo_config = YAML::LoadFile("assets/LL1.yaml"); YAML::Node areas_config = YAML::LoadFile("assets/areas.yaml"); - rooms_.reserve(lingo_config.size() + 1); // The +1 is for Menu + rooms_.reserve(lingo_config.size() + 1); // The +1 is for Menu for (const auto &room_it : lingo_config) { int room_id = AddOrGetRoom(room_it.first.as()); @@ -44,49 +45,49 @@ GameData::GameData() { Room &from_room_obj = rooms_[from_room_id]; switch (entrance_it.second.Type()) { - case YAML::NodeType::Scalar: { - // This is just "true". - from_room_obj.exits.push_back({.destination_room = room_id}); - break; - } - case YAML::NodeType::Map: { - Exit exit_obj; - exit_obj.destination_room = room_id; - - if (entrance_it.second["door"]) { - std::string door_room = room_obj.name; - if (entrance_it.second["room"]) { - door_room = entrance_it.second["room"].as(); - } - exit_obj.door = AddOrGetDoor( - door_room, entrance_it.second["door"].as()); + case YAML::NodeType::Scalar: { + // This is just "true". + from_room_obj.exits.push_back({.destination_room = room_id}); + break; } - - from_room_obj.exits.push_back(exit_obj); - break; - } - case YAML::NodeType::Sequence: { - for (const auto &option : entrance_it.second) { + case YAML::NodeType::Map: { Exit exit_obj; exit_obj.destination_room = room_id; - std::string door_room = room_obj.name; - if (option["room"]) { - door_room = option["room"].as(); + if (entrance_it.second["door"]) { + std::string door_room = room_obj.name; + if (entrance_it.second["room"]) { + door_room = entrance_it.second["room"].as(); + } + exit_obj.door = AddOrGetDoor( + door_room, entrance_it.second["door"].as()); } - exit_obj.door = - AddOrGetDoor(door_room, option["door"].as()); from_room_obj.exits.push_back(exit_obj); + break; } + case YAML::NodeType::Sequence: { + for (const auto &option : entrance_it.second) { + Exit exit_obj; + exit_obj.destination_room = room_id; + + std::string door_room = room_obj.name; + if (option["room"]) { + door_room = option["room"].as(); + } + exit_obj.door = + AddOrGetDoor(door_room, option["door"].as()); - break; - } - default: { - // This shouldn't happen. - std::cout << "Error reading game data: " << entrance_it << std::endl; - break; - } + from_room_obj.exits.push_back(exit_obj); + } + + break; + } + default: { + // This shouldn't happen. + std::cout << "Error reading game data: " << entrance_it << std::endl; + break; + } } } diff --git a/game_data.h b/game_data.h index f74f033..761b233 100644 --- a/game_data.h +++ b/game_data.h @@ -64,10 +64,10 @@ struct MapArea { }; class GameData { -public: + public: GameData(); -private: + private: int AddOrGetRoom(std::string room); int AddOrGetDoor(std::string room, std::string door); int AddOrGetPanel(std::string room, std::string panel); diff --git a/main.cpp b/main.cpp index 940fecc..4fbbe72 100644 --- a/main.cpp +++ b/main.cpp @@ -7,7 +7,7 @@ #include "tracker_frame.h" class TrackerApp : public wxApp { -public: + public: virtual bool OnInit() { TrackerFrame *frame = new TrackerFrame(); frame->Show(true); diff --git a/tracker_frame.h b/tracker_frame.h index 60ded2e..59544af 100644 --- a/tracker_frame.h +++ b/tracker_frame.h @@ -8,10 +8,10 @@ #endif class TrackerFrame : public wxFrame { -public: + public: TrackerFrame(); -private: + private: void OnExit(wxCommandEvent &event); void OnAbout(wxCommandEvent &event); }; diff --git a/tracker_panel.h b/tracker_panel.h index 49b4d23..32f7537 100644 --- a/tracker_panel.h +++ b/tracker_panel.h @@ -8,10 +8,10 @@ #endif class TrackerPanel : public wxPanel { -public: + public: TrackerPanel(wxWindow *parent); -private: + private: void OnPaint(wxPaintEvent &event); void Redraw(); -- cgit 1.4.1