mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-07-29 19:18:58 -07:00
Fix crash in Message Viewer when playing with an NTSC OTR. (#5367)
This commit is contained in:
parent
9250af0216
commit
cf75520394
4 changed files with 24 additions and 29 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "soh/SohGui/UIWidgets.hpp"
|
#include "soh/SohGui/UIWidgets.hpp"
|
||||||
#include "soh/SohGui/SohGui.hpp"
|
#include "soh/SohGui/SohGui.hpp"
|
||||||
|
#include "soh/SohGui/SohMenu.h"
|
||||||
#include "soh/OTRGlobals.h"
|
#include "soh/OTRGlobals.h"
|
||||||
|
|
||||||
#include <textures/message_static/message_static.h>
|
#include <textures/message_static/message_static.h>
|
||||||
|
@ -56,22 +57,12 @@ void MessageViewer::DrawElement() {
|
||||||
memset(mTextIdBuf, 0, sizeof(char) * MAX_STRING_SIZE);
|
memset(mTextIdBuf, 0, sizeof(char) * MAX_STRING_SIZE);
|
||||||
}
|
}
|
||||||
PopStyleCheckbox();
|
PopStyleCheckbox();
|
||||||
ImGui::Text("Language");
|
SohGui::SohMenu::UpdateLanguageMap(SohGui::languages);
|
||||||
ImGui::SameLine();
|
UIWidgets::Combobox("Language", &mLanguage, SohGui::languages,
|
||||||
PushStyleCombobox(THEME_COLOR);
|
UIWidgets::ComboboxOptions()
|
||||||
if (ImGui::BeginCombo("##Language", mLanguages[mLanguage])) {
|
.Color(THEME_COLOR)
|
||||||
// ReSharper disable CppDFAUnreachableCode
|
.DefaultIndex(0)
|
||||||
for (size_t i = 0; i < mLanguages.size(); i++) {
|
.Tooltip("Which language to load from the selected text ID"));
|
||||||
if (strlen(mLanguages[i]) > 0) {
|
|
||||||
if (ImGui::Selectable(mLanguages[i], i == mLanguage)) {
|
|
||||||
mLanguage = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ImGui::EndCombo();
|
|
||||||
}
|
|
||||||
PopStyleCombobox();
|
|
||||||
UIWidgets::InsertHelpHoverText("Which language to load from the selected text ID");
|
|
||||||
PushStyleButton(THEME_COLOR);
|
PushStyleButton(THEME_COLOR);
|
||||||
if (ImGui::Button("Display Message##ExistingMessage")) {
|
if (ImGui::Button("Display Message##ExistingMessage")) {
|
||||||
mDisplayExistingMessageClicked = true;
|
mDisplayExistingMessageClicked = true;
|
||||||
|
@ -196,6 +187,11 @@ void MessageDebug_StartTextBox(const char* tableId, uint16_t textId, uint8_t lan
|
||||||
R_TEXT_CHAR_SCALE = 75;
|
R_TEXT_CHAR_SCALE = 75;
|
||||||
R_TEXT_LINE_SPACING = 12;
|
R_TEXT_LINE_SPACING = 12;
|
||||||
R_TEXT_INIT_XPOS = 65;
|
R_TEXT_INIT_XPOS = 65;
|
||||||
|
if (language == LANGUAGE_JPN) {
|
||||||
|
R_TEXT_CHAR_SCALE = 88;
|
||||||
|
R_TEXT_LINE_SPACING = 18;
|
||||||
|
R_TEXT_INIT_XPOS = 65;
|
||||||
|
}
|
||||||
char* buffer = font->msgBuf;
|
char* buffer = font->msgBuf;
|
||||||
msgCtx->textId = textId;
|
msgCtx->textId = textId;
|
||||||
if (strlen(tableId) == 0) {
|
if (strlen(tableId) == 0) {
|
||||||
|
@ -207,10 +203,8 @@ void MessageDebug_StartTextBox(const char* tableId, uint16_t textId, uint8_t lan
|
||||||
constexpr int maxBufferSize = sizeof(font->msgBuf);
|
constexpr int maxBufferSize = sizeof(font->msgBuf);
|
||||||
const CustomMessage messageEntry = CustomMessageManager::Instance->RetrieveMessage(tableId, textId);
|
const CustomMessage messageEntry = CustomMessageManager::Instance->RetrieveMessage(tableId, textId);
|
||||||
font->charTexBuf[0] = (messageEntry.GetTextBoxType() << 4) | messageEntry.GetTextBoxPosition();
|
font->charTexBuf[0] = (messageEntry.GetTextBoxType() << 4) | messageEntry.GetTextBoxPosition();
|
||||||
switch (language) {
|
font->msgLength =
|
||||||
font->msgLength =
|
SohUtils::CopyStringToCharBuffer(buffer, messageEntry.GetForLanguage(language), maxBufferSize);
|
||||||
SohUtils::CopyStringToCharBuffer(buffer, messageEntry.GetForLanguage(language), maxBufferSize);
|
|
||||||
}
|
|
||||||
msgCtx->msgLength = static_cast<int32_t>(font->msgLength);
|
msgCtx->msgLength = static_cast<int32_t>(font->msgLength);
|
||||||
}
|
}
|
||||||
msgCtx->textBoxProperties = font->charTexBuf[0];
|
msgCtx->textBoxProperties = font->charTexBuf[0];
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#include "GuiWindow.h"
|
#include "GuiWindow.h"
|
||||||
#include <array>
|
#include <unordered_map>
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
|
@ -41,7 +41,6 @@ class MessageViewer : public Ship::GuiWindow {
|
||||||
void DisplayCustomMessage() const;
|
void DisplayCustomMessage() const;
|
||||||
|
|
||||||
static constexpr uint16_t MAX_STRING_SIZE = 1024;
|
static constexpr uint16_t MAX_STRING_SIZE = 1024;
|
||||||
static constexpr std::array<const char*, LANGUAGE_MAX> mLanguages = { "English", "German", "French" };
|
|
||||||
static constexpr int HEXADECIMAL = 0;
|
static constexpr int HEXADECIMAL = 0;
|
||||||
static constexpr int DECIMAL = 1;
|
static constexpr int DECIMAL = 1;
|
||||||
char* mTableIdBuf;
|
char* mTableIdBuf;
|
||||||
|
@ -49,7 +48,7 @@ class MessageViewer : public Ship::GuiWindow {
|
||||||
char* mTextIdBuf;
|
char* mTextIdBuf;
|
||||||
uint16_t mTextId;
|
uint16_t mTextId;
|
||||||
int mTextIdBase = HEXADECIMAL;
|
int mTextIdBase = HEXADECIMAL;
|
||||||
size_t mLanguage = LANGUAGE_ENG;
|
int32_t mLanguage = LANGUAGE_ENG;
|
||||||
char* mCustomMessageBuf;
|
char* mCustomMessageBuf;
|
||||||
std::string mCustomMessageString;
|
std::string mCustomMessageString;
|
||||||
bool mDisplayExistingMessageClicked = false;
|
bool mDisplayExistingMessageClicked = false;
|
||||||
|
|
|
@ -28,6 +28,13 @@ void disableBetaQuest();
|
||||||
|
|
||||||
namespace SohGui {
|
namespace SohGui {
|
||||||
|
|
||||||
|
static std::unordered_map<int32_t, const char*> languages = {
|
||||||
|
{ LANGUAGE_ENG, "English" },
|
||||||
|
{ LANGUAGE_GER, "German" },
|
||||||
|
{ LANGUAGE_FRA, "French" },
|
||||||
|
{ LANGUAGE_JPN, "Japanese" },
|
||||||
|
};
|
||||||
|
|
||||||
static const std::unordered_map<int32_t, const char*> menuThemeOptions = {
|
static const std::unordered_map<int32_t, const char*> menuThemeOptions = {
|
||||||
{ UIWidgets::Colors::Red, "Red" },
|
{ UIWidgets::Colors::Red, "Red" },
|
||||||
{ UIWidgets::Colors::DarkRed, "Dark Red" },
|
{ UIWidgets::Colors::DarkRed, "Dark Red" },
|
||||||
|
|
|
@ -14,12 +14,7 @@ namespace SohGui {
|
||||||
|
|
||||||
extern std::shared_ptr<SohMenu> mSohMenu;
|
extern std::shared_ptr<SohMenu> mSohMenu;
|
||||||
using namespace UIWidgets;
|
using namespace UIWidgets;
|
||||||
static const std::unordered_map<int32_t, const char*> languages = {
|
|
||||||
{ LANGUAGE_ENG, "English" },
|
|
||||||
{ LANGUAGE_GER, "German" },
|
|
||||||
{ LANGUAGE_FRA, "French" },
|
|
||||||
{ LANGUAGE_JPN, "Japanese" },
|
|
||||||
};
|
|
||||||
static std::unordered_map<int32_t, const char*> imguiScaleOptions = {
|
static std::unordered_map<int32_t, const char*> imguiScaleOptions = {
|
||||||
{ 0, "Small" },
|
{ 0, "Small" },
|
||||||
{ 1, "Normal" },
|
{ 1, "Normal" },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue