Skip to content

Commit

Permalink
openmw-cn: v11
Browse files Browse the repository at this point in the history
  • Loading branch information
dwing4g committed Jan 25, 2025
1 parent 6bf5622 commit dd4d67f
Show file tree
Hide file tree
Showing 30 changed files with 1,854 additions and 1,549 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
fail-fast: true
matrix:
image:
- "2019"
# - "2019"
- "2022"

uses: ./.github/workflows/windows.yml
Expand Down
27 changes: 21 additions & 6 deletions apps/openmw/mwgui/journalbooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include "textcolours.hpp"

#include "../mwdialogue/quest.hpp"

namespace
{
struct AddContent
Expand Down Expand Up @@ -72,17 +74,30 @@ namespace
{
}

void operator()(MWGui::JournalViewModel::JournalEntry const& entry)
void operator()(MWGui::JournalViewModel::JournalEntry const& entry, const MWDialogue::Quest* quest)
{
if (mAddHeader)
{
mTypesetter->write(mHeaderStyle, entry.timestamp());
mTypesetter->lineBreak();
}

if (quest)
{
auto questName = quest->getName();
if (!questName.empty())
{
intptr_t id = -reinterpret_cast<intptr_t>(quest);
auto style = mTypesetter->createHotStyle(mBodyStyle, MyGUI::Colour(0.60f, 0.00f, 0.00f),
MyGUI::Colour(0.70f, 0.10f, 0.10f), MyGUI::Colour(0.80f, 0.20f, 0.20f), id);
mTypesetter->write(style, MWGui::to_utf8_span(questName)); // mHeaderStyle
mTypesetter->lineBreak();
}
}

AddEntry::operator()(entry);

mTypesetter->sectionBreak(30);
mTypesetter->sectionBreak(10);
}
};

Expand All @@ -109,7 +124,7 @@ namespace
mTypesetter->selectContent(mContentId);
mTypesetter->write(mBodyStyle, 2, 3); // end quote

mTypesetter->sectionBreak(30);
mTypesetter->sectionBreak(10);
}
};

Expand All @@ -123,7 +138,7 @@ namespace
void operator()(MWGui::JournalViewModel::Utf8Span topicName)
{
mTypesetter->write(mBodyStyle, topicName);
mTypesetter->sectionBreak();
mTypesetter->sectionBreak(10);
}
};

Expand All @@ -137,7 +152,7 @@ namespace
void operator()(MWGui::JournalViewModel::Utf8Span topicName)
{
mTypesetter->write(mBodyStyle, topicName);
mTypesetter->sectionBreak();
mTypesetter->sectionBreak(10);
}
};
}
Expand Down Expand Up @@ -199,7 +214,7 @@ namespace MWGui

mModel->visitTopicName(topicId, AddTopicName(typesetter, header));

intptr_t contentId = typesetter->addContent(to_utf8_span(", \""));
intptr_t contentId = typesetter->addContent(to_utf8_span(": \""));

mModel->visitTopicEntries(topicId, AddTopicEntry(typesetter, body, header, contentId));

Expand Down
35 changes: 21 additions & 14 deletions apps/openmw/mwgui/journalviewmodel.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "journalviewmodel.hpp"
#include "journalviewmodel.hpp"

#include <map>

Expand Down Expand Up @@ -256,13 +256,13 @@ namespace MWGui
{
if (timestamp_buffer.empty())
{
std::string dayStr = MyGUI::LanguageManager::getInstance().replaceTags("#{sDay}");
// std::string dayStr = MyGUI::LanguageManager::getInstance().replaceTags("#{sDay}");

std::ostringstream os;

os << itr->mDayOfMonth << ' '
<< MWBase::Environment::get().getWorld()->getTimeManager()->getMonthName(itr->mMonth) << " ("
<< dayStr << " " << (itr->mDay) << ')';
os << MWBase::Environment::get().getWorld()->getTimeManager()->getMonthName(itr->mMonth)
<< " " << itr->mDayOfMonth
<< "日 (第" << itr->mDay << "天)";

timestamp_buffer = os.str();
}
Expand All @@ -272,39 +272,46 @@ namespace MWGui
};

void visitJournalEntries(
std::string_view questName, std::function<void(JournalEntry const&)> visitor) const override
std::string_view questName, std::function<void(JournalEntry const&, const MWDialogue::Quest*)> visitor) const override
{
MWBase::Journal* journal = MWBase::Environment::get().getJournal();

if (!questName.empty())
// if (!questName.empty())
{
std::vector<MWDialogue::Quest const*> quests;
for (MWBase::Journal::TQuestIter questIt = journal->questBegin(); questIt != journal->questEnd();
++questIt)
{
if (Misc::StringUtils::ciEqual(questIt->second.getName(), questName))
if (questName.empty() || Misc::StringUtils::ciEqual(questIt->second.getName(), questName))
quests.push_back(&questIt->second);
}

for (MWBase::Journal::TEntryIter i = journal->begin(); i != journal->end(); ++i)
{
bool visited = false;
for (std::vector<MWDialogue::Quest const*>::iterator questIt = quests.begin();
questIt != quests.end(); ++questIt)
{
MWDialogue::Quest const* quest = *questIt;
for (MWDialogue::Topic::TEntryIter j = quest->begin(); j != quest->end(); ++j)
{
if (i->mInfoId == j->mInfoId)
visitor(JournalEntryImpl<MWBase::Journal::TEntryIter>(this, i));
{
visitor(JournalEntryImpl<MWBase::Journal::TEntryIter>(this, i),
questName.empty() ? quest : nullptr);
visited = true;
}
}
}
if (!visited && questName.empty())
visitor(JournalEntryImpl<MWBase::Journal::TEntryIter>(this, i), nullptr);
}
}
else
{
for (MWBase::Journal::TEntryIter i = journal->begin(); i != journal->end(); ++i)
visitor(JournalEntryImpl<MWBase::Journal::TEntryIter>(this, i));
}
// else
// {
// for (MWBase::Journal::TEntryIter i = journal->begin(); i != journal->end(); ++i)
// visitor(JournalEntryImpl<MWBase::Journal::TEntryIter>(this, i));
// }
}

void visitTopicName(TopicId topicId, std::function<void(Utf8Span)> visitor) const override
Expand Down
4 changes: 3 additions & 1 deletion apps/openmw/mwgui/journalviewmodel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include "bookpage.hpp"

#include "../mwdialogue/quest.hpp"

namespace MWGui
{
/// View-Model for the journal GUI
Expand Down Expand Up @@ -81,7 +83,7 @@ namespace MWGui
/// walks over the journal entries related to all quests with the given name
/// If \a questName is empty, simply visits all journal entries
virtual void visitJournalEntries(
std::string_view questName, std::function<void(JournalEntry const&)> visitor) const = 0;
std::string_view questName, std::function<void(JournalEntry const&, const MWDialogue::Quest*)> visitor) const = 0;

/// provides the name of the topic specified by its id
virtual void visitTopicName(TopicId topicId, std::function<void(Utf8Span)> visitor) const = 0;
Expand Down
7 changes: 7 additions & 0 deletions apps/openmw/mwgui/journalwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,13 @@ namespace

void notifyTopicClicked(intptr_t linkId)
{
if (linkId < 0)
{
const auto* quest = reinterpret_cast<const MWDialogue::Quest*>(-linkId);
notifyQuestClicked(std::string(quest->getName()), 0);
return;
}

Book topicBook = createTopicBook(linkId);

if (mStates.size() > 1)
Expand Down
26 changes: 14 additions & 12 deletions apps/openmw/mwgui/savegamedialog.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "savegamedialog.hpp"
#include "savegamedialog.hpp"

#include <iomanip>
#include <sstream>
Expand Down Expand Up @@ -411,7 +411,7 @@ namespace MWGui

std::stringstream text;

text << Misc::fileTimeToString(mCurrentSlot->mTimeStamp, "%Y.%m.%d %T") << "\n";
text << Misc::fileTimeToString(mCurrentSlot->mTimeStamp, "%Y-%m-%d %T") << "\n";

if (mCurrentSlot->mProfile.mMaximumHealth > 0)
text << "#{OMWEngine:Health} " << static_cast<int>(mCurrentSlot->mProfile.mCurrentHealth) << "/"
Expand All @@ -420,20 +420,22 @@ namespace MWGui
text << "#{OMWEngine:Level} " << mCurrentSlot->mProfile.mPlayerLevel << "\n";
text << "#{sCell=" << mCurrentSlot->mProfile.mPlayerCellName << "}\n";

int hour = int(mCurrentSlot->mProfile.mInGameTime.mGameHour);
bool pm = hour >= 12;
if (hour >= 13)
hour -= 12;
if (hour == 0)
hour = 12;
float iHour;
float fHour = modf(mCurrentSlot->mProfile.mInGameTime.mGameHour, &iHour);
// bool pm = hour >= 12;
// if (hour >= 13)
// hour -= 12;
// if (hour == 0)
// hour = 12;

if (mCurrentSlot->mProfile.mCurrentDay > 0)
text << "#{Calendar:day} " << mCurrentSlot->mProfile.mCurrentDay << "\n";
text << "" << mCurrentSlot->mProfile.mCurrentDay << "\n";

text << mCurrentSlot->mProfile.mInGameTime.mDay << " "
<< MWBase::Environment::get().getWorld()->getTimeManager()->getMonthName(
text << "3E " << mCurrentSlot->mProfile.mInGameTime.mYear
<< "" << MWBase::Environment::get().getWorld()->getTimeManager()->getMonthName(
mCurrentSlot->mProfile.mInGameTime.mMonth)
<< " " << hour << " " << (pm ? "#{Calendar:pm}" : "#{Calendar:am}");
<< " " << mCurrentSlot->mProfile.mInGameTime.mDay
<< "" << int(iHour) << ":" << std::setw(2) << std::setfill('0') << int(fHour * 60); // << (pm ? "#{Calendar:pm}" : "#{Calendar:am}");

if (mCurrentSlot->mProfile.mTimePlayed > 0)
{
Expand Down
24 changes: 13 additions & 11 deletions apps/openmw/mwgui/waitdialog.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "waitdialog.hpp"
#include "waitdialog.hpp"

#include <MyGUI_InputManager.h>
#include <MyGUI_ProgressBar.h>
Expand Down Expand Up @@ -157,18 +157,20 @@ namespace MWGui

const MWWorld::DateTimeManager& timeManager = *MWBase::Environment::get().getWorld()->getTimeManager();
std::string_view month = timeManager.getMonthName();
int hour = static_cast<int>(timeManager.getTimeStamp().getHour());
bool pm = hour >= 12;
if (hour >= 13)
hour -= 12;
if (hour == 0)
hour = 12;
float iHour;
float fHour = modf(timeManager.getTimeStamp().getHour(), &iHour);
// bool pm = hour >= 12;
// if (hour >= 13)
// hour -= 12;
// if (hour == 0)
// hour = 12;

ESM::EpochTimeStamp currentDate = timeManager.getEpochTimeStamp();
std::string daysPassed = Misc::StringUtils::format("(#{Calendar:day} %i)", timeManager.getTimeStamp().getDay());
std::string_view formattedHour(pm ? "#{Calendar:pm}" : "#{Calendar:am}");
std::string dateTimeText
= Misc::StringUtils::format("%i %s %s %i %s", currentDate.mDay, month, daysPassed, hour, formattedHour);
// std::string daysPassed = Misc::StringUtils::format("(#{Calendar:day} %i)", timeManager.getTimeStamp().getDay());
// std::string_view formattedHour(pm ? "#{Calendar:pm}" : "#{Calendar:am}");
std::string dateTimeText = Misc::StringUtils::format("3E %i年 %s %i日 (第%i天) %i:%02i",
currentDate.mYear, month, currentDate.mDay, timeManager.getTimeStamp().getDay(),
static_cast<int>(iHour), static_cast<int>(fHour * 60));
mDateTimeText->setCaptionWithReplacing(dateTimeText);
}

Expand Down
8 changes: 4 additions & 4 deletions apps/openmw/mwinput/bindingsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,13 +555,13 @@ namespace MWInput
switch (wheel)
{
case ICS::InputControlSystem::MouseWheelClick::UP:
return "Mouse Wheel Up";
return "#{sMouseWheelUpShort}";
case ICS::InputControlSystem::MouseWheelClick::DOWN:
return "Mouse Wheel Down";
return "#{sMouseWheelDownShort}";
case ICS::InputControlSystem::MouseWheelClick::RIGHT:
return "Mouse Wheel Right";
return "鼠标滚轮向右";
case ICS::InputControlSystem::MouseWheelClick::LEFT:
return "Mouse Wheel Left";
return "鼠标滚轮向左";
default:
return "#{Interface:None}";
}
Expand Down
4 changes: 4 additions & 0 deletions components/debug/debugging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,9 @@ namespace Debug
#endif

int ret = 0;
#if defined(NDEBUG)
try
#endif
{
if (const auto env = std::getenv("OPENMW_DISABLE_CRASH_CATCHER");
env == nullptr || Misc::StringUtils::toNumeric<int>(env, 0) == 0)
Expand All @@ -459,6 +461,7 @@ namespace Debug
else
ret = innerApplication(argc, argv);
}
#if defined(NDEBUG)
catch (const std::exception& e)
{
#if (defined(__APPLE__) || defined(__linux) || defined(__unix) || defined(__posix))
Expand All @@ -470,6 +473,7 @@ namespace Debug

ret = 1;
}
#endif

// Restore cout and cerr
std::cout.rdbuf(rawStdout->rdbuf());
Expand Down
2 changes: 1 addition & 1 deletion components/lua/l10n.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace
{
// Argument values
if (value.is<std::string>())
args.push_back(icu::Formattable(LuaUtil::cast<std::string>(value).c_str()));
args.push_back(icu::Formattable(icu::UnicodeString::fromUTF8(LuaUtil::cast<std::string>(value).c_str())));
// Note: While we pass all numbers as doubles, they still seem to be handled appropriately.
// Numbers can be forced to be integers using the argType number and argStyle integer
// E.g. {var, number, integer}
Expand Down
8 changes: 7 additions & 1 deletion components/misc/strings/algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
#include <string>
#include <string_view>

namespace Translation
{
int compareStrByPinyin(std::string_view a, std::string_view b);
}

namespace Misc::StringUtils
{
struct CiCharLess
Expand All @@ -24,7 +29,8 @@ namespace Misc::StringUtils

inline bool ciLess(std::string_view x, std::string_view y)
{
return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), CiCharLess());
return Translation::compareStrByPinyin(x, y) < 0;
// return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), CiCharLess());
}

inline bool ciEqual(std::string_view x, std::string_view y)
Expand Down
Loading

0 comments on commit dd4d67f

Please sign in to comment.