Skip to content

Commit

Permalink
Fix minor rwviewer issues
Browse files Browse the repository at this point in the history
  • Loading branch information
danhedron committed May 28, 2019
1 parent 3cdb030 commit 2bb1bea
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
14 changes: 7 additions & 7 deletions rwgame/RWViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ std::vector<std::string> getFontTextureNames(GameData& data) {
std::string filename = p.filename().string();
std::transform(filename.begin(), filename.end(), filename.begin(),
::tolower);
if (!filename.compare("text")) {
if (filename == "text") {
textPath = p;
break;
}
Expand All @@ -54,7 +54,7 @@ std::vector<std::string> getFontTextureNames(GameData& data) {
auto langName = p.filename().string();
std::transform(langName.begin(), langName.end(), langName.begin(),
::tolower);
names.push_back(langName);
names.emplace_back(std::move(langName));
}
return names;
}
Expand Down Expand Up @@ -416,7 +416,7 @@ void TextViewer::cacheStrings() {
auto it = text.second.find(l);
if (it != text.second.end()) {
it->second.second =
GameStringUtil::toString(it->second.first, currentFont_);
GameStringUtil::toString(it->second.first, kFonts[currentFont_]);
}
}
}
Expand Down Expand Up @@ -454,13 +454,13 @@ void TextViewer::draw(GameRenderer& r) {
}
ImGui::Separator();

for (const auto& text : texts_) {
ImGui::Text("%s", text.first.c_str());
for (const auto& [code, text] : texts_) {
ImGui::Text("%s", code.c_str());
ImGui::NextColumn();

for (const auto& l : languages_) {
auto it = text.second.find(l);
if (it != text.second.end()) {
auto it = text.find(l);
if (it != text.end()) {
if (ImGui::Selectable(it->second.second.c_str(), false,
ImGuiSelectableFlags_AllowDoubleClick)) {
if (ImGui::IsMouseDoubleClicked(0)) {
Expand Down
54 changes: 27 additions & 27 deletions rwgame/RWViewer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
#include <set>

class TextViewer {
public:
explicit TextViewer(GameData& data);

void cacheStrings();
void draw(GameRenderer& r);

private:
GameData& data_;
std::vector<std::string> languages_;
Expand All @@ -30,36 +36,9 @@ class TextViewer {
char previewStr_[512] = {};
GameString previewText_;
bool drawPreview_ = true;

public:
explicit TextViewer(GameData& data);

void cacheStrings();
void draw(GameRenderer& r);
};

class RWViewer final : public GameBase {
private:
GameData data_;
GameRenderer renderer_;
GameState state_;
RWImGui imgui_;

std::unique_ptr<GameWorld> world_;

bool continue_ = true;

bool showModelList_ = false;
bool showTextViewer_ = false;
std::optional<TextViewer> textViewer_;
bool showImGuiDemo_ = false;
std::set<ModelID> showModels_;

GameObject* viewedObject_ = nullptr;
glm::vec3 viewParams_{};
enum MouseMode { Hovering, Dragging };
MouseMode mouseMode_ = MouseMode::Hovering;

public:
RWViewer(Logger& log, const std::optional<RWArgConfigLayer>& args);
~RWViewer() override;
Expand Down Expand Up @@ -96,6 +75,27 @@ class RWViewer final : public GameBase {
}

void viewModel(ModelID model);

GameData data_;
GameRenderer renderer_;
GameState state_;
RWImGui imgui_;

std::unique_ptr<GameWorld> world_;

bool continue_ = true;

bool showModelList_ = false;
bool showTextViewer_ = false;
std::optional<TextViewer> textViewer_;
bool showImGuiDemo_ = false;
std::set<ModelID> showModels_;

GameObject* viewedObject_ = nullptr;
glm::vec3 viewParams_{};
enum MouseMode { Hovering, Dragging };
MouseMode mouseMode_ = MouseMode::Hovering;

};

#endif

0 comments on commit 2bb1bea

Please sign in to comment.