diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-02 00:48:03 -0400 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-02 00:48:03 -0400 |
| commit | 531898b0fef9f81e82ad5d5f38d2c627a0c10e56 (patch) | |
| tree | 7e00c98c41f23ae7dca09e3f187ae52497a380b7 | |
| parent | 704c08bb439b9a90f7be2d26a0c8b01777e2cf2c (diff) | |
| download | lingo-ap-tracker-531898b0fef9f81e82ad5d5f38d2c627a0c10e56.tar.gz lingo-ap-tracker-531898b0fef9f81e82ad5d5f38d2c627a0c10e56.tar.bz2 lingo-ap-tracker-531898b0fef9f81e82ad5d5f38d2c627a0c10e56.zip | |
Use Google's style guide
| -rw-r--r-- | .clang-format | 2 | ||||
| -rw-r--r-- | game_data.cpp | 73 | ||||
| -rw-r--r-- | game_data.h | 4 | ||||
| -rw-r--r-- | main.cpp | 2 | ||||
| -rw-r--r-- | tracker_frame.h | 4 | ||||
| -rw-r--r-- | tracker_panel.h | 4 |
6 files changed, 46 insertions, 43 deletions
| diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..8de7fe6 --- /dev/null +++ b/.clang-format | |||
| @@ -0,0 +1,2 @@ | |||
| 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 @@ | |||
| 1 | #include "game_data.h" | 1 | #include "game_data.h" |
| 2 | 2 | ||
| 3 | #include <hkutil/string.h> | 3 | #include <hkutil/string.h> |
| 4 | #include <iostream> | ||
| 5 | #include <yaml-cpp/yaml.h> | 4 | #include <yaml-cpp/yaml.h> |
| 6 | 5 | ||
| 6 | #include <iostream> | ||
| 7 | |||
| 7 | LingoColor GetColorForString(const std::string &str) { | 8 | LingoColor GetColorForString(const std::string &str) { |
| 8 | if (str == "black") { | 9 | if (str == "black") { |
| 9 | return LingoColor::kBlack; | 10 | return LingoColor::kBlack; |
| @@ -33,7 +34,7 @@ GameData::GameData() { | |||
| 33 | YAML::Node lingo_config = YAML::LoadFile("assets/LL1.yaml"); | 34 | YAML::Node lingo_config = YAML::LoadFile("assets/LL1.yaml"); |
| 34 | YAML::Node areas_config = YAML::LoadFile("assets/areas.yaml"); | 35 | YAML::Node areas_config = YAML::LoadFile("assets/areas.yaml"); |
| 35 | 36 | ||
| 36 | rooms_.reserve(lingo_config.size() + 1); // The +1 is for Menu | 37 | rooms_.reserve(lingo_config.size() + 1); // The +1 is for Menu |
| 37 | 38 | ||
| 38 | for (const auto &room_it : lingo_config) { | 39 | for (const auto &room_it : lingo_config) { |
| 39 | int room_id = AddOrGetRoom(room_it.first.as<std::string>()); | 40 | int room_id = AddOrGetRoom(room_it.first.as<std::string>()); |
| @@ -44,49 +45,49 @@ GameData::GameData() { | |||
| 44 | Room &from_room_obj = rooms_[from_room_id]; | 45 | Room &from_room_obj = rooms_[from_room_id]; |
| 45 | 46 | ||
| 46 | switch (entrance_it.second.Type()) { | 47 | switch (entrance_it.second.Type()) { |
| 47 | case YAML::NodeType::Scalar: { | 48 | case YAML::NodeType::Scalar: { |
| 48 | // This is just "true". | 49 | // This is just "true". |
| 49 | from_room_obj.exits.push_back({.destination_room = room_id}); | 50 | from_room_obj.exits.push_back({.destination_room = room_id}); |
| 50 | break; | 51 | break; |
| 51 | } | ||
| 52 | case YAML::NodeType::Map: { | ||
| 53 | Exit exit_obj; | ||
| 54 | exit_obj.destination_room = room_id; | ||
| 55 | |||
| 56 | if (entrance_it.second["door"]) { | ||
| 57 | std::string door_room = room_obj.name; | ||
| 58 | if (entrance_it.second["room"]) { | ||
| 59 | door_room = entrance_it.second["room"].as<std::string>(); | ||
| 60 | } | ||
| 61 | exit_obj.door = AddOrGetDoor( | ||
| 62 | door_room, entrance_it.second["door"].as<std::string>()); | ||
| 63 | } | 52 | } |
| 64 | 53 | case YAML::NodeType::Map: { | |
| 65 | from_room_obj.exits.push_back(exit_obj); | ||
| 66 | break; | ||
| 67 | } | ||
| 68 | case YAML::NodeType::Sequence: { | ||
| 69 | for (const auto &option : entrance_it.second) { | ||
| 70 | Exit exit_obj; | 54 | Exit exit_obj; |
| 71 | exit_obj.destination_room = room_id; | 55 | exit_obj.destination_room = room_id; |
| 72 | 56 | ||
| 73 | std::string door_room = room_obj.name; | 57 | if (entrance_it.second["door"]) { |
| 74 | if (option["room"]) { | 58 | std::string door_room = room_obj.name; |
| 75 | door_room = option["room"].as<std::string>(); | 59 | if (entrance_it.second["room"]) { |
| 60 | door_room = entrance_it.second["room"].as<std::string>(); | ||
| 61 | } | ||
| 62 | exit_obj.door = AddOrGetDoor( | ||
| 63 | door_room, entrance_it.second["door"].as<std::string>()); | ||
| 76 | } | 64 | } |
| 77 | exit_obj.door = | ||
| 78 | AddOrGetDoor(door_room, option["door"].as<std::string>()); | ||
| 79 | 65 | ||
| 80 | from_room_obj.exits.push_back(exit_obj); | 66 | from_room_obj.exits.push_back(exit_obj); |
| 67 | break; | ||
| 81 | } | 68 | } |
| 69 | case YAML::NodeType::Sequence: { | ||
| 70 | for (const auto &option : entrance_it.second) { | ||
| 71 | Exit exit_obj; | ||
| 72 | exit_obj.destination_room = room_id; | ||
| 73 | |||
| 74 | std::string door_room = room_obj.name; | ||
| 75 | if (option["room"]) { | ||
| 76 | door_room = option["room"].as<std::string>(); | ||
| 77 | } | ||
| 78 | exit_obj.door = | ||
| 79 | AddOrGetDoor(door_room, option["door"].as<std::string>()); | ||
| 82 | 80 | ||
| 83 | break; | 81 | from_room_obj.exits.push_back(exit_obj); |
| 84 | } | 82 | } |
| 85 | default: { | 83 | |
| 86 | // This shouldn't happen. | 84 | break; |
| 87 | std::cout << "Error reading game data: " << entrance_it << std::endl; | 85 | } |
| 88 | break; | 86 | default: { |
| 89 | } | 87 | // This shouldn't happen. |
| 88 | std::cout << "Error reading game data: " << entrance_it << std::endl; | ||
| 89 | break; | ||
| 90 | } | ||
| 90 | } | 91 | } |
| 91 | } | 92 | } |
| 92 | 93 | ||
| 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 { | |||
| 64 | }; | 64 | }; |
| 65 | 65 | ||
| 66 | class GameData { | 66 | class GameData { |
| 67 | public: | 67 | public: |
| 68 | GameData(); | 68 | GameData(); |
| 69 | 69 | ||
| 70 | private: | 70 | private: |
| 71 | int AddOrGetRoom(std::string room); | 71 | int AddOrGetRoom(std::string room); |
| 72 | int AddOrGetDoor(std::string room, std::string door); | 72 | int AddOrGetDoor(std::string room, std::string door); |
| 73 | int AddOrGetPanel(std::string room, std::string panel); | 73 | 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 @@ | |||
| 7 | #include "tracker_frame.h" | 7 | #include "tracker_frame.h" |
| 8 | 8 | ||
| 9 | class TrackerApp : public wxApp { | 9 | class TrackerApp : public wxApp { |
| 10 | public: | 10 | public: |
| 11 | virtual bool OnInit() { | 11 | virtual bool OnInit() { |
| 12 | TrackerFrame *frame = new TrackerFrame(); | 12 | TrackerFrame *frame = new TrackerFrame(); |
| 13 | frame->Show(true); | 13 | 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 @@ | |||
| 8 | #endif | 8 | #endif |
| 9 | 9 | ||
| 10 | class TrackerFrame : public wxFrame { | 10 | class TrackerFrame : public wxFrame { |
| 11 | public: | 11 | public: |
| 12 | TrackerFrame(); | 12 | TrackerFrame(); |
| 13 | 13 | ||
| 14 | private: | 14 | private: |
| 15 | void OnExit(wxCommandEvent &event); | 15 | void OnExit(wxCommandEvent &event); |
| 16 | void OnAbout(wxCommandEvent &event); | 16 | void OnAbout(wxCommandEvent &event); |
| 17 | }; | 17 | }; |
| 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 @@ | |||
| 8 | #endif | 8 | #endif |
| 9 | 9 | ||
| 10 | class TrackerPanel : public wxPanel { | 10 | class TrackerPanel : public wxPanel { |
| 11 | public: | 11 | public: |
| 12 | TrackerPanel(wxWindow *parent); | 12 | TrackerPanel(wxWindow *parent); |
| 13 | 13 | ||
| 14 | private: | 14 | private: |
| 15 | void OnPaint(wxPaintEvent &event); | 15 | void OnPaint(wxPaintEvent &event); |
| 16 | 16 | ||
| 17 | void Redraw(); | 17 | void Redraw(); |
